- [i] Knowledge is:
- A theoretical/partial understanding of a subject/domain.
- The sum of what's currently known.
- [i] A domain expert is someone who possesses:
- Deep knowledge (facts and rules) and
- Strong practical experience
- ... in a particular domain, whose area may be limited.
- [i] The human mental process is internal.
- It is too complex to be represented as an algorithm.
- Experts can express knowledge in the form of rules for problem solving.
- An
$\text{IF}$ -$\text{THEN}$ structure - Relates given information to some actions.
- i.e., Relates
$\text{IF}$ part to$\text{THEN}$ part.
- i.e., Relates
- Provides some description on "how to solve a problem".
-
Antecedent (Premise/Condition) 前因: The
$\text{IF}$ part- Object: A thing to describe.
- Operator: Identifies an object, assigns a value.
- Value: Symbolic / Numeric.
-
Consequent (Conclusion/Action) 后果: The
$\text{THEN}$ part- Actions
- Example:
IF customer_age > 18
THEN sell_wine()
A rule can have multiple antecedents joined by:
-
$\text{AND}$ (Conjunction), and -
$\text{OR}$ (Disjunction), - or both. Example:
IF customer_age < 18
AND cash_withdrawal > 1000
THEN require(parent_signature)
Rules can represent:
IF fuel_tank is empty
THEN conclude("car is dead")
IF season is autumn
AND sky is cloudy
AND forecast is drizzle
THEN advice("take umbrella")
IF car is dead
AND fuel_tank is empty
THEN refuel(car)
IF car is dead
THEN check(fuel_tank), complete(step_1)
IF step_1 is complete
AND fuel_tank is full
THEN check(battery), complete(step_2)
IF spill is liquid
AND spill_ph < 6
AND spill_smell is vinegar
THEN conclude("spill_material is acetic acide")
- Domain Expert
- Knowledge Engineer
- Programmer
- Project Manager
- End-user
- Promoted by Newell and Simon from Carnegie-Mellon University.
- Idea:
- Apply given knowledge (in the form of production rules) to a problem,
- which is represented by problem-specific information.
- Property:
- Production rules are stored in the long-term memory.
- The problem-specific information (facts) are stored in the short-term memory.
flowchart TD
A["`
**Long-term Memory**
Production Rule
`"] <--> C[Reasoning]
B["`
**Short-term Memory**
Facts
`"] <--> C
C --> D[Conclusion]
-
Knowledge Base 规则库
- Contains domain knowledge.
- Knowledge is represented as a set of rules.
- Each rule specifies a relation/recommendation/directive/strategy/heuristic.
- Each rule has the
$\text{IF}-\text{THEN}$ structure.
- When the condition part of a rule is satisfied:
- The rule would fire, and the action part is executed.
- Once the action is created, new facts will be generated.
-
Database 事实库
- Contains a set of facts.
- Facts are used to match against the
$\text{IF}$ parts of rules stored in the knowledgebase.
-
Inference Engine 推理引擎
- Performs the Reasoning
- Carries out the reasoning, and reach a solution.
- Links rules from knowledge base and facts in database.
- Compares fact and the
$\text{IF}$ part of rules. - When the
$\text{IF}$ part of the rule matches some facts in the database:-
Fire the rule, execute the
$\text{THEN}$ part. - The rule generates new facts.
-
Fire the rule, execute the
-
Explanation Facilities 解释设施
- Explains the Reasoning
- Enables user to ask the expert system:
- how, a particular conclusion is reached, and
- why, a specific fact is needed.
flowchart TD
A["`
**Knowledge Base**
IF-THEN Rule
`"]
<-->
C["`
Inference Engine
推理引擎
`"]
B["`
**Database**
Facts
`"] <--> C
C
<-->
D["`
Explanation Facilities
解释设施
`"]
D <--> E[User Interface]
E <--> User
- As mentioned in [[#2.2.2 Structure of a rule-based expert system]]:
- The inference engine matches facts in the database and fire rules whose
$\text{IF}$ parts matches to some of the facts, producing new facts.
- The inference engine matches facts in the database and fire rules whose
- The matching of
$\text{IF}$ parts of the rules to the facts produces Inference Chains推理链条.- Inference chains indicates how an expert system applies the rules to reach a conclusion.
Rule set:
Rule 1: IF Y is true
AND D is true
THEN Z is true
Rule 2: IF X is true
AND B is true
AND E is true
THEN Y is true
Rule 3: IF A is true
THEN X is true
Graph of the rule set:
flowchart LR
A[A] --> X[X]
X[X] --> Y[Y]
B[B] --> Y[Y]
E[E] --> Y[Y]
Y[Y] --> Z[Z]
D[D] --> Z[Z]
- [i] Data-Driven Reasoning
- Given the rules, find the goal.
- Reasoning starts from the known data, and proceeds with it.
- In each iteration:
- Proceeds forward with known data, execute rules to get new facts.
- Any rule can be executed only once.
- Store new fact in the database.
- Proceeds forward with known data, execute rules to get new facts.
- Then use the new fact to do get other facts in the next iteration.
Known facts:
-
$A,B,E,D$ Given Rules:
flowchart LR
A[A] --> X[X]
X[X] --> Y[Y]
B[B] --> Y[Y]
E[E] --> Y[Y]
Y[Y] --> Z[Z]
D[D] --> Z[Z]
Inference Process:
| Iter | Known Facts | Rules Fired | New Facts | Remarks |
|---|---|---|---|---|
| 0 | Initial State | |||
| 1 |
|
|||
| 2 | ||||
| 3 | No more rules to be fired. |
- Forward chaining is a technique for:
- First gathering information,
- and then inferring from it.
- However, many rules may be executed.
- Where most of them has nothing to do with the established goal.
- Therefore:
- If our goal is to infer only one particular fact, forward chaining inference would not be efficient.
- [i] Goal-Driven Reasoning
- Given the goal, find the rules to prove this goal.
- An expert system has the goal
- The inference engine attempts to find the evidence to prove it.
- In each iteration:
- Search knowledge base to find rules that might prove the goal.
- If such rules is found, search for their
$\text{IF}$ parts in the database.- If the
$\text{IF}$ parts is matched, the goal is proved. - Otherwise, attempt to find rules that produces that particular
$\text{IF}$ part, and so on. (In a recursive manner)
- If the
Known Facts:
-
$\text{A},\text{B},\text{C},\text{E}$ Given Rules:
flowchart LR
A[A] --> D[D]
C[C] --> F[F]
D[D] --> F[F]
E[E] --> G[G]
F[F] --> Z[Z]
G[G] --> Z[Z]
Backward-Chaining Stack Trace:
Given A, B, C, E.
Start.
try F --> Z, (Can't find F)
try C & D --> Z, (Can't find D)
try A --> D. (Satisfied)
try G --> Z, (Can't find G)
try E --> G. (Satisfied)
End.
- [i] In fact, it is possible to have two rules conflicting.
Rule 1: IF traffic_light is red
THEN stop()
Rule 2: IF traffic_light is red
THEN go()
With the graph:
flowchart LR
A["`traffic_light *is* red`"] --> B["`stop()`"]
A --> C["`go()`"]
-
Rule 1andRule 2shares the same$\text{IF}$ part.- Thus, both of them can be set to fire when their common
$\text{IF}$ part is satisfied. - These rules represents a Conflict Set.
- Thus, both of them can be set to fire when their common
-
In forward chaining, both rules will be fired together if no resolution is made.
- In this case,
Rule 3will be fired afterRule 2in sequence. - Therefore, the action
go()will overwrite the actionstop().
- In this case,
-
The inference engine must decide which rule to fire from such a set.
- A method for choosing a rule to fire from a conflict set in a cycle is called Conflict Resolution.
- [i] Fire the rules with the highest priority.
- Priorities can be established by placing rules in an appropriate order in the knowledge base.
- Works well with expert systems with ~100 rules.
- [i] Fire the rules that's the most specific.
- Also known as the longest matching strategy.
- It is based on the assumption that:
- A specific rule processes more information than a general one.
Given:
A & B -> C
A -> !C
Choice:
A & B -> C
Reason:
A & B is more specific thant A itself.
- [i] Fire the rule that uses the fact that's most recently entered in the database.
- That is, to use the newest facts.
- This method relies on time tags attached to each fact in the database.
- [i] Knowledge about Knowledge
- About the use & control of domain knowledge in an expert sys.
- [i] Metaknowledge is represented by Metarules.
Metarule 1: Rules supplied by experts are prioritized over the ones supplied by novices. ....
- [p] Natural Knowledge Representation.
- [p] Uniform
$\text{IF}$ -$\text{THEN}$ Structure.- Each
$\text{IF}$ -$\text{THEN}$ Structure is an independent piece of knowledge.
- Each
- [p] Separation of Knowledge Base from Inference Engine.
- Can develop different applications with the same expert system structure.
- [p] Good at coping Incomplete & Uncertain Knowledge
- [c] Opaque Relations between Rules in a large Knowledge Base.
- Difficult to observe how individual rules server the overall strategy once the knowledge base gets large.
- [c] Ineffective search strategy.
- The inference engine applies an exhaustive search through all production rules during each iteration.
- Therefore, expert systems with a large set of rules can be slow, and thus incompatible with real-time applications.
- [c] Inability to learn.
- Rules can't be adjusted, and new rules can't be added either.
- Can't modify the knowledge base, thus can't learn from experience.
- This means that the knowledge engineer is responsible for revising the system. This is manual learning instead of machine learning.