| 1 | |
|---|
| 2 | :- category(proto_hierarchy, |
|---|
| 3 | implements(proto_hierarchyp)). |
|---|
| 4 | |
|---|
| 5 | :- info([ |
|---|
| 6 | version is 1.1, |
|---|
| 7 | author is 'Paulo Moura', |
|---|
| 8 | date is 2006/2/20, |
|---|
| 9 | comment is 'Prototype hierarchy predicates.']). |
|---|
| 10 | |
|---|
| 11 | parent(Parent) :- |
|---|
| 12 | self(Self), |
|---|
| 13 | extends_object(Self, Parent). |
|---|
| 14 | |
|---|
| 15 | parents(Parents) :- |
|---|
| 16 | self(Self), |
|---|
| 17 | findall(Parent, extends_object(Self, Parent), Parents). |
|---|
| 18 | |
|---|
| 19 | ancestor(Ancestor) :- |
|---|
| 20 | self(Self), |
|---|
| 21 | ancestor(Self, Ancestor). |
|---|
| 22 | |
|---|
| 23 | ancestor(Self, Ancestor) :- |
|---|
| 24 | extends_object(Self, Ancestor). |
|---|
| 25 | ancestor(Self, Ancestor) :- |
|---|
| 26 | extends_object(Self, Parent), |
|---|
| 27 | ancestor(Parent, Ancestor). |
|---|
| 28 | |
|---|
| 29 | ancestors(Ancestors) :- |
|---|
| 30 | self(Self), |
|---|
| 31 | findall(Ancestor, ancestor(Self, Ancestor), Ancestors). |
|---|
| 32 | |
|---|
| 33 | extension(Prototype) :- |
|---|
| 34 | self(Self), |
|---|
| 35 | extends_object(Prototype, Self). |
|---|
| 36 | |
|---|
| 37 | extensions(Prototypes) :- |
|---|
| 38 | self(Self), |
|---|
| 39 | findall(Prototype, extends_object(Prototype, Self), Prototypes). |
|---|
| 40 | |
|---|
| 41 | leaf(Leaf) :- |
|---|
| 42 | self(Self), |
|---|
| 43 | leaf(Self, Leaf). |
|---|
| 44 | |
|---|
| 45 | leaf(Self, Leaf) :- |
|---|
| 46 | extends_object(Leaf, Self), |
|---|
| 47 | \+ extends_object(_, Leaf). |
|---|
| 48 | leaf(Self, Leaf) :- |
|---|
| 49 | extends_object(Object, Self), |
|---|
| 50 | leaf(Object, Leaf). |
|---|
| 51 | |
|---|
| 52 | leaves(Leaves) :- |
|---|
| 53 | self(Self), |
|---|
| 54 | ( setof(Leaf, leaf(Self, Leaf), Leaves) -> |
|---|
| 55 | true |
|---|
| 56 | ; Leaves = [] |
|---|
| 57 | ). |
|---|
| 58 | |
|---|
| 59 | descendant(Descendant) :- |
|---|
| 60 | self(Self), |
|---|
| 61 | descendant(Self, Descendant). |
|---|
| 62 | |
|---|
| 63 | descendant(Self, Descendant) :- |
|---|
| 64 | extends_object(Descendant, Self). |
|---|
| 65 | descendant(Self, Descendant) :- |
|---|
| 66 | extends_object(Descendant, Self), |
|---|
| 67 | \+ extends_object(Descendant, Self). |
|---|
| 68 | descendant(Self, Descendant) :- |
|---|
| 69 | extends_object(Subclass, Self), |
|---|
| 70 | descendant(Subclass, Descendant). |
|---|
| 71 | |
|---|
| 72 | descendants(Descendants) :- |
|---|
| 73 | self(Self), |
|---|
| 74 | ( setof(Descendant, descendant(Self, Descendant), Descendants) -> |
|---|
| 75 | true |
|---|
| 76 | ; Descendants = [] |
|---|
| 77 | ). |
|---|
| 78 | |
|---|
| 79 | :- end_category. |
|---|