Metamath Proof Explorer


Theorem revpfxsfxrev

Description: The reverse of a prefix of a word is equal to the same-length suffix of the reverse of that word. (Contributed by BTernaryTau, 2-Dec-2023)

Ref Expression
Assertion revpfxsfxrev W Word V L 0 W reverse W prefix L = reverse W substr W L W

Proof

Step Hyp Ref Expression
1 pfxcl W Word V W prefix L Word V
2 revcl W prefix L Word V reverse W prefix L Word V
3 wrdfn reverse W prefix L Word V reverse W prefix L Fn 0 ..^ reverse W prefix L
4 1 2 3 3syl W Word V reverse W prefix L Fn 0 ..^ reverse W prefix L
5 4 adantr W Word V L 0 W reverse W prefix L Fn 0 ..^ reverse W prefix L
6 revlen W prefix L Word V reverse W prefix L = W prefix L
7 1 6 syl W Word V reverse W prefix L = W prefix L
8 7 adantr W Word V L 0 W reverse W prefix L = W prefix L
9 pfxlen W Word V L 0 W W prefix L = L
10 8 9 eqtrd W Word V L 0 W reverse W prefix L = L
11 10 oveq2d W Word V L 0 W 0 ..^ reverse W prefix L = 0 ..^ L
12 11 fneq2d W Word V L 0 W reverse W prefix L Fn 0 ..^ reverse W prefix L reverse W prefix L Fn 0 ..^ L
13 5 12 mpbid W Word V L 0 W reverse W prefix L Fn 0 ..^ L
14 revcl W Word V reverse W Word V
15 swrdcl reverse W Word V reverse W substr W L W Word V
16 wrdfn reverse W substr W L W Word V reverse W substr W L W Fn 0 ..^ reverse W substr W L W
17 14 15 16 3syl W Word V reverse W substr W L W Fn 0 ..^ reverse W substr W L W
18 17 adantr W Word V L 0 W reverse W substr W L W Fn 0 ..^ reverse W substr W L W
19 fznn0sub2 L 0 W W L 0 W
20 lencl W Word V W 0
21 nn0fz0 W 0 W 0 W
22 20 21 sylib W Word V W 0 W
23 revlen W Word V reverse W = W
24 23 oveq2d W Word V 0 reverse W = 0 W
25 22 24 eleqtrrd W Word V W 0 reverse W
26 swrdlen reverse W Word V W L 0 W W 0 reverse W reverse W substr W L W = W W L
27 14 19 25 26 syl3an W Word V L 0 W W Word V reverse W substr W L W = W W L
28 27 3anidm13 W Word V L 0 W reverse W substr W L W = W W L
29 20 nn0cnd W Word V W
30 29 adantr W Word V L 0 W W
31 elfzelz L 0 W L
32 31 zcnd L 0 W L
33 32 adantl W Word V L 0 W L
34 30 33 nncand W Word V L 0 W W W L = L
35 28 34 eqtrd W Word V L 0 W reverse W substr W L W = L
36 35 oveq2d W Word V L 0 W 0 ..^ reverse W substr W L W = 0 ..^ L
37 36 fneq2d W Word V L 0 W reverse W substr W L W Fn 0 ..^ reverse W substr W L W reverse W substr W L W Fn 0 ..^ L
38 18 37 mpbid W Word V L 0 W reverse W substr W L W Fn 0 ..^ L
39 simp1 W Word V L 0 W x 0 ..^ L W Word V
40 simp3 W Word V L 0 W x 0 ..^ L x 0 ..^ L
41 9 oveq2d W Word V L 0 W 0 ..^ W prefix L = 0 ..^ L
42 41 3adant3 W Word V L 0 W x 0 ..^ L 0 ..^ W prefix L = 0 ..^ L
43 40 42 eleqtrrd W Word V L 0 W x 0 ..^ L x 0 ..^ W prefix L
44 revfv W prefix L Word V x 0 ..^ W prefix L reverse W prefix L x = W prefix L W prefix L - 1 - x
45 1 44 sylan W Word V x 0 ..^ W prefix L reverse W prefix L x = W prefix L W prefix L - 1 - x
46 39 43 45 syl2anc W Word V L 0 W x 0 ..^ L reverse W prefix L x = W prefix L W prefix L - 1 - x
47 9 oveq1d W Word V L 0 W W prefix L 1 = L 1
48 47 oveq1d W Word V L 0 W W prefix L - 1 - x = L - 1 - x
49 48 fveq2d W Word V L 0 W W prefix L W prefix L - 1 - x = W prefix L L - 1 - x
50 49 3adant3 W Word V L 0 W x 0 ..^ L W prefix L W prefix L - 1 - x = W prefix L L - 1 - x
51 32 3ad2ant2 W Word V L 0 W x 0 ..^ L L
52 elfzoelz x 0 ..^ L x
53 52 zcnd x 0 ..^ L x
54 53 3ad2ant3 W Word V L 0 W x 0 ..^ L x
55 1cnd W Word V L 0 W x 0 ..^ L 1
56 51 54 55 sub32d W Word V L 0 W x 0 ..^ L L - x - 1 = L - 1 - x
57 ubmelm1fzo x 0 ..^ L L - x - 1 0 ..^ L
58 57 3ad2ant3 W Word V L 0 W x 0 ..^ L L - x - 1 0 ..^ L
59 56 58 eqeltrrd W Word V L 0 W x 0 ..^ L L - 1 - x 0 ..^ L
60 pfxfv W Word V L 0 W L - 1 - x 0 ..^ L W prefix L L - 1 - x = W L - 1 - x
61 59 60 syld3an3 W Word V L 0 W x 0 ..^ L W prefix L L - 1 - x = W L - 1 - x
62 46 50 61 3eqtrd W Word V L 0 W x 0 ..^ L reverse W prefix L x = W L - 1 - x
63 34 oveq2d W Word V L 0 W 0 ..^ W W L = 0 ..^ L
64 63 eleq2d W Word V L 0 W x 0 ..^ W W L x 0 ..^ L
65 64 biimp3ar W Word V L 0 W x 0 ..^ L x 0 ..^ W W L
66 id W Word V W L 0 W W Word V W Word V W L 0 W W Word V
67 66 3anidm13 W Word V W L 0 W W Word V W L 0 W W Word V
68 swrdfv reverse W Word V W L 0 W W 0 reverse W x 0 ..^ W W L reverse W substr W L W x = reverse W x + W - L
69 14 68 syl3anl1 W Word V W L 0 W W 0 reverse W x 0 ..^ W W L reverse W substr W L W x = reverse W x + W - L
70 25 69 syl3anl3 W Word V W L 0 W W Word V x 0 ..^ W W L reverse W substr W L W x = reverse W x + W - L
71 67 70 stoic3 W Word V W L 0 W x 0 ..^ W W L reverse W substr W L W x = reverse W x + W - L
72 19 71 syl3an2 W Word V L 0 W x 0 ..^ W W L reverse W substr W L W x = reverse W x + W - L
73 65 72 syld3an3 W Word V L 0 W x 0 ..^ L reverse W substr W L W x = reverse W x + W - L
74 0z 0
75 elfzuz3 L 0 W W L
76 32 addid2d L 0 W 0 + L = L
77 76 fveq2d L 0 W 0 + L = L
78 75 77 eleqtrrd L 0 W W 0 + L
79 eluzsub 0 L W 0 + L W L 0
80 74 31 78 79 mp3an2i L 0 W W L 0
81 fzoss1 W L 0 W L ..^ W 0 ..^ W
82 80 81 syl L 0 W W L ..^ W 0 ..^ W
83 82 3ad2ant2 W Word V L 0 W x 0 ..^ L W L ..^ W 0 ..^ W
84 20 nn0zd W Word V W
85 84 3ad2ant1 W Word V L 0 W x 0 ..^ L W
86 31 3ad2ant2 W Word V L 0 W x 0 ..^ L L
87 85 86 zsubcld W Word V L 0 W x 0 ..^ L W L
88 fzo0addel x 0 ..^ L W L x + W - L W L ..^ L + W - L
89 40 87 88 syl2anc W Word V L 0 W x 0 ..^ L x + W - L W L ..^ L + W - L
90 30 3adant3 W Word V L 0 W x 0 ..^ L W
91 51 90 pncan3d W Word V L 0 W x 0 ..^ L L + W - L = W
92 91 oveq2d W Word V L 0 W x 0 ..^ L W L ..^ L + W - L = W L ..^ W
93 89 92 eleqtrd W Word V L 0 W x 0 ..^ L x + W - L W L ..^ W
94 83 93 sseldd W Word V L 0 W x 0 ..^ L x + W - L 0 ..^ W
95 revfv W Word V x + W - L 0 ..^ W reverse W x + W - L = W W - 1 - x + W - L
96 39 94 95 syl2anc W Word V L 0 W x 0 ..^ L reverse W x + W - L = W W - 1 - x + W - L
97 90 55 subcld W Word V L 0 W x 0 ..^ L W 1
98 87 zcnd W Word V L 0 W x 0 ..^ L W L
99 97 54 98 sub32d W Word V L 0 W x 0 ..^ L W 1 - x - W L = W 1 - W L - x
100 97 54 98 subsub4d W Word V L 0 W x 0 ..^ L W 1 - x - W L = W - 1 - x + W - L
101 90 55 98 sub32d W Word V L 0 W x 0 ..^ L W - 1 - W L = W - W L - 1
102 101 oveq1d W Word V L 0 W x 0 ..^ L W 1 - W L - x = W W L - 1 - x
103 99 100 102 3eqtr3d W Word V L 0 W x 0 ..^ L W - 1 - x + W - L = W W L - 1 - x
104 34 3adant3 W Word V L 0 W x 0 ..^ L W W L = L
105 104 oveq1d W Word V L 0 W x 0 ..^ L W - W L - 1 = L 1
106 105 oveq1d W Word V L 0 W x 0 ..^ L W W L - 1 - x = L - 1 - x
107 103 106 eqtrd W Word V L 0 W x 0 ..^ L W - 1 - x + W - L = L - 1 - x
108 107 fveq2d W Word V L 0 W x 0 ..^ L W W - 1 - x + W - L = W L - 1 - x
109 73 96 108 3eqtrd W Word V L 0 W x 0 ..^ L reverse W substr W L W x = W L - 1 - x
110 62 109 eqtr4d W Word V L 0 W x 0 ..^ L reverse W prefix L x = reverse W substr W L W x
111 110 3expa W Word V L 0 W x 0 ..^ L reverse W prefix L x = reverse W substr W L W x
112 13 38 111 eqfnfvd W Word V L 0 W reverse W prefix L = reverse W substr W L W