trueagi-io / metta-examples

Discussion of MeTTa programming with examples
MIT License
20 stars 18 forks source link

puzzle solving example with port of some common predicates from prolog #25

Closed noskill closed 7 months ago

noskill commented 1 year ago

porting simple prolog programs to metta

noskill commented 1 year ago

@vsbogd when i run metta puzzle.metta it hangs forever

vsbogd commented 1 year ago

I tried it locally on a latest main and it finishes quickly enough.

noskill commented 1 year ago

here is truncated log

log.txt

patham9 commented 1 year ago

This is not logic programming style yet (assuming you wanted to make it as-close as to Prolog as possible), it can be done with a more direct Prolog translation without any let statement just with is. (please see Mattermost)

noskill commented 8 months ago

@patham9

it's possible to remove let:

  (= (eq $X $Y)
     (let $C (same $X $Y) (if (== $C True) True False)))
  (= (eq $X $Y)
      (if (== (same $X $Y) True) True False))

But what is the difference? Prolog considers that answer is false if it can't prove true, metta just returns expression unreduced, so i decided to emulate prolog behaviour with "let".