| 1 | |
|---|
| 2 | :- category(class_hierarchy, |
|---|
| 3 | implements(class_hierarchyp)). |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | :- info([ |
|---|
| 7 | version is 1.0, |
|---|
| 8 | author is 'Paulo Moura', |
|---|
| 9 | date is 2000/7/24, |
|---|
| 10 | comment is 'Class hierarchy predicates.']). |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | class(Class) :- |
|---|
| 14 | self(Self), |
|---|
| 15 | instantiates_class(Self, Class). |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | classes(Classes) :- |
|---|
| 19 | self(Self), |
|---|
| 20 | findall(Class, instantiates_class(Self, Class), Classes). |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | ancestor(Ancestor) :- |
|---|
| 24 | self(Self), |
|---|
| 25 | ancestor(Self, Ancestor). |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | ancestor(Self, Ancestor) :- |
|---|
| 29 | instantiates_class(Self, Ancestor). |
|---|
| 30 | |
|---|
| 31 | ancestor(Self, Ancestor) :- |
|---|
| 32 | instantiates_class(Self, Class), |
|---|
| 33 | superclass(Class, Ancestor). |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | ancestors(Ancestors) :- |
|---|
| 37 | self(Self), |
|---|
| 38 | findall(Ancestor, ancestor(Self, Ancestor), Ancestors). |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | instance(Instance) :- |
|---|
| 42 | self(Self), |
|---|
| 43 | instantiates_class(Instance, Self). |
|---|
| 44 | |
|---|
| 45 | |
|---|
| 46 | instances(Instances) :- |
|---|
| 47 | self(Self), |
|---|
| 48 | findall(Instance, instantiates_class(Instance, Self), Instances). |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | subclass(Subclass) :- |
|---|
| 52 | self(Self), |
|---|
| 53 | specializes_class(Subclass, Self). |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | subclasses(Subclasses) :- |
|---|
| 57 | self(Self), |
|---|
| 58 | findall(Subclass, specializes_class(Subclass, Self), Subclasses). |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | superclass(Superclass) :- |
|---|
| 62 | self(Self), |
|---|
| 63 | superclass(Self, Superclass). |
|---|
| 64 | |
|---|
| 65 | superclass(Self, Superclass) :- |
|---|
| 66 | specializes_class(Self, Superclass). |
|---|
| 67 | |
|---|
| 68 | superclass(Self, Superclass) :- |
|---|
| 69 | specializes_class(Self, Class), |
|---|
| 70 | superclass(Class, Superclass). |
|---|
| 71 | |
|---|
| 72 | superclasses(Superclasses) :- |
|---|
| 73 | self(Self), |
|---|
| 74 | findall(Superclass, specializes_class(Self, Superclass), Superclasses). |
|---|
| 75 | |
|---|
| 76 | |
|---|
| 77 | leaf(Leaf) :- |
|---|
| 78 | self(Self), |
|---|
| 79 | leaf(Self, Leaf). |
|---|
| 80 | |
|---|
| 81 | |
|---|
| 82 | leaf(Self, Leaf) :- |
|---|
| 83 | instantiates_class(Leaf, Self), |
|---|
| 84 | \+ instantiates_class(_, Leaf), |
|---|
| 85 | \+ specializes_class(_, Leaf). |
|---|
| 86 | |
|---|
| 87 | leaf(Self, Leaf) :- |
|---|
| 88 | specializes_class(Leaf, Self), |
|---|
| 89 | \+ instantiates_class(_, Leaf), |
|---|
| 90 | \+ specializes_class(_, Leaf). |
|---|
| 91 | |
|---|
| 92 | leaf(Self, Leaf) :- |
|---|
| 93 | specializes_class(Subclass, Self), |
|---|
| 94 | leaf(Subclass, Leaf). |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | leaves(Leaves) :- |
|---|
| 98 | self(Self), |
|---|
| 99 | findall(Leaf, leaf(Self, Leaf), Leaves). |
|---|
| 100 | |
|---|
| 101 | |
|---|
| 102 | leaf_instance(Leaf) :- |
|---|
| 103 | self(Self), |
|---|
| 104 | leaf_instance(Self, Leaf). |
|---|
| 105 | |
|---|
| 106 | |
|---|
| 107 | leaf_instance(Self, Leaf) :- |
|---|
| 108 | instantiates_class(Leaf, Self), |
|---|
| 109 | \+ instantiates_class(_, Leaf). |
|---|
| 110 | |
|---|
| 111 | leaf_instance(Self, Leaf) :- |
|---|
| 112 | specializes_class(Subclass, Self), |
|---|
| 113 | leaf_instance(Subclass, Leaf). |
|---|
| 114 | |
|---|
| 115 | |
|---|
| 116 | leaf_instances(Leaves) :- |
|---|
| 117 | self(Self), |
|---|
| 118 | findall(Leaf, leaf_instance(Self, Leaf), Leaves). |
|---|
| 119 | |
|---|
| 120 | |
|---|
| 121 | leaf_class(Leaf) :- |
|---|
| 122 | self(Self), |
|---|
| 123 | leaf_class(Self, Leaf). |
|---|
| 124 | |
|---|
| 125 | leaf_class(Self, Leaf) :- |
|---|
| 126 | specializes_class(Leaf, Self), |
|---|
| 127 | \+ specializes_class(_, Leaf). |
|---|
| 128 | |
|---|
| 129 | leaf_class(Self, Leaf) :- |
|---|
| 130 | specializes_class(Subclass, Self), |
|---|
| 131 | leaf_class(Subclass, Leaf). |
|---|
| 132 | |
|---|
| 133 | leaf_classes(Leaves) :- |
|---|
| 134 | self(Self), |
|---|
| 135 | findall(Leaf, leaf_class(Self, Leaf), Leaves). |
|---|
| 136 | |
|---|
| 137 | |
|---|
| 138 | descendant(Descendant) :- |
|---|
| 139 | self(Self), |
|---|
| 140 | descendant(Self, Descendant). |
|---|
| 141 | |
|---|
| 142 | |
|---|
| 143 | descendant(Self, Descendant) :- |
|---|
| 144 | instantiates_class(Descendant, Self). |
|---|
| 145 | |
|---|
| 146 | descendant(Self, Descendant) :- |
|---|
| 147 | specializes_class(Descendant, Self), |
|---|
| 148 | \+ instantiates_class(Descendant, Self). |
|---|
| 149 | |
|---|
| 150 | descendant(Self, Descendant) :- |
|---|
| 151 | specializes_class(Subclass, Self), |
|---|
| 152 | descendant(Subclass, Descendant). |
|---|
| 153 | |
|---|
| 154 | |
|---|
| 155 | descendants(Descendants) :- |
|---|
| 156 | self(Self), |
|---|
| 157 | findall(Descendant, descendant(Self, Descendant), Descendants). |
|---|
| 158 | |
|---|
| 159 | |
|---|
| 160 | descendant_class(Descendant) :- |
|---|
| 161 | self(Self), |
|---|
| 162 | descendant_class(Self, Descendant). |
|---|
| 163 | |
|---|
| 164 | |
|---|
| 165 | descendant_class(Self, Descendant) :- |
|---|
| 166 | specializes_class(Descendant, Self). |
|---|
| 167 | |
|---|
| 168 | descendant_class(Self, Descendant) :- |
|---|
| 169 | specializes_class(Subclass, Self), |
|---|
| 170 | descendant_class(Subclass, Descendant). |
|---|
| 171 | |
|---|
| 172 | |
|---|
| 173 | descendant_classes(Descendants) :- |
|---|
| 174 | self(Self), |
|---|
| 175 | findall(Descendant, descendant_class(Self, Descendant), Descendants). |
|---|
| 176 | |
|---|
| 177 | |
|---|
| 178 | descendant_instance(Descendant) :- |
|---|
| 179 | self(Self), |
|---|
| 180 | descendant_instance(Self, Descendant). |
|---|
| 181 | |
|---|
| 182 | |
|---|
| 183 | descendant_instance(Self, Descendant) :- |
|---|
| 184 | instantiates_class(Descendant, Self). |
|---|
| 185 | |
|---|
| 186 | descendant_instance(Self, Descendant) :- |
|---|
| 187 | specializes_class(Subclass, Self), |
|---|
| 188 | descendant_instance(Subclass, Descendant). |
|---|
| 189 | |
|---|
| 190 | |
|---|
| 191 | descendant_instances(Descendants) :- |
|---|
| 192 | self(Self), |
|---|
| 193 | findall(Descendant, descendant_instance(Self, Descendant), Descendants). |
|---|
| 194 | |
|---|
| 195 | |
|---|
| 196 | :- end_category. |
|---|