AlloyTools / org.alloytools.alloy

Alloy is a language for describing structures and a tool for exploring them. It has been used in a wide range of applications from finding holes in security mechanisms to designing telephone switching networks. This repository contains the code for the tool.
Other
711 stars 123 forks source link

Buggy "export to predicate" #258

Closed grayswandyr closed 5 months ago

grayswandyr commented 5 months ago

"Export to predicate" (in the Visualizer) issues a wrong predicate. E.g. for the following model, after hitting "fork" then "next state" several times:

sig S { var r: S }
run { some disj s1, s2 : set S | #((s1 + s2).r) > 2 } for 4 but 0 Int

here is the returned predicate, where r isn't constrained at all:

some disj _S1,_S0,_S3,_S2 : univ + (univ + (univ + (univ + (univ)')')')' {
  Int = none and seq/Int = none and String = none and this/S = _S0 + _S1 + _S2 + _S3

  univ = _S0 + _S1 + _S2 + _S3;
  univ = _S0 + _S1 + _S2 + _S3;
  univ = _S0 + _S1 + _S2 + _S3;
  univ = _S0 + _S1 + _S2 + _S3;
  univ = _S0 + _S1 + _S2 + _S3

  after after after after  {
    (univ = _S0 + _S1 + _S2 + _S3) implies after (univ = _S0 + _S1 + _S2 + _S3)
  }
}
nmacedo commented 5 months ago

Have you tested it at nmacedo/org.alloytools.alloy@de0bd2f200e9b9b43e2b0b526942973a165bed4c ? It was buggy but should be fixed, I'm getting this:

some disj _S1,_S0,_S3,_S2 : univ + (univ)' {
  // configuration
  Int = none
  seq/Int = none
  String = none
  this/S = _S0 + _S1 + _S2 + _S3

  {
  // state 0
  univ = _S0 + _S1 + _S2 + _S3
  (this/S <: r) = _S0 -> _S3 + _S1 -> _S1 + _S2 -> _S0 + _S3 -> _S0
  };
  {
  // state 1
  univ = _S0 + _S1 + _S2 + _S3
  (this/S <: r) = _S0 -> _S2 + _S1 -> _S2 + _S2 -> _S2 + _S3 -> _S1
  }

  // enforce loop
  after always {
  ({
  // state 1
  univ = _S0 + _S1 + _S2 + _S3
  (this/S <: r) = _S0 -> _S2 + _S1 -> _S2 + _S2 -> _S2 + _S3 -> _S1
  }) implies after ({
  // state 1
  univ = _S0 + _S1 + _S2 + _S3
  (this/S <: r) = _S0 -> _S2 + _S1 -> _S2 + _S2 -> _S2 + _S3 -> _S1
  })
  }
}
grayswandyr commented 5 months ago

My bad I was testing another commit. Looks good indeed, thanks.