regular-language

Generative regular expressions

妖精的绣舞 提交于 2019-11-30 07:24:49
Typically in our work we use regular expressions in capture or match operations. However, regular expressions can be used - manually at least - to generate legal sentences that match the regular expression. Of course, some regular expressions can match infinitely long sentences, e.g., the expression .+ . I have a problem that could be solved by using a regular expression sentence generating algorithm. In pseudocode, it would operate something like this: re = generate("foo(bar|baz)?", max_match = 100); #Don't give me more than 100 results assert re == ("foobar", "foobaz", "foo"); What algorithm

How should one proceed to prove (or find) if two regular expressions are same or equivalent?

一曲冷凌霜 提交于 2019-11-30 07:18:05
For example, in an assignment given to me, we were asked to find out if two regular expressions are equal or not. (a+b+c)* and ((ab)**c*)* My question is how is one supposed to do that? If I draw the transition graphs for both and then run a few strings through it and show that both of the TGs are able to accept it, is that a sufficient proof ? If not, how do I do it? Is there a mathematical/axiomatic approach towards this? Thanks in advance. EDIT: There is another thing that I'd like to clear which is kind of related to this question. Are the two FAs depicted in the photo below the same? i.e.

How should one proceed to prove (or find) if two regular expressions are same or equivalent?

不羁的心 提交于 2019-11-29 09:30:01
问题 For example, in an assignment given to me, we were asked to find out if two regular expressions are equal or not. (a+b+c)* and ((ab)**c*)* My question is how is one supposed to do that? If I draw the transition graphs for both and then run a few strings through it and show that both of the TGs are able to accept it, is that a sufficient proof ? If not, how do I do it? Is there a mathematical/axiomatic approach towards this? Thanks in advance. EDIT: There is another thing that I'd like to

Determining whether a regex is a subset of another

瘦欲@ 提交于 2019-11-28 16:32:03
I have a large collection of regular expression that when matched call a particular http handler. Some of the older regex's are unreachable (e.g. a.c* ⊃ abc* ) and I'd like to prune them. Is there a library that given two regex's will tell me if the second is subset of the first? I wasn't sure this was decidable at first (it smelled like the halting problem by a different name). But it turns out it's decidable . Kevin Stricker Trying to find the complexity of this problem lead me to this paper. The formal definition of the problem can be found within: this is generally called the inclusion

Is L = {a^n b^m | n>m} a regular or irregular language?

浪尽此生 提交于 2019-11-28 11:25:27
I have troubles in solving/proving this problem. Any ideas please? Grijesh Chauhan L = {a n b m | n > m} is not regular language. Yes, the problem is tricky at first few try and deserve vote-up. Pumping Lemma a necessary property of regular language is tool for formal proof that language is not regular language. Formal definition: Pumping lemma for regular languages Let L be a regular language. Then there exists an integer p ≥ 1 depending only on L such that every string w in L of length at least p ( p is called the "pumping length") can be written as w = xyz (i.e., w can be divided into three

Why L={wxw^R| w, x belongs to {a,b}^+ } is a regular language

爱⌒轻易说出口 提交于 2019-11-28 09:32:57
Using pumping lemma, we can easily prove that the language L1 = {WcW^R|W ∈ {a,b}*} is not a regular language . (the alphabet is {a,b,c}; W^R represents the reverse string W) However, If we replace character c with "x"(x ∈ {a,b}+) , say, L2 = {WxW^R| x, W ∈ {a,b}^+} , then L2 is a regular language . Could you give me some ideas? Grijesh Chauhan If we replace character c with x where (x ∈ {a,b} + ), say, L2 = {WXW R | x, W ∈ {a,b} + }, then L2 is a regular language. Yes, L2 is Regular Language :). You can write regular expression for L2 too. Language L2 = {WXW R | x, W ∈ {a,b} + } means: string

To make sure: Pumping lemma for infinite regular languages only?

為{幸葍}努か 提交于 2019-11-28 09:22:25
So this is not about the pumping lemma and how it works, it's about a pre-condition. Everywhere in the net you can read, that regular languages must pass the pumping lemma, but noweher anybody talks about finite languages, which actually are a part of regular languages. So we might all aggree, that the following language is a finite language as well as it's a regular one, but it definitely does not pass the pumping lemma: L = {'abc', 'defghi'} Please, tell me if simply no one writes about it or why we're wrong - or even not. The reason that finite languages work with the pumping lemma is

What is a regular language?

試著忘記壹切 提交于 2019-11-27 16:43:38
I'm trying to understand the concept of languages levels (regular, context free, context sensitive, etc.). I can look this up easily, but all explanations I find are a load of symbols and talk about sets . I have two questions: Can you describe in words what a regular language is, and how the languages differ? Where do people learn to understand this stuff? As I understand it, it is formal mathematics? I had a couple of courses at uni which used it and barely anyone understood it as the tutors just assumed we knew it. Where can I learn it and why are people "expected" to know it in so many

What will be the DFA for the regular expression 0(0+1)*0+1(0+1)*1?

孤人 提交于 2019-11-27 16:22:39
This is the DFA i have drawn- Is it correct? I am confused because q4 state has 2 different transitions for same input symbol which violates the rule of DFA , but I can't think of any other solution. Your DFA is not correct. your DFA is completely wrong so I don't comment DFA for RE: 0(1 + 0)*0 + 1(1 + 0)*1 Language Description : if string start with 0 it should end with 0 or if string start with 1 it should end with 1 . hence two final states (state-5, state-4). state-4 : accepts 1(1 + 0)*1 state-5 : accepts 0(1 + 0)*0 state-1 : start state. DFA : EDIT : + Operator in Regular Expression (0 +

Why is {a^nb^n | n >= 0} not regular?

六月ゝ 毕业季﹏ 提交于 2019-11-27 15:03:37
In a CS course I'm taking there is an example of a language that is not regular: {a^nb^n | n >= 0} I can understand that it is not regular since no Finite State Automaton/Machine can be written that validates and accepts this input since it lacks a memory component. (Please correct me if I'm wrong) The wikipedia entry on Regular Language also lists this example, but does not provide a (mathematical) proof why it is not regular. Can anyone enlighten me on this and provide proof for this, or point me too a good resource? cletus What you're looking for is Pumping lemma for regular languages .