I'm now trying to do my first existential proof in Isabelle. I have proven
have "e0 ∈ ℚ ∧ e1 ∈ ℚ ∧ e2 ∈ ℚ ∧ e3 ∈ ℚ ∧
(∑h ∈ {0..<m}. N $$ (h,i) * x $$ (h,0)) =
e0 * ?y0 + e1 * ?y1 + e2 * ?y2 + e3 * ?y3 +
(∑h ∈ {4..<m}. N $$ (h,i) * x $$ (h,0))" using eq2 by simp
I want to prove
"∃e0 e1 e2 e3. e0 ∈ ℚ ∧ e1 ∈ ℚ ∧ e2 ∈ ℚ ∧ e3 ∈ ℚ ∧
(∑h ∈ {0..<m}. N $$ (h,i) * x $$ (h,0)) =
e0 * one_of(y_of((a, b, c, d),(x0, x1, x2, x3))) +
e1 * two_of(y_of((a, b, c, d),(x0, x1, x2, x3))) +
e2 * three_of(y_of((a, b, c, d),(x0, x1, x2, x3))) +
e3 * four_of(y_of((a, b, c, d),(x0, x1, x2, x3))) +
(∑h ∈ {4..<m}. N $$ (h,i) * x $$ (h,0))"
Looking at the reference manual, I found exI and tried using it in the proof, but it didn't accept it. This seems like a straight-forward application. Is the fact that I have four variables e0, e1, e2, e3 instead of one variable the problem?
I forgot to mention this definition:
let ?y0 = "one_of(y_of((a, b, c, d),(x0, x1, x2, x3)))"
let ?y1 = "two_of(y_of((a, b, c, d),(x0, x1, x2, x3)))"
let ?y2 = "three_of(y_of((a, b, c, d),(x0, x1, x2, x3)))"
let ?y3 = "four_of(y_of((a, b, c, d),(x0, x1, x2, x3)))"
So it is really just a case of P(e0 e1 e2 e3) implies there exists e0 e1 e2 e3 such that P(e0 e1 e2 e3)
maybe just press sledgehammer
and see what if gives you?
I tried sledgehammering with no luck
huh, then something's probably off then
Assuming I did everything correctly, should exI work?
I think so, but you may need to apply it multiple times
Can you please give an example of how to apply it multiple times?
apply (intro exI[of ...])
apply (intro exI[of ...])
I guess
What do the three dots represent in this instance?
oh just something you should write to instantiate the exI
I just tried this with no luck, where ?thesis is what I want to prove:
thus ?thesis using (intro exI[of e0 e1 e2 e3]) by sledgehammer
that should give you an error
I'm not sure how to do it with apply.
lemma foo:
assumes "P a0 a1 a2 a3"
shows "∃a0 a1 a2 a3. P a0 a1 a2 a3"
apply (intro exI)
look at the goal state afterwards
I see. I'll try that. Thank you.
For this kind of cases you want unify_trace_failure
apply (intro exI[of _ e1])
apply (intro exI[of _ e2])
apply (intro exI[of _ e3])
supply [[unify_trace_failure]]
apply (rule assumption_with_e1_e2_e2)
thank you, I found another way to prove my lemma without even using the existence proof. However, I will need to do an existence proof in my main theorem, so this should help.
It turns out that definitely I will need to do at least five existence proofs, including the one I originally tried. I have been learning Isabelle mostly from the Fisher’s Inequality section of the archive of formal proofs, which doesn’t use “apply”, so this is all new to me. Are there any sections where you would recommend I learn “apply”.
Or is there a way to do it without using “apply”?
apply is the best way to debug why auto or sledgehammer does not work
With unify_trace_failure, you should reach the point where the error will tell you why the instantiation does not work
(type classes being different, an equality being reversed -- unlikely but possible)
You can work-around it with commas:
supply [[unify_trace_failure]]
by (rule exI[of _ e1], rule exI[of _ e2], rule exI[of _ e5], rule assumption_with_e1_e2_e2)
but this will produce more output as rule will also produce unification failures
I just tried
then have "e0 ∈ ℚ ∧ e1 ∈ ℚ ∧ e2 ∈ ℚ ∧ e3 ∈ ℚ ∧
(∑h ∈ {0..<m}. N $$ (h,i) * x $$ (h,0)) =
e0 * ?y0 + e1 * ?y1 + e2 * ?y2 + e3 * ?y3 +
(∑h ∈ {4..<m}. N $$ (h,i) * x $$ (h,0))" using eq2 by simp
apply (intro exI[of _ e0])
apply (intro exI[of _ e1])
apply (intro exI[of _ e2])
apply (intro exI[of _ e3])
supply [[unify_trace_failure]]
apply (rule assumption_with_e0_e1_e2_e3)
it gave me "Illegal application of proof command in "state" mode" I also tried:
then have "e0 ∈ ℚ ∧ e1 ∈ ℚ ∧ e2 ∈ ℚ ∧ e3 ∈ ℚ ∧
(∑h ∈ {0..<m}. N $$ (h,i) * x $$ (h,0)) =
e0 * ?y0 + e1 * ?y1 + e2 * ?y2 + e3 * ?y3 +
(∑h ∈ {4..<m}. N $$ (h,i) * x $$ (h,0))" using eq2 by simp
supply [[unify_trace_failure]]
by (rule exI[of _ e0], rule exI[of _ e1], rule exI[of _ e2], rule exI[of _ e3],
rule assumption_with_e0_e1_e2_e3)
and got the same thing "Illegal application of proof command in "state" mode"
then have ...
by simp
supply [[unify_trace_failure]]
by (rule exI[of _ e0], rule exI[of _ e1], rule exI[of _ e2], rule exI[of _ e3],
rule assumption_with_e0_e1_e2_e3)
you cannot have two bys
And this is not the place where I suggested putting it
show ?thesis
supply ...
by ...
Do you mean this?
then have final_eq: "e0 ∈ ℚ ∧ e1 ∈ ℚ ∧ e2 ∈ ℚ ∧ e3 ∈ ℚ ∧
(∑h ∈ {0..<m}. N $$ (h,i) * x $$ (h,0)) =
e0 * ?y0 + e1 * ?y1 + e2 * ?y2 + e3 * ?y3 +
(∑h ∈ {4..<m}. N $$ (h,i) * x $$ (h,0))" using eq2 by simp
show ?thesis
supply [[unify_trace_failure]]
by (rule exI[of _ e0], rule exI[of _ e1], rule exI[of _ e2], rule exI[of _ e3],
rule assumption_with_e0_e1_e2_e3)
I tried it but got "Undefined fact: "assumption_with_e0_e1_e2_e3"
?thesis is:
"∃e0 e1 e2 e3. e0 ∈ ℚ ∧ e1 ∈ ℚ ∧ e2 ∈ ℚ ∧ e3 ∈ ℚ ∧
(∑h ∈ {0..<m}. N $$ (h,i) * x $$ (h,0)) =
e0 * one_of(y_of((a, b, c, d),(x0, x1, x2, x3))) +
e1 * two_of(y_of((a, b, c, d),(x0, x1, x2, x3))) +
e2 * three_of(y_of((a, b, c, d),(x0, x1, x2, x3))) +
e3 * four_of(y_of((a, b, c, d),(x0, x1, x2, x3))) +
(∑h ∈ {4..<m}. N $$ (h,i) * x $$ (h,0))"
assumption_with_e0_e1_e2_e3
should be final_eq
(you did not provide the name so far…)
I just replaced it with
by (rule exI[of _ e0], rule exI[of _ e1], rule exI[of _ e2], rule exI[of _ e3],
final_eq)
I got "Undefined method: "final_eq"⌂"
rule final_eq
I got a better message, but not sure what it means.
No subgoals!
The following types do not unify:
(real ⇒ bool) ⇒ bool
(rat ⇒ bool) ⇒ bool
Failed to apply initial proof method⌂:
goal (1 subgoal):
1. ∃e0 e1 e2 e3.
e0 ∈ ℚ ∧
e1 ∈ ℚ ∧
e2 ∈ ℚ ∧
e3 ∈ ℚ ∧
complex_of_int (∑h = 0..<m. N $$ (h, i) * x $$ (h, 0)) =
complex_of_rat
(e0 * one_of (y_of ((a, b, c, d), x0, x1, x2, x3)) +
e1 * two_of (y_of ((a, b, c, d), x0, x1, x2, x3)) +
e2 * three_of (y_of ((a, b, c, d), x0, x1, x2, x3)) +
e3 * four_of (y_of ((a, b, c, d), x0, x1, x2, x3))) +
complex_of_int (∑h = 4..<m. N $$ (h, i) * x $$ (h, 0))
It means that some function (probably equality, but I am not sure) is taking a real instead of a rat as argument
So, time for you to look at all types
Excellent, thank you for your help. I’ve faced that type of issue before. It’s a pain but can be overcome with diligence.
I fixed it and it works now. The problem was a type error. Also, I was able to just use blast and not even bother with exI. So existence proofs aren't so hard as long as the types are correct.
Last updated: Dec 21 2024 at 12:33 UTC