Tecniche di Verifica. Introduction to Propositional Logic

Similar documents
Language of Propositional Logic

Comp487/587 - Boolean Formulas

A brief introduction to Logic. (slides from

Propositional Logic: Models and Proofs

Propositional Logic Basics Propositional Equivalences Normal forms Boolean functions and digital circuits. Propositional Logic.

Logic: Propositional Logic (Part I)

SAT Solvers: Theory and Practice

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

Propositional and Predicate Logic - II

Chapter 4: Classical Propositional Semantics

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

Propositional Logic Language

Propositional Calculus: Formula Simplification, Essential Laws, Normal Forms

Solutions to Sample Problems for Midterm

02 Propositional Logic

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

Advanced Topics in LP and FP

CSE 555 HW 5 SAMPLE SOLUTION. Question 1.

Normal Forms of Propositional Logic

Truth-Functional Logic

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

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

ECE473 Lecture 15: Propositional Logic

Compound Propositions

Automated Program Verification and Testing 15414/15614 Fall 2016 Lecture 2: Propositional Logic

Part 1: Propositional Logic

UNIT-I: Propositional Logic

Propositional Logic and Semantics

Lecture 4: Proposition, Connectives and Truth Tables

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

CS 512, Spring 2017, Handout 10 Propositional Logic: Conjunctive Normal Forms, Disjunctive Normal Forms, Horn Formulas, and other special forms

Learning Goals of CS245 Logic and Computation

Section 1.2 Propositional Equivalences. A tautology is a proposition which is always true. A contradiction is a proposition which is always false.

Knowledge representation DATA INFORMATION KNOWLEDGE WISDOM. Figure Relation ship between data, information knowledge and wisdom.

CHAPTER 4 CLASSICAL PROPOSITIONAL SEMANTICS

Lecture 2. Logic Compound Statements Conditional Statements Valid & Invalid Arguments Digital Logic Circuits. Reading (Epp s textbook)

CS156: The Calculus of Computation

7. Propositional Logic. Wolfram Burgard and Bernhard Nebel

Conjunctive Normal Form and SAT

Critical Reading of Optimization Methods for Logical Inference [1]

Propositional Logic Part 1

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

CSE 20 DISCRETE MATH WINTER

Logical Structures in Natural Language: Propositional Logic II (Truth Tables and Reasoning

Lecture 2 Propositional Logic & SAT

Tautologies, Contradictions, and Contingencies

Lecture 7. Logic. Section1: Statement Logic.

PROPOSITIONAL LOGIC. VL Logik: WS 2018/19

Propositional and First Order Reasoning

Announcements. CS243: Discrete Structures. Propositional Logic II. Review. Operator Precedence. Operator Precedence, cont. Operator Precedence Example

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

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

Conjunctive Normal Form and SAT

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

CSE20: Discrete Mathematics for Computer Science. Lecture Unit 2: Boolan Functions, Logic Circuits, and Implication

Announcements. CS311H: Discrete Mathematics. Propositional Logic II. Inverse of an Implication. Converse of a Implication

Foundations of Artificial Intelligence

Foundations of Artificial Intelligence

Conjunctive Normal Form and SAT

Propositional Logic. Logic. Propositional Logic Syntax. Propositional Logic

Foundations of Artificial Intelligence

EECS 1028 M: Discrete Mathematics for Engineers

Propositional Logic. Yimei Xiang 11 February format strictly follow the laws and never skip any step.

Formal Verification Methods 1: Propositional Logic

1 Propositional Logic

Informal Statement Calculus

Inference in Propositional Logic

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

COMP9414: Artificial Intelligence Propositional Logic: Automated Reasoning

3 Propositional Logic

A statement is a sentence that is definitely either true or false but not both.

Intelligent Agents. Pınar Yolum Utrecht University

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

Deductive Systems. Lecture - 3

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

Propositional Resolution

Propositional logic. Programming and Modal Logic

Warm-Up Problem. Is the following true or false? 1/35

Topic 1: Propositional logic

Automata Theory CS Complexity Theory I: Polynomial Time

Logic as a Tool Chapter 1: Understanding Propositional Logic 1.1 Propositions and logical connectives. Truth tables and tautologies

Supplementary exercises in propositional logic

More Propositional Logic Algebra: Expressive Completeness and Completeness of Equivalences. Computability and Logic

CS206 Lecture 03. Propositional Logic Proofs. Plan for Lecture 03. Axioms. Normal Forms

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

CS250: Discrete Math for Computer Science. L6: CNF and Natural Deduction for PropCalc

COMP219: Artificial Intelligence. Lecture 20: Propositional Reasoning

Chapter 7 R&N ICS 271 Fall 2017 Kalev Kask

CS:4420 Artificial Intelligence

Boolean Algebra. Philipp Koehn. 9 September 2016

Logical Agents. Chapter 7

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

Propositional logic II.

Chapter 2: Introduction to Propositional Logic

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

Logic and Inferences

LOGIC PROPOSITIONAL REASONING

Essential facts about NP-completeness:

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

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

Transcription:

Tecniche di Verifica Introduction to Propositional Logic 1

Logic A formal logic is defined by its syntax and semantics. Syntax An alphabet is a set of symbols. A finite sequence of these symbols is called an expression. A set of rules defines the well-formed expressions (wellformed femulae or wff s). Semantics Gives meaning to well-formed expressions Formal notions of induction and recursion are required to provide a rigorous semantics. 2

Propositional (Boolean) Logic Propositional logic is simple but extremely important in Computer Science 1. It is the basis for day-to-day reasoning (e.g., in programming) 2. It is the theory behind digital circuits. 3. Many problems can be translated into propositional logic. 4. It is an important part of more complex logics, such as: First-Order Logic (also called Predicate Logic), Modal and Temporal logic, which we will discuss later. 3

Propositional Logic: Syntax Alphabet ( Left parenthesis Begin group ) Right parenthesis End group Negation symbol English: not Conjunction symbol English: and Disjunction symbol English: or (inclusive) Conditional symbol English: if, then Bi-conditional symbol English: if and only if A 1 First propositional symbol A 2 Second propositional symbol A N N-th propositional symbol We are assuming a countable alphabet, but most of our conclusions hold equally well for an uncountable alphabet. 4

Propositional Logic: Syntax Alphabet Propositional connective symbols:,,,, Logical symbols:,,,,, (, ). Parameters or nonlogical symbols: A 1, A 2, A 3,... The meaning of logical symbols is always the same. The meaning of nonlogical symbols depends on the context. From now on, let AP be the set {A 1, A 2, A 3,...}, called the set of atomic propositions. 5

Propositional Logic: Syntax A propositional expression is a sequence of symbols. A sequence is denoted explicitly by a comma separated list enclosed in angle brackets: Examples (, A 1,, A 3, ) (A 1 A 3 ) (, (,, A 1, ),, A 2, ) (( A 1 ) A 2 ) ), ),, A 1,, A 5 )) A 1 A 5 We will write these sequences as simple strings of symbols, with the understanding that the formal structure represented is a sequence containing exactly the symbols in the string. The formal meaning becomes important when trying to prove things about expressions. We want to restrict the kinds of expressions that will be allowed. 6

Propositional Logic: Syntax Let us define the set W of well-formed formulas (wff s). (a) Every expression consisting of a single propositional symbol is in W (AP W); (b) If and are in W, then so are ( ), ( ), ( ), ( ) and ( ); (c) No other expression is in W. This definition is inductive: the set being defined is used as part of the definition. How would you use this definition to prove that the expression ( A 1 A 5 ) is not a wff? 7

Propositional Logic: Semantics Intuitively, given a wff and the truth value (either true or false ) for each propositional symbol in (the atomic propositions), we should be able to determine the truth value of. How do we make this precise? Let be a function from AP to {0,1}, where 0 represents false and 1 represents true. Recall that in the inductive definition of wff s, AP contains the propositional symbols. Any function defined as above is called truth assignment, and represent a possible propositional model. Now, we define the satisfaction relation elements of W. between and 8

Propositional Logic: Semantics Let be a function from AP to {0,1}, where 0 represents false and 1 represents true. The satisfaction relation between and elements of W is defined inductively as follows: A i if and only if (A i ) = 1 ( ) if and only if ( ) if and only if and ( ) if and only if or ( ) if and only if or ( ) if and only if if and only if 9

Truth Tables There are other ways to present the semantics which are less formal but perhaps more intuitive. 10

Truth Tables: Examples Truth tables can be used to calculate all possible truth values for a given wff with respect to any possible assignment There is a row for each possible truth assignment to the propositional atoms and connectives. 11

Satisfiability and Validity A wff is satisfiable if there exists some truth assignment which satisfies. Suppose is a set of wff s. Then tautologically implies, or, if every truth assignment which satisfies each formula in also satisfies. Particular cases: If, then we say is a tautology or is valid and we write If is unsatisfiable, then for every wff If (shorthand for { } ) and, then and are tautologically equivalent. if and only if the wff is valid ( ). 12

Some Tautologies 13

More Tautologies 14

Examples Suppose you have an algorithm SAT which would take a wff as input and return true if is satisfiable and false otherwise. How would you use this algorithm to verify each of the claims made above? 15

Examples Suppose you have an algorithm SAT which would take a wff as input and return true if is satisfiable and false otherwise. How would you use this algorithm to verify each of the claims made above? 16

Examples Now suppose you had an algorithm CHECKVALID which returns true when is valid and false otherwise. How would you verify the claims given this algorithm? Satisfiability and validity are dual notions: is unsatisfiable if and only if is valid. 17

Satisfiability with Truth Tables An Algorithm for Satisfiability To check whether is satisfiable, form the truth table for. If there is a row in which 1 appears as the value for, then is satisfiable. Otherwise, is unsatisfiable. Notice that this algorithm has exponential complexity, since the number of different rows in a truth table is exponential (2 n ) in the number n of atomic propositions occurring in. An Algorithm for Tautological Implication To check whether { 1,, k }, check the satisfiability of the wff ( 1 k ) ( ). If it is unsatisfiable, then { 1,, k }, otherwise { 1,, k }. Notice also that the computational complexity of the propositional satisfiability is NP-Complete! 18

Boolean Functions f : Domain Range Boolean function: Domain = {0, 1} n = {0,1}. {0,1}. Range = {0, 1} f is a function of n boolean variables. How many boolean functions of 3 variables are there? 19

Boolean Functions f : Domain Range Boolean function: Domain = {0, 1} n = {0,1}. {0,1}. Range = {0, 1} f is a function of n boolean variables. How many boolean functions of 3 variables are there? Answer : 2 23 = 2 8! There are 2 3 different input points and 2 possible output values for each input point. 2 23 is also the number of different n-ary propositional connectives 20

Boolean Functions & Truth Tables x y z g 0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 1 1 1 g : {0, 1} {0, 1} {0, 1} {0, 1} 21

Boolean Expressions Given a set of Boolean variables x,y, and the constants 1 (true) and 0 (false): t ::= x 0 1 t t t t t t t t t The semantics of Boolean Expressions is defined by means of truth tables as usual. Given an ordering of Boolean variables, Boolean expressions can be used to express Boolean functions. 22

Boolean expressions Boolean functions can also be represented as boolean (propositional) expressions. x y represents the function: f : {0, 1} {0, 1} {0, 1} f(0, 0) = f(0, 1) = f(1, 0) = f(1, 1) = 23

Boolean expressions Boolean functions can also be represented as boolean (propositional) expressions. x y represents the function: f : {0, 1} {0, 1} {0, 1} f(0, 0) = 0 f(0, 1) = 0 f(1, 0) = 0 f(1, 1) = 1 24

Boolean functions and expressions x y z g 0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 1 1 1 g : {0, 1} {0, 1} {0, 1} {0, 1} g = ((x y) z) ((x y) z) 25

Boolean expressions and functions x y z g 0 0 0 0 0 1 g = (x y z) (x y z) ( x y) 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 26

Boolean expressions and functions x y z g 0 0 0 0 0 0 1 0 g = (x y z) (x y z) ( x y) 0 1 0 1 0 1 1 1 1 0 0 0 g : {0, 1} {0, 1} {0, 1} {0, 1} 1 0 1 1 1 1 0 1 1 1 1 0 27

Three Representations Boolean functions Truth tables Propositional formulas. Three equivalent representations. We will look at a a fourth one later in the course. 28

Boolean Functions and Connectives For each n, there are 2 2n different n-place Boolean functions. There are 2 n different input points and 2 possible output values for each input point. 2 2n is also the number of different n-ary propositional connectives. 0-ary connectives There are two 0-place Boolean functions: the constants 0 and 1. We can construct corresponding 0-ary connectives and T with the meaning that and T regardless of the truth assignment. Unary connectives There are four 1-place Boolean functions, but these include the two constant functions mentioned above and the identity function. Thus the only additional connective of interest is negation:. Binary connectives There are sixteen 2-place Boolean functions. They are cataloged in the following table. Note that the first six correspond to 0-ary and unary connectives. 29

Binary Connectives 30

Example: Curcuits and PL 31

Normal Forms: DNF Normal forms in mathematics are canonical representations (i.e. all equivalent objects result in the same representation). Definition: A formula with A 1,A 2,,A n propositional variables is in Disjunctive Normal Form (DNF) if it is has the structure: (x 1 1 x 1 2 x 1 n) (x m 1 x m 2 x m n) where m 2 n and for i = 1,,n and j = 1,,m, x j i is either A i or A i (both A i and A i are called literals). E.g. ( A 1 A 2 A 3 ) (A 1 A 2 A 3 ) is in DNF ( (A 1 A 2 ) A 3 ) is not. Each of the series of conjunctions picks out a row of the truth table where formula is true. DNF ORs together the ANDs for the true rows. 32

DNF Consider the truth tables for the formulas p q r and p q r for p q r only row 1 is true; for p q r only row 3 is true; for p q r only row 6 is true. 33

DNF Consider the truth tables for the formulas p q r and p q r ( p q r) ( p q r) (p q r) is true on rows 1, 3 and 6 34

DNF Theorem: Every propositional formula that is not a contradiction is a logically equivalent to a DNF formula. Corollary: For, not contradictions, if and only if and have the same DNF representation. Proof: Two formulas are logically equivalent if and only if they have the same truth table (i.e. same true rows) and, thus, the same DNF. 35

DNF and Satisfiability Theorem: Satisfiability of propositional formula in DNF can be checked on Polynomial Time. Proof: Every formula in DNF is a disjunction of clauses. Therefore, the only possibility for the formula to be unsatisfiable is if every clause in isolation is unsatisfiable. Since every clause is a conjunction of literals, for a clause of a DNF formula to be unsatisfiable, it must contain both some literal (p) and its complement ( p). Therefore, every DFN formula is satisfiable unless every clause contains a pair of complementary literals. And this can easily be checked in Polynomial Time. 36

CNF Definition: A formula with A 1,A 2,,A n propositional variables is in Conjunctive Normal Form (CNF) if it is has the structure: (x 1 1 x 1 2 x 1 n) (x m 1 x m 2 x m n) where m 2 n, for i = 1,,n and j = 1,,m, x j i is either A i or A i. E.g. ( A 1 A 2 A 3 ) (A 1 A 2 A 3 ) is in CNF ( (A 1 A 2 ) A 3 ) is not. Each of the series of disjunctions represents the negation of a row of the truth table where formula is false. CNF ANDs together the ORs corresponding to the negation of the flase rows. One way to obtain the CNF form of a formula is to write down the DNF for, then negate it and apply De Morgan s lows as much as possilbe. 37

CNF and Validity Using CNF to Check (trivial) (x 1 1 x 1 2 x 1 n) (x m 1 x m 2 x m n) if and only if (x 1 1 x 1 2 x 1 n) (x 2 1 x 2 2 x 2 n) (x m 1 x m 2 x m n) If each x j i is a literal (e.g., p) or its negation (e.g., p) then (x j 1 x j 2 x j n) iff there exists k and l s.t. x j k = p and x j l = p. And this can easily be checked in Polynomial Time. 38

SAT complexity revisited Question: So why are not validity and satisfiability polynomial problems? Answer: Since converting a formula into an equivalent DNF or CNF can be exponential in size of the original formula. Example: CNF: (A 1 B 1 ) (A 2 B 2 ) (A n B n ) DNF: (A 1 A 2 A n ) (A 1 A 2 B n ) (A 1 A 2 B n-1 A n ) (A 1 A 2 B n-1 B n ) (B 1 B 2 B n ) In worlds, while the CNF formula contains n clauses, the DNF equivalent formula contains 2 n clauses, where each clause contains, for each i, either A i or B i. 39