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

feat: Proof refactoring suggestions #5812

Merged
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
21b942f
bump boogie
fabiomadge Oct 8, 2024
6651bdd
implemantation
fabiomadge Oct 8, 2024
26d7c54
Merge branch 'master' into proof_refactoring_suggestions
fabiomadge Oct 8, 2024
1f1c402
review
fabiomadge Oct 8, 2024
95299e1
style
fabiomadge Oct 8, 2024
a1ae235
avoid iterating over null
fabiomadge Oct 8, 2024
17eb6ff
tests
fabiomadge Oct 8, 2024
faff8df
bump boogie
fabiomadge Oct 15, 2024
c66fa0a
reintroduce rename error
fabiomadge Oct 15, 2024
42ed98d
Merge branch 'master' into proof_refactoring_suggestions
fabiomadge Oct 15, 2024
855e84f
fix patch
fabiomadge Oct 15, 2024
915bbcf
review
fabiomadge Oct 15, 2024
da63cb5
fix tests
fabiomadge Oct 15, 2024
3746748
regnerate doos
fabiomadge Oct 15, 2024
727ab27
review
fabiomadge Oct 15, 2024
6fb3807
review
fabiomadge Oct 16, 2024
661eaea
fix
fabiomadge Oct 16, 2024
8440d1f
Merge branch 'master' into proof_refactoring_suggestions
fabiomadge Oct 16, 2024
67073ee
fix tests
fabiomadge Oct 16, 2024
e3ca172
use different token
fabiomadge Oct 16, 2024
3c4be2f
review
fabiomadge Oct 16, 2024
a0e8acc
fix tests
fabiomadge Oct 16, 2024
4e067c5
Merge branch 'master' into proof_refactoring_suggestions
fabiomadge Oct 16, 2024
7f7f92d
fix tests
fabiomadge Oct 17, 2024
9bedde6
try update
fabiomadge Oct 17, 2024
804aa4c
try fix test
fabiomadge Oct 17, 2024
f6d6f60
try fix test
fabiomadge Oct 17, 2024
cfb066d
review
fabiomadge Oct 17, 2024
2e23507
update doos
fabiomadge Oct 17, 2024
93875b5
Merge branch 'master' into proof_refactoring_suggestions
keyboardDrummer Oct 18, 2024
fc00e6e
Update CommonOptionBag.cs
fabiomadge Oct 18, 2024
8d89dec
Update CommonOptionBag.cs
fabiomadge Oct 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/doc-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
path: dafny
- name: Load Z3
run: |
sudo apt-get install -qq libarchive-tools
sudo apt-get update && sudo apt-get install -qq libarchive-tools
mkdir -p dafny/Binaries/z3/bin
wget -qO- https://github.com/dafny-lang/solver-builds/releases/download/snapshot-2023-08-02/z3-4.12.1-x64-ubuntu-20.04-bin.zip | bsdtar -xf -
mv z3-* dafny/Binaries/z3/bin/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ jobs:
- name: Load Z3
if: "!inputs.all_platforms"
run: |
sudo apt-get install -qq libarchive-tools
sudo apt-get update && sudo apt-get install -qq libarchive-tools
mkdir -p dafny/Binaries/z3/bin
wget -qO- https://github.com/dafny-lang/solver-builds/releases/download/snapshot-2023-08-02/z3-4.12.1-x64-ubuntu-20.04-bin.zip | bsdtar -xf -
mv z3-4.12.1 dafny/Binaries/z3/bin/
Expand Down
37 changes: 24 additions & 13 deletions Source/DafnyCore/DafnyConsolePrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@

namespace Microsoft.Dafny;

public record AssertCmdPartialCopy(Boogie.IToken Tok, string Description, string Id);
public record VerificationRunResultPartialCopy(
int VCNum,
DateTime StartTime,
TimeSpan RunTime,
SolverOutcome Outcome,
List<AssertCmdPartialCopy> Asserts,
IEnumerable<TrackedNodeComponent> CoveredElements,
IEnumerable<Axiom> AvailableAxioms,
int ResourceCount);

public class DafnyConsolePrinter : ConsolePrinter {
public new DafnyOptions Options {
get => options;
Expand All @@ -21,19 +32,11 @@ public class DafnyConsolePrinter : ConsolePrinter {
private DafnyOptions options;

public record ImplementationLogEntry(string Name, Boogie.IToken Tok);
public record VCResultLogEntry(
int VCNum,
DateTime StartTime,
TimeSpan RunTime,
SolverOutcome Outcome,
List<(Boogie.IToken Tok, string Description)> Asserts,
IEnumerable<TrackedNodeComponent> CoveredElements,
int ResourceCount);
public record VerificationResultLogEntry(
VcOutcome Outcome,
TimeSpan RunTime,
int ResourceCount,
List<VCResultLogEntry> VCResults,
List<VerificationRunResultPartialCopy> VCResults,
List<Counterexample> Counterexamples);
public record ConsoleLogEntry(ImplementationLogEntry Implementation, VerificationResultLogEntry Result);

Expand All @@ -43,10 +46,18 @@ public static VerificationResultLogEntry DistillVerificationResult(Implementatio
verificationResult.ResourceCount, verificationResult.RunResults.Select(DistillVCResult).ToList(), verificationResult.Errors);
}

private static VCResultLogEntry DistillVCResult(VerificationRunResult r) {
return new VCResultLogEntry(r.VcNum, r.StartTime, r.RunTime, r.Outcome,
r.Asserts.Select(a => (a.tok, a.Description.SuccessDescription)).ToList(), r.CoveredElements,
r.ResourceCount);
public static VerificationRunResultPartialCopy DistillVCResult(VerificationRunResult r) {
return new VerificationRunResultPartialCopy(r.VcNum, r.StartTime, r.RunTime, r.Outcome,
r.Asserts.Select(a => new AssertCmdPartialCopy(a.tok, a.Description.SuccessDescription, GetId(a))).ToList(), r.CoveredElements,
r.DeclarationsAfterPruning.OfType<Axiom>(), r.ResourceCount);

string GetId(ICarriesAttributes construct) {
var values = construct.FindAllAttributes("id");
if (!values.Any()) {
return "";
}
return (string)values.Last().Params.First();
}
}

public ConcurrentBag<ConsoleLogEntry> VerificationResults { get; } = new();
Expand Down
2 changes: 1 addition & 1 deletion Source/DafnyCore/DafnyCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="System.Runtime.Numerics" Version="4.3.0" />
<PackageReference Include="System.Collections.Immutable" Version="1.7.1" />
<PackageReference Include="Boogie.ExecutionEngine" Version="3.2.5" />
<PackageReference Include="Boogie.ExecutionEngine" Version="3.3.3" />
<PackageReference Include="Tomlyn" Version="0.16.2" />
</ItemGroup>

Expand Down
15 changes: 15 additions & 0 deletions Source/DafnyCore/Options/CommonOptionBag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,15 @@ May produce spurious warnings.
May produce spurious warnings.") {
IsHidden = true
};
public static readonly Option<bool> SuggestProofRefactoring = new("--suggest-proof-refactoring", @"
(experimental) Emits suggestions for moving assertions into by-proofs and hiding unused function definitions.
May produce spurious suggestions. Use with --show-hints on the CLI.") {
IsHidden = true
};
public static readonly Option<bool> AnalyseProofs = new("--analyse-proofs", @"
(experimental) Implies --warn-contradictory-assumptions, --warn-redundant-assumptions, and --suggest-proof-refactoring") {
keyboardDrummer marked this conversation as resolved.
Show resolved Hide resolved
IsHidden = true
};
public static readonly Option<string> VerificationCoverageReport = new("--verification-coverage-report",
"Emit verification coverage report to a given directory, in the same format as a test coverage report.") {
ArgumentHelpName = "directory"
Expand Down Expand Up @@ -461,6 +470,7 @@ statements in implementation methods. It also disables anything

DafnyOptions.RegisterLegacyUi(WarnContradictoryAssumptions, DafnyOptions.ParseImplicitEnable, "Verification options", "warnContradictoryAssumptions");
DafnyOptions.RegisterLegacyUi(WarnRedundantAssumptions, DafnyOptions.ParseImplicitEnable, "Verification options", "warnRedundantAssumptions");
DafnyOptions.RegisterLegacyUi(SuggestProofRefactoring, DafnyOptions.ParseImplicitEnable, "Verification options", "suggestProofRefactoring");

void ParsePrintMode(Option<PrintModes> option, Boogie.CommandLineParseState ps, DafnyOptions options) {
if (ps.ConfirmArgumentCount(1)) {
Expand Down Expand Up @@ -514,6 +524,9 @@ void ParsePrintMode(Option<PrintModes> option, Boogie.CommandLineParseState ps,
DafnyOptions.RegisterLegacyBinding(WarnRedundantAssumptions, (options, value) => {
if (value) { options.TrackVerificationCoverage = true; }
});
DafnyOptions.RegisterLegacyBinding(SuggestProofRefactoring, (options, value) => {
if (value) { options.TrackVerificationCoverage = true; }
});

DafnyOptions.RegisterLegacyBinding(Target, (options, value) => { options.CompilerName = value; });

Expand Down Expand Up @@ -621,6 +634,8 @@ void ParsePrintMode(Option<PrintModes> option, Boogie.CommandLineParseState ps,
OptionRegistry.RegisterOption(InternalIncludeRuntimeOptionForExecution, OptionScope.Cli);
OptionRegistry.RegisterOption(WarnContradictoryAssumptions, OptionScope.Module);
OptionRegistry.RegisterOption(WarnRedundantAssumptions, OptionScope.Module);
OptionRegistry.RegisterOption(SuggestProofRefactoring, OptionScope.Module);
OptionRegistry.RegisterOption(AnalyseProofs, OptionScope.Module);
OptionRegistry.RegisterOption(VerificationCoverageReport, OptionScope.Cli);
OptionRegistry.RegisterOption(NoTimeStampForCoverageReport, OptionScope.Cli);
OptionRegistry.RegisterOption(DefaultFunctionOpacity, OptionScope.Module);
Expand Down
2 changes: 2 additions & 0 deletions Source/DafnyCore/Options/DafnyCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ static DafnyCommands() {
CommonOptionBag.DefaultFunctionOpacity,
CommonOptionBag.WarnContradictoryAssumptions,
CommonOptionBag.WarnRedundantAssumptions,
CommonOptionBag.SuggestProofRefactoring,
CommonOptionBag.AnalyseProofs,
CommonOptionBag.NoTimeStampForCoverageReport,
CommonOptionBag.VerificationCoverageReport,
CommonOptionBag.ExtractCounterexample,
Expand Down
1 change: 0 additions & 1 deletion Source/DafnyCore/Pipeline/Compilation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
using System.Linq;
using System.Reactive;
Expand Down
Loading
Loading