简体   繁体   English

合金元模型::定义局部状态和全局状态

[英]Alloy metamodel :: define local state and global state

We need to create a metamodel of Alloy models. 我们需要创建Alloy模型的元模型。 We have some doubts about how to model global and local state inside our model. 我们对如何在模型中建模全局和局部状态存有疑问。 We have this model so far: 到目前为止,我们有这个模型:

open util/ordering[Estado] as E

sig Estado{

}

//an alloy model is composed by a set of signatures
sig Model {
    sigs : set Signature
}

// each signature has name 
sig Signature {
    nameSig : one Name
}

sig Name {

}

sig Atom {
    nameAtom : one Name
}

sig Instance {
    atom : set Atom -> Estado,
    instance : set Estado
}

pred solve [m : Model, i : Instance, e : Estado] {
    -- every signature name must be different and they all should be part of the signatures
    (i.atom.e).(nameAtom) in (m.sigs).(nameSig)
}

pred valid[m : Model] {
    all n : Name | lone nameSig.n & m.sigs
}

pred invs [e : Estado]{
    -- every sig make part of the model
    all s : Signature | s in Model.sigs 
    all m : Model | valid[m]
    all m : Model, i : Instance | solve[m, i, e]
    all a : Atom | a in (Instance.atom).e 
}
-- invariants
fact invs1 {
    all e : Estado | invs[e]
}

----------------------------------------------------------------------------------
-- Será que estes predicados são sobre os atomos ou sobre as instancias?
----------------------------------------------------------------------------------

--pred mantemAtoms[e,e' : Estado, i : Instance]{
--  i.atom.e' = i.atom.e
--}

-- run { some e,e' : Estado, i : Instance | mantemAtoms[e, e', i] } for 3 but exactly 1 Model, exactly 2 Estado

--check addAtoms {
    --all e,e' : Estado, a : Atom, i : Instance | invs[e] and  addAtoms[e, e', a, i] => invs[e']
--}

pred addAtoms[e,e':Estado, a : Atom, i : Instance]{
    --pre
    a not in i.(atom.e)
    --pos
    atom.e' = atom.e + i -> a
    instance.e' = instance.e + i
    --frame
}

run { some e,e' : Estado, i : Instance,  a : Atom | addAtoms[e, e', a, i] }
for 3 but exactly 1 Model, exactly 2 Estado

--check addAtoms {
    --all e,e' : Estado, a : Atom, i : Instance | invs[e] and  addAtoms[e, e', a, i] => invs[e']
--}


pred excludeAtoms[e,e' : Estado, i : Instance]{
    --pre
    i in instance.e
    --pos
    atom.e'= atom.e - i -> i.(atom.e)
    instance.e' = instance.e - i
    --frame
}

The question is how to model the local and global state inside such a model? 问题是如何在这种模型中对局部和全局状态建模? We know what are the differences and how to model each state in a specific model but this is different. 我们知道有什么区别,以及如何在特定模型中为每个状态建模,但这是不同的。

Since you are interested in metamodelling, ie modelling Alloy models themselves, the Model signature encodes one particular model and the state associated with it can directly represent the global state (ie global state can be modelled as state associated with an instance of Model). 由于您对元建模感兴趣,即对Alloy模型本身进行建模,因此Model签名对一个特定模型进行编码,并且与其关联的状态可以直接表示全局状态(即,可以将全局状态建模为与Model实例相关联的状态)。 Local state, in turn, can be associated with instances of Signature signature (which are in turn associated with a particular instance of Model). 本地状态又可以与Signature签名的实例相关联(又与Model的特定实例相关联)。 Effectively, this approach can be thought of as viewing models "one level" higher, where a model is not a top-level entity but an instance of a signature. 实际上,可以将这种方法视为将模型“上一层”查看,其中模型不是顶级实体,而是签名的实例。 (The question is quite general and vague -- I hope my understanding of the question was appropriate and this answers the question.) (这个问题非常笼统和含糊-我希望我对该问题的理解是适当的,并能回答这个问题。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM