Skip to main content
AiIntermediate14 min readUpdated March 2025

Expert Systems

Expert systems are AI programs that emulate the decision-making ability of a human expert using a knowledge base and inference engine. This article covers their architecture, forward/backward chaining, and real-world applications.

What is an Expert System?

An expert system is an AI program designed to solve complex problems in a specific domain by reasoning through a body of knowledge, represented mainly as IF-THEN rules.

Expert systems were among the first truly successful AI applications, widely deployed in the 1970s-1990s in medicine, engineering, and finance.

Key components: 1. Knowledge Base - Contains domain-specific facts and rules. 2. Inference Engine - Applies rules to facts to derive conclusions. 3. User Interface - Allows users to query the system and receive explanations. 4. Explanation Facility - Explains how a conclusion was reached.

Knowledge Base: Facts and Rules

The knowledge base stores two types of information:

Facts: Known truths about the current situation. - "Patient has fever" - "Patient has cough"

Rules: IF-THEN statements encoding expert knowledge. - IF fever AND cough THEN possible_flu - IF possible_flu AND body_aches THEN likely_flu

Rules are typically written by knowledge engineers who interview domain experts and encode their expertise.

python
# Simple Medical Expert System

class ExpertSystem:
    def __init__(self):
        self.facts = set()
        self.rules = []
    
    def add_fact(self, fact: str):
        self.facts.add(fact)
    
    def add_rule(self, conditions: list, conclusion: str):
        self.rules.append((conditions, conclusion))
    
    def forward_chain(self):
        """Apply rules until no new facts are derived."""
        changed = True
        while changed:
            changed = False
            for conditions, conclusion in self.rules:
                if all(c in self.facts for c in conditions):
                    if conclusion not in self.facts:
                        self.facts.add(conclusion)
                        print(f"  Derived: {conclusion}")
                        changed = True
        return self.facts

# Build the expert system
es = ExpertSystem()

# Add rules
es.add_rule(["fever", "cough"], "possible_flu")
es.add_rule(["possible_flu", "body_aches"], "likely_flu")
es.add_rule(["likely_flu", "runny_nose"], "diagnose_influenza")
es.add_rule(["chest_pain", "shortness_of_breath"], "possible_cardiac")

# Add patient facts
es.add_fact("fever")
es.add_fact("cough")
es.add_fact("body_aches")
es.add_fact("runny_nose")

print("Running inference...")
result = es.forward_chain()
print("\nFinal diagnosis:", "Influenza" if "diagnose_influenza" in result else "Unknown")

Forward Chaining vs Backward Chaining

The inference engine can operate in two modes:

Forward Chaining (Data-Driven): - Starts with known facts and applies rules to derive new facts. - Continues until the goal is reached or no more rules apply. - Used when: you have data and want to find all possible conclusions. - Example: Medical diagnosis starting from symptoms.

Backward Chaining (Goal-Driven): - Starts with a goal and works backward to find supporting facts. - Asks: "What facts do I need to prove this goal?" - Used when: you have a specific hypothesis to verify. - Example: Prolog programs, legal reasoning.

python
# Backward Chaining Example

rules = {
    "diagnose_influenza": ["likely_flu", "runny_nose"],
    "likely_flu": ["possible_flu", "body_aches"],
    "possible_flu": ["fever", "cough"],
}

known_facts = {"fever", "cough", "body_aches", "runny_nose"}

def backward_chain(goal: str, rules: dict, facts: set, depth=0) -> bool:
    indent = "" * depth print(f"{indent}Trying to prove: {goal}")
    
    # Base case: goal is a known fact
    if goal in facts:
        print(f"{indent}[OK] {goal} is a known fact")
        return True
    
    # Try to prove via rules
    if goal in rules:
        conditions = rules[goal]
        print(f"{indent}Rule: {goal} <- {' AND '.join(conditions)}")
        if all(backward_chain(cond, rules, facts, depth + 1) for cond in conditions):
            print(f"{indent}[OK] Proved: {goal}")
            return True
    
    print(f"{indent}[FAIL] Cannot prove: {goal}")
    return False

print("Backward chaining to prove 'diagnose_influenza':")
result = backward_chain("diagnose_influenza", rules, known_facts)
print(f"\nDiagnosis confirmed: {result}")

Famous Expert Systems

Several landmark expert systems shaped the history of AI:

  • MYCIN (1970s) - Diagnosed bacterial infections and recommended antibiotics. Matched expert physicians in accuracy.
  • DENDRAL (1965) - Identified chemical compounds from mass spectrometry data.
  • XCON (1980) - Configured VAX computer systems for Digital Equipment Corporation, saving millions annually.
  • PROSPECTOR - Identified mineral deposits; discovered a molybdenum deposit worth $100M.
  • CLIPS - A general-purpose expert system shell still used today.

Limitations of Expert Systems

Despite their success, expert systems have significant limitations:

  • Knowledge Acquisition Bottleneck - Encoding expert knowledge is slow and expensive.
  • Brittleness - Fail unpredictably outside their narrow domain.
  • No Learning - Cannot improve from experience without manual updates.
  • Maintenance - Rules become outdated and contradictory over time.
  • Scalability - Performance degrades with thousands of rules.

Key Takeaways

  • Expert systems encode domain expertise as IF-THEN rules in a knowledge base.
  • The inference engine applies rules via forward chaining (data-driven) or backward chaining (goal-driven).
  • MYCIN and XCON were landmark expert systems with real-world commercial impact.
  • Expert systems are brittle, cannot learn, and suffer from knowledge acquisition bottlenecks.
  • Modern AI (ML/DL) has largely replaced expert systems but they remain in use in regulated domains.

Contact Us

Have a question or feedback? Fill out the form below or reach us directly at support@nvaitraining.com