dfa

How to implement regular expression NFA with character ranges?

自古美人都是妖i 提交于 2019-12-18 05:14:46
问题 When you read such posts as Regex: NFA and Thompson's algorithm everything looks rather straightforward until you realize in real life you need not only direct characters like "7" or "b", but also: [A-Z] [^_] . namely character classes (or ranges). And thus my question -- how to build NFA using character ranges? Using meta-characters like "not A", "anything else" and then computing overlapping ranges? This would lead to using tree-like structure when using final automaton, instead of just a

How does “δ:Q×Σ→Q” read in the definition of a DFA (deterministic finite automaton)?

不想你离开。 提交于 2019-12-17 07:38:55
问题 How do you say δ: Q × Σ → Q in English? Describing what × and → mean would also help. 回答1: δ is like a mathematical function called the transition function . Something like. z = f(x, y) A function in mathematical defines mapping of elements in one set to another set. In function set of input arguments are called Domain of a function and output is the rage. [ANSWER] In expression "δ:Q×Σ → Q" , × means Cartesian product (that is a set), and → is a mapping . "δ:Q×Σ → Q" says δ is a transition

drawing minmal DFA for the given regular expression

房东的猫 提交于 2019-12-17 06:51:14
问题 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 回答1: 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.

DFA of two simple languages and then product construction of those two languages

ぐ巨炮叔叔 提交于 2019-12-13 04:16:26
问题 The language below is the intersection of two simpler languages. First, identify the simpler languages and give the state diagrams of the DFAs that recognize them. Then, use the product construction to build a DFA that recognizes the language specified below; give its state diagram before and after simplification if there are any unneeded states or states that can be combined. Language: {w is a member of {0,1}* | w contains an odd number of 0s and the sum of its 0s and 1s is equal to 1} This

What is the algorithm for generating a random Deterministic Finite Automata?

大憨熊 提交于 2019-12-12 15:58:52
问题 The DFA must have the following four properties: The DFA has N nodes Each node has 2 outgoing transitions. Each node is reachable from every other node. The DFA is chosen with perfectly uniform randomness from all possibilities This is what I have so far: Start with a collection of N nodes. Choose a node that has not already been chosen. Connect its output to 2 other randomly selected nodes Label one transition 1 and the other transition 0. Go to 2, unless all nodes have been chosen.

What is the intersection of two languages with different alphabets? [closed]

馋奶兔 提交于 2019-12-11 13:44:08
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I did some googling on this and nothing really definitive popped up. Let's say I have two languages A and B. A = { w is a subset of {a,b,c}* such that the second to the last character of w is b } B = { w is a subset of {b,d}* such that the last character is b } How would one define this? I think the alphabet

Automata theory : Conversion of a Context free grammar to a DFA

泪湿孤枕 提交于 2019-12-11 02:06:24
问题 How to convert a Context Free Grammar to a DFA? This is easy if we have transitions like A->a B. But when we have the transitions as A->a B c. Then how should we represent it as a DFA 回答1: First, you should convert your language to CNF (Chomskey Normal Form). Then steps for conversion are as such: Convert it to left/right grammar is called a regular grammar. Convert the Regular Grammar into Finite Automata The transitions for automata are obtained as follows For every production A -> aB make

Customizable Static Java Call-Graph generator?

本小妞迷上赌 提交于 2019-12-11 01:01:36
问题 I have to refactor and maintain a bunch of horrible similar looking Java classes. Many have the following implementation pattern class Machine { public int advance(int state) { switch(state) { case 7: return step_7(); case 13: return step_13(); case 4: return step_4(); } } private int step_7() { if(something) return 13; else return 4; } private int step_13() { ... return 4; } private int step_4() { if(miep) return 7; ... return 13; } } And from this I'd like to generate a graph (with Graphviz

Show that the following set over {a,b} is regular

守給你的承諾、 提交于 2019-12-10 16:33:41
问题 Given the alphabet {a, b} we define N a (w) as the number of occurrences of a in the word w and similarly for N b (w) . Show that the following set over {a, b} is regular. A = {xy | N a (x) = N b (y)} I'm having a hard time figuring out where to start solving this problem. Any information would be greatly appreciated. 回答1: Yes it is regular language! Any string consists if a and b belongs the language A = {xy | N a (x) = N b (y)} . Example: Suppose string is: w = aaaab we can divide this

Find the regular expression for the language on E={a,b}

安稳与你 提交于 2019-12-08 13:11:36
问题 L = w : (na(w) - nb(w)) mod 3 /= 0 How can I go about finding the regular expression for this language? I understand that it means that the number of As minus the number of Bs cannot be a multiple of 3. So a - b cannot be 3,6,9,12, etc. But I am still having trouble putting it into a regular expression. I tried first making it a DFA or NFA but I couldn't do that either. Any help is appreciated! 回答1: I would go about it by dividing the list of words on {a,b} into three cases: L1 = w : (na(w) -