<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="http://www.ruleml.org/1.0/relaxng/naffologeq_relaxed.rnc"?>
<!--<?xml-model href="http://www.ruleml.org/1.0/xsd/naffologeq.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/naffologeq.xsd">

  <!-- a syntactic example rulebase for testing the Hornlog RuleML sublanguage -->

  <Assert mapClosure="universal" mapDirection="bidirectional">

    <Equal>
      <Ind>some constant</Ind>
      <Var>d</Var>
    </Equal>

    <Forall>
      <Var>d</Var>
      <Equal>
        <Ind>some constant</Ind>
        <Var>d</Var>
      </Equal>
    </Forall>

    <Exists>
      <Var>d</Var>
      <Equal>
        <Ind>some constant</Ind>
        <Var>d</Var>
      </Equal>
    </Exists>

    <Equivalent>
      <torso>
        <Equal>
          <Ind>some constant</Ind>
          <Var>d</Var>
        </Equal>
      </torso>
      <torso>
        <Equal>
          <Ind>some constant</Ind>
          <Var>d</Var>
        </Equal>
      </torso>
    </Equivalent>

    <Neg>
      <Equal>
        <Ind>some constant</Ind>
        <Var>d</Var>
      </Equal>
    </Neg>

    <Implies>
      <Naf>
        <Equal>
          <Ind>some constant</Ind>
          <Var>d</Var>
        </Equal>
      </Naf>
      <Atom>
        <Rel>own</Rel>
        <Var>person</Var>
        <Var>object</Var>
      </Atom>
    </Implies>

    <Forall>
      <Var>person</Var>
      <Var>object</Var>
      <Implies>
        <then>
          <Atom>
            <Rel>own</Rel>
            <Var>person</Var>
            <Var>object</Var>
          </Atom>
        </then>
        <if>
          <Naf mapDirection="bidirectional">
            <weak>
              <Implies node="#disclaiming-of-other-persons">
                <if>
                  <Equal>
                    <Ind>some constant</Ind>
                    <Var>d</Var>
                  </Equal>
                </if>
                <then>
                  <Equal>
                    <Ind>some constant</Ind>
                    <Var>d</Var>
                  </Equal>
                </then>
              </Implies>
            </weak>
          </Naf>
        </if>
      </Implies>
    </Forall>

    <Equivalent>
      <torso>
        <Atom>
          <Rel>own</Rel>
          <Skolem>test</Skolem>
          <Var>person</Var>
          <Var>object</Var>
        </Atom>
      </torso>
      <torso>
        <Atom>
          <degree>
            <Data xsi:type="xs:float">0.2</Data>
          </degree>
          <Rel>belongs</Rel>
          <Var>object</Var>
          <Var>person</Var>
          <repo>
            <Var>x</Var>
          </repo>
          <resl>
            <Var>y</Var>
          </resl>
        </Atom>
      </torso>
    </Equivalent>

    <Implies node="#claiming-through-disclaimers">
      <then>
        <Atom>
          <Rel>claim</Rel>
          <Var>person</Var>
          <Var>object</Var>
        </Atom>
      </then>
      <if>
        <And>
          <Equal>
            <Ind>some constant</Ind>
            <Var>d</Var>
          </Equal>
          <Naf mapClosure="existential">
            <Exists>
              <Var>merchant</Var>
              <And>
                <Atom>
                  <degree>
                    <Data xsi:type="xs:float">1.0</Data>
                  </degree>
                  <Rel>buy</Rel>
                  <Var>person</Var>
                  <Var>merchant</Var>
                  <Var>object</Var>
                </Atom>
                <Atom>
                  <Rel>keep</Rel>
                  <Var>person</Var>
                  <Var>object</Var>
                </Atom>
              </And>
            </Exists>
          </Naf>
          <Forall>
            <Var>x</Var>
            <Implies node="#disclaiming-of-other-persons">
              <if>
                <Atom>
                  <degree>
                    <Data xsi:type="xs:float">0.5</Data>
                  </degree>
                  <Rel>unequal</Rel>
                  <Var>x</Var>
                  <Var>person</Var>
                </Atom>
              </if>
              <then>
                <Atom>
                  <degree>
                    <Data xsi:type="xs:float">0.5</Data>
                  </degree>
                  <Rel>disclaim</Rel>
                  <Var>x</Var>
                  <Skolem>test</Skolem>
                  <Var>object</Var>
                </Atom>
              </then>
            </Implies>
          </Forall>
          <Atom>
            <Rel>keep</Rel>
            <Var>person</Var>
            <Var>object</Var>
          </Atom>
        </And>
      </if>
    </Implies>

    <Implies node="#claiming-or-relinquishing-through-disclaimers">
      <then>
        <Or>
          <Atom>
            <Rel>claim</Rel>
            <Var>person</Var>
            <Var>object</Var>
          </Atom>
          <Atom>
            <Rel>relinquish</Rel>
            <Var>person</Var>
            <Var>object</Var>
          </Atom>
        </Or>
      </then>
      <if>
        <Forall>
          <Var>x</Var>
          <Implies node="#disclaiming-of-other-persons">
            <if>
              <Atom>
                <Rel>unequal</Rel>
                <Var>x</Var>
                <Var>person</Var>
              </Atom>
            </if>
            <then>
              <Atom>
                <Rel>disclaim</Rel>
                <Var>x</Var>
                <Var>object</Var>
                <repo>
                  <Var>x</Var>
                </repo>
              </Atom>
            </then>
          </Implies>
        </Forall>
      </if>
    </Implies>
    <Implies>
      <then>
        <Or>
          <Atom>
            <op>
              <Rel>friend</Rel>
            </op>
            <slot>
              <Ind>t</Ind>
              <Ind>b</Ind>
            </slot>
            <Var>x</Var>
            <Var>y</Var>
            <Ind>Steph</Ind>
          </Atom>
          <Atom>
            <op>
              <Rel>friend</Rel>
            </op>
            <slot>
              <Ind>t</Ind>
              <Ind>b</Ind>
            </slot>
            <Var>x</Var>
            <Var>y</Var>
            <Ind>Jill</Ind>
          </Atom>
        </Or>
      </then>
      <if>
        <And>
          <Atom>
            <degree>
              <Data xsi:type="xs:float">0</Data>
            </degree>
            <op>
              <Rel>friend</Rel>
            </op>
            <Ind>Jane</Ind>
            <Ind>Joan</Ind>
            <Skolem/>
            <Ind>Jack</Ind>
            <Var>y</Var>
            <Ind>Frank</Ind>
            <Plex>
              <Ind/>
            </Plex>
            <repo>
              <Plex>
                <Ind/>
                <Var/>
              </Plex>
            </repo>
            <slot>
              <Ind>yar</Ind>
              <Expr>
                <op>
                  <Fun>constructor</Fun>
                </op>
                <Plex>
                  <Var>z</Var>
                  <slot>
                    <Ind>yar2</Ind>
                    <Ind>c</Ind>
                  </slot>
                </Plex>
              </Expr>
            </slot>
            <resl>
              <Plex>
                <slot>
                  <Ind/>
                  <Ind/>
                </slot>
              </Plex>
            </resl>
          </Atom>
        </And>
      </if>
    </Implies>

    <Atom>
      <op>
        <Rel>some relation</Rel>
      </op>
      <slot>
        <Ind>role_name1</Ind>
        <Ind>role 1</Ind>
      </slot>
      <Ind>constant a</Ind>
      <Ind>constant b</Ind>
      <slot>
        <Ind>role_name2</Ind>
        <Ind>role 2</Ind>
      </slot>
    </Atom>

    <Equal>
      <Expr>
        <op>
          <Fun per="value">some function</Fun>
        </op>
        <Ind>arg1</Ind>
        <Ind>arg2</Ind>
        <Ind>arg3</Ind>
      </Expr>
      <Expr>
        <op>
          <Fun per="value">some other function</Fun>
        </op>
        <Ind>arg4</Ind>
        <Ind>arg5</Ind>
        <Ind>arg6</Ind>
      </Expr>
    </Equal>


  </Assert>

</RuleML>
