I'm new to Isabelle/HOL (although not to HOL), so I decided to start learning by working through the examples in the excellent "prog-prove" tutorial.
I've got stuck on a context free grammar question (exercise 3.5 on page 43). In this question, you get two context free grammars:
S → ε | aSb | SS
T → ε | TaTb
and you are asked to prove they describe the same language. Proving that elements from T lie in the language described by S is easy, but I'm struggling with the other direction. In particular, I want to show that the language described by T is closed under concatenation.
Here's an informal proof: Suppose u
and v
lie in the language. Then we want to prove that uv
lies in the language. Proceed by induction on the length of v
. If length v = 0
then v
is the empty string and uv = u
and we are done. Otherwise, look at the production rules for T. Clearly v
isn't the empty string, so it must be of the form waxb
for some w, x
in the language. Since w
is shorter than v
, (strong) induction shows that uw
must lie in the language. Now use the second production rule.
This proof seems quite complicated, so I suspect that it's not the one the author of prog-prove had in mind. So I have two questions:
What (informally or formally) is the proof that the author of the exercise expects you to use?
(More technical) How would I express my informal proof above in Isabelle/HOL?
My attempt / flailing thus far starts with the following:
lemma T_mult: "cfT u ==> cfT v ==> cfT (u @ v)"
apply (induction "length v")
apply (auto)
apply (induction v rule: cfT.induct)
and the second induction application fails, but I assume that this is because I'm asking Isabelle to do the wrong thing...