@[irreducible]
Equations
- Chapter7.foldr1₀ f as = if h₂ : (↑as).length = 1 then (↑as).head ⋯ else let as' := (↑as).tail; have this := ⋯; f ((↑as).head ⋯) (Chapter7.foldr1₀ f ⟨as', ⋯⟩)
Instances For
@[irreducible]
Equations
- Chapter7.foldr1₁ f as h = if h₂ : as.length = 1 then as.head ⋯ else f (as.head ⋯) (Chapter7.foldr1₁ f as.tail ⋯)
Instances For
Equations
- Chapter7.foldr1 f [] = default
- Chapter7.foldr1 f (x_1 :: xs) = List.foldr f x_1 xs
Instances For
def
Chapter7.minWith
{a b : Type}
[LE b]
[Inhabited a]
[DecidableRel fun (x1 x2 : b) => x1 ≤ x2]
(f : a → b)
(as : List a)
:
a
Equations
- Chapter7.minWith f as = Chapter7.foldr1 ((fun (f : a → b) (x y : a) => bif decide (f x ≤ f y) then x else y) f) as
Instances For
Equations
- Chapter7.ic xs = (List.filter (fun (p : a × a) => decide (p.1 > p.2)) (Chapter7.pairs xs)).length
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
- Chapter7.picks [] = []
- Chapter7.picks (x_1 :: xs_1) = (x_1, xs_1) :: Chapter7.picks.helper x_1 (Chapter7.picks xs_1)
Instances For
def
Chapter7.pick
{a : Type}
[Inhabited a]
[LE a]
[h₂ : DecidableRel fun (x1 x2 : a) => x1 ≤ x2]
(xs : List a)
:
Equations
- Chapter7.pick xs = match Chapter7.picks xs with | [] => (default, []) | [p] => p | p :: ps => Chapter7.pick.aux p ps
Instances For
Equations
Instances For
Equations
Instances For
def
Chapter7.sort₁
{a : Type}
[Inhabited a]
[Ord a]
[LT a]
[h₁ : DecidableRel fun (x1 x2 : a) => x1 < x2]
:
Equations
- Chapter7.sort₁ [] = []
- Chapter7.sort₁ x✝ = match Chapter7.pick₁ x✝ with | (x, ys) => x :: Chapter7.sort ys
Instances For
def
Chapter7.sort₂
{a : Type}
[Inhabited a]
[LT a]
[h₁ : DecidableRel fun (x1 x2 : a) => x1 < x2]
[LE a]
[h₂ : DecidableRel fun (x1 x2 : a) => x1 ≤ x2]
:
Equations
- Chapter7.sort₂ [] = []
- Chapter7.sort₂ x✝ = match Chapter7.pick x✝ with | (x, ys) => x :: Chapter7.sort ys
Instances For
Equations
- Chapter7.instMaxTuple = { max := fun (x y : Chapter7.Tuple) => if x > y then x else y }
Equations
- Chapter7.amount ds cs = (List.zipWith (fun (x1 x2 : ℕ) => x1 * x2) ds cs).sum
Instances For
Equations
- Chapter7.mktuples₀ [1] x✝ = [[x✝]]
- Chapter7.mktuples₀ [] x✝ = panicWithPosWithDecl "Fad.Chapter7" "Chapter7.mktuples₀" 178 18 "mktuples: invalid empty list"
- Chapter7.mktuples₀ (d :: ds) x✝ = List.flatMap (fun (c : ℕ) => List.map (fun (cs : List ℕ) => c :: cs) (Chapter7.mktuples₀ ds (x✝ - c * d))) (List.range (x✝ / d + 1))
Instances For
Equations
Instances For
Equations
Instances For
Equations
- Chapter7.mkchange [1] x✝ = [x✝]
- Chapter7.mkchange [] x✝ = panicWithPosWithDecl "Fad.Chapter7" "Chapter7.mkchange" 208 18 "mkchange: invalid empty list"
- Chapter7.mkchange (d :: ds) x✝ = x✝ / d :: Chapter7.mkchange ds (x✝ - x✝ / d * d)