Cs133 lec01

Page 1

Finite Automata

Regular Languages

Nondeterminism

CS 133 : Automata Theory and Computability Regular Languages and Finite Automata Henry N. Adorna Nestine Hope S. Hernandez Algorithms and Complexity Laboratory Department of Computer Science University of the Philippines, Diliman {hnadorna,nshernandez}@dcs.upd.edu.ph

LEC 1


Finite Automata

Regular Languages

Regular Languages and Finite Automata

Finite Automata Introduction Formal Definition of a Finite Automaton Designing Finite Automata

Regular Languages

Nondeterminism Nondeterministic Finite Automata

Nondeterminism


Finite Automata

Regular Languages

Nondeterminism

Finite Automata • also known as finite state machines • one of the simplest models of computation • excellent models for computers with an extremely limited amount

of memory


Finite Automata

Regular Languages

Nondeterminism

Finite Automata • also known as finite state machines • one of the simplest models of computation • excellent models for computers with an extremely limited amount

of memory

Examples: • automatic door • elevator control • vending machine • calculator


Finite Automata

Regular Languages

Nondeterminism

Finite Automata • also known as finite state machines • one of the simplest models of computation • excellent models for computers with an extremely limited amount

of memory • are also the basis for programs that perform spell checking,

grammar checking, indexing • fundamental in the study of compilers


Finite Automata

Regular Languages

Automatic Door

Example Automatic Door Controller:

Nondeterminism


Finite Automata

Regular Languages

Automatic Door

Example Automatic Door Controller: It has two input pads - one on each side of the door.

Nondeterminism


Finite Automata

Regular Languages

Automatic Door

Example Automatic Door Controller: It has two input pads - one on each side of the door. The door is in one of the two states: OPEN or CLOSED.

Nondeterminism


Finite Automata

Regular Languages

Automatic Door

Example Automatic Door Controller: It has two input pads - one on each side of the door. The door is in one of the two states: OPEN or CLOSED. (Note: It opens from front to rear.)

Nondeterminism


Finite Automata

Regular Languages

Automatic Door

Example Automatic Door Controller: It has two input pads - one on each side of the door. The door is in one of the two states: OPEN or CLOSED. (Note: It opens from front to rear.) Four scenarios:

Nondeterminism


Finite Automata

Regular Languages

Automatic Door

Example Automatic Door Controller: It has two input pads - one on each side of the door. The door is in one of the two states: OPEN or CLOSED. (Note: It opens from front to rear.) Four scenarios: • FRONT - person on front pad only • REAR - person on rear pad only • BOTH - people on both pads • NEITHER - nobody on both pads

Nondeterminism


Finite Automata

Regular Languages

Nondeterminism

Automatic Door

Example Automatic Door Controller: It has two input pads - one on each side of the door. The door is in one of the two states: OPEN or CLOSED. (Note: It opens from front to rear.) Four scenarios: • FRONT - person on front pad only • REAR - person on rear pad only • BOTH - people on both pads • NEITHER - nobody on both pads

What happens if the door is CLOSED and someone is on the FRONT pad?


Finite Automata

Regular Languages

Nondeterminism

Automatic Door

Example Automatic Door Controller: It has two input pads - one on each side of the door. The door is in one of the two states: OPEN or CLOSED. (Note: It opens from front to rear.) Four scenarios: • FRONT - person on front pad only • REAR - person on rear pad only • BOTH - people on both pads • NEITHER - nobody on both pads

What happens if the door is CLOSED and someone is on the FRONT pad? on the REAR pad? on BOTH? NEITHER?


Finite Automata

Regular Languages

Nondeterminism

Automatic Door

Example Automatic Door Controller: It has two input pads - one on each side of the door. The door is in one of the two states: OPEN or CLOSED. (Note: It opens from front to rear.) Four scenarios: • FRONT - person on front pad only • REAR - person on rear pad only • BOTH - people on both pads • NEITHER - nobody on both pads

What happens if the door is CLOSED and someone is on the FRONT pad? on the REAR pad? on BOTH? NEITHER? What if it was OPEN?


Finite Automata

Regular Languages

Automatic Door Controller as an Automaton Can be represented by:

Nondeterminism


Finite Automata

Regular Languages

Automatic Door Controller as an Automaton Can be represented by:

• a state diagram

Nondeterminism


Finite Automata

Regular Languages

Automatic Door Controller as an Automaton Can be represented by:

• a state diagram

Nondeterminism


Finite Automata

Regular Languages

Automatic Door Controller as an Automaton Can be represented by:

• a state diagram • a state transition table

Nondeterminism


Finite Automata

Regular Languages

Nondeterminism

Automatic Door Controller as an Automaton Can be represented by:

• a state diagram • a state transition table

CLOSED OPEN

NEITHER CLOSED CLOSED

FRONT OPEN OPEN

REAR CLOSED OPEN

BOTH CLOSED OPEN


Finite Automata

Regular Languages

Nondeterminism

Automatic Door Controller as an Automaton Can be represented by:

• a state diagram • a state transition table

CLOSED OPEN

NEITHER CLOSED CLOSED

FRONT OPEN OPEN

REAR CLOSED OPEN

BOTH CLOSED OPEN

Depending on the size of your problem, one method may be easier to understand than the other.


Finite Automata

Regular Languages

Nondeterminism

Automatic Door Controller as an Automaton Can be represented by:

• a state diagram • a state transition table

CLOSED OPEN

NEITHER CLOSED CLOSED

FRONT OPEN OPEN

REAR CLOSED OPEN

BOTH CLOSED OPEN

Depending on the size of your problem, one method may be easier to understand than the other. When designing more complicated devices, using a standard methodology and terminology becomes very important.


Finite Automata

Regular Languages

Definition A finite automaton is a 5-tuple (Q, Σ, δ, q0 , F ),

Nondeterminism


Finite Automata

Regular Languages

Definition A finite automaton is a 5-tuple (Q, Σ, δ, q0 , F ), where 1. Q is a finite set called the states, 2. Σ is a finite set called the alphabet, 3. δ : Q × Σ → Q is the transition function, 4. q0 ∈ Q is the initial or start state, and 5. F ⊆ Q is the set of accept(final) states.

Nondeterminism


Finite Automata

Regular Languages

Definition A finite automaton is a 5-tuple (Q, Σ, δ, q0 , F ), where 1. Q is a finite set called the states, 2. Σ is a finite set called the alphabet, 3. δ : Q × Σ → Q is the transition function, 4. q0 ∈ Q is the initial or start state, and 5. F ⊆ Q is the set of accept(final) states. M1 :

Can you descibe M1 formally?

Nondeterminism


Finite Automata

Regular Languages

Nondeterminism

State Diagrams for Finite Automata

State diagrams can be used to represent finite automata as follows:


Finite Automata

Regular Languages

Nondeterminism

State Diagrams for Finite Automata

State diagrams can be used to represent finite automata as follows: • The states are represented as vertices


Finite Automata

Regular Languages

Nondeterminism

State Diagrams for Finite Automata

State diagrams can be used to represent finite automata as follows: • The states are represented as vertices • Directed edges labeled with the input represent the transitions


Finite Automata

Regular Languages

Nondeterminism

State Diagrams for Finite Automata

State diagrams can be used to represent finite automata as follows: • The states are represented as vertices • Directed edges labeled with the input represent the transitions • Final states are drawn with double circles


Finite Automata

Regular Languages

Nondeterminism

State Diagrams for Finite Automata

State diagrams can be used to represent finite automata as follows: • The states are represented as vertices • Directed edges labeled with the input represent the transitions • Final states are drawn with double circles • A special arrow pointing from nowhere indicates the start state


Finite Automata

Regular Languages

Nondeterminism

Formal Definition of Computation

Definition A finite automaton M = (Q, Σ, δ, q0 , F ) accepts a string w = w1 w2 · · · wn if a sequence of states r0 , r1 , · · · , rn ∈ Q exists with the three conditions: • r0 = q0 • δ(ri , wi+1 ) = ri+1 , for i = 0, 1, · · · , n − 1 • rn ∈ F

We say that M recognizes A if A = {w|M accepts w}.


Finite Automata

Regular Languages

Nondeterminism

We say that an input string ω is accepted by a finite state automaton M if it starts from q0 and ends at an accept state.


Finite Automata

Regular Languages

Nondeterminism

We say that an input string ω is accepted by a finite state automaton M if it starts from q0 and ends at an accept state. The language recognized by the finite automaton M , denoted by L(M ), is the set of all strings that are accepted by M .


Finite Automata

Regular Languages

Nondeterminism

We say that an input string ω is accepted by a finite state automaton M if it starts from q0 and ends at an accept state. The language recognized by the finite automaton M , denoted by L(M ), is the set of all strings that are accepted by M . M1 :

Can you describe L(M1 )?


Finite Automata

Regular Languages

Nondeterminism

We say that an input string ω is accepted by a finite state automaton M if it starts from q0 and ends at an accept state. The language recognized by the finite automaton M , denoted by L(M ), is the set of all strings that are accepted by M . M1 :

Can you describe L(M1 )? Let A = {ω|ω contains at least one 1 and an even number of 0s follow the last 1}.


Finite Automata

Regular Languages

Nondeterminism

We say that an input string ω is accepted by a finite state automaton M if it starts from q0 and ends at an accept state. The language recognized by the finite automaton M , denoted by L(M ), is the set of all strings that are accepted by M . M1 :

Can you describe L(M1 )? Let A = {ω|ω contains at least one 1 and an even number of 0s follow the last 1}. Then L(M1 ) = A,


Finite Automata

Regular Languages

Nondeterminism

We say that an input string ω is accepted by a finite state automaton M if it starts from q0 and ends at an accept state. The language recognized by the finite automaton M , denoted by L(M ), is the set of all strings that are accepted by M . M1 :

Can you describe L(M1 )? Let A = {ω|ω contains at least one 1 and an even number of 0s follow the last 1}. Then L(M1 ) = A, or equivalently, M1 recognizes A.


Finite Automata

Regular Languages

Nondeterminism

We say that an input string ω is accepted by a finite state automaton M if it starts from q0 and ends at an accept state. The language recognized by the finite automaton M , denoted by L(M ), is the set of all strings that are accepted by M . M1 :

Can you describe L(M1 )? Let A = {ω|ω contains at least one 1 and an even number of 0s follow the last 1}. Then L(M1 ) = A, or equivalently, M1 recognizes A. Note: A machine may accept several strings, but it always recognizes only one language.


Finite Automata

Regular Languages

M2 :

Terms: • state diagram • states • start state • accept state • transitions • accept or reject • language recognized by the finite automaton

Nondeterminism


Finite Automata

Regular Languages

M2 :

Terms: • state diagram • states • start state • accept state • transitions • accept or reject • language recognized by the finite automaton

Nondeterminism


Finite Automata

Regular Languages

M2 :

Terms: • state diagram • states • start state • accept state • transitions • accept or reject • language recognized by the finite automaton

Nondeterminism


Finite Automata

Regular Languages

M2 :

Terms: • state diagram • states • start state • accept state • transitions • accept or reject • language recognized by the finite automaton

Nondeterminism


Finite Automata

Regular Languages

M2 :

Terms: • state diagram • states • start state • accept state • transitions • accept or reject • language recognized by the finite automaton

Nondeterminism


Finite Automata

Regular Languages

M2 :

Terms: • state diagram • states • start state • accept state • transitions • accept or reject • language recognized by the finite automaton

Nondeterminism


Finite Automata

Regular Languages

M2 :

Terms: • state diagram • states • start state • accept state • transitions • accept or reject • language recognized by the finite automaton

Nondeterminism


Finite Automata

Regular Languages

M2 :

Terms: • state diagram • states • start state • accept state • transitions • accept or reject • language recognized by the finite automaton

Nondeterminism


Finite Automata

Regular Languages

M2 :

Terms: • state diagram • states • start state • accept state • transitions • accept or reject • language recognized by the finite automaton

Nondeterminism


Finite Automata

Regular Languages

Nondeterminism

Designing Finite Automata Suppose you are given some language L. If possible, you want to design a finite automaton that will recognize it.


Finite Automata

Regular Languages

Nondeterminism

Designing Finite Automata Suppose you are given some language L. If possible, you want to design a finite automaton that will recognize it. • The input is received one element at a time. You never know

when the input will end, so after each symbol, you must always be ready with an answer (accept or not).


Finite Automata

Regular Languages

Nondeterminism

Designing Finite Automata Suppose you are given some language L. If possible, you want to design a finite automaton that will recognize it. • The input is received one element at a time. You never know

when the input will end, so after each symbol, you must always be ready with an answer (accept or not).

• Design a finite automaton that will recognize the following

language over the alphabet {0, 1}: L1 = {1, 00}


Finite Automata

Regular Languages

Nondeterminism

Designing Finite Automata Suppose you are given some language L. If possible, you want to design a finite automaton that will recognize it. • The input is received one element at a time. You never know

when the input will end, so after each symbol, you must always be ready with an answer (accept or not). • States are meant to be used as memory. Each state remembers

some piece of information.


Finite Automata

Regular Languages

Nondeterminism

Designing Finite Automata Suppose you are given some language L. If possible, you want to design a finite automaton that will recognize it. • The input is received one element at a time. You never know

when the input will end, so after each symbol, you must always be ready with an answer (accept or not). • States are meant to be used as memory. Each state remembers

some piece of information.

• Design a finite automaton that will recognize the following

language over the alphabet {0, 1}: L2 = {ω|ω has an odd number of 1s}


Finite Automata

Regular Languages

Nondeterminism

Designing Finite Automata Suppose you are given some language L. If possible, you want to design a finite automaton that will recognize it. • The input is received one element at a time. You never know

when the input will end, so after each symbol, you must always be ready with an answer (accept or not). • States are meant to be used as memory. Each state remembers

some piece of information.

• Design a finite automaton that will recognize the following

language over the alphabet {0, 1}: L3 = {ω|ω contains substring 110}


Finite Automata

Regular Languages

Nondeterminism

Designing Finite Automata Suppose you are given some language L. If possible, you want to design a finite automaton that will recognize it. • The input is received one element at a time. You never know

when the input will end, so after each symbol, you must always be ready with an answer (accept or not). • States are meant to be used as memory. Each state remembers

some piece of information. • If the language is finite with the longest string of length n, then

we can build a trivial finite automaton that has one state for each node in a standard computation tree with height n. Each node corresponds to a finite string w of length less than n. If w ∈ L, we make that state (node) an accepting state. This is not true if n is not fixed - since we only have a finite number of states.


Finite Automata

Regular Languages

Nondeterminism

Regular Languages and Finite Automata

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


Finite Automata

Regular Languages

Regular Operations Let A and B be languages.

Nondeterminism


Finite Automata

Regular Languages

Regular Operations Let A and B be languages. • Union: A ∪ B = {x|x ∈ A or x ∈ B}.

Nondeterminism


Finite Automata

Regular Languages

Regular Operations Let A and B be languages. • Union: A ∪ B = {x|x ∈ A or x ∈ B}. • Concatenation: A ◦ B = {xy|x ∈ A and y ∈ B}.

Nondeterminism


Finite Automata

Regular Languages

Regular Operations Let A and B be languages. • Union: A ∪ B = {x|x ∈ A or x ∈ B}. • Concatenation: A ◦ B = {xy|x ∈ A and y ∈ B}. • Star: A∗ = {x1 x2 · · · xk |k ≥ 0 and each xi ∈ A}.

Nondeterminism


Finite Automata

Regular Languages

Regular Operations Let A and B be languages. • Union: A ∪ B = {x|x ∈ A or x ∈ B}. • Concatenation: A ◦ B = {xy|x ∈ A and y ∈ B}. • Star: A∗ = {x1 x2 · · · xk |k ≥ 0 and each xi ∈ A}.

Example (A = {a, b} and B = {1, 2, 3})

Nondeterminism


Finite Automata

Regular Languages

Regular Operations Let A and B be languages. • Union: A ∪ B = {x|x ∈ A or x ∈ B}. • Concatenation: A ◦ B = {xy|x ∈ A and y ∈ B}. • Star: A∗ = {x1 x2 · · · xk |k ≥ 0 and each xi ∈ A}.

Example (A = {a, b} and B = {1, 2, 3}) • A∪B =

Nondeterminism


Finite Automata

Regular Languages

Regular Operations Let A and B be languages. • Union: A ∪ B = {x|x ∈ A or x ∈ B}. • Concatenation: A ◦ B = {xy|x ∈ A and y ∈ B}. • Star: A∗ = {x1 x2 · · · xk |k ≥ 0 and each xi ∈ A}.

Example (A = {a, b} and B = {1, 2, 3}) • A ∪ B = {a, b, 1, 2, 3}

Nondeterminism


Finite Automata

Regular Languages

Regular Operations Let A and B be languages. • Union: A ∪ B = {x|x ∈ A or x ∈ B}. • Concatenation: A ◦ B = {xy|x ∈ A and y ∈ B}. • Star: A∗ = {x1 x2 · · · xk |k ≥ 0 and each xi ∈ A}.

Example (A = {a, b} and B = {1, 2, 3}) • A ∪ B = {a, b, 1, 2, 3} • A◦B =

Nondeterminism


Finite Automata

Regular Languages

Regular Operations Let A and B be languages. • Union: A ∪ B = {x|x ∈ A or x ∈ B}. • Concatenation: A ◦ B = {xy|x ∈ A and y ∈ B}. • Star: A∗ = {x1 x2 · · · xk |k ≥ 0 and each xi ∈ A}.

Example (A = {a, b} and B = {1, 2, 3}) • A ∪ B = {a, b, 1, 2, 3} • A ◦ B = {a1, a2, a3, b1, b2, b3}

Nondeterminism


Finite Automata

Regular Languages

Regular Operations Let A and B be languages. • Union: A ∪ B = {x|x ∈ A or x ∈ B}. • Concatenation: A ◦ B = {xy|x ∈ A and y ∈ B}. • Star: A∗ = {x1 x2 · · · xk |k ≥ 0 and each xi ∈ A}.

Example (A = {a, b} and B = {1, 2, 3}) • A ∪ B = {a, b, 1, 2, 3} • A ◦ B = {a1, a2, a3, b1, b2, b3} • A∗ =

Nondeterminism


Finite Automata

Regular Languages

Nondeterminism

Regular Operations Let A and B be languages. • Union: A ∪ B = {x|x ∈ A or x ∈ B}. • Concatenation: A ◦ B = {xy|x ∈ A and y ∈ B}. • Star: A∗ = {x1 x2 · · · xk |k ≥ 0 and each xi ∈ A}.

Example (A = {a, b} and B = {1, 2, 3}) • A ∪ B = {a, b, 1, 2, 3} • A ◦ B = {a1, a2, a3, b1, b2, b3} • A∗ = {ε, a, b, aa, ab, ba, bb, aaa, aab, aba, abb, baa, bab, bba, bbb, · · · }


Finite Automata

Regular Languages

Nondeterminism

Definition A collection of objects is closed under some operation if applying that operation to members of the collection returns an object still in the collection.


Finite Automata

Regular Languages

Nondeterminism

Definition A collection of objects is closed under some operation if applying that operation to members of the collection returns an object still in the collection.

Theorem The class of regular languages is closed under the union operation.

Proof.


Finite Automata

Regular Languages

Nondeterminism

Definition A collection of objects is closed under some operation if applying that operation to members of the collection returns an object still in the collection.

Theorem The class of regular languages is closed under the union operation.

Proof. Theorem The class of regular languages is closed under the concatenation operation.

Theorem The class of regular languages is closed under the star operation.


Finite Automata

M1 :

Regular Languages

Nondeterminism


Finite Automata

M1 :

N1 :

Regular Languages

Nondeterminism


Finite Automata

Regular Languages

Nondeterminism

Definition A nondeterministic finite automaton(NFA) is a 5-tuple (Q, Σ, δ, q0 , F ), where 1. Q is a finite set called the states, 2. Σ is a finite set called the alphabet, 3. δ : Q × Σε → ℘(Q) is the transition function, 4. q0 ∈ Q is the initial or start state, and 5. F ⊆ Q is the set of accept(final) states.


Finite Automata

Regular Languages

Nondeterminism

Definition A nondeterministic finite automaton(NFA) is a 5-tuple (Q, Σ, δ, q0 , F ), where 1. Q is a finite set called the states, 2. Σ is a finite set called the alphabet, 3. δ : Q × Σε → ℘(Q) is the transition function, 4. q0 ∈ Q is the initial or start state, and 5. F ⊆ Q is the set of accept(final) states.

Example N1 :


Finite Automata

Regular Languages

Nondeterminism

Definition A NFA is said to recognize or accept an input string ω, if there exists a final state that can be obtained from q0 using ω. The language recognized by a NFA M , denoted by L(M ), is the set of all strings that are recognized by M .


Finite Automata

Regular Languages

Nondeterminism

Definition A NFA is said to recognize or accept an input string ω, if there exists a final state that can be obtained from q0 using ω. The language recognized by a NFA M , denoted by L(M ), is the set of all strings that are recognized by M .

Example N1 :

Can you describe L(N1 )?


Finite Automata

Regular Languages

Questions? See you next meeting!

Nondeterminism


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.