Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
why3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
120
Issues
120
List
Boards
Labels
Service Desk
Milestones
Merge Requests
17
Merge Requests
17
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Why3
why3
Commits
24fc5f16
Commit
24fc5f16
authored
Apr 01, 2014
by
Léon Gondelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new example for balance
parent
37162168
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
274 additions
and
31 deletions
+274
-31
examples/balance.mlw
examples/balance.mlw
+64
-0
examples/balance/why3session.xml
examples/balance/why3session.xml
+210
-31
No files found.
examples/balance.mlw
View file @
24fc5f16
...
...
@@ -50,3 +50,67 @@ module Balance
if balls[6] < balls[7] then 6 else 7
end
module Balance12
use import int.Int
use import array.Array
(* All values in balls[lo..hi[ are equal to [w], apart from balls[lb]
which is of a different weight (lighter or heavier) . *)
predicate spec (balls: array int) (lo hi j: int) (w: int) (b: bool) =
0 <= lo <= j < hi <= length balls &&
(forall i: int. lo <= i < hi -> i <> j -> balls[i] = w) &&
(if b then balls[j] < w else balls[j] > w)
(* j : the index of the different ball,
b : the status (lighter or heavier) of the different ball
False True meaning heavier and True meaining lighter *)
let solve12 (balls: array int) (ghost w j: int) (ghost b: bool) : (int, bool)
requires { spec balls 0 12 j w b }
ensures { result = (j, b) }
=
if balls[0] + balls[1] + balls[2] + balls[3] =
balls[4] + balls[5] + balls[6] + balls[7]
then
if balls[0] + balls[8] = balls[9] + balls[10]
then
if balls[0] < balls[11]
then (11, False)
else (11, True)
else if balls[0] + balls[8] < balls[9] + balls[10]
then
if balls[9] = balls[10] then (8, True)
else if balls[9] < balls[10] then (10, False) else (9, False)
else
if balls[9] = balls[10] then (8, False)
else if balls[9] < balls[10] then (9, True) else (10, True)
else if balls[0] + balls[1] + balls[2] + balls[3] <
balls[4] + balls[5] + balls[6] + balls[7]
then
if balls[0] + balls[1] + balls[4] = balls[2] + balls[5] + balls[8]
then
if balls[6] = balls[7] then (3, True)
else if balls[6] < balls[7] then (7, False) else (6, False)
else if balls[0] + balls[1] + balls[4] < balls[2] + balls[5] + balls[8]
then
if balls[0] = balls[1] then (5, False)
else if balls[0] < balls[1] then (0, True) else (1, True)
else
if balls[4] = balls[8] then (2, True) else (4, False)
else
if balls[0] + balls[1] + balls[4] = balls[2] + balls[5] + balls[8]
then
if balls[6] = balls[7] then (3, False)
else if balls[6] < balls[7] then (6, True) else (7, True)
else if balls[0] + balls[1] + balls[4] < balls[2] + balls[5] + balls[8]
then
if balls[2] = balls[5] then (4, True )
else if balls[2] < balls[5] then (5, False) else (2, False)
else
if balls[0] = balls[1] then (5, True) else
if balls[0] < balls[1] then (1, False) else (0, False)
end
\ No newline at end of file
examples/balance/why3session.xml
View file @
24fc5f16
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment