I tried to prove an existential theorem
lemma "∃ x. x * (t :: nat) = t"
proof
obtain y where "y * t = t" by (auto)
but I could not finish the proof. So I have the necessary y
but how can I feed it into the original goal?
Soundness of natural deduction requires that you get hold of the witness before you open the existential quantifier. This is why you are not allowed to use obtained variables in show
statements. In your example, the proof
step implicitly applies the rule exI
. This turns the existentially quantified variable x
into the schematic variable ?x
, which can be instantiated later, but the instantiation may only refer to variables that have been in scope when ?x
came into place. In the low-level proof state, obtained variables are meta-quantified (!!
) and the instantiations for ?x
can only refer to such variables that appear as a parameter to ?x
.
Therefore, you have to switch the order in your proof:
lemma "∃ x. x * (t :: nat) = t"
proof - (* method - does not change the goal *)
obtain y where "y * t = t" by (auto)
then show ?thesis by(rule exI)
qed
You can give the witness (i.e. the element you want to put in for x) in the show
clause:
lemma "∃ x. x * (t :: nat) = t"
proof
show "1*t = t" by simp
qed
Alternatively, when you already know the witness (1
or Suc 0
here), you can explicitly instantiate the rule exI
to introduce the existential term:
lemma "∃ x. x * (t :: nat) = t"
by (rule exI[where x = "Suc 0"], simp)
Here, the existential quantifier introduction rule thm exI
is
?P ?x ⟹ ∃x. ?P x
you can explore and instantiate it gradually with the answer.
thm exI[where x = "Suc 0"]
is:
?P (Suc 0) ⟹ ∃x. ?P x
and exI[where P = "λ x. x * t = t" and x = "Suc 0"]
is
Suc 0 * t = t ⟹ ∃x. x * t = t
And Suc 0 * t = t
is only one simplification (simp
) away. But the system can figure out the last instantiation P = "λ x. x * t = t"
via unification, so it isn't really necessary.
Related: