Skip to content

Commit 397c434

Browse files
Added RelDecEq to PList.v
1 parent ea6b280 commit 397c434

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

theories/Data/PList.v

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Require Import ExtLib.Structures.Functor.
22
Require Import ExtLib.Structures.Applicative.
33
Require Import ExtLib.Data.POption.
4+
Require Import ExtLib.Core.RelDec.
5+
Require Import ExtLib.Tactics.Consider.
46

57
Set Universe Polymorphism.
68

@@ -125,3 +127,38 @@ Polymorphic Definition Applicative_plist@{i} : Applicative@{i i} plist@{i} :=
125127
{| pure := fun _ val => pcons val pnil
126128
; ap := @ap_plist
127129
|}.
130+
131+
Section PListEq.
132+
Variable T : Type.
133+
Variable EDT : RelDec (@eq T).
134+
135+
Fixpoint plist_eqb (ls rs : plist T) : bool :=
136+
match ls , rs with
137+
| pnil , pnil => true
138+
| pcons l ls , pcons r rs =>
139+
if l ?[ eq ] r then plist_eqb ls rs else false
140+
| _ , _ => false
141+
end.
142+
143+
(** Specialization for equality **)
144+
Global Instance RelDec_eq_plist : RelDec (@eq (plist T)) :=
145+
{ rel_dec := plist_eqb }.
146+
147+
Variable EDCT : RelDec_Correct EDT.
148+
149+
Global Instance RelDec_Correct_eq_plist : RelDec_Correct RelDec_eq_plist.
150+
Proof.
151+
constructor; induction x; destruct y; split; simpl in *; intros;
152+
repeat match goal with
153+
| [ H : context [ rel_dec ?X ?Y ] |- _ ] =>
154+
consider (rel_dec X Y); intros; subst
155+
| [ |- context [ rel_dec ?X ?Y ] ] =>
156+
consider (rel_dec X Y); intros; subst
157+
end; try solve [ auto | exfalso; clear - H; inversion H ].
158+
- f_equal. eapply IHx. eapply H0.
159+
- inversion H. subst. eapply IHx. reflexivity.
160+
- inversion H. exfalso. eapply H0. assumption.
161+
Qed.
162+
163+
End PListEq.
164+

0 commit comments

Comments
 (0)