Kernel Prolog with Fluent based Builtins

tarau.jinni
Class Unfolder

java.lang.Object
  |
  +--tarau.jinni.Term
        |
        +--tarau.jinni.Nonvar
              |
              +--tarau.jinni.SystemObject
                    |
                    +--tarau.jinni.Fluent
                          |
                          +--tarau.jinni.Source
                                |
                                +--tarau.jinni.Unfolder

class Unfolder
extends Source

For a given clause g= A0:-,A1,A2...,An, used as resolvent iterates over its possible unfoldings (LD-resolution steps) with clauses of the form B0:-B1,...,Bm in the default database. For each such step, a new clause (A0:-B1,...,Bm,A2...,An)mgu(A1,B0) is built and returned by the Unfolder's getElement method. Before the actual unfolding operations, builtins in Guard are executed, possibly providing bindings for some variables or failing. In case of failure of Guard or of unification, getElement() returns null.


Field Summary
private  java.util.Enumeration e
           
private  Clause goal
           
private  int oldtop
           
private  Prog prog
           
 
Fields inherited from class tarau.jinni.Fluent
persistent
 
Fields inherited from class tarau.jinni.SystemObject
ctr, ordinal
 
Fields inherited from class tarau.jinni.Term
CONST, INT, JAVA, REAL, VAR
 
Constructor Summary
Unfolder(Clause g, Prog p)
          Creates an Unfolder based on goal clause g for resolution step in program p
 
Method Summary
(package private)  Clause getAnswer()
          Extracts an answer at the end of an AND-derivation
 Term getElement()
          Returns a new clause by unfolding the goal with a matching clause in the database, or null if no such clause exists.
(package private)  boolean notLastClause()
          Checks if this clause is the last one, allowing LCO
(package private)  void reduceBuiltins()
          Reduces builtin functions after the neck of a clause, before a "real" atom is unfolded
 void stop()
          Stops production of more alternatives by setting the clause enumerator to null
 java.lang.String toString()
          Returns a string representation of this unfolder, based on the original clause it is based on.
(package private)  void trace_failing(Clause g)
          Tracer on exiting g
(package private)  void trace_goal(Clause g)
          Tracer on entering g
(package private)  void trace_nomatch(Term first)
          Tracer for undefined predicates
protected  void trailMe(Prog p)
          Overrides default trailing by empty action
 
Methods inherited from class tarau.jinni.Source
toFun, toList
 
Methods inherited from class tarau.jinni.Fluent
getPersistent, setPersistent, undo
 
Methods inherited from class tarau.jinni.SystemObject
bind_to, getArity, name
 
Methods inherited from class tarau.jinni.Nonvar
eq, listify, unify_to
 
Methods inherited from class tarau.jinni.Term
action, charsToString, copy, exec, exec, fromString, getKey, isBuiltin, isClause, matches, matching_copy, numbervars, pprint, pprint, reaction, ref, stringToChars, toChars, toClause, token, toObject, toTerm, toUnquoted, unify, varsOf
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

oldtop

private int oldtop

e

private java.util.Enumeration e

goal

private Clause goal

prog

private Prog prog
Constructor Detail

Unfolder

public Unfolder(Clause g,
                Prog p)
Creates an Unfolder based on goal clause g for resolution step in program p
Method Detail

trailMe

protected void trailMe(Prog p)
Overrides default trailing by empty action
Overrides:
trailMe in class Fluent

getAnswer

Clause getAnswer()
Extracts an answer at the end of an AND-derivation

notLastClause

final boolean notLastClause()
Checks if this clause is the last one, allowing LCO

reduceBuiltins

final void reduceBuiltins()
Reduces builtin functions after the neck of a clause, before a "real" atom is unfolded

getElement

public Term getElement()
Returns a new clause by unfolding the goal with a matching clause in the database, or null if no such clause exists.
Overrides:
getElement in class Source

stop

public void stop()
Stops production of more alternatives by setting the clause enumerator to null
Overrides:
stop in class Fluent

trace_goal

final void trace_goal(Clause g)
Tracer on entering g

trace_failing

final void trace_failing(Clause g)
Tracer on exiting g

trace_nomatch

final void trace_nomatch(Term first)
Tracer for undefined predicates

toString

public java.lang.String toString()
Returns a string representation of this unfolder, based on the original clause it is based on.
Overrides:
toString in class SystemObject

Kernel Prolog with Fluent based Builtins