Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Why3
why3
Commits
a6ab8fac
Commit
a6ab8fac
authored
Jul 16, 2010
by
Jean-Christophe Filliâtre
Browse files
programs: ropes
parent
e63b87af
Changes
2
Hide whitespace changes
Inline
Side-by-side
examples/programs/ropes.mlw
View file @
a6ab8fac
{
type char
use array.ArrayLength as S
type string = S.t char
logic empty_string : string
use string.String as S
type string = S.t
type rope =
| Str string (*ofs:*) int (len: int)
| App rope rope (len: int)
logic inv (r: rope) = match r with
| Str s ofs len -> 0 <= ofs < S.length s and ofs + len <= S.length s
| App l r len -> 0 < len l and 0 < len r
end
logic model (r: rope) : string = match r with
| Str s ofs len -> S.sub s ofs len
| App l r _ -> S.app (model l) (model r)
end
}
let empty () = Str
empty_string
0 0
let empty () = Str
(S.create 0)
0 0
let length r = len r
...
...
theories/string.why
0 → 100644
View file @
a6ab8fac
theory String
use import int.Int
type char
type t
logic get t int : char
logic set t int char : t
axiom Get_set_eq :
forall s : t. forall i j : int.
forall c : char [get (set s i c) j].
i = j -> get (set s i c) j = c
axiom Get_set_neq :
forall s : t. forall i j : int.
forall c : char [get (set s i c) j].
i <> j -> get (set s i c) j = get s j
logic length t : int
logic create int : t
axiom Create_length :
forall n : int. length (create n) = n
axiom Length_set :
forall s : t. forall i : int. forall c : char.
length (set s i c) = length s
logic sub t int int : t
logic app t t : t
end
Write
Preview
Supports
Markdown
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