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

Theorem swrdccat3a 13540
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 12471 . . . . . 6 (𝑁 ∈ (0...(𝐿 + (#‘𝐵))) → 𝑁 ∈ ℕ0)
2 0elfz 12475 . . . . . 6 (𝑁 ∈ ℕ0 → 0 ∈ (0...𝑁))
31, 2syl 17 . . . . 5 (𝑁 ∈ (0...(𝐿 + (#‘𝐵))) → 0 ∈ (0...𝑁))
43ancri 574 . . . 4 (𝑁 ∈ (0...(𝐿 + (#‘𝐵))) → (0 ∈ (0...𝑁) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))))
5 swrdccatin12.l . . . . . 6 𝐿 = (#‘𝐴)
65swrdccat3 13538 . . . . 5 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → ((0 ∈ (0...𝑁) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) → ((𝐴 ++ 𝐵) substr ⟨0, 𝑁⟩) = if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), if(𝐿 ≤ 0, (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩), ((𝐴 substr ⟨0, 𝐿⟩) ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))))))
76imp 444 . . . 4 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ (0 ∈ (0...𝑁) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵))))) → ((𝐴 ++ 𝐵) substr ⟨0, 𝑁⟩) = if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), if(𝐿 ≤ 0, (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩), ((𝐴 substr ⟨0, 𝐿⟩) ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))))
84, 7sylan2 490 . . 3 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) → ((𝐴 ++ 𝐵) substr ⟨0, 𝑁⟩) = if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), if(𝐿 ≤ 0, (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩), ((𝐴 substr ⟨0, 𝐿⟩) ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))))
9 iftrue 4125 . . . . 5 (𝑁𝐿 → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = (𝐴 substr ⟨0, 𝑁⟩))
109adantl 481 . . . 4 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) ∧ 𝑁𝐿) → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = (𝐴 substr ⟨0, 𝑁⟩))
11 iffalse 4128 . . . . . 6 𝑁𝐿 → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))
12113ad2ant2 1103 . . . . 5 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) ∧ ¬ 𝑁𝐿𝐿 ≤ 0) → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))
13 lencl 13356 . . . . . . . . . . . . 13 (𝐴 ∈ Word 𝑉 → (#‘𝐴) ∈ ℕ0)
145, 13syl5eqel 2734 . . . . . . . . . . . 12 (𝐴 ∈ Word 𝑉𝐿 ∈ ℕ0)
15 nn0le0eq0 11359 . . . . . . . . . . . 12 (𝐿 ∈ ℕ0 → (𝐿 ≤ 0 ↔ 𝐿 = 0))
1614, 15syl 17 . . . . . . . . . . 11 (𝐴 ∈ Word 𝑉 → (𝐿 ≤ 0 ↔ 𝐿 = 0))
1716biimpd 219 . . . . . . . . . 10 (𝐴 ∈ Word 𝑉 → (𝐿 ≤ 0 → 𝐿 = 0))
1817adantr 480 . . . . . . . . 9 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → (𝐿 ≤ 0 → 𝐿 = 0))
195eqeq1i 2656 . . . . . . . . . . . . . . . 16 (𝐿 = 0 ↔ (#‘𝐴) = 0)
2019biimpi 206 . . . . . . . . . . . . . . 15 (𝐿 = 0 → (#‘𝐴) = 0)
21 hasheq0 13192 . . . . . . . . . . . . . . 15 (𝐴 ∈ Word 𝑉 → ((#‘𝐴) = 0 ↔ 𝐴 = ∅))
2220, 21syl5ib 234 . . . . . . . . . . . . . 14 (𝐴 ∈ Word 𝑉 → (𝐿 = 0 → 𝐴 = ∅))
2322adantr 480 . . . . . . . . . . . . 13 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → (𝐿 = 0 → 𝐴 = ∅))
2423imp 444 . . . . . . . . . . . 12 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → 𝐴 = ∅)
25 0m0e0 11168 . . . . . . . . . . . . . . . 16 (0 − 0) = 0
26 oveq2 6698 . . . . . . . . . . . . . . . . 17 (0 = 𝐿 → (0 − 0) = (0 − 𝐿))
2726eqcoms 2659 . . . . . . . . . . . . . . . 16 (𝐿 = 0 → (0 − 0) = (0 − 𝐿))
2825, 27syl5eqr 2699 . . . . . . . . . . . . . . 15 (𝐿 = 0 → 0 = (0 − 𝐿))
2928adantl 481 . . . . . . . . . . . . . 14 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → 0 = (0 − 𝐿))
3029opeq1d 4439 . . . . . . . . . . . . 13 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → ⟨0, (𝑁𝐿)⟩ = ⟨(0 − 𝐿), (𝑁𝐿)⟩)
3130oveq2d 6706 . . . . . . . . . . . 12 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → (𝐵 substr ⟨0, (𝑁𝐿)⟩) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
3224, 31oveq12d 6708 . . . . . . . . . . 11 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (∅ ++ (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)))
33 swrdcl 13464 . . . . . . . . . . . . . 14 (𝐵 ∈ Word 𝑉 → (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩) ∈ Word 𝑉)
34 ccatlid 13404 . . . . . . . . . . . . . 14 ((𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩) ∈ Word 𝑉 → (∅ ++ (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
3533, 34syl 17 . . . . . . . . . . . . 13 (𝐵 ∈ Word 𝑉 → (∅ ++ (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
3635adantl 481 . . . . . . . . . . . 12 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → (∅ ++ (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
3736adantr 480 . . . . . . . . . . 11 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → (∅ ++ (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
3832, 37eqtrd 2685 . . . . . . . . . 10 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
3938ex 449 . . . . . . . . 9 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → (𝐿 = 0 → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)))
4018, 39syld 47 . . . . . . . 8 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → (𝐿 ≤ 0 → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)))
4140adantr 480 . . . . . . 7 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) → (𝐿 ≤ 0 → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)))
4241imp 444 . . . . . 6 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) ∧ 𝐿 ≤ 0) → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
43423adant2 1100 . . . . 5 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) ∧ ¬ 𝑁𝐿𝐿 ≤ 0) → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
4412, 43eqtrd 2685 . . . 4 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) ∧ ¬ 𝑁𝐿𝐿 ≤ 0) → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
45113ad2ant2 1103 . . . . 5 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) ∧ ¬ 𝑁𝐿 ∧ ¬ 𝐿 ≤ 0) → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))
465opeq2i 4437 . . . . . . . . . . 11 ⟨0, 𝐿⟩ = ⟨0, (#‘𝐴)⟩
4746oveq2i 6701 . . . . . . . . . 10 (𝐴 substr ⟨0, 𝐿⟩) = (𝐴 substr ⟨0, (#‘𝐴)⟩)
48 swrdid 13474 . . . . . . . . . 10 (𝐴 ∈ Word 𝑉 → (𝐴 substr ⟨0, (#‘𝐴)⟩) = 𝐴)
4947, 48syl5req 2698 . . . . . . . . 9 (𝐴 ∈ Word 𝑉𝐴 = (𝐴 substr ⟨0, 𝐿⟩))
5049adantr 480 . . . . . . . 8 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → 𝐴 = (𝐴 substr ⟨0, 𝐿⟩))
5150adantr 480 . . . . . . 7 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) → 𝐴 = (𝐴 substr ⟨0, 𝐿⟩))
52513ad2ant1 1102 . . . . . 6 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) ∧ ¬ 𝑁𝐿 ∧ ¬ 𝐿 ≤ 0) → 𝐴 = (𝐴 substr ⟨0, 𝐿⟩))
5352oveq1d 6705 . . . . 5 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) ∧ ¬ 𝑁𝐿 ∧ ¬ 𝐿 ≤ 0) → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = ((𝐴 substr ⟨0, 𝐿⟩) ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))
5445, 53eqtrd 2685 . . . 4 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) ∧ ¬ 𝑁𝐿 ∧ ¬ 𝐿 ≤ 0) → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = ((𝐴 substr ⟨0, 𝐿⟩) ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))
5510, 44, 542if2 4169 . . 3 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), if(𝐿 ≤ 0, (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩), ((𝐴 substr ⟨0, 𝐿⟩) ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))))
568, 55eqtr4d 2688 . 2 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) → ((𝐴 ++ 𝐵) substr ⟨0, 𝑁⟩) = if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))))
5756ex 449 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 383  w3a 1054   = wceq 1523  wcel 2030  c0 3948  ifcif 4119  cop 4216   class class class wbr 4685  cfv 5926  (class class class)co 6690  0cc0 9974   + caddc 9977  cle 10113  cmin 10304  0cn0 11330  ...cfz 12364  #chash 13157  Word cword 13323   ++ cconcat 13325   substr csubstr 13327
This theorem was proved from axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1762  ax-4 1777  ax-5 1879  ax-6 1945  ax-7 1981  ax-8 2032  ax-9 2039  ax-10 2059  ax-11 2074  ax-12 2087  ax-13 2282  ax-ext 2631  ax-rep 4804  ax-sep 4814  ax-nul 4822  ax-pow 4873  ax-pr 4936  ax-un 6991  ax-cnex 10030  ax-resscn 10031  ax-1cn 10032  ax-icn 10033  ax-addcl 10034  ax-addrcl 10035  ax-mulcl 10036  ax-mulrcl 10037  ax-mulcom 10038  ax-addass 10039  ax-mulass 10040  ax-distr 10041  ax-i2m1 10042  ax-1ne0 10043  ax-1rid 10044  ax-rnegex 10045  ax-rrecex 10046  ax-cnre 10047  ax-pre-lttri 10048  ax-pre-lttrn 10049  ax-pre-ltadd 10050  ax-pre-mulgt0 10051
This theorem depends on definitions:  df-bi 197  df-or 384  df-an 385  df-3or 1055  df-3an 1056  df-tru 1526  df-ex 1745  df-nf 1750  df-sb 1938  df-eu 2502  df-mo 2503  df-clab 2638  df-cleq 2644  df-clel 2647  df-nfc 2782  df-ne 2824  df-nel 2927  df-ral 2946  df-rex 2947  df-reu 2948  df-rab 2950  df-v 3233  df-sbc 3469  df-csb 3567  df-dif 3610  df-un 3612  df-in 3614  df-ss 3621  df-pss 3623  df-nul 3949  df-if 4120  df-pw 4193  df-sn 4211  df-pr 4213  df-tp 4215  df-op 4217  df-uni 4469  df-int 4508  df-iun 4554  df-br 4686  df-opab 4746  df-mpt 4763  df-tr 4786  df-id 5053  df-eprel 5058  df-po 5064  df-so 5065  df-fr 5102  df-we 5104  df-xp 5149  df-rel 5150  df-cnv 5151  df-co 5152  df-dm 5153  df-rn 5154  df-res 5155  df-ima 5156  df-pred 5718  df-ord 5764  df-on 5765  df-lim 5766  df-suc 5767  df-iota 5889  df-fun 5928  df-fn 5929  df-f 5930  df-f1 5931  df-fo 5932  df-f1o 5933  df-fv 5934  df-riota 6651  df-ov 6693  df-oprab 6694  df-mpt2 6695  df-om 7108  df-1st 7210  df-2nd 7211  df-wrecs 7452  df-recs 7513  df-rdg 7551  df-1o 7605  df-oadd 7609  df-er 7787  df-en 7998  df-dom 7999  df-sdom 8000  df-fin 8001  df-card 8803  df-pnf 10114  df-mnf 10115  df-xr 10116  df-ltxr 10117  df-le 10118  df-sub 10306  df-neg 10307  df-nn 11059  df-n0 11331  df-z 11416  df-uz 11726  df-fz 12365  df-fzo 12505  df-hash 13158  df-word 13331  df-concat 13333  df-substr 13335
This theorem is referenced by:  swrdccatid  13543
  Copyright terms: Public domain W3C validator