COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

29
COMP 170 L2 Part 3 of Course Chapter 3 of Textbook

Transcript of COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

Page 1: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2

Part 3 of Course

Chapter 3 of Textbook

Page 2: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2

Introduction to Part 3

Objectives Introduce the basics of logic (L07, L08)

Develop a language for talking about proofs

Discuss the logic principles behind proofs (L09)

Page 2

Page 3: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2

L07: Intro to Logic

Objective Introduce basic ingredients of the language of logic.

Page 3

Page 4: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2

Outline

Example: Logic in programs

Logic statements, truth table, and equivalence

Basic laws about logic statements

Conditional connectives

Page 4

Page 5: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2

Logic in ProgramsPage 5

Page 6: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2

Logic in ProgramsPage 6

Page 7: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2Page 7

Page 8: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2

Outline

Example: Logic in programs

Logic statements, truth table, and equivalence

Basic laws about logic statements

Conditional connectives

Page 8

Page 9: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2

What make up logic statements?

Symbolic compound statements consist of

Variables, logical connectives, and conditional connectives

Page 9

Page 10: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2

Logic StatementsPage 10

Page 11: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2

Logic Statements can be True or False

Variables such as s, t, u can be either true (T) or false (F)

Meaning of connectives as follows:

Page 11

Page 12: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2

Truth Table for Logic Statements

Variables such as s, t, u can be either true (T) or false (F) Many possible scenarios

s = T, t=T, u=T;

s = T, t=T, u=F;

s = T, t=F, u=T;

….

Truth table Shows whether a compound statement is true for false in all cases Allow us to determine whether two statements are equivalent

Page 12

Page 13: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2

Truth Table for Statements Involving ONE Connective

Page 13

Page 14: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2

The two programs are equivalent because they are true in the same scenarios.

Page 14

Page 15: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2

EquivalencePage 15

Page 16: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2Page 16

Page 17: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2

Outline

Example: Logic in programs

Logic statements, truth table, and equivalence

Basic laws about logic statements

Conditional connectives

Page 17

Page 18: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2Page 18

Also: w \/ ( u /\ v) = (w \/ u ) /\ (w /\ v)

Page 19: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2Page 19

Page 20: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2Page 20

Page 21: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2

Outline

Example: Logic in programs

Logic statements, truth table, and equivalence

Basic laws about logic statements

Conditional connectives

Page 21

Page 22: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2

Conditional ConnectivesPage 22

Page 23: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2Page 23

Page 24: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2Page 24

Page 25: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2Page 25

Truth Table for Implication

Page 26: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2Page 26

Truth Table for Implication

Page 27: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2

Truth Table for ImplicationPage 27

Page 28: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2Page 28

Page 29: COMP 170 L2 Part 3 of Course Chapter 3 of Textbook.

COMP 170 L2Page 29

Truth Table for If-and-Only-If