Class AspNlpTranslator
- java.lang.Object
-
- net.sf.tweety.logics.translators.Translator
-
- net.sf.tweety.logics.translators.aspfol.AspFolTranslator
-
- net.sf.tweety.logics.translators.aspnlp.AspNlpTranslator
-
public class AspNlpTranslator extends AspFolTranslator
Translates between DLP under the answer set semantics (ASP) and NLP. Because NLP is a kind of superset of FOL the Translator extends the AspFolTranslator.- Author:
- Tim Janus
-
-
Field Summary
-
Fields inherited from class net.sf.tweety.logics.translators.aspfol.AspFolTranslator
TT_NEGATION
-
Fields inherited from class net.sf.tweety.logics.translators.Translator
TT_ASSOC, TT_ATOM, TT_PREDICATE, TT_RULE
-
-
Constructor Summary
Constructors Constructor Description AspNlpTranslator()
-
Method Summary
Modifier and Type Method Description private void
bodiesFromDisjunction(Disjunction source, java.util.List<java.util.List<ASPBodyElement>> bodies)
Helper method:private void
bodiesFromFormula(FolFormula source, java.util.List<java.util.List<ASPBodyElement>> bodies)
Helper method: Generates a list of possible bodies for the given FOL-Formula.protected java.util.Map<java.lang.Class<?>,Pair<java.lang.Integer,java.lang.Class<?>>>
createTranslateMap()
private java.util.List<ASPHead>
headsFromConjunction(Conjunction c)
Program
toASP(NLPProgram program)
Translate the given NLP-program into an ASP-program.Program
toASP(NLPRule rule)
Translates the given NLP-rule into an ASP Program.(package private) NLPRule
toNLP(ASPRule rule)
Translates the given ASP rule to a NLP-rule.NLPProgram
toNLP(Program program)
-
Methods inherited from class net.sf.tweety.logics.translators.aspfol.AspFolTranslator
toASP, toASP, toASP, toASP, toFOL, toFOL, toFOL, toFOL, translateUsingMap
-
Methods inherited from class net.sf.tweety.logics.translators.Translator
createInstance, getTranslateInfo, translateAssociative, translateAtom, translatePredicate, translateRule
-
-
-
-
Method Detail
-
toNLP
NLPRule toNLP(ASPRule rule)
Translates the given ASP rule to a NLP-rule. Every ASP rule is expressible as NLP rule therefore there is no special behavior.- Parameters:
rule
- The ASP rule that is going to be translated.- Returns:
- The translated NLP rule
-
toNLP
public NLPProgram toNLP(Program program)
-
toASP
public Program toASP(NLPRule rule)
Translates the given NLP-rule into an ASP Program. A NLP rule might only be expressible by ASP with multiple rules. If the NLP rule is a :- b v c. Then the two ASP rules a :- b. and a :- c. Are generated. If Conjunctions exist in the head then a rule for every element of the conjunction in the head is generated. Those rules share the same body.- Parameters:
rule
- some rule- Returns:
- The ASP program that represens the rule given as parameter.
-
toASP
public Program toASP(NLPProgram program)
Translate the given NLP-program into an ASP-program.- Parameters:
program
- The NLP-program that is translated- Returns:
- A ASP-program representing the given NLP-program.
-
bodiesFromFormula
private void bodiesFromFormula(FolFormula source, java.util.List<java.util.List<ASPBodyElement>> bodies)
Helper method: Generates a list of possible bodies for the given FOL-Formula. It handles Literals by adding them to every body, Conjunctions by recursively calling this method and Disjunctions by delegating the work to the bodiesFromDisjunction() method.- Parameters:
source
- The FOL formula that is used to generate the bodiesbodies
- A list of bodies which is used as input and output parameter.
-
bodiesFromDisjunction
private void bodiesFromDisjunction(Disjunction source, java.util.List<java.util.List<ASPBodyElement>> bodies)
Helper method:- Parameters:
source
- a disjunctionbodies
- a list of list of body elements
-
headsFromConjunction
private java.util.List<ASPHead> headsFromConjunction(Conjunction c)
-
createTranslateMap
protected java.util.Map<java.lang.Class<?>,Pair<java.lang.Integer,java.lang.Class<?>>> createTranslateMap()
- Overrides:
createTranslateMap
in classAspFolTranslator
-
-