11/9/2020 Grok | COMP30026 Practice Exam
Ques on 6
Ques on 6 Part A (2 marks)
We define the simplicity of a regular expression as the total number of occurrences of concatena ons, unions, Kleene stars, alphabet symbols, empty string symbols, and empty set symbols in the regular expression. The simplest regular expression for a regular language is the regular expression with the smallest possible simplicity expressing that language.
For example, the regular expression has two concatena ons, one union, one Kleene star, one empty string symbol, and three alphabet symbols, for a total
simplicity of 8. However, it is not the simplest possible regular expression for its language; expresses the same language, and has simplicity 6.
Part A (2 marks)
The class of regular languages is closed under intersec on, so the language
is regular. What is the simplest regular expression for ?
Note: Par al marks will be awarded for a regular expression which is correct but not the simplest.
Instruc ons
Giveyouranswerasavariabler6A :: RegExp. Format
RegExp.hs provides a regular expression type RegExp, and a parser for regular expressions,parseRE :: String -> RegExp.Usethistypetoenteryouranswer.
For example:
The regular expression may be entered as follows:
Star (Concat (Symbol ‘b’) (Symbol ‘a’)),or
parseRE “(ba)*”.
The regular expression may be entered as follows:
Concat (Symbol ‘a’) (Union EmptyStr (Concat (Symbol ‘a’) (Symbol ‘b’))),or
parseRE “a(eps | ab)”.
https://groklearning.com/learn/unimelb-comp30026-2020-s2/prac-exam/14/ 1/1
Cheng
M
)∗a∗b(L ∩ )∗b∗a(L = M
∗)aba ∪ ε(
)ba ∪ ε(a
∗)ab(
∗)aba(