iso-prolog

What are the best Prolog programming practices and style guidelines? [closed]

懵懂的女人 提交于 2019-11-29 01:41:21
OK, I know that this is very general question and that there were written some papers on the subject, but I have a feeling that these publications cover very basic material and I'm looking for something more advanced which would improve style and efficency. This is what I have in paper: "Research Report AI-1989-08 Efficient Prolog: A Practical Guide" by Michael A. Covington, 1989 "Efficient Prolog Programming" by Timo Knuutila, 1992 "Coding guidelines for Prolog" by Covington, Bagnara, O'Keefe, Wielemaker, Price, 2011 Sample subjects covered in these: tail recursion and differential lists,

Prolog - unusual cons syntax for lists

馋奶兔 提交于 2019-11-28 13:15:49
I have come across an unfamiliar bit of Prolog syntax in Lee Naish's paper Higher-order logic programming in Prolog . Here is the first code sample from the paper: % insertion sort (simple version) isort([], []). isort(A.As, Bs) :- isort(As, Bs1), isort(A, Bs1, Bs). % insert number into sorted list insert(N, [], [N]). insert(N, H.L, N.H.L) :- N =< H. insert(N, H.LO, H.L) :- N > H, insert(N, LO, L). My confusion is with A.As in isort(A.As, Bs) :- . From the context, it appears to be an alternate cons syntax for lists, the equivalent of isort([A|As], Bs) :- . As well N.H.L appears to be a more

A searchable Prolog language description online [closed]

半腔热情 提交于 2019-11-28 10:04:16
Is there a description of Prolog language (syntax and semantics) available online? There are a lot of reference manuals for implementations. But neither of those is a language description. For example the SWI Prolog manual states This manual does not describe the full syntax and semantics of Prolog. And refers to a set of books printed on paper, published in the nineteen eighties. And to ISO standard which is for money and "should be available from my country's ISO representative" gibberish. false The ISO standard is available for a very low price (currently USD 30 60) from the ANSI webstore

Prolog systems in Javascript [closed]

梦想与她 提交于 2019-11-28 06:27:52
Javascript seems to become popular as an implementation language for other programming languages. The article Lightweight compilation of (C)LP to JavaScript. ICLP 2012 drew my attention on this. There are a lot of proof-of-concept prototypes for Prolog systems written in Javascript around on the Web. What are current, actively maintained, preferably ISO conforming Prolog systems written in Javascript? The only Prolog in JavaScript I know is YieldProlog , but I haven't tried it extensively, just the code available in QueryEditor . I was hoping than using the yield construct it was lightweight

Implementing cut in tracing meta interpreter prolog

一曲冷凌霜 提交于 2019-11-28 03:26:43
问题 I have this tracing meta interpreter, altered from previous question Prolog unbind bound variable. I don't understand how to interpret cut. Thanks to user @false who told me that the cut is badly implemented, my question is, how should I implement cut in this meta-interpreter? %tracer mi_trace(Goal):- mi_trace(Goal, 0). mi_trace(V, _):- var(V), !, throw(error(instantiation_error, _)). mi_trace(true, _Depth):-!, true. mi_trace(fail, _Depth):-!, fail. mi_trace(A > B, _Depth):-!, A > B. mi_trace

What are the best Prolog programming practices and style guidelines? [closed]

假装没事ソ 提交于 2019-11-27 21:43:24
问题 OK, I know that this is very general question and that there were written some papers on the subject, but I have a feeling that these publications cover very basic material and I'm looking for something more advanced which would improve style and efficency. This is what I have in paper: "Research Report AI-1989-08 Efficient Prolog: A Practical Guide" by Michael A. Covington, 1989 "Efficient Prolog Programming" by Timo Knuutila, 1992 "Coding guidelines for Prolog" by Covington, Bagnara, O

'if' in prolog?

梦想的初衷 提交于 2019-11-27 20:21:39
Is there a way to do an if in prolog, e.g. if a variable is 0, then to do some actions (write text to the terminal). An else isn't even needed, but I can't find any documentation of if. stonemetal A standard prolog predicate will do this. isfive(5). will evaluate to true if you call it with 5 and fail(return false) if you run it with anything else. For not equal you use \= isNotEqual(A,B):- A\=B. Technically it is does not unify, but it is similar to not equal. Learn Prolog Now is a good website for learning prolog. Edit: To add another example. isEqual(A,A). Yes, there is such a control

How to define (and name) the corresponding safe term comparison predicates in ISO Prolog?

泄露秘密 提交于 2019-11-27 14:34:43
Standard term order (ISO/IEC 13211-1 7.2 Term order) is defined over all terms — including variables. While there are good uses for this — think of the implementation of setof/3 , this makes many otherwise clean and logical uses of the built-ins in 8.4 Term comparison a declarative nightmare with imps (short form for imperative constructs) all around. 8.4 Term comparison features: 8.4 Term comparison 8.4.1 (@=<)/2, (==)/2, (\==)/2, (@<)/2, (@>)/2, (@>=)/2. 8.4.2 compare/3 . 8.4.3 sort/2 . 8.4.4 keysort/2 . To give an example, consider: ?- X @< a. true. This succeeds, because 7.2 Term order An

Prolog - unusual cons syntax for lists

一世执手 提交于 2019-11-27 07:43:19
问题 I have come across an unfamiliar bit of Prolog syntax in Lee Naish's paper Higher-order logic programming in Prolog . Here is the first code sample from the paper: % insertion sort (simple version) isort([], []). isort(A.As, Bs) :- isort(As, Bs1), isort(A, Bs1, Bs). % insert number into sorted list insert(N, [], [N]). insert(N, H.L, N.H.L) :- N =< H. insert(N, H.LO, H.L) :- N > H, insert(N, LO, L). My confusion is with A.As in isort(A.As, Bs) :- . From the context, it appears to be an

Which meanings of “type” are used in the standard?

限于喜欢 提交于 2019-11-27 06:55:12
问题 In part one of the ISO standard for Prolog, ISO/IEC 13211-1:1995, the notion of "type" is used to refer to different things. This often leads to confusion. For example, a page called IsoErrata (archived version, source) states (note that this page is not related to ISO): 7.12.2 and 8.1.2.1 There is a confusion about what a "type" is. There seem to be 3 different groups: Those that are listed in 8.1.2.1 and also occur as ValidTypes in type_error terms in 7.12.2.b Those that are listed in 8.1.2