SPARQL as the rules language - forward and backward chaining inference
5 N3 RulesFuXi uses SPARQL Graph Patterns as the antecedent (body) of Horn rules in N3 format. The => operator concludes the consequent (head). Each rule shows:
If Person has age >= 18, infer Adult category
FuXi Logic (N3):
→ Generated SPARQL:
If Person has age < 18, infer Minor category
FuXi Logic (N3):
→ Generated SPARQL:
Two persons within 5 years share age group
FuXi Logic (N3):
→ Generated SPARQL:
If Person has age >= 65, infer Senior category
FuXi Logic (N3):
→ Generated SPARQL:
FuXi Logic (N3 consequent → CONSTRUCT template):
→ Generated SPARQL CONSTRUCT:
Execute all N3 rules against fact graph, derive all inferred facts
fuxi.core facts.n3Answer specific query, generate proof graph
fuxi.proof --why='ASK { eg:bob ex:isBrotherOf eg:joe }' facts.n3Validate ontology, perform OWL entailment
fuxi.owl --dlp --method=bfp ontology.ttlCreate your base RDF triples in Turtle format:
Define Horn logic rules with SPARQL patterns:
Use RETE algorithm for exhaustive inference:
Use BFP for targeted queries:
How this FuXi demo was created from scratch:
Write Turtle file with sample persons, properties, and values
Upload Turtle to Virtuoso via SPARQL UPDATE or DAV
http://example.org/fuxi-demoSELECT COUNT(*) FROM <fuxi-demo> { ?s ?p ?o }Run SELECT, CONSTRUCT, DESCRIBE queries to verify data
Create schema:Article with hasPart sections
Transform RDF to interactive HTML with CSS styling
Generate .md file summarizing rules and test results
FuXi Logic (N3):
Translates to SPARQL:
FuXi Logic (N3):
Translates to SPARQL:
FuXi Logic (N3):
Translates to SPARQL:
FuXi Logic (N3):
Translates to SPARQL:
FuXi Logic (N3 consequent):
Translates to SPARQL CONSTRUCT:
FuXi uses SPARQL Graph Patterns as the antecedent (body) of Horn rules in N3 format. The rule { ?s ex:parentOf ?o } => { ?s ex:relatedTo ?o } uses SPARQL WHERE clause syntax to match triples in the fact graph, then infers the conclusion triple. This makes SPARQL both the query language AND the rules language.
Forward chaining (bottom-up) uses the RETE algorithm to exhaustively apply N3 rules against the fact graph. Starting with base facts, it repeatedly applies rules until no new facts can be derived. Command: fuxi.core facts.n3
Backward chaining (top-down) uses BFP (Breadth-First Proof) to answer queries by finding proofs without deriving all possible facts. More efficient for targeted queries. Command: fuxi.proof --why='SPARQL query' facts.n3