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

Theorem swrdccat3a 12678
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 11766 . . . . . 6  |-  ( N  e.  ( 0 ... ( L  +  (
# `  B )
) )  ->  N  e.  NN0 )
2 0elfz 11768 . . . . . 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 12676 . . . . 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 3945 . . . . 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 3948 . . . . . 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 1018 . . . . 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 12524 . . . . . . . . . . . . 13  |-  ( A  e. Word  V  ->  ( # `
 A )  e. 
NN0 )
145, 13syl5eqel 2559 . . . . . . . . . . . 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 465 . . . . . . . . 9  |-  ( ( A  e. Word  V  /\  B  e. Word  V )  ->  ( L  <_  0  ->  L  =  0 ) )
195eqeq1i 2474 . . . . . . . . . . . . . . . 16  |-  ( L  =  0  <->  ( # `  A
)  =  0 )
2019biimpi 194 . . . . . . . . . . . . . . 15  |-  ( L  =  0  ->  ( # `
 A )  =  0 )
21 hasheq0 12397 . . . . . . . . . . . . . . 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 10641 . . . . . . . . . . . . . . . 16  |-  ( 0  -  0 )  =  0
26 oveq2 6290 . . . . . . . . . . . . . . . . 17  |-  ( 0  =  L  ->  (
0  -  0 )  =  ( 0  -  L ) )
2726eqcoms 2479 . . . . . . . . . . . . . . . 16  |-  ( L  =  0  ->  (
0  -  0 )  =  ( 0  -  L ) )
2825, 27syl5eqr 2522 . . . . . . . . . . . . . . 15  |-  ( L  =  0  ->  0  =  ( 0  -  L ) )
2928adantl 466 . . . . . . . . . . . . . 14  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  L  =  0 )  ->  0  =  ( 0  -  L
) )
3029opeq1d 4219 . . . . . . . . . . . . 13  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  L  =  0 )  ->  <. 0 ,  ( N  -  L
) >.  =  <. (
0  -  L ) ,  ( N  -  L ) >. )
3130oveq2d 6298 . . . . . . . . . . . 12  |-  ( ( ( A  e. Word  V  /\  B  e. Word  V )  /\  L  =  0 )  ->  ( B substr  <.
0 ,  ( N  -  L ) >.
)  =  ( B substr  <. ( 0  -  L
) ,  ( N  -  L ) >.
) )
3224, 31oveq12d 6300 . . . . . . . . . . 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 12605 . . . . . . . . . . . . . 14  |-  ( B  e. Word  V  ->  ( B substr  <. ( 0  -  L ) ,  ( N  -  L )
>. )  e. Word  V )
34 ccatlid 12564 . . . . . . . . . . . . . 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 2508 . . . . . . . . . 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 1015 . . . . 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 2508 . . . 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 1018 . . . . 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 4217 . . . . . . . . . . 11  |-  <. 0 ,  L >.  =  <. 0 ,  ( # `  A
) >.
4746oveq2i 6293 . . . . . . . . . 10  |-  ( A substr  <. 0 ,  L >. )  =  ( A substr  <. 0 ,  ( # `  A
) >. )
48 swrdid 12611 . . . . . . . . . 10  |-  ( A  e. Word  V  ->  ( A substr  <. 0 ,  (
# `  A ) >. )  =  A )
4947, 48syl5req 2521 . . . . . . . . 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 1017 . . . . . 6  |-  ( ( ( ( A  e. Word  V  /\  B  e. Word  V
)  /\  N  e.  ( 0 ... ( L  +  ( # `  B
) ) ) )  /\  -.  N  <_  L  /\  -.  L  <_ 
0 )  ->  A  =  ( A substr  <. 0 ,  L >. ) )
5352oveq1d 6297 . . . . 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 2508 . . . 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 3987 . . 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 2511 . 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 973    = wceq 1379    e. wcel 1767   (/)c0 3785   ifcif 3939   <.cop 4033   class class class wbr 4447   ` cfv 5586  (class class class)co 6282   0cc0 9488    + caddc 9491    <_ cle 9625    - cmin 9801   NN0cn0 10791   ...cfz 11668   #chash 12369  Word cword 12496   concat cconcat 12498   substr csubstr 12500
This theorem was proved from axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1601  ax-4 1612  ax-5 1680  ax-6 1719  ax-7 1739  ax-8 1769  ax-9 1771  ax-10 1786  ax-11 1791  ax-12 1803  ax-13 1968  ax-ext 2445  ax-rep 4558  ax-sep 4568  ax-nul 4576  ax-pow 4625  ax-pr 4686  ax-un 6574  ax-cnex 9544  ax-resscn 9545  ax-1cn 9546  ax-icn 9547  ax-addcl 9548  ax-addrcl 9549  ax-mulcl 9550  ax-mulrcl 9551  ax-mulcom 9552  ax-addass 9553  ax-mulass 9554  ax-distr 9555  ax-i2m1 9556  ax-1ne0 9557  ax-1rid 9558  ax-rnegex 9559  ax-rrecex 9560  ax-cnre 9561  ax-pre-lttri 9562  ax-pre-lttrn 9563  ax-pre-ltadd 9564  ax-pre-mulgt0 9565
This theorem depends on definitions:  df-bi 185  df-or 370  df-an 371  df-3or 974  df-3an 975  df-tru 1382  df-ex 1597  df-nf 1600  df-sb 1712  df-eu 2279  df-mo 2280  df-clab 2453  df-cleq 2459  df-clel 2462  df-nfc 2617  df-ne 2664  df-nel 2665  df-ral 2819  df-rex 2820  df-reu 2821  df-rab 2823  df-v 3115  df-sbc 3332  df-csb 3436  df-dif 3479  df-un 3481  df-in 3483  df-ss 3490  df-pss 3492  df-nul 3786  df-if 3940  df-pw 4012  df-sn 4028  df-pr 4030  df-tp 4032  df-op 4034  df-uni 4246  df-int 4283  df-iun 4327  df-br 4448  df-opab 4506  df-mpt 4507  df-tr 4541  df-eprel 4791  df-id 4795  df-po 4800  df-so 4801  df-fr 4838  df-we 4840  df-ord 4881  df-on 4882  df-lim 4883  df-suc 4884  df-xp 5005  df-rel 5006  df-cnv 5007  df-co 5008  df-dm 5009  df-rn 5010  df-res 5011  df-ima 5012  df-iota 5549  df-fun 5588  df-fn 5589  df-f 5590  df-f1 5591  df-fo 5592  df-f1o 5593  df-fv 5594  df-riota 6243  df-ov 6285  df-oprab 6286  df-mpt2 6287  df-om 6679  df-1st 6781  df-2nd 6782  df-recs 7039  df-rdg 7073  df-1o 7127  df-oadd 7131  df-er 7308  df-en 7514  df-dom 7515  df-sdom 7516  df-fin 7517  df-card 8316  df-pnf 9626  df-mnf 9627  df-xr 9628  df-ltxr 9629  df-le 9630  df-sub 9803  df-neg 9804  df-nn 10533  df-n0 10792  df-z 10861  df-uz 11079  df-fz 11669  df-fzo 11789  df-hash 12370  df-word 12504  df-concat 12506  df-substr 12508
This theorem is referenced by:  swrdccatid  12681
  Copyright terms: Public domain W3C validator