Search code examples
finite-automata

How to represent a coffee machine using DFA?


I want to know how to represent a coffee machine using a Deterministic finite automata?

I've tried a lot to do this job. I represented each and every processes as a set,by putting one to one correspondence with Natural numbers. But I still don't know how to represent it using DFA.


Solution

  • First, try to imagine the states your automaton can be in. Something like:

    Off, Ready, Working
    

    Afterwards imagine the buttons or inputs you have to perform to switch between these states. Do not forget to define every input on every state. If you leave out several transitions, the automaton is not deterministic therefore is an NFA. Transitions could be:

    0 for power off/on
    1 for start/stop working
    
    Off -0-> Ready
    Ready -1-> Working
    Ready -0-> Off
    Working -1-> Ready  (4 for the actual working process)
    
    Off -1-> Off
    Working -0-> Working (nothing happens in this cases)
    

    Just connect the states with the given transitions, and voilá!