Skip to content

Commit ad3e508

Browse files
author
Gregory Malecha
committed
working on porting to 8.5 beta 3
1 parent 9e72791 commit ad3e508

File tree

9 files changed

+210
-75
lines changed

9 files changed

+210
-75
lines changed

_CoqProject

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
-Q theories ExtLib
2+
3+
4+
theories/ExtLib.v
5+
theories/Tactics.v
6+
7+
theories/Core/Any.v
8+
theories/Core/CmpDec.v
9+
theories/Core/EquivDec.v
10+
theories/Core/RelDec.v
11+
theories/Core/Type.v
12+
13+
theories/Structures/Applicative.v
14+
theories/Structures/BinOps.v
15+
theories/Structures/CoFunctor.v
16+
theories/Structures/CoMonad.v
17+
theories/Structures/EqDep.v
18+
theories/Structures/Foldable.v
19+
theories/Structures/FunctorLaws.v
20+
theories/Structures/Functor.v
21+
theories/Structures/Identity.v
22+
theories/Structures/Maps.v
23+
theories/Structures/MonadCont.v
24+
theories/Structures/MonadExc.v
25+
theories/Structures/MonadFix.v
26+
theories/Structures/MonadLaws.v
27+
theories/Structures/MonadPlus.v
28+
theories/Structures/MonadReader.v
29+
theories/Structures/MonadState.v
30+
theories/Structures/Monads.v
31+
theories/Structures/MonadTrans.v
32+
theories/Structures/Monad.v
33+
theories/Structures/MonadWriter.v
34+
theories/Structures/MonadZero.v
35+
theories/Structures/Monoid.v
36+
theories/Structures/Proper.v
37+
theories/Structures/Reducible.v
38+
theories/Structures/Sets.v
39+
theories/Structures/Traversable.v
40+
41+
theories/Data/Bool.v
42+
theories/Data/Char.v
43+
theories/Data/Checked.v
44+
theories/Data/Eq.v
45+
theories/Data/Fin.v
46+
theories/Data/Fun.v
47+
theories/Data/HList.v
48+
theories/Data/LazyList.v
49+
theories/Data/Lazy.v
50+
theories/Data/ListFirstnSkipn.v
51+
theories/Data/ListNth.v
52+
theories/Data/List.v
53+
theories/Data/Member.v
54+
theories/Data/Nat.v
55+
theories/Data/N.v
56+
theories/Data/Option.v
57+
theories/Data/Pair.v
58+
theories/Data/Positive.v
59+
theories/Data/PreFun.v
60+
theories/Data/Prop.v
61+
theories/Data/SigT.v
62+
theories/Data/Stream.v
63+
theories/Data/String.v
64+
theories/Data/SumN.v
65+
theories/Data/Sum.v
66+
theories/Data/Tuple.v
67+
theories/Data/Unit.v
68+
theories/Data/Vector.v
69+
theories/Data/Z.v
70+
71+
theories/Generic/Data.v
72+
theories/Generic/DerivingData.v
73+
theories/Generic/Func.v
74+
theories/Generic/Ind.v
75+
76+
theories/Programming/Eqv.v
77+
theories/Programming/Extras.v
78+
theories/Programming/Injection.v
79+
theories/Programming/Le.v
80+
theories/Programming/Show.v
81+
theories/Programming/With.v
82+
83+
theories/Recur/Facts.v
84+
theories/Recur/GenRec.v
85+
theories/Recur/Measure.v
86+
theories/Recur/Relation.v
87+
88+
theories/Relations/Compose.v
89+
theories/Relations/TransitiveClosure.v
90+
91+
theories/Tactics/BoolTac.v
92+
theories/Tactics/Cases.v
93+
theories/Tactics/Consider.v
94+
theories/Tactics/EqDep.v
95+
theories/Tactics/Equality.v
96+
theories/Tactics/Forward.v
97+
theories/Tactics/Injection.v
98+
theories/Tactics/MonadTac.v
99+
theories/Tactics/Parametric.v
100+
theories/Tactics/Reify.v
101+
theories/Tactics/TypeTac.v
102+
103+
theories/Data/Graph/BuildGraph.v
104+
theories/Data/Graph/GraphAdjList.v
105+
theories/Data/Graph/GraphAlgos.v
106+
theories/Data/Graph/Graph.v
107+
108+
theories/Data/Map/FMapAList.v
109+
theories/Data/Map/FMapPositive.v
110+
theories/Data/Map/FMapTwoThreeK.v
111+
112+
theories/Data/Monads/ContMonad.v
113+
theories/Data/Monads/EitherMonad.v
114+
theories/Data/Monads/FuelMonadLaws.v
115+
theories/Data/Monads/FuelMonad.v
116+
theories/Data/Monads/IdentityMonadLaws.v
117+
theories/Data/Monads/IdentityMonad.v
118+
theories/Data/Monads/ListMonad.v
119+
theories/Data/Monads/OptionMonadLaws.v
120+
theories/Data/Monads/OptionMonad.v
121+
theories/Data/Monads/ReaderMonadLaws.v
122+
theories/Data/Monads/ReaderMonad.v
123+
theories/Data/Monads/StateMonad.v
124+
theories/Data/Monads/WriterMonad.v
125+
theories/Data/Set/ListSet.v
126+
theories/Data/Set/SetMap.v
127+
theories/Data/Set/TwoThreeTrees.v

theories/Core/Type.v

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ Require Import ExtLib.Structures.Proper.
55
** Proper elements are the elements for which the equivalence
66
** relation is reflexive.
77
**)
8-
Polymorphic Class type (T : Type) : Type :=
8+
Polymorphic Class type@{t} (T : Type@{t}) : Type :=
99
{ equal : T -> T -> Prop
1010
; proper : T -> Prop
1111
}.
1212

13-
Polymorphic Definition type_from_equal {T} (r : T -> T -> Prop) : type T :=
13+
Polymorphic Definition type_from_equal@{t} {T : Type@{t}} (r : T -> T -> Prop) : type@{t} T :=
1414
{| equal := r
1515
; proper := fun x => r x x
1616
|}.
1717

18-
Polymorphic Definition type_libniz T : type T :=
18+
Polymorphic Definition type_libniz@{t} (T : Type@{t}) : type@{t} T :=
1919
{| equal := @eq T
2020
; proper := fun _ => True
2121
|}.
@@ -58,23 +58,25 @@ Section type.
5858
End type.
5959

6060

61-
Polymorphic Definition type1 (F : Type@{d} -> Type@{r}) : Type :=
62-
forall {T:Type@{d}}, type T -> type (F T).
61+
Polymorphic Definition type1@{d r z} (F : Type@{d} -> Type@{r}) : Type@{z} :=
62+
forall {T:Type@{d}}, type@{d} T -> type@{r} (F T).
6363

64-
Polymorphic Definition type2 (F : Type@{t} -> Type@{u} -> Type@{v}) : Type :=
64+
Polymorphic Definition type2@{t u v z} (F : Type@{t} -> Type@{u} -> Type@{v}) : Type@{z} :=
6565
forall {T:Type@{t}}, type T -> forall {U:Type@{u}}, type U -> type (F T U).
6666

67-
Polymorphic Definition type3 (F : Type@{t} -> Type@{u} -> Type@{v} -> Type@{w}) : Type :=
67+
Polymorphic Definition type3@{t u v w z} (F : Type@{t} -> Type@{u} -> Type@{v} -> Type@{w}) : Type@{z} :=
6868
forall {T:Type@{t}}, type T -> forall {U:Type@{u}}, type U -> forall {V:Type@{w}}, type V -> type (F T U V).
6969

70-
Polymorphic Definition typeOk1 F (tF : type1 F) : Type :=
71-
forall T tT, @typeOk T tT -> typeOk (tF _ tT).
70+
Polymorphic Definition typeOk1@{d r z} (F : Type@{d} -> Type@{r}) (tF : type1@{d r z} F) : Type@{z} :=
71+
forall (T : Type@{d}) tT, @typeOk T tT -> typeOk (tF _ tT).
7272

73-
Polymorphic Definition typeOk2 F (tF : type2 F) : Type :=
74-
forall T tT, @typeOk T tT -> typeOk1 _ (tF _ tT).
73+
Polymorphic Definition typeOk2@{t u v z}
74+
(F : Type@{t} -> Type@{u} -> Type@{v}) (tF : type2@{t u v z} F)
75+
: Type@{z} :=
76+
forall (T : Type@{t}) (tT : type@{t} T), @typeOk@{t} T tT -> typeOk1@{u v z} _ (tF _ tT).
7577

76-
Polymorphic Definition typeOk3 F (tF : type3 F) : Type :=
77-
forall T tT, @typeOk T tT -> typeOk2 _ (tF _ tT).
78+
Polymorphic Definition typeOk3@{t u v w z} F (tF : type3 F) : Type@{z} :=
79+
forall (T : Type@{t}) tT, @typeOk@{t} T tT -> typeOk2@{u v w z} _ (tF _ tT).
7880

7981
Existing Class type1.
8082
Existing Class type2.

theories/Data/PreFun.v

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ Require Import ExtLib.Core.Type.
66
Set Implicit Arguments.
77
Set Strict Implicit.
88

9-
Polymorphic Definition Fun A B := A -> B.
9+
Polymorphic Definition Fun@{d c} (A : Type@{d}) (B : Type@{c}) := A -> B.
1010

1111
Section type.
12-
Polymorphic Variables (T : Type@{t}) (U : Type@{u}) (tT : type T) (tU : type U).
12+
Polymorphic Variables (T : Type) (U : Type) (tT : type T) (tU : type U).
1313

1414
Global Polymorphic Instance type_Fun : type (T -> U) :=
1515
{ equal := fun f g => respectful equal equal f g
1616
; proper := fun x => respectful equal equal x x
1717
}.
1818

19-
Variables (tOk : typeOk tT) (uOk : typeOk tU).
19+
Polymorphic Variables (tOk : typeOk tT) (uOk : typeOk tU).
2020

2121
Global Instance typeOk_Fun : typeOk type_Fun.
2222
Proof.
@@ -71,4 +71,4 @@ Section type.
7171
End type.
7272

7373
Polymorphic Definition compose {A:Type} {B:Type} {C : Type} (g : B -> C) (f : A -> B) : A -> C :=
74-
fun x => g (f x).
74+
fun x => g (f x).

theories/Structures/Applicative.v

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
Set Implicit Arguments.
22
Set Maximal Implicit Insertion.
33

4-
Polymorphic Class PApplicative (T : Type@{d} -> Type) :=
5-
{ AppP : Type@{d} -> Type
4+
Polymorphic Class PApplicative@{d c p} (T : Type@{d} -> Type@{c}) :=
5+
{ AppP : Type@{d} -> Type@{p}
66
; ppure : forall {A : Type@{d}} {P : AppP A}, A -> T A
77
; pap : forall {A B : Type@{d}} {P : AppP B}, T (A -> B) -> T A -> T B
88
}.
99

10-
Polymorphic Class Applicative (T : Type@{d} -> Type) :=
10+
Polymorphic Class Applicative@{d c} (T : Type@{d} -> Type@{c}) :=
1111
{ pure : forall {A : Type@{d}}, A -> T A
1212
; ap : forall {A B : Type@{d}}, T (A -> B) -> T A -> T B
1313
}.
@@ -18,6 +18,6 @@ End ApplicativeNotation.
1818
Import ApplicativeNotation.
1919

2020
Section applicative.
21-
Polymorphic Definition liftA {T : Type@{d} -> Type} {AT:Applicative T} {A B : Type@{d}} (f:A -> B) (aT:T A) : T B := pure f <*> aT.
22-
Polymorphic Definition liftA2 {T : Type@{d} -> Type} {AT:Applicative T} {A B C : Type@{d}} (f:A -> B -> C) (aT:T A) (bT:T B) : T C := liftA f aT <*> bT.
21+
Polymorphic Definition liftA@{d c} {T : Type@{d} -> Type@{c}} {AT:Applicative@{d c} T} {A B : Type@{d}} (f:A -> B) (aT:T A) : T B := pure f <*> aT.
22+
Polymorphic Definition liftA2@{d c} {T : Type@{d} -> Type@{c}} {AT:Applicative@{d c} T} {A B C : Type@{d}} (f:A -> B -> C) (aT:T A) (bT:T B) : T C := liftA f aT <*> bT.
2323
End applicative.

theories/Structures/CoFunctor.v

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,21 @@ Set Implicit Arguments.
44
Set Strict Implicit.
55

66
Section functor.
7-
Polymorphic Variable F : Type@{d} -> Type.
87

9-
Polymorphic Class CoFunctor : Type :=
8+
Polymorphic Class CoFunctor@{d c} (F : Type@{d} -> Type@{c}) : Type :=
109
{ cofmap : forall {A B : Type@{d}}, (B -> A) -> F A -> F B }.
1110

12-
Definition ID {T : Type} (f : T -> T) : Prop :=
13-
forall x, f x = x.
14-
15-
Polymorphic Class CoPFunctor : Type :=
16-
{ CoFunP : Type -> Type
17-
; copfmap : forall {A B} {P : CoFunP B}, (B -> A) -> F A -> F B
11+
Polymorphic Class CoPFunctor@{d c p} (F : Type@{d} -> Type@{c}) : Type :=
12+
{ CoFunP : Type@{d} -> Type@{p}
13+
; copfmap : forall {A B : Type@{d}} {P : CoFunP B}, (B -> A) -> F A -> F B
1814
}.
1915

2016
Existing Class CoFunP.
2117
Hint Extern 0 (@CoFunP _ _ _) => progress (simpl CoFunP) : typeclass_instances.
2218

23-
Global Polymorphic Instance CoPFunctor_From_CoFunctor (F : CoFunctor) : CoPFunctor :=
24-
{ CoFunP := Any
25-
; copfmap := fun _ _ _ f x => cofmap f x
26-
}.
19+
Polymorphic Definition CoPFunctor_From_CoFunctor@{d c p} (F : Type@{d} -> Type@{c}) (F_ : CoFunctor@{d c} F) : CoPFunctor@{d c p} F :=
20+
{| CoFunP := Any@{p}
21+
; copfmap := fun _ _ _ f x => cofmap f x
22+
|}.
23+
Global Existing Instance CoPFunctor_From_CoFunctor.
2724
End functor.

theories/Structures/Functor.v

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,27 @@ Require Import ExtLib.Core.Any.
33
Set Implicit Arguments.
44
Set Strict Implicit.
55

6-
Polymorphic Class Functor (F : Type@{d} -> Type) : Type :=
6+
Polymorphic Class Functor@{d c} (F : Type@{d} -> Type@{c}) : Type :=
77
{ fmap : forall {A B : Type@{d}}, (A -> B) -> F A -> F B }.
88

9-
Polymorphic Definition ID {T : Type@{d}} (f : T -> T) : Prop :=
10-
forall x, f x = x.
9+
Polymorphic Definition ID@{d} {T : Type@{d}} (f : T -> T) : Prop :=
10+
forall x : T, f x = x.
1111

12-
Polymorphic Class PFunctor (F : Type@{d} -> Type) : Type :=
13-
{ FunP : Type@{d} -> Type
12+
Polymorphic Class PFunctor@{d c p} (F : Type@{d} -> Type@{c}) : Type :=
13+
{ FunP : Type@{d} -> Type@{p}
1414
; pfmap : forall {A B : Type@{d}} {P : FunP B}, (A -> B) -> F A -> F B
1515
}.
1616

1717
Existing Class FunP.
1818
Hint Extern 0 (@FunP _ _ _) => progress (simpl FunP) : typeclass_instances.
1919

20-
Global Polymorphic Instance PFunctor_From_Functor
21-
(F : Type@{d} -> Type) (FunF : Functor F) : PFunctor F :=
22-
{ FunP := Any
20+
(** TODO: This is due to a but in current 8.5 **)
21+
Polymorphic Definition PFunctor_From_Functor@{d c p}
22+
(F : Type@{d} -> Type@{c}) (FunF : Functor@{d c} F) : PFunctor@{d c p} F :=
23+
{| FunP := Any
2324
; pfmap := fun _ _ _ f x => fmap f x
24-
}.
25+
|}.
26+
Global Existing Instance PFunctor_From_Functor.
2527

2628
Module FunctorNotation.
2729
Notation "f <$> x" := (@pfmap _ _ _ _ _ f x) (at level 51, right associativity).

theories/Structures/Monad.v

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ Require Import ExtLib.Structures.Applicative.
55
Set Implicit Arguments.
66
Set Strict Implicit.
77

8-
Polymorphic Class Monad (m : Type@{d} -> Type) : Type :=
8+
Polymorphic Class Monad@{d c} (m : Type@{d} -> Type@{c}) : Type :=
99
{ ret : forall {t : Type@{d}}, t -> m t
1010
; bind : forall {t u : Type@{d}}, m t -> (t -> m u) -> m u
1111
}.
1212

13-
Polymorphic Class PMonad (m : Type@{d} -> Type) : Type :=
14-
{ MonP : Type -> Type
13+
Polymorphic Class PMonad@{d c p} (m : Type@{d} -> Type@{c}) : Type :=
14+
{ MonP : Type@{d} -> Type@{p}
1515
; pret : forall {t : Type@{d}} {Pt : MonP t}, t -> m t
1616
; pbind : forall {t u : Type@{d}} {Pu : MonP u}, m t -> (t -> m u) -> m u
1717
}.
@@ -26,21 +26,31 @@ Global Polymorphic Instance PMonad_Monad m (M : Monad m) : PMonad m :=
2626
}.
2727

2828
Section monadic.
29-
Variable m : Type@{d} -> Type.
30-
Context {M : Monad m}.
3129

32-
Polymorphic Definition liftM {T U : Type@{d}} (f : T -> U) : m T -> m U :=
30+
Polymorphic Definition liftM@{d c}
31+
{m : Type@{d} -> Type@{c}}
32+
{M : Monad m}
33+
{T U : Type@{d}} (f : T -> U) : m T -> m U :=
3334
fun x => bind x (fun x => ret (f x)).
3435

35-
Polymorphic Definition liftM2 {T U V : Type@{d}} (f : T -> U -> V) : m T -> m U -> m V :=
36+
Polymorphic Definition liftM2@{d c}
37+
{m : Type@{d} -> Type@{c}}
38+
{M : Monad m}
39+
{T U V : Type@{d}} (f : T -> U -> V) : m T -> m U -> m V :=
3640
Eval cbv beta iota zeta delta [ liftM ] in
3741
fun x y => bind x (fun x => liftM (f x) y).
3842

39-
Polymorphic Definition liftM3 {T U V W : Type@{d}} (f : T -> U -> V -> W) : m T -> m U -> m V -> m W :=
43+
Polymorphic Definition liftM3@{d c}
44+
{m : Type@{d} -> Type@{c}}
45+
{M : Monad m}
46+
{T U V W : Type@{d}} (f : T -> U -> V -> W) : m T -> m U -> m V -> m W :=
4047
Eval cbv beta iota zeta delta [ liftM2 ] in
4148
fun x y z => bind x (fun x => liftM2 (f x) y z).
4249

43-
Polymorphic Definition apM {A B : Type@{d}} (fM:m (A -> B)) (aM:m A) : m B :=
50+
Polymorphic Definition apM@{d c}
51+
{m : Type@{d} -> Type@{c}}
52+
{M : Monad m}
53+
{A B : Type@{d}} (fM:m (A -> B)) (aM:m A) : m B :=
4454
bind fM (fun f => liftM f aM).
4555
End monadic.
4656

0 commit comments

Comments
 (0)