@@ -27,14 +27,14 @@ Ltac decide_goal := eapply Decidable_sound; reflexivity.
27
27
28
28
(** Deciding logical connectives *)
29
29
30
- Program Instance Decidable_not (P: Prop ) (dP: Decidable P) : Decidable (~ P) := {
30
+ Global Program Instance Decidable_not (P: Prop ) (dP: Decidable P) : Decidable (~ P) := {
31
31
Decidable_witness := negb (@Decidable_witness P dP)
32
32
}.
33
33
Next Obligation .
34
34
rewrite negb_true_iff. split. apply Decidable_complete_alt. apply Decidable_sound_alt.
35
35
Qed .
36
36
37
- Program Instance Decidable_equiv (P Q: Prop ) (dP: Decidable P) (dQ: Decidable Q) : Decidable (P <-> Q) := {
37
+ Global Program Instance Decidable_equiv (P Q: Prop ) (dP: Decidable P) (dQ: Decidable Q) : Decidable (P <-> Q) := {
38
38
Decidable_witness := Bool.eqb (@Decidable_witness P dP) (@Decidable_witness Q dQ)
39
39
}.
40
40
Next Obligation .
@@ -46,21 +46,21 @@ Next Obligation.
46
46
eapply Decidable_sound_alt; rewrite H; eapply Decidable_complete_alt; eauto .
47
47
Qed .
48
48
49
- Program Instance Decidable_and (P Q: Prop ) (dP: Decidable P) (dQ: Decidable Q) : Decidable (P /\ Q) := {
49
+ Global Program Instance Decidable_and (P Q: Prop ) (dP: Decidable P) (dQ: Decidable Q) : Decidable (P /\ Q) := {
50
50
Decidable_witness := @Decidable_witness P dP && @Decidable_witness Q dQ
51
51
}.
52
52
Next Obligation .
53
53
rewrite andb_true_iff. rewrite ! Decidable_spec. tauto.
54
54
Qed .
55
55
56
- Program Instance Decidable_or (P Q: Prop ) (dP: Decidable P) (dQ: Decidable Q) : Decidable (P \/ Q) := {
56
+ Global Program Instance Decidable_or (P Q: Prop ) (dP: Decidable P) (dQ: Decidable Q) : Decidable (P \/ Q) := {
57
57
Decidable_witness := @Decidable_witness P dP || @Decidable_witness Q dQ
58
58
}.
59
59
Next Obligation .
60
60
rewrite orb_true_iff. rewrite ! Decidable_spec. tauto.
61
61
Qed .
62
62
63
- Program Instance Decidable_implies (P Q: Prop ) (dP: Decidable P) (dQ: Decidable Q) : Decidable (P -> Q) := {
63
+ Global Program Instance Decidable_implies (P Q: Prop ) (dP: Decidable P) (dQ: Decidable Q) : Decidable (P -> Q) := {
64
64
Decidable_witness := if @Decidable_witness P dP then @Decidable_witness Q dQ else true
65
65
}.
66
66
Next Obligation .
@@ -79,28 +79,28 @@ Next Obligation.
79
79
split; intros. InvBooleans. auto. subst y. apply dec_eq_true.
80
80
Qed .
81
81
82
- Program Instance Decidable_eq_bool : forall (x y : bool), Decidable (eq x y) := {
82
+ Global Program Instance Decidable_eq_bool : forall (x y : bool), Decidable (eq x y) := {
83
83
Decidable_witness := Bool.eqb x y
84
84
}.
85
85
Next Obligation .
86
86
apply eqb_true_iff.
87
87
Qed .
88
88
89
- Program Instance Decidable_eq_nat : forall (x y : nat), Decidable (eq x y) := {
89
+ Global Program Instance Decidable_eq_nat : forall (x y : nat), Decidable (eq x y) := {
90
90
Decidable_witness := Nat.eqb x y
91
91
}.
92
92
Next Obligation .
93
93
apply Nat.eqb_eq.
94
94
Qed .
95
95
96
- Program Instance Decidable_eq_positive : forall (x y : positive), Decidable (eq x y) := {
96
+ Global Program Instance Decidable_eq_positive : forall (x y : positive), Decidable (eq x y) := {
97
97
Decidable_witness := Pos.eqb x y
98
98
}.
99
99
Next Obligation .
100
100
apply Pos.eqb_eq.
101
101
Qed .
102
102
103
- Program Instance Decidable_eq_Z : forall (x y : Z), Decidable (eq x y) := {
103
+ Global Program Instance Decidable_eq_Z : forall (x y : Z), Decidable (eq x y) := {
104
104
Decidable_witness := Z.eqb x y
105
105
}.
106
106
Next Obligation .
@@ -109,35 +109,35 @@ Qed.
109
109
110
110
(** Deciding order on Z *)
111
111
112
- Program Instance Decidable_le_Z : forall (x y: Z), Decidable (x <= y) := {
112
+ Global Program Instance Decidable_le_Z : forall (x y: Z), Decidable (x <= y) := {
113
113
Decidable_witness := Z.leb x y
114
114
}.
115
115
Next Obligation .
116
116
apply Z.leb_le.
117
117
Qed .
118
118
119
- Program Instance Decidable_lt_Z : forall (x y: Z), Decidable (x < y) := {
119
+ Global Program Instance Decidable_lt_Z : forall (x y: Z), Decidable (x < y) := {
120
120
Decidable_witness := Z.ltb x y
121
121
}.
122
122
Next Obligation .
123
123
apply Z.ltb_lt.
124
124
Qed .
125
125
126
- Program Instance Decidable_ge_Z : forall (x y: Z), Decidable (x >= y) := {
126
+ Global Program Instance Decidable_ge_Z : forall (x y: Z), Decidable (x >= y) := {
127
127
Decidable_witness := Z.geb x y
128
128
}.
129
129
Next Obligation .
130
130
rewrite Z.geb_le. intuition lia.
131
131
Qed .
132
132
133
- Program Instance Decidable_gt_Z : forall (x y: Z), Decidable (x > y) := {
133
+ Global Program Instance Decidable_gt_Z : forall (x y: Z), Decidable (x > y) := {
134
134
Decidable_witness := Z.gtb x y
135
135
}.
136
136
Next Obligation .
137
137
rewrite Z.gtb_lt. intuition lia.
138
138
Qed .
139
139
140
- Program Instance Decidable_divides : forall (x y: Z), Decidable (x | y) := {
140
+ Global Program Instance Decidable_divides : forall (x y: Z), Decidable (x | y) := {
141
141
Decidable_witness := Z.eqb y ((y / x) * x)%Z
142
142
}.
143
143
Next Obligation .
153
153
154
154
(** Deciding properties over lists *)
155
155
156
- Program Instance Decidable_forall_in_list :
156
+ Global Program Instance Decidable_forall_in_list :
157
157
forall (A: Type) (l: list A) (P: A -> Prop) (dP: forall x:A, Decidable (P x)),
158
158
Decidable (forall x:A, In x l -> P x) := {
159
159
Decidable_witness := List.forallb (fun x => @Decidable_witness (P x) (dP x)) l
@@ -164,7 +164,7 @@ Next Obligation.
164
164
- eapply Decidable_complete; eauto .
165
165
Qed .
166
166
167
- Program Instance Decidable_exists_in_list :
167
+ Global Program Instance Decidable_exists_in_list :
168
168
forall (A: Type) (l: list A) (P: A -> Prop) (dP: forall x:A, Decidable (P x)),
169
169
Decidable (exists x:A, In x l /\ P x) := {
170
170
Decidable_witness := List.existsb (fun x => @Decidable_witness (P x) (dP x)) l
@@ -184,7 +184,7 @@ Class Finite (T: Type) := {
184
184
185
185
(** Deciding forall and exists quantification over finite types. *)
186
186
187
- Program Instance Decidable_forall : forall (T: Type) (fT: Finite T) (P: T -> Prop) (dP: forall x:T, Decidable (P x)), Decidable (forall x, P x) := {
187
+ Global Program Instance Decidable_forall : forall (T: Type) (fT: Finite T) (P: T -> Prop) (dP: forall x:T, Decidable (P x)), Decidable (forall x, P x) := {
188
188
Decidable_witness := List.forallb (fun x => @Decidable_witness (P x) (dP x)) (@Finite_elements T fT)
189
189
}.
190
190
Next Obligation .
@@ -193,7 +193,7 @@ Next Obligation.
193
193
- eapply Decidable_complete; eauto .
194
194
Qed .
195
195
196
- Program Instance Decidable_exists : forall (T: Type) (fT: Finite T) (P: T -> Prop) (dP: forall x:T, Decidable (P x)), Decidable (exists x, P x) := {
196
+ Global Program Instance Decidable_exists : forall (T: Type) (fT: Finite T) (P: T -> Prop) (dP: forall x:T, Decidable (P x)), Decidable (exists x, P x) := {
197
197
Decidable_witness := List.existsb (fun x => @Decidable_witness (P x) (dP x)) (@Finite_elements T fT)
198
198
}.
199
199
Next Obligation .
@@ -204,21 +204,21 @@ Qed.
204
204
205
205
(** Some examples of finite types. *)
206
206
207
- Program Instance Finite_bool : Finite bool := {
207
+ Global Program Instance Finite_bool : Finite bool := {
208
208
Finite_elements := false :: true :: nil
209
209
}.
210
210
Next Obligation .
211
211
destruct x; auto.
212
212
Qed .
213
213
214
- Program Instance Finite_pair : forall (A B: Type) (fA: Finite A) (fB: Finite B), Finite (A * B) := {
214
+ Global Program Instance Finite_pair : forall (A B: Type) (fA: Finite A) (fB: Finite B), Finite (A * B) := {
215
215
Finite_elements := list_prod (@Finite_elements A fA) (@Finite_elements B fB)
216
216
}.
217
217
Next Obligation .
218
218
apply List.in_prod; eapply Finite_elements_spec.
219
219
Qed .
220
220
221
- Program Instance Finite_option : forall (A: Type) (fA: Finite A), Finite (option A) := {
221
+ Global Program Instance Finite_option : forall (A: Type) (fA: Finite A), Finite (option A) := {
222
222
Finite_elements := None :: List.map (@Some A) (@Finite_elements A fA)
223
223
}.
224
224
Next Obligation .
0 commit comments