AI-KRR 4 (First Order Logic)
AI-KRR 4 (First Order Logic)
Deepak Khemani
Department of Computer Science & Engineering
IIT Madras
Sentences, Denotation, and Truth
• A logic is a formal language that defines a set of sentences
{𝛂, 𝛃, 𝛄 …}
• Each sentence has a meaning, ascribed from outside.
• Each sentence has a truth value, ascribed from outside
• Compound sentences have truth values that are determined
completely by its constituents and logical operators
• Logic has a notion of Entailment
• Logic also has Rules of Inference
• Logic has a machinery or algorithms for producing new
sentences from old by applying the rules of inference
• The goal of building the machinery is to mechanically produce
all and only the true sentences (conclusions) – given a set of
true sentences (axioms, premises)
The Socratic Argument is one of the fourteen valid forms of the Syllogism
All Men are Mortal
Socrates is a Man
Therefore, Socrates is Mortal
See https://plato.stanford.edu/entries/aristotle-logic/
Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning
Relations on a Domain
A Domain D or a Universe of Discourse is the ”world” of First Order Logic
Mortal Men
Socrates is mortal
X
Aristotle Rocks
Predicates
Socrates
Unary relations
Man(Socrates)
Man(Aristotle)
Man(X)
Dog(Ted)
Binary relations
Teacher(Socrates, Aristotle)
Pet(Socrates,Ted)
• A set of predicate symbols P = {P1, P2, P3, …}. We also use the symbols {P,
Q, R, …}. More commonly we use words like “Man”, “Mortal”, “GreaterThan”.
Each symbol has an arity associated with it.
• A set of function symbols F = {f1, f2, f3, …}. We commonly used the symbols
{f, g, h…} or words like “Successor” and “Sum”. Each function symbol has an
arity that denotes the number of argument it takes.
• A set of constant symbols C = {c1, c2, c3, …}. We often used symbols like “0”,
or “Socrates”, or “Darjeeling” that are meaningful to us.
The basic constituents of FOL expressions are terms. The set of terms ℑ
of L(P,F,C) is defined as follows. The constants and the variables are
terms by definition. More terms are defined using the function symbols.
If t ∈ V then t ∈ ℑ
If t ∈ C then t ∈ ℑ
If t1, t2, …, tn ∈ ℑ and f ∈ F is an n-place function symbol
then f(t1,t2, …,tn) ∈ ℑ
If α ∈ ℱ then ¬α ∈ ℱ
If α, β ∈ ℱ then (α∧β) ∈ ℱ
If α, β ∈ ℱ then (α∨β) ∈ ℱ
If α, β ∈ ℱ then (α⊃β) ∈ ℱ
We will also use the notation (forall (x) (α)) and (exists (x) (α))
as given in the book Artificial Intelligence by Eugene
Charniak and Drew McDermott.
Makes representation for use in programs simpler.
Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning
List notation
Standard mathematical notation
1. "x (Man(x) É Human(x)) : all men are human beings
2. Happy(suresh) Ú Rich(suresh) : Suresh is rich or happy
3. "x (CitrusFruit(x) É ¬Human(x)) : all citrus fruits are non-human
4. $x (Man(x) Ù Bright(x)) : some men are bright
Example: (forall (x) (and (exists (y) (loves-to-read x y)) (book y))
bound free
(Man(Socrates) ⊃ Mortal(Socrates))
$x (Man(x) ⊃ Mortal(x))
For example,
• colour(lily) = white is true iff both refer to the same colour
• president(usa) = commander(us_army) is true iff both are the same person
• LessThan(5,17) is true iff <5,17> ∈ < relation on Natural Numbers
• Brother(suresh, ramesh) is true iff
<suresh,ramesh> ∈ Brother relation on the set of people
P(a) ⊃ Q(a)
MP
P(a) Q(a)
List notation
1. (if (man ?x) (human ?x))
2. (or (happy suresh) (rich suresh))
3. (if (citrusFruit ?x) (not (human ?x)))
4. (and (man sk-11) (bright sk-11))
For example,
P(?x) ⊃ Q(?x)
MMP q = {<?x, a>}
P(a) Q(a)
Thus if
α = (Sport(tennis) ∧ Likes(Alice, tennis))
β⊃δ = (Sport(?y) ∧ Likes(?x, ?y)) ⊃ Watches(?x, ?y)
Bypassing Conjunction
P(?x,?y) ∧ R(?y)
Most general
conclusion
(SmallerOrEqual 0 ?x)
(SmallerOrEqual 0 7)
(GreaterOrEqual ?x 0)
(GreaterOrEqual ?z 0)
Unify(arg1, arg2)
Return SubUnify(arg1, arg2, ( ))
Skolemization Example
Version 2.4
How to skolemize a formula?
∃t∀u∀x ∃y P(t, u, x) ∧ Q(x, y) ⊃ ∃y R(u, x, y)
Summary
FOL formula ∃t∀u∀x ∃y P(t, u, x) ∧ Q(x, y) ⊃ ∃y R(u, x, y)
Skolem form ∀u∀x∀y ¬P(sk1, u, x) ∨ ¬Q(x, y) ∨ R(u, x, sk2(u, x))
Skolem form ∀u∀x∀y P(sk1, u, x) ∧ Q(x, y) ⊃ R(u, x, sk2(u, x))
Quantifier free form ¬P(sk1, ?u, ?x) ∨ ¬Q(?x, ?y) ∨ R(?u, ?x, sk2(?u, ?x))
Quantifier free form P(sk1, ?u, ?x) ∧ Q(?x, ?y) ⊃ R(?u, ?x, sk2(?u, ?x))
Rewrite connectives
P⊃Q ≡ ¬P ∨ Q ; P≡Q ≡ P⊃Q ∧ Q⊃P ;
Rearrange quantifiers
From high school we know that function parameters like x and t are
dummy variables, i.e., the parameter names do not determine the mean-
ing of a function.
Similarly, in FOL, the bound variables are dummy variables:
∀x[ P(x) ⊃ Q(x) ]
∀t[ P(t) ⊃ Q(t) ]
Therefore, we can rename the dummy variables as long as the original
meaning of the expression is preserved.
g(x) = m ∗ x + c; given function
g(t) = m ∗ t + c; acceptable name change: x → t
g(m) = m ∗ m + c; unacceptable name change: x → m
Renaming x to t preserves the meaning of g, it is an acceptable change,
but renaming x to m changes the meaning, so it is not acceptable.
During skolemization we can rename dummy variables as long as the
original meaning of the expression is preserved.
Also, after skolemization we can rename dummy variables, and there-
fore, the original formula and the skolemized version may carry com-
pletely different variables.
FOL formula: ∃x∀y P(x, y)
Skolem form: P(sk, ?y)
Skolem form: P(sk, ?t)
Skolem form: P(sk, ?x)