Class TPTPParser
java.lang.Object
org.tweetyproject.commons.Parser<FolBeliefSet,FolFormula>
org.tweetyproject.logics.fol.parser.TPTPParser
This class implements a parser for the TPTP syntax that parses single fol formulas and knowledge bases
(TPTP problem files or axiom files).
TPTP files consist of any of the following in any order and separated by newlines:
Negation: ~ formula
Conjunction: formula & formula
Disjunction: formula | formula
Implication: formula => formula
formula <= formula
Equivalence: formula <=> formula
Universal quantifier: ! [Variable1,Variable2,...] : (formula)
Existential quantifier: ? [Variable1,Variable2,...] : (formula)
Tautology: $true
Contradiction: $false
Equality: = (TODO soon to be added)
Inequality: != (TODO soon to be added)
- formulas
- comments, i.e. lines starting with "%"
- includes of other TPTP files, i.e. lines like "include('path/to/file',[optional,formula,names])"
- name is the name of the formula
- role is anything out of {axiom, hypothesis, definition, assumption, lemma, theorem, corollary conjecture, negated_conjecture}
- formula is the actual formula
- The other arguments are optional and ignored by this parser.
Negation: ~ formula
Conjunction: formula & formula
Disjunction: formula | formula
Implication: formula => formula
formula <= formula
Equivalence: formula <=> formula
Universal quantifier: ! [Variable1,Variable2,...] : (formula)
Existential quantifier: ? [Variable1,Variable2,...] : (formula)
Tautology: $true
Contradiction: $false
Equality: = (TODO soon to be added)
Inequality: != (TODO soon to be added)
- Author:
- Anna Gessler
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the signature of this parser.parseBeliefBase
(Reader reader) Parses the given reader into a belief base of the given type.parseFormula
(Reader reader) Parses the given reader into a formula of the given type.void
Reset the regular expression that restricts which formulas will be parsed to the default value, meaning formulas of all names will be parsed.void
Reset the regular expression that restricts which formulas will be parsed to the default value, meaning formulas of any TPTP roles will be parsed.void
setFormulaNames
(String formulaNames) Set the regular expression that restricts which formulas will be parsed.void
setFormulaRoles
(String formulaRoles) Set the regular expression that restricts which formulas will be parsed.void
setIncludePath
(String includePath) Set the location of included files.void
setSignature
(FolSignature signature) Sets the signature for this parser.Methods inherited from class org.tweetyproject.commons.Parser
isNumeric, parseBeliefBase, parseBeliefBaseFromFile, parseFormula, parseFormulaFromFile, parseListOfBeliefBases, parseListOfBeliefBases, parseListOfBeliefBasesFromFile, parseListOfBeliefBasesFromFile
-
Constructor Details
-
TPTPParser
public TPTPParser()
-
-
Method Details
-
parseBeliefBase
Description copied from class:Parser
Parses the given reader into a belief base of the given type.- Specified by:
parseBeliefBase
in classParser<FolBeliefSet,
FolFormula> - Parameters:
reader
- a reader- Returns:
- a belief base
- Throws:
IOException
- if some IO issue occurred.ParserException
- some parsing exceptions may be added here.
-
parseFormula
Description copied from class:Parser
Parses the given reader into a formula of the given type.- Specified by:
parseFormula
in classParser<FolBeliefSet,
FolFormula> - Parameters:
reader
- a reader- Returns:
- a formula
- Throws:
IOException
- if some IO issue occurred.ParserException
- some parsing exceptions may be added here.
-
setSignature
Sets the signature for this parser.- Parameters:
signature
- a fol signature.
-
getSignature
Returns the signature of this parser.- Returns:
- the signature of this parser.
-
setFormulaNames
Set the regular expression that restricts which formulas will be parsed. Formulas with names that do not match the expression will not be parsed.- Parameters:
formulaNames
- the regex for formula names
-
setFormulaRoles
Set the regular expression that restricts which formulas will be parsed. Formulas with roles that do not match the expression will not be parsed.- Parameters:
formulaRoles
- the regex for formula roles
-
resetFormulaRoles
public void resetFormulaRoles()Reset the regular expression that restricts which formulas will be parsed to the default value, meaning formulas of any TPTP roles will be parsed. Possible TPTP roles are axiom, hypothesis, definition, assumption, lemma, theorem, corollary, conjecture and negated_conjecture. -
resetFormulaNames
public void resetFormulaNames()Reset the regular expression that restricts which formulas will be parsed to the default value, meaning formulas of all names will be parsed. -
setIncludePath
Set the location of included files.- Parameters:
includePath
- path that will be prepended to the paths of all included problem files.
-