regular expressions in language

35 Views Asked by At

im learning theoretical computer science regular expressions

i need to find regular expressions for

language in $\sum {0,1,2,3 }$

a.) language with at most one 1 and at most one 2

$(0+3)^{*}1(0+3)^{*}2(0+3)^{*}+(0+3)^{*}2(0+3)^{*}1(0+3)^{*}+(0+3)^{*}1(0+3)^{*}+(0+3)^{*}2(0+3)^{*}+1^{*}$

or

$1^{*}(0^{+} + 2^{+} +3^{+}+ \epsilon)1^{*}(0^{+} + 2^{+} + 3^{+}\epsilon)1^{*}$

im not sure which one is right

b.) language that not end in 12

$(0+1+2)^{*}((0+2)(0+1+2)+1(0+1))$

is this correct?

2

There are 2 best solutions below

0
On BEST ANSWER

Ad a) $(0+3)∗1(0+3)∗2(0+3)∗+(0+3)∗2(0+3)∗1(0+3)∗+(0+3)∗1(0+3)∗+(0+3)∗2(0+3)∗+1∗$. The last expression $1*$ should be replaced by $(0+3)*$.

0
On

Since you are learning Theoretical computer science, it is easier to learn about automata theory.Then,every regular expression is equivalent to an automaton.So, you could construct first the automato that do what you want and after that to compute the appropriate language. Then you will be sure if you have the right result.