Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parity in Counterexample-Related Z3 Options for Command-Line vs Language Server #4792

Merged
merged 15 commits into from
Jan 22, 2024
Prev Previous commit
Next Next commit
Fix variable printing order and update tests
  • Loading branch information
Aleksandr Fedchin committed Jan 19, 2024
commit 0d7789f4633a4a00ee0063490fce4357c7a097db
2 changes: 1 addition & 1 deletion Source/DafnyDriver/CompilerDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ private static void PrintCounterexample(DafnyOptions options) {
var model = new DafnyModel(firstCounterexample.Model, options);
options.OutputWriter.WriteLine("Counterexample for first failing assertion: ");
foreach (var state in model.States.Where(state => state.StateContainsPosition())) {
options.OutputWriter.WriteLine($"at State {state.FullStateName}:");
options.OutputWriter.WriteLine(state.FullStateName + ":");
var vars = state.ExpandedVariableSet(-1);
foreach (var variable in vars) {
options.OutputWriter.WriteLine($"\t{variable.ShortName} : " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ internal DafnyModelState(DafnyModel model, Model.CapturedState state) {
/// <param name="maxDepth">The maximum depth up to which to expand the
/// variable set.</param>
/// <returns>Set of variables</returns>
public HashSet<DafnyModelVariable> ExpandedVariableSet(int maxDepth) {
HashSet<DafnyModelVariable> expandedSet = new();
public List<DafnyModelVariable> ExpandedVariableSet(int maxDepth) {
List<DafnyModelVariable> expandedSet = new();
// The following is the queue for elements to be added to the set. The 2nd
// element of a tuple is the depth of the variable w.r.t. the original set
List<Tuple<DafnyModelVariable, int>> varsToAdd = new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private IEnumerable<CounterExampleItem> GetCounterExamples(DafnyModel model) {
}

private CounterExampleItem GetCounterExample(DafnyModelState state) {
HashSet<DafnyModelVariable> vars = state.ExpandedVariableSet(counterExampleDepth);
List<DafnyModelVariable> vars = state.ExpandedVariableSet(counterExampleDepth);
return new(
new Position(state.GetLineId() - 1, state.GetCharId()),
vars.WithCancellation(cancellationToken).ToDictionary(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@ git-issue-2026.dfy(18,18): Related message: loop invariant violation

Dafny program verifier finished with 0 verified, 1 error
Counterexample for first failing assertion:
at State git-issue-2026.dfy(12,0): initial state:
git-issue-2026.dfy(12,0): initial state:
n : int = 2
ret : _System.array<seq<char>> = ()
at State git-issue-2026.dfy(13,24):
git-issue-2026.dfy(13,24):
n : int = 2
ret : _System.array?<seq<char>> = (Length := 2, [(- 7720)] := @0, [0] := @0)
@0 : seq<char> = ['o', 'd', 'd']
at State git-issue-2026.dfy(15,14):
git-issue-2026.dfy(15,14):
n : int = 2
ret : _System.array?<seq<char>> = (Length := 2, [(- 7720)] := @0, [0] := @0)
i : int = 0
@0 : seq<char> = ['o', 'd', 'd']
at State git-issue-2026.dfy(16,4): after some loop iterations:
git-issue-2026.dfy(16,4): after some loop iterations:
n : int = 2
ret : _System.array?<seq<char>> = (Length := 2, [(- 7720)] := @0)
i : int = 0
@0 : seq<char> = ['o', 'd', 'd']
at State git-issue-2026.dfy(22,27):
git-issue-2026.dfy(22,27):
n : int = 2
ret : _System.array?<seq<char>> = (Length := 2, [(- 7720)] := @0, [0] := @0)
i : int = 0
@0 : seq<char> = ['o', 'd', 'd']
at State git-issue-2026.dfy(26,18):
git-issue-2026.dfy(26,18):
n : int = 2
ret : _System.array?<seq<char>> = (Length := 2, [(- 7720)] := @0, [0] := @0)
i : int = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ counterexample_commandline.dfy(18,22): Related location: this is the postconditi

Dafny program verifier finished with 1 verified, 1 error
Counterexample for first failing assertion:
at State counterexample_commandline.dfy(21,8): initial state:
counterexample_commandline.dfy(21,8): initial state:
this : Patterns.Simple = (p := @0)
s : seq<char> = ['A']
@0 : seq<char> = ['?']
at State counterexample_commandline.dfy(22,22):
counterexample_commandline.dfy(22,22):
this : Patterns.Simple = (p := @0)
s : seq<char> = ['A']
i : int = 0
@0 : seq<char> = ['?']
at State counterexample_commandline.dfy(23,12): after some loop iterations:
counterexample_commandline.dfy(23,12): after some loop iterations:
this : Patterns.Simple = (p := @0)
s : seq<char> = ['A']
i : int = 0
@0 : seq<char> = ['?']
at State counterexample_commandline.dfy(30,32):
counterexample_commandline.dfy(30,32):
this : Patterns.Simple = (p := @0)
s : seq<char> = ['A']
i : int = 0
Expand Down
Loading