Datasets:
AI4M
/

text
stringlengths
0
3.34M
/- Copyright (c) 2022 Kyle Miller. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kyle Miller -/ import data.finite.basic import data.set.finite /-! # Finite instances for `set` This module provides ways to go between `set.finite` and `finite` and also provides a number of `finite` instances for basic set constructions such as unions, intersections, and so on. ## Main definitions * `set.finite_of_finite` creates a `set.finite` proof from a `finite` instance * `set.finite.finite` creates a `finite` instance from a `set.finite` proof * `finite.set.subset` for finiteness of subsets of a finite set ## Tags finiteness, finite sets -/ open set open_locale classical universes u v w x variables {α : Type u} {β : Type v} {ι : Sort w} {γ : Type x} /-- Constructor for `set.finite` using a `finite` instance. -/ theorem set.finite_of_finite (s : set α) [finite s] : s.finite := ⟨fintype.of_finite s⟩ /-- Projection of `set.finite` to its `finite` instance. This is intended to be used with dot notation. See also `set.finite.fintype`. -/ @[nolint dup_namespace] protected lemma set.finite.finite {s : set α} (h : s.finite) : finite s := finite.of_fintype h.fintype lemma set.finite_iff_finite {s : set α} : s.finite ↔ finite s := ⟨λ h, h.finite, λ h, by exactI set.finite_of_finite s⟩ /-- Construct a `finite` instance for a `set` from a `finset` with the same elements. -/ protected lemma finite.of_finset {p : set α} (s : finset α) (H : ∀ x, x ∈ s ↔ x ∈ p) : finite p := finite.of_fintype (fintype.of_finset s H) /-! ### Finite instances There is seemingly some overlap between the following instances and the `fintype` instances in `data.set.finite`. While every `fintype` instance gives a `finite` instance, those instances that depend on `fintype` or `decidable` instances need an additional `finite` instance to be able to generally apply. Some set instances do not appear here since they are consequences of others, for example `subtype.finite` for subsets of a finite type. -/ namespace finite.set example {s : set α} [finite α] : finite s := infer_instance example : finite (∅ : set α) := infer_instance example (a : α) : finite ({a} : set α) := infer_instance instance finite_union (s t : set α) [finite s] [finite t] : finite (s ∪ t : set α) := by { haveI := fintype.of_finite s, haveI := fintype.of_finite t, apply_instance } instance finite_sep (s : set α) (p : α → Prop) [finite s] : finite ({a ∈ s | p a} : set α) := by { haveI := fintype.of_finite s, apply_instance } protected lemma subset (s : set α) {t : set α} [finite s] (h : t ⊆ s) : finite t := by { rw eq_sep_of_subset h, apply_instance } instance finite_inter_of_right (s t : set α) [finite t] : finite (s ∩ t : set α) := finite.set.subset t (inter_subset_right s t) instance finite_inter_of_left (s t : set α) [finite s] : finite (s ∩ t : set α) := finite.set.subset s (inter_subset_left s t) instance finite_diff (s t : set α) [finite s] : finite (s \ t : set α) := finite.set.subset s (diff_subset s t) instance finite_Union [finite ι] (f : ι → set α) [∀ i, finite (f i)] : finite (⋃ i, f i) := begin convert_to finite (⋃ (i : plift ι), f i.down), { congr, ext, simp }, haveI := fintype.of_finite (plift ι), haveI := λ i, fintype.of_finite (f i), apply_instance, end instance finite_sUnion {s : set (set α)} [finite s] [H : ∀ (t : s), finite (t : set α)] : finite (⋃₀ s) := by { rw sUnion_eq_Union, exact @finite.set.finite_Union _ _ _ _ H } lemma finite_bUnion {ι : Type*} (s : set ι) [finite s] (t : ι → set α) (H : ∀ i ∈ s, finite (t i)) : finite (⋃(x ∈ s), t x) := begin convert_to finite (⋃ (x : s), t x), { congr' 1, ext, simp }, haveI : ∀ (i : s), finite (t i) := λ i, H i i.property, apply_instance, end instance finite_bUnion' {ι : Type*} (s : set ι) [finite s] (t : ι → set α) [∀ i, finite (t i)] : finite (⋃(x ∈ s), t x) := finite_bUnion s t (λ i h, infer_instance) /-- Example: `finite (⋃ (i < n), f i)` where `f : ℕ → set α` and `[∀ i, finite (f i)]` (when given instances from `data.nat.interval`). -/ instance finite_bUnion'' {ι : Type*} (p : ι → Prop) [h : finite {x | p x}] (t : ι → set α) [∀ i, finite (t i)] : finite (⋃ x (h : p x), t x) := @finite.set.finite_bUnion' _ _ (set_of p) h t _ instance finite_Inter {ι : Sort*} [nonempty ι] (t : ι → set α) [∀ i, finite (t i)] : finite (⋂ i, t i) := finite.set.subset (t $ classical.arbitrary ι) (Inter_subset _ _) instance finite_insert (a : α) (s : set α) [finite s] : finite (insert a s : set α) := ((set.finite_of_finite s).insert a).finite instance finite_image (s : set α) (f : α → β) [finite s] : finite (f '' s) := ((set.finite_of_finite s).image f).finite instance finite_range (f : ι → α) [finite ι] : finite (range f) := by { haveI := fintype.of_finite (plift ι), apply_instance } instance finite_replacement [finite α] (f : α → β) : finite {(f x) | (x : α)} := finite.set.finite_range f instance finite_prod (s : set α) (t : set β) [finite s] [finite t] : finite (s ×ˢ t : set (α × β)) := by { haveI := fintype.of_finite s, haveI := fintype.of_finite t, apply_instance } instance finite_image2 (f : α → β → γ) (s : set α) (t : set β) [finite s] [finite t] : finite (image2 f s t : set γ) := by { rw ← image_prod, apply_instance } instance finite_seq (f : set (α → β)) (s : set α) [finite f] [finite s] : finite (f.seq s) := by { rw seq_def, apply_instance } end finite.set /-! ### Non-instances -/ lemma set.finite_univ_iff : finite (set.univ : set α) ↔ finite α := (equiv.set.univ α).finite_iff lemma finite.of_finite_univ [finite ↥(univ : set α)] : finite α := set.finite_univ_iff.mp ‹_› lemma finite.set.finite_of_finite_image (s : set α) {f : α → β} (h : s.inj_on f) [finite (f '' s)] : finite s := finite.of_equiv _ (equiv.of_bijective _ h.bij_on_image.bijective).symm
[STATEMENT] lemma exp_two_pi_i' [simp]: "exp (\<i> * (of_real pi * 2)) = 1" [PROOF STATE] proof (prove) goal (1 subgoal): 1. exp (\<i> * (complex_of_real pi * 2)) = 1 [PROOF STEP] by (metis exp_two_pi_i mult.commute)
opaque f : Nat → Nat @[simp] axiom fEq (x : Nat) (h : x ≠ 0) : f x = x example (x : Nat) (h : x ≠ 0) : f x = x + 0 := by simp (discharger := trace_state; exact (fun h' => h') h) example (x y : Nat) (h1 : x ≠ 0) (h2 : y ≠ 0) (h3 : x = y) : f x = f y + 0 := by simp (discharger := trace_state; assumption) assumption example (x y : Nat) (h1 : x ≠ 0) (h2 : y ≠ 0) (h3 : x = y) : f x = f y + 0 := by simp (discharger := assumption) assumption example (x y : Nat) (h1 : x ≠ 0) (h2 : y ≠ 0) (h3 : x = y) : f x = f y + 0 := by simp (disch := assumption) assumption example (x y : Nat) (h1 : x ≠ 0) (h2 : y ≠ 0) (h3 : x = y) : f x = f y + 0 := by conv => lhs; simp (disch := assumption) trace_state conv => rhs; simp (disch := assumption) trace_state assumption
! ############################################################################################################################### ! Begin MIT license text. ! _______________________________________________________________________________________________________ ! Copyright 2019 Dr William R Case, Jr (dbcase29@gmail,com) ! Permission is hereby granted, free of charge, to any person obtaining a copy of this software and ! associated documentation files (the "Software"), to deal in the Software without restriction, including ! without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ! copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to ! the following conditions: ! The above copyright notice and this permission notice shall be included in all copies or substantial ! portions of the Software and documentation. ! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ! OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ! FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ! AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ! LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ! THE SOFTWARE. ! _______________________________________________________________________________________________________ ! End MIT license text. MODULE GET_PCOMP_SECT_PROPS_Interface INTERFACE SUBROUTINE GET_PCOMP_SECT_PROPS ( PCOMP_TM, PCOMP_IB, PCOMP_TS ) USE PENTIUM_II_KIND, ONLY : LONG, DOUBLE USE SCONTR, ONLY : BLNK_SUB_NAM, MPCOMP_PLIES, MPCOMP0, MRPCOMP_PLIES, MRPCOMP0 USE IOUNT1, ONLY : F04, WRT_LOG USE MODEL_STUF, ONLY : EPROP, INTL_PID, NUM_PLIES, RPCOMP, TPLY USE PARAMS, ONLY : PCMPTSTM USE CONSTANTS_1, ONLY : ZERO, THIRD USE TIMDAT, ONLY : TSEC USE SUBR_BEGEND_LEVELS, ONLY : GET_PCOMP_SECT_PROPS_BEGEND IMPLICIT NONE INTEGER(LONG), PARAMETER :: SUBR_BEGEND = GET_PCOMP_SECT_PROPS_BEGEND REAL(DOUBLE), INTENT(OUT) :: PCOMP_TM ! Membrane thickness of PCOMP for equivalent PSHELL REAL(DOUBLE), INTENT(OUT) :: PCOMP_IB ! Bending MOI of PCOMP for equivalent PSHELL REAL(DOUBLE), INTENT(OUT) :: PCOMP_TS ! Transverse shear thickness of PCOMP for equivalent PSHELL END SUBROUTINE GET_PCOMP_SECT_PROPS END INTERFACE END MODULE GET_PCOMP_SECT_PROPS_Interface
lemma continuous_trivial_limit: "trivial_limit net \<Longrightarrow> continuous net f"
From stdpp Require Import prelude. From AML Require Import Signature. From AML.Syntax Require Import Pattern. Section sec_pattern_translation. Context `{sign1 : signature EVar SVar Sigma1 EVarSet SVarSet} `{EqDecision Sigma2} `{sign2 : !signature EVar SVar Sigma2 EVarSet SVarSet} (h : Sigma1 -> Sigma2) `{!SignatureMorphism sign1 sign2 h}. Fixpoint pattern_translation (p : Pattern (Sigma := Sigma1)) : Pattern (Sigma := Sigma2) := match p with | PEVar e => PEVar e | PSVar s => PSVar s | p1 →ₚ p2 => pattern_translation p1 →ₚ pattern_translation p2 | PEx e p => PEx e (pattern_translation p) | μₚ s p => μₚ s (pattern_translation p) | PApp p1 p2 => PApp (pattern_translation p1) (pattern_translation p2) | POp s => POp (h s) end. Definition pattern_set_translation `{FinSet (Pattern (Sigma := Sigma1)) PatternSet1} `{FinSet (Pattern (Sigma := Sigma2)) PatternSet2} (Γ : PatternSet1) : PatternSet2 := set_map pattern_translation Γ. End sec_pattern_translation.
State Before: num den : Int ⊢ num /. -den = -num /. den State After: no goals Tactic: rw [← neg_divInt_neg, Int.neg_neg]
module Streaming.IO import Streaming ||| A `Stream` of `getLine`s export stdinLn : HasIO m => Stream (Of String) m r stdinLn = unfold (\_ => getLine >>= \line => pure (Right (line :> ()))) () ||| `putStrLn` for each `String` in `Stream (Of String)` export stdoutLn : HasIO m => Stream (Of String) m r -> m r stdoutLn = mapM_ putStrLn
lemma closure_Un [simp]: "closure (S \<union> T) = closure S \<union> closure T"
#Load ggplot2 library(ggplot2) # Set the values of angle and points golden_angle <- 13*pi/180 #actual golden angle forumla is Golden Angle= pi * (3 - sqrt(5)) points <- 2000 #create the formula t <- (1:points) * golden_angle x <- sin(t) y <- cos(t) df <- data.frame(t, x, y) # create the flower ggplot(df, aes(x*t, y*t))+ geom_point(size= 80, alpha= 0.1, shape= 1, color= "indianred4")+ theme(legend.position= "none", panel.background = element_rect(fill= "white"), panel.grid= element_blank(), axis.ticks= element_blank(), axis.title= element_blank(), axis.text= element_blank())+ ggsave("Phyllotaxis.png", width= 4, height= 4, units= "in")
State Before: x y : ℝ S : Set ℝ h₁ : Set.Nonempty S h₂ : BddAbove S ⊢ IsLUB S (sSup S) State After: x y : ℝ S : Set ℝ h₁ : Set.Nonempty S h₂ : BddAbove S ⊢ IsLUB S (choose (_ : ∃ x, IsLUB S x)) Tactic: simp only [sSup_def, dif_pos (And.intro h₁ h₂)] State Before: x y : ℝ S : Set ℝ h₁ : Set.Nonempty S h₂ : BddAbove S ⊢ IsLUB S (choose (_ : ∃ x, IsLUB S x)) State After: no goals Tactic: apply Classical.choose_spec
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Alexander Bentkamp ! This file was ported from Lean 3 source module linear_algebra.basis ! leanprover-community/mathlib commit 2f4cdce0c2f2f3b8cd58f05d556d03b468e1eb2e ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathlib.Algebra.BigOperators.Finsupp import Mathlib.Algebra.BigOperators.Finprod import Mathlib.Data.Fintype.BigOperators import Mathlib.LinearAlgebra.Finsupp import Mathlib.LinearAlgebra.LinearIndependent import Mathlib.LinearAlgebra.LinearPMap import Mathlib.LinearAlgebra.Projection /-! # Bases This file defines bases in a module or vector space. It is inspired by Isabelle/HOL's linear algebra, and hence indirectly by HOL Light. ## Main definitions All definitions are given for families of vectors, i.e. `v : ι → M` where `M` is the module or vector space and `ι : Type*` is an arbitrary indexing type. * `Basis ι R M` is the type of `ι`-indexed `R`-bases for a module `M`, represented by a linear equiv `M ≃ₗ[R] ι →₀ R`. * the basis vectors of a basis `b : Basis ι R M` are available as `b i`, where `i : ι` * `Basis.repr` is the isomorphism sending `x : M` to its coordinates `Basis.repr x : ι →₀ R`. The converse, turning this isomorphism into a basis, is called `Basis.ofRepr`. * If `ι` is finite, there is a variant of `repr` called `Basis.equivFun b : M ≃ₗ[R] ι → R` (saving you from having to work with `Finsupp`). The converse, turning this isomorphism into a basis, is called `Basis.ofEquivFun`. * `Basis.constr hv f` constructs a linear map `M₁ →ₗ[R] M₂` given the values `f : ι → M₂` at the basis elements `⇑b : ι → M₁`. * `Basis.reindex` uses an equiv to map a basis to a different indexing set. * `Basis.map` uses a linear equiv to map a basis to a different module. ## Main statements * `Basis.mk`: a linear independent set of vectors spanning the whole module determines a basis * `Basis.ext` states that two linear maps are equal if they coincide on a basis. Similar results are available for linear equivs (if they coincide on the basis vectors), elements (if their coordinates coincide) and the functions `b.repr` and `⇑b`. * `Basis.ofVectorSpace` states that every vector space has a basis. ## Implementation notes We use families instead of sets because it allows us to say that two identical vectors are linearly dependent. For bases, this is useful as well because we can easily derive ordered bases by using an ordered index type `ι`. ## Tags basis, bases -/ noncomputable section universe u open Function Set Submodule open BigOperators -- Porting note: TODO: workaround for lean4#2074 -- attribute [-instance] Ring.toNonAssocRing variable {ι : Type _} {ι' : Type _} {R : Type _} {R₂ : Type _} {K : Type _} variable {M : Type _} {M' M'' : Type _} {V : Type u} {V' : Type _} section Module variable [Semiring R] variable [AddCommMonoid M] [Module R M] [AddCommMonoid M'] [Module R M'] section variable (ι R M) /-- A `Basis ι R M` for a module `M` is the type of `ι`-indexed `R`-bases of `M`. The basis vectors are available as `FunLike.coe (b : Basis ι R M) : ι → M`. To turn a linear independent family of vectors spanning `M` into a basis, use `Basis.mk`. They are internally represented as linear equivs `M ≃ₗ[R] (ι →₀ R)`, available as `Basis.repr`. -/ structure Basis where /-- `Basis.ofRepr` constructs a basis given an assignment of coordinates to each vector. -/ ofRepr :: /-- `repr` is the linear equivalence sending a vector `x` to its coordinates: the `c`s such that `x = ∑ i, c i`. -/ repr : M ≃ₗ[R] ι →₀ R #align basis Basis #align basis.repr Basis.repr #align basis.of_repr Basis.ofRepr end instance uniqueBasis [Subsingleton R] : Unique (Basis ι R M) := ⟨⟨⟨default⟩⟩, fun ⟨b⟩ => by rw [Subsingleton.elim b]⟩ #align unique_basis uniqueBasis namespace Basis instance : Inhabited (Basis ι R (ι →₀ R)) := ⟨.ofRepr (LinearEquiv.refl _ _)⟩ variable (b b₁ : Basis ι R M) (i : ι) (c : R) (x : M) section repr theorem repr_injective : Injective (repr : Basis ι R M → M ≃ₗ[R] ι →₀ R) := fun f g h => by cases f; cases g; congr #align basis.repr_injective Basis.repr_injective /-- `b i` is the `i`th basis vector. -/ instance funLike : FunLike (Basis ι R M) ι fun _ => M where coe b i := b.repr.symm (Finsupp.single i 1) coe_injective' f g h := repr_injective <| LinearEquiv.symm_bijective.injective <| by ext x rw [← Finsupp.sum_single x, map_finsupp_sum, map_finsupp_sum] congr with (i r) have := congr_fun h i dsimp at this rw [← mul_one r, ← Finsupp.smul_single', LinearEquiv.map_smul, LinearEquiv.map_smul, this] #align basis.fun_like Basis.funLike @[simp] theorem coe_ofRepr (e : M ≃ₗ[R] ι →₀ R) : ⇑(ofRepr e) = fun i => e.symm (Finsupp.single i 1) := rfl #align basis.coe_of_repr Basis.coe_ofRepr protected theorem injective [Nontrivial R] : Injective b := b.repr.symm.injective.comp fun _ _ => (Finsupp.single_left_inj (one_ne_zero : (1 : R) ≠ 0)).mp #align basis.injective Basis.injective theorem repr_symm_single_one : b.repr.symm (Finsupp.single i 1) = b i := rfl #align basis.repr_symm_single_one Basis.repr_symm_single_one theorem repr_symm_single : b.repr.symm (Finsupp.single i c) = c • b i := calc b.repr.symm (Finsupp.single i c) = b.repr.symm (c • Finsupp.single i (1 : R)) := by { rw [Finsupp.smul_single', mul_one] } _ = c • b i := by rw [LinearEquiv.map_smul, repr_symm_single_one] #align basis.repr_symm_single Basis.repr_symm_single @[simp] theorem repr_self : b.repr (b i) = Finsupp.single i 1 := LinearEquiv.apply_symm_apply _ _ #align basis.repr_self Basis.repr_self theorem repr_self_apply (j) [Decidable (i = j)] : b.repr (b i) j = if i = j then 1 else 0 := by rw [repr_self, Finsupp.single_apply] #align basis.repr_self_apply Basis.repr_self_apply @[simp] theorem repr_symm_apply (v) : b.repr.symm v = Finsupp.total ι M R b v := calc b.repr.symm v = b.repr.symm (v.sum Finsupp.single) := by simp _ = ∑ i in v.support, b.repr.symm (Finsupp.single i (v i)) := by rw [Finsupp.sum, LinearEquiv.map_sum] _ = Finsupp.total ι M R b v := by simp [repr_symm_single, Finsupp.total_apply, Finsupp.sum] #align basis.repr_symm_apply Basis.repr_symm_apply @[simp] theorem coe_repr_symm : ↑b.repr.symm = Finsupp.total ι M R b := LinearMap.ext fun v => b.repr_symm_apply v #align basis.coe_repr_symm Basis.coe_repr_symm @[simp] theorem repr_total (v) : b.repr (Finsupp.total _ _ _ b v) = v := by rw [← b.coe_repr_symm] exact b.repr.apply_symm_apply v #align basis.repr_total Basis.repr_total @[simp] theorem total_repr : Finsupp.total _ _ _ b (b.repr x) = x := by rw [← b.coe_repr_symm] exact b.repr.symm_apply_apply x #align basis.total_repr Basis.total_repr theorem repr_range : LinearMap.range (b.repr : M →ₗ[R] ι →₀ R) = Finsupp.supported R R univ := by rw [LinearEquiv.range, Finsupp.supported_univ] #align basis.repr_range Basis.repr_range theorem mem_span_repr_support {ι : Type _} (b : Basis ι R M) (m : M) : m ∈ span R (b '' (b.repr m).support) := (Finsupp.mem_span_image_iff_total _).2 ⟨b.repr m, by simp [Finsupp.mem_supported_support]⟩ #align basis.mem_span_repr_support Basis.mem_span_repr_support theorem repr_support_subset_of_mem_span {ι : Type _} (b : Basis ι R M) (s : Set ι) {m : M} (hm : m ∈ span R (b '' s)) : ↑(b.repr m).support ⊆ s := by rcases(Finsupp.mem_span_image_iff_total _).1 hm with ⟨l, hl, hlm⟩ rwa [← hlm, repr_total, ← Finsupp.mem_supported R l] #align basis.repr_support_subset_of_mem_span Basis.repr_support_subset_of_mem_span end repr section Coord /-- `b.coord i` is the linear function giving the `i`'th coordinate of a vector with respect to the basis `b`. `b.coord i` is an element of the dual space. In particular, for finite-dimensional spaces it is the `ι`th basis vector of the dual space. -/ @[simps!] def coord : M →ₗ[R] R := Finsupp.lapply i ∘ₗ ↑b.repr #align basis.coord Basis.coord theorem forall_coord_eq_zero_iff {x : M} : (∀ i, b.coord i x = 0) ↔ x = 0 := Iff.trans (by simp only [b.coord_apply, FunLike.ext_iff, Finsupp.zero_apply]) b.repr.map_eq_zero_iff #align basis.forall_coord_eq_zero_iff Basis.forall_coord_eq_zero_iff /-- The sum of the coordinates of an element `m : M` with respect to a basis. -/ noncomputable def sumCoords : M →ₗ[R] R := (Finsupp.lsum ℕ fun _ => LinearMap.id) ∘ₗ (b.repr : M →ₗ[R] ι →₀ R) #align basis.sum_coords Basis.sumCoords @[simp] theorem coe_sumCoords : (b.sumCoords : M → R) = fun m => (b.repr m).sum fun _ => id := rfl #align basis.coe_sum_coords Basis.coe_sumCoords theorem coe_sumCoords_eq_finsum : (b.sumCoords : M → R) = fun m => ∑ᶠ i, b.coord i m := by ext m simp only [Basis.sumCoords, Basis.coord, Finsupp.lapply_apply, LinearMap.id_coe, LinearEquiv.coe_coe, Function.comp_apply, Finsupp.coe_lsum, LinearMap.coe_comp, finsum_eq_sum _ (b.repr m).finite_support, Finsupp.sum, Finset.finite_toSet_toFinset, id.def, Finsupp.fun_support_eq] #align basis.coe_sum_coords_eq_finsum Basis.coe_sumCoords_eq_finsum @[simp high] theorem coe_sumCoords_of_fintype [Fintype ι] : (b.sumCoords : M → R) = ∑ i, b.coord i := by ext m -- Porting note: - `eq_self_iff_true` -- + `comp_apply` `LinearMap.coeFn_sum` simp only [sumCoords, Finsupp.sum_fintype, LinearMap.id_coe, LinearEquiv.coe_coe, coord_apply, id.def, Fintype.sum_apply, imp_true_iff, Finsupp.coe_lsum, LinearMap.coe_comp, comp_apply, LinearMap.coeFn_sum] #align basis.coe_sum_coords_of_fintype Basis.coe_sumCoords_of_fintype @[simp] theorem sumCoords_self_apply : b.sumCoords (b i) = 1 := by simp only [Basis.sumCoords, LinearMap.id_coe, LinearEquiv.coe_coe, id.def, Basis.repr_self, Function.comp_apply, Finsupp.coe_lsum, LinearMap.coe_comp, Finsupp.sum_single_index] #align basis.sum_coords_self_apply Basis.sumCoords_self_apply theorem dvd_coord_smul (i : ι) (m : M) (r : R) : r ∣ b.coord i (r • m) := ⟨b.coord i m, by simp⟩ #align basis.dvd_coord_smul Basis.dvd_coord_smul theorem coord_repr_symm (b : Basis ι R M) (i : ι) (f : ι →₀ R) : b.coord i (b.repr.symm f) = f i := by simp only [repr_symm_apply, coord_apply, repr_total] #align basis.coord_repr_symm Basis.coord_repr_symm end Coord section Ext variable {R₁ : Type _} [Semiring R₁] {σ : R →+* R₁} {σ' : R₁ →+* R} variable [RingHomInvPair σ σ'] [RingHomInvPair σ' σ] variable {M₁ : Type _} [AddCommMonoid M₁] [Module R₁ M₁] /-- Two linear maps are equal if they are equal on basis vectors. -/ theorem ext {f₁ f₂ : M →ₛₗ[σ] M₁} (h : ∀ i, f₁ (b i) = f₂ (b i)) : f₁ = f₂ := by ext x rw [← b.total_repr x, Finsupp.total_apply, Finsupp.sum] simp only [LinearMap.map_sum, LinearMap.map_smulₛₗ, h] #align basis.ext Basis.ext /-- Two linear equivs are equal if they are equal on basis vectors. -/ theorem ext' {f₁ f₂ : M ≃ₛₗ[σ] M₁} (h : ∀ i, f₁ (b i) = f₂ (b i)) : f₁ = f₂ := by ext x rw [← b.total_repr x, Finsupp.total_apply, Finsupp.sum] simp only [LinearEquiv.map_sum, LinearEquiv.map_smulₛₗ, h] #align basis.ext' Basis.ext' /-- Two elements are equal iff their coordinates are equal. -/ theorem ext_elem_iff {x y : M} : x = y ↔ ∀ i, b.repr x i = b.repr y i := by simp only [← FunLike.ext_iff, EmbeddingLike.apply_eq_iff_eq] #align basis.ext_elem_iff Basis.ext_elem_iff alias ext_elem_iff ↔ _ _root_.Basis.ext_elem #align basis.ext_elem Basis.ext_elem theorem repr_eq_iff {b : Basis ι R M} {f : M →ₗ[R] ι →₀ R} : ↑b.repr = f ↔ ∀ i, f (b i) = Finsupp.single i 1 := ⟨fun h i => h ▸ b.repr_self i, fun h => b.ext fun i => (b.repr_self i).trans (h i).symm⟩ #align basis.repr_eq_iff Basis.repr_eq_iff theorem repr_eq_iff' {b : Basis ι R M} {f : M ≃ₗ[R] ι →₀ R} : b.repr = f ↔ ∀ i, f (b i) = Finsupp.single i 1 := ⟨fun h i => h ▸ b.repr_self i, fun h => b.ext' fun i => (b.repr_self i).trans (h i).symm⟩ #align basis.repr_eq_iff' Basis.repr_eq_iff' theorem apply_eq_iff {b : Basis ι R M} {x : M} {i : ι} : b i = x ↔ b.repr x = Finsupp.single i 1 := ⟨fun h => h ▸ b.repr_self i, fun h => b.repr.injective ((b.repr_self i).trans h.symm)⟩ #align basis.apply_eq_iff Basis.apply_eq_iff /-- An unbundled version of `repr_eq_iff` -/ theorem repr_apply_eq (f : M → ι → R) (hadd : ∀ x y, f (x + y) = f x + f y) (hsmul : ∀ (c : R) (x : M), f (c • x) = c • f x) (f_eq : ∀ i, f (b i) = Finsupp.single i 1) (x : M) (i : ι) : b.repr x i = f x i := by let f_i : M →ₗ[R] R := { toFun := fun x => f x i -- Porting note: `dsimp only []` is required for beta reduction. map_add' := fun _ _ => by dsimp only []; rw [hadd, Pi.add_apply] map_smul' := fun _ _ => by simp [hsmul, Pi.smul_apply] } have : Finsupp.lapply i ∘ₗ ↑b.repr = f_i := by refine' b.ext fun j => _ show b.repr (b j) i = f (b j) i rw [b.repr_self, f_eq] calc b.repr x i = f_i x := by { rw [← this] rfl } _ = f x i := rfl #align basis.repr_apply_eq Basis.repr_apply_eq /-- Two bases are equal if they assign the same coordinates. -/ theorem eq_ofRepr_eq_repr {b₁ b₂ : Basis ι R M} (h : ∀ x i, b₁.repr x i = b₂.repr x i) : b₁ = b₂ := repr_injective <| by ext; apply h #align basis.eq_of_repr_eq_repr Basis.eq_ofRepr_eq_repr /-- Two bases are equal if their basis vectors are the same. -/ @[ext] theorem eq_of_apply_eq {b₁ b₂ : Basis ι R M} : (∀ i, b₁ i = b₂ i) → b₁ = b₂ := FunLike.ext _ _ #align basis.eq_of_apply_eq Basis.eq_of_apply_eq end Ext section Map variable (f : M ≃ₗ[R] M') /-- Apply the linear equivalence `f` to the basis vectors. -/ @[simps] protected def map : Basis ι R M' := ofRepr (f.symm.trans b.repr) #align basis.map Basis.map @[simp] theorem map_apply (i) : b.map f i = f (b i) := rfl #align basis.map_apply Basis.map_apply end Map section MapCoeffs variable {R' : Type _} [Semiring R'] [Module R' M] (f : R ≃+* R') (h : ∀ (c) (x : M), f c • x = c • x) attribute [local instance] SMul.comp.isScalarTower /-- If `R` and `R'` are isomorphic rings that act identically on a module `M`, then a basis for `M` as `R`-module is also a basis for `M` as `R'`-module. See also `Basis.algebraMapCoeffs` for the case where `f` is equal to `algebraMap`. -/ @[simps (config := { simpRhs := true })] def mapCoeffs : Basis ι R' M := by letI : Module R' R := Module.compHom R (↑f.symm : R' →+* R) haveI : IsScalarTower R' R M := { smul_assoc := fun x y z => by -- Porting note: `dsimp [(· • ·)]` is unavailable because -- `HSMul.hsmul` becomes `SMul.smul`. change (f.symm x * y) • z = x • (y • z) rw [mul_smul, ← h, f.apply_symm_apply] } exact ofRepr <| (b.repr.restrictScalars R').trans <| Finsupp.mapRange.linearEquiv (Module.compHom.toLinearEquiv f.symm).symm #align basis.map_coeffs Basis.mapCoeffs theorem mapCoeffs_apply (i : ι) : b.mapCoeffs f h i = b i := apply_eq_iff.mpr <| by -- Porting note: in Lean 3, these were automatically infered from the definition of -- `mapCoeffs`. letI : Module R' R := Module.compHom R (↑f.symm : R' →+* R) haveI : IsScalarTower R' R M := { smul_assoc := fun x y z => by -- Porting note: `dsimp [(· • ·)]` is unavailable because -- `HSMul.hsmul` becomes `SMul.smul`. change (f.symm x * y) • z = x • (y • z) rw [mul_smul, ← h, f.apply_symm_apply] } simp #align basis.map_coeffs_apply Basis.mapCoeffs_apply @[simp] theorem coe_mapCoeffs : (b.mapCoeffs f h : ι → M) = b := funext <| b.mapCoeffs_apply f h #align basis.coe_map_coeffs Basis.coe_mapCoeffs end MapCoeffs section Reindex variable (b' : Basis ι' R M') variable (e : ι ≃ ι') /-- `b.reindex (e : ι ≃ ι')` is a basis indexed by `ι'` -/ def reindex : Basis ι' R M := .ofRepr (b.repr.trans (Finsupp.domLCongr e)) #align basis.reindex Basis.reindex theorem reindex_apply (i' : ι') : b.reindex e i' = b (e.symm i') := show (b.repr.trans (Finsupp.domLCongr e)).symm (Finsupp.single i' 1) = b.repr.symm (Finsupp.single (e.symm i') 1) by rw [LinearEquiv.symm_trans_apply, Finsupp.domLCongr_symm, Finsupp.domLCongr_single] #align basis.reindex_apply Basis.reindex_apply @[simp] theorem coe_reindex : (b.reindex e : ι' → M) = b ∘ e.symm := funext (b.reindex_apply e) #align basis.coe_reindex Basis.coe_reindex theorem repr_reindex_apply (i' : ι') : (b.reindex e).repr x i' = b.repr x (e.symm i') := show (Finsupp.domLCongr e : _ ≃ₗ[R] _) (b.repr x) i' = _ by simp #align basis.repr_reindex_apply Basis.repr_reindex_apply @[simp] theorem repr_reindex : (b.reindex e).repr x = (b.repr x).mapDomain e := FunLike.ext _ _ <| by simp [repr_reindex_apply] #align basis.repr_reindex Basis.repr_reindex @[simp] theorem reindex_refl : b.reindex (Equiv.refl ι) = b := eq_of_apply_eq fun i => by simp #align basis.reindex_refl Basis.reindex_refl /-- `simp` can prove this as `Basis.coe_reindex` + `EquivLike.range_comp` -/ theorem range_reindex : Set.range (b.reindex e) = Set.range b := by simp [coe_reindex, range_comp] #align basis.range_reindex Basis.range_reindex @[simp] theorem sumCoords_reindex : (b.reindex e).sumCoords = b.sumCoords := by ext x simp only [coe_sumCoords, repr_reindex] exact Finsupp.sum_mapDomain_index (fun _ => rfl) fun _ _ _ => rfl #align basis.sum_coords_reindex Basis.sumCoords_reindex /-- `b.reindex_range` is a basis indexed by `range b`, the basis vectors themselves. -/ def reindexRange : Basis (range b) R M := haveI := Classical.dec (Nontrivial R) if h : Nontrivial R then letI := h b.reindex (Equiv.ofInjective b (Basis.injective b)) else letI : Subsingleton R := not_nontrivial_iff_subsingleton.mp h .ofRepr (Module.subsingletonEquiv R M (range b)) #align basis.reindex_range Basis.reindexRange theorem reindexRange_self (i : ι) (h := Set.mem_range_self i) : b.reindexRange ⟨b i, h⟩ = b i := by by_cases htr : Nontrivial R · letI := htr simp [htr, reindexRange, reindex_apply, Equiv.apply_ofInjective_symm b.injective, Subtype.coe_mk] · letI : Subsingleton R := not_nontrivial_iff_subsingleton.mp htr letI := Module.subsingleton R M simp [reindexRange] #align basis.reindex_range_self Basis.reindexRange_self theorem reindexRange_repr_self (i : ι) : b.reindexRange.repr (b i) = Finsupp.single ⟨b i, mem_range_self i⟩ 1 := calc b.reindexRange.repr (b i) = b.reindexRange.repr (b.reindexRange ⟨b i, mem_range_self i⟩) := congr_arg _ (b.reindexRange_self _ _).symm _ = Finsupp.single ⟨b i, mem_range_self i⟩ 1 := b.reindexRange.repr_self _ #align basis.reindex_range_repr_self Basis.reindexRange_repr_self @[simp] theorem reindexRange_apply (x : range b) : b.reindexRange x = x := by rcases x with ⟨bi, ⟨i, rfl⟩⟩ exact b.reindexRange_self i #align basis.reindex_range_apply Basis.reindexRange_apply theorem reindexRange_repr' (x : M) {bi : M} {i : ι} (h : b i = bi) : b.reindexRange.repr x ⟨bi, ⟨i, h⟩⟩ = b.repr x i := by nontriviality subst h apply (b.repr_apply_eq (fun x i => b.reindexRange.repr x ⟨b i, _⟩) _ _ _ x i).symm · intro x y ext i simp only [Pi.add_apply, LinearEquiv.map_add, Finsupp.coe_add] · intro c x ext i simp only [Pi.smul_apply, LinearEquiv.map_smul, Finsupp.coe_smul] · intro i ext j simp only [reindexRange_repr_self] apply Finsupp.single_apply_left (f := fun i => (⟨b i, _⟩ : Set.range b)) exact fun i j h => b.injective (Subtype.mk.inj h) #align basis.reindex_range_repr' Basis.reindexRange_repr' @[simp] theorem reindexRange_repr (x : M) (i : ι) (h := Set.mem_range_self i) : b.reindexRange.repr x ⟨b i, h⟩ = b.repr x i := b.reindexRange_repr' _ rfl #align basis.reindex_range_repr Basis.reindexRange_repr section Fintype variable [Fintype ι] [DecidableEq M] /-- `b.reindex_finset_range` is a basis indexed by `finset.univ.image b`, the finite set of basis vectors themselves. -/ def reindexFinsetRange : Basis (Finset.univ.image b) R M := b.reindexRange.reindex ((Equiv.refl M).subtypeEquiv (by simp)) #align basis.reindex_finset_range Basis.reindexFinsetRange theorem reindexFinsetRange_self (i : ι) (h := Finset.mem_image_of_mem b (Finset.mem_univ i)) : b.reindexFinsetRange ⟨b i, h⟩ = b i := by rw [reindexFinsetRange, reindex_apply, reindexRange_apply] rfl #align basis.reindex_finset_range_self Basis.reindexFinsetRange_self @[simp] theorem reindexFinsetRange_apply (x : Finset.univ.image b) : b.reindexFinsetRange x = x := by rcases x with ⟨bi, hbi⟩ rcases Finset.mem_image.mp hbi with ⟨i, -, rfl⟩ exact b.reindexFinsetRange_self i #align basis.reindex_finset_range_apply Basis.reindexFinsetRange_apply theorem reindexFinsetRange_repr_self (i : ι) : b.reindexFinsetRange.repr (b i) = Finsupp.single ⟨b i, Finset.mem_image_of_mem b (Finset.mem_univ i)⟩ 1 := by ext ⟨bi, hbi⟩ rw [reindexFinsetRange, repr_reindex, Finsupp.mapDomain_equiv_apply, reindexRange_repr_self] -- Porting note: replaced a `convert; refl` with `simp` simp [Finsupp.single_apply] #align basis.reindex_finset_range_repr_self Basis.reindexFinsetRange_repr_self @[simp] theorem reindexFinsetRange_repr (x : M) (i : ι) (h := Finset.mem_image_of_mem b (Finset.mem_univ i)) : b.reindexFinsetRange.repr x ⟨b i, h⟩ = b.repr x i := by simp [reindexFinsetRange] #align basis.reindex_finset_range_repr Basis.reindexFinsetRange_repr end Fintype end Reindex protected theorem linearIndependent : LinearIndependent R b := linearIndependent_iff.mpr fun l hl => calc l = b.repr (Finsupp.total _ _ _ b l) := (b.repr_total l).symm _ = 0 := by rw [hl, LinearEquiv.map_zero] #align basis.linear_independent Basis.linearIndependent protected theorem ne_zero [Nontrivial R] (i) : b i ≠ 0 := b.linearIndependent.ne_zero i #align basis.ne_zero Basis.ne_zero protected theorem mem_span (x : M) : x ∈ span R (range b) := by rw [← b.total_repr x, Finsupp.total_apply, Finsupp.sum] exact Submodule.sum_mem _ fun i _ => Submodule.smul_mem _ _ (Submodule.subset_span ⟨i, rfl⟩) #align basis.mem_span Basis.mem_span protected theorem span_eq : span R (range b) = ⊤ := eq_top_iff.mpr fun x _ => b.mem_span x #align basis.span_eq Basis.span_eq theorem index_nonempty (b : Basis ι R M) [Nontrivial M] : Nonempty ι := by obtain ⟨x, y, ne⟩ : ∃ x y : M, x ≠ y := Nontrivial.exists_pair_ne obtain ⟨i, _⟩ := not_forall.mp (mt b.ext_elem_iff.2 ne) exact ⟨i⟩ #align basis.index_nonempty Basis.index_nonempty /-- If the submodule `P` has a basis, `x ∈ P` iff it is a linear combination of basis vectors. -/ theorem mem_submodule_iff {P : Submodule R M} (b : Basis ι R P) {x : M} : x ∈ P ↔ ∃ c : ι →₀ R, x = Finsupp.sum c fun i x => x • (b i : M) := by conv_lhs => rw [← P.range_subtype, ← Submodule.map_top, ← b.span_eq, Submodule.map_span, ← Set.range_comp, ← Finsupp.range_total] simp [@eq_comm _ x, Function.comp, Finsupp.total_apply] #align basis.mem_submodule_iff Basis.mem_submodule_iff section Constr variable (S : Type _) [Semiring S] [Module S M'] variable [SMulCommClass R S M'] /-- Construct a linear map given the value at the basis. This definition is parameterized over an extra `Semiring S`, such that `SMulCommClass R S M'` holds. If `R` is commutative, you can set `S := R`; if `R` is not commutative, you can recover an `AddEquiv` by setting `S := ℕ`. See library note [bundled maps over different rings]. -/ def constr : (ι → M') ≃ₗ[S] M →ₗ[R] M' where toFun f := (Finsupp.total M' M' R id).comp <| Finsupp.lmapDomain R R f ∘ₗ ↑b.repr invFun f i := f (b i) left_inv f := by ext simp right_inv f := by refine' b.ext fun i => _ simp map_add' f g := by refine' b.ext fun i => _ simp map_smul' c f := by refine' b.ext fun i => _ simp #align basis.constr Basis.constr theorem constr_def (f : ι → M') : constr (M' := M') b S f = Finsupp.total M' M' R id ∘ₗ Finsupp.lmapDomain R R f ∘ₗ ↑b.repr := rfl #align basis.constr_def Basis.constr_def theorem constr_apply (f : ι → M') (x : M) : constr (M' := M') b S f x = (b.repr x).sum fun b a => a • f b := by simp only [constr_def, LinearMap.comp_apply, Finsupp.lmapDomain_apply, Finsupp.total_apply] rw [Finsupp.sum_mapDomain_index] <;> simp [add_smul] #align basis.constr_apply Basis.constr_apply @[simp] theorem constr_basis (f : ι → M') (i : ι) : (constr (M' := M') b S f : M → M') (b i) = f i := by simp [Basis.constr_apply, b.repr_self] #align basis.constr_basis Basis.constr_basis theorem constr_eq {g : ι → M'} {f : M →ₗ[R] M'} (h : ∀ i, g i = f (b i)) : constr (M' := M') b S g = f := b.ext fun i => (b.constr_basis S g i).trans (h i) #align basis.constr_eq Basis.constr_eq theorem constr_self (f : M →ₗ[R] M') : (constr (M' := M') b S fun i => f (b i)) = f := b.constr_eq S fun _ => rfl #align basis.constr_self Basis.constr_self theorem constr_range [Nonempty ι] {f : ι → M'} : LinearMap.range (constr (M' := M') b S f) = span R (range f) := by rw [b.constr_def S f, LinearMap.range_comp, LinearMap.range_comp, LinearEquiv.range, ← Finsupp.supported_univ, Finsupp.lmapDomain_supported, ← Set.image_univ, ← Finsupp.span_image_eq_map_total, Set.image_id] #align basis.constr_range Basis.constr_range @[simp] theorem constr_comp (f : M' →ₗ[R] M') (v : ι → M') : constr (M' := M') b S (f ∘ v) = f.comp (constr (M' := M') b S v) := b.ext fun i => by simp only [Basis.constr_basis, LinearMap.comp_apply, Function.comp] #align basis.constr_comp Basis.constr_comp end Constr section Equiv variable (b' : Basis ι' R M') (e : ι ≃ ι') variable [AddCommMonoid M''] [Module R M''] /-- If `b` is a basis for `M` and `b'` a basis for `M'`, and the index types are equivalent, `b.equiv b' e` is a linear equivalence `M ≃ₗ[R] M'`, mapping `b i` to `b' (e i)`. -/ protected def equiv : M ≃ₗ[R] M' := b.repr.trans (b'.reindex e.symm).repr.symm #align basis.equiv Basis.equiv @[simp] theorem equiv_apply : b.equiv b' e (b i) = b' (e i) := by simp [Basis.equiv] #align basis.equiv_apply Basis.equiv_apply @[simp] theorem equiv_refl : b.equiv b (Equiv.refl ι) = LinearEquiv.refl R M := b.ext' fun i => by simp #align basis.equiv_refl Basis.equiv_refl @[simp] theorem equiv_symm : (b.equiv b' e).symm = b'.equiv b e.symm := b'.ext' fun i => (b.equiv b' e).injective (by simp) #align basis.equiv_symm Basis.equiv_symm @[simp] theorem equiv_trans {ι'' : Type _} (b'' : Basis ι'' R M'') (e : ι ≃ ι') (e' : ι' ≃ ι'') : (b.equiv b' e).trans (b'.equiv b'' e') = b.equiv b'' (e.trans e') := b.ext' fun i => by simp #align basis.equiv_trans Basis.equiv_trans @[simp] theorem map_equiv (b : Basis ι R M) (b' : Basis ι' R M') (e : ι ≃ ι') : b.map (b.equiv b' e) = b'.reindex e.symm := by ext i simp #align basis.map_equiv Basis.map_equiv end Equiv section Prod variable (b' : Basis ι' R M') /-- `Basis.prod` maps a `ι`-indexed basis for `M` and a `ι'`-indexed basis for `M'` to a `ι ⊕ ι'`-index basis for `M × M'`. For the specific case of `R × R`, see also `Basis.finTwoProd`. -/ protected def prod : Basis (Sum ι ι') R (M × M') := ofRepr ((b.repr.prod b'.repr).trans (Finsupp.sumFinsuppLEquivProdFinsupp R).symm) #align basis.prod Basis.prod @[simp] theorem prod_repr_inl (x) (i) : (b.prod b').repr x (Sum.inl i) = b.repr x.1 i := rfl #align basis.prod_repr_inl Basis.prod_repr_inl @[simp] theorem prod_repr_inr (x) (i) : (b.prod b').repr x (Sum.inr i) = b'.repr x.2 i := rfl #align basis.prod_repr_inr Basis.prod_repr_inr theorem prod_apply_inl_fst (i) : (b.prod b' (Sum.inl i)).1 = b i := b.repr.injective <| by ext j simp only [Basis.prod, Basis.coe_ofRepr, LinearEquiv.symm_trans_apply, LinearEquiv.prod_symm, LinearEquiv.prod_apply, b.repr.apply_symm_apply, LinearEquiv.symm_symm, repr_self, Equiv.toFun_as_coe, Finsupp.fst_sumFinsuppLEquivProdFinsupp] apply Finsupp.single_apply_left Sum.inl_injective #align basis.prod_apply_inl_fst Basis.prod_apply_inl_fst theorem prod_apply_inr_fst (i) : (b.prod b' (Sum.inr i)).1 = 0 := b.repr.injective <| by ext i simp only [Basis.prod, Basis.coe_ofRepr, LinearEquiv.symm_trans_apply, LinearEquiv.prod_symm, LinearEquiv.prod_apply, b.repr.apply_symm_apply, LinearEquiv.symm_symm, repr_self, Equiv.toFun_as_coe, Finsupp.fst_sumFinsuppLEquivProdFinsupp, LinearEquiv.map_zero, Finsupp.zero_apply] apply Finsupp.single_eq_of_ne Sum.inr_ne_inl #align basis.prod_apply_inr_fst Basis.prod_apply_inr_fst theorem prod_apply_inl_snd (i) : (b.prod b' (Sum.inl i)).2 = 0 := b'.repr.injective <| by ext j simp only [Basis.prod, Basis.coe_ofRepr, LinearEquiv.symm_trans_apply, LinearEquiv.prod_symm, LinearEquiv.prod_apply, b'.repr.apply_symm_apply, LinearEquiv.symm_symm, repr_self, Equiv.toFun_as_coe, Finsupp.snd_sumFinsuppLEquivProdFinsupp, LinearEquiv.map_zero, Finsupp.zero_apply] apply Finsupp.single_eq_of_ne Sum.inl_ne_inr #align basis.prod_apply_inl_snd Basis.prod_apply_inl_snd theorem prod_apply_inr_snd (i) : (b.prod b' (Sum.inr i)).2 = b' i := b'.repr.injective <| by ext i simp only [Basis.prod, Basis.coe_ofRepr, LinearEquiv.symm_trans_apply, LinearEquiv.prod_symm, LinearEquiv.prod_apply, b'.repr.apply_symm_apply, LinearEquiv.symm_symm, repr_self, Equiv.toFun_as_coe, Finsupp.snd_sumFinsuppLEquivProdFinsupp] apply Finsupp.single_apply_left Sum.inr_injective #align basis.prod_apply_inr_snd Basis.prod_apply_inr_snd @[simp] theorem prod_apply (i) : b.prod b' i = Sum.elim (LinearMap.inl R M M' ∘ b) (LinearMap.inr R M M' ∘ b') i := by ext <;> cases i <;> simp only [prod_apply_inl_fst, Sum.elim_inl, LinearMap.inl_apply, prod_apply_inr_fst, Sum.elim_inr, LinearMap.inr_apply, prod_apply_inl_snd, prod_apply_inr_snd, Function.comp] #align basis.prod_apply Basis.prod_apply end Prod section NoZeroSMulDivisors -- Can't be an instance because the basis can't be inferred. protected theorem noZeroSMulDivisors [NoZeroDivisors R] (b : Basis ι R M) : NoZeroSMulDivisors R M := ⟨fun {c x} hcx => by exact or_iff_not_imp_right.mpr fun hx => by rw [← b.total_repr x, ← LinearMap.map_smul] at hcx have := linearIndependent_iff.mp b.linearIndependent (c • b.repr x) hcx rw [smul_eq_zero] at this exact this.resolve_right fun hr => hx (b.repr.map_eq_zero_iff.mp hr)⟩ #align basis.no_zero_smul_divisors Basis.noZeroSMulDivisors protected theorem smul_eq_zero [NoZeroDivisors R] (b : Basis ι R M) {c : R} {x : M} : c • x = 0 ↔ c = 0 ∨ x = 0 := @smul_eq_zero _ _ _ _ _ b.noZeroSMulDivisors _ _ #align basis.smul_eq_zero Basis.smul_eq_zero theorem eq_bot_of_rank_eq_zero [NoZeroDivisors R] (b : Basis ι R M) (N : Submodule R M) (rank_eq : ∀ {m : ℕ} (v : Fin m → N), LinearIndependent R ((↑) ∘ v : Fin m → M) → m = 0) : N = ⊥ := by rw [Submodule.eq_bot_iff] intro x hx contrapose! rank_eq with x_ne refine' ⟨1, fun _ => ⟨x, hx⟩, _, one_ne_zero⟩ rw [Fintype.linearIndependent_iff] rintro g sum_eq i cases' i with _ hi simp only [Function.const_apply, Fin.default_eq_zero, Submodule.coe_mk, Finset.univ_unique, Function.comp_const, Finset.sum_singleton] at sum_eq convert (b.smul_eq_zero.mp sum_eq).resolve_right x_ne #align eq_bot_of_rank_eq_zero Basis.eq_bot_of_rank_eq_zero end NoZeroSMulDivisors section Singleton /-- `Basis.singleton ι R` is the basis sending the unique element of `ι` to `1 : R`. -/ protected def singleton (ι R : Type _) [Unique ι] [Semiring R] : Basis ι R R := ofRepr { toFun := fun x => Finsupp.single default x invFun := fun f => f default left_inv := fun x => by simp right_inv := fun f => Finsupp.unique_ext (by simp) map_add' := fun x y => by simp map_smul' := fun c x => by simp } #align basis.singleton Basis.singleton @[simp] theorem singleton_apply (ι R : Type _) [Unique ι] [Semiring R] (i) : Basis.singleton ι R i = 1 := apply_eq_iff.mpr (by simp [Basis.singleton]) #align basis.singleton_apply Basis.singleton_apply @[simp] theorem singleton_repr (ι R : Type _) [Unique ι] [Semiring R] (x i) : (Basis.singleton ι R).repr x i = x := by simp [Basis.singleton, Unique.eq_default i] #align basis.singleton_repr Basis.singleton_repr theorem basis_singleton_iff {R M : Type _} [Ring R] [Nontrivial R] [AddCommGroup M] [Module R M] [NoZeroSMulDivisors R M] (ι : Type _) [Unique ι] : Nonempty (Basis ι R M) ↔ ∃ (x : _)(_ : x ≠ 0), ∀ y : M, ∃ r : R, r • x = y := by constructor · rintro ⟨b⟩ refine' ⟨b default, b.linearIndependent.ne_zero _, _⟩ simpa [span_singleton_eq_top_iff, Set.range_unique] using b.span_eq · rintro ⟨x, nz, w⟩ refine ⟨ofRepr <| LinearEquiv.symm { toFun := fun f => f default • x invFun := fun y => Finsupp.single default (w y).choose left_inv := fun f => Finsupp.unique_ext ?_ right_inv := fun y => ?_ map_add' := fun y z => ?_ map_smul' := fun c y => ?_ }⟩ · simp [Finsupp.add_apply, add_smul] · simp only [Finsupp.coe_smul, Pi.smul_apply, RingHom.id_apply] rw [← smul_assoc, smul_eq_mul] · refine' smul_left_injective _ nz _ simp only [Finsupp.single_eq_same] exact (w (f default • x)).choose_spec · simp only [Finsupp.single_eq_same] exact (w y).choose_spec #align basis.basis_singleton_iff Basis.basis_singleton_iff end Singleton section Empty variable (M) /-- If `M` is a subsingleton and `ι` is empty, this is the unique `ι`-indexed basis for `M`. -/ protected def empty [Subsingleton M] [IsEmpty ι] : Basis ι R M := ofRepr 0 #align basis.empty Basis.empty instance emptyUnique [Subsingleton M] [IsEmpty ι] : Unique (Basis ι R M) where default := Basis.empty M uniq := fun _ => congr_arg ofRepr <| Subsingleton.elim _ _ #align basis.empty_unique Basis.emptyUnique end Empty end Basis section Fintype open Basis open Fintype variable [Fintype ι] (b : Basis ι R M) /-- A module over `R` with a finite basis is linearly equivalent to functions from its basis to `R`. -/ def Basis.equivFun : M ≃ₗ[R] ι → R := LinearEquiv.trans b.repr ({ Finsupp.equivFunOnFinite with toFun := (↑) map_add' := Finsupp.coe_add map_smul' := Finsupp.coe_smul } : (ι →₀ R) ≃ₗ[R] ι → R) #align basis.equiv_fun Basis.equivFun /-- A module over a finite ring that admits a finite basis is finite. -/ def Module.fintypeOfFintype (b : Basis ι R M) [Fintype R] : Fintype M := haveI := Classical.decEq ι Fintype.ofEquiv _ b.equivFun.toEquiv.symm #align module.fintype_of_fintype Module.fintypeOfFintype theorem Module.card_fintype (b : Basis ι R M) [Fintype R] [Fintype M] : card M = card R ^ card ι := by classical calc card M = card (ι → R) := card_congr b.equivFun.toEquiv _ = card R ^ card ι := card_fun #align module.card_fintype Module.card_fintype /-- Given a basis `v` indexed by `ι`, the canonical linear equivalence between `ι → R` and `M` maps a function `x : ι → R` to the linear combination `∑_i x i • v i`. -/ @[simp] theorem Basis.equivFun_symm_apply (x : ι → R) : b.equivFun.symm x = ∑ i, x i • b i := by simp [Basis.equivFun, Finsupp.total_apply, Finsupp.sum_fintype, Finsupp.equivFunOnFinite] #align basis.equiv_fun_symm_apply Basis.equivFun_symm_apply @[simp] theorem Basis.equivFun_apply (u : M) : b.equivFun u = b.repr u := rfl #align basis.equiv_fun_apply Basis.equivFun_apply @[simp] theorem Basis.map_equivFun (f : M ≃ₗ[R] M') : (b.map f).equivFun = f.symm.trans b.equivFun := rfl #align basis.map_equiv_fun Basis.map_equivFun theorem Basis.sum_equivFun (u : M) : (∑ i, b.equivFun u i • b i) = u := by conv_rhs => rw [← b.total_repr u] simp [Finsupp.total_apply, Finsupp.sum_fintype, b.equivFun_apply] #align basis.sum_equiv_fun Basis.sum_equivFun theorem Basis.sum_repr (u : M) : (∑ i, b.repr u i • b i) = u := b.sum_equivFun u #align basis.sum_repr Basis.sum_repr @[simp] theorem Basis.equivFun_self [DecidableEq ι] (i j : ι) : b.equivFun (b i) j = if i = j then 1 else 0 := by rw [b.equivFun_apply, b.repr_self_apply] #align basis.equiv_fun_self Basis.equivFun_self theorem Basis.repr_sum_self (c : ι → R) : ⇑(b.repr (∑ i, c i • b i)) = c := by ext j simp only [map_sum, LinearEquiv.map_smul, repr_self, Finsupp.smul_single, smul_eq_mul, mul_one, Finset.sum_apply'] rw [Finset.sum_eq_single j, Finsupp.single_eq_same] · rintro i - hi exact Finsupp.single_eq_of_ne hi · intros have := Finset.mem_univ j contradiction #align basis.repr_sum_self Basis.repr_sum_self /-- Define a basis by mapping each vector `x : M` to its coordinates `e x : ι → R`, as long as `ι` is finite. -/ def Basis.ofEquivFun (e : M ≃ₗ[R] ι → R) : Basis ι R M := .ofRepr <| e.trans <| LinearEquiv.symm <| Finsupp.linearEquivFunOnFinite R R ι #align basis.of_equiv_fun Basis.ofEquivFun @[simp] theorem Basis.ofEquivFun_repr_apply (e : M ≃ₗ[R] ι → R) (x : M) (i : ι) : (Basis.ofEquivFun e).repr x i = e x i := rfl #align basis.of_equiv_fun_repr_apply Basis.ofEquivFun_repr_apply @[simp] theorem Basis.coe_ofEquivFun [DecidableEq ι] (e : M ≃ₗ[R] ι → R) : (Basis.ofEquivFun e : ι → M) = fun i => e.symm (Function.update 0 i 1) := funext fun i => e.injective <| funext fun j => by simp [Basis.ofEquivFun, ← Finsupp.single_eq_pi_single, Finsupp.single_eq_update] #align basis.coe_of_equiv_fun Basis.coe_ofEquivFun @[simp] theorem Basis.ofEquivFun_equivFun (v : Basis ι R M) : Basis.ofEquivFun v.equivFun = v := by classical ext j simp only [Basis.equivFun_symm_apply, Basis.coe_ofEquivFun] simp_rw [Function.update_apply, ite_smul] simp only [Finset.mem_univ, if_true, Pi.zero_apply, one_smul, Finset.sum_ite_eq', zero_smul] #align basis.of_equiv_fun_equiv_fun Basis.ofEquivFun_equivFun variable (S : Type _) [Semiring S] [Module S M'] variable [SMulCommClass R S M'] @[simp] theorem Basis.constr_apply_fintype (f : ι → M') (x : M) : (constr (M' := M') b S f : M → M') x = ∑ i, b.equivFun x i • f i := by simp [b.constr_apply, b.equivFun_apply, Finsupp.sum_fintype] #align basis.constr_apply_fintype Basis.constr_apply_fintype /-- If the submodule `P` has a finite basis, `x ∈ P` iff it is a linear combination of basis vectors. -/ theorem Basis.mem_submodule_iff' {P : Submodule R M} (b : Basis ι R P) {x : M} : x ∈ P ↔ ∃ c : ι → R, x = ∑ i, c i • b i := b.mem_submodule_iff.trans <| Finsupp.equivFunOnFinite.exists_congr_left.trans <| exists_congr fun c => by simp [Finsupp.sum_fintype, Finsupp.equivFunOnFinite] #align basis.mem_submodule_iff' Basis.mem_submodule_iff' theorem Basis.coord_equivFun_symm (i : ι) (f : ι → R) : b.coord i (b.equivFun.symm f) = f i := b.coord_repr_symm i (Finsupp.equivFunOnFinite.symm f) #align basis.coord_equiv_fun_symm Basis.coord_equivFun_symm end Fintype end Module section CommSemiring namespace Basis variable [CommSemiring R] variable [AddCommMonoid M] [Module R M] [AddCommMonoid M'] [Module R M'] variable (b : Basis ι R M) (b' : Basis ι' R M') /-- If `b` is a basis for `M` and `b'` a basis for `M'`, and `f`, `g` form a bijection between the basis vectors, `b.equiv' b' f g hf hg hgf hfg` is a linear equivalence `M ≃ₗ[R] M'`, mapping `b i` to `f (b i)`. -/ def equiv' (f : M → M') (g : M' → M) (hf : ∀ i, f (b i) ∈ range b') (hg : ∀ i, g (b' i) ∈ range b) (hgf : ∀ i, g (f (b i)) = b i) (hfg : ∀ i, f (g (b' i)) = b' i) : M ≃ₗ[R] M' := { constr (M' := M') b R (f ∘ b) with invFun := constr (M' := M) b' R (g ∘ b') left_inv := have : (constr (M' := M) b' R (g ∘ b')).comp (constr (M' := M') b R (f ∘ b)) = LinearMap.id := b.ext fun i => Exists.elim (hf i) fun i' hi' => by rw [LinearMap.comp_apply, b.constr_basis, Function.comp_apply, ← hi', b'.constr_basis, Function.comp_apply, hi', hgf, LinearMap.id_apply] fun x => congr_arg (fun h : M →ₗ[R] M => h x) this right_inv := have : (constr (M' := M') b R (f ∘ b)).comp (constr (M' := M) b' R (g ∘ b')) = LinearMap.id := b'.ext fun i => Exists.elim (hg i) fun i' hi' => by rw [LinearMap.comp_apply, b'.constr_basis, Function.comp_apply, ← hi', b.constr_basis, Function.comp_apply, hi', hfg, LinearMap.id_apply] fun x => congr_arg (fun h : M' →ₗ[R] M' => h x) this } #align basis.equiv' Basis.equiv' @[simp] theorem equiv'_apply (f : M → M') (g : M' → M) (hf hg hgf hfg) (i : ι) : b.equiv' b' f g hf hg hgf hfg (b i) = f (b i) := b.constr_basis R _ _ #align basis.equiv'_apply Basis.equiv'_apply @[simp] theorem equiv'_symm_apply (f : M → M') (g : M' → M) (hf hg hgf hfg) (i : ι') : (b.equiv' b' f g hf hg hgf hfg).symm (b' i) = g (b' i) := b'.constr_basis R _ _ #align basis.equiv'_symm_apply Basis.equiv'_symm_apply theorem sum_repr_mul_repr {ι'} [Fintype ι'] (b' : Basis ι' R M) (x : M) (i : ι) : (∑ j : ι', b.repr (b' j) i * b'.repr x j) = b.repr x i := by conv_rhs => rw [← b'.sum_repr x] simp_rw [LinearEquiv.map_sum, LinearEquiv.map_smul, Finset.sum_apply'] refine' Finset.sum_congr rfl fun j _ => _ rw [Finsupp.smul_apply, smul_eq_mul, mul_comm] #align basis.sum_repr_mul_repr Basis.sum_repr_mul_repr end Basis end CommSemiring section Module open LinearMap variable {v : ι → M} variable [Ring R] [CommRing R₂] [AddCommGroup M] [AddCommGroup M'] [AddCommGroup M''] variable [Module R M] [Module R₂ M] [Module R M'] [Module R M''] variable {c d : R} {x y : M} variable (b : Basis ι R M) namespace Basis /-- Any basis is a maximal linear independent set. -/ theorem maximal [Nontrivial R] (b : Basis ι R M) : b.linearIndependent.Maximal := fun w hi h => by -- If `range w` is strictly bigger than `range b`, apply le_antisymm h -- then choose some `x ∈ range w \ range b`, intro x p by_contra q -- and write it in terms of the basis. have e := b.total_repr x -- This then expresses `x` as a linear combination -- of elements of `w` which are in the range of `b`, let u : ι ↪ w := ⟨fun i => ⟨b i, h ⟨i, rfl⟩⟩, fun i i' r => b.injective (by simpa only [Subtype.mk_eq_mk] using r)⟩ simp_rw [Finsupp.total_apply] at e -- Porting note: `change at` doesn't work replace e : ((b.repr x).sum fun (i : ι) (a : R) ↦ a • (u i : M)) = ((⟨x, p⟩ : w) : M) := e rw [← Finsupp.sum_embDomain (f := u) (g := fun x r ↦ r • (x : M)), ← Finsupp.total_apply] at e -- Now we can contradict the linear independence of `hi` refine' hi.total_ne_of_not_mem_support _ _ e simp only [Finset.mem_map, Finsupp.support_embDomain] rintro ⟨j, -, W⟩ simp only [Embedding.coeFn_mk, Subtype.mk_eq_mk] at W apply q ⟨j, W⟩ #align basis.maximal Basis.maximal section Mk variable (hli : LinearIndependent R v) (hsp : ⊤ ≤ span R (range v)) /-- A linear independent family of vectors spanning the whole module is a basis. -/ protected noncomputable def mk : Basis ι R M := .ofRepr { hli.repr.comp (LinearMap.id.codRestrict _ fun _ => hsp Submodule.mem_top) with invFun := Finsupp.total _ _ _ v left_inv := fun x => hli.total_repr ⟨x, _⟩ right_inv := fun _ => hli.repr_eq rfl } #align basis.mk Basis.mk @[simp] theorem mk_repr : (Basis.mk hli hsp).repr x = hli.repr ⟨x, hsp Submodule.mem_top⟩ := rfl #align basis.mk_repr Basis.mk_repr theorem mk_apply (i : ι) : Basis.mk hli hsp i = v i := show Finsupp.total _ _ _ v _ = v i by simp #align basis.mk_apply Basis.mk_apply @[simp] theorem coe_mk : ⇑(Basis.mk hli hsp) = v := funext (mk_apply _ _) #align basis.coe_mk Basis.coe_mk variable {hli hsp} /-- Given a basis, the `i`th element of the dual basis evaluates to 1 on the `i`th element of the basis. -/ theorem mk_coord_apply_eq (i : ι) : (Basis.mk hli hsp).coord i (v i) = 1 := show hli.repr ⟨v i, Submodule.subset_span (mem_range_self i)⟩ i = 1 by simp [hli.repr_eq_single i] #align basis.mk_coord_apply_eq Basis.mk_coord_apply_eq /-- Given a basis, the `i`th element of the dual basis evaluates to 0 on the `j`th element of the basis if `j ≠ i`. -/ theorem mk_coord_apply_ne {i j : ι} (h : j ≠ i) : (Basis.mk hli hsp).coord i (v j) = 0 := show hli.repr ⟨v j, Submodule.subset_span (mem_range_self j)⟩ i = 0 by simp [hli.repr_eq_single j, h] #align basis.mk_coord_apply_ne Basis.mk_coord_apply_ne /-- Given a basis, the `i`th element of the dual basis evaluates to the Kronecker delta on the `j`th element of the basis. -/ theorem mk_coord_apply [DecidableEq ι] {i j : ι} : (Basis.mk hli hsp).coord i (v j) = if j = i then 1 else 0 := by cases' eq_or_ne j i with h h · simp only [h, if_true, eq_self_iff_true, mk_coord_apply_eq i] · simp only [h, if_false, mk_coord_apply_ne h] #align basis.mk_coord_apply Basis.mk_coord_apply end Mk section Span variable (hli : LinearIndependent R v) /-- A linear independent family of vectors is a basis for their span. -/ protected noncomputable def span : Basis ι R (span R (range v)) := Basis.mk (linearIndependent_span hli) <| by intro x _ have : ∀ i, v i ∈ span R (range v) := fun i ↦ subset_span (Set.mem_range_self _) have h₁ : (((↑) : span R (range v) → M) '' range fun i => ⟨v i, this i⟩) = range v := by simp only [SetLike.coe_sort_coe, ← Set.range_comp] rfl have h₂ : map (Submodule.subtype (span R (range v))) (span R (range fun i => ⟨v i, this i⟩)) = span R (range v) := by rw [← span_image, Submodule.coeSubtype] -- Porting note: why doesn't `rw [h₁]` work here? exact congr_arg _ h₁ have h₃ : (x : M) ∈ map (Submodule.subtype (span R (range v))) (span R (Set.range fun i => Subtype.mk (v i) _)) := by rw [h₂] apply Subtype.mem x rcases mem_map.1 h₃ with ⟨y, hy₁, hy₂⟩ have h_x_eq_y : x = y := by rw [Subtype.ext_iff, ← hy₂] simp rwa [h_x_eq_y] #align basis.span Basis.span protected theorem span_apply (i : ι) : (Basis.span hli i : M) = v i := congr_arg ((↑) : span R (range v) → M) <| Basis.mk_apply _ _ _ #align basis.span_apply Basis.span_apply end Span /-- Given a basis `v` and a map `w` such that for all `i`, `w i` are elements of a group, `group_smul` provides the basis corresponding to `w • v`. -/ def groupSmul {G : Type _} [Group G] [DistribMulAction G R] [DistribMulAction G M] [IsScalarTower G R M] [SMulCommClass G R M] (v : Basis ι R M) (w : ι → G) : Basis ι R M := Basis.mk (LinearIndependent.group_smul v.linearIndependent w) (groupSmul_span_eq_top v.span_eq).ge #align basis.group_smul Basis.groupSmul theorem groupSmul_apply {G : Type _} [Group G] [DistribMulAction G R] [DistribMulAction G M] [IsScalarTower G R M] [SMulCommClass G R M] {v : Basis ι R M} {w : ι → G} (i : ι) : v.groupSmul w i = (w • (v : ι → M)) i := mk_apply (LinearIndependent.group_smul v.linearIndependent w) (groupSmul_span_eq_top v.span_eq).ge i #align basis.group_smul_apply Basis.groupSmul_apply theorem units_smul_span_eq_top {v : ι → M} (hv : Submodule.span R (Set.range v) = ⊤) {w : ι → Rˣ} : Submodule.span R (Set.range (w • v)) = ⊤ := groupSmul_span_eq_top hv #align basis.units_smul_span_eq_top Basis.units_smul_span_eq_top /-- Given a basis `v` and a map `w` such that for all `i`, `w i` is a unit, `smul_of_is_unit` provides the basis corresponding to `w • v`. -/ def unitsSmul (v : Basis ι R M) (w : ι → Rˣ) : Basis ι R M := Basis.mk (LinearIndependent.units_smul v.linearIndependent w) (units_smul_span_eq_top v.span_eq).ge #align basis.units_smul Basis.unitsSmul theorem unitsSmul_apply {v : Basis ι R M} {w : ι → Rˣ} (i : ι) : unitsSmul v w i = w i • v i := mk_apply (LinearIndependent.units_smul v.linearIndependent w) (units_smul_span_eq_top v.span_eq).ge i #align basis.units_smul_apply Basis.unitsSmul_apply @[simp] theorem coord_unitsSmul (e : Basis ι R₂ M) (w : ι → R₂ˣ) (i : ι) : (unitsSmul e w).coord i = (w i)⁻¹ • e.coord i := by classical apply e.ext intro j trans ((unitsSmul e w).coord i) ((w j)⁻¹ • (unitsSmul e w) j) · congr simp [Basis.unitsSmul, ← mul_smul] simp only [Basis.coord_apply, LinearMap.smul_apply, Basis.repr_self, Units.smul_def, SMulHomClass.map_smul, Finsupp.single_apply] split_ifs with h · simp [h] · simp #align basis.coord_units_smul Basis.coord_unitsSmul -- Porting note: TODO: workaround for lean4#2074 attribute [-instance] Ring.toNonAssocRing in @[simp] theorem repr_unitsSmul (e : Basis ι R₂ M) (w : ι → R₂ˣ) (v : M) (i : ι) : (e.unitsSmul w).repr v i = (w i)⁻¹ • e.repr v i := congr_arg (fun f : M →ₗ[R₂] R₂ => f v) (e.coord_unitsSmul w i) #align basis.repr_units_smul Basis.repr_unitsSmul /-- A version of `smul_of_units` that uses `IsUnit`. -/ def isUnitSmul (v : Basis ι R M) {w : ι → R} (hw : ∀ i, IsUnit (w i)) : Basis ι R M := unitsSmul v fun i => (hw i).unit #align basis.is_unit_smul Basis.isUnitSmul theorem isUnitSmul_apply {v : Basis ι R M} {w : ι → R} (hw : ∀ i, IsUnit (w i)) (i : ι) : v.isUnitSmul hw i = w i • v i := unitsSmul_apply i #align basis.is_unit_smul_apply Basis.isUnitSmul_apply section Fin /-- Let `b` be a basis for a submodule `N` of `M`. If `y : M` is linear independent of `N` and `y` and `N` together span the whole of `M`, then there is a basis for `M` whose basis vectors are given by `Fin.cons y b`. -/ noncomputable def mkFinCons {n : ℕ} {N : Submodule R M} (y : M) (b : Basis (Fin n) R N) (hli : ∀ (c : R), ∀ x ∈ N, c • y + x = 0 → c = 0) (hsp : ∀ z : M, ∃ c : R, z + c • y ∈ N) : Basis (Fin (n + 1)) R M := have span_b : Submodule.span R (Set.range (N.subtype ∘ b)) = N := by rw [Set.range_comp, Submodule.span_image, b.span_eq, Submodule.map_subtype_top] Basis.mk (v := Fin.cons y (N.subtype ∘ b)) ((b.linearIndependent.map' N.subtype (Submodule.ker_subtype _)).fin_cons' _ _ (by rintro c ⟨x, hx⟩ hc rw [span_b] at hx exact hli c x hx hc)) fun x _ => by rw [Fin.range_cons, Submodule.mem_span_insert', span_b] exact hsp x #align basis.mk_fin_cons Basis.mkFinCons @[simp] theorem coe_mkFinCons {n : ℕ} {N : Submodule R M} (y : M) (b : Basis (Fin n) R N) (hli : ∀ (c : R), ∀ x ∈ N, c • y + x = 0 → c = 0) (hsp : ∀ z : M, ∃ c : R, z + c • y ∈ N) : (mkFinCons y b hli hsp : Fin (n + 1) → M) = Fin.cons y ((↑) ∘ b) := by -- porting note: without `unfold`, Lean can't reuse the proofs included in the definition -- `mkFinCons` unfold mkFinCons exact coe_mk (v := Fin.cons y (N.subtype ∘ b)) _ _ #align basis.coe_mk_fin_cons Basis.coe_mkFinCons /-- Let `b` be a basis for a submodule `N ≤ O`. If `y ∈ O` is linear independent of `N` and `y` and `N` together span the whole of `O`, then there is a basis for `O` whose basis vectors are given by `Fin.cons y b`. -/ noncomputable def mkFinConsOfLe {n : ℕ} {N O : Submodule R M} (y : M) (yO : y ∈ O) (b : Basis (Fin n) R N) (hNO : N ≤ O) (hli : ∀ (c : R), ∀ x ∈ N, c • y + x = 0 → c = 0) (hsp : ∀ z ∈ O, ∃ c : R, z + c • y ∈ N) : Basis (Fin (n + 1)) R O := mkFinCons ⟨y, yO⟩ (b.map (Submodule.comapSubtypeEquivOfLe hNO).symm) (fun c x hc hx => hli c x (Submodule.mem_comap.mp hc) (congr_arg ((↑) : O → M) hx)) fun z => hsp z z.2 #align basis.mk_fin_cons_of_le Basis.mkFinConsOfLe @[simp] theorem coe_mkFinConsOfLe {n : ℕ} {N O : Submodule R M} (y : M) (yO : y ∈ O) (b : Basis (Fin n) R N) (hNO : N ≤ O) (hli : ∀ (c : R), ∀ x ∈ N, c • y + x = 0 → c = 0) (hsp : ∀ z ∈ O, ∃ c : R, z + c • y ∈ N) : (mkFinConsOfLe y yO b hNO hli hsp : Fin (n + 1) → O) = Fin.cons ⟨y, yO⟩ (Submodule.ofLe hNO ∘ b) := coe_mkFinCons _ _ _ _ #align basis.coe_mk_fin_cons_of_le Basis.coe_mkFinConsOfLe /-- The basis of `R × R` given by the two vectors `(1, 0)` and `(0, 1)`. -/ protected def finTwoProd (R : Type _) [Semiring R] : Basis (Fin 2) R (R × R) := Basis.ofEquivFun (LinearEquiv.finTwoArrow R R).symm #align basis.fin_two_prod Basis.finTwoProd @[simp] theorem finTwoProd_zero (R : Type _) [Semiring R] : Basis.finTwoProd R 0 = (1, 0) := by simp [Basis.finTwoProd, LinearEquiv.finTwoArrow] #align basis.fin_two_prod_zero Basis.finTwoProd_zero @[simp] theorem finTwoProd_one (R : Type _) [Semiring R] : Basis.finTwoProd R 1 = (0, 1) := by simp [Basis.finTwoProd, LinearEquiv.finTwoArrow] #align basis.fin_two_prod_one Basis.finTwoProd_one @[simp] theorem coe_finTwoProd_repr {R : Type _} [Semiring R] (x : R × R) : ⇑((Basis.finTwoProd R).repr x) = ![x.fst, x.snd] := rfl #align basis.coe_fin_two_prod_repr Basis.coe_finTwoProd_repr end Fin end Basis end Module section Induction variable [Ring R] [IsDomain R] variable [AddCommGroup M] [Module R M] {b : ι → M} /-- If `N` is a submodule with finite rank, do induction on adjoining a linear independent element to a submodule. -/ def Submodule.inductionOnRankAux (b : Basis ι R M) (P : Submodule R M → Sort _) (ih : ∀ N : Submodule R M, (∀ N' ≤ N, ∀ x ∈ N, (∀ (c : R), ∀ y ∈ N', c • x + y = (0 : M) → c = 0) → P N') → P N) (n : ℕ) (N : Submodule R M) (rank_le : ∀ {m : ℕ} (v : Fin m → N), LinearIndependent R ((↑) ∘ v : Fin m → M) → m ≤ n) : P N := by haveI : DecidableEq M := Classical.decEq M have Pbot : P ⊥ := by apply ih intro N _ x x_mem x_ortho exfalso rw [mem_bot] at x_mem simpa [x_mem] using x_ortho 1 0 N.zero_mem induction' n with n rank_ih generalizing N · suffices N = ⊥ by rwa [this] apply Basis.eq_bot_of_rank_eq_zero b _ fun m hv => le_zero_iff.mp (rank_le _ hv) apply ih intro N' N'_le x x_mem x_ortho apply rank_ih intro m v hli refine' Nat.succ_le_succ_iff.mp (rank_le (Fin.cons ⟨x, x_mem⟩ fun i => ⟨v i, N'_le (v i).2⟩) _) convert hli.fin_cons' x _ ?_ · ext i refine' Fin.cases _ _ i <;> simp · intro c y hcy refine' x_ortho c y (Submodule.span_le.mpr _ y.2) hcy rintro _ ⟨z, rfl⟩ exact (v z).2 #align submodule.induction_on_rank_aux Submodule.inductionOnRankAux end Induction section DivisionRing variable [DivisionRing K] [AddCommGroup V] [AddCommGroup V'] [Module K V] [Module K V'] variable {v : ι → V} {s t : Set V} {x y z : V} open Submodule namespace Basis section ExistsBasis /-- If `s` is a linear independent set of vectors, we can extend it to a basis. -/ noncomputable def extend (hs : LinearIndependent K ((↑) : s → V)) : Basis (hs.extend (subset_univ s)) K V := Basis.mk (@LinearIndependent.restrict_of_comp_subtype _ _ _ id _ _ _ _ (hs.linearIndependent_extend _)) (SetLike.coe_subset_coe.mp <| by simpa using hs.subset_span_extend (subset_univ s)) #align basis.extend Basis.extend theorem extend_apply_self (hs : LinearIndependent K ((↑) : s → V)) (x : hs.extend _) : Basis.extend hs x = x := Basis.mk_apply _ _ _ #align basis.extend_apply_self Basis.extend_apply_self @[simp] theorem coe_extend (hs : LinearIndependent K ((↑) : s → V)) : ⇑(Basis.extend hs) = ((↑) : _ → _) := funext (extend_apply_self hs) #align basis.coe_extend Basis.coe_extend theorem range_extend (hs : LinearIndependent K ((↑) : s → V)) : range (Basis.extend hs) = hs.extend (subset_univ _) := by rw [coe_extend, Subtype.range_coe_subtype, setOf_mem_eq] #align basis.range_extend Basis.range_extend -- Porting note: adding this to make the statement of `subExtend` more readable /-- Auxiliary definition: the index for the new basis vectors in `Basis.sumExtend`. The specific value of this definition should be considered an implementation detail. -/ def sumExtendIndex (hs : LinearIndependent K v) : Set V := LinearIndependent.extend hs.to_subtype_range (subset_univ _) \ range v /-- If `v` is a linear independent family of vectors, extend it to a basis indexed by a sum type. -/ noncomputable def sumExtend (hs : LinearIndependent K v) : Basis (ι ⊕ sumExtendIndex hs) K V := let s := Set.range v let e : ι ≃ s := Equiv.ofInjective v hs.injective let b := hs.to_subtype_range.extend (subset_univ (Set.range v)) (Basis.extend hs.to_subtype_range).reindex <| Equiv.symm <| calc Sum ι (b \ s : Set V) ≃ Sum s (b \ s : Set V) := Equiv.sumCongr e (Equiv.refl _) _ ≃ b := haveI := Classical.decPred (· ∈ s) Equiv.Set.sumDiffSubset (hs.to_subtype_range.subset_extend _) #align basis.sum_extend Basis.sumExtend theorem subset_extend {s : Set V} (hs : LinearIndependent K ((↑) : s → V)) : s ⊆ hs.extend (Set.subset_univ _) := hs.subset_extend _ #align basis.subset_extend Basis.subset_extend section variable (K V) /-- A set used to index `Basis.ofVectorSpace`. -/ noncomputable def ofVectorSpaceIndex : Set V := (linearIndependent_empty K V).extend (subset_univ _) #align basis.of_vector_space_index Basis.ofVectorSpaceIndex /-- Each vector space has a basis. -/ noncomputable def ofVectorSpace : Basis (ofVectorSpaceIndex K V) K V := Basis.extend (linearIndependent_empty K V) #align basis.of_vector_space Basis.ofVectorSpace theorem ofVectorSpace_apply_self (x : ofVectorSpaceIndex K V) : ofVectorSpace K V x = x := by unfold ofVectorSpace exact Basis.mk_apply _ _ _ #align basis.of_vector_space_apply_self Basis.ofVectorSpace_apply_self @[simp] theorem coe_ofVectorSpace : ⇑(ofVectorSpace K V) = ((↑) : _ → _ ) := funext fun x => ofVectorSpace_apply_self K V x #align basis.coe_of_vector_space Basis.coe_ofVectorSpace theorem ofVectorSpaceIndex.linearIndependent : LinearIndependent K ((↑) : ofVectorSpaceIndex K V → V) := by convert (ofVectorSpace K V).linearIndependent ext x rw [ofVectorSpace_apply_self] #align basis.of_vector_space_index.linear_independent Basis.ofVectorSpaceIndex.linearIndependent theorem range_ofVectorSpace : range (ofVectorSpace K V) = ofVectorSpaceIndex K V := range_extend _ #align basis.range_of_vector_space Basis.range_ofVectorSpace theorem exists_basis : ∃ s : Set V, Nonempty (Basis s K V) := ⟨ofVectorSpaceIndex K V, ⟨ofVectorSpace K V⟩⟩ #align basis.exists_basis Basis.exists_basis end end ExistsBasis end Basis open Fintype variable (K V) theorem VectorSpace.card_fintype [Fintype K] [Fintype V] : ∃ n : ℕ, card V = card K ^ n := by classical exact ⟨card (Basis.ofVectorSpaceIndex K V), Module.card_fintype (Basis.ofVectorSpace K V)⟩ #align vector_space.card_fintype VectorSpace.card_fintype section AtomsOfSubmoduleLattice variable {K V} /-- For a module over a division ring, the span of a nonzero element is an atom of the lattice of submodules. -/ theorem nonzero_span_atom (v : V) (hv : v ≠ 0) : IsAtom (span K {v} : Submodule K V) := by constructor · rw [Submodule.ne_bot_iff] exact ⟨v, ⟨mem_span_singleton_self v, hv⟩⟩ · intro T hT by_contra h apply hT.2 change span K {v} ≤ T simp_rw [span_singleton_le_iff_mem, ← Ne.def, Submodule.ne_bot_iff] at * rcases h with ⟨s, ⟨hs, hz⟩⟩ rcases mem_span_singleton.1 (hT.1 hs) with ⟨a, rfl⟩ rcases eq_or_ne a 0 with rfl | h · simp only [zero_smul, ne_eq, not_true] at hz · rwa [T.smul_mem_iff h] at hs #align nonzero_span_atom nonzero_span_atom /-- The atoms of the lattice of submodules of a module over a division ring are the submodules equal to the span of a nonzero element of the module. -/ theorem atom_iff_nonzero_span (W : Submodule K V) : IsAtom W ↔ ∃ (v : V) (_ : v ≠ 0), W = span K {v} := by refine' ⟨fun h => _, fun h => _⟩ · cases' h with hbot h rcases(Submodule.ne_bot_iff W).1 hbot with ⟨v, ⟨hW, hv⟩⟩ refine' ⟨v, ⟨hv, _⟩⟩ by_contra heq specialize h (span K {v}) rw [span_singleton_eq_bot, lt_iff_le_and_ne] at h exact hv (h ⟨(span_singleton_le_iff_mem v W).2 hW, Ne.symm heq⟩) · rcases h with ⟨v, ⟨hv, rfl⟩⟩ exact nonzero_span_atom v hv #align atom_iff_nonzero_span atom_iff_nonzero_span /-- The lattice of submodules of a module over a division ring is atomistic. -/ instance : IsAtomistic (Submodule K V) where eq_supₛ_atoms W := by refine ⟨_, submodule_eq_supₛ_le_nonzero_spans W, ?_⟩ rintro _ ⟨w, ⟨_, ⟨hw, rfl⟩⟩⟩ exact nonzero_span_atom w hw end AtomsOfSubmoduleLattice -- Porting note: TODO: workaround for lean4#2074 attribute [-instance] Ring.toNonAssocRing variable {K V} theorem LinearMap.exists_leftInverse_of_injective (f : V →ₗ[K] V') (hf_inj : LinearMap.ker f = ⊥) : ∃ g : V' →ₗ[K] V, g.comp f = LinearMap.id := by let B := Basis.ofVectorSpaceIndex K V let hB := Basis.ofVectorSpace K V have hB₀ : _ := hB.linearIndependent.to_subtype_range have : LinearIndependent K (fun x => x : f '' B → V') := by have h₁ : LinearIndependent K ((↑) : ↥(f '' Set.range (Basis.ofVectorSpace K V)) → V') := @LinearIndependent.image_subtype _ _ _ _ _ _ _ _ _ f hB₀ (show Disjoint _ _ by simp [hf_inj]) rwa [Basis.range_ofVectorSpace K V] at h₁ let C := this.extend (subset_univ _) have BC := this.subset_extend (subset_univ _) let hC := Basis.extend this haveI Vinh : Inhabited V := ⟨0⟩ refine' ⟨(hC.constr ℕ : _ → _) (C.restrict (invFun f)), hB.ext fun b => _⟩ rw [image_subset_iff] at BC have fb_eq : f b = hC ⟨f b, BC b.2⟩ := by change f b = Basis.extend this _ simp_rw [Basis.extend_apply_self] dsimp [] rw [Basis.ofVectorSpace_apply_self, fb_eq, hC.constr_basis] exact leftInverse_invFun (LinearMap.ker_eq_bot.1 hf_inj) _ #align linear_map.exists_left_inverse_of_injective LinearMap.exists_leftInverse_of_injective theorem Submodule.exists_isCompl (p : Submodule K V) : ∃ q : Submodule K V, IsCompl p q := let ⟨f, hf⟩ := p.subtype.exists_leftInverse_of_injective p.ker_subtype ⟨LinearMap.ker f, LinearMap.isCompl_of_proj <| LinearMap.ext_iff.1 hf⟩ #align submodule.exists_is_compl Submodule.exists_isCompl instance Module.Submodule.complementedLattice : ComplementedLattice (Submodule K V) := ⟨Submodule.exists_isCompl⟩ #align module.submodule.complemented_lattice Module.Submodule.complementedLattice theorem LinearMap.exists_rightInverse_of_surjective (f : V →ₗ[K] V') (hf_surj : range f = ⊤) : ∃ g : V' →ₗ[K] V, f.comp g = LinearMap.id := by let C := Basis.ofVectorSpaceIndex K V' let hC := Basis.ofVectorSpace K V' haveI : Inhabited V := ⟨0⟩ refine' ⟨(hC.constr ℕ : _ → _) (C.restrict (invFun f)), hC.ext fun c => _⟩ rw [LinearMap.comp_apply, hC.constr_basis] simp [rightInverse_invFun (LinearMap.range_eq_top.1 hf_surj) c] #align linear_map.exists_right_inverse_of_surjective LinearMap.exists_rightInverse_of_surjective /-- Any linear map `f : p →ₗ[K] V'` defined on a subspace `p` can be extended to the whole space. -/ theorem LinearMap.exists_extend {p : Submodule K V} (f : p →ₗ[K] V') : ∃ g : V →ₗ[K] V', g.comp p.subtype = f := let ⟨g, hg⟩ := p.subtype.exists_leftInverse_of_injective p.ker_subtype ⟨f.comp g, by rw [LinearMap.comp_assoc, hg, f.comp_id]⟩ #align linear_map.exists_extend LinearMap.exists_extend open Submodule LinearMap /-- If `p < ⊤` is a subspace of a vector space `V`, then there exists a nonzero linear map `f : V →ₗ[K] K` such that `p ≤ ker f`. -/ theorem Submodule.exists_le_ker_of_lt_top (p : Submodule K V) (hp : p < ⊤) : ∃ (f : V →ₗ[K] K), f ≠ 0 ∧ p ≤ ker f := by rcases SetLike.exists_of_lt hp with ⟨v, -, hpv⟩; clear hp rcases(LinearPMap.supSpanSingleton ⟨p, 0⟩ v (1 : K) hpv).toFun.exists_extend with ⟨f, hf⟩ refine' ⟨f, _, _⟩ · rintro rfl rw [LinearMap.zero_comp] at hf have := LinearPMap.supSpanSingleton_apply_mk ⟨p, 0⟩ v (1 : K) hpv 0 p.zero_mem 1 simpa using (LinearMap.congr_fun hf _).trans this · refine' fun x hx => mem_ker.2 _ have := LinearPMap.supSpanSingleton_apply_mk ⟨p, 0⟩ v (1 : K) hpv x hx 0 simpa using (LinearMap.congr_fun hf _).trans this #align submodule.exists_le_ker_of_lt_top Submodule.exists_le_ker_of_lt_top theorem quotient_prod_linearEquiv (p : Submodule K V) : Nonempty (((V ⧸ p) × p) ≃ₗ[K] V) := let ⟨q, hq⟩ := p.exists_isCompl Nonempty.intro <| ((quotientEquivOfIsCompl p q hq).prod (LinearEquiv.refl _ _)).trans (prodEquivOfIsCompl q p hq.symm) #align quotient_prod_linear_equiv quotient_prod_linearEquiv end DivisionRing
! RUN: bbc -emit-fir %s -o - | FileCheck %s ! CHECK-LABEL: func @_QPchar_return_callee( ! CHECK-SAME: %{{.*}}: !fir.ref<!fir.char<1,10>>{{.*}}, %{{.*}}: index{{.*}}, %{{.*}}: !fir.ref<i32>{{.*}}) -> !fir.boxchar<1> { function char_return_callee(i) character(10) :: char_return_callee integer :: i end function ! CHECK-LABEL: @_QPtest_char_return_caller() subroutine test_char_return_caller character(10) :: char_return_caller ! CHECK: fir.call @_QPchar_return_caller({{.*}}) : (!fir.ref<!fir.char<1,10>>, index, !fir.ref<i32>) -> !fir.boxchar<1> print *, char_return_caller(5) end subroutine ! CHECK-LABEL: func @_QPtest_passing_char_array() subroutine test_passing_char_array character(len=3) :: x(4) call sub_taking_a_char_array(x) ! CHECK-DAG: %[[xarray:.*]] = fir.alloca !fir.array<4x!fir.char<1,3>> ! CHECK-DAG: %[[c3:.*]] = arith.constant 3 : index ! CHECK-DAG: %[[xbuff:.*]] = fir.convert %[[xarray]] : (!fir.ref<!fir.array<4x!fir.char<1,3>>>) -> !fir.ref<!fir.char<1,?>> ! CHECK: %[[boxchar:.*]] = fir.emboxchar %[[xbuff]], %[[c3]] : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1> ! CHECK: fir.call @_QPsub_taking_a_char_array(%[[boxchar]]) : (!fir.boxchar<1>) -> () end subroutine ! TODO more implicit interface cases with/without explicit interface
function p04_story ( ) %*****************************************************************************80 % %% P04_STORY prints the "story" for problem p04. % % Licensing: % % This code is distributed under the GNU LGPL license. % % Modified: % % 01 August 2011 % % Author: % % John Burkardt % % Reference: % % Larry Irvine, Samuel Marin, Philip Smith, % Constrained Interpolation and Smoothing, % Constructive Approximation, % Volume 2, Number 1, December 1986, pages 129-151. % % Parameters: % % None % fprintf ( 1, '\n' ); fprintf ( 1, ' This example is due to Larry Irvine, Samuel Marin and Philip Smith.\n' ); fprintf ( 1, ' This data can cause problems for interpolation methods.\n' ); fprintf ( 1, ' There are sudden changes in direction, and at the same time,\n' ); fprintf ( 1, ' sparsely-placed data. This can cause an interpolant to overshoot\n' ); fprintf ( 1, ' the data in a way that seems implausible.\n' ); return end
(* Proof that function composition is associative, even without assuming functional extensionality. *) Require Import Basics. Open Scope program_scope. Theorem compose_assoc : forall (A : Set) (f g h : A -> A), f ∘ (g ∘ h) = (f ∘ g) ∘ h. Proof. reflexivity. Qed.
The Indian National Trust for Art and Cultural Heritage ( INTACH ) is also involved with the Archaeological Survey of India in improving the local conditions at the cave site . A book has been published jointly by UNESCO , INTACH and the Government of India which presents a comprehensive site plan for restoration and a brief history of each sculpture constructed inside the caves .
[STATEMENT] lemma f_swap_sing [simp]: "f_swap [a] = f [1-a]" [PROOF STATE] proof (prove) goal (1 subgoal): 1. f_swap [a] = f [1 - a] [PROOF STEP] unfolding f_swap_def bin_swap_morph_def bin_swap_def [PROOF STATE] proof (prove) goal (1 subgoal): 1. (f \<circ> map ((-) 1)) [a] = f [1 - a] [PROOF STEP] by force
theory MDEAK_examples imports Main MDEAK_Core_SE MDEAK_SE MDEAK_method begin lemma l1: "\<turnstile>d (A \<^sub>F)\<^sub>S\<^sub>F\<^sub>M \<turnstile>\<^sub>F\<^sub>M (A \<^sub>F)\<^sub>S\<^sub>F\<^sub>M" (*by (rule Id_fm) *) using [[simp_trace_new mode=full]] by mdeak lemma l2: "\<turnstile>d Y \<turnstile>\<^sub>F\<^sub>M ((A \<^sub>F) \<^sub>S\<^sub>F\<^sub>M) \<rightarrow>\<^sub>S ((A \<^sub>F) \<^sub>S\<^sub>F\<^sub>M)" using [[simp_trace_new mode=full]] (*by mdeak*) by (simp only: W_2L l1) (*by (simp only: derivable.intros) by (simp only: derivable.simps) by (simp only: derivable.cases) by (simp only: derivable.induct)*) (*by (simp only: IW_L I_2L_f Id_fm )*) (*apply (rule IW_L) apply (rule I_2L_f) apply (rule Id) done*) lemma l3: "\<turnstile>d Y \<turnstile>\<^sub>F\<^sub>M ((A \<^sub>F) \<rightarrow>\<^sub>F (A \<^sub>F))\<^sub>S\<^sub>F\<^sub>M" using [[simp_trace_new mode=full]] apply(rule ImpR_R) apply(rule l2) done (*using Bot_L IW_L I_2L_f ImpR_R by blast*) lemma step1 : "\<turnstile>d (a)\<^sub>S\<^sub>A\<^sub>C \<turnstile>\<^sub>A\<^sub>C (a)\<^sub>S\<^sub>A\<^sub>C" (*sledgehammer*) by (metis Action.exhaust Bdiam3_L Bdiam3_R Fdiam3_L Fdiam3_R Id_ag Id_fa) theorem AderivesA : "\<turnstile>d (A)\<^sub>S\<^sub>F\<^sub>M \<turnstile>\<^sub>F\<^sub>M (A)\<^sub>S\<^sub>F\<^sub>M" apply(induction A) apply (simp add: l1) apply (simp add: Top_L Top_R) apply (simp add: Bot_L Bot_R) apply (simp add: And_L And_R) apply (simp add: Or_L Or_R) apply (simp add: ImpR_L ImpR_R) apply (simp add: ImpL_L ImpL_R) apply (simp add: DimpR_L DimpR_R) apply (simp add: DimpL_L DimpL_R) apply (simp add: Fdiam0_L Fdiam0_R Id_fa) apply (simp add: Fbox0_L Fbox0_R Id_fa) apply (simp add: Fdiam1_L Fdiam1_R step1) apply (simp add: Fbox1_L Fbox1_R step1) apply (simp add: Fdiam2_L Fdiam2_R Id_ag) apply (simp add: Fbox2_L Fbox2_R Id_ag) apply (simp add: Bdiam0_L Bdiam0_R Id_fa) apply (simp add: Bbox0_L Bbox0_R Id_fa) apply (simp add: Bdiam1_L Bdiam1_R step1) apply (simp add: Bbox1_L Bbox1_R step1) apply (simp add: Bdiam2_L Bdiam2_R Id_ag) by (simp add: Bbox2_L Bbox2_R Id_ag) end
Use colour combinations to add a new stylistic dimension to your bedroom or match existing decor - or select pieces in pure white or black for elegant minimalism. Make the most of in-built lighting elements to throw your clothing into crisp relief or provide the room with a subtle background glow. You can even use the USM Haller system to build a complete storage system for your walk-in wardrobe. Try our interactive online configurator to design your own USM Haller wardrobe. If you’re ready to order or to work with one of our specialists on your bespoke designs, get in touch.
import Lean open Lean.Elab.Term open Lean.Elab.Command elab "∃'" b:term "," P:term : term => do let ex ← `(Exists (fun $b => $P)); elabTerm ex none elab "#check2" b:term : command => do let cmd ← `(#check $b #check $b); elabCommand cmd #check ∃' x, x > 0 #check ∃' (x : UInt32), x > 0 #check2 10 elab "try" t:tactic : tactic => do let t' ← `(tactic| first | $t | skip); Lean.Elab.Tactic.evalTactic t' theorem tst (x y z : Nat) : y = z → x = x → x = y → x = z := by { intro h1; intro h2; intro h3; apply @Eq.trans; try exact h1; -- `exact h1` fails trace_state; try exact h3; trace_state; try exact h1; }
(* Title: HOL/Auth/n_german.thy Author: Yongjian Li and Kaiqiang Duan, State Key Lab of Computer Science, Institute of Software, Chinese Academy of Sciences Copyright 2016 State Key Lab of Computer Science, Institute of Software, Chinese Academy of Sciences *) (*header{*The n_german Protocol Case Study*}*) theory n_german imports n_german_lemma_invs_on_rules n_german_on_inis begin lemma main: assumes a1: "s \<in> reachableSet {andList (allInitSpecs N)} (rules N)" and a2: "0 < N" shows "\<forall> f. f \<in> (invariants N) --> formEval f s" proof (rule consistentLemma) show "consistent (invariants N) {andList (allInitSpecs N)} (rules N)" proof (cut_tac a1, unfold consistent_def, rule conjI) show "\<forall> f ini s. f \<in> (invariants N) --> ini \<in> {andList (allInitSpecs N)} --> formEval ini s --> formEval f s" proof ((rule allI)+, (rule impI)+) fix f ini s assume b1: "f \<in> (invariants N)" and b2: "ini \<in> {andList (allInitSpecs N)}" and b3: "formEval ini s" have b4: "formEval (andList (allInitSpecs N)) s" apply (cut_tac b2 b3, simp) done show "formEval f s" apply (rule on_inis, cut_tac b1, assumption, cut_tac b2, assumption, cut_tac b3, assumption) done qed next show "\<forall> f r s. f \<in> invariants N --> r \<in> rules N --> invHoldForRule s f r (invariants N)" proof ((rule allI)+, (rule impI)+) fix f r s assume b1: "f \<in> invariants N" and b2: "r \<in> rules N" show "invHoldForRule s f r (invariants N)" apply (rule invs_on_rules, cut_tac b1, assumption, cut_tac b2, assumption) done qed qed next show "s \<in> reachableSet {andList (allInitSpecs N)} (rules N)" apply (metis a1) done qed end
! ############################################################################################################################### ! Begin MIT license text. ! _______________________________________________________________________________________________________ ! Copyright 2019 Dr William R Case, Jr ([email protected]) ! Permission is hereby granted, free of charge, to any person obtaining a copy of this software and ! associated documentation files (the "Software"), to deal in the Software without restriction, including ! without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ! copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to ! the following conditions: ! The above copyright notice and this permission notice shall be included in all copies or substantial ! portions of the Software and documentation. ! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ! OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ! FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ! AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ! LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ! THE SOFTWARE. ! _______________________________________________________________________________________________________ ! End MIT license text. MODULE BCHECK_2D_Interface INTERFACE SUBROUTINE BCHECK_2D ( B, BTYPE, ID, NROWB, NCOLB, NUM_GRIDS, XB, XL, BW ) USE PENTIUM_II_KIND, ONLY : BYTE, LONG, DOUBLE USE IOUNT1, ONLY : BUG, F04, WRT_LOG USE SCONTR, ONLY : BLNK_SUB_NAM USE TIMDAT, ONLY : TSEC USE SUBR_BEGEND_LEVELS, ONLY : BCHECK_BEGEND USE CONSTANTS_1, ONLY : ZERO, TWO USE MODEL_STUF, ONLY : ELDOF, NELGP, TE USE MODEL_STUF, ONLY : AGRID, ELGP IMPLICIT NONE CHARACTER(LEN=*), INTENT(IN) :: BTYPE ! Type of B matrix ('M' for membrane, 'B' for bending, 'S' for shear) INTEGER(LONG), INTENT(IN) :: NROWB ! Number of rows in the input B matrix INTEGER(LONG), INTENT(IN) :: NCOLB ! Number of cols in the input B matrix INTEGER(LONG), INTENT(IN) :: NUM_GRIDS ! Number of grids for the input B matrix INTEGER(LONG), INTENT(IN) :: ID(NCOLB) ! List of elem DOF's for each of the elem grids (e.g 3,4,5 for each of INTEGER(LONG), PARAMETER :: SUBR_BEGEND = BCHECK_BEGEND REAL(DOUBLE) , INTENT(IN) :: B(NROWB,NCOLB) ! Strain-displ matrix REAL(DOUBLE) , INTENT(IN) :: XB(NUM_GRIDS,3) ! Basic coords of elem grids (diff than XEB for TPLT2's in a MIN4T QUAD4) REAL(DOUBLE) , INTENT(IN) :: XL(NUM_GRIDS,3) ! Local coords of elem grids (diff than XEL for TPLT2's in a MIN4T QUAD4) REAL(DOUBLE) , INTENT(OUT) :: BW(NROWB,14) ! Output from subr BCHECK_2D (matrix of NROWB elem strains for various END SUBROUTINE BCHECK_2D END INTERFACE END MODULE BCHECK_2D_Interface
State Before: V : Type u inst✝² : Quiver V V' : Type u' inst✝¹ : Quiver V' V'' : Type u'' inst✝ : Quiver V'' φ : V ⥤q V' φ' : V' ⥤q V'' ⊢ freeGroupoidFunctor (φ ⋙q φ') = freeGroupoidFunctor φ ⋙ freeGroupoidFunctor φ' State After: V : Type u inst✝² : Quiver V V' : Type u' inst✝¹ : Quiver V' V'' : Type u'' inst✝ : Quiver V'' φ : V ⥤q V' φ' : V' ⥤q V'' ⊢ lift (φ ⋙q φ' ⋙q of V'') = lift (φ ⋙q of V') ⋙ lift (φ' ⋙q of V'') Tactic: dsimp only [freeGroupoidFunctor] State Before: V : Type u inst✝² : Quiver V V' : Type u' inst✝¹ : Quiver V' V'' : Type u'' inst✝ : Quiver V'' φ : V ⥤q V' φ' : V' ⥤q V'' ⊢ lift (φ ⋙q φ' ⋙q of V'') = lift (φ ⋙q of V') ⋙ lift (φ' ⋙q of V'') State After: V : Type u inst✝² : Quiver V V' : Type u' inst✝¹ : Quiver V' V'' : Type u'' inst✝ : Quiver V'' φ : V ⥤q V' φ' : V' ⥤q V'' ⊢ lift (φ ⋙q of V') ⋙ lift (φ' ⋙q of V'') = lift (φ ⋙q φ' ⋙q of V'') Tactic: symm State Before: V : Type u inst✝² : Quiver V V' : Type u' inst✝¹ : Quiver V' V'' : Type u'' inst✝ : Quiver V'' φ : V ⥤q V' φ' : V' ⥤q V'' ⊢ lift (φ ⋙q of V') ⋙ lift (φ' ⋙q of V'') = lift (φ ⋙q φ' ⋙q of V'') State After: case hΦ V : Type u inst✝² : Quiver V V' : Type u' inst✝¹ : Quiver V' V'' : Type u'' inst✝ : Quiver V'' φ : V ⥤q V' φ' : V' ⥤q V'' ⊢ of V ⋙q (lift (φ ⋙q of V') ⋙ lift (φ' ⋙q of V'')).toPrefunctor = φ ⋙q φ' ⋙q of V'' Tactic: apply lift_unique State Before: case hΦ V : Type u inst✝² : Quiver V V' : Type u' inst✝¹ : Quiver V' V'' : Type u'' inst✝ : Quiver V'' φ : V ⥤q V' φ' : V' ⥤q V'' ⊢ of V ⋙q (lift (φ ⋙q of V') ⋙ lift (φ' ⋙q of V'')).toPrefunctor = φ ⋙q φ' ⋙q of V'' State After: no goals Tactic: rfl
(* Default settings (from HsToCoq.Coq.Preamble) *) Generalizable All Variables. Unset Implicit Arguments. Set Maximal Implicit Insertion. Unset Strict Implicit. Unset Printing Implicit Defensive. Require Coq.Program.Tactics. Require Coq.Program.Wf. (* Preamble *) (* Converted imports: *) Require GHC.Base. Require GHC.Prim. Import GHC.Base.Notations. (* Converted type declarations: *) Record Category__Dict (cat : Type -> Type -> Type) := Category__Dict_Build { id__ : forall {a}, cat a a ; op_z2218U____ : forall {b} {c} {a}, cat b c -> cat a b -> cat a c }. Definition Category (cat : Type -> Type -> Type) := forall r__, (Category__Dict cat -> r__) -> r__. Existing Class Category. Definition id `{g__0__ : Category cat} : forall {a}, cat a a := g__0__ _ (id__ cat). Definition op_z2218U__ `{g__0__ : Category cat} : forall {b} {c} {a}, cat b c -> cat a b -> cat a c := g__0__ _ (op_z2218U____ cat). Notation "'_∘_'" := (op_z2218U__). Infix "∘" := (_∘_) (left associativity, at level 40). (* Converted value declarations: *) Definition op_zlzlzl__ {cat} {b} {c} {a} `{Category cat} : cat b c -> cat a b -> cat a c := _∘_. Notation "'_<<<_'" := (op_zlzlzl__). Infix "<<<" := (_<<<_) (at level 99). Definition op_zgzgzg__ {cat} {a} {b} {c} `{Category cat} : cat a b -> cat b c -> cat a c := fun f g => g ∘ f. Notation "'_>>>_'" := (op_zgzgzg__). Infix ">>>" := (_>>>_) (at level 99). (* Skipping instance `Control.Category.Category__Coercion' of class `Control.Category.Category' *) (* Skipping instance `Control.Category.Category__op_ZCz7eUz7eUZC__' of class `Control.Category.Category' *) (* Skipping instance `Control.Category.Category__op_ZCz7eUZC__' of class `Control.Category.Category' *) Local Definition Category__arrow_id : forall {a}, GHC.Prim.arrow a a := fun {a} => GHC.Base.id. Local Definition Category__arrow_op_z2218U__ : forall {b} {c} {a}, GHC.Prim.arrow b c -> GHC.Prim.arrow a b -> GHC.Prim.arrow a c := fun {b} {c} {a} => _GHC.Base.∘_. Program Instance Category__arrow : Category GHC.Prim.arrow := fun _ k__ => k__ {| id__ := fun {a} => Category__arrow_id ; op_z2218U____ := fun {b} {c} {a} => Category__arrow_op_z2218U__ |}. Module Notations. Notation "'_Control.Category.∘_'" := (op_z2218U__). Infix "Control.Category.∘" := (_∘_) (left associativity, at level 40). Notation "'_Control.Category.<<<_'" := (op_zlzlzl__). Infix "Control.Category.<<<" := (_<<<_) (at level 99). Notation "'_Control.Category.>>>_'" := (op_zgzgzg__). Infix "Control.Category.>>>" := (_>>>_) (at level 99). End Notations. (* External variables: Type GHC.Base.id GHC.Base.op_z2218U__ GHC.Prim.arrow *)
[STATEMENT] lemma two_block_non_interfering_dims: "dim_row (two_block_non_interfering A B) = dim_row A + dim_row B" "dim_col (two_block_non_interfering A B) = dim_col A + dim_col B" [PROOF STATE] proof (prove) goal (1 subgoal): 1. dim_row (two_block_non_interfering A B) = dim_row A + dim_row B &&& dim_col (two_block_non_interfering A B) = dim_col A + dim_col B [PROOF STEP] by (simp)+
[GOAL] g✝ : SL(2, ℤ) z : ℍ R : Type u_1 inst✝ : CommRing R g : SL(2, R) ⊢ IsCoprime (↑g 1 0) (↑g 1 1) [PROOFSTEP] use-(↑g : Matrix (Fin 2) (Fin 2) R) 0 1, (↑g : Matrix (Fin 2) (Fin 2) R) 0 0 [GOAL] case h g✝ : SL(2, ℤ) z : ℍ R : Type u_1 inst✝ : CommRing R g : SL(2, R) ⊢ -↑g 0 1 * ↑g 1 0 + ↑g 0 0 * ↑g 1 1 = 1 [PROOFSTEP] rw [add_comm, neg_mul, ← sub_eq_add_neg, ← det_fin_two] [GOAL] case h g✝ : SL(2, ℤ) z : ℍ R : Type u_1 inst✝ : CommRing R g : SL(2, R) ⊢ det ↑g = 1 [PROOFSTEP] exact g.det_coe [GOAL] g : SL(2, ℤ) z : ℍ R : Type u_1 inst✝ : CommRing R ⊢ Set.SurjOn (fun g => ↑g 1) Set.univ {cd | IsCoprime (cd 0) (cd 1)} [PROOFSTEP] rintro cd ⟨b₀, a, gcd_eqn⟩ [GOAL] case intro.intro g : SL(2, ℤ) z : ℍ R : Type u_1 inst✝ : CommRing R cd : Fin 2 → R b₀ a : R gcd_eqn : b₀ * cd 0 + a * cd 1 = 1 ⊢ cd ∈ (fun g => ↑g 1) '' Set.univ [PROOFSTEP] let A := of ![![a, -b₀], cd] [GOAL] case intro.intro g : SL(2, ℤ) z : ℍ R : Type u_1 inst✝ : CommRing R cd : Fin 2 → R b₀ a : R gcd_eqn : b₀ * cd 0 + a * cd 1 = 1 A : (fun x => Matrix (Fin (Nat.succ (Nat.succ 0))) (Fin (Nat.succ (Nat.succ 0))) R) ![![a, -b₀], cd] := ↑of ![![a, -b₀], cd] ⊢ cd ∈ (fun g => ↑g 1) '' Set.univ [PROOFSTEP] have det_A_1 : det A = 1 := by convert gcd_eqn rw [det_fin_two] simp [(by ring : a * cd 1 + b₀ * cd 0 = b₀ * cd 0 + a * cd 1)] [GOAL] g : SL(2, ℤ) z : ℍ R : Type u_1 inst✝ : CommRing R cd : Fin 2 → R b₀ a : R gcd_eqn : b₀ * cd 0 + a * cd 1 = 1 A : (fun x => Matrix (Fin (Nat.succ (Nat.succ 0))) (Fin (Nat.succ (Nat.succ 0))) R) ![![a, -b₀], cd] := ↑of ![![a, -b₀], cd] ⊢ det A = 1 [PROOFSTEP] convert gcd_eqn [GOAL] case h.e'_2 g : SL(2, ℤ) z : ℍ R : Type u_1 inst✝ : CommRing R cd : Fin 2 → R b₀ a : R gcd_eqn : b₀ * cd 0 + a * cd 1 = 1 A : (fun x => Matrix (Fin (Nat.succ (Nat.succ 0))) (Fin (Nat.succ (Nat.succ 0))) R) ![![a, -b₀], cd] := ↑of ![![a, -b₀], cd] ⊢ det A = b₀ * cd 0 + a * cd 1 [PROOFSTEP] rw [det_fin_two] [GOAL] case h.e'_2 g : SL(2, ℤ) z : ℍ R : Type u_1 inst✝ : CommRing R cd : Fin 2 → R b₀ a : R gcd_eqn : b₀ * cd 0 + a * cd 1 = 1 A : (fun x => Matrix (Fin (Nat.succ (Nat.succ 0))) (Fin (Nat.succ (Nat.succ 0))) R) ![![a, -b₀], cd] := ↑of ![![a, -b₀], cd] ⊢ A 0 0 * A 1 1 - A 0 1 * A 1 0 = b₀ * cd 0 + a * cd 1 [PROOFSTEP] simp [(by ring : a * cd 1 + b₀ * cd 0 = b₀ * cd 0 + a * cd 1)] [GOAL] g : SL(2, ℤ) z : ℍ R : Type u_1 inst✝ : CommRing R cd : Fin 2 → R b₀ a : R gcd_eqn : b₀ * cd 0 + a * cd 1 = 1 A : (fun x => Matrix (Fin (Nat.succ (Nat.succ 0))) (Fin (Nat.succ (Nat.succ 0))) R) ![![a, -b₀], cd] := ↑of ![![a, -b₀], cd] ⊢ a * cd 1 + b₀ * cd 0 = b₀ * cd 0 + a * cd 1 [PROOFSTEP] ring [GOAL] case intro.intro g : SL(2, ℤ) z : ℍ R : Type u_1 inst✝ : CommRing R cd : Fin 2 → R b₀ a : R gcd_eqn : b₀ * cd 0 + a * cd 1 = 1 A : (fun x => Matrix (Fin (Nat.succ (Nat.succ 0))) (Fin (Nat.succ (Nat.succ 0))) R) ![![a, -b₀], cd] := ↑of ![![a, -b₀], cd] det_A_1 : det A = 1 ⊢ cd ∈ (fun g => ↑g 1) '' Set.univ [PROOFSTEP] refine' ⟨⟨A, det_A_1⟩, Set.mem_univ _, _⟩ [GOAL] case intro.intro g : SL(2, ℤ) z : ℍ R : Type u_1 inst✝ : CommRing R cd : Fin 2 → R b₀ a : R gcd_eqn : b₀ * cd 0 + a * cd 1 = 1 A : (fun x => Matrix (Fin (Nat.succ (Nat.succ 0))) (Fin (Nat.succ (Nat.succ 0))) R) ![![a, -b₀], cd] := ↑of ![![a, -b₀], cd] det_A_1 : det A = 1 ⊢ (fun g => ↑g 1) { val := A, property := det_A_1 } = cd [PROOFSTEP] ext [GOAL] case intro.intro.h g : SL(2, ℤ) z : ℍ R : Type u_1 inst✝ : CommRing R cd : Fin 2 → R b₀ a : R gcd_eqn : b₀ * cd 0 + a * cd 1 = 1 A : (fun x => Matrix (Fin (Nat.succ (Nat.succ 0))) (Fin (Nat.succ (Nat.succ 0))) R) ![![a, -b₀], cd] := ↑of ![![a, -b₀], cd] det_A_1 : det A = 1 x✝ : Fin 2 ⊢ (fun g => ↑g 1) { val := A, property := det_A_1 } x✝ = cd x✝ [PROOFSTEP] simp [GOAL] g : SL(2, ℤ) z : ℍ ⊢ Tendsto (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) cofinite atTop [PROOFSTEP] letI : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule [GOAL] g : SL(2, ℤ) z : ℍ this : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule ⊢ Tendsto (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) cofinite atTop [PROOFSTEP] let π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 [GOAL] g : SL(2, ℤ) z : ℍ this : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 ⊢ Tendsto (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) cofinite atTop [PROOFSTEP] let π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 [GOAL] g : SL(2, ℤ) z : ℍ this : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 ⊢ Tendsto (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) cofinite atTop [PROOFSTEP] let f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := π₀.smulRight (z : ℂ) + π₁.smulRight 1 [GOAL] g : SL(2, ℤ) z : ℍ this : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 ⊢ Tendsto (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) cofinite atTop [PROOFSTEP] have f_def : ⇑f = fun p : Fin 2 → ℝ => (p 0 : ℂ) * ↑z + p 1 := by ext1 dsimp only [LinearMap.coe_proj, real_smul, LinearMap.coe_smulRight, LinearMap.add_apply] rw [mul_one] [GOAL] g : SL(2, ℤ) z : ℍ this : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 ⊢ ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) [PROOFSTEP] ext1 [GOAL] case h g : SL(2, ℤ) z : ℍ this : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 x✝ : Fin 2 → ℝ ⊢ ↑f x✝ = ↑(x✝ 0) * ↑z + ↑(x✝ 1) [PROOFSTEP] dsimp only [LinearMap.coe_proj, real_smul, LinearMap.coe_smulRight, LinearMap.add_apply] [GOAL] case h g : SL(2, ℤ) z : ℍ this : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 x✝ : Fin 2 → ℝ ⊢ ↑(Function.eval 0 x✝) * ↑z + ↑(Function.eval 1 x✝) * 1 = ↑(x✝ 0) * ↑z + ↑(x✝ 1) [PROOFSTEP] rw [mul_one] [GOAL] g : SL(2, ℤ) z : ℍ this : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) ⊢ Tendsto (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) cofinite atTop [PROOFSTEP] have : (fun p : Fin 2 → ℤ => normSq ((p 0 : ℂ) * ↑z + ↑(p 1))) = normSq ∘ f ∘ fun p : Fin 2 → ℤ => ((↑) : ℤ → ℝ) ∘ p := by ext1 rw [f_def] dsimp only [Function.comp] rw [ofReal_int_cast, ofReal_int_cast] [GOAL] g : SL(2, ℤ) z : ℍ this : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) ⊢ (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) = ↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p [PROOFSTEP] ext1 [GOAL] case h g : SL(2, ℤ) z : ℍ this : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) x✝ : Fin 2 → ℤ ⊢ ↑normSq (↑(x✝ 0) * ↑z + ↑(x✝ 1)) = (↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p) x✝ [PROOFSTEP] rw [f_def] [GOAL] case h g : SL(2, ℤ) z : ℍ this : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) x✝ : Fin 2 → ℤ ⊢ ↑normSq (↑(x✝ 0) * ↑z + ↑(x✝ 1)) = (↑normSq ∘ (fun p => ↑(p 0) * ↑z + ↑(p 1)) ∘ fun p => Int.cast ∘ p) x✝ [PROOFSTEP] dsimp only [Function.comp] [GOAL] case h g : SL(2, ℤ) z : ℍ this : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) x✝ : Fin 2 → ℤ ⊢ ↑normSq (↑(x✝ 0) * ↑z + ↑(x✝ 1)) = ↑normSq (↑↑(x✝ 0) * ↑z + ↑↑(x✝ 1)) [PROOFSTEP] rw [ofReal_int_cast, ofReal_int_cast] [GOAL] g : SL(2, ℤ) z : ℍ this✝ : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) this : (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) = ↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p ⊢ Tendsto (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) cofinite atTop [PROOFSTEP] rw [this] [GOAL] g : SL(2, ℤ) z : ℍ this✝ : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) this : (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) = ↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p ⊢ Tendsto (↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p) cofinite atTop [PROOFSTEP] have hf : LinearMap.ker f = ⊥ := by let g : ℂ →ₗ[ℝ] Fin 2 → ℝ := LinearMap.pi ![imLm, imLm.comp ((z : ℂ) • ((conjAe : ℂ →ₐ[ℝ] ℂ) : ℂ →ₗ[ℝ] ℂ))] suffices ((z : ℂ).im⁻¹ • g).comp f = LinearMap.id by exact LinearMap.ker_eq_bot_of_inverse this apply LinearMap.ext intro c have hz : (z : ℂ).im ≠ 0 := z.2.ne' rw [LinearMap.comp_apply, LinearMap.smul_apply, LinearMap.id_apply] ext i dsimp only [Pi.smul_apply, LinearMap.pi_apply, smul_eq_mul] fin_cases i · show (z : ℂ).im⁻¹ * (f c).im = c 0 rw [f_def, add_im, ofReal_mul_im, ofReal_im, add_zero, mul_left_comm, inv_mul_cancel hz, mul_one] · show (z : ℂ).im⁻¹ * ((z : ℂ) * conj (f c)).im = c 1 rw [f_def, RingHom.map_add, RingHom.map_mul, mul_add, mul_left_comm, mul_conj, conj_ofReal, conj_ofReal, ← ofReal_mul, add_im, ofReal_im, zero_add, inv_mul_eq_iff_eq_mul₀ hz] simp only [ofReal_im, ofReal_re, mul_im, zero_add, mul_zero] [GOAL] g : SL(2, ℤ) z : ℍ this✝ : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) this : (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) = ↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p ⊢ LinearMap.ker f = ⊥ [PROOFSTEP] let g : ℂ →ₗ[ℝ] Fin 2 → ℝ := LinearMap.pi ![imLm, imLm.comp ((z : ℂ) • ((conjAe : ℂ →ₐ[ℝ] ℂ) : ℂ →ₗ[ℝ] ℂ))] [GOAL] g✝ : SL(2, ℤ) z : ℍ this✝ : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) this : (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) = ↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p g : ℂ →ₗ[ℝ] Fin 2 → ℝ := LinearMap.pi ![imLm, LinearMap.comp imLm (↑z • ↑↑↑conjAe)] ⊢ LinearMap.ker f = ⊥ [PROOFSTEP] suffices ((z : ℂ).im⁻¹ • g).comp f = LinearMap.id by exact LinearMap.ker_eq_bot_of_inverse this [GOAL] g✝ : SL(2, ℤ) z : ℍ this✝¹ : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) this✝ : (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) = ↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p g : ℂ →ₗ[ℝ] Fin 2 → ℝ := LinearMap.pi ![imLm, LinearMap.comp imLm (↑z • ↑↑↑conjAe)] this : LinearMap.comp ((↑z).im⁻¹ • g) f = LinearMap.id ⊢ LinearMap.ker f = ⊥ [PROOFSTEP] exact LinearMap.ker_eq_bot_of_inverse this [GOAL] g✝ : SL(2, ℤ) z : ℍ this✝ : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) this : (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) = ↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p g : ℂ →ₗ[ℝ] Fin 2 → ℝ := LinearMap.pi ![imLm, LinearMap.comp imLm (↑z • ↑↑↑conjAe)] ⊢ LinearMap.comp ((↑z).im⁻¹ • g) f = LinearMap.id [PROOFSTEP] apply LinearMap.ext [GOAL] case h g✝ : SL(2, ℤ) z : ℍ this✝ : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) this : (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) = ↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p g : ℂ →ₗ[ℝ] Fin 2 → ℝ := LinearMap.pi ![imLm, LinearMap.comp imLm (↑z • ↑↑↑conjAe)] ⊢ ∀ (x : Fin 2 → ℝ), ↑(LinearMap.comp ((↑z).im⁻¹ • g) f) x = ↑LinearMap.id x [PROOFSTEP] intro c [GOAL] case h g✝ : SL(2, ℤ) z : ℍ this✝ : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) this : (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) = ↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p g : ℂ →ₗ[ℝ] Fin 2 → ℝ := LinearMap.pi ![imLm, LinearMap.comp imLm (↑z • ↑↑↑conjAe)] c : Fin 2 → ℝ ⊢ ↑(LinearMap.comp ((↑z).im⁻¹ • g) f) c = ↑LinearMap.id c [PROOFSTEP] have hz : (z : ℂ).im ≠ 0 := z.2.ne' [GOAL] case h g✝ : SL(2, ℤ) z : ℍ this✝ : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) this : (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) = ↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p g : ℂ →ₗ[ℝ] Fin 2 → ℝ := LinearMap.pi ![imLm, LinearMap.comp imLm (↑z • ↑↑↑conjAe)] c : Fin 2 → ℝ hz : (↑z).im ≠ 0 ⊢ ↑(LinearMap.comp ((↑z).im⁻¹ • g) f) c = ↑LinearMap.id c [PROOFSTEP] rw [LinearMap.comp_apply, LinearMap.smul_apply, LinearMap.id_apply] [GOAL] case h g✝ : SL(2, ℤ) z : ℍ this✝ : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) this : (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) = ↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p g : ℂ →ₗ[ℝ] Fin 2 → ℝ := LinearMap.pi ![imLm, LinearMap.comp imLm (↑z • ↑↑↑conjAe)] c : Fin 2 → ℝ hz : (↑z).im ≠ 0 ⊢ (↑z).im⁻¹ • ↑g (↑f c) = c [PROOFSTEP] ext i [GOAL] case h.h g✝ : SL(2, ℤ) z : ℍ this✝ : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) this : (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) = ↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p g : ℂ →ₗ[ℝ] Fin 2 → ℝ := LinearMap.pi ![imLm, LinearMap.comp imLm (↑z • ↑↑↑conjAe)] c : Fin 2 → ℝ hz : (↑z).im ≠ 0 i : Fin 2 ⊢ ((↑z).im⁻¹ • ↑g (↑f c)) i = c i [PROOFSTEP] dsimp only [Pi.smul_apply, LinearMap.pi_apply, smul_eq_mul] [GOAL] case h.h g✝ : SL(2, ℤ) z : ℍ this✝ : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) this : (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) = ↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p g : ℂ →ₗ[ℝ] Fin 2 → ℝ := LinearMap.pi ![imLm, LinearMap.comp imLm (↑z • ↑↑↑conjAe)] c : Fin 2 → ℝ hz : (↑z).im ≠ 0 i : Fin 2 ⊢ (↑z).im⁻¹ * ↑(vecCons imLm ![LinearMap.comp imLm (↑z • ↑↑↑conjAe)] i) (↑(LinearMap.smulRight (LinearMap.proj 0) ↑z + LinearMap.smulRight (LinearMap.proj 1) 1) c) = c i [PROOFSTEP] fin_cases i [GOAL] case h.h.head g✝ : SL(2, ℤ) z : ℍ this✝ : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) this : (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) = ↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p g : ℂ →ₗ[ℝ] Fin 2 → ℝ := LinearMap.pi ![imLm, LinearMap.comp imLm (↑z • ↑↑↑conjAe)] c : Fin 2 → ℝ hz : (↑z).im ≠ 0 ⊢ (↑z).im⁻¹ * ↑(vecCons imLm ![LinearMap.comp imLm (↑z • ↑↑↑conjAe)] { val := 0, isLt := (_ : 0 < 2) }) (↑(LinearMap.smulRight (LinearMap.proj 0) ↑z + LinearMap.smulRight (LinearMap.proj 1) 1) c) = c { val := 0, isLt := (_ : 0 < 2) } [PROOFSTEP] show (z : ℂ).im⁻¹ * (f c).im = c 0 [GOAL] case h.h.head g✝ : SL(2, ℤ) z : ℍ this✝ : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) this : (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) = ↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p g : ℂ →ₗ[ℝ] Fin 2 → ℝ := LinearMap.pi ![imLm, LinearMap.comp imLm (↑z • ↑↑↑conjAe)] c : Fin 2 → ℝ hz : (↑z).im ≠ 0 ⊢ (↑z).im⁻¹ * (↑f c).im = c 0 [PROOFSTEP] rw [f_def, add_im, ofReal_mul_im, ofReal_im, add_zero, mul_left_comm, inv_mul_cancel hz, mul_one] [GOAL] case h.h.tail.head g✝ : SL(2, ℤ) z : ℍ this✝ : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) this : (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) = ↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p g : ℂ →ₗ[ℝ] Fin 2 → ℝ := LinearMap.pi ![imLm, LinearMap.comp imLm (↑z • ↑↑↑conjAe)] c : Fin 2 → ℝ hz : (↑z).im ≠ 0 ⊢ (↑z).im⁻¹ * ↑(vecCons imLm ![LinearMap.comp imLm (↑z • ↑↑↑conjAe)] { val := 1, isLt := (_ : (fun a => a < 2) 1) }) (↑(LinearMap.smulRight (LinearMap.proj 0) ↑z + LinearMap.smulRight (LinearMap.proj 1) 1) c) = c { val := 1, isLt := (_ : (fun a => a < 2) 1) } [PROOFSTEP] show (z : ℂ).im⁻¹ * ((z : ℂ) * conj (f c)).im = c 1 [GOAL] case h.h.tail.head g✝ : SL(2, ℤ) z : ℍ this✝ : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) this : (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) = ↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p g : ℂ →ₗ[ℝ] Fin 2 → ℝ := LinearMap.pi ![imLm, LinearMap.comp imLm (↑z • ↑↑↑conjAe)] c : Fin 2 → ℝ hz : (↑z).im ≠ 0 ⊢ (↑z).im⁻¹ * (↑z * ↑(starRingEnd ((fun x => ℂ) c)) (↑f c)).im = c 1 [PROOFSTEP] rw [f_def, RingHom.map_add, RingHom.map_mul, mul_add, mul_left_comm, mul_conj, conj_ofReal, conj_ofReal, ← ofReal_mul, add_im, ofReal_im, zero_add, inv_mul_eq_iff_eq_mul₀ hz] [GOAL] case h.h.tail.head g✝ : SL(2, ℤ) z : ℍ this✝ : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) this : (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) = ↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p g : ℂ →ₗ[ℝ] Fin 2 → ℝ := LinearMap.pi ![imLm, LinearMap.comp imLm (↑z • ↑↑↑conjAe)] c : Fin 2 → ℝ hz : (↑z).im ≠ 0 ⊢ (↑z * ↑(c 1)).im = (↑z).im * c 1 [PROOFSTEP] simp only [ofReal_im, ofReal_re, mul_im, zero_add, mul_zero] [GOAL] g : SL(2, ℤ) z : ℍ this✝ : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) this : (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) = ↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p hf : LinearMap.ker f = ⊥ ⊢ Tendsto (↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p) cofinite atTop [PROOFSTEP] have hf' : ClosedEmbedding f := by have := @LinearEquiv.closedEmbedding_of_injective ℝ _ (Fin 2 → ℝ) _ _ ℂ _ _ _ f exact this hf [GOAL] g : SL(2, ℤ) z : ℍ this✝ : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) this : (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) = ↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p hf : LinearMap.ker f = ⊥ ⊢ ClosedEmbedding ↑f [PROOFSTEP] have := @LinearEquiv.closedEmbedding_of_injective ℝ _ (Fin 2 → ℝ) _ _ ℂ _ _ _ f [GOAL] g : SL(2, ℤ) z : ℍ this✝¹ : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) this✝ : (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) = ↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p hf : LinearMap.ker f = ⊥ this : LinearMap.ker f = ⊥ → ∀ [inst : FiniteDimensional ℝ (Fin 2 → ℝ)], ClosedEmbedding ↑f ⊢ ClosedEmbedding ↑f [PROOFSTEP] exact this hf [GOAL] g : SL(2, ℤ) z : ℍ this✝ : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) this : (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) = ↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p hf : LinearMap.ker f = ⊥ hf' : ClosedEmbedding ↑f ⊢ Tendsto (↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p) cofinite atTop [PROOFSTEP] have h₂ : Tendsto (fun p : Fin 2 → ℤ => ((↑) : ℤ → ℝ) ∘ p) cofinite (cocompact _) := by convert Tendsto.pi_map_coprodᵢ fun _ => Int.tendsto_coe_cofinite · rw [coprodᵢ_cofinite] · rw [coprodᵢ_cocompact] [GOAL] g : SL(2, ℤ) z : ℍ this✝ : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) this : (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) = ↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p hf : LinearMap.ker f = ⊥ hf' : ClosedEmbedding ↑f ⊢ Tendsto (fun p => Int.cast ∘ p) cofinite (cocompact (Fin 2 → ℝ)) [PROOFSTEP] convert Tendsto.pi_map_coprodᵢ fun _ => Int.tendsto_coe_cofinite [GOAL] case h.e'_4 g : SL(2, ℤ) z : ℍ this✝ : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) this : (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) = ↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p hf : LinearMap.ker f = ⊥ hf' : ClosedEmbedding ↑f ⊢ cofinite = Filter.coprodᵢ fun x => cofinite [PROOFSTEP] rw [coprodᵢ_cofinite] [GOAL] case h.e'_5 g : SL(2, ℤ) z : ℍ this✝ : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) this : (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) = ↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p hf : LinearMap.ker f = ⊥ hf' : ClosedEmbedding ↑f ⊢ cocompact (Fin 2 → ℝ) = Filter.coprodᵢ fun x => cocompact ℝ [PROOFSTEP] rw [coprodᵢ_cocompact] [GOAL] g : SL(2, ℤ) z : ℍ this✝ : Module ℝ (Fin 2 → ℝ) := NormedSpace.toModule π₀ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 0 π₁ : (Fin 2 → ℝ) →ₗ[ℝ] ℝ := LinearMap.proj 1 f : (Fin 2 → ℝ) →ₗ[ℝ] ℂ := LinearMap.smulRight π₀ ↑z + LinearMap.smulRight π₁ 1 f_def : ↑f = fun p => ↑(p 0) * ↑z + ↑(p 1) this : (fun p => ↑normSq (↑(p 0) * ↑z + ↑(p 1))) = ↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p hf : LinearMap.ker f = ⊥ hf' : ClosedEmbedding ↑f h₂ : Tendsto (fun p => Int.cast ∘ p) cofinite (cocompact (Fin 2 → ℝ)) ⊢ Tendsto (↑normSq ∘ ↑f ∘ fun p => Int.cast ∘ p) cofinite atTop [PROOFSTEP] exact tendsto_normSq_cocompact_atTop.comp (hf'.tendsto_cocompact.comp h₂) [GOAL] g : SL(2, ℤ) z : ℍ cd : Fin 2 → ℤ hcd : IsCoprime (cd 0) (cd 1) ⊢ (Fin 2 → ℝ) ≃ₗ[ℝ] Fin 2 → ℝ [PROOFSTEP] refine' LinearMap.GeneralLinearGroup.generalLinearEquiv ℝ (Fin 2 → ℝ) (GeneralLinearGroup.toLinear (planeConformalMatrix (cd 0 : ℝ) (-(cd 1 : ℝ)) _)) [GOAL] g : SL(2, ℤ) z : ℍ cd : Fin 2 → ℤ hcd : IsCoprime (cd 0) (cd 1) ⊢ ↑(cd 0) ^ 2 + (-↑(cd 1)) ^ 2 ≠ 0 [PROOFSTEP] norm_cast [GOAL] g : SL(2, ℤ) z : ℍ cd : Fin 2 → ℤ hcd : IsCoprime (cd 0) (cd 1) ⊢ ¬cd 0 ^ 2 + (-cd 1) ^ 2 = 0 [PROOFSTEP] rw [neg_sq] [GOAL] g : SL(2, ℤ) z : ℍ cd : Fin 2 → ℤ hcd : IsCoprime (cd 0) (cd 1) ⊢ ¬cd 0 ^ 2 + cd 1 ^ 2 = 0 [PROOFSTEP] exact hcd.sq_add_sq_ne_zero [GOAL] g : SL(2, ℤ) z : ℍ cd : Fin 2 → ℤ hcd : IsCoprime (cd 0) (cd 1) ⊢ Tendsto (fun g => ↑(lcRow0 cd) ↑(↑(SpecialLinearGroup.map (Int.castRingHom ℝ)) ↑g)) cofinite (cocompact ℝ) [PROOFSTEP] let mB : ℝ → Matrix (Fin 2) (Fin 2) ℝ := fun t => of ![![t, (-(1 : ℤ) : ℝ)], (↑) ∘ cd] [GOAL] g : SL(2, ℤ) z : ℍ cd : Fin 2 → ℤ hcd : IsCoprime (cd 0) (cd 1) mB : ℝ → Matrix (Fin 2) (Fin 2) ℝ := fun t => ↑of ![![t, -↑1], Int.cast ∘ cd] ⊢ Tendsto (fun g => ↑(lcRow0 cd) ↑(↑(SpecialLinearGroup.map (Int.castRingHom ℝ)) ↑g)) cofinite (cocompact ℝ) [PROOFSTEP] have hmB : Continuous mB := by refine' continuous_matrix _ simp only [Fin.forall_fin_two, continuous_const, continuous_id', of_apply, cons_val_zero, cons_val_one, and_self_iff] [GOAL] g : SL(2, ℤ) z : ℍ cd : Fin 2 → ℤ hcd : IsCoprime (cd 0) (cd 1) mB : ℝ → Matrix (Fin 2) (Fin 2) ℝ := fun t => ↑of ![![t, -↑1], Int.cast ∘ cd] ⊢ Continuous mB [PROOFSTEP] refine' continuous_matrix _ [GOAL] g : SL(2, ℤ) z : ℍ cd : Fin 2 → ℤ hcd : IsCoprime (cd 0) (cd 1) mB : ℝ → Matrix (Fin 2) (Fin 2) ℝ := fun t => ↑of ![![t, -↑1], Int.cast ∘ cd] ⊢ ∀ (i j : Fin 2), Continuous fun a => mB a i j [PROOFSTEP] simp only [Fin.forall_fin_two, continuous_const, continuous_id', of_apply, cons_val_zero, cons_val_one, and_self_iff] [GOAL] g : SL(2, ℤ) z : ℍ cd : Fin 2 → ℤ hcd : IsCoprime (cd 0) (cd 1) mB : ℝ → Matrix (Fin 2) (Fin 2) ℝ := fun t => ↑of ![![t, -↑1], Int.cast ∘ cd] hmB : Continuous mB ⊢ Tendsto (fun g => ↑(lcRow0 cd) ↑(↑(SpecialLinearGroup.map (Int.castRingHom ℝ)) ↑g)) cofinite (cocompact ℝ) [PROOFSTEP] refine' Filter.Tendsto.of_tendsto_comp _ (comap_cocompact_le hmB) [GOAL] g : SL(2, ℤ) z : ℍ cd : Fin 2 → ℤ hcd : IsCoprime (cd 0) (cd 1) mB : ℝ → Matrix (Fin 2) (Fin 2) ℝ := fun t => ↑of ![![t, -↑1], Int.cast ∘ cd] hmB : Continuous mB ⊢ Tendsto (mB ∘ fun g => ↑(lcRow0 cd) ↑(↑(SpecialLinearGroup.map (Int.castRingHom ℝ)) ↑g)) cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) [PROOFSTEP] let f₁ : SL(2, ℤ) → Matrix (Fin 2) (Fin 2) ℝ := fun g => Matrix.map (↑g : Matrix _ _ ℤ) ((↑) : ℤ → ℝ) [GOAL] g : SL(2, ℤ) z : ℍ cd : Fin 2 → ℤ hcd : IsCoprime (cd 0) (cd 1) mB : ℝ → Matrix (Fin 2) (Fin 2) ℝ := fun t => ↑of ![![t, -↑1], Int.cast ∘ cd] hmB : Continuous mB f₁ : SL(2, ℤ) → Matrix (Fin 2) (Fin 2) ℝ := fun g => Matrix.map (↑g) Int.cast ⊢ Tendsto (mB ∘ fun g => ↑(lcRow0 cd) ↑(↑(SpecialLinearGroup.map (Int.castRingHom ℝ)) ↑g)) cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) [PROOFSTEP] have cocompact_ℝ_to_cofinite_ℤ_matrix : Tendsto (fun m : Matrix (Fin 2) (Fin 2) ℤ => Matrix.map m ((↑) : ℤ → ℝ)) cofinite (cocompact _) := by simpa only [coprodᵢ_cofinite, coprodᵢ_cocompact] using Tendsto.pi_map_coprodᵢ fun _ : Fin 2 => Tendsto.pi_map_coprodᵢ fun _ : Fin 2 => Int.tendsto_coe_cofinite [GOAL] g : SL(2, ℤ) z : ℍ cd : Fin 2 → ℤ hcd : IsCoprime (cd 0) (cd 1) mB : ℝ → Matrix (Fin 2) (Fin 2) ℝ := fun t => ↑of ![![t, -↑1], Int.cast ∘ cd] hmB : Continuous mB f₁ : SL(2, ℤ) → Matrix (Fin 2) (Fin 2) ℝ := fun g => Matrix.map (↑g) Int.cast ⊢ Tendsto (fun m => Matrix.map m Int.cast) cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) [PROOFSTEP] simpa only [coprodᵢ_cofinite, coprodᵢ_cocompact] using Tendsto.pi_map_coprodᵢ fun _ : Fin 2 => Tendsto.pi_map_coprodᵢ fun _ : Fin 2 => Int.tendsto_coe_cofinite [GOAL] g : SL(2, ℤ) z : ℍ cd : Fin 2 → ℤ hcd : IsCoprime (cd 0) (cd 1) mB : ℝ → Matrix (Fin 2) (Fin 2) ℝ := fun t => ↑of ![![t, -↑1], Int.cast ∘ cd] hmB : Continuous mB f₁ : SL(2, ℤ) → Matrix (Fin 2) (Fin 2) ℝ := fun g => Matrix.map (↑g) Int.cast cocompact_ℝ_to_cofinite_ℤ_matrix : Tendsto (fun m => Matrix.map m Int.cast) cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) ⊢ Tendsto (mB ∘ fun g => ↑(lcRow0 cd) ↑(↑(SpecialLinearGroup.map (Int.castRingHom ℝ)) ↑g)) cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) [PROOFSTEP] have hf₁ : Tendsto f₁ cofinite (cocompact _) := cocompact_ℝ_to_cofinite_ℤ_matrix.comp Subtype.coe_injective.tendsto_cofinite [GOAL] g : SL(2, ℤ) z : ℍ cd : Fin 2 → ℤ hcd : IsCoprime (cd 0) (cd 1) mB : ℝ → Matrix (Fin 2) (Fin 2) ℝ := fun t => ↑of ![![t, -↑1], Int.cast ∘ cd] hmB : Continuous mB f₁ : SL(2, ℤ) → Matrix (Fin 2) (Fin 2) ℝ := fun g => Matrix.map (↑g) Int.cast cocompact_ℝ_to_cofinite_ℤ_matrix : Tendsto (fun m => Matrix.map m Int.cast) cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) hf₁ : Tendsto f₁ cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) ⊢ Tendsto (mB ∘ fun g => ↑(lcRow0 cd) ↑(↑(SpecialLinearGroup.map (Int.castRingHom ℝ)) ↑g)) cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) [PROOFSTEP] have hf₂ : ClosedEmbedding (lcRow0Extend hcd) := (lcRow0Extend hcd).toContinuousLinearEquiv.toHomeomorph.closedEmbedding [GOAL] g : SL(2, ℤ) z : ℍ cd : Fin 2 → ℤ hcd : IsCoprime (cd 0) (cd 1) mB : ℝ → Matrix (Fin 2) (Fin 2) ℝ := fun t => ↑of ![![t, -↑1], Int.cast ∘ cd] hmB : Continuous mB f₁ : SL(2, ℤ) → Matrix (Fin 2) (Fin 2) ℝ := fun g => Matrix.map (↑g) Int.cast cocompact_ℝ_to_cofinite_ℤ_matrix : Tendsto (fun m => Matrix.map m Int.cast) cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) hf₁ : Tendsto f₁ cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) hf₂ : ClosedEmbedding ↑(lcRow0Extend hcd) ⊢ Tendsto (mB ∘ fun g => ↑(lcRow0 cd) ↑(↑(SpecialLinearGroup.map (Int.castRingHom ℝ)) ↑g)) cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) [PROOFSTEP] convert hf₂.tendsto_cocompact.comp (hf₁.comp Subtype.coe_injective.tendsto_cofinite) using 1 [GOAL] case h.e'_3.h g : SL(2, ℤ) z : ℍ cd : Fin 2 → ℤ hcd : IsCoprime (cd 0) (cd 1) mB : ℝ → Matrix (Fin 2) (Fin 2) ℝ := fun t => ↑of ![![t, -↑1], Int.cast ∘ cd] hmB : Continuous mB f₁ : SL(2, ℤ) → Matrix (Fin 2) (Fin 2) ℝ := fun g => Matrix.map (↑g) Int.cast cocompact_ℝ_to_cofinite_ℤ_matrix : Tendsto (fun m => Matrix.map m Int.cast) cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) hf₁ : Tendsto f₁ cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) hf₂ : ClosedEmbedding ↑(lcRow0Extend hcd) ⊢ (mB ∘ fun g => ↑(lcRow0 cd) ↑(↑(SpecialLinearGroup.map (Int.castRingHom ℝ)) ↑g)) = ↑(lcRow0Extend hcd) ∘ f₁ ∘ fun a => ↑a [PROOFSTEP] ext ⟨g, rfl⟩ i j : 3 [GOAL] case h.e'_3.h.h.mk.a.h g✝ : SL(2, ℤ) z : ℍ f₁ : SL(2, ℤ) → Matrix (Fin 2) (Fin 2) ℝ := fun g => Matrix.map (↑g) Int.cast cocompact_ℝ_to_cofinite_ℤ_matrix : Tendsto (fun m => Matrix.map m Int.cast) cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) hf₁ : Tendsto f₁ cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) g : SL(2, ℤ) hcd : IsCoprime (↑g 1 0) (↑g 1 1) mB : ℝ → Matrix (Fin 2) (Fin 2) ℝ := fun t => ↑of ![![t, -↑1], Int.cast ∘ ↑g 1] hmB : Continuous mB hf₂ : ClosedEmbedding ↑(lcRow0Extend hcd) i j : Fin 2 ⊢ (mB ∘ fun g_1 => ↑(lcRow0 (↑g 1)) ↑(↑(SpecialLinearGroup.map (Int.castRingHom ℝ)) ↑g_1)) { val := g, property := (_ : ↑g 1 = ↑g 1) } i j = (↑(lcRow0Extend hcd) ∘ f₁ ∘ fun a => ↑a) { val := g, property := (_ : ↑g 1 = ↑g 1) } i j [PROOFSTEP] fin_cases i <;> [fin_cases j; skip] -- the following are proved by `simp`, but it is replaced by `simp only` to avoid timeouts. [GOAL] case h.e'_3.h.h.mk.a.h g✝ : SL(2, ℤ) z : ℍ f₁ : SL(2, ℤ) → Matrix (Fin 2) (Fin 2) ℝ := fun g => Matrix.map (↑g) Int.cast cocompact_ℝ_to_cofinite_ℤ_matrix : Tendsto (fun m => Matrix.map m Int.cast) cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) hf₁ : Tendsto f₁ cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) g : SL(2, ℤ) hcd : IsCoprime (↑g 1 0) (↑g 1 1) mB : ℝ → Matrix (Fin 2) (Fin 2) ℝ := fun t => ↑of ![![t, -↑1], Int.cast ∘ ↑g 1] hmB : Continuous mB hf₂ : ClosedEmbedding ↑(lcRow0Extend hcd) i j : Fin 2 ⊢ (mB ∘ fun g_1 => ↑(lcRow0 (↑g 1)) ↑(↑(SpecialLinearGroup.map (Int.castRingHom ℝ)) ↑g_1)) { val := g, property := (_ : ↑g 1 = ↑g 1) } i j = (↑(lcRow0Extend hcd) ∘ f₁ ∘ fun a => ↑a) { val := g, property := (_ : ↑g 1 = ↑g 1) } i j [PROOFSTEP] fin_cases i [GOAL] case h.e'_3.h.h.mk.a.h.head g✝ : SL(2, ℤ) z : ℍ f₁ : SL(2, ℤ) → Matrix (Fin 2) (Fin 2) ℝ := fun g => Matrix.map (↑g) Int.cast cocompact_ℝ_to_cofinite_ℤ_matrix : Tendsto (fun m => Matrix.map m Int.cast) cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) hf₁ : Tendsto f₁ cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) g : SL(2, ℤ) hcd : IsCoprime (↑g 1 0) (↑g 1 1) mB : ℝ → Matrix (Fin 2) (Fin 2) ℝ := fun t => ↑of ![![t, -↑1], Int.cast ∘ ↑g 1] hmB : Continuous mB hf₂ : ClosedEmbedding ↑(lcRow0Extend hcd) j : Fin 2 ⊢ (mB ∘ fun g_1 => ↑(lcRow0 (↑g 1)) ↑(↑(SpecialLinearGroup.map (Int.castRingHom ℝ)) ↑g_1)) { val := g, property := (_ : ↑g 1 = ↑g 1) } { val := 0, isLt := (_ : 0 < 2) } j = (↑(lcRow0Extend hcd) ∘ f₁ ∘ fun a => ↑a) { val := g, property := (_ : ↑g 1 = ↑g 1) } { val := 0, isLt := (_ : 0 < 2) } j [PROOFSTEP] fin_cases j [GOAL] case h.e'_3.h.h.mk.a.h.tail.head g✝ : SL(2, ℤ) z : ℍ f₁ : SL(2, ℤ) → Matrix (Fin 2) (Fin 2) ℝ := fun g => Matrix.map (↑g) Int.cast cocompact_ℝ_to_cofinite_ℤ_matrix : Tendsto (fun m => Matrix.map m Int.cast) cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) hf₁ : Tendsto f₁ cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) g : SL(2, ℤ) hcd : IsCoprime (↑g 1 0) (↑g 1 1) mB : ℝ → Matrix (Fin 2) (Fin 2) ℝ := fun t => ↑of ![![t, -↑1], Int.cast ∘ ↑g 1] hmB : Continuous mB hf₂ : ClosedEmbedding ↑(lcRow0Extend hcd) j : Fin 2 ⊢ (mB ∘ fun g_1 => ↑(lcRow0 (↑g 1)) ↑(↑(SpecialLinearGroup.map (Int.castRingHom ℝ)) ↑g_1)) { val := g, property := (_ : ↑g 1 = ↑g 1) } { val := 1, isLt := (_ : (fun a => a < 2) 1) } j = (↑(lcRow0Extend hcd) ∘ f₁ ∘ fun a => ↑a) { val := g, property := (_ : ↑g 1 = ↑g 1) } { val := 1, isLt := (_ : (fun a => a < 2) 1) } j [PROOFSTEP] skip [GOAL] case h.e'_3.h.h.mk.a.h.head.head g✝ : SL(2, ℤ) z : ℍ f₁ : SL(2, ℤ) → Matrix (Fin 2) (Fin 2) ℝ := fun g => Matrix.map (↑g) Int.cast cocompact_ℝ_to_cofinite_ℤ_matrix : Tendsto (fun m => Matrix.map m Int.cast) cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) hf₁ : Tendsto f₁ cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) g : SL(2, ℤ) hcd : IsCoprime (↑g 1 0) (↑g 1 1) mB : ℝ → Matrix (Fin 2) (Fin 2) ℝ := fun t => ↑of ![![t, -↑1], Int.cast ∘ ↑g 1] hmB : Continuous mB hf₂ : ClosedEmbedding ↑(lcRow0Extend hcd) ⊢ (mB ∘ fun g_1 => ↑(lcRow0 (↑g 1)) ↑(↑(SpecialLinearGroup.map (Int.castRingHom ℝ)) ↑g_1)) { val := g, property := (_ : ↑g 1 = ↑g 1) } { val := 0, isLt := (_ : 0 < 2) } { val := 0, isLt := (_ : 0 < 2) } = (↑(lcRow0Extend hcd) ∘ f₁ ∘ fun a => ↑a) { val := g, property := (_ : ↑g 1 = ↑g 1) } { val := 0, isLt := (_ : 0 < 2) } { val := 0, isLt := (_ : 0 < 2) } [PROOFSTEP] simp only [mulVec, dotProduct, Fin.sum_univ_two, coe_matrix_coe, Int.coe_castRingHom, lcRow0_apply, Function.comp_apply, cons_val_zero, lcRow0Extend_apply, LinearMap.GeneralLinearGroup.coeFn_generalLinearEquiv, GeneralLinearGroup.coe_toLinear, planeConformalMatrix_val, neg_neg, mulVecLin_apply, cons_val_one, head_cons, of_apply, Fin.mk_zero, Fin.mk_one] [GOAL] case h.e'_3.h.h.mk.a.h.head.tail.head g✝ : SL(2, ℤ) z : ℍ f₁ : SL(2, ℤ) → Matrix (Fin 2) (Fin 2) ℝ := fun g => Matrix.map (↑g) Int.cast cocompact_ℝ_to_cofinite_ℤ_matrix : Tendsto (fun m => Matrix.map m Int.cast) cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) hf₁ : Tendsto f₁ cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) g : SL(2, ℤ) hcd : IsCoprime (↑g 1 0) (↑g 1 1) mB : ℝ → Matrix (Fin 2) (Fin 2) ℝ := fun t => ↑of ![![t, -↑1], Int.cast ∘ ↑g 1] hmB : Continuous mB hf₂ : ClosedEmbedding ↑(lcRow0Extend hcd) ⊢ (mB ∘ fun g_1 => ↑(lcRow0 (↑g 1)) ↑(↑(SpecialLinearGroup.map (Int.castRingHom ℝ)) ↑g_1)) { val := g, property := (_ : ↑g 1 = ↑g 1) } { val := 0, isLt := (_ : 0 < 2) } { val := 1, isLt := (_ : (fun a => a < 2) 1) } = (↑(lcRow0Extend hcd) ∘ f₁ ∘ fun a => ↑a) { val := g, property := (_ : ↑g 1 = ↑g 1) } { val := 0, isLt := (_ : 0 < 2) } { val := 1, isLt := (_ : (fun a => a < 2) 1) } [PROOFSTEP] convert congr_arg (fun n : ℤ => (-n : ℝ)) g.det_coe.symm using 1 [GOAL] case h.e'_3 g✝ : SL(2, ℤ) z : ℍ f₁ : SL(2, ℤ) → Matrix (Fin 2) (Fin 2) ℝ := fun g => Matrix.map (↑g) Int.cast cocompact_ℝ_to_cofinite_ℤ_matrix : Tendsto (fun m => Matrix.map m Int.cast) cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) hf₁ : Tendsto f₁ cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) g : SL(2, ℤ) hcd : IsCoprime (↑g 1 0) (↑g 1 1) mB : ℝ → Matrix (Fin 2) (Fin 2) ℝ := fun t => ↑of ![![t, -↑1], Int.cast ∘ ↑g 1] hmB : Continuous mB hf₂ : ClosedEmbedding ↑(lcRow0Extend hcd) ⊢ (↑(lcRow0Extend hcd) ∘ f₁ ∘ fun a => ↑a) { val := g, property := (_ : ↑g 1 = ↑g 1) } { val := 0, isLt := (_ : 0 < 2) } { val := 1, isLt := (_ : (fun a => a < 2) 1) } = -↑(Matrix.det ↑g) [PROOFSTEP] simp only [mulVec, dotProduct, Fin.sum_univ_two, Matrix.det_fin_two, Function.comp_apply, Subtype.coe_mk, lcRow0Extend_apply, cons_val_zero, LinearMap.GeneralLinearGroup.coeFn_generalLinearEquiv, GeneralLinearGroup.coe_toLinear, planeConformalMatrix_val, mulVecLin_apply, cons_val_one, head_cons, map_apply, neg_mul, Int.cast_sub, Int.cast_mul, neg_sub, of_apply, Fin.mk_zero, Fin.mk_one] [GOAL] case h.e'_3 g✝ : SL(2, ℤ) z : ℍ f₁ : SL(2, ℤ) → Matrix (Fin 2) (Fin 2) ℝ := fun g => Matrix.map (↑g) Int.cast cocompact_ℝ_to_cofinite_ℤ_matrix : Tendsto (fun m => Matrix.map m Int.cast) cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) hf₁ : Tendsto f₁ cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) g : SL(2, ℤ) hcd : IsCoprime (↑g 1 0) (↑g 1 1) mB : ℝ → Matrix (Fin 2) (Fin 2) ℝ := fun t => ↑of ![![t, -↑1], Int.cast ∘ ↑g 1] hmB : Continuous mB hf₂ : ClosedEmbedding ↑(lcRow0Extend hcd) ⊢ -(↑(↑g 1 1) * ↑(↑g 0 0)) + ↑(↑g 1 0) * ↑(↑g 0 1) = ↑(↑g 0 1) * ↑(↑g 1 0) - ↑(↑g 0 0) * ↑(↑g 1 1) [PROOFSTEP] ring [GOAL] case h.e'_3.h.h.mk.a.h.tail.head g✝ : SL(2, ℤ) z : ℍ f₁ : SL(2, ℤ) → Matrix (Fin 2) (Fin 2) ℝ := fun g => Matrix.map (↑g) Int.cast cocompact_ℝ_to_cofinite_ℤ_matrix : Tendsto (fun m => Matrix.map m Int.cast) cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) hf₁ : Tendsto f₁ cofinite (cocompact (Matrix (Fin 2) (Fin 2) ℝ)) g : SL(2, ℤ) hcd : IsCoprime (↑g 1 0) (↑g 1 1) mB : ℝ → Matrix (Fin 2) (Fin 2) ℝ := fun t => ↑of ![![t, -↑1], Int.cast ∘ ↑g 1] hmB : Continuous mB hf₂ : ClosedEmbedding ↑(lcRow0Extend hcd) j : Fin 2 ⊢ (mB ∘ fun g_1 => ↑(lcRow0 (↑g 1)) ↑(↑(SpecialLinearGroup.map (Int.castRingHom ℝ)) ↑g_1)) { val := g, property := (_ : ↑g 1 = ↑g 1) } { val := 1, isLt := (_ : (fun a => a < 2) 1) } j = (↑(lcRow0Extend hcd) ∘ f₁ ∘ fun a => ↑a) { val := g, property := (_ : ↑g 1 = ↑g 1) } { val := 1, isLt := (_ : (fun a => a < 2) 1) } j [PROOFSTEP] rfl [GOAL] g : SL(2, ℤ) z : ℍ p : Fin 2 → ℤ hp : IsCoprime (p 0) (p 1) hg : ↑g 1 = p ⊢ ↑(g • z) = ↑(↑(lcRow0 p) ↑(↑(SpecialLinearGroup.map (Int.castRingHom ℝ)) g)) / (↑(p 0) ^ 2 + ↑(p 1) ^ 2) + (↑(p 1) * ↑z - ↑(p 0)) / ((↑(p 0) ^ 2 + ↑(p 1) ^ 2) * (↑(p 0) * ↑z + ↑(p 1))) [PROOFSTEP] have nonZ1 : (p 0 : ℂ) ^ 2 + (p 1 : ℂ) ^ 2 ≠ 0 := by exact_mod_cast hp.sq_add_sq_ne_zero [GOAL] g : SL(2, ℤ) z : ℍ p : Fin 2 → ℤ hp : IsCoprime (p 0) (p 1) hg : ↑g 1 = p ⊢ ↑(p 0) ^ 2 + ↑(p 1) ^ 2 ≠ 0 [PROOFSTEP] exact_mod_cast hp.sq_add_sq_ne_zero [GOAL] g : SL(2, ℤ) z : ℍ p : Fin 2 → ℤ hp : IsCoprime (p 0) (p 1) hg : ↑g 1 = p nonZ1 : ↑(p 0) ^ 2 + ↑(p 1) ^ 2 ≠ 0 ⊢ ↑(g • z) = ↑(↑(lcRow0 p) ↑(↑(SpecialLinearGroup.map (Int.castRingHom ℝ)) g)) / (↑(p 0) ^ 2 + ↑(p 1) ^ 2) + (↑(p 1) * ↑z - ↑(p 0)) / ((↑(p 0) ^ 2 + ↑(p 1) ^ 2) * (↑(p 0) * ↑z + ↑(p 1))) [PROOFSTEP] have : ((↑) : ℤ → ℝ) ∘ p ≠ 0 := fun h => hp.ne_zero (by ext i; simpa using congr_fun h i) [GOAL] g : SL(2, ℤ) z : ℍ p : Fin 2 → ℤ hp : IsCoprime (p 0) (p 1) hg : ↑g 1 = p nonZ1 : ↑(p 0) ^ 2 + ↑(p 1) ^ 2 ≠ 0 h : Int.cast ∘ p = 0 ⊢ p = 0 [PROOFSTEP] ext i [GOAL] case h g : SL(2, ℤ) z : ℍ p : Fin 2 → ℤ hp : IsCoprime (p 0) (p 1) hg : ↑g 1 = p nonZ1 : ↑(p 0) ^ 2 + ↑(p 1) ^ 2 ≠ 0 h : Int.cast ∘ p = 0 i : Fin 2 ⊢ p i = OfNat.ofNat 0 i [PROOFSTEP] simpa using congr_fun h i [GOAL] g : SL(2, ℤ) z : ℍ p : Fin 2 → ℤ hp : IsCoprime (p 0) (p 1) hg : ↑g 1 = p nonZ1 : ↑(p 0) ^ 2 + ↑(p 1) ^ 2 ≠ 0 this : Int.cast ∘ p ≠ 0 ⊢ ↑(g • z) = ↑(↑(lcRow0 p) ↑(↑(SpecialLinearGroup.map (Int.castRingHom ℝ)) g)) / (↑(p 0) ^ 2 + ↑(p 1) ^ 2) + (↑(p 1) * ↑z - ↑(p 0)) / ((↑(p 0) ^ 2 + ↑(p 1) ^ 2) * (↑(p 0) * ↑z + ↑(p 1))) [PROOFSTEP] have nonZ2 : (p 0 : ℂ) * z + p 1 ≠ 0 := by simpa using linear_ne_zero _ z this [GOAL] g : SL(2, ℤ) z : ℍ p : Fin 2 → ℤ hp : IsCoprime (p 0) (p 1) hg : ↑g 1 = p nonZ1 : ↑(p 0) ^ 2 + ↑(p 1) ^ 2 ≠ 0 this : Int.cast ∘ p ≠ 0 ⊢ ↑(p 0) * ↑z + ↑(p 1) ≠ 0 [PROOFSTEP] simpa using linear_ne_zero _ z this [GOAL] g : SL(2, ℤ) z : ℍ p : Fin 2 → ℤ hp : IsCoprime (p 0) (p 1) hg : ↑g 1 = p nonZ1 : ↑(p 0) ^ 2 + ↑(p 1) ^ 2 ≠ 0 this : Int.cast ∘ p ≠ 0 nonZ2 : ↑(p 0) * ↑z + ↑(p 1) ≠ 0 ⊢ ↑(g • z) = ↑(↑(lcRow0 p) ↑(↑(SpecialLinearGroup.map (Int.castRingHom ℝ)) g)) / (↑(p 0) ^ 2 + ↑(p 1) ^ 2) + (↑(p 1) * ↑z - ↑(p 0)) / ((↑(p 0) ^ 2 + ↑(p 1) ^ 2) * (↑(p 0) * ↑z + ↑(p 1))) [PROOFSTEP] field_simp [nonZ1, nonZ2, denom_ne_zero, num] [GOAL] g : SL(2, ℤ) z : ℍ p : Fin 2 → ℤ hp : IsCoprime (p 0) (p 1) hg : ↑g 1 = p nonZ1 : ↑(p 0) ^ 2 + ↑(p 1) ^ 2 ≠ 0 this : Int.cast ∘ p ≠ 0 nonZ2 : ↑(p 0) * ↑z + ↑(p 1) ≠ 0 ⊢ (↑(↑g 0 0) * ↑z + ↑(↑g 0 1)) * ((↑(p 0) ^ 2 + ↑(p 1) ^ 2) * ((↑(p 0) ^ 2 + ↑(p 1) ^ 2) * (↑(p 0) * ↑z + ↑(p 1)))) = ((↑(p 0) * ↑(↑g 0 0) + ↑(p 1) * ↑(↑g 0 1)) * ((↑(p 0) ^ 2 + ↑(p 1) ^ 2) * (↑(p 0) * ↑z + ↑(p 1))) + (↑(p 1) * ↑z - ↑(p 0)) * (↑(p 0) ^ 2 + ↑(p 1) ^ 2)) * denom (↑g) z [PROOFSTEP] rw [(by simp : (p 1 : ℂ) * z - p 0 = (p 1 * z - p 0) * ↑(Matrix.det (↑g : Matrix (Fin 2) (Fin 2) ℤ)))] [GOAL] g : SL(2, ℤ) z : ℍ p : Fin 2 → ℤ hp : IsCoprime (p 0) (p 1) hg : ↑g 1 = p nonZ1 : ↑(p 0) ^ 2 + ↑(p 1) ^ 2 ≠ 0 this : Int.cast ∘ p ≠ 0 nonZ2 : ↑(p 0) * ↑z + ↑(p 1) ≠ 0 ⊢ ↑(p 1) * ↑z - ↑(p 0) = (↑(p 1) * ↑z - ↑(p 0)) * ↑(Matrix.det ↑g) [PROOFSTEP] simp [GOAL] g : SL(2, ℤ) z : ℍ p : Fin 2 → ℤ hp : IsCoprime (p 0) (p 1) hg : ↑g 1 = p nonZ1 : ↑(p 0) ^ 2 + ↑(p 1) ^ 2 ≠ 0 this : Int.cast ∘ p ≠ 0 nonZ2 : ↑(p 0) * ↑z + ↑(p 1) ≠ 0 ⊢ (↑(↑g 0 0) * ↑z + ↑(↑g 0 1)) * ((↑(p 0) ^ 2 + ↑(p 1) ^ 2) * ((↑(p 0) ^ 2 + ↑(p 1) ^ 2) * (↑(p 0) * ↑z + ↑(p 1)))) = ((↑(p 0) * ↑(↑g 0 0) + ↑(p 1) * ↑(↑g 0 1)) * ((↑(p 0) ^ 2 + ↑(p 1) ^ 2) * (↑(p 0) * ↑z + ↑(p 1))) + (↑(p 1) * ↑z - ↑(p 0)) * ↑(Matrix.det ↑g) * (↑(p 0) ^ 2 + ↑(p 1) ^ 2)) * denom (↑g) z [PROOFSTEP] rw [← hg, det_fin_two] [GOAL] g : SL(2, ℤ) z : ℍ p : Fin 2 → ℤ hp : IsCoprime (p 0) (p 1) hg : ↑g 1 = p nonZ1 : ↑(p 0) ^ 2 + ↑(p 1) ^ 2 ≠ 0 this : Int.cast ∘ p ≠ 0 nonZ2 : ↑(p 0) * ↑z + ↑(p 1) ≠ 0 ⊢ (↑(↑g 0 0) * ↑z + ↑(↑g 0 1)) * ((↑(↑g 1 0) ^ 2 + ↑(↑g 1 1) ^ 2) * ((↑(↑g 1 0) ^ 2 + ↑(↑g 1 1) ^ 2) * (↑(↑g 1 0) * ↑z + ↑(↑g 1 1)))) = ((↑(↑g 1 0) * ↑(↑g 0 0) + ↑(↑g 1 1) * ↑(↑g 0 1)) * ((↑(↑g 1 0) ^ 2 + ↑(↑g 1 1) ^ 2) * (↑(↑g 1 0) * ↑z + ↑(↑g 1 1))) + (↑(↑g 1 1) * ↑z - ↑(↑g 1 0)) * ↑(↑g 0 0 * ↑g 1 1 - ↑g 0 1 * ↑g 1 0) * (↑(↑g 1 0) ^ 2 + ↑(↑g 1 1) ^ 2)) * denom (↑g) z [PROOFSTEP] simp only [Int.coe_castRingHom, coe_matrix_coe, Int.cast_mul, ofReal_int_cast, map_apply, denom, Int.cast_sub, coe_GLPos_coe_GL_coe_matrix, coe'_apply_complex] [GOAL] g : SL(2, ℤ) z : ℍ p : Fin 2 → ℤ hp : IsCoprime (p 0) (p 1) hg : ↑g 1 = p nonZ1 : ↑(p 0) ^ 2 + ↑(p 1) ^ 2 ≠ 0 this : Int.cast ∘ p ≠ 0 nonZ2 : ↑(p 0) * ↑z + ↑(p 1) ≠ 0 ⊢ (↑(↑g 0 0) * ↑z + ↑(↑g 0 1)) * ((↑(↑g 1 0) ^ 2 + ↑(↑g 1 1) ^ 2) * ((↑(↑g 1 0) ^ 2 + ↑(↑g 1 1) ^ 2) * (↑(↑g 1 0) * ↑z + ↑(↑g 1 1)))) = ((↑(↑g 1 0) * ↑(↑g 0 0) + ↑(↑g 1 1) * ↑(↑g 0 1)) * ((↑(↑g 1 0) ^ 2 + ↑(↑g 1 1) ^ 2) * (↑(↑g 1 0) * ↑z + ↑(↑g 1 1))) + (↑(↑g 1 1) * ↑z - ↑(↑g 1 0)) * (↑(↑g 0 0) * ↑(↑g 1 1) - ↑(↑g 0 1) * ↑(↑g 1 0)) * (↑(↑g 1 0) ^ 2 + ↑(↑g 1 1) ^ 2)) * (↑(↑g 1 0) * ↑z + ↑(↑g 1 1)) [PROOFSTEP] ring [GOAL] g : SL(2, ℤ) z : ℍ p : Fin 2 → ℤ hp : IsCoprime (p 0) (p 1) ⊢ Tendsto (fun g => |UpperHalfPlane.re (↑g • z)|) cofinite atTop [PROOFSTEP] suffices Tendsto (fun g : (fun g : SL(2, ℤ) => (↑ₘg) 1) ⁻¹' { p } => ((g : SL(2, ℤ)) • z).re) cofinite (cocompact ℝ) by exact tendsto_norm_cocompact_atTop.comp this [GOAL] g : SL(2, ℤ) z : ℍ p : Fin 2 → ℤ hp : IsCoprime (p 0) (p 1) this : Tendsto (fun g => UpperHalfPlane.re (↑g • z)) cofinite (cocompact ℝ) ⊢ Tendsto (fun g => |UpperHalfPlane.re (↑g • z)|) cofinite atTop [PROOFSTEP] exact tendsto_norm_cocompact_atTop.comp this [GOAL] g : SL(2, ℤ) z : ℍ p : Fin 2 → ℤ hp : IsCoprime (p 0) (p 1) ⊢ Tendsto (fun g => UpperHalfPlane.re (↑g • z)) cofinite (cocompact ℝ) [PROOFSTEP] have : ((p 0 : ℝ) ^ 2 + (p 1 : ℝ) ^ 2)⁻¹ ≠ 0 := by apply inv_ne_zero exact_mod_cast hp.sq_add_sq_ne_zero [GOAL] g : SL(2, ℤ) z : ℍ p : Fin 2 → ℤ hp : IsCoprime (p 0) (p 1) ⊢ (↑(p 0) ^ 2 + ↑(p 1) ^ 2)⁻¹ ≠ 0 [PROOFSTEP] apply inv_ne_zero [GOAL] case h g : SL(2, ℤ) z : ℍ p : Fin 2 → ℤ hp : IsCoprime (p 0) (p 1) ⊢ ↑(p 0) ^ 2 + ↑(p 1) ^ 2 ≠ 0 [PROOFSTEP] exact_mod_cast hp.sq_add_sq_ne_zero [GOAL] g : SL(2, ℤ) z : ℍ p : Fin 2 → ℤ hp : IsCoprime (p 0) (p 1) this : (↑(p 0) ^ 2 + ↑(p 1) ^ 2)⁻¹ ≠ 0 ⊢ Tendsto (fun g => UpperHalfPlane.re (↑g • z)) cofinite (cocompact ℝ) [PROOFSTEP] let f := Homeomorph.mulRight₀ _ this [GOAL] g : SL(2, ℤ) z : ℍ p : Fin 2 → ℤ hp : IsCoprime (p 0) (p 1) this : (↑(p 0) ^ 2 + ↑(p 1) ^ 2)⁻¹ ≠ 0 f : ℝ ≃ₜ ℝ := Homeomorph.mulRight₀ (↑(p 0) ^ 2 + ↑(p 1) ^ 2)⁻¹ this ⊢ Tendsto (fun g => UpperHalfPlane.re (↑g • z)) cofinite (cocompact ℝ) [PROOFSTEP] let ff := Homeomorph.addRight (((p 1 : ℂ) * z - p 0) / (((p 0 : ℂ) ^ 2 + (p 1 : ℂ) ^ 2) * (p 0 * z + p 1))).re [GOAL] g : SL(2, ℤ) z : ℍ p : Fin 2 → ℤ hp : IsCoprime (p 0) (p 1) this : (↑(p 0) ^ 2 + ↑(p 1) ^ 2)⁻¹ ≠ 0 f : ℝ ≃ₜ ℝ := Homeomorph.mulRight₀ (↑(p 0) ^ 2 + ↑(p 1) ^ 2)⁻¹ this ff : ℝ ≃ₜ ℝ := Homeomorph.addRight ((↑(p 1) * ↑z - ↑(p 0)) / ((↑(p 0) ^ 2 + ↑(p 1) ^ 2) * (↑(p 0) * ↑z + ↑(p 1)))).re ⊢ Tendsto (fun g => UpperHalfPlane.re (↑g • z)) cofinite (cocompact ℝ) [PROOFSTEP] convert (f.trans ff).closedEmbedding.tendsto_cocompact.comp (tendsto_lcRow0 hp) with _ _ g [GOAL] case h.e'_3.h.h g✝ : SL(2, ℤ) z : ℍ p : Fin 2 → ℤ hp : IsCoprime (p 0) (p 1) this : (↑(p 0) ^ 2 + ↑(p 1) ^ 2)⁻¹ ≠ 0 f : ℝ ≃ₜ ℝ := Homeomorph.mulRight₀ (↑(p 0) ^ 2 + ↑(p 1) ^ 2)⁻¹ this ff : ℝ ≃ₜ ℝ := Homeomorph.addRight ((↑(p 1) * ↑z - ↑(p 0)) / ((↑(p 0) ^ 2 + ↑(p 1) ^ 2) * (↑(p 0) * ↑z + ↑(p 1)))).re e_1✝ : ↑((fun g => ↑g 1) ⁻¹' {p}) = { g // ↑g 1 = p } g : ↑((fun g => ↑g 1) ⁻¹' {p}) ⊢ UpperHalfPlane.re (↑g • z) = (↑(Homeomorph.trans f ff) ∘ fun g => ↑(lcRow0 p) ↑(↑(SpecialLinearGroup.map (Int.castRingHom ℝ)) ↑g)) g [PROOFSTEP] change ((g : SL(2, ℤ)) • z).re = lcRow0 p ↑(↑g : SL(2, ℝ)) / ((p 0 : ℝ) ^ 2 + (p 1 : ℝ) ^ 2) + Complex.re (((p 1 : ℂ) * z - p 0) / (((p 0 : ℂ) ^ 2 + (p 1 : ℂ) ^ 2) * (p 0 * z + p 1))) [GOAL] case h.e'_3.h.h g✝ : SL(2, ℤ) z : ℍ p : Fin 2 → ℤ hp : IsCoprime (p 0) (p 1) this : (↑(p 0) ^ 2 + ↑(p 1) ^ 2)⁻¹ ≠ 0 f : ℝ ≃ₜ ℝ := Homeomorph.mulRight₀ (↑(p 0) ^ 2 + ↑(p 1) ^ 2)⁻¹ this ff : ℝ ≃ₜ ℝ := Homeomorph.addRight ((↑(p 1) * ↑z - ↑(p 0)) / ((↑(p 0) ^ 2 + ↑(p 1) ^ 2) * (↑(p 0) * ↑z + ↑(p 1)))).re e_1✝ : ↑((fun g => ↑g 1) ⁻¹' {p}) = { g // ↑g 1 = p } g : ↑((fun g => ↑g 1) ⁻¹' {p}) ⊢ UpperHalfPlane.re (↑g • z) = ↑(lcRow0 p) ↑(↑(SpecialLinearGroup.map (Int.castRingHom ℝ)) ↑g) / (↑(p 0) ^ 2 + ↑(p 1) ^ 2) + ((↑(p 1) * ↑z - ↑(p 0)) / ((↑(p 0) ^ 2 + ↑(p 1) ^ 2) * (↑(p 0) * ↑z + ↑(p 1)))).re [PROOFSTEP] exact_mod_cast congr_arg Complex.re (smul_eq_lcRow0_add z hp g.2) [GOAL] g : SL(2, ℤ) z : ℍ ⊢ ∃ g, ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) [PROOFSTEP] classical let s : Set (Fin 2 → ℤ) := {cd | IsCoprime (cd 0) (cd 1)} have hs : s.Nonempty := ⟨![1, 1], isCoprime_one_left⟩ obtain ⟨p, hp_coprime, hp⟩ := Filter.Tendsto.exists_within_forall_le hs (tendsto_normSq_coprime_pair z) obtain ⟨g, -, hg⟩ := bottom_row_surj hp_coprime refine' ⟨g, fun g' => _⟩ rw [SpecialLinearGroup.im_smul_eq_div_normSq, SpecialLinearGroup.im_smul_eq_div_normSq, div_le_div_left] · simpa [← hg] using hp ((↑ₘg') 1) (bottom_row_coprime g') · exact z.im_pos · exact normSq_denom_pos g' z · exact normSq_denom_pos g z [GOAL] g : SL(2, ℤ) z : ℍ ⊢ ∃ g, ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) [PROOFSTEP] let s : Set (Fin 2 → ℤ) := {cd | IsCoprime (cd 0) (cd 1)} [GOAL] g : SL(2, ℤ) z : ℍ s : Set (Fin 2 → ℤ) := {cd | IsCoprime (cd 0) (cd 1)} ⊢ ∃ g, ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) [PROOFSTEP] have hs : s.Nonempty := ⟨![1, 1], isCoprime_one_left⟩ [GOAL] g : SL(2, ℤ) z : ℍ s : Set (Fin 2 → ℤ) := {cd | IsCoprime (cd 0) (cd 1)} hs : Set.Nonempty s ⊢ ∃ g, ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) [PROOFSTEP] obtain ⟨p, hp_coprime, hp⟩ := Filter.Tendsto.exists_within_forall_le hs (tendsto_normSq_coprime_pair z) [GOAL] case intro.intro g : SL(2, ℤ) z : ℍ s : Set (Fin 2 → ℤ) := {cd | IsCoprime (cd 0) (cd 1)} hs : Set.Nonempty s p : Fin 2 → ℤ hp_coprime : p ∈ s hp : ∀ (a : Fin 2 → ℤ), a ∈ s → ↑normSq (↑(p 0) * ↑z + ↑(p 1)) ≤ ↑normSq (↑(a 0) * ↑z + ↑(a 1)) ⊢ ∃ g, ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) [PROOFSTEP] obtain ⟨g, -, hg⟩ := bottom_row_surj hp_coprime [GOAL] case intro.intro.intro.intro g✝ : SL(2, ℤ) z : ℍ s : Set (Fin 2 → ℤ) := {cd | IsCoprime (cd 0) (cd 1)} hs : Set.Nonempty s p : Fin 2 → ℤ hp_coprime : p ∈ s hp : ∀ (a : Fin 2 → ℤ), a ∈ s → ↑normSq (↑(p 0) * ↑z + ↑(p 1)) ≤ ↑normSq (↑(a 0) * ↑z + ↑(a 1)) g : SL(2, ℤ) hg : (fun g => ↑g 1) g = p ⊢ ∃ g, ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) [PROOFSTEP] refine' ⟨g, fun g' => _⟩ [GOAL] case intro.intro.intro.intro g✝ : SL(2, ℤ) z : ℍ s : Set (Fin 2 → ℤ) := {cd | IsCoprime (cd 0) (cd 1)} hs : Set.Nonempty s p : Fin 2 → ℤ hp_coprime : p ∈ s hp : ∀ (a : Fin 2 → ℤ), a ∈ s → ↑normSq (↑(p 0) * ↑z + ↑(p 1)) ≤ ↑normSq (↑(a 0) * ↑z + ↑(a 1)) g : SL(2, ℤ) hg : (fun g => ↑g 1) g = p g' : SL(2, ℤ) ⊢ UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) [PROOFSTEP] rw [SpecialLinearGroup.im_smul_eq_div_normSq, SpecialLinearGroup.im_smul_eq_div_normSq, div_le_div_left] [GOAL] case intro.intro.intro.intro g✝ : SL(2, ℤ) z : ℍ s : Set (Fin 2 → ℤ) := {cd | IsCoprime (cd 0) (cd 1)} hs : Set.Nonempty s p : Fin 2 → ℤ hp_coprime : p ∈ s hp : ∀ (a : Fin 2 → ℤ), a ∈ s → ↑normSq (↑(p 0) * ↑z + ↑(p 1)) ≤ ↑normSq (↑(a 0) * ↑z + ↑(a 1)) g : SL(2, ℤ) hg : (fun g => ↑g 1) g = p g' : SL(2, ℤ) ⊢ ↑normSq (denom (↑g) z) ≤ ↑normSq (denom (↑g') z) [PROOFSTEP] simpa [← hg] using hp ((↑ₘg') 1) (bottom_row_coprime g') [GOAL] case intro.intro.intro.intro.ha g✝ : SL(2, ℤ) z : ℍ s : Set (Fin 2 → ℤ) := {cd | IsCoprime (cd 0) (cd 1)} hs : Set.Nonempty s p : Fin 2 → ℤ hp_coprime : p ∈ s hp : ∀ (a : Fin 2 → ℤ), a ∈ s → ↑normSq (↑(p 0) * ↑z + ↑(p 1)) ≤ ↑normSq (↑(a 0) * ↑z + ↑(a 1)) g : SL(2, ℤ) hg : (fun g => ↑g 1) g = p g' : SL(2, ℤ) ⊢ 0 < UpperHalfPlane.im z [PROOFSTEP] exact z.im_pos [GOAL] case intro.intro.intro.intro.hb g✝ : SL(2, ℤ) z : ℍ s : Set (Fin 2 → ℤ) := {cd | IsCoprime (cd 0) (cd 1)} hs : Set.Nonempty s p : Fin 2 → ℤ hp_coprime : p ∈ s hp : ∀ (a : Fin 2 → ℤ), a ∈ s → ↑normSq (↑(p 0) * ↑z + ↑(p 1)) ≤ ↑normSq (↑(a 0) * ↑z + ↑(a 1)) g : SL(2, ℤ) hg : (fun g => ↑g 1) g = p g' : SL(2, ℤ) ⊢ 0 < ↑normSq (denom (↑g') z) [PROOFSTEP] exact normSq_denom_pos g' z [GOAL] case intro.intro.intro.intro.hc g✝ : SL(2, ℤ) z : ℍ s : Set (Fin 2 → ℤ) := {cd | IsCoprime (cd 0) (cd 1)} hs : Set.Nonempty s p : Fin 2 → ℤ hp_coprime : p ∈ s hp : ∀ (a : Fin 2 → ℤ), a ∈ s → ↑normSq (↑(p 0) * ↑z + ↑(p 1)) ≤ ↑normSq (↑(a 0) * ↑z + ↑(a 1)) g : SL(2, ℤ) hg : (fun g => ↑g 1) g = p g' : SL(2, ℤ) ⊢ 0 < ↑normSq (denom (↑g) z) [PROOFSTEP] exact normSq_denom_pos g z [GOAL] g : SL(2, ℤ) z : ℍ cd : Fin 2 → ℤ hcd : IsCoprime (cd 0) (cd 1) ⊢ ∃ g, ↑g 1 = cd ∧ ∀ (g' : SL(2, ℤ)), ↑g 1 = ↑g' 1 → |UpperHalfPlane.re (g • z)| ≤ |UpperHalfPlane.re (g' • z)| [PROOFSTEP] haveI : Nonempty { g : SL(2, ℤ) // (↑ₘg) 1 = cd } := let ⟨x, hx⟩ := bottom_row_surj hcd ⟨⟨x, hx.2⟩⟩ [GOAL] g : SL(2, ℤ) z : ℍ cd : Fin 2 → ℤ hcd : IsCoprime (cd 0) (cd 1) this : Nonempty { g // ↑g 1 = cd } ⊢ ∃ g, ↑g 1 = cd ∧ ∀ (g' : SL(2, ℤ)), ↑g 1 = ↑g' 1 → |UpperHalfPlane.re (g • z)| ≤ |UpperHalfPlane.re (g' • z)| [PROOFSTEP] obtain ⟨g, hg⟩ := Filter.Tendsto.exists_forall_le (tendsto_abs_re_smul z hcd) [GOAL] case intro g✝ : SL(2, ℤ) z : ℍ cd : Fin 2 → ℤ hcd : IsCoprime (cd 0) (cd 1) this : Nonempty { g // ↑g 1 = cd } g : { g // ↑g 1 = cd } hg : ∀ (a : { g // ↑g 1 = cd }), |UpperHalfPlane.re (↑g • z)| ≤ |UpperHalfPlane.re (↑a • z)| ⊢ ∃ g, ↑g 1 = cd ∧ ∀ (g' : SL(2, ℤ)), ↑g 1 = ↑g' 1 → |UpperHalfPlane.re (g • z)| ≤ |UpperHalfPlane.re (g' • z)| [PROOFSTEP] refine' ⟨g, g.2, _⟩ [GOAL] case intro g✝ : SL(2, ℤ) z : ℍ cd : Fin 2 → ℤ hcd : IsCoprime (cd 0) (cd 1) this : Nonempty { g // ↑g 1 = cd } g : { g // ↑g 1 = cd } hg : ∀ (a : { g // ↑g 1 = cd }), |UpperHalfPlane.re (↑g • z)| ≤ |UpperHalfPlane.re (↑a • z)| ⊢ ∀ (g' : SL(2, ℤ)), ↑↑g 1 = ↑g' 1 → |UpperHalfPlane.re (↑g • z)| ≤ |UpperHalfPlane.re (g' • z)| [PROOFSTEP] intro g1 hg1 [GOAL] case intro g✝ : SL(2, ℤ) z : ℍ cd : Fin 2 → ℤ hcd : IsCoprime (cd 0) (cd 1) this : Nonempty { g // ↑g 1 = cd } g : { g // ↑g 1 = cd } hg : ∀ (a : { g // ↑g 1 = cd }), |UpperHalfPlane.re (↑g • z)| ≤ |UpperHalfPlane.re (↑a • z)| g1 : SL(2, ℤ) hg1 : ↑↑g 1 = ↑g1 1 ⊢ |UpperHalfPlane.re (↑g • z)| ≤ |UpperHalfPlane.re (g1 • z)| [PROOFSTEP] have : g1 ∈ (fun g : SL(2, ℤ) => (↑ₘg) 1) ⁻¹' { cd } := by rw [Set.mem_preimage, Set.mem_singleton_iff] exact Eq.trans hg1.symm (Set.mem_singleton_iff.mp (Set.mem_preimage.mp g.2)) [GOAL] g✝ : SL(2, ℤ) z : ℍ cd : Fin 2 → ℤ hcd : IsCoprime (cd 0) (cd 1) this : Nonempty { g // ↑g 1 = cd } g : { g // ↑g 1 = cd } hg : ∀ (a : { g // ↑g 1 = cd }), |UpperHalfPlane.re (↑g • z)| ≤ |UpperHalfPlane.re (↑a • z)| g1 : SL(2, ℤ) hg1 : ↑↑g 1 = ↑g1 1 ⊢ g1 ∈ (fun g => ↑g 1) ⁻¹' {cd} [PROOFSTEP] rw [Set.mem_preimage, Set.mem_singleton_iff] [GOAL] g✝ : SL(2, ℤ) z : ℍ cd : Fin 2 → ℤ hcd : IsCoprime (cd 0) (cd 1) this : Nonempty { g // ↑g 1 = cd } g : { g // ↑g 1 = cd } hg : ∀ (a : { g // ↑g 1 = cd }), |UpperHalfPlane.re (↑g • z)| ≤ |UpperHalfPlane.re (↑a • z)| g1 : SL(2, ℤ) hg1 : ↑↑g 1 = ↑g1 1 ⊢ ↑g1 1 = cd [PROOFSTEP] exact Eq.trans hg1.symm (Set.mem_singleton_iff.mp (Set.mem_preimage.mp g.2)) [GOAL] case intro g✝ : SL(2, ℤ) z : ℍ cd : Fin 2 → ℤ hcd : IsCoprime (cd 0) (cd 1) this✝ : Nonempty { g // ↑g 1 = cd } g : { g // ↑g 1 = cd } hg : ∀ (a : { g // ↑g 1 = cd }), |UpperHalfPlane.re (↑g • z)| ≤ |UpperHalfPlane.re (↑a • z)| g1 : SL(2, ℤ) hg1 : ↑↑g 1 = ↑g1 1 this : g1 ∈ (fun g => ↑g 1) ⁻¹' {cd} ⊢ |UpperHalfPlane.re (↑g • z)| ≤ |UpperHalfPlane.re (g1 • z)| [PROOFSTEP] exact hg ⟨g1, this⟩ [GOAL] g : SL(2, ℤ) z : ℍ n : ℤ ⊢ ↑(T ^ n • z) = ↑z + ↑n [PROOFSTEP] rw [sl_moeb, UpperHalfPlane.coe_smul] [GOAL] g : SL(2, ℤ) z : ℍ n : ℤ ⊢ num (↑(T ^ n)) z / denom (↑(T ^ n)) z = ↑z + ↑n [PROOFSTEP] simp [coe_T_zpow, denom, num, -map_zpow] [GOAL] g : SL(2, ℤ) z : ℍ n : ℤ ⊢ UpperHalfPlane.re (T ^ n • z) = UpperHalfPlane.re z + ↑n [PROOFSTEP] rw [← coe_re, coe_T_zpow_smul_eq, add_re, int_cast_re, coe_re] [GOAL] g : SL(2, ℤ) z : ℍ n : ℤ ⊢ UpperHalfPlane.im (T ^ n • z) = UpperHalfPlane.im z [PROOFSTEP] rw [← coe_im, coe_T_zpow_smul_eq, add_im, int_cast_im, add_zero, coe_im] [GOAL] g : SL(2, ℤ) z : ℍ ⊢ UpperHalfPlane.re (T • z) = UpperHalfPlane.re z + 1 [PROOFSTEP] simpa using re_T_zpow_smul z 1 [GOAL] g : SL(2, ℤ) z : ℍ ⊢ UpperHalfPlane.im (T • z) = UpperHalfPlane.im z [PROOFSTEP] simpa using im_T_zpow_smul z 1 [GOAL] g : SL(2, ℤ) z : ℍ ⊢ UpperHalfPlane.re (T⁻¹ • z) = UpperHalfPlane.re z - 1 [PROOFSTEP] simpa using re_T_zpow_smul z (-1) [GOAL] g : SL(2, ℤ) z : ℍ ⊢ UpperHalfPlane.im (T⁻¹ • z) = UpperHalfPlane.im z [PROOFSTEP] simpa using im_T_zpow_smul z (-1) [GOAL] g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 0 ⊢ ∃ n, ∀ (z : ℍ), g • z = T ^ n • z [PROOFSTEP] have had := g.det_coe [GOAL] g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 0 had : det ↑g = 1 ⊢ ∃ n, ∀ (z : ℍ), g • z = T ^ n • z [PROOFSTEP] replace had : (↑ₘg) 0 0 * (↑ₘg) 1 1 = 1 [GOAL] case had g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 0 had : det ↑g = 1 ⊢ ↑g 0 0 * ↑g 1 1 = 1 [PROOFSTEP] rw [det_fin_two, hc] at had [GOAL] case had g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 - ↑g 0 1 * 0 = 1 ⊢ ↑g 0 0 * ↑g 1 1 = 1 [PROOFSTEP] linarith [GOAL] g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ⊢ ∃ n, ∀ (z : ℍ), g • z = T ^ n • z [PROOFSTEP] rcases Int.eq_one_or_neg_one_of_mul_eq_one' had with (⟨ha, hd⟩ | ⟨ha, hd⟩) [GOAL] case inl.intro g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = 1 hd : ↑g 1 1 = 1 ⊢ ∃ n, ∀ (z : ℍ), g • z = T ^ n • z [PROOFSTEP] use(↑ₘg) 0 1 [GOAL] case h g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = 1 hd : ↑g 1 1 = 1 ⊢ ∀ (z : ℍ), g • z = T ^ ↑g 0 1 • z [PROOFSTEP] suffices g = T ^ (↑ₘg) 0 1 by intro z; conv_lhs => rw [this] [GOAL] g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = 1 hd : ↑g 1 1 = 1 this : g = T ^ ↑g 0 1 ⊢ ∀ (z : ℍ), g • z = T ^ ↑g 0 1 • z [PROOFSTEP] intro z [GOAL] g : SL(2, ℤ) z✝ : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = 1 hd : ↑g 1 1 = 1 this : g = T ^ ↑g 0 1 z : ℍ ⊢ g • z = T ^ ↑g 0 1 • z [PROOFSTEP] conv_lhs => rw [this] [GOAL] g : SL(2, ℤ) z✝ : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = 1 hd : ↑g 1 1 = 1 this : g = T ^ ↑g 0 1 z : ℍ | g • z [PROOFSTEP] rw [this] [GOAL] g : SL(2, ℤ) z✝ : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = 1 hd : ↑g 1 1 = 1 this : g = T ^ ↑g 0 1 z : ℍ | g • z [PROOFSTEP] rw [this] [GOAL] g : SL(2, ℤ) z✝ : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = 1 hd : ↑g 1 1 = 1 this : g = T ^ ↑g 0 1 z : ℍ | g • z [PROOFSTEP] rw [this] [GOAL] case h g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = 1 hd : ↑g 1 1 = 1 ⊢ g = T ^ ↑g 0 1 [PROOFSTEP] ext i j [GOAL] case h.a g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = 1 hd : ↑g 1 1 = 1 i j : Fin 2 ⊢ ↑g i j = ↑(T ^ ↑g 0 1) i j [PROOFSTEP] fin_cases i [GOAL] case h.a.head g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = 1 hd : ↑g 1 1 = 1 j : Fin 2 ⊢ ↑g { val := 0, isLt := (_ : 0 < 2) } j = ↑(T ^ ↑g 0 1) { val := 0, isLt := (_ : 0 < 2) } j [PROOFSTEP] fin_cases j [GOAL] case h.a.tail.head g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = 1 hd : ↑g 1 1 = 1 j : Fin 2 ⊢ ↑g { val := 1, isLt := (_ : (fun a => a < 2) 1) } j = ↑(T ^ ↑g 0 1) { val := 1, isLt := (_ : (fun a => a < 2) 1) } j [PROOFSTEP] fin_cases j [GOAL] case h.a.head.head g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = 1 hd : ↑g 1 1 = 1 ⊢ ↑g { val := 0, isLt := (_ : 0 < 2) } { val := 0, isLt := (_ : 0 < 2) } = ↑(T ^ ↑g 0 1) { val := 0, isLt := (_ : 0 < 2) } { val := 0, isLt := (_ : 0 < 2) } [PROOFSTEP] simp [ha, hc, hd, coe_T_zpow, show (1 : Fin (0 + 2)) = (1 : Fin 2) from rfl] [GOAL] case h.a.head.tail.head g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = 1 hd : ↑g 1 1 = 1 ⊢ ↑g { val := 0, isLt := (_ : 0 < 2) } { val := 1, isLt := (_ : (fun a => a < 2) 1) } = ↑(T ^ ↑g 0 1) { val := 0, isLt := (_ : 0 < 2) } { val := 1, isLt := (_ : (fun a => a < 2) 1) } [PROOFSTEP] simp [ha, hc, hd, coe_T_zpow, show (1 : Fin (0 + 2)) = (1 : Fin 2) from rfl] [GOAL] case h.a.tail.head.head g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = 1 hd : ↑g 1 1 = 1 ⊢ ↑g { val := 1, isLt := (_ : (fun a => a < 2) 1) } { val := 0, isLt := (_ : 0 < 2) } = ↑(T ^ ↑g 0 1) { val := 1, isLt := (_ : (fun a => a < 2) 1) } { val := 0, isLt := (_ : 0 < 2) } [PROOFSTEP] simp [ha, hc, hd, coe_T_zpow, show (1 : Fin (0 + 2)) = (1 : Fin 2) from rfl] [GOAL] case h.a.tail.head.tail.head g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = 1 hd : ↑g 1 1 = 1 ⊢ ↑g { val := 1, isLt := (_ : (fun a => a < 2) 1) } { val := 1, isLt := (_ : (fun a => a < 2) 1) } = ↑(T ^ ↑g 0 1) { val := 1, isLt := (_ : (fun a => a < 2) 1) } { val := 1, isLt := (_ : (fun a => a < 2) 1) } [PROOFSTEP] simp [ha, hc, hd, coe_T_zpow, show (1 : Fin (0 + 2)) = (1 : Fin 2) from rfl] [GOAL] case inr.intro g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = -1 hd : ↑g 1 1 = -1 ⊢ ∃ n, ∀ (z : ℍ), g • z = T ^ n • z [PROOFSTEP] use-((↑ₘg) 0 1) [GOAL] case h g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = -1 hd : ↑g 1 1 = -1 ⊢ ∀ (z : ℍ), g • z = T ^ (-↑g 0 1) • z [PROOFSTEP] suffices g = -T ^ (-((↑ₘg) 0 1)) by intro z; conv_lhs => rw [this, SL_neg_smul] [GOAL] g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = -1 hd : ↑g 1 1 = -1 this : g = -T ^ (-↑g 0 1) ⊢ ∀ (z : ℍ), g • z = T ^ (-↑g 0 1) • z [PROOFSTEP] intro z [GOAL] g : SL(2, ℤ) z✝ : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = -1 hd : ↑g 1 1 = -1 this : g = -T ^ (-↑g 0 1) z : ℍ ⊢ g • z = T ^ (-↑g 0 1) • z [PROOFSTEP] conv_lhs => rw [this, SL_neg_smul] [GOAL] g : SL(2, ℤ) z✝ : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = -1 hd : ↑g 1 1 = -1 this : g = -T ^ (-↑g 0 1) z : ℍ | g • z [PROOFSTEP] rw [this, SL_neg_smul] [GOAL] g : SL(2, ℤ) z✝ : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = -1 hd : ↑g 1 1 = -1 this : g = -T ^ (-↑g 0 1) z : ℍ | g • z [PROOFSTEP] rw [this, SL_neg_smul] [GOAL] g : SL(2, ℤ) z✝ : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = -1 hd : ↑g 1 1 = -1 this : g = -T ^ (-↑g 0 1) z : ℍ | g • z [PROOFSTEP] rw [this, SL_neg_smul] [GOAL] case h g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = -1 hd : ↑g 1 1 = -1 ⊢ g = -T ^ (-↑g 0 1) [PROOFSTEP] ext i j [GOAL] case h.a g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = -1 hd : ↑g 1 1 = -1 i j : Fin 2 ⊢ ↑g i j = ↑(-T ^ (-↑g 0 1)) i j [PROOFSTEP] fin_cases i [GOAL] case h.a.head g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = -1 hd : ↑g 1 1 = -1 j : Fin 2 ⊢ ↑g { val := 0, isLt := (_ : 0 < 2) } j = ↑(-T ^ (-↑g 0 1)) { val := 0, isLt := (_ : 0 < 2) } j [PROOFSTEP] fin_cases j [GOAL] case h.a.tail.head g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = -1 hd : ↑g 1 1 = -1 j : Fin 2 ⊢ ↑g { val := 1, isLt := (_ : (fun a => a < 2) 1) } j = ↑(-T ^ (-↑g 0 1)) { val := 1, isLt := (_ : (fun a => a < 2) 1) } j [PROOFSTEP] fin_cases j [GOAL] case h.a.head.head g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = -1 hd : ↑g 1 1 = -1 ⊢ ↑g { val := 0, isLt := (_ : 0 < 2) } { val := 0, isLt := (_ : 0 < 2) } = ↑(-T ^ (-↑g 0 1)) { val := 0, isLt := (_ : 0 < 2) } { val := 0, isLt := (_ : 0 < 2) } [PROOFSTEP] simp [ha, hc, hd, coe_T_zpow, show (1 : Fin (0 + 2)) = (1 : Fin 2) from rfl] [GOAL] case h.a.head.tail.head g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = -1 hd : ↑g 1 1 = -1 ⊢ ↑g { val := 0, isLt := (_ : 0 < 2) } { val := 1, isLt := (_ : (fun a => a < 2) 1) } = ↑(-T ^ (-↑g 0 1)) { val := 0, isLt := (_ : 0 < 2) } { val := 1, isLt := (_ : (fun a => a < 2) 1) } [PROOFSTEP] simp [ha, hc, hd, coe_T_zpow, show (1 : Fin (0 + 2)) = (1 : Fin 2) from rfl] [GOAL] case h.a.tail.head.head g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = -1 hd : ↑g 1 1 = -1 ⊢ ↑g { val := 1, isLt := (_ : (fun a => a < 2) 1) } { val := 0, isLt := (_ : 0 < 2) } = ↑(-T ^ (-↑g 0 1)) { val := 1, isLt := (_ : (fun a => a < 2) 1) } { val := 0, isLt := (_ : 0 < 2) } [PROOFSTEP] simp [ha, hc, hd, coe_T_zpow, show (1 : Fin (0 + 2)) = (1 : Fin 2) from rfl] [GOAL] case h.a.tail.head.tail.head g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 0 had : ↑g 0 0 * ↑g 1 1 = 1 ha : ↑g 0 0 = -1 hd : ↑g 1 1 = -1 ⊢ ↑g { val := 1, isLt := (_ : (fun a => a < 2) 1) } { val := 1, isLt := (_ : (fun a => a < 2) 1) } = ↑(-T ^ (-↑g 0 1)) { val := 1, isLt := (_ : (fun a => a < 2) 1) } { val := 1, isLt := (_ : (fun a => a < 2) 1) } [PROOFSTEP] simp [ha, hc, hd, coe_T_zpow, show (1 : Fin (0 + 2)) = (1 : Fin 2) from rfl] [GOAL] g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 1 ⊢ g = T ^ ↑g 0 0 * S * T ^ ↑g 1 1 [PROOFSTEP] have hg := g.det_coe.symm [GOAL] g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 1 hg : 1 = det ↑g ⊢ g = T ^ ↑g 0 0 * S * T ^ ↑g 1 1 [PROOFSTEP] replace hg : (↑ₘg) 0 1 = (↑ₘg) 0 0 * (↑ₘg) 1 1 - 1 [GOAL] case hg g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 1 hg : 1 = det ↑g ⊢ ↑g 0 1 = ↑g 0 0 * ↑g 1 1 - 1 [PROOFSTEP] rw [det_fin_two, hc] at hg [GOAL] case hg g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 1 hg : 1 = ↑g 0 0 * ↑g 1 1 - ↑g 0 1 * 1 ⊢ ↑g 0 1 = ↑g 0 0 * ↑g 1 1 - 1 [PROOFSTEP] linarith [GOAL] g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 1 hg : ↑g 0 1 = ↑g 0 0 * ↑g 1 1 - 1 ⊢ g = T ^ ↑g 0 0 * S * T ^ ↑g 1 1 [PROOFSTEP] refine' Subtype.ext _ [GOAL] g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 1 hg : ↑g 0 1 = ↑g 0 0 * ↑g 1 1 - 1 ⊢ ↑g = ↑(T ^ ↑g 0 0 * S * T ^ ↑g 1 1) [PROOFSTEP] conv_lhs => rw [Matrix.eta_fin_two (↑ₘg)] [GOAL] g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 1 hg : ↑g 0 1 = ↑g 0 0 * ↑g 1 1 - 1 | ↑g [PROOFSTEP] rw [Matrix.eta_fin_two (↑ₘg)] [GOAL] g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 1 hg : ↑g 0 1 = ↑g 0 0 * ↑g 1 1 - 1 | ↑g [PROOFSTEP] rw [Matrix.eta_fin_two (↑ₘg)] [GOAL] g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 1 hg : ↑g 0 1 = ↑g 0 0 * ↑g 1 1 - 1 | ↑g [PROOFSTEP] rw [Matrix.eta_fin_two (↑ₘg)] [GOAL] g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 1 hg : ↑g 0 1 = ↑g 0 0 * ↑g 1 1 - 1 ⊢ ↑of ![![↑g 0 0, ↑g 0 1], ![↑g 1 0, ↑g 1 1]] = ↑(T ^ ↑g 0 0 * S * T ^ ↑g 1 1) [PROOFSTEP] rw [hc, hg] [GOAL] g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 1 hg : ↑g 0 1 = ↑g 0 0 * ↑g 1 1 - 1 ⊢ ↑of ![![↑g 0 0, ↑g 0 0 * ↑g 1 1 - 1], ![1, ↑g 1 1]] = ↑(T ^ ↑g 0 0 * S * T ^ ↑g 1 1) [PROOFSTEP] simp only [coe_mul, coe_T_zpow, coe_S, mul_fin_two] -- Porting note: Was `congrm !![_, _; _, _] <;> ring`. [GOAL] g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 1 hg : ↑g 0 1 = ↑g 0 0 * ↑g 1 1 - 1 ⊢ ↑of ![![↑g 0 0, ↑g 0 0 * ↑g 1 1 - 1], ![1, ↑g 1 1]] = ↑of ![![(1 * 0 + ↑g 0 0 * 1) * 1 + (1 * -1 + ↑g 0 0 * 0) * 0, (1 * 0 + ↑g 0 0 * 1) * ↑g 1 1 + (1 * -1 + ↑g 0 0 * 0) * 1], ![(0 * 0 + 1 * 1) * 1 + (0 * -1 + 1 * 0) * 0, (0 * 0 + 1 * 1) * ↑g 1 1 + (0 * -1 + 1 * 0) * 1]] [PROOFSTEP] congr! 3 <;> [skip; congr! 1; congr! 2] [GOAL] g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 1 hg : ↑g 0 1 = ↑g 0 0 * ↑g 1 1 - 1 ⊢ ↑of ![![↑g 0 0, ↑g 0 0 * ↑g 1 1 - 1], ![1, ↑g 1 1]] = ↑of ![![(1 * 0 + ↑g 0 0 * 1) * 1 + (1 * -1 + ↑g 0 0 * 0) * 0, (1 * 0 + ↑g 0 0 * 1) * ↑g 1 1 + (1 * -1 + ↑g 0 0 * 0) * 1], ![(0 * 0 + 1 * 1) * 1 + (0 * -1 + 1 * 0) * 0, (0 * 0 + 1 * 1) * ↑g 1 1 + (0 * -1 + 1 * 0) * 1]] [PROOFSTEP] congr! 3 [GOAL] case h.e'_6.h.e'_3.h.e'_3 g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 1 hg : ↑g 0 1 = ↑g 0 0 * ↑g 1 1 - 1 ⊢ ↑g 0 0 = (1 * 0 + ↑g 0 0 * 1) * 1 + (1 * -1 + ↑g 0 0 * 0) * 0 [PROOFSTEP] skip [GOAL] case h.e'_6.h.e'_3.h.e'_4 g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 1 hg : ↑g 0 1 = ↑g 0 0 * ↑g 1 1 - 1 ⊢ ![↑g 0 0 * ↑g 1 1 - 1] = ![(1 * 0 + ↑g 0 0 * 1) * ↑g 1 1 + (1 * -1 + ↑g 0 0 * 0) * 1] [PROOFSTEP] congr! 1 [GOAL] case h.e'_6.h.e'_4.h.e'_3 g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 1 hg : ↑g 0 1 = ↑g 0 0 * ↑g 1 1 - 1 ⊢ ![1, ↑g 1 1] = ![(0 * 0 + 1 * 1) * 1 + (0 * -1 + 1 * 0) * 0, (0 * 0 + 1 * 1) * ↑g 1 1 + (0 * -1 + 1 * 0) * 1] [PROOFSTEP] congr! 2 [GOAL] case h.e'_6.h.e'_3.h.e'_3 g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 1 hg : ↑g 0 1 = ↑g 0 0 * ↑g 1 1 - 1 ⊢ ↑g 0 0 = (1 * 0 + ↑g 0 0 * 1) * 1 + (1 * -1 + ↑g 0 0 * 0) * 0 [PROOFSTEP] ring [GOAL] case h.e'_6.h.e'_3.h.e'_4.h.e'_3 g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 1 hg : ↑g 0 1 = ↑g 0 0 * ↑g 1 1 - 1 ⊢ ↑g 0 0 * ↑g 1 1 - 1 = (1 * 0 + ↑g 0 0 * 1) * ↑g 1 1 + (1 * -1 + ↑g 0 0 * 0) * 1 [PROOFSTEP] ring [GOAL] case h.e'_6.h.e'_4.h.e'_3.h.e'_4.h.e'_3 g : SL(2, ℤ) z : ℍ hc : ↑g 1 0 = 1 hg : ↑g 0 1 = ↑g 0 0 * ↑g 1 1 - 1 ⊢ ↑g 1 1 = (0 * 0 + 1 * 1) * ↑g 1 1 + (0 * -1 + 1 * 0) * 1 [PROOFSTEP] ring [GOAL] g : SL(2, ℤ) z : ℍ h : 1 < ↑normSq ↑z ⊢ ↑normSq ↑(S • z) < 1 [PROOFSTEP] simpa [coe_S, num, denom] using (inv_lt_inv z.normSq_pos zero_lt_one).mpr h [GOAL] g : SL(2, ℤ) z : ℍ h : ↑normSq ↑z < 1 ⊢ UpperHalfPlane.im z < UpperHalfPlane.im (S • z) [PROOFSTEP] have : z.im < z.im / normSq (z : ℂ) := by have imz : 0 < z.im := im_pos z apply (lt_div_iff z.normSq_pos).mpr nlinarith [GOAL] g : SL(2, ℤ) z : ℍ h : ↑normSq ↑z < 1 ⊢ UpperHalfPlane.im z < UpperHalfPlane.im z / ↑normSq ↑z [PROOFSTEP] have imz : 0 < z.im := im_pos z [GOAL] g : SL(2, ℤ) z : ℍ h : ↑normSq ↑z < 1 imz : 0 < UpperHalfPlane.im z ⊢ UpperHalfPlane.im z < UpperHalfPlane.im z / ↑normSq ↑z [PROOFSTEP] apply (lt_div_iff z.normSq_pos).mpr [GOAL] g : SL(2, ℤ) z : ℍ h : ↑normSq ↑z < 1 imz : 0 < UpperHalfPlane.im z ⊢ UpperHalfPlane.im z * ↑normSq ↑z < UpperHalfPlane.im z [PROOFSTEP] nlinarith [GOAL] g : SL(2, ℤ) z : ℍ h : ↑normSq ↑z < 1 this : UpperHalfPlane.im z < UpperHalfPlane.im z / ↑normSq ↑z ⊢ UpperHalfPlane.im z < UpperHalfPlane.im (S • z) [PROOFSTEP] convert this [GOAL] case h.e'_4 g : SL(2, ℤ) z : ℍ h : ↑normSq ↑z < 1 this : UpperHalfPlane.im z < UpperHalfPlane.im z / ↑normSq ↑z ⊢ UpperHalfPlane.im (S • z) = UpperHalfPlane.im z / ↑normSq ↑z [PROOFSTEP] simp only [SpecialLinearGroup.im_smul_eq_div_normSq] [GOAL] case h.e'_4 g : SL(2, ℤ) z : ℍ h : ↑normSq ↑z < 1 this : UpperHalfPlane.im z < UpperHalfPlane.im z / ↑normSq ↑z ⊢ UpperHalfPlane.im z / ↑normSq (denom (↑S) z) = UpperHalfPlane.im z / ↑normSq ↑z [PROOFSTEP] simp [denom, coe_S] [GOAL] g : SL(2, ℤ) z : ℍ h : z ∈ 𝒟ᵒ ⊢ |2 * UpperHalfPlane.re z| < 1 [PROOFSTEP] rw [abs_mul, abs_two, ← lt_div_iff' (zero_lt_two' ℝ)] [GOAL] g : SL(2, ℤ) z : ℍ h : z ∈ 𝒟ᵒ ⊢ |UpperHalfPlane.re z| < 1 / 2 [PROOFSTEP] exact h.2 [GOAL] g : SL(2, ℤ) z : ℍ h : z ∈ 𝒟ᵒ ⊢ 3 < 4 * UpperHalfPlane.im z ^ 2 [PROOFSTEP] have : 1 < z.re * z.re + z.im * z.im := by simpa [Complex.normSq_apply] using h.1 [GOAL] g : SL(2, ℤ) z : ℍ h : z ∈ 𝒟ᵒ ⊢ 1 < UpperHalfPlane.re z * UpperHalfPlane.re z + UpperHalfPlane.im z * UpperHalfPlane.im z [PROOFSTEP] simpa [Complex.normSq_apply] using h.1 [GOAL] g : SL(2, ℤ) z : ℍ h : z ∈ 𝒟ᵒ this : 1 < UpperHalfPlane.re z * UpperHalfPlane.re z + UpperHalfPlane.im z * UpperHalfPlane.im z ⊢ 3 < 4 * UpperHalfPlane.im z ^ 2 [PROOFSTEP] have := h.2 [GOAL] g : SL(2, ℤ) z : ℍ h : z ∈ 𝒟ᵒ this✝ : 1 < UpperHalfPlane.re z * UpperHalfPlane.re z + UpperHalfPlane.im z * UpperHalfPlane.im z this : |UpperHalfPlane.re z| < 1 / 2 ⊢ 3 < 4 * UpperHalfPlane.im z ^ 2 [PROOFSTEP] cases abs_cases z.re [GOAL] case inl g : SL(2, ℤ) z : ℍ h : z ∈ 𝒟ᵒ this✝ : 1 < UpperHalfPlane.re z * UpperHalfPlane.re z + UpperHalfPlane.im z * UpperHalfPlane.im z this : |UpperHalfPlane.re z| < 1 / 2 h✝ : |UpperHalfPlane.re z| = UpperHalfPlane.re z ∧ 0 ≤ UpperHalfPlane.re z ⊢ 3 < 4 * UpperHalfPlane.im z ^ 2 [PROOFSTEP] nlinarith [GOAL] case inr g : SL(2, ℤ) z : ℍ h : z ∈ 𝒟ᵒ this✝ : 1 < UpperHalfPlane.re z * UpperHalfPlane.re z + UpperHalfPlane.im z * UpperHalfPlane.im z this : |UpperHalfPlane.re z| < 1 / 2 h✝ : |UpperHalfPlane.re z| = -UpperHalfPlane.re z ∧ UpperHalfPlane.re z < 0 ⊢ 3 < 4 * UpperHalfPlane.im z ^ 2 [PROOFSTEP] nlinarith [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ n : ℤ ⊢ 1 < ↑normSq ↑(T ^ n • z) [PROOFSTEP] have hz₁ : 1 < z.re * z.re + z.im * z.im := hz.1 [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ n : ℤ hz₁ : 1 < UpperHalfPlane.re z * UpperHalfPlane.re z + UpperHalfPlane.im z * UpperHalfPlane.im z ⊢ 1 < ↑normSq ↑(T ^ n • z) [PROOFSTEP] have hzn := Int.nneg_mul_add_sq_of_abs_le_one n (abs_two_mul_re_lt_one_of_mem_fdo hz).le [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ n : ℤ hz₁ : 1 < UpperHalfPlane.re z * UpperHalfPlane.re z + UpperHalfPlane.im z * UpperHalfPlane.im z hzn : 0 ≤ ↑n * (2 * UpperHalfPlane.re z) + ↑n * ↑n ⊢ 1 < ↑normSq ↑(T ^ n • z) [PROOFSTEP] have : 1 < (z.re + ↑n) * (z.re + ↑n) + z.im * z.im := by linarith [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ n : ℤ hz₁ : 1 < UpperHalfPlane.re z * UpperHalfPlane.re z + UpperHalfPlane.im z * UpperHalfPlane.im z hzn : 0 ≤ ↑n * (2 * UpperHalfPlane.re z) + ↑n * ↑n ⊢ 1 < (UpperHalfPlane.re z + ↑n) * (UpperHalfPlane.re z + ↑n) + UpperHalfPlane.im z * UpperHalfPlane.im z [PROOFSTEP] linarith [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ n : ℤ hz₁ : 1 < UpperHalfPlane.re z * UpperHalfPlane.re z + UpperHalfPlane.im z * UpperHalfPlane.im z hzn : 0 ≤ ↑n * (2 * UpperHalfPlane.re z) + ↑n * ↑n this : 1 < (UpperHalfPlane.re z + ↑n) * (UpperHalfPlane.re z + ↑n) + UpperHalfPlane.im z * UpperHalfPlane.im z ⊢ 1 < ↑normSq ↑(T ^ n • z) [PROOFSTEP] simpa [coe_T_zpow, normSq, num, denom, -map_zpow] [GOAL] g : SL(2, ℤ) z : ℍ n : ℤ hz : z ∈ 𝒟ᵒ hg : T ^ n • z ∈ 𝒟ᵒ ⊢ n = 0 [PROOFSTEP] suffices |(n : ℝ)| < 1 by rwa [← Int.cast_abs, ← Int.cast_one, Int.cast_lt, Int.abs_lt_one_iff] at this [GOAL] g : SL(2, ℤ) z : ℍ n : ℤ hz : z ∈ 𝒟ᵒ hg : T ^ n • z ∈ 𝒟ᵒ this : |↑n| < 1 ⊢ n = 0 [PROOFSTEP] rwa [← Int.cast_abs, ← Int.cast_one, Int.cast_lt, Int.abs_lt_one_iff] at this [GOAL] g : SL(2, ℤ) z : ℍ n : ℤ hz : z ∈ 𝒟ᵒ hg : T ^ n • z ∈ 𝒟ᵒ ⊢ |↑n| < 1 [PROOFSTEP] have h₁ := hz.2 [GOAL] g : SL(2, ℤ) z : ℍ n : ℤ hz : z ∈ 𝒟ᵒ hg : T ^ n • z ∈ 𝒟ᵒ h₁ : |UpperHalfPlane.re z| < 1 / 2 ⊢ |↑n| < 1 [PROOFSTEP] have h₂ := hg.2 [GOAL] g : SL(2, ℤ) z : ℍ n : ℤ hz : z ∈ 𝒟ᵒ hg : T ^ n • z ∈ 𝒟ᵒ h₁ : |UpperHalfPlane.re z| < 1 / 2 h₂ : |UpperHalfPlane.re (T ^ n • z)| < 1 / 2 ⊢ |↑n| < 1 [PROOFSTEP] rw [re_T_zpow_smul] at h₂ [GOAL] g : SL(2, ℤ) z : ℍ n : ℤ hz : z ∈ 𝒟ᵒ hg : T ^ n • z ∈ 𝒟ᵒ h₁ : |UpperHalfPlane.re z| < 1 / 2 h₂ : |UpperHalfPlane.re z + ↑n| < 1 / 2 ⊢ |↑n| < 1 [PROOFSTEP] calc |(n : ℝ)| ≤ |z.re| + |z.re + (n : ℝ)| := abs_add' (n : ℝ) z.re _ < 1 / 2 + 1 / 2 := (add_lt_add h₁ h₂) _ = 1 := add_halves 1 [GOAL] g : SL(2, ℤ) z✝ z : ℍ ⊢ ∃ g, g • z ∈ 𝒟 [PROOFSTEP] obtain ⟨g₀, hg₀⟩ := exists_max_im z [GOAL] case intro g : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) ⊢ ∃ g, g • z ∈ 𝒟 [PROOFSTEP] obtain ⟨g, hg, hg'⟩ := exists_row_one_eq_and_min_re z (bottom_row_coprime g₀) [GOAL] case intro.intro.intro g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg' : ∀ (g' : SL(2, ℤ)), ↑g 1 = ↑g' 1 → |UpperHalfPlane.re (g • z)| ≤ |UpperHalfPlane.re (g' • z)| ⊢ ∃ g, g • z ∈ 𝒟 [PROOFSTEP] refine' ⟨g, _⟩ -- `g` has same max im property as `g₀` [GOAL] case intro.intro.intro g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg' : ∀ (g' : SL(2, ℤ)), ↑g 1 = ↑g' 1 → |UpperHalfPlane.re (g • z)| ≤ |UpperHalfPlane.re (g' • z)| ⊢ g • z ∈ 𝒟 [PROOFSTEP] have hg₀' : ∀ g' : SL(2, ℤ), (g' • z).im ≤ (g • z).im := by have hg'' : (g • z).im = (g₀ • z).im := by rw [SpecialLinearGroup.im_smul_eq_div_normSq, SpecialLinearGroup.im_smul_eq_div_normSq, denom_apply, denom_apply, hg] simpa only [hg''] using hg₀ [GOAL] g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg' : ∀ (g' : SL(2, ℤ)), ↑g 1 = ↑g' 1 → |UpperHalfPlane.re (g • z)| ≤ |UpperHalfPlane.re (g' • z)| ⊢ ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) [PROOFSTEP] have hg'' : (g • z).im = (g₀ • z).im := by rw [SpecialLinearGroup.im_smul_eq_div_normSq, SpecialLinearGroup.im_smul_eq_div_normSq, denom_apply, denom_apply, hg] [GOAL] g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg' : ∀ (g' : SL(2, ℤ)), ↑g 1 = ↑g' 1 → |UpperHalfPlane.re (g • z)| ≤ |UpperHalfPlane.re (g' • z)| ⊢ UpperHalfPlane.im (g • z) = UpperHalfPlane.im (g₀ • z) [PROOFSTEP] rw [SpecialLinearGroup.im_smul_eq_div_normSq, SpecialLinearGroup.im_smul_eq_div_normSq, denom_apply, denom_apply, hg] [GOAL] g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg' : ∀ (g' : SL(2, ℤ)), ↑g 1 = ↑g' 1 → |UpperHalfPlane.re (g • z)| ≤ |UpperHalfPlane.re (g' • z)| hg'' : UpperHalfPlane.im (g • z) = UpperHalfPlane.im (g₀ • z) ⊢ ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) [PROOFSTEP] simpa only [hg''] using hg₀ [GOAL] case intro.intro.intro g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg' : ∀ (g' : SL(2, ℤ)), ↑g 1 = ↑g' 1 → |UpperHalfPlane.re (g • z)| ≤ |UpperHalfPlane.re (g' • z)| hg₀' : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) ⊢ g • z ∈ 𝒟 [PROOFSTEP] constructor [GOAL] case intro.intro.intro.left g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg' : ∀ (g' : SL(2, ℤ)), ↑g 1 = ↑g' 1 → |UpperHalfPlane.re (g • z)| ≤ |UpperHalfPlane.re (g' • z)| hg₀' : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) ⊢ 1 ≤ ↑normSq ↑(g • z) [PROOFSTEP] contrapose! hg₀' [GOAL] case intro.intro.intro.left g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg' : ∀ (g' : SL(2, ℤ)), ↑g 1 = ↑g' 1 → |UpperHalfPlane.re (g • z)| ≤ |UpperHalfPlane.re (g' • z)| hg₀' : ↑normSq ↑(g • z) < 1 ⊢ ∃ g', UpperHalfPlane.im (g • z) < UpperHalfPlane.im (g' • z) [PROOFSTEP] refine' ⟨S * g, _⟩ [GOAL] case intro.intro.intro.left g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg' : ∀ (g' : SL(2, ℤ)), ↑g 1 = ↑g' 1 → |UpperHalfPlane.re (g • z)| ≤ |UpperHalfPlane.re (g' • z)| hg₀' : ↑normSq ↑(g • z) < 1 ⊢ UpperHalfPlane.im (g • z) < UpperHalfPlane.im ((S * g) • z) [PROOFSTEP] rw [mul_smul] [GOAL] case intro.intro.intro.left g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg' : ∀ (g' : SL(2, ℤ)), ↑g 1 = ↑g' 1 → |UpperHalfPlane.re (g • z)| ≤ |UpperHalfPlane.re (g' • z)| hg₀' : ↑normSq ↑(g • z) < 1 ⊢ UpperHalfPlane.im (g • z) < UpperHalfPlane.im (S • g • z) [PROOFSTEP] exact im_lt_im_S_smul hg₀' [GOAL] case intro.intro.intro.right g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg' : ∀ (g' : SL(2, ℤ)), ↑g 1 = ↑g' 1 → |UpperHalfPlane.re (g • z)| ≤ |UpperHalfPlane.re (g' • z)| hg₀' : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) ⊢ |UpperHalfPlane.re (g • z)| ≤ 1 / 2 [PROOFSTEP] show |(g • z).re| ≤ 1 / 2 -- if not, then either `T` or `T'` decrease |Re|. [GOAL] case intro.intro.intro.right g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg' : ∀ (g' : SL(2, ℤ)), ↑g 1 = ↑g' 1 → |UpperHalfPlane.re (g • z)| ≤ |UpperHalfPlane.re (g' • z)| hg₀' : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) ⊢ |UpperHalfPlane.re (g • z)| ≤ 1 / 2 [PROOFSTEP] rw [abs_le] [GOAL] case intro.intro.intro.right g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg' : ∀ (g' : SL(2, ℤ)), ↑g 1 = ↑g' 1 → |UpperHalfPlane.re (g • z)| ≤ |UpperHalfPlane.re (g' • z)| hg₀' : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) ⊢ -(1 / 2) ≤ UpperHalfPlane.re (g • z) ∧ UpperHalfPlane.re (g • z) ≤ 1 / 2 [PROOFSTEP] constructor [GOAL] case intro.intro.intro.right.left g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg' : ∀ (g' : SL(2, ℤ)), ↑g 1 = ↑g' 1 → |UpperHalfPlane.re (g • z)| ≤ |UpperHalfPlane.re (g' • z)| hg₀' : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) ⊢ -(1 / 2) ≤ UpperHalfPlane.re (g • z) [PROOFSTEP] contrapose! hg' [GOAL] case intro.intro.intro.right.left g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg₀' : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) hg' : UpperHalfPlane.re (g • z) < -(1 / 2) ⊢ ∃ g', ↑g 1 = ↑g' 1 ∧ |UpperHalfPlane.re (g' • z)| < |UpperHalfPlane.re (g • z)| [PROOFSTEP] refine' ⟨T * g, (T_mul_apply_one _).symm, _⟩ [GOAL] case intro.intro.intro.right.left g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg₀' : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) hg' : UpperHalfPlane.re (g • z) < -(1 / 2) ⊢ |UpperHalfPlane.re ((T * g) • z)| < |UpperHalfPlane.re (g • z)| [PROOFSTEP] rw [mul_smul, re_T_smul] [GOAL] case intro.intro.intro.right.left g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg₀' : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) hg' : UpperHalfPlane.re (g • z) < -(1 / 2) ⊢ |UpperHalfPlane.re (g • z) + 1| < |UpperHalfPlane.re (g • z)| [PROOFSTEP] cases abs_cases ((g • z).re + 1) [GOAL] case intro.intro.intro.right.left.inl g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg₀' : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) hg' : UpperHalfPlane.re (g • z) < -(1 / 2) h✝ : |UpperHalfPlane.re (g • z) + 1| = UpperHalfPlane.re (g • z) + 1 ∧ 0 ≤ UpperHalfPlane.re (g • z) + 1 ⊢ |UpperHalfPlane.re (g • z) + 1| < |UpperHalfPlane.re (g • z)| [PROOFSTEP] cases abs_cases (g • z).re [GOAL] case intro.intro.intro.right.left.inr g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg₀' : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) hg' : UpperHalfPlane.re (g • z) < -(1 / 2) h✝ : |UpperHalfPlane.re (g • z) + 1| = -(UpperHalfPlane.re (g • z) + 1) ∧ UpperHalfPlane.re (g • z) + 1 < 0 ⊢ |UpperHalfPlane.re (g • z) + 1| < |UpperHalfPlane.re (g • z)| [PROOFSTEP] cases abs_cases (g • z).re [GOAL] case intro.intro.intro.right.left.inl.inl g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg₀' : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) hg' : UpperHalfPlane.re (g • z) < -(1 / 2) h✝¹ : |UpperHalfPlane.re (g • z) + 1| = UpperHalfPlane.re (g • z) + 1 ∧ 0 ≤ UpperHalfPlane.re (g • z) + 1 h✝ : |UpperHalfPlane.re (g • z)| = UpperHalfPlane.re (g • z) ∧ 0 ≤ UpperHalfPlane.re (g • z) ⊢ |UpperHalfPlane.re (g • z) + 1| < |UpperHalfPlane.re (g • z)| [PROOFSTEP] linarith [GOAL] case intro.intro.intro.right.left.inl.inr g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg₀' : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) hg' : UpperHalfPlane.re (g • z) < -(1 / 2) h✝¹ : |UpperHalfPlane.re (g • z) + 1| = UpperHalfPlane.re (g • z) + 1 ∧ 0 ≤ UpperHalfPlane.re (g • z) + 1 h✝ : |UpperHalfPlane.re (g • z)| = -UpperHalfPlane.re (g • z) ∧ UpperHalfPlane.re (g • z) < 0 ⊢ |UpperHalfPlane.re (g • z) + 1| < |UpperHalfPlane.re (g • z)| [PROOFSTEP] linarith [GOAL] case intro.intro.intro.right.left.inr.inl g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg₀' : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) hg' : UpperHalfPlane.re (g • z) < -(1 / 2) h✝¹ : |UpperHalfPlane.re (g • z) + 1| = -(UpperHalfPlane.re (g • z) + 1) ∧ UpperHalfPlane.re (g • z) + 1 < 0 h✝ : |UpperHalfPlane.re (g • z)| = UpperHalfPlane.re (g • z) ∧ 0 ≤ UpperHalfPlane.re (g • z) ⊢ |UpperHalfPlane.re (g • z) + 1| < |UpperHalfPlane.re (g • z)| [PROOFSTEP] linarith [GOAL] case intro.intro.intro.right.left.inr.inr g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg₀' : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) hg' : UpperHalfPlane.re (g • z) < -(1 / 2) h✝¹ : |UpperHalfPlane.re (g • z) + 1| = -(UpperHalfPlane.re (g • z) + 1) ∧ UpperHalfPlane.re (g • z) + 1 < 0 h✝ : |UpperHalfPlane.re (g • z)| = -UpperHalfPlane.re (g • z) ∧ UpperHalfPlane.re (g • z) < 0 ⊢ |UpperHalfPlane.re (g • z) + 1| < |UpperHalfPlane.re (g • z)| [PROOFSTEP] linarith [GOAL] case intro.intro.intro.right.right g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg' : ∀ (g' : SL(2, ℤ)), ↑g 1 = ↑g' 1 → |UpperHalfPlane.re (g • z)| ≤ |UpperHalfPlane.re (g' • z)| hg₀' : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) ⊢ UpperHalfPlane.re (g • z) ≤ 1 / 2 [PROOFSTEP] contrapose! hg' [GOAL] case intro.intro.intro.right.right g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg₀' : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) hg' : 1 / 2 < UpperHalfPlane.re (g • z) ⊢ ∃ g', ↑g 1 = ↑g' 1 ∧ |UpperHalfPlane.re (g' • z)| < |UpperHalfPlane.re (g • z)| [PROOFSTEP] refine' ⟨T⁻¹ * g, (T_inv_mul_apply_one _).symm, _⟩ [GOAL] case intro.intro.intro.right.right g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg₀' : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) hg' : 1 / 2 < UpperHalfPlane.re (g • z) ⊢ |UpperHalfPlane.re ((T⁻¹ * g) • z)| < |UpperHalfPlane.re (g • z)| [PROOFSTEP] rw [mul_smul, re_T_inv_smul] [GOAL] case intro.intro.intro.right.right g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg₀' : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) hg' : 1 / 2 < UpperHalfPlane.re (g • z) ⊢ |UpperHalfPlane.re (g • z) - 1| < |UpperHalfPlane.re (g • z)| [PROOFSTEP] cases abs_cases ((g • z).re - 1) [GOAL] case intro.intro.intro.right.right.inl g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg₀' : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) hg' : 1 / 2 < UpperHalfPlane.re (g • z) h✝ : |UpperHalfPlane.re (g • z) - 1| = UpperHalfPlane.re (g • z) - 1 ∧ 0 ≤ UpperHalfPlane.re (g • z) - 1 ⊢ |UpperHalfPlane.re (g • z) - 1| < |UpperHalfPlane.re (g • z)| [PROOFSTEP] cases abs_cases (g • z).re [GOAL] case intro.intro.intro.right.right.inr g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg₀' : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) hg' : 1 / 2 < UpperHalfPlane.re (g • z) h✝ : |UpperHalfPlane.re (g • z) - 1| = -(UpperHalfPlane.re (g • z) - 1) ∧ UpperHalfPlane.re (g • z) - 1 < 0 ⊢ |UpperHalfPlane.re (g • z) - 1| < |UpperHalfPlane.re (g • z)| [PROOFSTEP] cases abs_cases (g • z).re [GOAL] case intro.intro.intro.right.right.inl.inl g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg₀' : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) hg' : 1 / 2 < UpperHalfPlane.re (g • z) h✝¹ : |UpperHalfPlane.re (g • z) - 1| = UpperHalfPlane.re (g • z) - 1 ∧ 0 ≤ UpperHalfPlane.re (g • z) - 1 h✝ : |UpperHalfPlane.re (g • z)| = UpperHalfPlane.re (g • z) ∧ 0 ≤ UpperHalfPlane.re (g • z) ⊢ |UpperHalfPlane.re (g • z) - 1| < |UpperHalfPlane.re (g • z)| [PROOFSTEP] linarith [GOAL] case intro.intro.intro.right.right.inl.inr g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg₀' : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) hg' : 1 / 2 < UpperHalfPlane.re (g • z) h✝¹ : |UpperHalfPlane.re (g • z) - 1| = UpperHalfPlane.re (g • z) - 1 ∧ 0 ≤ UpperHalfPlane.re (g • z) - 1 h✝ : |UpperHalfPlane.re (g • z)| = -UpperHalfPlane.re (g • z) ∧ UpperHalfPlane.re (g • z) < 0 ⊢ |UpperHalfPlane.re (g • z) - 1| < |UpperHalfPlane.re (g • z)| [PROOFSTEP] linarith [GOAL] case intro.intro.intro.right.right.inr.inl g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg₀' : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) hg' : 1 / 2 < UpperHalfPlane.re (g • z) h✝¹ : |UpperHalfPlane.re (g • z) - 1| = -(UpperHalfPlane.re (g • z) - 1) ∧ UpperHalfPlane.re (g • z) - 1 < 0 h✝ : |UpperHalfPlane.re (g • z)| = UpperHalfPlane.re (g • z) ∧ 0 ≤ UpperHalfPlane.re (g • z) ⊢ |UpperHalfPlane.re (g • z) - 1| < |UpperHalfPlane.re (g • z)| [PROOFSTEP] linarith [GOAL] case intro.intro.intro.right.right.inr.inr g✝ : SL(2, ℤ) z✝ z : ℍ g₀ : SL(2, ℤ) hg₀ : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g₀ • z) g : SL(2, ℤ) hg : ↑g 1 = ↑g₀ 1 hg₀' : ∀ (g' : SL(2, ℤ)), UpperHalfPlane.im (g' • z) ≤ UpperHalfPlane.im (g • z) hg' : 1 / 2 < UpperHalfPlane.re (g • z) h✝¹ : |UpperHalfPlane.re (g • z) - 1| = -(UpperHalfPlane.re (g • z) - 1) ∧ UpperHalfPlane.re (g • z) - 1 < 0 h✝ : |UpperHalfPlane.re (g • z)| = -UpperHalfPlane.re (g • z) ∧ UpperHalfPlane.re (g • z) < 0 ⊢ |UpperHalfPlane.re (g • z) - 1| < |UpperHalfPlane.re (g • z)| [PROOFSTEP] linarith [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ ⊢ |↑g 1 0| ≤ 1 [PROOFSTEP] let c' : ℤ := (↑ₘg) 1 0 [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 ⊢ |↑g 1 0| ≤ 1 [PROOFSTEP] let c : ℝ := (c' : ℝ) [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' ⊢ |↑g 1 0| ≤ 1 [PROOFSTEP] suffices 3 * c ^ 2 < 4 by rw [← Int.cast_pow, ← Int.cast_three, ← Int.cast_four, ← Int.cast_mul, Int.cast_lt] at this replace this : c' ^ 2 ≤ 1 ^ 2; · linarith rwa [sq_le_sq, abs_one] at this [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' this : 3 * c ^ 2 < 4 ⊢ |↑g 1 0| ≤ 1 [PROOFSTEP] rw [← Int.cast_pow, ← Int.cast_three, ← Int.cast_four, ← Int.cast_mul, Int.cast_lt] at this [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' this : 3 * c' ^ 2 < 4 ⊢ |↑g 1 0| ≤ 1 [PROOFSTEP] replace this : c' ^ 2 ≤ 1 ^ 2 [GOAL] case this g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' this : 3 * c' ^ 2 < 4 ⊢ c' ^ 2 ≤ 1 ^ 2 [PROOFSTEP] linarith [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' this : c' ^ 2 ≤ 1 ^ 2 ⊢ |↑g 1 0| ≤ 1 [PROOFSTEP] rwa [sq_le_sq, abs_one] at this [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' ⊢ 3 * c ^ 2 < 4 [PROOFSTEP] suffices c ≠ 0 → 9 * c ^ 4 < 16 by rcases eq_or_ne c 0 with (hc | hc) · rw [hc]; norm_num · refine' (abs_lt_of_sq_lt_sq' _ (by norm_num)).2 specialize this hc linarith [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' this : c ≠ 0 → 9 * c ^ 4 < 16 ⊢ 3 * c ^ 2 < 4 [PROOFSTEP] rcases eq_or_ne c 0 with (hc | hc) [GOAL] case inl g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' this : c ≠ 0 → 9 * c ^ 4 < 16 hc : c = 0 ⊢ 3 * c ^ 2 < 4 [PROOFSTEP] rw [hc] [GOAL] case inl g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' this : c ≠ 0 → 9 * c ^ 4 < 16 hc : c = 0 ⊢ 3 * 0 ^ 2 < 4 [PROOFSTEP] norm_num [GOAL] case inr g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' this : c ≠ 0 → 9 * c ^ 4 < 16 hc : c ≠ 0 ⊢ 3 * c ^ 2 < 4 [PROOFSTEP] refine' (abs_lt_of_sq_lt_sq' _ (by norm_num)).2 [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' this : c ≠ 0 → 9 * c ^ 4 < 16 hc : c ≠ 0 ⊢ 0 ≤ 4 [PROOFSTEP] norm_num [GOAL] case inr g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' this : c ≠ 0 → 9 * c ^ 4 < 16 hc : c ≠ 0 ⊢ (3 * c ^ 2) ^ 2 < 4 ^ 2 [PROOFSTEP] specialize this hc [GOAL] case inr g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' hc : c ≠ 0 this : 9 * c ^ 4 < 16 ⊢ (3 * c ^ 2) ^ 2 < 4 ^ 2 [PROOFSTEP] linarith [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' ⊢ c ≠ 0 → 9 * c ^ 4 < 16 [PROOFSTEP] intro hc [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' hc : c ≠ 0 ⊢ 9 * c ^ 4 < 16 [PROOFSTEP] replace hc : 0 < c ^ 4 [GOAL] case hc g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' hc : c ≠ 0 ⊢ 0 < c ^ 4 [PROOFSTEP] change 0 < c ^ (2 * 2) [GOAL] case hc g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' hc : c ≠ 0 ⊢ 0 < c ^ (2 * 2) [PROOFSTEP] rw [pow_mul] [GOAL] case hc g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' hc : c ≠ 0 ⊢ 0 < (c ^ 2) ^ 2 [PROOFSTEP] apply sq_pos_of_pos (sq_pos_of_ne_zero _ hc) [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' hc : 0 < c ^ 4 ⊢ 9 * c ^ 4 < 16 [PROOFSTEP] have h₁ := mul_lt_mul_of_pos_right (mul_lt_mul'' (three_lt_four_mul_im_sq_of_mem_fdo hg) (three_lt_four_mul_im_sq_of_mem_fdo hz) (by linarith) (by linarith)) hc [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' hc : 0 < c ^ 4 ⊢ 0 ≤ 3 [PROOFSTEP] linarith [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' hc : 0 < c ^ 4 ⊢ 0 ≤ 3 [PROOFSTEP] linarith [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' hc : 0 < c ^ 4 h₁ : 3 * 3 * c ^ 4 < 4 * UpperHalfPlane.im (g • z) ^ 2 * (4 * UpperHalfPlane.im z ^ 2) * c ^ 4 ⊢ 9 * c ^ 4 < 16 [PROOFSTEP] have h₂ : (c * z.im) ^ 4 / normSq (denom (↑g) z) ^ 2 ≤ 1 := div_le_one_of_le (pow_four_le_pow_two_of_pow_two_le (UpperHalfPlane.c_mul_im_sq_le_normSq_denom z g)) (sq_nonneg _) [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' hc : 0 < c ^ 4 h₁ : 3 * 3 * c ^ 4 < 4 * UpperHalfPlane.im (g • z) ^ 2 * (4 * UpperHalfPlane.im z ^ 2) * c ^ 4 h₂ : (c * UpperHalfPlane.im z) ^ 4 / ↑normSq (denom (↑g) z) ^ 2 ≤ 1 ⊢ 9 * c ^ 4 < 16 [PROOFSTEP] let nsq := normSq (denom g z) [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' hc : 0 < c ^ 4 h₁ : 3 * 3 * c ^ 4 < 4 * UpperHalfPlane.im (g • z) ^ 2 * (4 * UpperHalfPlane.im z ^ 2) * c ^ 4 h₂ : (c * UpperHalfPlane.im z) ^ 4 / ↑normSq (denom (↑g) z) ^ 2 ≤ 1 nsq : (fun x => ℝ) (denom (↑g) z) := ↑normSq (denom (↑g) z) ⊢ 9 * c ^ 4 < 16 [PROOFSTEP] calc 9 * c ^ 4 < c ^ 4 * z.im ^ 2 * (g • z).im ^ 2 * 16 := by linarith _ = c ^ 4 * z.im ^ 4 / nsq ^ 2 * 16 := by rw [SpecialLinearGroup.im_smul_eq_div_normSq, div_pow] ring _ ≤ 16 := by rw [← mul_pow]; linarith [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' hc : 0 < c ^ 4 h₁ : 3 * 3 * c ^ 4 < 4 * UpperHalfPlane.im (g • z) ^ 2 * (4 * UpperHalfPlane.im z ^ 2) * c ^ 4 h₂ : (c * UpperHalfPlane.im z) ^ 4 / ↑normSq (denom (↑g) z) ^ 2 ≤ 1 nsq : (fun x => ℝ) (denom (↑g) z) := ↑normSq (denom (↑g) z) ⊢ 9 * c ^ 4 < c ^ 4 * UpperHalfPlane.im z ^ 2 * UpperHalfPlane.im (g • z) ^ 2 * 16 [PROOFSTEP] linarith [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' hc : 0 < c ^ 4 h₁ : 3 * 3 * c ^ 4 < 4 * UpperHalfPlane.im (g • z) ^ 2 * (4 * UpperHalfPlane.im z ^ 2) * c ^ 4 h₂ : (c * UpperHalfPlane.im z) ^ 4 / ↑normSq (denom (↑g) z) ^ 2 ≤ 1 nsq : (fun x => ℝ) (denom (↑g) z) := ↑normSq (denom (↑g) z) ⊢ c ^ 4 * UpperHalfPlane.im z ^ 2 * UpperHalfPlane.im (g • z) ^ 2 * 16 = c ^ 4 * UpperHalfPlane.im z ^ 4 / nsq ^ 2 * 16 [PROOFSTEP] rw [SpecialLinearGroup.im_smul_eq_div_normSq, div_pow] [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' hc : 0 < c ^ 4 h₁ : 3 * 3 * c ^ 4 < 4 * UpperHalfPlane.im (g • z) ^ 2 * (4 * UpperHalfPlane.im z ^ 2) * c ^ 4 h₂ : (c * UpperHalfPlane.im z) ^ 4 / ↑normSq (denom (↑g) z) ^ 2 ≤ 1 nsq : (fun x => ℝ) (denom (↑g) z) := ↑normSq (denom (↑g) z) ⊢ c ^ 4 * UpperHalfPlane.im z ^ 2 * (UpperHalfPlane.im z ^ 2 / ↑normSq (denom (↑g) z) ^ 2) * 16 = c ^ 4 * UpperHalfPlane.im z ^ 4 / nsq ^ 2 * 16 [PROOFSTEP] ring [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' hc : 0 < c ^ 4 h₁ : 3 * 3 * c ^ 4 < 4 * UpperHalfPlane.im (g • z) ^ 2 * (4 * UpperHalfPlane.im z ^ 2) * c ^ 4 h₂ : (c * UpperHalfPlane.im z) ^ 4 / ↑normSq (denom (↑g) z) ^ 2 ≤ 1 nsq : (fun x => ℝ) (denom (↑g) z) := ↑normSq (denom (↑g) z) ⊢ c ^ 4 * UpperHalfPlane.im z ^ 4 / nsq ^ 2 * 16 ≤ 16 [PROOFSTEP] rw [← mul_pow] [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ c' : ℤ := ↑g 1 0 c : ℝ := ↑c' hc : 0 < c ^ 4 h₁ : 3 * 3 * c ^ 4 < 4 * UpperHalfPlane.im (g • z) ^ 2 * (4 * UpperHalfPlane.im z ^ 2) * c ^ 4 h₂ : (c * UpperHalfPlane.im z) ^ 4 / ↑normSq (denom (↑g) z) ^ 2 ≤ 1 nsq : (fun x => ℝ) (denom (↑g) z) := ↑normSq (denom (↑g) z) ⊢ (c * UpperHalfPlane.im z) ^ 4 / nsq ^ 2 * 16 ≤ 16 [PROOFSTEP] linarith [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ ⊢ ↑g 1 0 = 0 [PROOFSTEP] have hp : ∀ {g' : SL(2, ℤ)}, g' • z ∈ 𝒟ᵒ → (↑ₘg') 1 0 ≠ 1 := by intro g' hg' by_contra hc let a := (↑ₘg') 0 0 let d := (↑ₘg') 1 1 have had : T ^ (-a) * g' = S * T ^ d := by rw [g_eq_of_c_eq_one hc]; group let w := T ^ (-a) • g' • z have h₁ : w = S • T ^ d • z := by simp only [← mul_smul, had] replace h₁ : normSq w < 1 := h₁.symm ▸ normSq_S_smul_lt_one (one_lt_normSq_T_zpow_smul hz d) have h₂ : 1 < normSq w := one_lt_normSq_T_zpow_smul hg' (-a) linarith [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ ⊢ ∀ {g' : SL(2, ℤ)}, g' • z ∈ 𝒟ᵒ → ↑g' 1 0 ≠ 1 [PROOFSTEP] intro g' hg' [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ g' : SL(2, ℤ) hg' : g' • z ∈ 𝒟ᵒ ⊢ ↑g' 1 0 ≠ 1 [PROOFSTEP] by_contra hc [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ g' : SL(2, ℤ) hg' : g' • z ∈ 𝒟ᵒ hc : ↑g' 1 0 = 1 ⊢ False [PROOFSTEP] let a := (↑ₘg') 0 0 [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ g' : SL(2, ℤ) hg' : g' • z ∈ 𝒟ᵒ hc : ↑g' 1 0 = 1 a : ℤ := ↑g' 0 0 ⊢ False [PROOFSTEP] let d := (↑ₘg') 1 1 [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ g' : SL(2, ℤ) hg' : g' • z ∈ 𝒟ᵒ hc : ↑g' 1 0 = 1 a : ℤ := ↑g' 0 0 d : ℤ := ↑g' 1 1 ⊢ False [PROOFSTEP] have had : T ^ (-a) * g' = S * T ^ d := by rw [g_eq_of_c_eq_one hc]; group [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ g' : SL(2, ℤ) hg' : g' • z ∈ 𝒟ᵒ hc : ↑g' 1 0 = 1 a : ℤ := ↑g' 0 0 d : ℤ := ↑g' 1 1 ⊢ T ^ (-a) * g' = S * T ^ d [PROOFSTEP] rw [g_eq_of_c_eq_one hc] [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ g' : SL(2, ℤ) hg' : g' • z ∈ 𝒟ᵒ hc : ↑g' 1 0 = 1 a : ℤ := ↑g' 0 0 d : ℤ := ↑g' 1 1 ⊢ T ^ (-a) * (T ^ ↑g' 0 0 * S * T ^ ↑g' 1 1) = S * T ^ d [PROOFSTEP] group [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ g' : SL(2, ℤ) hg' : g' • z ∈ 𝒟ᵒ hc : ↑g' 1 0 = 1 a : ℤ := ↑g' 0 0 d : ℤ := ↑g' 1 1 had : T ^ (-a) * g' = S * T ^ d ⊢ False [PROOFSTEP] let w := T ^ (-a) • g' • z [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ g' : SL(2, ℤ) hg' : g' • z ∈ 𝒟ᵒ hc : ↑g' 1 0 = 1 a : ℤ := ↑g' 0 0 d : ℤ := ↑g' 1 1 had : T ^ (-a) * g' = S * T ^ d w : ℍ := T ^ (-a) • g' • z ⊢ False [PROOFSTEP] have h₁ : w = S • T ^ d • z := by simp only [← mul_smul, had] [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ g' : SL(2, ℤ) hg' : g' • z ∈ 𝒟ᵒ hc : ↑g' 1 0 = 1 a : ℤ := ↑g' 0 0 d : ℤ := ↑g' 1 1 had : T ^ (-a) * g' = S * T ^ d w : ℍ := T ^ (-a) • g' • z ⊢ w = S • T ^ d • z [PROOFSTEP] simp only [← mul_smul, had] [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ g' : SL(2, ℤ) hg' : g' • z ∈ 𝒟ᵒ hc : ↑g' 1 0 = 1 a : ℤ := ↑g' 0 0 d : ℤ := ↑g' 1 1 had : T ^ (-a) * g' = S * T ^ d w : ℍ := T ^ (-a) • g' • z h₁ : w = S • T ^ d • z ⊢ False [PROOFSTEP] replace h₁ : normSq w < 1 := h₁.symm ▸ normSq_S_smul_lt_one (one_lt_normSq_T_zpow_smul hz d) [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ g' : SL(2, ℤ) hg' : g' • z ∈ 𝒟ᵒ hc : ↑g' 1 0 = 1 a : ℤ := ↑g' 0 0 d : ℤ := ↑g' 1 1 had : T ^ (-a) * g' = S * T ^ d w : ℍ := T ^ (-a) • g' • z h₁ : ↑normSq ↑w < 1 ⊢ False [PROOFSTEP] have h₂ : 1 < normSq w := one_lt_normSq_T_zpow_smul hg' (-a) [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ g' : SL(2, ℤ) hg' : g' • z ∈ 𝒟ᵒ hc : ↑g' 1 0 = 1 a : ℤ := ↑g' 0 0 d : ℤ := ↑g' 1 1 had : T ^ (-a) * g' = S * T ^ d w : ℍ := T ^ (-a) • g' • z h₁ : ↑normSq ↑w < 1 h₂ : 1 < ↑normSq ↑w ⊢ False [PROOFSTEP] linarith [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ hp : ∀ {g' : SL(2, ℤ)}, g' • z ∈ 𝒟ᵒ → ↑g' 1 0 ≠ 1 ⊢ ↑g 1 0 = 0 [PROOFSTEP] have hn : (↑ₘg) 1 0 ≠ -1 := by intro hc replace hc : (↑ₘ(-g)) 1 0 = 1; · simp [← neg_eq_iff_eq_neg.mpr hc] replace hg : -g • z ∈ 𝒟ᵒ := (SL_neg_smul g z).symm ▸ hg exact hp hg hc [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ hp : ∀ {g' : SL(2, ℤ)}, g' • z ∈ 𝒟ᵒ → ↑g' 1 0 ≠ 1 ⊢ ↑g 1 0 ≠ -1 [PROOFSTEP] intro hc [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ hp : ∀ {g' : SL(2, ℤ)}, g' • z ∈ 𝒟ᵒ → ↑g' 1 0 ≠ 1 hc : ↑g 1 0 = -1 ⊢ False [PROOFSTEP] replace hc : (↑ₘ(-g)) 1 0 = 1 [GOAL] case hc g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ hp : ∀ {g' : SL(2, ℤ)}, g' • z ∈ 𝒟ᵒ → ↑g' 1 0 ≠ 1 hc : ↑g 1 0 = -1 ⊢ (-↑g) 1 0 = 1 [PROOFSTEP] simp [← neg_eq_iff_eq_neg.mpr hc] [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ hp : ∀ {g' : SL(2, ℤ)}, g' • z ∈ 𝒟ᵒ → ↑g' 1 0 ≠ 1 hc : (-↑g) 1 0 = 1 ⊢ False [PROOFSTEP] replace hg : -g • z ∈ 𝒟ᵒ := (SL_neg_smul g z).symm ▸ hg [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hp : ∀ {g' : SL(2, ℤ)}, g' • z ∈ 𝒟ᵒ → ↑g' 1 0 ≠ 1 hc : (-↑g) 1 0 = 1 hg : -g • z ∈ 𝒟ᵒ ⊢ False [PROOFSTEP] exact hp hg hc [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ hp : ∀ {g' : SL(2, ℤ)}, g' • z ∈ 𝒟ᵒ → ↑g' 1 0 ≠ 1 hn : ↑g 1 0 ≠ -1 ⊢ ↑g 1 0 = 0 [PROOFSTEP] specialize hp hg [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ hn : ↑g 1 0 ≠ -1 hp : ↑g 1 0 ≠ 1 ⊢ ↑g 1 0 = 0 [PROOFSTEP] rcases Int.abs_le_one_iff.mp <| abs_c_le_one hz hg with ⟨⟩ [GOAL] case inl g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ hn : ↑g 1 0 ≠ -1 hp : ↑g 1 0 ≠ 1 h✝ : ↑g 1 0 = 0 ⊢ ↑g 1 0 = 0 [PROOFSTEP] tauto [GOAL] case inr g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ hn : ↑g 1 0 ≠ -1 hp : ↑g 1 0 ≠ 1 h✝ : ↑g 1 0 = 1 ∨ ↑g 1 0 = -1 ⊢ ↑g 1 0 = 0 [PROOFSTEP] tauto [GOAL] g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ ⊢ z = g • z [PROOFSTEP] obtain ⟨n, hn⟩ := exists_eq_T_zpow_of_c_eq_zero (c_eq_zero hz hg) [GOAL] case intro g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ hg : g • z ∈ 𝒟ᵒ n : ℤ hn : ∀ (z : ℍ), g • z = T ^ n • z ⊢ z = g • z [PROOFSTEP] rw [hn] at hg ⊢ [GOAL] case intro g : SL(2, ℤ) z : ℍ hz : z ∈ 𝒟ᵒ n : ℤ hg : T ^ n • z ∈ 𝒟ᵒ hn : ∀ (z : ℍ), g • z = T ^ n • z ⊢ z = T ^ n • z [PROOFSTEP] simp [eq_zero_of_mem_fdo_of_T_zpow_mem_fdo hz hg, one_smul]
import Lean.Parser.Command open Lean open Lean.Parser def testParser (input : String) : IO Unit := do env ← mkEmptyEnvironment; cmdPTables ← builtinCommandParsingTable.get; stx ← IO.ofExcept $ runParser env cmdPTables input "<input>" "command"; IO.println stx def test (is : List String) : IO Unit := is.mfor $ fun input => do IO.println input; testParser input def main (xs : List String) : IO Unit := do IO.println Command.declaration.info.firstTokens; test [ "@[inline] def x := 2", "protected def length.{u} {α : Type u} : List α → Nat | [] := 0 | (a::as) := 1 + length as", "/-- doc string test -/ private theorem bla (x : Nat) : x = x := Eq.refl x", "class Alternative (f : Type u → Type v) extends Applicative f : Type (max (u+1) v) := (failure : ∀ {α : Type u}, f α) (orelse : ∀ {α : Type u}, f α → f α → f α) ", "local attribute [instance] foo bla", "attribute [inline] test", "open Lean (hiding Name)", "reserve infixr ` ∨ `:30", "reserve prefix `¬`:40", "infixr ` ^ ` := Pow.pow", "notation f ` $ `:1 a:0 := f a", "notation `Prop` := Sort 0", "notation `∅` := EmptyCollection.emptyc _", "notation `⟦`:max a `⟧`:0 := Quotient.mk a" ]
/- Copyright (c) 2021 OpenAI. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kunhao Zheng, Stanislas Polu, David Renshaw, OpenAI GPT-f -/ import mathzoo.imports.miniF2F open_locale nat rat real big_operators topological_space theorem amc12a_2008_p2 (x : ℝ) (h₀ : x * (1 / 2 + 2 / 3) = 1) : x = 6 / 7 := begin linarith, end
import os import shutil from flask import Flask,request,render_template,Blueprint import torch import torch.nn as nn from flask_cors import CORS import base64 import numpy as np from io import BytesIO # custom package #import src.predict as predict import models.pneumonia.src.predict as predict #pneapp = Flask(__name__) pneapp=Blueprint("pneapp",__name__,template_folder="templates",static_folder="static") CORS(pneapp) @pneapp.route("/", methods=["GET","POST"]) def index(): if request.method=="POST": image_file=request.files["file"] if image_file: npimg = np.fromstring(image_file.read(),np.uint8) classifier=predict.predict_img(npimg) result,img=classifier.predict_pneumonia() byteIO = BytesIO() img.save(byteIO, format="JPEG") img_base64 = base64.b64encode(byteIO.getvalue()).decode('ascii') mime = "image/jpeg" uri = "data:%s;base64,%s"%(mime, img_base64) return render_template('/pneindex.html',resultt=result,image_loc=uri) return render_template('/pneindex.html',resultt=None,image_loc=None) # if __name__ == '__main__': # pneapp.run(debug=True,port=3000)
import data.real.cardinality -- The Non-Denumerability of the Continuum open set lemma t022 : ¬ countable (set.univ : set ℝ) := cardinal.not_countable_real
{-# OPTIONS --allow-unsolved-metas --no-positivity-check --no-termination-check --type-in-type --sized-types --injective-type-constructors --guardedness-preserving-type-constructors --experimental-irrelevance #-} module SafeFlagPragmas where
lemma reflect_poly_reflect_poly [simp]: "coeff p 0 \<noteq> 0 \<Longrightarrow> reflect_poly (reflect_poly p) = p"
4 beds 2 Bathrooms 3072 Sq.Ft. From Alex., Cty Rd 82 to Barrett Rd (#8) to just over I-94 turn left on Tall Timbers Rd to home on left. Follow signs.
[GOAL] K : Type u V : Type v inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V V₂ : Type v' inst✝³ : AddCommGroup V₂ inst✝² : Module K V₂ inst✝¹ : _root_.Finite K inst✝ : FiniteDimensional K V ⊢ _root_.Finite V [PROOFSTEP] cases nonempty_fintype K [GOAL] case intro K : Type u V : Type v inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V V₂ : Type v' inst✝³ : AddCommGroup V₂ inst✝² : Module K V₂ inst✝¹ : _root_.Finite K inst✝ : FiniteDimensional K V val✝ : Fintype K ⊢ _root_.Finite V [PROOFSTEP] haveI := fintypeOfFintype K V [GOAL] case intro K : Type u V : Type v inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V V₂ : Type v' inst✝³ : AddCommGroup V₂ inst✝² : Module K V₂ inst✝¹ : _root_.Finite K inst✝ : FiniteDimensional K V val✝ : Fintype K this : Fintype V ⊢ _root_.Finite V [PROOFSTEP] infer_instance [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type w inst✝ : _root_.Finite ι h : Basis ι K V ⊢ FiniteDimensional K V [PROOFSTEP] classical cases nonempty_fintype ι exact ⟨⟨Finset.univ.image h, by convert h.span_eq simp⟩⟩ [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type w inst✝ : _root_.Finite ι h : Basis ι K V ⊢ FiniteDimensional K V [PROOFSTEP] cases nonempty_fintype ι [GOAL] case intro K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type w inst✝ : _root_.Finite ι h : Basis ι K V val✝ : Fintype ι ⊢ FiniteDimensional K V [PROOFSTEP] exact ⟨⟨Finset.univ.image h, by convert h.span_eq simp⟩⟩ [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type w inst✝ : _root_.Finite ι h : Basis ι K V val✝ : Fintype ι ⊢ span K ↑(Finset.image (↑h) Finset.univ) = ⊤ [PROOFSTEP] convert h.span_eq [GOAL] case h.e'_2.h.e'_6 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type w inst✝ : _root_.Finite ι h : Basis ι K V val✝ : Fintype ι ⊢ ↑(Finset.image (↑h) Finset.univ) = Set.range ↑h [PROOFSTEP] simp [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V ⊢ Fintype ↑(Basis.ofVectorSpaceIndex K V) [PROOFSTEP] letI : IsNoetherian K V := IsNoetherian.iff_fg.2 inferInstance [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V this : IsNoetherian K V := Iff.mpr iff_fg inferInstance ⊢ Fintype ↑(Basis.ofVectorSpaceIndex K V) [PROOFSTEP] infer_instance [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V S : Submodule K V ⊢ FiniteDimensional K { x // x ∈ S } [PROOFSTEP] letI : IsNoetherian K V := iff_fg.2 ?_ [GOAL] case refine_2 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V S : Submodule K V this : IsNoetherian K V := Iff.mpr iff_fg ?refine_1 ⊢ FiniteDimensional K { x // x ∈ S } case refine_1 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V S : Submodule K V ⊢ Module.Finite K V [PROOFSTEP] exact iff_fg.1 (IsNoetherian.iff_rank_lt_aleph0.2 (lt_of_le_of_lt (rank_submodule_le _) (rank_lt_aleph0 K V))) [GOAL] case refine_1 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V S : Submodule K V ⊢ Module.Finite K V [PROOFSTEP] infer_instance [GOAL] K : Type u V : Type v inst✝⁴ : DivisionRing K inst✝³ : AddCommGroup V inst✝² : Module K V V₂ : Type v' inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ h : 0 < finrank K V ⊢ FiniteDimensional K V [PROOFSTEP] contrapose h [GOAL] K : Type u V : Type v inst✝⁴ : DivisionRing K inst✝³ : AddCommGroup V inst✝² : Module K V V₂ : Type v' inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ h : ¬FiniteDimensional K V ⊢ ¬0 < finrank K V [PROOFSTEP] simp [finrank_of_infinite_dimensional h] [GOAL] K : Type u V : Type v inst✝⁴ : DivisionRing K inst✝³ : AddCommGroup V inst✝² : Module K V V₂ : Type v' inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ n : ℕ hn : finrank K V = Nat.succ n ⊢ 0 < finrank K V [PROOFSTEP] rw [hn] [GOAL] K : Type u V : Type v inst✝⁴ : DivisionRing K inst✝³ : AddCommGroup V inst✝² : Module K V V₂ : Type v' inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ n : ℕ hn : finrank K V = Nat.succ n ⊢ 0 < Nat.succ n [PROOFSTEP] exact n.succ_pos [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ n : ℕ inst✝ : Fact (finrank K V = n + 1) ⊢ 0 < finrank K V [PROOFSTEP] convert Nat.succ_pos n [GOAL] case h.e'_4 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ n : ℕ inst✝ : Fact (finrank K V = n + 1) ⊢ finrank K V = Nat.succ n [PROOFSTEP] apply Fact.out [GOAL] K : Type u V : Type v inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V V₂ : Type v' inst✝³ : AddCommGroup V₂ inst✝² : Module K V₂ W : Type v inst✝¹ : AddCommGroup W inst✝ : Module K W n : ℕ hn : n ≠ 0 hVW : Module.rank K V = n • Module.rank K W ⊢ FiniteDimensional K V ↔ FiniteDimensional K W [PROOFSTEP] simp only [FiniteDimensional, ← IsNoetherian.iff_fg, IsNoetherian.iff_rank_lt_aleph0, hVW, Cardinal.nsmul_lt_aleph0_iff_of_ne_zero hn] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V ι : Type w h : Basis ι K V ⊢ ↑(finrank K V) = #ι [PROOFSTEP] haveI : IsNoetherian K V := iff_fg.2 inferInstance [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V ι : Type w h : Basis ι K V this : IsNoetherian K V ⊢ ↑(finrank K V) = #ι [PROOFSTEP] haveI : Fintype ι := fintypeBasisIndex h [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V ι : Type w h : Basis ι K V this✝ : IsNoetherian K V this : Fintype ι ⊢ ↑(finrank K V) = #ι [PROOFSTEP] rw [Cardinal.mk_fintype, finrank_eq_card_basis h] [GOAL] K : Type u V : Type v inst✝⁴ : DivisionRing K inst✝³ : AddCommGroup V inst✝² : Module K V V₂ : Type v' inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ ι : Type u_1 b : Basis ι K K ⊢ Unique ι [PROOFSTEP] have A : Cardinal.mk ι = ↑(FiniteDimensional.finrank K K) := (FiniteDimensional.finrank_eq_card_basis' b).symm [GOAL] K : Type u V : Type v inst✝⁴ : DivisionRing K inst✝³ : AddCommGroup V inst✝² : Module K V V₂ : Type v' inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ ι : Type u_1 b : Basis ι K K A : #ι = ↑(finrank K K) ⊢ Unique ι [PROOFSTEP] simp only [Cardinal.eq_one_iff_unique, FiniteDimensional.finrank_self, Nat.cast_one] at A [GOAL] K : Type u V : Type v inst✝⁴ : DivisionRing K inst✝³ : AddCommGroup V inst✝² : Module K V V₂ : Type v' inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ ι : Type u_1 b : Basis ι K K A : Subsingleton ι ∧ Nonempty ι ⊢ Unique ι [PROOFSTEP] exact Nonempty.some ((unique_iff_subsingleton_and_nonempty _).2 A) [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type u_1 inst✝ : Unique ι h : finrank K V = 1 v : V i : ι hv : v = 0 ⊢ ↑(↑(basisUnique ι h).repr v) i = 0 [PROOFSTEP] rw [hv, LinearEquiv.map_zero, Finsupp.zero_apply] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V ι : Type w b : ι → V h : LinearIndependent K b ⊢ #ι ≤ ↑(finrank K V) [PROOFSTEP] rw [← lift_le.{max v w}] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V ι : Type w b : ι → V h : LinearIndependent K b ⊢ lift #ι ≤ lift ↑(finrank K V) [PROOFSTEP] simpa [← finrank_eq_rank', -finrank_eq_rank] using cardinal_lift_le_rank_of_linearIndependent h [GOAL] K : Type u V : Type v inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V V₂ : Type v' inst✝³ : AddCommGroup V₂ inst✝² : Module K V₂ inst✝¹ : FiniteDimensional K V ι : Type u_1 inst✝ : Fintype ι b : ι → V h : LinearIndependent K b ⊢ Fintype.card ι ≤ finrank K V [PROOFSTEP] simpa using cardinal_mk_le_finrank_of_linearIndependent h [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V b : Finset V h : LinearIndependent K fun x => ↑x ⊢ Finset.card b ≤ finrank K V [PROOFSTEP] rw [← Fintype.card_coe] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V b : Finset V h : LinearIndependent K fun x => ↑x ⊢ Fintype.card { x // x ∈ b } ≤ finrank K V [PROOFSTEP] exact fintype_card_le_finrank_of_linearIndependent h [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type w inst✝ : FiniteDimensional K V v : ι → V h : LinearIndependent K v ⊢ #ι < ℵ₀ [PROOFSTEP] apply Cardinal.lift_lt.1 [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type w inst✝ : FiniteDimensional K V v : ι → V h : LinearIndependent K v ⊢ lift #ι < lift ℵ₀ [PROOFSTEP] apply lt_of_le_of_lt [GOAL] case a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type w inst✝ : FiniteDimensional K V v : ι → V h : LinearIndependent K v ⊢ lift #ι ≤ ?b case a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type w inst✝ : FiniteDimensional K V v : ι → V h : LinearIndependent K v ⊢ ?b < lift ℵ₀ case b K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type w inst✝ : FiniteDimensional K V v : ι → V h : LinearIndependent K v ⊢ Cardinal.{max w ?u.252424} [PROOFSTEP] apply cardinal_lift_le_rank_of_linearIndependent h [GOAL] case a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type w inst✝ : FiniteDimensional K V v : ι → V h : LinearIndependent K v ⊢ lift (Module.rank K V) < lift ℵ₀ [PROOFSTEP] rw [← finrank_eq_rank, Cardinal.lift_aleph0, Cardinal.lift_natCast] [GOAL] case a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type w inst✝ : FiniteDimensional K V v : ι → V h : LinearIndependent K v ⊢ ↑(finrank K V) < ℵ₀ [PROOFSTEP] apply Cardinal.nat_lt_aleph0 [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type w inf : Infinite ι inst✝ : FiniteDimensional K V v : ι → V ⊢ ¬LinearIndependent K v [PROOFSTEP] intro h_lin_indep [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type w inf : Infinite ι inst✝ : FiniteDimensional K V v : ι → V h_lin_indep : LinearIndependent K v ⊢ False [PROOFSTEP] have : ¬ℵ₀ ≤ #ι := not_le.mpr (lt_aleph0_of_linearIndependent h_lin_indep) [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type w inf : Infinite ι inst✝ : FiniteDimensional K V v : ι → V h_lin_indep : LinearIndependent K v this : ¬ℵ₀ ≤ #ι ⊢ False [PROOFSTEP] have : ℵ₀ ≤ #ι := infinite_iff.mp inf [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type w inf : Infinite ι inst✝ : FiniteDimensional K V v : ι → V h_lin_indep : LinearIndependent K v this✝ : ¬ℵ₀ ≤ #ι this : ℵ₀ ≤ #ι ⊢ False [PROOFSTEP] contradiction [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V ⊢ 0 < finrank K V ↔ 0 < Module.rank K V [PROOFSTEP] rw [← finrank_eq_rank] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V ⊢ 0 < finrank K V ↔ 0 < ↑(finrank K V) [PROOFSTEP] norm_cast [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V ⊢ 0 < finrank K V ↔ 0 < Module.rank K V [PROOFSTEP] rw [← finrank_eq_rank] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V ⊢ 0 < finrank K V ↔ 0 < ↑(finrank K V) [PROOFSTEP] norm_cast [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V ⊢ finrank K V = 0 ↔ Module.rank K V = 0 [PROOFSTEP] rw [← finrank_eq_rank] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V ⊢ finrank K V = 0 ↔ ↑(finrank K V) = 0 [PROOFSTEP] norm_cast [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V S : Submodule K V h : finrank K { x // x ∈ S } = finrank K V ⊢ S = ⊤ [PROOFSTEP] haveI : IsNoetherian K V := iff_fg.2 inferInstance [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V S : Submodule K V h : finrank K { x // x ∈ S } = finrank K V this : IsNoetherian K V ⊢ S = ⊤ [PROOFSTEP] set bS := Basis.ofVectorSpace K S with bS_eq [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V S : Submodule K V h : finrank K { x // x ∈ S } = finrank K V this : IsNoetherian K V bS : Basis (↑(Basis.ofVectorSpaceIndex K { x // x ∈ S })) K { x // x ∈ S } := Basis.ofVectorSpace K { x // x ∈ S } bS_eq : bS = Basis.ofVectorSpace K { x // x ∈ S } ⊢ S = ⊤ [PROOFSTEP] have : LinearIndependent K ((↑) : ((↑) '' Basis.ofVectorSpaceIndex K S : Set V) → V) := @LinearIndependent.image_subtype _ _ _ _ _ _ _ _ _ (Submodule.subtype S) (by simpa using bS.linearIndependent) (by simp) [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V S : Submodule K V h : finrank K { x // x ∈ S } = finrank K V this : IsNoetherian K V bS : Basis (↑(Basis.ofVectorSpaceIndex K { x // x ∈ S })) K { x // x ∈ S } := Basis.ofVectorSpace K { x // x ∈ S } bS_eq : bS = Basis.ofVectorSpace K { x // x ∈ S } ⊢ LinearIndependent K fun x => ↑x [PROOFSTEP] simpa using bS.linearIndependent [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V S : Submodule K V h : finrank K { x // x ∈ S } = finrank K V this : IsNoetherian K V bS : Basis (↑(Basis.ofVectorSpaceIndex K { x // x ∈ S })) K { x // x ∈ S } := Basis.ofVectorSpace K { x // x ∈ S } bS_eq : bS = Basis.ofVectorSpace K { x // x ∈ S } ⊢ Disjoint (span K (Basis.ofVectorSpaceIndex K { x // x ∈ S })) (LinearMap.ker (Submodule.subtype S)) [PROOFSTEP] simp [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V S : Submodule K V h : finrank K { x // x ∈ S } = finrank K V this✝ : IsNoetherian K V bS : Basis (↑(Basis.ofVectorSpaceIndex K { x // x ∈ S })) K { x // x ∈ S } := Basis.ofVectorSpace K { x // x ∈ S } bS_eq : bS = Basis.ofVectorSpace K { x // x ∈ S } this : LinearIndependent K Subtype.val ⊢ S = ⊤ [PROOFSTEP] set b := Basis.extend this with b_eq [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V S : Submodule K V h : finrank K { x // x ∈ S } = finrank K V this✝ : IsNoetherian K V bS : Basis (↑(Basis.ofVectorSpaceIndex K { x // x ∈ S })) K { x // x ∈ S } := Basis.ofVectorSpace K { x // x ∈ S } bS_eq : bS = Basis.ofVectorSpace K { x // x ∈ S } this : LinearIndependent K Subtype.val b : Basis (↑(LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ))) K V := Basis.extend this b_eq : b = Basis.extend this ⊢ S = ⊤ [PROOFSTEP] letI i1 : Fintype (this.extend _) := (finite_of_linearIndependent (by simpa using b.linearIndependent)).fintype [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V S : Submodule K V h : finrank K { x // x ∈ S } = finrank K V this✝ : IsNoetherian K V bS : Basis (↑(Basis.ofVectorSpaceIndex K { x // x ∈ S })) K { x // x ∈ S } := Basis.ofVectorSpace K { x // x ∈ S } bS_eq : bS = Basis.ofVectorSpace K { x // x ∈ S } this : LinearIndependent K Subtype.val b : Basis (↑(LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ))) K V := Basis.extend this b_eq : b = Basis.extend this ⊢ LinearIndependent ?m.281540 Subtype.val [PROOFSTEP] simpa using b.linearIndependent [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V S : Submodule K V h : finrank K { x // x ∈ S } = finrank K V this✝ : IsNoetherian K V bS : Basis (↑(Basis.ofVectorSpaceIndex K { x // x ∈ S })) K { x // x ∈ S } := Basis.ofVectorSpace K { x // x ∈ S } bS_eq : bS = Basis.ofVectorSpace K { x // x ∈ S } this : LinearIndependent K Subtype.val b : Basis (↑(LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ))) K V := Basis.extend this b_eq : b = Basis.extend this i1 : Fintype ↑(LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ)) := Set.Finite.fintype (_ : Set.Finite (LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ))) ⊢ S = ⊤ [PROOFSTEP] letI i2 : Fintype (((↑) : S → V) '' Basis.ofVectorSpaceIndex K S) := (finite_of_linearIndependent this).fintype [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V S : Submodule K V h : finrank K { x // x ∈ S } = finrank K V this✝ : IsNoetherian K V bS : Basis (↑(Basis.ofVectorSpaceIndex K { x // x ∈ S })) K { x // x ∈ S } := Basis.ofVectorSpace K { x // x ∈ S } bS_eq : bS = Basis.ofVectorSpace K { x // x ∈ S } this : LinearIndependent K Subtype.val b : Basis (↑(LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ))) K V := Basis.extend this b_eq : b = Basis.extend this i1 : Fintype ↑(LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ)) := Set.Finite.fintype (_ : Set.Finite (LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ))) i2 : Fintype ↑(Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S }) := Set.Finite.fintype (_ : Set.Finite (Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S })) ⊢ S = ⊤ [PROOFSTEP] letI i3 : Fintype (Basis.ofVectorSpaceIndex K S) := (finite_of_linearIndependent (by simpa using bS.linearIndependent)).fintype [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V S : Submodule K V h : finrank K { x // x ∈ S } = finrank K V this✝ : IsNoetherian K V bS : Basis (↑(Basis.ofVectorSpaceIndex K { x // x ∈ S })) K { x // x ∈ S } := Basis.ofVectorSpace K { x // x ∈ S } bS_eq : bS = Basis.ofVectorSpace K { x // x ∈ S } this : LinearIndependent K Subtype.val b : Basis (↑(LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ))) K V := Basis.extend this b_eq : b = Basis.extend this i1 : Fintype ↑(LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ)) := Set.Finite.fintype (_ : Set.Finite (LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ))) i2 : Fintype ↑(Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S }) := Set.Finite.fintype (_ : Set.Finite (Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S })) ⊢ LinearIndependent ?m.287044 Subtype.val [PROOFSTEP] simpa using bS.linearIndependent [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V S : Submodule K V h : finrank K { x // x ∈ S } = finrank K V this✝ : IsNoetherian K V bS : Basis (↑(Basis.ofVectorSpaceIndex K { x // x ∈ S })) K { x // x ∈ S } := Basis.ofVectorSpace K { x // x ∈ S } bS_eq : bS = Basis.ofVectorSpace K { x // x ∈ S } this : LinearIndependent K Subtype.val b : Basis (↑(LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ))) K V := Basis.extend this b_eq : b = Basis.extend this i1 : Fintype ↑(LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ)) := Set.Finite.fintype (_ : Set.Finite (LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ))) i2 : Fintype ↑(Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S }) := Set.Finite.fintype (_ : Set.Finite (Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S })) i3 : Fintype ↑(Basis.ofVectorSpaceIndex K { x // x ∈ S }) := Set.Finite.fintype (_ : Set.Finite (Basis.ofVectorSpaceIndex K { x // x ∈ S })) ⊢ S = ⊤ [PROOFSTEP] have : (↑) '' Basis.ofVectorSpaceIndex K S = this.extend (Set.subset_univ _) := Set.eq_of_subset_of_card_le (this.subset_extend _) (by rw [Set.card_image_of_injective _ Subtype.coe_injective, ← finrank_eq_card_basis bS, ← finrank_eq_card_basis b, h]) [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V S : Submodule K V h : finrank K { x // x ∈ S } = finrank K V this✝ : IsNoetherian K V bS : Basis (↑(Basis.ofVectorSpaceIndex K { x // x ∈ S })) K { x // x ∈ S } := Basis.ofVectorSpace K { x // x ∈ S } bS_eq : bS = Basis.ofVectorSpace K { x // x ∈ S } this : LinearIndependent K Subtype.val b : Basis (↑(LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ))) K V := Basis.extend this b_eq : b = Basis.extend this i1 : Fintype ↑(LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ)) := Set.Finite.fintype (_ : Set.Finite (LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ))) i2 : Fintype ↑(Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S }) := Set.Finite.fintype (_ : Set.Finite (Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S })) i3 : Fintype ↑(Basis.ofVectorSpaceIndex K { x // x ∈ S }) := Set.Finite.fintype (_ : Set.Finite (Basis.ofVectorSpaceIndex K { x // x ∈ S })) ⊢ Fintype.card ↑(LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ)) ≤ Fintype.card ↑(Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S }) [PROOFSTEP] rw [Set.card_image_of_injective _ Subtype.coe_injective, ← finrank_eq_card_basis bS, ← finrank_eq_card_basis b, h] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V S : Submodule K V h : finrank K { x // x ∈ S } = finrank K V this✝¹ : IsNoetherian K V bS : Basis (↑(Basis.ofVectorSpaceIndex K { x // x ∈ S })) K { x // x ∈ S } := Basis.ofVectorSpace K { x // x ∈ S } bS_eq : bS = Basis.ofVectorSpace K { x // x ∈ S } this✝ : LinearIndependent K Subtype.val b : Basis (↑(LinearIndependent.extend this✝ (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ))) K V := Basis.extend this✝ b_eq : b = Basis.extend this✝ i1 : Fintype ↑(LinearIndependent.extend this✝ (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ)) := Set.Finite.fintype (_ : Set.Finite (LinearIndependent.extend this✝ (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ))) i2 : Fintype ↑(Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S }) := Set.Finite.fintype (_ : Set.Finite (Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S })) i3 : Fintype ↑(Basis.ofVectorSpaceIndex K { x // x ∈ S }) := Set.Finite.fintype (_ : Set.Finite (Basis.ofVectorSpaceIndex K { x // x ∈ S })) this : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } = LinearIndependent.extend this✝ (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ) ⊢ S = ⊤ [PROOFSTEP] rw [← b.span_eq, b_eq, Basis.coe_extend, Subtype.range_coe, ← this, ← Submodule.coeSubtype, span_image] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V S : Submodule K V h : finrank K { x // x ∈ S } = finrank K V this✝¹ : IsNoetherian K V bS : Basis (↑(Basis.ofVectorSpaceIndex K { x // x ∈ S })) K { x // x ∈ S } := Basis.ofVectorSpace K { x // x ∈ S } bS_eq : bS = Basis.ofVectorSpace K { x // x ∈ S } this✝ : LinearIndependent K Subtype.val b : Basis (↑(LinearIndependent.extend this✝ (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ))) K V := Basis.extend this✝ b_eq : b = Basis.extend this✝ i1 : Fintype ↑(LinearIndependent.extend this✝ (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ)) := Set.Finite.fintype (_ : Set.Finite (LinearIndependent.extend this✝ (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ))) i2 : Fintype ↑(Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S }) := Set.Finite.fintype (_ : Set.Finite (Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S })) i3 : Fintype ↑(Basis.ofVectorSpaceIndex K { x // x ∈ S }) := Set.Finite.fintype (_ : Set.Finite (Basis.ofVectorSpaceIndex K { x // x ∈ S })) this : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } = LinearIndependent.extend this✝ (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ) ⊢ S = Submodule.map (Submodule.subtype S) (span K (Basis.ofVectorSpaceIndex K { x // x ∈ S })) [PROOFSTEP] have := bS.span_eq [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V S : Submodule K V h : finrank K { x // x ∈ S } = finrank K V this✝² : IsNoetherian K V bS : Basis (↑(Basis.ofVectorSpaceIndex K { x // x ∈ S })) K { x // x ∈ S } := Basis.ofVectorSpace K { x // x ∈ S } bS_eq : bS = Basis.ofVectorSpace K { x // x ∈ S } this✝¹ : LinearIndependent K Subtype.val b : Basis (↑(LinearIndependent.extend this✝¹ (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ))) K V := Basis.extend this✝¹ b_eq : b = Basis.extend this✝¹ i1 : Fintype ↑(LinearIndependent.extend this✝¹ (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ)) := Set.Finite.fintype (_ : Set.Finite (LinearIndependent.extend this✝¹ (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ))) i2 : Fintype ↑(Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S }) := Set.Finite.fintype (_ : Set.Finite (Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S })) i3 : Fintype ↑(Basis.ofVectorSpaceIndex K { x // x ∈ S }) := Set.Finite.fintype (_ : Set.Finite (Basis.ofVectorSpaceIndex K { x // x ∈ S })) this✝ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } = LinearIndependent.extend this✝¹ (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ) this : span K (Set.range ↑bS) = ⊤ ⊢ S = Submodule.map (Submodule.subtype S) (span K (Basis.ofVectorSpaceIndex K { x // x ∈ S })) [PROOFSTEP] rw [bS_eq, Basis.coe_ofVectorSpace, Subtype.range_coe] at this [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V S : Submodule K V h : finrank K { x // x ∈ S } = finrank K V this✝² : IsNoetherian K V bS : Basis (↑(Basis.ofVectorSpaceIndex K { x // x ∈ S })) K { x // x ∈ S } := Basis.ofVectorSpace K { x // x ∈ S } bS_eq : bS = Basis.ofVectorSpace K { x // x ∈ S } this✝¹ : LinearIndependent K Subtype.val b : Basis (↑(LinearIndependent.extend this✝¹ (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ))) K V := Basis.extend this✝¹ b_eq : b = Basis.extend this✝¹ i1 : Fintype ↑(LinearIndependent.extend this✝¹ (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ)) := Set.Finite.fintype (_ : Set.Finite (LinearIndependent.extend this✝¹ (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ))) i2 : Fintype ↑(Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S }) := Set.Finite.fintype (_ : Set.Finite (Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S })) i3 : Fintype ↑(Basis.ofVectorSpaceIndex K { x // x ∈ S }) := Set.Finite.fintype (_ : Set.Finite (Basis.ofVectorSpaceIndex K { x // x ∈ S })) this✝ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } = LinearIndependent.extend this✝¹ (_ : Subtype.val '' Basis.ofVectorSpaceIndex K { x // x ∈ S } ⊆ Set.univ) this : span K (Basis.ofVectorSpaceIndex K { x // x ∈ S }) = ⊤ ⊢ S = Submodule.map (Submodule.subtype S) (span K (Basis.ofVectorSpaceIndex K { x // x ∈ S })) [PROOFSTEP] rw [this, map_top (Submodule.subtype S), range_subtype] [GOAL] K : Type u V : Type v inst✝⁴ : DivisionRing K inst✝³ : AddCommGroup V inst✝² : Module K V V₂ : Type v' inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ ⊢ FiniteDimensional K K [PROOFSTEP] infer_instance [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V ι : Type w p : ι → Submodule K V hp : CompleteLattice.Independent p ⊢ #{ i // p i ≠ ⊥ } ≤ ↑(finrank K V) [PROOFSTEP] suffices Cardinal.lift.{v} #{ i // p i ≠ ⊥ } ≤ Cardinal.lift.{v} (finrank K V : Cardinal.{w}) by rwa [Cardinal.lift_le] at this [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V ι : Type w p : ι → Submodule K V hp : CompleteLattice.Independent p this : lift #{ i // p i ≠ ⊥ } ≤ lift ↑(finrank K V) ⊢ #{ i // p i ≠ ⊥ } ≤ ↑(finrank K V) [PROOFSTEP] rwa [Cardinal.lift_le] at this [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V ι : Type w p : ι → Submodule K V hp : CompleteLattice.Independent p ⊢ lift #{ i // p i ≠ ⊥ } ≤ lift ↑(finrank K V) [PROOFSTEP] calc Cardinal.lift.{v} #{ i // p i ≠ ⊥ } ≤ Cardinal.lift.{w} (Module.rank K V) := hp.subtype_ne_bot_le_rank _ = Cardinal.lift.{w} (finrank K V : Cardinal.{v}) := by rw [finrank_eq_rank] _ = Cardinal.lift.{v} (finrank K V : Cardinal.{w}) := by simp [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V ι : Type w p : ι → Submodule K V hp : CompleteLattice.Independent p ⊢ lift (Module.rank K V) = lift ↑(finrank K V) [PROOFSTEP] rw [finrank_eq_rank] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V ι : Type w p : ι → Submodule K V hp : CompleteLattice.Independent p ⊢ lift ↑(finrank K V) = lift ↑(finrank K V) [PROOFSTEP] simp [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V ι : Type w p : ι → Submodule K V hp : CompleteLattice.Independent p ⊢ Fintype { i // p i ≠ ⊥ } [PROOFSTEP] suffices #{ i // p i ≠ ⊥ } < (ℵ₀ : Cardinal.{w}) by rw [Cardinal.lt_aleph0_iff_fintype] at this exact this.some [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V ι : Type w p : ι → Submodule K V hp : CompleteLattice.Independent p this : #{ i // p i ≠ ⊥ } < ℵ₀ ⊢ Fintype { i // p i ≠ ⊥ } [PROOFSTEP] rw [Cardinal.lt_aleph0_iff_fintype] at this [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V ι : Type w p : ι → Submodule K V hp : CompleteLattice.Independent p this : Nonempty (Fintype { i // p i ≠ ⊥ }) ⊢ Fintype { i // p i ≠ ⊥ } [PROOFSTEP] exact this.some [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V ι : Type w p : ι → Submodule K V hp : CompleteLattice.Independent p ⊢ #{ i // p i ≠ ⊥ } < ℵ₀ [PROOFSTEP] refine' lt_of_le_of_lt hp.subtype_ne_bot_le_finrank_aux _ [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V ι : Type w p : ι → Submodule K V hp : CompleteLattice.Independent p ⊢ ↑(finrank K V) < ℵ₀ [PROOFSTEP] simp [Cardinal.nat_lt_aleph0] [GOAL] K : Type u V : Type v inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V V₂ : Type v' inst✝³ : AddCommGroup V₂ inst✝² : Module K V₂ inst✝¹ : FiniteDimensional K V ι : Type w p : ι → Submodule K V hp : CompleteLattice.Independent p inst✝ : Fintype { i // p i ≠ ⊥ } ⊢ Fintype.card { i // p i ≠ ⊥ } ≤ finrank K V [PROOFSTEP] simpa using hp.subtype_ne_bot_le_finrank_aux [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t ⊢ ∃ f, ∑ e in t, f e • e = 0 ∧ ∃ x, x ∈ t ∧ f x ≠ 0 [PROOFSTEP] classical have := mt finset_card_le_finrank_of_linearIndependent (by simpa using h) rw [not_linearIndependent_iff] at this obtain ⟨s, g, sum, z, zm, nonzero⟩ := this let f : V → K := fun x => if h : x ∈ t then if (⟨x, h⟩ : t) ∈ s then g ⟨x, h⟩ else 0 else 0 -- and finally clean up the mess caused by the extension. refine' ⟨f, _, _⟩ · dsimp rw [← (sum)] -- porting note: need parens to disambiguate fapply sum_bij_ne_zero fun v hvt _ => (⟨v, hvt⟩ : { v // v ∈ t }) · intro v hvt H dsimp rw [dif_pos hvt] at H contrapose! H rw [if_neg H, zero_smul] · intro _ _ _ _ _ _ exact Subtype.mk.inj · intro b hbs hb use b simpa only [hbs, exists_prop, dif_pos, Finset.mk_coe, and_true_iff, if_true, Finset.coe_mem, eq_self_iff_true, exists_prop_of_true, Ne.def] using hb · intro a h₁ dsimp rw [dif_pos h₁] intro h₂ rw [if_pos] contrapose! h₂ rw [if_neg h₂, zero_smul] · refine' ⟨z, z.2, _⟩ dsimp only erw [dif_pos z.2, if_pos] <;> rwa [Subtype.coe_eta] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t ⊢ ∃ f, ∑ e in t, f e • e = 0 ∧ ∃ x, x ∈ t ∧ f x ≠ 0 [PROOFSTEP] have := mt finset_card_le_finrank_of_linearIndependent (by simpa using h) [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t ⊢ ¬card ?m.337366 ≤ finrank ?m.337360 ?m.337361 [PROOFSTEP] simpa using h [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t this : ¬LinearIndependent K fun x => ↑x ⊢ ∃ f, ∑ e in t, f e • e = 0 ∧ ∃ x, x ∈ t ∧ f x ≠ 0 [PROOFSTEP] rw [not_linearIndependent_iff] at this [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t this : ∃ s g, ∑ i in s, g i • ↑i = 0 ∧ ∃ i, i ∈ s ∧ g i ≠ 0 ⊢ ∃ f, ∑ e in t, f e • e = 0 ∧ ∃ x, x ∈ t ∧ f x ≠ 0 [PROOFSTEP] obtain ⟨s, g, sum, z, zm, nonzero⟩ := this [GOAL] case intro.intro.intro.intro.intro K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t s : Finset { x // x ∈ t } g : { x // x ∈ t } → K sum : ∑ i in s, g i • ↑i = 0 z : { x // x ∈ t } zm : z ∈ s nonzero : g z ≠ 0 ⊢ ∃ f, ∑ e in t, f e • e = 0 ∧ ∃ x, x ∈ t ∧ f x ≠ 0 [PROOFSTEP] let f : V → K := fun x => if h : x ∈ t then if (⟨x, h⟩ : t) ∈ s then g ⟨x, h⟩ else 0 else 0 -- and finally clean up the mess caused by the extension. [GOAL] case intro.intro.intro.intro.intro K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t s : Finset { x // x ∈ t } g : { x // x ∈ t } → K sum : ∑ i in s, g i • ↑i = 0 z : { x // x ∈ t } zm : z ∈ s nonzero : g z ≠ 0 f : V → K := fun x => if h : x ∈ t then if { val := x, property := h } ∈ s then g { val := x, property := h } else 0 else 0 ⊢ ∃ f, ∑ e in t, f e • e = 0 ∧ ∃ x, x ∈ t ∧ f x ≠ 0 [PROOFSTEP] refine' ⟨f, _, _⟩ [GOAL] case intro.intro.intro.intro.intro.refine'_1 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t s : Finset { x // x ∈ t } g : { x // x ∈ t } → K sum : ∑ i in s, g i • ↑i = 0 z : { x // x ∈ t } zm : z ∈ s nonzero : g z ≠ 0 f : V → K := fun x => if h : x ∈ t then if { val := x, property := h } ∈ s then g { val := x, property := h } else 0 else 0 ⊢ ∑ e in t, f e • e = 0 [PROOFSTEP] dsimp [GOAL] case intro.intro.intro.intro.intro.refine'_1 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t s : Finset { x // x ∈ t } g : { x // x ∈ t } → K sum : ∑ i in s, g i • ↑i = 0 z : { x // x ∈ t } zm : z ∈ s nonzero : g z ≠ 0 f : V → K := fun x => if h : x ∈ t then if { val := x, property := h } ∈ s then g { val := x, property := h } else 0 else 0 ⊢ ∑ e in t, (if h : e ∈ t then if { val := e, property := h } ∈ s then g { val := e, property := h } else 0 else 0) • e = 0 [PROOFSTEP] rw [← (sum)] -- porting note: need parens to disambiguate [GOAL] case intro.intro.intro.intro.intro.refine'_1 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t s : Finset { x // x ∈ t } g : { x // x ∈ t } → K sum : ∑ i in s, g i • ↑i = 0 z : { x // x ∈ t } zm : z ∈ s nonzero : g z ≠ 0 f : V → K := fun x => if h : x ∈ t then if { val := x, property := h } ∈ s then g { val := x, property := h } else 0 else 0 ⊢ ∑ e in t, (if h : e ∈ t then if { val := e, property := h } ∈ s then g { val := e, property := h } else 0 else 0) • e = ∑ i in s, g i • ↑i [PROOFSTEP] fapply sum_bij_ne_zero fun v hvt _ => (⟨v, hvt⟩ : { v // v ∈ t }) [GOAL] case intro.intro.intro.intro.intro.refine'_1.hi K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t s : Finset { x // x ∈ t } g : { x // x ∈ t } → K sum : ∑ i in s, g i • ↑i = 0 z : { x // x ∈ t } zm : z ∈ s nonzero : g z ≠ 0 f : V → K := fun x => if h : x ∈ t then if { val := x, property := h } ∈ s then g { val := x, property := h } else 0 else 0 ⊢ ∀ (a : V) (h₁ : a ∈ t), (if h : a ∈ t then if { val := a, property := h } ∈ s then g { val := a, property := h } else 0 else 0) • a ≠ 0 → { val := a, property := h₁ } ∈ s [PROOFSTEP] intro v hvt H [GOAL] case intro.intro.intro.intro.intro.refine'_1.hi K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t s : Finset { x // x ∈ t } g : { x // x ∈ t } → K sum : ∑ i in s, g i • ↑i = 0 z : { x // x ∈ t } zm : z ∈ s nonzero : g z ≠ 0 f : V → K := fun x => if h : x ∈ t then if { val := x, property := h } ∈ s then g { val := x, property := h } else 0 else 0 v : V hvt : v ∈ t H : (if h : v ∈ t then if { val := v, property := h } ∈ s then g { val := v, property := h } else 0 else 0) • v ≠ 0 ⊢ { val := v, property := hvt } ∈ s [PROOFSTEP] dsimp [GOAL] case intro.intro.intro.intro.intro.refine'_1.hi K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t s : Finset { x // x ∈ t } g : { x // x ∈ t } → K sum : ∑ i in s, g i • ↑i = 0 z : { x // x ∈ t } zm : z ∈ s nonzero : g z ≠ 0 f : V → K := fun x => if h : x ∈ t then if { val := x, property := h } ∈ s then g { val := x, property := h } else 0 else 0 v : V hvt : v ∈ t H : (if h : v ∈ t then if { val := v, property := h } ∈ s then g { val := v, property := h } else 0 else 0) • v ≠ 0 ⊢ { val := v, property := hvt } ∈ s [PROOFSTEP] rw [dif_pos hvt] at H [GOAL] case intro.intro.intro.intro.intro.refine'_1.hi K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t s : Finset { x // x ∈ t } g : { x // x ∈ t } → K sum : ∑ i in s, g i • ↑i = 0 z : { x // x ∈ t } zm : z ∈ s nonzero : g z ≠ 0 f : V → K := fun x => if h : x ∈ t then if { val := x, property := h } ∈ s then g { val := x, property := h } else 0 else 0 v : V hvt : v ∈ t H : (if { val := v, property := hvt } ∈ s then g { val := v, property := hvt } else 0) • v ≠ 0 ⊢ { val := v, property := hvt } ∈ s [PROOFSTEP] contrapose! H [GOAL] case intro.intro.intro.intro.intro.refine'_1.hi K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t s : Finset { x // x ∈ t } g : { x // x ∈ t } → K sum : ∑ i in s, g i • ↑i = 0 z : { x // x ∈ t } zm : z ∈ s nonzero : g z ≠ 0 f : V → K := fun x => if h : x ∈ t then if { val := x, property := h } ∈ s then g { val := x, property := h } else 0 else 0 v : V hvt : v ∈ t H : ¬{ val := v, property := hvt } ∈ s ⊢ (if { val := v, property := hvt } ∈ s then g { val := v, property := hvt } else 0) • v = 0 [PROOFSTEP] rw [if_neg H, zero_smul] [GOAL] case intro.intro.intro.intro.intro.refine'_1.i_inj K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t s : Finset { x // x ∈ t } g : { x // x ∈ t } → K sum : ∑ i in s, g i • ↑i = 0 z : { x // x ∈ t } zm : z ∈ s nonzero : g z ≠ 0 f : V → K := fun x => if h : x ∈ t then if { val := x, property := h } ∈ s then g { val := x, property := h } else 0 else 0 ⊢ ∀ (a₁ a₂ : V) (h₁₁ : a₁ ∈ t), (if h : a₁ ∈ t then if { val := a₁, property := h } ∈ s then g { val := a₁, property := h } else 0 else 0) • a₁ ≠ 0 → ∀ (h₂₁ : a₂ ∈ t), (if h : a₂ ∈ t then if { val := a₂, property := h } ∈ s then g { val := a₂, property := h } else 0 else 0) • a₂ ≠ 0 → { val := a₁, property := h₁₁ } = { val := a₂, property := h₂₁ } → a₁ = a₂ [PROOFSTEP] intro _ _ _ _ _ _ [GOAL] case intro.intro.intro.intro.intro.refine'_1.i_inj K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t s : Finset { x // x ∈ t } g : { x // x ∈ t } → K sum : ∑ i in s, g i • ↑i = 0 z : { x // x ∈ t } zm : z ∈ s nonzero : g z ≠ 0 f : V → K := fun x => if h : x ∈ t then if { val := x, property := h } ∈ s then g { val := x, property := h } else 0 else 0 a₁✝ a₂✝ : V h₁₁✝ : a₁✝ ∈ t h₁₂✝ : (if h : a₁✝ ∈ t then if { val := a₁✝, property := h } ∈ s then g { val := a₁✝, property := h } else 0 else 0) • a₁✝ ≠ 0 h₂₁✝ : a₂✝ ∈ t h₂₂✝ : (if h : a₂✝ ∈ t then if { val := a₂✝, property := h } ∈ s then g { val := a₂✝, property := h } else 0 else 0) • a₂✝ ≠ 0 ⊢ { val := a₁✝, property := h₁₁✝ } = { val := a₂✝, property := h₂₁✝ } → a₁✝ = a₂✝ [PROOFSTEP] exact Subtype.mk.inj [GOAL] case intro.intro.intro.intro.intro.refine'_1.i_surj K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t s : Finset { x // x ∈ t } g : { x // x ∈ t } → K sum : ∑ i in s, g i • ↑i = 0 z : { x // x ∈ t } zm : z ∈ s nonzero : g z ≠ 0 f : V → K := fun x => if h : x ∈ t then if { val := x, property := h } ∈ s then g { val := x, property := h } else 0 else 0 ⊢ ∀ (b : { v // v ∈ t }), b ∈ s → g b • ↑b ≠ 0 → ∃ a h₁ h₂, b = { val := a, property := h₁ } [PROOFSTEP] intro b hbs hb [GOAL] case intro.intro.intro.intro.intro.refine'_1.i_surj K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t s : Finset { x // x ∈ t } g : { x // x ∈ t } → K sum : ∑ i in s, g i • ↑i = 0 z : { x // x ∈ t } zm : z ∈ s nonzero : g z ≠ 0 f : V → K := fun x => if h : x ∈ t then if { val := x, property := h } ∈ s then g { val := x, property := h } else 0 else 0 b : { v // v ∈ t } hbs : b ∈ s hb : g b • ↑b ≠ 0 ⊢ ∃ a h₁ h₂, b = { val := a, property := h₁ } [PROOFSTEP] use b [GOAL] case h K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t s : Finset { x // x ∈ t } g : { x // x ∈ t } → K sum : ∑ i in s, g i • ↑i = 0 z : { x // x ∈ t } zm : z ∈ s nonzero : g z ≠ 0 f : V → K := fun x => if h : x ∈ t then if { val := x, property := h } ∈ s then g { val := x, property := h } else 0 else 0 b : { v // v ∈ t } hbs : b ∈ s hb : g b • ↑b ≠ 0 ⊢ ∃ h₁ h₂, b = { val := ↑b, property := h₁ } [PROOFSTEP] simpa only [hbs, exists_prop, dif_pos, Finset.mk_coe, and_true_iff, if_true, Finset.coe_mem, eq_self_iff_true, exists_prop_of_true, Ne.def] using hb [GOAL] case intro.intro.intro.intro.intro.refine'_1.h K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t s : Finset { x // x ∈ t } g : { x // x ∈ t } → K sum : ∑ i in s, g i • ↑i = 0 z : { x // x ∈ t } zm : z ∈ s nonzero : g z ≠ 0 f : V → K := fun x => if h : x ∈ t then if { val := x, property := h } ∈ s then g { val := x, property := h } else 0 else 0 ⊢ ∀ (a : V) (h₁ : a ∈ t), (if h : a ∈ t then if { val := a, property := h } ∈ s then g { val := a, property := h } else 0 else 0) • a ≠ 0 → (if h : a ∈ t then if { val := a, property := h } ∈ s then g { val := a, property := h } else 0 else 0) • a = g { val := a, property := h₁ } • ↑{ val := a, property := h₁ } [PROOFSTEP] intro a h₁ [GOAL] case intro.intro.intro.intro.intro.refine'_1.h K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t s : Finset { x // x ∈ t } g : { x // x ∈ t } → K sum : ∑ i in s, g i • ↑i = 0 z : { x // x ∈ t } zm : z ∈ s nonzero : g z ≠ 0 f : V → K := fun x => if h : x ∈ t then if { val := x, property := h } ∈ s then g { val := x, property := h } else 0 else 0 a : V h₁ : a ∈ t ⊢ (if h : a ∈ t then if { val := a, property := h } ∈ s then g { val := a, property := h } else 0 else 0) • a ≠ 0 → (if h : a ∈ t then if { val := a, property := h } ∈ s then g { val := a, property := h } else 0 else 0) • a = g { val := a, property := h₁ } • ↑{ val := a, property := h₁ } [PROOFSTEP] dsimp [GOAL] case intro.intro.intro.intro.intro.refine'_1.h K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t s : Finset { x // x ∈ t } g : { x // x ∈ t } → K sum : ∑ i in s, g i • ↑i = 0 z : { x // x ∈ t } zm : z ∈ s nonzero : g z ≠ 0 f : V → K := fun x => if h : x ∈ t then if { val := x, property := h } ∈ s then g { val := x, property := h } else 0 else 0 a : V h₁ : a ∈ t ⊢ ¬(if h : a ∈ t then if { val := a, property := h } ∈ s then g { val := a, property := h } else 0 else 0) • a = 0 → (if h : a ∈ t then if { val := a, property := h } ∈ s then g { val := a, property := h } else 0 else 0) • a = g { val := a, property := h₁ } • a [PROOFSTEP] rw [dif_pos h₁] [GOAL] case intro.intro.intro.intro.intro.refine'_1.h K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t s : Finset { x // x ∈ t } g : { x // x ∈ t } → K sum : ∑ i in s, g i • ↑i = 0 z : { x // x ∈ t } zm : z ∈ s nonzero : g z ≠ 0 f : V → K := fun x => if h : x ∈ t then if { val := x, property := h } ∈ s then g { val := x, property := h } else 0 else 0 a : V h₁ : a ∈ t ⊢ ¬(if { val := a, property := h₁ } ∈ s then g { val := a, property := h₁ } else 0) • a = 0 → (if { val := a, property := h₁ } ∈ s then g { val := a, property := h₁ } else 0) • a = g { val := a, property := h₁ } • a [PROOFSTEP] intro h₂ [GOAL] case intro.intro.intro.intro.intro.refine'_1.h K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t s : Finset { x // x ∈ t } g : { x // x ∈ t } → K sum : ∑ i in s, g i • ↑i = 0 z : { x // x ∈ t } zm : z ∈ s nonzero : g z ≠ 0 f : V → K := fun x => if h : x ∈ t then if { val := x, property := h } ∈ s then g { val := x, property := h } else 0 else 0 a : V h₁ : a ∈ t h₂ : ¬(if { val := a, property := h₁ } ∈ s then g { val := a, property := h₁ } else 0) • a = 0 ⊢ (if { val := a, property := h₁ } ∈ s then g { val := a, property := h₁ } else 0) • a = g { val := a, property := h₁ } • a [PROOFSTEP] rw [if_pos] [GOAL] case intro.intro.intro.intro.intro.refine'_1.h.hc K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t s : Finset { x // x ∈ t } g : { x // x ∈ t } → K sum : ∑ i in s, g i • ↑i = 0 z : { x // x ∈ t } zm : z ∈ s nonzero : g z ≠ 0 f : V → K := fun x => if h : x ∈ t then if { val := x, property := h } ∈ s then g { val := x, property := h } else 0 else 0 a : V h₁ : a ∈ t h₂ : ¬(if { val := a, property := h₁ } ∈ s then g { val := a, property := h₁ } else 0) • a = 0 ⊢ { val := a, property := h₁ } ∈ s [PROOFSTEP] contrapose! h₂ [GOAL] case intro.intro.intro.intro.intro.refine'_1.h.hc K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t s : Finset { x // x ∈ t } g : { x // x ∈ t } → K sum : ∑ i in s, g i • ↑i = 0 z : { x // x ∈ t } zm : z ∈ s nonzero : g z ≠ 0 f : V → K := fun x => if h : x ∈ t then if { val := x, property := h } ∈ s then g { val := x, property := h } else 0 else 0 a : V h₁ : a ∈ t h₂ : ¬{ val := a, property := h₁ } ∈ s ⊢ (if { val := a, property := h₁ } ∈ s then g { val := a, property := h₁ } else 0) • a = 0 [PROOFSTEP] rw [if_neg h₂, zero_smul] [GOAL] case intro.intro.intro.intro.intro.refine'_2 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t s : Finset { x // x ∈ t } g : { x // x ∈ t } → K sum : ∑ i in s, g i • ↑i = 0 z : { x // x ∈ t } zm : z ∈ s nonzero : g z ≠ 0 f : V → K := fun x => if h : x ∈ t then if { val := x, property := h } ∈ s then g { val := x, property := h } else 0 else 0 ⊢ ∃ x, x ∈ t ∧ f x ≠ 0 [PROOFSTEP] refine' ⟨z, z.2, _⟩ [GOAL] case intro.intro.intro.intro.intro.refine'_2 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t s : Finset { x // x ∈ t } g : { x // x ∈ t } → K sum : ∑ i in s, g i • ↑i = 0 z : { x // x ∈ t } zm : z ∈ s nonzero : g z ≠ 0 f : V → K := fun x => if h : x ∈ t then if { val := x, property := h } ∈ s then g { val := x, property := h } else 0 else 0 ⊢ f ↑z ≠ 0 [PROOFSTEP] dsimp only [GOAL] case intro.intro.intro.intro.intro.refine'_2 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t s : Finset { x // x ∈ t } g : { x // x ∈ t } → K sum : ∑ i in s, g i • ↑i = 0 z : { x // x ∈ t } zm : z ∈ s nonzero : g z ≠ 0 f : V → K := fun x => if h : x ∈ t then if { val := x, property := h } ∈ s then g { val := x, property := h } else 0 else 0 ⊢ (if h : ↑z ∈ t then if { val := ↑z, property := h } ∈ s then g { val := ↑z, property := h } else 0 else 0) ≠ 0 [PROOFSTEP] erw [dif_pos z.2, if_pos] [GOAL] case intro.intro.intro.intro.intro.refine'_2 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t s : Finset { x // x ∈ t } g : { x // x ∈ t } → K sum : ∑ i in s, g i • ↑i = 0 z : { x // x ∈ t } zm : z ∈ s nonzero : g z ≠ 0 f : V → K := fun x => if h : x ∈ t then if { val := x, property := h } ∈ s then g { val := x, property := h } else 0 else 0 ⊢ g { val := ↑z, property := (_ : ↑z ∈ t) } ≠ 0 [PROOFSTEP] rwa [Subtype.coe_eta] [GOAL] case intro.intro.intro.intro.intro.refine'_2.hc K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V < card t s : Finset { x // x ∈ t } g : { x // x ∈ t } → K sum : ∑ i in s, g i • ↑i = 0 z : { x // x ∈ t } zm : z ∈ s nonzero : g z ≠ 0 f : V → K := fun x => if h : x ∈ t then if { val := x, property := h } ∈ s then g { val := x, property := h } else 0 else 0 ⊢ { val := ↑z, property := (_ : ↑z ∈ t) } ∈ s [PROOFSTEP] rwa [Subtype.coe_eta] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t ⊢ ∃ f, ∑ e in t, f e • e = 0 ∧ ∑ e in t, f e = 0 ∧ ∃ x, x ∈ t ∧ f x ≠ 0 [PROOFSTEP] classical -- Pick an element x₀ ∈ t, have card_pos : 0 < t.card := lt_trans (Nat.succ_pos _) h obtain ⟨x₀, m⟩ := (Finset.card_pos.1 card_pos).bex let shift : V ↪ V := ⟨fun x => x - x₀, sub_left_injective⟩ let t' := (t.erase x₀).map shift have h' : finrank K V < t'.card := by simp only [card_map, Finset.card_erase_of_mem m] exact Nat.lt_pred_iff.mpr h obtain ⟨g, gsum, x₁, x₁_mem, nz⟩ := exists_nontrivial_relation_of_rank_lt_card h' let f : V → K := fun z => if z = x₀ then -∑ z in t.erase x₀, g (z - x₀) else g (z - x₀) refine' ⟨f, _, _, _⟩ -- After this, it's a matter of verifying the properties, -- based on the corresponding properties for `g`. · show (∑ e : V in t, f e • e) = 0 -- We prove this by splitting off the `x₀` term of the sum, -- which is itself a sum over `t.erase x₀`, -- combining the two sums, and -- observing that after reindexing we have exactly -- ∑ (x : V) in t', g x • x = 0. simp only conv_lhs => apply_congr rfl rw [ite_smul] rw [Finset.sum_ite] conv => congr congr apply_congr -- Porting note: the next two steps used to work by `simp [filter_eq', m]` erw [filter_eq'] simp [m] conv => congr congr rfl apply_congr simp [filter_ne'] rw [sum_singleton, neg_smul, add_comm, ← sub_eq_add_neg, sum_smul, ← sum_sub_distrib] simp only [← smul_sub] -- At the end we have to reindex the sum, so we use `change` to -- express the summand using `shift`. change (∑ x : V in t.erase x₀, (fun e => g e • e) (shift x)) = 0 -- porting note: last argument can't be inferred rw [← sum_map _ shift (fun e => g e • e)] exact gsum · show (∑ e : V in t, f e) = 0 -- Again we split off the `x₀` term, -- observing that it exactly cancels the other terms. rw [← insert_erase m, sum_insert (not_mem_erase x₀ t)] dsimp rw [if_pos rfl] conv_lhs => congr rfl apply_congr rfl rw [if_neg (show _ ≠ x₀ from (mem_erase.mp ‹_›).1)] exact neg_add_self _ · show ∃ (x : V), x ∈ t ∧ f x ≠ 0 -- We can use x₁ + x₀. refine' ⟨x₁ + x₀, _, _⟩ · rw [Finset.mem_map] at x₁_mem rcases x₁_mem with ⟨x₁, x₁_mem, rfl⟩ rw [mem_erase] at x₁_mem simp only [x₁_mem, sub_add_cancel, Function.Embedding.coeFn_mk] · dsimp only rwa [if_neg, add_sub_cancel] rw [add_left_eq_self] rintro rfl simp only [sub_eq_zero, exists_prop, Finset.mem_map, Embedding.coeFn_mk, eq_self_iff_true, mem_erase, not_true, exists_eq_right, Ne.def, false_and_iff] at x₁_mem [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t ⊢ ∃ f, ∑ e in t, f e • e = 0 ∧ ∑ e in t, f e = 0 ∧ ∃ x, x ∈ t ∧ f x ≠ 0 [PROOFSTEP] have card_pos : 0 < t.card := lt_trans (Nat.succ_pos _) h [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t ⊢ ∃ f, ∑ e in t, f e • e = 0 ∧ ∑ e in t, f e = 0 ∧ ∃ x, x ∈ t ∧ f x ≠ 0 [PROOFSTEP] obtain ⟨x₀, m⟩ := (Finset.card_pos.1 card_pos).bex [GOAL] case intro K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t ⊢ ∃ f, ∑ e in t, f e • e = 0 ∧ ∑ e in t, f e = 0 ∧ ∃ x, x ∈ t ∧ f x ≠ 0 [PROOFSTEP] let shift : V ↪ V := ⟨fun x => x - x₀, sub_left_injective⟩ [GOAL] case intro K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } ⊢ ∃ f, ∑ e in t, f e • e = 0 ∧ ∑ e in t, f e = 0 ∧ ∃ x, x ∈ t ∧ f x ≠ 0 [PROOFSTEP] let t' := (t.erase x₀).map shift [GOAL] case intro K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) ⊢ ∃ f, ∑ e in t, f e • e = 0 ∧ ∑ e in t, f e = 0 ∧ ∃ x, x ∈ t ∧ f x ≠ 0 [PROOFSTEP] have h' : finrank K V < t'.card := by simp only [card_map, Finset.card_erase_of_mem m] exact Nat.lt_pred_iff.mpr h [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) ⊢ finrank K V < card t' [PROOFSTEP] simp only [card_map, Finset.card_erase_of_mem m] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) ⊢ finrank K V < card t - 1 [PROOFSTEP] exact Nat.lt_pred_iff.mpr h [GOAL] case intro K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' ⊢ ∃ f, ∑ e in t, f e • e = 0 ∧ ∑ e in t, f e = 0 ∧ ∃ x, x ∈ t ∧ f x ≠ 0 [PROOFSTEP] obtain ⟨g, gsum, x₁, x₁_mem, nz⟩ := exists_nontrivial_relation_of_rank_lt_card h' [GOAL] case intro.intro.intro.intro.intro K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 ⊢ ∃ f, ∑ e in t, f e • e = 0 ∧ ∑ e in t, f e = 0 ∧ ∃ x, x ∈ t ∧ f x ≠ 0 [PROOFSTEP] let f : V → K := fun z => if z = x₀ then -∑ z in t.erase x₀, g (z - x₀) else g (z - x₀) [GOAL] case intro.intro.intro.intro.intro K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ ∃ f, ∑ e in t, f e • e = 0 ∧ ∑ e in t, f e = 0 ∧ ∃ x, x ∈ t ∧ f x ≠ 0 [PROOFSTEP] refine' ⟨f, _, _, _⟩ -- After this, it's a matter of verifying the properties, -- based on the corresponding properties for `g`. [GOAL] case intro.intro.intro.intro.intro.refine'_1 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ ∑ e in t, f e • e = 0 [PROOFSTEP] show (∑ e : V in t, f e • e) = 0 -- We prove this by splitting off the `x₀` term of the sum, -- which is itself a sum over `t.erase x₀`, -- combining the two sums, and -- observing that after reindexing we have exactly -- ∑ (x : V) in t', g x • x = 0. [GOAL] case intro.intro.intro.intro.intro.refine'_1 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ ∑ e in t, f e • e = 0 [PROOFSTEP] simp only [GOAL] case intro.intro.intro.intro.intro.refine'_1 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ ∑ x in t, (if x = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (x - x₀)) • x = 0 [PROOFSTEP] conv_lhs => apply_congr rfl rw [ite_smul] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | ∑ x in t, (if x = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (x - x₀)) • x [PROOFSTEP] apply_congr rfl rw [ite_smul] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | ∑ x in t, (if x = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (x - x₀)) • x [PROOFSTEP] apply_congr rfl rw [ite_smul] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | ∑ x in t, (if x = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (x - x₀)) • x [PROOFSTEP] apply_congr [GOAL] case h K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ t = ?s₂ case a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) x✝ : V a✝ : x✝ ∈ ?s₂ ⊢ (if x✝ = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (x✝ - x₀)) • x✝ = ?g x✝ [PROOFSTEP] rfl [GOAL] case a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) x✝ : V a✝ : x✝ ∈ t ⊢ (if x✝ = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (x✝ - x₀)) • x✝ = ?g x✝ [PROOFSTEP] rw [ite_smul] [GOAL] case intro.intro.intro.intro.intro.refine'_1 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ (∑ x in t, if x = x₀ then (-∑ z in erase t x₀, g (z - x₀)) • x else g (x - x₀) • x) = 0 [PROOFSTEP] rw [Finset.sum_ite] [GOAL] case intro.intro.intro.intro.intro.refine'_1 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ ∑ x in filter (fun x => x = x₀) t, (-∑ z in erase t x₀, g (z - x₀)) • x + ∑ x in filter (fun x => ¬x = x₀) t, g (x - x₀) • x = 0 [PROOFSTEP] conv => congr congr apply_congr -- Porting note: the next two steps used to work by `simp [filter_eq', m]` erw [filter_eq'] simp [m] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | ∑ x in filter (fun x => x = x₀) t, (-∑ z in erase t x₀, g (z - x₀)) • x + ∑ x in filter (fun x => ¬x = x₀) t, g (x - x₀) • x = 0 [PROOFSTEP] congr congr apply_congr -- Porting note: the next two steps used to work by `simp [filter_eq', m]` erw [filter_eq'] simp [m] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | ∑ x in filter (fun x => x = x₀) t, (-∑ z in erase t x₀, g (z - x₀)) • x + ∑ x in filter (fun x => ¬x = x₀) t, g (x - x₀) • x = 0 [PROOFSTEP] congr congr apply_congr -- Porting note: the next two steps used to work by `simp [filter_eq', m]` erw [filter_eq'] simp [m] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | ∑ x in filter (fun x => x = x₀) t, (-∑ z in erase t x₀, g (z - x₀)) • x + ∑ x in filter (fun x => ¬x = x₀) t, g (x - x₀) • x = 0 [PROOFSTEP] congr [GOAL] case a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | ∑ x in filter (fun x => x = x₀) t, (-∑ z in erase t x₀, g (z - x₀)) • x + ∑ x in filter (fun x => ¬x = x₀) t, g (x - x₀) • x case a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | 0 [PROOFSTEP] congr [GOAL] case a.a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | ∑ x in filter (fun x => x = x₀) t, (-∑ z in erase t x₀, g (z - x₀)) • x case a.a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | ∑ x in filter (fun x => ¬x = x₀) t, g (x - x₀) • x case a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | 0 [PROOFSTEP] apply_congr -- Porting note: the next two steps used to work by `simp [filter_eq', m]` [GOAL] case a.a.h K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ filter (fun x => x = x₀) t = ?a.a.s₂ case a.a.a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) x✝ : V a✝ : x✝ ∈ ?a.a.s₂ ⊢ (-∑ z in erase t x₀, g (z - x₀)) • x✝ = ?a.a.g x✝ case a.a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | ∑ x in filter (fun x => ¬x = x₀) t, g (x - x₀) • x case a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | 0 [PROOFSTEP] erw [filter_eq'] [GOAL] case a.a.h K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | if x₀ ∈ t then {x₀} else ∅ case a.a.a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) x✝ : V a✝ : x✝ ∈ ?a.a.s₂ ⊢ (-∑ z in erase t x₀, g (z - x₀)) • x✝ = ?a.a.g x✝ case a.a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | ∑ x in filter (fun x => ¬x = x₀) t, g (x - x₀) • x case a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | 0 [PROOFSTEP] simp [m] [GOAL] case intro.intro.intro.intro.intro.refine'_1 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ ∑ x in {x₀}, (-∑ z in erase t x₀, g (z - x₀)) • x + ∑ x in filter (fun x => ¬x = x₀) t, g (x - x₀) • x = 0 [PROOFSTEP] conv => congr congr rfl apply_congr simp [filter_ne'] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | ∑ x in {x₀}, (-∑ z in erase t x₀, g (z - x₀)) • x + ∑ x in filter (fun x => ¬x = x₀) t, g (x - x₀) • x = 0 [PROOFSTEP] congr congr rfl apply_congr simp [filter_ne'] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | ∑ x in {x₀}, (-∑ z in erase t x₀, g (z - x₀)) • x + ∑ x in filter (fun x => ¬x = x₀) t, g (x - x₀) • x = 0 [PROOFSTEP] congr congr rfl apply_congr simp [filter_ne'] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | ∑ x in {x₀}, (-∑ z in erase t x₀, g (z - x₀)) • x + ∑ x in filter (fun x => ¬x = x₀) t, g (x - x₀) • x = 0 [PROOFSTEP] congr [GOAL] case a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | ∑ x in {x₀}, (-∑ z in erase t x₀, g (z - x₀)) • x + ∑ x in filter (fun x => ¬x = x₀) t, g (x - x₀) • x case a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | 0 [PROOFSTEP] congr [GOAL] case a.a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | ∑ x in {x₀}, (-∑ z in erase t x₀, g (z - x₀)) • x case a.a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | ∑ x in filter (fun x => ¬x = x₀) t, g (x - x₀) • x case a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | 0 [PROOFSTEP] rfl [GOAL] case a.a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | ∑ x in filter (fun x => ¬x = x₀) t, g (x - x₀) • x case a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | 0 [PROOFSTEP] apply_congr [GOAL] case a.a.h K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ filter (fun x => ¬x = x₀) t = ?a.a.s₂ case a.a.a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) x✝ : V a✝ : x✝ ∈ ?a.a.s₂ ⊢ g (x✝ - x₀) • x✝ = ?a.a.g x✝ case a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | 0 [PROOFSTEP] simp [filter_ne'] [GOAL] case intro.intro.intro.intro.intro.refine'_1 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ ∑ x in {x₀}, (-∑ z in erase t x₀, g (z - x₀)) • x + ∑ x in erase t x₀, g (x - x₀) • x = 0 [PROOFSTEP] rw [sum_singleton, neg_smul, add_comm, ← sub_eq_add_neg, sum_smul, ← sum_sub_distrib] [GOAL] case intro.intro.intro.intro.intro.refine'_1 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ ∑ x in erase t x₀, (g (x - x₀) • x - g (x - x₀) • x₀) = 0 [PROOFSTEP] simp only [← smul_sub] -- At the end we have to reindex the sum, so we use `change` to -- express the summand using `shift`. [GOAL] case intro.intro.intro.intro.intro.refine'_1 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ ∑ x in erase t x₀, g (x - x₀) • (x - x₀) = 0 [PROOFSTEP] change (∑ x : V in t.erase x₀, (fun e => g e • e) (shift x)) = 0 -- porting note: last argument can't be inferred [GOAL] case intro.intro.intro.intro.intro.refine'_1 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ ∑ x in erase t x₀, (fun e => g e • e) (↑shift x) = 0 [PROOFSTEP] rw [← sum_map _ shift (fun e => g e • e)] [GOAL] case intro.intro.intro.intro.intro.refine'_1 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ ∑ x in Finset.map shift (erase t x₀), g x • x = 0 [PROOFSTEP] exact gsum [GOAL] case intro.intro.intro.intro.intro.refine'_2 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ ∑ e in t, f e = 0 [PROOFSTEP] show (∑ e : V in t, f e) = 0 -- Again we split off the `x₀` term, -- observing that it exactly cancels the other terms. [GOAL] case intro.intro.intro.intro.intro.refine'_2 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ ∑ e in t, f e = 0 [PROOFSTEP] rw [← insert_erase m, sum_insert (not_mem_erase x₀ t)] [GOAL] case intro.intro.intro.intro.intro.refine'_2 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ f x₀ + ∑ x in erase t x₀, f x = 0 [PROOFSTEP] dsimp [GOAL] case intro.intro.intro.intro.intro.refine'_2 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ ((if x₀ = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (x₀ - x₀)) + ∑ x in erase t x₀, if x = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (x - x₀)) = 0 [PROOFSTEP] rw [if_pos rfl] [GOAL] case intro.intro.intro.intro.intro.refine'_2 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ (-∑ z in erase t x₀, g (z - x₀) + ∑ x in erase t x₀, if x = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (x - x₀)) = 0 [PROOFSTEP] conv_lhs => congr rfl apply_congr rfl rw [if_neg (show _ ≠ x₀ from (mem_erase.mp ‹_›).1)] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | -∑ z in erase t x₀, g (z - x₀) + ∑ x in erase t x₀, if x = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (x - x₀) [PROOFSTEP] congr rfl apply_congr rfl rw [if_neg (show _ ≠ x₀ from (mem_erase.mp ‹_›).1)] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | -∑ z in erase t x₀, g (z - x₀) + ∑ x in erase t x₀, if x = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (x - x₀) [PROOFSTEP] congr rfl apply_congr rfl rw [if_neg (show _ ≠ x₀ from (mem_erase.mp ‹_›).1)] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | -∑ z in erase t x₀, g (z - x₀) + ∑ x in erase t x₀, if x = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (x - x₀) [PROOFSTEP] congr [GOAL] case a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | -∑ z in erase t x₀, g (z - x₀) case a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | ∑ x in erase t x₀, if x = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (x - x₀) [PROOFSTEP] rfl [GOAL] case a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) | ∑ x in erase t x₀, if x = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (x - x₀) [PROOFSTEP] apply_congr [GOAL] case a.h K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ erase t x₀ = ?a.s₂ case a.a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) x✝ : V a✝ : x✝ ∈ ?a.s₂ ⊢ (if x✝ = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (x✝ - x₀)) = ?a.g x✝ [PROOFSTEP] rfl [GOAL] case a.a K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) x✝ : V a✝ : x✝ ∈ erase t x₀ ⊢ (if x✝ = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (x✝ - x₀)) = ?a.g x✝ [PROOFSTEP] rw [if_neg (show _ ≠ x₀ from (mem_erase.mp ‹_›).1)] [GOAL] case intro.intro.intro.intro.intro.refine'_2 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ -∑ z in erase t x₀, g (z - x₀) + ∑ x in erase t x₀, g (x - x₀) = 0 [PROOFSTEP] exact neg_add_self _ [GOAL] case intro.intro.intro.intro.intro.refine'_3 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ ∃ x, x ∈ t ∧ f x ≠ 0 [PROOFSTEP] show ∃ (x : V), x ∈ t ∧ f x ≠ 0 -- We can use x₁ + x₀. [GOAL] case intro.intro.intro.intro.intro.refine'_3 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ ∃ x, x ∈ t ∧ f x ≠ 0 [PROOFSTEP] refine' ⟨x₁ + x₀, _, _⟩ [GOAL] case intro.intro.intro.intro.intro.refine'_3.refine'_1 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ x₁ + x₀ ∈ t [PROOFSTEP] rw [Finset.mem_map] at x₁_mem [GOAL] case intro.intro.intro.intro.intro.refine'_3.refine'_1 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : ∃ a, a ∈ erase t x₀ ∧ ↑shift a = x₁ nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ x₁ + x₀ ∈ t [PROOFSTEP] rcases x₁_mem with ⟨x₁, x₁_mem, rfl⟩ [GOAL] case intro.intro.intro.intro.intro.refine'_3.refine'_1.intro.intro K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) x₁ : V x₁_mem : x₁ ∈ erase t x₀ nz : g (↑shift x₁) ≠ 0 ⊢ ↑shift x₁ + x₀ ∈ t [PROOFSTEP] rw [mem_erase] at x₁_mem [GOAL] case intro.intro.intro.intro.intro.refine'_3.refine'_1.intro.intro K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) x₁ : V x₁_mem : x₁ ≠ x₀ ∧ x₁ ∈ t nz : g (↑shift x₁) ≠ 0 ⊢ ↑shift x₁ + x₀ ∈ t [PROOFSTEP] simp only [x₁_mem, sub_add_cancel, Function.Embedding.coeFn_mk] [GOAL] case intro.intro.intro.intro.intro.refine'_3.refine'_2 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ f (x₁ + x₀) ≠ 0 [PROOFSTEP] dsimp only [GOAL] case intro.intro.intro.intro.intro.refine'_3.refine'_2 K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ (if x₁ + x₀ = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (x₁ + x₀ - x₀)) ≠ 0 [PROOFSTEP] rwa [if_neg, add_sub_cancel] [GOAL] case intro.intro.intro.intro.intro.refine'_3.refine'_2.hnc K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ ¬x₁ + x₀ = x₀ [PROOFSTEP] rw [add_left_eq_self] [GOAL] case intro.intro.intro.intro.intro.refine'_3.refine'_2.hnc K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 x₁ : V x₁_mem : x₁ ∈ t' nz : g x₁ ≠ 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) ⊢ ¬x₁ = 0 [PROOFSTEP] rintro rfl [GOAL] case intro.intro.intro.intro.intro.refine'_3.refine'_2.hnc K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V t : Finset V h : finrank K V + 1 < card t card_pos : 0 < card t x₀ : V m : x₀ ∈ t shift : V ↪ V := { toFun := fun x => x - x₀, inj' := (_ : Injective fun a => a - x₀) } t' : Finset V := Finset.map shift (erase t x₀) h' : finrank K V < card t' g : V → K gsum : ∑ e in t', g e • e = 0 f : V → K := fun z => if z = x₀ then -∑ z in erase t x₀, g (z - x₀) else g (z - x₀) x₁_mem : 0 ∈ t' nz : g 0 ≠ 0 ⊢ False [PROOFSTEP] simp only [sub_eq_zero, exists_prop, Finset.mem_map, Embedding.coeFn_mk, eq_self_iff_true, mem_erase, not_true, exists_eq_right, Ne.def, false_and_iff] at x₁_mem [GOAL] K : Type u V : Type v inst✝⁸ : DivisionRing K inst✝⁷ : AddCommGroup V inst✝⁶ : Module K V V₂ : Type v' inst✝⁵ : AddCommGroup V₂ inst✝⁴ : Module K V₂ L : Type u_1 inst✝³ : LinearOrderedField L W : Type v inst✝² : AddCommGroup W inst✝¹ : Module L W inst✝ : FiniteDimensional L W t : Finset W h : finrank L W + 1 < card t ⊢ ∃ f, ∑ e in t, f e • e = 0 ∧ ∑ e in t, f e = 0 ∧ ∃ x, x ∈ t ∧ 0 < f x [PROOFSTEP] obtain ⟨f, sum, total, nonzero⟩ := exists_nontrivial_relation_sum_zero_of_rank_succ_lt_card h [GOAL] case intro.intro.intro K : Type u V : Type v inst✝⁸ : DivisionRing K inst✝⁷ : AddCommGroup V inst✝⁶ : Module K V V₂ : Type v' inst✝⁵ : AddCommGroup V₂ inst✝⁴ : Module K V₂ L : Type u_1 inst✝³ : LinearOrderedField L W : Type v inst✝² : AddCommGroup W inst✝¹ : Module L W inst✝ : FiniteDimensional L W t : Finset W h : finrank L W + 1 < card t f : W → L sum : ∑ e in t, f e • e = 0 total : ∑ e in t, f e = 0 nonzero : ∃ x, x ∈ t ∧ f x ≠ 0 ⊢ ∃ f, ∑ e in t, f e • e = 0 ∧ ∑ e in t, f e = 0 ∧ ∃ x, x ∈ t ∧ 0 < f x [PROOFSTEP] exact ⟨f, sum, total, exists_pos_of_sum_zero_of_exists_nonzero f total nonzero⟩ [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type u_1 inst✝ : Unique ι h✝ : finrank K V = 1 v : V hv : v ≠ 0 b : Basis ι K V := basisUnique ι h✝ h : ↑(↑b.repr v) default ≠ 0 := mt basisUnique.repr_eq_zero_iff.mp hv ⊢ ∀ (x y : V), (fun w => Finsupp.single default (↑(↑b.repr w) default / ↑(↑b.repr v) default)) (x + y) = (fun w => Finsupp.single default (↑(↑b.repr w) default / ↑(↑b.repr v) default)) x + (fun w => Finsupp.single default (↑(↑b.repr w) default / ↑(↑b.repr v) default)) y [PROOFSTEP] simp [add_div] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type u_1 inst✝ : Unique ι h✝ : finrank K V = 1 v : V hv : v ≠ 0 b : Basis ι K V := basisUnique ι h✝ h : ↑(↑b.repr v) default ≠ 0 := mt basisUnique.repr_eq_zero_iff.mp hv ⊢ ∀ (r : K) (x : V), AddHom.toFun { toFun := fun w => Finsupp.single default (↑(↑b.repr w) default / ↑(↑b.repr v) default), map_add' := (_ : ∀ (a a_1 : V), Finsupp.single default (↑(↑(basisUnique ι h✝).repr (a + a_1)) default / ↑(↑(basisUnique ι h✝).repr v) default) = Finsupp.single default (↑(↑(basisUnique ι h✝).repr a) default / ↑(↑(basisUnique ι h✝).repr v) default) + Finsupp.single default (↑(↑(basisUnique ι h✝).repr a_1) default / ↑(↑(basisUnique ι h✝).repr v) default)) } (r • x) = ↑(RingHom.id K) r • AddHom.toFun { toFun := fun w => Finsupp.single default (↑(↑b.repr w) default / ↑(↑b.repr v) default), map_add' := (_ : ∀ (a a_1 : V), Finsupp.single default (↑(↑(basisUnique ι h✝).repr (a + a_1)) default / ↑(↑(basisUnique ι h✝).repr v) default) = Finsupp.single default (↑(↑(basisUnique ι h✝).repr a) default / ↑(↑(basisUnique ι h✝).repr v) default) + Finsupp.single default (↑(↑(basisUnique ι h✝).repr a_1) default / ↑(↑(basisUnique ι h✝).repr v) default)) } x [PROOFSTEP] simp [mul_div] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type u_1 inst✝ : Unique ι h✝ : finrank K V = 1 v : V hv : v ≠ 0 b : Basis ι K V := basisUnique ι h✝ h : ↑(↑b.repr v) default ≠ 0 := mt basisUnique.repr_eq_zero_iff.mp hv w : V ⊢ (fun f => ↑f default • v) (AddHom.toFun { toAddHom := { toFun := fun w => Finsupp.single default (↑(↑b.repr w) default / ↑(↑b.repr v) default), map_add' := (_ : ∀ (a a_1 : V), Finsupp.single default (↑(↑(basisUnique ι h✝).repr (a + a_1)) default / ↑(↑(basisUnique ι h✝).repr v) default) = Finsupp.single default (↑(↑(basisUnique ι h✝).repr a) default / ↑(↑(basisUnique ι h✝).repr v) default) + Finsupp.single default (↑(↑(basisUnique ι h✝).repr a_1) default / ↑(↑(basisUnique ι h✝).repr v) default)) }, map_smul' := (_ : ∀ (a : K) (a_1 : V), Finsupp.single default (↑(↑(basisUnique ι h✝).repr (a • a_1)) default / ↑(↑(basisUnique ι h✝).repr v) default) = a • Finsupp.single default (↑(↑(basisUnique ι h✝).repr a_1) default / ↑(↑(basisUnique ι h✝).repr v) default)) }.toAddHom w) = w [PROOFSTEP] apply_fun b.repr using b.repr.toEquiv.injective [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type u_1 inst✝ : Unique ι h✝ : finrank K V = 1 v : V hv : v ≠ 0 b : Basis ι K V := basisUnique ι h✝ h : ↑(↑b.repr v) default ≠ 0 := mt basisUnique.repr_eq_zero_iff.mp hv w : V ⊢ ↑b.repr ((fun f => ↑f default • v) (AddHom.toFun { toAddHom := { toFun := fun w => Finsupp.single default (↑(↑b.repr w) default / ↑(↑b.repr v) default), map_add' := (_ : ∀ (a a_1 : V), Finsupp.single default (↑(↑(basisUnique ι h✝).repr (a + a_1)) default / ↑(↑(basisUnique ι h✝).repr v) default) = Finsupp.single default (↑(↑(basisUnique ι h✝).repr a) default / ↑(↑(basisUnique ι h✝).repr v) default) + Finsupp.single default (↑(↑(basisUnique ι h✝).repr a_1) default / ↑(↑(basisUnique ι h✝).repr v) default)) }, map_smul' := (_ : ∀ (a : K) (a_1 : V), Finsupp.single default (↑(↑(basisUnique ι h✝).repr (a • a_1)) default / ↑(↑(basisUnique ι h✝).repr v) default) = a • Finsupp.single default (↑(↑(basisUnique ι h✝).repr a_1) default / ↑(↑(basisUnique ι h✝).repr v) default)) }.toAddHom w)) = ↑b.repr w [PROOFSTEP] apply_fun Equiv.finsuppUnique [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type u_1 inst✝ : Unique ι h✝ : finrank K V = 1 v : V hv : v ≠ 0 b : Basis ι K V := basisUnique ι h✝ h : ↑(↑b.repr v) default ≠ 0 := mt basisUnique.repr_eq_zero_iff.mp hv w : V ⊢ ↑Equiv.finsuppUnique (↑b.repr ((fun f => ↑f default • v) (AddHom.toFun { toAddHom := { toFun := fun w => Finsupp.single default (↑(↑b.repr w) default / ↑(↑b.repr v) default), map_add' := (_ : ∀ (a a_1 : V), Finsupp.single default (↑(↑(basisUnique ι h✝).repr (a + a_1)) default / ↑(↑(basisUnique ι h✝).repr v) default) = Finsupp.single default (↑(↑(basisUnique ι h✝).repr a) default / ↑(↑(basisUnique ι h✝).repr v) default) + Finsupp.single default (↑(↑(basisUnique ι h✝).repr a_1) default / ↑(↑(basisUnique ι h✝).repr v) default)) }, map_smul' := (_ : ∀ (a : K) (a_1 : V), Finsupp.single default (↑(↑(basisUnique ι h✝).repr (a • a_1)) default / ↑(↑(basisUnique ι h✝).repr v) default) = a • Finsupp.single default (↑(↑(basisUnique ι h✝).repr a_1) default / ↑(↑(basisUnique ι h✝).repr v) default)) }.toAddHom w))) = ↑Equiv.finsuppUnique (↑b.repr w) [PROOFSTEP] simp only [LinearEquiv.map_smulₛₗ, Finsupp.coe_smul, Finsupp.single_eq_same, RingHom.id_apply, smul_eq_mul, Pi.smul_apply, Equiv.finsuppUnique_apply] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type u_1 inst✝ : Unique ι h✝ : finrank K V = 1 v : V hv : v ≠ 0 b : Basis ι K V := basisUnique ι h✝ h : ↑(↑b.repr v) default ≠ 0 := mt basisUnique.repr_eq_zero_iff.mp hv w : V ⊢ ↑(↑(basisUnique ι h✝).repr w) default / ↑(↑(basisUnique ι h✝).repr v) default * ↑(↑(basisUnique ι h✝).repr v) default = ↑(↑(basisUnique ι h✝).repr w) default [PROOFSTEP] exact div_mul_cancel _ h [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type u_1 inst✝ : Unique ι h✝ : finrank K V = 1 v : V hv : v ≠ 0 b : Basis ι K V := basisUnique ι h✝ h : ↑(↑b.repr v) default ≠ 0 := mt basisUnique.repr_eq_zero_iff.mp hv f : ι →₀ K ⊢ AddHom.toFun { toAddHom := { toFun := fun w => Finsupp.single default (↑(↑b.repr w) default / ↑(↑b.repr v) default), map_add' := (_ : ∀ (a a_1 : V), Finsupp.single default (↑(↑(basisUnique ι h✝).repr (a + a_1)) default / ↑(↑(basisUnique ι h✝).repr v) default) = Finsupp.single default (↑(↑(basisUnique ι h✝).repr a) default / ↑(↑(basisUnique ι h✝).repr v) default) + Finsupp.single default (↑(↑(basisUnique ι h✝).repr a_1) default / ↑(↑(basisUnique ι h✝).repr v) default)) }, map_smul' := (_ : ∀ (a : K) (a_1 : V), Finsupp.single default (↑(↑(basisUnique ι h✝).repr (a • a_1)) default / ↑(↑(basisUnique ι h✝).repr v) default) = a • Finsupp.single default (↑(↑(basisUnique ι h✝).repr a_1) default / ↑(↑(basisUnique ι h✝).repr v) default)) }.toAddHom ((fun f => ↑f default • v) f) = f [PROOFSTEP] ext [GOAL] case h K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type u_1 inst✝ : Unique ι h✝ : finrank K V = 1 v : V hv : v ≠ 0 b : Basis ι K V := basisUnique ι h✝ h : ↑(↑b.repr v) default ≠ 0 := mt basisUnique.repr_eq_zero_iff.mp hv f : ι →₀ K ⊢ ↑(AddHom.toFun { toAddHom := { toFun := fun w => Finsupp.single default (↑(↑b.repr w) default / ↑(↑b.repr v) default), map_add' := (_ : ∀ (a a_1 : V), Finsupp.single default (↑(↑(basisUnique ι h✝).repr (a + a_1)) default / ↑(↑(basisUnique ι h✝).repr v) default) = Finsupp.single default (↑(↑(basisUnique ι h✝).repr a) default / ↑(↑(basisUnique ι h✝).repr v) default) + Finsupp.single default (↑(↑(basisUnique ι h✝).repr a_1) default / ↑(↑(basisUnique ι h✝).repr v) default)) }, map_smul' := (_ : ∀ (a : K) (a_1 : V), Finsupp.single default (↑(↑(basisUnique ι h✝).repr (a • a_1)) default / ↑(↑(basisUnique ι h✝).repr v) default) = a • Finsupp.single default (↑(↑(basisUnique ι h✝).repr a_1) default / ↑(↑(basisUnique ι h✝).repr v) default)) }.toAddHom ((fun f => ↑f default • v) f)) default = ↑f default [PROOFSTEP] simp only [LinearEquiv.map_smulₛₗ, Finsupp.coe_smul, Finsupp.single_eq_same, RingHom.id_apply, smul_eq_mul, Pi.smul_apply] [GOAL] case h K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type u_1 inst✝ : Unique ι h✝ : finrank K V = 1 v : V hv : v ≠ 0 b : Basis ι K V := basisUnique ι h✝ h : ↑(↑b.repr v) default ≠ 0 := mt basisUnique.repr_eq_zero_iff.mp hv f : ι →₀ K ⊢ ↑f default * ↑(↑(basisUnique ι h✝).repr v) default / ↑(↑(basisUnique ι h✝).repr v) default = ↑f default [PROOFSTEP] exact mul_div_cancel _ h [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type u_1 inst✝ : Unique ι h : finrank K V = 1 v : V hv : v ≠ 0 i : ι ⊢ ↑(basisSingleton ι h v hv) i = v [PROOFSTEP] cases Unique.uniq ‹Unique ι› i [GOAL] case refl K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type u_1 inst✝ : Unique ι h : finrank K V = 1 v : V hv : v ≠ 0 ⊢ ↑(basisSingleton ι h v hv) default = v [PROOFSTEP] simp [basisSingleton] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type u_1 inst✝ : Unique ι h : finrank K V = 1 v : V hv : v ≠ 0 ⊢ Set.range ↑(basisSingleton ι h v hv) = {v} [PROOFSTEP] rw [Set.range_unique, basisSingleton_apply] [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V n : ℕ h : Module.rank K V = ↑n ⊢ FiniteDimensional K V [PROOFSTEP] rw [FiniteDimensional, ← IsNoetherian.iff_fg, IsNoetherian.iff_rank_lt_aleph0, h] [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V n : ℕ h : Module.rank K V = ↑n ⊢ ↑n < ℵ₀ [PROOFSTEP] exact nat_lt_aleph0 n [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V h : Module.rank K V = 0 ⊢ finrank K V = 0 [PROOFSTEP] convert finrank_eq_rank K V [GOAL] case a K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V h : Module.rank K V = 0 ⊢ finrank K V = 0 ↔ ↑(finrank K V) = Module.rank K V [PROOFSTEP] rw [h] [GOAL] case a K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V h : Module.rank K V = 0 ⊢ finrank K V = 0 ↔ ↑(finrank K V) = 0 [PROOFSTEP] norm_cast [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V ⊢ Module.rank K { x // x ∈ ⊥ } = 0 [PROOFSTEP] simp [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V h : Module.rank K V = 0 ⊢ ⊥ = ⊤ [PROOFSTEP] haveI : FiniteDimensional _ _ := finiteDimensional_of_rank_eq_zero h [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V h : Module.rank K V = 0 this : FiniteDimensional K V ⊢ ⊥ = ⊤ [PROOFSTEP] apply eq_top_of_finrank_eq [GOAL] case h K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V h : Module.rank K V = 0 this : FiniteDimensional K V ⊢ finrank K { x // x ∈ ⊥ } = finrank K V [PROOFSTEP] rw [finrank_bot, finrank_eq_zero_of_rank_eq_zero h] [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V S : Submodule K V h : S = ⊥ ⊢ Module.rank K { x // x ∈ S } = 0 [PROOFSTEP] rw [h, rank_bot] [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V S : Submodule K V inst✝ : FiniteDimensional K { x // x ∈ S } ⊢ finrank K { x // x ∈ S } = 0 ↔ S = ⊥ [PROOFSTEP] rw [← rank_eq_zero, ← finrank_eq_rank, ← @Nat.cast_zero Cardinal, Cardinal.natCast_inj] [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V S₁ S₂ : Submodule K V h₁ : FiniteDimensional K { x // x ∈ S₁ } h₂ : FiniteDimensional K { x // x ∈ S₂ } ⊢ FiniteDimensional K { x // x ∈ S₁ ⊔ S₂ } [PROOFSTEP] unfold FiniteDimensional at * [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V S₁ S₂ : Submodule K V h₁ : Module.Finite K { x // x ∈ S₁ } h₂ : Module.Finite K { x // x ∈ S₂ } ⊢ Module.Finite K { x // x ∈ S₁ ⊔ S₂ } [PROOFSTEP] rw [finite_def] at * [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V S₁ S₂ : Submodule K V h₁ : FG ⊤ h₂ : FG ⊤ ⊢ FG ⊤ [PROOFSTEP] exact (fg_top _).2 (((fg_top S₁).1 h₁).sup ((fg_top S₂).1 h₂)) [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V ι : Type u_1 s : Finset ι S : ι → Submodule K V inst✝ : ∀ (i : ι), FiniteDimensional K { x // x ∈ S i } ⊢ FiniteDimensional K { x // x ∈ Finset.sup s S } [PROOFSTEP] refine' @Finset.sup_induction _ _ _ _ s S (fun i => FiniteDimensional K ↑i) (finiteDimensional_bot K V) _ fun i _ => by infer_instance [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V ι : Type u_1 s : Finset ι S : ι → Submodule K V inst✝ : ∀ (i : ι), FiniteDimensional K { x // x ∈ S i } i : ι x✝ : i ∈ s ⊢ (fun i => FiniteDimensional K { x // x ∈ i }) (S i) [PROOFSTEP] infer_instance [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V ι : Type u_1 s : Finset ι S : ι → Submodule K V inst✝ : ∀ (i : ι), FiniteDimensional K { x // x ∈ S i } ⊢ ∀ (a₁ : Submodule K V), (fun i => FiniteDimensional K { x // x ∈ i }) a₁ → ∀ (a₂ : Submodule K V), (fun i => FiniteDimensional K { x // x ∈ i }) a₂ → (fun i => FiniteDimensional K { x // x ∈ i }) (a₁ ⊔ a₂) [PROOFSTEP] intro S₁ hS₁ S₂ hS₂ [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V ι : Type u_1 s : Finset ι S : ι → Submodule K V inst✝ : ∀ (i : ι), FiniteDimensional K { x // x ∈ S i } S₁ : Submodule K V hS₁ : FiniteDimensional K { x // x ∈ S₁ } S₂ : Submodule K V hS₂ : FiniteDimensional K { x // x ∈ S₂ } ⊢ FiniteDimensional K { x // x ∈ S₁ ⊔ S₂ } [PROOFSTEP] exact Submodule.finiteDimensional_sup S₁ S₂ [GOAL] K : Type u V : Type v inst✝⁴ : DivisionRing K inst✝³ : AddCommGroup V inst✝² : Module K V ι : Sort u_1 inst✝¹ : _root_.Finite ι S : ι → Submodule K V inst✝ : ∀ (i : ι), FiniteDimensional K { x // x ∈ S i } ⊢ FiniteDimensional K { x // x ∈ ⨆ (i : ι), S i } [PROOFSTEP] cases nonempty_fintype (PLift ι) [GOAL] case intro K : Type u V : Type v inst✝⁴ : DivisionRing K inst✝³ : AddCommGroup V inst✝² : Module K V ι : Sort u_1 inst✝¹ : _root_.Finite ι S : ι → Submodule K V inst✝ : ∀ (i : ι), FiniteDimensional K { x // x ∈ S i } val✝ : Fintype (PLift ι) ⊢ FiniteDimensional K { x // x ∈ ⨆ (i : ι), S i } [PROOFSTEP] rw [← iSup_plift_down, ← Finset.sup_univ_eq_iSup] [GOAL] case intro K : Type u V : Type v inst✝⁴ : DivisionRing K inst✝³ : AddCommGroup V inst✝² : Module K V ι : Sort u_1 inst✝¹ : _root_.Finite ι S : ι → Submodule K V inst✝ : ∀ (i : ι), FiniteDimensional K { x // x ∈ S i } val✝ : Fintype (PLift ι) ⊢ FiniteDimensional K { x // x ∈ Finset.sup Finset.univ fun i => S i.down } [PROOFSTEP] exact Submodule.finiteDimensional_finset_sup _ _ [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V s : Submodule K V ⊢ finrank K (V ⧸ s) + finrank K { x // x ∈ s } = finrank K V [PROOFSTEP] have := rank_quotient_add_rank s [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V s : Submodule K V this : Module.rank K (V ⧸ s) + Module.rank K { x // x ∈ s } = Module.rank K V ⊢ finrank K (V ⧸ s) + finrank K { x // x ∈ s } = finrank K V [PROOFSTEP] rw [← finrank_eq_rank, ← finrank_eq_rank, ← finrank_eq_rank] at this [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V s : Submodule K V this : ↑(finrank K (V ⧸ s)) + ↑(finrank K { x // x ∈ s }) = ↑(finrank K V) ⊢ finrank K (V ⧸ s) + finrank K { x // x ∈ s } = finrank K V [PROOFSTEP] exact_mod_cast this [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V s : Submodule K V h : s < ⊤ ⊢ finrank K { x // x ∈ s } < finrank K V [PROOFSTEP] rw [← s.finrank_quotient_add_finrank, add_comm] [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V s : Submodule K V h : s < ⊤ ⊢ finrank K { x // x ∈ s } < finrank K { x // x ∈ s } + finrank K (V ⧸ s) [PROOFSTEP] exact Nat.lt_add_of_pos_right (finrank_pos_iff.mpr (Quotient.nontrivial_of_lt_top _ h)) [GOAL] K : Type u V : Type v inst✝⁴ : DivisionRing K inst✝³ : AddCommGroup V inst✝² : Module K V s t : Submodule K V inst✝¹ : FiniteDimensional K { x // x ∈ s } inst✝ : FiniteDimensional K { x // x ∈ t } ⊢ finrank K { x // x ∈ s ⊔ t } + finrank K { x // x ∈ s ⊓ t } = finrank K { x // x ∈ s } + finrank K { x // x ∈ t } [PROOFSTEP] have key : Module.rank K ↑(s ⊔ t) + Module.rank K ↑(s ⊓ t) = Module.rank K s + Module.rank K t := rank_sup_add_rank_inf_eq s t [GOAL] K : Type u V : Type v inst✝⁴ : DivisionRing K inst✝³ : AddCommGroup V inst✝² : Module K V s t : Submodule K V inst✝¹ : FiniteDimensional K { x // x ∈ s } inst✝ : FiniteDimensional K { x // x ∈ t } key : Module.rank K { x // x ∈ s ⊔ t } + Module.rank K { x // x ∈ s ⊓ t } = Module.rank K { x // x ∈ s } + Module.rank K { x // x ∈ t } ⊢ finrank K { x // x ∈ s ⊔ t } + finrank K { x // x ∈ s ⊓ t } = finrank K { x // x ∈ s } + finrank K { x // x ∈ t } [PROOFSTEP] repeat' rw [← finrank_eq_rank] at key [GOAL] K : Type u V : Type v inst✝⁴ : DivisionRing K inst✝³ : AddCommGroup V inst✝² : Module K V s t : Submodule K V inst✝¹ : FiniteDimensional K { x // x ∈ s } inst✝ : FiniteDimensional K { x // x ∈ t } key : Module.rank K { x // x ∈ s ⊔ t } + Module.rank K { x // x ∈ s ⊓ t } = Module.rank K { x // x ∈ s } + Module.rank K { x // x ∈ t } ⊢ finrank K { x // x ∈ s ⊔ t } + finrank K { x // x ∈ s ⊓ t } = finrank K { x // x ∈ s } + finrank K { x // x ∈ t } [PROOFSTEP] rw [← finrank_eq_rank] at key [GOAL] K : Type u V : Type v inst✝⁴ : DivisionRing K inst✝³ : AddCommGroup V inst✝² : Module K V s t : Submodule K V inst✝¹ : FiniteDimensional K { x // x ∈ s } inst✝ : FiniteDimensional K { x // x ∈ t } key : ↑(finrank K { x // x ∈ s ⊔ t }) + Module.rank K { x // x ∈ s ⊓ t } = Module.rank K { x // x ∈ s } + Module.rank K { x // x ∈ t } ⊢ finrank K { x // x ∈ s ⊔ t } + finrank K { x // x ∈ s ⊓ t } = finrank K { x // x ∈ s } + finrank K { x // x ∈ t } [PROOFSTEP] rw [← finrank_eq_rank] at key [GOAL] K : Type u V : Type v inst✝⁴ : DivisionRing K inst✝³ : AddCommGroup V inst✝² : Module K V s t : Submodule K V inst✝¹ : FiniteDimensional K { x // x ∈ s } inst✝ : FiniteDimensional K { x // x ∈ t } key : ↑(finrank K { x // x ∈ s ⊔ t }) + ↑(finrank K { x // x ∈ s ⊓ t }) = Module.rank K { x // x ∈ s } + Module.rank K { x // x ∈ t } ⊢ finrank K { x // x ∈ s ⊔ t } + finrank K { x // x ∈ s ⊓ t } = finrank K { x // x ∈ s } + finrank K { x // x ∈ t } [PROOFSTEP] rw [← finrank_eq_rank] at key [GOAL] K : Type u V : Type v inst✝⁴ : DivisionRing K inst✝³ : AddCommGroup V inst✝² : Module K V s t : Submodule K V inst✝¹ : FiniteDimensional K { x // x ∈ s } inst✝ : FiniteDimensional K { x // x ∈ t } key : ↑(finrank K { x // x ∈ s ⊔ t }) + ↑(finrank K { x // x ∈ s ⊓ t }) = ↑(finrank K { x // x ∈ s }) + Module.rank K { x // x ∈ t } ⊢ finrank K { x // x ∈ s ⊔ t } + finrank K { x // x ∈ s ⊓ t } = finrank K { x // x ∈ s } + finrank K { x // x ∈ t } [PROOFSTEP] rw [← finrank_eq_rank] at key [GOAL] K : Type u V : Type v inst✝⁴ : DivisionRing K inst✝³ : AddCommGroup V inst✝² : Module K V s t : Submodule K V inst✝¹ : FiniteDimensional K { x // x ∈ s } inst✝ : FiniteDimensional K { x // x ∈ t } key : ↑(finrank K { x // x ∈ s ⊔ t }) + ↑(finrank K { x // x ∈ s ⊓ t }) = ↑(finrank K { x // x ∈ s }) + ↑(finrank K { x // x ∈ t }) ⊢ finrank K { x // x ∈ s ⊔ t } + finrank K { x // x ∈ s ⊓ t } = finrank K { x // x ∈ s } + finrank K { x // x ∈ t } [PROOFSTEP] rw [← finrank_eq_rank] at key [GOAL] K : Type u V : Type v inst✝⁴ : DivisionRing K inst✝³ : AddCommGroup V inst✝² : Module K V s t : Submodule K V inst✝¹ : FiniteDimensional K { x // x ∈ s } inst✝ : FiniteDimensional K { x // x ∈ t } key : ↑(finrank K { x // x ∈ s ⊔ t }) + ↑(finrank K { x // x ∈ s ⊓ t }) = ↑(finrank K { x // x ∈ s }) + ↑(finrank K { x // x ∈ t }) ⊢ finrank K { x // x ∈ s ⊔ t } + finrank K { x // x ∈ s ⊓ t } = finrank K { x // x ∈ s } + finrank K { x // x ∈ t } [PROOFSTEP] norm_cast at key [GOAL] K : Type u V : Type v inst✝⁴ : DivisionRing K inst✝³ : AddCommGroup V inst✝² : Module K V s t : Submodule K V inst✝¹ : FiniteDimensional K { x // x ∈ s } inst✝ : FiniteDimensional K { x // x ∈ t } ⊢ finrank K { x // x ∈ s ⊔ t } ≤ finrank K { x // x ∈ s } + finrank K { x // x ∈ t } [PROOFSTEP] rw [← finrank_sup_add_finrank_inf_eq] [GOAL] K : Type u V : Type v inst✝⁴ : DivisionRing K inst✝³ : AddCommGroup V inst✝² : Module K V s t : Submodule K V inst✝¹ : FiniteDimensional K { x // x ∈ s } inst✝ : FiniteDimensional K { x // x ∈ t } ⊢ finrank K { x // x ∈ s ⊔ t } ≤ finrank K { x // x ∈ s ⊔ t } + finrank K { x // x ∈ s ⊓ t } [PROOFSTEP] exact self_le_add_right _ _ [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V s t : Submodule K V hdim : finrank K { x // x ∈ s } + finrank K { x // x ∈ t } = finrank K V hdisjoint : Disjoint s t ⊢ s ⊔ t = ⊤ [PROOFSTEP] have h_finrank_inf : finrank K ↑(s ⊓ t) = 0 := by rw [disjoint_iff_inf_le, le_bot_iff] at hdisjoint rw [hdisjoint, finrank_bot] [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V s t : Submodule K V hdim : finrank K { x // x ∈ s } + finrank K { x // x ∈ t } = finrank K V hdisjoint : Disjoint s t ⊢ finrank K { x // x ∈ s ⊓ t } = 0 [PROOFSTEP] rw [disjoint_iff_inf_le, le_bot_iff] at hdisjoint [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V s t : Submodule K V hdim : finrank K { x // x ∈ s } + finrank K { x // x ∈ t } = finrank K V hdisjoint : s ⊓ t = ⊥ ⊢ finrank K { x // x ∈ s ⊓ t } = 0 [PROOFSTEP] rw [hdisjoint, finrank_bot] [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V s t : Submodule K V hdim : finrank K { x // x ∈ s } + finrank K { x // x ∈ t } = finrank K V hdisjoint : Disjoint s t h_finrank_inf : finrank K { x // x ∈ s ⊓ t } = 0 ⊢ s ⊔ t = ⊤ [PROOFSTEP] apply eq_top_of_finrank_eq [GOAL] case h K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V s t : Submodule K V hdim : finrank K { x // x ∈ s } + finrank K { x // x ∈ t } = finrank K V hdisjoint : Disjoint s t h_finrank_inf : finrank K { x // x ∈ s ⊓ t } = 0 ⊢ finrank K { x // x ∈ s ⊔ t } = finrank K V [PROOFSTEP] rw [← hdim] [GOAL] case h K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V s t : Submodule K V hdim : finrank K { x // x ∈ s } + finrank K { x // x ∈ t } = finrank K V hdisjoint : Disjoint s t h_finrank_inf : finrank K { x // x ∈ s ⊓ t } = 0 ⊢ finrank K { x // x ∈ s ⊔ t } = finrank K { x // x ∈ s } + finrank K { x // x ∈ t } [PROOFSTEP] convert s.finrank_sup_add_finrank_inf_eq t [GOAL] case h.e'_2 K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V s t : Submodule K V hdim : finrank K { x // x ∈ s } + finrank K { x // x ∈ t } = finrank K V hdisjoint : Disjoint s t h_finrank_inf : finrank K { x // x ∈ s ⊓ t } = 0 ⊢ finrank K { x // x ∈ s ⊔ t } = finrank K { x // x ∈ s ⊔ t } + finrank K { x // x ∈ s ⊓ t } [PROOFSTEP] rw [h_finrank_inf] [GOAL] case h.e'_2 K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V s t : Submodule K V hdim : finrank K { x // x ∈ s } + finrank K { x // x ∈ t } = finrank K V hdisjoint : Disjoint s t h_finrank_inf : finrank K { x // x ∈ s ⊓ t } = 0 ⊢ finrank K { x // x ∈ s ⊔ t } = finrank K { x // x ∈ s ⊔ t } + 0 [PROOFSTEP] rfl [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ S₁ S₂ : Submodule K V inst✝ : FiniteDimensional K { x // x ∈ S₂ } hle : S₁ ≤ S₂ hd : finrank K { x // x ∈ S₂ } ≤ finrank K { x // x ∈ S₁ } ⊢ S₁ = S₂ [PROOFSTEP] rw [← LinearEquiv.finrank_eq (Submodule.comapSubtypeEquivOfLe hle)] at hd [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ S₁ S₂ : Submodule K V inst✝ : FiniteDimensional K { x // x ∈ S₂ } hle : S₁ ≤ S₂ hd : finrank K { x // x ∈ S₂ } ≤ finrank K { x // x ∈ comap (Submodule.subtype S₂) S₁ } ⊢ S₁ = S₂ [PROOFSTEP] exact le_antisymm hle (Submodule.comap_subtype_eq_top.1 (eq_top_of_finrank_eq (le_antisymm (comap (Submodule.subtype S₂) S₁).finrank_le hd))) [GOAL] K : Type u V : Type v inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V V₂ : Type v' inst✝³ : AddCommGroup V₂ inst✝² : Module K V₂ inst✝¹ : FiniteDimensional K V inst✝ : FiniteDimensional K V₂ p : Subspace K V q : Subspace K V₂ f₁ : { x // x ∈ p } ≃ₗ[K] { x // x ∈ q } f₂ : V ≃ₗ[K] V₂ ⊢ finrank K (V ⧸ p) = finrank K (V₂ ⧸ q) [PROOFSTEP] rw [← @add_right_cancel_iff _ _ _ (finrank K p), Submodule.finrank_quotient_add_finrank, LinearEquiv.finrank_eq f₁, Submodule.finrank_quotient_add_finrank, LinearEquiv.finrank_eq f₂] [GOAL] K : Type u V : Type v inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V V₂ : Type v' inst✝³ : AddCommGroup V₂ inst✝² : Module K V₂ inst✝¹ : FiniteDimensional K V inst✝ : FiniteDimensional K V₂ p q : Subspace K V f : (V ⧸ p) ≃ₗ[K] { x // x ∈ q } ⊢ finrank K (V ⧸ q) + ?m.798563 f = finrank K { x // x ∈ p } + ?m.798563 f [PROOFSTEP] rw [Submodule.finrank_quotient_add_finrank, ← LinearEquiv.finrank_eq f, add_comm, Submodule.finrank_quotient_add_finrank] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V f : V →ₗ[K] V hinj : Injective ↑f ⊢ Surjective ↑f [PROOFSTEP] have h := rank_range_of_injective _ hinj [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V f : V →ₗ[K] V hinj : Injective ↑f h : Module.rank K { x // x ∈ range f } = Module.rank K V ⊢ Surjective ↑f [PROOFSTEP] rw [← finrank_eq_rank, ← finrank_eq_rank, natCast_inj] at h [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V f : V →ₗ[K] V hinj : Injective ↑f h : finrank K { x // x ∈ range f } = finrank K V ⊢ Surjective ↑f [PROOFSTEP] exact range_eq_top.1 (eq_top_of_finrank_eq h) [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V f : V →ₗ[K] V ⊢ ker f = ⊥ ↔ range f = ⊤ [PROOFSTEP] rw [range_eq_top, ker_eq_bot, injective_iff_surjective] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V f g : V →ₗ[K] V hfg : f * g = 1 ⊢ g * f = 1 [PROOFSTEP] have ginj : Injective g := HasLeftInverse.injective ⟨f, fun x => show (f * g) x = (1 : V →ₗ[K] V) x by rw [hfg]⟩ [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V f g : V →ₗ[K] V hfg : f * g = 1 x : V ⊢ ↑(f * g) x = ↑1 x [PROOFSTEP] rw [hfg] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V f g : V →ₗ[K] V hfg : f * g = 1 ginj : Injective ↑g ⊢ g * f = 1 [PROOFSTEP] let ⟨i, hi⟩ := g.exists_rightInverse_of_surjective (range_eq_top.2 (injective_iff_surjective.1 ginj)) [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V f g : V →ₗ[K] V hfg : f * g = 1 ginj : Injective ↑g i : V →ₗ[K] V hi : comp g i = id ⊢ g * f = 1 [PROOFSTEP] have : f * (g * i) = f * 1 := congr_arg _ hi [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V f g : V →ₗ[K] V hfg : f * g = 1 ginj : Injective ↑g i : V →ₗ[K] V hi : comp g i = id this : f * (g * i) = f * 1 ⊢ g * f = 1 [PROOFSTEP] rw [← mul_assoc, hfg, one_mul, mul_one] at this [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V f g : V →ₗ[K] V hfg : f * g = 1 ginj : Injective ↑g i : V →ₗ[K] V hi : comp g i = id this : i = f ⊢ g * f = 1 [PROOFSTEP] rwa [← this] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V f : V →ₗ[K] V₂ ⊢ finrank K { x // x ∈ range f } + finrank K { x // x ∈ ker f } = finrank K V [PROOFSTEP] rw [← f.quotKerEquivRange.finrank_eq] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V f : V →ₗ[K] V₂ ⊢ finrank K (V ⧸ ker f) + finrank K { x // x ∈ ker f } = finrank K V [PROOFSTEP] exact Submodule.finrank_quotient_add_finrank _ [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : V →ₗ[K] V ⊢ IsUnit f ↔ ker f = ⊥ [PROOFSTEP] constructor [GOAL] case mp K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : V →ₗ[K] V ⊢ IsUnit f → ker f = ⊥ [PROOFSTEP] rintro ⟨u, rfl⟩ [GOAL] case mp.intro K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V u : (V →ₗ[K] V)ˣ ⊢ ker ↑u = ⊥ [PROOFSTEP] exact LinearMap.ker_eq_bot_of_inverse u.inv_mul [GOAL] case mpr K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : V →ₗ[K] V ⊢ ker f = ⊥ → IsUnit f [PROOFSTEP] intro h_inj [GOAL] case mpr K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : V →ₗ[K] V h_inj : ker f = ⊥ ⊢ IsUnit f [PROOFSTEP] rw [ker_eq_bot] at h_inj [GOAL] case mpr K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : V →ₗ[K] V h_inj : Injective ↑f ⊢ IsUnit f [PROOFSTEP] exact ⟨⟨f, (LinearEquiv.ofInjectiveEndo f h_inj).symm.toLinearMap, LinearEquiv.ofInjectiveEndo_right_inv f h_inj, LinearEquiv.ofInjectiveEndo_left_inv f h_inj⟩, rfl⟩ [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : V →ₗ[K] V ⊢ IsUnit f ↔ range f = ⊤ [PROOFSTEP] rw [isUnit_iff_ker_eq_bot, ker_eq_bot_iff_range_eq_top] [GOAL] K : Type u V : Type v inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V V₂ : Type v' inst✝³ : AddCommGroup V₂ inst✝² : Module K V₂ inst✝¹ : FiniteDimensional K V inst✝ : FiniteDimensional K V₂ H : finrank K V = finrank K V₂ f : V →ₗ[K] V₂ ⊢ Injective ↑f ↔ Surjective ↑f [PROOFSTEP] have := finrank_range_add_finrank_ker f [GOAL] K : Type u V : Type v inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V V₂ : Type v' inst✝³ : AddCommGroup V₂ inst✝² : Module K V₂ inst✝¹ : FiniteDimensional K V inst✝ : FiniteDimensional K V₂ H : finrank K V = finrank K V₂ f : V →ₗ[K] V₂ this : finrank K { x // x ∈ range f } + finrank K { x // x ∈ ker f } = finrank K V ⊢ Injective ↑f ↔ Surjective ↑f [PROOFSTEP] rw [← ker_eq_bot, ← range_eq_top] [GOAL] K : Type u V : Type v inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V V₂ : Type v' inst✝³ : AddCommGroup V₂ inst✝² : Module K V₂ inst✝¹ : FiniteDimensional K V inst✝ : FiniteDimensional K V₂ H : finrank K V = finrank K V₂ f : V →ₗ[K] V₂ this : finrank K { x // x ∈ range f } + finrank K { x // x ∈ ker f } = finrank K V ⊢ ker f = ⊥ ↔ range f = ⊤ [PROOFSTEP] refine' ⟨fun h => _, fun h => _⟩ [GOAL] case refine'_1 K : Type u V : Type v inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V V₂ : Type v' inst✝³ : AddCommGroup V₂ inst✝² : Module K V₂ inst✝¹ : FiniteDimensional K V inst✝ : FiniteDimensional K V₂ H : finrank K V = finrank K V₂ f : V →ₗ[K] V₂ this : finrank K { x // x ∈ range f } + finrank K { x // x ∈ ker f } = finrank K V h : ker f = ⊥ ⊢ range f = ⊤ [PROOFSTEP] rw [h, finrank_bot, add_zero, H] at this [GOAL] case refine'_1 K : Type u V : Type v inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V V₂ : Type v' inst✝³ : AddCommGroup V₂ inst✝² : Module K V₂ inst✝¹ : FiniteDimensional K V inst✝ : FiniteDimensional K V₂ H : finrank K V = finrank K V₂ f : V →ₗ[K] V₂ this : finrank K { x // x ∈ range f } = finrank K V₂ h : ker f = ⊥ ⊢ range f = ⊤ [PROOFSTEP] exact eq_top_of_finrank_eq this [GOAL] case refine'_2 K : Type u V : Type v inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V V₂ : Type v' inst✝³ : AddCommGroup V₂ inst✝² : Module K V₂ inst✝¹ : FiniteDimensional K V inst✝ : FiniteDimensional K V₂ H : finrank K V = finrank K V₂ f : V →ₗ[K] V₂ this : finrank K { x // x ∈ range f } + finrank K { x // x ∈ ker f } = finrank K V h : range f = ⊤ ⊢ ker f = ⊥ [PROOFSTEP] rw [h, finrank_top, H] at this [GOAL] case refine'_2 K : Type u V : Type v inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V V₂ : Type v' inst✝³ : AddCommGroup V₂ inst✝² : Module K V₂ inst✝¹ : FiniteDimensional K V inst✝ : FiniteDimensional K V₂ H : finrank K V = finrank K V₂ f : V →ₗ[K] V₂ this : finrank K V₂ + finrank K { x // x ∈ ker f } = finrank K V₂ h : range f = ⊤ ⊢ ker f = ⊥ [PROOFSTEP] exact finrank_eq_zero.1 (add_right_injective _ this) [GOAL] K : Type u V : Type v inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V V₂ : Type v' inst✝³ : AddCommGroup V₂ inst✝² : Module K V₂ inst✝¹ : FiniteDimensional K V inst✝ : FiniteDimensional K V₂ H : finrank K V = finrank K V₂ f : V →ₗ[K] V₂ ⊢ ker f = ⊥ ↔ range f = ⊤ [PROOFSTEP] rw [range_eq_top, ker_eq_bot, injective_iff_surjective_of_finrank_eq_finrank H] [GOAL] K✝ : Type u V : Type v F : Type u_1 K : Type u_2 inst✝⁴ : Field F inst✝³ : Ring K inst✝² : IsDomain K inst✝¹ : Algebra F K inst✝ : FiniteDimensional F K x : K H : x ≠ 0 ⊢ ∃ y, x * y = 1 [PROOFSTEP] have : Function.Surjective (LinearMap.mulLeft F x) := LinearMap.injective_iff_surjective.1 fun y z => ((mul_right_inj' H).1 : x * y = x * z → y = z) [GOAL] K✝ : Type u V : Type v F : Type u_1 K : Type u_2 inst✝⁴ : Field F inst✝³ : Ring K inst✝² : IsDomain K inst✝¹ : Algebra F K inst✝ : FiniteDimensional F K x : K H : x ≠ 0 this : Surjective ↑(LinearMap.mulLeft F x) ⊢ ∃ y, x * y = 1 [PROOFSTEP] exact this 1 [GOAL] K✝ : Type u V : Type v F : Type u_1 K : Type u_2 inst✝³ : Field F h : Ring K inst✝² : IsDomain K inst✝¹ : Algebra F K inst✝ : FiniteDimensional F K src✝ : IsDomain K := inst✝² x : K hx : x ≠ 0 ⊢ (x * if H : x = 0 then 0 else Classical.choose (_ : ∃ y, x * y = 1)) = 1 [PROOFSTEP] rw [dif_neg hx] [GOAL] K✝ : Type u V : Type v F : Type u_1 K : Type u_2 inst✝³ : Field F h : Ring K inst✝² : IsDomain K inst✝¹ : Algebra F K inst✝ : FiniteDimensional F K src✝ : IsDomain K := inst✝² x : K hx : x ≠ 0 ⊢ x * Classical.choose (_ : ∃ y, x * y = 1) = 1 [PROOFSTEP] exact (Classical.choose_spec (FiniteDimensional.exists_mul_eq_one F hx) :) [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V U W : Submodule K V h : IsCompl U W ⊢ finrank K { x // x ∈ U } + finrank K { x // x ∈ W } = finrank K V [PROOFSTEP] rw [← finrank_sup_add_finrank_inf_eq, h.codisjoint.eq_top, h.disjoint.eq_bot, finrank_bot, add_zero] [GOAL] K : Type u V : Type v inst✝⁵ : DivisionRing K inst✝⁴ : AddCommGroup V inst✝³ : Module K V V₂ : Type v' inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V U W : Submodule K V h : IsCompl U W ⊢ finrank K { x // x ∈ ⊤ } = finrank K V [PROOFSTEP] exact finrank_top _ _ [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v : V hv : v ≠ 0 ⊢ finrank K { x // x ∈ span K {v} } = 1 [PROOFSTEP] apply le_antisymm [GOAL] case a K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v : V hv : v ≠ 0 ⊢ finrank K { x // x ∈ span K {v} } ≤ 1 [PROOFSTEP] exact finrank_span_le_card ({ v } : Set V) [GOAL] case a K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v : V hv : v ≠ 0 ⊢ 1 ≤ finrank K { x // x ∈ span K {v} } [PROOFSTEP] rw [Nat.succ_le_iff, finrank_pos_iff] [GOAL] case a K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v : V hv : v ≠ 0 ⊢ Nontrivial { x // x ∈ span K {v} } [PROOFSTEP] use⟨v, mem_span_singleton_self v⟩, 0 [GOAL] case h K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v : V hv : v ≠ 0 ⊢ { val := v, property := (_ : v ∈ span K {v}) } ≠ 0 [PROOFSTEP] simp [hv] [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V h : finrank K V = 1 x : V hx : x ≠ 0 y : V ⊢ ∃ c, c • x = y [PROOFSTEP] have : Submodule.span K { x } = ⊤ := by have : FiniteDimensional K V := finiteDimensional_of_finrank (zero_lt_one.trans_le h.symm.le) apply eq_top_of_finrank_eq rw [h] exact finrank_span_singleton hx [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V h : finrank K V = 1 x : V hx : x ≠ 0 y : V ⊢ span K {x} = ⊤ [PROOFSTEP] have : FiniteDimensional K V := finiteDimensional_of_finrank (zero_lt_one.trans_le h.symm.le) [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V h : finrank K V = 1 x : V hx : x ≠ 0 y : V this : FiniteDimensional K V ⊢ span K {x} = ⊤ [PROOFSTEP] apply eq_top_of_finrank_eq [GOAL] case h K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V h : finrank K V = 1 x : V hx : x ≠ 0 y : V this : FiniteDimensional K V ⊢ finrank K { x_1 // x_1 ∈ span K {x} } = finrank K V [PROOFSTEP] rw [h] [GOAL] case h K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V h : finrank K V = 1 x : V hx : x ≠ 0 y : V this : FiniteDimensional K V ⊢ finrank K { x_1 // x_1 ∈ span K {x} } = 1 [PROOFSTEP] exact finrank_span_singleton hx [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V h : finrank K V = 1 x : V hx : x ≠ 0 y : V this : span K {x} = ⊤ ⊢ ∃ c, c • x = y [PROOFSTEP] have : y ∈ Submodule.span K { x } := by rw [this]; trivial [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V h : finrank K V = 1 x : V hx : x ≠ 0 y : V this : span K {x} = ⊤ ⊢ y ∈ span K {x} [PROOFSTEP] rw [this] [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V h : finrank K V = 1 x : V hx : x ≠ 0 y : V this : span K {x} = ⊤ ⊢ y ∈ ⊤ [PROOFSTEP] trivial [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V h : finrank K V = 1 x : V hx : x ≠ 0 y : V this✝ : span K {x} = ⊤ this : y ∈ span K {x} ⊢ ∃ c, c • x = y [PROOFSTEP] exact mem_span_singleton.1 this [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V ι : Type u_1 hι : Nonempty ι inst✝ : Fintype ι b : ι → V lin_ind : LinearIndependent K b card_eq : Fintype.card ι = finrank K V ⊢ span K (Set.range b) = ⊤ [PROOFSTEP] by_cases fin : FiniteDimensional K V [GOAL] case pos K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V ι : Type u_1 hι : Nonempty ι inst✝ : Fintype ι b : ι → V lin_ind : LinearIndependent K b card_eq : Fintype.card ι = finrank K V fin : FiniteDimensional K V ⊢ span K (Set.range b) = ⊤ [PROOFSTEP] replace fin : FiniteDimensional _ _ := fin [GOAL] case pos K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V ι : Type u_1 hι : Nonempty ι inst✝ : Fintype ι b : ι → V lin_ind : LinearIndependent K b card_eq : Fintype.card ι = finrank K V fin : FiniteDimensional K V ⊢ span K (Set.range b) = ⊤ [PROOFSTEP] by_contra ne_top [GOAL] case pos K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V ι : Type u_1 hι : Nonempty ι inst✝ : Fintype ι b : ι → V lin_ind : LinearIndependent K b card_eq : Fintype.card ι = finrank K V fin : FiniteDimensional K V ne_top : ¬span K (Set.range b) = ⊤ ⊢ False [PROOFSTEP] have lt_top : span K (Set.range b) < ⊤ := lt_of_le_of_ne le_top ne_top [GOAL] case pos K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V ι : Type u_1 hι : Nonempty ι inst✝ : Fintype ι b : ι → V lin_ind : LinearIndependent K b card_eq : Fintype.card ι = finrank K V fin : FiniteDimensional K V ne_top : ¬span K (Set.range b) = ⊤ lt_top : span K (Set.range b) < ⊤ ⊢ False [PROOFSTEP] exact ne_of_lt (Submodule.finrank_lt lt_top) (_root_.trans (finrank_span_eq_card lin_ind) card_eq) [GOAL] case neg K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V ι : Type u_1 hι : Nonempty ι inst✝ : Fintype ι b : ι → V lin_ind : LinearIndependent K b card_eq : Fintype.card ι = finrank K V fin : ¬FiniteDimensional K V ⊢ span K (Set.range b) = ⊤ [PROOFSTEP] exfalso [GOAL] case neg.h K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V ι : Type u_1 hι : Nonempty ι inst✝ : Fintype ι b : ι → V lin_ind : LinearIndependent K b card_eq : Fintype.card ι = finrank K V fin : ¬FiniteDimensional K V ⊢ False [PROOFSTEP] apply ne_of_lt (Fintype.card_pos_iff.mpr hι) [GOAL] case neg.h K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V ι : Type u_1 hι : Nonempty ι inst✝ : Fintype ι b : ι → V lin_ind : LinearIndependent K b card_eq : Fintype.card ι = finrank K V fin : ¬FiniteDimensional K V ⊢ 0 = Fintype.card ι [PROOFSTEP] symm [GOAL] case neg.h K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V ι : Type u_1 hι : Nonempty ι inst✝ : Fintype ι b : ι → V lin_ind : LinearIndependent K b card_eq : Fintype.card ι = finrank K V fin : ¬FiniteDimensional K V ⊢ Fintype.card ι = 0 [PROOFSTEP] replace fin := (not_iff_not.2 IsNoetherian.iff_fg).2 fin [GOAL] case neg.h K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V ι : Type u_1 hι : Nonempty ι inst✝ : Fintype ι b : ι → V lin_ind : LinearIndependent K b card_eq : Fintype.card ι = finrank K V fin : ¬IsNoetherian K V ⊢ Fintype.card ι = 0 [PROOFSTEP] calc Fintype.card ι = finrank K V := card_eq _ = 0 := dif_neg (mt IsNoetherian.iff_rank_lt_aleph0.mpr fin) [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V s : Finset V hs : Finset.Nonempty s lin_ind : LinearIndependent K Subtype.val card_eq : Finset.card s = finrank K V ⊢ ↑(finsetBasisOfLinearIndependentOfCardEqFinrank hs lin_ind card_eq) = Subtype.val [PROOFSTEP] rw [finsetBasisOfLinearIndependentOfCardEqFinrank] [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V s : Finset V hs : Finset.Nonempty s lin_ind : LinearIndependent K Subtype.val card_eq : Finset.card s = finrank K V ⊢ ↑(basisOfLinearIndependentOfCardEqFinrank lin_ind (_ : Fintype.card { x // x ∈ s } = finrank K V)) = Subtype.val [PROOFSTEP] exact Basis.coe_mk _ _ [GOAL] K : Type u V : Type v inst✝⁴ : DivisionRing K inst✝³ : AddCommGroup V inst✝² : Module K V s : Set V inst✝¹ : Nonempty ↑s inst✝ : Fintype ↑s lin_ind : LinearIndependent K Subtype.val card_eq : Finset.card (Set.toFinset s) = finrank K V ⊢ ↑(setBasisOfLinearIndependentOfCardEqFinrank lin_ind card_eq) = Subtype.val [PROOFSTEP] rw [setBasisOfLinearIndependentOfCardEqFinrank] [GOAL] K : Type u V : Type v inst✝⁴ : DivisionRing K inst✝³ : AddCommGroup V inst✝² : Module K V s : Set V inst✝¹ : Nonempty ↑s inst✝ : Fintype ↑s lin_ind : LinearIndependent K Subtype.val card_eq : Finset.card (Set.toFinset s) = finrank K V ⊢ ↑(basisOfLinearIndependentOfCardEqFinrank lin_ind (_ : Fintype.card ↑s = finrank K V)) = Subtype.val [PROOFSTEP] exact Basis.coe_mk _ _ [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v : V nz : v ≠ 0 h : finrank K V = 1 ⊢ span K {v} = ⊤ [PROOFSTEP] simpa using (basisSingleton PUnit.{u + 1} h v nz).span_eq [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v : V nz : v ≠ 0 s : span K {v} = ⊤ ⊢ ⊤ ≤ span K (Set.range fun x => ↑x) [PROOFSTEP] convert s.ge [GOAL] case h.e'_4.h.e'_6 K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v : V nz : v ≠ 0 s : span K {v} = ⊤ ⊢ (Set.range fun x => ↑x) = {v} [PROOFSTEP] simp [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v : V nz : v ≠ 0 ⊢ finrank K V = 1 ↔ ∀ (w : V), ∃ c, c • v = w [PROOFSTEP] rw [finrank_eq_one_iff_of_nonzero v nz] [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V v : V nz : v ≠ 0 ⊢ span K {v} = ⊤ ↔ ∀ (w : V), ∃ c, c • v = w [PROOFSTEP] apply span_singleton_eq_top_iff [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V ι : Type u_1 inst✝ : Unique ι ⊢ finrank K V = 1 ↔ Nonempty (Basis ι K V) [PROOFSTEP] constructor [GOAL] case mp K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V ι : Type u_1 inst✝ : Unique ι ⊢ finrank K V = 1 → Nonempty (Basis ι K V) [PROOFSTEP] intro h [GOAL] case mp K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V ι : Type u_1 inst✝ : Unique ι h : finrank K V = 1 ⊢ Nonempty (Basis ι K V) [PROOFSTEP] haveI := finiteDimensional_of_finrank (_root_.zero_lt_one.trans_le h.symm.le) [GOAL] case mp K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V ι : Type u_1 inst✝ : Unique ι h : finrank K V = 1 this : FiniteDimensional K V ⊢ Nonempty (Basis ι K V) [PROOFSTEP] exact ⟨basisUnique ι h⟩ [GOAL] case mpr K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V ι : Type u_1 inst✝ : Unique ι ⊢ Nonempty (Basis ι K V) → finrank K V = 1 [PROOFSTEP] rintro ⟨b⟩ [GOAL] case mpr.intro K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V ι : Type u_1 inst✝ : Unique ι b : Basis ι K V ⊢ finrank K V = 1 [PROOFSTEP] simpa using finrank_eq_card_basis b [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V ⊢ finrank K V = 1 ↔ ∃ v _n, ∀ (w : V), ∃ c, c • v = w [PROOFSTEP] rw [finrank_eq_one_iff PUnit.{u + 1}, Basis.basis_singleton_iff PUnit] [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V ⊢ finrank K V ≤ 1 ↔ ∃ v, ∀ (w : V), ∃ c, c • v = w [PROOFSTEP] constructor [GOAL] case mp K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V ⊢ finrank K V ≤ 1 → ∃ v, ∀ (w : V), ∃ c, c • v = w [PROOFSTEP] intro h [GOAL] case mp K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V h : finrank K V ≤ 1 ⊢ ∃ v, ∀ (w : V), ∃ c, c • v = w [PROOFSTEP] by_cases h' : finrank K V = 0 [GOAL] case pos K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V h : finrank K V ≤ 1 h' : finrank K V = 0 ⊢ ∃ v, ∀ (w : V), ∃ c, c • v = w [PROOFSTEP] use 0 [GOAL] case h K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V h : finrank K V ≤ 1 h' : finrank K V = 0 ⊢ ∀ (w : V), ∃ c, c • 0 = w [PROOFSTEP] intro w [GOAL] case h K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V h : finrank K V ≤ 1 h' : finrank K V = 0 w : V ⊢ ∃ c, c • 0 = w [PROOFSTEP] use 0 [GOAL] case h K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V h : finrank K V ≤ 1 h' : finrank K V = 0 w : V ⊢ 0 • 0 = w [PROOFSTEP] haveI := finrank_zero_iff.mp h' [GOAL] case h K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V h : finrank K V ≤ 1 h' : finrank K V = 0 w : V this : Subsingleton V ⊢ 0 • 0 = w [PROOFSTEP] apply Subsingleton.elim [GOAL] case neg K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V h : finrank K V ≤ 1 h' : ¬finrank K V = 0 ⊢ ∃ v, ∀ (w : V), ∃ c, c • v = w [PROOFSTEP] replace h' := zero_lt_iff.mpr h' [GOAL] case neg K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V h : finrank K V ≤ 1 h' : 0 < finrank K V ⊢ ∃ v, ∀ (w : V), ∃ c, c • v = w [PROOFSTEP] have : finrank K V = 1 := by linarith [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V h : finrank K V ≤ 1 h' : 0 < finrank K V ⊢ finrank K V = 1 [PROOFSTEP] linarith [GOAL] case neg K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V h : finrank K V ≤ 1 h' : 0 < finrank K V this : finrank K V = 1 ⊢ ∃ v, ∀ (w : V), ∃ c, c • v = w [PROOFSTEP] obtain ⟨v, -, p⟩ := finrank_eq_one_iff'.mp this [GOAL] case neg.intro.intro K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V h : finrank K V ≤ 1 h' : 0 < finrank K V this : finrank K V = 1 v : V p : ∀ (w : V), ∃ c, c • v = w ⊢ ∃ v, ∀ (w : V), ∃ c, c • v = w [PROOFSTEP] use v, p [GOAL] case mpr K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V ⊢ (∃ v, ∀ (w : V), ∃ c, c • v = w) → finrank K V ≤ 1 [PROOFSTEP] rintro ⟨v, p⟩ [GOAL] case mpr.intro K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V v : V p : ∀ (w : V), ∃ c, c • v = w ⊢ finrank K V ≤ 1 [PROOFSTEP] exact finrank_le_one v p [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V W : Submodule K V inst✝ : FiniteDimensional K { x // x ∈ W } ⊢ finrank K { x // x ∈ W } ≤ 1 ↔ IsPrincipal W [PROOFSTEP] rw [← W.rank_le_one_iff_isPrincipal, ← finrank_eq_rank, ← Cardinal.natCast_le, Nat.cast_one] [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V ⊢ finrank K V ≤ 1 ↔ IsPrincipal ⊤ [PROOFSTEP] rw [← Module.rank_le_one_iff_top_isPrincipal, ← finrank_eq_rank, ← Cardinal.natCast_le, Nat.cast_one] [GOAL] K : Type u V : Type v inst✝⁸ : DivisionRing K inst✝⁷ : AddCommGroup V inst✝⁶ : Module K V W : Type u_1 A : Type u_2 inst✝⁵ : Semiring A inst✝⁴ : Module A V inst✝³ : AddCommGroup W inst✝² : Module K W inst✝¹ : Module A W inst✝ : LinearMap.CompatibleSMul V W K A h : finrank K W = 1 f : V →ₗ[A] W w : f ≠ 0 ⊢ Surjective ↑f [PROOFSTEP] change Surjective (f.restrictScalars K) [GOAL] K : Type u V : Type v inst✝⁸ : DivisionRing K inst✝⁷ : AddCommGroup V inst✝⁶ : Module K V W : Type u_1 A : Type u_2 inst✝⁵ : Semiring A inst✝⁴ : Module A V inst✝³ : AddCommGroup W inst✝² : Module K W inst✝¹ : Module A W inst✝ : LinearMap.CompatibleSMul V W K A h : finrank K W = 1 f : V →ₗ[A] W w : f ≠ 0 ⊢ Surjective ↑(↑K f) [PROOFSTEP] obtain ⟨v, n⟩ := FunLike.ne_iff.mp w [GOAL] case intro K : Type u V : Type v inst✝⁸ : DivisionRing K inst✝⁷ : AddCommGroup V inst✝⁶ : Module K V W : Type u_1 A : Type u_2 inst✝⁵ : Semiring A inst✝⁴ : Module A V inst✝³ : AddCommGroup W inst✝² : Module K W inst✝¹ : Module A W inst✝ : LinearMap.CompatibleSMul V W K A h : finrank K W = 1 f : V →ₗ[A] W w : f ≠ 0 v : V n : ↑f v ≠ ↑0 v ⊢ Surjective ↑(↑K f) [PROOFSTEP] intro z [GOAL] case intro K : Type u V : Type v inst✝⁸ : DivisionRing K inst✝⁷ : AddCommGroup V inst✝⁶ : Module K V W : Type u_1 A : Type u_2 inst✝⁵ : Semiring A inst✝⁴ : Module A V inst✝³ : AddCommGroup W inst✝² : Module K W inst✝¹ : Module A W inst✝ : LinearMap.CompatibleSMul V W K A h : finrank K W = 1 f : V →ₗ[A] W w : f ≠ 0 v : V n : ↑f v ≠ ↑0 v z : W ⊢ ∃ a, ↑(↑K f) a = z [PROOFSTEP] obtain ⟨c, rfl⟩ := (finrank_eq_one_iff_of_nonzero' (f v) n).mp h z [GOAL] case intro.intro K : Type u V : Type v inst✝⁸ : DivisionRing K inst✝⁷ : AddCommGroup V inst✝⁶ : Module K V W : Type u_1 A : Type u_2 inst✝⁵ : Semiring A inst✝⁴ : Module A V inst✝³ : AddCommGroup W inst✝² : Module K W inst✝¹ : Module A W inst✝ : LinearMap.CompatibleSMul V W K A h : finrank K W = 1 f : V →ₗ[A] W w : f ≠ 0 v : V n : ↑f v ≠ ↑0 v c : K ⊢ ∃ a, ↑(↑K f) a = c • ↑f v [PROOFSTEP] exact ⟨c • v, by simp⟩ [GOAL] K : Type u V : Type v inst✝⁸ : DivisionRing K inst✝⁷ : AddCommGroup V inst✝⁶ : Module K V W : Type u_1 A : Type u_2 inst✝⁵ : Semiring A inst✝⁴ : Module A V inst✝³ : AddCommGroup W inst✝² : Module K W inst✝¹ : Module A W inst✝ : LinearMap.CompatibleSMul V W K A h : finrank K W = 1 f : V →ₗ[A] W w : f ≠ 0 v : V n : ↑f v ≠ ↑0 v c : K ⊢ ↑(↑K f) (c • v) = c • ↑f v [PROOFSTEP] simp [GOAL] K : Type u V : Type v inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V A : Type u_1 inst✝³ : Semiring A inst✝² : Module A V inst✝¹ : SMul K A inst✝ : IsScalarTower K A V h : finrank K V = 1 ⊢ IsSimpleOrder (Submodule A V) [PROOFSTEP] haveI := nontrivial_of_finrank_eq_succ h [GOAL] K : Type u V : Type v inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V A : Type u_1 inst✝³ : Semiring A inst✝² : Module A V inst✝¹ : SMul K A inst✝ : IsScalarTower K A V h : finrank K V = 1 this : Nontrivial V ⊢ IsSimpleOrder (Submodule A V) [PROOFSTEP] refine' ⟨fun S => or_iff_not_imp_left.2 fun hn => _⟩ [GOAL] K : Type u V : Type v inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V A : Type u_1 inst✝³ : Semiring A inst✝² : Module A V inst✝¹ : SMul K A inst✝ : IsScalarTower K A V h : finrank K V = 1 this : Nontrivial V S : Submodule A V hn : ¬S = ⊥ ⊢ S = ⊤ [PROOFSTEP] rw [← restrictScalars_inj K] at hn ⊢ [GOAL] K : Type u V : Type v inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V A : Type u_1 inst✝³ : Semiring A inst✝² : Module A V inst✝¹ : SMul K A inst✝ : IsScalarTower K A V h : finrank K V = 1 this : Nontrivial V S : Submodule A V hn : ¬restrictScalars K S = restrictScalars K ⊥ ⊢ restrictScalars K S = restrictScalars K ⊤ [PROOFSTEP] haveI : FiniteDimensional _ _ := finiteDimensional_of_finrank_eq_succ h [GOAL] K : Type u V : Type v inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V A : Type u_1 inst✝³ : Semiring A inst✝² : Module A V inst✝¹ : SMul K A inst✝ : IsScalarTower K A V h : finrank K V = 1 this✝ : Nontrivial V S : Submodule A V hn : ¬restrictScalars K S = restrictScalars K ⊥ this : FiniteDimensional K V ⊢ restrictScalars K S = restrictScalars K ⊤ [PROOFSTEP] refine' eq_top_of_finrank_eq ((Submodule.finrank_le _).antisymm _) [GOAL] K : Type u V : Type v inst✝⁶ : DivisionRing K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V A : Type u_1 inst✝³ : Semiring A inst✝² : Module A V inst✝¹ : SMul K A inst✝ : IsScalarTower K A V h : finrank K V = 1 this✝ : Nontrivial V S : Submodule A V hn : ¬restrictScalars K S = restrictScalars K ⊥ this : FiniteDimensional K V ⊢ finrank K V ≤ finrank K { x // x ∈ restrictScalars K S } [PROOFSTEP] simpa only [h, finrank_bot] using Submodule.finrank_strictMono (Ne.bot_lt hn) [GOAL] K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝² : Field F inst✝¹ : Ring E inst✝ : Algebra F E ⊢ FiniteDimensional F { x // x ∈ ⊥ } [PROOFSTEP] nontriviality E [GOAL] K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝² : Field F inst✝¹ : Ring E inst✝ : Algebra F E ✝ : Nontrivial E ⊢ FiniteDimensional F { x // x ∈ ⊥ } [PROOFSTEP] exact finiteDimensional_of_rank_eq_one Subalgebra.rank_bot [GOAL] K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝² : Field F inst✝¹ : Ring E inst✝ : Algebra F E S : Subalgebra F E h : Module.rank F { x // x ∈ S } ≤ 1 ⊢ S = ⊥ [PROOFSTEP] nontriviality E [GOAL] K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝² : Field F inst✝¹ : Ring E inst✝ : Algebra F E S : Subalgebra F E h : Module.rank F { x // x ∈ S } ≤ 1 ✝ : Nontrivial E ⊢ S = ⊥ [PROOFSTEP] obtain ⟨m, _, he⟩ := Cardinal.exists_nat_eq_of_le_nat (h.trans_eq Nat.cast_one.symm) -- porting note: fails without explicit type [GOAL] case intro.intro K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝² : Field F inst✝¹ : Ring E inst✝ : Algebra F E S : Subalgebra F E h : Module.rank F { x // x ∈ S } ≤ 1 ✝ : Nontrivial E m : ℕ left✝ : m ≤ 1 he : Module.rank F { x // x ∈ S } = ↑m ⊢ S = ⊥ [PROOFSTEP] haveI : FiniteDimensional F S := finiteDimensional_of_rank_eq_nat he [GOAL] case intro.intro K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝² : Field F inst✝¹ : Ring E inst✝ : Algebra F E S : Subalgebra F E h : Module.rank F { x // x ∈ S } ≤ 1 ✝ : Nontrivial E m : ℕ left✝ : m ≤ 1 he : Module.rank F { x // x ∈ S } = ↑m this : FiniteDimensional F { x // x ∈ S } ⊢ S = ⊥ [PROOFSTEP] rw [← not_bot_lt_iff, ← Subalgebra.toSubmodule.lt_iff_lt] -- porting note: fails without explicit type [GOAL] case intro.intro K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝² : Field F inst✝¹ : Ring E inst✝ : Algebra F E S : Subalgebra F E h : Module.rank F { x // x ∈ S } ≤ 1 ✝ : Nontrivial E m : ℕ left✝ : m ≤ 1 he : Module.rank F { x // x ∈ S } = ↑m this : FiniteDimensional F { x // x ∈ S } ⊢ ¬↑toSubmodule ⊥ < ↑toSubmodule S [PROOFSTEP] haveI : FiniteDimensional F (Subalgebra.toSubmodule S) := S.toSubmoduleEquiv.symm.finiteDimensional [GOAL] case intro.intro K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝² : Field F inst✝¹ : Ring E inst✝ : Algebra F E S : Subalgebra F E h : Module.rank F { x // x ∈ S } ≤ 1 ✝ : Nontrivial E m : ℕ left✝ : m ≤ 1 he : Module.rank F { x // x ∈ S } = ↑m this✝ : FiniteDimensional F { x // x ∈ S } this : FiniteDimensional F { x // x ∈ ↑toSubmodule S } ⊢ ¬↑toSubmodule ⊥ < ↑toSubmodule S [PROOFSTEP] refine fun hl => (Submodule.finrank_lt_finrank_of_lt hl).not_le (natCast_le.1 ?_) [GOAL] case intro.intro K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝² : Field F inst✝¹ : Ring E inst✝ : Algebra F E S : Subalgebra F E h : Module.rank F { x // x ∈ S } ≤ 1 ✝ : Nontrivial E m : ℕ left✝ : m ≤ 1 he : Module.rank F { x // x ∈ S } = ↑m this✝ : FiniteDimensional F { x // x ∈ S } this : FiniteDimensional F { x // x ∈ ↑toSubmodule S } hl : ↑toSubmodule ⊥ < ↑toSubmodule S ⊢ ↑(finrank F { x // x ∈ ↑toSubmodule S }) ≤ ↑(finrank F { x // x ∈ ↑toSubmodule ⊥ }) [PROOFSTEP] iterate 2 rw [Subalgebra.finrank_toSubmodule, finrank_eq_rank] [GOAL] case intro.intro K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝² : Field F inst✝¹ : Ring E inst✝ : Algebra F E S : Subalgebra F E h : Module.rank F { x // x ∈ S } ≤ 1 ✝ : Nontrivial E m : ℕ left✝ : m ≤ 1 he : Module.rank F { x // x ∈ S } = ↑m this✝ : FiniteDimensional F { x // x ∈ S } this : FiniteDimensional F { x // x ∈ ↑toSubmodule S } hl : ↑toSubmodule ⊥ < ↑toSubmodule S ⊢ ↑(finrank F { x // x ∈ ↑toSubmodule S }) ≤ ↑(finrank F { x // x ∈ ↑toSubmodule ⊥ }) [PROOFSTEP] rw [Subalgebra.finrank_toSubmodule, finrank_eq_rank] [GOAL] case intro.intro K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝² : Field F inst✝¹ : Ring E inst✝ : Algebra F E S : Subalgebra F E h : Module.rank F { x // x ∈ S } ≤ 1 ✝ : Nontrivial E m : ℕ left✝ : m ≤ 1 he : Module.rank F { x // x ∈ S } = ↑m this✝ : FiniteDimensional F { x // x ∈ S } this : FiniteDimensional F { x // x ∈ ↑toSubmodule S } hl : ↑toSubmodule ⊥ < ↑toSubmodule S ⊢ Module.rank F { x // x ∈ S } ≤ ↑(finrank F { x // x ∈ ↑toSubmodule ⊥ }) [PROOFSTEP] rw [Subalgebra.finrank_toSubmodule, finrank_eq_rank] [GOAL] case intro.intro K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝² : Field F inst✝¹ : Ring E inst✝ : Algebra F E S : Subalgebra F E h : Module.rank F { x // x ∈ S } ≤ 1 ✝ : Nontrivial E m : ℕ left✝ : m ≤ 1 he : Module.rank F { x // x ∈ S } = ↑m this✝ : FiniteDimensional F { x // x ∈ S } this : FiniteDimensional F { x // x ∈ ↑toSubmodule S } hl : ↑toSubmodule ⊥ < ↑toSubmodule S ⊢ Module.rank F { x // x ∈ S } ≤ Module.rank F { x // x ∈ ⊥ } [PROOFSTEP] exact h.trans_eq Subalgebra.rank_bot.symm [GOAL] K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝² : Field F inst✝¹ : Ring E inst✝ : Algebra F E S : Subalgebra F E h : finrank F { x // x ∈ S } = 1 ⊢ Module.rank F { x // x ∈ S } ≤ 1 [PROOFSTEP] haveI : FiniteDimensional F S := finiteDimensional_of_finrank_eq_succ h [GOAL] K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝² : Field F inst✝¹ : Ring E inst✝ : Algebra F E S : Subalgebra F E h : finrank F { x // x ∈ S } = 1 this : FiniteDimensional F { x // x ∈ S } ⊢ Module.rank F { x // x ∈ S } ≤ 1 [PROOFSTEP] rw [← finrank_eq_rank, h, Nat.cast_one] [GOAL] K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝³ : Field F inst✝² : Ring E inst✝¹ : Algebra F E inst✝ : Nontrivial E ⊢ ⊥ = ⊤ ↔ Module.rank F E = 1 [PROOFSTEP] rw [← rank_top, Subalgebra.rank_eq_one_iff, eq_comm] [GOAL] K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝³ : Field F inst✝² : Ring E inst✝¹ : Algebra F E inst✝ : Nontrivial E ⊢ ⊥ = ⊤ ↔ finrank F E = 1 [PROOFSTEP] rw [← finrank_top, ← subalgebra_top_finrank_eq_submodule_top_finrank, Subalgebra.finrank_eq_one_iff, eq_comm] [GOAL] K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝² : Field F inst✝¹ : Ring E inst✝ : Algebra F E hr : finrank F E = 2 i : Nontrivial E := nontrivial_of_finrank_pos (LT.lt.trans_eq zero_lt_two (Eq.symm hr)) h : ⊥ = ⊤ ⊢ False [PROOFSTEP] cases hr.symm.trans (Subalgebra.bot_eq_top_iff_finrank_eq_one.1 h) [GOAL] K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝² : Field F inst✝¹ : Ring E inst✝ : Algebra F E hr : finrank F E = 2 i : Nontrivial E := nontrivial_of_finrank_pos (LT.lt.trans_eq zero_lt_two (Eq.symm hr)) ⊢ ∀ (a : Subalgebra F E), a = ⊥ ∨ a = ⊤ [PROOFSTEP] intro S [GOAL] K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝² : Field F inst✝¹ : Ring E inst✝ : Algebra F E hr : finrank F E = 2 i : Nontrivial E := nontrivial_of_finrank_pos (LT.lt.trans_eq zero_lt_two (Eq.symm hr)) S : Subalgebra F E ⊢ S = ⊥ ∨ S = ⊤ [PROOFSTEP] haveI : FiniteDimensional F E := finiteDimensional_of_finrank_eq_succ hr [GOAL] K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝² : Field F inst✝¹ : Ring E inst✝ : Algebra F E hr : finrank F E = 2 i : Nontrivial E := nontrivial_of_finrank_pos (LT.lt.trans_eq zero_lt_two (Eq.symm hr)) S : Subalgebra F E this : FiniteDimensional F E ⊢ S = ⊥ ∨ S = ⊤ [PROOFSTEP] haveI : FiniteDimensional F S := FiniteDimensional.finiteDimensional_submodule (Subalgebra.toSubmodule S) [GOAL] K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝² : Field F inst✝¹ : Ring E inst✝ : Algebra F E hr : finrank F E = 2 i : Nontrivial E := nontrivial_of_finrank_pos (LT.lt.trans_eq zero_lt_two (Eq.symm hr)) S : Subalgebra F E this✝ : FiniteDimensional F E this : FiniteDimensional F { x // x ∈ S } ⊢ S = ⊥ ∨ S = ⊤ [PROOFSTEP] have : finrank F S ≤ 2 := hr ▸ S.toSubmodule.finrank_le [GOAL] K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝² : Field F inst✝¹ : Ring E inst✝ : Algebra F E hr : finrank F E = 2 i : Nontrivial E := nontrivial_of_finrank_pos (LT.lt.trans_eq zero_lt_two (Eq.symm hr)) S : Subalgebra F E this✝¹ : FiniteDimensional F E this✝ : FiniteDimensional F { x // x ∈ S } this : finrank F { x // x ∈ S } ≤ 2 ⊢ S = ⊥ ∨ S = ⊤ [PROOFSTEP] have : 0 < finrank F S := finrank_pos_iff.mpr inferInstance [GOAL] K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝² : Field F inst✝¹ : Ring E inst✝ : Algebra F E hr : finrank F E = 2 i : Nontrivial E := nontrivial_of_finrank_pos (LT.lt.trans_eq zero_lt_two (Eq.symm hr)) S : Subalgebra F E this✝² : FiniteDimensional F E this✝¹ : FiniteDimensional F { x // x ∈ S } this✝ : finrank F { x // x ∈ S } ≤ 2 this : 0 < finrank F { x // x ∈ S } ⊢ S = ⊥ ∨ S = ⊤ [PROOFSTEP] interval_cases h : finrank F { x // x ∈ S } [GOAL] case «1» K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝² : Field F inst✝¹ : Ring E inst✝ : Algebra F E hr : finrank F E = 2 i : Nontrivial E := nontrivial_of_finrank_pos (LT.lt.trans_eq zero_lt_two (Eq.symm hr)) S : Subalgebra F E this✝² : FiniteDimensional F E this✝¹ : FiniteDimensional F { x // x ∈ S } h : finrank F { x // x ∈ S } = 1 this✝ : 1 ≤ 2 this : 0 < 1 ⊢ S = ⊥ ∨ S = ⊤ [PROOFSTEP] left [GOAL] case «1».h K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝² : Field F inst✝¹ : Ring E inst✝ : Algebra F E hr : finrank F E = 2 i : Nontrivial E := nontrivial_of_finrank_pos (LT.lt.trans_eq zero_lt_two (Eq.symm hr)) S : Subalgebra F E this✝² : FiniteDimensional F E this✝¹ : FiniteDimensional F { x // x ∈ S } h : finrank F { x // x ∈ S } = 1 this✝ : 1 ≤ 2 this : 0 < 1 ⊢ S = ⊥ [PROOFSTEP] exact Subalgebra.eq_bot_of_finrank_one h [GOAL] case «2» K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝² : Field F inst✝¹ : Ring E inst✝ : Algebra F E hr : finrank F E = 2 i : Nontrivial E := nontrivial_of_finrank_pos (LT.lt.trans_eq zero_lt_two (Eq.symm hr)) S : Subalgebra F E this✝² : FiniteDimensional F E this✝¹ : FiniteDimensional F { x // x ∈ S } h : finrank F { x // x ∈ S } = 2 this✝ : 2 ≤ 2 this : 0 < 2 ⊢ S = ⊥ ∨ S = ⊤ [PROOFSTEP] right [GOAL] case «2».h K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝² : Field F inst✝¹ : Ring E inst✝ : Algebra F E hr : finrank F E = 2 i : Nontrivial E := nontrivial_of_finrank_pos (LT.lt.trans_eq zero_lt_two (Eq.symm hr)) S : Subalgebra F E this✝² : FiniteDimensional F E this✝¹ : FiniteDimensional F { x // x ∈ S } h : finrank F { x // x ∈ S } = 2 this✝ : 2 ≤ 2 this : 0 < 2 ⊢ S = ⊤ [PROOFSTEP] rw [← hr] at h [GOAL] case «2».h K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝² : Field F inst✝¹ : Ring E inst✝ : Algebra F E hr : finrank F E = 2 i : Nontrivial E := nontrivial_of_finrank_pos (LT.lt.trans_eq zero_lt_two (Eq.symm hr)) S : Subalgebra F E this✝² : FiniteDimensional F E this✝¹ : FiniteDimensional F { x // x ∈ S } h : finrank F { x // x ∈ S } = finrank F E this✝ : 2 ≤ 2 this : 0 < 2 ⊢ S = ⊤ [PROOFSTEP] rw [← Algebra.toSubmodule_eq_top] [GOAL] case «2».h K : Type u V : Type v F : Type u_1 E : Type u_2 inst✝² : Field F inst✝¹ : Ring E inst✝ : Algebra F E hr : finrank F E = 2 i : Nontrivial E := nontrivial_of_finrank_pos (LT.lt.trans_eq zero_lt_two (Eq.symm hr)) S : Subalgebra F E this✝² : FiniteDimensional F E this✝¹ : FiniteDimensional F { x // x ∈ S } h : finrank F { x // x ∈ S } = finrank F E this✝ : 2 ≤ 2 this : 0 < 2 ⊢ ↑toSubmodule S = ⊤ [PROOFSTEP] exact eq_top_of_finrank_eq h [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : End K V ⊢ ∃ k, k ≤ finrank K V ∧ LinearMap.ker (f ^ k) = LinearMap.ker (f ^ Nat.succ k) [PROOFSTEP] classical by_contra h_contra simp_rw [not_exists, not_and] at h_contra have h_le_ker_pow : ∀ n : ℕ, n ≤ (finrank K V).succ → n ≤ finrank K (LinearMap.ker (f ^ n)) := by intro n hn induction' n with n ih · exact zero_le (finrank _ _) · have h_ker_lt_ker : LinearMap.ker (f ^ n) < LinearMap.ker (f ^ n.succ) := by refine' lt_of_le_of_ne _ (h_contra n (Nat.le_of_succ_le_succ hn)) rw [pow_succ] apply LinearMap.ker_le_ker_comp have h_finrank_lt_finrank : finrank K (LinearMap.ker (f ^ n)) < finrank K (LinearMap.ker (f ^ n.succ)) := by apply Submodule.finrank_lt_finrank_of_lt h_ker_lt_ker calc n.succ ≤ (finrank K ↑(LinearMap.ker (f ^ n))).succ := Nat.succ_le_succ (ih (Nat.le_of_succ_le hn)) _ ≤ finrank K ↑(LinearMap.ker (f ^ n.succ)) := Nat.succ_le_of_lt h_finrank_lt_finrank have h_any_n_lt : ∀ n, n ≤ (finrank K V).succ → n ≤ finrank K V := fun n hn => (h_le_ker_pow n hn).trans (Submodule.finrank_le _) show False exact Nat.not_succ_le_self _ (h_any_n_lt (finrank K V).succ (finrank K V).succ.le_refl) [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : End K V ⊢ ∃ k, k ≤ finrank K V ∧ LinearMap.ker (f ^ k) = LinearMap.ker (f ^ Nat.succ k) [PROOFSTEP] by_contra h_contra [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : End K V h_contra : ¬∃ k, k ≤ finrank K V ∧ LinearMap.ker (f ^ k) = LinearMap.ker (f ^ Nat.succ k) ⊢ False [PROOFSTEP] simp_rw [not_exists, not_and] at h_contra [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : End K V h_contra : ∀ (x : ℕ), x ≤ finrank K V → ¬LinearMap.ker (f ^ x) = LinearMap.ker (f ^ Nat.succ x) ⊢ False [PROOFSTEP] have h_le_ker_pow : ∀ n : ℕ, n ≤ (finrank K V).succ → n ≤ finrank K (LinearMap.ker (f ^ n)) := by intro n hn induction' n with n ih · exact zero_le (finrank _ _) · have h_ker_lt_ker : LinearMap.ker (f ^ n) < LinearMap.ker (f ^ n.succ) := by refine' lt_of_le_of_ne _ (h_contra n (Nat.le_of_succ_le_succ hn)) rw [pow_succ] apply LinearMap.ker_le_ker_comp have h_finrank_lt_finrank : finrank K (LinearMap.ker (f ^ n)) < finrank K (LinearMap.ker (f ^ n.succ)) := by apply Submodule.finrank_lt_finrank_of_lt h_ker_lt_ker calc n.succ ≤ (finrank K ↑(LinearMap.ker (f ^ n))).succ := Nat.succ_le_succ (ih (Nat.le_of_succ_le hn)) _ ≤ finrank K ↑(LinearMap.ker (f ^ n.succ)) := Nat.succ_le_of_lt h_finrank_lt_finrank [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : End K V h_contra : ∀ (x : ℕ), x ≤ finrank K V → ¬LinearMap.ker (f ^ x) = LinearMap.ker (f ^ Nat.succ x) ⊢ ∀ (n : ℕ), n ≤ Nat.succ (finrank K V) → n ≤ finrank K { x // x ∈ LinearMap.ker (f ^ n) } [PROOFSTEP] intro n hn [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : End K V h_contra : ∀ (x : ℕ), x ≤ finrank K V → ¬LinearMap.ker (f ^ x) = LinearMap.ker (f ^ Nat.succ x) n : ℕ hn : n ≤ Nat.succ (finrank K V) ⊢ n ≤ finrank K { x // x ∈ LinearMap.ker (f ^ n) } [PROOFSTEP] induction' n with n ih [GOAL] case zero K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : End K V h_contra : ∀ (x : ℕ), x ≤ finrank K V → ¬LinearMap.ker (f ^ x) = LinearMap.ker (f ^ Nat.succ x) n : ℕ hn✝ : n ≤ Nat.succ (finrank K V) hn : Nat.zero ≤ Nat.succ (finrank K V) ⊢ Nat.zero ≤ finrank K { x // x ∈ LinearMap.ker (f ^ Nat.zero) } [PROOFSTEP] exact zero_le (finrank _ _) [GOAL] case succ K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : End K V h_contra : ∀ (x : ℕ), x ≤ finrank K V → ¬LinearMap.ker (f ^ x) = LinearMap.ker (f ^ Nat.succ x) n✝ : ℕ hn✝ : n✝ ≤ Nat.succ (finrank K V) n : ℕ ih : n ≤ Nat.succ (finrank K V) → n ≤ finrank K { x // x ∈ LinearMap.ker (f ^ n) } hn : Nat.succ n ≤ Nat.succ (finrank K V) ⊢ Nat.succ n ≤ finrank K { x // x ∈ LinearMap.ker (f ^ Nat.succ n) } [PROOFSTEP] have h_ker_lt_ker : LinearMap.ker (f ^ n) < LinearMap.ker (f ^ n.succ) := by refine' lt_of_le_of_ne _ (h_contra n (Nat.le_of_succ_le_succ hn)) rw [pow_succ] apply LinearMap.ker_le_ker_comp [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : End K V h_contra : ∀ (x : ℕ), x ≤ finrank K V → ¬LinearMap.ker (f ^ x) = LinearMap.ker (f ^ Nat.succ x) n✝ : ℕ hn✝ : n✝ ≤ Nat.succ (finrank K V) n : ℕ ih : n ≤ Nat.succ (finrank K V) → n ≤ finrank K { x // x ∈ LinearMap.ker (f ^ n) } hn : Nat.succ n ≤ Nat.succ (finrank K V) ⊢ LinearMap.ker (f ^ n) < LinearMap.ker (f ^ Nat.succ n) [PROOFSTEP] refine' lt_of_le_of_ne _ (h_contra n (Nat.le_of_succ_le_succ hn)) [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : End K V h_contra : ∀ (x : ℕ), x ≤ finrank K V → ¬LinearMap.ker (f ^ x) = LinearMap.ker (f ^ Nat.succ x) n✝ : ℕ hn✝ : n✝ ≤ Nat.succ (finrank K V) n : ℕ ih : n ≤ Nat.succ (finrank K V) → n ≤ finrank K { x // x ∈ LinearMap.ker (f ^ n) } hn : Nat.succ n ≤ Nat.succ (finrank K V) ⊢ LinearMap.ker (f ^ n) ≤ LinearMap.ker (f ^ Nat.succ n) [PROOFSTEP] rw [pow_succ] [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : End K V h_contra : ∀ (x : ℕ), x ≤ finrank K V → ¬LinearMap.ker (f ^ x) = LinearMap.ker (f ^ Nat.succ x) n✝ : ℕ hn✝ : n✝ ≤ Nat.succ (finrank K V) n : ℕ ih : n ≤ Nat.succ (finrank K V) → n ≤ finrank K { x // x ∈ LinearMap.ker (f ^ n) } hn : Nat.succ n ≤ Nat.succ (finrank K V) ⊢ LinearMap.ker (f ^ n) ≤ LinearMap.ker (f * f ^ n) [PROOFSTEP] apply LinearMap.ker_le_ker_comp [GOAL] case succ K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : End K V h_contra : ∀ (x : ℕ), x ≤ finrank K V → ¬LinearMap.ker (f ^ x) = LinearMap.ker (f ^ Nat.succ x) n✝ : ℕ hn✝ : n✝ ≤ Nat.succ (finrank K V) n : ℕ ih : n ≤ Nat.succ (finrank K V) → n ≤ finrank K { x // x ∈ LinearMap.ker (f ^ n) } hn : Nat.succ n ≤ Nat.succ (finrank K V) h_ker_lt_ker : LinearMap.ker (f ^ n) < LinearMap.ker (f ^ Nat.succ n) ⊢ Nat.succ n ≤ finrank K { x // x ∈ LinearMap.ker (f ^ Nat.succ n) } [PROOFSTEP] have h_finrank_lt_finrank : finrank K (LinearMap.ker (f ^ n)) < finrank K (LinearMap.ker (f ^ n.succ)) := by apply Submodule.finrank_lt_finrank_of_lt h_ker_lt_ker [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : End K V h_contra : ∀ (x : ℕ), x ≤ finrank K V → ¬LinearMap.ker (f ^ x) = LinearMap.ker (f ^ Nat.succ x) n✝ : ℕ hn✝ : n✝ ≤ Nat.succ (finrank K V) n : ℕ ih : n ≤ Nat.succ (finrank K V) → n ≤ finrank K { x // x ∈ LinearMap.ker (f ^ n) } hn : Nat.succ n ≤ Nat.succ (finrank K V) h_ker_lt_ker : LinearMap.ker (f ^ n) < LinearMap.ker (f ^ Nat.succ n) ⊢ finrank K { x // x ∈ LinearMap.ker (f ^ n) } < finrank K { x // x ∈ LinearMap.ker (f ^ Nat.succ n) } [PROOFSTEP] apply Submodule.finrank_lt_finrank_of_lt h_ker_lt_ker [GOAL] case succ K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : End K V h_contra : ∀ (x : ℕ), x ≤ finrank K V → ¬LinearMap.ker (f ^ x) = LinearMap.ker (f ^ Nat.succ x) n✝ : ℕ hn✝ : n✝ ≤ Nat.succ (finrank K V) n : ℕ ih : n ≤ Nat.succ (finrank K V) → n ≤ finrank K { x // x ∈ LinearMap.ker (f ^ n) } hn : Nat.succ n ≤ Nat.succ (finrank K V) h_ker_lt_ker : LinearMap.ker (f ^ n) < LinearMap.ker (f ^ Nat.succ n) h_finrank_lt_finrank : finrank K { x // x ∈ LinearMap.ker (f ^ n) } < finrank K { x // x ∈ LinearMap.ker (f ^ Nat.succ n) } ⊢ Nat.succ n ≤ finrank K { x // x ∈ LinearMap.ker (f ^ Nat.succ n) } [PROOFSTEP] calc n.succ ≤ (finrank K ↑(LinearMap.ker (f ^ n))).succ := Nat.succ_le_succ (ih (Nat.le_of_succ_le hn)) _ ≤ finrank K ↑(LinearMap.ker (f ^ n.succ)) := Nat.succ_le_of_lt h_finrank_lt_finrank [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : End K V h_contra : ∀ (x : ℕ), x ≤ finrank K V → ¬LinearMap.ker (f ^ x) = LinearMap.ker (f ^ Nat.succ x) h_le_ker_pow : ∀ (n : ℕ), n ≤ Nat.succ (finrank K V) → n ≤ finrank K { x // x ∈ LinearMap.ker (f ^ n) } ⊢ False [PROOFSTEP] have h_any_n_lt : ∀ n, n ≤ (finrank K V).succ → n ≤ finrank K V := fun n hn => (h_le_ker_pow n hn).trans (Submodule.finrank_le _) [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : End K V h_contra : ∀ (x : ℕ), x ≤ finrank K V → ¬LinearMap.ker (f ^ x) = LinearMap.ker (f ^ Nat.succ x) h_le_ker_pow : ∀ (n : ℕ), n ≤ Nat.succ (finrank K V) → n ≤ finrank K { x // x ∈ LinearMap.ker (f ^ n) } h_any_n_lt : ∀ (n : ℕ), n ≤ Nat.succ (finrank K V) → n ≤ finrank K V ⊢ False [PROOFSTEP] show False [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : End K V h_contra : ∀ (x : ℕ), x ≤ finrank K V → ¬LinearMap.ker (f ^ x) = LinearMap.ker (f ^ Nat.succ x) h_le_ker_pow : ∀ (n : ℕ), n ≤ Nat.succ (finrank K V) → n ≤ finrank K { x // x ∈ LinearMap.ker (f ^ n) } h_any_n_lt : ∀ (n : ℕ), n ≤ Nat.succ (finrank K V) → n ≤ finrank K V ⊢ False [PROOFSTEP] exact Nat.not_succ_le_self _ (h_any_n_lt (finrank K V).succ (finrank K V).succ.le_refl) [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V f : End K V k : ℕ h : LinearMap.ker (f ^ k) = LinearMap.ker (f ^ Nat.succ k) ⊢ LinearMap.ker (f ^ k) = LinearMap.ker (f ^ (k + 0)) [PROOFSTEP] simp [GOAL] K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V f : End K V k : ℕ h : LinearMap.ker (f ^ k) = LinearMap.ker (f ^ Nat.succ k) m : ℕ ⊢ LinearMap.ker (f ^ k) = LinearMap.ker (f ^ (k + (m + 1))) [PROOFSTEP] apply le_antisymm [GOAL] case a K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V f : End K V k : ℕ h : LinearMap.ker (f ^ k) = LinearMap.ker (f ^ Nat.succ k) m : ℕ ⊢ LinearMap.ker (f ^ k) ≤ LinearMap.ker (f ^ (k + (m + 1))) [PROOFSTEP] rw [add_comm, pow_add] [GOAL] case a K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V f : End K V k : ℕ h : LinearMap.ker (f ^ k) = LinearMap.ker (f ^ Nat.succ k) m : ℕ ⊢ LinearMap.ker (f ^ k) ≤ LinearMap.ker (f ^ (m + 1) * f ^ k) [PROOFSTEP] apply LinearMap.ker_le_ker_comp [GOAL] case a K : Type u V : Type v inst✝² : DivisionRing K inst✝¹ : AddCommGroup V inst✝ : Module K V f : End K V k : ℕ h : LinearMap.ker (f ^ k) = LinearMap.ker (f ^ Nat.succ k) m : ℕ ⊢ LinearMap.ker (f ^ (k + (m + 1))) ≤ LinearMap.ker (f ^ k) [PROOFSTEP] rw [ker_pow_constant h m, add_comm m 1, ← add_assoc, pow_add, pow_add f k m, LinearMap.mul_eq_comp, LinearMap.mul_eq_comp, LinearMap.ker_comp, LinearMap.ker_comp, h, Nat.add_one] [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : End K V m : ℕ hm : finrank K V ≤ m ⊢ LinearMap.ker (f ^ m) = LinearMap.ker (f ^ finrank K V) [PROOFSTEP] obtain ⟨k, h_k_le, hk⟩ : ∃ k, k ≤ finrank K V ∧ LinearMap.ker (f ^ k) = LinearMap.ker (f ^ k.succ) := exists_ker_pow_eq_ker_pow_succ f [GOAL] case intro.intro K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : End K V m : ℕ hm : finrank K V ≤ m k : ℕ h_k_le : k ≤ finrank K V hk : LinearMap.ker (f ^ k) = LinearMap.ker (f ^ Nat.succ k) ⊢ LinearMap.ker (f ^ m) = LinearMap.ker (f ^ finrank K V) [PROOFSTEP] calc LinearMap.ker (f ^ m) = LinearMap.ker (f ^ (k + (m - k))) := by rw [add_tsub_cancel_of_le (h_k_le.trans hm)] _ = LinearMap.ker (f ^ k) := by rw [ker_pow_constant hk _] _ = LinearMap.ker (f ^ (k + (finrank K V - k))) := (ker_pow_constant hk (finrank K V - k)) _ = LinearMap.ker (f ^ finrank K V) := by rw [add_tsub_cancel_of_le h_k_le] [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : End K V m : ℕ hm : finrank K V ≤ m k : ℕ h_k_le : k ≤ finrank K V hk : LinearMap.ker (f ^ k) = LinearMap.ker (f ^ Nat.succ k) ⊢ LinearMap.ker (f ^ m) = LinearMap.ker (f ^ (k + (m - k))) [PROOFSTEP] rw [add_tsub_cancel_of_le (h_k_le.trans hm)] [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : End K V m : ℕ hm : finrank K V ≤ m k : ℕ h_k_le : k ≤ finrank K V hk : LinearMap.ker (f ^ k) = LinearMap.ker (f ^ Nat.succ k) ⊢ LinearMap.ker (f ^ (k + (m - k))) = LinearMap.ker (f ^ k) [PROOFSTEP] rw [ker_pow_constant hk _] [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : End K V m : ℕ hm : finrank K V ≤ m k : ℕ h_k_le : k ≤ finrank K V hk : LinearMap.ker (f ^ k) = LinearMap.ker (f ^ Nat.succ k) ⊢ LinearMap.ker (f ^ (k + (finrank K V - k))) = LinearMap.ker (f ^ finrank K V) [PROOFSTEP] rw [add_tsub_cancel_of_le h_k_le] [GOAL] K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : End K V m : ℕ ⊢ LinearMap.ker (f ^ m) ≤ LinearMap.ker (f ^ finrank K V) [PROOFSTEP] by_cases h_cases : m < finrank K V [GOAL] case pos K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : End K V m : ℕ h_cases : m < finrank K V ⊢ LinearMap.ker (f ^ m) ≤ LinearMap.ker (f ^ finrank K V) [PROOFSTEP] rw [← add_tsub_cancel_of_le (Nat.le_of_lt h_cases), add_comm, pow_add] [GOAL] case pos K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : End K V m : ℕ h_cases : m < finrank K V ⊢ LinearMap.ker (f ^ m) ≤ LinearMap.ker (f ^ (finrank K V - m) * f ^ m) [PROOFSTEP] apply LinearMap.ker_le_ker_comp [GOAL] case neg K : Type u V : Type v inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V f : End K V m : ℕ h_cases : ¬m < finrank K V ⊢ LinearMap.ker (f ^ m) ≤ LinearMap.ker (f ^ finrank K V) [PROOFSTEP] rw [ker_pow_eq_ker_pow_finrank_of_le (le_of_not_lt h_cases)] [GOAL] K✝ : Type u V✝ : Type v K V : Type u inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V ⊢ #V = #K ^ Module.rank K V [PROOFSTEP] let s := Basis.ofVectorSpaceIndex K V [GOAL] K✝ : Type u V✝ : Type v K V : Type u inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V s : Set V := Basis.ofVectorSpaceIndex K V ⊢ #V = #K ^ Module.rank K V [PROOFSTEP] let hs := Basis.ofVectorSpace K V [GOAL] K✝ : Type u V✝ : Type v K V : Type u inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V s : Set V := Basis.ofVectorSpaceIndex K V hs : Basis (↑(Basis.ofVectorSpaceIndex K V)) K V := Basis.ofVectorSpace K V ⊢ #V = #K ^ Module.rank K V [PROOFSTEP] calc #V = #(s →₀ K) := Quotient.sound ⟨hs.repr.toEquiv⟩ _ = #(s → K) := (Quotient.sound ⟨Finsupp.equivFunOnFinite⟩) _ = _ := by rw [← Cardinal.lift_inj.1 hs.mk_eq_rank, Cardinal.power_def] [GOAL] K✝ : Type u V✝ : Type v K V : Type u inst✝³ : DivisionRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : FiniteDimensional K V s : Set V := Basis.ofVectorSpaceIndex K V hs : Basis (↑(Basis.ofVectorSpaceIndex K V)) K V := Basis.ofVectorSpace K V ⊢ #(↑s → K) = #K ^ Module.rank K V [PROOFSTEP] rw [← Cardinal.lift_inj.1 hs.mk_eq_rank, Cardinal.power_def] [GOAL] K✝ : Type u V✝ : Type v K V : Type u inst✝⁴ : DivisionRing K inst✝³ : AddCommGroup V inst✝² : Module K V inst✝¹ : _root_.Finite K inst✝ : FiniteDimensional K V ⊢ #V < ℵ₀ [PROOFSTEP] letI : IsNoetherian K V := IsNoetherian.iff_fg.2 inferInstance [GOAL] K✝ : Type u V✝ : Type v K V : Type u inst✝⁴ : DivisionRing K inst✝³ : AddCommGroup V inst✝² : Module K V inst✝¹ : _root_.Finite K inst✝ : FiniteDimensional K V this : IsNoetherian K V := Iff.mpr IsNoetherian.iff_fg inferInstance ⊢ #V < ℵ₀ [PROOFSTEP] rw [cardinal_mk_eq_cardinal_mk_field_pow_rank K V] [GOAL] K✝ : Type u V✝ : Type v K V : Type u inst✝⁴ : DivisionRing K inst✝³ : AddCommGroup V inst✝² : Module K V inst✝¹ : _root_.Finite K inst✝ : FiniteDimensional K V this : IsNoetherian K V := Iff.mpr IsNoetherian.iff_fg inferInstance ⊢ #K ^ Module.rank K V < ℵ₀ [PROOFSTEP] exact Cardinal.power_lt_aleph0 (Cardinal.lt_aleph0_of_finite K) (IsNoetherian.rank_lt_aleph0 K V)
lemma contra (P Q : Prop) : (P ∧ ¬ P) → Q := begin intro h, cases h with p notp, rw not_iff_imp_false at notp, exfalso, apply notp, exact p, end
module Test.Toml.DataTest import IdrTest.Test import IdrTest.Expectation import Data.List import Toml.Data export suite : Test suite = describe "Toml Data Tests" []
lemma (in sigma_algebra) sets_Collect_countable_All': assumes "\<And>i. i \<in> I \<Longrightarrow> {x\<in>\<Omega>. P i x} \<in> M" assumes "countable I" shows "{x\<in>\<Omega>. \<forall>i\<in>I. P i x} \<in> M"
import tactic import data.nat.lattice -- for well-ordering for naturals import data.set.basic -- for creating sets -- Define a set for the remainder of a/b : -- remainder_set takes a and b and returns set of all possible nonnegative remainders of a/b def remainder_set : ℤ → ℤ → set ℕ := λ a, λ b, { y | (∃ x : ℤ, ((y : ℤ) = a - b * x))} -- LEMMAS lemma mem_remainder_set_iff {a b : ℤ} {k : ℕ} : (k ∈ remainder_set a b) ↔ ∃ x : ℤ, (k : ℤ) = a - b * x := begin split, { intro h, rw set.mem_def at h, exact h, }, { intro h, rw set.mem_def, exact h, } end lemma pos_z_pos_nat { b : ℤ } (hb : b > 0 ) : (b.to_nat > 0) := begin have hb2 := (le_of_lt hb), rw ← (int.to_nat_of_nonneg hb2) at hb, exact int.coe_nat_pos.mp hb, end lemma nonneg_remainder_exists { a b : ℤ } (hb : b > 0) : a + b * |a| ≥ 0 := begin have ha := le_or_lt 0 a, cases ha, { rw abs_of_nonneg ha, nth_rewrite 0 ← one_mul a, rw ← add_mul, have hb2 : 1 + b ≥ 0 := by linarith, exact mul_nonneg hb2 ha, }, { rw [abs_of_neg ha, (neg_mul_comm b a).symm], nth_rewrite 0 ← one_mul a, rw ← add_mul, have hb2 : 1 + -b ≤ 0 := by linarith, have ha2 : a ≤ 0 := le_of_lt ha, exact mul_nonneg_of_nonpos_of_nonpos hb2 ha2, }, end /- PROOF SKETCH (1) Define remainder set, S -- let S = {a - bx : x ∈ ℤ ∧ a - bx ≥ 0} (2) Show S is nonempty -- use x = -|a|, and a + b |a| ≥ 0 to show S nonempty (3) Apply Well-ordering of naturals to show that S contains a minimum, r (4) Show r satisfies conditions of division algorithm -- show r < b, by contradiction if r - b ≥ 0 -/ lemma division_algorithm (a b : ℤ) (hb : b > 0) : (∃ q r : ℤ, ((a = b * q + r) ∧ (0 ≤ r) ∧ (r < b))) := begin -- (1) Define remainder set, S -- let S = {a - bx : x ∈ ℤ ∧ a - bx ≥ 0} -- ( remainder_set : ℤ → ℤ → set ℕ := λ a, λ b, { y | (∃ x : ℤ, ((y : ℤ) = a - b * x)) } ) set S := remainder_set a b, set r := has_Inf.Inf S, -- (2) Show S is nonempty -- use x = -|a|, and a + b |a| ≥ 0 to show S nonempty have hns : S.nonempty, -- we are asserting this is true, and proving it in the brackets { -- show that a + b * |a| ≥ 0 (using lemma proved above) have h1 : a + b * |a| ≥ 0 := nonneg_remainder_exists hb, -- set k = a + b * |a| ≥ 0 (and we want k ∈ ℕ) obtain ⟨k, hk⟩ := int.eq_coe_of_zero_le (h1), -- obtain = have + cases -- show k ∈ S have hk_mem : k ∈ S, { rw mem_remainder_set_iff, use (-|a|), linarith, }, -- since k ∈ S, S ≠ ∅ exact set.nonempty_of_mem hk_mem, }, -- (3) Apply Well-ordering of naturals to show that S contains a minimum, r have hr : r ∈ S := Inf_mem hns, -- (4) Show r satisfies conditions of division algorithm -- show r < b, by contradiction: if r - b ≥ 0, then r - b ∈ S, so r - b ≤ r since r = Inf S. -- use definition of r ∈ S rw mem_remainder_set_iff at hr, -- get x and hx from existence in hypothesis cases hr with x hx, -- show x and r satisfy existence in target use [x, r], -- we need to prove both sides of conjunction (∧ is right associative) split, { -- r = a - b x, so a = b x + r linarith, }, { split, { -- r ∈ ℕ, so r ≥ 0 exact int.of_nat_nonneg r, }, { -- suppose r ≥ b, prove false by_contra h, push_neg at h, rw ← int.to_nat_of_nonneg (le_of_lt hb) at h, -- prove that r - b ∈ S have h_r_sub_b_mem : (r - b.to_nat) ∈ S, { rw mem_remainder_set_iff, -- r = a - b x → r - b = a - b (x + 1) use (x + 1), -- remove coercions rw [int.coe_nat_sub (int.coe_nat_le.mp h), hx, int.to_nat_of_nonneg (le_of_lt hb)], linarith, }, -- b > 0, so r - b < r have h_r_sub_b_le_r : r - b.to_nat < r := (b.to_nat).sub_lt_of_pos_le r (pos_z_pos_nat hb) (int.coe_nat_le.mp h), -- infimum of S is less than or equal to every member of S have h_mem_ge_inf : r ≤ r - b.to_nat := nat.Inf_le h_r_sub_b_mem, -- r - b < r and r ≤ r - b → false exact nat.lt_le_antisymm h_r_sub_b_le_r h_mem_ge_inf, }, }, end --#print division_algorithm -- theorem above is one big λ function! -- EASY WAY -- use ℤ is an instance of Euclidean Domain theorem division_algorithm' (a b : ℤ) (hb : b > 0) : (∃ q r : ℤ, ((a = b * q + r) ∧ (0 ≤ r) ∧ (r < b))) := begin have h := euclidean_domain.mod_add_div a b, -- q, r not unique for general ED use [(a/b), a % b ], -- integer division and remainder : q = a/b ; r = a % b exact ⟨(euclidean_domain.quotient_mul_add_remainder_eq a b).symm, int.mod_nonneg a (ne_of_gt hb), int.mod_lt_of_pos a hb,⟩, end -- (5) Show uniqueness lemma division_algorithm_uniqueness (a b q1 q2 r1 r2 : ℤ) (hr1 : (0 ≤ r1) ∧ (r1 < b)) (hr2 : (0 ≤ r2) ∧ (r2 < b)) (hb : b > 0) (hd1 : a = b * q1 + r1) (hd2 : a = b * q2 + r2) : (q1 = q2 ∧ r1 = r2) := begin have hq : q1 = q2, { rw hd2 at hd1, have j : b * (q2 - q1) = r1 - r2 := by linarith, have k : -b < -r2 ∧ -r2 ≤ 0, { split, { linarith, }, { linarith, },}, have l : -b < r1 - r2 ∧ r1 - r2 < b, { split, { linarith,}, { linarith,},}, have m : -b < b*(q2 - q1) ∧ b*(q2 - q1) < b, { split, {linarith,}, {linarith,},}, have i : -1 < q2 - q1 ∧ q2 - q1 < 1, {split, { cases m, rw (show -b = b*(-1), by linarith) at m_left, exact (mul_lt_mul_left hb).mp m_left, }, { cases m, nth_rewrite 1 ← (mul_one b) at m_right, exact (mul_lt_mul_left hb).mp m_right, },}, linarith, }, split, { assumption, }, { rw hq at hd1, linarith, }, end
-- Math 52: Quiz 5 -- Open this file in a folder that contains 'utils'. import utils open classical definition divides (a b : ℤ) : Prop := ∃ (k : ℤ), b = a * k local infix ∣ := divides axiom not_3_divides : ∀ (m : ℤ), ¬ (3 ∣ m) ↔ 3 ∣ m - 1 ∨ 3 ∣ m + 1 lemma not_3_divides_of_3_divides_minus_1 : ∀ (m : ℤ), 3 ∣ m - 1 → ¬ (3 ∣ m) := begin intros m H, rw not_3_divides, left, assumption, end lemma not_3_divides_of_3_divides_plus_1 : ∀ (m : ℤ), 3 ∣ m + 1 → ¬ (3 ∣ m) := begin intros m H, rw not_3_divides, right, assumption, end theorem main : ∀ (n : ℤ), 3 ∣ n * n - 1 → ¬ (3 ∣ n) := begin intro n, intro H, rw not_3_divides, --I checked the case where n=1 by using --a trichotomy, but the calc expressions still didn't --like the division in the cases where n≠1. --I haven't been able to figure out --mul_left_cancel_of_nonzero. by_trichotomy(n,1), {intro H1, left, unfold divides, existsi(0:ℤ ), rw H1, refl}, {intro H2, right, unfold divides, cases H with a b, existsi((a/(n-1))), symmetry, calc 3 * (a / (n - 1)) = (3*a/(n-1)): by sorry... = (n*n-1)/(n-1): by rw b... = n+1: by sorry}, {intro H3, right, unfold divides, cases H with c d, existsi((c/(n-1))), symmetry, calc 3 * (c / (n - 1)) = (3*c/(n-1)): by sorry... = (n*n-1)/(n-1): by rw d... = n+1: by sorry}, end --Proof: Let n be an arbitrary integer. Assume --that 3 divides n * n - 1, meaning that there --exists some integer c for which n * n - 1 = 3c. --The goal is to prove that 3 does not divide n. --We consider 2 cases: --First, we consider the case that n=1. --3 does not divide 1. --Second, we consider the case that n≠1. By the --lemma, we know that 3 divides either n-1 or n or --n+1, but only one of these possibilities is true. --If we want to prove that 3 does not divide --n, we must prove that either 3 divides n-1 or --3 divides n+1. Assume that 3 does not divide --n-1. The goal is now to prove that 3 divides n+1, --meaning that there exists some integer k for --which n + 1 = 3k. Consider k = c / (n - 1). --Then, 3k = 3c / (n - 1) = n * n - 1 / (n - 1) -- = n + 1. --Both cases lead us to the conclusion that --3 does not divide n. --So I'm realizing I can't prove that c/(n-1) is --an integer, but Lean seems to be okay with it. --Below is my attempt to prove it using a P3 method --(contrapositive) theorem contrapositive : ∀ (n : ℤ), (3 ∣ n) → ¬ (3 ∣ n * n - 1) := begin intro n, intro H, unfold divides at H ⊢ , cases H with c Ha, intro Hb, cases Hb with k Hc, --Now, by substituting 3c for n, we get 9c^2-1=3k, --and k=3c^2-(1/3). Since 3c^2 is an integer, we --know that 3c^2-(1/3) is not an integer, and we --have proven a contradiction. But this seems to --be showing that the contrapositive is false, --and the contrapositive should be true because --it is logically equivalent to the initial --theorem. This makes me think I'm misusing --or misinterpreting lean. sorry end
myTestRule { #Input parameters are: # Property list # Keyword to find #Output parameter is: # Value #Create key-value string msiString2KeyValPair(*Str,*KVpair); #Output property list writeLine("stdout","Property list is"); msiPrintKeyValPair("stdout",*KVpair); #Extract property value msiPropertiesGet(*KVpair,*Str1,*Val); writeLine("stdout","Properties list keyword *Str1 has value *Val"); } INPUT *Str="key1=value1", *Str1="key1" OUTPUT ruleExecOut
(* *********************************************************************) (* *) (* The CertiKOS Certified Kit Operating System *) (* *) (* The FLINT Group, Yale University *) (* *) (* Copyright The FLINT Group, Yale University. All rights reserved. *) (* This file is distributed under the terms of the Yale University *) (* Non-Commercial License Agreement. *) (* *) (* *********************************************************************) Require Import Decision. (* This file defines a typeclass for observations (the return type of the observation functions discussed in the paper). We require all observations to come with a partial order here, in anticipation of proving monotonicity with respect to a semantics (see Section 2 of the paper for discussion of monotonicity). *) Section OBSERVATION. (* To talk about observations, we need a carrier type for both the observations themselves and the principals that can do the observing. The obs_leq predicate defines the partial order. The obs_measure function maps each observation to a natural number, which is meant to represent the "number of observations" made (e.g., if the observation type is an output buffer, then the measure would be the size of the buffer). We need it for technical reasons that come up in simulations and whole-execution behaviors; we hope that a future version will be able to get rid of this measure. *) Class ObservationOps := { principal : Type; obs : Type; obs_leq : obs -> obs -> Prop; obs_lt o1 o2 := obs_leq o1 o2 /\ o1 <> o2; obs_measure : obs -> nat }. Class Observation `{Obs: ObservationOps} := { (* decidability is useful for technical reasons *) principal_eq_dec : forall p1 p2 : principal, Decision (p1 = p2); obs_eq_dec : forall o1 o2 : obs, Decision (o1 = o2); (* obs_leq must be a partial order *) obs_leq_refl : forall o, obs_leq o o; obs_leq_antisym : forall o1 o2, obs_leq o1 o2 -> obs_leq o2 o1 -> o1 = o2; obs_leq_trans : forall o1 o2 o3, obs_leq o1 o2 -> obs_leq o2 o3 -> obs_leq o1 o3; (* obs_measure must be consistent with obs_leq *) obs_lt_measure : forall o1 o2, obs_lt o1 o2 -> obs_measure o1 < obs_measure o2 }. Context `{Obs : Observation}. Lemma obs_leq_lt : forall o1 o2, obs_leq o1 o2 <-> obs_lt o1 o2 \/ o1 = o2. Proof. unfold obs_lt; intros o1 o2; split; intro H. destruct (obs_eq_dec o1 o2); auto. destruct H as [[? ?]|?]; auto. subst; apply obs_leq_refl. Qed. Lemma obs_measure_eq : forall o1 o2, obs_leq o1 o2 -> obs_measure o1 = obs_measure o2 -> o1 = o2. Proof. intros o1 o2 Hleq Hm. rewrite obs_leq_lt in Hleq; destruct Hleq; auto. apply obs_lt_measure in H; omega. Qed. End OBSERVATION.
||| Module tries to implement all the friendly methods provided by the Haskell datatime library. module Data.DateTime import Data.Time.Clock.Internal.UTCTime import Data.Time.Clock.System import Data.Time.Clock.Internal.SystemTime import Data.Time.Calendar.Gregorian import Internal.CTimespec import Data.Time.Calendar.Days import Data.Time.Clock.Internal.DiffTime import Data.Time.Calendar.Days import Data.Time.LocalTime.Internal.TimeOfDay import Data.Fin ||| A structure that stores MJD as Days and Diff time DateTime: Type DateTime = UTCTime ||| Return the Gregorian date based on the call to machine's getSystemTime public export today : IO Gregorian today = do let (MkUTCTime x y) = systemToUTCTime !getSystemTime pure $ toGregorian x ||| Add days to Gregorian public export addDays: Gregorian -> Nat -> Gregorian addDays gregorian n = let x = fromGregorian gregorian new_gregororian = addDays (cast n) x in toGregorian new_gregororian ||| Build the DateTime object based on machince getSystemTime public export getUTCTime: IO DateTime getUTCTime = pure $ systemToUTCTime !getSystemTime ||| Return the current TimeOfDay based on machine's getSystemTime public export getCurrentUTCTimeOfDay : IO TimeOfDay getCurrentUTCTimeOfDay = do utcTime <- getUTCTime pure $ timeToTimeOfDay (utctDayTime utcTime)
Load test. Print some. Let a:=some. Parameter signed1: object->human->Prop. Theorem EX:(walk) john-> some man (walk). (**GAUTO x x x* (here only AUTO is used which takes no arguments, "x x x" are used because GAUTO takes obligatory 3 arguments, they play no role for proofs involving only use of AUTO*) intro. unfold some. exists john. assumption. Qed. Theorem EX1: some man (walk) -> (walk) john. cbv. intro. elim H. intro. intro. replace john with x. assumption. (**this cannot be proven*) Theorem EX2: all man (walk)->walk john. (**GAUTO x x x*) cbv. intro. apply H. Qed. Theorem EX3: all man (walk)->walk john->some man (walk). (**GAUTO x x x*) cbv. intros. exists john. assumption. Qed. Ltac EXTAC:= cbv; eauto. Ltac EXTAC1 x:= cbv; try exists x;EXTAC. Theorem EX5 : all man (walk)-> some man (walk). (** AUTOa John x x (here John is needed to be used with exists*)EXTAC1 john. Qed. Theorem IRISH: (some irishdelegate)(on_time1 human(finish(the survey)))->(some delegate)(on_time1 human(finish(the survey))). (**AUTOa x x x.*) cbv. intro. elim H. intro. intro. exists x. auto. Qed. Theorem SWE:(a swede)(won3(a nobel_prize))->(a scandinavian)(won3(a nobel_prize)). (**AUTOa x x x.*) cbv. intros. elim H. intros. exists x. assumption. Qed. Check not1. Theorem SWE2:not ((a scandinavian)(won2(the nobel_prize)))->not ((a swede)(won2(the nobel_prize))). (**AUTOa x x x.*) cbv. intro. intro. elim H. elim H0. intros. exists x. assumption. Qed. Theorem SCAN: (no delegate)(on_time1 human(finish(the report)))->not((some scandinaviandelegate)(on_time1 human(finish(the report)))). (**AUTOa x x x.*) cbv. intro. intro. elim H0. intro. apply H. Qed. Theorem IRISH2: (some delegate)(on_time (finish(the survey)))->(some delegate)((finish (the survey))). (**AUTOa ADV x x(ADV is used so destruct ADV can take effect*) cbv. intro. destruct ADV in H. elim H. intro. intro. exists x0. apply f0. assumption. Qed. (** on time delegate finish the survey, the second component of VER delegate finish the survey is a proof that forall x: delegate, on time delegate finish the survey x -> finish the survey x *) Theorem FORT: fortunately (walk john)-> walk john. (**AUTOa ADVS x x (similarly)*) cbv. destruct ADVS. apply w. Qed. Parameter in_europe: forall A:CN, (A->Prop)->(A->Prop). Parameter can: forall A:CN, (A->Prop)->(A->Prop). Parameter travel: object->Prop. Parameter freely: forall A:CN, (A->Prop)->(A->Prop). Parameter within_Europe: forall A:CN, (A->Prop)->(A->Prop). Let each:= all. Let person:= human. Parameter european: CN. Axiom eu: european->human. Coercion eu: european>->human. Parameter right_to_live_in_europe:CN. Check have. Parameter have1: object->human->Prop. Axiom ro2: right_to_live_in_europe->object. Coercion ro2: right_to_live_in_europe>->object. Theorem EUROPEAN: ((each european)(have1 (the right_to_live_in_europe))/\forall x:person, ((have1 (the right_to_live_in_europe)x)->can human(within_Europe human (freely human (travel)))x))->(each european)(can human(within_Europe human(freely human (travel)))). (**AUTOa x x x*) cbv. intuition. Qed. Theorem GENUINE: (a genuine_diamond)(has john)->(a diamond)(has john). (**AUTOa x x x*) cbv. intro. elim H. intros. exists x. assumption. Qed. Theorem MICKEY: (small animal mickey) ->not( large animal mickey). (** The proof here works due to the lexical semantics of Small, defined as both not large and not normalsized *)(**AUTOa x x x.*) cbv. unfold not. intro. apply H. Qed. Theorem MICKEY2: (all mouse (small animal)/\ large mouse mickey)->not( large animal mickey). (**AUTOa H1 x H1.*) cbv. intro. elim H. intro. intro. destruct H0 with mickey. assumption. Qed. Set Implicit Arguments. Parameter Fast : forall A : CN, A -> Prop. Parameter FASTER_THAN : forall A : CN, {p : A -> A -> Prop & forall h1 h2 h3 : A, (p h1 h2 /\ p h2 h3 -> p h1 h3) /\ (forall h4 h5 : A, p h4 h5 -> Fast h4 -> Fast h5)}. Definition faster_than:= fun A:CN=>projT1 (FASTER_THAN A). Parameter pc6082 : object. Parameter itelxz : object. Variables o1 o2 o3 : object. Definition as_fast_as:= fun A:CN=> fun a:A=>fun b:A=> Fast a ->Fast b. Theorem FAST2: faster_than itelxz pc6082 /\ Fast itelxz -> Fast pc6082. cbv. intro. destruct FASTER_THAN in H. case a0 with o1 o2 o3. intros. elim H. intros. apply H1 with itelxz. assumption. assumption. Qed. (**This can be semiautomated with the existing tactics: cbv. intro. destruct FASTER_THAN in H. case a0 with o1 o2 o3. AUTOa x x x.*) Theorem KNOW:know john((won2 (the contract) itel))-> (won2 (the contract) itel) . (**AUTOa FACTIVE A B(this makes use of all the arguments, given that the first argument is always destructed as A B, we use A and B for the next two arguments of AUTOa*)cbv. destruct FACTIVE. intro. apply p with john. assumption. Qed. Theorem CONJ:(signed1(the contract)(and3 smith jones anderson)-> (signed1(the contract)smith)). (**AUTOa AND3 A B.*) cbv. destruct AND3. intro. apply a0. assumption. Theorem CURRENTLY: (has1 (a_factory)itel) t-> currently (((has1 (a_factory)itel)))t. (**AUTOa x x x.*) cbv. intros. destruct H. AUTO. Qed.
namespace hidden constant and: Prop -> Prop -> Prop constant or: Prop -> Prop -> Prop constant not: Prop -> Prop constant implies: Prop -> Prop -> Prop constant Proof: Prop -> Type variables p q r: Prop constant and_comm: ∀ p q: Prop, Proof (implies (and p q) (and q p)) #check and_comm p q constant modus_ponens: ∀ p q: Prop, Proof (implies p q) -> Proof p -> Proof q constant implies_intro: ∀ p q: Prop, (Proof p -> Proof q) -> Proof (implies p q) end hidden namespace hidden constants p q: Prop theorem t1: p -> q -> p := λ (hp: p) (hq: q), hp theorem t1': p -> q -> p := assume hp: p, assume hq: q, hp theorem t1'': p -> q -> p := assume hp: p, assume hq: q, show p, from hp axiom ap : p theorem t2: q -> p := t1 ap theorem t1''': ∀ {p q: Prop}, p -> q -> p := assume p q, assume hp: p, assume hq: q, hp end hidden theorem t1: ∀ (p q: Prop), p -> q -> p := assume p q, assume hp: p, assume hq: q, hp variables p q r s: Prop #check t1 #check t1 p q #check t1 r s #check t1 (r -> s) (s -> r) theorem t2 (h₁: q -> r) (h₂: p -> q): p -> r := assume h₃: p, show r, from h₁ (h₂ h₃) #check t2
[STATEMENT] theorem CK_nf_real_card: shows "card ((\<lambda> f. f RRR) ` {f . CK_nf f}) = 14" [PROOF STATE] proof (prove) goal (1 subgoal): 1. card ((\<lambda>f. f RRR) ` {f. CK_nf f}) = 14 [PROOF STEP] by (simp add: CK_nf_set) ((subst card_insert_disjoint; auto dest!: RRR_test simp: nf_RRR id_def[symmetric])[1])+
From QuickChick Require Import QuickChick. From Coq Require Import List String ExtrOcamlNatInt. Import ListNotations. Local Instance this_section : Mutant.section := "test"%string. Definition prop_example := let x := 10 mutant! 20 in let y := 1 mutant: "foo" 2 mutant! 3 mutant: "bar" 4 in whenFail (show x ++ " + " ++ show y ++ " <> 11")%string (x + y = 11 ?). Definition main := runTests [ qc "example" prop_example ]. Extraction "mutation.ml" main.
mutual record R : Set₁ where field A : Set B : Set B = A field C : Set D : Set D = A → B → C record S : Set₁ where field A : Set B : Set B = A field C : Set D : Set D = A → B → C
[STATEMENT] lemma sdrop_simps[simp]: "shd (sdrop n s) = s !! n" "stl (sdrop n s) = sdrop (Suc n) s" [PROOF STATE] proof (prove) goal (1 subgoal): 1. shd (sdrop n s) = s !! n &&& stl (sdrop n s) = sdrop (Suc n) s [PROOF STEP] by (induct n arbitrary: s) auto
State Before: n m : ℕ hzero : n ≠ 0 h : m ∣ n hdiff : m ≠ n ⊢ divisors m ⊆ properDivisors n State After: n m : ℕ hzero : n ≠ 0 h : m ∣ n hdiff : m ≠ n ⊢ ∀ ⦃x : ℕ⦄, x ∈ divisors m → x ∈ properDivisors n Tactic: apply Finset.subset_iff.2 State Before: n m : ℕ hzero : n ≠ 0 h : m ∣ n hdiff : m ≠ n ⊢ ∀ ⦃x : ℕ⦄, x ∈ divisors m → x ∈ properDivisors n State After: n m : ℕ hzero : n ≠ 0 h : m ∣ n hdiff : m ≠ n x : ℕ hx : x ∈ divisors m ⊢ x ∈ properDivisors n Tactic: intro x hx State Before: n m : ℕ hzero : n ≠ 0 h : m ∣ n hdiff : m ≠ n x : ℕ hx : x ∈ divisors m ⊢ x ∈ properDivisors n State After: no goals Tactic: exact Nat.mem_properDivisors.2 ⟨(Nat.mem_divisors.1 hx).1.trans h, lt_of_le_of_lt (divisor_le hx) (lt_of_le_of_ne (divisor_le (Nat.mem_divisors.2 ⟨h, hzero⟩)) hdiff)⟩
module Data.Vec.Exts where open import Data.Fin open import Data.Maybe open import Data.Nat open import Data.Vec using (Vec; []; _∷_) open import Relation.Nullary open import Relation.Unary open import Data.Vec.Relation.Unary.Any findIndex : {n : ℕ} {A : Set} {P : A -> Set} -> Decidable P -> Vec A n -> Maybe (Fin n) findIndex P? xs with any? P? xs ... | yes ix = just (index ix) ... | no _ = nothing
David Jury 's book , About Face : Reviving the Rules of Typography ( 2004 ) — published in Switzerland — clarifies the contemporary typographic position on sentence spacing :
On 13 December 2000 , BBC Radio 3 broadcast a new adaptation directed by Howard Davies starring Geraldine McEwan as Lady Bracknell , Simon Russell Beale as Jack Worthing , Julian Wadham as Algernon Moncrieff , Geoffrey Palmer as Canon Chasuble , Celia Imrie as Miss Prism , Victoria Hamilton as Gwendolen and Emma Fielding as Cecily , with music composed by Dominic <unk> . The production was released on audio cassette .
import centralizer_world.centralizer_is_subgroup -- hide variables {G : Type} [group G] -- hide /- ## The Final Boss In this very final level we will prove that $C_G(A)$ is a normal subgroup of $N_G(A)$. This takes a bit of effort, but hopefully the tools that you have learned all along the way will serve you well in this final battle. Good luck! -/ /- Lemma: no-side-bar The centralizer $C_G(A)$ is a normal subgroup of the normalizer $N_G(A)$. -/ lemma sc2 (A : set G) : is_normal (centralizer A) (normalizer A) := begin rw is_normal, split, { intro x, intro hx, rw normalizer_mem, rw centralizer_mem at hx, intro a, split, { intro ha, specialize hx a ha, rw hx, assumption, }, { intro ha, specialize hx _ ha, rw mul_left_inj (x⁻¹) at hx, rw mul_right_inj x at hx, rw ←hx, assumption, } }, { intros g x hg hx, rw normalizer_mem at hg, rw centralizer_mem at hx ⊢, intros a ha, replace hg := (hg a).1 ha, specialize hx _ hg, rw show g⁻¹ * x * g * a * (g⁻¹ * x * g)⁻¹ = g⁻¹ * (x * (g * a * g⁻¹) * x⁻¹) * g, by group, rw hx, group, } end
lemma poly_1 [simp]: "poly 1 x = 1"
[STATEMENT] lemma map_update_eta_repair[simp]: (* An update operation may get simplified, if it happens to be eta-expanded. This lemma tries to repair some common expressions *) "dom (\<lambda>x. if x=k then Some v else m x) = insert k (dom m)" "m k = None \<Longrightarrow> ran (\<lambda>x. if x=k then Some v else m x) = insert v (ran m)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. dom (\<lambda>x. if x = k then Some v else m x) = insert k (dom m) &&& (m k = None \<Longrightarrow> ran (\<lambda>x. if x = k then Some v else m x) = insert v (ran m)) [PROOF STEP] apply auto [] [PROOF STATE] proof (prove) goal (1 subgoal): 1. m k = None \<Longrightarrow> ran (\<lambda>x. if x = k then Some v else m x) = insert v (ran m) [PROOF STEP] apply (force simp: ran_def) [PROOF STATE] proof (prove) goal: No subgoals! [PROOF STEP] done
= = Criticism = =
= = Criticism = =
-- WARNING: This file was generated automatically by Vehicle -- and should not be modified manually! -- Metadata -- - Agda version: 2.6.2 -- - AISEC version: 0.1.0.1 -- - Time generated: ??? {-# OPTIONS --allow-exec #-} open import Vehicle open import Data.Integer as ℤ using (ℤ) open import Data.Rational as ℚ using (ℚ) module simple-arithmetic-temp-output where precedence : ℚ → (ℚ → (ℚ → ℚ)) precedence x y z = (x ℚ.+ (ℤ.+ 2 ℚ./ 1) ℚ.* y) ℚ.- z ℚ.÷ y
{-# OPTIONS --without-K --safe --no-sized-types --no-guardedness --no-subtyping #-} module Agda.Builtin.String.Properties where open import Agda.Builtin.String open import Agda.Builtin.Equality primitive primStringToListInjective : ∀ a b → primStringToList a ≡ primStringToList b → a ≡ b
[GOAL] α : Type u β : Type v G : Type w H : Type x inst✝³ : TopologicalSpace G inst✝² : Group G inst✝¹ : TopologicalGroup G inst✝ : T2Space G K : PositiveCompacts G ⊢ LocallyCompactSpace G [PROOFSTEP] refine' locally_compact_of_compact_nhds fun x => _ [GOAL] α : Type u β : Type v G : Type w H : Type x inst✝³ : TopologicalSpace G inst✝² : Group G inst✝¹ : TopologicalGroup G inst✝ : T2Space G K : PositiveCompacts G x : G ⊢ ∃ s, s ∈ 𝓝 x ∧ IsCompact s [PROOFSTEP] obtain ⟨y, hy⟩ := K.interior_nonempty [GOAL] case intro α : Type u β : Type v G : Type w H : Type x inst✝³ : TopologicalSpace G inst✝² : Group G inst✝¹ : TopologicalGroup G inst✝ : T2Space G K : PositiveCompacts G x y : G hy : y ∈ interior ↑K ⊢ ∃ s, s ∈ 𝓝 x ∧ IsCompact s [PROOFSTEP] let F := Homeomorph.mulLeft (x * y⁻¹) [GOAL] case intro α : Type u β : Type v G : Type w H : Type x inst✝³ : TopologicalSpace G inst✝² : Group G inst✝¹ : TopologicalGroup G inst✝ : T2Space G K : PositiveCompacts G x y : G hy : y ∈ interior ↑K F : G ≃ₜ G := Homeomorph.mulLeft (x * y⁻¹) ⊢ ∃ s, s ∈ 𝓝 x ∧ IsCompact s [PROOFSTEP] refine' ⟨F '' K, _, K.isCompact.image F.continuous⟩ [GOAL] case intro α : Type u β : Type v G : Type w H : Type x inst✝³ : TopologicalSpace G inst✝² : Group G inst✝¹ : TopologicalGroup G inst✝ : T2Space G K : PositiveCompacts G x y : G hy : y ∈ interior ↑K F : G ≃ₜ G := Homeomorph.mulLeft (x * y⁻¹) ⊢ ↑F '' ↑K ∈ 𝓝 x [PROOFSTEP] suffices F.symm ⁻¹' K ∈ 𝓝 x by convert this using 1 apply Equiv.image_eq_preimage [GOAL] α : Type u β : Type v G : Type w H : Type x inst✝³ : TopologicalSpace G inst✝² : Group G inst✝¹ : TopologicalGroup G inst✝ : T2Space G K : PositiveCompacts G x y : G hy : y ∈ interior ↑K F : G ≃ₜ G := Homeomorph.mulLeft (x * y⁻¹) this : ↑(Homeomorph.symm F) ⁻¹' ↑K ∈ 𝓝 x ⊢ ↑F '' ↑K ∈ 𝓝 x [PROOFSTEP] convert this using 1 [GOAL] case h.e'_4 α : Type u β : Type v G : Type w H : Type x inst✝³ : TopologicalSpace G inst✝² : Group G inst✝¹ : TopologicalGroup G inst✝ : T2Space G K : PositiveCompacts G x y : G hy : y ∈ interior ↑K F : G ≃ₜ G := Homeomorph.mulLeft (x * y⁻¹) this : ↑(Homeomorph.symm F) ⁻¹' ↑K ∈ 𝓝 x ⊢ ↑F '' ↑K = ↑(Homeomorph.symm F) ⁻¹' ↑K [PROOFSTEP] apply Equiv.image_eq_preimage [GOAL] case intro α : Type u β : Type v G : Type w H : Type x inst✝³ : TopologicalSpace G inst✝² : Group G inst✝¹ : TopologicalGroup G inst✝ : T2Space G K : PositiveCompacts G x y : G hy : y ∈ interior ↑K F : G ≃ₜ G := Homeomorph.mulLeft (x * y⁻¹) ⊢ ↑(Homeomorph.symm F) ⁻¹' ↑K ∈ 𝓝 x [PROOFSTEP] apply ContinuousAt.preimage_mem_nhds F.symm.continuous.continuousAt [GOAL] case intro α : Type u β : Type v G : Type w H : Type x inst✝³ : TopologicalSpace G inst✝² : Group G inst✝¹ : TopologicalGroup G inst✝ : T2Space G K : PositiveCompacts G x y : G hy : y ∈ interior ↑K F : G ≃ₜ G := Homeomorph.mulLeft (x * y⁻¹) ⊢ ↑K ∈ 𝓝 (↑(Homeomorph.symm F) x) [PROOFSTEP] have : F.symm x = y := by simp only [Homeomorph.mulLeft_symm, mul_inv_rev, inv_inv, Homeomorph.coe_mulLeft, inv_mul_cancel_right] [GOAL] α : Type u β : Type v G : Type w H : Type x inst✝³ : TopologicalSpace G inst✝² : Group G inst✝¹ : TopologicalGroup G inst✝ : T2Space G K : PositiveCompacts G x y : G hy : y ∈ interior ↑K F : G ≃ₜ G := Homeomorph.mulLeft (x * y⁻¹) ⊢ ↑(Homeomorph.symm F) x = y [PROOFSTEP] simp only [Homeomorph.mulLeft_symm, mul_inv_rev, inv_inv, Homeomorph.coe_mulLeft, inv_mul_cancel_right] [GOAL] case intro α : Type u β : Type v G : Type w H : Type x inst✝³ : TopologicalSpace G inst✝² : Group G inst✝¹ : TopologicalGroup G inst✝ : T2Space G K : PositiveCompacts G x y : G hy : y ∈ interior ↑K F : G ≃ₜ G := Homeomorph.mulLeft (x * y⁻¹) this : ↑(Homeomorph.symm F) x = y ⊢ ↑K ∈ 𝓝 (↑(Homeomorph.symm F) x) [PROOFSTEP] rw [this] [GOAL] case intro α : Type u β : Type v G : Type w H : Type x inst✝³ : TopologicalSpace G inst✝² : Group G inst✝¹ : TopologicalGroup G inst✝ : T2Space G K : PositiveCompacts G x y : G hy : y ∈ interior ↑K F : G ≃ₜ G := Homeomorph.mulLeft (x * y⁻¹) this : ↑(Homeomorph.symm F) x = y ⊢ ↑K ∈ 𝓝 y [PROOFSTEP] exact mem_interior_iff_mem_nhds.1 hy [GOAL] α : Type u β : Type v G : Type w H : Type x inst✝³ : Group G inst✝² : TopologicalSpace G inst✝¹ : TopologicalGroup G Γ : Subgroup G inst✝ : LocallyCompactSpace G ⊢ Continuous fun p => p.fst • p.snd [PROOFSTEP] let F : G × G ⧸ Γ → G ⧸ Γ := fun p => p.1 • p.2 [GOAL] α : Type u β : Type v G : Type w H : Type x inst✝³ : Group G inst✝² : TopologicalSpace G inst✝¹ : TopologicalGroup G Γ : Subgroup G inst✝ : LocallyCompactSpace G F : G × G ⧸ Γ → G ⧸ Γ := fun p => p.fst • p.snd ⊢ Continuous fun p => p.fst • p.snd [PROOFSTEP] change Continuous F [GOAL] α : Type u β : Type v G : Type w H : Type x inst✝³ : Group G inst✝² : TopologicalSpace G inst✝¹ : TopologicalGroup G Γ : Subgroup G inst✝ : LocallyCompactSpace G F : G × G ⧸ Γ → G ⧸ Γ := fun p => p.fst • p.snd ⊢ Continuous F [PROOFSTEP] have H : Continuous (F ∘ fun p : G × G => (p.1, QuotientGroup.mk p.2)) := by change Continuous fun p : G × G => QuotientGroup.mk (p.1 * p.2) refine' continuous_coinduced_rng.comp continuous_mul [GOAL] α : Type u β : Type v G : Type w H : Type x inst✝³ : Group G inst✝² : TopologicalSpace G inst✝¹ : TopologicalGroup G Γ : Subgroup G inst✝ : LocallyCompactSpace G F : G × G ⧸ Γ → G ⧸ Γ := fun p => p.fst • p.snd ⊢ Continuous (F ∘ fun p => (p.fst, ↑p.snd)) [PROOFSTEP] change Continuous fun p : G × G => QuotientGroup.mk (p.1 * p.2) [GOAL] α : Type u β : Type v G : Type w H : Type x inst✝³ : Group G inst✝² : TopologicalSpace G inst✝¹ : TopologicalGroup G Γ : Subgroup G inst✝ : LocallyCompactSpace G F : G × G ⧸ Γ → G ⧸ Γ := fun p => p.fst • p.snd ⊢ Continuous fun p => ↑(p.fst * p.snd) [PROOFSTEP] refine' continuous_coinduced_rng.comp continuous_mul [GOAL] α : Type u β : Type v G : Type w H✝ : Type x inst✝³ : Group G inst✝² : TopologicalSpace G inst✝¹ : TopologicalGroup G Γ : Subgroup G inst✝ : LocallyCompactSpace G F : G × G ⧸ Γ → G ⧸ Γ := fun p => p.fst • p.snd H : Continuous (F ∘ fun p => (p.fst, ↑p.snd)) ⊢ Continuous F [PROOFSTEP] exact QuotientMap.continuous_lift_prod_right quotientMap_quotient_mk' H
-- Eta contraction didn't consider hiding when contracting, -- leading to the following module not type checking. module Issue259 where postulate A : Set B : A → Set foo : (∀ x → B x) → A q : ∀ {x} → B x foo′ : (∀ {x} → B x) → A bar : A bar = foo (λ y → q {y}) Baz : B bar → Set → Set Baz b C with C Baz b C | _ = C -- In fact you're not allowed to eta contract hidden lambdas at all. bar′ : A bar′ = foo′ (λ {y} → q {y}) Baz′ : B bar′ → Set → Set Baz′ b C with C Baz′ b C | _ = C
[GOAL] ⊢ Tendsto (fun n => ↑(numDerangements n) / ↑(Nat.factorial n)) atTop (𝓝 (Real.exp (-1))) [PROOFSTEP] let s : ℕ → ℝ := fun n => ∑ k in Finset.range n, (-1 : ℝ) ^ k / k.factorial [GOAL] s : ℕ → ℝ := fun n => ∑ k in Finset.range n, (-1) ^ k / ↑(Nat.factorial k) ⊢ Tendsto (fun n => ↑(numDerangements n) / ↑(Nat.factorial n)) atTop (𝓝 (Real.exp (-1))) [PROOFSTEP] suffices ∀ n : ℕ, (numDerangements n : ℝ) / n.factorial = s (n + 1) by simp_rw [this] -- shift the function by 1, and then use the fact that the partial sums -- converge to the infinite sum rw [tendsto_add_atTop_iff_nat (f := fun n => ∑ k in Finset.range n, (-1 : ℝ) ^ k / k.factorial) 1] apply HasSum.tendsto_sum_nat rw [Real.exp_eq_exp_ℝ] exact expSeries_div_hasSum_exp ℝ (-1 : ℝ) [GOAL] s : ℕ → ℝ := fun n => ∑ k in Finset.range n, (-1) ^ k / ↑(Nat.factorial k) this : ∀ (n : ℕ), ↑(numDerangements n) / ↑(Nat.factorial n) = s (n + 1) ⊢ Tendsto (fun n => ↑(numDerangements n) / ↑(Nat.factorial n)) atTop (𝓝 (Real.exp (-1))) [PROOFSTEP] simp_rw [this] -- shift the function by 1, and then use the fact that the partial sums -- converge to the infinite sum [GOAL] s : ℕ → ℝ := fun n => ∑ k in Finset.range n, (-1) ^ k / ↑(Nat.factorial k) this : ∀ (n : ℕ), ↑(numDerangements n) / ↑(Nat.factorial n) = s (n + 1) ⊢ Tendsto (fun n => ∑ k in Finset.range (n + 1), (-1) ^ k / ↑(Nat.factorial k)) atTop (𝓝 (Real.exp (-1))) [PROOFSTEP] rw [tendsto_add_atTop_iff_nat (f := fun n => ∑ k in Finset.range n, (-1 : ℝ) ^ k / k.factorial) 1] [GOAL] s : ℕ → ℝ := fun n => ∑ k in Finset.range n, (-1) ^ k / ↑(Nat.factorial k) this : ∀ (n : ℕ), ↑(numDerangements n) / ↑(Nat.factorial n) = s (n + 1) ⊢ Tendsto (fun n => ∑ k in Finset.range n, (-1) ^ k / ↑(Nat.factorial k)) atTop (𝓝 (Real.exp (-1))) [PROOFSTEP] apply HasSum.tendsto_sum_nat [GOAL] case h s : ℕ → ℝ := fun n => ∑ k in Finset.range n, (-1) ^ k / ↑(Nat.factorial k) this : ∀ (n : ℕ), ↑(numDerangements n) / ↑(Nat.factorial n) = s (n + 1) ⊢ HasSum (fun i => (-1) ^ i / ↑(Nat.factorial i)) (Real.exp (-1)) [PROOFSTEP] rw [Real.exp_eq_exp_ℝ] [GOAL] case h s : ℕ → ℝ := fun n => ∑ k in Finset.range n, (-1) ^ k / ↑(Nat.factorial k) this : ∀ (n : ℕ), ↑(numDerangements n) / ↑(Nat.factorial n) = s (n + 1) ⊢ HasSum (fun i => (-1) ^ i / ↑(Nat.factorial i)) (exp ℝ (-1)) [PROOFSTEP] exact expSeries_div_hasSum_exp ℝ (-1 : ℝ) [GOAL] s : ℕ → ℝ := fun n => ∑ k in Finset.range n, (-1) ^ k / ↑(Nat.factorial k) ⊢ ∀ (n : ℕ), ↑(numDerangements n) / ↑(Nat.factorial n) = s (n + 1) [PROOFSTEP] intro n [GOAL] s : ℕ → ℝ := fun n => ∑ k in Finset.range n, (-1) ^ k / ↑(Nat.factorial k) n : ℕ ⊢ ↑(numDerangements n) / ↑(Nat.factorial n) = s (n + 1) [PROOFSTEP] rw [← Int.cast_ofNat, numDerangements_sum] [GOAL] s : ℕ → ℝ := fun n => ∑ k in Finset.range n, (-1) ^ k / ↑(Nat.factorial k) n : ℕ ⊢ ↑(∑ k in Finset.range (n + 1), (-1) ^ k * ↑(Nat.ascFactorial k (n - k))) / ↑(Nat.factorial n) = s (n + 1) [PROOFSTEP] push_cast [GOAL] s : ℕ → ℝ := fun n => ∑ k in Finset.range n, (-1) ^ k / ↑(Nat.factorial k) n : ℕ ⊢ (∑ x in Finset.range (n + 1), (-1) ^ x * ↑(Nat.ascFactorial x (n - x))) / ↑(Nat.factorial n) = ∑ k in Finset.range (n + 1), (-1) ^ k / ↑(Nat.factorial k) [PROOFSTEP] rw [Finset.sum_div] -- get down to individual terms [GOAL] s : ℕ → ℝ := fun n => ∑ k in Finset.range n, (-1) ^ k / ↑(Nat.factorial k) n : ℕ ⊢ ∑ x in Finset.range (n + 1), (-1) ^ x * ↑(Nat.ascFactorial x (n - x)) / ↑(Nat.factorial n) = ∑ k in Finset.range (n + 1), (-1) ^ k / ↑(Nat.factorial k) [PROOFSTEP] refine' Finset.sum_congr (refl _) _ [GOAL] s : ℕ → ℝ := fun n => ∑ k in Finset.range n, (-1) ^ k / ↑(Nat.factorial k) n : ℕ ⊢ ∀ (x : ℕ), x ∈ Finset.range (n + 1) → (-1) ^ x * ↑(Nat.ascFactorial x (n - x)) / ↑(Nat.factorial n) = (-1) ^ x / ↑(Nat.factorial x) [PROOFSTEP] intro k hk [GOAL] s : ℕ → ℝ := fun n => ∑ k in Finset.range n, (-1) ^ k / ↑(Nat.factorial k) n k : ℕ hk : k ∈ Finset.range (n + 1) ⊢ (-1) ^ k * ↑(Nat.ascFactorial k (n - k)) / ↑(Nat.factorial n) = (-1) ^ k / ↑(Nat.factorial k) [PROOFSTEP] have h_le : k ≤ n := Finset.mem_range_succ_iff.mp hk [GOAL] s : ℕ → ℝ := fun n => ∑ k in Finset.range n, (-1) ^ k / ↑(Nat.factorial k) n k : ℕ hk : k ∈ Finset.range (n + 1) h_le : k ≤ n ⊢ (-1) ^ k * ↑(Nat.ascFactorial k (n - k)) / ↑(Nat.factorial n) = (-1) ^ k / ↑(Nat.factorial k) [PROOFSTEP] rw [Nat.ascFactorial_eq_div, add_tsub_cancel_of_le h_le] [GOAL] s : ℕ → ℝ := fun n => ∑ k in Finset.range n, (-1) ^ k / ↑(Nat.factorial k) n k : ℕ hk : k ∈ Finset.range (n + 1) h_le : k ≤ n ⊢ (-1) ^ k * ↑(Nat.factorial n / Nat.factorial k) / ↑(Nat.factorial n) = (-1) ^ k / ↑(Nat.factorial k) [PROOFSTEP] push_cast [Nat.factorial_dvd_factorial h_le] [GOAL] s : ℕ → ℝ := fun n => ∑ k in Finset.range n, (-1) ^ k / ↑(Nat.factorial k) n k : ℕ hk : k ∈ Finset.range (n + 1) h_le : k ≤ n ⊢ (-1) ^ k * (↑(Nat.factorial n) / ↑(Nat.factorial k)) / ↑(Nat.factorial n) = (-1) ^ k / ↑(Nat.factorial k) [PROOFSTEP] field_simp [Nat.factorial_ne_zero] [GOAL] s : ℕ → ℝ := fun n => ∑ k in Finset.range n, (-1) ^ k / ↑(Nat.factorial k) n k : ℕ hk : k ∈ Finset.range (n + 1) h_le : k ≤ n ⊢ (-1) ^ k * ↑(Nat.factorial n) * ↑(Nat.factorial k) = (-1) ^ k * (↑(Nat.factorial k) * ↑(Nat.factorial n)) [PROOFSTEP] ring
lemma sgn_le_0_iff [simp]: "sgn x \<le> 0 \<longleftrightarrow> x \<le> 0" for x :: real
lemma connected_iff_connected_component_eq: "connected S \<longleftrightarrow> (\<forall>x \<in> S. \<forall>y \<in> S. connected_component_set S x = connected_component_set S y)"
(* Title: HOL/SPARK/SPARK.thy Author: Stefan Berghofer Copyright: secunet Security Networks AG Declaration of proof functions for SPARK/Ada verification environment. *) theory SPARK imports SPARK_Setup begin text \<open>Bitwise logical operators\<close> spark_proof_functions bit__and (integer, integer) : integer = "op AND" bit__or (integer, integer) : integer = "op OR" bit__xor (integer, integer) : integer = "op XOR" lemmas [simp] = OR_upper [of _ 8, simplified zle_diff1_eq [symmetric], simplified] OR_upper [of _ 8, simplified] OR_upper [of _ 16, simplified zle_diff1_eq [symmetric], simplified] OR_upper [of _ 16, simplified] OR_upper [of _ 32, simplified zle_diff1_eq [symmetric], simplified] OR_upper [of _ 32, simplified] OR_upper [of _ 64, simplified zle_diff1_eq [symmetric], simplified] OR_upper [of _ 64, simplified] lemmas [simp] = XOR_upper [of _ 8, simplified zle_diff1_eq [symmetric], simplified] XOR_upper [of _ 8, simplified] XOR_upper [of _ 16, simplified zle_diff1_eq [symmetric], simplified] XOR_upper [of _ 16, simplified] XOR_upper [of _ 32, simplified zle_diff1_eq [symmetric], simplified] XOR_upper [of _ 32, simplified] XOR_upper [of _ 64, simplified zle_diff1_eq [symmetric], simplified] XOR_upper [of _ 64, simplified] lemma bit_not_spark_eq: "NOT (word_of_int x :: ('a::len0) word) = word_of_int (2 ^ len_of TYPE('a) - 1 - x)" proof - have "word_of_int x + NOT (word_of_int x) = word_of_int x + (word_of_int (2 ^ len_of TYPE('a) - 1 - x)::'a word)" by (simp only: bwsimps bin_add_not Min_def) (simp add: word_of_int_hom_syms word_of_int_2p_len) then show ?thesis by (rule add_left_imp_eq) qed lemmas [simp] = bit_not_spark_eq [where 'a=8, simplified] bit_not_spark_eq [where 'a=16, simplified] bit_not_spark_eq [where 'a=32, simplified] bit_not_spark_eq [where 'a=64, simplified] text \<open>Minimum and maximum\<close> spark_proof_functions integer__min = "min :: int \<Rightarrow> int \<Rightarrow> int" integer__max = "max :: int \<Rightarrow> int \<Rightarrow> int" end
(************************** uc/OS-II ******************************) (*************************** OS_SEM.C *********************************) (****Proofs for API Fucntion: void* OSSemAccept(OS_EVENT* pevent)*****) (************************C Source Code:******************************) (** /* ********************************************************************************************************* * ACCEPT SEMAPHORE * * Description: This function checks the semaphore to see if a resource is available or, if an event * occurred. Unlike OSSemPend(), OSSemAccept() does not suspend the calling task if the * resource is not available or the event did not occur. * * Arguments : pevent is a pointer to the event control block * * Returns : > 0 if the resource is available or the event did not occur the semaphore is * decremented to obtain the resource. * == 0 if the resource is not available or the event did not occur or, * if 'pevent' is a NULL pointer or, * if you didn't pass a pointer to a semaphore ********************************************************************************************************* */ #if OS_SEM_ACCEPT_EN > 0 INT16U OSSemAccept (OS_EVENT *pevent) { INT16U cnt; BOOLEAN legal; 1 if (pevent == (OS_EVENT * )0) { 2 return (0); } 3 OS_ENTER_CRITICAL(); 4 legal = OS_EventSearch(pevent); 5 if (!legal) { 6 OS_EXIT_CRITICAL(); 7 return (0); } 8 if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { 9 OS_EXIT_CRITICAL(); 10 return (0); } 11 cnt = pevent->OSEventCnt; 12 if (cnt > 0) { 13 --pevent->OSEventCnt; } 14 OS_EXIT_CRITICAL(); 15 return (cnt); } ***) (* ** Ac: Print LoadPath. *) Require Import sem_common. Require Import semacc_pure. (* Lemma semacc_ecblist_P_compose_no_change: already exist ! *) (* Hint Resolve gooda_qcc retpost_osev. *) Open Scope code_scope. Lemma OSSemAccProof: forall tid vl p r, Some p = BuildPreA' os_api OSSemAccept (semacc, (Tint16, Tptr os_ucos_h.OS_EVENT :: nil)) vl OSLInv tid init_lg -> Some r = BuildRetA' os_api OSSemAccept (semacc, (Tint16, Tptr os_ucos_h.OS_EVENT :: nil)) vl OSLInv tid init_lg -> exists t d1 d2 s, os_api OSSemAccept = Some (t, d1, d2, s) /\ {|OS_spec, GetHPrio, OSLInv, I, r, Afalse|} |- tid {{p}}s {{Afalse}}. Proof. init_spec. (* L1 - L2 *) lzh_hoare_if; pure_auto. subst. hoare abscsq. Hint Resolve noabs_oslinv. auto. eapply semacc_absimp_null. auto. can_change_aop_solver. hoare forward. (* L3 *) hoare forward prim; pure_auto. (* L4 *) hoare unfold. hoare forward. instantiate (2:= semacc (Vptr x0 :: nil)). sep cancel Aie. sep cancel Ais. sep cancel Aisr. sep cancel Acs. sep cancel tcbdllflag. sep cancel AECBList. sep cancel AOSRdyTblGrp. sep cancel AOSTCBList. sep cancel AOSTCBPrioTbl. sep cancel 1%nat 1%nat. exact_s. pure_auto. pure_auto. apply retpost_osev. intros. sep pauto. (* ** ac: Check disj_star_elim. *) sep destruct H2. apply adisj_elim in H2. destruct H2. sep auto. sep auto. intros. sep auto. hoare_split_pure_all. unfold OS_EventSearchPost. unfold OS_EventSearchPost'. unfold getasrt. (* getasrt is meaning of notation PRE *) eapply backward_rule1. intros. eapply disj_star_elim; eauto. (* 由于os_eventsearch(pevent)可能找到,也可能找不到,所以,这里就天然的要分成两种情况 *) hoare forward. (************************************ legal == 0 **********************************) Focus 2. (* proof legal == 0 branch first *) hoare_split_pure_all. mytac. inverts H4; inverts H5; inverts H6. lzh_hoare_if. pure_auto. hoare abscsq. auto. eapply semacc_absimp_no_sem. can_change_aop_solver. eapply sem_H_get_none; auto. hoare forward; pauto. hoare forward prim. sep pauto. pure_auto. hoare forward. (**********************************************************************************) (*********************************** legal == 1 **********************************) lzh_simpl_int_eq; tryfalse. hoare_split_pure_all. inverts H10; inverts H15; inverts H16. mytac. lzh_hoare_if. pure_auto. lzh_simpl_int_eq; tryfalse. hoare unfold. lzh_hoare_if. pure_auto. pure_auto. pure_auto. transform_pre semacc_eventtype_neq_sem ltac:(sep cancel AEventData). hoare_split_pure_all. hoare abscsq. auto. eapply semacc_absimp_no_sem; pauto. (********* exit critical ***********) fold_AEventNode_r. compose_evsllseg. fold_AECBList. hoare forward prim. sep pauto. pure_auto. hoare forward. (******************************* type != sem finished **********************) (******************************* type = sem ********************************) hoare unfold. lzh_simpl_int_eq; subst. clear Hif_false. hoare forward. (* pure_auto. *) struct_type_match_solver. lzh_hoare_if. pure_auto. pure_auto. hoare forward. (* pure_auto. *) struct_type_match_solver. pure_auto. (***************************** cnt = 0 ****************************) Focus 2. apply semacc_ltu_zero_false in Hif_false. subst. transform_pre semacc_triangle_sem ltac:(sep cancel AEventData). hoare_split_pure_all. (* ** ac: Check eventsearch_after_get_H. *) assert (Hget:EcbMod.get v'35 (v'26, Int.zero) = Some v'46). eapply eventsearch_after_get_H; eauto. destruct H11 as [? [? ?]]. subst. hoare abscsq. auto. eapply semacc_absimp_no_source; pauto. fold_AEventNode_r. compose_evsllseg. fold_AECBList. hoare forward prim. sep pauto. pure_auto. hoare forward. (*************************************** cnt = 0 finished *****************************) (*************************************** cnt > 0 **************************************) transform_pre semacc_triangle_sem ltac:(sep cancel AEventData). hoare_split_pure_all. mytac_H. assert (Hget: EcbMod.get v'35 (v'26, Int.zero) = Some (abssem i1, x)). eapply EcbMod.join_joinsig_get; eauto. hoare abscsq. auto. eapply semacc_absimp_succ; pauto. transform_pre semacc_new_fundation ltac:(sep cancel AEventData). clear H5 H6. hoare_split_pure_all. fold_AEventNode_r. compose_evsllseg. lets Hnewjoin: ecb_get_set_join_join Hget H7 H10. destruct Hnewjoin as (ml1n & F1 & F2). assert ( ECBList_P v'38 Vnull (v'22 ++ ((V$OS_EVENT_TYPE_SEM :: Vint32 i :: Vint32 (i1-ᵢ$ 1):: x2 :: x3 :: v'42 :: nil, v'40) :: nil) ++ v'23) (v'24 ++ (DSem (i1-ᵢ$ 1) :: nil) ++ v'25) (EcbMod.set v'35 (v'26, Int.zero) (abssem (i1-ᵢ$ 1), x)) v'36). eapply semacc_compose_EcbList_P; eauto. fold_AECBList. hoare forward prim. sep pauto. eapply semacc_RH_TCBList_ECBList_P_hold; eauto. pauto. hoare forward. pure_auto. Qed.
------------------------------------------------------------------------ -- The Agda standard library -- -- An equality postulate which evaluates ------------------------------------------------------------------------ module Relation.Binary.PropositionalEquality.TrustMe where open import Relation.Binary.PropositionalEquality private primitive primTrustMe : ∀ {a} {A : Set a} {x y : A} → x ≡ y -- trustMe {x = x} {y = y} evaluates to refl if x and y are -- definitionally equal. -- -- For an example of the use of trustMe, see Data.String._≟_. trustMe : ∀ {a} {A : Set a} {x y : A} → x ≡ y trustMe = primTrustMe
State Before: r : ℝ hr : 0 < r x : ℝ hx : x ∈ Set.Ioi 0 ⊢ log x / x ^ (-r) = (fun x => log x * x ^ r) x State After: no goals Tactic: rw [rpow_neg hx.out.le, div_inv_eq_mul]
theory Ex042 imports Main begin theorem ProofByContradiction: "(\<not>A \<longrightarrow> False) \<longrightarrow> A" proof - { assume "(\<not>A \<longrightarrow> False)" { assume "\<not>A" with \<open>\<not>A \<longrightarrow> False\<close> have False by (rule mp) hence A by (rule FalseE) } hence "A" by (rule classical) } thus ?thesis by (rule impI) qed
lemma additive_left: "additive (\<lambda>a. prod a b)"
\section*{Run \#13} \begin{figure}[H] \centering \includegraphics[width=0.5\textwidth]{images/13/stream_image} \end{figure} \begin{figure}[H] \centering \includegraphics[width=\textwidth]{images/13/trajectories} \end{figure}
State Before: α : Type u β : Type v G : Type w H : Type x inst✝⁶ : TopologicalSpace G inst✝⁵ : Group G inst✝⁴ : TopologicalGroup G inst✝³ : TopologicalSpace α f : α → G s : Set α x : α inst✝² : TopologicalSpace H inst✝¹ : OrderedCommGroup H inst✝ : ContinuousInv H a : H ⊢ Tendsto Inv.inv (𝓝[Iio a⁻¹] a⁻¹) (𝓝[Ioi a] a) State After: no goals Tactic: simpa only [inv_inv] using @tendsto_inv_nhdsWithin_Iio _ _ _ _ a⁻¹
State Before: V : Type u V' : Type v V'' : Type w G : SimpleGraph V G' : SimpleGraph V' G'' : SimpleGraph V'' u v : V ⊢ (∃ p, length p = 0) ↔ u = v State After: case mp V : Type u V' : Type v V'' : Type w G : SimpleGraph V G' : SimpleGraph V' G'' : SimpleGraph V'' u v : V ⊢ (∃ p, length p = 0) → u = v case mpr V : Type u V' : Type v V'' : Type w G : SimpleGraph V G' : SimpleGraph V' G'' : SimpleGraph V'' u v : V ⊢ u = v → ∃ p, length p = 0 Tactic: constructor State Before: case mp V : Type u V' : Type v V'' : Type w G : SimpleGraph V G' : SimpleGraph V' G'' : SimpleGraph V'' u v : V ⊢ (∃ p, length p = 0) → u = v State After: case mp.intro V : Type u V' : Type v V'' : Type w G : SimpleGraph V G' : SimpleGraph V' G'' : SimpleGraph V'' u v : V p : Walk G u v hp : length p = 0 ⊢ u = v Tactic: rintro ⟨p, hp⟩ State Before: case mp.intro V : Type u V' : Type v V'' : Type w G : SimpleGraph V G' : SimpleGraph V' G'' : SimpleGraph V'' u v : V p : Walk G u v hp : length p = 0 ⊢ u = v State After: no goals Tactic: exact eq_of_length_eq_zero hp State Before: case mpr V : Type u V' : Type v V'' : Type w G : SimpleGraph V G' : SimpleGraph V' G'' : SimpleGraph V'' u v : V ⊢ u = v → ∃ p, length p = 0 State After: case mpr V : Type u V' : Type v V'' : Type w G : SimpleGraph V G' : SimpleGraph V' G'' : SimpleGraph V'' u : V ⊢ ∃ p, length p = 0 Tactic: rintro rfl State Before: case mpr V : Type u V' : Type v V'' : Type w G : SimpleGraph V G' : SimpleGraph V' G'' : SimpleGraph V'' u : V ⊢ ∃ p, length p = 0 State After: no goals Tactic: exact ⟨nil, rfl⟩
function RHF(ints::IntegralHelper{Float64}, Alg::Direct) Fermi.HartreeFock.hf_header() output("Collecting One-electron integrals...") t = @elapsed begin ints["S"] ints["T"] ints["V"] if !haskey(ints.cache, "Jinv") ints["Jinv"] = inv(GaussianBasis.ERI_2e2c(ints.eri_type.basisset)) end end output("Done in {:10.5f} s", t) guess = Options.get("scf_guess") if guess == "core" C, Λ = RHF_core_guess(ints) elseif guess == "gwh" C, Λ = RHF_gwh_guess(ints) end RHF(ints, C, Λ, Alg) end function RHF(ints::IntegralHelper{Float64, <:AbstractERI, AtomicOrbitals}, C::Array{Float64,2}, Λ::Array{Float64,2}, Alg::Direct) output("Using the DIRECT algorithm.") molecule = ints.molecule output(Fermi.string_repr(molecule)) # Grab some options maxit = Options.get("scf_max_iter") Etol = Options.get("scf_e_conv") Dtol = Options.get("scf_max_rms") do_diis = Options.get("diis") oda = Options.get("oda") oda_cutoff = Options.get("oda_cutoff") oda_shutoff = Options.get("oda_shutoff") # Variables that will get updated iteration-to-iteration ite = 1 E = 0.0 ΔE = 1.0 Drms = 1.0 Drms = 1.0 diis = false damp = 0.0 converged = false # Build a diis_manager, if needed if do_diis DM = Fermi.DIIS.DIISManager{Float64,Float64}(size=Options.get("ndiis")) diis_start = Options.get("diis_start") end # Grab ndocc,nvir ndocc = try Int((molecule.Nα + molecule.Nβ)/2) catch InexactError throw(FermiException("Invalid number of electrons $(molecule.Nα + molecule.Nβ) for RHF method.")) end nvir = size(C,2) - ndocc nao = size(C,1) output(" Number of AOs: {:5.0d}", nao) output(" Number of Doubly Occupied Orbitals: {:5.0d}", ndocc) output(" Number of Virtual Spatial Orbitals: {:5.0d}", nvir) S = ints["S"] T = ints["T"] V = ints["V"] if !haskey(ints.cache, "Jinv") ints["Jinv"] = inv(GaussianBasis.ERI_2e2c(ints.eri_type.basisset)) end Jinv = ints["Jinv"] # Form the density matrix from occupied subset of guess coeffs Co = C[:, 1:ndocc] D = Co*Co' D_old = deepcopy(D) eps = nothing # Build the inital Fock Matrix F = T + V coulumb_to_fock!(F, D, Jinv, ints.orbitals.basisset, ints.eri_type.basisset) exchange_to_fock!(F, C, Jinv, ints.molecule.Nα, ints.orbitals.basisset, ints.eri_type.basisset) F̃ = deepcopy(F) D̃ = deepcopy(D) N = length(D) # Number of elements in D (For RMS computation) output(" Guess Energy {:20.14f}", RHFEnergy(D,T+V,F)) output("\n Iter. {:>15} {:>10} {:>10} {:>8} {:>8} {:>8}", "E[RHF]", "ΔE", "Dᵣₘₛ", "t", "DIIS", "damp") output(repeat("-",80)) t = @elapsed while ite ≤ maxit t_iter = @elapsed begin # Produce Ft Ft = Λ'*F*Λ # Get orbital energies and transformed coefficients eps, Ct = LinearAlgebra.eigen(Symmetric(Ft), sortby=x->x) # Reverse transformation to get MO coefficients C = Λ*Ct # Produce new Density Matrix Co = C[:,1:ndocc] D = Co*Co' # Build the Fock Matrix F .= T + V coulumb_to_fock!(F, D, Jinv, ints.orbitals.basisset, ints.eri_type.basisset) exchange_to_fock!(F, C, Jinv, ints.molecule.Nα, ints.orbitals.basisset, ints.eri_type.basisset) Eelec = RHFEnergy(D, T + V, F) # Compute Energy Enew = Eelec + molecule.Vnuc # Store vectors for DIIS if do_diis err = transpose(Λ)*(F*D*S - S*D*F)*Λ push!(DM, F, err) end # Branch for ODA vs DIIS convergence aids diis = false damp = 0.0 # Use ODA damping? if oda && Drms > oda_cutoff && ite < oda_shutoff diis = false dD = D - D̃ s = tr(F̃ * dD) c = tr((F - F̃) * (dD)) if c <= -s/(2*c) λ = 1.0 else λ = -s/(2*c) end F̃ .= (1-λ)*F̃ + λ*F D̃ .= (1-λ)*D̃ + λ*D damp = 1-λ F .= F̃ # Or Use DIIS? elseif do_diis && ite > diis_start diis = true F = Fermi.DIIS.extrapolate(DM) end # Compute the Density RMS ΔD = D - D_old Drms = √(sum(ΔD.^2) / N) # Compute Energy Change ΔE = Enew - E E = Enew D_old .= D end output(" {:<3} {:>15.10f} {:>11.3e} {:>11.3e} {:>8.2f} {:>8} {:5.2f}", ite, E, ΔE, Drms, t_iter, diis, damp) ite += 1 if (abs(ΔE) < Etol) & (Drms < Dtol) & (ite > 5) converged = true break end end output(repeat("-",80)) output(" RHF done in {:>5.2f}s", t) output(" @Final RHF Energy {:>20.12f} Eₕ", E) output("\n • Orbitals Summary",) output("\n {:>10} {:>15} {:>10}", "Orbital", "Energy", "Occupancy") for i in eachindex(eps) output(" {:>10} {:> 15.10f} {:>6}", i, eps[i], (i ≤ ndocc ? "↿⇂" : "")) end output("") if converged output(" ✔ SCF Equations converged 😄") else output("❗ SCF Equations did not converge in {:>5} iterations ❗", maxit) end output(repeat("-",80)) Orbitals = RHFOrbitals(molecule, ints.basis, eps, E, C) return RHF(molecule, E, ndocc, nvir, Orbitals, ΔE, Drms) end
From iris.algebra Require Import auth excl csum gmap. From aneris.algebra Require Import monotone. From iris.proofmode Require Import tactics. From iris.base_logic Require Import invariants. From aneris.aneris_lang Require Import network lang resources events. From aneris.aneris_lang.state_interp Require Import state_interp. From aneris.aneris_lang Require Import network resources proofmode. From aneris.prelude Require Import time. From aneris.aneris_lang.lib Require Import inject list_proof vector_clock_proof network_util_proof. From aneris.examples.gcounter_convergence Require Import crdt_code crdt_model crdt_resources vc. Section specification. Context `{!anerisG (GCounterM gcdata) Σ, !GCounterG Σ gcdata}. (** General specifications for read & write *) Definition query_spec (GCounter : nat → nat → iProp Σ) (query : val) (i: nat) (a : socket_address) : iProp Σ := Eval simpl in □ (∀ n : nat, ⌜gcd_addr_list gcdata !! i = Some a⌝ -∗ {{{ GCounter i n }}} query #() @[ip_of_address a] {{{ m, RET #m; ⌜n <= m⌝ ∗ GCounter i m }}})%I. Definition incr_spec (GCounter : nat → nat → iProp Σ) (incr : val) (i: nat) (a : socket_address) : iProp Σ := Eval simpl in □ (∀ n: nat, ⌜gcd_addr_list gcdata !! i = Some a⌝ -∗ {{{ GCounter i n }}} incr #() @[ip_of_address a] {{{ RET #(); ∃ m, ⌜n < m⌝ ∗ GCounter i m }}})%I. End specification. Section proof. Context `{!anerisG (GCounterM gcdata) Σ, !GCounterG Σ gcdata}. Fixpoint vector_clock_merge (l1 l2 : list nat) : list nat := match l1, l2 with | [], l | l, [] => l | x :: l, y :: k => max x y :: vector_clock_merge l k end. Lemma vector_clock_merge_lookup l1 l2 i : length l1 = length l2 → vector_clock_merge l1 l2 !! i = (l1 !! i) ≫= (λ x, (l2 !! i) ≫= (λ y, Some (x `max` y))). Proof. revert i l2; induction l1 as [|a l1 IHl1]; intros i l2 Hlen. { destruct l2; done. } destruct l2 as [|b l2]; first done. destruct i; first done. apply IHl1; auto. Qed. Lemma vector_clock_merge_length n l1 l2 : length l1 = n → length l2 = n → length (vector_clock_merge l1 l2) = n. Proof. revert l1 l2; induction n as [|n IHn]; intros l1 l2 Hl1 Hl2. { destruct l1; destruct l2; done. } destruct l1 as [|a l1]; first done. destruct l2 as [|b l2]; first done. simpl in *. rewrite IHn; auto. Qed. Lemma vector_clock_merge_le l1 l2 : length l1 = length l2 → vector_clock_le l1 (vector_clock_merge l1 l2). Proof. revert l2; induction l1 as [|a l1 IHl1]; intros l2 Hlen. - destruct l2; last done. constructor. - destruct l2; first done. simpl; constructor; first lia. apply IHl1; auto. Qed. Lemma vector_clock_le_vc_le n (vc1 vc2 : vector_clock n) : vector_clock_le vc1 vc2 → vc_le vc1 vc2. Proof. rewrite /vector_clock_le Forall2_lookup. intros Hle i. specialize (Hle i). assert (vec_to_list vc1 !! (fin_to_nat i) = Some (vc1 !!! i)) as Heq1 by by rewrite -vlookup_lookup. assert (vec_to_list vc2 !! (fin_to_nat i) = Some (vc2 !!! i)) as Heq2 by by rewrite -vlookup_lookup. rewrite Heq1 Heq2 in Hle. inversion Hle; simplify_eq; done. Qed. Lemma vc_mrge_lookup n (vc1 vc2 : vector_clock n) i : vc_merge vc1 vc2 !!! i = vc1 !!! i `max` vc2 !!! i. Proof. apply vlookup_zip_with. Qed. Lemma vector_clock_merge_vc_merge n l1 (vc1 : vector_clock n) l2 (vc2 : vector_clock n) : vec_to_list vc1 = l1 → vec_to_list vc2 = l2 → vector_clock_merge l1 l2 = vec_to_list (vc_merge vc1 vc2). Proof. intros Hl1 Hl2. apply list_eq; intros i. rewrite vector_clock_merge_lookup; last by rewrite -Hl1 -Hl2 !vec_to_list_length. destruct (decide (i < n)) as [Hlt|Hnlt]. - pose (fi := nat_to_fin Hlt). destruct (lookup_lt_is_Some_2 l1 i) as [x Hx]; first by rewrite -Hl1 vec_to_list_length. destruct (lookup_lt_is_Some_2 l2 i) as [y Hy]; first by rewrite -Hl2 vec_to_list_length. rewrite Hx Hy /=. rewrite -(fin_to_nat_to_fin _ _ Hlt) -Hl1 in Hx. rewrite -(fin_to_nat_to_fin _ _ Hlt) -Hl2 in Hy. apply vlookup_lookup in Hx. apply vlookup_lookup in Hy. rewrite -(fin_to_nat_to_fin _ _ Hlt). symmetry; apply vlookup_lookup. rewrite vc_mrge_lookup Hx Hy; done. - rewrite !lookup_ge_None_2; rewrite -?Hl1 -?Hl2 ?vec_to_list_length; auto with lia. Qed. Lemma vector_clock_to_val_inj l1 l2 : vector_clock_to_val l1 = vector_clock_to_val l2 → l1 = l2. Proof. revert l2; induction l1 as [|a l1 IHl1]; intros l2. - destruct l2; inversion 1; done. - destruct l2; first by inversion 1. inversion 1; simplify_eq. erewrite IHl1; done. Qed. Lemma wp_gcounter_merge ip v1 v2 vc1 vc2 : {{{ ⌜length vc1 = length vc2⌝ ∗ ⌜is_vc v1 vc1⌝ ∗ ⌜is_vc v2 vc2⌝ }}} gcounter_merge v1 v2 @[ip] {{{w, RET w; ⌜is_vc w (vector_clock_merge vc1 vc2)⌝}}}. Proof. iIntros (Φ) "(%Hlen & %Hv1 & %Hv2) HΦ". rewrite /gcounter_merge. iInduction vc1 as [|a vc1] "IH" forall (Φ v1 v2 vc2 Hlen Hv1 Hv2). { destruct vc2; last done. rewrite Hv1 Hv2. wp_pures. iApply "HΦ"; done. } destruct vc2 as [|b vc2]; first done. simpl in *. destruct Hv1 as [v1' [-> ?]]. destruct Hv2 as [v2' [-> ?]]. wp_pures. destruct (decide (a ≤ b)). - rewrite bool_decide_eq_true_2; last lia. wp_if; wp_let. wp_apply ("IH" $! _ v1' v2' vc2 with "[] [] []"); [iPureIntro; lia|done|done|]. iIntros (w) "%Hw". wp_pures. replace #b with $ #b; last done. rewrite /is_vc in Hw. wp_apply (wp_list_cons _ (vector_clock_merge vc1 vc2) with "[]"); first done. iIntros (w') "%". iApply "HΦ". rewrite Nat.max_r; done. - rewrite bool_decide_eq_false_2; last lia. wp_if; wp_let. wp_apply ("IH" $! _ v1' v2' vc2 with "[] [] []"); [iPureIntro; lia|done|done|]. iIntros (w) "%Hw". wp_pures. replace #a with $ #a; last done. rewrite /is_vc in Hw. wp_apply (wp_list_cons _ (vector_clock_merge vc1 vc2) with "[]"); first done. iIntros (w') "%". iApply "HΦ". rewrite Nat.max_l; last lia; done. Qed. Lemma wp_perform_merge l (vcx : vector_clock (GClen gcdata)) vc i (j : fin (GClen gcdata)) a : gcd_addr_list gcdata !! i = Some a → vc = vec_to_list vcx → {{{ GCallocated i l ∗ GCounterSnapShot j vcx ∗ Global_Inv }}} perform_merge #l (vector_clock_to_val vc) @[ip_of_address a] {{{ RET #(); GCounterSnapShot i vcx }}}. Proof. iIntros (Hia Hvcvcx Φ) "#(Hial & Hsnap & Hinv) HΦ". assert (length vc = GClen gcdata) as Hvclen. { rewrite Hvcvcx vec_to_list_length //. } rewrite /perform_merge. iLöb as "IH". wp_pures. wp_bind (! _)%E. iInv CvRDT_InvName as (st locs sevss revss) "(Hfst & HGC & >Hlocs & Hsevss & >Hrevss & >Hlocs_coh & Hsevss_coh & Hrevss_coh & Hnet)" "Hcl". iDestruct (locations_is_allocated with "Hlocs Hial") as %Hil. iDestruct (locations_coherence_length with "Hlocs_coh") as %?. assert (i < GClen gcdata) as Hilt. { apply lookup_lt_is_Some_1; eauto. } set (fi := nat_to_fin Hilt). iDestruct (locations_coherence_insert_acc fi with "Hlocs_coh") as "[Hl Hback]"; first by rewrite fin_to_nat_to_fin; apply Hil. iDestruct "Hl" as (vc' Hfivc') "[Hevs Hl]". rewrite fin_to_nat_to_fin Hia in Hfivc'; simplify_eq Hfivc'; intros <-. wp_load. iDestruct ("Hback" $! (Some _) with "[Hevs Hl]") as "Hlocs_coh". { iExists _; iFrame; rewrite fin_to_nat_to_fin; done. } iMod ("Hcl" with "[Hfst HGC Hlocs Hsevss Hrevss Hlocs_coh Hsevss_coh Hrevss_coh Hnet]") as "_". { iNext; iExists _, _, _, _; iFrame. rewrite vlookup_insert_self list_insert_id; last by rewrite fin_to_nat_to_fin. iFrame. } iModIntro. wp_pures. wp_apply wp_gcounter_merge. { iSplit; last by eauto using vector_clock_to_val_is_vc. rewrite vec_to_list_length Hvclen; done. } iIntros (w Hw). wp_bind (CAS _ _ _). iInv CvRDT_InvName as (st' locs' sevss' revss') "(>Hfst & >HGC & >Hlocs & Hsevss & Hrevss & >Hlocs_coh & Hsevss_coh & Hrevss_coh & Hnet)" "Hcl". iDestruct (locations_is_allocated with "Hlocs Hial") as %Hil'. iDestruct (locations_coherence_length with "Hlocs_coh") as %?. iDestruct (locations_coherence_insert_acc fi with "Hlocs_coh") as "[Hl Hback]"; first by rewrite fin_to_nat_to_fin; apply Hil'. iDestruct "Hl" as (vc' Hfivc'') "[Hevs Hl]". rewrite fin_to_nat_to_fin Hia in Hfivc''; simplify_eq Hfivc''; intros <-. destruct (decide (st !!! fi = st' !!! fi)) as [Heq|Hneq]. - iDestruct (GCounterSnapShot_le j with "Hsnap HGC") as %Hmrel. iApply aneris_wp_atomic_take_step_model. iModIntro. iExists _, _; iFrame "Hfst". iSplit. { iPureIntro; right. eapply (ApplyStep _ _ fi j); apply Hmrel. } wp_cas_suc; first by rewrite Heq. iIntros "Hfst". assert (length (vector_clock_merge (vec_to_list (st !!! fi)) vc) = GClen gcdata) as Hnewlen. { apply vector_clock_merge_length; first rewrite vec_to_list_length; done. } iMod (GCounters_update fi (vc_merge (st' !!! fi) vcx) with "HGC") as "[HGC _]"; first by apply vc_merge_le1. iDestruct ("Hback" $! (Some l) (vc_merge (st' !!! fi) vcx) with "[Hevs Hl]") as "Hlocs_coh". { erewrite <- (is_vc_vector_clock_to_val w); last by eauto. erewrite vector_clock_merge_vc_merge; eauto. iExists _; iSplit; first by rewrite fin_to_nat_to_fin. rewrite Heq. iFrame. } iMod (get_GCounterSnapShot_weaken fi _ vcx with "HGC") as "[HGC #Hvcsnap]". { rewrite vlookup_insert. apply vc_merge_le2. } iMod ("Hcl" with "[Hfst HGC Hlocs Hsevss Hrevss Hlocs_coh Hsevss_coh Hrevss_coh Hnet]") as "_". { iNext; iExists _, _, _, _; iFrame. rewrite list_insert_id; last by rewrite fin_to_nat_to_fin. iFrame. } iApply fupd_mask_intro_subseteq; first done. wp_if. rewrite fin_to_nat_to_fin. iApply "HΦ"; done. - wp_cas_fail. { intros Heq'%vector_clock_to_val_inj; apply Hneq. apply vec_to_list_inj2; done. } iDestruct ("Hback" $! (Some _) with "[Hevs Hl]") as "Hlocs_coh". { iExists _; iFrame; rewrite fin_to_nat_to_fin; done. } iMod ("Hcl" with "[Hfst HGC Hlocs Hsevss Hrevss Hlocs_coh Hsevss_coh Hrevss_coh Hnet]") as "_". { iNext; iExists _, _, _, _; iFrame. rewrite vlookup_insert_self list_insert_id; last by rewrite fin_to_nat_to_fin. iFrame. } iModIntro. wp_if. iApply "IH"; done. Qed. Lemma gcounter_apply_proof l sh i a : gcd_addr_list gcdata !! i = Some a → {{{ ([∗ list] a ∈ gcd_addr_list gcdata, a ⤇ GCounter_socket_proto) ∗ GCallocated i l ∗ Global_Inv ∗ recevs_frag i [] ∗ inv (nroot .@ "skt") (sh ↪[ip_of_address a] mkSocket (Some a) true) }}} gcounter_apply #l #(LitSocket sh) @[ip_of_address a] {{{ RET #(); True }}}. Proof. iIntros (Hia Φ) "(#Hprotos & #Hial & #Hinv & Hrevsfrg & #Hsh) _". rewrite /gcounter_apply. do 6 wp_pure _. iAssert ([∗ list] rev ∈ (@nil (vector_clock (GClen gcdata))), GCounterSnapShot i rev)%I as "Hsnaps". { done. } generalize (@nil (vector_clock (GClen gcdata))); intros revs. iLöb as "IH" forall (revs) "Hsnaps". wp_pures. wp_bind (ReceiveFrom _). iInv CvRDT_InvName as (st locs sevss revss) "(Hfst & HGC & Hlocs & Hsevss & >Hrevss & Hlocs_coh & Hsevss_coh & >Hrevss_coh & >Hnet)" "Hcl". iDestruct (big_sepL_lookup_acc with "Hnet") as "[Hnet Hback]"; first by apply Hia. iDestruct "Hnet" as (R T) "[Ha #HR]". iDestruct (big_sepL_lookup with "Hprotos") as "Hproto"; first by apply Hia. iInv (nroot .@ "skt") as "Hsh'" "Hshcl". iDestruct (recevs_agree with "Hrevss Hrevsfrg") as %Hlu. iDestruct (recevs_coherence_insert_acc with "Hrevss_coh") as "[Hrevs Hback']"; first apply Hlu. iDestruct "Hrevs" as (sa' prevs Hsa') "(_ & Halloc & Hprevs & %Hrevs_cor)". rewrite Hia in Hsa'; simplify_eq Hsa'; intros <-. wp_apply (aneris_wp_receivefrom_tracked _ _ _ _ _ _ _ _ _ _ (λ _, True)%I (λ _, True)%I with "[$Hsh' $Hprevs $Ha $Hproto]"); [done|done|done| |]. { iSplitL; last iNext; auto. } iIntros (m) "(% & H & Hprevs)". iDestruct "Hprevs" as (σ stks r ?) "(Hprevs & _ & _)". iAssert (sh ↪[ ip_of_address a] mkSocket (Some a) true ∗ GCounter_socket_proto m ∗ ∃ R T, a ⤳[true, true] (R, T) ∗ ([∗ set] m ∈ R, GCounter_socket_proto m))%I with "[H HR]" as "(Hsh' & #Hm & Hnet)". { iDestruct "H" as "[(% & $ & Ha & _ & #Hm)|(%HmR & $ & Ha)]". - iFrame "#". iExists _, _; iFrame "Ha". rewrite big_sepS_insert //; iFrame "#". - iDestruct (big_sepS_elem_of with "HR") as "Hm"; first by apply HmR. iFrame "#". iExists _, _; iFrame "Ha"; done. } iDestruct ("Hback" with "Hnet") as "Hnet". iMod ("Hshcl" with "Hsh'") as "_". iDestruct "Hm" as (vc k j Hvc Hkm Hjm Hkj Hvclen) "Hmsnap". iDestruct ("Hback'" $! (revs ++ [vc]) with "[Hprevs]") as "Hrevss_coh". { iExists _, _; iSplit; first done. iFrame. iSplit. - iIntros (rev n Hn Hnlu). assert (n < length revs + 1). { apply lookup_lt_Some in Hnlu. rewrite app_length in Hnlu; done. } rewrite app_length /= in Hn. assert (n < length revs) by lia. rewrite lookup_app_l in Hnlu; last done. iDestruct (big_sepL_lookup _ _ n with "Hsnaps") as "?"; done. - iSplit; first by eauto. iPureIntro. apply Forall2_app; first done. apply List.Forall2_cons; last done. eexists _, _, _, _, _, _; eauto. } iMod (recevs_update _ _ _ (revs ++ [vc]) with "Hrevss Hrevsfrg") as "[Hrevss Hrevsfrg]". iMod ("Hcl" with "[Hfst HGC Hlocs Hsevss Hrevss Hlocs_coh Hsevss_coh Hrevss_coh Hnet]") as "_". { iNext; iExists _, _, _, _; iFrame. } iApply fupd_mask_intro_subseteq; first done. wp_apply wp_unSOME; first done. iIntros "_". wp_pures. wp_apply wp_vect_deserialize; first done. iIntros "_". wp_pures. assert (k < GClen gcdata) as Hklt. { apply lookup_lt_is_Some_1; eauto. } set (fk := nat_to_fin Hklt). wp_apply (wp_perform_merge _ vc vc i fk); [done|done|by rewrite fin_to_nat_to_fin; iFrame "#"|]. iIntros "#Hvcsnap". do 2 wp_pure _. wp_apply ("IH" with "Hrevsfrg"). iModIntro. rewrite big_sepL_snoc; iFrame "#". Qed. Lemma wp_sendToAll (i : fin (GClen gcdata)) (vc : vector_clock (GClen gcdata)) l sevs a sh v s : gcd_addr_list gcdata !! (fin_to_nat i) = Some a → is_list (gcd_addr_list gcdata) v → vc_is_ser (vector_clock_to_val vc) s → (∀ sev, sev ∈ sevs → vc_le sev.2.1 vc) → {{{ GCounterSnapShot i vc ∗ inv (nroot.@"skt") (sh ↪[ ip_of_address a] mkSocket (Some a) true) ∗ Global_Inv ∗ sendevs_frag i sevs ∗ GCallocated i l ∗ [∗ list] a0 ∈ gcd_addr_list gcdata, a0 ⤇ GCounter_socket_proto }}} sendToAll #(LitSocket sh) #s v #i @[ip_of_address a] {{{ sevs', RET #(); sendevs_frag i sevs' }}}. Proof. iIntros (Hia Hv Hvcs Hvc_valid Φ) "(#Hsnap & #Hsh & #Hinv & Hsevsfrg & #Hial & #Hprotos) HΦ". assert (length vc = GClen gcdata) as Hvclen. { rewrite vec_to_list_length //. } assert (i < GClen gcdata) as Hilt. { apply lookup_lt_is_Some_1; eauto. } set (fi := nat_to_fin Hilt). rewrite /sendToAll. do 10 wp_pure _. change 0%Z with (0%nat : Z). rewrite -(app_nil_r sevs). assert (∀ sev, sev ∈ @nil (nat * (vector_clock (GClen gcdata) * vector_clock (GClen gcdata))) → sev.1 < 0) as Htl. { inversion 1. } revert Htl. generalize (@nil (nat * (vector_clock (GClen gcdata) * vector_clock (GClen gcdata)))). generalize 0%nat as z. intros z tl Htl. iLöb as "IH" forall (z tl Htl). wp_pures. wp_apply wp_list_length; first done. iIntros (? ->). wp_pures. destruct (decide (z < GClen gcdata)%Z); last first. { rewrite bool_decide_eq_false_2; last done. wp_if. iApply "HΦ"; done. } rewrite bool_decide_eq_true_2; last done. wp_pures. destruct (decide (fin_to_nat i = z :> Z)) as [->|]. { rewrite bool_decide_eq_true_2; last done. wp_if. wp_op. replace (z + 1)%Z with ((z + 1)%nat : Z) by lia. iApply ("IH" with "[] Hsevsfrg"); last done. iPureIntro; intros ? ?; etrans; first by apply Htl. lia. } rewrite bool_decide_eq_false_2; last done. wp_pures. wp_apply wp_list_nth; first done. iIntros (w Hw). destruct Hw as [[? ?]|(r & -> & Hr)]; first lia. apply misc.nth_error_lookup in Hr. wp_apply wp_unSOME; first done. iIntros "_". wp_pures. wp_bind (SendTo _ _ _). iInv CvRDT_InvName as (st locs sevss revss) "(Hfst & HGC & >Hlocs & >Hsevss & Hrevss & >Hlocs_coh & >Hsevss_coh & Hrevss_coh & Hnet)" "Hcl". iDestruct (locations_is_allocated with "Hlocs Hial") as %Hil. iDestruct (big_sepL_lookup_acc with "Hnet") as "[Hnet Hback]"; first by apply Hia. iDestruct "Hnet" as (R T) "[Ha #HR]". iDestruct (big_sepL_lookup with "Hprotos") as "Hproto"; first by apply Hr. iInv (nroot .@ "skt") as "Hsh'" "Hshcl". iDestruct (sendevs_agree with "Hsevss Hsevsfrg") as %Hsevs. iDestruct (sendevs_coherence_insert_acc i _ _ with "Hsevss_coh") as "[Hsevsi Hback']"; [apply Hil|apply Hsevs|]. iDestruct "Hsevsi" as (sa Hsa Hvl) "[Hsnaps Hrest]". rewrite Hia in Hsa; simplify_eq. iDestruct "Hrest" as (psevs) "[Hpsevs %Hpsevs]". iDestruct (locations_coherence_insert_acc fi with "Hlocs_coh") as "[Hl Hback'']"; first by rewrite fin_to_nat_to_fin; apply Hil. iDestruct "Hl" as (vc' Hfivc'') "[Hevs Hl]". rewrite fin_to_nat_to_fin Hia in Hfivc''; simplify_eq Hfivc''; intros <-. wp_apply (aneris_wp_send_tracked _ _ _ _ _ _ _ _ _ _ _ psevs (λ σ, l ↦[ip_of_address sa] vector_clock_to_val (vec_to_list (st !!! fi)) ∗ ∃ h : heap, ⌜σ.(state_heaps) !! (ip_of_address sa) = Some h ∧ h !! l = Some (vector_clock_to_val (vec_to_list (st !!! fi)))⌝)%I (λ σ, True)%I with "[$Hsh' $Ha $Hproto $Hpsevs Hl]"); [done|done| |]. { iSplitR. { iNext. iExists _, _, _; repeat iSplit; eauto. } iSplitL; last by eauto. iIntros (σ δ) "Hsi". iDestruct (aneris_state_interp_heap_valid with "Hsi Hl") as (h) "[% %]". iModIntro; iFrame; eauto. } iIntros "(Hsh' & Ha & Hev)". iDestruct "Hev" as (σ skts r' Hr') "(Hpsevs & [Hl Hh] & _)". iDestruct "Hh" as (h) "[% %]". iDestruct ("Hback''" $! (Some l) with "[Hl Hevs]") as "Hlocs_coh". { iExists _; iSplit; first by rewrite fin_to_nat_to_fin. iFrame. } iMod (get_GCounterSnapShot fi with "HGC") as "[HGC #Hsnap']". iMod (sendevs_update _ _ _ (sevs ++ tl ++ [(z, ((st !!! fi), vc))]) with "Hsevss Hsevsfrg") as "[Hsevss Hsevsfrg]". iDestruct ("Hback'" $! (Some l) (sevs ++ tl ++ [(z, (st !!! fi, vc))]) with "[Hsnaps Hpsevs]") as "Hsevss_coh". { iExists _; iSplit; first done. iSplit. { iPureIntro. apply sendevs_valid_extend; [done| |done]. intros sev Hsev; simpl. apply Htl in Hsev; lia. } iSplit. { rewrite assoc_L big_sepL_snoc fin_to_nat_to_fin; auto. } iExists _; iFrame. iPureIntro. rewrite assoc_L. apply Forall2_app; first done. apply List.Forall2_cons; last done. eexists _, _, _, _, _, _, _, _; eauto 10. } iDestruct ("Hback" with "[Ha]") as "Hnet". { iExists _, _ ; iFrame; done. } iMod ("Hshcl" with "Hsh'") as "_". iMod ("Hcl" with "[Hfst HGC Hlocs Hsevss Hrevss Hlocs_coh Hsevss_coh Hrevss_coh Hnet]") as "_". { iNext; iExists _, _, _, _; iFrame. rewrite fin_to_nat_to_fin. rewrite !(list_insert_id locs) //. rewrite vlookup_insert_self. iFrame. } iApply fupd_mask_intro_subseteq; first done. do 2 wp_pure _. wp_op. replace (z + 1)%Z with ((z + 1)%nat : Z) by lia. iApply ("IH" with "[] Hsevsfrg"); [|done]. iPureIntro. intros sev [| ->%elem_of_list_singleton]%elem_of_app; last by simpl; lia. etrans; first apply Htl; auto with lia. Qed. Lemma gcounter_broadcast_proof l sh i v a : gcd_addr_list gcdata !! i = Some a → is_list (gcd_addr_list gcdata) v → {{{ ([∗ list] a ∈ gcd_addr_list gcdata, a ⤇ GCounter_socket_proto) ∗ GCallocated i l ∗ Global_Inv ∗ sendevs_frag i [] ∗ inv (nroot .@ "skt") (sh ↪[ip_of_address a] mkSocket (Some a) true) }}} gcounter_broadcast #l #(LitSocket sh) v #i @[ip_of_address a] {{{ RET #(); True }}}. Proof. iIntros (Hia Hv Φ) "(#Hprotos & #Hial & #Hinv & Hsevsfrg & #Hsh) _". assert (i < GClen gcdata) as Hilt. { apply lookup_lt_is_Some_1; eauto. } set (fi := nat_to_fin Hilt). rewrite /gcounter_broadcast. do 10 wp_pure _. generalize (@nil (nat * (vector_clock (GClen gcdata) * vector_clock (GClen gcdata)))); intros sevs. iLöb as "IH" forall (sevs). wp_pures. rewrite /sleep. wp_pures. wp_bind (! _)%E. iInv CvRDT_InvName as (st locs sevss revss) "(Hfst & HGC & >Hlocs & Hsevss & Hrevss & >Hlocs_coh & >Hsevss_coh & Hrevss_coh & Hnet)" "Hcl". iDestruct (locations_is_allocated with "Hlocs Hial") as %Hil'. iDestruct (locations_coherence_length with "Hlocs_coh") as %?. iDestruct (locations_coherence_insert_acc fi with "Hlocs_coh") as "[Hl Hback]"; first by rewrite fin_to_nat_to_fin; apply Hil'. iDestruct "Hl" as (vc' Hfivc'') "[Hevs Hl]". rewrite fin_to_nat_to_fin Hia in Hfivc''; simplify_eq Hfivc''; intros <-. wp_load; simpl. iMod (get_GCounterSnapShot fi with "HGC") as "[HGC #Hsnap]". iDestruct ("Hback" $! (Some _) with "[Hevs Hl]") as "Hlocs_coh". { iExists _; iFrame; rewrite fin_to_nat_to_fin; done. } iAssert (⌜∀ sev, sev ∈ sevs → vc_le sev.2.1 (st !!! fi)⌝)%I as %?. { iDestruct (sendevs_agree with "Hsevss Hsevsfrg") as %Hsevs. iDestruct (sendevs_coherence_insert_acc i _ _ with "Hsevss_coh") as "[Hsevsi Hback']"; [apply Hil'|apply Hsevs|]. iDestruct "Hsevsi" as (sa Hsa Hvl) "[Hsnaps Hrest]". iIntros (sev [j Hsev]%elem_of_list_lookup). iApply (GCounterSnapShot_le with "[Hsnaps] HGC"). iDestruct (big_sepL_lookup _ _ j with "Hsnaps") as "?"; first by eauto. rewrite fin_to_nat_to_fin; done. } iMod ("Hcl" with "[Hfst HGC Hlocs Hsevss Hrevss Hlocs_coh Hsevss_coh Hrevss_coh Hnet]") as "_". { iNext; iExists _, _, _, _; iFrame. rewrite vlookup_insert_self list_insert_id; last by rewrite fin_to_nat_to_fin. iFrame. } iModIntro. wp_pures. wp_apply wp_vect_serialize. { iPureIntro. eexists; apply vector_clock_to_val_is_vc. } iIntros (s Hs). wp_pures. rewrite -(fin_to_nat_to_fin _ _ Hilt). wp_apply (wp_sendToAll with "[$Hsevsfrg]"); [by rewrite fin_to_nat_to_fin|done|apply Hs|done|by iFrame "#"|]. iIntros (sevs') "Hsevs'frg". do 2 wp_pure _. iApply "IH"; done. Qed. Lemma wp_gcounter_sum ip v l : is_vc v l → {{{ True }}} gcounter_sum v @[ip] {{{ (m : nat), RET #m; ⌜m = list_sum l⌝ }}}. Proof. iIntros (Hvl Φ) "_ HΦ". rewrite /gcounter_sum. iInduction l as [|n l IHl] "IH" forall (v Hvl Φ). { rewrite Hvl; wp_pures. replace #0 with #(0%nat); last done. iApply "HΦ"; done. } wp_pures. destruct Hvl as [w [-> Hw]]. do 9 wp_pure _. wp_bind ((RecV _ _ _) _). wp_apply "IH"; first done. iIntros (? ->). wp_pures. replace (n + list_sum l)%Z with ((n + list_sum l)%nat : Z); last lia. iApply "HΦ"; done. Qed. (* definitely move *) Lemma list_sum_le l1 l2 : Forall2 le l1 l2 → list_sum l1 ≤ list_sum l2. Proof. revert l2; induction l1 as [|a l1 IHl1]; intros l2 Hle. { inversion Hle; simplify_eq; done. } inversion Hle; simplify_eq. simpl; apply Nat.add_le_mono; auto. Qed. (* definitely move *) Lemma vc_le_sum n (vc vc' : vector_clock n) : vc_le vc vc' → list_sum vc ≤ list_sum vc'. Proof. intros Hle. apply list_sum_le. apply Forall2_lookup; intros i. destruct (decide (i < n)) as [Hlt|]; last first. { rewrite !lookup_ge_None_2; first (by constructor); rewrite vec_to_list_length; auto with lia. } destruct (lookup_lt_is_Some_2 vc i) as [x Hx]; first by rewrite vec_to_list_length. destruct (lookup_lt_is_Some_2 vc' i) as [y Hy]; first by rewrite vec_to_list_length. rewrite Hx Hy; constructor. rewrite -(fin_to_nat_to_fin _ _ Hlt) in Hx, Hy. apply vlookup_lookup in Hx, Hy. rewrite -Hx -Hy. apply Hle. Qed. Lemma gcounter_query_proof l i a : ⊢ query_spec (λ i n, ∃ vc, Global_Inv ∗ GCallocated i l ∗ GCounterSnapShot i vc ∗ ⌜list_sum vc = n⌝)%I (λ: <>, gcounter_sum ! #l)%V i a. Proof. rewrite /query_spec. iIntros "!#" (n Hia Φ) "!# Hgc HΦ". assert (i < GClen gcdata) as Hilt. { apply lookup_lt_is_Some_1; eauto. } set (fi := nat_to_fin Hilt). iDestruct "Hgc" as (vc) "#(Hinv & Hial & Hsnap & <-)". wp_pures. wp_bind (! _)%E. iInv CvRDT_InvName as (st locs sevss revss) "(Hfst & HGC & >Hlocs & Hsevss & Hrevss & >Hlocs_coh & >Hsevss_coh & Hrevss_coh & Hnet)" "Hcl". iDestruct (locations_is_allocated with "Hlocs Hial") as %Hil'. iDestruct (locations_coherence_length with "Hlocs_coh") as %?. iDestruct (locations_coherence_insert_acc fi with "Hlocs_coh") as "[Hl Hback]"; first by rewrite fin_to_nat_to_fin; apply Hil'. iDestruct "Hl" as (vc' Hfivc'') "[Hevs Hl]". rewrite fin_to_nat_to_fin Hia in Hfivc''; simplify_eq Hfivc''; intros <-. wp_load; simpl. iDestruct (GCounterSnapShot_le fi with "[Hsnap] HGC") as %?. { rewrite fin_to_nat_to_fin; done. } iMod (get_GCounterSnapShot fi with "HGC") as "[HGC #Hsnap']". iDestruct ("Hback" $! (Some _) with "[Hevs Hl]") as "Hlocs_coh". { iExists _; iFrame; rewrite fin_to_nat_to_fin; done. } iMod ("Hcl" with "[Hfst HGC Hlocs Hsevss Hrevss Hlocs_coh Hsevss_coh Hrevss_coh Hnet]") as "_". { iNext; iExists _, _, _, _; iFrame. rewrite vlookup_insert_self list_insert_id; last by rewrite fin_to_nat_to_fin. iFrame. } iModIntro. wp_apply wp_gcounter_sum; [apply vector_clock_to_val_is_vc|done|]. iIntros (m ->). iApply "HΦ". iSplit; first by iPureIntro; apply vc_le_sum. rewrite fin_to_nat_to_fin. iExists (st !!! fi); iFrame "#"; done. Qed. Lemma vec_to_list_vc_incr n (vc : vector_clock n) i : ∀ (H : i < n), vec_to_list (vc_incr (nat_to_fin H) vc) = incr_time vc i. Proof. intros H. apply list_eq; intros j. destruct (decide (j < n)) as [Hlt|]; last first. { rewrite lookup_ge_None_2; last by rewrite vec_to_list_length; lia. rewrite lookup_ge_None_2; last by rewrite incr_time_length vec_to_list_length; lia. done. } destruct (lookup_lt_is_Some_2 vc j) as [x Hx]; first by rewrite vec_to_list_length; lia. destruct (decide (i = j)) as [->|]. - erewrite incr_time_proj; last apply Hx. rewrite /vc_incr. rewrite -{1}(fin_to_nat_to_fin _ _ H). apply vlookup_lookup. rewrite vlookup_insert. f_equal. apply vlookup_lookup; rewrite fin_to_nat_to_fin; done. - erewrite incr_time_proj_neq; last done. rewrite Hx /vc_incr. rewrite -(fin_to_nat_to_fin _ _ Hlt). apply vlookup_lookup. rewrite vlookup_insert_ne; last first. { intros Heq. pose proof (f_equal fin_to_nat Heq) as Heq'. rewrite !fin_to_nat_to_fin in Heq'; done. } apply vlookup_lookup. rewrite fin_to_nat_to_fin; done. Qed. Lemma list_sum_incr_time l i : i < length l → list_sum l < list_sum (incr_time l i). Proof. revert i; induction l as [|a l IHl]; intros i Hli; simpl in *; first lia. destruct i; simpl; first lia. apply plus_lt_compat_l; apply IHl; lia. Qed. Lemma gcounter_incr_proof l (i : nat) a : ⊢ incr_spec (λ i n, ∃ vc, Global_Inv ∗ GCallocated i l ∗ GCounterSnapShot i vc ∗ ⌜list_sum vc = n⌝)%I (rec: "incr" <> := let: "tmp" := ! #l in if: CAS #l "tmp" (vect_inc "tmp" #i) then #() else "incr" #())%V i a. Proof. rewrite /incr_spec. iIntros "!#" (n Hia Φ) "!# Hgc HΦ". assert (i < GClen gcdata) as Hilt. { apply lookup_lt_is_Some_1; eauto. } set (fi := nat_to_fin Hilt). iDestruct "Hgc" as (vc) "#(Hinv & Hial & Hsnap & <-)". iLöb as "IH". wp_pures. wp_bind (! _)%E. iInv CvRDT_InvName as (st locs sevss revss) "(Hfst & HGC & >Hlocs & >Hsevss & Hrevss & >Hlocs_coh & >Hsevss_coh & Hrevss_coh & Hnet)" "Hcl". iDestruct (locations_is_allocated with "Hlocs Hial") as %Hil. iDestruct (locations_coherence_length with "Hlocs_coh") as %?. iDestruct (locations_coherence_insert_acc fi with "Hlocs_coh") as "[Hl Hback]"; first by rewrite fin_to_nat_to_fin; apply Hil. iDestruct "Hl" as (vc' Hfivc') "[Hevs Hl]". rewrite fin_to_nat_to_fin Hia in Hfivc'; simplify_eq Hfivc'; intros <-. wp_load; simpl. iDestruct (GCounterSnapShot_le fi with "[Hsnap] HGC") as %?. { rewrite fin_to_nat_to_fin; done. } iDestruct ("Hback" $! (Some _) with "[Hevs Hl]") as "Hlocs_coh". { iExists _; iFrame; rewrite fin_to_nat_to_fin; done. } iMod ("Hcl" with "[Hfst HGC Hsevss Hrevss Hlocs Hlocs_coh Hsevss_coh Hrevss_coh Hnet]") as "_". { iNext; iExists _, _, _, _; iFrame. rewrite vlookup_insert_self list_insert_id; last by rewrite fin_to_nat_to_fin. iFrame. } iModIntro. wp_pures. destruct (lookup_lt_is_Some_2 (vec_to_list (st !!! fi)) i) as [x Hx]; first by rewrite vec_to_list_length. wp_apply (wp_vect_inc _ _ (vec_to_list (st !!! fi))); [by rewrite vec_to_list_length; lia|apply Hx|iPureIntro; apply vector_clock_to_val_is_vc|]. iIntros (v Hv). erewrite <- (is_vc_vector_clock_to_val v); last apply Hv. wp_bind (CAS _ _ _). iInv CvRDT_InvName as (st' locs' sevss' revss') "(>Hfst & HGC & >Hlocs & Hsevss & Hrevss & >Hlocs_coh & >Hsevss_coh & Hrevss_coh & Hnet)" "Hcl". iDestruct (locations_is_allocated with "Hlocs Hial") as %Hil'. iDestruct (locations_coherence_length with "Hlocs_coh") as %?. iDestruct (locations_coherence_insert_acc fi with "Hlocs_coh") as "[Hl Hback]"; first by rewrite fin_to_nat_to_fin; apply Hil'. iDestruct "Hl" as (vc' Hfivc'') "[Hevs Hl]". rewrite fin_to_nat_to_fin Hia in Hfivc''; simplify_eq Hfivc''; intros <-. destruct (decide (st !!! fi = st' !!! fi)) as [Heq|Hneq]. - iApply aneris_wp_atomic_take_step_model. iModIntro. iExists _, _; iFrame "Hfst". iSplit. { iPureIntro; right. apply (IncrStep _ fi). } wp_cas_suc; first by rewrite Heq. iIntros "Hfst". iDestruct ("Hback" $! (Some l) (vc_incr fi (st' !!! fi)) with "[Hevs Hl]") as "Hlocs_coh". { iExists _; iSplit; first by rewrite fin_to_nat_to_fin. rewrite Heq vec_to_list_vc_incr. iFrame. } iMod (GCounters_update fi (vc_incr fi (st' !!! fi)) with "HGC") as "[HGC _]"; first by apply vc_incr_le. iMod (get_GCounterSnapShot fi with "HGC") as "[HGC #Hsnap']". rewrite vlookup_insert. iMod ("Hcl" with "[Hfst HGC Hsevss Hrevss Hlocs Hlocs_coh Hsevss_coh Hrevss_coh Hnet]") as "_". { iNext; iExists _, _, _, _; iFrame. rewrite list_insert_id; last by rewrite fin_to_nat_to_fin. iFrame. } iApply fupd_mask_intro_subseteq; first done. wp_if. iClear "Hsnap". rewrite fin_to_nat_to_fin. iApply "HΦ". iExists (list_sum (vc_incr fi (st' !!! fi))); iFrame "#". iSplit; last by iExists _; iFrame "Hsnap'". iPureIntro. eapply le_lt_trans; first by apply vc_le_sum. rewrite vec_to_list_vc_incr Heq. apply list_sum_incr_time. rewrite vec_to_list_length; done. - wp_cas_fail. { intros Heq'%vector_clock_to_val_inj; apply Hneq. apply vec_to_list_inj2; done. } iDestruct ("Hback" $! (Some _) with "[Hevs Hl]") as "Hlocs_coh". { iExists _; iFrame; rewrite fin_to_nat_to_fin; done. } iMod ("Hcl" with "[Hfst HGC Hsevss Hrevss Hlocs Hlocs_coh Hsevss_coh Hrevss_coh Hnet]") as "_". { iNext; iExists _, _, _, _; iFrame. rewrite vlookup_insert_self list_insert_id; last by rewrite fin_to_nat_to_fin. iFrame. } iModIntro. wp_if. iApply "IH"; done. Qed. (* definitely move *) Lemma list_sum_replicate n m : list_sum (replicate n m) = n * m. Proof. induction n; simpl; lia. Qed. Lemma install_proof (i : nat) (a : socket_address) (v : val) : is_list (gcd_addr_list gcdata) v → gcd_addr_list gcdata !! i = Some a → {{{ Global_Inv ∗ GCunallocated i ∗ ([∗ list] i ↦ a ∈ gcd_addr_list gcdata, a ⤇ GCounter_socket_proto) ∗ free_ports (ip_of_address a) {[port_of_address a]} ∗ sendevs_frag i [] ∗ recevs_frag i [] }}} gcounter_install (StringOfZ i) v #i @[ip_of_address a] {{{ (GCounter : nat → nat → iProp Σ) query incr, RET (query, incr); GCounter i 0 ∗ query_spec GCounter query i a ∗ incr_spec GCounter incr i a}}}. Proof. iIntros (Hilv Hia Φ) "(#Hgi & Hua & #Hprotos & Hfpa & Hsevsfrg & Hrevsfrg) HΦ". rewrite /gcounter_install. assert (i < GClen gcdata) as Hilt. { apply lookup_lt_is_Some_1; eauto. } set (fi := nat_to_fin Hilt). wp_pures. wp_apply wp_list_length; first done. iIntros (? ->). wp_pures. replace #0 with #0%nat; last done. wp_apply wp_vect_make; first done. iIntros (w Hw). wp_bind (ref<<_>> _)%E. iInv CvRDT_InvName as (st locs sevss revss) "(Hfst & HGC & >Hlocs & >Hsevss & Hrevss & >Hlocs_coh & >Hsevss_coh & Hrevss_coh & Hnet)" "Hcl". iDestruct (locations_is_unallocated with "Hlocs Hua") as %Hlocsi. iDestruct (locations_coherence_length with "Hlocs_coh") as %Hlocslen. iDestruct (locations_coherence_insert_acc fi _ None with "Hlocs_coh") as "[Hloci Hback]". { by rewrite fin_to_nat_to_fin. } iDestruct (sendevs_coherence_length with "Hsevss_coh") as %Hsevsslen. destruct (lookup_lt_is_Some_2 sevss i) as [sevs Hsevs]; first by rewrite -Hsevsslen Hlocslen. iDestruct (sendevs_coherence_insert_acc i _ None with "Hsevss_coh") as "[Hsevsi Hback']"; [apply Hlocsi|apply Hsevs|]. iDestruct "Hloci" as "[Hlocievs %Hstfi]". wp_apply (aneris_wp_alloc_tracked with "[Hlocievs]"); first by rewrite (fin_to_nat_to_fin _ _ Hilt). iIntros (l h σ) "(Hl & % & Hlocievs)". iPoseProof ("Hback" $! (Some l) (vreplicate (GClen gcdata) 0) with "[Hl Hlocievs]") as "Hlocs_coh". { iExists _; iSplit; rewrite (fin_to_nat_to_fin _ _ Hilt); first done. erewrite is_vc_vector_clock_to_val; last by rewrite vec_to_list_replicate. iFrame. iExists _, _; iFrame; done. } rewrite -Hstfi vlookup_insert_self. iPoseProof ("Hback'" $! (Some l) sevs with "[Hsevsi]") as "Hsevss_coh". { iDestruct "Hsevsi" as (sa' Hsa' ?) "(? & ? & ->)". rewrite Hia in Hsa'; simplify_eq Hsa'; intros <-. iExists _; iSplit; first done. iSplit; first done. iFrame. iExists _; iFrame; auto. } rewrite (list_insert_id sevss); last done. iMod (locations_alloc with "Hlocs Hua") as "[Hlocs #Hial]". iMod (get_GCounterSnapShot fi with "HGC") as "[HGC #Hsnap]". rewrite !fin_to_nat_to_fin Hstfi. iMod ("Hcl" with "[Hfst HGC Hlocs Hsevss Hrevss Hlocs_coh Hsevss_coh Hrevss_coh Hnet]") as "_". { iNext; iExists _, _, _, _; iFrame. } iModIntro. wp_pures. wp_apply wp_list_nth; first done. iIntros (? [[]| (r & -> & Hr)]); first lia. apply misc.nth_error_lookup in Hr. rewrite Hia in Hr; simplify_eq. wp_apply wp_unSOME; first done. iIntros "_". wp_pures. wp_socket sh as "Hsh". wp_pures. wp_socketbind. iMod (inv_alloc (nroot .@ "skt") _ (sh ↪[ ip_of_address r] mkSocket (Some r) true) with "[$Hsh //]") as "#Hsh". wp_apply aneris_wp_fork. iSplitR "Hrevsfrg"; last first. { iNext. iApply (gcounter_apply_proof with "[Hrevsfrg]"); eauto. } iNext. wp_pures. wp_apply aneris_wp_fork. iSplitR "Hsevsfrg"; last first. { iNext. iApply (gcounter_broadcast_proof with "[Hsevsfrg]"); eauto. } iNext. wp_pures. rewrite /gcounter_query /gcounter_incr /=. wp_pures. iApply ("HΦ" $! (λ i n, ∃ vc, Global_Inv ∗ GCallocated i l ∗ GCounterSnapShot i vc ∗ ⌜list_sum vc = n⌝)%I). iSplit. { iExists _; iFrame "#". rewrite vec_to_list_replicate list_sum_replicate; auto with lia. } iSplit. - iApply gcounter_query_proof. - iApply gcounter_incr_proof. Qed. End proof.
If $h$ is bilinear, then $h(x, 0) = 0$.
#pragma once #include "Action.hpp" #include "BoardModel.hpp" #include "CellState.hpp" #include <boost/property_tree/ptree.hpp> namespace model::serialize { namespace pt = boost::property_tree; // save a game state (level only, or in-progress game) as property tree pt::ptree to_ptree(BoardModel const & model); // restore a level or in-progress game model from boost ptree void setup_model_from_ptree(pt::ptree & moves, BoardModel & model); // store/recreate a boardmodel as a json file void to_json_stream(std::ostream & ostr, BoardModel const & model); void to_json_stream(std::ostream & ostr, pt::ptree const & tree); void setup_model_from_json_stream(std::istream & istr, BoardModel & model); } // namespace model::serialize
Formal statement is: lemma closure_Un [simp]: "closure (S \<union> T) = closure S \<union> closure T" Informal statement is: The closure of the union of two sets is the union of the closures of the two sets.
lemma convex_hull_insert_alt: "convex hull (insert a S) = (if S = {} then {a} else {(1 - u) *\<^sub>R a + u *\<^sub>R x |x u. 0 \<le> u \<and> u \<le> 1 \<and> x \<in> convex hull S})"
import number_theory.padics.padic_integers --OUTPUT 1 theorem p_adic_unit (p : ℕ) (x : ℕ) (h : p.prime) (h_c : coprime p x): is_unit (p_adic_norm h) x := begin assume (h1 : ¬ is_unit (p_adic_norm h) x), have h2 : (p_adic_norm h) x < 1, from sorry, show false, from sorry, end --OUTPUT 2 theorem padic_units (p : ℕ) (x : ℕ) : ((x ≠ 0) ∧ gcd p x = 1) → ∃! u : ℕ, x * u = 1 := begin assume h1 : (x ≠ 0) ∧ gcd p x = 1, have h2 : x ∈ units (ℕ : Type*) := by { exact units.mk x 1 sorry }, have h3 : x ∈ units (padic_integers p) := by { exact units.mk x 1 sorry }, show ∃! u : ℕ, x * u = 1, from sorry, end --OUTPUT 3 theorem padic_units (p x : ℕ) : coprime p x → ∃ (u : ℤ), u * (p:ℤ) = x := begin assume h1 : coprime p x, have h2 : (p:ℤ) ∣ x, from sorry, have h3 : (p:ℤ) ∣ (1:ℤ), from sorry, have h4 : (p:ℤ) ∣ (x:ℤ), from sorry, have h5 : x = (p:ℤ)*(x:ℤ), from sorry, show ∃ u : ℤ, u * (p:ℤ) = x, from sorry, end --OUTPUT 4 theorem p_adic_units (p : ℕ) (hp : p.prime) (x : ℕ) (hx : (x ∣ p) = ff) : ((x : ℕ) : ℤp) ∈ units (ℤp) := begin have h1 : ((x : ℕ) : ℤp) ∈ units (ℤp) ↔ (norm p ((x : ℕ) : ℤp)) = 1, from begin have h1 : (x : ℤp) ≠ 0, from sorry, -- TODO: mod out x by p, see if it is equivalent to 0 have h2 : (x : ℤp) ∈ mul_group (ℤp), from sorry, -- TODO: show that if g is any unit, g is in the multiplicative group sorry, end, have h2 : (norm p ((x : ℕ) : ℤp)) = 1 ↔ (x : ℕ) ∣ p = ff, from sorry, -- TODO: finish this proof sorry, end --OUTPUT 5 theorem p_adic_units (p x : ℤ) (h₁ : prime p) (h₂ : nat.coprime x p.nat_abs) : (∀ (n : ℕ), ∃ (b : ℤ), n = p ^ b) → ∃ (n : ℕ), ∃ (b : ℤ), x = p ^ b * n := begin assume h₃ : ∀ (n : ℕ), ∃ (b : ℤ), n = p ^ b, have h4 : ∀ (n : ℕ), ∃ (b : ℤ), p ^ b * n = x, by { assume n, have h5 : n = p ^ nat.find (λ b, p ^ b * n = x), from sorry, sorry, }, let n := x.nat_abs, have h6 : ∃ (b : ℤ), p ^ b * n = x, from sorry, show ∃ (n : ℕ), ∃ (b : ℤ), x = p ^ b * n, from sorry, end --OUTPUT 6 theorem p_adic_units (p : ℕ) [hp : prime p] (x : ℕ) : coprime p x → is_unit (padic_int p x) := begin show ¬ is_unit (padic_int p x) → ¬ coprime p x, assume h1, show ¬ coprime p x, by { rcases h1 with ⟨y, h2, rfl⟩, show p ∣ x, from sorry, }, end --OUTPUT 7 theorem p_adic_units (p : ℕ) (x : ℕ) (hp : prime p) (hx : nat.coprime p x): nat.gcd x p = 1 → x ∈ units (padic_int p) := begin let p_pos : 0 < p := prime.pos hp, have x_ne_1 : x ≠ 1, { assume hx_1 : x = 1, have hp_1 : p = 1, { have h_p_x : nat.gcd p x = 1, { exact nat.gcd_eq_one_iff.2 hx, }, have h_p_1 : nat.gcd p 1 = 1, { exact nat.gcd_one_right p, }, have h_p_x_eq_p_1 : nat.gcd p x = nat.gcd p 1, { have h_x_1_eq : x = 1, { exact eq.subst hx_1 rfl, }, exact eq.subst h_x_1_eq h_p_x, }, exact eq.subst h_p_x_eq_p_1 h_p_1, }, have hp_1_false : p = 1 → false, { assume : p = 1, exact prime.ne_one hp, }, exact hp_1_false hp_1, }, have x_ne_0 : x ≠ 0, { assume hx_0 : x = 0, have hx_eq_0_1 : x = 1, { exact eq.subst hx_0 rfl, }, exact x_ne_1 hx_eq_0_1, }, have h_non_unit : ¬ is_unit x, { assume hu, rcases is_unit_iff_dvd_one.1 hu with ⟨u, rfl⟩, have x_eu : u * x = 1, { exact mul_one x, }, have hu_eq_1 : u = 1, { exact eq.subst x_eu rfl, }, have hu_1_eq_1 : u = 1 → 1 = 1, { assume hu_1, exact eq.subst hu_1 rfl, }, have hu_eq_x : u = x, { exact eq.subst (hu_1_eq_1 hu_eq_1) rfl, }, have hx_u_eq : x = u, { exact eq.subst hu_eq_x rfl, }, have hx_u : x = u, { exact eq.subst hx_u_eq rfl, }, have hx_not_1 : x ≠ 1, { assume h_x_1, have h_x_u : x = u, { exact eq.subst h_x_1 rfl, }, exact x_ne_1 h_x_u, }, exact hx_not_1 hu_eq_1, }, have h_x_not_unit : x ∉ units ℤ, { assume : x ∈ units ℤ, exact h_non_unit this, }, have h_p_not_dvd : p ∤ x, { assume hp_dvd, rcases hp_dvd with ⟨c, rfl⟩, have hc_0 : c = 0, { exact eq.subst rfl rfl, }, have hx_0 : x = 0, { exact eq.subst hc_0 rfl, }, exact x_ne_0 hx_0, }, have h_x_not_dvd_p : ¬ x ∣ p, { assume hx_dvd_p, rw nat.dvd_iff_mod_eq_zero at hx_dvd_p, have hx_mod_p_eq_zero : x % p = 0, { exact hx_dvd_p, }, have hx_mod_p_eq_0 : x % p = 0, { exact eq.subst hx_mod_p_eq_zero rfl, }, have h_x_eq_0_mod_p : x = 0 % p, { exact eq.subst hx_mod_p_eq_0 rfl, }, have h_x_mod_p_eq_x : x % p = x, { exact eq.subst h_x_eq_0_mod_p rfl, }, have h_x_at_most_p_minus_1 : x ≤ p-1, { exact nat.mod_lt x p_pos, }, have h_x_eq_p : x = p, { exact nat.eq_of_le_of_eq_sub_right h_x_at_most_p_minus_1 rfl, }, have h_x_p_not_1 : x ≠ 1, { assume hx_p_1, have h_x_prime_power : x = (prime.iterate (prime.iterate p 1 (prime.pow_one_right hp)) 1 (prime.pow_one_right hp)), { exact eq.subst hx_p_1 rfl, }, have h_x_power_of_p : x = p^p^p, { exact eq.subst h_x_prime_power rfl, }, have h_x_power_of_p_eq : x = (p^p)^p, { exact eq.subst h_x_power_of_p rfl, }, have h_x_power_of_p : x = p^(p^p), { exact eq.subst h_x_power_of_p_eq rfl, }, have h_not_prime : ¬ prime p, { have h_p_power_of_p_not_1 : (p^(p^p)) ≠ 1, { exact prime.pow_ne_one hp (p^p), }, exact prime.ne_one hp h_p_power_of_p_not_1, }, exact h_not_prime hp, }, exact x_ne_1 h_x_eq_p, }, have h_not_factor : ¬ (∃ c', c' * x = p), { assume h_factor, have h_factor_exists : ∃ c', c' * x = p, { exact h_factor, }, rcases h_factor_exists with ⟨ c', rfl⟩, have hc'_0 : c' = 0, { exact eq.subst rfl rfl, }, have hc'_0_false : c' = 0 → false, { assume : c' = 0, exact h_p_not_dvd rfl, }, have hx_eq_0 : x = 0, { exact eq.subst hc'_0 rfl, }, exact x_ne_0 hx_eq_0, }, have h_x_not_dvd_p_1 : ¬ x ∣ p-1, { assume hx_dvd_p_1, rw nat.dvd_iff_mod_eq_zero at hx_dvd_p_1 end --Needs more than 2000 tokens! --OUTPUT 8 theorem p_adic_units (p : ℕ) [hp : is_prime p] (x : ℕ) : coprime p x → is_unit (x : ℤ/p) := begin intro h1, have h2 : (p : ℕ) ≠ 0, from sorry, calc (x : ℤ/p) = ↑(x : ℤ) : rfl ... = ↑(x : ℕ) : sorry ... = ↑(x) : sorry ... = ↑(x) : sorry ... = ↑x : sorry ... = ↑(x) : sorry ... = ↑(x : ℤ) : sorry ... = (x : ℤ/p) : sorry end --OUTPUT 9 theorem padic_units (p : ℕ) (q : ℤ) (hp : prime p) (hq : ∀ a : ℤ, a * q = 1 → p ∤ a) : ¬(gcd p q = 1) := begin assume (h : gcd p q = 1), sorry, end --OUTPUT 10 theorem p_adic_units (p : ℕ) (hp : prime p) (x : ℕ) : x.coprime p → x.nat_abs ∈ units (p_adic_int p) := sorry /--`theorem` Galois' Conjugates Given a prime number $p$ and a natural number $x$, let $y$ be a $p$-adic conjugate of $x$, that is, $y \equiv x \pmod {p^2}$. Then $y$ is a unit. `proof` We prove the contrapositive, that is, if $y$ is not a unit, then $p | y$. We know that $y \equiv x \pmod {p^2}$. Also, we have that $y \equiv 0 \pmod p$, as this is true for all $p$-adic conjugates. Thus, $p | y$. This completes the proof. QED -/ theorem p_adic_conjugates (p : ℕ) (hp : prime p) (x : ℕ) (y : ℕ) : y ≡ x [ZMOD p^2] → y.nat_abs ∉ units (p_adic_int p) → p ∣ y := sorry /--`theorem` Finite Cardinality Characteristic Let $\struct {G, \circ}$ be a group. Then the number of elements of $G$ is either finite or countably infinite. `proof` The proof is by induction on the number of elements of $G$. The base case is when $G$ has no elements. In this case, $G$ is empty, so the number of elements of $G$ is finite. Now assume that the result holds for all groups with $n$ elements, for all natural numbers $n$ no bigger than some fixed $k$, and assume that $G$ has $k+1$ elements. Let $x$ be one of the $k+1$ elements of $G$. We claim that $G$ is the disjoint union of the following sets: :$S_1 = \set{e}$ :$S_2 = \set{x}$ :$S_3 = \set{a : a \in G, a \neq e, a \neq x}$ :$S_4 = \set{a \circ x^{-1} : a \in G}$ To show that $G$ is the disjoint union of $S_1, S_2, S_3,$ and $S_4$, we must show that the following are true: :$G = S_1 \cup S_2 \cup S_3 \cup S_4$ :$S_1 \cap S_2 = \emptyset$ :$S_1 \cap S_3 = \emptyset$ :$S_1 \cap S_4 = \emptyset$ :$S_2 \cap S_3 = \emptyset$ :$S_2 \cap S_4 = \emptyset$ :$S_3 \cap S_4 = \emptyset$ First, $G = S_1 \cup S_2 \cup S_3 \cup S_4$. This is true because the members of $S_1$, $S_2$, $S_3$, and $S_4$ are all elements of $G$. Second, $S_1 \cap S_2 = \emptyset$. This is true because $S_1$ and $S_2$ are both singleton sets, so they can only intersect if they have the same element, but $x \neq e$. Third, $S_1 \cap S_3 = \emptyset$. This is true because $G$ is a group, so the identity element is unique. Fourth, $S_1 \cap S_4 = \emptyset$. This is true because $S_4$ does not contain $e$ or $x$. Fifth, $S_2 \cap S_3 = \emptyset$. This is true because $S_2$ and $S_3$ are disjoint by construction. Sixth, $S_2 \cap S_4 = \emptyset$. This is true because $S_2$ contains $x$, and there is no element $a$ such that $a \circ x^{-1} = x$. Last, $S_3 \cap S_4 = \emptyset$. This is true because $S_3$ does not contain $x$ and $S_4$ does not contain $e$. The sets $S_1$, $S_2$, and $S_3$ are all finite, so we need only show that $S_4$ is finite. Because $S_4$ is the set of all elements of $G$ that are conjugates of $x$, its cardinality is the number of conjugates of $x$. Suppose that $x$ has $k$ conjugates. Then the number of elements of $G$ is the sum of $k$, 1, and $k$, which is $k + 1 + k = 2k + 1$, so the number of elements of $G$ is finite. We conclude that if $G$ has $2k+1$ elements, it cannot have $k+1$ conjugates, so $G$ has no more than $k$ conjugates. Assume that $G$ has $k+1$ conjugates. Then $G$ has $2k+1$ elements, because of the above argument. This contradicts the induction hypothesis, which states that a group with $2k+1$ elements must have $k$ or fewer conjugates, so $G$ must have $k$ or fewer conjugates. Because $G$ has $k$ or fewer conjugates, the number of elements of $G$ is either $2k+1$ or less than $2k+1$. We conclude that if $G$ has $k+1$ elements, it cannot have $k+1$ conjugates, so $G$ has either $k$ elements or fewer, or $2k+1$ elements or less. We conclude that if $G$ has $k+1$ elements, it has either $k$ or fewer elements, or it has $2k+1$ or fewer elements. {{qed}} -/ theorem finite_cardinality_characteristic {G : Type*} [group G] : (finite (set.card G)) ∨ (set.card G = cardinal.omega) := begin sorry, end /- FEW SHOT PROMPTS TO CODEX(START) /--`theorem` Power Set is Closed under Intersection Let $S$ be a set. Let $\powerset S$ be the power set of $S$. Then: :$\forall A, B \in \powerset S: A \cap B \in \powerset S$ `proof` Let $A, B \in \powerset S$. Then by the definition of power set, $A \subseteq S$ and $B \subseteq S$. From Intersection is Subset we have that $A \cap B \subseteq A$. It follows from Subset Relation is Transitive that $A \cap B \subseteq S$. Thus $A \cap B \in \powerset S$ and closure is proved. {{qed}} -/ theorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S := begin assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S), have h1 : (A ⊆ S) ∧ (B ⊆ S), from sorry, have h2 : (A ∩ B) ⊆ A, from sorry, have h3 : (A ∩ B) ⊆ S, from sorry, show (A ∩ B) ∈ 𝒫 S, from sorry, end /--`theorem` Square of Sum :$\forall x, y \in \R: \paren {x + y}^2 = x^2 + 2 x y + y^2$ `proof` Follows from the distribution of multiplication over addition: {{begin-eqn}} {{eqn | l = \left({x + y}\right)^2 | r = \left({x + y}\right) \cdot \left({x + y}\right) }} {{eqn | r = x \cdot \left({x + y}\right) + y \cdot \left({x + y}\right) | c = Real Multiplication Distributes over Addition }} {{eqn | r = x \cdot x + x \cdot y + y \cdot x + y \cdot y | c = Real Multiplication Distributes over Addition }} {{eqn | r = x^2 + 2xy + y^2 | c = }} {{end-eqn}} {{qed}} -/ theorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := begin calc (x + y)^2 = (x+y)*(x+y) : by sorry ... = x*(x+y) + y*(x+y) : by sorry ... = x*x + x*y + y*x + y*y : by sorry ... = x^2 + 2*x*y + y^2 : by sorry, end /--`theorem` Identity of Group is Unique Let $\struct {G, \circ}$ be a group. Then there is a unique identity element $e \in G$. `proof` From Group has Latin Square Property, there exists a unique $x \in G$ such that: :$a x = b$ and there exists a unique $y \in G$ such that: :$y a = b$ Setting $b = a$, this becomes: There exists a unique $x \in G$ such that: :$a x = a$ and there exists a unique $y \in G$ such that: :$y a = a$ These $x$ and $y$ are both $e$, by definition of identity element. {{qed}} -/ theorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a := begin have h1 : ∀ a b : G, ∃! x : G, a * x = b, from sorry, have h2 : ∀ a b : G, ∃! y : G, y * a = b, from sorry, have h3 : ∀ a : G, ∃! x : G, a * x = a, from sorry, have h4 : ∀ a : G, ∃! y : G, y * a = a, from sorry, have h5 : ∀ a : G, classical.some (h3 a) = (1 : G), from sorry, have h6 : ∀ a : G, classical.some (h4 a) = (1 : G), from sorry, show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by { use (1 : G), have h7 : ∀ e : G, (∀ a : G, e * a = a ∧ a * e = a) → e = 1, from by { assume (e : G) (h7 : ∀ a : G, e * a = a ∧ a * e = a), have h8 : ∀ a : G, e = classical.some (h3 a), from sorry, have h9 : ∀ a : G, e = classical.some (h4 a), from sorry, show e = (1 : G), from sorry, }, sorry, } end /--`theorem` p-adic units Given a prime number $p$ and a natural number $x$, if $x$ is coprime to $p$, then $x$ is a unit in the $p$-adic integers. `proof` Let us prove the contrapositive, that is, is $x$ is not a unit of $\mathbb{Z}_p$, then $x$ is not coprime to $p$. We know that any element of $\mathbb{Z}_p$ is a unit if and only if it has norm 1, thus $\Vert x \Vert \neq 1$. Also, since every element of $\mathbb{Z}_p$ must have norm less than or equal to 1, we conclude that $\Vert x \Vert < 1$. But this must imply that $p | x$. This completes our proof. QED -/ theorem FEW SHOT PROMPTS TO CODEX(END)-/
George Washington Papers, Series 4, General Correspondence: Mark Hopkins to James Barret . 1776. Manuscript/Mixed Material. https://www.loc.gov/item/mgw444371/. (1776) George Washington Papers, Series 4, General Correspondence: Mark Hopkins to James Barret . [Manuscript/Mixed Material] Retrieved from the Library of Congress, https://www.loc.gov/item/mgw444371/. George Washington Papers, Series 4, General Correspondence: Mark Hopkins to James Barret . 1776. Manuscript/Mixed Material. Retrieved from the Library of Congress, <www.loc.gov/item/mgw444371/>.
import SciLean.Data.ArrayType.Properties namespace SciLean variable {Cont : Type} {Idx : Type |> outParam} {Elem : Type |> outParam} variable [ArrayType Cont Idx Elem] [Enumtype Idx] [Nonempty Idx] @[simp] theorem sum_setElem_zero [Vec Elem] (f : Idx → Elem) : ∑ (i : Idx), setElem (0 : Cont) i (f i) = introElem f := sorry_proof @[simp] theorem sum_setElem_zero' [Vec Elem] (f : Idx → Elem) (g : Idx → Idx) [IsInv g] : ∑ (i : Idx), setElem (0 : Cont) (g i) (f i) = introElem (λ i => f (g⁻¹ i)) := sorry_proof
module Issue231 where postulate A : Set data List : Set where _∷_ : A → List → List data Any : List → Set where there : ∀ {x xs} → Any xs → Any (x ∷ xs) postulate id : (A : Set) → A → A lemma : (xs : List) → Set → (p : Any xs) → Set lemma (x ∷ xs) A (there p) with id (Any xs) p lemma (x ∷ xs) A (there p) | p′ = {!p′!} -- Before case-split: -- lemma (x ∷ xs) A (there p) | p′ = {!p′!} -- After case-split: -- lemma (A ∷ _) _ (there p) | there y = ?
import SciLean.Mechanics import SciLean.Operators.ODE import SciLean.Solver import SciLean.Tactic.LiftLimit import SciLean.Tactic.FinishImpl import SciLean.Data.PowType import SciLean.Core.Extra import SciLean.Functions open SciLean set_option synthInstance.maxSize 2048 set_option synthInstance.maxHeartbeats 500000 set_option maxHeartbeats 500000 def LennardJones (ε minEnergy : ℝ) (radius : ℝ) (x : ℝ^(3:ℕ)) : ℝ := let x' := ∥1/radius * x∥^{-6, ε} 4 * minEnergy * x' * (x' - 1) argument x [Fact (ε≠0)] isSmooth, diff, hasAdjDiff, adjDiff def Coloumb (ε strength mass : ℝ) (x : ℝ^(3:ℕ)) : ℝ := - strength * mass * ∥x∥^{-1,ε} argument x [Fact (ε≠0)] isSmooth, diff, hasAdjDiff, adjDiff example (n : ℕ) (ε : ℝ) [Fact (n≠0)] [Fact (ε≠0)] (C LJ : ℝ) (r m : Idx n → ℝ) : (∂† λ (x : (ℝ^(3:ℕ))^n) => ∑ i j, Coloumb ε C (m i * m j) (x[i] - x[j]) + LennardJones ε LJ (r i + r j) (x[i] - x[j])) = λ x dx' => PowType.intro λ i => ∑ j, Coloumb.arg_x.adjDiff ε C (m i * m j) (x[i] - x[j]) dx' - Coloumb.arg_x.adjDiff ε C (m j * m i) (x[j] - x[i]) dx' + ( LennardJones.arg_x.adjDiff ε LJ (r i + r j) (x[i] - x[j]) dx' - LennardJones.arg_x.adjDiff ε LJ (r j + r i) (x[j] - x[i]) dx') := by simp; unfold hold; simp; simp [sum_into_lambda] simp [← sum_of_add] done def H (n : ℕ) (ε : ℝ) (C LJ : ℝ) (r m : Idx n → ℝ) (x p : (ℝ^(3:ℕ))^n) : ℝ := (∑ i, (1/(2*m i)) * ∥p[i]∥²) + ∑ i j, Coloumb ε C (m i * m j) (x[i] - x[j]) + LennardJones ε LJ (r i + r j) (x[i] - x[j]) argument p [Fact (n≠0)] [Fact (ε≠0)] isSmooth, diff, hasAdjDiff, adjDiff argument x [Fact (n≠0)] [Fact (ε≠0)] isSmooth, diff, hasAdjDiff, adjDiff by simp[H]; unfold hold; simp; unfold hold; simp; simp [sum_into_lambda] simp [← sum_of_add]
State Before: α : Type u β : Type v γ : Type w ι : Sort x inst✝¹ : Preorder α inst✝ : Preorder β s t : Set α a b : α ⊢ ¬BddAbove s ↔ ∀ (x : α), ∃ y, y ∈ s ∧ ¬y ≤ x State After: no goals Tactic: simp [BddAbove, upperBounds, Set.Nonempty]
/- Copyright (c) 2022 Joseph Myers. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Myers ! This file was ported from Lean 3 source module analysis.convex.strict_convex_between ! leanprover-community/mathlib commit e1730698f86560a342271c0471e4cb72d021aabf ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathbin.Analysis.Convex.Between import Mathbin.Analysis.Convex.StrictConvexSpace /-! # Betweenness in affine spaces for strictly convex spaces This file proves results about betweenness for points in an affine space for a strictly convex space. -/ variable {V P : Type _} [NormedAddCommGroup V] [NormedSpace ℝ V] [PseudoMetricSpace P] variable [NormedAddTorsor V P] [StrictConvexSpace ℝ V] include V theorem Sbtw.dist_lt_max_dist (p : P) {p₁ p₂ p₃ : P} (h : Sbtw ℝ p₁ p₂ p₃) : dist p₂ p < max (dist p₁ p) (dist p₃ p) := by have hp₁p₃ : p₁ -ᵥ p ≠ p₃ -ᵥ p := by simpa using h.left_ne_right rw [Sbtw, ← wbtw_vsub_const_iff p, Wbtw, affineSegment_eq_segment, ← insert_endpoints_openSegment, Set.mem_insert_iff, Set.mem_insert_iff] at h rcases h with ⟨h | h | h, hp₂p₁, hp₂p₃⟩ · rw [vsub_left_cancel_iff] at h exact False.elim (hp₂p₁ h) · rw [vsub_left_cancel_iff] at h exact False.elim (hp₂p₃ h) · rw [openSegment_eq_image, Set.mem_image] at h rcases h with ⟨r, ⟨hr0, hr1⟩, hr⟩ simp_rw [@dist_eq_norm_vsub V, ← hr] exact norm_combo_lt_of_ne (le_max_left _ _) (le_max_right _ _) hp₁p₃ (sub_pos.2 hr1) hr0 (by abel) #align sbtw.dist_lt_max_dist Sbtw.dist_lt_max_dist theorem Wbtw.dist_le_max_dist (p : P) {p₁ p₂ p₃ : P} (h : Wbtw ℝ p₁ p₂ p₃) : dist p₂ p ≤ max (dist p₁ p) (dist p₃ p) := by by_cases hp₁ : p₂ = p₁; · simp [hp₁] by_cases hp₃ : p₂ = p₃; · simp [hp₃] have hs : Sbtw ℝ p₁ p₂ p₃ := ⟨h, hp₁, hp₃⟩ exact (hs.dist_lt_max_dist _).le #align wbtw.dist_le_max_dist Wbtw.dist_le_max_dist /-- Given three collinear points, two (not equal) with distance `r` from `p` and one with distance at most `r` from `p`, the third point is weakly between the other two points. -/ theorem Collinear.wbtw_of_dist_eq_of_dist_le {p p₁ p₂ p₃ : P} {r : ℝ} (h : Collinear ℝ ({p₁, p₂, p₃} : Set P)) (hp₁ : dist p₁ p = r) (hp₂ : dist p₂ p ≤ r) (hp₃ : dist p₃ p = r) (hp₁p₃ : p₁ ≠ p₃) : Wbtw ℝ p₁ p₂ p₃ := by rcases h.wbtw_or_wbtw_or_wbtw with (hw | hw | hw) · exact hw · by_cases hp₃p₂ : p₃ = p₂ · simp [hp₃p₂] have hs : Sbtw ℝ p₂ p₃ p₁ := ⟨hw, hp₃p₂, hp₁p₃.symm⟩ have hs' := hs.dist_lt_max_dist p rw [hp₁, hp₃, lt_max_iff, lt_self_iff_false, or_false_iff] at hs' exact False.elim (hp₂.not_lt hs') · by_cases hp₁p₂ : p₁ = p₂ · simp [hp₁p₂] have hs : Sbtw ℝ p₃ p₁ p₂ := ⟨hw, hp₁p₃, hp₁p₂⟩ have hs' := hs.dist_lt_max_dist p rw [hp₁, hp₃, lt_max_iff, lt_self_iff_false, false_or_iff] at hs' exact False.elim (hp₂.not_lt hs') #align collinear.wbtw_of_dist_eq_of_dist_le Collinear.wbtw_of_dist_eq_of_dist_le /-- Given three collinear points, two (not equal) with distance `r` from `p` and one with distance less than `r` from `p`, the third point is strictly between the other two points. -/ theorem Collinear.sbtw_of_dist_eq_of_dist_lt {p p₁ p₂ p₃ : P} {r : ℝ} (h : Collinear ℝ ({p₁, p₂, p₃} : Set P)) (hp₁ : dist p₁ p = r) (hp₂ : dist p₂ p < r) (hp₃ : dist p₃ p = r) (hp₁p₃ : p₁ ≠ p₃) : Sbtw ℝ p₁ p₂ p₃ := by refine' ⟨h.wbtw_of_dist_eq_of_dist_le hp₁ hp₂.le hp₃ hp₁p₃, _, _⟩ · rintro rfl exact hp₂.ne hp₁ · rintro rfl exact hp₂.ne hp₃ #align collinear.sbtw_of_dist_eq_of_dist_lt Collinear.sbtw_of_dist_eq_of_dist_lt
(* Default settings (from HsToCoq.Coq.Preamble) *) Generalizable All Variables. Unset Implicit Arguments. Set Maximal Implicit Insertion. Unset Strict Implicit. Unset Printing Implicit Defensive. Require Coq.Program.Tactics. Require Coq.Program.Wf. (* Converted imports: *) Require Data.Foldable. Require GHC.Base. Require GHC.Prim. Require UniqFM. Require Unique. Import GHC.Base.Notations. (* Converted type declarations: *) Inductive UniqSet a : Type := Mk_UniqSet (getUniqSet' : UniqFM.UniqFM a) : UniqSet a. Arguments Mk_UniqSet {_} _. Definition getUniqSet' {a} (arg_0__ : UniqSet a) := let 'Mk_UniqSet getUniqSet' := arg_0__ in getUniqSet'. (* Converted value declarations: *) Definition unsafeUFMToUniqSet {a} : UniqFM.UniqFM a -> UniqSet a := Mk_UniqSet. Definition unitUniqSet {a} `{Unique.Uniquable a} : a -> UniqSet a := fun x => Mk_UniqSet (UniqFM.unitUFM x x). Definition uniqSetMinusUFM {a} {b} : UniqSet a -> UniqFM.UniqFM b -> UniqSet a := fun arg_0__ arg_1__ => match arg_0__, arg_1__ with | Mk_UniqSet s, t => Mk_UniqSet (UniqFM.minusUFM s t) end. Definition uniqSetAny {a} : (a -> bool) -> UniqSet a -> bool := fun arg_0__ arg_1__ => match arg_0__, arg_1__ with | p, Mk_UniqSet s => UniqFM.anyUFM p s end. Definition uniqSetAll {a} : (a -> bool) -> UniqSet a -> bool := fun arg_0__ arg_1__ => match arg_0__, arg_1__ with | p, Mk_UniqSet s => UniqFM.allUFM p s end. Definition unionUniqSets {a} : UniqSet a -> UniqSet a -> UniqSet a := fun arg_0__ arg_1__ => match arg_0__, arg_1__ with | Mk_UniqSet s, Mk_UniqSet t => Mk_UniqSet (UniqFM.plusUFM s t) end. Definition sizeUniqSet {a} : UniqSet a -> nat := fun '(Mk_UniqSet s) => UniqFM.sizeUFM s. Definition restrictUniqSetToUFM {a} {b} : UniqSet a -> UniqFM.UniqFM b -> UniqSet a := fun arg_0__ arg_1__ => match arg_0__, arg_1__ with | Mk_UniqSet s, m => Mk_UniqSet (UniqFM.intersectUFM s m) end. Instance Unpeel_UniqSet ele : GHC.Prim.Unpeel (UniqSet ele) (UniqFM.UniqFM ele) := GHC.Prim.Build_Unpeel _ _ (fun '(Mk_UniqSet y) => y) Mk_UniqSet. Definition partitionUniqSet {a} : (a -> bool) -> UniqSet a -> (UniqSet a * UniqSet a)%type := fun arg_0__ arg_1__ => match arg_0__, arg_1__ with | p, Mk_UniqSet s => GHC.Prim.coerce (UniqFM.partitionUFM p s) end. Definition nonDetKeysUniqSet {elt} : UniqSet elt -> list Unique.Unique := UniqFM.nonDetKeysUFM GHC.Base.∘ getUniqSet'. Definition nonDetFoldUniqSet_Directly {elt} {a} : (Unique.Unique -> elt -> a -> a) -> a -> UniqSet elt -> a := fun arg_0__ arg_1__ arg_2__ => match arg_0__, arg_1__, arg_2__ with | f, n, Mk_UniqSet s => UniqFM.nonDetFoldUFM_Directly f n s end. Definition nonDetFoldUniqSet {elt} {a} : (elt -> a -> a) -> a -> UniqSet elt -> a := fun arg_0__ arg_1__ arg_2__ => match arg_0__, arg_1__, arg_2__ with | c, n, Mk_UniqSet s => UniqFM.nonDetFoldUFM c n s end. Definition nonDetEltsUniqSet {elt} : UniqSet elt -> list elt := UniqFM.nonDetEltsUFM GHC.Base.∘ getUniqSet'. Definition minusUniqSet {a} : UniqSet a -> UniqSet a -> UniqSet a := fun arg_0__ arg_1__ => match arg_0__, arg_1__ with | Mk_UniqSet s, Mk_UniqSet t => Mk_UniqSet (UniqFM.minusUFM s t) end. Definition lookupUniqSet_Directly {a} : UniqSet a -> Unique.Unique -> option a := fun arg_0__ arg_1__ => match arg_0__, arg_1__ with | Mk_UniqSet s, k => UniqFM.lookupUFM_Directly s k end. Definition lookupUniqSet {a} {b} `{Unique.Uniquable a} : UniqSet b -> a -> option b := fun arg_0__ arg_1__ => match arg_0__, arg_1__ with | Mk_UniqSet s, k => UniqFM.lookupUFM s k end. Definition isEmptyUniqSet {a} : UniqSet a -> bool := fun '(Mk_UniqSet s) => UniqFM.isNullUFM s. Definition intersectUniqSets {a} : UniqSet a -> UniqSet a -> UniqSet a := fun arg_0__ arg_1__ => match arg_0__, arg_1__ with | Mk_UniqSet s, Mk_UniqSet t => Mk_UniqSet (UniqFM.intersectUFM s t) end. Definition getUniqSet {a} : UniqSet a -> UniqFM.UniqFM a := getUniqSet'. Definition filterUniqSet_Directly {elt} : (Unique.Unique -> elt -> bool) -> UniqSet elt -> UniqSet elt := fun arg_0__ arg_1__ => match arg_0__, arg_1__ with | f, Mk_UniqSet s => Mk_UniqSet (UniqFM.filterUFM_Directly f s) end. Definition filterUniqSet {a} : (a -> bool) -> UniqSet a -> UniqSet a := fun arg_0__ arg_1__ => match arg_0__, arg_1__ with | p, Mk_UniqSet s => Mk_UniqSet (UniqFM.filterUFM p s) end. Definition emptyUniqSet {a} : UniqSet a := Mk_UniqSet UniqFM.emptyUFM. Definition unionManyUniqSets {a} (xs : list (UniqSet a)) : UniqSet a := match xs with | nil => emptyUniqSet | cons set sets => Data.Foldable.foldr unionUniqSets set sets end. Definition elementOfUniqSet {a} `{Unique.Uniquable a} : a -> UniqSet a -> bool := fun arg_0__ arg_1__ => match arg_0__, arg_1__ with | a, Mk_UniqSet s => UniqFM.elemUFM a s end. Definition elemUniqSet_Directly {a} : Unique.Unique -> UniqSet a -> bool := fun arg_0__ arg_1__ => match arg_0__, arg_1__ with | a, Mk_UniqSet s => UniqFM.elemUFM_Directly a s end. Definition delOneFromUniqSet_Directly {a} : UniqSet a -> Unique.Unique -> UniqSet a := fun arg_0__ arg_1__ => match arg_0__, arg_1__ with | Mk_UniqSet s, u => Mk_UniqSet (UniqFM.delFromUFM_Directly s u) end. Definition delOneFromUniqSet {a} `{Unique.Uniquable a} : UniqSet a -> a -> UniqSet a := fun arg_0__ arg_1__ => match arg_0__, arg_1__ with | Mk_UniqSet s, a => Mk_UniqSet (UniqFM.delFromUFM s a) end. Definition delListFromUniqSet_Directly {a} : UniqSet a -> list Unique.Unique -> UniqSet a := fun arg_0__ arg_1__ => match arg_0__, arg_1__ with | Mk_UniqSet s, l => Mk_UniqSet (UniqFM.delListFromUFM_Directly s l) end. Definition delListFromUniqSet {a} `{Unique.Uniquable a} : UniqSet a -> list a -> UniqSet a := fun arg_0__ arg_1__ => match arg_0__, arg_1__ with | Mk_UniqSet s, l => Mk_UniqSet (UniqFM.delListFromUFM s l) end. Definition addOneToUniqSet {a} `{Unique.Uniquable a} : UniqSet a -> a -> UniqSet a := fun arg_0__ arg_1__ => match arg_0__, arg_1__ with | Mk_UniqSet set, x => Mk_UniqSet (UniqFM.addToUFM set x x) end. Definition mkUniqSet {a} `{Unique.Uniquable a} : list a -> UniqSet a := Data.Foldable.foldl' addOneToUniqSet emptyUniqSet. Definition mapUniqSet {b} {a} `{Unique.Uniquable b} : (a -> b) -> UniqSet a -> UniqSet b := fun f => mkUniqSet GHC.Base.∘ (GHC.Base.map f GHC.Base.∘ nonDetEltsUniqSet). Definition addListToUniqSet {a} `{Unique.Uniquable a} : UniqSet a -> list a -> UniqSet a := Data.Foldable.foldl' addOneToUniqSet. (* Skipping all instances of class `Data.Data.Data', including `UniqSet.Data__UniqSet' *) Local Definition Semigroup__UniqSet_op_zlzlzgzg__ {inst_a} : UniqSet inst_a -> UniqSet inst_a -> UniqSet inst_a := GHC.Prim.coerce _GHC.Base.<<>>_. Program Instance Semigroup__UniqSet {a} : GHC.Base.Semigroup (UniqSet a) := fun _ k__ => k__ {| GHC.Base.op_zlzlzgzg____ := Semigroup__UniqSet_op_zlzlzgzg__ |}. Local Definition Monoid__UniqSet_mappend {inst_a} : UniqSet inst_a -> UniqSet inst_a -> UniqSet inst_a := GHC.Prim.coerce GHC.Base.mappend. Local Definition Monoid__UniqSet_mconcat {inst_a} : list (UniqSet inst_a) -> UniqSet inst_a := GHC.Prim.coerce GHC.Base.mconcat. Local Definition Monoid__UniqSet_mempty {inst_a} : UniqSet inst_a := Mk_UniqSet GHC.Base.mempty. Program Instance Monoid__UniqSet {a} : GHC.Base.Monoid (UniqSet a) := fun _ k__ => k__ {| GHC.Base.mappend__ := Monoid__UniqSet_mappend ; GHC.Base.mconcat__ := Monoid__UniqSet_mconcat ; GHC.Base.mempty__ := Monoid__UniqSet_mempty |}. (* Skipping all instances of class `Outputable.Outputable', including `UniqSet.Outputable__UniqSet' *) (* Skipping instance `UniqSet.Eq___UniqSet' of class `GHC.Base.Eq_' *) (* External variables: bool cons list nat op_zt__ option Data.Foldable.foldl' Data.Foldable.foldr GHC.Base.Monoid GHC.Base.Semigroup GHC.Base.map GHC.Base.mappend GHC.Base.mappend__ GHC.Base.mconcat GHC.Base.mconcat__ GHC.Base.mempty GHC.Base.mempty__ GHC.Base.op_z2218U__ GHC.Base.op_zlzlzgzg__ GHC.Base.op_zlzlzgzg____ GHC.Prim.Build_Unpeel GHC.Prim.Unpeel GHC.Prim.coerce UniqFM.UniqFM UniqFM.addToUFM UniqFM.allUFM UniqFM.anyUFM UniqFM.delFromUFM UniqFM.delFromUFM_Directly UniqFM.delListFromUFM UniqFM.delListFromUFM_Directly UniqFM.elemUFM UniqFM.elemUFM_Directly UniqFM.emptyUFM UniqFM.filterUFM UniqFM.filterUFM_Directly UniqFM.intersectUFM UniqFM.isNullUFM UniqFM.lookupUFM UniqFM.lookupUFM_Directly UniqFM.minusUFM UniqFM.nonDetEltsUFM UniqFM.nonDetFoldUFM UniqFM.nonDetFoldUFM_Directly UniqFM.nonDetKeysUFM UniqFM.partitionUFM UniqFM.plusUFM UniqFM.sizeUFM UniqFM.unitUFM Unique.Uniquable Unique.Unique *)
From iris.proofmode Require Import tactics. From iris.program_logic Require Export weakestpre. From iris.heap_lang Require Export derived_laws. From iris.heap_lang Require Import proofmode notation. From iris.prelude Require Import options. (** Provides some array utilities: * [array_free], to deallocate an entire array in one go. * [array_copy_to], a function which copies to an array in-place. * Using [array_copy_to] we also implement [array_clone], which allocates a fresh array and copies to it. * [array_init], to create and initialize an array with a given function. Specifically, [array_init n f] creates a new array of size [n] in which the [i]th element is initialized with [f #i] *) Definition array_free : val := rec: "freeN" "ptr" "n" := if: "n" ≤ #0 then #() else Free "ptr";; "freeN" ("ptr" +ₗ #1) ("n" - #1). Definition array_copy_to : val := rec: "array_copy_to" "dst" "src" "n" := if: "n" ≤ #0 then #() else "dst" <- !"src";; "array_copy_to" ("dst" +ₗ #1) ("src" +ₗ #1) ("n" - #1). Definition array_clone : val := λ: "src" "n", let: "dst" := AllocN "n" #() in array_copy_to "dst" "src" "n";; "dst". (* [array_init_loop src i n f] initializes elements [i], [i+1], ..., [n] of the array [src] to [f #i], [f #(i+1)], ..., [f #n] *) Local Definition array_init_loop : val := rec: "loop" "src" "i" "n" "f" := if: "i" = "n" then #() else "src" +ₗ "i" <- "f" "i";; "loop" "src" ("i" + #1) "n" "f". Definition array_init : val := λ: "n" "f", let: "src" := AllocN "n" #() in array_init_loop "src" #0 "n" "f";; "src". Section proof. Context `{!heapG Σ}. Lemma twp_array_free s E l vs (n : Z) : n = length vs → [[{ l ↦∗ vs }]] array_free #l #n @ s; E [[{ RET #(); True }]]. Proof. iIntros (Hlen Φ) "Hl HΦ". iInduction vs as [|v vs] "IH" forall (l n Hlen); subst n; wp_rec; wp_pures. { iApply "HΦ". done. } iDestruct (array_cons with "Hl") as "[Hv Hl]". wp_free. wp_pures. iApply ("IH" with "[] Hl"); eauto with lia. Qed. Lemma wp_array_free s E l vs (n : Z) : n = length vs → {{{ l ↦∗ vs }}} array_free #l #n @ s; E {{{ RET #(); True }}}. Proof. iIntros (? Φ) "H HΦ". iApply (twp_wp_step with "HΦ"). iApply (twp_array_free with "H"); [auto..|]; iIntros "H HΦ". by iApply "HΦ". Qed. Lemma twp_array_copy_to stk E (dst src : loc) vdst vsrc dq (n : Z) : Z.of_nat (length vdst) = n → Z.of_nat (length vsrc) = n → [[{ dst ↦∗ vdst ∗ src ↦∗{dq} vsrc }]] array_copy_to #dst #src #n @ stk; E [[{ RET #(); dst ↦∗ vsrc ∗ src ↦∗{dq} vsrc }]]. Proof. iIntros (Hvdst Hvsrc Φ) "[Hdst Hsrc] HΦ". iInduction vdst as [|v1 vdst] "IH" forall (n dst src vsrc Hvdst Hvsrc); destruct vsrc as [|v2 vsrc]; simplify_eq/=; try lia; wp_rec; wp_pures. { iApply "HΦ". auto with iFrame. } iDestruct (array_cons with "Hdst") as "[Hv1 Hdst]". iDestruct (array_cons with "Hsrc") as "[Hv2 Hsrc]". wp_load; wp_store. wp_smart_apply ("IH" with "[%] [%] Hdst Hsrc"); [ lia .. | ]. iIntros "[Hvdst Hvsrc]". iApply "HΦ"; by iFrame. Qed. Lemma wp_array_copy_to stk E (dst src : loc) vdst vsrc dq (n : Z) : Z.of_nat (length vdst) = n → Z.of_nat (length vsrc) = n → {{{ dst ↦∗ vdst ∗ src ↦∗{dq} vsrc }}} array_copy_to #dst #src #n @ stk; E {{{ RET #(); dst ↦∗ vsrc ∗ src ↦∗{dq} vsrc }}}. Proof. iIntros (? ? Φ) "H HΦ". iApply (twp_wp_step with "HΦ"). iApply (twp_array_copy_to with "H"); [auto..|]; iIntros "H HΦ". by iApply "HΦ". Qed. Lemma twp_array_clone stk E l dq vl n : Z.of_nat (length vl) = n → (0 < n)%Z → [[{ l ↦∗{dq} vl }]] array_clone #l #n @ stk; E [[{ l', RET #l'; l' ↦∗ vl ∗ l ↦∗{dq} vl }]]. Proof. iIntros (Hvl Hn Φ) "Hvl HΦ". wp_lam. wp_alloc dst as "Hdst"; first by auto. wp_smart_apply (twp_array_copy_to with "[$Hdst $Hvl]"). - rewrite replicate_length Z2Nat.id; lia. - auto. - iIntros "[Hdst Hl]". wp_pures. iApply "HΦ"; by iFrame. Qed. Lemma wp_array_clone stk E l dq vl n : Z.of_nat (length vl) = n → (0 < n)%Z → {{{ l ↦∗{dq} vl }}} array_clone #l #n @ stk; E {{{ l', RET #l'; l' ↦∗ vl ∗ l ↦∗{dq} vl }}}. Proof. iIntros (? ? Φ) "H HΦ". iApply (twp_wp_step with "HΦ"). iApply (twp_array_clone with "H"); [auto..|]; iIntros (l') "H HΦ". by iApply "HΦ". Qed. Section array_init. Context (Q : nat → val → iProp Σ). Implicit Types (f v : val) (i j : nat). Local Lemma wp_array_init_loop stk E l i n k f : n = Z.of_nat (i + k) → {{{ (l +ₗ i) ↦∗ replicate k #() ∗ [∗ list] j ∈ seq i k, WP f #(j : nat) @ stk; E {{ Q j }} }}} array_init_loop #l #i #n f @ stk; E {{{ vs, RET #(); ⌜ length vs = k ⌝ ∗ (l +ₗ i) ↦∗ vs ∗ [∗ list] j↦v ∈ vs, Q (i + j) v }}}. Proof. iIntros (Hn Φ) "[Hl Hf] HΦ". iInduction k as [|k] "IH" forall (i Hn); simplify_eq/=; wp_rec; wp_pures. { rewrite bool_decide_eq_true_2; last (repeat f_equal; lia). wp_pures. iApply ("HΦ" $! []). auto. } rewrite bool_decide_eq_false_2; last naive_solver lia. iDestruct (array_cons with "Hl") as "[Hl HSl]". iDestruct "Hf" as "[Hf HSf]". wp_smart_apply (wp_wand with "Hf"); iIntros (v) "Hv". wp_store. wp_pures. rewrite Z.add_1_r -Nat2Z.inj_succ. iApply ("IH" with "[%] [HSl] HSf"); first lia. { by rewrite loc_add_assoc Z.add_1_r -Nat2Z.inj_succ. } iIntros "!>" (vs). iDestruct 1 as (<-) "[HSl Hvs]". iApply ("HΦ" $! (v :: vs)). iSplit; [naive_solver|]. iSplitL "Hl HSl". - iFrame "Hl". by rewrite loc_add_assoc Z.add_1_r -Nat2Z.inj_succ. - iEval (rewrite /= Nat.add_0_r; setoid_rewrite Nat.add_succ_r). iFrame. Qed. Local Lemma twp_array_init_loop stk E l i n k f : n = Z.of_nat (i + k) → [[{ (l +ₗ i) ↦∗ replicate k #() ∗ [∗ list] j ∈ seq i k, WP f #(j : nat) @ stk; E [{ Q j }] }]] array_init_loop #l #i #n f @ stk; E [[{ vs, RET #(); ⌜ length vs = k ⌝ ∗ (l +ₗ i) ↦∗ vs ∗ [∗ list] j↦v ∈ vs, Q (i + j) v }]]. Proof. iIntros (Hn Φ) "[Hl Hf] HΦ". iInduction k as [|k] "IH" forall (i Hn); simplify_eq/=; wp_rec; wp_pures. { rewrite bool_decide_eq_true_2; last (repeat f_equal; lia). wp_pures. iApply ("HΦ" $! []). auto. } rewrite bool_decide_eq_false_2; last naive_solver lia. iDestruct (array_cons with "Hl") as "[Hl HSl]". iDestruct "Hf" as "[Hf HSf]". wp_smart_apply (twp_wand with "Hf"); iIntros (v) "Hv". wp_store. wp_pures. rewrite Z.add_1_r -Nat2Z.inj_succ. iApply ("IH" with "[%] [HSl] HSf"); first lia. { by rewrite loc_add_assoc Z.add_1_r -Nat2Z.inj_succ. } iIntros (vs). iDestruct 1 as (<-) "[HSl Hvs]". iApply ("HΦ" $! (v :: vs)). iSplit; [naive_solver|]. iSplitL "Hl HSl". - iFrame "Hl". by rewrite loc_add_assoc Z.add_1_r -Nat2Z.inj_succ. - iEval (rewrite /= Nat.add_0_r; setoid_rewrite Nat.add_succ_r). iFrame. Qed. Lemma wp_array_init stk E n f : (0 < n)%Z → {{{ [∗ list] i ∈ seq 0 (Z.to_nat n), WP f #(i : nat) @ stk; E {{ Q i }} }}} array_init #n f @ stk; E {{{ l vs, RET #l; ⌜Z.of_nat (length vs) = n⌝ ∗ l ↦∗ vs ∗ [∗ list] k↦v ∈ vs, Q k v }}}. Proof. iIntros (Hn Φ) "Hf HΦ". wp_lam. wp_alloc l as "Hl"; first done. wp_smart_apply (wp_array_init_loop _ _ _ 0 n (Z.to_nat n) with "[Hl $Hf] [HΦ]"). { by rewrite /= Z2Nat.id; last lia. } { by rewrite loc_add_0. } iIntros "!>" (vs). iDestruct 1 as (Hlen) "[Hl Hvs]". wp_pures. iApply ("HΦ" $! _ vs). iModIntro. iSplit. { iPureIntro. by rewrite Hlen Z2Nat.id; last lia. } rewrite loc_add_0. iFrame. Qed. Lemma twp_array_init stk E n f : (0 < n)%Z → [[{ [∗ list] i ∈ seq 0 (Z.to_nat n), WP f #(i : nat) @ stk; E [{ Q i }] }]] array_init #n f @ stk; E [[{ l vs, RET #l; ⌜Z.of_nat (length vs) = n⌝ ∗ l ↦∗ vs ∗ [∗ list] k↦v ∈ vs, Q k v }]]. Proof. iIntros (Hn Φ) "Hf HΦ". wp_lam. wp_alloc l as "Hl"; first done. wp_smart_apply (twp_array_init_loop _ _ _ 0 n (Z.to_nat n) with "[Hl $Hf] [HΦ]"). { by rewrite /= Z2Nat.id; last lia. } { by rewrite loc_add_0. } iIntros (vs). iDestruct 1 as (Hlen) "[Hl Hvs]". wp_pures. iApply ("HΦ" $! _ vs). iModIntro. iSplit. { iPureIntro. by rewrite Hlen Z2Nat.id; last lia. } rewrite loc_add_0. iFrame. Qed. End array_init. Section array_init_fmap. Context {A} (g : A → val) (Q : nat → A → iProp Σ). Implicit Types (xs : list A) (f : val). Local Lemma big_sepL_exists_eq vs : ([∗ list] k↦v ∈ vs, ∃ x, ⌜v = g x⌝ ∗ Q k x) -∗ ∃ xs, ⌜ vs = g <$> xs ⌝ ∗ [∗ list] k↦x ∈ xs, Q k x. Proof. iIntros "Hvs". iInduction vs as [|v vs] "IH" forall (Q); simpl. { iExists []. by auto. } iDestruct "Hvs" as "[Hv Hvs]"; iDestruct "Hv" as (x ->) "Hv". iDestruct ("IH" with "Hvs") as (xs ->) "Hxs". iExists (x :: xs). by iFrame. Qed. Lemma wp_array_init_fmap stk E n f : (0 < n)%Z → {{{ [∗ list] i ∈ seq 0 (Z.to_nat n), WP f #(i : nat) @ stk; E {{ v, ∃ x, ⌜v = g x⌝ ∗ Q i x }} }}} array_init #n f @ stk; E {{{ l xs, RET #l; ⌜Z.of_nat (length xs) = n⌝ ∗ l ↦∗ (g <$> xs) ∗ [∗ list] k↦x ∈ xs, Q k x }}}. Proof. iIntros (Hn Φ) "Hf HΦ". iApply (wp_array_init with "Hf"); first done. iIntros "!>" (l vs). iDestruct 1 as (<-) "[Hl Hvs]". iDestruct (big_sepL_exists_eq with "Hvs") as (xs ->) "Hxs". iApply "HΦ". iFrame "Hl Hxs". by rewrite fmap_length. Qed. Lemma twp_array_init_fmap stk E n f : (0 < n)%Z → [[{ [∗ list] i ∈ seq 0 (Z.to_nat n), WP f #(i : nat) @ stk; E [{ v, ∃ x, ⌜v = g x⌝ ∗ Q i x }] }]] array_init #n f @ stk; E [[{ l xs, RET #l; ⌜Z.of_nat (length xs) = n⌝ ∗ l ↦∗ (g <$> xs) ∗ [∗ list] k↦x ∈ xs, Q k x }]]. Proof. iIntros (Hn Φ) "Hf HΦ". iApply (twp_array_init with "Hf"); first done. iIntros (l vs). iDestruct 1 as (<-) "[Hl Hvs]". iDestruct (big_sepL_exists_eq with "Hvs") as (xs ->) "Hxs". iApply "HΦ". iFrame "Hl Hxs". by rewrite fmap_length. Qed. End array_init_fmap. End proof.
/- Copyright (c) 2021 Paul Lezeau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anne Baanen, Paul Lezeau ! This file was ported from Lean 3 source module ring_theory.chain_of_divisors ! leanprover-community/mathlib commit f694c7dead66f5d4c80f446c796a5aad14707f0e ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathbin.Algebra.IsPrimePow import Mathbin.Algebra.Squarefree import Mathbin.Order.Hom.Bounded import Mathbin.Algebra.GcdMonoid.Basic /-! # Chains of divisors The results in this file show that in the monoid `associates M` of a `unique_factorization_monoid` `M`, an element `a` is an n-th prime power iff its set of divisors is a strictly increasing chain of length `n + 1`, meaning that we can find a strictly increasing bijection between `fin (n + 1)` and the set of factors of `a`. ## Main results - `divisor_chain.exists_chain_of_prime_pow` : existence of a chain for prime powers. - `divisor_chain.is_prime_pow_of_has_chain` : elements that have a chain are prime powers. - `multiplicity_prime_eq_multiplicity_image_by_factor_order_iso` : if there is a monotone bijection `d` between the set of factors of `a : associates M` and the set of factors of `b : associates N` then for any prime `p ∣ a`, `multiplicity p a = multiplicity (d p) b`. - `multiplicity_eq_multiplicity_factor_dvd_iso_of_mem_normalized_factor` : if there is a bijection between the set of factors of `a : M` and `b : N` then for any prime `p ∣ a`, `multiplicity p a = multiplicity (d p) b` ## Todo - Create a structure for chains of divisors. - Simplify proof of `mem_normalized_factors_factor_dvd_iso_of_mem_normalized_factors` using `mem_normalized_factors_factor_order_iso_of_mem_normalized_factors` or vice versa. -/ variable {M : Type _} [CancelCommMonoidWithZero M] theorem Associates.isAtom_iff {p : Associates M} (h₁ : p ≠ 0) : IsAtom p ↔ Irreducible p := ⟨fun hp => ⟨by simpa only [Associates.isUnit_iff_eq_one] using hp.1, fun a b h => (hp.le_iff.mp ⟨_, h⟩).casesOn (fun ha => Or.inl (a.isUnit_iff_eq_one.mpr ha)) fun ha => Or.inr (show IsUnit b by rw [ha] at h apply isUnit_of_associated_mul (show Associated (p * b) p by conv_rhs => rw [h]) h₁)⟩, fun hp => ⟨by simpa only [Associates.isUnit_iff_eq_one, Associates.bot_eq_one] using hp.1, fun b ⟨⟨a, hab⟩, hb⟩ => (hp.isUnit_or_isUnit hab).casesOn (fun hb => show b = ⊥ by rwa [Associates.isUnit_iff_eq_one, ← Associates.bot_eq_one] at hb) fun ha => absurd (show p ∣ b from ⟨(ha.Unit⁻¹ : Units _), by simp [hab] <;> rw [mul_assoc] <;> rw [IsUnit.mul_val_inv ha] <;> rw [mul_one]⟩) hb⟩⟩ #align associates.is_atom_iff Associates.isAtom_iff open UniqueFactorizationMonoid multiplicity Irreducible Associates namespace DivisorChain theorem exists_chain_of_prime_pow {p : Associates M} {n : ℕ} (hn : n ≠ 0) (hp : Prime p) : ∃ c : Fin (n + 1) → Associates M, c 1 = p ∧ StrictMono c ∧ ∀ {r : Associates M}, r ≤ p ^ n ↔ ∃ i, r = c i := by refine' ⟨fun i => p ^ (i : ℕ), _, fun n m h => _, fun y => ⟨fun h => _, _⟩⟩ · rw [Fin.val_one', Nat.mod_eq_of_lt, pow_one] exact Nat.lt_succ_of_le (nat.one_le_iff_ne_zero.mpr hn) · exact associates.dvd_not_unit_iff_lt.mp ⟨pow_ne_zero n hp.ne_zero, p ^ (m - n : ℕ), not_isUnit_of_not_isUnit_dvd hp.not_unit (dvd_pow dvd_rfl (Nat.sub_pos_of_lt h).ne'), (pow_mul_pow_sub p h.le).symm⟩ · obtain ⟨i, i_le, hi⟩ := (dvd_prime_pow hp n).1 h rw [associated_iff_eq] at hi exact ⟨⟨i, Nat.lt_succ_of_le i_le⟩, hi⟩ · rintro ⟨i, rfl⟩ exact ⟨p ^ (n - i : ℕ), (pow_mul_pow_sub p (nat.succ_le_succ_iff.mp i.2)).symm⟩ #align divisor_chain.exists_chain_of_prime_pow DivisorChain.exists_chain_of_prime_pow theorem element_of_chain_not_isUnit_of_index_ne_zero {n : ℕ} {i : Fin (n + 1)} (i_pos : i ≠ 0) {c : Fin (n + 1) → Associates M} (h₁ : StrictMono c) : ¬IsUnit (c i) := DvdNotUnit.not_unit (Associates.dvdNotUnit_iff_lt.2 (h₁ <| show (0 : Fin (n + 1)) < i from i.pos_iff_ne_zero.mpr i_pos)) #align divisor_chain.element_of_chain_not_is_unit_of_index_ne_zero DivisorChain.element_of_chain_not_isUnit_of_index_ne_zero theorem first_of_chain_isUnit {q : Associates M} {n : ℕ} {c : Fin (n + 1) → Associates M} (h₁ : StrictMono c) (h₂ : ∀ {r}, r ≤ q ↔ ∃ i, r = c i) : IsUnit (c 0) := by obtain ⟨i, hr⟩ := h₂.mp Associates.one_le rw [Associates.isUnit_iff_eq_one, ← Associates.le_one_iff, hr] exact h₁.monotone (Fin.zero_le i) #align divisor_chain.first_of_chain_is_unit DivisorChain.first_of_chain_isUnit /-- The second element of a chain is irreducible. -/ theorem second_of_chain_is_irreducible {q : Associates M} {n : ℕ} (hn : n ≠ 0) {c : Fin (n + 1) → Associates M} (h₁ : StrictMono c) (h₂ : ∀ {r}, r ≤ q ↔ ∃ i, r = c i) (hq : q ≠ 0) : Irreducible (c 1) := by cases n; · contradiction refine' (Associates.isAtom_iff (ne_zero_of_dvd_ne_zero hq (h₂.2 ⟨1, rfl⟩))).mp ⟨_, fun b hb => _⟩ · exact ne_bot_of_gt (h₁ (show (0 : Fin (n + 2)) < 1 from Fin.one_pos)) obtain ⟨⟨i, hi⟩, rfl⟩ := h₂.1 (hb.le.trans (h₂.2 ⟨1, rfl⟩)) cases i · exact (Associates.isUnit_iff_eq_one _).mp (first_of_chain_is_unit h₁ @h₂) · simpa [Fin.lt_iff_val_lt_val] using h₁.lt_iff_lt.mp hb #align divisor_chain.second_of_chain_is_irreducible DivisorChain.second_of_chain_is_irreducible theorem eq_second_of_chain_of_prime_dvd {p q r : Associates M} {n : ℕ} (hn : n ≠ 0) {c : Fin (n + 1) → Associates M} (h₁ : StrictMono c) (h₂ : ∀ {r : Associates M}, r ≤ q ↔ ∃ i, r = c i) (hp : Prime p) (hr : r ∣ q) (hp' : p ∣ r) : p = c 1 := by cases n · contradiction obtain ⟨i, rfl⟩ := h₂.1 (dvd_trans hp' hr) refine' congr_arg c (eq_of_ge_of_not_gt _ fun hi => _) · rw [Fin.le_iff_val_le_val, Fin.val_one, Nat.succ_le_iff, ← Fin.val_zero (n.succ + 1), ← Fin.lt_iff_val_lt_val, Fin.pos_iff_ne_zero] rintro rfl exact hp.not_unit (first_of_chain_is_unit h₁ @h₂) obtain rfl | ⟨j, rfl⟩ := i.eq_zero_or_eq_succ · cases hi refine' not_irreducible_of_not_unit_dvdNotUnit (DvdNotUnit.not_unit (Associates.dvdNotUnit_iff_lt.2 (h₁ (show (0 : Fin (n + 2)) < j from _)))) _ hp.irreducible · simpa [Fin.succ_lt_succ_iff, Fin.lt_iff_val_lt_val] using hi · refine' Associates.dvdNotUnit_iff_lt.2 (h₁ _) simpa only [Fin.coe_eq_castSucc] using Fin.lt_succ #align divisor_chain.eq_second_of_chain_of_prime_dvd DivisorChain.eq_second_of_chain_of_prime_dvd theorem card_subset_divisors_le_length_of_chain {q : Associates M} {n : ℕ} {c : Fin (n + 1) → Associates M} (h₂ : ∀ {r}, r ≤ q ↔ ∃ i, r = c i) {m : Finset (Associates M)} (hm : ∀ r, r ∈ m → r ≤ q) : m.card ≤ n + 1 := by classical have mem_image : ∀ r : Associates M, r ≤ q → r ∈ finset.univ.image c := by intro r hr obtain ⟨i, hi⟩ := h₂.1 hr exact Finset.mem_image.2 ⟨i, Finset.mem_univ _, hi.symm⟩ rw [← Finset.card_fin (n + 1)] exact (Finset.card_le_of_subset fun x hx => mem_image x <| hm x hx).trans Finset.card_image_le #align divisor_chain.card_subset_divisors_le_length_of_chain DivisorChain.card_subset_divisors_le_length_of_chain variable [UniqueFactorizationMonoid M] theorem element_of_chain_eq_pow_second_of_chain {q r : Associates M} {n : ℕ} (hn : n ≠ 0) {c : Fin (n + 1) → Associates M} (h₁ : StrictMono c) (h₂ : ∀ {r}, r ≤ q ↔ ∃ i, r = c i) (hr : r ∣ q) (hq : q ≠ 0) : ∃ i : Fin (n + 1), r = c 1 ^ (i : ℕ) := by classical let i := (normalized_factors r).card have hi : normalized_factors r = Multiset.replicate i (c 1) := by apply Multiset.eq_replicate_of_mem intro b hb refine' eq_second_of_chain_of_prime_dvd hn h₁ (fun r' => h₂) (prime_of_normalized_factor b hb) hr (dvd_of_mem_normalized_factors hb) have H : r = c 1 ^ i := by have := UniqueFactorizationMonoid.normalizedFactors_prod (ne_zero_of_dvd_ne_zero hq hr) rw [associated_iff_eq, hi, Multiset.prod_replicate] at this rw [this] refine' ⟨⟨i, _⟩, H⟩ have : (finset.univ.image fun m : Fin (i + 1) => c 1 ^ (m : ℕ)).card = i + 1 := by conv_rhs => rw [← Finset.card_fin (i + 1)] cases n · contradiction rw [Finset.card_image_iff] refine' Set.injOn_of_injective (fun m m' h => Fin.ext _) _ refine' pow_injective_of_not_unit (element_of_chain_not_is_unit_of_index_ne_zero (by simp) h₁) _ h exact Irreducible.ne_zero (second_of_chain_is_irreducible hn h₁ (@h₂) hq) suffices H' : ∀ r ∈ finset.univ.image fun m : Fin (i + 1) => c 1 ^ (m : ℕ), r ≤ q · simp only [← Nat.succ_le_iff, Nat.succ_eq_add_one, ← this] apply card_subset_divisors_le_length_of_chain (@h₂) H' simp only [Finset.mem_image] rintro r ⟨a, ha, rfl⟩ refine' dvd_trans _ hr use c 1 ^ (i - a) rw [pow_mul_pow_sub (c 1)] · exact H · exact nat.succ_le_succ_iff.mp a.2 #align divisor_chain.element_of_chain_eq_pow_second_of_chain DivisorChain.element_of_chain_eq_pow_second_of_chain theorem eq_pow_second_of_chain_of_has_chain {q : Associates M} {n : ℕ} (hn : n ≠ 0) {c : Fin (n + 1) → Associates M} (h₁ : StrictMono c) (h₂ : ∀ {r : Associates M}, r ≤ q ↔ ∃ i, r = c i) (hq : q ≠ 0) : q = c 1 ^ n := by classical obtain ⟨i, hi'⟩ := element_of_chain_eq_pow_second_of_chain hn h₁ (fun r => h₂) (dvd_refl q) hq convert hi' refine' (Nat.lt_succ_iff.1 i.prop).antisymm' (Nat.le_of_succ_le_succ _) calc n + 1 = (Finset.univ : Finset (Fin (n + 1))).card := (Finset.card_fin _).symm _ = (finset.univ.image c).card := (finset.card_image_iff.mpr (h₁.injective.inj_on _)).symm _ ≤ (finset.univ.image fun m : Fin (i + 1) => c 1 ^ (m : ℕ)).card := (Finset.card_le_of_subset _) _ ≤ (Finset.univ : Finset (Fin (i + 1))).card := Finset.card_image_le _ = i + 1 := Finset.card_fin _ intro r hr obtain ⟨j, -, rfl⟩ := Finset.mem_image.1 hr have := h₂.2 ⟨j, rfl⟩ rw [hi'] at this obtain ⟨u, hu, hu'⟩ := (dvd_prime_pow (show Prime (c 1) from _) i).1 this refine' finset.mem_image.mpr ⟨u, Finset.mem_univ _, _⟩ · rw [associated_iff_eq] at hu' rw [Fin.val_cast_of_lt (Nat.lt_succ_of_le hu), hu'] · rw [← irreducible_iff_prime] exact second_of_chain_is_irreducible hn h₁ (@h₂) hq #align divisor_chain.eq_pow_second_of_chain_of_has_chain DivisorChain.eq_pow_second_of_chain_of_has_chain theorem isPrimePow_of_has_chain {q : Associates M} {n : ℕ} (hn : n ≠ 0) {c : Fin (n + 1) → Associates M} (h₁ : StrictMono c) (h₂ : ∀ {r : Associates M}, r ≤ q ↔ ∃ i, r = c i) (hq : q ≠ 0) : IsPrimePow q := ⟨c 1, n, irreducible_iff_prime.mp (second_of_chain_is_irreducible hn h₁ (@h₂) hq), zero_lt_iff.mpr hn, (eq_pow_second_of_chain_of_has_chain hn h₁ (@h₂) hq).symm⟩ #align divisor_chain.is_prime_pow_of_has_chain DivisorChain.isPrimePow_of_has_chain end DivisorChain variable {N : Type _} [CancelCommMonoidWithZero N] theorem factor_orderIso_map_one_eq_bot {m : Associates M} {n : Associates N} (d : { l : Associates M // l ≤ m } ≃o { l : Associates N // l ≤ n }) : (d ⟨1, one_dvd m⟩ : Associates N) = 1 := by letI : OrderBot { l : Associates M // l ≤ m } := Subtype.orderBot bot_le letI : OrderBot { l : Associates N // l ≤ n } := Subtype.orderBot bot_le simp [← Associates.bot_eq_one] #align factor_order_iso_map_one_eq_bot factor_orderIso_map_one_eq_bot theorem coe_factor_orderIso_map_eq_one_iff {m u : Associates M} {n : Associates N} (hu' : u ≤ m) (d : Set.Iic m ≃o Set.Iic n) : (d ⟨u, hu'⟩ : Associates N) = 1 ↔ u = 1 := ⟨fun hu => by rw [show u = ↑(d.symm ⟨↑(d ⟨u, hu'⟩), (d ⟨u, hu'⟩).Prop⟩) by simp only [Subtype.coe_eta, OrderIso.symm_apply_apply, Subtype.coe_mk]] convert factor_orderIso_map_one_eq_bot d.symm, fun hu => by simp_rw [hu] convert factor_orderIso_map_one_eq_bot d⟩ #align coe_factor_order_iso_map_eq_one_iff coe_factor_orderIso_map_eq_one_iff section variable [UniqueFactorizationMonoid N] [UniqueFactorizationMonoid M] open DivisorChain theorem pow_image_of_prime_by_factor_orderIso_dvd [DecidableEq (Associates M)] {m p : Associates M} {n : Associates N} (hn : n ≠ 0) (hp : p ∈ normalizedFactors m) (d : Set.Iic m ≃o Set.Iic n) {s : ℕ} (hs' : p ^ s ≤ m) : (d ⟨p, dvd_of_mem_normalizedFactors hp⟩ : Associates N) ^ s ≤ n := by by_cases hs : s = 0 · simp [hs] suffices (d ⟨p, dvd_of_mem_normalized_factors hp⟩ : Associates N) ^ s = ↑(d ⟨p ^ s, hs'⟩) by rw [this] apply Subtype.prop (d ⟨p ^ s, hs'⟩) obtain ⟨c₁, rfl, hc₁', hc₁''⟩ := exists_chain_of_prime_pow hs (prime_of_normalized_factor p hp) set c₂ : Fin (s + 1) → Associates N := fun t => d ⟨c₁ t, le_trans (hc₁''.2 ⟨t, by simp⟩) hs'⟩ have c₂.def : ∀ t, c₂ t = d ⟨c₁ t, _⟩ := fun t => rfl refine' (congr_arg (· ^ s) (c₂.def 1).symm).trans _ refine' (eq_pow_second_of_chain_of_has_chain hs (fun t u h => _) (fun r => ⟨fun hr => _, _⟩) _).symm · rw [c₂.def, c₂.def, Subtype.coe_lt_coe, d.lt_iff_lt, Subtype.mk_lt_mk, hc₁'.lt_iff_lt] exact h · have : r ≤ n := hr.trans (d ⟨c₁ 1 ^ s, _⟩).2 suffices d.symm ⟨r, this⟩ ≤ ⟨c₁ 1 ^ s, hs'⟩ by obtain ⟨i, hi⟩ := hc₁''.1 this use i simp only [c₂.def, ← hi, d.apply_symm_apply, Subtype.coe_eta, Subtype.coe_mk] conv_rhs => rw [← d.symm_apply_apply ⟨c₁ 1 ^ s, hs'⟩] rw [d.symm.le_iff_le] simpa only [← Subtype.coe_le_coe, Subtype.coe_mk] using hr · rintro ⟨i, hr⟩ rw [hr, c₂.def, Subtype.coe_le_coe, d.le_iff_le] simpa [Subtype.mk_le_mk] using hc₁''.2 ⟨i, rfl⟩ exact ne_zero_of_dvd_ne_zero hn (Subtype.prop (d ⟨c₁ 1 ^ s, _⟩)) #align pow_image_of_prime_by_factor_order_iso_dvd pow_image_of_prime_by_factor_orderIso_dvd theorem map_prime_of_factor_orderIso [DecidableEq (Associates M)] {m p : Associates M} {n : Associates N} (hn : n ≠ 0) (hp : p ∈ normalizedFactors m) (d : Set.Iic m ≃o Set.Iic n) : Prime (d ⟨p, dvd_of_mem_normalizedFactors hp⟩ : Associates N) := by rw [← irreducible_iff_prime] refine' (Associates.isAtom_iff <| ne_zero_of_dvd_ne_zero hn (d ⟨p, _⟩).Prop).mp ⟨_, fun b hb => _⟩ · rw [Ne.def, ← Associates.isUnit_iff_eq_bot, Associates.isUnit_iff_eq_one, coe_factor_orderIso_map_eq_one_iff _ d] rintro rfl exact (prime_of_normalized_factor 1 hp).not_unit isUnit_one · obtain ⟨x, hx⟩ := d.surjective ⟨b, le_trans (le_of_lt hb) (d ⟨p, dvd_of_mem_normalized_factors hp⟩).Prop⟩ rw [← Subtype.coe_mk b _, Subtype.coe_lt_coe, ← hx] at hb letI : OrderBot { l : Associates M // l ≤ m } := Subtype.orderBot bot_le letI : OrderBot { l : Associates N // l ≤ n } := Subtype.orderBot bot_le suffices x = ⊥ by rw [this, OrderIso.map_bot d] at hx refine' (Subtype.mk_eq_bot_iff _ _).mp hx.symm exact bot_le obtain ⟨a, ha⟩ := x rw [Subtype.mk_eq_bot_iff] · exact ((Associates.isAtom_iff <| Prime.ne_zero <| prime_of_normalized_factor p hp).mpr <| irreducible_of_normalized_factor p hp).right a (subtype.mk_lt_mk.mp <| d.lt_iff_lt.mp hb) exact bot_le #align map_prime_of_factor_order_iso map_prime_of_factor_orderIso theorem mem_normalizedFactors_factor_orderIso_of_mem_normalizedFactors [DecidableEq (Associates M)] [DecidableEq (Associates N)] {m p : Associates M} {n : Associates N} (hn : n ≠ 0) (hp : p ∈ normalizedFactors m) (d : Set.Iic m ≃o Set.Iic n) : ↑(d ⟨p, dvd_of_mem_normalizedFactors hp⟩) ∈ normalizedFactors n := by obtain ⟨q, hq, hq'⟩ := exists_mem_normalized_factors_of_dvd hn (map_prime_of_factor_orderIso hn hp d).Irreducible (d ⟨p, dvd_of_mem_normalized_factors hp⟩).Prop rw [associated_iff_eq] at hq' rwa [hq'] #align mem_normalized_factors_factor_order_iso_of_mem_normalized_factors mem_normalizedFactors_factor_orderIso_of_mem_normalizedFactors variable [DecidableRel ((· ∣ ·) : M → M → Prop)] [DecidableRel ((· ∣ ·) : N → N → Prop)] theorem multiplicity_prime_le_multiplicity_image_by_factor_orderIso [DecidableEq (Associates M)] {m p : Associates M} {n : Associates N} (hp : p ∈ normalizedFactors m) (d : Set.Iic m ≃o Set.Iic n) : multiplicity p m ≤ multiplicity (↑(d ⟨p, dvd_of_mem_normalizedFactors hp⟩)) n := by by_cases hn : n = 0 · simp [hn] by_cases hm : m = 0 · simpa [hm] using hp rw [← PartENat.natCast_get (finite_iff_dom.1 <| finite_prime_left (prime_of_normalized_factor p hp) hm), ← pow_dvd_iff_le_multiplicity] exact pow_image_of_prime_by_factor_orderIso_dvd hn hp d (pow_multiplicity_dvd _) #align multiplicity_prime_le_multiplicity_image_by_factor_order_iso multiplicity_prime_le_multiplicity_image_by_factor_orderIso theorem multiplicity_prime_eq_multiplicity_image_by_factor_orderIso [DecidableEq (Associates M)] {m p : Associates M} {n : Associates N} (hn : n ≠ 0) (hp : p ∈ normalizedFactors m) (d : Set.Iic m ≃o Set.Iic n) : multiplicity p m = multiplicity (↑(d ⟨p, dvd_of_mem_normalizedFactors hp⟩)) n := by refine' le_antisymm (multiplicity_prime_le_multiplicity_image_by_factor_orderIso hp d) _ suffices multiplicity (↑(d ⟨p, dvd_of_mem_normalized_factors hp⟩)) n ≤ multiplicity (↑(d.symm (d ⟨p, dvd_of_mem_normalized_factors hp⟩))) m by rw [d.symm_apply_apply ⟨p, dvd_of_mem_normalized_factors hp⟩, Subtype.coe_mk] at this exact this letI := Classical.decEq (Associates N) simpa only [Subtype.coe_eta] using multiplicity_prime_le_multiplicity_image_by_factor_orderIso (mem_normalizedFactors_factor_orderIso_of_mem_normalizedFactors hn hp d) d.symm #align multiplicity_prime_eq_multiplicity_image_by_factor_order_iso multiplicity_prime_eq_multiplicity_image_by_factor_orderIso end variable [Unique Mˣ] [Unique Nˣ] /-- The order isomorphism between the factors of `mk m` and the factors of `mk n` induced by a bijection between the factors of `m` and the factors of `n` that preserves `∣`. -/ @[simps] def mkFactorOrderIsoOfFactorDvdEquiv {m : M} {n : N} {d : { l : M // l ∣ m } ≃ { l : N // l ∣ n }} (hd : ∀ l l', (d l : N) ∣ d l' ↔ (l : M) ∣ (l' : M)) : Set.Iic (Associates.mk m) ≃o Set.Iic (Associates.mk n) where toFun l := ⟨Associates.mk (d ⟨associatesEquivOfUniqueUnits ↑l, by obtain ⟨x, hx⟩ := l rw [Subtype.coe_mk, associatesEquivOfUniqueUnits_apply, out_dvd_iff] exact hx⟩), mk_le_mk_iff_dvd_iff.mpr (Subtype.prop (d ⟨associatesEquivOfUniqueUnits ↑l, _⟩))⟩ invFun l := ⟨Associates.mk (d.symm ⟨associatesEquivOfUniqueUnits ↑l, by obtain ⟨x, hx⟩ := l <;> rw [Subtype.coe_mk, associatesEquivOfUniqueUnits_apply, out_dvd_iff] <;> exact hx⟩), mk_le_mk_iff_dvd_iff.mpr (Subtype.prop (d.symm ⟨associatesEquivOfUniqueUnits ↑l, _⟩))⟩ left_inv := fun ⟨l, hl⟩ => by simp only [Subtype.coe_eta, Equiv.symm_apply_apply, Subtype.coe_mk, associatesEquivOfUniqueUnits_apply, mk_out, out_mk, normalize_eq] right_inv := fun ⟨l, hl⟩ => by simp only [Subtype.coe_eta, Equiv.apply_symm_apply, Subtype.coe_mk, associatesEquivOfUniqueUnits_apply, out_mk, normalize_eq, mk_out] map_rel_iff' := by rintro ⟨a, ha⟩ ⟨b, hb⟩ <;> simp only [Equiv.coe_fn_mk, Subtype.mk_le_mk, Associates.mk_le_mk_iff_dvd_iff, hd, Subtype.coe_mk, associatesEquivOfUniqueUnits_apply, out_dvd_iff, mk_out] #align mk_factor_order_iso_of_factor_dvd_equiv mkFactorOrderIsoOfFactorDvdEquiv variable [UniqueFactorizationMonoid M] [UniqueFactorizationMonoid N] [DecidableEq M] theorem mem_normalizedFactors_factor_dvd_iso_of_mem_normalizedFactors [DecidableEq N] {m p : M} {n : N} (hm : m ≠ 0) (hn : n ≠ 0) (hp : p ∈ normalizedFactors m) {d : { l : M // l ∣ m } ≃ { l : N // l ∣ n }} (hd : ∀ l l', (d l : N) ∣ d l' ↔ (l : M) ∣ (l' : M)) : ↑(d ⟨p, dvd_of_mem_normalizedFactors hp⟩) ∈ normalizedFactors n := by suffices Prime ↑(d ⟨associatesEquivOfUniqueUnits (associates_equiv_of_unique_units.symm p), by simp [dvd_of_mem_normalized_factors hp]⟩) by simp only [associatesEquivOfUniqueUnits_apply, out_mk, normalize_eq, associatesEquivOfUniqueUnits_symm_apply] at this obtain ⟨q, hq, hq'⟩ := exists_mem_normalized_factors_of_dvd hn this.irreducible (d ⟨p, by apply dvd_of_mem_normalized_factors <;> convert hp⟩).Prop rwa [associated_iff_eq.mp hq'] have : Associates.mk ↑(d ⟨associatesEquivOfUniqueUnits (associates_equiv_of_unique_units.symm p), by simp only [dvd_of_mem_normalized_factors hp, associatesEquivOfUniqueUnits_apply, out_mk, normalize_eq, associatesEquivOfUniqueUnits_symm_apply]⟩) = ↑(mkFactorOrderIsoOfFactorDvdEquiv hd ⟨associates_equiv_of_unique_units.symm p, by simp only [associatesEquivOfUniqueUnits_symm_apply] <;> exact mk_dvd_mk.mpr (dvd_of_mem_normalized_factors hp)⟩) := by rw [mkFactorOrderIsoOfFactorDvdEquiv_apply_coe] simp only [Subtype.coe_mk] rw [← Associates.prime_mk, this] letI := Classical.decEq (Associates M) refine' map_prime_of_factor_orderIso (mk_ne_zero.mpr hn) _ _ obtain ⟨q, hq, hq'⟩ := exists_mem_normalized_factors_of_dvd (mk_ne_zero.mpr hm) ((prime_mk p).mpr (prime_of_normalized_factor p (by convert hp))).Irreducible (mk_le_mk_of_dvd (dvd_of_mem_normalized_factors hp)) simpa only [associated_iff_eq.mp hq', associatesEquivOfUniqueUnits_symm_apply] using hq #align mem_normalized_factors_factor_dvd_iso_of_mem_normalized_factors mem_normalizedFactors_factor_dvd_iso_of_mem_normalizedFactors variable [DecidableRel ((· ∣ ·) : M → M → Prop)] [DecidableRel ((· ∣ ·) : N → N → Prop)] theorem multiplicity_factor_dvd_iso_eq_multiplicity_of_mem_normalized_factor {m p : M} {n : N} (hm : m ≠ 0) (hn : n ≠ 0) (hp : p ∈ normalizedFactors m) {d : { l : M // l ∣ m } ≃ { l : N // l ∣ n }} (hd : ∀ l l', (d l : N) ∣ d l' ↔ (l : M) ∣ l') : multiplicity (d ⟨p, dvd_of_mem_normalizedFactors hp⟩ : N) n = multiplicity p m := by apply Eq.symm suffices multiplicity (Associates.mk p) (Associates.mk m) = multiplicity (Associates.mk ↑(d ⟨associatesEquivOfUniqueUnits (associates_equiv_of_unique_units.symm p), by simp [dvd_of_mem_normalized_factors hp]⟩)) (Associates.mk n) by simpa only [multiplicity_mk_eq_multiplicity, associatesEquivOfUniqueUnits_symm_apply, associatesEquivOfUniqueUnits_apply, out_mk, normalize_eq] using this have : Associates.mk ↑(d ⟨associatesEquivOfUniqueUnits (associates_equiv_of_unique_units.symm p), by simp only [dvd_of_mem_normalized_factors hp, associatesEquivOfUniqueUnits_symm_apply, associatesEquivOfUniqueUnits_apply, out_mk, normalize_eq]⟩) = ↑(mkFactorOrderIsoOfFactorDvdEquiv hd ⟨associates_equiv_of_unique_units.symm p, by rw [associatesEquivOfUniqueUnits_symm_apply] <;> exact mk_le_mk_of_dvd (dvd_of_mem_normalized_factors hp)⟩) := by rw [mkFactorOrderIsoOfFactorDvdEquiv_apply_coe] rfl rw [this] letI := Classical.decEq (Associates M) refine' multiplicity_prime_eq_multiplicity_image_by_factor_orderIso (mk_ne_zero.mpr hn) _ (mkFactorOrderIsoOfFactorDvdEquiv hd) obtain ⟨q, hq, hq'⟩ := exists_mem_normalized_factors_of_dvd (mk_ne_zero.mpr hm) ((prime_mk p).mpr (prime_of_normalized_factor p hp)).Irreducible (mk_le_mk_of_dvd (dvd_of_mem_normalized_factors hp)) rwa [associated_iff_eq.mp hq'] #align multiplicity_factor_dvd_iso_eq_multiplicity_of_mem_normalized_factor multiplicity_factor_dvd_iso_eq_multiplicity_of_mem_normalized_factor
{-# Language DerivingVia #-} {-# Language FlexibleInstances #-} {-# Language GeneralizedNewtypeDeriving #-} {-# Language MultiParamTypeClasses #-} {-# Language UndecidableInstances #-} module Geometry.Testing ( DInt (..) , Parameter (..) , Position (..) , AnyPoint (..) , AnyCircle (..) , AnyAngle (..) , AnyLine (..) , AnyRay (..) , AnySegment (..) , Motion (..), appMotion , Nontrivial (..) , NonDegenerate (..) , (<==>) ) where import Data.Complex import Data.Foldable import Data.Monoid import Test.QuickCheck hiding (scale) import Test.QuickCheck.Modifiers import Data.Tuple.Extra (second) import Geometry import Geometry.Circle (mkCircle) import Geometry.Base (roundUp) infix 0 <==> a <==> b = (a ==> b) .&&. (b ==> a) ------------------------------------------------------------ {- | A type for an interger double number. >>> sample (arbitrary :: Gen DInt) DInt 0.0 DInt 2.0 DInt 0.0 DInt (-1.0) DInt 7.0 ... -} newtype DInt = DInt Double deriving Show instance Arbitrary DInt where arbitrary = DInt . fromIntegral <$> (arbitrary :: Gen Int) shrink (DInt l) = DInt <$> shrink l {- | A type for a double number parameterizing the `Manifold`. >>> sample (arbitrary :: Gen Parameter) Parameter 0.6977012699848539 Parameter 0.5321234247634057 Parameter 9.832672492232597e-2 Parameter 0.9510866292762408 ... -} newtype Parameter = Parameter { getParameter :: Double} deriving Show instance Arbitrary Parameter where arbitrary = Parameter <$> choose (0, 1) shrink (Parameter l) = Parameter <$> shrink l ------------------------------------------------------------ {- | A type for an affine position (`XY`, `Cmp`, `Point` etc). >>> sample (arbitrary :: Gen (Position XY)) Position (0.0,0.0) Position (-1.0,2.0) Position (-3.0,3.0) Position (6.0,4.0) Position (-1.0,-1.0 ... -} newtype Position a = Position a deriving (Show, Affine, Trans, Metric, Eq) instance (Eq a, Pnt a, Arbitrary a) => Arbitrary (Position a) where arbitrary = Position . roundUp 1 <$> arbitrary shrink = shrinkPos 0.5 shrinkPos :: (Eq a, Affine a, Metric a) => Double -> a -> [a] shrinkPos d x = res where res = filter (/= x) $ map (roundUp d) $ takeWhile (\p -> distance x p >= d/2) $ map (\s -> asCmp $ (1 - s) * cmp x) $ iterate (/2) 1 ------------------------------------------------------------ instance Arbitrary Direction where arbitrary = oneof [asDeg <$> arbitrary, asCmp <$> arbitrary] shrink = shrinkPos 1 ------------------------------------------------------------ instance Arbitrary Point where arbitrary = Point <$> arbitrary shrink = shrinkPos 1 {- | A wrapper for a `Point`. -} newtype AnyPoint = AnyPoint Point deriving (Show, Arbitrary) ------------------------------------------------------------ instance Arbitrary Circle where arbitrary = do (Position c) <- arbitrary (Position r) <- arbitrary :: Gen (Position Cmp) return (mkCircle (norm r) c # rotateAt' c (angle r)) shrink cir = do Position c <- shrink (Position (center cir)) r <- shrink (radius cir) return $ mkCircle r c {- | A wrapper for nondegenative `Circle`. -} newtype AnyCircle = AnyCircle Circle deriving Show deriving Arbitrary via Nontrivial Circle ------------------------------------------------------------ instance Arbitrary Angle where arbitrary = do (Position p) <- arbitrary Angle p <$> arbitrary <*> arbitrary shrink an = do Position p <- shrink (Position (refPoint an)) s <- shrink (angleStart an) e <- shrink (angleEnd an) return $ Angle p s e {- | A wrapper for nontrivial `Angle`. -} newtype AnyAngle = AnyAngle Angle deriving Show deriving Arbitrary via Nontrivial Angle ------------------------------------------------------------ instance Arbitrary Segment where arbitrary = do Position p1 <- arbitrary Position p2 <- arbitrary return $ Segment (p1, p2) shrink l = let (p1, p2) = refPoints l in do Position p1' <- shrink (Position p1) Position p2' <- shrink (Position p2) return $ Segment (p1', p2') instance Arbitrary Line where arbitrary = asLine <$> (arbitrary :: Gen Segment) shrink l = asLine <$> shrink (asSegment l) instance Arbitrary Ray where arbitrary = asRay <$> (arbitrary :: Gen Segment) shrink l = asRay <$> shrink (asSegment l) {- | A wrapper for nontrivial `Line`. -} newtype AnyLine = AnyLine Line deriving Show deriving Arbitrary via Nontrivial Line {- | A wrapper for nontrivial `Ray`. -} newtype AnyRay = AnyRay Ray deriving Show deriving Arbitrary via Nontrivial Ray {- | A wrapper for nontrivial `Segment`. -} newtype AnySegment = AnySegment Segment deriving Show deriving Arbitrary via Nontrivial Segment ------------------------------------------------------------ {- | A wrapper for a motion `translate`, `rotate` or `reflect`. -} newtype Motion a = Motion (String, Endo a) appMotion :: Motion a -> a -> a appMotion (Motion (_, m)) = appEndo m instance Show (Motion a) where show (Motion (s, _)) = s instance Trans a => Arbitrary (Motion a) where arbitrary = Motion . fold <$> listOf (oneof motions) where motions = [ label "Tr " translate <$> (arbitrary :: Gen XY) , label "Rot " rotate <$> arbitrary , label "Ref " reflect <$> arbitrary ] label l t x = (l <> show x <> " ", Endo $ t x) ------------------------------------------------------------ {- | A wrapper for a nontrivial `Figure`. -} newtype Nontrivial a = Nontrivial a deriving ( Eq , Show , Figure , Affine , Trans , Curve , ClosedCurve , Manifold , PiecewiseLinear , Polygonal , APoint , Linear , Circular , Angular ) instance (Arbitrary a, Figure a) => Arbitrary (Nontrivial a) where arbitrary = Nontrivial <$> arbitrary `suchThat` isNontrivial shrink (Nontrivial l) = Nontrivial <$> filter isNontrivial (shrink l) -------------------------------------------------------------------------------- {- | A wrapper for a nondegenerate `Figure`. -} newtype NonDegenerate a = NonDegenerate a deriving ( Eq , Show , Figure , Affine , Trans , Curve , ClosedCurve , Manifold , PiecewiseLinear , Polygonal , APoint , Linear , Circular , Angular ) instance (Arbitrary a, PiecewiseLinear a) => Arbitrary (NonDegenerate a) where arbitrary = NonDegenerate <$> arbitrary `suchThat` isNondegenerate shrink (NonDegenerate l) = NonDegenerate <$> filter isNondegenerate (shrink l) -------------------------------------------------------------------------------- instance Arbitrary Triangle where arbitrary = (`suchThat` isNontrivial) $ do Position p1 <- arbitrary Position p2 <- arbitrary Position p3 <- arbitrary pure $ Triangle [p1, p2, p3] shrink (Triangle [p1, p2, p3]) = filter isNontrivial $ do p1' <- shrink p1 p2' <- shrink p2 p3' <- shrink p3 pure $ Triangle [p1', p2', p3'] instance Arbitrary RightTriangle where arbitrary = (`suchThat` isNondegenerate) $ do Positive a <- arbitrary Positive b <- arbitrary m <- arbitrary pure $ aRightTriangle # scaleX a # scaleY b # appMotion m shrink (RightTriangle t) = RightTriangle <$> shrink t
(************************************************************************) (* * The Coq Proof Assistant / The Coq Development Team *) (* v * INRIA, CNRS and contributors - Copyright 1999-2018 *) (* <O___,, * (see CREDITS file for the list of authors) *) (* \VV/ **************************************************************) (* // * This file is distributed under the terms of the *) (* * GNU Lesser General Public License Version 2.1 *) (* * (see LICENSE file for the text of the license) *) (************************************************************************) (** This module states the functional form of the axiom of choice over setoids, commonly called extensional axiom of choice [[Carlström04]], [[Martin-Löf05]]. This is obtained by a decomposition of the axiom into the following components: - classical logic - relational axiom of choice - axiom of unique choice - a limited form of functional extensionality Among other results, it entails: - proof irrelevance - choice of a representative in equivalence classes [[Carlström04]] Jesper Carlström, EM + Ext_ + AC_int is equivalent to AC_ext, Mathematical Logic Quaterly, vol 50(3), pp 236-240, 2004. [[Martin-Löf05] Per Martin-Löf, 100 years of Zermelo’s axiom of choice: what was the problem with it?, lecture notes for KTH/SU colloquium, 2005. *) Require Export ClassicalChoice. (* classical logic, relational choice, unique choice *) Require Export ExtensionalFunctionRepresentative. Require Import ChoiceFacts. Require Import ClassicalFacts. Require Import RelationClasses. Theorem setoid_choice : forall A B, forall R : A -> A -> Prop, forall T : A -> B -> Prop, Equivalence R -> (forall x x' y, R x x' -> T x y -> T x' y) -> (forall x, exists y, T x y) -> exists f : A -> B, forall x : A, T x (f x) /\ (forall x' : A, R x x' -> f x = f x'). Proof. apply setoid_functional_choice_first_characterization. split; [|split]. - exact choice. - exact extensional_function_representative. - exact classic. Qed. Theorem representative_choice : forall A (R:A->A->Prop), (Equivalence R) -> exists f : A->A, forall x : A, R x (f x) /\ forall x', R x x' -> f x = f x'. Proof. apply setoid_fun_choice_imp_repr_fun_choice. exact setoid_choice. Qed.
lemma complex_cnj_neg_numeral [simp]: "cnj (- numeral w) = - numeral w"
/- Copyright (c) 2022 Jujian Zhang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jujian Zhang, Eric Wieser ! This file was ported from Lean 3 source module ring_theory.graded_algebra.radical ! leanprover-community/mathlib commit f1944b30c97c5eb626e498307dec8b022a05bd0a ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathbin.RingTheory.GradedAlgebra.HomogeneousIdeal /-! This file contains a proof that the radical of any homogeneous ideal is a homogeneous ideal ## Main statements * `ideal.is_homogeneous.is_prime_iff`: for any `I : ideal A`, if `I` is homogeneous, then `I` is prime if and only if `I` is homogeneously prime, i.e. `I ≠ ⊤` and if `x, y` are homogeneous elements such that `x * y ∈ I`, then at least one of `x,y` is in `I`. * `ideal.is_prime.homogeneous_core`: for any `I : ideal A`, if `I` is prime, then `I.homogeneous_core 𝒜` (i.e. the largest homogeneous ideal contained in `I`) is also prime. * `ideal.is_homogeneous.radical`: for any `I : ideal A`, if `I` is homogeneous, then the radical of `I` is homogeneous as well. * `homogeneous_ideal.radical`: for any `I : homogeneous_ideal 𝒜`, `I.radical` is the the radical of `I` as a `homogeneous_ideal 𝒜` ## Implementation details Throughout this file, the indexing type `ι` of grading is assumed to be a `linear_ordered_cancel_add_comm_monoid`. This might be stronger than necessary but cancelling property is strictly necessary; for a counterexample of how `ideal.is_homogeneous.is_prime_iff` fails for a non-cancellative set see `counterexample/homogeneous_prime_not_prime.lean`. ## Tags homogeneous, radical -/ open GradedRing DirectSum SetLike Finset open BigOperators variable {ι σ A : Type _} variable [CommRing A] variable [LinearOrderedCancelAddCommMonoid ι] variable [SetLike σ A] [AddSubmonoidClass σ A] {𝒜 : ι → σ} [GradedRing 𝒜] include A /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/ theorem Ideal.IsHomogeneous.isPrime_of_homogeneous_mem_or_mem {I : Ideal A} (hI : I.Homogeneous 𝒜) (I_ne_top : I ≠ ⊤) (homogeneous_mem_or_mem : ∀ {x y : A}, Homogeneous 𝒜 x → Homogeneous 𝒜 y → x * y ∈ I → x ∈ I ∨ y ∈ I) : Ideal.IsPrime I := ⟨I_ne_top, by intro x y hxy by_contra rid obtain ⟨rid₁, rid₂⟩ := not_or_distrib.mp rid classical /- The idea of the proof is the following : since `x * y ∈ I` and `I` homogeneous, then `proj i (x * y) ∈ I` for any `i : ι`. Then consider two sets `{i ∈ x.support | xᵢ ∉ I}` and `{j ∈ y.support | yⱼ ∉ J}`; let `max₁, max₂` be the maximum of the two sets, then `proj (max₁ + max₂) (x * y) ∈ I`. Then, `proj max₁ x ∉ I` and `proj max₂ j ∉ I` but `proj i x ∈ I` for all `max₁ < i` and `proj j y ∈ I` for all `max₂ < j`. ` proj (max₁ + max₂) (x * y)` `= ∑ {(i, j) ∈ supports | i + j = max₁ + max₂}, xᵢ * yⱼ` `= proj max₁ x * proj max₂ y` ` + ∑ {(i, j) ∈ supports \ {(max₁, max₂)} | i + j = max₁ + max₂}, xᵢ * yⱼ`. This is a contradiction, because both `proj (max₁ + max₂) (x * y) ∈ I` and the sum on the right hand side is in `I` however `proj max₁ x * proj max₂ y` is not in `I`. -/ set set₁ := (decompose 𝒜 x).support.filterₓ fun i => proj 𝒜 i x ∉ I with set₁_eq set set₂ := (decompose 𝒜 y).support.filterₓ fun i => proj 𝒜 i y ∉ I with set₂_eq have nonempty : ∀ x : A, x ∉ I → ((decompose 𝒜 x).support.filterₓ fun i => proj 𝒜 i x ∉ I).Nonempty := by intro x hx rw [filter_nonempty_iff] contrapose! hx simp_rw [proj_apply] at hx rw [← sum_support_decompose 𝒜 x] exact Ideal.sum_mem _ hx set max₁ := set₁.max' (Nonempty x rid₁) with max₁_eq set max₂ := set₂.max' (Nonempty y rid₂) with max₂_eq have mem_max₁ : max₁ ∈ set₁ := max'_mem set₁ (Nonempty x rid₁) have mem_max₂ : max₂ ∈ set₂ := max'_mem set₂ (Nonempty y rid₂) replace hxy : proj 𝒜 (max₁ + max₂) (x * y) ∈ I := hI _ hxy have mem_I : proj 𝒜 max₁ x * proj 𝒜 max₂ y ∈ I := by set antidiag := ((decompose 𝒜 x).support ×ˢ (decompose 𝒜 y).support).filterₓ fun z : ι × ι => z.1 + z.2 = max₁ + max₂ with ha have mem_antidiag : (max₁, max₂) ∈ antidiag := by simp only [add_sum_erase, mem_filter, mem_product] exact ⟨⟨mem_of_mem_filter _ mem_max₁, mem_of_mem_filter _ mem_max₂⟩, rfl⟩ have eq_add_sum := calc proj 𝒜 (max₁ + max₂) (x * y) = ∑ ij in antidiag, proj 𝒜 ij.1 x * proj 𝒜 ij.2 y := by simp_rw [ha, proj_apply, DirectSum.decompose_mul, DirectSum.coe_mul_apply 𝒜] _ = proj 𝒜 max₁ x * proj 𝒜 max₂ y + ∑ ij in antidiag.erase (max₁, max₂), proj 𝒜 ij.1 x * proj 𝒜 ij.2 y := (add_sum_erase _ _ mem_antidiag).symm rw [eq_sub_of_add_eq eq_add_sum.symm] refine' Ideal.sub_mem _ hxy (Ideal.sum_mem _ fun z H => _) rcases z with ⟨i, j⟩ simp only [mem_erase, Prod.mk.inj_iff, Ne.def, mem_filter, mem_product] at H rcases H with ⟨H₁, ⟨H₂, H₃⟩, H₄⟩ have max_lt : max₁ < i ∨ max₂ < j := by rcases lt_trichotomy max₁ i with (h | rfl | h) · exact Or.inl h · refine' False.elim (H₁ ⟨rfl, add_left_cancel H₄⟩) · apply Or.inr have := add_lt_add_right h j rw [H₄] at this exact lt_of_add_lt_add_left this cases max_lt · -- in this case `max₁ < i`, then `xᵢ ∈ I`; for otherwise `i ∈ set₁` then `i ≤ max₁`. have not_mem : i ∉ set₁ := fun h => lt_irrefl _ ((max'_lt_iff set₁ (Nonempty x rid₁)).mp max_lt i h) rw [set₁_eq] at not_mem simp only [not_and, Classical.not_not, Ne.def, mem_filter] at not_mem exact Ideal.mul_mem_right _ I (not_mem H₂) · -- in this case `max₂ < j`, then `yⱼ ∈ I`; for otherwise `j ∈ set₂`, then `j ≤ max₂`. have not_mem : j ∉ set₂ := fun h => lt_irrefl _ ((max'_lt_iff set₂ (Nonempty y rid₂)).mp max_lt j h) rw [set₂_eq] at not_mem simp only [not_and, Classical.not_not, Ne.def, mem_filter] at not_mem exact Ideal.mul_mem_left I _ (not_mem H₃) have not_mem_I : proj 𝒜 max₁ x * proj 𝒜 max₂ y ∉ I := by have neither_mem : proj 𝒜 max₁ x ∉ I ∧ proj 𝒜 max₂ y ∉ I := by rw [mem_filter] at mem_max₁ mem_max₂ exact ⟨mem_max₁.2, mem_max₂.2⟩ intro rid cases homogeneous_mem_or_mem ⟨max₁, SetLike.coe_mem _⟩ ⟨max₂, SetLike.coe_mem _⟩ mem_I · apply neither_mem.1 h · apply neither_mem.2 h exact not_mem_I mem_I⟩ #align ideal.is_homogeneous.is_prime_of_homogeneous_mem_or_mem Ideal.IsHomogeneous.isPrime_of_homogeneous_mem_or_mem theorem Ideal.IsHomogeneous.isPrime_iff {I : Ideal A} (h : I.Homogeneous 𝒜) : I.IsPrime ↔ I ≠ ⊤ ∧ ∀ {x y : A}, SetLike.Homogeneous 𝒜 x → SetLike.Homogeneous 𝒜 y → x * y ∈ I → x ∈ I ∨ y ∈ I := ⟨fun HI => ⟨ne_of_apply_ne _ HI.ne_top, fun x y hx hy hxy => Ideal.IsPrime.mem_or_mem HI hxy⟩, fun ⟨I_ne_top, homogeneous_mem_or_mem⟩ => h.isPrime_of_homogeneous_mem_or_mem I_ne_top @homogeneous_mem_or_mem⟩ #align ideal.is_homogeneous.is_prime_iff Ideal.IsHomogeneous.isPrime_iff theorem Ideal.IsPrime.homogeneousCore {I : Ideal A} (h : I.IsPrime) : (I.homogeneousCore 𝒜).toIdeal.IsPrime := by apply (Ideal.homogeneousCore 𝒜 I).Homogeneous.isPrime_of_homogeneous_mem_or_mem · exact ne_top_of_le_ne_top h.ne_top (Ideal.toIdeal_homogeneousCore_le 𝒜 I) rintro x y hx hy hxy have H := h.mem_or_mem (Ideal.toIdeal_homogeneousCore_le 𝒜 I hxy) refine' H.imp _ _ · exact Ideal.mem_homogeneousCore_of_homogeneous_of_mem hx · exact Ideal.mem_homogeneousCore_of_homogeneous_of_mem hy #align ideal.is_prime.homogeneous_core Ideal.IsPrime.homogeneousCore theorem Ideal.IsHomogeneous.radical_eq {I : Ideal A} (hI : I.Homogeneous 𝒜) : I.radical = infₛ { J | J.Homogeneous 𝒜 ∧ I ≤ J ∧ J.IsPrime } := by rw [Ideal.radical_eq_infₛ] apply le_antisymm · exact infₛ_le_infₛ fun J => And.right · refine' infₛ_le_infₛ_of_forall_exists_le _ rintro J ⟨HJ₁, HJ₂⟩ refine' ⟨(J.homogeneous_core 𝒜).toIdeal, _, J.to_ideal_homogeneous_core_le _⟩ refine' ⟨HomogeneousIdeal.isHomogeneous _, _, HJ₂.homogeneous_core⟩ refine' hI.to_ideal_homogeneous_core_eq_self.symm.trans_le (Ideal.homogeneousCore_mono _ HJ₁) #align ideal.is_homogeneous.radical_eq Ideal.IsHomogeneous.radical_eq theorem Ideal.IsHomogeneous.radical {I : Ideal A} (h : I.Homogeneous 𝒜) : I.radical.Homogeneous 𝒜 := by rw [h.radical_eq] exact Ideal.IsHomogeneous.inf fun _ => And.left #align ideal.is_homogeneous.radical Ideal.IsHomogeneous.radical /-- The radical of a homogenous ideal, as another homogenous ideal. -/ def HomogeneousIdeal.radical (I : HomogeneousIdeal 𝒜) : HomogeneousIdeal 𝒜 := ⟨I.toIdeal.radical, I.Homogeneous.radical⟩ #align homogeneous_ideal.radical HomogeneousIdeal.radical @[simp] theorem HomogeneousIdeal.coe_radical (I : HomogeneousIdeal 𝒜) : I.radical.toIdeal = I.toIdeal.radical := rfl #align homogeneous_ideal.coe_radical HomogeneousIdeal.coe_radical
[STATEMENT] lemma less_eq_multiset_empty_right[simp]: "M \<noteq> {#} \<Longrightarrow> \<not> M \<le> {#}" [PROOF STATE] proof (prove) goal (1 subgoal): 1. M \<noteq> {#} \<Longrightarrow> \<not> M \<le> {#} [PROOF STEP] by (metis less_eq_multiset_empty_left antisym)
open import Agda.Builtin.Sigma open import Agda.Builtin.Equality infix 1 Σ-syntax Σ-syntax = Σ syntax Σ-syntax A (λ x → B) = Σ[ x ∈ A ] B pair : Set → Set pair A = Σ[ _ ∈ A ] A diag : Set → Set diag A = Σ[ p ∈ pair A ] fst p ≡ snd p diag-pat : Set → Set diag-pat A = Σ[ p@(x , y) ∈ pair A ] p ≡ (y , x) -- WAS: parse error for p@(x , y) -- WANT: success
[STATEMENT] lemma GSMP_wt_subst_subset: assumes "t \<in> GSMP (M \<cdot>\<^sub>s\<^sub>e\<^sub>t \<I>)" "wt\<^sub>s\<^sub>u\<^sub>b\<^sub>s\<^sub>t \<I>" "wf\<^sub>t\<^sub>r\<^sub>m\<^sub>s (subst_range \<I>)" shows "t \<in> GSMP M" [PROOF STATE] proof (prove) goal (1 subgoal): 1. t \<in> GSMP M [PROOF STEP] using SMP_wt_subst_subset[OF _ assms(2,3), of t M] assms(1) [PROOF STATE] proof (prove) using this: t \<in> SMP (M \<cdot>\<^sub>s\<^sub>e\<^sub>t \<I>) \<Longrightarrow> t \<in> SMP M t \<in> GSMP (M \<cdot>\<^sub>s\<^sub>e\<^sub>t \<I>) goal (1 subgoal): 1. t \<in> GSMP M [PROOF STEP] unfolding GSMP_def [PROOF STATE] proof (prove) using this: t \<in> SMP (M \<cdot>\<^sub>s\<^sub>e\<^sub>t \<I>) \<Longrightarrow> t \<in> SMP M t \<in> {t \<in> SMP (M \<cdot>\<^sub>s\<^sub>e\<^sub>t \<I>). fv t = {}} goal (1 subgoal): 1. t \<in> {t \<in> SMP M. fv t = {}} [PROOF STEP] by simp
[STATEMENT] lemma (in Order) ord_equiv_segment_segment: "\<lbrakk>Order E; ord_equiv D E; a \<in> carrier D\<rbrakk> \<Longrightarrow> \<exists>t\<in>carrier E. ord_equiv (Iod D (segment D a)) (Iod E (segment E t))" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>Order E; ord_equiv D E; a \<in> carrier D\<rbrakk> \<Longrightarrow> \<exists>t\<in>carrier E. ord_equiv (Iod D (segment D a)) (Iod E (segment E t)) [PROOF STEP] apply (simp add:ord_equiv_def, erule exE) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>f. \<lbrakk>Order E; a \<in> carrier D; ord_isom D E f\<rbrakk> \<Longrightarrow> \<exists>t\<in>carrier E. \<exists>f. ord_isom (Iod D (segment D a)) (Iod E (segment E t)) f [PROOF STEP] apply (frule_tac f = f in ord_isom_segment_segment[of E _ a], assumption+) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>f. \<lbrakk>Order E; a \<in> carrier D; ord_isom D E f; ord_isom (Iod D (segment D a)) (Iod E (segment E (f a))) (restrict f (carrier (Iod D (segment D a))))\<rbrakk> \<Longrightarrow> \<exists>t\<in>carrier E. \<exists>f. ord_isom (Iod D (segment D a)) (Iod E (segment E t)) f [PROOF STEP] apply (frule_tac f = f in ord_isom_mem[of E _ a], assumption+) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>f. \<lbrakk>Order E; a \<in> carrier D; ord_isom D E f; ord_isom (Iod D (segment D a)) (Iod E (segment E (f a))) (restrict f (carrier (Iod D (segment D a)))); f a \<in> carrier E\<rbrakk> \<Longrightarrow> \<exists>t\<in>carrier E. \<exists>f. ord_isom (Iod D (segment D a)) (Iod E (segment E t)) f [PROOF STEP] apply blast [PROOF STATE] proof (prove) goal: No subgoals! [PROOF STEP] done
library(ggplot2) library(scales) library(shiny) function(input, output) { file = "http://dd.weather.gc.ca/hydrometric/csv/SK/hourly/SK_hourly_hydrometric.csv" skdat <- read.csv(file, head=T, sep=",", dec=".", stringsAsFactors = F) colnames(skdat) <- c("ID", "Date", "WaterLevel", "Grade1", "Symbol1", "QAQC-1", "DischargeDebit", "Grade2", "Symbol2", "QAQC-2") #subds <- subset(skdat, ID=input$z) #subds$datetime <- as.POSIXct(subds$Date, format = "%Y-%m-%dT%H:%M:%OS") #output$lineplot <- renderPlot({ # ggplot(subds, aes(x = datetime, y = !!as.name(input$y))) + geom_line() #}) output$lineplot <- renderPlot({ subds <- subset(skdat, ID == input$z) subds$datetime <- as.POSIXct(subds$Date, format = "%Y-%m-%dT%H:%M:%OS") ggplot(subds, aes(x = datetime, y = !!as.name(input$y))) + geom_line() }) }
Formal statement is: lemma emeasure_sup_measure': assumes sets_eq[simp]: "sets B = sets A" and [simp, intro]: "X \<in> sets A" shows "emeasure (sup_measure' A B) X = (SUP Y\<in>sets A. emeasure A (X \<inter> Y) + emeasure B (X \<inter> - Y))" (is "_ = ?S X") Informal statement is: If $A$ and $B$ are two $\sigma$-algebras on the same set, then the measure of a set $X$ in the $\sigma$-algebra generated by $A$ and $B$ is the supremum of the measures of $X \cap Y$ in $A$ and $X \cap (Y^c)$ in $B$ over all sets $Y$ in $A$.
{-# LANGUAGE MagicHash, CPP, UnboxedTuples, BangPatterns, FlexibleContexts #-} ----------------------------------------------------------------------------- -- | -- Module : Data.Packed.Internal.Vector -- Copyright : (c) Alberto Ruiz 2007 -- License : GPL-style -- -- Maintainer : Alberto Ruiz <[email protected]> -- Stability : provisional -- Portability : portable (uses FFI) -- -- Vector implementation -- ----------------------------------------------------------------------------- module Data.Packed.Internal.Vector ( Vector, dim, fromList, toList, (|>), join, (@>), safe, at, at', subVector, takesV, mapVector, mapVectorWithIndex, zipVectorWith, unzipVectorWith, mapVectorM, mapVectorM_, mapVectorWithIndexM, mapVectorWithIndexM_, foldVector, foldVectorG, foldLoop, foldVectorWithIndex, createVector, vec, asComplex, asReal, float2DoubleV, double2FloatV, stepF, stepD, condF, condD, conjugateQ, conjugateC, fwriteVector, freadVector, fprintfVector, fscanfVector, cloneVector, unsafeToForeignPtr, unsafeFromForeignPtr, unsafeWith ) where import Data.Packed.Internal.Common import Data.Packed.Internal.Signatures import Foreign.Marshal.Alloc(free) import Foreign.Marshal.Array(peekArray, pokeArray, copyArray, advancePtr) import Foreign.ForeignPtr(ForeignPtr, castForeignPtr) import Foreign.Ptr(Ptr) import Foreign.Storable(Storable, peekElemOff, pokeElemOff, sizeOf) import Foreign.C.String import Foreign.C.Types import Data.Complex import Control.Monad(when) import System.IO.Unsafe(unsafePerformIO) #if __GLASGOW_HASKELL__ >= 605 import GHC.ForeignPtr (mallocPlainForeignPtrBytes) #else import Foreign.ForeignPtr (mallocForeignPtrBytes) #endif import GHC.Base #if __GLASGOW_HASKELL__ < 612 import GHC.IOBase hiding (liftIO) #endif import qualified Data.Vector.Storable as Vector import Data.Vector.Storable(Vector, unsafeToForeignPtr, unsafeFromForeignPtr, unsafeWith) -- | Number of elements dim :: (Storable t) => Vector t -> Int dim = Vector.length -- C-Haskell vector adapter -- vec :: Adapt (CInt -> Ptr t -> r) (Vector t) r vec :: (Storable t) => Vector t -> (((CInt -> Ptr t -> t1) -> t1) -> IO b) -> IO b vec x f = unsafeWith x $ \p -> do let v g = do g (fi $ dim x) p f v {-# INLINE vec #-} -- allocates memory for a new vector createVector :: Storable a => Int -> IO (Vector a) createVector n = do when (n <= 0) $ error ("trying to createVector of dim "++show n) fp <- doMalloc undefined return $ unsafeFromForeignPtr fp 0 n where -- -- Use the much cheaper Haskell heap allocated storage -- for foreign pointer space we control -- doMalloc :: Storable b => b -> IO (ForeignPtr b) doMalloc dummy = do #if __GLASGOW_HASKELL__ >= 605 mallocPlainForeignPtrBytes (n * sizeOf dummy) #else mallocForeignPtrBytes (n * sizeOf dummy) #endif {- | creates a Vector from a list: @> fromList [2,3,5,7] 4 |> [2.0,3.0,5.0,7.0]@ -} fromList :: Storable a => [a] -> Vector a fromList l = unsafePerformIO $ do v <- createVector (length l) unsafeWith v $ \ p -> pokeArray p l return v safeRead v = inlinePerformIO . unsafeWith v {-# INLINE safeRead #-} inlinePerformIO :: IO a -> a inlinePerformIO (IO m) = case m realWorld# of (# _, r #) -> r {-# INLINE inlinePerformIO #-} {- | extracts the Vector elements to a list @> toList (linspace 5 (1,10)) [1.0,3.25,5.5,7.75,10.0]@ -} toList :: Storable a => Vector a -> [a] toList v = safeRead v $ peekArray (dim v) {- | An alternative to 'fromList' with explicit dimension. The input list is explicitly truncated if it is too long, so it may safely be used, for instance, with infinite lists. This is the format used in the instances for Show (Vector a). -} (|>) :: (Storable a) => Int -> [a] -> Vector a infixl 9 |> n |> l = if length l' == n then fromList l' else error "list too short for |>" where l' = take n l -- | access to Vector elements without range checking at' :: Storable a => Vector a -> Int -> a at' v n = safeRead v $ flip peekElemOff n {-# INLINE at' #-} -- -- turn off bounds checking with -funsafe at configure time. -- ghc will optimise away the salways true case at compile time. -- #if defined(UNSAFE) safe :: Bool safe = False #else safe = True #endif -- | access to Vector elements with range checking. at :: Storable a => Vector a -> Int -> a at v n | safe = if n >= 0 && n < dim v then at' v n else error "vector index out of range" | otherwise = at' v n {-# INLINE at #-} {- | takes a number of consecutive elements from a Vector @> subVector 2 3 (fromList [1..10]) 3 |> [3.0,4.0,5.0]@ -} subVector :: Storable t => Int -- ^ index of the starting element -> Int -- ^ number of elements to extract -> Vector t -- ^ source -> Vector t -- ^ result subVector = Vector.slice {- | Reads a vector position: @> fromList [0..9] \@\> 7 7.0@ -} (@>) :: Storable t => Vector t -> Int -> t infixl 9 @> (@>) = at {- | creates a new Vector by joining a list of Vectors @> join [fromList [1..5], constant 1 3] 8 |> [1.0,2.0,3.0,4.0,5.0,1.0,1.0,1.0]@ -} join :: Storable t => [Vector t] -> Vector t join [] = error "joining zero vectors" join [v] = v join as = unsafePerformIO $ do let tot = sum (map dim as) r <- createVector tot unsafeWith r $ \ptr -> joiner as tot ptr return r where joiner [] _ _ = return () joiner (v:cs) _ p = do let n = dim v unsafeWith v $ \pb -> copyArray p pb n joiner cs 0 (advancePtr p n) {- | Extract consecutive subvectors of the given sizes. @> takesV [3,4] (linspace 10 (1,10)) [3 |> [1.0,2.0,3.0],4 |> [4.0,5.0,6.0,7.0]]@ -} takesV :: Storable t => [Int] -> Vector t -> [Vector t] takesV ms w | sum ms > dim w = error $ "takesV " ++ show ms ++ " on dim = " ++ (show $ dim w) | otherwise = go ms w where go [] _ = [] go (n:ns) v = subVector 0 n v : go ns (subVector n (dim v - n) v) --------------------------------------------------------------- -- | transforms a complex vector into a real vector with alternating real and imaginary parts asReal :: (RealFloat a, Storable a) => Vector (Complex a) -> Vector a asReal v = unsafeFromForeignPtr (castForeignPtr fp) (2*i) (2*n) where (fp,i,n) = unsafeToForeignPtr v -- | transforms a real vector into a complex vector with alternating real and imaginary parts asComplex :: (RealFloat a, Storable a) => Vector a -> Vector (Complex a) asComplex v = unsafeFromForeignPtr (castForeignPtr fp) (i `div` 2) (n `div` 2) where (fp,i,n) = unsafeToForeignPtr v --------------------------------------------------------------- float2DoubleV :: Vector Float -> Vector Double float2DoubleV v = unsafePerformIO $ do r <- createVector (dim v) app2 c_float2double vec v vec r "float2double" return r double2FloatV :: Vector Double -> Vector Float double2FloatV v = unsafePerformIO $ do r <- createVector (dim v) app2 c_double2float vec v vec r "double2float2" return r foreign import ccall unsafe "float2double" c_float2double:: TFV foreign import ccall unsafe "double2float" c_double2float:: TVF --------------------------------------------------------------- stepF :: Vector Float -> Vector Float stepF v = unsafePerformIO $ do r <- createVector (dim v) app2 c_stepF vec v vec r "stepF" return r stepD :: Vector Double -> Vector Double stepD v = unsafePerformIO $ do r <- createVector (dim v) app2 c_stepD vec v vec r "stepD" return r foreign import ccall unsafe "stepF" c_stepF :: TFF foreign import ccall unsafe "stepD" c_stepD :: TVV --------------------------------------------------------------- condF :: Vector Float -> Vector Float -> Vector Float -> Vector Float -> Vector Float -> Vector Float condF x y l e g = unsafePerformIO $ do r <- createVector (dim x) app6 c_condF vec x vec y vec l vec e vec g vec r "condF" return r condD :: Vector Double -> Vector Double -> Vector Double -> Vector Double -> Vector Double -> Vector Double condD x y l e g = unsafePerformIO $ do r <- createVector (dim x) app6 c_condD vec x vec y vec l vec e vec g vec r "condD" return r foreign import ccall unsafe "condF" c_condF :: CInt -> PF -> CInt -> PF -> CInt -> PF -> TFFF foreign import ccall unsafe "condD" c_condD :: CInt -> PD -> CInt -> PD -> CInt -> PD -> TVVV -------------------------------------------------------------------------------- conjugateAux fun x = unsafePerformIO $ do v <- createVector (dim x) app2 fun vec x vec v "conjugateAux" return v conjugateQ :: Vector (Complex Float) -> Vector (Complex Float) conjugateQ = conjugateAux c_conjugateQ foreign import ccall unsafe "conjugateQ" c_conjugateQ :: TQVQV conjugateC :: Vector (Complex Double) -> Vector (Complex Double) conjugateC = conjugateAux c_conjugateC foreign import ccall unsafe "conjugateC" c_conjugateC :: TCVCV -------------------------------------------------------------------------------- cloneVector :: Storable t => Vector t -> IO (Vector t) cloneVector v = do let n = dim v r <- createVector n let f _ s _ d = copyArray d s n >> return 0 app2 f vec v vec r "cloneVector" return r ------------------------------------------------------------------ -- | map on Vectors mapVector :: (Storable a, Storable b) => (a-> b) -> Vector a -> Vector b mapVector f v = unsafePerformIO $ do w <- createVector (dim v) unsafeWith v $ \p -> unsafeWith w $ \q -> do let go (-1) = return () go !k = do x <- peekElemOff p k pokeElemOff q k (f x) go (k-1) go (dim v -1) return w {-# INLINE mapVector #-} -- | zipWith for Vectors zipVectorWith :: (Storable a, Storable b, Storable c) => (a-> b -> c) -> Vector a -> Vector b -> Vector c zipVectorWith f u v = unsafePerformIO $ do let n = min (dim u) (dim v) w <- createVector n unsafeWith u $ \pu -> unsafeWith v $ \pv -> unsafeWith w $ \pw -> do let go (-1) = return () go !k = do x <- peekElemOff pu k y <- peekElemOff pv k pokeElemOff pw k (f x y) go (k-1) go (n -1) return w {-# INLINE zipVectorWith #-} -- | unzipWith for Vectors unzipVectorWith :: (Storable (a,b), Storable c, Storable d) => ((a,b) -> (c,d)) -> Vector (a,b) -> (Vector c,Vector d) unzipVectorWith f u = unsafePerformIO $ do let n = dim u v <- createVector n w <- createVector n unsafeWith u $ \pu -> unsafeWith v $ \pv -> unsafeWith w $ \pw -> do let go (-1) = return () go !k = do z <- peekElemOff pu k let (x,y) = f z pokeElemOff pv k x pokeElemOff pw k y go (k-1) go (n-1) return (v,w) {-# INLINE unzipVectorWith #-} foldVector :: Storable a => (a -> b -> b) -> b -> Vector a -> b foldVector f x v = unsafePerformIO $ unsafeWith v $ \p -> do let go (-1) s = return s go !k !s = do y <- peekElemOff p k go (k-1::Int) (f y s) go (dim v -1) x {-# INLINE foldVector #-} -- the zero-indexed index is passed to the folding function foldVectorWithIndex :: Storable a => (Int -> a -> b -> b) -> b -> Vector a -> b foldVectorWithIndex f x v = unsafePerformIO $ unsafeWith v $ \p -> do let go (-1) s = return s go !k !s = do y <- peekElemOff p k go (k-1::Int) (f k y s) go (dim v -1) x {-# INLINE foldVectorWithIndex #-} foldLoop f s0 d = go (d - 1) s0 where go 0 s = f (0::Int) s go !j !s = go (j - 1) (f j s) foldVectorG f s0 v = foldLoop g s0 (dim v) where g !k !s = f k (at' v) s {-# INLINE g #-} -- Thanks to Ryan Ingram (http://permalink.gmane.org/gmane.comp.lang.haskell.cafe/46479) {-# INLINE foldVectorG #-} ------------------------------------------------------------------- -- | monadic map over Vectors -- the monad @m@ must be strict mapVectorM :: (Storable a, Storable b, Monad m) => (a -> m b) -> Vector a -> m (Vector b) mapVectorM f v = do w <- return $! unsafePerformIO $! createVector (dim v) mapVectorM' w 0 (dim v -1) return w where mapVectorM' w' !k !t | k == t = do x <- return $! inlinePerformIO $! unsafeWith v $! \p -> peekElemOff p k y <- f x return $! inlinePerformIO $! unsafeWith w' $! \q -> pokeElemOff q k y | otherwise = do x <- return $! inlinePerformIO $! unsafeWith v $! \p -> peekElemOff p k y <- f x _ <- return $! inlinePerformIO $! unsafeWith w' $! \q -> pokeElemOff q k y mapVectorM' w' (k+1) t {-# INLINE mapVectorM #-} -- | monadic map over Vectors mapVectorM_ :: (Storable a, Monad m) => (a -> m ()) -> Vector a -> m () mapVectorM_ f v = do mapVectorM' 0 (dim v -1) where mapVectorM' !k !t | k == t = do x <- return $! inlinePerformIO $! unsafeWith v $! \p -> peekElemOff p k f x | otherwise = do x <- return $! inlinePerformIO $! unsafeWith v $! \p -> peekElemOff p k _ <- f x mapVectorM' (k+1) t {-# INLINE mapVectorM_ #-} -- | monadic map over Vectors with the zero-indexed index passed to the mapping function -- the monad @m@ must be strict mapVectorWithIndexM :: (Storable a, Storable b, Monad m) => (Int -> a -> m b) -> Vector a -> m (Vector b) mapVectorWithIndexM f v = do w <- return $! unsafePerformIO $! createVector (dim v) mapVectorM' w 0 (dim v -1) return w where mapVectorM' w' !k !t | k == t = do x <- return $! inlinePerformIO $! unsafeWith v $! \p -> peekElemOff p k y <- f k x return $! inlinePerformIO $! unsafeWith w' $! \q -> pokeElemOff q k y | otherwise = do x <- return $! inlinePerformIO $! unsafeWith v $! \p -> peekElemOff p k y <- f k x _ <- return $! inlinePerformIO $! unsafeWith w' $! \q -> pokeElemOff q k y mapVectorM' w' (k+1) t {-# INLINE mapVectorWithIndexM #-} -- | monadic map over Vectors with the zero-indexed index passed to the mapping function mapVectorWithIndexM_ :: (Storable a, Monad m) => (Int -> a -> m ()) -> Vector a -> m () mapVectorWithIndexM_ f v = do mapVectorM' 0 (dim v -1) where mapVectorM' !k !t | k == t = do x <- return $! inlinePerformIO $! unsafeWith v $! \p -> peekElemOff p k f k x | otherwise = do x <- return $! inlinePerformIO $! unsafeWith v $! \p -> peekElemOff p k _ <- f k x mapVectorM' (k+1) t {-# INLINE mapVectorWithIndexM_ #-} mapVectorWithIndex :: (Storable a, Storable b) => (Int -> a -> b) -> Vector a -> Vector b --mapVectorWithIndex g = head . mapVectorWithIndexM (\a b -> [g a b]) mapVectorWithIndex f v = unsafePerformIO $ do w <- createVector (dim v) unsafeWith v $ \p -> unsafeWith w $ \q -> do let go (-1) = return () go !k = do x <- peekElemOff p k pokeElemOff q k (f k x) go (k-1) go (dim v -1) return w {-# INLINE mapVectorWithIndex #-} ------------------------------------------------------------------- -- | Loads a vector from an ASCII file (the number of elements must be known in advance). fscanfVector :: FilePath -> Int -> IO (Vector Double) fscanfVector filename n = do charname <- newCString filename res <- createVector n app1 (gsl_vector_fscanf charname) vec res "gsl_vector_fscanf" free charname return res foreign import ccall unsafe "vector_fscanf" gsl_vector_fscanf:: Ptr CChar -> TV -- | Saves the elements of a vector, with a given format (%f, %e, %g), to an ASCII file. fprintfVector :: FilePath -> String -> Vector Double -> IO () fprintfVector filename fmt v = do charname <- newCString filename charfmt <- newCString fmt app1 (gsl_vector_fprintf charname charfmt) vec v "gsl_vector_fprintf" free charname free charfmt foreign import ccall unsafe "vector_fprintf" gsl_vector_fprintf :: Ptr CChar -> Ptr CChar -> TV -- | Loads a vector from a binary file (the number of elements must be known in advance). freadVector :: FilePath -> Int -> IO (Vector Double) freadVector filename n = do charname <- newCString filename res <- createVector n app1 (gsl_vector_fread charname) vec res "gsl_vector_fread" free charname return res foreign import ccall unsafe "vector_fread" gsl_vector_fread:: Ptr CChar -> TV -- | Saves the elements of a vector to a binary file. fwriteVector :: FilePath -> Vector Double -> IO () fwriteVector filename v = do charname <- newCString filename app1 (gsl_vector_fwrite charname) vec v "gsl_vector_fwrite" free charname foreign import ccall unsafe "vector_fwrite" gsl_vector_fwrite :: Ptr CChar -> TV