data.list.permutation
⟷
Mathlib.Data.List.Permutation
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.
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(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)
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -187,7 +187,7 @@ theorem mem_permutationsAux2 {t : α} {ts : List α} {ys : List α} {l l' : List
· exact ⟨y :: l₁, l₂, l0, by simp⟩
· rintro ⟨_ | ⟨y', l₁⟩, l₂, l0, ye, rfl⟩
· simp [ye]
- · simp only [cons_append] at ye ; rcases ye with ⟨rfl, rfl⟩
+ · simp only [cons_append] at ye; rcases ye with ⟨rfl, rfl⟩
exact Or.inr ⟨l₁, l₂, l0, by simp⟩
#align list.mem_permutations_aux2 List.mem_permutationsAux2
-/
@@ -282,7 +282,7 @@ theorem map_permutationsAux (f : α → β) :
∀ ts is : List α, map (map f) (permutationsAux ts is) = permutationsAux (map f ts) (map f is) :=
by
refine' permutations_aux.rec (by simp) _
- introv IH1 IH2; rw [map] at IH2
+ introv IH1 IH2; rw [map] at IH2
simp only [foldr_permutations_aux2, map_append, map, map_map_permutations_aux2, permutations,
bind_map, IH1, append_assoc, permutations_aux_cons, cons_bind, ← IH2, map_bind]
#align list.map_permutations_aux List.map_permutationsAux
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -3,7 +3,7 @@ Copyright (c) 2014 Parikshit Khanna. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Parikshit Khanna, Jeremy Avigad, Leonardo de Moura, Floris van Doorn, Mario Carneiro
-/
-import Mathbin.Data.List.Join
+import Data.List.Join
#align_import data.list.permutation from "leanprover-community/mathlib"@"be24ec5de6701447e5df5ca75400ffee19d65659"
mathlib commit https://github.com/leanprover-community/mathlib/commit/8ea5598db6caeddde6cb734aa179cc2408dbd345
@@ -2,14 +2,11 @@
Copyright (c) 2014 Parikshit Khanna. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Parikshit Khanna, Jeremy Avigad, Leonardo de Moura, Floris van Doorn, Mario Carneiro
-
-! This file was ported from Lean 3 source module data.list.permutation
-! leanprover-community/mathlib commit be24ec5de6701447e5df5ca75400ffee19d65659
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathbin.Data.List.Join
+#align_import data.list.permutation from "leanprover-community/mathlib"@"be24ec5de6701447e5df5ca75400ffee19d65659"
+
/-!
# Permutations of a list
mathlib commit https://github.com/leanprover-community/mathlib/commit/9fb8964792b4237dac6200193a0d533f1b3f7423
@@ -57,6 +57,7 @@ variable {α β : Type _}
namespace List
+#print List.permutationsAux2_fst /-
theorem permutationsAux2_fst (t : α) (ts : List α) (r : List β) :
∀ (ys : List α) (f : List α → β), (permutationsAux2 t ts r ys f).1 = ys ++ ts
| [], f => rfl
@@ -66,13 +67,17 @@ theorem permutationsAux2_fst (t : α) (ts : List α) (r : List β) :
_, permutations_aux2_fst ys _ with
| ⟨_, zs⟩, rfl => rfl
#align list.permutations_aux2_fst List.permutationsAux2_fst
+-/
+#print List.permutationsAux2_snd_nil /-
@[simp]
theorem permutationsAux2_snd_nil (t : α) (ts : List α) (r : List β) (f : List α → β) :
(permutationsAux2 t ts r [] f).2 = r :=
rfl
#align list.permutations_aux2_snd_nil List.permutationsAux2_snd_nil
+-/
+#print List.permutationsAux2_snd_cons /-
@[simp]
theorem permutationsAux2_snd_cons (t : α) (ts : List α) (r : List β) (y : α) (ys : List α)
(f : List α → β) :
@@ -84,13 +89,17 @@ theorem permutationsAux2_snd_cons (t : α) (ts : List α) (r : List β) (y : α)
_, permutationsAux2_fst t ts r _ _ with
| ⟨_, zs⟩, rfl => rfl
#align list.permutations_aux2_snd_cons List.permutationsAux2_snd_cons
+-/
+#print List.permutationsAux2_append /-
/-- The `r` argument to `permutations_aux2` is the same as appending. -/
theorem permutationsAux2_append (t : α) (ts : List α) (r : List β) (ys : List α) (f : List α → β) :
(permutationsAux2 t ts nil ys f).2 ++ r = (permutationsAux2 t ts r ys f).2 := by
induction ys generalizing f <;> simp [*]
#align list.permutations_aux2_append List.permutationsAux2_append
+-/
+#print List.permutationsAux2_comp_append /-
/-- The `ts` argument to `permutations_aux2` can be folded into the `f` argument. -/
theorem permutationsAux2_comp_append {t : α} {ts ys : List α} {r : List β} (f : List α → β) :
(permutationsAux2 t [] r ys fun x => f (x ++ ts)).2 = (permutationsAux2 t ts r ys f).2 :=
@@ -99,7 +108,9 @@ theorem permutationsAux2_comp_append {t : α} {ts ys : List α} {r : List β} (f
· simp
· simp [ys_ih fun xs => f (ys_hd :: xs)]
#align list.permutations_aux2_comp_append List.permutationsAux2_comp_append
+-/
+#print List.map_permutationsAux2' /-
theorem map_permutationsAux2' {α β α' β'} (g : α → α') (g' : β → β') (t : α) (ts ys : List α)
(r : List β) (f : List α → β) (f' : List α' → β') (H : ∀ a, g' (f a) = f' (map g a)) :
map g' (permutationsAux2 t ts r ys f).2 =
@@ -108,7 +119,9 @@ theorem map_permutationsAux2' {α β α' β'} (g : α → α') (g' : β → β')
induction ys generalizing f f' <;> simp [*]
apply ys_ih; simp [H]
#align list.map_permutations_aux2' List.map_permutationsAux2'
+-/
+#print List.map_permutationsAux2 /-
/-- The `f` argument to `permutations_aux2` when `r = []` can be eliminated. -/
theorem map_permutationsAux2 (t : α) (ts : List α) (ys : List α) (f : List α → β) :
(permutationsAux2 t ts [] ys id).2.map f = (permutationsAux2 t ts [] ys f).2 :=
@@ -116,7 +129,9 @@ theorem map_permutationsAux2 (t : α) (ts : List α) (ys : List α) (f : List α
rw [map_permutations_aux2' id, map_id, map_id]; rfl
simp
#align list.map_permutations_aux2 List.map_permutationsAux2
+-/
+#print List.permutationsAux2_snd_eq /-
/-- An expository lemma to show how all of `ts`, `r`, and `f` can be eliminated from
`permutations_aux2`.
@@ -132,17 +147,22 @@ theorem permutationsAux2_snd_eq (t : α) (ts : List α) (r : List β) (ys : List
((permutationsAux2 t [] [] ys id).2.map fun x => f (x ++ ts)) ++ r :=
by rw [← permutations_aux2_append, map_permutations_aux2, permutations_aux2_comp_append]
#align list.permutations_aux2_snd_eq List.permutationsAux2_snd_eq
+-/
+#print List.map_map_permutationsAux2 /-
theorem map_map_permutationsAux2 {α α'} (g : α → α') (t : α) (ts ys : List α) :
map (map g) (permutationsAux2 t ts [] ys id).2 =
(permutationsAux2 (g t) (map g ts) [] (map g ys) id).2 :=
map_permutationsAux2' _ _ _ _ _ _ _ _ fun _ => rfl
#align list.map_map_permutations_aux2 List.map_map_permutationsAux2
+-/
+#print List.map_map_permutations'Aux /-
theorem map_map_permutations'Aux (f : α → β) (t : α) (ts : List α) :
map (map f) (permutations'Aux t ts) = permutations'Aux (f t) (map f ts) := by
induction' ts with a ts ih <;> [rfl; · simp [← ih]; rfl]
#align list.map_map_permutations'_aux List.map_map_permutations'Aux
+-/
#print List.permutations'Aux_eq_permutationsAux2 /-
theorem permutations'Aux_eq_permutationsAux2 (t : α) (ts : List α) :
@@ -183,10 +203,12 @@ theorem mem_permutationsAux2' {t : α} {ts : List α} {ys : List α} {l : List
#align list.mem_permutations_aux2' List.mem_permutationsAux2'
-/
+#print List.length_permutationsAux2 /-
theorem length_permutationsAux2 (t : α) (ts : List α) (ys : List α) (f : List α → β) :
length (permutationsAux2 t ts [] ys f).2 = length ys := by
induction ys generalizing f <;> simp [*]
#align list.length_permutations_aux2 List.length_permutationsAux2
+-/
#print List.foldr_permutationsAux2 /-
theorem foldr_permutationsAux2 (t : α) (ts : List α) (r L : List (List α)) :
@@ -258,6 +280,7 @@ theorem permutations_nil : permutations ([] : List α) = [[]] := by
#align list.permutations_nil List.permutations_nil
-/
+#print List.map_permutationsAux /-
theorem map_permutationsAux (f : α → β) :
∀ ts is : List α, map (map f) (permutationsAux ts is) = permutationsAux (map f ts) (map f is) :=
by
@@ -266,16 +289,21 @@ theorem map_permutationsAux (f : α → β) :
simp only [foldr_permutations_aux2, map_append, map, map_map_permutations_aux2, permutations,
bind_map, IH1, append_assoc, permutations_aux_cons, cons_bind, ← IH2, map_bind]
#align list.map_permutations_aux List.map_permutationsAux
+-/
+#print List.map_permutations /-
theorem map_permutations (f : α → β) (ts : List α) :
map (map f) (permutations ts) = permutations (map f ts) := by
rw [permutations, permutations, map, map_permutations_aux, map]
#align list.map_permutations List.map_permutations
+-/
+#print List.map_permutations' /-
theorem map_permutations' (f : α → β) (ts : List α) :
map (map f) (permutations' ts) = permutations' (map f ts) := by
induction' ts with t ts ih <;> [rfl; simp [← ih, map_bind, ← map_map_permutations'_aux, bind_map]]
#align list.map_permutations' List.map_permutations'
+-/
#print List.permutationsAux_append /-
theorem permutationsAux_append (is is' ts : List α) :
mathlib commit https://github.com/leanprover-community/mathlib/commit/cca40788df1b8755d5baf17ab2f27dacc2e17acb
@@ -141,7 +141,7 @@ theorem map_map_permutationsAux2 {α α'} (g : α → α') (t : α) (ts ys : Lis
theorem map_map_permutations'Aux (f : α → β) (t : α) (ts : List α) :
map (map f) (permutations'Aux t ts) = permutations'Aux (f t) (map f ts) := by
- induction' ts with a ts ih <;> [rfl;· simp [← ih]; rfl]
+ induction' ts with a ts ih <;> [rfl; · simp [← ih]; rfl]
#align list.map_map_permutations'_aux List.map_map_permutations'Aux
#print List.permutations'Aux_eq_permutationsAux2 /-
@@ -170,7 +170,7 @@ theorem mem_permutationsAux2 {t : α} {ts : List α} {ys : List α} {l l' : List
· exact ⟨y :: l₁, l₂, l0, by simp⟩
· rintro ⟨_ | ⟨y', l₁⟩, l₂, l0, ye, rfl⟩
· simp [ye]
- · simp only [cons_append] at ye; rcases ye with ⟨rfl, rfl⟩
+ · simp only [cons_append] at ye ; rcases ye with ⟨rfl, rfl⟩
exact Or.inr ⟨l₁, l₂, l0, by simp⟩
#align list.mem_permutations_aux2 List.mem_permutationsAux2
-/
@@ -192,7 +192,7 @@ theorem length_permutationsAux2 (t : α) (ts : List α) (ys : List α) (f : List
theorem foldr_permutationsAux2 (t : α) (ts : List α) (r L : List (List α)) :
foldr (fun y r => (permutationsAux2 t ts r y id).2) r L =
(L.bind fun y => (permutationsAux2 t ts [] y id).2) ++ r :=
- by induction' L with l L ih <;> [rfl;· simp [ih]; rw [← permutations_aux2_append]]
+ by induction' L with l L ih <;> [rfl; · simp [ih]; rw [← permutations_aux2_append]]
#align list.foldr_permutations_aux2 List.foldr_permutationsAux2
-/
@@ -262,7 +262,7 @@ theorem map_permutationsAux (f : α → β) :
∀ ts is : List α, map (map f) (permutationsAux ts is) = permutationsAux (map f ts) (map f is) :=
by
refine' permutations_aux.rec (by simp) _
- introv IH1 IH2; rw [map] at IH2
+ introv IH1 IH2; rw [map] at IH2
simp only [foldr_permutations_aux2, map_append, map, map_map_permutations_aux2, permutations,
bind_map, IH1, append_assoc, permutations_aux_cons, cons_bind, ← IH2, map_bind]
#align list.map_permutations_aux List.map_permutationsAux
@@ -274,7 +274,7 @@ theorem map_permutations (f : α → β) (ts : List α) :
theorem map_permutations' (f : α → β) (ts : List α) :
map (map f) (permutations' ts) = permutations' (map f ts) := by
- induction' ts with t ts ih <;> [rfl;simp [← ih, map_bind, ← map_map_permutations'_aux, bind_map]]
+ induction' ts with t ts ih <;> [rfl; simp [← ih, map_bind, ← map_map_permutations'_aux, bind_map]]
#align list.map_permutations' List.map_permutations'
#print List.permutationsAux_append /-
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -57,12 +57,6 @@ variable {α β : Type _}
namespace List
-/- warning: list.permutations_aux2_fst -> List.permutationsAux2_fst is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} (t : α) (ts : List.{u1} α) (r : List.{u2} β) (ys : List.{u1} α) (f : (List.{u1} α) -> β), Eq.{succ u1} (List.{u1} α) (Prod.fst.{u1, u2} (List.{u1} α) (List.{u2} β) (List.permutationsAux2.{u1, u2} α β t ts r ys f)) (Append.append.{u1} (List.{u1} α) (List.hasAppend.{u1} α) ys ts)
-but is expected to have type
- forall {α : Type.{u2}} {β : Type.{u1}} (t : α) (ts : List.{u2} α) (r : List.{u1} β) (ys : List.{u2} α) (f : (List.{u2} α) -> β), Eq.{succ u2} (List.{u2} α) (Prod.fst.{u2, u1} (List.{u2} α) (List.{u1} β) (List.permutationsAux2.{u2, u1} α β t ts r ys f)) (HAppend.hAppend.{u2, u2, u2} (List.{u2} α) (List.{u2} α) (List.{u2} α) (instHAppend.{u2} (List.{u2} α) (List.instAppendList.{u2} α)) ys ts)
-Case conversion may be inaccurate. Consider using '#align list.permutations_aux2_fst List.permutationsAux2_fstₓ'. -/
theorem permutationsAux2_fst (t : α) (ts : List α) (r : List β) :
∀ (ys : List α) (f : List α → β), (permutationsAux2 t ts r ys f).1 = ys ++ ts
| [], f => rfl
@@ -73,24 +67,12 @@ theorem permutationsAux2_fst (t : α) (ts : List α) (r : List β) :
| ⟨_, zs⟩, rfl => rfl
#align list.permutations_aux2_fst List.permutationsAux2_fst
-/- warning: list.permutations_aux2_snd_nil -> List.permutationsAux2_snd_nil is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} (t : α) (ts : List.{u1} α) (r : List.{u2} β) (f : (List.{u1} α) -> β), Eq.{succ u2} (List.{u2} β) (Prod.snd.{u1, u2} (List.{u1} α) (List.{u2} β) (List.permutationsAux2.{u1, u2} α β t ts r (List.nil.{u1} α) f)) r
-but is expected to have type
- forall {α : Type.{u2}} {β : Type.{u1}} (t : α) (ts : List.{u2} α) (r : List.{u1} β) (f : (List.{u2} α) -> β), Eq.{succ u1} (List.{u1} β) (Prod.snd.{u2, u1} (List.{u2} α) (List.{u1} β) (List.permutationsAux2.{u2, u1} α β t ts r (List.nil.{u2} α) f)) r
-Case conversion may be inaccurate. Consider using '#align list.permutations_aux2_snd_nil List.permutationsAux2_snd_nilₓ'. -/
@[simp]
theorem permutationsAux2_snd_nil (t : α) (ts : List α) (r : List β) (f : List α → β) :
(permutationsAux2 t ts r [] f).2 = r :=
rfl
#align list.permutations_aux2_snd_nil List.permutationsAux2_snd_nil
-/- warning: list.permutations_aux2_snd_cons -> List.permutationsAux2_snd_cons is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} (t : α) (ts : List.{u1} α) (r : List.{u2} β) (y : α) (ys : List.{u1} α) (f : (List.{u1} α) -> β), Eq.{succ u2} (List.{u2} β) (Prod.snd.{u1, u2} (List.{u1} α) (List.{u2} β) (List.permutationsAux2.{u1, u2} α β t ts r (List.cons.{u1} α y ys) f)) (List.cons.{u2} β (f (Append.append.{u1} (List.{u1} α) (List.hasAppend.{u1} α) (List.cons.{u1} α t (List.cons.{u1} α y ys)) ts)) (Prod.snd.{u1, u2} (List.{u1} α) (List.{u2} β) (List.permutationsAux2.{u1, u2} α β t ts r ys (fun (x : List.{u1} α) => f (List.cons.{u1} α y x)))))
-but is expected to have type
- forall {α : Type.{u2}} {β : Type.{u1}} (t : α) (ts : List.{u2} α) (r : List.{u1} β) (y : α) (ys : List.{u2} α) (f : (List.{u2} α) -> β), Eq.{succ u1} (List.{u1} β) (Prod.snd.{u2, u1} (List.{u2} α) (List.{u1} β) (List.permutationsAux2.{u2, u1} α β t ts r (List.cons.{u2} α y ys) f)) (List.cons.{u1} β (f (HAppend.hAppend.{u2, u2, u2} (List.{u2} α) (List.{u2} α) (List.{u2} α) (instHAppend.{u2} (List.{u2} α) (List.instAppendList.{u2} α)) (List.cons.{u2} α t (List.cons.{u2} α y ys)) ts)) (Prod.snd.{u2, u1} (List.{u2} α) (List.{u1} β) (List.permutationsAux2.{u2, u1} α β t ts r ys (fun (x : List.{u2} α) => f (List.cons.{u2} α y x)))))
-Case conversion may be inaccurate. Consider using '#align list.permutations_aux2_snd_cons List.permutationsAux2_snd_consₓ'. -/
@[simp]
theorem permutationsAux2_snd_cons (t : α) (ts : List α) (r : List β) (y : α) (ys : List α)
(f : List α → β) :
@@ -103,24 +85,12 @@ theorem permutationsAux2_snd_cons (t : α) (ts : List α) (r : List β) (y : α)
| ⟨_, zs⟩, rfl => rfl
#align list.permutations_aux2_snd_cons List.permutationsAux2_snd_cons
-/- warning: list.permutations_aux2_append -> List.permutationsAux2_append is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} (t : α) (ts : List.{u1} α) (r : List.{u2} β) (ys : List.{u1} α) (f : (List.{u1} α) -> β), Eq.{succ u2} (List.{u2} β) (Append.append.{u2} (List.{u2} β) (List.hasAppend.{u2} β) (Prod.snd.{u1, u2} (List.{u1} α) (List.{u2} β) (List.permutationsAux2.{u1, u2} α β t ts (List.nil.{u2} β) ys f)) r) (Prod.snd.{u1, u2} (List.{u1} α) (List.{u2} β) (List.permutationsAux2.{u1, u2} α β t ts r ys f))
-but is expected to have type
- forall {α : Type.{u2}} {β : Type.{u1}} (t : α) (ts : List.{u2} α) (r : List.{u1} β) (ys : List.{u2} α) (f : (List.{u2} α) -> β), Eq.{succ u1} (List.{u1} β) (HAppend.hAppend.{u1, u1, u1} (List.{u1} β) (List.{u1} β) (List.{u1} β) (instHAppend.{u1} (List.{u1} β) (List.instAppendList.{u1} β)) (Prod.snd.{u2, u1} (List.{u2} α) (List.{u1} β) (List.permutationsAux2.{u2, u1} α β t ts (List.nil.{u1} β) ys f)) r) (Prod.snd.{u2, u1} (List.{u2} α) (List.{u1} β) (List.permutationsAux2.{u2, u1} α β t ts r ys f))
-Case conversion may be inaccurate. Consider using '#align list.permutations_aux2_append List.permutationsAux2_appendₓ'. -/
/-- The `r` argument to `permutations_aux2` is the same as appending. -/
theorem permutationsAux2_append (t : α) (ts : List α) (r : List β) (ys : List α) (f : List α → β) :
(permutationsAux2 t ts nil ys f).2 ++ r = (permutationsAux2 t ts r ys f).2 := by
induction ys generalizing f <;> simp [*]
#align list.permutations_aux2_append List.permutationsAux2_append
-/- warning: list.permutations_aux2_comp_append -> List.permutationsAux2_comp_append is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} {t : α} {ts : List.{u1} α} {ys : List.{u1} α} {r : List.{u2} β} (f : (List.{u1} α) -> β), Eq.{succ u2} (List.{u2} β) (Prod.snd.{u1, u2} (List.{u1} α) (List.{u2} β) (List.permutationsAux2.{u1, u2} α β t (List.nil.{u1} α) r ys (fun (x : List.{u1} α) => f (Append.append.{u1} (List.{u1} α) (List.hasAppend.{u1} α) x ts)))) (Prod.snd.{u1, u2} (List.{u1} α) (List.{u2} β) (List.permutationsAux2.{u1, u2} α β t ts r ys f))
-but is expected to have type
- forall {α : Type.{u2}} {β : Type.{u1}} {t : α} {ts : List.{u2} α} {ys : List.{u2} α} {r : List.{u1} β} (f : (List.{u2} α) -> β), Eq.{succ u1} (List.{u1} β) (Prod.snd.{u2, u1} (List.{u2} α) (List.{u1} β) (List.permutationsAux2.{u2, u1} α β t (List.nil.{u2} α) r ys (fun (x : List.{u2} α) => f (HAppend.hAppend.{u2, u2, u2} (List.{u2} α) (List.{u2} α) (List.{u2} α) (instHAppend.{u2} (List.{u2} α) (List.instAppendList.{u2} α)) x ts)))) (Prod.snd.{u2, u1} (List.{u2} α) (List.{u1} β) (List.permutationsAux2.{u2, u1} α β t ts r ys f))
-Case conversion may be inaccurate. Consider using '#align list.permutations_aux2_comp_append List.permutationsAux2_comp_appendₓ'. -/
/-- The `ts` argument to `permutations_aux2` can be folded into the `f` argument. -/
theorem permutationsAux2_comp_append {t : α} {ts ys : List α} {r : List β} (f : List α → β) :
(permutationsAux2 t [] r ys fun x => f (x ++ ts)).2 = (permutationsAux2 t ts r ys f).2 :=
@@ -130,12 +100,6 @@ theorem permutationsAux2_comp_append {t : α} {ts ys : List α} {r : List β} (f
· simp [ys_ih fun xs => f (ys_hd :: xs)]
#align list.permutations_aux2_comp_append List.permutationsAux2_comp_append
-/- warning: list.map_permutations_aux2' -> List.map_permutationsAux2' is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} {α' : Type.{u3}} {β' : Type.{u4}} (g : α -> α') (g' : β -> β') (t : α) (ts : List.{u1} α) (ys : List.{u1} α) (r : List.{u2} β) (f : (List.{u1} α) -> β) (f' : (List.{u3} α') -> β'), (forall (a : List.{u1} α), Eq.{succ u4} β' (g' (f a)) (f' (List.map.{u1, u3} α α' g a))) -> (Eq.{succ u4} (List.{u4} β') (List.map.{u2, u4} β β' g' (Prod.snd.{u1, u2} (List.{u1} α) (List.{u2} β) (List.permutationsAux2.{u1, u2} α β t ts r ys f))) (Prod.snd.{u3, u4} (List.{u3} α') (List.{u4} β') (List.permutationsAux2.{u3, u4} α' β' (g t) (List.map.{u1, u3} α α' g ts) (List.map.{u2, u4} β β' g' r) (List.map.{u1, u3} α α' g ys) f')))
-but is expected to have type
- forall {α : Type.{u4}} {β : Type.{u3}} {α' : Type.{u2}} {β' : Type.{u1}} (g : α -> α') (g' : β -> β') (t : α) (ts : List.{u4} α) (ys : List.{u4} α) (r : List.{u3} β) (f : (List.{u4} α) -> β) (f' : (List.{u2} α') -> β'), (forall (a : List.{u4} α), Eq.{succ u1} β' (g' (f a)) (f' (List.map.{u4, u2} α α' g a))) -> (Eq.{succ u1} (List.{u1} β') (List.map.{u3, u1} β β' g' (Prod.snd.{u4, u3} (List.{u4} α) (List.{u3} β) (List.permutationsAux2.{u4, u3} α β t ts r ys f))) (Prod.snd.{u2, u1} (List.{u2} α') (List.{u1} β') (List.permutationsAux2.{u2, u1} α' β' (g t) (List.map.{u4, u2} α α' g ts) (List.map.{u3, u1} β β' g' r) (List.map.{u4, u2} α α' g ys) f')))
-Case conversion may be inaccurate. Consider using '#align list.map_permutations_aux2' List.map_permutationsAux2'ₓ'. -/
theorem map_permutationsAux2' {α β α' β'} (g : α → α') (g' : β → β') (t : α) (ts ys : List α)
(r : List β) (f : List α → β) (f' : List α' → β') (H : ∀ a, g' (f a) = f' (map g a)) :
map g' (permutationsAux2 t ts r ys f).2 =
@@ -145,12 +109,6 @@ theorem map_permutationsAux2' {α β α' β'} (g : α → α') (g' : β → β')
apply ys_ih; simp [H]
#align list.map_permutations_aux2' List.map_permutationsAux2'
-/- warning: list.map_permutations_aux2 -> List.map_permutationsAux2 is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} (t : α) (ts : List.{u1} α) (ys : List.{u1} α) (f : (List.{u1} α) -> β), Eq.{succ u2} (List.{u2} β) (List.map.{u1, u2} (List.{u1} α) β f (Prod.snd.{u1, u1} (List.{u1} α) (List.{u1} (List.{u1} α)) (List.permutationsAux2.{u1, u1} α (List.{u1} α) t ts (List.nil.{u1} (List.{u1} α)) ys (id.{succ u1} (List.{u1} α))))) (Prod.snd.{u1, u2} (List.{u1} α) (List.{u2} β) (List.permutationsAux2.{u1, u2} α β t ts (List.nil.{u2} β) ys f))
-but is expected to have type
- forall {α : Type.{u2}} {β : Type.{u1}} (t : α) (ts : List.{u2} α) (ys : List.{u2} α) (f : (List.{u2} α) -> β), Eq.{succ u1} (List.{u1} β) (List.map.{u2, u1} (List.{u2} α) β f (Prod.snd.{u2, u2} (List.{u2} α) (List.{u2} (List.{u2} α)) (List.permutationsAux2.{u2, u2} α (List.{u2} α) t ts (List.nil.{u2} (List.{u2} α)) ys (id.{succ u2} (List.{u2} α))))) (Prod.snd.{u2, u1} (List.{u2} α) (List.{u1} β) (List.permutationsAux2.{u2, u1} α β t ts (List.nil.{u1} β) ys f))
-Case conversion may be inaccurate. Consider using '#align list.map_permutations_aux2 List.map_permutationsAux2ₓ'. -/
/-- The `f` argument to `permutations_aux2` when `r = []` can be eliminated. -/
theorem map_permutationsAux2 (t : α) (ts : List α) (ys : List α) (f : List α → β) :
(permutationsAux2 t ts [] ys id).2.map f = (permutationsAux2 t ts [] ys f).2 :=
@@ -159,12 +117,6 @@ theorem map_permutationsAux2 (t : α) (ts : List α) (ys : List α) (f : List α
simp
#align list.map_permutations_aux2 List.map_permutationsAux2
-/- warning: list.permutations_aux2_snd_eq -> List.permutationsAux2_snd_eq is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} (t : α) (ts : List.{u1} α) (r : List.{u2} β) (ys : List.{u1} α) (f : (List.{u1} α) -> β), Eq.{succ u2} (List.{u2} β) (Prod.snd.{u1, u2} (List.{u1} α) (List.{u2} β) (List.permutationsAux2.{u1, u2} α β t ts r ys f)) (Append.append.{u2} (List.{u2} β) (List.hasAppend.{u2} β) (List.map.{u1, u2} (List.{u1} α) β (fun (x : List.{u1} α) => f (Append.append.{u1} (List.{u1} α) (List.hasAppend.{u1} α) x ts)) (Prod.snd.{u1, u1} (List.{u1} α) (List.{u1} (List.{u1} α)) (List.permutationsAux2.{u1, u1} α (List.{u1} α) t (List.nil.{u1} α) (List.nil.{u1} (List.{u1} α)) ys (id.{succ u1} (List.{u1} α))))) r)
-but is expected to have type
- forall {α : Type.{u2}} {β : Type.{u1}} (t : α) (ts : List.{u2} α) (r : List.{u1} β) (ys : List.{u2} α) (f : (List.{u2} α) -> β), Eq.{succ u1} (List.{u1} β) (Prod.snd.{u2, u1} (List.{u2} α) (List.{u1} β) (List.permutationsAux2.{u2, u1} α β t ts r ys f)) (HAppend.hAppend.{u1, u1, u1} (List.{u1} β) (List.{u1} β) (List.{u1} β) (instHAppend.{u1} (List.{u1} β) (List.instAppendList.{u1} β)) (List.map.{u2, u1} (List.{u2} α) β (fun (x : List.{u2} α) => f (HAppend.hAppend.{u2, u2, u2} (List.{u2} α) (List.{u2} α) (List.{u2} α) (instHAppend.{u2} (List.{u2} α) (List.instAppendList.{u2} α)) x ts)) (Prod.snd.{u2, u2} (List.{u2} α) (List.{u2} (List.{u2} α)) (List.permutationsAux2.{u2, u2} α (List.{u2} α) t (List.nil.{u2} α) (List.nil.{u2} (List.{u2} α)) ys (id.{succ u2} (List.{u2} α))))) r)
-Case conversion may be inaccurate. Consider using '#align list.permutations_aux2_snd_eq List.permutationsAux2_snd_eqₓ'. -/
/-- An expository lemma to show how all of `ts`, `r`, and `f` can be eliminated from
`permutations_aux2`.
@@ -181,24 +133,12 @@ theorem permutationsAux2_snd_eq (t : α) (ts : List α) (r : List β) (ys : List
by rw [← permutations_aux2_append, map_permutations_aux2, permutations_aux2_comp_append]
#align list.permutations_aux2_snd_eq List.permutationsAux2_snd_eq
-/- warning: list.map_map_permutations_aux2 -> List.map_map_permutationsAux2 is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {α' : Type.{u2}} (g : α -> α') (t : α) (ts : List.{u1} α) (ys : List.{u1} α), Eq.{succ u2} (List.{u2} (List.{u2} α')) (List.map.{u1, u2} (List.{u1} α) (List.{u2} α') (List.map.{u1, u2} α α' g) (Prod.snd.{u1, u1} (List.{u1} α) (List.{u1} (List.{u1} α)) (List.permutationsAux2.{u1, u1} α (List.{u1} α) t ts (List.nil.{u1} (List.{u1} α)) ys (id.{succ u1} (List.{u1} α))))) (Prod.snd.{u2, u2} (List.{u2} α') (List.{u2} (List.{u2} α')) (List.permutationsAux2.{u2, u2} α' (List.{u2} α') (g t) (List.map.{u1, u2} α α' g ts) (List.nil.{u2} (List.{u2} α')) (List.map.{u1, u2} α α' g ys) (id.{succ u2} (List.{u2} α'))))
-but is expected to have type
- forall {α : Type.{u2}} {α' : Type.{u1}} (g : α -> α') (t : α) (ts : List.{u2} α) (ys : List.{u2} α), Eq.{succ u1} (List.{u1} (List.{u1} α')) (List.map.{u2, u1} (List.{u2} α) (List.{u1} α') (List.map.{u2, u1} α α' g) (Prod.snd.{u2, u2} (List.{u2} α) (List.{u2} (List.{u2} α)) (List.permutationsAux2.{u2, u2} α (List.{u2} α) t ts (List.nil.{u2} (List.{u2} α)) ys (id.{succ u2} (List.{u2} α))))) (Prod.snd.{u1, u1} (List.{u1} α') (List.{u1} (List.{u1} α')) (List.permutationsAux2.{u1, u1} α' (List.{u1} α') (g t) (List.map.{u2, u1} α α' g ts) (List.nil.{u1} (List.{u1} α')) (List.map.{u2, u1} α α' g ys) (id.{succ u1} (List.{u1} α'))))
-Case conversion may be inaccurate. Consider using '#align list.map_map_permutations_aux2 List.map_map_permutationsAux2ₓ'. -/
theorem map_map_permutationsAux2 {α α'} (g : α → α') (t : α) (ts ys : List α) :
map (map g) (permutationsAux2 t ts [] ys id).2 =
(permutationsAux2 (g t) (map g ts) [] (map g ys) id).2 :=
map_permutationsAux2' _ _ _ _ _ _ _ _ fun _ => rfl
#align list.map_map_permutations_aux2 List.map_map_permutationsAux2
-/- warning: list.map_map_permutations'_aux -> List.map_map_permutations'Aux is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} (f : α -> β) (t : α) (ts : List.{u1} α), Eq.{succ u2} (List.{u2} (List.{u2} β)) (List.map.{u1, u2} (List.{u1} α) (List.{u2} β) (List.map.{u1, u2} α β f) (List.permutations'Aux.{u1} α t ts)) (List.permutations'Aux.{u2} β (f t) (List.map.{u1, u2} α β f ts))
-but is expected to have type
- forall {α : Type.{u2}} {β : Type.{u1}} (f : α -> β) (t : α) (ts : List.{u2} α), Eq.{succ u1} (List.{u1} (List.{u1} β)) (List.map.{u2, u1} (List.{u2} α) (List.{u1} β) (List.map.{u2, u1} α β f) (List.permutations'Aux.{u2} α t ts)) (List.permutations'Aux.{u1} β (f t) (List.map.{u2, u1} α β f ts))
-Case conversion may be inaccurate. Consider using '#align list.map_map_permutations'_aux List.map_map_permutations'Auxₓ'. -/
theorem map_map_permutations'Aux (f : α → β) (t : α) (ts : List α) :
map (map f) (permutations'Aux t ts) = permutations'Aux (f t) (map f ts) := by
induction' ts with a ts ih <;> [rfl;· simp [← ih]; rfl]
@@ -243,12 +183,6 @@ theorem mem_permutationsAux2' {t : α} {ts : List α} {ys : List α} {l : List
#align list.mem_permutations_aux2' List.mem_permutationsAux2'
-/
-/- warning: list.length_permutations_aux2 -> List.length_permutationsAux2 is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} (t : α) (ts : List.{u1} α) (ys : List.{u1} α) (f : (List.{u1} α) -> β), Eq.{1} Nat (List.length.{u2} β (Prod.snd.{u1, u2} (List.{u1} α) (List.{u2} β) (List.permutationsAux2.{u1, u2} α β t ts (List.nil.{u2} β) ys f))) (List.length.{u1} α ys)
-but is expected to have type
- forall {α : Type.{u2}} {β : Type.{u1}} (t : α) (ts : List.{u2} α) (ys : List.{u2} α) (f : (List.{u2} α) -> β), Eq.{1} Nat (List.length.{u1} β (Prod.snd.{u2, u1} (List.{u2} α) (List.{u1} β) (List.permutationsAux2.{u2, u1} α β t ts (List.nil.{u1} β) ys f))) (List.length.{u2} α ys)
-Case conversion may be inaccurate. Consider using '#align list.length_permutations_aux2 List.length_permutationsAux2ₓ'. -/
theorem length_permutationsAux2 (t : α) (ts : List α) (ys : List α) (f : List α → β) :
length (permutationsAux2 t ts [] ys f).2 = length ys := by
induction ys generalizing f <;> simp [*]
@@ -324,12 +258,6 @@ theorem permutations_nil : permutations ([] : List α) = [[]] := by
#align list.permutations_nil List.permutations_nil
-/
-/- warning: list.map_permutations_aux -> List.map_permutationsAux is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} (f : α -> β) (ts : List.{u1} α) (is : List.{u1} α), Eq.{succ u2} (List.{u2} (List.{u2} β)) (List.map.{u1, u2} (List.{u1} α) (List.{u2} β) (List.map.{u1, u2} α β f) (List.permutationsAux.{u1} α ts is)) (List.permutationsAux.{u2} β (List.map.{u1, u2} α β f ts) (List.map.{u1, u2} α β f is))
-but is expected to have type
- forall {α : Type.{u2}} {β : Type.{u1}} (f : α -> β) (ts : List.{u2} α) (is : List.{u2} α), Eq.{succ u1} (List.{u1} (List.{u1} β)) (List.map.{u2, u1} (List.{u2} α) (List.{u1} β) (List.map.{u2, u1} α β f) (List.permutationsAux.{u2} α ts is)) (List.permutationsAux.{u1} β (List.map.{u2, u1} α β f ts) (List.map.{u2, u1} α β f is))
-Case conversion may be inaccurate. Consider using '#align list.map_permutations_aux List.map_permutationsAuxₓ'. -/
theorem map_permutationsAux (f : α → β) :
∀ ts is : List α, map (map f) (permutationsAux ts is) = permutationsAux (map f ts) (map f is) :=
by
@@ -339,23 +267,11 @@ theorem map_permutationsAux (f : α → β) :
bind_map, IH1, append_assoc, permutations_aux_cons, cons_bind, ← IH2, map_bind]
#align list.map_permutations_aux List.map_permutationsAux
-/- warning: list.map_permutations -> List.map_permutations is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} (f : α -> β) (ts : List.{u1} α), Eq.{succ u2} (List.{u2} (List.{u2} β)) (List.map.{u1, u2} (List.{u1} α) (List.{u2} β) (List.map.{u1, u2} α β f) (List.permutations.{u1} α ts)) (List.permutations.{u2} β (List.map.{u1, u2} α β f ts))
-but is expected to have type
- forall {α : Type.{u2}} {β : Type.{u1}} (f : α -> β) (ts : List.{u2} α), Eq.{succ u1} (List.{u1} (List.{u1} β)) (List.map.{u2, u1} (List.{u2} α) (List.{u1} β) (List.map.{u2, u1} α β f) (List.permutations.{u2} α ts)) (List.permutations.{u1} β (List.map.{u2, u1} α β f ts))
-Case conversion may be inaccurate. Consider using '#align list.map_permutations List.map_permutationsₓ'. -/
theorem map_permutations (f : α → β) (ts : List α) :
map (map f) (permutations ts) = permutations (map f ts) := by
rw [permutations, permutations, map, map_permutations_aux, map]
#align list.map_permutations List.map_permutations
-/- warning: list.map_permutations' -> List.map_permutations' is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} (f : α -> β) (ts : List.{u1} α), Eq.{succ u2} (List.{u2} (List.{u2} β)) (List.map.{u1, u2} (List.{u1} α) (List.{u2} β) (List.map.{u1, u2} α β f) (List.permutations'.{u1} α ts)) (List.permutations'.{u2} β (List.map.{u1, u2} α β f ts))
-but is expected to have type
- forall {α : Type.{u2}} {β : Type.{u1}} (f : α -> β) (ts : List.{u2} α), Eq.{succ u1} (List.{u1} (List.{u1} β)) (List.map.{u2, u1} (List.{u2} α) (List.{u1} β) (List.map.{u2, u1} α β f) (List.permutations'.{u2} α ts)) (List.permutations'.{u1} β (List.map.{u2, u1} α β f ts))
-Case conversion may be inaccurate. Consider using '#align list.map_permutations' List.map_permutations'ₓ'. -/
theorem map_permutations' (f : α → β) (ts : List α) :
map (map f) (permutations' ts) = permutations' (map f ts) := by
induction' ts with t ts ih <;> [rfl;simp [← ih, map_bind, ← map_map_permutations'_aux, bind_map]]
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -201,10 +201,7 @@ but is expected to have type
Case conversion may be inaccurate. Consider using '#align list.map_map_permutations'_aux List.map_map_permutations'Auxₓ'. -/
theorem map_map_permutations'Aux (f : α → β) (t : α) (ts : List α) :
map (map f) (permutations'Aux t ts) = permutations'Aux (f t) (map f ts) := by
- induction' ts with a ts ih <;>
- [rfl;·
- simp [← ih]
- rfl]
+ induction' ts with a ts ih <;> [rfl;· simp [← ih]; rfl]
#align list.map_map_permutations'_aux List.map_map_permutations'Aux
#print List.permutations'Aux_eq_permutationsAux2 /-
@@ -233,8 +230,7 @@ theorem mem_permutationsAux2 {t : α} {ts : List α} {ys : List α} {l l' : List
· exact ⟨y :: l₁, l₂, l0, by simp⟩
· rintro ⟨_ | ⟨y', l₁⟩, l₂, l0, ye, rfl⟩
· simp [ye]
- · simp only [cons_append] at ye
- rcases ye with ⟨rfl, rfl⟩
+ · simp only [cons_append] at ye; rcases ye with ⟨rfl, rfl⟩
exact Or.inr ⟨l₁, l₂, l0, by simp⟩
#align list.mem_permutations_aux2 List.mem_permutationsAux2
-/
@@ -262,11 +258,7 @@ theorem length_permutationsAux2 (t : α) (ts : List α) (ys : List α) (f : List
theorem foldr_permutationsAux2 (t : α) (ts : List α) (r L : List (List α)) :
foldr (fun y r => (permutationsAux2 t ts r y id).2) r L =
(L.bind fun y => (permutationsAux2 t ts [] y id).2) ++ r :=
- by
- induction' L with l L ih <;>
- [rfl;·
- simp [ih]
- rw [← permutations_aux2_append]]
+ by induction' L with l L ih <;> [rfl;· simp [ih]; rw [← permutations_aux2_append]]
#align list.foldr_permutations_aux2 List.foldr_permutationsAux2
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/8d33f09cd7089ecf074b4791907588245aec5d1b
@@ -201,8 +201,9 @@ but is expected to have type
Case conversion may be inaccurate. Consider using '#align list.map_map_permutations'_aux List.map_map_permutations'Auxₓ'. -/
theorem map_map_permutations'Aux (f : α → β) (t : α) (ts : List α) :
map (map f) (permutations'Aux t ts) = permutations'Aux (f t) (map f ts) := by
- induction' ts with a ts ih <;> [rfl,
- · simp [← ih]
+ induction' ts with a ts ih <;>
+ [rfl;·
+ simp [← ih]
rfl]
#align list.map_map_permutations'_aux List.map_map_permutations'Aux
@@ -262,8 +263,9 @@ theorem foldr_permutationsAux2 (t : α) (ts : List α) (r L : List (List α)) :
foldr (fun y r => (permutationsAux2 t ts r y id).2) r L =
(L.bind fun y => (permutationsAux2 t ts [] y id).2) ++ r :=
by
- induction' L with l L ih <;> [rfl,
- · simp [ih]
+ induction' L with l L ih <;>
+ [rfl;·
+ simp [ih]
rw [← permutations_aux2_append]]
#align list.foldr_permutations_aux2 List.foldr_permutationsAux2
-/
@@ -364,7 +366,7 @@ but is expected to have type
Case conversion may be inaccurate. Consider using '#align list.map_permutations' List.map_permutations'ₓ'. -/
theorem map_permutations' (f : α → β) (ts : List α) :
map (map f) (permutations' ts) = permutations' (map f ts) := by
- induction' ts with t ts ih <;> [rfl, simp [← ih, map_bind, ← map_map_permutations'_aux, bind_map]]
+ induction' ts with t ts ih <;> [rfl;simp [← ih, map_bind, ← map_map_permutations'_aux, bind_map]]
#align list.map_permutations' List.map_permutations'
#print List.permutationsAux_append /-
mathlib commit https://github.com/leanprover-community/mathlib/commit/bd9851ca476957ea4549eb19b40e7b5ade9428cc
@@ -95,15 +95,16 @@ theorem map_permutationsAux2' {α β α' β'} (g : α → α') (g' : β → β')
· simp
· simp only [map, permutationsAux2_snd_cons, cons_append, cons.injEq]
rw [ys_ih, permutationsAux2_fst]
- refine' ⟨_, rfl⟩
- · simp only [← map_cons, ← map_append]; apply H
+ · refine' ⟨_, rfl⟩
+ simp only [← map_cons, ← map_append]; apply H
· intro a; apply H
#align list.map_permutations_aux2' List.map_permutationsAux2'
/-- The `f` argument to `permutationsAux2` when `r = []` can be eliminated. -/
theorem map_permutationsAux2 (t : α) (ts : List α) (ys : List α) (f : List α → β) :
(permutationsAux2 t ts [] ys id).2.map f = (permutationsAux2 t ts [] ys f).2 := by
- rw [map_permutationsAux2' id, map_id, map_id]; rfl
+ rw [map_permutationsAux2' id, map_id, map_id]
+ · rfl
simp
#align list.map_permutations_aux2 List.map_permutationsAux2
@@ -133,8 +133,7 @@ theorem map_map_permutations'Aux (f : α → β) (t : α) (ts : List α) :
map (map f) (permutations'Aux t ts) = permutations'Aux (f t) (map f ts) := by
induction' ts with a ts ih
· rfl
- · simp only [permutations'Aux, map_cons, map_map, ← ih, cons.injEq, true_and]
- rfl
+ · simp only [permutations'Aux, map_cons, map_map, ← ih, cons.injEq, true_and, Function.comp_def]
#align list.map_map_permutations'_aux List.map_map_permutations'Aux
theorem permutations'Aux_eq_permutationsAux2 (t : α) (ts : List α) :
@@ -180,8 +179,7 @@ theorem foldr_permutationsAux2 (t : α) (ts : List α) (r L : List (List α)) :
(L.bind fun y => (permutationsAux2 t ts [] y id).2) ++ r := by
induction' L with l L ih
· rfl
- · simp only [foldr_cons, ih, cons_bind, append_assoc]
- rw [← permutationsAux2_append]
+ · simp_rw [foldr_cons, ih, cons_bind, append_assoc, permutationsAux2_append]
#align list.foldr_permutations_aux2 List.foldr_permutationsAux2
theorem mem_foldr_permutationsAux2 {t : α} {ts : List α} {r L : List (List α)} {l' : List α} :
Remove dependencies on algebra in the Data.List
folder except for:
Data.List.EditDistance
: Actually relies on algebra. Maybe should be moved?Data.List.Card
: Completely unused and redundant.Data.List.Cycle
: Relies on Fintype
, which shouldn't rely on algebra but it's hard to fix right now. Maybe should be moved?Data.List.Func
: Completely unused and redundant.Data.List.Lex
: That's order theory. Could be moved.Data.List.Prime
. That's algebra. Should definitely be moved.Data.List.Sym
: Relies on Multiset
, which shouldn't rely on algebra but it's hard to fix right now. Maybe should be moved?Data.List.ToFinsupp
: That's algebra. Should definitely be moved.As a consequence, move the big operators lemmas that were in there to Algebra.BigOperators.List.Basic
. For the lemmas that were Nat
-specific and not about auxiliary definitions, keep a version of them in the original file but stated using Nat.sum
.
Before
After
@@ -44,6 +44,8 @@ all positions. Hence, to build `[0, 1, 2, 3].permutations'`, it does
Show that `l.Nodup → l.permutations.Nodup`. See `Data.Fintype.List`.
-/
+-- Make sure we don't import algebra
+assert_not_exists Monoid
open Nat
@@ -198,19 +200,19 @@ theorem mem_foldr_permutationsAux2 {t : α} {ts : List α} {r L : List (List α)
theorem length_foldr_permutationsAux2 (t : α) (ts : List α) (r L : List (List α)) :
length (foldr (fun y r => (permutationsAux2 t ts r y id).2) r L) =
- sum (map length L) + length r :=
- by simp [foldr_permutationsAux2, (· ∘ ·), length_permutationsAux2]
+ Nat.sum (map length L) + length r :=
+ by simp [foldr_permutationsAux2, (· ∘ ·), length_permutationsAux2, length_bind']
#align list.length_foldr_permutations_aux2 List.length_foldr_permutationsAux2
theorem length_foldr_permutationsAux2' (t : α) (ts : List α) (r L : List (List α)) (n)
(H : ∀ l ∈ L, length l = n) :
length (foldr (fun y r => (permutationsAux2 t ts r y id).2) r L) = n * length L + length r := by
- rw [length_foldr_permutationsAux2, (_ : List.sum (map length L) = n * length L)]
+ rw [length_foldr_permutationsAux2, (_ : Nat.sum (map length L) = n * length L)]
induction' L with l L ih
· simp
- have sum_map : sum (map length L) = n * length L := ih fun l m => H l (mem_cons_of_mem _ m)
+ have sum_map : Nat.sum (map length L) = n * length L := ih fun l m => H l (mem_cons_of_mem _ m)
have length_l : length l = n := H _ (mem_cons_self _ _)
- simp [sum_map, length_l, mul_add, add_comm, mul_succ]
+ simp [sum_map, length_l, Nat.mul_add, Nat.add_comm, mul_succ]
#align list.length_foldr_permutations_aux2' List.length_foldr_permutationsAux2'
@[simp]
@@ -129,7 +129,10 @@ theorem map_map_permutationsAux2 {α α'} (g : α → α') (t : α) (ts ys : Lis
theorem map_map_permutations'Aux (f : α → β) (t : α) (ts : List α) :
map (map f) (permutations'Aux t ts) = permutations'Aux (f t) (map f ts) := by
- induction' ts with a ts ih <;> [rfl; (simp [← ih]; rfl)]
+ induction' ts with a ts ih
+ · rfl
+ · simp only [permutations'Aux, map_cons, map_map, ← ih, cons.injEq, true_and]
+ rfl
#align list.map_map_permutations'_aux List.map_map_permutations'Aux
theorem permutations'Aux_eq_permutationsAux2 (t : α) (ts : List α) :
@@ -175,7 +178,7 @@ theorem foldr_permutationsAux2 (t : α) (ts : List α) (r L : List (List α)) :
(L.bind fun y => (permutationsAux2 t ts [] y id).2) ++ r := by
induction' L with l L ih
· rfl
- · simp [ih]
+ · simp only [foldr_cons, ih, cons_bind, append_assoc]
rw [← permutationsAux2_append]
#align list.foldr_permutations_aux2 List.foldr_permutationsAux2
Removes nonterminal simps on lines looking like simp [...]
@@ -135,7 +135,8 @@ theorem map_map_permutations'Aux (f : α → β) (t : α) (ts : List α) :
theorem permutations'Aux_eq_permutationsAux2 (t : α) (ts : List α) :
permutations'Aux t ts = (permutationsAux2 t [] [ts ++ [t]] ts id).2 := by
induction' ts with a ts ih; · rfl
- simp [permutations'Aux, permutationsAux2_snd_cons, ih]
+ simp only [permutations'Aux, ih, cons_append, permutationsAux2_snd_cons, append_nil, id_eq,
+ cons.injEq, true_and]
simp (config := { singlePass := true }) only [← permutationsAux2_append]
simp [map_permutationsAux2]
#align list.permutations'_aux_eq_permutations_aux2 List.permutations'Aux_eq_permutationsAux2
Type _
and Sort _
(#6499)
We remove all possible occurences of Type _
and Sort _
in favor of Type*
and Sort*
.
This has nice performance benefits.
@@ -47,7 +47,7 @@ Show that `l.Nodup → l.permutations.Nodup`. See `Data.Fintype.List`.
open Nat
-variable {α β : Type _}
+variable {α β : Type*}
namespace List
@@ -141,12 +141,12 @@ theorem permutations'Aux_eq_permutationsAux2 (t : α) (ts : List α) :
#align list.permutations'_aux_eq_permutations_aux2 List.permutations'Aux_eq_permutationsAux2
theorem mem_permutationsAux2 {t : α} {ts : List α} {ys : List α} {l l' : List α} :
- l' ∈ (permutationsAux2 t ts [] ys (l ++ .)).2 ↔
+ l' ∈ (permutationsAux2 t ts [] ys (l ++ ·)).2 ↔
∃ l₁ l₂, l₂ ≠ [] ∧ ys = l₁ ++ l₂ ∧ l' = l ++ l₁ ++ t :: l₂ ++ ts := by
induction' ys with y ys ih generalizing l
· simp (config := { contextual := true })
rw [permutationsAux2_snd_cons,
- show (fun x : List α => l ++ y :: x) = (l ++ [y] ++ .) by funext _; simp, mem_cons, ih]
+ show (fun x : List α => l ++ y :: x) = (l ++ [y] ++ ·) by funext _; simp, mem_cons, ih]
constructor
· rintro (rfl | ⟨l₁, l₂, l0, rfl, rfl⟩)
· exact ⟨[], y :: ys, by simp⟩
@@ -161,7 +161,7 @@ theorem mem_permutationsAux2 {t : α} {ts : List α} {ys : List α} {l l' : List
theorem mem_permutationsAux2' {t : α} {ts : List α} {ys : List α} {l : List α} :
l ∈ (permutationsAux2 t ts [] ys id).2 ↔
∃ l₁ l₂, l₂ ≠ [] ∧ ys = l₁ ++ l₂ ∧ l = l₁ ++ t :: l₂ ++ ts :=
- by rw [show @id (List α) = ([] ++ .) by funext _; rfl]; apply mem_permutationsAux2
+ by rw [show @id (List α) = ([] ++ ·) by funext _; rfl]; apply mem_permutationsAux2
#align list.mem_permutations_aux2' List.mem_permutationsAux2'
theorem length_permutationsAux2 (t : α) (ts : List α) (ys : List α) (f : List α → β) :
@@ -2,14 +2,11 @@
Copyright (c) 2014 Parikshit Khanna. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Parikshit Khanna, Jeremy Avigad, Leonardo de Moura, Floris van Doorn, Mario Carneiro
-
-! This file was ported from Lean 3 source module data.list.permutation
-! leanprover-community/mathlib commit dd71334db81d0bd444af1ee339a29298bef40734
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathlib.Data.List.Join
+#align_import data.list.permutation from "leanprover-community/mathlib"@"dd71334db81d0bd444af1ee339a29298bef40734"
+
/-!
# Permutations of a list
This PR is the result of running
find . -type f -name "*.lean" -exec sed -i -E 's/^( +)\. /\1· /' {} \;
find . -type f -name "*.lean" -exec sed -i -E 'N;s/^( +·)\n +(.*)$/\1 \2/;P;D' {} \;
which firstly replaces .
focusing dots with ·
and secondly removes isolated instances of such dots, unifying them with the following line. A new rule is placed in the style linter to verify this.
@@ -93,12 +93,12 @@ theorem map_permutationsAux2' {α β α' β'} (g : α → α') (g' : β → β')
map g' (permutationsAux2 t ts r ys f).2 =
(permutationsAux2 (g t) (map g ts) (map g' r) (map g ys) f').2 := by
induction' ys with ys_hd _ ys_ih generalizing f f'
- . simp
- . simp only [map, permutationsAux2_snd_cons, cons_append, cons.injEq]
+ · simp
+ · simp only [map, permutationsAux2_snd_cons, cons_append, cons.injEq]
rw [ys_ih, permutationsAux2_fst]
refine' ⟨_, rfl⟩
- . simp only [← map_cons, ← map_append]; apply H
- . intro a; apply H
+ · simp only [← map_cons, ← map_append]; apply H
+ · intro a; apply H
#align list.map_permutations_aux2' List.map_permutationsAux2'
/-- The `f` argument to `permutationsAux2` when `r = []` can be eliminated. -/
The main breaking change is that tac <;> [t1, t2]
is now written tac <;> [t1; t2]
, to avoid clashing with tactics like cases
and use
that take comma-separated lists.
@@ -132,9 +132,7 @@ theorem map_map_permutationsAux2 {α α'} (g : α → α') (t : α) (ts ys : Lis
theorem map_map_permutations'Aux (f : α → β) (t : α) (ts : List α) :
map (map f) (permutations'Aux t ts) = permutations'Aux (f t) (map f ts) := by
- induction' ts with a ts ih <;> [rfl,
- · simp [← ih]
- rfl]
+ induction' ts with a ts ih <;> [rfl; (simp [← ih]; rfl)]
#align list.map_map_permutations'_aux List.map_map_permutations'Aux
theorem permutations'Aux_eq_permutationsAux2 (t : α) (ts : List α) :
@@ -248,7 +246,7 @@ theorem map_permutations (f : α → β) (ts : List α) :
theorem map_permutations' (f : α → β) (ts : List α) :
map (map f) (permutations' ts) = permutations' (map f ts) := by
- induction' ts with t ts ih <;> [rfl, simp [← ih, map_bind, ← map_map_permutations'Aux, bind_map]]
+ induction' ts with t ts ih <;> [rfl; simp [← ih, map_bind, ← map_map_permutations'Aux, bind_map]]
#align list.map_permutations' List.map_permutations'
theorem permutationsAux_append (is is' ts : List α) :
This was done semi-automatically with some regular expressions in vim in contrast to the fully automatic https://github.com/leanprover-community/mathlib4/pull/1523.
Co-authored-by: Moritz Firsching <firsching@google.com>
@@ -233,8 +233,8 @@ theorem permutations_nil : permutations ([] : List α) = [[]] := by
#align list.permutations_nil List.permutations_nil
theorem map_permutationsAux (f : α → β) :
- ∀ ts is : List α, map (map f) (permutationsAux ts is) = permutationsAux (map f ts) (map f is) :=
- by
+ ∀ ts is :
+ List α, map (map f) (permutationsAux ts is) = permutationsAux (map f ts) (map f is) := by
refine' permutationsAux.rec (by simp) _
introv IH1 IH2; rw [map] at IH2
simp only [foldr_permutationsAux2, map_append, map, map_map_permutationsAux2, permutations,
by
line breaks (#1523)
During porting, I usually fix the desired format we seem to want for the line breaks around by
with
awk '{do {{if (match($0, "^ by$") && length(p) < 98) {p=p " by";} else {if (NR!=1) {print p}; p=$0}}} while (getline == 1) if (getline==0) print p}' Mathlib/File/Im/Working/On.lean
I noticed there are some more files that slipped through.
This pull request is the result of running this command:
grep -lr "^ by\$" Mathlib | xargs -n 1 awk -i inplace '{do {{if (match($0, "^ by$") && length(p) < 98 && not (match(p, "^[ \t]*--"))) {p=p " by";} else {if (NR!=1) {print p}; p=$0}}} while (getline == 1) if (getline==0) print p}'
Co-authored-by: Moritz Firsching <firsching@google.com>
@@ -91,8 +91,7 @@ theorem permutationsAux2_comp_append {t : α} {ts ys : List α} {r : List β} (f
theorem map_permutationsAux2' {α β α' β'} (g : α → α') (g' : β → β') (t : α) (ts ys : List α)
(r : List β) (f : List α → β) (f' : List α' → β') (H : ∀ a, g' (f a) = f' (map g a)) :
map g' (permutationsAux2 t ts r ys f).2 =
- (permutationsAux2 (g t) (map g ts) (map g' r) (map g ys) f').2 :=
- by
+ (permutationsAux2 (g t) (map g ts) (map g' r) (map g ys) f').2 := by
induction' ys with ys_hd _ ys_ih generalizing f f'
. simp
. simp only [map, permutationsAux2_snd_cons, cons_append, cons.injEq]
@@ -104,8 +103,7 @@ theorem map_permutationsAux2' {α β α' β'} (g : α → α') (g' : β → β')
/-- The `f` argument to `permutationsAux2` when `r = []` can be eliminated. -/
theorem map_permutationsAux2 (t : α) (ts : List α) (ys : List α) (f : List α → β) :
- (permutationsAux2 t ts [] ys id).2.map f = (permutationsAux2 t ts [] ys f).2 :=
- by
+ (permutationsAux2 t ts [] ys id).2.map f = (permutationsAux2 t ts [] ys f).2 := by
rw [map_permutationsAux2' id, map_id, map_id]; rfl
simp
#align list.map_permutations_aux2 List.map_permutationsAux2
@@ -140,8 +138,7 @@ theorem map_map_permutations'Aux (f : α → β) (t : α) (ts : List α) :
#align list.map_map_permutations'_aux List.map_map_permutations'Aux
theorem permutations'Aux_eq_permutationsAux2 (t : α) (ts : List α) :
- permutations'Aux t ts = (permutationsAux2 t [] [ts ++ [t]] ts id).2 :=
- by
+ permutations'Aux t ts = (permutationsAux2 t [] [ts ++ [t]] ts id).2 := by
induction' ts with a ts ih; · rfl
simp [permutations'Aux, permutationsAux2_snd_cons, ih]
simp (config := { singlePass := true }) only [← permutationsAux2_append]
@@ -150,8 +147,7 @@ theorem permutations'Aux_eq_permutationsAux2 (t : α) (ts : List α) :
theorem mem_permutationsAux2 {t : α} {ts : List α} {ys : List α} {l l' : List α} :
l' ∈ (permutationsAux2 t ts [] ys (l ++ .)).2 ↔
- ∃ l₁ l₂, l₂ ≠ [] ∧ ys = l₁ ++ l₂ ∧ l' = l ++ l₁ ++ t :: l₂ ++ ts :=
- by
+ ∃ l₁ l₂, l₂ ≠ [] ∧ ys = l₁ ++ l₂ ∧ l' = l ++ l₁ ++ t :: l₂ ++ ts := by
induction' ys with y ys ih generalizing l
· simp (config := { contextual := true })
rw [permutationsAux2_snd_cons,
@@ -180,8 +176,7 @@ theorem length_permutationsAux2 (t : α) (ts : List α) (ys : List α) (f : List
theorem foldr_permutationsAux2 (t : α) (ts : List α) (r L : List (List α)) :
foldr (fun y r => (permutationsAux2 t ts r y id).2) r L =
- (L.bind fun y => (permutationsAux2 t ts [] y id).2) ++ r :=
- by
+ (L.bind fun y => (permutationsAux2 t ts [] y id).2) ++ r := by
induction' L with l L ih
· rfl
· simp [ih]
@@ -61,10 +61,10 @@ theorem permutationsAux2_fst (t : α) (ts : List α) (r : List β) :
#align list.permutations_aux2_fst List.permutationsAux2_fst
@[simp]
-theorem permutations_aux2_snd_nil (t : α) (ts : List α) (r : List β) (f : List α → β) :
+theorem permutationsAux2_snd_nil (t : α) (ts : List α) (r : List β) (f : List α → β) :
(permutationsAux2 t ts r [] f).2 = r :=
rfl
-#align list.permutations_aux2_snd_nil List.permutations_aux2_snd_nil
+#align list.permutations_aux2_snd_nil List.permutationsAux2_snd_nil
@[simp]
theorem permutationsAux2_snd_cons (t : α) (ts : List α) (r : List β) (y : α) (ys : List α)
@@ -74,13 +74,13 @@ theorem permutationsAux2_snd_cons (t : α) (ts : List α) (r : List β) (y : α)
by simp [permutationsAux2, permutationsAux2_fst t _ _ ys]
#align list.permutations_aux2_snd_cons List.permutationsAux2_snd_cons
-/-- The `r` argument to `permutations_aux2` is the same as appending. -/
+/-- The `r` argument to `permutationsAux2` is the same as appending. -/
theorem permutationsAux2_append (t : α) (ts : List α) (r : List β) (ys : List α) (f : List α → β) :
(permutationsAux2 t ts nil ys f).2 ++ r = (permutationsAux2 t ts r ys f).2 := by
induction ys generalizing f <;> simp [*]
#align list.permutations_aux2_append List.permutationsAux2_append
-/-- The `ts` argument to `permutations_aux2` can be folded into the `f` argument. -/
+/-- The `ts` argument to `permutationsAux2` can be folded into the `f` argument. -/
theorem permutationsAux2_comp_append {t : α} {ts ys : List α} {r : List β} (f : List α → β) :
((permutationsAux2 t [] r ys) fun x => f (x ++ ts)).2 = (permutationsAux2 t ts r ys f).2 := by
induction' ys with ys_hd _ ys_ih generalizing f
@@ -102,7 +102,7 @@ theorem map_permutationsAux2' {α β α' β'} (g : α → α') (g' : β → β')
. intro a; apply H
#align list.map_permutations_aux2' List.map_permutationsAux2'
-/-- The `f` argument to `permutations_aux2` when `r = []` can be eliminated. -/
+/-- The `f` argument to `permutationsAux2` when `r = []` can be eliminated. -/
theorem map_permutationsAux2 (t : α) (ts : List α) (ys : List α) (f : List α → β) :
(permutationsAux2 t ts [] ys id).2.map f = (permutationsAux2 t ts [] ys f).2 :=
by
@@ -111,12 +111,12 @@ theorem map_permutationsAux2 (t : α) (ts : List α) (ys : List α) (f : List α
#align list.map_permutations_aux2 List.map_permutationsAux2
/-- An expository lemma to show how all of `ts`, `r`, and `f` can be eliminated from
-`permutations_aux2`.
+`permutationsAux2`.
-`(permutations_aux2 t [] [] ys id).2`, which appears on the RHS, is a list whose elements are
+`(permutationsAux2 t [] [] ys id).2`, which appears on the RHS, is a list whose elements are
produced by inserting `t` into every non-terminal position of `ys` in order. As an example:
```lean
-#eval permutations_aux2 1 [] [] [2, 3, 4] id
+#eval permutationsAux2 1 [] [] [2, 3, 4] id
-- [[1, 2, 3, 4], [2, 1, 3, 4], [2, 3, 1, 4]]
```
-/
@@ -182,9 +182,10 @@ theorem foldr_permutationsAux2 (t : α) (ts : List α) (r L : List (List α)) :
foldr (fun y r => (permutationsAux2 t ts r y id).2) r L =
(L.bind fun y => (permutationsAux2 t ts [] y id).2) ++ r :=
by
- induction' L with l L ih <;> [rfl,
- · simp [ih]
- rw [← permutationsAux2_append]]
+ induction' L with l L ih
+ · rfl
+ · simp [ih]
+ rw [← permutationsAux2_append]
#align list.foldr_permutations_aux2 List.foldr_permutationsAux2
theorem mem_foldr_permutationsAux2 {t : α} {ts : List α} {r L : List (List α)} {l' : List α} :
@@ -211,7 +212,8 @@ theorem length_foldr_permutationsAux2' (t : α) (ts : List α) (r L : List (List
(H : ∀ l ∈ L, length l = n) :
length (foldr (fun y r => (permutationsAux2 t ts r y id).2) r L) = n * length L + length r := by
rw [length_foldr_permutationsAux2, (_ : List.sum (map length L) = n * length L)]
- induction' L with l L ih; · simp
+ induction' L with l L ih
+ · simp
have sum_map : sum (map length L) = n * length L := ih fun l m => H l (mem_cons_of_mem _ m)
have length_l : length l = n := H _ (mem_cons_self _ _)
simp [sum_map, length_l, mul_add, add_comm, mul_succ]
The unported dependencies are