CV Courseversity

Expert Systems and Rule-Based AI

Covers the architecture of expert systems — knowledge bases and production rules, forward- and backward-chaining inference engines, explanation facilities, and the knowledge-acquisition process — through the landmark case of MYCIN.

“In the 1970s, researchers observed that physicians at community hospitals prescribed antibiotics rationally in only about 13% of cases — a statistic that helped motivate a Stanford team to build MYCIN, a program that reasoned over hundreds of IF-THEN rules distilled from infectious-disease specialists to recommend antimicrobial therapy. How can a machine with no biological understanding reach expert-level judgments simply by chaining together simple conditional rules — and what happens when two rules point to conflicting conclusions, or when nobody, including the system's own designers, can explain why it reached a particular answer?”

Knowledge Bases and Production Rules · 15 min

An expert system separates what it knows from how it reasons: a knowledge base holds the domain's facts and rules, while a distinct inference engine applies general reasoning procedures to that knowledge base to reach conclusions. This separation of declarative knowledge from the procedures that operate on it was a deliberate and, at the time, unusual design choice — it meant a system's expertise could be inspected, edited, and extended as a body of explicit rules rather than being buried inside procedural code, and the same inference engine could in principle be reused across different domains simply by swapping in a different knowledge base. Knowledge within such a system is typically encoded as production rules: conditional statements of the form "IF a set of conditions holds THEN assert a conclusion or take an action," each rule representing one small, self-contained piece of expertise that can be added, removed, or modified largely independently of the others.

The landmark demonstration of this architecture was MYCIN, developed at Stanford to recommend antimicrobial therapy for bacterial infections. MYCIN's designers were motivated in part by evidence that physicians' antibiotic-prescribing decisions in actual hospital practice were judged rational only about 13% of the time, which underscored a real gap that a consistent, rule-driven consultation system might help close. MYCIN reasoned over several hundred production rules encoding the judgment of infectious-disease specialists, working primarily through backward chaining — reasoning backward from a candidate diagnosis or therapy to the clinical evidence needed to support it — which is why the system has been described as an evidence-gathering program: it asked the clinician targeted questions only when their answers were needed to evaluate a specific rule. The project built directly on lessons learned from DENDRAL, an earlier Stanford program for inferring chemical structures, and involved a genuinely interdisciplinary team of physicians and computer scientists working together to encode medical judgment as explicit rules.

Constructing such a knowledge base is itself a specialized activity, later named knowledge engineering by Edward Feigenbaum, who described the knowledge engineer as someone who works intensively with a domain expert to acquire that expert's knowledge and organize it into a form a program can use, while simultaneously matching available AI techniques — program structures, inference methods, representation formalisms — to the problem at hand. Feigenbaum's account emphasizes a genuine difficulty at the heart of this process: much of an expert's skill is tacit, exercised fluently but not consciously articulated, so a knowledge engineer's job is as much about drawing out knowledge the expert does not realize they possess as it is about transcribing knowledge the expert can state outright. This iterative back-and-forth between engineer and expert — proposing a rule, testing it against real or remembered cases, and refining it when the expert objects that the conclusion feels wrong — is what turns a domain's scattered expertise into a coherent, testable knowledge base rather than a one-time transcription exercise.

Inference Engines: Forward and Backward Chaining · 15 min

An inference engine applies a knowledge base's rules to a set of known facts, and it can do so in two directions. Forward chaining is data-driven: starting from the facts currently held, the engine repeatedly finds rules whose conditions are satisfied by those facts, fires them to add their conclusions as new facts, and continues until no further rule can fire — a process that, for knowledge bases expressed as function-free definite clauses (Datalog), is guaranteed to terminate. The inner loop of forward chaining, finding which rules' conditions currently match the known facts, is in general an expensive pattern-matching problem, and production systems built for real-time use employ techniques such as the RETE algorithm, which preprocesses the rule set into a dataflow network that retains partial matches across cycles so the engine only re-examines the facts that actually changed rather than recomputing every match from scratch. RETE-based forward-chaining production systems proved capable of firing well over a million rules and became central both to commercial systems such as XCON/R1, which configured computer orders, and to cognitive-architecture research systems such as ACT and SOAR.

Backward chaining runs in the opposite direction: it starts from a goal — a hypothesis to prove or a question to answer — and works backward through the rules, treating each rule whose conclusion matches the current goal as generating new subgoals from that rule's conditions, recursively, until the subgoals bottom out in facts that are already known or that can be asked of the user. This goal-directed search is exactly the strategy MYCIN used, since a consultation naturally starts from questions like "what organism is causing this infection?" rather than from an undirected sweep through everything that happens to be true, letting the system ask only the clinical questions relevant to the hypothesis currently under consideration. The same backward-chaining idea, extended with practical features such as built-in arithmetic and side-effecting predicates, underlies logic programming languages such as Prolog. Choosing between the two directions is largely a question of fit between the reasoning strategy and the task: a system meant to derive everything it can from a fixed set of facts, as in configuration or monitoring, suits forward chaining, while a system meant to answer a specific, narrowly posed question — like a single diagnostic consultation — suits the more targeted, question-driven structure that backward chaining naturally provides.

Because clinical evidence is rarely certain, MYCIN also needed a way to combine uncertain premises into an appropriately qualified conclusion, which it did with a certainty-factor model: a numeric scheme, distinct from formal probability, for propagating and combining degrees of confidence as rules fired in sequence. Certainty factors were a pragmatic solution built for a domain where the full conditional-probability tables a rigorous Bayesian treatment would require were not available, and later research in probabilistic AI went on to develop more principled formal alternatives, such as Bayesian networks, for representing and propagating uncertainty — a reminder that an engineering solution adopted for practical necessity in one era is not always where the underlying problem's theory eventually settles. Whichever mechanism is used, the underlying inference engine still has to decide, on every cycle, which of potentially several eligible rules to fire next — a conflict-resolution step production systems must handle in some principled way, since firing eligible rules in an arbitrary order would make a system's behavior difficult to predict or reproduce. Getting this combination right, choosing both a workable uncertainty scheme and a disciplined way of ordering rule firing, was as much a part of what made MYCIN's recommendations dependable as the content of any individual rule, and it illustrates a broader point about production-rule systems: the rules themselves are only half the design, and the procedure governing how, when, and with what confidence they combine is just as consequential for whether the system's final output can actually be trusted.

Explanation, Knowledge Acquisition, and the Legacy of Expert Systems · 15 min

Because a rule-based system's conclusions are reached through a discrete, inspectable chain of rule firings, it can explain itself in a way that was, and largely remains, hard for purely statistical black-box models to match. MYCIN supported this directly: during a consultation, a clinician could ask "WHY" a particular question was being posed, and the system would show the current subgoal and the specific rule whose evaluation required that answer, or ask "HOW" a conclusion was reached to see the reasoning chain and preconditions behind it. After a consultation, MYCIN could also answer follow-up questions about the case, or about any of its rules in general, by retrieving and displaying the exact rules involved — turning the same explicit, modular rule representation that made the system's knowledge editable into a resource for making its behavior transparent to the people relying on it. For a physician deciding whether to trust a recommendation about a patient's antibiotic therapy, being able to inspect the specific chain of clinical reasoning behind it, rather than simply accepting or rejecting an unexplained output, was as central to the system's usefulness as the accuracy of the recommendation itself.

That same explicit representation supported a rule-acquisition facility: rather than requiring a programmer as an intermediary, MYCIN allowed a domain expert to enter a new rule in something close to plain English, following the format of the system's existing rules, after which the system translated it into its internal representation and displayed a paraphrased version back to the expert for confirmation, correction, or refinement. This kind of interactive knowledge acquisition was a direct response to what became a widely recognized bottleneck in building expert systems: eliciting an expert's tacit knowledge and encoding it correctly is slow, effortful, and easy to get subtly wrong, and tools that let an expert refine the knowledge base directly — rather than only through a knowledge engineer relaying every change — were built specifically to ease that bottleneck. Beyond entering brand-new rules, the same facility let an expert revisit and correct an existing rule through interactive dialogue with the system, so that as the knowledge base grew, refining what was already there stayed as accessible to the domain expert as adding to it from scratch.

Rule-based expert systems moved from research demonstrations to real commercial deployments in the 1980s, but the very features that made them powerful also exposed hard limits: knowledge bases that grew to thousands of rules became expensive to maintain and prone to unexpected interactions between rules, and systems whose expertise was narrowly scoped to the rules they had been given tended to fail unpredictably, without graceful degradation, once a case fell outside that scope. Even so, the core architecture did not vanish — it persists today in business-rule engines, clinical decision-support tools, and forward-chaining production systems embedded in larger software, and the broader questions this module opened, particularly how to combine explicit rules with statistical and learned methods, remain directly relevant to how modern hybrid, neuro-symbolic AI systems are designed. The specific engineering lessons carried forward are concrete ones: keep knowledge explicit and inspectable rather than implicit, separate what a system knows from how it reasons over that knowledge, and treat explanation as a first-class design requirement rather than something added on afterward once a system already works.

Practice

A Backward-Chaining Rule-Firing Chain

has_fever has_cough R1 suspect_flu has_bodyache R2 diagnose_flu

A two-rule forward-chaining trace: R1 fires once has_fever and has_cough are both known, adding suspect_flu as a new fact; R2 then fires once suspect_flu and has_bodyache are both known, concluding diagnose_flu — each arrow shows a fact feeding a rule and a rule producing a new fact.

  • The core architectural move of an expert system is separating a knowledge base of explicit rules from the inference engine that reasons over them, which is what makes the knowledge editable, extensible, and inspectable rather than buried in procedural code.
  • Forward chaining is data-driven and works well when you want to derive everything that follows from known facts, while backward chaining is goal-driven and works well when you have a specific hypothesis to evaluate, as MYCIN did during a clinical consultation.
  • A rule-based system's explanation facility and its knowledge-acquisition facility both rely on the same property — an explicit, modular representation of rules — which is what let MYCIN both trace WHY/HOW explanations and let experts add or edit rules directly.

Recall Practice

ArchitectureClick to reveal
What are the two core components of a classical expert system, and what does each one hold or do?
The knowledge base holds the domain's facts and production rules; the inference engine applies a general reasoning procedure — forward or backward chaining — to that knowledge base to derive conclusions.
ChainingClick to reveal
What is the essential difference between forward chaining and backward chaining?
Forward chaining is data-driven, starting from known facts and firing any rule whose conditions are satisfied to derive new facts until none can fire; backward chaining is goal-driven, starting from a hypothesis and working backward through rules to the subgoals and evidence needed to support it.
RETEClick to reveal
What problem does the RETE algorithm solve, and how?
It solves the cost of repeatedly matching rule conditions against facts in forward chaining by preprocessing rules into a dataflow network that retains partial matches across cycles, so only facts that actually changed need to be reexamined.
MYCIN explanationClick to reveal
What could a clinician ask MYCIN during a consultation to understand its reasoning, and what did the system show in response?
A clinician could ask WHY a question was being posed, and MYCIN would show the current subgoal and the specific rule requiring that answer, or ask HOW a conclusion was reached to see the reasoning chain and preconditions behind it.

Glossary

Knowledge base
The collection of facts and production rules that encodes a system's domain expertise, kept separate from the reasoning procedure that operates on it.
Production rule
A conditional statement of the form 'IF conditions THEN conclusion/action,' representing one discrete, editable piece of expertise.
Inference engine
The general reasoning procedure — such as forward or backward chaining — that applies a knowledge base's rules to derive new facts or conclusions.
Forward chaining
A data-driven inference strategy that starts from known facts and fires any rule whose conditions are satisfied, repeating until no more rules can fire.
Backward chaining
A goal-driven inference strategy that starts from a hypothesis and works backward through rules to the subgoals and evidence needed to support it.
Certainty factor
A pragmatic, non-probabilistic numeric scheme MYCIN used to combine and propagate degrees of confidence across chained rule firings.
Practical Activity

Build and Trace a Tiny Production Rule Base by Hand

This is a fully paper-based simulation — no software is run. Write a small knowledge base of 5 production rules for a simple everyday domain of your choosing (for example, deciding whether to bring an umbrella, given facts like sky_is_cloudy, rain_forecast, and going_outside). Then, starting from a chosen set of initial facts, hand-trace one full forward-chaining pass: at each step, write down which rule's conditions are satisfied by the current facts, fire it, and add its conclusion to the fact set, continuing until no more rules can fire. Next, pick one of your rule base's possible conclusions as a goal and hand-trace a backward-chaining pass: write the goal, list which rule(s) conclude it, and recursively write the subgoals those rules require, marking each subgoal as either "already known" or "would need to ask the user," stopping once every branch bottoms out. Finally, write a short WHY/HOW explanation exchange in plain English (2–3 exchanges) that mimics what MYCIN's explanation facility would have shown for one step of your backward-chaining trace, naming the specific rule and subgoal involved.

Ready to test yourself?

5 questions on this module.

Start Quiz