Questions tagged [prolog-metainterpreter]

Use with Prolog when Prolog code is a meta-interpreter, e.g. a self-interpreter of Prolog code or a meta-circular interpreter of Prolog code.

Prolog meta interpreters are useful to change the evaluation process of Prolog code.

References:

A Couple of Meta-interpreters in Prolog
Three Meta-Interpreters: Prolog in Prolog, EXSHELL, and a Planner (pdf)

32 questions
10
votes
3 answers

Refactoring tangled, circular rules in Prolog

Right up front: This is not a homework exercise. I’m trying to learn Prolog and this is just a problem that happens to need solving and for which Prolog is a perfect fit. I have a bunch of family relations which comprise my…
8
votes
1 answer

Implementing cut in tracing meta interpreter prolog

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…
Đrakenus
  • 540
  • 3
  • 20
6
votes
3 answers

Depth limited search in prolog (vanilla meta-interpreter)

I need to modify the vanilla meta-interpreter in order to make a search with limited depth. I'm using the following code for testing my sollution: value(wire1,1). connected(wire2, wire1). connected(wire3, wire2). connected(wire4,…
Caroline
  • 611
  • 1
  • 6
  • 11
6
votes
2 answers

Prolog: "Vanilla" metainterpreter with builtins

This answer by Jan Burse shows one of the simplest implementations of a metainterpreter in Prolog: solve(true) :- !. solve((A,B)) :- !, solve(A), solve(B). solve(H) :- clause(H,B), solve(B). I would like to extend this interpreter so that it can…
Daniel Lyons
  • 22,421
  • 2
  • 50
  • 77
5
votes
2 answers

Dealing with complicated prolog loops

I am using Prolog to encode some fairly complicated rules in a project of mine. There is a lot of recursion, including mutual recursion. Part of the rules look something like this: pred1(X) :- ... pred1(X) :- someguard(X), pred2(X). pred2(X) :-…
Ed McMan
  • 521
  • 2
  • 15
4
votes
1 answer

error while compling the metaprogram in prolog

I am trying to implement a meta-program in ECLiPSe Prolog, and here's the code that i have written - :- dynamic go/1. sol(true):- !. sol((A,B)):- !, sol(A), sol(B). sol(A):- clause(A, Body), sol(Body). go(X):- X is 5. Now when I query with…
kallakafar
  • 725
  • 3
  • 11
  • 27
4
votes
2 answers

Looping in Prolog metainterpreter

I'm writing a trivial metainterpreter in Prolog for self-education. Basically I want to carry along the "probability" of a given solution. To do this I just declare the probability of my clause being correct. I expect if this works I will extend it…
Daniel Lyons
  • 22,421
  • 2
  • 50
  • 77
4
votes
1 answer

Prolog tracing interpreter failing into infinite loop when executing recursive programs

I have this tracing meta interpreter which I found in book written by Ivan Bratko called Prolog Programming For Artifical Intelligence 3rd edition and it looks like this: trace(Goal):- trace(Goal, 0). trace(true, Depth):-!. %I added those below…
3
votes
1 answer

Proof as an output argument in Prolog meta interpreter

I am putting together a simple meta interpreter which outputs the steps of a proof. I am having trouble with getting the proof steps as an output argument. My predicate explain1 returns the proof in the detailed form that i would like, but not as an…
user3170496
3
votes
3 answers

Combing generator results and writing result to stream

Currently I can generate expression trees. expression_tree([_|N_s],N_s, [number(0)]). expression_tree([_|N_s0],N_s1, [op(neg),[E1]]) :- expression_tree(N_s0,N_s1, E1). expression_tree([_|N_s0],N_s2, [op(add), [E1, E2]]) :- …
Guy Coder
  • 24,501
  • 8
  • 71
  • 136
3
votes
1 answer

What is wrong with this version of trace?

I have this tracing meta interpreter. It is written for swi-prolog. trace(Goal):- trace(Goal, 0). trace(true, _Depth):-!, true. trace(fail, _Depth):-!, fail. trace(A > B, _Depth):-!, A > B. trace(A < B, _Depth):-!, A < B. trace(A <= B,…
Đrakenus
  • 540
  • 3
  • 20
2
votes
0 answers

What is SLG resolution in Prolog?

I want to understand how does SLG resolution work. But I don't know what SLG is (what does it stand for?). The resource I found are Query evaluation under the well-founded semantics and citation to Efficient implementation of general logical queries…
notoria
  • 2,053
  • 1
  • 4
  • 15
2
votes
1 answer

Meta-interpreter for calculating max recursion depth

I'm trying to write a meta-interpreter in prolog for prolog, which would return maximal reached recursion depth in a given prolog program. This code actually counts number of all recursive calls in a program: rc( true, 0) :- !. rc( ( Goal1, Goal2),…
Uros K
  • 3,274
  • 4
  • 31
  • 45
2
votes
3 answers

Pure Prolog Meta-Interpreter with one Rule

I wonder whether there is a pure Prolog meta-interpreter with only one rule. The usual Prolog vanilla meta-interpreter has two rules. It reads as follows: solve(true). solve((A, B)) :- solve(A), solve(B). /* rule 1 */ solve(H) :- program(H, B),…
user502187
2
votes
1 answer

No permission to access private_procedure `true/0'

I am trying to use vanilla meta interpreter with 'if' and 'and'. Here is my code:- :- op( 600, xfy, if). :- op( 500, xfy, and). findnum(X,X). findnum(X,[X|Tail]). findnum(X,[Y|Tail]):- findnum(X,Tail). prove(true). prove((A,B)):-…
Veve Nana
  • 23
  • 3
1
2 3