induction x in Rocq (Coq)
induction n applies the induction principle nat_ind to a predicate, a base hole and a step hole.
General shape: nat_ind P ?base ?step x. The induction principle applied to the predicate P, a base case, a step case (with the induction hypothesis as an extra argument) and x.
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 plus_n_O_ex : forall n : nat, n = n + 0.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
induction n as [| n' IHn'].Builtnat_ind (fun n0 : nat => n0 = n0 + 0) ?Goal (fun (n' : nat) (IHn' : n' = n' + 0) => ?Goal0) n.(fun n : nat => nat_ind (fun n0 : nat => n0 = n0 + 0) ?Goal (fun (n' : nat) (IHn' : n' = n' + 0) => ?Goal0) n)
2 open goals: ?Goal, ?Goal0
-Builds no new structure.(fun n : nat => nat_ind (fun n0 : nat => n0 = n0 + 0) ?Goal (fun (n' : nat) (IHn' : n' = n' + 0) => ?Goal0) n)
2 open goals: ?Goal, ?Goal0
reflexivity.Builteq_refl.(fun n : nat => nat_ind (fun n0 : nat => n0 = n0 + 0) eq_refl (fun (n' : nat) (IHn' : n' = n' + 0) => ?Goal) n)
1 open goal: ?Goal
-Builds no new structure.(fun n : nat => nat_ind (fun n0 : nat => n0 = n0 + 0) eq_refl (fun (n' : nat) (IHn' : n' = n' + 0) => ?Goal) n)1 open goal: ?Goal
simpl.Built?Goal : S n' = S n' + 0.(fun n : nat => nat_ind (fun n0 : nat => n0 = n0 + 0) eq_refl (fun (n' : nat) (IHn' : n' = n' + 0) => ?Goal : S n' = S n' + 0) n)
1 open goal: ?Goal
rewrite <- IHn'.Builteq_ind n' (fun n0 : nat => S n' = S n0) ?Goal (n' + 0) IHn'.(fun n : nat => nat_ind (fun n0 : nat => n0 = n0 + 0) eq_refl (fun (n' : nat) (IHn' : n' = n' + 0) => eq_ind n' (fun n0 : nat => S n' = S n0) ?Goal (n' + 0) IHn' : S n' = S n' + 0) n)
1 open goal: ?Goal
reflexivity.Builteq_refl.(fun n : nat => nat_ind (fun n0 : nat => n0 = n0 + 0) eq_refl (fun (n' : nat) (IHn' : n' = n' + 0) => eq_ind n' (fun n0 : nat => S n' = S n0) eq_refl (n' + 0) IHn' : S n' = S n' + 0) n)No holes left: the term is complete.
Qed.The kernel type-checks the finished term against the statement.plus_n_O_ex : forall n : nat, n = n + 0
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
- destruct x Case analysis on a number
- 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