Earlier quoted context omitted.
It is a general rule that those who avoid answering a question do not have an answer, and this is no exception. Here, You completely misunderstand Chomsky’s hierarchy: By your inverted-hierarchy argument, the simplest regular language would be complex enough that incompleteness would be an issue in its validation.
Well, this looks like abuse of Cunningham's law, but I'll bite. It is a general rule that general rules have exceptions. And you have (incorrectly) asserted that this is not an exception. Q.E.D Even the most powerful languages (Type 0 in the hierarchy) cannot solve the halting problem. Which is equivalent to Godel's incompleteness theorem. https://www.scottaaronson.com/blog/?p=710 If a Type 3 grammar can recursively…
Is there a regular expression to detect a valid regular expression?
171–180 of 224 posts
Re: Is there a regular expression to detect a valid regular expression?
#172Earlier quoted context omitted.
Well, this looks like abuse of Cunningham's law, but I'll bite. It is a general rule that general rules have exceptions. And you have (incorrectly) asserted that this is not an exception. Q.E.D Even the most powerful languages (Type 0 in the hierarchy) cannot solve the halting problem. Which is equivalent to Godel's incompleteness theorem. https://www.scottaaronson.com/blog/?p=710 If a Type 3 grammar can recursively…
Your second paragraph is just a direct begging-of-the-question. More significantly, verifying that sentences are well-formed in some language is not the same as proving the language’s correctness. As a response to you argument, consider this regular language: A
Re: Is there a regular expression to detect a valid regular expression?
#173Earlier quoted context omitted.
Well, this looks like abuse of Cunningham's law, but I'll bite. It is a general rule that general rules have exceptions. And you have (incorrectly) asserted that this is not an exception. Q.E.D Even the most powerful languages (Type 0 in the hierarchy) cannot solve the halting problem. Which is equivalent to Godel's incompleteness theorem. https://www.scottaaronson.com/blog/?p=710 If a Type 3 grammar can recursively…
Your second paragraph is just a direct begging-of-the-question. More significantly, verifying that sentences are well-formed in some language is not the same as proving the language’s correctness. As a response to you argument, consider this regular language: A
Proving that a sentences are “well-formed” is the same as implementing an algorithm which takes a string and returns a Boolean.
You can call this function “is_well_formed?”
I await your proof in the regular language you have specified above.
Re: Is there a regular expression to detect a valid regular expression?
#174Earlier quoted context omitted.
You are axiomatically assuming that the proposition "V determines well-formedness of any regular expressions" to be true. I am asking you to prove that. Constructively.
It's not possible to do this for regular expressions, but it is possible to do it for context free grammars. You can write a context-free grammar in Backus-Naur form that recognizes all context-free grammars in Backus-Naur form: ::= | ::= " ">" "::=" ::= " " | "" ::= | "|" ::= | ::= | ::= | " ">" ::= '"' '"' | "'" "'" ::= "" | ::= '' | ::= | | ::= "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L"…
The choice exists.
https://en.wikipedia.org/wiki/Total_functional_programming
Observe though that BNF is just a notation. Parsers for BNF are not implemented in BNF. Bison. Yacc.
Re: Is there a regular expression to detect a valid regular expression?
#175Earlier quoted context omitted.
Can regex engines actually process arbitrarily deep nestings themselves though? It seems to me it would start getting computationally expensive very quickly to search for those kinds of regexes, so is 'arbitrarily deep' a practical concern for todays hardware?
Yes, regex engines that are designed to do so run in linear time on the size of the regex (as well as linear time with respect to the length of the input). One such engine is rust's https://github.com/rust-lang/regex
Re: Is there a regular expression to detect a valid regular expression?
#176My second thought: the voice of Linus Torvalds at DebConf 14 saying "Hum… No! Hum… that was quick." [1]
Though this is only speaking about a recursively defined regular expression language which is infinite, which strictly handles regular languages, as defined in computer science lessons in university.
And then, "Why not just try and see if it breaks the provided regex parser since you have one?", and it's actually one of the answers in the link… awesome. I wonder it is has security implications though (are forged regexes exploiting flawed regex parsers a thing?)
Re: Is there a regular expression to detect a valid regular expression?
#177Earlier quoted context omitted.
Yes, regex engines that are designed to do so run in linear time on the size of the regex (as well as linear time with respect to the length of the input). One such engine is rust's https://github.com/rust-lang/regex
Does "linear wrt A and linear wrt B" mean O(A*B) or O(A+B)?
I'm not sure if it's possible to match regex with that time complexity, it looks like the implementation I referenced is O(AB). https://docs.rs/regex/1.3.1/regex/#untrusted-input.
(star symbol removed because hn decided to turn them into a block of italics)
Re: Is there a regular expression to detect a valid regular expression?
#178Earlier quoted context omitted.
Just considering the language of balanced parentheses, the only memory needed is a single integer to track depth. If we see a "(", increment. If we see a ")", decrement. If we never go negative and end up with zero, that's a balanced parentheses expression. (To be clear, the parser I've described is not a regex parser.) Adding the rest of the regex machinery makes this a bit more complex, but in general, if the compu…
)))((()(()
I'm sure some sort of rather cheap algorithm falls out of the above. It wont guarantee correctness in what the balanced brackets actually contain but they will at least be balanced.
Re: Is there a regular expression to detect a valid regular expression?
#179My first thought seeing this title: "Why, no. Next!" My second thought: the voice of Linus Torvalds at DebConf 14 saying "Hum… No! Hum… that was quick." [1] Though this is only speaking about a recursively defined regular expression language which is infinite, which strictly handles regular languages, as defined in computer science lessons in university. And then, "Why not just try and see if it breaks the provided r…
Looks like yes, depending on the engine.
PCRE for instance has a long list of security vulnerabilities including some with arbitrary code execution: https://www.cvedetails.com/vulnerability-list.php?vendor_id=...
Re: Is there a regular expression to detect a valid regular expression?
#180Earlier quoted context omitted.
I don't know if it's possible to do the "string describing a set strings" thing that regex does with more powerful parsing while maintaining the ease of use. CFGs make heavy use of named sub-languages (productions). A regex-style parser would at least have to have some kind of recursion-inducing metacharacter.
How about this for ease-of-use? sentence --> noun_phrase, verb_phrase. noun_phrase --> det, noun. verb_phrase --> verb, noun_phrase. det --> [the]. det --> [a]. noun --> [cat]. noun --> [bat]. verb --> [eats]. Reads -and behaves- as BNF. Strings in []'s are terminals, the rest are nonterminals. It's directly executable as a logic program (it's Prolog syntactic sugar).