-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpython-rules.txt
110 lines (85 loc) · 2.37 KB
/
python-rules.txt
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
;; Prolog rules that define relative relations
;; Assumes that the prefix 'rltv' is bound to a namespace
;; of your choice
(<-- (string-concat ?result ?string1 ?string2 ?string3)
(lisp ?result (string+ ?string1 ?string2 ?string3)))
(<-- (name ?person ?first ?last)
(q ?person !rltv:first-name ?first)
(q ?person !rltv:last-name ?last))
(<-- (woman ?person)
(q ?person !rltv:sex !rltv:female)
(q ?person !rdf:type !rltv:person))
(<-- (man ?person)
(q ?person !rltv:sex !rltv:male)
(q ?person !rdf:type !rltv:person))
(<-- (father ?parent ?child)
(man ?parent)
(q ?parent !rltv:has-child ?child))
(<-- (mother ?parent ?child)
(woman ?parent)
(q ?parent !rltv:has-child ?child))
(<-- (parent ?father ?child)
(father ?father ?child))
(<-- (parent ?mother ?child)
(mother ?mother ?child))
(<-- (grandparent ?x ?y)
(parent ?x ?z)
(parent ?z ?y))
(<-- (grandchild ?x ?y)
(grandparent ?y ?x))
(<-- (ancestor ?x ?y)
(parent ?x ?y))
(<- (ancestor ?x ?y)
(parent ?x ?z)
(ancestor ?z ?y))
(<-- (descendent ?x ?y)
(ancestor ?y ?x))
(<-- (aunt ?x ?y)
(father ?z ?x)
(woman ?x)
(father ?z ?w)
(not (= ?x ?w))
(parent ?w ?y))
(<-- (uncle ?uncle ?child)
(man ?uncle)
(parent ?grandparent ?uncle)
(parent ?grandparent ?siblingOfUncle)
(not (= ?uncle ?siblingOfUncle))
(parent ?siblingOfUncle ?child))
(<-- (nephew ?x ?y)
(aunt ?y ?x)
(man ?x))
(<- (nephew ?x ?y)
(uncle ?y ?x)
(man ?x))
(<-- (niece ?x ?y)
(aunt ?y ?x)
(woman ?x))
(<- (niece ?x ?y)
(uncle ?y ?x)
(woman ?x))
(<-- (parent-child-have-same-name ?x ?y)
(q- ?x !rltv:first-name ?n1)
(parent ?x ?y)
(q- ?y !rltv:first-name ?n2)
(= ?n1 ?n2))
(<-- (parent-child-went-to-ivy-league-school ?x ?y)
(q- ?x !rltv:alma-mater ?am)
(q- ?am !rltv:ivy-league !rltv:true)
(parent ?x ?y)
(q- ?y !rltv:alma-mater ?am2)
(q- ?am2 !rltv:ivy-league !rltv:true))
(<-- (parent-child-went-to-same-ivy-league-school ?x ?y)
(q- ?x !rltv:alma-mater ?am)
(q- ?am !rltv:ivy-league !rltv:true)
(parent ?x ?y)
(q- ?y !rltv:alma-mater ?am))
(<-- (spouse ?x ?y)
(q ?x !rltv:spouse ?y))
;; ?x has a spouse and children
(<-- (family ?x ?fam)
(q ?x !rltv:spouse ?sp)
(bagof ?ch (parent ?x ?ch) ?bag)
(append ?bag (?sp) ?fam)
;#!
)