How to avoid unexpected backtracking in Prolog fail loops
A Prolog fail loop is a way of doing iteration in Prolog. For example, in this predicate (methods and functions are called predicates in Prolog because the method name is used in the predicate position of propositions used to write Prolog code), we iterate over all facts in the knowledge base that match the given 'edge' pattern:
buildEdges(MiddleNode, RightNode) :-
LeftNode #< MiddleNode, %ECLiPSe feature: constrain LeftNode to be an int smaller than MiddleNode
edge(LeftNode, MiddleNode),
addEdge(LeftNode, RightNode),
fail.
The reason that putting 'fail' at the end leads to iteration is that Prolog automatically searches for other ways of satisfying conditions, unless you tell it not to. So, if there is a fact matching the 'edge' pattern, and if 'addEdge' also succeeds, then when the interpreter reaches 'fail' it "backtracks" to the addEdge call to see if there were any unexplored ways of satisfying it (aka, it checks if there were any other "choicepoints"). If there were such unexplored options in addEdge, the interpreter tries the first one; if ...
-
Why Palm’s webOS is the future of Android (and desktop computing)
Do you connect these dots in the same way I do?
The current practice in OSs and browsers of asking the user at install time whether ...
[January 28th by david]
-
How to enable TestNG launch configurations in Eclipse IDE (Windows)
When using TestNG 5.11 (and at least one earlier version, 5.9) with the Eclipse IDE 3.4.2 (Ganymede, for Windows), one can't setup a Run configuration ...
[January 3rd by david]
-
Glossary and notes for Len Talmy’s work on cognitive semantics
I'm starting to read Talmy's work on folk concepts of space and causality, and I find that I need to keep a glossary of his ...
[December 27th by david]
-
Good advice about how to hire programmers
http://www.aaronsw.com/weblog/hiring
[December 27th by david]
-
Porting Amzi prolog to ECLiPSe
While Amzi Prolog has the best debugger I've seen for any flavor of Prolog (and I've evaluated many flavors), it's become clear that my project ...
[December 2nd by david]
-
Evaluating animation toolkits for ‘perception of intentionality’ simulations
Our team needs to create 2D animations that trigger the 'perception of causality' or the 'perception of intentionality' through the movement of simple shapes. (Jointed ...
[October 13th by david]
-
A font for eco-friendly printing
So you already print double-sided or reuse single-sided prints? You can go even further in your quest for eco-friendly printing.
A font has been developed that ...
[August 5th by david]
-
Open a page in the default browser following a schedule
The notification component of our wiki (plone) isn't useful enough to bother with, so as a workaround I view its "Recent Changes" page on a ...
[June 7th by david]
-
Portable Windows with/without admin privilege
Update: SORRY! It turns out that VirtualBox ties its configuration very closely to specifics of its host machine (such as through the MAC address), so ...
[May 26th by david]
-
Getting svn+ssh client access in Windows
The following steps should help if you are using an svn commandline client and you get an error like:
svn: OPTIONS of 'http://YOURSVNDOMAINANDPATH': could not connect ...
[May 10th by david]
-
Making games more fun with artificial stupidity
If one buys into Daniel Dennett's proposed use of "the intentional stance" to generate explanations and predictions of human behavior (say, in an AI program ...
[March 21st by david]
-
How to sync Windows Mobile with both Exchange and Google
For Windows Mobile phones, Google suggests that you use the ActiveSync program on the phone to connect to one of their servers. This is problematic ...
[March 11th by david]