Hello I'm having trouble understanding how an intersection/union of regular languages can be regular and in other case non-regular.
Can someone please give me some good examples?
Hello I'm having trouble understanding how an intersection/union of regular languages can be regular and in other case non-regular.
Can someone please give me some good examples?
For every word $w$, there's a language $\{ w\}$, which is regular, and $\Sigma^* \setminus \{ w\}$, which is also regular.
But, we can express every language (regular or not) $L$ as an infinite union: $L = \bigcup_{w \in L} \{ w \}$, which is an infinite union of regular languages.
For intersection, you do the opposite:
$L = \bigcap_{w \not \in L} (\Sigma^* \setminus \{w \})$.
So, we know that there are regular languages, and non-regular languages, and they can all be expressed as infinite unions or intersections of regular languages.
Every regular language can be described as a DFA. So assume you have a DFA that represents language one, and a DFA that represents language two. Now construct a third DFA that represents the union of the first two DFA. Construct another DFA that represents the intersection of the first two DFA.