Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into gabriela/new-evaluator
Browse files Browse the repository at this point in the history
  • Loading branch information
bugarela committed Sep 9, 2024
2 parents be10877 + 27e91c9 commit c641178
Show file tree
Hide file tree
Showing 17 changed files with 264 additions and 68 deletions.
24 changes: 20 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Calling `q::test`, `q::testOnce` and `q::lastTrace` on the REPL now works properly (#1495)

### Changed

- Performance of the REPL was drastically improved (#1495)
- Error reporting was improved for many runtime errors (#1495)

### Deprecated
### Removed
### Fixed

- Sending SIGINT (hitting Ctrl+C) to the run and test commands now actually stops the execution (#1495)

### Security

## v0.21.2 -- 2024-09-09

### Added

- In the `verify` command, add warning if `--out-itf` option contains `{test}` or `{seq}` as those have no effect since Apalache only produces a single trace (#1485)
- The `run` and `test` commands now display a progress bar (#1457)
- Calling `q::test`, `q::testOnce` and `q::lastTrace` on the REPL now works properly (#1495)

### Changed

- Performance of incrementally checking types (i.e. in REPL) was improved (#1483).
- Performance of the REPL was drastically improved (#1495)
- In the `run` and `test` commands, change placeholders from `{}` to `{test}` and from `{#}` to `{seq}` (#1485)
- In the `run` command, auto-append trace sequence number to filename if more than one trace is present and `{seq}` is not specified (#1485)
- In the `test` command, rename `--output` to `--out-itf`
- Error reporting was improved for many runtime errors (#1495)

### Deprecated

Expand All @@ -34,7 +50,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Bumped GRPC message sizes to 1G (#1480)
- Fix format of ITF trace emitted by `verify` command (#1448)
- Sending SIGINT (hitting Ctrl+C) to the run and test commands now actually stops the execution (#1495)
- Relax uppercase check for types qualified with a namespace (#1494)

### Security

Expand Down
2 changes: 2 additions & 0 deletions examples/.scripts/run-example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ get_verify_args () {
args="--init=Init --step=Next"
elif [[ "$file" == "games/tictactoe/tictactoe.qnt" ]] ; then
args="--max-steps=1" # pretty slow, and we just want to check that verification can run
elif [[ "$file" == "classic/distributed/TeachingConcurrency/teachingConcurrency.qnt" ]] ; then
args="--temporal correct"
fi
echo "${args}"
}
Expand Down
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ listed without any additional command line arguments.
| [classic/distributed/Paxos/Paxos.qnt](./classic/distributed/Paxos/Paxos.qnt) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x:<sup>https://github.com/informalsystems/quint/issues/1284</sup> |
| [classic/distributed/Paxos/Voting.qnt](./classic/distributed/Paxos/Voting.qnt) | :white_check_mark: | :white_check_mark: | N/A[^parameterized] | N/A[^nostatemachine] |
| [classic/distributed/ReadersWriters/ReadersWriters.qnt](./classic/distributed/ReadersWriters/ReadersWriters.qnt) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| [classic/distributed/TeachingConcurrency/teachingConcurrency.qnt](./classic/distributed/TeachingConcurrency/teachingConcurrency.qnt) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| [classic/distributed/TwoPhaseCommit/two_phase_commit.qnt](./classic/distributed/TwoPhaseCommit/two_phase_commit.qnt) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| [classic/distributed/TwoPhaseCommit/two_phase_commit_modules.qnt](./classic/distributed/TwoPhaseCommit/two_phase_commit_modules.qnt) | :white_check_mark: | :white_check_mark: | :x:<sup>https://github.com/informalsystems/quint/issues/1299</sup> | :x:<sup>https://github.com/informalsystems/quint/issues/1299</sup> |
| [classic/sequential/BinSearch/BinSearch.qnt](./classic/sequential/BinSearch/BinSearch.qnt) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// -*- mode: Bluespec; -*-
/**
* A simple algorithm from Lamport's "Teaching Concurrency" paper:
* https://lamport.azurewebsites.net/pubs/teaching-concurrency.pdf
*
* Run in verifier with:
* quint verify --temporal correct teachingConcurrency.qnt
*/

// An example instance of the algorithm with N=5.
module teachingConcurrency {
import teachingConcurrencyN(NUM_PROCS=5).*
}

// A concurrency algorithm providing a basic form of mutual
// exclusion. For details and proofs see section 7.2 of
// https://lamport.azurewebsites.net/tla/proving-safety.pdf
module teachingConcurrencyN {
// N processes (numbered from 0 to N-1).
const NUM_PROCS: int
assume nonEmpty = NUM_PROCS >= 1

var x: List[int]
var y: List[int]

// Set of processes yet to be executed.
var pendingProcs: Set[int]

// Initial state:
// - x and y zeroed for all processes
// - all processes pending scheduling
action init = all {
x' = zeroes(NUM_PROCS),
y' = zeroes(NUM_PROCS),
pendingProcs' = 0.to(NUM_PROCS-1),
}

// Stepping action: randomly pick a pending process (if
// any) and execute it. Otherwise stutter forever, as
// every process has stopped.
action step = {
if (termination) {
allStopped
} else {
processUpdate
}
}

// Execute the algorithm for a pending process.
action processUpdate = {
nondet proc = pendingProcs.oneOf()

val nextX = x.replaceAt(proc, 1)
val index = circularIndex(proc, NUM_PROCS)
val yValue = nextX[index]

all {
x' = nextX,
y' = y.replaceAt(proc, yValue),
pendingProcs' = pendingProcs.exclude(Set(proc)),
}
}

// All processes have stopped.
action allStopped = all {
x' = x,
y' = y,
pendingProcs' = pendingProcs,
}

// Return a List of 0s, with the given length.
pure def zeroes(len: int): List[int] = {
0.to(len-1).fold(List(), (l, _) => l.append(0))
}

// Calculate the circular index `(i-1) mod N`.
pure def circularIndex(i: int, N: int): int = {
if (i == 0) {
N-1
} else {
i-1
}
}

// Correctness invariant: (after every process has
// stopped) y[i] == 1 for at least one process.
val yContainsOne = {
y.select(v => v == 1).length() >= 1
}

// Termination invariant: all processes have stopped
// (i.e. none is pending scheduling).
val termination = {
pendingProcs.size() == 0
}

temporal correct = eventually(termination and yContainsOne)
}
4 changes: 2 additions & 2 deletions quint/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion quint/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@informalsystems/quint",
"version": "0.21.1",
"version": "0.21.2",
"description": "Core tool for the Quint specification language",
"keywords": [
"temporal",
Expand Down
18 changes: 12 additions & 6 deletions quint/src/parsing/ToIrListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,7 @@ export class ToIrListener implements QuintListener {
const name = ctx.qualId()!.text
const id = this.getId(ctx)

if (name[0].match('[a-z]')) {
this.errors.push(lowercaseTypeError(id, name))
}
this.checkForUppercaseTypeName(id, name)

const def: QuintTypeDef = {
id,
Expand All @@ -319,9 +317,8 @@ export class ToIrListener implements QuintListener {
const type = this.popType().unwrap(() =>
fail('internal error: type alias declaration parsed with no right hand side')
)
if (name[0].match('[a-z]')) {
this.errors.push(lowercaseTypeError(id, name))
}

this.checkForUppercaseTypeName(id, name)

let defWithoutParams: QuintTypeDef = { id: id, kind: 'typedef', name, type }
const def: QuintTypeDef =
Expand Down Expand Up @@ -1297,6 +1294,15 @@ export class ToIrListener implements QuintListener {
}
}
}

private checkForUppercaseTypeName(id: bigint, qualifiedName: string) {
const parts = qualifiedName.split('::')
const unqualifiedName = parts.pop()!

if (unqualifiedName[0].match('[a-z]')) {
this.errors.push(lowercaseTypeError(id, unqualifiedName, parts))
}
}
}

function popMany<T>(stack: T[], n: number, defaultGen: () => T): T[] {
Expand Down
22 changes: 12 additions & 10 deletions quint/src/parsing/parseErrors.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import { QuintError } from '../quintError'

export function lowercaseTypeError(id: bigint, name: string): QuintError {
export function lowercaseTypeError(id: bigint, name: string, prefix: string[]): QuintError {
const original = [...prefix, name].join('::')
const newName = name[0].toUpperCase() + name.slice(1)
const replacement = [...prefix, newName].join('::')

return {
code: 'QNT007',
message: 'type names must start with an uppercase letter',
reference: id,
data: name[0].match('[a-z]')
? {
fix: {
kind: 'replace',
original: `type ${name[0]}`,
replacement: `type ${name[0].toUpperCase()}`,
},
}
: {},
data: {
fix: {
kind: 'replace',
original: `type ${original}`,
replacement: `type ${replacement}`,
},
},
}
}

Expand Down
2 changes: 1 addition & 1 deletion quint/src/version.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// Generated by genversion.
export const version = '0.21.1'
export const version = '0.21.2'
2 changes: 1 addition & 1 deletion quint/testFixture/SuperSpec.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion quint/testFixture/SuperSpec.map.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions quint/testFixture/SuperSpec.qnt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ module withConsts {
const MyRecord: { i: int, b: bool, s: str }
const MyRecordWithComma: { i: int, b: bool, s: str, }

// A type prefixed with a namespace
type some::namespace::MyType = int

// a disjoint union is a common pattern in TLA+
type MyUnionType =
| Circle(int)
Expand Down
9 changes: 9 additions & 0 deletions vscode/quint-vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
### Security

## v0.14.5 -- 2024-09-09

### Added
### Changed
### Deprecated
### Removed
### Fixed
### Security

## v0.14.4 -- 2024-05-22

### Added
Expand Down
4 changes: 2 additions & 2 deletions vscode/quint-vscode/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vscode/quint-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Quint",
"description": "Language support for Quint specifications",
"icon": "./icons/logo.png",
"version": "0.14.4",
"version": "0.14.5",
"publisher": "informal",
"engines": {
"vscode": "^1.52.0"
Expand Down
Loading

0 comments on commit c641178

Please sign in to comment.