You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
178
179
179
180
## 11.2. Attributes on functions and methods
@@ -276,6 +277,7 @@ although it is free to read and write newly allocated objects.
276
277
See [`{:extern <name>}`](#sec-extern).
277
278
278
279
### 11.2.8. `{:fuel X}` {#sec-fuel}
280
+
279
281
The fuel attribute is used to specify how much "fuel" a function should have,
280
282
i.e., how many times the verifier is permitted to unfold its definition. The
281
283
`{:fuel}` annotation can be added to the function itself, in which
@@ -323,13 +325,11 @@ The two contexts are:
323
325
324
326
The form of the `{:induction}` attribute is one of the following:
325
327
326
-
*`{:induction}` -- apply induction to all bound variables
328
+
*`{:induction}`or `{:induction true}`-- apply induction to all bound variables
327
329
*`{: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
329
331
-- 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.
333
333
334
334
Here is an example of using it on a quantifier expression:
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).
`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).
358
363
@@ -379,7 +384,7 @@ method TestUnverified() {
379
384
380
385
More information about the Boogie implementation of `{:opaque}` is [here](https://github.com/dafny-lang/dafny/blob/master/docs/Compilation/Boogie.md).
381
386
382
-
### 11.2.12. `{:print}` {#sec-print}
387
+
### 11.2.13. `{:print}` {#sec-print}
383
388
This attribute declares that a method may have print effects,
384
389
that is, it may use `print` statements and may call other methods
385
390
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
389
394
does.
390
395
Print effects are enforced only with `--track-print-effects`.
391
396
392
-
### 11.2.13. `{:priority}`
397
+
### 11.2.14. `{:priority}`
393
398
`{:priority N}` assigns a positive priority 'N' to a method or function to control the order
394
399
in which methods or functions are verified (default: N = 1).
395
400
396
-
### 11.2.14. `{:resource_limit}` and `{:rlimit}` {#sec-rlimit}
401
+
### 11.2.15. `{:resource_limit}` and `{:rlimit}` {#sec-rlimit}
397
402
398
403
`{:resource_limit N}` limits the verifier resource usage to verify the method or function to `N`.
399
404
@@ -442,14 +447,14 @@ To give orders of magnitude about resource usage, here is a list of examples ind
442
447
443
448
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`.
444
449
445
-
### 11.2.15. `{:selective_checking}`
450
+
### 11.2.16. `{:selective_checking}`
446
451
Turn all assertions into assumptions except for the ones reachable from after the
447
452
assertions marked with the attribute `{:start_checking_here}`.
448
453
Thus, `assume {:start_checking_here} something;` becomes an inverse
449
454
of `assume false;`: the first one disables all verification before
450
455
it, and the second one disables all verification after.
451
456
452
-
### 11.2.16. `{:tailrecursion}`
457
+
### 11.2.17. `{:tailrecursion}`
453
458
This attribute is used on method or function declarations. It has a boolean argument.
454
459
455
460
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
539
544
the tail closer to where it's used or switching the order of computing
540
545
`r` and `tail`, but the `by method` body can stay the same.
541
546
542
-
### 11.2.17. `{:test}` {#sec-test-attribute}
547
+
### 11.2.18. `{:test}` {#sec-test-attribute}
543
548
This attribute indicates the target function or method is meant
544
549
to be executed at runtime in order to test that the program is working as intended.
545
550
@@ -577,22 +582,22 @@ harness that supplies input arguments but has no inputs of its own and that
577
582
checks any output values, perhaps with `expect` statements. The test harness
578
583
is then the method marked with `{:test}`.
579
584
580
-
### 11.2.18. `{:timeLimit N}` {#sec-time-limit}
585
+
### 11.2.19. `{:timeLimit N}` {#sec-time-limit}
581
586
Set the time limit for verifying a given function or method.
582
587
583
-
### 11.2.19. `{:timeLimitMultiplier X}`
588
+
### 11.2.20. `{:timeLimitMultiplier X}`
584
589
This attribute may be placed on a method or function declaration
585
590
and has an integer argument. If `{:timeLimitMultiplier X}` was
586
591
specified a `{:timeLimit Y}` attribute is passed on to Boogie
587
592
where `Y` is `X` times either the default verification time limit
588
593
for a function or method, or times the value specified by the
589
594
Boogie `-timeLimit` command-line option.
590
595
591
-
### 11.2.20. `{:transparent}` {#sec-transparent}
596
+
### 11.2.21. `{:transparent}` {#sec-transparent}
592
597
593
598
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.
594
599
595
-
### 11.2.21. `{:verify false}` {#sec-verify}
600
+
### 11.2.22. `{:verify false}` {#sec-verify}
596
601
597
602
Skip verification of a function or a method altogether,
598
603
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
601
606
602
607
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.
This attribute applies only to modules. It configures Dafny as if
676
681
`OPT0`, `OPT1`, … had been passed on the command line. Outside of the module,
@@ -1001,4 +1006,67 @@ following attributes.
1001
1006
*`{:weight}`
1002
1007
*`{:yields}`
1003
1008
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:
0 commit comments