Docsity

Predicate Logic-Formal Specification Methods in Software Development-Lecture Slides, Slides of Software Development Methodologies

Partial preview of the text

Download Predicate Logic-Formal Specification Methods in Software Development-Lecture Slides and more Slides Software Development Methodologies in PDF only on Docsity!

Chapter 3

Predicate Logic

Chapter 3: Predicate Logic

  • In this chapter we introduce another part of our logical language.
  • The language of propositions allows us to make statements about specific objects
  • But that does not allow us to describe such as “Every cloud has a silver lining”
  • These are known as universal statements
  • Since they describe properties that must be satisfied by every object in some universe of discourse.

Predicate Logic

Sometimes we wish to state that at least one

thing has a particular property, without necessarily knowing which thing it is. This leads to an existential statement.

Example 3.2 The following are examples of

existential statements:

  1. I heard it from one of your friends.
  2. A mad dog has bitten Andy.
  3. Some people prefer logic.

Predicate Logic

• To formalize such statements, we

require a language that reveals the

internal structure of propositional

statements,

• A language that allows us to take

them apart and apply them to

objects without proper names.

• The language we require is the

language of predicate calculus.

Predicate and Proposition

Example: Construct a predicate and proposition from “_ > 5 ”.

Predicate: The statement “_ > 5 ”, _ is filled by x and the resultant, “x > 5 ”, is called predicate

Note: The statement was filled but still not a proposition. This is because we cannot say whether it is true or false without knowing the value of x.

Proposition: One of the ways to make a proposition out of “x > 5” is as  x    x > 5 (this is proposition)

Predicate Logic

Meanings of:  x    x > 5 (True)

Explanation: Let  = {0, 1, 2, 3,.. .}

The above statement can be written as

0 > 5  1 > 5  2 > 5  3 > 5  4 > 5  ….

Meanings of:  x    x > 5 (False)

Explanation:

This statement can be written as

0 > 5  1 > 5  2 > 5  3 > 5  4 > 5  ….

Formalization using Existential Quantifier

Example 3.2 (2) : Formalize the statement

  • A mad dog has bitten Andy Formalization:
  • Notation: MadDog stand for set of all mad dogs, x bit y mean that x has bitten y.
  • Formal Statement:

 d  MadDog  d bit Andy

Formalization using Existential Quantifier

Example 3.2 (3) : Formalize the statement

  • Some people prefer logic. Formalization:
  • Notation: Person stand for the set of all people, and PL(x) mean that x prefers logic.
  • Formal Statement:

 p  Person  PL(p)

Formalization using Universal Quantifier

Example 3.1 (2): Formalize following statements

  1. Nobody knows the trouble I have seen. Formalization:
  • Notation: Person stand for set of all people, knows_trouble (x) mean that x knows the trouble I have seen
  • Formal Statement:

 p  Person   knows_trouble(p)

Formalization using Universal Quantifier

  1. Jim doesn't know anybody who can sign his

bail application.

  • Notation:

Person stand for set of all people, x Knows y mean that x knows y x CanBail y mean that x can sign y’s application for bail

  • Formal Statement:  pPersonJim Knows

p   (p CanBail Jim)

Useful Equivalences

  1. ( x : a | p  q)  ( x : a  p  q)
  2. ( x : a | p  q)  ( x : a  p  q)
  • Pronunciation:
  •  x : a | p  q is pronounced as “there

exists an x in a satisfying p, such that q”.

  •  x : a | p  q is pronounced “for all x in a

satisfying p, q holds”

Scope of Variable

  1. ( x : a | p  q  r)  s  t
  2. ( y : a | p  q  ( y : b | r  s  t)  u  v)

Dependant Variable has Importance

Example 3.8: Consider the following quantified expression, which states that there is some natural number max such that every natural number num must be less than or equal to max

 max : N  (  num : N  num  max)

This statement is false.

  • By changing the name of the universal quantifier variable from num to max , results confusion

 max : N  (  max : N  max  max)

  • This statement is true; the meaning has changed.

Bound Variable as a Range Variable

Example 3.10: In the expression below, the

first bound variable is used as the range of the second:

 a : b   c : a  p =  a : b  (  c : a  p)

In this case, it would make no sense to merge the two quantifications.