-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreature.pl
More file actions
42 lines (31 loc) · 1.23 KB
/
creature.pl
File metadata and controls
42 lines (31 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
%Creatures come in two types: humans and birds.
edge(human, ako, creature).
edge(bird, ako, creature).
%One type of human is a man.
edge(man, ako, human).
%One type of bird is a turkey.
edge(turkey, ako, bird).
%Louis is a man.
edge(louis, isa, man).
%Albert is a man.
edge(albert, isa, man).
%Frank is a turkey.
edge(frank, isa, turkey).
%Humans normally have two legs
property(human, legs, two).
%Birds can normally fly
property(bird, fly, yes).
%Louis has one leg
property(louis, legs, one).
%Turkeys cannot fly.
property(turkey, fly, nope).
%rel(SourceNode, RelationshipType, DestinationNode)
rel(A, Relationship, B):- edge(A, Relationship, B).
rel(A, Relationship, B):- edge(A, Relationship, C), rel(C, isa, B).
rel(A, Relationship, B):- edge(A, Relationship, C), rel(C, ako, B).
%Overriding the properties
PropCheck(A, Prop, Value):- property(A, Prop, Value).
%PropCheck(A, Prop, Value):- edge(A, isa, C), PropCheck(C, Prop, Value), \+ property(A, Prop, _).
%PropCheck(A, Prop, Value):- edge(A, ako, C), PropCheck(C, Prop, Value), \+ property(A, Prop, _).
PropCheck(A, Prop, Value):- edge(A,Prop,C), PropCheck(C, isa, Value).
PropCheck(A, Prop, Value):- edge(A,Prop,C), PropCheck(C, ako, Value).