Lecture 2 Conditional Statements Translating English Sentences ...

Report 6 Downloads 41 Views
5/15/2016

Conditional Statements • Variety of terminology is used to express p → q:

Lecture 2 Application of Propositional Logic and Propositional Equivalence

“if p, then q”

“p implies q”

“if p, q”

“p only if q”

“p is sufficient for q”

“a sufficient condition for q is p”

“q if p”

“q whenever p”

“q when p”

“q is necessary for p”

“a necessary condition for p is q”

“q follows from p”

“q unless ¬p”

S. Ahmed

CSE173 Discrete Mathematics

S. Ahmed

1

Translating English Sentences

Example 2: “You cannot ride the roller coaster if you are under 4 feet tall unless you are older than 16 years old.” Solution:

– analyzed to determine their truth values, – Manipulated, and – Rules of inferences can be used to reason about them.

Let,

Example 1: How can this English sentence be translated into a logical Expression? “You can access the Internet from campus only if you are a computer science major or you are not a freshman.”

CSE173 Discrete Mathematics

2

Translating English Sentences

• English is often ambiguous. Translating sentences into compound logical expressions removes the ambiguity. • After translating, these expressions can be

S. Ahmed

CSE173 Discrete Mathematics

3

q: You can ride the roller coaster r: You are under 4 feet tall. s: You are older than 16 years old So the sentence becomes of the form: “¬q if r unless s” “¬q if r” => r → ¬q “¬q unless s” => ¬s → ¬q Together: (r → ¬q) ᴧ (¬s → ¬q) ≡ (r ᴧ ¬s) → ¬q S. Ahmed

CSE173 Discrete Mathematics

4

1

5/15/2016

System Specifications

System Specifications

• Translating sentences in natural language (e.g. English) into logical expressions is an essential part of specifying both hardware and software systems. • Gain unambiguity among system specification • To prove consistency. Example 1: Expression the specification “The automated reply cannot be sent when the file system is full.” using logical connectives.

Example 2: Determine whether these system specifications are consistent: “The diagnostic message is stored in the buffer or it is retransmitted.” “The diagnostic message is not stored in the buffer.” “If the diagnostic message is stored in the buffer, then it is retransmitted.” Solution: (Done on the board)

Solution: Let, p: “The automated reply can be sent” q: “The file system is full” So the sentence becomes of the form: “¬p when q” ≡ q → ¬p

S. Ahmed

CSE173 Discrete Mathematics

5

S. Ahmed

System Specifications

CSE173 Discrete Mathematics

6

Logic Circuits • Propositional logic can be applied to the design of computer hardware. • A logic circuit (or digital circuit) receives input signal p1, p2, … pn each a bit [either 0(off) or 1(on)], and produces output signals s1, s2, …, sn each a bit.

Example 3: Do the system specifications in the previous example remain consistent if the specification “The diagnostic message is not retransmitted” is added? Solution: (Done on the board)

Figure: Basic Logic Gates S. Ahmed

CSE173 Discrete Mathematics

7

S. Ahmed

CSE173 Discrete Mathematics

8

2

5/15/2016

Logic circuits

Logic circuits

Example 1: Determine the output for the combinatorial circuit in the figure.

Example 2: Build a digital circuit that produces the output (p ∨¬r) ∧ (¬p ∨ (q ∨¬r)) when given input bits p, q, and r. Solution:

S. Ahmed

CSE173 Discrete Mathematics

9

S. Ahmed

Propositional Equivalences

CSE173 Discrete Mathematics

10

Logical Equivalence

• Tautology: A compound proposition that is always true, no matter what the truth values of the propositional variables that occur in it, is called a tautology. • Contradiction: A compound proposition that is always false in called a contradiction. E.g. p ∧ ¬p.

• The compound propositions p and q are called logically equivalent if p ↔ q is a tautology. [p and q have the same truth values in all possible cases] • Notation: ‘≡’ or • One way to determine whether two compound propositions are equivalent is to use a truth table.

• Contingency: A compound proposition that is neither a tautology nor a contradiction is called a contingency. S. Ahmed

CSE173 Discrete Mathematics

11

S. Ahmed

CSE173 Discrete Mathematics

12

3

5/15/2016

Logical Equivalence

Logical Equivalence

• Example 1: Show that p ∨ (q ∧ r) and (p ∨ q) ∧ (p ∨ r) are logically equivalent. Solution: (Done in the board) • Exercise 2: Use truth table to verify the first De Morgan law ¬(p ∧ q) ≡ ¬p ∨¬q Solution: (Done in the board)

S. Ahmed

CSE173 Discrete Mathematics

13

S. Ahmed

Logical Equivalence

S. Ahmed

CSE173 Discrete Mathematics

CSE173 Discrete Mathematics

14

Logical Equivalence

15

S. Ahmed

CSE173 Discrete Mathematics

16

4

5/15/2016

Logical Equivalence

Logical Equivalence Example 1: Show that ¬(p ∨ (¬p ∧ q)) and ¬p ∧¬q are logically equivalent by developing a series of logical equivalences. Solution: (Done on the board) Example 2: Show that (p ∧ q) → (p ∨ q) is a tautology. Solution: (Done on the board)

S. Ahmed

CSE173 Discrete Mathematics

17

S. Ahmed

CSE173 Discrete Mathematics

18

Logical Equivalence Exercise 22: Show that (p → q) ∧ (p → r) and p → (q ∧ r) are logically equivalent. Solution: (Done on the board)

S. Ahmed

CSE173 Discrete Mathematics

19

5