CMPSCI 250 Discussion #3: Practicing Proofs
David Mix Barrington
26 September 2007
In this discussion we applied our proof methods, for both the propositional
and predicate calculi, to prove some statements about numbers and strings.
First, recall the definitions of a string over a fixed alphabet, the
concatenation of two strings, and the reversal w^{R} of
a string w (which is w written backwards). We will assume the following two
facts, which we aren't prepared to prove yet:
 Fact I: ∀w: (w^{R})^{R} = w
 Fact II: ∀u:∀v: (uv)^{R} = v^{R}u^{R}
A palindrome is a string w such that w^{R} = 2. Examples
the empty string λ, "hannah", and a statement attributed to Napoleon,
"Able was I ere I saw Elba", which is a palindrome as long as we ignore
capitalization. We'll write Pal(w) to mean "w is a palindrome".
One string is a prefix of another if you can make the second by
concatenating some string onto the first  using quantifiers:
Pre(u,v) ↔ ∃w:(uw=v)
Writing Exercises:

We begin by using the quantifier rules to prove some statements about natural
numbers as in Discussion #1. We define Even(x) to mean
∃y: x = 2y and Odd(x) to mean ∃y: x = 2y+1. Prove:
∀x:forall;y: [Odd(x) ∧ Odd(y)] → [Even(x+y) ∧ Odd(xy)]
Since we want to prove a universal statement, we start by letting a and b
we arbitrary naturals. We assume Odd(a) and Odd(b) to start a direct proof
of the implication [Odd(a) ∧ Odd(b)] → [Even(a+b) ∧ Odd(ab)].
By the definition of Odd, we have ∃c:a = 2c+1 and ∃d: b = 2d+1.
By Instantiation, let c and d be naturals such that a = 2c+1 and b = 2d+1.
By arithmetic, a+b = 2c + 2d + 2 = 2(c+d+1). By Existence, letting e = c+d+1,
we get that ∃e: a+b = 2e which is the definition of Even(a+b). By more
arithmetic, ab = (2c+1)(2d+1) = 4cd + 2c + 2d + 1 = 2(2cd+c+d) + 1. Using
Existence with
f = 2cd+c+d, we have ∃f: ab = 2f+1 which is the definition of Odd(ab).
Assuming Odd(a) ∧ Odd(b), we have proved Even(a+b) ∧ Odd(ab), so we
have proved the desired implication by direct proof.
Since a and b were arbitrary, by Generalization we may conclude
∀x:∀y:[Odd(x) ∧ Odd(y)] → [Even(x+y) ∧ Odd(ab)].
 Now using the Pal and Pre predicates defined above, prove
∀x:∃y: Pre(x,y) ∧ Pal(y)
 Let a be an arbitrary string.
 Let b be aa^{R}. (Note: This is the creative step  we have to
convince ourselves that this is the string we want.)
 Letting c be a^{R}, note that ac = b and hence ∃c: ac = b
by Existence.
 By the definition of Pre, we have that Pre(a,b).
 Since (aa^{R})^{R} =
(a^{R})^{R}a^{R} by Fact II which equals aa^{R}
by Fact I, we know that Pal(aa^{R}) and hence Pal(b).
 Using Existence on b, we have that ∃y:Pre(a,y) ∧ Pal(y).
 Since a was arbitrary, by Generalization we have ∀x:∃y:
Pre(x,y) ∧ Pal(y).
 Prove ∃u:∀v:∃w: (v = (uw)^{R}), where again
all variables denote strings.
This one is tricky in that the first step of the formal proof requires us
to decide what u is going to be. But note that u is going to have the property
that for any v, we can find a w to make v = (uw)^{R} true. If v
happens to be empty, uw will have to be empty and thus u will have to be empty.
 We need to prove ∀v:∃w: v = (λw)^{R}.
 Let v be arbitrary.
 Let w be v^{R}. Note that λw = w.
 By Fact I, w^{R} = (v^{R})^{R} = v.
 By Existence, we have that ∃w: v = (λw)^{R}.
 Since v was arbitrary, we have that ∀v:∃w: v =
(λw)^{R}.
 By Existence, letting u be λ, we have
∃u:∀v:∃w: v = (uw)^{R}, as desired.
 Prove that Pre is a partial order on the set of all strings. To prove
antisymmetry, use the fact that every string w has a length w, the fact
that uv = u + v, and arithmetic on naturals.
 Pre is reflexive: We must prove ∀x: Pre(x,x). Because x =
xλ, by Existence we have ∃w: xw = x, which is the definition of
Pre(x,x).
 Pre is antisymmetric: We must prove ∀u:∀v:[Pre(u,v) ∧
Pre(v,u)] → (u=v). Let u and v be arbitrary strings and assume Pre(u,v)
and Pre(v,u). By Instantiation on the definitions of Pre(u,v) and Pre(v,u),
let w and x be strings such that uw = v and vx = w. By the given rules about
lengths, v = uw = u + w and u = vx = v + x. Since w and x
are naturals and cannot be negative, we must have w = x = 0 so that w = x =
λ. But then u = uλ = v. We have proved that [Pre(u,v) ∧
Pre(v,u)] → (u=v), and since u and v were arbitrary we have proved
antisymmetry.
 Pre is transitive: We must prove ∀u:∀v:∀w: [Pre(u,v)
∧ Pre(v,w)] → Pre(u,w). So let u, v, and w be arbitrary strings and
assume Pre(u,v) and Pre(v,w). By Instantiation on the definition of Pre, let
x and y be strings such that ux = v and vy = w. Then by substitution, w = vy =
(ux)y. Letting z = xy, we have w = uz and hence ∃z: uz = w by Existence.
This is the definition of Pre(u,w). We have proved the desired implication by
direct proof, and since u, v, and w were arbitrary we can conclude the
quantified statement by Generalization.
Last modified 26 September 2007