IMP-logics is the implementation of:
- the metamodel of a Datalog schema extended with negation and built-in literals. That is, it implements the Datalog concepts of term, atom, literal, derivation rule, etc. In addition, the schema also includes logic constraints written in the form of logic denials.
- the metamodel of dependencies (e.g. tuple-generating dependencies), which is useful for implementing a * Datalog+/- schema*. That is, it implements the concepts of TGDs and EGDs.
E.g., with this library you can parse the following (datalog) logic schema:
% This rule says that d is a DeptWithEmploye if there is one employee e, working in d with a salary greather than 1000
DeptWithEmploye(d) :- Emp(e, d, s), s > 1000
% This other rule is a logic denial stating that there cannot be Dept d that is not a DeptWithEmploye
:- Dept(d), not(DeptWithEmploye(d))
This library is not a datalog interpreter. Hence, it does not implement the notion of fact, or the process to run a query.
IMP-logics can be used to parse, transform, or analyze a datalog (dependency) schema, that is, the normal clauses ( dependencies) that conforms a datalog (datalog+/-) program.
For instance, you can parse a datalog schema, and check whether it is safe.
LogicSchema logicSchema = new LogicSchemaWithoutIDsParser().parse(schemaString);
logicSchema.isSafe();
Or you can traverse their derivation rules, logc constraints, or predicates:
LogicSchema logicSchema = new LogicSchemaWithoutIDsParser().parse(schemaString);
for(DerivationRule rule: logicSchema.getAllDerivationRules){
...
}
for(LogicConstraint constraint: logicSchema.getAllLogicConstraints){
...
}
for(Predicate predicate: logicSchema.getAllPredicates){
...
}
You can see more examples in docs\USERS_GUIDE.md file.
To compile the project for the first time, or whenever we change the grammar files, we need to execute
the mvn generate-sources
phase.
Indeed, this phase creates the ANTLR4 autogenerated classes to visit the grammar. Hence, we recommend compiling the
project with maven.
This library is implemented by the IMP research group (https://imp.upc.edu/en), and the innovation lab group inLab-FIB (https://inlab.fib.upc.edu/en/), both from Universitat Politècnica de Catalunya - BarcelonaTech (https://www.upc.edu/en)