Скачать презентацию Comp 307 Lecture 19 Week 3 Help Скачать презентацию Comp 307 Lecture 19 Week 3 Help

7d71deb2930475b9e2bd1bd45540ffc0.ppt

  • Количество слайдов: 18

Comp 307 Lecture 19 Week 3 • Help desks – – – Mon 4 Comp 307 Lecture 19 Week 3 • Help desks – – – Mon 4 -5 CO 238 Tutor: Su Wed 1 -2 CO 238 Tutor: Urvesh Fri 11 -12 CO 238 Tutor: Bing • Lectures: Mon, Tue, 3 -4, HU 119 • Tutorial: Fri, 3 -4, HU 119

Comp 307 Knowledge based systems Reasoning Backward chaining Forward chaining Reasoning implemented in Prolog Comp 307 Knowledge based systems Reasoning Backward chaining Forward chaining Reasoning implemented in Prolog More on Knowledge representation More on reasoning Challenges

Comp 307 Simple Rule-based System in Prolog mammal: -f(hair). mammal: -f(milk). bird: -f(feathers). bird: Comp 307 Simple Rule-based System in Prolog mammal: -f(hair). mammal: -f(milk). bird: -f(feathers). bird: -f(eggs), f(flies). carnivore: -mammal, f(meat). classify(tiger): -carnivore, f(tawny), f(striped). classify(puma): -carnivore, f(black). f(hair). f(black). f(meat). |? -classify(X). X=puma.

Comp 307 Lecture 19 An example • classify. pl – – Prolog Knowledge in Comp 307 Lecture 19 An example • classify. pl – – Prolog Knowledge in a special rule language Expert system shell/tool Backward chaining • Available on lecture page • It will ask questions, just answer “yes” or “no”, can ask “why”.

Comp 307 Rule Language for the Knowledge. Base Defining the operators : : - Comp 307 Rule Language for the Knowledge. Base Defining the operators : : - op(511, op(505, op(503, op(501, xfx, : : ). fx, if). xfx, then). xfy, and). rule 4: : if eggs and flies then bird. : : (rule 4, if(then(and(eggs, flies), bird))).

Comp 307 Operators in Prolog • Examples of operators: : - ? - , Comp 307 Operators in Prolog • Examples of operators: : - ? - , ; + - * / is • Operator declarations e. g. : - op(1200, fx, ? -). : - op(1200, xfx, : -). : - op(1000, xfy, , ). : - op(700, xfx, is). : - op(500, yfx, [+, -]). : - op(400, yfx, [*, /]).

Comp 307 Operators in Prolog • Operator precedence is represented as a number 0 Comp 307 Operators in Prolog • Operator precedence is represented as a number 0 -1200 (A higher number means a lower precedence. ) Operator types: xfx xfy yfx fx, fy xf, yf binary, infix, not associative binary, infix, right-associative binary, infix, left-associative unary, prefix unary, postfix

Comp 307 Operator Precedence and Parse Trees : - op(1200, xfx, : -). : Comp 307 Operator Precedence and Parse Trees : - op(1200, xfx, : -). : - op(700, xfx, is). : - op(500, yfx, [+, -]). add(X, Y, Z) : - Z is X + Y Internal (term) representation: : - (add(X, Y, Z), is(Z, +(X, Y))). : - (1200) add(X, Y, Z) is (700) Z + (500) X Y

Comp 307 Design your own rules in prolog : -op(800, fx, if). : -op(700, Comp 307 Design your own rules in prolog : -op(800, fx, if). : -op(700, xfx, then). : -op(300, xfy, or). : -op(200, xfy, and). If hall_wet and kitchen_dry then leak_in_bathroom. if window_closed or no_rain then no_water_from_outside. fact(hall_wet). fact(bathroom_dry). fact(no_rain).

Comp 307 backward-chaining • Pick one hypothesis • Find the rule • Verify each Comp 307 backward-chaining • Pick one hypothesis • Find the rule • Verify each condition in the body of the rule – Each condition as a new goal

Comp 307 Backward chaining in Prolog is_true(p): fact(p). is_true(P): if Condition then P, is_true Comp 307 Backward chaining in Prolog is_true(p): fact(p). is_true(P): if Condition then P, is_true (Condition). is_true(P 1 and P 2): is_true(P 1), is_true(P 2). is_true(P 1 or P 2): is_true(P 1) ; is_true(P 2).

Comp 307 Forward Chaining • Data driving, Data directed reasoning, bottom up – Search Comp 307 Forward Chaining • Data driving, Data directed reasoning, bottom up – Search from facts to valid conclusions • Given database of true facts: Apply all rules that match facts in the database – Add conclusions to database – Repeat until a goal is reached OR – Repeat until no new facts added –

Comp 307 Design your own rules in prolog : -op(800, fx, if). : -op(700, Comp 307 Design your own rules in prolog : -op(800, fx, if). : -op(700, xfx, then). : -op(300, xfy, or). : -op(200, xfy, and). If hall_wet and kitchen_dry then leak_in_bathroom. if window_closed or no_rain then no_water_from_outside. fact(hall_wet). fact(bathroom_dry).

Comp 307 Forward Chaining in Prolog : -dynamic fact/1. farward: new_derived_fact(P), !, assert(fact(P)), farward: Comp 307 Forward Chaining in Prolog : -dynamic fact/1. farward: new_derived_fact(P), !, assert(fact(P)), farward: -write(‘no more facts’). new_derived_fact(Conclusion): if Cond then Conclusion, + fact(Conclusion), composed_fact(Cond): -fact(Cond). composed_fact(Cond 1 and Cond 2): composed_fact(Cond 1), composed_fact(Cond 2). composed_fact(Cond 1 or Cond 2): composed_fact(Cond 1) ; composed_fact(Cond 2).

Comp 307 Knowledge Representation and reasoning • More Knowledge Representation – – – Decision Comp 307 Knowledge Representation and reasoning • More Knowledge Representation – – – Decision trees Decision tables Belief nets Fuzzy logic Neural networks … • Reasoning – Case based reasoning • Knowledge: Cases and modification rules • Reasoning: find similar case and adapt – …

Comp 307 Decision Tables diet meat grass meat habitat color jungle striped house striped Comp 307 Decision Tables diet meat grass meat habitat color jungle striped house striped plains striped jungle brown animal tiger tabby zebra weasel Example Rules: tiger meat jungle striped jungle<-- meat / striped / tiger

Comp 307 Decision Tree Diet? grass zebra meat Color? striped brown Habitat? weasel house Comp 307 Decision Tree Diet? grass zebra meat Color? striped brown Habitat? weasel house jungle tabby tiger

Comp 307 Knowledge based systems • Challenges and limitations – – – Knowledge acquisition Comp 307 Knowledge based systems • Challenges and limitations – – – Knowledge acquisition Conflict resolution Uncertainty Common sense ……