Geospatial Rules

From RuleML Wiki
Jump to: navigation, search
Horn Fragments of some RCC Relation Rules in PSOA RuleML:

Document (
  Group (
    Forall ?X ( _ConnectsWith(?X ?X) )
	
    Forall ?X ?Y (
	_ConnectsWith(?X ?Y) :- _ConnectsWith(?Y ?X)
    )
	
    Forall ?X ?Y ?Z (
        _ConnectsWith(?X ?Z) :- 
          And(_ConnectsWith(?X ?Y) 
                  _PartOf(?Y ?Z))
    )

    Forall ?X ?Y ?Z (
        _Overlaps(?X ?Y) :-
          And(_PartOf(?Z ?X) 
                  _PartOf(?Z ?Y))
    )
	 
    Forall ?X ?Y (
        _ExternallyConnectedTo(?X ?Y) :- 
          And(_ConnectsWith(?X ?Y) 
                  _DiscreteFrom(?X ?Y))
    )
	 
    Forall ?X ?Y (
        _ConnectsWith(?X ?Y) :- _ExternallyConnectedTo(?X ?Y)
    )
	
    Forall ?X ?Y (
        _DiscreteFrom(?X ?Y) :- _ExternallyConnectedTo(?X ?Y)
    )
	
    Forall ?X ?Y (
        _EqualTo(?X ?Y) :- 
          And(_PartOf(?X ?Y) 
                 _PartOf(?Y ?X))
    )
	 
    Forall ?X ?Y (
        _PartOf(?X ?Y) :- _ProperPartOf(?X ?Y)
    )

    Forall ?X ?Y (
        _Overlaps(?X ?Y) :- _PartiallyOverlaps(?X ?Y)
    )

    Forall ?X ?Y ?Z (
      _TangentialProperPartof(?X ?Y) :-
        And(_ProperPartOf(?X ?Y)
	        _ExternallyConnectedTo(?Z ?X)
            _ExternallyConnectedTo(?Z ?Y))
    )

    Forall ?X ?Y (
      _InverseProperPartOf(?X ?Y) :- _ProperPartOf(?Y ?X)
    )

    Forall ?X ?Y (
      _ProperPartOf(?Y ?X) :- _InverseProperPartOf(?X ?Y)
    )
	
    Forall ?X ?Y (
      _ProperPartOf(?X ?Y) :- _TangentialProperPartof(?X ?Y)
    )
	
    Forall ?X ?Y (
      _ProperPartOf(?X ?Y) :- _NonTangentialProperPartof(?X ?Y)
    )
	
    Forall ?X ?Y (
      _InverseTangentialProperPartof(?Y ?X) :- _TangentialProperPartof(?X ?Y)
    )
    
    Forall ?X ?Y (
      _TangentialProperPartof(?Y ?X) :- _InverseTangentialProperPartof(?X ?Y)
    )
	
    Forall ?X ?Y (
      _InverseNonTangentialProperPartof(?Y ?X) :- _NonTangentialProperPartof(?X ?Y)
    )

    Forall ?X ?Y (
      _NonTangentialProperPartof(?Y ?X) :- _InverseNonTangentialProperPartof(?X ?Y)
    )
	
    Forall ?X ?Y ?Z (
      _DisconnectedFrom(?X ?Z) :- And(_PartOf(?X ?Y) _DisconnectedFrom(?Y ?Z))
    )

    Forall ?X ?Y ?Z (
      _DiscreteFrom(?X ?Z) :- And(_TangentialProperPartof(?X ?Y) _ExternallyConnectedTo(?Y ?Z))
    )
	
    Forall ?X ?Y ?Z (
      _ProperPartof(?X ?Z) :- And(_TangentialProperPartof(?X ?Y) _TangentialProperPartof(?Y ?Z))
    )

    Forall ?X ?Y ?Z (
      _NonTangentialProperPartof(?X ?Z) :- And(_Partof(?X ?Y) _NonTangentialProperPartof(?Y ?Z))
    )

    Forall ?X ?Y ?Z (
      _DisconnectedFrom(?X ?Z) :- And(_NonTangentialProperPartof(?X ?Y) _ExternallyConnectedTo(?Y ?Z))
    )

    Forall ?X ?Y ?Z (
      _NonTangentialProperPartof(?X ?Z) :- 
         And(_NonTangentialProperPartof(?X ?Y) _TangentialProperPartof(?Y ?Z))
    )

    Forall ?X ?Y ?Z (
      _ProperPartOf(?X ?Z) :- And(_ProperPartOf(?X ?Y) _ProperPartOf(?Y ?Z))
    )
	
    Forall ?X ?Y (
      Or() :- 
        And(_ConnectsWith(?X ?Y) 
            _DisconnectsFrom(?X ?Y))
    )

    Forall ?X ?Y (
      Or() :- And(_DiscreteFrom(?X ?Y) _Overlaps(?X ?Y))
    )

    Forall ?X ?Y (
      Or() :-
         And(_PartiallyOverlaps(?X ?Y) 
             Or( _PartOf(?X ?Y) _PartOf(?Y ?X)))
    )

    Forall ?X ?Y ?Z (
      Or() :-
         And(_NonTangentialProperPartof(?X ?Y)
	     _ExternallyConnectedTo(?Z ?X)
             _ExternallyConnectedTo(?Z ?Y))
    )
 
    Forall ?X ?Y (
      Exists ?Z (And(_PartOf(?Z ?X) _PartOf(?Z ?Y))) :- _Overlaps(?X ?Y)
    )

    Forall ?X ?Y (
      Exists ?Z (
        And (_ExternallyConnectedTo(?Z ?X)
             _ExternallyConnectedTo(?Z ?Y)))
        :- _TangentialProperPartof(?X ?Y)
    )
    
    _ProperPartOf(_USA _NorthAmerica)
    _ProperPartOf(_California _USA)
    _ProperPartOf(_Virginia _USA)
    _ExternallyConnectedTo(_PacificOcean _California)
    _ExternallyConnectedTo(_AtlanticOcean _Virginia)
    _ExternallyConnectedTo(_PacificOcean _USA)
    _ExternallyConnectedTo(_AtlanticOcean _USA)
    _State(_California)
    _State(_Virginia)
    _Ocean(_PacificOcean)
    _Ocean(_AtlanticOcean)

    Forall ?X ?Y ?Z (
      _NearTo(?Z ?X) :-
        And(_APrioriNearTo(?Y ?X)
	    Or(_PartOf(?Z ?Y)
	         _PartiallyOverlaps(?Z ?Y)))
    )

    Forall ?X ?Y ?Z ?b ?p1 ?p2 ?l1 ?l2 ?w (
      _APrioriNearTo(?Y ?X) :-
        And(?p1#_AdminPartition(subregion->?X subregion->?Y partLevel->?l1)   // ?X and ?Y belong to the same administrative partition ?p1
              ?p2#_AdminPartition(subregion->?b partLevel->?l2) // ?b is a region belonging to the administrative partition ?p2
              _nextLevelOf(?l2 ?l1) // ?p2 is the next upper level partition of ?p1
              _PartOf(?X ?b)
              Or(_PartOf(?Y ?b)
                 _ExternallyConnectedTo(?Y ?b))
              ?w#_FunctionalRegion   // ?X and ?Y belong to the same functional region ?w
              _LocatedIn(?X ?w)
              _LocatedIn(?Y ?w))
    )
  )
)

Queries

_ProperPartOf(_California _NorthAmerica)
Answer: Yes

And(State(?St) _TangentialProperPartof(?St _USA))
Answer: ?St = _California
        ?St = _Virginia

And( _State(?St) _Ocean(?O) _ProperPartOf(?St _NorthAmerica) _ConnectsWith(?St ?O))
Answer: ?St = _California, ?O = _PacificOcean
        ?St = _Virginia, ?O = _AtlanticOcean

XML Version:

<?xml-modelhref = "http://deliberation.ruleml.org/1.01/relaxng/datalogplus_min_relaxed.rnc"?>
<RuleML>
  <Assert>
    <Forall>
      <Var>X</Var>
      <Atom>
        <Rel>ConnectsWith</Rel>
        <Var>X</Var>
        <Var>X</Var>
      </Atom>
    </Forall>
  </Assert>  
  <Assert>
    <!-- Symmetry of ConnectsWith relation
      -->
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Implies>
        <if>
          <Atom>
            <Rel>ConnectsWith</Rel>
            <Var>X</Var>
            <Var>Y</Var>
          </Atom>
        </if>
        <then>
          <Atom>
            <Rel>ConnectsWith</Rel>
            <Var>Y</Var>
            <Var>X</Var>
          </Atom>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <!--
      -->
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Var>Z</Var>
      <Implies>
        <if>
          <And>
            <Atom>
              <Rel>ConnectsWith</Rel>
              <Var>X</Var>
              <Var>Y</Var>
            </Atom>
            <Atom>
              <Rel>PartOf</Rel>
              <Var>Y</Var>
              <Var>Z</Var>
            </Atom>
          </And>
        </if>
        <then>
          <Atom>
            <Rel>ConnectsWith</Rel>
            <Var>X</Var>
            <Var>Z</Var>
          </Atom>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <!-- Definition of Overlaps
      -->
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Var>Z</Var>
      <Implies>
        <if>
          <And>
            <Atom>
              <Rel>PartOf</Rel>
              <Var>Z</Var>
              <Var>X</Var>
            </Atom>
            <Atom>
              <Rel>PartOf</Rel>
              <Var>Z</Var>
              <Var>Y</Var>
            </Atom>
          </And>
        </if>
        <then>
          <Atom>
            <Rel>Overlaps</Rel>
            <Var>X</Var>
            <Var>Y</Var>
          </Atom>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <!-- Definition of ExternallyConnectedTo
      -->
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Implies>
        <if>
          <And>
            <Atom>
              <Rel>ConnectsWith</Rel>
              <Var>X</Var>
              <Var>Y</Var>
            </Atom>
            <Atom>
              <Rel>DiscreteFrom</Rel>
              <Var>X</Var>
              <Var>Y</Var>
            </Atom>
          </And>
        </if>
        <then>
          <Atom>
            <Rel>ExternallyConnectedTo</Rel>
            <Var>X</Var>
            <Var>Y</Var>
          </Atom>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <!-- ExternallyConnectedTo is a subrelation of ConnectsWith
      -->
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Implies>
        <if>
          <Atom>
            <Rel>ExternallyConnectedTo</Rel>
            <Var>X</Var>
            <Var>Y</Var>
          </Atom>
        </if>
        <then>
          <Atom>
            <Rel>ConnectsWith</Rel>
            <Var>X</Var>
            <Var>Y</Var>
          </Atom>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <!-- ExternallyConnectedTo is a subrelation of DiscreteFrom
      -->
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Implies>
        <if>
          <Atom>
            <Rel>ExternallyConnectedTo</Rel>
            <Var>X</Var>
            <Var>Y</Var>
          </Atom>
        </if>
        <then>
          <Atom>
            <Rel>DiscreteFrom</Rel>
            <Var>X</Var>
            <Var>Y</Var>
          </Atom>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <!-- Definition of EqualTo
      -->
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Var>Z</Var>
      <Implies>
        <if>
          <And>
            <Atom>
              <Rel>PartOf</Rel>
              <Var>X</Var>
              <Var>Y</Var>
            </Atom>
            <Atom>
              <Rel>PartOf</Rel>
              <Var>Y</Var>
              <Var>Z</Var>
            </Atom>
          </And>
        </if>
        <then>
          <Atom>
            <Rel>EqualTo</Rel>
            <Var>X</Var>
            <Var>Z</Var>
          </Atom>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <!-- ProperPartOf is a subrelation of PartOf
      -->
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Implies>
        <if>
          <Atom>
            <Rel>ProperPartOf</Rel>
            <Var>X</Var>
            <Var>Y</Var>
          </Atom>
        </if>
        <then>
          <Atom>
            <Rel>PartOf</Rel>
            <Var>X</Var>
            <Var>Y</Var>
          </Atom>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <!-- PartiallyOverlaps is a subrelation of Overlaps
      -->
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Implies>
        <if>
          <Atom>
            <Rel>PartiallyOverlaps</Rel>
            <Var>X</Var>
            <Var>Y</Var>
          </Atom>
        </if>
        <then>
          <Atom>
            <Rel>Overlaps</Rel>
            <Var>X</Var>
            <Var>Y</Var>
          </Atom>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <!-- Definition of TangentialProperPartof
      -->
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Var>Z</Var>
      <Implies>
        <if>
          <And>
            <Atom>
              <Rel>ProperPartOf</Rel>
              <Var>X</Var>
              <Var>Y</Var>
            </Atom>
            <Atom>
              <Rel>ExternallyConnectedTo</Rel>
              <Var>Z</Var>
              <Var>X</Var>
            </Atom>
            <Atom>
              <Rel>ExternallyConnectedTo</Rel>
              <Var>Z</Var>
              <Var>Y</Var>
            </Atom>
          </And>
        </if>
        <then>
          <Atom>
            <Rel>TangentialProperPartof</Rel>
            <Var>X</Var>
            <Var>Y</Var>
          </Atom>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <!-- InverseProperPartOf and ProperPartOf
      -->
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Implies>
        <if>
          <Atom>
            <Rel>ProperPartOf</Rel>
            <Var>X</Var>
            <Var>Y</Var>
          </Atom>
        </if>
        <then>
          <Atom>
            <Rel>InverseProperPartOf</Rel>
            <Var>Y</Var>
            <Var>X</Var>
          </Atom>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <!-- InverseProperPartOf and ProperPartOf
      -->
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Implies>
        <if>
          <Atom>
            <Rel>InverseProperPartOf</Rel>
            <Var>X</Var>
            <Var>Y</Var>
          </Atom>
        </if>
        <then>
          <Atom>
            <Rel>ProperPartOf</Rel>
            <Var>Y</Var>
            <Var>X</Var>
          </Atom>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <!-- TangentialProperPartof and InverseTangentialProperPartof
      -->
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Implies>
        <if>
          <Atom>
            <Rel>TangentialProperPartof</Rel>
            <Var>X</Var>
            <Var>Y</Var>
          </Atom>
        </if>
        <then>
          <Atom>
            <Rel>InverseTangentialProperPartof</Rel>
            <Var>Y</Var>
            <Var>X</Var>
          </Atom>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <!-- TangentialProperPartof and InverseTangentialProperPartof
      -->
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Implies>
        <if>
          <Atom>
            <Rel>InverseTangentialProperPartof</Rel>
            <Var>X</Var>
            <Var>Y</Var>
          </Atom>
        </if>
        <then>
          <Atom>
            <Rel>TangentialProperPartof</Rel>
            <Var>Y</Var>
            <Var>X</Var>
          </Atom>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <!-- NonTangentialProperPartof and InverseNonTangentialProperPartof
      -->
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Implies>
        <if>
          <Atom>
            <Rel>NonTangentialProperPartof</Rel>
            <Var>X</Var>
            <Var>Y</Var>
          </Atom>
        </if>
        <then>
          <Atom>
            <Rel>InverseNonTangentialProperPartof</Rel>
            <Var>Y</Var>
            <Var>X</Var>
          </Atom>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <!-- NonTangentialProperPartof and InverseNonTangentialProperPartof
      -->
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Implies>
        <if>
          <Atom>
            <Rel>InverseNonTangentialProperPartof</Rel>
            <Var>X</Var>
            <Var>Y</Var>
          </Atom>
        </if>
        <then>
          <Atom>
            <Rel>NonTangentialProperPartof</Rel>
            <Var>Y</Var>
            <Var>X</Var>
          </Atom>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <!-- 
      -->
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Var>Z</Var>
      <Implies>
        <if>
          <And>
            <Atom>
              <Rel>PartOf</Rel>
              <Var>X</Var>
              <Var>Y</Var>
            </Atom>
            <Atom>
              <Rel>DisconnectedFrom</Rel>
              <Var>Y</Var>
              <Var>Z</Var>
            </Atom>
          </And>
        </if>
        <then>
          <Atom>
            <Rel>DisconnectedFrom</Rel>
            <Var>X</Var>
            <Var>Z</Var>
          </Atom>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <!-- 
      -->
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Var>Z</Var>
      <Implies>
        <if>
          <And>
            <Atom>
              <Rel>TangentialProperPartof</Rel>
              <Var>X</Var>
              <Var>Y</Var>
            </Atom>
            <Atom>
              <Rel>ExternallyConnectedTo</Rel>
              <Var>Y</Var>
              <Var>Z</Var>
            </Atom>
          </And>
        </if>
        <then>
          <Atom>
            <Rel>DiscreteFrom</Rel>
            <Var>X</Var>
            <Var>Z</Var>
          </Atom>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <!-- 
      -->
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Var>Z</Var>
      <Implies>
        <if>
          <And>
            <Atom>
              <Rel>TangentialProperPartof</Rel>
              <Var>X</Var>
              <Var>Y</Var>
            </Atom>
            <Atom>
              <Rel>TangentialProperPartof</Rel>
              <Var>Y</Var>
              <Var>Z</Var>
            </Atom>
          </And>
        </if>
        <then>
          <Atom>
            <Rel>ProperPartof</Rel>
            <Var>X</Var>
            <Var>Z</Var>
          </Atom>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <!-- 
      -->
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Var>Z</Var>
      <Implies>
        <if>
          <And>
            <Atom>
              <Rel>Partof</Rel>
              <Var>X</Var>
              <Var>Y</Var>
            </Atom>
            <Atom>
              <Rel>NonTangentialProperPartof</Rel>
              <Var>Y</Var>
              <Var>Z</Var>
            </Atom>
          </And>
        </if>
        <then>
          <Atom>
            <Rel>NonTangentialProperPartof</Rel>
            <Var>X</Var>
            <Var>Z</Var>
          </Atom>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <!-- 
      -->
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Var>Z</Var>
      <Implies>
        <if>
          <And>
            <Atom>
              <Rel>NonTangentialProperPartof</Rel>
              <Var>X</Var>
              <Var>Y</Var>
            </Atom>
            <Atom>
              <Rel>ExternallyConnectedTo</Rel>
              <Var>Y</Var>
              <Var>Z</Var>
            </Atom>
          </And>
        </if>
        <then>
          <Atom>
            <Rel>DisconnectedFrom</Rel>
            <Var>X</Var>
            <Var>Z</Var>
          </Atom>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <!-- 
      -->
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Var>Z</Var>
      <Implies>
        <if>
          <And>
            <Atom>
              <Rel>NonTangentialProperPartof</Rel>
              <Var>X</Var>
              <Var>Y</Var>
            </Atom>
            <Atom>
              <Rel>TangentialProperPartof</Rel>
              <Var>Y</Var>
              <Var>Z</Var>
            </Atom>
          </And>
        </if>
        <then>
          <Atom>
            <Rel>NonTangentialProperPartof</Rel>
            <Var>X</Var>
            <Var>Z</Var>
          </Atom>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <!-- 
      -->
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Var>Z</Var>
      <Implies>
        <if>
          <And>
            <Atom>
              <Rel>ProperPartOf</Rel>
              <Var>X</Var>
              <Var>Y</Var>
            </Atom>
            <Atom>
              <Rel>ProperPartOf</Rel>
              <Var>Y</Var>
              <Var>Z</Var>
            </Atom>
          </And>
        </if>
        <then>
          <Atom>
            <Rel>ProperPartOf</Rel>
            <Var>X</Var>
            <Var>Z</Var>
          </Atom>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <!-- 
      -->
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Implies>
        <if>
          <And>
            <Atom>
              <Rel>ConnectsWith</Rel>
              <Var>X</Var>
              <Var>Y</Var>
            </Atom>
            <Atom>
              <Rel>DisconnectedFrom</Rel>
              <Var>X</Var>
              <Var>Y</Var>
            </Atom>
          </And>
        </if>
        <then>
          <Or/>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <!-- 
      -->
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Implies>
        <if>
          <And>
            <Atom>
              <Rel>DiscreteFrom</Rel>
              <Var>X</Var>
              <Var>Y</Var>
            </Atom>
            <Atom>
              <Rel>Overlaps</Rel>
              <Var>X</Var>
              <Var>Y</Var>
            </Atom>
          </And>
        </if>
        <then>
          <Or/>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <!-- 
      -->
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Implies>
        <if>
          <And>
            <Atom>
              <Rel>PartiallyOverlaps</Rel>
              <Var>X</Var>
              <Var>Y</Var>
            </Atom>
            <Or>
              <Atom>
                <Rel>PartOf</Rel>
                <Var>X</Var>
                <Var>Y</Var>
              </Atom>
              <Atom>
                <Rel>PartOf</Rel>
                <Var>Y</Var>
                <Var>X</Var>
              </Atom>
            </Or>
          </And>
        </if>
        <then>
          <Or/>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <!-- 
      -->
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Var>Z</Var>
      <Implies>
        <if>
          <And>
            <Atom>
              <Rel>NonTangentialProperPartof</Rel>
              <Var>X</Var>
              <Var>Y</Var>
            </Atom>
            <Atom>
              <Rel>ExternallyConnectedTo</Rel>
              <Var>Z</Var>
              <Var>X</Var>
            </Atom>
            <Atom>
              <Rel>ExternallyConnectedTo</Rel>
              <Var>Z</Var>
              <Var>Y</Var>
            </Atom>
          </And>
        </if>
        <then>
          <Or/>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Implies>
        <if>
          <Atom>
            <Rel>Overlaps</Rel>
            <Var>X</Var>
            <Var>Y</Var>
          </Atom>
        </if>
        <then>
          <Exists>
            <Var>Z</Var>
            <And>
              <Atom>
                <Rel>PartOf</Rel>
                <Var>Z</Var>
                <Var>X</Var>
              </Atom>
              <Atom>
                <Rel>PartOf</Rel>
                <Var>Z</Var>
                <Var>Y</Var>
              </Atom>
            </And>
          </Exists>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <Forall>
      <Var>X</Var>
      <Var>Y</Var>
      <Implies>
        <if>
          <Atom>
            <Rel>TangentialProperPartof</Rel>
            <Var>X</Var>
            <Var>Y</Var>
          </Atom>
        </if>
        <then>
          <Exists>
            <Var>Z</Var>
            <And>
              <Atom>
                <Rel>ExternallyConnectedTo</Rel>
                <Var>Z</Var>
                <Var>X</Var>
              </Atom>
              <Atom>
                <Rel>ExternallyConnectedTo</Rel>
                <Var>Z</Var>
                <Var>Y</Var>
              </Atom>
            </And>
          </Exists>
        </then>
      </Implies>
    </Forall>
  </Assert>
  <Assert>
    <!-- Facts of the rulebase
    -->
    <Atom>
      <Rel>ProperPartOf</Rel>
      <Ind>USA</Ind>
      <Ind>NorthAmerica</Ind>
    </Atom>
    <Atom>
      <Rel>ProperPartOf</Rel>
      <Ind>California</Ind>
      <Ind>USA</Ind>
    </Atom>
    <Atom>
      <Rel>ProperPartOf</Rel>
      <Ind>Virginia</Ind>
      <Ind>USA</Ind>
    </Atom>
    <Atom>
      <Rel>ExternallyConnectedTo</Rel>
      <Ind>PacificOcean</Ind>
      <Ind>California</Ind>
    </Atom>
    <Atom>
      <Rel>ExternallyConnectedTo</Rel>
      <Ind>AtlanticOcean</Ind>
      <Ind>Virginia</Ind>
    </Atom>
    <Atom>
      <Rel>ExternallyConnectedTo</Rel>
      <Ind>PacificOcean</Ind>
      <Ind>USA</Ind>
    </Atom>
    <Atom>
      <Rel>ExternallyConnectedTo</Rel>
      <Ind>AtlanticOcean</Ind>
      <Ind>USA</Ind>
    </Atom>
    <Atom>
      <Rel>State</Rel>
      <Ind>California</Ind>
    </Atom>
    <Atom>
      <Rel>State</Rel>
      <Ind>Virginia</Ind>
    </Atom>
    <Atom>
      <Rel>Ocean</Rel>
      <Ind>PacificOcean</Ind>
    </Atom>
    <Atom>
      <Rel>Ocean</Rel>
      <Ind>AtlanticOcean</Ind>
    </Atom>
  </Assert>
  <Query>
    <!-- 
         Is California proper part of North America?
      -->
    <Atom>
      <Rel>ProperPartOf</Rel>
      <Ind>California</Ind>
      <Ind>NorthAmerica</Ind>
    </Atom>
  </Query>
  <Query>
    <!-- 
         Which states are tangential proper part of the USA?
         Answers:
         St: California
         St: Virginia
      -->
    <And>
      <Atom>
        <Rel>State</Rel>
        <Var>St</Var>
      </Atom>
      <Atom>
        <Rel>TangentialProperPartof</Rel>
        <Var>St</Var>
        <Ind>USA</Ind>
      </Atom>
    </And>
  </Query>
  <Query>
    <!-- 
         Which states in North America connect to an ocean?
         Answers:
         St: California O: PacificOcean
         St: Virginia O: AtlanticOcean
      -->
    <And>
      <Atom>
        <Rel>State</Rel>
        <Var>St</Var>
      </Atom>
      <Atom>
        <Rel>Ocean</Rel>
        <Var>O</Var>
      </Atom>
      <Atom>
        <Rel>ProperPartof</Rel>
        <Var>St</Var>
        <Ind>NorthAmerica</Ind>
      </Atom>
      <Atom>
        <Rel>ConnectsWith</Rel>
        <Var>St</Var>
        <Ind>O</Ind>
      </Atom>
    </And>
  </Query>
</RuleML>