Outline
- Search and Proofs
- In-Class Exercise
- Validity, Satisfiability, Refutations
Introduction
- We were talking about Logical Agents.
- We were focusing initially on propositional logic as a framework for representing our knowledge base as this
is about the simplest logic in town.
- We were talking about algorithms by which a logical agent could infer things about its environments (which in turn would hopefully inform the choice of its actions).
- We looked at examples of how we could see if `KB models alpha` holds in the Wumpus World setting using
model checking. i.e., we check that in every model in which `KB` holds `alpha` holds as well.
- Checking all models of a collection of propositional logic statements involves checking all truth assignments
to the variables. If one has `n` variables, one gets `2^n` meaning this algorithm is slow.
- So we said we wanted to determine entailment via theorem proving -- applying rules of inference directly to the sentences in our knowledge base to construct a proof of the desired sentence without consulting models.
- To start today, we continue are development of theorem proving systems.
Truth of any Sentence in a Model
- The semantics of propositional logic must specify how to compute the truth value of any sentence, given a model.
- We do this inductively. We define True to be true in any model and False to be false in any model. Recall a model give a value true of false to each of the propositional variables in the model. As the AtomicSentences consist of True, False, or single variables, the model itself says the truth or falsity of all AtomicSentences. Suppose we have already defined the truth of `phi` and `psi`. Then:
`neg phi` is true in `M` iff `phi` is false in `M`
`phi ^^ psi` is true in `M` iff `phi` is true in `M` and `psi` is true in `M`
`phi vv psi` is true in `M` iff `phi` is true in `M` or `psi` is true in `M`
`phi => psi` is true in `M` unless `phi` is true in `M` and `psi` is false in `M`
`phi <=> psi` is true in `M` iff both `phi` and `psi` are both true or both false
A Simple Knowledge Base
- Now that we have defined the semantics of propositional logic, we can construct a KB for the wumpus world:
- We use the following variables with intended meanings:
- `P_(x,y)` is true if there is a pit in `[x,y]`
- `W_(x,y)` is true if there is a wumpus in `[x,y]` dead or alive
- `B_(x,y)` is true if the agent perceives a breeze in `[x,y]`
- `S_(x,y)` is true if the agent perceives a stench in `[x,y]`
- We now write some sentences which suffice to derive `neg P_(1,2)`. We label each sentence `R_i` so we can refer to them.
- There is no pit in [1,1]:
`R_1 : neg P_(1,1)`
- A square is breezy iff there is a pit in a neighboring square. This has to be stated for each square: for now we include just the relevant squares:
`R_2 : B_(1,1) <=> (P_(1,2) vv P_(2,1))`
`R_3 : B_(2,1) <=> (P_(1,1) vv P_(2,2) vv P_(3,1))`
- The preceding sentences are true in all Wumpus worlds. Now we include the breeze percept for the first two squares visited in the specific world the agent is in:
`R_4: neg B_(1,1)`
`R_5: B_(2,1)`
A Simple Inference Procedure
- Our goal is to decide whether `KB models alpha` for some sentence `alpha`.
- In particular, is `neg P_(1,2)` entailed by our `KB`.
- Our first algorithm for inference is a model-checking approach: enumerate the models, and check that `alpha` is true in every model in which KB is true.
- So for our wumpus world example the relevant variables to consider are: `B_(1,1), B_(2,1), P_(1,1), P_(1,2), P_(2,1), P_(2,2), and P_(3,1)`
- These can take on `2^7 = 128` values (possible worlds). In three of these the KB is true. In each of these it turns out that `neg P_(1,2)`, so it does follow
- This is an exponential time algorithm in the number of propositions. It turns out that we don't know if we can do better by being clever: It would imply `NP = co`-`NP`.
Theorem Proving
- Rather than determining entailment by model checking, one could instead do it via theorem proving -- applying rules of inference directly to the sentences in our knowledge base to construct a proof of the desired sentence without consulting models.
- To do this we make use of something called logical equivalence: two sentences `alpha` and `beta` are logically equivalent if they are true in the same set of models. For `alpha`, and `beta` sentences we would write this as `alpha equiv beta`.
- For example, `P ^^ Q` and `Q ^^ P` are logically equivalent
- The second concept needed for theorem proving is that of validity: A sentence is valid if it is true in all models. Valid sentences are also known as tautologies.
- The deduction theorem known to the ancient Greeks says that `alpha models beta` iff the sentence `alpha => beta` is valid.
- So we will be interested in tautologies of the latter form.
Common Logical Equivalences
- `(alpha ^^ beta) equiv (beta ^^ alpha)` commutativety of `^^`
- `(alpha vv beta) equiv (beta vv alpha)` commutativety of `vv`
- `((alpha ^^ beta) ^^ gamma) equiv (alpha ^^ (beta ^^ gamma))` associativety of `^^`
- `((alpha vv beta) vv gamma) equiv (alpha vv (beta vv gamma))` associativety of `vv`
- `neg (neg alpha) equiv alpha` double-negation elimination
- `alpha => beta equiv not beta => not alpha` contraposition
- `alpha => beta equiv not alpha vv beta` implication elimination
- `alpha <=> beta equiv alpha => beta ^^ beta =>alpha` biconditional elimination
- `not (alpha ^^ beta) equiv (not alpha vv not beta)` DeMorgan
- `not (alpha vv beta) equiv (not alpha ^^ not beta)` DeMorgan
- `alpha ^^ (beta vv gamma) equiv (alpha ^^ beta) vv (alpha ^^ gamma)` distributivity of `^^` or `vv`
- `alpha vv (beta ^^ gamma) equiv (alpha vv beta) ^^ (alpha vv gamma)` distributivity of `vv` or `^^`
Satisfiability
- A sentence is satisfiable if it is true in some model.
- For example, `(A ^^ B)` is satisfiable in the model `{A= true, B = true}`
- For propositional logic, the problem of given a propositional formula determining if it is satisfiable, is often written as SAT.
It is an example of an NP-complete problem.
- By the deduction theorem, we had `alpha models beta` iff `alpha => beta` is valid (aka, a tautology).
- The later is equivalent to `\not alpha vv beta` and by deMorgan's rule equivalent to `not (alpha ^^ not beta)`.
- So we could prove `alpha => beta` by checking the unsatisfiability `alpha ^^ not beta`. This process is sometimes called
reduction ad absurdum.
- If it is also called proof by refutation or proof by contradiction.