Metamath Proof Explorer


Theorem lenrevpfxcctswrd

Description: The length of the concatenation of the rest of a word and the prefix of the word is the length of the word. (Contributed by Alexander van der Vekens, 1-Apr-2018) (Revised by AV, 9-May-2020)

Ref Expression
Assertion lenrevpfxcctswrd ( ( 𝑊 ∈ Word 𝑉𝑀 ∈ ( 0 ... ( ♯ ‘ 𝑊 ) ) ) → ( ♯ ‘ ( ( 𝑊 substr ⟨ 𝑀 , ( ♯ ‘ 𝑊 ) ⟩ ) ++ ( 𝑊 prefix 𝑀 ) ) ) = ( ♯ ‘ 𝑊 ) )

Proof

Step Hyp Ref Expression
1 swrdcl ( 𝑊 ∈ Word 𝑉 → ( 𝑊 substr ⟨ 𝑀 , ( ♯ ‘ 𝑊 ) ⟩ ) ∈ Word 𝑉 )
2 pfxcl ( 𝑊 ∈ Word 𝑉 → ( 𝑊 prefix 𝑀 ) ∈ Word 𝑉 )
3 ccatlen ( ( ( 𝑊 substr ⟨ 𝑀 , ( ♯ ‘ 𝑊 ) ⟩ ) ∈ Word 𝑉 ∧ ( 𝑊 prefix 𝑀 ) ∈ Word 𝑉 ) → ( ♯ ‘ ( ( 𝑊 substr ⟨ 𝑀 , ( ♯ ‘ 𝑊 ) ⟩ ) ++ ( 𝑊 prefix 𝑀 ) ) ) = ( ( ♯ ‘ ( 𝑊 substr ⟨ 𝑀 , ( ♯ ‘ 𝑊 ) ⟩ ) ) + ( ♯ ‘ ( 𝑊 prefix 𝑀 ) ) ) )
4 1 2 3 syl2anc ( 𝑊 ∈ Word 𝑉 → ( ♯ ‘ ( ( 𝑊 substr ⟨ 𝑀 , ( ♯ ‘ 𝑊 ) ⟩ ) ++ ( 𝑊 prefix 𝑀 ) ) ) = ( ( ♯ ‘ ( 𝑊 substr ⟨ 𝑀 , ( ♯ ‘ 𝑊 ) ⟩ ) ) + ( ♯ ‘ ( 𝑊 prefix 𝑀 ) ) ) )
5 4 adantr ( ( 𝑊 ∈ Word 𝑉𝑀 ∈ ( 0 ... ( ♯ ‘ 𝑊 ) ) ) → ( ♯ ‘ ( ( 𝑊 substr ⟨ 𝑀 , ( ♯ ‘ 𝑊 ) ⟩ ) ++ ( 𝑊 prefix 𝑀 ) ) ) = ( ( ♯ ‘ ( 𝑊 substr ⟨ 𝑀 , ( ♯ ‘ 𝑊 ) ⟩ ) ) + ( ♯ ‘ ( 𝑊 prefix 𝑀 ) ) ) )
6 addlenrevpfx ( ( 𝑊 ∈ Word 𝑉𝑀 ∈ ( 0 ... ( ♯ ‘ 𝑊 ) ) ) → ( ( ♯ ‘ ( 𝑊 substr ⟨ 𝑀 , ( ♯ ‘ 𝑊 ) ⟩ ) ) + ( ♯ ‘ ( 𝑊 prefix 𝑀 ) ) ) = ( ♯ ‘ 𝑊 ) )
7 5 6 eqtrd ( ( 𝑊 ∈ Word 𝑉𝑀 ∈ ( 0 ... ( ♯ ‘ 𝑊 ) ) ) → ( ♯ ‘ ( ( 𝑊 substr ⟨ 𝑀 , ( ♯ ‘ 𝑊 ) ⟩ ) ++ ( 𝑊 prefix 𝑀 ) ) ) = ( ♯ ‘ 𝑊 ) )