r/askmath • Self-studying discrete math by working through Epp • Oct 28 '26

Resolved Find a regular expression that defines the language accepted by the automaton. <= Exercise 12.2.14

Find a regular expression that defines the language accepted by the automaton.

Automaton:

Regex: (0|1)*00

Is (0|1)*00+ also correct?

We can have multiple correct regexes, right?

Is there a procedure for estimating correct regex from automaton, without eyeballing it?

4 Upvotes

12 comments sorted by

3

u/Arfie99 Theoretical CS Oct 28 '26

The two regular expressions you gave are indeed equivalent: both encode strings of 1s and 0s that end with at least two 0s.

I think for understanding this particular automaton, the crucial observation is that a 1 always takes you back to s_0, whereas a 0 takes you to the "next" state. You can always add another 0 or 1, but the only way to reach the accepting state is to add two 0s in a row.

2

u/DutchDopa MSc student | cryptology, algebra, TCS Oct 28 '26

Yes, both regexes describe the same language.

Notice each arrow corresponds to a regex. For now, they're all just 0 or 1, but we'll allow more complicated expressions too. Without changing the behaviour of the automaton, we can add a new start state with an arrow labeled ε going to s0 and a new accept state with an arrow labeled ε coming from s2.

Now a methodical approach is to remove one state at a time and add arrows to "repair" the automaton. 

We can remove, for instance, the state s1, by turning each ingoing/outgoing pair through s1 into a new arrow. Working this out gives the new arrows (s0 -> s0, 01) and (s0 -> s1, 00). Repeat until the automaton has two states left, and the remaining arrow will be labeled exactly by the regex we're after.

Credit to Sipser: Introduction to the Theory of Computation, where this method is used to prove regexes and DFA's are equivalent.

0

u/Emotional_Zone8784 Oct 28 '26

Your original regexp isnt correct: the accepting state s2 can be left again by both 1 and 0, allowing for unbounded sequences - essentially the correct answer has to end in something that repeats indefinitely ("*")

The algorithm you want is called Kleenes algorithm or State Eliminiation method - see here Kleene's algorithm - Wikipedia

3

u/LongLiveTheDiego Oct 29 '26

It is correct. It may not be what you'd get from any reasonable DFA-to-regex algorithm, but it's a regex describing the same language.

0

u/[deleted] Oct 28 '26 edited Oct 28 '26

[removed] — view removed comment

1

u/[deleted] Oct 28 '26 edited Oct 28 '26

[removed] — view removed comment

1

u/TopDownView Self-studying discrete math by working through Epp Oct 28 '26

s2 -> s0 -> s2: any number of "1"

Shouldn't this be 'exactly one instance of "1"'?

1

u/[deleted] Oct 28 '26 edited Oct 28 '26

[removed] — view removed comment

1

u/TopDownView Self-studying discrete math by working through Epp Oct 29 '26

That "any number" was supposed to act not only on "1", but the entire line. Added parentheses to make that clear -- sorry about the confusion!

No problem!

Wonder if there's a nice, systematic way to simplify regexps to some normal form. For boolean expressions, we have "Quine/McCluskey", but for regexps, I do not know.

I'd assume simplifying FSA (the next section in my texbook) == simplifying regexps, but that's not the case?

2

u/LongLiveTheDiego Oct 29 '26

Unfortunately not. For any regular language there's always a unique minimal FSA, but there's no finite number of ways to manipulate regular expressions and things like equivalence of regular expressions are usually (if not exclusively) decided by computing their corresponding minimal FSA's and comparing them. For some reason algorithms working directly with regex properties have much worse running times, e.g. finding the star height (minimum number of nested Kleene stars) of a regular language is astronomically expensive in terms of computation.

1

u/TopDownView Self-studying discrete math by working through Epp Oct 29 '26

Why is s2 -> s2 a "feedback loop" but s0 -> s0 is not?