ebook img

Modeling Hybrid Systems in the Concurrent Constraint Paradigm PDF

0.15 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Modeling Hybrid Systems in the Concurrent Constraint Paradigm

Modeling Hybrid Systems in the Concurrent Constraint Paradigm Damia´nAdalid Mar´ıadel MarGallardo LauraTitolo Dept.LenguajesyCienciasdelaComputacio´n ∗ E.T.S.I.Informa´tica UniversityofMa´laga [damian,gallardo,laura.titolo]@lcc.uma.es Hybrid systems, which combine discrete and continuous dynamics, require quality modeling lan- guagestobeeitherdescribedoranalyzed. TheConcurrentConstraintparadigm(ccp)isanexpres- sive declarative paradigm, characterized by the use of a common constraint store to communicate andsynchronizeconcurrentagents. In this paradigm,the informationis stated in the formof con- straints,incontrasttothevariable/valuestyletypicalofimperativelanguages. Severalextensionsof ccp have been proposedin order to modelreactive systems. One of these extensionsis the Timed ConcurrentConstraintLanguage(tccp)thataddstoccpanotionofdiscretetimeandnewfeaturesto modeltime-outandpreemptionactions. Thegoalofthispaperistoexploretheexpressivepoweroftccptodescribehybridsystems. We introducethelanguageHy-tccpasaconservativeextensionoftccp,byaddinganotionofcontinuous time andnew constructsto describe the continuousdynamicsof hybridsystems. In this paper, we presentthesyntaxandtheoperationalsemanticsofHy-tccptogetherwithsomeexamplesthatshow theexpressivepowerofournewlanguage. 1 Introduction Inthelastyears,concurrent, reactiveandhybridsystemshavebecomeessentialtomodelalargenumber ofmodernapplications. Often,systemsofthiskindareclassifiedascritical,i.e.,anerrorinthesoftware canhavetragicconsequencesintermsofhumanlivesormoney. Thisisthecaseofavionicorautomotive software, e-banking, orfinancialapplications. Description, verification and analysis of concurrent and reactive systems are very hard tasks, due to the concurrent execution of different agents and to issues of synchronization. In the case of hybrid systems, these phases are even harder due to the combination of discrete and continuous dynamics and the presence of real-valued variables. Therefore, it is important to develop high-level description lan- guages thatallowthese systemstobemodeledwithenough precision andatthesametimethateasethe application offormalmethodstechniques. Many formalisms have been developed to describe concurrent systems. One of these is the Con- current Constraint paradigm (ccp) [10], a simple but powerful model for concurrent systems. It differs from other paradigms mainly due to the notion of store-as-constraint that replaces the classical store- as-valuation model. In this paradigm, the agents running in parallel communicate by means of aglobal constraintstore. TheTimedConcurrentConstraintLanguage[2](tccpinshort)isaconcurrentlogiclan- guage obtained by extending ccp with the notion of time and a suitable mechanism to model time-outs andpreemptions. ∗ ThisworkhasbeensupportedbytheAndalusianExcellenceProjectP11-TIC7659andtheSpanishMinistryofEconomy andCompetitivenessprojectTIN2012-35669 S.Escobar(Ed.):XIVJornadassobreProgramacio´n ©Adalid,Gallardo&Titolo yLenguajes,PROLE2014,RevisedSelectedPapers Thisworkislicensedunderthe EPTCS173,2015,pp.1–15,doi:10.4204/EPTCS.173.1 CreativeCommonsAttributionLicense. 2 ModelingHybridSystemsintheConcurrentConstraintParadigm In this paper, we present the language Hy-tccp: an extension of tccp over continuous time. Hy- tccpisanon-deterministic andsynchronous language thatincorporates continuous variables thatfollow dynamicsdeterminedbyanordinarydifferentialequation(ODE).Itsdeclarativenaturefacilitates ahigh level description of hybrid systems in the style of hybrid automata [8]. Furthermore, its logical nature facilitates thedevelopmentofsemanticsbasedprogrammanipulation toolsforhybridsystems(verifiers, analyzers, debuggers...). Parallel composition of hybrid automata is naturally supported in Hy-tccp due totheexistence ofaglobal shared store and tothesynchronization mechanism inherited from tccp. By defining Hy-tccp, we show that the extension of a declarative constraint language with continuous dynamicsisnotonlypossible,butitleadstoapowerfulandexpressivelanguageabletodescribecomplex hybridsystems. In this paper, wehave only considered the modeling ofmulti-rated [5]hybrid systems, i.e., systems whose continuous variables follow a constant dynamics. However, in the future we aim to relax this restriction inordertodescribe morecomplexdynamicssuchasthosedefinedbyrectangular sets. The paper is organized as follows. In Section 2, we briefly introduce the language tccp and the essentialaspectsofhybridautomata. InSection3,weintroducethenewlanguage Hy-tccptogetherwith its operational semantics, and we describe the new features that have been added to tccp in order to model hybrid systems. Section 4contains someexamples tohighlight the expressive power of Hy-tccp. Section 5 presents some related work and, finally, Section 6 concludes the paper and outlines future work. 2 Background In this section wepresent some background to clarify the contributions of the paper. InSubsection 2.1, we introduce the language tccp, the starting point for the definition of Hy-tccp. In Subsection 2.2, we introducethebasicnotionsofhybridautomata,whichistheformalismcommonlyusedtodescribehybrid systems. 2.1 The Timed Concurrent Constraint Language The Timed Concurrent Constraint Language (tccp, [2]) is a time extension of ccp. It adds to ccp the notionoftimeandtheabilitytocapturetheabsenceofinformation. Withthesefeatures,onecanspecify behaviors typicalofconcurrent andreactivesystems. The computation in tccp proceeds as the concurrent execution of several agents that can monotoni- callyaddconstraints inaglobalstoreorquery information fromit. Asareallthelanguages fromthecc paradigm, tccpisparametricw.r.t.acylindric constraint system. DEFINITION 2.1 (CYLINDRIC CONSTRAINT SYSTEM [2]) A cylindric constraint system is an alge- braicstructureoftheform: C=⟨C,⪯,∧,true,false,Var,∃⟩ suchthat: 1. ⟨C,⪯,∧,true,false⟩isacompletelatticewhere∧istheleastupperbound(lub)operator,andtrue andfalseare,respectively, theleastandthegreatest elementsofC. Weoftenusetheinverse order ⊢(theentailmentrelation) insteadof⪯overconstraints. Formally∀c,d ∈C c⪯d⇔d⊢c. 2. Varisadenumerable setofvariables. Adalid,Gallardo&Titolo 3 3. Foreachelementx∈Var,afunction(alsocalledcylindricoperator)∃ ∶C→C isdefinedsuchthat, x foranyc,d∈C thefollowingaxiomshold: (a) c⊢∃ c x (b) ifc⊢d then∃ c⊢∃ d x x (c) ∃ (c∧∃ d)=∃ c∧∃ d x x x x (d) ∃ (∃ c)=∃ (∃ c) x y y x Theentailmentrelation⊢intuitivelystatesthatifccontainsmoreinformationthand thenc⊢d. The lub operator ∧ merges the information from two constraints (e.g. x>0∧x>5∧y=9∶=x>5∧y=9and x=0∧x=7∶=false). The cylindrification (or hiding) operator is defined in terms of a general notion of existential quantifier. It is used to project away information about the considered variable inorder to makeitlocaltotheconstraint andhideitfromthecontext(e.g. ∃x(x=0∧y=x∧z>7)∶=y=0∧z>7). Thetccp global store ismonotonic inthesense thatonce aconstraint isadded tothe store, itcannot be removed. Thus, given the store x>0∧y>2 we can add the information x>5 and obtain the store x>5∧y>2. Furthermore,byaddingx=0weobtaintheinconsistent storefalsesincetheconstraintx=0 isincontradiction withtheinformation alreadypresentinthestore. Thesyntax oftccpagentsisgivenbythegrammar: A∶∶=stop∣tell(c)∣A∥A∣∃xA∣∑n ask(c)→A∣nowcthenAelseA∣p(x⃗) i=1 i wherec,c ,...,c arefiniteconstraintsinC, pisaprocesssymbol,andx⃗∈Var×⋅⋅⋅×Var. Atccpprogram 1 n isapairD.A,whereAistheinitialagentandDisasetofprocess declarations oftheform p(x⃗)∶−A. Theoperational semanticsoftccp[2]isdescribed byatransition system T =(Conf,→). Configura- tions in Conf are pairs ⟨A,c⟩ representing the agent A to be executed in the current global store c. The transition relation →⊆Conf ×Conf is the least relation satisfying the rules in Figure 1. Each transition step takes exactly one time-unit. The notion of time is introduced by defining a global clock which synchronizes allagents. As can be seen from the rules, the stop agent represents the successful termination of the computa- tion. Thetell(c)agentaddstheconstraintctothecurrentstorebymeansofthe∧operatorandthenstops. Ittakesonetime-unit, thustheconstraint cisvisible totheotheragents fromthefollowing timeinstant. Thechoiceagent∑n ask(c)→A consultsthestoreandnon-deterministicallyexecutes(atthefollowing i=1 i i time instant) one of the agents A whose corresponding guard c is entailed by the current store; other- i i wise, ifno guard isentailed by thestore, the agent suspends. Theconditional agent nowcthenAelseB behaves (in the current time instant) like A (respectively B) if c is (respectively is not) entailed by the store. This conditional agent is able to process negative information (lack of some information): it can capture whensomeinformation isnotpresent inthestore sincetheagent Bisexecuted both when¬cis satisfied,butalsowhenneithercnor¬caresatisfied. A∥BmodelstheparallelcompositionofAandBin termsofmaximal parallelism, i.e.,alltheenabled agents ofAandBareexecuted atthe sametime. The agent ∃xAmakesvariable xlocaltoA,tothisend, itusesthe∃ operator oftheconstraint system. More specifically, itbehaves likeAwithxconsidered local, i.e.,theinformation onxprovided bytheexternal environment is hidden to A, and the information on x produced by A is hidden to the external world. In the corresponding rule, the store l in the agent ∃lxA represents the store local to A. This auxiliary operator is linked to the hiding construct by setting the initial local store to true, thus ∃xA∶=∃truexA. Finally,theagent p(x⃗)takesfromDadeclaration oftheform p(x⃗)∶−AandthenexecutesA. 4 ModelingHybridSystemsintheConcurrentConstraintParadigm ∃1≤ j≤n.d⊢c j ⟨tell(c),d⟩→⟨stop,c∧d⟩ ⟨∑n ask(c)→A,d⟩→⟨A ,d⟩ i=1 i i j ⟨A,d⟩→⟨A′,d′⟩,d⊢c ⟨A,d⟩→/,d⊢c ⟨nowcthenAelseB,d⟩→⟨A′,d′⟩ ⟨nowcthenAelseB,d⟩→⟨A,d⟩ ⟨B,d⟩→⟨B′,d′⟩,d⊬c ⟨B,d⟩→/,d⊬c ⟨nowcthenAelseB,d⟩→⟨B′,d′⟩ ⟨nowcthenAelseB,d⟩→⟨B,d⟩ ⟨A,d⟩→⟨A′,d′⟩ ⟨B,d⟩→⟨B′,c′⟩ ⟨A,d⟩→⟨A′,d′⟩ ⟨B,d⟩→/ ⟨A∥B,d⟩→⟨A′∥B′,d′∧c′⟩ ⟨A∥B,d⟩→⟨A′∥B,d′⟩ ⟨B∥A,d⟩→⟨B∥A′,d′⟩ ⟨A,l∧∃ d⟩→⟨B,l′⟩ p(x⃗)∶−A∈D x ⟨∃lxA,d⟩→⟨∃l′xB,d∧∃ l′⟩ ⟨p(x⃗),d⟩→⟨A,d⟩ x Figure1: Thetransition systemfortccp. 2.2 Introduction to hybridautomata Many real systems have complex behaviors and evolve following both discrete and continuous dynam- ics. These systems are called hybrid systems. For instance, a cooler system is a hybrid system: it has two discrete states (on or off) that are chosen according to the temperature of the room, which evolves continuously overtime. Hybridautomata [8]areanextension offinite-state automatausedtodescribe hybridsystems. Intu- itively, the discrete behavior of a hybrid automaton is defined by means of a finite set of discrete states (calledlocations)andasetof(instantaneous) discretetransitionsfromonelocationtoanother. Thecon- tinuousbehaviorofhybridautomataisdescribedateachlocationbymeansofsomeOrdinaryDifferential Equations (ODEs)whichdescribe howcontinuous variables evolveovertime(continuous transitions). DEFINITION 2.2 (HYBRID AUTOMATON) Ahybridautomaton H isatuple ⟨Loc,T,S ,X,Init,Inv,Flow,Jump⟩ where: • Locisafiniteset{loc ,...,loc }ofdiscretestates(locations). 1 n • T ⊆Loc×Locisafinitesetofdiscretetransitions. • S isasetofeventnames,associated withalabelling functionL ∶T →S . • X ={x ,...,x }isafinitesetofreal-valuedvariables. ThesetX˙ ={x˙,...,x˙ }representsthefirst 1 m 1 m derivativesoftheelementsinX. Inaddition,thesetX′={x′,...,x′ }representstheupdatesofthe 1 m variableswhenadiscretetransitiontakesplace. Inthissection,weassumethatdiscretevariables arecontinuous variables whosederivative iszeroatalllocations. • ThefunctionsInit,InvandFlowassignpredicatestoeachlocationloc∈Loc. Init(loc)establishes the possible initial values for the continuous variables at location loc. Inv(loc) constrains the values of the continuous variables at location loc. Flow(loc) contains the differential equations describing theevolution ofthecontinuous variables atlocation loc. Adalid,Gallardo&Titolo 5 T ≥26 T =26 T ≤30 T˙ =−0.5 T˙ =+2.0 on T =30 off Figure2: Hybridautomatonforthecoolersystem • Function Jump assigns to each discrete transition t ∈T a guard that must be satisfied in order to allowthetransitiontotakeplace,andaresetpredicatewhichupdatesthevalueand/ortheflowof acontinuous variables. EXAMPLE 2.3 Figure 2shows ahybrid automaton modeling acooler system. The automaton has two locations on and off and a continuous variable T storing the room temperature. When the automaton is at location on (the cooler is turned on) the temperature decreases at rate −0.5. When the location is off (thecooler isturned off)thetemperature increases atrate+2.0. Transitions between locations represent theturningonoroffofthecooler. Thesetransitionsareguardedwithconditions. Forinstance,transition on-off takes place whenthetemperature is26, whiletransition off-ontakes place whenthe temperature is30. Ahybridautomaton behaves likeatimedtransition system (TTS),whereeachstepislabelled either with a positive real value t (continuous transition of duration t ) or with s (discrete transition). Let [X →R]bethesetofmapsfrom X toR. Anautomaton state, called hybrid statefrom nowon, isapair (loc,v)∈(Loc×[X →R]), where loc∈Loc is a location of the automaton, and v∈[X →R] maps each continuous variabletoitscurrentvalue. Let pbeapredicate overX∪X˙ orX∪X′,then⟦p⟧denotes allfunctions v∈[X →R]thatsatisfy p. DEFINITION 2.4 (TRAJECTORIES) LetH =⟨Loc,T,S ,X,Init,Inv,Flow,Jump⟩be ahybrid automa- ton. Weconsider twotypesoftransitions: Discretetransitions Let(loc,loc′)∈T,(loc,v)→s (loc′,v′),iffv,v′∈[X →R],and(v,v′)∈⟦Jump(t)⟧. Continuoustransitions For each t ∈R+, we have (loc,v)→t (loc,v′) iff there exists a differentiable function f ∶[0,t ]→Rm, f˙∶[0,t ]→Rm beingitsfirstderivative, suchthat: • f(0)=v • f(t )=v′ • ∀t ′∈[0,t ],f(t ′)∈⟦Inv(loc)⟧ • (f(t ′),f˙(t ′))∈⟦Flow(loc)⟧ A trajectory is a (possible infinite) sequence of hybrid states such as (loc0,v0)→l (loc1,v1)→l 1 2 ...→l (locn,vn)→l ...,whereforalli≥0,vi∈⟦Inv(loci)⟧andl i∈R∪{s }. n n Itisworthnoting thatthesystem isfreetoselect non-deterministically ateachmomentanyenabled transition, eitherdiscreteorcontinuous. EXAMPLE 2.5 Considering the hybrid system in Figure 2, the following trajectory represents a possi- ble evolution of the automaton starting at hybrid state (on,27): (on,27)→1(on,26.5)→1(on,26)→s (off,26)→0.5(off,27)→1.5(off,30)→s (on,30)... 6 ModelingHybridSystemsintheConcurrentConstraintParadigm 3 Hy-tccp: an extension of tccp over continuous time Inthissection, wepresentthelanguage Hy-tccp, whichsubsumes tccpandincludes newagents inorder to model the continuous behavior typical of hybrid systems in the style of hybrid automata. In contrast totccp,inHy-tccpweconsideranotion ofcontinuous timebymeansofaglobalcontinuous clock. Hy-tccpusesatccpmonotonicstore(calleddiscretestore)tomodeltheinformationaboutthecurrent location andtheassociated invariants ofahybridautomaton. Discretetransitions aremodeledasinstan- taneous transitions in Hy-tccp and they are used to synchronize parallel agents/automata. In summary, the features offered by tccp are used to model the discrete behavior of hybrid automata. However, hy- bridautomataarecharacterized bytheuseofcontinuous variableswhosevalueschangefollowingsome ODEs. For this reason, the tccp store is extended by adding a component called continuous store. The continuousstoreisnotmonotonic,insteaditrecordsthedynamicalevolutionofthecontinuousvariables. We distinguish the set of discrete variables Var, whose information is accumulated monotonically, and the set of continuous variables Ṽar, whose values change continuously over time (Var∩Ṽar=∅). Constraints inC arenowdefinedoverVar∪Ṽar. Acontinuousstoreisafunctionthatassociatesacontinuousvariablewithtworealnumbers: itsvalue and its flow, which indicates how its value changes over time. In this work, we consider only ODEsof the form x˙=n with n∈R. In the future, we intend to also consider ODEs of the form x˙∈[n1,n2] with n ,n ∈Rinordertomodelrectangular hybridsystems. 1 2 Wedenote asC˜=[Ṽar↪(R×R)]thesetofallpossible continuous stores, andast̃rueandf̃alse the emptyandtheinconsistentcontinuousstore,respectively. Wedenotewithdom(c˜)⊆Ṽarthedomainofc˜. Givenc˜∈C˜andx∈dom(c˜),c˜(x)=⟨v, f⟩meansthatxhasvaluev(denotedasc˜(x).v)andflow f (denoted asc˜(x).f). Thebinary operator ∧˜ ∶C˜×C˜→C˜mergestheinformation fromtwocontinuous stores. Inthe case the same variable appears in both stores with different values or flows, their merge is inconsistent. Givenc˜,d˜∈C˜: c˜∧˜t̃rue=c˜ c˜∧˜f̃alse=f̃alse c˜∧˜d˜=f̃alse if∃x∈dom(c˜)∩dom(d˜).c˜(x)≠d˜(x) ⎧ c˜∧˜d˜=l y.⎪⎪⎨c˜(y) ify∈dom(c˜) if∀x∈dom(c˜)∩dom(d˜).c˜(x)=d˜(x) ⎪⎪d˜(y) ify∈dom(d˜) ⎩ Wedefinetheoperator∃˜ ∶Var×C˜→C˜suchthat,givenc˜∈C˜andx∈Ṽar,∃˜ c˜deletestheinformationabout x xinc˜. Givenc˜∈C˜,x∈dom(c˜)andv∈R,wedenote asc˜[v/x] thecontinuous store thatisequal toc˜except forthevalueofxthatbecomesv. ⎧ c˜[v/x]=l y.⎪⎪⎨c˜(y) ify∈dom(c˜),y≠x ⎪⎪(v,c˜(x).f) ify=x ⎩ A Hy-tccp store isapair ⟨c,c˜⟩wherec∈C (discrete store) isamonotonic constraint store asintccp and c˜∈C˜ (continuous store) is such that c∧⋀x∈dom(c˜)(x=c˜(x).v)≠false, i.e., discrete and continuous store are consistent1. We denote as G the set of all possible Hy-tccp stores. We define the extension of the entailment relation ⊢ over Hy-tccp stores as ⊢˜ ∶G ×C such that given ⟨c,c˜⟩∈G and d∈C, ⟨c,c˜⟩⊢˜d if c∧⋀x∈dom(c˜)(x=c˜(x).v)⊢d. In other words, a store ⟨c,c˜⟩ entails a constraint d if the discrete store c 1Weassumethatourunderlyingconstraintsystemhandlesequalityconstraints. Adalid,Gallardo&Titolo 7 merged with the projection of the current values of the continuous variables entails d in the underlying constraint system. Givent ∈R+wedenoteas⟨c,c˜t ⟩thecontinuousprojectionofthestore⟨c,c˜⟩attimet : thevaluesof thecontinuousvariablesareupdatedattimet ,whiletheflowsareunchanged: c˜t =l y.c˜[ny/y]wherey∈ dom(c˜)andny=c˜(y).v+(c˜(y).f ∗t ). Forinstance consider thestore ⟨x>10,y↦(2,5)⟩, itsprojection attime3isthestore⟨x>10,y↦(17,5)⟩. Wesaythat⟨c,c˜t ⟩isacontinuous projection of⟨c,c˜⟩attime t that satisfies d (denoted as ⟨c,c˜⟩↝td ⟨c,c˜t ⟩) if for all t ′ ∈[0,t ] ⟨c,c˜t′⟩⊢˜d. For instance, the above projection satisfiesy>0: ⟨x>10,y↦(2,5)⟩↝y>0⟨x>10,y↦(17,5)⟩. 3 The update operator ⊲, given c˜,d˜∈C˜ such that dom(c˜)∩dom(d˜)={x1,...,xn}, updates c˜ with the information of d˜as follows: c˜⊲d˜∶=(∃˜x1,...,xnc˜)∧˜d˜. Note that it is impossible to obtain an inconsistent continuousstoresincethecommonvariablesarehiddenfromc˜andreplacedbythenewvaluesandflows fromd˜. Inordertomodelthetypicalbehaviors ofhybridsystemsweintroduce twonewconstructs w.r.t. the syntaxoftccp: changeandãsk. The agent change updates the current continuous store with a new value and/or flow for a given continuous variable. Itroughlycorresponds tothereset predicate ofhybridautomata. Continuous transitions are modeled by the new construct ãsk(inv) that makes continuous variables evolve over continuous time while the invariant inv is satisfied. The tccp choice agent is extended by allowingthenon-deterministic choicebetweendiscrete andcontinuous transitions inthefollowingway: ∑ni=1ask(ci)→A+∑mj=1ãsk(invj). Here, the ãskbranches can be non-deterministically selected when the corresponding invariant inv j is entailed in the current store. The continuous variables evolve over time while inv holds and until j another askbranchisselected. Thesyntax ofHy-tccpagentsisgivenbythefollowinggrammar: A∶∶=stop∣tell(c)∣A∥A∣nowcthenAelseA∣∃xA∣p(x⃗)∣ change(y,v,f)∣∑ni=1ask(ci)→A+∑mj=1ãsk(invj) where c, c and inv are finite constraints in C, y is a continuous variable in Ṽar, v, f ∈R, p is a process i j symbol,x∈Var∪Ṽar,x⃗∈(Var∪Ṽar)×⋅⋅⋅×(Var∪Ṽar),n≥0andm≥0. Theoperational semantics of Hy-tccpisdescribed byatransition systemT =(C̃onf,→s ,→t ). Con- figurations in C̃onf are triples ⟨A,c,c˜⟩ representing the agent A to be executed in the current extended store ⟨c,c˜⟩. In contrast to the tccp approach, the discrete transition relation →s ⊆C̃onf ×C̃onf does not represent thepassage ofonetimeunit. Instead, itmodels acomputational step whichdoes notconsume time but it is needed to synchronize the agents in parallel. The continuous passage of time is modeled bythetransitionrelation→t ⊆C̃onf×C̃onf wheret ∈R+isa(strictly)positiverealnumberthatindicates the duration of the transition. In Figure 3, we formally describe the operational semantics of Hy-tccp. Whereverpossiblewewillusethesubindexl ∈R+∪{s }torepresent bothkindsoftransitions (discrete andcontinuous). RuleR1shows theeffects ofadding aconstraint c∈C tothecurrent discrete store. InRuleR1’, the agentchangeupdates thecontinuous stored˜withanewinitialvaluevandanewflow f forthevariable ybyusingtheupdateoperator⊲. Rules R2 and R2’ describe the non-deterministic choice behavior. Rule R2 represents the discrete transition that is performed when one of the ask guards is entailed in the current store. In this case the 8 ModelingHybridSystemsintheConcurrentConstraintParadigm correspondingagentisexecutedinthenextstep. RuleR2’modelsthecontinuousevolutionofthesystem whileone oftheãskinvariants holds inthestore. Afteracontinuous transition ofduration t ,thevalues of the variables in the continuous store d˜are updated while the discrete store is unchanged. At the end ofthattransition thenon-deterministic choice isexecuted againallowing another discrete orcontinuous branchtobeselected. Inthecasenoguardorinvariant holdsthisagentsuspends. Rules R3, R3’, R4 and R4’ describe the behavior of agent now. This agent behaves as A if c is entailed bytheconstraint store, otherwiseitbehavesasB. RuleR5representstheparallelexecutionoftwodiscretetransitionsintermsofmaximalparallelism, i.e., all the enabled agents of A and B are executed at the same time. Rule R6 represents the parallel execution of two continuous transitions, note that their duration must coincide. Rule R7 expresses the parallel composition of a discrete and a continuous transition. In this case, the discrete transition is executedbeforethecontinuousone. RuleR8statesthatwhenanagentisblocked,theotheroneperforms itstransition (discrete orcontinuous). InRuleR9,theagent∃⟨l,l˜⟩xAmakesvariablexlocaltoA. Itbehaves likeAwithxconsidered local, i.e.,theinformationonxprovidedbytheexternalenvironmentishiddenfromAbyusingthe∃˜ operator, and, in the same way, the information on x produced by A is hidden from the global environment. The store ⟨l,l˜⟩ in the agent ∃⟨l,l˜⟩xA represents the store local to A. This auxiliary operator is linked to the hidingconstruct bysettingtheinitiallocalstoreto⟨true,t̃rue⟩,thus∃xA∶=∃⟨true,t̃rue⟩xA. Finally, in Rule R10, the agent p(x⃗) takes from D a declaration of the form p(x⃗)∶−A and executes A. Let us formalize the notion of behavior of a Hy-tccp program P in terms of the transition system described in Figure 3. The small-step operational behavior of Hy-tccp collects all the small-step com- putations associated with P(in terms of sequences of Hy-tccp stores closed by prefix) for each possible initialstore. Weassumethatsubsequentcontinuoustransitionsareconsideredasaunique(maximal)one whoselengthisequaltothesumofallthesubsequenttransitionlengths. Forinstance,asequenceofcon- tinuous transitions of the form ⟨A0,c0,c˜0⟩→t1 ...→tn ⟨An,cn,c˜n⟩is considered as the unique transition ⟨A0,c0,c˜0⟩→t ⟨An,cn,c˜n⟩wheret =∑ni=1ti2. DEFINITION 3.1 Let P=D.A be a Hy-tccp program. The small-step (observable) behavior of P is defined as: Bss⟦D.A⟧∶= ⋃ {⟨c0,c˜0⟩⋅⟨c1,c˜1⟩⋅...⋅⟨cn,c˜n⟩∣⟨A,c0,c˜0⟩→l ⟨A1,c1,c˜1⟩ 1 ⟨c0,c˜0⟩∈G →l ...→l ⟨An,cn,c˜n⟩,∀1≤i≤n.l n∈R+∪{s }}∪{e } 2 n 4 Examples In order toshow the expressivity of Hy-tccp, wepresent some examples of hybrid systems described in thislanguage. Foreachcase,wepresentthe Hy-tccpcodeandthecorresponding hybridautomaton. 4.1 Coolersystem In Figure 4 we model in Hy-tccp the cooler system introduced in Example 2.5. The initial state of thecoolerissettooff andthetemperature T initially hasvalue29andchanges witharateof+2.0. The temperaturevalueincreasescontinuouslyovertime(firstãsk)untilthetemperatureislowerthanorequal 2WeassumethatoursystemdoesnotexhibitZenobehaviors. Adalid,Gallardo&Titolo 9 (R1) ⟨tell(c),d,d˜⟩→s ⟨stop,c∧d,d˜⟩ (R1’) ⟨change(y,v,f),d,d˜⟩→s ⟨stop,d,d˜⊲(y↦(v,f))⟩ ∃1≤k≤n.⟨d,d˜⟩⊢˜ck (R2) ⟨∑ni=1ask(ci)→Ai+∑mj=1ãsk(invj),d,d˜⟩→s ⟨Ak,d,d˜⟩ ∃1≤k≤m,t ∈R+.⟨d,d˜⟩↝itnvk ⟨d,d˜t ⟩ (R2’) ⟨∑ni=1ask(ci)→Ai+∑mj=1ãsk(invj),d,d˜⟩→t ⟨∑ni=1ask(ci)→Ai+∑mj=1ãsk(invj),d,d˜t ⟩ ⟨A,d,d˜⟩→l ⟨A′,d′,d˜′⟩ l ∈R+∪{s } ⟨d,d˜⟩⊢˜c (R3) ⟨nowcthenAelseB,d,d˜⟩→l ⟨A′,d′,d˜′⟩ ⟨A,d,d˜⟩→/l l ∈R+∪{s } ⟨d,d˜⟩⊢˜c (R3’) ⟨nowcthenAelseB,d,d˜⟩→s ⟨A,d,d˜⟩ ⟨B,d,d˜⟩→l ⟨B′,d′,d˜′⟩ l ∈R∪{s } ⟨d,d˜⟩⊬˜c (R4) ⟨nowcthenAelseB,d,d˜⟩→l ⟨B′,d′,d˜′⟩ ⟨B,d,d˜⟩→/l l ∈R∪{s } ⟨d,d˜⟩⊬˜c (R4’) ⟨nowcthenAelseB,d,d˜⟩→s ⟨B,d,d˜⟩ ⟨A,d,d˜⟩→s ⟨A′,d′,d˜′⟩ ⟨B,d,d˜⟩→s ⟨B′,d′′,d˜′′⟩ (R5) ⟨A∥B,d,d˜⟩→s ⟨A′∥B′,d′∧d′′,d˜′∧˜d˜′′⟩ ⟨A,d,d˜⟩→t ⟨A,d,d˜′⟩ ⟨B,d,d˜⟩→t ⟨B,d,d˜′⟩ t ∈R+ (R6) ⟨A∥B,d,d˜⟩→t ⟨A∥B,d,d˜′⟩ ⟨A,d,d˜⟩→s ⟨A′,d′,d˜′⟩ ⟨B,d,d˜⟩→t ⟨B,d,d˜′′⟩ t ∈R+ (R7) ⟨A∥B,d,d˜⟩→s ⟨A′∥B,d′,d˜′⟩ ⟨A,d,d˜⟩→l ⟨A′,d′,d˜′⟩ ⟨B,d,d˜⟩→/l ′ l ,l ′∈R+∪{s } (R8) ⟨A∥B,d,d˜⟩→l ⟨A′∥B,d′,d˜′⟩ ⟨B∥A,d,d˜⟩→l ⟨B∥A′,d′,d˜′⟩ ⟨A,l∧∃xd,l˜∧˜∃˜xd˜⟩→l ⟨B,l′,l˜′⟩ l ∈R+∪{s } (R9) ⟨∃⟨l,l˜⟩xA,d,d˜⟩→l ⟨∃⟨l′,l˜′⟩xB,d∧∃xl′,d˜∧˜∃˜xl˜′⟩ p(x⃗)∶−A∈D (R10) ⟨p(x⃗),d,d˜⟩→s ⟨A,d,d˜⟩ Figure3: Thetransition systemfor Hy-tccp. 10 ModelingHybridSystemsintheConcurrentConstraintParadigm init∶−∃St,T (tell(St=[off∣ ])∥change(T,29,+2.0)∥tell(T≥26∧T≤30)∥cooler(St,T)) cooler(St,T)∶−∃St′( ãsk(St=[off∣ ]∧T≤30) +ask(St=[off∣ ]∧T=30)→(tell(St=[off∣St′])∥tell(St′=[on∣ ])∥change(T,30,−0.5)∥cooler(St′,T)) +ãsk(St=[on∣ ]∧T≥26) +ask(St=[on∣]∧T=26)→(tell(St=[on∣St′])∥tell(St′=[off∣ ])∥change(T,26,+2.0)∥cooler(St′,T))) Figure4: Hy-tccpmodelforthecoolersystem to the value of 30. When the temperature reaches this limit, the cooler is turned on and the flow of the temperature changes from +2.0 to −0.5 (first ask). Atthis point, the temperature starts decreasing until it reaches the value of 26 (second ãsk). When this happens, the cooler is turned off and the flow of the temperature ischangedagainto+2.0(second ask). It is worth noting that, due to the monotonicity of the discrete constraint store, streams (written in a list-fashion way) are used to model imperative-style variables [2]. A stream is a list of the form St=[on∣St′] where the head on represents the current value of St, and the tail St′ is afree variable that willbeinstantiatedwiththefuturevaluesofSt. ObservethatweusetheglobalconstraintT ≥26∧T ≤30 to add a global invariant of the cooler system ensuring that the temperature always stays in the interval [26,30]. Thefollowing partial trace represents thesmall-step behavior (see Definition 3.1)ofcooler(St,T) startingfromtheinitialstore⟨St=[off ∣ ]∧T≥26∧T≤30,T ↦(29,+2.0)⟩. Thismeansthat,initially,the cooleristurnedoffandthetemperature hasavalueof29andaflowof+2.0. Moreover, thetemperature is constrained to be between the values 26 and 30. Observe how the values on and off are accumulated in the stream St in order to model the evolution of the state. The current state corresponds to the last valueadded tothestream. Weuse toindicate thatthetailofthestream St isafreevariable thatcanbe instantiatedwithfuturevalues. Thecontinuousvariablesevolveovertimeuntilanotherdiscretetransition is executed. The repeated equal stores occurring in the trace correspond to the discrete computational steps taken in Hy-tccp (as well as in tccp) to evaluate one of the ask guards or to perform a procedure call. Thesesteps arenecessary tosynchronize parallel agents. Forsakeofclarity, weexplicitly indicate the kind oftransition occurring between twostates (wewrite s for discrete transitions and the duration t ∈R+ forcontinuous ones). ⟨St=[off ∣ ]∧T ≥26∧T ≤30,T↦(29,+2.0)⟩⋅0.5⟨St=[off ∣ ]∧T ≥26∧T ≤30,T↦(30,+2.0)⟩⋅s ⟨St=[off ∣ ]∧T ≥26∧T ≤30,T↦(30,+2.0)⟩⋅s ⟨St=[off,on∣ ]∧T ≥26∧T ≤30,T↦(30,−0.5)⟩⋅s ⟨St=[off,on∣ ]∧T ≥26∧T ≤30,T↦(30,−0.5)⟩⋅8⟨St=[off,on∣ ]∧T ≥26∧T ≤30,T ↦(26,−0.5)⟩⋅s ⟨St=[off,on∣ ]∧T ≥26∧T ≤30,T↦(26,−0.5)⟩⋅s ⟨St=[off,on,off ∣ ]∧T ≥26∧T ≤30,T ↦(26,+2.0)⟩... 4.2 Catand mouserace We consider the cat and mouse problem proposed in [7] (see Figure 5 for the corresponding hybrid automaton). TheHy-tccpcodeofthismodelisshowninFigure6. Thepositionsofthecatandthemouse aremodeled bytwocontinuous variables, calledC andM respectively. Amousestartsrunning fromthe point of origin at a speed of 10 meters/second (change(M,0,10.0)) towards a hole that is 100 meters

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.