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

Theorem swrdccat3a 12473
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 11568 . . . . . 6  |-  ( N  e.  ( 0 ... ( L  +  (
# `  B )
) )  ->  N  e.  NN0 )
2 0elfz 11570 . . . . . 6  |-  ( N  e.  NN0  ->  0  e.  ( 0 ... N
) )
31, 2syl 16 . . . . 5  |-  ( N  e.  ( 0 ... ( L  +  (
# `  B )
) )  ->  0  e.  ( 0 ... N
) )
43ancri 552 . . . 4  |-  ( N  e.  ( 0 ... ( L  +  (
# `  B )
) )  ->  (
0  e.  ( 0 ... N )  /\  N  e.  ( 0 ... ( L  +  ( # `  B ) ) ) ) )
5 swrdccatin12.l . . . . . 6  |-  L  =  ( # `  A
)
65swrdccat3 12471 . . . . 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 429 . . . 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 474 . . 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 3881 . . . . 5  |-  ( N  <_  L  ->  if ( N  <_  L , 
( A substr  <. 0 ,  N >. ) ,  ( A concat  ( B substr  <. 0 ,  ( N  -  L ) >. )
) )  =  ( A substr  <. 0 ,  N >. ) )
109adantl 466 . . . 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 3883 . . . . . 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 1010 . . . . 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 12337 . . . . . . . . . . . . 13  |-  ( A  e. Word  V  ->  ( # `
 A )  e. 
NN0 )
145, 13syl5eqel 2540 . . . . . . . . . . . 12  |-  ( A  e. Word  V  ->  L  e.  NN0 )
15 nn0le0eq0 10695 . . . . . . . . . . . 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 465 . . . . . . . . 9  |-  ( ( A  e. Word  V  /\  B  e. Word  V )  ->  ( L  <_  0  ->  L  =  0 ) )
195eqeq1i 2456 . . . . . . . . . . . . . . . 16  |-  ( L  =  0  <->  ( # `  A
)  =  0 )
2019biimpi 194 . . . . . . . . . . . . . . 15  |-  ( L  =  0  ->  ( # `
 A )  =  0 )
21 hasheq0 12218 . . . . . . . . . . . . . . 15  |-  ( A  e. Word  V  ->  (
( # `  A )  =  0  <->  A  =  (/) ) )
2220, 21syl5ib 219 . . . . . . . . . . . . . 14  |-  ( A  e. Word  V  ->  ( L  =  0  ->  A  =  (/) ) )
2322adantr 465 . . . . . . . . . . . . 13  |-  ( ( A  e. Word  V  /\  B  e. Word  V )  ->  ( L  =  0  ->  A  =  (/) ) )
2423imp 429 . . . . . . . . . . . 12  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  L  =  0 )  ->  A  =  (/) )
25 0m0e0 10518 . . . . . . . . . . . . . . . 16  |-  ( 0  -  0 )  =  0
26 oveq2 6184 . . . . . . . . . . . . . . . . 17  |-  ( 0  =  L  ->  (
0  -  0 )  =  ( 0  -  L ) )
2726eqcoms 2461 . . . . . . . . . . . . . . . 16  |-  ( L  =  0  ->  (
0  -  0 )  =  ( 0  -  L ) )
2825, 27syl5eqr 2504 . . . . . . . . . . . . . . 15  |-  ( L  =  0  ->  0  =  ( 0  -  L ) )
2928adantl 466 . . . . . . . . . . . . . 14  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  L  =  0 )  ->  0  =  ( 0  -  L
) )
3029opeq1d 4149 . . . . . . . . . . . . 13  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  L  =  0 )  ->  <. 0 ,  ( N  -  L
) >.  =  <. (
0  -  L ) ,  ( N  -  L ) >. )
3130oveq2d 6192 . . . . . . . . . . . 12  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  L  =  0 )  ->  ( B substr  <.
0 ,  ( N  -  L ) >.
)  =  ( B substr  <. ( 0  -  L
) ,  ( N  -  L ) >.
) )
3224, 31oveq12d 6194 . . . . . . . . . . 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 ) >. )
) )
33 swrdcl 12403 . . . . . . . . . . . . . 14  |-  ( B  e. Word  V  ->  ( B substr  <. ( 0  -  L ) ,  ( N  -  L )
>. )  e. Word  V )
34 ccatlid 12372 . . . . . . . . . . . . . 14  |-  ( ( B substr  <. ( 0  -  L ) ,  ( N  -  L )
>. )  e. Word  V  -> 
( (/) concat  ( B substr  <. (
0  -  L ) ,  ( N  -  L ) >. )
)  =  ( B substr  <. ( 0  -  L
) ,  ( N  -  L ) >.
) )
3533, 34syl 16 . . . . . . . . . . . . 13  |-  ( B  e. Word  V  ->  ( (/) concat  ( B substr  <. ( 0  -  L ) ,  ( N  -  L
) >. ) )  =  ( B substr  <. (
0  -  L ) ,  ( N  -  L ) >. )
)
3635adantl 466 . . . . . . . . . . . 12  |-  ( ( A  e. Word  V  /\  B  e. Word  V )  ->  ( (/) concat  ( B substr  <. (
0  -  L ) ,  ( N  -  L ) >. )
)  =  ( B substr  <. ( 0  -  L
) ,  ( N  -  L ) >.
) )
3736adantr 465 . . . . . . . . . . 11  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  L  =  0 )  ->  ( (/) concat  ( B substr  <. ( 0  -  L
) ,  ( N  -  L ) >.
) )  =  ( B substr  <. ( 0  -  L ) ,  ( N  -  L )
>. ) )
3832, 37eqtrd 2490 . . . . . . . . . 10  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  L  =  0 )  ->  ( A concat  ( B substr  <. 0 ,  ( N  -  L )
>. ) )  =  ( B substr  <. ( 0  -  L ) ,  ( N  -  L )
>. ) )
3938ex 434 . . . . . . . . 9  |-  ( ( A  e. Word  V  /\  B  e. Word  V )  ->  ( L  =  0  ->  ( A concat  ( 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 concat  ( B substr  <. 0 ,  ( N  -  L ) >.
) )  =  ( B substr  <. ( 0  -  L ) ,  ( N  -  L )
>. ) ) )
4140adantr 465 . . . . . . 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 )
>. ) ) )
4241imp 429 . . . . . 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 )
>. ) )
43423adant2 1007 . . . . 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 )
>. ) )
4412, 43eqtrd 2490 . . . 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 ) >. )
)
45113ad2ant2 1010 . . . . 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 ) >. )
) )
465opeq2i 4147 . . . . . . . . . . 11  |-  <. 0 ,  L >.  =  <. 0 ,  ( # `  A
) >.
4746oveq2i 6187 . . . . . . . . . 10  |-  ( A substr  <. 0 ,  L >. )  =  ( A substr  <. 0 ,  ( # `  A
) >. )
48 swrdid 12409 . . . . . . . . . 10  |-  ( A  e. Word  V  ->  ( A substr  <. 0 ,  (
# `  A ) >. )  =  A )
4947, 48syl5req 2503 . . . . . . . . 9  |-  ( A  e. Word  V  ->  A  =  ( A substr  <. 0 ,  L >. ) )
5049adantr 465 . . . . . . . 8  |-  ( ( A  e. Word  V  /\  B  e. Word  V )  ->  A  =  ( A substr  <. 0 ,  L >. ) )
5150adantr 465 . . . . . . 7  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  ->  A  =  ( A substr  <. 0 ,  L >. ) )
52513ad2ant1 1009 . . . . . 6  |-  ( ( ( ( A  e. Word  V  /\  B  e. Word  V
)  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  /\  -.  N  <_  L  /\  -.  L  <_ 
0 )  ->  A  =  ( A substr  <. 0 ,  L >. ) )
5352oveq1d 6191 . . . . 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 ) >. )
) )
5445, 53eqtrd 2490 . . . 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 ) >.
) ) )
5510, 44, 542if2 3921 . . 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 ) >.
) ) ) ) )
568, 55eqtr4d 2493 . 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 ) >. )
) ) )
5756ex 434 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 setvar class
Syntax hints:   -. wn 3    -> wi 4    <-> wb 184    /\ wa 369    /\ w3a 965    = wceq 1370    e. wcel 1757   (/)c0 3721   ifcif 3875   <.cop 3967   class class class wbr 4376   ` cfv 5502  (class class class)co 6176   0cc0 9369    + caddc 9372    <_ cle 9506    - cmin 9682   NN0cn0 10666   ...cfz 11524   #chash 12190  Word cword 12309   concat cconcat 12311   substr csubstr 12313
This theorem was proved from axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1592  ax-4 1603  ax-5 1671  ax-6 1709  ax-7 1729  ax-8 1759  ax-9 1761  ax-10 1776  ax-11 1781  ax-12 1793  ax-13 1944  ax-ext 2429  ax-rep 4487  ax-sep 4497  ax-nul 4505  ax-pow 4554  ax-pr 4615  ax-un 6458  ax-cnex 9425  ax-resscn 9426  ax-1cn 9427  ax-icn 9428  ax-addcl 9429  ax-addrcl 9430  ax-mulcl 9431  ax-mulrcl 9432  ax-mulcom 9433  ax-addass 9434  ax-mulass 9435  ax-distr 9436  ax-i2m1 9437  ax-1ne0 9438  ax-1rid 9439  ax-rnegex 9440  ax-rrecex 9441  ax-cnre 9442  ax-pre-lttri 9443  ax-pre-lttrn 9444  ax-pre-ltadd 9445  ax-pre-mulgt0 9446
This theorem depends on definitions:  df-bi 185  df-or 370  df-an 371  df-3or 966  df-3an 967  df-tru 1373  df-ex 1588  df-nf 1591  df-sb 1702  df-eu 2263  df-mo 2264  df-clab 2436  df-cleq 2442  df-clel 2445  df-nfc 2598  df-ne 2643  df-nel 2644  df-ral 2797  df-rex 2798  df-reu 2799  df-rab 2801  df-v 3056  df-sbc 3271  df-csb 3373  df-dif 3415  df-un 3417  df-in 3419  df-ss 3426  df-pss 3428  df-nul 3722  df-if 3876  df-pw 3946  df-sn 3962  df-pr 3964  df-tp 3966  df-op 3968  df-uni 4176  df-int 4213  df-iun 4257  df-br 4377  df-opab 4435  df-mpt 4436  df-tr 4470  df-eprel 4716  df-id 4720  df-po 4725  df-so 4726  df-fr 4763  df-we 4765  df-ord 4806  df-on 4807  df-lim 4808  df-suc 4809  df-xp 4930  df-rel 4931  df-cnv 4932  df-co 4933  df-dm 4934  df-rn 4935  df-res 4936  df-ima 4937  df-iota 5465  df-fun 5504  df-fn 5505  df-f 5506  df-f1 5507  df-fo 5508  df-f1o 5509  df-fv 5510  df-riota 6137  df-ov 6179  df-oprab 6180  df-mpt2 6181  df-om 6563  df-1st 6663  df-2nd 6664  df-recs 6918  df-rdg 6952  df-1o 7006  df-oadd 7010  df-er 7187  df-en 7397  df-dom 7398  df-sdom 7399  df-fin 7400  df-card 8196  df-pnf 9507  df-mnf 9508  df-xr 9509  df-ltxr 9510  df-le 9511  df-sub 9684  df-neg 9685  df-nn 10410  df-n0 10667  df-z 10734  df-uz 10949  df-fz 11525  df-fzo 11636  df-hash 12191  df-word 12317  df-concat 12319  df-substr 12321
This theorem is referenced by:  swrdccatid  12476
  Copyright terms: Public domain W3C validator