Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Computable analysis · FTCMonomials · fd889115 k1

Definition
liuyao_ca_fd889115_k1_Analysis_FTCMonomials

by liuyao · Nov 15, 2026 · Mathlib 0df444a (Lean v4.33.1)

ca-fd889115-k1

Private dependency for the Distribution Theory mission. Module ComputableAnalysis/FTCMonomials.lean from the frozen computable-analysis foundation with kernel-checked rational decision proofs.

Definition code
import Definitions.Def_liuyao_ca_fd889115_k1_Analysis_FTCRealCalculus
import Definitions.Def_liuyao_ca_fd889115_k1_Analysis_FinitePolynomialCalculus

set_option autoImplicit true

/-! Finite rational monomials as actual FTC steps. These support integration
of constants and the polynomial terms generated by repeated FTC. -/
namespace ComputableAnalysis.FTCMonomials
open ComputableCoefficient RealApproximationOrder FTCRealCalculus RationalMajorant FinitePolynomial
set_option maxHeartbeats 600000

private theorem one_pow (n : Nat) : (1:Rat)^n=1 := by
  induction n with
  | zero => rfl
  | succ n ih => rw [Rat.pow_succ,ih,Rat.one_mul]

private theorem unit_abs {u : Rat} (hu : 0≤u) (hv : u≤1) : qabs u≤1 := by
  rw [qabs_eq_self_of_nonneg hu]
  exact hv

def normalized (n : Nat) :
    Step (fun t => Value.rational (t^(n+1)/((n+1:Nat):Rat)))
      (fun t => Value.rational (t^n)) 0 1 where
  error := powerSecantErrorBound 1 (n+1)
  error_nonnegative := powerSecantErrorBound_nonneg (by decide +kernel) _
  radius := ⟨1,by decide +kernel⟩
  firstOrder := by
    intro u v hu huv hv _
    have hp : 0<v-u := by grind only
    have H := (FinitePolynomial.normalizedMonomialSecantBound 1 n (by decide +kernel)).error_bound
      u (v-u) (Rat.ne_of_gt hp) (unit_abs hu (by grind only))
      (by rw [show u+(v-u)=v by grind only]; exact unit_abs (by grind only) hv)
    rw [show u+(v-u)=v by grind only,qabs_eq_self_of_nonneg (Rat.le_of_lt hp)] at H
    let A := v^(n+1)/((n+1:Nat):Rat)-u^(n+1)/((n+1:Nat):Rat)-(v-u)*u^n
    have he : A=(v-u)*((v^(n+1)/((n+1:Nat):Rat)-u^(n+1)/((n+1:Nat):Rat))/(v-u)-u^n) := by
      have hc := Rat.mul_inv_cancel (v-u) (Rat.ne_of_gt hp)
      dsimp [A]
      simp only [Rat.div_def]
      grind only
    have hb : qabs A≤powerSecantErrorBound 1 (n+1)*(v-u)*(v-u) := by
      rw [he,qabs_mul,qabs_eq_self_of_nonneg (Rat.le_of_lt hp)]
      have h := Rat.mul_le_mul_of_nonneg_left H (Rat.le_of_lt hp)
      change _≤(v-u)*((v-u)*powerSecantErrorBound 1 (n+1)) at h
      grind only
    apply ((rational_small A).mono hb).congr
    apply arithmetic_identity
    intro s
    simp only [Value.rational,sub,scale]
    rfl
  variation := (n:Rat)
  variation_nonnegative := Rat.natCast_nonneg
  lipschitz := by
    intro u v hu huv hv
    have H := qabs_pow_sub_le_lipschitz (x := v) (y := u) (B := 1)
      (by decide +kernel) (by decide +kernel) (unit_abs (by grind only) hv) (unit_abs hu (by grind only)) n
    have hone := one_pow n
    rw [hone,Rat.mul_one,qabs_eq_self_of_nonneg (show 0≤v-u by grind only)] at H
    have hb : qabs (v^n-u^n)≤(n:Rat)*(v-u) := by grind only
    apply ((rational_small (v^n-u^n)).mono hb).congr
    apply arithmetic_identity
    intro s
    simp only [Value.rational,sub]

def term (n : Nat) (t : Rat) : Rat := t^n/factorialRat n

def factorial (n : Nat) :
    Step (fun t => Value.rational (term (n+1) t)) (fun t => Value.rational (term n t)) 0 1 := by
  let S := (normalized n).scale (1/factorialRat n)
  apply S.congr
  · intro t
    apply arithmetic_identity
    intro s
    simp only [scale,Value.rational,term]
    rw [FormalPowerSeries.factorialRat_succ]
    simp only [Rat.div_def,Rat.inv_mul_rev,Rat.one_mul]
    grind only
  · intro t
    apply arithmetic_identity
    intro s
    simp only [scale,Value.rational,term,Rat.div_def,Rat.one_mul]
    grind only

/-- A represented constant times the monomial generated by the preceding
integration. Coefficients may be irrational. -/
def coefficient (n : Nat) (C : Value) (B : Rat) (hB : 0≤B) (hC : Small C B) :
    Step (fun t => scale (term (n+1) t) C) (fun t => scale (term n t) C) 0 1 := by
  let S := (factorial n).mul_constant C B hB hC
  apply S.congr
  · intro t
    apply arithmetic_identity
    intro s
    simp only [Value.mul,Value.rational,scale]
    grind only
  · intro t
    apply arithmetic_identity
    intro s
    simp only [Value.mul,Value.rational,scale]
    grind only

theorem term_zero_succ (n : Nat) : term (n+1) 0=0 := by
  unfold term
  rw [Rat.pow_succ,Rat.mul_zero,Rat.div_def,Rat.zero_mul]

theorem term_zero_zero : term 0 0=1 := by decide +kernel

theorem term_one (n : Nat) : term n 1=1/factorialRat n := by
  have h : (1:Rat)^n=1 := by induction n with | zero => rfl | succ n ih => rw [Rat.pow_succ,ih,Rat.one_mul]
  unfold term
  rw [h]

end ComputableAnalysis.FTCMonomials

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me