Search code examples
regexcomputation-theory

How this language has even number of symbols ((0+1)(0+1))*


I am studying course for Automata, may be as a beginner I'm missing something , I am really confused with this regular expression as the teacher saying

it represents a language with all binary strings having even number of symbols

Alphabet Σ={0,1}

((0+1)(0+1))*

(0+1) saying union of 0 and 1

but I am confused here let suppose first (0+1) gives 01 and second (0+1) gives only 0, then finally we concatenate both having (010)* and let it end up with only one occurrence i.e. 010

then how it has even number of symbols? need little understanding of this...


Solution

  • The given Question: ((0+1)(0+1))*

    Let's start from the innermost bracket (0+1) this matches with either 0 or 1 not 01

    '+' means "or" operator, this is not a conjunction operator.

    and this is repeated twice hence ((0+1)(0+1)) matches with 01 or 10 or 00 or 11

    and '*' means it matches 0 or more times

    Hence, ((0+1)(0+1))* matches with [NULL] or 01 or 10 or 00 or 11 or 0011 or 1100 or 1010 or 0110 ....so on