logic-programming

Is pure Prolog Turing-complete, and if so, why can't it implement list intersection?

∥☆過路亽.° 提交于 2021-02-04 04:58:19
问题 The Wikipedia section on this topic is a mess. It states: Pure Prolog is based on a subset of first-order predicate logic, Horn clauses, which is Turing-complete. Turing completeness of Prolog can be shown by using it to simulate a Turing machine: (emphasis added) And then it goes on to show code that uses things that are not Horn clauses ( ! and once ): turing(Tape0, Tape) :- perform(q0, [], Ls, Tape0, Rs), reverse(Ls, Ls1), append(Ls1, Rs, Tape). perform(qf, Ls, Ls, Rs, Rs) :- !. perform(Q0

Is pure Prolog Turing-complete, and if so, why can't it implement list intersection?

喜夏-厌秋 提交于 2021-02-04 04:56:57
问题 The Wikipedia section on this topic is a mess. It states: Pure Prolog is based on a subset of first-order predicate logic, Horn clauses, which is Turing-complete. Turing completeness of Prolog can be shown by using it to simulate a Turing machine: (emphasis added) And then it goes on to show code that uses things that are not Horn clauses ( ! and once ): turing(Tape0, Tape) :- perform(q0, [], Ls, Tape0, Rs), reverse(Ls, Ls1), append(Ls1, Rs, Tape). perform(qf, Ls, Ls, Rs, Rs) :- !. perform(Q0

Is pure Prolog Turing-complete, and if so, why can't it implement list intersection?

与世无争的帅哥 提交于 2021-02-04 04:56:29
问题 The Wikipedia section on this topic is a mess. It states: Pure Prolog is based on a subset of first-order predicate logic, Horn clauses, which is Turing-complete. Turing completeness of Prolog can be shown by using it to simulate a Turing machine: (emphasis added) And then it goes on to show code that uses things that are not Horn clauses ( ! and once ): turing(Tape0, Tape) :- perform(q0, [], Ls, Tape0, Rs), reverse(Ls, Ls1), append(Ls1, Rs, Tape). perform(qf, Ls, Ls, Rs, Rs) :- !. perform(Q0

Brave/Cautious reasoning in clingo

*爱你&永不变心* 提交于 2021-01-29 04:29:58
问题 In Clingo guide, there are two modes called cautious and brave introduced as the follows: brave Compute the brave consequences (union of all answer sets) of a logic program. cautious Compute the cautious consequences (intersection of all answer sets) of a logic program. No more information is provided in the guide. I tried some examples and have trouble understanding the issue. I tried to run the following simple ASP program: p :- not q. q :- not p. Running Clingo with no mode parameter will

λProlog rejecting hypothetical reasoning queries?

Deadly 提交于 2021-01-27 12:46:59
问题 I suspect that teyjus, the main implementation of λProlog, might be a bit of abandonware, but λProlog is a fascinating Prolog that is supposed to let you use higher-order logic, hypothetical reasoning and other things, which is why I'm trying to use it. File "example.sig": sig example. kind person, language type. type hans person. type german, french, italian language. type grade person -> o. type take person -> language -> o. File "example.mod": module example. (grade P) :- (take P german),

Is “almost pure” Prolog expressive?

…衆ロ難τιáo~ 提交于 2021-01-13 09:37:11
问题 @false commented earlier: Yes, you can implement a Turing machine without dif/2 . But you cannot even implement intersection or similar predicates. Suppose we do extend pure Prolog (Horn FOL + CWA + UNA) with call/N , dif/2 , and (=)/3 , to be used in if_/3 , would there still be gaps in its expressiveness, i.e. things that are trivial to define in, say, Scheme, but are much harder to state in such extended (almost pure) Prolog? In particular, does such a Prolog allow manipulating Prolog

NU-Prolog's and Gödel's logical and sound `if-then-else` extension

女生的网名这么多〃 提交于 2021-01-03 06:28:16
问题 A paper about mercury says the following: The if-then-else and negation constructs in most variants of Prolog are non-logical and unsound: they can cause the system to compute answers which are inconsistent with the program viewed as a logical theory. Some existing logic programming systems such as NU-Prolog and Gödel provide logical and sound replacements for these Prolog constructs . Unfortunately, these systems enforce safety via runtime groundness checks. This effect can increase the

NU-Prolog's and Gödel's logical and sound `if-then-else` extension

╄→尐↘猪︶ㄣ 提交于 2021-01-03 06:28:06
问题 A paper about mercury says the following: The if-then-else and negation constructs in most variants of Prolog are non-logical and unsound: they can cause the system to compute answers which are inconsistent with the program viewed as a logical theory. Some existing logic programming systems such as NU-Prolog and Gödel provide logical and sound replacements for these Prolog constructs . Unfortunately, these systems enforce safety via runtime groundness checks. This effect can increase the

Prolog: How can I implement the sum of squares of two largest numbers out of three?

半腔热情 提交于 2020-01-15 06:18:32
问题 Exercise 1.3 of the book Structure and Interpretation of Computer Programs asks the following: Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers. I'm learning Prolog. Here's the function I tried to implement: square(X, Y) :- Y is X * X. squareTwoLargest(X, Y, Z, R) :- R is square(L1) + square(L2), L1 = max(X, Y), L2 = max(min(X, Y), Z). However, when I run it, it gives the following error: ERROR: is/2: Arguments are not