2023-04-18 18:42:40 -04:00
|
|
|
|
namespace pair {
|
|
|
|
|
|
2023-05-21 14:09:34 -04:00
|
|
|
|
def0 Σ : 0.(A : ★⁰) → 0.(0.A → ★⁰) → ★⁰ = λ A B ⇒ (x : A) × B x;
|
2023-04-18 18:42:40 -04:00
|
|
|
|
|
2023-05-21 14:09:34 -04:00
|
|
|
|
def fst : 0.(A : ★⁰) → 0.(B : 0.A → ★⁰) → ω.(Σ A B) → A =
|
2023-04-18 18:42:40 -04:00
|
|
|
|
λ A B p ⇒ caseω p return A of { (x, _) ⇒ x };
|
|
|
|
|
|
2023-05-21 14:09:34 -04:00
|
|
|
|
def snd : 0.(A : ★⁰) → 0.(B : 0.A → ★⁰) → ω.(p : Σ A B) → B (fst A B p) =
|
2023-04-18 18:42:40 -04:00
|
|
|
|
λ A B p ⇒ caseω p return p' ⇒ B (fst A B p') of { (_, y) ⇒ y };
|
|
|
|
|
|
|
|
|
|
def uncurry :
|
2023-05-21 14:09:34 -04:00
|
|
|
|
0.(A : ★⁰) → 0.(B : 0.A → ★⁰) → 0.(C : 0.(x : A) → 0.(B x) → ★⁰) →
|
2023-04-18 18:42:40 -04:00
|
|
|
|
1.(f : 1.(x : A) → 1.(y : B x) → C x y) →
|
|
|
|
|
1.(p : Σ A B) → C (fst A B p) (snd A B p) =
|
|
|
|
|
λ A B C f p ⇒
|
|
|
|
|
case1 p return p' ⇒ C (fst A B p') (snd A B p') of { (x, y) ⇒ f x y };
|
|
|
|
|
|
2023-04-19 15:36:57 -04:00
|
|
|
|
def uncurry' :
|
2023-05-21 14:09:34 -04:00
|
|
|
|
0.(A B C : ★⁰) → 1.(1.A → 1.B → C) → 1.(A × B) → C =
|
2023-04-19 15:36:57 -04:00
|
|
|
|
λ A B C ⇒ uncurry A (λ _ ⇒ B) (λ _ _ ⇒ C);
|
|
|
|
|
|
2023-04-18 18:42:40 -04:00
|
|
|
|
def curry :
|
2023-05-21 14:09:34 -04:00
|
|
|
|
0.(A : ★⁰) → 0.(B : 0.A → ★⁰) → 0.(C : 0.(Σ A B) → ★⁰) →
|
2023-04-18 18:42:40 -04:00
|
|
|
|
1.(f : 1.(p : Σ A B) → C p) → 1.(x : A) → 1.(y : B x) → C (x, y) =
|
|
|
|
|
λ A B C f x y ⇒ f (x, y);
|
|
|
|
|
|
2023-04-19 15:36:57 -04:00
|
|
|
|
def curry' :
|
2023-05-21 14:09:34 -04:00
|
|
|
|
0.(A B C : ★⁰) → 1.(1.(A × B) → C) → 1.A → 1.B → C =
|
2023-04-19 15:36:57 -04:00
|
|
|
|
λ A B C ⇒ curry A (λ _ ⇒ B) (λ _ ⇒ C);
|
|
|
|
|
|
2023-04-18 18:42:40 -04:00
|
|
|
|
def0 fst-snd :
|
2023-05-21 14:09:34 -04:00
|
|
|
|
0.(A : ★⁰) → 0.(B : 0.A → ★⁰) →
|
2023-04-18 18:42:40 -04:00
|
|
|
|
1.(p : Σ A B) → p ≡ (fst A B p, snd A B p) : Σ A B =
|
|
|
|
|
λ A B p ⇒
|
|
|
|
|
case1 p
|
|
|
|
|
return p' ⇒ p' ≡ (fst A B p', snd A B p') : Σ A B
|
|
|
|
|
of { (x, y) ⇒ δ 𝑖 ⇒ (x, y) };
|
|
|
|
|
|
|
|
|
|
def map :
|
2023-05-21 14:09:34 -04:00
|
|
|
|
0.(A A' : ★⁰) →
|
|
|
|
|
0.(B : 0.A → ★⁰) → 0.(B' : 0.A' → ★⁰) →
|
2023-04-18 18:42:40 -04:00
|
|
|
|
1.(f : 1.A → A') → 1.(g : 0.(x : A) → 1.(B x) → B' (f x)) →
|
|
|
|
|
1.(Σ A B) → Σ A' B' =
|
|
|
|
|
λ A A' B B' f g p ⇒
|
|
|
|
|
case1 p return Σ A' B' of { (x, y) ⇒ (f x, g x y) };
|
|
|
|
|
|
2023-05-21 14:09:34 -04:00
|
|
|
|
def map' : 0.(A A' B B' : ★⁰) →
|
2023-04-19 15:36:57 -04:00
|
|
|
|
1.(1.A → A') → 1.(1.B → B') → 1.(A × B) → A' × B' =
|
2023-04-18 18:42:40 -04:00
|
|
|
|
λ A A' B B' f g ⇒ map A A' (λ _ ⇒ B) (λ _ ⇒ B') f (λ _ ⇒ g);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def0 Σ = pair.Σ;
|
|
|
|
|
def fst = pair.fst;
|
|
|
|
|
def snd = pair.snd;
|