Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations...
Transcript of Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations...
![Page 1: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/1.jpg)
Theory of Computer ScienceC4. Regular Languages: Closure Properties and Decidability
Gabriele Roger
University of Basel
March 28, 2018
![Page 2: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/2.jpg)
Closure Properties Decidability Summary
Overview
Automata &Formal Languages
Languages& Grammars
RegularLanguages
RegularGrammars
DFAs
NFAs
RegularExpressions
PumpingLemma
MinimalAutomata
Properties
Context-freeLanguages
Context-sensitive &Type-0 Languages
![Page 3: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/3.jpg)
Closure Properties Decidability Summary
Closure Properties
![Page 4: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/4.jpg)
Closure Properties Decidability Summary
Closure Properties
How can you combineregular languages in a way to get
another regular languageas a result?
Picture courtesy of stockimages / FreeDigitalPhotos.net
![Page 5: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/5.jpg)
Closure Properties Decidability Summary
Closure Properties: Operations
Let L and L′ be regular languages over Σ and Σ′, respectively.
We consider the following operations:
union L ∪ L′ = {w | w ∈ L or w ∈ L′} over Σ ∪ Σ′
intersection L ∩ L′ = {w | w ∈ L and w ∈ L′} over Σ ∩ Σ′
complement L = {w ∈ Σ∗ | w /∈ L} over Σ
product LL′ = {uv | u ∈ L and v ∈ L′} over Σ ∪ Σ′
special case: Ln = Ln−1L, where L0 = {ε}star L∗ =
⋃k≥0 Lk over Σ
German: Abschlusseigenschaften, Vereinigung, Schnitt,Komplement, Produkt, Stern
![Page 6: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/6.jpg)
Closure Properties Decidability Summary
Closure Properties
Definition (Closure)
Let K be a class of languages.
Then K is closed. . .
. . . under union if L, L′ ∈ K implies L ∪ L′ ∈ K
. . . under intersection if L, L′ ∈ K implies L ∩ L′ ∈ K
. . . under complement if L ∈ K implies L ∈ K
. . . under product if L, L′ ∈ K implies LL′ ∈ K
. . . under star if L ∈ K implies L∗ ∈ K
German: Abgeschlossenheit, K ist abgeschlossen unter Vereinigung(Schnitt, Komplement, Produkt, Stern)
![Page 7: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/7.jpg)
Closure Properties Decidability Summary
Clourse Properties of Regular Languages
Theorem
The regular languages are closed under:
union
intersection
complement
product
star
![Page 8: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/8.jpg)
Closure Properties Decidability Summary
Closure Properties
Proof.
Closure under union, product, and star follows becausefor regular expressions α and β, the expressions(α|β), (αβ) and (α∗) describe the corresponding languages.
Complement: Let M = 〈Q,Σ, δ, q0,E 〉 be a DFA with L(M) = L.Then M ′ = 〈Q,Σ, δ, q0,Q \ E 〉 is a DFA with L(M ′) = L.
Intersection: Let M1 = 〈Q1,Σ1, δ1, q01,E1〉 andM2 = 〈Q2,Σ2, δ2, q02,E2〉 be DFAs. The product automaton
M = 〈Q1 × Q2,Σ1 ∩ Σ2, δ, 〈q01, q02〉,E1 × E2〉
with δ(〈q1, q2〉, a) = 〈δ1(q1, a), δ2(q2, a)〉
accepts L(M) = L(M1) ∩ L(M2).
German: Kreuzproduktautomat
![Page 9: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/9.jpg)
Closure Properties Decidability Summary
Closure Properties
Proof.
Closure under union, product, and star follows becausefor regular expressions α and β, the expressions(α|β), (αβ) and (α∗) describe the corresponding languages.
Complement: Let M = 〈Q,Σ, δ, q0,E 〉 be a DFA with L(M) = L.Then M ′ = 〈Q,Σ, δ, q0,Q \ E 〉 is a DFA with L(M ′) = L.
Intersection: Let M1 = 〈Q1,Σ1, δ1, q01,E1〉 andM2 = 〈Q2,Σ2, δ2, q02,E2〉 be DFAs. The product automaton
M = 〈Q1 × Q2,Σ1 ∩ Σ2, δ, 〈q01, q02〉,E1 × E2〉
with δ(〈q1, q2〉, a) = 〈δ1(q1, a), δ2(q2, a)〉
accepts L(M) = L(M1) ∩ L(M2).
German: Kreuzproduktautomat
![Page 10: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/10.jpg)
Closure Properties Decidability Summary
Closure Properties
Proof.
Closure under union, product, and star follows becausefor regular expressions α and β, the expressions(α|β), (αβ) and (α∗) describe the corresponding languages.
Complement: Let M = 〈Q,Σ, δ, q0,E 〉 be a DFA with L(M) = L.Then M ′ = 〈Q,Σ, δ, q0,Q \ E 〉 is a DFA with L(M ′) = L.
Intersection: Let M1 = 〈Q1,Σ1, δ1, q01,E1〉 andM2 = 〈Q2,Σ2, δ2, q02,E2〉 be DFAs. The product automaton
M = 〈Q1 × Q2,Σ1 ∩ Σ2, δ, 〈q01, q02〉,E1 × E2〉
with δ(〈q1, q2〉, a) = 〈δ1(q1, a), δ2(q2, a)〉
accepts L(M) = L(M1) ∩ L(M2).
German: Kreuzproduktautomat
![Page 11: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/11.jpg)
Closure Properties Decidability Summary
Questions
Questions?
![Page 12: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/12.jpg)
Closure Properties Decidability Summary
Decidability
![Page 13: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/13.jpg)
Closure Properties Decidability Summary
Decision Problems and Decidability (1)
“Intuitive Definition:” Decision Problem, Decidability
A decision problem is an algorithmic problem where
for a given input
an algorithm determines if the input has a given property
and then produces the output “yes” or “no” accordingly.
A decision problem is decidable if an algorithm for it(that always gives the correct answer) exists.
German: Entscheidungsproblem, Eingabe, Eigenschaft, Ausgabe,entscheidbar
Note: “exists” 6= “is known”
![Page 14: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/14.jpg)
Closure Properties Decidability Summary
Decision Problems and Decidability (2)
Notes:
not a formal definition: we did not formally define“algorithm”, “input”, “output” etc. (which is not trivial)
lack of a formal definition makes it difficult to provethat something is not decidable
studied thoroughly in the next part of the course
![Page 15: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/15.jpg)
Closure Properties Decidability Summary
Decision Problems: Example
For now we describe decision problems in a semi-formal“given”/“question” way:
Example (Emptiness Problem for Regular Languages)
The emptiness problem P∅ for regular languagesis the following problem:
Given: regular grammar GQuestion: Is L(G ) = ∅?
German: Leerheitsproblem
![Page 16: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/16.jpg)
Closure Properties Decidability Summary
Word Problem
Definition (Word Problem for Regular Languages)
The word problem P∈ for regular languages is:
Given: regular grammar G with alphabet Σand word w ∈ Σ∗
Question: Is w ∈ L(G )?
German: Wortproblem (fur regulare Sprachen)
![Page 17: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/17.jpg)
Closure Properties Decidability Summary
Decidability: Word Problem
Theorem
The word problem for regular languages is decidable.
Proof.
Construct a DFA M with L(M) = L(G ).(The proofs in Chapter C2 describe a possible method.)
Simulate M on input w . The simulation ends after |w | steps.
The DFA M is an end state after this iff w ∈ L(G ).Print “yes” or “no” accordingly.
![Page 18: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/18.jpg)
Closure Properties Decidability Summary
Emptiness Problem
Definition (Emptiness Problem for Regular Languages)
The emptiness problem P∅ for regular languages is:
Given: regular grammar GQuestion: Is L(G ) = ∅?
German: Leerheitsproblem
![Page 19: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/19.jpg)
Closure Properties Decidability Summary
Decidability: Emptiness Problem
Theorem
The emptiness problem for regular languages is decidable.
Proof.
Construct a DFA M with L(M) = L(G ).
We have L(G ) = ∅ iff in the transition diagram of Mthere is no path from the start state to any end state.
This can be checked with standard graph algorithms(e.g., breadth-first search).
![Page 20: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/20.jpg)
Closure Properties Decidability Summary
Finiteness Problem
Definition (Finiteness Problem for Regular Languages)
The finiteness problem P∞ for regular languages is:
Given: regular grammar GQuestion: Is |L(G )| <∞?
German: Endlichkeitsproblem
![Page 21: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/21.jpg)
Closure Properties Decidability Summary
Decidability: Finiteness Problem
Theorem
The finiteness problem for regular languages is decidable.
Proof.
Construct a DFA M with L(M) = L(G ).
We have |L(G )| =∞ iff in the transition diagram of Mthere is a cycle that is reachable from the start stateand from which an end state can be reached.
This can be checked with standard graph algorithms.
![Page 22: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/22.jpg)
Closure Properties Decidability Summary
Intersection Problem
Definition (Intersection Problem for Regular Languages)
The intersection problem P∩ for regular languages is:
Given: regular grammars G and G ′
Question: Is L(G ) ∩ L(G ′) = ∅?
German: Schnittproblem
![Page 23: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/23.jpg)
Closure Properties Decidability Summary
Decidability: Intersection Problem
Theorem
The intersection problem for regular languages is decidable.
Proof.
Using the closure of regular languages under intersection,we can construct (e.g., by converting to DFAs, constructingthe product automaton, then converting back to a grammar)a grammar G ′′ with L(G ′′) = L(G ) ∩ L(G ′)and use the algorithm for the emptiness problem P∅.
![Page 24: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/24.jpg)
Closure Properties Decidability Summary
Equivalence Problem
Definition (Equivalence Problem for Regular Languages)
The equivalence problem P= for regular languages is:
Given: regular grammars G and G ′
Question: Is L(G ) = L(G ′)?
German: Aquivalenzproblem
![Page 25: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/25.jpg)
Closure Properties Decidability Summary
Decidability: Equivalence Problem
Theorem
The equivalence problem for regular languages is decidable.
Proof.
In general for languages L and L′, we have
L = L′ iff (L ∩ L′) ∪ (L ∩ L′) = ∅.
The regular languages are closed under intersection, unionand complement, and we know algorithms for these operations.
We can therefore construct a grammar for (L ∩ L′) ∪ (L ∩ L′)and use the algorithm for the emptiness problem P∅.
![Page 26: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/26.jpg)
Closure Properties Decidability Summary
Questions
Questions?
![Page 27: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/27.jpg)
Closure Properties Decidability Summary
Summary
![Page 28: Theory of Computer Science · Closure Properties DecidabilitySummary Closure Properties: Operations Let L and L0be regular languages over and 0, respectively. We consider the following](https://reader035.fdocuments.us/reader035/viewer/2022081614/5fc4e0613059b12ea0052765/html5/thumbnails/28.jpg)
Closure Properties Decidability Summary
Summary
The regular languages are closed under all usual operations(union, intersection, complement, product, star).
All usual decision problems (word problem, emptiness,finiteness, intersection, equivalence) are decidablefor regular languages.