Commit 29e42dd4 authored by Jean-Christophe's avatar Jean-Christophe

simplified specifications involving theory NumOf

parent dcb6c555
......@@ -31,15 +31,15 @@ module Spec
(* we introduce two predicates:
- [numeq a v l u] is the number of values in a[l..u[ equal to v
- [numlt a v l u] is the number of values in a[l..u[ less than v *)
type param = (M.map int int, int)
type param = (array int, int)
predicate eq (p: param) (i: int) = let (a,v) = p in M.get a i = v
predicate eq (p: param) (i: int) = let (a,v) = p in a[i] = v
clone int.NumOfParam as Neq with type param = param, predicate pr = eq
function numeq (a: array int) (v i j : int) : int = Neq.num_of (a.elts, v) i j
function numeq (a: array int) (v i j : int) : int = Neq.num_of (a, v) i j
predicate lt (p: param) (i: int) = let (a,v) = p in M.get a i < v
predicate lt (p: param) (i: int) = let (a,v) = p in a[i] < v
clone int.NumOfParam as Nlt with type param = param, predicate pr = lt
function numlt (a: array int) (v i j : int) : int = Nlt.num_of (a.elts, v) i j
function numlt (a: array int) (v i j : int) : int = Nlt.num_of (a, v) i j
(* an ovious lemma relates numeq and numlt *)
lemma eqlt:
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -11,20 +11,20 @@ module Muller
use import module ref.Refint
use import module array.Array
type param = M.map int int
predicate pr (a: param) (n: int) = M.([]) a n <> 0
type param = array int
predicate pr (a: param) (n: int) = a[n] <> 0
clone import int.NumOfParam with type param = param, predicate pr = pr
let compact (a: array int) =
let count = ref 0 in
for i = 0 to length a - 1 do
invariant { 0 <= !count = num_of a.elts 0 i <= i}
invariant { 0 <= !count = num_of a 0 i <= i}
if a[i] <> 0 then incr count
done;
let u = make !count 0 in
count := 0;
for i = 0 to length a - 1 do
invariant { 0 <= !count = num_of a.elts 0 i <= i }
invariant { 0 <= !count = num_of a 0 i <= i }
if a[i] <> 0 then begin u[!count] <- a[i]; incr count end
done
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment