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
479621eb
Commit
479621eb
authored
Apr 15, 2012
by
Jean-Christophe Filliâtre
Browse files
vstte 12, problem 4: a variant (in progress)
parent
4f32fb2b
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
examples/programs/vstte12_tree_reconstruction.mlw
View file @
479621eb
...
...
@@ -139,16 +139,24 @@ module ZipperBased
exception Failure
(*
predicate inv (left: list (int, tree)) = match left with
| Nil -> true
| Cons (d, _) Nil -> d <> 0
| Cons (d1, _) ((Cons (d2, _) _) as left') -> d1 <> d2 /\ inv left'
end
*)
let rec tc (left: list (int, tree)) (right: list (int, tree)) : tree
variant { (length left + length right, length right) } with lex =
{ (*
forall t: tree. depths 0 t <> forest_depths (reverse
left
)
*) }
{ (*
inv
left *) }
match left, right with
| _, Nil ->
raise Failure
| Nil, Cons (v, t) Nil ->
if v = 0 then t else raise Failure
| Nil, Cons
vt
right' ->
tc (Cons
vt
Nil) right'
| Nil, Cons
(v, t)
right' ->
tc (Cons
(v, t)
Nil) right'
| Cons (v1, t1) left', Cons (v2, t2) right' ->
if v1 = v2 then tc left' (Cons (v1 - 1, Node t1 t2) right')
else tc (Cons (v2, t2) left) right'
...
...
examples/programs/vstte12_tree_reconstruction/why3session.xml
View file @
479621eb
This diff is collapsed.
Click to expand it.
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