Skip to content
Rainbow docs menu

Reference · The Applied Higher-Order Functions catalogue

rainbow.algorithms.proofs.ahof.linear-interpolation

The Applied Higher-Order Functions cataloguesrc/rainbow/algorithms/proofs/ahof/linear_interpolation.clj4 definitions, 5 theorems

AHoF D27 Linear Interpolation over exact rationals: interpolate between two values a and b with convex weights w0, w1 (summing to one), lerp a b w0 w1 = w0 * a + w1 * b. Interpolating between 1/2 and 3/4: the midpoint (weights 1/2, 1/2) is 5/8; the left endpoint (weights 1, 0) is 1/2; the right endpoint (weights 0, 1) is 3/4. Values are proved by cross-product equivalence. Proved native and axiom-free. Scope (measured by the kernel): this module has 4 worked instances (statements about specific values) and 1 definitional unfoldings (true by unfolding a definition). None of its theorems is a guarantee about the algorithm for all inputs; `lein verify rainbow.algorithms.proofs.ahof.linear-interpolation` prints this classification.

interp/lerp

DefinitionSource, line 56

interp/lerp :
  (x₁ x₂ x₃ x₄ : ℚ≥0)
  → ℚ≥0

ℚ≥0 = nnrat/NonnegativeRational

interp/midpoint

DefinitionSource, line 63

interp/midpoint :
  → ℚ≥0

ℚ≥0 = nnrat/NonnegativeRational

interp/left-endpoint

DefinitionSource, line 66

interp/left-endpoint :
  → ℚ≥0

ℚ≥0 = nnrat/NonnegativeRational

interp/right-endpoint

DefinitionSource, line 69

interp/right-endpoint :
  → ℚ≥0

ℚ≥0 = nnrat/NonnegativeRational

interp/lerp-unfold

TheoremHolds by unfolding a definitionNo axiomsSource, line 78

interp/lerp-unfold :
  (a b w0 w1 : ℚ≥0)
  → interp/lerp a b w0 w1 = w0 · a + w1 · b

+ = nnrat/add= = equality/Eq· = nnrat/multiplyℚ≥0 = nnrat/NonnegativeRational

interp/midpoint-is-five-eighths

TheoremWorked exampleNo axiomsSource, line 89

interp/midpoint-is-five-eighths :
  → interp/midpoint = 5/8

= = nnrat/equivalent: equality of rational values

interp/left-endpoint-is-a

TheoremWorked exampleNo axiomsSource, line 95

interp/left-endpoint-is-a :
  → interp/left-endpoint = 1/2

= = nnrat/equivalent: equality of rational values

interp/right-endpoint-is-b

TheoremWorked exampleNo axiomsSource, line 101

interp/right-endpoint-is-b :
  → interp/right-endpoint = 3/4

= = nnrat/equivalent: equality of rational values

interp/linear-interpolation

TheoremWorked exampleNo axiomsSource, line 108

interp/linear-interpolation :
  → proposition/conjunction (interp/midpoint = 5/8) (interp/left-endpoint = 1/2)

= = nnrat/equivalent: equality of rational values