can’t be c

302
can’t be c can’t be b Could be c this is b could be c

description

can’t be b. this is b. can’t be c. Could be c. could be c. Names. Constants are used to name existing objects a, b, c, d, e, f max, claire, carl No constant can name more than one object An object can have more than one name or no name at all. Leonard Euler. - PowerPoint PPT Presentation

Transcript of can’t be c

Page 1: can’t be c

can’t be ccan’t be b

Could be c

this is b

could be c

Page 2: can’t be c
Page 3: can’t be c
Page 4: can’t be c

Names

Constants are used to name existing objectsa, b, c, d, e, fmax, claire, carl

No constant can name more than one object An object can have more than one name or

no name at all

Page 5: can’t be c

Tiberius Sempronius GracchusGaius Sempronius Gracchus

Examples

Leonard EulerHonest Abe Lincoln

Page 6: can’t be c
Page 7: can’t be c

Predicates

A (determinate) property possessed by an object Shape Size

A (determinate) relationship among objects Shape relationship Size relationship Positional relationship Equality =

Page 8: can’t be c

Atomic Sentences

A sentence formed by a single predicate followed by one or more names

Max is tall Tall(max)

e is larger than b Larger(e,b)

e is identical to a e = a

A sentence expresses a claim that is either true or false

Page 9: can’t be c

Atomic Sentences in FOL

Predicate(arg1, arg2,…, argn) Predicates have names beginning with an uppercase letter or are

represented by an operator symbol The number of arguments is called the predicate’s arity The order of the arguments is important

Larger(e,c) – e is larger than cLarger(c,e) – c is larger than eBetween(a,b,e) – a is between b and eBetween(b,a,e) – b is between a and e

=(a,b) a and b are identical Usually, written in infix form a = b

Page 10: can’t be c

Function Symbols

A function is used to express complex names (a reference to an individual without using a name)

father(b) – b’s father password(c) – c’s password

A function may be nested Max’s father’s father

father(father(max))

A function is never a predicate Can’t nest predicates

Tall(Tall(max)) A predicate forms a sentence, while a function names an individual

Page 11: can’t be c

Functions in FOL

function(arg1, arg2,…, argn)Function names begin with a lowercase letter or are

expressed with a symbol father(max) Max’s father

father(mother(max)) Max’s mother’s father

youngestChild(max,ann) Max and Ann’s youngest child

*(5,+(2,4)) 30

starship(son(dr_crusher)) Dr_Crusher’s son’s starship

Page 12: can’t be c

Connectives

Not And, Or , Material Conditional Biconditional

Page 13: can’t be c

Examples

Larger(e,c)

Cube(b) Large(b)

SameRow(e,c) BackOf(e,b)

e is not larger than c

b is a cube or b is large

e and c are in the same row and e is in back of b

Page 14: can’t be c

First Order Logic

Names Predicates Functions Connectives

Are there more?

Atomic Sentences

Page 15: can’t be c

Example FOL

English FOLNames Brando brando

Nancy nancySean sean

Predicates x is identical to y x = yx is a better actor than y BetterActor(x,y)

Functions x's favorite actor favoriteActor(x)

Page 16: can’t be c

Translation

Brando is Nancy’s favorite actor. brando = favoriteActor(nancy)

BetterActor(favoriteActor(nancy), favoriteActor(max)) Nancy’s favorite actor is better than Max’s favorite actor.

sean = favoriteActor(sean) Sean is his own favorite actor.

Brando is someone’s favorite actor. x(brando = favoriteActor(x))

Page 17: can’t be c

Quantifiers and Variables

For every x x There exists y y

Page 18: can’t be c

First Order Logic

Names Predicates Functions Connectives Quantifiers and variables

Revised List

Page 19: can’t be c

Translation using functions

c is the front-most block in b’s column. c is in the same row as the front-most block in b’s column.

The right-most block in the same row as the front-most block in b’s column is small.

c = fm(b)

SameRow(c,fm(b))

Small(rm(fm(b)))

Page 20: can’t be c

First-order Arithmetic

Names Zero 0 One 1

Predicates Equality = Less than <

Functions Addition + Multiplication

1) 0 and 1 are terms.2) If t1 and t2 are terms then so are (t1 + t2) and

(t1 t2).3) Nothing is a term unless formed from the

above rules.

Page 21: can’t be c

What is an argument?

A series of statements in which one (called the conclusion) is meant to follow from or be supported by the others (called the premises).

Page 22: can’t be c

Fitch-style Argument

P1 P2

... Pn

Q

premises

conclusion

Page 23: can’t be c

Valid Argument

A valid argument is one that guarantees the truth of its conclusion on the assumption that the premises are true.

A valid argument ensures the conclusion is true provided the premises are true.

A valid argument does not depend on any world for its validity

Page 24: can’t be c

Valid Argument

Large(b) v Cube(b) Cube(b) Large(b)

Large(b) Cube(b) Large(b) v Cube(b) Cube(b) Large(b)T T T F TT F T T TF T T F FF F F T F

premises conclusion

Page 25: can’t be c

Invalid Argument

Large(b) v Cube(b) Cube(b) Large(b)

Large(b) Cube(b) Large(b) v Cube(b) Cube(b) Large(b)T T T T TT F T F TF T T T FF F F F F

premises conclusion

Page 26: can’t be c

Sound Argument

If an argument is valid and its premises are true, then the argument is said to be sound.

The soundness or unsoundness of an argument is determined with respect to some world

Page 27: can’t be c

Sound Argument

Page 28: can’t be c

Argument is not sound

Page 29: can’t be c

Methods of Proof

FormalWe will use a Fitch-style proof employed in the text and

software of the same name. “Formal” proof evokes images of being rigorous. In fact, it has to do creating a proof with strict syntax rules.

InformalThis style of proof , used by mathematicians, is just as

rigorous. It consists of sentences describing the situation at hand, the inferences being made, and the justification of each inference.

Page 30: can’t be c

What constitutes a proof?

A proof that sentence Q follows from the premises P1, P2, …, Pn is a step-by-step demonstration that shows Q must be true in any circumstances in which the premises are all true.

Page 31: can’t be c

Types of Proof

Direct Indirect Proof by cases Proof by contradiction Proof by induction Proof by counterexample

Page 32: can’t be c

Fitch-style Proof

P1

P2

… Pn

S1

S2

… Sn

Q

Premises

Deductions & Justificationsmay contain sub-proofs

Conclusion

Fitch Bar

Page 33: can’t be c

Rules/Axioms

= EliminationIf b = c and P(b) then P(c).

= Introductiona = a

Symmetry of IdentityIf a = b then b = a.

Transitivity of IdentityIf a = b and b = c then a = c

These follow from above

Page 34: can’t be c

= Elimination

P(n)

n = m

P(m)

Page 35: can’t be c

= Introduction

n = n

Page 36: can’t be c

Symmetry of Identity

a = b

1)

2)

3)

a = a = Introduction

b = a = Elimination 1, 2

Page 37: can’t be c
Page 38: can’t be c

Example Formal Proof

Smaller(a,b) c = b

Larger(b,a) Ana Con 1

c = c = Introduction

b = c = Elim 2, 4

Larger(c,a) = Elim 5, 3

1)2)

3)

4)

5)

6)

Page 39: can’t be c

Example Informal Proof

Prove: If a is smaller than b and c is identical to b then c is larger than a.

Since a is smaller than b, it follows that b must be larger than a. Moreover, since c is identical to b, it follows that c must be larger than a. QED

Page 40: can’t be c

Consequence Rules

There are three consequence “rules” in Fitch Tautological Consequence (Taut Con) First-order Consequence (FO Con) Analytic Consequence (Ana Con)

Cons rules are proof seekers that work behind the scenes. Success is indicated by the beloved blue check mark . Failure is indicated by the dreaded red x.

Page 41: can’t be c

Taut Con

Weakest of the three Cons “rules” Attempts to prove if the current step follows

from the cited statements by virtue of the truth-functional connectives. E.g., p q can be replaced by p q.

Page 42: can’t be c

FO Con

More powerful than Taut Con but weaker than Ana Con

Attempts to prove if the current step follows from the cited steps by virtue of the truth-functional connectives, the quantifiers, and the identity predicate. E.g., a=b b=c can be replaced by a=c.

Page 43: can’t be c

Ana Con

Most powerful Cons “rule” Attempts to prove if the current step follows

from the cited steps by virtue of the truth-functional connectives, the quantifiers, the the identity predicate and the meanings of each predicate of Tarski’s World.

E.g., Larger(a,b) can be replaced by Smaller(b,a).

Page 44: can’t be c

Showing Non-consequence

To show Q is not a consequence of premises P1, P2, …, Pn, create a world where the premises are simultaneously true and the conclusion Q is false.

This shows the argument below is invalid P1

P2

… Pn

Q

Page 45: can’t be c

Invalid Argument

SameRow(b,c) SameRow(a,d) SameRow(d,f) LeftOf(a,b)

LeftOf(f,c)

b c

a df f

Page 46: can’t be c
Page 47: can’t be c

Boolean Connectives

Negation Conjunction Disjunction

It is not the case that

And, but, moreover

Or

Page 48: can’t be c

Negation

P P

T F

F T

Page 49: can’t be c

Negation Facts

P is translated as It is not the case that P.

(a = b) is equivalent to a b P is equivalent to P

P P P

T F T

F T F

Page 50: can’t be c

The Game

Used to understand the truth value of a complex sentence

Strategy: Given a sentence of the form P that you believe to be True (False) implies P is False (True)implies P is True (False)implies P is False (True)

Page 51: can’t be c

Assessment is incorrect

Page 52: can’t be c

Conjunction and Disjunction

P Q P Q P Q

T T T T

T F F T

F T F T

F F F F

Page 53: can’t be c

Game Revisited

If you believe P Q is true you will be asked to select the disjunct that is true.

If you believe P Q is false Tarski’s World will attempt to find a disjunct that is true.

If you believe P Q is true Tarski’s World will attempt to find a conjunct that is false.

If you believe P Q is false you will be asked to select a conjunct that is false.

Page 54: can’t be c

Translation

Both A and B Either A or B Neither A nor B

A B

A B

(A B)

Both c and e are cubes. Cube(c) Cube(e)

Either c or e is a cube. Cube(c) Cube(e)

Neither c nor e is a cube. (Cube(c) Cube(e))

Page 55: can’t be c

Avoid Ambiguity

A B C(A B) C Both A or B and C

A (B C) Either A or both B and C

A B C(A B) C Either both A and B or C

A (B C) Both A and either B or C

Either both Max is at home and Claire is tall or Carl is happy.

[Home(Max) Tall(Claire)] Happy(Carl)

Page 56: can’t be c

Distributive Rules

A (B C) is tautologically equivalent to (A B) (A C)

A (B C) is tautologically equivalent to (A B) (A C)

Page 57: can’t be c

Famous Equivalences

DeMorgan’s Laws (A B) A B(A B) A B

Idempotent A A

Page 58: can’t be c

Negation Normal FormNNF

A sentence S is in negation normal form if the is moved as far inside S as possible.

[(A B) C] (A B) C ( A B) C( A B) C

Page 59: can’t be c

Conjunctive Normal FormCNF

A sentence S of the form

A1 A2 … An where each Ai, 1 i nis of the form

B1 B2 … Bm(i) where each Bj is a literal or the negation of a literal, 1 j m(i).

Page 60: can’t be c

Disjunctive Normal FormDNF

A sentence S of the form

A1 A2 … An where each Ai, 1 i nis of the form

B1 B2 … Bm(i) where each Bj is a literal or the negation of a literal, 1 j m(i).

Page 61: can’t be c

Example

[(A B) C] (A B) C ( A B) C( A B) C NNF, CNF( A C) (B C) NNF, DNF

Page 62: can’t be c

Reiteration

P

P

Page 63: can’t be c

Conjunctive Elimination

PQ

. . . P EliminationQ

Page 64: can’t be c

Conjunctive Introduction

P . . .

Q . . .

P Q Introduction

Page 65: can’t be c

Proof

Cube(b) Tet(d) Large(d) Tet(d) Elim 1 Large(d) Reit 2 Tet(d) Large(d) Intro 3, 4

2

1

3

4

Page 66: can’t be c

Disjunction Introduction

P

. . .

P Q Introduction

Page 67: can’t be c

ABC(B C) D

1. AB2. C3. 4. 5.

B Elim: 1B C Intro: 3, 2(B C) D Intro: 4

Prove:

Page 68: can’t be c

Disjunctive EliminationProof by cases

P Q . . . P … S Q … SS

Elimination

Same conclusion

Page 69: can’t be c

A BB CA C

1. A B2. B C 3. A 4. A C Intro: 3

5. B 6. C Elim: 2 7. A C Intro: 6

8. A C Elim: 1, 3-4, 5-7

Prove:

Page 70: can’t be c

Tautology

A sentence S is a tautology if and only if every row of its truth table assigns true to S.

Page 71: can’t be c

Example

Page 72: can’t be c

Logical Possibility

A sentence S is a logical possibility if there is some logically possible circumstance in which S is true.

A sentence S is a TW-possible if there is a world in which S is true.

Page 73: can’t be c

Examples

Cube(b) Large(b) b is a large cube.

(Tet(c) Cube(c) Dodec(c)) It is not the case that c is a tet or a cube or a dodec.

e e e is not identical to iteself.

Logically possible TW-possible

Not TW-possibleLogically possible

Not Logically possible Not TW-possible

Page 74: can’t be c

Spurious Rows

A spurious row in a truth table is a row whose reference columns describe a situation or circumstance that is impossible to realize on logical grounds.

Page 75: can’t be c

Example

P Q RT T TT T FT F TT F FF T TF T FF F TF F F

Cube(a) a=b Cube(b)T T TT T F SpuriousT F TT F FF T T SpuriousF T FF F TF F F

Reference Columns

Page 76: can’t be c

Logical Necessity

A sentence S is a logical necessity if and only if S is true in every logical circumstance.

A sentence S is a logical necessity if and only if S is true in every non-spurious row of its truth table.

Logical-Necessity

TW-Necessity

Page 77: can’t be c

Example

a=b b=b a=b v b=bT T TT F T spuriousF T TF F F spurious

Logical Necessity TW-Necessity

Reference Columns S

Page 78: can’t be c

Example

Larger(a,b) Smaller(a,b) Larger(a,b) v Smaller(a,b)T T T spuriousT F TF T TF F F

Not a TW-NecessityNot a Logical Necessity

Reference Columns S

Can you find an example which is a TW-necessity but not a logical necessity?

Page 79: can’t be c

Sentence Hierarchy

Tautologies

Logical Necessities

TW Necessities

Tet(b) Tet(b)

a=a

Tet(b) Cube(b) Dodec(b)

Cube(a) Small(a)

Page 80: can’t be c

Tautological Equivalence

Two sentences S and S’ are tautologically equivalent if and only if every row of their joint truth table assigns the same values to S and S’.

Page 81: can’t be c

Example

P Q P --> Q ~P v QT T T TT F F FF T T TF F T T

Reference Columns S S’

Page 82: can’t be c

Logical Equivalence

Two sentences S and S’ are logically equivalent if and only if every non-spurious row of their joint truth table assigns the same values to S and S’.

Page 83: can’t be c

Example

a=b Cube(a) Cube(b) a=b ̂Cube(a) a=b ̂Cube(b)T T T T TT T F T F SpuriousT F T F T SpuriousT F F F FF T T F FF T F F FF F T F FF F F F F

Not Tautologically Equivalent Logically Equivalent

Reference Columns S S’

Page 84: can’t be c

Tautological Consequence

Sentence Q is a tautological consequence of P1, P2, …, Pn if and only if every row that assigns true to all of the premises also assigns true to Q.

Page 85: can’t be c

Example

P Q P v Q Q PT T T F TT F T T TF T T F FF F F T F

Reference Columns Premises Conclusion

Page 86: can’t be c

Logical Consequence

Sentence Q is a logical consequence of P1, P2, …, Pn if and only if every non-spurious row that assigns true to all of the premises also assigns true to Q.

Page 87: can’t be c

Example

a=b b=c a=c a=b ̂b=c a=cT T T T TT T F T F SpuriousT F T F T SpuriousT F F F FF T T F T SpuriousF T F F FF F T F TF F F F F

Reference Columns Premises Conclusion

Page 88: can’t be c

Summary

Every tautological consequence of a set of premises is a logical consequence of these premises.

Not every logical consequence of a set of premises is a tautological consequence of these premises.

Page 89: can’t be c

Summary

Every tautological equivalence is a logical equivalence.

Not every logical equivalence is a tautological equivalence.

Page 90: can’t be c

Summary

Every tautology is a logical necessity. Not every logical necessity is a tautology.

Page 91: can’t be c

Negative Elimination

P

. . .

P Elimination

Page 92: can’t be c

Negative IntroductionProof by contradiction

P

. . .

P Introduction

Page 93: can’t be c

Negative IntroductionProof by contradiction

P

. . .

P Introduction

Page 94: can’t be c

Bottom Elimination

. . .

P Elimination

Anything you wish follows

from a contradiction

Page 95: can’t be c

A BBA

1. A B2. B 3. A 4. A 5. Intro: 4, 3

6. B 7. Intro: 6, 2 8. Elim: 1, 4-5, 6-79. A Intro: 3-810. A Elim: 9

Prove:

Page 96: can’t be c

Material Conditional

PQ

P is called the antecedent and Q is called the consequent.

Page 97: can’t be c

Definition of

P Q P Q

T T T

T F F

F T T

F F T

Page 98: can’t be c

English Translations

If P then Q

P implies Q P only if Q P is sufficient for Q

Q provided that P

Q is necessary for P

Q if P

P

Q

Large

Cube

Page 99: can’t be c
Page 100: can’t be c

P Q

If not P then QUnless P, QQ, unless P

Unless Max is at home, Claire won’t get the message.

b is cube, unless it is large.

Home(max) GetsMessage(claire)

Large(b) Cube(b)

Page 101: can’t be c

Equivalencies

P Q

P Q

Q P

Page 102: can’t be c

Biconditional

P Q

Page 103: can’t be c

English Translations

P if and only if Q P just in case Q P is a necessary and sufficient condition for

Q.

Page 104: can’t be c

Definition of

P Q PQ

T T T

T F F

F T F

F F T

Page 105: can’t be c

Equivalencies

PQ

(P Q) (Q P)

(P Q) (P Q)

P and Q are sufficient and necessary for each other.

Page 106: can’t be c

Well-formed Formula (wff)

Any atomic sentence is a wff. If A are B are wffs then so are

A A B A B A B A B

Page 107: can’t be c

Elimination

P Q …

P … Q Elim

Page 108: can’t be c

Inference Patterns

Modus Tollens P Q Q P

Page 109: can’t be c

Modus Tollens

Page 110: can’t be c

Introduction

P …

Q P Q Intro

Page 111: can’t be c

Example

Prove this argument is valid.

P (Q P)

Page 112: can’t be c

Elimination

P Q …

P … Q Elim

Page 113: can’t be c

Introduction

P … Q

Q … P P Q

Intro

Page 114: can’t be c

Example

Deduce A C from A B and B C.

Called Hypothetical

Syllogism

Page 115: can’t be c

Law of Excluded Middle

P P

A TautologyWeakest

form of Taut Con

Prove from P P (may use Law of Excluded Middle)

Page 116: can’t be c

Example

Page 117: can’t be c

Valid Argument

P1

P2

… Pn

Q

Q is a tautological (logical) consequence of P1, P2, …, Pn

(P1 P2 … Pn) Q is a tautology (logical necessity).

Valid Argument

Page 118: can’t be c

Example

Show P is a tautological consequence of (P Q).

Methods of attack: Boole

Show P is a tautological consequence of (P Q). Show (P Q) P is a tautology.

Fitch Show (P Q) is a valid argument

P

Page 119: can’t be c

Tautological Consequence

Page 120: can’t be c

Tautology

Page 121: can’t be c

Using Fitch

Page 122: can’t be c

Example

Show P is not a tautological consequence of (P Q).

Method of attack: Boole

Show P is not a tautological consequence of (P Q). Show (P Q) P is not a tautology.

Build a world Show (P Q) is an invalid argument

P

Page 123: can’t be c

Not a Tautological Consequence

Page 124: can’t be c

Not a Tautology

Page 125: can’t be c

Build a World

Let P be assigned true and Q false. (P Q) is true while P is false.

premises conclusion

Page 126: can’t be c

Example

Show the following argument is valid.

Cube(b) (Cube(c) Cube(b)) Cube(c)

Page 127: can’t be c

Logical Consequence

Cube(b) Cube(c) Cube(b) ~(Cube(b) ̂Cube(c )) ~Cube(c) is spurious?T T T F F noT F T T T noF T F T F noF F F T T no

Page 128: can’t be c

Logical Necessity

Cube(b) Cube(c) Cube(b) ~(Cube(b) ̂Cube(c) ~Cube(c) (Cube(b) ̂~(Cube(b) ̂Cube(c))) -> ~Cube(c)T T T F F TT F T T T TF T F T F TF F F T T T

Every non-spurious row is true! In fact, every row is true, so we have a tautology!!

Page 129: can’t be c

Fitch

Page 130: can’t be c

Non-consequence

Show the following argument is invalid.

Cube(a) Cube(b) (Cube(c) Cube(b)) Cube(c)

Page 131: can’t be c

Counterexample

Page 132: can’t be c

Tautological Consequence

Page 133: can’t be c

Tautology

Page 134: can’t be c

Clausal Form

Given a sentence S written in CNF S = ( ) ( ) . . . ( )

Convert each ( ) into a clause - a set consisting of each of the literals in the disjunction ( ).

Example: S = (A) (B C D) (A D)Clauses are: {A}, {B, C, D} and {A, D}

Page 135: can’t be c

Satisfying a Set of Clauses

Assigning truth-values to each of the literals so that at least one of the literals in each clause is assigned True.

Example: {{A, C, D}, {C}, {A}, {A, D}} issatisfied by A = False D =True C = True

Page 136: can’t be c

Empty Clause

{ } denoted by .�

The empty clause is not satisfied by any truth-assignment.

Example: Consider the fallacy A A represented by a set of clauses {{A}, { A}}.

No truth-assignment satisfies these clauses.

Page 137: can’t be c

Resolvent

A clause R is said to be a resolvent of clauses C1 and C2 if there is a literal in C1 whose negation is in clause C2 and R consists of all the remaining literals in either clause.

Example: {A, B, D} is a resolvent of the clauses {A, C , D} and {B, C}.

Page 138: can’t be c

Resolution Theorem

For any set of clauses that are not satisfiable, it is possible to arrive at the empty clause by applying a succession of resolution operations on Z.

Example: The fallacy (A) (A), whose set of clauses Z = {{A}, { A}} is not satisfiable since, {A} {A} �

Page 139: can’t be c

Example

Show A (B C) (C D) (A D) (B D) is not satisfiable.

Clauses: Z = {{ A}, {B, C}, {C, D}, {A, D}, {B, D}}.

{A} {A,D} {B,C} {C, D}

{D} {B, D} {B, D}

{D}

Page 140: can’t be c

Determine Validity of Argumentsusing Resolution

A sentence Q is a logical consequence of a set of sentences SS if and only if T = T =SS {Q} is not satisfiable.

Q

P1

P2

Pn

SS

Page 141: can’t be c

Logical Truths and Resolution

A sentence S, in conjunctive normal form, is a logical truth if and only if S is not satisfiable.

Example: S = P P is a logical truth.S = P P = {{P}, {P}}

{P} {P} this implies S is not satisfiable

Page 142: can’t be c

Example

Modus PonesPQ or PQ or { P,Q}

P or {P}

Q negate to get {Q}

Apply resolution: {P,Q} {P} {Q} {Q}

Page 143: can’t be c

PROLOG

Programs = facts + rules + queries

B. FactB:-A. Rule:-A. Query

Page 144: can’t be c

Example Prolog Program

grandfather(X,Y) :- father(X,Z), father(Z,Y).

grandFather(X,Y) :- father(X,Z), mother(Z,Y).

mother(ann,bill).father(carl,ed).father(nick,ann).father(ed,sam).

Page 145: can’t be c

What is a Horn sentence?

A positive literal is any literal that is not preceded with a . For example, Cube(b) and P are positive literals and Tet(c) and Q are negative literals.

A sentence S is a Horn sentence if and only if it is in conjunctive normal form and every conjunct is composed of at most one positive literal.

Page 146: can’t be c

Examples

(A B C) (A B)

(A B C) (D)

(A B) (C D)

Horn sentence

Not Horn sentence

(A C) (B C) (A D) (B D)

Horn sentence

Page 147: can’t be c

Why are Horn sentences important?

Unlike sentences in general, Horn sentences can easily be determined to be or not to be satisfiable.

Consider a sentence with 50 distinct literals. Its truth table has 250 rows.

Attack problem with a truth table?

Page 148: can’t be c

Satisfaction Algorithm for Horn sentences

(1) No conjunct in S consists of a single literal

(2) Some conjunct in S consists of a single literal S= L1 L2 … Lt ( ) … ( ) (May or may not be Satisfiable!!!)

Every conjunct in S has a negative literal

Take one conjunct at a time, assign a negative literal the truth-value of False. Since (False anything) is True this conjunct may be removed. Continue substituting this literal’s value into the remaining conjuncts. Repeat this processfor the next conjunct. Do this until no literals are left to assign. (ALWAYS Satisfiable!!!)

Page 149: can’t be c

Done = False; W=S;

Repeat Assign Li’s a truth-value of True (False) if positive (negative). Also replace their values inside ( )s.

If all conjuncts in S are True Done = True; W is satisfiable Else if there exists a conjunct in S whose value is False Done = False; W is not satisfiable Else Remove any conjunct in S which has at least one True. What remains are ( )s with disjunction of unassigned literals. Call this sentence S’.

If S’ is of form (1) Done = True; W is satisfiable Else W = S’Until Done

Page 150: can’t be c

Examples

S = (P Q) (P Q) (P Q)

S = (C A B) (A B) (C B) A

S = (A B) C B

Page 151: can’t be c

Alternate Form of Horn Conjunct

A1 A2... An B

(A1 A2 ... An) B

(A1 A2 ... An) B Conditional Formof

Horn sentence

Page 152: can’t be c

Special Cases

No positive literalA1 A2... An

No negative literalsB

(A1 A2 ... An) False

True B

Page 153: can’t be c

Logical Consequence Revisited

Theorem:A sentence Q is a logical consequence of a set of sentences SS if and only if S S {Q} is not satisfiable.

Page 154: can’t be c

CNF to PROLOG

A B C = (AC) B = (A C)B or

AC B

B :- A, C.A.C.

Query: :- B.

Page 155: can’t be c

Variables

Cube(b) Cube(d) The truth of this sentence is determined by the truth values of P and Q.

Cube(x) Cube(d) Cube(x) is neither true nor false, since x is a placeholder for the name of an object. x is said to be free or unbound.

Wffand a

sentence

Wffbut not asentence

Page 156: can’t be c

wff

If P is wff then so is P. If P1, P2, … , Pn are wffs then so is (P1 P2 … Pn).

If P1, P2, … , Pn are wffs then so is (P1 P2 … Pn).

If P and Q are wffs, so is (P Q). If P and Q are wffs, so is (P Q). If P is a wff and v is a variable, then v P is a wff. Every

occurrence of v is said to be bound. If P is a wff and v is a variable, then v P is a wff. Every

occurrence of v is said to be bound.

Page 157: can’t be c

Sentences

A sentence is a well-formed formula with no unbound (free) variables.

The scope of a quantifier is defined as those variables that fall under the quantifier’s influence as indicated by the enclosing parentheses.

Page 158: can’t be c

Unbounded Variables

x LeftOf(x, y)

x Cube(x) Large(x)

x Small(x) Tet(y)

x (Cube(c) SameRow(x, c))

Page 159: can’t be c

Satisfaction of a wff

Let S(x) be a wff with free variable x. An object b is said to satisfy S(x) if and only if S(b) is a true sentence.

Page 160: can’t be c

Semantics of Quantifiers

x S(x) is true if and only if there is at least one object that satisfies S(x).

x S(x) is true if and only if every object satisfies S(x).

The truth-value is determined withrespect to a domain of discourse!

Page 161: can’t be c
Page 162: can’t be c

Aristotelian Forms

All P’s are Q’s

x [P(x) Q(x)]

Q

P

Page 163: can’t be c

Aristotelian Forms

Some P’s are Q’s

x [P(x) Q(x)]

Q P

Page 164: can’t be c

Aristotelian Forms

No P’s are Q’s

x [P(x) Q(x)]

Q

P

Page 165: can’t be c

Aristotelian Forms

Some P’s are not Q’s

x [P(x) Q(x)]

Q P

Page 166: can’t be c

Translation

x (Tet(x) LeftOf(x, c))

x [Cube(x) BackOf(x, c)]

Some Tet is to the left of c.

Every cube is in back of c.

Page 167: can’t be c

Quantifiers and Functions

Everyone is taller than Max’s father.

Someone’s father is taller than Max.

x Taller(x, father(max))

x Taller(father(x), max)

Page 168: can’t be c

Quantifiers and Tautology

When is a sentence involving quantifiers a tautology?

Example: x Cube(x) x Cube(x)

Page 169: can’t be c

Truth-Functional Form Algorithm

Start at the beginning of sentence S and proceed to the right. If you encounter a quantifier, underline the quantifier and the entire formula that it is applied to. If you encounter an atomic sentence simply underline it. When you come to the end of an underline assign a letter (A, B, C, …). If an underlined sentence is identical to one that occurs previously (i.e., character for character), use the same letter to label it. Determine if the sentences formed in terms of these letters is a tautology. If it is, then the original is a tautology.

Page 170: can’t be c

When is a sentence a tautology?

A quantified sentence S is a tautology if and only if its truth-functional form is a tautology.

Page 171: can’t be c

Example

x Cube(x) x Cube(x)

A B

Since A B is not a tautology, then neither is the sentence above.

Page 172: can’t be c

Example

x Cube(x) [x Cube(x)]

A A

Since A A is a tautology, then so is the sentence above.

Page 173: can’t be c

Example

(Tet(d) x Small(x)) (Tet(d) y Small(y))

A B A C

(A B) (A C)

Page 174: can’t be c
Page 175: can’t be c

Tautological Valid?

Is the following argument valid or invalid?

x Cube(x)x Small(x)x (Cube(x) Small(x))

ABC

Not tautologically valid!!!In fact, it is not valid.

Page 176: can’t be c

Tautological Valid?

Is the following argument valid or invalid?

x Cube(x) x Small(x) x Cube(x) x Small(x)

A BAB

Is tautologically valid!!!

Page 177: can’t be c

Tautological Valid?

Is the following argument valid or invalid?

x [Cube(x) Small(x)]x Cube(x) x Small(x)

A BC

Is not tautologically valid.It is logically valid!

Page 178: can’t be c

Propositional Logic

Tautology Tautological Consequence Tautological Equivalence

Based on thetruth-functional

Connectives

Page 179: can’t be c

First-Order Logic

Takes into consideration all of the truth-functional connectives ( ), the identity symbol (=), and the quantifiers (x y).

Does not take the meanings of the names, functions or any predicates into consideration (other than =) when determining whether or not a sentence is a logical truth or whether or not an argument is valid, or whether or not two sentences are equivalent.

Page 180: can’t be c

First-Order Logic

FO Validity is a sentence that can’t be false. FO Consequence applies to an argument

whose conclusion can’t be made false, while at the same time, all of its premises are simultaneously true.

FO Equivalence applies to a pair of sentences that, in all possible circumstances, are satisfied by the same objects.

Page 181: can’t be c

Facts

All tautologies are FO Validities. All FO Validities are logical truths.

Tet(b) Tet(b) Tautologies

FO Validities

Logical truths

x Cube(x) Cube(a)

x LeftOf(x, x)

Page 182: can’t be c

Using Boole

spurious

Page 183: can’t be c

Using Fitch to Prove

Page 184: can’t be c

S is not a tautology, since A is not a tautology Even though we know that no object can be to the

left of itself. Consider replacing LeftOf with a meaningless predicate say R. Then it is not obvious that x R(x,x) is still a true statement.

In fact, if we let R be the = predicate, x (x = x) is false when the domain = integers.

S = x LeftOf(x, x)

Page 185: can’t be c

Using Fitch to Disprove

Page 186: can’t be c

Facts

All tautological consequences are FO Consequences.

All tautological equivalencies are FO Equivalencies.

Page 187: can’t be c

FO Consequence

x [P(x) Q(x)] Q(b)

P(b)

QP

b

x [Tet(x) Large(x)] Large(b)

Tet(b)

A B

C

C is not a tautological consequence of A and B

Page 188: can’t be c

Using Fitch

Page 189: can’t be c

Not an FO Consequence

x R(x,a)x R(b,x) R(c,d) R(a,b)

Interpret R(x,y) as x loves y.

The first line says, nobody loves a (Scrooge) including a (Scrooge).The second line says, b (Moriarty) loves nobody including b (Moriarty).The third line says, c (Romeo) loves d (Juliet).The conclusion says a (Scrooge) loves b (Moriarity).

Moriarty Scrooge Romeo Juliet

Page 190: can’t be c

Replacement Method

This method is used to determine if a sentence is an FO Validity or if an argument is an FO Consequence.

Page 191: can’t be c

Replacement Method

Replace all predicates in the sentence or in the argument with symbolic ones making sure that if a predicate appears more than once it is replaced with the same symbolic name.|

See if you can describe a circumstance where the sentence is false, if this is impossible then the sentence is a FO Validity.

See if you can describe a circumstance where the conclusion is false and the premises are all true. If this is impossible, then the conclusion is an FO Consequence of its premises.

Page 192: can’t be c

DeMorgan’s Laws for Quantifiers

x P(x) x [P(x)]Nobody is P.Everyone is not P.

x P(x) x [P(x)]It is not the case that everyone is P.Somebody is not P.

P

P

Page 193: can’t be c

Aristotelian Forms Revisited

Negate: All P’s are Q’s.

x[P(x) Q(x)] x [ (P(x) Q(x)) ] x [(P(x) Q(x))] x [P(x) Q(x)]

Some P’s are not Q’s

Page 194: can’t be c

A Special Form and its Equivalent

Only the Q’s are P’s

All P’s are Q’s

P

Qx [P(x) Q(x)]

x [P(x) Q(x)]

Page 195: can’t be c
Page 196: can’t be c

Other Equivalences

x [P(x) Q(x)] x P(x) x Q(x)

x [P(x) Q(x)] x P(x) x Q(x)

x [P(x) Q(x)] x P(x) x Q(x)

x [P(x) Q(x)] x P(x) x Q(x)

Page 197: can’t be c

Other Equivalences

x P P, where x is not free in P x P P, where x is not free in P x [P Q(x)] P x Q(x) x [P Q(x)] P x Q(x) x P(x) y P(y) x P(x) y P(y)

Page 198: can’t be c

Proofs Involving Quantifiers

Universal Elimination

x S(x) …

S(c) Elim

Page 199: can’t be c

Example

Prove

x Cube(x) x Large(x)

Large(d) Cube(d)]

Page 200: can’t be c
Page 201: can’t be c

Proofs Involving Quantifiers

Universal Introduction c

S(c)

x S(x) Intro

Assume c is anarbitrary elementin the domain ofdiscourse.

Page 202: can’t be c

Example

Prove

x Cube(x) x Large(x)

x [Large(x) Cube(x)]

Page 203: can’t be c
Page 204: can’t be c

Proofs Involving Quantifiers

Existential Introduction

S(c) …

x S(x) Intro

Page 205: can’t be c

Example

Prove

Cube(e) Large(e) LeftOf(e,a) x [Cube(x) LeftOf(x,a)]

Page 206: can’t be c
Page 207: can’t be c

Proofs Involving Quantifiers

Existential Elimination x S(x)

c S(c)

Q

Q Elim

Since there exists an x such that S(x),

let c designate this object.

Symbol c cannot appear outside this

subproof!

Page 208: can’t be c

Example

Prove

x Large(x) x Cube(x)

x [Large(x) Cube(x)]

Page 209: can’t be c
Page 210: can’t be c

General Conditional Proof

Universal Introduction c P(c)

Q(c)

x [P(x) Q(x)] Intro

Assume c is anarbitrary elementin the domain ofDiscourse and assume P(c)

Page 211: can’t be c

Example

Prove

x [P(x) Q(x)] z [Q(z) R(z)]

x [P(x) R(x)]

Page 212: can’t be c
Page 213: can’t be c

Order of Quantifiers vs. Meaning

x y P(x,y) is logically equivalent to y x P(x,y)

x y P(x,y) is logically equivalent to y x P(x,y)

x y P(x,y) is not logically equivalent to y x P(x,y)

Page 214: can’t be c

Careful

x y[(Cube(x) Cube(y)) (LeftOf(x,y) RightOf(x,y))]

x y[(Cube(x) Cube(y) xy) (LeftOf(x,y) RightOf(x,y))]

Page 215: can’t be c

Translation

x y P(x,y) For each x there is a yx such that P(x,y).

Page 216: can’t be c

Translation

x y P(x,y) There us a special x such that for all y, P(x,y).

Page 217: can’t be c

Example

Let Q(x,y) means x + y = x – y.

Determine if yx Q(x,y) is true or false using the integers as the domain of discourse. Let y = 0 (special element). Consider the reduced sentence,x Q(x,0) or x (x = x) is obviously true.

Determine if yx Q(x,y) is true or false using the integers as the domain of discourse. Let c represent an arbitrary but fixed y, i.e., y = c. Consider the reduced sentence, x Q(x,c) or x (x+c = x-c) or x (c = -c) which is false.

Page 218: can’t be c

Translation

All cubes are to the left of something large.x [Cube(x) x is to the left of something large]

x [Cube(x) y (Large(y) LeftOf(x, y))]

Some cube is to the left of everything large. x [Cube(x) x is to the left of everything large] x [Cube(x) y [Large(y) LeftOf(x,y)]]

Page 219: can’t be c

Translation Worksheet Handout

Page 220: can’t be c

At Least One

x P(x)

There exists an x such that P(x)

There is at least one x such that P(x)

Page 221: can’t be c

At Least Two

x y [P(x) P(y) xy]

There exists a pair (x,y) such that P(x) and P(y) and x is not equal to y.

There are at least two objects that satisfy P(x).

Page 222: can’t be c

At Least Three

x y z [P(x) P(y) P(z) xy xz yz]

There are at least three objects that satisfy P(x).

Page 223: can’t be c

At Least n

x1 x2…xn [P(x1) P(x2) … P(xn) x1 x2 x1 x3 … x1 xn

x2 x3 x2 x4 … x2 xn x3 x4 x3 x5 … x3 xn … xn-1 xn ]

There are at least n objects that satisfy P(x).

n existential quantifiers and Combinations(n,2) = n(n-1)/2 not equal to symbols

Page 224: can’t be c

Exactly One

x [P(x) y (P(y) yx)]

There exists an x such that P(x) and for any y that satisfies P(y) that y must equal x.

Exactly one x satisfies P(x).

Page 225: can’t be c

Exactly Two

x y [P(x) P(y) xy z (P(z) (zx zy)]

There exists an x and a y where xy , such that P(x) and P(y) and for any z that satisfies P(z) that z must equal either x or y.

Exactly two objects satisfies P(x).

Page 226: can’t be c

Exactly n

x1 x2…xn [P(x1) P(x2) … P(xn) x1 x2 x1 x3 … x1 xn

x2 x3 x2 x4 … x2 xn x3 x4 x3 x5 … x3 xn … xn-1 xn

z (P(z) (zx1 zx2 … zxn))]

Exactly n objects satisfies P(x).

Page 227: can’t be c

At Most One

“at most one” means either none or exactly one.

x P(x) says “nobody satisfies P(x)”

x [P(x) y (P(y) yx)] says “exactly one”

Combining gives x P(x) x [P(x) y (P(y) yx)]

Page 228: can’t be c

At Most One

“at most one” means (“at least two”)

(x y [P(x) P(y) xy])x y [P(x) P(y) x=y]

x y [(P(x) P(y)) x=y]

At most one objects satisfy P(x).

Page 229: can’t be c

At Most Two

“at most two” means (“at least three”)

(x y z [P(x) P(y) P(z) xy xz yz]) x y z [P(x) P(y) P(z) x=y x=z y=z]

x y z [(P(x) P(y) P(z)) (x=y x=z y=z)]

At most two objects satisfy P(x).

Page 230: can’t be c

At Most n

“at most n” means (“at least n+1”)

(x1x2 …xn+1[P(x1) P(x2) … P(xn+1) x1 x2 x1 x3 … x1 xn+1

x2 x3 x2 x4 … x2 xn+1 x3 x4 x3 x5 … x3 xn+1 … xn xn+1 ]) At most n objects satisfy P(x).

Page 231: can’t be c

At Most n

x1 x2 … xn+1[P(x1) P(x2) … P(xn+1) x1= x2 x1= x3 … x1= xn+1

x2 = x3 x2 = x4 … x2 = xn+1

x3 = x4 x3 = x5 … x3 = xn+1 …

xn = xn+1 ])

Page 232: can’t be c

At Most n

x1 x2 … xn+1[(P(x1) P(x2) … P(xn+1)) (x1= x2 x1= x3 … x1= xn+1

x2 = x3 x2 = x4 … x2 = xn+1

x3 = x4 x3 = x5 … x3 = xn+1 …

xn = xn+1 )]

Page 233: can’t be c

Models of Computation

Function (table look-up) Finite-state Automata

Page 234: can’t be c

XOR Table

Combine two n-bit binary numbers using exclusive or

Table size = 2n x 2n rows

If n = 32 then table size 1.8 x 1019

Page 235: can’t be c

XOR Automata

0 1

00, 11

00, 11

01, 10

01, 10

1 1 0 1 0 0 1 1 01 0 0 1 1 0 0 1 10 1 0 0 1 0 1 0 1

Page 236: can’t be c

Mathematical Preliminaries

Set – a group of objects represented as a unit.{a, b, c}= {a, b, c, b} = {b, c, a}

Sequence – a list of objects in some order.(a, b, c) (b, c, a)(a, b, c, b) (a, b, c)

Page 237: can’t be c

Mathematical Preliminaries

Cartesian Product A x B =

{(x,y) | x A and y B}

Generalized Cartesian ProductA1 x A2 x … x An =

{(a1, a2, …, an) | ai Ai for each i}

Page 238: can’t be c

Mathematical Preliminaries

Function f: D Rf associates each element d D with some element r R. This association is denoted f(d) = r.

Example: f(x) = (x + 1) mod 3D = {1, 2, 3, 4} R = {0, 1, 2}

Page 239: can’t be c

Mathematical Preliminaries

Example: f(x,y) = max(x,y)f: A x A A where A = {1, 2, 3}

(1,1) 1(1,2) 2(1,3) 3(2,1) 2(2,2) 2(2,3) 3(3,1) 3(3,2) 3(3,3) 3

Page 240: can’t be c

Mathematical Preliminaries

Alphabet – a finite set of symbols called . A string s over is a finite sequence of symbols

from . The length of s is the number of symbols it contains, designated |s|.

is used to represent the empty string. Let s and t be strings over , st is the string

obtained by appending string t to the end of string s.

Page 241: can’t be c

Mathematical Preliminaries

A language is a set of strings over . Lexicographic ordering is dictionary order of

strings in which shorter strings precede longer strings. Example: { 0, 1, 00, 01, 10, 11, 000, 001} – lexicographic order

{ 0, 00, 000, 001, 01, 1, 10, 11} – dictionary order

Page 242: can’t be c

Finite Automaton

5 - tuple M = (Q, , , q0, F)

Q is a finite set of states

is an alphabet :Q x Q is the transition function q0 Q is the starting state F Q is the set of accept states.

Page 243: can’t be c

JFLAP software

www.jflap.org

Page 244: can’t be c

Example M1

q0 q1 q2

0

11

0

0, 1

q1

Q = {q0 , q1 , q2}

= {0, 1} F = {q1}

Page 245: can’t be c

Language Recognized

A string w is accepted by M if and only if after processing each symbol of w M finds itself in a state belonging to F (otherwise, we say w is rejected by M).

If A is the set of all strings accepted by M, we say A is the language of machine M, denoted by L(M) = A. M is said to recognize A.

Page 246: can’t be c

More Formally

Let w = w1w2…wn be a string accepted by M then there exists states r0, r1, …, rn in Q satisfying

1) r0 = q0

2) (ri, wi+1) = ri+1, where i = 0, …, n-13) rn in F

Page 247: can’t be c

Regular Language

A language is called a regular language if some finite automaton recognizes it.

Page 248: can’t be c

Creating a Automaton

Given a language L over an alphabet , design a deterministic finite automaton (DFA) M such that L(M) = L.

Page 249: can’t be c

Example 1

L1 = {w | w is a string over ={0,1} that contains an even number of 0s and an odd number of 1s }

Method:Define nodes to represent when a) both an even number of 0s and 1s have been seen in the input b) both an odd number of 0s and 1s have been seen in the input c) an even number of 0s and an odd number of 1s have been seen in the input d) an even number of 1s and an odd number of 0s have been seen in the input

Page 250: can’t be c

qoe qoo

qee

1

01

0 00

1

1

qeo

Example 1

Page 251: can’t be c
Page 252: can’t be c

Example 2 (complement)

L2 = {w | w is a string over ={0,1} that does not contain an even number of 0s and an odd number of 1s } = L1

Page 253: can’t be c

qeo

1

01

0 00

1

1

Example 2

qee

qoeqoo

Page 254: can’t be c

Example 3

L3 = { w | w is a string over {0, 1} such that |w| 3}

= {, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, 100, 101, 110, 111}

Starting state must be final

Page 255: can’t be c

Example 3

q0 q1q2

0, 1 0, 1q3

0, 1

0, 1

q4

0, 1

Page 256: can’t be c

Example 4

L4 = {w | w is a string over ={0,1} such that w contains the substring 11} = { w | w = x11y, where x and y are strings over ={0, 1}}

Page 257: can’t be c

Example 4

q0 q1

0

1

0

1q2

0, 1

0 1q0 q0 q1q1 q0 q2q2 q2 q2f

s

Page 258: can’t be c

Machine M accepts string w

If there exists a sequence of states r0, r1, …, rn in Q such that 1) r0 = q0 2) (ri , wi+1) = ri+1, for i=0,…,n-1 3) rn in F

Note: w = w1w2…wn

Page 259: can’t be c

Regular Languages

Machine M recognizes language A if A = {w| M accepts w}

A language is called regular if some finite automaton recognizes it.

Page 260: can’t be c

Regular Languages

Machine M recognizes language A if A = {w| M accepts w}

A language is called regular if some finite automaton recognizes it.

Page 261: can’t be c

Regular Operations

Let A and B be languages. Union

A B = { x | x in A or x in B}

ConcatenationA B = {xy | x in A and y in B}

StarA* = {x1x2…xk | k 0 and each xj in A}

Note: is always a member of A*.

Page 262: can’t be c

Regular languages are closed under union

Let A1 and A2 be regular languages. We want to show A1A2 is a regular language. Since A1 and A2 are regular languages there exists a finite automaton M1 and there exists a finite automaton M2 such that M1 recognizes A1 and M2 recognizes A2.

Assume M1 = (Q1, , 1, q1, F1) and M2 = (Q2, , 2, q2, F2) It suffices to create a finite automaton M that recognizes A1A2.

Page 263: can’t be c

Continue …

Let a be a symbol in and states r1 in Q1 and r2 in Q2. Define M = (Q, , , q0, F) where

Q = Q1 x Q2 states

((r1, r2), a) = (1(r1, a), 2(r2, a)) transition function

q0 = (q1, q2) start state

F = (F1 x Q2) (Q1 x F2) final states

Page 264: can’t be c

Example

u v

0,1

01

M1

x z

0

0,1

M2

y1

10M = (Q, , , q0, F) Q = {(u,x), (v,x), (u,y), (v,y), (u,z), (v,z)} statesq0 = (u, x) start stateF = {(v,x), (v,y), (v,z)} {(u,z), (v,z)} = {(v,x), (v,y), (v,z), (u,z)} final states 0 1

(u,x) ((u),2(x)) = (v,z) ((u),2(x)) = (v,y)

(u,y) ((u),2(y)) = (v,y) ((u),2(y)) = (v,z)

(u,z) ((u),2(z)) = (v,y) ((u),2(z)) = (v,y)

(v,x) ((v),2(x)) = (v,z) ((v),2(x)) = (u,y)

(v,y) ((v),2(y)) = (v,y) ((v),2(y)) = (u,z)

(v,z) ((v),2(z)) = (v,y) ((v),2(z)) = (u,y)

Page 265: can’t be c

Regular languages are closed under concatenation

Let A1 and A2 be regular languages. We want to show

A1 A2 is a regular language. Since A1 and A2 are regular languages there exists a finite automaton M1 and there exists a finite automaton M2 such that M1 recognizes A1 and M2 recognizes A2.

Assume M1 = (Q1, , 1, q1, F1) and M2 = (Q2, , 2, q2, F2) It suffices to create a finite automaton M that recognizes

A1 A2. There is a problem since M doesn’t know where to subdivide the input string into the part accepted by M1 and the remaining part that will be accepted by M2. We will return to this later.

Page 266: can’t be c

Regular Expressions

R is a regular expression if1) x for some x in (note: regular expression x represents language {x})

2) (empty string) (note: regular expression represents language {}) 3) (empty set)4) (R1 R2) where R1 and R2 are regular expressions5) (R1 R2) where R1 and R2 are regular expressions6) (R1*) where R1 is a regular expression

If R is a regular expression then L(R) is the language of R.

Page 267: can’t be c

Non-Deterministic Automaton

NFAs generalize DFAs. In a DFA, each state has exactly one transition for each

symbol in the alphabet. In an NFA, at any state there may be zero or more

transitions for a symbol in the alphabet. In a DFA, a label on a transition arrow is a symbol in the

alphabet. In an NFA, a label on a transition arrow is a symbol in

the alphabet or .

Page 268: can’t be c

Example

q1 q2 q3

0, 1

1 0, 1

0, 1

q4

Page 269: can’t be c

q1

q1

q1

q2

q1

q3

q2 q4q3

q3q1

q4q4q3q2q1

q3q1 q4 q4

0

1 11

00

11

1 1

0 0 0 0

1 1 1 1 1

Input:010110

Page 270: can’t be c

Non-Deterministic Finite Automaton

N = (Q, , , q0, F)

Q is a finite set of states is a finite alphabet : Q x ( {}) (Q) F Q is a set of accept states

(Q) is the powerset of Q =

{X| X Q}

Page 271: can’t be c

Machine N accepts string w

If there exists a sequence of states r0, r1, …, rn in Q such that 1) r0 = q0 2) ri+1 in (ri , wi+1) for i=0,…,n-1 3) rn in F

Note: w = w1w2…wn (ri , wi+1) is a set of states

Page 272: can’t be c

Are NFAs more powerful than DFAs?

Every deterministic finite automaton has an equivalent non-deterministic finite automaton. (see next slide)

Every non-deterministic finite automaton has an equivalent deterministic finite automaton.

Page 273: can’t be c

Non-deterministic?

q0 q1

0

1

0

1q2

0, 1

0 1q0 q0 q1q1 q0 q2q2 q2 q2

0 1{q0} {q0} {q1}{q1} {q0} {q2}{q2} {q2} {q2}

Non-deterministic interpretationDeterministic interpretation

Page 274: can’t be c

Deterministic Equivalent?

1

2 3

b

a, b

a

a

with edges without edges

1 20

3

01

NN

Next four slides color coded with respect to these examples

= {0, 1} = {a, b}

Page 275: can’t be c

DFA from NFA Construction

Assume no edges.Let N = (Q, , , q0, F)be an NFA that recognizes language A. We construct a DFA called M = (Q’, , ’, q0’, F’)

1) Q’ = (Q) 2) For R in Q’ and a in let ’(R,a) = {q in Q| q in (r,a) for some r in R}

= (r,a)

r in R

Q’ = {{}, {1}, {2}, {3}, {1,2}, {1,3}, {2,3}, {1,2,3}}

’({1,2},b) = (1,b) (2,b) = {2} {3} = {2,3}

Q’ = {{}, {1}, {2}, {3}, {1,2}, {1,3}, {2,3}, {1,2,3}}

’({2, 3},0) = (2,0) (3,0) = {} {} =

Page 276: can’t be c

Continued …

3) q0’ = { q0} 4) F’ = {R in Q’| R contains an accept state of N} (do blue example)

Assume edges, then we need these modifications.Let R be a state of M. Define E(R) = {q in Q| q can be reached from R traveling along 0 or more edges}

Modify ’(R,a) = {q in Q| q in E((r,a)) for some r in R}

= E((r,a)) transition function r in R

’({1,2},b) = E((1,b)) E((2,b)) = E({2}) E({3}) = {2,3} ’({3},a) = E((3,a)) = E({1}) = {1,3}

q0’ = E({q0}) start state (do red example)

Page 277: can’t be c

Find Deterministic Equivalent

0 1{ } { } { }{1} { 2,3} { }

{2,3} { } {1}

Deterministic Equivalent

Start state q0’= {1}Final states F’ = { {2,3} }

without edges

1 20

3

01

N

Page 278: can’t be c

Solution

{1}

{ }

{2,3}

0, 1

0

1 0

1M

Page 279: can’t be c

Find Deterministic Equivalent

1

2 3

b

a, b

a

a

a b{ } { } { }{1} { } {2}{2} {2,3} {3}{3} {1,3} { }

{1,2} {2,3} {2,3}{1,3} {1,3} {2}{2,3} {1,2,3} {3}

{1,2,3} {1,2,3} {2,3}

Deterministic Equivalent

Start state q0’= E({1}) = {1,3}Final states F’ = { {1}, {1,2}, {1,3}, {1,2,3} }

N

Page 280: can’t be c

Final Solutiona

{1,3}

{2}

b

{3}a

{ }b

b

{2,3}a

b

a, b

a

b

a

{1,2,3}

b

{1,2}

a, b {1}

a

M

Page 281: can’t be c

Regular languages are closed under union

Let A1 and A2 be regular languages. We want to show A1A2 is a regular language. Since A1 and A2 are regular languages there exists an NFA N1 and there exists an NFA N2 such that N1 recognizes A1 and N2 recognizes A2.

Assume N1 = (Q1, , 1, q1, F1) and N2 = (Q2, , 2, q2, F2) It suffices to create a NFA N that recognizes A1A2.

Page 282: can’t be c

Construction of NFA

N1

N2

q1

q2

q0

N = (Q, , , q0, F)Q = {q0} Q1 Q2

F = F1 F2

1 (q,a) q in Q1 (q,a) = 2 (q,a) q in Q2 {q1, q2} q = q0 and a= { } q = q0 and a

Nq1

q2

Page 283: can’t be c

Example Union

u v

0,1

01

M1

x z

0

0,1

M2

y1

10

q0

See slide 260 (union) for original machines

Page 284: can’t be c

Regular languages are closed under concatenation

Let A1 and A2 be regular languages. We want to show

A1 A2 is a regular language. Since A1 and A2 are regular languages there exists an NFA N1 and there exists an NFA N2 such that N1 recognizes A1 and N2 recognizes A2.

Assume N1 = (Q1, , 1, q1, F1) and N2 = (Q2, , 2, q2, F2)

It suffices to create a NFA N that recognizes A1 A2.

Page 285: can’t be c

Construction of NFA

N1

N2

N = (Q, , , q1, F2)Q = Q1 Q2 and q1 (start state) and F = F2

1 (q,a) q in Q1 and q not in F1 (q,a) = 2 (q,a) q in Q2

1 (q,a) {q2} q in F1 and a= (add edges to q2 keep edges from final states in N1)

1 (q,a) q in F1 and a (keep non- edges from final states in N1)

q1

q2

q1q2

N

Not

Not

Page 286: can’t be c

Example Concatenation

u v

0,1

01

M1

x z

0

0,1

M2

y1

10

Page 287: can’t be c

Regular languages are closed under the star operation

Let A be a regular language. We want to show A* is a regular language. Since A is regular language there exists an NFA N1 such that N1 recognizes A.

Assume N1 = (Q1, , 1, q1, F1) It suffices to create a NFA N that recognizes A*.

Page 288: can’t be c

Construct NFA

N1

N

N = (Q, , , q0, F)Q = {q0} Q1 F = F1 {q0} and q0 the start state

1 (q,a) q in Q1 and q not in F1

(q,a) = 1 (q,a) q in F1 and a 1 (q,a) {q1} q in F1 and a= {q1} q = q0 and a= { } q= q0 and a

q0

q1

q1

Page 289: can’t be c

Find Star of M2

x z

0

0,1

M2

y1

10

x z

0

0,1

M2*

y1

10q0

Page 290: can’t be c

Regular Expressions

R is a regular expression if1) x for some x in (note: regular expression x represents language {x})

2) (empty string) (note: regular expression represents language {}) 3) (empty set)4) (R1 R2) where R1 and R2 are regular expressions5) (R1 R2) where R1 and R2 are regular expressions6) (R1*) where R1 is a regular expression

If R is a regular expression then L(R) is the language of R.

Page 291: can’t be c

Examples

0*0 {w| w contains at least one zero} * = {} 11 00 = {11, 00} 0 *1 = {w| w begins with a 0 and ends in a 1} (01)* = {, 01, 0101, 010101, 01010101, …} 1*0 = {w| w contains any number of 1s followed by exactly one 0}

Page 292: can’t be c

Using Regular Expressions

Page 293: can’t be c

Beginning or End?

Page 294: can’t be c

Regular Expressions vs. Regular Languages

A language is regular if and only if some regular expression describes it.

Part a) If a regular expression describes a language then it is regular.

Part b) If a language is regular then a regular expression describes it.

Page 295: can’t be c

x

NFA that recognizes {x}

x

Page 296: can’t be c

NFA that recognizes {}

Page 297: can’t be c

NFA that recognizes

Page 298: can’t be c

R1 R2, R1 R2, or R1*

Construct a machine the same way we did to show regular languages are closed under , , or *.

Page 299: can’t be c

NFA to recognize (0 11)*

0 1

11

0

11

Page 300: can’t be c

NFA to recognize (0 11)*

0

11

0

11

Page 301: can’t be c

Part b) If a language is regular then a regular expression describes it.

Properties of GNFA1) The start state has transition arrows going to every other state but no arrows coming in from any other state.2) There is one accept state, and it has arrows coming in from every other state but no arrows going to any other state. The start state is not the same as the final state.3) Except for the start and accept states, one arrow goes from every state to every other state and also from each state to itself.4) The labels on each edge is a regular expression.

Page 302: can’t be c

Example GNFA

start accept

ab*

b

ab ba

b*

ab

aa

(aa)*a*