Mathbox for Alexander van der Vekens < Previous   Next > Nearby theorems Mirrors  >  Home  >  MPE Home  >  Th. List  >   Mathboxes  >  cshword2 Structured version   Visualization version   GIF version

Theorem cshword2 40757
 Description: Perform a cyclical shift for a word. (Contributed by AV, 11-May-2020.)
Assertion
Ref Expression
cshword2 ((𝑊 ∈ Word 𝑉𝑁 ∈ ℤ) → (𝑊 cyclShift 𝑁) = ((𝑊 substr ⟨(𝑁 mod (#‘𝑊)), (#‘𝑊)⟩) ++ (𝑊 prefix (𝑁 mod (#‘𝑊)))))

Proof of Theorem cshword2
Dummy variables 𝑙 𝑤 are mutually distinct and distinct from all other variables.
StepHypRef Expression
1 iswrd 13253 . . . . 5 (𝑊 ∈ Word 𝑉 ↔ ∃𝑙 ∈ ℕ0 𝑊:(0..^𝑙)⟶𝑉)
2 ffn 6007 . . . . . 6 (𝑊:(0..^𝑙)⟶𝑉𝑊 Fn (0..^𝑙))
32reximi 3006 . . . . 5 (∃𝑙 ∈ ℕ0 𝑊:(0..^𝑙)⟶𝑉 → ∃𝑙 ∈ ℕ0 𝑊 Fn (0..^𝑙))
41, 3sylbi 207 . . . 4 (𝑊 ∈ Word 𝑉 → ∃𝑙 ∈ ℕ0 𝑊 Fn (0..^𝑙))
5 fneq1 5942 . . . . . 6 (𝑤 = 𝑊 → (𝑤 Fn (0..^𝑙) ↔ 𝑊 Fn (0..^𝑙)))
65rexbidv 3046 . . . . 5 (𝑤 = 𝑊 → (∃𝑙 ∈ ℕ0 𝑤 Fn (0..^𝑙) ↔ ∃𝑙 ∈ ℕ0 𝑊 Fn (0..^𝑙)))
76elabg 3338 . . . 4 (𝑊 ∈ Word 𝑉 → (𝑊 ∈ {𝑤 ∣ ∃𝑙 ∈ ℕ0 𝑤 Fn (0..^𝑙)} ↔ ∃𝑙 ∈ ℕ0 𝑊 Fn (0..^𝑙)))
84, 7mpbird 247 . . 3 (𝑊 ∈ Word 𝑉𝑊 ∈ {𝑤 ∣ ∃𝑙 ∈ ℕ0 𝑤 Fn (0..^𝑙)})
9 cshfn 13480 . . 3 ((𝑊 ∈ {𝑤 ∣ ∃𝑙 ∈ ℕ0 𝑤 Fn (0..^𝑙)} ∧ 𝑁 ∈ ℤ) → (𝑊 cyclShift 𝑁) = if(𝑊 = ∅, ∅, ((𝑊 substr ⟨(𝑁 mod (#‘𝑊)), (#‘𝑊)⟩) ++ (𝑊 substr ⟨0, (𝑁 mod (#‘𝑊))⟩))))
108, 9sylan 488 . 2 ((𝑊 ∈ Word 𝑉𝑁 ∈ ℤ) → (𝑊 cyclShift 𝑁) = if(𝑊 = ∅, ∅, ((𝑊 substr ⟨(𝑁 mod (#‘𝑊)), (#‘𝑊)⟩) ++ (𝑊 substr ⟨0, (𝑁 mod (#‘𝑊))⟩))))
11 iftrue 4069 . . . . 5 (𝑊 = ∅ → if(𝑊 = ∅, ∅, ((𝑊 substr ⟨(𝑁 mod (#‘𝑊)), (#‘𝑊)⟩) ++ (𝑊 substr ⟨0, (𝑁 mod (#‘𝑊))⟩))) = ∅)
1211adantr 481 . . . 4 ((𝑊 = ∅ ∧ (𝑊 ∈ Word 𝑉𝑁 ∈ ℤ)) → if(𝑊 = ∅, ∅, ((𝑊 substr ⟨(𝑁 mod (#‘𝑊)), (#‘𝑊)⟩) ++ (𝑊 substr ⟨0, (𝑁 mod (#‘𝑊))⟩))) = ∅)
13 oveq1 6617 . . . . . . . 8 (𝑊 = ∅ → (𝑊 substr ⟨(𝑁 mod (#‘𝑊)), (#‘𝑊)⟩) = (∅ substr ⟨(𝑁 mod (#‘𝑊)), (#‘𝑊)⟩))
14 swrd0 13379 . . . . . . . 8 (∅ substr ⟨(𝑁 mod (#‘𝑊)), (#‘𝑊)⟩) = ∅
1513, 14syl6eq 2671 . . . . . . 7 (𝑊 = ∅ → (𝑊 substr ⟨(𝑁 mod (#‘𝑊)), (#‘𝑊)⟩) = ∅)
16 oveq1 6617 . . . . . . . 8 (𝑊 = ∅ → (𝑊 prefix (𝑁 mod (#‘𝑊))) = (∅ prefix (𝑁 mod (#‘𝑊))))
17 pfx0 40705 . . . . . . . 8 (∅ prefix (𝑁 mod (#‘𝑊))) = ∅
1816, 17syl6eq 2671 . . . . . . 7 (𝑊 = ∅ → (𝑊 prefix (𝑁 mod (#‘𝑊))) = ∅)
1915, 18oveq12d 6628 . . . . . 6 (𝑊 = ∅ → ((𝑊 substr ⟨(𝑁 mod (#‘𝑊)), (#‘𝑊)⟩) ++ (𝑊 prefix (𝑁 mod (#‘𝑊)))) = (∅ ++ ∅))
2019adantr 481 . . . . 5 ((𝑊 = ∅ ∧ (𝑊 ∈ Word 𝑉𝑁 ∈ ℤ)) → ((𝑊 substr ⟨(𝑁 mod (#‘𝑊)), (#‘𝑊)⟩) ++ (𝑊 prefix (𝑁 mod (#‘𝑊)))) = (∅ ++ ∅))
21 wrd0 13276 . . . . . 6 ∅ ∈ Word V
22 ccatrid 13316 . . . . . 6 (∅ ∈ Word V → (∅ ++ ∅) = ∅)
2321, 22ax-mp 5 . . . . 5 (∅ ++ ∅) = ∅
2420, 23syl6req 2672 . . . 4 ((𝑊 = ∅ ∧ (𝑊 ∈ Word 𝑉𝑁 ∈ ℤ)) → ∅ = ((𝑊 substr ⟨(𝑁 mod (#‘𝑊)), (#‘𝑊)⟩) ++ (𝑊 prefix (𝑁 mod (#‘𝑊)))))
2512, 24eqtrd 2655 . . 3 ((𝑊 = ∅ ∧ (𝑊 ∈ Word 𝑉𝑁 ∈ ℤ)) → if(𝑊 = ∅, ∅, ((𝑊 substr ⟨(𝑁 mod (#‘𝑊)), (#‘𝑊)⟩) ++ (𝑊 substr ⟨0, (𝑁 mod (#‘𝑊))⟩))) = ((𝑊 substr ⟨(𝑁 mod (#‘𝑊)), (#‘𝑊)⟩) ++ (𝑊 prefix (𝑁 mod (#‘𝑊)))))
26 iffalse 4072 . . . . 5 𝑊 = ∅ → if(𝑊 = ∅, ∅, ((𝑊 substr ⟨(𝑁 mod (#‘𝑊)), (#‘𝑊)⟩) ++ (𝑊 substr ⟨0, (𝑁 mod (#‘𝑊))⟩))) = ((𝑊 substr ⟨(𝑁 mod (#‘𝑊)), (#‘𝑊)⟩) ++ (𝑊 substr ⟨0, (𝑁 mod (#‘𝑊))⟩)))
2726adantr 481 . . . 4 ((¬ 𝑊 = ∅ ∧ (𝑊 ∈ Word 𝑉𝑁 ∈ ℤ)) → if(𝑊 = ∅, ∅, ((𝑊 substr ⟨(𝑁 mod (#‘𝑊)), (#‘𝑊)⟩) ++ (𝑊 substr ⟨0, (𝑁 mod (#‘𝑊))⟩))) = ((𝑊 substr ⟨(𝑁 mod (#‘𝑊)), (#‘𝑊)⟩) ++ (𝑊 substr ⟨0, (𝑁 mod (#‘𝑊))⟩)))
28 simprl 793 . . . . . . 7 ((¬ 𝑊 = ∅ ∧ (𝑊 ∈ Word 𝑉𝑁 ∈ ℤ)) → 𝑊 ∈ Word 𝑉)
29 simprr 795 . . . . . . . 8 ((¬ 𝑊 = ∅ ∧ (𝑊 ∈ Word 𝑉𝑁 ∈ ℤ)) → 𝑁 ∈ ℤ)
30 df-ne 2791 . . . . . . . . . 10 (𝑊 ≠ ∅ ↔ ¬ 𝑊 = ∅)
31 lennncl 13271 . . . . . . . . . . . 12 ((𝑊 ∈ Word 𝑉𝑊 ≠ ∅) → (#‘𝑊) ∈ ℕ)
3231ex 450 . . . . . . . . . . 11 (𝑊 ∈ Word 𝑉 → (𝑊 ≠ ∅ → (#‘𝑊) ∈ ℕ))
3332adantr 481 . . . . . . . . . 10 ((𝑊 ∈ Word 𝑉𝑁 ∈ ℤ) → (𝑊 ≠ ∅ → (#‘𝑊) ∈ ℕ))
3430, 33syl5bir 233 . . . . . . . . 9 ((𝑊 ∈ Word 𝑉𝑁 ∈ ℤ) → (¬ 𝑊 = ∅ → (#‘𝑊) ∈ ℕ))
3534impcom 446 . . . . . . . 8 ((¬ 𝑊 = ∅ ∧ (𝑊 ∈ Word 𝑉𝑁 ∈ ℤ)) → (#‘𝑊) ∈ ℕ)
3629, 35zmodcld 12638 . . . . . . 7 ((¬ 𝑊 = ∅ ∧ (𝑊 ∈ Word 𝑉𝑁 ∈ ℤ)) → (𝑁 mod (#‘𝑊)) ∈ ℕ0)
37 pfxval 40703 . . . . . . 7 ((𝑊 ∈ Word 𝑉 ∧ (𝑁 mod (#‘𝑊)) ∈ ℕ0) → (𝑊 prefix (𝑁 mod (#‘𝑊))) = (𝑊 substr ⟨0, (𝑁 mod (#‘𝑊))⟩))
3828, 36, 37syl2anc 692 . . . . . 6 ((¬ 𝑊 = ∅ ∧ (𝑊 ∈ Word 𝑉𝑁 ∈ ℤ)) → (𝑊 prefix (𝑁 mod (#‘𝑊))) = (𝑊 substr ⟨0, (𝑁 mod (#‘𝑊))⟩))
3938eqcomd 2627 . . . . 5 ((¬ 𝑊 = ∅ ∧ (𝑊 ∈ Word 𝑉𝑁 ∈ ℤ)) → (𝑊 substr ⟨0, (𝑁 mod (#‘𝑊))⟩) = (𝑊 prefix (𝑁 mod (#‘𝑊))))
4039oveq2d 6626 . . . 4 ((¬ 𝑊 = ∅ ∧ (𝑊 ∈ Word 𝑉𝑁 ∈ ℤ)) → ((𝑊 substr ⟨(𝑁 mod (#‘𝑊)), (#‘𝑊)⟩) ++ (𝑊 substr ⟨0, (𝑁 mod (#‘𝑊))⟩)) = ((𝑊 substr ⟨(𝑁 mod (#‘𝑊)), (#‘𝑊)⟩) ++ (𝑊 prefix (𝑁 mod (#‘𝑊)))))
4127, 40eqtrd 2655 . . 3 ((¬ 𝑊 = ∅ ∧ (𝑊 ∈ Word 𝑉𝑁 ∈ ℤ)) → if(𝑊 = ∅, ∅, ((𝑊 substr ⟨(𝑁 mod (#‘𝑊)), (#‘𝑊)⟩) ++ (𝑊 substr ⟨0, (𝑁 mod (#‘𝑊))⟩))) = ((𝑊 substr ⟨(𝑁 mod (#‘𝑊)), (#‘𝑊)⟩) ++ (𝑊 prefix (𝑁 mod (#‘𝑊)))))
4225, 41pm2.61ian 830 . 2 ((𝑊 ∈ Word 𝑉𝑁 ∈ ℤ) → if(𝑊 = ∅, ∅, ((𝑊 substr ⟨(𝑁 mod (#‘𝑊)), (#‘𝑊)⟩) ++ (𝑊 substr ⟨0, (𝑁 mod (#‘𝑊))⟩))) = ((𝑊 substr ⟨(𝑁 mod (#‘𝑊)), (#‘𝑊)⟩) ++ (𝑊 prefix (𝑁 mod (#‘𝑊)))))
4310, 42eqtrd 2655 1 ((𝑊 ∈ Word 𝑉𝑁 ∈ ℤ) → (𝑊 cyclShift 𝑁) = ((𝑊 substr ⟨(𝑁 mod (#‘𝑊)), (#‘𝑊)⟩) ++ (𝑊 prefix (𝑁 mod (#‘𝑊)))))
 Colors of variables: wff setvar class Syntax hints:  ¬ wn 3   → wi 4   ∧ wa 384   = wceq 1480   ∈ wcel 1987  {cab 2607   ≠ wne 2790  ∃wrex 2908  Vcvv 3189  ∅c0 3896  ifcif 4063  ⟨cop 4159   Fn wfn 5847  ⟶wf 5848  ‘cfv 5852  (class class class)co 6610  0cc0 9887  ℕcn 10971  ℕ0cn0 11243  ℤcz 11328  ..^cfzo 12413   mod cmo 12615  #chash 13064  Word cword 13237   ++ cconcat 13239   substr csubstr 13241   cyclShift ccsh 13478   prefix cpfx 40701 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 4736  ax-sep 4746  ax-nul 4754  ax-pow 4808  ax-pr 4872  ax-un 6909  ax-cnex 9943  ax-resscn 9944  ax-1cn 9945  ax-icn 9946  ax-addcl 9947  ax-addrcl 9948  ax-mulcl 9949  ax-mulrcl 9950  ax-mulcom 9951  ax-addass 9952  ax-mulass 9953  ax-distr 9954  ax-i2m1 9955  ax-1ne0 9956  ax-1rid 9957  ax-rnegex 9958  ax-rrecex 9959  ax-cnre 9960  ax-pre-lttri 9961  ax-pre-lttrn 9962  ax-pre-ltadd 9963  ax-pre-mulgt0 9964  ax-pre-sup 9965 This theorem depends on definitions:  df-bi 197  df-or 385  df-an 386  df-3or 1037  df-3an 1038  df-tru 1483  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-rmo 2915  df-rab 2916  df-v 3191  df-sbc 3422  df-csb 3519  df-dif 3562  df-un 3564  df-in 3566  df-ss 3573  df-pss 3575  df-nul 3897  df-if 4064  df-pw 4137  df-sn 4154  df-pr 4156  df-tp 4158  df-op 4160  df-uni 4408  df-int 4446  df-iun 4492  df-br 4619  df-opab 4679  df-mpt 4680  df-tr 4718  df-eprel 4990  df-id 4994  df-po 5000  df-so 5001  df-fr 5038  df-we 5040  df-xp 5085  df-rel 5086  df-cnv 5087  df-co 5088  df-dm 5089  df-rn 5090  df-res 5091  df-ima 5092  df-pred 5644  df-ord 5690  df-on 5691  df-lim 5692  df-suc 5693  df-iota 5815  df-fun 5854  df-fn 5855  df-f 5856  df-f1 5857  df-fo 5858  df-f1o 5859  df-fv 5860  df-riota 6571  df-ov 6613  df-oprab 6614  df-mpt2 6615  df-om 7020  df-1st 7120  df-2nd 7121  df-wrecs 7359  df-recs 7420  df-rdg 7458  df-1o 7512  df-oadd 7516  df-er 7694  df-en 7907  df-dom 7908  df-sdom 7909  df-fin 7910  df-sup 8299  df-inf 8300  df-card 8716  df-pnf 10027  df-mnf 10028  df-xr 10029  df-ltxr 10030  df-le 10031  df-sub 10219  df-neg 10220  df-div 10636  df-nn 10972  df-n0 11244  df-z 11329  df-uz 11639  df-rp 11784  df-fz 12276  df-fzo 12414  df-fl 12540  df-mod 12616  df-hash 13065  df-word 13245  df-concat 13247  df-substr 13249  df-csh 13479  df-pfx 40702 This theorem is referenced by: (None)
 Copyright terms: Public domain W3C validator