-->

 

jDREW

 

 
<--

 

Rules used by the demo

Example 1

%Sydney is connected to Truro via Acadian_Lines.

 connected_to_via_Acadian_Lines('Sydney', 'Truro').

 % Truro is connected to Amherst via Acadian_Lines.

connected_to_via_Acadian_Lines('Truro', 'Amherst').

% Amherst is connected to Sussex via SMT.

connected_to_via_SMT('Amherst', 'Sussex').

% Sussex is connected to Fredericton via SMT.

connected_to_via_SMT('Sussex', 'Fredericton').

 % If X is connected to Y via Acadian Lines, then we say X and Y are connected.

connected_to(X, Y) :- connected_to_via_Acadian_Lines(X, Y).

% If X is connected to Y via SMT, then we say X and Y are connected.

connected_to(X, Y) :- connected_to_via_SMT(X, Y).

% If X and Y are connected, then we say Y and X are also connected.

connected_to(X, Y) :- connected_to(Y, X).

% If X, Z are connected and Z, Y are connected , then we say X and Y are connected.

% connected_to(X, Y) :- connected_to(X, Z), connected_to(Z, Y).

Example 2

% If X is Ys parent, Y is Zs parent and X is female, then X is Zs grandmother.

grandmother(X, Z) :- parent(X, Y), parent(Y, Z), female(X).

% If X is male, X and Y are sibling and Y is Zs parent, then X is Zs uncle.

uncle(X, Z) :- male(X), sibling(X, Y), parent(Y, Z).

%Ed is male.

male(Ed).

%Chas and Ed are siblings.

sibling(Chas, Ed).

%If X is Ys sibling, then Y is also Xs sibling.

sibling(X, Y) :- sibling(Y, X).

%Chas is Wills parent.

parent(Chas, Will).

%Liz is female.

female(Liz).

% Liz is Chass parent.

parent(Liz, Chas).

Example 3 (Prolog)

% rome is on the route.

on_route(rome).

% If we can, through some way, move from place1 to another place that is on the route, we say that the place1 is also on the route.

on_route(Place):- on_route(NewPlace),   move(Place,Method,NewPlace).

%We can move from home to halifax by taxi.

move(home,taxi,halifax).

%We can move from halifax to gatwick by train.

move(halifax,train,gatwick).

%We can move from gatewick to rome by plane.

Move(gatwick,plane,rome).

Example 3 (RuleML)

<?xml version="1.0" standalone="no"?>

<rulebase>

<imp>

  <_head>

    <atom>

        <_opr><rel>on_route</rel></_opr>

        <var>Place</var>

    </atom>

  </_head>

  <_body>

    <and>

      <atom>

          <_opr><rel>on_route</rel></_opr>

          <var>NewPlace</var>

      </atom>

      <atom>

          <_opr><rel>move</rel></_opr>

          <var>Place</var>

          <var>Method</var>

          <var>NewPlace</var>

      </atom>

    </and>

  </_body>

</imp>

<fact>

 <_head>

  <atom>

      <_opr><rel>on_route</rel></_opr>

      <ind>rome</ind>

  </atom>

 </_head>

</fact>

<fact>

 <_head>

  <atom>

      <_opr><rel>move</rel></_opr>

      <ind>home</ind>

      <ind>taxi</ind>

      <ind>halifax</ind>

  </atom>

 </_head>

</fact>

<fact>

 <_head>

   <atom>

      <_opr><rel>move</rel></_opr>

      <ind>halifax</ind>

      <ind>train</ind>

      <ind>gatwick</ind>

   </atom>

 </_head>

</fact>

<fact>

 <_head>

   <atom>

      <_opr><rel>move</rel></_opr>

      <ind>gatwick</ind>

      <ind>plane</ind>

      <ind>rome</ind>

   </atom>

 </_head>

</fact>

</rulebase>