-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexpertSystem.clp
More file actions
525 lines (523 loc) · 14.7 KB
/
expertSystem.clp
File metadata and controls
525 lines (523 loc) · 14.7 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
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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
CLIPS (6.30 3/17/15)
CLIPS> (defrule Menu
(not(viewingMethod ?))
=>
(printout t crlf crlf
"The celestial object is viewed by " crlf crlf
"(1):By naked-eye" crlf crlf
"(2):By special instruments" crlf crlf
"Enter your response (1|2) :")
(assert (viewingMethod (read))))
CLIPS> (defrule Naked_Eye
(viewingMethod 1)
(not(objectAppearance ?))
=>
(printout t crlf
"Celestial object has an appearance like..." crlf
"(1):A point light" crlf
"(2):A extended light" crlf
"Enter your response (1|2): ")
(assert (objectAppearance (read))))
CLIPS> (defrule PointLight
(viewingMethod 1)
(objectAppearance 1)
?retractResApp <- (objectAppearance 1)
?retractResView <- (viewingMethod 1)
(not(isTwinkling ?))
=>
(retract ?retractResApp)
(retract ?retractResView)
(printout t crlf
"Is point light is twinkling" crlf
"(1):Yes" crlf
"(2):No" crlf
"Enter your response (1|2): ")
(assert (isTwinkling (read))))
CLIPS> (defrule ExtendedLight
(viewingMethod 1)
(objectAppearance 2)
?retractResApp <- (objectAppearance 2)
?retractResView <- (viewingMethod 1)
(not(isLocatedInPolarRegion ?))
=>
(retract ?retractResApp)
(retract ?retractResView)
(printout t crlf
"Is extended light is appearing in polar regions..." crlf
"(1):Yes" crlf
"(2):No" crlf
"Enter your response (1|2): ")
(assert (isLocatedInPolarRegion (read))))
CLIPS> (defrule Twinkling
(isTwinkling 1)
?retractResTwin <- (isTwinkling 1)
(not(hasMotion ?))
=>
(retract ?retractResTwin)
(printout t crlf
"Object has a motion..." crlf
"(1):Relative to other stars" crlf
"(2):Relative to earth" crlf
"Enter your response (1|2): ")
(assert (hasMotion (read))))
CLIPS> (defrule NotTwinkling
(isTwinkling 2)
?retractResTwin <- (isTwinkling 2)
(not(hasMotion ?))
=>
:;(retract ?retractResTwin)
(printout t crlf
"Object has a motion..." crlf
"(1):Orbital motion" crlf
"(2):Non orbital" crlf
"Enter your response (1|2): ")
(assert (hasMotion (read))))
CLIPS> (defrule RelativeToOtherStars
(not(isTwinkling 2))
(hasMotion 1)
?retractResMos <- (hasMotion 1)
=>
(retract ?retractResMos)
(printout t crlf
"<==== Final Output ====>" crlf
"The celestial objecct is a proper motion star!"))
CLIPS> (defrule RelativeToEarth
(not(isTwinkling 2))
(hasMotion 2)
?retractResMos <- (hasMotion 2)
(not(visibleLightColorOfObject ?))
=>
(retract ?retractResMos)
(printout t crlf
"Visible light color of object is..." crlf
"(1): Red" crlf
"(2): Blue" crlf
"Enter your response (1|2): ")
(assert (visibleLightColorOfObject (read))))
CLIPS> (defrule lightColorRed
(visibleLightColorOfObject 1)
?retractResColor <- (visibleLightColorOfObject 1)
=>
(retract ?retractResColor)
(printout t crlf
"<==== Final Output ====>" crlf
"The celestial objecct is a negative radio star!"))
CLIPS> (defrule lightColorBlue
(visibleLightColorOfObject 2)
?retractResColor <- (visibleLightColorOfObject 2)
=>
(retract ?retractResColor)
(printout t crlf
"<==== Final Output ====>" crlf
"The celestial objecct is a positive radio star!"))
CLIPS> (defrule orbitalMotion
(isTwinkling 2)
(hasMotion 1)
?retractResMos <- (hasMotion 1)
?retractResTwin <- (isTwinkling 2)
(not(orbitIsAround ?))
=>
(retract ?retractResMos)
(retract ?retractResTwin)
(printout t crlf
"Orbit of celestail object is around..." crlf
"(1):A star" crlf
"(2):A planet" crlf
"Enter your response (1|2): ")
(assert (orbitIsAround (read))))
CLIPS> (defrule centralizedStarObject
(orbitIsAround 1)
?retractResCenter <- (orbitIsAround 1)
=>
(retract ?retractResCenter)
(printout t crlf
"<==== Final Output ====>" crlf
"The celestial objecct is a planet!"))
CLIPS> (defrule centralizedPlanetObject
(orbitIsAround 2)
?retractResCenter <- (orbitIsAround 2)
=>
(retract ?retractResCenter)
(printout t crlf
"<==== Final Output ====>" crlf
"The celestial objecct is a moon!"))
CLIPS> (defrule nonOrbitalMotion
(isTwinkling 2)
(hasMotion 2)
?retractResMos <- (hasMotion 2)
?retractResTwin <- (isTwinkling 2)
(not(orbitIsAround ?))
=>
(retract ?retractResMos)
(retract ?retractResTwin)
(printout t crlf
"<==== Final Output ====>" crlf
"The celestial objecct is an UFO or Unknown object!"))
CLIPS> (defrule polarRegion
(isLocatedInPolarRegion 1)
?retractResPolar <- (isLocatedInPolarRegion 1)
=>
(retract ?retractResPolar)
(printout t crlf
"<==== Final Output ====>" crlf
"The celestial objecct is an aurora!"))
CLIPS> (defrule notPolarRegion
(isLocatedInPolarRegion 2)
?retractResPolar <- (isLocatedInPolarRegion 2)
=>
(retract ?retractResPolar)
(printout t crlf
"<==== Final Output ====>" crlf
"The celestial objecct is a galaxy or a nebulae!"))
CLIPS> (defrule specialInstruments
(viewingMethod 2)
?retractRes1 <- (viewingMethod 2)
(not(objectAppearance ?))
=>
(printout t crlf
"Celestial object has an appearance like..." crlf
"(1):A spiral" crlf
"(2):An elliptical" crlf
"(3):A lenticular" crlf
"(4):A fuzzy tail and head with distinct nucleus" crlf
"(5):A faint point of light and irregular shape" crlf
"(6):A diffusive and cloudy" crlf
"(7):A sphere shape" crlf
"Enter your response (1|2|3|4|5|6|7): ")
(assert (objectAppearance (read))))
CLIPS> (defrule spiralEllipticalLenticular
(or (objectAppearance 1) (objectAppearance 2) (objectAppearance 3))
(viewingMethod 2)
?retractResApp <- (objectAppearance ?option)
?retractResView <- (viewingMethod 2)
(not(luminosityLvl ?))
=>
(retract ?retractResApp)
(retract ?retractResView)
(printout t crlf
"What is the luminosity level as percentage..." crlf
"Enter your response (Eg-40): ")
(assert (luminosityLvl (read))))
CLIPS> (defrule luminosityLevel
(luminosityLvl ?luminosityLvl)
?retractResLum <- (luminosityLvl ?luminosityLvl)
=>
(if (<= ?luminosityLvl 100)
then
(if (>= ?luminosityLvl 70)
then
(retract ?retractResLum)
(printout t
"<==== Final Output ====>" crlf
"The celestial objecct is a quasar luminosity galaxy!" crlf)
)
(if (and (< ?luminosityLvl 70) (>= ?luminosityLvl 40))
then
(retract ?retractResLum)
(printout t
"<==== Final Output ====>" crlf
"The celestial objecct is an sub luminous galaxy!" crlf)
)
(if (and (< ?luminosityLvl 40) (>= ?luminosityLvl 0))
then
(retract ?retractResLum)
(printout t
"<==== Final Output ====>" crlf
"The celestial objecct is a low luminosity galaxy!" crlf)
)
else
(retract ?retractResLum)
(printout t "Invalid luminosity level" crlf)
)
)
CLIPS> (defrule fuzzyTailNucleus
(objectAppearance 4)
(viewingMethod 2)
?retractResApp <- (objectAppearance 4)
?retractResView <- (viewingMethod 2)
(not(orbitNature ?))
=>
(retract ?retractResApp)
(retract ?retractResView)
(printout t crlf
"Has an orbit which is..." crlf
"(1): near to the sun" crlf
"(2): near to the jupiter" crlf
"(3): disrupted or destroyed"
"Enter your response(1|2|3): ")
(assert (orbitNature (read))))
CLIPS> (defrule OrbitNature
(orbitNature ?orbitNature)
?retractResOrbit <- (orbitNature ?orbitNature)
=>
(if (<= ?orbitNature 3)
then
(if (= ?orbitNature 1)
then
(retract ?retractResOrbit)
(printout t
"<==== Final Output ====>" crlf
"The celestial objecct is a sungrazer comet!" crlf)
)
(if (= ?orbitNature 2)
then
(retract ?retractResOrbit)
(printout t
"<==== Final Output ====>" crlf
"The celestial objecct is a jupiter-family comet!" crlf)
)
(if (= ?orbitNature 3)
then
(retract ?retractResOrbit)
(printout t
"<==== Final Output ====>" crlf
"The celestial objecct is an extinct comet!" crlf)
)
else
(retract ?retractResOrbit)
(printout t "Invalid answer" crlf)
)
)
CLIPS> (defrule asteroidColorFinder
(objectAppearance 5)
(viewingMethod 2)
?retractResApp <- (objectAppearance 5)
?retractResView <- (viewingMethod 2)
(not(asteroidColor ?))
=>
(retract ?retractResApp)
(retract ?retractResView)
(printout t crlf
"Visible color of comet is..." crlf
"(1): dark reddish" crlf
"(2): bright reddish" crlf
"(3): metalic" crlf
"Enter your response(1|2|3): ")
(assert (asteroidColor (read))))
CLIPS> (defrule asteroidTypeFinder
(asteroidColor ?asteroidColor)
?retractResAsteroidColor <- (asteroidColor ?asteroidColor)
=>
(if (<= ?asteroidColor 3)
then
(if (= ?asteroidColor 1)
then
(retract ?retractResAsteroidColor)
(printout t
"<==== Final Output ====>" crlf
"The celestial objecct is a type C asteroid!" crlf)
)
(if (= ?asteroidColor 2)
then
(retract ?retractResAsteroidColor)
(printout t
"<==== Final Output ====>" crlf
"The celestial objecct is a type S asteroid!" crlf)
)
(if (= ?asteroidColor 3)
then
(retract ?retractResAsteroidColor)
(printout t
"<==== Final Output ====>" crlf
"The celestial objecct is a type M asteroid!" crlf)
)
else
(retract ?retractResAsteroidColor)
(printout t "Invalid answer" crlf)
)
)
CLIPS> (defrule nebulaeCompositionFinder
(objectAppearance 6)
(viewingMethod 2)
?retractResApp <- (objectAppearance 6)
?retractResView <- (viewingMethod 2)
(not(nebulaeComposition ?))
=>
(retract ?retractResApp)
(retract ?retractResView)
(printout t crlf
"The celestial object is composed by..." crlf
"(1): gas and dust" crlf
"(2): remnants of stars" crlf
"Enter your response(1|2): ")
(assert (nebulaeComposition (read))))
CLIPS> (defrule asteroidColorSet1Finder
(nebulaeComposition 1)
(not(nebColor ?))
=>
(printout t crlf
"Visible color of the object is..." crlf
"(1): Red" crlf
"(2): Black" crlf
"(3): Other" crlf
"Enter your response(1|2|3): ")
(assert (nebColor (read)))
)
CLIPS> (defrule asteroidColorSet2Finder
(nebulaeComposition 2)
(not(nebColor ?))
=>
(printout t crlf
"Visible color of the object is..." crlf
"(1): Green" crlf
"(2): black" crlf
"Enter your response(1|2): ")
(assert (nebColor (read)))
)
CLIPS> (defrule nebulaeTypeFinder
(nebulaeComposition ?nebulaeComposition)
(nebColor ?nebColor)
?retractResNebColor <- (nebColor ?nebColor)
?retractResNebComp <- (nebulaeComposition ?nebulaeComposition)
=>
(if (= ?nebulaeComposition 1)
then
(if (= ?nebColor 1)
then
(retract ?retractResNebColor)
(retract ?retractResNebComp)
(printout t
"<==== Final Output ====>" crlf
"The celestial objecct is an emission nebulae!" crlf)
)
(if (= ?nebColor 2)
then
(retract ?retractResNebColor)
(retract ?retractResNebComp)
(printout t
"<==== Final Output ====>" crlf
"The celestial objecct is a dark nebulae!" crlf)
)
(if (= ?nebColor 3)
then
(retract ?retractResNebColor)
(retract ?retractResNebComp)
(printout t
"<==== Final Output ====>" crlf
"The celestial objecct is a reflection nebulae!" crlf)
)
else
(retract ?retractResNebColor)
(retract ?retractResNebComp)
)
(if (= ?nebulaeComposition 2)
then
(if (= ?nebColor 1)
then
(retract ?retractResNebColor)
(retract ?retractResNebComp)
(printout t
"<==== Final Output ====>" crlf
"The celestial objecct is a planetary nebulae!" crlf)
)
(if (= ?nebColor 2)
then
(retract ?retractResNebColor)
(retract ?retractResNebComp)
(printout t
"<==== Final Output ====>" crlf
"The celestial objecct is an emission nebulae!" crlf)
)
else
(retract ?retractResNebColor)
(retract ?retractResNebComp)
)
)
CLIPS> (defrule gravitationalPowerDetector
(objectAppearance 7)
(viewingMethod 2)
?retractResApp <- (objectAppearance 7)
?retractResView <- (viewingMethod 2)
(not(natureOfGravity ?))
=>
(retract ?retractResApp)
(retract ?retractResView)
(printout t crlf
"Object has a " crlf
"(1): Abnormal massive gravitational power" crlf
"(2): Normal gravitational power" crlf
"Enter your response(1|2): ")
(assert (natureOfGravity (read))))
CLIPS> (defrule solarMassesFinder
(natureOfGravity 1)
?retractResGrav <- (natureOfGravity 1)
(not(noOfSolarMasses ?))
=>
(retract ?retractResGrav)
(printout t crlf
"How many number of solar masses involve to create..." crlf
"(1): 1-100" crlf
"(2): 100-100000" crlf
"(3): 100000-10^9" crlf
"Enter your response(1|2|3): ")
(assert (noOfSolarMasses (read))))
CLIPS> (defrule natureOFLightEmission
(natureOfGravity 2)
?retractResGrav <- (natureOfGravity 2)
(not(isLightsource ?))
=>
(retract ?retractResGrav)
(printout t crlf
"Is object a light source..." crlf
"(1): Yes" crlf
"(2): No" crlf crlf
"Enter your response(1|2): ")
(assert (isLightsource (read))))
CLIPS> (defrule blackHoleTypeFinder
(noOfSolarMasses ?noOfSolarMasses)
?retractResSolarMasses <- (noOfSolarMasses ?noOfSolarMasses)
=>
(if (<= ?noOfSolarMasses 3)
then
(if (= ?noOfSolarMasses 1)
then
(retract ?retractResSolarMasses)
(printout t
"<==== Final Output ====>" crlf
"The celestial objecct is a stellar black hole!" crlf)
)
(if (= ?noOfSolarMasses 2)
then
(retract ?retractResSolarMasses)
(printout t
"<==== Final Output ====>" crlf
"The celestial objecct is an intermidiate mass black hole!" crlf)
)
(if (= ?noOfSolarMasses 3)
then
(retract ?retractResSolarMasses)
(printout t
"<==== Final Output ====>" crlf
"The celestial objecct is a super massive black hole!" crlf)
)
else
(retract ?retractResSolarMasses)
(printout t "Invalid answer" crlf)
)
)
CLIPS> (defrule objectFinder
(isLightsource ?isLightsource)
?retractResLight <- (isLightsource ?isLightsource)
=>
(if (<= ?isLightsource 2)
then
(if (= ?isLightsource 1)
then
(retract ?retractResLight)
(printout t
"<==== Final Output ====>" crlf
"The celestial objecct is a star!" crlf)
)
(if (= ?isLightsource 2)
then
(retract ?retractResLight)
(printout t
"<==== Final Output ====>" crlf
"The celestial objecct is a planet!" crlf)
)
else
(retract ?retractResLight)
(printout t "Invalid answer" crlf)
)
)
CLIPS>