Skip to content

Commit

Permalink
Merge pull request #1701 from informalsystems/ro/funSets-as-arrays
Browse files Browse the repository at this point in the history
Encode function sets as SMT arrays
  • Loading branch information
rodrigo7491 authored May 3, 2022
2 parents 0fff5ac + b98ba8c commit d0878ca
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
3 changes: 3 additions & 0 deletions UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
* Some bug fix, see #124
DO NOT LEAVE A BLANK LINE BELOW THIS PREAMBLE -->
### Bug fixes

* Fix usage of sets of function sets in the arrays encoding, see #1680
20 changes: 20 additions & 0 deletions test/tla/OracleFunSet.tla
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
------ MODULE OracleFunSet --------
\* A regression test for the use of sets of function sets, see:
\* https://github.com/informalsystems/apalache/issues/1680

VARIABLES
\* @type: Set(Bool -> Int);
witness,
\* @type: Bool;
found

Init ==
/\ witness \in {[{TRUE} -> {222521218, 0}]}
/\ found \in BOOLEAN

Next ==
UNCHANGED <<witness, found>>

NotFound ==
~found
======================
11 changes: 11 additions & 0 deletions test/tla/cli-integration-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,17 @@ $ apalache-mc check --inv=Inv --length=6 --cinit=CInit SetAddDel.tla | sed 's/I@
EXITCODE: OK
```
### check OracleFunSet succeeds (array-encoding)
Regression test for https://github.com/informalsystems/apalache/issues/1680
Function sets themselves should be able to be set elements.
```sh
$ apalache-mc check OracleFunSet.tla | sed 's/I@.*//'
...
EXITCODE: OK
```
## configure the check command
Testing various flags that are set via command-line options and the TLC configuration file. The CLI has priority over
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,11 @@ class Z3SolverContext(val config: SolverConfig) extends SolverContext {
case PowSetT(domType) if encoding == arraysEncoding =>
z3context.mkArraySort(getOrMkCellSort(domType), z3context.getBoolSort)

case FunT(FinSetT(domType), resType) if encoding == arraysEncoding =>
z3context.mkArraySort(getOrMkCellSort(domType), getOrMkCellSort(resType))
case FinFunSetT(domType, FinSetT(cdmElemType)) if encoding == arraysEncoding =>
z3context.mkArraySort(getOrMkCellSort(FunT(domType, cdmElemType)), z3context.getBoolSort)

case FunT(FinSetT(domElemType), resType) if encoding == arraysEncoding =>
z3context.mkArraySort(getOrMkCellSort(domElemType), getOrMkCellSort(resType))

case _ =>
log(s"(declare-sort $sig 0)")
Expand Down

0 comments on commit d0878ca

Please sign in to comment.