0 | module Control.Function
6 | interface Injective (f : a -> b) | f where
7 | constructor MkInjective
8 | injective : {x, y : a} -> f x = f y -> x = y
11 | inj : (0 f : a -> b) -> {auto 0 _ : Injective f} -> {0 x, y : a} -> (0 _ : f x = f y) -> x = y
12 | inj _ eq = irrelevantEq (injective eq)
18 | [ComposeInjective] {f : a -> b} -> {g : b -> c} ->
19 | (Injective f, Injective g) => Injective (g . f) where
20 | injective = injective . injective
24 | [InjFromComp] {f : a -> b} -> {g : b -> c} ->
25 | Injective (g . f) => Injective f where
26 | injective prf = injective {f = (g . f)} $
cong g prf
29 | [IdInjective] Injective Prelude.id where
38 | interface Biinjective (0 f : a -> b -> c) | f where
39 | constructor MkBiinjective
40 | biinjective : {x, y : a} -> {v, w : b} -> f x v = f y w -> (x = y, v = w)
43 | biinj : (0 f : _) -> (0 _ : Biinjective f) => (0 _ : f x v = f y w) -> (x = y, v = w)
44 | biinj _ eq = let 0 bii = biinjective eq in (irrelevantEq $
fst bii, irrelevantEq $
snd bii)
47 | [ComposeBiinjective] {f : a -> b -> c} -> {g : c -> d} ->
48 | Biinjective f => Injective g => Biinjective (g .: f) where
49 | biinjective = biinjective . injective
53 | [BiinjFromComp] {f : a -> b -> c} -> {g : c -> d} ->
54 | Biinjective (g .: f) => Biinjective f where
55 | biinjective prf = biinjective {f = (g .: f)} $
cong g prf
58 | [FlipBiinjective] {f : a -> b -> c} ->
59 | Biinjective f => Biinjective (flip f) where
60 | biinjective = swap . biinjective
63 | [FromBiinjectiveL] {f : a -> b -> c} -> {x : a} ->
64 | Biinjective f => Injective (f x) where
65 | injective = snd . biinjective
68 | [FromBiinjectiveR] {f : a -> b -> c} -> {y : b} ->
69 | Biinjective f => Injective (`f` y) where
70 | injective = fst . biinjective
73 | Biinjective MkPair where
74 | biinjective Refl = (Refl, Refl)