Intermediate Topic 21 of 51 Theory & Discrete Math
Regular Languages
Languages recognized by finite automata.
How it works
Regular languages are those that can be recognized by finite automata, described by regular expressions or generated by regular grammars; these three views are equivalent, by Kleene's theorem. The class is closed under union, intersection, complement, concatenation, Kleene star and reversal. Decision questions such as emptiness, membership and equivalence are decidable. The Myhill-Nerode theorem characterizes them by the number of distinguishable string classes.
Step-by-step walkthrough
- Many descriptions give the same class of languages.
- A DFA recognizes them.
- An NFA recognizes them.
- A regular expression describes them.
- The class is closed under union, concatenation, star and complement.
Where it is used
Lexical analysis in compilers, input validation, search patterns, network packet filters and log parsing use regular languages.
Common pitfall
Many natural languages and structures are not regular, such as balanced brackets, palindromes and a to the n b to the n, and need stronger models. Practical regex features such as backreferences go beyond regular languages. To show a language is not regular, use the pumping lemma or Myhill-Nerode; failing to build a DFA is not proof. Be careful with closure properties.
Where it fits in the course
Regular Languages is topic 21 of 51 in Theory & Discrete Math, rated Intermediate. It follows Nondeterministic Finite Automata. The next topic is Regular Expressions in Theory.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Theory & Discrete Math quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Theory & Discrete Math quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is Regular Languages?
Where do people use Regular Languages?
What is the most common mistake with Regular Languages?
What should I learn before this topic?
How can I practice it?
Is Regular Languages hard to learn?
How long does it take to learn Regular Languages?
Which topics are related to Regular Languages?
What should I study after Regular Languages?
Related topics
- Nondeterministic Finite Automata (Theory & Discrete Math)
- Regular Expressions in Theory (Theory & Discrete Math)
- Deterministic Finite Automata (Theory & Discrete Math)
- Pumping Lemma for Regular Languages (Theory & Discrete Math)
- Compiled vs Interpreted Languages (Languages & Compilers)
- Regular Expressions (Programming Fundamentals)
- Domain-Specific Languages (Languages & Compilers)