http://qs1969.pair.com?node_id=677187

ady has asked for the wisdom of the Perl Monks concerning the following question:

Guys & gulls, --
I'm playing with The unknowable (hereby recommended :) and on the way casting the LISP programs to Perl.

In the statement (from the Gödel proof):
     print eval cadr cadr &$g('&$g')
I expect eval to return :
     $is_unprovable('$value_of('&$g('&$g')')')
-- but I get a '1'.

How come?
#!/usr/bin/perl -w use strict; use warnings; # ==================================================================== +========== # Fixpoint # f(x): x -> (('x)('x)) # In LISP: # define (f x) # let y [be] cons "' cons x nil [y is ('x) ] # [return] cons y cons y nil [return (('x)('x))] # In Perl: my $f = sub { my $x = $_[0]; return "$x('$x')"; }; print &$f('x'), "\n"; print &$f('&$f'), "\n"; print eval &$f('&$f'), "\n"; print eval eval eval eval eval &$f('&$f'), "\n"; print '&$f(\'&$f\')' eq eval eval eval eval eval &$f('&$f'), "\n"; # Run : # x('x') # &$f('&$f') # &$f('&$f') # &$f('&$f') # 1 # ==================================================================== +========== # Gödel # g(x): x -> (is-unprovable (value-of (('x)('x))))] # In LISP: # define (g x) # let (L x y) cons x cons y nil [Makes x and y into list] # (L is-unprovable # (L value-of (L (L "' x) (L "' x)))) # In Perl: my $is_unprovable = '$is_unprovable'; my $value_of = '$value_of'; sub cadr { return ($_[0]) =~ /\(\'(.*)\'\)/; }; my $L = sub { my ($x, $y) = @_; return "$x('$y')"; }; my $g = sub { my $x = $_[0]; &$L($is_unprovable, &$L($value_of, "$x('$x')")); }; print '&$g(\'x\') -> ', &$g('x'), "\n"; print '&$g(\'&$g\') -> ', &$g('&$g'), "\n"; print cadr cadr &$g('&$g'), "\n"; print eval cadr cadr &$g('&$g'), "\n"; ### expected return: ### $is_unprovable('$value_o +f('&$g('&$g')')') #"\n", &$g('&$g') eq eval cadr cadr &$g('&$g'); # Run : # &$g('x') -> $is_unprovable('$value_of('x('x')')') # &$g('&$g') -> $is_unprovable('$value_of('&$g('&$g')')') # &$g('&$g') # 1 ### but it returns 1 ???

Best regards,
Allan dystrup