wiedijk_100_theorems.konigsbergArchive.Wiedijk100Theorems.Konigsberg

This file has been ported!

Changes since the initial port

The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(last sync)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -106,8 +106,8 @@ theorem not_isEulerian {u v : Verts} (p : graph.Walk u v) (h : p.IsEulerian) : F
       Set.mem_singleton_iff]
     cases w <;> simp
   have h := h.card_odd_degree
-  simp_rw [this] at h 
-  norm_num at h 
+  simp_rw [this] at h
+  norm_num at h
 #align konigsberg.not_is_eulerian Konigsberg.not_isEulerian
 
 end Konigsberg
Diff
@@ -3,8 +3,8 @@ Copyright (c) 2022 Kyle Miller. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Kyle Miller
 -/
-import Mathbin.Combinatorics.SimpleGraph.Trails
-import Mathbin.Tactic.DeriveFintype
+import Combinatorics.SimpleGraph.Trails
+import Tactic.DeriveFintype
 
 #align_import wiedijk_100_theorems.konigsberg from "leanprover-community/mathlib"@"08b081ea92d80e3a41f899eea36ef6d56e0f1db0"
 
Diff
@@ -2,15 +2,12 @@
 Copyright (c) 2022 Kyle Miller. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Kyle Miller
-
-! This file was ported from Lean 3 source module wiedijk_100_theorems.konigsberg
-! leanprover-community/mathlib commit 08b081ea92d80e3a41f899eea36ef6d56e0f1db0
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.Combinatorics.SimpleGraph.Trails
 import Mathbin.Tactic.DeriveFintype
 
+#align_import wiedijk_100_theorems.konigsberg from "leanprover-community/mathlib"@"08b081ea92d80e3a41f899eea36ef6d56e0f1db0"
+
 /-!
 # The Königsberg bridges problem
 
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Kyle Miller
 
 ! This file was ported from Lean 3 source module wiedijk_100_theorems.konigsberg
-! leanprover-community/mathlib commit 5563b1b49e86e135e8c7b556da5ad2f5ff881cad
+! leanprover-community/mathlib commit 08b081ea92d80e3a41f899eea36ef6d56e0f1db0
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -14,6 +14,9 @@ import Mathbin.Tactic.DeriveFintype
 /-!
 # The Königsberg bridges problem
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 We show that a graph that represents the islands and mainlands of Königsberg and seven bridges
 between them has no Eulerian trail.
 -/
Diff
@@ -3,8 +3,8 @@ Copyright (c) 2022 Kyle Miller. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Kyle Miller
 
-! This file was ported from Lean 3 source module «100-theorems-list».«54_konigsberg»
-! leanprover-community/mathlib commit af8760ccc4c03bbdff0b140e6f7bd047b0eecbeb
+! This file was ported from Lean 3 source module wiedijk_100_theorems.konigsberg
+! leanprover-community/mathlib commit 5563b1b49e86e135e8c7b556da5ad2f5ff881cad
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/

Changes in mathlib4

mathlib3
mathlib4
chore: bump to v4.3.0-rc2 (#8366)

PR contents

This is the supremum of

along with some minor fixes from failures on nightly-testing as Mathlib master is merged into it.

Note that some PRs for changes that are already compatible with the current toolchain and will be necessary have already been split out: #8380.

I am hopeful that in future we will be able to progressively merge adaptation PRs into a bump/v4.X.0 branch, so we never end up with a "big merge" like this. However one of these adaptation PRs (#8056) predates my new scheme for combined CI, and it wasn't possible to keep that PR viable in the meantime.

Lean PRs involved in this bump

In particular this includes adjustments for the Lean PRs

leanprover/lean4#2778

We can get rid of all the

local macro_rules | `($x ^ $y) => `(HPow.hPow $x $y) -- Porting note: See issue [lean4#2220](https://github.com/leanprover/lean4/pull/2220)

macros across Mathlib (and in any projects that want to write natural number powers of reals).

leanprover/lean4#2722

Changes the default behaviour of simp to (config := {decide := false}). This makes simp (and consequentially norm_num) less powerful, but also more consistent, and less likely to blow up in long failures. This requires a variety of changes: changing some previously by simp or norm_num to decide or rfl, or adding (config := {decide := true}).

leanprover/lean4#2783

This changed the behaviour of simp so that simp [f] will only unfold "fully applied" occurrences of f. The old behaviour can be recovered with simp (config := { unfoldPartialApp := true }). We may in future add a syntax for this, e.g. simp [!f]; please provide feedback! In the meantime, we have made the following changes:

  • switching to using explicit lemmas that have the intended level of application
  • (config := { unfoldPartialApp := true }) in some places, to recover the old behaviour
  • Using @[eqns] to manually adjust the equation lemmas for a particular definition, recovering the old behaviour just for that definition. See #8371, where we do this for Function.comp and Function.flip.

This change in Lean may require further changes down the line (e.g. adding the !f syntax, and/or upstreaming the special treatment for Function.comp and Function.flip, and/or removing this special treatment). Please keep an open and skeptical mind about these changes!

Co-authored-by: leanprover-community-mathlib4-bot <leanprover-community-mathlib4-bot@users.noreply.github.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Mauricio Collares <mauricio@collares.org>

Diff
@@ -75,7 +75,7 @@ lemma degree_eq_degree (v : Verts) : graph.degree v = degree v := by cases v <;>
 #align konigsberg.degree_eq_degree Konigsberg.degree_eq_degree
 
 lemma not_even_degree_iff (w : Verts) : ¬Even (degree w) ↔ w = V1 ∨ w = V2 ∨ w = V3 ∨ w = V4 := by
-  cases w <;> simp
+  cases w <;> decide
 
 lemma setOf_odd_degree_eq :
     {v | Odd (graph.degree v)} = {Verts.V1, Verts.V2, Verts.V3, Verts.V4} := by
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -2,15 +2,12 @@
 Copyright (c) 2022 Kyle Miller. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Kyle Miller
-
-! This file was ported from Lean 3 source module wiedijk_100_theorems.konigsberg
-! leanprover-community/mathlib commit 5563b1b49e86e135e8c7b556da5ad2f5ff881cad
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Combinatorics.SimpleGraph.Trails
 import Mathlib.Tactic.DeriveFintype
 
+#align_import wiedijk_100_theorems.konigsberg from "leanprover-community/mathlib"@"5563b1b49e86e135e8c7b556da5ad2f5ff881cad"
+
 /-!
 # The Königsberg bridges problem
 
feat: add recall command (#5278)
Diff
@@ -23,36 +23,27 @@ namespace Konigsberg
 
 /-- The vertices for the Königsberg graph; four vertices for the bodies of land and seven
 vertices for the bridges. -/
--- @[nolint has_inhabited_instance] -- Porting note: removed
 inductive Verts : Type
-  | V1
-  | V2
-  | V3
-  | V4-- The islands and mainlands
-
-  | B1
-  | B2
-  | B3
-  | B4
-  | B5
-  | B6
-  | B7
+  -- The islands and mainlands
+  | V1 | V2 | V3 | V4
+  -- The bridges
+  | B1 | B2 | B3 | B4 | B5 | B6 | B7
   deriving DecidableEq, Fintype
 #align konigsberg.verts Konigsberg.Verts
 
--- The bridges
 open Verts
 
 /-- Each of the connections between the islands/mainlands and the bridges.
 These are ordered pairs, but the data becomes symmetric in `Konigsberg.adj`. -/
 def edges : List (Verts × Verts) :=
-  [(V1, B1), (V1, B2), (V1, B3), (V1, B4), (V1, B5), (B1, V2), (B2, V2), (B3, V4), (B4, V3),
-    (B5, V3), (V2, B6), (B6, V4), (V3, B7), (B7, V4)]
+  [(V1, B1), (V1, B2), (V1, B3), (V1, B4), (V1, B5),
+   (B1, V2), (B2, V2), (B3, V4), (B4, V3), (B5, V3),
+   (V2, B6), (B6, V4),
+   (V3, B7), (B7, V4)]
 #align konigsberg.edges Konigsberg.edges
 
 /-- The adjacency relation for the Königsberg graph. -/
-def adj (v w : Verts) : Bool :=
-  (v, w) ∈ edges || (w, v) ∈ edges
+def adj (v w : Verts) : Bool := (v, w) ∈ edges || (w, v) ∈ edges
 #align konigsberg.adj Konigsberg.adj
 
 /-- The Königsberg graph structure. While the Königsberg bridge problem
@@ -73,42 +64,33 @@ def graph : SimpleGraph Verts where
     decide
 #align konigsberg.graph Konigsberg.graph
 
-instance : DecidableRel graph.Adj := fun a b => decidable_of_bool (adj a b) Iff.rfl
+instance : DecidableRel graph.Adj := fun a b => inferInstanceAs <| Decidable (adj a b)
 
 /-- To speed up the proof, this is a cache of all the degrees of each vertex,
 proved in `Konigsberg.degree_eq_degree`. -/
-@[simp]
 def degree : Verts → ℕ
-  | V1 => 5
-  | V2 => 3
-  | V3 => 3
-  | V4 => 3
-  | B1 => 2
-  | B2 => 2
-  | B3 => 2
-  | B4 => 2
-  | B5 => 2
-  | B6 => 2
-  | B7 => 2
+  | V1 => 5 | V2 => 3 | V3 => 3 | V4 => 3
+  | B1 => 2 | B2 => 2 | B3 => 2 | B4 => 2 | B5 => 2 | B6 => 2 | B7 => 2
 #align konigsberg.degree Konigsberg.degree
 
 @[simp]
-theorem degree_eq_degree (v : Verts) : graph.degree v = degree v := by cases v <;> rfl
+lemma degree_eq_degree (v : Verts) : graph.degree v = degree v := by cases v <;> rfl
 #align konigsberg.degree_eq_degree Konigsberg.degree_eq_degree
 
+lemma not_even_degree_iff (w : Verts) : ¬Even (degree w) ↔ w = V1 ∨ w = V2 ∨ w = V3 ∨ w = V4 := by
+  cases w <;> simp
+
+lemma setOf_odd_degree_eq :
+    {v | Odd (graph.degree v)} = {Verts.V1, Verts.V2, Verts.V3, Verts.V4} := by
+  ext w
+  simp [not_even_degree_iff]
+
 /-- The Königsberg graph is not Eulerian. -/
 theorem not_isEulerian {u v : Verts} (p : graph.Walk u v) (h : p.IsEulerian) : False := by
-  have : {v | Odd (graph.degree v)} = {Verts.V1, Verts.V2, Verts.V3, Verts.V4} := by
-    ext w
-    simp only [degree_eq_degree, Nat.odd_iff_not_even, Set.mem_setOf_eq, Set.mem_insert_iff,
-      Set.mem_singleton_iff]
-    cases w <;> simp
   have h := h.card_odd_degree
-  -- Porting note: the next four lines were `simp_rw [this] at h`, which times out
-  rw [← Set.toFinset_card] at h
-  conv_lhs at h => arg 1; simp only [this]
-  conv_rhs at h => arg 1; simp only [this]
-  rw [Set.toFinset_card] at h
+  have h' := setOf_odd_degree_eq
+  apply_fun Fintype.card at h'
+  rw [h'] at h
   norm_num at h
 #align konigsberg.not_is_eulerian Konigsberg.not_isEulerian
 
feat: port MeasureTheory.Function.ConditionalExpectation.Basic (#4898)

Dependencies 7 + 230

231 files ported (97.1%)
104012 lines ported (97.1%)
Show graph

The unported dependencies are