Lecture 1: Logical Foundations

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

CS156: The Calculus of Computation

Part 1: Propositional Logic

WHAT IS AN SMT SOLVER? Jaeheon Yi - April 17, 2008

The Calculus of Computation: Decision Procedures with Applications to Verification. Part I: FOUNDATIONS. by Aaron Bradley Zohar Manna

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

Tutorial 1: Modern SMT Solvers and Verification

First Order Logic vs Propositional Logic CS477 Formal Software Dev Methods

Learning Goals of CS245 Logic and Computation

Comp487/587 - Boolean Formulas

Satisfiability Modulo Theories

Advanced Topics in LP and FP

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

Introduction to Artificial Intelligence Propositional Logic & SAT Solving. UIUC CS 440 / ECE 448 Professor: Eyal Amir Spring Semester 2010

COMP219: Artificial Intelligence. Lecture 20: Propositional Reasoning

CS156: The Calculus of Computation Zohar Manna Autumn 2008

A brief introduction to Logic. (slides from

Chapter 7 R&N ICS 271 Fall 2017 Kalev Kask

Propositional Logic: Models and Proofs

ECE473 Lecture 15: Propositional Logic

Propositional logic. Programming and Modal Logic

Propositional Logic. Testing, Quality Assurance, and Maintenance Winter Prof. Arie Gurfinkel

Logical Agents. Santa Clara University

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

Topics in Model-Based Reasoning

Lecture 2 Propositional Logic & SAT

Intelligent Agents. Pınar Yolum Utrecht University

Notes. Corneliu Popeea. May 3, 2013

Propositional Logic. Methods & Tools for Software Engineering (MTSE) Fall Prof. Arie Gurfinkel

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

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

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

Logic: Propositional Logic (Part I)

Logic. Introduction to Artificial Intelligence CS/ECE 348 Lecture 11 September 27, 2001

Introduction to Artificial Intelligence. Logical Agents

First Order Logic (FOL) 1 znj/dm2017

Lecture 2: Syntax. January 24, 2018

Propositional Reasoning

Foundations of Artificial Intelligence

Logical Agents. Chapter 7

Logic and Inferences

Classical First-Order Logic

Tecniche di Verifica. Introduction to Propositional Logic

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

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

Propositional logic. Programming and Modal Logic

Propositional and Predicate Logic - II

Inf2D 06: Logical Agents: Knowledge Bases and the Wumpus World

Natural Deduction for Propositional Logic

Logic. proof and truth syntacs and semantics. Peter Antal

An Introduction to SAT Solving

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

LOGIC PROPOSITIONAL REASONING

Foundations of Artificial Intelligence

Decision Procedures for Satisfiability and Validity in Propositional Logic

Foundations of Artificial Intelligence

MAI0203 Lecture 7: Inference and Predicate Calculus

On the Complexity of the Reflected Logic of Proofs

Classical Propositional Logic

Computation and Inference

Foundations of Artificial Intelligence

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

7. Propositional Logic. Wolfram Burgard and Bernhard Nebel

Informal Statement Calculus

02 Propositional Logic

Class Assignment Strategies

CS:4420 Artificial Intelligence

Propositional Logic Language

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

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

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

Kecerdasan Buatan M. Ali Fauzi

Trichotomy Results on the Complexity of Reasoning with Disjunctive Logic Programs

Logic Part I: Classical Logic and Its Semantics

Logical Agents. Outline

Introduction to Metalogic

CSE507. Introduction. Computer-Aided Reasoning for Software. Emina Torlak courses.cs.washington.edu/courses/cse507/17wi/

The Wumpus Game. Stench Gold. Start. Cao Hoang Tru CSE Faculty - HCMUT

Propositional Logic: Syntax

Introduction to Metalogic

CS 380: ARTIFICIAL INTELLIGENCE PREDICATE LOGICS. Santiago Ontañón

Introduction to Model Theory

CS 771 Artificial Intelligence. Propositional Logic

Deliberative Agents Knowledge Representation I. Deliberative Agents

Price: $25 (incl. T-Shirt, morning tea and lunch) Visit:

CS 380: ARTIFICIAL INTELLIGENCE

SAT Solvers: Theory and Practice

Computational Logic Chapter 2. Propositional Logic


Propositional Logic: Methods of Proof. Chapter 7, Part II

Part 1: Propositional Logic

Propositional Logic: Methods of Proof (Part II)

Practical SAT Solving

A Cut-Free Calculus for Second-Order Gödel Logic

Propositional and First Order Reasoning

First Order Logic (FOL)

Lecture Notes on SAT Solvers & DPLL

Agenda. Artificial Intelligence. Reasoning in the Wumpus World. The Wumpus World

Classical First-Order Logic

185.A09 Advanced Mathematical Logic

Transcription:

Lecture 1: Logical Foundations Zak Kincaid January 13, 2016 Logics have two components: syntax and semantics Syntax: defines the well-formed phrases of the language. given by a formal grammar. Typically Semantics: defines the meaning of each phrase. The semantics of a logic are defined by developing a class of structures which can be used to interpret each phrase. 1 Propositional Logic 1.1 Syntax of propositional logic A propositional signature is a set of atomic propositions P = {p, q, r,..}. The syntax of propositional logic is given by the following calculus. A judgement ϕ : Formula(P ) should be read ϕ is a well-formed propositional formula over the signature P. true : Formula(P ) false : Formula(P ) p : Formula(P ) p P ϕ : Formula(P ) ϕ : Formula(P ) ϕ : Formula(P ) ψ : Formula(P ) ϕ ψ : Formula(P ) ϕ : Formula(P ) ψ : Formula(P ) ϕ ψ : Formula(P ) 1

The following OCaml data type encapsulates the above definition: type a formula = True False Proposition of a Not of ( a formula) Normal forms for propositional formulas: And of ( a formula) * ( a formula) Or of ( a formula) * ( a formula) Negation normal form if negation is only applied to propositions. For example, (p q) p is in negation normal form, (p q) is not. Conjunctive normal form if it is a conjunction of clauses. A clause is a disjunction of literals, and literal is either a proposition or a negated proposition. There is an exponential blow-up incurred when computing CNF. For example, p (q r) ( s r t) is in CNF. Most SAT solvers operate on CNF formulas. Given an (arbitrary) input formula ϕ, it is possible to compute an equi-satisfiable CNF formula of slize linear in ϕ (Tseytin transformation). Disjunctive normal form if it is a disjunction of cubes. A cube is a conjunction of literals. There is an exponential blow-up incurred when computing DNF. For example, p (q r) ( s r t) is in CNF. 1.2 Semantics of propositional logic Definition 1.1 (Interpretation). An interpretation over a propositional signature P is a function M : P {true, false}. Every propositional formula is a statement about propositional interpretations. The statement may or may not hold in a given interpretation, we write M = ϕ ( M satisfies ϕ, or M is a model of ϕ ) if the statement ϕ holds in the interpretation M. The precise meaning of this relationship is as follows: M = true 2

M = p M(p) = true M = ϕ M = ϕ M = ϕ ψ M = ϕ and M = ψ M = ϕ ψ M = ϕ or M = ψ The following OCaml function encapsulates this definition: let rec eval m phi = match phi with True -> true False -> false Proposition p -> m p Not psi -> not (eval m psi) And (psi, psi ) -> (eval m psi) && (eval m psi ) Or (psi, psi ) -> (eval m psi) (eval m psi ) Definition 1.2. Let P be a propositional signature, and let ϕ be a propositional formula over P. If M is an interpretation over P such that M = ϕ, then we say that M is a model of ϕ. Examples: p q has 3 models of over the signature {p, q}: 1. {p true, q true} 2. {p true, q false} 3. {p false, q false} If ϕ has a model, then ϕ is satisfiable. Examples: p q p q r p p If every interpretation is a model of ϕ, then ϕ is valid (or, ϕ is a tautology). Examples: p p (law of the excluded middle) 3

((p q) p) p (Peirce s law) Boolean satisfiability problem: Given a propositional formula ϕ, is ϕ satisfiable? This problem is NP-complete (Cook s theorem, [Cook, 1971]) but there are tools (see http://www.satcompetition.org/) and algorithms (DPLL [Davis and Putnam, 1960, Davis et al., 1962], local search [Selman et al., 1992]) for solving it which are efficient in practice. 2 First-order logic 2.1 Syntax of first-order logic Definition 2.1 (First-order signature). A (single-sorted) first-order signature is a triple Σ = F, R, ar where F is a set of function symbols, R is a set of relation symbols, and ar : F R N maps each symbol to its arity. We will sometimes use a short-hand to define signatures. We write a signature as two lists (separated by a semi-colon), where the first list gives function symbols and their arity, and the second list gives relation symbols and their arity. For example: (f/2, c/0; P/1, Q/2) denotes the signature {f, c}, {P, Q}, ar, where ar(f) = 2, ar(c) = 0, ar(p ) = 1, and ar(q) = 2. Example 2.1. The signature of linear integer arithmetic Σ LA is We can define some useful shorthand: (+/2, /1, 0/0, 1/0; </2, =/2) For any integer n and any term t, we can write n t to denote the term if n is positive, and if n is negative. t + t + + t }{{} n times (t } + t + {{ + } t) n times 4

For any integer n, we can use n to denote the term n 1 We can use s t to denote formula s = t s < t... The syntax of first-order logic over a given signature Σ is defined by the following calculus. There are two types of judgements, corresponding to the syntactic categories of terms and formulas. The judgement t : Term(Σ) is read as t is a well-formed term over Σ, and ϕ : Formula(Σ) as ϕ is a well-formed formula over Σ. v : Term(Σ) t 1 : Term(Σ)... t ar(f) : Term(Σ) f(t 1,..., t ar(f) ) : Term(Σ) t 1 : Term(Σ)... t ar(r) : Term(Σ) r(t 1,..., t ar(r) ) : Formula(Σ) false : Formula(Σ) ϕ : Formula(Σ) ϕ : Formula(Σ) true : Formula(Σ) ϕ : Formula(Σ) ψ : Formula(Σ) ϕ ψ : Formula(Σ) ϕ : Formula(Σ) v.ϕ : Formula(Σ) ϕ : Formula(Σ) ψ : Formula(Σ) ϕ ψ : Formula(Σ) ϕ : Formula(Σ) v.ϕ : Formula(Σ) For any formula ϕ (term t), we use fv(ϕ) (fv(t)) to denote the set of free 5

variables of ϕ (t). Formally, fv(v) {v} fv(f(t 1,..., t n )) fv(t 1 ) fv(t n ) fv(true) fv(false) fv( ϕ) fv(ϕ) fv(ϕ ψ) fv(ϕ) fv(ψ) fv(ϕ ψ) fv(ϕ) fv(ψ) fv( v.ϕ) fv(ϕ) \ {v} fv( v.ϕ) fv(ϕ) \ {v} Definition 2.2. A formula ϕ : Formula(Σ) is: A sentence if it has no free variables (fv(ϕ) = ) Ground if it is a sentence and it is free of quantifiers Conjunctive if it is ground and free of disjunction 2.2 Semantics of first-order logic Definition 2.3 (Structure). Let Σ = F, R, ar be a first-order signature. A Σ-structure M consists of a set U M (the domain or universe of M), along with a function f M : U } M {{ U M } U M ar(f) times for each function symbol f F, and a relation for each predicate symbol P R. P M U M U M }{{} ar(p ) times Given a structure M and a set of variables V, a valuation is a function ρ : V U M. 6

The semantics of terms is given by a function t (M, ρ) which maps a term t, a structure M, and a valuation ρ to a value in U M : v (M, ρ) = ρ(v) f(t 1,...t n ) (M, ρ) = f M ( t 1 (M, ρ),..., t n (M, ρ)) Like propositional logic, the semantics of formulas is given by a satisfaction relation =. However, since formulas may have free variables (which do not have a defefined interpretation withinin a structure), the left hand side of the satisfaction relation also includes a valuation. So M, ρ = ϕ should be thread that M satisfies ϕ when the free variables in ϕ are interpreted according to ρ. If ϕ has no free variables, we may omit ρ. Formally, the satisfaction relation is defined as follows: M, ρ = P (t 1,..., t m ) ( t 1 (M, ρ),..., t m (M, ρ)) P M M, ρ = ϕ M, ρ = ϕ M, ρ = ϕ ψ M, ρ = ϕ and M, ρ = ψ M, ρ = ϕ ψ M, ρ = ϕ or M, ρ = ψ M, ρ = v.ϕ m U M.M, ρ[v m] = ϕ M, ρ = v.ϕ m U M.M, ρ[v m] = ϕ 2.3 Sequent calculus Question: Given a first-order formula ϕ, how can we be assured that ϕ is valid? For propositional logic, we could just enumerate all interpretations and check that each one satisfies ϕ. For first order logic, this is impossible there are infinitely many stuctures! One answer to this question is to define a proof calculus, which is a formal system for deriving new truths from old old ones. In particular, we will define a sequent calculus. A judgement of a sequent calculus is a sequent Γ ϕ, where Γ is a set of formulas and ϕ is a formula. A sequent Γ ϕ should be read as Any structure which satisfies every formula in Γ also satisfies ϕ. 7

The inference rules are as follows: Identity -R 1 Γ ϕ -R 2 Γ ψ -R Γ ϕ Γ ψ -L Γ, ϕ 1, ϕ 2 ψ ϕ ϕ Γ ϕ ψ Γ ϕ ψ Γ ϕ ψ Γ, ϕ 1 ϕ 2 ψ -L Γ, ϕ 1 ψ Γ, ϕ 2 ψ Γ, ϕ 1 ϕ 2 ψ -L Γ ϕ Γ, ϕ ψ -R Γ false Γ ϕ -R Γ ϕ[x a] Γ x.ϕ a fresh -R Γ ϕ[x t] Γ x.ϕ -L Γ, ϕ[x t] ϕ Γ, x.ϕ ψ -L Γ ϕ Γ, x.ϕ ψ a fresh Theorem 2.4 (Soundness). For any set of assumptions Γ and any formula ϕ, if Γ ϕ then Γ ϕ. Proof. By induction on the derivation of the judgement Γ ϕ. The other direction is more difficult prove, but does hold: Theorem 2.5 (Completeness, [Gödel, 1929]). For any set of assumptions Γ and any formula ϕ, if Γ ϕ then Γ ϕ. 2.4 Theories Definition 2.6 (Theory). Let Σ be a first-order signature. A Σ-theory T is a set of Σ-sentences which is closed under deduction (i.e., if ϕ T and ϕ ψ, then ψ T ). Let Σ be a first-order signature, and let A be a set of Σ-sentences. Then A generates a theory, which we call T. We say that the set A axiomatizes T. If T is axiomatized by a recursive (i.e., decidable) set of axioms, then we say that T is recursively axiomatizable. Example 2.2. The theory of partial orders (over the signature ( ; /2)) has three axioms: Reflexivity: a.a a 8

Transitivity: a. b. c.(a b b c) a c Anti-symmetry: a. b.a b b a A theory T is decidable if there is a procedure which decides membership in T. As nice as it would be to pick either recursive or decidable and stick to it, nobody says decidably axiomatizable or recursive theory. Exercise 2.1. Let T be a recursively axiomatizable theory. Prove that: 1. Proof checking is decidable. 2. T is recursively enumerable (semi-decidable). Some examples of decidable theories: Equality logic Linear rational/integer/mixed arithmetic Bitvector arithmetic The ground fragment of some theories is decidable (i.e., there is a procedure which decides membership in the theory, but only for ground (quantifierfree) formulas): The theory axiomatized by Linear arithmetic with uninterpreted function symbols. A formula ϕ is T -satisfiable if there is some model of T which is a model of ϕ. A set of formulas Γ T -entails a formula ϕ, written Γ = T ϕ, if every model T that satisfies all formulas in Γ satisfies ϕ as well. Ground T -satisfiability problem: determine whether a given ground formula is T -satisfiable. Like SAT, SMT is intractable in theory, there but there are tools (see http://www.smtcomp.org/) and algorithms (DPLL(T )) which work well in practice. 9

References [Cook, 1971] Cook, S. A. (1971). The complexity of theorem-proving procedures. In Proceedings of the Third Annual ACM Symposium on Theory of Computing, STOC 71, pages 151 158, New York, NY, USA. ACM. [Davis et al., 1962] Davis, M., Logemann, G., and Loveland, D. (1962). A machine program for theorem-proving. Commun. ACM, 5(7):394 397. [Davis and Putnam, 1960] Davis, M. and Putnam, H. (1960). A computing procedure for quantification theory. J. ACM, 7(3):201 215. [Gödel, 1929] Gödel, K. (1929). Über die Vollständigkeit des Logikkalküls. PhD thesis, University Of Vienna. [Selman et al., 1992] Selman, B., Levesque, H., and Mitchell, D. (1992). A new method for solving hard satisfiability problems. In Proceedings of the Tenth National Conference on Artificial Intelligence, AAAI 92, pages 440 446. AAAI Press. 10