rs2fol is a reasoning tool that transforms RDF surfaces into first-order logic (FOL) and performs entailment checking using external theorem provers, following the informal semantics of the RDF Surface primer.
The repository contains test cases that were directly taken from the RDF Surfaces Community Group and can be found at the GitHub repository RDF Surfaces tests.
- Translates RDF surfaces into TPTP annotated first-order formulas
- Satisfiability checking using FOL provers
- Consequence checking using FOL provers
- Supports D-entailment (by canonicalisation of literals (lexical values & datatypes)) and simple entailment
- Provides experimental support for the negative answer surface using FOL answer extraction
Every release contains executables of the project for
- Windows
- MacOS
- Linux
You can find these executables in the release section.
To build the project from source, you need to follow these steps:
git clone https://github.com/RebekkaMa/rs2fol.git
cd rs2fol
makeThe CLI executable will be in bin/:
./bin/rs2fol --helpFor subcommands like check and transform-qa, an external FOL theorem prover must be installed.
- TPTP format support as input
- SZS Ontology support as output
- For
transform-qa: Answer extraction support using SZS Ontology together with the tuple answer form
I recommend Vampire, built from the qa branch to support answer extraction (transform-qa). eprover was also tested together with rs2fol and supports answer extraction as well.
Create a config.json to configure executable paths and options:
{
"programs": {
"vampire": {
"exe": "path/to/vampire",
"options": [
{
"optionId": 0,
"flags": ["-t", "${timeLimit}s"]
},
{
"optionId": 1,
"flags": ["--mode", "casc", "--cores", "0", "-t", "${timeLimit}s"]
}
]
},
"eprover": {
"exe": "/path/to/eprover",
"options": [
{
"optionId": 0,
"flags": ["--soft-cpu-limit=${timeLimit}"]
}
]
}
}
}An example configuration file with settings that yielded the best results during internal evaluations of rs2fol can be found here: exampleConfig.json.
This subcommand transforms the RDF surface (--input, -i) into a TPTP annotated first-order formula <fof_annotated> of type axiom.
./bin/rs2fol transform -i path/to/rdfSurface.n3sThis subcommand parses an RDF surface (--input, -i) and rewrites it into a more readable and standardized format. It can be useful for debugging purposes or for canonicalizing literals (when using --d-entailment).
./bin/rs2fol rewrite -i path/to/rdfSurface.n3sThis subcommand performs the following steps:
- Transforms the given RDF surface (
--input,-i) into a TPTP annotated first-order formula<fof_annotated>of typeaxiom, excluding any query or negative answer surfaces on the default surface. Nested query/negative answer surfaces will be interpreted as negative surfaces. - Transforms the consequence RDF surface (
--consequence,-c) into a TPTP annotated formula of typeconjecture - Combines the
conjectureand theaxiom - Starts a theorem prover process and passes the result of step 3 for entailment checking
- Receives and interprets the output of the theorem prover
Possible results:
- consequence → the consequence follows from the RDF surface
- no consequence → the consequence does not follow
- contradiction → the axioms are unsatisfiable
- timeout → the time limit was exceeded
./bin/rs2fol check -i path/to/antecedent.n3s -c path/to/consequence.n3s --program vampire --option-id 0 --config /path/to/config.json./bin/rs2fol check -i path/to/antecedent.n3s -c path/to/consequence.n3s --program vampire --option-id 0 --config /path/to/config.json --d-entailmentThis subcommand performs the following steps:
- Transforms the RDF surface (
--input,-i) into a TPTP annotated first-order formula<fof_annotated>of typeaxiom, excluding any query or negative answer surfaces on the default surface. Nested query/negative answer surfaces will be interpreted as negative surfaces. - Starts a theorem prover process and passes the
axiomfor satisfiability checking - Receives and interprets the output of the theorem prover
Possible results:
- satisfiable → the RDF surface is satisfiable
- unsatisfiable → the RDF surface is not satisfiable
- timeout → the time limit was exceeded
./bin/rs2fol check -i path/to/antecedent.n3s --program vampire --option-id 0 --config /path/to/config.jsonBecause no consequence surface is provided, this checks the satisfiability of the input RDF surface.
Simulates the behavior of the negative answer surface. Only supported on the default surface, not nested ones.
Steps:
- Transforms the RDF surface (
--input,-i) into a TPTP annotated first-order formula<fof_annotated>of typeaxiom, excluding any query or negative answer surfaces on the default surface. Nested query/negative answer surfaces will be interpreted as negative surfaces. - transforms the query/negative answer surface into a TPTP annotated first order formula <fof_annotated> of type question
- starts a theorem prover process and passes both first order formula for answer extraction
- receives the output triples of the theorem prover process
- transforms the output triples (in tuple answer form) into an RDF surface using the query/negative answer surface within the input RDF surface
./bin/rs2fol transform-qa --program vampire-qa --option-id 2 -t 5 -i path/to/surface.n3s --config /path/to/config.jsonLack of results does not imply lack of answers. Poor prover configuration can lead to missing or partial answers. Best results were obtained using Vampire with --mode casc. This mode usually does not terminate, so setting a timeout (e.g., 5s) is recommended. See the sample config.json.
This subcommand transforms a FOL question answering result into an RDF surface by replacing all blank nodes that are coreferences to the blank node graffiti defined on the given query surface.
rs2fol currently supports only the 'Tuple Answer Form' specified in https://www.tptp.org/TPTP/Proposals/AnswerExtraction.html.
Following input types are possible:
--input-type raw- accepts only one answer tuple list
- Examples
[['http://example.com/abc','"123"^^http://www.w3.org/2001/XMLSchema#string'],['http://example.com/abc','"123"^^http://www.w3.org/2001/XMLSchema#string']|_][[list('http://example.com/abc',list('http://example.com/abc','http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'))]]
--input-type szs- accepts multiline input, extracts the answer tuple list from all lines containing 'SZS answers Tuple' and combines the results (this is especially useful for the combined use of Vampire's cascade mode)
- Examples
% SZS answers Tuple [['http://example.com/abc','"123"^^http://www.w3.org/2001/XMLSchema#string'],['http://example.com/abc','"123"^^http://www.w3.org/2001/XMLSchema#string']|_] for ANS001+1% SZS answers Tuple [[list('http://example.com/abc',list('http://example.com/abc','http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'))]] for ANS001+1
All variables/blank nodes should be interpreted as universally quantified variables. Skolem functions (sK) are also transformed into variables, but these variables should be interpreted as existentially quantified variables. This way of quantification of all these variables is not implemented yet. They appear to be existentially quantified.
Only the following structure types of answer elements are supported:
- Literals
'"123"^^http://www.w3.org/2001/XMLSchema#integer''"cat"@en'
- Skolem functions
sKsK2('http://example.com/abc','http://example.com/efg')
- IRIs
'http://example.com/abc'
- Collections
'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'list('http://example.com/abc',list('http://example.com/efg', list('http://example.com/abc',list('http://example.com/b','http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'))))
- Blank Nodes / Variables
BN_1Var
The TPTP syntax allows only a limited set of characters for the representation of variables and constants. Therefore, characters that are not allowed are encoded during transformation into a FOL formula. Since the choice of allowed characters is tiny, two different encoding types are used, which, for lack of options, are not standardized. However, both encodings use the UTF-16 encoding of a character. UTF-32 codepoints that go beyond this range are represented as usual with two UTF-16 characters (high surrogate, low surrogate).
\u####– UTF-16 hex codeOx####– same, withO(not0) prefix
The encoding can be deactivated by using the --no-enc option. This is useful for debugging purposes, but the output may not be valid TPTP syntax.
The project follows the principles of Clean Architecture as proposed by Robert C. Martin.