Skip to main content
Became Hot Network Question
Add code quotes
Source Link
Jason Rute
  • 9.2k
  • 1
  • 18
  • 54

I just started with Lean and with this nice SE.

In the official web book/tutorial, when explaining definitions https://leanprover.github.io/theorem_proving_in_lean/index.html they ask to complete this (partial) definition of curry (in paragraph 2.4):

def curry (α β γ : Type*) (f : α × β → γ) : α → β → γ := sorry

def curry (α β γ : Type*) (f : α × β → γ) : α → β → γ := sorry

I tried

def curry (α β γ : Type*) (f : α × β → γ) : α → β → γ := λ x y, f (x,y)

def curry (α β γ : Type*) (f : α × β → γ) : α → β → γ := λ  x y, f (x,y) 

and it seems to be accepted by the system.

Is this definition correct? If yes, how do I use it?

I expected something like

curry x y fcurry x y f or curry f x y curry f x y

should work, but they don't.

Actually the given (partial) definition is of type α → β → γα → β → γ so it expects just 2 arguments of type α and ββ respectively, but no function ff.

Thank you for your help

I just started with Lean and with this nice SE.

In the official web book/tutorial, when explaining definitions https://leanprover.github.io/theorem_proving_in_lean/index.html they ask to complete this (partial) definition of curry (in paragraph 2.4):

def curry (α β γ : Type*) (f : α × β → γ) : α → β → γ := sorry

I tried

def curry (α β γ : Type*) (f : α × β → γ) : α → β → γ := λ x y, f (x,y)

and it seems to be accepted by the system.

Is this definition correct? If yes, how do I use it?

I expected something like

curry x y f or curry f x y

should work, but they don't.

Actually the given (partial) definition is of type α → β → γ so it expects just 2 arguments of type α and β respectively, but no function f.

Thank you for your help

I just started with Lean and with this nice SE.

In the official web book/tutorial, when explaining definitions https://leanprover.github.io/theorem_proving_in_lean/index.html they ask to complete this (partial) definition of curry (in paragraph 2.4):

def curry (α β γ : Type*) (f : α × β → γ) : α → β → γ := sorry

I tried

def curry (α β γ : Type*) (f : α × β → γ) : α → β → γ := λ  x y, f (x,y) 

and it seems to be accepted by the system.

Is this definition correct? If yes, how do I use it?

I expected something like

curry x y f or curry f x y

should work, but they don't.

Actually the given (partial) definition is of type α → β → γ so it expects just 2 arguments of type α and β respectively, but no function f.

Thank you for your help

[Edit removed during grace period]
Link
Guy Coder
  • 2.8k
  • 1
  • 12
  • 38
Source Link
magma
  • 193
  • 4

How to define curry in Lean

I just started with Lean and with this nice SE.

In the official web book/tutorial, when explaining definitions https://leanprover.github.io/theorem_proving_in_lean/index.html they ask to complete this (partial) definition of curry (in paragraph 2.4):

def curry (α β γ : Type*) (f : α × β → γ) : α → β → γ := sorry

I tried

def curry (α β γ : Type*) (f : α × β → γ) : α → β → γ := λ x y, f (x,y)

and it seems to be accepted by the system.

Is this definition correct? If yes, how do I use it?

I expected something like

curry x y f or curry f x y

should work, but they don't.

Actually the given (partial) definition is of type α → β → γ so it expects just 2 arguments of type α and β respectively, but no function f.

Thank you for your help