Zulip Chat Archive

Stream: graph theory

Topic: Any low hanging fruits related to SimpleGraph?


Lessness (Oct 24 2023 at 12:50):

The title. I want to prove something for training purposes about simple graphs (and too lazy to browse Mathlib documentation, at least right now :sweat_smile:).

Cheers! :tea:

Shreyas Srinivas (Oct 24 2023 at 12:51):

I don't know how low this is, but given that a formulation already exists in Isabelle: Berge's Lemma

Lessness (Oct 24 2023 at 12:51):

Oh, thank you! Will try doing it.

Lessness (Oct 24 2023 at 14:58):

Do you know where to find the Isabelle proof of Berge's Lemma? I only found the arXiv publication here. It states that their proof was different from standard proof and shorter than it.

Shreyas Srinivas (Oct 24 2023 at 20:57):

They describe their shorter proof there. I thought there was an AFP entry for it. I'll ask the author.

Lessness (Oct 25 2023 at 11:20):

Thank you!

Lessness (Oct 25 2023 at 11:22):

Does this formulation of Berge's Lemma makes sense?

import Mathlib.Init.Function
import Mathlib.Combinatorics.SimpleGraph.Matching
import Mathlib.Combinatorics.SimpleGraph.Finsubgraph
import Mathlib.Combinatorics.SimpleGraph.Connectivity


def IsMaximum {V} {G: SimpleGraph V} {M: SimpleGraph.Finsubgraph G} (H: M.val.IsMatching): Prop :=
  forall (M': SimpleGraph.Finsubgraph G) (H': M'.val.IsMatching),
  exists (f: M'.val.verts -> M.val.verts), Function.Injective f

mutual
  def AlternatingWalkFalse {V} {G: SimpleGraph V} (M: SimpleGraph.Finsubgraph G) {x y: V}: SimpleGraph.Walk G x y -> Prop
  | SimpleGraph.Walk.nil => True
  | @SimpleGraph.Walk.cons _ _ x' y' _ _ p => (M.val.Adj x' y' -> False) /\ AlternatingWalkTrue M p
  def AlternatingWalkTrue {V} {G: SimpleGraph V} (M: SimpleGraph.Finsubgraph G) {x y: V}: SimpleGraph.Walk G x y -> Prop
  | SimpleGraph.Walk.nil => True
  | @SimpleGraph.Walk.cons _ _ x' y' _ _ p => M.val.Adj x' y' /\ AlternatingWalkFalse M p
end

def AugmentingPath {V} {G: SimpleGraph V} (M: SimpleGraph.Finsubgraph G) {x y: V} (P: SimpleGraph.Path G x y): Prop :=
  (Set.Mem x M.val.verts -> False) /\
  (Set.Mem y M.val.verts -> False) /\
  AlternatingWalkFalse M P.val

theorem Berge's_lemma {V} {G: SimpleGraph V} {M: SimpleGraph.Finsubgraph G} (H: M.val.IsMatching):
  IsMaximum H <-> (forall (x y: V) (P: SimpleGraph.Path G x y), AugmentingPath M P -> False) := by
  sorry

Lessness (Oct 25 2023 at 11:24):

Especially definition of IsMaximum which, probably, could be defined in some better way.

Shreyas Srinivas (Oct 25 2023 at 11:48):

So first a little bit of notational clean up:

import Mathlib


def IsMaximum {V} {G: SimpleGraph V} {M: SimpleGraph.Finsubgraph G} (_: M.val.IsMatching): Prop :=
   (M': SimpleGraph.Finsubgraph G), M'.val.IsMatching 
     (f: M'.val.verts -> M.val.verts), Function.Injective f

mutual
  def AlternatingWalkFalse {V} {G: SimpleGraph V} (M: SimpleGraph.Finsubgraph G) {x y: V}: SimpleGraph.Walk G x y -> Prop
  | SimpleGraph.Walk.nil => True
  | @SimpleGraph.Walk.cons _ _ x' y' _ _ p => (M.val.Adj x' y' -> False)  AlternatingWalkTrue M p
  def AlternatingWalkTrue {V} {G: SimpleGraph V} (M: SimpleGraph.Finsubgraph G) {x y: V}: SimpleGraph.Walk G x y -> Prop
  | SimpleGraph.Walk.nil => True
  | @SimpleGraph.Walk.cons _ _ x' y' _ _ p => M.val.Adj x' y'   AlternatingWalkFalse M p
end

def AugmentingPath {V} {G: SimpleGraph V} (M: SimpleGraph.Finsubgraph G) {x y: V} (P: SimpleGraph.Path G x y): Prop :=
  (x  M.val.verts)   (y  M.val.verts) 
  AlternatingWalkFalse M P.val

theorem Berge's_lemma {V} {G: SimpleGraph V} {M: SimpleGraph.Finsubgraph G} (H: M.val.IsMatching):
  IsMaximum H  ( (x y: V) (P: SimpleGraph.Path G x y), AugmentingPath M P  False) := by
  sorry

Shreyas Srinivas (Oct 25 2023 at 11:51):

Secondly, I am not sure how Berge's theorem applies to infinite graphs, but this is partly because I have not touched this area in a long time. The proof that I mentioned works naturally for the case of finite graphs. SimpleGraph V is not finite by default

Yaël Dillies (Oct 25 2023 at 11:52):

You can always just assume Finite V.

Shreyas Srinivas (Oct 25 2023 at 11:52):

Yeah that's what I wanted to say

Shreyas Srinivas (Oct 25 2023 at 11:53):

Further, when you limit yourself to finite graphs (perhaps with Finite or Finset), you can use the cardinality based definition of maximum matching

Shreyas Srinivas (Oct 25 2023 at 11:54):

And then consider the definition of augmenting path

Shreyas Srinivas (Oct 25 2023 at 11:56):

It it based on alternating walks.

Shreyas Srinivas (Oct 25 2023 at 11:56):

which need not terminate even in finite graphs

Shreyas Srinivas (Oct 25 2023 at 12:03):

Also, I am not sure why you are calling IsMaximum on a proof that M is a matching without using the proof.

Lessness (Oct 25 2023 at 12:53):

Aren't walks basically a finite list, which always terminate? Or I'm misunderstanding something.

Lessness (Oct 25 2023 at 12:55):

Shreyas Srinivas said:

Also, I am not sure why you are calling IsMaximum on a proof that M is a matching without using the proof.

Fixed.

Shreyas Srinivas (Oct 25 2023 at 12:58):

A walk can loop indefinitely.

Shreyas Srinivas (Oct 25 2023 at 12:59):

unlike a path.

Shreyas Srinivas (Oct 25 2023 at 13:01):

A path requires a sequence of distinct vertices which form a walk. walks don't have the distinctness requirement.

Shreyas Srinivas (Oct 25 2023 at 13:04):

An alternating walk which is looping at the end won't be augmenting.

Lessness (Oct 25 2023 at 13:09):

One can't define infinitely long walk, as I believe, even if there are loops. At least in Lean it will be finite, as inductive datatypes do.

Shreyas Srinivas (Oct 25 2023 at 13:18):

No it is not just about infinite walks. Berge's theorem holds for augmenting paths, not augmenting walks.

Shreyas Srinivas (Oct 25 2023 at 13:21):

An augmenting walk can loop back to the beginning and it will meet the definition of an augmenting walk (be alternating with both endpoints unmatched). But augmenting the matching with this path will not give you a larger matching.

Lessness (Oct 25 2023 at 13:23):

def AugmentingPath {V} [Finite V] {G: SimpleGraph V} (M: SimpleGraph.Subgraph G) {x y: V} (P: SimpleGraph.Path G x y): Prop :=
  x  M.verts  y  M.verts  AlternatingWalkFalse M P.val

Here I have P: SimpleGraph.Path G x y, so that should be okay, imho. :thinking:

Shreyas Srinivas (Oct 25 2023 at 13:46):

yes that should work

Lessness (Oct 25 2023 at 13:50):

Lessness said:

Shreyas Srinivas said:

Also, I am not sure why you are calling IsMaximum on a proof that M is a matching without using the proof.

Fixed.

Fixed it back (and changed Finsubgraph to simply Subgraph).

def IsMaximum {V} [Finite V] {G: SimpleGraph V} {M: SimpleGraph.Subgraph G} (_: M.IsMatching): Prop :=
   (M': SimpleGraph.Subgraph G), M'.IsMatching 
   (f: M'.verts -> M.verts), Function.Injective f

Imho, if I remove both M.IsMatchingit goes wrong. I need these hypothesis to talk specifically about Matchings, not some general subgraph.

Lessness (Oct 25 2023 at 13:56):

It's similar to this:

def IsMaximum' {V} [Finite V] {G: SimpleGraph V} (H: { M: SimpleGraph.Subgraph G // M.IsMatching }): Prop :=
   (H': { M': SimpleGraph.Subgraph G // M'.IsMatching }),
   (f: H'.val.verts -> H.val.verts), Function.Injective f

Shreyas Srinivas (Oct 25 2023 at 14:47):

A simpler way to do that is to attach the matching condition to the body of the definition.

Shreyas Srinivas (Oct 25 2023 at 14:49):

Because you don't have to destructure the object of the subtype all the time.

Lessness (Oct 25 2023 at 15:43):

Current version is such:

import Mathlib

def IsMaximum {V} {G: SimpleGraph V} {M: SimpleGraph.Subgraph G} (_: M.IsMatching): Prop :=
   (M': SimpleGraph.Subgraph G), M'.IsMatching 
  M'.support.ncard  M.support.ncard

mutual
  def AlternatingWalkFalse {V} {G: SimpleGraph V} (M: SimpleGraph.Subgraph G) {x y: V}: SimpleGraph.Walk G x y  Prop
  | SimpleGraph.Walk.nil => True
  | @SimpleGraph.Walk.cons _ _ x' y' _ _ p => ¬ M.Adj x' y'  AlternatingWalkTrue M p
  def AlternatingWalkTrue {V} {G: SimpleGraph V} (M: SimpleGraph.Subgraph G) {x y: V}: SimpleGraph.Walk G x y  Prop
  | SimpleGraph.Walk.nil => True
  | @SimpleGraph.Walk.cons _ _ x' y' _ _ p => M.Adj x' y'  AlternatingWalkFalse M p
end

def AugmentingPath {V} {G: SimpleGraph V} (M: SimpleGraph.Subgraph G) {x y: V} (P: SimpleGraph.Path G x y): Prop :=
  x  M.support  y  M.support  AlternatingWalkFalse M P.val

theorem Berge's_lemma {V} [Finite V] {G: SimpleGraph V} {M: SimpleGraph.Subgraph G} (H: M.IsMatching):
  IsMaximum H  ( (x y: V) (P: SimpleGraph.Path G x y), ¬ AugmentingPath M P) := by
  sorry

Lessness (Oct 25 2023 at 15:44):

Will start tinkering with proving this lemma now.

Shreyas Srinivas (Oct 25 2023 at 16:26):

are you comfortable with mutually inductive definitions?

Shreyas Srinivas (Oct 25 2023 at 16:26):

Personally I am not.

Lessness (Oct 25 2023 at 16:43):

It was the easiest way (for me) to define the AugmentingPath. I believe I have no problems with mutual definitions.

Do you have some better suggestion?

Kyle Miller (Oct 25 2023 at 16:49):

I'd say feel free to use the mutually inductive definitions if you have no problems proving things about them, at least for the experience.

Kyle Miller (Oct 25 2023 at 16:50):

You can also make the False/True suffixes be an actual Bool argument to a single definition

Kyle Miller (Oct 25 2023 at 16:53):

I've found before that alternating walks are a real pain to deal with. My last attempt, I made a custom inductive type for them along with maps to plain Walks, since that way you can do cases on the alternating walk and make progress without needing to wrestle with unfolding a definition. https://github.com/leanprover-community/mathlib/blob/a5c872475ef4a299a616d5eb1fc6723128741158/src/hamiltonian2.lean#L458

Lessness (Oct 25 2023 at 16:58):

Kyle Miller said:

You can also make the False/True suffixes be an actual Bool argument to a single definition

Great idea! Done.

Shreyas Srinivas (Oct 25 2023 at 17:45):

you might benefit here from an index which tracks the path length

Lessness (Oct 28 2023 at 13:23):

What did I do wrong here? Or, probably better question, what should I use instead of SimpleGraph.Subgraph.degree?

import Mathlib

#check SimpleGraph.Subgraph.degree

def aux0 {V} [Finite V] {G: SimpleGraph V} {M: G.Subgraph}:
   (x: V), x  M.verts  M.degree x  2 := by
    sorry

It gives me an error: failed to synthesize instance Fintype ↑(SimpleGraph.Subgraph.neighborSet M x).

Yaël Dillies (Oct 28 2023 at 13:24):

Replace [Finite V] by [Fintype V] [DecidableEq V]

Lessness (Oct 28 2023 at 13:25):

Thank you!

Lessness (Oct 28 2023 at 13:28):

Another possible option is, I believe, such:

import Mathlib

def aux0 {V} {G: SimpleGraph V} {M: G.Subgraph}:
   (x: V), x  M.verts  (M.neighborSet x).ncard  2 := by
    sorry

Yaël Dillies (Oct 28 2023 at 13:29):

Please don't use ncard when you know the set is finite. This is going to prove painful further down the line.

Lessness (Oct 28 2023 at 13:30):

Oh, thank you

Shreyas Srinivas (Oct 28 2023 at 13:30):

I am still not sure that using functions with junk values won't result in proving statements that look wrong (emphasis on 'look') and mess with people's minds.

Shreyas Srinivas (Oct 28 2023 at 13:42):

At least in graph theory, the correct default can vary according to the problem.

Lessness (Oct 28 2023 at 13:45):

Hmm, it still don't work for me. Lean still announces that it can't synthesize the instance. :(
Does it work for you?

import Mathlib

def aux0 {V} [Fintype V] [DecidableEq V] {G: SimpleGraph V} (M: G.Subgraph):
   (x: V), x  M.verts  M.degree x  2 := by
    sorry

Kyle Miller (Oct 28 2023 at 13:46):

You probably need [DecidableRel G.Adj] (I take that back, it's unclear which decidability assumption is needed/best)

Kyle Miller (Oct 28 2023 at 13:51):

I think this instance is the one that's not firing because you don't have enough assumptions to get that DecidablePred instance

Kyle Miller (Oct 28 2023 at 13:57):

Shreyas Srinivas said:

I am still not sure that using functions with junk values won't result in proving statements that look wrong (emphasis on 'look') and mess with people's minds.

If you've got a concrete example of this causing an issue in one of your mathlib formalization projects, then feel free to create a new topic explaining it!

Lessness (Oct 28 2023 at 15:12):

What's solution to this? Defining necessary instances by hand?

Anyway, reading/learning about type classes now in "Theorem Proving in Lean 4"... with hope to solve the problem myself, maybe.

Lessness (Oct 28 2023 at 16:42):

This works.

import Mathlib

def aux0 {V} [Fintype V] {G: SimpleGraph V} (M: G.Subgraph) [DecidableRel M.Adj]:
   (x: V), x  M.verts  M.degree x  2 := by sorry

Lessness (Oct 29 2023 at 12:02):

Yes, some progress! :sweat_smile: :partying_face:

Did long proof (probably could be shortened very much when I get more experience) of the lemma

def aux0 {V} {G: SimpleGraph V} {M1 M2: G.Subgraph} (H1: M1.IsMatching) (H2: M2.IsMatching):
  let S := M1.SymmDiff M2
   (x: V), x  S.verts  (S.neighborSet x).encard  2

Lessness (Oct 29 2023 at 13:15):

Any hints how to approach lemma aux1?
It's here at Github.

Shreyas Srinivas (Oct 29 2023 at 13:17):

404 on that link for me

Lessness (Oct 29 2023 at 13:17):

Ow, sorry, yes, it's still private. One minute.

Lessness (Oct 29 2023 at 13:19):

Fixed the link

Lessness (Oct 29 2023 at 13:21):

I probably should at first prove that for all graphs with maximum vertex degree 2 there is only three types of connected components... and then use this information to prove their properties for the symmetrical difference of two matchings.

Shreyas Srinivas (Oct 29 2023 at 13:24):

On my phone right now, but isn't aux0 a theorem?

Lessness (Oct 29 2023 at 13:25):

Yes. Changed def to theorem.

Lessness (Oct 29 2023 at 15:02):

Simplified aux1 formulation to such:

theorem aux1 {V} {G: SimpleGraph V} (M: G.Subgraph):
  ( (x: V), x  M.verts  (M.neighborSet x).encard  2) 
   (c: M.coe.ConnectedComponent),
   (x y: V) (W: G.Walk x y), W.IsTrail  W.toSubgraph = (: G.Subgraph).induce c.supp := by sorry

If I manage to prove this (big if), then the three types of connected components should be easy to prove. Just reason about the length and equality or inequality of the endpoints.

Lessness (Oct 29 2023 at 16:46):

It seems I need to exclude possibility of infinitely big connected components, otherwise it will be impossible to prove the theorem aux1. What's the best way to do that?
Finite V, Finite M.verts or maybe even Finite M.support?

Lessness (Oct 29 2023 at 17:55):

I chose to use Finite V, as it seemed the best (subjectively) to me.

Mauricio Collares (Oct 29 2023 at 18:00):

Quoting Yaël's advice:

Yaël Dillies said:

Replace [Finite V] by [Fintype V] [DecidableEq V]

Mauricio Collares (Oct 29 2023 at 18:00):

I understand this is not exactly what you're asking, but it just seemed relevant

Lessness (Oct 29 2023 at 18:02):

Right, yes.

Lessness (Oct 29 2023 at 18:02):

Thank you!

Lessness (Oct 30 2023 at 17:05):

In need of suggestions/hints for proof of theorem aux1... Thanks in advance.

Graph theory is harder than it seems at the first sight. :sweat_smile:

Lessness (Oct 30 2023 at 17:06):

Lessness said:

It's here at Github.

Kevin Buzzard (Oct 30 2023 at 17:07):

Lessness said:

Graph theory is harder than it seems at the first sight. :sweat_smile:

Yup, Lean even had perfectoid spaces before it had graphs!

Lessness (Oct 30 2023 at 17:10):

Interesting!

Shreyas Srinivas (Oct 30 2023 at 17:12):

As a first simplification, after you have all the finiteness conditions, don't use encard. This is only going to add extra steps.

Shreyas Srinivas (Oct 30 2023 at 17:17):

For further help I will have to play with the proof first.

Lessness (Oct 30 2023 at 17:20):

Ok, so the first step is to get rid of the encard. That I can do.

Kyle Miller (Oct 30 2023 at 17:23):

I feel like encard is the least of your worries -- all you need is some lemma that can go back and forth between (M.neighborSet x).encard ≤ 2 and some other convenient representation, and applying that lemma is hardly a step compared to a full proof of aux1.

Do you have a paper proof yet of aux1, one where you don't cheat and use your intuition about how obvious it is? I find that's usually the biggest problem... Lots of this stuff is a lot more technical than you might think.

Shreyas Srinivas (Oct 30 2023 at 17:25):

You might benefit from just plugging in the interval_cases version of that claim namely that the degree of x is 0, 1, or 2

Kyle Miller (Oct 30 2023 at 17:27):

One argument I can see is that you do induction on the number of edges of M, build up theory for what happens to connected components when you add/delete edges, and then argue that if the edge is joining the connected components then the trails from each connected component's trail must start/end at the vertices being joined since those vertices must be degree <= 1, and so you can join them to make the trail for the joined connected component.

Shreyas Srinivas (Oct 30 2023 at 17:27):

Then you have a separate theorem to prove that a connected graph in which all nodes have degree exactly 2 is a cycle.

Shreyas Srinivas (Oct 30 2023 at 17:28):

Then a slight generalisation says " if G is a connected graph with all its vertices having degrees 1 or 2, then it is a cycle or a path"

Kyle Miller (Oct 30 2023 at 17:29):

I forgot to handle the case of an edge that isn't a bridge between connected components -- in that case you argue you can just extend the trail for the connected-component-without-the-edge by the edge. Incidentally that's a cycle, but the fact it's a cycle isn't so important for the proof.

Shreyas Srinivas (Oct 30 2023 at 17:30):

Shreyas Srinivas said:

Then a slight generalisation says " if G is a connected graph with all its vertices having degrees 1 or 2, then it is a cycle or a path"

These are simpler theorems that are show that a graph is one of so many kinds.

Shreyas Srinivas (Oct 30 2023 at 17:31):

Then extend them to subgraphs

Shreyas Srinivas (Oct 30 2023 at 17:31):

(This is a trivial step)

Shreyas Srinivas (Oct 30 2023 at 17:37):

Okay I now see Kyle's message (thanks zulip's android app). His argument is useful for applying the lemmas I described in the subgraphs while handling the connected component related details.

Lessness (Oct 30 2023 at 17:37):

OK, you were right that getting rid of S.encard <= 2 will be easy.
Proved that

theorem encard_aux1 {V} (S: Set V) (H: S.encard  2):
  S =   ( x, S = {x})  ( x y, x  y  S = {x, y})

Kyle Miller (Oct 30 2023 at 17:38):

(And because getting rid of it is easy, it's harmless keeping it in the definition.)

Shreyas Srinivas (Oct 30 2023 at 17:38):

I just think it becomes a tedious distraction

Lessness (Oct 30 2023 at 17:41):

It's harmless distraction right now thanks to the theorem (encard_aux1), I believe. Now looking forward the hardest part.

Will make some kind of paper proof for the start, maybe.
I like to tinker directly in a proof assistant, without doing paper proofs, but that works only for simplest situations, probably. Must get rid of this habit.

Lessness (Oct 30 2023 at 17:42):

Now reading your suggestions and hints, thank you all!

Kyle Miller (Oct 30 2023 at 17:50):

For aux1, another strategy, rather than futzing too much with connected components, is to reduce to the case that M is connected somehow (going to a connected component, you still have the same degree condition, with the same degrees), and then prove by contradiction. You want to prove that given "forall x y : V and W : G.walk x y, then if W.toSubgraph is equal to the subgraph, then W is not a trail" you can prove False. Since G is finite, there must be some walk W such that W.toSubgraph is equal to the subgraph. So then take a least-length such walk. This is not a trail by assumption. Now it's a simple matter of combinatorics :wink: (More seriously, you use this to somehow argue you have a vertex of degree at least three, and if there isn't one, to argue that your walk is not of least length.)

Shreyas Srinivas (Oct 30 2023 at 17:58):

How can M be connected? It is a matching

Kyle Miller (Oct 30 2023 at 18:01):

Not in aux1. (@Lessness There seems to be a bug in the aux1 statement. Do you mean M.induce c.supp rather than (⊤: G.Subgraph).induce c.supp?)

Lessness (Oct 30 2023 at 18:08):

Ouw. Have to check definition of induce, but it's possible that I have made a bug.

Kyle Miller (Oct 30 2023 at 18:12):

(⊤: G.Subgraph).induce c.supp gives you the induced subgraph relative to G itself, and it might have more edges than M.induce c.supp (in particular, edges outside of M). If you want c-as-a-subgraph, then since c : M.coe.ConnectedComponent, it seems that M.induce c.supp is capturing the intent.

(Side note: at some point I was working on building up API around the set of connected components as subgraphs -- maybe I'll try to find it again and see if it's worth salvaging.)

Lessness (Oct 30 2023 at 18:14):

Yes, it seems that M.induce c.supp is the right, not what I had for now.

Lessness (Nov 01 2023 at 13:33):

The first part of aux1 - where the connected component has node with degree 0 - is proven (with some ugly proof, imho)
Here

That's some progress :partying_face:

Lessness (Nov 01 2023 at 14:13):

Erm, should probably restructure the proof somewhat... I mean, prove that connected component with some node of degree zero is trail. In different theorem.
Then look at connected components with some node of degree 1 (all nodes has degree 1 or 2). Probably another separate theorem.
And then the final theorem where all nodes has degree of 2.

Then combine them into one - the current formulation of aux1.

Lessness (Nov 01 2023 at 19:37):

Restructuring done.

Now I have two theorems with sorry and aux1 proved assuming these two are correct and will be proved too.

theorem aux1_subcase_2 {V} {G: SimpleGraph V} (M: G.Subgraph):
   (x: V) (H: x  M.verts) (H0:  (y: V), M.neighborSet x = {y}),
   (z: V) (W: G.Walk x z), W.IsTrail 
  W.toSubgraph = M.induce (M.coe.connectedComponentMk x, H⟩).supp := by
    sorry

theorem aux1_subcase_3 {V} {G: SimpleGraph V} (M: G.Subgraph):
   (c: M.coe.ConnectedComponent)
  (H:  x, x  c.supp   x1 x2, x1  x2  M.neighborSet x = {x1, x2}),
   (x: V) (W: G.Walk x x), W.IsCycle  W.toSubgraph = M.induce c.supp := by
    sorry

Peter Nelson (Nov 03 2023 at 15:38):

encard is the correct generality for that lemma - any connected graph with maximum degree at most 2 is a cycle or (possibly infinite) path.

Lessness (Nov 05 2023 at 08:19):

Hello, currently I'm trying to prove the theorem about graph with max degree 2 and got stuck a bit.
In this case I'm going to ask for some help.

At the file Berge.lean, line 640, I have commented at the place.
Part of the proof state:

W_1: SimpleGraph.Walk (SimpleGraph.Subgraph.coe (SimpleGraph.Subgraph.deleteVerts M {v}))
  { val := x_2, property := (_ : x_2  M.verts \ {v}) } { val := u, property := H7 }
H12: u  M.verts
 SimpleGraph.Walk (SimpleGraph.Subgraph.coe M) { val := x_2, property := (_ : x_2  M.verts) }
  { val := u, property := H12 }

Here I want to do induction on W_1 and construct Walk in the subgraph M using parts of W_1. But the induction doesn't work and I can't find a way to fix that (for now).
The error message is:

index in target's type is not a variable (consider using the `cases` tactic instead)
  { val := x_2, property := (_ : x_2  M.verts \ {v}) }

Shreyas Srinivas (Nov 05 2023 at 16:09):

How are you calling induction?

Lessness (Nov 05 2023 at 16:10):

induction W_1... are there other ways, too?

Lessness (Nov 05 2023 at 18:19):

Probably the simple induction isn't going to work even after generalizing a bit. Something to think about.

Taking a pause because Monday means studying other stuff and tests at university.

Shreyas Srinivas (Nov 14 2023 at 23:37):

I am sorry I forgot about this entirely

Shreyas Srinivas (Nov 14 2023 at 23:38):

I was reading the hitchhikers guide to logical verification and came across this exact issue

Shreyas Srinivas (Nov 14 2023 at 23:38):

Page 92

Shreyas Srinivas (Nov 14 2023 at 23:41):

(deleted)

Shreyas Srinivas (Nov 14 2023 at 23:42):

The simplest trick (not described there explicitly) is to take whatever expression lean is complaining about as not a variable (say e), and use the set tactic from mathlib to assign a new variable to it.

Shreyas Srinivas (Nov 14 2023 at 23:43):

set x:=e with h will assign a variable x to expression e, replace all occurrences of e with x in all hypothesis and the goal and insert an equality h: x=e in your hypothesis, which you can use for rw

Kyle Miller (Nov 14 2023 at 23:47):

Yeah, set or generalize are tricks for this index problem

Lessness (Nov 17 2023 at 16:05):

Thank you! I managed to prove auxiliary lemma to use instead of set or generalize, but next time will try them out too.

Lessness (Nov 17 2023 at 16:10):

Anyway, I'm abandoning this Berge's lemma for now (probably at least for two and half months... I have exams at university during January and, if anything goes successfully, then will return to this).

I believe that anything up to formulation of aux_experiment and the Berge's_lemma at the end is good enough to use for someone who is interesting finishing what I started (if there's anyone, of course). I will be glad to learn from this person, if that happens. :)

Sorry! And cheers!

Kyle Miller (Nov 17 2023 at 18:53):

Ah well, I hope you had fun struggling with simple graphs, and I hope to see you back!

(These might be low-hanging fruit, but there's something about combinatorial objects where, you can see the fruit, you can see that you can reach the fruit, but somehow you're not allowed to just go and pick it. There's always some additional complexity you have to sort out first... It's not quite the same, but I'm suddenly reminded of that hilarious babel fish puzzle in the old The Hitchhiker's Guide To The Galaxy text adventure game.)

To remind myself where you are so far, I think you've got it here


Last updated: Dec 20 2023 at 11:08 UTC