MPE Home Metamath Proof Explorer < Previous   Next >
Nearby theorems
Mirrors  >  Home  >  MPE Home  >  Th. List  >  algcvg Structured version   Unicode version

Theorem algcvg 13756
Description: One way to prove that an algorithm halts is to construct a countdown function  C : S --> NN0 whose value is guaranteed to decrease for each iteration of  F until it reaches  0. That is, if  X  e.  S is not a fixed point of  F, then  ( C `  ( F `  X ) )  <  ( C `
 X ).

If  C is a countdown function for algorithm  F, the sequence  ( C `  ( R `  k ) ) reaches  0 after at most  N steps, where  N is the value of  C for the initial state  A. (Contributed by Paul Chapman, 22-Jun-2011.)

Hypotheses
Ref Expression
algcvg.1  |-  F : S
--> S
algcvg.2  |-  R  =  seq 0 ( ( F  o.  1st ) ,  ( NN0  X.  { A } ) )
algcvg.3  |-  C : S
--> NN0
algcvg.4  |-  ( z  e.  S  ->  (
( C `  ( F `  z )
)  =/=  0  -> 
( C `  ( F `  z )
)  <  ( C `  z ) ) )
algcvg.5  |-  N  =  ( C `  A
)
Assertion
Ref Expression
algcvg  |-  ( A  e.  S  ->  ( C `  ( R `  N ) )  =  0 )
Distinct variable groups:    z, C    z, F    z, R    z, S
Allowed substitution hints:    A( z)    N( z)

Proof of Theorem algcvg
Dummy variable  k is distinct from all other variables.
StepHypRef Expression
1 nn0uz 10900 . . . 4  |-  NN0  =  ( ZZ>= `  0 )
2 algcvg.2 . . . 4  |-  R  =  seq 0 ( ( F  o.  1st ) ,  ( NN0  X.  { A } ) )
3 0zd 10663 . . . 4  |-  ( A  e.  S  ->  0  e.  ZZ )
4 id 22 . . . 4  |-  ( A  e.  S  ->  A  e.  S )
5 algcvg.1 . . . . 5  |-  F : S
--> S
65a1i 11 . . . 4  |-  ( A  e.  S  ->  F : S --> S )
71, 2, 3, 4, 6algrf 13753 . . 3  |-  ( A  e.  S  ->  R : NN0 --> S )
8 algcvg.5 . . . 4  |-  N  =  ( C `  A
)
9 algcvg.3 . . . . 5  |-  C : S
--> NN0
109ffvelrni 5847 . . . 4  |-  ( A  e.  S  ->  ( C `  A )  e.  NN0 )
118, 10syl5eqel 2527 . . 3  |-  ( A  e.  S  ->  N  e.  NN0 )
12 fvco3 5773 . . 3  |-  ( ( R : NN0 --> S  /\  N  e.  NN0 )  -> 
( ( C  o.  R ) `  N
)  =  ( C `
 ( R `  N ) ) )
137, 11, 12syl2anc 661 . 2  |-  ( A  e.  S  ->  (
( C  o.  R
) `  N )  =  ( C `  ( R `  N ) ) )
14 fco 5573 . . . 4  |-  ( ( C : S --> NN0  /\  R : NN0 --> S )  ->  ( C  o.  R ) : NN0 --> NN0 )
159, 7, 14sylancr 663 . . 3  |-  ( A  e.  S  ->  ( C  o.  R ) : NN0 --> NN0 )
16 0nn0 10599 . . . . . 6  |-  0  e.  NN0
17 fvco3 5773 . . . . . 6  |-  ( ( R : NN0 --> S  /\  0  e.  NN0 )  -> 
( ( C  o.  R ) `  0
)  =  ( C `
 ( R ` 
0 ) ) )
187, 16, 17sylancl 662 . . . . 5  |-  ( A  e.  S  ->  (
( C  o.  R
) `  0 )  =  ( C `  ( R `  0 ) ) )
191, 2, 3, 4algr0 13752 . . . . . 6  |-  ( A  e.  S  ->  ( R `  0 )  =  A )
2019fveq2d 5700 . . . . 5  |-  ( A  e.  S  ->  ( C `  ( R `  0 ) )  =  ( C `  A ) )
2118, 20eqtrd 2475 . . . 4  |-  ( A  e.  S  ->  (
( C  o.  R
) `  0 )  =  ( C `  A ) )
2221, 8syl6reqr 2494 . . 3  |-  ( A  e.  S  ->  N  =  ( ( C  o.  R ) ` 
0 ) )
237ffvelrnda 5848 . . . . 5  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( R `  k
)  e.  S )
24 fveq2 5696 . . . . . . . . 9  |-  ( z  =  ( R `  k )  ->  ( F `  z )  =  ( F `  ( R `  k ) ) )
2524fveq2d 5700 . . . . . . . 8  |-  ( z  =  ( R `  k )  ->  ( C `  ( F `  z ) )  =  ( C `  ( F `  ( R `  k ) ) ) )
2625neeq1d 2626 . . . . . . 7  |-  ( z  =  ( R `  k )  ->  (
( C `  ( F `  z )
)  =/=  0  <->  ( C `  ( F `  ( R `  k
) ) )  =/=  0 ) )
27 fveq2 5696 . . . . . . . 8  |-  ( z  =  ( R `  k )  ->  ( C `  z )  =  ( C `  ( R `  k ) ) )
2825, 27breq12d 4310 . . . . . . 7  |-  ( z  =  ( R `  k )  ->  (
( C `  ( F `  z )
)  <  ( C `  z )  <->  ( C `  ( F `  ( R `  k )
) )  <  ( C `  ( R `  k ) ) ) )
2926, 28imbi12d 320 . . . . . 6  |-  ( z  =  ( R `  k )  ->  (
( ( C `  ( F `  z ) )  =/=  0  -> 
( C `  ( F `  z )
)  <  ( C `  z ) )  <->  ( ( C `  ( F `  ( R `  k
) ) )  =/=  0  ->  ( C `  ( F `  ( R `  k )
) )  <  ( C `  ( R `  k ) ) ) ) )
30 algcvg.4 . . . . . 6  |-  ( z  e.  S  ->  (
( C `  ( F `  z )
)  =/=  0  -> 
( C `  ( F `  z )
)  <  ( C `  z ) ) )
3129, 30vtoclga 3041 . . . . 5  |-  ( ( R `  k )  e.  S  ->  (
( C `  ( F `  ( R `  k ) ) )  =/=  0  ->  ( C `  ( F `  ( R `  k
) ) )  < 
( C `  ( R `  k )
) ) )
3223, 31syl 16 . . . 4  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( ( C `  ( F `  ( R `
 k ) ) )  =/=  0  -> 
( C `  ( F `  ( R `  k ) ) )  <  ( C `  ( R `  k ) ) ) )
33 peano2nn0 10625 . . . . . . 7  |-  ( k  e.  NN0  ->  ( k  +  1 )  e. 
NN0 )
34 fvco3 5773 . . . . . . 7  |-  ( ( R : NN0 --> S  /\  ( k  +  1 )  e.  NN0 )  ->  ( ( C  o.  R ) `  (
k  +  1 ) )  =  ( C `
 ( R `  ( k  +  1 ) ) ) )
357, 33, 34syl2an 477 . . . . . 6  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( ( C  o.  R ) `  (
k  +  1 ) )  =  ( C `
 ( R `  ( k  +  1 ) ) ) )
361, 2, 3, 4, 6algrp1 13754 . . . . . . 7  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( R `  (
k  +  1 ) )  =  ( F `
 ( R `  k ) ) )
3736fveq2d 5700 . . . . . 6  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( C `  ( R `  ( k  +  1 ) ) )  =  ( C `
 ( F `  ( R `  k ) ) ) )
3835, 37eqtrd 2475 . . . . 5  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( ( C  o.  R ) `  (
k  +  1 ) )  =  ( C `
 ( F `  ( R `  k ) ) ) )
3938neeq1d 2626 . . . 4  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( ( ( C  o.  R ) `  ( k  +  1 ) )  =/=  0  <->  ( C `  ( F `
 ( R `  k ) ) )  =/=  0 ) )
40 fvco3 5773 . . . . . 6  |-  ( ( R : NN0 --> S  /\  k  e.  NN0 )  -> 
( ( C  o.  R ) `  k
)  =  ( C `
 ( R `  k ) ) )
417, 40sylan 471 . . . . 5  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( ( C  o.  R ) `  k
)  =  ( C `
 ( R `  k ) ) )
4238, 41breq12d 4310 . . . 4  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( ( ( C  o.  R ) `  ( k  +  1 ) )  <  (
( C  o.  R
) `  k )  <->  ( C `  ( F `
 ( R `  k ) ) )  <  ( C `  ( R `  k ) ) ) )
4332, 39, 423imtr4d 268 . . 3  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( ( ( C  o.  R ) `  ( k  +  1 ) )  =/=  0  ->  ( ( C  o.  R ) `  (
k  +  1 ) )  <  ( ( C  o.  R ) `
 k ) ) )
4415, 22, 43nn0seqcvgd 13750 . 2  |-  ( A  e.  S  ->  (
( C  o.  R
) `  N )  =  0 )
4513, 44eqtr3d 2477 1  |-  ( A  e.  S  ->  ( C `  ( R `  N ) )  =  0 )
Colors of variables: wff setvar class
Syntax hints:    -> wi 4    /\ wa 369    = wceq 1369    e. wcel 1756    =/= wne 2611   {csn 3882   class class class wbr 4297    X. cxp 4843    o. ccom 4849   -->wf 5419   ` cfv 5423  (class class class)co 6096   1stc1st 6580   0cc0 9287   1c1 9288    + caddc 9290    < clt 9423   NN0cn0 10584    seqcseq 11811
This theorem was proved from axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1591  ax-4 1602  ax-5 1670  ax-6 1708  ax-7 1728  ax-8 1758  ax-9 1760  ax-10 1775  ax-11 1780  ax-12 1792  ax-13 1943  ax-ext 2423  ax-sep 4418  ax-nul 4426  ax-pow 4475  ax-pr 4536  ax-un 6377  ax-cnex 9343  ax-resscn 9344  ax-1cn 9345  ax-icn 9346  ax-addcl 9347  ax-addrcl 9348  ax-mulcl 9349  ax-mulrcl 9350  ax-mulcom 9351  ax-addass 9352  ax-mulass 9353  ax-distr 9354  ax-i2m1 9355  ax-1ne0 9356  ax-1rid 9357  ax-rnegex 9358  ax-rrecex 9359  ax-cnre 9360  ax-pre-lttri 9361  ax-pre-lttrn 9362  ax-pre-ltadd 9363  ax-pre-mulgt0 9364
This theorem depends on definitions:  df-bi 185  df-or 370  df-an 371  df-3or 966  df-3an 967  df-tru 1372  df-ex 1587  df-nf 1590  df-sb 1701  df-eu 2257  df-mo 2258  df-clab 2430  df-cleq 2436  df-clel 2439  df-nfc 2573  df-ne 2613  df-nel 2614  df-ral 2725  df-rex 2726  df-reu 2727  df-rab 2729  df-v 2979  df-sbc 3192  df-csb 3294  df-dif 3336  df-un 3338  df-in 3340  df-ss 3347  df-pss 3349  df-nul 3643  df-if 3797  df-pw 3867  df-sn 3883  df-pr 3885  df-tp 3887  df-op 3889  df-uni 4097  df-iun 4178  df-br 4298  df-opab 4356  df-mpt 4357  df-tr 4391  df-eprel 4637  df-id 4641  df-po 4646  df-so 4647  df-fr 4684  df-we 4686  df-ord 4727  df-on 4728  df-lim 4729  df-suc 4730  df-xp 4851  df-rel 4852  df-cnv 4853  df-co 4854  df-dm 4855  df-rn 4856  df-res 4857  df-ima 4858  df-iota 5386  df-fun 5425  df-fn 5426  df-f 5427  df-f1 5428  df-fo 5429  df-f1o 5430  df-fv 5431  df-riota 6057  df-ov 6099  df-oprab 6100  df-mpt2 6101  df-om 6482  df-1st 6582  df-2nd 6583  df-recs 6837  df-rdg 6871  df-er 7106  df-en 7316  df-dom 7317  df-sdom 7318  df-pnf 9425  df-mnf 9426  df-xr 9427  df-ltxr 9428  df-le 9429  df-sub 9602  df-neg 9603  df-nn 10328  df-n0 10585  df-z 10652  df-uz 10867  df-fz 11443  df-seq 11812
This theorem is referenced by:  algcvga  13759
  Copyright terms: Public domain W3C validator