Mathematical Logic Part One

Similar documents
Mathematical Logic Part One

Mathematical Logic Part One

Mathematical Logic Part One

Mathematical Logic Part One

Mathematical Logic Part One

Mathematical Logic Part One

Mathematical Logic Part One

Mathematical Logic Part Two

Outline for Today. What is an Implication? Negations and their Applications. Proof by Contrapositive. Proof by Contradiction

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

Outline for Today. What is an Implication? Negations and their Applications. Proof by Contrapositive. Proof by Contradiction

Mathematical Logic Part Three

Mathematical Logic Part Three

Mathematical Logic Part Three

HW1 graded review form? HW2 released CSE 20 DISCRETE MATH. Fall

Announcements. Problem Set 1 out. Checkpoint due Monday, September 30. Remaining problems due Friday, October 4.

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

Guide to Negating Formulas

Boolean Logic. CS 231 Dianna Xu

Discrete Mathematics and Its Applications

EECS 1028 M: Discrete Mathematics for Engineers

Propositional Logic. Fall () Propositional Logic Fall / 30

The Inductive Proof Template

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

Manual of Logical Style (fresh version 2018)

Compound Propositions

Finite Automata Part One

Course Staff. Textbook

Introducing Proof 1. hsn.uk.net. Contents

MITOCW ocw f99-lec09_300k

Proof: If (a, a, b) is a Pythagorean triple, 2a 2 = b 2 b / a = 2, which is impossible.

An Introduction to Logic 1.1 ~ 1.4 6/21/04 ~ 6/23/04

A Little Deductive Logic

Manual of Logical Style

Section 1.1: Logical Form and Logical Equivalence

Propositional logic ( ): Review from Mat 1348

Lesson 6: Algebra. Chapter 2, Video 1: "Variables"

CSC Discrete Math I, Spring Propositional Logic

NP-Completeness Part One

THE LOGIC OF COMPOUND STATEMENTS

A Little Deductive Logic

Mathematical Induction

CS103 Handout 09 Fall 2012 October 19, 2012 Problem Set 4

The statement calculus and logic

Definition 2. Conjunction of p and q

Lecture 02: Propositional Logic

Binary Relations Part Two

3 The Semantics of the Propositional Calculus

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

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

Checkpoint Questions Due Monday, October 1 at 2:15 PM Remaining Questions Due Friday, October 5 at 2:15 PM

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

What is Logic? Introduction to Logic. Simple Statements. Which one is statement?

UNIT-I: Propositional Logic

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

AMTH140 Lecture 8. Symbolic Logic

Propositions. Frequently, we will use the word statement instead of proposition.

Deduction by Daniel Bonevac. Chapter 3 Truth Trees

MITOCW ocw f99-lec17_300k

Math.3336: Discrete Mathematics. Applications of Propositional Logic

Ella failed to drop the class. Ella dropped the class.

Logical Operators. Conjunction Disjunction Negation Exclusive Or Implication Biconditional

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

MITOCW ocw f99-lec16_300k

MAT2345 Discrete Math

TRUTH TABLES LOGIC (CONTINUED) Philosophical Methods

CSE 20 DISCRETE MATH WINTER

2/13/2012. Logic: Truth Tables. CS160 Rosen Chapter 1. Logic?

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

15414/614 Optional Lecture 1: Propositional Logic

A Note on Turing Machine Design

Logic, Sets, and Proofs

Truth-Functional Logic

Logic. Def. A Proposition is a statement that is either true or false.

Chapter Summary. Propositional Logic. Predicate Logic. Proofs. The Language of Propositions (1.1) Applications (1.2) Logical Equivalences (1.

Discrete Mathematical Structures. Chapter 1 The Foundation: Logic

MITOCW watch?v=vjzv6wjttnc

Outline for Today. Modeling transformations between sets. Injections, surjections, and bijections.

CS103 Handout 08 Spring 2012 April 20, 2012 Problem Set 3

Recommended Reading. A Brief History of Infinity The Mystery of the Aleph Everything and More

Instructor (Brad Osgood)

CSE 311: Foundations of Computing I. Spring 2015 Lecture 1: Propositional Logic

Discrete Mathematics and Probability Theory Spring 2016 Rao and Walrand Note 1

MITOCW ocw f99-lec05_300k

Connectives Name Symbol OR Disjunction And Conjunction If then Implication/ conditional If and only if Bi-implication / biconditional

MITOCW MITRES_18-007_Part1_lec2_300k.mp4

Propositional Logic Not Enough

1 Propositional Logic

CSE 240 Logic and Discrete Mathematics

Topic 1: Propositional logic

PHIL12A Section answers, 16 February 2011

Predicates, Quantifiers and Nested Quantifiers

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

Recap from Last Time

FUNDAMENTALS OF MATHEMATICS HANDOUT 1.3 DR. MCLOUGHLIN

Overview. 1. Introduction to Propositional Logic. 2. Operations on Propositions. 3. Truth Tables. 4. Translating Sentences into Logical Expressions

6.041SC Probabilistic Systems Analysis and Applied Probability, Fall 2013 Transcript Tutorial:A Random Number of Coin Flips

Mathematical Writing and Methods of Proof

Section 3.1 Statements, Negations, and Quantified Statements

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

Transcription:

Mathematical Logic Part One

Question: How do we formalize the definitions and reasoning we use in our proofs?

Where We're Going Propositional Logic (Today) Basic logical connectives. Truth tables. Logical equivalences. First-Order Logic (Wednesday/Friday) Reasoning about properties of multiple objects.

Propositional Logic

A proposition is a statement that is, by itself, either true or false.

Some Sample Propositions Puppies are cuter than kittens. Kittens are cuter than puppies. Usain Bolt can outrun everyone in this room. CS103 is useful for cocktail parties. This is the last entry on this list.

More Propositions They say time's supposed to heal ya. But I ain't done much healing. I'm in California dreaming about who we used to be. I've forgotten how it felt before the world fell at our feet. There's such a difference between us.

Things That Aren't Propositions Commands Commands cannot cannot be be true true or or false. false.

Things That Aren't Propositions Questions Questions cannot cannot be be true true or or false. false.

Things That Aren't Propositions The The first first half half isis aa valid valid proposition. proposition. I am the walrus, goo goo g'joob Jibberish Jibberish cannot cannot be be true true or or false. false.

Propositional Logic Propositional logic is a mathematical system for reasoning about propositions and how they relate to one another. Every statement in propositional logic consists of propositional variables combined via propositional connectives. Each variable represents some proposition, such as You liked it or You should have put a ring on it. Connectives encode how propositions are related, such as If you liked it, then you should have put a ring on it.

Propositional Variables Each proposition will be represented by a propositional variable. Propositional variables are usually represented as lower-case letters, such as p, q, r, s, etc. Each variable can take one one of two values: true or false.

Propositional Connectives Logical NOT: p Read not p p is true if and only if p is false. Also called logical negation. Logical AND: p q Read p and q. p q is true if both p and q are true. Also called logical conjunction. Logical OR: p q Read p or q. p q is true if at least one of p or q are true (inclusive OR) Also called logical disjunction.

Truth Tables A truth table is a table showing the truth value of a propositional logic formula as a function of its inputs. Useful for several reasons: They give a formal definition of what a connective means. They give us a way to figure out what a complex propositional formula says.

The Truth Table Tool

Summary of Important Points The connective is an inclusive or. It's true if at least one of the operands is true. Similar to the operator in C, C++, Java and the or operator in Python. If we need an exclusive or operator, we can build it out of what we already have.

Mathematical Implication

Implication The connective is used to represent implications. Its technical name is the material conditional operator. What is its truth table?

Why This Truth Table? The truth values of the are the way they are because they're defined that way. The intuition: We want p q to mean if p is true, q is true as well. The only way this doesn't happen is if p is true and q is false. In other words, p q should be true whenever (p q) is true. What's the truth table for (p q)?

Truth Table for Implication p F F T T q p q F T T T F F T T The The only only way way for for pp qq to to be be false false isis for for pp to to be be true true and and qq to to be be false. false. Otherwise, Otherwise, pp qq isis by by definition definition true. true.

The Biconditional Connective

The Biconditional Connective The biconditional connective is used to represent a two-directional implication. Specifically, p q means that p implies q and q implies p. What should its truth table look like?

Biconditionals The biconditional connective p q is read p if and only if q. Here's its truth table: p F F T T q p q F T T F F F T T One One interpretation interpretation of of isis to to think think of of itit as as equality: equality: the the two two propositions propositions must must have have equal equal truth truth values. values.

True and False There are two more connectives to speak of: true and false. The symbol is a value that is always true. The symbol is value that is always false. These are often called connectives, though they don't connect anything. (Or rather, they connect zero things.)

Proof by Contradiction Suppose you want to prove p is true using a proof by contradiction. The setup looks like this: Assume p is false. Derive something that we know is false. Conclude that p is true. In propositional logic: ( p ) p

Operator Precedence How do we parse this statement? x y z x y z Operator precedence for propositional logic: All operators are right-associative. We can use parentheses to disambiguate.

Operator Precedence How do we parse this statement? x y z x y z Operator precedence for propositional logic: All operators are right-associative. We can use parentheses to disambiguate.

Operator Precedence How do we parse this statement? ( x) y z x y z Operator precedence for propositional logic: All operators are right-associative. We can use parentheses to disambiguate.

Operator Precedence How do we parse this statement? ( x) y z x y z Operator precedence for propositional logic: All operators are right-associative. We can use parentheses to disambiguate.

Operator Precedence How do we parse this statement? ( x) y z x (y z) Operator precedence for propositional logic: All operators are right-associative. We can use parentheses to disambiguate.

Operator Precedence How do we parse this statement? ( x) y z x (y z) Operator precedence for propositional logic: All operators are right-associative. We can use parentheses to disambiguate.

Operator Precedence How do we parse this statement? ( x) (y z) (x (y z)) Operator precedence for propositional logic: All operators are right-associative. We can use parentheses to disambiguate.

Operator Precedence How do we parse this statement? ( x) (y z) (x (y z)) Operator precedence for propositional logic: All operators are right-associative. We can use parentheses to disambiguate.

Operator Precedence How do we parse this statement? ( x) ((y z) (x (y z))) Operator precedence for propositional logic: All operators are right-associative. We can use parentheses to disambiguate.

Operator Precedence How do we parse this statement? ( x) ((y z) (x (y z))) Operator precedence for propositional logic: All operators are right-associative. We can use parentheses to disambiguate.

Operator Precedence The main points to remember: binds to whatever immediately follows it. and bind more tightly than. We will commonly write expressions like p q r without adding parentheses. For more complex expressions, we'll try to add parentheses. Confused? Just ask!

Time-Out for Announcements!

Problem Set One The checkpoint problem for PS1 was due at the start of class today. We'll try to have it graded and returned by the start of Wednesday's class. The remaining problems from PS1 are due on Friday. Have questions? Stop by office hours, or ask on Piazza, or email the staff list!

Solution Sets We've released hardcopy solutions to the checkpoint problem for Problem Set One. Please be sure to read the solution sets in this course. The solution sets give sample solutions, which can be super useful for learning how to write proofs. For the full problem sets, we also explain why we asked each question and what insights we were hoping you would have. Solutions are not available electronically. We release solutions in hardcopy only. If you didn't pick them up in class, you can pick them up in the Gates building. (I'll show you where in a second). SCPD students: we'll send solutions to your site monitors, who will then distribute them to you.

Where to Get Solutions

Handouts Handoutswill will be available be available here... here... and andhere, here, ififwe werun runout out ofofspace. space.

Your Questions

Why do things like computability and complexity theory matter to a Software Developer? Many Many fundamental fundamental aspects aspects of of computers computers and and programming programming (the (the need need to to debug debug things, things, multithreading, multithreading, virtualization, virtualization, optimization, optimization, etc.) etc.) are are all all fundamentally fundamentally motivated motivated by by deep deep results results from from computability computability theory. theory. If If we we have have time time later later this this quarter, quarter, we'll we'll see see why, why, for for example, example, debugging debugging isis necessary, necessary, recursion recursion isis inescapable inescapable and and virtualization virtualization must must be be possible. possible. Complexity Complexity theory theory helps helps us us better better understand understand why why certain certain key key problems problems are are hard hard to to solve solve and and what what to to do do when when we we find find them. them. You'll You'll almost almost certainly certainly encounter encounter problems problems whose whose hardness hardness isis theoretically theoretically motivated motivated inin the the course course of of aa software software career. career. If If you you don't, don't, aim aim higher! higher!

Can parallelism impact tractability and/or computability? The The answer answer isis either either it it depends depends or or nobody nobody knows. knows. We'll We'll explore explore this this later later inin the the quarter. quarter.

Back to CS103!

Recap So Far A propositional variable is a variable that is either true or false. The propositional connectives are Negation: p Conjunction: p q Disjunction: p q Implication: p q Biconditional: p q True: False:

Translating into Propositional Logic

Some Sample Propositions a: I will be awake this evening. b: There is a lunar eclipse this evening. c: I will see the lunar eclipse.

Some Sample Propositions a: I will be awake this evening. b: There is a lunar eclipse this evening. c: I will see the lunar eclipse. I I won't won't see see aa lunar lunar eclipse eclipse if if I'm I'm not not awake awake this this evening. evening.

Some Sample Propositions a: I will be awake this evening. b: There is a lunar eclipse this evening. c: I will see the lunar eclipse. I I won't won't see see aa lunar lunar eclipse eclipse if if I'm I'm not not awake awake this this evening. evening. a c

p if q translates to q p It does not translate to p q

Some Sample Propositions a: I will be awake this evening. b: There is a lunar eclipse this evening. c: I will see a lunar eclipse.

Some Sample Propositions a: I will be awake this evening. b: There is a lunar eclipse this evening. c: I will see a lunar eclipse. If If II will will be be awake awake this this evening, evening, but but there's there's no no lunar lunar eclipse, eclipse, II won't won't see see aa lunar lunar eclipse. eclipse.

Some Sample Propositions a: I will be awake this evening. b: There is a lunar eclipse this evening. c: I will see a lunar eclipse. If If II will will be be awake awake this this evening, evening, but but there's there's no no lunar lunar eclipse, eclipse, II won't won't see see aa lunar lunar eclipse. eclipse. a b c

p, but q translates to p q

The Takeaway Point When translating into or out of propositional logic, be very careful not to get tripped up by nuances of the English language. In fact, this is one of the reasons we have a symbolic notation in the first place! Many prepositional phrases lead to counterintuitive translations; make sure to double-check yourself!

Propositional Equivalences

Quick Question: What would I have to show you to convince you that the statement p q is false?

Quick Question: What would I have to show you to convince you that the statement p q is false?

De Morgan's Laws Using truth tables, we concluded that (p q) is equivalent to p q We also saw that (p q) is equivalent to p q These two equivalences are called De Morgan's Laws.

De Morgan's Laws in Code Pro tip: Don't write this: if (!(p() && q()) { /* */ } Write this instead: if (!p()!q()) { /* */ } (This even short-circuits correctly!)

Logical Equivalence Because (p q) and p q have the same truth tables, we say that they're equivalent to one another. We denote this by writing (p q) p q The symbol is not a connective. The statement (p q) ( p q) is a propositional formula. If you plug in different values of p and q, it will evaluate to a truth value. It just happens to evaluate to true every time. The statement (p q) p q means these two formulas have exactly the same truth table. In other words, the notation φ ψ means φ and ψ always have the same truth values, regardless of how the variables are assigned.

An Important Equivalence Earlier, we talked about the truth table for p q. We chose it so that p q (p q) Later on, this equivalence will be incredibly useful: (p q) p q

Another Important Equivalence Here's a useful equivalence. Start with p q (p q) By De Morgan's laws: p q (p q) p q p q p q p q Thus p q p q

Another Important Equivalence Here's a useful equivalence. Start with p q (p q) By De Morgan's laws: p q (p q) p q p q If If pp isis false, false, then then p p qq isis true. true. If If pp isis p q p q Thus p q p q true, true, then then qq has has to to be be true true for for the the whole whole expression expression to to be be true. true.

One Last Equivalence

The Contrapositive The contrapositive of the statement p q is the statement q p These are logically equivalent, which is why proof by contrapositive works: p q q p

Why All This Matters

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 x + y = 16 x 8 y 8

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 x + y = 16 x 8 y 8

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 (x 8 y 8) (x + y = 16)

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 (x 8 y 8) (x + y = 16)

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 (x 8 y 8) (x + y = 16)

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 (x 8 y 8) x + y 16

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 (x 8 y 8) x + y 16

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 (x 8 y 8) x + y 16

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 (x 8) (y 8) x + y 16

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 (x 8) (y 8) x + y 16

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 (x 8) (y 8) x + y 16

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 x < 8 (y 8) x + y 16

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 x < 8 (y 8) x + y 16

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 x < 8 (y 8) x + y 16

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 x < 8 y < 8 x + y 16

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 x < 8 y < 8 x + y 16

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 x < 8 y < 8 x + y 16 If x < 8 and y < 8, then x + y 16

Theorem: If x + y = 16, then x 8 or y 8. Proof: By contrapositive. We will prove that if x < 8 and y < 8, then x + y 16. To see this, note that x+y<8+y <8+8 = 16 This means that x + y < 16, so x + y 16, which is what we needed to show.

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 x + y = 16 x 8 y 8

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 (x + y = 16 x 8 y 8)

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 (x + y = 16 x 8 y 8)

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 x + y = 16 (x 8 y 8)

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 x + y = 16 (x 8 y 8)

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 x + y = 16 (x 8 y 8)

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 x + y = 16 (x 8) (y 8)

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 x + y = 16 (x 8) (y 8)

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 x + y = 16 (x 8) (y 8)

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 x + y = 16 x < 8 (y 8)

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 x + y = 16 x < 8 (y 8)

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 x + y = 16 x < 8 (y 8)

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 x + y = 16 x < 8 y < 8

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 x + y = 16 x < 8 y < 8

Why All This Matters Suppose we want to prove the following statement: If x + y = 16, then x 8 or y 8 x + y = 16 x < 8 y < 8 x + y = 16, but x < 8 and y < 8.

Theorem: If x + y = 16, then x 8 or y 8. Proof: Assume for the sake of contradiction that x + y = 16, but that x < 8 and y < 8. Then x+y<8+y <8+8 = 16 So x + y < 16, contradicting that x + y = 16. We have reached a contradiction, so our assumption must have been wrong. Therefore if x + y = 16, then x 8 or y 8.

Why This Matters Propositional logic is a tool for reasoning about how various statements affect one another. To better understand how to prove a result, it often helps to translate what you're trying to prove into propositional logic first. That said, propositional logic isn't expressive enough to capture all statements. For that, we need something more powerful.