Facts, rules and inference
Knowledge representation is the way an AI system records information so it can use that information to reason. A fact records an assertion; a rule states which conclusions follow when specified conditions hold. Inference derives conclusions from facts and rules. Unlike a model that estimates likely answers from examples, a symbolic system can show exactly which assumptions supported a result.
A fictional training machine
Imagine a tabletop simulator called M1. Its input report contains low_battery and failed_start. A third fact, manual_available, means a fictional manual is present. These are synthetic observations, not verified measurements of real equipment. A teaching rule says: if low_battery AND failed_start, then check_battery. The conclusion means recommend reviewing a diagnostic step, not prove the battery is defective or perform any action. A second rule says: if check_battery AND manual_available, then review_manual. The collection of facts and rules is a knowledge base (KB).
Propositions and logical connectives
A proposition is a statement that is true or false in a particular interpretation. Use P for low_battery and Q for failed_start. NOT P (¬P) reverses P; P AND Q (P ∧ Q) requires both; P OR Q (P ∨ Q) requires at least one, including both. P → Q is material implication: it is false only when P is true and Q false. It does not assert causation, sequence, or that P is true. Parentheses make grouping explicit. A truth assignment gives each atom a Boolean value; a truth table evaluates a formula for all assignments.
def implies(p, q): return (not p) or q
for p, q in [(False, False), (False, True), (True, False), (True, True)]: print(p, q, implies(p, q))Expected output, one row per pair: False False True, False True True, True False False, True True True. The function uses Python Boolean operators on actual bool inputs; it is not a general parser for logical expressions. If P is false, P → Q is true regardless of Q. That does not establish Q. In the machine rule, P is the conjunction of both observations and Q is the recommendation.
Apply a rule without reversing it
Modus ponens uses P and P → Q to infer Q. The generalized form for our rules requires every premise to hold. From low_battery and failed_start the KB derives check_battery. Knowing check_battery alone does not establish low_battery: another rule, such as an inspection schedule, could also support it. Inferring the antecedent from the consequent is the fallacy of affirming the consequent. From P → Q and ¬Q one can infer ¬P in classical logic (modus tollens), but our positive-rule program implements neither explicit negation nor modus tollens.
Represent a rule as a pair [premises, head], where premises is a list of atom names and head is one name. Use sets for known facts and return sorted names for deterministic output. The next function checks only the facts supplied at the start of the call. It does not add a derived head to the working set, so a second rule depending on that head does not fire in this pass. An empty premise list is an unconditional fact: all([]) is True.
def applicable_heads(facts, rules): known = set(facts) return sorted({head for premises, head in rules if all(p in known for p in premises)})
facts = ["low_battery", "failed_start", "manual_available"]rules = [(["check_battery", "manual_available"], "review_manual"), (["low_battery", "failed_start"], "check_battery")]print(applicable_heads(facts, rules))print(applicable_heads(["failed_start"], rules))Expected output: ['check_battery'] then []. The rule for review_manual appears first but its check_battery premise is not yet known. The second input lacks low_battery, so neither rule fires. Duplicate rule heads are returned once. The code treats atom names as opaque case-sensitive strings; no arithmetic, natural-language parsing, or real device control is performed.
Entailment, soundness and missing evidence
A model of the KB is an interpretation that makes every KB statement true. KB entails a conclusion when the conclusion is true in every such model. A sound inference method derives only entailed statements; completeness means it can derive every conclusion of the specified kind that is entailed. The one-pass function is sound for the positive rule fragment but is not a complete multi-step reasoner. Even a logically sound conclusion depends on the quality of input assertions and rules; incorrect observations can produce an inappropriate recommendation.
Under an open-world assumption, a missing assertion is not automatically false. If low_battery is absent, it may be unknown. A closed-world policy may treat a missing derivable atom as false within a deliberately complete dataset, but that is an additional modeling choice, not a general logical law. Explicit evidence for both P and ¬P is a contradiction. Classical logic with inconsistent premises has no model and entails every formula; a practical assistant must detect and quarantine conflicting reports rather than issue arbitrary recommendations. Our positive atom engine cannot detect classical negation, and a string such as not_low_battery has no built-in relationship to low_battery.
Practice
Predict the heads for facts ["low_battery", "manual_available"]; then add failed_start. Explain why the original rule cannot prove a defective battery, and why a missing low_battery report should prompt a request for evidence rather than a claim that the battery is healthy. Next, use the same rule representation to derive chains of conclusions.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Facts, rules and inference — understanding check
Apply the rules and explain the scope of the inference.
Which facts support check_battery in the original rule?
When is P → Q false in classical propositional logic?
The sole rule is (low_battery AND failed_start) → check_battery. If check_battery is known but neither premise is reported, what does the rule establish about the premises?
For facts=[] and rules=[([], "ready")], what does applicable_heads(facts, rules) return?
Under open-world reasoning, a missing low_battery assertion is not entailed or contradicted by other evidence. How should it be treated?