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

Theorem 2swrd1eqwrdeq 13392
Description: Two (nonempty) words are equal if and only if they have the same prefix and the same single symbol suffix. (Contributed by Alexander van der Vekens, 23-Sep-2018.) (Revised by Mario Carneiro/AV, 23-Oct-2018.)
Assertion
Ref Expression
2swrd1eqwrdeq ((𝑊 ∈ Word 𝑉𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑊)) → (𝑊 = 𝑈 ↔ ((#‘𝑊) = (#‘𝑈) ∧ ((𝑊 substr ⟨0, ((#‘𝑊) − 1)⟩) = (𝑈 substr ⟨0, ((#‘𝑊) − 1)⟩) ∧ ( lastS ‘𝑊) = ( lastS ‘𝑈)))))

Proof of Theorem 2swrd1eqwrdeq
StepHypRef Expression
1 lencl 13263 . . . . . . 7 (𝑊 ∈ Word 𝑉 → (#‘𝑊) ∈ ℕ0)
2 nn0z 11344 . . . . . . 7 ((#‘𝑊) ∈ ℕ0 → (#‘𝑊) ∈ ℤ)
3 elnnz 11331 . . . . . . . 8 ((#‘𝑊) ∈ ℕ ↔ ((#‘𝑊) ∈ ℤ ∧ 0 < (#‘𝑊)))
43simplbi2 654 . . . . . . 7 ((#‘𝑊) ∈ ℤ → (0 < (#‘𝑊) → (#‘𝑊) ∈ ℕ))
51, 2, 43syl 18 . . . . . 6 (𝑊 ∈ Word 𝑉 → (0 < (#‘𝑊) → (#‘𝑊) ∈ ℕ))
65a1d 25 . . . . 5 (𝑊 ∈ Word 𝑉 → (𝑈 ∈ Word 𝑉 → (0 < (#‘𝑊) → (#‘𝑊) ∈ ℕ)))
763imp 1254 . . . 4 ((𝑊 ∈ Word 𝑉𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑊)) → (#‘𝑊) ∈ ℕ)
8 fzo0end 12501 . . . 4 ((#‘𝑊) ∈ ℕ → ((#‘𝑊) − 1) ∈ (0..^(#‘𝑊)))
97, 8syl 17 . . 3 ((𝑊 ∈ Word 𝑉𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑊)) → ((#‘𝑊) − 1) ∈ (0..^(#‘𝑊)))
10 2swrdeqwrdeq 13391 . . 3 ((𝑊 ∈ Word 𝑉𝑈 ∈ Word 𝑉 ∧ ((#‘𝑊) − 1) ∈ (0..^(#‘𝑊))) → (𝑊 = 𝑈 ↔ ((#‘𝑊) = (#‘𝑈) ∧ ((𝑊 substr ⟨0, ((#‘𝑊) − 1)⟩) = (𝑈 substr ⟨0, ((#‘𝑊) − 1)⟩) ∧ (𝑊 substr ⟨((#‘𝑊) − 1), (#‘𝑊)⟩) = (𝑈 substr ⟨((#‘𝑊) − 1), (#‘𝑊)⟩)))))
119, 10syld3an3 1368 . 2 ((𝑊 ∈ Word 𝑉𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑊)) → (𝑊 = 𝑈 ↔ ((#‘𝑊) = (#‘𝑈) ∧ ((𝑊 substr ⟨0, ((#‘𝑊) − 1)⟩) = (𝑈 substr ⟨0, ((#‘𝑊) − 1)⟩) ∧ (𝑊 substr ⟨((#‘𝑊) − 1), (#‘𝑊)⟩) = (𝑈 substr ⟨((#‘𝑊) − 1), (#‘𝑊)⟩)))))
12 hashneq0 13095 . . . . . . . . . . 11 (𝑊 ∈ Word 𝑉 → (0 < (#‘𝑊) ↔ 𝑊 ≠ ∅))
1312biimpd 219 . . . . . . . . . 10 (𝑊 ∈ Word 𝑉 → (0 < (#‘𝑊) → 𝑊 ≠ ∅))
1413imdistani 725 . . . . . . . . 9 ((𝑊 ∈ Word 𝑉 ∧ 0 < (#‘𝑊)) → (𝑊 ∈ Word 𝑉𝑊 ≠ ∅))
15143adant2 1078 . . . . . . . 8 ((𝑊 ∈ Word 𝑉𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑊)) → (𝑊 ∈ Word 𝑉𝑊 ≠ ∅))
1615adantr 481 . . . . . . 7 (((𝑊 ∈ Word 𝑉𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑊)) ∧ (#‘𝑊) = (#‘𝑈)) → (𝑊 ∈ Word 𝑉𝑊 ≠ ∅))
17 swrdlsw 13390 . . . . . . 7 ((𝑊 ∈ Word 𝑉𝑊 ≠ ∅) → (𝑊 substr ⟨((#‘𝑊) − 1), (#‘𝑊)⟩) = ⟨“( lastS ‘𝑊)”⟩)
1816, 17syl 17 . . . . . 6 (((𝑊 ∈ Word 𝑉𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑊)) ∧ (#‘𝑊) = (#‘𝑈)) → (𝑊 substr ⟨((#‘𝑊) − 1), (#‘𝑊)⟩) = ⟨“( lastS ‘𝑊)”⟩)
19 breq2 4617 . . . . . . . . . 10 ((#‘𝑊) = (#‘𝑈) → (0 < (#‘𝑊) ↔ 0 < (#‘𝑈)))
20193anbi3d 1402 . . . . . . . . 9 ((#‘𝑊) = (#‘𝑈) → ((𝑊 ∈ Word 𝑉𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑊)) ↔ (𝑊 ∈ Word 𝑉𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑈))))
21 hashneq0 13095 . . . . . . . . . . . . 13 (𝑈 ∈ Word 𝑉 → (0 < (#‘𝑈) ↔ 𝑈 ≠ ∅))
2221biimpd 219 . . . . . . . . . . . 12 (𝑈 ∈ Word 𝑉 → (0 < (#‘𝑈) → 𝑈 ≠ ∅))
2322imdistani 725 . . . . . . . . . . 11 ((𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑈)) → (𝑈 ∈ Word 𝑉𝑈 ≠ ∅))
24233adant1 1077 . . . . . . . . . 10 ((𝑊 ∈ Word 𝑉𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑈)) → (𝑈 ∈ Word 𝑉𝑈 ≠ ∅))
25 swrdlsw 13390 . . . . . . . . . 10 ((𝑈 ∈ Word 𝑉𝑈 ≠ ∅) → (𝑈 substr ⟨((#‘𝑈) − 1), (#‘𝑈)⟩) = ⟨“( lastS ‘𝑈)”⟩)
2624, 25syl 17 . . . . . . . . 9 ((𝑊 ∈ Word 𝑉𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑈)) → (𝑈 substr ⟨((#‘𝑈) − 1), (#‘𝑈)⟩) = ⟨“( lastS ‘𝑈)”⟩)
2720, 26syl6bi 243 . . . . . . . 8 ((#‘𝑊) = (#‘𝑈) → ((𝑊 ∈ Word 𝑉𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑊)) → (𝑈 substr ⟨((#‘𝑈) − 1), (#‘𝑈)⟩) = ⟨“( lastS ‘𝑈)”⟩))
2827impcom 446 . . . . . . 7 (((𝑊 ∈ Word 𝑉𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑊)) ∧ (#‘𝑊) = (#‘𝑈)) → (𝑈 substr ⟨((#‘𝑈) − 1), (#‘𝑈)⟩) = ⟨“( lastS ‘𝑈)”⟩)
29 oveq1 6611 . . . . . . . . . . 11 ((#‘𝑊) = (#‘𝑈) → ((#‘𝑊) − 1) = ((#‘𝑈) − 1))
30 id 22 . . . . . . . . . . 11 ((#‘𝑊) = (#‘𝑈) → (#‘𝑊) = (#‘𝑈))
3129, 30opeq12d 4378 . . . . . . . . . 10 ((#‘𝑊) = (#‘𝑈) → ⟨((#‘𝑊) − 1), (#‘𝑊)⟩ = ⟨((#‘𝑈) − 1), (#‘𝑈)⟩)
3231oveq2d 6620 . . . . . . . . 9 ((#‘𝑊) = (#‘𝑈) → (𝑈 substr ⟨((#‘𝑊) − 1), (#‘𝑊)⟩) = (𝑈 substr ⟨((#‘𝑈) − 1), (#‘𝑈)⟩))
3332eqeq1d 2623 . . . . . . . 8 ((#‘𝑊) = (#‘𝑈) → ((𝑈 substr ⟨((#‘𝑊) − 1), (#‘𝑊)⟩) = ⟨“( lastS ‘𝑈)”⟩ ↔ (𝑈 substr ⟨((#‘𝑈) − 1), (#‘𝑈)⟩) = ⟨“( lastS ‘𝑈)”⟩))
3433adantl 482 . . . . . . 7 (((𝑊 ∈ Word 𝑉𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑊)) ∧ (#‘𝑊) = (#‘𝑈)) → ((𝑈 substr ⟨((#‘𝑊) − 1), (#‘𝑊)⟩) = ⟨“( lastS ‘𝑈)”⟩ ↔ (𝑈 substr ⟨((#‘𝑈) − 1), (#‘𝑈)⟩) = ⟨“( lastS ‘𝑈)”⟩))
3528, 34mpbird 247 . . . . . 6 (((𝑊 ∈ Word 𝑉𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑊)) ∧ (#‘𝑊) = (#‘𝑈)) → (𝑈 substr ⟨((#‘𝑊) − 1), (#‘𝑊)⟩) = ⟨“( lastS ‘𝑈)”⟩)
3618, 35eqeq12d 2636 . . . . 5 (((𝑊 ∈ Word 𝑉𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑊)) ∧ (#‘𝑊) = (#‘𝑈)) → ((𝑊 substr ⟨((#‘𝑊) − 1), (#‘𝑊)⟩) = (𝑈 substr ⟨((#‘𝑊) − 1), (#‘𝑊)⟩) ↔ ⟨“( lastS ‘𝑊)”⟩ = ⟨“( lastS ‘𝑈)”⟩))
37 hashgt0n0 13096 . . . . . . . . 9 ((𝑊 ∈ Word 𝑉 ∧ 0 < (#‘𝑊)) → 𝑊 ≠ ∅)
38 lswcl 13294 . . . . . . . . 9 ((𝑊 ∈ Word 𝑉𝑊 ≠ ∅) → ( lastS ‘𝑊) ∈ 𝑉)
3937, 38syldan 487 . . . . . . . 8 ((𝑊 ∈ Word 𝑉 ∧ 0 < (#‘𝑊)) → ( lastS ‘𝑊) ∈ 𝑉)
40393adant2 1078 . . . . . . 7 ((𝑊 ∈ Word 𝑉𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑊)) → ( lastS ‘𝑊) ∈ 𝑉)
4140adantr 481 . . . . . 6 (((𝑊 ∈ Word 𝑉𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑊)) ∧ (#‘𝑊) = (#‘𝑈)) → ( lastS ‘𝑊) ∈ 𝑉)
42 hashgt0n0 13096 . . . . . . . . . 10 ((𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑈)) → 𝑈 ≠ ∅)
43 lswcl 13294 . . . . . . . . . 10 ((𝑈 ∈ Word 𝑉𝑈 ≠ ∅) → ( lastS ‘𝑈) ∈ 𝑉)
4442, 43syldan 487 . . . . . . . . 9 ((𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑈)) → ( lastS ‘𝑈) ∈ 𝑉)
45443adant1 1077 . . . . . . . 8 ((𝑊 ∈ Word 𝑉𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑈)) → ( lastS ‘𝑈) ∈ 𝑉)
4620, 45syl6bi 243 . . . . . . 7 ((#‘𝑊) = (#‘𝑈) → ((𝑊 ∈ Word 𝑉𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑊)) → ( lastS ‘𝑈) ∈ 𝑉))
4746impcom 446 . . . . . 6 (((𝑊 ∈ Word 𝑉𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑊)) ∧ (#‘𝑊) = (#‘𝑈)) → ( lastS ‘𝑈) ∈ 𝑉)
48 s111 13334 . . . . . 6 ((( lastS ‘𝑊) ∈ 𝑉 ∧ ( lastS ‘𝑈) ∈ 𝑉) → (⟨“( lastS ‘𝑊)”⟩ = ⟨“( lastS ‘𝑈)”⟩ ↔ ( lastS ‘𝑊) = ( lastS ‘𝑈)))
4941, 47, 48syl2anc 692 . . . . 5 (((𝑊 ∈ Word 𝑉𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑊)) ∧ (#‘𝑊) = (#‘𝑈)) → (⟨“( lastS ‘𝑊)”⟩ = ⟨“( lastS ‘𝑈)”⟩ ↔ ( lastS ‘𝑊) = ( lastS ‘𝑈)))
5036, 49bitrd 268 . . . 4 (((𝑊 ∈ Word 𝑉𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑊)) ∧ (#‘𝑊) = (#‘𝑈)) → ((𝑊 substr ⟨((#‘𝑊) − 1), (#‘𝑊)⟩) = (𝑈 substr ⟨((#‘𝑊) − 1), (#‘𝑊)⟩) ↔ ( lastS ‘𝑊) = ( lastS ‘𝑈)))
5150anbi2d 739 . . 3 (((𝑊 ∈ Word 𝑉𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑊)) ∧ (#‘𝑊) = (#‘𝑈)) → (((𝑊 substr ⟨0, ((#‘𝑊) − 1)⟩) = (𝑈 substr ⟨0, ((#‘𝑊) − 1)⟩) ∧ (𝑊 substr ⟨((#‘𝑊) − 1), (#‘𝑊)⟩) = (𝑈 substr ⟨((#‘𝑊) − 1), (#‘𝑊)⟩)) ↔ ((𝑊 substr ⟨0, ((#‘𝑊) − 1)⟩) = (𝑈 substr ⟨0, ((#‘𝑊) − 1)⟩) ∧ ( lastS ‘𝑊) = ( lastS ‘𝑈))))
5251pm5.32da 672 . 2 ((𝑊 ∈ Word 𝑉𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑊)) → (((#‘𝑊) = (#‘𝑈) ∧ ((𝑊 substr ⟨0, ((#‘𝑊) − 1)⟩) = (𝑈 substr ⟨0, ((#‘𝑊) − 1)⟩) ∧ (𝑊 substr ⟨((#‘𝑊) − 1), (#‘𝑊)⟩) = (𝑈 substr ⟨((#‘𝑊) − 1), (#‘𝑊)⟩))) ↔ ((#‘𝑊) = (#‘𝑈) ∧ ((𝑊 substr ⟨0, ((#‘𝑊) − 1)⟩) = (𝑈 substr ⟨0, ((#‘𝑊) − 1)⟩) ∧ ( lastS ‘𝑊) = ( lastS ‘𝑈)))))
5311, 52bitrd 268 1 ((𝑊 ∈ Word 𝑉𝑈 ∈ Word 𝑉 ∧ 0 < (#‘𝑊)) → (𝑊 = 𝑈 ↔ ((#‘𝑊) = (#‘𝑈) ∧ ((𝑊 substr ⟨0, ((#‘𝑊) − 1)⟩) = (𝑈 substr ⟨0, ((#‘𝑊) − 1)⟩) ∧ ( lastS ‘𝑊) = ( lastS ‘𝑈)))))
Colors of variables: wff setvar class
Syntax hints:  wi 4  wb 196  wa 384  w3a 1036   = wceq 1480  wcel 1987  wne 2790  c0 3891  cop 4154   class class class wbr 4613  cfv 5847  (class class class)co 6604  0cc0 9880  1c1 9881   < clt 10018  cmin 10210  cn 10964  0cn0 11236  cz 11321  ..^cfzo 12406  #chash 13057  Word cword 13230   lastS clsw 13231  ⟨“cs1 13233   substr csubstr 13234
This theorem was proved from axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1719  ax-4 1734  ax-5 1836  ax-6 1885  ax-7 1932  ax-8 1989  ax-9 1996  ax-10 2016  ax-11 2031  ax-12 2044  ax-13 2245  ax-ext 2601  ax-rep 4731  ax-sep 4741  ax-nul 4749  ax-pow 4803  ax-pr 4867  ax-un 6902  ax-cnex 9936  ax-resscn 9937  ax-1cn 9938  ax-icn 9939  ax-addcl 9940  ax-addrcl 9941  ax-mulcl 9942  ax-mulrcl 9943  ax-mulcom 9944  ax-addass 9945  ax-mulass 9946  ax-distr 9947  ax-i2m1 9948  ax-1ne0 9949  ax-1rid 9950  ax-rnegex 9951  ax-rrecex 9952  ax-cnre 9953  ax-pre-lttri 9954  ax-pre-lttrn 9955  ax-pre-ltadd 9956  ax-pre-mulgt0 9957
This theorem depends on definitions:  df-bi 197  df-or 385  df-an 386  df-3or 1037  df-3an 1038  df-tru 1483  df-fal 1486  df-ex 1702  df-nf 1707  df-sb 1878  df-eu 2473  df-mo 2474  df-clab 2608  df-cleq 2614  df-clel 2617  df-nfc 2750  df-ne 2791  df-nel 2894  df-ral 2912  df-rex 2913  df-reu 2914  df-rab 2916  df-v 3188  df-sbc 3418  df-csb 3515  df-dif 3558  df-un 3560  df-in 3562  df-ss 3569  df-pss 3571  df-nul 3892  df-if 4059  df-pw 4132  df-sn 4149  df-pr 4151  df-tp 4153  df-op 4155  df-uni 4403  df-int 4441  df-iun 4487  df-br 4614  df-opab 4674  df-mpt 4675  df-tr 4713  df-eprel 4985  df-id 4989  df-po 4995  df-so 4996  df-fr 5033  df-we 5035  df-xp 5080  df-rel 5081  df-cnv 5082  df-co 5083  df-dm 5084  df-rn 5085  df-res 5086  df-ima 5087  df-pred 5639  df-ord 5685  df-on 5686  df-lim 5687  df-suc 5688  df-iota 5810  df-fun 5849  df-fn 5850  df-f 5851  df-f1 5852  df-fo 5853  df-f1o 5854  df-fv 5855  df-riota 6565  df-ov 6607  df-oprab 6608  df-mpt2 6609  df-om 7013  df-1st 7113  df-2nd 7114  df-wrecs 7352  df-recs 7413  df-rdg 7451  df-1o 7505  df-oadd 7509  df-er 7687  df-en 7900  df-dom 7901  df-sdom 7902  df-fin 7903  df-card 8709  df-pnf 10020  df-mnf 10021  df-xr 10022  df-ltxr 10023  df-le 10024  df-sub 10212  df-neg 10213  df-nn 10965  df-n0 11237  df-xnn0 11308  df-z 11322  df-uz 11632  df-fz 12269  df-fzo 12407  df-hash 13058  df-word 13238  df-lsw 13239  df-s1 13241  df-substr 13242
This theorem is referenced by:  wwlksnextinj  26663  clwwlksf1  26783
  Copyright terms: Public domain W3C validator