Задание такое:
Факты: Прокол камеры влечет неисправность шины;
утечка золотника влечет неисправность шины;
неисправность шины влечет неровный ход велосипеда;
разрыв спицы влечет искривление колеса;
искривление колеса влечет неровный ход велосипеда;
повреждение троса влечет повреждение тормоза;
повреждение тормоза влечет аварийное состояние велосипеда.
Задача:
Найти все Х, где Х приводит к аварийному состоянию велосипеда
и выявить последовательность неисправностей.
Показать логический вывод.
Ввод пользователем любой характеристики неисправности велосипеда – представляет последовательность из событий приводящих к ней.
Мой вариант такой:
Кликните здесь для просмотра всего текста
Lisp |
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
| (deffunction ask-question (?question $?allowed-values)
(printout t ?question)
(bind ?answer (read))
(if (lexemep ?answer)
then
(bind ?answer (lowcase ?answer))
)
(while (not (member ?answer ?allowed-values)) do
(printout t ?question)
(bind ?answer (read))
(if (lexemep ?answer)
then (bind ?answer (lowcase ?answer)))
)?answer
)
(deffunction yes-or-no-p (?question)
(bind ?response (ask-question ?question yes no y n))
(if (or (eq ?response yes) (eq ?response y))
then TRUE
else FALSE)
)
(defrule determine-working-state ""
(initial-fact)
=>
(if (yes-or-no-p "Y vas ne tormozit velosiped? (yes/no)?")
then
(assert (defects_of_bike damage_tross is damage_to_the_brake))
(assert (working-state not-stable))
else
(assert (repair “Remont ne trebuetsa»))
(assert (working-state stable))
)
(if (yes-or-no-p "Y vas nerovnyj xod velosipeda? (yes/no)?")
then
(if (yes-or-no-p "Est li iskrevlenie kolesa? (yes/no)?")
then
(assert (defects_of_bike the_gap_in_the_spokes is bending_wheel))
(assert (working-state not-stable))
else
(assert (repair "Remont ne trebuetsa"))
(assert (working-state stable))
)
(if (yes-or-no-p "Naparuvalis na ostrue ob'ektu? (yes/no)?")
then
(assert (defects_of_bike puncture_bus_camera is flat_tire))
(assert (working-state not-stable))
else
(assert (repair "Remont ne trebuetsa"))
(assert (working-state stable))
)
(if (yes-or-no-p "Est li problemu s zolotnikom? (yes/no)?")
then
(assert (defects_of_bike the_gap_in_the_spokes is bending_wheel))
(assert (working-state not-stable))
else
(assert (repair "Remont ne trebuetsa"))
(assert (working-state stable))
)
else
(assert (working-state disenabled))
)
)
(defrule determine-power-state ""
(working-state disenabled)
(not (repair ?))
=>
(if (yes-or-no-p "Est li problemu s vilkoi(ypravliaushei) na velosipede (yes/no)? ")
then
(printout t "Mu takoe ne 4inim" crlf)
(assert (repair "Remont ne trebuetsa"))
else
(assert (repair "Y vas bolshe net voprosov"))
)
)
(defrule rule_flat_tire_1 "неисправность шины влечет неровный ход велосипеда"
(defects_of_bike puncture_bus_camera is flat_tire)
=>
(printout t "U vas nerovnyj hod velosipeda, potomu chto u vas prokol kamery" crlf)
(assert
(repair flat_tire is uneven_stroke_bike)
)
)
(defrule rule_flat_tire_2 "неисправность шины влечет неровный ход велосипеда"
(defects_of_bike leakage_of_the_valve is flat_tire)
=>
(printout t "U vas nerovnyj hod velosipeda, potomu chto u vas utechka zolotnika" crlf)
(assert
(repair flat_tire is uneven_stroke_bike)
)
)
(defrule rule_flat_tire_3 "Искривление колеса влечет неровный ход велосипеда"
(defects_of_bike the_gap_in_the_spokes is bending_wheel)
=>
(printout t "U vas nerovnyj hod velosipeda, potomu chto u vas razryv spicy" crlf)
(assert
(repair bending_wheel is uneven_stroke_bike)
)
)
(defrule damage_to_the_brake "повреждение тормоза влечет аварийное состояние велосипеда"
(defects_of_bike damage_tross is damage_to_the_brake)
=>
(printout t "U vas avarijnoe sostoyanie, potomu chto u vas povrezhden tross" crlf)
(assert
(repair damage_to_the_brake is emergency_condition)
)
) |
|
Что неправильно:
Ни одно правило не работает.
Задание очень хорошо может представлять логический вывод.
И мне послали пример где работает хотя бы 2 правила, и моя работа(код выше)
->
Что мне здесь надо исправить, вообще не могу понять, помогите кто сможет
P.S. прилагаю скриншоты которые мне прислали. С clips вообще впервые, кое как попытался понять, но не совсем еще осилил)