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

Theorem swrdccat3a 13702
 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 12639 . . . . . 6 (𝑁 ∈ (0...(𝐿 + (♯‘𝐵))) → 𝑁 ∈ ℕ0)
2 0elfz 12643 . . . . . 6 (𝑁 ∈ ℕ0 → 0 ∈ (0...𝑁))
31, 2syl 17 . . . . 5 (𝑁 ∈ (0...(𝐿 + (♯‘𝐵))) → 0 ∈ (0...𝑁))
43ancri 531 . . . 4 (𝑁 ∈ (0...(𝐿 + (♯‘𝐵))) → (0 ∈ (0...𝑁) ∧ 𝑁 ∈ (0...(𝐿 + (♯‘𝐵)))))
5 swrdccatin12.l . . . . . 6 𝐿 = (♯‘𝐴)
65swrdccat3 13700 . . . . 5 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → ((0 ∈ (0...𝑁) ∧ 𝑁 ∈ (0...(𝐿 + (♯‘𝐵)))) → ((𝐴 ++ 𝐵) substr ⟨0, 𝑁⟩) = if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), if(𝐿 ≤ 0, (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩), ((𝐴 substr ⟨0, 𝐿⟩) ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))))))
76imp 393 . . . 4 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ (0 ∈ (0...𝑁) ∧ 𝑁 ∈ (0...(𝐿 + (♯‘𝐵))))) → ((𝐴 ++ 𝐵) substr ⟨0, 𝑁⟩) = if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), if(𝐿 ≤ 0, (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩), ((𝐴 substr ⟨0, 𝐿⟩) ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))))
84, 7sylan2 572 . . 3 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (♯‘𝐵)))) → ((𝐴 ++ 𝐵) substr ⟨0, 𝑁⟩) = if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), if(𝐿 ≤ 0, (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩), ((𝐴 substr ⟨0, 𝐿⟩) ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))))
9 iftrue 4229 . . . . 5 (𝑁𝐿 → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = (𝐴 substr ⟨0, 𝑁⟩))
109adantl 467 . . . 4 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (♯‘𝐵)))) ∧ 𝑁𝐿) → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = (𝐴 substr ⟨0, 𝑁⟩))
11 iffalse 4232 . . . . . 6 𝑁𝐿 → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))
12113ad2ant2 1127 . . . . 5 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (♯‘𝐵)))) ∧ ¬ 𝑁𝐿𝐿 ≤ 0) → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))
13 lencl 13519 . . . . . . . . . . . . 13 (𝐴 ∈ Word 𝑉 → (♯‘𝐴) ∈ ℕ0)
145, 13syl5eqel 2853 . . . . . . . . . . . 12 (𝐴 ∈ Word 𝑉𝐿 ∈ ℕ0)
15 nn0le0eq0 11522 . . . . . . . . . . . 12 (𝐿 ∈ ℕ0 → (𝐿 ≤ 0 ↔ 𝐿 = 0))
1614, 15syl 17 . . . . . . . . . . 11 (𝐴 ∈ Word 𝑉 → (𝐿 ≤ 0 ↔ 𝐿 = 0))
1716biimpd 219 . . . . . . . . . 10 (𝐴 ∈ Word 𝑉 → (𝐿 ≤ 0 → 𝐿 = 0))
1817adantr 466 . . . . . . . . 9 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → (𝐿 ≤ 0 → 𝐿 = 0))
195eqeq1i 2775 . . . . . . . . . . . . . . . 16 (𝐿 = 0 ↔ (♯‘𝐴) = 0)
2019biimpi 206 . . . . . . . . . . . . . . 15 (𝐿 = 0 → (♯‘𝐴) = 0)
21 hasheq0 13355 . . . . . . . . . . . . . . 15 (𝐴 ∈ Word 𝑉 → ((♯‘𝐴) = 0 ↔ 𝐴 = ∅))
2220, 21syl5ib 234 . . . . . . . . . . . . . 14 (𝐴 ∈ Word 𝑉 → (𝐿 = 0 → 𝐴 = ∅))
2322adantr 466 . . . . . . . . . . . . 13 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → (𝐿 = 0 → 𝐴 = ∅))
2423imp 393 . . . . . . . . . . . 12 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → 𝐴 = ∅)
25 0m0e0 11331 . . . . . . . . . . . . . . . 16 (0 − 0) = 0
26 oveq2 6800 . . . . . . . . . . . . . . . . 17 (0 = 𝐿 → (0 − 0) = (0 − 𝐿))
2726eqcoms 2778 . . . . . . . . . . . . . . . 16 (𝐿 = 0 → (0 − 0) = (0 − 𝐿))
2825, 27syl5eqr 2818 . . . . . . . . . . . . . . 15 (𝐿 = 0 → 0 = (0 − 𝐿))
2928adantl 467 . . . . . . . . . . . . . 14 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → 0 = (0 − 𝐿))
3029opeq1d 4543 . . . . . . . . . . . . 13 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → ⟨0, (𝑁𝐿)⟩ = ⟨(0 − 𝐿), (𝑁𝐿)⟩)
3130oveq2d 6808 . . . . . . . . . . . 12 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → (𝐵 substr ⟨0, (𝑁𝐿)⟩) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
3224, 31oveq12d 6810 . . . . . . . . . . 11 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (∅ ++ (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)))
33 swrdcl 13626 . . . . . . . . . . . . . 14 (𝐵 ∈ Word 𝑉 → (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩) ∈ Word 𝑉)
34 ccatlid 13567 . . . . . . . . . . . . . 14 ((𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩) ∈ Word 𝑉 → (∅ ++ (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
3533, 34syl 17 . . . . . . . . . . . . 13 (𝐵 ∈ Word 𝑉 → (∅ ++ (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
3635adantl 467 . . . . . . . . . . . 12 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → (∅ ++ (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
3736adantr 466 . . . . . . . . . . 11 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → (∅ ++ (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
3832, 37eqtrd 2804 . . . . . . . . . 10 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝐿 = 0) → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
3938ex 397 . . . . . . . . 9 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → (𝐿 = 0 → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)))
4018, 39syld 47 . . . . . . . 8 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → (𝐿 ≤ 0 → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)))
4140adantr 466 . . . . . . 7 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (♯‘𝐵)))) → (𝐿 ≤ 0 → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩)))
4241imp 393 . . . . . 6 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (♯‘𝐵)))) ∧ 𝐿 ≤ 0) → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
43423adant2 1124 . . . . 5 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (♯‘𝐵)))) ∧ ¬ 𝑁𝐿𝐿 ≤ 0) → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
4412, 43eqtrd 2804 . . . 4 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (♯‘𝐵)))) ∧ ¬ 𝑁𝐿𝐿 ≤ 0) → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩))
45113ad2ant2 1127 . . . . 5 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (♯‘𝐵)))) ∧ ¬ 𝑁𝐿 ∧ ¬ 𝐿 ≤ 0) → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))
465opeq2i 4541 . . . . . . . . . . 11 ⟨0, 𝐿⟩ = ⟨0, (♯‘𝐴)⟩
4746oveq2i 6803 . . . . . . . . . 10 (𝐴 substr ⟨0, 𝐿⟩) = (𝐴 substr ⟨0, (♯‘𝐴)⟩)
48 swrdid 13636 . . . . . . . . . 10 (𝐴 ∈ Word 𝑉 → (𝐴 substr ⟨0, (♯‘𝐴)⟩) = 𝐴)
4947, 48syl5req 2817 . . . . . . . . 9 (𝐴 ∈ Word 𝑉𝐴 = (𝐴 substr ⟨0, 𝐿⟩))
5049adantr 466 . . . . . . . 8 ((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) → 𝐴 = (𝐴 substr ⟨0, 𝐿⟩))
5150adantr 466 . . . . . . 7 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (♯‘𝐵)))) → 𝐴 = (𝐴 substr ⟨0, 𝐿⟩))
52513ad2ant1 1126 . . . . . 6 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (♯‘𝐵)))) ∧ ¬ 𝑁𝐿 ∧ ¬ 𝐿 ≤ 0) → 𝐴 = (𝐴 substr ⟨0, 𝐿⟩))
5352oveq1d 6807 . . . . 5 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (♯‘𝐵)))) ∧ ¬ 𝑁𝐿 ∧ ¬ 𝐿 ≤ 0) → (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)) = ((𝐴 substr ⟨0, 𝐿⟩) ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))
5445, 53eqtrd 2804 . . . 4 ((((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (♯‘𝐵)))) ∧ ¬ 𝑁𝐿 ∧ ¬ 𝐿 ≤ 0) → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = ((𝐴 substr ⟨0, 𝐿⟩) ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))
5510, 44, 542if2 4273 . . 3 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (♯‘𝐵)))) → if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))) = if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), if(𝐿 ≤ 0, (𝐵 substr ⟨(0 − 𝐿), (𝑁𝐿)⟩), ((𝐴 substr ⟨0, 𝐿⟩) ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩)))))
568, 55eqtr4d 2807 . 2 (((𝐴 ∈ Word 𝑉𝐵 ∈ Word 𝑉) ∧ 𝑁 ∈ (0...(𝐿 + (♯‘𝐵)))) → ((𝐴 ++ 𝐵) substr ⟨0, 𝑁⟩) = if(𝑁𝐿, (𝐴 substr ⟨0, 𝑁⟩), (𝐴 ++ (𝐵 substr ⟨0, (𝑁𝐿)⟩))))
5756ex 397 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 382   ∧ w3a 1070   = wceq 1630   ∈ wcel 2144  ∅c0 4061  ifcif 4223  ⟨cop 4320   class class class wbr 4784  ‘cfv 6031  (class class class)co 6792  0cc0 10137   + caddc 10140   ≤ cle 10276   − cmin 10467  ℕ0cn0 11493  ...cfz 12532  ♯chash 13320  Word cword 13486   ++ cconcat 13488   substr csubstr 13490 This theorem was proved from axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1869  ax-4 1884  ax-5 1990  ax-6 2056  ax-7 2092  ax-8 2146  ax-9 2153  ax-10 2173  ax-11 2189  ax-12 2202  ax-13 2407  ax-ext 2750  ax-rep 4902  ax-sep 4912  ax-nul 4920  ax-pow 4971  ax-pr 5034  ax-un 7095  ax-cnex 10193  ax-resscn 10194  ax-1cn 10195  ax-icn 10196  ax-addcl 10197  ax-addrcl 10198  ax-mulcl 10199  ax-mulrcl 10200  ax-mulcom 10201  ax-addass 10202  ax-mulass 10203  ax-distr 10204  ax-i2m1 10205  ax-1ne0 10206  ax-1rid 10207  ax-rnegex 10208  ax-rrecex 10209  ax-cnre 10210  ax-pre-lttri 10211  ax-pre-lttrn 10212  ax-pre-ltadd 10213  ax-pre-mulgt0 10214 This theorem depends on definitions:  df-bi 197  df-an 383  df-or 827  df-3or 1071  df-3an 1072  df-tru 1633  df-ex 1852  df-nf 1857  df-sb 2049  df-eu 2621  df-mo 2622  df-clab 2757  df-cleq 2763  df-clel 2766  df-nfc 2901  df-ne 2943  df-nel 3046  df-ral 3065  df-rex 3066  df-reu 3067  df-rab 3069  df-v 3351  df-sbc 3586  df-csb 3681  df-dif 3724  df-un 3726  df-in 3728  df-ss 3735  df-pss 3737  df-nul 4062  df-if 4224  df-pw 4297  df-sn 4315  df-pr 4317  df-tp 4319  df-op 4321  df-uni 4573  df-int 4610  df-iun 4654  df-br 4785  df-opab 4845  df-mpt 4862  df-tr 4885  df-id 5157  df-eprel 5162  df-po 5170  df-so 5171  df-fr 5208  df-we 5210  df-xp 5255  df-rel 5256  df-cnv 5257  df-co 5258  df-dm 5259  df-rn 5260  df-res 5261  df-ima 5262  df-pred 5823  df-ord 5869  df-on 5870  df-lim 5871  df-suc 5872  df-iota 5994  df-fun 6033  df-fn 6034  df-f 6035  df-f1 6036  df-fo 6037  df-f1o 6038  df-fv 6039  df-riota 6753  df-ov 6795  df-oprab 6796  df-mpt2 6797  df-om 7212  df-1st 7314  df-2nd 7315  df-wrecs 7558  df-recs 7620  df-rdg 7658  df-1o 7712  df-oadd 7716  df-er 7895  df-en 8109  df-dom 8110  df-sdom 8111  df-fin 8112  df-card 8964  df-pnf 10277  df-mnf 10278  df-xr 10279  df-ltxr 10280  df-le 10281  df-sub 10469  df-neg 10470  df-nn 11222  df-n0 11494  df-z 11579  df-uz 11888  df-fz 12533  df-fzo 12673  df-hash 13321  df-word 13494  df-concat 13496  df-substr 13498 This theorem is referenced by:  swrdccatid  13705
 Copyright terms: Public domain W3C validator