Stanford University CS103: Math for Computer Science Handout LN9 Luca Trevisan April 25, 2014

Similar documents
Mat 243 Exam 1 Review

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

Introduction to Decision Sciences Lecture 2

Logical Operators. Conjunction Disjunction Negation Exclusive Or Implication Biconditional

CSC Discrete Math I, Spring Propositional Logic

Logic. Definition [1] A logic is a formal language that comes with rules for deducing the truth of one proposition from the truth of another.

Proofs. Joe Patten August 10, 2018

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

Proposition/Statement. Boolean Logic. Boolean variables. Logical operators: And. Logical operators: Not 9/3/13. Introduction to Logical Operators

1 Completeness Theorem for Classical Predicate

EECS 1028 M: Discrete Mathematics for Engineers

Logic and Proofs. (A brief summary)

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

1 Propositional Logic

Learning Goals of CS245 Logic and Computation

Mathematical Logic Part One

HANDOUT AND SET THEORY. Ariyadi Wijaya

Proofs Propositions and Calculuses

Boolean Logic. CS 231 Dianna Xu

Introducing Proof 1. hsn.uk.net. Contents

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

Packet #1: Logic & Proofs. Applied Discrete Mathematics

Introduction to Sets and Logic (MATH 1190)

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

Discrete Mathematical Structures. Chapter 1 The Foundation: Logic

Propositional Logic and Semantics

For all For every For each For any There exists at least one There exists There is Some

2/2/2018. CS 103 Discrete Structures. Chapter 1. Propositional Logic. Chapter 1.1. Propositional Logic

Lecture 5 : Proofs DRAFT

CS 2800: Logic and Computation Fall 2010 (Lecture 13)

Numbers that are divisible by 2 are even. The above statement could also be written in other logically equivalent ways, such as:

Topic 1: Propositional logic

5. Use a truth table to determine whether the two statements are equivalent. Let t be a tautology and c be a contradiction.

Foundation of proofs. Jim Hefferon.

Compound Propositions

Discrete Mathematics and Its Applications

Exercise Set 1 Solutions Math 2020 Due: January 30, Find the truth tables of each of the following compound statements.

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

Mathematical Logic Part One

THE LOGIC OF COMPOUND STATEMENTS

CSE 20. Final Review. CSE 20: Final Review

Discrete Mathematics and Probability Theory Spring 2014 Anant Sahai Note 1

Gödel s Completeness Theorem

Propositional and Predicate Logic

THE LOGIC OF QUANTIFIED STATEMENTS

Before you get started, make sure you ve read Chapter 1, which sets the tone for the work we will begin doing here.

3/29/2017. Logic. Propositions and logical operations. Main concepts: propositions truth values propositional variables logical operations

Review of Predicate Logic

Mathematical Logic Part One

Recall that the expression x > 3 is not a proposition. Why?

First Order Logic: Syntax and Semantics

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

3 The Semantics of the Propositional Calculus

Discrete Mathematics and Probability Theory Fall 2012 Vazirani Note 1

Propositional and Predicate Logic

Conjunction: p q is true if both p, q are true, and false if at least one of p, q is false. The truth table for conjunction is as follows.

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

Logic and Proofs. (A brief summary)

Foundations of Mathematics MATH 220 FALL 2017 Lecture Notes

Logic Overview, I. and T T T T F F F T F F F F

Logic and Propositional Calculus

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

Why Learning Logic? Logic. Propositional Logic. Compound Propositions

1.1 Language and Logic

Discrete Mathematics & Mathematical Reasoning Predicates, Quantifiers and Proof Techniques

CHAPTER 10. Gentzen Style Proof Systems for Classical Logic

cse 311: foundations of computing Fall 2015 Lecture 6: Predicate Logic, Logical Inference

Lecture Notes 1 Basic Concepts of Mathematics MATH 352

CHAPTER 2. FIRST ORDER LOGIC

AI Principles, Semester 2, Week 2, Lecture 5 Propositional Logic and Predicate Logic

Propositional Logic Not Enough

Predicate Calculus - Syntax

CS70 is a course about on Discrete Mathematics for Computer Scientists. The purpose of the course is to teach you about:

1.1 Language and Logic

2/18/14. What is logic? Proposi0onal Logic. Logic? Propositional Logic, Truth Tables, and Predicate Logic (Rosen, Sections 1.1, 1.2, 1.

Introduction to Metalogic 1

Lecture 11: Measuring the Complexity of Proofs

A Little Deductive Logic

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

Review. Propositional Logic. Propositions atomic and compound. Operators: negation, and, or, xor, implies, biconditional.

Chapter 2: The Logic of Quantified Statements. January 22, 2010

Unit 1. Propositional Logic Reading do all quick-checks Propositional Logic: Ch. 2.intro, 2.2, 2.3, 2.4. Review 2.9

2. The Logic of Compound Statements Summary. Aaron Tan August 2017

Logic and Propositional Calculus

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

A Little Deductive Logic

Equivalence and Implication

Direct Proof and Proof by Contrapositive

Logic, Sets, and Proofs

Logic. Logic is a discipline that studies the principles and methods used in correct reasoning. It includes:

Logic. Readings: Coppock and Champollion textbook draft, Ch

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

Discrete Structures for Computer Science

Logic. Quantifiers. (real numbers understood). x [x is rotten in Denmark]. x<x+x 2 +1

Introduction to Metalogic

Tecniche di Verifica. Introduction to Propositional Logic

Introduction to first-order logic:

Math 10850, fall 2017, University of Notre Dame

Supplementary Logic Notes CSE 321 Winter 2009

CS Module 1. Ben Harsha Apr 12, 2017

Transcription:

Stanford University CS103: Math for Computer Science Handout LN9 Luca Trevisan April 25, 2014 Notes for Lecture 9 Mathematical logic is the rigorous study of the way in which we prove the validity of mathematical statements. One of the applications of mathematical logic is that it provides a precise language to express mathematical statements and to write completely rigorous proofs. The simplest type of logical system is propositional logic. Propositional logic formalizes simple reasoning by cases and the meaning of negation, of implication, and of other ways to combine simpler statements into more complex ones. First-order logic is a more expressive formalism that, with some hacks, suffices to represent statements about integers and about computer programs, induction and so on. Second-order logic, which we will not talk about, is a generalization of firstorder logic that works well to talk about real and complex numbers, and to formalize calculus, real and complex analysis, and more or less all of pure mathematics. 1 Propositional Logic A proposition is a statement that can be true or false. Propositional logic studies how to reason about the truth of propositions and how the truth of a proposition relates to the truth of another one. Every statement in propositional logic is an expression that is built up from propositional variables, by combining them with logical connectives. Propositional variables are usually denoted with letters like p, q, 1 etc., and they are meant to stand for the propositions that we are interested in, that is statements like 2 < 4, life will pass me by, I don t open up my eyes, and so on. The connectives express how propositions are related, for example one can connect two propositions with an implication as in if I don t open up my eyes, life will pass me by. Propositional logic allows us to reason that the above proposition means the same as if life doesn t pass me by, then I have opened up my eyes and also the same as either I open up my eyes, or life will pass me by 1 We will also use letters like p, q,..., to stand for propositions. Hopefully this will not cause confusion. 1

The logical connectives of propositional logic are: Logical NOT written. If p is a proposition, then p (pronounced not p ) is a proposition, and p is true if p is false, and vice versa; Logical AND written. If p and q are propositions, then p q (pronounced p and q ) is a proposition, and it is true if and only if both p and q are true; Logical OR written. If p and q are propositions, then p q (pronounced p or q ) is a proposition, and it is true if at least one of p and q are true; Logical Implication written. If p and q are propositions, then p q (pronounced p implies q ) is a proposition, and it is true unless p is true and q is false; Biconditional written. If p and q are propositions, then p q (pronounced p if and only if q ) is a proposition, and it is true if and only if the truth values of p and q are the same. (Meaning they are either both true or both false.) We also have two special symbols: is a proposition, and it is always true, and is a proposition and it is always false. For a given proposition p, it is often helpful to construct its truth table, that is the list of all the possible truth values of the propositional variables occurring in p, together with the corresponding truth value of the proposition. Here are the truth values of the propositions obtained by applying the logical connectives to propositional variables. p p F T T F p q p q F F F F T F T F F T T T p q p q F F F F T T T F T T T T 2

p q p q F F T F T T T F F T T T p q p q F F T F T F T F F T T T The precedence of the operators is that binds the closest, followed by,, and. This means that the proposition is parsed as p q r q r ((( p) q) r) (q r) To construct the truth table of a complex proposition p one can first parse it, and then construct the truth tables of all the smaller propositions into which we have parsed p, starting from the smallest ones. For example, p q r p p q q r ( p q) r (( p q) r) (q r) F F F T F F F T F F T T F F T F F T F T T F T F F T T T T T T T T F F F F F F T T F T F F F T F T T F F F F F T T T T F F T T T Two propositions are logically equivalent if they have the same truth value for every possible assignment of truth values to the propositional variables that they contain. If propositions p and q are logically equivalent, then we write p q. Here are some important logical equivalences. The first two are called De Morgan s laws. (p q) p q (1) 3

(p q) p q (2) p q p q (3) p q (p q) (q p) (4) Note that these equivalences imply that every proposition can be transformed into an equivalent one that involves only the use of the connectives and, or only the use of the connectives and. Another example of equivalence is that the propositions p q and q p are logically equivalent. An easy way to verify equivalence of simple propositions is to construct their truth tables, and verify that they are identical. Note that for two propositions to be logically equivalent they do not need to be defined over the same set of propositional variables: for example, p ( p q) is logically equivalent to p. 2 The notion of logical equivalence is one of the useful features of propositional logic: given a complex mathematical statement, we can replace various parts of the statement with propositional variables and obtain a proposition, then change the resulting proposition to a logically equivalent one, and finally replace back the propositional variables with the original statements. The new mathematical statement will be equivalent to the original one, regardless of the meaning and of the truth-value of the original statement. For example, applying this approach to the equivalence p q q p we obtain proofs by contrapositive. A proposition that is true for all the possible truth-values of its propositional variables is called a tautology. For example, p (p q) is a tautology. Note that p q holds if and only if the proposition p q is a tautology. 2 First-Order Logic In first-order logic, besides having propositional variables and boolean connectives, we have quantifiers, predicates, and functions. 2 We can use truth-tables in order to check the logical equivalence of two propositions that involve different sets of propositional values: we just list, in the construction of the truth-table, all the possible truth-values of all the variables occurring in either of the two propositions. 4

It is easier to start from a couple of concrete examples of what a first-order sentence looks like. The first-order sentence corresponding to the statement If n is a natural number, then n 2 is odd if and only if n is odd becomes n.nat(n) (odd(square(n)) odd(n)) The statement you can fool some of the people all of the time becomes x.person(x) ( t.time(t) canf ool(x, t)) The statement you can fool all of the people some of the time becomes x.person(x) t.(time(t) canf ool(x, t)) In the above examples, odd( ), person( ), time( ) and canf ool(, ) are predicates, that is, they are properties that may or may not be true for the objects that we give to them in input. The arity of a predicate is the number of objects that it takes as input. Then we have variables, like x, t, n, which are bound by the quantifiers and. A sentence of the form x.s is true if the sentence S is true for every possible assignment of x to any object; a sentence of the form x.s is true if there if there is an object whose value we can assign to x so that S is true. We also have functions, such as square( ) that take as input a certain number of objects and output an object. The arity of a function is the number of inputs it takes. A predicate can have arity zero, in which case we call it a propositional symbol, and a function can have arity zero, in which case we call it a constant. Finally, we have the same boolean connectives that we have already studied in the setting of propositional logic. In order to understand the meaning of a sentence in first-order logic we need to know what is the set of all possible objects (called the universe) that the quantifiers refer to, what are the values of the propositional symbols and constants, and what are the values that the various predicates and functions return for each possible input. This information is called a model for the sentence. In a given model, a sentence is either true or false. A sentence is valid if it is true in every model. The useful feature of first-order logic is that if we can prove that a given sentence is valid, then we know that the statement it formalizes is true, without having to know what any of the functions or predicates appearing in the sentence even mean. 5

Two sentences are equivalent if, in every model, they have the same truth-value. Here are some more details (but not a completely rigorous treatment) of what are sentences in first-order logic. Variables and constants are terms If f( ) is a k-ary function, and t 1,..., t k are k terms, then f(t 1,..., t k ) is also a term A propositional symbol is a sentence If P ( ) is a k-ary predicate, and t 1,..., t k are k terms, then P (t 1,..., t k ) is a sentence If t 1 and t 2 are terms, then t 1 = t 2 is a sentence If S is a sentence and x is a variable, then x.s is a sentence If S is a sentence and x is a variable, then x.s is a sentence If S and T are sentences, then the following are sentences: S, S T, S T, S T, S T. A sentence is well-formed if all its variables are bound. The definition of bound versus free variables is as follows: in a term t, all the variables occurring in t are free. If P ( ) is a k-ary predicate and t 1,..., t k are terms, then P (t 1,..., t k ) is a sentence whose free variables are all the variables occurring in the terms. If S is a sentence in which x is a free variables, then x.s and x.s are sentences in which x is bound by the quantifier. (Being bound is the same as not being free.) When we construct a sentence by joining other sentences with boolean connectors, then the set of free variables of the resulting sentence is the union of the sets of free variables of the sentences that we started from. For example, in x.(a(x, y) ( z.b(x, y, z))) the variables x and z are bound, but y is free, and so the above sentence is not a well-formed sentence. Also note that in the sentence x.a(x, y) ( y.b(x, y)) 6

the first occurrence of y is free, but the second occurrence is bound, which means that the above sentence is not well formed. There is a general theory of how to write proofs of validity of first-order sentences, but it goes beyond the scope of this course to discuss it. In practice, mathematical statements as they appear in textbooks and research papers are formulated using a mix of first-order logic notation and plain English, just like pseudo-code in programming textbooks and computer science research papers is a mix of plain English and of valid commands in programming languages like C or Python. In order to understand those statements, it is enough to understand the meaning of the symbols described above, and in order to follow proofs involving this notation, it is enough to be familiar with certain basic equivalences between first-order sentences. First of all, all the equivalences of propositional logic are still true, and they can be applied within a sentence of first-order logic. For example, the sentence is equivalent to x y.(a(x) B(y)) x y.( B(y) A(x)) Another observation is that if you have two quantifications of the same type binding variables in the same sentence, then the order of quantification is not important. For example, the sentence x. y.s where S is a sentence in which x and y are free is equivalent to and is equivalent to y. x.s x y.s y x.s If you have different quantifiers, however, you cannot exchange them: the sentence x y.(integer(x) (integer(y) smaller(x, y))) which says that for every integer x there is a bigger integer y is true (in the model in which integer(x) is true if x is an integer and smaller(x, y) is true if x is smaller than y), but the sentence y x.(integer(x) (integer(y) smaller(x, y))) 7

means, in the same model, that there is an integer y which is bigger than all other integers, which is false. So the two sentences are not equivalent because there is a model in which the first is true but the second is false. When doing proofs by contradiction, it is important to be able to correctly negate a sentence. From the previous section, we know how to negate any expression involving only boolean connectives. Regarding quantifiers, the sentence is equivalent to x.s x. S which is intuitive: saying that it is not true that there is an x for which S is true is the same as saying for every x we have that S is false. Similarly, x.s is equivalent to x. S 8