Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Why3
why3
Commits
10d63bb5
Commit
10d63bb5
authored
Nov 11, 2010
by
Jean-Christophe Filliâtre
Browse files
vstte'10 : cleaning up
parent
fdb62b55
Changes
1
Hide whitespace changes
Inline
Side-by-side
examples/programs/vstte10_search_list.mlw
View file @
10d63bb5
...
...
@@ -5,28 +5,30 @@
use export list.List
use export list.Length
use export list.Nth
logic zero_at (l : list int) (i : int) =
nth i l = Some 0 and forall j:int. 0 <= j < i -> nth j l <> Some 0
logic no_zero (l : list int) =
forall j:int. 0 <= j < length l -> nth j l <> Some 0
}
let rec search i l =
let rec search i l
variant { length l }
=
{}
match l with
| Nil -> i
| Cons x r -> if x = 0 then i else search (i+1) r
end
{ (i <= result < i + length l and nth (result - i) l = Some 0 and
forall j:int. 0 <= j < result - i -> nth j l <> Some 0)
{ (i <= result < i + length l and zero_at l (result - i))
or
(result = i + length l and
forall j:int. 0 <= j < length l -> nth j l <> Some 0) }
(result = i + length l and no_zero l) }
let search_list l =
{ }
search 0 l
{ (0 <= result < length l and nth result l = Some 0 and
forall j:int. 0 <= j < result -> nth j l <> Some 0)
{ (0 <= result < length l and zero_at l result)
or
(result = length l and
forall j:int. 0 <= j < length l -> nth j l <> Some 0) }
(result = length l and no_zero l) }
(*
...
...
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