* Lambda-Term (f x) (x f) translated to Ocaml?
@ 2006-03-28 0:07 Oliver Bandel
2006-03-31 20:58 ` [Caml-list] " Thomas Fischbacher
0 siblings, 1 reply; 7+ messages in thread
From: Oliver Bandel @ 2006-03-28 0:07 UTC (permalink / raw)
To: caml-list
Hello,
I'm not firm in lambda calculus, what is the lambda-term
in the subject translated to OCaml?
Is this possible?
And how will it be evaluated?
Any hint is welcome.
TIA,
Oliver Bandel
P.S.: Also welcome is a "Lambda-Calculus for Dummies" recommendation
on literature (or web-links). ;-)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] Lambda-Term (f x) (x f) translated to Ocaml?
2006-03-28 0:07 Lambda-Term (f x) (x f) translated to Ocaml? Oliver Bandel
@ 2006-03-31 20:58 ` Thomas Fischbacher
0 siblings, 0 replies; 7+ messages in thread
From: Thomas Fischbacher @ 2006-03-31 20:58 UTC (permalink / raw)
To: Oliver Bandel; +Cc: caml-list
> P.S.: Also welcome is a "Lambda-Calculus for Dummies" recommendation
> on literature (or web-links). ;-)
Crash Course:
http://www.cip.physik.uni-muenchen.de/~tf/lambda/aei
And furthermore - as you are german anyway:
http://www.cip.physik.uni-muenchen.de/~tf/lambda
I would not say that this material is of sufficiently high quality to
publish it in a book (I consider it to be only ~90% correct, for example),
but I think it nevertheless is reasonably okay.
--
regards, tf@cip.physik.uni-muenchen.de (o_
Thomas Fischbacher - http://www.cip.physik.uni-muenchen.de/~tf //\
(lambda (n) ((lambda (p q r) (p p q r)) (lambda (g x y) V_/_
(if (= x 0) y (g g (- x 1) (* x y)))) n 1)) (Debian GNU)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] Lambda-Term (f x) (x f) translated to Ocaml?
2006-03-31 21:01 ` Thomas Fischbacher
@ 2006-03-31 23:53 ` yoann padioleau
0 siblings, 0 replies; 7+ messages in thread
From: yoann padioleau @ 2006-03-31 23:53 UTC (permalink / raw)
To: Thomas Fischbacher; +Cc: Oliver Bandel, caml-list
On 31 mars 06, at 23:01, Thomas Fischbacher wrote:
>
>> I guess that this is not a lambda term that can be typed.
>> There are many of them. A famous one is the Y combinator.
>> The _typed_ lambda calculus does not allow all the lambda terms
>> of the (normal) lambda calculus.
>
> # let rec y f = f (y f);;
> val y : ('a -> 'a) -> 'a = <fun>
I know that, but you cheat. This not a lambda calcul Y combinator.
>
> --
> regards, tf@cip.physik.uni-muenchen.de (o_
> Thomas Fischbacher - http://www.cip.physik.uni-muenchen.de/~tf //\
> (lambda (n) ((lambda (p q r) (p p q r)) (lambda (g x y) V_/_
> (if (= x 0) y (g g (- x 1) (* x y)))) n 1))
> (Debian GNU)
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] Lambda-Term (f x) (x f) translated to Ocaml?
2006-03-28 0:44 yoann padioleau
2006-03-28 0:55 ` Marius Nita
2006-03-28 1:11 ` Oliver Bandel
@ 2006-03-31 21:01 ` Thomas Fischbacher
2006-03-31 23:53 ` yoann padioleau
2 siblings, 1 reply; 7+ messages in thread
From: Thomas Fischbacher @ 2006-03-31 21:01 UTC (permalink / raw)
To: yoann padioleau; +Cc: Oliver Bandel, caml-list
> I guess that this is not a lambda term that can be typed.
> There are many of them. A famous one is the Y combinator.
> The _typed_ lambda calculus does not allow all the lambda terms
> of the (normal) lambda calculus.
# let rec y f = f (y f);;
val y : ('a -> 'a) -> 'a = <fun>
--
regards, tf@cip.physik.uni-muenchen.de (o_
Thomas Fischbacher - http://www.cip.physik.uni-muenchen.de/~tf //\
(lambda (n) ((lambda (p q r) (p p q r)) (lambda (g x y) V_/_
(if (= x 0) y (g g (- x 1) (* x y)))) n 1)) (Debian GNU)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] Lambda-Term (f x) (x f) translated to Ocaml?
2006-03-28 0:44 yoann padioleau
2006-03-28 0:55 ` Marius Nita
@ 2006-03-28 1:11 ` Oliver Bandel
2006-03-31 21:01 ` Thomas Fischbacher
2 siblings, 0 replies; 7+ messages in thread
From: Oliver Bandel @ 2006-03-28 1:11 UTC (permalink / raw)
To: caml-list
On Tue, Mar 28, 2006 at 02:44:55AM +0200, yoann padioleau wrote:
>
> > Hello,
> >
> > I'm not firm in lambda calculus, what is the lambda-term
> > in the subject translated to OCaml?
> >
> > Is this possible?
>
> the ocaml interpreter dont want this definition
>
> let g f x = (f x) (x f)
Oh, looks easy.... ( at least the definition on the left side ;-) )
>
> and shout:
> this expression has type ('a -> 'b) -> 'c -> 'd but is here used with type 'a
OK,
I tried this:
=====================================================================
first:~/Desktop oliver$ ocaml
Objective Caml version 3.09.0
# let g f x = (f x) (x f) ;;
This expression has type ('a -> 'b) -> 'c -> 'd but is here used with type 'a
# ^D
first:~/Desktop oliver$ ocaml -rectypes
Objective Caml version 3.09.0
# let g f x = (f x) (x f) ;;
val g : (('a -> 'c as 'b) -> 'c -> 'd as 'a) -> 'b -> 'd = <fun>
#
=====================================================================
Well, looks complicated to me.
Any hints to this?
Ciao,
Oliver
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] Lambda-Term (f x) (x f) translated to Ocaml?
2006-03-28 0:44 yoann padioleau
@ 2006-03-28 0:55 ` Marius Nita
2006-03-28 1:11 ` Oliver Bandel
2006-03-31 21:01 ` Thomas Fischbacher
2 siblings, 0 replies; 7+ messages in thread
From: Marius Nita @ 2006-03-28 0:55 UTC (permalink / raw)
To: padator; +Cc: Oliver Bandel, caml-list
yoann padioleau wrote:
>> Hello,
>>
>> I'm not firm in lambda calculus, what is the lambda-term
>> in the subject translated to OCaml?
>>
>> Is this possible?
>
> the ocaml interpreter dont want this definition
>
> let g f x = (f x) (x f)
>
> and shout:
> this expression has type ('a -> 'b) -> 'c -> 'd but is here used with type 'a
>
> I guess that this is not a lambda term that can be typed.
> There are many of them. A famous one is the Y combinator.
> The _typed_ lambda calculus does not allow all the lambda terms
> of the (normal) lambda calculus.
g can't be written, but (f x) (x f) works for suitable values for f and
x :) Namely if f = x = id. There's probably some deep parametricity
property at the heart of it.
-marius
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] Lambda-Term (f x) (x f) translated to Ocaml?
@ 2006-03-28 0:44 yoann padioleau
2006-03-28 0:55 ` Marius Nita
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: yoann padioleau @ 2006-03-28 0:44 UTC (permalink / raw)
To: Oliver Bandel, caml-list
> Hello,
>
> I'm not firm in lambda calculus, what is the lambda-term
> in the subject translated to OCaml?
>
> Is this possible?
the ocaml interpreter dont want this definition
let g f x = (f x) (x f)
and shout:
this expression has type ('a -> 'b) -> 'c -> 'd but is here used with type 'a
I guess that this is not a lambda term that can be typed.
There are many of them. A famous one is the Y combinator.
The _typed_ lambda calculus does not allow all the lambda terms
of the (normal) lambda calculus.
>
> P.S.: Also welcome is a "Lambda-Calculus for Dummies" recommendation
> on literature (or web-links). ;-)
>
I liked very much:
G.J.Michaelson, An Introduction to Functional Programming Through Lambda Calculus, Addison-Wesley
now available online from
http://www.macs.hw.ac.uk/~greg/books.html
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-03-31 23:53 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-28 0:07 Lambda-Term (f x) (x f) translated to Ocaml? Oliver Bandel
2006-03-31 20:58 ` [Caml-list] " Thomas Fischbacher
2006-03-28 0:44 yoann padioleau
2006-03-28 0:55 ` Marius Nita
2006-03-28 1:11 ` Oliver Bandel
2006-03-31 21:01 ` Thomas Fischbacher
2006-03-31 23:53 ` yoann padioleau
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox