Skip to content

Instantly share code, notes, and snippets.

@gallais
Created September 29, 2018 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gallais/eb3b22fdfe0509286d65dee6d4134b44 to your computer and use it in GitHub Desktop.
Save gallais/eb3b22fdfe0509286d65dee6d4134b44 to your computer and use it in GitHub Desktop.
Generic combinator for injectivity proofs.
open import Relation.Binary.PropositionalEquality
open import Relation.Binary.HeterogeneousEquality
open import Data.Maybe
open import Function
cong⁻¹ : ∀ {A B : Set} {a a'} (f : A → Maybe B) →
(eq : a ≡ a') →
from-just (f a) ≅ from-just (f a')
cong⁻¹ {a = a} f refl = refl
data A : Set where
C : A → A
D : A → A → A
C-injective : ∀ {a b} → C a ≡ C b → a ≅ b
C-injective = cong⁻¹ λ { (C a) → just a; _ → nothing }
D₁-injective : ∀ {a b c} → D a b ≡ D b c → a ≅ b
D₁-injective = cong⁻¹ λ { (D a _) → just a; _ → nothing }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment