Lecture Slides for MAT-60556 PART III: First order logic: Formulas, - - PowerPoint PPT Presentation

lecture slides for mat 60556 part iii first order logic
SMART_READER_LITE
LIVE PREVIEW

Lecture Slides for MAT-60556 PART III: First order logic: Formulas, - - PowerPoint PPT Presentation

Lecture Slides for MAT-60556 PART III: First order logic: Formulas, Models, Tableaux Henri Hansen September 20, 2013 1 Relations and predicates Theories with axioms and theorems in mathematics are defined on sets such as the set of


slide-1
SLIDE 1

Lecture Slides for MAT-60556 PART III: First order logic: Formulas, Models, Tableaux

Henri Hansen September 20, 2013

1

slide-2
SLIDE 2

Relations and predicates

  • Theories with axioms and theorems in mathematics

are defined on sets such as the set of integers Z

  • We need to be able to write and manipulate for-

mulas that contain relations on the elements from arbitrary sets

  • R ⊆ Dn is called an n-ary relation over the domain
  • D. We also call relations predicates.
  • R can be represented by a boolean function PR :

Dn → {T, F}

2

slide-3
SLIDE 3

First Order Logic Symbols

  • Let P, A, and V be countable sets of predicate, con-

stant, and variable symbols. Each predicate pn ∈ P is associated with arity.

  • “∀” is the universal quantifier, and “∃” is the exis-

tential quantifier

  • Variables and constants are called terms. Terms are

elements of some (possibly unknown) set

  • The arguments of a predicate are terms.

3

slide-4
SLIDE 4

FOL Syntax

  • An atomic formula is an n-ary predicate followed

by a list of arguments. A formula is a tree defined recursively as follows:

  • 1. A formula is a leaf that is labeled by an atomic

formula

  • 2. A formula is a node labeled with a logical oper-

ator (as in propositional logic), and its children are formulas

  • 3. A formula is labeled by ∀x or ∃x for some variable

x, and it has a single child that is a formula

4

slide-5
SLIDE 5

Scope of variables

  • A formula such as ∀xA is a quantified formula. x is

the quantified variable, and its scope is the formula

  • A. x is not required to actually appear in A
  • Let A be a formula. An occurrence of x in A is a

free variable of A iff x is not within the scope of a quantified variable x. A variable that is not free, is bound

  • A formula with no free variables is closed and a

formula with free variables is open

5

slide-6
SLIDE 6

Interpretation and Assignment

  • Let A be a formula where {p1, . . . , pm} are the pred-

icates, and {a1, . . . , ak} are the constants that ap-

  • pear. An interpretation for A, IA is a triple

(D, {R1, . . . , Rm}, {d1, . . . , dk}) where D is a non-empty set called domain, Ri ⊆ Dni is a relation assigned to the predicate pi and di ∈ D is the element assigned to the constant ai.

  • An assignment σIA : V → D is a function that maps

each free variable to an element of D

6

slide-7
SLIDE 7

Validity and satisfiability

  • The truth value of a closed formula depends only
  • n the interpretation (not assignment)
  • Given a closed formula A in first-order logic
  • 1. A is true in the intrepretation I iff νI(A) = T,

denoted I | = A

  • 2. A is valid if it is true for all interpretations, de-

noted | = A

  • 3. A is satisfiable if there is some interpretation I

such that I | = A

7

slide-8
SLIDE 8

Logical equivalence

  • Given two formulas A1 and A2 we write A1 ≡ A2 if

they are true for the same interpretations

  • Given U = {A1, . . . , an} of closed formulas,
  • 1. A ≡ B iff |

= A ↔ B

  • 2. U |

= A iff | = (A1 ∧ · · · ∧ An) → A

  • 3. ∀xA(x) ≡ ¬∃x¬A(x)
  • 4. ∃xA(x) ≡ ¬∀x¬A(x)

8

slide-9
SLIDE 9

Semantic Tableaux

  • let A be a quantified formula, either ∀xA1(x) or

∃xA1(x) and let a be a constant. An instantiation

  • f A is the formula A1(a), where all the free occur-

rences of x have been replaced by a

  • A literal is a closed atomic formula p(a1, . . . , ak),

where all arguments are constants, or the negation

  • f such a formula.
  • A semantic tableau is a tree T where each node is

labeled by a pair (U(n), C(n)) where U is a set of formulas and C is a set of constants that appear in the formulas of U(n)

9

slide-10
SLIDE 10

Semantic Tableaux (contd.)

  • A branch of a semantic tableau can be infinite, finite

and marked open, or finite and marked closed

  • The root of the tableau for the formula φ is marked

({φ}, {a01, . . . , a0k}), where the constants are the constans appearing in φ

  • If U(l) contains a complementary pair of literals,

then it should be marked closed, or ×

10

slide-11
SLIDE 11

Rules for Tableaux

  • The same α- and β- rules as used with tableaux for

propositional formulas applies for first order logic

  • In addition, we have γ and δ rules
  • γ- formula is either ∀xA(x) or ¬∃xA(x), and the

result is A(a) or ¬A(a) resp. where a is an arbitrary constant

  • δ- formula is either ∃xA(x) or ¬∀xA(x), and the

result is A(a) or ¬A(a)

11

slide-12
SLIDE 12

Semantic Tableau algorithm for the formula φ.

  • Start with {{φ}, {a0, . . . , an}} at the root.
  • Choose an unmarked leaf {U, C} and apply the first

applicable rule from the following list and start over.

  • 1. If the set U contains a complementary pair of

literals, close the branch.

  • 2. Choose a formula A ∈ U that is either an α−, β−
  • r δ-formula; apply the rule
  • 3. Apply the γ-rule. If the resulting formula is the

same as before applying it, mark the branch open.

12

slide-13
SLIDE 13

Handling of formulas

  • If A is an α-formula, create a new node as the child
  • f l, and label it with ((U(l) − {A}) ∪ {α1, α2}, C(l))
  • If A is a β- formula, create two new nodes as chil-

dren of l and label them with

  • 1. ((U(l) − {A}) ∪ {β1}, C(l))
  • 2. ((U(l) − {A}) ∪ {β2}, C(l))
  • If A is a δ- formula, create a new node as the child of

l, and label it with ((U(l)−{A})∪{δ(a′)}, C(l)∪{a′}), where a′ does not appear in U(l)

13

slide-14
SLIDE 14

Handling of formulas (contd.)

  • Given the set {γ1, . . . , γm} ⊆ U, of the γ-formulas of

U, create a new node as a child of l, and label it with formulas (U ∪ {

m

i=1

c∈C

γi(c)}, C)

  • In other words: a γ-formula γi is added by γi(c) for

all the constants c in the formula.

14

slide-15
SLIDE 15

Soundness of Tableaux

  • Let φ be a formula of first order logic, and T be a

tableau for φ. If T closes, then φ is unsatisfiable – Proof is by induction on the height of a node; α and β-rules are like in the propositional case. – γ-rules add A(a) to a child, when ∀xA(x) ap- pears, and if A(a) is unsat, then ∀xA(x) is unsat – δ-rules replace ∃xA(x) with A(a) for a new a. Assume the former is satisfiable. Then it has a model. As it has a model, then there is some constant a for which A(a) is satisfiable, and thus A(a) has a model too.

15

slide-16
SLIDE 16

Hintikka sets

  • U is a Hintikka set if for all formulas A ∈ U
  • 1. If A is a literal, then either A /

∈ U or Ac / ∈ U

  • 2. If A is an α-formula, then α1 ∈ U and α2 ∈ U
  • 3. If A is a β-formula, then β1 ∈ U or β2 ∈ U
  • 4. If A is a γ-formula, then γ(c) ∈ U for all constants

in the formulas of U

  • 5. If A is a δ-formula, then δ(c) ∈ U for some con-

stant c

16

slide-17
SLIDE 17

Completeness:

  • Theorem:

If U is a Hintikka set, then there is a model for U

  • Theorem:

If A is a valid formula, the semantic tableau for ¬A closes – If the tableaux for ¬A does not close, this means that we can construct a Hintikka set from an

  • pen branch, which implies there is a model for

¬A, and thus, A is not valid

  • In summary:

Tableaux can establish the validity

  • f A by finding whether ¬A has a model, but the

tableau itself does not directly yield a model

17

slide-18
SLIDE 18

Deductive systems

  • As with propositional logic, deductive systems can

be used to prove formulas of first-order logic. They do so by taking axioms and rules of inference as before, but new rules and axioms are needed for quantifiers

  • We leave familiarization with deductive systems (Gentzen

and Hilbert) as an exercise

18

slide-19
SLIDE 19

Normal forms in FOL

  • Consider the formula ∀x∀y∀z(p(x, y)∧p(y, z)) → p(x, z),

under the interpretation {Z, {<}, {}}

  • The formula states that the less-than- relation is

transitive in the domain of the integers

  • Suppose we wish to express something like ∀x∀y∀z(x <

y) → x + z < y + z

  • The diffeerence is that in addition to the predicate

“<”, it uses the function “+”. We first extend first-order logic with functions in order to discuss such statements

19

slide-20
SLIDE 20

FOL with functions

  • Let F be a (countable) set of function symbols,

where each symbol has an arity denoted by a su- perscript.

  • A term is defined recursively as follows

– A variable, constant, or 0-ary function is a term – if fn is an n-ary function symbol and {t1, . . . , tn} is a set of terms, then f(t1, . . . , tn) is a term

  • In the extended logic, an atomic formula is a n-ary

predicate followed by a list of terms, i.e., p(t1, . . . , tn)

20

slide-21
SLIDE 21

FOL interpretation with functions

  • Let U be a set of formulas, and p1, . . . , pk the pred-

icate symbols, f1, . . . , fl the function symbols and a1, . . . , am the constant symbols of U. An interpre- tation for U is a 4-tuple {D, {R1, . . . , Rk}, {F n1

1 , . . . , F nl l }, {d1, . . . , dm}}

consisting of the domain D, relations Ri on D as- sociated with each predicate symbol pi, functions Fi on D associated with fi and elements di of D associated with ai

  • The semantics of the interpretation are the same

as for FOL without functions

21

slide-22
SLIDE 22

Tableaux for FOL with functions

  • The algorithm for building tableaux for FOL with

functions is almost the same as without. There are two differences: all terms, not just constants, can be substituted for a variable, and the definition of literal needs to be generalized – A ground term is a term that contains no vari- ables – A ground atomic formula is an atomic formula where all terms are ground terms – A ground literal is a ground atomic formula or its negation

22

slide-23
SLIDE 23

– A ground formula is a quantifier free formula where all the atomic formulas are ground – A ground instance is a formula that is obtained from a ground formula by substituting ground terms with free variables

  • The construction of tableaux is modified so that δ-

rule requires substituting a ground term instead of substituting a constant

  • Theorem:

The set of ground terms is countable (proof: the set of finite n-tuples of a countable set is countable, c.f., rational numbers)

slide-24
SLIDE 24

PCNF and clausal form

  • A formula is in prenex conjunctive normal form (PCNF)

iff it is of the form Q1x1 · · · QnxnM where Qi are quantifiers and M is a quantifier-free formula in CNF. Q1x1 · · · Qnxn is called the prefix and M is called the matrix of the formula

  • Let A be a PCNF formula where the prefix consists
  • nly of universal quantifiers. The clausal form of A

is a matrix of A written as a set of clauses

23

slide-25
SLIDE 25

Skolem’s theorem

  • Theorem: Let A be a closed formula. Then there

exists a clausal form A′ such that A ≃ A′

  • Note that it simply says that the clausal form A′

is satisfiable if and only if A is, not that they are logically equivalent

  • Skolem’s algorithm transforms A first into PCNF,

then removes existential quantifiers through a pro- cess called Skolemization

24

slide-26
SLIDE 26

Skolemization

  • Skolemization replaces existential quantifiers in a

PCNF formula by skolem functions, i.e., ∃x is re- moved, and all instances of x are replaced with a function f, whose arguments are the universally quantified variables to the left of ∃x

  • Example: ∀z∃x∃y((p(x) ∨ ¬p(y)) ∧ ¬(q(x) ∨ ¬p(y)))

– Skolemization of x gives ∀z∃y((p(f(z))∨¬p(y))∧ (q(f(z)) ∨ ¬p(y))) – Skolemization of y after this: ∀z((p(f(z))∨¬p(g(z)))∧ (q(f(z)) ∨ ¬p(g(z))))

25

slide-27
SLIDE 27

Proof of Skolem’s theorem

  • To prove Skolem’s theorem, we need to show that

skolemization preserves satisfiability.

  • Assume that we have I |

= ∀y1 · · · ∀yn∃xp(y1, . . . , yn, x)

  • In I we have Rp associated with the proposition p,

and we must have some constants (c1, . . . , cn, cn+1) ∈ Rp, and because I is a model for the formula, at least one such a cn+1 must exist for arbitrary c1, . . . , cn. We construct a function F so that F(c1, . . . , cn) =

26

slide-28
SLIDE 28

cn+1, and then we introduce the new skolem func- tion f such that F is the function associated with f in I′

  • Proof in the other direction is simple
slide-29
SLIDE 29

Herbrand models

  • Description of the set of possible interpretations of

function symbols in terms is not easy

  • The so-called Herbrand models are a canonical in-

terpretation for sets of clauses

  • If a set of clauses has a model, it has a Herbrand

model

  • Herbrand models will be important for resolution

27

slide-30
SLIDE 30

Herbrand Universe

  • Let S be a set of clauses and A be the set of con-

stants in S, and F the set of function symbols in S The Herbrand universe of S, HS, is defined recur- sively as follows – a ∈ HS for every a ∈ A – f0

i ∈ HS for f0 i ∈ F

– fn

i (t1, . . . , fn) ∈ Hs, when fn i ∈ F and tj ∈ HS

  • If there are no constant symbols or 0-ary functions

in S, then initialize HS with an arbitrary constant a.

28

slide-31
SLIDE 31
  • The herbrand universe is the set of ground terms

that can be formed from the symbols in S

slide-32
SLIDE 32

Herbrand Interpretations

  • Herbrand Universe gives a domain for the formula,

but we need also everything else in an interpretation

  • Let S be a formula in clausal form, and PS =

{p1, . . . , pn} are the predicate symbols, FS = {f1, . . . , fk} are the function symbols and A = {a1, . . . , am} are the constants. Then a Herbrand intepretation of S is I = {HS, {R1, . . . , Rn}, {f1, . . . , fk}, A}

  • Ri are arbitrary relations with aproppriate arities.

When fi is a function symbol of arity l, and when

29

slide-33
SLIDE 33

t1, . . . , tl ∈ HS, then fi(t1, . . . , tl) is valuated recur- sively: ν(a) = a and ν(f(t1, . . . , tl)) = f(ν(t1), . . . , ν(tl))

  • if I |

= S, then I is a Herbrand model for S.

  • Theorem: A set of clauses S has a model if and
  • nly if it has a Herbrand model.
  • Note: The theorem is not general for all formulas:

p(a) ∧ ∃x¬p(x) has no Herbrand model!

slide-34
SLIDE 34

Herbrand’s Theorem

  • Form 1: A set of clauses S is unsatisfiable if and
  • nly if a finite set of ground instances of clauses of

S is unsatisfiable

  • Form 2: A formula A is unsatisfiable if and only if a

formula built from a finite set of ground instances

  • f subformulas of A is unsatisfiable
  • Syntactic Form: A formula Aof FOL is provable if

and only if a formula built from a finite set of ground instances of subformulas of A is provable using only the axioms and inference rules of propositional logic

30

slide-35
SLIDE 35

Semi-Decision procedure based on Herbrand’s Theorem

  • The theorem gives as a consequence the following

procedure to check the validity of FOL formulas

  • 1. Negate the formula
  • 2. Transform into clausal form
  • 3. Generate a finite set of ground clauses
  • 4. Check if the set of ground clauses is unsatisfiable
  • The first two steps are trivial and the last one can

be treated as in propositional logic

31