File tree Expand file tree Collapse file tree 3 files changed +29
-2
lines changed
Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ Section EqDec.
5858 Qed .
5959End EqDec.
6060
61+ (* Specialized induction rules *)
6162Lemma list_ind_singleton
6263: forall {T : Type } (P : list T -> Prop )
6364 (Hnil : P nil)
@@ -69,6 +70,17 @@ Proof.
6970 destruct ls. eauto. eauto.
7071Qed .
7172
73+ Lemma list_rev_ind
74+ : forall T (P : list T -> Prop),
75+ P nil ->
76+ (forall l ls, P ls -> P (ls ++ l :: nil)) ->
77+ forall ls, P ls.
78+ Proof .
79+ clear. intros. rewrite <- rev_involutive.
80+ induction (rev ls).
81+ apply H.
82+ simpl. auto.
83+ Qed .
7284
7385Section AllB.
7486 Variable T : Type.
Original file line number Diff line number Diff line change @@ -107,3 +107,9 @@ Global Instance Injective_S (a b : nat) : Injective (S a = S b) :=
107107}.
108108abstract (inversion 1; auto).
109109Defined .
110+
111+ Definition nat_get_eq (n m : nat) (pf : unit -> n = m) : n = m :=
112+ match PeanoNat.Nat.eq_dec n m with
113+ | left pf => pf
114+ | right bad => match bad (pf tt) with end
115+ end .
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ Require Import ExtLib.Structures.Functor.
22Require Import ExtLib.Structures.Applicative.
33Require Import ExtLib.Data.POption.
44
5- Set Printing Universes .
5+ Set Universe Polymorphism .
66
77Section plist.
88 Polymorphic Universe i.
@@ -24,7 +24,6 @@ Section plist.
2424 | pcons l ls => pcons l (app ls ls')
2525 end .
2626
27-
2827 Polymorphic Definition hd (ls : plist) : poption T :=
2928 match ls with
3029 | pnil => pNone
@@ -55,6 +54,13 @@ Section plist.
5554 | pcons l ls0 => if p l then anyb p ls0 else false
5655 end .
5756
57+ Polymorphic Fixpoint nth_error (ls : plist) (n : nat) : poption T :=
58+ match n , ls with
59+ | 0 , pcons l _ => pSome l
60+ | S n , pcons _ ls => nth_error ls n
61+ | _ , _ => pNone
62+ end .
63+
5864 Section folds.
5965 Polymorphic Universe j.
6066 Context {U : Type@{j}}.
@@ -80,6 +86,9 @@ Arguments pcons {_} _ _.
8086Arguments pIn {_} _ _.
8187Arguments anyb {_} _ _.
8288Arguments allb {_} _ _.
89+ Arguments fold_left {_ _} _ _ _.
90+ Arguments fold_right {_ _} _ _ _.
91+ Arguments nth_error {_} _ _.
8392
8493Section pmap.
8594 Polymorphic Universe i j.
You can’t perform that action at this time.
0 commit comments