Users' Mathboxes Mathbox for Alexander van der Vekens < Previous   Next >
Nearby theorems
Mirrors  >  Home  >  MPE Home  >  Th. List  >   Mathboxes  >  swrdccat3a Structured version   Unicode version

Theorem swrdccat3a 28251
Description: A prefix of a concatenation is either a prefix of the first concatenated word or a concatenation of the first word with a prefix of the second word. (Contributed by Alexander van der Vekens, 31-Mar-2018.) (Revised by Alexander van der Vekens, 29-May-2018.)
Hypothesis
Ref Expression
swrdccatin12.l  |-  L  =  ( # `  A
)
Assertion
Ref Expression
swrdccat3a  |-  ( ( A  e. Word  V  /\  B  e. Word  V )  ->  ( N  e.  ( 0 ... ( L  +  ( # `  B
) ) )  -> 
( ( A concat  B
) substr  <. 0 ,  N >. )  =  if ( N  <_  L , 
( A substr  <. 0 ,  N >. ) ,  ( A concat  ( B substr  <. 0 ,  ( N  -  L ) >. )
) ) ) )

Proof of Theorem swrdccat3a
StepHypRef Expression
1 elfznn0 11088 . . . . . 6  |-  ( N  e.  ( 0 ... ( L  +  (
# `  B )
) )  ->  N  e.  NN0 )
2 0elfz 28134 . . . . . 6  |-  ( N  e.  NN0  ->  0  e.  ( 0 ... N
) )
31, 2syl 16 . . . . 5  |-  ( N  e.  ( 0 ... ( L  +  (
# `  B )
) )  ->  0  e.  ( 0 ... N
) )
43ancri 537 . . . 4  |-  ( N  e.  ( 0 ... ( L  +  (
# `  B )
) )  ->  (
0  e.  ( 0 ... N )  /\  N  e.  ( 0 ... ( L  +  ( # `  B ) ) ) ) )
5 swrdccatin12.l . . . . . 6  |-  L  =  ( # `  A
)
65swrdccat3 28249 . . . . 5  |-  ( ( A  e. Word  V  /\  B  e. Word  V )  ->  ( ( 0  e.  ( 0 ... N
)  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  ->  ( ( A concat  B ) substr  <. 0 ,  N >. )  =  if ( N  <_  L ,  ( A substr  <. 0 ,  N >. ) ,  if ( L  <_  0 ,  ( B substr  <. (
0  -  L ) ,  ( N  -  L ) >. ) ,  ( ( A substr  <. 0 ,  L >. ) concat 
( B substr  <. 0 ,  ( N  -  L
) >. ) ) ) ) ) )
76imp 420 . . . 4  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  ( 0  e.  ( 0 ... N
)  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) ) )  ->  ( ( A concat  B ) substr  <. 0 ,  N >. )  =  if ( N  <_  L ,  ( A substr  <. 0 ,  N >. ) ,  if ( L  <_  0 ,  ( B substr  <. (
0  -  L ) ,  ( N  -  L ) >. ) ,  ( ( A substr  <. 0 ,  L >. ) concat 
( B substr  <. 0 ,  ( N  -  L
) >. ) ) ) ) )
84, 7sylan2 462 . . 3  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  ->  ( ( A concat  B ) substr  <. 0 ,  N >. )  =  if ( N  <_  L ,  ( A substr  <. 0 ,  N >. ) ,  if ( L  <_  0 ,  ( B substr  <. (
0  -  L ) ,  ( N  -  L ) >. ) ,  ( ( A substr  <. 0 ,  L >. ) concat 
( B substr  <. 0 ,  ( N  -  L
) >. ) ) ) ) )
9 iftrue 3747 . . . . 5  |-  ( N  <_  L  ->  if ( N  <_  L , 
( A substr  <. 0 ,  N >. ) ,  ( A concat  ( B substr  <. 0 ,  ( N  -  L ) >. )
) )  =  ( A substr  <. 0 ,  N >. ) )
109adantl 454 . . . 4  |-  ( ( ( ( A  e. Word  V  /\  B  e. Word  V
)  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  /\  N  <_  L
)  ->  if ( N  <_  L ,  ( A substr  <. 0 ,  N >. ) ,  ( A concat 
( B substr  <. 0 ,  ( N  -  L
) >. ) ) )  =  ( A substr  <. 0 ,  N >. ) )
11 iffalse 3748 . . . . . 6  |-  ( -.  N  <_  L  ->  if ( N  <_  L ,  ( A substr  <. 0 ,  N >. ) ,  ( A concat  ( B substr  <. 0 ,  ( N  -  L ) >. )
) )  =  ( A concat  ( B substr  <. 0 ,  ( N  -  L ) >. )
) )
12113ad2ant2 980 . . . . 5  |-  ( ( ( ( A  e. Word  V  /\  B  e. Word  V
)  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  /\  -.  N  <_  L  /\  L  <_  0
)  ->  if ( N  <_  L ,  ( A substr  <. 0 ,  N >. ) ,  ( A concat 
( B substr  <. 0 ,  ( N  -  L
) >. ) ) )  =  ( A concat  ( B substr  <. 0 ,  ( N  -  L )
>. ) ) )
13 lencl 11740 . . . . . . . . . . . . 13  |-  ( A  e. Word  V  ->  ( # `
 A )  e. 
NN0 )
145, 13syl5eqel 2522 . . . . . . . . . . . 12  |-  ( A  e. Word  V  ->  L  e.  NN0 )
15 nn0le0eq0 10255 . . . . . . . . . . . 12  |-  ( L  e.  NN0  ->  ( L  <_  0  <->  L  = 
0 ) )
1614, 15syl 16 . . . . . . . . . . 11  |-  ( A  e. Word  V  ->  ( L  <_  0  <->  L  = 
0 ) )
1716biimpd 200 . . . . . . . . . 10  |-  ( A  e. Word  V  ->  ( L  <_  0  ->  L  =  0 ) )
1817adantr 453 . . . . . . . . 9  |-  ( ( A  e. Word  V  /\  B  e. Word  V )  ->  ( L  <_  0  ->  L  =  0 ) )
195eqeq1i 2445 . . . . . . . . . . . . . . . 16  |-  ( L  =  0  <->  ( # `  A
)  =  0 )
2019biimpi 188 . . . . . . . . . . . . . . 15  |-  ( L  =  0  ->  ( # `
 A )  =  0 )
21 hasheq0 11649 . . . . . . . . . . . . . . 15  |-  ( A  e. Word  V  ->  (
( # `  A )  =  0  <->  A  =  (/) ) )
2220, 21syl5ib 212 . . . . . . . . . . . . . 14  |-  ( A  e. Word  V  ->  ( L  =  0  ->  A  =  (/) ) )
2322adantr 453 . . . . . . . . . . . . 13  |-  ( ( A  e. Word  V  /\  B  e. Word  V )  ->  ( L  =  0  ->  A  =  (/) ) )
2423imp 420 . . . . . . . . . . . 12  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  L  =  0 )  ->  A  =  (/) )
25 0cn 9089 . . . . . . . . . . . . . . . . 17  |-  0  e.  CC
2625subidi 9376 . . . . . . . . . . . . . . . 16  |-  ( 0  -  0 )  =  0
27 oveq2 6092 . . . . . . . . . . . . . . . . 17  |-  ( 0  =  L  ->  (
0  -  0 )  =  ( 0  -  L ) )
2827eqcoms 2441 . . . . . . . . . . . . . . . 16  |-  ( L  =  0  ->  (
0  -  0 )  =  ( 0  -  L ) )
2926, 28syl5eqr 2484 . . . . . . . . . . . . . . 15  |-  ( L  =  0  ->  0  =  ( 0  -  L ) )
3029adantl 454 . . . . . . . . . . . . . 14  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  L  =  0 )  ->  0  =  ( 0  -  L
) )
3130opeq1d 3992 . . . . . . . . . . . . 13  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  L  =  0 )  ->  <. 0 ,  ( N  -  L
) >.  =  <. (
0  -  L ) ,  ( N  -  L ) >. )
3231oveq2d 6100 . . . . . . . . . . . 12  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  L  =  0 )  ->  ( B substr  <.
0 ,  ( N  -  L ) >.
)  =  ( B substr  <. ( 0  -  L
) ,  ( N  -  L ) >.
) )
3324, 32oveq12d 6102 . . . . . . . . . . 11  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  L  =  0 )  ->  ( A concat  ( B substr  <. 0 ,  ( N  -  L )
>. ) )  =  (
(/) concat  ( B substr  <. (
0  -  L ) ,  ( N  -  L ) >. )
) )
34 swrdcl 11771 . . . . . . . . . . . . . 14  |-  ( B  e. Word  V  ->  ( B substr  <. ( 0  -  L ) ,  ( N  -  L )
>. )  e. Word  V )
35 ccatlid 11753 . . . . . . . . . . . . . 14  |-  ( ( B substr  <. ( 0  -  L ) ,  ( N  -  L )
>. )  e. Word  V  -> 
( (/) concat  ( B substr  <. (
0  -  L ) ,  ( N  -  L ) >. )
)  =  ( B substr  <. ( 0  -  L
) ,  ( N  -  L ) >.
) )
3634, 35syl 16 . . . . . . . . . . . . 13  |-  ( B  e. Word  V  ->  ( (/) concat  ( B substr  <. ( 0  -  L ) ,  ( N  -  L
) >. ) )  =  ( B substr  <. (
0  -  L ) ,  ( N  -  L ) >. )
)
3736adantl 454 . . . . . . . . . . . 12  |-  ( ( A  e. Word  V  /\  B  e. Word  V )  ->  ( (/) concat  ( B substr  <. (
0  -  L ) ,  ( N  -  L ) >. )
)  =  ( B substr  <. ( 0  -  L
) ,  ( N  -  L ) >.
) )
3837adantr 453 . . . . . . . . . . 11  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  L  =  0 )  ->  ( (/) concat  ( B substr  <. ( 0  -  L
) ,  ( N  -  L ) >.
) )  =  ( B substr  <. ( 0  -  L ) ,  ( N  -  L )
>. ) )
3933, 38eqtrd 2470 . . . . . . . . . 10  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  L  =  0 )  ->  ( A concat  ( B substr  <. 0 ,  ( N  -  L )
>. ) )  =  ( B substr  <. ( 0  -  L ) ,  ( N  -  L )
>. ) )
4039ex 425 . . . . . . . . 9  |-  ( ( A  e. Word  V  /\  B  e. Word  V )  ->  ( L  =  0  ->  ( A concat  ( B substr  <. 0 ,  ( N  -  L )
>. ) )  =  ( B substr  <. ( 0  -  L ) ,  ( N  -  L )
>. ) ) )
4118, 40syld 43 . . . . . . . 8  |-  ( ( A  e. Word  V  /\  B  e. Word  V )  ->  ( L  <_  0  ->  ( A concat  ( B substr  <. 0 ,  ( N  -  L ) >.
) )  =  ( B substr  <. ( 0  -  L ) ,  ( N  -  L )
>. ) ) )
4241adantr 453 . . . . . . 7  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  ->  ( L  <_ 
0  ->  ( A concat  ( B substr  <. 0 ,  ( N  -  L )
>. ) )  =  ( B substr  <. ( 0  -  L ) ,  ( N  -  L )
>. ) ) )
4342imp 420 . . . . . 6  |-  ( ( ( ( A  e. Word  V  /\  B  e. Word  V
)  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  /\  L  <_  0
)  ->  ( A concat  ( B substr  <. 0 ,  ( N  -  L )
>. ) )  =  ( B substr  <. ( 0  -  L ) ,  ( N  -  L )
>. ) )
44433adant2 977 . . . . 5  |-  ( ( ( ( A  e. Word  V  /\  B  e. Word  V
)  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  /\  -.  N  <_  L  /\  L  <_  0
)  ->  ( A concat  ( B substr  <. 0 ,  ( N  -  L )
>. ) )  =  ( B substr  <. ( 0  -  L ) ,  ( N  -  L )
>. ) )
4512, 44eqtrd 2470 . . . 4  |-  ( ( ( ( A  e. Word  V  /\  B  e. Word  V
)  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  /\  -.  N  <_  L  /\  L  <_  0
)  ->  if ( N  <_  L ,  ( A substr  <. 0 ,  N >. ) ,  ( A concat 
( B substr  <. 0 ,  ( N  -  L
) >. ) ) )  =  ( B substr  <. (
0  -  L ) ,  ( N  -  L ) >. )
)
46113ad2ant2 980 . . . . 5  |-  ( ( ( ( A  e. Word  V  /\  B  e. Word  V
)  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  /\  -.  N  <_  L  /\  -.  L  <_ 
0 )  ->  if ( N  <_  L , 
( A substr  <. 0 ,  N >. ) ,  ( A concat  ( B substr  <. 0 ,  ( N  -  L ) >. )
) )  =  ( A concat  ( B substr  <. 0 ,  ( N  -  L ) >. )
) )
475opeq2i 3990 . . . . . . . . . . 11  |-  <. 0 ,  L >.  =  <. 0 ,  ( # `  A
) >.
4847oveq2i 6095 . . . . . . . . . 10  |-  ( A substr  <. 0 ,  L >. )  =  ( A substr  <. 0 ,  ( # `  A
) >. )
49 swrdid 11777 . . . . . . . . . 10  |-  ( A  e. Word  V  ->  ( A substr  <. 0 ,  (
# `  A ) >. )  =  A )
5048, 49syl5req 2483 . . . . . . . . 9  |-  ( A  e. Word  V  ->  A  =  ( A substr  <. 0 ,  L >. ) )
5150adantr 453 . . . . . . . 8  |-  ( ( A  e. Word  V  /\  B  e. Word  V )  ->  A  =  ( A substr  <. 0 ,  L >. ) )
5251adantr 453 . . . . . . 7  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  ->  A  =  ( A substr  <. 0 ,  L >. ) )
53523ad2ant1 979 . . . . . 6  |-  ( ( ( ( A  e. Word  V  /\  B  e. Word  V
)  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  /\  -.  N  <_  L  /\  -.  L  <_ 
0 )  ->  A  =  ( A substr  <. 0 ,  L >. ) )
5453oveq1d 6099 . . . . 5  |-  ( ( ( ( A  e. Word  V  /\  B  e. Word  V
)  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  /\  -.  N  <_  L  /\  -.  L  <_ 
0 )  ->  ( A concat  ( B substr  <. 0 ,  ( N  -  L ) >. )
)  =  ( ( A substr  <. 0 ,  L >. ) concat  ( B substr  <. 0 ,  ( N  -  L ) >. )
) )
5546, 54eqtrd 2470 . . . 4  |-  ( ( ( ( A  e. Word  V  /\  B  e. Word  V
)  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  /\  -.  N  <_  L  /\  -.  L  <_ 
0 )  ->  if ( N  <_  L , 
( A substr  <. 0 ,  N >. ) ,  ( A concat  ( B substr  <. 0 ,  ( N  -  L ) >. )
) )  =  ( ( A substr  <. 0 ,  L >. ) concat  ( B substr  <.
0 ,  ( N  -  L ) >.
) ) )
5610, 45, 552if2 28067 . . 3  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  ->  if ( N  <_  L ,  ( A substr  <. 0 ,  N >. ) ,  ( A concat 
( B substr  <. 0 ,  ( N  -  L
) >. ) ) )  =  if ( N  <_  L ,  ( A substr  <. 0 ,  N >. ) ,  if ( L  <_  0 , 
( B substr  <. ( 0  -  L ) ,  ( N  -  L
) >. ) ,  ( ( A substr  <. 0 ,  L >. ) concat  ( B substr  <.
0 ,  ( N  -  L ) >.
) ) ) ) )
578, 56eqtr4d 2473 . 2  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  ->  ( ( A concat  B ) substr  <. 0 ,  N >. )  =  if ( N  <_  L ,  ( A substr  <. 0 ,  N >. ) ,  ( A concat  ( B substr  <. 0 ,  ( N  -  L ) >. )
) ) )
5857ex 425 1  |-  ( ( A  e. Word  V  /\  B  e. Word  V )  ->  ( N  e.  ( 0 ... ( L  +  ( # `  B
) ) )  -> 
( ( A concat  B
) substr  <. 0 ,  N >. )  =  if ( N  <_  L , 
( A substr  <. 0 ,  N >. ) ,  ( A concat  ( B substr  <. 0 ,  ( N  -  L ) >. )
) ) ) )
Colors of variables: wff set class
Syntax hints:   -. wn 3    -> wi 4    <-> wb 178    /\ wa 360    /\ w3a 937    = wceq 1653    e. wcel 1726   (/)c0 3630   ifcif 3741   <.cop 3819   class class class wbr 4215   ` cfv 5457  (class class class)co 6084   0cc0 8995    + caddc 8998    <_ cle 9126    - cmin 9296   NN0cn0 10226   ...cfz 11048   #chash 11623  Word cword 11722   concat cconcat 11723   substr csubstr 11725
This theorem is referenced by:  2cshw1lem2  28283
This theorem was proved from axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1556  ax-5 1567  ax-17 1627  ax-9 1667  ax-8 1688  ax-13 1728  ax-14 1730  ax-6 1745  ax-7 1750  ax-11 1762  ax-12 1951  ax-ext 2419  ax-rep 4323  ax-sep 4333  ax-nul 4341  ax-pow 4380  ax-pr 4406  ax-un 4704  ax-cnex 9051  ax-resscn 9052  ax-1cn 9053  ax-icn 9054  ax-addcl 9055  ax-addrcl 9056  ax-mulcl 9057  ax-mulrcl 9058  ax-mulcom 9059  ax-addass 9060  ax-mulass 9061  ax-distr 9062  ax-i2m1 9063  ax-1ne0 9064  ax-1rid 9065  ax-rnegex 9066  ax-rrecex 9067  ax-cnre 9068  ax-pre-lttri 9069  ax-pre-lttrn 9070  ax-pre-ltadd 9071  ax-pre-mulgt0 9072
This theorem depends on definitions:  df-bi 179  df-or 361  df-an 362  df-3or 938  df-3an 939  df-tru 1329  df-ex 1552  df-nf 1555  df-sb 1660  df-eu 2287  df-mo 2288  df-clab 2425  df-cleq 2431  df-clel 2434  df-nfc 2563  df-ne 2603  df-nel 2604  df-ral 2712  df-rex 2713  df-reu 2714  df-rab 2716  df-v 2960  df-sbc 3164  df-csb 3254  df-dif 3325  df-un 3327  df-in 3329  df-ss 3336  df-pss 3338  df-nul 3631  df-if 3742  df-pw 3803  df-sn 3822  df-pr 3823  df-tp 3824  df-op 3825  df-uni 4018  df-int 4053  df-iun 4097  df-br 4216  df-opab 4270  df-mpt 4271  df-tr 4306  df-eprel 4497  df-id 4501  df-po 4506  df-so 4507  df-fr 4544  df-we 4546  df-ord 4587  df-on 4588  df-lim 4589  df-suc 4590  df-om 4849  df-xp 4887  df-rel 4888  df-cnv 4889  df-co 4890  df-dm 4891  df-rn 4892  df-res 4893  df-ima 4894  df-iota 5421  df-fun 5459  df-fn 5460  df-f 5461  df-f1 5462  df-fo 5463  df-f1o 5464  df-fv 5465  df-ov 6087  df-oprab 6088  df-mpt2 6089  df-1st 6352  df-2nd 6353  df-riota 6552  df-recs 6636  df-rdg 6671  df-1o 6727  df-oadd 6731  df-er 6908  df-en 7113  df-dom 7114  df-sdom 7115  df-fin 7116  df-card 7831  df-pnf 9127  df-mnf 9128  df-xr 9129  df-ltxr 9130  df-le 9131  df-sub 9298  df-neg 9299  df-nn 10006  df-n0 10227  df-z 10288  df-uz 10494  df-fz 11049  df-fzo 11141  df-hash 11624  df-word 11728  df-concat 11729  df-substr 11731
  Copyright terms: Public domain W3C validator