(. . 15.2) . (, ieak_in_kitchen - ), . , prcblem_in_kitchen ( ) no_Mater_from_outaide ( ) . , , . , , .
, , (leak:_in_kitchen) (hall_wet - ..). Prolog , , Prolog. Prolog :
leak in bathroom:- 4
hall_wet, %
kitchen_dry. %
prablem_in_kitchea: - %
15.
hallwet, %
bathroom dry. %
no_water_from_outside r- %
window_closed %
no_rain. %
leak in kitchen:- %
Problem_in_kitchen, % no_water_from_outside. %
Prolog :
hall wet. %
bathroom_dry. %
window_closed, %
, ' :
? - leak_in_kitchen. %
yes
Prolog, , , .
1. , Prolog; , , , .
2. ; .
, Prolog. , "if, "then", "and" "or" , , .
|
|
op ( xfx, " t) hen).
:- 5! 300, %, and).
, , . 15.2, :
if
hall_wet and kitchen_dry
then
leak_inJbathroom,
if
hall wet and bathroom dry
then
problem_in_kitchen.
if
window_closed or no_rain then
no water from outside.
, fact:
332 II. Prolog
factC hall_wet).
f act (bathrDDm dry).
fact(window_closed).
, , . : is_tro*H )
fact, . 15.4. , . :
?- is_true(leak_in_kitchen). yes
15.4.
:- (800, fie, if).
:- opt 700, xfx, then).
;- op(300, xfy, or).
: - opt 200, Kty, and).
IS true (P):- "fact( P).
'"if"Condition then P, % /
s_true< Condition). %
is_true(Pi and P2):-
io££i P2).
is_true(PI or P2):-is_true(Pi)
is_true(P2).
, , , , . , . , , , . 16.