Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Mizar/abstr/   (Mizar Prover Version 8.1.15©)  Datei vom 6.10.2026 mit Größe 20 kB image not shown  

Quelle  stirlin1.abs   Sprache: Mizar

 

:: A Formal Proof of {S}tirling's Formula
::  by Yasushige Watase
:: 
:: Received September 17, 2025
:: Copyright (c) 2025-2026 Association of Mizar Users
::           (Stowarzyszenie Uzytkownikow Mizara, Bialystok, Poland).
:: This code can be distributed under the GNU General Public Licence
:: version 3.0 or later, or the Creative Commons Attribution-ShareAlike
:: License version 4.0 or later, subject to the binding interpretation
:: detailed in file COPYING.interpretation.
:: See COPYING.GPL and COPYING.CC-BY-SA for the full text of these
:: licenses, or see http://www.gnu.org/licenses/gpl.html and
:: http://creativecommons.org/licenses/by-sa/4.0/.

environ

 vocabularies NUMBERS, SUBSET_1, REAL_1, INTEGRA1, FINSEQ_1, ORDINAL4, CARD_3,
      ARYTM_1, ARYTM_3, RELAT_1, FUNCT_1, XXREAL_0, NAT_1, XBOOLE_0, VALUED_1,
      TARSKI, XXREAL_2, ORDINAL2, CARD_1, FDIFF_1, XXREAL_1, RCOMP_1, INTEGRA5,
      MEASURE5, XCMPLX_0, VECTSP_1, LTLAXIO1, VALUED_0, SQUARE_1, REALSET1,
      PARTFUN1, TAYLOR_1, LIMFUNC1, PRALG_3, PRE_POLY, DIOPHAN2, JGRAPH_2,
      FCONT_1, SEQ_4, FUNCT_7, STRUCT_0, NEWTON, SEQ_1, QC_LANG1, POWER, SEQ_2,
      PREPOWER, MEASURE7, INTEGRA4, MESFUN14, FUNCT_3, INTEGRA2, FUNCT_2,
      SUPINF_2, FUNCOP_1, COMPLEX1, GR_CY_1, MESFUNC1, INTEGRA7, SERIES_1,
      PRGCOR_2, AFINSQ_1, SIN_COS, STIRLIN1, WALLIS01;
 notations TARSKI, XBOOLE_0, SUBSET_1, RELAT_1, FUNCT_1, ORDINAL1, RELSET_1,
      PARTFUN1, FUNCT_2, FUNCOP_1, NUMBERS, XCMPLX_0, XXREAL_0, XREAL_0,
      SQUARE_1, NAT_1, VALUED_0, COMPLEX1, NAT_D, XXREAL_2, FINSEQ_1, VALUED_1,
      SEQ_1, SEQ_2, RFUNCT_1, RVSUM_1, NEWTON, SEQ_4, RCOMP_1, FCONT_1,
      FDIFF_1, PREPOWER, POWER, SERIES_1, LIMFUNC1, MEASURE5, SIN_COS,
      AFINSQ_1, IRRAT_1, TAYLOR_1, PRE_POLY, INTEGRA1, INTEGRA2, INTEGRA3,
      INTEGRA4, INTEGRA5, PARTFUN3, STRUCT_0, ALGSTR_0, RLVECT_1, VECTSP_1,
      POLYNOM1, BINOM, INTEGRA7, MATRTOP1, DIOPHAN2, MESFUN14, WALLIS01;
 constructors RELSET_1, SQUARE_1, NAT_D, BINOP_2, COMSEQ_2, RVSUM_1, SEQ_4,
      FCONT_1, FDIFF_1, PREPOWER, LIMFUNC1, MEASURE6, SIN_COS, TAYLOR_1,
      INTEGRA2, INTEGRA3, INTEGRA4, INTEGRA5, PARTFUN3, FVSUM_1, BINOM,
      INTEGRA7, MATRTOP1, DIOPHAN2, RVSUM_4, MESFUN14, E_TRANS1, WALLIS01;
 registrations RELAT_1, NUMBERS, XXREAL_0, XREAL_0, MEMBERED, FINSEQ_1,
      RCOMP_1, INTEGRA1, VALUED_0, VALUED_1, FUNCT_2, FINSET_1, XXREAL_2,
      CARD_1, RELSET_1, MEASURE5, ORDINAL1, FUNCT_1, NAT_1, POLYDIFF, FUNCOP_1,
      NEWTON04, XCMPLX_0, NEWTON, SIN_COS, RVSUM_4, STRUCT_0, SUBSET_1,
      VECTSP_1, FCONT_1, SQUARE_1, NAT_6, PARTFUN3, POWER, FINSEQ_9, FCONT_3,
      FDIFF_1, AFINSQ_1, FOMODEL0, WALLIS01;
 requirements NUMERALS, BOOLE, SUBSET, REAL, ARITHM;


begin

theorem :: STIRLIN1:1
  for n be Nat,k be Nat st k in Seg (n+1) holds
    divset(EqDiv(['0,1'],(n+1)),k) = [.(k-'1)/(n+1), k/(n+1).];

definition
  func D[01] -> sequence of divs ['0,1'] means
:: STIRLIN1:def 1
  for n be Element of NAT holds it.n = EqDiv(['0,1'],n+1);
end;

theorem :: STIRLIN1:2
  for n be Nat holds delta(EqDiv(['0,1'],n+1)) = 1/(n+1);

theorem :: STIRLIN1:3
  delta(D[01]) is 0-convergent non-zero Real_Sequence;

definition
  let a,b be Real;
  func ax_+_b(a,b) -> PartFunc of REAL,REAL equals
:: STIRLIN1:def 2
  AffineMap(a,b);
end;

definition
  let r be Real;
  func const(r) -> PartFunc of REAL,REAL equals
:: STIRLIN1:def 3
  AffineMap(0,r);
end;

registration
  let r be Real;
  cluster const(r) -> constant;
end;

definition
  func rohl -> Subset of REAL equals
:: STIRLIN1:def 4
  right_open_halfline(-1);
end;

definition
  let f be PartFunc of REAL,REAL,
      A be non empty closed_interval Subset of REAL;
  pred f is_C^1-Class_on A means
:: STIRLIN1:def 5
  f is_differentiable_on right_open_halfline(-1)
  & f`|(right_open_halfline(-1)) is continuous &
  A c= right_open_halfline(-1) & right_open_halfline(-1) c= dom f;
end;

definition
  let A be non empty closed_interval Subset of REAL;
  let f be PartFunc of REAL,REAL;
  assume
 f is_C^1-Class_on A;
  func @'(f,A) -> Function of A, REAL equals
:: STIRLIN1:def 6
  (f`|right_open_halfline(-1))|A;
end;

definition
  let A be non empty closed_interval Subset of REAL;
  let f be PartFunc of REAL,REAL;
  assume
 A c= dom f;
  func @(f,A) -> Function of A, REAL equals
:: STIRLIN1:def 7
  f|A;
end;

 reserve Z for open Subset of REAL;

theorem :: STIRLIN1:4
  for n be Nat,k be Nat, x0 be Real, f be PartFunc of REAL,REAL
   st k in Seg (n+1) & x0 in ['(k-'1)/(n+1),k/(n+1)'] &
   f is_C^1-Class_on ['0,1'] holds
   integral(f`|rohl,['x0,k/(n+1)'])
   = f.(upper_bound ['x0,k/(n+1)'])-f.(lower_bound ['x0,k/(n+1)']);

definition
  let n be Nat,f be PartFunc of REAL,REAL;
  func UPBND_rng_d(f,n) -> FinSequence of F_Real means
:: STIRLIN1:def 8
  len it = n+1 & for i being Nat st i in dom it holds
  it.i = upper_bound rng ((f`|rohl)|['(i-'1)/(n+1),i/(n+1)']);
end;

definition
  let n be Nat,f be PartFunc of REAL,REAL;
  func LWBND_rng_d(f,n) -> FinSequence of F_Real means
:: STIRLIN1:def 9
  len it = n+1 & for i being Nat st i in dom it holds
  it.i = lower_bound rng ((f`|rohl)|['(i-'1)/(n+1),i/(n+1)']);
end;

definition
  let f be PartFunc of REAL,REAL;
  func Sum_UPBND_rng_d(f) -> sequence of REAL means
:: STIRLIN1:def 10
  for i being Nat holds it.i = (Sum (UPBND_rng_d(f,i)))/(i+1);
end;

definition
  let f be PartFunc of REAL,REAL;
  func Sum_LWBND_rng_d(f) -> sequence of REAL means
:: STIRLIN1:def 11
  for i being Nat holds it.i = (Sum (LWBND_rng_d(f,i)))/(i+1);
end;

theorem :: STIRLIN1:5
  for n be Nat,k be Nat, x0 be Real, f be PartFunc of REAL,REAL
    st k in Seg (n+1) & x0 in ['(k-'1)/(n+1),k/(n+1)']
    & f is_C^1-Class_on ['0,1'] holds
    integral(const(UPBND_rng_d(f,n).k),x0,k/(n+1))
    = (UPBND_rng_d(f,n).k)*(k/(n+1) -x0) &
    integral(const((LWBND_rng_d(f,n)).k),x0,k/(n+1))
    = ((LWBND_rng_d(f,n)).k)*(k/(n+1) -x0);

theorem :: STIRLIN1:6
  for n be Nat,k be Nat, x0 be Real, f be PartFunc of REAL,REAL
   st k in Seg (n+1) & x0 in ['(k-'1)/(n+1),k/(n+1)']
   & f is_C^1-Class_on ['0,1'] holds
   integral(f`|rohl,x0,k/(n+1))
   <= integral(const(UPBND_rng_d(f,n).k),x0,k/(n+1));

theorem :: STIRLIN1:7
  for n be Nat,k be Nat, x0 be Real, f be PartFunc of REAL,REAL
    st k in Seg (n+1) & x0 in ['(k-'1)/(n+1),k/(n+1)']
    & f is_C^1-Class_on ['0,1'] holds
    integral(const((LWBND_rng_d(f,n)).k),x0,k/(n+1))
     <= integral(f`|rohl,x0,k/(n+1));

theorem :: STIRLIN1:8
  for n be Nat,k be Nat, x0 be Real, f be PartFunc of REAL,REAL
   st k in Seg (n+1) & x0 in ['(k-'1)/(n+1),k/(n+1)']
   & f is_C^1-Class_on ['0,1'] holds
   f.(k/(n+1)) -f.x0 <= (UPBND_rng_d(f,n).k)*(k/(n+1) -x0) &
   ((LWBND_rng_d(f,n)).k)*(k/(n+1) -x0) <= f.(k/(n+1)) -f.x0;

definition
  let n be Nat, f be PartFunc of REAL,REAL;
  func 'F'(f,n) -> FinSequence of F_Real means
:: STIRLIN1:def 12
  dom it = Seg (n+1) & for i being Nat st i in dom it holds
   it.i = integral(const(f.(i/(n+1))),(i-'1)/(n+1),i/(n+1));
end;

definition
  let n be Nat, f be PartFunc of REAL,REAL;
  func 'G'(f,n) -> FinSequence of F_Real means
:: STIRLIN1:def 13
  dom it = Seg (n+1) & for i being Nat st i in dom it holds
  it.i = integral(-f,(i-'1)/(n+1),i/(n+1));
end;

definition
   let n be Nat,f be PartFunc of REAL,REAL;
   func step_(f,n) -> FinSequence of F_Real means
:: STIRLIN1:def 14

   dom it = Seg (n+1) & for i being Nat st i in dom it holds
   it.i = f.(i/(n+1));
end;

theorem :: STIRLIN1:9
   for n be Nat,f be PartFunc of REAL,REAL holds
   integral(-f,0,0) = 0;

definition
  let f be PartFunc of REAL,REAL;
  func Sum_step(f) -> Real_Sequence means
:: STIRLIN1:def 15
  for n be Nat holds it.n = Sum step_(f,n);
end;

definition
  let f be PartFunc of REAL,REAL;
  func n_Integral(f) -> Real_Sequence means
:: STIRLIN1:def 16
  for n be Nat holds it.n = (n+1)*integral((-f),0,1);
end;

definition
  let f be PartFunc of REAL,REAL;
  func w_seq(f) -> Real_Sequence equals
:: STIRLIN1:def 17
  Sum_step(f) + n_Integral(f);
end;

:: Main Lemma
theorem :: STIRLIN1:10
  for f be PartFunc of REAL,REAL st f is_C^1-Class_on ['0,1'] holds
    lim w_seq(f) = (1/2)*(integral((f`|rohl)||['0,1']));

begin :: Section 2: Apply the Lemma to log(1+x)

definition
  let c be Real;
  func x_+_c -> PartFunc of REAL,REAL equals
:: STIRLIN1:def 18
  AffineMap(1,c);
end;

theorem :: STIRLIN1:11
  ln*((x_+_(1))|rohl) is_differentiable_on right_open_halfline(-1);

theorem :: STIRLIN1:12
  for Z be open Subset of REAL st Z c= dom (ln*((x_+_(1))|rohl)) holds
   ln*((x_+_(1))|rohl) is_differentiable_on Z &
   for x be Real st x in Z holds ((ln*((x_+_(1))|rohl))`|Z).x = 1/(1+x);

theorem :: STIRLIN1:13
  (ln*((x_+_(1))|rohl))`|rohl = (x_+_(1)^)|rohl;

 reserve x,x0,x1,x2 for Real;

theorem :: STIRLIN1:14
  ((x_+_(1))(#)(ln*((x_+_(1))|rohl)) + (-1(#)(x_+_(0))))`|rohl
    = ln*((x_+_(1))|rohl);

theorem :: STIRLIN1:15
  integral(ln*((x_+_(1))|rohl),0,1) = log(number_e,4/number_e);

theorem :: STIRLIN1:16
    integral((ln*((x_+_(1))|rohl))`|rohl,['0,1']) = ln.2;

theorem :: STIRLIN1:17
  lim w_seq(ln*((x_+_(1))|rohl)) = (1/2)*(ln.2);

definition
  let m be non zero Nat,f be PartFunc of REAL,REAL;
  func Step_(f,m) -> Real_Sequence means
:: STIRLIN1:def 19
  for i be Nat holds it.i = f.(i/m);
end;

theorem :: STIRLIN1:18
  for m be non zero Nat, f be PartFunc of REAL,REAL holds
    (XFS2FS((Step_(f,m))|Segm(m+1))) = <*f.0*>^(step_(f,m-'1));

theorem :: STIRLIN1:19
  for m be non zero Nat,
  f be PartFunc of REAL,REAL st f is_C^1-Class_on ['0,1'] holds
  Sum (XFS2FS((Step_(f,m))|Segm(m+1))) = f.0 + Sum (step_(f,m-'1));

theorem :: STIRLIN1:20
  for m be non zero Nat holds
   Sum (XFS2FS((Step_(ln*((x_+_(1))|rohl),m))|Segm(m+1)))
   = Sum (step_(ln*((x_+_(1))|rohl),m-'1));

theorem :: STIRLIN1:21
  for m be non zero Nat holds
    (w_seq(ln*((x_+_(1))|rohl))).(m-'1)
    = ln.(((2*m)!/(m!))*((number_e/(4*m))^m));

definition
  func W_STIRL -> Real_Sequence means
:: STIRLIN1:def 20
  for n be Nat holds it.n
    = ((2*(n+1))!/((n+1)!))*((number_e/(4*(n+1)))^(n+1));
end;

theorem :: STIRLIN1:22
  for n be Nat holds
    (w_seq(ln*((x_+_(1))|rohl))).n = ln.(W_STIRL.n);

theorem :: STIRLIN1:23
  lim W_STIRL = sqrt(2) & W_STIRL is convergent;

definition
  func Stirl_Seq -> Real_Sequence means
:: STIRLIN1:def 21
  for n be Nat holds it.n = n!/((n^(n+1/2))*(number_e^(-n)));
end;

theorem :: STIRLIN1:24
  lim Stirl_Seq = sqrt(2*PI);

Messung
CHZG
9410010097

¤ Dauer der Verarbeitung: 0.10 Sekunden  (vorverarbeitet am  2026-11-23) ¤

*© Formatika GbR, Deutschland