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

Theorem algcvg 12954
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 10413 . . . 4  |-  NN0  =  ( ZZ>= `  0 )
2 algcvg.2 . . . 4  |-  R  =  seq  0 ( ( F  o.  1st ) ,  ( NN0  X.  { A } ) )
3 0z 10186 . . . . 5  |-  0  e.  ZZ
43a1i 10 . . . 4  |-  ( A  e.  S  ->  0  e.  ZZ )
5 id 19 . . . 4  |-  ( A  e.  S  ->  A  e.  S )
6 algcvg.1 . . . . 5  |-  F : S
--> S
76a1i 10 . . . 4  |-  ( A  e.  S  ->  F : S --> S )
81, 2, 4, 5, 7algrf 12951 . . 3  |-  ( A  e.  S  ->  R : NN0 --> S )
9 algcvg.5 . . . 4  |-  N  =  ( C `  A
)
10 algcvg.3 . . . . 5  |-  C : S
--> NN0
1110ffvelrni 5771 . . . 4  |-  ( A  e.  S  ->  ( C `  A )  e.  NN0 )
129, 11syl5eqel 2450 . . 3  |-  ( A  e.  S  ->  N  e.  NN0 )
13 fvco3 5703 . . 3  |-  ( ( R : NN0 --> S  /\  N  e.  NN0 )  -> 
( ( C  o.  R ) `  N
)  =  ( C `
 ( R `  N ) ) )
148, 12, 13syl2anc 642 . 2  |-  ( A  e.  S  ->  (
( C  o.  R
) `  N )  =  ( C `  ( R `  N ) ) )
15 fco 5504 . . . 4  |-  ( ( C : S --> NN0  /\  R : NN0 --> S )  ->  ( C  o.  R ) : NN0 --> NN0 )
1610, 8, 15sylancr 644 . . 3  |-  ( A  e.  S  ->  ( C  o.  R ) : NN0 --> NN0 )
17 0nn0 10129 . . . . . 6  |-  0  e.  NN0
18 fvco3 5703 . . . . . 6  |-  ( ( R : NN0 --> S  /\  0  e.  NN0 )  -> 
( ( C  o.  R ) `  0
)  =  ( C `
 ( R ` 
0 ) ) )
198, 17, 18sylancl 643 . . . . 5  |-  ( A  e.  S  ->  (
( C  o.  R
) `  0 )  =  ( C `  ( R `  0 ) ) )
201, 2, 4, 5algr0 12950 . . . . . 6  |-  ( A  e.  S  ->  ( R `  0 )  =  A )
2120fveq2d 5636 . . . . 5  |-  ( A  e.  S  ->  ( C `  ( R `  0 ) )  =  ( C `  A ) )
2219, 21eqtrd 2398 . . . 4  |-  ( A  e.  S  ->  (
( C  o.  R
) `  0 )  =  ( C `  A ) )
2322, 9syl6reqr 2417 . . 3  |-  ( A  e.  S  ->  N  =  ( ( C  o.  R ) ` 
0 ) )
24 ffvelrn 5770 . . . . . 6  |-  ( ( R : NN0 --> S  /\  k  e.  NN0 )  -> 
( R `  k
)  e.  S )
258, 24sylan 457 . . . . 5  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( R `  k
)  e.  S )
26 fveq2 5632 . . . . . . . . 9  |-  ( z  =  ( R `  k )  ->  ( F `  z )  =  ( F `  ( R `  k ) ) )
2726fveq2d 5636 . . . . . . . 8  |-  ( z  =  ( R `  k )  ->  ( C `  ( F `  z ) )  =  ( C `  ( F `  ( R `  k ) ) ) )
2827neeq1d 2542 . . . . . . 7  |-  ( z  =  ( R `  k )  ->  (
( C `  ( F `  z )
)  =/=  0  <->  ( C `  ( F `  ( R `  k
) ) )  =/=  0 ) )
29 fveq2 5632 . . . . . . . 8  |-  ( z  =  ( R `  k )  ->  ( C `  z )  =  ( C `  ( R `  k ) ) )
3027, 29breq12d 4138 . . . . . . 7  |-  ( z  =  ( R `  k )  ->  (
( C `  ( F `  z )
)  <  ( C `  z )  <->  ( C `  ( F `  ( R `  k )
) )  <  ( C `  ( R `  k ) ) ) )
3128, 30imbi12d 311 . . . . . 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 ) ) ) ) )
32 algcvg.4 . . . . . 6  |-  ( z  e.  S  ->  (
( C `  ( F `  z )
)  =/=  0  -> 
( C `  ( F `  z )
)  <  ( C `  z ) ) )
3331, 32vtoclga 2934 . . . . 5  |-  ( ( R `  k )  e.  S  ->  (
( C `  ( F `  ( R `  k ) ) )  =/=  0  ->  ( C `  ( F `  ( R `  k
) ) )  < 
( C `  ( R `  k )
) ) )
3425, 33syl 15 . . . 4  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( ( C `  ( F `  ( R `
 k ) ) )  =/=  0  -> 
( C `  ( F `  ( R `  k ) ) )  <  ( C `  ( R `  k ) ) ) )
35 peano2nn0 10153 . . . . . . 7  |-  ( k  e.  NN0  ->  ( k  +  1 )  e. 
NN0 )
36 fvco3 5703 . . . . . . 7  |-  ( ( R : NN0 --> S  /\  ( k  +  1 )  e.  NN0 )  ->  ( ( C  o.  R ) `  (
k  +  1 ) )  =  ( C `
 ( R `  ( k  +  1 ) ) ) )
378, 35, 36syl2an 463 . . . . . 6  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( ( C  o.  R ) `  (
k  +  1 ) )  =  ( C `
 ( R `  ( k  +  1 ) ) ) )
381, 2, 4, 5, 7algrp1 12952 . . . . . . 7  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( R `  (
k  +  1 ) )  =  ( F `
 ( R `  k ) ) )
3938fveq2d 5636 . . . . . 6  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( C `  ( R `  ( k  +  1 ) ) )  =  ( C `
 ( F `  ( R `  k ) ) ) )
4037, 39eqtrd 2398 . . . . 5  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( ( C  o.  R ) `  (
k  +  1 ) )  =  ( C `
 ( F `  ( R `  k ) ) ) )
4140neeq1d 2542 . . . 4  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( ( ( C  o.  R ) `  ( k  +  1 ) )  =/=  0  <->  ( C `  ( F `
 ( R `  k ) ) )  =/=  0 ) )
42 fvco3 5703 . . . . . 6  |-  ( ( R : NN0 --> S  /\  k  e.  NN0 )  -> 
( ( C  o.  R ) `  k
)  =  ( C `
 ( R `  k ) ) )
438, 42sylan 457 . . . . 5  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( ( C  o.  R ) `  k
)  =  ( C `
 ( R `  k ) ) )
4440, 43breq12d 4138 . . . 4  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( ( ( C  o.  R ) `  ( k  +  1 ) )  <  (
( C  o.  R
) `  k )  <->  ( C `  ( F `
 ( R `  k ) ) )  <  ( C `  ( R `  k ) ) ) )
4534, 41, 443imtr4d 259 . . 3  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( ( ( C  o.  R ) `  ( k  +  1 ) )  =/=  0  ->  ( ( C  o.  R ) `  (
k  +  1 ) )  <  ( ( C  o.  R ) `
 k ) ) )
4616, 23, 45nn0seqcvgd 12948 . 2  |-  ( A  e.  S  ->  (
( C  o.  R
) `  N )  =  0 )
4714, 46eqtr3d 2400 1  |-  ( A  e.  S  ->  ( C `  ( R `  N ) )  =  0 )
Colors of variables: wff set class
Syntax hints:    -> wi 4    /\ wa 358    = wceq 1647    e. wcel 1715    =/= wne 2529   {csn 3729   class class class wbr 4125    X. cxp 4790    o. ccom 4796   -->wf 5354   ` cfv 5358  (class class class)co 5981   1stc1st 6247   0cc0 8884   1c1 8885    + caddc 8887    < clt 9014   NN0cn0 10114   ZZcz 10175    seq cseq 11210
This theorem is referenced by:  algcvga  12957
This theorem was proved from axioms:  ax-1 5  ax-2 6  ax-3 7  ax-mp 8  ax-gen 1551  ax-5 1562  ax-17 1621  ax-9 1659  ax-8 1680  ax-13 1717  ax-14 1719  ax-6 1734  ax-7 1739  ax-11 1751  ax-12 1937  ax-ext 2347  ax-sep 4243  ax-nul 4251  ax-pow 4290  ax-pr 4316  ax-un 4615  ax-cnex 8940  ax-resscn 8941  ax-1cn 8942  ax-icn 8943  ax-addcl 8944  ax-addrcl 8945  ax-mulcl 8946  ax-mulrcl 8947  ax-mulcom 8948  ax-addass 8949  ax-mulass 8950  ax-distr 8951  ax-i2m1 8952  ax-1ne0 8953  ax-1rid 8954  ax-rnegex 8955  ax-rrecex 8956  ax-cnre 8957  ax-pre-lttri 8958  ax-pre-lttrn 8959  ax-pre-ltadd 8960  ax-pre-mulgt0 8961
This theorem depends on definitions:  df-bi 177  df-or 359  df-an 360  df-3or 936  df-3an 937  df-tru 1324  df-ex 1547  df-nf 1550  df-sb 1654  df-eu 2221  df-mo 2222  df-clab 2353  df-cleq 2359  df-clel 2362  df-nfc 2491  df-ne 2531  df-nel 2532  df-ral 2633  df-rex 2634  df-reu 2635  df-rab 2637  df-v 2875  df-sbc 3078  df-csb 3168  df-dif 3241  df-un 3243  df-in 3245  df-ss 3252  df-pss 3254  df-nul 3544  df-if 3655  df-pw 3716  df-sn 3735  df-pr 3736  df-tp 3737  df-op 3738  df-uni 3930  df-iun 4009  df-br 4126  df-opab 4180  df-mpt 4181  df-tr 4216  df-eprel 4408  df-id 4412  df-po 4417  df-so 4418  df-fr 4455  df-we 4457  df-ord 4498  df-on 4499  df-lim 4500  df-suc 4501  df-om 4760  df-xp 4798  df-rel 4799  df-cnv 4800  df-co 4801  df-dm 4802  df-rn 4803  df-res 4804  df-ima 4805  df-iota 5322  df-fun 5360  df-fn 5361  df-f 5362  df-f1 5363  df-fo 5364  df-f1o 5365  df-fv 5366  df-ov 5984  df-oprab 5985  df-mpt2 5986  df-1st 6249  df-2nd 6250  df-riota 6446  df-recs 6530  df-rdg 6565  df-er 6802  df-en 7007  df-dom 7008  df-sdom 7009  df-pnf 9016  df-mnf 9017  df-xr 9018  df-ltxr 9019  df-le 9020  df-sub 9186  df-neg 9187  df-nn 9894  df-n0 10115  df-z 10176  df-uz 10382  df-fz 10936  df-seq 11211
  Copyright terms: Public domain W3C validator