Not entirely sure if this is what you need, but you can easily express that a class has a set of properties by creating a graph structure of facts (see the list of properties facts below and the rule for finding the properties within a set).
Then to express the composition of that set of properties you need another set of composition facts and rule that discovers any sub-properties of the class and as a result things it can be composed of.
I've given a code example below as well to help explain.
property(bird, red_robotic_bird).
property(red, red_robotic_bird).
property(robot, red_robotic_bird).
property(tasty, cake).
property(red_robotic_bird, macaw).
property(Property, Thing) :-
property(PropertySet, Thing),
property(Property, PropertySet).
composition(buttons, red_robotic_bird).
composition(cheese, red_robotic_bird).
composition(wire, red_robotic_bird).
composition(flour, cake).
composition(Material, Thing) :-
property(Property, Thing),
composition(Material, Property).
example queries
?- composition(Material, macaw).
Material = buttons ;
Material = cheese ;
Material = wire ;
no
?- composition(buttons, Thing).
Thing = red_robotic_bird ;
Thing = macaw ;
no
?- composition(flour, macaw).
no
?- property(bird, macaw).
yes
?- property(bird, cake).
no
property(Property, macaw).
Property = red_robotic_bird ;
Property = bird ;
Property = red ;
Property = robot ;
no
Prolog rules in brief.
Rules are essentially just facts (eg. animal(cat).
) that are conditional on other rules or facts being true. A rule is made up a head and a body (head :- body.
). A body is a logical proof most commonly expressed in conjunctive normal form (A /\ B /\ C). The and operator in prolog is ,
, the or operator is ;
(but its use is discouraged in rules), and the period (.
) denotes the end of a rule or fact.
Note that if a later rule or fact in the body fails then prolog will backtrack and ask for an alternative answer from a previous rule or fact and then try again. Consider the somewhat contrived example below.
share_same_colour(FruitA, FruitB) :-
colour(Colour, FruitA),
colour(Colour, FruitB).
If we execute the query share_same_colour(apple, strawberry).
then colour(Colour, apple).
might return Colour as being green. However, there no green strawberries, so prolog will backtrack and ask what other colours do apples come in. The next answer might be red, upon which the second colour statement would succeed and the whole rule be true.