Expert System Engineering
Full lifecycle methodology for engineering knowledge-based expert systems. Upstream phases use CommonKADS for organizational scoping and conceptual modeling. Downstream phases use generalized MYCIN/EMYCIN patterns for rule-based implementation. Follow all phases in order.
For domain terminology, see terminology.md.
Phase 0: Suitability Assessment
Determine whether the problem warrants an expert system before committing to the methodology.
Classify the problem type:
- Analytic (classification, diagnosis, assessment, monitoring) — system interprets existing data
- Synthetic (configuration, planning, scheduling, design) — system constructs a solution from components
- Neither — redirect to a different approach
Evaluate expert-system fit against alternatives:
| Criterion |
Expert System Fit |
Alternative |
| Domain has identifiable human experts |
Required |
If no experts → data-driven ML |
| Knowledge is heuristic, judgmental |
Strong fit |
If purely algorithmic → conventional software |
| Reasoning must be explainable |
Strong fit |
If black-box acceptable → ML/statistical |
| Domain is bounded and well-scoped |
Required |
If open-ended → LLM-based approaches |
| Decisions involve uncertainty |
Strong fit (CF/rules) |
If precise probabilities needed → Bayesian networks |
| Training data is limited |
Advantage over ML |
If large labeled datasets exist → ML |
Make an explicit go/no-go decision. Document the rationale.
Completion gate
Phase 1: Organizational Scoping & Feasibility
Scrutinize the organizational environment, isolate the knowledge bottleneck, and confirm feasibility before technical work begins.
Map organizational context (OM-1): Document business mission, drivers, problems, opportunities, and candidate solution directions.
Analyze variant aspects (OM-2): Map organizational structure, business processes (activity diagrams), people, resources, and culture/power dynamics.
Decompose into tasks (OM-3): Break business processes into discrete tasks. For each, record the performing agent, knowledge assets used, knowledge-intensity (1–5), and business significance.
Assess knowledge assets (OM-4): For each asset, evaluate whether it is in the right form, right place, right time, and right quality.
Produce feasibility decision (OM-5): Score business, technical, and project feasibility. Identify the specific knowledge bottleneck the system will address.
Completion gate
Phase 2: Task Analysis & Knowledge Acquisition
Analyze the target task and begin eliciting domain expertise.
Task Analysis
Characterize the task (TM-1): Specify goal, value-add, inputs, outputs, control structure, resources, and quality criteria.
Identify knowledge bottlenecks (TM-2): For each knowledge item the task requires, assess nature (heuristic, formal, procedural, tacit), availability, and the specific bottleneck.
Model agents (AM-1): For each agent involved, catalogue competencies, responsibilities, communication links, and constraints.
Knowledge Elicitation
Select elicitation technique matched to the target knowledge type:
| Target Knowledge |
Technique |
| Orientation, scope, terminology |
Unstructured interview |
| Heuristic rules, decision criteria |
Structured interview (probes P1–P6) |
| Dynamic reasoning, problem-solving trace |
Protocol analysis (think-aloud) |
| Concept hierarchies, taxonomies |
Laddering |
| Latent dimensions, attribute discovery |
Concept sorting / repertory grids |
Execute elicitation sessions with recording and realistic problem scenarios.
Code transcripts against the knowledge model structure: mark up concepts, attributes, values, inferences, and candidate rules.
Validate findings with the domain expert using teach-back.
Completion gate
Phase 3: Conceptual Knowledge Modeling
Construct an implementation-independent model of domain, inference, and task knowledge. Model before rules — do not encode rules until this model is stable.
For detailed construction procedures and the full task template catalog, see knowledge-modeling.md.
Domain Layer
Build the domain schema: Identify concepts, attributes, value types, relations, and subtype hierarchies. This is the static structure of the domain — independent of any reasoning task.
Define rule types: Specify logical dependencies between domain expressions (antecedent → consequent) with cardinality and connection type.
Inference Layer
Specify inferences: Define each primitive reasoning step as a declarative specification with named input and output knowledge roles. Inferences are black boxes — they must not contain internal control flow.
Map knowledge roles to domain: Connect dynamic roles (run-time inputs/outputs) and static roles (stable knowledge base references) to domain schema elements.
Define transfer functions: Specify interaction points with external agents — obtain (system asks), receive (agent volunteers), present (system reports), provide (agent requests).
Task Layer
Select a task template matching the problem type:
- Analytic: Classification, Assessment, Diagnosis, Monitoring
- Synthetic: Configuration Design, Assignment, Planning, Scheduling
Specify task methods: Define how each task decomposes into subtasks and inferences, with explicit control structures (sequence, iteration, selection).
Validation
- Walk through scenarios: Trace at least 2 realistic cases through the complete model (domain → inference → task) on paper. Verify no missing inferences, unmapped roles, or dead-end paths.
Completion gate
Phase 4: Knowledge Representation & Rule Engineering
Choose a representation and encode the conceptual model into executable knowledge structures.
For detailed rule engineering patterns (context trees, parameter types, certainty factor calculus, rule syntax, backward chaining mechanics), see rule-engineering.md.
Representation Selection
Choose representation based on the knowledge model:
| Knowledge Characteristics |
Representation |
| Heuristic associations, evidential reasoning |
Production rules + certainty factors |
| Structured entities with inheritance |
Frames / object hierarchies |
| Taxonomic relationships, shared vocabulary |
Ontologies / semantic networks |
| Tabular decision logic, bounded conditions |
Decision tables |
| Similarity-based reasoning |
Case libraries |
| Multiple knowledge types |
Hybrid combination |
Rule-Based Encoding (when production rules selected)
Define the domain entity hierarchy: Organize entities into a context tree with parent-child relationships and specify properties for each node.
Classify domain parameters: For each attribute, specify value type and bounds, exclusivity (single-valued / multi-valued / binary), and acquisition method (ask user, deduce from rules, or both).
Encode production rules: Each rule is a standalone modular conditional — a conjunction of predicate functions over parameters concluding a parameter value with a certainty weight.
Assign certainty factors: Attach evidential strength CF ∈ [-1.0, +1.0] to each rule action. Positive values increase belief; negative values increase disbelief.
Build knowledge tables: Consolidate repetitive multi-rule mappings into static lookup tables accessed via standardized predicates.
Index rules: Compile cross-reference indices — UPDATED-BY (rules concluding about each parameter) and LOOKAHEAD (rules referencing each parameter in their premise).
Completion gate
Phase 5: Verification & Validation
Verify the knowledge base for consistency and completeness before deployment.
Static Verification
Partition rules into clusters concluding about the same parameter within the same context.
Build condition-action matrices: Enumerate all condition value combinations and map to concluded action values.
Run consistency checks:
- Conflict: Identical conditions → contradictory conclusions
- Redundancy: Identical conditions → identical conclusions
- Subsumption: Rule A's conditions ⊂ Rule B's conditions, same conclusion
Run completeness checks: Identify condition combinations with no rule mapping. Determine if each gap is a genuine missing rule or an impossible domain state.
Resolve anomalies with the domain expert: distinguish real bugs from intentional domain shortcuts.
Dynamic Validation
Assemble a test case library with known expert-determined outcomes.
Run consultation traces and compare outputs against expert determinations.
Trace failures: For each discrepancy, unwind the reasoning chain to identify the root cause (missing rule, incorrect CF, wrong inference path, unmapped parameter).
Completion gate
Phase 6: Design, Implementation & Explanation
Map the verified knowledge model into a working system with explanation and maintenance facilities.
Architecture
Apply structure-preserving design: The domain/inference/task distinctions from the knowledge model must appear explicitly in the software architecture. Flattening them destroys transparency, maintainability, and explanation capability.
Decompose via Model-View-Controller:
- Model: Knowledge base access, inference execution, task control
- View: User interface, explanation display
- Controller: Session management, event dispatch, dialogue flow
Design the inference engine:
- Select chaining strategy (backward / forward / hybrid)
- Implement rule preview (discard rules with known-false premises before evaluation)
- Implement threshold guardrails (halt low-yield branches when premise tally ≤ 0.2)
- Partition self-referencing rules for deferred execution
Explanation Facility
Record reasoning trace: Log the full goal stack, rules evaluated, evidence contributions, and conclusions during each consultation (history tree).
Support interactive explanation:
- WHY: Unwind one level up the goal stack — show current goal, parent goal, linking rule, and premise status
- HOW: Descend one level into a subgoal — show rules evaluated and evidence tallies
Support retrospective queries: Parse post-consultation questions to retrieve reasoning traces, rule citations, and data provenance.
Maintenance Loop
Interactive knowledge acquisition: When a test case fails, trace the history tree to locate the fault, solicit a new rule from the expert, validate against existing rules (subsumption, conflict, tautology), and rerun the test library.
Case-based refinement: Failed cases feed back into elicitation (Phase 2), model refinement (Phase 3), and re-verification (Phase 5).
Completion gate
Worked Examples
For worked examples illustrating each phase (housing eligibility assessment, bacterial infection diagnosis, backward chaining traces, interactive explanation dialogues, and knowledge acquisition sessions), see examples.md.
1---2name: expert-system-engineer3description: Use when engineering knowledge-based expert systems using CommonKADS methodology, MYCIN/EMYCIN rule patterns, certainty factors, or backward-chaining inference engines.4---56# Expert System Engineering78Full lifecycle methodology for engineering knowledge-based expert systems. Upstream phases use CommonKADS for organizational scoping and conceptual modeling. Downstream phases use generalized MYCIN/EMYCIN patterns for rule-based implementation. Follow all phases in order.910For domain terminology, see [terminology.md](references/terminology.md).1112---1314## Phase 0: Suitability Assessment1516Determine whether the problem warrants an expert system before committing to the methodology.17181. **Classify the problem type**:19 - **Analytic** (classification, diagnosis, assessment, monitoring) — system interprets existing data20 - **Synthetic** (configuration, planning, scheduling, design) — system constructs a solution from components21 - **Neither** — redirect to a different approach22232. **Evaluate expert-system fit against alternatives**:2425 | Criterion | Expert System Fit | Alternative |26 |---|---|---|27 | Domain has identifiable human experts | Required | If no experts → data-driven ML |28 | Knowledge is heuristic, judgmental | Strong fit | If purely algorithmic → conventional software |29 | Reasoning must be explainable | Strong fit | If black-box acceptable → ML/statistical |30 | Domain is bounded and well-scoped | Required | If open-ended → LLM-based approaches |31 | Decisions involve uncertainty | Strong fit (CF/rules) | If precise probabilities needed → Bayesian networks |32 | Training data is limited | Advantage over ML | If large labeled datasets exist → ML |33343. Make an explicit **go/no-go decision**. Document the rationale.3536### Completion gate37- [ ] Problem type classified (analytic or synthetic)38- [ ] Fit evaluated against at least three alternatives39- [ ] Go/no-go decision documented with rationale4041---4243## Phase 1: Organizational Scoping & Feasibility4445Scrutinize the organizational environment, isolate the knowledge bottleneck, and confirm feasibility before technical work begins.46471. **Map organizational context** (OM-1): Document business mission, drivers, problems, opportunities, and candidate solution directions.48492. **Analyze variant aspects** (OM-2): Map organizational structure, business processes (activity diagrams), people, resources, and culture/power dynamics.50513. **Decompose into tasks** (OM-3): Break business processes into discrete tasks. For each, record the performing agent, knowledge assets used, knowledge-intensity (1–5), and business significance.52534. **Assess knowledge assets** (OM-4): For each asset, evaluate whether it is in the right **form**, right **place**, right **time**, and right **quality**.54555. **Produce feasibility decision** (OM-5): Score business, technical, and project feasibility. Identify the specific knowledge bottleneck the system will address.5657### Completion gate58- [ ] Knowledge bottleneck identified and scoped59- [ ] Feasibility scored across all three dimensions60- [ ] Project focus confirmed (which task, which knowledge asset)6162---6364## Phase 2: Task Analysis & Knowledge Acquisition6566Analyze the target task and begin eliciting domain expertise.6768### Task Analysis69701. **Characterize the task** (TM-1): Specify goal, value-add, inputs, outputs, control structure, resources, and quality criteria.71722. **Identify knowledge bottlenecks** (TM-2): For each knowledge item the task requires, assess nature (heuristic, formal, procedural, tacit), availability, and the specific bottleneck.73743. **Model agents** (AM-1): For each agent involved, catalogue competencies, responsibilities, communication links, and constraints.7576### Knowledge Elicitation77784. **Select elicitation technique** matched to the target knowledge type:7980 | Target Knowledge | Technique |81 |---|---|82 | Orientation, scope, terminology | Unstructured interview |83 | Heuristic rules, decision criteria | Structured interview (probes P1–P6) |84 | Dynamic reasoning, problem-solving trace | Protocol analysis (think-aloud) |85 | Concept hierarchies, taxonomies | Laddering |86 | Latent dimensions, attribute discovery | Concept sorting / repertory grids |87885. **Execute elicitation sessions** with recording and realistic problem scenarios.89906. **Code transcripts** against the knowledge model structure: mark up concepts, attributes, values, inferences, and candidate rules.91927. **Validate findings** with the domain expert using teach-back.9394### Completion gate95- [ ] Task goal, inputs, outputs, and quality criteria specified96- [ ] Knowledge bottlenecks identified with nature and availability97- [ ] At least one elicitation session executed and coded98- [ ] Findings validated with domain expert99100---101102## Phase 3: Conceptual Knowledge Modeling103104Construct an implementation-independent model of domain, inference, and task knowledge. **Model before rules** — do not encode rules until this model is stable.105106For detailed construction procedures and the full task template catalog, see [knowledge-modeling.md](references/knowledge-modeling.md).107108### Domain Layer1091101. **Build the domain schema**: Identify concepts, attributes, value types, relations, and subtype hierarchies. This is the static structure of the domain — independent of any reasoning task.1111122. **Define rule types**: Specify logical dependencies between domain expressions (antecedent → consequent) with cardinality and connection type.113114### Inference Layer1151163. **Specify inferences**: Define each primitive reasoning step as a declarative specification with named input and output knowledge roles. Inferences are black boxes — they must not contain internal control flow.1171184. **Map knowledge roles to domain**: Connect dynamic roles (run-time inputs/outputs) and static roles (stable knowledge base references) to domain schema elements.1191205. **Define transfer functions**: Specify interaction points with external agents — obtain (system asks), receive (agent volunteers), present (system reports), provide (agent requests).121122### Task Layer1231246. **Select a task template** matching the problem type:125 - **Analytic**: Classification, Assessment, Diagnosis, Monitoring126 - **Synthetic**: Configuration Design, Assignment, Planning, Scheduling1271287. **Specify task methods**: Define how each task decomposes into subtasks and inferences, with explicit control structures (sequence, iteration, selection).129130### Validation1311328. **Walk through scenarios**: Trace at least 2 realistic cases through the complete model (domain → inference → task) on paper. Verify no missing inferences, unmapped roles, or dead-end paths.133134### Completion gate135- [ ] Domain schema specified (concepts, relations, rule types)136- [ ] Inference layer specified (all inferences, knowledge role mappings)137- [ ] Task template selected, methods defined with control structures138- [ ] At least 2 scenarios traced through the full model without gaps139140---141142## Phase 4: Knowledge Representation & Rule Engineering143144Choose a representation and encode the conceptual model into executable knowledge structures.145146For detailed rule engineering patterns (context trees, parameter types, certainty factor calculus, rule syntax, backward chaining mechanics), see [rule-engineering.md](references/rule-engineering.md).147148### Representation Selection1491501. **Choose representation based on the knowledge model**:151152 | Knowledge Characteristics | Representation |153 |---|---|154 | Heuristic associations, evidential reasoning | Production rules + certainty factors |155 | Structured entities with inheritance | Frames / object hierarchies |156 | Taxonomic relationships, shared vocabulary | Ontologies / semantic networks |157 | Tabular decision logic, bounded conditions | Decision tables |158 | Similarity-based reasoning | Case libraries |159 | Multiple knowledge types | Hybrid combination |160161### Rule-Based Encoding (when production rules selected)1621632. **Define the domain entity hierarchy**: Organize entities into a context tree with parent-child relationships and specify properties for each node.1641653. **Classify domain parameters**: For each attribute, specify value type and bounds, exclusivity (single-valued / multi-valued / binary), and acquisition method (ask user, deduce from rules, or both).1661674. **Encode production rules**: Each rule is a standalone modular conditional — a conjunction of predicate functions over parameters concluding a parameter value with a certainty weight.1681695. **Assign certainty factors**: Attach evidential strength CF ∈ [-1.0, +1.0] to each rule action. Positive values increase belief; negative values increase disbelief.1701716. **Build knowledge tables**: Consolidate repetitive multi-rule mappings into static lookup tables accessed via standardized predicates.1721737. **Index rules**: Compile cross-reference indices — UPDATED-BY (rules concluding about each parameter) and LOOKAHEAD (rules referencing each parameter in their premise).174175### Completion gate176- [ ] Representation selected with rationale177- [ ] Domain entity hierarchy defined178- [ ] All parameters classified with types and value bounds179- [ ] Rules encoded in modular form with certainty factors180- [ ] Cross-reference indices compiled181182---183184## Phase 5: Verification & Validation185186Verify the knowledge base for consistency and completeness before deployment.187188### Static Verification1891901. **Partition rules** into clusters concluding about the same parameter within the same context.1911922. **Build condition-action matrices**: Enumerate all condition value combinations and map to concluded action values.1931943. **Run consistency checks**:195 - **Conflict**: Identical conditions → contradictory conclusions196 - **Redundancy**: Identical conditions → identical conclusions197 - **Subsumption**: Rule A's conditions ⊂ Rule B's conditions, same conclusion1981994. **Run completeness checks**: Identify condition combinations with no rule mapping. Determine if each gap is a genuine missing rule or an impossible domain state.2002015. **Resolve anomalies** with the domain expert: distinguish real bugs from intentional domain shortcuts.202203### Dynamic Validation2042056. **Assemble a test case library** with known expert-determined outcomes.2062077. **Run consultation traces** and compare outputs against expert determinations.2082098. **Trace failures**: For each discrepancy, unwind the reasoning chain to identify the root cause (missing rule, incorrect CF, wrong inference path, unmapped parameter).210211### Completion gate212- [ ] Zero unresolved rule conflicts213- [ ] Missing rule combinations reviewed and resolved214- [ ] Test case library exercised with documented results215- [ ] Failure root causes identified and addressed216217---218219## Phase 6: Design, Implementation & Explanation220221Map the verified knowledge model into a working system with explanation and maintenance facilities.222223### Architecture2242251. **Apply structure-preserving design**: The domain/inference/task distinctions from the knowledge model must appear explicitly in the software architecture. Flattening them destroys transparency, maintainability, and explanation capability.2262272. **Decompose via Model-View-Controller**:228 - **Model**: Knowledge base access, inference execution, task control229 - **View**: User interface, explanation display230 - **Controller**: Session management, event dispatch, dialogue flow2312323. **Design the inference engine**:233 - Select chaining strategy (backward / forward / hybrid)234 - Implement rule preview (discard rules with known-false premises before evaluation)235 - Implement threshold guardrails (halt low-yield branches when premise tally ≤ 0.2)236 - Partition self-referencing rules for deferred execution237238### Explanation Facility2392404. **Record reasoning trace**: Log the full goal stack, rules evaluated, evidence contributions, and conclusions during each consultation (history tree).2412425. **Support interactive explanation**:243 - **WHY**: Unwind one level up the goal stack — show current goal, parent goal, linking rule, and premise status244 - **HOW**: Descend one level into a subgoal — show rules evaluated and evidence tallies2452466. **Support retrospective queries**: Parse post-consultation questions to retrieve reasoning traces, rule citations, and data provenance.247248### Maintenance Loop2492507. **Interactive knowledge acquisition**: When a test case fails, trace the history tree to locate the fault, solicit a new rule from the expert, validate against existing rules (subsumption, conflict, tautology), and rerun the test library.2512528. **Case-based refinement**: Failed cases feed back into elicitation (Phase 2), model refinement (Phase 3), and re-verification (Phase 5).253254### Completion gate255- [ ] Architecture preserves knowledge model structure256- [ ] Inference engine handles chaining, pruning, thresholds, and self-referencing rules257- [ ] Explanation facility supports WHY, HOW, and retrospective queries258- [ ] Knowledge acquisition loop operational for incremental refinement259260---261262## Worked Examples263264For worked examples illustrating each phase (housing eligibility assessment, bacterial infection diagnosis, backward chaining traces, interactive explanation dialogues, and knowledge acquisition sessions), see [examples.md](references/examples.md).