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

Theorem swrdccat3a 13488
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 𝐿 = (#‘𝐴)
Assertion
Ref Expression
swrdccat3a ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → (𝑁 ∈ (0...(𝐿 + (#‘𝐵))) → ((𝐴 ++ 𝐵) substr ⟨0, 𝑁⟩) = if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))))

Proof of Theorem swrdccat3a
StepHypRef Expression
1 elfznn0 12429 . . . . . 6 (𝑁 ∈ (0...(𝐿 + (#‘𝐵))) → 𝑁 ∈ ℕ0)
2 0elfz 12432 . . . . . 6 (𝑁 ∈ ℕ0 → 0 ∈ (0...𝑁))
31, 2syl 17 . . . . 5 (𝑁 ∈ (0...(𝐿 + (#‘𝐵))) → 0 ∈ (0...𝑁))
43ancri 575 . . . 4 (𝑁 ∈ (0...(𝐿 + (#‘𝐵))) → (0 ∈ (0...𝑁) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))))
5 swrdccatin12.l . . . . . 6 𝐿 = (#‘𝐴)
65swrdccat3 13486 . . . . 5 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → ((0 ∈ (0...𝑁) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) → ((𝐴 ++ 𝐵) substr ⟨0, 𝑁⟩) = if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), if(𝐿 ≤ 0, (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩), ((𝐴 substr ⟨0, 𝐿⟩) ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))))))
76imp 445 . . . 4 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ (0 ∈ (0...𝑁) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵))))) → ((𝐴 ++ 𝐵) substr ⟨0, 𝑁⟩) = if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), if(𝐿 ≤ 0, (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩), ((𝐴 substr ⟨0, 𝐿⟩) ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))))
84, 7sylan2 491 . . 3 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) → ((𝐴 ++ 𝐵) substr ⟨0, 𝑁⟩) = if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), if(𝐿 ≤ 0, (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩), ((𝐴 substr ⟨0, 𝐿⟩) ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))))
9 iftrue 4090 . . . . 5 (𝑁𝐿 → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = (𝐴 substr ⟨0, 𝑁⟩))
109adantl 482 . . . 4 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) ∧ 𝑁𝐿) → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = (𝐴 substr ⟨0, 𝑁⟩))
11 iffalse 4093 . . . . . 6 𝑁𝐿 → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))
12113ad2ant2 1082 . . . . 5 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) ∧ ¬ 𝑁𝐿𝐿 ≤ 0) → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))
13 lencl 13319 . . . . . . . . . . . . 13 (𝐴 ∈ Word 𝑉 → (#‘𝐴) ∈ ℕ0)
145, 13syl5eqel 2704 . . . . . . . . . . . 12 (𝐴 ∈ Word 𝑉𝐿 ∈ ℕ0)
15 nn0le0eq0 11318 . . . . . . . . . . . 12 (𝐿 ∈ ℕ0 → (𝐿 ≤ 0 ↔ 𝐿 = 0))
1614, 15syl 17 . . . . . . . . . . 11 (𝐴 ∈ Word 𝑉 → (𝐿 ≤ 0 ↔ 𝐿 = 0))
1716biimpd 219 . . . . . . . . . 10 (𝐴 ∈ Word 𝑉 → (𝐿 ≤ 0 → 𝐿 = 0))
1817adantr 481 . . . . . . . . 9 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → (𝐿 ≤ 0 → 𝐿 = 0))
195eqeq1i 2626 . . . . . . . . . . . . . . . 16 (𝐿 = 0 ↔ (#‘𝐴) = 0)
2019biimpi 206 . . . . . . . . . . . . . . 15 (𝐿 = 0 → (#‘𝐴) = 0)
21 hasheq0 13149 . . . . . . . . . . . . . . 15 (𝐴 ∈ Word 𝑉 → ((#‘𝐴) = 0 ↔ 𝐴 = ∅))
2220, 21syl5ib 234 . . . . . . . . . . . . . 14 (𝐴 ∈ Word 𝑉 → (𝐿 = 0 → 𝐴 = ∅))
2322adantr 481 . . . . . . . . . . . . 13 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → (𝐿 = 0 → 𝐴 = ∅))
2423imp 445 . . . . . . . . . . . 12 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → 𝐴 = ∅)
25 0m0e0 11127 . . . . . . . . . . . . . . . 16 (0 − 0) = 0
26 oveq2 6655 . . . . . . . . . . . . . . . . 17 (0 = 𝐿 → (0 − 0) = (0 − 𝐿))
2726eqcoms 2629 . . . . . . . . . . . . . . . 16 (𝐿 = 0 → (0 − 0) = (0 − 𝐿))
2825, 27syl5eqr 2669 . . . . . . . . . . . . . . 15 (𝐿 = 0 → 0 = (0 − 𝐿))
2928adantl 482 . . . . . . . . . . . . . 14 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → 0 = (0 − 𝐿))
3029opeq1d 4406 . . . . . . . . . . . . 13 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → ⟨0, (𝑁𝐿)⟩ = ⟨(0 − 𝐿), (𝑁𝐿)⟩)
3130oveq2d 6663 . . . . . . . . . . . 12 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → (𝐵 substr ⟨0, (𝑁𝐿)⟩) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
3224, 31oveq12d 6665 . . . . . . . . . . 11 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (∅ ++ (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)))
33 swrdcl 13413 . . . . . . . . . . . . . 14 (𝐵 ∈ Word 𝑉 → (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩) ∈ Word 𝑉)
34 ccatlid 13364 . . . . . . . . . . . . . 14 ((𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩) ∈ Word 𝑉 → (∅ ++ (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
3533, 34syl 17 . . . . . . . . . . . . 13 (𝐵 ∈ Word 𝑉 → (∅ ++ (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
3635adantl 482 . . . . . . . . . . . 12 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → (∅ ++ (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
3736adantr 481 . . . . . . . . . . 11 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → (∅ ++ (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
3832, 37eqtrd 2655 . . . . . . . . . 10 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
3938ex 450 . . . . . . . . 9 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → (𝐿 = 0 → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)))
4018, 39syld 47 . . . . . . . 8 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → (𝐿 ≤ 0 → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)))
4140adantr 481 . . . . . . 7 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) → (𝐿 ≤ 0 → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)))
4241imp 445 . . . . . 6 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) ∧ 𝐿 ≤ 0) → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
43423adant2 1079 . . . . 5 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) ∧ ¬ 𝑁𝐿𝐿 ≤ 0) → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
4412, 43eqtrd 2655 . . . 4 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) ∧ ¬ 𝑁𝐿𝐿 ≤ 0) → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
45113ad2ant2 1082 . . . . 5 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) ∧ ¬ 𝑁𝐿 ∧ ¬ 𝐿 ≤ 0) → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))
465opeq2i 4404 . . . . . . . . . . 11 ⟨0, 𝐿⟩ = ⟨0, (#‘𝐴)⟩
4746oveq2i 6658 . . . . . . . . . 10 (𝐴 substr ⟨0, 𝐿⟩) = (𝐴 substr ⟨0, (#‘𝐴)⟩)
48 swrdid 13422 . . . . . . . . . 10 (𝐴 ∈ Word 𝑉 → (𝐴 substr ⟨0, (#‘𝐴)⟩) = 𝐴)
4947, 48syl5req 2668 . . . . . . . . 9 (𝐴 ∈ Word 𝑉𝐴 = (𝐴 substr ⟨0, 𝐿⟩))
5049adantr 481 . . . . . . . 8 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → 𝐴 = (𝐴 substr ⟨0, 𝐿⟩))
5150adantr 481 . . . . . . 7 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) → 𝐴 = (𝐴 substr ⟨0, 𝐿⟩))
52513ad2ant1 1081 . . . . . 6 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) ∧ ¬ 𝑁𝐿 ∧ ¬ 𝐿 ≤ 0) → 𝐴 = (𝐴 substr ⟨0, 𝐿⟩))
5352oveq1d 6662 . . . . 5 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) ∧ ¬ 𝑁𝐿 ∧ ¬ 𝐿 ≤ 0) → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = ((𝐴 substr ⟨0, 𝐿⟩) ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))
5445, 53eqtrd 2655 . . . 4 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) ∧ ¬ 𝑁𝐿 ∧ ¬ 𝐿 ≤ 0) → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = ((𝐴 substr ⟨0, 𝐿⟩) ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))
5510, 44, 542if2 4134 . . 3 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), if(𝐿 ≤ 0, (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩), ((𝐴 substr ⟨0, 𝐿⟩) ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))))
568, 55eqtr4d 2658 . 2 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) → ((𝐴 ++ 𝐵) substr ⟨0, 𝑁⟩) = if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))))
5756ex 450 1 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → (𝑁 ∈ (0...(𝐿 + (#‘𝐵))) → ((𝐴 ++ 𝐵) substr ⟨0, 𝑁⟩) = if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))))
Colors of variables: wff setvar class
Syntax hints:  ¬ wn 3  wi 4  wb 196  wa 384  w3a 1037   = wceq 1482  wcel 1989  c0 3913  ifcif 4084  cop 4181   class class class wbr 4651  cfv 5886  (class class class)co 6647  0cc0 9933   + caddc 9936  cle 10072  cmin 10263  0cn0 11289  ...cfz 12323  #chash 13112  Word cword 13286   ++ cconcat 13288   substr csubstr 13290
This theorem was proved from axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1721  ax-4 1736  ax-5 1838  ax-6 1887  ax-7 1934  ax-8 1991  ax-9 1998  ax-10 2018  ax-11 2033  ax-12 2046  ax-13 2245  ax-ext 2601  ax-rep 4769  ax-sep 4779  ax-nul 4787  ax-pow 4841  ax-pr 4904  ax-un 6946  ax-cnex 9989  ax-resscn 9990  ax-1cn 9991  ax-icn 9992  ax-addcl 9993  ax-addrcl 9994  ax-mulcl 9995  ax-mulrcl 9996  ax-mulcom 9997  ax-addass 9998  ax-mulass 9999  ax-distr 10000  ax-i2m1 10001  ax-1ne0 10002  ax-1rid 10003  ax-rnegex 10004  ax-rrecex 10005  ax-cnre 10006  ax-pre-lttri 10007  ax-pre-lttrn 10008  ax-pre-ltadd 10009  ax-pre-mulgt0 10010
This theorem depends on definitions:  df-bi 197  df-or 385  df-an 386  df-3or 1038  df-3an 1039  df-tru 1485  df-ex 1704  df-nf 1709  df-sb 1880  df-eu 2473  df-mo 2474  df-clab 2608  df-cleq 2614  df-clel 2617  df-nfc 2752  df-ne 2794  df-nel 2897  df-ral 2916  df-rex 2917  df-reu 2918  df-rab 2920  df-v 3200  df-sbc 3434  df-csb 3532  df-dif 3575  df-un 3577  df-in 3579  df-ss 3586  df-pss 3588  df-nul 3914  df-if 4085  df-pw 4158  df-sn 4176  df-pr 4178  df-tp 4180  df-op 4182  df-uni 4435  df-int 4474  df-iun 4520  df-br 4652  df-opab 4711  df-mpt 4728  df-tr 4751  df-id 5022  df-eprel 5027  df-po 5033  df-so 5034  df-fr 5071  df-we 5073  df-xp 5118  df-rel 5119  df-cnv 5120  df-co 5121  df-dm 5122  df-rn 5123  df-res 5124  df-ima 5125  df-pred 5678  df-ord 5724  df-on 5725  df-lim 5726  df-suc 5727  df-iota 5849  df-fun 5888  df-fn 5889  df-f 5890  df-f1 5891  df-fo 5892  df-f1o 5893  df-fv 5894  df-riota 6608  df-ov 6650  df-oprab 6651  df-mpt2 6652  df-om 7063  df-1st 7165  df-2nd 7166  df-wrecs 7404  df-recs 7465  df-rdg 7503  df-1o 7557  df-oadd 7561  df-er 7739  df-en 7953  df-dom 7954  df-sdom 7955  df-fin 7956  df-card 8762  df-pnf 10073  df-mnf 10074  df-xr 10075  df-ltxr 10076  df-le 10077  df-sub 10265  df-neg 10266  df-nn 11018  df-n0 11290  df-z 11375  df-uz 11685  df-fz 12324  df-fzo 12462  df-hash 13113  df-word 13294  df-concat 13296  df-substr 13298
This theorem is referenced by:  swrdccatid  13491
  Copyright terms: Public domain W3C validator