{"library":"owlrl","title":"OWL-RL","description":"OWL-RL is a Python library that provides a simple implementation of the OWL2 RL Profile, as well as basic RDFS inference, on top of RDFLib. It performs mechanical forward chaining to compute the deductive closure of RDF graphs. The current version is 7.1.4, and it is actively maintained with a focus on semantic web inference capabilities.","language":"python","status":"active","last_verified":"Sun May 17","install":{"commands":["pip install owlrl"],"cli":null},"imports":["from owlrl import DeductiveClosure","from owlrl import RDFS_Semantics","from owlrl import OWLRL_Semantics","from rdflib import Graph"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"from rdflib import Graph, Literal, Namespace, RDF, RDFS\nfrom owlrl import DeductiveClosure, OWLRL_Semantics\n\n# Define a simple namespace for demonstration\nex = Namespace(\"http://example.org/ontology#\")\n\n# Create an RDFLib graph\ngraph = Graph()\ngraph.bind(\"ex\", ex)\n\n# Add some initial triples (asserted facts)\ngraph.add((ex.Person, RDF.type, RDFS.Class))\ngraph.add((ex.Student, RDFS.subClassOf, ex.Person))\ngraph.add((ex.John, RDF.type, ex.Student))\n\n# Add a rule that says if someone is a Person, they are also an Agent\ngraph.add((ex.Agent, RDF.type, RDFS.Class))\ngraph.add((ex.Person, RDFS.subClassOf, ex.Agent))\n\nprint(f\"Graph size before OWL RL expansion: {len(graph)}\")\n\n# Initialize and run the OWL 2 RL deductive closure\nclosure = DeductiveClosure(OWLRL_Semantics)\nclosure.expand(graph)\n\n# The graph now contains inferred triples, e.g., John is a Person, and also an Agent\nprint(f\"Graph size after OWL RL expansion: {len(graph)}\")\n\n# Check for an inferred triple\nif (ex.John, RDF.type, ex.Agent) in graph:\n    print(\"Inferred: John is an Agent.\")\n\n# You can also run RDFS inference separately\nrdfs_graph = Graph()\nrdfs_graph.bind(\"ex\", ex)\nrdfs_graph.add((ex.Teacher, RDFS.subClassOf, ex.Person))\nrdfs_graph.add((ex.Jane, RDF.type, ex.Teacher))\n\nprint(f\"\\nGraph size before RDFS expansion: {len(rdfs_graph)}\")\nfrom owlrl import RDFS_Semantics\nrdfs_closure = DeductiveClosure(RDFS_Semantics)\nrdfs_closure.expand(rdfs_graph)\nprint(f\"Graph size after RDFS expansion: {len(rdfs_graph)}\")\nif (ex.Jane, RDF.type, ex.Person) in rdfs_graph:\n    print(\"Inferred: Jane is a Person.\")","lang":"python","description":"This quickstart demonstrates how to create an RDFLib graph, populate it with some triples, and then use `owlrl.DeductiveClosure` with `OWLRL_Semantics` or `RDFS_Semantics` to infer new triples based on the respective OWL 2 RL or RDFS rules. The `expand` method modifies the graph in place, adding all possible derived triples. It shows how to check for an inferred triple after expansion.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-17","installed_version":"7.1.4","pypi_latest":"7.1.4","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":2,"avg_import_s":0.38,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"owlrl","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.33,"mem_mb":10.8,"disk_size":"23.5M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"owlrl","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2,"import_time_s":0.24,"mem_mb":10.8,"disk_size":"24M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"owlrl","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.5,"mem_mb":11.7,"disk_size":"26.3M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"owlrl","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.9,"import_time_s":0.44,"mem_mb":11.7,"disk_size":"27M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"owlrl","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.44,"mem_mb":11.7,"disk_size":"17.9M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"owlrl","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.8,"import_time_s":0.45,"mem_mb":11.7,"disk_size":"18M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"owlrl","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.43,"mem_mb":11.8,"disk_size":"17.7M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"owlrl","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.9,"import_time_s":0.43,"mem_mb":11.8,"disk_size":"18M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"owlrl","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.28,"mem_mb":10.6,"disk_size":"23.0M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"owlrl","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.2,"import_time_s":0.25,"mem_mb":10.6,"disk_size":"24M"}]}}