Logical Agents

Knowledge-Based Agents

Agents that maintain an internal Knowledge Base (KB).

To act, the agent TELLs the KB what it perceives, and ASKs the KB what it should do.

Logic Terminology

Entailment & Inference

Entailment: KB \models \alpha (The KB entails sentence \alpha).33. Entailment is the invisible mathematical reality; inference is the computer algorithm trying to uncover that reality.

Inference: The algorithmic process of deriving new sentences from old ones. KB \vdash_i \alpha means algorithm i derives \alpha from the KB.

Propositional Logic

A very simple logic consisting of proposition symbols (e.g., P_1, Q_2) and logical connectives.44. Propositional logic is extremely limited because you cannot express general rules easily (e.g., you’d need a separate rule for every single square on a chessboard).

Connectives:

Aside: Implication Truth Table

Remember that P \implies Q is only false if P is true and Q is false. If P is false, the implication is true regardless of Q’s value (vacuous truth).

Theorem Proving

Checking entailment can be done by:

  1. Model Checking: Enumerating all possible truth assignments and checking if \alpha holds whenever KB holds (Truth tables). O(2^n) time.
  2. Inference Rules: Applying sound rules directly to sentences.

Resolution

A powerful, single inference rule that is sound and complete for propositional logic.55. Because resolution is complete, we can use it to build automated theorem provers that guarantee a definitive answer.

Requires sentences to be in Conjunctive Normal Form (CNF) (an AND of ORs).

Rule: l_1 \lor ... \lor l_k and m_1 \lor ... \lor m_n, where l_i and m_j are complementary literals (e.g., P and \neg P).

Resolve to: l_1 \lor ... \lor l_{i-1} \lor l_{i+1} \lor ... \lor l_k \lor m_1 \lor ... \lor m_{j-1} \lor m_{j+1} \lor ... \lor m_n.

Example: Resolution

Clause 1: P \lor Q Clause 2: \neg P \lor R Resolvent: Q \lor R (Because P can’t be both true and false, either Q or R must be true to satisfy both clauses).

DPLL Algorithm

DPLL is a complete, backtracking-based search algorithm for deciding propositional satisfiability (SAT). It improves on pure model checking through three powerful heuristics:

  1. Early Termination: The algorithm stops evaluating a clause if any literal is already satisfied, and stops evaluating the entire formula if any clause is already falsified.
  2. Pure Symbol Heuristic: If a symbol appears with only one sign (either strictly positive or strictly negative) throughout all clauses, DPLL assigns it the value that satisfies all those clauses.
  3. Unit Clause Heuristic: If a clause has only one unassigned literal left (and all others are false), that literal must be assigned true for the formula to be satisfied, forcing an immediate assignment.

  1. Unlike reflex agents, a knowledge-based agent can be told new facts at runtime and immediately change its behavior without needing to be re-programmed.↩︎

  2. Syntax is “how you write it”; semantics is “what it means.” “X + Y = Z” is syntactically valid math, but its semantic truth depends on the values of the variables.↩︎

  3. Entailment is the invisible mathematical reality; inference is the computer algorithm trying to uncover that reality.↩︎

  4. Propositional logic is extremely limited because you cannot express general rules easily (e.g., you’d need a separate rule for every single square on a chessboard).↩︎

  5. Because resolution is complete, we can use it to build automated theorem provers that guarantee a definitive answer.↩︎