Skip to main content

A more general reasoning case

The wumpus world despite its triviality, contains some deeper abstractions that are worth summarizing.
  1. Logical inference can be done via an internal representation that are sentences - their syntax and semantics we will examined next.
  2. Sentences may be expressed in natural language. Together with the perception and probabilistic reasoning subsystems that can generate symbols associated with a task, the natural language can be grounded and inferences can be drawn in a ‘soft’ or probabilistic way at the symbolic level.
To return to the backpack problem, for the sentence β\beta that declares that the backpack was abandoned, we need to entail a sentence α\alpha (and we denote it as αβ\alpha \models \beta) that the backpack was handed over to nobody\mathtt{nobody} and therefore justify an action to sound the security alarm. Note the direction in notation: α\alpha is a stronger assertion that β\beta. The specific world model mm is a mathematical abstraction that fixes as TRUE or FALSE each of the sentences it contains and as you understand, depending on the sentences, it may or may not correspond to reality. We denote the set of models that satisfy sentence α\alpha as M(α)M(\alpha). We also say that mm is a model of α\alpha. Now that we have defined the world model we can go back to the definition of entailment in the earlier example and write: αβ    M(α)M(β) \alpha \models \beta \iff M(\alpha) ⊆ M(\beta)

Model-Checking Algorithm

The reasoning algorithm regarding the possible state of the environment in surrounding cells that the agent performed informally above, is called model checking because it enumerates all possible models to check that a sentence aa is supported by the KB i.e. M(KB)M(α)M(KB) ⊆ M(\alpha). wumpus-entailment Possible Models in the presence of pits in cells [1,2],[2,2] and [3,1]. There are 23=82^3=8 possible models. The KB when the percepts indicate nothing in cell [1,1] and a breeze in [2,1] is shown as a solid line. With dotted line we show all models of a1="not have a pit in [1,2]"a_1=\text{"not have a pit in [1,2]"} sentence. wumpus-noentailment Same situation as the figure above but we indicate with dot circle a different sentence a2a_2. What is this sentence?

Propositional Logic Syntax

The PL syntax defines the allowable sentences that can be complex. Each atomic sentence consists of a single (propositional) symbol and the fixed symbols TRUE & FALSE. In BNF the atomic sentences or formulas are also called terminal elements. Complex sentences can be constructed from sentences using logical operators (connectives that connect two or more sentences). In evaluating complex sentences the operator precedence shown in the figure below must be followed. BNF-grammar-prop-logic BNF grammar of propositional logic Out of all the operators, two are worthy of further explanation.
  1. imply (⇒) operator: the left hand side is the premise and the right hand side is the implication or conclusion or consequent. This is an operator of key importance known as rule. Its an if-then statement.
  2. if and only if (⇔) operator: its expressing an equivalence (≡) or a biconditional.

Propositional Logic Semantics

The semantics for propositional logic specify how to compute the value of any sentence given a model. To do so we use the following truth table. truth-table Truth tables for three primary and five derived logical operators. Note the presence of the XOR connective. Given a world model in the KB m1=[P1,2=FALSE,P2,2=FALSE,P3,1=TRUE]m_1 = \left[ P_{1,2}=FALSE, P_{2,2}=FALSE, P_{3,1}=TRUE \right] a sentence can be assigned a truth value (FALSE/TRUE) using the semantics above. For example the sentence, ¬P1,2(P2,2P3,1)=TRUE\neg P_{1,2} \land (P_{2,2} \lor P_{3,1}) = TRUE

Inference Example

Using the operators and their semantics we can now construct an KB as an example for the wumpus world. We will use the following symbols to describe atomic and complex sentences in this world.
SymbolsDescription
Px,yP_{x,y}Pit in cel [x,y]
Wx,yW_{x,y}Wumpus (dead or alive) in cel [x,y]
Bx,yB_{x,y}Perception of a breeze while in cel [x,y]
Sx,yS_{x,y}Perception of a stench while in cel [x,y]
Using these symbols we can convert the natural language assertions into logical sentences and populate the KB. The sentences R1R_1 and R2/R3R_2/R_3 are general rules of the wumpus world. R4R_4 and R5R_5 are specific to the specific world instance and moves of the agent.
SentenceDescriptionKB
R1R_1There is no pit in cel [1,1]¬P1,1\neg P_{1,1}
R2R_2The cell [1,1] is breezy if and only if there is a pit in the neighboring cell.B1,1(P1,2P2,1)B_{1,1} ⇔ (P_{1,2} \lor P_{2,1})
R3R_3The cell [2,1] is breezy if and only if there is a pit in the neighboring cell.B2,1(P1,1P2,2P3,1)B_{2,1} ⇔ (P_{1,1} \lor P_{2,2} \lor P_{3,1})
R4R_4Agent while in cell [1,1] perceives [Stench, Breeze, Glitter, Bump, Scream]=[None, None, None, None, None]¬B1,1\neg B_{1,1}
R5R_5Agent while in cell [2,1] perceives [Stench, Breeze, Glitter, Bump, Scream]=[None, Breeze, None, None, None]B2,1B_{2,1}
As the agent moves, it uses the KB to decide whether a sentence is entailed by the the KB or not. For example can we infer that there is no pit at cell [1,2] ? The sentence of interest is α=¬P1,2 \alpha = \neg P_{1,2} and we need to prove that: KBαKB \models \alpha To answer such question we will use the model checking algorithm outlined in this chapter: enumerate all models and check that α\alpha is true for in every model where the KB is true. We construct the truth table that involves the symbols and sentences present in the KB: truth-table-kb As described in the figure caption, 3 models out of the 27=1282^7=128 models make the KB true and in these rows the P1,2P_{1,2} is false. Although the model checking approach was instructive, there is an issue with its complexity. Notice that if there are nn symbols in the KB there will be 2n2^n models, the time complexity is O(2n)O(2^n). The symbolic representation together with the explosive increase in the number of sentences in the KB as time goes by, cant scale. Another approach to do entailment, potentially more efficient, is theorem proving where we are applying inference rules directly to the sentences of the KB to construct a proof of the desired sentence/query. Even better, we can invest in new representations as described in the PDDL chapter to develop planning approaches that combine search and logic and do not suffer necessarily from the combinatorial explosion problem. If you need to review the BNF expressed grammar for propositional logic (as shown in the syntax above) review part 1 and part 2 video tutorials.
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.