SemWeb.Inference.RDFS

SemWeb : SemWeb.Inference Namespace
RDFS Class

A RDFS inferencing engine.

public class RDFS : Reasoner

#### Remarks

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(SemWeb.Inference.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 RDFS class loads in a schema and scans for rdf:subClassOf, rdf:subPropertyOf, rdf:domain, and rdf:range relations in the schema to establish the class and property hierarchies.

Entailments are queried by calls to Select on the Store that you have added the reasoner to.

Normally a reasoning engine is applied to a SemWeb.Store using SemWeb.Store.AddReasoner(SemWeb.Inference.Reasoner).

When all of the fields in the statement are non-`null`, the following reasoning is applied:

Calling Select(X rdf:type Y), i.e. asking whether X is typed Y, sends the statement back if the entity is marked as being a type of any subclass of Y, or if X is found in the domain or range of a predicate whose domain or range type is Y.

When checking if X is a subclass or subproperty of Y with a call to Select(X rdf:subClassOf/rdf:subPropertyOf Y), the statement is sent back if Y is in the transitive closure of rdf:subClassOf or rdf:subPropertyOf for X, which was already loaded into memory when the schema information was loaded.

When one or more of the fields in the statement is `null`, then following reasoning is applied:

When asking for the subclasses, superclasses, subproperties, or superproperties using Select(X rdfs:subClass/PropertyOf `null`) or Select(`null` rdfs:subClass/PropertyOf Y), the transitive closure is returned.

Asking for all entities with a given type using Select(`null` rdf:type Y) returns all entities marked as being typed as Y or any of its subclasses. Domains and ranges of properties are not used in this case because it would require selecting for all occurrences of all properties with domains and ranges, which isn't scalable. (This will probably be enable-able in the future.) When the type of an entity is requested with a call to Select(X rdf:type `null`), the type found for X in the underlying data source is returned and all of its superclasses, and if X is found in the domain or range of any predicates whose domain or range is given in the schema, the domain or range is returned as well.

For queries Select(X P Y), where X and Y may be null, statements of the form U P V are returned if there is a statement U Q V in the underlying data source where Q is a subproperty of P. (If X is not `null`, U=X; similarly for Y and V.) Note that the returned statements all contain P as the predicate, the property actually queried on, and not the subproperties which were found in the underlying data source.

For all other calls, the arguments are passed down to the underlying Select method of the data source without any RDFS processing.

Below is an example of using this class.

C# Example
    // This example demonstrates basic RDFS reasoning.

    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 me = new BNode("me");
    		BNode you = new BNode("you");

    		Entity rdfType = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
    		Entity rdfsLabel= "http://www.w3.org/2000/01/rdf-schema#label";
    		Entity foafPerson = "http://xmlns.com/foaf/0.1/Person";
    		Entity foafAgent = "http://xmlns.com/foaf/0.1/Agent";
    		Entity foafName = "http://xmlns.com/foaf/0.1/name";

    		dataModel.Add(new Statement(me, rdfType, foafPerson));
    		dataModel.Add(new Statement(you, rdfType, foafPerson));
    		dataModel.Add(new Statement(me, foafName, (Literal)"John Doe"));
    		dataModel.Add(new Statement(you, foafName, (Literal)"Sam Smith"));

    		// Create the RDFS engine and apply it to the data model.

    		RDFS engine = new RDFS();
    		engine.LoadSchema(RdfReader.LoadFromUri(new Uri("http://xmlns.com/foaf/0.1/index.rdf")));

    		dataModel.AddReasoner(engine);

    		// Query the data model

    		// Ask for who are typed as Agents.  Note that the people are
    		// typed as foaf:Person, and the schema asserts that foaf:Person
    		// is a subclass of foaf:Agent.
    		Console.WriteLine("Who are Agents?");
    		foreach (Entity r in dataModel.SelectSubjects(rdfType, foafAgent))
    			Console.WriteLine("\t" + r);

    		// Ask for the rdfs:labels of everyone.  Note that the data model
    		// has foaf:names for the people, and the schema asserts that
    		// foaf:name is a subproperty of rdfs:label.
    		Console.WriteLine("People's labels:");
    		foreach (Statement s in dataModel.Select(new Statement(null, rdfsLabel, null)))
    			Console.WriteLine("\t" + s);
    	}

    }

## Members

See Also: Inherited members from Reasoner.

### Constructors

RDFS () To be added.
RDFS (SemWeb.StatementSource) Creates a new RDFS reasoner with the provided schema.

### Properties

Distinct [read-only] abstract | bool . To be added. (Inherited from Reasoner.)
Schema [read-only] | SemWeb.StatementSink . A StatementSink representing the schema used by the inferencer.

### Methods

| LoadSchema (SemWeb.StatementSource) Adds schema information to the inferencer.
abstract | MetaQuery (SemWeb.Statement[], SemWeb.Query.QueryOptions, SemWeb.SelectableSource) : SemWeb.Query.MetaQueryResult To be added. (Inherited from Reasoner.)
abstract | Query (SemWeb.Statement[], SemWeb.Query.QueryOptions, SemWeb.SelectableSource, SemWeb.Query.QueryResultSink) To be added. (Inherited from Reasoner.)
abstract | Select (SemWeb.SelectFilter, SemWeb.SelectableSource, SemWeb.StatementSink) To be added. (Inherited from Reasoner.)
| Select (SemWeb.Statement, SemWeb.SelectableSource, SemWeb.StatementSink) To be added. (Inherited from Reasoner.)

## Member Details

### RDFS Constructor

public RDFS (SemWeb.StatementSource schema)

Creates a new RDFS reasoner with the provided schema.

#### Parameters

schema
  The source of schema information.

#### Remarks

schema is scanned for RDFS schema statements.

### LoadSchema Method

public void LoadSchema (SemWeb.StatementSource source)

Adds schema information to the inferencer.

#### Parameters

source
  A source of RDFS schema information.

#### Remarks

The source will be scanned for schema information. If the data source implements SemWeb.SelectableSource, the source will be selected just for the relevant RDFS predicates. Otherwise, the entire source will be scanned.

### Schema Property

public SemWeb.StatementSink Schema { get; }

A StatementSink representing the schema used by the inferencer.

#### Value

A StatementSink that statements added to will contribute to the schema used by the inferencer.

#### Remarks

Add statements to the value of this property to add schema information to the inferencer.

### RDFS Constructor

public RDFS ()

To be added.

#### Remarks

To be added.