You are on page 1of 44

Chapter 3

First Order Logic

Dr. Abdelaziz Said

1
Chapter 3

First Order Logic

Dr. Abdelaziz Said

2
Contents

1 PL drawbacks

2 Predicate

3 Quantifiers

4 First order logic (FOL)

5 Reasoning in FOL

3
PL drawbacks

❖ The PL is not powerful enough to represent all types


of assertions that are used in computer science and
mathematics.
▪ EX: X > 1

❖ Also PL is not powerful enough to represent certain


types of relationship between propositions such as
equivalence.

"Not all integers are even", "some integers are not even"

4
PL drawbacks

❖ To solve PL drawbacks, we introduce two


new features:

✓ Predicates
✓ Quantifiers

5
Predicate

❖ A predicate: is a verb phrase template that describes a property of


objects, or a relationship among objects represented
by variables , EX:
❖ The car Tom is driving is blue
❖ The sky is blue
❖ The cover of book is blue
❖ The phrase "is blue" is a predicate and it describes the property of
being blue.

❖blue(tom’s car)
❖is_blue(sky)
❖b(book’s cover)

6
Predicate

❖ A predicate: is a verb phrase template that describes a property of


objects, or a relationship among objects represented
by variables , EX:

❖ Ahmed is the parent of Ali


❖ Ahmed gives a book to Ali
❖ The phrase “parent" and the phrase “give ” are predicates describe a
relationship between objects

❖parent(ahmed, ali)
❖give(ahmed, book, ali)

7
Predicate

❖ A predicate with variables called an atomic


formula. P(X)

❖ Every atomic formula has a degree (arity).

8
Predicates with Connectives

❖ If John is a cool man, then kay is a cool man

Cool(john) → Cool(kay)

❖ john is not a cool man

¬ Cool(john)

❖ neither john nor Kay is a cool man

¬ Cool(john)&¬Cool(kay)

9
Quantifiers

❖ A predicate with variables (called an atomic formula)


is not a proposition.

❖ For "x >1" to be a proposition either:

▪ Assign a value to the variable.

▪ Or, quantify the variable using a quantifier.

10
Quantifiers

❖ The universe of discourse is the set of objects of


interest

❖ The universe is the domain of the (individual)


variables

❖ It can be the set of real numbers, the set of


integers, the set of all cars on a parking lot, the
set of all students in a classroom, etc.

11
Quantifiers

Universal Quantifier
❖ The expression: x P(X), denotes the universal
quantification of the atomic formula P(X)

❖ x P(X) translated into the English as:


• "For all x, P(X) holds",
• "for each x, P(X) holds" or
• "for every x, P(X) holds".

❖  is called the universal quantifier,


❖ x means all the objects x in the universe.
❖ It mean that P(X) is true for every object x in the
universe.

12
Quantifiers

Universal Quantifier Vs. & (and)

❖ If all the elements in the universe of discourse can be


listed then the universal quantification x P(X) is
equivalent to the conjunction:

P(x1) & P(x2) & P(x3) & ... P(xn) .

13
Quantifiers

Existential Quantifier
❖ The expression: xP(X), denotes the existential
quantification of the atomic formula P(X).
❖ xP(X) translated into the English as:

• “There exists an x such that P(X) holds" or


• "There is at least one x such that P(X) holds“

❖  is called the existential quantifier,


❖ x means at least one object x in the universe.
❖ It mean that P(X) is true for at least one object x of
the universe.

14
Quantifiers

Existential Quantifier Vs. v (OR)

❖ If all the elements in the universe of discourse can be


listed, then the existential quantification xP(X) is
equivalent to the disjunction:

P(x1) P(x2) P(x3)  ... P(xn).

15
Quantifiers

How to read quantified formulas


P(X) denote: "x is Perfect“
❖ x P(X) translated to:
❑ "For every object x the following holds: x is perfect
❑ "Every thing is perfect”
❖ x P(X) translated to:
❑ "For some object x the following holds: x is perfect“
❑ " Some thing is perfect”
❖  x¬P(X) translated to:
" Every things is not perfect”

16
Quantifiers

How to read quantified formulas


P(X) denote: "x is Perfect“

❖ ¬x P(X) translated to:

“Not every thing is perfect”

❖ P(book) translated to:

“this book is perfect“

17
Quantifiers

❖ Variable in a predicate is said to be bound if either a


specific value is assigned to it or it is quantified.

❖ If variable is not bound, it is called free.

EX ∃x q(X,Y) : Y is free and X is bound

18
Quantifiers

❖ The scope of the quantifier:


▪ The extent of the effect of a quantifier.

▪ It is indicated by square brackets [ ]. If there are no square


brackets, then the scope is understood to be the smallest
wff following the quantification.

▪ Ex:
✓ In ∃x P(x, y), the variable x is bound while y is free.
✓ In  x [∃y P(x, y) v Q(x, y) ]:
x and the y in P(x, y) are bound, while y in Q(x, y) is free,
because the scope of ∃ y is P(x, y) and The scope of  x is
[∃ y P(x, y) v Q(x, y) ].

19
Quantifiers

How to read quantified formulas


L(X,Y) denote: “X likes Y“

❖ x y L(X, Y) translated to:


" Every one Like every one”

❖ x L(X, ali) translated to:

" Every one Like ali”

❖ x y L(X, Y) translated to:

" Every one Like some one”

20
Quantifiers
Translating English to Predicate Logic WFFs

❖ " Ahmed likes every one who Ali likes ”

x [L(ali,X) → L(ahmed,X)]

❖ " Ahmed likes every one who likes him”


x [L(X,ahmed) → L(ahmed,X)]

❖ " Ahmed likes some one who like him”

 x [L(ahmed, X) & L(X, ahmed)]

21
Quantifiers
Translating English to Predicate Logic WFFs:
E(x): x is even , O(x): x is odd
❖ "Not every integer is even"

¬ x E(x)

❖ "Some integers are not even"

 x ¬E(x)

❖ "Some integers are even and some are odd "

 x E(x) Λ  x O(x)

22
Quantifiers
Translating English to Predicate Logic WFFs:
E(x): x is even , O(x): x is odd
❖ "If an integer is not even, then it is odd"

x [¬E(x) → O(x) ]

23
Quantifiers
Translating English to Predicate Logic WFFs:
I(x): x is integer, E(x): x is even , O(x): x is odd
❖ "All integers are even"

x [ I(x) → E(x) ]

❖ "Some integers are odd"

 x [I(x) Λ O(x)]

❖ "Only integers are even" Ξ "if it is even, then it is integer"

 x [ E(x) → I(x) ]

24
First Order Logic (FOL)
Predicate Logic

❖ FOL syntax rules:


1. Every atomic formula is wff
2. If α is a well-formed formula, then so is [α]
3. If α is a well-formed formula, then so is ¬α
4. If α and β are well-formed formulas, then:
α&β ,αvβ, α→β, α↔β:
are wffs.
5. If x is a variable and α is well-formed formula, then:
x α ,  x α
are wffs
6. Nothing else is a wff

25
First order logic (FOL)

Interpretation
❖ A WFF in general not proposition. EX : x P(X)
where P(X) denote: “X is Positive“

❖ Interpretation is the process of determining the universe of


discourse, and the assignment of values to the free variables
EX: IF universe is the set {1,2,3}, the wff is true
IF universe is the set {-1,3,5}, the wff is false

❖ A wff becomes a proposition when it is given an interpretation.

26
First order logic (FOL)

Evaluation
❖ Suppose we have two predicates p(x), q(x,y), and the
universe of discourse is the set {a,b}
❖ Suppose the following truth assignment:
p(a): T p(b): F
q(a,a): T q(b,b): F
q(a,b): F q(b,a): T
❖ The truth assignment for the wff: x [p(X) → q(X,X)] is:

[p(a)→q(a,a) & p(b) →q(b,b)]


[(T →T) & (F → F)]
[ T & (F → F)]
[ T & T]
T
27
First order logic (FOL)

Evaluation
❖ Suppose we have two predicates p(x), q(x,y), and the
universe of discourse is the set {a,b}
❖ Suppose the following truth assignment:
p(a): T p(b): F
q(a,a): T q(b,b): F
q(a,b): F q(b,a): T
❖ The truth assignment for the wff: x y q(X,Y) is:
[y q(a,Y) & y q(b,Y) ]
[ [q(a,a)  q(a,b)] & [q(b,a)  q(b,b)] ]
[ [T F] & [T  F] ]
[ T & [T  F] ]
[T&T]
T
28
First order logic (FOL)

Satisfaction
❖ Suppose we have two predicates p(x), q(x), and the universe
of discourse is the set {a,b}.
❖ The truth table for the wffs:

p(a)  p(b)
x [p(X) → q(X)]
x q(X)

Truth table size:

For a language with n constants and m relation of arity k 29


First order logic (FOL)

❖ A wff is said to be satisfiable if there exists an


interpretation that makes it true.

❖ A wff is valid if it is true for every interpretation.

❖ A wff is unsatisfiable if it is false for every


interpretation.

30
First order logic (FOL)

❖ Equivalence:
➢ Two wffs W1 and W2 are equivalent if and only if W1 ↔
W2 is valid, that is if and only if W1 ↔ W2 is true for all
interpretations.
➢ Ex: x P(x) and ¬x ¬P(x) are equivalent for any
predicate name P.
➢ Also, x [P(x) Λ Q(x)] and x P(x) Λ x Q(x) are
equivalent.

31
Reasoning in FOL

❖Axioms of predicate logic


▪ Universal Instantiation (UI)
▪ Universal Generalization (UG)
▪ Existential Instantiation (EI)
▪ Existential Generalization (EG)
▪ Negation of quantified statement

32
Reasoning in FOL

❖Axioms of predicate logic


(UI):

33
Reasoning in FOL

❖Axioms of predicate logic


(UG):

34
Reasoning in FOL

❖Axioms of predicate logic


(EI):

35
Reasoning in FOL

❖Axioms of predicate logic

(EG):

36
Reasoning in FOL

❖Axioms of predicate logic

Negation of quantified statement

• ¬xP(x) ↔ x¬P(x)
• ¬xP(x) ↔ x¬P(x)

Ex: let P(x) represents x is happy and the universe is the set of
people

There does not exist a person who is happy Ξ everyone is not


happy

37
Reasoning in FOL

consider the following argument:

x[P(X)&G(X)]

xP(X) & x G(X)

❖ Predicates :
▪ P(x): x is Positive
▪ G(x): x is greater than zero
▪ The universe is the set {1,2,3}

38
Reasoning in FOL

1) x[P(X)&G(X)] Premise
2)P(1)&G(1) 3 UI
3) P(1) 2 Simpl.
4) G(1) 2 Simpl.
5) xP(X) 3 UG
6) x G(X) 4 UG
7) xP(X) & x G(X) 5,6 Conj #

39
Reasoning in FOL

A check is void if it has not been cashed for 30 days.


This check has not been cashed for 30 days. You
cannot cash a check which is void. Show that we
now have a check which cannot be cashed.

❖ Predicates :
▪ C(x): x is a check.
▪ T(x): x has been cashed within 30 days.
▪ V(x): x is void.
▪ S(x): x can be cashed.
40
Reasoning in FOL

consider the following argument:


C( this _check)
¬T(this _check)
x [ [C(X)& ¬T(X)] → V(X)]
x [ [C(X)&V(X)] → ¬S(X)]

 x [ C(X)& ¬S(X)]
❖ Predicates :
▪ C(x): x is a check.
▪ T(x): x has been cashed within 30 days.
▪ V(x): x is void.
▪ S(x): x can be cashed.
41
Reasoning in FOL

1) C(this_check) Premise

2) ¬T(this_check) Premise

3) x [ [C(X)& ¬T(X)] → V(X)] Premise


4) x [ [C(X)&V(X)] → ¬S(X)] Premise
5) C(this_check) &¬T(this_check) 1,2 Conj.
6) [C(this_check)& ¬T(this_check)] → V(this_check) 3 UI
7) V(this_check) 5,6 MP
8) C(this_check) & V(this_check) 1,7 Conj.
9) C(this_check)& V(this_check) → ¬S(this_check) 4 UI
10) ¬S(this_check) 9,8 MP
11) C(this_check) & ¬S(this_check) 1,10 Conj.
12) x [ C(X)& ¬S(X)] 11 EG #

42
Assignment_3

Consider this initial configuration for Sukoshi game:

Suppose we have predicates:

❖ Cell(X_coordinate, Y_coordinate ,Value) : to define the value in a given cell


❖ Same(X, Y) : to state that X is the same as Y

Use predicate logic syntax to formalize the following:


a) The Initial configuration for the game.
b) Every cell must contain at least one value.
c) No numeral is repeated in any row or column.
43
Chapter 3

44

You might also like