Logtalk 2.26.2 files.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1487 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
11
Logtalk/examples/lpa/faults/NOTES
Normal file
11
Logtalk/examples/lpa/faults/NOTES
Normal file
@@ -0,0 +1,11 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.26.2
|
||||
|
||||
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
||||
|
||||
This example is an adaptation of the LPA Prolog++ faults example.
|
||||
|
||||
To load this example and for sample queries, please see the SCRIPT file.
|
34
Logtalk/examples/lpa/faults/SCRIPT
Normal file
34
Logtalk/examples/lpa/faults/SCRIPT
Normal file
@@ -0,0 +1,34 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.26.2
|
||||
|
||||
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
||||
|
||||
% start by loading the necessary library support files (if not
|
||||
% already loaded):
|
||||
|
||||
| ?- logtalk_load(library(hierarchies_loader)).
|
||||
...
|
||||
|
||||
|
||||
% now you are ready for loading the example:
|
||||
|
||||
| ?- logtalk_load(lpa_faults(loader)).
|
||||
...
|
||||
|
||||
|
||||
| ?- fault::findall.
|
||||
|
||||
Please answer all questions with yes or no.
|
||||
|
||||
The starter turns but the engine doesnt fire? no.
|
||||
The engine has difficulty starting? yes.
|
||||
The engine cuts out shortly after starting? yes.
|
||||
|
||||
Location : distributor
|
||||
Possible Fault: Worn distributor brushes
|
||||
|
||||
No (more) explanations found.
|
||||
yes.
|
6
Logtalk/examples/lpa/faults/cylinders.lgt
Normal file
6
Logtalk/examples/lpa/faults/cylinders.lgt
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
:- object(cylinders,
|
||||
extends(engine)).
|
||||
|
||||
|
||||
:- end_object.
|
25
Logtalk/examples/lpa/faults/distributor.lgt
Normal file
25
Logtalk/examples/lpa/faults/distributor.lgt
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
:- object(distributor,
|
||||
extends(sparking)).
|
||||
|
||||
|
||||
fault(f1001, 'Condensation in the distributor cap').
|
||||
fault(f1002, 'Faulty distributor arm').
|
||||
fault(f1003, 'Worn distributor brushes').
|
||||
|
||||
symptom(s1001, 'The starter turns but the engine doesnt fire').
|
||||
symptom(s1002, 'The engine has difficulty starting').
|
||||
symptom(s1003, 'The engine cuts out shortly after starting').
|
||||
symptom(s1004, 'The engine cuts out at speed').
|
||||
|
||||
effect(f1001, s1001).
|
||||
effect(f1002, s1001).
|
||||
effect(f1002, s1004).
|
||||
effect(f1003, s1002).
|
||||
effect(f1003, s1003).
|
||||
|
||||
contrary(s1002, s1001).
|
||||
contrary(s1003, s1001).
|
||||
|
||||
|
||||
:- end_object.
|
6
Logtalk/examples/lpa/faults/electrical.lgt
Normal file
6
Logtalk/examples/lpa/faults/electrical.lgt
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
:- object(electrical,
|
||||
extends(fault)).
|
||||
|
||||
|
||||
:- end_object.
|
6
Logtalk/examples/lpa/faults/engine.lgt
Normal file
6
Logtalk/examples/lpa/faults/engine.lgt
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
:- object(engine,
|
||||
extends(mechanical)).
|
||||
|
||||
|
||||
:- end_object.
|
72
Logtalk/examples/lpa/faults/fault.lgt
Normal file
72
Logtalk/examples/lpa/faults/fault.lgt
Normal file
@@ -0,0 +1,72 @@
|
||||
|
||||
:- object(fault,
|
||||
imports(proto_hierarchy)).
|
||||
|
||||
|
||||
:- info([
|
||||
author is 'Paulo Moura',
|
||||
version is 1.0,
|
||||
date is 2000/4/22,
|
||||
comment is 'Expert system for automobile fault diagnosis.',
|
||||
source is 'Example adopted from the LPA Prolog++ documentation.']).
|
||||
|
||||
|
||||
:- public(findall/0).
|
||||
:- mode(findall, one).
|
||||
|
||||
:- private(told_by_user_/2).
|
||||
:- dynamic(told_by_user_/2).
|
||||
:- mode(told_by_user_(?nonvar, ?nonvar), zero_or_more).
|
||||
|
||||
:- public(find/1).
|
||||
:- mode(find(?nonvar), zero_or_more).
|
||||
|
||||
:- private(exhibited/1).
|
||||
:- mode(exhibited(+nonvar), zero_or_one).
|
||||
|
||||
:- public(contrary/2).
|
||||
:- mode(contrary(?nonvar, ?nonvar), zero_or_more).
|
||||
|
||||
:- public(fault/2).
|
||||
:- mode(fault(?nonvar, ?nonvar), zero_or_more).
|
||||
|
||||
:- public(effect/2).
|
||||
:- mode(effect(?nonvar, ?nonvar), zero_or_more).
|
||||
|
||||
:- public(symptom/2).
|
||||
:- mode(symptom(?nonvar, ?nonvar), zero_or_more).
|
||||
|
||||
|
||||
findall :-
|
||||
retractall(told_by_user_(_, _)),
|
||||
write('Please answer all questions with yes or no.'), nl, nl,
|
||||
forall(
|
||||
(::descendant(Where), Where::find(Description)),
|
||||
(nl, write('Location : '), write(Where), nl,
|
||||
write('Possible Fault: '), write(Description), nl)),
|
||||
nl, write('No (more) explanations found.').
|
||||
|
||||
|
||||
find(Description) :-
|
||||
::fault(Fault, Description),
|
||||
forall(::effect(Fault, Symptom), exhibited(Symptom)).
|
||||
|
||||
|
||||
exhibited(Symptom) :-
|
||||
told_by_user_(Symptom, Reply),
|
||||
!,
|
||||
Reply = yes.
|
||||
|
||||
exhibited(Symptom) :-
|
||||
::symptom(Symptom, Description),
|
||||
write(Description), write('? '),
|
||||
read(Reply),
|
||||
asserta(told_by_user_(Symptom, Reply)),
|
||||
Reply = yes,
|
||||
forall(
|
||||
(::contrary(Symptom, Contrary);
|
||||
::contrary(Contrary, Symptom)),
|
||||
asserta(told_by_user_(Contrary, no))).
|
||||
|
||||
|
||||
:- end_object.
|
178
Logtalk/examples/lpa/faults/faults.lgt
Normal file
178
Logtalk/examples/lpa/faults/faults.lgt
Normal file
@@ -0,0 +1,178 @@
|
||||
|
||||
:- object(fault,
|
||||
imports(proto_hierarchy)).
|
||||
|
||||
:- info([
|
||||
author is 'Paulo Moura',
|
||||
version is 1.0,
|
||||
date is 2000/4/22,
|
||||
comment is 'Expert system for automobile fault diagnosis.',
|
||||
source is 'Example adopted from the LPA Prolog++ documentation.']).
|
||||
|
||||
:- public(findall/0).
|
||||
:- mode(findall, one).
|
||||
|
||||
:- private(told_by_user_/2).
|
||||
:- dynamic(told_by_user_/2).
|
||||
:- mode(told_by_user_(?nonvar, ?nonvar), zero_or_more).
|
||||
|
||||
:- public(find/1).
|
||||
:- mode(find(?nonvar), zero_or_more).
|
||||
|
||||
:- private(exhibited/1).
|
||||
:- mode(exhibited(+nonvar), zero_or_one).
|
||||
|
||||
:- public(contrary/2).
|
||||
:- mode(contrary(?nonvar, ?nonvar), zero_or_more).
|
||||
|
||||
:- public(fault/2).
|
||||
:- mode(fault(?nonvar, ?nonvar), zero_or_more).
|
||||
|
||||
:- public(effect/2).
|
||||
:- mode(effect(?nonvar, ?nonvar), zero_or_more).
|
||||
|
||||
:- public(symptom/2).
|
||||
:- mode(symptom(?nonvar, ?nonvar), zero_or_more).
|
||||
|
||||
findall :-
|
||||
retractall(told_by_user_(_, _)),
|
||||
write('Please answer all questions with yes or no.'), nl, nl,
|
||||
forall(
|
||||
(::descendant(Where), Where::find(Description)),
|
||||
(nl, write('Location : '), write(Where), nl,
|
||||
write('Possible Fault: '), write(Description), nl)),
|
||||
nl, write('No (more) explanations found.').
|
||||
|
||||
find(Description) :-
|
||||
::fault(Fault, Description),
|
||||
forall(::effect(Fault, Symptom), exhibited(Symptom)).
|
||||
|
||||
exhibited(Symptom) :-
|
||||
told_by_user_(Symptom, Reply) ->
|
||||
Reply = yes
|
||||
;
|
||||
::symptom(Symptom, Description),
|
||||
write(Description), write('? '),
|
||||
read(Reply),
|
||||
asserta(told_by_user_(Symptom, Reply)),
|
||||
Reply = yes,
|
||||
forall(
|
||||
(::contrary(Symptom, Contrary); ::contrary(Contrary, Symptom)),
|
||||
asserta(told_by_user_(Contrary, no))).
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
|
||||
/* electrical sub-system:
|
||||
|
||||
electrical
|
||||
lights
|
||||
starting
|
||||
sparking
|
||||
distributor
|
||||
plugs
|
||||
starter_motor
|
||||
|
||||
*/
|
||||
|
||||
|
||||
:- object(electrical,
|
||||
extends(fault)).
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
:- object(lights,
|
||||
extends(electrical)).
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
:- object(starting,
|
||||
extends(electrical)).
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
:- object(sparking,
|
||||
extends(starting)).
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
:- object(distributor,
|
||||
extends(sparking)).
|
||||
|
||||
fault(f1001, 'Condensation in the distributor cap').
|
||||
fault(f1002, 'Faulty distributor arm').
|
||||
fault(f1003, 'Worn distributor brushes').
|
||||
|
||||
symptom(s1001, 'The starter turns but the engine doesnt fire').
|
||||
symptom(s1002, 'The engine has difficulty starting').
|
||||
symptom(s1003, 'The engine cuts out shortly after starting').
|
||||
symptom(s1004, 'The engine cuts out at speed').
|
||||
|
||||
effect(f1001, s1001).
|
||||
effect(f1002, s1001).
|
||||
effect(f1002, s1004).
|
||||
effect(f1003, s1002).
|
||||
effect(f1003, s1003).
|
||||
|
||||
contrary(s1002, s1001).
|
||||
contrary(s1003, s1001).
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
:- object(plugs,
|
||||
extends(sparking)).
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
:- object(starter_motor,
|
||||
extends(starting)).
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
|
||||
/* mechanical sub-system:
|
||||
|
||||
mechanical
|
||||
engine
|
||||
cylinders
|
||||
*/
|
||||
|
||||
|
||||
:- object(mechanical,
|
||||
extends(fault)).
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
:- object(engine,
|
||||
extends(mechanical)).
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
:- object(cylinders,
|
||||
extends(engine)).
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
|
||||
/* fuel_system sub-system:
|
||||
|
||||
fuel_system
|
||||
...
|
||||
*/
|
||||
|
||||
|
||||
:- object(fuel_system,
|
||||
extends(fault)).
|
||||
|
||||
:- end_object.
|
6
Logtalk/examples/lpa/faults/fuel_system.lgt
Normal file
6
Logtalk/examples/lpa/faults/fuel_system.lgt
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
:- object(fuel_system,
|
||||
extends(fault)).
|
||||
|
||||
|
||||
:- end_object.
|
6
Logtalk/examples/lpa/faults/lights.lgt
Normal file
6
Logtalk/examples/lpa/faults/lights.lgt
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
:- object(lights,
|
||||
extends(electrical)).
|
||||
|
||||
|
||||
:- end_object.
|
13
Logtalk/examples/lpa/faults/loader.lgt
Normal file
13
Logtalk/examples/lpa/faults/loader.lgt
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
:- initialization(
|
||||
logtalk_load([
|
||||
faults])).
|
||||
|
||||
/*
|
||||
If you intend to use the FOP XSL:FO processor for generating PDF documenting
|
||||
files, comment the directive above and uncomment the directive below
|
||||
|
||||
:- initialization(
|
||||
logtalk_load(
|
||||
[faults], [xmlsref(standalone)])).
|
||||
*/
|
6
Logtalk/examples/lpa/faults/mechanical.lgt
Normal file
6
Logtalk/examples/lpa/faults/mechanical.lgt
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
:- object(mechanical,
|
||||
extends(fault)).
|
||||
|
||||
|
||||
:- end_object.
|
6
Logtalk/examples/lpa/faults/plugs.lgt
Normal file
6
Logtalk/examples/lpa/faults/plugs.lgt
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
:- object(plugs,
|
||||
extends(sparking)).
|
||||
|
||||
|
||||
:- end_object.
|
6
Logtalk/examples/lpa/faults/sparking.lgt
Normal file
6
Logtalk/examples/lpa/faults/sparking.lgt
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
:- object(sparking,
|
||||
extends(starting)).
|
||||
|
||||
|
||||
:- end_object.
|
6
Logtalk/examples/lpa/faults/starter_motor.lgt
Normal file
6
Logtalk/examples/lpa/faults/starter_motor.lgt
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
:- object(starter_motor,
|
||||
extends(starting)).
|
||||
|
||||
|
||||
:- end_object.
|
6
Logtalk/examples/lpa/faults/starting.lgt
Normal file
6
Logtalk/examples/lpa/faults/starting.lgt
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
:- object(starting,
|
||||
extends(electrical)).
|
||||
|
||||
|
||||
:- end_object.
|
Reference in New Issue
Block a user