diff options
| author | Nicolas James <Eele1Ephe7uZahRie@tutanota.com> | 2025-02-13 18:00:17 +1100 |
|---|---|---|
| committer | Nicolas James <Eele1Ephe7uZahRie@tutanota.com> | 2025-02-13 18:00:17 +1100 |
| commit | 98cef5e9a772602d42acfcf233838c760424db9a (patch) | |
| tree | 5277fa1d7cc0a69a0f166fcbf10fd320f345f049 /seng2011/1/ex4.dfy | |
initial commit
Diffstat (limited to 'seng2011/1/ex4.dfy')
| -rw-r--r-- | seng2011/1/ex4.dfy | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/seng2011/1/ex4.dfy b/seng2011/1/ex4.dfy new file mode 100644 index 0000000..900ac48 --- /dev/null +++ b/seng2011/1/ex4.dfy @@ -0,0 +1,15 @@ +method Eval(x:int) returns (r:int) +requires x > 0; +ensures r == x * x; +{ + var y:int := x; + var z:int := 0; + while (y >0) + decreases y + invariant (y >= 0 && y <= x && z == x * (x - y)); + { + z := z + x; + y := y - 1; + } + return z; +} |
