@@ -5,49 +5,49 @@ Require Import Program.Program.
5
5
Local Open Scope Z_scope.
6
6
Import ListNotations.
7
7
8
- Fixpoint length_aux {A : Type } (len : Z) (x : list A) : Z :=
8
+ Fixpoint length_aux {A : Set } (len : Z) (x : list A) : Z :=
9
9
match x with
10
10
| [] => len
11
11
| cons a l => length_aux (Z.add len 1) l
12
12
end .
13
13
14
- Definition length {A : Type } (l : list A) : Z := length_aux 0 l.
14
+ Definition length {A : Set } (l : list A) : Z := length_aux 0 l.
15
15
16
- Lemma length_cons {A : Type } (x : A) (l : list A)
16
+ Lemma length_cons {A : Set } (x : A) (l : list A)
17
17
: length (x :: l) = length l + 1.
18
18
Admitted .
19
19
20
- Lemma length_is_pos {A : Type } (l : list A) : 0 <= length l.
20
+ Lemma length_is_pos {A : Set } (l : list A) : 0 <= length l.
21
21
Admitted .
22
22
23
- Definition append {A : Type } : (list A) -> (list A) -> list A :=
24
- Stdlib .app.
23
+ Definition append {A : Set } : (list A) -> (list A) -> list A :=
24
+ List .app (A := A) .
25
25
26
- Fixpoint rev_append {A : Type } (l1 : list A) (l2 : list A) : list A :=
26
+ Fixpoint rev_append {A : Set } (l1 : list A) (l2 : list A) : list A :=
27
27
match l1 with
28
28
| [] => l2
29
29
| cons a l => rev_append l (cons a l2)
30
30
end .
31
31
32
- Definition rev {A : Type } (l : list A) : list A := rev_append l [].
32
+ Definition rev {A : Set } (l : list A) : list A := rev_append l [].
33
33
34
- Fixpoint flatten {A : Type } (x : list (list A)) : list A :=
34
+ Fixpoint flatten {A : Set } (x : list (list A)) : list A :=
35
35
match x with
36
36
| [] => []
37
- | cons l r => Stdlib .app l (flatten r)
37
+ | cons l r => List .app l (flatten r)
38
38
end .
39
39
40
- Definition concat {A : Type } : (list (list A)) -> list A := flatten.
40
+ Definition concat {A : Set } : (list (list A)) -> list A := flatten.
41
41
42
- Fixpoint map {A B : Type } (f : A -> B) (x : list A) : list B :=
42
+ Fixpoint map {A B : Set } (f : A -> B) (x : list A) : list B :=
43
43
match x with
44
44
| [] => []
45
45
| cons a l =>
46
46
let r := f a in
47
47
cons r (map f l)
48
48
end .
49
49
50
- Fixpoint mapi_aux {A B : Type } (i : Z) (f : Z -> A -> B) (x : list A)
50
+ Fixpoint mapi_aux {A B : Set } (i : Z) (f : Z -> A -> B) (x : list A)
51
51
: list B :=
52
52
match x with
53
53
| [] => []
@@ -56,43 +56,43 @@ Fixpoint mapi_aux {A B : Type} (i : Z) (f : Z -> A -> B) (x : list A)
56
56
cons r (mapi_aux (Z.add i 1) f l)
57
57
end .
58
58
59
- Definition mapi {A B : Type } (f : Z -> A -> B) (l : list A) : list B :=
59
+ Definition mapi {A B : Set } (f : Z -> A -> B) (l : list A) : list B :=
60
60
mapi_aux 0 f l.
61
61
62
- Definition rev_map {A B : Type } (f : A -> B) (l : list A) : list B :=
62
+ Definition rev_map {A B : Set } (f : A -> B) (l : list A) : list B :=
63
63
let fix rmap_f (accu : list B) (x : list A) : list B :=
64
64
match x with
65
65
| [] => accu
66
66
| cons a l => rmap_f (cons (f a) accu) l
67
67
end in
68
68
rmap_f [] l.
69
69
70
- Fixpoint fold_left {A B : Type } (f : A -> B -> A) (accu : A) (l : list B) : A :=
70
+ Fixpoint fold_left {A B : Set } (f : A -> B -> A) (accu : A) (l : list B) : A :=
71
71
match l with
72
72
| [] => accu
73
73
| cons a l => fold_left f (f accu a) l
74
74
end .
75
75
76
- Fixpoint fold_right {A B : Type } (f : A -> B -> B) (l : list A) (accu : B)
76
+ Fixpoint fold_right {A B : Set } (f : A -> B -> B) (l : list A) (accu : B)
77
77
: B :=
78
78
match l with
79
79
| [] => accu
80
80
| cons a l => f a (fold_right f l accu)
81
81
end .
82
82
83
- Fixpoint for_all {A : Type } (p : A -> bool) (x : list A) : bool :=
83
+ Fixpoint for_all {A : Set } (p : A -> bool) (x : list A) : bool :=
84
84
match x with
85
85
| [] => true
86
86
| cons a l => andb (p a) (for_all p l)
87
87
end .
88
88
89
- Fixpoint _exists {A : Type } (p : A -> bool) (x : list A) : bool :=
89
+ Fixpoint _exists {A : Set } (p : A -> bool) (x : list A) : bool :=
90
90
match x with
91
91
| [] => false
92
92
| cons a l => orb (p a) (_exists p l)
93
93
end .
94
94
95
- Fixpoint mem {A : Type } `{EqDec A} (x : A) (l : list A) : bool :=
95
+ Fixpoint mem {A : Set } `{EqDec A} (x : A) (l : list A) : bool :=
96
96
match l with
97
97
| [] => false
98
98
| y :: l =>
@@ -102,7 +102,7 @@ Fixpoint mem {A : Type} `{EqDec A} (x : A) (l : list A) : bool :=
102
102
mem x l
103
103
end .
104
104
105
- Definition find_all {A : Type } (p : A -> bool) : (list A) -> list A :=
105
+ Definition find_all {A : Set } (p : A -> bool) : (list A) -> list A :=
106
106
let fix find (accu : list A) (x : list A) : list A :=
107
107
match x with
108
108
| [] => rev accu
@@ -114,9 +114,9 @@ Definition find_all {A : Type} (p : A -> bool) : (list A) -> list A :=
114
114
end in
115
115
find [].
116
116
117
- Definition filter {A : Type } : (A -> bool) -> (list A) -> list A := find_all.
117
+ Definition filter {A : Set } : (A -> bool) -> (list A) -> list A := find_all.
118
118
119
- Definition partition {A : Type } (p : A -> bool) (l : list A)
119
+ Definition partition {A : Set } (p : A -> bool) (l : list A)
120
120
: (list A) * (list A) :=
121
121
let fix part (yes : list A) (no : list A) (x : list A)
122
122
: (list A) * (list A) :=
@@ -130,7 +130,7 @@ Definition partition {A : Type} (p : A -> bool) (l : list A)
130
130
end in
131
131
part [] [] l.
132
132
133
- Fixpoint mem_assoc {A B : Type } `{EqDec A} (x : A) (l : list (A * B)) : bool :=
133
+ Fixpoint mem_assoc {A B : Set } `{EqDec A} (x : A) (l : list (A * B)) : bool :=
134
134
match l with
135
135
| [] => false
136
136
| (y, v) :: l =>
@@ -140,7 +140,7 @@ Fixpoint mem_assoc {A B : Type} `{EqDec A} (x : A) (l : list (A * B)) : bool :=
140
140
mem_assoc x l
141
141
end .
142
142
143
- Fixpoint remove_assoc {A B : Type } `{EqDec A} (x : A) (l : list (A * B))
143
+ Fixpoint remove_assoc {A B : Set } `{EqDec A} (x : A) (l : list (A * B))
144
144
: list (A * B) :=
145
145
match l with
146
146
| [] => l
@@ -151,7 +151,7 @@ Fixpoint remove_assoc {A B : Type} `{EqDec A} (x : A) (l : list (A * B))
151
151
remove_assoc x l
152
152
end .
153
153
154
- Fixpoint split {A B : Type } (x : list (A * B)) : (list A) * (list B) :=
154
+ Fixpoint split {A B : Set } (x : list (A * B)) : (list A) * (list B) :=
155
155
match x with
156
156
| [] => ([], [])
157
157
| cons (x, y) l =>
@@ -160,7 +160,7 @@ Fixpoint split {A B : Type} (x : list (A * B)) : (list A) * (list B) :=
160
160
end
161
161
end .
162
162
163
- Fixpoint merge {A : Type } (cmp : A -> A -> Z) (l1 : list A) (l2 : list A)
163
+ Fixpoint merge {A : Set } (cmp : A -> A -> Z) (l1 : list A) (l2 : list A)
164
164
: list A :=
165
165
let fix merge_aux (l2 : list A) : list A :=
166
166
match (l1, l2) with
0 commit comments