Zulip Chat Archive

Stream: Is there code for X?

Topic: Minimal relation satisfying `trans_gen`


Patrick Johnson (Jan 02 2022 at 10:25):

While working on improving and generalizing definitions in the formalization of the angel problem, I spent too much time wrestling with this lemma:

import logic.relation
import set_theory.cardinal
open relation
open_locale cardinal

example {α : Type*} {R : α  set α} {t : α} :
   (r : α  set α),  x,
  (r x  R x) 
  (# (r x) = min (# (R x)) 1) 
  (trans_gen R x t  trans_gen r x t) :=
begin
  sorry
end

What is the easiest way to prove it? I tried several different approaches, but haven't finished any of them, because things start to get complicated.

Here is an informal proof (I just don't know what's the easiest way to translate it to Lean): We explicitly construct relation r. Given some (x : α). If R x is empty, then r x is empty too. Otherwise, if trans_gen R x t is false, then return the singleton containing some element of R x (using the axiom of choice). If trans_gen R x t is true, it must be constructed using trans_gen.tail, which takes some (y : α) and proofs of trans_gen R x y and R y t. Return the singleton containing that y (we can't obtain y directly, because of proof irrelevance, but it exists, so we can use the axiom of choice).

It turns out that the problem is t being fixed, so we can't easily prove that transitivity works for some other t.

My attempt

Eric Wieser (Jan 02 2022 at 10:31):

You should either change r to α → α → Prop and replace r x with {y | r x y}, or replace trans_gen r with trans_gen (λ x y, y ∈ r x), else you'll end up with a nonsense goal along the way

Patrick Johnson (Jan 02 2022 at 10:40):

Sure, I'll polish the proof in the end. But I somehow managed to establish a mental model to literally see y ∈ r x as r x y, or {x} y as y = x, or ∅ x as false. :upside_down:

David Wärn (Jan 02 2022 at 10:50):

This is basically docs#quiver.geodesic_arborescence. It shows that in a directed graph where there is a path from r to any other vertex, there is a subgraph where there is a unique path from r to every other vertex. Of course there is a wrinkle in that your lemma doesn't assume that there are paths to t...

David Wärn (Jan 02 2022 at 11:08):

BTW I don't think your proof sketch will work. For example suppose α is with_top nat, R is <, and t is top. If you're unlucky, the axiom of choice will pick r n = {n+1}. Then trans_gen r n top is always false: if you follow the path from n in r you will just go n -> n+1 -> n+2 ... forever. This issue is basically the reason to use the 'geodesic' subgraph. I see that you use a different choice of r in the code above, which will work on this counterexample, but you can construct another counterexample where it doesn't work by adding one more top' which is related to top but not to n : nat.

Patrick Johnson (Jan 02 2022 at 12:24):

Thanks. I'll play with geodesic subgraph and see how it goes.

Patrick Johnson (Jan 02 2022 at 15:48):

As a side question, how to finish this subgoal?

example {α : Type*} {S : set α}
  (h : ¬S = ) :
  1  # S :=
begin
  sorry
end

Patrick Johnson (Jan 02 2022 at 15:56):

I have this proof, but it looks very ugly. I hope there is a better way:

example {α : Type*} {S : set α}
  (h : ¬S = ) :
  1  # S :=
begin
  rw set.eq_empty_iff_forall_not_mem at h,
  push_neg at h,
  cases h with x h,
  fsplit, fsplit,
  { intro u, exact x, h },
  { rintro a b h₁, cases h₁, simp, },
end

Yaël Dillies (Jan 02 2022 at 15:58):

Looks like you should switch over to finset and use docs#finset.one_le_card_iff

Stuart Presnell (Jan 02 2022 at 16:03):

Does docs#cardinal.one_le_iff_ne_zero help?

Reid Barton (Jan 02 2022 at 16:04):

and docs#cardinal.mk_ne_zero_iff

Ruben Van de Velde (Jan 02 2022 at 19:14):

import logic.relation
import set_theory.cardinal

open_locale cardinal

example {α : Type*} {S : set α}
  (h : ¬S = ) :
  1  # S :=
begin
  suffices : # S  0,
  { -- library_search
    refine cardinal.one_le_iff_ne_zero.mpr this },
  contrapose! h,
  -- library_search
  refine cardinal.mk_emptyc_iff.mp h,
end

Stuart Presnell (Jan 02 2022 at 19:37):

Or, condensing it further:

import logic.relation
import set_theory.cardinal

open_locale cardinal

example {α : Type*} {S : set α}
  (h : ¬S = ) :
  1  # S :=
cardinal.one_le_iff_ne_zero.mpr (mt cardinal.mk_emptyc_iff.mp h)

Patrick Johnson (Jan 02 2022 at 20:09):

It's interesting how the "side question" turns out to be so bikesheddy. But thanks, those proofs are definitely shorter than mine.


Last updated: Dec 20 2023 at 11:08 UTC