finite-automata

How are finite automata implemented in code?

空扰寡人 提交于 2019-11-30 07:09:13
问题 How does one implement a dfa or an nfa for that matter in Python code? What are some good ways to do it in python? And are they ever used in real world projects? 回答1: A straightforward way to represent a DFA is as a dictionary of dictionaries. For each state create a dictionary which is keyed by the letters of the alphabet and then a global dictionary which is keyed by the states. For example, the following DFA from the Wikipedia article on DFAs can be represented by a dictionary like this:

Graph drawing algorithms - I'm trying to render finite state automata

雨燕双飞 提交于 2019-11-30 06:47:12
问题 I want to write something that will draw finite state automata. Does anyone know any algorithms that are related to this? EDIT: I should mention that I know about graphviz. I want to build my own draw program/function, so what I'm looking for is some more theoretical stuff/pseudo-code for algorithms. 回答1: Graph drawing is a fairly complex subject due to the fact that different graphs need to be drawn in different ways - there is no one algorithm fits all approach. May I suggest the following

Does C# include finite state machines?

馋奶兔 提交于 2019-11-29 20:11:15
I've recently read about the boost::statechart library (finite state machines) and I loved the concept. Does C# have a similar mechanism ? Or can it be implemented using a specific design pattern? Yes, C# has iterator blocks which are compiler-generated state machines. If you wish to implement you own state machine you can create custom implementations of the IEnumerable<T> and IEnumerator<T> interfaces. Both of these approaches highlight the .NET framework's implementation of the iterator pattern . .NET 4 Update 1 now supports it in the following class: System.Activities.Statements

How should one proceed to prove (or find) if two regular expressions are same or equivalent?

不羁的心 提交于 2019-11-29 09:30:01
问题 For example, in an assignment given to me, we were asked to find out if two regular expressions are equal or not. (a+b+c)* and ((ab)**c*)* My question is how is one supposed to do that? If I draw the transition graphs for both and then run a few strings through it and show that both of the TGs are able to accept it, is that a sufficient proof ? If not, how do I do it? Is there a mathematical/axiomatic approach towards this? Thanks in advance. EDIT: There is another thing that I'd like to

How are finite automata implemented in code?

最后都变了- 提交于 2019-11-29 03:43:05
How does one implement a dfa or an nfa for that matter in Python code? What are some good ways to do it in python? And are they ever used in real world projects? A straightforward way to represent a DFA is as a dictionary of dictionaries. For each state create a dictionary which is keyed by the letters of the alphabet and then a global dictionary which is keyed by the states. For example, the following DFA from the Wikipedia article on DFAs can be represented by a dictionary like this: dfa = {0:{'0':0, '1':1}, 1:{'0':2, '1':0}, 2:{'0':1, '1':2}} To "run" a dfa against an input string drawn

Graph drawing algorithms - I'm trying to render finite state automata

≯℡__Kan透↙ 提交于 2019-11-28 21:58:07
I want to write something that will draw finite state automata. Does anyone know any algorithms that are related to this? EDIT: I should mention that I know about graphviz. I want to build my own draw program/function, so what I'm looking for is some more theoretical stuff/pseudo-code for algorithms. AAA Graph drawing is a fairly complex subject due to the fact that different graphs need to be drawn in different ways - there is no one algorithm fits all approach. May I suggest the following resource: http://cs.brown.edu/people/rtamassi/papers/gd-tutorial/gd-constraints.pdf It should be a good

To use goto or not?

大城市里の小女人 提交于 2019-11-28 21:17:55
This question may sound cliched, but I am in a situation here. I am trying to implement a finite state automaton to parse a certain string in C. As I started writing the code, I realised the code may be more readable if I used labels to mark the different states and use goto to jump from one state to another as the case comes. Using the standard breaks and flag variables is quite cumbersome in this case and hard to keep track of the state. What approach is better? More than anything else I am worried it may leave a bad impression on my boss, as I am on an internship. Using a goto for

Does C# include finite state machines?

淺唱寂寞╮ 提交于 2019-11-28 16:00:18
问题 I've recently read about the boost::statechart library (finite state machines) and I loved the concept. Does C# have a similar mechanism ? Or can it be implemented using a specific design pattern? 回答1: Yes, C# has iterator blocks which are compiler-generated state machines. If you wish to implement you own state machine you can create custom implementations of the IEnumerable<T> and IEnumerator<T> interfaces. Both of these approaches highlight the .NET framework's implementation of the

To make sure: Pumping lemma for infinite regular languages only?

為{幸葍}努か 提交于 2019-11-28 09:22:25
So this is not about the pumping lemma and how it works, it's about a pre-condition. Everywhere in the net you can read, that regular languages must pass the pumping lemma, but noweher anybody talks about finite languages, which actually are a part of regular languages. So we might all aggree, that the following language is a finite language as well as it's a regular one, but it definitely does not pass the pumping lemma: L = {'abc', 'defghi'} Please, tell me if simply no one writes about it or why we're wrong - or even not. The reason that finite languages work with the pumping lemma is

How to use the intersection construction to form a DFA?

只谈情不闲聊 提交于 2019-11-28 04:09:28
I'm doing a homework assignment for my theory of computation class and am a bit confused how to combine 2 DFAs. The book says it uses the "intersection construction" to do so, but I'm not sure what that is. Here are 2 examples: The idea is pretty straightforward, although I can see where the confusion comes in. I will give a text/symbolic description of the process for making the intersection (union, difference) machines via the Cartesian Product Machine construction (same thing as you are talking about). A DFA is a 5-tuple (E, Q, q0, A, f) where E is the input alphabet, a non-empty finite set