regular-language

is a* the same as (a*)*?

ぐ巨炮叔叔 提交于 2019-12-06 03:05:48
Quick question, if a is a regular expression then is it true that a* = (a*)* ? Is (a*)* a valid expression? If it is, then can anyone explain why is it the same as a* ? I apologize for asking here, but I couldn't find anything via Google. Grijesh Chauhan Yes , a*=(a*)* are same. Both generate same language that is string any numbers a's including null . L(a*) = {^, a, aa, aa...... } = L ((a*)*) Is (a*)* a valid expression? Yes, this expression is called REGULAR-EXPRESSION (I saw you missed the tag). Any Regular Language(RL) can be represented by Regular Expression(RE). A alphabetical way of

Is it possible to have regexp that matches all valid regular expressions?

寵の児 提交于 2019-12-06 02:07:52
问题 Is it possible to detect if a given string is valid regular expression, using just regular expressions? Say I have some strings, that may or may not be a valid regular expressions. I'd like to have a regular expression matches those string that correspond to valid regular expression. Is that possible? Or do I have use some higher level grammar (i.e. context free language) to detect this? Does it affect if I am using some extended version of regexps like Perl regexps? If that is possible, what

generalizing the pumping lemma for UNIX-style regular expressions

爷,独闯天下 提交于 2019-12-06 02:06:15
问题 Most UNIX regular expressions have, besides the usual ** , + , ?* operators a backslash operator where \1,\2,... match whatever's in the last parentheses, so for example *L=(a*)b\1* matches the (non regular) language *a^n b a^n* . On one hand, this seems to be pretty powerful since you can create (a*)b\1b\1 to match the language *a^n b a^n b a^n* which can't even be recognized by a stack automaton. On the other hand, I'm pretty sure *a^n b^n* cannot be expressed this way. I have two questions

Representing identifiers using Regular Expression

只谈情不闲聊 提交于 2019-12-05 10:19:51
问题 The regular definition for recognizing identifiers in C programming language is given by letter -> a|b|...z|A|B|...|Z|_ digit -> 0|1|...|9 identifier -> letter(letter|digit)* This definition will generate identifiers of the form identifier: [_a-zA-Z][_a-zA-Z0-9]* My question now is how do you limit the length of the identifier that can be generated to not more than 31 characters. What changes need to be made in the regular definition or how to write a regular expression to limit it to not

Pumping lemma (Regular language)

浪尽此生 提交于 2019-12-05 09:08:56
I need some help with a pumping lemma problem. L = { {a,b,c}* | #a(L) < #b(L) < #c(L) } This is what I got so far: y = uvw is the string from the pumping lemma. I let y = abbc^n, n is the length from the pumping lemma. y is in L because the number of a:s is less than the number of b:s, and the number of b:s is less than the number of c:s. I let u = a, v = bb and w = c^n. |uv| < y, as stated in pumping lemma. If I "pump" (bb)^2 then i get y = abbbbc^n which violates the rule #b(L) < #c(L). Is this right ? Am I on the "right path" ? Thanks The main idea of the pumping lemma is to tell you that

Regular languages vs. non-regular ones [closed]

假装没事ソ 提交于 2019-12-05 05:08:26
Can anyone kindly help me distinguish between regular languages (i.e. those that can be described by regular expressions) and other languages that are not regular in terms of the formal definition of regular languages? Furthermore, can you provide some examples on both sides? Regular languages are defined recursively over an alphabet A as follows: The empty set \null is regular. The set { \eps } is regular, where \eps is the empty string. The set { a } is regular for all a \in A If X and Y are regular, then the set { xy | x \in X, y \in Y } is also regular. If X and Y are regular, then X

Regular expression for [a-zA-Z] [closed]

女生的网名这么多〃 提交于 2019-12-04 14:02:54
Closed . This question needs to be more focused. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it focuses on one problem only by editing this post . Closed 4 years ago . I have a regular expression that matches English letters only, a [a-zA-Z] character class. Is there any built-in regular expression for that? I mean something like \s or \w . You are asking for a shorthand class for English letters. In case you are using POSIX-compliant regex , [:alpha:] is the "bracket expression" for [a-zA-Z] class. It is also supported by PCRE

Minimum pumping length for a regular language

有些话、适合烂在心里 提交于 2019-12-04 12:52:54
How to calculate minimum pumping length of a regular language. For example if i have 0001* then minimum pumping length for this should be 4 ,that is 000 could not be pumped . Why it is so? It will be less than or equal to the number of states in a minimal DFA for the language, minus one. So convert the regular expression into a DFA, minimize it, and count the states. For your example: 0001* SOURCE SYMBOL DESTINATION q1 0 q2 q1 1 q5 q2 0 q3 q2 1 q5 q3 0 q4 q3 1 q5 q4 0 q5 q4 1 q4 q5 0 q5 q5 1 q5 Why is it equal to this? Because that's the maximum number of transitions you can take in the DFA

Scheme, When to use Symbols instead of Strings?

时间秒杀一切 提交于 2019-12-04 09:39:36
I apologize in advance for my primitive english; i will try my best to avoid grammatical errors and such. Two weeks ago i decided to freshen my knowledge of Scheme (and its enlightnings) whilst implementing some math material i got between hands, specifically, Regular Languages from a course on Automata theory and Computation in which i am enrolled. So far, i've been representing alphabets as lists of symbols instead of lists of chars because i want to have letters of variable size. lists of strings because i somewhat feel thats unelegant. I'm inexperienced and would like to know your opinion

generalizing the pumping lemma for UNIX-style regular expressions

你说的曾经没有我的故事 提交于 2019-12-04 06:54:44
Most UNIX regular expressions have, besides the usual ** , + , ?* operators a backslash operator where \1,\2,... match whatever's in the last parentheses, so for example *L=(a*)b\1* matches the (non regular) language *a^n b a^n* . On one hand, this seems to be pretty powerful since you can create (a*)b\1b\1 to match the language *a^n b a^n b a^n* which can't even be recognized by a stack automaton. On the other hand, I'm pretty sure *a^n b^n* cannot be expressed this way. I have two questions: Is there any literature on this family of languages (UNIX-y regular). In particular, is there a