Professional Documents
Culture Documents
This is a powerful extension of propositional logic. It is the most Propositional logic is quite nice, but not very expressive.
important logic of all. Statements like
• explain predicate logic syntax and semantics carefully • every worker has a boss
• do English–predicate logic translation, and see examples from • there is someone worse off than you
computing
need something more than propositional logic to express.
• generalise arguments and validity from propositional logic to
predicate logic Propositional logic can’t express arguments like this one of De
• consider ways of establishing validity in predicate logic: Morgan:
– truth tables — they don’t work
• A horse is an animal.
– direct argument — very useful
– equivalences — also useful • Therefore, the head of a horse is the head of an animal.
– natural deduction (sorry).
106 107
A quantifier specifies a quantity (of things that have some property). There are just two:
110 111
6.3 Variables
We will use variables to do quantification. We fix an infinite collection
(set) V of variables: eg, x, y, z, u, v, w, x0 , x1 , x2 , . . .
Sometimes I write x or y to mean ‘any variable’.
6.4 Signatures
As well as formulas like Sun(Heron), we’ll write ones like Sun(x).
• Now, to say ‘Everything is a Sun’, we’ll write ∀x Sun(x). Definition 6.1 (signature) A signature is a collection (set) of
This is read as: ‘For all x, x is a Sun’. constants, and relation symbols with specified arities.
• ‘Something is a Sun’, can be written ∃x Sun(x).
Some call it a similarity type, or vocabulary, or (loosely) language.
‘There exists x such that x is a Sun.’
• ‘Frank bought a Sun’, can be written It replaces the collection of atoms we had in propositional logic.
∃x(Sun(x) ∧ bought(Frank, x)). We usually write L to denote a signature. We often write c, d, . . . for
constants, and P, Q, R, S, . . . for relation symbols.
‘There is an x such that x is a Sun and Frank bought x.’
Or: ‘For some x, x is a Sun and Frank bought x.’
See how the new internal structure of atoms is used.
We will now make all of this precise.
112 113
6.5 Terms
114 115
118 119
The structure M
' $
i
y y
Frank human
y
Example of a structure
Susan
PP bought
PP
Below is a diagram of a particular L-structure, called M (say).
P P
i
P
There are 12 objects (the 12 dots) in the domain of M . q
P
y y Clyde
Some are labelled (eg ‘Frank’) to show the meanings of the Tony
M
constants of L (eg Frank). B
B bought
iTexel
The interpretations (meanings) of Sun, human are drawn as regions.
i
B
The interpretation of lecturer is indicated by the black dots. boughtB
The interpretation of bought is shown by the arrows between objects. B Room-308
B
iHeron i
NB
Sun
ic
& %
120 121
Tony or Tony?
Our signature L has only constants and unary and binary relation
constant Tony in L.
symbols.
(I use different fonts, to try to help.)
They are quite different things. Tony is syntactic, while wis semantic.
For this L, we drew an L-structure M by
So TonyM = the object wmarked ‘Tony’. If there were several binary relation symbols in L, we’d have to label
In a different structure, Tony may name (mean) something else. the arrows.
The meaning of a constant c IS the object cM assigned to it by a In general, there’s no easy way to draw interpretations of 3-ary or
structure M . A constant (and any symbol of L) has as many higher-arity relation symbols.
meanings as there are L-structures. 0-ary (nullary) relation symbols are the same as propositional atoms.
122 123
v
says is a Sun. Room-308
v
We write this as M |= Sun(Heron).
Texel
Can read as ‘M says Sun(Heron)’. PP
PP
Warning: This is a quite different use of |= from definition 3.1. Susan P qf
P
human
vc
v
‘|=’ is overloaded. Tony M0
Sun
• Similarly, bought(Susan, Clyde) is true in M . BM Frank
f f
In symbols, M |= bought(Susan, Clyde). PPB
BPPP
124 125
Evaluating formulas with quantifiers
& %
126 127
f= HeronM .
The effect of ‘bought(Tony, x) →’ is to restrict the ∀x to those x that
Tony bought — here, just HeronM .
For this object f, bought(Susan, f) is true in M . So
bought(Tony, f)→bought(Susan, f) is true in M .
There is: we can take (eg.) x to be TonyM .
128 129
Exercise: which are true in M ?
' $
f
v v
Frank 7.3 Truth in a structure — formally!
human
Susan v bought We saw how to evaluate some formulas in a structure. Now we show
P
PPP
qf
how to evaluate arbitrary formulas.
PP ∃x(Sun(x) ∧ bought(Frank, x))
v v
Tony Clyde In propositional logic, we calculated the truth value of a formula in a
bought ∃x(Sun(x) ∧ ∃y bought(y, x))
B
situation by working up through its formation tree — from the atomic
B f
Texel
f
subformulas (leaves) up to the root.
B
bought
∀x(lecturer(x) → human(x))
B Room-308
BN f
For predicate logic, this is not so easy.
f Sun
Not all formulas of predicate logic are true or false in a structure!
fc
Heron
& %
130 131
Example
∀x(bought(Tony, x) → Sun(x)) is true in M (see slide 130). Free and bound variables
132 133
Example Sentences
134 135
Sentences are true or false in a structure. An assignment supplies the missing values of variables.
But non-sentences are not!
What a structure does for constants,
A formula with free variables is neither true nor false in a structure
an assignment does for variables.
M , because the free variables have no meaning in M . It’s like asking
‘is x = 7 true?’ Definition 7.5 (assignment) Let M be a structure. An assignment
(or ‘valuation’) into M is something that allocates an object in
We get stuck trying to evaluate a predicate formula in a structure in
dom(M ) to each variable.
the same way as a propositional one, because the structure does not
For an assignment h and a variable x, we write h(x) for the object
fix the meanings of variables that occur free. They are variables,
assigned to x by h.
after all.
[Formally, h : V → dom(M ) is a function.]
Getting round the problem
So we must specify values for free variables, before evaluating a Given an L-structure M plus an assignment h into M , we can
formula to true or false. evaluate:
This is so even if it turns out that the values do not affect the answer • any L-term, to an object in dom(M ),
(like x = x). • any L-formula, to true or false.
136 137
Example
(1) The value in M under h (below) of the term Tony is the object w
marked ‘Tony’. (From now on, I usually write just ‘Tony’ (or TonyM ,
but NOT Tony) for it.)
' $
Evaluating terms (easy!) (2) The value in M under h of x is Heron.
f
vh(z) v
Definition 7.6 (value of term) Let L be a signature, M an Frank
human
v
L-structure, h an assignment into M , and t an L-term.
Susan PPbought
PP
qf
The value of t in M under h is the object in M allocated to it by:
PP
v vh(y)
• M (if t is a constant) — that is, tM , Tony Clyde M, h
B
bought
f
h(v)
f
• h (if t is a variable) — that is, h(t). B Texel
boughtB
B Room-308
BN f
f Sun
fc
Heron
h(x)
& %
138 139
140 141
7.4 Useful notation for free variables Notation for assignments
The books often write things like Fact 7.9 For any formula A, whether or not M, h |= A only depends
on h(x) for those variables x that occur free in A.
‘Let A(x1 , . . . , xn ) be a formula.’
• So for a formula A(x1 , . . . , xn ), if h(xi ) = ai (each i), it’s OK to
This indicates that the free variables of A are among x1 , . . . , xn . write M |= A(a1 , . . . , an ) instead of M, h |= A.
Note: x1 , . . . , xn should all be different. And not all of them need • Suppose we are explicitly given a formula C, such as
actually occur free in A.
∀x(R(x, y) → ∃yS(y, z)).
Example: if C is the formula
If h(y) = a, h(z) = b, say, we can write
∀x(R(x, y) → ∃yS(y, z)),
M |= ∀x(R(x, a) → ∃yS(y, b))
we could write it as
• C(y, z) instead of M, h |= C. Note: only the free occurrences of y in C
• C(x, z, v, y) are replaced by a. The bound y is unchanged.
• C (if we’re not using the useful notation)
• For a sentence S, we can just write M |= S, because by fact 7.9,
but not as C(x). whether M, h |= S does not depend on h at all.
142 143
Working out |= in this notation Now we do some examples of evaluation. Let’s have a new
L-structure, say N . The black dots are the lecturers. The arrows
Suppose we have an L-structure M , an L-formula A(x, y1 , . . . , yn ), indicate the interpretation in N of the relation symbol bought.
and objects a1 , . . . , an in dom(M ). ' $
v
• To establish that M |= (∀xA)(a1 , . . . , an ) you check that Frank human
Susan v
M |= A(b, a1 , . . . , an ) for each object b in dom(M ).
PP
PP
in M . ‘Not just Frank, Texel, . . . , but all the other fand wtoo.’ qf
You have to check even those b with no constants naming them
P P Clyde N |= ∃x(bought(x, Heron) ∧ x = Susan)?
v
v
Tony
• To establish M |= (∃xA)(a1 , . . . , an ), you try to find some object b B
f f
in the domain of M such that M |= A(b, a1 , . . . , an ). B
N |= ∀x(lecturer(x) → ∃ybought(x, y))?
B Texel
c (‘Every lecturer bought something.’)
B
BN f
Room-308
f Sun
A is simpler than ∀xA or ∃xA. So you can recursively work out if
f
M |= A(b, a1 , . . . , an ), in the same way. The process terminates. Heron
& %
144 145
1. N |= ∃x(bought(x, Heron) ∧ x = Susan)?
Room 308 0 0 0
..
. 0 0 0
146 147
148 149
N |= ∀x(lecturer(x) → ∃y bought(x, y)) ctd
N |= ∀x(lecturer(x) → ∃y bought(x, y)) ctd
Not necessarily.
Reduced table with b just the lecturers: We might have chosen bad ds for Susan and Frank. L(b) is true for
them, so we must try to choose a d that b bought, so that B(b, d) will
b sample d L(b) B(b, d)
be true.
Tony Heron 1 1
And indeed, we can:
Susan Tony 1 0
b d L(b) B(b, d)
Frank Clyde 1 0
other w Clyde 1 1 Tony Heron 1 1
Susan Heron 1 1
Frank Texel 1 1
other w Clyde
We don’t have 1s all down the RH column.
Does this mean N 6|= ∀x(lecturer(x) → ∃y bought(x, y))? 1 1
shows N |= ∀x(lecturer(x) → ∃y bought(x, y)).
150 151
Advice
How do we choose the ‘right’ d in examples like this? We have the
following options: How hard is it?
1. In ∃x or ∀x cases, tabulate all possible values of d. In most practical cases, it’s easy to do the evaluation mentally,
In ∀x∃y cases, etc, tabulate all d for each b: that is, tabulate all without tables, once used to it.
pairs (b, d). But in general, evaluation is hard.
(Very boring; no room to do it above.)
Suppose that N is the natural numbers with the usual meanings of
2. Try to see what properties d should have (above: being bought prime, even, >, +.
by b). Translating into English (see later on) should help. Then
No-one knows whether
go for d with these properties.
3. Guess a few d and see what goes wrong. This may lead you to N |= ∀x(even(x) ∧ x > 2 → ∃y∃z(prime(y) ∧ prime(z) ∧ x = y + z)).
(2).
152 153
Playing G(M, A)
The game starts at the root of the formation tree of A, and works
7.6 Hintikka games down node by node to the leaves. If the current node is:
Working out |= by tables is clumsy. Often you can do the evaluation • ∀x, then (the player labeled) ∀ chooses a value (in dom(M )) for
just by looking. the variable x
• ∃x, then ∃ chooses a value for x
But if it’s not immediately clear whether or not M |= A, it can help to • ∧, then ∀ chooses the next node down
use a game G(M, A) with two players — me and you, say. • ∨, then ∃ chooses the next node down
In G(M, A), M is an L-structure, A is an L-sentence. You are trying • ¬, then we swap labels (∀ and ∃)
to show that M |= A, and I am testing you to see if you can. • →, ↔ — regard A → B as ¬A ∨ B, and A ↔ B as
(A ∧ B) ∨ (¬A ∧ ¬B).
There are two labels, ‘∀’ and ‘∃’.
• an atomic (or quantifier-free) formula, then we stop and evaluate
At the start, I am given the label ∀, and you get label ∃. it in M with the current values of variables.
The player currently labeled ∃ wins the game if it’s true, and the
one labeled ∀ wins if it’s false.
154 155
w
Frank human
Winning strategies
Susan w
P
PPP
A strategy for a player in G(M, A) is just a set of rules telling that
player what to do in any position. PP
P qg Clyde
w
w
Tony
A strategy is winning if its owner wins any play (or match) of the
B N
game in which the strategy is used.
Texel g g
B
B
Theorem 7.10 Let M be an L-structure. Then M |= A if and only if
B c
Room-308
gHeron
BNB
g Sun
you have a winning strategy in G(M, A).
g
So your winning once is not enough for M |= A. You must be able to
& %
win however I play.
The black dots are the lecturers. The arrows indicate the
interpretation in N of the relation symbol bought.
156 157
N |= ∀x∃y(lecturer(x) → bought(x, y))? N |= ∃y∀x(lecturer(x) → bought(x, y))?
∀x ∃x
∃y ∀y
∨ ∨
! aa ! aa
! aa ! aa
!! aa !! aa
!! !!
¬ ¬
bought(x, y) bought(x, y)
lecturer(x) lecturer(x)
158 159
• Some Sun has a buyer: ∃x(Sun(x) ∧ ∃y bought(y, x)). • Only Susan bought Clyde: ∀x(bought(x, Clyde) ↔ x = Susan).
• All buyers are human lecturers: • If Tony bought everything that Susan bought, and Tony bought a
∀x(∃y bought(x, y) → human(x) ∧ lecturer(x)). Sun, then Susan didn’t buy a Sun:
| {z }
x is a buyer ∀x(bought(Susan, x) → bought(Tony, x))
• No lecturer bought a Sun: ∧ ∃y(Sun(y) ∧ bought(Tony, y))
¬∃x(lecturer(x) ∧ ∃y(bought(x, y) ∧ Sun(y))). → ¬∃y(Sun(y) ∧ bought(Susan, y)).
| {z }
x bought a Sun
(This may not be true! But we can still say it.)
162 163
166 167
170 171
' $
of s1 , s2 , . . .). So it looks like:
f
v v
Frank
sort human We need a binary relation symbol boughts,s0 for each pair (s, s0 ) of
Susan v boughth,r
P sorts.
PPP
qf
lecturer (black dots) must be implemented as 2 or 3 relation
PP
v v Clyde
Tony M symbols, because (as in Haskell) each object has only 1 sort, not 2.
bought (Alternative: use sorts for human lecturer, non-human lecturer, etc —
B
fTexel f
h,s
B
sort rest all possible types of object.)
boughth,sB
B
BN f
Room-308
f sort Sun
fc
Heron
& %
174 175
Interpretation of L-symbols
176 177
Precision is vital
0 1 2 ... How about a constant [] : [Nat] for the empty list, and function
symbols
2-sorted (all nos)
• cons : (Nat, [Nat]) → [Nat]
structure
[Nat] • ++ : ([Nat], [Nat]) → [Nat]
M • head : [Nat] → Nat
[] [2] [2,1,3] ...
• tail : [Nat] → [Nat]
(all lists : [Nat]) • ] : [Nat] → Nat
& % • !! : ([Nat], Nat) → Nat
180 181
Problem: tail etc are partial operations Lists in first-order logic: summary
In first-order logic, a structure must provide a meaning for function Now we can define a signature L suitable for lists of type [Nat].
symbols on all possible arguments (of the right sorts). • L has constants 0, 1, . . . : Nat, relation symbols <, ≤, >, ≥ of sort
What is the head or tail of the empty list? What is xs !! ](xs)? What is (Nat,Nat), a constant [] : [Nat], and function symbols +, −, : or
34 − 61? cons, ++, head, tail, ], !!, with sorts as specified 2 slides ago.
Two solutions (for tail): We write the constants as 0, 1,. . . to avoid confusion with actual
1. Choose an arbitrary value (of the right sort) for tail([]), etc. numbers 0, 1, . . . We write symbols in infix notation where
2. Use a relation symbol Rtail([Nat],[Nat]) instead of a function
appropriate.
symbol tail : [Nat] → [Nat]. Make Rtail(xs, ys) true just when
• Let x, y, z, k, n, m . . . be variables of sort Nat, and xs, ys, zs, . . .
ys is the tail of xs. If xs has no tail, Rtail(xs, ys) will be false for
variables of sort [Nat].
all ys.
• Let M be an L-structure in which the objects of sort Nat are the
Similarly for head, !!. E.g., use a function symbol
natural numbers 0, 1, . . . , the objects of sort [Nat] are all
!! : ([Nat], Nat) → Nat, and choose arbitrary value for !!(xs, n) when
possible lists of natural numbers, and the L-symbols are
n ≥ ](xs). Or use a relation symbol !!([Nat], Nat, Nat).
interpreted in the natural way: ++ as concatenation of lists, etc.
We’ll take the function symbol option (1), as it leads to shorter (Define 34 − 61, tail([]), etc. arbitrarily.)
formulas. But we must beware: values of functions on ‘invalid’
See figure, 3 slides ago.
arguments are ‘unpredictable’.
182 183
∀xs(](xs) = 0 ∨ head(xs) = xs!!0) Eg for the function log(x), you’d want a pre-condition of x > 0. For
√
x you’d want x ≥ 0.
∀xs(xs 6= [] → ](tail(xs)) = ](xs) − 1)
∀xs∀n(0 < n ∧ n < ](xs) → xs!!n = tail(xs)!!(n − 1)) Pre-conditions are usually very easy to write:
∀xs∀ys∀zs(xs = ys++zs ↔ • xs is not empty: use xs 6= [].
](xs) = ](ys) + ](zs) ∧ ∀n(n < ](ys) → xs!!n = ys!!n)
∧ ∀n(n < ](zs) → xs!!(n + ](ys)) = zs!!n). • n is non-negative: use n ≥ 0.
184 185
Post-conditions in logic
These express the required connection between the input and output
of a function.
Type information To do post-conditions in logic, you write a formula expressing the
This is not part of the pre-condition. intended value of a function in terms of its arguments.
If there are no restrictions on the arguments beyond their typing The formula should have free variables for the arguments, and
information, you can write ‘none’, or >, as pre-condition. should involve the function call so as to describe the required value.
The formula should be true if and only if the output is as intended.
186 187
Similarly, use \/ for ∨, (A) for ∀, ~ for ¬. But should arrange that M |= ∃zA(a, b, z) whenever a, b meet the
pre-condition: otherwise, the function cannot meet its post-condition.
So need M |= ∀x∀y(pre(x, y) → ∃z post(x, y, z)), for functions of 2
arguments with pre-, post-conditions given by formulas pre, post.
188 189
10.5 Examples Least entry
isin :: Nat -> [Nat] -> Bool ∀n∀m(n < m ∧ m < ](xs) → xs!!n ≤ xs!!m) expresses that list xs is
-- pre: none ordered. So does ∀ys∀zs∀m∀n(xs = ys++(m:(n:zs)) → m≤n).
-- post: isin n xs <--> (E)ys,zs(xs=ys++n:zs) Exercise: specify a function
The code for isin may in the end be very different from the sorted :: [Nat] -> Bool
post-condition(!), but isin should meet its post-condition. that returns true if and only if its argument is an ordered list.
190 191
Merge
Specifying ‘merge’
Informal specification:
merge :: [Nat] -> [Nat] -> [Nat] -> Bool Quite hard to specify explicitly (challenge for you!).
-- pre:none But can write an implicit specification:
-- post:merge(xs,ys,zs) holds when xs, ys are ∀xs∀zs(merge(xs, [], zs) ↔ xs = zs)
-- merged to give zs, the elements of xs and ys ∀ys∀zs(merge([], ys, zs) ↔ ys = zs)
-- remaining in the same relative order. ∀x . . . zs[merge(x:xs, y:ys, z:zs) ↔ (x = z ∧ merge(xs, y:ys, zs)
∨ y = z ∧ merge(x:xs, ys, zs))]
merge([1,2],[3,4,5],[1,3,4,2,5]) and
merge([1,2],[3,4,5],[3,4,1,2,5]) are true. This pins down merge exactly: there exists a unique way to interpret
a 3-ary relation symbol merge in M so that these three sentences are
merge([1,2],[3,4,5],[1]) and
true. So they could form a post-condition.
merge([1,2],[3,4,5],[5,4,3,2,1]) are false.
192 193
Count
Can use merge to specify other things: 11. Arguments, validity
count : Nat -> [Nat] -> Nat Predicate logic is much more expressive than propositional logic. But
-- pre:none our experience with propositional logic tells us how to define ‘valid
-- post (informal): count x xs = number of x’s in xs argument’ etc.
-- post: (E)ys,zs(merge ys zs xs Definition 11.1 (valid argument) Let L be a signature and A1 , . . . ,
-- & (A)n:Nat(in(n,ys) -> n=x) An , B be L-formulas.
-- & (A)n:Nat(in(n,zs) -> n<>x)
An argument ‘A1 , . . . , An , therefore B’ is valid if for any L-structure
-- & count x xs = #ys)
M and assignment h into M ,
Idea: ys takes all the x from xs, and zs takes the rest. So the number if M, h |= A1 , M, h |= A2 , . . . , and M, h |= An , then M, h |= B.
of x is ](ys). We write A1 , . . . , An |= B in this case.
Conclusion
This says: in any situation (structure + assignment) in which
First-order logic is a valuable and powerful way to specify programs A1 , . . . , An are all true, B must be true too.
precisely, by writing first-order formulas expressing their pre- and
Special case: n = 0. Then we write just |= B. It means that B is true
post-conditions.
in every L-structure under every assignment into it.
More on this in 141 ‘Reasoning about Programs’ next term.
194 195
196 197
11.1 Direct reasoning
Let’s show
Useful ways of validating arguments
∀x(lecturer(x) → human(x)), ∃x(lecturer(x) ∧ bought(x, Texel))
In spite of theorem 11.5, we can often verify in practice that an |= ∃x(human(x) ∧ bought(x, Texel)).
argument or formula in predicate logic is valid. Ways to do it include: Take any L-structure M (where L is as before). Assume that
1) M |= ∀x(lecturer(x) → human(x)) and
• direct reasoning (the easiest, once you get used to it)
2) M |= ∃x(lecturer(x) ∧ bought(x, Texel)).
• equivalences (also useful) Show M |= ∃x(human(x) ∧ bought(x, Texel)).
• proof systems like natural deduction So we need to find an a in M such that
M |= human(a) ∧ bought(a, Texel).
The same methods work for showing a formula is valid. (A is valid if
By (2), there is a in M such that
and only if |= A.)
M |= lecturer(a) ∧ bought(a, Texel).
Truth tables no longer work. You can’t tabulate all structures — there So M |= lecturer(a).
are infinitely many. By (1), M |= lecturer(a) → human(a).
So M |= human(a).
So M |= human(a) ∧ bought(a, Texel), as required.
198 199
Another example
Well, by (3), M |= human(a) ∨ Sun(a). So there is an object c in dom(M ) such that M |= R(b, c).
If M |= human(a), then by (1), M |= lecturer(a). Therefore, M |= ∃vR(b, v). We’re done.
Otherwise, M |= Sun(a). Then by (2), M |= lecturer(a).
So either way, M |= lecturer(a), as required.
200 201
Equivalences involving bound variables
34. If x does not occur free in A, then ∀xA and ∃xA are equivalent
11.2 Equivalences to A.
As well as the propositional equivalences seen before, we have extra 35. If x doesn’t occur free in A, then
ones for predicate logic. A, B denote arbitrary predicate formulas. ∃x(A ∧ B) is equivalent to A ∧ ∃xB, and
∀x(A ∨ B) is equivalent to A ∨ ∀xB.
28. ∀x∀yA is logically equivalent to ∀y∀xA.
36. If x does not occur free in A then
29. ∃x∃yA is (logically) equivalent to ∃y∃xA.
∀x(A → B) is equivalent to A → ∀xB.
30. ¬∀xA is equivalent to ∃x¬A. 37. Note: if x does not occur free in B then
31. ¬∃xA is equivalent to ∀x¬A. ∀x(A → B) is equivalent to ∃xA → B.
202 203
204 205
11.3 Natural deduction for predicate logic
Warning: non-equivalences This is quite easy to set up. We keep the old propositional rules —
e.g., A ∨ ¬A for any first-order sentence A (‘lemma’)
Depending on A, B, the following need NOT be logically equivalent — and add new ones for ∀, ∃, =.
(though the first |= the second):
You construct natural deduction proofs as for propositional logic: first
• ∀x(A → B) and ∀xA → ∀xB think of a direct argument, then convert to ND.
• ∃x(A ∧ B) and ∃xA ∧ ∃xB. This is even more important than for propositional logic. There’s
quite an art to it.
• ∀xA ∨ ∀xB and ∀x(A ∨ B).
Validating arguments by predicate ND can sometimes be harder than
Can you find a ‘countermodel’ for each one? (Find suitable A, B and
for propositional ones, because the new rules give you wide choices,
a structure M such that M |= 2nd but M 6|= 1st.)
and at first you may make the wrong ones! If you find this
depressing, remember, it’s a hard problem, there’s no computer
program to do it (theorem 11.5)!
206 207
∀-introduction, ∀I
To introduce the sentence ∀xA, for some A(x), you introduce a new
constant, say c, not used in the proof so far, and prove A(c).
During the proof, you can use anything already established. Justification
But once you’ve proved A(c), you can no longer use the constant c
later on. To show M |= ∀xA, we must show M |= A(a) for every object a in
So isolate the proof of A(c), in a box: dom(M ).
So choose an arbitrary a, add a new constant c naming a, and prove
1 c ∀I const
A(c). As a is arbitrary, this shows ∀xA.
hthe proofi hard struggle
2 A(c) we made it! c must be new, because the constants already in use may not name
3 ∀xA ∀I(1, 2) this particular a.
This is the only time in ND that you write a line (1) containing a term,
not a formula. And it’s the only time a box doesn’t start with a line
labelled ‘ass’.
212 213
Example of ∀-rules
214 215
1 ∃x∀yG(x, y) given Idea: often we have proved ∀x(A(x) → B(x)) and A(t), for some
2 d ∀I const formulas A(x), B(x) and some closed term t.
3 ∀yG(c, y) ass We know we can derive B(t) from this:
4 G(c, d) ∀E(3)
1 ∀x(A(x) → B(x)) (got this somehow)
5 ∃xG(x, d) ∃I(4)
2 A(t) (this too)
6 ∃xG(x, d) ∃E(1, 3, 5)
3 A(t) → B(t) ∀E(1)
7 ∀y∃xG(x, y) ∀I(2, 6)
4 B(t) →E(2, 3)
English: Assume ∃x∀yG(x, y). Then there is some object c such that So let’s just do it in 1 step:
∀yG(c, y).
1 ∀x(A(x) → B(x)) (got this somehow)
So for any object d, we have G(c, d), so certainly ∃xG(x, d). 2 A(t) (this too)
Since d was arbitrary, we have ∀y∃xG(x, y). 3 B(t) ∀→E(2, 1)
216 217
Example of ∀→E in action
Rules for equality
Show ∀x∀y(P (x, y) → Q(x, y)), ∃xP (x, a) ` ∃yQ(y, a).
• Reflexivity of equality (refl).
1 ∀x∀y(P (x, y) → Q(x, y)) given Whenever you feel like it, you can introduce the sentence t = t,
2 ∃xP (x, a) given for any closed L-term t and for any L you like.
3 P (c, a) ass
..
4 Q(c, a) ∀→E(3, 1) . bla bla bla
5 ∃yQ(y, a) ∃I(4) 1 t=t refl
6 ∃yQ(y, a) ∃E(2, 3, 5)
(Idea: any L-structure makes t = t true, so this is sound.)
We used ∀→E on 2 ∀s at once. This is even more useful.
218 219
220 221
Harder example
More examples with equality. . . Show ∃x∀y(P (y) → y = x), ∀xP (f (x)) ` ∃x(x = f (x)).
Now you’ve done sets, relations, and functions in other courses(?), Propositional logic
here’s what an L-structure M really is. • Syntax
Literals, clauses (see Prolog next term!)
It consists of the following items: • Semantics
• a non-empty set, dom(M ) • English–logic translations
• for each constant c ∈ L, • Arguments, validity
an element cM ∈ dom(M ) – †truth tables
• for each n-ary function symbol f ∈ L, an n-ary function – direct reasoning
f M : dom(M )n → dom(M ) – equivalences, †normal forms
• for each n-ary relation symbol R ∈ L, an n-ary relation RM on – natural deduction
dom(M ) — that is, RM ⊆ dom(M )n .
Classical first-order predicate logic
n times same again (except †), plus
z }| {
Recall for a set S, S n is S × S × · · · × S. • Many-sorted logic
• Specifications, pre- and post-conditions (continued in Reasoning
Another name for a relation (symbol) is a predicate (symbol).
about Programs)
224 225
Modern logic at research level
Some of what we didn’t do. . . • Advanced computing uses classical, modal, temporal, and
dynamic logics. Applications in AI, to specify and verify chips, in
• normal forms for first-order logic
databases, concurrent and distributed systems, multi-agent
• proof of soundness or completeness for natural deduction systems, protocols, knowledge representation, . . . Theoretical
computing (complexity, finite model theory) need logic.
• theories, compactness, non-standard models, interpolation
• In mathematics, logic is studied in set theory, model theory,
• Gödel’s theorem
including non-standard analysis, and recursion theory. Each of
• non-classical logics, eg. intuitionisitic logic, linear logic, modal & these is an entire field, with dozens or hundreds of research
temporal logic workers.
• finite structures and computational complexity • In philosophy, logic is studied for its contribution to formalising
truth, validity, argument, in many settings: eg, involving time, or
• automated theorem proving
other possible worlds.
Do the 2nd and 4th years for some of these. • Logic provides the foundation for several modern theories in
linguistics. This is nowadays relevant to computing.
226 227