Class 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
    • Constructor Detail

      • AspNlpTranslator

        public AspNlpTranslator()
    • 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
      • 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 bodies
        bodies - 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 disjunction
        bodies - 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 class AspFolTranslator