COMP 170 L2 Part 3 of Course Chapter 3 of Textbook

Preview:

Citation preview

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

COMP 170 L2

L07: Intro to Logic

Objective Introduce basic ingredients of the language of logic.

Page 3

COMP 170 L2

Outline

Example: Logic in programs

Logic statements, truth table, and equivalence

Basic laws about logic statements

Conditional connectives

Page 4

COMP 170 L2

Logic in ProgramsPage 5

COMP 170 L2

Logic in ProgramsPage 6

COMP 170 L2Page 7

COMP 170 L2

Outline

Example: Logic in programs

Logic statements, truth table, and equivalence

Basic laws about logic statements

Conditional connectives

Page 8

COMP 170 L2

What make up logic statements?

Symbolic compound statements consist of

Variables, logical connectives, and conditional connectives

Page 9

COMP 170 L2

Logic StatementsPage 10

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

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

COMP 170 L2

Truth Table for Statements Involving ONE Connective

Page 13

COMP 170 L2

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

Page 14

COMP 170 L2

EquivalencePage 15

COMP 170 L2Page 16

COMP 170 L2

Outline

Example: Logic in programs

Logic statements, truth table, and equivalence

Basic laws about logic statements

Conditional connectives

Page 17

COMP 170 L2Page 18

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

COMP 170 L2Page 19

COMP 170 L2Page 20

COMP 170 L2

Outline

Example: Logic in programs

Logic statements, truth table, and equivalence

Basic laws about logic statements

Conditional connectives

Page 21

COMP 170 L2

Conditional ConnectivesPage 22

COMP 170 L2Page 23

COMP 170 L2Page 24

COMP 170 L2Page 25

Truth Table for Implication

COMP 170 L2Page 26

Truth Table for Implication

COMP 170 L2

Truth Table for ImplicationPage 27

COMP 170 L2Page 28

COMP 170 L2Page 29

Truth Table for If-and-Only-If

Recommended