Knowledge & Reasoning10 min read

Expert Systems

If-then rules that mimic a specialist
scope:Core Conceptdifficulty:Beginner

The Doctor in a Box

It's 1978. A patient walks into a hospital with a mysterious infection. The doctors aren't sure what bacteria is causing it. So they turn on a computer and run MYCIN β€” a program that asks questions about the patient's symptoms, lab results, and history, then recommends antibiotics.

MYCIN had no neural networks. No deep learning. No massive dataset. It had 600 if-then rules, each one capturing a piece of a human expert's knowledge:

IF the infection is in the blood AND the patient has a fever AND the culture shows gram-positive cocci THEN there is a 70% chance the organism is Staphylococcus.

Remarkably, MYCIN performed as well as human specialists β€” and better than many general practitioners. It was one of the first expert systems, and it proved that AI could capture and apply human expertise.

What is an Expert System?

An expert system is a program that mimics the decision-making of a human specialist. It has three main parts:

  • Knowledge Base β€” a collection of if-then rules from domain experts
  • Inference Engine β€” the logic that applies rules to reach conclusions (forward or backward chaining)
  • User Interface β€” where you input facts and receive recommendations

The Golden Age of Expert Systems

The 1980s were the golden age. Companies poured millions into building expert systems for every domain:

  • MYCIN (1978) β€” medical diagnosis for bacterial infections
  • DENDRAL (1969) β€” identifying chemical compounds from mass spectrometry data
  • XCON (1980) β€” configuring VAX computer orders at DEC, saving the company $40 million per year
  • PROSPECTOR (1983) β€” geological exploration, which actually discovered a molybdenum deposit worth millions

For a brief, shining moment, it seemed like expert systems would revolutionize every industry.

The Brittleness Problem

Then reality hit. Expert systems were brittle β€” they only worked within their narrow domain. Ask MYCIN about a broken bone, and it would confidently give you antibiotic recommendations anyway. It had no common sense, no ability to say "I don't know."

Building and maintaining the knowledge base was agonizing. Every rule had to be manually extracted from human experts in endless interview sessions (called knowledge elicitation). Rules conflicted, edge cases multiplied, and the whole system became a tangled mess.

Build a Mini Expert System

class ExpertSystem:
def __init__(self, name):
self.name = name
self.rules = []
self.facts = {}
def add_rule(self, conditions, conclusion, confidence):
self.rules.append((conditions, conclusion, confidence))
def set_fact(self, fact, value):
self.facts[fact] = value
def diagnose(self):
"""Run the inference engine."""
results = []
for conditions, conclusion, confidence in self.rules:
if all(self.facts.get(k) == v for k, v in conditions.items()):
results.append((conclusion, confidence))
results.sort(key=lambda x: x[1], reverse=True)
return results
# Build a pet health expert system
vet = ExpertSystem("PetVet")
# Add rules from a veterinarian's knowledge
vet.add_rule(
{"sneezing": True, "runny_nose": True, "fever": False},
"Likely allergies", 0.8
)
vet.add_rule(
{"sneezing": True, "fever": True, "lethargy": True},
"Possible upper respiratory infection", 0.9
)
vet.add_rule(
{"vomiting": True, "diarrhea": True},
"Possible dietary issue or gastroenteritis", 0.7
)
vet.add_rule(
{"limping": True, "swelling": True},
"Possible sprain or fracture β€” see vet immediately", 0.85
)
# Patient: a sneezing cat with fever
vet.set_fact("sneezing", True)
vet.set_fact("fever", True)
vet.set_fact("lethargy", True)
vet.set_fact("runny_nose", False)
print(f"--- {vet.name} Diagnosis ---")
for diagnosis, confidence in vet.diagnose():
print(f" {diagnosis} (confidence: {confidence:.0%})")
Output
--- PetVet Diagnosis ---
  Possible upper respiratory infection (confidence: 90%)
Note: Expert systems never died β€” they evolved. Modern "business rules engines" in insurance, banking, and healthcare are direct descendants of 1980s expert systems. When your insurance claim is automatically approved or denied, there's often a rule-based engine behind it. The difference is that today they're combined with machine learning, not used alone.

Lessons from Expert Systems

Expert systems taught the AI community valuable lessons:

  • Knowledge is power β€” but acquiring it from humans is brutally hard
  • Rules have limits β€” the real world has too many exceptions for hand-crafted rules
  • Transparency is a superpower β€” unlike neural networks, expert systems can explain every decision ("I recommended this because rules 3, 7, and 12 fired")

Today's AI world is dominated by machine learning, which learns patterns from data instead of having rules hand-coded. But the dream of explainable, transparent AI β€” where the system can tell you why it made a decision β€” is very much alive. And expert systems blazed that trail.

Quick check

What are the three main components of an expert system?
Challenge

Continue reading