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
119
Issues
119
List
Boards
Labels
Service Desk
Milestones
Merge Requests
16
Merge Requests
16
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
ffbbc1b8
Commit
ffbbc1b8
authored
Nov 10, 2010
by
Jean-Christophe Filliâtre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vstte'10 competition: problem 3 completed
parent
82069d55
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
14 deletions
+14
-14
examples/programs/vstte10_search_list.mlw
examples/programs/vstte10_search_list.mlw
+12
-10
theories/list.why
theories/list.why
+2
-4
No files found.
examples/programs/vstte10_search_list.mlw
View file @
ffbbc1b8
...
...
@@ -4,27 +4,29 @@
{
use export list.List
use export list.Length
use export option.Option
(*
logic nth (n : int) (l : list 'a) = match l with
| Nil -> None
| Cons x r -> if n = 0 then Some x else nth (n - 1) r
end
*)
use export list.Nth
}
let rec search i 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)
or
(result = i + length l and
forall j:int. 0 <= j < length l -> nth j l <> Some 0) }
let search_list l =
{ }
search 0 l
{ (0 <= result < length l (* nth result l = 0*)) or
(result = length l) }
{ (0 <= result < length l and nth result l = Some 0 and
forall j:int. 0 <= j < result -> nth j l <> Some 0)
or
(result = length l and
forall j:int. 0 <= j < length l -> nth j l <> Some 0) }
(*
...
...
theories/list.why
View file @
ffbbc1b8
...
...
@@ -29,19 +29,17 @@ theory Mem
end
(*
theory Nth
use export List
use
im
port option.Option
use
ex
port option.Option
use import int.Int
logic nth (n : int) (l : list 'a) = match l with
logic nth (n : int) (l : list 'a)
: option 'a
= match l with
| Nil -> None
| Cons x r -> if n = 0 then Some x else nth (n - 1) r
end
end
*)
theory Sorted
...
...
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