📄 expertsys.pro
字号:
/* The complete seashellpro expert system shell
with the marine creatures knowledge-base */
:- op(800,fx,if).
:- op(700,xfx,then).
:- op(300,xfy,or).
:- op(200,xfy,and).
:- op(800,fx,fact).
:- op(800,xfx,<=).
if east then westlake_east.
if south then westlake_south.
if southwest then westlake_southwest.
if west then westlake_west.
if north then westlake_north.
if northeast then westlake_northeast.
if middle then westlake_middle.
if westlake_east and westlake_park then child_park.
if westlake_east and westlake_house then gold_gate.
if westlake_east and westlake_load then nanshan_load.
if westlake_east and westlake_hotel then liulang_hotel.
if westlake_south and westlake_park then longbirdge_park.
if westlake_south and westlake_house then leifeng_tower.
if westlake_south and westlake_hotel then xizi_hotel.
if westlake_south and westlake_mountain then afterglow_mountain.
if westlake_south and westlake_load then southnanshan_load.
if westlake_southwest and westlake_park then flower_park.
if westlake_west and westlake_hotel then west_lake_hotel.
if westlake_west and westlake_load then sudi_load.
if sudi_load and size_large_bridge then yadi_bridge.
if sudi_load and size_middle_bridge then wangshan_bridge.
if sudi_load and size_small_bridge then yinbo_bridge.
if sudi_load and longest_bridge then suolan_bridge.
if westlake_north and westlake_load then white_load.
if white_load and size_large_bridge then jindai_bridge.
if white_load and most_old_bridge then break_bridge.
if white_load and westlake_park then zhongshan_park.
if white_load and westlake_hotel then hourseinhourse_hotel.
if white_load and westlake_house then zhejiang_library.
if white_load and westlake_mountain then loneliness_mountain.
if westlake_northeast and westlake_hotel then huaqiao_hotel.
if westlake_northeast and westlake_park then hubin_park.
if westlake_northeast and westlake_load then hubin_load.
if westlake_middle and island then mid_lake_island.
if mid_lake_island then small_continent.
/* Backward chaining inference engine with explanation facility */
is_true(P,P) :- fact P.
is_true(C, C<= ProofTreeA) :-
if A then C,
is_true(A,ProofTreeA).
is_true(P1 and P2, ProofTree1 and ProofTree2) :-
is_true(P1, ProofTree1),
is_true(P2, ProofTree2).
is_true(P1 or P2, ProofTree1) :- is_true(P1, ProofTree1).
is_true(P1 or P2, ProofTree2) :- is_true(P2, ProofTree2).
/* Forward chaining inference engine */
forward :- new_derived_fact(P), !,
write('Derived: '), write(P), nl,
assert(fact P),
forward.
forward :- write('No more facts. ').
new_derived_fact(C) :- if A then C,
not fact C,
composed_fact(A).
composed_fact(P) :- fact(P).
composed_fact(P1 and P2) :- composed_fact(P1),
composed_fact(P2).
composed_fact(P1 or P2) :- composed_fact(P1).
composed_fact(P1 or P2) :- composed_fact(P2).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -