destruct x in Rocq (Coq)
On nat the branches are `match` arms: one for 0 and one for S m.
General shape: match x with | C₁ … => ?g₁ | C₂ … => ?g₂ end. One branch (hole) per constructor. For bool, Coq prints the match as if … then … else.
Step by step: the proof term after each sentence
Recorded from Coq with Show Proof. after every sentence. Teal is what the sentence built; ?Goal pills are holes still to fill.
Theorem destruct_nat_ex : forall n : nat, n = 0 \/ exists m, n = S m.Starts with a single hole whose type is the statement.?Goal1 open goal: ?Goal
intros n.Built(fun n : nat => ?Goal).(fun n : nat => ?Goal)
1 open goal: ?Goal
destruct n as [| m].Builtmatch n as n0 return (n0 = 0 \/ (exists m : nat, n0 = S m)) with | 0 => ?Goal | S n0 => (fun m : nat => ?Goal0) n0 end.(fun n : nat => match n as n0 return (n0 = 0 \/ (exists m : nat, n0 = S m)) with | 0 => ?Goal | S n0 => (fun m : nat => ?Goal0) n0 end)
2 open goals: ?Goal, ?Goal0
-Builds no new structure.(fun n : nat => match n as n0 return (n0 = 0 \/ (exists m : nat, n0 = S m)) with | 0 => ?Goal | S n0 => (fun m : nat => ?Goal0) n0 end)
2 open goals: ?Goal, ?Goal0
left.Builtor_introl ?Goal0.(fun n : nat => match n as n0 return (n0 = 0 \/ (exists m : nat, n0 = S m)) with | 0 => or_introl ?Goal0 | S n0 => (fun m : nat => ?Goal) n0 end)
2 open goals: ?Goal0, ?Goal
reflexivity.Builteq_refl.(fun n : nat => match n as n0 return (n0 = 0 \/ (exists m : nat, n0 = S m)) with | 0 => or_introl eq_refl | S n0 => (fun m : nat => ?Goal) n0 end)
1 open goal: ?Goal
-Builds no new structure.(fun n : nat => match n as n0 return (n0 = 0 \/ (exists m : nat, n0 = S m)) with | 0 => or_introl eq_refl | S n0 => (fun m : nat => ?Goal) n0 end)1 open goal: ?Goal
right.Builtor_intror ?Goal.(fun n : nat => match n as n0 return (n0 = 0 \/ (exists m : nat, n0 = S m)) with | 0 => or_introl eq_refl | S n0 => (fun m : nat => or_intror ?Goal) n0 end)
1 open goal: ?Goal
exists m.Built(ex_intro (fun m0 : nat => S m = S m0) m ?Goal).(fun n : nat => match n as n0 return (n0 = 0 \/ (exists m : nat, n0 = S m)) with | 0 => or_introl eq_refl | S n0 => (fun m : nat => or_intror (ex_intro (fun m0 : nat => S m = S m0) m ?Goal)) n0 end)
1 open goal: ?Goal
reflexivity.Builteq_refl.(fun n : nat => match n as n0 return (n0 = 0 \/ (exists m : nat, n0 = S m)) with | 0 => or_introl eq_refl | S n0 => (fun m : nat => or_intror (ex_intro (fun m0 : nat => S m = S m0) m eq_refl)) n0 end)No holes left: the term is complete.
Qed.The kernel type-checks the finished term against the statement.destruct_nat_ex : forall n : nat, n = 0 \/ (exists m : nat, n = S m)
Print Assumptions: Closed under the global context
Other tactics
- intro / intros Introducing hypotheses
- apply H Applying a hypothesis
- exact t Giving the term directly
- reflexivity Closing an equation
- destruct x Case analysis
- induction x Induction on nat
- induction x Induction on a list
- split Proving a conjunction
- left Choosing the left disjunct
- right Choosing the right disjunct
- assert (H : P) Proving a helper fact
- rewrite H Rewriting with an equation
- rewrite <- H Rewriting right to left
- assumption Finding the hypothesis
- discriminate Impossible equations
- revert x Putting a variable back in the goal
- exists t Providing a witness