2.2 Conditional Statements, Exams of Computer Programming

A conditional statement is the sentence “if p then q”, denoted symbolically p → q. 3 p is called the hypothesis. 4 q is called the conclusion.

Typology: Exams

2022/2023

Uploaded on 03/01/2023

picoo
picoo 🇮🇳

4.5

(13)

235 documents

1 / 28

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
2.2 Conditional Statements
2.2 Conditional Statements 1 / 10
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c

Partial preview of the text

Download 2.2 Conditional Statements and more Exams Computer Programming in PDF only on Docsity!

2.2 Conditional Statements

Conditional Statements

Definition

(^1) When making a logical inference, one reasons from a hypothesis to a conclusion.

Conditional Statements

Definition

(^1) When making a logical inference, one reasons from a hypothesis to a conclusion. (^2) A conditional statement is the sentence “if p then q”, denoted symbolically p → q. (^3) p is called the hypothesis. (^4) q is called the conclusion. (^5) p → q is false when p is true and q is false, and true otherwise.

Truth Table for p → q

Fact

The truth table for p → q is

p q p → q T T

Truth Table for p → q

Fact

The truth table for p → q is

p q p → q T T T T F F F T

Truth Table for p → q

Fact

The truth table for p → q is

p q p → q T T T T F F F T T F F

Example

Example

A conditional statement that is true by virtue of the fact that its hypothesis is false is called vacuously true. For example:

If 0 = 1 then 0 = 2.

If-Then as Or

Example

(^1) Show that p → q ≡∼ p ∨ q.

If-Then as Or

Example

(^1) Show that p → q ≡∼ p ∨ q. (^2) Rewrite the following statement in an if-then form: “Either you do not get 90% or you get an A”. (^3) Show that ∼ (p → q) ≡ p∧ ∼ q.

The Contrapositive of a Conditional Statement

Definition

The contrapositive of a conditional statement of the form “If p then q” is

The Contrapositive of a Conditional Statement

Definition

The contrapositive of a conditional statement of the form “If p then q” is “If ∼ q then ∼ p”. Symbolically the contrapositive of p → q is

∼ q →∼ p.

Conditional statement ≡ its contrapositive

Fact

A conditional statement is logically equivalent to its contrapositive.

The Converse and Inverse of a Conditional Statement

Definitions

Suppose a conditional statement of the form “If p then q” is given. (^1) The converse is “If q then p.” (^2) The inverse is

The Converse and Inverse of a Conditional Statement

Definitions

Suppose a conditional statement of the form “If p then q” is given. (^1) The converse is “If q then p.” (^2) The inverse is “If ∼ p then ∼ q.”