-
Notifications
You must be signed in to change notification settings - Fork 1
/
clips.clp
292 lines (246 loc) · 5.1 KB
/
clips.clp
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
(defclass University
(is-a USER)
(role concrete)
(multislot Name (type STRING))
(slot Location (propagation no-inherit) (type STRING))
)
(defclass Faculty
(is-a University)
(role concrete)
(slot Location (propagation no-inherit) (type STRING))
(slot university (type STRING))
)
(defclass Department
(is-a Faculty)
(role concrete)
(slot Name (allowed-values CS IT AI IT DS))
(slot min_GPA (type NUMBER))
(slot Student_Num (type NUMBER))
)
(defclass Program
(is-a Faculty)
(role concrete)
(slot Name (allowed-values CS IT AI IT DS General))
(slot Student_Num (type NUMBER))
)
(defclass Course
(is-a Faculty)
(role concrete)
(slot Student_Num (type NUMBER))
(slot facultyName (type STRING)))
(defclass Academic_staff
(is-a Faculty)
(role concrete)
(slot Academic_Num (type NUMBER))
)
(defclass Exams
(is-a Faculty)
(role concrete)
)
(defclass Course_work
(is-a Faculty)
(role concrete)
)
(defclass Thesis
(is-a Faculty)
(role concrete)
)
(defclass Lecture_hall
(is-a Faculty)
(role concrete)
)
(defclass Library
(is-a Faculty)
(role concrete)
)
(defclass Lab_room
(is-a Faculty)
(role concrete)
)
(defclass Lecturer
(is-a Faculty)
(role concrete)
(slot FacultyNameL (type STRING))
)
(defclass TA
(is-a Faculty)
(role concrete)
(slot depName (type SYMBOL))
)
(defclass Student
(is-a Faculty)
(role concrete)
(multislot courses (type STRING))
(slot GPA (type NUMBER))
)
;definstances
(definstances University
(U1 of University
(Name "Cairo University")
(Location "Giza/Cairo"))
(U2 of University
(Name "Helwan University")
(Location "Helwan/Cairo"))
)
(definstances Faculty
(F1 of Faculty
(Name "Computer Science")
(Location "Giza")
(university "Cairo University"))
(F2 of Faculty
(Name "calture faculty")
(Location "Giza")
(university "Helwan University"))
(F3 of Faculty
(Name "Engennering faculty")
(Location "Giza")
(university "Cairo University"))
)
(definstances TA
(T1 of TA
(Name "Ahmed Sayed")
(depName CS))
(T2 of TA
(Name "Samah")
(depName CS))
(T3 of TA
(Name "Aya")
(depName CS))
(T4 of TA
(Name "Khaled Ashraf")
(depName CS))
)
(definstances Department
(D1 of Department
(Name CS)
(min_GPA 2.7)
(Student_Num 70))
(D2 of Department
(Name IT)
(min_GPA 2.2)
(Student_Num 100))
)
(definstances Student
(S1 of Student
(Name Ahmed)
(GPA 3.22)
(courses OOP Algorithms))
(S2 of Student
(Name Khaled)
(GPA 3.45)
(courses C++ DataBase))
(S3 of Student
(Name Manar)
(GPA 3.7)
(courses OOP Math3))
)
(definstances Lecturer
(L1 of Lecturer
(Name Dr:Abir)
(FacultyNameL "Computer Science"))
(L2 of Lecturer
(Name Dr:Amin)
(FacultyNameL "Computer Science"))
(L3 of Lecturer
(Name Dr:Manar)
(FacultyNameL "Engennering faculty"))
)
(definstances Course
(c1 of Course
(Name OOP)
(Student_Num 20)
(facultyName "Computer Science"))
(c2 of Course
(Name Algorithms)
(Student_Num 20)
(facultyName "Computer Science"))
(c3 of Course
(Name c++)
(Student_Num 20)
(facultyName "Computer Science"))
(c4 of Course
(Name DataBase)
(Student_Num 202)
(facultyName "Engennering faculty"))
(c5 of Course
(Name Math3)
(Student_Num 202)
(facultyName "Engennering faculty"))
)
;all TAs belonging to a department.
(defrule print-TAs-department
(declare (salience 9))
?y <- (dep ?d)
(object (name ?name) (depName ?d))
=>
(send ?name printNames)
)
;all Courses belonging to a Student.
(defrule print-Courses-Student
(declare (salience 7))
?y <- (stu ?d)
(object (name ?name) (Name ?d) (courses $?obj))
=>
(retract ?y)
(send ?name printCourses)
)
;all Courses belonging to a Faculty.
(defrule print-Courses-Faculty
(declare (salience 5))
?y <- (Fac ?d)
(object (name ?name) (facultyName ?d))
=>
(send ?name printCoursesF)
)
;all Lecturer belonging to a Faculty.
(defrule print-Lecturer-Faculty
(declare (salience 3))
?y <- (FacL ?d)
(object (name ?name) (FacultyNameL ?d) (is-a Lecturer))
=>
(send ?name printLecturer)
)
;all Lecturer belonging to a Faculty.
(defrule print-faculties-university
(declare (salience 0))
?y <- (University ?U)
(object (name ?name) (university ?U) (is-a Faculty))
=>
(send ?name printFaculty)
)
(defmessage-handler TA printNames ()
(bind ?Names (send ?self get-Name))
(printout t ?Names crlf)
(open "TEMP/GUI1.txt" data "a")
(printout t ?Names crlf)
(printout data ?Names crlf)
(close data)
)
(defmessage-handler Student printCourses ()
(bind ?courses (send ?self get-courses))
(open "TEMP/GUI2.txt" data "a")
(printout t ?courses crlf)
(printout data ?courses crlf)
(close data)
)
(defmessage-handler Course printCoursesF ()
(bind ?Names (send ?self get-Name))
(open "TEMP/GUI3.txt" data "a")
(printout t ?Names crlf)
(printout data ?Names crlf)
(close data)
)
(defmessage-handler Lecturer printLecturer ()
(bind ?Names (send ?self get-Name))
(open "TEMP/GUI4.txt" data "a")
(printout t ?Names crlf)
(printout data ?Names crlf)
(close data)
)
(defmessage-handler Faculty printFaculty ()
(bind ?Names (send ?self get-Name))
(open "TEMP/GUI5.txt" data "a")
(printout t ?Names crlf)
(printout data ?Names crlf)
(close data)
)