5
$\begingroup$

How can we design a regular expressions without particular substrings. The goal of this is to create language L which won't contain a particular substring (i.e. 110)

for the case of a regular expression without substring $110$, I Was thinking of: $\require{cancel}\cancel{(101)^*+}(010)^*+(10)^*+(\cancel{1}1)^*+(\cancel{0}0)^*+(01)^*$ but is that over excessive?

Then for example, I crossed out (101)* because obviously if you have two of those 101101, a subset of that will be 110, which we don't want.

Notes:

Question has been edited since it gained attention in the past few days. Also see comment for justification.

$\endgroup$
7
  • 1
    $\begingroup$ Hello :) look that $(101)^*$ may generate $101101$, and there is a $110$. $\endgroup$ May 5, 2013 at 0:03
  • $\begingroup$ 11 010 and 11 00 are permitted by you language but both start with 110, and 101 10 is also permitted and ends with 110. $\endgroup$ May 5, 2013 at 2:07
  • $\begingroup$ Doh! That's me being confused. The "001 is disallowed" statement was explicitly based on you concatenating closures without an outer closure. You need a closure around your union. (But not the union you've currently got.) $\endgroup$ May 5, 2013 at 23:14
  • $\begingroup$ Question edited, I don't think this should be closed because it's useful for anyone studying Automata and Regular Language. This is a constructive question that clearly states the intention. It was a question I struggled with when I took this class back in May 2013. $\endgroup$
    – Iancovici
    Jan 31, 2014 at 12:03
  • $\begingroup$ The attempted answer in the question is incorrect: it does not match 00100, for example. $\endgroup$ Jan 31, 2014 at 13:07

5 Answers 5

9
$\begingroup$

I did the following multistep technique.

Step 1: make a DFA that accepts all strings with "110". I am able to construct a DFA that accepts all strings with substring "110" and has just 4 states.

Step 2: Flip all the accepting states to non-accepting and all the non-accepting states to accepting. This page at Old Dominion describes the technique quite succinctly. This creates a DFA that accepts the language you want.

Step 3: Now you need to convert the DFA back to a regular expression. As @Alejandro Sazo mentioned there is a proof that this is possible. But you need an algorithm. This paper by Christoph Neumann describes three different techniques. The easiest one is the "state removal technique." You remove a state and replace all the edges between states that were connected to the removed state with edges labeled with regular expressions. As you reduce in this way you eventually get to a regular expression for the whole DFA. (Note that Figure 4 in the paper I linked is not quite right. The self-loop on state $q_j$ should have the regular expression "c e* b", not "c e* d".)

By going through this process it became clear that: the language you are going to need to solve for this particular problem has the property that once you have seen the sub-string "11" then you can never see another "0".

$\endgroup$
7
$\begingroup$

Here is a long answer: create the automata $M$ that recognizes the substring $110$, then create it's complement $\bar{M}$ and translate it into a regular expression. Fortunately this is possible thanks to the theorem:

If $L = L(M)$ is the lenguage recognized by a DFA $M$, then exists a regular expresion R such that $L = L(R)$

The answer is long because the number of steps (build $M$, build $\bar{M}$, create RE). In fact you may need to minimize the DFA before build the RE.

$\endgroup$
0
5
$\begingroup$

If your question is to find a regular expression for strings that avoid $110$ then a possible answer is $(0+10)^*1^*$ as computed by ChesterX. The intuition is clear: after two $1$'s we can only add $1$'s, so that can only happen at the end. Otherwise we are "safe" if we accompany every $1$ by a $0$.

If you question is how to find a regular expression for the expression avoiding subword $w$ in general, then follow the course set by Alajandro and Wandering Logic: (1) make a "linear" nondeterministic FSA for $\Sigma^* w \Sigma^*$, (2) determinize (3) complement (4) construct expression by successive state removal.

Here I want to make two remarks.

First, in general the determinization of a FSA can result in a exponentional blow-up in size. Fortunately in this setting this will not happen. The automata obtained are related to the construction of a patternmatching automaton due to Knuth-Morris-Prat.

Second, although the automaton will not explode in size, its structure can be nontrivial.

An example of both observations is given below. The automaton for pattern $11011010$ in both nondeterministic and deterministic versions. For the DFA I have cheated a little. For state $8*$ we find by the usual algorithm a large set of states, all accepting. That an easily be summarixed by this single state (which becomes useless after complementation).

enter image description here

$\endgroup$
0
$\begingroup$

I used jFlap to draw the DFA.

DFA accepting all strings not containing substring 110

Then using jFlap again, got the RegEx as : $(0+10)^*(\lambda+1+111^*)$

$\endgroup$
1
  • 4
    $\begingroup$ That tells us how to run a program that solves the problem for us, but it does not tell us how the program does it (which is what we want to understand). $\endgroup$
    – Raphael
    Jan 31, 2014 at 9:43
-6
$\begingroup$

I don't know the real logic but as per my understanding... It is clearly work on the logic of don't accept the 110 .. so it means whenever you got the substring like 110 ... At that time you must be not at a " Final state" so as per the above fig mentioned by my friend it is clear that after accepting the 0 in q2 state we not reach at final state it means ..We not get the final state so system generate error or ignore this type of no to accept ...And our aim to remove or not generate the string which contain 110 is clearly satisfy..

$\endgroup$
2
  • 2
    $\begingroup$ If you don't know the answer while others do, please don't post an answer. $\endgroup$ Jan 28, 2017 at 17:44
  • $\begingroup$ And if you have a question, please post a question! $\endgroup$
    – Raphael
    Jan 29, 2017 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.