Finish First-order Logic Overview




CS156

Chris Pollett

Nov 7, 2022

Outline

Introduction

Examples of 1st Order Knowledge Bases

KBs, First-Order Proofs

Soundness and Completeness

Quiz

Which of the following is true?

  1. A Horn clause must have exactly one positive literal.
  2. Under CWA, things we don't know about we assume are false.
  3. It is impossible to come up with a model `M` such that `M |== (exists x) (1+1)cdot x = 1+1+1`.

Theorem Proving in First-Order Logic

The basic idea is we want to reduce the first-order case to the propositional case. To do this:

  1. Convert each formula in the set of formulas `KB cup {neg alpha}` using some of the operations previously described into prenex normal form:
    `forall vec(x) exists vec(y) forall vec(z) ... G(vec(x), vec(y), vec(z), ...)`
    where `G` does not involve quantifiers and may involve `neg, vee, wedge`. The reason why we are working with sets rather than the single formula `KB wedge neg alpha` is to allow for the case KB is an infinite set of formulas.
  2. Introduce new function symbols for `forall exists` blocks. For example,
    `forall x_1 forall x_2, exists y_1, exists y_2, exists y_3 G(x_1, x_2, y_1, y_2, y_3)`
    transforms to
    `forall x_1 forall x_2,G(x_1, x_2, f_1(x_1, x_2), f_2(x_1, x_2), f_3(x_1, x_2))`
    This process is called Skolemization. Given a formula `A` we denote its Skolemization as `A^S`. For a set of formula `Gamma` applying Skolemization to each formula yields a set `Gamma^S`. One can show `Gamma |== B` iff `Gamma^S |== B`, so if `KB cup { not alpha}` has refutation then so does `(KB cup {not alpha})^S`.
  3. If we have all variables bound, and only universal quantifiers, we can ditch the quantifiers and have an open formula with our variables all free.
  4. Once we get open formulas without any quantifiers, convert to CNF and try to use resolution algorithm.

Some remarks on the above:

  1. How do we handles formulas with just existentials quantifiers and no universal? Answer: we view these as functions from no arguments to a value. I.e., we replace these with fresh constants.
  2. How are the new function symbols related to the existing terms in the language before adding the function symbols? In general, a new function symbol `f` is connected to existing function and predicate symbols in the language but won't necessarily be expressible as a term in the original language. For example, Skolemizing an induction axiom:
    `A(0, vec a) wedge forall x(A(x, vec a) => A(S(x), vec a)) => A(t(vec a), vec a)`
    might yield a function of the predicate `A`, which when given a `t(vec a)` such that `A(0) and neg A(t(vec a))` holds, searches for a value `v` as a function of `vec a` such that `A(v, vec a)` holds but `A(S(v), vec a)` does not. This search operation might not be expressible as a single term in the original language.
  3. To do resolution we might now also need to come up with substitution lists between two atomic formulas in `G`, say `F(vec(t))`, `F(vec(s))`, for the terms `t_1, ..., t_n` and `s_1`, ..., `s_n` so that they are the same formula. This is so that after doing the substitution, we can resolve the two formulas. Unification is an algorithm for doing this.

Unification Algorithm

If x is a list let head(x) denote the first element of the list, x[0], and tail(x) denote x[1:]. The code below relies on Unify-var which is on the next slide.

Unify(x, y, S)
x - a variable, constant, term or list 
y - a variable, constant, term, or list 
S - a substitution so far
if(S == fail) return fail
if (x(S) == y(S)) return S
else if ( var? (x))
    return Unify-var(x, y, S)
else if ( var? (y))
    return Unify-var(y, x, S)
else if ( term? (x) and term? (y))
    return (Unify(args (x), args(y), Unify( op(x), op(y), S))
else if (list? (x) and list? (y) )
    return (Unify(tail(x), tail(y), Unify(head(x), head(y), S)))
else
    return fail

As an example of what I mean by op and args, consider x:=((z*z) +35). Here op is the top operation. So op(x) := a + b as + is the outer most function symbol. Here a,b are new variables that don't appear elsewhere. args(x) := (z*z, 35), so contains two terms: the left and right symbol of +.

Unify-var

Here Unify-var is defined as:

Unify-var(var, y, S)
var - a variable
y - an expression 
S - a substitution
if(var |-> val) exists in S 
    return Unify(val, y, S)
else if (y |-> val) exists in S 
     return Unify(var, val, S)
else if (occur-ck? (var, y)) return fail;
else
    return ( append((var |-> y), S))

Suppose x is f(var), then var occurs in f(var) in the above and occur-ck of (var, x) is true! (note: prolog doesn't do occur-ck's)