Crash course in First Order Logic

Crash course in First Order Logic
Raphaël Carroy
Università di Torino
Marseille, France
Octobre 2013
1/32
What is this all about?
We want to formalize a framework in which all mathematics could
be done.
What does maths do? For instance, study provable properties of a
given structure, as the integers or the reals. Ideally a structure is
exactly caracterized by a simple list of definable properties of
its elements. Here,
exactly caracterized means up to isomorphism, and
definable properties means formulae in a specified language
Problem.
Is it possible to find a list of axioms concerning the reals that are
valid up to isomorphism only in the real line?
2/32
What is this all about?
To address this question we need to define properly what we mean
by isomorphism, formulae and valid. This is what modern logic
does, and the starting point is the separation between syntax and
semantics.
Syntax handles:
What a language is,
What a sentence is,
What a proof is.
Semantics handles:
What a structure is,
What a morphism is,
When does a sentence
hold in a structure.
The very nice feature of FOL is the exact adequacy between these
two sides.
3/32
Syntax: the language
A first-order language consists in two parts, a logical part which is
the same in every language, and a symbolic part which can vary.
The logical part
Boolean connectives: ∧, ∨, ¬, →, ↔
Quantifiers: ∀, ∃
An infinite (countable) set of variables
x , y , z, x0 , x1 , · · ·
Parentheses: ()
The symbol for the equality relation =.
The symbolic part
Constant symbols, ex: 0, π, e, 1, · · ·
Function symbols with different arities, ex:
+, cos, · · ·
Relation symbols with different arities, ex:
<, ∈, ∼
=, · · · .
We often give only the symbolic part of a first-order language.
4/32
Syntax: example of the language of groups
The symbolic part of language of groups consists in:
A binary function symbol ?,
A constant symbol e.
The binary function symbol stands for the group operation and the
constant stands for the neutral element.
Remarks
1
We gave the symbolic part, but the logical part is also there.
2
We could have added the unary operation inverse.
3
Everything can be done only with the binary operation ?!
4
The only predicate symbol of this language is =.
5/32
Syntax: example of the axioms of groups
Here are three formulae in the language of groups.
1
ϕ0 : ∀x ∀y ∀z ((x ? y ) ? z = x ? (y ? z)),
2
ϕ1 : ∀x ∃y (x ? y = e),
3
ϕ2 : ∀x (x ? e = x ).
The formula ϕ0 expresses the associativity of the group operation,
ϕ1 the existence of a right inverse and ϕ2 the existence of the
neutral element. Together they form the axioms of group theory.
Warning
We do not give here the formal definition of a formula! It is made
by induction and uses trees. Instead, we walk through it to show
that the sequences of symbols above are indeed formulae.
6/32
Syntax: formula and terms, general idea
Which are the strings of symbols that form a formula? Could
we run a computer program to sort them out?
We need to decompose a formula. But what are the simplest
possible formulae? Where do we stop?
The simplest formulae are the atomic ones, without
quantifiers or connectives. What do they apply to?
Variables, constants, images of variables by a function...
These strings of symbols are terms. They bear no meaning,
and are just names for elements. These are the first we need
to define.
7/32
Syntax: formula and terms, on an example
We first have to check that the terms are correctly built.
variables and constant are terms.
if t, t 0 are terms, so is (t ? t 0 )
So here we have step one:
1
ϕ0 : ∀x ∀y ∀z ((x ? y ) ? z = x ? (y ? z)),
2
ϕ1 : ∀x ∃y (x ? y = e),
3
ϕ2 : ∀x (x ? e = x ).
8/32
Syntax: formula and terms, on an example
We first have to check that the terms are correctly built.
variables and constant are terms.
if t, t 0 are terms, so is (t ? t 0 )
So here we have step two:
1
ϕ0 : ∀x ∀y ∀z ((x ? y ) ? z = x ? (y ? z)),
2
ϕ1 : ∀x ∃y (x ? y = e),
3
ϕ2 : ∀x (x ? e = x ).
9/32
Syntax: formula and terms, on an example
We first have to check that the terms are correctly built.
variables and constant are terms.
if t, t 0 are terms, so is (t ? t 0 )
And finally step three:
1
ϕ0 : ∀x ∀y ∀z ((x ? y ) ? z = x ? (y ? z)),
2
ϕ1 : ∀x ∃y (x ? y = e),
3
ϕ2 : ∀x (x ? e = x ).
10/32
Syntax: formula and terms, on an example
We then check that the formulae are correctly built.
Relation symbols involving terms are atomic formulae.
When ϕ and ψ are formulae, so are ϕ ∧ ψ, ϕ ∨ ψ, · · ·
When ϕ is a formula so is ∀x (ϕ)
So here we have step one:
1
ϕ0 : ∀x ∀y ∀z ((x ? y ) ? z = x ? (y ? z)),
2
ϕ1 : ∀x ∃y (x ? y = e),
3
ϕ2 : ∀x (x ? e = x ).
11/32
Syntax: formula and terms, on an example
We then check that the formulae are correctly built.
Relation symbols involving terms are atomic formulae.
When ϕ and ψ are formulae, so are ϕ ∧ ψ, ϕ ∨ ψ, · · ·
When ϕ is a formula so is ∀x (ϕ)
So here we have step two:
1
ϕ0 : ∀x ∀y ∀z ((x ? y ) ? z = x ? (y ? z)),
2
ϕ1 : ∀x ∃y (x ? y = e),
3
ϕ2 : ∀x (x ? e = x ).
12/32
Syntax: formula and terms, on an example
We then check that the formulae are correctly built.
Relation symbols involving terms are atomic formulae.
When ϕ and ψ are formulae, so are ϕ ∧ ψ, ϕ ∨ ψ, · · ·
When ϕ is a formula so is ∀x (ϕ)
So here we have step three:
1
ϕ0 : ∀x ∀y ∀z ((x ? y ) ? z = x ? (y ? z)),
2
ϕ1 : ∀x ∃y (x ? y = e),
3
ϕ2 : ∀x (x ? e = x ).
13/32
Syntax: formula and terms, on an example
We then check that the formulae are correctly built.
Relation symbols involving terms are atomic formulae.
When ϕ and ψ are formulae, so are ϕ ∧ ψ, ϕ ∨ ψ, · · ·
When ϕ is a formula so is ∀x (ϕ)
And finaly step four:
1
ϕ0 : ∀x ∀y ∀z ((x ? y ) ? z = x ? (y ? z)),
2
ϕ1 : ∀x ∃y (x ? y = e),
3
ϕ2 : ∀x (x ? e = x ).
14/32
Syntax: Proofs, simplified version
Proofs are defined inductively as well. There are several ways to do
it, we give here a general idea of the definition.
A proof of a formula ϕ from a set of formulae (or theory) Γ is a
finite sequence of formulae that are
either in Γ
deduced from the beginning of the sequence using a finite set
of rules.
Example of rule, R∧ .
If ϕ ∧ ψ figures in the beginning of the sequence then both ϕ and
ψ can figure afterwards. Conversely if both ϕ and ψ figure in the
beginning, ϕ ∧ ψ can figure afterwards.
Definition
When a proof of ϕ from Γ exists, we write Γ ` ϕ.
15/32
Syntax: Proofs, an example in the theory of groups
Instead of giving the rules for all connectives, quantifers and for
the equality, let us now give an example of their use in a proof:
ϕ0 , ϕ1 , ϕ2 ` ∀x ∃y (x ? y = e ∧ y ? x = e).
In words, group theory proves the existence of a two-sided inverse.
16/32
Syntax: Proofs, an example in the theory of groups
(ϕ1 )
(R∃ , R∀ , (1))
(R= , (2))
(ϕ0 , ϕ2 , (3))
(ϕ1 , R∀ )
(R∃ , (5))
(R= , (4), (6))
(ϕ0 , (7))
(R= , (5), (8))
(ϕ2 , (9))
∀x ∃y (x ? y = e)
(1)
x ?y =e
(2)
y ? (x ? y ) = y ? e
(3)
(y ? x ) ? y = y
(4)
0
0
∃y (y ? y = e)
(5)
0
y ?y =e
(6)
0
((y ? x ) ? y ) ? y = e
0
(7)
(y ? x ) ? (y ? y ) = e
(8)
(y ? x ) ? e = e
(9)
y ?x =e
(10)
(R∧ , (2), (10))
x ?y =e∧y ?x =e
(11)
(R∀ , R∃ , (11))
∀x ∃y (x ? y = e ∧ y ? x = e)
(12)
17/32
Transition
What about semantics?
18/32
Semantics: L-structures
Given a first-order language L, an L-structure M is given by:
A set M which we call the domain of M,
for each constant symbol c in L an element c M of M,
for each n-ary function symbol f in L an n-ary function
f M : M n → M,
for each n-ary relation symbol R in L a subset R M of M n .
If L = {e, ?} is the language of groups, here are a few examples of
L-structures:
N = (N, 0, +)
(Z, 1, +)
R = (R, 0, +)
(R, 1, ×)
Z = (Z, 0, +)
(C(R), id, ◦)
19/32
Semantics: Morphisms between L-structures
Given two L-structures M and N, a function σ : M → N is a
L-morphism from M to N if:
for each constant symbol c in L, σ(c M ) = c N ,
for each n-ary function symbol f in L, σ(f M (x̄ )) = f N (x̄ ),
for each n-ary relation symbol R in L, R M (x̄ ) implies
R N (σ(x̄ )).
If L = {e, ?} is the language of groups, here are a few examples of
L-morphisms:
(Z, 0, +) −→ (R, 1, ×)
n 7−→ 2
n
(N, 0, +) −→ (C(R), id, ◦)
n 7−→ (x 7→ x + n)
An isomorphism is a bijective morphism which inverse is also a
morphism.
20/32
Semantics: Validity in L-structures
Validity of a formula ϕ in a L-structure M is defined (once again)
by induction. We give now a general idea of how it is done.
validity for atomic formulae in M is given with M itself.
we say ϕ ∧ ψ is valid in M when both ϕ and ψ are valid in M,
we say that ∀x (ϕ) is valid in M if for every possible value
a ∈ M that can be assigned to the variable x , the formula
ϕ(a) is valid in M.
···
Definition
When ϕ is valid in M we say that M is a model of ϕ and we write
M |= ϕ.
21/32
Semantics: Examples on groups.
Fix L the language of groups, recall the axioms of group theory:
1
ϕ0 : ∀x ∀y ∀z ((x ? y ) ? z = x ? (y ? z)),
2
ϕ1 : ∀x ∃y (x ? y = e),
3
ϕ2 : ∀x (x ? e = x ).
and check whether or not they are valid in each of our examples:
N = (N, 0, +)
(Z, 1, +)
R = (R, 0, +)
(R, 1, ×)
Z = (Z, 0, +)
(C(R), id, ◦)
22/32
Semantics: Examples on groups.
Star with ϕ0 , associativity of the operation.
ϕ0 : ∀x ∀y ∀z ((x ? y ) ? z = x ? (y ? z)).
Addition is associative in N, Z and R, multiplication is associative
in R and composition of functions is associative, so:
N = (N, 0, +) |= ϕ0
(Z, 1, +) |= ϕ0
R = (R, 0, +) |= ϕ0
(R, 1, ×) |= ϕ0
Z = (Z, 0, +) |= ϕ0
(C(R), id, ◦) |= ϕ0
23/32
Semantics: Examples on groups.
Continue with ϕ1 , the existence of an inverse
ϕ1 : ∀x ∃y (x ? y = e).
We have:
N |= ¬(1 + n = 0) for any integer n ∈ N
R |= x + (−x ) = 0 for any real x ∈ R
Z |= n + (−n) = 0 for any n ∈ Z
(Z, 1, +) |= n + (−n + 1) = 1 for any n ∈ Z
(R, 1, ×) |= ∀x (0 × x = 0)
(C(R), id, ◦) |= ∀x (¬(1 ◦ x = id))
24/32
Semantics: Examples on groups.
Continue with ϕ1 , the existence of an inverse
ϕ1 : ∀x ∃y (x ? y = e).
So:
N = (N, 0, +) |= ϕ0 ∧ ¬ϕ1
R = (R, 0, +) |= ϕ0 ∧ ϕ1
Z = (Z, 0, +) |= ϕ0 ∧ ϕ1
(Z, 1, +) |= ϕ0 ∧ ϕ1
(R, 1, ×) |= ϕ0 ∧ ¬ϕ1
(C(R), id, ◦) |= ϕ0 ∧ ¬ϕ1
25/32
Semantics: Examples on groups.
Finish with the neutrality of the distinguished element for the
operation.
ϕ2 : ∀x (x ? e = x ).
By definition 0 is neutral for + in N, Z and R, 1 is neutral for ×
and the identity is neutral for ◦, but
(Z, 1, +) |= ¬(n + 1 = n)foranyn ∈ Z.
So:
N |= ϕ0 ∧ ¬ϕ1 ∧ ϕ2
(Z, 1, +) |= ϕ0 ∧ ϕ1 ∧ ¬ϕ2
R |= ϕ0 ∧ ϕ1 ∧ ϕ2
(R, 1, ×) |= ϕ0 ∧ ¬ϕ1 ∧ ϕ2
Z |= ϕ0 ∧ ϕ1 ∧ ϕ2
(C(R), id, ◦) |= ϕ0 ∧ ¬ϕ1 ∧ ϕ2
26/32
Semantics: Consequence
We now have a notion of semantic consequence:
Definition
Given a first-order language L, a theory Γ and a formula ϕ in L,
we say that ϕ is the semantic consequence of Γ if every model of
Γ is a model of ϕ, and we write Γ |= ϕ.
Every rule for syntactic proof correspond to a point in the very
definition of validity so we have indeed
Fact
Γ ` ϕ implies Γ |= ϕ.
Hence every element of any group has a two-sided inverse.
27/32
Semantics: Consequence, example in groups
In any group, the neutral element is two-sided neutral:
Proposition
ϕ0 , ϕ1 , ϕ2 |= ∀x (e ? x = x )
Proof.
Take G = (G, eG , ?G ) any group, and g any element of G. Call h
its two-sided inverse. Then we have
eG ?G g = (g ?G h) ?G g = g ?G (h ?G g) = g ?G eG = g.
28/32
Gödel’s completeness Theorem.
Given a language L and a theory Γ, we say that Γ is consistent if it
has a model. It is incoherent if Γ ` ϕ ∧ ¬ϕ for some L-formula ϕ.
Theorem
Γ is consistent if and only if it is coherent.
Equivalently, for any formula ϕ we have
Γ ` ϕ iff Γ |= ϕ.
As consequence, we have for groups
ϕ0 , ϕ1 , ϕ2 ` ∀x (e ? x = x ).
29/32
Applications: Complete theories.
Definition
Given a language L and a theory Γ in it, we say that Γ is
complete if for any formula ϕ either Γ ` ϕ or Γ ` ¬ϕ.
A complete coherent theory Γ is maximal among coherent theories,
since for any ϕ ∈
/ Γ we have ¬ϕ ∈ Γ so Γ ∪ {ϕ} ` ϕ ∧ ¬ϕ so it is
incoherent.
Fact
Group theory is incomplete.
Proof.
There are commutative groups and non-commutative groups, so by
the Completeness Theorem we have both
ϕ0 , ϕ1 , ϕ2 6` ∀x ∀y (y ? x = x ? y ) and
ϕ0 , ϕ1 , ϕ2 6` ¬(∀x ∀y (y ? x = x ? y )).
30/32
Applications: Elementary equivalence.
When two structures have the exact same properties definable in L,
Definition
We say that two L-structures M and N are elementary
equivalent and we write M ≡ N if for any L-formula ϕ we have
M |= ϕ iff N |= ϕ.
Using the Completeness Theorem, we get elementary equivalence
as the semantic counterpart of complete theories:
Proposition
A coherent theory Γ is complete iff all models of Γ are elementary
equivalent.
31/32
Applications: Rephrasing the original problem.
We can now rephrase our original problem concerning the reals.
Let L be the language of ordered fields, so L = {e0 , e1 , ?+ , ?× , S}
where e0 , e1 are constant symbols, ?+ and ?× are binary function
symbols and S is a binary relation symbol.
Set R = (R, 0, 1, +, ×, ≤), then
Problem.
Given a L-structure M do we have
R ≡ M implies R ∼
= M?
Short answer, using Completeness: NO!
32/32