Skip to content

Commit b3a4c81

Browse files
committed
some injection instances for poption.
1 parent a88fd63 commit b3a4c81

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

theories/Data/POption.v

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Require Import ExtLib.Structures.Functor.
22
Require Import ExtLib.Structures.Applicative.
3+
Require Import ExtLib.Tactics.Injection.
34

45
Set Printing Universes.
56

@@ -11,6 +12,45 @@ Section poption.
1112
| pSome : T -> poption
1213
| pNone.
1314

15+
Global Polymorphic Instance Injective_pSome a b
16+
: Injective (pSome a = pSome b) :=
17+
{ result := a = b
18+
; injection := fun pf =>
19+
match pf in _ = X
20+
return a = match X with
21+
| pSome y => y
22+
| _ => a
23+
end
24+
with
25+
| eq_refl => eq_refl
26+
end }.
27+
28+
Global Polymorphic Instance Injective_pSome_pNone a
29+
: Injective (pSome a = pNone) :=
30+
{ result := False
31+
; injection := fun pf =>
32+
match pf in _ = X
33+
return match X with
34+
| pSome y => True
35+
| _ => False
36+
end
37+
with
38+
| eq_refl => I
39+
end }.
40+
41+
Global Polymorphic Instance Injective_pNone_pSome a
42+
: Injective (pNone = pSome a) :=
43+
{ result := False
44+
; injection := fun pf =>
45+
match pf in _ = X
46+
return match X with
47+
| pNone => True
48+
| _ => False
49+
end
50+
with
51+
| eq_refl => I
52+
end }.
53+
1454
End poption.
1555

1656
Arguments pSome {_} _.
@@ -45,4 +85,4 @@ Existing Instance Functor_poption.
4585
Polymorphic Definition Applicative_poption@{i} : Applicative@{i i} poption@{i} :=
4686
{| pure := @pSome@{i}
4787
; ap := @ap_poption |}.
48-
Existing Instance Applicative_poption.
88+
Existing Instance Applicative_poption.

0 commit comments

Comments
 (0)