-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcurry.lean4
More file actions
33 lines (23 loc) · 893 Bytes
/
curry.lean4
File metadata and controls
33 lines (23 loc) · 893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class uncurry_ty (α) where
ty : (α → Sort _) → Sort _
uncurry : (∀ x, β x) → ty β
namespace uncurry_ty
instance default : uncurry_ty α where
ty β := ∀ x, β x
uncurry := id
instance prod [uncurry_ty α'] : uncurry_ty (α × α') where
ty β := ∀ x, ty λ x' => β ⟨x, x'⟩
uncurry f x := uncurry λ x' => f ⟨x, x'⟩
instance sigma [∀ x, uncurry_ty (α' x)] : uncurry_ty (Sigma α') where
ty β := ∀ x, ty λ x' => β ⟨x, x'⟩
uncurry f x := uncurry λ x' => f ⟨x, x'⟩
end uncurry_ty
open uncurry_ty (uncurry)
def sum₃ : Nat × Nat × Nat → Nat :=
λ (x, y, z) => x + y + z
def head : (Σ n, Fin (n + 1) → Nat) → Nat :=
λ ⟨n, f⟩ => f 0
#eval uncurry sum₃ 1 2 3
#eval uncurry head 1 λ _ => 42
def sum₃' : Nat → Nat → Nat → Nat := uncurry sum₃
def head' : ∀ n, (Fin (n + 1) → Nat) → Nat := uncurry head