I am new to Alloy. I am trying to formalize a system using Alloy. Here I want to execute certain operations based on the events. For this, I have a list of events that I want to track using enum Event. And I am going through all the State using ordering function of Alloy. In each state, I am taking the mixture object and running the operation.
Problem that I am facing currently is - In my system, I have two sig object - ClassA and ClassB. After executing the alloy code I am generating the flow diagram. Unfortunately, I am noticing my ClassB get referenced to ClassA of Mixture object. I am attaching the diagram
I am also attaching my full code here. Can anyone help me debugging the problem, please? I have tried to impose different predicate and logic, but none of them worked.
open util/ordering[State]
abstract sig Base{
name: String,
value : Int
}{
value >= 0
}
sig ClassA extends Base{
}{
name = "Class A"
}
sig ClassB extends Base{
}{
name = "Class B"
}
enum Event {EVENT1, EVENT2}
sig State{
mixture: Mixture
}
sig Mixture{
classA: Base,
classB: Base
} {
classA != classB
}
fact {
all s: State, s': s.next{
s.mixture ! in s'.*next.mixture
operation [s.mixture]
}
}
pred operation [mixture: Mixture]{
all ev: Event| ev = EVENT1 => {
mixture.classA.name = "Class A" => {
mixture.classA.value = 1
}
}
}
run random {} for 3
You have
sig Mixture{
classA: Base,
classB: Base
}
In your diagram, the relations are named classA
and classB
. Since each can point to any arbitrary Base
, there's nothing stopping classA
from pointing to a ClassB
instance. You probably want something like
sig Mixture {
, classA: ClassA
, classB: ClassB
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.