data.W.basicMathlib.Data.W.Basic

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)

(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)

(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)

(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)

(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)

(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)

(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)

(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)

(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)

(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)

(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
@@ -3,7 +3,7 @@ Copyright (c) 2019 Jeremy Avigad. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Jeremy Avigad
 -/
-import Mathbin.Logic.Equiv.List
+import Logic.Equiv.List
 
 #align_import data.W.basic from "leanprover-community/mathlib"@"327c3c0d9232d80e250dc8f65e7835b82b266ea5"
 
Diff
@@ -2,14 +2,11 @@
 Copyright (c) 2019 Jeremy Avigad. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Jeremy Avigad
-
-! This file was ported from Lean 3 source module data.W.basic
-! leanprover-community/mathlib commit 327c3c0d9232d80e250dc8f65e7835b82b266ea5
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.Logic.Equiv.List
 
+#align_import data.W.basic from "leanprover-community/mathlib"@"327c3c0d9232d80e250dc8f65e7835b82b266ea5"
+
 /-!
 # W types
 
Diff
@@ -67,15 +67,19 @@ def ofSigma : (Σ a : α, β a → WType β) → WType β
 #align W_type.of_sigma WType.ofSigma
 -/
 
+#print WType.ofSigma_toSigma /-
 @[simp]
 theorem ofSigma_toSigma : ∀ w : WType β, ofSigma (toSigma w) = w
   | ⟨a, f⟩ => rfl
 #align W_type.of_sigma_to_sigma WType.ofSigma_toSigma
+-/
 
+#print WType.toSigma_ofSigma /-
 @[simp]
 theorem toSigma_ofSigma : ∀ s : Σ a : α, β a → WType β, toSigma (ofSigma s) = s
   | ⟨a, f⟩ => rfl
 #align W_type.to_sigma_of_sigma WType.toSigma_ofSigma
+-/
 
 variable (β)
 
@@ -101,6 +105,7 @@ def elim (γ : Type _) (fγ : (Σ a : α, β a → γ) → γ) : WType β → γ
 #align W_type.elim WType.elim
 -/
 
+#print WType.elim_injective /-
 theorem elim_injective (γ : Type _) (fγ : (Σ a : α, β a → γ) → γ)
     (fγ_injective : Function.Injective fγ) : Function.Injective (elim γ fγ)
   | ⟨a₁, f₁⟩, ⟨a₂, f₂⟩, h =>
@@ -109,6 +114,7 @@ theorem elim_injective (γ : Type _) (fγ : (Σ a : α, β a → γ) → γ)
     congr with x
     exact elim_injective (congr_fun (eq_of_hEq h) x : _)
 #align W_type.elim_injective WType.elim_injective
+-/
 
 instance [hα : IsEmpty α] : IsEmpty (WType β) :=
   ⟨fun w => WType.recOn w (IsEmpty.elim hα)⟩
@@ -143,12 +149,16 @@ def depth : WType β → ℕ
 #align W_type.depth WType.depth
 -/
 
+#print WType.depth_pos /-
 theorem depth_pos (t : WType β) : 0 < t.depth := by cases t; apply Nat.succ_pos
 #align W_type.depth_pos WType.depth_pos
+-/
 
+#print WType.depth_lt_depth_mk /-
 theorem depth_lt_depth_mk (a : α) (f : β a → WType β) (i : β a) : depth (f i) < depth ⟨a, f⟩ :=
   Nat.lt_succ_of_le (Finset.le_sup (Finset.mem_univ i))
 #align W_type.depth_lt_depth_mk WType.depth_lt_depth_mk
+-/
 
 /-
 Show that W types are encodable when `α` is an encodable fintype and for every `a : α`, `β a` is
Diff
@@ -54,7 +54,7 @@ variable {α : Type _} {β : α → Type _}
 #print WType.toSigma /-
 /-- The canonical map to the corresponding sigma type, returning the label of a node as an
   element `a` of `α`, and the children of the node as a function `β a → W_type β`. -/
-def toSigma : WType β → Σa : α, β a → WType β
+def toSigma : WType β → Σ a : α, β a → WType β
   | ⟨a, f⟩ => ⟨a, f⟩
 #align W_type.to_sigma WType.toSigma
 -/
@@ -62,7 +62,7 @@ def toSigma : WType β → Σa : α, β a → WType β
 #print WType.ofSigma /-
 /-- The canonical map from the sigma type into a `W_type`. Given a node `a : α`, and
   its children as a function `β a → W_type β`, return the corresponding tree. -/
-def ofSigma : (Σa : α, β a → WType β) → WType β
+def ofSigma : (Σ a : α, β a → WType β) → WType β
   | ⟨a, f⟩ => WType.mk a f
 #align W_type.of_sigma WType.ofSigma
 -/
@@ -73,7 +73,7 @@ theorem ofSigma_toSigma : ∀ w : WType β, ofSigma (toSigma w) = w
 #align W_type.of_sigma_to_sigma WType.ofSigma_toSigma
 
 @[simp]
-theorem toSigma_ofSigma : ∀ s : Σa : α, β a → WType β, toSigma (ofSigma s) = s
+theorem toSigma_ofSigma : ∀ s : Σ a : α, β a → WType β, toSigma (ofSigma s) = s
   | ⟨a, f⟩ => rfl
 #align W_type.to_sigma_of_sigma WType.toSigma_ofSigma
 
@@ -83,7 +83,7 @@ variable (β)
 /-- The canonical bijection with the sigma type, showing that `W_type` is a fixed point of
   the polynomial functor `X ↦ Σ a : α, β a → X`. -/
 @[simps]
-def equivSigma : WType β ≃ Σa : α, β a → WType β
+def equivSigma : WType β ≃ Σ a : α, β a → WType β
     where
   toFun := toSigma
   invFun := ofSigma
@@ -96,12 +96,12 @@ variable {β}
 
 #print WType.elim /-
 /-- The canonical map from `W_type β` into any type `γ` given a map `(Σ a : α, β a → γ) → γ`. -/
-def elim (γ : Type _) (fγ : (Σa : α, β a → γ) → γ) : WType β → γ
+def elim (γ : Type _) (fγ : (Σ a : α, β a → γ) → γ) : WType β → γ
   | ⟨a, f⟩ => fγ ⟨a, fun b => elim (f b)⟩
 #align W_type.elim WType.elim
 -/
 
-theorem elim_injective (γ : Type _) (fγ : (Σa : α, β a → γ) → γ)
+theorem elim_injective (γ : Type _) (fγ : (Σ a : α, β a → γ) → γ)
     (fγ_injective : Function.Injective fγ) : Function.Injective (elim γ fγ)
   | ⟨a₁, f₁⟩, ⟨a₂, f₂⟩, h =>
     by
@@ -171,14 +171,14 @@ private def encodable_zero : Encodable (WType' β 0) :=
   have : ∀ x, finv (f x) = x := fun ⟨x, h⟩ => False.elim <| not_lt_of_ge h (WType.depth_pos _)
   Encodable.ofLeftInverse f finv this
 
-private def f (n : ℕ) : WType' β (n + 1) → Σa : α, β a → WType' β n
+private def f (n : ℕ) : WType' β (n + 1) → Σ a : α, β a → WType' β n
   | ⟨t, h⟩ => by
     cases' t with a f
     have h₀ : ∀ i : β a, WType.depth (f i) ≤ n := fun i =>
       Nat.le_of_lt_succ (lt_of_lt_of_le (WType.depth_lt_depth_mk a f i) h)
     exact ⟨a, fun i : β a => ⟨f i, h₀ i⟩⟩
 
-private def finv (n : ℕ) : (Σa : α, β a → WType' β n) → WType' β (n + 1)
+private def finv (n : ℕ) : (Σ a : α, β a → WType' β n) → WType' β (n + 1)
   | ⟨a, f⟩ =>
     let f' := fun i : β a => (f i).val
     have : WType.depth ⟨a, f'⟩ ≤ n + 1 := add_le_add_right (Finset.sup_le fun b h => (f b).2) 1
@@ -194,8 +194,8 @@ encodable. -/
 instance : Encodable (WType β) :=
   by
   haveI h' : ∀ n, Encodable (W_type' β n) := fun n => Nat.recOn n encodable_zero encodable_succ
-  let f : WType β → Σn, W_type' β n := fun t => ⟨t.depth, ⟨t, le_rfl⟩⟩
-  let finv : (Σn, W_type' β n) → WType β := fun p => p.2.1
+  let f : WType β → Σ n, W_type' β n := fun t => ⟨t.depth, ⟨t, le_rfl⟩⟩
+  let finv : (Σ n, W_type' β n) → WType β := fun p => p.2.1
   have : ∀ t, finv (f t) = t := fun t => rfl
   exact Encodable.ofLeftInverse f finv this
 
Diff
@@ -67,23 +67,11 @@ def ofSigma : (Σa : α, β a → WType β) → WType β
 #align W_type.of_sigma WType.ofSigma
 -/
 
-/- warning: W_type.of_sigma_to_sigma -> WType.ofSigma_toSigma is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : α -> Type.{u2}} (w : WType.{u1, u2} α β), Eq.{max (succ u1) (succ u2)} (WType.{u1, u2} α (fun (a : α) => β a)) (WType.ofSigma.{u1, u2} α (fun (a : α) => β a) (WType.toSigma.{u1, u2} α β w)) w
-but is expected to have type
-  forall {α : Type.{u2}} {β : α -> Type.{u1}} (w : WType.{u2, u1} α β), Eq.{max (succ u2) (succ u1)} (WType.{u2, u1} α (fun (a : α) => β a)) (WType.ofSigma.{u2, u1} α (fun (a : α) => β a) (WType.toSigma.{u2, u1} α β w)) w
-Case conversion may be inaccurate. Consider using '#align W_type.of_sigma_to_sigma WType.ofSigma_toSigmaₓ'. -/
 @[simp]
 theorem ofSigma_toSigma : ∀ w : WType β, ofSigma (toSigma w) = w
   | ⟨a, f⟩ => rfl
 #align W_type.of_sigma_to_sigma WType.ofSigma_toSigma
 
-/- warning: W_type.to_sigma_of_sigma -> WType.toSigma_ofSigma is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : α -> Type.{u2}} (s : Sigma.{u1, max u1 u2} α (fun (a : α) => (β a) -> (WType.{u1, u2} α β))), Eq.{max (succ u1) (succ (max u1 u2))} (Sigma.{u1, max u1 u2} α (fun (a : α) => (β a) -> (WType.{u1, u2} α (fun (a : α) => β a)))) (WType.toSigma.{u1, u2} α (fun (a : α) => β a) (WType.ofSigma.{u1, u2} α (fun (a : α) => β a) s)) s
-but is expected to have type
-  forall {α : Type.{u2}} {β : α -> Type.{u1}} (s : Sigma.{u2, max u2 u1} α (fun (a : α) => (β a) -> (WType.{u2, u1} α β))), Eq.{max (succ u2) (succ u1)} (Sigma.{u2, max u2 u1} α (fun (a : α) => (β a) -> (WType.{u2, u1} α (fun (a : α) => β a)))) (WType.toSigma.{u2, u1} α (fun (a : α) => β a) (WType.ofSigma.{u2, u1} α (fun (a : α) => β a) s)) s
-Case conversion may be inaccurate. Consider using '#align W_type.to_sigma_of_sigma WType.toSigma_ofSigmaₓ'. -/
 @[simp]
 theorem toSigma_ofSigma : ∀ s : Σa : α, β a → WType β, toSigma (ofSigma s) = s
   | ⟨a, f⟩ => rfl
@@ -113,12 +101,6 @@ def elim (γ : Type _) (fγ : (Σa : α, β a → γ) → γ) : WType β → γ
 #align W_type.elim WType.elim
 -/
 
-/- warning: W_type.elim_injective -> WType.elim_injective is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : α -> Type.{u2}} (γ : Type.{u3}) (fγ : (Sigma.{u1, max u2 u3} α (fun (a : α) => (β a) -> γ)) -> γ), (Function.Injective.{max (succ u1) (succ (max u2 u3)), succ u3} (Sigma.{u1, max u2 u3} α (fun (a : α) => (β a) -> γ)) γ fγ) -> (Function.Injective.{max (succ u1) (succ u2), succ u3} (WType.{u1, u2} α (fun (a : α) => β a)) γ (WType.elim.{u1, u2, u3} α (fun (a : α) => β a) γ fγ))
-but is expected to have type
-  forall {α : Type.{u2}} {β : α -> Type.{u1}} (γ : Type.{u3}) (fγ : (Sigma.{u2, max u1 u3} α (fun (a : α) => (β a) -> γ)) -> γ), (Function.Injective.{max (max (succ u2) (succ u1)) (succ u3), succ u3} (Sigma.{u2, max u1 u3} α (fun (a : α) => (β a) -> γ)) γ fγ) -> (Function.Injective.{max (succ u1) (succ u2), succ u3} (WType.{u2, u1} α (fun (a : α) => β a)) γ (WType.elim.{u2, u1, u3} α (fun (a : α) => β a) γ fγ))
-Case conversion may be inaccurate. Consider using '#align W_type.elim_injective WType.elim_injectiveₓ'. -/
 theorem elim_injective (γ : Type _) (fγ : (Σa : α, β a → γ) → γ)
     (fγ_injective : Function.Injective fγ) : Function.Injective (elim γ fγ)
   | ⟨a₁, f₁⟩, ⟨a₂, f₂⟩, h =>
@@ -161,21 +143,9 @@ def depth : WType β → ℕ
 #align W_type.depth WType.depth
 -/
 
-/- warning: W_type.depth_pos -> WType.depth_pos is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : α -> Type.{u2}} [_inst_1 : forall (a : α), Fintype.{u2} (β a)] (t : WType.{u1, u2} α β), LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) (WType.depth.{u1, u2} α β (fun (a : α) => _inst_1 a) t)
-but is expected to have type
-  forall {α : Type.{u2}} {β : α -> Type.{u1}} [_inst_1 : forall (a : α), Fintype.{u1} (β a)] (t : WType.{u2, u1} α β), LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) (WType.depth.{u2, u1} α β (fun (a : α) => _inst_1 a) t)
-Case conversion may be inaccurate. Consider using '#align W_type.depth_pos WType.depth_posₓ'. -/
 theorem depth_pos (t : WType β) : 0 < t.depth := by cases t; apply Nat.succ_pos
 #align W_type.depth_pos WType.depth_pos
 
-/- warning: W_type.depth_lt_depth_mk -> WType.depth_lt_depth_mk is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : α -> Type.{u2}} [_inst_1 : forall (a : α), Fintype.{u2} (β a)] (a : α) (f : (β a) -> (WType.{u1, u2} α β)) (i : β a), LT.lt.{0} Nat Nat.hasLt (WType.depth.{u1, u2} α β (fun (a : α) => _inst_1 a) (f i)) (WType.depth.{u1, u2} α (fun (a : α) => β a) (fun (a : α) => _inst_1 a) (WType.mk.{u1, u2} α (fun (a : α) => β a) a f))
-but is expected to have type
-  forall {α : Type.{u2}} {β : α -> Type.{u1}} [_inst_1 : forall (a : α), Fintype.{u1} (β a)] (a : α) (f : (β a) -> (WType.{u2, u1} α β)) (i : β a), LT.lt.{0} Nat instLTNat (WType.depth.{u2, u1} α β (fun (a : α) => _inst_1 a) (f i)) (WType.depth.{u2, u1} α β (fun (a : α) => _inst_1 a) (WType.mk.{u2, u1} α β a f))
-Case conversion may be inaccurate. Consider using '#align W_type.depth_lt_depth_mk WType.depth_lt_depth_mkₓ'. -/
 theorem depth_lt_depth_mk (a : α) (f : β a → WType β) (i : β a) : depth (f i) < depth ⟨a, f⟩ :=
   Nat.lt_succ_of_le (Finset.le_sup (Finset.mem_univ i))
 #align W_type.depth_lt_depth_mk WType.depth_lt_depth_mk
Diff
@@ -167,10 +167,7 @@ lean 3 declaration is
 but is expected to have type
   forall {α : Type.{u2}} {β : α -> Type.{u1}} [_inst_1 : forall (a : α), Fintype.{u1} (β a)] (t : WType.{u2, u1} α β), LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) (WType.depth.{u2, u1} α β (fun (a : α) => _inst_1 a) t)
 Case conversion may be inaccurate. Consider using '#align W_type.depth_pos WType.depth_posₓ'. -/
-theorem depth_pos (t : WType β) : 0 < t.depth :=
-  by
-  cases t
-  apply Nat.succ_pos
+theorem depth_pos (t : WType β) : 0 < t.depth := by cases t; apply Nat.succ_pos
 #align W_type.depth_pos WType.depth_pos
 
 /- warning: W_type.depth_lt_depth_mk -> WType.depth_lt_depth_mk is a dubious translation:
@@ -200,9 +197,7 @@ variable [∀ a : α, Encodable (β a)]
 
 private def encodable_zero : Encodable (WType' β 0) :=
   let f : WType' β 0 → Empty := fun ⟨x, h⟩ => False.elim <| not_lt_of_ge h (WType.depth_pos _)
-  let finv : Empty → WType' β 0 := by
-    intro x
-    cases x
+  let finv : Empty → WType' β 0 := by intro x; cases x
   have : ∀ x, finv (f x) = x := fun ⟨x, h⟩ => False.elim <| not_lt_of_ge h (WType.depth_pos _)
   Encodable.ofLeftInverse f finv this
 
@@ -222,10 +217,7 @@ private def finv (n : ℕ) : (Σa : α, β a → WType' β n) → WType' β (n +
 variable [Encodable α]
 
 private def encodable_succ (n : Nat) (h : Encodable (WType' β n)) : Encodable (WType' β (n + 1)) :=
-  Encodable.ofLeftInverse (f n) (finv n)
-    (by
-      rintro ⟨⟨_, _⟩, _⟩
-      rfl)
+  Encodable.ofLeftInverse (f n) (finv n) (by rintro ⟨⟨_, _⟩, _⟩; rfl)
 
 /-- `W_type` is encodable when `α` is an encodable fintype and for every `a : α`, `β a` is
 encodable. -/
Diff
@@ -195,7 +195,6 @@ and of themselves, so we mark them as `private`.
 private def W_type' {α : Type _} (β : α → Type _) [∀ a : α, Fintype (β a)]
     [∀ a : α, Encodable (β a)] (n : ℕ) :=
   { t : WType β // t.depth ≤ n }
-#align W_type.W_type' W_type.W_type'
 
 variable [∀ a : α, Encodable (β a)]
 
@@ -206,7 +205,6 @@ private def encodable_zero : Encodable (WType' β 0) :=
     cases x
   have : ∀ x, finv (f x) = x := fun ⟨x, h⟩ => False.elim <| not_lt_of_ge h (WType.depth_pos _)
   Encodable.ofLeftInverse f finv this
-#align W_type.encodable_zero W_type.encodable_zero
 
 private def f (n : ℕ) : WType' β (n + 1) → Σa : α, β a → WType' β n
   | ⟨t, h⟩ => by
@@ -214,14 +212,12 @@ private def f (n : ℕ) : WType' β (n + 1) → Σa : α, β a → WType' β n
     have h₀ : ∀ i : β a, WType.depth (f i) ≤ n := fun i =>
       Nat.le_of_lt_succ (lt_of_lt_of_le (WType.depth_lt_depth_mk a f i) h)
     exact ⟨a, fun i : β a => ⟨f i, h₀ i⟩⟩
-#align W_type.f W_type.f
 
 private def finv (n : ℕ) : (Σa : α, β a → WType' β n) → WType' β (n + 1)
   | ⟨a, f⟩ =>
     let f' := fun i : β a => (f i).val
     have : WType.depth ⟨a, f'⟩ ≤ n + 1 := add_le_add_right (Finset.sup_le fun b h => (f b).2) 1
     ⟨⟨a, f'⟩, this⟩
-#align W_type.finv W_type.finv
 
 variable [Encodable α]
 
@@ -230,7 +226,6 @@ private def encodable_succ (n : Nat) (h : Encodable (WType' β n)) : Encodable (
     (by
       rintro ⟨⟨_, _⟩, _⟩
       rfl)
-#align W_type.encodable_succ W_type.encodable_succ
 
 /-- `W_type` is encodable when `α` is an encodable fintype and for every `a : α`, `β a` is
 encodable. -/

Changes in mathlib4

mathlib3
mathlib4
style: homogenise porting notes (#11145)

Homogenises porting notes via capitalisation and addition of whitespace.

It makes the following changes:

  • converts "--porting note" into "-- Porting note";
  • converts "porting note" into "Porting note".
Diff
@@ -84,7 +84,7 @@ def equivSigma : WType β ≃ Σa : α, β a → WType β
 
 variable {β}
 
--- porting note: Universes have a different order than mathlib3 definition
+-- Porting note: Universes have a different order than mathlib3 definition
 /-- The canonical map from `WType β` into any type `γ` given a map `(Σ a : α, β a → γ) → γ`. -/
 def elim (γ : Type*) (fγ : (Σa : α, β a → γ) → γ) : WType β → γ
   | ⟨a, f⟩ => fγ ⟨a, fun b => elim γ fγ (f b)⟩
chore: banish Type _ and Sort _ (#6499)

We remove all possible occurences of Type _ and Sort _ in favor of Type* and Sort*.

This has nice performance benefits.

Diff
@@ -31,10 +31,10 @@ identifier `W` in the root namespace.
 set_option linter.uppercaseLean3 false
 
 /--
-Given `β : α → Type _`, `WType β` is the type of finitely branching trees where nodes are labeled by
+Given `β : α → Type*`, `WType β` is the type of finitely branching trees where nodes are labeled by
 elements of `α` and the children of a node labeled `a` are indexed by elements of `β a`.
 -/
-inductive WType {α : Type _} (β : α → Type _)
+inductive WType {α : Type*} (β : α → Type*)
   | mk (a : α) (f : β a → WType β) : WType β
 #align W_type WType
 
@@ -43,7 +43,7 @@ instance : Inhabited (WType fun _ : Unit => Empty) :=
 
 namespace WType
 
-variable {α : Type _} {β : α → Type _}
+variable {α : Type*} {β : α → Type*}
 
 /-- The canonical map to the corresponding sigma type, returning the label of a node as an
   element `a` of `α`, and the children of the node as a function `β a → WType β`. -/
@@ -86,11 +86,11 @@ variable {β}
 
 -- porting note: Universes have a different order than mathlib3 definition
 /-- The canonical map from `WType β` into any type `γ` given a map `(Σ a : α, β a → γ) → γ`. -/
-def elim (γ : Type _) (fγ : (Σa : α, β a → γ) → γ) : WType β → γ
+def elim (γ : Type*) (fγ : (Σa : α, β a → γ) → γ) : WType β → γ
   | ⟨a, f⟩ => fγ ⟨a, fun b => elim γ fγ (f b)⟩
 #align W_type.elim WType.elim
 
-theorem elim_injective (γ : Type _) (fγ : (Σa : α, β a → γ) → γ)
+theorem elim_injective (γ : Type*) (fγ : (Σa : α, β a → γ) → γ)
     (fγ_injective : Function.Injective fγ) : Function.Injective (elim γ fγ)
   | ⟨a₁, f₁⟩, ⟨a₂, f₂⟩, h => by
     obtain ⟨rfl, h⟩ := Sigma.mk.inj_iff.mp (fγ_injective h)
@@ -145,7 +145,7 @@ induction on `n` that these are all encodable. These auxiliary constructions are
 and of themselves, so we mark them as `private`.
 -/
 @[reducible]
-private def WType' {α : Type _} (β : α → Type _) [∀ a : α, Fintype (β a)]
+private def WType' {α : Type*} (β : α → Type*) [∀ a : α, Fintype (β a)]
     [∀ a : α, Encodable (β a)] (n : ℕ) :=
   { t : WType β // t.depth ≤ n }
 
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,14 +2,11 @@
 Copyright (c) 2019 Jeremy Avigad. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Jeremy Avigad
-
-! This file was ported from Lean 3 source module data.W.basic
-! leanprover-community/mathlib commit 2445c98ae4b87eabebdde552593519b9b6dc350c
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Logic.Equiv.List
 
+#align_import data.W.basic from "leanprover-community/mathlib"@"2445c98ae4b87eabebdde552593519b9b6dc350c"
+
 /-!
 # W types
 
chore: formatting issues (#4947)

Co-authored-by: Scott Morrison <scott.morrison@anu.edu.au> Co-authored-by: Parcly Taxel <reddeloostw@gmail.com>

Diff
@@ -136,7 +136,7 @@ theorem depth_pos (t : WType β) : 0 < t.depth := by
 #align W_type.depth_pos WType.depth_pos
 
 theorem depth_lt_depth_mk (a : α) (f : β a → WType β) (i : β a) : depth (f i) < depth ⟨a, f⟩ :=
-  Nat.lt_succ_of_le (Finset.le_sup (f:=(depth <| f ·)) (Finset.mem_univ i))
+  Nat.lt_succ_of_le (Finset.le_sup (f := (depth <| f ·)) (Finset.mem_univ i))
 #align W_type.depth_lt_depth_mk WType.depth_lt_depth_mk
 
 /-
feat: add compile_inductive% and compile_def% commands (#4097)

Add a #compile inductive command to compile the recursors of an inductive type, which works by creating a recursive definition and using @[csimp].

Co-authored-by: Parth Shastri <31370288+cppio@users.noreply.github.com> Co-authored-by: Mario Carneiro <di.gama@gmail.com>

Diff
@@ -186,7 +186,7 @@ private def encodable_succ (n : Nat) (h : Encodable (WType' β n)) : Encodable (
 /-- `WType` is encodable when `α` is an encodable fintype and for every `a : α`, `β a` is
 encodable. -/
 instance : Encodable (WType β) := by
-  haveI h' : ∀ n, Encodable (WType' β n) := fun n => Nat.recC encodable_zero encodable_succ n
+  haveI h' : ∀ n, Encodable (WType' β n) := fun n => Nat.rec encodable_zero encodable_succ n
   let f : WType β → Σn, WType' β n := fun t => ⟨t.depth, ⟨t, le_rfl⟩⟩
   let finv : (Σn, WType' β n) → WType β := fun p => p.2.1
   have : ∀ t, finv (f t) = t := fun t => rfl
chore: bye-bye, solo bys! (#3825)

This PR puts, with one exception, every single remaining by that lies all by itself on its own line to the previous line, thus matching the current behaviour of start-port.sh. The exception is when the by begins the second or later argument to a tuple or anonymous constructor; see https://github.com/leanprover-community/mathlib4/pull/3825#discussion_r1186702599.

Essentially this is s/\n *by$/ by/g, but with manual editing to satisfy the linter's max-100-char-line requirement. The Python style linter is also modified to catch these "isolated bys".

Diff
@@ -95,8 +95,7 @@ def elim (γ : Type _) (fγ : (Σa : α, β a → γ) → γ) : WType β → γ
 
 theorem elim_injective (γ : Type _) (fγ : (Σa : α, β a → γ) → γ)
     (fγ_injective : Function.Injective fγ) : Function.Injective (elim γ fγ)
-  | ⟨a₁, f₁⟩, ⟨a₂, f₂⟩, h =>
-    by
+  | ⟨a₁, f₁⟩, ⟨a₂, f₂⟩, h => by
     obtain ⟨rfl, h⟩ := Sigma.mk.inj_iff.mp (fγ_injective h)
     congr with x
     exact elim_injective γ fγ fγ_injective (congr_fun (eq_of_heq h) x : _)
chore: add missing #align statements (#1902)

This PR is the result of a slight variant on the following "algorithm"

  • take all mathlib 3 names, remove _ and make all uppercase letters into lowercase
  • take all mathlib 4 names, remove _ and make all uppercase letters into lowercase
  • look for matches, and create pairs (original_lean3_name, OriginalLean4Name)
  • for pairs that do not have an align statement:
    • use Lean 4 to lookup the file + position of the Lean 4 name
    • add an #align statement just before the next empty line
  • manually fix some tiny mistakes (e.g., empty lines in proofs might cause the #align statement to have been inserted too early)
Diff
@@ -82,6 +82,8 @@ def equivSigma : WType β ≃ Σa : α, β a → WType β
   left_inv := ofSigma_toSigma
   right_inv := toSigma_ofSigma
 #align W_type.equiv_sigma WType.equivSigma
+#align W_type.equiv_sigma_symm_apply WType.equivSigma_symm_apply
+#align W_type.equiv_sigma_apply WType.equivSigma_apply
 
 variable {β}
 
chore: Rename Type* to Type _ (#1866)

A bunch of docstrings were still mentioning Type*. This changes them to Type _.

Diff
@@ -34,7 +34,7 @@ identifier `W` in the root namespace.
 set_option linter.uppercaseLean3 false
 
 /--
-Given `β : α → Type*`, `WType β` is the type of finitely branching trees where nodes are labeled by
+Given `β : α → Type _`, `WType β` is the type of finitely branching trees where nodes are labeled by
 elements of `α` and the children of a node labeled `a` are indexed by elements of `β a`.
 -/
 inductive WType {α : Type _} (β : α → Type _)
feat: add uppercase lean 3 linter (#1796)

Implements a linter for lean 3 declarations containing capital letters (as suggested on Zulip).

Co-authored-by: Mario Carneiro <di.gama@gmail.com>

Diff
@@ -30,6 +30,8 @@ While the name `WType` is somewhat verbose, it is preferable to putting a single
 identifier `W` in the root namespace.
 -/
 
+-- For "W_type"
+set_option linter.uppercaseLean3 false
 
 /--
 Given `β : α → Type*`, `WType β` is the type of finitely branching trees where nodes are labeled by
feat: port Data.W.Basic (#1743)

Co-authored-by: ChrisHughes24 <chrishughes24@gmail.com>

Dependencies 6 + 210

211 files ported (97.2%)
93453 lines ported (97.7%)
Show graph

The unported dependencies are