Here is the code from the book:
Example In_example_2 :
forall n, In n [2; 4] ->
exists n', n = 2 * n'.
Proof.
(* WORKED IN CLASS *)
simpl.
intros n [H | [H | []]].
- exists 1. rewrite <- H. reflexivity.
- exists 2. rewrite <- H. reflexivity.
Qed.
After simpl.
In
is transformed into a disjunction of 3 elements:
============================
forall n : nat, 2 = n \/ 4 = n \/ False -> exists n' : nat, n = n' + (n' + 0)
But I totally don't understand how to read this:
intros n [H | [H | []]].
It produced this:
n : nat
H : 2 = n
============================
exists n' : nat, n = n' + (n' + 0)
subgoal 2 (ID 229) is:
exists n' : nat, n = n' + (n' + 0)
What I understood:
- It put n from
forall
into the context. - It split disjunction of 3 elements into 2 subgoals, ignoring False:
- Created 2 subgoals according to the number of splits.
There is also a notice at the bottom:
(** (Notice the use of the empty pattern to discharge the last case
_en passant_.) *)
En passant (French: [ɑ̃ paˈsɑ̃], lit. in passing) is a move in chess. It is a special pawn capture that can only occur immediately after a pawn makes a move of two squares from its starting square, and when it could have been captured by an enemy pawn had it advanced only one square.
Looking at this:
intros n [H | [H | []]].
Can somebody explain me:
- Should command of this form be used for destructing forall? Is there something else for this task?
- How to read this command in English?
- Why
[H | []]
was put into another pair of brackets? - How
[]
told coq to ignore the False statement? - When this command should be used in general?