Questions tagged [prolog-toplevel]

The "toplevel" or "top level loop" is Prolog's REPL.

The toplevel or top level loop is Prolog's REPL.

The toplevel differs from the read-eval-print loop in several ways:

Evaluation is performed incrementally. Typically, evaluation is only performed up to determining one answer, requiring user interaction to compute the next answer.

Printing an answer includes printing answer substitutions but may also include residual constraints.

155 questions
0
votes
2 answers

Prolog different variable, same value

If you query e.g. ?- X = 10, Y = 10, Z = 10. The output is X = Y, Y = Z, Z = 10. But my X is totally different from Y, they just happen to accidentally both be 10, so it doesn't seem clear/logical to display it that way. Can i make it look like…
Frodo
  • 21
  • 2
0
votes
1 answer

Why SWI-Prolog doesn't display 'false' when there aren't any more results to show

I'm following a Prolog book and currently trying the following example. My facts are; parent(tom, bob). parent(pam, bob). parent(tom, liz). parent(bob, ann). parent(bob, pat). parent(pat, jim). I queried Prolog as: ?- parent(X, Y). Results were; X…
Hareen Laks
  • 1,432
  • 2
  • 17
  • 33
0
votes
1 answer

How to get a numeric value from the consulting file in Prolog?

I am very new to Prolog, and am trying to write a rule that finds a person with more money. I am consulting a file which looks like this: money('Henry', 200). money('Sally', 500). money('Tom', 50). Here is my attempt at writing a rule that finds…
Royal Rat
  • 165
  • 1
  • 7
0
votes
1 answer

Prolog: Storing result of an operation

just started programming with prolog and I'm having a few issues. I wanna store the result on an operation , for…
SimoDev
  • 1
  • 2
0
votes
2 answers

Change the default output values in ​swi-prolog "true" and "false" for predicate evaluation

When you execute anything in prolog you can see that the result of the evaluation comes out as: true or false I would like to change those values for personalized ones. Based on this question, I saw that what I want is defined in the…
Ruslan López
  • 4,433
  • 2
  • 26
  • 37
0
votes
1 answer

Why is this Prolog program returning true AND false?

i'm new to Prolog, and try to understand why this very simple program is return 2 solutions : true AND false. For me, this should return only true, why return false too ? predicate1(_,[]). predicate1(X,[_|T]) :- predicate1(X,T). ?-…
Cristof
  • 26
  • 1
0
votes
2 answers

Prolog returning "true" instead of "yes"

My Prolog code is required to return yes (or no) after the query is inputted, but is instead returning "true ?" and requiring me to press enter to get the "yes". The problem is about Russian dolls, the order of dolls from outer to inner is…
0
votes
0 answers

Additional 'false' at end of query

Basically I'm wondering why one of my definitions for a new predicate gresults in my query ending whith a 'false', while the other definition jumps straight back to '?-'. Given a database like this: f(a,b). f(b,c). f(c,d). I want to produce a new…
azureai
  • 181
  • 1
  • 13
0
votes
0 answers

Prolog, result correctly given but false is printed

I have for example the following function computing the set of all internal nodes in a binary tree (nodes which have at least one child, i.e. are no leaves) internals(nil,[]). internals(t(_,nil,nil),[]). internals(t(X,L,nil),[X|S]) :- L = t(_,_,_),…
Wouter Vandenputte
  • 1,948
  • 4
  • 26
  • 50
0
votes
0 answers

permutation/2 returns no permutation

What is permutation/2 ? As said in the help(permutation).: The predicate permutation/2 is primarily intended to generate permutations. That's what I want to use it for. How permutation/2 should work This is the example given in the…
Asqiir
  • 607
  • 1
  • 8
  • 23
0
votes
1 answer

how can I delete the command history in swi-prolog

So, I enjoy the option of using the up and down arrow keys to search through the command history in Swi-Prolog instead of retyping commands. I want to know how I can delete the command history.
quixote
  • 195
  • 1
  • 7
0
votes
1 answer

Prolog Queries is returning wrong boolean value

so I have a fact weather(jan, 17, cold, wind, snow). and rule match(W,D,T) :- weather(W,D,T,_,_) ; weather(W,D,_,T,_) ; weather(W,D,_,_,T). When I type match(jan, 17, wind). Prolog returns true; false. I want it to only return true,…
Han Ben
  • 17
  • 4
0
votes
1 answer

Not getting full result when output is on one line

Im new at Prolog , and I am trying some manipulation on graphs . I have a problem in my implementation, and since it is very long and complicated to expose , I will give a simple and similar problem . Let say we have the following graph :…
StamDad
  • 135
  • 8
0
votes
3 answers

Prolog program returns false

I implemented the following power program in Prolog: puissance(_,0,1). puissance(X,N,P) :- N>0,A is N-1, puissance(X,A,Z), P is Z*X. The code does what is supposed to do, but after the right answer it prints "false.". I don't understand why. I am…
ColgateAlo
  • 35
  • 4
0
votes
1 answer

Typing listing in SWI-prolog and pressing enter does nothing

I'm going through the prolog tutorial here and it tells me to type in listing for a list of the contents of the current knowledgebase. I'm pretty sure that without loading a KB, it should display gibberish. However, instead I have: after I press…