Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newbie here, I created a proof with mmj2. How do I add the proof to the database #3908

Closed
metakunt opened this issue Apr 5, 2024 · 17 comments · Fixed by #3920
Closed

Newbie here, I created a proof with mmj2. How do I add the proof to the database #3908

metakunt opened this issue Apr 5, 2024 · 17 comments · Fixed by #3920

Comments

@metakunt
Copy link
Contributor

metakunt commented Apr 5, 2024

So the mmp file format looks different than the mm file format. And for the love of god I couldn't find any utility to convert it.
The mmj2 repo help says that there is no functionality to add a proof automatically.

In the attachment there is a file of a subproof I am hoping is helpful. What I want to show is that a function is a permutation.
proofsandsupproofs.zip

In the zip archive there are three files. One is a subproof that mmj2 already says is correct. (File: noideahowtonameit.mmp)
The second and third one is the actual proof .
Here I am still debating if I can generalize to include the case ( 1 ... 0 ) --> ( 1 ... 0 ) which is a map from the empty to the empty set.
This is a map, which should also be bijective, so it should work.
I want to show that the function defined by F is a permutation. The domain is ( 1 ... N ) where N is in NN0 (here I am debating if NN0 is better than NN, it might make more sense to define it that way, but the only use case will be N in NN). Let the domain be A.
I want to show that F: A->A is a function from A to A.
Then I planned to use the fact that A is finite together with an injection/surjection (I still don't know which one is easier) -> F bijective.

Let i \in {1,...,m}
The function F is defined by two if statements. In Latexlike it would be something like
{1,...,m} -> {1,...,m}
j |-> m-i+j+\chi(m-i+j,i) if 1 \leq j \leq i-1
j |-> j if i=j
j |-> j-i+\chi(j-i,i) i+1 \leq j \leq m

Eventually I want to show that this is a permutation. For now, I'd be more than happy to show that it is a function with dom=cod={1,...,m}

This is why I developed this new lemma. My hope is that I can show
(x e. ( 1 ... M ) -> bla)
by showing
(x e. (1 ... M ) and x = I ) -> bla
(x e. (1 ... M ) and x \neq I and x < l) -> bla
(x e. (1 ... M ) and x \neq I and not ( x < l )) -> bla

where bla is the fact that the evaluation of F(x) is in (1...m)
Then I can use my theorem to eliminate all, such that the unification works. But I didn't find a good way. The only thing I've found is a syllogism rule, which is quite helpful, but I didn't find how I can move antecedents inside and outside of the if statements.

@icecream17
Copy link
Contributor

This doesn't solve the file conversion problem, but the following theorems are relevant to move antecedents:

ex
imp
3expia
3impia

Also, for closure and if statement specifically, there is:

ifcld
ifclda

@metakunt
Copy link
Contributor Author

metakunt commented Apr 6, 2024

Hey thanks very much, that already helped me. Currently I am trying to show that F is a permutation.
My first step was to show, that F: ( 1 ... M ) --> ( 1 ... M )
I am currently having trouble deriving the d51actualnev:: |- -. ( ( x e. ( 1 ... M ) /\ -. x = I /\ x = 1 ) /\ -. x < I ).
It should work, but it doesn't for some reason. $x \neq i$ and $x \geq i$ should imply that $x &gt; i$, together with $x = 1$ I should get
$1 &gt; i$, and together with syllogism.2 i should be able to get $i \geq 1$.
Combining both gives $1 &gt; i \geq 1$ -> $1 &gt; 1$, which is a contradiction. But I just can't get it for some reason.

$( <MM> <PROOF_ASST> THEOREM=alphafirstlem LOC_AFTER=

hm::syllogism.1 |- M e. NN
hex::syllogism.2 |- I e. ( 1 ... M )
h4::syllogism.3 |- F = ( x  e. ( 1 ... M ) |-> if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) )



minm:m:jm2.27dlem3 |- M e. ( 1 ... M )

lalao::iftrue      |- (  x = I -> if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) = M )
dft:minm:a1i |- (  x = I ->  M e. ( 1 ... M ) )
dfii:lalao,dft:eqeltrd |-  ( x = I -> if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) e. ( 1 ... M ) )
dfcomb:lalao,dfii:eqeltrrd |- (  x = I ->  M e. ( 1 ... M ) )
dfcomb2:dfcomb:a1i |- ( x e. ( 1 ... M ) -> (  x = I ->  M e. ( 1 ... M ) ) )

dfxitl:dft,dfii: |- ( x = I -> M e. ( 1 ... M ) )




d4::simpl          |- (  ( x e. ( 1 ... M ) /\ x = I )
                      -> x e. ( 1 ... M ) )

dxj1::breq1 |- ( x = 1 -> ( x e ( 1 ... M ) <-> 1 e ( 1 ... M ) ) )



d51actualnev:: |- -. (  ( x e. ( 1 ... M ) /\ -. x = I /\ x = 1 ) /\ -. x < I )

dfxit:: |- ( x = I -> if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) e. ( 1 ... M ) )

dfxi:dfxit:a1i |- ( x e. ( 1 ... M ) -> ( x = I -> if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) e. ( 1 ... M ) ) )

d2:dfxi:imp        |- (  ( x e. ( 1 ... M ) /\ x = I )
                      ->    if ( x = I , M , if ( x < I , x , ( x - 1 ) ) )
                         e. ( 1 ... M ) )
d3t::iffalse       |- (  -. x < I
                      -> if ( x < I , x , ( x - 1 ) ) = ( x - 1 ) )

!d5352::           |- (  (  ( x e. ( 1 ... M ) /\ -. x = I /\ x = 1 )
                         /\ x < I )
                      ->    if ( x = I , M , if ( x < I , x , ( x - 1 ) ) )
                         e. ( 1 ... M ) )
d5353:d51actualnev:pm2.21i |- (  (  ( x e. ( 1 ... M ) /\ -. x = I /\ x = 1 )
                         /\ -. x < I )
                      ->    if ( x = I , M , if ( x < I , x , ( x - 1 ) ) )
                         e. ( 1 ... M ) )
d531:d5352,d5353:pm2.61dan |- (  (   x e. ( 1 ... M ) /\ -. x = I 
                         /\ x = 1 )
                      ->    if ( x = I , M , if ( x < I , x , ( x - 1 ) ) )
                         e. ( 1 ... M ) )
d53:d531:3expa |- (  (  ( x e. ( 1 ... M ) /\ -. x = I )
                         /\ x = 1 )
                      ->    if ( x = I , M , if ( x < I , x , ( x - 1 ) ) )
                         e. ( 1 ... M ) )
!d5351::            |- (  (  ( x e. ( 1 ... M ) /\ x < I /\ -. x = 1 )
                         /\ -. x = I )
                      ->    if ( x = I , M , if ( x < I , x , ( x - 1 ) ) )
                         e. ( 1 ... M ) )
!d535:d5351:            |- (  (  ( x e. ( 1 ... M ) /\ -. x = I /\ -. x = 1 )
                         /\ x < I )
                      ->    if ( x = I , M , if ( x < I , x , ( x - 1 ) ) )
                         e. ( 1 ... M ) )
!d536::            |- (  (  ( x e. ( 1 ... M ) /\ -. x = I /\ -. x = 1 )
                         /\ -. x < I )
                      ->    if ( x = I , M , if ( x < I , x , ( x - 1 ) ) )
                         e. ( 1 ... M ) )
d534:d535,d536:pm2.61dan   |- (  ( x e. ( 1 ... M ) /\ -. x = I /\ -. x = 1 )
                      ->    if ( x = I , M , if ( x < I , x , ( x - 1 ) ) )
                         e. ( 1 ... M ) )
d54:d534:3expa         |- (  (  ( x e. ( 1 ... M ) /\ -. x = I )
                         /\ -. x = 1 )
                      ->    if ( x = I , M , if ( x < I , x , ( x - 1 ) ) )
                         e. ( 1 ... M ) )
d3:d53,d54:pm2.61dan        |- (  ( x e. ( 1 ... M ) /\ -. x = I )
                      ->    if ( x = I , M , if ( x < I , x , ( x - 1 ) ) )
                         e. ( 1 ... M ) )
d1:d2,d3:pm2.61dan          |- (  x e. ( 1 ... M )
                      ->    if ( x = I , M , if ( x < I , x , ( x - 1 ) ) )
                         e. ( 1 ... M ) )
la:4,d1:fmpti      |- F : ( 1 ... M ) --> ( 1 ... M )
qed::equid |- x = x
$d M x 
$=  ( equid ) AE $.
$)

@avekens
Copy link
Contributor

avekens commented Apr 7, 2024

So the mmp file format looks different than the mm file format. And for the love of god I couldn't find any utility to convert it. The mmj2 repo help says that there is no functionality to add a proof automatically.

You can open the *.mmp file in mmj2, and then copy the content displayed and paste it into a *.mm file. You have to edit a little bit. Your example noideahowtonameit (in mmj2):

h1::theotestaa.1 |- ( ( ph /\ ps ) -> ch )
h2::theotestaa.2 |- ( ( ( ph /\ -. ps ) /\ th ) -> ch )
h3::theotestaa.3 |- ( ( ( ph /\ -. ps ) /\ -. th ) -> ch )
s1:2,3:pm2.61dan   |- ( ( ph /\ -. ps ) -> ch )
qed:1,s1:pm2.61dan |- ( ph -> ch )

$=  ( theotestaa.1 theotestaa.2 theotestaa.3 wn wa pm2.61dan ) ABCEAB
    HIDCFGJJ $.

would become:

${
   theotestaa.1 $e |- ( ( ph /\ ps ) -> ch ) $.
   theotestaa.2 $e |- ( ( ( ph /\ -. ps ) /\ th ) -> ch ) $.
   theotestaa.3 $e |- ( ( ( ph /\ -. ps ) /\ -. th ) -> ch ) $.
   theotestaa $p |- ( ph -> ch )

$=  ( wn wa pm2.61dan ) ABCEAB
    HIDCFGJJ $.
$}

I usually write the theorem in an *.mm file, import it into mmj2, prove it in mmj2, and copy the proof back to the *.mm file.

@tirix
Copy link
Contributor

tirix commented Apr 7, 2024

$x \neq i$ and $x \geq i$ should imply that $x &gt; i$, together with $x = 1$ I should get $1 &gt; i$, and together with syllogism.2 i should be able to get $i \geq 1$.

Here is what I came up with. I get $1 &lt; x$ at step 47, it's coming from $1 \leq i$ and $i &lt; x$, whereas the latter is indeed coming from $i \leq x$ and $i \neq x$.

h1::syllogism.1           |- M e. NN
h2::syllogism.2                |- I e. ( 1 ... M )
h3::syllogism.3     |- F = ( x e. ( 1 ... M ) |-> if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) )
4:1:jm2.27dlem3        |- M e. ( 1 ... M )
5::iftrue             |- ( x = I -> if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) = M )
6:4:a1i               |- ( x = I -> M e. ( 1 ... M ) )
7:5,6:eqeltrd        |- ( x = I -> if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) e. ( 1 ... M ) )
8:5,7:eqeltrrd      |- ( x = I -> M e. ( 1 ... M ) )
9:8:a1i            |- ( x e. ( 1 ... M ) -> ( x = I -> M e. ( 1 ... M ) ) )
10::eleq1            |- ( M = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) -> ( M e. ( 1 ... M ) <-> if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) e. ( 1 ... M ) ) )
11::eleq1            |- ( if ( x < I , x , ( x - 1 ) ) = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) -> ( if ( x < I , x , ( x - 1 ) ) e. ( 1 ... M ) <-> if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) e. ( 1 ... M ) ) )
12:4:a1i             |- ( ( x e. ( 1 ... M ) /\ x = I ) -> M e. ( 1 ... M ) )
13::eleq1             |- ( x = if ( x < I , x , ( x - 1 ) ) -> ( x e. ( 1 ... M ) <-> if ( x < I , x , ( x - 1 ) ) e. ( 1 ... M ) ) )
14::eleq1             |- ( ( x - 1 ) = if ( x < I , x , ( x - 1 ) ) -> ( ( x - 1 ) e. ( 1 ... M ) <-> if ( x < I , x , ( x - 1 ) ) e. ( 1 ... M ) ) )
15::simpll            |- ( ( ( x e. ( 1 ... M ) /\ -. x = I ) /\ x < I ) -> x e. ( 1 ... M ) )
16::fzm1ne1             |- ( ( x e. ( 1 ... M ) /\ x =/= 1 ) -> ( x - 1 ) e. ( 1 ... ( M - 1 ) ) )
17::fzssm12              |- ( ( 1 e. ZZ /\ M e. ZZ /\ 1 e. NN0 ) -> ( 1 ... ( M - 1 ) ) C_ ( 1 ... M ) )
18::1nn0                 |- 1 e. NN0
19::1z                   |- 1 e. ZZ
20:1:nnzi                |- M e. ZZ
21:19,20,18,17:mp3an    |- ( 1 ... ( M - 1 ) ) C_ ( 1 ... M )
22:21,16:sseldi        |- ( ( x e. ( 1 ... M ) /\ x =/= 1 ) -> ( x - 1 ) e. ( 1 ... M ) )
23::simpll                 |- ( ( ( x e. ( 1 ... M ) /\ -. x = I ) /\ -. x < I ) -> x e. ( 1 ... M ) )
24::lenlt                     |- ( ( I e. RR /\ x e. RR ) -> ( I <_ x <-> -. x < I ) )
25::fz1ssnn                    |- ( 1 ... M ) C_ NN
26:25,2:sselii                |- I e. NN
27:26:nnrei                  |- I e. RR
28:25:sseli                   |- ( x e. ( 1 ... M ) -> x e. NN )
29:28:nnred                  |- ( x e. ( 1 ... M ) -> x e. RR )
30:24:biimprd                |- ( ( I e. RR /\ x e. RR ) -> ( -. x < I -> I <_ x ) )
31:27,29,30:sylancr         |- ( x e. ( 1 ... M ) -> ( -. x < I -> I <_ x ) )
32:31:imp                  |- ( ( x e. ( 1 ... M ) /\ -. x < I ) -> I <_ x )
33:23,32:sylancom         |- ( ( ( x e. ( 1 ... M ) /\ -. x = I ) /\ -. x < I ) -> I <_ x )
34:27:a1i                   |- ( x e. ( 1 ... M ) -> I e. RR )
35:34,29:ltlend            |- ( x e. ( 1 ... M ) -> ( I < x <-> ( I <_ x /\ x =/= I ) ) )
36:35:biimpar             |- ( ( x e. ( 1 ... M ) /\ ( I <_ x /\ x =/= I ) ) -> I < x )
37::simplr                 |- ( ( ( x e. ( 1 ... M ) /\ -. x = I ) /\ -. x < I ) -> -. x = I )
38:37:neqned              |- ( ( ( x e. ( 1 ... M ) /\ -. x = I ) /\ -. x < I ) -> x =/= I )
39:23,33,38,36:syl12anc  |- ( ( ( x e. ( 1 ... M ) /\ -. x = I ) /\ -. x < I ) -> I < x )
40::1red                 |- ( ( ( x e. ( 1 ... M ) /\ -. x = I ) /\ -. x < I ) -> 1 e. RR )
41:27:a1i                |- ( ( ( x e. ( 1 ... M ) /\ -. x = I ) /\ -. x < I ) -> I e. RR )
42:23,29:syl             |- ( ( ( x e. ( 1 ... M ) /\ -. x = I ) /\ -. x < I ) -> x e. RR )
43::elnnz1                  |- ( I e. NN <-> ( I e. ZZ /\ 1 <_ I ) )
44:26,43:mpbi              |- ( I e. ZZ /\ 1 <_ I )
45:44:simpri              |- 1 <_ I
46:45:a1i                |- ( ( ( x e. ( 1 ... M ) /\ -. x = I ) /\ -. x < I ) -> 1 <_ I )
47:40,41,42,46,39:lelttrd |- ( ( ( x e. ( 1 ... M ) /\ -. x = I ) /\ -. x < I ) -> 1 < x )
48:23,29:syl       |- ( ( ( x e. ( 1 ... M ) /\ -. x = I ) /\ -. x < I ) -> x e. RR )
49:40,47:gtned         |- ( ( ( x e. ( 1 ... M ) /\ -. x = I ) /\ -. x < I ) -> x =/= 1 )
50:23,49,22:syl2anc   |- ( ( ( x e. ( 1 ... M ) /\ -. x = I ) /\ -. x < I ) -> ( x - 1 ) e. ( 1 ... M ) )
51:13,14,15,50:ifbothda |- ( ( x e. ( 1 ... M ) /\ -. x = I ) -> if ( x < I , x , ( x - 1 ) ) e. ( 1 ... M ) )
52:10,11,12,51:ifbothda |- ( x e. ( 1 ... M ) -> if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) e. ( 1 ... M ) )
53:3,52:fmpti      |- F : ( 1 ... M ) --> ( 1 ... M )

@icecream17
Copy link
Contributor

Incidentally this is very similar to https://us.metamath.org/mpeuni/fzto1st.html

@metakunt
Copy link
Contributor Author

metakunt commented Apr 7, 2024

Oh wow that was awesome. @tirix , you are awesome. Thank you very much. @icecream17 thanks for the link as well.

I'll be studying your process. Also I have figured out that natural deduction is so good. When I started my journey a few days ago I had really big issues on getting any deduction. Not knowing which theorems are applicable for a given use case was extremely daunting. For some reason, I wasn't able to even show that A<B, B<C -> A<C, and searching in metamath-exe engine was not yielding the correct results, even though I was absolutely certain that something like that MUST be in the database.

One question on the approach. To build bigger statements, do I start from the inside and do hypothesis building with a1i, Because sometimes I need to show A -> B where A and B syntactically differ in the inside.
Let us assume that A and B differ only in two small ways, which are easy to prove by themselves. Do I then start with the differing, and use hypothesis building with a1i? Because I have found out that proofs in natural deduction are so much easier to read than other proofs, which use multiple complex inference rules.

I have made a WIP draft of what I want to show. I want to show that $\delta= (\alpha)^{-1}\circ \beta \circ \alpha$ and that the values on $\delta$, which is defined separately, coincide with the above equation. That shows that $\delta$ is a permutation with the desired properties. For now my first goal is to show that alpha is a permutation. A big milestone would be, if I could prove that

$$\alpha : \{1,\dots,m\}\to \{1,\dots,m\}$$

I'd already be quite happy.
In metamath I plan on using https://us.metamath.org/mpeuni/fcof1od.html and as of now I plan on satisfying the first hypothesis. In my draft I have already proven all four hypotheses for $\alpha$.

Is my current approach correct. Do you have any ideas for improvement. I'd love to hear your opinion. After all I don't want to use an approach that leads me to a dead end without me knowing that I am stuck.

draft_2024-04-07.pdf

@tirix
Copy link
Contributor

tirix commented Apr 7, 2024

Yes, natural deduction is really nice to use, so maybe one tip I'd give is to rather write your theorem in a deduction form, as in:

|- ( ( M e. NN /\ I e. ( 1 ... M ) ) -> F : ( 1 ... M ) --> ( 1 ... M ) )

This way it will be much easier to use later on.

searching in metamath-exe engine was not yielding the correct results

I think one of the biggest hurdle when starting with Metamath is to find the theorem you're looking for. There are some naming patterns which may help. For example, the one you're stating is "Lower Than is TRansitive, Induction version", so it's named lttri. But in general in the end searching strategies are like:

  • write the statement and let the tools (MMJ2 or Yamma) fill-in with the theorem,
  • search a sufficiently specific part of the statement (I use regular expressions a lot, but there are better tools out there)
  • search by name,
  • find the chapter which deals with the topic of the theorem, and skim through to find what is similar.

I need to show A -> B where A and B syntactically differ in the inside.

Generally I like to work with deduction form, in which case your A would be broken down into a conjunction (like $A \Leftrightarrow A_1 \wedge A_2 \wedge A_3$ ), and the hypotheses are formulated as $\varphi \implies A_1$, $\varphi \implies A_2$, $\varphi \implies A_3$.

Then you have to derive $\varphi \implies B_1$, $\varphi \implies B_2$, $\varphi \implies B_3$, which should be easy if $B_1$, $B_2$, $B_3$ don't differ much or are identical to some of the $A_1$, $A_2$, $A_3$.

@tirix
Copy link
Contributor

tirix commented Apr 7, 2024

If you have a function $\alpha$, know its converse $\gamma$, and want to prove that it is a bijection, maybe a good way could be to use ~f1o2d. Compared to ~fcof1od, I think it might save you a few steps, because you will not need to evaluate (F o. G) and (G o. F), but you will instead directly deal with their values at $x$ and $y$.

Several of your functions seem to be permutation cycles, or compositions of a few cycles. I've started to define permutation cycles and prove some of their properties in my mathbox. Maybe it would be easier to deal with these cycles, but that would be a different approach from your PDF, so maybe it's not the approach you prefer.

@metakunt
Copy link
Contributor Author

metakunt commented Apr 7, 2024

You are my hero. That was what I was searching. I just couldn't find the fitting theorem. I'll check out your mathbox and I'll likely try both approaches to see what is easier. My goal overall is to define $\delta$ in terms of primitives and show that the equation above holds. It is likely possible to show that with subtheorems, but I think the difficulty will be evaluating

$$\alpha^{-1}(\beta(\alpha(x)))=\delta(x) ~~~\forall x \in \{1,\dots,m\}$$

later.

The actual proof of that statement was a big case distinction, as the defined value of $\delta$ has the indicator function in its closed form. The distinction in cases was made whether the indicator function is $1$ or $0$.

Also recall the definition of $\beta$ for $1\leq j \leq i-1$

$$\beta(j) = m-i+j$$

I'd hope to show that with above restriction that

$$\beta(j) \in \{m-i+1,\dots,m-1\}$$

I assume that there are theorems in metamath for closed ranges that make this possible. Something like
k e. NN /\ x e. ( M ... N ) -> ( k + x ) e. ( ( k + M ) ... ( k + N ) )

Because if I want to calculate $\delta$ i would need to consider several subcases. In my mind there are lots of conditions that need to be evaluated separately, namely

$$j=i,~j=m,~j\in\{1,\dots,i-1\},~j\in\{i+1,\dots,m-1\}$$$

As well as the evaluation of the indicator function twice. This gives me a total of 16 cases that I have to check, because I need to check that the image of one application fulfils the condition of the next function to be able to evaluate it.

I have thought to evaluate the image on all 16 parts for all functions $\alpha, \beta,\alpha^{-1}$ and $\delta$ first. and then combine them. For example I want to show that
$\phi \implies \alpha(j)=j \land \psi$
where $\phi$ and $\psi$ are one of those 16 conditions. If everything is defined on all those conditions then I can show equality by checking for equality in all 16 definitions. Does this approach make sense?

@metakunt
Copy link
Contributor Author

metakunt commented Apr 8, 2024

Well i have tried using f1o2d, here is what I put in


!d1::              |-   F
                      = (   x
                        e.  ( 1 ... M )
                        |-> if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) )
!d2::              |- (  ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ x e. ( 1 ... M ) )
                      ->    if ( x = I , M , if ( x < I , x , ( x - 1 ) ) )
                         e. ( 1 ... M ) )
!d3::              |- (  (  ( M e. NN /\ I e. ( 1 ... M ) )
                         /\ y e. ( 1 ... M ) )
                      ->    if ( y = M , I , if ( y < I , y , ( y + 1 ) ) )
                         e. ( 1 ... M ) )

d4::  |- (  (  ( M e. NN /\ I e. ( 1 ... M ) )
                         /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) )
                      -> (     x
                             = if ( y = M , I , if ( y < I , y , ( y + 1 ) ) )
                         <->   y
                             = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) )
                         ) )
100:d1,d2,d3,d4:f1o2d 
                   |- (  ( M e. NN /\ I e. ( 1 ... M ) )
                      -> F : ( 1 ... M ) -1-1-onto-> ( 1 ... M ) )

Autocomplete gave me

!d1::              |-   F
                      = (   x
                        e.  ( 1 ... M )
                        |-> if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) )
!d2::              |- (  ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ x e. ( 1 ... M ) )
                      ->    if ( x = I , M , if ( x < I , x , ( x - 1 ) ) )
                         e. ( 1 ... M ) )
!d3::              |- (  (  ( M e. NN /\ I e. ( 1 ... M ) )
                         /\ y e. ( 1 ... M ) )
                      ->    if ( y = M , I , if ( y < I , y , ( y + 1 ) ) )
                         e. ( 1 ... M ) )
!d5::              |- (  (  ( M e. NN /\ I e. ( 1 ... M ) )
                         /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) )
                      -> x = y )
!d6::              |- (  (  (  (  ( M e. NN /\ I e. ( 1 ... M ) )
                               /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) )
                            /\ y = M )
                         /\ x = I )
                      -> I = M )
!d7::              |- (  (  (  (  ( M e. NN /\ I e. ( 1 ... M ) )
                               /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) )
                            /\ y = M )
                         /\ -. x = I
                         /\ x < I )
                      -> I = x )
!d8::              |- (  (  (  (  ( M e. NN /\ I e. ( 1 ... M ) )
                               /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) )
                            /\ y = M )
                         /\ -. x = I
                         /\ -. x < I )
                      -> I = ( x - 1 ) )
d9:d6,d7,d8:2if2   |- (  (  (  ( M e. NN /\ I e. ( 1 ... M ) )
                            /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) )
                         /\ y = M )
                      ->   I
                         = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) )
!d10::             |- (  (  (  (  (  ( M e. NN /\ I e. ( 1 ... M ) )
                                  /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) )
                               /\ -. y = M )
                            /\ y < I )
                         /\ x = I )
                      -> y = M )
!d11::             |- (  (  (  (  (  ( M e. NN /\ I e. ( 1 ... M ) )
                                  /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) )
                               /\ -. y = M )
                            /\ y < I )
                         /\ -. x = I
                         /\ x < I )
                      -> y = x )
!d12::             |- (  (  (  (  (  ( M e. NN /\ I e. ( 1 ... M ) )
                                  /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) )
                               /\ -. y = M )
                            /\ y < I )
                         /\ -. x = I
                         /\ -. x < I )
                      -> y = ( x - 1 ) )
d13:d10,d11,d12:2if2  
                   |- (  (  (  (  ( M e. NN /\ I e. ( 1 ... M ) )
                               /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) )
                            /\ -. y = M )
                         /\ y < I )
                      ->   y
                         = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) )
!d14::             |- (  (  (  (  (  ( M e. NN /\ I e. ( 1 ... M ) )
                                  /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) )
                               /\ -. y = M )
                            /\ -. y < I )
                         /\ x = I )
                      -> ( y + 1 ) = M )
!d15::             |- (  (  (  (  (  ( M e. NN /\ I e. ( 1 ... M ) )
                                  /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) )
                               /\ -. y = M )
                            /\ -. y < I )
                         /\ -. x = I
                         /\ x < I )
                      -> ( y + 1 ) = x )
!d16::             |- (  (  (  (  (  ( M e. NN /\ I e. ( 1 ... M ) )
                                  /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) )
                               /\ -. y = M )
                            /\ -. y < I )
                         /\ -. x = I
                         /\ -. x < I )
                      -> + = - )
!d17::             |- (  (  (  (  (  ( M e. NN /\ I e. ( 1 ... M ) )
                                  /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) )
                               /\ -. y = M )
                            /\ -. y < I )
                         /\ -. x = I
                         /\ -. x < I )
                      -> y = x )
d18::eqidd         |- (  (  (  (  (  ( M e. NN /\ I e. ( 1 ... M ) )
                                  /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) )
                               /\ -. y = M )
                            /\ -. y < I )
                         /\ -. x = I
                         /\ -. x < I )
                      -> 1 = 1 )
d19:d16,d17,d18:oveq123d  
                   |- (  (  (  (  (  ( M e. NN /\ I e. ( 1 ... M ) )
                                  /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) )
                               /\ -. y = M )
                            /\ -. y < I )
                         /\ -. x = I
                         /\ -. x < I )
                      -> ( y + 1 ) = ( x - 1 ) )
d20:d14,d15,d19:2if2  
                   |- (  (  (  (  ( M e. NN /\ I e. ( 1 ... M ) )
                               /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) )
                            /\ -. y = M )
                         /\ -. y < I )
                      ->   ( y + 1 )
                         = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) )
d21:d13,d20:ifeqda  
                   |- (  (  (  ( M e. NN /\ I e. ( 1 ... M ) )
                            /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) )
                         /\ -. y = M )
                      ->   if ( y < I , y , ( y + 1 ) )
                         = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) )
d22:d9,d21:ifeqda  |- (  (  ( M e. NN /\ I e. ( 1 ... M ) )
                         /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) )
                      ->   if ( y = M , I , if ( y < I , y , ( y + 1 ) ) )
                         = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) )
d4:d5,d22:eqeq12d  |- (  (  ( M e. NN /\ I e. ( 1 ... M ) )
                         /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) )
                      -> (     x
                             = if ( y = M , I , if ( y < I , y , ( y + 1 ) ) )
                         <->   y
                             = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) )
                         ) )
100:d1,d2,d3,d4:f1o2d 
                   |- (  ( M e. NN /\ I e. ( 1 ... M ) )
                      -> F : ( 1 ... M ) -1-1-onto-> ( 1 ... M ) )

which just can't be right.

Let us focus on d4: The other steps seem simpler.

Intuitively it is clear what i need to do. I need to check the cases.
x=I, y=M gives I=I <-> M=M, x<I gives y<I, evaluating again gives x=y <-> y=x.
The last case is x>=i, y>=i. But then x = y+1 <-> y=x-1, which is again true.
All other cases should give me a contradiction one way or another. There are 4 conditions: 2 on x and 2 on y. Combining all 4 conditions with its converse gives a total of 16 conditions, most of which will can be ignored due to a contradiction.

But I have no clue how to get the substitution. I have studied the theorems that use f1o2d, but the final condition in the last step is usually trivial, like this one
https://us.metamath.org/mpeuni/dvdsflf1o.html

There must be an easier way. Am I missing something?

@tirix
Copy link
Contributor

tirix commented Apr 8, 2024

Yes it does not seem right!

MMJ2's autocomplete is not an oracle and sometimes goes the wrong way...
For solving d4 I would use ˜ifbothda like above, to split both cases, and then again for the embedded "if".

Here I've filled in the first case:

h1::alphafirstlem.1 |- F = ( x e. ( 1 ... M ) |-> if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) )
2::elfznn                     |- ( x e. ( 1 ... M ) -> x e. NN )
3::elfznn                     |- ( y e. ( 1 ... M ) -> y e. NN )
4::elfznn                     |- ( I e. ( 1 ... M ) -> I e. NN )
5:2:nnred                    |- ( x e. ( 1 ... M ) -> x e. RR )
6:3:nnred                    |- ( y e. ( 1 ... M ) -> y e. RR )
7:4:nnred                    |- ( I e. ( 1 ... M ) -> I e. RR )
8:5:ad2antrl                |- ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) -> x e. RR )
9::                 |- ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ x e. ( 1 ... M ) ) -> if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) e. ( 1 ... M ) )
10::                |- ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ y e. ( 1 ... M ) ) -> if ( y = M , I , if ( y < I , y , ( y + 1 ) ) ) e. ( 1 ... M ) )
11::eqeq2             |- ( I = if ( y = M , I , if ( y < I , y , ( y + 1 ) ) ) -> ( x = I <-> x = if ( y = M , I , if ( y < I , y , ( y + 1 ) ) ) ) )
12:11:bibi1d         |- ( I = if ( y = M , I , if ( y < I , y , ( y + 1 ) ) ) -> ( ( x = I <-> y = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) ) <-> ( x = if ( y = M , I , if ( y < I , y , ( y + 1 ) ) ) <-> y = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) ) ) )
13::eqeq2             |- ( if ( y < I , y , ( y + 1 ) ) = if ( y = M , I , if ( y < I , y , ( y + 1 ) ) ) -> ( x = if ( y < I , y , ( y + 1 ) ) <-> x = if ( y = M , I , if ( y < I , y , ( y + 1 ) ) ) ) )
14:13:bibi1d         |- ( if ( y < I , y , ( y + 1 ) ) = if ( y = M , I , if ( y < I , y , ( y + 1 ) ) ) -> ( ( x = if ( y < I , y , ( y + 1 ) ) <-> y = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) ) <-> ( x = if ( y = M , I , if ( y < I , y , ( y + 1 ) ) ) <-> y = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) ) ) )
15::eqeq2              |- ( M = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) -> ( y = M <-> y = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) ) )
16:15:bibi2d          |- ( M = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) -> ( ( x = I <-> y = M ) <-> ( x = I <-> y = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) ) ) )
17::eqeq2              |- ( if ( x < I , x , ( x - 1 ) ) = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) -> ( y = if ( x < I , x , ( x - 1 ) ) <-> y = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) ) )
18:17:bibi2d          |- ( if ( x < I , x , ( x - 1 ) ) = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) -> ( ( x = I <-> y = if ( x < I , x , ( x - 1 ) ) ) <-> ( x = I <-> y = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) ) ) )
19::simpr              |- ( ( ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) /\ y = M ) /\ x = I ) -> x = I )
20::simplr             |- ( ( ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) /\ y = M ) /\ x = I ) -> y = M )
21:19,20:2thd         |- ( ( ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) /\ y = M ) /\ x = I ) -> ( x = I <-> y = M ) )
22::simpr              |- ( ( ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) /\ y = M ) /\ -. x = I ) -> -. x = I )
23::eqeq2                |- ( x = if ( x < I , x , ( x - 1 ) ) -> ( y = x <-> y = if ( x < I , x , ( x - 1 ) ) ) )
24:23:notbid            |- ( x = if ( x < I , x , ( x - 1 ) ) -> ( -. y = x <-> -. y = if ( x < I , x , ( x - 1 ) ) ) )
25::eqeq2                |- ( ( x - 1 ) = if ( x < I , x , ( x - 1 ) ) -> ( y = ( x - 1 ) <-> y = if ( x < I , x , ( x - 1 ) ) ) )
26:25:notbid            |- ( ( x - 1 ) = if ( x < I , x , ( x - 1 ) ) -> ( -. y = ( x - 1 ) <-> -. y = if ( x < I , x , ( x - 1 ) ) ) )
27:8:ad3antrrr             |- ( ( ( ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) /\ y = M ) /\ -. x = I ) /\ x < I ) -> x e. RR )
28:6:ad2antll               |- ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) -> y e. RR )
29:28:ad3antrrr            |- ( ( ( ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) /\ y = M ) /\ -. x = I ) /\ x < I ) -> y e. RR )
30:7:ad2antlr               |- ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) -> I e. RR )
31:30:ad3antrrr            |- ( ( ( ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) /\ y = M ) /\ -. x = I ) /\ x < I ) -> I e. RR )
32::simpr                  |- ( ( ( ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) /\ y = M ) /\ -. x = I ) /\ x < I ) -> x < I )
33::elfzle2                  |- ( I e. ( 1 ... M ) -> I <_ M )
34:33:ad5antlr              |- ( ( ( ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) /\ y = M ) /\ -. x = I ) /\ x < I ) -> I <_ M )
35::simpllr                 |- ( ( ( ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) /\ y = M ) /\ -. x = I ) /\ x < I ) -> y = M )
36:34,35:breqtrrd          |- ( ( ( ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) /\ y = M ) /\ -. x = I ) /\ x < I ) -> I <_ y )
37:27,31,29,32,36:ltletrd
                          |- ( ( ( ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) /\ y = M ) /\ -. x = I ) /\ x < I ) -> x < y )
38:27,37:gtned           |- ( ( ( ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) /\ y = M ) /\ -. x = I ) /\ x < I ) -> y =/= x )
39:38:neneqd            |- ( ( ( ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) /\ y = M ) /\ -. x = I ) /\ x < I ) -> -. y = x )
40::                    |- ( ( ( ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) /\ y = M ) /\ -. x = I ) /\ -. x < I ) -> -. y = ( x - 1 ) )
41:24,26,39,40:ifbothda
                       |- ( ( ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) /\ y = M ) /\ -. x = I ) -> -. y = if ( x < I , x , ( x - 1 ) ) )
42:22,41:2falsed      |- ( ( ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) /\ y = M ) /\ -. x = I ) -> ( x = I <-> y = if ( x < I , x , ( x - 1 ) ) ) )
43:16,18,21,42:ifbothda
                     |- ( ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) /\ y = M ) -> ( x = I <-> y = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) ) )
44::                 |- ( ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) /\ -. y = M ) -> ( x = if ( y < I , y , ( y + 1 ) ) <-> y = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) ) )
45:12,14,43,44:ifbothda
                    |- ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) -> ( x = if ( y = M , I , if ( y < I , y , ( y + 1 ) ) ) <-> y = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) ) )
qed:1,9,10,45:f1o2d
                   |- ( ( M e. NN /\ I e. ( 1 ... M ) ) -> F : ( 1 ... M ) -1-1-onto-> ( 1 ... M ) )

@metakunt
Copy link
Contributor Author

metakunt commented Apr 8, 2024

Alright I was working few hours on this problem. The learning curve is really steep.
First I was trying to resolve 44. Here I am a bit stuck since I struggle to fill in the values of the autocomplete

!d1::              |- (    M
                         = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) )
                      -> (   &W2
                         <-> (   x = if ( y < I , y , ( y + 1 ) )
                             <->   y
                                 = if
                                   (  x = I
                                   ,  M
                                   ,  if ( x < I , x , ( x - 1 ) ) ) ) ) )
!d2::              |- (    if ( x < I , x , ( x - 1 ) )
                         = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) )
                      -> (   &W3
                         <-> (   x = if ( y < I , y , ( y + 1 ) )
                             <->   y
                                 = if
                                   (  x = I
                                   ,  M
                                   ,  if ( x < I , x , ( x - 1 ) ) ) ) ) )
!d3::              |- (  (  (  (  ( M e. NN /\ I e. ( 1 ... M ) )
                               /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) )
                            /\ -. y = M )
                         /\ x = I )
                      -> &W2 )
!d4::              |- (  (  (  (  ( M e. NN /\ I e. ( 1 ... M ) )
                               /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) )
                            /\ -. y = M )
                         /\ -. x = I )
                      -> &W3 )
44:d1,d2,d3,d4:ifbothda 
                   |- ( ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) /\ -. y = M ) -> ( x = if ( y < I , y , ( y + 1 ) ) <-> y = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) ) )

My thought process is to use the same &W2 and &W3 as you
&W2 ( x = I <-> y = M )
&W3 ( x = I <-> y = if ( x < I , x , ( x - 1 ) ) )
But even if I use it I don't understand the idea behind this substitution. If you have any explanation that would be great.

I am also struggling to understand your bootstrapping of the theorem. I see that you are using eqeq2 and bibiid* and I see that it works, but I don't understand the rationale behind it. For example if I try to finish the problem I already know that I will have problems with nested ifs and I don't know how to resolve them

Next I've tried to resolve 40 partially. It is hideous, but for now I am happy that I was way faster. It only took me 8 hours to get that down, and some proof steps are also done via deduction, which I am somewhat happy that I am slowly grasping the concepts. But some things are still unclear.

Intuitively it is clear
If y = x-1, then x = y+1, but y is m so x = m+1. However

$$x\in \{1,\dots,m\} \implies x \leq m$$

and

$$m < m +1 = x \leq m \implies m < m$$

Which is a contradiction.
The line 40 is unclear how to resolve. I was researching the rules in the negation section, there must be an easy way to solve it

40::                    |- ( ( ( ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) /\ y = M ) /\ -. x = I ) /\ -. x < I ) -> -. y = ( x - 1 ) )

I tried it out

50:: |- ( ph -> A e. CC )
51::1cnd |- ( ph -> 1 e. CC )
52::1red |- ( 1 e. CC -> 1 e. RR )
53:51,52:syl   |- ( ph -> 1 e. RR )
54::rexr |- ( 1 e. RR -> 1 e. RR* )
55:51,52,54:3syl |- ( ph -> 1 e. RR* )
56:: |- ( ph -> M e. NN )
57::nnre |- ( M e. NN -> M e. RR )
58:56,57:syl   |- ( ph -> M e. RR )
59:53,58:jca       |- ( ph -> (  1 e. RR  /\   M e. RR  ) )
60::rexr |- ( M e. RR -> M e. RR* )
61:56,57,60:3syl   |- ( ph -> M e. RR* )

62::   |- ( ph -> x e. ( 1 ... M ) )
63::elfzelz |- ( x e. ( 1 ... M ) -> x e. ZZ )
64::zre |- ( x e. ZZ -> x e. RR )
65::recn   |- ( x e. RR -> x e. CC )
66:62,63,64,65:4syl  |- ( ph -> x e. CC )
67::rexr |- ( x e. RR -> x e. RR* )
68:63,64,67:3syl   |- ( x e. ( 1 ... M ) -> x e. RR* )
69:62,68:syl |- ( ph -> x e. RR* )
70:69,61:jca |- ( ph -> ( x e. RR* /\ M e. RR* ) )
71::elfzle2   |- ( x e. ( 1 ... M ) ->  x <_ M )
72:62,71:syl       |- ( ph -> x <_ M )
73:66,51:jca   |- ( ph -> ( x e. CC /\  1 e. CC ) ) 
74:66,51:subcld  |- ( ph -> ( x - 1 ) e. CC )
75::npcan |- ( ( x e. CC /\ 1 e. CC ) -> ( ( x - 1 ) + 1 ) = x ) 
76:73,75:syl       |- (  ph -> ( ( x - 1 ) + 1 ) = x )
77:: |- ( ph ->  M = ( x - 1 ) )
78:77:oveq1d |- ( ph ->  ( M + 1 ) = ( ( x - 1 ) + 1 ) )
79:78,76:eqtrd |- ( ph ->  ( M + 1 ) = x )
80::xrlenlt        |- (  ( x e. RR* /\ M e. RR* ) -> ( x <_ M <-> -. M < x ) )
81:70,80:syl       |- (  ph -> ( x <_ M <-> -. M < x ) )
82:72,81:mpbid    |- (  ph ->  -. M < x ) 

84::   |- ( ( ( ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) /\ y = M ) /\ -. x = I ) /\ -. x < I ) -> -. y = ( x - 1 ) )
85::eqeq1 |- ( y = M -> ( y = ( x - 1 ) <-> M = ( x - 1 ) ) )
86::   |- ( y = M -> ( y = ( x - 1 ) <-> ( M + 1 ) = x ) )
87::elfzle2 |- ( x e. ( 1 ... M ) -> x <_ M )
88:: |- ( ( A e. NN /\ B e. NN ) -> A < ( A + B ) )

89::ltaddpos       |- (  ( 1 e. RR /\ M e. RR ) -> ( 0 < 1 <-> M < ( M + 1 ) ) )
90::0lt1 |- 0 < 1
91:90,89:mpbii |- (  ( 1 e. RR /\ M e. RR ) ->  M < ( M + 1 ) )

92:59,91:syl |- ( ph -> M < ( M + 1 ) )
*substitution
93:86,92: |- ( ph -> ( y = ( x - 1 ) <-> M < x ) )
94::lelttr         |- (  ( M e. RR /\ x e. RR /\ M e. RR ) -> ( ( M <_ x /\ x < M ) -> M < M ) )
95::leid           |- ( M e. RR -> M <_ M )
96:: |- ( ph -> ( M e. RR /\ x e. RR /\ M e. RR ) )
97:96,94:syl       |- (  ph -> ( ( M <_ x /\ x < M ) -> M < M ) )
*I DON'T KNOW HOW THIS WORKS :( This should be a contradiction but I don't know which rule to use.
*I cant negate the whole ph, i just want to negate the inner statement in 93
*Basically I want to show 
98:93,97: |- ( ph -> -. M < x )
*Which should give me
99:98,93:mtbird |- ( ph -> -. y = ( x - 1 )  )

The deduction mode takes time to get used to, but I think it will be better. This is my proof of concept, I likely will need to rewrite it eventually to make sure that ph is correct.

Do you have any feedback, I'd love to hear it.
Thanks

@icecream17
Copy link
Contributor

icecream17 commented Apr 9, 2024

in this case the theorem is mtod and xrltnr

also perhaps looking at the proof of mteqand and the various theorems that use it would be helpful


Perhaps we should add a section on how to find theorems we don't know about. There are two strategies I can think of:

using the website: table of contents, this theorem is referenced by, definitons, and nearby theorems

using the search functionality of metamath.exe, mmj2, or the online metamath proof maker (I forget the name, feel free to edit my post)

Although dealing with propositions is less amenable to these strategies. It's why earlier me proved ioin9i8, because it was a very nontrivial process for past me to figure out...

@tirix
Copy link
Contributor

tirix commented Apr 9, 2024

First I was trying to resolve 44. Here I am a bit stuck since I struggle to fill in the values of the autocomplete

Here is how to complete the hypotheses for ifbothda at step 44:

d5::eqeq2            |- ( M = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) -> ( y = M <-> y = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) ) )
d1:d5:bibi2d        |- ( M = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) -> ( ( x = if ( y < I , y , ( y + 1 ) ) <-> y = M ) <-> ( x = if ( y < I , y , ( y + 1 ) ) <-> y = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) ) ) )
d6::eqeq2            |- ( if ( x < I , x , ( x - 1 ) ) = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) -> ( y = if ( x < I , x , ( x - 1 ) ) <-> y = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) ) )
d2:d6:bibi2d        |- ( if ( x < I , x , ( x - 1 ) ) = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) -> ( ( x = if ( y < I , y , ( y + 1 ) ) <-> y = if ( x < I , x , ( x - 1 ) ) ) <-> ( x = if ( y < I , y , ( y + 1 ) ) <-> y = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) ) ) )
d3::                |- ( ( ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) /\ -. y = M ) /\ x = I ) -> ( x = if ( y < I , y , ( y + 1 ) ) <-> y = M ) )
d4::                |- ( ( ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) /\ -. y = M ) /\ -. x = I ) -> ( x = if ( y < I , y , ( y + 1 ) ) <-> y = if ( x < I , x , ( x - 1 ) ) ) )
44:d1,d2,d3,d4:ifbothda
                   |- ( ( ( ( M e. NN /\ I e. ( 1 ... M ) ) /\ ( x e. ( 1 ... M ) /\ y e. ( 1 ... M ) ) ) /\ -. y = M ) -> ( x = if ( y < I , y , ( y + 1 ) ) <-> y = if ( x = I , M , if ( x < I , x , ( x - 1 ) ) ) ) )

The idea is that we handle the cases of the if, so each d1 and d2 correspond to one of those cases:

  • d1 is the first case, if x = I, the "if" expression resolves to M. So the &W2 is what we want to prove, with the "if" expression substituted with M
  • d2 is the second case, if -. x = I, the "if" expression resolves to the other embedded if expression.

Then d3 adds x = I as an assumption, and you need to prove there that &W2, the target statement with the "if" expression substituted with M, holds.

In d3, obviously both statements are false, so I would continue with a ~ 2falsed (similar to step my 42 above)

This results again in a two-cases situation with an if, so the recipe is again to use ~ifbothda.

@metakunt
Copy link
Contributor Author

metakunt commented Apr 14, 2024

Ah thanks, sorry I was busy working and I couldn't reply.

I think I might have chosen the wrong path to define the function.

Recently I was thinking by defining F as a union F1, F2, F3. where
F1: x<I -> x |-> x
F2: x = I -> x|-> M
F3: x > I -> x |-> x-1

All I want is to have function definitions so that I can evaluate F(x). But to do that I need to be able to make sure that there exists exaclty one y such that xFy. This has been so far the bane of my problems.

By defining F1,F2,F3 I wanted to show independently that they are 1-1 and onto with disjoint domains and ranges and then glue them together.
Because the definition includes only = and not $\in$ I thought there are some results to show that only one such y can exist.

I think this is a more sensible approach, but I have no reference if that will actually be easier.
Ultimately my goal is to define $\delta$ and show that $\delta = \alpha^{-1}\circ\beta\circ\alpha$, where I know that $\alpha, \beta$ is bijective, i can also conclude that $\delta$ is bijective.

Does my approach make sense, and if so what's the best way moving forward. I was thinking of defining F3 something like that

$$F_3 = \{ (x,y) \in \{i+1,\dots,M\} \times \{i,\dots,M-1\} ~\vert~x=y-1 \}$$

But then I would need to show that F_3 is a function from ${i+1,\dots,M}$ to ${i,\dots,M-1}$ and here I am struggling. Not only that, I also have issues to show that it is bijective. My hope for injectivity was to show that

$$x_1 < x_2 \implies F(x_1)=x_1-1, F(x_2)=x_2-1$$

and

$$x_1 < x_2 \implies x_1 - 1 < x_2 -1 \implies F(x_1) < F(x_2)$$

I have figured that my reasoning is abstract, since I know why this function is surjective, but without knowing how to prove it in metamath.

@icecream17
Copy link
Contributor

the idea would work ( ~ f1oco )

I think it would work similarly to tirix's proof above, where a theorem like f1o2d would be used (f1o2d seems like the most practical theorem for proving bijectivity)

(incidentally I thought the proof would make this task solved)

@tirix
Copy link
Contributor

tirix commented Apr 15, 2024

Actually writing the function as a union of other functions is a clever idea.

Proving that each individual function is 1-1 and onto should not be too difficult (we have for example icoshftf1o, maybe the same on integer intervals could be written if it does not exist yet), and then proving that the different intervals are disjoint could work with theorems like ~fzodisj. Finally there is ~f1oun to glue the functions together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants