CMPSCI 250 Discussion #2: Practicing Proofs

David Mix Barrington

20/22 September 2004

Solution for this discussion:

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 wR 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:

We're not in a position to prove these facts until we have a more formal definition (which will come in Chapter 4), but for now we will assume that these Facts are true.

A palindrome is a string w such that wR=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 uR seems to work in examples. Can we prove Pal(uuR) in general? Yes, given the Facts above. We need to show that $(uuR)R = uuR. Applying Fact II above, (uuR)R = (uR)RuR and, since (uR)R = u by Fact I, this is equal to uuR. 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).♠

Writing Exercise:

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*'').

  1. ∀x:Pal(x)↔Pal(xR).
  2. ∃u:∀v:∃w:(uv=w).
  3. 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