Knowledge and logic: reasoning with facts
Humans reason from what they know to new conclusions. Knowledge-based agents do the same with formal logic.
Propositional logic in brief
- Propositions are statements that are true or false: P = "it is raining", Q = "the ground is wet."
- Connectives combine them: NOT (¬), AND (∧), OR (∨), IMPLIES (→), IF AND ONLY IF (↔).
- A knowledge base (KB) is a set of sentences the agent believes, such as P → Q and P.
- A model is one possible assignment of true/false to every proposition.
Entailment and inference
The KB entails a sentence α (written KB ⊨ α) if α is true in every model where the KB is true. From P → Q and P, the KB entails Q.
Two ways to check:
- Model checking: list every possible model and confirm α holds wherever the KB holds. Simple, but with n propositions there are 2^n models, which becomes impossible fast.
- Inference rules: derive new sentences step by step. Modus ponens (from P → Q and P, conclude Q) is the classic rule. Resolution is a single general rule that, applied systematically, can prove anything that is entailed, and is the basis of many automated theorem provers.
Beyond propositions
First-order logic adds objects, properties and relationships with quantifiers ("for all", "there exists"): every person has a mother. It is far more expressive and underlies knowledge graphs, database query languages and formal verification of software and chips.
Strengths and limits
| Strengths | Limits |
|---|---|
| Conclusions are provably correct if the premises are | Someone must write down all the knowledge |
| Every step can be explained | The world is uncertain and messy; logic is all-or-nothing |
| Great for rules, regulations, configuration, verification | Brittle: one wrong or missing rule breaks reasoning |
This is why 1980s expert systems struggled, and why probability and machine learning took over. But logic is back in new forms: verifying AI-written code, checking that outputs satisfy rules, and combining LLMs with formal tools.
Check your understanding
A knowledge base contains 'If it rains, the match is cancelled' and 'It is raining.' What does it entail?
Why does model checking become impractical with many propositions?