Metamath Proof Explorer


Theorem metakunt12

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

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

Proof

Step Hyp Ref Expression
1 metakunt12.1 ( 𝜑𝑀 ∈ ℕ )
2 metakunt12.2 ( 𝜑𝐼 ∈ ℕ )
3 metakunt12.3 ( 𝜑𝐼𝑀 )
4 metakunt12.4 𝐴 = ( 𝑥 ∈ ( 1 ... 𝑀 ) ↦ if ( 𝑥 = 𝐼 , 𝑀 , if ( 𝑥 < 𝐼 , 𝑥 , ( 𝑥 − 1 ) ) ) )
5 metakunt12.5 𝐶 = ( 𝑦 ∈ ( 1 ... 𝑀 ) ↦ if ( 𝑦 = 𝑀 , 𝐼 , if ( 𝑦 < 𝐼 , 𝑦 , ( 𝑦 + 1 ) ) ) )
6 metakunt12.6 ( 𝜑𝑋 ∈ ( 1 ... 𝑀 ) )
7 ioran ( ¬ ( 𝑋 = 𝑀𝑋 < 𝐼 ) ↔ ( ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) )
8 4 a1i ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → 𝐴 = ( 𝑥 ∈ ( 1 ... 𝑀 ) ↦ if ( 𝑥 = 𝐼 , 𝑀 , if ( 𝑥 < 𝐼 , 𝑥 , ( 𝑥 − 1 ) ) ) ) )
9 eqeq1 ( 𝑥 = ( 𝐶𝑋 ) → ( 𝑥 = 𝐼 ↔ ( 𝐶𝑋 ) = 𝐼 ) )
10 breq1 ( 𝑥 = ( 𝐶𝑋 ) → ( 𝑥 < 𝐼 ↔ ( 𝐶𝑋 ) < 𝐼 ) )
11 id ( 𝑥 = ( 𝐶𝑋 ) → 𝑥 = ( 𝐶𝑋 ) )
12 oveq1 ( 𝑥 = ( 𝐶𝑋 ) → ( 𝑥 − 1 ) = ( ( 𝐶𝑋 ) − 1 ) )
13 10 11 12 ifbieq12d ( 𝑥 = ( 𝐶𝑋 ) → if ( 𝑥 < 𝐼 , 𝑥 , ( 𝑥 − 1 ) ) = if ( ( 𝐶𝑋 ) < 𝐼 , ( 𝐶𝑋 ) , ( ( 𝐶𝑋 ) − 1 ) ) )
14 9 13 ifbieq2d ( 𝑥 = ( 𝐶𝑋 ) → if ( 𝑥 = 𝐼 , 𝑀 , if ( 𝑥 < 𝐼 , 𝑥 , ( 𝑥 − 1 ) ) ) = if ( ( 𝐶𝑋 ) = 𝐼 , 𝑀 , if ( ( 𝐶𝑋 ) < 𝐼 , ( 𝐶𝑋 ) , ( ( 𝐶𝑋 ) − 1 ) ) ) )
15 14 adantl ( ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) ∧ 𝑥 = ( 𝐶𝑋 ) ) → if ( 𝑥 = 𝐼 , 𝑀 , if ( 𝑥 < 𝐼 , 𝑥 , ( 𝑥 − 1 ) ) ) = if ( ( 𝐶𝑋 ) = 𝐼 , 𝑀 , if ( ( 𝐶𝑋 ) < 𝐼 , ( 𝐶𝑋 ) , ( ( 𝐶𝑋 ) − 1 ) ) ) )
16 5 a1i ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → 𝐶 = ( 𝑦 ∈ ( 1 ... 𝑀 ) ↦ if ( 𝑦 = 𝑀 , 𝐼 , if ( 𝑦 < 𝐼 , 𝑦 , ( 𝑦 + 1 ) ) ) ) )
17 eqeq1 ( 𝑦 = 𝑋 → ( 𝑦 = 𝑀𝑋 = 𝑀 ) )
18 breq1 ( 𝑦 = 𝑋 → ( 𝑦 < 𝐼𝑋 < 𝐼 ) )
19 id ( 𝑦 = 𝑋𝑦 = 𝑋 )
20 oveq1 ( 𝑦 = 𝑋 → ( 𝑦 + 1 ) = ( 𝑋 + 1 ) )
21 18 19 20 ifbieq12d ( 𝑦 = 𝑋 → if ( 𝑦 < 𝐼 , 𝑦 , ( 𝑦 + 1 ) ) = if ( 𝑋 < 𝐼 , 𝑋 , ( 𝑋 + 1 ) ) )
22 17 21 ifbieq2d ( 𝑦 = 𝑋 → if ( 𝑦 = 𝑀 , 𝐼 , if ( 𝑦 < 𝐼 , 𝑦 , ( 𝑦 + 1 ) ) ) = if ( 𝑋 = 𝑀 , 𝐼 , if ( 𝑋 < 𝐼 , 𝑋 , ( 𝑋 + 1 ) ) ) )
23 22 adantl ( ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) ∧ 𝑦 = 𝑋 ) → if ( 𝑦 = 𝑀 , 𝐼 , if ( 𝑦 < 𝐼 , 𝑦 , ( 𝑦 + 1 ) ) ) = if ( 𝑋 = 𝑀 , 𝐼 , if ( 𝑋 < 𝐼 , 𝑋 , ( 𝑋 + 1 ) ) ) )
24 simp2 ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → ¬ 𝑋 = 𝑀 )
25 iffalse ( ¬ 𝑋 = 𝑀 → if ( 𝑋 = 𝑀 , 𝐼 , if ( 𝑋 < 𝐼 , 𝑋 , ( 𝑋 + 1 ) ) ) = if ( 𝑋 < 𝐼 , 𝑋 , ( 𝑋 + 1 ) ) )
26 24 25 syl ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → if ( 𝑋 = 𝑀 , 𝐼 , if ( 𝑋 < 𝐼 , 𝑋 , ( 𝑋 + 1 ) ) ) = if ( 𝑋 < 𝐼 , 𝑋 , ( 𝑋 + 1 ) ) )
27 simp3 ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → ¬ 𝑋 < 𝐼 )
28 iffalse ( ¬ 𝑋 < 𝐼 → if ( 𝑋 < 𝐼 , 𝑋 , ( 𝑋 + 1 ) ) = ( 𝑋 + 1 ) )
29 27 28 syl ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → if ( 𝑋 < 𝐼 , 𝑋 , ( 𝑋 + 1 ) ) = ( 𝑋 + 1 ) )
30 26 29 eqtrd ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → if ( 𝑋 = 𝑀 , 𝐼 , if ( 𝑋 < 𝐼 , 𝑋 , ( 𝑋 + 1 ) ) ) = ( 𝑋 + 1 ) )
31 30 adantr ( ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) ∧ 𝑦 = 𝑋 ) → if ( 𝑋 = 𝑀 , 𝐼 , if ( 𝑋 < 𝐼 , 𝑋 , ( 𝑋 + 1 ) ) ) = ( 𝑋 + 1 ) )
32 23 31 eqtrd ( ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) ∧ 𝑦 = 𝑋 ) → if ( 𝑦 = 𝑀 , 𝐼 , if ( 𝑦 < 𝐼 , 𝑦 , ( 𝑦 + 1 ) ) ) = ( 𝑋 + 1 ) )
33 6 3ad2ant1 ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → 𝑋 ∈ ( 1 ... 𝑀 ) )
34 6 elfzelzd ( 𝜑𝑋 ∈ ℤ )
35 34 3ad2ant1 ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → 𝑋 ∈ ℤ )
36 35 peano2zd ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → ( 𝑋 + 1 ) ∈ ℤ )
37 16 32 33 36 fvmptd ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → ( 𝐶𝑋 ) = ( 𝑋 + 1 ) )
38 eqeq1 ( ( 𝐶𝑋 ) = ( 𝑋 + 1 ) → ( ( 𝐶𝑋 ) = 𝐼 ↔ ( 𝑋 + 1 ) = 𝐼 ) )
39 breq1 ( ( 𝐶𝑋 ) = ( 𝑋 + 1 ) → ( ( 𝐶𝑋 ) < 𝐼 ↔ ( 𝑋 + 1 ) < 𝐼 ) )
40 id ( ( 𝐶𝑋 ) = ( 𝑋 + 1 ) → ( 𝐶𝑋 ) = ( 𝑋 + 1 ) )
41 oveq1 ( ( 𝐶𝑋 ) = ( 𝑋 + 1 ) → ( ( 𝐶𝑋 ) − 1 ) = ( ( 𝑋 + 1 ) − 1 ) )
42 39 40 41 ifbieq12d ( ( 𝐶𝑋 ) = ( 𝑋 + 1 ) → if ( ( 𝐶𝑋 ) < 𝐼 , ( 𝐶𝑋 ) , ( ( 𝐶𝑋 ) − 1 ) ) = if ( ( 𝑋 + 1 ) < 𝐼 , ( 𝑋 + 1 ) , ( ( 𝑋 + 1 ) − 1 ) ) )
43 38 42 ifbieq2d ( ( 𝐶𝑋 ) = ( 𝑋 + 1 ) → if ( ( 𝐶𝑋 ) = 𝐼 , 𝑀 , if ( ( 𝐶𝑋 ) < 𝐼 , ( 𝐶𝑋 ) , ( ( 𝐶𝑋 ) − 1 ) ) ) = if ( ( 𝑋 + 1 ) = 𝐼 , 𝑀 , if ( ( 𝑋 + 1 ) < 𝐼 , ( 𝑋 + 1 ) , ( ( 𝑋 + 1 ) − 1 ) ) ) )
44 37 43 syl ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → if ( ( 𝐶𝑋 ) = 𝐼 , 𝑀 , if ( ( 𝐶𝑋 ) < 𝐼 , ( 𝐶𝑋 ) , ( ( 𝐶𝑋 ) − 1 ) ) ) = if ( ( 𝑋 + 1 ) = 𝐼 , 𝑀 , if ( ( 𝑋 + 1 ) < 𝐼 , ( 𝑋 + 1 ) , ( ( 𝑋 + 1 ) − 1 ) ) ) )
45 2 nnred ( 𝜑𝐼 ∈ ℝ )
46 45 3ad2ant1 ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → 𝐼 ∈ ℝ )
47 35 zred ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → 𝑋 ∈ ℝ )
48 36 zred ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → ( 𝑋 + 1 ) ∈ ℝ )
49 46 47 lenltd ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → ( 𝐼𝑋 ↔ ¬ 𝑋 < 𝐼 ) )
50 27 49 mpbird ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → 𝐼𝑋 )
51 47 ltp1d ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → 𝑋 < ( 𝑋 + 1 ) )
52 46 47 48 50 51 lelttrd ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → 𝐼 < ( 𝑋 + 1 ) )
53 46 52 ltned ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → 𝐼 ≠ ( 𝑋 + 1 ) )
54 53 necomd ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → ( 𝑋 + 1 ) ≠ 𝐼 )
55 54 neneqd ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → ¬ ( 𝑋 + 1 ) = 𝐼 )
56 iffalse ( ¬ ( 𝑋 + 1 ) = 𝐼 → if ( ( 𝑋 + 1 ) = 𝐼 , 𝑀 , if ( ( 𝑋 + 1 ) < 𝐼 , ( 𝑋 + 1 ) , ( ( 𝑋 + 1 ) − 1 ) ) ) = if ( ( 𝑋 + 1 ) < 𝐼 , ( 𝑋 + 1 ) , ( ( 𝑋 + 1 ) − 1 ) ) )
57 55 56 syl ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → if ( ( 𝑋 + 1 ) = 𝐼 , 𝑀 , if ( ( 𝑋 + 1 ) < 𝐼 , ( 𝑋 + 1 ) , ( ( 𝑋 + 1 ) − 1 ) ) ) = if ( ( 𝑋 + 1 ) < 𝐼 , ( 𝑋 + 1 ) , ( ( 𝑋 + 1 ) − 1 ) ) )
58 47 lep1d ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → 𝑋 ≤ ( 𝑋 + 1 ) )
59 46 47 48 50 58 letrd ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → 𝐼 ≤ ( 𝑋 + 1 ) )
60 46 48 lenltd ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → ( 𝐼 ≤ ( 𝑋 + 1 ) ↔ ¬ ( 𝑋 + 1 ) < 𝐼 ) )
61 59 60 mpbid ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → ¬ ( 𝑋 + 1 ) < 𝐼 )
62 iffalse ( ¬ ( 𝑋 + 1 ) < 𝐼 → if ( ( 𝑋 + 1 ) < 𝐼 , ( 𝑋 + 1 ) , ( ( 𝑋 + 1 ) − 1 ) ) = ( ( 𝑋 + 1 ) − 1 ) )
63 61 62 syl ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → if ( ( 𝑋 + 1 ) < 𝐼 , ( 𝑋 + 1 ) , ( ( 𝑋 + 1 ) − 1 ) ) = ( ( 𝑋 + 1 ) − 1 ) )
64 35 zcnd ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → 𝑋 ∈ ℂ )
65 1cnd ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → 1 ∈ ℂ )
66 64 65 pncand ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → ( ( 𝑋 + 1 ) − 1 ) = 𝑋 )
67 57 63 66 3eqtrd ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → if ( ( 𝑋 + 1 ) = 𝐼 , 𝑀 , if ( ( 𝑋 + 1 ) < 𝐼 , ( 𝑋 + 1 ) , ( ( 𝑋 + 1 ) − 1 ) ) ) = 𝑋 )
68 44 67 eqtrd ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → if ( ( 𝐶𝑋 ) = 𝐼 , 𝑀 , if ( ( 𝐶𝑋 ) < 𝐼 , ( 𝐶𝑋 ) , ( ( 𝐶𝑋 ) − 1 ) ) ) = 𝑋 )
69 68 adantr ( ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) ∧ 𝑥 = ( 𝐶𝑋 ) ) → if ( ( 𝐶𝑋 ) = 𝐼 , 𝑀 , if ( ( 𝐶𝑋 ) < 𝐼 , ( 𝐶𝑋 ) , ( ( 𝐶𝑋 ) − 1 ) ) ) = 𝑋 )
70 15 69 eqtrd ( ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) ∧ 𝑥 = ( 𝐶𝑋 ) ) → if ( 𝑥 = 𝐼 , 𝑀 , if ( 𝑥 < 𝐼 , 𝑥 , ( 𝑥 − 1 ) ) ) = 𝑋 )
71 1 2 3 5 metakunt2 ( 𝜑𝐶 : ( 1 ... 𝑀 ) ⟶ ( 1 ... 𝑀 ) )
72 71 3ad2ant1 ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → 𝐶 : ( 1 ... 𝑀 ) ⟶ ( 1 ... 𝑀 ) )
73 72 33 ffvelrnd ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → ( 𝐶𝑋 ) ∈ ( 1 ... 𝑀 ) )
74 8 70 73 33 fvmptd ( ( 𝜑 ∧ ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) → ( 𝐴 ‘ ( 𝐶𝑋 ) ) = 𝑋 )
75 74 3expb ( ( 𝜑 ∧ ( ¬ 𝑋 = 𝑀 ∧ ¬ 𝑋 < 𝐼 ) ) → ( 𝐴 ‘ ( 𝐶𝑋 ) ) = 𝑋 )
76 7 75 sylan2b ( ( 𝜑 ∧ ¬ ( 𝑋 = 𝑀𝑋 < 𝐼 ) ) → ( 𝐴 ‘ ( 𝐶𝑋 ) ) = 𝑋 )