6.01 Lecture Notes - Lecture 16: Principle Of Compositionality, Ernest Webnje Nfor, Linear Time-Invariant Theory

5 views11 pages

Document Summary

Recall that we have de ned a python class sm. sm to represent state machines. Here we consider a special type of state machine, whose states are always integers that start at 0 and increment by 1 on each transition. We can represent this new type of state machines as a python subclass of sm. sm called countingstatemachine. Here is an example of a subclass of countingstatemachine. class countmod5(countingstatemachine): def getoutput(self, state, inp): return state % 5. Instances of countmod5 generate output sequences of the form 0, 1, 2, 3, 4, 0, 1, 2, 3, Since countingstatemachine is a subclass of sm. sm, you will have to provide de nitions of the startstate instance variable and getnextvalues method, just as we have done for other state machines. Countingstatemachine will provide an appropriate getoutput method. class countingstatemachine(sm. sm): def __init__(self): self. startstate = 0 def getnextvalues(self, state, inp): return(state + 1, self. getoutput(state, inp))

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents

Related Questions