2

I'm having some issues trying to do exercise 4.5 of 'Concrete Semantics' in Isar:

inductive S :: "alpha list ⇒ bool" where
 Sε : "S []" |
 aSb : "S m ⟹ S (a#m @ [b])" |
 SS : "S l ⟹ S r ⟹ S (l @ r)"

inductive T :: "alpha list ⇒ bool" where
 Tε : "T []" |
 TaTb : "T l ⟹ T r ⟹ T (l @ a#(r @ [b]))"

lemma TS: "T w ⟹ S w"
proof (induction w rule: T.induct)
  case Tε 
  show ?case by (simp add:Sε)
  case (TaTb l r) show ?case using TaTb.IH(1) (* This being S l, which allows us to case-split on l using S.induct *)
  proof (cases "l" rule: S.induct)
    case Sε
    then show ?case by (simp add: TaTb.IH(2) aSb)
  next case (aSb m)

I'm getting Illegal schematic variable(s) in case "aSb"⌂ Also I find suspicious that in Sε I cannot refer to ?case, I get Unbound schematic variable: ?case. I'm thinking that maybe the problem is that I have a cases in an induction?

cxandru
  • 158
  • 8
  • I cannot try it right now, but in cases you need ?thesis, not ?cases. And to avoid surprises you should also add a next before the case TaTb – Mathias Fleury Feb 13 '22 at 16:12
  • 1
    To complement what @MathiasFleury already pointed out: You should also use `proof (cases l)` without forcing `S.induct` to be used, otherwise the subgoal does not refine the actual goal. – Javier Díaz Feb 13 '22 at 17:35

1 Answers1

2

As summarized by the comments, you have two problems:

  1. cases "l" rule: S.induct makes little sense and you should either use a nested induction induction l rule: S.induct or a case distinction cases l rule: S.cases

  2. In cases you should use ?thesis instead of cases as the Isabelle/jEdit outline tells you (you can click on that thing to insert it into the buffer!). That way you would also have given a name to all variable in the case TaTb.

So you probably want something like:

lemma TS: "T w ⟹ S w"
proof (induction w rule: T.induct)
  case Tε 
  show ?case by (simp add:Sε)
next
  case (TaTb l r a b) show ?case using TaTb.IH(1)
  proof (cases "l" rule: S.cases)
    case Sε
    then show ?thesis sorry
  next
    case (aSb m a b)
    then show ?thesis sorry
  next
    case (SS l r)
    then show ?thesis sorry
  qed
qed
Mathias Fleury
  • 2,221
  • 5
  • 12
  • Thanks. It was not entirely clear to me that one needs to use `S.cases` here, there are other instances where `.simps`, `.cases`, `.induct` are interchangeable, I think that's what caused the confusion. – cxandru Feb 16 '22 at 14:58
  • @Commodore64: Actually, `S.cases` is not needed in your context, since the fact `TaTb.IH(1)` is explicitly passed to the `cases` method, therefore the `S.cases` is implicitly used. That is, `proof (cases l)` will suffice. For further information, please refer to page 159 in the _Isabelle/Isar Reference Manual_. – Javier Díaz Feb 16 '22 at 16:25