I am working on proving a lemma in predicate logic using Isabelle, and I've encountered a schematic variable in the proof state that I'm finding somewhat confusing. I would greatly appreciate your insights.
Here's the Isabelle code for the lemma:
lemma "(∃x. ∀y. P x y) ⟹ (∀y. ∃x. P x y)"
apply(erule exE)
apply(rule allI)
apply(rule exI)
After running the above code, the last proof state is:
proof (prove)
goal (1 subgoal):
1. ⋀x y. ∀y. P x y ⟹ P (?x4 x y) y
What does conclusion P (?x4 x y) y mean exactly? What is the use of ?x4 here and is it a function of x and y. I guess here it's supposed to return x, but why is it ?x4 x y in the first place?
I tried apply assumption but it couldnt finish the proof, why?
Generally, a schematic variable like
?x4means that you may instantiate this variable at a later time in the proof—but it must be done consistently over the whole proof state.Let us look at your example, tweaked to disambiguate between left-hand and right-hand side names for clarity:
?xr4indeed is a function of abstract type'a ⇒ 'b ⇒ 'aif'ais the type ofxl/rand'bthe type ofyl/r. So,(?xr4 xl yr)is a function application that means that you may usexlandyrto construct your witness in the proof ofP (...) yr.As you've pointed out,
apply assumptionwill usually help with such instantiations. It finds a fact that can be unified to the goal by more-or-less straightforward instantiations.In your particular proof state
apply assumptionfails, because the term∀yl. P xl ylis different fromP (...) yr, no matter how we fill the hole(...).So, we first have to derive a fact that looks like the goal. For instance, we could:
spec: ∀x. ?P x ⟹ ?P ?xused as a forward (or destruction) rule allows to push a universal quantification in a fact into a schematic variable (or, more commonly, to instantiate it directly). Here, it leads to a new schematic variable term(?yl6 xl yr)appearing on the left-hand side.Now, there are clear instantiations for both:
?yl6 == λx y. yand?xr4 == λx y. xmake both terms evaluate toP xl yr. Therefore, we can close the proof here.