DISCRETE MATHEMATICS Lecture 22 - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

DISCRETE MATHEMATICS Lecture 22

Description:

Now, how can we model the computer itself, and what it is doing when it carries ... Elevator, vending machine, car-building robot. Compilers, interpreters ... – PowerPoint PPT presentation

Number of Views:35
Avg rating:3.0/5.0
Slides: 21
Provided by: Kem
Category:

less

Transcript and Presenter's Notes

Title: DISCRETE MATHEMATICS Lecture 22


1
DISCRETE MATHEMATICSLecture 22
  • Dr. Kemal Akkaya
  • Department of Computer Science

2
Modeling Computation
  • We learned earlier the concept of an algorithm.
  • A description of a computational procedure.
  • Now, how can we model the computer itself, and
    what it is doing when it carries out an
    algorithm?
  • For this, we want to model the abstract process
    of computation itself.

3
Early Models of Computation
  • Recursive Function Theory
  • Kleene, Church, Turing, Post, 1930s
  • Turing Machines Turing, 1940s
  • RAM Machines von Neumann, 1940s
  • Cellular Automata von Neumann, 1950s
  • Finite-state machines, pushdown automata
  • various people, 1950s
  • VLSI models 1970s
  • Parallel RAMs, etc. 1980s

4
Turing Finite State Machines
  • Any algorithm can be implemented in a Turing
    machine
  • Alan Turing
  • Topic of Theory of Computation Programming
    Languages
  • We will give definition of Turing machines
  • Finite State machines with external memory
  • And briefly look at Finite State Machines

5
Turing Machines (TM)
  • Alan M. Turing (19121954)
  • In 1936, Turing introduced hisabstract model
    for computation inhis article On Computable
    Numbers, with an
  • application to the Entscheidungsproblem.
  • At the same time, Alonzo Church published
    similar ideas and results.
  • However, the Turing model has become
    thestandard model in theoretical computer
    science.

6
Informal Description TM
At every step, the head of the TM M reads a
letter xi from the one-way infinite tape.
Depending on its state and the letter xi, the TM
- writes down a letter, - moves its read/write
head left or right, and - jumps to a new state.
7
Motivation to use Finite State Machines
  • Many applications of FSMs
  • Control systems of all sorts
  • GUI interaction model
  • Elevator, vending machine, car-building robot
  • Compilers, interpreters
  • Simple parsers for languages
  • Let M be a FSM. We say that M accepts a language
    L (of finite strings from Ms input alphabet S)
    if and only if
  • For all t in L, FSM on t ends in a final state
  • For all t not in L, FSM on t does not end in a
    final state

8
12.2 - What is a Finite State Machine?
  • Lets define the idea of a machine
  • organism (real or synthetic) that responds to a
    countable (finite) set of stimuli (events) by
    generating predictable responses (outputs) based
    on a history of prior events (current state).
  • A finite state machine (fsm) is a computational
    model of a machine with primitive memory
  • Similar to Combinational Circuits
  • But this time their output also depend on state
  • Input is provided
  • Base on the state an output is given
  • Any circuit with memory is a FSM
  • Serial adder example

9
Serial Adder
  • Gets inputs as bits
  • The state here is
  • Having a carry bit
  • If there is a carry, add it to the sum
  • Otherwise do nothing
  • So INPUT STATE determine together the OUPUT

10
Serial Adder FSM
11
Elements of a FSM
  • States represent the particular configurations
    that our machine can assume.
  • Events define the various inputs that a machine
    will recognize
  • Transitions represent a change of state from a
    current state to another (possibly the same)
    state that is dependent upon a specific event.
  • The Start State is the state of the machine
    before it has received any events

12
Size of FSMs
  • The information capacity of an FSM is C log
    S.
  • Thus, if we represent a machine having an
    information capacity of C bits as an FSM, then
    its state transition graph will have S 2C
    nodes.
  • Computers can be viewed as huge FSMs
  • E.g. suppose your desktop computer has a 512MB
    memory, and 60GB hard drive.
  • Its information capacity, including the hard
    drive and memory (and ignoring the CPUs internal
    state), is then roughly 512223 60233
    519,691,042,816 b.
  • How many states would be needed to write out the
    machines entire transition function graph?

2519,691,042,816 A number having gt1.7 trillion
decimal digits!
13
One Problem with FSMs as Models
  • The FSM diagram of a reasonably-sized computer is
    more than astronomically huge.
  • Yet, we are able to design and build these
    computers using only a modest amount of
    industrial resources.
  • Why is this possible?
  • Answer A real computer has regularities in its
    transition function that are not captured if we
    just write out its FSM transition function
    explicitly.
  • i.e., a transition function can have a small,
    simple, regular description, even if its domain
    is enormous.

14
Vending Machine Example
  • Suppose a certain vending machine accepts
    nickels, dimes, and quarters.
  • If gt30 is deposited, change isimmediately
    returned.
  • If the coke button is pressed,the machine
    drops a coke.
  • Can then accept a new payment.

Ignore any otherbuttons, bills,out of
change,etc.
15
Modeling the Machine
  • Input symbol set I nickel, dime, quarter,
    button
  • We could add nothing or ? as an additional
    input symbol if we want.
  • Representing no input at a given time.
  • Output symbol set O ?, 5, 10, 15, 20,
    25, coke.
  • State set S 0, 5, 10, 15, 20, 25, 30.
  • Representing how much money has been taken.

16
Transition Function Table
17
Transition Function Table cont.
18
Another Format State Table
Each entryshowsnew state,output symbol
19
Directed-Graph State Diagram
  • As you can see, these can get kind of busy.

q,5
d,5
q
q
q,20
d
d
d
n
n
n
n
n
n
0
5
10
15
20
25
30
n,5
b
b
b
b
b
b
d,10
q,25
q,15
b,coke
q,10
20
Formalizing FSMs
  • Just like the general transition-function
    definition from earlier, but with the output
    function separated from the transition function,
    and with the various sets added in, along with an
    initial state.
  • A finite-state machine M(S, I, O, f, g, s0)
  • S is the state set.
  • I is the alphabet (vocabulary) of input symbols
  • O is the alphabet (vocab.) of output symbols
  • f is the state transition function
  • g is the output function
  • s0 is the initial state.
  • Our transition function from before is T (f,g).
Write a Comment
User Comments (0)
About PowerShow.com