This GitHub repository contains source code to compare two legal reasoners on Resource Description Framework (RDF) data. The first legal reasoner is based on the Shapes Constraint Language (SHACL), the second one is based on the DLV2 automated reasoner for ASP-Core-2.
Specifically, a selected use case of legal norms is formalized both in SHACL and ASP-Core-2 formulae. Then, the formulae are executed through the corresponding reasoner on synthetic states of affairs of increasing size encoded in RDF. The execution checks compliance of the states of affairs with respect to the legal norms.
This GitHub repository includes source code and instructions to execute the reasoners both when the states of affairs are stored within RDF files and when they are stored within a Apache Jena Fuseki SPARQL endpoint. The implementations detect the violations of the legal norms and store them within an output file, together with the measured execution time.
The use case includes the following four articles:
- Article 1. The Licensor grants the Licensee a licence to evaluate the Product.
- Article 2. The Licensee must not publish the results of the evaluation of the Product without the approval of the Licensor. If the Licensee publishes results of the evaluation of the Product without approval from the Licensor, the material must be removed.
- Article 3. The Licensee must not publish comments about the evaluation of the Product, unless the Licensee is permitted to publish the results of the evaluation.
- Article 4. If the Licensee is commissioned to perform an independent evaluation of the Product, then the Licensee has the obligation to publish the evaluation results.
The two implementations are available at the links below:
- Source code and instructions for the SHACL implementation are available at this link.
- Executables and instructions for the DLV2 implementation are available at this link.
The implementations have been tested on the synthetic (ABox) datasets available in the subfolder CORPUS. Further corpora may be created via the dataset generator available at this link.
The fuseki server, configured to upload the files in CORPUS and make them available as a SPARQL endpoint on localhost, is available in the subfolder FUSEKI.
Experiments have been executed on a Linux machine running Ubuntu 22.04.1 LTS equipped with Intel® Core™ i7-9750H CPU and 32GB of RAM.
Experiments can be also replicated using Ubuntu Bash on a Windows machine or a standard terminal on MacOS. The Ubuntu Bash for Windows can be downloaded from the Windows Store at this link.
In order to run all the experiments the following steps must be performed
- Open a terminal or the Ubuntu Bash
- Install the
Java JDK
and theJava JRE
- Install the
rdflib
and theSPARQLWrapper
Python3 modules necessary to runDLV2
with SPARQL support - Move inside the experiments root folder
- On Linux:
cd path/to/compliancecheckingOnRDF
- On Windows (if the folder is located on your Desktop):
cd /mnt/c/Users/<YOUR_WINDOWS_USERNAME>/Desktop/compliancecheckingOnRDF
- On Linux:
- Run the experiments executing the following commands one by one
sh runFuseki_DLV2_SHACL.sh dlv2 2>/dev/null
sh runFuseki_DLV2_SHACL.sh shacl 2>/dev/null
sh runLocal_DLV2_SHACL.sh dlv2 2>/dev/null
sh runLocal_DLV2_SHACL.sh shacl 2>/dev/null
- ALTERNATIVELY, all the experiments can be executed running the following command
- To print the results on
stdout
executesh runAll.sh
- To print the results on a
csv
file calledresults_all.csv
executesh runAll.sh > results_all.csv
- To print the results on
sudo apt update
sudo apt install default-jdk
sudo apt install default-jre
sudo pip3 install rdflib SPARQLWrapper