trueagi-io / metta-examples

Discussion of MeTTa programming with examples
MIT License
14 stars 15 forks source link

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

Closed noskill closed 2 months ago

noskill commented 7 months ago

porting simple prolog programs to metta

noskill commented 7 months ago

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

vsbogd commented 7 months ago

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

noskill commented 7 months ago

here is truncated log

log.txt

patham9 commented 7 months 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 3 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".