0% found this document useful (0 votes)
107 views

First Order Logic (FOL) : Syntax and Semantics

This document discusses the syntax and semantics of first-order logic (FOL). It covers FOL syntax including variables, function symbols, predicate symbols, terms, and formulas. It also discusses FOL semantics including subformulas, variable binding, and structures which define the interpretation of symbols. Examples are provided to illustrate syntactic components and semantic concepts.

Uploaded by

Adit Dut
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
107 views

First Order Logic (FOL) : Syntax and Semantics

This document discusses the syntax and semantics of first-order logic (FOL). It covers FOL syntax including variables, function symbols, predicate symbols, terms, and formulas. It also discusses FOL semantics including subformulas, variable binding, and structures which define the interpretation of symbols. Examples are provided to illustrate syntactic components and semantic concepts.

Uploaded by

Adit Dut
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

Slideset 4

First Order Logic (FOL)


Syntax and Semantics

Adila Krisnadhi

First Order Logic (FOL)


Syntax and Semantics

CSCE604144 - Logika Komputasional FOL Syntax

Last update: October 10, 2017 FOL Semantics

Semantic
Equivalences

Adila Krisnadhi
Fakultas Ilmu Komputer
Universitas Indonesia
1/27
Slideset 4
Acknowledgement First Order Logic (FOL)
Syntax and Semantics

Adila Krisnadhi

FOL Syntax

FOL Semantics

Semantic
Equivalences

Material in these slides are taken from the lecture manuscript


of Logic for Computer Scientists course authored by Pascal
Hitzler at Wright State University.

2/27
Slideset 4
Outline First Order Logic (FOL)
Syntax and Semantics

Adila Krisnadhi

FOL Syntax

1 FOL Syntax FOL Semantics

Semantic
Equivalences

2 FOL Semantics

3 Semantic Equivalences

3/27
Slideset 4
Difficult/impossible to model using propositional logic First Order Logic (FOL)
Syntax and Semantics

Adila Krisnadhi

FOL Syntax

• For all n ∈ N, n! ≥ n. FOL Semantics

Semantic
• Healthy beings are not dead. Equivalences

• Every cat is alive or dead.


• If somebody owns something, (s)he cares for it.
• A happy cat owner owns a cat and all beings (s)he cares
for are healthy.
• Schrödinger is a happy cat owner.

4/27
Slideset 4
FOL Syntactic components First Order Logic (FOL)
Syntax and Semantics

Adila Krisnadhi

• Variables: x1 , x2 , . . . (also y, z, . . . )
• Function symbols: f1 , f2 , . . . (also g, h, . . . ).
Each function symbol has an arity, which is a natural FOL Syntax

number (0, 1, . . . ) indicating the number of parameters of FOL Semantics

the function symbol. Semantic


Equivalences

• Constants are function symbols with arity 0.


• Predicate symbols or simply predicates: P1 , P2 , . . . (also
Q, R, . . . ).
Each predicate symbol has an arity indicating the number
of parameters of the predicate symbol.
From variables and function symbols, we define terms
inductively as follows:
• Every variable is a term.
• If f is a function symbol of arity k and t1 , . . . , tk are terms,
then f (t1 , . . . , tk ) is also a term.

5/27
Slideset 4
FOL Formula First Order Logic (FOL)
Syntax and Semantics

Adila Krisnadhi

Formulas in first-order logic is defined inductively as follows:


• If P is a predicate symbol with arity k and t1 , . . . , tk are FOL Syntax

terms, then P(t1 , . . . , tk ) is a formula, called atomic formula. FOL Semantics

Semantic
• If F is a formula, then ¬F is a formula. Equivalences

• If F and G are formulas, then (F ∧ G) and (F ∨ G) are


formulas.
• If F is a formula and x is a variable, then ∀xF and ∃xF are
formulas.
Like in propositional logic, we use F → G as a shorthand for
¬F ∨ G, and F ↔ G as a shorthand for (F → G) ∧ (G → F).
• ∀, ∃ are called quantifiers.
• ¬, ∧, ∨, →, ↔ are called connectives

6/27
Slideset 4
Exercise First Order Logic (FOL)
Syntax and Semantics

Adila Krisnadhi

FOL Syntax

FOL Semantics

Semantic
Equivalences

Try representing the sentences in the first slide as first-order


logic formulas.

7/27
Slideset 4
Subformula, variable binding First Order Logic (FOL)
Syntax and Semantics

Adila Krisnadhi

FOL Syntax

FOL Semantics
• If a formula F occurs as a part of a formula G, then we say
Semantic
that F is a subformula of G. Equivalences

• An occurrence of a variable x in a formula F is bound if the


occurrence is within a subformula of F of the form ∀x.G or
∃x.G. Otherwise, the occurrence is free.
• A formula is closed if it does not contain any free variable.
Otherwise, it is open.

8/27
Slideset 4
Exercise First Order Logic (FOL)
Syntax and Semantics

Adila Krisnadhi

FOL Syntax

FOL Semantics

Semantic
Equivalences

• List all subformulas of ∀x(C(x) → (A(x) ∨ D(x)))


• Give an example of a formula which contains both free
and bound occurrences of a variable x.

9/27
Slideset 4
FOL Semantics: Structure First Order Logic (FOL)
Syntax and Semantics

Adila Krisnadhi

A structure is a pair A = (UA , IA ) where UA is a non-empty set


called the ground set or universe, and IA is a mapping that FOL Syntax
maps: FOL Semantics

• every k-ary predicate symbol P to some k-ary relation on Semantic


Equivalences
UA (whenever IA is defined for P)
• every k-ary function symbol f to some k-ary function on
UA (whenever IA is defined for f )
• every variable x to some element of UA (whenever IA is
defined for x).
For readability, we often write PA , instead of IA (P), etc.
• A structure A is suitable for a formula F if IA is defined for
all predicate and function symbols in F and for all free
variables in F.

10/27
Slideset 4
Exercise First Order Logic (FOL)
Syntax and Semantics

Adila Krisnadhi

FOL Syntax

FOL Semantics

Semantic
Give two different suitable structures for the formula below: Equivalences

∀x∀y P(a) ∧ P(x) → P(s(x)) ∧ Q(x, x)



∧ ((P(y) ∧ Q(x, y)) → Q(x, s(y)))

11/27
Slideset 4
FOL Semantics: Value of Terms First Order Logic (FOL)
Syntax and Semantics

Adila Krisnadhi

FOL Syntax

FOL Semantics

Let F be a formula and A = (UA , IA ) a suitable structure for F. Semantic


Equivalences
For each term t in F, define the value of t (written tA ):

• If t = x is a variable, tA = xA .
• If t = f (t1 , . . . , tk ) then tA = f A (t1A , . . . , tkA )

12/27
Slideset 4
FOL Semantics: Truth Value of Formulas First Order Logic (FOL)
Syntax and Semantics

Adila Krisnadhi
For each formula F, define the truth value of F (written A(F))
as follows where A[x/u] is the same as A except xA[x/u] = u.
(
1, if (t1A , . . . , tkA ) ∈ PA
• A(P(t1 , . . . , tk )) =
0, otherwise FOL Syntax

( FOL Semantics

1, if A(G) = 1 and A(H) = 1 Semantic


• A(G ∧ H) = Equivalences

0, otherwise
(
1, if A(G) = 1 or A(H) = 1
• A(G ∨ H) =
0, otherwise
(
1, if A(G) = 0
• A(¬G) =
0, otherwise
(
1, if for all u ∈ UA , A[x/u] (G) = 1
• A(∀xG) =
0, otherwise
(
1, if there exists some u ∈ UA , A[x/u] (G) = 1
• A(∃xG) =
0, otherwise
13/27
Slideset 4
Model, satisfiability, validity, entailment First Order Logic (FOL)
Syntax and Semantics

Adila Krisnadhi

• Let F be a formula and A be a structure suitable for F. If FOL Syntax

A(F) = 1, then A is a model for F or F is true in A, and we FOL Semantics

Semantic
write A |= F. Equivalences

• F is satisfiable if it has a model. Otherwise, F is


unsatisfiable.
• F is valid (or a tautology), written |= F, if every suitable
structure A for F is a model for F.
• A set M = {F1 , . . . , Fk } of formulas is satisfiable if there is
a structure A suitable for all of F1 , . . . , Fk and A is a model
for all of F1 , . . . , Fk . Such an A is said to be a model for M.

14/27
Slideset 4
Entailment, logical consequence First Order Logic (FOL)
Syntax and Semantics

Adila Krisnadhi

• Let M = {F1 , . . . , Fk } be a set of formulas and G a formula.


We say that G is a logical consequence of M, or M entails
G, written M |= G, if every model for M is also a model for
FOL Syntax
G.
FOL Semantics
• If M = {F} is just a set of a single formula, we may Semantic
conveniently write F |= G, instead of {F} |= G. Equivalences

• F is equivalent to G, written F ≡ G, if F |= G and G |= F.

Like in propositional logic, the following theorem holds.


Theorem 9
All three statements below are equivalent:
1 {F1 , . . . , Fk } entails G.
V  
k
2 i=1 F i → G is a tautology.
V  
k
3 i=1 Fi ∧ ¬G is unsatisfiable.

15/27
Slideset 4
Example of Structures and Models I First Order Logic (FOL)
Syntax and Semantics

Adila Krisnadhi

FOL Syntax
Consider the sentences: James is a parent of Harry. Harry is
FOL Semantics
an orphan. Any parent of an orphan is dead.
Semantic
Equivalences
In FOL using parentOf /2, orphan/1, and dead/1 as predicates,
and james/0 and harry/0 as function symbols:

parentOf (james, harry)


∧ orphan(harry)
∧ ∀x∀y(orphan(x) ∧ parentOf (y, x) → dead(y))

16/27
Slideset 4
Example of Structures and Models II First Order Logic (FOL)
Syntax and Semantics

Adila Krisnadhi

Suitable structures for the previous formula (which one is a


FOL Syntax
model for the formula?):
FOL Semantics
• A1 = (UA1 , IA1 ) where Semantic
Equivalences
UA1 = {j, h}, harryA1 = h, jamesA1 = j, orphanA1 = {h},
parentOf A1 = {(j, h)}, deadA1 = {j}
• A2 = (UA2 , IA2 ) where
UA2 = N, harryA2 = 1, jamesA2 = 2, orphanA2 = {1, 3, 4},
parentOf A2 = {(2, 1)}, deadA2 = {1, 2}
• A3 = (UA3 , IA3 ) where
UA3 = N, harryA3 = 1, jamesA3 = 2, orphanA3 = {3, 4, 5},
parentOf A3 = {(1, 2), (3, 1)}, deadA3 = {1, 3, 4}

17/27
Slideset 4
Example of Structures and Models III First Order Logic (FOL)
Syntax and Semantics

Adila Krisnadhi

• A4 = (UA4 , IA4 ) where FOL Syntax

UA4 = {a}, harryA4 = a, jamesA4 = a, orphanA4 = {a}, FOL Semantics

parentOf A4 = {(a, a)}, deadA4 = {a}


Semantic
Equivalences

• A5 = (UA5 , IA5 ) where


UA5 = {j, h}, harryA5 = h, jamesA5 = j, orphanA5 = {h},
parentOf A5 = {(h, j)}, deadA5 = ∅
• A6 = (UA6 , IA6 ) where
UA6 = {j, h}, harryA6 = h, jamesA6 = j, orphanA6 = {h},
parentOf A6 = {(j, h)}, deadA6 = {h}

18/27
Slideset 4
Example of Structures and Models IV First Order Logic (FOL)
Syntax and Semantics

Adila Krisnadhi

FOL Syntax

FOL Semantics

Semantic
Equivalences

Give two structures for the formula F = ∀x∃yP(x, y, f (z)) such


that one is a model for F while the other is not.

19/27
Slideset 4
Example Entailment I First Order Logic (FOL)
Syntax and Semantics

Adila Krisnadhi

FOL Syntax

FOL Semantics

parentOf (james, harry) (1) Semantic


Equivalences
∧ orphan(harry) (2)
∧ ∀x∀y(orphan(x) ∧ parentOf (y, x) → dead(y)) (3)

The formula above entails the following formula (why?):

dead(james)

20/27
Slideset 4
Example Entailment II First Order Logic (FOL)
Syntax and Semantics

Adila Krisnadhi

FOL Syntax

parentOf (fatherOf (harry), harry) (4) FOL Semantics

Semantic
∧ orphan(harry) (5) Equivalences

∀x∀y((orphan(x) ∧ parentOf (y, x)) → dead(y)) (6)

entails (why?)

dead(fatherOf (harry))

21/27
Slideset 4
Example Entailment III First Order Logic (FOL)
Syntax and Semantics

Adila Krisnadhi

FOL Syntax

FOL Semantics
human(harry) (7) Semantic
Equivalences
∧ orphan(harry) (8)
∧ ∀x(human(x) → parentOf (fatherOf (x), x)) (9)
∧ ∀x∀y((orphan(x) ∧ parentOf (y, x)) → dead(y)) (10)

entails (why?)

dead(fatherOf (harry))

22/27
Slideset 4
Example Entailment IV First Order Logic (FOL)
Syntax and Semantics

Adila Krisnadhi

FOL Syntax

FOL Semantics

Semantic
∀x(human(x) → parentOf (fatherOf (x), x)) (11) Equivalences

∧ ∀x∀y((orphan(x) ∧ parentOf (y, x)) → dead(y)) (12)

entails (why?)

∀x((human(x) ∧ orphan(x)) → dead(fatherOf (x)))

23/27
Slideset 4
Propositional Logic vs. FOL First Order Logic (FOL)
Syntax and Semantics

Adila Krisnadhi

• Propositional logic is a fragment of FOL: every formula in


FOL Syntax
propositional logic can be expressed in FOL (in at least
FOL Semantics
two ways):
Semantic
• when every predicate is of arity 0 – thus every predicate can Equivalences

be viewed as an atomic formula in propositional logic


• when no variable is used
• Formulas without quantifier can be transformed into NNF,
CNF, and DNF using transformation algorithms in
propositional logic
• FOL is more powerful than propositional logic, but not the
most powerful. There are logics more powerful than FOL,
e.g., second order predicate logic.

24/27
Slideset 4
Equivalence laws I First Order Logic (FOL)
Syntax and Semantics

For every formula F, G, and H, the following equivalences hold: Adila Krisnadhi

(F ∧ F) ≡ F (Idempotency)
(F ∨ F) ≡ F (Idempotency)
(F ∧ G) ≡ (G ∧ F) (Commutativity of ∧)
FOL Syntax
(F ∨ G) ≡ (G ∨ F) (Commutativity of ∨) FOL Semantics
((F ∧ G) ∧ H) ≡ (F ∧ (G ∧ H)) (Associativity of ∧) Semantic
Equivalences
((F ∨ G) ∨ H) ≡ (F ∨ (G ∨ H)) (Associativity of ∨)
(F ∧ (F ∨ G)) ≡ F (Absorption)
(F ∨ (F ∧ G)) ≡ F (Absorption)
(F ∧ (G ∨ H)) ≡ ((F ∧ G) ∨ (F ∧ H)) (Distributivity)
(F ∨ (G ∧ H)) ≡ ((F ∨ G) ∧ (F ∨ H)) (Distributivity)
¬¬F ≡ F (Double Negation)
¬(F ∧ G) ≡ (¬F ∨ ¬G) (deMorgan’s Laws)
¬(F ∨ G) ≡ (¬F ∧ ¬G) (deMorgan’s Laws)
(F ∨ G) ≡ F, if F is a tautology
(F ∧ G) ≡ G, if F is a tautology
(F ∨ G) ≡ G, if F is unsatisfiable
(F ∧ G) ≡ F, if F is unsatisfiable

25/27
Slideset 4
Equivalence laws II First Order Logic (FOL)
Syntax and Semantics

Adila Krisnadhi

¬∀xF ≡ ∃x¬F (de Morgan’s) FOL Syntax

¬∃xF ≡ ∀x¬F (de Morgan’s) FOL Semantics

(∀xF ∧ ∀xG) ≡ ∀x(F ∧ G) Semantic


Equivalences
(∃xF ∨ ∃xG) ≡ ∃x(F ∨ G)
∀x∀yF ≡ ∀y∀xF
∃x∃yF ≡ ∃y∃xF
∀xF ∧ G ≡ ∀x(F ∧ G) if x does not occur free in G
∀xF ∨ G ≡ ∀x(F ∨ G) if x does not occur free in G
∃xF ∧ G ≡ ∃x(F ∧ G) if x does not occur free in G
∃xF ∨ G ≡ ∃x(F ∨ G) if x does not occur free in G

26/27
Slideset 4
Non-equivalence (be careful!) First Order Logic (FOL)
Syntax and Semantics

Adila Krisnadhi

FOL Syntax

FOL Semantics

Semantic
Show that: Equivalences

(∀xF ∨ ∀xG) 6≡ ∀x(F ∨ G)


(∃xF ∧ ∃xG) 6≡ ∃x(F ∧ G)

27/27

You might also like