Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Why3
why3
Commits
7ed9920a
Commit
7ed9920a
authored
Sep 25, 2013
by
Jean-Christophe Filliâtre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
maximum_subarray: proof of algo 3 in progress
parent
5ed91aef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
802 additions
and
615 deletions
+802
-615
examples/in_progress/maximum_subarray.mlw
examples/in_progress/maximum_subarray.mlw
+4
-1
examples/in_progress/maximum_subarray/why3session.xml
examples/in_progress/maximum_subarray/why3session.xml
+798
-614
No files found.
examples/in_progress/maximum_subarray.mlw
View file @
7ed9920a
...
...
@@ -112,6 +112,7 @@ module Algo3
let s = ref !ms in
for i = mid-1 downto l do
invariant { l <= !lo <= mid && !hi = mid+1 && !ms = sum a !lo !hi }
invariant { forall l': int. i < l' <= mid -> sum a l' (mid+1) <= !ms }
invariant { !s = sum a (i+1) (mid+1) }
s += a[i];
assert { !s = sum a i (mid+1) };
...
...
@@ -120,12 +121,14 @@ module Algo3
s := !ms;
for i = mid+1 to h-1 do
invariant { l <= !lo <= mid < !hi <= h && !ms = sum a !lo !hi }
invariant { forall l' h': int. l <= l' <= mid < h' <= i ->
sum a l' h' <= !ms }
invariant { !s = sum a !lo i }
s += a[i];
assert { !s = sum a !lo (i+1) };
if !s > !ms then begin ms := !s; hi := (i+1) end
done;
(* then consider sums
left and right of mid
, recursively *)
(* then consider sums
in a[l..mid[ and a[mid+1..h[
, recursively *)
if l < mid then begin
let ghost lo' = ref 0 in
let ghost hi' = ref 0 in
...
...
examples/in_progress/maximum_subarray/why3session.xml
View file @
7ed9920a
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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