automata

Design Pattern problem involving N states and transitions between them

偶尔善良 提交于 2019-11-27 09:37:53
问题 I have a problem at hand and I am not getting which design pattern to use. The problem goes as such: I have to build a system which has 'N' states and my system has to do a transition from any state to any other state depending on some conditions. Ex: On condition 1, movement from State 1 to 3 and on condition 2 from state 1 to 4. Even the transition from one state to other state can be done on 2 or more different conditions. For example, transition from State 1 to state 3 can be done when:

Regular vs Context Free Grammars

假如想象 提交于 2019-11-27 05:52:37
I'm studying for my computing languages test, and there's one idea I'm having problems wrapping my head around. I understood that regular grammars are simpler and cannot contain ambiguity, but can't do a lot of tasks that are required for programming languages. I also understood that context-free grammars allow ambiguity, but allow for some things necessary for programming languages (like palindromes). What I'm having trouble with is understanding how I can derive all of the above by knowing that regular grammar nonterminals can map to a terminal or a nonterminal followed by a terminal or that

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

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

♀尐吖头ヾ 提交于 2019-11-26 18:36:37
问题 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. 回答1: 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 +

Is it possible for a computer to “learn” a regular expression by user-provided examples?

☆樱花仙子☆ 提交于 2019-11-26 16:52:57
Is it possible for a computer to "learn" a regular expression by user-provided examples? To clarify: I do not want to learn regular expressions. I want to create a program which "learns" a regular expression from examples which are interactively provided by a user, perhaps by selecting parts from a text or selecting begin or end markers. Is it possible? Are there algorithms, keywords, etc. which I can Google for? EDIT : Thank you for the answers, but I'm not interested in tools which provide this feature. I'm looking for theoretical information, like papers, tutorials, source code, names of

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

旧时模样 提交于 2019-11-26 16:15:01
问题 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

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

≡放荡痞女 提交于 2019-11-26 15:01:40
问题 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 . 回答1: 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

Finding the complement of a DFA?

巧了我就是萌 提交于 2019-11-26 08:13:30
问题 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