I have a datatype and an inductive predicate over it (which is actually a small-step semantics of some transition system):
datatype dtype = E | A | B dtype
inductive dsem :: "dtype ⇒ dtype ⇒ bool" where
"dsem A E"
| "dsem (B E) E"
| "dsem d d' ⟹ dsem (B d) (B d')"
and also a function which is computed by case distinction:
fun f :: "dtype ⇒ nat" where
"f E = 0"
| "f A = 1"
| "f (B _) = 2"
I'm trying to prove some property about the inductive predicate, and assumptions also involve computing the value of f
which doesn't participate in induction.
lemma
assumes d: "dsem s s'"
and h: "h s v"
and v: "v = f s"
shows "P v"
using d h
proof (induct rule: dsem.induct)
For the 3rd semantics rule Isabelle computes the subgoal
⋀d d'. dsem d d' ⟹ (h d v ⟹ P v) ⟹ h (B d) v ⟹ P v
where the value of s
is lost so it is impossible to compute the value v
.
I can neither include v
into the induction assumptions because then Isabelle generates the subgoal
⋀d d'. dsem d d' ⟹ (h d v ⟹ v = f d ⟹ P v) ⟹ h (B d) v ⟹ v = f (B d) ⟹ P v
where the induction hypothesis says v = f d
which is incorrect since v = f (B d)
in this case. Nor can I put v
into arbitrary: ...
because the value of v
must be fixed throughout the proof.
It would be nice to have an explicit binding s = B d
in the generated subgoal; unfortunately, the rule dsem.induct
doesn't provide it.
Does anybody know a workaround for computing the value v
in this case?
lemma "dsem s s' ⟹ (⋀v. ⟦ h s v ; v = f s ⟧ ⟹ P v)"
? – John Wickersonv
(i.e.,v = f s
) contains the variables
and you are doing induction ondsem s s'
(which also containss
) there is no way around also includingv
into the induction assumptions. If the statement is not provable after doing so, you will have to reformulate it appropriately (whatever that means). – chrisv
unfolded, i.e.lemma "dsem s s' ⟹ h s (f s) ⟹ P (f s)"
. This version is logically equivalent to the one stated in the question (and to the one suggested by John Wickerson above). – Brian Huffman