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

lemma Tapp: "⟦T l;  T r⟧ ⟹ T (l@r)"
proof (induction r rule: T.induct)

I get 'Failed to apply initial proof method⌂'

In Isabelle one could use rotate_tac I guess to get induction to work on the desired argument, what's the Isar equivalent? Would it help to reformulate the lemma with 'assumes' & 'shows'?

cxandru
  • 158
  • 8

1 Answers1

2

Rule induction is always on the leftmost premise of the goal. Therefore, the Isabelle/Isar solution consists on inverting the order of the premises:

lemma Tapp: "⟦T r;  T l⟧ ⟹ T (l@r)"
proof (induction r rule: T.induct)
...

Or, using assumes and shows:

lemma Tapp: assumes "T r" and "T l" shows "T (l@r)"
using assms proof (induction r rule: T.induct)
...
Javier Díaz
  • 1,071
  • 4
  • 7
  • won't that be a nuisance when _using_ the lemma though? Is there no way to rearrange the arguments _inside_ the body of the lemma, so the user gets a lemma of type `⟦T l; T r⟧ ⟹ T (l@r)` – cxandru Feb 22 '22 at 15:16
  • I don't think there is a nuisance when using the lemma, since `lemma "⟦T l; T r⟧ ⟹ T (l@r)" by (rule Tapp)` also holds, and therefore you can safely ignore the order of the arguments when using `Tapp`. Now, if you really want your lemma statement to be `⟦T l; T r⟧ ⟹ T (l@r)` and prove it by rule induction, then you could do it as follows: `lemma Tapp: "⟦T l; T r⟧ ⟹ T (l@r)" proof - assume "T l" and "T r" from ‹T r› show ?thesis proof (induction r rule: T.induct) ... qed`. – Javier Díaz Feb 22 '22 at 17:46