Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does MiniKanren have the "not" operator?

Does MiniKanren have the "not" operator?

For example, how would one represent Prolog's

a :- b, not(c)

a is true if b is true and c is not (Prolog uses negation as failure, i.e. not(c) is considered proven if c can not be proven)

Prolog's not also works with non-ground expressions, e.g.

a(X, d(Y)) :- b(d(X), d(Y)), not(c(d(X)))
like image 360
MWB Avatar asked Aug 11 '17 21:08

MWB


People also ask

What is the main programming style supported by miniKanren?

probabilistic logic programming, nominal logic programming, and tabling.

How does miniKanren work?

miniKanren performs an interleaved search which will eventually find any solution that exists, even if any one branch of the search tree is infinitely long and contains no solutions. If no solution exists, miniKanren may search forever if the search tree is infinite.


2 Answers

According to https://github.com/zhjhxxxjh/ykanren the answer is no.

like image 80
soegaard Avatar answered Nov 15 '22 08:11

soegaard


There is no not operator in minikanren, but you can achieve something similar with conda:

(defmacro not
  "fail if the given goal succeeds, use with extreme caution"
  [goal]
  `(conda 
     [~goal fail]
     [succeed]))

See my similar question on Google Groups

like image 23
Gordon Gustafson Avatar answered Nov 15 '22 09:11

Gordon Gustafson