Built with
doc-gen4 , running Lean4.
Bubbles (
) indicate interactive fragments: hover for details, tap to reveal contents.
Use
Ctrl+ā Ctrl+ā to navigate,
Ctrl+š±ļø to focus.
On Mac, use
Cmd instead of
Ctrl .
/-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Kenny Lau, Scott Morrison
! This file was ported from Lean 3 source module data.list.fin_range
! leanprover-community/mathlib commit 9003f28797c0664a49e4179487267c494477d853
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathlib.Data.List.OfFn
import Mathlib.Data.List.Perm
/-!
# Lists of elements of `Fin n`
This file develops some results on `finRange n`.
-/
universe u
namespace List
variable { α : Type u }
@[ simp ]
theorem map_coe_finRange ( n : ā ) : (( finRange n ) : List ( Fin n )). map : {α : Type ?u.13} ā {β : Type ?u.12} ā (α ā β ) ā List α ā List β map ( Fin.val ) = List.range n := by
simp_rw [ finRange , map_pmap : ā {α : Type ?u.196} {β : Type ?u.195} {γ : Type ?u.194} {p : α ā Prop } (g : β ā γ ) (f : (a : α ) ā p a ā β ) (l : List α )
(H : ā (a : α ), a ā l ā p a ), map g (pmap f l H ) = pmap (fun a h => g (f a h ) ) l H map_pmap, pmap_eq_map ]
exact List.map_id : ā {α : Type ?u.455} (l : List α ), map id l = l List.map_id _
#align list.map_coe_fin_range List.map_coe_finRange
theorem finRange_succ_eq_map ( n : ā ) : finRange n . succ = 0 :: ( finRange n ). map : {α : Type ?u.508} ā {β : Type ?u.507} ā (α ā β ) ā List α ā List β map Fin.succ := by
apply map_injective_iff . mpr : ā {a b : Prop }, (a ā b ) ā b ā a mpr Fin.val_injective
rw [ map_cons : ā {α : Type ?u.577} {β : Type ?u.578} (f : α ā β ) (a : α ) (l : List α ), map f (a :: l ) = f a :: map f l map_cons, map_coe_finRange , range_succ_eq_map , Fin.val_zero : ā (n : ā ) [inst : NeZero n ], ā0 = 0 Fin.val_zero, ā map_coe_finRange , map_map : ā {β : Type ?u.644} {γ : Type ?u.645} {α : Type ?u.646} (g : β ā γ ) (f : α ā β ) (l : List α ),
map g (map f l ) = map (g ā f ) l map_map,
map_map : ā {β : Type ?u.663} {γ : Type ?u.664} {α : Type ?u.665} (g : β ā γ ) (f : α ā β ) (l : List α ),
map g (map f l ) = map (g ā f ) l map_map]
simp only [ Function.comp : {α : Sort ?u.717} ā {β : Sort ?u.716} ā {Ī“ : Sort ?u.715} ā (β ā Ī“ ) ā (α ā β ) ā α ā Ī“ Function.comp, Fin.val_succ ]
#align list.fin_range_succ_eq_map List.finRange_succ_eq_map
-- Porting note : `map_nth_le` moved to `List.finRange_map_get` in Data.List.Range
theorem ofFn_eq_pmap { α n } { f : Fin n ā α } :
ofFn f = pmap : {α : Type ?u.870} ā
{β : Type ?u.869} ā {p : α ā Prop } ā ((a : α ) ā p a ā β ) ā (l : List α ) ā (ā (a : α ), a ā l ā p a ) ā List β pmap ( fun i hi => f ⨠i , hi ā©) ( range n ) fun _ => mem_range . 1 : ā {a b : Prop }, (a ā b ) ā a ā b 1 := by
( rw [ pmap_eq_map_attach : ā {α : Type ?u.921} {β : Type ?u.920} {p : α ā Prop } (f : (a : α ) ā p a ā β ) (l : List α ) (H : ā (a : α ), a ā l ā p a ),
pmap f l H = map (fun x => f āx (_ : p āx ) ) (attach l ) pmap_eq_map_attach] ;
exact ext_get ( by simp ) fun i hi1 hi2 => by
get (ofFn f ) { val := i , isLt := hi1 } = get (map (fun x => f { val := āx , isLt := (_ : āx < n ) } ) (attach (range n ) ) ) { val := i , isLt := hi2 } simp [ get_ofFn f ⨠i , hi1 ā©] )
#align list.of_fn_eq_pmap List.ofFn_eq_pmap
theorem ofFn_id ( n ) : ofFn : {α : Type ?u.2316} ā {n : ā } ā (Fin n ā α ) ā List α ofFn id : {α : Sort ?u.2319} ā α ā α id = finRange n :=
ofFn_eq_pmap
#align list.of_fn_id List.ofFn_id
theorem ofFn_eq_map { α n } { f : Fin n ā α } : ofFn : {α : Type ?u.2428} ā {n : ā } ā (Fin n ā α ) ā List α ofFn f = ( finRange n ). map : {α : Type ?u.2436} ā {β : Type ?u.2435} ā (α ā β ) ā List α ā List β map f := by
rw [ ā ofFn_id , map_ofFn , Function.right_id : ā {α : Sort ?u.2487} {β : Sort ?u.2486} (f : α ā β ), f ā id = f Function.right_id]
#align list.of_fn_eq_map List.ofFn_eq_map
theorem nodup_ofFn_ofInjective { α n } { f : Fin n ā α } ( hf : Function.Injective : {α : Sort ?u.2534} ā {β : Sort ?u.2533} ā (α ā β ) ā Prop Function.Injective f ) :
Nodup ( ofFn : {α : Type ?u.2544} ā {n : ā } ā (Fin n ā α ) ā List α ofFn f ) := by
rw [ ofFn_eq_pmap ]
exact ( nodup_range n ). pmap : ā {α : Type ?u.2582} {β : Type ?u.2581} {p : α ā Prop } {f : (a : α ) ā p a ā β } {l : List α }
{H : ā (a : α ), a ā l ā p a },
(ā (a : α ) (ha : p a ) (b : α ) (hb : p b ), f a ha = f b hb ā a = b ) ā Nodup l ā Nodup (pmap f l H ) pmap fun _ _ _ _ H => Fin.veq_of_eq : ā {n : ā } {i j : Fin n }, i = j ā āi = āj Fin.veq_of_eq <| hf H
#align list.nodup_of_fn_of_injective List.nodup_ofFn_ofInjective
theorem nodup_ofFn { α n } { f : Fin n ā α } : Nodup ( ofFn : {α : Type ?u.2690} ā {n : ā } ā (Fin n ā α ) ā List α ofFn f ) ā Function.Injective : {α : Sort ?u.2700} ā {β : Sort ?u.2699} ā (α ā β ) ā Prop Function.Injective f := by
refine' ⨠_ , nodup_ofFn_ofInjective ā©
refine' Fin.consInduction : ā {α : Type ?u.2735} {P : {n : ā } ā (Fin n ā α ) ā Sort ?u.2736 },
P Fin.elim0 ā (ā {n : ā } (xā : α ) (x : Fin n ā α ), P x ā P (Fin.cons xā x ) ) ā ā {n : ā } (x : Fin n ā α ), P x Fin.consInduction _ ( fun xā xs ih => _ ) f
Ā· intro _
exact Function.injective_of_subsingleton _
Ā· intro h
rw [ Fin.cons_injective_iff ]
simp_rw [ ofFn_succ , Fin.cons_succ , nodup_cons , Fin.cons_zero , mem_ofFn ] at h
exact h . imp_right : ā {a b c : Prop }, (a ā b ) ā c ā§ a ā c ā§ b imp_right ih
#align list.nodup_of_fn List.nodup_ofFn
end List
open List
theorem Equiv.Perm.map_finRange_perm { n : ā } ( Ļ : Equiv.Perm : Sort ?u.3610 ā Sort (max1?u.3610) Equiv.Perm ( Fin n )) :
map : {α : Type ?u.3616} ā {β : Type ?u.3615} ā (α ā β ) ā List α ā List β map Ļ ( finRange n ) ~ finRange n := by
rw [ perm_ext (( nodup_finRange n ). map Ļ . injective ) <| nodup_finRange n ]
simpa [ mem_map , mem_finRange , true_and_iff , iff_true_iff ] using Ļ . surjective
#align equiv.perm.map_fin_range_perm Equiv.Perm.map_finRange_perm
/-- The list obtained from a permutation of a tuple `f` is permutation equivalent to
the list obtained from `f`. -/
theorem Equiv.Perm.ofFn_comp_perm { n : ā } { α : Type u } ( Ļ : Equiv.Perm : Sort ?u.8670 ā Sort (max1?u.8670) Equiv.Perm ( Fin n )) ( f : Fin n ā α ) :
ofFn : {α : Type ?u.8679} ā {n : ā } ā (Fin n ā α ) ā List α ofFn ( f ā Ļ ) ~ ofFn : {α : Type ?u.8781} ā {n : ā } ā (Fin n ā α ) ā List α ofFn f := by
rw [ ofFn_eq_map , ofFn_eq_map , ā map_map : ā {β : Type ?u.8825} {γ : Type ?u.8826} {α : Type ?u.8827} (g : β ā γ ) (f : α ā β ) (l : List α ),
map g (map f l ) = map (g ā f ) l map_map]
exact Ļ . map_finRange_perm . map : ā {α : Type ?u.8875} {β : Type ?u.8874} (f : α ā β ) {lā lā : List α }, lā ~ lā ā map f lā ~ map f lā map f
#align equiv.perm.of_fn_comp_perm Equiv.Perm.ofFn_comp_perm