When writing structured proofs, it is best to avoid meta-implication (and quantification) for the outermost structure of the subgoal. I.e. instead of talking about
⋀x. P x ⟹ Q x ⟹ R x
you should use
fix x
assume "P x" "Q x"
...
show "R x"
If P x
and Q x
have some structure, it is fine to use meta-implication and -quantification for these.
There is a number of reasons to prefer fix
/assumes
over the meta-operators in structured proofs.
Somewhat trivially, you do not have to state them again in every have and show statement.
More important, when you use fix
to quantify a variable, it stays the same in the whole proof. If you use ⋀
, it is freshly quantified in each have
statement (and doesn't exist outside). This makes it impossible to refer to this variable directly and often complicates the search space for automated tools. Similar things hold for assume
vs ⟹
.
A more intricate point is the behaviour of show
in the presence of meta-implications. Consider the following proof attempt:
lemma "P ⟷ Q"
proof
show "P ⟹ Q" sorry
next
show "Q ⟹ P" sorry
qed
After the proof
command, there are two subgoals: P ⟹ Q
and Q ⟹ P
. Nevertheless, the final qed
fails. How did this happen?
The first show
applies the rule P ⟹ Q
to the first applicable subgoal, namely P ⟹ Q
. Using the usual rule resolution mechanism of Isabelle, this yields P ⟹ P
(assume P
show Q` would have removed the subgoal).
The second show
applies the rule Q ⟹ P
to the first applicable subgoal: This is now P ⟹ P
(as Q ⟹ P
is the second subgoal), yielding P ⟹ Q
again.
As a result, we are still have the two subgoals P ⟹ Q
and Q ⟹ P
and qed
cannot close the goal.
In many cases, we don't notice this behaviour of show
, as trivial subgoals like P ⟹ P
can be solved by qed
.
A few words on the behavior of show
: As we have seen above, meta-implication in show
does not correspond to assume
. Instead, it corresponds to assume
s lesser known brother, presume
. presume
allows you to introduce new assumptions, but requires you to discharge them afterwards. As an example, compare
lemma "P 2 ⟹ P 0"
proof -
presume "P 1" then show "P 0" sorry
next
assume "P 2" then show "P 1" sorry
qed
and
lemma "P 2 ⟹ P 0"
proof -
show "P 1 ⟹ P 0" sorry
next
assume "P 2" then show "P 1" sorry
qed