Zulip Chat Archive

Stream: new members

Topic: Bijective 4


Răzvan Flavius Panda (Jul 18 2025 at 19:40):

Trying to prove: https://github.com/hrmacbeth/math2001/blob/e660f42b13ddcb6d12b52ba036d6bd071a0cfb9b/Math2001/08_Functions/02_Bijective.lean#L191

Haven't got much:

example :  f : Subatomic  Subatomic, Injective f  Bijective f := by
  intro f h
  constructor
  · exact h
  · dsimp [Surjective]
    dsimp [Injective] at h
    intro b

I don't know how to proceed further.

Aaron Liu (Jul 18 2025 at 19:41):

you have to start casing on b

Răzvan Flavius Panda (Jul 18 2025 at 19:43):

I tried cases b but did not know how to solve the sub-goals. Do I need to treat every possible implementation of function f?

Aaron Liu (Jul 18 2025 at 19:43):

yes, unless you want to develop the theory of finiteness

Aaron Liu (Jul 18 2025 at 19:44):

you can choose to do that instead, but be warned it is quite tricky

Răzvan Flavius Panda (Jul 18 2025 at 19:44):

I'll try every implementation of f. How do I do that?

Aaron Liu (Jul 18 2025 at 19:46):

what you want to do is do cases on f u where u is running through all the constructors of Subatomic

Răzvan Flavius Panda (Jul 18 2025 at 19:47):

That sounds like the code is insulting me haha

Aaron Liu (Jul 18 2025 at 19:47):

do cases helec : f .electron so you can remember what you're casing on

Răzvan Flavius Panda (Jul 18 2025 at 20:18):

Didn't quite get exactly what to do, I tried:

    cases b
    cases helec : f .electron

f : Subatomic → Subatomic
h : ∀ ⦃a₁ a₂ : Subatomic⦄, f a₁ = f a₂ → a₁ = a₂
helec : f electron = proton
∃ a, f a = proton
f : Subatomic → Subatomic
h : ∀ ⦃a₁ a₂ : Subatomic⦄, f a₁ = f a₂ → a₁ = a₂
helec : f electron = neutron
∃ a, f a = proton
f : Subatomic → Subatomic
h : ∀ ⦃a₁ a₂ : Subatomic⦄, f a₁ = f a₂ → a₁ = a₂
helec : f electron = electron
∃ a, f a = proton
f : Subatomic → Subatomic
h : ∀ ⦃a₁ a₂ : Subatomic⦄, f a₁ = f a₂ → a₁ = a₂
∃ a, f a = neutron
f : Subatomic → Subatomic
h : ∀ ⦃a₁ a₂ : Subatomic⦄, f a₁ = f a₂ → a₁ = a₂
∃ a, f a = electron

Răzvan Flavius Panda (Jul 18 2025 at 20:19):

I see first sub-goal is solvable but not the 2nd sub-goal.

Aaron Liu (Jul 18 2025 at 20:21):

Well you need to case on f neutron and f proton too

Răzvan Flavius Panda (Jul 18 2025 at 20:22):

Like so?

    cases b
    cases helec1 : f .electron
    cases helec2 : f .proton
    cases helec3 : f .neutron

Aaron Liu (Jul 18 2025 at 20:22):

idk maybe save the cases b for last

Aaron Liu (Jul 18 2025 at 20:23):

Also each cases generates multiple subgoals so you should immediately indent them with the focusing dot

Răzvan Flavius Panda (Jul 18 2025 at 20:25):

Aaron Liu said:

Also each cases generates multiple subgoals so you should immediately indent them with the focusing dot

I don't get how that works. Could you show me?

Răzvan Flavius Panda (Jul 18 2025 at 20:34):

These goals are clearly not all the possibilities:

f : Subatomic → Subatomic
h : ∀ ⦃a₁ a₂ : Subatomic⦄, f a₁ = f a₂ → a₁ = a₂
helec1 : f electron = proton
helec2 : f proton = proton
helec3 : f neutron = proton
∃ a, f a = proton
f : Subatomic → Subatomic
h : ∀ ⦃a₁ a₂ : Subatomic⦄, f a₁ = f a₂ → a₁ = a₂
helec1 : f electron = proton
helec2 : f proton = proton
helec3 : f neutron = proton
∃ a, f a = neutron
f : Subatomic → Subatomic
h : ∀ ⦃a₁ a₂ : Subatomic⦄, f a₁ = f a₂ → a₁ = a₂
helec1 : f electron = proton
helec2 : f proton = proton
helec3 : f neutron = proton
∃ a, f a = electron
f : Subatomic → Subatomic
h : ∀ ⦃a₁ a₂ : Subatomic⦄, f a₁ = f a₂ → a₁ = a₂
b : Subatomic
helec1 : f electron = proton
helec2 : f proton = proton
helec3 : f neutron = neutron
∃ a, f a = b
f : Subatomic → Subatomic
h : ∀ ⦃a₁ a₂ : Subatomic⦄, f a₁ = f a₂ → a₁ = a₂
b : Subatomic
helec1 : f electron = proton
helec2 : f proton = proton
helec3 : f neutron = electron
∃ a, f a = b
f : Subatomic → Subatomic
h : ∀ ⦃a₁ a₂ : Subatomic⦄, f a₁ = f a₂ → a₁ = a₂
b : Subatomic
helec1 : f electron = proton
helec2 : f proton = neutron
∃ a, f a = b
f : Subatomic → Subatomic
h : ∀ ⦃a₁ a₂ : Subatomic⦄, f a₁ = f a₂ → a₁ = a₂
b : Subatomic
helec1 : f electron = proton
helec2 : f proton = electron
∃ a, f a = b
f : Subatomic → Subatomic
h : ∀ ⦃a₁ a₂ : Subatomic⦄, f a₁ = f a₂ → a₁ = a₂
b : Subatomic
helec1 : f electron = neutron
∃ a, f a = b
f : Subatomic → Subatomic
h : ∀ ⦃a₁ a₂ : Subatomic⦄, f a₁ = f a₂ → a₁ = a₂
b : Subatomic
helec1 : f electron = electron
∃ a, f a = b

Răzvan Flavius Panda (Jul 18 2025 at 20:34):

Also cases b doesn't seem to do anything to the last few goals, it stays f a = b

Aaron Liu (Jul 18 2025 at 20:37):

like I said, there are multiple goals

Aaron Liu (Jul 18 2025 at 20:37):

here's a sample

    cases helec1 : f .electron with
    | proton =>
      cases helec2 : f .proton with
      | proton =>
        exfalso
        sorry
      | neutron =>
        cases helec3 : f .neutron with
        | proton =>
          exfalso
          sorry
        | neutron =>
          exfalso
          sorry
        | electron =>
          cases b with
          | proton =>
            sorry
          | neutron =>
            sorry
          | electron =>
            sorry
      | electron =>
        sorry
    | neutron =>
      sorry
    | electron =>
      sorry

Răzvan Flavius Panda (Jul 18 2025 at 20:37):

Yes, I see that but

Aaron Liu (Jul 18 2025 at 20:37):

you have to run your tactic on every goal

Aaron Liu (Jul 18 2025 at 20:38):

by default it only runs on the first goal

Aaron Liu (Jul 18 2025 at 20:39):

you can also just use the focusing dot like this

    cases helec1 : f .electron
    · sorry
    · sorry
    · sorry

but then you don't get to control what order they come out in

Răzvan Flavius Panda (Jul 18 2025 at 20:40):

This is some Cartesian product stuff. Trying to understand, I still don't get how to fill what you provided.

Aaron Liu (Jul 18 2025 at 20:41):

somehow I don't see cartesian products anywhere

Răzvan Flavius Panda (Jul 18 2025 at 20:41):

It's everything combined with everything.

Aaron Liu (Jul 18 2025 at 20:41):

oh yeah it is

Aaron Liu (Jul 18 2025 at 20:42):

the proof size blows up the more constructors you add

Aaron Liu (Jul 18 2025 at 20:42):

the advantage of developing finiteness is that you can reuse the same proof over and over

Răzvan Flavius Panda (Jul 18 2025 at 20:42):

Is this 3 ^ 4 total goals after I fill up everything above?

Aaron Liu (Jul 18 2025 at 20:42):

some of the branches get cut off early for being impossible

Aaron Liu (Jul 18 2025 at 20:43):

so it's a bit less than that

Aaron Liu (Jul 18 2025 at 20:43):

in particular every branch I put exfalso on is impossible without having to do any more casing

Răzvan Flavius Panda (Jul 18 2025 at 20:44):

What makes the branches be impossible?

Aaron Liu (Jul 18 2025 at 20:45):

the hypotheses you have can make a contradiction with h : Injective f

Răzvan Flavius Panda (Jul 18 2025 at 20:46):

So 2 argument values resolving to same function value?

Aaron Liu (Jul 18 2025 at 20:46):

yes

Răzvan Flavius Panda (Jul 18 2025 at 20:47):

What does exfalso do?

Răzvan Flavius Panda (Jul 18 2025 at 20:47):

I see you still put sorry after exfalso

Aaron Liu (Jul 18 2025 at 20:47):

changes the goal to False

Aaron Liu (Jul 18 2025 at 20:47):

the reason I still put sorry is because you still need to prove a contradiction

Răzvan Flavius Panda (Jul 18 2025 at 20:47):

Oh

Aaron Liu (Jul 18 2025 at 20:47):

I think probably after you finish the proofs you can remove the exfalso

Răzvan Flavius Panda (Jul 18 2025 at 20:49):

This proof is driving me insane.
I chose the wrong way to solve it.

Răzvan Flavius Panda (Jul 18 2025 at 20:50):

Aaron Liu said:

yes, unless you want to develop the theory of finiteness

How would this proof work?

Aaron Liu (Jul 18 2025 at 20:50):

developing finiteness takes probably at least twice as long depending on the exact way you do it

Răzvan Flavius Panda (Jul 18 2025 at 20:51):

The thing is, next exercise is the same thing but with a type that has 4 constructors:

example :  f : Element  Element, Injective f  Bijective f := by

Răzvan Flavius Panda (Jul 18 2025 at 20:52):

Going through 4 ^ 4 combinations even with dead ends is a lot.

Răzvan Flavius Panda (Jul 18 2025 at 20:53):

I don't understand why the book did not choose an exercise with 2 constructors only. That would have been a gentle introduction to solving it.

Răzvan Flavius Panda (Jul 18 2025 at 20:53):

And in the end 2, 3, 4, etc. same thing just more work.

Aaron Liu (Jul 18 2025 at 21:03):

Răzvan Flavius Panda said:

Aaron Liu said:

yes, unless you want to develop the theory of finiteness

How would this proof work?

lots of steps, I had a go at this once (exact same problem), this is the plan I came up with

  • define a type as finite if you can put all its elements into a List without missing any
  • prove that finite type can't admit an injection from Nat
  • prove that if f^[a + c] x = f^[b + c] x then f^[a] x = f^[b] x if f is injective
  • prove that iterating an injective function from a finite type to itself sends every element in a loop
  • show injective functions from a finite type to itself are surjective
  • show that Subatomic and Element are finite

Răzvan Flavius Panda (Jul 18 2025 at 21:04):

Wow, yeah, that is a lot of things to prove.

Răzvan Flavius Panda (Jul 18 2025 at 21:05):

Ok, I think I will just skip this exercise for now and maybe come back to it when I get better at LEAN.

Răzvan Flavius Panda (Jul 18 2025 at 21:05):

I am kind of looking forward to working on another book. This book was good but felt like it was missing a lot of explanations.

Răzvan Flavius Panda (Jul 18 2025 at 21:06):

Thank you for the explanations.


Last updated: Dec 20 2025 at 21:32 UTC