Bounded Solve boundedsolve Goal Depth Goal Depth boundedsolve
Bounded Solve % bounded_solve (Goal, Depth) – Ισχύει όταν ο στόχος Goal έχει απόδειξη βάθους μικρότερου ή ισου του Depth. bounded_solve (true, X) bounded_ solve ((A, B), X): - bounded_solve(A, X), bounded_solve(B, X). bounded_solve (A, X): - system (A), A. bounded_solve (A, X): - X ≥ 0, clause (A, B), X 1 is X-1, bounded_solve(B, X 1). % bounded_solve (Goal, Depth, Proof). bounded_solve (true, X, true). bounded_solve (A, B), X, (Proof. A, Proof. B)): - bounded_solve (A, X, Proof. A), bounded_solve (B, X, Proof. B). bounded_solve (A, X, (A is a system predicate)): - system(A), A. bounded_solve (A, X, (A follows from Proof)): - X ≥ 0, clause (A, B), X 1 is X-1, bounded_solve (B, X 1 , Proof).
Προσομοίωση με επεξήγηση shell <-- prompt, read(G), do(G). prompt <-- write ('Next command? '). do (exit) < -- ! do(G) <-- ground(G), !, answer_ground(G), shell. do(G) <-- answer(G), shell. answer_ground(G) <-- solve 2(G, Proof), !, write('Yes'), nl, write('Would you like an explanation? ’), nl, read (Answer), act(Answer, Proof). answer_ground(G) <-- write ('No'), nl.
Προσομοίωση με επεξήγηση (συν. ) answer(G) <-- solve 2(G, Proof), !, write(G), nl, write('Would you like an explanation? '), nl, read(Answer) , act(Answer, Proof), fail. answer(G) < -- write('No (more) solutions'), nl. act(yes, Proof) <-- present(Proof), nl. act(no, Proof). solve 2(true, true) solve 2((A, B), (Proof. A, Proof. B)): - solve 2(A, Proof A), solve 2 (B, Proof. B). solve 2((A, (A <-- true)): - clause(A, B), B==true, solve 2(A, (A <-- Proof)): - clause(A, B), B=/=true, solve 2(B, Proof).
Άσκηση 8 – Λύση [2] (συνέχεια) present((Proof 1, Proof 2)) < present(Proof 1), present(Proof 2). present(Proof) < fact(Proof, Fact), nl, writeln ([Fact, 'is a fact in the program. ']). present(Proof) < rule(Proof, Head, Body, Rest), nl, writeln([Head, 'is proved using the rule']), display _rule(Head, Body)), present(Rest). fact((Fact < true), Fact). rule((Goal < Proof), Goal, Body, Proof) < Proof ≠ true, extract_body(Proof, Body) extract_body ((Proof 1 , Proof 2), (Body 1, Body 2)) < !, extract_body(Proof 1 , Body 1), extract_ body(Proof 2, Body 2). extract_body((Goal < Proof), Goal)).
- Slides: 5