object TPTPParser
Parser for TPTP-based input languages for automated theorem proving, including ...
- THF (TH0/TH1): Monomorphic and polymorphic higher-order logic,
- TFF (TF0/TF1): Monomorphic and polymorphic typed first-order logic, including extended TFF (TFX),
- FOF: Untyped first-order logic,
- TCF: Typed clause-normal form,
- CNF: (Untyped) clause-normal form, and
- TPI: TPTP Process Instruction language.
Both annotated as well as "plain" (meant here: not annotated) formulas can be read.
An annotated formula (here, as an example: annotated THF formula) is of form
thf(name, role, formula, annotations)
whereas the plain formula is the formula
part of this instance.
The parser translated plain formulas into an abstract syntax tree defined at datastructures.TPTP, resp. its corresponding specializations for the respective language dialect:
- THF formulas are parsed into datastructures.TPTP.THF,
- TFF formulas are parsed into datastructures.TPTP.TFF,
- FOF/TPI formulas are parsed into datastructures.TPTP.FOF,
- TCF formulas are parsed into datastructures.TPTP.TCF, and
- CNF formulas are parsed into datastructures.TPTP.CNF.
Annotated formulas are additionally wrapped in an datastructures.TPTP.AnnotatedFormula object as follows:
- Annotated THF formulas wrapped as datastructures.TPTP.THFAnnotated,
- Annotated TFF formulas wrapped as datastructures.TPTP.TFFAnnotated,
- Annotated FOF formulas wrapped as datastructures.TPTP.FOFAnnotated,
- Annotated TCF formulas wrapped as datastructures.TPTP.TCFAnnotated,
- Annotated CNF formulas wrapped as datastructures.TPTP.CNFAnnotated, and
- Annotated TPI formulas wrapped as datastructures.TPTP.TPIAnnotated.
Whole TPTP files are represented by datastructures.TPTP.Problem objects.
Note that include
directives etc. are parsed as-is and are represented by an datastructures.TPTP.Include entry
in the datastructures.TPTP.Problem representation. In particular, they are not parsed recursively.
This has to be implemented externally (e.g., by recursive calls to the parser).
Parsing errors will cause TPTPParser.TPTPParseExceptions.
- Since
January 2021
- Note
For the original implementation of this parser v7.4.0.3 of the TPTP syntax was used, but it's being updated constantly to keep track with TPTP language updates.
- See also
Original TPTP syntax definition at http://tptp.org/TPTP/SyntaxBNF.html.
- Alphabetic
- By Inheritance
- TPTPParser
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- final class TPTPLexer extends BufferedIterator[TPTPLexerToken]
A token stream of leo.modules.input.TPTPParser.TPTPLexer.TPTPLexerTokens that represents a TPTP input.
- class TPTPParseException extends RuntimeException
Main exception thrown by the leo.modules.input.TPTPParser if some parsing error occurs.
- final class TPTPParser extends AnyRef
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def annotated(annotatedFormula: String): AnnotatedFormula
Parses an TPTP annotated formula given as String.
Parses an TPTP annotated formula given as String. Any kind of annotated formula can be passed to the function (THF/TFF/FOF/CNF/TPI), the parser will produce the respective specialization of AnnotatedFormula, e.g., THFAnnotated for annotated THF formulas.
- annotatedFormula
The annotated formula as string.
- returns
The parsing result as an AnnotatedFormula object.
- Exceptions thrown
TPTPParseException
If an parsing error occurred.
- final def annotatedCNF(annotatedFormula: String): CNFAnnotated
Parses an TPTP CNF annotated formula given as String.
Parses an TPTP CNF annotated formula given as String.
- annotatedFormula
The annotated formula as string.
- returns
The parsing result as CNFAnnotated object
- Exceptions thrown
TPTPParseException
If an parsing error occurred.
- final def annotatedFOF(annotatedFormula: String): FOFAnnotated
Parses an TPTP FOF annotated formula given as String.
Parses an TPTP FOF annotated formula given as String.
- annotatedFormula
The annotated formula as string.
- returns
The parsing result as FOFAnnotated object
- Exceptions thrown
TPTPParseException
If an parsing error occurred.
- final def annotatedTCF(annotatedFormula: String): TCFAnnotated
Parses an TPTP TCF annotated formula given as String.
Parses an TPTP TCF annotated formula given as String.
- annotatedFormula
The annotated formula as string.
- returns
The parsing result as leo.datastructures.TPTP.TCFAnnotated object
- Exceptions thrown
TPTPParseException
If an parsing error occurred.
- final def annotatedTFF(annotatedFormula: String, tfx: Boolean = true): TFFAnnotated
Parses an TPTP TFF annotated formula given as String.
Parses an TPTP TFF annotated formula given as String.
- annotatedFormula
The annotated formula as string.
- tfx
If set to
true
, accept TFX formulas as well (default); otherwise exclude TFX inputs.- returns
The parsing result as TFFAnnotated object
- Exceptions thrown
TPTPParseException
If an parsing error occurred.
- final def annotatedTHF(annotatedFormula: String): THFAnnotated
Parses an TPTP THF annotated formula given as String.
Parses an TPTP THF annotated formula given as String.
- annotatedFormula
The annotated formula as string.
- returns
The parsing result as THFAnnotated object
- Exceptions thrown
TPTPParseException
If an parsing error occurred.
- final def annotatedTPI(annotatedFormula: String): TPIAnnotated
Parses an TPTP TPI annotated formula given as String.
Parses an TPTP TPI annotated formula given as String.
- annotatedFormula
The annotated formula as string.
- returns
The parsing result as TPIAnnotated object
- Exceptions thrown
TPTPParseException
If an parsing error occurred.
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @IntrinsicCandidate()
- final def cnf(formula: String): Formula
Parses a plain CNF formula (i.e., without annotations) given as String.
Parses a plain CNF formula (i.e., without annotations) given as String.
- formula
The annotated formula as string.
- returns
The parsing resultas CNFFormula object
- Exceptions thrown
TPTPParseException
If an parsing error occurred.
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def fof(formula: String): Formula
Parses a plain FOF formula (i.e., without annotations) given as String.
Parses a plain FOF formula (i.e., without annotations) given as String.
- formula
The annotated formula as string.
- returns
The parsing resultas FOFFormula object
- Exceptions thrown
TPTPParseException
If an parsing error occurred.
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- final def problem(input: String): Problem
Parses a whole TPTP file given as String.
Parses a whole TPTP file given as String.
- input
The TPTP problem file contents as string.
- returns
The parsing result as a leo.datastructures.TPTP.Problem object.
- Annotations
- @inline()
- Exceptions thrown
TPTPParseException
If an parsing error occurred.
- final def problem(input: Source): Problem
Parses a whole TPTP file given as scala.io.Source.
Parses a whole TPTP file given as scala.io.Source.
- input
The TPTP problem file.
- returns
The parsing result as a leo.datastructures.TPTP.Problem object.
- Exceptions thrown
TPTPParseException
If an parsing error occurred.
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- final def tcf(formula: String): Formula
Parses a plain TCF formula (i.e., without annotations) given as String.
Parses a plain TCF formula (i.e., without annotations) given as String.
- formula
The annotated formula as string.
- returns
The parsing resultas TCFFormula object
- Exceptions thrown
TPTPParseException
If an parsing error occurred.
- final def tff(formula: String, tfx: Boolean = true): Formula
Parses a plain TFF formula (i.e., without annotations) given as String.
Parses a plain TFF formula (i.e., without annotations) given as String.
- formula
The annotated formula as string.
- tfx
If set to
true
, accept TFX formulas as well (default); otherwise exclude TFX inputs.- returns
The parsing resultas TFFFormula object
- Exceptions thrown
TPTPParseException
If an parsing error occurred.
- final def thf(formula: String): Formula
Parses a plain THF formula (i.e., without annotations) given as String.
Parses a plain THF formula (i.e., without annotations) given as String.
- formula
The annotated formula as string.
- returns
The parsing result as THFFormula object
- Exceptions thrown
TPTPParseException
If an parsing error occurred.
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- object TPTPLexer
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
This is the documentation for the Scala TPTP parser used, e.g., by the Leo-III prover.
Package structure
The leo package contains two sub-packages as follows:
leo.datastructures
contains the leo.datastructures.TPTP object that bundles the different abstract syntax tree (AST) representations for the different TPTP language dialects, including ...leo.datastructures.TPTP.THF
- Higher-order formulas (THF)leo.datastructures.TPTP.TFF
- Typed first-order formulas (TFF)leo.datastructures.TPTP.FOF
- Untyped first-order formulas (FOF)leo.datastructures.TPTP.TCF
- Typed clausal form (TCF)leo.datastructures.TPTP.CNF
- Untyped clausal form (CNF)leo.modules.input
- the parser itself.Usage (in short)
The leo.modules.input.TPTPParser offers several parsing methods:
Exemplary use case