propositional (boolean) logic - oswego

73
Propositional (Boolean) Logic Prof. Elaine Wenderholm Computer Science Department SUNY Oswego c 2009 Elaine Wenderholm All Rights Reserved – p.1/18

Upload: others

Post on 18-Dec-2021

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Propositional (Boolean) Logic - Oswego

Propositional (Boolean) Logic

Prof. Elaine Wenderholm

Computer Science Department

SUNY Oswego

c©2009 Elaine Wenderholm All Rights Reserved – p.1/18

Page 2: Propositional (Boolean) Logic - Oswego

Propositions

A (logical) proposition is a statement that is unequivically

either true or false.

c©2009 Elaine Wenderholm All Rights Reserved – p.2/18

Page 3: Propositional (Boolean) Logic - Oswego

Propositions

A (logical) proposition is a statement that is unequivically

either true or false.

“13 is an odd number” is ...

c©2009 Elaine Wenderholm All Rights Reserved – p.2/18

Page 4: Propositional (Boolean) Logic - Oswego

Propositions

A (logical) proposition is a statement that is unequivically

either true or false.

“13 is an odd number” is ...

... true

c©2009 Elaine Wenderholm All Rights Reserved – p.2/18

Page 5: Propositional (Boolean) Logic - Oswego

Propositions

A (logical) proposition is a statement that is unequivically

either true or false.

“13 is an odd number” is ...

... true

“√

25 = 5” is ...

c©2009 Elaine Wenderholm All Rights Reserved – p.2/18

Page 6: Propositional (Boolean) Logic - Oswego

Propositions

A (logical) proposition is a statement that is unequivically

either true or false.

“13 is an odd number” is ...

... true

“√

25 = 5” is ...

... false

c©2009 Elaine Wenderholm All Rights Reserved – p.2/18

Page 7: Propositional (Boolean) Logic - Oswego

Propositions

A (logical) proposition is a statement that is unequivically

either true or false.

“13 is an odd number” is ...

... true

“√

25 = 5” is ...

... false

“calc I is a hard course” is ...

c©2009 Elaine Wenderholm All Rights Reserved – p.2/18

Page 8: Propositional (Boolean) Logic - Oswego

Propositions

A (logical) proposition is a statement that is unequivically

either true or false.

“13 is an odd number” is ...

... true

“√

25 = 5” is ...

... false

“calc I is a hard course” is ...

... NOT a proposition!

c©2009 Elaine Wenderholm All Rights Reserved – p.2/18

Page 9: Propositional (Boolean) Logic - Oswego

Propositions

A (logical) proposition is a statement that is unequivically

either true or false.

“13 is an odd number” is ...

... true

“√

25 = 5” is ...

... false

“calc I is a hard course” is ...

... NOT a proposition!

“x is a prime number” is ...

c©2009 Elaine Wenderholm All Rights Reserved – p.2/18

Page 10: Propositional (Boolean) Logic - Oswego

Propositions

A (logical) proposition is a statement that is unequivically

either true or false.

“13 is an odd number” is ...

... true

“√

25 = 5” is ...

... false

“calc I is a hard course” is ...

... NOT a proposition!

“x is a prime number” is ...

... not a proposition.

c©2009 Elaine Wenderholm All Rights Reserved – p.2/18

Page 11: Propositional (Boolean) Logic - Oswego

Logical Operators

Logical operators are used to combine existing propositions

to form new propositions.

c©2009 Elaine Wenderholm All Rights Reserved – p.3/18

Page 12: Propositional (Boolean) Logic - Oswego

Logical Operators

Logical operators are used to combine existing propositions

to form new propositions.

Logical operators are defined with truth tables.

c©2009 Elaine Wenderholm All Rights Reserved – p.3/18

Page 13: Propositional (Boolean) Logic - Oswego

AND, OR, NOT Operators

and or not

p q p ∧ q

T T T

T F F

F T F

F F F

p q p ∨ q

T T T

T F T

F T T

F F F

p ¬p

T F

F T

c©2009 Elaine Wenderholm All Rights Reserved – p.4/18

Page 14: Propositional (Boolean) Logic - Oswego

Venn Diagrams

A Venn Diagram provides a visual depiction of logical operations

in terms of sets .

This is an excellent web reference to learn aboutVenn Diagrams.

http://www.purplemath.com/modules/venndiag.htm

c©2009 Elaine Wenderholm All Rights Reserved – p.5/18

Page 15: Propositional (Boolean) Logic - Oswego

Implication (conditional) and Bicondi-tional Operators

p implies q p iff q

p q p → q

T T T

T F F

F T T

F F T

p q p ↔ q

T T T

T F F

F T F

F F T

c©2009 Elaine Wenderholm All Rights Reserved – p.6/18

Page 16: Propositional (Boolean) Logic - Oswego

Implication (conditional) and Bicondi-tional Operators

p implies q p iff q

p q p → q

T T T

T F F

F T T

F F T

p q p ↔ q

T T T

T F F

F T F

F F T

p → q “p implies q” is false only when p (the antecedent) is

true and q (the consequence) is false. Let me explain...

The operators p ↔ q and p ≡ q are logically equivalent.

c©2009 Elaine Wenderholm All Rights Reserved – p.6/18

Page 17: Propositional (Boolean) Logic - Oswego

Logical Equivalence

Two propositions are logically equivalent (or equivalent, or

equal) if their truth tables are identical.

c©2009 Elaine Wenderholm All Rights Reserved – p.7/18

Page 18: Propositional (Boolean) Logic - Oswego

Logical Equivalence

Two propositions are logically equivalent (or equivalent, or

equal) if their truth tables are identical.

Common equivalences:

c©2009 Elaine Wenderholm All Rights Reserved – p.7/18

Page 19: Propositional (Boolean) Logic - Oswego

Logical Equivalence

Two propositions are logically equivalent (or equivalent, or

equal) if their truth tables are identical.

Common equivalences:

p → q ≡ ¬p ∨ q

c©2009 Elaine Wenderholm All Rights Reserved – p.7/18

Page 20: Propositional (Boolean) Logic - Oswego

Logical Equivalence

Two propositions are logically equivalent (or equivalent, or

equal) if their truth tables are identical.

Common equivalences:

p → q ≡ ¬p ∨ q

(one of) DeMorgan’s laws: ¬(p ∨ q) ≡ ¬p ∧ ¬q

c©2009 Elaine Wenderholm All Rights Reserved – p.7/18

Page 21: Propositional (Boolean) Logic - Oswego

Logical Equivalence

Two propositions are logically equivalent (or equivalent, or

equal) if their truth tables are identical.

Common equivalences:

p → q ≡ ¬p ∨ q

(one of) DeMorgan’s laws: ¬(p ∨ q) ≡ ¬p ∧ ¬q

Use truth tables to determine...

c©2009 Elaine Wenderholm All Rights Reserved – p.7/18

Page 22: Propositional (Boolean) Logic - Oswego

Logical Equivalence

Two propositions are logically equivalent (or equivalent, or

equal) if their truth tables are identical.

Common equivalences:

p → q ≡ ¬p ∨ q

(one of) DeMorgan’s laws: ¬(p ∨ q) ≡ ¬p ∧ ¬q

Use truth tables to determine...

You answer these

c©2009 Elaine Wenderholm All Rights Reserved – p.7/18

Page 23: Propositional (Boolean) Logic - Oswego

Logical Equivalence

Two propositions are logically equivalent (or equivalent, or

equal) if their truth tables are identical.

Common equivalences:

p → q ≡ ¬p ∨ q

(one of) DeMorgan’s laws: ¬(p ∨ q) ≡ ¬p ∧ ¬q

Use truth tables to determine...

You answer these

What is equivalent to ¬(p ∧ q) ? (Hint: the other

DeMorgan’s law)

c©2009 Elaine Wenderholm All Rights Reserved – p.7/18

Page 24: Propositional (Boolean) Logic - Oswego

Logical Equivalence

Two propositions are logically equivalent (or equivalent, or

equal) if their truth tables are identical.

Common equivalences:

p → q ≡ ¬p ∨ q

(one of) DeMorgan’s laws: ¬(p ∨ q) ≡ ¬p ∧ ¬q

Use truth tables to determine...

You answer these

What is equivalent to ¬(p ∧ q) ? (Hint: the other

DeMorgan’s law)

¬¬p ≡ ?

c©2009 Elaine Wenderholm All Rights Reserved – p.7/18

Page 25: Propositional (Boolean) Logic - Oswego

Logical Equivalence

Two propositions are logically equivalent (or equivalent, or

equal) if their truth tables are identical.

Common equivalences:

p → q ≡ ¬p ∨ q

(one of) DeMorgan’s laws: ¬(p ∨ q) ≡ ¬p ∧ ¬q

Use truth tables to determine...

You answer these

What is equivalent to ¬(p ∧ q) ? (Hint: the other

DeMorgan’s law)

¬¬p ≡ ?

p ∧ T ≡ ? p ∨ F ≡ ?

c©2009 Elaine Wenderholm All Rights Reserved – p.7/18

Page 26: Propositional (Boolean) Logic - Oswego

Tautologies, Contradictions

A tautology is a proposition that is TRUE under any

assignment of values to propositional variables.

Example: p ∨ ¬p

c©2009 Elaine Wenderholm All Rights Reserved – p.8/18

Page 27: Propositional (Boolean) Logic - Oswego

Tautologies, Contradictions

A tautology is a proposition that is TRUE under any

assignment of values to propositional variables.

Example: p ∨ ¬p

A contradition is a propostion that is FALSE under any

assignment of values to propositional variables.

Example: p ∧ ¬p

c©2009 Elaine Wenderholm All Rights Reserved – p.8/18

Page 28: Propositional (Boolean) Logic - Oswego

Tautologies, Contradictions

A tautology is a proposition that is TRUE under any

assignment of values to propositional variables.

Example: p ∨ ¬p

A contradition is a propostion that is FALSE under any

assignment of values to propositional variables.

Example: p ∧ ¬p

Other examples? The previous slides lists equivalences –

these are tautologies.

c©2009 Elaine Wenderholm All Rights Reserved – p.8/18

Page 29: Propositional (Boolean) Logic - Oswego

Predicate Logic

Propositions may contain a variable from some domain.

Example: x2 < 4 where x ∈ RIn this case the domain is the set of real numbers.

c©2009 Elaine Wenderholm All Rights Reserved – p.9/18

Page 30: Propositional (Boolean) Logic - Oswego

Predicate Logic

Propositions may contain a variable from some domain.

Example: x2 < 4 where x ∈ RIn this case the domain is the set of real numbers.

Predicate Logic is propositional logic, and it also

c©2009 Elaine Wenderholm All Rights Reserved – p.9/18

Page 31: Propositional (Boolean) Logic - Oswego

Predicate Logic

Propositions may contain a variable from some domain.

Example: x2 < 4 where x ∈ RIn this case the domain is the set of real numbers.

Predicate Logic is propositional logic, and it also

Has a domain of discourse (or a Universe)

c©2009 Elaine Wenderholm All Rights Reserved – p.9/18

Page 32: Propositional (Boolean) Logic - Oswego

Predicate Logic

Propositions may contain a variable from some domain.

Example: x2 < 4 where x ∈ RIn this case the domain is the set of real numbers.

Predicate Logic is propositional logic, and it also

Has a domain of discourse (or a Universe)

Has variables : free and bound

c©2009 Elaine Wenderholm All Rights Reserved – p.9/18

Page 33: Propositional (Boolean) Logic - Oswego

Predicate Logic

Propositions may contain a variable from some domain.

Example: x2 < 4 where x ∈ RIn this case the domain is the set of real numbers.

Predicate Logic is propositional logic, and it also

Has a domain of discourse (or a Universe)

Has variables : free and bound

Has quantifiers :

universal quantifier - “for all” - ∀existential quantifier - “there exists” (for some) - ∃

c©2009 Elaine Wenderholm All Rights Reserved – p.9/18

Page 34: Propositional (Boolean) Logic - Oswego

Free Variables

Example: A proposition involving a free variable over some

domain U .

c©2009 Elaine Wenderholm All Rights Reserved – p.10/18

Page 35: Propositional (Boolean) Logic - Oswego

Free Variables

Example: A proposition involving a free variable over some

domain U .

p(x) is some property of x (and evaluates to TRUE or FALSE).

c©2009 Elaine Wenderholm All Rights Reserved – p.10/18

Page 36: Propositional (Boolean) Logic - Oswego

Free Variables

Example: A proposition involving a free variable over some

domain U .

p(x) is some property of x (and evaluates to TRUE or FALSE).

Example : x < 4 – x has the property that its value is less than

4.

c©2009 Elaine Wenderholm All Rights Reserved – p.10/18

Page 37: Propositional (Boolean) Logic - Oswego

Free Variables

Example: A proposition involving a free variable over some

domain U .

p(x) is some property of x (and evaluates to TRUE or FALSE).

Example : x < 4 – x has the property that its value is less than

4.

x is a free variable because we are free to substitute any

value form x ∈ U , and evaluate the truth or falsity of the

proposition.

c©2009 Elaine Wenderholm All Rights Reserved – p.10/18

Page 38: Propositional (Boolean) Logic - Oswego

Free Variables

Example: A proposition involving a free variable over some

domain U .

p(x) is some property of x (and evaluates to TRUE or FALSE).

Example : x < 4 – x has the property that its value is less than

4.

x is a free variable because we are free to substitute any

value form x ∈ U , and evaluate the truth or falsity of the

proposition.

p(x) is called a propositional function, an open sentence, or

a condition defined on the domain U .

c©2009 Elaine Wenderholm All Rights Reserved – p.10/18

Page 39: Propositional (Boolean) Logic - Oswego

How do we evaluate a propositionalfunction?

Look at some p(x) defined on domain U .

c©2009 Elaine Wenderholm All Rights Reserved – p.11/18

Page 40: Propositional (Boolean) Logic - Oswego

How do we evaluate a propositionalfunction?

Look at some p(x) defined on domain U .

We can take every element a in U , substitute it into p(x), and

evaluate each one for truth or falsity.

c©2009 Elaine Wenderholm All Rights Reserved – p.11/18

Page 41: Propositional (Boolean) Logic - Oswego

How do we evaluate a propositionalfunction?

Look at some p(x) defined on domain U .

We can take every element a in U , substitute it into p(x), and

evaluate each one for truth or falsity.

We look at all the elements that make p(x) true and call it the

truth set of p(x).

c©2009 Elaine Wenderholm All Rights Reserved – p.11/18

Page 42: Propositional (Boolean) Logic - Oswego

How do we evaluate a propositionalfunction?

Look at some p(x) defined on domain U .

We can take every element a in U , substitute it into p(x), and

evaluate each one for truth or falsity.

We look at all the elements that make p(x) true and call it the

truth set of p(x).

Examples on the domain N - the Natural numbers. Let’s

define the truth set for each propositinal function.

c©2009 Elaine Wenderholm All Rights Reserved – p.11/18

Page 43: Propositional (Boolean) Logic - Oswego

How do we evaluate a propositionalfunction?

Look at some p(x) defined on domain U .

We can take every element a in U , substitute it into p(x), and

evaluate each one for truth or falsity.

We look at all the elements that make p(x) true and call it the

truth set of p(x).

Examples on the domain N - the Natural numbers. Let’s

define the truth set for each propositinal function.

p(x) is x + 2 > 7. What elements of N make this true?

c©2009 Elaine Wenderholm All Rights Reserved – p.11/18

Page 44: Propositional (Boolean) Logic - Oswego

How do we evaluate a propositionalfunction?

Look at some p(x) defined on domain U .

We can take every element a in U , substitute it into p(x), and

evaluate each one for truth or falsity.

We look at all the elements that make p(x) true and call it the

truth set of p(x).

Examples on the domain N - the Natural numbers. Let’s

define the truth set for each propositinal function.

p(x) is x + 2 > 7. What elements of N make this true?

{x|p(x)} = {6, 7, 8, . . .}

c©2009 Elaine Wenderholm All Rights Reserved – p.11/18

Page 45: Propositional (Boolean) Logic - Oswego

How do we evaluate a propositionalfunction?

Look at some p(x) defined on domain U .

We can take every element a in U , substitute it into p(x), and

evaluate each one for truth or falsity.

We look at all the elements that make p(x) true and call it the

truth set of p(x).

Examples on the domain N - the Natural numbers. Let’s

define the truth set for each propositinal function.

p(x) is x + 2 > 7. What elements of N make this true?

{x|p(x)} = {6, 7, 8, . . .}p(x) is x + 3 < 1 ...

c©2009 Elaine Wenderholm All Rights Reserved – p.11/18

Page 46: Propositional (Boolean) Logic - Oswego

How do we evaluate a propositionalfunction?

Look at some p(x) defined on domain U .

We can take every element a in U , substitute it into p(x), and

evaluate each one for truth or falsity.

We look at all the elements that make p(x) true and call it the

truth set of p(x).

Examples on the domain N - the Natural numbers. Let’s

define the truth set for each propositinal function.

p(x) is x + 2 > 7. What elements of N make this true?

{x|p(x)} = {6, 7, 8, . . .}p(x) is x + 3 < 1 ...

{x|p(x)} = ∅

c©2009 Elaine Wenderholm All Rights Reserved – p.11/18

Page 47: Propositional (Boolean) Logic - Oswego

How do we evaluate a propositionalfunction?

Look at some p(x) defined on domain U .

We can take every element a in U , substitute it into p(x), and

evaluate each one for truth or falsity.

We look at all the elements that make p(x) true and call it the

truth set of p(x).

Examples on the domain N - the Natural numbers. Let’s

define the truth set for each propositinal function.

p(x) is x + 2 > 7. What elements of N make this true?

{x|p(x)} = {6, 7, 8, . . .}p(x) is x + 3 < 1 ...

{x|p(x)} = ∅x < 5 ∧ x%2 = 0

c©2009 Elaine Wenderholm All Rights Reserved – p.11/18

Page 48: Propositional (Boolean) Logic - Oswego

How do we evaluate a propositionalfunction?

Look at some p(x) defined on domain U .

We can take every element a in U , substitute it into p(x), and

evaluate each one for truth or falsity.

We look at all the elements that make p(x) true and call it the

truth set of p(x).

Examples on the domain N - the Natural numbers. Let’s

define the truth set for each propositinal function.

p(x) is x + 2 > 7. What elements of N make this true?

{x|p(x)} = {6, 7, 8, . . .}p(x) is x + 3 < 1 ...

{x|p(x)} = ∅x < 5 ∧ x%2 = 0

{x|p(x)} = {2, 4}

c©2009 Elaine Wenderholm All Rights Reserved – p.11/18

Page 49: Propositional (Boolean) Logic - Oswego

Bound Variables - Quantified Statements

∀x(p(x)) means

c©2009 Elaine Wenderholm All Rights Reserved – p.12/18

Page 50: Propositional (Boolean) Logic - Oswego

Bound Variables - Quantified Statements

∀x(p(x)) means

for all variables x in the domain, the property p is true for x.

c©2009 Elaine Wenderholm All Rights Reserved – p.12/18

Page 51: Propositional (Boolean) Logic - Oswego

Bound Variables - Quantified Statements

∀x(p(x)) means

for all variables x in the domain, the property p is true for x.

x is a bound variable

c©2009 Elaine Wenderholm All Rights Reserved – p.12/18

Page 52: Propositional (Boolean) Logic - Oswego

Bound Variables - Quantified Statements

∀x(p(x)) means

for all variables x in the domain, the property p is true for x.

x is a bound variable

It is bound to the quantifier ∀

c©2009 Elaine Wenderholm All Rights Reserved – p.12/18

Page 53: Propositional (Boolean) Logic - Oswego

Bound Variables - Quantified Statements

∀x(p(x)) means

for all variables x in the domain, the property p is true for x.

x is a bound variable

It is bound to the quantifier ∀Example: domain is N ∀x(x >= 0)

c©2009 Elaine Wenderholm All Rights Reserved – p.12/18

Page 54: Propositional (Boolean) Logic - Oswego

Bound Variables - Quantified Statements

∀x(p(x)) means

for all variables x in the domain, the property p is true for x.

x is a bound variable

It is bound to the quantifier ∀Example: domain is N ∀x(x >= 0)

This is true for every x ∈ N . In fact it is a tautology.

c©2009 Elaine Wenderholm All Rights Reserved – p.12/18

Page 55: Propositional (Boolean) Logic - Oswego

Bound Variables - Quantified Statements

∀x(p(x)) means

for all variables x in the domain, the property p is true for x.

x is a bound variable

It is bound to the quantifier ∀Example: domain is N ∀x(x >= 0)

This is true for every x ∈ N . In fact it is a tautology.

Example: domain is Z - the Integers

∃x(x2 − 4 = 0)

c©2009 Elaine Wenderholm All Rights Reserved – p.12/18

Page 56: Propositional (Boolean) Logic - Oswego

Bound Variables - Quantified Statements

∀x(p(x)) means

for all variables x in the domain, the property p is true for x.

x is a bound variable

It is bound to the quantifier ∀Example: domain is N ∀x(x >= 0)

This is true for every x ∈ N . In fact it is a tautology.

Example: domain is Z - the Integers

∃x(x2 − 4 = 0)

The only values of x to make this true are x = {2,−2}.

c©2009 Elaine Wenderholm All Rights Reserved – p.12/18

Page 57: Propositional (Boolean) Logic - Oswego

Bound Variables - Quantified Statements

∀x(p(x)) means

for all variables x in the domain, the property p is true for x.

x is a bound variable

It is bound to the quantifier ∀Example: domain is N ∀x(x >= 0)

This is true for every x ∈ N . In fact it is a tautology.

Example: domain is Z - the Integers

∃x(x2 − 4 = 0)

The only values of x to make this true are x = {2,−2}.

Only some of the values in Z make the statement true,

but that’sall we need.

c©2009 Elaine Wenderholm All Rights Reserved – p.12/18

Page 58: Propositional (Boolean) Logic - Oswego

Another way to define quantifiers in termsof sets

Given: domain U , and p(x) is a property of x on elements in U .

Universal Quantifier

c©2009 Elaine Wenderholm All Rights Reserved – p.13/18

Page 59: Propositional (Boolean) Logic - Oswego

Another way to define quantifiers in termsof sets

Given: domain U , and p(x) is a property of x on elements in U .

Universal Quantifier

∀xp(x) is true whenever {x|p(x)} = U , otherwise ∀xp(x) is

false.

c©2009 Elaine Wenderholm All Rights Reserved – p.13/18

Page 60: Propositional (Boolean) Logic - Oswego

Another way to define quantifiers in termsof sets

Given: domain U , and p(x) is a property of x on elements in U .

Universal Quantifier

∀xp(x) is true whenever {x|p(x)} = U , otherwise ∀xp(x) is

false.

Existential Quantifier

c©2009 Elaine Wenderholm All Rights Reserved – p.13/18

Page 61: Propositional (Boolean) Logic - Oswego

Another way to define quantifiers in termsof sets

Given: domain U , and p(x) is a property of x on elements in U .

Universal Quantifier

∀xp(x) is true whenever {x|p(x)} = U , otherwise ∀xp(x) is

false.

Existential Quantifier

∃xp(x) is true whenever {x|p(x)} 6= ∅, otherwise ∃xp(x) is

false.

c©2009 Elaine Wenderholm All Rights Reserved – p.13/18

Page 62: Propositional (Boolean) Logic - Oswego

Negating Quantifiers

¬(∀x(p(x)) ≡ ∃x(¬p(x))

c©2009 Elaine Wenderholm All Rights Reserved – p.14/18

Page 63: Propositional (Boolean) Logic - Oswego

Negating Quantifiers

¬(∀x(p(x)) ≡ ∃x(¬p(x))

¬(∃x(p(x)) ≡ ∀x(¬p(x))

c©2009 Elaine Wenderholm All Rights Reserved – p.14/18

Page 64: Propositional (Boolean) Logic - Oswego

Nested Quantifiers - 1

Domain = Z (the Integers).

How do we evalute ∃x∀y(x + y = 0)? (btw it’s true)

From the inside to the outside:

c©2009 Elaine Wenderholm All Rights Reserved – p.15/18

Page 65: Propositional (Boolean) Logic - Oswego

Nested Quantifiers - 1

Domain = Z (the Integers).

How do we evalute ∃x∀y(x + y = 0)? (btw it’s true)

From the inside to the outside:

∃x∀y(x + y = 0)︸ ︷︷ ︸

pick any y

c©2009 Elaine Wenderholm All Rights Reserved – p.15/18

Page 66: Propositional (Boolean) Logic - Oswego

Nested Quantifiers - 1

Domain = Z (the Integers).

How do we evalute ∃x∀y(x + y = 0)? (btw it’s true)

From the inside to the outside:

∃x∀y(x + y = 0)︸ ︷︷ ︸

pick any y

∃x∀y(x + y = 0)︸ ︷︷ ︸

pick any y︸ ︷︷ ︸

there is some x that makes this true

c©2009 Elaine Wenderholm All Rights Reserved – p.15/18

Page 67: Propositional (Boolean) Logic - Oswego

Nested Quantifiers - 2

This is not the same as ∀x∃y(x + y = 0) (btw it’s false)

c©2009 Elaine Wenderholm All Rights Reserved – p.16/18

Page 68: Propositional (Boolean) Logic - Oswego

Nested Quantifiers - 2

This is not the same as ∀x∃y(x + y = 0) (btw it’s false)

∀x∃y(x + y = 0)︸ ︷︷ ︸

pick some y

c©2009 Elaine Wenderholm All Rights Reserved – p.16/18

Page 69: Propositional (Boolean) Logic - Oswego

Nested Quantifiers - 2

This is not the same as ∀x∃y(x + y = 0) (btw it’s false)

∀x∃y(x + y = 0)︸ ︷︷ ︸

pick some y

∀x∃y(x + y = 0)︸ ︷︷ ︸

pick some y︸ ︷︷ ︸

any x makes this true

c©2009 Elaine Wenderholm All Rights Reserved – p.16/18

Page 70: Propositional (Boolean) Logic - Oswego

DeMorgan’s laws in logic and program-ming languages

Logic Software Hardware

¬(p ∨ q) = ¬p ∧ ¬q !(x||y) = !x && !y p · q = p + q

¬(p ∧ q) = ¬p ∨ ¬q !(x&&y) = !x || !y p + q = p · q

c©2009 Elaine Wenderholm All Rights Reserved – p.17/18

Page 71: Propositional (Boolean) Logic - Oswego

DeMorgan’s laws in logic and program-ming languages

Logic Software Hardware

¬(p ∨ q) = ¬p ∧ ¬q !(x||y) = !x && !y p · q = p + q

¬(p ∧ q) = ¬p ∨ ¬q !(x&&y) = !x || !y p + q = p · q

In (digital) hardware, the gates are AND gates and OR gates.

(Actually, AND and OR can be made from one gate - NAND

gate.)

c©2009 Elaine Wenderholm All Rights Reserved – p.17/18

Page 72: Propositional (Boolean) Logic - Oswego

DeMorgan’s laws in logic and program-ming languages

Logic Software Hardware

¬(p ∨ q) = ¬p ∧ ¬q !(x||y) = !x && !y p · q = p + q

¬(p ∧ q) = ¬p ∨ ¬q !(x&&y) = !x || !y p + q = p · q

In (digital) hardware, the gates are AND gates and OR gates.

(Actually, AND and OR can be made from one gate - NAND

gate.)

We can draw the circuit diagram (a combinatorial circuit) for

any propositional statement in hardware. table.

c©2009 Elaine Wenderholm All Rights Reserved – p.17/18

Page 73: Propositional (Boolean) Logic - Oswego

Algorithm

The proposition is viewed as a function: it has input values (the

logical variables) and an output value (what the proposition

evaluates to)

Write the truth table for the function (How many rows in the

truth table?)

Draw the input variables as vertical lines

For each row in the truth table that evaluates to T do:

Connect the input variables to an AND gate - if the

variable is T , connect it directly; if it is F , put an inverter

between it and the gate

Connect the output of all the AND gates into an OR gate.

The output from the OR gate is the output of the function

c©2009 Elaine Wenderholm All Rights Reserved – p.18/18