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

Theorem swrdccat3a 13291
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 12257 . . . . . 6 (𝑁 ∈ (0...(𝐿 + (#‘𝐵))) → 𝑁 ∈ ℕ0)
2 0elfz 12260 . . . . . 6 (𝑁 ∈ ℕ0 → 0 ∈ (0...𝑁))
31, 2syl 17 . . . . 5 (𝑁 ∈ (0...(𝐿 + (#‘𝐵))) → 0 ∈ (0...𝑁))
43ancri 572 . . . 4 (𝑁 ∈ (0...(𝐿 + (#‘𝐵))) → (0 ∈ (0...𝑁) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))))
5 swrdccatin12.l . . . . . 6 𝐿 = (#‘𝐴)
65swrdccat3 13289 . . . . 5 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → ((0 ∈ (0...𝑁) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) → ((𝐴 ++ 𝐵) substr ⟨0, 𝑁⟩) = if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), if(𝐿 ≤ 0, (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩), ((𝐴 substr ⟨0, 𝐿⟩) ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))))))
76imp 443 . . . 4 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ (0 ∈ (0...𝑁) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵))))) → ((𝐴 ++ 𝐵) substr ⟨0, 𝑁⟩) = if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), if(𝐿 ≤ 0, (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩), ((𝐴 substr ⟨0, 𝐿⟩) ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))))
84, 7sylan2 489 . . 3 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) → ((𝐴 ++ 𝐵) substr ⟨0, 𝑁⟩) = if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), if(𝐿 ≤ 0, (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩), ((𝐴 substr ⟨0, 𝐿⟩) ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))))
9 iftrue 4041 . . . . 5 (𝑁𝐿 → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = (𝐴 substr ⟨0, 𝑁⟩))
109adantl 480 . . . 4 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) ∧ 𝑁𝐿) → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = (𝐴 substr ⟨0, 𝑁⟩))
11 iffalse 4044 . . . . . 6 𝑁𝐿 → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))
12113ad2ant2 1075 . . . . 5 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) ∧ ¬ 𝑁𝐿𝐿 ≤ 0) → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))
13 lencl 13125 . . . . . . . . . . . . 13 (𝐴 ∈ Word 𝑉 → (#‘𝐴) ∈ ℕ0)
145, 13syl5eqel 2691 . . . . . . . . . . . 12 (𝐴 ∈ Word 𝑉𝐿 ∈ ℕ0)
15 nn0le0eq0 11168 . . . . . . . . . . . 12 (𝐿 ∈ ℕ0 → (𝐿 ≤ 0 ↔ 𝐿 = 0))
1614, 15syl 17 . . . . . . . . . . 11 (𝐴 ∈ Word 𝑉 → (𝐿 ≤ 0 ↔ 𝐿 = 0))
1716biimpd 217 . . . . . . . . . 10 (𝐴 ∈ Word 𝑉 → (𝐿 ≤ 0 → 𝐿 = 0))
1817adantr 479 . . . . . . . . 9 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → (𝐿 ≤ 0 → 𝐿 = 0))
195eqeq1i 2614 . . . . . . . . . . . . . . . 16 (𝐿 = 0 ↔ (#‘𝐴) = 0)
2019biimpi 204 . . . . . . . . . . . . . . 15 (𝐿 = 0 → (#‘𝐴) = 0)
21 hasheq0 12967 . . . . . . . . . . . . . . 15 (𝐴 ∈ Word 𝑉 → ((#‘𝐴) = 0 ↔ 𝐴 = ∅))
2220, 21syl5ib 232 . . . . . . . . . . . . . 14 (𝐴 ∈ Word 𝑉 → (𝐿 = 0 → 𝐴 = ∅))
2322adantr 479 . . . . . . . . . . . . 13 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → (𝐿 = 0 → 𝐴 = ∅))
2423imp 443 . . . . . . . . . . . 12 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → 𝐴 = ∅)
25 0m0e0 10977 . . . . . . . . . . . . . . . 16 (0 − 0) = 0
26 oveq2 6535 . . . . . . . . . . . . . . . . 17 (0 = 𝐿 → (0 − 0) = (0 − 𝐿))
2726eqcoms 2617 . . . . . . . . . . . . . . . 16 (𝐿 = 0 → (0 − 0) = (0 − 𝐿))
2825, 27syl5eqr 2657 . . . . . . . . . . . . . . 15 (𝐿 = 0 → 0 = (0 − 𝐿))
2928adantl 480 . . . . . . . . . . . . . 14 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → 0 = (0 − 𝐿))
3029opeq1d 4340 . . . . . . . . . . . . 13 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → ⟨0, (𝑁𝐿)⟩ = ⟨(0 − 𝐿), (𝑁𝐿)⟩)
3130oveq2d 6543 . . . . . . . . . . . 12 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → (𝐵 substr ⟨0, (𝑁𝐿)⟩) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
3224, 31oveq12d 6545 . . . . . . . . . . 11 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (∅ ++ (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)))
33 swrdcl 13217 . . . . . . . . . . . . . 14 (𝐵 ∈ Word 𝑉 → (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩) ∈ Word 𝑉)
34 ccatlid 13168 . . . . . . . . . . . . . 14 ((𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩) ∈ Word 𝑉 → (∅ ++ (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
3533, 34syl 17 . . . . . . . . . . . . 13 (𝐵 ∈ Word 𝑉 → (∅ ++ (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
3635adantl 480 . . . . . . . . . . . 12 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → (∅ ++ (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
3736adantr 479 . . . . . . . . . . 11 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → (∅ ++ (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
3832, 37eqtrd 2643 . . . . . . . . . 10 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
3938ex 448 . . . . . . . . 9 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → (𝐿 = 0 → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)))
4018, 39syld 45 . . . . . . . 8 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → (𝐿 ≤ 0 → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)))
4140adantr 479 . . . . . . 7 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) → (𝐿 ≤ 0 → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)))
4241imp 443 . . . . . 6 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) ∧ 𝐿 ≤ 0) → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
43423adant2 1072 . . . . 5 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) ∧ ¬ 𝑁𝐿𝐿 ≤ 0) → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
4412, 43eqtrd 2643 . . . 4 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) ∧ ¬ 𝑁𝐿𝐿 ≤ 0) → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
45113ad2ant2 1075 . . . . 5 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) ∧ ¬ 𝑁𝐿 ∧ ¬ 𝐿 ≤ 0) → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))
465opeq2i 4338 . . . . . . . . . . 11 ⟨0, 𝐿⟩ = ⟨0, (#‘𝐴)⟩
4746oveq2i 6538 . . . . . . . . . 10 (𝐴 substr ⟨0, 𝐿⟩) = (𝐴 substr ⟨0, (#‘𝐴)⟩)
48 swrdid 13226 . . . . . . . . . 10 (𝐴 ∈ Word 𝑉 → (𝐴 substr ⟨0, (#‘𝐴)⟩) = 𝐴)
4947, 48syl5req 2656 . . . . . . . . 9 (𝐴 ∈ Word 𝑉𝐴 = (𝐴 substr ⟨0, 𝐿⟩))
5049adantr 479 . . . . . . . 8 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → 𝐴 = (𝐴 substr ⟨0, 𝐿⟩))
5150adantr 479 . . . . . . 7 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) → 𝐴 = (𝐴 substr ⟨0, 𝐿⟩))
52513ad2ant1 1074 . . . . . 6 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) ∧ ¬ 𝑁𝐿 ∧ ¬ 𝐿 ≤ 0) → 𝐴 = (𝐴 substr ⟨0, 𝐿⟩))
5352oveq1d 6542 . . . . 5 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) ∧ ¬ 𝑁𝐿 ∧ ¬ 𝐿 ≤ 0) → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = ((𝐴 substr ⟨0, 𝐿⟩) ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))
5445, 53eqtrd 2643 . . . 4 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) ∧ ¬ 𝑁𝐿 ∧ ¬ 𝐿 ≤ 0) → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = ((𝐴 substr ⟨0, 𝐿⟩) ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))
5510, 44, 542if2 4085 . . 3 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), if(𝐿 ≤ 0, (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩), ((𝐴 substr ⟨0, 𝐿⟩) ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))))
568, 55eqtr4d 2646 . 2 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (#‘𝐵)))) → ((𝐴 ++ 𝐵) substr ⟨0, 𝑁⟩) = if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))))
5756ex 448 1 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → (𝑁 ∈ (0...(𝐿 + (#‘𝐵))) → ((𝐴 ++ 𝐵) substr ⟨0, 𝑁⟩) = if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))))
Colors of variables: wff setvar class
Syntax hints:  ¬ wn 3  wi 4  wb 194  wa 382  w3a 1030   = wceq 1474  wcel 1976  c0 3873  ifcif 4035  cop 4130   class class class wbr 4577  cfv 5790  (class class class)co 6527  0cc0 9792   + caddc 9795  cle 9931  cmin 10117  0cn0 11139  ...cfz 12152  #chash 12934  Word cword 13092   ++ cconcat 13094   substr csubstr 13096
This theorem was proved from axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1712  ax-4 1727  ax-5 1826  ax-6 1874  ax-7 1921  ax-8 1978  ax-9 1985  ax-10 2005  ax-11 2020  ax-12 2033  ax-13 2233  ax-ext 2589  ax-rep 4693  ax-sep 4703  ax-nul 4712  ax-pow 4764  ax-pr 4828  ax-un 6824  ax-cnex 9848  ax-resscn 9849  ax-1cn 9850  ax-icn 9851  ax-addcl 9852  ax-addrcl 9853  ax-mulcl 9854  ax-mulrcl 9855  ax-mulcom 9856  ax-addass 9857  ax-mulass 9858  ax-distr 9859  ax-i2m1 9860  ax-1ne0 9861  ax-1rid 9862  ax-rnegex 9863  ax-rrecex 9864  ax-cnre 9865  ax-pre-lttri 9866  ax-pre-lttrn 9867  ax-pre-ltadd 9868  ax-pre-mulgt0 9869
This theorem depends on definitions:  df-bi 195  df-or 383  df-an 384  df-3or 1031  df-3an 1032  df-tru 1477  df-ex 1695  df-nf 1700  df-sb 1867  df-eu 2461  df-mo 2462  df-clab 2596  df-cleq 2602  df-clel 2605  df-nfc 2739  df-ne 2781  df-nel 2782  df-ral 2900  df-rex 2901  df-reu 2902  df-rab 2904  df-v 3174  df-sbc 3402  df-csb 3499  df-dif 3542  df-un 3544  df-in 3546  df-ss 3553  df-pss 3555  df-nul 3874  df-if 4036  df-pw 4109  df-sn 4125  df-pr 4127  df-tp 4129  df-op 4131  df-uni 4367  df-int 4405  df-iun 4451  df-br 4578  df-opab 4638  df-mpt 4639  df-tr 4675  df-eprel 4939  df-id 4943  df-po 4949  df-so 4950  df-fr 4987  df-we 4989  df-xp 5034  df-rel 5035  df-cnv 5036  df-co 5037  df-dm 5038  df-rn 5039  df-res 5040  df-ima 5041  df-pred 5583  df-ord 5629  df-on 5630  df-lim 5631  df-suc 5632  df-iota 5754  df-fun 5792  df-fn 5793  df-f 5794  df-f1 5795  df-fo 5796  df-f1o 5797  df-fv 5798  df-riota 6489  df-ov 6530  df-oprab 6531  df-mpt2 6532  df-om 6935  df-1st 7036  df-2nd 7037  df-wrecs 7271  df-recs 7332  df-rdg 7370  df-1o 7424  df-oadd 7428  df-er 7606  df-en 7819  df-dom 7820  df-sdom 7821  df-fin 7822  df-card 8625  df-pnf 9932  df-mnf 9933  df-xr 9934  df-ltxr 9935  df-le 9936  df-sub 10119  df-neg 10120  df-nn 10868  df-n0 11140  df-z 11211  df-uz 11520  df-fz 12153  df-fzo 12290  df-hash 12935  df-word 13100  df-concat 13102  df-substr 13104
This theorem is referenced by:  swrdccatid  13294
  Copyright terms: Public domain W3C validator