Prolog - DPLL - First-order Logic




CS156

Chris Pollett

Oct 31, 2022

Outline

Introduction

Horn Clauses and Definite Clauses

Prolog

A Prolog Example Logic Program

Consider the Horn program:

a. /* lines end with a period, a rule without a tail is called a fact */
b:- a.
c:-b.
d:- a, b.

How Prolog computes its answers

Quiz

Which of the following is true?

  1. Natural Deduction is non-classical proof system which allows that the law of excluded middle might fail.
  2. The resolution inference is not a sound rule of inference.
  3. Every propositional formula can be converted into an equivalent formula in CNF.

DPLL Algorithm: A general resolution finding algorithm

DPLL Algorithm

function DPLL-Satisfiable?(s) returns true or false
   inputs: s a sentence in propositional logic

   clauses := the set of clauses in the CNF representation of s
   symbols := a list of the propositional symbols in s
   return DPLL(clauses, symbols, {})

function DPLL(clauses, symbols, model) returns true or false
   if every clause in clauses is true in model then return true
   if some clause in clauses is false in model then return false
   P, value := FIND-PURE-SYMBOL(symbols, clauses, model)
   if P is non-null then return DPLL(clauses, symbols - P, model ∪ {P=value})
   P, value := FIND-UNIT-CLAUSE(clauses, model)
   if P is non-null then return DPLL(clauses, symbols - P, model ∪ {P=value})
   P := FIRST(symbols); //symbols is a list, this get the first element in the list into P
   rest = REST(symbols); //all the elements in the list excluding the first element
   return DPLL(clauses, rest, model ∪ {P=true}) or
       DPLL(clauses, rest, model ∪ {P=false})

First-Order Logic