-
-
Notifications
You must be signed in to change notification settings - Fork 57
/
coq.sample
36 lines (30 loc) · 888 Bytes
/
coq.sample
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
From Coq Require Import ssreflect.
(* ensure proofs are well-structured *)
Set Default Goal Selector "!".
#[global] Open Scope general_if_scope.
Module list_playground.
(* Let's do a typical proof by induction: we'll define [list] as an inductive,
[app] (list append) as a recursive function, and prove that [app] is
associative. *)
Inductive list (A: Type) :=
| nil
| cons (x: A) (l: list A).
(* Fix up implicit arguments. *)
Arguments nil {A}.
Arguments cons {A} x l.
Notation "[]" := nil.
Infix "::" := cons.
Fixpoint app {A} (l1 l2: list A): list A :=
match l1 with
| [] => l2
| x :: l1 => x :: app l1 l2
end.
Infix "++" := app.
Theorem app_assoc {A} (l1 l2 l3: list A) :
(l1 ++ l2) ++ l3 = l1 ++ (l2 ++ l3).
Proof.
induction l1 as [|x l1]; simpl.
- reflexivity.
- by rewrite IHl1.
Qed.
End list_playground.