iso-prolog

Prolog infix operator definition

﹥>﹥吖頭↗ 提交于 2021-02-07 20:37:42
问题 I am recently learning about Prolog and I find the three types used for defining infix operators confusing. What are the differences between xfx, xfy and yfx when specifying the type of an operator? I have googled about the problem and haven't found anything useful. I tried typing the following codes in Prolog: :- op(500,yfx,is_alive). is_alive(A,B) :- display([A,B]). :- op(500,xfy,is_alive2). is_alive2(A,B) :- display([A,B]). :- op(500,xfx,is_alive3). is_alive3(A,B) :- display([A,B]). and

Prolog infix operator definition

旧时模样 提交于 2021-02-07 20:32:12
问题 I am recently learning about Prolog and I find the three types used for defining infix operators confusing. What are the differences between xfx, xfy and yfx when specifying the type of an operator? I have googled about the problem and haven't found anything useful. I tried typing the following codes in Prolog: :- op(500,yfx,is_alive). is_alive(A,B) :- display([A,B]). :- op(500,xfy,is_alive2). is_alive2(A,B) :- display([A,B]). :- op(500,xfx,is_alive3). is_alive3(A,B) :- display([A,B]). and

Unification with STO detection

扶醉桌前 提交于 2021-01-20 18:52:47
问题 In ISO Prolog unification is defined only for those cases that are NSTO (not subject to occurs-check). The idea behind is to cover those cases of unifications that are mostly used in programs and that are actually supported by all Prolog systems. More specifically, ISO/IEC 13211-1:1995 reads: 7.3.3 Subject to occurs-check (STO) and not subject to occurs-check (NSTO) A set of equations (or two terms) is "subject to occurs- check" (STO) iff there exists a way to proceed through the steps of the

Unification with STO detection

拥有回忆 提交于 2021-01-20 18:50:00
问题 In ISO Prolog unification is defined only for those cases that are NSTO (not subject to occurs-check). The idea behind is to cover those cases of unifications that are mostly used in programs and that are actually supported by all Prolog systems. More specifically, ISO/IEC 13211-1:1995 reads: 7.3.3 Subject to occurs-check (STO) and not subject to occurs-check (NSTO) A set of equations (or two terms) is "subject to occurs- check" (STO) iff there exists a way to proceed through the steps of the

Unification with STO detection

本小妞迷上赌 提交于 2021-01-20 18:46:41
问题 In ISO Prolog unification is defined only for those cases that are NSTO (not subject to occurs-check). The idea behind is to cover those cases of unifications that are mostly used in programs and that are actually supported by all Prolog systems. More specifically, ISO/IEC 13211-1:1995 reads: 7.3.3 Subject to occurs-check (STO) and not subject to occurs-check (NSTO) A set of equations (or two terms) is "subject to occurs- check" (STO) iff there exists a way to proceed through the steps of the

Complexity of ISO Prolog predicates

笑着哭i 提交于 2020-01-18 04:44:13
问题 Are there any guarantees for upper bounds on the time complexity of the standard Prolog predicates? For example: is it certain that sort(+List, ?SortedList) runs in O(nlog(n)) time (n being the length of List ) in any standard compliant Prolog system? 回答1: tl;dr: No and no. Let's start with sort/2 which ideally would need n ld( n ) comparisons. Fine, but how long does one comparison take? Let's try this out: tails(Es0, [Es0|Ess]) :- Es0 = [_|Es], tails(Es, Ess). tails([],[[]]). call_time(G,T)

What is the meaning of predicate “simple/1” in Prolog (SWI-Prolog)

橙三吉。 提交于 2020-01-17 08:31:20
问题 I run into problem while reading a book. I see a program use predicate "simple" ( I guess simple/1 ). I don't know what is the meaning of this predicate, I can't find it with ?-help(simple) in the console. But when I tried with some queries in console, it worked something like: 5 ?- simple(p(x)). false. 6 ?- simple(mia). true. 7 ?- simple(Mia). true. 8 ?- simple(f(Mia)). false. I guess it is some sort of predicate to determine if the argument was Terms(or Variables) or Complex Terms. 回答1: The

What is the meaning of predicate “simple/1” in Prolog (SWI-Prolog)

狂风中的少年 提交于 2020-01-17 08:31:16
问题 I run into problem while reading a book. I see a program use predicate "simple" ( I guess simple/1 ). I don't know what is the meaning of this predicate, I can't find it with ?-help(simple) in the console. But when I tried with some queries in console, it worked something like: 5 ?- simple(p(x)). false. 6 ?- simple(mia). true. 7 ?- simple(Mia). true. 8 ?- simple(f(Mia)). false. I guess it is some sort of predicate to determine if the argument was Terms(or Variables) or Complex Terms. 回答1: The

Prolog DCG set_prolog_flag double_quotes source code directive location matters; documentation?

北慕城南 提交于 2020-01-13 09:22:09
问题 I learned the hard way that with SWI-Prolog the location for the Prolog directive set_prolog_flag matters in a source code file. The only documentation I found of value about loading source code files with directives was in Loading Prolog source files A directive is an instruction to the compiler. Directives are used to set (predicate) properties (see section 4.15), set flags (see set_prolog_flag/2) and load files (this section). Directives are terms of the form :- <term>. Is there

Prolog: Clauses are not together in source-file

风格不统一 提交于 2020-01-01 07:32:28
问题 I have this piece of code: % Family tree female(pen). male(tom). male(bob). female(liz). female(pat). female(ann). male(jim). parent(pam, bob). parent(tom, bob). parent(tom, liz). parent(bob, ann). parent(bob, pat). parent(pat, jim). I get this error: Warning: Clauses of female/1 are not together in source-file Warning: Clauses of male/1 are not together in source-file What is the purpose of this error? I mean, file does compile and run just fine and I am aware of the meaning of the error.