3 ms·
Given example strings: {a, b, c, d} The most restrictive regular expression is: a | b | c | d The most permissive regular expression is: * If the sy
by brudgers 11y ago
Given example strings:
{a, b, c, d}
The most restrictive regular expression is:
a | b | c | d
The most permissive regular expression is:
*
If the system produces anything in between I cannot predict the output without knowing a set of rules that are more complicated than the regular expression that the system of rules produces. TANSTAAFL.
- mimmuz 11y agothe system requires also negative examples
- brudgers 11y agoNegative examples do not change the most restrictive regular language. It remains the union of the accepted strings. Negative examples constrain the most permissive interpretation to the regular language defined: 1a. Let NegativeExamples be the most restrictive regular expression [as above] using the negative examples as input. or 1b. Let NegativeExamples be the most permissive regular expression [as above] using the negative exmaples as input. 2. Let U be the regular language defined by the kleene star. The negative examples define the regular language: U - NegativeExamples And depending on the choice of 1a or 1b, you get a regular language slightly more restricted than the kleene star or the empty language. Regular expressions are a compact way of precisely describing an enumeration of permutations. The only way to get equal precision via enumeration is to fully enumerate all the permutations. Once a parser gets into the picture, then the input strings have to have semantics that the parser can use and a hidden set of parser rules for interpreting those semantics.
- mimmuz 11y agoI do not understand the point. Really. My limit... Or you misunderstood the purpose of the automatic regex generator.
- brudgers 11y ago[skipping wikipedia links] Formally, regular expressions describe finite automata. A finite automata is a state machine that accepts a language. Hence, a regular expression defines a language [and in particular a regular language]. Regular languages have closure properties, which is to say that under certain operations two regular languages produce another regular language, and therefore certain operations on regular expressions can produce another regular expression. The regular expression generator takes some input and produce a regular expression. There are two possible scenarios: 1. Treat the input as one or more regular languages and perform only closed operations. 2. Treat the input as some other type of language, e.g. a context free language and parse the input according to the rules of that language to produce a regular expression. The first option means that we can determine the output of the regular expression generator by knowing only one rule: is does it generate regular expressions starting by adding to the empty language or by difference from the kleene star. But there is still ambiguity that requires we have knowledge about the internal workings of the expression generator. The second option means that in order to determine what output a given input will produce we have to know about a potentially unlimited number of rules (and these rules may change dynamically based on the input)[1]. What this means is that no regular expression generator is generally useful as a black box. Ambiguity assures it, and ambiguity is intrinsic because the regular expression generator must treat the input as within a more complex language (e.g. context free) and force it into the simpler class of regular languages. As my analysis shows, the way in which the regular expression generator interprets the input is arbitrary. If you're really interested in the topic, Jeff Ulman (who with Alfred Aho wrote the book on automata) teaches a course on automata via Coursera. Rumor (well actually an email) has it that he is teaching it again this fall. A person could do worse than learning about automata from a person down a Stanford hallway from Donald Knuth's office. Even cooler is that Jeff Ullman shows up in class to discuss questions (which is probably why the course only comes around once a year). https://www.coursera.org/course/automata https://www.coursera.org/course/automata Just because lunches cannot be free doesn't mean they can't be cheap. [1] Moreover, via the Halting Problem we cannot be certain that the regular expression generator will produce any output at all.
- mimmuz 11y ago
- mimmuz 11y agoMoreover an equally restrictive regex could be: [a-d] I start to think that we are talking about different topics ;-)
- brudgers 11y agoThat assumes a particular encoding, e.g. that a,b,c,d are not names of expressions.