OxiRS Rule Engine
Status: Production Release (v0.1.0) - Released January 7, 2026
⨠Production Release: Production-ready with API stability guarantees and comprehensive testing.
A high-performance, comprehensive reasoning engine for Semantic Web applications, implementing forward chaining, backward chaining, RETE networks, RDFS, OWL RL, and SWRL rule processing.
Features
š Core Reasoning Engines
- Forward Chaining - Efficient data-driven inference with pattern matching and built-in predicates
- Backward Chaining - Goal-driven proof search with cycle detection and caching
- RETE Network - High-performance pattern matching for real-time rule execution
šÆ Standards Compliance
- RDFS Reasoning - Complete RDFS entailment rules (rdfs2, rdfs3, rdfs5, rdfs7, rdfs9, rdfs11)
- OWL RL Support - Class/property equivalence, characteristics, identity reasoning
- SWRL Integration - Semantic Web Rule Language with extensive built-in predicates
ā” Performance Features
- Incremental Updates - Efficient handling of dynamic knowledge base changes
- Pattern Indexing - Optimized rule and fact lookup with caching
- Memory Optimization - Efficient data structures for large-scale reasoning
- Statistics & Monitoring - Comprehensive performance metrics and tracing
Installation
Add to your Cargo.toml:
# Experimental feature
[]
= "0.1.0"
Quick Start
use *;
// Create a new rule engine
let mut engine = new;
// Add facts
engine.add_fact;
// Add rules
engine.add_rule;
// Perform forward chaining inference
let stats = engine.forward_chain?;
println!;
// Query the knowledge base
let results = engine.query?;
for result in results
Architecture
Core Components
RuleEngine- Main interface unifying all reasoning strategiesForwardChainEngine- Data-driven inference with fixpoint calculationBackwardChainEngine- Goal-driven proof search with memoizationReteNetwork- High-performance pattern matching networkRdfsReasoner- RDFS schema reasoning and entailmentOwlReasoner- OWL RL profile reasoningSwrlEngine- SWRL rule processing with built-in functions
Data Structures
// Core data types
Reasoning Strategies
Forward Chaining
Ideal for:
- Batch processing of large datasets
- Materializing all possible inferences
- Data integration and ETL processes
let stats = engine.forward_chain?;
println!;
println!;
Backward Chaining
Ideal for:
- Query-driven reasoning
- Interactive applications
- Proof explanation and validation
let goal = atom!;
let proofs = engine.backward_chain?;
for proof in proofs
RETE Network
Ideal for:
- Real-time rule processing
- Incremental updates
- High-throughput applications
let mut rete = new;
rete.add_rule;
rete.add_fact;
let results = rete.execute?;
Built-in Predicates
Comparison Operations
equal(?x, ?y)- Equality testingnotEqual(?x, ?y)- Inequality testinglessThan(?x, ?y)- Numeric comparisongreaterThan(?x, ?y)- Numeric comparison
Mathematical Operations
add(?x, ?y, ?result)- Additionsubtract(?x, ?y, ?result)- Subtractionmultiply(?x, ?y, ?result)- Multiplication
String Operations
stringConcat(?s1, ?s2, ?result)- String concatenationstringLength(?string, ?length)- String length
Utility Predicates
bound(?var)- Variable binding checkunbound(?var)- Variable unbound check
RDFS Reasoning
Automatic inference of:
- Class hierarchies (
rdfs:subClassOf) - Property hierarchies (
rdfs:subPropertyOf) - Domain and range constraints (
rdfs:domain,rdfs:range) - Type membership (
rdf:type)
let mut rdfs = new;
rdfs.add_schema_triple;
rdfs.add_data_triple;
let inferred = rdfs.materialize?;
// Automatically infers: alice rdf:type Agent
OWL RL Reasoning
Support for:
- Property characteristics (functional, transitive, symmetric)
- Class equivalence and disjointness
- Individual identity (
owl:sameAs,owl:differentFrom) - Basic property restrictions
let mut owl = new;
owl.add_axiom;
owl.add_fact;
owl.add_fact;
let inferred = owl.reason?;
// Automatically infers: alice hasParent charlie
SWRL Rules
Support for complex rule definitions:
// Person(?p) ā§ hasAge(?p, ?age) ā§ greaterThan(?age, 18) ā Adult(?p)
let swrl_rule = SwrlRule ;
Performance Characteristics
Scalability
- Forward Chaining: O(n³) worst case, optimized for sparse rules
- Backward Chaining: O(2^n) worst case, pruned with cycle detection
- RETE Network: O(1) for fact insertion, O(n) for rule addition
Memory Usage
- Efficient fact storage with deduplication
- Rule indexing for fast pattern matching
- Configurable caching strategies
Benchmarks
- 1M+ triples: <60 seconds for full materialization
- 10K+ rules: <10 seconds for compilation
- Memory usage: <8GB for 1M triple datasets
Integration
With oxirs-core
use ;
use RuleEngine;
let mut engine = new;
// Convert oxirs-core triples to rule facts
engine.add_triple?;
With SPARQL
// Use reasoning results in SPARQL queries
let inferred_facts = engine.get_materialized_facts;
// Add to SPARQL dataset for querying
Testing
Run the comprehensive test suite:
# Run all tests
# Run specific reasoning tests
# Run performance benchmarks
Test Coverage
- 722/722 tests passing (100% success rate)
- Unit tests for all reasoning algorithms
- Integration tests with real-world datasets
- Performance regression tests
Configuration
use EngineConfig;
let config = EngineConfig ;
let engine = with_config;
Error Handling
Comprehensive error types with detailed context:
use RuleEngineError;
match engine.forward_chain
Logging and Monitoring
Built-in tracing support:
use ;
// Enable tracing
init;
// Reasoning operations automatically logged
let stats = engine.forward_chain?;
// Logs: "Forward chaining completed: 1000 facts derived, 50 rules fired"
Contributing
- Follow Rust 2021 edition best practices
- Maintain >95% test coverage
- Use
cargo clippyandcargo fmt - Add comprehensive documentation
- Include performance benchmarks
License
Licensed under the Apache License, Version 2.0 or the MIT License, at your option.
Status
š Production Release (v0.1.0) ā January 7, 2026
Highlights:
- ā Forward/backward chaining over persisted datasets with automatic inference snapshots
- ā RETE network optimized with SciRS2 metrics and tracing hooks
- ā Integrated with federation-aware SPARQL workflows for rule-driven post-processing
- ā 722/722 tests passing plus CLI end-to-end coverage
- š§ Advanced distributed reasoning (planned for future release)