dfa

Grammatical inference of regular expressions for given finite list of representative strings?

删除回忆录丶 提交于 2019-11-27 13:11:38
I'm working on analyzing a large public dataset with lots of verbose human-readable strings that were clearly generated by some regular (in the formal language theory sense) grammar. It's not too hard to look at sets of these strings one by one to see the patterns; unfortunately, there's about 24,000 of these unique strings broken up into 33 categories and 1714 subcategories, so it's somewhat painful to do this manually. Basically, I'm looking for an existing algorithm (preferably with an existing reference implementation ) to take an arbitrary list of strings and try to infer some minimal

Design DFA accepting binary strings divisible by a number 'n'

不打扰是莪最后的温柔 提交于 2019-11-27 09:59:07
I need to learn how to design a DFA such that given any number 'n', it accepts binary strings {0, 1} whose decimal equivalent number is divisible by 'n'. There will be different DFAs for different 'n', but can somebody give a basic approach that I should follow to proceed with any number 0 < n < 10 . Grijesh Chauhan Below, I have written an answer for n equals to 5, but you can apply same approach to draw DFAs for any value of n and 'any positional number system' e.g binary, ternary... First lean the term 'Complete DFA', A DFA defined on complete domain in δ:Q × Σ→Q is called 'Complete DFA'.

Regular expressions Equivalence

你。 提交于 2019-11-27 09:40:28
Is there a way to find out if two arbitrary regular expressions are equivalent? Looks like complex problem to me, but there might be some DFA simplification mechanism or something? To test equivalence you can compute the minimal DFAs for the expressions and compare them. Testability of equality is one of the classical properties of regular expressions. (N.B. This doesn't hold if you're really talking about Perl regular expressions or some other technically nonregular superlanguage.) Turn your REs to generalised finite automata A and B, then construct a new automaton A-B such that the accepting

Pumping lemma for regular language

☆樱花仙子☆ 提交于 2019-11-27 09:18:45
I have a little confusion in checking whether the given language is regular or not using pumping lemma. Suppose we have to check whether: L. The language accepting even number of 0 's in regular or not? We know that it is regular because we can construct a DFA for L. But I want to prove this with pumping lemma. Now suppose, I take a String w= "0000" : Now will divide the string as x = 0 , y = 0 , and z = 00 . Now on applying pumping lemma for i = 2 , I will get the string "00000" , which is not present in my language so by pumping lemma its prove that the language is not regular. But it is

Ambiguity in transition: How to process string in NFA?

时光毁灭记忆、已成空白 提交于 2019-11-27 07:12:02
问题 I have made DFA from a given regular expression to match the test string. There are some cases in which .* occurs. ( for example .*ab ) . Let say now the machine is in state 1. In the DFA, .* refers to the transition for all the characters to itself and another transition for a from the state 1 for 'a'. If test string contains 'a' then what could be the transition because from state 1, machine can go to two states that is not possible in DFA. 回答1: I start with fundamental with your example so

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

假装没事ソ 提交于 2019-11-27 02:59:48
问题 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? 回答1: 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

drawing minmal DFA for the given regular expression

北战南征 提交于 2019-11-27 02:06:44
What is the direct and easy approach to draw minimal DFA , that accepts the same language as of given Regular Expression(RE) . I know it can be done by: Regex ---to----► NFA ---to-----► DFA ---to-----► minimized DFA But is there any shortcut way? like for (a+b)*ab Grijesh Chauhan Regular Expression to DFA Although there is NO algorithmic shortcut to draw DFA from a Regular Expression(RE) but a shortcut technique is possible by analysis not by derivation, it can save your time to draw a minimized dfa. But off-course the technique you can learn only by practice. I take your example to show my

NFA与DFA

风格不统一 提交于 2019-11-27 01:23:19
正则表达式匹配,包含两个东西,一个是表达式,一个文本。 NFA(Nondeterministic Finite Automaton),不确定有穷自动机,表达式主导,NFA去吃文本,贪婪算法吃下去,如果因为前面吃得太多,导致后面没的吃(后面匹配失败),前面吃的要吐出一点,后面还匹配不成功,前面再吐出一点。。。 DFA(Deterministic Finite Automaton),确定有穷自动机,文本主导,DFA去找吃货,去掉不能吃的吃货,找到最合适的吃货。 举例来说:.*[0-9]+, 去匹配 hangzhou 2015,从程序的角度来看,[0-9]+ 是死代码,因为.*是大范围,[0-9]+是小范围,按道理永远不会被匹配到。 实际的匹配流程是: .*一直吃到5,然后发现坏了,吃太多了,导致[0-9]+没法匹配,于是吐出5,这样就导致[0-9]+匹配成功,也就是说,.*匹配hangzhou 201,[0-9]+匹配5,显然,这不是好的匹配结果,好的匹配结果应该是,.*匹配hangzhou ,[0-9]+匹配2015,但是NFA不管,我只要匹配成功就好了,才不管你是不是最优匹配呢。 如何解决上面的问题呢? 因为量词是优先匹配的,也就是尽量多吃,解决办法是忽略优先量词,也就是尽量少吃,使用 (.*?)([09]+),匹配结果就是 .*?匹配hangzhou ,[0-9]+匹配2015,

Need Regular Expression for Finite Automata: Even number of 1s and Even number of 0s

别来无恙 提交于 2019-11-27 01:05:13
My problem may sounds different to you. I am a beginner and I am learning Finite Automata. I am googing over Internet to find the Regular Expression for Finite Automata of Given Machine Below. Can anyone help me to write "Regular Expression for Finite Automata" of above machine Any help will be appreciated Grijesh Chauhan How to write regular expression for a DFA using Arden theorem Lets instead of language symbols 0 , 1 we take Σ = {a, b} and following is new DFA. Notice start state is Q 0 You have not given but In my answer initial state is Q 0 , Where final state is also Q 0 . Language

Finding the complement of a DFA?

天涯浪子 提交于 2019-11-26 22:12:23
I am asked to show DFA diagram and RegEx for the complement of the RegEx (00 + 1)* . In the previous problem I had to prove that the complement of a DFA is closed and is a regular expression also, so I know that to convert a DFA, M to the complement, M`, I just need to swap the initial accepting states and final accepting states. However, it appears that the initial accepting states for the RegEx are {00, 1, ^} and the final accepting states are {00, 1, ^} as well. So swapping them will just result in the exact same RegEx and DFA which seems contradictory. Am I doing something wrong or is this