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

Theorem swrdccat3a 12713
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 ++  B
) substr  <. 0 ,  N >. )  =  if ( N  <_  L , 
( A substr  <. 0 ,  N >. ) ,  ( A ++  ( B substr  <. 0 ,  ( N  -  L ) >. )
) ) ) )

Proof of Theorem swrdccat3a
StepHypRef Expression
1 elfznn0 11775 . . . . . 6  |-  ( N  e.  ( 0 ... ( L  +  (
# `  B )
) )  ->  N  e.  NN0 )
2 0elfz 11777 . . . . . 6  |-  ( N  e.  NN0  ->  0  e.  ( 0 ... N
) )
31, 2syl 16 . . . . 5  |-  ( N  e.  ( 0 ... ( L  +  (
# `  B )
) )  ->  0  e.  ( 0 ... N
) )
43ancri 550 . . . 4  |-  ( N  e.  ( 0 ... ( L  +  (
# `  B )
) )  ->  (
0  e.  ( 0 ... N )  /\  N  e.  ( 0 ... ( L  +  ( # `  B ) ) ) ) )
5 swrdccatin12.l . . . . . 6  |-  L  =  ( # `  A
)
65swrdccat3 12711 . . . . 5  |-  ( ( A  e. Word  V  /\  B  e. Word  V )  ->  ( ( 0  e.  ( 0 ... N
)  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  ->  ( ( A ++  B ) substr  <. 0 ,  N >. )  =  if ( N  <_  L ,  ( A substr  <. 0 ,  N >. ) ,  if ( L  <_  0 ,  ( B substr  <. (
0  -  L ) ,  ( N  -  L ) >. ) ,  ( ( A substr  <. 0 ,  L >. ) ++  ( B substr  <. 0 ,  ( N  -  L ) >. )
) ) ) ) )
76imp 427 . . . 4  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  ( 0  e.  ( 0 ... N
)  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) ) )  ->  ( ( A ++  B ) substr  <. 0 ,  N >. )  =  if ( N  <_  L ,  ( A substr  <. 0 ,  N >. ) ,  if ( L  <_  0 ,  ( B substr  <. (
0  -  L ) ,  ( N  -  L ) >. ) ,  ( ( A substr  <. 0 ,  L >. ) ++  ( B substr  <. 0 ,  ( N  -  L ) >. )
) ) ) )
84, 7sylan2 472 . . 3  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  ->  ( ( A ++  B ) substr  <. 0 ,  N >. )  =  if ( N  <_  L ,  ( A substr  <. 0 ,  N >. ) ,  if ( L  <_  0 ,  ( B substr  <. (
0  -  L ) ,  ( N  -  L ) >. ) ,  ( ( A substr  <. 0 ,  L >. ) ++  ( B substr  <. 0 ,  ( N  -  L ) >. )
) ) ) )
9 iftrue 3935 . . . . 5  |-  ( N  <_  L  ->  if ( N  <_  L , 
( A substr  <. 0 ,  N >. ) ,  ( A ++  ( B substr  <. 0 ,  ( N  -  L ) >. )
) )  =  ( A substr  <. 0 ,  N >. ) )
109adantl 464 . . . 4  |-  ( ( ( ( A  e. Word  V  /\  B  e. Word  V
)  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  /\  N  <_  L
)  ->  if ( N  <_  L ,  ( A substr  <. 0 ,  N >. ) ,  ( A ++  ( B substr  <. 0 ,  ( N  -  L ) >. )
) )  =  ( A substr  <. 0 ,  N >. ) )
11 iffalse 3938 . . . . . 6  |-  ( -.  N  <_  L  ->  if ( N  <_  L ,  ( A substr  <. 0 ,  N >. ) ,  ( A ++  ( B substr  <. 0 ,  ( N  -  L ) >. )
) )  =  ( A ++  ( B substr  <. 0 ,  ( N  -  L ) >. )
) )
12113ad2ant2 1016 . . . . 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 ++  ( B substr  <. 0 ,  ( N  -  L ) >. )
) )  =  ( A ++  ( B substr  <. 0 ,  ( N  -  L ) >. )
) )
13 lencl 12552 . . . . . . . . . . . . 13  |-  ( A  e. Word  V  ->  ( # `
 A )  e. 
NN0 )
145, 13syl5eqel 2546 . . . . . . . . . . . 12  |-  ( A  e. Word  V  ->  L  e.  NN0 )
15 nn0le0eq0 10820 . . . . . . . . . . . 12  |-  ( L  e.  NN0  ->  ( L  <_  0  <->  L  = 
0 ) )
1614, 15syl 16 . . . . . . . . . . 11  |-  ( A  e. Word  V  ->  ( L  <_  0  <->  L  = 
0 ) )
1716biimpd 207 . . . . . . . . . 10  |-  ( A  e. Word  V  ->  ( L  <_  0  ->  L  =  0 ) )
1817adantr 463 . . . . . . . . 9  |-  ( ( A  e. Word  V  /\  B  e. Word  V )  ->  ( L  <_  0  ->  L  =  0 ) )
195eqeq1i 2461 . . . . . . . . . . . . . . . 16  |-  ( L  =  0  <->  ( # `  A
)  =  0 )
2019biimpi 194 . . . . . . . . . . . . . . 15  |-  ( L  =  0  ->  ( # `
 A )  =  0 )
21 hasheq0 12419 . . . . . . . . . . . . . . 15  |-  ( A  e. Word  V  ->  (
( # `  A )  =  0  <->  A  =  (/) ) )
2220, 21syl5ib 219 . . . . . . . . . . . . . 14  |-  ( A  e. Word  V  ->  ( L  =  0  ->  A  =  (/) ) )
2322adantr 463 . . . . . . . . . . . . 13  |-  ( ( A  e. Word  V  /\  B  e. Word  V )  ->  ( L  =  0  ->  A  =  (/) ) )
2423imp 427 . . . . . . . . . . . 12  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  L  =  0 )  ->  A  =  (/) )
25 0m0e0 10641 . . . . . . . . . . . . . . . 16  |-  ( 0  -  0 )  =  0
26 oveq2 6278 . . . . . . . . . . . . . . . . 17  |-  ( 0  =  L  ->  (
0  -  0 )  =  ( 0  -  L ) )
2726eqcoms 2466 . . . . . . . . . . . . . . . 16  |-  ( L  =  0  ->  (
0  -  0 )  =  ( 0  -  L ) )
2825, 27syl5eqr 2509 . . . . . . . . . . . . . . 15  |-  ( L  =  0  ->  0  =  ( 0  -  L ) )
2928adantl 464 . . . . . . . . . . . . . 14  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  L  =  0 )  ->  0  =  ( 0  -  L
) )
3029opeq1d 4209 . . . . . . . . . . . . 13  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  L  =  0 )  ->  <. 0 ,  ( N  -  L
) >.  =  <. (
0  -  L ) ,  ( N  -  L ) >. )
3130oveq2d 6286 . . . . . . . . . . . 12  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  L  =  0 )  ->  ( B substr  <.
0 ,  ( N  -  L ) >.
)  =  ( B substr  <. ( 0  -  L
) ,  ( N  -  L ) >.
) )
3224, 31oveq12d 6288 . . . . . . . . . . 11  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  L  =  0 )  ->  ( A ++  ( B substr  <. 0 ,  ( N  -  L
) >. ) )  =  ( (/) ++  ( B substr  <.
( 0  -  L
) ,  ( N  -  L ) >.
) ) )
33 swrdcl 12638 . . . . . . . . . . . . . 14  |-  ( B  e. Word  V  ->  ( B substr  <. ( 0  -  L ) ,  ( N  -  L )
>. )  e. Word  V )
34 ccatlid 12595 . . . . . . . . . . . . . 14  |-  ( ( B substr  <. ( 0  -  L ) ,  ( N  -  L )
>. )  e. Word  V  -> 
( (/) ++  ( B substr  <. (
0  -  L ) ,  ( N  -  L ) >. )
)  =  ( B substr  <. ( 0  -  L
) ,  ( N  -  L ) >.
) )
3533, 34syl 16 . . . . . . . . . . . . 13  |-  ( B  e. Word  V  ->  ( (/) ++ 
( B substr  <. ( 0  -  L ) ,  ( N  -  L
) >. ) )  =  ( B substr  <. (
0  -  L ) ,  ( N  -  L ) >. )
)
3635adantl 464 . . . . . . . . . . . 12  |-  ( ( A  e. Word  V  /\  B  e. Word  V )  ->  ( (/) ++  ( B substr  <.
( 0  -  L
) ,  ( N  -  L ) >.
) )  =  ( B substr  <. ( 0  -  L ) ,  ( N  -  L )
>. ) )
3736adantr 463 . . . . . . . . . . 11  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  L  =  0 )  ->  ( (/) ++  ( B substr  <. ( 0  -  L
) ,  ( N  -  L ) >.
) )  =  ( B substr  <. ( 0  -  L ) ,  ( N  -  L )
>. ) )
3832, 37eqtrd 2495 . . . . . . . . . 10  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  L  =  0 )  ->  ( A ++  ( B substr  <. 0 ,  ( N  -  L
) >. ) )  =  ( B substr  <. (
0  -  L ) ,  ( N  -  L ) >. )
)
3938ex 432 . . . . . . . . 9  |-  ( ( A  e. Word  V  /\  B  e. Word  V )  ->  ( L  =  0  ->  ( A ++  ( B substr  <. 0 ,  ( N  -  L )
>. ) )  =  ( B substr  <. ( 0  -  L ) ,  ( N  -  L )
>. ) ) )
4018, 39syld 44 . . . . . . . 8  |-  ( ( A  e. Word  V  /\  B  e. Word  V )  ->  ( L  <_  0  ->  ( A ++  ( B substr  <. 0 ,  ( N  -  L ) >.
) )  =  ( B substr  <. ( 0  -  L ) ,  ( N  -  L )
>. ) ) )
4140adantr 463 . . . . . . 7  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  ->  ( L  <_ 
0  ->  ( A ++  ( B substr  <. 0 ,  ( N  -  L
) >. ) )  =  ( B substr  <. (
0  -  L ) ,  ( N  -  L ) >. )
) )
4241imp 427 . . . . . 6  |-  ( ( ( ( A  e. Word  V  /\  B  e. Word  V
)  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  /\  L  <_  0
)  ->  ( A ++  ( B substr  <. 0 ,  ( N  -  L
) >. ) )  =  ( B substr  <. (
0  -  L ) ,  ( N  -  L ) >. )
)
43423adant2 1013 . . . . 5  |-  ( ( ( ( A  e. Word  V  /\  B  e. Word  V
)  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  /\  -.  N  <_  L  /\  L  <_  0
)  ->  ( A ++  ( B substr  <. 0 ,  ( N  -  L
) >. ) )  =  ( B substr  <. (
0  -  L ) ,  ( N  -  L ) >. )
)
4412, 43eqtrd 2495 . . . 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 ++  ( B substr  <. 0 ,  ( N  -  L ) >. )
) )  =  ( B substr  <. ( 0  -  L ) ,  ( N  -  L )
>. ) )
45113ad2ant2 1016 . . . . 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 ++  ( B substr  <. 0 ,  ( N  -  L ) >. )
) )  =  ( A ++  ( B substr  <. 0 ,  ( N  -  L ) >. )
) )
465opeq2i 4207 . . . . . . . . . . 11  |-  <. 0 ,  L >.  =  <. 0 ,  ( # `  A
) >.
4746oveq2i 6281 . . . . . . . . . 10  |-  ( A substr  <. 0 ,  L >. )  =  ( A substr  <. 0 ,  ( # `  A
) >. )
48 swrdid 12647 . . . . . . . . . 10  |-  ( A  e. Word  V  ->  ( A substr  <. 0 ,  (
# `  A ) >. )  =  A )
4947, 48syl5req 2508 . . . . . . . . 9  |-  ( A  e. Word  V  ->  A  =  ( A substr  <. 0 ,  L >. ) )
5049adantr 463 . . . . . . . 8  |-  ( ( A  e. Word  V  /\  B  e. Word  V )  ->  A  =  ( A substr  <. 0 ,  L >. ) )
5150adantr 463 . . . . . . 7  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  ->  A  =  ( A substr  <. 0 ,  L >. ) )
52513ad2ant1 1015 . . . . . 6  |-  ( ( ( ( A  e. Word  V  /\  B  e. Word  V
)  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  /\  -.  N  <_  L  /\  -.  L  <_ 
0 )  ->  A  =  ( A substr  <. 0 ,  L >. ) )
5352oveq1d 6285 . . . . 5  |-  ( ( ( ( A  e. Word  V  /\  B  e. Word  V
)  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  /\  -.  N  <_  L  /\  -.  L  <_ 
0 )  ->  ( A ++  ( B substr  <. 0 ,  ( N  -  L ) >. )
)  =  ( ( A substr  <. 0 ,  L >. ) ++  ( B substr  <. 0 ,  ( N  -  L ) >. )
) )
5445, 53eqtrd 2495 . . . 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 ++  ( B substr  <. 0 ,  ( N  -  L ) >. )
) )  =  ( ( A substr  <. 0 ,  L >. ) ++  ( B substr  <. 0 ,  ( N  -  L ) >.
) ) )
5510, 44, 542if2 3977 . . 3  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  ->  if ( N  <_  L ,  ( A substr  <. 0 ,  N >. ) ,  ( A ++  ( 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 >. ) ++  ( B substr  <. 0 ,  ( N  -  L ) >. )
) ) ) )
568, 55eqtr4d 2498 . 2  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  ->  ( ( A ++  B ) substr  <. 0 ,  N >. )  =  if ( N  <_  L ,  ( A substr  <. 0 ,  N >. ) ,  ( A ++  ( B substr  <. 0 ,  ( N  -  L ) >. )
) ) )
5756ex 432 1  |-  ( ( A  e. Word  V  /\  B  e. Word  V )  ->  ( N  e.  ( 0 ... ( L  +  ( # `  B
) ) )  -> 
( ( A ++  B
) substr  <. 0 ,  N >. )  =  if ( N  <_  L , 
( A substr  <. 0 ,  N >. ) ,  ( A ++  ( B substr  <. 0 ,  ( N  -  L ) >. )
) ) ) )
Colors of variables: wff setvar class
Syntax hints:   -. wn 3    -> wi 4    <-> wb 184    /\ wa 367    /\ w3a 971    = wceq 1398    e. wcel 1823   (/)c0 3783   ifcif 3929   <.cop 4022   class class class wbr 4439   ` cfv 5570  (class class class)co 6270   0cc0 9481    + caddc 9484    <_ cle 9618    - cmin 9796   NN0cn0 10791   ...cfz 11675   #chash 12390  Word cword 12521   ++ cconcat 12523   substr csubstr 12525
This theorem was proved from axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1623  ax-4 1636  ax-5 1709  ax-6 1752  ax-7 1795  ax-8 1825  ax-9 1827  ax-10 1842  ax-11 1847  ax-12 1859  ax-13 2004  ax-ext 2432  ax-rep 4550  ax-sep 4560  ax-nul 4568  ax-pow 4615  ax-pr 4676  ax-un 6565  ax-cnex 9537  ax-resscn 9538  ax-1cn 9539  ax-icn 9540  ax-addcl 9541  ax-addrcl 9542  ax-mulcl 9543  ax-mulrcl 9544  ax-mulcom 9545  ax-addass 9546  ax-mulass 9547  ax-distr 9548  ax-i2m1 9549  ax-1ne0 9550  ax-1rid 9551  ax-rnegex 9552  ax-rrecex 9553  ax-cnre 9554  ax-pre-lttri 9555  ax-pre-lttrn 9556  ax-pre-ltadd 9557  ax-pre-mulgt0 9558
This theorem depends on definitions:  df-bi 185  df-or 368  df-an 369  df-3or 972  df-3an 973  df-tru 1401  df-ex 1618  df-nf 1622  df-sb 1745  df-eu 2288  df-mo 2289  df-clab 2440  df-cleq 2446  df-clel 2449  df-nfc 2604  df-ne 2651  df-nel 2652  df-ral 2809  df-rex 2810  df-reu 2811  df-rmo 2812  df-rab 2813  df-v 3108  df-sbc 3325  df-csb 3421  df-dif 3464  df-un 3466  df-in 3468  df-ss 3475  df-pss 3477  df-nul 3784  df-if 3930  df-pw 4001  df-sn 4017  df-pr 4019  df-tp 4021  df-op 4023  df-uni 4236  df-int 4272  df-iun 4317  df-br 4440  df-opab 4498  df-mpt 4499  df-tr 4533  df-eprel 4780  df-id 4784  df-po 4789  df-so 4790  df-fr 4827  df-we 4829  df-ord 4870  df-on 4871  df-lim 4872  df-suc 4873  df-xp 4994  df-rel 4995  df-cnv 4996  df-co 4997  df-dm 4998  df-rn 4999  df-res 5000  df-ima 5001  df-iota 5534  df-fun 5572  df-fn 5573  df-f 5574  df-f1 5575  df-fo 5576  df-f1o 5577  df-fv 5578  df-riota 6232  df-ov 6273  df-oprab 6274  df-mpt2 6275  df-om 6674  df-1st 6773  df-2nd 6774  df-recs 7034  df-rdg 7068  df-1o 7122  df-oadd 7126  df-er 7303  df-en 7510  df-dom 7511  df-sdom 7512  df-fin 7513  df-card 8311  df-cda 8539  df-pnf 9619  df-mnf 9620  df-xr 9621  df-ltxr 9622  df-le 9623  df-sub 9798  df-neg 9799  df-nn 10532  df-2 10590  df-n0 10792  df-z 10861  df-uz 11083  df-fz 11676  df-fzo 11800  df-hash 12391  df-word 12529  df-concat 12531  df-substr 12533
This theorem is referenced by:  swrdccatid  12716
  Copyright terms: Public domain W3C validator