Commit ccb57be4 by Jean-Christophe Filliatre

### theory int.Sum with excluded right bound

`this is consistent with other, similar theories`
parent 82471364
 ... ... @@ -60,14 +60,14 @@ module TestCursor let sum (t: t) (c: cursor) : int requires { coherent t c } requires { c.i = 0 } ensures { result = sum 0 (length c.seq - 1) (get c.seq) } ensures { result = sum 0 (length c.seq) (get c.seq) } = let s = ref 0 in 'I: while has_next t c do invariant { coherent t c } invariant { 0 <= c.i <= length c.seq } invariant { !s = sum 0 (c.i - 1) (get c.seq) } invariant { !s = sum 0 c.i (get c.seq) } variant { length c.seq - c.i } let x = next t c in s += x ... ...
 ... ... @@ -7,12 +7,12 @@ ... ... @@ -20,7 +20,7 @@ ... ... @@ -43,14 +43,14 @@ ... ... @@ -100,22 +100,22 @@ ... ... @@ -141,7 +141,7 @@ ... ... @@ -176,29 +176,9 @@
No preview for this file type
 ... ... @@ -347,38 +347,38 @@ theory Sum use HighOrd function sum (a b: int) (f: int -> int) : int (** sum of [f n] for [a <= n <= b] *) (** sum of [f n] for [a <= n < b] *) axiom sum_def1: forall f: int -> int, a b: int. b < a -> sum a b f = 0 b <= a -> sum a b f = 0 axiom sum_def2: forall f: int -> int, a b: int. a <= b -> sum a b f = sum a (b - 1) f + f b a < b -> sum a b f = sum a (b - 1) f + f (b - 1) lemma sum_left: forall f: int -> int, a b: int. a <= b -> sum a b f = f a + sum (a + 1) b f a < b -> sum a b f = f a + sum (a + 1) b f lemma sum_ext: forall f g: int -> int, a b: int. (forall i. a <= i <= b -> f i = g i) -> (forall i. a <= i < b -> f i = g i) -> sum a b f = sum a b g lemma sum_le: forall f g: int -> int, a b: int. (forall i. a <= i <= b -> f i <= g i) -> (forall i. a <= i < b -> f i <= g i) -> sum a b f <= sum a b g lemma sum_nonneg: forall f: int -> int, a b: int. (forall i. a <= i <= b -> 0 <= f i) -> (forall i. a <= i < b -> 0 <= f i) -> 0 <= sum a b f lemma sum_decomp: forall f: int -> int, a b c: int. a <= b <= c -> sum a c f = sum a b f + sum (b+1) c f sum a c f = sum a b f + sum b c f end ... ...
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!