Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
why3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Why3
why3
Commits
9453ec6f
Commit
9453ec6f
authored
14 years ago
by
Jean-Christophe Filliâtre
Browse files
Options
Downloads
Patches
Plain Diff
vstte'10 competition : problem 1 completed
parent
898b5b80
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/programs/.gitignore
+1
-0
1 addition, 0 deletions
examples/programs/.gitignore
examples/programs/vstte10_max_sum.mlw
+28
-0
28 additions, 0 deletions
examples/programs/vstte10_max_sum.mlw
with
29 additions
and
0 deletions
examples/programs/.gitignore
+
1
−
0
View file @
9453ec6f
next_digit_sum
vstte10_max_sum
This diff is collapsed.
Click to expand it.
examples/programs/vstte10_max_sum.mlw
0 → 100644
+
28
−
0
View file @
9453ec6f
(* VSTTE'10 competition *)
{
use array.ArrayLength as A
use import int.MinMax
type array 'a = A.t int 'a
logic (#) (a : array 'a) (i : int) : 'a = A.get a i
}
let max_sum a n =
{ n >= 0 and forall i:int. 0 <= i < n -> a#i >= 0 }
let sum = ref 0 in
let max = ref 0 in
for i = 0 to n-1 do
invariant { !sum <= i * !max and forall j:int. 0 <= j < i -> a#j <= !max }
if !max < a#i then max := a#i;
sum := !sum + a#i
done;
(!sum, !max)
{ let (sum, max) = result in sum <= n * max }
(*
Local Variables:
compile-command: "unset LANG; make -C ../.. examples/programs/vstte10_max_sum.gui"
End:
*)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment