Metamath Proof Explorer


Theorem pfxeq

Description: The prefixes of two words are equal iff they have the same length and the same symbols at each position. (Contributed by Alexander van der Vekens, 7-Aug-2018) (Revised by AV, 4-May-2020)

Ref Expression
Assertion pfxeq W Word V U Word V M 0 N 0 M W N U W prefix M = U prefix N M = N i 0 ..^ M W i = U i

Proof

Step Hyp Ref Expression
1 pfxcl W Word V W prefix M Word V
2 pfxcl U Word V U prefix N Word V
3 eqwrd W prefix M Word V U prefix N Word V W prefix M = U prefix N W prefix M = U prefix N i 0 ..^ W prefix M W prefix M i = U prefix N i
4 1 2 3 syl2an W Word V U Word V W prefix M = U prefix N W prefix M = U prefix N i 0 ..^ W prefix M W prefix M i = U prefix N i
5 4 3ad2ant2 M 0 N 0 W Word V U Word V M W N U W prefix M = U prefix N W prefix M = U prefix N i 0 ..^ W prefix M W prefix M i = U prefix N i
6 simp2l M 0 N 0 W Word V U Word V M W N U W Word V
7 simpl M 0 N 0 M 0
8 lencl W Word V W 0
9 8 adantr W Word V U Word V W 0
10 simpl M W N U M W
11 7 9 10 3anim123i M 0 N 0 W Word V U Word V M W N U M 0 W 0 M W
12 elfz2nn0 M 0 W M 0 W 0 M W
13 11 12 sylibr M 0 N 0 W Word V U Word V M W N U M 0 W
14 pfxlen W Word V M 0 W W prefix M = M
15 6 13 14 syl2anc M 0 N 0 W Word V U Word V M W N U W prefix M = M
16 simp2r M 0 N 0 W Word V U Word V M W N U U Word V
17 simpr M 0 N 0 N 0
18 lencl U Word V U 0
19 18 adantl W Word V U Word V U 0
20 simpr M W N U N U
21 17 19 20 3anim123i M 0 N 0 W Word V U Word V M W N U N 0 U 0 N U
22 elfz2nn0 N 0 U N 0 U 0 N U
23 21 22 sylibr M 0 N 0 W Word V U Word V M W N U N 0 U
24 pfxlen U Word V N 0 U U prefix N = N
25 16 23 24 syl2anc M 0 N 0 W Word V U Word V M W N U U prefix N = N
26 15 25 eqeq12d M 0 N 0 W Word V U Word V M W N U W prefix M = U prefix N M = N
27 26 anbi1d M 0 N 0 W Word V U Word V M W N U W prefix M = U prefix N i 0 ..^ W prefix M W prefix M i = U prefix N i M = N i 0 ..^ W prefix M W prefix M i = U prefix N i
28 15 adantr M 0 N 0 W Word V U Word V M W N U M = N W prefix M = M
29 28 oveq2d M 0 N 0 W Word V U Word V M W N U M = N 0 ..^ W prefix M = 0 ..^ M
30 29 raleqdv M 0 N 0 W Word V U Word V M W N U M = N i 0 ..^ W prefix M W prefix M i = U prefix N i i 0 ..^ M W prefix M i = U prefix N i
31 6 ad2antrr M 0 N 0 W Word V U Word V M W N U M = N i 0 ..^ M W Word V
32 13 ad2antrr M 0 N 0 W Word V U Word V M W N U M = N i 0 ..^ M M 0 W
33 simpr M 0 N 0 W Word V U Word V M W N U M = N i 0 ..^ M i 0 ..^ M
34 pfxfv W Word V M 0 W i 0 ..^ M W prefix M i = W i
35 31 32 33 34 syl3anc M 0 N 0 W Word V U Word V M W N U M = N i 0 ..^ M W prefix M i = W i
36 16 ad2antrr M 0 N 0 W Word V U Word V M W N U M = N i 0 ..^ M U Word V
37 23 ad2antrr M 0 N 0 W Word V U Word V M W N U M = N i 0 ..^ M N 0 U
38 oveq2 M = N 0 ..^ M = 0 ..^ N
39 38 eleq2d M = N i 0 ..^ M i 0 ..^ N
40 39 adantl M 0 N 0 W Word V U Word V M W N U M = N i 0 ..^ M i 0 ..^ N
41 40 biimpa M 0 N 0 W Word V U Word V M W N U M = N i 0 ..^ M i 0 ..^ N
42 pfxfv U Word V N 0 U i 0 ..^ N U prefix N i = U i
43 36 37 41 42 syl3anc M 0 N 0 W Word V U Word V M W N U M = N i 0 ..^ M U prefix N i = U i
44 35 43 eqeq12d M 0 N 0 W Word V U Word V M W N U M = N i 0 ..^ M W prefix M i = U prefix N i W i = U i
45 44 ralbidva M 0 N 0 W Word V U Word V M W N U M = N i 0 ..^ M W prefix M i = U prefix N i i 0 ..^ M W i = U i
46 30 45 bitrd M 0 N 0 W Word V U Word V M W N U M = N i 0 ..^ W prefix M W prefix M i = U prefix N i i 0 ..^ M W i = U i
47 46 pm5.32da M 0 N 0 W Word V U Word V M W N U M = N i 0 ..^ W prefix M W prefix M i = U prefix N i M = N i 0 ..^ M W i = U i
48 5 27 47 3bitrd M 0 N 0 W Word V U Word V M W N U W prefix M = U prefix N M = N i 0 ..^ M W i = U i
49 48 3com12 W Word V U Word V M 0 N 0 M W N U W prefix M = U prefix N M = N i 0 ..^ M W i = U i