Classical First-Order Logic

Similar documents
Classical First-Order Logic

Roadmap. Introduction

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

The Curry-Howard Isomorphism

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

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

Beyond First-Order Logic

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

03 Review of First-Order Logic

Predicate Calculus. CS 270 Math Foundations of Computer Science Jeremy Johnson

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

15414/614 Optional Lecture 3: Predicate Logic

First-Order Logic (FOL)

Formal Logic and Deduction Systems

06 From Propositional to Predicate Logic

CHAPTER 2. FIRST ORDER LOGIC

Automated Reasoning Lecture 5: First-Order Logic

Logic: Propositional Logic Truth Tables

First Order Logic (FOL) 1 znj/dm2017

185.A09 Advanced Mathematical Logic

Introduction to Logic in Computer Science: Autumn 2006

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

INTRODUCTION TO PREDICATE LOGIC HUTH AND RYAN 2.1, 2.2, 2.4

CS156: The Calculus of Computation Zohar Manna Winter 2010

First Order Logic: Syntax and Semantics

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

Mathematical Logic. Reasoning in First Order Logic. Chiara Ghidini. FBK-IRST, Trento, Italy

Propositional Logic: Deductive Proof & Natural Deduction Part 1

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

Final Exam (100 points)

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

Learning Goals of CS245 Logic and Computation

Classical Propositional Logic

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

Formal Methods for Java

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

Predicate Logic. Bow-Yaw Wang. Institute of Information Science Academia Sinica, Taiwan. November 22, 2017

First-Order Predicate Logic. Basics

Lecture 10: Predicate Logic and Its Language

PROOFS IN PREDICATE LOGIC AND COMPLETENESS; WHAT DECIDABILITY MEANS HUTH AND RYAN 2.3, SUPPLEMENTARY NOTES 2

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

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

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

Overview of Logic and Computation: Notes

Notes on Propositional and First-Order Logic (CPSC 229 Class Notes, January )

Propositional Logic Language

Advanced Topics in LP and FP

A Logic Primer. Stavros Tripakis University of California, Berkeley

Logic Part I: Classical Logic and Its Semantics

Lecture 1: Logical Foundations

CMPS 217 Logic in Computer Science. Lecture #17

Propositional Logic: Part II - Syntax & Proofs 0-0

02 Propositional Logic

Propositional Logic: Syntax

Propositional and Predicate Logic - XIII

First Order Logic (FOL)

Přednáška 12. Důkazové kalkuly Kalkul Hilbertova typu. 11/29/2006 Hilbertův kalkul 1

Sequent calculus for predicate logic

AAA615: Formal Methods. Lecture 2 First-Order Logic

if t 1,...,t k Terms and P k is a k-ary predicate, then P k (t 1,...,t k ) Formulas (atomic formulas)

Modal Logic XX. Yanjing Wang

Logic: Propositional Logic (Part I)

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

Formal Methods for Java

MAI0203 Lecture 7: Inference and Predicate Calculus

SKETCHY NOTES FOR WEEKS 7 AND 8

An Introduction to Modal Logic III

First-Order Logic. Chapter Overview Syntax

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

Predicate Logic: Sematics Part 1

Cooperation of Background Reasoners in Theory Reasoning by Residue Sharing

Ling 130 Notes: Predicate Logic and Natural Deduction

CHAPTER 4 CLASSICAL PROPOSITIONAL SEMANTICS

About the relationship between formal logic and complexity classes

Introduction to first-order logic:

All psychiatrists are doctors All doctors are college graduates All psychiatrists are college graduates

Informal Statement Calculus

Equational Logic. Chapter Syntax Terms and Term Algebras

Nonclassical logics (Nichtklassische Logiken)

Herbrand Theorem, Equality, and Compactness

Propositional Logic: Review

Propositional and Predicate Logic - VII

Predicate Logic: Syntax

Lecture 2: Syntax. January 24, 2018

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

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


Modal logics: an introduction

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:

Chapter 4: Classical Propositional Semantics

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

Cooperation of Background Reasoners in Theory Reasoning by Residue Sharing

Predicate Logic - Introduction

Automated Synthesis of Tableau Calculi

Abstract model theory for extensions of modal logic

Propositional Logic Arguments (5A) Young W. Lim 11/8/16

Description Logics. Deduction in Propositional Logic. franconi. Enrico Franconi

Lecture 11: Gödel s Second Incompleteness Theorem, and Tarski s Theorem

Madhavan Mukund Chennai Mathematical Institute

Introduction to Logic in Computer Science: Autumn 2007

Transcription:

Classical First-Order Logic Software Formal Verification Maria João Frade Departmento de Informática Universidade do Minho 2009/2010 Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 1 / 33 Introduction First-order logic (FOL) is a richer language than propositional logic. Its lexicon contains not only the symbols,,, and (and parentheses) from propositional logic, but also the symbols and for there exists and for all, along with various symbols to represent variables, constants, functions, and relations. There are two sorts of things involved in a first-order logic formula: terms, which denote the objects that we are talking about; formulas, which denote truth values. Examples: Not all birds can fly. Every child is younger than its mother. Andy and Paul have the same maternal grandmother. Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 2 / 33

Syntax Variables: x, y, z,... X (represent arbitrary elements of an underlying set) Constants: a, b, c,... C (represent specific elements of an underlying set) Functions: f,g,h,... F (every function f as a fixed arity, ar(f)) Predicates: P, Q, R,... P (every predicate P as a fixed arity, ar(p )) Fixed logical symbols:,,,,,, Fixed predicate symbol: = for equals ( first-order logic with equality ) Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 3 / 33 Syntax Terms The set T, of terms of FOL, is given by the abstract syntax T t ::= x c f(t 1,...,t ar(f) ) Formulas The set L, of formulas of FOL, is given by the abstract syntax Lφ, ψ ::= φ φ ψ φ ψ φ ψ t 1 = t 2 x. φ x. φ P (t 1,...,t ar(p ) ) In absence of parentheses, we adopt the following convention about precedence. Ranging from the highest precedence to the lowest, we have respectively:,, and. Finallywehavethat binds more tightly than and. Implication is right-associative. Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 4 / 33

Free and bound variables The free variables of a formula φ are those variables occurring in φ that are not quantified. FV(φ) denotes the set of free variables occurring in φ. The bound variables of a formula φ are those variables occurring in φ that do have quantifiers. BV(φ) denote the set of bound variables occurring in φ. Note that variables can have both free and bound occurrences within the same formula. Let φ be x. R(x, y) y. P(y, x), then FV(φ) ={y} and BV(φ) ={x, y}. Aformulaφ is closed if it does not contain any free variables. If FV(φ) ={x 1,...,x n },then its universal closure is x 1... x n.φ its existential closure is x1... x n.φ Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 5 / 33 Substitution Substitution We define u[t/x] to be the term obtained by replacing each occurrence of variable x in u with t. We define φ[t/x] to be the formula obtained by replacing each free occurrence of variable x in φ with t. Care must be taken, because substitutions can give rise to undesired effects. Given a term t, avariablex and a formula φ, wesaythatt is free for x in φ if no free x in φ occurs in the scope of z or z for any variable z occurring in t. From now on we will assume that all substitutions satisfy this condition. That is when performing the φ[t/x] we are always assuming that t is free for x in φ. Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 6 / 33

Substitution Convention We write φ(x 1,...,x n ) to denote a formula having free variables x 1,...,x n.wewriteφ(t 1,...,t n ) to denote the formula obtained by replacing each free occurrence of x i in φ with the term t i.whenusing this notation, it should always be assumed that each t i is free for x i in φ. Also note that when writhing φ(x 1,...,x n ) we do not mean that x 1,...,x n are the only free variables of φ. A sentence of first-order logic is a formula having no free variables. The presence of free variables distinguishes formulas from sentences. This distinction did not exist in propositional logic. Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 7 / 33 Semantics Vocabulary A vocabulary (or signature) is a set of function, relation, and constant symbols. C F P is a vocabulary. V-structure Let V be a vocabulary. A V-structure consists of a nonempty underlying set U along with an interpretation of V. An interpretation of V assigns: Model an element of U to each constant in V, a function from U n to U to each n-ary function in V, and a subset of U n to each n-ary relation in V. We say that M is a model of (C, F, P) iff M is a (C F P)-structure. Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 8 / 33

Semantics An alternative definition: Model A model M of (C, F, P) consists of the following set of data: a non-empty set U, the universe of concrete values; for each constant symbol c C, a concrete element M(c) U; for each f F, a concrete function M(f) :U ar(f) U; for each P P,asubsetM(P ) U ar(p ). The set U is the interpretation domain (or interpretation universe) of M. Semantically, one recognises the special role of equality by imposing on an interpretation function M(=) to be actual equality on the set U of M. Thus, (a, b) is in the set M(=) iff a and b are the same elements in the set U. Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 9 / 33 Semantics Assignment An assignment or environment for a universe U of concrete values is a function α : X U. We denote by α[x a] the assignment which maps x to a and any other variable y to α(y). Given a model M for (C, F, P) with interpretation domain U, and given an assignment α : X U, we define an interpretation function for terms, α M : T U, as follows: α M (x) = α(x) α M (c) = M(c) α M (f(t 1,...,t n )) = M(f)(α M (t 1 ),...,α M (t n )) Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 10 / 33

Semantics Satisfaction relation Given a model M for (C, F, P) and given an assignment α : X U, we define the satisfaction relation M = α φ for each logical formula φ over (C, F, P) as follows: M = α M = α M = α P (t 1,...,t n ) iff (α M (t 1 ),...,α M (t n )) M(P ) M = α φ iff M = α φ M = α φ ψ iff M = α φ and M = α ψ M = α φ ψ iff M = α φ or M = ψ M = α φ ψ iff M = α φ or M = α ψ M = α x. φ iff M = α[x a] φ for all a U M = α x. φ iff M = α[x a] φ for some a U If φ is a sentence we often drop α and write M = φ. Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 11 / 33 Validity, satisfiability, and contradiction If M = φ holds, then we say that M models φ, orthatφ holds in M, or simply, that φ is true in M. Asentenceφ is valid iff it holds in every model. We write = φ. Avalidsentenceiscalledatautology. satisfiable iff it holds in some model. unsatisfiable iff there is no model in which φ is true. An unsatisfiable sentence is called a contradiction. Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 12 / 33

Validity, satisfiability, and contradiction The definition of satisfiability can be extended to apply to all formulas of first-order logic (not just sentences). The formula φ(x 1,...,x n ) is satisfiable if and only if the sentence x 1... x n.φ(x 1,...,x n ) (its universal closure) is satisfiable. Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 13 / 33 Consequence and equivalence φ = ψ iff for every model M, ifm = φ then M = ψ. Wesayψ is a consequence of φ. φ ψ iff φ = ψ and ψ = φ. We say φ and ψ are equivalent. Let Γ={φ 1,φ 2,φ 3,...} be a set of sentences. M =Γ iff M = φ i for each sentence φ i in Γ. WesayM models Γ. Γ = ψ iff M =Γimplies M = ψ for every model M. Wesay ψ is a consequence of Γ. Proposition φ = ψ iff = φ ψ Γ = ψ and Γ finite iff = Γ ψ Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 14 / 33

Consistency Let Γ={φ 1,φ 2,φ 3,...} be a set of sentences. Γ is consistent or satisfiable iff there is a model for Γ. We say that Γ is inconsistent iff it is not consistent and denote this by Γ =. Proposition {φ, φ} = If Γ = and Γ, then =. Γ = φ iff Γ, φ = Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 15 / 33 Substitution Formula ψ is a subformula of formula φ if it occurs syntactically within φ. Formula ψ is a strict subformula of φ if ψ is a subformula of φ and ψ = φ Substitution theorem Suppose φ ψ. Letθ be a formula that contains φ as a subformula. Let θ be the formula obtained by safe replacing (i.e., avoiding the capture of free variables of φ) some occurrence of φ in θ with ψ. Thenθ θ. Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 16 / 33

Adquate sets of connectives for FOL As in propositional logic, there is some redundancy among the connectives and quantifiers. Note that in classical first-order logic x. φ x. φ x. φ x. φ Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 17 / 33 Decidability Given formulas φ and ψ as input, we may ask: Decision problems Validity problem: Is φ valid? Satisfiability problem: Is φ satisfiable? Consequence problem: Is ψ a consequence of φ? Equivalence problem: Are φ and ψ equivalent? These are, in some sense, variations of the same problem. φ is valid iff φ is unsatisfiable φ = ψ iff (φ ψ) is unsatisfiable φ ψ iff φ = ψ and ψ = φ φ is satisfiable iff φ is not valid Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 18 / 33

Decidability A solution to a decision problem is a program that takes problem instances as input and always terminates, producing a correct yes or no output. A decision problem is decidable if it has a solution. A decision problem is undecidable if it is not decidable. In PL we could, in theory, compute a truth table to determine whether or not a formula is satisfiable. In FOL, we would have to check every model to do this. Theorem (Church & Turing) The decision problem of validity in first-order logic is undecidable: no program exists which, given any φ, decides whether = φ. The decision problem of satisfiability in first-order logic is undecidable: no program exists which, given any φ, decides whether φ is satisfiable. Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 19 / 33 Decidability However, there is a procedure that halts and says yes if φ is valid. A decision problem is semi-decidable if exists a procedure that, given an input, halts and answers yes iff yes is the correct answer, halts and answers no if no is the correct answer, or does not halt if no is the correct answer Unlike a decidable problem, the procedure is only guaranteed to halt if the correct answer is yes. The decision problem of validity in first-order logic is semi-decidable. Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 20 / 33

Decidability Methods for the Validity problem in fist-order logic: Semantic Tableaux Resolution for first-order logic SLD-resolution... Although first-order validity is undecidable, there are special simple fragments of FOL where it is decidable, e.g. Monadic predicate logic (i.e. only unary predicates and no function symbols) is decidable. The Bernays-Schönfinkel class of formulas (i.e. formulas that can be written with all quantiers appearing at the beginning of the formula with existentials before universals and that do not contain any function symbols) is decidable. Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 21 / 33 Proof system As with any logic, the semantics of first-order logic yield rules for deducing the truth of one sentence from that of another. The proof system we present for FOL is Natural Deduction in sequent style. The sequent Γ φ indicates that φ can be formally derived from the set of assumptions Γ. Basically, we just have to add rules for quantifiers and the equality. Other proof systems for FOL: Hilbert system and sequent calculus. Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 22 / 33

Natural deduction rules for L (in sequent style) Γ true φ Γ Γ φ assumption Γ φ Γ Γ Γ φ monotonicity Γ φ Γ ψ Γ φ ψ I Γ φ ψ Γ ψ E1 Γ φ ψ Γ ψ E2 Γ φ Γ φ ψ I1 Γ ψ Γ φ ψ I2 Γ φ ψ Γ,φ θ Γ,ψ θ Γ θ E Γ,φ ψ Γ φ ψ I Γ φ Γ φ ψ Γ ψ E Γ,φ Γ φ I Γ φ Γ φ Γ E Γ Γ φ E Γ φ Γ φ E Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 23 / 33 Natural deduction rules for L (in sequent style) Proof rules for equality and quantifiers. Γ t = t = I Γ φ(t 1 ) Γ t 1 = t 2 Γ φ(t 2 ) = E Γ φ(y) Γ x. φ(x) I (a) Γ x. φ(x) Γ φ(t) E Γ φ(t) Γ x. φ(x) I Γ x. φ(x) Γ,φ(y) θ Γ θ E (b) (a) y must not occur free in Γ or φ(x). (b) y must not occur free in Γ, φ(x) or θ. Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 24 / 33

Formal proof Deduction is purely syntactical. A formal proof is a finite sequence of statements of the form Γ φ each of which follows from the previous statements by one of the basic rules. We say that ψ can be derived from Γ if there is a formal proof concluding with the statement Γ ψ. Example: t 1 = t 2 t 2 = t 1 Statements Justification 1. t 1 = t 2 t 1 = t 2 assumption 2. t 1 = t 2 t 1 = t 1 = I 1 3. t 1 = t 2 t 2 = t 1 = E 2, 1 Recall that in a proof-assistant the proof is usually developed backwards. Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 25 / 33 Formal proof Example: P (t), ( x. P (x) Q(x)) Q(t) Statements Justification 1. P (t), x. P (x) Q(x) P (t) assumption 2. P (t), x. P (x) Q(x) x. P (x) Q(x) assumption 3. P (t), x. P (x) Q(x) P (t) Q(t) E 2 4. P (t), x. P (x) Q(x) Q(t) E 1, 3 Example: x. P (x) x. P (x) Statements Justification 1. x. P (x) x. P (x) assumption 2. x. P (x) P (t) E 1 3. x. P (x) x. P (x) I 2 Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 26 / 33

Formal proof Example: x. ψ(x) x. ψ(x) Statements Justification 1. x. ψ(x), x. ψ(x) x. ψ(x) assumption 2. x. ψ(x), x. ψ(x), ψ(x 0 ) x. ψ(x) assumption 3. x. ψ(x), x. ψ(x), ψ(x 0 ) ψ(x 0 ) assumption 4. x. ψ(x), x. ψ(x), ψ(x 0 ) ψ(x 0 ) E 2 5. x. ψ(x), x. ψ(x), ψ(x 0 ) E 4, 3 6. x. ψ(x), x. ψ(x) E 1, 5 7. x. ψ(x) x. ψ(x) I 6 Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 27 / 33 Soundness, completeness and compactness Soundness If Γ φ, thenγ = φ. Therefore, if ψ, thenψ is a tautology; and if ψ, thenψ is a contradiction. Completeness If Γ = φ, thenγ φ. Compactness A (possible infinite) set of sentences Γ is satisfiable if and only if every finite subset of Γ is satisfiable. Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 28 / 33

Exercises Prove that the following sequents hold x.ψ(x) x. ψ(x) (classical) ( x.φ(x)) ( x.ψ(x)) x.φ(x) ψ(x) x. y.φ(x, y) y. x.φ(x, y) Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 29 / 33 Proof checking mathematical statements Mathematics is usually presented in an informal but precise way. In situation Γ we have ψ. Proof. p. QED In Logic, Γ,ψ become formal objects and proofs can be formalized as a derivation (following some precisely given set of rules). Γ L ψ Proof. p. QED Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 30 / 33

Proof-assistants A proof-assistant is the combination of a proof-checker with a proof-development system to help on the formalization process and the interactive development of proofs. In a proof-assistant, after formalizing the primitive notions of the theory (under study), the user develops the proofs interactively by means of (proof) tactics, and when a proof is finished a proof-term is created. Machine assisted theorem proving: helps to deal with large problems; prevents us from overseeing details; does the bookkeeping of the proofs. Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 31 / 33 Proof-assistants There are many proof-assistants for many different logics: fist-order logic, higher-order logic, modal logic,... We can mention as examples: Coq - http://coq.inria.fr/ Isabelle - http://isabelle.in.tum.de/ HOL - http://www.cl.cam.ac.uk/research/hvg/hol Agda - http://wiki.portal.chalmers.se/agda/ PVS - http://pvs.csl.sri.com/... Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 32 / 33

The Coq proof-assistant Demo http://coq.inria.fr/ Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10 33 / 33