The module provides the tools to work with Horn Reasoning Systems (HRS) through the definition of facts and rules and the use of forward and backward chaining to make deductions. Conversion to standard formulas and clauses is also provided to apply other algorithms on them.
LogicUS.PL.SyntaxSemantics.PSymb
It defines a fact as a propositional variable. Use ("⟂", []) for represent inconsistence and ("⊤", []) for represent tautology.
( Set HornFact
, HornFact
)
It defines an inference rule of Horn as a tuple whose first element regards to the antecedents of the rule and the second one to de consecuent of the rule.
Set HornFact
It defines a Knowledge Base of Horn as a set of facts.
{ step : Basics.Int
, kb : HornKB
, avRules : List Basics.Int
, shRules : List Basics.Int
, newFacts : HornKB
}
It defines a row of a table of FC process with the properties:
{ rules : List HornRule
, initialKB : HornKB
, goal : HornFact
, table : List FwChRow
, res : Basics.Bool
}
It holds the result of forward chaining process including rules, the initial KB, the goal, a table that summarizes the development of the algorithm and the result (if the goal can be deducted from initial KB with the rules given )
forwardChaining1 : List HornRule -> HornKB -> HornFact -> FwChResult
It performs forwardChaining algorithm with removing, at each step, the rules shot from available rules.
forwardChaining2 : List HornRule -> HornKB -> HornFact -> FwChResult
It performs forwardChaining algorithm with removing, at each step, the rules whose consecuent is already in the KB from available rules.
forwardChainingResultToString : FwChResult -> List String
It generates two tables in a list with the result and the process of a forwarding chaining execution.
forwardChainingResultToMDString : FwChResult -> String
It generates a markdown string (including latex notation) of the result of a forwarding chaining execution.
{ step : Basics.Int
, opened : List ( Basics.Bool
, HornKB )
, currentNode : Maybe HornKB
, goal : Maybe HornFact
, descendents : List ( Basics.Bool
, Basics.Int
, List ( Basics.Bool
, HornFact ) )
}
It defines a row of a table of BW process with the properties:
{ rules : List HornRule
, initialKB : HornKB
, goal : HornFact
, table : List BwChRow
, res : Basics.Bool
}
It holds the result of backward chaining process including rules, the initial KB, the goal, a table that summarizes the development of the algorithm and the result (if the goal can be deducted from initial KB with the rules given).
backwardChaining1 : List HornRule -> HornKB -> HornFact -> BwChResult
It performs the backward chaining algorithm by selecting at each step the way with the fewest remaining goals and the goal using alphabetical order.
backwardChainingResultToString : BwChResult -> List String
It generates two tables in a list with the result and the process of a backwarding chaining execution.
backwardChainingResultToMDString : BwChResult -> String
It generates a MD string (including latex notation) of the result of an execution of BC algorithm
hornFactToFPL : HornFact -> LogicUS.PL.SyntaxSemantics.FormulaPL
It transform a Horn fact to a standard formula
hornKBToSPL : HornKB -> LogicUS.PL.SyntaxSemantics.SetPL
It transform a Horn KB to a standard formula set
hornRuleToFPL : HornRule -> LogicUS.PL.SyntaxSemantics.FormulaPL
It transform a Horn rule to a standard formula
hornRulesToSPL : List HornRule -> LogicUS.PL.SyntaxSemantics.SetPL
It transform a list of Horn rules to a standard formula
hornFactToClause : HornFact -> LogicUS.PL.Clauses.ClausePL
It transform a Horn fact to a clause
hornKBToClauses : HornKB -> LogicUS.PL.Clauses.ClausePLSet
It transform a Horn kb to a set of clauses
hornRuleToClause : HornRule -> LogicUS.PL.Clauses.ClausePL
It transform a Horn rule to a clause
hornRulesToClauses : List HornRule -> LogicUS.PL.Clauses.ClausePLSet
It transform a list of Horn rules to a set of clauses
hornFactReadFromString : String -> ( Maybe HornFact, String, String )
It reads a Horn fact from a string. The string may correspond to:
It gives a tuple with the Horn fact (if it could be read) , the input string and the message of error (if fact couldn't be read).
hornFactReadExtraction : ( Maybe HornFact, String, String ) -> HornFact
It extract the Horn fact read. If it is not present it returns a fact of inconsistency
hornFactToInputString : HornFact -> String
It generates the string that corresponds to the input of a given Horn fact
hornKBReadFromString : String -> ( Maybe HornKB, String, String )
It reads a Horn KB from a string. The string has to match to a serial of facts separated by commas, following the rules defined for facts parsing.
It gives a tuple with the Horn KB (if it could be read) , the input string and the message of error (if fact couldn't be read).
hornKBReadExtraction : ( Maybe HornKB, String, String ) -> HornKB
It extract the Horn KB read. If it is not present it returns an empty set
hornKBToInputString : HornKB -> String
It generates the string that corresponds to the input of a given Horn KB
hornRuleReadFromString : String -> ( Maybe HornRule, String, String )
It reads a Horn rule from a string. The string has to match to a serial of facts separated by &
for the antecedents, followed by the symbol ->
and a unique fact as consecuent.
It gives a tuple with the Horn rule (if it could be read) , the input string and the message of error (if fact couldn't be read).
hornRuleReadExtraction : ( Maybe HornRule, String, String ) -> HornRule
It extract the Horn rule read. If it is not present it returns a rule with inconsistence as antecedent and consecuent
hornRuleToInputString : HornRule -> String
It generates the string that corresponds to the input of a given Horn rule
hornRulesReadFromString : String -> ( Maybe (List HornRule), String, String )
It reads a Horn rule list from a string. The string has to match to a serial of rules separated by commas.
It gives a tuple with the Horn rule list (if it could be read) , the input string and the message of error (if fact couldn't be read).
hornRulesReadExtraction : ( Maybe (List HornRule), String, String ) -> List HornRule
It extract the list of Horn rules read. If it is not present it returns an empty list
hornRulesToInputString : List HornRule -> String
It generates the string that corresponds to the input of a given list of Horn rules
hornFactToString : HornFact -> String
It gives the string representation of a Horn fact using unicode notation
hornFactToMathString : HornFact -> String
It gives the string representation of a Horn fact using latex notation
hornKBToStringComma : HornKB -> String
It gives the string representation of a Horn KB separating facts by comma using unicode notation
hornKBToStringWedge : HornKB -> String
It gives the string representation of a Horn KB separating facts by ∧ using unicode notation
hornKBToMathStringComma : HornKB -> String
It gives the string representation of a Horn KB separating facts by comma using latex notation
hornKBToMathStringWedge : HornKB -> String
It gives the string representation of a Horn KB separating facts by ∧ using latex notation
hornRuleToString : HornRule -> String
It gives the string representation of a Horn rule using unicode notation
hornRuleToMathString : HornRule -> String
It gives the string representation of a Horn rule using latex notation
hornRulesToString : List HornRule -> String
It gives the string representation of a Horn rule list using unicode notation and indexing the formulas by its position in the list
hornRulesToMathString : List HornRule -> String
It gives the string representation of a Horn rule list using latex notation and indexing the formulas by its position in the list