Implements a backward-chaining reasoner with Euler path detection based on the Euler library by Jos de Roo.
This class is based on the JavaScript version of the Euler library at http://www.agfa.com/w3c/euler/.
This class is an instance of the SemWeb.Inference.Reasoner class. To use a Reasoner, you add it to a Store with SemWeb.Store.AddReasoner(Reasoner). Subsequently, calls to Select and Query on the Store will be processed by the reasoner, and so will provide the entailments given by the reasoner directly.
The following example shows how to use this class to reason about transitive relations.
C# Example // This example demonstrates general reasoning with // the Euler engine based on Jos De Roo's Euler proof // mechanism. The example is based on the "graph" // example from Euler. using System; using System.IO; using SemWeb; using SemWeb.Inference; public class EulerTest { public static void Main() { // Create the instance data MemoryStore dataModel = new MemoryStore(); BNode paris = new BNode("paris"); BNode orleans = new BNode("orleans"); BNode chartres = new BNode("chartres"); BNode amiens = new BNode("amiens"); BNode blois = new BNode("blois"); BNode bourges = new BNode("bourges"); BNode tours = new BNode("tours"); BNode lemans = new BNode("lemans"); BNode angers = new BNode("angers"); BNode nantes = new BNode("nantes"); Entity oneway = new Entity("http://www.agfa.com/w3c/euler/graph.axiom#oneway"); Entity path = new Entity("http://www.agfa.com/w3c/euler/graph.axiom#path"); dataModel.Add(new Statement(paris, oneway, orleans)); dataModel.Add(new Statement(paris, oneway, chartres)); dataModel.Add(new Statement(paris, oneway, amiens)); dataModel.Add(new Statement(orleans, oneway, blois)); dataModel.Add(new Statement(orleans, oneway, bourges)); dataModel.Add(new Statement(blois, oneway, tours)); dataModel.Add(new Statement(chartres, oneway, lemans)); dataModel.Add(new Statement(lemans, oneway, angers)); dataModel.Add(new Statement(lemans, oneway, tours)); dataModel.Add(new Statement(angers, oneway, nantes)); // Create the inference rules by reading them from a N3 string. string rules = "@prefix : <http://www.agfa.com/w3c/euler/graph.axiom#>.\n" + "\n" + "{ ?a :oneway ?b } => { ?a :path ?b } .\n" + "{ ?a :path ?b . ?b :path ?c . } => { ?a :path ?c } .\n"; // Create our question in the form of a statement to test. Statement question = new Statement(paris, path, nantes); // Create the Euler engine Euler engine = new Euler(new N3Reader(new StringReader(rules))); // First Method of Inference: // Ask the engine whether there is a path from paris to nantes. // The Prove method will return a list of proofs, or an empty // array if it could not find a proof. foreach (Proof p in engine.Prove(dataModel, new Statement[] { question })) { Console.WriteLine(p.ToString()); } // Second Method of Inference: // Apply the engine to the data model and then use the data // model's Contains method to see if the statement is "in" // the model + reasoning. dataModel.AddReasoner(engine); Console.WriteLine("Euler Says the Question is: " + dataModel.Contains(question)); } }
Namespace: SemWeb.Inference
Assembly: SemWeb (in SemWeb.dll)
Assembly Versions: 1.0.6.0, 1.0.6.2
See Also: Inherited members from Reasoner.
⊟ Public Constructors
Constructs a new Euler inference engine with the inference rules provided in the given statement stream. ⊟ Public Properties
⊟ Public Methods
abstractMetaQuery (SemWeb.Statement[], SemWeb.Query.QueryOptions, SemWeb.SelectableSource) : SemWeb.Query.MetaQueryResult Documentation for this section has not yet been entered. (Inherited from Reasoner.)Prove (SemWeb.SelectableSource, SemWeb.Statement[]) : Proof[] Documentation for this section has not yet been entered. abstractQuery (SemWeb.Statement[], SemWeb.Query.QueryOptions, SemWeb.SelectableSource, SemWeb.Query.QueryResultSink) Documentation for this section has not yet been entered. (Inherited from Reasoner.) abstractSelect (SemWeb.SelectFilter, SemWeb.SelectableSource, SemWeb.StatementSink) Documentation for this section has not yet been entered. (Inherited from Reasoner.)Select (SemWeb.Statement, SemWeb.SelectableSource, SemWeb.StatementSink) Documentation for this section has not yet been entered. (Inherited from Reasoner.)
⊟ Euler Constructor
Constructs a new Euler inference engine with the inference rules provided in the given statement stream.
public Euler (SemWeb.StatementSource rules)⊟ Parameters
- rules
- A source of inference statements.
⊟ Remarks
The source of inference statements usually comes from an N3 file with rules of the form "{ . . . antecedent statements . . . } => { . . . consequent statements . . . }", with variables such as "?var1" used in both parts. The "=>" predicate is shorthand for the URI http://www.w3.org/2000/10/swap/log#implies.⊟ Requirements
Namespace: SemWeb.Inference
Assembly: SemWeb (in SemWeb.dll)
Assembly Versions: 1.0.6.2
⊟ Prove Method
Documentation for this section has not yet been entered.
⊟ Parameters
- world
- Documentation for this section has not yet been entered.
- goal
- Documentation for this section has not yet been entered.
⊟ Returns
Documentation for this section has not yet been entered.⊟ Remarks
Documentation for this section has not yet been entered.⊟ Requirements
Namespace: SemWeb.Inference
Assembly: SemWeb (in SemWeb.dll)
Assembly Versions: 1.0.6.2