#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
Home / Blog /

Production Systems in AI

Types, Rules, and Design Challenges

Published
6 min read
Scroll Down

What is a production system?

A production system is a way of structuring an AI program as a set of IF-THEN rules (called productions) that act on a store of facts. The program runs by repeatedly finding a rule whose IF part matches the current facts and applying its THEN part, which changes the facts, until a goal is reached or no rule applies. The idea goes back to Newell and Simon's models of human problem solving, and it is the basis of rule-based expert systems.

Rich and Knight's Artificial Intelligence describes a production system as having four parts:

  1. A set of rules, each of the form condition → action. The left side says when the rule applies; the right side says what it does.
  2. One or more knowledge databases (working memory) that hold the facts about the current state of the problem, plus any permanent knowledge the rules need.
  3. A control strategy that decides which rule to apply next and when to stop. A good strategy must cause motion (actually move toward a solution) and be systematic (not wander or repeat itself).
  4. A rule applier that carries out the chosen rule.

The production rules for the water jug problem, such as "if the 4-litre jug is not full, fill it", are a standard example of this structure.

How a production system runs: the match-resolve-act cycle

  1. Match: find every rule whose conditions are satisfied by working memory. These rules form the conflict set.
  2. Resolve: if more than one rule matches, choose one using a conflict-resolution strategy.
  3. Act: apply the chosen rule, which adds, deletes or changes facts in working memory.
  4. Repeat until a goal fact appears, or the conflict set is empty.

Common conflict-resolution strategies

  • Refractoriness: do not fire the same rule twice on the same facts.
  • Recency: prefer rules that match the most recently added facts, which keeps the reasoning focused.
  • Specificity: prefer the rule with more conditions, since it applies to a narrower, better-described situation.
  • Rule order (priority): prefer the rule written first, or the one with a higher assigned priority.

A small production system in Python

This forward-chaining rule engine identifies an animal from observed facts. It shows working memory, the conflict set, conflict resolution by specificity and rule order, and refractoriness.

# Production rules: (name, conditions that must all be in working memory, fact to add)
rules = [
    ("R1", {"has hair"}, "mammal"),
    ("R2", {"gives milk"}, "mammal"),
    ("R3", {"mammal", "eats meat"}, "carnivore"),
    ("R4", {"mammal", "has pointed teeth", "has claws"}, "carnivore"),
    ("R5", {"carnivore", "tawny colour", "dark spots"}, "cheetah"),
    ("R6", {"carnivore", "tawny colour", "black stripes"}, "tiger"),
]

def run(working_memory):
    fired = set()
    cycle = 0
    while True:
        # MATCH: rules whose conditions all hold and whose result is new
        conflict_set = [r for r in rules
                        if r[1] <= working_memory and r[2] not in working_memory and r[0] not in fired]
        if not conflict_set:
            break
        # RESOLVE: prefer the most specific rule (most conditions), then the earliest rule
        name, conds, fact = max(conflict_set, key=lambda r: (len(r[1]), -rules.index(r)))
        # ACT: add the new fact and remember that this rule has fired (refractoriness)
        cycle += 1
        working_memory.add(fact)
        fired.add(name)
        print(f"cycle {cycle}: conflict set {[r[0] for r in conflict_set]} -> fire {name}, add '{fact}'")
    return working_memory

facts = {"has hair", "gives milk", "eats meat", "tawny colour", "dark spots"}
result = run(set(facts))
print("Conclusion:", "cheetah" if "cheetah" in result else "tiger" if "tiger" in result else "unknown")

Output:

cycle 1: conflict set ['R1', 'R2'] -> fire R1, add 'mammal'
cycle 2: conflict set ['R3'] -> fire R3, add 'carnivore'
cycle 3: conflict set ['R5'] -> fire R5, add 'cheetah'
Conclusion: cheetah

In cycle 1, both R1 and R2 match and conclude the same thing. They have the same number of conditions, so rule order picks R1. In cycle 2, R2 no longer appears in the conflict set because "mammal" is already in working memory. The control strategy here is simple, but real rule engines use the same loop; they speed up the match step with the Rete algorithm, which avoids re-checking every rule against every fact on each cycle.

Types of production systems

Rich and Knight classify production systems by two properties of their rules:

  • Monotonic: applying a rule never prevents the later application of another rule that could also have been applied when the first was chosen. Facts are only added, never invalidated.
  • Non-monotonic: applying a rule can block rules that were applicable before, for example by deleting or changing a fact.
  • Partially commutative: if a sequence of rules changes state x into state y, then any allowable reordering of the same rules also changes x into y. The order of steps does not matter for the result.
  • Commutative: both monotonic and partially commutative.
MonotonicNon-monotonic
Partially commutativeTheorem provingRobot navigation
Not partially commutativeChemical synthesisBridge (the card game)
  • Theorem proving: proving a new lemma never makes an earlier one false, and lemmas can be derived in different orders.
  • Robot navigation: moving changes the robot's position (non-monotonic), but a set of moves in a different allowable order can reach the same place.
  • Chemical synthesis: adding a compound does not undo anything, but the order of reactions matters to the final product.
  • Bridge: once a card is played it cannot be played again, and the order of play changes the outcome.

This classification matters for search. In a partially commutative system, the control strategy does not need to try every ordering of the same steps, and in a monotonic, reversible one, it never needs to backtrack to undo damage.

Forward and backward chaining

Forward chainingBackward chaining
Starts fromKnown factsThe goal to prove
Uses rulesLeft to right: when conditions match, add the conclusionRight to left: find a rule that concludes the goal, then try to prove its conditions
Good whenThere are few starting facts and many possible conclusions, such as monitoring and configurationThere is a specific question to answer, such as diagnosis
Example systemsOPS5, CLIPS (production rule languages)Prolog, MYCIN-style diagnosis

Backward chaining builds a tree of goals and subgoals: proving a goal may need all conditions of one rule (AND) or any one of several rules (OR). That structure is an AND-OR graph, the kind the AO* algorithm searches.

Characteristics: advantages and limitations

AdvantagesLimitations
Modularity: each rule is a separate piece of knowledge that can be added or removed without rewriting the program.Opacity: with hundreds of rules, it becomes hard to see why the system reached a conclusion or how rules interact.
Simplicity and naturalness: IF-THEN rules are close to how experts explain their reasoning.Inefficiency: matching every rule against every fact on every cycle is expensive without algorithms such as Rete.
Explainability: the chain of fired rules is a readable trace of the reasoning.No learning: a basic production system cannot create new rules from experience.
Separation of knowledge and control: the same engine works for different rule sets.Conflict resolution is tricky: a poorly chosen strategy can loop or reach a poor answer.

How the facts in working memory are represented is a topic of its own; see knowledge representation in AI. The control strategy of a production system is usually a search strategy such as BFS or DFS, and a system that adds its own rules over time becomes a learning agent. Rule-based systems and search are part of Uncodemy's Artificial Intelligence course.