@[inline]
Tail-recursive version of Nat.fold
.
Equations
- Nat.foldTR f n init = Nat.foldTR.loop f n n init
Instances For
@[specialize #[]]
Equations
- Nat.foldTR.loop f n 0 x = x
- Nat.foldTR.loop f n (Nat.succ n_1) x = Nat.foldTR.loop f n n_1 (f (n - Nat.succ n_1) x)
Instances For
@[specialize #[]]
Nat.foldRev
evaluates f
on the numbers up to n
exclusive, in decreasing order:
Nat.foldRev f 3 init = f 0 <| f 1 <| f 2 <| init
Equations
- Nat.foldRev f 0 x = x
- Nat.foldRev f (Nat.succ n) x = Nat.foldRev f n (f n x)
Instances For
@[specialize #[]]
Equations
- Nat.anyTR.loop f n 0 = false
- Nat.anyTR.loop f n (Nat.succ n_1) = (f (n - Nat.succ n_1) || Nat.anyTR.loop f n n_1)
Instances For
@[specialize #[]]
Equations
- Nat.allTR.loop f n 0 = true
- Nat.allTR.loop f n (Nat.succ n_1) = (f (n - Nat.succ n_1) && Nat.allTR.loop f n n_1)
Instances For
@[specialize #[]]
Nat.repeat f n a
is f^(n) a
; that is, it iterates f
n
times on a
.
Nat.repeat f 3 a = f <| f <| f <| a
Equations
- Nat.repeat f 0 x = x
- Nat.repeat f (Nat.succ n) x = f (Nat.repeat f n x)
Instances For
@[inline]
Tail-recursive version of Nat.repeat
.
Equations
- Nat.repeatTR f n a = Nat.repeatTR.loop f n a
Instances For
@[specialize #[]]
Equations
- Nat.repeatTR.loop f 0 x = x
- Nat.repeatTR.loop f (Nat.succ n) x = Nat.repeatTR.loop f n (f x)
Instances For
Helper "packing" theorems #
Helper Bool relation theorems #
Nat.add theorems #
Nat.mul theorems #
Inequalities #
Equations
Basic theorems for comparing numerals #
mul + order #
power #
min/max #
Auxiliary theorems for well-founded recursion #
sub/pred theorems #
Helper normalization theorems #
csimp theorems #
theorem
Nat.repeat_eq_repeatTR.go
(α : Type u_1)
(f : α → α)
(init : α)
(m : Nat)
(n : Nat)
:
Nat.repeatTR.loop f m (Nat.repeat f n init) = Nat.repeat f (m + n) init
@[inline]
(start, stop).foldI f a
evaluates f
on all the numbers
from start
(inclusive) to stop
(exclusive) in increasing order:
(5, 8).foldI f init = init |> f 5 |> f 6 |> f 7
Equations
- Prod.foldI f i a = Nat.foldTR.loop f i.snd (i.snd - i.fst) a