Computational Logic. Davide Martinenghi. Spring Free University of Bozen-Bolzano. Computational Logic Davide Martinenghi (1/26)

Similar documents
3 Propositional Logic

When describing some state of affairs in the real world we often use declarative 1 sentences

Computational Logic Automated Deduction Fundamentals

The non-logical symbols determine a specific F OL language and consists of the following sets. Σ = {Σ n } n<ω

Propositional Logic Language

First-Order Logic (FOL)

Outline. Formale Methoden der Informatik First-Order Logic for Forgetters. Why PL1? Why PL1? Cont d. Motivation

First-Order Predicate Logic. Basics

Syntax. Notation Throughout, and when not otherwise said, we assume a vocabulary V = C F P.

AAA615: Formal Methods. Lecture 2 First-Order Logic

Computational Logic. Recall of First-Order Logic. Damiano Zanardini

CS156: The Calculus of Computation Zohar Manna Winter 2010

Predicate Logic: Sematics Part 1

A Little Logic. Propositional Logic. Satisfiability Problems. Solving Sudokus. First Order Logic. Logic Programming

Propositional and Predicate Logic. jean/gbooks/logic.html

Logic: Propositional Logic (Part I)

First Order Logic (FOL) 1 znj/dm2017

Introduction to Logic in Computer Science: Autumn 2006

Predicate Logic. CSE 595 Semantic Web Instructor: Dr. Paul Fodor Stony Brook University

Logic: First Order Logic (Part I)

THE LANGUAGE OF FIRST-ORDER LOGIC (FOL) Sec2 Sec1(1-16)

Definite Logic Programs: Derivation and Proof Trees. CSE 505 Computing with Logic Stony Brook University

First-Order Logic First-Order Theories. Roopsha Samanta. Partly based on slides by Aaron Bradley and Isil Dillig

Propositional Logic: Models and Proofs

Part 2: First-Order Logic

Automated Reasoning Lecture 5: First-Order Logic

Description Logics. Foundations of Propositional Logic. franconi. Enrico Franconi

Introduction to Sets and Logic (MATH 1190)

Propositional logic (revision) & semantic entailment. p. 1/34

06 From Propositional to Predicate Logic

Introduction to Logic in Computer Science: Autumn 2007

Syntax of FOL. Introduction to Logic in Computer Science: Autumn Tableaux for First-order Logic. Syntax of FOL (2)

Overview. CS389L: Automated Logical Reasoning. Lecture 7: Validity Proofs and Properties of FOL. Motivation for semantic argument method

3. Only sequences that were formed by using finitely many applications of rules 1 and 2, are propositional formulas.

First-Order Logic. Chapter Overview Syntax

Learning Goals of CS245 Logic and Computation

Intelligent Agents. First Order Logic. Ute Schmid. Cognitive Systems, Applied Computer Science, Bamberg University. last change: 19.

Introduction to first-order logic:

Classical First-Order Logic

03 Review of First-Order Logic

Logic: The Big Picture


Discrete Mathematics and Its Applications

Logic. Foundations of First Order Logic. franconi. Enrico Franconi

Reasoning. Inference. Knowledge Representation 4/6/2018. User

4 Predicate / First Order Logic

First order logic. Example The deduction of statements: This reasoning is intuitively correct. Every man is mortal. Since Ade is a man, he is mortal.

cis32-ai lecture # 18 mon-3-apr-2006

Herbrand Theorem, Equality, and Compactness

A Logic Primer. Stavros Tripakis University of California, Berkeley

Computational Logic. Davide Martinenghi. Spring Free University of Bozen-Bolzano. Computational Logic Davide Martinenghi (1/30)

Predicate Calculus. Formal Methods in Verification of Computer Systems Jeremy Johnson


Language of Propositional Logic

First Order Logic: Syntax and Semantics

Resolution for Predicate Logic

Propositional Logic Not Enough

Mathematics 114L Spring 2018 D.A. Martin. Mathematical Logic

Notation for Logical Operators:

Classical First-Order Logic

CS1021. Why logic? Logic about inference or argument. Start from assumptions or axioms. Make deductions according to rules of reasoning.

Propositional Logic: Syntax

7. Propositional Logic. Wolfram Burgard and Bernhard Nebel

Logic: First Order Logic

A Logic Primer. Stavros Tripakis University of California, Berkeley. Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 A Logic Primer 1 / 35

Formal (Natural) Deduction for Predicate Calculus

J Propositional logic is declarative J Propositional logic is compositional: q meaning of B 1,1 P 1,2 is derived from meaning of B 1,1 and of P 1,2

GS03/4023: Validation and Verification Predicate Logic Jonathan P. Bowen Anthony Hall

Informal Statement Calculus

Chapter 3. SLD-Resolution. 3.1 Informal Introduction

Section Summary. Section 1.5 9/9/2014

Propositional logic. First order logic. Alexander Clark. Autumn 2014

Advanced Topics in LP and FP

Automated Reasoning in First-Order Logic

Examples: P: it is not the case that P. P Q: P or Q P Q: P implies Q (if P then Q) Typical formula:

Predicate Calculus - Syntax

MAI0203 Lecture 7: Inference and Predicate Calculus

Logic for Computer Scientists

Logic for Computer Scientists

Introduction to Metalogic

Title: Logical Agents AIMA: Chapter 7 (Sections 7.4 and 7.5)

Modal Logics. Most applications of modal logic require a refined version of basic modal logic.

Handout: Proof of the completeness theorem

THE LOGIC OF QUANTIFIED STATEMENTS. Predicates and Quantified Statements I. Predicates and Quantified Statements I CHAPTER 3 SECTION 3.

22c:145 Artificial Intelligence. First-Order Logic. Readings: Chapter 8 of Russell & Norvig.

First-Order Logic. 1 Syntax. Domain of Discourse. FO Vocabulary. Terms

G52DOA - Derivation of Algorithms Predicate Logic

Logic: Propositional Logic Truth Tables

Notes. Corneliu Popeea. May 3, 2013

CS2742 midterm test 2 study sheet. Boolean circuits: Predicate logic:

Reasoning with Quantified Boolean Formulas

Logic: First Order Logic

Algebraizing Hybrid Logic. Evangelos Tzanis University of Amsterdam Institute of Logic, Language and Computation

Applied Logic. Lecture 1 - Propositional logic. Marcin Szczuka. Institute of Informatics, The University of Warsaw

First Order Logic (FOL)

Foundations of Artificial Intelligence

A MODEL-THEORETIC PROOF OF HILBERT S NULLSTELLENSATZ

Foundations of Artificial Intelligence

First-Order Logic. Propositional logic. First Order logic. First Order Logic. Logics in General. Syntax of FOL. Examples of things we can say:

Exercises 1 - Solutions

Transcription:

Computational Logic Davide Martinenghi Free University of Bozen-Bolzano Spring 2010 Computational Logic Davide Martinenghi (1/26)

Propositional Logic - algorithms Complete calculi for deciding logical entailment run into time and space problem as soon as formulas are larger Unfortunately, many real word applications (planning, scheduling) require too many propositional variables Incomplete procedures have been developed, which can take care of large formulas We will introduce a general framework for this kind of algorithms, and then two instantiations: GSAT and GWSAT Computational Logic Davide Martinenghi (2/26)

Propositional Logic - algorithms GenSAT framework Input: a formula F in CNF Output: a model for F, or no model found 1: for j := 1 to maxtries do 2: I := initial(f) 3: for k := 1 to maxloops do 4: if I = F then 5: return I 6: else 7: I := flip(i, pick(hillclimb(f, I))) 8: end if 9: end for 10: end for 11: return no model found maxtries and maxloops are some natural numbers, initial(f) randomly selects an interpretation for F, pick() randomly selects an element from a given set of propositions, flip() changes the truth value of a proposition in an interpretation Computational Logic Davide Martinenghi (3/26)

Propositional Logic - algorithms Hillclimb procedure for GenSAT hillclimb() computes a set of variables which can be potentially flipped Input a propositional formula F and an interpretation I such that I = F Output a set of propositions in F 1: r := rand(0, 1) 2: return {P select(f, I, P, r) = true} select() returns true for some variables depending on a random number r Computational Logic Davide Martinenghi (4/26)

Propositional Logic - algorithms We now introduce GSAT (greedy satisfiability testing) Let F u (I) be the set of unsatisfied clauses of CNF F in interpretation I Let P be a proposition in F, then the rank of P in F and I is rank(f, I, P) := F u (I) F u (flip(i, P)) If rank(f, I, P) > 0 then the number of unsatisfied clauses in F decreases when P is flipped In GSAT the select() function is defined as { true if rank(f, I, P) is maximal in P select(f, I, P, r) = false otherwise i.e., select() retains all propositions that make a maximal change in the number of satisfied clauses This is the reason why it is called greedy This procedure will inevitably end in a local minimum of F u (I) Computational Logic Davide Martinenghi (5/26)

Propositional Logic - algorithms It was observed that the performance of algorithms that avoid local minima is better GWSAT (greedy satisfiability testing with random walks) is an extension of GSAT which randomly selects arbitrary propositions to flip In this way propositions with non-maximal, or even negative, rank can be selected true if r > p and rank(f, I, P) is maximal select(f, I, P, r) = true if r p and P occurs in F u (I) false otherwise where p is a fixed value between 0 and 1 In experiments, GWSAT is shown to perform better than GSAT Computational Logic Davide Martinenghi (6/26)

First-Order Logic (FOL) - syntax Propositional logic (PL) has many applications, but its expressive power is restricted Sentences such as all men are mortal and each child must have parents can be expressed as propositions in a way that does not capture the intended relationship between men, mortals, children, and parents Frege developed what is now known as first-order logic (FOL, aka predicate logic) in 1879, extending propositional logic with functions, variables and quantifiers Epistemologically (states of knowledge), both PL and FOL consider truth and falsity Ontologically (what exists), PL considers facts, while FOL also considers objects: people, houses, numbers, courses,... properties and relations: being red, being happy, being prime,..., being bigger than, being part of,... functions: parent of, age of, successor of,... Computational Logic Davide Martinenghi (7/26)

FOL - syntax The alphabet of a FOL language L is composed of A countably infinite set of variables: X, Y, Z,... A set of function symbols: f, g,... A set of predicate (aka relation) symbols: p, q, r,... The following connectives:,,,, The following quantifiers:, The punctuation symbols: (, ), and commas Each function and relation symbol has a fixed arity which denotes the number of arguments associated with it p/n indicates that predicate (or function) p has arity n Nullary functions are called constants; nullary predicates are called propositions No meaning is attached to the symbols of the alphabet (this is the role of the semantics ) Computational Logic Davide Martinenghi (8/26)

FOL - syntax Terms denote all the objects L is able to speak about. They are inductively defined as follows: A variable is a term If f/n is a function symbol, and t1,..., t n are terms, then f(t 1,..., t n ) is a term Generic terms are typically denoted by s, t,... A nullary function c() is simply written as c Computational Logic Davide Martinenghi (9/26)

FOL - syntax The set of FOL formulas is inductively defined as the smallest set such that: If p/n is a relation symbol, and t1,..., t n are terms, then p(t 1,..., t n ) is a formula called atomic formula or atom If F and G are formulas, and X is a variable, then are formulas ( F) (F G) (F G) (F G) (F G) ( XF) ( XF) A nullary predicate p() is simply written as p Computational Logic Davide Martinenghi (10/26)

FOL - syntax Literals are atoms (positive literals), or negated atoms (negative literals) Parentheses are omitted whenever possible with the following precedence order:, > > > > > For convenience ( X1 (... ( X n (F))...) is abbreviated as ( X 1,..., X n (F)), and ( X 1 (... ( X n (F))...) is abbreviated as ( X 1,..., X n (F)) Computational Logic Davide Martinenghi (11/26)

FOL - syntax Examples of possible FOL translations of sentences in natural language: all humans are mortal becomes ( X(h(X) m(x))) each child must have parents becomes X(c(X) ( Y, Z p(x, Y, Z)))) Computational Logic Davide Martinenghi (12/26)

FOL - syntax Observations on the translation into FOL The main connective in use with is Example: everyone at Unibz is smart is translated as X(at(X, unibz) smart(x)) Note that the formula X(at(X, unibz) smart(x)) means that everyone is at Unibz and everyone is smart! Similarly, the main connective in use with is Example: someone at Unibz is smart is translated as X(at(X, unibz) smart(x)) Note that the formula X(at(X, unibz) smart(x)) means that there is someone who either is not at Unibz or is smart (or both)! Computational Logic Davide Martinenghi (13/26)

FOL - syntax An expression is either a term or a formula A subterm of an expression E is a substring of E which is also a term in the same language If t is a subterm of E, then it is said that t occurs in E Every term is a subterm of itself; so a subterm t of s is a proper subterm if t s Computational Logic Davide Martinenghi (14/26)

FOL - syntax VAR(E) denotes the set of variables occurring in E; if VAR(E) = then E is said to be ground If QX(F) is a formula, and Q a quantifier, then F is said to be the scope of Q, and Q is said to be applied to F An occurrence of a variable in a formula is bound iff its occurrence is within the scope of a quantifier employing the variable It is bound by the quantifier of smallest scope that causes it to be bound Otherwise it is free Example: X( Y(p(X, Y) q(x, Y))) A formula is closed iff it does not contain free occurrences of variables; closed formulas are also called sentences The universal closure of a formula F is obtained by adding as a prefix a universal quantifier for each free variable occurring in F, commonly indicated as (F) Similarly, the existential closure of F is written as (F) Computational Logic Davide Martinenghi (15/26)

FOL - syntax Substitutions A substitution θ is a finite set of pairs of terms {X 1 /t 1,..., X n /t n }, where each t i is a term and each X i a variable such that X i t i and X i X j if i j Substitutions are usually denoted by θ, ρ, σ... The identity mapping {}, or ɛ is called the empty substitution A pair X/t is called a binding A substitution {X 1 /Y 1,..., X n /Y n } is a renaming iff Y 1,..., Y n is a permutation of X 1,..., X n Example: θ = {X/f(Y, Z), Y/g(h(W), a)} is a substitution but not a renaming Example: σ = {X/Y, Y/Z, Z/X} is a renaming substitution Computational Logic Davide Martinenghi (16/26)

FOL - syntax Substitutions Let θ = {X 1 /t 1,..., X n /t n } be a substitution, and V a set of variables then DOM(θ) denotes the set {X1,..., X n } RANGE(θ) denotes the set {t1,..., t n } VRANGE(θ) denotes the set of variables occurring in RANGE(θ) VAR(θ) = DOM(θ) VRANGE(θ) θ V = {X/t θ X V} is the restriction of θ to V Computational Logic Davide Martinenghi (17/26)

FOL - syntax Substitutions The application Eθ of a substitution θ to an expression E is the expression obtained by simultaneously replacing each occurrence of a variable X by term t whenever X/t θ Eθ is called an instance of E θ is said to be a grounding substitution for E if Eθ is ground If θ is a renaming substitution, then Eθ is called a variant of E Examples: term substitution instance {}}{{}}{{}}{ p(f(x, Z), f(y, a)) {X/a, Y/Z, W/b}= p(f(a, Z), f(z, a)) term substitution instance {}}{{}}{{}}{ p(x, Y) {X/f(Y), Y/b}= p(f(y), b) Computational Logic Davide Martinenghi (18/26)

FOL - syntax Substitutions Let θ and σ be two substitutions, then their composition θσ is the substitution {X/tσ X/t θ and X tσ} {Y/t σ Y DOM(θ)} Example: {X/f(Z), Y/W}{X/a, Z/a, W/Y} = {X/f(a), Z/a, W/Y} Composition of substitutions is associative: E(θσ) = (Eθ)σ (θσ)γ = θ(σγ) Composition has ɛ both as left and as right identity ɛθ = θɛ = θ However, composition is not commutative A substitution θ is idempotent iff θθ = θ It turns out that θ is idempotent iff DOM(θ) RANGE(θ) = Computational Logic Davide Martinenghi (19/26)

FOL - semantics As PL, FOL has a two-valued semantics based on the notion of interpretation An interpretation I of an alphabet A is a non-empty domain D (also indicated I ) and a mapping that associates each constant c A with an element ci D each function symbol f/n A with a function f I : D n D n times {}}{ each predicate symbol p/n A with a relation pi D... D However, before assigning meaning to formulas, the meaning of terms has to be defined Since terms may contain variables, a valuation (aka state) is needed, i.e., a mapping from variables of A to I The meaning φ I (t) of a term t under interpretation I and valuation φ is then inductively defined as ci if t is a constant c φ(x) if t is a variable X f I (φ I (t 1 ),..., φ I (t n )) if t is of the form f(t 1,..., t n ) Computational Logic Davide Martinenghi (20/26)

FOL - semantics Example: consider the term g(f(c), X) Let I be an interpretation with I = N and such that Constants: c I = 0 Functions: fi (x) = 1 + x (successor), g I (x, y) = x + y (addition) Let φ be a valuation such that φ(x) = 0 Then φ I (g(f(c), X)) = φ I (f(c)) + φ I (X) = (1 + φ I (c)) + φ(x) = (1 + 0) + 0 = 1 The same term can have different meanings. Take, e.g. I = persons in the Bible c I = Abel f I (x) = father of x, g I (x, y) = firstborn of x and y and a valuation φ such that φ(x) = Eve Eventually you get that φi (g(f(c), X)) = Cain Computational Logic Davide Martinenghi (21/26)

FOL - semantics Let φ be a valuation, X a variable, I an interpretation, and c I I Then φ[x c I ] is a valuation identical to φ except that it maps X to c I The meaning of a formula is a truth value that is defined inductively as follows We write I = φ F to indicate that F is true wrt. I and φ I = φ p(t 1,..., t n ) iff φ I (t 1 ),..., φ I (t n ) p I I = φ ( F) iff I = φ F I = φ (F G) iff I = φ F and I = φ G I = φ (F G) iff I = φ F or I = φ G I = φ (F G) iff I = φ F or I = φ G I = φ (F G) iff I = φ (F G) and I = φ (G F) I = φ ( X(F)) iff I = φ[x ci ] F for every c I I I = φ ( X(F)) iff I = φ[x ci ] F for some c I I Computational Logic Davide Martinenghi (22/26)

FOL - semantics If F is a sentence, its meaning only depends on the interpretation The valuation will then be omitted when considering sentences Commonly, in logic programming, formulas are implicitly considered as universally quantified, i.e., whenever there are free variables, the universal closure is considered instead An interpretation I is said to be a model for F, written I = F, iff for every valuation φ we have that I = φ F If F is a set of formulas, an interpretation is a model of F iff it is a model for each F F Computational Logic Davide Martinenghi (23/26)

FOL - semantics Example (cont d) Let I be an interpretation with I = N and such that Constants: ci = 0 Functions: fi (x) = 1 + x (successor) Predicates: pi = { 1, 3, 5,...} Then the meaning of the formula p(c) p(f(c)) in I is as follows I = p(c) p(f(c)) iff I = p(c) and I = p(f(c)) iff φ I (c) p I and φ I (f(c)) p I iff φ I (c) p I and 1 + φ I (c) p I iff 0 p I and 1 p I Now, 1 p I but 0 p I, so I is not a model for the formula Computational Logic Davide Martinenghi (24/26)

FOL - semantics The logical entailment = relation between sets of formulas and formulas can be extended to FOL and so can the concepts of validity, satisfiability, falsifiability, contingency, and unsatisfiability The deduction theorem and the theorem relating validity with unsatisfiability through negation also apply to FOL closed formulas In contrast to PL, the question of whether a FOL formula is a logical consequence of a set of formulas is undecidable This can be formally shown by reducing some known undecidable problem (like the halting problem for Turing machines) to logical entailment in FOL However, logical entailment in FOL is semidecidable Computational Logic Davide Martinenghi (25/26)

FOL - semantics Equivalences The equivalences shown for PL can be extended to FOL Some additional equivalences for FOL: X(F) ( X( F)) quantifier duality 1 (1) X(F) ( X( F)) quantifier duality 2 (2) X(F) ( X)G X(F G) (3) X(F) ( X)G X(F G) (4) ( X)( Y)F ( Y)( X)F (5) ( X)( Y)F ( Y)( X)F (6) ( X(F)) G X(F G) (7) ( X(F)) G X(F G) (8) ( X(F)) G X(F G) (9) ( X(F)) G X(F G) (10) only applies if X does not occur free in G Computational Logic Davide Martinenghi (26/26)