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

In reply to eval unexpected return value '1' by ady

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.