Rocq proof terms formerly Coq

Case analysis on a numberdestruct x

On nat the branches are `match` arms: one for 0 and one for S m.

Tactic script

Theorem destruct_nat_ex : forall n : nat, n = 0 \/ exists m, n = S m.
Proof.
  intros n.
  destruct n as [| m].
  - left.
    reflexivity.
  - right.
    exists m.
    reflexivity.
Qed.

Proof term

MMMMMMMMMM
destruct n as [| m]. built match 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  with
     | 0 => ?Goal
     | S n0 => (fun (m : nat) => ?Goal0) n0
   end)

Open goals (2) one per hole

  • ?Goalcurrent goal
    ⊢ 0 = 0 \/ (exists m : nat, 0 = S m)
  • ?Goal0goal 2
    m : nat
    ⊢ S m = 0 \/ (exists m0 : nat, S m = S m0)
built by the current tactichole: a goal still to fillearlier tactics greyed · later ones dashed

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.

  1. Theorem destruct_nat_ex : forall n : nat, n = 0 \/ exists m, n = S m. Starts with a single hole whose type is the statement.
    ?Goal

    1 open goal: ?Goal

  2. intros n. Built (fun n : nat => ?Goal).
    (fun n : nat => ?Goal)

    1 open goal: ?Goal

  3. destruct n as [| m]. Built match 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

  4. - 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

  5. left. Built or_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

  6. reflexivity. Built eq_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

  7. - 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

  8. right. Built or_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

  9. 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

  10. reflexivity. Built eq_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.

  11. 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