statement
stringlengths
1
15.9k
proof
stringlengths
0
44.6k
type
stringclasses
18 values
symbolic_name
stringlengths
1
61
library
stringclasses
21 values
filename
stringclasses
502 values
imports
listlengths
0
38
deps
listlengths
0
64
docstring
stringlengths
0
500
source_url
stringclasses
1 value
commit
stringclasses
1 value
t
type
t
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
op t t : t
function
op
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
Assoc : forall x y z : t. op (op x y) z = op x (op y z)
axiom
Assoc
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[ "op" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
Comm : forall x y : t. op x y = op y x
axiom
Comm
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[ "op" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
unit : t
constant
unit
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
Unit_def_l : forall x:t. op unit x = x
axiom
Unit_def_l
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[ "op", "unit" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
Unit_def_r : forall x:t. op x unit = x
axiom
Unit_def_r
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[ "op", "unit" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
inv t : t
function
inv
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
Inv_def_l : forall x:t. op (inv x) x = unit
axiom
Inv_def_l
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[ "inv", "op", "unit" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
Inv_def_r : forall x:t. op x (inv x) = unit
axiom
Inv_def_r
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[ "inv", "op", "unit" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
zero : t
constant
zero
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
(+) t t : t
function
(+)
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
(-_) t : t
function
(-_)
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
(*) t t : t
function
(*)
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
Mul_distr_l : forall x y z : t. x * (y + z) = x * y + x * z
axiom
Mul_distr_l
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
Mul_distr_r : forall x y z : t. (y + z) * x = y * x + z * x
axiom
Mul_distr_r
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
one : t
constant
one
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
Unitary : forall x:t. one * x = x
axiom
Unitary
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[ "one" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
NonTrivialRing : zero <> one
axiom
NonTrivialRing
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[ "one", "zero" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
(<=) t t
predicate
(<=)
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
ZeroLessOne : zero <= one
axiom
ZeroLessOne
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[ "one", "zero" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
CompatOrderAdd : forall x y z : t. x <= y -> x + z <= y + z
axiom
CompatOrderAdd
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
CompatOrderMult : forall x y z : t. x <= y -> zero <= z -> x * z <= y * z
axiom
CompatOrderMult
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[ "zero" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
Inverse : forall x:t. x <> zero -> x * inv x = one
axiom
Inverse
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[ "inv", "one", "zero" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
(-) (x y : t) : t
= x + -y
function
(-)
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
(/) (x y : t) : t
= x * inv y
function
(/)
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[ "inv" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
add_div : forall x y z : t. z <> zero -> (x+y)/z = x/z + y/z
lemma
add_div
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[ "zero" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
sub_div : forall x y z : t. z <> zero -> (x-y)/z = x/z - y/z
lemma
sub_div
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[ "zero" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
neg_div : forall x y : t. y <> zero -> (-x)/y = -(x/y)
lemma
neg_div
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[ "zero" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
assoc_mul_div: forall x y z:t. (* todo: discard the hypothesis ? *) z <> zero -> (x*y)/z = x*(y/z)
lemma
assoc_mul_div
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[ "zero" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
assoc_div_mul: forall x y z:t. (* todo: discard the hypothesis ? *) y <> zero /\ z <> zero -> (x/y)/z = x/(y*z)
lemma
assoc_div_mul
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[ "zero" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
assoc_div_div: forall x y z:t. (* todo: discard the hypothesis ? *) y <> zero /\ z <> zero -> x/(y/z) = (x*z)/y
lemma
assoc_div_div
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[ "zero" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
CompatOrderAdd : forall x y z : t. x <= y -> x + z <= y + z
axiom
CompatOrderAdd
stdlib
stdlib/algebra.mlw
[ "Assoc", "Comm", "CommutativeGroup", "CommutativeRing", "Field", "Group", "Monoid", "Ring", "UnitaryCommutativeRing", "relations.TotalOrder" ]
[]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
array [@extraction:array] 'a
= private { mutable ghost elts : int -> 'a; length : int } invariant { 0 <= length }
type
array
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "int", "length" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
([]) (a: array 'a) (i: int) : 'a
= a.elts i
function
([])
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "int" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
([]) (a: array 'a) (i: int) : 'a requires { [@expl:index in array bounds] 0 <= i < length a } ensures { result = a[i] }
val
([])
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "bounds", "int", "length" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
([<-]) (a: array 'a) (i: int) (v: 'a): array 'a ensures { result.length = a.length } ensures { result.elts = Map.set a.elts i v }
val function
([<-])
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "int", "length", "set" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
([]<-) (a: array 'a) (i: int) (v: 'a) : unit writes {a} requires { [@expl:index in array bounds] 0 <= i < length a } ensures { a.elts = Map.set (old a).elts i v } ensures { a = (old a)[i <- v] }
val
([]<-)
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "bounds", "int", "length", "set", "unit" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
OutOfBounds
exception
OutOfBounds
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[]
unsafe get/set operations with no precondition
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
defensive_get (a: array 'a) (i: int) ensures { 0 <= i < length a /\ result = a[i] } raises { OutOfBounds -> i < 0 \/ i >= length a }
= if i < 0 || i >= length a then raise OutOfBounds; a[i]
let
defensive_get
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "OutOfBounds", "array", "int", "length" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
defensive_set (a: array 'a) (i: int) (v: 'a) ensures { 0 <= i < length a } ensures { a = (old a)[i <- v] } raises { OutOfBounds -> (i < 0 \/ i >= length a) /\ a = old a }
= if i < 0 || i >= length a then raise OutOfBounds; a[i] <- v
let
defensive_set
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "OutOfBounds", "array", "int", "length" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
make (n: int) (v: 'a) : array 'a
function
make
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "int" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
make_spec : forall n:int, v:'a. n >= 0 -> (forall i:int. 0 <= i < n -> (make n v)[i] = v) /\ length (make n v) = n
axiom
make_spec
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "int", "length", "make" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
make [@extraction:array_make] (n: int) (v: 'a) : array 'a requires { [@expl:array creation size] n >= 0 } ensures { forall i:int. 0 <= i < n -> result[i] = v } ensures { result.length = n }
val
make
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "int", "length", "size" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
empty () : array 'a ensures { result.length = 0 }
val
empty
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "length" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
copy (a: array 'a) : array 'a ensures { length result = length a } ensures { forall i:int. 0 <= i < length result -> result[i] = a[i] }
= let len = length a in if len = 0 then empty () else begin let b = make len a[0] in for i = 1 to len - 1 do invariant { forall k. 0 <= k < i -> b[k] = a[k] } b[i] <- a[i] done; b end
let
copy
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "empty", "int", "len", "length", "make" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
sub (a: array 'a) (ofs: int) (len: int) : array 'a requires { 0 <= ofs /\ 0 <= len /\ ofs + len <= length a } ensures { length result = len } ensures { forall i:int. 0 <= i < len -> result[i] = a[ofs + i] }
= if length a = 0 then begin assert { len = 0 }; empty () end else begin let b = make len a[0] in for i = 0 to len-1 do invariant { forall k. 0 <= k < i -> b[k] = a[ofs+k] } b[i] <- a[ofs+i]; done; b end
let
sub
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "empty", "int", "len", "length", "make", "ofs" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
fill (a: array 'a) (ofs: int) (len: int) (v: 'a) requires { 0 <= ofs /\ 0 <= len /\ ofs + len <= length a } ensures { forall i:int. (0 <= i < ofs \/ ofs + len <= i < length a) -> a[i] = old a[i] } ensures { forall i:int. ofs <= i < ofs + len -> a[i] = v }
= for k = 0 to len - 1 do invariant { forall i:int. (0 <= i < ofs \/ ofs + len <= i < length a) -> a[i] = old a[i] } invariant { forall i:int. ofs <= i < ofs + k -> a[i] = v } a[ofs + k] <- v done
let
fill
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "int", "len", "length", "ofs" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
blit (a1: array 'a) (ofs1: int) (a2: array 'a) (ofs2: int) (len: int) : unit writes {a2} requires { 0 <= ofs1 /\ 0 <= len /\ ofs1 + len <= length a1 } requires { 0 <= ofs2 /\ ofs2 + len <= length a2 } ensures { forall i:int. (0 <= i < ofs2 \/ ofs2 + len <= i < length a2) ...
= for i = 0 to len - 1 do invariant { forall k. not (0 <= k < i) -> a2[ofs2 + k] = old a2[ofs2 + k] } invariant { forall k. 0 <= k < i -> a2[ofs2 + k] = a1[ofs1 + k] } a2[ofs2 + i] <- a1[ofs1 + i]; done
let
blit
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "a1", "a2", "array", "int", "len", "length", "ofs2", "unit" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
append (a1: array 'a) (a2: array 'a) : array 'a ensures { length result = length a1 + length a2 } ensures { forall i. 0 <= i < length a1 -> result[i] = a1[i] } ensures { forall i. 0 <= i < length a2 -> result[length a1 + i] = a2[i] }
= if length a1 = 0 then copy a2 else begin let a = make (length a1 + length a2) a1[0] in blit a1 0 a 0 (length a1); blit a2 0 a (length a1) (length a2); a end
let
append
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "a1", "a2", "array", "blit", "copy", "length", "make" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
self_blit (a: array 'a) (ofs1: int) (ofs2: int) (len: int) : unit writes {a} requires { 0 <= ofs1 /\ 0 <= len /\ ofs1 + len <= length a } requires { 0 <= ofs2 /\ ofs2 + len <= length a } ensures { forall i:int. (0 <= i < ofs2 \/ ofs2 + len <= i < length a) -> a[i] = old a[i] } ens...
= if ofs1 <= ofs2 then (* from right to left *) for k = len - 1 downto 0 do invariant { forall i:int. (0 <= i <= ofs2 + k \/ ofs2 + len <= i < length a) -> a[i] = (old a)[i] } invariant { forall i:int. ofs2 + k < i < ofs2 + len -> a[i] = (old a)[ofs1 + i - ofs2]...
let
self_blit
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "int", "len", "length", "ofs2", "unit" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
init (n: int) (f: int -> 'a) : array 'a requires { [@expl:array creation size] n >= 0 } ensures { forall i:int. 0 <= i < n -> result[i] = f i } ensures { result.length = n }
= if n = 0 then empty () else begin let a = make n (f 0) in for i = 1 to n - 1 do invariant { forall k. 0 <= k < i -> a[k] = f k } a[i] <- f i done; a end
let
init
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "empty", "int", "length", "make", "size" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
sorted_sub (a : array int) (l u : int)
= M.sorted_sub a.elts l u
predicate
sorted_sub
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "int" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
sorted (a : array int)
= M.sorted_sub a.elts 0 a.length
predicate
sorted
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "int", "length", "sorted_sub" ]
`sorted_sub a l u` is true whenever the array segment `a(l..u-1)` is sorted w.r.t order relation `le`
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
elt
type
elt
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
le elt elt
predicate
le
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "elt" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
sorted_sub (a: array elt) (l u: int)
= forall i1 i2 : int. l <= i1 < i2 < u -> le a[i1] a[i2]
predicate
sorted_sub
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "elt", "i1", "i2", "int", "le" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
sorted (a: array elt)
= forall i1 i2 : int. 0 <= i1 < i2 < length a -> le a[i1] a[i2]
predicate
sorted
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "elt", "i1", "i2", "int", "le", "length" ]
`sorted_sub a l u` is true whenever the array segment `a(l..u-1)` is sorted w.r.t order relation `le`
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
array_eq_sub (a1 a2: array 'a) (l u: int)
= a1.length = a2.length /\ 0 <= l <= a1.length /\ 0 <= u <= a1.length /\ map_eq_sub a1.elts a2.elts l u
predicate
array_eq_sub
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "a1", "a2", "array", "int", "length", "map_eq_sub" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
array_eq (a1 a2: array 'a)
= a1.length = a2.length /\ map_eq_sub a1.elts a2.elts 0 (length a1)
predicate
array_eq
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "a1", "a2", "array", "length", "map_eq_sub" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
exchange (a1 a2: array 'a) (i j: int)
= a1.length = a2.length /\ M.exchange a1.elts a2.elts 0 a1.length i j
predicate
exchange
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "a1", "a2", "array", "int", "length" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
permut (a1 a2: array 'a) (l u: int)
= a1.length = a2.length /\ 0 <= l <= a1.length /\ 0 <= u <= a1.length /\ M.permut a1.elts a2.elts l u
predicate
permut
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "a1", "a2", "array", "int", "length" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
permut_sub (a1 a2: array 'a) (l u: int)
= map_eq_sub a1.elts a2.elts 0 l /\ permut a1 a2 l u /\ map_eq_sub a1.elts a2.elts u (length a1)
predicate
permut_sub
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "a1", "a2", "array", "int", "length", "map_eq_sub", "permut" ]
`permut a1 a2 l u` is true when the segment `a1(l..u-1)` is a permutation of the segment `a2(l..u-1)`. Values outside of the interval `(l..u-1)` are ignored.
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
permut_all (a1 a2: array 'a)
= a1.length = a2.length /\ M.permut a1.elts a2.elts 0 a1.length
predicate
permut_all
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "a1", "a2", "array", "length", "permut" ]
`permut_sub a1 a2 l u` is true when the segment `a1(l..u-1)` is a permutation of the segment `a2(l..u-1)` and values outside of the interval `(l..u-1)` are equal.
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
exchange_permut_sub: forall a1 a2: array 'a, i j l u: int. exchange a1 a2 i j -> l <= i < u -> l <= j < u -> 0 <= l -> u <= length a1 -> permut_sub a1 a2 l u
lemma
exchange_permut_sub
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "a1", "a2", "array", "exchange", "int", "length", "permut_sub" ]
`permut_all a1 a2 l u` is true when array `a1` is a permutation of array `a2`.
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
permut_sub_trans: forall a1 a2 a3: array 'a, l u: int. 0 <= l -> u <= length a1 -> permut_sub a1 a2 l u -> permut_sub a2 a3 l u -> permut_sub a1 a3 l u
lemma
permut_sub_trans
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "a1", "a2", "array", "int", "length", "permut_sub" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
permut_sub_weakening: forall a1 a2: array 'a, l1 u1 l2 u2: int. permut_sub a1 a2 l1 u1 -> 0 <= l2 <= l1 -> u1 <= u2 <= length a1 -> permut_sub a1 a2 l2 u2
lemma
permut_sub_weakening
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "a1", "a2", "array", "int", "length", "permut_sub", "u1", "u2" ]
we can always enlarge the interval
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
exchange_permut_all: forall a1 a2: array 'a, i j: int. exchange a1 a2 i j -> permut_all a1 a2
lemma
exchange_permut_all
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "a1", "a2", "array", "exchange", "int", "permut_all" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
swap (a:array 'a) (i:int) (j:int) : unit requires { 0 <= i < length a /\ 0 <= j < length a } writes { a } ensures { exchange (old a) a i j }
= let v = a[i] in a[i] <- a[j]; a[j] <- v
let
swap
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "exchange", "int", "length", "unit" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
sum (a: array int) (l h: int) : int
= S.sum a.elts l h
function
sum
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "int" ]
`sum a l h` is the sum of `a[i]` for `l <= i < h`
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
numof (pr: int -> 'a -> bool) (a: array 'a) (l u: int) : int
= N.numof (fun i -> pr i a[i]) l u
function
numof
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "int", "pr" ]
the number of `a[i]` such that `l <= i < u` and `pr i a[i]`
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
numof (a: array 'a) (v: 'a) (l u: int) : int
= N.numof (fun i -> a[i] = v) l u
function
numof
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "int" ]
the number of `a[i]` such that `l <= i < u` and `a[i] = v`
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
to_list (a: array 'a) (l u: int) : list 'a requires { l >= 0 /\ u <= a.length } variant { u - l }
= if u <= l then Nil else Cons a[l] (to_list a (l+1) u)
let function
to_list
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "int", "length", "list" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
to_list_append (a: array 'a) (l m u: int) requires { 0 <= l <= m <= u <= a.length } variant { m - l } ensures { to_list a l m ++ to_list a m u = to_list a l u }
= if l < m then to_list_append a (l+1) m u
let lemma
to_list_append
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "int", "length", "to_list" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
to_seq_sub (a: array 'a) (l u: int) : S.seq 'a requires { l >= 0 /\ u <= a.length } variant { u - l }
= if u <= l then S.empty else S.cons a[l] (to_seq_sub a (l+1) u)
let function
to_seq_sub
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "cons", "empty", "int", "length", "seq" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
to_seq_length (a: array 'a) (l u: int) requires { 0 <= l <= u <= length a } variant { u - l } ensures { S.length (to_seq_sub a l u) = u - l }
= if l < u then to_seq_length a (l+1) u
let lemma
to_seq_length
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "int", "length", "to_seq_sub" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
to_seq_nth (a: array 'a) (l i u: int) requires { 0 <= l <= i < u <= length a } variant { i - l } ensures { S.get (to_seq_sub a l u) (i - l) = a[i] }
= if l < i then to_seq_nth a (l+1) i u
let lemma
to_seq_nth
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "get", "int", "length", "to_seq_sub" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
to_seq (a: array 'a) : S.seq 'a
= to_seq_sub a 0 (length a)
let function
to_seq
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "length", "seq", "to_seq_sub" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
inversion (a: array int) (i j: int)
= a[i] > a[j]
predicate
inversion
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "int" ]
to prove termination, we count the total number of inversions
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
inversions_for (a: array int) (i: int) : int
= numof (inversion a i) i (length a)
function
inversions_for
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "int", "inversion", "length", "numof" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
inversions (a: array int) : int
= sum (inversions_for a) 0 (length a)
function
inversions
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "array", "int", "inversions_for", "length", "sum" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
exchange_inversion (a1 a2: array int) (i0: int) requires { 0 <= i0 < length a1 - 1 } requires { a1[i0] > a1[i0 + 1] } requires { exchange a1 a2 i0 (i0 + 1) } ensures { inversions a2 < inversions a1 }
= assert { inversion a1 i0 (i0+1) }; assert { not (inversion a2 i0 (i0+1)) }; assert { forall i. 0 <= i < i0 -> inversions_for a2 i = inversions_for a1 i by numof (inversion a2 i) i (length a2) = numof (inversion a2 i) i i0 + numof (inversion a2 i) i0 (i0+1)...
let lemma
exchange_inversion
stdlib
stdlib/array.mlw
[ "Array", "ArrayEq", "ArrayExchange", "int.Int", "int.NumOf", "int.Sum", "list.Append", "list.List", "map.Map", "map.MapEq", "map.MapExchange", "map.MapPermut", "map.MapSorted", "seq.Seq" ]
[ "a1", "a2", "array", "exchange", "int", "inversion", "inversions", "inversions_for", "length", "numof", "sum", "sum_decomp" ]
the key lemma to prove termination: whenever we swap two consecutive values that are ill-sorted, the total number of inversions decreases
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
bag 'a
type
bag
stdlib
stdlib/bag.mlw
[ "int.Int", "int.MinMax" ]
[]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
nb_occ (x: 'a) (b: bag 'a): int
function
nb_occ
stdlib
stdlib/bag.mlw
[ "int.Int", "int.MinMax" ]
[ "bag", "int" ]
the most basic operation is the number of occurrences
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
occ_non_negative: forall b: bag 'a, x: 'a. nb_occ x b >= 0
axiom
occ_non_negative
stdlib
stdlib/bag.mlw
[ "int.Int", "int.MinMax" ]
[ "bag", "nb_occ" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
mem (x: 'a) (b: bag 'a)
= nb_occ x b > 0
predicate
mem
stdlib
stdlib/bag.mlw
[ "int.Int", "int.MinMax" ]
[ "bag", "nb_occ" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
(==) (a b: bag 'a)
= forall x:'a. nb_occ x a = nb_occ x b
predicate
(==)
stdlib
stdlib/bag.mlw
[ "int.Int", "int.MinMax" ]
[ "bag", "nb_occ" ]
equality of bags
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
bag_extensionality: forall a b: bag 'a. a == b -> a = b
axiom
bag_extensionality
stdlib
stdlib/bag.mlw
[ "int.Int", "int.MinMax" ]
[ "bag" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
empty_bag: bag 'a
function
empty_bag
stdlib
stdlib/bag.mlw
[ "int.Int", "int.MinMax" ]
[ "bag" ]
basic constructors of bags
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
occ_empty: forall x: 'a. nb_occ x empty_bag = 0
axiom
occ_empty
stdlib
stdlib/bag.mlw
[ "int.Int", "int.MinMax" ]
[ "empty_bag", "nb_occ" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
is_empty: forall b: bag 'a. (forall x: 'a. nb_occ x b = 0) -> b = empty_bag
lemma
is_empty
stdlib
stdlib/bag.mlw
[ "int.Int", "int.MinMax" ]
[ "bag", "empty_bag", "nb_occ" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
singleton (x: 'a) : bag 'a
function
singleton
stdlib
stdlib/bag.mlw
[ "int.Int", "int.MinMax" ]
[ "bag" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
occ_singleton: forall x y: 'a. (x = y /\ (nb_occ y (singleton x)) = 1) \/ (x <> y /\ (nb_occ y (singleton x)) = 0)
axiom
occ_singleton
stdlib
stdlib/bag.mlw
[ "int.Int", "int.MinMax" ]
[ "nb_occ", "singleton" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
occ_singleton_eq: forall x y: 'a. x = y -> nb_occ y (singleton x) = 1
lemma
occ_singleton_eq
stdlib
stdlib/bag.mlw
[ "int.Int", "int.MinMax" ]
[ "nb_occ", "singleton" ]
FIXME? nb_occ y (singleton x) = if x = y then 1 else 0
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
occ_singleton_neq: forall x y: 'a. x <> y -> nb_occ y (singleton x) = 0
lemma
occ_singleton_neq
stdlib
stdlib/bag.mlw
[ "int.Int", "int.MinMax" ]
[ "nb_occ", "singleton" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
union (bag 'a) (bag 'a) : bag 'a
function
union
stdlib
stdlib/bag.mlw
[ "int.Int", "int.MinMax" ]
[ "bag" ]
union
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
occ_union: forall x: 'a, a b: bag 'a. nb_occ x (union a b) = nb_occ x a + nb_occ x b
axiom
occ_union
stdlib
stdlib/bag.mlw
[ "int.Int", "int.MinMax" ]
[ "bag", "nb_occ", "union" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
Union_comm: forall a b: bag 'a. union a b = union b a
lemma
Union_comm
stdlib
stdlib/bag.mlw
[ "int.Int", "int.MinMax" ]
[ "bag", "union" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
Union_identity: forall a: bag 'a. union a empty_bag = a
lemma
Union_identity
stdlib
stdlib/bag.mlw
[ "int.Int", "int.MinMax" ]
[ "bag", "empty_bag", "union" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784
Union_assoc: forall a b c: bag 'a. union a (union b c) = union (union a b) c
lemma
Union_assoc
stdlib
stdlib/bag.mlw
[ "int.Int", "int.MinMax" ]
[ "bag", "union" ]
https://gitlab.inria.fr/why3/why3
7c59064b4eed9a4059292599f3a657716aa34784