4 solveGoal Proof solvetrue true solveA B Proof
Μέτα-μεταφραστές • Παράδειγμα 4 (Δέντρο Απόδειξης): %solve(Goal, Proof) – solve(true, true). – solve((A, B) (Proof. A, Proof. B)): solve-one(A, Proof. A), solve(B, Proof. B). – solve(A, (A isa builtin)): -builtin(A), A. – solve(A, (A follows from Proof)): clause(A, B), solve(B, Proof).
Μέτα-μεταφραστές • Παράδειγμα 4 (Δέντρο Απόδειξης-Αλλαγή): %solve(Goal, Proof) – solve(true, true). – solve((A, B) (Proof. A, Proof. B)): solve-one(A, Proof. A), solve(B, Proof. B). – solve(A, (A isa builtin)): -builtin(A), A. – solve(A, (A is a fact)): clause(A, B), B = true. – solve(A, (A follows from Proof)): clause(A, B), B = true, solve(B, Proof).
Παράδειγμα Πρόγραμμα αντικειμένου P: son (X, Y) : - father (Y, X), male (X). daughter (X, Y) : - father (Y, X), female (X). father (haran, lot). male (isaac) female () father (abraham, isaac). male (lot) ? solve (son (lot, haran), Proof). Yes Proof = (son (lot, haran) follows ((father (haren, lot) is a fact), (male (lot) is a fact)))
Ανιχνευτής της Prolog % solve_trace ( Goal) Goal is true given the Prolog program defined by clause/2. The program traces the proof by side effects. solve_trace (Goal) solve_trace (Goal, 0). solve_trace (true, Depth) !. solve_trace ((A, B), Depth) !, solve_trace(A, Depth), solve_trace(B, Depth). solve_trace (A, Depth) builtin (A), !, A, display (A, Depth), nl. solve_trace (A, Depth) clause (A, B), display (A, Depth), nl, Depth 1 is Depth + 1, solve_trace (B, Depth 1).
Ανιχνευτής της Prolog (συν. ) display (A , Depth) Spacing is 3*Depth, put_spaces (Spacing), write (A). put_spaces (N) between (1, N, I), put_char (' '), fail. put_spaces (N). betveen(1, N, I) - See Program. 8. 5.
Προγραμματισμός – Συλλογισμός με Αβεβαιότητα solve ( Goal, Certainty) Certainty is our confidence that Goal is true. solve (true, 1) !. solve ((A, B) , C) !, solve(A, C 1), solve (B, C 2), minimum (C 1, C 2, C). solve (A, 1) builtin (A), !, A. solve (A, C) clause_cf (A, B, C 1), solve(B, C 2), C is C 1 * C 2. clause_cf (A, B, C 1) : - …. (Ανάλογα με την αναπαράσταση της γνώσης στους κανόνες αντικειμένου)
Προγραμματισμός – Συλλογισμός με Αβεβαιότητα solve ( Goal, Certainty, Threshold) Certainty is our confidence, greater than Threshold, that Goal is true solve (true, 1, T) !. solve ((A, B), C, T) !, solve(A, C 1, T), solve(B, C 2, T), minimum(C 1, C 2, C). solve (A, 1, T) builtin (A), !, A. solve (A, C, T) clause_cf (A, B, C 1), C 1 > T, T 1 is T/C 1, solve (B, C 2, T 1), C is C 1 * C 2.
- Slides: 12