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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Buggy "export to predicate"

grayswandyr opened this issue · comments

"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)
  }
}

Have you tested it at nmacedo/org.alloytools.alloy@de0bd2f ? 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
  })
  }
}

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