.


:




:

































 

 

 

 


explore




explore; Goal, Trace, Answer)

Answer Goal , 16.2.2. Goal , , , Goal , AND OR

366 II. Prolog


.

Goal. - , , AND/OR, , :

(X has feathers) or {X flies} and (X lays eggs)

Trace. ,
Goal
:

Goal by Rule , Goal Rule. , , "peter isa tiger" ( - ), "peter eats meat" ( ). , , 16.1, . t (peter isa carnivore) by rule3, (peter isa tiger) by rule5 ]

.

"peter eats meat", rule3 "peter isa carnivore" ( ). , "peter isa carnivore", ruleS "peter isa tiger".

Answer. (.. AND/OR) Goal. Answer :

Conclusion was Found

Found Conclusion. , , .

1. :

(connected| heater, fusel) is true) was 'found as a fact1

2. ; (peter eats neat) is false was told

3. :

(peter isa carnivore) i3 true was ('derived by' rule3 from (peter isa mammal) is true was ('derived by- rulel from (peter has hair) is true was told) and (peter eats meat) is true was told)

explore Prolog 16.3. , 16.2.2, , .

16.3.

t % explore(Goal, Trace, Answer)

% Answer, Goal, Trace -

% , explore

% . Answer

I ,

I

:- (900, xfx,::).


16.



 

- op ( 800, xfx, was).
- op ( 870, fx,  
- op ( 880, xfx, then).
- Op ( 550, xf , or).
- op ( 540, xfy, and).
- op( 300, fx, 'derivedby')
- op ( 600, xfx, from).
- op( 600, xfx, by).

% , (700, xfx, is) 4 op! 900, fx, not)

explore! Goal, Trace, Goal is true was ' found as a fact'):-fact:: Goal.

,


Goall

explore! Goal, Trace,

derived by' Rule from Answer]:- Rule, Goal Trace], Answer),

Goal is TruthValue was

Rule:: if Condition then Goal,

explore [ Condition, [Goal by Rule

!,

truth{ Answer, TruthValue). explore) Goall and Goal2, Trace, Answer)

explore Goall, Trace, Answerl),

continues Answerl, Goall and Goal2, Trace, Answer). explore! Goal] or Goal2, Trace, Answer]:-

exploreyes! Goall, Trace, Answer) - ,


exploreyes! Goal2, Trace, Answer). l , :' Goal2 explore(Goall or Goal2, Trace, Answerl and Answer2):-!, not exploreyes! Goall, Trace, J),

not exploreyes i Goal2, Trace, _~), ': explore(Goall, Trace, Answerl), Answerl explore (Goal2, Trace, Answer2). % Answer; explore! Goal, Trace, Goal is Answer was -old):-

useransweri Goal, Trace, Answer).! ,

exploreyes! Goal, Trace, Answer):-

explore! Goal, Trace, Answer),

positive! Answer). continue! Answerl, Goall and Goal2, Trace, Answer):-

positive! Answerl),

explore! Goal2, Trace, Answer2), {positive Answer2!,

Answer = Answerl and Answer2


: -

TruthValue)

negative!. Answer2),

Answer = Answer2

). continue; Answerl, Goall and Goal2, _, Answerl)

negative! Answerl). trutht Question is TruthValue was Found, truth [ Answerl andAnswer2, TruthValue)

truth(Answerl, true),

truth! Answer2r true], I,

TruthValue - true


: -


!.


TruthValue = false. positive(Answer):-

truth I Answer, true). negative{ Answer):-

truth Answer, false).


getreply! Reply):-read (Answer), means Answer, Reply),!


% ?


 



II. Prolog


i

nl, write('Answer unknown, try again please'), nl, %

getreply(Reply). %

means(yesr yes). means { y, yes),. means { no, no). means in, no). means! why, why). meansI w, why).





:


: 2015-10-01; !; : 398 |


:

:

, , .
==> ...

1715 - | 1413 -


© 2015-2024 lektsii.org - -

: 0.009 .