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

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

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

Propositional Logic Not Enough

Introduction to first-order logic:

First Order Logic: Syntax and Semantics

03 Review of First-Order Logic

06 From Propositional to Predicate Logic

Classical First-Order Logic

First-order logic Syntax and semantics

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

Introduction to Sets and Logic (MATH 1190)

Classical First-Order Logic

A Little Deductive Logic

A Little Deductive Logic

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

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:

Propositional Logic: Syntax

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

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

Logic. Propositional Logic: Syntax. Wffs

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

Logic. Propositional Logic: Syntax

LING 501, Fall 2004: Quantification

Introduction to Logic in Computer Science: Autumn 2006

Learning Goals of CS245 Logic and Computation

A Logic Primer. Stavros Tripakis University of California, Berkeley

INTRODUCTION TO LOGIC. Propositional Logic. Examples of syntactic claims

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

Informal Statement Calculus

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

Discrete Structures for Computer Science

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

First order Logic ( Predicate Logic) and Methods of Proof

First Order Logic (FOL) 1 znj/dm2017

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

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

To every formula scheme there corresponds a property of R. This relationship helps one to understand the logic being studied.

Notes. Corneliu Popeea. May 3, 2013

Automated Reasoning Lecture 5: First-Order Logic

MAI0203 Lecture 7: Inference and Predicate Calculus

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

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

15414/614 Optional Lecture 3: Predicate Logic

7.5.2 Proof by Resolution

Propositional Logic. Jason Filippou UMCP. ason Filippou UMCP) Propositional Logic / 38

First-order Logic (Session 1) Anthony W. Lin Yale-nus College, Singapore

Introduction to Logic

Section Summary. Predicate logic Quantifiers. Negating Quantifiers. Translating English to Logic. Universal Quantifier Existential Quantifier

Discrete Mathematics & Mathematical Reasoning Predicates, Quantifiers and Proof Techniques

First Order Logic Semantics (3A) Young W. Lim 9/17/17

03 Propositional Logic II

Propositional Resolution Introduction

COMP4418: Knowledge Representation and Reasoning First-Order Logic

Logical Agents. Knowledge based agents. Knowledge based agents. Knowledge based agents. The Wumpus World. Knowledge Bases 10/20/14

Lecture 9. Model theory. Consistency, independence, completeness, categoricity of axiom systems. Expanded with algebraic view.

Propositional and Predicate Logic

2. Use quantifiers to express the associative law for multiplication of real numbers.

Logic: The Big Picture

Section Summary. Predicate logic Quantifiers. Negating Quantifiers. Translating English to Logic. Universal Quantifier Existential Quantifier

Logic: Propositional Logic (Part I)

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

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

CS 730/730W/830: Intro AI

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

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

Announcements CompSci 102 Discrete Math for Computer Science

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

CHAPTER 2. FIRST ORDER LOGIC

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

185.A09 Advanced Mathematical Logic

1 Predicates and Quantifiers

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

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

Knowledge base (KB) = set of sentences in a formal language Declarative approach to building an agent (or other system):

1 First-order logic. 1 Syntax of first-order logic. 2 Semantics of first-order logic. 3 First-order logic queries. 2 First-order query evaluation

Formal (Natural) Deduction for Predicate Calculus

Formal Methods for Java

The Importance of Being Formal. Martin Henz. February 5, Propositional Logic

Logic As Algebra COMP1600 / COMP6260. Dirk Pattinson Australian National University. Semester 2, 2017

SKETCHY NOTES FOR WEEKS 7 AND 8

Marie Duží

KRIPKE S THEORY OF TRUTH 1. INTRODUCTION

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

Section Summary. Predicates Variables Quantifiers. Negating Quantifiers. Translating English to Logic Logic Programming (optional)

Introduction to Metalogic

Predicate Logic. Predicates. Math 173 February 9, 2010

Predicate Logic: Sematics Part 1

INF3170 Logikk Spring Homework #8 For Friday, March 18

COMP9414: Artificial Intelligence First-Order Logic

Semantics and Pragmatics of NLP

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

Outline. Logic. Definition. Theorem (Gödel s Completeness Theorem) Summary of Previous Week. Undecidability. Unification

Logik für Informatiker Logic for computer scientists

Logic for Computer Science Handout Week 8 DERIVED RULE MODUS TOLLENS DERIVED RULE RAA DERIVED RULE TND

Logical Structures in Natural Language: First order Logic (FoL)

CHAPTER 4 CLASSICAL PROPOSITIONAL SEMANTICS

Logic. Lesson 3: Tables and Models. Flavio Zelazek. October 22, 2014

- Introduction to propositional, predicate and higher order logics

Discrete Mathematics and Its Applications

6.825 Techniques in Artificial Intelligence. Logic Miscellanea. Completeness and Incompleteness Equality Paramodulation

Transcription:

GS03/4023: Validation and Verification Predicate Logic Jonathan P. Bowen www.cs.ucl.ac.uk/staff/j.bowen/gs03 Anthony Hall GS03 W1 L3 Predicate Logic 12 January 2007 1

Overview The need for extra structure variables, quantifiers, terms, equality, function symbols Proof well formedness natural deduction Semantics models Properties soundness completeness decidability expressiveness GS03 W1 L3 Predicate Logic 12 January 2007 2

Propositions are not enough Samantha is Charlie s sister need to distinguish properties from the things to which they apply All sisters are female need to express all Some people don t have sisters need to express some No-one is their own sister need notion of equality Everyone s mother is also their sisters mother useful to have functions like mother GS03 W1 L3 Predicate Logic 12 January 2007 3

Elements of predicate logic Variables x, y, Predicates female(x) x is female sister(x, y) x is the sister of y any number of arguments x = y Quantifiers Ax for all x Ex for some x or there exists an x such that Logical connectives vfi same as propositional logic GS03 W1 L3 Predicate Logic 12 January 2007 4

Extra-logical terms In pure logic, the only terms used are variables In any real application, predicate logic is used with some other language that is relevant to the application domain This language may contain for example sets, functions, relations or arithmetic For simplicity, we ll start by using just one new kind of term: a function symbol Charlie constant: function of arity 0 Mother(x) the mother of x Wedding(x,y) date of the wedding of x and y any finite number of arguments allowed GS03 W1 L3 Predicate Logic 12 January 2007 5

Formalising natural language Samantha is Charlie s sister sister(samantha, Charlie) All sisters are female (Ax (A y sister(x, y) fi female(x) )) Some people don t have sisters (Ey ( Ex sister( x, y ) )) No-one is their own sister (Ax (A y sister( x, y ) fi x=y )) Everyone s mother is also their sister s mother (Ax (A y sister(x, y) fi mother(x) = mother(y) )) GS03 W1 L3 Predicate Logic 12 January 2007 6

Disambiguating natural language Everyone loves a winner (Ax (A y winner ( y ) fi loves ( x, y ) )) or (Ax (E y winner ( y ) loves ( x, y ) )) or (E y winner ( y ) (Ax loves ( x, y ) ))? GS03 W1 L3 Predicate Logic 12 January 2007 7

Overview The need for extra structure variables, quantifiers, terms, equality, function symbols Proof well formedness natural deduction Semantics models Properties soundness completeness decidability expressiveness GS03 W1 L3 Predicate Logic 12 January 2007 8

Well formed formulae φ ::= P(t 1, t 2,, t n ) ( φ) (φ φ) (φ v φ) (φ fi φ) (A x φ) (E x φ) t ::= x c f (t 1, t 2,, t n ) Quantifiers and bind most tightly GS03 W1 L3 Predicate Logic 12 January 2007 9

Free and bound variables Variables are bound if they are within the scope of a quantifier, otherwise they are free (A y sister ( x, y ) fi female ( x )) y is bound, x is free The same variable may be bound and free in different occurrences (A x (A y sister ( x, y ) fi female ( x ) ) loves ( x, y ) ) Terms may be substituted for free variables The substituted term must not contain any variables that are bound at that point (A y sister ( mother ( z ), y ) fi female ( mother ( z )) ) Not (A y sister ( mother ( y ), y ) fi female ( mother ( y )) ) GS03 W1 L3 Predicate Logic 12 January 2007 10

Rules for reasoning All the rules for propositional formulae carry over In addition there are rules for equality = universal quantification A generalisation of conjunction existential quantification E generalisation of disjunction v These give rise to important equivalences which are often used in practice GS03 W1 L3 Predicate Logic 12 January 2007 11

Rules for equality t=t t 1 =t 2 φ[t 1 /x] φ[t 2 /x] =i =e t 1 = t 2 t 2 = t 1 1 t 1 = t 2 premise 2 t 1 = t 1 =i 3 t 2 = t 1 =e 1,2 t 1 = t 2, t 2 = t 3 t 1 = t 3 1 t 2 = t 3 premise 2 t 1 = t 2 premise 3 t 1 = t 3 =e 1,2 GS03 W1 L3 Predicate Logic 12 January 2007 12

Rules for universal quantification φ [x 0 /x] (Ax φ) (Ax φ) φ [t/x] where x 0 is a fresh variable A i A e where t free for x in φ GS03 W1 L3 Predicate Logic 12 January 2007 13

Rules for existential quantification φ [t/x] (E x φ) where t free for x in φ E i (E x φ) φ [x 0 /x] χ χ E e GS03 W1 L3 Predicate Logic 12 January 2007 14

There are many useful equivalences Example: generalisation of De Morgan s laws Ax φ Ex φ E x φ A x φ Sample proof: Ex φ Ax φ 1 Ex φ premise 2 Ax φ assumption 3 φ[x o /x] assumption 4 φ[x o /x] Ae 2 5 e 4,3 6 Ee 1, 3-5 7 Ax φ i 2-7 GS03 W1 L3 Predicate Logic 12 January 2007 15

Overview The need for extra structure variables, quantifiers, terms, equality, function symbols Proof well formedness natural deduction Semantics models Properties soundness completeness decidability expressiveness GS03 W1 L3 Predicate Logic 12 January 2007 16

Models In propositional logic, truth depends only on the truth of the (uninterpreted) propositions In predicate logic, we need to consider what the variables represent So every formula is interpreted relative to some Universe of Discourse (UoD) All men are mortal; Socrates is a man; therefore Socrates is mortal UoD is perhaps all living things All states with successors are live; all reachable states have successors; therefore all reachable states are live UoD is states of some system GS03 W1 L3 Predicate Logic 12 January 2007 17

What is a model? A non-empty, possibly infinite, set A living things, states, transactions, aircraft, For each predicate symbol P with arity n, a set P M of n-tuples of A the set of tuples of values for which P is true For each function symbol f with arity n, a function f M : A n A the real-world value of the function f if n is 0, this is just a constant element of A GS03 W1 L3 Predicate Logic 12 January 2007 18

A model of a state-transition system Let P Í {R, Final} ; F Í {i} R is a two-place predicate: the transition relation Final is a one-place predicate: the final states i is a constant: the initial state Then A is the set of all states e.g., {a, b, c} i M is the initial state e.g., a R M is the transition relation e.g., {(a,a), (a,b), (a,c), (b,c), (c,c)} Final M is the set of final states e.g., {b,c} GS03 W1 L3 Predicate Logic 12 January 2007 19

What do the following mean? Which are true in the model? E y R(i,y) Final(i) A x A y A z ( R(x,y) R(x,z) fi y=z ) A x E y R(x,y) GS03 W1 L3 Predicate Logic 12 January 2007 20

Environments and free variables If a formula contains free variables, we need to know what values they have An environment (look-up table) for A is a function l : var A, where var is the set of all variable names An environment can be overwritten: l[x å a] is the environment where x has the value a and all other variables y have the value l(y) GS03 W1 L3 Predicate Logic 12 January 2007 21

Satisfaction M l φ means that model M satisfies formula φ in environment l If the formula φ has no free variables it is called a sentence, and we don t need an environment, so can just write M φ φ is satisfiable iff M l φ for some M and l A set Γ of formulae is satisfiable (consistent) if there is some M and l for which M l φ for all φ e Γ φ is valid if M l φ for all M and l Semantic entailment φ 1, φ 2, φ n ψmeans that for every M and l such that M l φ i for all φ i, M l ψ GS03 W1 L3 Predicate Logic 12 January 2007 22

Definition of satisfaction M l P(t 1, t 2, t n ) iff (a 1, a 2, a n ) e P M where a i is the result of evaluating t i in M and l M Ax φ iff M l l [x å a] φ holds for all a e A M E x φ iff M l l [x å a] φ holds for some a e A M φ iff M l l φ does not hold M φ l 1 φ 2 iff M φ l 1 holds and M l φ 2 holds M φ l 1 v φ 2 iff M φ l 1 holds or M l φ 2 holds M φ l 1 fi φ 2 iff M φ l 2 holds whenever M l φ 1 holds GS03 W1 L3 Predicate Logic 12 January 2007 23

Computability It is in general infeasible to compute satisfaction it requires examination of every member of possibly infinite sets It is even more infeasible to compute validity or entailment it requires examination of every possible model It can be feasible to compute satisfiability it only requires a single witness Satisfiability of φ is a refutation of φ So proof theory and model semantics play complementary roles GS03 W1 L3 Predicate Logic 12 January 2007 24

Overview The need for extra structure variables, quantifiers, terms, equality, function symbols Proof well formedness natural deduction Semantics models Properties soundness completeness decidability expressiveness GS03 W1 L3 Predicate Logic 12 January 2007 25

Predicate logic is sound and complete If φ 1, φ 2, φ n ψ then φ 1, φ 2, φ n ψ If φ 1, φ 2, φ n ψ then φ 1, φ 2, φ n ψ Proofs: too difficult for this course Consequence We can use proofs interchangeably with model checking to investigate the validity of formulae GS03 W1 L3 Predicate Logic 12 January 2007 26

Predicate logic is not decidable There is no uniform mechanical procedure for determining the validity of a formula φ Proof show that some other problem that is known to be insoluble can be expressed in predicate logic Post s correspondence problem halting problem Consequence analysis is hard there is a difficult trade-off between expressiveness and tractability GS03 W1 L3 Predicate Logic 12 January 2007 27

Undecidability is bad but not catastrophic It does not mean that we can never prove anything mechanically but we can never prove everything mechanically It does not mean that we cannot establish the correctness of a proof if we have a proof, we can check it but we have no uniform method of finding it in the first place It does not mean that model checking is useless if we can find a refutation, our conjecture is certainly false if we have a finite model, we can (in principle) check any property of that model GS03 W1 L3 Predicate Logic 12 January 2007 28

How expressive is predicate logic? Not completely does not include the whole of arithmetic cannot express closure of relations (reachability in graphs) Proof see textbook Consequences In practice, we never use pure predicate logic. Always have some extra-logical theory that defines the set of terms Set theory (Z, VDM, B, ) Relations (Alloy) Arithmetic (e.g., Presburger consistent, complete, decidable) For some purposes, need higher-order logics (used in theorem provers like HOL, Isabelle and PVS) GS03 W1 L3 Predicate Logic 12 January 2007 29

Summary First order predicate logic is the foundation of most reasoning in software engineering It is sound and complete We can use proof (which most easily shows positive results) interchangeably with model checking (which most easily shows negative results) It is undecidable So we always have to make compromises and trade-offs between being expressive and having full tool support It normally depends on having domain-specific extra-logical models GS03 W1 L3 Predicate Logic 12 January 2007 30

Conclusion This week: Introduction Propositional logic Predication logic Next week: Using logic for specifications Z notation Alloy Analyzer Coursework #1 GS03 W1 L3 Predicate Logic 12 January 2007 31

Reading and exercises Read Chapter 2 of Huth and Ryan apart from section 2.7 (especially 2.1 2.4; 2.5 2.6 optional) Do selected (starred) exercises with online solutions, depending on your previous experience. E.g.: 2.1, 1(a), 3(a); 2.2 1(a) ii & iii, 3(a), 4 2.3 3 (a),(b), 7(a), 9(a); 2.4 1, 5, 8, 11(b), 12(b) If you know the correct answers do less If you have difficulty do more starred questions GS03 W1 L3 Predicate Logic 12 January 2007 32

Stop Press! Recommended talk: What Can We Expect From Program Verification? By Michael Jackson (father of Daniel Jackson Alloy Analyzer) BCS-FACS (Formal Aspects of Computing Science) Specialist Group www.bcs-facs.org/events British Computer Society London office Southampton Street, Covent Garden 5.45pm, Wednesday 7 February Free tea/coffee/biscuits from 5.15pm! Needs to be booked send your name to Paul.Boca@virgin.net GS03 W1 L3 Predicate Logic 12 January 2007 33