Docsity

Predicate Logic in Software Engineering - Prof. Ahmed, Lecture notes of Theory of Formal Languages for Automata

Partial preview of the text

Download Predicate Logic in Software Engineering - Prof. Ahmed and more Lecture notes Theory of Formal Languages for Automata in PDF only on Docsity!

Department of Computer Science,

CUI Lahore Campus

Formal Methods in Software Engineering By Farooq Ahmad

1

Predicate Logic

Predicates, Quantified statements

2

Predicate logic

One of the limitations with the propositional logic is that, while it allows us to argue about individual values, it does not give us the ability to argue about sets of values.

For the purpose of reasoning about sets of values, a more powerful tool than the propositional logic has been devised, namely the predicate logic.

Predicate

A predicate is a truth-valued expression containing free variables.

The variables allow the expression to be evaluated by giving different values to them. Once the variables are evaluated they are said to be bound.

A predicate is a sentence that contains a finite number of variables and becomes a statement when specific values are substituted for the variables.

The domain of a predicate variable is the set of all values that may be substituted in place of the variable.

Example

Let P(x) be the predicate โ€œ x^2 > x โ€ with domain the set R of all real numbers. Write P( 2 ), P( 1/2 ) , and P( โˆ’1/2 ) , and indicate which of these statements are true and which are false.

Example: Truth Set

Let Q(n) be the predicate โ€œ n is a factor of 8.โ€ Find the truth set of Q(n) if

a. the domain of n is the set Z +^ of all positive integers

b. the domain of n is the set Z of all integers.

Solution: a. The truth set is {1 , 2 , 4 , 8} because these are exactly the positive integers that divide 8 evenly.

b. The truth set is {1 , 2 , 4 , 8 , โˆ’1 , โˆ’2 , โˆ’4 , โˆ’8} because the negative integersโˆ’1 , โˆ’2 , โˆ’4,and โˆ’8 also divide into 8 without leaving a remainder.

Let Q(x) be a predicate and D the domain of x. A universal quantified statement is a statement of the form โ€œโˆ€ x โˆˆ D, Q(x).โ€

It is defined to be true if, and only if, Q(x) is true for every x in D. It is defined to be false if, and only if, Q(x) is false for at least one x in D.

A value for x for which Q(x) is false is called a counterexample to the universal statement.

11 Exercise

Example of implicit quantification

17 Different form of universal quantification

Quantified Predicate with free variable

Whether the existential quantification

y: Z โ€ข x = y 2

is true depends only on the choice of a value for x, so x is still

free in the existential quantification.

If we choose 4, it is true; if we choose 73, or -14, it is false.

Therefore, y: Z โ€ข x = y 2 is not a statement but predicate due to

the free variable which is not bounded by the quantifier.

20 Existential quantifier in Z