Skip to content

Commit 78de2ea

Browse files
authored
chore: Add v4.9.1 (#45)
1 parent 880cccb commit 78de2ea

File tree

425 files changed

+51433
-154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

425 files changed

+51433
-154
lines changed

latest/DafnyRef/Attributes.md

Lines changed: 91 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# 11. Attributes {#sec-attributes}
2+
23
Dafny allows many of its entities to be annotated with _Attributes_.
34
Attributes are declared between `{:` and `}` like this:
45
<!-- %no-check -->
@@ -173,7 +174,7 @@ Dafny does not perform sanity checks on the arguments---it is the user's respons
173174

174175
For more detail on the use of `{:extern}`, see the corresponding [section](#sec-extern-decls) in the user's guide.
175176

176-
### 11.1.5. `{:disable-nonlinear-arithmetic}` {#sec-disable-nonlinear-arithmetic}
177+
### 11.1.5. `{:disableNonlinearArithmetic}` {#sec-disable-nonlinear-arithmetic}
177178
This attribute only applies to module declarations. It overrides the global option `--disable-nonlinear-arithmetic` for that specific module. The attribute can be given true or false to disable or enable nonlinear arithmetic. When no value is given, the default value is true.
178179

179180
## 11.2. Attributes on functions and methods
@@ -276,6 +277,7 @@ although it is free to read and write newly allocated objects.
276277
See [`{:extern <name>}`](#sec-extern).
277278

278279
### 11.2.8. `{:fuel X}` {#sec-fuel}
280+
279281
The fuel attribute is used to specify how much "fuel" a function should have,
280282
i.e., how many times the verifier is permitted to unfold its definition. The
281283
`{:fuel}` annotation can be added to the function itself, in which
@@ -323,13 +325,11 @@ The two contexts are:
323325

324326
The form of the `{:induction}` attribute is one of the following:
325327

326-
* `{:induction}` -- apply induction to all bound variables
328+
* `{:induction}` or `{:induction true}` -- apply induction to all bound variables
327329
* `{:induction false}` -- suppress induction, that is, don't apply it to any bound variable
328-
* `{:induction L}` where `L` is a list consisting entirely of bound variables
330+
* `{:induction L}` where `L` is a sublist of the bound variables
329331
-- apply induction to the specified bound variables
330-
* `{:induction X}` where `X` is anything else -- treat the same as
331-
`{:induction}`, that is, apply induction to all bound variables. For this
332-
usage conventionally `X` is `true`.
332+
* `{:induction X}` where `X` is anything else -- raise an error.
333333

334334
Here is an example of using it on a quantifier expression:
335335
<!-- %check-verify -->
@@ -352,7 +352,12 @@ lemma Correspondence()
352352
}
353353
```
354354

355-
### 11.2.11. `{:only}` {#sec-only-functions-methods}
355+
356+
### 11.2.11. `{:inductionTrigger}` {#sec-induction-trigger}
357+
358+
Dafny automatically generates triggers for quantified induction hypotheses. The default selection can be overridden using the `{:inductionTrigger}` attribute, which works like the usual [`{:trigger}` attribute](#sec-trigger).
359+
360+
### 11.2.12. `{:only}` {#sec-only-functions-methods}
356361

357362
`method {:only} X() {}` or `function {:only} X() {}` temporarily disables the verification of all other non-`{:only}` members, e.g. other functions and methods, in the same file, even if they contain [assertions with `{:only}`](#sec-only).
358363

@@ -379,7 +384,7 @@ method TestUnverified() {
379384

380385
More information about the Boogie implementation of `{:opaque}` is [here](https://github.com/dafny-lang/dafny/blob/master/docs/Compilation/Boogie.md).
381386

382-
### 11.2.12. `{:print}` {#sec-print}
387+
### 11.2.13. `{:print}` {#sec-print}
383388
This attribute declares that a method may have print effects,
384389
that is, it may use `print` statements and may call other methods
385390
that have print effects. The attribute can be applied to compiled
@@ -389,11 +394,11 @@ allowed to use a `{:print}` attribute only if the overridden method
389394
does.
390395
Print effects are enforced only with `--track-print-effects`.
391396

392-
### 11.2.13. `{:priority}`
397+
### 11.2.14. `{:priority}`
393398
`{:priority N}` assigns a positive priority 'N' to a method or function to control the order
394399
in which methods or functions are verified (default: N = 1).
395400

396-
### 11.2.14. `{:resource_limit}` and `{:rlimit}` {#sec-rlimit}
401+
### 11.2.15. `{:resource_limit}` and `{:rlimit}` {#sec-rlimit}
397402

398403
`{:resource_limit N}` limits the verifier resource usage to verify the method or function to `N`.
399404

@@ -442,14 +447,14 @@ To give orders of magnitude about resource usage, here is a list of examples ind
442447

443448
Note that, the default solver Z3 tends to overshoot by `7K` to `8K`, so if you put `{:rlimit 20}` in the last example, the total resource usage would be `27K`.
444449

445-
### 11.2.15. `{:selective_checking}`
450+
### 11.2.16. `{:selective_checking}`
446451
Turn all assertions into assumptions except for the ones reachable from after the
447452
assertions marked with the attribute `{:start_checking_here}`.
448453
Thus, `assume {:start_checking_here} something;` becomes an inverse
449454
of `assume false;`: the first one disables all verification before
450455
it, and the second one disables all verification after.
451456

452-
### 11.2.16. `{:tailrecursion}`
457+
### 11.2.17. `{:tailrecursion}`
453458
This attribute is used on method or function declarations. It has a boolean argument.
454459

455460
If specified with a `false` value, it means the user specifically
@@ -539,7 +544,7 @@ Note that the function definition can be changed by computing
539544
the tail closer to where it's used or switching the order of computing
540545
`r` and `tail`, but the `by method` body can stay the same.
541546

542-
### 11.2.17. `{:test}` {#sec-test-attribute}
547+
### 11.2.18. `{:test}` {#sec-test-attribute}
543548
This attribute indicates the target function or method is meant
544549
to be executed at runtime in order to test that the program is working as intended.
545550

@@ -577,22 +582,22 @@ harness that supplies input arguments but has no inputs of its own and that
577582
checks any output values, perhaps with `expect` statements. The test harness
578583
is then the method marked with `{:test}`.
579584

580-
### 11.2.18. `{:timeLimit N}` {#sec-time-limit}
585+
### 11.2.19. `{:timeLimit N}` {#sec-time-limit}
581586
Set the time limit for verifying a given function or method.
582587

583-
### 11.2.19. `{:timeLimitMultiplier X}`
588+
### 11.2.20. `{:timeLimitMultiplier X}`
584589
This attribute may be placed on a method or function declaration
585590
and has an integer argument. If `{:timeLimitMultiplier X}` was
586591
specified a `{:timeLimit Y}` attribute is passed on to Boogie
587592
where `Y` is `X` times either the default verification time limit
588593
for a function or method, or times the value specified by the
589594
Boogie `-timeLimit` command-line option.
590595

591-
### 11.2.20. `{:transparent}` {#sec-transparent}
596+
### 11.2.21. `{:transparent}` {#sec-transparent}
592597

593598
By default, the body of a function is transparent to its users. This can be overridden using the `--default-function-opacity` command line flag. If default function opacity is set to `opaque` or `autoRevealDependencies`, then this attribute can be used on functions to make them always non-opaque.
594599

595-
### 11.2.21. `{:verify false}` {#sec-verify}
600+
### 11.2.22. `{:verify false}` {#sec-verify}
596601
597602
Skip verification of a function or a method altogether,
598603
not even trying to verify the [well-formedness](#sec-assertion-batches) of postconditions and preconditions.
@@ -601,7 +606,7 @@ which performs these minimal checks while not checking that the body satisfies t
601606

602607
If you simply want to temporarily disable all verification except on a single function or method, use the [`{:only}`](#sec-only-functions-methods) attribute on that function or method.
603608

604-
### 11.2.22. `{:vcs_max_cost N}` {#sec-vcs_max_cost}
609+
### 11.2.23. `{:vcs_max_cost N}` {#sec-vcs_max_cost}
605610
Per-method version of the command-line option `/vcsMaxCost`.
606611

607612
The [assertion batch](#sec-assertion-batches) of a method
@@ -610,7 +615,7 @@ number, defaults to 2000.0. In
610615
[keep-going mode](#sec-vcs_max_keep_going_splits), only applies to the first round.
611616
If [`{:isolate_assertions}`](#sec-isolate_assertions) is set, then this parameter is useless.
612617

613-
### 11.2.23. `{:vcs_max_keep_going_splits N}` {#sec-vcs_max_keep_going_splits}
618+
### 11.2.24. `{:vcs_max_keep_going_splits N}` {#sec-vcs_max_keep_going_splits}
614619

615620
Per-method version of the command-line option `/vcsMaxKeepGoingSplits`.
616621
If set to more than 1, activates the _keep going mode_ where, after the first round of splitting,
@@ -621,22 +626,22 @@ case an error is reported for that assertion).
621626
Defaults to 1.
622627
If [`{:isolate_assertions}`](#sec-isolate_assertions) is set, then this parameter is useless.
623628

624-
### 11.2.24. `{:vcs_max_splits N}` {#sec-vcs_max_splits}
629+
### 11.2.25. `{:vcs_max_splits N}` {#sec-vcs_max_splits}
625630

626631
Per-method version of the command-line option `/vcsMaxSplits`.
627632
Maximal number of [assertion batches](#sec-assertion-batches) generated for this method.
628633
In [keep-going mode](#sec-vcs_max_keep_going_splits), only applies to the first round.
629634
Defaults to 1.
630635
If [`{:isolate_assertions}`](#sec-isolate_assertions) is set, then this parameter is useless.
631636

632-
### 11.2.25. `{:isolate_assertions}` {#sec-isolate_assertions}
637+
### 11.2.26. `{:isolate_assertions}` {#sec-isolate_assertions}
633638
Per-method version of the command-line option<span id="sec-vcs_split_on_every_assert"></span> `/vcsSplitOnEveryAssert`
634639

635640
In the first and only verification round, this option will split the original [assertion batch](#sec-assertion-batches)
636641
into one assertion batch per assertion.
637642
This is mostly helpful for debugging which assertion is taking the most time to prove, e.g. to profile them.
638643

639-
### 11.2.26. `{:synthesize}` {#sec-synthesize-attr}
644+
### 11.2.27. `{:synthesize}` {#sec-synthesize-attr}
640645

641646
The `{:synthesize}` attribute must be used on methods that have no body and
642647
return one or more fresh objects. During compilation,
@@ -670,7 +675,7 @@ BOUNDVARS = ID : ID
670675
| BOUNDVARS, BOUNDVARS
671676
```
672677

673-
### 11.2.27. `{:options OPT0, OPT1, ... }` {#sec-attr-options}
678+
### 11.2.28. `{:options OPT0, OPT1, ... }` {#sec-attr-options}
674679

675680
This attribute applies only to modules. It configures Dafny as if
676681
`OPT0`, `OPT1`, … had been passed on the command line. Outside of the module,
@@ -1001,4 +1006,67 @@ following attributes.
10011006
* `{:weight}`
10021007
* `{:yields}`
10031008

1009+
## 11.9. New attribute syntax {#sec-at-attributes}
1010+
1011+
There is a new syntax for typed prefix attributes that is being added: `@Attribute(...)`.
1012+
For now, the new syntax works only as top-level declarations. When all previous attributes will be migrated, this section will be rewritten. For example, you can write
1013+
1014+
<!-- %check-resolve -->
1015+
```dafny
1016+
@IsolateAssertions
1017+
method Test() {
1018+
}
1019+
```
1020+
1021+
instead of
1022+
1023+
<!-- %check-resolve -->
1024+
```dafny
1025+
method {:isolate_assertions} Test() {
1026+
}
1027+
```
1028+
1029+
1030+
Dafny rewrites `@`-attributes to old-style equivalent attributes. The definition of these attributes is similar to the following:
1031+
1032+
<!-- %no-check -->
1033+
```dafny
1034+
datatype Attribute =
1035+
| AutoContracts
1036+
| AutoRequires
1037+
| AutoRevealDependenciesAll
1038+
| AutoRevealDependencies
1039+
| Axiom
1040+
| Compile(bool)
1041+
| Concurrent
1042+
| DisableNonlinearArithmetic
1043+
| Fuel(low: int, high: int := low + 1, functionName: string := "")
1044+
| IsolateAssertions
1045+
| NativeUInt8 | NativeInt8 ... | NativeUInt128 | NativeInt128 | NativeInt | NativeNone | NativeIntOrReal
1046+
| Options(string)
1047+
| Print
1048+
| Priority(weight: int)
1049+
| ResourceLimit(value: string)
1050+
| Synthesize
1051+
| TimeLimit(amount: int)
1052+
| TimeLimitMultiplier(multiplier: int)
1053+
| TailRecursion
1054+
| Test
1055+
| TestEntry
1056+
| TestInline(amount: int)
1057+
| Transparent
1058+
| VcsMaxCost
1059+
| VcsMaxKeepGoingSplits
1060+
| VcsMaxSplits
1061+
| Verify(verify: bool)
1062+
| VerifyOnly
1063+
1064+
```
1065+
1066+
@-attributes have the same checks as regular resolved datatype values
1067+
* The attribute should exist
1068+
* Arguments should be compatible with the parameters, like for a datatype constructor call
10041069

1070+
However, @-attributes have more checks:
1071+
* The attribute should be applied to a place where it can be used by Dafny
1072+
* Arguments should be literals
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
text.dfy(2,9): Error: assertion might not hold
1+
text.dfy(2,11): Error: assertion might not hold
22

33
Dafny program verifier finished with 0 verified, 1 error

latest/DafnyRef/Expressions.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,11 +1878,12 @@ internal. However, it can be written as a Dafny expression using the
18781878
`decreases to` operator.
18791879

18801880
The Boolean expression `(a, ..., b decreases to a', ..., b')` encodes
1881-
this ordering. For example, the following assertions are valid:
1881+
this ordering. (The parentheses can be omitted if there is exactly 1 left-hand side
1882+
and exactly 1 right-hand side.) For example, the following assertions are valid:
18821883
<!-- %check-verify -->
18831884
```dafny
18841885
method M(x: int, y: int) {
1885-
assert (1 decreases to 0);
1886+
assert 1 decreases to 0;
18861887
assert (true, false decreases to false, true);
18871888
assert (x, y decreases to x - 1, y);
18881889
}
@@ -1892,12 +1893,12 @@ Conversely, the following assertion is invalid:
18921893
<!-- %check-verify Expressions.5.expect -->
18931894
```dafny
18941895
method M(x: int, y: int) {
1895-
assert (x decreases to x + 1);
1896+
assert x decreases to x + 1;
18961897
}
18971898
```
18981899

1899-
Currently, `decreases to` expressions must be written in parentheses to
1900-
avoid parsing ambiguities.
1900+
The `decreases to` operator is strict, that is, it means "strictly greater than".
1901+
The `nonincreases to` operator is the non-strict ("greater than or equal") version of it.
19011902

19021903
## 9.39. Compile-Time Constants {#sec-compile-time-constants}
19031904

0 commit comments

Comments
 (0)