Automatic Reasoning (Section 8.3)

Similar documents
Mathematical Logics. 17 Resolution and Unification. Luciano Serafini. Fondazione Bruno Kessler, Trento, Italy

CSL105: Discrete Mathematical Structures. Ragesh Jaiswal, CSE, IIT Delhi

Foundations of AI. 9. Predicate Logic. Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution

Module 6. Knowledge Representation and Logic (First Order Logic) Version 2 CSE IIT, Kharagpur

Module 6. Knowledge Representation and Logic (First Order Logic) Version 2 CSE IIT, Kharagpur

Lecture 17 of 41. Clausal (Conjunctive Normal) Form and Resolution Techniques

CSE & CSE6002E - Soft Computing Fall Semester, 2013

Computational Logic. SLD resolution. Damiano Zanardini

Resolution (14A) Young W. Lim 6/14/14

Integrity Constraints (Chapter 7.3) Overview. Bottom-Up. Top-Down. Integrity Constraint. Disjunctive & Negative Knowledge. Proof by Refutation

Quantification. Using the suggested notation, symbolize the statements expressed by the following sentences.

Mathematical Logic Prof. Arindama Singh Department of Mathematics Indian Institute of Technology, Madras. Lecture - 37 Resolution Rules

6.034 Notes: Section 10.1

Inf2D 12: Resolution-Based Inference

Overview. CS389L: Automated Logical Reasoning. Lecture 6: First Order Logic Syntax and Semantics. Constants in First-Order Logic.

PHIL 240, Introduction to Logic, Sections Fall 2011 FINAL EXAM 14 December Name (5 points): Section (5 points):

Lecture 4: January 12, 2015

6. Inference and resolution

Knowledge & Reasoning

Full Clausal Logic - Syntax: clauses

CPSC 121: Models of Computation. Module 6: Rewriting predicate logic statements

First Order Logic and Resolution

University of Innsbruck

Automated Reasoning PROLOG and Automated Reasoning 13.4 Further Issues in Automated Reasoning 13.5 Epilogue and References 13.

The Resolution Principle

Artificial Intelligence. Chapters Reviews. Readings: Chapters 3-8 of Russell & Norvig.

Knowledge Representation. CS 486/686: Introduction to Artificial Intelligence

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,,

Linear Clause Generation by Tableaux and DAGs

An algorithm for generating arguments in classical predicate logic

. Tutorial Class V 3-10/10/2012 First Order Partial Derivatives;...

CPSC 121 Midterm 2 Friday November 13th, 2015

Resolution in FOPC. Deepak Kumar November Knowledge Engineering in FOPC

Proofs are Programs. Prof. Clarkson Fall Today s music: Proof by Paul Simon

CS 4700: Artificial Intelligence

Charanpal Dhanjal. January Supervised by Simon Colton and Stephen Muggleton

Inference in First-Order Logic

CS221 / Autumn 2017 / Liang & Ermon. Lecture 17: Logic II

Constraint Propagation for Efficient Inference in Markov Logic

THE PREDICATE CALCULUS

Logic Programming and Resolution Lecture notes for INF3170/4171

Knowledge Representation and Reasoning Logics for Artificial Intelligence

Proofs are Programs. Prof. Clarkson Fall Today s music: Two Sides to Every Story by Dyan Cannon and Willie Nelson

An Improvement on Sub-Herbrand Universe Computation

Range Restriction for General Formulas

Typed Lambda Calculus

(a) (4 pts) Prove that if a and b are rational, then ab is rational. Since a and b are rational they can be written as the ratio of integers a 1

Mixed Integer Linear Programming

Notes. Notes. Introduction. Notes. Propositional Functions. Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry.

Logical reasoning systems

Knowledge Representation and Reasoning Logics for Artificial Intelligence

2SAT Andreas Klappenecker

CMPSCI 250: Introduction to Computation. Lecture #7: Quantifiers and Languages 6 February 2012

Knowledge Compilation : A Unit Resolution Approach

Warm-Up Problem. Let L be the language consisting of as constant symbols, as a function symbol and as a predicate symbol. Give an interpretation where

Encoding First Order Proofs in SAT

COMP4418 Knowledge Representation and Reasoning

Inference in First-Order Logic

Constraint Handling Rules - Syntax and Semantics of CHR. Prof. Dr. Thom Frühwirth 2009 University of Ulm, Germany

Typed Lambda Calculus for Syntacticians

Resolution in FO logic (Ch. 9)

Inst-Gen A Modular Approach to Instantiation-Based Automated Reasoning

INTRODUCTION TO PROLOG

Seminar decision procedures: Certification of SAT and unsat proofs

Today s Lecture 4/13/ WFFs/ Free and Bound Variables 9.3 Proofs for Pred. Logic (4 new implicational rules)!

CS 321 Programming Languages and Compilers. Prolog

Lecture 1: Conjunctive Queries

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

A Satisfiability Procedure for Quantified Boolean Formulae

u.n.v,.,.. Libraries Carnegie Mellon University Pittsburgh PA A SIMPLIFIED FORMAT FOR THE MODEL ELIMINATION THEOREM-PROVING PROCEDURE

Optimization of logical query plans Eliminating redundant joins

Chapter 1.3 Quantifiers, Predicates, and Validity. Reading: 1.3 Next Class: 1.4. Motivation

Constraint Solving. Systems and Internet Infrastructure Security

Homework 1. Due Date: Wednesday 11/26/07 - at the beginning of the lecture

What is a Logic Program. Introduction to Logic Programming. Introductory Examples. Introductory Examples. Foundations, First-Order Language

Section 13.2 The Church-Turing Thesis The Church-Turing Thesis: Anything that is intuitively computable can be be computed by a Turing machine.

ECE Spring 2018 Problem Set #2 Due: 3/14/18

Programming Systems in Artificial Intelligence Introduction

Introduction to Logic Programming

Going beyond propositional logic

PROPOSITIONAL LOGIC (2)

8 NP-complete problem Hard problems: demo

CSE20: Discrete Mathematics

Mapping CSP into Many-Valued SAT

Towards a Logical Reconstruction of Relational Database Theory

Answers. The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 3 MODULE, AUTUMN SEMESTER KNOWLEDGE REPRESENTATION AND REASONING

Introduction to dependent types in Coq

Automated Reasoning. Natural Deduction in First-Order Logic

NP-Complete Reductions 2

Answer Key #1 Phil 414 JL Shaheen Fall 2010

What's the difference between the entailment symbol with the equals vs the entailment symbol with one line? Single turnstile meaning

Techniques and Examples for Propositional Clauses AUTOMATED REASONING SLIDES 1:

Inconsistency-tolerant logics

Logic: TD as search, Datalog (variables)

First-Order Predicate Logic. CSCI 5582, Fall 2007

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

CITS2211 Discrete Structures Logic

Advanced Logic and Functional Programming

Chapter 16. Logic Programming. Topics. Unification. Resolution. Prolog s Search Strategy. Prolog s Search Strategy

Joint probability distributions

Transcription:

Automatic Reasoning (Section 8.3)

Automatic Reasoning Can reasoning be automated? Yes, for some logics, including first-order logic. We could try to automate natural deduction, but there are many proof rules that can be applied in many ways. We ll introduce a single proof rule, called resolution that can be applied automatically by a computer. Using resolution requires that we try to prove that a wff is unsatisfiable. But we know that a wff is valid iff its negation is unsatisfiable, so we will work with negations of the wff.

Resolution for Propositional Logic Just to get started, we will look at resolution for Propositional Logic. p A, p B (A p) (B p) The Resolution Rule for Propositional Logic is: where A p denotes A with all occurrences of p removed and B p denotes B with all occurrences of p removed. Special case: Special case: Ponens. p, p [ ] (where [ ] denotes false). p q,p q also known as p q,p q which is Modus

Steps in a resolution proof To prove a wff is valid: 1. negate the wff 2. convert it to CNF 3. write down the fundamental disjunctions as premises 4. use resolution to find a false statement

Example Prove (p q) (q r) (p r) is a tautology. Solution: Negate the wff and transform it into CNF: ( p q) ( q r) p r. Proof: 1. p q P 2. q r P 3. p P 4. r P 5. q 1,3,R 6. r 2,5,R 7. [ ] 4,6,R QED

Another Example Prove (A B) (A C D) (B E F ) (C D) (E F ) is a tautology. Negate and transform into CNF to get: (A B) ( A C) ( A D) ( B E) ( B F ) ( C D) ( E F ). Proof on next page.

Proof: Proof 1. A B P 2. A C P 3. A D P 4. B E P 5. B F P 6. C D P 7. E F P

Proof: Proof 1. A B P 2. A C P 3. A D P 4. B E P 5. B F P 6. C D P 7. E F P 8. A C 3,6,R 9. B F 4,7,R 10. B B 5,9,R 11. A A 2,8,R 12. B 1,11,R 13. [ ] 10,12,R QED

Resolution for FOL Example (to show the idea): following two lines: Suppose some proof contains the 1. p(a, x) q(x, y, a) P 2. p(x, b) r(x, y, b) P First we need to change variable names so all clauses have distinct variables. So, line 2 becomes: 3. p(v, b) r(v, w, b) P

Resolution for FOL (continued) Unify (i.e., match) p(a, x) on line 1 and p(v, b) on line 3 to get a substitution (i.e., a set of bindings) θ = {v/a, x/b} Apply θ to clauses on lines 1 and 3. p(a, b) q(b, y, a) p(a, b) r(a, w, b) Apply resolution to the transformed wffs. 4. q(b, y, a) r(a, w, b) 1,3,R, θ = {v/a, x/b}

First-order resolution So, three major topics need to be examined: 1. the clausal form of wffs 2. unification of atoms 3. the inference rule

Clausal Form A clause is a disjunction of literals. A clausal form is the universal closure of a conjunction of clauses. Example: The clausal form: x y (p(x) (q(x, y) r(x)) ( p(x) s(y))) is represented by the set: {p(x), q(x, y) r(x), p(x) s(y)} Not every wff is equivalent to a clausal form. For example, the wff x p(x) is not equivalent to a clausal form. But we have a result from Skolem that is sufficient for resolution. (See next slide.)

Skolem s Algorithm Every wff can be associated with a clausal form in which the two are either both satisfiable or both unsatisfiable. 1. Construct the prenex CNF for the wff. 2. Replace all occurrences of each free variable by a new constant. 3. Eliminate the existential quantifiers by Skolem s Rule: If x W (x) is not inside the scope of a universal quantifier, then replace x W (x) by W (c) for a new constant c. If x W (x) is inside the scope of x 1... x n, then replace x W (x) by W (f (x 1,..., x n )) for a new function symbol f.

Skolem examples Find a clausal form for each wff: 1. x A(x)

Skolem examples Find a clausal form for each wff: 1. x A(x) 1. A(c) 2. x y B(x, y) 2.

Skolem examples Find a clausal form for each wff: 1. x A(x) 1. A(c) 2. x y B(x, y) 2. x B(x, f (x)) 3. x y z C(x, y, z) 3.

Skolem examples Find a clausal form for each wff: 1. x A(x) 1. A(c) 2. x y B(x, y) 2. x B(x, f (x)) 3. x y z C(x, y, z) 3. x y C(x, y, g(x, y)) 4. x y z D(x, y, z) 4.

Skolem examples Find a clausal form for each wff: 1. x A(x) 1. A(c) 2. x y B(x, y) 2. x B(x, f (x)) 3. x y z C(x, y, z) 3. x y C(x, y, g(x, y)) 4. x y z D(x, y, z) 4. x D(x, f (x), g(x))

Clausal form example Find a clausal form for the wff: y x p(x, y) z (q(x) r(z)) y x p(x, y) z (q(w) r(z)) (renamed) y x p(x, y) z (q(w) r(z)) (removed ) y x p(x, y) z (q(w) r(z)) (moved inside) y( x p(x, y) z (q(w) r(z))) (moved y out) y x z ( p(x, y) (q(w) r(z))) (moved x, z out y x z (( p(x, y) q(w)) ( p(x, y) r(z))) (constructed CNF) (replace free variable w by constant c) y x z (( p(x, y) q(c)) ( p(x, y) r(z))) Apply Skolem s Rule to eliminate x and z. y(( p(f (y), y) q(c)) ( p(f (y), y) r(g(y)))) Giving us two clauses: { p(f (y), y) q(c), p(f (y), y) r(g(y))}

Substitutions and Unification A binding of a variable x to a term t is denoted x/t and it means replace x by t. Applying a binding to an expression: If x/t is a binding and E is an expression, then E(x/t) denotes the expression obtained from E by replacing all free occurrences of x with t. Examples: p(x, y, z)(x/y) = p(y, y, z) p(x, y, z)(y/f (z)) = p(x, f (z), z) A substitution is a finite set of bindings with distinct numerators. (We use lowercase greek letters for substitutions.) Examples: θ = {x/y, y/f (z)} σ = {y/f (a), z/b}

Apply a Substitution If θ is a substitution and E is an expression, then Eθ denotes the expression obtained from E by simultaneously applying the bindings in θ to E. Example: If θ = {x/y, y/f (z)}, then p(x, y, z)θ = p(x, y, z){x/y, y/f (z)} = p(y, f (z), z) If S is a set of expressions, then Sθ is the set of expressions obtained from S by applying θ to each expression of S Example: If θ = {x/y, y/f (z)} and S = {p(x, y), q(y, g(z))}, then Sθ = {p(x, y)θ, q(y, g(z))θ} = {p(y, f (z)), q(f (z), g(z))}

Composing Substitutions If θ and σ are two substitutions, then the composition of them θσ is applied to an expression E by E(θσ) = (Eθ)σ. We can calculate θσ by applying it to an atom that contains all the numerator variables of the two substitutions. Then collect the bindings that result from the application. Example: Let θ = {x/y, y/f (z)} and σ = {y/f (a), z/b}. Since the numerator variables are x, y, z we calculate: p(x, y, z)(θσ) = (p(x, y, z)θ)σ = p(y, f (z), z)σ = p(f (a), f (b), b) So θσ = {x/f (a), y/f (b), z/b}.

Unifiers A unifier of a set S of expressions is a substitution θ such that Sθ is a singleton set. Example: {x/a} is a unifier of {p(x), p(a)} because {p(x), p(a)}{x/a} is {p(a)}. Example Quiz: What are some unifiers of S = {p(x, a), p(y, z)}?

Unifiers A unifier of a set S of expressions is a substitution θ such that Sθ is a singleton set. Example: {x/a} is a unifier of {p(x), p(a)} because {p(x), p(a)}{x/a} is {p(a)}. Example Quiz: What are some unifiers of S = {p(x, a), p(y, z)}? Answer: Since a is a constant, any unifier must include the binding z/a. A unifier might also include x/y or y/x. So two unifiers of S are {x/y, z/a} and {y/x, z/a} because: S{x/y, z/a} = {p(y, a)} and S{y/x, z/a} = {p(x, a)}. Notice also that {x/t, y/t, z/a} is a unifier of S for any term t because: S{x/t, y/t, z/a} = {p(t, a)}.

Robinson s Unification Algorithm For a finite set S of atoms, find whether S has an mgu. 1. k := 0; θ 0 := ɛ; go to Step 2. 2. If Sθ k is a singleton then stop with mgu θ k. Otherwise construct D k (set of terms in leftmost position of disagreement); go to Step 3. 3. If D k has a variable v and a term t such that v does not occur in t then θ k+1 := θ k {v/t}; k := k + 1; go to Step 2. Otherwse stop (S is not unifiable).

Unification Example Trace the algorithm for S = {p(x, h(x, g(y)), y), p(x, h(a, z), b}. 1. k := 0; θ 0 := ɛ. 2. Sθ 0 = Sɛ = {p(x, h(x, g(y)), y), p(x, h(a, z), b} is not a singleton; D 0 = {x, a}. 3. θ 1 := θ 0 {x/a} = {x/a}; k := 1 4. (2) Sθ 1 = {p(a, h(a, g(y)), y), p(a, h(a, z), b)} is not a singleton; D 1 = {g(y), z}. 5. (3) θ 2 := θ 1 {z/g(y)} = {x/a, z/g(y)}; k := 2. 6. (2) Sθ 2 = {p(a, h(a, g(y)), y), p(a, h(a, g(y)), b)} is not a singleton; D 2 = {y, b}. 7. (3) θ 3 := θ 2 {y/b} = {x/a, z/g(b), y/b}; k := 3. 8. (2) Sθ 3 = {p(a, h(a, g(b)), b)} is a singleton; stop with mgu θ 3 = {x/a, z/g(b), y/b}.

A Failed Example Apply the algorithm to S = {p(x), p(f (x))}.

A Failed Example Apply the algorithm to S = {p(x), p(f (x))}. S is not unifiable because in the set D 0 = {x, f (x))} x occurs in f (x).

Resolution Rule Given the following two clauses: L 1... L k C and M 1... M n D where L i and M i are atoms and C and D are disjunctions of other literals. Assume also that: 1. The clauses have distinct sets of variable names (rename if necessary). 2. θ is the mgu of {L 1,..., L k, M 1,..., M n }. 3. N = L 1 θ, where {L 1,..., L k, M 1,..., M n }θ = {N}. Then we have: L 1... L k C, M 1... M n D (Cθ N) (Dθ N)

Example Given the two clauses in the following proof segment: k. p(a, y) p(a, z) q(x, y, z) P k+1. p(w, f (b)) r(w, v, g(w)) P These two clauses have the form L 1 L 2 C and M 1 D. The two clauses have distinct sets of variables. The set of atoms {p(a, y), p(a, z), p(w, f (b))} has mgu θ = {w/a, y/f (b), z/f (b)}. Notice that {p(a, y), p(a, z), p(w, f (b))}θ = {p(a, f (b))} So, the resolution rule can be applied to the two clauses to obtain the resolvant: k+2. q(x, f (b), f (b)) r(a, v, g(a)) k, k + 1, R, {w/a, y/f (b), z/f (b)}

Whole Process To prove a wff is valid: negate the wff and convert it to clausal form; write down the clauses as premises; use resolution to find a false statement. Example:: Use resolution to prove the following wff is valid: x ( y p(x, y) z q(x, z) y (p(x, y) q(x, y))) Solution: Negate the wff, giving you: x ( y p(x, y) z q(x, z) y (p(x, y) q(x, y))). Then convert it to clausal form:

Convert to clausal form Convert: x ( y p(x, y) z q(x, z) y (p(x, y) q(x, y))) x ( y p(x, y) z q(x, z) w (p(x, w) q(x, w))) (renamed variables) x (( y p(x, y) z q(x, z)) w ( p(x, w) q(x, w))) (removed and moved right) x w (( y p(x, y) z q(x, z)) p(x, w) q(x, w)) (moved w left) x w y z ((p(x, y) q(x, z)) p(x, w) q(x, w)) (moved y and z left) x y z ((p(x, y) q(x, z)) p(x, f (x)) q(x, f (x))) (removed w by Skolem) So, the set of clauses is: {p(x, y) q(x, z), p(x, f (x)), q(x, f (x))}

Resolution steps Now do a resolution proof by making each of the three clauses a premise (rename to get distinct variable names). 1. p(x, y) q(x, z) P 2. p(u, f (u)) P 3. q(w, f (w)) P 4. q(u, z) 1,2,R,{x/u,y/f(u)} 5. [ ] 3,4,R,{w/u,z/f(u)} QED