edu.udo.cs.ie.cowbots.logic
Class ELP

Package class diagram package ELP
java.lang.Object
  extended by edu.udo.cs.ie.cowbots.logic.ELP
Direct Known Subclasses:
DisjunctiveLogicProgram

public class ELP
extends java.lang.Object

this class models an extended logic program. it consists of a set of rules (and fact and constraints).


Field Summary
(package private)  java.util.ArrayList<ELPRule> rules
           
 
Constructor Summary
ELP()
           
ELP(Literal l)
           
 
Method Summary
 void add(ELP program2)
          this methods adds all rules from the given program to this program
 void addRaw(java.lang.String s)
          adds a raw, unchecked string as the head of a new rule to the elp. this method can be used to pass arbitrary statements to the program. it also removes the last '.' from the input string.
 void addRule(ELPRule r)
           
 Alphabet getAlphabet()
          returns the alphabet of this program (set of all functor symbols)
 java.util.List<ELPLiteral> getFacts()
          return all literals that are facts (even disjunctive)
 ELPRule getRule(int i)
          get rule i
 java.util.ArrayList<ELPRule> getRules()
          returns all elp rules in this program
static ELP loadFrom(java.lang.String filename)
          loads an elp from a file ressource
 ELP merge(ELP other)
          merges this and another elp and return a new elp
 int nRules()
          number of rules in elp
 void saveAs(java.lang.String filename)
          store elp on disc
 void split(java.util.Collection<ELPLiteral> literals, java.util.Collection<ELPRule> rules)
          splits the given program into rules and facts.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

rules

java.util.ArrayList<ELPRule> rules
Constructor Detail

ELP

public ELP(Literal l)

ELP

public ELP()
Method Detail

addRule

public void addRule(ELPRule r)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

nRules

public int nRules()
number of rules in elp

Returns:

getRule

public ELPRule getRule(int i)
get rule i

Parameters:
i -
Returns:
rule with name (index) i

getRules

public java.util.ArrayList<ELPRule> getRules()
returns all elp rules in this program

Returns:
arraylist of elp rules

getFacts

public java.util.List<ELPLiteral> getFacts()
return all literals that are facts (even disjunctive)

Returns:

saveAs

public void saveAs(java.lang.String filename)
store elp on disc

Parameters:
file - output filename (like foo.elp or bar.txt)

loadFrom

public static ELP loadFrom(java.lang.String filename)
loads an elp from a file ressource

Parameters:
filename - file to read elp from

merge

public ELP merge(ELP other)
merges this and another elp and return a new elp

Parameters:
other - second elp to merge with
Returns:
elp with all rules from this and other

addRaw

public void addRaw(java.lang.String s)
adds a raw, unchecked string as the head of a new rule to the elp. this method can be used to pass arbitrary statements to the program. it also removes the last '.' from the input string. anyway, use with care..

Parameters:
s - text string added to program

getAlphabet

public Alphabet getAlphabet()
returns the alphabet of this program (set of all functor symbols)

Returns:
alphabet of program

split

public void split(java.util.Collection<ELPLiteral> literals,
                  java.util.Collection<ELPRule> rules)
splits the given program into rules and facts. note that disjunctive facts are treated as rules.

Parameters:
literals - output container for all literals
rules - output container for all rules

add

public void add(ELP program2)
this methods adds all rules from the given program to this program

Parameters:
program2 - program to add