-
Notifications
You must be signed in to change notification settings - Fork 176
/
expertsystem.pl
136 lines (105 loc) · 3.08 KB
/
expertsystem.pl
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
/* Author : Ely Zobi
Title : Expert System for Computer Maintenance
Status : Incomplete conversion from Turbo Prolog to ISO Prolog.
*/
/*
Problem Considered
1. Floppy Disk
2. Hard Disk
3. POST
4. Printer
5. Motherboard
6. Power Supply
*/
:- dynamic asked/2.
main :-
retractall(asked(_,_)),
fault(Problem),
!,
nl,
write('The problem is '), write(Problem), write(.), nl.
main :-
nl,
write('The problem cannot be recognized.'), nl.
problem(disc_format) :-
query('Does the computer show error cannot format').
problem(boot_failure) :-
query('Does the computer show boot failure').
problem(bad_sector) :-
query('Does the computer show bad sector error').
problem(cannot_read) :-
query('Does the computer show cannot read from specified device').
problem(long_beep) :-
query('Is there a long beep during bootup').
problem(short_beep) :-
query('Is there a short beep during bootup').
problem(two_long_beeps) :-
query('Are there two long beeps during bootup').
problem(two_short_beeps) :-
query('Are there two short beeps during bootup').
problem(blank_display) :-
query('Is there a blank display during bootup').
problem(repeating_short_beeps) :-
query('Are there repeating short beeps during bootup').
problem(continuous_beeps) :-
query('Is there a continuous beep during bootup').
problem(no_beep) :-
query('Is there a beep during bootup').
problem(not_printing) :-
query('Is there a problem with printing').
problem(missing_dots) :-
query('Is there a missing character during printing').
problem(non_uniform_printing) :-
query('Is there uniform printing').
problem(spread_ink) :-
query('Is there spreading of ink during printing').
problem(paper_jam) :-
query('Is there a paper jam during printing').
problem(out_of_paper) :-
query('Is there out-of- paper error during printing').
fault(power_supply) :-
problem(repeating_short_beeps),
problem(continuous_beeps),
problem(blank_display),
problem(no_beep).
fault(display_adapter) :-
problem(long_beep),
problem(two_short_beeps),
problem(blank_display),
problem(no_beep).
fault(motherboard) :-
problem(long_beep),
problem(short_beep).
fault(hard_disc) :-
problem(two_short_beeps),
problem(blank_display).
fault(booting_problem) :-
problem(bad_sector),
problem(boot_failure).
fault(floppy_disk_unusable) :-
problem(bad_sector),
problem(cannot_read),
problem(disc_format).
fault(printer_head) :-
problem(not_printing),
problem(missing_dots),
problem(nonuniform_printing).
fault(ribbon) :-
problem(not_printing),
problem(missing_dots),
problem(spread_ink).
fault(paper) :-
problem(not_printing),
problem(paper_jam),
problem(out_of_paper).
query(Prompt) :-
( asked(Prompt, Reply) -> true
; nl, write(Prompt), write(' (y/n)? '), flush,
read_line_to_codes(user_input, [Initial|_]),
( [Initial] = "y" -> Reply = y
; [Initial] = "Y" -> Reply = y
; Reply = n
),
assert(asked(Prompt, Reply))
),
Reply = y.