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
}
opaque union Angle
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:UInt) = 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)
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 Lin {
lvar(Nat)
lconst(Rat)
lzero
ladd(Lin, Lin)
lsub(Lin, Lin)
lneg(Lin)
lscale(Rat, Lin)
}
union LinFact {
lin_fact(LinRel, Lin, Lin)
}
union LinRel {
rle
rlt
req
}
opaque union Line
concept LinearArith<T> {
refines OrderedQVectorSpace<T>
fun unit : T
theorem unit_pos: zero < unit
}
union List<T> {
empty
node(T, List<T>)
}
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)
}
opaque union Point
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)
angle_add: all A:Point, B:Point, C:Point, D:Point. if angle_interior(D, A, B, C) then m_angle(A, B, D) + m_angle(D, B, C) = m_angle(A, B, C)
angle_add_assoc: all a:Angle, b:Angle, c:Angle. a + b + c = a + (b + c)
angle_add_commute: all a:Angle, b:Angle. a + b = b + a
angle_add_inverse: all a:Angle. a + - a = deg(+0)
angle_add_le_right_mono: all a:Angle, b:Angle, c:Angle. if a ≤ b then a + c ≤ b + c
angle_add_zero: all a:Angle. a + deg(+0) = a
define angle_bisects : (fn (Point, Point, Point, Point) -> bool) = fun D:Point, A:Point, B:Point, C:Point {
angle_interior(D, A, B, C) and m_angle(A, B, D) = m_angle(D, B, C)
}
define angle_congruent : (fn (Point, Point, Point, Point, Point, Point) -> bool) = fun A:Point, B:Point, C:Point, D:Point, E:Point, F:Point {
m_angle(A, B, C) = m_angle(D, E, F)
}
angle_dist_add_mult: all p:Rat, q:Rat, a:Angle. (p + q) * a = p * a + q * a
angle_dist_mult_add: all q:Rat, a:Angle, b:Angle. q * (a + b) = q * a + q * b
define angle_interior : (fn (Point, Point, Point, Point) -> bool) = fun D:Point, A:Point, B:Point, C:Point {
same_side(D, C, line(B, A)) and same_side(D, A, line(B, C))
}
angle_less_def: all a:Angle, b:Angle. a < b = (a ≤ b and a ≠ b)
angle_less_equal_antisymmetric: all a:Angle, b:Angle. if a ≤ b and b ≤ a then a = b
angle_less_equal_refl: all a:Angle. a ≤ a
angle_less_equal_total: all a:Angle, b:Angle. a ≤ b or b ≤ a
angle_less_equal_trans: all a:Angle, b:Angle, c:Angle. if a ≤ b and b ≤ c then a ≤ c
angle_linear_pair: all A:Point, B:Point, C:Point, D:Point. if between(A, B, C) and not collinear(A, B, D) then m_angle(A, B, D) + m_angle(D, B, C) = deg(+180)
angle_measure_collinear: all A:Point, B:Point, C:Point. if collinear(A, B, C) then m_angle(A, B, C) = deg(+0) or m_angle(A, B, C) = deg(+180)
angle_measure_dot_cross: all A:Point, B:Point, C:Point, D:Point, E:Point, F:Point. if dot(B, A, C) = dot(E, D, F) and abs(cross(B, A, C)) = abs(cross(E, D, F)) then m_angle(A, B, C) = m_angle(D, E, F)
angle_measure_eq: all A:Point, B:Point, C:Point, D:Point, E:Point, F:Point. if not collinear(A, B, C) and not collinear(D, E, F) then m_angle(A, B, C) = m_angle(D, E, F) = (dot(B, A, C) * abs(cross(E, D, F)) = abs(cross(B, A, C)) * dot(E, D, F))
angle_measure_range: all A:Point, B:Point, C:Point. deg(+0) ≤ m_angle(A, B, C) and m_angle(A, B, C) ≤ deg(+180)
angle_measure_ray: all A:Point, B:Point, C:Point, P:Point. if A ≠ B and P ≠ B and on_ray(P, B, A) then m_angle(P, B, C) = m_angle(A, B, C)
angle_measure_straight: all A:Point, B:Point, C:Point. if between(A, B, C) then m_angle(A, B, C) = deg(+180)
angle_measure_strict: all A:Point, B:Point, C:Point. if not collinear(A, B, C) then deg(+0) < m_angle(A, B, C) and m_angle(A, B, C) < deg(+180)
angle_measure_symmetric: all A:Point, B:Point, C:Point. m_angle(A, B, C) = m_angle(C, B, A)
angle_measure_zero: all A:Point, B:Point, C:Point. if on_ray(C, B, A) then m_angle(A, B, C) = deg(+0)
angle_mult_assoc: all p:Rat, q:Rat, a:Angle. p * q * a = p * (q * a)
angle_mult_pos: all q:Rat, a:Angle. if rat(+0) < q and deg(+0) < a then deg(+0) < q * a
angle_one_mult: all a:Angle. rat(+1) * a = a
angle_protractor: all A:Point, B:Point, H:Point, r:Angle. if A ≠ B and not on_line(H, line(B, A)) and deg(+0) < r and r < deg(+180) then some C:Point. same_side(C, H, line(B, A)) and m_angle(A, B, C) = r
angle_protractor_unique: all A:Point, B:Point, C:Point, D:Point. if A ≠ B and same_side(C, D, line(B, A)) and m_angle(A, B, C) = m_angle(A, B, D) then on_ray(D, B, C)
angle_right_dot: all A:Point, B:Point, C:Point. if A ≠ B and C ≠ B then right_angle(A, B, C) = (dot(B, A, C) = real(+0))
angle_right_perpendicular: all A:Point, B:Point, C:Point. if A ≠ B and C ≠ B then right_angle(A, B, C) = perpendicular(line(B, A), line(B, C))
angle_sub_def: all a:Angle, b:Angle. a - b = a + - b
angle_vertical: all A:Point, B:Point, C:Point, D:Point, E:Point. if between(A, E, C) and between(B, E, D) and not collinear(A, E, B) then m_angle(A, E, B) = m_angle(C, E, D)
angle_zero_add: all a:Angle. deg(+0) + a = a
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
define between : (fn (Point, Point, Point) -> bool) = fun A:Point, B:Point, C:Point {
collinear(A, B, C) and dot(B, A, C) < real(+0)
}
between_collinear: all A:Point, B:Point, C:Point. if between(A, B, C) then collinear(A, B, C)
between_distinct: all A:Point, B:Point, C:Point. if between(A, B, C) then A ≠ B and B ≠ C and A ≠ C
between_midpoint: all A:Point, B:Point. if A ≠ B then between(A, midpoint(A, B), B)
between_seg_add: all A:Point, B:Point, C:Point. if between(A, B, C) then dist(A, B) + dist(B, C) = dist(A, C)
between_seg_add_converse: all A:Point, B:Point, C:Point. if A ≠ B and B ≠ C and dist(A, B) + dist(B, C) = dist(A, C) then between(A, B, C)
between_symmetric: all A:Point, B:Point, C:Point. between(A, B, C) = between(C, B, A)
between_trichotomy: all A:Point, B:Point, C:Point. if collinear(A, B, C) and A ≠ B and B ≠ C and A ≠ C then between(B, A, C) or between(A, B, C) or between(A, C, B)
between_unique: all A:Point, B:Point, C:Point. if between(A, B, C) then not between(B, A, C) and not between(A, C, B)
define collinear : (fn (Point, Point, Point) -> bool) = fun A:Point, B:Point, C:Point {
cross(A, B, C) = real(+0)
}
define complementary : (fn (Angle, Angle) -> bool) = fun a:Angle, b:Angle {
a + b = deg(+90)
}
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))
define cross : (fn (Point, Point, Point) -> Real) = fun O:Point, A:Point, B:Point {
(xcoord(A) - xcoord(O)) * (ycoord(B) - ycoord(O)) - (ycoord(A) - ycoord(O)) * (xcoord(B) - xcoord(O))
}
opaque define deg : (fn Int -> Angle)
opaque define deg : (fn Rat -> Angle)
auto deg_add_int_int
deg_add_int_int: all n:Int, m:Int. deg(n) + deg(m) = deg(n + m)
auto deg_add_int_rat
deg_add_int_rat: all n:Int, r:Rat. deg(n) + deg(r) = deg(rat(n) + r)
auto deg_add_rat_int
deg_add_rat_int: all q:Rat, m:Int. deg(q) + deg(m) = deg(q + rat(m))
auto deg_add_rat_rat
deg_add_rat_rat: all q:Rat, r:Rat. deg(q) + deg(r) = deg(q + r)
auto deg_eq_int_int
deg_eq_int_int: all n:Int, m:Int. deg(n) = deg(m) = (n = m)
auto deg_eq_int_rat
deg_eq_int_rat: all n:Int, r:Rat. deg(n) = deg(r) = (rat(n) = r)
auto deg_eq_rat_int
deg_eq_rat_int: all q:Rat, m:Int. deg(q) = deg(m) = (q = rat(m))
auto deg_eq_rat_rat
deg_eq_rat_rat: all q:Rat, r:Rat. deg(q) = deg(r) = (q = r)
auto deg_le_int_int
deg_le_int_int: all n:Int, m:Int. deg(n) ≤ deg(m) = n ≤ m
auto deg_le_int_rat
deg_le_int_rat: all n:Int, r:Rat. deg(n) ≤ deg(r) = rat(n) ≤ r
auto deg_le_rat_int
deg_le_rat_int: all q:Rat, m:Int. deg(q) ≤ deg(m) = q ≤ rat(m)
auto deg_le_rat_rat
deg_le_rat_rat: all q:Rat, r:Rat. deg(q) ≤ deg(r) = q ≤ r
auto deg_less_int_int
deg_less_int_int: all n:Int, m:Int. deg(n) < deg(m) = n < m
auto deg_less_int_rat
deg_less_int_rat: all n:Int, r:Rat. deg(n) < deg(r) = rat(n) < r
auto deg_less_rat_int
deg_less_rat_int: all q:Rat, m:Int. deg(q) < deg(m) = q < rat(m)
auto deg_less_rat_rat
deg_less_rat_rat: all q:Rat, r:Rat. deg(q) < deg(r) = q < r
auto deg_mult_int
deg_mult_int: all q:Rat, m:Int. q * deg(m) = deg(q * rat(m))
auto deg_mult_rat
deg_mult_rat: all q:Rat, r:Rat. q * deg(r) = deg(q * r)
auto deg_neg_int
deg_neg_int: all n:Int. - deg(n) = deg(- n)
auto deg_neg_rat
deg_neg_rat: all q:Rat. - deg(q) = deg(- q)
auto deg_rat_int
deg_rat_int: all n:Int. deg(rat(n)) = deg(n)
auto deg_sub_int_int
deg_sub_int_int: all n:Int, m:Int. deg(n) - deg(m) = deg(n - m)
auto deg_sub_int_rat
deg_sub_int_rat: all n:Int, r:Rat. deg(n) - deg(r) = deg(rat(n) - r)
auto deg_sub_rat_int
deg_sub_rat_int: all q:Rat, m:Int. deg(q) - deg(m) = deg(q - rat(m))
auto deg_sub_rat_rat
deg_sub_rat_rat: all q:Rat, r:Rat. deg(q) - deg(r) = deg(q - r)
opaque define den : (fn Rat -> UInt)
dichotomy: all x:Nat, y:Nat. x ≤ y or y < x
define dist : (fn (Point, Point) -> Real) = fun A:Point, B:Point {
sqrt(dist2(A, B))
}
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')
}
}
}
define dist2 : (fn (Point, Point) -> Real) = fun A:Point, B:Point {
(xcoord(A) - xcoord(B)) * (xcoord(A) - xcoord(B)) + (ycoord(A) - ycoord(B)) * (ycoord(A) - ycoord(B))
}
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 (Int, Int) -> bool) = fun a:Int, b:Int {
some k:Int. a * k = b
}
define divides : (fn (Nat, Nat) -> bool) = fun a:Nat, b:Nat {
some k:Nat. a * k = b
}
define dot : (fn (Point, Point, Point) -> Real) = fun O:Point, A:Point, B:Point {
(xcoord(A) - xcoord(O)) * (xcoord(B) - xcoord(O)) + (ycoord(A) - ycoord(O)) * (ycoord(B) - ycoord(O))
}
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 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))
}
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
}
}
define gcd : (fn (Int, Int) -> Int) = fun a:Int, b:Int {
pos(gcd(abs(a), abs(b)))
}
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
}
}
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 ++ node(y, @[]<T>)) = xs
recursive inits<T>(List<T>) -> List<List<T>>{
inits([]) = node([], [])
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:UInt) = 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:UInt) = n * n
auto int_pow_zero
int_pow_zero: all n:Int. n ^ (0:UInt) = +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 [] {
node(x, [])
}
case node(y, ys) {
node(x, node(sep, intersperse(xs, sep)))
}
}
}
intersperse_singleton: all T:type. all x:T, sep:T. intersperse(node(x, @[]<T>), sep) = node(x, @[]<T>)
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 ++ node(y, @[]<T>)) = 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
recursive lin_all_hold<T> where { LinearArith<T> } (List<LinFact>,List<T>) -> bool{
lin_all_hold([], env) = true
lin_all_hold(node(f, fs), env) = lin_holds(f, env) and lin_all_hold(fs, env)
}
recursive lin_all_zero(List<Rat>) -> bool{
lin_all_zero([]) = true
lin_all_zero(node(x, xs)) = x = rat(+0) and lin_all_zero(xs)
}
define lin_check : (fn (List<LinFact>, List<Rat>) -> bool) = fun facts:List<LinFact>, cs:List<Rat> {
lin_all_zero(lin_coeffs(lin_combine(node(lin_unit_fact, facts), cs))) and lin_signs_ok(node(lin_unit_fact, facts), cs) and lin_some_strict(node(lin_unit_fact, facts), cs)
}
define lin_check_goal : (fn (LinFact, List<LinFact>, List<Rat>, List<Rat>) -> bool) = fun g:LinFact, facts:List<LinFact>, cs1:List<Rat>, cs2:List<Rat> {
switch g {
case lin_fact(r, a, b) {
switch r { case rle { lin_check(node(lin_fact(rlt, b, a), facts), cs1) } case rlt { lin_check(node(lin_fact(rle, b, a), facts), cs1) } case req { lin_check(node(lin_fact(rlt, a, b), facts), cs1) and lin_check(node(lin_fact(rlt, b, a), facts), cs2) } }
}
}
}
recursive lin_coeffs(Lin) -> List<Rat>{
lin_coeffs(lvar(i)) = lin_vunit(suc(i))
lin_coeffs(lconst(q)) = node(q, [])
lin_coeffs(lzero) = []
lin_coeffs(ladd(a, b)) = lin_vadd(lin_coeffs(a), lin_coeffs(b))
lin_coeffs(lsub(a, b)) = lin_vadd(lin_coeffs(a), lin_vscale(lin_coeffs(b), rat(- 1)))
lin_coeffs(lneg(a)) = lin_vscale(lin_coeffs(a), rat(- 1))
lin_coeffs(lscale(q, a)) = lin_vscale(lin_coeffs(a), q)
}
recursive lin_combine(List<LinFact>,List<Rat>) -> Lin{
lin_combine([], cs) = lzero
lin_combine(node(f, fs), cs) =
switch cs {
case [] {
lzero
}
case node(c, cs2) {
ladd(lscale(c, lin_diff(f)), lin_combine(fs, cs2))
}
}
}
recursive lin_combo<T> where { LinearArith<T> } (List<Rat>,List<T>) -> T{
lin_combo([], env) = zero
lin_combo(node(c, cs), env) = scale(c, lin_get(env, zero, zero)) + lin_combo(cs, lin_tail(env))
}
recursive lin_denote<T> where { LinearArith<T> } (Lin,List<T>) -> T{
lin_denote(lvar(i), env) = lin_get(env, i, zero)
lin_denote(lconst(q), env) = scale(q, unit)
lin_denote(lzero, env) = zero
lin_denote(ladd(a, b), env) = lin_denote(a, env) + lin_denote(b, env)
lin_denote(lsub(a, b), env) = lin_denote(a, env) - lin_denote(b, env)
lin_denote(lneg(a), env) = - lin_denote(a, env)
lin_denote(lscale(q, a), env) = scale(q, lin_denote(a, env))
}
define lin_diff : (fn LinFact -> Lin) = fun f:LinFact {
switch f {
case lin_fact(r, a, b) {
lsub(b, a)
}
}
}
lin_disprove: all T:type where { LinearArith<T> }. all env:List<T>, g:LinFact, facts:List<LinFact>, cs:List<Rat>. if lin_check(node(g, facts), cs) and lin_all_hold(facts, env) then not lin_holds(g, env)
recursive lin_get<T>(List<T>,Nat,T) -> T{
lin_get([], i, d) = d
lin_get(node(x, xs), i, d) =
switch i {
case zero {
x
}
case suc(j) {
lin_get(xs, j, d)
}
}
}
define lin_holds : (fn <T> where { LinearArith<T> } (LinFact, List<T>) -> bool) = generic T where { LinearArith<T> } {
fun f:LinFact, env:List<T> {
switch f {
case lin_fact(r, a, b) {
switch r { case rle { lin_denote(a, env) ≤ lin_denote(b, env) } case rlt { lin_denote(a, env) < lin_denote(b, env) } case req { lin_denote(a, env) = lin_denote(b, env) } }
}
}
}
}
lin_prove: all T:type where { LinearArith<T> }. all env:List<T>, g:LinFact, facts:List<LinFact>, cs1:List<Rat>, cs2:List<Rat>. if lin_check_goal(g, facts, cs1, cs2) and lin_all_hold(facts, env) then lin_holds(g, env)
lin_refute: all T:type where { LinearArith<T> }. all env:List<T>, facts:List<LinFact>, cs:List<Rat>. not (lin_check(facts, cs) and lin_all_hold(facts, env))
define lin_sign_ok : (fn (LinFact, Rat) -> bool) = fun f:LinFact, c:Rat {
switch f {
case lin_fact(r, a, b) {
switch r { case rle { rat(+0) ≤ c } case rlt { rat(+0) ≤ c } case req { true } }
}
}
}
recursive lin_signs_ok(List<LinFact>,List<Rat>) -> bool{
lin_signs_ok([], cs) = true
lin_signs_ok(node(f, fs), cs) =
switch cs {
case [] {
true
}
case node(c, cs2) {
lin_sign_ok(f, c) and lin_signs_ok(fs, cs2)
}
}
}
recursive lin_some_strict(List<LinFact>,List<Rat>) -> bool{
lin_some_strict([], cs) = false
lin_some_strict(node(f, fs), cs) =
switch cs {
case [] {
false
}
case node(c, cs2) {
lin_strict_pos(f, c) or lin_some_strict(fs, cs2)
}
}
}
define lin_strict_pos : (fn (LinFact, Rat) -> bool) = fun f:LinFact, c:Rat {
switch f {
case lin_fact(r, a, b) {
switch r { case rle { false } case rlt { rat(+0) < c } case req { false } }
}
}
}
define lin_tail : (fn <T> List<T> -> List<T>) = generic T {
fun xs:List<T> {
switch xs {
case [] {
xs
}
case node(y, ys) {
ys
}
}
}
}
define lin_unit_fact : LinFact = lin_fact(rlt, lzero, lconst(rat(+1)))
recursive lin_vadd(List<Rat>,List<Rat>) -> List<Rat>{
lin_vadd([], ys) = ys
lin_vadd(node(x, xs), ys) =
switch ys {
case [] {
node(x, xs)
}
case node(y, ys2) {
node(x + y, lin_vadd(xs, ys2))
}
}
}
recursive lin_vscale(List<Rat>,Rat) -> List<Rat>{
lin_vscale([], q) = []
lin_vscale(node(x, xs), q) = node(q * x, lin_vscale(xs, q))
}
recursive lin_vunit(Nat) -> List<Rat>{
lin_vunit(zero) = node(rat(+1), [])
lin_vunit(suc(i)) = node(rat(+0), lin_vunit(i))
}
opaque define line : (fn (Point, Point) -> Line)
line_on_collinear: all A:Point, B:Point, P:Point. if A ≠ B then on_line(P, line(A, B)) = collinear(A, B, P)
line_on_left: all A:Point, B:Point. on_line(A, line(A, B))
line_on_right: all A:Point, B:Point. on_line(B, line(A, B))
line_opposite_sides_between: all P:Point, Q:Point, L:Line. if not on_line(P, L) and not on_line(Q, L) then opposite_sides(P, Q, L) = some X:Point. on_line(X, L) and between(P, X, Q)
line_opposite_sides_cross: all A:Point, B:Point, P:Point, Q:Point. if A ≠ B then opposite_sides(P, Q, line(A, B)) = cross(A, B, P) * cross(A, B, Q) < real(+0)
line_opposite_sides_off: all P:Point, Q:Point, L:Line. if opposite_sides(P, Q, L) then not on_line(P, L) and not on_line(Q, L)
line_opposite_sides_symmetric: all P:Point, Q:Point, L:Line. opposite_sides(P, Q, L) = opposite_sides(Q, P, L)
line_opposite_sides_trans: all P:Point, Q:Point, R:Point, L:Line. if opposite_sides(P, Q, L) and opposite_sides(Q, R, L) then same_side(P, R, L)
line_parallel_alt_interior: all A:Point, B:Point, C:Point, D:Point. if A ≠ C and opposite_sides(B, D, line(A, C)) then parallel(line(A, B), line(C, D)) = angle_congruent(B, A, C, D, C, A)
line_parallel_refl: all L:Line. parallel(L, L)
line_parallel_seg_cross: all A:Point, B:Point, C:Point, D:Point. if A ≠ B and C ≠ D then parallel(line(A, B), line(C, D)) = (seg_cross(A, B, C, D) = real(+0))
line_parallel_slope: all A:Point, B:Point, C:Point, D:Point. if xcoord(A) ≠ xcoord(B) and xcoord(C) ≠ xcoord(D) then parallel(line(A, B), line(C, D)) = (slope(A, B) = slope(C, D))
line_parallel_symmetric: all L:Line, M:Line. if parallel(L, M) then parallel(M, L)
line_parallel_trans: all L:Line, M:Line, N:Line. if parallel(L, M) and parallel(M, N) then parallel(L, N)
line_parallel_unique: all L:Line, M:Line, P:Point. if parallel(L, M) and on_line(P, L) and on_line(P, M) then L = M
line_perpendicular_parallel: all L:Line, M:Line, N:Line. if perpendicular(L, N) and perpendicular(M, N) then parallel(L, M)
line_perpendicular_seg_dot: all A:Point, B:Point, C:Point, D:Point. if A ≠ B and C ≠ D then perpendicular(line(A, B), line(C, D)) = (seg_dot(A, B, C, D) = real(+0))
line_perpendicular_slope: all A:Point, B:Point, C:Point, D:Point. if xcoord(A) ≠ xcoord(B) and xcoord(C) ≠ xcoord(D) then perpendicular(line(A, B), line(C, D)) = (slope(A, B) * slope(C, D) = real(- 1))
line_perpendicular_symmetric: all L:Line, M:Line. if perpendicular(L, M) then perpendicular(M, L)
line_plane_separation: all P:Point, Q:Point, L:Line. if not on_line(P, L) and not on_line(Q, L) then (same_side(P, Q, L) or opposite_sides(P, Q, L)) and not (same_side(P, Q, L) and opposite_sides(P, Q, L))
line_points: all L:Line. some A:Point,B:Point. A ≠ B and L = line(A, B)
line_same_opposite_sides: all P:Point, Q:Point, R:Point, L:Line. if same_side(P, Q, L) and opposite_sides(Q, R, L) then opposite_sides(P, R, L)
line_same_side_cross: all A:Point, B:Point, P:Point, Q:Point. if A ≠ B then same_side(P, Q, line(A, B)) = real(+0) < cross(A, B, P) * cross(A, B, Q)
line_same_side_off: all P:Point, Q:Point, L:Line. if same_side(P, Q, L) then not on_line(P, L) and not on_line(Q, L)
line_same_side_refl: all P:Point, L:Line. if not on_line(P, L) then same_side(P, P, L)
line_same_side_symmetric: all P:Point, Q:Point, L:Line. same_side(P, Q, L) = same_side(Q, P, L)
line_same_side_trans: all P:Point, Q:Point, R:Point, L:Line. if same_side(P, Q, L) and same_side(Q, R, L) then same_side(P, R, L)
line_symmetric: all A:Point, B:Point. line(A, B) = line(B, A)
line_unique: all A:Point, B:Point, L:Line. if A ≠ B and on_line(A, L) and on_line(B, L) then L = line(A, B)
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
opaque define m_angle : (fn (Point, Point, Point) -> Angle)
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
}
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)
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'))
}
}
}
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 midpoint : (fn (Point, Point) -> Point) = fun A:Point, B:Point {
point(real(frac(+1, 2)) * (xcoord(A) + xcoord(B)), real(frac(+1, 2)) * (ycoord(A) + ycoord(B)))
}
define min : (fn (UInt, UInt) -> UInt) = fun x:UInt, y:UInt {
if x < y then
x
else
y
}
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)
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'))
}
}
}
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)) }
}
model LinearArith<Rat> {
fun unit = rat(+1)
}
model LinearArith<Real> {
fun unit = real(+1)
}
model AddCommMonoid<Angle> {
fun operator + = operator +
fun zero = deg(+0)
}
model AddCommGroup<Angle> {
fun operator - = operator -
fun operator - = operator -
}
model OrderedAddCommGroup<Angle> {
fun operator ≤ = operator ≤
fun operator < = operator <
}
model OrderedQVectorSpace<Angle> {
fun scale = operator *
}
model LinearArith<Angle> {
fun unit = deg(+1)
}
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)
opaque define on_line : (fn (Point, Line) -> bool)
define on_ray : (fn (Point, Point, Point) -> bool) = fun P:Point, A:Point, B:Point {
on_segment(P, A, B) or between(A, B, P)
}
define on_segment : (fn (Point, Point, Point) -> bool) = fun P:Point, A:Point, B:Point {
P = A or P = B or between(A, P, B)
}
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
}
opaque define operator % : (fn (Int, Int) -> Int)
define operator % : (fn (Nat, Nat) -> Nat) = fun n:Nat, m:Nat {
n ∸ (n / m) * m
}
opaque recursive operator *(UInt,UInt) -> UInt
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 *(Nat,Nat) -> Nat{
operator *(zero, m) = zero
operator *(suc(n), m) = m + n * m
}
opaque define operator * : (fn (Rat, Angle) -> Angle)
opaque recursive operator +(UInt,UInt) -> UInt
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 +(Nat,Nat) -> Nat{
operator +(zero, m) = m
operator +(suc(n), m) = suc(n + m)
}
opaque define operator + : (fn (Angle, Angle) -> Angle)
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)
opaque define operator - : (fn Angle -> Angle)
opaque define operator - : (fn (Angle, Angle) -> Angle)
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
}
}
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)
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 recursive operator <(UInt,UInt) -> bool
opaque define operator < : (fn (Int, Int) -> bool)
opaque define operator < : (fn (Rat, Rat) -> bool)
opaque define operator < : (fn (Real, Real) -> bool)
define operator < : (fn (Nat, Nat) -> bool) = fun x:Nat, y:Nat {
suc(x) ≤ y
}
opaque define operator < : (fn (Angle, Angle) -> bool)
define operator > : (fn (UInt, UInt) -> bool) = fun x:UInt, y:UInt {
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
}
define operator > : (fn (Nat, Nat) -> bool) = fun x:Nat, y:Nat {
y < x
}
define operator > : (fn (Angle, Angle) -> bool) = fun a:Angle, b:Angle {
b < a
}
opaque define operator ^ : (fn (UInt, UInt) -> UInt)
opaque define operator ^ : (fn (Int, UInt) -> Int)
opaque define operator ^ : (fn (Rat, UInt) -> Rat)
opaque define operator ^ : (fn (Real, UInt) -> Real)
define operator ^ : (fn (Nat, Nat) -> Nat) = fun a:Nat, b:Nat {
expt(b, a)
}
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
}
opaque define operator ≤ : (fn (Int, Int) -> bool)
opaque define operator ≤ : (fn (Rat, Rat) -> bool)
postulate fun operator ≤ : (fn (Real, Real) -> bool)
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 (Angle, Angle) -> bool)
define operator ≥ : (fn (UInt, UInt) -> bool) = fun x:UInt, y:UInt {
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
}
define operator ≥ : (fn (Nat, Nat) -> bool) = fun x:Nat, y:Nat {
y ≤ x
}
define operator ≥ : (fn (Angle, Angle) -> bool) = fun a:Angle, b:Angle {
b ≤ a
}
opaque define opposite_sides : (fn (Point, Point, Line) -> bool)
opaque define parallel : (fn (Line, Line) -> bool)
recursive parity(Nat,bool) -> bool{
parity(zero, b) = b
parity(suc(n'), b) = parity(n', not b)
}
opaque define perpendicular : (fn (Line, Line) -> bool)
opaque define point : (fn (Real, Real) -> Point)
point_collinear_rotate: all A:Point, B:Point, C:Point. collinear(A, B, C) = collinear(B, C, A)
point_collinear_same: all A:Point, B:Point. collinear(A, A, B)
point_collinear_swap: all A:Point, B:Point, C:Point. collinear(A, B, C) = collinear(A, C, B)
point_collinear_trans: all A:Point, B:Point, C:Point, D:Point. if A ≠ B and collinear(A, B, C) and collinear(A, B, D) then collinear(A, C, D)
point_coords: all P:Point. point(xcoord(P), ycoord(P)) = P
point_cross_frame: all A:Point, B:Point, C:Point, D:Point. dist2(A, B) * cross(A, C, D) = dot(A, B, C) * cross(A, B, D) - cross(A, B, C) * dot(A, B, D)
point_dist2_dot: all A:Point, B:Point, C:Point. dist2(B, C) = (dist2(A, B) + dist2(A, C)) - real(+2) * dot(A, B, C)
point_dist2_nonneg: all A:Point, B:Point. real(+0) ≤ dist2(A, B)
point_dist2_pos: all A:Point, B:Point. if A ≠ B then real(+0) < dist2(A, B)
point_dist2_self: all A:Point. dist2(A, A) = real(+0)
point_dist2_symmetric: all A:Point, B:Point. dist2(A, B) = dist2(B, A)
point_dist2_zero: all A:Point, B:Point. dist2(A, B) = real(+0) = (A = B)
point_dist_nonneg: all A:Point, B:Point. real(+0) ≤ dist(A, B)
point_dist_self: all A:Point. dist(A, A) = real(+0)
point_dist_square: all A:Point, B:Point. dist(A, B) * dist(A, B) = dist2(A, B)
point_dist_symmetric: all A:Point, B:Point. dist(A, B) = dist(B, A)
point_dist_unique: all A:Point, B:Point, r:Real. if real(+0) ≤ r and r * r = dist2(A, B) then dist(A, B) = r
point_dist_zero: all A:Point, B:Point. dist(A, B) = real(+0) = (A = B)
point_dot_frame: all A:Point, B:Point, C:Point, D:Point. dist2(A, B) * dot(A, C, D) = dot(A, B, C) * dot(A, B, D) + cross(A, B, C) * cross(A, B, D)
point_equal: all P:Point, Q:Point. if xcoord(P) = xcoord(Q) and ycoord(P) = ycoord(Q) then P = Q
point_midpoint_collinear: all A:Point, B:Point. collinear(A, midpoint(A, B), B)
point_midpoint_dist2: all A:Point, B:Point. real(+4) * dist2(A, midpoint(A, B)) = dist2(A, B)
point_midpoint_equidistant: all A:Point, B:Point. dist2(A, midpoint(A, B)) = dist2(midpoint(A, B), B)
point_midpoint_seg_congruent: all A:Point, B:Point. seg_congruent(A, midpoint(A, B), midpoint(A, B), B)
point_midpoint_self: all A:Point. midpoint(A, A) = A
point_midpoint_symmetric: all A:Point, B:Point. midpoint(A, B) = midpoint(B, A)
point_pythagoras: all A:Point, B:Point, C:Point. if dot(A, B, C) = real(+0) then dist2(B, C) = dist2(A, B) + dist2(A, C)
point_pythagoras_converse: all A:Point, B:Point, C:Point. if dist2(B, C) = dist2(A, B) + dist2(A, C) then dot(A, B, C) = real(+0)
point_seg_congruent_dist: all A:Point, B:Point, C:Point, D:Point. seg_congruent(A, B, C, D) = (dist(A, B) = dist(C, D))
point_seg_congruent_refl: all A:Point, B:Point. seg_congruent(A, B, A, B)
point_seg_congruent_reverse: all A:Point, B:Point. seg_congruent(A, B, B, A)
point_seg_congruent_symm: all A:Point, B:Point, C:Point, D:Point. if seg_congruent(A, B, C, D) then seg_congruent(C, D, A, B)
point_seg_congruent_trans: all A:Point, B:Point, C:Point, D:Point, E:Point, F:Point. if seg_congruent(A, B, C, D) and seg_congruent(C, D, E, F) then seg_congruent(A, B, E, F)
point_slope_collinear: all A:Point, B:Point, C:Point. if xcoord(A) ≠ xcoord(B) and xcoord(A) ≠ xcoord(C) then collinear(A, B, C) = (slope(A, B) = slope(A, C))
point_slope_symmetric: all A:Point, B:Point. slope(A, B) = slope(B, A)
auto point_xcoord
point_xcoord: all x:Real, y:Real. xcoord(point(x, y)) = x
auto point_ycoord
point_ycoord: all x:Real, y:Real. ycoord(point(x, y)) = y
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
ray_dist_unique: all A:Point, B:Point, P:Point, Q:Point. if A ≠ B and on_ray(P, A, B) and on_ray(Q, A, B) and dist(A, P) = dist(A, Q) then P = Q
ray_dot: all A:Point, B:Point, P:Point. if A ≠ B then on_ray(P, A, B) = (collinear(A, B, P) and real(+0) ≤ dot(A, B, P))
ray_on_line: all A:Point, B:Point, P:Point. if A ≠ B and on_ray(P, A, B) then on_line(P, line(A, B))
ray_opposite: all A:Point, B:Point, C:Point, P:Point. if between(B, A, C) then (on_ray(P, A, B) or on_ray(P, A, C)) = on_line(P, line(A, B))
ray_point_plotting: all A:Point, B:Point, r:Real. if A ≠ B and real(+0) ≤ r then some P:Point. on_ray(P, A, B) and dist(A, P) = r
ray_ruler: all A:Point, B:Point, P:Point. if A ≠ B then on_ray(P, A, B) = (on_line(P, line(A, B)) and real(+0) ≤ ruler(A, B, P))
ray_ruler_dist: all A:Point, B:Point, P:Point. if A ≠ B and on_ray(P, A, B) then dist(A, P) = ruler(A, B, P)
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) ++ node(n, [])
}
reverse_append: all U:type, xs:List<U>, ys:List<U>. reverse(xs ++ ys) = reverse(ys) ++ reverse(xs)
define right_angle : (fn (Point, Point, Point) -> bool) = fun A:Point, B:Point, C:Point {
m_angle(A, B, C) = deg(+90)
}
define ruler : (fn (Point, Point, Point) -> Real) = fun A:Point, B:Point, P:Point {
dot(A, B, P) / dist(A, B)
}
ruler_dist: all A:Point, B:Point, P:Point, Q:Point. if A ≠ B and on_line(P, line(A, B)) and on_line(Q, line(A, B)) then dist(P, Q) = abs(ruler(A, B, P) - ruler(A, B, Q))
ruler_left: all A:Point, B:Point. ruler(A, B, A) = real(+0)
ruler_onto: all A:Point, B:Point, r:Real. if A ≠ B then some P:Point. on_line(P, line(A, B)) and ruler(A, B, P) = r
ruler_right: all A:Point, B:Point. if A ≠ B then ruler(A, B, B) = dist(A, B)
opaque define same_side : (fn (Point, Point, Line) -> bool)
seg_add: all A:Point, B:Point, C:Point. on_segment(B, A, C) = (dist(A, B) + dist(B, C) = dist(A, C))
define seg_congruent : (fn (Point, Point, Point, Point) -> bool) = fun A:Point, B:Point, C:Point, D:Point {
dist2(A, B) = dist2(C, D)
}
define seg_cross : (fn (Point, Point, Point, Point) -> Real) = fun A:Point, B:Point, C:Point, D:Point {
(xcoord(B) - xcoord(A)) * (ycoord(D) - ycoord(C)) - (ycoord(B) - ycoord(A)) * (xcoord(D) - xcoord(C))
}
define seg_dot : (fn (Point, Point, Point, Point) -> Real) = fun A:Point, B:Point, C:Point, D:Point {
(xcoord(B) - xcoord(A)) * (xcoord(D) - xcoord(C)) + (ycoord(B) - ycoord(A)) * (ycoord(D) - ycoord(C))
}
seg_midpoint_iff: all A:Point, B:Point, M:Point. M = midpoint(A, B) = (on_segment(M, A, B) and dist(A, M) = dist(M, B))
seg_on_left: all A:Point, B:Point. on_segment(A, A, B)
seg_on_ray: all P:Point, A:Point, B:Point. if on_segment(P, A, B) then on_ray(P, A, B)
seg_on_right: all A:Point, B:Point. on_segment(B, A, B)
seg_symmetric: all P:Point, A:Point, B:Point. on_segment(P, A, B) = on_segment(P, B, A)
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
define slope : (fn (Point, Point) -> Real) = fun A:Point, B:Point {
(ycoord(A) - ycoord(B)) / (xcoord(A) - xcoord(B))
}
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 supplementary : (fn (Angle, Angle) -> bool) = fun a:Angle, b:Angle {
a + b = deg(+180)
}
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([]) = node([], [])
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))) })
tri_aas: all A:Point, B:Point, C:Point, D:Point, E:Point, F:Point. if triangle(A, B, C) and angle_congruent(C, A, B, F, D, E) and angle_congruent(A, B, C, D, E, F) and seg_congruent(B, C, E, F) then tri_congruent(A, B, C, D, E, F)
tri_angle_sum: all A:Point, B:Point, C:Point. if triangle(A, B, C) then m_angle(C, A, B) + m_angle(A, B, C) + m_angle(B, C, A) = deg(+180)
tri_asa: all A:Point, B:Point, C:Point, D:Point, E:Point, F:Point. if triangle(A, B, C) and angle_congruent(C, A, B, F, D, E) and seg_congruent(A, B, D, E) and angle_congruent(A, B, C, D, E, F) then tri_congruent(A, B, C, D, E, F)
define tri_congruent : (fn (Point, Point, Point, Point, Point, Point) -> bool) = fun A:Point, B:Point, C:Point, D:Point, E:Point, F:Point {
seg_congruent(A, B, D, E) and seg_congruent(B, C, E, F) and seg_congruent(C, A, F, D) and angle_congruent(C, A, B, F, D, E) and angle_congruent(A, B, C, D, E, F) and angle_congruent(B, C, A, E, F, D)
}
tri_congruent_rotate: all A:Point, B:Point, C:Point, D:Point, E:Point, F:Point. if tri_congruent(A, B, C, D, E, F) then tri_congruent(B, C, A, E, F, D)
tri_cpctc: all A:Point, B:Point, C:Point, D:Point, E:Point, F:Point. if tri_congruent(A, B, C, D, E, F) then seg_congruent(A, B, D, E) and seg_congruent(B, C, E, F) and seg_congruent(C, A, F, D) and angle_congruent(C, A, B, F, D, E) and angle_congruent(A, B, C, D, E, F) and angle_congruent(B, C, A, E, F, D)
tri_exterior_angle: all A:Point, B:Point, C:Point, D:Point. if triangle(A, B, C) and between(B, C, D) then m_angle(A, C, D) = m_angle(C, A, B) + m_angle(A, B, C)
tri_hl: all A:Point, B:Point, C:Point, D:Point, E:Point, F:Point. if right_angle(A, C, B) and right_angle(D, F, E) and seg_congruent(A, B, D, E) and seg_congruent(A, C, D, F) then tri_congruent(A, B, C, D, E, F)
tri_inequality: all A:Point, B:Point, C:Point. dist(A, C) ≤ dist(A, B) + dist(B, C)
tri_inequality_strict: all A:Point, B:Point, C:Point. if triangle(A, B, C) then dist(A, C) < dist(A, B) + dist(B, C)
tri_isosceles: all A:Point, B:Point, C:Point. if seg_congruent(A, B, A, C) then angle_congruent(A, B, C, A, C, B)
tri_isosceles_converse: all A:Point, B:Point, C:Point. if triangle(A, B, C) and angle_congruent(A, B, C, A, C, B) then seg_congruent(A, B, A, C)
tri_sas: all A:Point, B:Point, C:Point, D:Point, E:Point, F:Point. if triangle(A, B, C) and seg_congruent(A, B, D, E) and angle_congruent(C, A, B, F, D, E) and seg_congruent(A, C, D, F) then tri_congruent(A, B, C, D, E, F)
tri_sss: all A:Point, B:Point, C:Point, D:Point, E:Point, F:Point. if seg_congruent(A, B, D, E) and seg_congruent(B, C, E, F) and seg_congruent(C, A, F, D) then tri_congruent(A, B, C, D, E, F)
define triangle : (fn (Point, Point, Point) -> bool) = fun A:Point, B:Point, C:Point {
not collinear(A, B, C)
}
triangle_distinct: all A:Point, B:Point, C:Point. if triangle(A, B, C) then A ≠ B and B ≠ C and A ≠ C
triangle_right: all A:Point, B:Point, C:Point. if right_angle(A, B, C) then triangle(A, B, C)
triangle_rotate: all A:Point, B:Point, C:Point. triangle(A, B, C) = triangle(B, C, A)
triangle_swap: all A:Point, B:Point, C:Point. triangle(A, B, C) = triangle(A, C, B)
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:UInt) = 0
uint_log_pos: all n:UInt. if 1 < n then 0 < log(n)
uint_log_two: log(2:UInt) = 1
auto uint_log_zero
uint_log_zero: log(0:UInt) = 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) + 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:UInt) + (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:UInt) ^ 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)))
}
opaque define xcoord : (fn Point -> Real)
opaque define ycoord : (fn Point -> Real)
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, []:List<U>) = []
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))