Exploring Policyholder Behavior in the Extreme Tail Yuhong (Jason) Xue, FSA MAAA.
Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee...
-
date post
19-Dec-2015 -
Category
Documents
-
view
215 -
download
1
Transcript of Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee...
![Page 1: Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University.](https://reader037.fdocuments.us/reader037/viewer/2022110207/56649d3a5503460f94a149f5/html5/thumbnails/1.jpg)
Type System, March 12, 2002 - 1
Data Types and Behavioral Types
Yuhong XiongEdward A. Lee
Department of Electrical Engineering and Computer Sciences
University of California at Berkeley
![Page 2: Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University.](https://reader037.fdocuments.us/reader037/viewer/2022110207/56649d3a5503460f94a149f5/html5/thumbnails/2.jpg)
Type System, March 12, 2002 - 2
Component Interfacing
• Two levels of interface:– data types and– dynamic interaction: communication & execution
• Dynamic behavior defined by models of computation (MoC)
![Page 3: Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University.](https://reader037.fdocuments.us/reader037/viewer/2022110207/56649d3a5503460f94a149f5/html5/thumbnails/3.jpg)
Type System, March 12, 2002 - 3
Capturing Dynamic Behavior
• Dynamic behavior in each MoC can be described formally, using type systems
• Success of type systems:– Safety through type checking– Polymorphism supports reuse (flexible
components)– Type conversion– Program optimization– Interface documentation, clarification– Run-time reflection of component interfaces
![Page 4: Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University.](https://reader037.fdocuments.us/reader037/viewer/2022110207/56649d3a5503460f94a149f5/html5/thumbnails/4.jpg)
Type System, March 12, 2002 - 4
Data Types in Ptolemy II
• Lattice-based infrastructure
• Support polymorphism, type conversion, and structured types
General
String
ScalarBoolean
Complex
Double
Long
Int
Unknown
![Page 5: Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University.](https://reader037.fdocuments.us/reader037/viewer/2022110207/56649d3a5503460f94a149f5/html5/thumbnails/5.jpg)
Type System, March 12, 2002 - 5
Behavioral Type
• Data types only specify static aspects of interface
• Proposal:– Capture the dynamic interaction of
components in types– Obtain benefits analogous to data typing– Call the result behavioral types
![Page 6: Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University.](https://reader037.fdocuments.us/reader037/viewer/2022110207/56649d3a5503460f94a149f5/html5/thumbnails/6.jpg)
Type System, March 12, 2002 - 6
Interaction Semantics
• Flow of control issues – in Ptolemy II, these are defined by a Director class
• Communication between components– in Ptolemy II, this is defined by a Receiver class
produceractor
consumeractor
IOPort
Receiver
Director
Actor interface for execution: fireReceiver interface for communication: put, get, hasToken
![Page 7: Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University.](https://reader037.fdocuments.us/reader037/viewer/2022110207/56649d3a5503460f94a149f5/html5/thumbnails/7.jpg)
Type System, March 12, 2002 - 7
IOPort
FIFOQueue
1..1
1..1
«Interface»Receiver
+get() : Token+getContainer() : IOPort+hasRoom() : boolean+hasToken() : boolean+put(t : Token)+setContainer(port : IOPort)
0..1 0..n
QueueReceiver
NoRoomException
throws
NoTokenExceptionthrows
PNReceiver
«Interface»ProcessReceiver
CSPReceiver
SDFReceiver
ArrayFIFOQueue
1..11..1
DEReceiverMailbox
CTReceiver
Receiver Object Model
![Page 8: Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University.](https://reader037.fdocuments.us/reader037/viewer/2022110207/56649d3a5503460f94a149f5/html5/thumbnails/8.jpg)
Type System, March 12, 2002 - 8
Models of Computation
• Define the interaction semantics• Implemented in Ptolemy II by a domain
– Receiver + Director
• Examples:– Communicating Sequential Processes (CSP):
rendezvous-style communication– Process Networks (PN):
asynchronous communication– Synchronous Data Flow (SDF):
stream-based communication, statically scheduled– Discrete Event (DE):
event-based communication– Synchronous/Reactive (SR):
synchronous, fixed point semantics
![Page 9: Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University.](https://reader037.fdocuments.us/reader037/viewer/2022110207/56649d3a5503460f94a149f5/html5/thumbnails/9.jpg)
Type System, March 12, 2002 - 9
Formal Interaction Semantics:
Use Interface Automata• Based on interface automata
– Proposed by de Alfaro and Henzinger– Concise composition (vs. standard automata)– Alternating simulation provides contravariance
• Compatibility checking– Done by automata composition– Captures the notion “components can work together”
• Alternating simulation (from Q to P)– All input steps of P can be simulated by Q, and– All output steps of Q can be simulated by P.– Provides the ordering we need for subtyping &
polymorphism
• Key theorem about compatibility and alternating simulation
![Page 10: Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University.](https://reader037.fdocuments.us/reader037/viewer/2022110207/56649d3a5503460f94a149f5/html5/thumbnails/10.jpg)
Type System, March 12, 2002 - 10
Example: Synchronous Dataflow (SDF) Consumer Actor Type
Definition
fR Return from fire
g get
hT hasToken
f fire
t Token
hTT Return True from hasToken
hTF Return False from hasToken
Inputs:Outputs:
Such actors are passive, and assume that input is available when they fire.
executioninterface
communicationinterface
![Page 11: Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University.](https://reader037.fdocuments.us/reader037/viewer/2022110207/56649d3a5503460f94a149f5/html5/thumbnails/11.jpg)
Type System, March 12, 2002 - 11
Type Definition – Synchronous Dataflow (SDF)
Domain
produceractor
consumeractor
IOPort
Receiver
Directorreceiverinterface
directorinterface
![Page 12: Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University.](https://reader037.fdocuments.us/reader037/viewer/2022110207/56649d3a5503460f94a149f5/html5/thumbnails/12.jpg)
Type System, March 12, 2002 - 12
Type Checking – Compose SDF Consumer Actor with SDF Domain
ComposeSDF Domain SDF Consumer Actor
![Page 13: Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University.](https://reader037.fdocuments.us/reader037/viewer/2022110207/56649d3a5503460f94a149f5/html5/thumbnails/13.jpg)
Type System, March 12, 2002 - 13
Type Definition – SDF Consumer Actor in SDF
Domain
1. receives token from producer
interface toproducer actor
2. accept token
3. internal action: fire consumer
4. internal action: call get()
5. internal action: get token
6. internal action: return from fire
![Page 14: Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University.](https://reader037.fdocuments.us/reader037/viewer/2022110207/56649d3a5503460f94a149f5/html5/thumbnails/14.jpg)
Type System, March 12, 2002 - 14
Type Definition –Discrete Event (DE) Domain
This domain may fire actors without first providing inputs
![Page 15: Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University.](https://reader037.fdocuments.us/reader037/viewer/2022110207/56649d3a5503460f94a149f5/html5/thumbnails/15.jpg)
Type System, March 12, 2002 - 15
Recall Component BehaviorSDF Consumer Actor
1. is fired2. calls get()3. gets a token4. returns
![Page 16: Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University.](https://reader037.fdocuments.us/reader037/viewer/2022110207/56649d3a5503460f94a149f5/html5/thumbnails/16.jpg)
Type System, March 12, 2002 - 16
Type Checking – Compose SDF Consumer Actor with DE
Domain
• Empty automaton indicates incompatibility• Composition type has no behaviors
ComposeDE Domain SDF Consumer Actor
![Page 17: Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University.](https://reader037.fdocuments.us/reader037/viewer/2022110207/56649d3a5503460f94a149f5/html5/thumbnails/17.jpg)
Type System, March 12, 2002 - 17
Subtyping RelationAlternating Simulation: SDF
DE
SDF Domain DE Domain
![Page 18: Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University.](https://reader037.fdocuments.us/reader037/viewer/2022110207/56649d3a5503460f94a149f5/html5/thumbnails/18.jpg)
Type System, March 12, 2002 - 18
System-Level Type Lattice –Defined by Alternating
Simulation• Subtyping relation• Shown here for a few
Ptolemy II domains
If an actor is compatible with a certain type, it is also compatible with the subtypes
unknown
PN
SDF
DE
CSP
DP
discreteevents
synchronousdataflow
unknown
processnetworks
communicatingsequentialprocesses
domainpolymorphic
![Page 19: Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University.](https://reader037.fdocuments.us/reader037/viewer/2022110207/56649d3a5503460f94a149f5/html5/thumbnails/19.jpg)
Type System, March 12, 2002 - 19
Type Definition – Domain Polymorphic Consumer Actor
1. is fired 2. calls hasToken()
3. true
3. false
4. return
4. call get()
5. get token
6. return
This actor checks for token availability before attempting to get the token.
![Page 20: Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University.](https://reader037.fdocuments.us/reader037/viewer/2022110207/56649d3a5503460f94a149f5/html5/thumbnails/20.jpg)
Type System, March 12, 2002 - 20
Domain Polymorphic ActorComposes with the DE
Domain
ComposeDE Domain Poly Actor
![Page 21: Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University.](https://reader037.fdocuments.us/reader037/viewer/2022110207/56649d3a5503460f94a149f5/html5/thumbnails/21.jpg)
Type System, March 12, 2002 - 21
Domain Polymorphic Actor Also
Composes with the SDF Domain
ComposePoly ActorSDF Domain
![Page 22: Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University.](https://reader037.fdocuments.us/reader037/viewer/2022110207/56649d3a5503460f94a149f5/html5/thumbnails/22.jpg)
Type System, March 12, 2002 - 22
Conclusion• Data types
– Lattice-based infrastructure– Support polymorphism, type conversion,
and structured types
• Behavioral types– Formally captures the structure of MoCs– Describe interaction types and component
behavior using interface automata– Perform type checking through automata
composition– Subtyping order is given by the alternating
simulation relation, supporting polymorphism