Hi,
I am trying to use the erule ssubst
command
to use an equality from the assumption
to do a rewriting to the goal,
but I can't get Isabelle to select the second rather than the first assumption to do that
rewriting:
theory Example imports Main begin
fun Lexists_nonEmpty :: "'a list ⇒ ('a ⇒ bool) ⇒ bool" where
"Lexists_nonEmpty [] p = False"
| "Lexists_nonEmpty [a] p = (p a)"
| "Lexists_nonEmpty (a # as) p = (p a ∨ Lexists_nonEmpty as p)"
lemma Lexists_nonEmpty_concat: shows "Lexists_nonEmpty (rs @ rs2) p = (Lexists_nonEmpty rs p ∨ Lexists_nonEmpty rs2 p)"
apply(induct rs )
apply simp+
apply(subgoal_tac "Lexists_nonEmpty (a # rs @ rs2) p = p a ∨ Lexists_nonEmpty (rs @ rs2) p")
apply(erule ssubst(2))
sorry
end
Any ideas?
thanks a lot!
Chengsong
First: ssubst(2)
means the second theorem of ssubst
, like in every context
Second: you can reorder assumptions with rotate_tac
Third: it makes no difference here, because only one assumption is an equality. So I do not get what you are trying to achieve
Lexists_nonEmpty (rs @ rs2) p = (Lexists_nonEmpty rs p ∨ Lexists_nonEmpty rs2 p) ⟹
Lexists_nonEmpty (a # rs @ rs2) p = p a ∨ Lexists_nonEmpty (rs @ rs2) p ⟹
Lexists_nonEmpty (a # rs @ rs2) p = (Lexists_nonEmpty (a # rs) p ∨ Lexists_nonEmpty rs2 p)
Mathias Fleury said:
Third: it makes no difference here, because only one assumption is an equality. So I do not get what you are trying to achieve
Hi Mathias,
I was trying to use the equality which I just inserted using subgoal_tac
, namely
Lexists_nonEmpty (a # rs @ rs2) p = p a ∨ Lexists_nonEmpty (rs @ rs2) p
So I would like to turn the LHS Lexists_nonEmpty (a # rs @ rs2) p
into p a \/ .......
(Using bracket mode) the proof state looks like this:
proof (prove)
goal (2 subgoals):
1. ⋀a rs.
⟦Lexists_nonEmpty (rs @ rs2) p = (Lexists_nonEmpty rs p ∨ Lexists_nonEmpty rs2 p);
Lexists_nonEmpty (a # rs @ rs2) p = p a ∨ Lexists_nonEmpty (rs @ rs2) p⟧
⟹ Lexists_nonEmpty (a # rs @ rs2) p = (Lexists_nonEmpty (a # rs) p ∨ Lexists_nonEmpty rs2 p)
.......
so I am a bit puzzled why after erule ssubst
the inductive hypothesis got deleted instead of the second premise in this proof state.
This Lexists_nonEmpty (a # rs @ rs2) p = p a ∨ Lexists_nonEmpty (rs @ rs2) p
is (_ = _) ∨ _
So no equality here
erule always eliminates the assumption.
erule is here looking at all the possible assumptions (there is only one), instantiate the theorem and rewrites it. As it is HO unification, the term ?s does not appear in the goal, so the function is (%_. x) ?s
and you do not see any difference
If you try
lemma Lexists_nonEmpty_concat: shows "Lexists_nonEmpty (rs @ rs2) p = (Lexists_nonEmpty rs p ∨ Lexists_nonEmpty rs2 p)"
apply(induct rs )
apply simp+
apply(subgoal_tac "Lexists_nonEmpty (a # rs @ rs2) p = (p a ∨ Lexists_nonEmpty (rs @ rs2) p)")
apply(erule ssubst)
you will see the rewriting making more sense
Mathias Fleury said:
So no equality here
Nicely spotted
Mathias Fleury said:
erule is here looking at all the possible assumptions (there is only one), instantiate the theorem and rewrites it. As it is HO unification, the term ?s does not appear in the goal, so the function is
(%_. x) ?s
and you do not see any difference
Sorry if this seems obvious but which term are you referring to is (%_. x) ?s
?
The function in the conclusion of ssubst rule
[Quoting…]
Just to rephrase it to double-check my understanding,
the x
means the term Lexists_nonEmpty (rs @ rs2) p = (Lexists_nonEmpty (a # rs) p \/ Lexists_nonEmpty rs2 p)
right?
And ?s and ?t have been instantiated to the LHS and RHS of the I.H., though they are discarded by the function and therefore the output remains to be x
.
yes exactly
Last updated: Dec 21 2024 at 16:20 UTC