Algebraic Example OBJ3.ppt
《Algebraic Example OBJ3.ppt》由会员分享,可在线阅读,更多相关《Algebraic Example OBJ3.ppt(21页珍藏版)》请在麦多课文档分享上搜索。
1、10/19/2000,cs599 - Formal Methods in Software Architecture,1,Algebraic Example OBJ3,Tarang Garg Srikumar Nagaraj,10/19/2000,cs599 - Formal Methods in Software Architecture,2,OBJ3 - Revision,“ OBJ3 is a wide spectrum first order functional language that is rigorously based upon equational logic.”Base
2、d on order sorted equational logic Provides notion of Subsort that rigorously supports multiple inheritance Exception handling and Overloading It is a theorem prover It gives powerful support for design and verification,10/19/2000,cs599 - Formal Methods in Software Architecture,3,Cruise Control,“ Th
3、e objects are identified by the Nouns in the specification and the interaction between the objects are identified by the Verbs.”Objects :Vehicle (not a required object for specs)brakeaccelerator pedal CC(cruise control) button On /OffCC button Set/Accelerator CC button Resume/Decelerator,10/19/2000,
4、cs599 - Formal Methods in Software Architecture,4,Cruise Control,Assumptions: * 1. If cruise-speed = 0 then the car is not cruisingand if cruise-speed 0 then the car is cruising. 2. cruise_state represents the button. 3. Max. allowed speed is 140 mph. 4. The car does not take any time to change spee
5、ds. * th CAR-STATE is sort INT . protecting INT .protecting TRUTH-VALUE . op init1_ : INT INT .op init2_ : TRUTH-VALUE TRUTH-VALUE .vars curr_speed cruise_speed last_cruise_speed : INT .var cruise_state : TRUTH-VALUE . eq init1 curr_speed = 0 .eq init1 cruise_speed = 0 . eq init1 last_cruise_speed =
6、 0 .eq init2 cruise_state = false . endth,10/19/2000,cs599 - Formal Methods in Software Architecture,5,Cruise Control,obj CC-ON-OFFV-CAR-STATE : CAR-STATE .protecting TRUTH-VALUE .op cruise-press_ : TRUTH-VALUE TRUTH-VALUE .var I : TRUTH-VALUE .cq cruise-press (cruise_state) = (I = false) * This che
7、cks for the cruise control button if it is ONif cruise-state = true .eq cruise-state = I .cq cruise-press (cruise-state) = (I = false) and (last-cruise-speed = 0) * This checks for the cruise control button if it is OFFif cruise-state = false . endo,10/19/2000,cs599 - Formal Methods in Software Arch
8、itecture,6,Cruise Control,obj CC-SET-ACCELERATEV-CAR-STATE : CAR-STATE .protecting INT .protecting TRUTH-VALUE .op button-press_ _ _ : INT INT TRUTH-VALUE INT INT INT .op button-press_ _ : INT TRUTH-VALUE INT INT .op time_ : INT INT .vars X Y : INT .cq button-press (cruise-speed , curr-speed , cruis
9、e-state) = (cruise-speed = curr-speed) and (last-cruise-speed = cruise-speed) if (cruise-state = true) and (curr-speed 30)and (curr-speed 30) and (cruise_speed 90) .eq time X = Y . endo* Assumption: Time is a function which takes time in seconds(X) for which SET is pressed & gives * the speed factor
10、(Y) to add to cruise-speed.,10/19/2000,cs599 - Formal Methods in Software Architecture,7,Cruise Control,obj CC-RESUME-DECELERATEV-CAR-STATE : CAR-STATE .protecting INT .protecting TRUTH-VALUE .op button-press_ _ _ _ : INT INT INT TRUTH-VALUE INT INT op button-press_ _ : INT TRUTH-VALUE INT INT . op
11、time_ : INT INT .vars X Y : INT .cq button-press (cruise-speed , curr-speed , last-cruise-speed, cruise-state) = (cruise-speed = last-cruise-speed) if (cruise-state = true) and (curr-speed 30) and (curr-speed 90)and (cruise-speed = 0) and (last-cruise-speed =/= 0) .cq button-press (cruise-speed , cr
12、uise-state) = (cruise-speed = cruise-speed Y ) and (last-cruise-speed = cruise-speed)if (cruise-state = true) and (cruise-speed =/= 0) .eq time X = Y . endo *Assumption: Time is a function which takes time in seconds(X) for which RESUME is * pressed and gives the speed factor(Y) to subtract to cruis
13、e-speed.,10/19/2000,cs599 - Formal Methods in Software Architecture,8,Cruise Control,obj ACCELERATOR-PEDALV-CAR-STATE : CAR-STATE . protecting INT .op pedal-press_ _ : INT INT INT .op time_ : INT INT .op uphill _ _ : INT INT INT .vars X Y : INT .cq pedal-press (curr-speed , cruise-speed) = (curr-spe
14、ed = curr-speed + Y)if (cruise-speed = 0) and (curr-speed 140) .eq time X = Y . cq uphill (curr-speed, cruise-speed) = ( curr-speed = curr-speed + Z) and (cruise-speed = curr-speed)if (cruise-speed =/= 0) and (current-speed cruise-speed) . endo * Assumption: Time is an operation which takes time in
15、seconds(X) for which pedal is * pressed and returns the factor(Y) by which the speed is to be increased. * Z is a factor which gives the drop in the speed when the car goes uphill,10/19/2000,cs599 - Formal Methods in Software Architecture,9,Cruise Control,obj BRAKE-PEDALV-CAR-STATE : CAR-STATE .prot
16、ecting INT .op pedal-press_ _ : INT INT INT .op pedal-press_ : INT INT INT INT .op time_ : INT INT .op downhill _ _ : INT INT INT .vars X Y : INT .cq pedal-press (curr-speed , cruise-speed) = (curr-speed = curr-speed X)if (cruise-speed = 0) and (curr-speed 0) .cq pedal-press (cruise-speed) = (cruise
17、-speed = 0) and (last-cruise-speed = 0)if (cruise-speed =/= 0) .eq time X = Y . eq downhill (curr-speed, cruise-speed) = ( curr-speed = curr-speed - Z) and (cruise-speed = curr-speed)if (cruise-speed =/= 0) and (current-speed cruise-speed) . endo * Assumption: Time is an operation which takes time f
18、or which the pedal is pressed and * returns the factor by which the speed is decreased. * Z is the factor which gives the increase in the speed when the car goes downhill,10/19/2000,cs599 - Formal Methods in Software Architecture,10,Gas Station,Assumptions * 1. When the customer goes to the cashier
19、& pays cash, the cashier allots a pump no. & a password to the customer. 2. Pump has one nozzle and three buttons for premium, plus & regular. 3. type-of-gas has integer values viz. plus 1 $1.90 per gallonregular 2 $ 1.80 per gallonpremium 3 $ 2.00 per gallon * Objects:pumpnozzlecustomercashiercar (
20、unnecessary)Gas tank car tank (unnecessary)sensor meter on the pump (unnecessary),10/19/2000,cs599 - Formal Methods in Software Architecture,11,Gas Station,th PASSWORD is sort INT .protecting INT .protecting TRUTH-VALUE .op init1_ : TRUTH-VALUE TRUTH-VALUE .op init2_ : INT INT .var enable-pump : TRU
21、TH-VALUE .vars pump-password-value customer-password-value : INT .eq init1 enable-pump = false .eq init2 pump-password-value = 0 .eq init2 customer-password-value = 0 . endth th TANK-STATES is sort INT .protecting INT .op init1_ : INT INT .vars amount-gas-car-tank amount-gas-station-tank : INT .eq i
22、nit1 amount-gas-car-tank = 0 .eq init1 amount-gas-station-tank threshold . endth * Assumption: threshold is some integer value which is pre-defined for the tank. * Initially we are assuming that the gas in the GAS STATION TANK is greater than threshold.,10/19/2000,cs599 - Formal Methods in Software
23、Architecture,12,Gas Station,th GAS-STATE is sort INT .protecting INT .protecting FLOAT .protecting TRUTH-VALUE .op init1_ : TRUTH-VALUE TRUTH-VALUE .op init2_ : INT INT .vars nozzle-up lever-press : TRUTH-VALUE .var type-of-gas amount-gas-dispensed : INT .var amount-charged : FLOAT .eq init1 nozzle-
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- ALGEBRAICEXAMPLEOBJ3PPT
