In this Excursion we will apply our proof methods, for both the
propositional and predicate calculi, to prove some statements about
strings and formal languages.
First, recall the definitions of a **string**
over a fixed alphabet, of the **concatenation** of two strings,
and of the **reversal** of a string (written w^{R} for the
reversal of w).
We lack the formal machinery to prove even some
very basic facts about concatenation and reversal.
For example, playing around with
examples should convince you of the following two general rules:

- Fact I: ∀w:(w
^{R})^{R}= w - Fact II: ∀u:∀v:(uv)
^{R}= u^{R}v^{R}

A **palindrome** is a string w such that w^{R}=w. Examples are
λ,, "hannah", and a statement attributed to Napoleon,
"Able was I ere I saw Elba'', which we might represent as the string
"ablewasiereisawelba". We'll write Pal(w) to mean
``w is a palindrome''. Now let's try to prove the following fact:

**Theorem:** ∀u:∃v:Pal(uv). That is, any string can be
extended to give a palindrome.

**Proof** It's usually good to start by trying a direct proof, trying to
prove our goal statement with no assumptions. So let u be an arbitrary
string, and we'll try to prove ∃v:Pal(u,v) without any assumptions
about u other than that it's a string (then, by the Rule of Generalization,
we'll be done). How to prove ∃v:Pal(u,v)? If we can think of a
particular v such that we can prove uv is a palindrome, then we'll be done
by the Rule of Existence. What v would work? It presumably depends on u,
and in fact u^{R} seems to work in examples. Can we prove
Pal(uu^{R}) in
general? Yes, given the Facts above. We need to show that
$(uu^{R})^{R} = uu^{R}.
Applying Fact II above, (uu^{R})^{R} =
(u^{R})^{R}u^{R} and,
since (u^{R})^{R} = u by Fact I,
this is equal to uu^{R}. So a suitable v always
exists, though note that because of the order of the quantifiers, v may
depend on u rather than being the same for all u. Since we assumed
nothing about u, we may use the Rule of Generalization to conclude
∀u:∃v:Pal(u,v).♠

Here are a few practice statements to prove. For
this exercise, you should go slightly overboard in justifying your steps.
All the small-letter variables are of type "string in A^{*}''
(where A is
a non-empty finite set, and A^{*}
is the set of all strings of letters in A)
and all the capital-letter variables are of type
"language over A'' (or "subset of A^{*}'').

- ∀x:Pal(x)↔Pal(x
^{R}). - ∃u:∀v:∃w:(uv=w).
- Assuming ∀u:∃v:(uv∈L) and ∃a:∀y:∀z:(yaz≠y), prove ¬∃w:∀x:[(x∈L)→∃y:(w=xy)]. Is this conclusion true without the first assumption? (The second assumption is true for strings over any nonempty alphabet.)

Last modified 23 September 2004