Both sides previous revision
Poprzednia wersja
Nowa wersja
|
Poprzednia wersja
|
pl:dydaktyka:dss:rules:intro [2017/11/28 14:59] msl |
pl:dydaktyka:dss:rules:intro [2017/12/07 14:56] msl [5.1. Adding Knowledge to the KB] |
siblings(X, Y), | siblings(X, Y), |
man(X).</code> | man(X).</code> |
Define two additional rules: | Define the following rules: |
* siblings(X,Y) --- two different people with a common parent | * siblings(X,Y) --- two different people with a common parent; |
| * tip: ** (test (neq ?x ?y)) ** checks inequality of variables. |
| * question: why do you have to use ** test ** keyword? |
* sister(X,Y) | * sister(X,Y) |
* grandfather(X,Y) | * grandfather(X,Y) |
* grandparent(X,Y) --- tip: use ** OR ** | * grandparent(X,Y) --- tip: use ** OR ** |
* cousins(X,Y) --- two different people with a common grandparent. You can check this rule in Prolog with a query: <code>cousins(X,Y), parent(R,X), parent(R, Y)</code>, it should return **false** | * cousins(X,Y) --- two different people with a common grandparent. You can check this rule in Prolog with a query: <code>cousins(X,Y), parent(R,X), parent(R, Y)</code>, it should return **false** |
| * remember: siblings are not cousins! |
* aunt(X,Y) and uncle(X,Y) in terms of sister, brother and parent. | * aunt(X,Y) and uncle(X,Y) in terms of sister, brother and parent. |
* half-orphan(X) --- a person with only one parent. TIP: celina is the only half-orphan in the KB | * half-orphan(X) --- a person with only one parent. TIP: celina is the only half-orphan in the KB |
| |
Allows tracking of rules: firing, activation. | Allows tracking of rules: firing, activation. |
- Because we did learn anything interesting tracing the fact, we will follow the **widow** rule and all the rules it depends on: **parent**, **marriage**: <code> | - Because we did learn nothing interesting tracing the fact, we will follow the **widow** rule and all the rules it depends on: **parent**, **marriage**: <code> |
(unwatch all) | (unwatch all) |
(watch parents widow parent) | (watch rules marriage widow parent) |
</code> | </code> |
- Now we reset the fact base: <code> (reset) </code> | - Now we reset the fact base: <code> (reset) </code> |