Reputation: 2664
For the proof:
Parameter A B : Prop.
Goal A->B.
intro A.
I get:
1 subgoals
A : A
______________________________________(1/1)
B
How do I return then A
back to the goal section? To return to:
1 subgoals
______________________________________(1/1)
A -> B
Upvotes: 7
Views: 873
Reputation: 6432
You can use the revert
tactic.
Given Coq's plethora of tactics, each with various corner cases and varying quality of documentation, it's quite common that you won't know which tactic to use.
In such cases, I find it useful to think of your proof as a program (see Curry-Howard Isomorphism) and to ask yourself what term you would have to write to solve your goal. The advantages of this approach is that Coq's term language is easier to learn (because there just aren't that many different kinds of terms) and expressive enough to solve all goals solvable with tactics (sometimes the proofs are more verbose though).
You can use the refine
tactic to write your proofs in the term language. The argument of refine
is a term with holes _
. refine
discharges the current goal using the term and generates a subgoal for every hole in the term. Once you know how refine
works, all you have to do is to come up with a term that does what you want. For example:
h
with refine (_ h)
.h
with refine (fun h => _)
.h
with refine ((fun h' => _) h)
.Note that Coq's tactics tend to do quite a bit of magic behind the scenes. For example, the revert
tactic is "smarter" than the refine
above when dealing with dependent variables:
Goal forall n:nat, n >= 0.
intro n; revert n. (* forall n : nat, n >= 0 *)
Restart.
intro n; refine (_ n). (* nat -> n >= 0 *)
Restart.
intro n'; refine ((_ : forall n, n >= 0) n'). (* forall n : nat, n >= 0 *)
Abort.
Upvotes: 3
Reputation: 23622
Use the revert
tactic:
revert A.
It is exactly the inverse of intro
, cf. the reference manual.
Upvotes: 9