-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closing #272: better diagnostics for recursive operators
- Loading branch information
Showing
8 changed files
with
103 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,27 @@ | ||
--------------------------- MODULE Rec10 ------------------------------------- | ||
(* | ||
* A regression test. | ||
* Recursive operators that are declared via instances should not fail. | ||
* A test for unfolding recursive definitions. | ||
* | ||
* Igor Konnov, April 2020 | ||
*) | ||
-------------------------------- MODULE test ------------------------------- | ||
----------------------------- MODULE inner --------------------------- | ||
RECURSIVE A(_) | ||
A(x) == IF x = 1 THEN 1 ELSE A(1) | ||
====================================================================== | ||
EXTENDS Integers | ||
|
||
VARIABLES f | ||
I == INSTANCE inner | ||
|
||
Init == f = I!A(0) | ||
RECURSIVE Fact(_) | ||
|
||
Next == UNCHANGED f | ||
Fact(n) == | ||
IF n <= 1 | ||
THEN 1 | ||
ELSE n * Fact(n - 1) | ||
|
||
Inv == TRUE | ||
============================================================================ | ||
Init == | ||
f = Fact(4) | ||
|
||
Next == | ||
f' = Fact(7) | ||
|
||
Inv == | ||
f >= 1 | ||
|
||
============================================================================= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--------------------------- MODULE Rec11 ------------------------------------- | ||
(* | ||
* A test for unfolding recursive definitions. | ||
* | ||
* Igor Konnov, April 2020 | ||
*) | ||
EXTENDS Integers | ||
|
||
VARIABLES f | ||
|
||
RECURSIVE Fact(_) | ||
|
||
Fact(n) == | ||
IF n <= 1 | ||
THEN 1 | ||
ELSE n * Fact(n - 1) | ||
|
||
\* define the default value | ||
UNROLL_DEFAULT_Fact == 0 | ||
|
||
\* but keep UNROLL_TIMES_Fact undefined | ||
\*UNROLL_TIMES_Fact == 4 | ||
|
||
Init == | ||
f = Fact(4) | ||
|
||
Next == | ||
f' = Fact(7) | ||
|
||
Inv == | ||
f >= 1 | ||
|
||
============================================================================= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters