210 likes | 328 Views
ISAT 252:Analytical Methods IV Introduction to Expert/Knowledge-Based Systems (EKBS) and Declarative programming Reading Assignment1 What are Expert Systems?. Declarative Programming Module Objectives:.
E N D
ISAT 252:Analytical Methods IV Introduction to Expert/Knowledge-Based Systems (EKBS) and Declarative programming Reading Assignment1 What are Expert Systems?
Declarative Programming Module Objectives: • To be able to explain how the declarative programming differs from other programming paradigms, describe the role of logic in declarative programming, and describe how to use and use a EKBS shell in a declarative programming project application; • To be able to define a KBS and an ES, describe the human resources and roles required to build a KBS, and describe the architecture, components, a methodology, and programming constructs used, to build a KBS; • To (be able to) build a KBS that illustrates all of the objectives mentioned above; that is, to develop the skills required to build a KBS, through the experience of designing and developing a KBS in a KBS shell.
Outline: • 1. Lecture 1: Introduction to KBS and declarative programming • 2. Lecture 2: Knowledge-based systems (KBS) definition and requirements overview • 3. Lecture 3: KBS development and programming details • 4. Lecture 4: Inference engines and search algorithms*
Lecture 1: Introduction to KBS and declarative programming • Distinguish two Programming Paradigms: • procedural programming • declarative programming • Explain the role of logic in programming, in particular in declarative programming • master the truth table definition of a “valid rule of inference” • Apply the truth table definition of valid inference to distinguish between examples of valid and invalid inferences.
Programming paradigms • in the procedural programming paradigm: • a program (code) provides the computer a procedure, i.e., an ordered sequence of steps to be executed, in order, one step at a time. • for example, a procedure (algorithm) can be specified to process a payroll. • commercial applications and successes: • COBOL: business programming • FORTRAN: scientific programming • C, … VB (various versions) and C++ have procedural components
Procedural Knowledge • Procedural Knowledge is knowing how to do something. The solution to problems that require procedural knowledge can be express with an Algorithm • Where an Agorithm is a logical and finite sequence of precise steps leading to the solution of the problem Definition of Procedural Knowledge (Fox) • A person x knows how to q if and only if • the procedure q is correct: that is, if x follows q, x gets a ... (cake baked, pay role paid, house built …) • x is minimally competent to q: that is, under appropriate circumstances, with appropriate tools, ...
Procedural Knowledge Example Problem: How to replace a light bulb in a lamp SolutionAlgorithm • Find a new light bulb • Turn off the lamp • Take out the old light bulb from the lamp • Put in the new light bulb • Turn on the lamp • If the light bulb does not work, repeat from 1, otherwise stop
Procedural Knowledge Example Problem: process a payroll Algorithm: For each employee card • Determine hours worked during the pay period. • Multiply by dollars/hour to determine gross pay. • Calculate and subtract appropriate taxes and withholding. • Print a check for the net pay for the employee in the current card . • Update the employee card. • Continue (loop) until all employees cards are processed.
Declarative Knowledge • Declarative knowledge is knowledge about things, that something is the case, about “facts” and relationships among facts, for example, • Water is made up of hydrogen and oxygen, H2O. • 2 + 2 = 4 • If you heat water it will boil. • If Cleopatra is a women and all women are mortal than Cleopatra is mortal • By definition, declarative knowledge cannot be FALSE! We cannot know that 2 + 2 = 5 or that the Sun revolves around the Earth, although some of us might have once held the former belief and many the latter. The classical and arguable still the best definition (understanding) of Declarative Knowledge comes from Plato: • A person x knows that p if and only if • x believes that p • p is true • x is justified in believing that p
Example of Declarative Knowledge: Family/Kinship Relationships Tell me something that is not explicitly stated but that follows from what we have here. • Facts: • Mary is the mother of Bill, • Anne is the mother of Mary,… • Robert is Mary’s brother • Relationships: • A person is a grandmother whenever she is the mother of another person who is either a mother or a father . • A person is a grandfather whenever he is the father of another person who is either a mother or a father. • A person is a son of another person whenever the other person is his/her mother • A person is an uncle whenever that person is the brother of a person who has either a father or a mother • …….. How did you (do we) do this and how do you know that you got it right? This is the ability that we want to capture, automate, compute, i.e., the human ability to reason.
Programming paradigms cont. • Declarative programming (vs. procedural programming): • The program describes to the computer a set of conditions/ relationships among the facts, concepts and description of a problem • The computer finds the solution by making logic inferences from the facts and relationships provided in the program • Used to formulate and solve problems historically identified with artificial intelligence applications. • Also called Symbolic Programming or Logic Programming
Programming paradigms • Declarative programming: • Some typical applications http://www.exsys.com/case2.htmldiagnostic system, e.g., which infectious disease is implicated by the evident symptoms. • Configuration systems, e.g., the computing system discussed earlier in the semester … • Decision support systems, e.g. what CISAT computing equipment to replace with this years budget. • KBS Environments • KBS Shells and Programming Environments: built to facilitate this type of problem solving • EXSYS Corvid • (OPS 5) • Special symbolic/reasoning programming languages • PROLOG • LISP can be use to build diagnostic system, configuration systems, decision support systems, etc..
Example: Identifying suspects in a crime • Suzie is the victim • Suspects ? • Suzie was killed with a blunt instrument. • Mario knew Suzie. • Cyril is covered in blood. • Mario is covered in mud. • Cyril is a butcher. • Mario is a footballer. • John is a carpenter. • John has a wooden leg. • If the subject has a football boot then (s)he has a blunt instrument. • If the subject has a wooden leg then (s)he has a blunt instrument. • If the subject is a footballer then (s)he has football boots. • If the subject has a blunt instrument then (s)he is suspect • If the subject is covered with blood then (s)he is a suspect . • If the subject knew the victim then (s)he is suspect. Suspects? Why? Cyril John Mario rio Cyril [5, 15] John [10, 12, 14] Mario [4, 16] [8, 13, 11,14] Suzie is the victim. Mario is the prime suspect!
KBS use an inference engine (built on valid rules of inference) to infer conclusions. What is a valid rule of inference? By definition,avalid rule of inferenceguarantees that if the statements (premises) to which the rule is applied are true, (correct) then the conclusion of the rule must be true (correct). For example, (paraphrasing the set of examples found above): If Mario knew Suzie then Mario is a suspect. Mario knew Suzie. Therefore, Mario is a suspect. If Cyril is covered in blood then Cyril is a suspect. Cyril is covered in blood. Therefore, Cyril is a suspect. Intuitively, these are paradigmatic examples of validity. We share the recognition that if their premises are true, their conclusions must be true. The formal definition of “validity” must account for these, and other, examples.
Rules of Inferences • Knowledge is inferred by applying/using valid rules of inference on the facts and relationships • Avalid rule of inferenceGUARANTEES that if the statements (premises) to which the rule is applied are true, the conclusion must be true. Consider another example: • What rule(s) of inference guarantees this? If Anne is the mother of Mary and Premise Mary is the mother of Bill then Anne is the grandmother of Bill Anne is the mother of Mary Premise Mary is the mother of Bill Premise Therefore Anne is the grandmother of Bill Conclusion
MODUS PONENSis the most common rule of inference, that is, the most common rule for playing the “game of logic” Premises Conclusion Rules of Inference: Modus Ponens Modus Ponens is intuitively a valid rule of inference : • The conclusion cannot be false, if the statements to which the rule is applied are True. • How can we establish this? Let Pbe a statement and P Q be a conditional statement If P then Q P Q (TRUE) P P(TRUE) By MP Q Q (TRUE)
Let X and Y be variables for declarative statements; by definition statements are either TRUE or FALSEBy definition Truth Tables determine the truth values of combination of statementsas follows: Modus Ponens: Rule of Inference X Y IF X THEN Y TRUE FALSE TRUE TRUE X Y TRUETRUE TRUEFALSE FALSETRUE FALSEFALSE - X NOT X FALSE FALSE TRUE TRUE X ^ Y X AND Y TRUE FALSE FALSE FALSE X v Y X OR Y TRUE TRUE TRUE FALSE How can we use this to establish MP as a Valid Rule of Inference ?
P Q TRUE FALSE TRUE TRUE Modus Ponens Whenever P is TRUE and P Q is TRUE (IF P Then Q is TRUE) Q is TRUE P P Q / Q COMPONENTS PREM PREM CONCLUSION P Q TRUE TRUE TRUEFALSE FALSE TRUE FALSE FALSE P TRUE TRUE FALSE FALSE Q TRUE FALSE TRUE FALSE Alternatively, if Q is FALSE, either P or P Q is FALSE Therefore, Modus Ponens is a valid rule of inference
T T F T F T F T F FT T FTF FTT FT F FTT
KBS Homework 1 TT analysis to reinforce understanding the definition of a valid argument Rule 1: If A and (A and F) D are premises Then D is a valid conclusion Rule 2: If (NOT A) and (A F) are premises Then NOT F is a valid conclusion Rule 3: If A and (A or F) D are premises Then D is a valid conclusion Rule 4: If A v F and A D are premises Then D is a valid conclusion