Given a valid Coq proof using the ;
tactical, is there a general formula for converting it to a valid equivalent proof with .
substituted for ;
?
Many Coq proofs use the ;
or tactic sequencing tactical. As a beginner, I want to watch the individual steps execute, so I want to substitute .
for ;
, but to my surprise I find that this may break the proof.
Documentation on ;
is sparse, and I haven't found an explicit discussion of .
anywhere. I did see a paper that says informal meaning of t1; t2
is
apply
t2
to every subgoal produced by the execution oft1
in the current proof context,
and I wonder if .
only operates on the current subgoal and that explains the different behavior? But especially I want to know if there is a general solution to repairing the breakage caused by substituting .
for ;
.
The semantics of
tac1 ; tac2
is to runtac1
and then runtac2
on all the subgoals created bytac1
. So you may face a variety of cases:There are no goals left after running
tac1
If there are no goals left after running
tac1
thentac2
is never run and Coq simply silently succeeds. For instance, in this first derivation we have a useless; intros
at the end of the (valid) proof:If we isolate it, then we get an
Error: No such goal.
because we are trying to run a tactics when there is nothing to prove!There is exactly one goal left after running
tac1
.If there is precisely one goal left after running
tac1
thentac1 ; tac2
behaves a bit liketac1. tac2
. The main difference is that iftac2
fails then so does the whole oftac1 ; tac2
because the sequence of two tactics is seen as a unit that can either succeed as a whole or fail as a whole. But iftac2
succeeds, then it's pretty much equivalent.E.g. the following proof is a valid one:
Running
tac1
generates more than one goal.Finally, if multiple goals are generated by running
tac1
thentac2
is applied to all of the generated subgoals. In our running example, we can observe that if we cut off the sequence of tactics afterrepeat split
then we have 5 goals on our hands. Which means that we need to copy / pasteassumption
five times to replicate the proof given earlier using;
: