Expert Systems II: Inference Engines and Chaining Strategies

Overview of Expert Systems Components

  • Main Components and Human Interfaces:

    • Human Expert: Provides the domain-specific knowledge to be encoded into the system.

    • Knowledge Engineer: The individual who translates the expert's knowledge into a computer-understandable format.

    • Knowledge Base: The storage area for the rules and facts collected from the human expert.

    • Inference Engine: The "brain" of the expert system that processes rules and facts to derive conclusions.

    • User Interface: The medium through which the user interacts with the system.

    • User: The person seeking advice or information (who may not be an expert in the field).

The Inference Engine

  • Definition: The inference engine is responsible for drawing conclusions from the knowledge base.

  • Conceptual Examples of Inferencing:

    • Case 1: If given the facts "All boys have a mother" and "John is a boy," the inference engine can deduce that "John has a mother" without being explicitly told that specific fact.

    • Case 2: If given the facts "All men are mortal" and "Socrates is a man," the engine infers that "Socrates is mortal."

  • Knowledge Representation: This course focuses on inferring using knowledge represented in RULES.

  • Rule-based Expert Systems: Expert systems that store knowledge in the form of rules in their knowledge base.

  • The Inference Cycle: The engine cycles through three primary steps:

    1. Match: Compare facts against the rules in the knowledge base.

    2. Select/Fire: Select a specific rule to apply.

    3. Execute: Carry out the action dictated by the rule.

Inference Strategies

  • Forward Chaining (Data-Driven):

    • Starts with available facts and uses rules to draw conclusions or take actions.

    • Best Use Cases: Prognosis, monitoring, and control systems.

    • Example Tools: CLIPS, OPS5.

  • Backward Chaining (Goal/Query-Driven):

    • Works backward from a specific goal or decision to look for rules that provide the necessary evidence to support that goal.

    • Best Use Cases: Diagnosis problems.

    • Example Tools: MYCIN.

Forward Chaining: Detailed Mechanics

  • Approach: It is data-driven, starting from information as it is received or basic ideas to reach a conclusion.

  • Mechanism: The computer analyzes the facts to find matches with the "IF" conditions of IF-THEN rules.

  • Behavioral Example: A salesperson uses forward chaining if they ask: "The customer wants comfort and has enough money (Customer has moneyCustomer \text{ has } money); what should I recommend to them?"

  • Step-by-Step Logic Example 1:

    • Rule Base:

      • R1: IF A AND B THEN D\text{R1: IF A AND B THEN D}

      • R2: IF B THEN C\text{R2: IF B THEN C}

      • R3: IF C AND D THEN E\text{R3: IF C AND D THEN E}

    • Knowledge Base (Existing): AA, BB

    • Process:

      • Facts AA and BB fire R1\text{R1}, producing fact DD.

      • Fact BB fires R2\text{R2}, producing fact CC.

      • Facts CC and DD (now in the KB) fire R3\text{R3}, producing fact EE.

    • Sequence: R1→R2→R3\text{R1} \rightarrow \text{R2} \rightarrow \text{R3}. The conclusion is EE.

  • Step-by-Step Logic Example 2:

    • Rule Base:

      • R1: If Y and D then Z\text{R1: If Y and D then Z}

      • R2: If X and B and E then Y\text{R2: If X and B and E then Y}

      • R3: If A then X\text{R3: If A then X}

      • R4: If C then L\text{R4: If C then L}

      • R5: If L and M then N\text{R5: If L and M then N}

    • Knowledge Base (Existing): AA, BB, CC, DD, EE

    • Process:

      • Fact AA triggers R3\text{R3}, creating XX.

      • Fact CC triggers R4\text{R4}, creating LL.

      • Facts X,B,EX, B, E trigger R2\text{R2}, creating YY.

      • Facts Y,DY, D trigger R1\text{R1}, creating ZZ.

      • R5\text{R5} is not executed because fact MM is missing.

    • Sequence: R3→R4→R2→R1\text{R3} \rightarrow \text{R4} \rightarrow \text{R2} \rightarrow \text{R1}.

Backward Chaining: Detailed Mechanics

  • Approach: It is goal-driven, starting from a hypothesized outcome and seeking evidence to support or contradict it.

  • Mechanism: This often involves testing intermediate hypotheses (sub-hypotheses).

  • Behavioral Example: A salesperson uses backward chaining if they ask: "Do I recommend a Rolls Royce to this customer or not?" They start with the conclusion and work toward the explanation.

  • Step-by-Step Logic Example 1:

    • Rule Base: Same as Forward Chaining Example 1. (R1, R2, R3\text{R1, R2, R3})

    • Goal: EE

    • Process:

      • To prove EE, the system needs CC and DD (R3\text{R3}).

      • To prove CC, the system needs BB (R2\text{R2}). Fact BB exists.

      • To prove DD, the system needs AA and BB (R1\text{R1}). Facts AA and BB exist.

    • Sequence: R3→R2→R1\text{R3} \rightarrow \text{R2} \rightarrow \text{R1}.

  • Step-by-Step Logic Example 2:

    • Rule Base: Same as Forward Chaining Example 2. (R1-R5\text{R1-R5})

    • Goal: ZZ

    • Process:

      • To prove ZZ, it needs YY and DD (R1\text{R1}). DD exists.

      • To prove YY, it needs X,B, and EX, B, \text{ and } E (R2\text{R2}). BB and EE exist.

      • To prove XX, it needs AA (R3\text{R3}). AA exists.

    • Sequence: R1→R2→R3\text{R1} \rightarrow \text{R2} \rightarrow \text{R3}.

Practical Case Study: Car Diagnosis Expert System

  • Rules Provided:

    • Rule 1: IF the engine is getting gas AND the engine will turn over THEN the problem is spark plugs.

    • Rule 2: IF the engine does not turn over AND the lights do not come on THEN the problem is battery or cables.

    • Rule 3: IF the engine does not turn over AND the lights do come on THEN the problem is the starter motor.

    • Rule 4: IF there is gas in the fuel tank AND there is gas in the carburetor THEN the engine is getting gas.

  • Forward Chaining Scenario:

    • Existing Knowledge: F1F1 (Gas in fuel tank), F2F2 (Gas in carburetor), F3F3 (Engine will turn over).

    • Deduction: F1+F2→Rule 4→F4F1 + F2 \rightarrow \text{Rule 4} \rightarrow F4 (Engine is getting gas).

    • Further Deduction: F4+F3→Rule 1→F5F4 + F3 \rightarrow \text{Rule 1} \rightarrow F5 (Problem is spark plugs).

    • Conclusion: The problem is spark plugs.

  • Backward Chaining Scenario:

    • Goal (GG): The problem is spark plugs.

    • Deduction: The system checks Rule 1. It needs "turn over" and "getting gas." It finds "turn over" in the knowledge base but must trigger Rule 4 to prove "getting gas."

Real-World Application: NHS 111 Online

  • System Details: A popular expert system used by the National Health Service (UK) website. Doctors have collated symptom-illness rules to triage patients.

  • Information Gathering Steps:

    1. Identity: Sex, Age, and Location (Postcode).

    2. Emergency Filtering: Checks for critical conditions (signs of heart attack, stroke, severe breathing difficulty, severe injuries, seizures, or heavy bleeding).

    3. Topic Identification: User selects primary symptom (e.g., "Sneezing").

    4. Triage Questions: Assessing illness severity (e.g., "Have you stopped usual daily activities?", "Are you breathing harder when doing nothing?", "Fever results?").

  • Outcomes/Advice Generated:

    • Speak to GP within 24 hours.

    • Speak to GP urgently (within 1 hour).

    • Phone 999 for an ambulance.

    • Self-care instructions (rest, fluids, paracetamol, ibuprofen guidelines).

Appropriateness of Expert Systems

  • Criteria for using an Expert System:

    • The solution justifies the development cost and effort.

    • Human expertise is scarce or not universally available.

    • The problem involves symbols and reasoning rather than just numbers.

    • Domain is well-structured and does not require "common sense."

    • Traditional computing methods (standard algorithms) are insufficient.

    • Experts are available, cooperative, and articulate.

    • The problem has a manageable size and scope.

  • System Requirements:

    • Ability to handle uncertain data (e.g., "I don't know").

    • Limited to a specific area of expertise.

    • Must explain the reasoning behind its advice.

Strengths and Weaknesses

  • Strengths:

    • Consistency in repetitive tasks and decisions.

    • Maintains massive levels of technical information.

    • Reduces training costs for human employees.

    • Centralizes decision-making power.

    • Efficiency and speed in problem-solving.

    • Synthesizes the intelligence of multiple experts.

    • Minimizes human error and oversight.

    • Provides strategic advantages against competitors.

  • Weaknesses:

    • Requires extensive, detailed knowledge during build.

    • Knowledge domain is strictly restricted.

    • Not all knowledge can be formatted as IF-THEN rules.

    • Requires consensus among experts (which may not exist).

    • Experts may struggle to explain their logic.

    • Knowledge acquisition is time-consuming.

    • Difficulty in adapting to changing environments (lack of flexibility).

    • Inability to recognize when it cannot provide an answer.

Questions & Interaction

  • Decision Rule:

    • To prove a decision: Use Backward Chaining.

    • To find all possible solutions: Use Forward Chaining.

  • Knowledge Base Transition: The notes demonstrate how facts (Knowledge Base) transition to New Knowledge as rules fire during the forward chaining process.