Skip to content

Instantly share code, notes, and snippets.

@takada-at
Last active April 25, 2019 04:21
Show Gist options
  • Save takada-at/8c073ba50d4f9b1374bed7a9bcfbc97b to your computer and use it in GitHub Desktop.
Save takada-at/8c073ba50d4f9b1374bed7a9bcfbc97b to your computer and use it in GitHub Desktop.
-- definition of Existential Type
data ∃ {A : Set} (B : A → Set) : Set where
_,_ : (x₁ : A) → B x₁ → ∃ \(x : A) → B x
-- left projection
p : {A : Set} {B : A → Set} → (∃ \(x : A) → B x) → A
p {A} {B} (a , b) = a
-- right projection
q : {A : Set} {B : A → Set} → (c : ∃ \(x : A) → B x) → B (p c)
q {A} {B} (a , b) = b
axiom-of-choice : {A : Set} {B : A → Set} {C : (x : A) → B x → Set}
→ (∀(x : A) → ∃ \(y : (B x)) → C x y)
→ ∃ \(f : ∀(x : A) → B x) → ∀(x : A) → C x (f x)
axiom-of-choice {A} {B} {C} z = f , g
where
f : ∀(x : A) → B x
f x = p (z x)
g : ∀(x : A) → C x (f x)
g x = q (z x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment