concept AddCommGroup<T> {
refines AddCommMonoid<T>
fun operator - : (fn T -> T)
fun operator - : (fn (T, T) -> T)
theorem add_inverse: all x:T. x + - x = zero
theorem sub_def: all x:T, y:T. x - y = x + - y
}
concept AddCommMonoid<T> {
fun operator + : (fn (T, T) -> T)
fun zero : T
theorem add_commute: all x:T, y:T. x + y = y + x
theorem add_assoc: all x:T, y:T, z:T. x + y + z = x + (y + z)
theorem add_zero: all x:T. x + zero = x
}
concept CommRing<T> {
refines CommSemiring<T>
refines AddCommGroup<T>
}
concept CommSemiring<T> {
refines AddCommMonoid<T>
fun operator * : (fn (T, T) -> T)
fun one : T
fun from_uint : (fn UInt -> T)
fun operator ^ : (fn (T, UInt) -> T)
theorem mult_commute: all x:T, y:T. x * y = y * x
theorem mult_assoc: all x:T, y:T, z:T. x * y * z = x * (y * z)
theorem mult_one: all x:T. x * one = x
theorem mult_zero: all x:T. x * zero = zero
theorem dist_mult_add: all x:T, y:T, z:T. x * (y + z) = x * y + x * z
theorem from_uint_zero: from_uint(0) = zero
theorem from_uint_one: from_uint(1) = one
theorem from_uint_add: all m:UInt, n:UInt. from_uint(m + n) = from_uint(m) + from_uint(n)
theorem from_uint_mult: all m:UInt, n:UInt. from_uint(m * n) = from_uint(m) * from_uint(n)
theorem pow_zero: all x:T. x ^ 0 = one
theorem pow_one_add: all x:T, k:UInt. x ^ (1 + k) = x * x ^ k
}
define Even : (fn UInt -> bool) = fun n:UInt {
some m:UInt. n = 2 * m
}
define Even : (fn Int -> bool) = fun n:Int {
some m:Int. n = +2 * m
}
define EvenNat : (fn Nat -> bool) = fun n:Nat {
some m:Nat. n = suc(suc(zero)) * m
}
Even_not_Odd: all n:Nat. EvenNat(n) ⇔ not OddNat(n)
Even_or_Odd: all n:Nat. EvenNat(n) or OddNat(n)
union FP {
fp(RExpr, RExpr)
}
concept Field<T> {
refines CommRing<T>
fun inv : (fn T -> T)
fun operator / : (fn (T, T) -> T)
fun from_frac : (fn (UInt, UInt) -> T)
theorem one_nonzero: one ≠ zero
theorem mult_inv: all x:T. if x ≠ zero then x * inv(x) = one
theorem div_def: all x:T, y:T. x / y = x * inv(y)
theorem from_frac_mult: all n:UInt, d:UInt. if from_uint(d) ≠ zero then from_frac(n, d) * from_uint(d) = from_uint(n)
}
union Int {
pos(UInt)
negsuc(UInt)
}
union List<T> {
empty
node(T, List<T>)
}
union Mono {
mono(UInt, List<UInt>)
}
union Nat {
zero
suc(Nat)
}
define Odd : (fn UInt -> bool) = fun n:UInt {
some m:UInt. n = 1 + 2 * m
}
define Odd : (fn Int -> bool) = fun n:Int {
some m:Int. n = +1 + +2 * m
}
define OddNat : (fn Nat -> bool) = fun n:Nat {
some m:Nat. n = suc(suc(suc(zero)) * m)
}
concept OrderedAddCommGroup<T> {
refines AddCommGroup<T>
fun operator ≤ : (fn (T, T) -> bool)
fun operator < : (fn (T, T) -> bool)
theorem less_equal_trans: all x:T, y:T, z:T. if x ≤ y and y ≤ z then x ≤ z
theorem less_equal_antisymmetric: all x:T, y:T. if x ≤ y and y ≤ x then x = y
theorem less_equal_total: all x:T, y:T. x ≤ y or y ≤ x
theorem add_le_right_mono: all x:T, y:T, z:T. if x ≤ y then x + z ≤ y + z
theorem less_def: all x:T, y:T. x < y = (x ≤ y and x ≠ y)
}
concept OrderedQVectorSpace<T> {
refines OrderedAddCommGroup<T>
fun scale : (fn (Rat, T) -> T)
theorem scale_one: all x:T. scale(rat(+1), x) = x
theorem scale_assoc: all p:Rat, q:Rat, x:T. scale(p * q, x) = scale(p, scale(q, x))
theorem scale_add_left: all p:Rat, q:Rat, x:T. scale(p + q, x) = scale(p, x) + scale(q, x)
theorem scale_add_right: all q:Rat, x:T, y:T. scale(q, x + y) = scale(q, x) + scale(q, y)
theorem scale_pos: all q:Rat, x:T. if rat(+0) < q and zero < x then zero < scale(q, x)
}
union PN {
pn(List<Mono>, List<Mono>)
}
union RExpr {
rvar(Nat)
rzero
rone
rconst(UInt)
radd(RExpr, RExpr)
rsub(RExpr, RExpr)
rneg(RExpr)
rmul(RExpr, RExpr)
rpow(RExpr, UInt)
rinv(RExpr)
rdiv(RExpr, RExpr)
rfrac(UInt, UInt)
}
opaque union Rat
postulate type Real
view UInt {
source Binary
target UIntView
into uint_view
out uint_unview
roundtrip uint_view_unview
inverse uint_unview_view
}
concept WellFounded<T> {
fun operator < : (fn (T, T) -> bool)
theorem strong_induction: all P:(fn T -> bool), n:T. if (all j:T. if (all i:T. if i < j then P(i)) then P(j)) then P(n)
}
opaque define abs : (fn Int -> UInt)
opaque define abs : (fn Rat -> Rat)
opaque define abs : (fn Real -> Real)
auto abs_lit
abs_lit: all x:Nat. abs(pos(fromNat(lit(x)))) = fromNat(lit(x))
abs_neg: all n:Int. abs(- n) = abs(n)
add_assoc: all m:Nat, n:Nat, o:Nat. m + n + o = m + (n + o)
add_both_monus: all z:Nat, y:Nat, x:Nat. (z + y) ∸ (z + x) = y ∸ x
add_both_sides_of_equal: all x:Nat. all y:Nat, z:Nat. x + y = x + z ⇔ y = z
add_both_sides_of_less: all x:Nat, y:Nat, z:Nat. x + y < x + z ⇔ y < z
add_both_sides_of_less_equal: all x:Nat. all y:Nat, z:Nat. x + y ≤ x + z ⇔ y ≤ z
add_commute: all n:Nat. all m:Nat. n + m = m + n
add_commute_uint_int: all x:UInt, y:Int. x + y = y + x
define add_div : (fn (Nat, Nat, Nat) -> Nat) = fun a:Nat, b:Nat, y:Nat {
(a + b) / y
}
add_mono_less: all a:Nat, b:Nat, c:Nat, d:Nat. if a < c and b < d then a + b < c + d
add_mono_less_equal: all a:Nat, b:Nat, c:Nat, d:Nat. if a ≤ c and b ≤ d then a + b ≤ c + d
add_monus_identity: all m:Nat. all n:Nat. (m + n) ∸ m = n
add_pos_pos: all n:UInt, m:UInt. pos(n) + pos(m) = pos(n + m)
add_suc: all m:Nat. all n:Nat. m + suc(n) = suc(m + n)
addition_of_evens: all x:Nat, y:Nat. if EvenNat(x) and EvenNat(y) then EvenNat(x + y)
append_assoc: all U:type, xs:List<U>, ys:List<U>, zs:List<U>. xs ++ ys ++ zs = xs ++ (ys ++ zs)
append_empty: all U:type, xs:List<U>. xs ++ [] = xs
assoc_add: all m:Nat, n:Nat, o:Nat. m + (n + o) = m + n + o
recursive contains<E>(List<E>,E) -> bool{
contains([], x) = false
contains(node(y, next), x) = y = x or contains(next, x)
}
contains_append: all T:type. all xs:List<T>, ys:List<T>, e:T. contains(xs ++ ys, e) = (contains(xs, e) or contains(ys, e))
opaque define den : (fn Rat -> UInt)
dichotomy: all x:Nat, y:Nat. x ≤ y or y < x
recursive dist(Nat,Nat) -> Nat{
dist(zero, n) = n
dist(suc(m), n) =
switch n {
case zero {
suc(m)
}
case suc(n') {
dist(m, n')
}
}
}
dist_mult_add: all a:Nat, x:Nat, y:Nat. a * (x + y) = a * x + a * y
dist_mult_add_right: all x:Nat, y:Nat, a:Nat. (x + y) * a = x * a + y * a
dist_mult_monus: all x:Nat. all y:Nat, z:Nat. x * (y ∸ z) = x * y ∸ x * z
dist_mult_monus_one: all x:Nat, y:Nat. x * (y ∸ suc(zero)) = x * y ∸ x
dist_neg_mult: all x:Int, y:Int. - (x * y) = - x * y
opaque define div2 : (fn UInt -> UInt)
recfun div_alt(a:Nat, b:Nat, y:Nat) -> Pair<Nat,Nat>
measure a + b + b of Nat
{
if b = zero then
pair(zero, a)
else
if a = y and zero < a then
(define f = div_alt(zero, b, y);
pair(suc(first(f)), second(f)))
else
div_alt(suc(a), b ∸ suc(zero), y)
}
terminates {
arbitrary a : Nat,
b : Nat,
y : Nat
have A: if b ≠ zero and a = y and zero < a then zero + b + b < a + b + b by {
assume prem
have X: b + b < b + b + a by {
apply less_add_pos[b + b, a] to prem
}
replace add_commute[a, b + b]
X
}
have B: if b ≠ zero and not (a = y and zero < a) then suc(a) + (b ∸ suc(zero)) + (b ∸ suc(zero)) < a + b + b by {
assume prem
obtain b' where bs : b = suc(b') from apply not_zero_suc[b] to prem
replace bs
expand operator ∸
replace monus_zero | add_suc | add_suc
expand operator + | operator + | operator < | operator ≤ | operator ≤
less_equal_refl
}
A, B
}
auto div_negsuc_negsuc
div_negsuc_negsuc: all au:UInt, bu:UInt. negsuc(au) / negsuc(bu) = pos((1 + au) / (1 + bu))
auto div_negsuc_pos
div_negsuc_pos: all au:UInt, bu:UInt. negsuc(au) / pos(bu) = - pos((1 + au) / bu)
auto div_negsuc_uint
div_negsuc_uint: all au:UInt, bu:UInt. negsuc(au) / bu = - pos((1 + au) / bu)
auto div_pos_negsuc
div_pos_negsuc: all au:UInt, bu:UInt. pos(au) / negsuc(bu) = - pos(au / (1 + bu))
auto div_pos_pos
div_pos_pos: all au:UInt, bu:UInt. pos(au) / pos(bu) = pos(au / bu)
auto div_pos_uint
div_pos_uint: all au:UInt, bu:UInt. pos(au) / bu = pos(au / bu)
define divides : (fn (UInt, UInt) -> bool) = fun a:UInt, b:UInt {
some k:UInt. a * k = b
}
define divides : (fn (Nat, Nat) -> bool) = fun a:Nat, b:Nat {
some k:Nat. a * k = b
}
define divides : (fn (Int, Int) -> bool) = fun a:Int, b:Int {
some k:Int. a * k = b
}
recursive drop<T>(List<T>,UInt) -> List<T>{
drop([], n) = []
drop(node(x, xs'), n) =
if n = 0 then
node(x, xs')
else
drop(xs', n ∸ 1)
}
drop_append: all E:type, xs:List<E>, ys:List<E>. drop(xs ++ ys, length(xs)) = ys
drop_zero_identity: all E:type, xs:List<E>. drop(xs, 0) = xs
recursive equal(Nat,Nat) -> bool{
equal(zero, n) =
switch n {
case zero {
true
}
case suc(n') {
false
}
}
equal(suc(m'), n) =
switch n {
case zero {
false
}
case suc(n') {
equal(m', n')
}
}
}
equal_complete_sound: all m:Nat. all n:Nat. m = n ⇔ equal(m, n)
equal_implies_less_equal: all x:Nat, y:Nat. if x = y then x ≤ y
equal_refl: all n:Nat. equal(n, n)
even_or_odd: all n:Nat. is_even(n) or is_odd(n)
exp_one_implies_zero_or_one: all m:Nat, n:Nat. if m ^ n = suc(zero) then n = zero or m = suc(zero)
recursive expt(Nat,Nat) -> Nat{
expt(zero, n) = suc(zero)
expt(suc(p), n) = n * expt(p, n)
}
recursive field_conds(RExpr) -> List<RExpr>{
field_conds(rvar(i)) = []
field_conds(rzero) = []
field_conds(rone) = []
field_conds(rconst(n)) = []
field_conds(radd(a, b)) = field_conds(a) ++ field_conds(b)
field_conds(rsub(a, b)) = field_conds(a) ++ field_conds(b)
field_conds(rneg(a)) = field_conds(a)
field_conds(rmul(a, b)) = field_conds(a) ++ field_conds(b)
field_conds(rpow(a, k)) = field_conds(a)
field_conds(rinv(a)) = field_factors(fp_num(field_frac(a))) ++ field_conds(a)
field_conds(rdiv(a, b)) = field_factors(fp_num(field_frac(b))) ++ (field_conds(a) ++ field_conds(b))
field_conds(rfrac(n, d)) = [rconst(d)]
}
recursive field_covers(List<RExpr>,List<RExpr>) -> bool{
field_covers([], cs) = true
field_covers(node(x, xs), cs) = field_in(cs, x) and field_covers(xs, cs)
}
recursive field_denote<T> where { Field<T> } (RExpr,List<T>) -> T{
field_denote(rvar(i), env) = ring_get(env, i)
field_denote(rzero, env) = zero
field_denote(rone, env) = one
field_denote(rconst(n), env) = from_uint(n)
field_denote(radd(a, b), env) = field_denote(a, env) + field_denote(b, env)
field_denote(rsub(a, b), env) = field_denote(a, env) - field_denote(b, env)
field_denote(rneg(a), env) = - field_denote(a, env)
field_denote(rmul(a, b), env) = field_denote(a, env) * field_denote(b, env)
field_denote(rpow(a, k), env) = field_denote(a, env) ^ k
field_denote(rinv(a), env) = inv(field_denote(a, env))
field_denote(rdiv(a, b), env) = field_denote(a, env) / field_denote(b, env)
field_denote(rfrac(n, d), env) = from_frac(n, d)
}
recursive field_factors(RExpr) -> List<RExpr>{
field_factors(rvar(i)) = [rvar(i)]
field_factors(rzero) = [rzero]
field_factors(rone) = []
field_factors(rconst(n)) = [rconst(n)]
field_factors(radd(a, b)) = [radd(a, b)]
field_factors(rsub(a, b)) = [rsub(a, b)]
field_factors(rneg(a)) = field_factors(a)
field_factors(rmul(a, b)) = field_factors(a) ++ field_factors(b)
field_factors(rpow(a, k)) =
if k = 0 then
[]
else
field_factors(a)
field_factors(rinv(a)) = [rinv(a)]
field_factors(rdiv(a, b)) = [rdiv(a, b)]
field_factors(rfrac(n, d)) = [rfrac(n, d)]
}
recursive field_frac(RExpr) -> FP{
field_frac(rvar(i)) = fp(rvar(i), rone)
field_frac(rzero) = fp(rzero, rone)
field_frac(rone) = fp(rone, rone)
field_frac(rconst(n)) = fp(rconst(n), rone)
field_frac(radd(a, b)) = fp_add(field_frac(a), field_frac(b))
field_frac(rsub(a, b)) = fp_sub(field_frac(a), field_frac(b))
field_frac(rneg(a)) = fp_neg(field_frac(a))
field_frac(rmul(a, b)) = fp_mul(field_frac(a), field_frac(b))
field_frac(rpow(a, k)) = fp_pow(field_frac(a), k)
field_frac(rinv(a)) = fp_inv(field_frac(a))
field_frac(rdiv(a, b)) = fp_mul(field_frac(a), fp_inv(field_frac(b)))
field_frac(rfrac(n, d)) = fp(rconst(n), rconst(d))
}
define field_frac_eq : (fn (RExpr, RExpr) -> bool) = fun a:RExpr, b:RExpr {
ring_pn_eq(rmul(fp_num(field_frac(a)), fp_den(field_frac(b))), rmul(fp_num(field_frac(b)), fp_den(field_frac(a))))
}
recursive field_in(List<RExpr>,RExpr) -> bool{
field_in([], c) = false
field_in(node(d, ds), c) =
if c = d then
true
else
field_in(ds, c)
}
define field_mul : (fn (RExpr, RExpr) -> RExpr) = fun a:RExpr, b:RExpr {
if a = rone then
b
else
if b = rone then
a
else
rmul(a, b)
}
recursive field_nonzero<T> where { Field<T> } (List<RExpr>,List<T>) -> bool{
field_nonzero([], env) = true
field_nonzero(node(c, cs), env) = ring_denote(c, env) ≠ zero and field_nonzero(cs, env)
}
field_prove: all T:type where { Field<T> }. all env:List<T>, a:RExpr, b:RExpr, cs:List<RExpr>. if field_frac_eq(a, b) and field_covers(field_conds(a) ++ field_conds(b), cs) then if field_nonzero(cs, env) then field_denote(a, env) = field_denote(b, env)
recursive filter<E>(List<E>,(fn E -> bool)) -> List<E>{
filter([], P) = []
filter(node(x, ls), P) =
if P(x) then
node(x, filter(ls, P))
else
filter(ls, P)
}
recursive foldl<T,U>(List<T>,U,(fn (U, T) -> U)) -> U{
foldl([], u, c) = u
foldl(node(t, ls), u, c) = foldl(ls, c(u, t), c)
}
recursive foldr<T,U>(List<T>,U,(fn (T, U) -> U)) -> U{
foldr([], u, c) = u
foldr(node(t, ls), u, c) = c(t, foldr(ls, u, c))
}
define fp_add : (fn (FP, FP) -> FP) = fun x:FP, y:FP {
fp(radd(field_mul(fp_num(x), fp_den(y)), field_mul(fp_num(y), fp_den(x))), field_mul(fp_den(x), fp_den(y)))
}
define fp_den : (fn FP -> RExpr) = fun x:FP {
switch x {
case fp(n, d) {
d
}
}
}
define fp_holds : (fn <T> where { Field<T> } (T, FP, List<T>) -> bool) = generic T where { Field<T> } {
fun x:T, X:FP, env:List<T> {
x * ring_denote(fp_den(X), env) = ring_denote(fp_num(X), env) and ring_denote(fp_den(X), env) ≠ zero
}
}
define fp_inv : (fn FP -> FP) = fun x:FP {
fp(fp_den(x), fp_num(x))
}
define fp_mul : (fn (FP, FP) -> FP) = fun x:FP, y:FP {
fp(field_mul(fp_num(x), fp_num(y)), field_mul(fp_den(x), fp_den(y)))
}
define fp_neg : (fn FP -> FP) = fun x:FP {
fp(rneg(fp_num(x)), fp_den(x))
}
define fp_num : (fn FP -> RExpr) = fun x:FP {
switch x {
case fp(n, d) {
n
}
}
}
define fp_pow : (fn (FP, UInt) -> FP) = fun x:FP, k:UInt {
fp(rpow(fp_num(x), k), rpow(fp_den(x), k))
}
define fp_sub : (fn (FP, FP) -> FP) = fun x:FP, y:FP {
fp(rsub(field_mul(fp_num(x), fp_den(y)), field_mul(fp_num(y), fp_den(x))), field_mul(fp_den(x), fp_den(y)))
}
opaque define frac : (fn (Int, UInt) -> Rat)
opaque recursive fromNat(Nat) -> UInt
fromNat_add: all x:Nat, y:Nat. fromNat(x + y) = fromNat(x) + fromNat(y)
fromNat_div: all x:Nat, y:Nat. fromNat(x) / fromNat(y) = fromNat(x / y)
fromNat_expt: all x:Nat, y:Nat. fromNat(x ^ y) = fromNat(x) ^ fromNat(y)
fromNat_injective: all x:Nat, y:Nat. if fromNat(x) = fromNat(y) then x = y
fromNat_mod: all x:Nat, y:Nat. fromNat(x) % fromNat(y) = fromNat(x % y)
fromNat_mult: all x:Nat, y:Nat. fromNat(x * y) = fromNat(x) * fromNat(y)
from_one: 1 = 1
from_zero: 0 = 0
recfun gcd(a:UInt, b:UInt) -> UInt
measure b of UInt
{
if b = 0 then
a
else
gcd(b, a % b)
}
terminates {
arbitrary a : UInt,
b : UInt
assume bnz: b ≠ 0
have b_pos: 0 < b by {
apply or_not to uint_zero_or_positive[b], bnz
}
conclude a % b < b by {
apply uint_mod_less_divisor[a, b] to b_pos
}
}
recfun gcd(a:Nat, b:Nat) -> Nat
measure b of Nat
{
if b = zero then
a
else
gcd(b, a % b)
}
terminates {
arbitrary a : Nat,
b : Nat
assume bnz: b ≠ zero
have b_pos: zero < b by {
apply or_not to zero_or_positive[b], bnz
}
conclude a % b < b by {
apply mod_less_divisor[a, b] to b_pos
}
}
define gcd : (fn (Int, Int) -> Int) = fun a:Int, b:Int {
pos(gcd(abs(a), abs(b)))
}
gcd_divides: all b:Nat, a:Nat. divides(gcd(a, b), a) and divides(gcd(a, b), b)
recursive get<T>(List<T>,UInt) -> Option<T>{
get([], i) = none
get(node(x, xs), i) =
if i = 0 then
just(x)
else
get(xs, i ∸ 1)
}
get_append_back: all T:type, xs:List<T>, ys:List<T>, i:UInt. get(xs ++ ys, length(xs) + i) = get(ys, i)
get_append_front: all T:type, xs:List<T>, ys:List<T>, i:UInt. if i < length(xs) then get(xs ++ ys, i) = get(xs, i)
get_drop: all T:type, xs:List<T>, n:UInt, i:UInt, d:T. get(drop(xs, n), i) = get(xs, n + i)
get_none: all T:type, xs:List<T>, i:UInt. if length(xs) ≤ i then get(xs, i) = none
greater_implies_not_equal: all x:Nat, y:Nat. if x > y then x ≠ y
define head : (fn <T> List<T> -> Option<T>) = generic T {
fun ls:List<T> {
switch ls {
case [] {
@none<T>
}
case node(x, xs) {
just(x)
}
}
}
}
head_append: all E:type, L:List<E>, R:List<E>. if 0 < length(L) then head(L ++ R) = head(L)
head_inits: all T:type. all xs:List<T>. head(inits(xs)) = just(@[]<T>)
head_tails: all T:type. all xs:List<T>. head(tails(xs)) = just(xs)
inc_add_one: all n:UInt. inc(n) = 1 + n
recursive init<T>(List<T>) -> List<T>{
init([]) = @[]<T>
init(node(x, xs)) =
switch xs {
case [] {
@[]<T>
}
case node(y, ys) {
node(x, init(xs))
}
}
}
init_append_node: all T:type. all xs:List<T>, y:T. init(xs ++ [y]) = xs
recursive inits<T>(List<T>) -> List<List<T>>{
inits([]) = [[]]
inits(node(x, xs)) = node([], map(inits(xs), fun ys:List<T> { node(x, ys) }))
}
int_Even_iff_abs_Even: all x:Int. Even(x) ⇔ Even(abs(x))
int_Even_not_Odd: all n:Int. Even(n) ⇔ not Odd(n)
int_Even_or_Odd: all n:Int. Even(n) or Odd(n)
int_Odd_iff_abs_Odd: all x:Int. Odd(x) ⇔ Odd(abs(x))
int_abs_add: all x:Int, y:Int. abs(x + y) ≤ abs(x) + abs(y)
int_abs_div: all x:Int, y:Int. abs(x / y) = abs(x) / abs(y)
int_abs_eq_iff_eq_or_neg: all x:Int, y:Int. abs(x) = abs(y) ⇔ (x = y or x = - y)
int_abs_eq_zero_iff_zero: all x:Int. abs(x) = 0 ⇔ x = +0
int_abs_eq_zero_implies_zero: all x:Int. if abs(x) = 0 then x = +0
int_abs_le_iff: all x:Int, y:UInt. abs(x) ≤ y ⇔ (- pos(y) ≤ x and x ≤ pos(y))
int_abs_mod: all x:Int, y:Int. abs(x % y) = abs(x) % abs(y)
int_abs_mult: all x:Int, y:Int. abs(x * y) = abs(x) * abs(y)
auto int_abs_negsuc
int_abs_negsuc: all n:UInt. abs(negsuc(n)) = 1 + n
auto int_abs_pos
int_abs_pos: all n:UInt. abs(pos(n)) = n
int_abs_pow: all n:Int, k:UInt. abs(n ^ k) = abs(n) ^ k
int_abs_sub_symm: all x:Int, y:Int. abs(x - y) = abs(y - x)
auto int_abs_zero
int_abs_zero: abs(+0) = 0
int_add_assoc: all x:Int, y:Int, z:Int. x + y + z = x + (y + z)
int_add_both_sides_of_equal: all x:Int, y:Int, z:Int. if x + y = x + z then y = z
int_add_both_sides_of_equal_iff: all x:Int, y:Int, z:Int. x + y = x + z ⇔ y = z
int_add_both_sides_of_equal_right: all x:Int, y:Int, z:Int. if y + x = z + x then y = z
int_add_both_sides_of_less: all x:Int, y:Int, z:Int. x + y < x + z ⇔ y < z
int_add_both_sides_of_less_equal: all x:Int, y:Int, z:Int. x + y ≤ x + z ⇔ y ≤ z
int_add_both_sides_of_less_equal_right: all x:Int, y:Int, z:Int. y + x ≤ z + x ⇔ y ≤ z
int_add_both_sides_of_less_right: all x:Int, y:Int, z:Int. y + x < z + x ⇔ y < z
int_add_commute: all x:Int, y:Int. x + y = y + x
int_add_inverse: all x:Int. x + - x = +0
int_add_le_left_mono: all x:Int, y:Int, z:Int. if y ≤ z then x + y ≤ x + z
int_add_le_right_mono: all x:Int, y:Int, z:Int. if y ≤ z then y + x ≤ z + x
int_add_left_inverse: all x:Int. - x + x = +0
int_add_less_mono_left: all x:Int, y:Int, z:Int. if y < z then x + y < x + z
int_add_less_mono_right: all x:Int, y:Int, z:Int. if y < z then y + x < z + x
int_add_mono_less: all a:Int, b:Int, c:Int, d:Int. if a < c and b < d then a + b < c + d
int_add_mono_less_equal: all a:Int, b:Int, c:Int, d:Int. if a ≤ c and b ≤ d then a + b ≤ c + d
int_add_sub_cancel: all x:Int, y:Int. (x + y) - y = x
auto int_add_zero
int_add_zero: all n:Int. n + +0 = n
int_dichotomy: all x:Int, y:Int. x ≤ y or y < x
int_dist_mult_add: all a:Int, x:Int, y:Int. a * (x + y) = a * x + a * y
int_dist_mult_add_right: all a:Int, x:Int, y:Int. (x + y) * a = x * a + y * a
int_dist_mult_sub: all a:Int, x:Int, y:Int. a * (x - y) = a * x - a * y
int_div_mod: all n:Int, m:Int. if m ≠ +0 then (n / m) * m + n % m = n
int_div_one: all n:Int. n / +1 = n
int_div_self: all n:Int. if n ≠ +0 then n / n = +1
int_div_zero: all n:Int. n / +0 = +0
int_divides_add: all d:Int, m:Int, n:Int. if divides(d, m) and divides(d, n) then divides(d, m + n)
int_divides_antisymmetric: all a:Int, b:Int. if divides(a, b) and divides(b, a) then abs(a) = abs(b)
int_divides_iff_abs: all a:Int, b:Int. divides(a, b) ⇔ divides(abs(a), abs(b))
int_divides_iff_mod_zero: all m:Int, n:Int. if m ≠ +0 then divides(m, n) ⇔ n % m = +0
int_divides_lcm_left: all a:Int, b:Int. divides(a, lcm(a, b))
int_divides_lcm_right: all a:Int, b:Int. divides(b, lcm(a, b))
int_divides_mult_left: all d:Int, n:Int, m:Int. if divides(d, n) then divides(d, m * n)
int_divides_mult_right: all d:Int, n:Int, m:Int. if divides(d, n) then divides(d, n * m)
int_divides_neg_left: all d:Int, n:Int. if divides(d, n) then divides(- d, n)
int_divides_neg_right: all d:Int, n:Int. if divides(d, n) then divides(d, - n)
int_divides_refl: all n:Int. divides(n, n)
int_divides_sub: all d:Int, m:Int, n:Int. if divides(d, m) and divides(d, n) then divides(d, m - n)
int_divides_trans: all a:Int, b:Int, c:Int. if divides(a, b) and divides(b, c) then divides(a, c)
int_divides_zero: all n:Int. divides(n, +0)
int_even_add_even: all x:Int, y:Int. if Even(x) and Even(y) then Even(x + y)
int_even_add_odd: all x:Int, y:Int. if Even(x) and Odd(y) then Odd(x + y)
int_even_mult_left: all x:Int, y:Int. if Even(x) then Even(x * y)
int_even_mult_right: all x:Int, y:Int. if Even(y) then Even(x * y)
int_even_neg: all x:Int. Even(x) ⇔ Even(- x)
int_even_one_odd: all n:Int. if Even(+1 + n) then Odd(n)
int_gcd_commutative: all a:Int, b:Int. gcd(a, b) = gcd(b, a)
int_gcd_divides_left: all a:Int, b:Int. divides(gcd(a, b), a)
int_gcd_divides_right: all a:Int, b:Int. divides(gcd(a, b), b)
int_gcd_greatest: all d:Int, a:Int, b:Int. if divides(d, a) and divides(d, b) then divides(d, gcd(a, b))
int_gcd_lcm_product: all a:Int, b:Int. gcd(a, b) * lcm(a, b) = pos(abs(a * b))
int_greater_implies_not_equal: all x:Int, y:Int. if x > y then x ≠ y
int_lcm_commutative: all a:Int, b:Int. lcm(a, b) = lcm(b, a)
int_lcm_least: all a:Int, b:Int, m:Int. if divides(a, m) and divides(b, m) then divides(lcm(a, b), m)
int_lcm_zero_left: all b:Int. lcm(+0, b) = +0
int_lcm_zero_right: all a:Int. lcm(a, +0) = +0
int_le_abs: all x:Int. x ≤ pos(abs(x))
int_le_iff_diff_nonneg: all a:Int, b:Int. a ≤ b ⇔ +0 ≤ b - a
int_less_equal_antisymmetric: all x:Int, y:Int. if x ≤ y and y ≤ x then x = y
int_less_equal_iff_less_or_equal: all x:Int, y:Int. x ≤ y ⇔ (x < y or x = y)
int_less_equal_iff_not_greater: all x:Int, y:Int. x ≤ y ⇔ not (y < x)
int_less_equal_implies_less_or_equal: all x:Int, y:Int. if x ≤ y then x < y or x = y
int_less_equal_refl: all n:Int. n ≤ n
int_less_equal_trans: all m:Int, n:Int, o:Int. if m ≤ n and n ≤ o then m ≤ o
int_less_iff_diff_pos: all a:Int, b:Int. a < b ⇔ +0 < b - a
int_less_implies_less_equal: all x:Int, y:Int. if x < y then x ≤ y
int_less_implies_not_equal: all x:Int, y:Int. if x < y then x ≠ y
int_less_implies_not_greater: all x:Int, y:Int. if x < y then not (y < x)
int_less_irreflexive: all x:Int. not (x < x)
int_less_or_equal_implies_less_equal: all x:Int, y:Int. if x < y or x = y then x ≤ y
int_less_trans: all x:Int, y:Int, z:Int. if x < y and y < z then x < z
int_less_trans_less_equal_left: all x:Int, y:Int, z:Int. if x ≤ y and y < z then x < z
int_less_trans_less_equal_right: all x:Int, y:Int, z:Int. if x < y and y ≤ z then x < z
auto int_lit_negsuc_eq
int_lit_negsuc_eq: all x:Nat, y:Nat. negsuc(fromNat(lit(x))) = negsuc(fromNat(lit(y))) = (fromNat(lit(x)) = fromNat(lit(y)))
auto int_lit_pos_eq
int_lit_pos_eq: all x:Nat, y:Nat. pos(fromNat(lit(x))) = pos(fromNat(lit(y))) = (fromNat(lit(x)) = fromNat(lit(y)))
auto int_lit_sub_negsuc_negsuc
int_lit_sub_negsuc_negsuc: all x:Nat, y:Nat. negsuc(fromNat(lit(x))) - negsuc(fromNat(lit(y))) = negsuc(fromNat(lit(x))) + - negsuc(fromNat(lit(y)))
auto int_lit_sub_negsuc_pos
int_lit_sub_negsuc_pos: all x:Nat, y:Nat. negsuc(fromNat(lit(x))) - pos(fromNat(lit(y))) = negsuc(fromNat(lit(x))) + - pos(fromNat(lit(y)))
auto int_lit_sub_pos_negsuc
int_lit_sub_pos_negsuc: all x:Nat, y:Nat. pos(fromNat(lit(x))) - negsuc(fromNat(lit(y))) = pos(fromNat(lit(x))) + - negsuc(fromNat(lit(y)))
auto int_lit_sub_pos_pos
int_lit_sub_pos_pos: all x:Nat, y:Nat. pos(fromNat(lit(x))) - pos(fromNat(lit(y))) = pos(fromNat(lit(x))) + - pos(fromNat(lit(y)))
int_max_assoc: all x:Int, y:Int, z:Int. max(max(x, y), z) = max(x, max(y, z))
int_max_equal_greater_left: all x:Int, y:Int. if y ≤ x then max(x, y) = x
int_max_equal_greater_right: all x:Int, y:Int. if x ≤ y then max(x, y) = y
int_max_greater_left: all x:Int, y:Int. x ≤ max(x, y)
int_max_greater_right: all x:Int, y:Int. y ≤ max(x, y)
int_max_idempotent: all x:Int. max(x, x) = x
int_max_is_left_or_right: all x:Int, y:Int. max(x, y) = x or max(x, y) = y
int_max_less_equal: all x:Int, y:Int, z:Int. if x ≤ z and y ≤ z then max(x, y) ≤ z
int_max_min_absorb_left: all x:Int, y:Int. max(x, min(x, y)) = x
int_max_min_absorb_right: all x:Int, y:Int. max(min(x, y), x) = x
int_max_symmetric: all x:Int, y:Int. max(x, y) = max(y, x)
int_min_assoc: all x:Int, y:Int, z:Int. min(min(x, y), z) = min(x, min(y, z))
int_min_equal_less_left: all x:Int, y:Int. if x ≤ y then min(x, y) = x
int_min_equal_less_right: all x:Int, y:Int. if y ≤ x then min(x, y) = y
int_min_greatest_less_equal: all x:Int, y:Int, z:Int. if z ≤ x and z ≤ y then z ≤ min(x, y)
int_min_idempotent: all x:Int. min(x, x) = x
int_min_is_left_or_right: all x:Int, y:Int. min(x, y) = x or min(x, y) = y
int_min_less_equal_left: all x:Int, y:Int. min(x, y) ≤ x
int_min_less_equal_right: all x:Int, y:Int. min(x, y) ≤ y
int_min_max_absorb_left: all x:Int, y:Int. min(x, max(x, y)) = x
int_min_max_absorb_right: all x:Int, y:Int. min(max(x, y), x) = x
int_min_symmetric: all x:Int, y:Int. min(x, y) = min(y, x)
int_mod_less_abs: all n:Int, m:Int. if m ≠ +0 then abs(n % m) < abs(m)
int_mod_neg_divisor: all n:Int, m:Int. n % - m = n % m
int_mod_one: all n:Int. n % +1 = +0
int_mod_self: all n:Int. n % n = +0
int_mod_small: all n:Int, m:Int. if abs(n) < abs(m) then n % m = n
int_mod_zero: all n:Int. n % +0 = n
int_mult_assoc: all x:Int, y:Int, z:Int. x * y * z = x * (y * z)
int_mult_commute: all x:Int, y:Int. x * y = y * x
int_mult_left_cancel: all n:Int, x:Int, y:Int. if n ≠ +0 and n * x = n * y then x = y
auto int_mult_one
int_mult_one: all x:Int. x * +1 = x
int_mult_right_cancel: all n:Int, x:Int, y:Int. if n ≠ +0 and x * n = y * n then x = y
int_mult_to_zero: all x:Int, y:Int. if x * y = +0 then x = +0 or y = +0
auto int_mult_zero
int_mult_zero: all x:Int. x * +0 = +0
int_neg_abs_le: all x:Int. - pos(abs(x)) ≤ x
int_neg_injective: all x:Int, y:Int. if - x = - y then x = y
int_neg_le_iff: all x:Int, y:Int. x ≤ y ⇔ - y ≤ - x
int_neg_le_mono: all x:Int, y:Int. if x ≤ y then - y ≤ - x
int_neg_less_iff: all x:Int, y:Int. x < y ⇔ - y < - x
int_neg_less_mono: all x:Int, y:Int. if x < y then - y < - x
int_neg_mult_left_cancel_le: all n:Int, x:Int, y:Int. if n < +0 and n * x ≤ n * y then y ≤ x
int_neg_mult_left_cancel_less: all n:Int, x:Int, y:Int. if n < +0 and n * x < n * y then y < x
int_neg_mult_mono_less_left: all n:Int, x:Int, y:Int. if n < +0 and x < y then n * y < n * x
int_neg_mult_mono_less_right: all n:Int, x:Int, y:Int. if n < +0 and x < y then y * n < x * n
int_neg_mult_right: all x:Int, y:Int. x * - y = - (x * y)
int_neg_mult_right_cancel_le: all n:Int, x:Int, y:Int. if n < +0 and x * n ≤ y * n then y ≤ x
int_neg_mult_right_cancel_less: all n:Int, x:Int, y:Int. if n < +0 and x * n < y * n then y < x
int_neg_one_pow_even: all k:UInt. if Even(k) then - +1 ^ k = +1
int_neg_one_pow_odd: all k:UInt. if Odd(k) then - +1 ^ k = - +1
int_negsuc_eq_pos_false: all x:UInt, y:UInt. negsuc(x) ≠ pos(y)
int_negsuc_injective: all x:UInt, y:UInt. if negsuc(x) = negsuc(y) then x = y
auto int_negsuc_le_negsuc
int_negsuc_le_negsuc: all au:UInt, bu:UInt. negsuc(au) ≤ negsuc(bu) = bu ≤ au
auto int_negsuc_le_pos
int_negsuc_le_pos: all au:UInt, bu:UInt. negsuc(au) ≤ pos(bu) = true
auto int_negsuc_less_negsuc
int_negsuc_less_negsuc: all au:UInt, bu:UInt. negsuc(au) < negsuc(bu) = bu < au
auto int_negsuc_less_pos
int_negsuc_less_pos: all au:UInt, bu:UInt. negsuc(au) < pos(bu) = true
int_nonneg_mult_mono_le_left: all n:Int, x:Int, y:Int. if +0 ≤ n and x ≤ y then n * x ≤ n * y
int_nonneg_mult_mono_le_right: all n:Int, x:Int, y:Int. if +0 ≤ n and x ≤ y then x * n ≤ y * n
int_nonpos_mult_mono_le_left: all n:Int, x:Int, y:Int. if n ≤ +0 and x ≤ y then n * y ≤ n * x
int_nonpos_mult_mono_le_right: all n:Int, x:Int, y:Int. if n ≤ +0 and x ≤ y then y * n ≤ x * n
int_not_less_equal_iff_greater: all x:Int, y:Int. not (x ≤ y) ⇔ y < x
int_not_less_implies_less_equal: all x:Int, y:Int. if not (x < y) then y ≤ x
int_odd_add_even: all x:Int, y:Int. if Odd(x) and Even(y) then Odd(x + y)
int_odd_add_odd: all x:Int, y:Int. if Odd(x) and Odd(y) then Even(x + y)
int_odd_mult_odd: all x:Int, y:Int. if Odd(x) and Odd(y) then Odd(x * y)
int_odd_neg: all x:Int. Odd(x) ⇔ Odd(- x)
int_odd_one_even: all n:Int. if Odd(+1 + n) then Even(n)
int_one_divides: all n:Int. divides(+1, n)
auto int_one_mult
int_one_mult: all x:Int. +1 * x = x
auto int_one_pow
int_one_pow: all k:UInt. +1 ^ k = +1
int_one_two_odd: all n:Int. Odd(+1 + +2 * n)
int_pos_abs_eq_iff_nonneg: all x:Int. pos(abs(x)) = x ⇔ +0 ≤ x
int_pos_eq_negsuc_false: all x:UInt, y:UInt. pos(x) ≠ negsuc(y)
int_pos_injective: all x:UInt, y:UInt. if pos(x) = pos(y) then x = y
auto int_pos_le_negsuc
int_pos_le_negsuc: all au:UInt, bu:UInt. pos(au) ≤ negsuc(bu) = false
auto int_pos_le_pos
int_pos_le_pos: all au:UInt, bu:UInt. pos(au) ≤ pos(bu) = au ≤ bu
auto int_pos_less_negsuc
int_pos_less_negsuc: all au:UInt, bu:UInt. pos(au) < negsuc(bu) = false
auto int_pos_less_pos
int_pos_less_pos: all au:UInt, bu:UInt. pos(au) < pos(bu) = au < bu
int_pos_mult_left_cancel_le: all n:Int, x:Int, y:Int. if +0 < n and n * x ≤ n * y then x ≤ y
int_pos_mult_left_cancel_less: all n:Int, x:Int, y:Int. if +0 < n and n * x < n * y then x < y
int_pos_mult_mono_less_left: all n:Int, x:Int, y:Int. if +0 < n and x < y then n * x < n * y
int_pos_mult_mono_less_right: all n:Int, x:Int, y:Int. if +0 < n and x < y then x * n < y * n
int_pos_mult_right_cancel_le: all n:Int, x:Int, y:Int. if +0 < n and x * n ≤ y * n then x ≤ y
int_pos_mult_right_cancel_less: all n:Int, x:Int, y:Int. if +0 < n and x * n < y * n then x < y
int_pow_add: all n:Int, j:UInt, k:UInt. n ^ (j + k) = n ^ j * n ^ k
int_pow_eq_zero: all n:Int, k:UInt. if n ^ k = +0 then n = +0
int_pow_mul_base: all k:UInt, a:Int, b:Int. (a * b) ^ k = a ^ k * b ^ k
int_pow_mul_exp: all n:Int, j:UInt, k:UInt. n ^ (j * k) = n ^ k ^ j
int_pow_neg_base_even: all m:UInt, n:Int. - n ^ (2 * m) = n ^ (2 * m)
int_pow_neg_base_odd: all m:UInt, n:Int. - n ^ (1 + 2 * m) = - (n ^ (1 + 2 * m))
int_pow_neg_base_when_even: all n:Int, k:UInt. if Even(k) then - n ^ k = n ^ k
int_pow_neg_base_when_odd: all n:Int, k:UInt. if Odd(k) then - n ^ k = - (n ^ k)
int_pow_nonneg: all n:Int, k:UInt. if +0 ≤ n then +0 ≤ n ^ k
int_pow_nonzero: all n:Int, k:UInt. if n ≠ +0 then n ^ k ≠ +0
auto int_pow_one
int_pow_one: all n:Int. n ^ 1 = n
int_pow_one_add: all n:Int, k:UInt. n ^ (1 + k) = n * n ^ k
auto int_pow_pos
int_pow_pos: all m:UInt, k:UInt. pos(m) ^ k = pos(m ^ k)
int_pow_pos_of_pos: all n:Int, k:UInt. if +0 < n then +0 < n ^ k
int_pow_two: all n:Int. n ^ 2 = n * n
auto int_pow_zero
int_pow_zero: all n:Int. n ^ 0 = +1
int_rev_triangle: all x:Int, y:Int. abs(x) ∸ abs(y) ≤ abs(x - y)
int_rev_triangle_right: all x:Int, y:Int. abs(y) ∸ abs(x) ≤ abs(x - y)
int_sub_add_cancel: all x:Int, y:Int. (x - y) + y = x
int_sub_cancel: all x:Int. x - x = +0
define int_summation : (fn (UInt, UInt, (fn UInt -> Int)) -> Int) = fun k:UInt, begin:UInt, f:(fn UInt -> Int) {
int_summation_nat(toNat(k), toNat(begin), f)
}
int_summation_add: all a:UInt. all b:UInt, s:UInt, t:UInt, f:(fn UInt -> Int), g:(fn UInt -> Int), h:(fn UInt -> Int). if (all i:Nat. if i < toNat(a) then g(s + fromNat(i)) = f(s + fromNat(i))) and (all i:Nat. if i < toNat(b) then h(t + fromNat(i)) = f(s + a + fromNat(i))) then int_summation(a + b, s, f) = int_summation(a, s, g) + int_summation(b, t, h)
int_summation_add_pointwise: all k:UInt, s:UInt, f:(fn UInt -> Int), g:(fn UInt -> Int). int_summation(k, s, fun i:UInt { f(i) + g(i) }) = int_summation(k, s, f) + int_summation(k, s, g)
int_summation_cong: all k:UInt. all f:(fn UInt -> Int), g:(fn UInt -> Int), s:UInt, t:UInt. if (all i:Nat. if i < toNat(k) then f(s + fromNat(i)) = g(t + fromNat(i))) then int_summation(k, s, f) = int_summation(k, t, g)
int_summation_const_zero: all k:UInt, s:UInt. int_summation(k, s, fun i:UInt { +0 }) = +0
recursive int_summation_nat(Nat,Nat,(fn UInt -> Int)) -> Int{
int_summation_nat(zero, begin, f) = +0
int_summation_nat(suc(k), begin, f) = f(fromNat(begin)) + int_summation_nat(k, suc(begin), f)
}
int_summation_neg: all k:UInt, s:UInt, f:(fn UInt -> Int). int_summation(k, s, fun i:UInt { - f(i) }) = - int_summation(k, s, f)
int_summation_next: all n:UInt, s:UInt, f:(fn UInt -> Int). int_summation(1 + n, s, f) = int_summation(n, s, f) + f(s + n)
int_summation_sub: all k:UInt, s:UInt, f:(fn UInt -> Int), g:(fn UInt -> Int). int_summation(k, s, fun i:UInt { f(i) - g(i) }) = int_summation(k, s, f) - int_summation(k, s, g)
int_summation_zero: all begin:UInt, f:(fn UInt -> Int). int_summation(0, begin, f) = +0
int_trichotomy: all x:Int, y:Int. x < y or x = y or y < x
int_two_even: all n:Int. Even(+2 * n)
auto int_zero_add
int_zero_add: all n:Int. +0 + n = n
int_zero_div: all m:Int. +0 / m = +0
int_zero_implies_abs_eq_zero: all x:Int. if x = +0 then abs(x) = 0
int_zero_mod: all m:Int. +0 % m = +0
auto int_zero_mult
int_zero_mult: all x:Int. +0 * x = +0
int_zero_pow: all k:UInt. if 0 < k then +0 ^ k = +0
recursive intersperse<T>(List<T>,T) -> List<T>{
intersperse([], sep) = @[]<T>
intersperse(node(x, xs), sep) =
switch xs {
case [] {
[x]
}
case node(y, ys) {
node(x, node(sep, intersperse(xs, sep)))
}
}
}
intersperse_singleton: all T:type. all x:T, sep:T. intersperse([x], sep) = [x]
opaque define inv : (fn Rat -> Rat)
postulate fun inv : (fn Real -> Real)
define is_even : (fn Nat -> bool) = fun n:Nat {
parity(n, true)
}
is_even_odd: all n:Nat. (if is_even(n) then EvenNat(n)) and if is_odd(n) then OddNat(n)
define is_odd : (fn Nat -> bool) = fun n:Nat {
parity(n, false)
}
recursive iterate<T>(Nat,T,(fn T -> T)) -> T{
iterate(zero, init, f) = init
iterate(suc(n), init, f) = f(@iterate<T>(n, init, f))
}
recursive last<T>(List<T>) -> Option<T>{
last([]) = @none<T>
last(node(x, xs)) =
switch xs {
case [] {
just(x)
}
case node(y, ys) {
last(xs)
}
}
}
last_append_node: all T:type. all xs:List<T>, y:T. last(xs ++ [y]) = just(y)
define lcm : (fn (UInt, UInt) -> UInt) = fun a:UInt, b:UInt {
if a = 0 or b = 0 then
0
else
(a * b) / gcd(a, b)
}
define lcm : (fn (Int, Int) -> Int) = fun a:Int, b:Int {
pos(lcm(abs(a), abs(b)))
}
le_exists_monus: all n:Nat, m:Nat. if n ≤ m then some x:Nat. m = n + x
le_less_trans: all m:Nat, n:Nat, o:Nat. if m ≤ n and n < o then m < o
auto le_lit_suc
le_lit_suc: all x:Nat, y:Nat. lit(suc(x)) ≤ lit(suc(y)) = lit(x) ≤ lit(y)
left_cancel: all x:Nat. all y:Nat, z:Nat. if x + y = x + z then y = z
len_drop: all E:type, xs:List<E>, n:UInt. if n ≤ length(xs) then length(drop(xs, n)) + n = length(xs)
recursive length<E>(List<E>) -> UInt{
length([]) = 0
length(node(n, next)) = 1 + length(next)
}
length_append: all U:type, xs:List<U>, ys:List<U>. length(xs ++ ys) = length(xs) + length(ys)
length_drop: all E:type, xs:List<E>, n:UInt. if n ≤ length(xs) then length(drop(xs, n)) + n = length(xs)
length_drop_zero: all E:type, xs:List<E>, n:UInt. if length(xs) < n then length(drop(xs, n)) = 0
length_filter_complement: all T:type. all xs:List<T>. all p:(fn T -> bool). length(filter(xs, p)) + length(filter(xs, fun y:T { not p(y) })) = length(xs)
length_inits: all T:type. all xs:List<T>. length(inits(xs)) = 1 + length(xs)
length_map: all T:type, f:(fn T -> T), xs:List<T>. length(map(xs, f)) = length(xs)
length_reverse: all U:type, xs:List<U>. length(reverse(xs)) = length(xs)
length_tails: all T:type. all xs:List<T>. length(tails(xs)) = 1 + length(xs)
length_zero_empty: all T:type, xs:List<T>. if length(xs) = 0 then xs = []
less_equal_add: all x:Nat. all y:Nat. x ≤ x + y
less_equal_add_left: all x:Nat, y:Nat. y ≤ x + y
less_equal_add_monus: all m:Nat. all n:Nat, o:Nat. if n ≤ m and m ≤ n + o then m ∸ n ≤ o
less_equal_antisymmetric: all x:Nat. all y:Nat. if x ≤ y and y ≤ x then x = y
less_equal_fromNat: all x:Nat, y:Nat. if x ≤ y then fromNat(x) ≤ fromNat(y)
less_equal_implies_less_or_equal: all x:Nat. all y:Nat. if x ≤ y then x < y or x = y
less_equal_not_equal_implies_less: all x:Nat, y:Nat. if x ≤ y and x ≠ y then x < y
less_equal_pow_log: all n:Nat. n ≤ pow2(log(n))
less_equal_refl: all n:Nat. n ≤ n
less_equal_toNat: all x:UInt, y:UInt. if toNat(x) ≤ toNat(y) then x ≤ y
less_equal_trans: all m:Nat. all n:Nat, o:Nat. if m ≤ n and n ≤ o then m ≤ o
less_fromNat: all x:Nat, y:Nat. if x < y then fromNat(x) < fromNat(y)
less_implies_less_equal: all x:Nat. all y:Nat. if x < y then x ≤ y
less_implies_not_equal: all x:Nat, y:Nat. if x < y then x ≠ y
less_implies_not_greater: all x:Nat. all y:Nat. if x < y then not (y < x)
less_irreflexive: all x:Nat. not (x < x)
less_le_trans: all m:Nat, n:Nat, o:Nat. if m < n and n ≤ o then m < o
auto less_lit_suc
less_lit_suc: all x:Nat, y:Nat. lit(suc(x)) < lit(suc(y)) = lit(x) < lit(y)
auto less_lit_zero_suc
less_lit_zero_suc: all y:Nat. ℕ0 < lit(suc(y)) = true
less_pow_log: all n:UInt. if 0 < n then n < 2 ^ (1 + log(n))
less_suc_iff_suc_less: all x:Nat, y:Nat. x < y ⇔ suc(x) < suc(y)
less_toNat: all x:UInt, y:UInt. if toNat(x) < toNat(y) then x < y
less_trans: all m:Nat, n:Nat, o:Nat. if m < n and n < o then m < o
auto less_zero_false
less_zero_false: all x:Nat. x < zero = false
define lit : (fn Nat -> Nat) = fun a:Nat {
a
}
auto lit_add_div
lit_add_div: all b:Nat, y:Nat. add_div(suc(y), b, suc(y)) = ℕ1 + add_div(zero, b, suc(y))
auto lit_add_div_suc
lit_add_div_suc: all a:Nat, b:Nat, y:Nat. add_div(a, suc(b), y) = add_div(suc(a), b, y)
auto lit_add_div_zero
lit_add_div_zero: all a:Nat, y:Nat. if a < y then add_div(a, zero, y) = ℕ0
auto lit_add_fromNat
lit_add_fromNat: all x:Nat, y:Nat. fromNat(lit(x)) + fromNat(lit(y)) = fromNat(lit(x) + lit(y))
auto lit_add_lit_pos
lit_add_lit_pos: all x:Nat, y:Nat. fromNat(lit(x)) + pos(fromNat(lit(y))) = pos(fromNat(lit(x) + lit(y)))
auto lit_add_negsuc_negsuc
lit_add_negsuc_negsuc: all x:Nat, y:Nat. negsuc(fromNat(lit(x))) + negsuc(fromNat(lit(y))) = negsuc(1 + fromNat(lit(x)) + fromNat(lit(y)))
auto lit_add_negsuc_pos_suc
lit_add_negsuc_pos_suc: all x:Nat, y:Nat. negsuc(fromNat(lit(suc(x)))) + pos(fromNat(lit(suc(y)))) = negsuc(fromNat(lit(x))) + pos(fromNat(lit(y)))
auto lit_add_negsuc_zero_pos_suc
lit_add_negsuc_zero_pos_suc: all x:Nat, y:Nat. -1 + pos(fromNat(lit(suc(y)))) = pos(fromNat(lit(y)))
auto lit_add_pos_lit
lit_add_pos_lit: all x:Nat, y:Nat. pos(fromNat(lit(x))) + fromNat(lit(y)) = pos(fromNat(lit(x) + lit(y)))
auto lit_add_pos_negsuc_suc
lit_add_pos_negsuc_suc: all x:Nat, y:Nat. pos(fromNat(lit(suc(y)))) + negsuc(fromNat(lit(suc(x)))) = pos(fromNat(lit(y))) + negsuc(fromNat(lit(x)))
auto lit_add_pos_pos
lit_add_pos_pos: all x:Nat, y:Nat. pos(fromNat(lit(x))) + pos(fromNat(lit(y))) = pos(fromNat(lit(x) + lit(y)))
auto lit_add_pos_suc_negsuc_zero
lit_add_pos_suc_negsuc_zero: all x:Nat, y:Nat. pos(fromNat(lit(suc(y)))) + -1 = pos(fromNat(lit(y)))
auto lit_add_suc
lit_add_suc: all n:Nat, m:Nat. lit(n) + suc(m) = lit(suc(n)) + m
auto lit_dist_mult_add
lit_dist_mult_add: all a:Nat, x:Nat, y:Nat. lit(a) * (x + y) = lit(a) * x + lit(a) * y
auto lit_dist_mult_add_right
lit_dist_mult_add_right: all x:Nat, y:Nat, a:Nat. (x + y) * lit(a) = x * lit(a) + y * lit(a)
auto lit_div
lit_div: all x:Nat, y:Nat. lit(x) / lit(y) = add_div(zero, x, y)
auto lit_div_cancel
lit_div_cancel: all y:Nat. lit(suc(y)) / lit(suc(y)) = ℕ1
auto lit_expt_fromNat
lit_expt_fromNat: all x:Nat, y:Nat. fromNat(lit(x)) ^ fromNat(lit(y)) = fromNat(lit(x) ^ lit(y))
auto lit_expt_suc
lit_expt_suc: all n:Nat, m:Nat. n ^ lit(suc(m)) = n * n ^ lit(m)
lit_expt_two: all n:Nat. n ^ ℕ2 = n * n
auto lit_expt_zero
lit_expt_zero: all n:Nat. n ^ ℕ0 = ℕ1
auto lit_idem
lit_idem: all x:Nat. lit(lit(x)) = lit(x)
auto lit_less_zero_false
lit_less_zero_false: all x:Nat. x < ℕ0 = false
auto lit_monus_fromNat
lit_monus_fromNat: all x:Nat, y:Nat. fromNat(lit(x)) ∸ fromNat(lit(y)) = fromNat(lit(x) ∸ lit(y))
auto lit_mult_fromNat
lit_mult_fromNat: all x:Nat, y:Nat. fromNat(lit(x)) * fromNat(lit(y)) = fromNat(lit(x) * lit(y))
lit_mult_left_cancel: all m:Nat, a:Nat, b:Nat. if lit(suc(m)) * a = lit(suc(m)) * b then a = b
auto lit_mult_lit_suc
lit_mult_lit_suc: all m:Nat, n:Nat. lit(m) * lit(suc(n)) = lit(m) + lit(m) * lit(n)
auto lit_mult_suc
lit_mult_suc: all m:Nat, n:Nat. lit(m) * suc(n) = lit(m) + lit(m) * n
auto lit_one_expt
lit_one_expt: all n:Nat. ℕ1 ^ n = ℕ1
auto lit_pow_mul_r
lit_pow_mul_r: all m:Nat, n:Nat, o:UInt. fromNat(lit(m)) ^ (fromNat(lit(n)) * o) = fromNat(lit(m)) ^ fromNat(lit(n)) ^ o
auto lit_suc_add
lit_suc_add: all x:Nat, y:Nat. lit(suc(x)) + lit(y) = lit(suc(lit(x) + lit(y)))
lit_suc_add2: all x:Nat, y:Nat. suc(lit(x) + y) = lit(suc(x)) + y
auto lit_suc_less_equal_zero_false
lit_suc_less_equal_zero_false: all x:Nat. lit(suc(x)) ≤ ℕ0 = false
auto lit_suc_monus_suc
lit_suc_monus_suc: all n:Nat, m:Nat. lit(suc(n)) ∸ lit(suc(m)) = lit(n) ∸ lit(m)
auto lit_suc_mult
lit_suc_mult: all m:Nat, n:Nat. lit(suc(m)) * lit(n) = lit(n) + lit(m) * lit(n)
lit_two_mult: all n:Nat. ℕ2 * n = n + n
auto lit_zero_div
lit_zero_div: all x:Nat. ℕ0 / lit(suc(x)) = ℕ0
auto lit_zero_less_equal_true
lit_zero_less_equal_true: all x:Nat. ℕ0 ≤ x = true
opaque define log : (fn UInt -> UInt)
define log : (fn Nat -> Nat) = fun n {
find_log(n, zero, zero)
}
define log2 : (fn Nat -> Nat) = fun n {
find_log2(n, n, zero)
}
log_pow: all n:UInt. log(2 ^ n) = n
recursive map<T,U>(List<T>,(fn T -> U)) -> List<U>{
map([], f) = []
map(node(x, ls), f) = node(f(x), map(ls, f))
}
map_append: all T:type, U:type, f:(fn T -> U), ys:List<T>, xs:List<T>. map(xs ++ ys, f) = map(xs, f) ++ map(ys, f)
map_compose: all T:type, U:type, V:type, f:(fn T -> U), g:(fn U -> V), ls:List<T>. map(map(ls, f), g) = map(ls, g ∘ f)
map_id: all T:type, f:(fn T -> T). if (all x:T. f(x) = x) then all xs:List<T>. map(xs, f) = xs
define max : (fn (UInt, UInt) -> UInt) = fun x:UInt, y:UInt {
if x < y then
y
else
x
}
recursive max(Nat,Nat) -> Nat{
max(zero, n) = n
max(suc(m'), n) =
switch n {
case zero {
suc(m')
}
case suc(n') {
suc(max(m', n'))
}
}
}
define max : (fn (Int, Int) -> Int) = fun x:Int, y:Int {
if x < y then
y
else
x
}
define max : (fn (Rat, Rat) -> Rat) = fun x:Rat, y:Rat {
if x < y then
y
else
x
}
opaque define max : (fn (Real, Real) -> Real)
max_assoc: all x:Nat, y:Nat, z:Nat. max(max(x, y), z) = max(x, max(y, z))
max_equal_greater_left: all x:Nat, y:Nat. if y ≤ x then max(x, y) = x
max_equal_greater_right: all x:Nat, y:Nat. if x ≤ y then max(x, y) = y
max_greater_left: all x:Nat, y:Nat. x ≤ max(x, y)
max_greater_right: all y:Nat, x:Nat. y ≤ max(x, y)
max_is_left_or_right: all x:Nat, y:Nat. max(x, y) = x or max(x, y) = y
max_less_equal: all x:Nat, y:Nat, z:Nat. if x ≤ z and y ≤ z then max(x, y) ≤ z
max_symmetric: all x:Nat, y:Nat. max(x, y) = max(y, x)
define min : (fn (UInt, UInt) -> UInt) = fun x:UInt, y:UInt {
if x < y then
x
else
y
}
recursive min(Nat,Nat) -> Nat{
min(zero, n) = zero
min(suc(m'), n) =
switch n {
case zero {
zero
}
case suc(n') {
suc(min(m', n'))
}
}
}
define min : (fn (Int, Int) -> Int) = fun x:Int, y:Int {
if x < y then
x
else
y
}
define min : (fn (Rat, Rat) -> Rat) = fun x:Rat, y:Rat {
if x < y then
x
else
y
}
opaque define min : (fn (Real, Real) -> Real)
auto mod_negsuc_negsuc
mod_negsuc_negsuc: all au:UInt, bu:UInt. negsuc(au) % negsuc(bu) = - pos((1 + au) % (1 + bu))
auto mod_negsuc_pos
mod_negsuc_pos: all au:UInt, bu:UInt. negsuc(au) % pos(bu) = - pos((1 + au) % bu)
auto mod_pos_negsuc
mod_pos_negsuc: all au:UInt, bu:UInt. pos(au) % negsuc(bu) = pos(au % (1 + bu))
auto mod_pos_pos
mod_pos_pos: all au:UInt, bu:UInt. pos(au) % pos(bu) = pos(au % bu)
model WellFounded<UInt> {
fun operator < = operator <
}
model WellFounded<Nat> {
fun operator < = operator <
}
model AddCommMonoid<UInt> {
fun operator + = operator +
fun zero = 0
}
model CommSemiring<UInt> {
fun operator * = operator *
fun one = 1
fun from_uint = fun n:UInt { n }
fun operator ^ = operator ^
}
model AddCommMonoid<Int> {
fun operator + = operator +
fun zero = +0
}
model AddCommGroup<Int> {
fun operator - = operator -
fun operator - = operator -
}
model CommSemiring<Int> {
fun operator * = operator *
fun one = +1
fun from_uint = fun n:UInt { pos(n) }
fun operator ^ = operator ^
}
model CommRing<Int> {
}
model AddCommMonoid<Rat> {
fun operator + = operator +
fun zero = rat(+0)
}
model AddCommGroup<Rat> {
fun operator - = operator -
fun operator - = operator -
}
model OrderedAddCommGroup<Rat> {
fun operator ≤ = operator ≤
fun operator < = operator <
}
model OrderedQVectorSpace<Rat> {
fun scale = operator *
}
model CommSemiring<Rat> {
fun operator * = operator *
fun one = rat(+1)
fun from_uint = fun n:UInt { rat(pos(n)) }
fun operator ^ = operator ^
}
model CommRing<Rat> {
}
model Field<Rat> {
fun inv = inv
fun operator / = operator /
fun from_frac = fun n:UInt,d:UInt { frac(pos(n), d) }
}
model AddCommMonoid<Real> {
fun operator + = operator +
fun zero = real(+0)
}
model AddCommGroup<Real> {
fun operator - = operator -
fun operator - = operator -
}
model OrderedAddCommGroup<Real> {
fun operator ≤ = operator ≤
fun operator < = operator <
}
model OrderedQVectorSpace<Real> {
fun scale = real_scale
}
model CommSemiring<Real> {
fun operator * = operator *
fun one = real(+1)
fun from_uint = fun n:UInt { real(pos(n)) }
fun operator ^ = operator ^
}
model CommRing<Real> {
}
model Field<Real> {
fun inv = inv
fun operator / = operator /
fun from_frac = fun n:UInt,d:UInt { real(frac(pos(n), d)) }
}
monus_add_assoc: all n:Nat. all l:Nat, m:Nat. if m ≤ n then l + (n ∸ m) = (l + n) ∸ m
monus_add_identity: all n:Nat. all m:Nat. if m ≤ n then m + (n ∸ m) = n
monus_monus_eq_monus_add: all x:Nat. all y:Nat. all z:Nat. x ∸ y ∸ z = x ∸ (y + z)
monus_order: all x:Nat, y:Nat, z:Nat. x ∸ y ∸ z = x ∸ z ∸ y
monus_right_cancel: all x:Nat, y:Nat, a:Nat. if x ∸ a = y ∸ a and a ≤ x and a ≤ y then x = y
mset_equal_implies_set_equal: all T:type, xs:List<T>, ys:List<T>. if mset_of(xs) = mset_of(ys) then set_of(xs) = set_of(ys)
recursive mset_of<T>(List<T>) -> MultiSet<T>{
mset_of([]) = m_empty()
mset_of(node(x, xs)) = m_one(x) ⨄ mset_of(xs)
}
mset_of_empty: all T:type, xs:List<T>. if mset_of(xs) = @m_empty<T>() then xs = []
mult_assoc: all m:Nat. all n:Nat, o:Nat. m * n * o = m * (n * o)
mult_cancel_left_less: all x:Nat, y:Nat, z:Nat. if x * y < x * z then y < z
mult_cancel_right_less: all x:Nat, y:Nat, z:Nat. if y * x < z * x then y < z
mult_commute: all m:Nat. all n:Nat. m * n = n * m
auto mult_lit_neg_lit
mult_lit_neg_lit: all x:Nat, y:Nat. fromNat(lit(x)) * negsuc(fromNat(lit(y))) = - pos(fromNat(lit(x)) + fromNat(lit(x)) * fromNat(lit(y)))
auto mult_lit_pos_lit
mult_lit_pos_lit: all x:Nat, y:Nat. fromNat(lit(x)) * pos(fromNat(lit(y))) = pos(fromNat(lit(x) * lit(y)))
mult_mono_le: all n:Nat. all x:Nat, y:Nat. if x ≤ y then n * x ≤ n * y
mult_mono_le2: all n:Nat, x:Nat, m:Nat, y:Nat. if n ≤ m and x ≤ y then n * x ≤ m * y
mult_mono_le_r: all n:Nat. all x:Nat, y:Nat. if x ≤ y then x * n ≤ y * n
auto mult_neg_lit_lit
mult_neg_lit_lit: all x:Nat, y:Nat. negsuc(fromNat(lit(x))) * fromNat(lit(y)) = - pos(fromNat(lit(y)) + fromNat(lit(y)) * fromNat(lit(x)))
auto mult_neg_lit_neg_lit
mult_neg_lit_neg_lit: all x:Nat, y:Nat. negsuc(fromNat(lit(x))) * negsuc(fromNat(lit(y))) = pos((1 + fromNat(lit(x))) * (1 + fromNat(lit(y))))
auto mult_neg_lit_pos
mult_neg_lit_pos: all x:Nat, y:Nat. negsuc(fromNat(lit(x))) * pos(fromNat(lit(y))) = - pos(fromNat(lit(y)) + fromNat(lit(y)) * fromNat(lit(x)))
auto mult_pos_lit_lit
mult_pos_lit_lit: all x:Nat, y:Nat. pos(fromNat(lit(x))) * fromNat(lit(y)) = pos(fromNat(lit(x) * lit(y)))
auto mult_pos_lit_neg_lit
mult_pos_lit_neg_lit: all x:Nat, y:Nat. pos(fromNat(lit(x))) * negsuc(fromNat(lit(y))) = - pos(fromNat(lit(x)) + fromNat(lit(x)) * fromNat(lit(y)))
auto mult_pos_lit_pos_lit
mult_pos_lit_pos_lit: all x:Nat, y:Nat. pos(fromNat(lit(x))) * pos(fromNat(lit(y))) = pos(fromNat(lit(x) * lit(y)))
mult_pos_pos: all x:UInt, y:UInt. pos(x) * pos(y) = pos(x * y)
mult_suc: all m:Nat. all n:Nat. m * suc(n) = m + m * n
mult_to_zero: all n:Nat, m:Nat. if m * n = zero then m = zero or n = zero
mult_two: all n:Nat. n + n = ℕ2 * n
auto mult_zero
mult_zero: all n:Nat. n * zero = zero
n_le_nn: all n:Nat. n ≤ n * n
nat_add_to_zero: all n:Nat, m:Nat. if n + m = ℕ0 then n = ℕ0 and m = ℕ0
auto nat_add_zero
nat_add_zero: all x:Nat. x + ℕ0 = x
nat_less_add_pos: all x:Nat, y:Nat. if ℕ0 < y then x < x + y
nat_monus_cancel: all n:Nat. n ∸ n = ℕ0
nat_monus_one_pred: all x:Nat. x ∸ ℕ1 = pred(x)
auto nat_monus_zero
nat_monus_zero: all n:Nat. n ∸ ℕ0 = n
nat_monus_zero_iff_less_eq: all x:Nat, y:Nat. x ≤ y ⇔ x ∸ y = ℕ0
auto nat_mult_one
nat_mult_one: all n:Nat. n * ℕ1 = n
auto nat_mult_zero
nat_mult_zero: all x:Nat. lit(x) * ℕ0 = ℕ0
nat_not_one_add_zero: all n:Nat. ℕ1 + n ≠ ℕ0
auto nat_one_mult
nat_one_mult: all n:Nat. ℕ1 * n = n
nat_positive_suc: all n:Nat. if ℕ0 < n then some n':Nat. n = ℕ1 + n'
nat_suc_one_add: all n:Nat. suc(n) = ℕ1 + n
auto nat_zero_add
nat_zero_add: all y:Nat. ℕ0 + y = y
nat_zero_le_zero: all x:Nat. if x ≤ ℕ0 then x = ℕ0
nat_zero_less_one_add: all n:Nat. ℕ0 < ℕ1 + n
nat_zero_monus: all m:Nat. ℕ0 ∸ lit(m) = ℕ0
auto nat_zero_mult
nat_zero_mult: all y:Nat. ℕ0 * lit(y) = ℕ0
nat_zero_or_positive: all x:Nat. x = ℕ0 or ℕ0 < x
neg_distr_add: all x:Int, y:Int. - (x + y) = - x + - y
neg_involutive: all n:Int. - - n = n
auto neg_lit_suc
neg_lit_suc: all x:Nat. - fromNat(lit(suc(x))) = negsuc(fromNat(lit(x)))
auto neg_lit_zero
neg_lit_zero: - +0 = +0
auto neg_negsuc_lit
neg_negsuc_lit: all x:Nat. - negsuc(fromNat(lit(x))) = pos(fromNat(lit(suc(x))))
neg_pos: all n:UInt. - pos(1 + n) = negsuc(n)
auto neg_pos_lit_suc
neg_pos_lit_suc: all x:Nat. - pos(fromNat(lit(suc(x)))) = negsuc(fromNat(lit(x)))
auto neg_uint_zero
neg_uint_zero: - 0 = +0
neg_zero: - +0 = +0
not_equal_not_eq: all m:Nat, n:Nat. if not equal(m, n) then m ≠ n
not_less_equal_iff_greater: all x:Nat, y:Nat. not (x ≤ y) ⇔ y < x
not_less_equal_less_equal: all x:Nat, y:Nat. if not (x ≤ y) then y ≤ x
not_less_implies_less_equal: all x:Nat. all y:Nat. if not (x < y) then y ≤ x
not_set_of_remove_all: all W:type, xs:List<W>, y:W. not (y ∈ set_of(remove_all(xs, y)))
not_suc_less_equal_zero: all x:Nat. not (suc(x) ≤ zero)
opaque define num : (fn Rat -> Int)
auto one_mult
one_mult: all n:Nat. suc(zero) * n = n
define operator % : (fn (UInt, UInt) -> UInt) = fun n:UInt, m:UInt {
n ∸ (n / m) * m
}
define operator % : (fn (Nat, Nat) -> Nat) = fun n:Nat, m:Nat {
n ∸ (n / m) * m
}
opaque define operator % : (fn (Int, Int) -> Int)
opaque recursive operator *(UInt,UInt) -> UInt
recursive operator *(Nat,Nat) -> Nat{
operator *(zero, m) = zero
operator *(suc(n), m) = m + n * m
}
opaque define operator * : (fn (Int, Int) -> Int)
opaque define operator * : (fn (UInt, Int) -> Int)
opaque define operator * : (fn (Int, UInt) -> Int)
opaque define operator * : (fn (Rat, Rat) -> Rat)
postulate fun operator * : (fn (Real, Real) -> Real)
opaque recursive operator +(UInt,UInt) -> UInt
recursive operator +(Nat,Nat) -> Nat{
operator +(zero, m) = m
operator +(suc(n), m) = suc(n + m)
}
opaque define operator + : (fn (Int, Int) -> Int)
opaque define operator + : (fn (UInt, Int) -> Int)
opaque define operator + : (fn (Int, UInt) -> Int)
opaque define operator + : (fn (Rat, Rat) -> Rat)
postulate fun operator + : (fn (Real, Real) -> Real)
recursive operator ++<E>(List<E>,List<E>) -> List<E>{
operator ++([], ys) = ys
operator ++(node(n, xs), ys) = node(n, xs ++ ys)
}
opaque define operator - : (fn Int -> Int)
opaque define operator - : (fn UInt -> Int)
define operator - : (fn (Int, Int) -> Int) = fun n:Int, m:Int {
n + - m
}
opaque define operator - : (fn (UInt, Int) -> Int)
opaque define operator - : (fn (Int, UInt) -> Int)
opaque define operator - : (fn (UInt, UInt) -> Int)
opaque define operator - : (fn Rat -> Rat)
opaque define operator - : (fn (Rat, Rat) -> Rat)
postulate fun operator - : (fn Real -> Real)
opaque define operator - : (fn (Real, Real) -> Real)
recfun operator /(n:UInt, m:UInt) -> UInt
measure n of UInt
{
if n < m then
0
else
if m = 0 then
0
else
1 + (n ∸ m) / m
}
terminates {
arbitrary n : UInt,
m : UInt
assume cond: not (n < m) and m ≠ 0
suffices m + (n ∸ m) < m + n by {
uint_add_both_sides_of_less[m, n ∸ m, n]
}
suffices n < m + n by {
have m_n: m ≤ n by {
apply uint_not_less_implies_less_equal to conjunct 0 of cond
}
replace (apply uint_monus_add_identity[n, m] to m_n)
.
}
have m_pos: 0 < m by {
apply uint_not_zero_pos to conjunct 1 of cond
}
conclude n < m + n by {
replace uint_add_commute in apply uint_less_add_pos[n, m] to expand lit | fromNat in m_pos
}
}
recfun operator /(n:Nat, m:Nat) -> Nat
measure n of Nat
{
if n < m then
zero
else
if m = zero then
zero
else
suc(zero) + (n ∸ m) / m
}
terminates {
arbitrary n : Nat,
m : Nat
assume cond: not (n < m) and m ≠ zero
suffices m + (n ∸ m) < m + n by {
add_both_sides_of_less[m, n ∸ m, n]
}
suffices n < m + n by {
have m_n: m ≤ n by {
apply not_less_implies_less_equal to conjunct 0 of cond
}
replace (apply monus_add_identity[n, m] to m_n)
.
}
obtain m' where m_sm : m = suc(m') from apply not_zero_suc to conjunct 1 of cond
suffices n < suc(m') + n by {
replace m_sm
.
}
suffices n ≤ m' + n by {
expand operator + | operator < | operator ≤
.
}
replace add_commute
conclude n ≤ n + m' by {
less_equal_add
}
}
opaque define operator / : (fn (Int, Int) -> Int)
opaque define operator / : (fn (Int, UInt) -> Int)
opaque define operator / : (fn (Rat, Rat) -> Rat)
opaque define operator / : (fn (Real, Real) -> Real)
opaque recursive operator <(UInt,UInt) -> bool
define operator < : (fn (Nat, Nat) -> bool) = fun x:Nat, y:Nat {
suc(x) ≤ y
}
opaque define operator < : (fn (Int, Int) -> bool)
opaque define operator < : (fn (Rat, Rat) -> bool)
opaque define operator < : (fn (Real, Real) -> bool)
define operator > : (fn (UInt, UInt) -> bool) = fun x:UInt, y:UInt {
y < x
}
define operator > : (fn (Nat, Nat) -> bool) = fun x:Nat, y:Nat {
y < x
}
define operator > : (fn (Int, Int) -> bool) = fun x:Int, y:Int {
y < x
}
define operator > : (fn (Rat, Rat) -> bool) = fun x:Rat, y:Rat {
y < x
}
define operator > : (fn (Real, Real) -> bool) = fun x:Real, y:Real {
y < x
}
opaque define operator ^ : (fn (UInt, UInt) -> UInt)
define operator ^ : (fn (Nat, Nat) -> Nat) = fun a:Nat, b:Nat {
expt(b, a)
}
opaque define operator ^ : (fn (Int, UInt) -> Int)
opaque define operator ^ : (fn (Rat, UInt) -> Rat)
opaque define operator ^ : (fn (Real, UInt) -> Real)
opaque recursive operator ∸(UInt,UInt) -> UInt
recursive operator ∸(Nat,Nat) -> Nat{
operator ∸(zero, m) = zero
operator ∸(suc(n), m) =
switch m {
case zero {
suc(n)
}
case suc(m') {
n ∸ m'
}
}
}
define operator ≤ : (fn (UInt, UInt) -> bool) = fun x:UInt, y:UInt {
x < y or x = y
}
recursive operator ≤(Nat,Nat) -> bool{
operator ≤(zero, m) = true
operator ≤(suc(n'), m) =
switch m {
case zero {
false
}
case suc(m') {
n' ≤ m'
}
}
}
opaque define operator ≤ : (fn (Int, Int) -> bool)
opaque define operator ≤ : (fn (Rat, Rat) -> bool)
postulate fun operator ≤ : (fn (Real, Real) -> bool)
define operator ≥ : (fn (UInt, UInt) -> bool) = fun x:UInt, y:UInt {
y ≤ x
}
define operator ≥ : (fn (Nat, Nat) -> bool) = fun x:Nat, y:Nat {
y ≤ x
}
define operator ≥ : (fn (Int, Int) -> bool) = fun x:Int, y:Int {
y ≤ x
}
define operator ≥ : (fn (Rat, Rat) -> bool) = fun x:Rat, y:Rat {
y ≤ x
}
define operator ≥ : (fn (Real, Real) -> bool) = fun x:Real, y:Real {
y ≤ x
}
recursive parity(Nat,bool) -> bool{
parity(zero, b) = b
parity(suc(n'), b) = parity(n', not b)
}
define pn_add : (fn (PN, PN) -> PN) = fun x:PN, y:PN {
pn(ring_add(pn_pos(x), pn_pos(y)), ring_add(pn_neg(x), pn_neg(y)))
}
define pn_mul : (fn (PN, PN) -> PN) = fun x:PN, y:PN {
pn(ring_add(ring_mul(pn_pos(x), pn_pos(y)), ring_mul(pn_neg(x), pn_neg(y))), ring_add(ring_mul(pn_pos(x), pn_neg(y)), ring_mul(pn_neg(x), pn_pos(y))))
}
define pn_neg : (fn PN -> List<Mono>) = fun x:PN {
switch x {
case pn(p, n) {
n
}
}
}
recursive pn_npow(Nat,PN) -> PN{
pn_npow(zero, x) = pn(ring_norm(rone), [])
pn_npow(suc(n), x) = pn_mul(x, pn_npow(n, x))
}
define pn_pos : (fn PN -> List<Mono>) = fun x:PN {
switch x {
case pn(p, n) {
p
}
}
}
define pn_swap : (fn PN -> PN) = fun x:PN {
pn(pn_neg(x), pn_pos(x))
}
recursive poly_eval(List<Real>,Real) -> Real{
poly_eval([], x) = real(+0)
poly_eval(node(c, cs), x) = c + x * poly_eval(cs, x)
}
pos_mult_both_sides_of_less: all n:Nat, x:Nat, y:Nat. if ℕ0 < n and x < y then n * x < n * y
pos_mult_left_cancel: all m:Nat, a:Nat, b:Nat. if ℕ0 < m and m * a = m * b then a = b
pos_mult_left_cancel_less_equal: all n:Nat, x:Nat, y:Nat. if ℕ0 < n and n * x ≤ n * y then x ≤ y
pos_mult_right_cancel_less: all c:Nat, a:Nat, b:Nat. if ℕ0 < c and a * c < b * c then a < b
recursive pow2(Nat) -> Nat{
pow2(zero) = suc(zero)
pow2(suc(n')) = suc(suc(zero)) * pow2(n')
}
pow_add_r: all n:Nat, m:Nat, o:Nat. m ^ (n + o) = m ^ n * m ^ o
pow_eq_zero: all n:Nat, m:Nat. if m ^ n = zero then m = zero
pow_le_mono_l: all c:Nat, a:Nat, b:Nat. if a ≤ b then a ^ c ≤ b ^ c
pow_log2_greater: all n:Nat. n < ℕ2 * ℕ2 ^ log2(n)
pow_log2_less_equal: all n:Nat. if ℕ0 < n then ℕ2 ^ log2(n) ≤ n
pow_lt_mono_l: all c:Nat, a:Nat, b:Nat. if zero < c then if a < b then a ^ c < b ^ c
pow_lt_mono_r: all c:Nat, a:Nat, b:Nat. if suc(zero) < a then if b < c then a ^ b < a ^ c
pow_mul_l: all o:Nat, m:Nat, n:Nat. (m * n) ^ o = m ^ o * n ^ o
pow_mul_r: all o:Nat, m:Nat, n:Nat. m ^ n ^ o = m ^ (n * o)
pow_pos_nonneg: all b:Nat, a:Nat. if zero < a then zero < a ^ b
pow_zero_l: all a:Nat. if zero < a then zero ^ a = zero
define pred : (fn Nat -> Nat) = fun n:Nat {
switch n {
case zero {
zero
}
case suc(n') {
n'
}
}
}
opaque define rat : (fn Int -> Rat)
opaque define rat : (fn UInt -> Rat)
rat_abs_add: all x:Rat, y:Rat. abs(x + y) ≤ abs(x) + abs(y)
rat_abs_le_iff: all x:Rat, y:Rat. abs(x) ≤ y = (- y ≤ x and x ≤ y)
rat_abs_mult: all x:Rat, y:Rat. abs(x * y) = abs(x) * abs(y)
rat_abs_neg: all x:Rat. abs(- x) = abs(x)
rat_abs_nonneg: all x:Rat. rat(+0) ≤ abs(x)
rat_abs_nonneg_eq: all x:Rat. if rat(+0) ≤ x then abs(x) = x
rat_abs_nonpos_eq: all x:Rat. if x ≤ rat(+0) then abs(x) = - x
rat_add_assoc: all x:Rat, y:Rat, z:Rat. x + y + z = x + (y + z)
rat_add_both_sides_of_equal: all x:Rat, y:Rat, z:Rat. x + y = x + z = (y = z)
rat_add_both_sides_of_equal_right: all x:Rat, y:Rat, z:Rat. y + x = z + x = (y = z)
rat_add_both_sides_of_less: all x:Rat, y:Rat, z:Rat. x + y < x + z = y < z
rat_add_both_sides_of_less_equal: all x:Rat, y:Rat, z:Rat. x + y ≤ x + z = y ≤ z
rat_add_both_sides_of_less_equal_right: all x:Rat, y:Rat, z:Rat. y + x ≤ z + x = y ≤ z
rat_add_both_sides_of_less_right: all x:Rat, y:Rat, z:Rat. y + x < z + x = y < z
rat_add_commute: all x:Rat, y:Rat. x + y = y + x
rat_add_frac: all n:Int, d:UInt, m:Int, e:UInt. if 0 < d and 0 < e then frac(n, d) + frac(m, e) = frac(n * pos(e) + m * pos(d), d * e)
rat_add_inverse: all x:Rat. x + - x = rat(+0)
rat_add_le_right_mono: all x:Rat, y:Rat, z:Rat. if x ≤ y then x + z ≤ y + z
rat_add_left_inverse: all x:Rat. - x + x = rat(+0)
rat_add_mono_less: all a:Rat, b:Rat, c:Rat, d:Rat. if a < c and b < d then a + b < c + d
rat_add_mono_less_equal: all a:Rat, b:Rat, c:Rat, d:Rat. if a ≤ c and b ≤ d then a + b ≤ c + d
rat_add_sub_cancel: all x:Rat, y:Rat. (x + y) - y = x
auto rat_add_zero
rat_add_zero: all x:Rat. x + rat(+0) = x
rat_den_int: all n:Int. den(rat(n)) = 1
rat_den_neg: all x:Rat. den(- x) = den(x)
rat_den_pos: all x:Rat. 0 < den(x)
rat_dichotomy: all x:Rat, y:Rat. x ≤ y or y < x
rat_dist_mult_add: all x:Rat, y:Rat, z:Rat. x * (y + z) = x * y + x * z
rat_dist_mult_add_right: all x:Rat, y:Rat, z:Rat. (y + z) * x = y * x + z * x
rat_dist_mult_sub: all x:Rat, y:Rat, z:Rat. x * (y - z) = x * y - x * z
rat_dist_mult_sub_right: all x:Rat, y:Rat, z:Rat. (y - z) * x = y * x - z * x
rat_div_def: all x:Rat, y:Rat. x / y = x * inv(y)
rat_div_mult_cancel: all x:Rat, y:Rat. if y ≠ rat(+0) then (x / y) * y = x
auto rat_div_one
rat_div_one: all x:Rat. x / rat(+1) = x
rat_div_self: all x:Rat. if x ≠ rat(+0) then x / x = rat(+1)
auto rat_div_zero
rat_div_zero: all x:Rat. x / rat(+0) = rat(+0)
rat_eq_cross: all x:Rat, y:Rat. if num(x) * pos(den(y)) = num(y) * pos(den(x)) then x = y
rat_frac_cross: all n:Int, d:UInt. if 0 < d then num(frac(n, d)) * pos(d) = n * pos(den(frac(n, d)))
rat_frac_cross_eq: all n:Int, d:UInt, m:Int, e:UInt. if 0 < d and 0 < e and n * pos(e) = m * pos(d) then frac(n, d) = frac(m, e)
rat_frac_div: all n:Int, d:UInt. frac(n, d) = rat(n) / rat(pos(d))
rat_frac_eq_cross: all n:Int, d:UInt, m:Int, e:UInt. if 0 < d and 0 < e and frac(n, d) = frac(m, e) then n * pos(e) = m * pos(d)
rat_frac_eq_iff: all n:Int, d:UInt, m:Int, e:UInt. if 0 < d and 0 < e then frac(n, d) = frac(m, e) = (n * pos(e) = m * pos(d))
auto rat_frac_lit_add
rat_frac_lit_add: all n:Int, y:Nat, m:Int, z:Nat. frac(n, fromNat(lit(suc(y)))) + frac(m, fromNat(lit(suc(z)))) = frac(n * pos(fromNat(lit(suc(z)))) + m * pos(fromNat(lit(suc(y)))), fromNat(lit(suc(y))) * fromNat(lit(suc(z))))
auto rat_frac_lit_add_int
rat_frac_lit_add_int: all n:Int, y:Nat, m:Int. frac(n, fromNat(lit(suc(y)))) + rat(m) = frac(n + m * pos(fromNat(lit(suc(y)))), fromNat(lit(suc(y))) * 1)
auto rat_frac_lit_div
rat_frac_lit_div: all n:Int, y:Nat, m:Int, z:Nat. frac(n, fromNat(lit(suc(y)))) / frac(m, fromNat(lit(suc(z)))) = frac(n, fromNat(lit(suc(y)))) * inv(frac(m, fromNat(lit(suc(z)))))
auto rat_frac_lit_div_int
rat_frac_lit_div_int: all n:Int, y:Nat, m:Int. frac(n, fromNat(lit(suc(y)))) / rat(m) = frac(n, fromNat(lit(suc(y)))) * inv(rat(m))
auto rat_frac_lit_eq
rat_frac_lit_eq: all n:Int, y:Nat, m:Int, z:Nat. frac(n, fromNat(lit(suc(y)))) = frac(m, fromNat(lit(suc(z)))) = (n * pos(fromNat(lit(suc(z)))) = m * pos(fromNat(lit(suc(y)))))
auto rat_frac_lit_eq_int
rat_frac_lit_eq_int: all n:Int, y:Nat, m:Int. frac(n, fromNat(lit(suc(y)))) = rat(m) = (n = m * pos(fromNat(lit(suc(y)))))
auto rat_frac_lit_le
rat_frac_lit_le: all n:Int, y:Nat, m:Int, z:Nat. frac(n, fromNat(lit(suc(y)))) ≤ frac(m, fromNat(lit(suc(z)))) = n * pos(fromNat(lit(suc(z)))) ≤ m * pos(fromNat(lit(suc(y))))
auto rat_frac_lit_le_int
rat_frac_lit_le_int: all n:Int, y:Nat, m:Int. frac(n, fromNat(lit(suc(y)))) ≤ rat(m) = n ≤ m * pos(fromNat(lit(suc(y))))
auto rat_frac_lit_less
rat_frac_lit_less: all n:Int, y:Nat, m:Int, z:Nat. frac(n, fromNat(lit(suc(y)))) < frac(m, fromNat(lit(suc(z)))) = n * pos(fromNat(lit(suc(z)))) < m * pos(fromNat(lit(suc(y))))
auto rat_frac_lit_less_int
rat_frac_lit_less_int: all n:Int, y:Nat, m:Int. frac(n, fromNat(lit(suc(y)))) < rat(m) = n < m * pos(fromNat(lit(suc(y))))
auto rat_frac_lit_mult
rat_frac_lit_mult: all n:Int, y:Nat, m:Int, z:Nat. frac(n, fromNat(lit(suc(y)))) * frac(m, fromNat(lit(suc(z)))) = frac(n * m, fromNat(lit(suc(y))) * fromNat(lit(suc(z))))
auto rat_frac_lit_mult_int
rat_frac_lit_mult_int: all n:Int, y:Nat, m:Int. frac(n, fromNat(lit(suc(y)))) * rat(m) = frac(n * m, fromNat(lit(suc(y))) * 1)
auto rat_frac_lit_neg
rat_frac_lit_neg: all n:Int, y:Nat. - frac(n, fromNat(lit(suc(y)))) = frac(- n, fromNat(lit(suc(y))))
auto rat_frac_lit_one
rat_frac_lit_one: all n:Int. frac(n, 1) = rat(n)
auto rat_frac_lit_reduce
rat_frac_lit_reduce: all x:Nat, y:Nat. if 1 < gcd(fromNat(lit(suc(x))), fromNat(lit(suc(y)))) then frac(pos(fromNat(lit(suc(x)))), fromNat(lit(suc(y)))) = frac(pos(fromNat(lit(suc(x)) / gcd(lit(suc(x)), lit(suc(y))))), fromNat(lit(suc(y)) / gcd(lit(suc(x)), lit(suc(y)))))
auto rat_frac_lit_reduce_neg
rat_frac_lit_reduce_neg: all x:Nat, y:Nat. if 1 < gcd(fromNat(lit(suc(x))), fromNat(lit(suc(y)))) then frac(negsuc(fromNat(lit(x))), fromNat(lit(suc(y)))) = frac(- pos(fromNat(lit(suc(x)) / gcd(lit(suc(x)), lit(suc(y))))), fromNat(lit(suc(y)) / gcd(lit(suc(x)), lit(suc(y)))))
auto rat_frac_lit_sub
rat_frac_lit_sub: all n:Int, y:Nat, m:Int, z:Nat. frac(n, fromNat(lit(suc(y)))) - frac(m, fromNat(lit(suc(z)))) = frac(n, fromNat(lit(suc(y)))) + frac(- m, fromNat(lit(suc(z))))
auto rat_frac_lit_sub_int
rat_frac_lit_sub_int: all n:Int, y:Nat, m:Int. frac(n, fromNat(lit(suc(y)))) - rat(m) = frac(n, fromNat(lit(suc(y)))) + rat(- m)
auto rat_frac_lit_zero
rat_frac_lit_zero: all n:Int. frac(n, 0) = rat(+0)
rat_frac_neg: all n:Int, d:UInt. frac(- n, d) = - frac(n, d)
rat_frac_num_den: all x:Rat. frac(num(x), den(x)) = x
rat_frac_rep: all x:Rat. some n:Int,d:UInt. 0 < d and x = frac(n, d)
rat_frac_scale: all k:UInt, n:Int, d:UInt. if 0 < k then frac(pos(k) * n, k * d) = frac(n, d)
rat_frac_self: all k:UInt. if 0 < k then frac(pos(k), k) = rat(+1)
auto rat_frac_zero
rat_frac_zero: all d:UInt. frac(+0, d) = rat(+0)
auto rat_int_add
rat_int_add: all n:Int, m:Int. rat(n) + rat(m) = rat(n + m)
auto rat_int_add_frac_lit
rat_int_add_frac_lit: all m:Int, n:Int, y:Nat. rat(m) + frac(n, fromNat(lit(suc(y)))) = frac(m * pos(fromNat(lit(suc(y)))) + n, 1 * fromNat(lit(suc(y))))
auto rat_int_div
rat_int_div: all n:Int, m:Int. rat(n) / rat(m) = rat(n) * inv(rat(m))
auto rat_int_div_frac_lit
rat_int_div_frac_lit: all m:Int, n:Int, y:Nat. rat(m) / frac(n, fromNat(lit(suc(y)))) = rat(m) * inv(frac(n, fromNat(lit(suc(y)))))
auto rat_int_eq
rat_int_eq: all n:Int, m:Int. rat(n) = rat(m) = (n = m)
auto rat_int_eq_frac_lit
rat_int_eq_frac_lit: all m:Int, n:Int, y:Nat. rat(m) = frac(n, fromNat(lit(suc(y)))) = (m * pos(fromNat(lit(suc(y)))) = n)
rat_int_frac: all n:Int. rat(n) = frac(n, 1)
rat_int_injective: all n:Int, m:Int. if rat(n) = rat(m) then n = m
auto rat_int_le
rat_int_le: all n:Int, m:Int. rat(n) ≤ rat(m) = n ≤ m
auto rat_int_le_frac_lit
rat_int_le_frac_lit: all m:Int, n:Int, y:Nat. rat(m) ≤ frac(n, fromNat(lit(suc(y)))) = m * pos(fromNat(lit(suc(y)))) ≤ n
auto rat_int_less
rat_int_less: all n:Int, m:Int. rat(n) < rat(m) = n < m
auto rat_int_less_frac_lit
rat_int_less_frac_lit: all m:Int, n:Int, y:Nat. rat(m) < frac(n, fromNat(lit(suc(y)))) = m * pos(fromNat(lit(suc(y)))) < n
auto rat_int_mult
rat_int_mult: all n:Int, m:Int. rat(n) * rat(m) = rat(n * m)
auto rat_int_mult_frac_lit
rat_int_mult_frac_lit: all m:Int, n:Int, y:Nat. rat(m) * frac(n, fromNat(lit(suc(y)))) = frac(m * n, 1 * fromNat(lit(suc(y))))
auto rat_int_neg
rat_int_neg: all n:Int. - rat(n) = rat(- n)
auto rat_int_sub
rat_int_sub: all n:Int, m:Int. rat(n) - rat(m) = rat(n - m)
auto rat_int_sub_frac_lit
rat_int_sub_frac_lit: all m:Int, n:Int, y:Nat. rat(m) - frac(n, fromNat(lit(suc(y)))) = rat(m) + frac(- n, fromNat(lit(suc(y))))
rat_inv_frac: all a:UInt, d:UInt. if 0 < a and 0 < d then inv(frac(pos(a), d)) = frac(pos(d), a)
auto rat_inv_frac_lit_neg
rat_inv_frac_lit_neg: all x:Nat, y:Nat. inv(frac(negsuc(fromNat(lit(x))), fromNat(lit(suc(y))))) = frac(- pos(fromNat(lit(suc(y)))), fromNat(lit(suc(x))))
auto rat_inv_frac_lit_pos
rat_inv_frac_lit_pos: all x:Nat, y:Nat. inv(frac(pos(fromNat(lit(suc(x)))), fromNat(lit(suc(y))))) = frac(pos(fromNat(lit(suc(y)))), fromNat(lit(suc(x))))
rat_inv_frac_neg: all a:UInt, d:UInt. if 0 < a and 0 < d then inv(frac(- pos(a), d)) = frac(- pos(d), a)
auto rat_inv_int_lit_neg
rat_inv_int_lit_neg: all x:Nat. inv(rat(negsuc(fromNat(lit(x))))) = frac(- 1, fromNat(lit(suc(x))))
auto rat_inv_int_lit_pos
rat_inv_int_lit_pos: all x:Nat. inv(rat(pos(fromNat(lit(suc(x)))))) = frac(+1, fromNat(lit(suc(x))))
rat_inv_inv: all x:Rat. inv(inv(x)) = x
rat_inv_mult: all x:Rat. if x ≠ rat(+0) then inv(x) * x = rat(+1)
rat_inv_mult_distr: all x:Rat, y:Rat. inv(x * y) = inv(x) * inv(y)
rat_inv_neg: all x:Rat. inv(- x) = - inv(x)
rat_inv_one: inv(rat(+1)) = rat(+1)
rat_inv_pos: all x:Rat. if rat(+0) < x then rat(+0) < inv(x)
rat_inv_unique: all x:Rat, y:Rat. if x * y = rat(+1) then inv(x) = y
auto rat_inv_zero
rat_inv_zero: inv(rat(+0)) = rat(+0)
rat_le_abs: all x:Rat. x ≤ abs(x)
rat_le_def: all x:Rat, y:Rat. x ≤ y = num(x) * pos(den(y)) ≤ num(y) * pos(den(x))
rat_le_frac: all n:Int, d:UInt, m:Int, e:UInt. if 0 < d and 0 < e then frac(n, d) ≤ frac(m, e) = n * pos(e) ≤ m * pos(d)
rat_le_iff_sub_nonneg: all x:Rat, y:Rat. x ≤ y = rat(+0) ≤ y - x
rat_le_zero_num: all x:Rat. x ≤ rat(+0) = num(x) ≤ +0
rat_less_def: all x:Rat, y:Rat. x < y = num(x) * pos(den(y)) < num(y) * pos(den(x))
rat_less_equal_antisymmetric: all x:Rat, y:Rat. if x ≤ y and y ≤ x then x = y
rat_less_equal_iff_less_or_equal: all x:Rat, y:Rat. x ≤ y ⇔ (x < y or x = y)
rat_less_equal_iff_not_greater: all x:Rat, y:Rat. x ≤ y ⇔ not (y < x)
rat_less_equal_refl: all x:Rat. x ≤ x
rat_less_equal_total: all x:Rat, y:Rat. x ≤ y or y ≤ x
rat_less_equal_trans: all x:Rat, y:Rat, z:Rat. if x ≤ y and y ≤ z then x ≤ z
rat_less_frac: all n:Int, d:UInt, m:Int, e:UInt. if 0 < d and 0 < e then frac(n, d) < frac(m, e) = n * pos(e) < m * pos(d)
rat_less_iff_le_not_equal: all x:Rat, y:Rat. x < y = (x ≤ y and x ≠ y)
rat_less_iff_sub_pos: all x:Rat, y:Rat. x < y = rat(+0) < y - x
rat_less_implies_less_equal: all x:Rat, y:Rat. if x < y then x ≤ y
rat_less_implies_not_equal: all x:Rat, y:Rat. if x < y then x ≠ y
rat_less_implies_not_greater: all x:Rat, y:Rat. if x < y then not (y < x)
rat_less_irreflexive: all x:Rat. not (x < x)
rat_less_trans: all x:Rat, y:Rat, z:Rat. if x < y and y < z then x < z
rat_less_trans_less_equal_left: all x:Rat, y:Rat, z:Rat. if x ≤ y and y < z then x < z
rat_less_trans_less_equal_right: all x:Rat, y:Rat, z:Rat. if x < y and y ≤ z then x < z
rat_less_zero_num: all x:Rat. x < rat(+0) = num(x) < +0
rat_max_equal_greater_left: all x:Rat, y:Rat. if y ≤ x then max(x, y) = x
rat_max_equal_greater_right: all x:Rat, y:Rat. if x ≤ y then max(x, y) = y
rat_max_greater_left: all x:Rat, y:Rat. x ≤ max(x, y)
rat_max_greater_right: all x:Rat, y:Rat. y ≤ max(x, y)
rat_max_less_equal: all x:Rat, y:Rat, z:Rat. if x ≤ z and y ≤ z then max(x, y) ≤ z
rat_max_symmetric: all x:Rat, y:Rat. max(x, y) = max(y, x)
rat_min_equal_less_left: all x:Rat, y:Rat. if x ≤ y then min(x, y) = x
rat_min_equal_less_right: all x:Rat, y:Rat. if y ≤ x then min(x, y) = y
rat_min_greatest_less_equal: all x:Rat, y:Rat, z:Rat. if z ≤ x and z ≤ y then z ≤ min(x, y)
rat_min_less_equal_left: all x:Rat, y:Rat. min(x, y) ≤ x
rat_min_less_equal_right: all x:Rat, y:Rat. min(x, y) ≤ y
rat_min_symmetric: all x:Rat, y:Rat. min(x, y) = min(y, x)
rat_mult_assoc: all x:Rat, y:Rat, z:Rat. x * y * z = x * (y * z)
rat_mult_commute: all x:Rat, y:Rat. x * y = y * x
rat_mult_div_cancel: all x:Rat, y:Rat. if y ≠ rat(+0) then (x * y) / y = x
rat_mult_frac: all n:Int, d:UInt, m:Int, e:UInt. if 0 < d and 0 < e then frac(n, d) * frac(m, e) = frac(n * m, d * e)
rat_mult_inv: all x:Rat. if x ≠ rat(+0) then x * inv(x) = rat(+1)
rat_mult_left_cancel: all x:Rat, y:Rat, z:Rat. if x ≠ rat(+0) and x * y = x * z then y = z
rat_mult_neg: all x:Rat, y:Rat. x * - y = - (x * y)
rat_mult_nonneg: all x:Rat, y:Rat. if rat(+0) ≤ x and rat(+0) ≤ y then rat(+0) ≤ x * y
auto rat_mult_one
rat_mult_one: all x:Rat. x * rat(+1) = x
rat_mult_pos: all x:Rat, y:Rat. if rat(+0) < x and rat(+0) < y then rat(+0) < x * y
rat_mult_right_cancel: all x:Rat, y:Rat, z:Rat. if x ≠ rat(+0) and y * x = z * x then y = z
rat_mult_to_zero: all x:Rat, y:Rat. if x * y = rat(+0) then x = rat(+0) or y = rat(+0)
auto rat_mult_zero
rat_mult_zero: all x:Rat. x * rat(+0) = rat(+0)
rat_neg_abs_le: all x:Rat. - abs(x) ≤ x
rat_neg_distr_add: all x:Rat, y:Rat. - (x + y) = - x + - y
rat_neg_injective: all x:Rat, y:Rat. if - x = - y then x = y
rat_neg_involutive: all x:Rat. - - x = x
rat_neg_le_iff: all x:Rat, y:Rat. - y ≤ - x = x ≤ y
rat_neg_less_iff: all x:Rat, y:Rat. - y < - x = x < y
rat_neg_mult: all x:Rat, y:Rat. - x * y = - (x * y)
rat_neg_mult_neg: all x:Rat, y:Rat. - x * - y = x * y
rat_neg_one_mult: all x:Rat. - rat(+1) * x = - x
rat_neg_sub: all x:Rat, y:Rat. - (x - y) = y - x
auto rat_neg_zero
rat_neg_zero: - rat(+0) = rat(+0)
rat_nonneg_mult_mono_le_left: all z:Rat, x:Rat, y:Rat. if rat(+0) ≤ z and x ≤ y then z * x ≤ z * y
rat_nonneg_mult_mono_le_right: all z:Rat, x:Rat, y:Rat. if rat(+0) ≤ z and x ≤ y then x * z ≤ y * z
rat_not_less_equal_iff_greater: all x:Rat, y:Rat. not (x ≤ y) ⇔ y < x
rat_not_less_implies_less_equal: all x:Rat, y:Rat. if not (x < y) then y ≤ x
rat_num_int: all n:Int. num(rat(n)) = n
rat_num_neg: all x:Rat. num(- x) = - num(x)
auto rat_one_mult
rat_one_mult: all x:Rat. rat(+1) * x = x
rat_one_not_zero: rat(+1) ≠ rat(+0)
rat_pos_mult_le_iff: all z:Rat, x:Rat, y:Rat. if rat(+0) < z then x * z ≤ y * z = x ≤ y
rat_pos_mult_less_iff: all z:Rat, x:Rat, y:Rat. if rat(+0) < z then x * z < y * z = x < y
rat_pos_mult_mono_less_left: all z:Rat, x:Rat, y:Rat. if rat(+0) < z and x < y then z * x < z * y
rat_pos_mult_mono_less_right: all z:Rat, x:Rat, y:Rat. if rat(+0) < z and x < y then x * z < y * z
rat_pow_add: all x:Rat, j:UInt, k:UInt. x ^ (j + k) = x ^ j * x ^ k
rat_pow_mul_base: all k:UInt, x:Rat, y:Rat. (x * y) ^ k = x ^ k * y ^ k
rat_pow_one_add: all x:Rat, k:UInt. x ^ (1 + k) = x * x ^ k
auto rat_pow_zero
rat_pow_zero: all x:Rat. x ^ 0 = rat(+1)
rat_square_nonneg: all x:Rat. rat(+0) ≤ x * x
rat_sub_add_cancel: all x:Rat, y:Rat. (x - y) + y = x
auto rat_sub_cancel
rat_sub_cancel: all x:Rat. x - x = rat(+0)
rat_sub_def: all x:Rat, y:Rat. x - y = x + - y
rat_sub_eq_zero_iff: all x:Rat, y:Rat. x - y = rat(+0) = (x = y)
auto rat_sub_zero
rat_sub_zero: all x:Rat. x - rat(+0) = x
rat_trichotomy: all x:Rat, y:Rat. x < y or x = y or y < x
rat_uint_int: all n:UInt. rat(n) = rat(pos(n))
auto rat_zero_add
rat_zero_add: all x:Rat. rat(+0) + x = x
auto rat_zero_div
rat_zero_div: all x:Rat. rat(+0) / x = rat(+0)
rat_zero_le_frac: all n:Int, d:UInt. if 0 < d then rat(+0) ≤ frac(n, d) = +0 ≤ n
rat_zero_le_neg: all x:Rat. rat(+0) ≤ - x = x ≤ rat(+0)
rat_zero_le_num: all x:Rat. rat(+0) ≤ x = +0 ≤ num(x)
rat_zero_less_frac: all n:Int, d:UInt. if 0 < d then rat(+0) < frac(n, d) = +0 < n
rat_zero_less_neg: all x:Rat. rat(+0) < - x = x < rat(+0)
rat_zero_less_num: all x:Rat. rat(+0) < x = +0 < num(x)
rat_zero_less_one: rat(+0) < rat(+1)
auto rat_zero_mult
rat_zero_mult: all x:Rat. rat(+0) * x = rat(+0)
auto rat_zero_sub
rat_zero_sub: all x:Rat. rat(+0) - x = - x
opaque recfun real(n:UInt) -> Real
opaque define real : (fn Int -> Real)
opaque define real : (fn Rat -> Real)
real_abs_add: all x:Real, y:Real. abs(x + y) ≤ abs(x) + abs(y)
real_abs_def: all x:Real. abs(x) = if real(+0) ≤ x then x else - x
real_abs_le_iff: all x:Real, y:Real. abs(x) ≤ y = (- y ≤ x and x ≤ y)
real_abs_mult: all x:Real, y:Real. abs(x * y) = abs(x) * abs(y)
real_abs_neg: all x:Real. abs(- x) = abs(x)
real_abs_nonneg: all x:Real. real(+0) ≤ abs(x)
real_abs_nonneg_eq: all x:Real. if real(+0) ≤ x then abs(x) = x
real_abs_nonpos_eq: all x:Real. if x ≤ real(+0) then abs(x) = - x
postulate real_add_assoc: all x:Real, y:Real, z:Real. x + y + z = x + (y + z)
real_add_both_sides_of_equal: all x:Real, y:Real, z:Real. x + y = x + z = (y = z)
real_add_both_sides_of_equal_right: all x:Real, y:Real, z:Real. y + x = z + x = (y = z)
real_add_both_sides_of_less: all x:Real, y:Real, z:Real. x + y < x + z = y < z
real_add_both_sides_of_less_equal: all x:Real, y:Real, z:Real. x + y ≤ x + z = y ≤ z
real_add_both_sides_of_less_equal_right: all x:Real, y:Real, z:Real. y + x ≤ z + x = y ≤ z
real_add_both_sides_of_less_right: all x:Real, y:Real, z:Real. y + x < z + x = y < z
postulate real_add_commute: all x:Real, y:Real. x + y = y + x
auto real_add_int_int
real_add_int_int: all n:Int, m:Int. real(n) + real(m) = real(n + m)
auto real_add_int_rat
real_add_int_rat: all n:Int, r:Rat. real(n) + real(r) = real(rat(n) + r)
postulate real_add_inverse: all x:Real. x + - x = real(+0)
real_add_inverse_unique: all x:Real, y:Real. if x + y = real(+0) then y = - x
real_add_le_left_mono: all x:Real, y:Real, z:Real. if x ≤ y then z + x ≤ z + y
postulate real_add_le_right_mono: all x:Real, y:Real, z:Real. if x ≤ y then x + z ≤ y + z
real_add_left_inverse: all x:Real. - x + x = real(+0)
real_add_mono_less: all a:Real, b:Real, c:Real, d:Real. if a < c and b < d then a + b < c + d
real_add_mono_less_equal: all a:Real, b:Real, c:Real, d:Real. if a ≤ c and b ≤ d then a + b ≤ c + d
auto real_add_rat_int
real_add_rat_int: all q:Rat, m:Int. real(q) + real(m) = real(q + rat(m))
auto real_add_rat_rat
real_add_rat_rat: all q:Rat, r:Rat. real(q) + real(r) = real(q + r)
real_add_sub_cancel: all x:Real, y:Real. (x + y) - y = x
auto real_add_zero
postulate real_add_zero: all x:Real. x + real(+0) = x
real_dichotomy: all x:Real, y:Real. x ≤ y or y < x
real_diff_squares: all a:Real, b:Real. a * a - b * b = (a - b) * (a + b)
postulate real_dist_mult_add: all x:Real, y:Real, z:Real. x * (y + z) = x * y + x * z
real_dist_mult_add_right: all x:Real, y:Real, z:Real. (y + z) * x = y * x + z * x
real_dist_mult_sub: all x:Real, y:Real, z:Real. x * (y - z) = x * y - x * z
real_dist_mult_sub_right: all x:Real, y:Real, z:Real. (y - z) * x = y * x - z * x
real_div_def: all x:Real, y:Real. x / y = x * inv(y)
auto real_div_int_int
real_div_int_int: all n:Int, m:Int. real(n) / real(m) = real(rat(n) * inv(rat(m)))
auto real_div_int_rat
real_div_int_rat: all n:Int, r:Rat. real(n) / real(r) = real(rat(n) / r)
real_div_mult_cancel: all x:Real, y:Real. if y ≠ real(+0) then (x / y) * y = x
auto real_div_one
real_div_one: all x:Real. x / real(+1) = x
auto real_div_rat_int
real_div_rat_int: all q:Rat, m:Int. real(q) / real(m) = real(q / rat(m))
auto real_div_rat_rat
real_div_rat_rat: all q:Rat, r:Rat. real(q) / real(r) = real(q / r)
real_div_self: all x:Real. if x ≠ real(+0) then x / x = real(+1)
auto real_div_zero
real_div_zero: all x:Real. x / real(+0) = real(+0)
auto real_eq_int_int
real_eq_int_int: all n:Int, m:Int. real(n) = real(m) = (n = m)
auto real_eq_int_rat
real_eq_int_rat: all n:Int, r:Rat. real(n) = real(r) = (rat(n) = r)
auto real_eq_rat_int
real_eq_rat_int: all q:Rat, m:Int. real(q) = real(m) = (q = rat(m))
auto real_eq_rat_rat
real_eq_rat_rat: all q:Rat, r:Rat. real(q) = real(r) = (q = r)
real_frac: all n:Int, d:UInt. if 0 < d then real(frac(n, d)) = real(n) * inv(real(d))
real_int_add: all n:Int, m:Int. real(n + m) = real(n) + real(m)
real_int_eq: all n:Int, m:Int. real(n) = real(m) = (n = m)
real_int_injective: all n:Int, m:Int. if real(n) = real(m) then n = m
real_int_le: all n:Int, m:Int. real(n) ≤ real(m) = n ≤ m
real_int_less: all n:Int, m:Int. real(n) < real(m) = n < m
real_int_mult: all n:Int, m:Int. real(n * m) = real(n) * real(m)
real_int_neg: all n:Int. real(- n) = - real(n)
real_int_negsuc: all a:UInt. real(negsuc(a)) = - real(1 + a)
real_int_nonneg_iff: all n:Int. real(+0) ≤ real(n) = +0 ≤ n
real_int_pos: all a:UInt. real(pos(a)) = real(a)
real_int_sub: all n:Int, m:Int. real(n - m) = real(n) - real(m)
auto real_inv_int
real_inv_int: all n:Int. inv(real(n)) = real(inv(rat(n)))
real_inv_inv: all x:Real. inv(inv(x)) = x
real_inv_mult: all x:Real. if x ≠ real(+0) then inv(x) * x = real(+1)
real_inv_mult_distr: all x:Real, y:Real. inv(x * y) = inv(x) * inv(y)
real_inv_neg: all x:Real. inv(- x) = - inv(x)
real_inv_not_zero: all x:Real. if x ≠ real(+0) then inv(x) ≠ real(+0)
auto real_inv_one
real_inv_one: inv(real(+1)) = real(+1)
real_inv_pos: all x:Real. if real(+0) < x then real(+0) < inv(x)
auto real_inv_rat
real_inv_rat: all q:Rat. inv(real(q)) = real(inv(q))
real_inv_unique: all x:Real, y:Real. if x * y = real(+1) then inv(x) = y
auto real_inv_zero
postulate real_inv_zero: inv(real(+0)) = real(+0)
real_le_abs: all x:Real. x ≤ abs(x)
real_le_iff_sub_nonneg: all x:Real, y:Real. x ≤ y = real(+0) ≤ y - x
auto real_le_int_int
real_le_int_int: all n:Int, m:Int. real(n) ≤ real(m) = n ≤ m
auto real_le_int_rat
real_le_int_rat: all n:Int, r:Rat. real(n) ≤ real(r) = rat(n) ≤ r
auto real_le_rat_int
real_le_rat_int: all q:Rat, m:Int. real(q) ≤ real(m) = q ≤ rat(m)
auto real_le_rat_rat
real_le_rat_rat: all q:Rat, r:Rat. real(q) ≤ real(r) = q ≤ r
real_less_def: all x:Real, y:Real. x < y = (x ≤ y and x ≠ y)
postulate real_less_equal_antisymmetric: all x:Real, y:Real. if x ≤ y and y ≤ x then x = y
real_less_equal_iff_less_or_equal: all x:Real, y:Real. x ≤ y ⇔ (x < y or x = y)
real_less_equal_iff_not_greater: all x:Real, y:Real. x ≤ y ⇔ not (y < x)
real_less_equal_refl: all x:Real. x ≤ x
postulate real_less_equal_total: all x:Real, y:Real. x ≤ y or y ≤ x
postulate real_less_equal_trans: all x:Real, y:Real, z:Real. if x ≤ y and y ≤ z then x ≤ z
real_less_iff_sub_pos: all x:Real, y:Real. x < y = real(+0) < y - x
real_less_implies_less_equal: all x:Real, y:Real. if x < y then x ≤ y
real_less_implies_not_equal: all x:Real, y:Real. if x < y then x ≠ y
real_less_implies_not_greater: all x:Real, y:Real. if x < y then not (y < x)
auto real_less_int_int
real_less_int_int: all n:Int, m:Int. real(n) < real(m) = n < m
auto real_less_int_rat
real_less_int_rat: all n:Int, r:Rat. real(n) < real(r) = rat(n) < r
real_less_irreflexive: all x:Real. not (x < x)
auto real_less_rat_int
real_less_rat_int: all q:Rat, m:Int. real(q) < real(m) = q < rat(m)
auto real_less_rat_rat
real_less_rat_rat: all q:Rat, r:Rat. real(q) < real(r) = q < r
real_less_trans: all x:Real, y:Real, z:Real. if x < y and y < z then x < z
real_less_trans_less_equal_left: all x:Real, y:Real, z:Real. if x ≤ y and y < z then x < z
real_less_trans_less_equal_right: all x:Real, y:Real, z:Real. if x < y and y ≤ z then x < z
real_max_def: all x:Real, y:Real. max(x, y) = if x ≤ y then y else x
real_max_equal_greater_left: all x:Real, y:Real. if y ≤ x then max(x, y) = x
real_max_equal_greater_right: all x:Real, y:Real. if x ≤ y then max(x, y) = y
real_max_greater_left: all x:Real, y:Real. x ≤ max(x, y)
real_max_greater_right: all x:Real, y:Real. y ≤ max(x, y)
real_max_less_equal: all x:Real, y:Real, z:Real. if x ≤ z and y ≤ z then max(x, y) ≤ z
real_max_symmetric: all x:Real, y:Real. max(x, y) = max(y, x)
real_min_def: all x:Real, y:Real. min(x, y) = if x ≤ y then x else y
real_min_equal_less_left: all x:Real, y:Real. if x ≤ y then min(x, y) = x
real_min_equal_less_right: all x:Real, y:Real. if y ≤ x then min(x, y) = y
real_min_greatest_less_equal: all x:Real, y:Real, z:Real. if z ≤ x and z ≤ y then z ≤ min(x, y)
real_min_less_equal_left: all x:Real, y:Real. min(x, y) ≤ x
real_min_less_equal_right: all x:Real, y:Real. min(x, y) ≤ y
real_min_symmetric: all x:Real, y:Real. min(x, y) = min(y, x)
postulate real_mult_assoc: all x:Real, y:Real, z:Real. x * y * z = x * (y * z)
postulate real_mult_commute: all x:Real, y:Real. x * y = y * x
real_mult_div_cancel: all x:Real, y:Real. if y ≠ real(+0) then (x * y) / y = x
auto real_mult_int_int
real_mult_int_int: all n:Int, m:Int. real(n) * real(m) = real(n * m)
auto real_mult_int_rat
real_mult_int_rat: all n:Int, r:Rat. real(n) * real(r) = real(rat(n) * r)
postulate real_mult_inv: all x:Real. if x ≠ real(+0) then x * inv(x) = real(+1)
real_mult_inv_cross: all a:Real, b:Real, c:Real, d:Real. if b ≠ real(+0) and d ≠ real(+0) and a * d = c * b then a * inv(b) = c * inv(d)
real_mult_left_cancel: all x:Real, y:Real, z:Real. if x ≠ real(+0) and x * y = x * z then y = z
real_mult_neg: all x:Real, y:Real. x * - y = - (x * y)
postulate real_mult_nonneg: all x:Real, y:Real. if real(+0) ≤ x and real(+0) ≤ y then real(+0) ≤ x * y
auto real_mult_one
postulate real_mult_one: all x:Real. x * real(+1) = x
real_mult_pos: all x:Real, y:Real. if real(+0) < x and real(+0) < y then real(+0) < x * y
auto real_mult_rat_int
real_mult_rat_int: all q:Rat, m:Int. real(q) * real(m) = real(q * rat(m))
auto real_mult_rat_rat
real_mult_rat_rat: all q:Rat, r:Rat. real(q) * real(r) = real(q * r)
real_mult_right_cancel: all x:Real, y:Real, z:Real. if x ≠ real(+0) and y * x = z * x then y = z
real_mult_to_zero: all x:Real, y:Real. if x * y = real(+0) then x = real(+0) or y = real(+0)
auto real_mult_zero
real_mult_zero: all x:Real. x * real(+0) = real(+0)
real_mult_zero_iff: all x:Real, y:Real. if x ≠ real(+0) then x * y = real(+0) = (y = real(+0))
real_neg_abs_le: all x:Real. - abs(x) ≤ x
real_neg_distr_add: all x:Real, y:Real. - (x + y) = - x + - y
real_neg_injective: all x:Real, y:Real. if - x = - y then x = y
auto real_neg_int
real_neg_int: all n:Int. - real(n) = real(- n)
real_neg_involutive: all x:Real. - - x = x
real_neg_le_iff: all x:Real, y:Real. - y ≤ - x = x ≤ y
real_neg_le_zero: all x:Real. - x ≤ real(+0) = real(+0) ≤ x
real_neg_less_iff: all x:Real, y:Real. - y < - x = x < y
real_neg_mult: all x:Real, y:Real. - x * y = - (x * y)
real_neg_mult_neg: all x:Real, y:Real. - x * - y = x * y
real_neg_one_mult: all x:Real. - real(+1) * x = - x
auto real_neg_rat
real_neg_rat: all q:Rat. - real(q) = real(- q)
real_neg_sub: all x:Real, y:Real. - (x - y) = y - x
auto real_neg_zero
real_neg_zero: - real(+0) = real(+0)
real_nonneg_mult_mono_le_left: all z:Real, x:Real, y:Real. if real(+0) ≤ z and x ≤ y then z * x ≤ z * y
real_nonneg_mult_mono_le_right: all z:Real, x:Real, y:Real. if real(+0) ≤ z and x ≤ y then x * z ≤ y * z
real_not_less_equal_iff_greater: all x:Real, y:Real. not (x ≤ y) ⇔ y < x
real_not_less_implies_less_equal: all x:Real, y:Real. if not (x < y) then y ≤ x
postulate real_odd_degree_root: all cs:List<Real>. if Even(length(cs)) and last(cs) ≠ just(real(+0)) then some x:Real. poly_eval(cs, x) = real(+0)
auto real_one_mult
real_one_mult: all x:Real. real(+1) * x = x
postulate real_one_not_zero: real(+1) ≠ real(+0)
real_pos_mult_le_iff: all z:Real, x:Real, y:Real. if real(+0) < z then x * z ≤ y * z = x ≤ y
real_pos_mult_less_iff: all z:Real, x:Real, y:Real. if real(+0) < z then x * z < y * z = x < y
real_pos_mult_mono_less_left: all z:Real, x:Real, y:Real. if real(+0) < z and x < y then z * x < z * y
real_pos_mult_mono_less_right: all z:Real, x:Real, y:Real. if real(+0) < z and x < y then x * z < y * z
real_pow_add: all x:Real, j:UInt, k:UInt. x ^ (j + k) = x ^ j * x ^ k
real_pow_mul_base: all k:UInt, x:Real, y:Real. (x * y) ^ k = x ^ k * y ^ k
real_pow_one_add: all x:Real, k:UInt. x ^ (1 + k) = x * x ^ k
auto real_pow_zero
real_pow_zero: all x:Real. x ^ 0 = real(+1)
real_rat_add: all q:Rat, r:Rat. real(q + r) = real(q) + real(r)
real_rat_def: all q:Rat. real(q) = real(num(q)) * inv(real(den(q)))
real_rat_div: all q:Rat, r:Rat. real(q / r) = real(q) / real(r)
real_rat_eq: all q:Rat, r:Rat. real(q) = real(r) = (q = r)
auto real_rat_int
real_rat_int: all n:Int. real(rat(n)) = real(n)
real_rat_inv: all q:Rat. real(inv(q)) = inv(real(q))
real_rat_le: all q:Rat, r:Rat. real(q) ≤ real(r) = q ≤ r
real_rat_less: all q:Rat, r:Rat. real(q) < real(r) = q < r
real_rat_mult: all q:Rat, r:Rat. real(q * r) = real(q) * real(r)
real_rat_neg: all q:Rat. real(- q) = - real(q)
real_rat_sub: all q:Rat, r:Rat. real(q - r) = real(q) - real(r)
define real_scale : (fn (Rat, Real) -> Real) = fun q:Rat, x:Real {
real(q) * x
}
real_scale_add_left: all p:Rat, q:Rat, x:Real. real_scale(p + q, x) = real_scale(p, x) + real_scale(q, x)
real_scale_add_right: all q:Rat, x:Real, y:Real. real_scale(q, x + y) = real_scale(q, x) + real_scale(q, y)
real_scale_assoc: all p:Rat, q:Rat, x:Real. real_scale(p * q, x) = real_scale(p, real_scale(q, x))
real_scale_one: all x:Real. real_scale(rat(+1), x) = x
real_scale_pos: all q:Rat, x:Real. if rat(+0) < q and real(+0) < x then real(+0) < real_scale(q, x)
postulate real_sqrt: all x:Real. if real(+0) ≤ x then real(+0) ≤ sqrt(x) and sqrt(x) * sqrt(x) = x
real_sqrt_abs_square: all x:Real. sqrt(x * x) = abs(x)
real_sqrt_le_mono: all x:Real, y:Real. if real(+0) ≤ x and x ≤ y then sqrt(x) ≤ sqrt(y)
real_sqrt_mult: all x:Real, y:Real. if real(+0) ≤ x and real(+0) ≤ y then sqrt(x * y) = sqrt(x) * sqrt(y)
real_sqrt_nonneg: all x:Real. if real(+0) ≤ x then real(+0) ≤ sqrt(x)
real_sqrt_of_square: all y:Real. if real(+0) ≤ y then sqrt(y * y) = y
real_sqrt_one: sqrt(real(+1)) = real(+1)
real_sqrt_square: all x:Real. if real(+0) ≤ x then sqrt(x) * sqrt(x) = x
real_sqrt_unique: all x:Real, y:Real. if real(+0) ≤ y and y * y = x then sqrt(x) = y
real_sqrt_zero: sqrt(real(+0)) = real(+0)
real_square_injective: all a:Real, b:Real. if real(+0) ≤ a and real(+0) ≤ b and a * a = b * b then a = b
real_square_less: all a:Real, b:Real. if real(+0) ≤ a and a < b then a * a < b * b
real_square_nonneg: all x:Real. real(+0) ≤ x * x
real_sub_add_cancel: all x:Real, y:Real. (x - y) + y = x
auto real_sub_cancel
real_sub_cancel: all x:Real. x - x = real(+0)
real_sub_def: all x:Real, y:Real. x - y = x + - y
real_sub_eq_zero_iff: all x:Real, y:Real. x - y = real(+0) = (x = y)
auto real_sub_int_int
real_sub_int_int: all n:Int, m:Int. real(n) - real(m) = real(n - m)
auto real_sub_int_rat
real_sub_int_rat: all n:Int, r:Rat. real(n) - real(r) = real(rat(n) - r)
auto real_sub_rat_int
real_sub_rat_int: all q:Rat, m:Int. real(q) - real(m) = real(q - rat(m))
auto real_sub_rat_rat
real_sub_rat_rat: all q:Rat, r:Rat. real(q) - real(r) = real(q - r)
auto real_sub_zero
real_sub_zero: all x:Real. x - real(+0) = x
real_trichotomy: all x:Real, y:Real. x < y or x = y or y < x
real_uint_add: all m:UInt, n:UInt. real(m + n) = real(m) + real(n)
real_uint_injective: all m:UInt, n:UInt. if real(m) = real(n) then m = n
real_uint_le: all m:UInt, n:UInt. if m ≤ n then real(m) ≤ real(n)
real_uint_le_iff: all m:UInt, n:UInt. real(m) ≤ real(n) = m ≤ n
real_uint_less: all m:UInt, n:UInt. if m < n then real(m) < real(n)
real_uint_mult: all m:UInt, n:UInt. real(m * n) = real(m) * real(n)
real_uint_nonneg: all n:UInt. real(+0) ≤ real(n)
real_uint_pos: all n:UInt. if 0 < n then real(+0) < real(n)
real_uint_suc: all n:UInt. real(1 + n) = real(+1) + real(n)
auto real_zero_add
real_zero_add: all x:Real. real(+0) + x = x
auto real_zero_div
real_zero_div: all x:Real. real(+0) / x = real(+0)
real_zero_le_neg: all x:Real. real(+0) ≤ - x = x ≤ real(+0)
real_zero_less_neg: all x:Real. real(+0) < - x = x < real(+0)
real_zero_less_one: real(+0) < real(+1)
auto real_zero_mult
real_zero_mult: all x:Real. real(+0) * x = real(+0)
auto real_zero_sub
real_zero_sub: all x:Real. real(+0) - x = - x
recursive remove<T>(List<T>,T) -> List<T>{
remove([], y) = []
remove(node(x, xs'), y) =
if x = y then
xs'
else
node(x, remove(xs', y))
}
recursive remove_all<T>(List<T>,T) -> List<T>{
remove_all([], y) = []
remove_all(node(x, xs'), y) =
if x = y then
remove_all(xs', y)
else
node(x, remove_all(xs', y))
}
recursive reverse<E>(List<E>) -> List<E>{
reverse([]) = []
reverse(node(n, next)) = reverse(next) ++ [n]
}
reverse_append: all U:type, xs:List<U>, ys:List<U>. reverse(xs ++ ys) = reverse(ys) ++ reverse(xs)
recursive ring_add(List<Mono>,List<Mono>) -> List<Mono>{
ring_add([], qs) = qs
ring_add(node(t, ps), qs) =
switch t {
case mono(c, m) {
ring_insert(ring_add(ps, qs), c, m)
}
}
}
recursive ring_denote<T> where { CommRing<T> } (RExpr,List<T>) -> T{
ring_denote(rvar(i), env) = ring_get(env, i)
ring_denote(rzero, env) = zero
ring_denote(rone, env) = one
ring_denote(rconst(n), env) = from_uint(n)
ring_denote(radd(a, b), env) = ring_denote(a, env) + ring_denote(b, env)
ring_denote(rsub(a, b), env) = ring_denote(a, env) - ring_denote(b, env)
ring_denote(rneg(a), env) = - ring_denote(a, env)
ring_denote(rmul(a, b), env) = ring_denote(a, env) * ring_denote(b, env)
ring_denote(rpow(a, k), env) = ring_denote(a, env) ^ k
ring_denote(rinv(a), env) = zero
ring_denote(rdiv(a, b), env) = zero
ring_denote(rfrac(n, d), env) = zero
}
recursive ring_get<T> where { CommSemiring<T> } (List<T>,Nat) -> T{
ring_get([], i) = zero
ring_get(node(x, xs), i) =
switch i {
case zero {
x
}
case suc(j) {
ring_get(xs, j)
}
}
}
recursive ring_insert(List<Mono>,UInt,List<UInt>) -> List<Mono>{
ring_insert([], c, m) = [mono(c, m)]
ring_insert(node(t, ps), c, m) =
switch t {
case mono(d, m2) {
if m = m2 then node(mono(c + d, m), ps) else if ring_mono_less(m, m2) then node(mono(c, m), node(t, ps)) else node(t, ring_insert(ps, c, m))
}
}
}
recursive ring_mdenote<T> where { CommSemiring<T> } (List<UInt>,List<T>) -> T{
ring_mdenote([], env) = one
ring_mdenote(node(e, es), env) = ring_get(env, zero) ^ e * ring_mdenote(es, ring_tail(env))
}
recursive ring_mono_less(List<UInt>,List<UInt>) -> bool{
ring_mono_less([], ys) =
switch ys {
case [] {
false
}
case node(y, ys2) {
true
}
}
ring_mono_less(node(x, xs), ys) =
switch ys {
case [] {
false
}
case node(y, ys2) {
if x = y then ring_mono_less(xs, ys2) else x < y
}
}
}
recursive ring_mul(List<Mono>,List<Mono>) -> List<Mono>{
ring_mul([], qs) = []
ring_mul(node(t, ps), qs) =
switch t {
case mono(c, m) {
ring_add(ring_scale(qs, c, m), ring_mul(ps, qs))
}
}
}
recursive ring_norm(RExpr) -> List<Mono>{
ring_norm(rvar(i)) = [mono(1, ring_vunit(i))]
ring_norm(rzero) = []
ring_norm(rone) = [mono(1, [])]
ring_norm(rconst(n)) =
if n = 0 then
[]
else
[mono(n, [])]
ring_norm(radd(a, b)) = ring_add(ring_norm(a), ring_norm(b))
ring_norm(rsub(a, b)) = []
ring_norm(rneg(a)) = []
ring_norm(rmul(a, b)) = ring_mul(ring_norm(a), ring_norm(b))
ring_norm(rpow(a, k)) = ring_npow(toNat(k), ring_norm(a))
ring_norm(rinv(a)) = []
ring_norm(rdiv(a, b)) = []
ring_norm(rfrac(n, d)) = []
}
recursive ring_npow(Nat,List<Mono>) -> List<Mono>{
ring_npow(zero, ps) = [mono(1, [])]
ring_npow(suc(n), ps) = ring_mul(ps, ring_npow(n, ps))
}
recursive ring_pdenote<T> where { CommSemiring<T> } (List<Mono>,List<T>) -> T{
ring_pdenote([], env) = zero
ring_pdenote(node(t, ps), env) =
switch t {
case mono(c, m) {
from_uint(c) * ring_mdenote(m, env) + ring_pdenote(ps, env)
}
}
}
recursive ring_pn(RExpr) -> PN{
ring_pn(rvar(i)) = pn(ring_norm(rvar(i)), [])
ring_pn(rzero) = pn([], [])
ring_pn(rone) = pn(ring_norm(rone), [])
ring_pn(rconst(n)) = pn(ring_norm(rconst(n)), [])
ring_pn(radd(a, b)) = pn_add(ring_pn(a), ring_pn(b))
ring_pn(rsub(a, b)) = pn_add(ring_pn(a), pn_swap(ring_pn(b)))
ring_pn(rneg(a)) = pn_swap(ring_pn(a))
ring_pn(rmul(a, b)) = pn_mul(ring_pn(a), ring_pn(b))
ring_pn(rpow(a, k)) = pn_npow(toNat(k), ring_pn(a))
ring_pn(rinv(a)) = pn([], [])
ring_pn(rdiv(a, b)) = pn([], [])
ring_pn(rfrac(n, d)) = pn([], [])
}
define ring_pn_eq : (fn (RExpr, RExpr) -> bool) = fun a:RExpr, b:RExpr {
ring_add(pn_pos(ring_pn(a)), pn_neg(ring_pn(b))) = ring_add(pn_pos(ring_pn(b)), pn_neg(ring_pn(a)))
}
recursive ring_pow<T> where { CommSemiring<T> } (Nat,T) -> T{
ring_pow(zero, x) = one
ring_pow(suc(n), x) = x * ring_pow(n, x)
}
ring_prove: all T:type where { CommRing<T> }. all env:List<T>, a:RExpr, b:RExpr. if ring_pn_eq(a, b) then ring_denote(a, env) = ring_denote(b, env)
recursive ring_scale(List<Mono>,UInt,List<UInt>) -> List<Mono>{
ring_scale([], c, m) = []
ring_scale(node(t, ps), c, m) =
switch t {
case mono(d, m2) {
node(mono(c * d, ring_vadd(m, m2)), ring_scale(ps, c, m))
}
}
}
recursive ring_sdenote<T> where { CommSemiring<T> } (RExpr,List<T>) -> T{
ring_sdenote(rvar(i), env) = ring_get(env, i)
ring_sdenote(rzero, env) = zero
ring_sdenote(rone, env) = one
ring_sdenote(rconst(n), env) = from_uint(n)
ring_sdenote(radd(a, b), env) = ring_sdenote(a, env) + ring_sdenote(b, env)
ring_sdenote(rsub(a, b), env) = zero
ring_sdenote(rneg(a), env) = zero
ring_sdenote(rmul(a, b), env) = ring_sdenote(a, env) * ring_sdenote(b, env)
ring_sdenote(rpow(a, k), env) = ring_sdenote(a, env) ^ k
ring_sdenote(rinv(a), env) = zero
ring_sdenote(rdiv(a, b), env) = zero
ring_sdenote(rfrac(n, d), env) = zero
}
define ring_tail : (fn <T> List<T> -> List<T>) = generic T {
fun xs:List<T> {
switch xs {
case [] {
xs
}
case node(y, ys) {
ys
}
}
}
}
recursive ring_vadd(List<UInt>,List<UInt>) -> List<UInt>{
ring_vadd([], ys) = ys
ring_vadd(node(x, xs), ys) =
switch ys {
case [] {
node(x, xs)
}
case node(y, ys2) {
node(x + y, ring_vadd(xs, ys2))
}
}
}
recursive ring_vunit(Nat) -> List<UInt>{
ring_vunit(zero) = [1]
ring_vunit(suc(i)) = node(0, ring_vunit(i))
}
semiring_prove: all T:type where { CommSemiring<T> }. all env:List<T>, a:RExpr, b:RExpr. if ring_norm(a) = ring_norm(b) then ring_sdenote(a, env) = ring_sdenote(b, env)
recursive set_of<T>(List<T>) -> Set<T>{
set_of([]) = empty_set()
set_of(node(x, xs)) = single(x) ∪ set_of(xs)
}
set_of_append: all T:type, xs:List<T>, ys:List<T>. set_of(xs ++ ys) = set_of(xs) ∪ set_of(ys)
set_of_empty: all T:type, xs:List<T>. if set_of(xs) = empty_set() then xs = []
auto sign_neg_lit
sign_neg_lit: all x:Nat. sign(negsuc(fromNat(lit(x)))) = negative
auto sign_pos_lit
sign_pos_lit: all x:Nat. sign(pos(fromNat(lit(x)))) = positive
som_mset_eq_set: all T:type, xs:List<T>. set_of_mset(mset_of(xs)) = set_of(xs)
define sqr : (fn UInt -> UInt) = fun a:UInt {
a * a
}
postulate fun sqrt : (fn Real -> Real)
strong_induction: all P:(fn Nat -> bool), n:Nat. if (all j:Nat. if (all i:Nat. if i < j then P(i)) then P(j)) then P(n)
auto suc_lit
suc_lit: all n:Nat. suc(lit(n)) = lit(suc(n))
suc_uint_monuso: all x:UInt, y:UInt. (1 + x) ⊝ (1 + y) = x ⊝ y
sum_n': all n:Nat. ℕ2 * summation(suc(n), ℕ0, fun x { x }) = n * (n + ℕ1)
sum_n: all n:Nat. ℕ2 * summation(n, ℕ0, fun x { x }) = n * (n ∸ ℕ1)
recursive summation(Nat,Nat,(fn Nat -> Nat)) -> Nat{
summation(zero, begin, f) = zero
summation(suc(k), begin, f) = f(begin) + summation(k, suc(begin), f)
}
summation_add: all a:Nat. all b:Nat, s:Nat, t:Nat, f:(fn Nat -> Nat), g:(fn Nat -> Nat), h:(fn Nat -> Nat). if (all i:Nat. if i < a then g(s + i) = f(s + i)) and (all i:Nat. if i < b then h(t + i) = f(s + a + i)) then summation(a + b, s, f) = summation(a, s, g) + summation(b, t, h)
summation_cong: all k:Nat. all f:(fn Nat -> Nat), g:(fn Nat -> Nat), s:Nat, t:Nat. if (all i:Nat. if i < k then f(s + i) = g(t + i)) then summation(k, s, f) = summation(k, t, g)
summation_const_one: all n:Nat. all s:Nat. summation(n, s, fun i:Nat { suc(zero) }) = n
summation_next: all n:Nat, s:Nat, f:(fn Nat -> Nat). summation(ℕ1 + n, s, f) = summation(n, s, f) + f(s + n)
summation_pow2_succ: all n:Nat. ℕ1 + summation(n, ℕ0, fun i:Nat { ℕ2 ^ i }) = ℕ2 ^ n
summation_pow_succ: all a:Nat. if ℕ1 ≤ a then all n:Nat. ℕ1 + (a ∸ ℕ1) * summation(n, ℕ0, fun i:Nat { a ^ i }) = a ^ n
define tail : (fn <T> List<T> -> List<T>) = generic T {
fun ls:List<T> {
switch ls {
case [] {
@[]<T>
}
case node(x, xs) {
xs
}
}
}
}
tail_append: all E:type, L:List<E>, R:List<E>. if 0 < length(L) then tail(L ++ R) = tail(L) ++ R
recursive tails<T>(List<T>) -> List<List<T>>{
tails([]) = [[]]
tails(node(x, xs)) = node(node(x, xs), tails(xs))
}
tails_contains_empty: all T:type. all xs:List<T>. contains(tails(xs), @[]<T>) = true
recursive take<T>(List<T>,UInt) -> List<T>{
take([], n) = []
take(node(x, xs), n) =
if n = 0 then
[]
else
node(x, take(xs, n ∸ 1))
}
take_append: all E:type, xs:List<E>, ys:List<E>. take(xs ++ ys, length(xs)) = xs
take_zero: all E:type, xs:List<E>. take(xs, 0) = []
opaque recursive toNat(UInt) -> Nat
toNat_add: all x:UInt, y:UInt. toNat(x + y) = toNat(x) + toNat(y)
toNat_expt: all p:UInt, n:UInt. toNat(n ^ p) = toNat(n) ^ toNat(p)
toNat_less: all x:UInt, y:UInt. if x < y then toNat(x) < toNat(y)
toNat_less_equal: all x:UInt, y:UInt. if x ≤ y then toNat(x) ≤ toNat(y)
toNat_mod: all x:UInt, y:UInt. toNat(x % y) = toNat(x) % toNat(y)
toNat_monus: all x:UInt, y:UInt. toNat(x ∸ y) = toNat(x) ∸ toNat(y)
toNat_mult: all x:UInt, y:UInt. toNat(x * y) = toNat(x) * toNat(y)
toNat_uint_summation: all k:UInt, begin:UInt, f:(fn UInt -> UInt). toNat(uint_summation(k, begin, f)) = summation(toNat(k), toNat(begin), fun i { toNat(f(fromNat(i))) })
trichotomy: all x:Nat. all y:Nat. x < y or x = y or y < x
trichotomy2: all y:Nat, x:Nat. if x ≠ y and not (x < y) then y < x
uint_Even_not_Odd: all n:UInt. Even(n) ⇔ not Odd(n)
uint_Even_or_Odd: all n:UInt. Even(n) or Odd(n)
uint_add_assoc: all x:UInt, y:UInt, z:UInt. x + y + z = x + (y + z)
uint_add_both_monus: all z:UInt, y:UInt, x:UInt. (z + y) ∸ (z + x) = y ∸ x
uint_add_both_sides_of_equal: all x:UInt, y:UInt, z:UInt. x + y = x + z ⇔ y = z
auto uint_add_both_sides_of_le_equal
uint_add_both_sides_of_le_equal: all x:UInt. all y:UInt, z:UInt. x + y ≤ x + z = y ≤ z
uint_add_both_sides_of_less: all x:UInt, y:UInt, z:UInt. x + y < x + z ⇔ y < z
uint_add_both_sides_of_less_equal: all x:UInt. all y:UInt, z:UInt. x + y ≤ x + z ⇔ y ≤ z
uint_add_commute: all x:UInt, y:UInt. x + y = y + x
uint_add_div_one: all n:UInt, m:UInt. if 0 < m then (n + m) / m = 1 + n / m
uint_add_mod: all a:UInt, b:UInt, m:UInt. if 0 < m then (a + b) % m = (a % m + b % m) % m
uint_add_mono_less: all a:UInt, b:UInt, c:UInt, d:UInt. if a < c and b < d then a + b < c + d
uint_add_mono_less_equal: all a:UInt, b:UInt, c:UInt, d:UInt. if a ≤ c and b ≤ d then a + b ≤ c + d
auto uint_add_monus_identity
uint_add_monus_identity: all m:UInt, n:UInt. (m + n) ∸ m = n
uint_add_mult_div: all n:UInt, k:UInt, m:UInt. if 0 < m then (n + k * m) / m = k + n / m
uint_add_mult_mod: all n:UInt, k:UInt, m:UInt. if 0 < m then (n + k * m) % m = n % m
uint_add_one_le_double: all x:UInt. if 0 < x then 1 + x ≤ x + x
uint_add_to_zero: all n:UInt, m:UInt. if n + m = 0 then n = 0 and m = 0
auto uint_add_zero
uint_add_zero: all x:UInt. x + 0 = x
uint_dichotomy: all x:UInt, y:UInt. x ≤ y or y < x
uint_dist_mult_add: all a:UInt, x:UInt, y:UInt. a * (x + y) = a * x + a * y
uint_dist_mult_add_right: all x:UInt, y:UInt, a:UInt. (x + y) * a = x * a + y * a
uint_dist_mult_monus: all x:UInt. all y:UInt, z:UInt. x * (y ∸ z) = x * y ∸ x * z
uint_div_cancel: all y:UInt. if 0 < y then y / y = 1
uint_div_less: all n:UInt, m:UInt. if 0 < n and 1 < m then n / m < n
uint_div_less_equal: all n:UInt, m:UInt. if 0 < m then n / m ≤ n
uint_div_mod: all n:UInt, m:UInt. if 0 < m then (n / m) * m + n % m = n
uint_div_one: all n:UInt. n / 1 = n
uint_div_zero: all n:UInt. n / 0 = 0
uint_divides_add: all d:UInt, m:UInt, n:UInt. if divides(d, m) and divides(d, n) then divides(d, m + n)
uint_divides_antisymmetric: all a:UInt, b:UInt. if divides(a, b) and divides(b, a) then a = b
uint_divides_lcm_left: all a:UInt, b:UInt. divides(a, lcm(a, b))
uint_divides_lcm_right: all a:UInt, b:UInt. divides(b, lcm(a, b))
uint_divides_less_equal: all a:UInt, b:UInt. if divides(a, b) and 0 < b then a ≤ b
uint_divides_mod: all d:UInt, m:UInt, n:UInt. if divides(d, n) and divides(d, m % n) and 0 < n then divides(d, m)
uint_divides_mod_of_divides: all d:UInt, m:UInt, n:UInt. if divides(d, m) and divides(d, n) then divides(d, m % n)
uint_divides_monus: all d:UInt, m:UInt, n:UInt. if divides(d, m) and divides(d, n) then divides(d, m ∸ n)
uint_divides_mult_both: all k:UInt, a:UInt, b:UInt. if divides(a, b) then divides(k * a, k * b)
uint_divides_mult_cancel: all k:UInt, a:UInt, b:UInt. if 0 < k and divides(k * a, k * b) then divides(a, b)
uint_divides_mult_left: all d:UInt, n:UInt, m:UInt. if divides(d, n) then divides(d, m * n)
uint_divides_mult_right: all d:UInt, n:UInt, m:UInt. if divides(d, n) then divides(d, n * m)
uint_divides_refl: all n:UInt. divides(n, n)
uint_divides_trans: all a:UInt, b:UInt, c:UInt. if divides(a, b) and divides(b, c) then divides(a, c)
uint_divides_zero: all n:UInt. divides(n, 0)
auto uint_equal
uint_equal: all x:Nat, y:Nat. fromNat(lit(x)) = fromNat(lit(y)) = (x = y)
uint_equal_implies_less_equal: all x:UInt, y:UInt. if x = y then x ≤ y
uint_even_add_even: all x:UInt, y:UInt. if Even(x) and Even(y) then Even(x + y)
uint_even_add_odd: all x:UInt, y:UInt. if Even(x) and Odd(y) then Odd(x + y)
uint_even_mult_left: all x:UInt, y:UInt. if Even(x) then Even(x * y)
uint_even_mult_right: all x:UInt, y:UInt. if Even(y) then Even(x * y)
uint_even_one_odd: all n:UInt. if Even(1 + n) then Odd(n)
uint_expt_log_less_equal: all n:UInt. if 0 < n then 2 ^ log(n) ≤ n
auto uint_expt_one
uint_expt_one: all n:UInt. n ^ 1 = n
uint_expt_suc: all n:UInt, m:Nat. n ^ fromNat(lit(suc(m))) = n * n ^ fromNat(lit(m))
uint_expt_two: all n:UInt. n ^ 2 = n * n
auto uint_expt_zero
uint_expt_zero: all n:UInt. n ^ 0 = 1
uint_fromNat_toNat: all b:UInt. fromNat(toNat(b)) = b
uint_gcd_commutative: all a:UInt, b:UInt. gcd(a, b) = gcd(b, a)
uint_gcd_divides: all b:UInt, a:UInt. divides(gcd(a, b), a) and divides(gcd(a, b), b)
uint_gcd_divides_left: all a:UInt, b:UInt. divides(gcd(a, b), a)
uint_gcd_divides_right: all a:UInt, b:UInt. divides(gcd(a, b), b)
uint_gcd_greatest: all d:UInt, a:UInt, b:UInt. if divides(d, a) and divides(d, b) then divides(d, gcd(a, b))
uint_gcd_lcm_product: all a:UInt, b:UInt. gcd(a, b) * lcm(a, b) = a * b
uint_gcd_mult_distributive: all k:UInt, a:UInt, b:UInt. gcd(k * a, k * b) = k * gcd(a, b)
uint_gcd_pos: all a:UInt, b:UInt. if 0 < a then 0 < gcd(a, b)
uint_gcd_self: all a:UInt. gcd(a, a) = a
uint_gcd_zero_left: all b:UInt. gcd(0, b) = b
uint_gcd_zero_right: all a:UInt. gcd(a, 0) = a
uint_greater_implies_not_equal: all x:UInt, y:UInt. if x > y then x ≠ y
uint_induction: all P:(fn UInt -> bool). if P(0) and (all m:UInt. if P(m) then P(1 + m)) then all n:UInt. P(n)
uint_k_induction: all P:(fn UInt -> bool), k:UInt. if P(k) and (all m:UInt. if k ≤ m and P(m) then P(1 + m)) then all n:UInt. if k ≤ n then P(n)
uint_lcm_commutative: all a:UInt, b:UInt. lcm(a, b) = lcm(b, a)
uint_lcm_least: all a:UInt, b:UInt, m:UInt. if divides(a, m) and divides(b, m) then divides(lcm(a, b), m)
auto uint_lcm_zero_left
uint_lcm_zero_left: all b:UInt. lcm(0, b) = 0
auto uint_lcm_zero_right
uint_lcm_zero_right: all a:UInt. lcm(a, 0) = 0
uint_le_exists_monus: all n:UInt, m:UInt. if n ≤ m then some x:UInt. m = n + x
uint_less_add_one_implies_less_equal: all x:UInt, y:UInt. if x < 1 + y then x ≤ y
uint_less_equal_add: all x:UInt, y:UInt. x ≤ x + y
uint_less_equal_add_left: all x:UInt, y:UInt. y ≤ x + y
uint_less_equal_antisymmetric: all x:UInt, y:UInt. if x ≤ y and y ≤ x then x = y
uint_less_equal_refl: all n:UInt. n ≤ n
auto uint_less_equal_refl_true
uint_less_equal_refl_true: all n:UInt. n ≤ n = true
uint_less_equal_trans: all x:UInt, y:UInt, z:UInt. if x ≤ y and y ≤ z then x ≤ z
uint_less_equal_zero: all x:UInt. if x ≤ 0 then x = 0
uint_less_implies_less_equal: all x:UInt, y:UInt. if x < y then x ≤ y
uint_less_implies_not_equal: all x:UInt, y:UInt. if x < y then x ≠ y
uint_less_implies_not_greater: all x:UInt, y:UInt. if x < y then not (y < x)
uint_less_irreflexive: all x:UInt. not (x < x)
uint_less_is_less_equal: all x:UInt, y:UInt. x < y = 1 + x ≤ y
uint_less_plus1: all n:UInt. n < 1 + n
auto uint_less_plus1_true
uint_less_plus1_true: all n:UInt. n < 1 + n = true
auto uint_less_refl_false
uint_less_refl_false: all x:UInt. x < x = false
uint_less_trans: all x:UInt, y:UInt, z:UInt. if x < y and y < z then x < z
auto uint_lit_div
uint_lit_div: all x:Nat, y:Nat. fromNat(lit(x)) / fromNat(lit(y)) = fromNat(lit(x) / lit(y))
auto uint_lit_less
uint_lit_less: all x:Nat, y:Nat. fromNat(lit(x)) < fromNat(lit(y)) = lit(x) < lit(y)
auto uint_lit_less_equal
uint_lit_less_equal: all x:Nat, y:Nat. fromNat(lit(x)) ≤ fromNat(lit(y)) = lit(x) ≤ lit(y)
uint_log_add_le_log_mult: all m:UInt, n:UInt. if 0 < m and 0 < n then log(m) + log(n) ≤ log(m * n)
uint_log_greater_one: all n:UInt. if 2 ≤ n then 1 ≤ log(n)
uint_log_lt: all n:UInt, m:UInt. if 0 < n then log(n) < m ⇔ n < 2 ^ m
uint_log_mono: all x:UInt, y:UInt. if x ≤ y then log(x) ≤ log(y)
uint_log_mult_le_log_add: all m:UInt, n:UInt. log(m * n) ≤ 1 + log(m) + log(n)
auto uint_log_one
uint_log_one: log(1) = 0
uint_log_pos: all n:UInt. if 1 < n then 0 < log(n)
uint_log_two: log(2) = 1
auto uint_log_zero
uint_log_zero: log(0) = 0
uint_logn_le_n: all n:UInt. log(n) ≤ n
uint_max_assoc: all x:UInt, y:UInt, z:UInt. max(max(x, y), z) = max(x, max(y, z))
uint_max_equal_greater_left: all x:UInt, y:UInt. if y ≤ x then max(x, y) = x
uint_max_equal_greater_right: all x:UInt, y:UInt. if x ≤ y then max(x, y) = y
uint_max_greater_left: all x:UInt, y:UInt. x ≤ max(x, y)
uint_max_greater_right: all x:UInt, y:UInt. y ≤ max(x, y)
uint_max_idempotent: all x:UInt. max(x, x) = x
uint_max_is_left_or_right: all x:UInt, y:UInt. max(x, y) = x or max(x, y) = y
uint_max_less_equal: all x:UInt, y:UInt, z:UInt. if x ≤ z and y ≤ z then max(x, y) ≤ z
uint_max_min_absorb_left: all x:UInt, y:UInt. max(x, min(x, y)) = x
uint_max_min_absorb_right: all x:UInt, y:UInt. max(min(x, y), x) = x
uint_max_symmetric: all x:UInt, y:UInt. max(x, y) = max(y, x)
auto uint_max_zero
uint_max_zero: all x:UInt. max(x, 0) = x
uint_min_equal_less_left: all x:UInt, y:UInt. if x ≤ y then min(x, y) = x
uint_min_equal_less_right: all x:UInt, y:UInt. if y ≤ x then min(x, y) = y
uint_min_greatest_less_equal: all x:UInt, y:UInt, z:UInt. if z ≤ x and z ≤ y then z ≤ min(x, y)
uint_min_idempotent: all x:UInt. min(x, x) = x
uint_min_is_left_or_right: all x:UInt, y:UInt. min(x, y) = x or min(x, y) = y
uint_min_less_equal_left: all x:UInt, y:UInt. min(x, y) ≤ x
uint_min_less_equal_right: all x:UInt, y:UInt. min(x, y) ≤ y
uint_min_max_absorb_left: all x:UInt, y:UInt. min(x, max(x, y)) = x
uint_min_max_absorb_right: all x:UInt, y:UInt. min(max(x, y), x) = x
uint_min_symmetric: all x:UInt, y:UInt. min(x, y) = min(y, x)
uint_mod_less_divisor: all n:UInt, m:UInt. if 0 < m then n % m < m
uint_mod_mod: all n:UInt, m:UInt. if 0 < m then n % m % m = n % m
uint_mod_one: all n:UInt. n % 1 = 0
uint_mod_self_zero: all y:UInt. y % y = 0
uint_mod_small: all n:UInt, m:UInt. if n < m then n % m = n
uint_monus_add_assoc: all n:UInt, l:UInt, m:UInt. if m ≤ n then l + (n ∸ m) = (l + n) ∸ m
uint_monus_add_identity: all n:UInt. all m:UInt. if m ≤ n then m + (n ∸ m) = n
auto uint_monus_cancel
uint_monus_cancel: all n:UInt. n ∸ n = 0
uint_monus_monus_eq_monus_add: all x:UInt, y:UInt, z:UInt. x ∸ y ∸ z = x ∸ (y + z)
uint_monus_one_less: all n:UInt. if n ≠ 0 then n ∸ 1 < n
uint_monus_order: all x:UInt, y:UInt, z:UInt. x ∸ y ∸ z = x ∸ z ∸ y
auto uint_monus_zero
uint_monus_zero: all n:UInt. n ∸ 0 = n
uint_monus_zero_iff_less_eq: all x:UInt, y:UInt. x ≤ y ⇔ x ∸ y = 0
uint_mult_add_div: all k:UInt, n:UInt, m:UInt. if 0 < m then (k * m + n) / m = k + n / m
uint_mult_add_mod: all k:UInt, n:UInt, m:UInt. if 0 < m then (k * m + n) % m = n % m
uint_mult_assoc: all m:UInt, n:UInt, o:UInt. m * n * o = m * (n * o)
uint_mult_commute: all m:UInt, n:UInt. m * n = n * m
uint_mult_div_inverse: all n:UInt, m:UInt. if 0 < m then (n * m) / m = n
uint_mult_div_left_inverse: all n:UInt, m:UInt. if 0 < m then (m * n) / m = n
uint_mult_mod: all a:UInt, b:UInt, m:UInt. if 0 < m then (a * b) % m = ((a % m) * (b % m)) % m
uint_mult_mod_left_zero: all n:UInt, m:UInt. if 0 < m then (m * n) % m = 0
uint_mult_mod_right_zero: all n:UInt, m:UInt. if 0 < m then (n * m) % m = 0
uint_mult_mono_le: all n:UInt, x:UInt, y:UInt. if x ≤ y then n * x ≤ n * y
uint_mult_mono_le2: all n:UInt, x:UInt, m:UInt, y:UInt. if n ≤ m and x ≤ y then n * x ≤ m * y
auto uint_mult_one
uint_mult_one: all n:UInt. n * 1 = n
uint_mult_to_zero: all n:UInt, m:UInt. if n * m = 0 then n = 0 or m = 0
auto uint_mult_zero
uint_mult_zero: all n:UInt. n * 0 = 0
uint_not_less_equal_iff_greater: all x:UInt, y:UInt. not (x ≤ y) ⇔ y < x
uint_not_less_implies_less_equal: all x:UInt, y:UInt. if not (x < y) then y ≤ x
uint_not_less_zero: all x:UInt. not (x < 0)
uint_not_one_add_le_zero: all n:UInt. not (1 + n ≤ 0)
uint_not_one_add_zero: all n:UInt. 1 + n ≠ 0
uint_not_zero_pos: all n:UInt. if n ≠ 0 then 0 < n
uint_odd_add_even: all x:UInt, y:UInt. if Odd(x) and Even(y) then Odd(x + y)
uint_odd_add_odd: all x:UInt, y:UInt. if Odd(x) and Odd(y) then Even(x + y)
uint_odd_mult_odd: all x:UInt, y:UInt. if Odd(x) and Odd(y) then Odd(x * y)
uint_odd_one_even: all n:UInt. if Odd(1 + n) then Even(n)
auto uint_one_add_zero_false
uint_one_add_zero_false: all n:UInt. 1 + n = 0 = false
auto uint_one_expt
uint_one_expt: all n:UInt. 1 ^ n = 1
auto uint_one_mult
uint_one_mult: all n:UInt. 1 * n = n
uint_one_two_odd: all n:UInt. Odd(1 + 2 * n)
uint_pos_implies_one_le: all n:UInt. if 0 < n then 1 ≤ n
uint_pos_mult_both_sides_of_less: all n:UInt, x:UInt, y:UInt. if 0 < n and x < y then n * x < n * y
uint_pos_mult_left_cancel: all n:UInt, x:UInt, y:UInt. if 0 < n and n * x = n * y then x = y
uint_pos_mult_left_cancel_less: all n:UInt, x:UInt, y:UInt. if 0 < n and n * x < n * y then x < y
uint_pos_mult_left_cancel_less_equal: all n:UInt, x:UInt, y:UInt. if 0 < n and n * x ≤ n * y then x ≤ y
uint_pos_mult_right_cancel: all n:UInt, x:UInt, y:UInt. if 0 < n and x * n = y * n then x = y
uint_pos_mult_right_cancel_less: all n:UInt, x:UInt, y:UInt. if 0 < n and x * n < y * n then x < y
uint_pos_mult_right_cancel_less_equal: all n:UInt, x:UInt, y:UInt. if 0 < n and x * n ≤ y * n then x ≤ y
uint_pos_not_zero: all n:UInt. if 0 < n then n ≠ 0
uint_positive_add_one: all n:UInt. if 0 < n then some n':UInt. n = 1 + n'
uint_pow_add_r: all m:UInt, n:UInt, o:UInt. m ^ (n + o) = m ^ n * m ^ o
uint_pow_eq_one: all m:UInt, n:UInt. if m ^ n = 1 then n = 0 or m = 1
uint_pow_eq_zero: all m:UInt, n:UInt. if m ^ n = 0 then m = 0
uint_pow_gt_one: all n:UInt, m:UInt. if 1 < n then 0 < m ⇔ 1 < n ^ m
uint_pow_inj_l: all a:UInt, b:UInt, c:UInt. if 0 < c then if a ^ c = b ^ c then a = b
uint_pow_inj_r: all a:UInt, b:UInt, c:UInt. if 1 < a then if a ^ b = a ^ c then b = c
uint_pow_le_mono_l: all c:UInt, a:UInt, b:UInt. if a ≤ b then a ^ c ≤ b ^ c
uint_pow_le_mono_r: all c:UInt, a:UInt, b:UInt. if 1 ≤ a then if b ≤ c then a ^ b ≤ a ^ c
uint_pow_lt_implies_lt: all c:UInt, a:UInt, b:UInt. if 0 < c then if a ^ c < b ^ c then a < b
uint_pow_lt_mono_l: all c:UInt, a:UInt, b:UInt. if 0 < c then if a < b then a ^ c < b ^ c
uint_pow_lt_mono_r: all c:UInt, a:UInt, b:UInt. if 1 < a then if b < c then a ^ b < a ^ c
uint_pow_mul_l: all m:UInt, n:UInt, o:UInt. (m * n) ^ o = m ^ o * n ^ o
uint_pow_mul_r: all m:UInt, n:UInt, o:UInt. m ^ n ^ o = m ^ (n * o)
uint_pow_pos: all a:UInt, b:UInt. if 0 < a then 0 < a ^ b
uint_strong_induction: all P:(fn UInt -> bool), n:UInt. if (all j:UInt. if (all i:UInt. if i < j then P(i)) then P(j)) then P(n)
define uint_summation : (fn (UInt, UInt, (fn UInt -> UInt)) -> UInt) = fun k:UInt, begin:UInt, f:(fn UInt -> UInt) {
fromNat(summation(toNat(k), toNat(begin), fun i { toNat(f(fromNat(i))) }))
}
uint_summation_add: all a:UInt. all b:UInt, s:UInt, t:UInt, f:(fn UInt -> UInt), g:(fn UInt -> UInt), h:(fn UInt -> UInt). if (all i:Nat. if i < toNat(a) then g(s + fromNat(i)) = f(s + fromNat(i))) and (all i:Nat. if i < toNat(b) then h(t + fromNat(i)) = f(s + a + fromNat(i))) then uint_summation(a + b, s, f) = uint_summation(a, s, g) + uint_summation(b, t, h)
uint_summation_cong: all k:UInt. all f:(fn UInt -> UInt), g:(fn UInt -> UInt), s:UInt, t:UInt. if (all i:Nat. if i < toNat(k) then f(s + fromNat(i)) = g(t + fromNat(i))) then uint_summation(k, s, f) = uint_summation(k, t, g)
uint_summation_const_one: all n:UInt. all s:UInt. uint_summation(n, s, fun i:UInt { 1 }) = n
uint_summation_id: all n:UInt. 2 * uint_summation(n, 0, fun i:UInt { i }) = n * (n ∸ 1)
uint_summation_next: all n:UInt, s:UInt, f:(fn UInt -> UInt). uint_summation(1 + n, s, f) = uint_summation(n, s, f) + f(s + n)
uint_summation_pow2_succ: all n:UInt. 1 + uint_summation(n, 0, fun i:UInt { 2 ^ i }) = 2 ^ n
uint_summation_pow_succ: all a:UInt. if 1 ≤ a then all n:UInt. 1 + (a ∸ 1) * uint_summation(n, 0, fun i:UInt { a ^ i }) = a ^ n
uint_toNat_fromNat: all x:Nat. toNat(fromNat(x)) = x
uint_toNat_injective: all x:UInt, y:UInt. if toNat(x) = toNat(y) then x = y
uint_trichotomy: all x:UInt, y:UInt. x < y or x = y or y < x
uint_two_even: all n:UInt. Even(2 * n)
uint_two_mult: all n:UInt. 2 * n = n + n
auto uint_zero_add
uint_zero_add: all x:UInt. 0 + x = x
uint_zero_div: all x:UInt. if 0 < x then 0 / x = 0
uint_zero_le: all x:UInt. 0 ≤ x
uint_zero_le_zero: all x:UInt. if x ≤ 0 then x = 0
auto uint_zero_less_equal_true
uint_zero_less_equal_true: all x:UInt. 0 ≤ x = true
uint_zero_less_one_add: all n:UInt. 0 < 1 + n
auto uint_zero_less_one_add_true
uint_zero_less_one_add_true: all n:UInt. 0 < 1 + n = true
auto uint_zero_max
uint_zero_max: all x:UInt. max(0, x) = x
uint_zero_mod: all x:UInt. 0 % x = 0
auto uint_zero_mult
uint_zero_mult: all n:UInt. 0 * n = 0
uint_zero_or_add_one: all x:UInt. x = 0 or some x':UInt. x = 1 + x'
uint_zero_or_positive: all x:UInt. x = 0 or 0 < x
uint_zero_pow: all a:UInt. if 0 < a then 0 ^ a = 0
recursive unzip<T,U>(List<Pair<T,U>>) -> Pair<List<T>,List<U>>{
unzip([]) = pair(@[]<T>, @[]<U>)
unzip(node(p, ps)) = define xys = unzip(ps);
pair(node(first(p), first(xys)), node(second(p), second(xys)))
}
auto zero_less_equal_true
zero_less_equal_true: all x:Nat. zero ≤ x = true
zero_or_positive: all x:Nat. x = zero or zero < x
recursive zip<T,U>(List<T>,List<U>) -> List<Pair<T,U>>{
zip([], ys) = []
zip(node(x, xs'), ys) =
switch ys {
case [] {
[]
}
case node(y, ys') {
node(pair(x, y), zip(xs', ys'))
}
}
}
zip_empty_right: all T:type, U:type, xs:List<T>. zip(xs, []) = []
zip_map: all T1:type, T2:type, U1:type, U2:type, f:(fn T1 -> T2), g:(fn U1 -> U2), xs:List<T1>, ys:List<U1>. zip(map(xs, f), map(ys, g)) = map(zip(xs, ys), pairfun(f, g))