Ӧо
APPLICATION RESEARCH OF COMPUTERS
2000Vol.17No.5P.15-17



һֲϵͳĹԼ
ͮ
ժ Ҫ˲ϵͳһֹԼһڶԲϵͳнģͶģ͵֤ʽ뵽һֶάĹԼУʹʽ߸ӦõĿС⣬һֲϵͳʽģ͡
ؼʡϵͳʽԼģʽUnity߼
1 
ʽԣѧҶΪоҪ塣ʵʵи෽ЧشģϵͳĿ[7]θЧʹʽ½顣
ǿʽģͺضӦʽ
ӦʽΪĻ
ӦעʹôȵϼҪʹϸȵġķ ڱУǲһֶάԼϵͳöάһͼλʾһʵϵͳĽṹΪͬʱһʽʱ߼֤ϵͳĹܺʡֱʾںһŵ㡣
ʹòͬıʾһϵͳĲͬ棻
ڿпԲͬϵͳģͣ
÷һõۻ(ʽʱ߼)ڼ̳ʹеĹߡ
1.1 ģʽ
ΪʽԼǲ[2]ģʽĸ÷һģʽ(Object-oriented pattern)һϵо໥ϵĶļϣضĹܺͽӿڡĳһеĸ(ָԼ)ĹϵԼγһġϸϵͳ
1.2 һֻ󾫵Ŀ
һϵͳһϵ໥õģ飬ЩģضͬϵģͬһַռнôӶϵͳܡĳһģԣܾһϵͳܾһϵ໥õģļϣһжϵԭӳԭӳпɰ˳ѭƽṹ
ϵļģͣϵͳĿ̿ɾطΪ裺󾫽׶κͳ󾫽׶Ρ󾫽׶ΣǽһʼSΪһǿʼTTS塢ʵ֡󾫹ҪϵͳֽΪһĲģ飬Щģ齻һҪʵֵSʣÿһģʵַԼTһʡڷֽĹӦøģĽΪƣֽõĵһϵͳҪ֤һϵͳеʡ󾫹һֱУֱõһģģеϵͳģ͡ŶԵõĳϵͳģͽг󾫣󾫵Ŀĳֱھļϵʵָóģ͡󾫱뱣֤õĸģȫʵӦĳģʹԼ󾫹ǹĵ(߼)ȷԱ֤ڳ󾫽׶Ҫ֤ȷ﷨()ʵ֡ڱֻ۶ʵ󾫡
2 Unity߼
UnityһԼ֤ϵͳ۰Ҫ֣һּ򵥵ıдһ߼ʾʣһ֤ϵͳ֤ضʡͨأһUnityֹɣDeclareóõıInitiallyֵAssignһǿոֵ伯
ôͳUnity߼ԼϵͳӦķ档һǸ߼ȱٿUnityһظֵɵļϣڳڲڲϵûͨ˳е˳ѭƽṹUnity߼ļһϸȵĲϵͳһصʹø߼Լ֤Чش͸ϵͳ˱УǽµUnityӶõһֲϵͳʽģԼϵͳǵĹ¡
UnityΪģ鼶
ģƽṹ
2.1 ϵͳʽģ
1ϵͳĳģԪsys=(Vp,Vs, Is, S)Vpʾ޸˽бԪɵ࣬˽бԪ࣬Ԫغ͹̶Ĳģأģдʣ
Vsʾ޸ԪɵļƹԪԪһģдʣ
IsƱʼ̣ϵͳвֹԪֵIsϵͳǰִһΣ
Sʾ޸ģɵļϣƲģ鼯ǲϵͳĺĲ֡
2ģʽԼԪ mod=(Vmod, Imod, ENB, FB)
Vmodģ˽бԪVmodǿռ
ImodǸģĳʼ̣VmodеıԪÿʱĳֵ
ENBVsϵ߼νʣƸģĴҪòģӦϵͳ״̬
FBVsVmodϵ߼νʣƸģһִʱĺԣʾģһִʱϵͳ״̬
ע⣬ģʱڿִɵԭģ飬ִйбжϡһϵͳģsysн(򵽴ﲻ)ҽsysе״̬ڸ״̬sys.SеһģmodENBΪ١
2.2 ʱ
һϵͳģͶԣͨҪʣȫԣҪϵͳйжΪ棻չԣҪϵͳн(򵽴ﲻ)ʱΪ档UnityҪ߼unlessensuresleads-toǰһﰲȫԵģչԵġʱǶǰϵͳģ͸ӦĶ塣
2.2.1 unless'
һϵͳģsys, p unless' qָһνpΪ棬pһֱΪֱνqΪ档

2.2.2  ensures'
һϵͳģsysp ensures' qָp unless' qԸϵͳͬʱνpһģִǰΪڸģִнʱqΪ档

2.2.3  leads-to'
һϵͳģͣp leads-to' qָνpΪ棬ܵνqΪ档leads-to'ensures'ͬqΪǰνpΪҲΪ١

3  ϵͳĶάԼ
άϵͳԼһͼιԼߣϵͳΪͽṹһʽԼߣϵͳĹܺʡͼ1ʾ÷߸
ͼαʾߣԼϵͳΪṹͼιԼߡǵĹԼУ״̬ͼΪͼιԼϵͳΪͽṹ״̬ͼ(State Chart)һֳõͼλϵͳʾ֮ѡΪ״̬ͼԱͼλʽӳ󵽾Ĺɡ
߼ʾߣԼϵͳģ͡ʵʽԼߡʽĹԼ߾ʹϵͳģͼ֤
ϵͳ״̬ͼʾͼιԼ߱ʾĳһӦϵͳΪṹͼʾ
ϵͳģͣʽԼ߱ʾĳһӦϵͳʽģ͡
ϵͳʣʽԼ߱ʾĳһӦϵͳӦ߼νʡϵͳʰ⡢νʺʱ߼νʡ
ӳϵĳһ岢ϵͳ״̬ͼʾʽϵͳģ֮ĶӦϵ
֤:֤ĳһ岢ϵͳĳģҪʡõ߼ϵͳֳɵĻ֤ϵͳָ˹֤

ͼ1һֲϵͳĹԼ
ͼ1ϵʾͼαʾߺ߼ʾߣڷһ϶õĹԼ߽мʾϵͳ״̬ͼʾģͺʣĳһӦϵͳʹ๤߷ֱʾΪͼʾģͺʣµʾĳһӦϵͳΪͼʾģͺ֮Ĺϵ
4  Լʽʾ
ͨģʽϵĹԼģʽв[2]Gammaȵıʾ
4.1  ģʽ1DiagramSpec(ͼιԼ)
ͼαʾࣺ  
class: DiagramNotation  
attributes:
atomic-elements: P Token
compound-elements: P Token
start-element: Token
structural-rules:
P(compound-elementsP(atomic-elementscompound -element))
operations:
restrictions: 'the start-element must be a compound element'.
״̬ͼ
object: StateChart instance-of Diagram- Notation
attributes:
atomic-elements: { initial-state, trigger, effect };
compound-elements:{system,actiondiagram,class, entity }
start-element: system
structure-rules: {system?actiondiagram
actiondiagramP class ( P entity
entityinitial-state ( P action,
actiontrigger( effect;...}
˵ 
systemԼϵͳ
actiondiagramϵͳ״̬ͼʾʵΪ֮Ĺϵ
classϵͳĳʵĳʾ;
entityϵͳоʵʵ;
initial-state: ϵͳиʵĳʼ״̬
actionʵһΪ;
triggerʾactionĴ;
effectactionΪ
4.2  Pattern 2: LogicSpec (߼Լ)
߼ʾࣺ
classLogicNotation
attributers:
atomic-elements: P Token
compound-elements: P Token  
structural-rules:
P (compound-elementsP (atomic-elements(compound-elements))
operators: P Token
theorems: P rewriting-rule
operations:
restrictions:
ϵͳģͣ
object: Abstractmodel instance of LogicNotation
attributes:
atomic-elements: {truth-value, variable, constant}
compound-elements: {system-model, module, ENB, FP, predicate, 
  quantified-predicate,  proposition, relation-expression}structural-rules: {system-modelP module, modelENB(FP, ENBP predicate, FPP predicate, predicatepropositionquantified-predicate, propositionrelation-expression, relation-expression(variable(constant)(operators((variable(constant),..}
operators:{+,(,relation-operators(<,,>,,=), logical-connectives quantifiers (, ), temporal-operator (unless', stable', invariant', ensures' andleads-to') }
Theorems: {Է, Է, Ƶ, ȡ, ȡ, PSP, etc...}
˵
system-modelϵͳĳģͣ
moduleͨENBFPϵͳиģΪԼ
predicateϵͳģΪƵ߼ʾ
quantified predicate ȫʻʵνʣ
proposition()һʵ߼
relation-expression(ϵʽ):֮Ĺϵ
true value(ֵ)truefalse
operatorsϵ(relation-operators)ν߼
(logic-connectives)ʱ߼(temporal-operators)
5   
һֶԪĲϵͳԼͼλߺʽ߽ܵĽһʹ÷ܸõӦõʵʵĿС
ĿʡȻѧ(98F005G)
ʡƼͷ(1998-37)
(ϴѧѧϵ  650091)
ͮ(ϴѧѧϵ  650091)
ο
1Mary Shaw, David Garlan. Software Architecture: Perspectives of an Emerging Discipline. Prentice-Hall, 1996
2Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides. Design Patterns: Elements of Reusable Object-oriented Software. Addison-Wesley, 1995
3R. Wirfs-Brock. Object-oriented Frameworks. American Programmer 4 (10) (1988)
4K. M. Chandy and J. Misra. Parallel Program Design: A Foundation. Reading, MA: Addison-Wesley, 1998
5Ying Liu, Ambuj K. Singh, and Rajive L. Bagrodia. A Decompositional Approach to the Design of Parallel Programs. IEEE Transitions on Software Engineering, Vol. 20, No. 12, 1994
6Boutheina Chetali. Formal Verification of Concurrent Programs Using the Larch Prover. IEEE Transaction on Software Engineering, Vol. 24, No. 1, 1998
7Lu Qi, Joseph Goguen. Formal Methods: Promises and Problems. IEEE Software 1997
8Colin Fidge, Peter Kearney, Mark Utting. A Formal Method for Building Concurrent Real-Time Software. IEEE Software 1997
9Bo Sanden. Modeling Concurrent Software. IEEE Software 1997
10磬 Դ. г. ϺϺƼ׳, 1994
ոڣ1999-10-3
