Metamath Proof Explorer


Theorem metakunt8

Description: C is the left inverse for A. (Contributed by metakunt, 24-May-2024)

Ref Expression
Hypotheses metakunt8.1 ( 𝜑𝑀 ∈ ℕ )
metakunt8.2 ( 𝜑𝐼 ∈ ℕ )
metakunt8.3 ( 𝜑𝐼𝑀 )
metakunt8.4 𝐴 = ( 𝑥 ∈ ( 1 ... 𝑀 ) ↦ if ( 𝑥 = 𝐼 , 𝑀 , if ( 𝑥 < 𝐼 , 𝑥 , ( 𝑥 − 1 ) ) ) )
metakunt8.5 𝐶 = ( 𝑦 ∈ ( 1 ... 𝑀 ) ↦ if ( 𝑦 = 𝑀 , 𝐼 , if ( 𝑦 < 𝐼 , 𝑦 , ( 𝑦 + 1 ) ) ) )
metakunt8.6 ( 𝜑𝑋 ∈ ( 1 ... 𝑀 ) )
Assertion metakunt8 ( ( 𝜑𝐼 < 𝑋 ) → ( 𝐶 ‘ ( 𝐴𝑋 ) ) = 𝑋 )

Proof

Step Hyp Ref Expression
1 metakunt8.1 ( 𝜑𝑀 ∈ ℕ )
2 metakunt8.2 ( 𝜑𝐼 ∈ ℕ )
3 metakunt8.3 ( 𝜑𝐼𝑀 )
4 metakunt8.4 𝐴 = ( 𝑥 ∈ ( 1 ... 𝑀 ) ↦ if ( 𝑥 = 𝐼 , 𝑀 , if ( 𝑥 < 𝐼 , 𝑥 , ( 𝑥 − 1 ) ) ) )
5 metakunt8.5 𝐶 = ( 𝑦 ∈ ( 1 ... 𝑀 ) ↦ if ( 𝑦 = 𝑀 , 𝐼 , if ( 𝑦 < 𝐼 , 𝑦 , ( 𝑦 + 1 ) ) ) )
6 metakunt8.6 ( 𝜑𝑋 ∈ ( 1 ... 𝑀 ) )
7 5 a1i ( ( 𝜑𝐼 < 𝑋 ) → 𝐶 = ( 𝑦 ∈ ( 1 ... 𝑀 ) ↦ if ( 𝑦 = 𝑀 , 𝐼 , if ( 𝑦 < 𝐼 , 𝑦 , ( 𝑦 + 1 ) ) ) ) )
8 eqeq1 ( 𝑦 = ( 𝐴𝑋 ) → ( 𝑦 = 𝑀 ↔ ( 𝐴𝑋 ) = 𝑀 ) )
9 breq1 ( 𝑦 = ( 𝐴𝑋 ) → ( 𝑦 < 𝐼 ↔ ( 𝐴𝑋 ) < 𝐼 ) )
10 id ( 𝑦 = ( 𝐴𝑋 ) → 𝑦 = ( 𝐴𝑋 ) )
11 oveq1 ( 𝑦 = ( 𝐴𝑋 ) → ( 𝑦 + 1 ) = ( ( 𝐴𝑋 ) + 1 ) )
12 9 10 11 ifbieq12d ( 𝑦 = ( 𝐴𝑋 ) → if ( 𝑦 < 𝐼 , 𝑦 , ( 𝑦 + 1 ) ) = if ( ( 𝐴𝑋 ) < 𝐼 , ( 𝐴𝑋 ) , ( ( 𝐴𝑋 ) + 1 ) ) )
13 8 12 ifbieq2d ( 𝑦 = ( 𝐴𝑋 ) → if ( 𝑦 = 𝑀 , 𝐼 , if ( 𝑦 < 𝐼 , 𝑦 , ( 𝑦 + 1 ) ) ) = if ( ( 𝐴𝑋 ) = 𝑀 , 𝐼 , if ( ( 𝐴𝑋 ) < 𝐼 , ( 𝐴𝑋 ) , ( ( 𝐴𝑋 ) + 1 ) ) ) )
14 13 adantl ( ( ( 𝜑𝐼 < 𝑋 ) ∧ 𝑦 = ( 𝐴𝑋 ) ) → if ( 𝑦 = 𝑀 , 𝐼 , if ( 𝑦 < 𝐼 , 𝑦 , ( 𝑦 + 1 ) ) ) = if ( ( 𝐴𝑋 ) = 𝑀 , 𝐼 , if ( ( 𝐴𝑋 ) < 𝐼 , ( 𝐴𝑋 ) , ( ( 𝐴𝑋 ) + 1 ) ) ) )
15 1 2 3 4 5 6 metakunt7 ( ( 𝜑𝐼 < 𝑋 ) → ( ( 𝐴𝑋 ) = ( 𝑋 − 1 ) ∧ ¬ ( 𝐴𝑋 ) = 𝑀 ∧ ¬ ( 𝐴𝑋 ) < 𝐼 ) )
16 15 simp2d ( ( 𝜑𝐼 < 𝑋 ) → ¬ ( 𝐴𝑋 ) = 𝑀 )
17 iffalse ( ¬ ( 𝐴𝑋 ) = 𝑀 → if ( ( 𝐴𝑋 ) = 𝑀 , 𝐼 , if ( ( 𝐴𝑋 ) < 𝐼 , ( 𝐴𝑋 ) , ( ( 𝐴𝑋 ) + 1 ) ) ) = if ( ( 𝐴𝑋 ) < 𝐼 , ( 𝐴𝑋 ) , ( ( 𝐴𝑋 ) + 1 ) ) )
18 16 17 syl ( ( 𝜑𝐼 < 𝑋 ) → if ( ( 𝐴𝑋 ) = 𝑀 , 𝐼 , if ( ( 𝐴𝑋 ) < 𝐼 , ( 𝐴𝑋 ) , ( ( 𝐴𝑋 ) + 1 ) ) ) = if ( ( 𝐴𝑋 ) < 𝐼 , ( 𝐴𝑋 ) , ( ( 𝐴𝑋 ) + 1 ) ) )
19 15 simp3d ( ( 𝜑𝐼 < 𝑋 ) → ¬ ( 𝐴𝑋 ) < 𝐼 )
20 iffalse ( ¬ ( 𝐴𝑋 ) < 𝐼 → if ( ( 𝐴𝑋 ) < 𝐼 , ( 𝐴𝑋 ) , ( ( 𝐴𝑋 ) + 1 ) ) = ( ( 𝐴𝑋 ) + 1 ) )
21 19 20 syl ( ( 𝜑𝐼 < 𝑋 ) → if ( ( 𝐴𝑋 ) < 𝐼 , ( 𝐴𝑋 ) , ( ( 𝐴𝑋 ) + 1 ) ) = ( ( 𝐴𝑋 ) + 1 ) )
22 18 21 eqtrd ( ( 𝜑𝐼 < 𝑋 ) → if ( ( 𝐴𝑋 ) = 𝑀 , 𝐼 , if ( ( 𝐴𝑋 ) < 𝐼 , ( 𝐴𝑋 ) , ( ( 𝐴𝑋 ) + 1 ) ) ) = ( ( 𝐴𝑋 ) + 1 ) )
23 15 simp1d ( ( 𝜑𝐼 < 𝑋 ) → ( 𝐴𝑋 ) = ( 𝑋 − 1 ) )
24 23 oveq1d ( ( 𝜑𝐼 < 𝑋 ) → ( ( 𝐴𝑋 ) + 1 ) = ( ( 𝑋 − 1 ) + 1 ) )
25 elfznn ( 𝑋 ∈ ( 1 ... 𝑀 ) → 𝑋 ∈ ℕ )
26 6 25 syl ( 𝜑𝑋 ∈ ℕ )
27 26 nncnd ( 𝜑𝑋 ∈ ℂ )
28 1cnd ( 𝜑 → 1 ∈ ℂ )
29 27 28 npcand ( 𝜑 → ( ( 𝑋 − 1 ) + 1 ) = 𝑋 )
30 29 adantr ( ( 𝜑𝐼 < 𝑋 ) → ( ( 𝑋 − 1 ) + 1 ) = 𝑋 )
31 24 30 eqtrd ( ( 𝜑𝐼 < 𝑋 ) → ( ( 𝐴𝑋 ) + 1 ) = 𝑋 )
32 22 31 eqtrd ( ( 𝜑𝐼 < 𝑋 ) → if ( ( 𝐴𝑋 ) = 𝑀 , 𝐼 , if ( ( 𝐴𝑋 ) < 𝐼 , ( 𝐴𝑋 ) , ( ( 𝐴𝑋 ) + 1 ) ) ) = 𝑋 )
33 32 adantr ( ( ( 𝜑𝐼 < 𝑋 ) ∧ 𝑦 = ( 𝐴𝑋 ) ) → if ( ( 𝐴𝑋 ) = 𝑀 , 𝐼 , if ( ( 𝐴𝑋 ) < 𝐼 , ( 𝐴𝑋 ) , ( ( 𝐴𝑋 ) + 1 ) ) ) = 𝑋 )
34 14 33 eqtrd ( ( ( 𝜑𝐼 < 𝑋 ) ∧ 𝑦 = ( 𝐴𝑋 ) ) → if ( 𝑦 = 𝑀 , 𝐼 , if ( 𝑦 < 𝐼 , 𝑦 , ( 𝑦 + 1 ) ) ) = 𝑋 )
35 1 2 3 4 metakunt1 ( 𝜑𝐴 : ( 1 ... 𝑀 ) ⟶ ( 1 ... 𝑀 ) )
36 35 adantr ( ( 𝜑𝐼 < 𝑋 ) → 𝐴 : ( 1 ... 𝑀 ) ⟶ ( 1 ... 𝑀 ) )
37 6 adantr ( ( 𝜑𝐼 < 𝑋 ) → 𝑋 ∈ ( 1 ... 𝑀 ) )
38 36 37 ffvelrnd ( ( 𝜑𝐼 < 𝑋 ) → ( 𝐴𝑋 ) ∈ ( 1 ... 𝑀 ) )
39 7 34 38 37 fvmptd ( ( 𝜑𝐼 < 𝑋 ) → ( 𝐶 ‘ ( 𝐴𝑋 ) ) = 𝑋 )