SlideShare uma empresa Scribd logo
1 de 12
Baixar para ler offline
18.404/6.840 Lecture 2
Last time: (Sipser §1.1)
- Finite automata, regular languages
- Regular operations ∪,∘,∗
- Regular expressions
- Closure under ∪
Today: (Sipser §1.2 – §1.3)
- Nondeterminism
- Closure under ∘ and ∗
- Regular expressions → finite automata
Goal: Show finite automata equivalent to regular expressions
1
Problem Sets
- 35% of overall grade
- Problems are hard! Leave time to think about them.
- Writeups need to be clear and understandable, handwritten ok.
Level of detail in proofs comparable to lecture: focus on main ideas.
Don’t need to include minor details.
- Submit via gradescope (see Canvas) by 2:30pm Cambridge time.
Late submission accepted (on gradescope) until 11:59pm following day:
1 point (out of 10 points) per late problem penalty.
After that solutions are posted so not accepted without S3 excuse.
- Optional problems:
Don’t count towards grade except for A+.
Value to you (besides the challenge):
Recommendations, employment (future grading, TA, UROP)
- Problem Set 1 is due in one week.
2
Closure Properties for Regular Languages
Theorem: If 𝐴1, 𝐴2 are regular languages, so is 𝐴1𝐴2 (closure under ∘)
Recall proof attempt: Let 𝑀1 = (𝑄1, Σ, 𝛿1 , 𝑞1 , 𝐹1 ) recognize 𝐴1
𝑀2 = (𝑄2, Σ, 𝛿2 , 𝑞2 , 𝐹2 ) recognize 𝐴2
Construct 𝑀 = (𝑄, Σ, 𝛿, 𝑞0, 𝐹) recognizing 𝐴1𝐴2
𝑀2
𝑀1
𝑀 should accept input 𝑤
if 𝑤 = 𝑥𝑦 where
𝑀1 accepts 𝑥 and 𝑀2 accepts 𝑦.
𝑀
𝑤
𝑥 𝑦
Doesn’t work: Where to split 𝑤?
Hold off. Need new concept.
3
Nondeterministic Finite Automata
Nondeterminism doesn’t correspond
to a physical machine we can build.
However, it is useful mathematically.
𝑁1
𝑞1 𝑞2 𝑞4
b a,ε
b
a
a
𝑞3
New features of nondeterminism:
- multiple paths possible (0, 1 or many at each step)
- ε-transition is a “free” move without reading input
- Accept input if some path leads to accept
Example inputs:
- ab accept
- aa reject
- aba accept
- abb reject
Check-in 2.1
Check-in 2.1
What does 𝑁1 do on input aab ?
(a) Accept
(b) Reject
(c) Both Accept and Reject
4
NFA – Formal Definition
Ways to think about nondeterminism:
Computational: Fork new parallel thread and
accept if any thread leads to an accept state.
Mathematical: Tree with branches.
Accept if any branch leads to an accept state.
Magical: Guess at each nondeterministic step
which way to go. Machine always makes the
right guess that leads to accepting, if possible.
𝑁1
𝑞1 𝑞2 𝑞4
b a,ε
b
a
a
𝑞3
Defn: A nondeterministic finite automaton (NFA)
𝑁 is a 5-tuple (𝑄, Σ, 𝛿, 𝑞0, 𝐹)
- all same as before except 𝛿
- 𝛿: 𝑄 × Σε → 𝓟 𝑄 = 𝑅 𝑅 ⊆ 𝑄}
- In the 𝑁1 example: 𝛿 𝑞1, a = {𝑞1, 𝑞2}
𝛿 𝑞1, b = ∅
Σ ∪ {ε}
power set
5
Converting NFAs to DFAs
Theorem: If an NFA recognizes 𝐴 then 𝐴 is regular
Proof: Let NFA 𝑀 = (𝑄, Σ, 𝛿, 𝑞0 , 𝐹) recognize 𝐴
Construct DFA 𝑀′ = (𝑄′, Σ, 𝛿′, 𝑞0
′
, 𝐹′) recognizing 𝐴
(Ignore the ε-transitions, can easily modify to handle them)
IDEA: DFA 𝑀′ keeps track of the subset of possible states in NFA 𝑀.
Construction of 𝑴′:
𝑄′ = 𝓟 𝑄
𝛿′ 𝑅, 𝑎 = 𝑞 𝑞 ∈ 𝛿(𝑟, 𝑎) for some 𝑟 ∈ 𝑅}
𝑞0
′
= {q0}
𝐹′ = 𝑅 ∈ 𝑄′ 𝑅 intersects 𝐹}
𝑀
𝑞3
𝑞7
NFA
𝑀′
{𝑞3,𝑞7}
DFA
𝑅 ∈ 𝑄′
Check-in 2.2
Check-in 2.2
If 𝑀 has 𝑛 states, how many
states does 𝑀′ have by this
construction?
(a) 2𝑛
(b) 𝑛2
(c) 2𝑛
6
Return to Closure Properties
Recall Theorem: If 𝐴1, 𝐴2 are regular languages, so is 𝐴1 ∪ 𝐴2
(The class of regular languages is closed under union)
New Proof (sketch): Given DFAs 𝑀1 and 𝑀2 recognizing 𝐴1 and 𝐴2
Construct NFA 𝑀 recognizing 𝐴1 ∪ 𝐴2
𝑀2
𝑀1
ε
ε
𝑀
Nondeterminism
parallelism
vs
guessing
7
Closure under ∘ (concatenation)
Theorem: If 𝐴1, 𝐴2 are regular languages, so is 𝐴1𝐴2
Proof sketch: Given DFAs 𝑀1 and 𝑀1 recognizing 𝐴1 and 𝐴2
Construct NFA 𝑀 recognizing 𝐴1𝐴2
𝑀2
𝑀1
ε
ε
𝑀
𝑀 should accept input 𝑤
if 𝑤 = 𝑥𝑦 where
𝑀1 accepts 𝑥 and 𝑀2 accepts 𝑦.
Nondeterministic 𝑀′ has the option
to jump to 𝑀2 when 𝑀1 accepts.
𝑤 =
𝑥 𝑦
8
Closure under ∗ (star)
Theorem: If 𝐴 is a regular language, so is 𝐴∗
Proof sketch: Given DFA 𝑀 recognizing 𝐴
Construct NFA 𝑀′ recognizing 𝐴∗
ε
ε
𝑀
𝑀′
ε
Make sure 𝑀′ accepts ε
𝑀′ should accept input 𝑤
if 𝑤 = 𝑥1𝑥2 … 𝑥𝑘
where 𝑘 ≥ 0 and 𝑀 accepts each 𝑥𝑖
𝑤 =
𝑥1 𝑥2 𝑥3 𝑥4
Check-in 2.3
If 𝑀 has 𝑛 states, how many states
does 𝑀′ have by this construction?
(a) 𝑛
(b) 𝑛 + 1
(c) 2𝑛
Check-in 2.3
9
Regular Expressions → NFA
Theorem: If 𝑅 is a regular expr and 𝐴 = 𝐿 𝑅 then 𝐴 is regular
Proof: Convert 𝑅 to equivalent NFA 𝑀:
Example:
Convert a ∪ ab ∗ to equivalent NFA
a:
b:
ab:
a ∪ ab:
a ∪ ab ∗:
If 𝑅 is atomic:
𝑅 = 𝑎 for 𝑎 ∈ Σ
𝑅 = ε
𝑅 = ∅
If 𝑅 is composite:
𝑅 = 𝑅1 ∪ 𝑅2
𝑅 = 𝑅1 ∘ 𝑅2
𝑅 = 𝑅1
∗
Equivalent 𝑀 is:
𝑎
}Use closure constructions
a
a b
b
ε
a
a b
ε
ε
ε
ε
a
a b
ε
ε
ε
ε
ε
10
Quick review of today
1. Nondeterministic finite automata (NFA)
2. Proved: NFA and DFA are equivalent in power
3. Proved: Class of regular languages is closed under ∘,∗
4. Conversion of regular expressions to NFA
Check-in 2.4
Recitations start tomorrow online (same link as for lectures).
They are optional, unless you need more help.
You may attend any recitation(s).
Which do you think you’ll attend? (you may check several)
(a) 10:00 (b) 11:00 (c) 12:00
(d) 1:00 (e) 2:00 (f) I prefer a different time (please
post on piazza, but no promises)
Check-in 2.4
11
MIT OpenCourseWare
https://ocw.mit.edu
18.404J Theory of Computation
Fall 2020
For information about citing these materials or our Terms of Use, visit: https://ocw.mit.edu/terms.

Mais conteúdo relacionado

Semelhante a TheoryOfComputaionNonDeterministic1.pptx

Paper Study: Melding the data decision pipeline
Paper Study: Melding the data decision pipelinePaper Study: Melding the data decision pipeline
Paper Study: Melding the data decision pipelineChenYiHuang5
 
Parallel Computing 2007: Bring your own parallel application
Parallel Computing 2007: Bring your own parallel applicationParallel Computing 2007: Bring your own parallel application
Parallel Computing 2007: Bring your own parallel applicationGeoffrey Fox
 
Lecture 05 syntax analysis 2
Lecture 05 syntax analysis 2Lecture 05 syntax analysis 2
Lecture 05 syntax analysis 2Iffat Anjum
 
Integral Calculus Anti Derivatives reviewer
Integral Calculus Anti Derivatives reviewerIntegral Calculus Anti Derivatives reviewer
Integral Calculus Anti Derivatives reviewerJoshuaAgcopra
 
Sienna 4 divideandconquer
Sienna 4 divideandconquerSienna 4 divideandconquer
Sienna 4 divideandconquerchidabdu
 
Dynamic Programming - Laughlin Lunch and Learn
Dynamic Programming - Laughlin Lunch and LearnDynamic Programming - Laughlin Lunch and Learn
Dynamic Programming - Laughlin Lunch and LearnBillie Rose
 
lecture 8
lecture 8lecture 8
lecture 8sajinsc
 
dynamic programming Rod cutting class
dynamic programming Rod cutting classdynamic programming Rod cutting class
dynamic programming Rod cutting classgiridaroori
 
Divide and conquer strategy
Divide and conquer strategyDivide and conquer strategy
Divide and conquer strategyNisha Soms
 
Algorithm review
Algorithm reviewAlgorithm review
Algorithm reviewchidabdu
 
P, NP and NP-Complete, Theory of NP-Completeness V2
P, NP and NP-Complete, Theory of NP-Completeness V2P, NP and NP-Complete, Theory of NP-Completeness V2
P, NP and NP-Complete, Theory of NP-Completeness V2S.Shayan Daneshvar
 
2 random variables notes 2p3
2 random variables notes 2p32 random variables notes 2p3
2 random variables notes 2p3MuhannadSaleh
 
On the Configuration-LP of the Restricted Assignment Problem
On the Configuration-LP of the Restricted Assignment ProblemOn the Configuration-LP of the Restricted Assignment Problem
On the Configuration-LP of the Restricted Assignment ProblemArash Pourdamghani
 
Skiena algorithm 2007 lecture15 backtracing
Skiena algorithm 2007 lecture15 backtracingSkiena algorithm 2007 lecture15 backtracing
Skiena algorithm 2007 lecture15 backtracingzukun
 

Semelhante a TheoryOfComputaionNonDeterministic1.pptx (20)

Paper Study: Melding the data decision pipeline
Paper Study: Melding the data decision pipelinePaper Study: Melding the data decision pipeline
Paper Study: Melding the data decision pipeline
 
Mcs 031
Mcs 031Mcs 031
Mcs 031
 
Parallel Computing 2007: Bring your own parallel application
Parallel Computing 2007: Bring your own parallel applicationParallel Computing 2007: Bring your own parallel application
Parallel Computing 2007: Bring your own parallel application
 
Lecture 05 syntax analysis 2
Lecture 05 syntax analysis 2Lecture 05 syntax analysis 2
Lecture 05 syntax analysis 2
 
Integral Calculus Anti Derivatives reviewer
Integral Calculus Anti Derivatives reviewerIntegral Calculus Anti Derivatives reviewer
Integral Calculus Anti Derivatives reviewer
 
Sienna 4 divideandconquer
Sienna 4 divideandconquerSienna 4 divideandconquer
Sienna 4 divideandconquer
 
Dynamic Programming - Laughlin Lunch and Learn
Dynamic Programming - Laughlin Lunch and LearnDynamic Programming - Laughlin Lunch and Learn
Dynamic Programming - Laughlin Lunch and Learn
 
Computer Network Assignment Help
Computer Network Assignment HelpComputer Network Assignment Help
Computer Network Assignment Help
 
lecture 8
lecture 8lecture 8
lecture 8
 
Lect6 csp
Lect6 cspLect6 csp
Lect6 csp
 
dynamic programming Rod cutting class
dynamic programming Rod cutting classdynamic programming Rod cutting class
dynamic programming Rod cutting class
 
Divide and conquer strategy
Divide and conquer strategyDivide and conquer strategy
Divide and conquer strategy
 
Algorithm review
Algorithm reviewAlgorithm review
Algorithm review
 
Approx
ApproxApprox
Approx
 
Knapsack problem using fixed tuple
Knapsack problem using fixed tupleKnapsack problem using fixed tuple
Knapsack problem using fixed tuple
 
An Efficient and Parallel Abstract Interpreter in Scala — First Algorithm
An Efficient and Parallel Abstract Interpreter in Scala — First AlgorithmAn Efficient and Parallel Abstract Interpreter in Scala — First Algorithm
An Efficient and Parallel Abstract Interpreter in Scala — First Algorithm
 
P, NP and NP-Complete, Theory of NP-Completeness V2
P, NP and NP-Complete, Theory of NP-Completeness V2P, NP and NP-Complete, Theory of NP-Completeness V2
P, NP and NP-Complete, Theory of NP-Completeness V2
 
2 random variables notes 2p3
2 random variables notes 2p32 random variables notes 2p3
2 random variables notes 2p3
 
On the Configuration-LP of the Restricted Assignment Problem
On the Configuration-LP of the Restricted Assignment ProblemOn the Configuration-LP of the Restricted Assignment Problem
On the Configuration-LP of the Restricted Assignment Problem
 
Skiena algorithm 2007 lecture15 backtracing
Skiena algorithm 2007 lecture15 backtracingSkiena algorithm 2007 lecture15 backtracing
Skiena algorithm 2007 lecture15 backtracing
 

Último

Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network DevicesChandrakantDivate1
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdfKamal Acharya
 
Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...ppkakm
 
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdflitvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdfAlexander Litvinenko
 
Introduction to Robotics in Mechanical Engineering.pptx
Introduction to Robotics in Mechanical Engineering.pptxIntroduction to Robotics in Mechanical Engineering.pptx
Introduction to Robotics in Mechanical Engineering.pptxhublikarsn
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
Cybercrimes in the Darknet and Their Detections: A Comprehensive Analysis and...
Cybercrimes in the Darknet and Their Detections: A Comprehensive Analysis and...Cybercrimes in the Darknet and Their Detections: A Comprehensive Analysis and...
Cybercrimes in the Darknet and Their Detections: A Comprehensive Analysis and...dannyijwest
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 
Adsorption (mass transfer operations 2) ppt
Adsorption (mass transfer operations 2) pptAdsorption (mass transfer operations 2) ppt
Adsorption (mass transfer operations 2) pptjigup7320
 
UNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxUNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxkalpana413121
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...ssuserdfc773
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxSCMS School of Architecture
 
8086 Microprocessor Architecture: 16-bit microprocessor
8086 Microprocessor Architecture: 16-bit microprocessor8086 Microprocessor Architecture: 16-bit microprocessor
8086 Microprocessor Architecture: 16-bit microprocessorAshwiniTodkar4
 
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...ronahami
 
INTERRUPT CONTROLLER 8259 MICROPROCESSOR
INTERRUPT CONTROLLER 8259 MICROPROCESSORINTERRUPT CONTROLLER 8259 MICROPROCESSOR
INTERRUPT CONTROLLER 8259 MICROPROCESSORTanishkaHira1
 
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...josephjonse
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdfAldoGarca30
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxSCMS School of Architecture
 

Último (20)

Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...
 
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdflitvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
 
Introduction to Robotics in Mechanical Engineering.pptx
Introduction to Robotics in Mechanical Engineering.pptxIntroduction to Robotics in Mechanical Engineering.pptx
Introduction to Robotics in Mechanical Engineering.pptx
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Cybercrimes in the Darknet and Their Detections: A Comprehensive Analysis and...
Cybercrimes in the Darknet and Their Detections: A Comprehensive Analysis and...Cybercrimes in the Darknet and Their Detections: A Comprehensive Analysis and...
Cybercrimes in the Darknet and Their Detections: A Comprehensive Analysis and...
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Adsorption (mass transfer operations 2) ppt
Adsorption (mass transfer operations 2) pptAdsorption (mass transfer operations 2) ppt
Adsorption (mass transfer operations 2) ppt
 
UNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxUNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptx
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
8086 Microprocessor Architecture: 16-bit microprocessor
8086 Microprocessor Architecture: 16-bit microprocessor8086 Microprocessor Architecture: 16-bit microprocessor
8086 Microprocessor Architecture: 16-bit microprocessor
 
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
 
INTERRUPT CONTROLLER 8259 MICROPROCESSOR
INTERRUPT CONTROLLER 8259 MICROPROCESSORINTERRUPT CONTROLLER 8259 MICROPROCESSOR
INTERRUPT CONTROLLER 8259 MICROPROCESSOR
 
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 

TheoryOfComputaionNonDeterministic1.pptx

  • 1. 18.404/6.840 Lecture 2 Last time: (Sipser §1.1) - Finite automata, regular languages - Regular operations ∪,∘,∗ - Regular expressions - Closure under ∪ Today: (Sipser §1.2 – §1.3) - Nondeterminism - Closure under ∘ and ∗ - Regular expressions → finite automata Goal: Show finite automata equivalent to regular expressions 1
  • 2. Problem Sets - 35% of overall grade - Problems are hard! Leave time to think about them. - Writeups need to be clear and understandable, handwritten ok. Level of detail in proofs comparable to lecture: focus on main ideas. Don’t need to include minor details. - Submit via gradescope (see Canvas) by 2:30pm Cambridge time. Late submission accepted (on gradescope) until 11:59pm following day: 1 point (out of 10 points) per late problem penalty. After that solutions are posted so not accepted without S3 excuse. - Optional problems: Don’t count towards grade except for A+. Value to you (besides the challenge): Recommendations, employment (future grading, TA, UROP) - Problem Set 1 is due in one week. 2
  • 3. Closure Properties for Regular Languages Theorem: If 𝐴1, 𝐴2 are regular languages, so is 𝐴1𝐴2 (closure under ∘) Recall proof attempt: Let 𝑀1 = (𝑄1, Σ, 𝛿1 , 𝑞1 , 𝐹1 ) recognize 𝐴1 𝑀2 = (𝑄2, Σ, 𝛿2 , 𝑞2 , 𝐹2 ) recognize 𝐴2 Construct 𝑀 = (𝑄, Σ, 𝛿, 𝑞0, 𝐹) recognizing 𝐴1𝐴2 𝑀2 𝑀1 𝑀 should accept input 𝑤 if 𝑤 = 𝑥𝑦 where 𝑀1 accepts 𝑥 and 𝑀2 accepts 𝑦. 𝑀 𝑤 𝑥 𝑦 Doesn’t work: Where to split 𝑤? Hold off. Need new concept. 3
  • 4. Nondeterministic Finite Automata Nondeterminism doesn’t correspond to a physical machine we can build. However, it is useful mathematically. 𝑁1 𝑞1 𝑞2 𝑞4 b a,ε b a a 𝑞3 New features of nondeterminism: - multiple paths possible (0, 1 or many at each step) - ε-transition is a “free” move without reading input - Accept input if some path leads to accept Example inputs: - ab accept - aa reject - aba accept - abb reject Check-in 2.1 Check-in 2.1 What does 𝑁1 do on input aab ? (a) Accept (b) Reject (c) Both Accept and Reject 4
  • 5. NFA – Formal Definition Ways to think about nondeterminism: Computational: Fork new parallel thread and accept if any thread leads to an accept state. Mathematical: Tree with branches. Accept if any branch leads to an accept state. Magical: Guess at each nondeterministic step which way to go. Machine always makes the right guess that leads to accepting, if possible. 𝑁1 𝑞1 𝑞2 𝑞4 b a,ε b a a 𝑞3 Defn: A nondeterministic finite automaton (NFA) 𝑁 is a 5-tuple (𝑄, Σ, 𝛿, 𝑞0, 𝐹) - all same as before except 𝛿 - 𝛿: 𝑄 × Σε → 𝓟 𝑄 = 𝑅 𝑅 ⊆ 𝑄} - In the 𝑁1 example: 𝛿 𝑞1, a = {𝑞1, 𝑞2} 𝛿 𝑞1, b = ∅ Σ ∪ {ε} power set 5
  • 6. Converting NFAs to DFAs Theorem: If an NFA recognizes 𝐴 then 𝐴 is regular Proof: Let NFA 𝑀 = (𝑄, Σ, 𝛿, 𝑞0 , 𝐹) recognize 𝐴 Construct DFA 𝑀′ = (𝑄′, Σ, 𝛿′, 𝑞0 ′ , 𝐹′) recognizing 𝐴 (Ignore the ε-transitions, can easily modify to handle them) IDEA: DFA 𝑀′ keeps track of the subset of possible states in NFA 𝑀. Construction of 𝑴′: 𝑄′ = 𝓟 𝑄 𝛿′ 𝑅, 𝑎 = 𝑞 𝑞 ∈ 𝛿(𝑟, 𝑎) for some 𝑟 ∈ 𝑅} 𝑞0 ′ = {q0} 𝐹′ = 𝑅 ∈ 𝑄′ 𝑅 intersects 𝐹} 𝑀 𝑞3 𝑞7 NFA 𝑀′ {𝑞3,𝑞7} DFA 𝑅 ∈ 𝑄′ Check-in 2.2 Check-in 2.2 If 𝑀 has 𝑛 states, how many states does 𝑀′ have by this construction? (a) 2𝑛 (b) 𝑛2 (c) 2𝑛 6
  • 7. Return to Closure Properties Recall Theorem: If 𝐴1, 𝐴2 are regular languages, so is 𝐴1 ∪ 𝐴2 (The class of regular languages is closed under union) New Proof (sketch): Given DFAs 𝑀1 and 𝑀2 recognizing 𝐴1 and 𝐴2 Construct NFA 𝑀 recognizing 𝐴1 ∪ 𝐴2 𝑀2 𝑀1 ε ε 𝑀 Nondeterminism parallelism vs guessing 7
  • 8. Closure under ∘ (concatenation) Theorem: If 𝐴1, 𝐴2 are regular languages, so is 𝐴1𝐴2 Proof sketch: Given DFAs 𝑀1 and 𝑀1 recognizing 𝐴1 and 𝐴2 Construct NFA 𝑀 recognizing 𝐴1𝐴2 𝑀2 𝑀1 ε ε 𝑀 𝑀 should accept input 𝑤 if 𝑤 = 𝑥𝑦 where 𝑀1 accepts 𝑥 and 𝑀2 accepts 𝑦. Nondeterministic 𝑀′ has the option to jump to 𝑀2 when 𝑀1 accepts. 𝑤 = 𝑥 𝑦 8
  • 9. Closure under ∗ (star) Theorem: If 𝐴 is a regular language, so is 𝐴∗ Proof sketch: Given DFA 𝑀 recognizing 𝐴 Construct NFA 𝑀′ recognizing 𝐴∗ ε ε 𝑀 𝑀′ ε Make sure 𝑀′ accepts ε 𝑀′ should accept input 𝑤 if 𝑤 = 𝑥1𝑥2 … 𝑥𝑘 where 𝑘 ≥ 0 and 𝑀 accepts each 𝑥𝑖 𝑤 = 𝑥1 𝑥2 𝑥3 𝑥4 Check-in 2.3 If 𝑀 has 𝑛 states, how many states does 𝑀′ have by this construction? (a) 𝑛 (b) 𝑛 + 1 (c) 2𝑛 Check-in 2.3 9
  • 10. Regular Expressions → NFA Theorem: If 𝑅 is a regular expr and 𝐴 = 𝐿 𝑅 then 𝐴 is regular Proof: Convert 𝑅 to equivalent NFA 𝑀: Example: Convert a ∪ ab ∗ to equivalent NFA a: b: ab: a ∪ ab: a ∪ ab ∗: If 𝑅 is atomic: 𝑅 = 𝑎 for 𝑎 ∈ Σ 𝑅 = ε 𝑅 = ∅ If 𝑅 is composite: 𝑅 = 𝑅1 ∪ 𝑅2 𝑅 = 𝑅1 ∘ 𝑅2 𝑅 = 𝑅1 ∗ Equivalent 𝑀 is: 𝑎 }Use closure constructions a a b b ε a a b ε ε ε ε a a b ε ε ε ε ε 10
  • 11. Quick review of today 1. Nondeterministic finite automata (NFA) 2. Proved: NFA and DFA are equivalent in power 3. Proved: Class of regular languages is closed under ∘,∗ 4. Conversion of regular expressions to NFA Check-in 2.4 Recitations start tomorrow online (same link as for lectures). They are optional, unless you need more help. You may attend any recitation(s). Which do you think you’ll attend? (you may check several) (a) 10:00 (b) 11:00 (c) 12:00 (d) 1:00 (e) 2:00 (f) I prefer a different time (please post on piazza, but no promises) Check-in 2.4 11
  • 12. MIT OpenCourseWare https://ocw.mit.edu 18.404J Theory of Computation Fall 2020 For information about citing these materials or our Terms of Use, visit: https://ocw.mit.edu/terms.

Notas do Editor

  1. Type equation here.
  2. Type equation here.
  3. Type equation here.
  4. Type equation here.
  5. Type equation here.
  6. Type equation here.
  7. Type equation here.
  8. Type equation here.
  9. Type equation here.