Metamath Proof Explorer


Theorem pfxlsw2ccat

Description: Reconstruct a word from its prefix and its last two symbols. (Contributed by Thierry Arnoux, 26-Sep-2023)

Ref Expression
Hypothesis pfxlsw2ccat.n N=W
Assertion pfxlsw2ccat WWordV2NW=WprefixN2++⟨“WN2WN1”⟩

Proof

Step Hyp Ref Expression
1 pfxlsw2ccat.n N=W
2 simpl WWordV2NWWordV
3 simpr WWordV2N2N
4 3 1 breqtrdi WWordV2N2W
5 wrdlenge2n0 WWordV2WW
6 2 4 5 syl2anc WWordV2NW
7 pfxlswccat WWordVWWprefixW1++⟨“lastSW”⟩=W
8 2 6 7 syl2anc WWordV2NWprefixW1++⟨“lastSW”⟩=W
9 lsw WWordVlastSW=WW1
10 1 oveq1i N1=W1
11 10 fveq2i WN1=WW1
12 9 11 eqtr4di WWordVlastSW=WN1
13 2 12 syl WWordV2NlastSW=WN1
14 13 s1eqd WWordV2N⟨“lastSW”⟩=⟨“WN1”⟩
15 14 oveq2d WWordV2NWprefixW1++⟨“lastSW”⟩=WprefixW1++⟨“WN1”⟩
16 8 15 eqtr3d WWordV2NW=WprefixW1++⟨“WN1”⟩
17 pfxcl WWordVWprefixW1WordV
18 2 17 syl WWordV2NWprefixW1WordV
19 lencl WWordVW0
20 2 19 syl WWordV2NW0
21 1 20 eqeltrid WWordV2NN0
22 nn0ge2m1nn N02NN1
23 21 3 22 syl2anc WWordV2NN1
24 10 23 eqeltrrid WWordV2NW1
25 20 nn0red WWordV2NW
26 25 lem1d WWordV2NW1W
27 pfxn0 WWordVW1W1WWprefixW1
28 2 24 26 27 syl3anc WWordV2NWprefixW1
29 pfxlswccat WprefixW1WordVWprefixW1WprefixW1prefixWprefixW11++⟨“lastSWprefixW1”⟩=WprefixW1
30 18 28 29 syl2anc WWordV2NWprefixW1prefixWprefixW11++⟨“lastSWprefixW1”⟩=WprefixW1
31 ige2m1fz W02WW10W
32 20 4 31 syl2anc WWordV2NW10W
33 pfxlen WWordVW10WWprefixW1=W1
34 2 32 33 syl2anc WWordV2NWprefixW1=W1
35 34 oveq1d WWordV2NWprefixW11=W-1-1
36 0zd WWordV2N0
37 nn0ge2m1nn0 N02NN10
38 21 3 37 syl2anc WWordV2NN10
39 10 38 eqeltrrid WWordV2NW10
40 39 nn0zd WWordV2NW1
41 1zzd WWordV2N1
42 40 41 zsubcld WWordV2NW-1-1
43 2nn0 20
44 43 a1i WWordV2N20
45 nn0sub 20N02NN20
46 45 biimpa 20N02NN20
47 44 21 3 46 syl21anc WWordV2NN20
48 47 nn0ge0d WWordV2N0N2
49 21 nn0cnd WWordV2NN
50 sub1m1 NN-1-1=N2
51 49 50 syl WWordV2NN-1-1=N2
52 48 51 breqtrrd WWordV2N0N-1-1
53 10 oveq1i N-1-1=W-1-1
54 52 53 breqtrdi WWordV2N0W-1-1
55 24 nnred WWordV2NW1
56 55 lem1d WWordV2NW-1-1W1
57 36 40 42 54 56 elfzd WWordV2NW-1-10W1
58 35 57 eqeltrd WWordV2NWprefixW110W1
59 pfxpfx WWordVW10WWprefixW110W1WprefixW1prefixWprefixW11=WprefixWprefixW11
60 2 32 58 59 syl3anc WWordV2NWprefixW1prefixWprefixW11=WprefixWprefixW11
61 34 10 eqtr4di WWordV2NWprefixW1=N1
62 61 oveq1d WWordV2NWprefixW11=N-1-1
63 62 51 eqtrd WWordV2NWprefixW11=N2
64 63 oveq2d WWordV2NWprefixWprefixW11=WprefixN2
65 60 64 eqtrd WWordV2NWprefixW1prefixWprefixW11=WprefixN2
66 pfxtrcfvl WWordV2WlastSWprefixW1=WW2
67 2 4 66 syl2anc WWordV2NlastSWprefixW1=WW2
68 1 a1i WWordV2NN=W
69 68 fvoveq1d WWordV2NWN2=WW2
70 67 69 eqtr4d WWordV2NlastSWprefixW1=WN2
71 70 s1eqd WWordV2N⟨“lastSWprefixW1”⟩=⟨“WN2”⟩
72 65 71 oveq12d WWordV2NWprefixW1prefixWprefixW11++⟨“lastSWprefixW1”⟩=WprefixN2++⟨“WN2”⟩
73 30 72 eqtr3d WWordV2NWprefixW1=WprefixN2++⟨“WN2”⟩
74 73 oveq1d WWordV2NWprefixW1++⟨“WN1”⟩=WprefixN2++⟨“WN2”⟩++⟨“WN1”⟩
75 pfxcl WWordVWprefixN2WordV
76 2 75 syl WWordV2NWprefixN2WordV
77 ccatw2s1ccatws2 WprefixN2WordVWprefixN2++⟨“WN2”⟩++⟨“WN1”⟩=WprefixN2++⟨“WN2WN1”⟩
78 76 77 syl WWordV2NWprefixN2++⟨“WN2”⟩++⟨“WN1”⟩=WprefixN2++⟨“WN2WN1”⟩
79 16 74 78 3eqtrd WWordV2NW=WprefixN2++⟨“WN2WN1”⟩