Pred Logic
Pred Logic
Predicate Logic
Anvesh Komuravelli
This kind of logic is called first-order logic. There are richer logics (nth -order
logics or higher-order logics) where, for e.g., predicate variables are also consid-
ered which can be quantified but we will not consider those in this treatment.
We are also interested in the special predicate, equality, denoted =. This is
the extensional equality we saw in Coq, i.e. equality in terms of computational
results and not just by defintion.
1
2 Examples
2.1 Predicates
Consider encoding the statement : Every child is younger than its brother. This
is not true in general (consider the case when the brother in question is younger
than the child). But our concern now is to encode it, not to decide whether it
is true or false. Consider the following predicates.
C(x) : x is a child.
B(x, y) : x is a brother of y.
Y (x, y) : x is younger than y.
It is not hard to see that there are multiple sources of ambiguity in the statement.
1. How many brothers does a child have? We will assume that the statement
is about every brother, for simplicity.
2. What does its mean? Does it imply the existence of at least one brother?
Not clear.
The encoding depends on how we answer the second question above. If the
answer is no, we might encode as follows.
2.2 Constants
If we want to encode the statement Andy is younger than Paul, we might use
the above predicates to get something like
Y (A, P )
where A and P are constants standing for specific entities, Andy and Paul,
respectively.
2.3 Functions
If we replace brother with mother in the previous example, we can simply replace
the predicate B(·, ·) with M (·, ·) standing for x is mother of y. But, as mothers
are unique, a more precise encoding is the following.
∀x. (C(x) → (∃y. (M (y, x) ∧ Y (x, y)) ∧ ∀y1 , y2 . (M (y1 , x) ∧ M (y2 , x) → y1 = y2 )))
2
The newly added conjunct says that if y1 and y2 are both mothers of x, then
y1 = y2 .
We can simplify the notation by introducing a function m(x) for the mother of
x. The encoding will now be simply
3 Natural Deduction
In addition to the rules we saw for Propositional Logic, we have the following
ones.
3.1 Equality
eq-i
t=t
In the above rule, φ[t/x] stands for substituting t for the free occurences of x in
φ. And whenever we do such substitutions, we should remember that t should
not have any variables which are already bound in φ (usually called, t is free
for x in φ). This is exactly the side-condition of the rule above.
For example, in (∃y.(x < y))[y/x], doing a blind substitution would result in
∃y.(y < y) which is absurd. The problem arose because y was already bound
in the formula (∃y). But that’s usually not the intended purpose of the sub-
stitution. Suppose that we have a side-condition that y is free for x in the
formula. As y is already bound in the formula, it is as if the bound variable
is first changed, say to z, resulting in ∃z.(x < z) which is essentially the same
formula and then substituting y for x resulting in ∃z.(y < z) which is what we
desired!
In the rest of this note, we assume that t is free for x in such substitutions and
not specify explicitly.
The two tactics above correspond to the tactics reflexivity and rewrite,
respectively.
3
Note that the introduction rule for ∀ corresponds exactly to how we prove
universal statements in mathematics. We let x0 be an arbitrary entity and
prove the statement in terms of x0 wherever x appears in the statement. Then
as x0 was arbitrary, we conclude that the statement holds for every such x.
That is exactly the rule above! As is the case with the rule of implication
introduction, we should remember to discharge these fresh variable assumptions
before the proof finishes. This corresponds to the tactic intro in Coq.
∀x.φ
forall-e
φ[t/x]
Here, t is any term which can be substituted for x. This implicitly assumes that
when φ is true for every x, there exists at least one x for which φ is true. This
corresponds to the tactic apply in Coq.
x0 (assumption)
∃x.φ
φ[x0 /x] → χ(χ has no free occurences of x0 )
exists-e
χ
This rule says how to use the fact that ∃x.φ. We assume that φ is true for x0 ,
a new variable. Then, if we can prove χ from φ[x0 /x] we can conclude that χ is
true. Again, we should remember to discharge the assumptions before we end
the proof. Note that, this parallels how we prove statements in mathematics.
This corresponds to the tactic destruct in Coq.
4 Exercises
1. (x + 1 = 1 + x), (x + 1 > 1 → x + 1 > 0) ` (1 + x > 1 → 1 + x > 0)
2. t1 = t2 ` t2 = t1
3. t1 = t2 , t2 = t3 ` t1 = t3
4
7. ∀x.(P (x) → Q(x)), ∃x.P (x) ` ∃x.Q(x)
8. ∀x.(Q(x) → R(x)), ∃x.(P (x) ∧ Q(x)) ` ∃x.(P (x) ∧ R(x))
9. ¬∀x.P (x) ` ∃x.¬P (x) (not intuitionistic)
10. ∃x.¬P (x) ` ¬∀x.P (x)
11. (∀x.P (x)) ∧ Q ` ∀x.(P (x) ∧ Q) (assume that Q does not depend on x.)
12. ∃x.P (x) ∨ ∃x.Q(x) ` ∃x.(P (x) ∨ Q(x))
13. ∃x.∃y.P (x, y) ` ∃y.∃x.P (x, y)
Some of these are done in Coq which you can find on the Lectures page.
5 References
1. Logic in Computer Science: Modelling and Reasoning about Systems. Michael
Huth and Mark Ryan, Cambridge University Press.