Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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 :
-- 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

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2022-12-10 05:30 GMT
Find Nodes?
    Voting Booth?

    No recent polls found