<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE spec SYSTEM "../shared/xmlspec.dtd" [
	<!ENTITY base.uri "http://www.w3.org/2009/sparql/docs/sparql11-entailment/">
	<!ENTITY maturity.level "WD">
	<!ENTITY doc.shortname "sparql11-entailment">
	<!ENTITY draft.year "2009">
	<!ENTITY draft.month.name "October">
	<!ENTITY draft.month "10">
	<!ENTITY draft.day "13">
	<!ENTITY iso6.doc.date "&draft.year;&draft.month;&draft.day;">
	<!ENTITY doc.ident "&maturity.level;-&doc.shortname;-&iso6.doc.date;">
	<!ENTITY this.version "&base.uri;&doc.ident;">
	<!ENTITY xml.version "&doc.ident;.xml">
	<!ENTITY review.version "&doc.ident;-review.html">
	<!ENTITY pdf.version "&doc.ident;.pdf">
	<!ENTITY errataloc "">
	<!ENTITY preverrataloc "">
	<!ENTITY translationloc "http://www.w3.org/2003/03/Translations/byTechnology?technology=&doc.shortname;">
	<!ENTITY impreploc "">
	<!ENTITY versionOfSPARQL "1.1">
	<!ENTITY WebSGML "WebSGML Adaptations Annex to ISO 8879">
	<!ENTITY nbsp "&#160;">
	<!ENTITY mdash "&#x2014;">
	<!ENTITY magicents "<code>amp</code>,
<code>lt</code>,
<code>gt</code>,
<code>apos</code>,
<code>quot</code>">
	<!ENTITY may "may">
	<!ENTITY MAY "<rfc2119>MAY</rfc2119>">
	<!ENTITY % local.common.att "xml:lang    CDATA  #IMPLIED">
]>
<?xml-stylesheet type="text/xsl" href="../shared/REC-xml.xsl"?>
<spec w3c-doctype="rec" xml:lang="en">
<!--
Notes on preparation of SPARQL 1.1
	
-->
	<header>
		<title>SPARQL &versionOfSPARQL; Entailment Regimes</title>
		<w3c-designation>&doc.ident;</w3c-designation>
		<w3c-doctype>Editor's Draft</w3c-doctype>
		<pubdate>
			<day>&draft.day;</day>
			<month>&draft.month.name;</month>
			<year>&draft.year;</year>
		</pubdate>
		<publoc>
			<loc href="&this.version;/">&this.version;/</loc>
		</publoc>
        <!--
		<altlocs>
			<loc href="&xml.version;">XML</loc>
			<loc href="&pdf.version;">PDF</loc>
			<loc href="&review.version;">XHTML with color-coded revision indicators</loc>
		</altlocs>
        -->
		<latestloc>
			<loc href="http://www.w3.org/TR/&doc.shortname;/">http://www.w3.org/TR/&doc.shortname;/</loc>
		</latestloc>
        <!--
		<prevlocs> -->
   <!-- @@FPWD loc href="http://www.w3.org/TR/2009/WD-rdf-sparql-query-20090915/">http://www.w3.org/TR/2009/WD-rdf-sparql-query-20090915/</loc -->
<!--			<loc href="http://www.w3.org/TR/2008/REC-rdf-sparql-query-20080115/">http://www.w3.org/TR/2008/REC-rdf-sparql-query-20080115/</loc> -->
<!--		</prevlocs> -->
		<authlist>
			<author role="Editor">
				<name>Birte Glimm</name>
				<affiliation>Oxford University Computing Laboratory</affiliation>
				<email href="mailto:birte.glimm@comlab.ox.ac.uk">birte.glimm@comlab.ox.ac.uk</email>
			</author>
			<author role="Editor">
				<name>Bijan Parsia</name>
				<affiliation>University of Manchester</affiliation>
				<email href="mailto:bparsia@cs.manchester.ac.uk">bparsia@cs.manchester.ac.uk</email>
			</author>
		</authlist>
        <!--
		<errataloc href="&errataloc;"/>
		<preverrataloc href="&preverrataloc;"/>
		<translationloc href="&translationloc;"/>
        -->
		<abstract>
      <p>SPARQL is a query language for data that is stored natively
	as RDF or viewed as RDF via middleware. What correct answers
	to a SPARQL query are depends on the used entailment regime
	and the vocabulary from which the resulting answers can be
	taken. The first version of SPARQL 
	<bibref ref="SPARQL11"/> was defined only for <a
	href="http://www.w3.org/TR/rdf-mt/#entail" title="http://www.w3.org/TR/rdf-mt/#entail">simple
	entailment</a>, but it defines a set of conditions that have
	to be met when defining what correct results are for SPARQL
	queries under different entailment regimes. The goal of this
	document is to specify conditions such that SPARQL can be used
	with entailment regimes other than simple entailment. Currently the semantics of SPARQL queries under 
	<a href="http://www.w3.org/TR/rdf-mt/#rdf_entail" title="http://www.w3.org/TR/rdf-mt/#rdf_entail">RDF</a> and 
	<a href="http://www.w3.org/TR/rdf-mt/#rdfs_entailment" title="http://www.w3.org/TR/rdf-mt/#rdfs_entailment">RDFS entailment</a> is defined. 
	Time permitting, entailment regimes will also be defined for
	<a href="http://www.w3.org/TR/rdf-mt/#D_entailment" title="http://www.w3.org/TR/rdf-mt/#D_entailment">D-entailment</a>,
	OWL with <a
	href="http://www.w3.org/TR/2009/WD-owl2-overview-20090611/#ref-owl-2-direct-semantics"
	title="http://www.w3.org/TR/2009/WD-owl2-overview-20090611/#ref-owl-2-direct-semantics">Direct</a>
	and <a
	href="http://www.w3.org/TR/2009/WD-owl2-overview-20090611/#ref-owl-2-rdf-semantics"
	title="http://www.w3.org/TR/2009/WD-owl2-overview-20090611/#ref-owl-2-rdf-semantics">RDF-Based</a>
	semantics including 
	<a href="http://www.w3.org/TR/owl2-profiles/" title="http://www.w3.org/TR/owl2-profiles/">OWL 2 Profiles</a>, 
	and the rule interchange format <a href="http://www.w3.org/TR/rif-overview/" title="http://www.w3.org/TR/rif-overview/">RIF</a>. </p>
	</abstract>
	<status>
      <p><em>This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the <a href="http://www.w3.org/TR/">W3C technical reports index</a> at http://www.w3.org/TR/.</em></p>

      <p>This is a <a href="http://www.w3.org/2005/10/Process-20051014/tr.html#RecsWD">Editors' Working Draft</a>.</p>

      <p>Comments on this document should be sent to <a href="mailto:public-rdf-dawg-comments@w3.org">public-rdf-dawg-comments@w3.org</a>, a mailing list with a <a href="http://lists.w3.org/Archives/Public/public-rdf-dawg-comments">public archive</a>. Questions and comments about SPARQL that are not related to this specification, including extensions and features, can be discussed on the mailing list <a href="mailto:public-sparql-dev@w3.org">public-sparql-dev@w3.org</a>, (<a href="http://lists.w3.org/Archives/Public/public-sparql-dev">public archive</a>).</p>

      <p>This document was produced by the <a href="http://www.w3.org/2001/sw/DataAccess/">SPARQL Working Group</a>, which is part of the <a href="http://www.w3.org/2001/sw/Activity">W3C Semantic Web Activity</a>.</p>

      <p>This document was produced by a group operating under the <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 W3C Patent Policy</a>. W3C maintains a <a rel="disclosure" href="http://www.w3.org/2004/01/pp-impl/35463/status">public list of any patent disclosures</a> made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential Claim(s)</a> must disclose the information in accordance with <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the W3C Patent Policy</a>.</p>
		</status>
		<pubstmt>
			<p>@@@ Chicago, Vancouver, Mountain View, Edinburgh, et al.: World-Wide Web Consortium, XML
Working Group, 1996, 1997, 2000, 2006, 2008.</p>
		</pubstmt>
		<sourcedesc>
			<p>Created in electronic form.</p>
		</sourcedesc>
		<langusage>
			<language id="EN">English</language>
			<language id="ebnf">Extended Backus-Naur Form (formal grammar)</language>
		</langusage>
		<revisiondesc>
			<p role="cvsid">$Id: xmlspec.xml,v 1.18 2009/11/23 18:23:28 bglimm Exp $</p>
		</revisiondesc>
	</header>
	
	
	
	<body>
	
	<div1 id="sec-intro"><head>Introduction</head>
		<p>The first SPARQL specification defines only simple entailment, which allows for finding answers by matching the triple pattern of the query onto the RDF graph of the queried data. Other entailment regimes, such as RDFS entailment, allow for finding answers to a query that are not directly specified in the queried graph, but can be infered using a set of inference rules. In this document, we specify how SPARQL can be used with entailment regimes other than simple entailment. </p>
		<p>SPARQL Entailment Regimes is closely related to the following specifications:</p>
		<ul>
		<li> The <a href="http://www.w3.org/TR/rdf-sparql-query/" title="http://www.w3.org/TR/rdf-sparql-query/">SPARQL Query Language for RDF</a> specification, which normatively specifies the SPARQL query language in human-readable language.</li>
		<li> The <a href="http://www.w3.org/2009/sparql/docs/query-1.1/" title="http://www.w3.org/2009/sparql/docs/query-1.1/">SPARQL 1.1/Query</a> specification, which extends the first SPARQL query language specification.</li>
		<li> The <a href="http://www.w3.org/2009/sparql/docs/update-1.1/" title="http://www.w3.org/2009/sparql/docs/update-1.0/">SPARQL 1.1/Update</a> specification, which describes an update language for RDF graphs.</li>
		<li> The <a href="http://www.w3.org/2009/sparql/docs/protocol-1.1/" title="http://www.w3.org/2009/sparql/docs/protocol-1.1/">SPARQL 1.1/Protocol</a> specification, which extends the SPARQL Protocol specification.</li>
		<li> The <a href="http://www.w3.org/TR/rdf-sparql-XMLres/" title="http://www.w3.org/TR/rdf-sparql-XMLres/">SPARQL Query Results XML Format</a> specification defines an XML document format for representing the results of SPARQL SELECT and ASK queries.</li>
		<li> The <a
        href="http://www.w3.org/2009/sparql/docs/service-description-1.1/xmlspec.xml" title="http://www.w3.org/2009/sparql/docs/service-description-1.1/xmlspec.xml">SPARQL 1.1/Service Descriptions</a>, a method for discovering and vocabulary for describing SPARQL services made available via the SPARQL Protocol. </li>
		</ul>
		<p>In places, we refer to the RDF or RDFS entailment rules from the <a href="http://www.w3.org/TR/rdf-mt/" title="http://www.w3.org/TR/rdf-mt/">RDF Semantics</a> specification. This rules are just used in an informative way and implementations are not expected to implement these rules as they are used here. </p>    

		<div2 id="t11"><head>Document Conventions</head>
			<p>Throughout the document, we adhere to certain conventions that are outlined below. </p>
			<div3 id="t111"><head>Graph Syntax</head>
				<p>This document uses the Turtle <bibref ref="TURTLE"/> data format to show triples explicitly. This notation uses a node identifier (nodeID) convention to indicate blank nodes in the triples of a graph. While node identifiers such as <code>_:xxx</code> serve to identify blank nodes in the surface syntax, these expressions are not considered to be the label of the graph node they identify; they are not names, and do not occur in the actual graph. In particular, the RDF graphs described by two Turtle  documents which differ only by re-naming their node identifiers will be understood to be equivalent. This re-naming convention should be understood as applying only to whole documents, since re-naming the node identifiers in part of a document may result in a document describing a different RDF graph. A generated blank node may also be made with <code>[]</code>. </p>
				<p>IRIs are written enclosed in <code>&lt;</code> and <code>&gt;</code> and may be absolute RDF IRI References or relative to the current base IRI. IRIs may also be abbreviated by using Turtle's <code>@prefix</code> directive that allows declaring a short prefix name for a long prefix of repeated IRIs. Once a prefix such as <code>@prefix foo: &lt;http://example.org/ns#&gt;</code> is defined, any mention of an IRI later in the document may use a qualified name that starts <code>foo:</code> to stand for the longer IRI. For example, the qualified name foo:bar is a shorthand for the IRI <code>http://example.org/ns#bar</code>.</p>
				<p>For example, the following triples use prefixes and abbreviated IRIs and also non-abbreviated IRIs such as <code>&lt;book2&gt;</code>, which are relative to the base IRI of the document.</p>
<codeeg>@prefix dc:   &lt;http://purl.org/dc/elements/1.1/&gt; .
@prefix&nbsp;:     &lt;http://example.org/book/&gt; .
:book1  dc:title "SPARQL Tutorial" . 
&lt;book2&gt; dc:title "Turtle Tutorial" .</codeeg>
			</div3>
			
			<div3 id="t112"><head>Namespaces</head>
				<p>Examples assume the following namespace prefix bindings unless otherwise stated:</p>
				<div style="text-align: left;">
  				<table style="border-color: rgb(0, 0, 0); border-collapse: collapse;" border="1" cellpadding="5">
    				<tbody><tr>
      					<th>Prefix</th>
				    	<th>IRI</th>
				    </tr>
				    <tr>
				      <td><code>rdf:</code></td>
				      <td><code>http://www.w3.org/1999/02/22-rdf-syntax-ns#</code></td>
				    </tr>
				    <tr>
				      <td><code>rdfs:</code></td>
				      <td><code>http://www.w3.org/2000/01/rdf-schema#</code></td>
				    </tr>
				    <tr>
				      <td><code>xsd:</code></td>
				      <td><code>http://www.w3.org/2001/XMLSchema#</code></td>
				    </tr>
				    <tr>
				      <td><code>fn:</code></td>
				      <td><code>http://www.w3.org/2005/xpath-functions#</code></td>
				    </tr>
				  </tbody></table>
				</div>
				<p>In the interests of brevity, the prefix ex: is also used in the examples. The prefix is assumed to be bound to an imaginary IRI such as http://www.example.org/. </p>
			</div3>
			
			<div3 id="t113"><head>Preliminary Definitions</head>
				<p>This document uses the same <a href="http://www.w3.org/TR/rdf-sparql-query/#sparqlBasicTerms" title="http://www.w3.org/TR/rdf-sparql-query/#sparqlBasicTerms">definitions</a> as the <a href="http://www.w3.org/TR/rdf-sparql-query/" title="http://www.w3.org/TR/rdf-sparql-query/">SPARQL Query Language</a> specification and we recapture the most important terms here for clarity. In the case of any difference, the SPARQL Query Language definitions are the normative ones. </p>
				<p>We use <em>RDF-L</em> for the set of all RDF Literals, <em>RDF-B</em> for the set of all blank nodes in RDF graphs, and <em>RDF-T</em> for the set of RDF Terms, which is a union of the set of all IRIs, <em>RDF-L</em>, and <em>RDF-B</em>.</p>
				<p>We use <em>V</em> for the set of query variables, where <em>V</em> is infinite and disjoint from <em>RDF-T</em>. A triple pattern is member of the set:</p>
                <glist>
                   <gitem>
                    <def><em>(RDF-T union V) x (I union V) x (RDF-T union V),</em></def>
                    </gitem>
                </glist>
				<p>A Basic Graph Pattern is a set of Triple Patterns. </p>		
			</div3>
		</div2>

		<div2 id="t12"><head>Effects of Different Entailment Regimes </head>
			<p>The SPARQL 1.0 specification already envisages that SPARQL can be used with entailment regimes other than simple entailment and to illustrate the differences between simple, RDF, and RDFS entailment, we consider the following data:</p>
<codeeg>(1) ex:book1 rdf:type ex:Publication .
(2) ex:book2 rdf:type ex:Article .
(3) ex:Article rdfs:subClassOf ex:Publication .
(4) ex:publishes rdfs:range ex:Publication .
(5) ex:MITPress ex:publishes ex:book3 .</codeeg>
			<p>We use the following query that asks for a list of all publications</p>
			<codeeg>SELECT&nbsp;?pub WHERE {&nbsp;?pub rdf:type ex:Publication . }</codeeg>
			<p>Clearly, <code>ex:book1</code> is an answer due to triple (1). Intuiltively, we can expect that <code>ex:book2</code> is also a publication because it is an article (2) and all articles are publications (3). Even <code>ex:book3</code> is a publication because it is published by MIT Press (5) and everything that is published is a publication (4). Under simple and RDF entailment, <code>ex:book1</code> is the only answer because a system that uses simple entailment will not perform any of the reasoning steps that were required to find that <code>ex:book2</code> and <code>ex:book3</code> are publications. Under simple entailment, we check how the basic graph pattern <code>?pub rdf:type ex:Publication</code> can be mapped to the queried graph and by instantiating <code>?pub with ex:book1</code> we have a match. RDF already supports a few inferences, but not those that are required to derive that <code>ex:book2</code> and <code>ex:book3</code> are publications. In order to retrieve <code>ex:book2</code> and <code>ex:book3</code>, one would need a system that supports RDFS entailment. Under RDFS entailment, a set of <a href="http://www.w3.org/TR/rdf-mt/#RDFSRules" title="http://www.w3.org/TR/rdf-mt/#RDFSRules">RDFS entailment rules</a> is applied to the explicitly given data to derive new consequences. E.g., the rule <em>rdfs9</em> can be applied to the triples (3) and (2) to derive</p>
			<codeeg>(6) ex:book2 rdf:type ex:Publication .</codeeg>
			<p>The rule <em>rdfs3</em> can be applied to (4) and (5) to derive </p>
			<codeeg>(7) ex:book3 rdf:type ex:Publication .</codeeg>
			<p>The triples (6) and (7) can then be used to find that <code>ex:book2</code> and <code>ex:book3</code> are also answers to the query under an RDFS entailment regime. </p>
			<p>The difference between RDF and simple entailment is less significant since RDF supports only few inferences. Consider, for example, the following query:</p>
			<codeeg>SELECT&nbsp;?prop WHERE {&nbsp;?prop rdf:type rdf:Property . }</codeeg>
			<p>Under simple entailment the query has an empty answer when querying the above graph. Under RDF entailment, we can use the <a href="http://www.w3.org/TR/rdf-mt/#RDFRules" title="http://www.w3.org/TR/rdf-mt/#RDFRules">RDF rule</a> <em>rdf1</em> on (5) to derive the triple</p>
			<codeeg>ex:publishes rdf:type rdf:Property .</codeeg>
			<p>which means that <code>ex:publishes</code> is a valid binding for <code>?prop</code> and will be returned as an answer for the query from a system that uses RDF entailment. </p>
			<p>The web ontology language OWL allows for even more inferences and in the remainder, we specify what correct answers are for the different entailment regimes.</p>
		</div2>
		
		<div2 id="t13"><head>Extensions to Basic Graph Pattern Matching</head>
			<p>The SPARQL 1.0 specification gives a set of <a href="http://www.w3.org/TR/rdf-sparql-query/#sparqlBGPExtend" title="http://www.w3.org/TR/rdf-sparql-query/#sparqlBGPExtend">conditions</a> that have to be met when extending the basic graph pattern matching to other entailment regimes and SPARQL 1.0 says: </p>
<p>An entailment regime specifies</p>
<olist>
<item>A subset of RDF graphs called well-formed for the regime</item>
<item>An entailment relation between subsets of well-formed graphs and well-formed graphs.</item>
</olist>
			<p>Since the OWL 2 Direct Semantics is, for example, only defined for certain well-formeded of RDF graphs, the first condition can be used to define an OWL 2 Direct Semantics entailment regime only over those RDF graphs that represent an OWL 2 DL ontology. For the entailment relations mentioned in the second condition we use those entailment relations that are already specified and used in the Semantic Web such as RDF(S) entailment, OWL entailment, or RIF entailment. </p>
			<p>SPARQL 1.0 further defines <a href="http://www.w3.org/TR/rdf-sparql-query/#sparqlBGPExtend" title="http://www.w3.org/TR/rdf-sparql-query/#sparqlBGPExtend">a set of conditions</a> for extensions of the basic graph pattern matching. We repeat these conditions here for clarity and give an idea of how the different entailment regimes satisfy them. Further details for each of the specified entailment regimes can be found in the corresponding section for that entailment regime. </p>
			<p>1 -- The <a href="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes" title="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes">scoping graph</a>, SG, corresponding to any consistent active graph AG is uniquely specified and is E-equivalent to AG.</p>
			<p>2 -- For any basic graph pattern BGP and pattern solution mapping P, P(BGP) is well-formed for E. </p>
			<p>3 -- For any <a href="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes" title="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes">scoping graph</a> SG and answer set {P<sub>1</sub> ... P<sub>n</sub>} for a basic graph pattern BGP, and where {BGP<sub>1</sub> .... BGP<sub>n</sub>} is a set of basic graph patterns all equivalent to BGP, none of which share any blank nodes with any other or with SG</p>
            <glist><gitem>
			<def>   SG E-entails (SG union P<sub>1</sub>(BGP<sub>1</sub>) union ... union P<sub>n</sub>(BGP<sub>n</sub>))</def>
            </gitem></glist>
			<p>These conditions do not fully determine the set of possible answers, since RDF allows unlimited amounts of redundancy. In addition, therefore, the following must hold.</p>
			<p>4 -- Each SPARQL extension must provide conditions on answer sets which guarantee that every BGP and AG has a finite set of answers which is unique up to RDF graph equivalence.</p>
			<p>We do not change any of the existing entailment relations, but rather define the vocabulary from which possible answers can be taken and which answers are legal answers in order to guarantee that query answers are always finite. We also do not restrict the set of legal graphs that can be queried apart from the restriction to graphs that are legal under the entailment regime in question. E.g., under the RDFS entailment regime, one can query all legal RDFS graphs, while under OWL 2 DL Direct Semantics, one can query all graphs that correspond to legal OWL 2 DL ontologies. We do define which queries are legal and how illegal queries or graphs and inconsistencies are handled.</p>
			<p>For 1: All entailment regimes specified here use the same definition of a <a href="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes" title="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes">scoping graph as given in SPARQL 1</a>. Thus, the required equivalence is immediate. </p>
			<p>For 2: This gives minimal conditions on what legal answers are for an entailment regime E: A mapping is only a legal solution mapping and included in the answer if applying the mapping yields a set of RDF triples that are well-formed for E. For example, under RDFS entailment, any SPARQL query is legal, but queries that require literals as a binding for a variable in a subject position have no answer because all mappings that result in a set of RDFS entailed tripes are not well-formed RDF since RDF forbids literals in the subject position. Similarly, for OWL 2 DL entailment, a query might have no answer because all possible bindings might result in RDF triples that are not well-formed for <a href="http://www.w3.org/TR/owl2-mapping-to-rdf/" title="http://www.w3.org/TR/owl2-mapping-to-rdf/">OWL 2 DL</a>. </p>
			<p>For 3: This condition prevents the reuse of blank nodes between query answers unless those blank nodes are really the same in the queried graph. Under this restriction no accidental co-references among blank nodes are introduced. Since we use the same definition of a <a href="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes" title="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes">scoping graph</a>, the condition is also satisfied. </p>
			<ednote><date>14/10/2009</date><edtext>The proof needs to be redone though since it uses the interpolation lemma, which does not hold e.g., for RDFS-entailment. </edtext></ednote>
			<p>For 4: For entailment regimes other then simple entailment this point is very important since a finite set of answers is no longer guaranteed. For example, already under RDF and RDFS entailment, even the empty graph entails an infinite number of axiomatic triples such as <code>rdf:_1 rdf:type rdf:Property</code>, <code>rdf:_2 rdf:type rdf:Property</code>, ... Thus, a query with BGP <code>{&nbsp;?x rdf:type rdf:Property . }</code> would, without further restrictions, have infinitely many answers. 
			In order to guarantee finite answers, different entailment regimes will impose different restrictions on the vocabulary from which bindings can be taken. We explain these restrictions in greater detail in the following section. </p>
		</div2>
	</div1>
	
	
	
	<div1><head>Details for Different Entailment Regimes</head>
		<p>For each of the covered entailment regimes, we adress all the conditions that entailment extensions to SPARQL basic graph pattern matching have to satify.</p>
		
		<div2><head>RDF Entailment Regime</head>
			<p>RDF entailment is closest to simple entailment in that it provides only few additional answers and RDF is not expressive enough to express inconsistencies. RDF does, however, entail an infinite set of axiomatic triples and we have to specify how we can guarantee the forth condition on extensions of basic graph pattern matching, which requires that answer sets are always finite. </p>
			<div style="text-align: left;">
  			<table style="border-color: rgb(0, 0, 0); border-collapse: collapse;" border="1" cellpadding="5">
			<tbody>
			<tr>
				<th>Name</th><td>RDF</td>
			</tr>
			<tr>
				<th>Legal Graphs</th><td>Any legal RDF graph.</td>
			</tr>
			<tr>
				<th>Legal Queries</th><td>Any legal SPARQL query.</td>
			</tr>
			<tr>
				<th>Illegal handling</th><td>In case the query or the queried graph is illegal (syntax errors), the system <rfc2119>MUST</rfc2119> raise an error.</td>
			</tr>
			<tr>
				<th>Entailment</th><td><a href="http://www.w3.org/TR/rdf-mt/#rdf_entail" title="http://www.w3.org/TR/rdf-mt/#rdf_entail">RDF Entailment</a></td>
			</tr>
			<tr>
				<th>Inconsistency</th><td>RDF graphs are always RDF consistent and no inconsistency handling is required.</td>
			</tr>
			<tr>
				<th>Query Answers</th>
				<td>A <em>pattern instance mapping</em> P for RDF entailment is a pair (&#956;, &#963;), where &#956;&nbsp;: V -&gt; RDF-T is a solution mapping and &#963;&nbsp;: RDF-B -&gt; RDF-T is an <a href="http://www.w3.org/TR/rdf-mt/#definst" title="http://www.w3.org/TR/rdf-mt/#definst">RDF instance mapping</a>. Let BGP be a basic graph pattern, V(BGP) the set of variables in BGP, B(BGP) the set of blank nodes in BGP, G an RDF graph, and P=(&#956;, &#963;) a pattern instance mapping for RDF entailment. We write <em>P(BGP)</em> to denote the result of replacing each variable v from V(BGP) for which &#956; is defined with &#956;(v) and each blank node b from B(BGP) for which &#963; is defined with &#963;(b).
				<p>A solution mapping &#956; is a <em>possible solution for BGP from G under RDF entailment</em> if dom(&#956;) = V(BGP) and there is an RDF instance mapping &#963; from B(BGP) to RDF-T such that dom(&#963;)=B(BGP) and the pattern instance mapping P=(&#956;, &#963;) is such that P(BGP) are well-formed RDF triples that are RDF entailed by G. </p>
				<p>A possible solution &#956; is a <em>solution for BGP from G under RDF entailment</em> if </p>
				<p>(C1) each subject s of a triple ( s, p, o ) in P(BGP) occurs in the <a href="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes" title="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes">scoping graph</a> and </p>
				<p>(C2) each blank node b in the range of &#956; and &#963; occurs in the <a href="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes" title="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes">scoping graph</a> SG.</p>
				</td>
			</tr>
			</tbody>
			</table>
			</div>
			<p>Please note that we define what legal answers under RDF entailment are in a two-stage process. Intuitively, the possible answers are all answers that one would expect under RDF entailment, i.e., all mappings such that instantiating the basic graph patterns with them results in RDF triples that are RDF entailed by the queried graph. The set of possible answers is, however, not necessarily finite. To obtain always a finite set of answers, the next step defines which of the possible answers are actually to be returned as answers to the query. In this step, we restrict answers so that we only return finitely many of the axiomatic triples (C1) and return no answers that are equivalent to other answers and just contain fresh blank nodes that were created by applications of RDF entailment rules (C2). We comment on these two restrictions below. </p>
			
			<div3><head>Examples for the Restrictions on Solutions (Informative) </head>
				<p>The following example illustrates the use of both conditions C1 and C2. Consider the query </p>
				<codeeg>SELECT&nbsp;?x WHERE {&nbsp;?x rdf:type rdf:Property . } </codeeg>
				<p>against a graph containing only the triples </p>
<codeeg>ex:a ex:b ex:c . 
_:xxx rdf:type rdf:Bag .
_:xxx rdf:_1 ex:a .</codeeg>
				<p>The scoping graph is assumed to be the same as the active graph, i.e., the graph for the triples shown above. One of the possible solutions is <code>{ (x, ex:b) }</code> since according to the <a href="http://www.w3.org/TR/rdf-mt/#RDFRules" title="http://www.w3.org/TR/rdf-mt/#RDFRules">RDF entailment rule</a> <em>rdf1</em></p>
				<codeeg>ex:a ex:b ex:c . </codeeg>
				<p>entails </p>
				<codeeg>ex:b rdf:type rdf:Property .</codeeg>
				<p>Further, the axiomatic triples, give the possible solutions such as <code>{ (x, rdf:type) }</code> or <code>{ (x, rdf:subject) }</code> and <code>{ (x, rdf:_1) }</code>, <code>{ (x, rdf:_2) }</code>, ...
				There are even more possible answers since the <a href="http://www.w3.org/TR/rdf-mt/#simpleRules" title="http://www.w3.org/TR/rdf-mt/#simpleRules">simple entailment rule</a> <em>se2</em> means that </p>
				<codeeg>ex:b rdf:type rdf:Property . </codeeg>
				<p>RDF entails</p>
				<codeeg>_:exb1 rdf:type rdf:Property .</codeeg>
				<p>for some blank node <code>_:exb1</code> <a href="http://www.w3.org/TR/rdf-mt/#defallocated" title="http://www.w3.org/TR/rdf-mt/#defallocated">allocated</a> to <code>ex:b</code> and <code>{ (x, _:exb1) }</code> is a possible solution. The <a href="http://www.w3.org/TR/rdf-mt/#simpleRules" title="http://www.w3.org/TR/rdf-mt/#simpleRules">rule</a> <em>se2</em> can be applied again to the just mentioned triple, showing that the following triple is also entailed by the queried graph</p>
				<codeeg>_:exb2 rdf:type rdf:Property .</codeeg>
				<p>for some blank node <code>_:exb2</code> <a href="http://www.w3.org/TR/rdf-mt/#defallocated" title="http://www.w3.org/TR/rdf-mt/#defallocated">allocated</a> to <code>_:exb1</code> and <code>{ (x, _:exb2) }</code> is a possible solution too. One can, in fact, infer infinitely many blank nodes to be possible solutions for the query.  </p>
				<p>Clearly, the set of possible solutions is infinite in this case, but for a possible solution to actually be a solution, the two conditions C1 and C2 have to be met: 
				(C1) each subject s of a triple ( s, p, o ) in P(BGP) occurs in the <a href="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes" title="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes">scoping graph</a> and
				(C2) each blank node b in the range of &#956; and &#963; occurs in the <a href="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes" title="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes">scoping graph</a> SG. </p>
				<p>In this case, condition C1 limits the answers from the axiomatic triples. We consider the examplary possible answers <code>{ (x, rdf:type) }</code>, <code>{ (x, rdf:subject) }</code>, <code>{ (x, rdf:_1) }</code>, and <code>{ (x, rdf:_2) }</code>. </p>
				<ul>
					<li>For the possible solution &#956;: x -&gt; <code>rdf:type</code>, take an empty RDF instance mapping &#963; to obtain a pattern instance mapping P=(&#956;, &#963;) with P(BGP) = <code>rdf:type rdf:type rdf:Property . </code></li>
				</ul>
				<p>Since the subject <code>rdf:type</code> occurs in the <a href="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes" title="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes">scoping graph</a> (here the scoping graph and the active graph are equal) and condition C2 is trivially satisfied, this solution mapping is actualy a solution. </p>
				<ul>
					<li>For the possible solution &#956;: x -&gt; <code>rdf:subject</code>, take again an empty RDF instance mapping &#963; to obtain a pattern instance mapping P=(&#956;, &#963;) with P(BGP) = <code>rdf:subject rdf:type rdf:Property . </code></li>
				</ul> 
				<p>Since the subject <code>rdf:subject</code> does not occur in the <a href="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes" title="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes">scoping graph</a>, this possible solution mapping is excluded and nor part of the actual solutions although the triple is entailed. </p>
				<ul>
					<li>For the possible solution &#956;: x -&gt; <code>rdf:_1</code>, take again an empty RDF instance mapping &#963; to obtain a pattern instance mapping P=(&#956;, &#963;) with P(BGP) = <code>rdf:_1 rdf:type rdf:Property . </code></li>
				</ul>
				<p>Since the subject <code>rdf:_1</code> occurs in the <a href="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes" title="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes">scoping graph</a> and condition C2 is trivially satisfied, this solution mapping is actualy a solution. </p>
				<ul>
					<li>For the possible solution &#956;: x -&gt; <code>rdf:_2</code>, take again an empty RDF instance mapping &#963; to obtain a pattern instance mapping P=(&#956;, &#963;) with P(BGP) = <code>rdf:_2 rdf:type rdf:Property . </code></li>
				</ul>
				<p>Since the subject <code>rdf:_2</code> does not occur in the <a href="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes" title="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes">scoping graph</a>, this solution mapping is not a solution. Similar arguments can be used for <code>rdf:_n</code> with n &gt; 2 and for other bindings from axiomatic triples such as <code>rdf:first</code> from the axiomatic triple <code>rdf:first rdf:type rdf:Property .</code>.</p>
				<p>The second condition rules out <code>{ (x, _:exb1) }</code>, <code>{ (x, _:exb2) }</code>, ... since the blank nodes <code>_:exb1</code>, <code>_:exb2</code>, ... do not occur in the <a href="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes" title="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes">scoping graph</a> (again the scoping graph equals the active graph here). Thus, the only answers are <code>{ (x, ex:b) }</code>, <code>{ (x, rdf:type) }</code>, and <code>{ (x, rdf:_1) }</code>. </p>
				<p>We give another example for RDFS entailment that shows the behavior if the query contains blank nodes and for the case where entailment really makes a difference other than adding some axiomatic triples. </p>
			</div3>
			
			<div3><head>Literals in the Subject Position (Informative) </head>
				<p>Please note that solution mappings that map variables that occur in the subject in the basic graph pattern BGP to literals will not be returned as solutions even though there might be a pattern instance mapping P for the solution mapping such that P(BGP) is RDF entailed by the queried graph, but P(BGP) is not well-formed as required (see also <a href="http://www.w3.org/TR/rdf-sparql-query/#sparqlTriplePatterns" title="http://www.w3.org/TR/rdf-sparql-query/#sparqlTriplePatterns">the SPARQL triple patterns definition</a>). E.g., given a query </p>
				<codeeg>SELECT&nbsp;?x WHERE {&nbsp;?x rdf:type rdf:XMLLiteral . }</codeeg>
				<p>even the empty graph would RDF entail all statements <code>xxx rdf:type rdf:XMLLiteral</code> for <code>xxx</code> a well-formed RDF XML literal, but applying a solution mapping such as &#956;&nbsp;:&nbsp;x -&gt; <code>"&lt;a&gt;abc&lt;/a&gt;"^^rdf:XMLLiteral</code> would result in a triple that is not a valid RDF triple. </p>
				<p>Please note that triples with literals in the subject positions are currently not considered well-formed RDF, but this <a href="http://www.w3.org/TR/rdf-sparql-query/#sparqlTriplePatterns" title="http://www.w3.org/TR/rdf-sparql-query/#sparqlTriplePatterns">might be changed in the future</a>. If literals were allowed in the subject position, condition C1 would still guarantee finite answers. </p>
			</div3>
			
			<div3><head>Boolean Queries (Informative) </head>
				<p>The two conditions C1 and C2 also have an effect on the answers to Boolean queries. For Boolean queries that contain variables, e.g., </p>
				<codeeg>ASK {&nbsp;?x rdf:type rdf:Property . }</codeeg>
				<p>this is straighforward. The query answer is <code>yes</code> (true) if <code>x</code> has at least one solution and it is <code>no</code> (false) otherwise. For Boolean queries without variables it is less clear how the answer is determined. We have two possible outcomes for a Boolean query without variables: there is a solution sequence containing a mapping ( &#956; ) where &#956; has an empty domain (it does not map any variable to anything) or there is only an empty solution sequence <code>( )</code>. In the first case, the query answer is <code>yes</code> (true), whereas in the second case the query answer is <code>no</code> (false). Thus we can still apply the two conditions on possible solutions and check whether the solution mapping is indeed a solution. For example, if we ask the above query against the empty graph, we find that the solution mapping &#956; with empy domain is a possible solution, but condition C1 rules this solution mapping out as an answer and the query answer is <code>no</code> (false). </p>
			</div3>
			
			<ednote><date>14/10/2009</date><edtext>
				<p>Other Possible Design Choices for Finite Answers</p>
				<p>1) Instead of using the vocabulary of the graph to limit the number of axiomatic triples, we could simply exclude the axiomatic triples from the set of query answers. </p>
				<p>2) We do return axiomatic triples, but <code>SELECT</code> or <code>CONSTRUCT</code> queries that contain one of the following the triple patterns </p>
				<codeeg>?x rdf:type rdf:Property . 
?x rdf:type rdfs:ContainerMembershipProperty . 
?x rdfs:domain rdfs:Resource . 
?x rdfs:range rdfs:Resource . 
</codeeg>
				<p>must satisfy additional safety restrictions. E.g., if a query contains the one of the above triple patterns, then it must specify a limit clause. This would have the advantage that we do have a kind of monotonic behavior, i.e., both ask queries described above would have the answer yes and the subject would be contained in the answers for the according select query, but the additional limit clause would restrict answers to a finite subset of all answers. The disadvantage is that we do have no control as to what would be in the returned answer and what would be left out, which is not very intuitive either. </p>
				<p>3) Since, as long as literals are not allowed in subject positions, only subjects of the form <code>rdf:_1</code>, <code>rdf:_2</code>, ... can cause infinite answers, we could also look at what the largest n is in elements of the form <code>rdf:_n</code> and return axiomatic triples such as <code>rdf:_m rdf:type rdf:Property</code> only if m&lt;=n. This falls apart, however, if we allow literals in subject position, since in that case </p>
				<codeeg>xxx rdf:type rdf:XMLLiteral </codeeg>
				<p>is an answer to the query </p>
				<codeeg>SELECT&nbsp;?x WHERE { &nbsp;?x rdf:type rdf:XMLLiteral }</codeeg>
				<p>for <code>xxx</code> a well-formed RDF XML literal. </p>
			</edtext></ednote>
		</div2>
		
		
		
		<div2><head>RDFS Entailment Regime</head>
			<p>Under RDFS we have not only more entailment rules, which result in possibly more query answers, but we also have to handle inconsistencies, which can result in infinite answer sets since an inconsistet graph RDFS entails any consequence. </p>
			<div style="text-align: left;">
  			<table style="border-color: rgb(0, 0, 0); border-collapse: collapse;" border="1" cellpadding="5">
			<tbody>
			<tr>
				<th>Name</th><td>RDFS</td>
			</tr>
			<tr>
				<th>Legal Graphs</th><td>Any legal RDF graph.</td>
			</tr>
			<tr>
				<th>Legal Queries</th><td>Any legal SPARQL query.</td>
			</tr>
			<tr>
				<th>Illegal handling</th><td>In case the query or the queried graph is illegal (syntax errors), the system <rfc2119>MUST</rfc2119> raise an error.</td>
			</tr>
			<tr>
				<th>Entailment</th><td><a href="http://www.w3.org/TR/rdf-mt/#rdfs_entailment" title="http://www.w3.org/TR/rdf-mt/#rdfs_entailment">RDFS Entailment</a></td>
			</tr>
			<tr>
				<th>Inconsistency</th><td>If the queried graph is <a href="http://www.w3.org/TR/rdf-mt/#RDFSINTERP" title="http://www.w3.org/TR/rdf-mt/#RDFSINTERP">RDFS-inconsistent</a>, an implementation <rfc2119>MAY</rfc2119> generate an error or warning and <rfc2119>SHOULD</rfc2119> generate such an error or warning if, in the course of processing, it determines that the data or query is not compatible with the request.</td>
			</tr>
			<tr>
				<th>Query Answers</th>
				<td>A <em>pattern instance mapping P for RDFS entailment</em> is a pair (&#956;, &#963;), where &#956;&nbsp;: V -&gt; RDF-T is a solution mapping and &#963;&nbsp;: RDF-B -&gt; RDF-T is an <a href="http://www.w3.org/TR/rdf-mt/#definst" class="external text" title="http://www.w3.org/TR/rdf-mt/#definst">RDF instance mapping</a>. Let BGP be a basic graph pattern, V(BGP) the set of variables in BGP, B(BGP) the set of blank nodes in BGP, G an RDF graph that is RDFS-consistent, and P=(&#956;, &#963;) a pattern instance mapping for RDFS entailment. We write <em>P(BGP)</em> to denote the result of replacing each variable v from V(BGP) for which &#956; is defined with &#956;(v) and each blank node b from B(BGP) for which &#963; is defined with &#963;(b).
				<p>A solution mapping &#956; is a <em>possible solution for BGP from G under RDFS entailment</em> if dom(&#956;) = V(BGP) and there is an RDF instance mapping &#963; from B(BGP) to RDF-T such that dom(&#963;)=B(BGP) and the pattern instance mapping P=(&#956;, &#963;) is such that P(BGP) are well-formed RDF triples that are RDFS entailed by G. </p>
				<p>A possible solution &#956; is a <em>solution for BGP from G under RDFS entailment</em> if </p>
				<p>(C1) each subject s of a triple ( s, p, o ) in P(BGP) occurs in the <a href="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes" class="external text" title="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes">scoping graph</a> and </p>
				<p>(C2) each blank node b in the range of &#956; and &#963; occurs in the <a href="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes" title="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes">scoping graph</a> SG.</p>
				</td>
			</tr>
			</tbody>
			</table>
			</div>
			<p>As under RDF entailment, we use a two-stage process to define what legal answers under RDFS entailment are. Possible answers are all answers that one would expect under RDFS entailment, i.e., all mappings such that instantiating the basic graph patterns with them results in RDF triples that are RDFS entailed by the queried graph. The set of possible answers is, however, not necessarily finite. To obtain always a finite set of answers, the next step defines which of the possible answers are actually to be returned as answers to the query and we restrict answers so that we only return finitely many of the axiomatic triples (C1) and return no answers that are equivalent to other answers and just contain fresh blank nodes that were created by applications of RDFS entailment rules (C2). </p>
			<p>Please note that this definition of answers works well with the sound and complete entailment algorithm for RDFS as proposed by ter Horst <bibref ref="RDFSENTAILMENT"/> and guarantees interoperability between systems independent of the intermediate and possibly redundant consequences that different systems might add or avoid to add.</p>
			
			<div3><head>Examples for the Restrictions on Solutions (Informative)</head>
				<p>For RDFS entailment, we consider an example that uses RDFS entailment to derive implicit consequences and we also consider a query with blank nodes in it. The active graph in this example is for the triples</p>
<codeeg>_:a ex:s _:b1 . 
_:a ex:t _:b2 . 
ex:s rdfs:subPropertyOf ex:r . </codeeg>
				<p>The scoping graph is again assumed to be the the same as the active graph. The query is</p>
				<codeeg>SELECT&nbsp;?x WHERE {&nbsp;?x ex:r _:a . }</codeeg>
				<p>We deliberately use a blank node in the query that has the same label as one of the blank nodes in the active graph. Since we consider RDFS entailment, the active graph entails a number of interesting triples such as </p>
<codeeg>_:a ex:r _:b1 . 
_:aa ex:r _:b1 . 
_:a ex:r _:b11 . 
_:aa ex:r _:b11 . </codeeg>
				<p>just to name some. The active graph does, however, not entail</p>
				<codeeg> _:x ex:r _:a . </codeeg>
				<p>since it is not the case that every RDFS interpretation must map <code>_:a</code> to an element that is the <code>ex:r</code> successor of something. The graph does also not entail </p>
				<codeeg>_:a ex:s _:b2 . </codeeg>
				<p>since <code>ex:t</code> is not a subproperty of <code>ex:s</code>.</p>
				<p>From the entailed triples, we get a number of possible solutions, e.g., </p>
<codeeg>P<sub>1</sub>=(&#956;<sub>1</sub>, &#963;<sub>1</sub>) with &#956;<sub>1</sub>&nbsp;: x-&gt;_:a and &#963;<sub>1</sub>&nbsp;: _:a-&gt;_:b1, 
P<sub>2</sub>=(&#956;<sub>2</sub>, &#963;<sub>2</sub>) with &#956;<sub>2</sub>&nbsp;: x-&gt;_:aa and &#963;<sub>2</sub>&nbsp;: _:a-&gt;_:b1, 
P<sub>3</sub>=(&#956;<sub>3</sub>, &#963;<sub>3</sub>) with &#956;<sub>3</sub>&nbsp;: x-&gt;_:a and &#963;<sub>3</sub>&nbsp;: _:a-&gt;_:b11, 
P<sub>4</sub>=(&#956;<sub>4</sub>, &#963;<sub>4</sub>) with &#956;<sub>4</sub>&nbsp;: x-&gt;_:aa and &#963;<sub>4</sub>&nbsp;: _:a-&gt;_:b11, </codeeg>
				<p>etc., but we do not get P=(&#956;, &#963;) with &#956;&nbsp;: x-&gt;<code>_:x</code> and &#963;&nbsp;: <code>_:a</code>-&gt;<code>_:a</code> since P(BGP) is not entailed by the scoping graph as argued above. To be solutions, the possible solution have to satisfy C1 and C2:</p>
				<p>(C1) each subject s of a triple ( s, p, o ) in P(BGP) occurs in the <a href="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes" class="external text" title="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes">scoping graph</a> and</p>
				<p>(C2) each blank node b in the range of &#956; and &#963; occurs in the <a href="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes" class="external text" title="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes">scoping graph</a> SG. </p>
				<p>Here we have </p>
<codeeg>P<sub>1</sub>(BGP)=_:a ex:r _:b1 . 
P<sub>2</sub>(BGP)=_:aa ex:r _:b1 . 
P<sub>3</sub>(BGP)=_:a ex:r _:b11 . 
P<sub>4</sub>(BGP)=_:aa ex:r _:b11 . </codeeg>
				<p>and P<sub>1</sub> and P<sub>3</sub> do satisfy condition C1, but condition C2 rules out P<sub>3</sub> and we have a single answer <code>{ (x, _:a) }</code> from P<sub>1</sub>. 
				Interestingly, it is not the case that the result of instantiating the BGP <code>?x ex:r _:a</code> with the solution mapping (<code>_:a ex:r _:a</code>) results in a triple that is RDFS entailed by the active graph because we would have to use an appropriate RDF instance mapping too. Such an instance mapping, e.g., &#963;<sub>1</sub>, maps <code>_:a</code> from the BGP to a suitable blank node in the scoping graph. Although the label <code>_:a</code> is used in the BGP and in the queried graph, the semantics of blank nodes and their local scope means that the two labels are not required to refer to the element. We can equally use the query </p>
				<codeeg>SELECT&nbsp;?x WHERE {&nbsp;?x ex:r []. }.</codeeg>
				<p>We only need names for the blank nodes in the query to enforce co-references. E.g., in the query</p>
				<codeeg>SELECT&nbsp;?x WHERE {&nbsp;?x ex:r _:b . _:b ex:s ex:a. }.</codeeg>
				<p>we ask for elements that start an <code>ex:r ex:s</code> chain. If the queried graph contains also a blank node <code>_:b</code>, then the name <code>_:b</code> in the query is, however, not necessarily mapped to the same element as the <code>_:b</code> in the queried graph.</p>
				<p>We can consider the above example again, but this time with a scoping graph that does use different names for the blank nodes in the active graph and the query. E.g., assume that the scoping graph SG contains the triples</p>
<codeeg>_:sga ex:s _:sgb1 . 
_:sga ex:t _:sgb2 . 
ex:s rdfs:subPropertyOf ex:r . </codeeg>
				<p>The query is again</p>
				<codeeg>SELECT&nbsp;?x WHERE {&nbsp;?x ex:r _:a . }</codeeg>
				<p>The scoping graph entails a number of intersting triples such as </p>
<codeeg>_:sga ex:r _:sgb1 . 
_:aa ex:r _:b1 . 
_:sga ex:r _:b11 . 
_:aa ex:r _:b11 . </codeeg>
				<p>just to name some. The scoping graph does, however, not entail</p>
				<codeeg> _:x ex:r _:sga . </codeeg>
				<p>since it is not the case that every RDFS interpretation must map <code>_:sga</code> to an element that is the <code>ex:r</code> successor of something. The graph does also not entail </p>
				<codeeg>_:sga ex:s _:sgb2 . </codeeg>
				<p>since <code>ex:t</code> is not a subproperty of <code>ex:s</code>.</p>
				<p>From the entailed triples, we get a number of possible solutions, e.g., </p>
<codeeg>P<sub>1</sub>=(&#956;<sub>1</sub>, &#963;<sub>1</sub>) with &#956;<sub>1</sub>&nbsp;: x-&gt;_:sga and &#963;<sub>1</sub>&nbsp;: _:a-&gt;_:sgb1, 
P<sub>2</sub>=(&#956;<sub>2</sub>, &#963;<sub>2</sub>) with &#956;<sub>2</sub>&nbsp;: x-&gt;_:aa and &#963;<sub>2</sub>&nbsp;: _:a-&gt;_:sgb1, 
P<sub>3</sub>=(&#956;<sub>3</sub>, &#963;<sub>3</sub>) with &#956;<sub>3</sub>&nbsp;: x-&gt;_:sga and &#963;<sub>3</sub>&nbsp;: _:a-&gt;_:b11, 
P<sub>4</sub>=(&#956;<sub>4</sub>, &#963;<sub>4</sub>) with &#956;<sub>4</sub>&nbsp;: x-&gt;_:aa and &#963;<sub>4</sub>&nbsp;: _:a-&gt;_:b11, </codeeg>
				<p>etc., but we do not get P=(&#956;, &#963;) with &#956;&nbsp;: x-&gt;<code>_:x</code> and &#963;&nbsp;: <code>_:a</code>-&gt;<code>_:sga</code> since P(BGP) is not entailed by the scoping graph as argued above. To be solutions, the possible solution have to satisfy C1 and C2:</p>
				<p>(C1) each subject s of a triple ( s, p, o ) in P(BGP) occurs in the <a href="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes" class="external text" title="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes">scoping graph</a> and</p>
				<p>(C2) each blank node b in the range of &#956; and &#963; occurs in the <a href="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes" title="http://www.w3.org/TR/rdf-sparql-query/#BGPsparqlBNodes">scoping graph</a> SG.</p> 
				<p>Here we have </p>
<codeeg>P<sub>1</sub>(BGP)=_:sga ex:r _:sgb1 . 
P<sub>2</sub>(BGP)=_:aa ex:r _:sgb1 . 
P<sub>3</sub>(BGP)=_:sga ex:r _:b11 . 
P<sub>4</sub>(BGP)=_:aa ex:r _:b11 . </codeeg>
				<p>and P<sub>1</sub> and P<sub>3</sub> do satisfy condition C1, but condition C2 rules out P<sub>3</sub> and we again have a single answer <code>{ (x, _:sga) }</code> from P<sub>1</sub>.</p>
				
				For clarity, implementors are encouraged to rename blank node labels such that blank node labels used in the BGP are not the same as blank nodes in solution mappings. This is not required for correctness, but can help users to understand the answers better. 
			</div3>
			
			<div3><head>Inconsistencies (Informative)</head>
				<p>An RDFS-inconsistent graph <a href="http://www.w3.org/TR/rdf-mt/#rdfs_entailment" title="http://www.w3.org/TR/rdf-mt/#rdfs_entailment">RDFS-entails</a> any graph, but there are limited possibilities to express an inconsistency in RDFS. Every inconsistency is due to a literal of type rdf:XMLLiteral, where the lexical form is a mal-formed XML string, e.g., </p>
				<codeeg>ex:a ex:b "&lt;"^^rdf:XMLLiteral .</codeeg>
				<p>in combination with a range restriction on the property, e.g., </p>
				<codeeg>ex:b rdfs:range rdf:XMLLiteral .</codeeg>
				<p>The first triple alone does not cause an inconsistency. It only requires that the literal <code>"&lt;"^^rdf:XMLLiteral</code> is interpreted as something that is not in the extension of <code>rdfs:Literal</code>. Since <code>rdfs:Literal</code> contains <code>rdf:XMLLiteral</code>, the second triple together with the first one results in an inconsistency. The following example illustrates that an inconsistency is not always as directly visible as in the example above and one might need to apply some inference rules to detect it. E.g., consider the following triples (numbers are only given to explain the inferences later):</p>
<codeeg>(1) ex:a rdfs:subClassOf rdfs:Literal .
(2) ex:b rdfs:range ex:a .
(3) ex:c rdfs:subPropertyOf ex:b.
(4) ex:d ex:c "&lt;"^^rdf:XMLLiteral .</codeeg>
				<p>Here we can to derive the inconsistency as follows: </p>
<codeeg>(6) ex:d ex:b "&lt;"^^rdf:XMLLiteral .    (by applying <a href="http://www.w3.org/TR/rdf-mt/#RDFSRules" title="http://www.w3.org/TR/rdf-mt/#RDFSRules">rule rdfs7</a> to (3) and (4))
(7) "&lt;"^^rdf:XMLLiteral rdf:type ex:a.   (by applying <a href="http://www.w3.org/TR/rdf-mt/#RDFSRules" title="http://www.w3.org/TR/rdf-mt/#RDFSRules">rule rdfs3</a> to (2) and (6))
(8) "&lt;"^^rdf:XMLLiteral rdf:type rdfs:Literal .   (by applying <a href="http://www.w3.org/TR/rdf-mt/#RDFSRules" title="http://www.w3.org/TR/rdf-mt/#RDFSRules">rule rdfs9</a> to (1) and (7))</codeeg>
				<p>At this point, we can detect the inconsistency since <code>"&lt;"</code> is not a valid lexical form for an RDF XML literal and we have to interpret it as some element tha is NOT in <code>rdfs:Literal</code>, but at the same time it should be of type <code>rdfs:Literal</code>. The triple derived last is characteristic for an RDFS inconsistency. </p>

				<ednote><date>14/10/2009</date><edtext>
					<h4>Effects of Unchecked Inconsistencies</h4>
					<p>Please note that the above definition of the RDFS entailment regimes does not require that systems <rfc2119>MUST</rfc2119> generate an error or a warning in the case of an inconsistency, but systems <rfc2119>MAY</rfc2119> generate an error or warning. A system <rfc2119>SHOULD</rfc2119> generate such an error or warning if, in the course of processing, it determines that the data or query is not compatible with the request. Thus, it can happen that we query an inconistent graph and get a (finite) answer sequence as a result although such a graph would in fact (trivially) entail any RDF triple. This was to allow for more efficient implementations. Consider, for example, a default graph containing the following triples</p>
<codeeg>ex:b ex:s ex:y<sub>1</sub> .
ex:b ex:s ex:y<sub>2</sub> .
...
ex:b ex:s ex:y<sub>10000</sub> .
ex:a ex:d "&lt;"^^rdf:XMLLiteral .
ex:d rdfs:range rdf:XMLLiteral . </codeeg>
					<p>and a query</p>
					<codeeg>SELECT * WHERE { ex:b ex:r ?x . ?x ex:s ?y . }</codeeg>
					<p>which requires a join operation in the query processor. This graph is RDFS-inconsistent due to the last two triples, but the query processor might know (after parsing) that there is no ex:r property at all in the graph. Thus, the processor knows that it does not have to evaluate the query, but a required check for consistency can be very costly (there could be more than 10,000 <code>ex:b ex:s ex:y<sub>n</sub></code> tuples) and after a possibly long time the user would get an error. </p>
					<p>Another motivation comes from queries that require a union. For example, the query </p>
					<codeeg>SELECT * WHERE { {BGP1} UNION {BGP2} }</codeeg>
					<p>can be executed by dispatching BGP1 and BGP2 in parallel to some processing element, streaming results back to the caller from either side of the UNION as they become available. Since the use of HTTP for streaming back results places some constraints on what can be done, e.g., the error or success code must be transmitted before results start, at the point where a query processor might discover the inconsistency it might be too late for a conformant way of communicating this to the client. </p>
					<p>A consequence of not requiring a consistency check is that in the case of an inconsistency, not all conditions on extensions of basic graph pattern matching are satisfied. For example, the first condition </p>
                    <glist><gitem>
					<def>The scoping graph, SG, corresponding to any consistent active graph AG is uniquely specified and is E-equivalent to AG.</def>
                    </gitem></glist>
					<p>explicitly mentions that the scoping graph must be E-equivalent (RDFS equivalent in this case) to the active graph and that AG must be consistent. Clearly that is not possible if the active graph is inconsistent. One way around this would be to specify an entailment regimes for a subset of RDFS that cannot express inconsistencies, e.g., be defining well-formed graphs for the regime as those that contain only syntactically valid rdf XML literals. Any graph with an invalid RDF XML literal can be rejected for that regime. This requires just a syntactic check and all legal graphs for the regime will be consistent. </p>
					<p>We could also define different two RDFS regimes, one for systems that guarantee a consistency check and one for systems that cannot give this guarantee. A system without such a guarantee allows for a more efficient implementation. A system with such a guarantee is satisfying the conditions on extending basic graph pattern matching, is closer to RDFS entailment as it is defined, and allows users to detect and repair problems (usually inconsistencies are unintended), for a higher cost of implementation and a possibly slower response time in general. </p>
				</edtext></ednote>
			</div3>
		</div2>
		
		<div2><head>D-Entailment Regime</head>
			<ednote><date>14/10/2009</date><edtext>D-Entailment is just a hook at the moment... </edtext></ednote>
			<p></p>
			<div style="text-align: left;">
  			<table style="border-color: rgb(0, 0, 0); border-collapse: collapse;" border="1" cellpadding="5">
			<tbody>
			<tr>
				<th>Name</th><td>D-Entailment</td>
			</tr>
			<tr>
				<th>Legal Graphs</th><td>Any legal RDF graph.</td>
			</tr>
			<tr>
				<th>Legal Queries</th><td>Any legal SPARQL query.</td>
			</tr>
			<tr>
				<th>Illegal handling</th><td>In case the query or the queried graph is illegal (syntax errors), the system <rfc2119>MUST</rfc2119> raise an error.</td>
			</tr>
			<tr>
				<th>Entailment</th><td><a href="http://www.w3.org/TR/rdf-mt/#D_entailment" title="http://www.w3.org/TR/rdf-mt/#D_entailment">D-Entailment</a></td>
			</tr>
			<tr>
				<th>Inconsistency</th><td>TBD</td>
			</tr>
			<tr>
				<th>Query Answers</th><td>TBD</td>
			</tr>
			</tbody>
			</table>
			</div>
		</div2>
		
		<div2><head>OWL 2 RDF-Based Semantics Entailment Regime</head>
			<ednote><date>14/10/2009</date><edtext>OWL 2 RDF-Based Semantics is just a hook at the moment (covers OWL 2 Full and OWL 2 RL)... </edtext></ednote>
			<p></p>
			<div style="text-align: left;">
  			<table style="border-color: rgb(0, 0, 0); border-collapse: collapse;" border="1" cellpadding="5">
			<tbody>
			<tr>
				<th>Name</th><td>OWL 2 RDF-Based Semantics</td>
			</tr>
			<tr>
				<th>Legal Graphs</th><td>Any legal RDF graph.</td>
			</tr>
			<tr>
				<th>Legal Queries</th><td>Any legal SPARQL query.</td>
			</tr>
			<tr>
				<th>Illegal handling</th><td>In case the query or the queried graph is illegal (syntax errors), the system <rfc2119>MUST</rfc2119> raise an error.</td>
			</tr>
			<tr>
				<th>Entailment</th><td><a href="http://www.w3.org/TR/owl2-rdf-based-semantics/" title="http://www.w3.org/TR/owl2-rdf-based-semantics/">OWL 2 RDF-Based Semantics</a></td>
			</tr>
			<tr>
				<th>Inconsistency</th><td>TBD</td>
			</tr>
			<tr>
				<th>Query Answers</th><td>TBD</td>
			</tr>
			</tbody>
			</table>
			</div>
		</div2>
		
		<div2><head>OWL 2 Direct Semantics Entailment Regime</head>

			<p>For the OWL 2 Direct Semantics entailment regime, semantic conditions are defined with respect to ontology structures (i.e., instances of the <b>Ontology</b> class as defined in the OWL 2 Syntax specification <bibref ref="OWL2"/>). Given an RDF graph G, the ontology structure for G, denoted O(G), is obtained by <a href="http://www.w3.org/TR/owl2-mapping-to-rdf/#Mapping_from_RDF_Graphs_to_the_Structural_Specification">mapping the queried RDF graph into an OWL 2 ontology</a> <bibref ref="RDF2OWLMAPPING"/>. This mapping is only defined for OWL 2 DL ontologies, i.e., ontologies that certify certain syntactic conditions. </p>
			<p>An OWL DL ontology contains a set of axioms and each axiom can correspond to several RDF triples. The RDF triples might contain auxiliary blank nodes that are no longer visible in the obtained ontology structure. E.g., the axiom</p> 
<codeeg>ClassAssertion(ObjectSomeValuesFrom(:hasFather :Person) :Peter)</codeeg> 
			<p>corresponds to the RDF triples</p>  
<codeeg>:Peter rdf:type _:x . 
_:x rdf:type owl:Restriction .
_:x owl:onProperty :hasFather .
_:x owl:someValuesFrom :Person . 
</codeeg>
			<p>where <code>_:x</code> is an arbitrary blank node. The obtained axioms may still contain blank nodes, but these correspond to OWL individuals that have no explicit names and are called <a href="http://www.w3.org/TR/2009/CR-owl2-syntax-20090611/#Anonymous_Individuals">anonymous individuals</a>. For example, the axiom </p>
<codeeg>ObjectPropertyAssertion(:hasBrother :Peter _:y)</codeeg>
			<p>corresponds to the triple</p>
<codeeg>:Peter :hasBrother _:y .</codeeg>
			<p>While parsing an input document (containing RDF triples) into an OWL ontology, it can be neccessary to rename blank nodes/anonymous individuals and there is no guarantee that the blank node identifier <code>_:y</code> from the above triple is used as identifier for Peter's brother in the ontology structure. Thus, the above RDF triple could also be represented by the OWL axiom</p> 
<codeeg>:Peter :hasBrother _:somethingelse .</codeeg>			      			
			<p>For query answers, we only consider anonymous individuals as possible bindings since other blank nodes have no representation in the resulting ontology structures. </p>
			
			<p>SPARQL is only defined for basic graph patterns that can be instantiated into RDF triples. For OWL 2 Direct Semantics, an extension to BGPs in functional style syntax (FSS) or other popular OWL syntaxes seems natural, but is not part of this specification. </p>
			
			<p>Some RDF triples that are well-formed for OWL 2 DL, are mapped to OWL 2 DL axioms that carry no semantics. If strictly applying the direct semantics, it is not possible to query for any such axioms (triples). Axioms (triples) that carry no semantics are </p>
			<olist>
			  <item>Annotations</item>
			  <item>Entity Declarations</item>
			  <item>Ontology Properties (imports, ontology IRIs)</item>
			</olist>
			<p>Since in particular annotations are important for users and users do want to query for annotations, the OWL 2 Direct Semantics entailment regime uses a combined semantics that treats annotations, entity declarations, and ontology header axioms (containing the ontology IRI or other annotations) with simple entailment semantics, and applies Direct Semantics to all other axioms, i.e., to axioms that carry semantics in OWL 2 DL. Axioms that carry semantics under OWL 2 Direct Semantics are called <emph>logical axioms</emph> and axioms the do not carry semantics are called <emph>non-logical axioms</emph>. </p>
			
			<div style="text-align: left;">
  			<table style="border-color: rgb(0, 0, 0); border-collapse: collapse;" border="1" cellpadding="5">
			<tbody>
			<tr>
				<th>Name</th><td>OWL 2 Direct Semantics</td>
			</tr>
			<tr>
				<th>Legal Graphs</th><td>Any RDF graph which can be mapped into an <a href="http://www.w3.org/TR/2009/CR-owl2-conformance-20090611/#Syntactic_Conformance" title="http://www.w3.org/TR/2009/CR-owl2-conformance-20090611/#Syntactic_Conformance">OWL 2 DL ontology document</a>. </td>
			</tr>
			<tr>
				<th>Legal Queries</th><td>Any legal SPARQL query.</td>
			</tr>
			<tr>
				<th>Illegal handling</th><td>In case the query or the queried graph cannot be parsed (syntax error), the system <rfc2119>MUST</rfc2119> raise an error. If the queried ontology is not an OWL 2 DL ontology, the system <rfc2119>MAY</rfc2119> reject the ontology and raise an error or the system <rfc2119>MAY</rfc2119> use only a subset of the triples in the ontology. In the latter case, the system can be incomplete.</td>
			</tr>
			<tr>
				<th>Entailment</th><td><a href="http://www.w3.org/TR/2009/CR-owl2-conformance-20090611/#Query_Answering_Tool" title="http://www.w3.org/TR/2009/CR-owl2-conformance-20090611/#Query_Answering_Tool">OWL 2 Direct Semantics</a></td>
			</tr>
			<tr>
				<th>Inconsistency</th><td>If the queried ontology is inconsistent under OWL 2 Direct Semantics, the system <rfc2119>MUST</rfc2119> raise an error. </td>
			</tr>
			<tr>
				<th>Query Answers</th>
				<td><p>Let BGP be a basic graph pattern. We use V(BGP) for the set of variables in BGP, AI(BGP) for the set of anonymous individuals in BGP.
				      A <em>pattern instance mapping P for OWL 2 Direct Semantics</em> is a pair (&#956;, &#963;), where &#956; : V -> RDF-T is a solution mapping and &#963; : RDF-B -> RDF-T is an RDF instance mapping. 
                      For P=(&#956;, &#963;) a pattern instance mapping, we denote with <em>&#956;(BGP)</em> the result of replacing each variable v from V(BGP) for which &#956; is defined with &#956;(v). 
                      Similarly, with <em>&#963;(BGP)</em> we denote the result of replacing each anonymous individual i from AI(BGP) for which &#963; is defined with &#963;(i). 
                      We write <em>P(BGP)</em> for the pattern obtained by applying both &#956; and &#963; to BGP, i.e., P(BGP) denotes &#956;(&#963;(BGP)). </p>
   				      <p>Let O be the queried ontology and BGP the basic graph pattern of the query. 
   				      A solution mapping &#956; is a <em>solution for BGP from O under OWL 2 Direct Semantics</em> if 
   				      <olist>
						<item>dom(&#956;) = V(BGP), </item>
						<item>there is a pattern instance mapping P=(&#956;, &#963;) such that</item> 
						<olist>
						  <item>dom(&#963;)=AI(BGP), </item>
						  <item>P(BGP) are well-formed RDF triples that can be parsed into a set of OWL 2 DL axioms Ax or into an OWL 2 DL ontology O<sup>'</sup> containing a set of axioms Ax, and </item>
						  <item>for each axiom ax in Ax such that ax is non-logical or ax contains an annotation, ax is simply entailed by O, and</item>
						  <item>for each logical axiom ax in Ax such that ax does not contain an annotation, ax is entailed by O under the Direct Semantics and
						        there is no v in V(BGP) such that &#956;(v) is contained in the triples that constitute ax and &#956;(v) is from the <a href="http://www.w3.org/TR/owl2-syntax/#IRIs">reserved vocabulary of OWL 2</a>. </item>
						</olist>
					  </olist>
					</p>
				</td>
			</tr>
			</tbody>
			</table>
			</div>
			
			<div3><head>Typing Information</head>
			   <p>If the BGP cannot be instantiated into a complete OWL 2 DL ontology, then it must be possible to instantiate the BGP extended with <code>_:o a owl:Ontology</code> for a fresh blank node <code>_:o</code> into an OWL 2 DL ontology or the BGP will result in an empty answer. Thus, the requirements for declarations as for OWL 2 DL ontologies also apply to BGPs. </p>
			   <p>For axioms to be parsed into an OWL 2 DL ontology or from a BGP, the types of resources must be clear. This is why there must be a declaration for each property in an ontology. E.g., from the triple <code>:a :r :b.</code> it is not clear whether <code>:r</code> is an object or an annotation property. Depending on the type, the triple would be parsed as <code>ObjectPropertyAssertion(:r :a :b)</code> or <code>AnnotationAssertion(:r :a :b)</code>, but without type information the triple cannot be mapped into an OWL object. If the predicate is not a variable, then one could use the queried ontology to determine the type of <code>:r</code>. If the BGP contains a triple such as <code>:a ?p ?o</code>, however, this is not possible. It is required, therefore, that the BGP also contains the required declaration, i.e., a BGP such as <code>:a ?p ?o . ?p a owl:ObjectProperty .</code> is a valid and parsable BGP. </p> 
			</div3>
			
			<div3><head>Parsing Basic Graph Pattern for Direct Semantics</head>
			   <ednote><date>17/11/2009</date><edtext>Parsing becomes a bit of a nightmare: <code>SELECT ?x ?type WHERE { ?x rdf:type ?type }</code> has answers from declarations under simple entailment and from class instance queries under Direct Semantics. E.g., <code>?x/:C, ?type/owl:Class</code> results in the triple <code>:C rdf:type owl:Class</code>, which is <code>Declaration(Class(:C))</code> in FSS and should be checked with simple entailment, whereas <code>?x/:a, ?type/:C</code> results in the triple <code>:a rdf:type :C</code>, which is <code>ClassAssertion(:C :a)</code> in FSS and should be checked with Direct Semantics. Maybe we have to parse the query twice: once to generate non-logical axioms and once to generate logical axioms. We can then union/join the answers together. </edtext></ednote>
			   <p></p> 
			</div3>
			
			<div3><head>Blank Nodes in the Query and in the Answer (Informative)</head>
			<p>Anonymous individuals can be used in the solution mapping. For example, let O be an ontology containing the axioms</p>
<codeeg>ClassAssertion(:Person :Peter)
ClassAssertion(:Person _:1)
ObjectPropertyAssertion(:hasBrother _:1 _:2)
ObjectPropertyAssertion(:hasBrother _:1 _:Peter)</codeeg>
			<p>The query for O is</p>
<codeeg>SELECT ?x WHERE { ?x rdf:type :Person . }</codeeg>
			<p>An anonymous or named individual i is in the solution sequence as binding for ?x if O entails <code>ClassAssertion(:Person i)</code>, where <code>ClassAssertion(:Person i)</code> is the ontology axiom that corresponds to the triple <code>i rdf:type :Person</code>. Consider the following pattern instance mappings each for the empty RDF instance mapping &#963; : {} -&gt; {}:</p>
<codeeg>P<sub>1</sub>=(&#956;<sub>1</sub>, &#963;) with &#956;<sub>1</sub>&nbsp;: x-&gt;:Peter, 
P<sub>2</sub>=(&#956;<sub>2</sub>, &#963;) with &#956;<sub>2</sub>&nbsp;: x-&gt;_:1, 
P<sub>3</sub>=(&#956;<sub>3</sub>, &#963;) with &#956;<sub>3</sub>&nbsp;: x-&gt;_:2, 
P<sub>4</sub>=(&#956;<sub>4</sub>, &#963;) with &#956;<sub>4</sub>&nbsp;: x-&gt;_:neither1nor2, </codeeg>
			<p>Applied to the BGP <code>?x rdf:type:Person</code> of the query this yields (in the form of OWL axioms)</p>
<codeeg>P<sub>1</sub>(BGP)=ClassAssertion(:Person :Peter), 
P<sub>2</sub>(BGP)=ClassAssertion(:Person _:1), 
P<sub>3</sub>(BGP)=ClassAssertion(:Person _:2), 
P<sub>4</sub>(BGP)=ClassAssertion(:Person _:neither1nor2).</codeeg>
			<p>The ontology O entails P(BGP) if and only if each model of O that interprets also the vocabulary of the query is a model for P(BGP). Thus, &#956;<sub>1</sub> is a solution. Similarly, &#956;<sub>2</sub> is a solution. For P<sub>3</sub>(BGP), we can build a model for O that interprets <code>_:2</code> as an element that does not belong to the interpretation of the class <code>:Person</code> and  &#956;<sub>3</sub> is not a solution. Finally,  &#956;<sub>4</sub> is also not a solution since <code>_:neither1nor2</code> can also be interpreted as an element that does not belong to the extension of the class <code>:Person</code>.</p>
			<p>Thus, the solution sequence contains two solutions: <code>(x, :Peter)</code> and <code>(x, _:1)</code>. This illustrates that anonymous individuals can be returned as part of the answer and that the anonymous individuals from the queried ontology behave like named individuals. It should be noted, however, that the RDF graph or input document from which the ontology O was built does not have to contain the blank nodes <code>_:1</code> and <code>_:2</code>. These blank nodes could have used different identifiers, e.g., <code>_:x</code> and <code>_:y</code>. </p>
			
			<p>Anonymous individuals in the query play a slightly different role. For example, the query</p>
<codeeg>SELECT ?x WHERE { ?x :hasBrother _:y . }</codeeg>
			<p>for the same ontology O as above has a single answer <code>(x, _:1)</code>. Since the anonymous individual <code>_:1</code> is the only individual occurring in the subject position for the <code>:hasBrother</code> predicate, the only reasonable solution mapping is &#956;&nbsp;: x-&gt;<code>_:1</code>. For &#956; to be a solution, there has to be an RDF instance mapping and &#963;<sub>1</sub> : <code>_:y</code> -&gt; <code>:Peter</code> or &#963;<sub>2</sub> : <code>_:y</code> -&gt; <code>_:2</code> could both be used. Although there are two possible instance mappings, the cardinality of the solution sequence is one.  </p>
			<p>Using the same blank nodes in the query and in the ontology has no effect on the query answer, although for clarity we assume that the ontology is obtained from a scoping graph that uses only blank nodes that do not occur in the query and in the input RDF graph. If we assume that the query has the BGP <code>?x :hasBrother _:1</code>, the answer is still as before since we can use the RDF instance mapping &#963; : <code>_:1</code> -&gt; <code>:Peter</code> or &#963; : <code>_:1</code> -&gt; <code>_:2</code>. </p> 
			</div3>
			
			<div3><head>Relationship with First-Order Conjunctive Queries (Informative)</head>
			<p>The semantics of SPARQL queries under OWL 2 Direct Semantics is slightly different from the standard First-Order conjunctive query semantics. For standard First-Order semantics, one would not use an RDF instance mapping but map from anonymous individuals (blank nodes) in the query to elements of the object and data domain for each model of O:</p>
			<def>A solution mapping &#956; is a <em>solution for BGP from O under OWL 2 Direct Semantics</em> if dom(&#956;) = V(BGP), &#956;(BGP) are well-formed RDF triples that can be parsed into a set of OWL 2 DL axioms Ax, and, for each model I of O, there is a mapping &#963; from AI(BGP) to the union of the object and the data domain such that dom(&#963;)=AI(BGP) and I is a model for P(BGP) with P=(&#956;, &#963;).</def> 
			<p>At the time of writing it is unknown whether conjunctive query entailment is decidable under this semantics and the SPARQL semantics seams a more natural choice that allows for practical implementations.</p>  
			</div3>
			
			<div3><head>Data Properties and Literals</head>
			    <p>Without restrictions on the use of <em>owl:topDataProperty</em> that connects all objects with all literals, queries such as</p>  
<codeeg>SELECT ?o, ?d WHERE { ?o owl:TopObjectProperty ?d }</codeeg>
				<p>would result in infinite solutions. Unlike for RDF and RDFS entailment, where restrictions are placed on possible solutions to restrict the set of actual solutions to a finite set, OWL 2 itself defines restrictions that guarantee finite answers. 
				  For <em>owl:topDataProperty</em>, the <a href="http://www.w3.org/TR/owl2-syntax/#The_Restrictions_on_the_Axiom_Closure">following requirement</a> has to be met:</p> 
				<def>The <em>owl:topDataProperty</em> property occurs in Ax only in the <b>superDataPropertyExpression</b> part of <b>SubDataPropertyOf</b> axioms.</def>
				<p>Thus, any solution mapping applied to the BGP <code>?o owl:TopObjectProperty ?d</code> results in an RDF triple that <em>cannot</em> be parsed into an OWL 2 DL axiom as required for the solution mapping to be a solution.</p>
				
				<p>Under OWL 2 Direct Semantics individuals can be related to a data value although this is not explicitly stated and the actual value might not occur in any axiom of the ontology. For example an ontology containing the axioms</p>
<codeeg>ClassAssertion(DataSomeValuesFrom(:hasAge DatatypeRestriction( xsd:int xsd:minExclusive "17"^^xsd:int ))  :Peter )
ClassAssertion(:Minor :Peter)
SubClassOf(Minor DataAllValuesFrom(:hasAge DatatypeRestriction( xsd:int xsd:maxExclusive "19"^^xsd:int )))</codeeg> 
				<p>entails <code>DataPropertyAssertion(:hasAge :Peter "18"^^xsd:int)</code>. 
				Since there are infinitely many integers, a SPARQL endpoint cannot answer a query with BGP <code>:Peter :hasAge ?x . :hasAge a owl:DataProperty .</code> by replacing all possible integer values for ?x and then testing entailment. It is also not possible to restrict candidate bindings to the set of data values that occur explicitly in the queried ontology since "18" does not occur in the ontology. 
				One can, however, built one (arbitrary) model for the queried ontology (which is part of any consistency test) and from that model one can identify a finite set of candidate solutions. This finite set of candidates can be used to find the actual solutions for the query. </p>
			</div3>
			
			<div3><head>Higher Order Queries</head>
				<p>The defined semantics allows for certain forms of higher order queries. For example, one can use the BGP <code>?x rdfs:subClassOf ?y</code> to query for pairs of sub- and superclass. 
				  Queries in which variables are used in positions that would require bindings from the OWL 2 reserved vocabulary will have an empty answer. 
				  This applies to variables that occur in the position of quantifiers. For example, the following query asks whether <em>some</em> or <em>all</em> brothers of Peter are persons:</p>
<codeeg>SELECT ?x WHERE {
   :Peter rdf:type _:x . 
   _:x rdf:type owl:Restriction .
   _:x owl:onProperty :hasBrother .
   _:x ?x :Person . 
   :hasBrother a owl:ObjectProperty . 
} 
</codeeg>
                <p>In functional-style syntax this query corresponds to the axiom <code>ClassAssertion( ?x(:hasBrother :Person) :Peter )</code>. 
                Any solution mapping for the above query must map <code>?x</code> to <em>owl:SomeValuesFrom</em> or <em>owl:AllValuesFrom</em> in order to result in a set of triples that can be parsed into an OWL 2 DL ontology. 
                Since the triples in the BGP are parsed into a logical annotation-free axiom, condition 2.d) applies, which forbids mappings that use the reserved vocabulary of OWL and the query has an empty answer. </p> 
			</div3>
			
			<div3><head>Querying for Non-Logical Axioms</head>
				<p>Querying for non-logical axioms is possible due to the combined semantics used for the Direct Semantics entailment regime. 
				For example, if the ontology contains a triple such as <code>ex:myOntology rdf:type owl:Ontology</code> (in FSS <code>Ontology(ex:myOntology ...)</code>), this means that the ontology has IRI <code>ex:myOntology</code>, but the triple <code>ex:myOntology rdf:type owl:Ontology</code> is not entailed by the ontology under Direct Semantics and a query such as</p> 
				<codeeg>SELECT ?ontIRI WHERE { ?ontIRIR a owl:Ontology . }</codeeg> 
				<p>would have no answer when strictly applying the Direct Semantics. Similarly, under strict Direct Semantics it is not possible to query for annotations or declarations.  
				   The above definition of the Direct Semantics entailment regime uses, therefore, a kind of combined semantics. The BGP is to be separated into logical and non-logical parts, then Direct Semantics is applied to the logical parts and simple semantics to the non-logical parts. For logical axioms from the BGP that contain annotations, it only makes sense to apply simple semantics. Even when querying for sub- and superclass pairs from an annotated subclass axiom, it does not make sense to compute inferred pairs of sub- and superclasses since each sub- and superclass binding also has to match under simple entailment, which means all inferred sub- and superclass relationships are filtered out. </p>
				
				<div4><head>Queries for Declarations</head>
				<p>Declarations in FSS have forms such as <code>Declaration(Class(:myClass))</code> or <code>Declaration(AnnotationProperty(:myAnnotationProperty))</code>. In Turtle that is <code>:myClass a owl:Class</code> and <code>:myAnnotationProperty a owl:AnnotationProperty</code>, respectively. A query such as </p>
				<codeeg>SELECT ?name ?type WHERE { ?name a ?type . }</codeeg>
				<p>would not return all declarations since simple entailment is used for non-logical axioms. The query also returns all individuals and their types since the BGP can also be instantiated into <code>ClassAssertion(:C :a)</code> for <code>:C</code> a class and <code>:a</code> an individual (in Turtle <code>:a rdf:type :C</code>). In this case, hwever, Direct Semantics is applied since class assertion axioms are logical axioms.</p>
				</div4>
				
				<div4><head>Queries for the Ontology Properties</head>
				<p>Ontologies can but do not have to have an ontology IRI and a header containing imports or ontology annotations. For an ontology with IRI <code>:myOntology</code>, the RDF triples for the ontology contain <code>:myOntology a owl:Ontology</code>. For an ontology without an IRI, the RDF triples contain a triple <code>_:x a owl:Ontology</code> for <code>_:x</code> some blank node. Thus, a query such as </p>
				<codeeg>SELECT ?ontIRI WHERE { ?ontIRI a owl:Ontology }</codeeg>
				<p>does return the IRI of the ontology or a blank node identifier in case the ontology has no IRI since simple entailment is used. </p>
				</div4>
				
				<div4><head>Queries for Annotations</head>
				<p>In OWL 2 DL several forms of annotations can be used. The ontology header of an ontology with IRI <code>:myOntology</code> can contain annotation such as <code>Annotation(rdfs:comment "This is just a toy ontology")</code> (in Turtle <code>:myOntology rdfs:comment "This is just a toy ontology"</code>). 
				The ontology can further contain annotation assertions such as <code>AnnotationAssertion(rdfs:label "All persons" :Person)</code> (in Turtle <code>:Person rdfs:label "All persons"</code>), which adds a label to the class <code>:Person</code>. 
				Finally, axioms can be annotated. For example the following subclass axiom has a label attached to it via an annotation: <code>SubClassOf(Annotation(rdfs:label "Employees are persons.") :Employee :Person)</code>. The RDF triple version of annotated axioms is quite verbose and uses a fresh blank node to represent the annotaated axiom: </p>
<codeeg>:Employee rdfs:subClassOf :Person .
_:x a owl:Axiom .
_:x owl:AnnotationSource :Employee .
_:x owl:AnnotationProperty rdfs:subClassOf .
_:x owl:AnnotationTarget :Person .
_:x rdfs:label "Employees are persons." .</codeeg>
				<p>In order to retrieve ontology annotations, one can, for example, use the query </p>
				<codeeg>SELECT ?ap ?av WHERE { _:x a owl:Ontology . _:x ?ap ?av }</codeeg>
				<p>where <code>?ap</code> binds to annotation properties and <code>?av</code> to the corresponding annotation values.</p>
				<p>One can also select certain types of axioms with certain annotations, e.g., sub- and superclasses from a subclass axioms that has has a comment:</p>
<codeeg>SELECT ?sub ?sup ?comment WHERE {
     _:x a owl:Axiom .  
     _:x owl:annotatedSource ?sub . 
     _:x owl:annotatedProperty rdfs:subClassOf . 
     _:x owl:annotatedTarget ?sup . 
     _:x rdfs:comment ?comment . 
}</codeeg>
				<p>Apart from the annotations and annotation axioms itself, one can also declare sub- and superproperty relationships between annotation properties, e.g., by stating <code>SubAnnotationPropertyOf(:ap1 :ap2)</code> for two annotation properties <code>:ap1</code> and <code>:ap2</code> (in Turtle <code>:ap1 rdfs:subPropertyOf :ap2</code>), but again such an axiom are non-logical and they have no influence on the consequences of an ontology. 
				Finally, one can declare domain and range restrictions for annoation properties, which are also non-logical axioms. 
				Since only simple entailment is used for such axioms, there are no inferences for sub- and super-annotation properties. 
				E.g., if the ontology contains only the axioms <code>SubAnnotationPropertyOf(:ap1 :ap2)</code> and <code>AnnotationAssertion(:ap1 :Person "Some annotation")</code>, a query for annotation assertions for <code>:ap2</code> will have no answer. </p>
				</div4> 
			</div3>
			
			<div3><head>OWL 2 EL and OWL 2 QL</head>
			  <p>The EL and the QL profiles of OWL 2 are also defined for Direct Smeantics.     
			  OWL 2 EL is particularly useful in applications employing ontologies that contain very large numbers of properties and/or classes. The profile captures the expressive power used by many such ontologies and is a subset of OWL 2 DL for which the basic reasoning problems can be performed in time that is polynomial with respect to the size of the ontology. 
			  OWL 2 QL is aimed at applications that use very large volumes of instance data, and where query answering is the most important reasoning task. In OWL 2 QL, conjunctive query answering can be implemented using conventional relational database systems. Using a suitable reasoning technique, sound and complete conjunctive query answering can be performed in LOGSPACE with respect to the size of the data (assertions). As in OWL 2 EL, polynomial time algorithms can be used to implement the ontology consistency and class expression subsumption reasoning problems.
			  Compared to OWL 2 DL, these two profiles place further restrictions the sets of RDF triples that consitute valid OWL 2 EL and OWL 2 QL ontologies. Thus, systems that support these entailment regimes may reject more inputs than systems that work with all of OWL 2 DL. Consequently, there are also more BGPs that will have an empty answer because the BGP cannot be parsed into axioms that belong to the OWL 2 EL or the OWL 2 QL profile.
			  Nevertheless, OWL 2 DL, EL, and QL can all be used with the Direct Semantics entailment regime. </p>   
			</div3>
		</div2>
		
		
		
		
		
		
		<div2><head>RIF Entailment</head>
			<ednote><date>14/10/2009</date><edtext>RIF Entailment is just a hook at the moment... </edtext></ednote>
			<p></p>
			<div style="text-align: left;">
  			<table style="border-color: rgb(0, 0, 0); border-collapse: collapse;" border="1" cellpadding="5">
			<tbody>
			<tr>
				<th>Name</th><td>RIF</td>
			</tr>
			<tr>
				<th>Legal Graphs</th><td>TBD</td>
			</tr>
			<tr>
				<th>Legal Queries</th><td>Any legal SPARQL query.</td>
			</tr>
			<tr>
				<th>Illegal handling</th><td>In case the query or the queried graph is illegal (syntax errors), the system <rfc2119>MUST</rfc2119> raise an error.</td>
			</tr>
			<tr>
				<th>Entailment</th><td>TBD</td>
			</tr>
			<tr>
				<th>Inconsistency</th><td>TBD</td>
			</tr>
			<tr>
				<th>Query Answers</th><td>TBD</td>
			</tr>
			</tbody>
			</table>
			</div>
		</div2>
	</div1>
	
	<div1><head>Entailment Regimes and Data Sets (Informative)</head>
		<p>Many RDF data stores hold multiple RDF graphs and applications can make queries that involve information from more than one graph. In this section we clarify how entailment regimes behave in the presence of named graphs. </p>
		<p>As defined in the SPARQL specification, a SPARQL query is executed against an <a href="http://www.w3.org/TR/rdf-sparql-query/#rdfDataset" title="http://www.w3.org/TR/rdf-sparql-query/#rdfDataset">RDF Dataset</a> which represents a collection of graphs. An RDF Dataset comprises one graph, the default graph, which does not have a name, and zero or more named graphs, where each named graph is identified by an IRI. The graph that is used for matching a basic graph pattern is the active graph. Under an entailment regime E other than simple entailment, we do not only consider the triples that are in the graph, but also triples that are E-entailed by the graph. The entailed triples must, however, be E-entailed by the active graph and not by a merge of the triples in all graphs. This follows from conditions conditions 1 and 3 of the <a href="http://www.w3.org/TR/rdf-sparql-query/#sparqlBGPExtend" class="external text" title="http://www.w3.org/TR/rdf-sparql-query/#sparqlBGPExtend">conditions on extensions for basic graph matching</a>. </p>
		<p>For an example, we consider a data set with consists of an empty default graph, a named graph graphA with IRI <code>http://example.org/a.rdf</code>, and a named graph graphB with IRI <code>http://example.org/a.rdf</code>. The named graphs contain the following data:</p>
		<p><code>http://example.org/a.rdf:</code></p>
		<codeeg>ex:p rdfs:domain ex:A .</codeeg>
		<p><code>http://example.org/b.rdf:</code></p>
		<codeeg>ex:x ex:p ex:y .</codeeg>
		<p>If we ask the following query under RDFS entailment</p>
		<codeeg>SELECT&nbsp;?g WHERE { GRAPH&nbsp;?g { ex:x a&nbsp;?type . } }</codeeg>
		<p>the answer sequence is empty because neither the default graph, nor the named graphs on their own entail a triple that would provide the required binding for&nbsp;?type. </p>
		<p>In order to evaluate a query over the merge of the triples in the named graphs, one can use several <code>FROM</code> clauses, which result in the creation of a fresh default graph for the query that contains a merge of the triples, e.g., </p>
		<codeeg>SELECT&nbsp;?t FROM &lt;http://example.org/a.rdf&gt; FROM &lt;http://example.org/b.rdf&gt; WHERE { ex:x a&nbsp;?t . } </codeeg>
		<p>has the answer <code>{ (t, ex:A) }</code>. One can not merge triples from several sources into a named graph (they will always be merged into a fresh default graph) and such an extension would require changes to the conditions for extensions of basic graph pattern matching in the existing SPARQL query language specification.</p>
	</div1>
	
	
	</body>
	
	
	
	
	
	
	
	
	
	
	<back>
		<div1><head>Related Issues</head>
			<ul>
				<li>[<a href="http://www.w3.org/2009/sparql/track/issues/28" title="http://www.w3.org/2009/sparql/track/issues/28">ISSUE 28</a>]: Entailment regimes vs. update?</li>
				<li>[<a href="http://www.w3.org/2009/sparql/track/issues/34" title="http://www.w3.org/2009/sparql/track/issues/34">ISSUE 34</a>]: How do entailment regimes interaction with aggregates, grouping, and blank nodes?</li>
				<li>[<a href="http://www.w3.org/2009/sparql/track/issues/40" title="http://www.w3.org/2009/sparql/track/issues/40">ISSUE 40</a>]: How can other entailment regimes plug in their semantics to SPARQL/Update?</li>
				<li>[<a href="http://www.w3.org/2009/sparql/track/issues/42" title="http://www.w3.org/2009/sparql/track/issues/42">ISSUE 42</a>]: TF-ENT What should happen for RDFS entailment in the face of inconsistencies?</li>
				<li>[<a href="http://www.w3.org/2009/sparql/track/issues/43" title="http://www.w3.org/2009/sparql/track/issues/43">ISSUE 43</a>]: should entailment-regimes be declared over the whole dataset or individual graphs?</li>
			</ul>
		</div1>
	
		<!-- &SGML; -->
		<!-- &Biblio; -->
		<div1 id="sec-bibliography">
			<head>References</head>
			<div2 id="sec-existing-stds">
				<head>Normative References</head>
				<blist>
					<bibl id="SPARQL11" href="http://www.w3.org/TR/rdf-sparql-query/" key="SPARQL/Query 1.0"> 
					<titleref>SPARQL Query Language for RDF</titleref>, ed. Eric Prud'hommeaux, Andy Seaborne. W3C Recommendation 15 January 2008. </bibl>
				</blist>
				<blist>
					<bibl id="OWL2" href="http://www.w3.org/TR/owl2-syntax/" key="OWL 2 Specification">
					<titleref>OWL 2 Web Ontology Language Structural Specification and Functional-Style Syntax</titleref>, ed. Boris Motik, Peter F. Patel-Schneider, Bijan Parsia. W3C Recommendation 27 October 2009. </bibl>
				</blist>
				<blist>
					<bibl id="RDF2OWLMAPPING" href="http://www.w3.org/TR/owl2-mapping-to-rdf/" key="OWL 2 Mapping to RDF Graphs">
					<titleref>OWL 2 Web Ontology Language Mapping to RDF Graphs</titleref>, ed. Peter F. Patel-Schneider, Boris Motik. W3C Recommendation 27 October 2009. </bibl>
				</blist>
			</div2>
			<div2 id="null">
				<!--
ID made "null" to match its previous value in the First
Edition; it's odd, but if there's no set value, the stylesheet
currently generates an odd string that would be backwards
incompatible with any references anyone might have made before.
-->
				<head>Other References</head>
				<blist>
					<bibl id="RDFSENTAILMENT" href="http://www.websemanticsjournal.org/papers/20050719/document5.pdf">Herman J. ter Horst
					<titleref>Completeness, decidability and complexity of entailment for RDF Schema and a semantic extension involving the OWL vocabulary</titleref>.
					Journal of Web Semantics, 3(2-3):79-115, 2005.
					</bibl>
					<bibl id="TURTLE" href="http://www.w3.org/TeamSubmission/turtle/">Dave Beckett. 
					<titleref>Turtle - Terse RDF Triple Language</titleref>. W3C Team Submission 14 January 2008.</bibl>
				</blist>
			</div2>
		</div1>
		<div1 id="sec-cvsLog">
			<head>CVS History</head>
			<div2 id="sec-cvsLog-meat">
			</div2>
		</div1>
	</back>
</spec>
