Knowledge and logic: reasoning with facts

11 min read

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:

  1. 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.
  2. 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

StrengthsLimits
Conclusions are provably correct if the premises areSomeone must write down all the knowledge
Every step can be explainedThe world is uncertain and messy; logic is all-or-nothing
Great for rules, regulations, configuration, verificationBrittle: 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

Check 1 of 2Module 2 · Classic AI: search, logic, probability and optimization

A knowledge base contains 'If it rains, the match is cancelled' and 'It is raining.' What does it entail?

Check 2 of 2Module 2 · Classic AI: search, logic, probability and optimization

Why does model checking become impractical with many propositions?

Answer the checks, then mark this lesson complete
Completion and scores are saved in this browser.