Topic: Prolog Predicate
Answers to Common Questions
How to Create a Prolog Append Predicate
Prolog contains a built-in predicate called "append" that appends two lists, but writing your own will help you gain an understanding how the language uses matching and unification to perform computations. In a procedural and imperative pro... Read More »
Source: http://www.ehow.com/how_6081568_create-prolog-append-predicate.ht...
What is a predicate and an argument in Prolog?
best(me) best() is the predicate which returns either True or False me is the argument because I am not the best, best(me) will return false if you are the best then best(you) will return true any term which returns either true or false dep... Read More »
Source: http://answers.yahoo.com/question/index?qid=20071125072335AA2m46z
How to define a predicate in prolog
You can use the assert/1 predicate: ?- assert(adjacent(1,4)). true EDIT: By the way, this will not work if you try to combine it with predicates defined in a file. So either define all adjacent/2 predicates in your file, are define them all... Read More »
Source: http://stackoverflow.com/questions/1843899/how-to-define-a-predic...
Answers to Other Common Questions
Your code is very strange, however I can recommend you to use trace predicate for testing purposes. Here is the example: 4 ?- trace([equals,contains]). % equals/2: [call, redo, exit, fail] % contains/2: [call, redo, exit, fail] true. [debug... Read More »
Source: http://stackoverflow.com/questions/1060630/why-does-this-prolog-p...
Elegant systems provide false/0 as a declarative synonym for the imperative "fail/0". An example where it is useful is when you manually want to force backtracking for side-effects, like: ?- between(1,3,N), format("line ~w\n", [N]), false. ... Read More »
Source: http://stackoverflow.com/questions/3001825/what-are-the-uses-of-t...
s/1 stands for successor. It's used to represent numbers in a logically accessible ways. Read More »
Source: http://stackoverflow.com/questions/8197088/what-does-the-s-predic...
given these 2 sentences in predicate logic: 1. for all Car: color(Car, blue) -> not owner(tim, Car) // tim doesnot have a blue car 2. color ( auto4, blue) // auto4 is a blue car with modus ponens I can conclude: 3. not owner(tim, auto4) // ... Read More »
Source: http://objectmix.com/prolog/183261-problem-how-translate-predicat...
Escape the quote with backslash; for example, to output a single single-quote: ?- write('\''). ' true. Read More »
Source: http://stackoverflow.com/questions/4353821/how-to-write-single-qu...
As I understand it, the basic problem is that if circular definitions are allowed, although the resulting language is self-consistent, there can be subtle consequences which are often counter-intuitive. There are also efficiency considerati... Read More »
Source: http://stackoverflow.com/questions/1424151/how-can-i-fix-this-cir...
I think you must be seeing readln not readin. The library predicate readln/1 reads tokens from an input line in the interactive SWI-Prolog console and makes a list of them. Most Prolog term reading predicates require a period to terminate i... Read More »
Source: http://stackoverflow.com/questions/8015687/what-does-readin-predi...
Want A Personal Answer?
730,460 people are answering.
About - Privacy - AskEraser - Advertise - Careers - Ask Blog - iPhone - Android - Help - Feedback ©2012 Ask.com