State Machines and User Interface work — any examples/experience?

I’m currently working with a (proprietary) framework that lends itself well to the UI-as-state-machine paradigm, and it can definitely reduce (but not eliminate) the problems with complex and unforeseen interactions between UI elements. The main benefit is that it allows you to think at a higher level of abstraction, at a higher granularity. Instead of … Read more

DFA vs NFA engines: What is the difference in their capabilities and limitations?

Deterministic Finite Automatons (DFAs) and Nondeterministic Finite Automatons (NFAs) have exactly the same capabilities and limitations. The only difference is notational convenience. A finite automaton is a processor that has states and reads input, each input character potentially setting it into another state. For example, a state might be “just read two Cs in a … Read more

Practical non-Turing-complete languages?

Don’t listen to the naysayers. There are very good reasons one might prefer a non-Turing complete language in some contexts, if you want to guarantee termination, or simplify code, for example by removing the possibility of runtime errors. Sometimes, just ignoring things may not be sufficient. The paper Total Functional Programming argues more or less … Read more

What is a finite state transducer?

A finite state transducer (FST) is a finite state automaton (FSA, FA) which produces output as well as reading input, which means it is useful for parsing (while a “bare” FSA can only be used for recognizing, i.e. pattern matching). An FST consists of a finite number of states which are linked by transitions labeled … Read more

How useful is Turing completeness? are neural nets turing complete?

The point of stating that a mathematical model is Turing Complete is to reveal the capability of the model to perform any calculation, given a sufficient amount of resources (i.e. infinite), not to show whether a specific implementation of a model does have those resources. Non-Turing complete models would not be able to handle a … Read more

Is there a typical state machine implementation pattern?

I prefer to use a table driven approach for most state machines: typedef enum { STATE_INITIAL, STATE_FOO, STATE_BAR, NUM_STATES } state_t; typedef struct instance_data instance_data_t; typedef state_t state_func_t( instance_data_t *data ); state_t do_state_initial( instance_data_t *data ); state_t do_state_foo( instance_data_t *data ); state_t do_state_bar( instance_data_t *data ); state_func_t* const state_table[ NUM_STATES ] = { do_state_initial, do_state_foo, … Read more

Can regular expressions be used to match nested patterns? [duplicate]

No. It’s that easy. A finite automaton (which is the data structure underlying a regular expression) does not have memory apart from the state it’s in, and if you have arbitrarily deep nesting, you need an arbitrarily large automaton, which collides with the notion of a finite automaton. You can match nested/paired elements up to … Read more