induction x in Rocq (Coq)
The same shape for another inductive type: list_ind.
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 app_nil_ex : forall l : list nat, l ++ nil = l.Starts with a single hole whose type is the statement.?Goal1 open goal: ?Goal
intros l.Built(fun l : list nat => ?Goal).(fun l : list nat => ?Goal)
1 open goal: ?Goal
induction l as [| h t IHt].Builtlist_ind (fun l0 : list nat => l0 ++ nil = l0) ?Goal (fun (h : nat) (t : list nat) (IHt : t ++ nil = t) => ?Goal0) l.(fun l : list nat => list_ind (fun l0 : list nat => l0 ++ nil = l0) ?Goal (fun (h : nat) (t : list nat) (IHt : t ++ nil = t) => ?Goal0) l)
2 open goals: ?Goal, ?Goal0
-Builds no new structure.(fun l : list nat => list_ind (fun l0 : list nat => l0 ++ nil = l0) ?Goal (fun (h : nat) (t : list nat) (IHt : t ++ nil = t) => ?Goal0) l)
2 open goals: ?Goal, ?Goal0
reflexivity.Builteq_refl.(fun l : list nat => list_ind (fun l0 : list nat => l0 ++ nil = l0) eq_refl (fun (h : nat) (t : list nat) (IHt : t ++ nil = t) => ?Goal) l)
1 open goal: ?Goal
-Builds no new structure.(fun l : list nat => list_ind (fun l0 : list nat => l0 ++ nil = l0) eq_refl (fun (h : nat) (t : list nat) (IHt : t ++ nil = t) => ?Goal) l)1 open goal: ?Goal
simpl.Built?Goal : (h :: t) ++ nil = h :: t.(fun l : list nat => list_ind (fun l0 : list nat => l0 ++ nil = l0) eq_refl (fun (h : nat) (t : list nat) (IHt : t ++ nil = t) => ?Goal : (h :: t) ++ nil = h :: t) l)
1 open goal: ?Goal
rewrite IHt.Builteq_ind_r (fun l0 : list nat => h :: l0 = h :: t) ?Goal IHt.(fun l : list nat => list_ind (fun l0 : list nat => l0 ++ nil = l0) eq_refl (fun (h : nat) (t : list nat) (IHt : t ++ nil = t) => eq_ind_r (fun l0 : list nat => h :: l0 = h :: t) ?Goal IHt : (h :: t) ++ nil = h :: t) l)
1 open goal: ?Goal
reflexivity.Builteq_refl.(fun l : list nat => list_ind (fun l0 : list nat => l0 ++ nil = l0) eq_refl (fun (h : nat) (t : list nat) (IHt : t ++ nil = t) => eq_ind_r (fun l0 : list nat => h :: l0 = h :: t) eq_refl IHt : (h :: t) ++ nil = h :: t) l)No holes left: the term is complete.
Qed.The kernel type-checks the finished term against the statement.app_nil_ex : forall l : list nat, l ++ nil = l
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 nat
- 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