iso-prolog

How is a integer created as a character code constant?

ⅰ亾dé卋堺 提交于 2019-12-01 21:02:28
I am building some test cases for integer/1 using SWI-Prolog. ISO/IEC 13211-1 gives a BNF definition for integer and one of the alternatives for integer is for a character code constant . I am able to create and test examples of all the other alternatives using integer/1 but for character code constant I cannot create a valid example. (see below) How is an integer as a character code constant created that will return true using integer/1 ? Answer Thanks to @false. integer(0'0). true. integer(0'9). true. integer(0'a). true. integer(0'\n). true. Usefulness X is 0'\n. X = 10. X is 0b010101. X =

throw without catch in ISO Prolog

寵の児 提交于 2019-12-01 20:38:10
I am struggling with what is the precise semantics of throw/1 without a suitable catch/3 in ISO Prolog. I am reading the ISO Prolog specification, and it seems to me that the execution will end up in an infinite recursion. (Note that you must have access to the ISO Prolog standard in order to interpret this question). Step 1. Let's say we call throw(unknown), and there is no catch/3 on the stack whatsoever. Step 2. It will end up in 7.8.10.1 c), saying that it will be an system error (7.12.2 j). Step 3. This is the same kind of formulation used at other places for other places, so I assume it

Hilog terms in (XSB) Prolog

谁都会走 提交于 2019-12-01 16:08:14
Are Hilog terms (i.e. compounds having as functors arbitrary terms) still regarded as a powerful feature in XSB Prolog (or any other Prolog) ? Are there many XSB projects currently using this feature ? which of them for example ? I ask since as far as I understand higher order programming is equally possible using the ISO built-in call/N. Specifically, I would like to understand if XSB is using Hilog terms just for historical reasons or if Hilog terms have considerable advantages in comparison to the current ISO standard. Within XSB, Hilog terms are very strongly connected to the module system

Variable occurrence in a list of variables

∥☆過路亽.° 提交于 2019-12-01 15:00:57
Consider a (meta-logical) predicate var_in_vars(Var, Vars) which takes a variable Var and a list of variables Vars and succeeds if Var occurs in Vars . So we do not need to ensure that Var is a variable, nor that Vars is a list of variables. What is the most compact and canonical way to express this in ISO Prolog? Here is an overview of the built-ins in ISO/IEC 13211-1:1995 including Cor.2:2012. ?- var_in_vars(V, [U,V,W]). true. ?- var_in_vars(V, [X,Y,Z]). false. One possibility: var_in_vars(V, Vs) :- \+ unify_with_occurs_check(V, Vs). and shorter: var_in_vars(V, Vs) :- \+ subsumes_term(V, Vs)

Variable occurrence in a list of variables

微笑、不失礼 提交于 2019-12-01 13:49:15
问题 Consider a (meta-logical) predicate var_in_vars(Var, Vars) which takes a variable Var and a list of variables Vars and succeeds if Var occurs in Vars . So we do not need to ensure that Var is a variable, nor that Vars is a list of variables. What is the most compact and canonical way to express this in ISO Prolog? Here is an overview of the built-ins in ISO/IEC 13211-1:1995 including Cor.2:2012. ?- var_in_vars(V, [U,V,W]). true. ?- var_in_vars(V, [X,Y,Z]). false. 回答1: One possibility: var_in

Extension to CFG, what is it?

耗尽温柔 提交于 2019-11-30 19:44:15
Consider the following extension to context-free grammars that permits rules to have in the left-hand side, one (or more) terminal on the right side of the non-terminal. That is, rules of the form: A b -> ... The right-hand side may be anything, like in context-free grammars. In particular, it is not required, that the right-hand side will have exactly the same terminal symbol at the end. In that case, this extension would be context-sensitive. But the terminal is not just a context. Sometimes, this terminal is called "pushback". Clearly, this is no longer CFG (type-2). It includes type-1. But

Rearranging variable_names

▼魔方 西西 提交于 2019-11-30 10:42:14
How to write in a standard conforming manner avs_term_rearranged(AVs, T, AVsR) with given AVs and T such that AVsR is a permutation of AVs with the elements arranged in same order as their variables occur in left-to-right order in T . AVs is a list of elements of the form A = V where A is an atom designating a variable name like 'X' and V is a corresponding variable. Such lists are produced by read_term/2,3 with the read-option variable_names/1 (7.10.3). Additionally, the precise order of elements is not defined. | ?- read_term(T,[variable_names(AVs)]). A+B+A+_+C. AVs = ['A'=A,'B'=B,'C'=C] T =

What does +,+ mode in Prolog mean?

假装没事ソ 提交于 2019-11-29 11:55:04
So am being told a specific predicate has to work in +,+ mode. What does that mean in Prolog? When one wants to give information on a predicate in prolog, those conventions are often used : arity : predicate/3 means predicate takes 3 arguments. parameters : predicate(+Element, +List, -Result) means that Element and List should not be free variables and that Result should be a free variable for the predicate to work properly. ? is used when it can be both, @ is mentionned on the above answer but is not really used as much (at least in swi-pl doc) and means that the input will not be bound

Implementing cut in tracing meta interpreter prolog

天大地大妈咪最大 提交于 2019-11-29 10:15:48
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(A < B, _Depth):-!, A < B. mi_trace(A =< B, _Depth):-!, A =< B. mi_trace(A >= B, _Depth):-!, A >= B.

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

末鹿安然 提交于 2019-11-29 10:07:29
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.1 and occur as ValidDomain in domain_error terms in 7.12.2.c Those that are listed in 8.1.2.1 only