Closure Properties and Decidability

Theory of Computer Science
April 4, 2016 — C4. Regular Languages: Closure Properties and Decidability
Theory of Computer Science
C4. Regular Languages: Closure Properties and Decidability
C4.1 Closure Properties
Malte Helmert
C4.2 Decidability
University of Basel
C4.3 Summary
April 4, 2016
M. Helmert (Univ. Basel)
Theorie
C4. Regular Languages: Closure Properties and Decidability
April 4, 2016
1 / 24
Closure Properties
M. Helmert (Univ. Basel)
Theorie
C4. Regular Languages: Closure Properties and Decidability
April 4, 2016
2 / 24
Closure Properties
Closure Properties
How can you combine
regular languages in a way to get
another regular language
as a result?
C4.1 Closure Properties
Picture courtesy of stockimages / FreeDigitalPhotos.net
M. Helmert (Univ. Basel)
Theorie
April 4, 2016
3 / 24
M. Helmert (Univ. Basel)
Theorie
April 4, 2016
4 / 24
C4. Regular Languages: Closure Properties and Decidability
Closure Properties
Closure Properties: Operations
C4. Regular Languages: Closure Properties and Decidability
Closure Properties
Closure Properties
Let L and L0 be regular languages over Σ and Σ0 , respectively.
Definition (Closure)
Let K be a class of languages.
We consider the following operations:
Then K is closed. . .
I
union L ∪ L0 = {w | w ∈ L or w ∈ L0 } over Σ ∪ Σ0
I
intersection L ∩ L0 = {w | w ∈ L and w ∈ L0 } over Σ ∩ Σ0
I
. . . under union if L, L0 ∈ K implies L ∪ L0 ∈ K
I
complement L̄ = {w ∈ Σ∗ | w ∈
/ L} over Σ
product LL0 = {uv | u ∈ L and v ∈ L0 } over Σ ∪ Σ0
I
. . . under intersection if L, L0 ∈ K implies L ∩ L0 ∈ K
I
. . . under complement if L ∈ K implies L̄ ∈ K
I
. . . under product if L, L0 ∈ K implies LL0 ∈ K
I
. . . under star if L ∈ K implies L∗ ∈ K
I
I
I
special case: Ln = Ln−1 L, where L0 = {ε}
star L∗ =
S
k
k≥0 L
over Σ
German: Abschlusseigenschaften, Vereinigung, Schnitt,
Komplement, Produkt, Stern
M. Helmert (Univ. Basel)
Theorie
C4. Regular Languages: Closure Properties and Decidability
German: Abgeschlossenheit, K ist abgeschlossen unter Vereinigung
(Schnitt, Komplement, Produkt, Stern)
April 4, 2016
5 / 24
Closure Properties
Clourse Properties of Regular Languages
union
I
intersection
I
complement
I
product
I
star
Theorie
April 4, 2016
C4. Regular Languages: Closure Properties and Decidability
6 / 24
Closure Properties
Closure Properties
Proof.
Closure under union, product, and star follows because
for regular expressions α and β, the expressions
(α|β), (αβ) and (α∗ ) describe the corresponding languages.
Theorem
The regular languages are closed under:
I
M. Helmert (Univ. Basel)
Complement: Let M = hQ, Σ, δ, q0 , E i be a DFA with L(M) = L.
Then M 0 = hQ, Σ, δ, q0 , Q \ E i is a DFA with L(M 0 ) = L̄.
Intersection: Let M1 = hQ1 , Σ1 , δ1 , q01 , E1 i and
M2 = hQ2 , Σ2 , δ2 , q02 , E2 i be DFAs. The product automaton
M = hQ1 × Q2 , Σ1 ∩ Σ2 , δ, hq01 , q02 i, E1 × E2 i
with δ(hq1 , q2 i, a) = hδ1 (q1 , a), δ2 (q2 , a)i
accepts L(M) = L(M1 ) ∩ L(M2 ).
German: Kreuzproduktautomat
M. Helmert (Univ. Basel)
Theorie
April 4, 2016
7 / 24
M. Helmert (Univ. Basel)
Theorie
April 4, 2016
8 / 24
C4. Regular Languages: Closure Properties and Decidability
Decidability
C4. Regular Languages: Closure Properties and Decidability
Decidability
Decision Problems and Decidability (1)
“Intuitive Definition:” Decision Problem, Decidability
A decision problem is an algorithmic problem where
C4.2 Decidability
I
for a given an input
I
an algorithm determines if the input has a given property
I
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”
M. Helmert (Univ. Basel)
Theorie
April 4, 2016
C4. Regular Languages: Closure Properties and Decidability
9 / 24
Decidability
Decision Problems and Decidability (2)
M. Helmert (Univ. Basel)
Theorie
April 4, 2016
C4. Regular Languages: Closure Properties and Decidability
10 / 24
Decidability
Decision Problems: Example
For now we describe decision problems in a semi-formal
“given”/“question” way:
Notes:
I
not a formal definition: we did not formally define
“algorithm”, “input”, “output” etc. (which is not trivial)
I
lack of a formal definition makes it difficult to prove
that something is not decidable
Example (Emptiness Problem for Regular Languages)
The emptiness problem P∅ for regular languages
is the following problem:
Given:
Question:
studied thoroughly in the next part of the course
regular grammar G
Is L(G ) = ∅?
German: Leerheitsproblem
M. Helmert (Univ. Basel)
Theorie
April 4, 2016
11 / 24
M. Helmert (Univ. Basel)
Theorie
April 4, 2016
12 / 24
C4. Regular Languages: Closure Properties and Decidability
Decidability
Word Problem
Theorem
The word problem for regular languages is decidable.
The word problem P∈ for regular languages is:
Question:
Proof.
Construct a DFA M with L(M) = L(G ).
(The proofs in Chapter C2 describe a possible method.)
regular grammar G with alphabet Σ
and word w ∈ Σ∗
Is w ∈ L(G )?
Simulate M on input w . The simulation ends after |w | steps.
German: Wortproblem (für reguläre Sprachen)
M. Helmert (Univ. Basel)
Theorie
The DFA M is an end state after this iff w ∈ L(G ).
Print “yes” or “no” accordingly.
April 4, 2016
C4. Regular Languages: Closure Properties and Decidability
13 / 24
Decidability
Emptiness Problem
M. Helmert (Univ. Basel)
Theorie
April 4, 2016
C4. Regular Languages: Closure Properties and Decidability
14 / 24
Decidability
Decidability: Emptiness Problem
Theorem
The emptiness problem for regular languages is decidable.
Definition (Emptiness Problem for Regular Languages)
The emptiness problem P∅ for regular languages is:
Given:
Question:
Decidability
Decidability: Word Problem
Definition (Word Problem for Regular Languages)
Given:
C4. Regular Languages: Closure Properties and Decidability
Proof.
Construct a DFA M with L(M) = L(G ).
regular grammar G
Is L(G ) = ∅?
We have L(G ) = ∅ iff in the transition diagram of M
there is no path from the start state to any end state.
German: Leerheitsproblem
This can be checked with standard graph algorithms
(e.g., breadth-first search).
M. Helmert (Univ. Basel)
Theorie
April 4, 2016
15 / 24
M. Helmert (Univ. Basel)
Theorie
April 4, 2016
16 / 24
C4. Regular Languages: Closure Properties and Decidability
Decidability
Finiteness Problem
Decidability
Decidability: Finiteness Problem
Theorem
The finiteness problem for regular languages is decidable.
Definition (Finiteness Problem for Regular Languages)
The finiteness problem P∞ for regular languages is:
Given:
Question:
C4. Regular Languages: Closure Properties and Decidability
Proof.
Construct a DFA M with L(M) = L(G ).
regular grammar G
Is |L(G )| < ∞?
We have |L(G )| = ∞ iff in the transition diagram of M
there is a cycle that is reachable from the start state
and from which an end state can be reached.
German: Endlichkeitsproblem
This can be checked with standard graph algorithms.
M. Helmert (Univ. Basel)
Theorie
April 4, 2016
C4. Regular Languages: Closure Properties and Decidability
17 / 24
Decidability
Intersection Problem
April 4, 2016
C4. Regular Languages: Closure Properties and Decidability
18 / 24
Decidability
Theorem
The intersection problem for regular languages is decidable.
The intersection problem P∩ for regular languages is:
Proof.
Using the closure of regular languages under intersection,
we can construct (e.g., by converting to DFAs, constructing
the product automaton, then converting back to a grammar)
a grammar G 00 with L(G 00 ) = L(G ) ∩ L(G 0 )
and use the algorithm for the emptiness problem P∅ .
regular grammars G and G 0
Is L(G ) ∩ L(G 0 ) = ∅?
German: Schnittproblem
M. Helmert (Univ. Basel)
Theorie
Decidability: Intersection Problem
Definition (Intersection Problem for Regular Languages)
Given:
Question:
M. Helmert (Univ. Basel)
Theorie
April 4, 2016
19 / 24
M. Helmert (Univ. Basel)
Theorie
April 4, 2016
20 / 24
C4. Regular Languages: Closure Properties and Decidability
Decidability
Equivalence Problem
C4. Regular Languages: Closure Properties and Decidability
Decidability
Decidability: Equivalence Problem
Theorem
The equivalence problem for regular languages is decidable.
Definition (Equivalence Problem for Regular Languages)
Proof.
In general for languages L and L0 , we have
The equivalence problem P= for regular languages is:
Given:
Question:
regular grammars G and G 0
Is L(G ) = L(G 0 )?
L = L0 iff (L ∩ L̄0 ) ∪ (L̄ ∩ L0 ) = ∅.
German: Äquivalenzproblem
The regular languages are closed under intersection, union
and complement, and we know algorithms for these operations.
We can therefore construct a grammar for (L ∩ L̄0 ) ∪ (L̄ ∩ L0 )
and use the algorithm for the emptiness problem P∅ .
M. Helmert (Univ. Basel)
Theorie
April 4, 2016
C4. Regular Languages: Closure Properties and Decidability
21 / 24
Summary
M. Helmert (Univ. Basel)
Theorie
April 4, 2016
C4. Regular Languages: Closure Properties and Decidability
22 / 24
Summary
Summary
C4.3 Summary
M. Helmert (Univ. Basel)
Theorie
April 4, 2016
23 / 24
I
The regular languages are closed under all usual operations
(union, intersection, complement, product, star).
I
All usual decision problems (word problem, emptiness,
finiteness, intersection, equivalence) are decidable
for regular languages.
M. Helmert (Univ. Basel)
Theorie
April 4, 2016
24 / 24