intro / introsIntroducing hypothesesEach intro peels one binder off the goal and wraps the hole in a fun.
(fun P Q : Prop => ?Goal)fun x => ?holeOne example per tactic. Each card shows the fragment of the term Coq built for it, taken from a recorded run.
intro / introsIntroducing hypothesesEach intro peels one binder off the goal and wraps the hole in a fun.
(fun P Q : Prop => ?Goal)fun x => ?holeapply HApplying a hypothesisapply H puts H at the head of an application; its premises become holes.
g ?GoalH ?arg1 … ?argNexact tGiving the term directlyexact t fills the hole with t itself.
ptreflexivityClosing an equationreflexivity closes x = x with eq_refl.
eq_refleq_refldestruct xCase analysisdestruct x builds a match with one branch (hole) per constructor.
if b as b0 return ((b0 || true)%bool = true) then ?Goal else ?Goal0match x with | C₁ … => ?g₁ | C₂ … => ?g₂ enddestruct xCase analysis on a numberOn nat the branches are `match` arms: one for 0 and one for S m.
match n as n0 return (n0 = 0 \/ (exists m : nat, n0 = S m)) with | 0 => ?Goal | S n0 => (fun m : nat => ?Goal0) n0 endmatch x with | C₁ … => ?g₁ | C₂ … => ?g₂ endinduction xInduction on natinduction n applies the induction principle nat_ind to a predicate, a base hole and a step hole.
nat_ind (fun n0 : nat => n0 = n0 + 0) ?Goal (fun (n' : nat) (IHn' : n' = n' + 0) => ?Goal0) nnat_ind P ?base ?step xinduction xInduction on a listThe same shape for another inductive type: list_ind.
list_ind (fun l0 : list nat => l0 ++ nil = l0) ?Goal (fun (h : nat) (t : list nat) (IHt : t ++ nil = t) => ?Goal0) lnat_ind P ?base ?step xsplitProving a conjunctionsplit on P /\ Q builds conj with two holes.
conj ?Goal ?Goal0conj ?l ?rleftChoosing the left disjunctleft on P \/ Q builds or_introl.
or_introl ?Goalor_introl ?lrightChoosing the right disjunctright on P \/ Q builds or_intror.
or_intror ?Goalor_intror ?rassert (H : P)Proving a helper factassert introduces a local lemma: a function applied to its own proof.
let H : Q := ?Goal in ?Goal0let H : P := ?proof in ?restrewrite HRewriting with an equationrewrite uses an equality eliminator (eq_ind / eq_ind_r) driven by H.
eq_ind_r (fun a0 : nat => b = a0) ?Goal Heq_ind_r (fun x => …) ?g Hrewrite <- HRewriting right to leftrewrite <- H is the mirror image of rewrite H.
eq_ind a (fun b0 : nat => b0 = a) ?Goal b Heq_ind x (fun y => …) ?g y HassumptionFinding the hypothesisassumption fills the hole with the first hypothesis whose type matches.
(_ : P) (q : Q) => qthe hypothesisdiscriminateImpossible equationsdiscriminate derives False from a constructor clash.
let H0 : False := eq_ind (S n) (fun e : nat => match e with | 0 => False | S _ => True end) I 0 H in False_ind False H0False_ind … (eq_ind … I … H)revert xPutting a variable back in the goalrevert abstracts the goal over x; the term is a hole applied to x, not a fun.
?Goal n?m xexists tProviding a witnessexists t builds ex_intro with the witness and a hole for the proof.
(ex_intro (fun n : nat => n + 1 = 3) 2 ?Goal)ex_intro P t ?proof