![]() attr ( style = 'filled', color = 'lightgrey' ) c. subgraph ( name = 'cluster_0' ) as c : c. """""" from graphviz import Digraph g = Digraph ( 'G', filename = 'cluster.gv' ) # NOTE: the subgraph name needs to begin with 'cluster' (all lowercase) # so that Graphviz recognizes it as a special cluster subgraph with g. attr ( 'node', shape = 'doublecircle' ) f. attr ( rankdir = 'LR', size = '8,5' ) f. Digraph ( 'finite_state_machine', filename = 'fsm.gv' ) f. It's consistent, which makes it easier to use for describing behaviors."""""" import graphviz f = graphviz. States in a state machine are just variables. For the simple python program above, there are "hidden" states like heap, stack, program counter, etc. It's just that states in a program are much harder to manage and describe because they are represented differently. Python (replace with your favorite language) can also be used to describe program behaviors. It's a spec and it just specifies the state transitions for this state machine. And in fact it's not a program that you run at all. You should not read this like python which executes the program from top to bottom. The state machine describing its behavior would look something like: if pc = start: We can describe this program behavior as a state machine of two variables: a and pc (stands for program counter). Let's look at the following tiny example: a = get_random_number() State machine is very flexible and easy-to-use at describing system behaviors. Behaviors can be described in programming languages, but they are often too concrete. So naturally, a state machine is sufficient to describe anything computable. And Turing Machine can be described as a state machine. View every system as a state machineĪnything computable can be done by the Turing Machine. Computer, physically, is nothing more than a storage of various states, and combinational logic based on all the states (Program Counter, register values, RAM, Carry Flag, etc.) for state transition. So any algorithm, program, distributed system, the most complicated system interaction you can ever imagine, can be described as a state machine, which can be implemented by a Turing Machine. What is a Turing Machineīen Eater has a very good video explaining Turing Machine. And Turing Machine describes and defines all possible behaviors of all computers in the world. You might have guessed it already, a computer is a Turing Machine. But instead, describe and define a computer by what it can do. Maybe we should not look at the physical presence of a computer. But this certainly doesn't describe all computers of different architectures. Is computer a set of transistors wired up in a very specific way? This can describe computers of certain architecture, maybe e.g. If I just throw a billion transistors in a trash can, the trash can is not a computer. But this certainly doesn't describe all computers. Is computer the thing on your desk right now with billions of transistors? Well, that describes the computer on your desk, or more generally a class of computers of this kind. ![]() We are surrounded by computers nowadays (smart phones, laptops, game consoles, smart speaker, smart home devices, etc.). ![]() Most likely you are reading this post on your computer as well (or smartphone, which is also a computer). I am writing this post on my computer, which has 32 GB of RAM and 8 2.4 GHz cores. What is a computerįirst, let's take a look at a very philosophical question - "what is a computer?". This is the first post of a series of posts I plan to make about TLA+.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |