Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL
Logics for Data and Knowledge Representation
- 1. Introduction to First order logic
Luciano Serafini
FBK-irst, Trento, Italy
September 24, 2012
1 / 120
Logics for Data and Knowledge Representation 1. Introduction to - - PowerPoint PPT Presentation
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Logics for Data and Knowledge Representation 1. Introduction to First order logic Luciano Serafini FBK-irst, Trento, Italy September 24, 2012 1 / 120 Why First Order Logic?
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL
FBK-irst, Trento, Italy
1 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL
2 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL
3 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL
4 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL
5 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL
6 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL
7 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL
8 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL
9 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL
10 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL
11 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL
12 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL
13 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL
14 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL
15 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL
16 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL
1
2
3
4
5
6
7
8
17 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL
1
2
3
4
5
6
7
8
18 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
19 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
20 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
21 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
22 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
23 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
24 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
25 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
Example (Language) constants functions (arity) Predicate (arity) Aldo Bruno Carlo MathLogic DataBase 0, 1, . . . , 10 mark (2) best-friend (1) attend (2) friend (2) student (1) course (1) less-than (2) Example (Terms) Intuitive meaning an individual named Aldo the mark 1 Bruno’s best friend anything Bruno’s mark in MathLogic somebody’s mark in DataBase Bruno’s best friend mark in MathLogic term Aldo 1 best-friend(Bruno) x mark(Bruno,MathLogic) mark(x,DataBase) mark(best-friend(Aldo),MathLogic)
26 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
Example (Formulas) Intuitive meaning Bob and Roberto are the same person Carlo is a person and MathLogic is a course Aldo attends MathLogic Courses are attended only by students every course is attended by somebody every student attends a course a student who attends all the courses a course has at least two attenders Aldo’s best friend attend the same courses attended by Aldo best-friend is symmetric Aldo and his best friend have the same mark in MathLogic A student can attend at most two courses Formula Bob = Roberto person(Carlo) ∧ course(MathLogic) attend(Aldo, MathLogic) ∀x(attend(x, y) ⊃ course(y) ⊃ student(x)) ∀x(course(x) ⊃ ∃y attend(y, x)) ∀x(student(x) ⊃ ∃y attend(x, y)) ∃x(student(x) ∧ ∀y(course(y) ⊃ attend(x, y))) ∀x(course(x) ⊃ ∃y∃z (attend(y, x) ∧ attend(z, x) ∧ ¬y = z)) ∀x(attend(Aldo, x) ⊃ attend(best-friend(Aldo), x)) ∀x(best-friend(best-friend(x)) = x) mark(best-friend(Aldo), MathLogic) = mark(Aldo, MathLogic) ∀x∀y∀z∀w(attend(x, y) ∧ attend(x, z)∧ attend(x, w) ⊃ (y = z ∨ z = w ∨ y = w))
27 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
28 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
29 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
30 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
31 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
32 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
33 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
n+1
n+1
34 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
n
n
35 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
36 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
37 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
38 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
39 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
40 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
1
2
3
41 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
I(mother-of(alice))[a] = 3 I(mother-of(x))[a[x/4]] = 5 I(friends(x, y)) = x := y := 1 2 2 1 4 1 1 4 4 2 2 4 4 3 3 4 4 4 I(friends(x, x)) = x := 4 I(friends(x, y) ∧ x = y) = x := y := 4 4 I(∃xfriends(x, y)) = y := 2 1 4 3 I(∀xfriends(x, y)) = y := 4
42 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
43 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
44 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
45 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
46 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
47 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
We’ll come back to this in the next lecture. 48 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
49 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
Proposition The following formulas are valid ∀x(φ(x) ∧ ψ(x)) ≡ ∀xφ(x) ∧ ∀xψ(x) ∃x(φ(x) ∨ ψ(x)) ≡ ∃xφ(x) ∨ ∃xψ(x) ∀xφ(x) ≡ ¬∃x¬φ(x) ∀x∃xφ(x) ≡ ∃xφ(x) ∃x∀xφ(x) ≡ ∀xφ(x) Proposition The following formulas are not valid ∀x(φ(x) ∨ ψ(x)) ≡ ∀xφ(x) ∨ ∀xψ(x) ∃x(φ(x) ∧ ψ(x)) ≡ ∃xφ(x) ∧ ∃xψ(x) ∀xφ(x) ≡ ∃xφ(x) ∀x∃yφ(x, y) ≡ ∃y∀xφ(x, y)
50 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
51 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
52 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
53 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
54 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
55 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
56 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL Syntax and Semantics First Order Theories
Number theory (or Peano Arithmetic) PA L contains the constant symbol 0, the 1-nary function symbol s, (for successor) and two 2-nary function symbol + and ∗
1
0 = s(x)
2
s(x) = s(y) ⊃ x = y
3
x + 0 = x
4
x + s(y) = s(x + y)
5
x ∗ 0 = 0
6
x ∗ s(y) = (x ∗ y) + x
7
the Induction axiom schema: φ(0) ∧ ∀x.(φ(x) ⊃ φ(s(x))) ⊃ ∀x.φ(x), for every formula φ(x) with at least one free variable
= PA if and only if I is isomorphic to the standard models for natural numbers.
57 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
58 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
59 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
60 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
61 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
The truth table method is Exponential The problem of determining if a formula A containing n primitive propositions, is a logical consequence of the empty set, i.e., the problem of determining if A is valid, (| = A), takes an n-exponential number of steps. To check if A is a tautology, we have to consider 2n interpretations in the truth table, corresponding to 2n lines. More efficient algorithms? Are there more efficient algorithms? That is, is it possible to define an algorithm which takes a polinomial number of steps in n, to determine the validity of A? This is an unsolved problem P
?
= NP The existence of a polinomial algorithm for checking validity is still an open problem, even it there are a lot of evidences in favor of non-existence
62 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
63 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
64 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
65 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
66 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
67 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
If A and B are equal, then we know that ⊢ A ⊃ B (see previous example), and by monotonicity Γ ⊢ A ⊃ B. Suppose that A and B are distinct formulas. Let π = (A1, . . . , An = B) be a deduction of Γ, A ⊢ B, we proceed by induction on the length of π. Base case n = 1 If π = (B), then either B ∈ Γ or B is an axiom If B ∈ Γ, then Axiom A1 B ⊃ (A ⊃ B) B ∈ Γ or B is an axiom B by MP A ⊃ B is a deduction of A ⊃ B from Γ or from the empty set, and therefore Γ ⊢ A ⊃ B.
68 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
Step case If An = B is either an axiom or an element of Γ, then we can reason as the previous case. If B is derived by MP form Ai and Aj = Ai ⊃ B. Then, Ai and Aj = Ai ⊃ B, are provable in less then n steps and, by induction hypothesis, Γ ⊢ A ⊃ Ai and Γ ⊢ A ⊃ (A1 ⊃ B). Starting from the deductions of these two formulas from Γ, we can build a deduction of A ⊃ B form Γ as follows: By induction . . . deduction of A ⊃ (Ai ⊃ B) form Γ A ⊃ (Ai ⊃ B) By induction . . . deduction of A ⊃ Ai form Γ A ⊃ Ai A2 (A ⊃ (Ai ⊃ B)) ⊃ ((A ⊃ Ai) ⊃ (A ⊃ B)) MP (A ⊃ Ai) ⊃ (A ⊃ B) MP A ⊃ B
69 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
70 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
71 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
72 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
73 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
74 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
75 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
76 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
77 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
78 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
79 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
80 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
81 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
82 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
83 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
84 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
85 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
86 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
87 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
88 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
89 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
φ ψ φ ∧ ψ ∧I φ ∧ ψ φ φ ∧ ψ ψ ∧E φ φ ∨ ψ ψ φ ∨ ψ ∨I φ ∨ ψ [φ] . . . . θ [ψ] . . . . θ θ ∨E [φ] . . . . ψ φ ⊃ ψ ⊃ I φ φ ⊃ ψ ψ ⊃ E [¬φ] . . . . ⊥ φ ⊥c φ(x) ∀x.φ(x) ∀I ∀x.φ(x) φ(t) ∀E φ(t) ∃x.φ(x) ∃I ∃x.φ(x) [φ(x)] . . . . θ θ ∃E t = t = I φ(t) x = t φ(x) = E 90 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
91 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
92 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
1
2
3
4
5
6
7
8
9
10 ¬(A ⊃ ¬B) ⊢ND (A ∧ B) 11 A ⊃ (B ⊃ C), A ∨ C, ¬B ⊃ ¬A ⊢ND C 93 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
94 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
95 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
96 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
97 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
98 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
99 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
100 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
101 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
102 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
103 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
104 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
105 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
106 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
107 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
108 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
109 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
1
2
3
1
2
110 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
1
2
3
4
5
111 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
112 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
113 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
114 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
115 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
116 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
117 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
118 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
1
2
3
4
5
6
7
8
119 / 120
Why First Order Logic? Syntax and Semantics of FOL Reasoning in FOL General concepts Hilbert style axiomatization Natural Deduction
1
2
3
4
5
6
7
120 / 120