-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcurry4.lean4
34 lines (24 loc) · 1.24 KB
/
curry4.lean4
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
34
class uncurry_ty (α) where
ty : (α → Sort _) → Sort _
uncurry : (∀ x, β x) → ty β
open uncurry_ty (uncurry)
instance : uncurry_ty α where
ty β := ∀ x, β x
uncurry := id
instance [uncurry_ty α'] : uncurry_ty (α × α') where
ty β := ∀ x, uncurry_ty.ty λ x' => β ⟨x, x'⟩
uncurry f x := uncurry λ x' => f ⟨x, x'⟩
class uncurry_ty' (α) (hd : /-outParam-/ (Sort _)) (tl : outParam ((α → Sort _) → hd → Sort _)) where
uncurry : (∀ x, β x) → ∀ x, tl β x
instance : uncurry_ty' α α id where
uncurry := id
instance [uncurry_ty' α' hd' tl'] : uncurry_ty' (α × α') α (λ β x => ∀ x', tl' (λ x' => β ⟨x, x'⟩) x') where
uncurry f x := uncurry_ty'.uncurry λ x' => f ⟨x, x'⟩
def uncurry' {α} hd : ∀ {tl} [uncurry_ty' α hd tl] {β}, (∀ x, β x) → ∀ x, tl β x := uncurry_ty'.uncurry
def sum₃ : Nat × Nat × Nat → Nat :=
λ (x, y, z) => x + y + z
def sum₃' : Nat → Nat → Nat → Nat := uncurry sum₃
def sum₃0 : Nat × Nat × Nat → Nat := uncurry' (Nat × Nat × Nat) sum₃
def sum₃1 : Nat → Nat × Nat → Nat := uncurry' Nat sum₃
def sum₃2 : Nat → Nat → Nat → Nat := uncurry' _ sum₃
def sum₃2 : Nat → Nat → Nat → Nat := uncurry' Nat sum₃