Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Lecture 5 Knowledge Representation Formal Method.

Similar presentations


Presentation on theme: "Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Lecture 5 Knowledge Representation Formal Method."— Presentation transcript:

1 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Lecture 5 Knowledge Representation Formal Method Non-Formal Method Examples

2 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Knowledge Representation KR encompasses:  The structure used to describe elements of Knowledge  The interpretive process required to use the described knowledge Components:  Factual Knowledge (Facts)  Procedural Knowledge (Rules)

3 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Representation Evaluation  Transparency: Easy identification of knowledge  Explicitness: Direct representation  Naturalness: Represent without transformation  Efficiency: easy access of knowledge  Adequacy: Complete knowledge representation  Modularity: Fragmentations-independent storage

4 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Level of Representation  Low Level Knowledge The fundamental knowledge used to derive further knowledge Example: The law of Gravity (also known as first principle knowledge)  High Level Knowledge The derived knowledge from the first principle knowledge. This uses inferencing methods

5 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Formal Logic  The most widely used formal logic method is FIRST-ORDER PREDICATE LOGIC Components : Alphabets Formal language Axioms Inference Rules

6 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Alphabets-I Predicates, variables, functions,constants, connectives, quantifiers, and delimiters Constants: (all capital letters) BLUEa color SANTROa car CROWa bird Variables: (all lower case letters) dogan element that is a dog, but unspecified coloran unspecified color

7 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Alphabets-II Function: father(ALI)A function that specifies the unique element, that is the father of ALI killer(x)x is a killer Predicate MAN(SHAHID)A predicate which gets TRUTH value equal to 1 (or represented by T) when the interpretation is true. Here Shahid is a man so the predicate is true. BIGGER(ALI,father(BABAR))Ali is bigger than the father of Babar.

8 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Alphabets-III Connectives: ^and vor ~not Implication Quantification Universal quantifiers Existential quantifiers

9 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Examples My house is a blue, two-story, with red shutters on the corners BLUE(MY-HOUSE)^TWO-STORY(MY-HOUSE)^RED- SHUTTERS(MY-HOUSE)^CORNER(MY-HOUSE) Ali bought a scooter or a car BOUGHT(ALI,CAR)vBOUGHT(ALI,SCOOTER) IF fuel, air and spark are present the fuel will combust PRESENT(SPARK)^PRESENT(FUEL)^PRESEN(AIR) COMBUSTION(FUEL)

10 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Examples All people need air Vx[PERSON(x) NEED_AIR(x)] The owner of the car also owns the boat [OWNER(x,CAR)^OWNER(x,BOAT)] Formulate the following expression in the PC: “Ali is a computer science student but not a pilot or a football player”

11 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Examples Restate the sentence in the following way: 1.Ali is a computer science (CS) student 2.Ali is not a pilot 3.Ali is not a football player CS_STUDENT(ALI)^ ~PILOT(ALI)^ ~FOOTBALL_PLAYER(ALI)

12 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Examples Studying expert systems is exciting and applying logic is very fun if you are not going to spend all of your time slaving over the terminal Vx(~SLAVE(x) [ES_ECITING(x)^LOGIC_FUN(x)]) Every voter either favors the amendment or despises it Vx[VOTER(x) [FAVOR(x,AMENDMENT) v DESPISE(x,AMENDMENT)] ^ ~[FAVOR(x,AMENDMENT) v DESPISE(x,AMENDMENT)[)]

13 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Non-formal Methods Rule Based Method A rule based system consists of a set of IF-THEN rules, a set of facts normally representing things that are currently held to be true, and some interpreter controlling the application of the rules, given the facts Control Scheme Database of facts Initial facts Rules IF ------ THEN ADD -------- IF ----- AND ----- THEN ADD -----

14 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Reasoning Methods Forward Chaining Method Data Driven: Starts from the initial facts and adds new conclusions to the facts database and tries to reach the conclusions Backward Chaining Method Goal Driven: Starts from the goal and looks for the premise of the conclusion in the database, followed by redefining the goal and so on.

15 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Forward Chaining Method Algorithm Repeat: 1.Find all the rules which have conditions (IF part) satisfied 2.Select one, using conflict resolution strategies (which rule to be selected first if there more than one satisfy the conditions). 3.Perform actions in conclusions, possibly modifying current working memory (database of facts).

16 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Forward Chaining Method-II

17 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Inference Chain

18 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Forward Chaining Method Facts: F1:alarm_beeps F2:hot Rules: R1: IF hot AND smoky THEN ADD fire R2:IF alarm_beeps THEN ADD smoky R3: IF fire THEN ADD switch_on_sprinklers

19 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Conflict Resolution  Prefer rules that involve facts that have been recently added to the working memory  Prefer rules with more specific facts  Allow user to prioritise the rules

20 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Forward Chaining Method Facts: F1:alarm_beeps F2:hot F3:dry Rules: R1: IF hot AND smoky THEN ADD fire R2:IF alarm_beeps THEN ADD smoky R3: IF fire THEN ADD switch_on_sprinklers R4: IF dry THEN ADD switch_on_humidifiers R5: IF sprinklers_on THEN DELETE dry R6: IF hot THEN ADD summer

21 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Backward Chaining Method Algorithm To prove a goal: 1.If G is in the initial facts it is proven 2.Otherwise, find a rule which can be used to conclude G, and try to prove each of that rule’s pre-conditions. G is then proved true if all the pre-conditions are proved true.

22 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Backward Chaining Method

23 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Backward Chaining Method G: switch on the sprinklers Facts: F1:alarm_beeps F2:hot Rules: R1: IF hot AND smoky THEN ADD fire R2:IF alarm_beeps THEN ADD smoky R3: IF fire THEN ADD switch_on_sprinklers

24 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Backward Chaining Method Let G=G1: switch on the sprinklers Matches conclusion of R4, precondition of R4 have to be satisfied and becomes new goal New Goal G2: fire Matches conclusion of R1, precondition of R1 have to be satisfied and becomes new goal New Goals G3:smoky, G4: hot G3 Matches conclusion of R2, thus new goal is alarm beeps G4 is already in the initial facts so is true New Goal is G5: alarm_beeps, G4: hot Both are included in the initial facts thus the initial Goal G is true

25 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Example Facts: Nil Rules: R1: IF coughing THEN ADD smoky R2: IF wet AND NOT raining THEN ADD burst_pipe R3: IF NOT coughing AND alarm_rings THEN ADD burglar R4: IF smoky AND hot THEN ADD fire Specify the Line of Questioning and implement backward chaining method to prove burglary

26 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Example Interaction between the user and the ES: System: Are you coughing?. User: No. System: Are you getting wet?. User: No. System: Is there an alarm ringing?. User: No.

27 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Example-II Suppose we are trying to develop a safety system for the a chemical plant. If some liquids spills over and if it is flammable the situation is dangerous and the fire department should be called. In order to check that what type of liquid is spilled one should check the smell of the liquid and the pH value of the material. If the smell is like vinegar and the pH is less than 6, the material is definitely acetic acid. Specify the Line of Questioning and implement backward chaining method to prove material being acetic acid and should the fire deaprtment be called or not

28 Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Rules R1: If a flammable liquid was spilled, then call the fre department R2: If the pH of the spill is less than 6, then the spill material is an acid R3: If the spill material is an acid, and the spill smells like vinegar, then the spill material is acetic acid Ph less than 6 Smell like vinegar Material acid Acetic Acid


Download ppt "Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Lecture 5 Knowledge Representation Formal Method."

Similar presentations


Ads by Google