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

Theorem algcvg 13022
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 10476 . . . 4  |-  NN0  =  ( ZZ>= `  0 )
2 algcvg.2 . . . 4  |-  R  =  seq  0 ( ( F  o.  1st ) ,  ( NN0  X.  { A } ) )
3 0z 10249 . . . . 5  |-  0  e.  ZZ
43a1i 11 . . . 4  |-  ( A  e.  S  ->  0  e.  ZZ )
5 id 20 . . . 4  |-  ( A  e.  S  ->  A  e.  S )
6 algcvg.1 . . . . 5  |-  F : S
--> S
76a1i 11 . . . 4  |-  ( A  e.  S  ->  F : S --> S )
81, 2, 4, 5, 7algrf 13019 . . 3  |-  ( A  e.  S  ->  R : NN0 --> S )
9 algcvg.5 . . . 4  |-  N  =  ( C `  A
)
10 algcvg.3 . . . . 5  |-  C : S
--> NN0
1110ffvelrni 5828 . . . 4  |-  ( A  e.  S  ->  ( C `  A )  e.  NN0 )
129, 11syl5eqel 2488 . . 3  |-  ( A  e.  S  ->  N  e.  NN0 )
13 fvco3 5759 . . 3  |-  ( ( R : NN0 --> S  /\  N  e.  NN0 )  -> 
( ( C  o.  R ) `  N
)  =  ( C `
 ( R `  N ) ) )
148, 12, 13syl2anc 643 . 2  |-  ( A  e.  S  ->  (
( C  o.  R
) `  N )  =  ( C `  ( R `  N ) ) )
15 fco 5559 . . . 4  |-  ( ( C : S --> NN0  /\  R : NN0 --> S )  ->  ( C  o.  R ) : NN0 --> NN0 )
1610, 8, 15sylancr 645 . . 3  |-  ( A  e.  S  ->  ( C  o.  R ) : NN0 --> NN0 )
17 0nn0 10192 . . . . . 6  |-  0  e.  NN0
18 fvco3 5759 . . . . . 6  |-  ( ( R : NN0 --> S  /\  0  e.  NN0 )  -> 
( ( C  o.  R ) `  0
)  =  ( C `
 ( R ` 
0 ) ) )
198, 17, 18sylancl 644 . . . . 5  |-  ( A  e.  S  ->  (
( C  o.  R
) `  0 )  =  ( C `  ( R `  0 ) ) )
201, 2, 4, 5algr0 13018 . . . . . 6  |-  ( A  e.  S  ->  ( R `  0 )  =  A )
2120fveq2d 5691 . . . . 5  |-  ( A  e.  S  ->  ( C `  ( R `  0 ) )  =  ( C `  A ) )
2219, 21eqtrd 2436 . . . 4  |-  ( A  e.  S  ->  (
( C  o.  R
) `  0 )  =  ( C `  A ) )
2322, 9syl6reqr 2455 . . 3  |-  ( A  e.  S  ->  N  =  ( ( C  o.  R ) ` 
0 ) )
248ffvelrnda 5829 . . . . 5  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( R `  k
)  e.  S )
25 fveq2 5687 . . . . . . . . 9  |-  ( z  =  ( R `  k )  ->  ( F `  z )  =  ( F `  ( R `  k ) ) )
2625fveq2d 5691 . . . . . . . 8  |-  ( z  =  ( R `  k )  ->  ( C `  ( F `  z ) )  =  ( C `  ( F `  ( R `  k ) ) ) )
2726neeq1d 2580 . . . . . . 7  |-  ( z  =  ( R `  k )  ->  (
( C `  ( F `  z )
)  =/=  0  <->  ( C `  ( F `  ( R `  k
) ) )  =/=  0 ) )
28 fveq2 5687 . . . . . . . 8  |-  ( z  =  ( R `  k )  ->  ( C `  z )  =  ( C `  ( R `  k ) ) )
2926, 28breq12d 4185 . . . . . . 7  |-  ( z  =  ( R `  k )  ->  (
( C `  ( F `  z )
)  <  ( C `  z )  <->  ( C `  ( F `  ( R `  k )
) )  <  ( C `  ( R `  k ) ) ) )
3027, 29imbi12d 312 . . . . . 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 ) ) ) ) )
31 algcvg.4 . . . . . 6  |-  ( z  e.  S  ->  (
( C `  ( F `  z )
)  =/=  0  -> 
( C `  ( F `  z )
)  <  ( C `  z ) ) )
3230, 31vtoclga 2977 . . . . 5  |-  ( ( R `  k )  e.  S  ->  (
( C `  ( F `  ( R `  k ) ) )  =/=  0  ->  ( C `  ( F `  ( R `  k
) ) )  < 
( C `  ( R `  k )
) ) )
3324, 32syl 16 . . . 4  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( ( C `  ( F `  ( R `
 k ) ) )  =/=  0  -> 
( C `  ( F `  ( R `  k ) ) )  <  ( C `  ( R `  k ) ) ) )
34 peano2nn0 10216 . . . . . . 7  |-  ( k  e.  NN0  ->  ( k  +  1 )  e. 
NN0 )
35 fvco3 5759 . . . . . . 7  |-  ( ( R : NN0 --> S  /\  ( k  +  1 )  e.  NN0 )  ->  ( ( C  o.  R ) `  (
k  +  1 ) )  =  ( C `
 ( R `  ( k  +  1 ) ) ) )
368, 34, 35syl2an 464 . . . . . 6  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( ( C  o.  R ) `  (
k  +  1 ) )  =  ( C `
 ( R `  ( k  +  1 ) ) ) )
371, 2, 4, 5, 7algrp1 13020 . . . . . . 7  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( R `  (
k  +  1 ) )  =  ( F `
 ( R `  k ) ) )
3837fveq2d 5691 . . . . . 6  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( C `  ( R `  ( k  +  1 ) ) )  =  ( C `
 ( F `  ( R `  k ) ) ) )
3936, 38eqtrd 2436 . . . . 5  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( ( C  o.  R ) `  (
k  +  1 ) )  =  ( C `
 ( F `  ( R `  k ) ) ) )
4039neeq1d 2580 . . . 4  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( ( ( C  o.  R ) `  ( k  +  1 ) )  =/=  0  <->  ( C `  ( F `
 ( R `  k ) ) )  =/=  0 ) )
41 fvco3 5759 . . . . . 6  |-  ( ( R : NN0 --> S  /\  k  e.  NN0 )  -> 
( ( C  o.  R ) `  k
)  =  ( C `
 ( R `  k ) ) )
428, 41sylan 458 . . . . 5  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( ( C  o.  R ) `  k
)  =  ( C `
 ( R `  k ) ) )
4339, 42breq12d 4185 . . . 4  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( ( ( C  o.  R ) `  ( k  +  1 ) )  <  (
( C  o.  R
) `  k )  <->  ( C `  ( F `
 ( R `  k ) ) )  <  ( C `  ( R `  k ) ) ) )
4433, 40, 433imtr4d 260 . . 3  |-  ( ( A  e.  S  /\  k  e.  NN0 )  -> 
( ( ( C  o.  R ) `  ( k  +  1 ) )  =/=  0  ->  ( ( C  o.  R ) `  (
k  +  1 ) )  <  ( ( C  o.  R ) `
 k ) ) )
4516, 23, 44nn0seqcvgd 13016 . 2  |-  ( A  e.  S  ->  (
( C  o.  R
) `  N )  =  0 )
4614, 45eqtr3d 2438 1  |-  ( A  e.  S  ->  ( C `  ( R `  N ) )  =  0 )
Colors of variables: wff set class
Syntax hints:    -> wi 4    /\ wa 359    = wceq 1649    e. wcel 1721    =/= wne 2567   {csn 3774   class class class wbr 4172    X. cxp 4835    o. ccom 4841   -->wf 5409   ` cfv 5413  (class class class)co 6040   1stc1st 6306   0cc0 8946   1c1 8947    + caddc 8949    < clt 9076   NN0cn0 10177   ZZcz 10238    seq cseq 11278
This theorem is referenced by:  algcvga  13025
This theorem was proved from axioms:  ax-1 5  ax-2 6  ax-3 7  ax-mp 8  ax-gen 1552  ax-5 1563  ax-17 1623  ax-9 1662  ax-8 1683  ax-13 1723  ax-14 1725  ax-6 1740  ax-7 1745  ax-11 1757  ax-12 1946  ax-ext 2385  ax-sep 4290  ax-nul 4298  ax-pow 4337  ax-pr 4363  ax-un 4660  ax-cnex 9002  ax-resscn 9003  ax-1cn 9004  ax-icn 9005  ax-addcl 9006  ax-addrcl 9007  ax-mulcl 9008  ax-mulrcl 9009  ax-mulcom 9010  ax-addass 9011  ax-mulass 9012  ax-distr 9013  ax-i2m1 9014  ax-1ne0 9015  ax-1rid 9016  ax-rnegex 9017  ax-rrecex 9018  ax-cnre 9019  ax-pre-lttri 9020  ax-pre-lttrn 9021  ax-pre-ltadd 9022  ax-pre-mulgt0 9023
This theorem depends on definitions:  df-bi 178  df-or 360  df-an 361  df-3or 937  df-3an 938  df-tru 1325  df-ex 1548  df-nf 1551  df-sb 1656  df-eu 2258  df-mo 2259  df-clab 2391  df-cleq 2397  df-clel 2400  df-nfc 2529  df-ne 2569  df-nel 2570  df-ral 2671  df-rex 2672  df-reu 2673  df-rab 2675  df-v 2918  df-sbc 3122  df-csb 3212  df-dif 3283  df-un 3285  df-in 3287  df-ss 3294  df-pss 3296  df-nul 3589  df-if 3700  df-pw 3761  df-sn 3780  df-pr 3781  df-tp 3782  df-op 3783  df-uni 3976  df-iun 4055  df-br 4173  df-opab 4227  df-mpt 4228  df-tr 4263  df-eprel 4454  df-id 4458  df-po 4463  df-so 4464  df-fr 4501  df-we 4503  df-ord 4544  df-on 4545  df-lim 4546  df-suc 4547  df-om 4805  df-xp 4843  df-rel 4844  df-cnv 4845  df-co 4846  df-dm 4847  df-rn 4848  df-res 4849  df-ima 4850  df-iota 5377  df-fun 5415  df-fn 5416  df-f 5417  df-f1 5418  df-fo 5419  df-f1o 5420  df-fv 5421  df-ov 6043  df-oprab 6044  df-mpt2 6045  df-1st 6308  df-2nd 6309  df-riota 6508  df-recs 6592  df-rdg 6627  df-er 6864  df-en 7069  df-dom 7070  df-sdom 7071  df-pnf 9078  df-mnf 9079  df-xr 9080  df-ltxr 9081  df-le 9082  df-sub 9249  df-neg 9250  df-nn 9957  df-n0 10178  df-z 10239  df-uz 10445  df-fz 11000  df-seq 11279
  Copyright terms: Public domain W3C validator