问题
Imagine I have a function definition with three cases:
function f where
eq1 if cond1
| eq2 if cond2
| eq3 if cond3
How can I prove some equation:
f x y = f y x
using case analysis on the left-hand side?
Just writing apply(cases f.cases) does not work for me. I get an error
Undefined constant: "f"⌂
回答1:
I decided to post my comment as an answer in an attempt to close this issue.
For your use case, it should be possible to use apply(cases ‹(x, y)› rule: f.cases)
(or similar). However, it would help to see a minimal working example before one can confirm this.
For further information about the method cases
see section 6.5.2 "Proof methods" in Isar-ref.
回答2:
In order to complement user9716869's answer, here's a minimal working example:
function f where
"f x y = 0" if "x = y" |
"f x y = Suc 0" if "x ≠ y"
by auto
termination by lexicographic_order
lemma "f x y = f y x"
proof (cases ‹(x, y)› rule: f.cases)
case (1 x y)
then show ?thesis
by simp
next
case (2 x y)
then show ?thesis
by simp
qed
来源:https://stackoverflow.com/questions/60683091/case-analysis-on-function-definition-in-isabelle