{"id":28213516,"url":"https://github.com/solidlabresearch/rspql-containment-checker","last_synced_at":"2026-02-15T22:04:39.604Z","repository":{"id":285390895,"uuid":"957966079","full_name":"SolidLabResearch/rspql-containment-checker","owner":"SolidLabResearch","description":"Extending the SPeCS solver to determine query containment relation in between RSP-QL queries.","archived":false,"fork":false,"pushed_at":"2025-06-11T11:26:49.000Z","size":879,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-11T12:22:42.053Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"SMT","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SolidLabResearch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-31T12:28:20.000Z","updated_at":"2025-06-11T11:26:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"82cf8c8e-5317-456e-a3e1-cd936b7050fb","html_url":"https://github.com/SolidLabResearch/rspql-containment-checker","commit_stats":null,"previous_names":["solidlabresearch/rspql-containment-checker"],"tags_count":2,"template":false,"template_full_name":"argahsuknesib/TS-Template","purl":"pkg:github/SolidLabResearch/rspql-containment-checker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SolidLabResearch%2Frspql-containment-checker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SolidLabResearch%2Frspql-containment-checker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SolidLabResearch%2Frspql-containment-checker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SolidLabResearch%2Frspql-containment-checker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SolidLabResearch","download_url":"https://codeload.github.com/SolidLabResearch/rspql-containment-checker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SolidLabResearch%2Frspql-containment-checker/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259308154,"owners_count":22837974,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-17T20:10:47.357Z","updated_at":"2025-10-10T19:38:10.915Z","avatar_url":"https://github.com/SolidLabResearch.png","language":"SMT","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RSPQL Containment Checker\n\nThe RSPQL Containment Checker is a tool that extends the [SPeCS](https://github.com/mirkospasic/SpeCS) SPARQL Containment solver to check containment between two RSP-QL queries. The RSP-QL queries are translated to SPARQL queries, along with their streaming semantics, and then the containment is checked using the SPeCS tool for the SPARQL queries. The streaming semantics are utilized to determine if the RSP-QL queries are on the same data source and if they are compatible for containment checking.\n\nOnce the compatibility is established, the containment checking is performed using the SPeCS tool. \n\nThe RSP-QL containment checker is presented as a HTTP service that can be accessed via a REST API. The server accepts RSP-QL queries and returns the containment result. The RSP-QL containment checker is implemented with Typescript and Node.js. \n\n# Prerequisites\nTo run the RSPQL Containment Checker, you need to have the following software installed on your machine:\n- [Node.js](https://nodejs.org/en/) (v20.0.0 or higher)\n- [npm](https://www.npmjs.com/) (v9.0.0 or higher)\n- [Z3 Solver](https://github.com/Z3Prover/z3) needs to be installed as well to execute the tool.\n\n# Usage\n\nThe RSPQL containment checker can be utilized as a NPM package or as a standalone tool. It is designed to be used in a Node.js environment, and it can be integrated into other applications or used as a command-line tool.\n\nTo use the RSPQL Containment Checker as a NPM package, you can install it using the following command:\n```bash\nnpm install rspql-containment-checker\n```\nYou can then import the package in your Node.js application and use it to check the containment of RSP-QL queries. Here is an example of how to use the package:\n\n```ts\nimport { ContainmentChecker } from \"rspql-containment-checker\";\n\nasync function checkContainment(subquery: string, superquery: string) {\n    const checker = new ContainmentChecker();\n    try {\n        const result = await checker.checkContainment(subquery, superquery);\n        console.log(`Containment result: ${result.containment}`);\n    } catch (error) {\n        console.error(`Error checking containment: ${error.message}`);\n    }\n}\n\n// Example usage\nlet subquery = `PREFIX ex: \u003chttp://example.org/\u003e\nREGISTER RStream \u003coutput\u003e AS\nSELECT (COUNT(?x) AS ?count)\nFROM NAMED WINDOW ex:w1 ON STREAM ex:stream1 [RANGE 10 STEP 5]\nWHERE {\n    WINDOW ex:w1 { ?x a ex:Person. }\n}`;\n\nlet superquery = `PREFIX ex: \u003chttp://example.org/\u003e\nREGISTER RStream \u003coutput\u003e AS\nSELECT (COUNT(?x) AS ?count)\nFROM NAMED WINDOW ex:w1 ON STREAM ex:stream1 [RANGE 10 STEP 5]\nWHERE {\n  WINDOW ex:w1 { \n    ?x a ex:Person.\n    ?x ex:hasAge ex:One.\n  }\n}`;\n\n\nconsole.log(checkContainment(subquery, superquery));\n// Output: Containment result: true\n```\n\nwhere `subquery` and `superquery` are the RSP-QL queries you want to check for containment. The `checkContainment` method will return a boolean value indicating whether the `subquery` is contained in the `superquery`.\n\n# Using as a Standalone Tool \n\nTo install the RSPQL Containment Checker, follow these steps:\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/SolidLabResearch/rspql-containment-checker.git\n   ```\n\n2. Install the relevant dependencies:\n   ```bash\n   npm install\n   ```\n3. Build the project:\n   ```bash\n   npm run build\n   ```\n4. Start the containment checker tool with\n   ```bash\n   npm run start containment-checker\n   ```\nThis will start the RSPQL Containment Checker server on `http://localhost:8085`. You can change the port in the `src/index.ts` file.\n\nThe RSPQL containment checker is implemented as a REST API. You can use any HTTP client to send requests to the server. The server accepts RSP-QL queries and returns the containment result in JSON format.\n\n# API Endpoints\n\nThe RSPQL Containment Checker provides the following API endpoints:\n- `POST /containment`: This endpoint checks the containment of two RSP-QL queries. The request body should contain the following JSON object:\n```json\n{\n  \"subquery\": \"\u003cRSP-QL query 1\u003e\",\n  \"superquery\": \"\u003cRSP-QL query 2\u003e\"\n}\n```\nThe response will contain the containment result in the following format:\n```json\n{\n  \"containment\": \"\u003cboolean value of true | false\u003e\",\n}\n```\n\n# Example Usage\n\nWhen the containment checker is up and running,\n\nFor the two RSP-QL queries:\n```sparql\nPREFIX ex: \u003chttp://example.org/\u003e\nREGISTER RStream \u003coutput\u003e AS\nSELECT (COUNT(?x) AS ?count)\nFROM NAMED WINDOW ex:w1 ON STREAM ex:stream1 [RANGE 10 STEP 5]\nWHERE {\n    WINDOW ex:w1 { ?x a ex:Person. }\n}\n```\nand\n\n```sparql\nPREFIX ex: \u003chttp://example.org/\u003e\nREGISTER RStream \u003coutput\u003e AS\nSELECT (COUNT(?x) AS ?count)\nFROM NAMED WINDOW ex:w1 ON STREAM ex:stream1 [RANGE 10 STEP 5]\nWHERE {\n  WINDOW ex:w1 { \n    ?x a ex:Person.\n    ?x ex:hasAge ex:One.\n  }\n}\n```\nYou can check the containment between the queries by doing a POST request to the `/containment` endpoint with the following example of JSON:\n```json\n{\n  \"subquery\": \"PREFIX ex: \u003chttp://example.org/\u003e\\nREGISTER RStream \u003coutput\u003e AS\\nSELECT (COUNT(?x) AS ?count)\\nFROM NAMED WINDOW ex:w1 ON STREAM ex:stream1 [RANGE 10 STEP 5]\\nWHERE {\\n    WINDOW ex:w1 { ?x a ex:Person. }\\n}\",\n  \"superquery\": \"PREFIX ex: \u003chttp://example.org/\u003e\\nREGISTER RStream \u003coutput\u003e AS\\nSELECT (COUNT(?x) AS ?count)\\nFROM NAMED WINDOW ex:w1 ON STREAM ex:stream1 [RANGE 10 STEP 5]\\nWHERE {\\n  WINDOW ex:w1 { \\n    ?x a ex:Person.\\n    ?x ex:hasAge ex:One.\\n  }\\n}\"\n}\n```\n\nThe server will respond with the containment result:\n```json\n{\n  \"containment\": true\n}\n```\nThis indicates that the first query is contained in the second query.\n\n# Isomorphism Check\n\nThe RSPQL Containment Checker also provides an isomorphism check for the two queries. Isomorphism relation is basically double containment on the both sides.\nThe isomorphism check can also be performed using the  `POST /containment` endpoint. The request body should contain the following JSON object:\n```json\n{\n  \"query1\": \"\u003cRSP-QL query 1\u003e\",\n  \"query2\": \"\u003cRSP-QL query 2\u003e\"\n}\n```\n\nThe response will contain the isomorphism result in the following format:\n```json\n{\n  \"isomorphism\": \"\u003cboolean value of true | false\u003e\",\n}\n```\n\nWe utilize the [RSPQL Query Isomorphism](https://github.com/SolidLabResearch/rspql-query-isomorphism) tool to check the isomorphism.\nSince the isomorphism relation is cheaper to compute than the containment relation, we first check for isomorphism before checking for containment. In case the two queries are isomorphic, we return the result as `true` without checking for containment.\nIf the two queries are not isomorphic, we check for containment and return the result as `false` if the containment check fails and `true` if the containment check passes.\n\n# License\nThe code is licensed under the GPL-3.0 License. See the [LICENSE](LICENSE) file for details.\n\n# Acknowledgements\nWe would like to thank the authors of the [SPeCS](https://github.com/mirkospasic/SpeCS) tool for their work on SPARQL containment checking. The RSPQL Containment Checker builds upon their work and extends it to support RSP-QL queries. \n\n# Contact\nFor any questions regarding the repository, please contact [Kush](mailto:kushbisen@proton.me) or open an issue on the repository.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolidlabresearch%2Frspql-containment-checker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsolidlabresearch%2Frspql-containment-checker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolidlabresearch%2Frspql-containment-checker/lists"}