Built with Alectryon, running Coq+SerAPI v8.19.0+0.19.3. Bubbles () indicate interactive fragments: hover for details, tap to reveal contents. Use Ctrl+↑Ctrl+↓ to navigate, Ctrl+🖱️ to focus. On Mac, use ⌘ instead of Ctrl.
[Loading ML file number_string_notation_plugin.cmxs (using legacy method) ... done]
LocalOpen Scope nat_scope.LocalOpen Scope type_scope.Declare Scope ne_list_scope.Delimit Scope ne_list_scope with ne_list.Open Scope ne_list_scope.(** Nonempty list implementation [ne_list.ne_list]. *)Modulene_list.Sectionwith_type.Context {T: Type}.(** A nonempty list. Below there is an implicit coercion [ne_list >-> list]. *)Inductivene_list : Type
:= one: T → ne_list | cons: T → ne_list → ne_list.Fixpointapp (ab: ne_list): ne_list :=
match a with
| one x => cons x b
| cons x y => cons x (app y b)
end.Fixpointfoldr {R} (u: T → R) (f: T → R → R) (a: ne_list): R :=
match a with
| one x => u x
| cons x y => f x (foldr u f y)
end.Fixpointfoldr1 (f: T → T → T) (a: ne_list): T :=
match a with
| one x => x
| cons x y => f x (foldr1 f y)
end.Definitionhead (l: ne_list): T
:= match l with one x => x | cons x _ => x end.Fixpointto_list (l: ne_list): list T :=
match l with
| one x => x :: nil
| cons x xs => x :: to_list xs
end.Fixpointfrom_list (x: T) (xs: list T): ne_list :=
match xs with
| nil => one x
| List.Core.cons h t => cons x (from_list h t)
end.Definitiontail (l: ne_list): list T
:= match l with one _ => nil | cons _ x => to_list x end.
T: Type l: ne_list
l = from_list (head l) (tail l)
T: Type l: ne_list
l = from_list (head l) (tail l)
T: Type t: T l: ne_list IHl: l = from_list (head l) (tail l)
cons t l =
from_list (head (cons t l)) (tail (cons t l))
T: Type t, t0: T l: ne_list IHl: cons t0 l = from_list (head (cons t0 l)) (tail (cons t0 l))
cons t (cons t0 l) =
from_list (head (cons t (cons t0 l)))
(tail (cons t (cons t0 l)))
T: Type t, t0: T l: ne_list IHl: cons t0 l = from_list t0 (to_list l)
cons t (cons t0 l) = cons t (from_list t0 (to_list l))
rewrite IHl...Qed.Definitionlast: ne_list → T := foldr1 (funxy => y).Fixpointreplicate_Sn (x: T) (n: nat): ne_list :=
match n with
| 0 => one x
| S n' => cons x (replicate_Sn x n')
end.Fixpointtake (n: nat) (l: ne_list): ne_list :=
match l, n with
| cons x xs, S n' => take n' xs
| _, _ => one (head l)
end.Fixpointfront (l: ne_list) : list T :=
match l with
| one _ => nil
| cons x xs => x :: front xs
end.
T: Type P: ne_list -> Type Pone: forallx : T, P (one x) Ptwo: forallxy : T, P (cons x (one y)) Pmore: forall (xy : T) (z : ne_list),
P z ->
(forally' : T, P (cons y' z)) ->
P (cons x (cons y z))
foralll : ne_list, P l
T: Type P: ne_list -> Type Pone: forallx : T, P (one x) Ptwo: forallxy : T, P (cons x (one y)) Pmore: forall (xy : T) (z : ne_list),
P z ->
(forally' : T, P (cons y' z)) ->
P (cons x (cons y z))
foralll : ne_list, P l
T: Type P: ne_list -> Type Pone: forallx : T, P (one x) Ptwo: forallxy : T, P (cons x (one y)) Pmore: forall (xy : T) (z : ne_list),
P z ->
(forally' : T, P (cons y' z)) ->
P (cons x (cons y z))
(foralll : ne_list,
P l * (forallx : T, P (cons x l))) ->
foralll : ne_list, P l
T: Type P: ne_list -> Type Pone: forallx : T, P (one x) Ptwo: forallxy : T, P (cons x (one y)) Pmore: forall (xy : T) (z : ne_list),
P z ->
(forally' : T, P (cons y' z)) ->
P (cons x (cons y z))
foralll : ne_list, P l * (forallx : T, P (cons x l))
T: Type P: ne_list -> Type Pone: forallx : T, P (one x) Ptwo: forallxy : T, P (cons x (one y)) Pmore: forall (xy : T) (z : ne_list),
P z ->
(forally' : T, P (cons y' z)) ->
P (cons x (cons y z))
(foralll : ne_list,
P l * (forallx : T, P (cons x l))) ->
foralll : ne_list, P l
T: Type P: ne_list -> Type Pone: forallx : T, P (one x) Ptwo: forallxy : T, P (cons x (one y)) Pmore: forall (xy : T) (z : ne_list),
P z ->
(forally' : T, P (cons y' z)) ->
P (cons x (cons y z)) X: foralll : ne_list,
P l * (forallx : T, P (cons x l)) l: ne_list
P l
apply X.
T: Type P: ne_list -> Type Pone: forallx : T, P (one x) Ptwo: forallxy : T, P (cons x (one y)) Pmore: forall (xy : T) (z : ne_list),
P z ->
(forally' : T, P (cons y' z)) ->
P (cons x (cons y z))
foralll : ne_list, P l * (forallx : T, P (cons x l))
T: Type P: ne_list -> Type Pone: forallx : T, P (one x) Ptwo: forallxy : T, P (cons x (one y)) Pmore: forall (xy : T) (z : ne_list),
P z ->
(forally' : T, P (cons y' z)) ->
P (cons x (cons y z)) t: T l: ne_list
P (cons t l) * (forallx : T, P (cons x (cons t l)))
T: Type P: ne_list -> Type Pone: forallx : T, P (one x) Ptwo: forallxy : T, P (cons x (one y)) Pmore: forall (xy : T) (z : ne_list),
P z ->
(forally' : T, P (cons y' z)) ->
P (cons x (cons y z)) l: ne_list
forallt : T,
P (cons t l) * (forallx : T, P (cons x (cons t l)))
T: Type P: ne_list -> Type Pone: forallx : T, P (one x) Ptwo: forallxy : T, P (cons x (one y)) Pmore: forall (xy : T) (z : ne_list),
P z ->
(forally' : T, P (cons y' z)) ->
P (cons x (cons y z)) t: T l: ne_list IHl: forallt : T,
P (cons t l) *
(forallx : T, P (cons x (cons t l)))
forallt0 : T,
P (cons t0 (cons t l)) *
(forallx : T, P (cons x (cons t0 (cons t l))))
T: Type P: ne_list -> Type Pone: forallx : T, P (one x) Ptwo: forallxy : T, P (cons x (one y)) Pmore: forall (xy : T) (z : ne_list),
P z ->
(forally' : T, P (cons y' z)) ->
P (cons x (cons y z)) t: T l: ne_list IHl: forallt : T,
P (cons t l) *
(forallx : T, P (cons x (cons t l))) t0: T
P (cons t0 (cons t l)) *
(forallx : T, P (cons x (cons t0 (cons t l))))
T: Type P: ne_list -> Type Pone: forallx : T, P (one x) Ptwo: forallxy : T, P (cons x (one y)) Pmore: forall (xy : T) (z : ne_list),
P z ->
(forally' : T, P (cons y' z)) ->
P (cons x (cons y z)) t: T l: ne_list IHl: forallt : T,
P (cons t l) *
(forallx : T, P (cons x (cons t l))) t0: T
P (cons t0 (cons t l))
T: Type P: ne_list -> Type Pone: forallx : T, P (one x) Ptwo: forallxy : T, P (cons x (one y)) Pmore: forall (xy : T) (z : ne_list),
P z ->
(forally' : T, P (cons y' z)) ->
P (cons x (cons y z)) t: T l: ne_list IHl: forallt : T,
P (cons t l) *
(forallx : T, P (cons x (cons t l))) t0: T
forallx : T, P (cons x (cons t0 (cons t l)))
T: Type P: ne_list -> Type Pone: forallx : T, P (one x) Ptwo: forallxy : T, P (cons x (one y)) Pmore: forall (xy : T) (z : ne_list),
P z ->
(forally' : T, P (cons y' z)) ->
P (cons x (cons y z)) t: T l: ne_list IHl: forallt : T,
P (cons t l) *
(forallx : T, P (cons x (cons t l))) t0: T
P (cons t0 (cons t l))
apply IHl.
T: Type P: ne_list -> Type Pone: forallx : T, P (one x) Ptwo: forallxy : T, P (cons x (one y)) Pmore: forall (xy : T) (z : ne_list),
P z ->
(forally' : T, P (cons y' z)) ->
P (cons x (cons y z)) t: T l: ne_list IHl: forallt : T,
P (cons t l) *
(forallx : T, P (cons x (cons t l))) t0: T
forallx : T, P (cons x (cons t0 (cons t l)))
T: Type P: ne_list -> Type Pone: forallx : T, P (one x) Ptwo: forallxy : T, P (cons x (one y)) Pmore: forall (xy : T) (z : ne_list),
P z ->
(forally' : T, P (cons y' z)) ->
P (cons x (cons y z)) t: T l: ne_list IHl: forallt : T,
P (cons t l) *
(forallx : T, P (cons x (cons t l))) t0, x: T
destruct l; reflexivity.Qed.Endwith_type.Arguments ne_list : clear implicits.Fixpointtails {T} (l: ne_list T): ne_list (ne_list T) :=
match l with
| one x => one (one x)
| cons x y => cons l (tails y)
end.
T: Type t: T y, x: ne_list T IHy: InList x (to_list (tails y)) -> length (to_list x) <= length (to_list y)
(cons t y = x) + InList x (to_list (tails y)) ->
length (to_list x) <= (length (to_list y)).+1
T: Type t: T x: ne_list T
(one t = x) + Empty -> length (to_list x) <= 1
T: Type t: T x: ne_list T
length (to_list (one t)) <= 1
T: Type t: T x: ne_list T C: Empty
length (to_list x) <= 1
T: Type t: T x: ne_list T
length (to_list (one t)) <= 1
constructor.
T: Type t: T x: ne_list T C: Empty
length (to_list x) <= 1
elim C.
T: Type t: T y, x: ne_list T IHy: InList x (to_list (tails y)) -> length (to_list x) <= length (to_list y)
(cons t y = x) + InList x (to_list (tails y)) ->
length (to_list x) <= (length (to_list y)).+1
T: Type t: T y, x: ne_list T IHy: InList x (to_list (tails y)) -> length (to_list x) <= length (to_list y)
length (to_list (cons t y)) <= (length (to_list y)).+1
T: Type t: T y, x: ne_list T IHy: InList x (to_list (tails y)) -> length (to_list x) <= length (to_list y) C: InList x (to_list (tails y))
length (to_list x) <= (length (to_list y)).+1
T: Type t: T y, x: ne_list T IHy: InList x (to_list (tails y)) -> length (to_list x) <= length (to_list y)
length (to_list (cons t y)) <= (length (to_list y)).+1
exact _.
T: Type t: T y, x: ne_list T IHy: InList x (to_list (tails y)) -> length (to_list x) <= length (to_list y) C: InList x (to_list (tails y))
length (to_list x) <= (length (to_list y)).+1
byapply leq_succ_r, IHy.Qed.Fixpointmap {AB} (f: A → B) (l: ne_list A): ne_list B :=
match l with
| one x => one (f x)
| cons h t => cons (f h) (map f t)
end.
A, B: Type f: A -> B l: ne_list A
to_list (map f l) = list_map f (to_list l)
A, B: Type f: A -> B l: ne_list A
to_list (map f l) = list_map f (to_list l)
A, B: Type f: A -> B t: A
to_list (map f (one t)) = list_map f (to_list (one t))
A, B: Type f: A -> B t: A l: ne_list A IHl: to_list (map f l) = list_map f (to_list l)
to_list (map f (cons t l)) =
list_map f (to_list (cons t l))
A, B: Type f: A -> B t: A
to_list (map f (one t)) = list_map f (to_list (one t))
reflexivity.
A, B: Type f: A -> B t: A l: ne_list A IHl: to_list (map f l) = list_map f (to_list l)
to_list (map f (cons t l)) =
list_map f (to_list (cons t l))
A, B: Type f: A -> B t: A l: ne_list A IHl: to_list (map f l) = list_map f (to_list l)
(f t :: to_list (map f l))%list =
(f t :: list_map f (to_list l))%list
A, B: Type f: A -> B t: A l: ne_list A IHl: to_list (map f l) = list_map f (to_list l)
(f t :: to_list (map f l))%list =
(f t :: to_list (map f l))%list
reflexivity.Qed.Fixpointinits {A} (l: ne_list A): ne_list (ne_list A) :=
match l with
| one x => one (one x)
| cons h t => cons (one h) (map (cons h) (inits t))
end.Fixpointzip {AB: Type} (l: ne_list A) (m: ne_list B)
: ne_list (A * B) :=
match l with
| one a => one (a, head m)
| cons a l =>
match m with
| one b => one (a, b)
| cons b m => cons (a, b) (zip l m)
endend.Modulenotations.Global Notationne_list := ne_list.GlobalNotation"[: x :]" := (one x) : ne_list_scope.GlobalNotation"[: x ; .. ; y ; z :]"
:= (cons x .. (cons y (one z)) ..) : ne_list_scope.GlobalInfix":::" := cons : ne_list_scope.Endnotations.Endne_list.Global Coercionne_list.to_list : ne_list.ne_list >-> list.