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

Add script to run Boogie with the args Dafny uses #4492

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
4 changes: 4 additions & 0 deletions Scripts/dafny_boogie.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
ROOT=$(dirname $(dirname "${BASH_SOURCE[0]}"))
BOOGIE_ARGS=$(sed -e 's|^|-|' "${ROOT}"/Test/boogie-args.cfg | sed -e "s|{ROOT}|$ROOT|")
dotnet tool run boogie $BOOGIE_ARGS "$@"
16 changes: 6 additions & 10 deletions Source/IntegrationTests/LitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,7 @@ public class LitTests {

private static readonly string RepositoryRoot = Path.GetFullPath("../../../../../"); // Up from Source/IntegrationTests/bin/Debug/net6.0/

private static readonly string[] DefaultBoogieArguments = new[] {
"/infer:j",
"/proverOpt:O:auto_config=false",
"/proverOpt:O:type_check=true",
"/proverOpt:O:smt.case_split=3",
"/proverOpt:O:smt.qi.eager_threshold=100",
"/proverOpt:O:smt.delay_units=true",
"/proverOpt:O:smt.arith.solver=2",
"/proverOpt:PROVER_PATH:" + RepositoryRoot + $"Binaries/z3/bin/z3-{DafnyOptions.DefaultZ3Version}"
};
private static readonly string[] DefaultBoogieArguments;

private static readonly LitTestConfiguration Config;

Expand Down Expand Up @@ -68,6 +59,11 @@ public class LitTests {
{ "%repositoryRoot", RepositoryRoot.Replace(@"\", "/") },
};

DefaultBoogieArguments =
File.ReadAllLines(RepositoryRoot + "Test/boogie-args.cfg")
.Select(arg => "-" + arg.Replace("{ROOT}", RepositoryRoot))
.ToArray();

var commands = new Dictionary<string, Func<IEnumerable<string>, LitTestConfiguration, ILitCommand>> {
{
"%baredafny", (args, config) =>
Expand Down
12 changes: 12 additions & 0 deletions Test/boogie-args.cfg
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this deserves to be under Source somewhere rather than hidden under Test, since it's an alternate expression of how Dafny configures Boogie.

On that note, is there any way to assert that these are equivalent to what options Dafny actually sets through the library interface?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would really like to be able to guarantee that they're equivalent. I haven't thought of a good way to do it yet, but that doesn't mean there isn't one!

Until there is one, it feels weird to put it under Source when nothing in that directory uses it, but stuff in Test does.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this fix issue 2800, or would a slight addition to this PR fix it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's still some more work we'd need to do to ensure that's correct. We could add some code to copy the contents of this new file to the top of the generated Boogie file, but there's currently no guarantee that that would match what Dafny uses.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
infer:j
normalizeDeclarationOrder:1
normalizeNames:1
typeEncoding:a
prune
proverOpt:O:auto_config=false
proverOpt:O:type_check=true
proverOpt:O:smt.case_split=3
proverOpt:O:smt.qi.eager_threshold=100
proverOpt:O:smt.delay_units=true
proverOpt:O:smt.arith.solver=2
proverOpt:PROVER_PATH:{ROOT}/Binaries/z3/bin/z3-4.12.1
42 changes: 18 additions & 24 deletions Test/lit.site.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,21 @@ boogieExecutable = 'dotnet tool run boogie'

config.suffixes.append('.transcript')

def find(name, rooot):
for root, dirs, files in os.walk(rooot):
for file in files:
if file.endswith(name):
return name
return ""

solverPath = \
find("z3-4.12.1", binaryDir) or \
find("cvc4", binaryDir)

if not solverPath:
lit_config.fatal('Could not find solver')
config.substitutions.append( ('%z3', solverPath ) )

dafnyArgs = [
# We do not want absolute or relative paths in error messages, just the basename of the file
'useBaseNameForFileName',
Expand All @@ -128,15 +143,9 @@ dafnyArgs = [
'timeLimit:300'
]

boogieArgs = [
'infer:j',
'proverOpt:O:auto_config=false',
'proverOpt:O:type_check=true',
'proverOpt:O:smt.case_split=3',
'proverOpt:O:smt.qi.eager_threshold=100',
'proverOpt:O:smt.delay_units=true',
'proverOpt:O:smt.arith.solver=2'
]
boogieArgs = ""
with open(repositoryRoot + '/Test/boogie-args.cfg', 'r') as boogieArgFile:
boogieArgs = boogieArgFile.read().replace('{ROOT}', repositoryRoot).splitlines()

# Add standard parameters
def addParams(cmd):
Expand Down Expand Up @@ -200,21 +209,6 @@ elif "18.04" in ver and "Ubuntu" in ver:
else:
config.available_features = [ 'ubuntu', 'posix' ]

def find(name, rooot):
for root, dirs, files in os.walk(rooot):
for file in files:
if file.endswith(name):
return name
return ""

solverPath = \
find("z3-4.12.1", binaryDir) or \
find("cvc4", binaryDir)

if not solverPath:
lit_config.fatal('Could not find solver')
config.substitutions.append( ('%z3', solverPath ) )

# Add diff tool substitution
commonDiffFlags=' --unified=3 --strip-trailing-cr'
diffExecutable = None
Expand Down
4 changes: 2 additions & 2 deletions dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
]
},
"boogie": {
"version": "2.16.0",
"version": "3.0.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(blocking) Should be 3.0.0 to match the actual dependency: https://github.com/dafny-lang/dafny/blob/master/Source/DafnyCore/DafnyCore.csproj#L35

Ideally we'd at least have a test that asserts they are the same somehow, if not an actual way of keeping them in sync automatically.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, oops. I was using 3.0.1 in my proof dependency PR and forgot it wasn't merged yet. :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll see if I can construct a test that compares the versions without too much effort.

"commands": [
"boogie"
]
}
}
}
}
Loading