<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="http://www.ruleml.org/1.0/relaxng/datalog_relaxed.rnc"?>
<!--<?xml-model href="http://www.ruleml.org/1.0/xsd/datalog.xsd" type="application/xml" schematypens="http://www.w3.org/2001/XMLSchema"?>-->
<!--<RuleML xmlns="http://ruleml.org/spec"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://ruleml.org/spec http://www.ruleml.org/1.0/xsd/datalog.xsd"> -->

<RuleML xmlns="http://ruleml.org/spec"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xs="http://www.w3.org/2001/XMLSchema">
  
  <!-- This suite of examples about constants deals with the RuleML counterparts to synonyms and homonyms in natural languages.
       The syntax of local symbols permits to introduce short constant names.
       The semantics of local symbols permits to merge documents while avoiding name clashs, as in W3C RDF and RIF.
       A constant consisting of either a local symbol or a global IRI ('webizing') corresponds to rif:local and rif:iri in W3C RIF.
       A constant consisting of both a local symbol and a global IRI can explicitly represent any synonymy or homonymy of the symbol via the IRI.
       When different local symbols are associated with one global IRI, the shared IRI establishes their synonymy.
       When one local symbol is associated with different global IRIs, the various IRIs disambiguate its homonymy.
       The suite systematically varies three kinds of constant (symbol vs. IRI vs. combined) with two kinds of performatives (Assert vs. Query).
       Its predicted Query results serve to constrain the semantics of possibly 'webized' unary predicate constants.
       A similar systematics should also be attempted for types, n-ary predicates/functions, individuals, etc. -->


  <Assert mapClosure="universal">

  <!-- Synonyms: local (unary) predicate symbols -->
 
    <Atom>
      <Rel>car</Rel>
      <Ind>enty1</Ind>
    </Atom>
 
    <Atom>
      <Rel>auto</Rel>
      <Ind>enty2</Ind>
    </Atom>

  </Assert>

  <Query>

    <!-- Query for entities that are cars will retrieve enty1 -->

    <Atom>
      <Rel>car</Rel>
      <Var>?X</Var>
    </Atom>

  </Query>

  <Query>

    <!-- Query for entities that are autos will retrieve enty2 -->

    <Atom>
      <Rel>auto</Rel>
      <Var>?X</Var>
    </Atom>

  </Query>

  <Query>

    <!-- Query for enty1 being an auto will fail -->

    <Atom>
      <Rel>auto</Rel>
      <Ind>enty1</Ind>
    </Atom>

  </Query>

  <Query>

    <!-- Query for enty2 being a car will fail -->

    <Atom>
      <Rel>car</Rel>
      <Ind>enty2</Ind>
    </Atom>

  </Query>

  <Query>

    <!-- Query for entities that are cars, associated with a global IRI, will fail -->

    <Atom>
      <Rel iri="http://example.org/vehicle#automobile">car</Rel>
      <Var>?X</Var>
    </Atom>

  </Query>

  <Query>

    <!-- Query for entities that are autos, associated with a global IRI, will fail -->

    <Atom>
      <Rel iri="http://example.org/vehicle#automobile">auto</Rel>
      <Var>?X</Var>
    </Atom>

  </Query>


  <Assert mapClosure="universal">

  <!-- Synonyms: local (unary) predicate symbols identified through identical global IRI -->

    <Atom>
      <Rel iri="http://example.org/vehicle#automobile">car</Rel>
      <Ind>enty3</Ind>
    </Atom>

    <Atom>
      <Rel iri="http://example.org/vehicle#automobile">auto</Rel>
      <Ind>enty4</Ind>
    </Atom>

  </Assert>

  <Query>

    <!-- Query for entities identified through IRI .../vehicle#automobile, keeping symbol car, will retrieve enty3 -->

    <Atom>
      <Rel iri="http://example.org/vehicle#automobile">car</Rel>
      <Var>?X</Var>
    </Atom>

  </Query>

  <Query>

    <!-- Query for entities identified through IRI .../vehicle#automobile, keeping symbol auto, will retrieve enty4 -->

    <Atom>
      <Rel iri="http://example.org/vehicle#automobile">auto</Rel>
      <Var>?X</Var>
    </Atom>

  </Query>

  <Query>

    <!-- Query for entities identified through IRI .../vehicle#automobile, omitting symbols car and auto, will retrieve enty3 and enty4 -->

    <Atom>
      <Rel iri="http://example.org/vehicle#automobile"/>
      <Var>?X</Var>
    </Atom>

  </Query>

  <Query>

    <!-- Query for entities that are cars, omitting IRI, will retrieve enty1 and enty3 -->

    <Atom>
      <Rel>car</Rel>
      <Var>?X</Var>
    </Atom>

  </Query>

  <Query>

    <!-- Query for entities that are autos, omitting IRI, will retrieve enty2 and enty4 -->

    <Atom>
      <Rel>auto</Rel>
      <Var>?X</Var>
    </Atom>

  </Query>


  <Assert mapClosure="universal">

  <!-- Synonyms: (unary) predicates as identical global IRI -->

    <Atom>
      <Rel iri="http://example.org/vehicle#automobile"/>
      <Ind>enty5</Ind>
    </Atom>

    <Atom>
      <Rel iri="http://example.org/vehicle#automobile"/>
      <Ind>enty6</Ind>
    </Atom>

  </Assert>

  <Query>

    <!-- Query for entities identified through IRI .../vehicle#automobile will retrieve enty3 to enty6 -->

    <Atom>
      <Rel iri="http://example.org/vehicle#automobile"/>
      <Var>?X</Var>
    </Atom>

  </Query>

  <Query>

    <!-- Query for entities identified through IRI .../vehicle#automobile, keeping symbol car, will retrieve enty3 -->

    <Atom>
      <Rel iri="http://example.org/vehicle#automobile">car</Rel>
      <Var>?X</Var>
    </Atom>

  </Query>

  <Query>

    <!-- Query for entities identified through IRI .../vehicle#automobile, keeping symbol auto, will retrieve enty4 -->

    <Atom>
      <Rel iri="http://example.org/vehicle#automobile">auto</Rel>
      <Var>?X</Var>
    </Atom>

  </Query>



  <Assert mapClosure="universal">

  <!-- Homonyms: local (unary) predicate symbols -->
 
    <Atom>
      <Rel>bank</Rel>
      <Ind>thng1</Ind>
    </Atom>
 
    <Atom>
      <Rel>bank</Rel>
      <Ind>thng2</Ind>
    </Atom>

  </Assert>

  <Query>

    <!-- Query for things that are banks will retrieve thng1 and thng2 -->

    <Atom>
      <Rel>bank</Rel>
      <Var>?X</Var>
    </Atom>

  </Query>

  <Query>

    <!-- Query for thng1 being a bank will succeed -->

    <Atom>
      <Rel>bank</Rel>
      <Ind>thng1</Ind>
    </Atom>

  </Query>

  <Query>

    <!-- Query for thng2 being a bank will succeed -->

    <Atom>
      <Rel>bank</Rel>
      <Ind>thng2</Ind>
    </Atom>

  </Query>

  <Query>

    <!-- Query for symbol bank, associated with IRI .../geography#riverbank, will fail -->

    <Atom>
      <Rel iri="http://example.org/geography#riverbank">bank</Rel>
      <Var>?X</Var>
    </Atom>

  </Query>

  <Query>

    <!-- Query for symbol bank, associated with IRI .../finance#savingsbank, will fail -->

    <Atom>
      <Rel iri="http://example.org/financial#savingsbank">bank</Rel>
      <Var>?X</Var>
    </Atom>

  </Query>


  <Assert mapClosure="universal">

  <!-- Homonyms: local (unary) predicate symbols differentiated through different global IRIs -->
 
    <Atom>
      <Rel iri="http://example.org/geography#riverbank">bank</Rel>
      <Ind>thng3</Ind>
    </Atom>
 
    <Atom>
      <Rel iri="http://example.org/financial#savingsbank">bank</Rel>
      <Ind>thng4</Ind>
    </Atom>

  </Assert>

  <Query>

    <!-- Query for things identified through IRI .../geography#riverbank, keeping symbol bank, will retrieve thng3 -->

    <Atom>
      <Rel iri="http://example.org/geography#riverbank">bank</Rel>
      <Var>?X</Var>
    </Atom>

  </Query>

  <Query>

    <!-- Query for things identified through IRI .../finance#savingsbank, keeping symbol bank, will retrieve thng4 -->

    <Atom>
      <Rel iri="http://example.org/financial#savingsbank">bank</Rel>
      <Var>?X</Var>
    </Atom>

  </Query>

  <Query>

    <!-- Query for things identified through IRI .../geography#riverbank, omitting symbol bank, will retrieve thng3 -->

    <Atom>
      <Rel iri="http://example.org/geography#riverbank"/>
      <Var>?X</Var>
    </Atom>

  </Query>

  <Query>

    <!-- Query for things identified through IRI .../finance#savingsbank, omitting symbol bank, will retrieve thng4 -->

    <Atom>
      <Rel iri="http://example.org/financial#savingsbank"/>
      <Var>?X</Var>
    </Atom>

  </Query>


  <Assert mapClosure="universal">

  <!-- Homonyms: local (unary) predicates as different global IRIs -->
 
    <Atom>
      <Rel iri="http://example.org/geography#riverbank"/>
      <Ind>thng5</Ind>
    </Atom>
 
    <Atom>
      <Rel iri="http://example.org/financial#savingsbank"/>
      <Ind>thng6</Ind>
    </Atom>

 </Assert>

  <Query>

    <!-- Query for things identified through IRI .../geography#riverbank will retrieve thng3 and thng5 -->

    <Atom>
      <Rel iri="http://example.org/geography#riverbank"/>
      <Var>?X</Var>
    </Atom>

  </Query>

  <Query>

    <!-- Query for things identified through IRI .../finance#savingsbank will retrieve thng4 and thng6 -->

    <Atom>
      <Rel iri="http://example.org/financial#savingsbank"/>
      <Var>?X</Var>
    </Atom>

  </Query>


  <Assert mapClosure="universal">

  <!-- Homonyms: local (unary) predicate symbols, the second occurrence disambiguated through global IRI -->
 
    <Atom>
      <Rel>bank</Rel>
      <Ind>thng7</Ind>
    </Atom>
 
    <Atom>
      <Rel iri="http://example.org/financial#savingsbank">bank</Rel>
      <Ind>thng8</Ind>
    </Atom>

  </Assert>

  <Query>

    <!-- Query for things that are banks will retrieve thng1 to thng4 as well as thng7 and thng8 -->

    <Atom>
      <Rel>bank</Rel>
      <Var>?X</Var>
    </Atom>

  </Query>

  <Query>

    <!-- Query for things identified through IRI .../geography#riverbank, keeping symbol bank, will retrieve thng3 -->

    <Atom>
      <Rel iri="http://example.org/geography#riverbank">bank</Rel>
      <Var>?X</Var>
    </Atom>

  </Query>

  <Query>

    <!-- Query for things identified through IRI .../finance#savingsbank, keeping symbol bank, will retrieve thng4 as well as thng8 -->

    <Atom>
      <Rel iri="http://example.org/financial#savingsbank">bank</Rel>
      <Var>?X</Var>
    </Atom>

  </Query>

  <Query>

    <!-- Query for things identified through IRI .../geography#riverbank, omitting symbol bank, will retrieve thng3 and thng5 -->

    <Atom>
      <Rel iri="http://example.org/geography#riverbank"/>
      <Var>?X</Var>
    </Atom>

  </Query>

  <Query>

    <!-- Query for things identified through IRI .../finance#savingsbank, omitting symbol bank, will retrieve thng4 and thng6 as well as thng8 -->

    <Atom>
      <Rel iri="http://example.org/financial#savingsbank"/>
      <Var>?X</Var>
    </Atom>

  </Query>


</RuleML>

