Datasets:
AI4M
/

text
stringlengths
0
3.34M
/- Copyright (c) 2020 Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bhavik Mehta, Andrew Yang ! This file was ported from Lean 3 source module category_theory.limits.constructions.equalizers ! leanprover-community/mathlib commit 3424a5932a77dcec2c177ce7d805acace6149299 ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathlib.CategoryTheory.Limits.Shapes.Equalizers import Mathlib.CategoryTheory.Limits.Shapes.BinaryProducts import Mathlib.CategoryTheory.Limits.Shapes.Pullbacks import Mathlib.CategoryTheory.Limits.Preserves.Shapes.Pullbacks import Mathlib.CategoryTheory.Limits.Preserves.Shapes.BinaryProducts /-! # Constructing equalizers from pullbacks and binary products. If a category has pullbacks and binary products, then it has equalizers. TODO: generalize universe -/ noncomputable section universe v v' u u' open CategoryTheory CategoryTheory.Category namespace CategoryTheory.Limits variable {C : Type u} [Category.{v} C] variable {D : Type u'} [Category.{v'} D] (G : C ⥤ D) -- We hide the "implementation details" inside a namespace namespace HasEqualizersOfHasPullbacksAndBinaryProducts variable [HasBinaryProducts C] [HasPullbacks C] /-- Define the equalizing object -/ @[reducible] def constructEqualizer (F : WalkingParallelPair ⥤ C) : C := pullback (prod.lift (𝟙 _) (F.map WalkingParallelPairHom.left)) (prod.lift (𝟙 _) (F.map WalkingParallelPairHom.right)) #align category_theory.limits.has_equalizers_of_has_pullbacks_and_binary_products.construct_equalizer CategoryTheory.Limits.HasEqualizersOfHasPullbacksAndBinaryProducts.constructEqualizer /-- Define the equalizing morphism -/ abbrev pullbackFst (F : WalkingParallelPair ⥤ C) : constructEqualizer F ⟶ F.obj WalkingParallelPair.zero := pullback.fst #align category_theory.limits.has_equalizers_of_has_pullbacks_and_binary_products.pullback_fst CategoryTheory.Limits.HasEqualizersOfHasPullbacksAndBinaryProducts.pullbackFst theorem pullbackFst_eq_pullback_snd (F : WalkingParallelPair ⥤ C) : pullbackFst F = pullback.snd := by convert (eq_whisker pullback.condition Limits.prod.fst : (_ : constructEqualizer F ⟶ F.obj WalkingParallelPair.zero) = _) <;> simp #align category_theory.limits.has_equalizers_of_has_pullbacks_and_binary_products.pullback_fst_eq_pullback_snd CategoryTheory.Limits.HasEqualizersOfHasPullbacksAndBinaryProducts.pullbackFst_eq_pullback_snd /-- Define the equalizing cone -/ @[reducible] def equalizerCone (F : WalkingParallelPair ⥤ C) : Cone F := Cone.ofFork (Fork.ofι (pullbackFst F) (by conv_rhs => rw [pullbackFst_eq_pullback_snd] convert (eq_whisker pullback.condition Limits.prod.snd : (_ : constructEqualizer F ⟶ F.obj WalkingParallelPair.one) = _) using 1 <;> simp)) #align category_theory.limits.has_equalizers_of_has_pullbacks_and_binary_products.equalizer_cone CategoryTheory.Limits.HasEqualizersOfHasPullbacksAndBinaryProducts.equalizerCone /-- Show the equalizing cone is a limit -/ def equalizerConeIsLimit (F : WalkingParallelPair ⥤ C) : IsLimit (equalizerCone F) where lift := by intro c; apply pullback.lift (c.π.app _) (c.π.app _) apply limit.hom_ext rintro (_ | _) <;> simp fac := by rintro c (_ | _) <;> simp uniq := by intro c _ J have J0 := J WalkingParallelPair.zero; simp at J0 apply pullback.hom_ext · rwa [limit.lift_π] · erw [limit.lift_π, ← J0, pullbackFst_eq_pullback_snd] #align category_theory.limits.has_equalizers_of_has_pullbacks_and_binary_products.equalizer_cone_is_limit CategoryTheory.Limits.HasEqualizersOfHasPullbacksAndBinaryProducts.equalizerConeIsLimit end HasEqualizersOfHasPullbacksAndBinaryProducts open HasEqualizersOfHasPullbacksAndBinaryProducts -- This is not an instance, as it is not always how one wants to construct equalizers! /-- Any category with pullbacks and binary products, has equalizers. -/ theorem hasEqualizers_of_hasPullbacks_and_binary_products [HasBinaryProducts C] [HasPullbacks C] : HasEqualizers C := { has_limit := fun F => HasLimit.mk { cone := equalizerCone F isLimit := equalizerConeIsLimit F } } #align category_theory.limits.has_equalizers_of_has_pullbacks_and_binary_products CategoryTheory.Limits.hasEqualizers_of_hasPullbacks_and_binary_products attribute [local instance] hasPullback_of_preservesPullback /-- A functor that preserves pullbacks and binary products also presrves equalizers. -/ def preservesEqualizersOfPreservesPullbacksAndBinaryProducts [HasBinaryProducts C] [HasPullbacks C] [PreservesLimitsOfShape (Discrete WalkingPair) G] [PreservesLimitsOfShape WalkingCospan G] : PreservesLimitsOfShape WalkingParallelPair G := ⟨fun {K} => preservesLimitOfPreservesLimitCone (equalizerConeIsLimit K) <| { lift := fun c => by refine' pullback.lift ?_ ?_ ?_ ≫ (PreservesPullback.iso _ _ _ ).inv · exact c.π.app WalkingParallelPair.zero · exact c.π.app WalkingParallelPair.zero apply (mapIsLimitOfPreservesOfIsLimit G _ _ (prodIsProd _ _)).hom_ext rintro (_ | _) · simp only [Category.assoc, ← G.map_comp, prod.lift_fst, BinaryFan.π_app_left, BinaryFan.mk_fst] · simp only [BinaryFan.π_app_right, BinaryFan.mk_snd, Category.assoc, ← G.map_comp, prod.lift_snd] exact (c.π.naturality WalkingParallelPairHom.left).symm.trans (c.π.naturality WalkingParallelPairHom.right) fac := fun c j => by rcases j with (_ | _) <;> simp only [Category.comp_id, PreservesPullback.iso_inv_fst, Cone.ofFork_π, G.map_comp, PreservesPullback.iso_inv_fst_assoc, Functor.mapCone_π_app, eqToHom_refl, Category.assoc, Fork.ofι_π_app, pullback.lift_fst, pullback.lift_fst_assoc] exact (c.π.naturality WalkingParallelPairHom.left).symm.trans (Category.id_comp _) uniq := fun s m h => by rw [Iso.eq_comp_inv] have := h WalkingParallelPair.zero dsimp [equalizerCone] at this apply pullback.hom_ext <;> simp only [PreservesPullback.iso_hom_snd, Category.assoc, PreservesPullback.iso_hom_fst, pullback.lift_fst, pullback.lift_snd, Category.comp_id, ← pullbackFst_eq_pullback_snd, ← this] }⟩ #align category_theory.limits.preserves_equalizers_of_preserves_pullbacks_and_binary_products CategoryTheory.Limits.preservesEqualizersOfPreservesPullbacksAndBinaryProducts -- We hide the "implementation details" inside a namespace namespace HasCoequalizersOfHasPushoutsAndBinaryCoproducts variable [HasBinaryCoproducts C] [HasPushouts C] /-- Define the equalizing object -/ @[reducible] def constructCoequalizer (F : WalkingParallelPair ⥤ C) : C := pushout (coprod.desc (𝟙 _) (F.map WalkingParallelPairHom.left)) (coprod.desc (𝟙 _) (F.map WalkingParallelPairHom.right)) #align category_theory.limits.has_coequalizers_of_has_pushouts_and_binary_coproducts.construct_coequalizer CategoryTheory.Limits.HasCoequalizersOfHasPushoutsAndBinaryCoproducts.constructCoequalizer /-- Define the equalizing morphism -/ abbrev pushoutInl (F : WalkingParallelPair ⥤ C) : F.obj WalkingParallelPair.one ⟶ constructCoequalizer F := pushout.inl #align category_theory.limits.has_coequalizers_of_has_pushouts_and_binary_coproducts.pushout_inl CategoryTheory.Limits.HasCoequalizersOfHasPushoutsAndBinaryCoproducts.pushoutInl theorem pushoutInl_eq_pushout_inr (F : WalkingParallelPair ⥤ C) : pushoutInl F = pushout.inr := by convert (whisker_eq Limits.coprod.inl pushout.condition : (_ : F.obj _ ⟶ constructCoequalizer _) = _) <;> simp #align category_theory.limits.has_coequalizers_of_has_pushouts_and_binary_coproducts.pushout_inl_eq_pushout_inr CategoryTheory.Limits.HasCoequalizersOfHasPushoutsAndBinaryCoproducts.pushoutInl_eq_pushout_inr /-- Define the equalizing cocone -/ @[reducible] def coequalizerCocone (F : WalkingParallelPair ⥤ C) : Cocone F := Cocone.ofCofork (Cofork.ofπ (pushoutInl F) (by conv_rhs => rw [pushoutInl_eq_pushout_inr] convert (whisker_eq Limits.coprod.inr pushout.condition : (_ : F.obj _ ⟶ constructCoequalizer _) = _) using 1 <;> simp)) #align category_theory.limits.has_coequalizers_of_has_pushouts_and_binary_coproducts.coequalizer_cocone CategoryTheory.Limits.HasCoequalizersOfHasPushoutsAndBinaryCoproducts.coequalizerCocone /-- Show the equalizing cocone is a colimit -/ def coequalizerCoconeIsColimit (F : WalkingParallelPair ⥤ C) : IsColimit (coequalizerCocone F) where desc := by intro c; apply pushout.desc (c.ι.app _) (c.ι.app _) apply colimit.hom_ext rintro (_ | _) <;> simp fac := by rintro c (_ | _) <;> simp uniq := by intro c m J have J1 : pushoutInl F ≫ m = c.ι.app WalkingParallelPair.one := by simpa using J WalkingParallelPair.one apply pushout.hom_ext · rw [colimit.ι_desc] exact J1 · rw [colimit.ι_desc, ← pushoutInl_eq_pushout_inr] exact J1 #align category_theory.limits.has_coequalizers_of_has_pushouts_and_binary_coproducts.coequalizer_cocone_is_colimit CategoryTheory.Limits.HasCoequalizersOfHasPushoutsAndBinaryCoproducts.coequalizerCoconeIsColimit end HasCoequalizersOfHasPushoutsAndBinaryCoproducts open HasCoequalizersOfHasPushoutsAndBinaryCoproducts -- This is not an instance, as it is not always how one wants to construct equalizers! /-- Any category with pullbacks and binary products, has equalizers. -/ theorem hasCoequalizers_of_hasPushouts_and_binary_coproducts [HasBinaryCoproducts C] [HasPushouts C] : HasCoequalizers C := { has_colimit := fun F => HasColimit.mk { cocone := coequalizerCocone F isColimit := coequalizerCoconeIsColimit F } } #align category_theory.limits.has_coequalizers_of_has_pushouts_and_binary_coproducts CategoryTheory.Limits.hasCoequalizers_of_hasPushouts_and_binary_coproducts attribute [local instance] hasPushout_of_preservesPushout /-- A functor that preserves pushouts and binary coproducts also presrves coequalizers. -/ def preservesCoequalizersOfPreservesPushoutsAndBinaryCoproducts [HasBinaryCoproducts C] [HasPushouts C] [PreservesColimitsOfShape (Discrete WalkingPair) G] [PreservesColimitsOfShape WalkingSpan G] : PreservesColimitsOfShape WalkingParallelPair G := ⟨fun {K} => preservesColimitOfPreservesColimitCocone (coequalizerCoconeIsColimit K) <| { desc := fun c => by refine' (PreservesPushout.iso _ _ _).inv ≫ pushout.desc _ _ _ · exact c.ι.app WalkingParallelPair.one · exact c.ι.app WalkingParallelPair.one apply (mapIsColimitOfPreservesOfIsColimit G _ _ (coprodIsCoprod _ _)).hom_ext rintro (_ | _) · simp only [BinaryCofan.ι_app_left, BinaryCofan.mk_inl, Category.assoc, ← G.map_comp_assoc, coprod.inl_desc] · simp only [BinaryCofan.ι_app_right, BinaryCofan.mk_inr, Category.assoc, ← G.map_comp_assoc, coprod.inr_desc] exact (c.ι.naturality WalkingParallelPairHom.left).trans (c.ι.naturality WalkingParallelPairHom.right).symm fac := fun c j => by rcases j with (_ | _) <;> simp only [Functor.mapCocone_ι_app, Cocone.ofCofork_ι, Category.id_comp, eqToHom_refl, Category.assoc, Functor.map_comp, Cofork.ofπ_ι_app, pushout.inl_desc, PreservesPushout.inl_iso_inv_assoc] exact (c.ι.naturality WalkingParallelPairHom.left).trans (Category.comp_id _) uniq := fun s m h => by rw [Iso.eq_inv_comp] have := h WalkingParallelPair.one dsimp [coequalizerCocone] at this apply pushout.hom_ext <;> simp only [PreservesPushout.inl_iso_hom_assoc, Category.id_comp, pushout.inl_desc, pushout.inr_desc, PreservesPushout.inr_iso_hom_assoc, ← pushoutInl_eq_pushout_inr, ← this] }⟩ #align category_theory.limits.preserves_coequalizers_of_preserves_pushouts_and_binary_coproducts CategoryTheory.Limits.preservesCoequalizersOfPreservesPushoutsAndBinaryCoproducts end CategoryTheory.Limits
From Coq Require Import ssreflect. From stdpp Require Import base gmap. From iris.proofmode Require Import tactics. From aneris.prelude Require Import gset_map. From aneris.aneris_lang.lib Require Import list_proof. From aneris.aneris_lang.lib.serialization Require Import serialization_proof. From aneris.aneris_lang Require Import aneris_lifting proofmode. From aneris.examples.crdt.spec Require Import crdt_base crdt_time crdt_events crdt_denot crdt_resources. From aneris.examples.crdt.oplib Require Import oplib_code. From aneris.examples.crdt.oplib.spec Require Import model spec. From aneris.examples.crdt.oplib.examples.add_wins_set Require Import add_wins_set_code. Section awsCrdt. Context `{!Log_Time} `{!EqDecision vl} `{!Countable vl}. Inductive awsOp : Type := | Add : vl → awsOp | Remove : vl → awsOp. Definition awsSt : Type := gset (vl * Time). Global Instance awsOp_eqdec : EqDecision awsOp. Proof. solve_decision. Qed. Global Instance awsOp_countable : Countable awsOp. Proof. apply (inj_countable' (λ op, match op with Add v => inl v | Remove v => inr v end) (λ x, match x with inl v => Add v | inr v => Remove v end)); intros []; done. Qed. Definition aws_denot (s : gset (Event awsOp)) (state : awsSt) : Prop := ∀ v tm, (v, tm) ∈ state ↔ ∃ add_ev, add_ev ∈ s ∧ EV_Op add_ev = Add v ∧ EV_Time add_ev = tm ∧ ∀ rm_ev, rm_ev ∈ s → EV_Op rm_ev = Remove v → ¬ TM_le tm (EV_Time rm_ev). Global Instance aws_denot_fun : Rel2__Fun aws_denot. Proof. constructor; intros s st1 st2 Hst1 Hst2. apply set_eq; intros [v tm]. rewrite Hst1 Hst2; done. Qed. Global Instance aws_denot_instance : CrdtDenot awsOp awsSt := { crdt_denot := aws_denot; }. End awsCrdt. Global Arguments awsOp _ : clear implicits. Global Arguments awsSt {_} _ {_ _}. (* TODO: Move to the right place. *) Global Instance TM_le_dec `{!Log_Time} tm1 tm2 : Decision (TM_le tm1 tm2). Proof. destruct (decide (TM_lt tm1 tm2)). { left; apply TM_lt_TM_le; done. } destruct (decide (tm1 = tm2)) as [->|]. { left; reflexivity. } right; intros []%TM_le_eq_or_lt; done. Qed. Section OpAws. Context `{!Log_Time} `{!EqDecision vl} `{!Countable vl}. Definition update_state (ev : Event (awsOp vl)) (st : awsSt vl) : awsSt vl := match EV_Op ev with | Add v => {[(v, EV_Time ev)]} ∪ st | Remove v => filter (λ '(w, tm), v ≠ w ∨ ¬ TM_le tm (EV_Time ev)) st end. Definition op_aws_effect (st : awsSt vl) (ev : Event (awsOp vl)) (st' : awsSt vl) : Prop := st' = update_state ev st. Lemma op_aws_effect_fun st : Rel2__Fun (op_aws_effect st). Proof. constructor; intros ??? -> ->; done. Qed. Instance op_aws_effect_coh : OpCrdtEffectCoh op_aws_effect. Proof. intros s ev st st' Hst Hevs Hmax Hext Hto. rewrite /op_aws_effect /crdt_denot /= /aws_denot /update_state. split. - intros ->. intros v tm; split. + intros Hup. destruct ev as [[add_vl|rm_vl] evorig evtm]; simpl in *. * rewrite elem_of_union elem_of_singleton in Hup. destruct Hup as [|Hup]; simplify_eq. -- exists {| EV_Op := Add add_vl; EV_Orig := evorig; EV_Time := evtm |}; simpl. split_and!; [set_solver|done|done|]. intros [[|rm_val] rm_orig rm_tm] Hrmvs ?; simpl in *; first done. destruct Hmax as [? Hmax]. specialize (Hmax _ Hrmvs). rewrite /time /= in Hmax. intros [->|Hle]%TM_le_eq_or_lt; last done. simplify_eq. assert ({| EV_Op := Add add_vl; EV_Orig := evorig; EV_Time := rm_tm |} = {| EV_Op := Remove add_vl; EV_Orig := rm_orig; EV_Time := rm_tm |}); last by simplify_eq. apply Hext; set_solver. -- apply Hst in Hup as (add_ev&?&?&?&?). exists add_ev; split_and!; [set_solver|done|done|set_solver]. * apply elem_of_filter in Hup as [Hupin Hup]. apply Hst in Hup as (add_ev&?&?&?&Hno_rm); simplify_eq. exists add_ev; split_and!; [set_solver|done|done|]. intros rm_ev Hrm_ev ?. pose proof Hrm_ev as Hrm_ev'. rewrite elem_of_union elem_of_singleton in Hrm_ev'. destruct Hrm_ev' as [|]; first by apply Hno_rm. simplify_eq/=; simpl. destruct Hupin; done. + intros (add_ev & Hadd_ev_in & Hadd_ev_val & Hadd_ev_tm & Hadd_ev_no_rm). destruct ev as [[add_vl|rm_vl] evorig evtm]; simpl in *. * rewrite elem_of_union elem_of_singleton in Hadd_ev_in. destruct Hadd_ev_in as [Hadd_ev_in|]; simplify_eq/=; last set_solver. apply elem_of_union; right. apply Hst. exists add_ev; split_and!; [done|done|done|set_solver]. * apply elem_of_filter. split. -- destruct (decide (rm_vl = v)); last tauto. right; apply (Hadd_ev_no_rm {| EV_Op := Remove rm_vl; EV_Orig := evorig; EV_Time := evtm |}); [set_solver|simpl; congruence]. -- apply Hst; exists add_ev; split_and!; [set_solver|done|done|set_solver]. - intros Hst'. apply set_eq; intros [v tm]; split. + intros (add_ev & Hadd_ev_in & Hadd_ev_val & Hadd_ev_tm & Hadd_ev_no_rm)%Hst'. destruct ev as [[add_vl|rm_vl] evorig evtm]; simpl in *. * rewrite elem_of_union elem_of_singleton in Hadd_ev_in. destruct Hadd_ev_in as [Hadd_ev_in|]; simplify_eq/=; last set_solver. apply elem_of_union; right. apply Hst. exists add_ev; split_and!; [done|done|done|set_solver]. * apply elem_of_filter. split. -- destruct (decide (rm_vl = v)); last tauto. right; apply (Hadd_ev_no_rm {| EV_Op := Remove rm_vl; EV_Orig := evorig; EV_Time := evtm |}); [set_solver|simpl; congruence]. -- apply Hst; exists add_ev; split_and!; [set_solver|done|done|set_solver]. + intros Hup. destruct ev as [[add_vl|rm_vl] evorig evtm]; simpl in *. * rewrite elem_of_union elem_of_singleton in Hup. destruct Hup as [|Hup]; simplify_eq. -- apply Hst'. exists {| EV_Op := Add add_vl; EV_Orig := evorig; EV_Time := evtm |}; simpl. split_and!; [set_solver|done|done|]. intros [[|rm_val] rm_orig rm_tm] Hrmvs ?; simpl in *; first done. destruct Hmax as [? Hmax]. specialize (Hmax _ Hrmvs). rewrite /time /= in Hmax. intros [->|Hle]%TM_le_eq_or_lt; last done. simplify_eq. assert ({| EV_Op := Add add_vl; EV_Orig := evorig; EV_Time := rm_tm |} = {| EV_Op := Remove add_vl; EV_Orig := rm_orig; EV_Time := rm_tm |}); last by simplify_eq. apply Hext; set_solver. -- apply Hst'. apply Hst in Hup as (add_ev&?&?&?&?). exists add_ev; split_and!; [set_solver|done|done|set_solver]. * apply Hst'. apply elem_of_filter in Hup as [Hupin Hup]. apply Hst in Hup as (add_ev&?&?&?&Hno_rm); simplify_eq. exists add_ev; split_and!; [set_solver|done|done|]. intros rm_ev Hrm_ev ?. pose proof Hrm_ev as Hrm_ev'. rewrite elem_of_union elem_of_singleton in Hrm_ev'. destruct Hrm_ev' as [|]; first by apply Hno_rm. simplify_eq/=; simpl. destruct Hupin; done. Qed. Definition op_aws_init_st : awsSt vl := ∅. Lemma op_aws_init_st_coh : ⟦ (∅ : gset (Event (awsOp vl))) ⟧ ⇝ op_aws_init_st. Proof. intros ? ?; split; first set_solver. intros (?&?&?); set_solver. Qed. Global Instance op_aws_model_instance : OpCrdtModel (awsOp vl) (awsSt vl) := { op_crdtM_effect := op_aws_effect; op_crdtM_effect_fun := op_aws_effect_fun; op_crdtM_effect_coh := op_aws_effect_coh; op_crdtM_init_st := op_aws_init_st; op_crdtM_init_st_coh := op_aws_init_st_coh }. End OpAws. From aneris.prelude Require Import time. From aneris.aneris_lang.lib Require Import list_code list_proof. From aneris.aneris_lang.lib.vector_clock Require Import vector_clock_code vector_clock_proof. From aneris.aneris_lang.lib Require Import inject. From aneris.examples.crdt.oplib.proof Require Import time. (* TODO: move to the right place. *) Global Instance vector_clock_inject : Inject vector_clock val := { inject := vector_clock_to_val }. Section aws_proof. Context `{!EqDecision vl} `{!Countable vl} `{!Inject vl val} `{!∀ (a : vl), Serializable vl_serialization $a}. Context `{!anerisG M Σ}. Context `{!CRDT_Params} `{!OpLib_Res (awsOp vl)}. Global Program Instance awsOp_inj : Inject (awsOp vl) val := {| inject w := match w with add_wins_set_proof.Add v => InjLV $v | Remove v => InjRV $v end |}. Next Obligation. Proof. intros [] []; simpl; intros ?; simplify_eq; done. Qed. Definition aws_OpLib_Op_Coh := λ (op : awsOp vl) (v : val), v = $op. Lemma aws_OpLib_Op_Coh_Inj (o1 o2 : awsOp vl) (v : val) : aws_OpLib_Op_Coh o1 v → aws_OpLib_Op_Coh o2 v → o1 = o2. Proof. rewrite /aws_OpLib_Op_Coh; intros ? ?; simplify_eq; done. Qed. Lemma aws_OpLib_Coh_Ser (op : awsOp vl) (v : val) : aws_OpLib_Op_Coh op v → Serializable (sum_serialization vl_serialization vl_serialization) v. Proof. intros Heq. rewrite Heq; destruct op; apply _. Qed. Definition aws_OpLib_State_Coh := λ (st : awsSt vl) v, ∃ (l : list (vl * vector_clock)), is_list l v ∧ ∀ vtm, vtm ∈ st ↔ vtm ∈ l. Global Instance aws_OpLib_Params : OpLib_Params (awsOp vl) (awsSt vl) := {| OpLib_Serialization := (sum_serialization vl_serialization vl_serialization); OpLib_State_Coh := aws_OpLib_State_Coh; OpLib_Op_Coh := aws_OpLib_Op_Coh; OpLib_Op_Coh_Inj := aws_OpLib_Op_Coh_Inj; OpLib_Coh_Ser := aws_OpLib_Coh_Ser |}. Lemma aws_init_st_fn_spec : ⊢ init_st_fn_spec init_st. Proof. iIntros (addr). iIntros "!#" (Φ) "_ HΦ". rewrite /init_st. wp_pures. iApply "HΦ". iPureIntro; eexists []; split_and!; [done|set_solver]. Qed. (* TODO: moe to the right place; this strengthenes the existing proof. *) (* This also changes the API to use filter instead of list.filter. Why whas that choice made!?*) Lemma wp_list_filter `{!Inject A val} (l : list A) (P : A -> bool) (f lv : val) ip : {{{ (∀ (x : A), {{{ ⌜x ∈ l⌝ }}} f $x @[ip] {{{ w, RET w; ⌜w = $(P x)⌝ }}} ) ∗ ⌜is_list l lv⌝ }}} list_code.list_filter f lv @[ip] {{{ rv, RET rv; ⌜is_list (filter P l) rv⌝ }}}. Proof. iIntros (Φ) "[#Hf %Hil] HΦ". iInduction l as [ | h t] "IH" forall (lv Hil Φ); simpl in Hil. - subst. rewrite /list_code.list_filter; wp_pures. iApply "HΦ"; done. - destruct Hil as (lv' & -> & Hil). rewrite /list_code.list_filter. do 7 (wp_pure _). fold list_code.list_filter. wp_apply ("IH" $! lv'); [done| |]. { iIntros "!#" (? ?) "!# %"; iApply "Hf"; iPureIntro; apply elem_of_cons; auto. } iIntros (rv) "%Hilp"; wp_pures. wp_apply "Hf"; [by iPureIntro; apply elem_of_cons; auto|]. iIntros (w) "->". destruct (P h) eqn:HP; wp_pures. + wp_apply wp_list_cons; [by eauto |]. iIntros (v) "%Hil'". iApply "HΦ"; iPureIntro. rewrite filter_cons. rewrite HP; simpl. simpl in Hil'; done. + iApply "HΦ"; iPureIntro. rewrite filter_cons. rewrite HP. done. Qed. Lemma aws_effect_spec : ⊢ effect_spec effect. Proof. iIntros (addr ev st s log_ev log_st). iIntros "!#" (Φ) "(%Hev & %Hst & %Hs & %Hevs) HΦ". rewrite /effect. destruct log_ev as [log_ev orig vc]. destruct Hev as (evpl&evvc&evorig& ?&Hopcoh&?&?). destruct Hevs as (Hnin & Hmax & Hext). destruct Hst as (l&?&Hstl). simplify_eq/=. rewrite Hopcoh /=. wp_pures. destruct log_ev; wp_pures. - replace ($ v, evvc)%V with ($ (v, vc) : val); last first. { simpl; erewrite is_vc_vector_clock_to_val; done. } wp_apply wp_list_cons; first by iPureIntro. iIntros (w Hw). iApply "HΦ". iExists _; iSplit; last by eauto. simpl; iPureIntro; eexists _; split_and!; first done. intros []; rewrite /update_state /=; set_solver. - wp_apply (wp_list_filter _ (λ '(w, wvc), (bool_decide (w ≠ v)) || (negb (bool_decide (vector_clock_le wvc vc))))). + iSplit; last done. iIntros ([w wvc]) "!#". iIntros (Ψ) "_ HΨ". wp_pures. destruct (decide (w = v)) as [->|Hneq]. * wp_op; [rewrite bin_op_eval_eq_val bool_decide_eq_true_2; done|]. wp_pures. wp_apply wp_vect_leq; first by iPureIntro; split; [apply vector_clock_to_val_is_vc|done]. iIntros (? ->); simpl. wp_pures. iApply "HΨ". rewrite (bool_decide_eq_false_2 (v ≠ v)); by auto. * wp_op. { rewrite bin_op_eval_eq_val bool_decide_eq_false_2; first done. intros ?; apply Hneq; eapply inj; eauto with typeclass_instances. } wp_pures. iApply "HΨ". rewrite (bool_decide_eq_true_2 (w ≠ v)); by auto. + iIntros (w Hw). iApply "HΦ". iExists _; iSplit; last by eauto. simpl; iPureIntro; eexists _; split_and!; first done. intros [u uvc]. rewrite /update_state /=. rewrite elem_of_filter elem_of_list_filter Hstl. rewrite -bool_decide_not -bool_decide_or bool_decide_spec. clear; firstorder. Qed. Lemma aws_crdt_fun_spec : ⊢ crdt_fun_spec aws_crdt. Proof. iIntros (addr). iIntros "!#" (Φ) "_ HΦ". rewrite /aws_crdt. wp_pures. iApply "HΦ". iExists _, _; iSplit; first done. iSplit. - iApply aws_init_st_fn_spec; done. - iApply aws_effect_spec; done. Qed. Lemma aws_init_spec : init_spec (oplib_init (s_ser (s_serializer (sum_serialization vl_serialization vl_serialization))) (s_deser (s_serializer (sum_serialization vl_serialization vl_serialization)))) -∗ init_spec_for_specific_crdt (aws_init (s_ser (s_serializer vl_serialization)) (s_deser (s_serializer vl_serialization))). Proof. iIntros "#Hinit" (repId addr addrs_val). iIntros (Φ) "!# (%Haddrs & %Hrepid & Hprotos & Hskt & Hfr & Htoken) HΦ". rewrite /aws_init. wp_pures. wp_apply ("Hinit" with "[$Hprotos $Htoken $Hskt $Hfr]"). { do 2 (iSplit; first done). iApply aws_crdt_fun_spec; done. } iIntros (get update) "(HLS & #Hget & #Hupdate)". wp_pures. iApply "HΦ"; eauto. Qed. End aws_proof.
function varargout = tpfp(varargin) % VL_TPFP Compute true positives and false positives % This is an helper function used by VL_PR(), VL_ROC(), VL_DET(). % % See also: VL_PR(), VL_ROC(), VL_DET(), VL_HELP(). [varargout{1:nargout}] = vl_tpfp(varargin{:});
import LMT variable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)] example {a1 a2 a3 : A I E} : ((((a3).write i2 (v2)).write i3 (((a3).write i3 (v2)).read i2)).read i2) ≠ (v2) → False := by arr
axiom appendNil {α} (as : List α) : as ++ [] = as axiom appendAssoc {α} (as bs cs : List α) : (as ++ bs) ++ cs = as ++ (bs ++ cs) axiom reverseEq {α} (as : List α) : as.reverse.reverse = as theorem ex1 {α} (as bs : List α) : as.reverse.reverse ++ [] ++ [] ++ bs ++ bs = as ++ (bs ++ bs) := by rw [appendNil, appendNil, reverseEq]; trace_state; rw [←appendAssoc]; theorem ex2 {α} (as bs : List α) : as.reverse.reverse ++ [] ++ [] ++ bs ++ bs = as ++ (bs ++ bs) := by rewrite [reverseEq, reverseEq]; -- Error on second reverseEq done axiom zeroAdd (x : Nat) : 0 + x = x theorem ex2a (x y z) (h₁ : 0 + x = y) (h₂ : 0 + y = z) : x = z := by rewrite [zeroAdd] at h₁ h₂; trace_state; subst x; subst y; exact rfl theorem ex3 (x y z) (h₁ : 0 + x = y) (h₂ : 0 + y = z) : x = z := by rewrite [zeroAdd] at *; subst x; subst y; exact rfl theorem ex4 (x y z) (h₁ : 0 + x = y) (h₂ : 0 + y = z) : x = z := by rewrite [appendAssoc] at *; -- Error done theorem ex5 (m n k : Nat) (h : 0 + n = m) (h : k = m) : k = n := by rw [zeroAdd] at *; trace_state; -- `h` is still a name for `h : k = m` refine Eq.trans h ?hole; apply Eq.symm; assumption theorem ex6 (p q r : Prop) (h₁ : q → r) (h₂ : p ↔ q) (h₃ : p) : r := by rw [←h₂] at h₁; exact h₁ h₃ theorem ex7 (p q r : Prop) (h₁ : q → r) (h₂ : p ↔ q) (h₃ : p) : r := by rw [h₂] at h₃; exact h₁ h₃ example (α : Type) (p : Prop) (a b c : α) (h : p → a = b) : a = c := by rw [h _] -- should manifest goal `⊢ p`, like `rw [h]` would
If $f$ is a positive additive function on a ring of sets, then $f$ is a measure.
%!TEX root = ../../thesis.tex %!TEX enableSynctex = true %******************************************************************************* %****************************** Third Chapter ********************************** %******************************************************************************* % **************************** Define Graphics Path ************************** \ifpdf{} \graphicspath{{Chapters/dualslit/Figs/Raster/}{Chapters/dualslit/Figs/PDF/}{Chapters/dualslit/Figs/}} \else \graphicspath{{Chapters/dualslit/Figs/Vector/}{Chapters/dualslit/Figs/}} \fi \chapter{Developments in confocal virtual \gls{slit-scanning} microscopy}\label{chapter:dualslit} % \epigraph{\emph{}}{--- Rick Ricketts} %Confocal microscopy is a variant of a pointing scanning systems whereby a pin hole in a conjugate plane rejects out-of-focus light to enable volumetric imaging. %Similarly a slit may replace a pinhole greatly speeding up the acquisition process for the cost of resolution and %sectioning capabilities. %In digitially scanned light-sheet microscopy, the swept beam may be conjugated to a slit to provide better contrast, resolution and sectioning in the direction of scanning. Conventional epi-illumination fluorescence microscopes illuminate the focal plane of the detection objective as well as a large fraction of the sample outside the focal plane. This leads to background intensity due to out-of-focus fluorescence, affecting resolution and contrast. Confocal-microscopes use a pin-hole in a conjugate image plane to %forcibly reject fluorescence from outside of the focal plane, producing overall better axially resolved images and contrast and resolution. Sectioning by this means leads to a large photon dose throughout the sample and the pixel-wise acquisition has a significant cost to the overall speed. Light-sheet microscopes address both problems by illuminating with a \emph{thin} sheet of light orthogonally to the detection; but for having wide-field contrast and optical sectioning being on the order of the thickness of the light-sheet. In this chapter the use of a virtual slit will be employed directly on the detection camera in the \gls{light-sheet} microscope presented in this thesis. Methods will be introduced to improve the speed of acquisition and simulations introduced for other microscope systems that may benefit from confocal \gls{slit-scanning}. \pagebreak \section{Single beam confocal \gls{slit-scanning}} \begin{figure} \centering \includegraphics[width=0.4\linewidth]{slit_scanning_alt} \caption[The principle of confocal \gls{slit-scanning} using digital light-sheet microscopy]{The principle of confocal \gls{slit-scanning} using digital light-sheet microscopy. An incident beam (green) approaches orthogonally to the direction of the rolling shutter, the shutter consists of a width of active pixels (yellow). The inactive pixels correspond to out-of-focus light and are rejected from the final image.}\label{fig:slit_scanning_alt} \end{figure} It was shown that a confocal microscope may be made faster by using a narrow slit rather than a pin-hole. This type of confocal slit increases contrast and resolution in one direction~\cite{sabharwalSlitscanningConfocalMicroendoscope1999}. The same principle can be applied to a \gls{DSLM}, provided the propagation of the beam is in the same direction as the slit. By scanning the slit and the beam concomitantly, an increase in resolution and contrast may be achieved in one direction~\cite{baumgartScannedLightSheet2012}. Moreover, the out-of-focus light then being rejected means the method also increases the overall axial resolution in one imaging axis. There exist several approaches for the implementation of such a confocal system. One approach is to add a slit in a conjugate image plane and synchronously shift a physical spatial slit with the scanning illumination. The forces involved in accelerating a physical slit would be, however, large as the slit would be moving at \SI{\sim10}{\kilo\hertz} linearly. A more practical approach would involve de-scanning the entire image onto a static slit using galvanometric mirrors, optically. This does introduce more complexity to a system, but has the potential to increase the overall available \gls{FOV} beyond just the field number of the detection objective~\cite{jahrHyperspectralLightSheet2015}. This technique was exploited to great effect by Huisken~\emph{et.~al.} where de-scanning was used to keep the emission photons of the beam along one row of pixels on a camera. The remaining pixel rows of the detector were filled with spectral information by placing a diffractive element in emission path. %Physical slits may be substituted for virtual slits when exploiting the nature of sCMOS cameras. By selectively activating pixels on an \gls{sCMOS} detector for reading-off, out-of-focus light may be rejected in a similar fashion to a physical slit. %The process of rolling a shutter occurs within the electronics of the camera for pixel read off by design. The rolling of the electronically gated shutter with a synchronised sweeping of a beam of light allows for live confocal imaging, depicted in \figurename~\ref{fig:slit_scanning_alt}. The width of the slit adjusts the contrast and resolution of the final image. % An optimal will then be % should be When the slit is of a similar width to the waist of the incident beam the \gls{SNR} will be maximal. %Setting the width of the rolling slit to be similar to the width of the light beam %Controlling the width of the slit to near the width of the beam, \subsection{Optimisation} A characterisation of the optimal slit width of the virtual slit was needed to provide the best imaging contrast. To measure this, \SI{200}{\nano\metre} diameter fluorescent beads (TetraSpeck) were suspended in \SI{1}{\percent} \gls{agarose VII} gel (Sigma Aldrich) at a concentration of \SI{2.3e3}{\text{beads} \per\milli\litre}. % [insert concentration]. %%~2.3 × 10^10 particles/mL 10^-6 The agarose was mounted by pipetting warm liquid gel at \SI{\sim40}{\degree\celsius} on to an lightly scratched PDMS bar, which helped adherence. Entire volumes (\SI{2048}{\text{px}} \(\times \) \SI{2048}{\text{px}} \(\times \) \SI{100}{\micro\metre}) were imaged per each varying each slit width. Beads were then localised manually (in 3D) by analysis of an axially projected image. %(see Chapter~\ref{sec:spt} %TODO insert chapter %). Of the \SI{31} beads that were localised a single candidate bead was chosen that %was suitable as it was not part of an aggregate, %it was sufficiently bright and unobscured. By analysing both the \gls{SNR} and the contrast of each cropped window around the candidate bead, it was shown that the ideal slit width was \SI{2.51(5)}{\micro\metre} which is on the order of the width of the incident laser beam, \SI{2.3(2)}{\micro\metre} (\figurename~\ref{fig:optimal_slit_snr_contrast}). A narrow beam waist was used achieve good contrast and signal as well as to give good axial resolution so as to avoid cross talk from nearby beads. It was also assume that this characterisation would only be needed in situations where small narrow \gls{FOV}, fine axial-resolution was needed. %Beam width 18 pixels. 2048 pixels, 25x mag each pixel 502 um The \gls{SNR} was computed by taking the ratio of the squared amplitude of the acquired fluoresce signal, to that of the estimated Gaussian background noise amplitude at varying slit widths. The contrast was calculated by fitting a \gls{2D} Gaussian to each image, with varying slit width, and plotting the fitted amplitude \(A\) with an offset \(B\), from the \gls{2D} Gaussian model: \begin{align} A e^{-\left(\frac{{(x-x_0)}^2-{(y-y_0)}^2}{2\sigma^2}\right)}+B \label{eq:2d_guassian_fit} \end{align} \begin{figure} \centering \includegraphics{Chapters/dualslit/Figs/PDF/optimal_slit_snr_contrast} \caption[Optimising the confocal slit width by varying slit width on a single fluorescent bead.]{ Optimising the confocal slit width by varying slit width on a single fluorescent bead. Fluorescent beads were mounted in \SI{1}{\percent} agarose gel. The \gls{SNR} and normalised contrast show peaks at a slit width of \SI{2.51(5)}{\micro\metre} which is optimal. Contrast was found using \( A\) in Equation~\eqref{eq:2d_guassian_fit} and normalised across all values of slit width. }\label{fig:optimal_slit_snr_contrast} \end{figure} \section{Double speed \gls{slit-scanning} microscopy} % It was been demonstrated that confocal \gls{slit-scanning} makes an improvement on \gls{SNR} for recorded imaged. % This was characterised with beads. % However, imaging speeds using confocal \gls{slit-scanning} are half maximum when using a single beam. % To this end two beams were generated optically using a simple beam splitter and two mirrors. % Each beam could be independently positioned such that they were separated by a half a sensor area, at the camera plane. The sensor used in the Orca Flash v4 (as well as other \gls{sCMOS} cameras including the Pco.Edge and Andor Zyla) consists of two adjacent Fairchild \gls{sCMOS} sensors. In a standard exposure, the shutter propagates outward (middle to top and middle to bottom) from the centre of the sensor simultaneously, as in \figurename~\ref{fig:dual_slit_scanning/standard}. The fastest exposure possible for each chip (\SI{10}{\milli\second}) provides the maximum \SI{100}{\hertz} imaging for the full \gls{FOV}. For confocal \gls{slit-scanning}, the two sensors are addressed with a single thin shutter propagating from one side of one sensor (ex.~bottom to middle) and across the next sensor (ex.~middle to top), in series. In this mode the maximum frame rate achievable is \SI{50}{\hertz} as illustrated in \figurename~\ref{fig:dual_slit_scanning/single_slit}. %when scanning confocally. In this work, a custom camera firmware was used to produce a pair of electronically gated confocal slits (\figurename~\ref{fig:dual_slit_scanning/dual_slit}), on each sensor half, to scan in the same direction simultaneously; providing the \SI{100}{\hertz} imaging that was ordinarily only available in global shutter mode. % \begin{figure} % \centering % \includegraphics{dual_slit_scanning} % \caption{ % The orinciple behind doubling the frame rate of the Orca Flash v4 when using \gls{slit-scanning} mode. % Standard exposure: In global shutter mode \SI{100}{\hertz} imaging may be achieved as each side of the sensor rolls an independent shutter. % \Gls{slit-scanning}: In normal \gls{slit-scanning} mode the shutter moves from one half of the chip to the other serially, halving available frame-rate. % Dual \gls{slit-scanning}: % The full frame-rate of the sensor is achievable when using two rolling shutters % %Having two shutters roll in \gls{slit-scanning} % %Having two shutters roll in \gls{slit-scanning} mode would make available the full of frame rate % } % \label{fig:dual_slit_scanning} % \end{figure} \begin{figure} \centering \begin{subfigure}[t]{0.32\linewidth} \centering \includegraphics{dual_slit_scanning/standard} \caption{Standard exposure}\label{fig:dual_slit_scanning/standard} \end{subfigure}\hfill \begin{subfigure}[t]{0.32\linewidth} \centering \includegraphics{dual_slit_scanning/single_slit} \caption{Slit scanning}\label{fig:dual_slit_scanning/single_slit} \end{subfigure}\hfill \begin{subfigure}[t]{0.32\linewidth} \centering \includegraphics{dual_slit_scanning/dual_slit} \caption{Dual slit scanning}\label{fig:dual_slit_scanning/dual_slit} \end{subfigure} \caption[The principle behind doubling the frame rate of the Orca Flash v4 when using \gls{slit-scanning} mode]{ The principle behind doubling the frame rate of the Orca Flash v4 when using \gls{slit-scanning} mode. Standard exposure: In global shutter mode \SI{100}{\hertz} imaging may be achieved as each side of the sensor rolls an independent shutter. \Gls{slit-scanning}: In normal \gls{slit-scanning} mode the shutter moves from one half of the chip to the other serially, halving available frame-rate. Dual \gls{slit-scanning}: The full frame-rate of the sensor is achievable when using two rolling shutters %Having two shutters roll in \gls{slit-scanning} %Having two shutters roll in \gls{slit-scanning} mode would make available the full of frame rate }\label{fig:dual_slit_scanning} \end{figure} % \subsection{Proposed implementations} \subsection{Dual slits using an \gls{SLM}}\label{sec:dualslits} To exploit the new functionality of the two propagating shutters, two paraxial beams were needed for illumination at the sample plane. Initially, an \gls{SLM} was optically relayed directly onto the first scanning mirror using a pair of relay lenses (\figurename~\ref{fig:dual_beam_layouts}a). % The relay at Optically relaying allowed access to the image plane of the scan mirror, whilst the second relay controlled the magnification of pixel size of the \gls{SLM} at the imaging plane of the excitation objective. The energy in each resultant beam, when a diffractive pattern was displayed on the \gls{SLM}, was not equal due to the implementation being polarisation sensitive. % This implementation was polarisation sensitive in that each beam's energy was not equal % and caused difficult for distributing an equal amount of power into each beam. This was compensated for by controlling the voltage of each pixel (which controlled the phase of the reflected photons) on the \gls{SLM} but due to the discrete nature of the voltage being applied to each \gls{SLM} pixel, the energies of each beam could not be sufficiently well matched. As well, due to the fixed pixel grid of the \gls{SLM}, the separation of the two beams (governed by the \gls{SLM} pattern frequency) could only be set to discrete distances, with the step size being larger than a single pixel at the camera. Using an \gls{SLM} also limited the potential for creating exotic illumination superimposed on the both beams. Though solutions do exist (using super-pixels~\cite{puttenSpatialAmplitudePhase2008}, or dual SLMs~\cite{fuImagingMulticellularSpecimens2016}) the methods are limited and heavily optically complex. % \begin{figure} % \centering % \includegraphics{dual_beam_layouts} % \caption[Designs for each optical layout to create dual-beams in a light sheet system]{Designs for each optical layout to create dual-beams in a light sheet system. % a) Shows the conjugation of the SLM to the first scanning mirror, this technique suffered for optical losses on the SLM; discrete angular steps limited by the pixel size on the SLM and inhomogeneous distribution of power into each beam. % b) Shows an optical solution for create two beams. % } % \label{fig:dual_beam_layouts} % \end{figure} \begin{figure} \centering \begin{subfigure}[t]{0.6\textwidth} \centering \includegraphics{dual_beam_layout/slm} \caption{Using an \gls{SLM} to create two beams}\label{fig:dual_beam_layout/slm} \end{subfigure} \hspace{\fill} \begin{subfigure}[t]{0.3\textwidth} \centering \includegraphics{dual_beam_layout/beamsplitter} \caption{Using a beamsplitter to create two beams, separated by \SI{1}{\degree}}\label{fig:dual_beam_layout/beamsplitter} %TODO labelled primary secondary beam \end{subfigure}\\ \vspace{\abovecaptionskip} \begin{subfigure}[t]{\textwidth} \centering \includegraphics{dual_beam_layout/key} \end{subfigure} \caption[Designs for each optical layout to create dual-beams in a light sheet system]{ Designs for possible optical layouts to create dual-beams in a \gls{DSLM} system. (\subref{fig:dual_beam_layout/slm}) shows the conjugation of the \gls{SLM} to the first scanning mirror, this technique suffered for optical losses on the \gls{SLM}; discrete angular steps limited by the pixel size on the \gls{SLM} and inhomogeneous distribution of power into each beam. (\subref{fig:dual_beam_layout/beamsplitter}) shows an optical solution for creating two beams by using a beamsplitter. The primary beam is in solid black and the secondary beam is dotted grey. }\label{fig:dual_beam_layouts} \end{figure} \subsection{Dual slits using a fast galvanometric mirror} A conceivable alternative method to Section~\ref{sec:dualslits} was considered in which % Conceivably, by driving the galvanometric mirrors would be driven at a very high frequency with pulsed \gls{Laser} illumination which %and pulsing a laser appropriately, a pulsed sampling of the of the laser could emulate two independent laser sources moving in unison. This solution would require no additional optics to create two create dual-beam illumination. To realise this, the round trip time of the scanning mirror, would in the best case, have to match the time it takes for the shutter to move up one row of pixels, \(\frac{\SI{10}{\milli\second}}{1024}=\SI{9.8}{\micro\second}\). Therefore, the drive frequency would then exceed \SI{100}{\kilo\hertz}, which is currently infeasible with most commercial scanning mirror technology and most affordable visible lasers and hence this setup was rejected for the present work. \subsection{An all-optical dual-slit implementation} An alternative implementation was employed whereby, immediately follow the four spatially co-aligned colours, a beam splitter was added with two returning mirrors (similar to Michelson interferometer). The beam arms were not optically interfered; instead they were purposely aimed-off to create a small angle in their propagation before reaching the scanning mirror (\figurename~\ref{fig:dual_beam_layouts}b). This slight angular difference, once imaged through the telecentric scan lens, then became a spatial separation at the imaging plane of the system and was easily tuned using the kinematic mirrors flanking the beam splitter. The all-optical approach offered many advantages: the system was polarisation insensitive and suffered minimal optical losses, especially when compared to using an \gls{SLM}, as in \figurename~\ref{fig:dual_beam_layout/slm}; and secondly, as the duplication of the beams was now independent of any beam shaping, actual beam shaping optics could be readily implemented. This had the potential for optics such as cubic phase masks and axicon lenses or even an \gls{SLM} being inserted to structure the beams. \begin{figure} \centering %\includegraphics[width=0.4\linewidth]{dualbeams/170517_40ms_exposure_488nm_58_amp_4_spacing} \includegraphics{dual_beam_profile} \caption[Fluorescence image of two beams at the image plane]{Fluorescence image of two beams at the image plane, beam alignment is performed by imaging aqueous (\SI{1}{\milli\text{M}}) solution of Rhodamine 6G.}\label{fig:real_dual_beams} \end{figure} % % \begin{figure} % \centering % \begin{subfigure}{0.7\textwidth} % \centering % \includegraphics{dual_beam_layout/slm} % \caption{\gls{SLM}} % \end{subfigure} % \begin{subfigure}{0.3\textwidth} % \centering % \includegraphics{dual_beam_layout/beamsplitter} % \caption{All-optical} % \end{subfigure}\\ % \begin{subfigure}{\textwidth} % \centering % \includegraphics{dual_beam_layout/key} % \end{subfigure} % %\includegraphics[width=0.4\linewidth]{dualbeams/170517_40ms_exposure_488nm_58_amp_4_spacing} % % \includegraphics{dual_beam_profile} % \caption[Fluorescence image of two beams at the image plane]{Fluorescence image of two beams at the image plane, beam alignment is performed by imaging aqueous (\SI{1}{\milli\text{M}}) solution of Rhodamine 6G.} % \label{fig:real_dual_beams} % \end{figure} % \subsection{Implementation} Using the approach in \figurename~\ref{fig:dual_beam_layout/beamsplitter}, two laser beams were created at the imaging plane that could be manually separated as shown by the recorded fluorescent image in \figurename~\ref{fig:real_dual_beams}. To position the beams the correct distance apart, the bottom most beam was aligned to middle of the \gls{FOV} by reducing the \gls{FOV} of the camera by half digitally and aligning the \emph{primary} beam with the bottom of the image using the galvanometric mirror. The \emph{secondary} beam was pushed to the top of the image using an appropriate the kinematic mirror flanking the beam splitter. %\subsection{Implementation} % Talk about SLM options %\subsubsection{Spatial light modulator} %Image of two beams with optimisation of intensity %\subsubsection{All optical solution} %Polarisation insensitive better etc, option to make bessel. %\begin{figure} %\centering %\begin{subfigure}[b]{0.4\textwidth} % \input{Chapters/dualslit/Figs/PDF/optimal_slit_snr.tex} % \caption{You a beaut} % \end{subfigure}% %\begin{subfigure}[b]{0.4\textwidth} % \centering % \input{Chapters/dualslit/Figs/PDF/optimal_slit_contrast.tex} % \caption{You a beaut} % \end{subfigure}% %\end{figure} \section{Structured illumination enhanced with slit-scan\-ning} %Confocal \gls{slit-scanning} extends the pass band of the objective to up double in one direction. %***WRITE WORDS HERE ABOUT SLIT SHEET AND SEGWAY TO SIMULATIONS** \subsection{Wide-field slit scanning} In this project it was proposed that a similar effect to a swept beam in a \gls{light-sheet} system can be realised in an epifluorescence \gls{wide-field} microscope using an \gls{SLM} in the excitation path. By conjugating an \gls{SLM} to the image plane of the objective, with suitable polarisers, activate pixels on the \gls{SLM} will exclusively illuminate the corresponding region in the image plane. To achieve a resolution and contrast improvement, a row of \gls{SLM} pixels are activated and the line synchronously swept with the confocal virtual shutter on the camera. With this, the contrast and resolution of the output image increases in the direction of propagation of the shutter, as shown by simulations in \figurename~\ref{fig:widefield_slit}. Ignoring three dimensional contributions to the imaging system for convieince, the following equation can be derived to describe the \(n^\text{th}\) time-step in one image exposure: % \begin{gather} % \intertext{A general widefield imaging model can be described as:} % d(x,y) = (s(x,y) \cdot (I_{\text{ill}}(x,y,n) * \text{PSF}_\text{ex}(x,y)) *\text{PSF}_\text{em}(x,y) % \intertext{Note the special cases where} % \text{I}_\text{ill}(x,y,n) = \delta(x,y) % \intertext{Which results in the familiar equation for confocal imaging} % d_\text{Confocal}(x,y) = s(x,y) * (\text{PSF}_\text{ex} \cdot \text{PSF}_\text{em}(x,y)) % % \intertext{And where the illumination \gls{PSF} is spatially invariant} % \intertext{We complete the slit scanning model by summing the accepted pixels over all pixel rows} % I_{\text{em}}(x,y) = \sum_{n=0}^{n=h-1} d(x,y) \cdot H(y-n) \cdot H(-(y-n)+w_{\text{slit}}) % % \end{gather} % % \begin{gather} % \intertext{Where \(0\leq x < w \) and \(H(y)\) is the Heaviside step function:} % H(y) = \int_{-\infty}^y \delta(s) d(s) % \end{gather} \begin{gather} \intertext{A general incoherent wide-field imaging model \(e(x,y)\) can be described as:} I_{\text{em}}(x,y,n) = (s(x,y) \cdot (I_{\text{ill}}(x,y,n) * \text{PSF}_\text{ex}(x,y)) *\text{PSF}_\text{em}(x,y) \intertext{Note the special cases where the illumination is at a single spot, becoming the familiar equation for confocal imaging} \text{I}_\text{ill}(x,y,n) = \delta(x,y) \implies d_\text{Confocal}(x,y) = s(x,y) * (\text{PSF}_\text{ex} \cdot \text{PSF}_\text{em}(x,y)) \intertext{and the case where the illumination constant across the image removing any dependance of detected image on the illumination PSF} \text{I}_\text{ill}(x,y,n) = I_0 \implies d_\text{Flat-Ill}(x,y) = (s(x,y) \cdot I_0) * \text{PSF}_\text{em}(x,y) % \intertext{And where the illumination \gls{PSF} is spatially invariant} \intertext{We complete the slit scanning model by summing the accepted pixels over all pixel rows} d(x,y) = \sum_{n=0}^{n=h-1} I_{\text{em}}(x,y,n) \cdot H(y-n) \cdot H(-(y-n)+w_{\text{slit}}) % \end{gather} % \begin{gather} \intertext{Where \(0\leq x < w \) and \(H(y)\) is the Heaviside step function:} H(y) = \int_{-\infty}^y \delta(s) d(s) \end{gather} The sample \(s(x,y)\) is illuminated with a spatial pattern of \(I_{\text{Ill}}(x,y,n)\) (which may vary during an exposure, as in \gls{light-sheet} microscopy) and imaged onto a detector with width \(w\) and height \(h\). \(n\) is the pixel number of the active row as the shutter rolls; \(H(y-n) \cdot H(-(y-n)+w_{\text{slit}})\) represents the active region on the detector as the shutter rolls with a width of \(w_{\text{slit}}\), \(\text{PSF}(x,y)\) is the point-spread function, \(I_{\text{ill}}(x,y,n)\) is the intensity profile of the illumination at the detector and \(d(x,y)\) is the illumination intensity at the detector with electronic slit-scanning enabled. % \begin{gather} % \intertext{For flat wide-field illumination, \(I_{\text{ill}}\) is contant.} % I_{\text{ill}}(x,y,n), = {I_0} % \intertext{For slit-scanning flat wide-field illumination} % I_{\text{ill}}(x,y,n) = {I_0} \cdot H(y-n) \cdot H(-(y-n)+w_{\text{slit}}) % \intertext{For slit-scanning flat wide-field illumination,} % % \end{gather} % % % % \begin{gather} % % note, that the \(\text{PSF}_\text{ex}\) for coherent illumination \gls{SIM} becomes unity as the illumination is generated with interference at the sample plane. % % shift_cosine_p = exp(-1i*((sim_factor*2*pi*r_est*((cos(a_est).*x+sin(a_est).*y))/(width))+ph_est));)} % %1+(\cos(\theta+\phi)x+\sin(\theta+\phi)y) % % I_{ill}(x,y,n,r,\theta,\phi) = e^{-i 2 \pi r (\cos(\theta)x+\sin(\theta)y) + \phi + e^{-i 2 \pi r (\cos(\theta)x+\sin(\theta)y) + \phi} % \intertext{The application of confocal \gls{slit-scanning} was also considered for structured illumination sources where:} % I_{\text{ill}}(x,y,n) = % \begin{split} % &\left(\frac{1}{2} (\cos (2 \pi r ( (\cos \theta)x+( \sin \theta)y + \phi ) )+1)\right) \\ &\cdot H(y-n) \cdot H(-(y-n)+w_{\text{slit}}) % \end{split} \label{eq:sim_ill} % \intertext{Where \(r\) is the frequency, \(\phi \) is the phase and \(\theta \), is the angle of the \gls{SIM} pattern. % Note, that the \(\text{PSF}_\text{ex}\) in \(d(x,y)\) for coherent illumination \gls{SIM} becomes unity as the illumination is generated with interference at the sample plane.} % % At one of 3 angles \(\theta = \frac{k_x}{k_y}\) and one of 3 phases (\(\phi\)). % % \end{gather} % % \begin{gather} % % % For \gls{DSLM} illumination} % % I_{\text{ill}}(x,y,n) &= {I_0} {\left(\frac{w_0}{w{(x+n)}}\right)}^2 {e^{\frac{-2y^2}{w{(x+n)}^2}}} % % \end{gather} % % \begin{gather} % \intertext{For completeness the same simulations were also run for \gls{DSLM} where\(w_0\) is the illumination beam waist and \(w(y+n)\) is the width of the Gaussian illumination beam as in Equation~\ref{eq:Lorrentzian}.} % \intertext{I_{\text{ill}}(x,y,n) &= {I_0} {\left(\frac{w_0}{w{(x+n)}}\right)}^2 {e^{\frac{-2y^2}{w{(x+n)}^2}}} % As the imaging and illumination objective lens are not the same, \(I_{\text{em}}(x,y,n)\) is now established.} % I_{\text{em}}(x,y,n) = \sum_{n=0}^{n=h-1} % \Biggl(\begin{split} % &\left[ (s(x,y) \cdot I_{\text{ill}}(x,y,n)) * \text{PSF}(x,y) \right] \\ &\cdot H(y-n) \cdot H(-(y-n)+w_{\text{slit}}) % \end{split}\Biggr) % \end{gather} \begin{gather} \intertext{For flat wide-field illumination, \(I_{\text{ill}}\) is constant.} I_{\text{ill}}(x,y,n) = {I_0} \intertext{For slit-scanning flat wide-field illumination,} I_{\text{ill}}(x,y,n) = {I_0} \cdot H(y-n) \cdot H(-(y-n)+w_{\text{slit}}) % \intertext{For slit-scanning flat wide-field illumination,} % \end{gather} % \begin{gather} % note, that the \(\text{PSF}_\text{ex}\) for coherent illumination \gls{SIM} becomes unity as the illumination is generated with interference at the sample plane. % shift_cosine_p = exp(-1i*((sim_factor*2*pi*r_est*((cos(a_est).*x+sin(a_est).*y))/(width))+ph_est));)} %1+(\cos(\theta+\phi)x+\sin(\theta+\phi)y) % I_{ill}(x,y,n,r,\theta,\phi) = e^{-i 2 \pi r (\cos(\theta)x+\sin(\theta)y) + \phi + e^{-i 2 \pi r (\cos(\theta)x+\sin(\theta)y) + \phi} \intertext{The application of confocal slit-scanning was also considered for structured illumination sources,} I_{\text{ill}}(x,y,n) = \begin{split} &\left(\frac{1}{2} (\cos (2 \pi r ( (\cos \theta)x+( \sin \theta)y + \phi ) )+1)\right) \\ &\cdot H(y-n) \cdot H(-(y-n)+w_{\text{slit}}) \end{split} \label{eq:sim_ill} \intertext{Where \(r\) is the frequency, \(\phi \) is the phase and \(\theta \), is the angle of the \gls{SIM} pattern. Note, that the \(\text{PSF}_\text{ex}\) in \(d(x,y)\) for coherent illumination \gls{SIM} becomes unity as the illumination is generated with interference at the sample plane.} % At one of 3 angles \(\theta = \frac{k_x}{k_y}\) and one of 3 phases (\(\phi\)). % \end{gather} % \begin{gather} % \intertext{For \gls{DSLM} illumination} % I_{\text{ill}}(x,y,n) = {I_0} {\left(\frac{w_0}{w{(x+n)}}\right)}^2 {e^{\frac{-2y^2}{w{(x+n)}^2}}} % \end{gather} % \begin{gather} \intertext{For completeness the same simulations were also run for \gls{DSLM} where \(w_0\) is the illumination beam waist and \(w(y+n)\) is the width of the Gaussian illumination beam as in Equation~\ref{eq:Lorrentzian}.} I_{\text{ill}}(x,y,n) = {I_0} {\left(\frac{w_0}{w{(y+n)}}\right)}^2 {e^{\frac{-2y^2}{w{(y+n)}^2}}} % \intertext{As the imaging and illumination objective lens are not the same, \(I_{\text{em}}(x,y,n)\) is now established.} % I_{\text{em}}(x,y) = \sum_{n=0}^{n=h-1} % \Biggl(\begin{split} % &\left[ (s(x,y) \cdot I_{\text{ill}}(x,y,n)) * \text{PSF}(x,y) \right] \\ &\cdot H(y-n) \cdot H(-(y-n)+w_{\text{slit}}) % \end{split}\Biggr) \end{gather} % For flat wide-field illumination \(I_{Illumination}(x,y,n) = 1\). % % % \begin{align} % I(r,z) & = {I_0} {\left(\frac{w_0}{w{(z)}}\right)}^2 {e^{\frac{-2r^2}{w{(z)}^2}}\label{eq:GuasianBeam}} \\ % w(z) & = \gls{w_0} \sqrt{1+\frac{z}{z_R}} \label{eq:Lorrentzian} \\ % z_R & = \frac{\pi w^2}{\lambda} \label{eq:Rayleigh} % \end{align} % Initially \gls{slit-scanning} was considered for a flat illumination control across a testcard image, and it was found that a potential doubling of resolution could be attained as in \figurename~\ref{fig:widefield_slit}. % % \gls{slit-scanning} was then applied to the, well-established, structured illumination techniques of \gls{SIM} and \gls{mSIM} % \begin{figure} % \centering % \includegraphics{widefield_slit} % \caption{Simulation of a confocal slit-scanned wide-field or swept light-sheet system. % a) Is the raw, image with b) showing Fourier space and the frequency passband. % c) Shows a the confocal \gls{slit-scanning} in progress and d) shows what the \gls{SLM} will be displaying. % d) is the final image as it would appear after an acquisition and e) is the the new larger OTF is frequency space. % } % \label{fig:widefield_slit} % \end{figure} % \clearpage \begin{figure}[ht] \centering \begin{subfigure}[t]{0.3\textwidth} \centering \begin{tikzpicture}[node distance=0cm] \node (img) {\includegraphics[width=0.75\textwidth]{widefield_slit/widefield.pdf}}; \node[below=of img] {\(x\vphantom{k_x}\)}; \node[left=of img,rotate=90,yshift=0.2cm] {\(y\)}; \end{tikzpicture} % \includegraphics[width=\textwidth]{widefield_slit/widefield} \caption{Widefield} \end{subfigure}\quad \begin{subfigure}[t]{0.3\textwidth} \centering \begin{tikzpicture}[node distance=0cm] \node (img) {\includegraphics[width=0.75\textwidth]{widefield_slit/widefield_fft}}; % \node (img) {\includegraphics[width=0.75\textwidth]{widefield_slit/log_widefield_fft}}; \node[below=of img] {\(k_x\)}; \node[left=of img,rotate=90,yshift=0.2cm] {\(k_y\)}; \end{tikzpicture} % \includegraphics[width=\textwidth]{widefield_slit/widefield_fft} \caption{Widefield \gls{FFT}} \end{subfigure}\\\vspace{\abovecaptionskip} \begin{subfigure}[t]{0.3\textwidth} \centering \begin{tikzpicture}[node distance=0cm] \node (img) {\includegraphics[width=0.75\textwidth]{widefield_slit/slitscanned_partial}}; \node[below=of img] {\(x\vphantom{k_x}\)}; \node[left=of img,rotate=90,yshift=0.2cm] {\(y\)}; \end{tikzpicture} % \includegraphics[width=\textwidth]{widefield_slit/slitscanned_partial} \caption{Partially scanned slit} \end{subfigure}\quad \begin{subfigure}[t]{0.3\textwidth} \centering \begin{tikzpicture}[node distance=0cm] \node (img) {\includegraphics[width=0.75\textwidth]{widefield_slit/illiumination_partial}}; \node[below=of img] {\(x\vphantom{k_x}\)}; \node[left=of img,rotate=90,yshift=0.2cm] {\(y\)}; \end{tikzpicture} % \includegraphics[width=\textwidth]{widefield_slit/illiumination_partial} \caption{Illumination pattern} \end{subfigure}\\\vspace{\abovecaptionskip} \begin{subfigure}[t]{0.3\textwidth} \centering \begin{tikzpicture}[node distance=0cm] \node (img) {\includegraphics[width=0.75\textwidth]{widefield_slit/slitscanned.pdf}}; \node[below=of img] {\(x\vphantom{k_x}\)}; \node[left=of img,rotate=90,yshift=0.2cm] {\(y\)}; \end{tikzpicture} % \includegraphics[width=\textwidth]{widefield_slit/slitscanned} \caption{Slit-scanned image} \end{subfigure}\quad \begin{subfigure}[t]{0.3\textwidth} \centering \begin{tikzpicture}[node distance=0cm] \node (img) {\includegraphics[width=0.75\textwidth]{widefield_slit/slitscanning_fft}}; % \node (img) {\includegraphics[width=0.75\textwidth]{widefield_slit/log_slitscanning_fft}}; \node[below=of img] {\(k_x\)}; \node[left=of img,rotate=90,yshift=0.2cm] {\(k_y\)}; \end{tikzpicture} % \includegraphics[width=\textwidth]{widefield_slit/slitscanning_fft} \caption{Slit-scanning \gls{FFT}} \end{subfigure} % \includegraphics{widefield_slit} \caption[Simulation of a confocal slit-scanned wide-field or swept light-sheet system]{ Simulation of a confocal slit-scanned wide-field or swept light-sheet system. (a) is the a raw wide-field image of the test sample, with (b) showing Fourier space and the frequency passband. (c) shows the confocal \gls{slit-scanning} in progress at some time-point about \SI{\sim80}{\percent} of the way through a single exposure; (d) shows what the \gls{SLM} will be displaying at this time-point. (e) is the final image as it would appear after an acquisition and (f) is the the new \gls{OTF} with a larger support in \(y\) corresponding to finer y-resolution in (e). }\label{fig:widefield_slit} \end{figure} \subsection{\Gls{slit-scanning} \gls{SIM}} In the case of \gls{SIM} and \gls{mSIM}, patterned light is projected onto a sample so that a resolution doubling can be achieved after a reconstruction step, as discussed in Chapter~\ref{chapter:principles}. \gls{SIM} relies on spatial frequency mixing to shift high resolution information from outside the pass band of the objective into the observable. % , reminiscent of a heterodyne. High contrast fringes are needed so that sharp peaks can be localised from the sinusoidal illumination pattern in Fourier space. Fringe contrast in real-space corresponds to \gls{SNR} of these peaks. An accurate \gls{SIM} reconstruction requires the spatial frequency (\(\mathbf{k}\)) vectors of the illumination to be precisely recovered. % To recover the shift (\(\mathbf{k}\)) vectors in frequency space, sharp peaks are localised from the sinusoidal illumination pattern. %To reliably reconstruct a SIM image, high contrast fringes are needed to very accurately localise their points in Fourier space as fringe contrast in image space corresponds to the amplitude of the delta functions of a sinusoid in Fourier space.. If the estimation of these parameters is inaccurate, computationally inverting the frequency mixing of the illumination and the sample results in artefacts in the reconstructed image. As discussed, \gls{slit-scanning} has the potential to increase the raw image contrast without sacrificing speed of acquisition. Achieving this slit-scanning in \gls{SIM} requires a fast ferroelectric \gls{SLM}, with a refresh rate better than the imaging camera. For slit-scanning \gls{SIM}, as in slit-scanning \gls{wide-field}, a row of active pixels is swept during an exposure but now this pattern is the product of a standard set of \gls{SIM} patterns as shown in \figurename~\ref{fig:sim_slit}. For these simulations, 9 unique patterns were used, 3 oriented patterns with each 3 phases; though fewer can be used\cite{strohlSpeedLimitsStructured2017}. Slit-scanned \gls{SIM} simulations of a test image were successfully reconstructed, as seen in \figurename~\ref{fig:sim_slit_reconstructed}, with the spatial illumination from Equation~\eqref{eq:sim_ill} at one of 3 angles \(\theta \) and one of 3 phases (\(\phi \)). % \begin{align} % % \intertext{For \gls{SIM} illumination:} % I_{\text{ill}}(x,y,n) &= {I_0} [1 + \cos(k_x x + k_y y + \phi] \cdot H(y-n) \cdot H(-(y-n)+w_{\text{slit}}) % \end{align} % \begin{figure} % \centering % \includegraphics{sim_slit} % \caption{a) Optical diagram for \gls{SLM} implementation of dual-beam \gls{slit-scanning}. % b) Diagram showing a much simplified approach for creating two beams optically with minimal loss of photons, light-polarisation insensitivity and without the need for an \gls{SLM}.} % \label{fig:sim_slit} % \end{figure} \begin{figure}[ht!] \centering \begin{subfigure}[t]{0.23\textwidth} \centering % \includegraphics[width=\textwidth]{sim_slit/1/vert_pattern} % \caption{Illumination pattern} Total illumination \end{subfigure}\hfill \begin{subfigure}[t]{0.23\textwidth} \centering % \includegraphics[width=\textwidth]{sim_slit/1/sim_vert_frame} % \caption{Widefield} Recorded image \end{subfigure}\hfill \begin{subfigure}[t]{0.23\textwidth} \centering % \includegraphics[width=\textwidth]{sim_slit/1/sim_slit_pattern} % \caption{Widefield \gls{FFT}} Single SLM frame \end{subfigure}\hfill \begin{subfigure}[t]{0.23\textwidth} \centering % \includegraphics[width=\textwidth]{sim_slit/1/fft} % \caption{Partially scanned slit} \gls{FFT} of image \end{subfigure}\\\vspace{\abovecaptionskip} \begin{subfigure}[t]{0.23\textwidth} \centering \includegraphics[width=\textwidth]{sim_slit/1/vert_pattern} \caption{} \end{subfigure}\hfill \begin{subfigure}[t]{0.23\textwidth} \centering \includegraphics[width=\textwidth]{sim_slit/1/sim_vert_frame} \caption{} \end{subfigure}\hfill \begin{subfigure}[t]{0.23\textwidth} \centering \includegraphics[width=\textwidth]{sim_slit/1/sim_slit_pattern} \caption{} \end{subfigure}\hfill \begin{subfigure}[t]{0.23\textwidth} \centering \includegraphics[width=\textwidth]{sim_slit/1/fft} \caption{} \end{subfigure}\\\vspace{\abovecaptionskip} \begin{subfigure}[t]{0.23\textwidth} \centering \includegraphics[width=\textwidth]{sim_slit/2/angle_pattern} \caption{} \end{subfigure}\hfill \begin{subfigure}[t]{0.23\textwidth} \centering \includegraphics[width=\textwidth]{sim_slit/2/sim_angle_frame} \caption{} \end{subfigure}\hfill \begin{subfigure}[t]{0.23\textwidth} \centering \includegraphics[width=\textwidth]{sim_slit/2/sim_slit_pattern} \caption{} \end{subfigure}\hfill \begin{subfigure}[t]{0.23\textwidth} \centering \includegraphics[width=\textwidth]{sim_slit/2/fft} \caption{} \end{subfigure}\\\vspace{\abovecaptionskip} \begin{subfigure}[t]{0.23\textwidth} \centering \includegraphics[width=\textwidth]{sim_slit/3/vert_pattern} \caption{} \end{subfigure}\hfill \begin{subfigure}[t]{0.23\textwidth} \centering \includegraphics[width=\textwidth]{sim_slit/3/sim_vert_frame} \caption{} \end{subfigure}\hfill \begin{subfigure}[t]{0.23\textwidth} \centering \includegraphics[width=\textwidth]{sim_slit/3/sim_slit_pattern} \caption{} \end{subfigure}\hfill \begin{subfigure}[t]{0.23\textwidth} \centering \includegraphics[width=\textwidth]{sim_slit/3/fft} \caption{} \end{subfigure} % \includegraphics{widefield_slit} \caption[Simulations of slit-scanning \gls{SIM} during acquisition]{ Simulations of slit-scanning \gls{SIM} during acquisition. (a),~(e) and (i) are the three \gls{SIM} angles commonly used for reconstruction. (b),~(f) and (j) are these illuminations during a partial single frame exposure and (c),~(g) and (k) are the respective patterns as displayed on an \gls{SLM}. The computed recorded frames from (b),~(f) and (j) have Fourier space representations (d),~(h) and (l) from which a high resolution \gls{SIM} reconstruction can be obtained. Givingg he final images (d),~(h) and (l) as seen in frequency space with the larger \gls{OTF} support. }\label{fig:sim_slit} \end{figure} \begin{figure}[ht!] \centering \begin{subfigure}[t]{0.3\textwidth} \centering \begin{tikzpicture}[node distance=0cm] \node (img) {\includegraphics[width=0.75\textwidth]{sim_slit/recon/input}}; \node[below=of img] {\(x\vphantom{k_x}\)}; \node[left=of img,rotate=90,yshift=0.2cm] {\(y\)}; \end{tikzpicture} % \includegraphics[width=\textwidth]{sim_slit/recon/input} \caption{Projected, 9 raw images} \end{subfigure}\quad \begin{subfigure}[t]{0.3\textwidth} \centering \begin{tikzpicture}[node distance=0cm] \node (img) {\includegraphics[width=0.75\textwidth]{sim_slit/recon/FFT_input}}; \node[below=of img] {\(k_x\)}; \node[left=of img,rotate=90,yshift=0.2cm] {\(k_y\)}; \end{tikzpicture} % \includegraphics[width=\textwidth]{sim_slit/recon/FFT_input} \caption{\gls{FFT}, 1 angle + 3 phases} \end{subfigure}\\\vspace{\abovecaptionskip} \begin{subfigure}[t]{0.3\textwidth} \centering \begin{tikzpicture}[node distance=0cm] \node (img) {\includegraphics[width=0.75\textwidth]{sim_slit/recon/reconstruction_no_attenuation-1}}; \node[below=of img] {\(x\vphantom{k_x}\)}; \node[left=of img,rotate=90,yshift=0.2cm] {\(y\)}; \end{tikzpicture} % \includegraphics[width=\textwidth]{sim_slit/recon/reconstruction_no_attenuation-1} \caption{Reconstructed, 9 raw images} \end{subfigure}\quad \begin{subfigure}[t]{0.3\textwidth} \centering \begin{tikzpicture}[node distance=0cm] \node (img) {\includegraphics[width=0.75\textwidth]{sim_slit/recon/FFT_reconstruction_no_attenuation}}; \node[below=of img] {\(k_x\)}; \node[left=of img,rotate=90,yshift=0.2cm] {\(k_y\)}; \end{tikzpicture} % \includegraphics[width=\textwidth]{sim_slit/recon/FFT_reconstruction_no_attenuation} \caption{\gls{FFT}, 3 angles and 3 phases} \end{subfigure} % \includegraphics{widefield_slit} \caption[Slit-SIM images as reconstructed using fairSIM]{ Slit-scanning \gls{SIM} images as reconstructed using fairSIM.\@ (a), the projected sum of the 9 raw \gls{SIM} images with (b), the complimentary Fourier space image which shows the diffraction limited information along the horizontal. (c), the slit-SIM reconstruction with (d), the Fourier space image showing the OTF support being extended along the horizontal. }\label{fig:sim_slit_reconstructed} \end{figure} \subsection{Slit-scanning \gls{mSIM}} The same principle for \gls{slit-scanning} \gls{SIM} can be also be applied to \gls{mSIM}, which was presented in Section~\ref{sec:msim}. In \gls{slit-scanning} \gls{mSIM}, during each exposure, the \gls{SLM} will display a single row of illumination spots from the full lattice with a standard \gls{mSIM} pattern. This row is then swept synchronously with the virtual slit as with slit-\gls{SIM}. For the proceeding exposure, the line of point illuminators is iterated in the orthogonal direction to the propagating shutter. The act of using a virtual slit on the camera reduces the dimensionality of the reconstruction of an \gls{mSIM} image, drastically increasing the speed of an acquisition without the need for additional optics. Ordinarily, the virtual pin-holing step is achieved computational by reconstructing from an \(n\times n\) (\(O(n^2)\)) set of images; using \gls{slit-scanning} the reconstruction reduces to \(n \) (\(O(n)\)) operations. Schroff~\emph{et.~al}, for instance, require \SI{200x200}{} images for a single \gls{mSIM} reconstruction~\cite{yorkResolutionDoublingLive2012}. The method proposed here, would potentially increase the speed of this process by \SI{200}{} fold. % This is however dwarfed by \gls{iSIM}, which gives instantaneous super-resolved images at the cost of requiring extensive additional optics\cite{yorkInstantSuperresolutionImaging2013}. %\Gls{slit-scanning} mSIm was considered whereby the number of images to be reconstructed in the final image was square-rooted. % In \gls{mSIM}, ordinarily, the virtual pin-holing step is achieved computational by reconstructing from an \(n\times n\) (\(O(n^2\)) set of images; using \gls{slit-scanning} the reconstruction reduces from to \(n \) (\(O(n)\)) operations. Through computer simulation it was shown, in \figurename~\ref{fig:msim_slit}, that the \gls{OTF} support of the reconstructed \gls{mSIM} image increases in one direction up to \SI{2}{} fold in ideal theoretical conditions, using a slit width (\(w_{\text{slit}}\)) of one pixel. Using fewer images can reduce the amount of acquisition time needed, but as \gls{slit-scanning} does reject photons there may be a trade-off in real samples when acquiring a sufficient number of photons to reconstruct an image, potentially increasing exposure times. % \begin{figure} % \centering % \includegraphics{msim_slit} % \caption{ % a) The capturing of a single \gls{mSIM} frame; % b) \gls{mSIM} illumination pattern as it rolls; % c) reconstructed slit-\gls{mSIM} image; % d) \gls{OTF} of a single \gls{mSIM} frame; % e) \gls{OTF} of reconstructed slit-gls{mSIM} frame % } % \label{fig:msim_slit} % \end{figure} \begin{figure}[ht!] \centering \begin{subfigure}[t]{0.3\textwidth} \centering \begin{tikzpicture}[node distance=0cm] \node (img) {\includegraphics[width=0.75\textwidth]{msim_slit/single_progress}}; \node[below=of img] {\(x\vphantom{k_x}\)}; \node[left=of img,rotate=90,yshift=0.2cm] {\(y\)}; \end{tikzpicture} % \includegraphics[width=\textwidth]{msim_slit/single_progress} \caption{The capturing of a single \gls{mSIM} frame} \end{subfigure}\quad \begin{subfigure}[t]{0.3\textwidth} \centering \begin{tikzpicture}[node distance=0cm] \node (img) {\includegraphics[width=0.75\textwidth]{msim_slit/single_illumination_contrast}}; \node[below=of img] {\(x\vphantom{k_x}\)}; \node[left=of img,rotate=90,yshift=0.2cm] {\(y\)}; \end{tikzpicture} % \includegraphics[width=\textwidth]{msim_slit/single_illumination_contrast} \caption{\gls{mSIM} illumination pattern as it rolls} \end{subfigure}\quad \begin{subfigure}[t]{0.3\textwidth} \centering \begin{tikzpicture}[node distance=0cm] \node (img) {\includegraphics[width=0.75\textwidth]{msim_slit/fft_single}}; \node[below=of img] {\(k_x\)}; \node[left=of img,rotate=90,yshift=0.2cm] {\(k_y\)}; \end{tikzpicture} % \includegraphics[width=\textwidth]{msim_slit/fft_single} \caption{The \gls{OTF} of a single \gls{mSIM} frame} \end{subfigure}\\\vspace{\abovecaptionskip} \begin{subfigure}[t]{0.3\textwidth} \centering \begin{tikzpicture}[node distance=0cm] \node (img) {\includegraphics[width=0.75\textwidth]{msim_slit/msim_recon}}; \node[below=of img] {\(x\vphantom{k_x}\)}; \node[left=of img,rotate=90,yshift=0.2cm] {\(y\)}; \end{tikzpicture} % \includegraphics[width=\textwidth]{msim_slit/msim_recon} \caption{The reconstructed slit-\gls{mSIM} image;} \end{subfigure}\quad \begin{subfigure}[t]{0.3\textwidth} \centering \hspace{\textwidth} % \includegraphics[width=\textwidth]{} % \caption{} \end{subfigure}\quad \begin{subfigure}[t]{0.3\textwidth} \centering \begin{tikzpicture}[node distance=0cm] \node (img) {\includegraphics[width=0.75\textwidth]{msim_slit/msim_recon_fft}}; \node[below=of img] {\(k_x\)}; \node[left=of img,rotate=90,yshift=0.2cm] {\(y\)}; \end{tikzpicture} % \includegraphics[width=\textwidth]{msim_slit/msim_recon_fft} \caption{The \gls{FFT} of a reconstructed slit-\gls{mSIM} frame, now with a wider \gls{OTF} support.} \end{subfigure} % \includegraphics{widefield_slit} \caption[Simulated slit-scanning \gls{mSIM} images during an acquisition]{ Simulated slit-scanning \gls{mSIM} images during an acquisition. The process of acquiring a simulated slit-scanning \gls{mSIM} image providing a wider \gls{OTF} support which requried few captured image frames. }\label{fig:msim_slit} \end{figure} % \subsection{\Gls{slit-scanning} simulated computationally} % % \begin{figure} % \centering % \includegraphics{sim_slit_reconstructed} % \caption{slit-SIM images as reconstructed using fairSIM. % a) The sum projected image of the 9 raw SIM images; % b) with the complimentary Fourier space image, showing diffraction limited information in the horizontal. % c) The slit-SIM reconstruction; % d) with the Fourier space image showing how the OTF support, along the horizontal, has been extended beyond the diffraction limit.} % \label{fig:sim_slit_reconstructed} % \end{figure} \section{Discussion and future work} \subsection{Dual \gls{slit-scanning}} Confocal \gls{slit-scanning} can now be achieved at full \SI{100}{\hertz} imaging rates and so could be applied to fast dynamic processes in need of contrast and axial resolution improvements. The intent with this work was to apply the improvement provided by \gls{slit-scanning} to \gls{SPT}, as precise time resolution is essential for characterising motion; similarly a large field of \gls{FOV} would mean particles can be tracked for longer times periods of time. %allows for tracks to be recorded over longer epochs % An alternative techniques In having two independently addressable sensors, another technique which can be implemented is chromatically separating the two channels on to each of the sensors, providing simultaneous two colour \SI{100}{\hertz} imaging. % is to chromatically separate channels onto each of the chips, for simultaneous two colour \SI{100}{\hertz} imaging. Such image splitting devices are commercially available\cite{EmissionImageSplitter}%, with the trade-off of \gls{FOV} for time-resolution. Due to the additional optics added to the light-sheet system for the astigmatic tracking module, there was not sufficient space to investigate this technique further. \subsection{Structured illumination \gls{slit-scanning}} The effect of confocal \gls{slit-scanning} was demonstrated \emph{in silico}, to verify the expectation that resolution and contrast could be improved. %using confocal \gls{slit-scanning}. This was considered, for the first time, both for systems imaging orthogonally, such as is light-sheet microscopy, as well for epi-illumination systems with control over the the illumination structure. % This would be realised by running an SLM at \SI{}{\kilo\hertz} rates, which is feasible for ferroelectric devices. The simulations technique presented here can be immediately adapted onto microscope systems with \gls{SLM}s already embedded, provided there is intensity (rather than phase) control at the sample plane. For a \SI{512x512}{\text{px}} \gls{FOV}, at \SI{40}{\milli\second} exposure, the \gls{SLM} would need to be run at \SI{12.8}{\kilo\hertz} which is only viable for ferroelectric liquid crystal \gls{SLM}s. % For \gls{slit-scanning}-SIM to become valuable, a full rotational asymmetric reconstruction algorithm will need to be written which incorporates the potential one-directional resolution increase seen in the OTFs. Reconstructions for \gls{SIM} were achieved using fairSIM, an open-source \gls{SIM} reconstruction package implemented in Java for ImageJ~\cite{mullerOpensourceImageReconstruction2016a}. However, fairSIM assumes that each angle provided will have the same size \gls{OTF} at each illumination angle. When using \gls{slit-scanning} the \gls{OTF} support becomes larger in the direction of the rolling shutter; as such fairSIM, though it reconstructs successfully, omits additional resolution in one direction. To realise \gls{slit-scanning} \gls{SIM}, a custom reconstruction algorithm will be needed to maximally fill the reconstructed frequency space, by using asymmetric \gls{OTF}s. It was expected that the contrast improvement in \gls{SIM} would be the primary benefit to the technique. However, it may be possible exploit the increase in resolution in one direction to increase the resolution of \gls{SIM} further. Currently fairSIM only considers possible \gls{OTF} supports which have rotational symmetry. The addition of confocal \gls{slit-scanning} means that, though the reconstruction is successful, higher resolution information afforded by \gls{slit-scanning}, is neglected. Going further, it may be possible in a real system to display a very fine (beyond the frequency cut-off of the objective lens) \gls{SIM} pattern in the direction of confocal \gls{slit-scanning}. The Moirè fringes of this image would ordinarily be blurred to the point where the \gls{SIM} pattern in Fourier space would be outside of the passband. Using \gls{slit-scanning} with \gls{SIM} may allow the recovery of these fringes, for reconstruction, potentially giving up to a \SI{4}{\times} resolution improvement, with better optical sectioning and contrast. Using slit-scanning could reveal sinusoidal peaks at \(2k_0 \), though an illumination objective lens double the \gls{NA} of the detection objective lens would be needed. Or, it would be possible to generate a very fine illumination pattern using surface plasmons created on a substrate~\cite{weiPlasmonicStructuredIllumination2010} and selectively illuminated using an \gls{SLM} in a synchronised slit-scanning fashion. The following chapter will present a novel and customisable 3D printed sample chamber for use with large objective lenses. This chamber will be used during the remainder of the work for biological sample mounting and incubation. % illumination objective would % Generating such a fine pattern would be challenging and would likely rely on. %a full dark state can be realised %Dual slit work %% Attempt in real samples, apply to virus tracking. %Apple to real microscopes, should be a free upgrade as it is only computational. % Calculate refresh rate for 512 px %OTF has a funny shape %Interestingly the OTF, in the direction that ungoes a post-processing reconstruction, %future work, make an algorithm that works with SIM-slit-slit_scanning_alt %Demonstrated that \gls{slit-scanning} does improvement %The assumptions made here are that the imaging system is ideal, that imaging is only a frequency passband and that the axial is infinity thin. %There exist adapters to split the image on the chip into two colours, could use \gls{slit-scanning} for that, though no room for tuning.
# # Run package tests # # run from the temp directory, as tests output a bunch of files... setwd("/var/tmp") sapply(installed.packages()[,"Package"], tools::testInstalledPackage) list.files()
[STATEMENT] lemma continuous_on_compose[continuous_intros]: "continuous_on s f \<Longrightarrow> continuous_on (f ` s) g \<Longrightarrow> continuous_on s (g \<circ> f)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>continuous_on s f; continuous_on (f ` s) g\<rbrakk> \<Longrightarrow> continuous_on s (g \<circ> f) [PROOF STEP] unfolding continuous_on_topological [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>\<forall>x\<in>s. \<forall>B. open B \<longrightarrow> f x \<in> B \<longrightarrow> (\<exists>A. open A \<and> x \<in> A \<and> (\<forall>y\<in>s. y \<in> A \<longrightarrow> f y \<in> B)); \<forall>x\<in>f ` s. \<forall>B. open B \<longrightarrow> g x \<in> B \<longrightarrow> (\<exists>A. open A \<and> x \<in> A \<and> (\<forall>y\<in>f ` s. y \<in> A \<longrightarrow> g y \<in> B))\<rbrakk> \<Longrightarrow> \<forall>x\<in>s. \<forall>B. open B \<longrightarrow> (g \<circ> f) x \<in> B \<longrightarrow> (\<exists>A. open A \<and> x \<in> A \<and> (\<forall>y\<in>s. y \<in> A \<longrightarrow> (g \<circ> f) y \<in> B)) [PROOF STEP] by simp metis
export parselog function parselog(logfile::String, verbose::Bool) verbose && println("CPUMonitor: Begin Parsing Log...") # Read log file as array with " " delim log = readdlm(logfile) # Find unique process IDs pids = unique(log[:,1]) count = 1 stat = Array{CPUStat,1}(length(pids)) # Collect stats from each PID into an instance of CPUStat for pid in pids inds = find(x -> x == pid, log[:,1]) stat[count] = CPUStat(pid, log[inds, 9], log[inds, 10]) count += 1 end verbose && println("CPUMonitor: End Parsing Log...") return stat end
module Test.Suite import IdrTest.Test import Test.Inigo.Account.AccountTest import Test.Inigo.Archive.ArchiveTest import Test.Inigo.Package.PackageDepsTest import Test.Inigo.Package.PackageIndexTest import Test.Inigo.Package.PackageTest import Test.Server.Template.TemplateTest suite : IO () suite = do runSuites [ Test.Inigo.Account.AccountTest.suite , Test.Inigo.Archive.ArchiveTest.suite , Test.Inigo.Package.PackageDepsTest.suite , Test.Inigo.Package.PackageIndexTest.suite , Test.Inigo.Package.PackageTest.suite , Test.Server.Template.TemplateTest.suite ]
State Before: α : Type ?u.1029930 ⊢ ∀ (a b : ZNum), a * b = b * a State After: no goals Tactic: transfer
module Test.Suite import IdrTest.Test import Test.Toml.DataTest import Test.Toml.LexerTest import Test.TomlTest suite : IO () suite = do runSuites [ Test.Toml.LexerTest.suite , Test.Toml.DataTest.suite , Test.TomlTest.suite ]
\documentclass{article} \begin{document} \section{Block} \begin{equation} e^{i\pi}=-1 \label{eq:euler} \end{equation} Equation~\ref{eq:euler} is some good math. \section{Inline} some lovely maths \(x^2 + y^2 = z^2\) \end{document}
lemma emeasure_INT_decseq_subset: fixes F :: "nat \<Rightarrow> 'a set" assumes I: "I \<noteq> {}" and F: "\<And>i j. i \<in> I \<Longrightarrow> j \<in> I \<Longrightarrow> i \<le> j \<Longrightarrow> F j \<subseteq> F i" assumes F_sets[measurable]: "\<And>i. i \<in> I \<Longrightarrow> F i \<in> sets M" and fin: "\<And>i. i \<in> I \<Longrightarrow> emeasure M (F i) \<noteq> \<infinity>" shows "emeasure M (\<Inter>i\<in>I. F i) = (INF i\<in>I. emeasure M (F i))"
syntax:65 (name := myAdd1) term "+++" term:65 : term syntax:65 (name := myAdd2) term "+++" term:65 : term macro_rules (kind := myAdd1) | `($a +++ $b) => `(Nat.add $a $b) macro_rules (kind := myAdd2) | `($a +++ $b) => `(Append.append $a $b) #check (1:Nat) +++ 3 theorem tst1 : ((1:Nat) +++ 3) = 1 + 3 := rfl #check fun (x : Nat) => if x +++ 3 = x then x else x + 1 #check [1, 2] +++ [3, 4] theorem tst2 : ([1, 2] +++ [3, 4]) = [1, 2] ++ [3, 4] := rfl
Delivered Hunter 7/12/44; Dow Fd 21/12/44; Assigned 327BS/92BG [UX-E] Podington 4/3/45; Missing in Action Dresden 17/4/45 with John Paul, Pete Taylor (2 Prisoner of War); Nathan Shane, E.J. Pruit, Reinhold Hoffman, Joe Budzius, Tom Shanahan, Bradford Mathewson (6 Killed in Action); mid air coll with 44-8903; crashed near Dresden; Missing Air Crew Report 14053. NAUGHTY NANCY.
[STATEMENT] lemma ex_minimal_witness[consumes 1, case_names Minimal]: assumes "\<exists> k. P (k::nat)" and "\<And> K. P K \<Longrightarrow> (\<And> k. k < K \<Longrightarrow> \<not> (P k)) \<Longrightarrow> Q" shows "Q" [PROOF STATE] proof (prove) goal (1 subgoal): 1. Q [PROOF STEP] proof - [PROOF STATE] proof (state) goal (1 subgoal): 1. Q [PROOF STEP] from assms minimal_witness_ex [PROOF STATE] proof (chain) picking this: \<exists>k. P k \<lbrakk>P ?K; \<And>k. k < ?K \<Longrightarrow> \<not> P k\<rbrakk> \<Longrightarrow> Q ?P ?k \<Longrightarrow> \<exists>k0\<le>?k. ?P k0 \<and> (\<forall>k<k0. \<not> ?P k) [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) using this: \<exists>k. P k \<lbrakk>P ?K; \<And>k. k < ?K \<Longrightarrow> \<not> P k\<rbrakk> \<Longrightarrow> Q ?P ?k \<Longrightarrow> \<exists>k0\<le>?k. ?P k0 \<and> (\<forall>k<k0. \<not> ?P k) goal (1 subgoal): 1. Q [PROOF STEP] by metis [PROOF STATE] proof (state) this: Q goal: No subgoals! [PROOF STEP] qed
! ! SDF (Self-Describing Format) Fortran Library ! Copyright (c) 2013-2016, SDF Development Team ! ! Distributed under the terms of the BSD 3-clause License. ! See the LICENSE file for details. ! MODULE sdf_input_station USE sdf_input_station_ru USE sdf_input_station_r4 USE sdf_input_station_r8 IMPLICIT NONE INTERFACE sdf_read_station_array MODULE PROCEDURE & read_station_array_r4_r4, & read_station_array_r8_r4, & read_station_array_r4_r8, & read_station_array_r8_r8 END INTERFACE sdf_read_station_array END MODULE sdf_input_station
/- Copyright (c) 2016 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Author: Leonardo de Moura -/ prelude import Init.Data.UInt.Basic /-- Determines if the given integer is a valid [Unicode scalar value](https://www.unicode.org/glossary/#unicode_scalar_value). Note that values in `[0xd800, 0xdfff]` are reserved for [UTF-16 surrogate pairs](https://en.wikipedia.org/wiki/Universal_Character_Set_characters#Surrogates). -/ @[inline, reducible] def isValidChar (n : UInt32) : Prop := n < 0xd800 ∨ (0xdfff < n ∧ n < 0x110000) namespace Char protected def lt (a b : Char) : Prop := a.val < b.val protected def le (a b : Char) : Prop := a.val ≤ b.val instance : LT Char := ⟨Char.lt⟩ instance : LE Char := ⟨Char.le⟩ instance (a b : Char) : Decidable (a < b) := UInt32.decLt _ _ instance (a b : Char) : Decidable (a ≤ b) := UInt32.decLe _ _ /-- Determines if the given nat is a valid [Unicode scalar value](https://www.unicode.org/glossary/#unicode_scalar_value).-/ abbrev isValidCharNat (n : Nat) : Prop := n < 0xd800 ∨ (0xdfff < n ∧ n < 0x110000) theorem isValidUInt32 (n : Nat) (h : isValidCharNat n) : n < UInt32.size := by match h with | Or.inl h => apply Nat.lt_trans h decide | Or.inr ⟨_, h₂⟩ => apply Nat.lt_trans h₂ decide theorem isValidChar_of_isValidChar_Nat (n : Nat) (h : isValidCharNat n) : isValidChar (UInt32.ofNat' n (isValidUInt32 n h)) := match h with | Or.inl h => Or.inl h | Or.inr ⟨h₁, h₂⟩ => Or.inr ⟨h₁, h₂⟩ theorem isValidChar_zero : isValidChar 0 := Or.inl (by decide) /-- Underlying unicode code point as a `Nat`. -/ @[inline] def toNat (c : Char) : Nat := c.val.toNat instance : Inhabited Char where default := 'A' /-- Is the character a space (U+0020) a tab (U+0009), a carriage return (U+000D) or a newline (U+000A)? -/ def isWhitespace (c : Char) : Bool := c = ' ' || c = '\t' || c = '\r' || c = '\n' /-- Is the character in `ABCDEFGHIJKLMNOPQRSTUVWXYZ`? -/ def isUpper (c : Char) : Bool := c.val ≥ 65 && c.val ≤ 90 /-- Is the character in `abcdefghijklmnopqrstuvwxyz`? -/ def isLower (c : Char) : Bool := c.val ≥ 97 && c.val ≤ 122 /-- Is the character in `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`? -/ def isAlpha (c : Char) : Bool := c.isUpper || c.isLower /-- Is the character in `0123456789`? -/ def isDigit (c : Char) : Bool := c.val ≥ 48 && c.val ≤ 57 /-- Is the character in `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`? -/ def isAlphanum (c : Char) : Bool := c.isAlpha || c.isDigit /-- Convert an upper case character to its lower case character. Only works on basic latin letters. -/ def toLower (c : Char) : Char := let n := toNat c; if n >= 65 ∧ n <= 90 then ofNat (n + 32) else c /-- Convert a lower case character to its upper case character. Only works on basic latin letters. -/ def toUpper (c : Char) : Char := let n := toNat c; if n >= 97 ∧ n <= 122 then ofNat (n - 32) else c end Char
data ⊥ : Set where postulate M : Set → Set A : Set _>>=_ : ∀ {A B} → M A → (A → M B) → M B ma : M A f : A → M ⊥ pure : ∀ {A} → A → M A absurd-do : ∀ {A} → M A absurd-do = do x ← ma () ← f x atabsurd-do : ∀ {A} → M A atabsurd-do = do x ← ma (y@()) ← f x -- I don't know why you would do that but we can support it
import tactic.interactive lemma a {α} [nonempty α] : ∃ a : α, a = a := by inhabit α; use default _; refl noncomputable def b {α} [nonempty α] : α := by inhabit α; apply default lemma c {α} [nonempty α] : ∀ n : ℕ, ∃ b : α, n = n := by inhabit α; intro; use default _; refl noncomputable def d {α} [nonempty α] : ∀ n : ℕ, α := by inhabit α; intro; apply default
Require Import Setoid Coq.Program.Basics. Global Open Scope program_scope. Axiom foo : forall A (f : A -> A), f ∘ f = f. Require Import Coq.Program.Combinators. Hint Rewrite foo. Theorem t {A B C D} (f : A -> A) (g : B -> C) (h : C -> D) : f ∘ f = f. Proof. rewrite_strat topdown (hints core).
""" $(TYPEDEF) """ struct NonlinearSolution{T,N,uType,R,P,A,O,uType2} <: AbstractNonlinearSolution{T,N} u::uType resid::R prob::P alg::A retcode::Symbol original::O left::uType2 right::uType2 end const SteadyStateSolution = NonlinearSolution function build_solution(prob::AbstractNonlinearProblem, alg,u,resid;calculate_error = true, retcode = :Default, original = nothing, left = nothing, right = nothing, kwargs...) T = eltype(eltype(u)) N = length((size(prob.u0)...,)) NonlinearSolution{T,N,typeof(u),typeof(resid), typeof(prob),typeof(alg),typeof(original),typeof(left)}( u,resid,prob,alg,retcode,original,left,right) end function sensitivity_solution(sol::AbstractNonlinearSolution,u) T = eltype(eltype(u)) N = length((size(sol.prob.u0)...,)) NonlinearSolution{T,N,typeof(u),typeof(sol.resid), typeof(sol.prob),typeof(sol.alg), typeof(sol.original),typeof(sol.left)}( u,sol.resid,sol.prob,sol.alg,sol.retcode,sol.original,sol.left,sol.right) end
import category_theory.limits.shapes.images import algebraic_topology.simplex_category import tactic.equiv_rw import category_theory.limits.shapes.regular_mono noncomputable theory /- universes u namespace category_theory lemma concrete_category.bijective_of_is_iso {C : Type*} [category C] [concrete_category C] {X Y : C} (f : X ⟶ Y) [is_iso f] : function.bijective ((forget _).map f) := by { rw ← is_iso_iff_bijective, apply_instance, } lemma strong_epi_of_is_split_epi {C : Type*} [category C] {A B : C} (f : A ⟶ B) [is_split_epi f] : strong_epi f := strong_epi.mk' begin introsI X Y z hz u v sq, exact comm_sq.has_lift.mk' { l := section_ f ≫ u, fac_left' := by simp only [← cancel_mono z, sq.w, category.assoc, is_split_epi.id_assoc], fac_right' := by simp only [sq.w, category.assoc, is_split_epi.id_assoc], } end variables {C D : Type*} [category C] [category D] (F : C ⥤ D) {A B : C} (f : A ⟶ B) namespace functor def is_split_epi_iff [full F] [faithful F] : is_split_epi f ↔ is_split_epi (F.map f) := begin split, { intro h, refine is_split_epi.mk' ((split_epi_equiv F f).to_fun h.exists_split_epi.some), }, { intro h, refine is_split_epi.mk' ((split_epi_equiv F f).inv_fun h.exists_split_epi.some), }, end variable {F} lemma strong_epi_imp_strong_epi_map_of_adjunction {F' : D ⥤ C} (adj : F ⊣ F') (f : A ⟶ B) [h₁ : preserves_monomorphisms F'] [h₂ : preserves_epimorphisms F] : strong_epi f → strong_epi (F.map f) := begin introI hf, refine ⟨infer_instance, _⟩, intros X Y z, introI, rw has_lifting_property.iff_of_adjunction adj, apply_instance, end instance strong_epi_map_of_is_equivalence [is_equivalence F] [h : strong_epi f] : strong_epi (F.map f) := strong_epi_imp_strong_epi_map_of_adjunction ((as_equivalence F).to_adjunction) f h lemma strong_epi.of_arrow_iso {A B A' B' : C} {f : A ⟶ B} {g : A' ⟶ B'} (e : arrow.mk f ≅ arrow.mk g) [h : strong_epi f] : strong_epi g := { epi := begin haveI : epi (f ≫ (arrow.right_func.map_iso e).hom) := epi_comp _ _, have eq : g = (arrow.left_func.map_iso e).inv ≫ f ≫ (arrow.right_func.map_iso e).hom, { have eq' := arrow.hom.congr_right e.inv_hom_id, dsimp at eq', simp only [map_iso_inv, arrow.left_func_map, map_iso_hom, arrow.right_func_map, arrow.w_mk_right_assoc, arrow.mk_hom, eq'], dsimp, simp only [category.comp_id], }, rw eq, apply epi_comp, end, llp := λ X Y z, begin introI, apply has_lifting_property.of_arrow_iso_left e z, end } lemma strong_epi_iff_of_arrow_iso {A B A' B' : C} {f : A ⟶ B} {g : A' ⟶ B'} (e : arrow.mk f ≅ arrow.mk g) : strong_epi f ↔ strong_epi g := by { split; introI, exacts [strong_epi.of_arrow_iso e, strong_epi.of_arrow_iso e.symm], } def arrow.iso_of_nat_iso {C D : Type*} [category C] [category D] {F G : C ⥤ D} (e : F ≅ G) (f : arrow C) : F.map_arrow.obj f ≅ G.map_arrow.obj f := arrow.iso_mk (e.app f.left) (e.app f.right) (by simp) variable (F) lemma strong_epi_iff_strong_epi_map_of_is_equivalence [is_equivalence F] : strong_epi f ↔ strong_epi (F.map f) := begin split, { introI, apply_instance, }, { introI, have e : arrow.mk f ≅ arrow.mk (F.inv.map (F.map f)) := arrow.iso_of_nat_iso (F.as_equivalence.unit_iso) (arrow.mk f), rw strong_epi_iff_of_arrow_iso e, apply_instance, } end open limits def preimage_strong_epi_mono_factorisation (s : strong_epi_mono_factorisation (F.map f)) [is_equivalence F] : strong_epi_mono_factorisation f := begin haveI : mono (F.preimage (F.as_equivalence.counit_iso.hom.app _ ≫ s.m)), { simp only [← F.mono_map_iff_mono, as_equivalence_counit, image_preimage], apply mono_comp, }, haveI : strong_epi (F.preimage (s.e ≫ F.as_equivalence.counit_iso.inv.app _)), { simp only [← @strong_epi_map_iff_strong_epi_of_is_equivalence _ _ _ _ F, image_preimage, as_equivalence_counit], apply strong_epi_comp, }, exact { I := F.inv.obj s.I, m := F.preimage (F.as_equivalence.counit_iso.hom.app _ ≫ s.m), e := F.preimage (s.e ≫ F.as_equivalence.counit_iso.inv.app _), m_mono := infer_instance, fac' := begin apply F.map_injective, simp only [map_comp, image_preimage, category.assoc, iso.inv_hom_id_app_assoc, mono_factorisation.fac], end, } end lemma has_strong_epi_mono_factorisations_imp [is_equivalence F] [h : has_strong_epi_mono_factorisations D] : has_strong_epi_mono_factorisations C := ⟨λ X Y f, begin apply nonempty.intro, apply F.preimage_strong_epi_mono_factorisation, let H := h.has_fac, exact (H (F.map f)).some, end⟩ end functor end category_theory open category_theory namespace simplex_category lemma skeletal_equivalence.functor.map_eq {Δ₁ Δ₂ : simplex_category} (f : Δ₁ ⟶ Δ₂) : coe_fn (simplex_category.skeletal_equivalence.{u}.functor.map f) = ulift.up ∘ f.to_order_hom ∘ ulift.down := rfl lemma skeletal_equivalence.functor.surjective_iff_map {Δ₁ Δ₂ : simplex_category} (f : Δ₁ ⟶ Δ₂) : function.surjective f.to_order_hom ↔ function.surjective (simplex_category.skeletal_equivalence.{u}.functor.map f) := by rw [skeletal_equivalence.functor.map_eq, function.surjective.of_comp_iff' ulift.up_bijective, function.surjective.of_comp_iff _ ulift.down_surjective] lemma skeletal_equivalence.functor.injective_iff_map {Δ₁ Δ₂ : simplex_category} (f : Δ₁ ⟶ Δ₂) : function.injective f.to_order_hom ↔ function.injective (simplex_category.skeletal_equivalence.{u}.functor.map f) := by rw [skeletal_equivalence.functor.map_eq, function.injective.of_comp_iff ulift.up_injective, function.injective.of_comp_iff' _ ulift.down_bijective] end simplex_category namespace NonemptyFinLinOrd lemma epi_iff_surjective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) : epi f ↔ function.surjective f := begin have eq := simplex_category.skeletal_equivalence.counit_iso.hom.naturality f, simp only [← cancel_mono (simplex_category.skeletal_equivalence.counit_iso.inv.app B), category.assoc, iso.hom_inv_id_app, category.comp_id, functor.id_map] at eq, rw [← simplex_category.skeletal_equivalence.inverse.epi_map_iff_epi, simplex_category.epi_iff_surjective, simplex_category.skeletal_equivalence.functor.surjective_iff_map, ← functor.comp_map, eq, coe_comp, coe_comp, function.surjective.of_comp_iff, function.surjective.of_comp_iff'], { apply concrete_category.bijective_of_is_iso, }, { apply function.bijective.surjective, apply concrete_category.bijective_of_is_iso, }, end instance : split_epi_category NonemptyFinLinOrd.{u} := ⟨λ X Y f hf, begin have H : ∀ (y : Y), nonempty (f⁻¹' { y }), { rw epi_iff_surjective at hf, intro y, exact nonempty.intro ⟨(hf y).some, (hf y).some_spec⟩, }, let φ : Y → X := λ y, (H y).some.1, have hφ : ∀ (y : Y), f (φ y) = y := λ y, (H y).some.2, refine is_split_epi.mk' ⟨⟨φ, _⟩, _⟩, swap, { ext b, apply hφ, }, { intros a b, contrapose, intro h, simp only [not_le] at h ⊢, suffices : b ≤ a, { cases this.lt_or_eq with h₁ h₂, { assumption, }, { exfalso, simpa only [h₂, lt_self_iff_false] using h, }, }, simpa only [hφ] using f.monotone (le_of_lt h), }, end⟩ lemma mono_iff_injective {A B : NonemptyFinLinOrd.{u}} {f : A ⟶ B} : mono f ↔ function.injective f := begin have eq := simplex_category.skeletal_equivalence.counit_iso.hom.naturality f, simp only [← cancel_mono (simplex_category.skeletal_equivalence.counit_iso.inv.app B), category.assoc, iso.hom_inv_id_app, category.comp_id, functor.id_map] at eq, rw [← simplex_category.skeletal_equivalence.inverse.mono_map_iff_mono, simplex_category.mono_iff_injective, simplex_category.skeletal_equivalence.functor.injective_iff_map, ← functor.comp_map, eq, coe_comp, coe_comp, function.injective.of_comp_iff', function.injective.of_comp_iff], { apply function.bijective.injective, apply concrete_category.bijective_of_is_iso, }, { apply concrete_category.bijective_of_is_iso, }, end @[protected, simps] def strong_epi_mono_factorisation {X Y : NonemptyFinLinOrd.{u}} (f : X ⟶ Y) : limits.strong_epi_mono_factorisation f := begin let I : NonemptyFinLinOrd.{u} := ⟨set.image (coe_fn f) ⊤, ⟨⟩⟩, let e : X ⟶ I := ⟨λ x, ⟨f x, ⟨x, by tidy⟩⟩, λ x₁ x₂ h, f.monotone h⟩, let m : I ⟶ Y := ⟨λ y, y, by tidy⟩, haveI : epi e, { rw epi_iff_surjective, tidy, }, haveI : strong_epi e := strong_epi_of_epi e, haveI : mono m, { rw mono_iff_injective, tidy, }, exact { I := I, m := m, e := e, }, end instance : limits.has_strong_epi_mono_factorisations NonemptyFinLinOrd.{u} := ⟨λ X Y f, nonempty.intro (NonemptyFinLinOrd.strong_epi_mono_factorisation f)⟩ end NonemptyFinLinOrd namespace simplex_category open category_theory.limits instance : split_epi_category simplex_category := ⟨λ X Y f, begin introI, rw ← simplex_category.skeletal_equivalence.{0}.functor.is_split_epi_iff, apply is_split_epi_of_epi, end⟩ @[protected] lemma has_strong_epi_mono_factorisations : has_strong_epi_mono_factorisations simplex_category := simplex_category.skeletal_functor.has_strong_epi_mono_factorisations_imp.{0} attribute [instance] has_strong_epi_mono_factorisations lemma image_eq {Δ Δ' Δ'' : simplex_category } {φ : Δ ⟶ Δ''} {e : Δ ⟶ Δ'} [epi e] {i : Δ' ⟶ Δ''} [mono i] (fac : e ≫ i = φ) : image φ = Δ' := begin haveI := strong_epi_of_epi e, let eq := image.iso_strong_epi_mono e i fac, ext, apply le_antisymm, { exact @len_le_of_epi _ _ eq.hom infer_instance, }, { exact @len_le_of_mono _ _ eq.hom infer_instance, }, end lemma image_ι_eq {Δ Δ'' : simplex_category } {φ : Δ ⟶ Δ''} {e : Δ ⟶ image φ} [epi e] {i : image φ ⟶ Δ''} [mono i] (fac : e ≫ i = φ) : image.ι φ = i := begin haveI := strong_epi_of_epi e, rw ← image.iso_strong_epi_mono_hom_comp_ι e i fac, conv_lhs { rw ← category.id_comp (image.ι φ), }, congr, symmetry, apply simplex_category.eq_id_of_is_iso, apply_instance, end lemma factor_thru_image_eq {Δ Δ'' : simplex_category } {φ : Δ ⟶ Δ''} {e : Δ ⟶ image φ} [epi e] {i : image φ ⟶ Δ''} [mono i] (fac : e ≫ i = φ) : factor_thru_image φ = e := by rw [← cancel_mono i, fac, ← image_ι_eq fac, image.fac] end simplex_category -/
import tkinter as tk import pandas as pd import numpy as np from sklearn import tree from sklearn.tree import DecisionTreeClassifier # Import Decision Tree Classifier from sklearn.model_selection import train_test_split # Import train_test_split function from sklearn import metrics # Import scikit-learn metrics module for accuracy calculation import csv import ipython_genutils as ip import matplotlib as mpl from matplotlib import pyplot as plt import seaborn as sns import warnings from collections import Counter import datetime import wordcloud warnings.filterwarnings('ignore') df1 = pd.read_csv(r"./CAvideos.csv", encoding='utf-8') df1["title_length"] = df1["title"].apply(lambda x: len(x)) PLOT_COLORS = ["#268bd2", "#0052CC", "#FF5722", "#b58900", "#003f5c"] pd.options.display.float_format = '{:.2f}'.format sns.set(style="ticks") plt.rc('figure', figsize=(8, 5), dpi=100) plt.rc('axes', labelpad=20, facecolor="#ffffff", linewidth=0.4, grid=True, labelsize=14) plt.rc('patch', linewidth=0) plt.rc('xtick.major', width=0.2) plt.rc('ytick.major', width=0.2) plt.rc('grid', color='#9E9E9E', linewidth=0.4) plt.rc('font', family='Arial', weight='400', size=10) plt.rc('text', color='#282828') plt.rc('savefig', pad_inches=0.3, dpi=300) fig, ax = plt.subplots() _ = ax.scatter(x=df1['views'], y=df1['title_length'], color=PLOT_COLORS[2], edgecolors="#000000", linewidths=0.5) _ = ax.set(xlabel="Views", ylabel="Title Length") def show(): plt.show()
/- Copyright (c) 2023 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ import analysis.special_functions.exponential /-! # Trigonometric functions as sums of infinite series In this file we express trigonometric functions in terms of their series expansion. ## Main results * `complex.has_sum_cos`, `complex.tsum_cos`: `complex.cos` as the sum of an infinite series. * `real.has_sum_cos`, `real.tsum_cos`: `real.cos` as the sum of an infinite series. * `complex.has_sum_sin`, `complex.tsum_sin`: `complex.sin` as the sum of an infinite series. * `real.has_sum_sin`, `real.tsum_sin`: `real.sin` as the sum of an infinite series. -/ open_locale nat /-! ### `cos` and `sin` for `ℝ` and `ℂ` -/ section sin_cos lemma complex.has_sum_cos' (z : ℂ) : has_sum (λ n : ℕ, (z * complex.I) ^ (2 * n) / ↑(2 * n)!) (complex.cos z) := begin rw [complex.cos, complex.exp_eq_exp_ℂ], have := ((exp_series_div_has_sum_exp ℂ (z * complex.I)).add (exp_series_div_has_sum_exp ℂ (-z * complex.I))).div_const 2, replace := ((nat.div_mod_equiv 2)).symm.has_sum_iff.mpr this, dsimp [function.comp] at this, simp_rw [←mul_comm 2 _] at this, refine this.prod_fiberwise (λ k, _), dsimp only, convert has_sum_fintype (_ : fin 2 → ℂ) using 1, rw fin.sum_univ_two, simp_rw [fin.coe_zero, fin.coe_one, add_zero, pow_succ', pow_mul, mul_pow, neg_sq, ←two_mul, neg_mul, mul_neg, neg_div, add_right_neg, zero_div, add_zero, mul_div_cancel_left _ (two_ne_zero : (2 : ℂ) ≠ 0)], end lemma complex.has_sum_sin' (z : ℂ) : has_sum (λ n : ℕ, (z * complex.I) ^ (2 * n + 1) / ↑(2 * n + 1)! / complex.I) (complex.sin z) := begin rw [complex.sin, complex.exp_eq_exp_ℂ], have := (((exp_series_div_has_sum_exp ℂ (-z * complex.I)).sub (exp_series_div_has_sum_exp ℂ (z * complex.I))).mul_right complex.I).div_const 2, replace := ((nat.div_mod_equiv 2)).symm.has_sum_iff.mpr this, dsimp [function.comp] at this, simp_rw [←mul_comm 2 _] at this, refine this.prod_fiberwise (λ k, _), dsimp only, convert has_sum_fintype (_ : fin 2 → ℂ) using 1, rw fin.sum_univ_two, simp_rw [fin.coe_zero, fin.coe_one, add_zero, pow_succ', pow_mul, mul_pow, neg_sq, sub_self, zero_mul, zero_div, zero_add, neg_mul, mul_neg, neg_div, ← neg_add', ←two_mul, neg_mul, neg_div, mul_assoc, mul_div_cancel_left _ (two_ne_zero : (2 : ℂ) ≠ 0), complex.div_I], end /-- The power series expansion of `complex.cos`. -/ lemma complex.has_sum_cos (z : ℂ) : has_sum (λ n : ℕ, ((-1) ^ n) * z ^ (2 * n) / ↑(2 * n)!) (complex.cos z) := begin convert complex.has_sum_cos' z using 1, simp_rw [mul_pow, pow_mul, complex.I_sq, mul_comm] end /-- The power series expansion of `complex.sin`. -/ lemma complex.has_sum_sin (z : ℂ) : has_sum (λ n : ℕ, ((-1) ^ n) * z ^ (2 * n + 1) / ↑(2 * n + 1)!) (complex.sin z) := begin convert complex.has_sum_sin' z using 1, simp_rw [mul_pow, pow_succ', pow_mul, complex.I_sq, ←mul_assoc, mul_div_assoc, div_right_comm, div_self complex.I_ne_zero, mul_comm _ ((-1 : ℂ)^_), mul_one_div, mul_div_assoc, mul_assoc] end lemma complex.cos_eq_tsum' (z : ℂ) : complex.cos z = ∑' n : ℕ, (z * complex.I) ^ (2 * n) / ↑(2 * n)! := (complex.has_sum_cos' z).tsum_eq.symm lemma complex.sin_eq_tsum' (z : ℂ) : complex.sin z = ∑' n : ℕ, (z * complex.I) ^ (2 * n + 1) / ↑(2 * n + 1)! / complex.I := (complex.has_sum_sin' z).tsum_eq.symm lemma complex.cos_eq_tsum (z : ℂ) : complex.cos z = ∑' n : ℕ, ((-1) ^ n) * z ^ (2 * n) / ↑(2 * n)! := (complex.has_sum_cos z).tsum_eq.symm lemma complex.sin_eq_tsum (z : ℂ) : complex.sin z = ∑' n : ℕ, ((-1) ^ n) * z ^ (2 * n + 1) / ↑(2 * n + 1)! := (complex.has_sum_sin z).tsum_eq.symm /-- The power series expansion of `real.cos`. -/ lemma real.has_sum_cos (r : ℝ) : has_sum (λ n : ℕ, ((-1) ^ n) * r ^ (2 * n) / ↑(2 * n)!) (real.cos r) := by exact_mod_cast complex.has_sum_cos r /-- The power series expansion of `real.sin`. -/ lemma real.has_sum_sin (r : ℝ) : has_sum (λ n : ℕ, ((-1) ^ n) * r ^ (2 * n + 1) / ↑(2 * n + 1)!) (real.sin r) := by exact_mod_cast complex.has_sum_sin r lemma real.cos_eq_tsum (r : ℝ) : real.cos r = ∑' n : ℕ, ((-1) ^ n) * r ^ (2 * n) / ↑(2 * n)! := (real.has_sum_cos r).tsum_eq.symm lemma real.sin_eq_tsum (r : ℝ) : real.sin r = ∑' n : ℕ, ((-1) ^ n) * r ^ (2 * n + 1) / ↑(2 * n + 1)! := (real.has_sum_sin r).tsum_eq.symm end sin_cos
module Issue2224 where -- This is a placeholder to ensure that the test case is run. -- The file of interest is `Issue2224.sh`, and the associated file -- Issue2224WrongExtension.agda.tex
(* No axiom is being used in this module *) (* This is the reverse of Peirce law which is not very interesting *) Proposition peirce_reverse : forall P Q: Prop, P->(P->Q)->P. Proof. intros P Q Hp; intro Hpq; exact Hp. Qed. Proposition P_non_P : forall P:Prop, P->~~P. Proof. intros P Hp; intro H; apply H; exact Hp. Qed. Proposition or_not_and_not : forall P Q:Prop, P\/Q->~(~P/\~Q). Proof. intros P Q H; intro H'; elim H'; intros Hnp Hnq. elim H. intro Hp; apply Hnp; exact Hp. intro Hq; apply Hnq; exact Hq. Qed. Proposition not_P_or_imp : forall P Q: Prop, (~P\/Q)->(P->Q). Proof. intros P Q H Hp. elim H. intro Hnp. apply False_ind. apply Hnp; exact Hp. intro Hq; exact Hq. Qed. Proposition forall_not_exists : forall (A:Type) (P: A->Prop), (forall x:A, P x) -> ~(exists x:A, ~P x). Proof. intros A P H H'. elim H'. intros a Ha. apply Ha. apply H. Qed.
lemma open_ball [intro, simp]: "open (ball x e)"
module MLib.Fin.Parts where open import MLib.Prelude open import MLib.Prelude.RelProps import MLib.Fin.Parts.Core as C open import MLib.Fin.Parts.Nat open import Function.Surjection using (_↠_) open import Function.Related renaming (module EquationalReasoning to BijReasoning) import Relation.Binary.Indexed as I open Nat using (_*_; _+_; _<_) open Fin using (toℕ; fromℕ≤) open Table open C using (Parts; constParts) hiding (module Parts) public module Parts {a} {A : Set a} {size : A → ℕ} (P : Parts A size) where open C.Parts P public module PN = Partsℕ P -- Fin functions private bounded′ : ∀ {i} (j : Fin (sizeAt i)) → toℕ j < PN.sizeAt (fromℕ≤ (Fin.bounded i)) bounded′ j = Nat.≤-trans (Fin.bounded j) (Nat.≤-reflexive (≡.sym (≡.cong sizeAt (Fin.fromℕ≤-toℕ _ _)))) fromParts : Σ (Fin numParts) (Fin ∘ sizeAt) → Fin totalSize fromParts (i , j) = fromℕ≤ {PN.fromParts (toℕ i , toℕ j)} (PN.fromParts-prop (Fin.bounded i) (bounded′ j)) toParts : Fin totalSize → Σ (Fin numParts) (Fin ∘ sizeAt) toParts k = let p , q = PN.toParts-prop (Fin.bounded k) in fromℕ≤ p , fromℕ≤ q abstract fromParts-fromPartsℕ : (i : Fin numParts) (j : Fin (sizeAt i)) → toℕ (fromParts (i , j)) ≡ PN.fromParts (toℕ i , toℕ j) fromParts-fromPartsℕ _ _ = Fin.toℕ-fromℕ≤ _ toParts-toPartsℕ : (k : Fin totalSize) → Σ.map toℕ toℕ (toParts k) ≡ PN.toParts (toℕ k) toParts-toPartsℕ k = Σ.≡×≡⇒≡ (Fin.toℕ-fromℕ≤ _ , Fin.toℕ-fromℕ≤ _) toParts-fromParts : ∀ {i j} → toParts (fromParts (i , j)) ≡ (i , j) toParts-fromParts {i} {j} = Fin.toℕ-injective₂ (begin Σ.map toℕ toℕ (toParts (fromParts (i , j))) ≡⟨ toParts-toPartsℕ _ ⟩ PN.toParts (toℕ (fromParts (i , j))) ≡⟨ ≡.cong PN.toParts (fromParts-fromPartsℕ i j) ⟩ PN.toParts (PN.fromParts (toℕ i , toℕ j)) ≡⟨ PN.toParts-fromParts (Fin.bounded i) (bounded′ j) ⟩ (toℕ i , toℕ j) ∎) where open ≡.Reasoning fromParts-toParts : ∀ {k} → fromParts (toParts k) ≡ k fromParts-toParts {k} = Fin.toℕ-injective ( begin toℕ (fromParts (toParts k)) ≡⟨ uncurry fromParts-fromPartsℕ (toParts k) ⟩ PN.fromParts (Σ.map toℕ toℕ (toParts k)) ≡⟨ ≡.cong PN.fromParts (toParts-toPartsℕ k) ⟩ PN.fromParts (PN.toParts (toℕ k)) ≡⟨ PN.fromParts-toParts (toℕ k) (Fin.bounded k) ⟩ toℕ k ∎) where open ≡.Reasoning asParts : Fin totalSize ↔ Σ (Fin numParts) (Fin ∘ sizeAt) asParts = record { to = ≡.→-to-⟶ toParts ; from = ≡.→-to-⟶ fromParts ; inverse-of = record { left-inverse-of = λ _ → fromParts-toParts ; right-inverse-of = λ _ → toParts-fromParts } } Parts² : ∀ {a} (A : Set a) (size : A → ℕ) → Set a Parts² A size = Parts (Parts A size) Parts.totalSize module _ {a} {A : Set a} {size : A → ℕ} (P₁ : Parts² A size) where private module P₁ = Parts P₁ module _ (i : Fin P₁.numParts) where private P₂ = P₁.partAt i module P₂ = Parts P₂ fromParts² : (j : Fin P₂.numParts) → Fin (size (P₂.partAt j)) → Fin P₁.totalSize fromParts² j = curry P₁.fromParts i ∘ curry P₂.fromParts j asParts² : Fin P₁.totalSize ↔ Σ (Fin P₁.numParts) (λ i → let P₂ = P₁.partAt i module P₂ = Parts P₂ in Σ (Fin P₂.numParts) (Fin ∘ P₂.sizeAt)) asParts² = Fin P₁.totalSize ↔⟨ P₁.asParts ⟩ Σ (Fin P₁.numParts) (Fin ∘ P₁.sizeAt) ↔⟨ Σ-bij (Parts.asParts ∘ P₁.partAt) ⟩ Σ (Fin P₁.numParts) (λ i → let P₂ = P₁.partAt i module P₂ = Parts P₂ in Σ (Fin P₂.numParts) (Fin ∘ P₂.sizeAt)) ∎ where open BijReasoning
lemma scale_measure_1 [simp]: "scale_measure 1 M = M"
module StateSizedIO.IOObject where open import Data.Product open import Size open import SizedIO.Base open import StateSizedIO.Object -- --- -- --- -- --- FILE IS DELETED !!! -- --- -- --- -- An IO object is like a simple object, -- but the method returns IO applied to the result type of a simple object -- which means the method returns an IO program which when terminating -- returns the result of the simple object {- NOTE IOObject is now replaced by IOObjectˢ as defined in StateSizedIO.Base -} {- module _ (ioi : IOInterface) (let C = Command ioi) (let R = Response ioi) (oi : Interfaceˢ) (let S = Stateˢ oi) (let M = Methodˢ oi) (let Rt = Resultˢ oi) (let next = nextˢ oi) where record IOObject (i : Size) (s : S) : Set where coinductive field method : ∀{j : Size< i} (m : M s) → IO ioi ∞ (Σ[ r ∈ Rt s m ] IOObject j (next s m r) ) open IOObject public -}
/- If P and Q are propositions, then so in P ∨ Q. We want to judge P ∨ Q to be true if at least one of them is true. In other words, to judge P ∨ Q to be true, we need either to be able to judge P to be true or Q to be true (and if both are true, that's fine, too). -/ #check or /- inductive or (a b : Prop) : Prop | inl (h : a) : or | inr (h : b) : or -/ /- It's a polymorphic "either" type (in Prop)! -/ axioms (P Q : Prop) (p : P) lemma porq' : P ∨ Q := or.inl p lemma porq'' : P ∨ Q := begin apply or.inl _, exact p, end axiom q : Q lemma porq''' : P ∨ Q := or.inr q /- def or.intro_left {a : Prop} (b : Prop) (ha : a) : or a b := or.inl ha def or.intro_right (a : Prop) {b : Prop} (hb : b) : or a b := or.inr hb -/ /- Suppose it's raining or the sprinkler is running. Futhermore, suppose that if it's raining the grass is wet, and if the sprinkler is running then the grass is wet? What can you conclude? -/ /- You *used* the fact that at least one of the cases held, combined with the fact that in *either* case, the grass is wet, to deduce that the grass is wet. -/ axioms (R : Prop) (porq : P ∨ Q) (pr : P → R) (qr : Q → R) theorem RisTrue : R := or.elim porq pr qr theorem RisTrue' : R := begin apply or.elim porq, exact pr, exact qr, end /- Or -/ /- inductive or (a b : Prop) : Prop | inl (h : a) : or | inr (h : b) : or -/ -- commutes forward, proof term example : P ∨ Q → Q ∨ P := λ h, (match h with | or.inl p := or.inr p | or.inr q := or.inl q end) -- commutes forward, tactic script example : P ∨ Q → Q ∨ P := begin assume porq, cases porq with p q, exact or.inr p, exact or.inl q, end /- or is associative, full proof -/ example : P ∨ (Q ∨ R) ↔ (P ∨ Q) ∨ R := begin apply iff.intro _ _, -- Forwards -> assume pqr, cases pqr with p qr, apply or.inl _, exact or.inl p, cases qr with q r, apply or.inl, exact or.inr q, exact or.inr r, -- Backwards <- assume pqr, cases pqr, _ end
lemma of_real_minus [simp]: "of_real (- x) = - of_real x"
theory Simple_Network_Language_Certificate_Code imports Simple_Network_Language_Certificate Simple_Network_Language_Certificate_Checking begin paragraph \<open>Optimized code equations\<close> lemmas [code_unfold] = imp_for_imp_for' definition dbm_subset'_impl'_int :: "nat \<Rightarrow> int DBMEntry Heap.array \<Rightarrow> int DBMEntry Heap.array \<Rightarrow> bool Heap" where [symmetric, int_folds]: "dbm_subset'_impl'_int = dbm_subset'_impl'" lemma less_eq_dbm_le_int[int_folds]: "(\<le>) = dbm_le_int" unfolding dbm_le_dbm_le_int less_eq .. schematic_goal dbm_subset'_impl'_int_code[code]: "dbm_subset'_impl'_int \<equiv> \<lambda>m a b. do { imp_for 0 ((m + 1) * (m + 1)) Heap_Monad.return (\<lambda>i _. do { x \<leftarrow> Array.nth a i; y \<leftarrow> Array.nth b i; Heap_Monad.return (dbm_le_int x y) }) True } " unfolding dbm_subset'_impl'_int_def[symmetric] dbm_subset'_impl'_def int_folds . definition dbm_subset_impl_int :: "nat \<Rightarrow> int DBMEntry Heap.array \<Rightarrow> int DBMEntry Heap.array \<Rightarrow> bool Heap" where [symmetric, int_folds]: "dbm_subset_impl_int = dbm_subset_impl" schematic_goal dbm_subset_impl_int_code[code]: "dbm_subset_impl_int \<equiv> ?i" unfolding dbm_subset_impl_int_def[symmetric] dbm_subset_impl_def unfolding int_folds . lemmas [code_unfold] = int_folds export_code state_space in SML module_name Test hide_const Parser_Combinator.return hide_const Error_Monad.return definition "show_lit = String.implode o show" definition "rename_state_space \<equiv> \<lambda>dc ids_to_names (broadcast, automata, bounds) L\<^sub>0 s\<^sub>0 formula. let _ = println (STR ''Make renaming'') in do { (m, num_states, num_actions, renum_acts, renum_vars, renum_clocks, renum_states, inv_renum_states, inv_renum_vars, inv_renum_clocks) \<leftarrow> make_renaming broadcast automata bounds; let _ = println (STR ''Renaming''); let (broadcast', automata', bounds') = rename_network broadcast bounds automata renum_acts renum_vars renum_clocks renum_states; let _ = println (STR ''Calculating ceiling''); let k = Simple_Network_Impl_nat_defs.local_ceiling broadcast' bounds' automata' m num_states; let _ = println (STR ''Running model checker''); let inv_renum_states' = (\<lambda>i. ids_to_names i o inv_renum_states i); let f = (\<lambda>show_clock show_state broadcast bounds' automata m num_states num_actions k L\<^sub>0 s\<^sub>0 formula. state_space broadcast bounds' automata m num_states num_actions k L\<^sub>0 s\<^sub>0 formula show_clock show_state () ); let r = do_rename_mc f dc broadcast bounds automata k STR ''_urge'' L\<^sub>0 s\<^sub>0 formula m num_states num_actions renum_acts renum_vars renum_clocks renum_states inv_renum_states' inv_renum_vars inv_renum_clocks; let show_clock = show o inv_renum_clocks; let show_state = (show_state :: _ \<Rightarrow> _ \<Rightarrow> _ \<times> int list \<Rightarrow> _) inv_renum_states inv_renum_vars; let renamings = (m, num_states, num_actions, renum_acts, renum_vars, renum_clocks, renum_states, inv_renum_states, inv_renum_vars, inv_renum_clocks ); Result (r, show_clock, show_state, renamings, k) }" definition "check_subsumed n xs (i :: int) M \<equiv> do { (_, b) \<leftarrow> imp_nfoldli xs (\<lambda>(_, b). return (\<not> b)) (\<lambda>M' (j, b). if i = j then return (j + 1, b) else do { b \<leftarrow> dbm_subset'_impl n M M'; if b then return (j, True) else return (j + 1, False) } ) (0, False); return b } " definition "imp_filter_index P xs = do { (_, xs) \<leftarrow> imp_nfoldli xs (\<lambda>_. return True) (\<lambda>x (i :: nat, xs). do { b \<leftarrow> P i x; return (i + 1, if b then (x # xs) else xs) } ) (0, []); return (rev xs) }" definition "filter_dbm_list n xs = imp_filter_index (\<lambda>i M. do {b \<leftarrow> check_subsumed n xs i M; return (\<not> b)}) xs" partial_function (heap) imp_map :: "('a \<Rightarrow> 'b Heap) \<Rightarrow> 'a list \<Rightarrow> 'b list Heap" where "imp_map f xs = (if xs = [] then return [] else do {y \<leftarrow> f (hd xs); ys \<leftarrow> imp_map f (tl xs); return (y # ys)})" lemma imp_map_simps[code, simp]: "imp_map f [] = return []" "imp_map f (x # xs) = do {y \<leftarrow> f x; ys \<leftarrow> imp_map f xs; return (y # ys)}" by (simp add: imp_map.simps)+ definition trace_state where "trace_state n show_clock show_state \<equiv> \<lambda> (l, M). do { let st = show_state l; m \<leftarrow> show_dbm_impl n show_clock show M; let s = ''('' @ st @ '', ['' @ m @ ''])''; let s = String.implode s; let _ = println s; return () } " for show_clock show_state definition "show_str = String.implode o show" definition parse_convert_run_print where "parse_convert_run_print dc s \<equiv> case parse json s \<bind> convert of Error es \<Rightarrow> do {let _ = map println es; return ()} | Result (ids_to_names, _, broadcast, automata, bounds, formula, L\<^sub>0, s\<^sub>0) \<Rightarrow> do { let r = rename_state_space dc ids_to_names (broadcast, automata, bounds) L\<^sub>0 s\<^sub>0 formula; case r of Error es \<Rightarrow> do {let _ = map println es; return ()} | Result (r, show_clk, show_st, renamings, k) \<Rightarrow> case r of None \<Rightarrow> return () | Some r \<Rightarrow> do { r \<leftarrow> r; let _ = STR ''Number of discrete states: '' + (length r |> show_str) |> println; let _ = STR ''Size of passed list: '' + show_str (sum_list (map (length o snd) r)) |> println; let n = Simple_Network_Impl.clk_set' automata |> list_of_set |> length; r \<leftarrow> imp_map (\<lambda> (a, b). do { b \<leftarrow> imp_map (return o snd) b; b \<leftarrow> filter_dbm_list n b; return (a, b) }) r; let _ = STR ''Number of discrete states: '' + show_str (length r) |> println; let _ = STR ''Size of passed list after removing subsumed states: '' + show_str (sum_list (map (length o snd) r)) |> println; let show_dbm = (\<lambda>M. do { s \<leftarrow> show_dbm_impl_all n show_clk show M; return (''<'' @ s @ ''>'') }); _ \<leftarrow> imp_map (\<lambda> (s, xs). do { let s = show_st s; xs \<leftarrow> imp_map show_dbm xs; let _ = s @ '': '' @ show xs |> String.implode |> println; return () } ) r; return () } }" ML \<open> structure Timing : sig val start_timer: unit -> unit val save_time: string -> unit val get_timings: unit -> (string * Time.time) list end = struct val t = Unsynchronized.ref Time.zeroTime; val timings = Unsynchronized.ref []; fun start_timer () = (t := Time.now ()); fun get_elapsed () = Time.- (Time.now (), !t); fun save_time s = (timings := ((s, get_elapsed ()) :: !timings)); fun get_timings () = !timings; end \<close> ML \<open> fun print_timings () = let val tab = Timing.get_timings (); fun print_time (s, t) = writeln(s ^ ": " ^ Time.toString t); in map print_time tab end; \<close> code_printing constant "Show_State_Defs.tracei" \<rightharpoonup> (SML) "(fn n => fn show_state => fn show_clock => fn typ => fn x => ()) _ _ _" and (OCaml) "(fun n show_state show_clock ty x -> ()) _ _ _" datatype mode = Impl1 | Impl2 | Impl3 | Buechi | Debug definition "distr xs \<equiv> let (m, d) = fold (\<lambda>x (m, d). case m x of None \<Rightarrow> (m(x \<mapsto> 1:: nat), x # d) | Some y \<Rightarrow> (m(x \<mapsto> (y + 1)), d)) xs (Map.empty, []) in map (\<lambda>x. (x, the (m x))) (sort d)" definition split_k'' :: "nat \<Rightarrow> ('a \<times> 'b list) list \<Rightarrow> ('a \<times> 'b list) list list" where "split_k'' k xs \<equiv> let width = sum_list (map (length o snd) xs) div k; width = (if length xs mod k = 0 then width else width + 1) in split_size (length o snd) width 0 [] xs" definition "print_errors es = do {Heap_Monad.fold_map print_line_impl es; return ()}" definition parse_convert_run_check where "parse_convert_run_check mode num_split dc s \<equiv> case parse json s \<bind> convert of Error es \<Rightarrow> print_errors es | Result (ids_to_names, _, broadcast, automata, bounds, formula, L\<^sub>0, s\<^sub>0) \<Rightarrow> do { let r = rename_state_space dc ids_to_names (broadcast, automata, bounds) L\<^sub>0 s\<^sub>0 formula; case r of Error es \<Rightarrow> print_errors es | Result (r, show_clk, show_st, renamings, k) \<Rightarrow> case r of None \<Rightarrow> return () | Some r \<Rightarrow> do { let t = now (); r \<leftarrow> r; let t = now () - t; print_line_impl (STR ''Time for model checking + certificate extraction: '' + time_to_string t); let (m,num_states,num_actions,renum_acts,renum_vars,renum_clocks,renum_states, inv_renum_states, inv_renum_vars, inv_renum_clocks ) = renamings; let _ = start_timer (); state_space \<leftarrow> Heap_Monad.fold_map (\<lambda>(s, xs). do { let xs = map snd xs; xs \<leftarrow> Heap_Monad.fold_map (dbm_to_list_impl m) xs; return (s, xs) } ) r; let _ = save_time STR ''Time for converting DBMs in certificate''; print_line_impl (STR ''Number of discrete states of state space: '' + show_lit (length state_space)); let _ = STR ''Size of passed list: '' + show_str (sum_list (map (length o snd) r)) |> println; STR ''DBM list length distribution: '' + show_str (distr (map (length o snd) state_space)) |> print_line_impl; let split = (if mode = Impl3 then split_k'' num_split state_space else split_k num_split state_space); let split_distr = map (sum_list o map (length o snd)) split; STR ''Size of passed list distribution after split: '' + show_str split_distr |> print_line_impl; let t = now (); check \<leftarrow> case mode of Debug \<Rightarrow> rename_check_dbg num_split dc broadcast bounds automata k L\<^sub>0 s\<^sub>0 formula m num_states num_actions renum_acts renum_vars renum_clocks renum_states inv_renum_states inv_renum_vars inv_renum_clocks state_space | Impl1 \<Rightarrow> rename_check num_split dc broadcast bounds automata k L\<^sub>0 s\<^sub>0 formula m num_states num_actions renum_acts renum_vars renum_clocks renum_states state_space | Impl2 \<Rightarrow> rename_check2 num_split dc broadcast bounds automata k L\<^sub>0 s\<^sub>0 formula m num_states num_actions renum_acts renum_vars renum_clocks renum_states state_space |> return | Impl3 \<Rightarrow> rename_check3 num_split dc broadcast bounds automata k L\<^sub>0 s\<^sub>0 formula m num_states num_actions renum_acts renum_vars renum_clocks renum_states state_space |> return; let t = now () - t; print_line_impl (STR ''Time for certificate checking: '' + time_to_string t); case check of Renaming_Failed \<Rightarrow> print_line_impl (STR ''Renaming failed'') | Preconds_Unsat \<Rightarrow> print_line_impl (STR ''Preconditions were not met'') | Sat \<Rightarrow> print_line_impl (STR ''Certificate was accepted'') | Unsat \<Rightarrow> print_line_impl (STR ''Certificate was rejected'') } }" ML \<open> fun do_test dc file = let val s = file_to_string file; in @{code parse_convert_run_print} dc s end \<close> ML_val \<open> do_test true "/Users/wimmers/Formalizations/Timed_Automata/benchmarks/HDDI_02.muntax" () \<close> ML_val \<open> do_test true "/Users/wimmers/Formalizations/Timed_Automata/benchmarks/HDDI_02_test.muntax" () \<close> ML_val \<open> do_test true "/Users/wimmers/Formalizations/Timed_Automata/benchmarks/simple.muntax" () \<close> ML_val \<open> do_test true "/Users/wimmers/Formalizations/Timed_Automata/benchmarks/light_switch.muntax" () \<close> ML_val \<open> do_test true "/Users/wimmers/Formalizations/Timed_Automata/benchmarks/PM_test.muntax" () \<close> ML_val \<open> do_test true "/Users/wimmers/Formalizations/Timed_Automata/benchmarks/bridge.muntax" () \<close> ML_val \<open> do_test true "/Users/wimmers/Formalizations/Timed_Automata/benchmarks/PM_mod1.muntax" () \<close> code_printing constant "parallel_fold_map" \<rightharpoonup> (SML) "(fn f => fn xs => fn () => Par'_List.map (fn x => f x ()) xs) _ _" definition "num_split \<equiv> 4 :: nat" ML \<open> fun do_check dc file = let val s = file_to_string file; in @{code parse_convert_run_check} @{code Impl3} @{code num_split} dc s end \<close> (* ML_val \<open> do_check false "/Users/wimmers/Formalizations/Timed_Automata/benchmarks/HDDI_02.muntax" () \<close> ML_val \<open> do_check true "/Users/wimmers/Formalizations/Timed_Automata/benchmarks/HDDI_02.muntax" () \<close> ML_val \<open> do_check true "/Users/wimmers/Formalizations/Timed_Automata/benchmarks/simple.muntax" () \<close> ML_val \<open> do_check true "/Users/wimmers/Formalizations/Timed_Automata/benchmarks/light_switch.muntax" () \<close> ML_val \<open> do_check false "/Users/wimmers/Formalizations/Timed_Automata/benchmarks/PM_test.muntax" () \<close> ML_val \<open> do_check true "/Users/wimmers/Formalizations/Timed_Automata/benchmarks/PM_test.muntax" () \<close> ML_val \<open> do_check true "/Users/wimmers/Formalizations/Timed_Automata/benchmarks/bridge.muntax" () \<close> *) ML_val \<open> do_check false "/Users/wimmers/Formalizations/Timed_Automata/benchmarks/PM_all_3.muntax" () \<close> (* ML_val \<open> do_check true "/Users/wimmers/Formalizations/Timed_Automata/benchmarks/PM_all_3.muntax" () \<close> *) text \<open>Executing \<open>Heap_Monad.fold_map\<close> in parallel in Isabelle/ML\<close> definition \<open>Test \<equiv> Heap_Monad.fold_map (\<lambda>x. do {let _ = println STR ''x''; return x}) ([1,2,3] :: nat list)\<close> ML_val \<open>@{code Test} ()\<close> paragraph \<open>Checking external certificates\<close> definition "list_of_json_object obj \<equiv> case obj of Object m \<Rightarrow> Result m | _ \<Rightarrow> Error [STR ''Not an object''] " definition "map_of_debug prefix m \<equiv> let m = map_of m in (\<lambda>x. case m x of None \<Rightarrow> let _ = println (STR ''Key error('' + prefix + STR ''): '' + show_lit x) in None | Some v \<Rightarrow> Some v)" for prefix definition "renaming_of_json' opt prefix json \<equiv> do { vars \<leftarrow> list_of_json_object json; vars \<leftarrow> combine_map (\<lambda> (a, b). do {b \<leftarrow> of_nat b; Result (String.implode a, b)}) vars; let vars = vars @ (case opt of Some x \<Rightarrow> [(x, fold max (map snd vars) 0 + 1)] | _ \<Rightarrow> []); Result (the o map_of_debug prefix vars, the o map_of_debug prefix (map prod.swap vars)) } " for json prefix definition "renaming_of_json \<equiv> renaming_of_json' None" definition "nat_renaming_of_json prefix max_id json \<equiv> do { vars \<leftarrow> list_of_json_object json; vars \<leftarrow> combine_map (\<lambda>(a, b). do { a \<leftarrow> parse lx_nat (String.implode a); b \<leftarrow> of_nat b; Result (a, b) }) vars; let ids = fst ` set vars; let missing = filter (\<lambda>i. i \<notin> ids) [0..<max_id]; let m = the o map_of_debug prefix vars; let m = extend_domain m missing (length vars); Result (m, the o map_of_debug prefix (map prod.swap vars)) } " for json prefix definition convert_renaming :: "(nat \<Rightarrow> nat \<Rightarrow> String.literal) \<Rightarrow> (String.literal \<Rightarrow> nat) \<Rightarrow> JSON \<Rightarrow> _" where "convert_renaming ids_to_names process_names_to_index json \<equiv> do { json \<leftarrow> of_object json; vars \<leftarrow> get json ''vars''; (var_renaming, var_inv) \<leftarrow> renaming_of_json STR ''var renaming'' vars; clocks \<leftarrow> get json ''clocks''; (clock_renaming, clock_inv) \<leftarrow> renaming_of_json' (Some STR ''_urge'') STR ''clock renaming'' clocks; processes \<leftarrow> get json ''processes''; (process_renaming, process_inv) \<leftarrow> renaming_of_json STR ''process renaming'' processes; locations \<leftarrow> get json ''locations''; locations \<leftarrow> list_of_json_object locations; \<comment>\<open>process name \<rightarrow> json\<close> locations \<leftarrow> combine_map (\<lambda>(name, renaming). do { let p_num = process_names_to_index (String.implode name); assert (process_renaming (String.implode name) = p_num) (STR ''Process renamings do not agree on '' + String.implode name); let max_id = 1000; renaming \<leftarrow> nat_renaming_of_json (STR ''process'' + show_str p_num) max_id renaming; \<comment>\<open>location id \<rightarrow> nat\<close> Result (p_num, renaming) } ) locations; \<comment>\<open>process id \<rightarrow> location id \<rightarrow> nat\<close> let location_renaming = the o map_of_debug STR ''location'' (map (\<lambda>(i, f, _). (i, f)) locations); let location_inv = the o map_of_debug STR ''location inv'' (map (\<lambda>(i, _, f). (i, f)) locations); Result (var_renaming, clock_renaming, location_renaming, var_inv, clock_inv, location_inv) } " for json definition "load_renaming dc model renaming \<equiv> case do { model \<leftarrow> parse json model; renaming \<leftarrow> parse json renaming; (ids_to_names, process_names_to_index, broadcast, automata, bounds, formula, L\<^sub>0, s\<^sub>0) \<leftarrow> convert model; convert_renaming ids_to_names process_names_to_index renaming } of Error e \<Rightarrow> return (Error e) | Result r \<Rightarrow> do { let (var_renaming, clock_renaming, location_renaming, _, _, _) = r; let _ = map (\<lambda>p. map (\<lambda>n. location_renaming p n |> show_lit |> println) [0..<8]) [0..<6]; return (Result ()) } " ML \<open> fun do_check dc model_file renaming_file = let val model = file_to_string model_file; val renaming = file_to_string renaming_file; in @{code load_renaming} dc model renaming end \<close> ML_val \<open> do_check true "/Users/wimmers/Code/mlunta/benchmarks/resources/csma_R_6.muntax" "/Users/wimmers/Scratch/certificates/csma.renaming" () \<close> definition parse_compute where "parse_compute model renaming \<equiv> do { model \<leftarrow> parse json model; (ids_to_names, process_names_to_index, broadcast, automata, bounds, formula, L\<^sub>0, s\<^sub>0) \<leftarrow> convert model; renaming \<leftarrow> parse json renaming; (var_renaming, clock_renaming, location_renaming, inv_renum_vars, inv_renum_clocks, inv_renum_states) \<leftarrow> convert_renaming ids_to_names process_names_to_index renaming; (m, num_states, num_actions, renum_acts, renum_vars, renum_clocks, renum_states, _, _, _) \<leftarrow> make_renaming broadcast automata bounds; assert (renum_clocks STR ''_urge'' = m) STR ''Computed renaming: _urge is not last clock!''; let renum_vars = var_renaming; let renum_clocks = clock_renaming; let renum_states = location_renaming; assert (renum_clocks STR ''_urge'' = m) STR ''Given renaming: _urge is not last clock!''; let _ = println (STR ''Renaming''); let (broadcast', automata', bounds') = rename_network broadcast bounds automata renum_acts renum_vars renum_clocks renum_states; let _ = println (STR ''Calculating ceiling''); let k = Simple_Network_Impl_nat_defs.local_ceiling broadcast' bounds' automata' m num_states; let urgent_locations = map (\<lambda>(_, urgent, _, _). urgent) automata'; Result (broadcast, bounds, automata, urgent_locations, k, L\<^sub>0, s\<^sub>0, formula, m, num_states, num_actions, renum_acts, renum_vars, renum_clocks, renum_states, inv_renum_states, inv_renum_vars, inv_renum_clocks) }" for num_split datatype 'l state_space = Reachable_Set (reach_of: "(('l list \<times> int list) \<times> int DBMEntry list list) list") | Buechi_Set (buechi_of: "(('l list \<times> int list) \<times> (int DBMEntry list \<times> nat) list) list") definition normalize_dbm :: "nat \<Rightarrow> int DBMEntry list \<Rightarrow> int DBMEntry list" where "normalize_dbm m xs = do { dbm \<leftarrow> Array.of_list xs; dbm \<leftarrow> fw_impl_int m dbm; Array.freeze dbm } |> run_heap " definition insert_every_nth :: "nat \<Rightarrow> 'a \<Rightarrow> 'a list \<Rightarrow> 'a list" where "insert_every_nth n a xs \<equiv> fold (\<lambda>x (i, xs). if i = n then (1, a # x # xs) else (i + 1, x # xs)) xs (1, []) |> snd |> rev" definition convert_dbm where "convert_dbm urge m dbm = take m dbm @ Le 0 # insert_every_nth m DBMEntry.INF (drop m dbm) @ (if urge then Le 0 else DBMEntry.INF) # replicate (m - 1) DBMEntry.INF @ [Le 0] |> normalize_dbm m" fun convert_state_space :: "_ \<Rightarrow> _ \<Rightarrow> int state_space \<Rightarrow> nat state_space" where "convert_state_space m is_urgent (Reachable_Set xs) = Reachable_Set ( map (\<lambda>((locs, vars), dbms). ((map nat locs, vars), map (convert_dbm (is_urgent (locs, vars)) m) dbms)) xs)" | "convert_state_space m is_urgent (Buechi_Set xs) = Buechi_Set ( map (\<lambda>((locs, vars), dbms). ((map nat locs, vars), map (\<lambda>(dbm, i). (convert_dbm (is_urgent (locs, vars)) m dbm, i)) dbms)) xs)" fun len_of_state_space where "len_of_state_space (Reachable_Set xs) = length xs" | "len_of_state_space (Buechi_Set xs) = length xs" context fixes num_clocks :: nat fixes inv_renum_states :: "nat \<Rightarrow> nat \<Rightarrow> nat" and inv_renum_vars :: "nat \<Rightarrow> String.literal" and inv_renum_clocks :: "nat \<Rightarrow> String.literal" begin private definition show_st where "show_st = show_state inv_renum_states inv_renum_vars" private definition show_dbm :: "int DBMEntry list \<Rightarrow> char list" where "show_dbm = dbm_list_to_string num_clocks (show_clock inv_renum_clocks) show" fun show_state_space where "show_state_space (Reachable_Set xs) = map (\<lambda>(l, xs). map (\<lambda>x. ''('' @ show_st l @ '', <'' @ show_dbm x @ ''>)'' |> String.implode |> println) xs) xs" | "show_state_space (Buechi_Set xs) = map (\<lambda>(l, xs). map (\<lambda>(x, i). show i @ '': ('' @ show_st l @ '', <'' @ show_dbm x @ ''>)'' |> String.implode |> println) xs) xs" end definition "print_sep \<equiv> \<lambda>(). println (String.implode (replicate 100 CHR ''-''))" definition parse_convert_check where "parse_convert_check mode num_split dc model renaming state_space show_cert \<equiv> let r = parse_compute model renaming in case r of Error es \<Rightarrow> do {let _ = map println es; return ()} | Result r \<Rightarrow> do { let (broadcast, bounds, automata, urgent_locations, k, L\<^sub>0, s\<^sub>0, formula, m, num_states, num_actions, renum_acts, renum_vars, renum_clocks, renum_states, inv_renum_states, inv_renum_vars, inv_renum_clocks) = r; let is_urgent = (\<lambda>(L, _). list_ex (\<lambda>(l, urgent). l \<in> set urgent) (zip L urgent_locations)); let inv_renum_clocks = (\<lambda>i. if i = m then STR ''_urge'' else inv_renum_clocks i); let t = now (); let state_space = convert_state_space m is_urgent state_space; let t = now () - t; let _ = println (STR ''Time for converting state space: '' + time_to_string t); let _ = start_timer (); \<comment> \<open>XXX: What is going on here?\<close> let _ = save_time STR ''Time for converting DBMs in certificate''; let _ = println (STR ''Number of discrete states: ''+ show_lit (len_of_state_space state_space)); let _ = do { if show_cert then do { let _ = print_sep (); let _ = println (STR ''Certificate''); let _ = print_sep (); let _ = show_state_space m inv_renum_states inv_renum_vars inv_renum_clocks state_space; let _ = print_sep (); return ()} else return () }; let t = now (); check \<leftarrow> case mode of Debug \<Rightarrow> rename_check_dbg num_split dc broadcast bounds automata k L\<^sub>0 s\<^sub>0 formula m num_states num_actions renum_acts renum_vars renum_clocks renum_states inv_renum_states inv_renum_vars inv_renum_clocks (reach_of state_space) | Impl1 \<Rightarrow> rename_check num_split dc broadcast bounds automata k L\<^sub>0 s\<^sub>0 formula m num_states num_actions renum_acts renum_vars renum_clocks renum_states (reach_of state_space) | Impl2 \<Rightarrow> rename_check2 num_split dc broadcast bounds automata k L\<^sub>0 s\<^sub>0 formula m num_states num_actions renum_acts renum_vars renum_clocks renum_states (reach_of state_space) |> return | Impl3 \<Rightarrow> rename_check3 num_split dc broadcast bounds automata k L\<^sub>0 s\<^sub>0 formula m num_states num_actions renum_acts renum_vars renum_clocks renum_states (reach_of state_space) |> return | Buechi \<Rightarrow> rename_check_buechi num_split broadcast bounds automata k L\<^sub>0 s\<^sub>0 formula m num_states num_actions renum_acts renum_vars renum_clocks renum_states (buechi_of state_space) |> return; let t = now () - t; let _ = println (STR ''Time for certificate checking: '' + time_to_string t); case check of Renaming_Failed \<Rightarrow> do {let _ = println STR ''Renaming failed''; return ()} | Preconds_Unsat \<Rightarrow> do {let _ = println STR ''Preconditions were not met''; return ()} | Sat \<Rightarrow> do {let _ = println STR ''Certificate was accepted''; return ()} | Unsat \<Rightarrow> do {let _ = println STR ''Certificate was rejected''; return ()} } " for num_split and state_space :: "int state_space" (* XXX This is a bug fix. Fix in Isabelle distribution *) code_printing constant IArray.length' \<rightharpoonup> (SML) "(IntInf.fromInt o Vector.length)" code_printing constant Parallel.map \<rightharpoonup> (SML) "Par'_List.map" code_printing code_module "Timing" \<rightharpoonup> (SML) \<open> structure Timing : sig val start_timer: unit -> unit val save_time: string -> unit val get_timings: unit -> (string * Time.time) list val set_cpu: bool -> unit end = struct open Timer; val is_cpu = Unsynchronized.ref false; fun set_cpu b = is_cpu := b; val cpu_timer: cpu_timer option Unsynchronized.ref = Unsynchronized.ref NONE; val real_timer: real_timer option Unsynchronized.ref = Unsynchronized.ref NONE; val timings = Unsynchronized.ref []; fun start_timer () = ( if !is_cpu then cpu_timer := SOME (startCPUTimer ()) else real_timer := SOME (startRealTimer ())); fun get_elapsed () = ( if !is_cpu then #usr (!cpu_timer |> the |> checkCPUTimer) else (!real_timer |> the |> checkRealTimer)); fun save_time s = (timings := ((s, get_elapsed ()) :: !timings)); fun get_timings () = !timings; end \<close> paragraph \<open>Optimized code printings\<close> definition "array_freeze' = array_freeze" lemma [code]: "array_freeze a = array_freeze' a" unfolding array_freeze'_def .. definition "array_unfreeze' = array_unfreeze" lemma [code]: "array_unfreeze a = array_unfreeze' a" unfolding array_unfreeze'_def .. definition "array_copy' = array_copy" lemma [code]: "array_copy a = array_copy' a" unfolding array_copy'_def .. code_printing constant array_freeze' \<rightharpoonup> (SML) "(fn () => Array.vector _)" code_printing constant array_unfreeze' \<rightharpoonup> (SML) "(fn a => fn () => Array.tabulate (Vector.length a, fn i => Vector.sub (a, i))) _" code_printing constant array_copy' \<rightharpoonup> (SML) "(fn a => fn () => Array.tabulate (Array.length a, fn i => Array.sub (a, i))) _" text \<open>According to microbenchmarks, these versions are nearly two times faster.\<close> code_printing constant array_unfreeze' \<rightharpoonup> (SML) "(fn a => fn () => if Vector.length a = 0 then Array.fromList [] else let val x = Vector.sub(a, 0) val n = Array.array (Vector.length a, x) val '_ = Array.copyVec {src=a,dst=n,di=0} in n end ) _" code_printing constant array_copy' \<rightharpoonup> (SML) "(fn a => fn () => if Array.length a = 0 then Array.fromList [] else let val x = Array.sub(a, 0) val n = Array.array (Array.length a, x) val '_ = Array.copy {src=a,dst=n,di=0} in n end ) _" partial_function (heap) imp_for_int_inner :: "integer \<Rightarrow> integer \<Rightarrow> ('a \<Rightarrow> bool Heap) \<Rightarrow> (integer \<Rightarrow> 'a \<Rightarrow> 'a Heap) \<Rightarrow> 'a \<Rightarrow> 'a Heap" where "imp_for_int_inner i u c f s = (if i \<ge> u then return s else do {ctn <- c s; if ctn then f i s \<bind> imp_for_int_inner (i + 1) u c f else return s})" lemma integer_of_nat_le_simp: "integer_of_nat i \<le> integer_of_nat u \<longleftrightarrow> i \<le> u" unfolding integer_of_nat_eq_of_nat by simp lemma imp_for_imp_for_int_inner[code_unfold]: "imp_for i u c f s = imp_for_int_inner (integer_of_nat i) (integer_of_nat u) c (f o nat_of_integer) s" apply (induction "u - i" arbitrary: i u s) apply (simp add: integer_of_nat_le_simp imp_for_int_inner.simps; fail) apply (subst imp_for_int_inner.simps, simp add: integer_of_nat_le_simp) apply auto apply (fo_rule arg_cong, rule ext) apply clarsimp apply (fo_rule arg_cong) apply (auto simp: algebra_simps integer_of_nat_eq_of_nat) done definition "imp_for_int i u c f s \<equiv> imp_for_int_inner (integer_of_nat i) (integer_of_nat u) c (f o nat_of_integer) s" lemma imp_for_imp_for_int[code_unfold]: "imp_for = imp_for_int" by (intro ext, unfold imp_for_int_def imp_for_imp_for_int_inner, rule HOL.refl) partial_function (heap) imp_for'_int_inner :: "integer \<Rightarrow> integer \<Rightarrow> (integer \<Rightarrow> 'a \<Rightarrow> 'a Heap) \<Rightarrow> 'a \<Rightarrow> 'a Heap" where "imp_for'_int_inner i u f s = (if i \<ge> u then return s else f i s \<bind> imp_for'_int_inner (i + 1) u f)" lemma imp_for'_imp_for_int_inner: "imp_for' i u f s \<equiv> imp_for'_int_inner (integer_of_nat i) (integer_of_nat u) (f o nat_of_integer) s" apply (induction "u - i" arbitrary: i u s) apply (simp add: integer_of_nat_le_simp imp_for'_int_inner.simps; fail) apply (subst imp_for'_int_inner.simps, simp add: integer_of_nat_le_simp) apply auto apply (fo_rule arg_cong, rule ext) apply (auto simp: algebra_simps integer_of_nat_eq_of_nat) done lemma imp_for'_int_cong: "imp_for' l u f a = imp_for' l u g a" if "\<And> i x. l \<le> i \<Longrightarrow> i < u \<Longrightarrow> f i x = g i x" using that apply (induction "u - l" arbitrary: l u a) apply (simp add: imp_for'.simps; fail) apply (subst imp_for'.simps, simp add: integer_of_nat_le_simp) apply safe apply clarsimp apply (fo_rule arg_cong) apply auto done definition "imp_for'_int i u f s \<equiv> imp_for'_int_inner (integer_of_nat i) (integer_of_nat u) (f o nat_of_integer) s" lemma imp_for'_imp_for_int[code_unfold, int_folds]: "imp_for' = imp_for'_int" by (intro ext, unfold imp_for'_int_def imp_for'_imp_for_int_inner, rule HOL.refl) code_printing code_module "Iterators" \<rightharpoonup> (SML) \<open> fun imp_for_inner i u c f s = let fun imp_for1 i u f s = if IntInf.<= (u, i) then (fn () => s) else if c s () then imp_for1 (i + 1) u f (f i s ()) else (fn () => s) in imp_for1 i u f s end; fun imp_fora_inner i u f s = let fun imp_for1 i u f s = if IntInf.<= (u, i) then (fn () => s) else imp_for1 (i + 1) u f (f i s ()) in imp_for1 i u f s end; \<close> code_reserved SML imp_for_inner imp_fora_inner (* XXX How much do we gain from this? *) (* code_printing constant imp_for_int_inner \<rightharpoonup> (SML) "imp'_for'_inner" | constant imp_for'_int_inner \<rightharpoonup> (SML) "imp'_fora'_inner" *) definition "nth_integer a n = Array.nth a (nat_of_integer n)" definition "upd_integer n x a = Array.upd (nat_of_integer n) x a" code_printing constant upd_integer \<rightharpoonup> (SML) "(fn a => fn () => (Array.update (a, IntInf.toInt _, _); a)) _" | constant nth_integer \<rightharpoonup> (SML) "(fn () => Array.sub (_, IntInf.toInt _))" definition "fw_upd_impl_integer n a k i j = do { let n = n + 1; let i' = i * n + j; y \<leftarrow> nth_integer a (i * n + k); z \<leftarrow> nth_integer a (k * n + j); x \<leftarrow> nth_integer a i'; let m = dbm_add_int y z; if dbm_lt_int m x then upd_integer i' m a else return a } " lemma nat_of_integer_add: "nat_of_integer i + nat_of_integer j = nat_of_integer (i + j)" if "i \<ge> 0" "j \<ge> 0" proof - have *: "nat a + nat b = nat (a + b)" if "a \<ge> 0" "b \<ge> 0" for a b using that by simp show ?thesis unfolding nat_of_integer.rep_eq apply (simp add: *) apply (subst *) subgoal using zero_integer.rep_eq less_eq_integer.rep_eq that by metis subgoal using zero_integer.rep_eq less_eq_integer.rep_eq that by metis .. qed lemma nat_of_integer_mult: "nat_of_integer i * nat_of_integer j = nat_of_integer (i * j)" if "i \<ge> 0" "j \<ge> 0" using that proof - have *: "nat a * nat b = nat (a * b)" if "a \<ge> 0" "b \<ge> 0" for a b using that by (simp add: nat_mult_distrib) show ?thesis unfolding nat_of_integer.rep_eq apply simp apply (subst *) subgoal using zero_integer.rep_eq less_eq_integer.rep_eq that by metis subgoal using zero_integer.rep_eq less_eq_integer.rep_eq that by metis .. qed lemma fw_upd_impl_int_fw_upd_impl_integer: "fw_upd_impl_int (nat_of_integer n) a (nat_of_integer k) (nat_of_integer i) (nat_of_integer j) = fw_upd_impl_integer n a k i j" if "i \<ge> 0" "j \<ge> 0" "k \<ge> 0" "n \<ge> 0" unfolding fw_upd_impl_integer_def fw_upd_impl_int_def[symmetric] fw_upd_impl_def mtx_get_def mtx_set_def unfolding int_folds less unfolding nth_integer_def upd_integer_def fst_conv snd_conv using that apply (simp add: nat_of_integer_add nat_of_integer_mult algebra_simps) apply (fo_rule arg_cong | rule ext)+ apply (simp add: nat_of_integer_add nat_of_integer_mult algebra_simps) done lemma integer_of_nat_nat_of_integer: "integer_of_nat (nat_of_integer n) = n" if "n \<ge> 0" using that by (simp add: integer_of_nat_eq_of_nat max_def) lemma integer_of_nat_aux: "integer_of_nat (nat_of_integer n + 1) = n + 1" if "n \<ge> 0" proof - have "nat_of_integer n + 1 = nat_of_integer n + nat_of_integer 1" by simp also have "\<dots> = nat_of_integer (n + 1)" using that by (subst nat_of_integer_add; simp) finally show ?thesis using that by (simp add: integer_of_nat_nat_of_integer) qed definition "fwi_impl_integer n a k = fwi_impl_int (nat_of_integer n) a (nat_of_integer k)" lemma fwi_impl_int_eq1: "fwi_impl_int n a k \<equiv> fwi_impl_integer (integer_of_nat n) a (integer_of_nat k)" unfolding fwi_impl_integer_def fwi_impl_int_def by simp partial_function (heap) imp_for'_int_int :: "int \<Rightarrow> int \<Rightarrow> (int \<Rightarrow> 'a \<Rightarrow> 'a Heap) \<Rightarrow> 'a \<Rightarrow> 'a Heap" where "imp_for'_int_int i u f s = (if i \<ge> u then return s else f i s \<bind> imp_for'_int_int (i + 1) u f)" lemma int_bounds_up_induct: assumes "\<And>l. u \<le> (l :: int) \<Longrightarrow> P l u" and "\<And>l. P (l + 1) u \<Longrightarrow> l < u \<Longrightarrow> P l u" shows "P l u" by (induction "nat (u - l)" arbitrary: l) (auto intro: assms) lemma imp_for'_int_int_cong: "imp_for'_int_int l u f a = imp_for'_int_int l u g a" if "\<And> i x. l \<le> i \<Longrightarrow> i < u \<Longrightarrow> f i x = g i x" using that apply (induction arbitrary: a rule: int_bounds_up_induct) apply (simp add: imp_for'_int_int.simps; fail) apply (subst (2) imp_for'_int_int.simps) apply (subst imp_for'_int_int.simps) apply simp apply (fo_rule arg_cong, rule ext) . lemma plus_int_int_of_integer_aux: "(plus_int (int_of_integer l) 1) = int_of_integer (l + 1)" by simp lemma imp_for'_int_inner_imp_for'_int_int: "imp_for'_int_inner l u f a = imp_for'_int_int (int_of_integer l) (int_of_integer u) (f o integer_of_int) a" apply (induction "int_of_integer l" "int_of_integer u" arbitrary: a l u rule: int_bounds_up_induct) apply (simp add: imp_for'_int_int.simps imp_for'_int_inner.simps less_eq_integer.rep_eq; fail) apply (subst imp_for'_int_int.simps) apply (subst imp_for'_int_inner.simps) apply (simp add: less_eq_integer.rep_eq) apply (fo_rule arg_cong, rule ext) apply (subst plus_int_int_of_integer_aux) apply rprems using plus_int_int_of_integer_aux by metis+ lemma imp_for'_int_inner_cong: "imp_for'_int_inner l u f a = imp_for'_int_inner l u g a" if "\<And> i x. l \<le> i \<Longrightarrow> i < u \<Longrightarrow> f i x = g i x" unfolding imp_for'_int_inner_imp_for'_int_int by (rule imp_for'_int_int_cong)(auto simp: less_eq_integer.rep_eq less_integer.rep_eq intro: that) schematic_goal fwi_impl_int_unfold1: "fwi_impl_int (nat_of_integer n) a (nat_of_integer k) = ?i" if "0 \<le> k" "0 \<le> n" unfolding fwi_impl_int_def[symmetric] fwi_impl_def unfolding int_folds unfolding imp_for'_int_def unfolding comp_def integer_of_nat_0 apply (rule imp_for'_int_inner_cong) apply (rule imp_for'_int_inner_cong) apply (rule fw_upd_impl_int_fw_upd_impl_integer) by (assumption | rule that)+ lemma integer_of_nat_add: "integer_of_nat (x + y) = integer_of_nat x + integer_of_nat y" by (simp add: integer_of_nat_eq_of_nat) schematic_goal fwi_impl_int_code [code]: "fwi_impl_int n a k \<equiv> ?x" unfolding fwi_impl_int_eq1 unfolding fwi_impl_integer_def apply (subst fwi_impl_int_unfold1) apply (simp add: integer_of_nat_eq_of_nat; fail) apply (simp add: integer_of_nat_eq_of_nat; fail) unfolding nat_of_integer_integer_of_nat unfolding integer_of_nat_add integer_of_nat_1 apply (abstract_let "integer_of_nat n + 1" n_plus_1) apply (abstract_let "integer_of_nat n" n) . code_printing code_module "Integer" \<rightharpoonup> (Eval) \<open> structure Integer: sig val div_mod: int -> int -> int * int end = struct fun div_mod i j = (i div j, i mod j) end \<close> text \<open>Delete ``junk''\<close> code_printing code_module Bits_Integer \<rightharpoonup> (SML) \<open>\<close> text \<open>For agreement with SML\<close> code_printing type_constructor Typerep.typerep \<rightharpoonup> (Eval) | constant Typerep.Typerep \<rightharpoonup> (Eval) (* code_printing type_constructor Typerep.typerep \<rightharpoonup> (Eval) "typerepa" | constant Typerep.Typerep \<rightharpoonup> (Eval) "Typerep/ (_, _)" *) (* datatype typerepa = Typerep of string * typerepa list; *) (* Speedup for Poly *) (* definition "fw_upd_impl_integer' = fw_upd_impl_integer" lemma [code]: "fw_upd_impl_integer = fw_upd_impl_integer'" unfolding fw_upd_impl_integer'_def .. code_printing constant fw_upd_impl_integer' \<rightharpoonup> (SML) "(fn n => fn a => fn k => fn i => fn j => let val na = IntInf.+ (n, (1 : IntInf.int)); val ia = IntInf.+ (IntInf.* (i, na), j); val x = Array.sub (a, IntInf.toInt ia); val y = Array.sub (a, IntInf.toInt (IntInf.+ (IntInf.* (i, na), k))); val z = Array.sub (a, IntInf.toInt (IntInf.+ (IntInf.* (k, na), j))); val m = dbm'_add'_int y z; in if dbm'_lt'_int m x then (fn () => (Array.update (a, IntInf.toInt ia, m); a)) else (fn () => a) end) _ _ _ _ _" *) lemmas [code] = imp_for'_int_inner.simps imp_for_int_inner.simps export_code parse_convert_check parse_convert_run_print parse_convert_run_check Result Error nat_of_integer int_of_integer DBMEntry.Le DBMEntry.Lt DBMEntry.INF Impl1 Impl2 Impl3 Buechi Debug Reachable_Set Buechi_Set E_op_impl in Eval module_name Model_Checker file "../ML/Certificate.ML" export_code parse_convert_check parse_convert_run_print parse_convert_run_check Result Error nat_of_integer int_of_integer DBMEntry.Le DBMEntry.Lt DBMEntry.INF Impl1 Impl2 Impl3 Buechi Reachable_Set Buechi_Set E_op_impl in SML module_name Model_Checker file "../ML/Certificate.sml" code_printing code_module "Printing" \<rightharpoonup> (Haskell) \<open> import qualified Debug.Trace; print s = Debug.Trace.trace s (); printM s = Debug.Trace.traceM s; \<close> code_printing constant Printing.print \<rightharpoonup> (Haskell) "Printing.print _" (* code_printing code_module "Timing" \<rightharpoonup> (Haskell) \<open> import Data.Time.Clock.System; now = systemToTAITime . Prelude.unsafePerformIO getSystemTime; \<close> *) code_printing constant print_line_impl \<rightharpoonup> (Haskell) "Printing.printM _" (* code_printing constant "now" \<rightharpoonup> (Haskell) "Prelude.const (Time (Int'_of'_integer 0)) _" code_printing constant "time_to_string" \<rightharpoonup> (Haskell) "Prelude.show _" code_printing constant "(-) :: time \<Rightarrow> time \<Rightarrow> time" \<rightharpoonup> (Haskell) "(case _ of Time a -> case _ of Time b -> Time (b - a))" *) code_printing type_constructor time \<rightharpoonup> (Haskell) "Integer" | constant "now" \<rightharpoonup> (Haskell) "Prelude.const 0" | constant "time_to_string" \<rightharpoonup> (Haskell) "Prelude.show _" | constant "(-) :: time \<Rightarrow> time \<Rightarrow> time" \<rightharpoonup> (Haskell) "(-)" code_printing constant list_of_set' \<rightharpoonup> (Haskell) "(case _ of Set xs -> xs)" export_code parse_convert_check parse_convert_run_print parse_convert_run_check Result Error nat_of_integer int_of_integer DBMEntry.Le DBMEntry.Lt DBMEntry.INF Impl1 Impl2 Impl3 Buechi Reachable_Set Buechi_Set in Haskell module_name Model_Checker file "../Haskell/" end
function varargout = randomAngle3d(varargin) %RANDOMANGLE3D Return a 3D angle uniformly distributed on unit sphere. % % usage % [THETA PHI] = randomAngle3d % Generate an angle unformly distributed on the surface of the unit % sphere. % % "Mathematical" convention is used: theta is the colatitude (angle with % vertical axis, 0 for north pole, +pi for south pole, pi/2 for points at % equator) with z=0. % phi is the same as matlab cart2sph: angle from Ox axis, counted % positively counter-clockwise. % % [THETA PHI] = randomAngle3d(N) % generates N random angles (N is a scalar). The result is a N-by-2 % array. % % Example: % % Draw some points on the surface of a sphere % figure; % drawSphere; hold on; % drawPoint3d(pts, '.'); % axis equal; % % See also % angles3d, sph2cart2, cart2sph2 % ------ % Author: David Legland % E-mail: [email protected] % Created: 2005-02-18 % Copyright 2005-2022 INRA - Cepia Software platform N = 1; if ~isempty(varargin) N = varargin{1}; end phi = 2*pi*rand(N, 1); theta = asin(2*rand(N, 1)-1) + pi/2; if nargout<2 var = [theta phi]; varargout{1} = var; else varargout{1} = theta; varargout{2} = phi; end
section \<open>Common Proof Methods and Idioms\<close> theory Idioms imports "../Sep_Main" Open_List Circ_List Hash_Set_Impl begin text_raw\<open>\label{thy:ex:idioms}\<close> text \<open> This theory gives a short documentation of common proof techniques and idioms for the separation logic framework. For this purpose, it presents some proof snippets (inspired by the other example theories), and heavily comments on them. \<close> subsection \<open>The Method \<open>sep_auto\<close>\<close> text \<open>The most versatile method of our framework is \<open>sep_auto\<close>, which integrates the verification condition generator, the entailment solver and some pre- and postprocessing tactics based on the simplifier and classical reasoner. It can be applied to a Hoare-triple or entailment subgoal, and will try to solve it, and any emerging new goals. It stops when the goal is either solved or it gets stuck somewhere.\<close> text \<open>As a simple example for \<open>sep_auto\<close> consider the following program that does some operations on two circular lists:\<close> definition "test \<equiv> do { l1 \<leftarrow> cs_empty; l2 \<leftarrow> cs_empty; l1 \<leftarrow> cs_append ''a'' l1; l2 \<leftarrow> cs_append ''c'' l2; l1 \<leftarrow> cs_append ''b'' l1; l2 \<leftarrow> cs_append ''e'' l2; l2 \<leftarrow> cs_prepend ''d'' l2; l2 \<leftarrow> cs_rotate l2; return (l1,l2) }" text \<open>The \<open>sep_auto\<close> method does all the necessary frame-inference automatically, and thus manages to prove the following lemma in one step:\<close> lemma "<emp> test <\<lambda>(l1,l2). cs_list [''a'',''b''] l1 * cs_list [''c'',''e'',''d''] l2>\<^sub>t" unfolding test_def apply (sep_auto) done text \<open>\<open>sep_auto\<close> accepts all the section-options of the classical reasoner and simplifier, e.g., \<open>simp add/del:\<close>, \<open>intro:\<close>. Moreover, it has some more section options, the most useful being \<open>heap add/del:\<close> to add or remove Hoare-rules that are applied with frame-inference. A complete documentation of the accepted options can be found in Section~\ref{sec:auto:overview}. \<close> text \<open>As a typical example, consider the following proof:\<close> lemma complete_ht_rehash: "<is_hashtable l ht> ht_rehash ht <\<lambda>r. is_hashtable l ht * is_hashtable (ls_rehash l) r>" proof - have LEN: " l \<noteq> [] \<Longrightarrow> Suc 0 < 2 * length l" by (cases l) auto show ?thesis apply (rule cons_pre_rule[OF ht_imp_len]) unfolding ht_rehash_def apply (sep_auto heap: complete_ht_new_sz complete_ht_copy simp: ls_rehash_def LEN ) \<comment> \<open>Here we add a heap-rule, and some simp-rules\<close> done qed subsection \<open>Applying Single Rules\<close> text \<open>\paragraph{Hoare Triples} In this example, we show how to do a proof step-by-step.\<close> lemma "<os_list xs n> os_prepend x n <os_list (x # xs)>" unfolding os_prepend_def txt \<open>The rules to deconstruct compound statements are contained in the \<open>sep_decon_rules\<close> collection\<close> thm sep_decon_rules apply (rule sep_decon_rules) txt \<open>The rules for statement that deend on the heap are contained in the \<open>sep_heap_rules\<close> collection. The \<open>fi_rule\<close>-lemma prepares frame inference for them\<close> apply (rule sep_heap_rules[THEN fi_rule]) apply frame_inference \<comment> \<open>This method does the frame-inference\<close> txt \<open>The consequence rule comes in three versions, \<open>const_rule\<close>, \<open>cons_pre_rule\<close>, and \<open>cons_post_rule\<close>\<close> apply (rule cons_post_rule) apply (rule sep_decon_rules) txt \<open>A simplification unfolds \<open>os_list\<close> and extract the pure part of the assumption\<close> apply (clarsimp) txt \<open>We can use \<open>ent_ex_postI\<close> to manually introduce existentials in entailsments\<close> apply (rule_tac x=xa in ent_ex_postI) apply (rule_tac x=n in ent_ex_postI) txt \<open>The simplifier has a setup for assertions, so it will do the rest\<close> apply simp done text \<open>Note that the proof above can be done with \<open>sep_auto\<close>, the "Swiss army knife" of our framework\<close> lemma "<os_list xs n> os_prepend x n <os_list (x # xs)>" unfolding os_prepend_def by sep_auto text \<open>\paragraph{Entailment} This example presents an actual proof from the circular list theory, where we have to manually apply a rule and give some hints to frame inference\<close> lemma cs_append_rule: "<cs_list l p> cs_append x p <cs_list (l@[x])>" apply (cases p) apply (sep_auto simp: cs_append.simps) apply (sep_auto simp: cs_append.simps heap: lseg_append) txt \<open>At this point, we are left with an entailment subgoal that sep-auto cannot solve. A closer look reveals that we could use the rule \<open>lseg_append\<close>. With the \<open>ent_frame_fwd\<close>-rule, we can manually apply a rule to solve an entailment, involving frame inference. In this case, we have the additional problem that frame-inference guesses a wrong instantiation, and is not able to infer the frame. So we have to pre-instantiate the rule, as done below.\<close> apply (rule_tac s1=pp in ent_frame_fwd[OF lseg_append]) apply frame_inference \<comment> \<open>Now frame-inference is able to infer the frame\<close> txt \<open>Now we are left with a trivial entailment, modulo commutativity of star. This can be handled by the entailment solver:\<close> apply solve_entails done subsection \<open>Functions with Explicit Recursion\<close> text \<open>If the termination argument of a function depends on one of its parameters, we can use the function package. For example, the following function inserts elements from a list into a hash-set:\<close> fun ins_from_list :: "('x::{heap,hashable}) list \<Rightarrow> 'x hashset \<Rightarrow> 'x hashset Heap" where "ins_from_list [] hs = return hs" | "ins_from_list (x # l) hs = do { hs \<leftarrow> hs_ins x hs; ins_from_list l hs }" text \<open>Proofs over such functions are usually done by structural induction on the explicit parameter, in this case, on the list\<close> lemma ins_from_list_correct: "<is_hashset s hs> ins_from_list l hs <is_hashset (s\<union>set l)>\<^sub>t" proof (induction l arbitrary: hs s) case (Cons x l) txt \<open>In the induction step, the induction hypothesis has to be declared as a heap-rule, as \<open>sep_auto\<close> currently does not look for potential heap-rules among the premises of the subgoal\<close> show ?case by (sep_auto heap: Cons.IH) qed sep_auto subsection \<open> Functions with Recursion Involving the Heap \<close> text \<open>If the termination argument of a function depends on data stored on the heap, \<open>partial_function\<close> is a useful tool. Note that, despite the name, proving a Hoare-Triple \<open><\<dots>> \<dots> <\<dots>>\<close> for something defined with \<open>partial_function\<close> implies total correctness. \<close> text \<open>In the following example, we compute the sum of a list, using an iterator. Note that the partial-function package does not provide a code generator setup by default, so we have to add a \<open>[code]\<close> attribute manually\<close> partial_function (heap) os_sum' :: "int os_list_it \<Rightarrow> int \<Rightarrow> int Heap" where [code]: "os_sum' it s = do { b \<leftarrow> os_it_has_next it; if b then do { (x,it') \<leftarrow> os_it_next it; os_sum' it' (s+x) } else return s }" text \<open>The proof that the function is correct can be done by induction over the representation of the list that we still have to iterate over. Note that for iterators over sets, we need induction on finite sets, cf. also \<open>To_List_Ga.thy\<close>\<close> lemma os_sum'_rule: "<os_is_it l p l' it> os_sum' it s <\<lambda>r. os_list l p * \<up>(r = s + sum_list l')>\<^sub>t" proof (induct l' arbitrary: it s) case Nil thus ?case txt \<open>To unfold the definition of a partial function, we have to use \<open>subst\<close>. Note that \<open>simp\<close> would loop, unfolding the function arbitrarily deep\<close> apply (subst os_sum'.simps) txt \<open>\<open>sep_auto\<close> accepts all the section parameters that \<open>auto\<close> does, eg. \<open>intro:\<close>\<close> apply (sep_auto intro: os.quit_iteration) done next case (Cons x l') show ?case apply (subst os_sum'.simps) txt \<open>Additionally, \<open>sep_auto\<close> accepts some more section parameters. The most common one, \<open>heap:\<close>, declares rules to be used with frame inference. See Section~\ref{sec:auto:overview} for a complete overview.\<close> apply (sep_auto heap: Cons.hyps) done qed subsection \<open>Precision Proofs\<close> text \<open> Precision lemmas show that an assertion uniquely determines some of its parameters. Our example shows that two list segments from the same start pointer and with the same list, also have to end at the same end pointer. \<close> lemma lseg_prec3: "\<forall>q q'. h \<Turnstile> (lseg l p q * F1) \<and>\<^sub>A (lseg l p q' * F2) \<longrightarrow> q=q'" apply (intro allI) proof (induct l arbitrary: p F1 F2) case Nil thus ?case apply simp \<comment> \<open>A precision solver for references and arrays is included in the standard simplifier setup. Building a general precision solver remains future work.\<close> by metis \<comment> \<open>Unfortunately, the simplifier cannot cope with arbitrarily directed equations, so we have to use some more powerful tool\<close> next case (Cons x l) show ?case apply clarsimp apply (subgoal_tac "na=n") txt \<open>The \<open>prec_frame\<close> and \<open>prec_frame'\<close> rules are useful to do precision proofs\<close> apply (erule prec_frame'[OF Cons.hyps]) apply frame_inference apply frame_inference apply (drule prec_frame[OF sngr_prec]) apply frame_inference apply frame_inference apply simp done qed end
------------------------------------------------------------------------------ -- Definition of FOTC Conat using Agda's co-inductive combinators ------------------------------------------------------------------------------ {-# OPTIONS --allow-unsolved-metas #-} {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Data.Conat.TypeSL where open import Codata.Musical.Notation open import FOTC.Base ------------------------------------------------------------------------------ data Conat : D → Set where cozero : Conat zero cosucc : ∀ {n} → ∞ (Conat n) → Conat (succ₁ n) Conat-out : ∀ {n} → Conat n → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ Conat n') Conat-out cozero = inj₁ refl Conat-out (cosucc {n} Cn) = inj₂ (n , refl , ♭ Cn) Conat-in : ∀ {n} → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ Conat n') → Conat n Conat-in (inj₁ n≡0) = subst Conat (sym n≡0) cozero Conat-in (inj₂ (n' , prf , Cn')) = subst Conat (sym prf) (cosucc (♯ Cn')) -- TODO (2019-01-04): Agda doesn't accept this definition which was -- accepted by a previous version. {-# TERMINATING #-} Conat-coind : (A : D → Set) → (∀ {n} → A n → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ A n')) → ∀ {n} → A n → Conat n Conat-coind A h An with h An ... | inj₁ refl = cozero ... | inj₂ (n' , refl , An') = cosucc (♯ (Conat-coind A h An')) -- TODO (07 January 2014): We couldn't prove Conat-stronger-coind. Conat-stronger-coind : ∀ (A : D → Set) {n} → (A n → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ A n')) → A n → Conat n Conat-stronger-coind A h An with h An ... | inj₁ n≡0 = subst Conat (sym n≡0) cozero ... | inj₂ (n' , prf , An') = subst Conat (sym prf) (cosucc (♯ (Conat-coind A {!!} An'))) postulate ∞D : D ∞-eq : ∞D ≡ succ₁ ∞D -- TODO (06 January 2014): Agda doesn't accept the proof of Conat ∞D. {-# TERMINATING #-} ∞-Conat : Conat ∞D ∞-Conat = subst Conat (sym ∞-eq) (cosucc (♯ ∞-Conat))
/- Copyright (c) 2023 Wojciech Nawrocki. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Wojciech Nawrocki -/ import ProofChecker.Model.PropVars /-! Reasoning about definitional extensions. -/ namespace PropTerm variable [DecidableEq ν] theorem equivalentOver_def_ext {x : ν} {X : Set ν} (φ ψ : PropTerm ν) : ↑φ.semVars ⊆ X → ↑ψ.semVars ⊆ X → x ∉ X → equivalentOver X φ (φ ⊓ .biImpl (.var x) ψ) := by intro hφ hψ hMem τ constructor case mp => intro ⟨σ₁, hAgree, h₁⟩ let σ₂ := σ₁.set x (ψ.eval σ₁) have hAgree₂₁ : σ₂.agreeOn X σ₁ := σ₁.agreeOn_set_of_not_mem _ hMem have : σ₂.agreeOn X τ := hAgree₂₁.trans hAgree have : σ₂ ⊨ φ := agreeOn_semVars (hAgree₂₁.subset hφ) |>.mpr h₁ have : σ₂ ⊨ ψ ↔ σ₁ ⊨ ψ := agreeOn_semVars (hAgree₂₁.subset hψ) have : σ₂ ⊨ .biImpl (.var x) ψ := by aesop exact ⟨σ₂, by assumption, satisfies_conj.mpr (by constructor <;> assumption)⟩ case mpr => intro ⟨σ₂, hAgree, h₂⟩ exact ⟨σ₂, hAgree, (satisfies_conj.mp h₂).left⟩ theorem equivalentOver_def_self {x : ν} {X : Set ν} (φ : PropTerm ν) : x ∉ X → ↑φ.semVars ⊆ X → equivalentOver X (.var x ⊓ .biImpl (.var x) φ) φ := by intro hMem hφ τ constructor case mp => intro ⟨σ₁, hAgree, h₁⟩ simp only [satisfies_conj, satisfies_biImpl] at h₁ exact ⟨σ₁, hAgree, h₁.right.mp h₁.left⟩ case mpr => intro ⟨σ₂, hAgree, h₂⟩ let σ₁ := σ₂.set x ⊤ have hAgree₁₂ : σ₁.agreeOn X σ₂ := σ₂.agreeOn_set_of_not_mem _ hMem have : σ₁.agreeOn X τ := hAgree₁₂.trans hAgree have : σ₁ ⊨ φ := agreeOn_semVars (hAgree₁₂.subset hφ) |>.mpr h₂ exact ⟨σ₁, by assumption, satisfies_conj.mpr (by simp (config := {zeta := false}) [this])⟩ theorem hasUniqueExtension_def_ext {X : Set ν} (x : ν) (φ ψ : PropTerm ν) : ↑ψ.semVars ⊆ X → hasUniqueExtension X (insert x X) (φ ⊓ .biImpl (.var x) ψ) := by intro hψ σ₁ σ₂ h₁ h₂ hAgree suffices σ₁ ⊨ .var x ↔ σ₂ ⊨ .var x by intro x h cases Set.mem_insert_iff.mp h next h => simp only [satisfies_var, ← Bool.eq_iff_eq_true_iff] at this rw [h, this] next h => exact hAgree _ h have := agreeOn_semVars (hAgree.subset hψ) constructor <;> simp_all theorem disj_def_eq (x : ν) (φ₁ φ₂ : PropTerm ν) : ((.var x)ᶜ ⊔ (φ₁ ⊔ φ₂)) ⊓ ((.var x ⊔ φ₁ᶜ) ⊓ (.var x ⊔ φ₂ᶜ)) = .biImpl (.var x) (φ₁ ⊔ φ₂) := by ext τ cases h : τ x <;> simp [not_or, h] theorem equivalentOver_disj_def_ext {x : ν} {X : Set ν} (φ φ₁ φ₂ : PropTerm ν) : ↑φ.semVars ⊆ X → ↑φ₁.semVars ⊆ X → ↑φ₂.semVars ⊆ X → x ∉ X → equivalentOver X φ (φ ⊓ ((.var x)ᶜ ⊔ φ₁ ⊔ φ₂) ⊓ (.var x ⊔ φ₁ᶜ) ⊓ (.var x ⊔ φ₂ᶜ)) := by intro hφ h₁ h₂ hMem simp [sup_assoc, inf_assoc, disj_def_eq] have := Finset.coe_subset.mpr (semVars_disj φ₁ φ₂) apply equivalentOver_def_ext _ _ hφ (subset_trans this (by simp [*])) hMem -- TODO: bigConj_def_eq end PropTerm
||| A key-value tree data structure. ||| ||| This structure doesn't encode the invariants of the tree and is ||| *simply* a container. This structure ideally shouldn't be exposed ||| to the user at all. This structure should be used to build other ||| data structures. See the modules alongside this for appropriate ||| interfaces for using the tree. ||| ||| @keyTy The type associated with the key. data Tree : (keyTy : Type) -> Type where ||| An empty Tree node. Empty : Tree k ||| A Key Value node in the Tree. ||| ||| @key The key. ||| @left The left child of the Node ||| @right THe right child of the Node. Node : (key : k) -> (left : Tree k) -> (right : Tree k) -> Tree k %name Tree t, tree -- ------------------------------------------------------------- [ Definitions ] data Balance : Nat -> Nat -> Type where LHeavy : Balance (S n) n RHeavy : Balance n (S n) Balanced : Balance n n %name Balance b, bal ||| Indirection ensures that it reduces to at least S n' without ||| needing to case split on balance. ||| ||| Should make proofs easier. height : Balance n m -> Nat height b = S (height' b) where height' : Balance n m -> Nat height' (LHeavy {n}) = S n height' (RHeavy {n}) = S n height' {n} (Balanced {n}) = n ||| Encoding of the AVL tree height invariants. ||| ||| @height The height of a Tree. ||| @tree The tree whose height we are capturing. data AVLInvariant : (height : Nat) -> (tree : Tree k) -> Type where ||| A tree of height zero. AVLEmpty : AVLInvariant 0 Empty ||| A Balanced tree. ||| ||| @left The invariant of the left child. ||| @right The invariant of the right child. ||| @b The encoding of the nodes' balance. AVLNode : (left : AVLInvariant n l) -> (right : AVLInvariant m r) -> (b : Balance n m) -> AVLInvariant (height b) (Node k l r) %name AVLInvariant inv ||| An AVL Tree. ||| ||| Modelled using subset to separate the invariants from the tree ||| implementation itself. ||| ||| @height The height of the Tree. ||| @keyTy The type associated with the keys. AVLTree : (height : Nat) -> (keyTy : Type) -> Type AVLTree n k = Subset (Tree k) (AVLInvariant n) -- --------------------------------------------------------------- [ Rotations ] data InsertRes : Nat -> (k : Type) -> Type where Same : AVLTree n k -> InsertRes n k Grew : AVLTree (S n) k -> InsertRes n k %name InsertRes res, r ||| Process the result of an insertion of a new Key-Value pair into ||| the Tree, returning the new tree and proof of the new tree's ||| height. ||| ||| `InsertRes` is obtained from the result of running `Tree.insert`. runInsertRes : InsertRes n k -> (n : Nat ** AVLTree n k) runInsertRes (Same t) = (_ ** t) runInsertRes (Grew t) = (_ ** t) ||| Perform a Left rotation. rotLeft : k -> AVLTree n k -> AVLTree (S (S n)) k -> InsertRes (S (S n)) k -- Impossible because Empty has depth 0 and we know the depth is at least 2 from the type rotLeft key l (Element Empty AVLEmpty) impossible rotLeft key (Element l invl) (Element (Node key' rl rr) (AVLNode invrl invrr Balanced)) = Grew $ Element (Node key' (Node key l rl) rr) (AVLNode (AVLNode invl invrl RHeavy) invrr LHeavy) rotLeft key (Element l invl) (Element (Node key' (Node key'' rll rlr) rr) (AVLNode (AVLNode invrll invrlr LHeavy) invrr LHeavy)) = Same $ Element (Node key'' (Node key l rll) (Node key' rlr rr)) -- Needs Checking (AVLNode (AVLNode invl invrll Balanced) (AVLNode invrlr invrr RHeavy) Balanced) rotLeft key (Element l invl) (Element (Node key' (Node key'' rll rlr) rr) (AVLNode (AVLNode invrll invrlr RHeavy) invrr LHeavy)) = Same $ Element (Node key'' (Node key l rll) (Node key' rlr rr)) (AVLNode (AVLNode invl invrll LHeavy) (AVLNode invrlr invrr Balanced) Balanced) rotLeft key (Element l invl) (Element (Node key' (Node key'' rll rlr) rr) (AVLNode (AVLNode invrll invrlr Balanced) invrr LHeavy)) = Same $ Element (Node key'' (Node key l rll) (Node key' rlr rr)) (AVLNode (AVLNode invl invrll Balanced) (AVLNode invrlr invrr Balanced) Balanced) -- Needs Checking rotLeft key (Element l invl) (Element (Node key' rl rr) (AVLNode invrl invrr RHeavy)) = Same $ Element (Node key' (Node key l rl) rr) (AVLNode (AVLNode invl invrl Balanced) invrr Balanced) ||| Perform a Right rotation. rotRight : k -> AVLTree (S (S n)) k -> AVLTree n k -> InsertRes (S (S n)) k rotRight key (Element Empty AVLEmpty) r impossible rotRight key'' (Element (Node key ll (Node key' lrl lrr)) (AVLNode invll (AVLNode invlrl invlrr RHeavy) RHeavy)) (Element r invr) = Same $ Element (Node key' (Node key ll lrl) (Node key'' lrr r)) (AVLNode (AVLNode invll invlrl LHeavy) (AVLNode invlrr invr Balanced) Balanced) rotRight key'' (Element (Node key ll (Node key' lrl lrr)) (AVLNode invll (AVLNode invlrl invlrr LHeavy) RHeavy)) (Element r invr) = Same $ Element (Node key' (Node key ll lrl) (Node key'' lrr r)) (AVLNode (AVLNode invll invlrl Balanced) (AVLNode invlrr invr RHeavy) Balanced) rotRight key (Element (Node key' ll lr) (AVLNode invll invlr Balanced)) (Element r invr) = Grew $ Element (Node key' ll (Node key lr r)) (AVLNode invll (AVLNode invlr invr LHeavy) RHeavy) rotRight key (Element (Node key' ll lr) (AVLNode invll invlr LHeavy)) (Element r invr) = Same $ Element (Node key' ll (Node key lr r)) (AVLNode invll (AVLNode invlr invr Balanced) Balanced) rotRight key (Element (Node key' ll (Node key'' lrl lrr)) (AVLNode invll (AVLNode invlrl invlrr Balanced) RHeavy)) (Element r invr) = Same $ Element (Node key'' (Node key' ll lrl) (Node key lrr r)) (AVLNode (AVLNode invll invlrl Balanced) (AVLNode invlrr invr Balanced) Balanced) --------------------------------------------------------------- [ Insertion ] ||| Perform an insertion into the tree returning the new tree wrapped ||| in a description describing the height change. doInsert : (Ord k) => k -> AVLTree n k -> InsertRes n k doInsert newKey (Element Empty AVLEmpty) = Grew (Element (Node newKey Empty Empty) (AVLNode AVLEmpty AVLEmpty Balanced)) doInsert newKey (Element (Node key l r) (AVLNode invl invr b)) with (compare newKey key) doInsert newKey (Element (Node key l r) (AVLNode invl invr b)) | EQ = Same (Element (Node newKey l r) (AVLNode invl invr b)) doInsert newKey (Element (Node key l r) (AVLNode invl invr b)) | LT with (assert_total $ doInsert newKey (Element l invl)) -- Totality checker not clever enough to see that this is smaller doInsert newKey (Element (Node key l r) (AVLNode invl invr b)) | LT | (Same (Element l' invl')) = Same $ Element (Node key l' r) (AVLNode invl' invr b) doInsert newKey (Element (Node key l r) (AVLNode invl invr LHeavy)) | LT | (Grew (Element l' invl')) = rotRight key (Element l' invl') (Element r invr) doInsert newKey (Element (Node key l r) (AVLNode invl invr Balanced)) | LT | (Grew (Element l' invl')) = Grew $ Element (Node key l' r) (AVLNode invl' invr LHeavy) doInsert newKey (Element (Node key l r) (AVLNode invl invr RHeavy)) | LT | (Grew (Element l' invl')) = Same $ Element (Node key l' r) (AVLNode invl' invr Balanced) doInsert newKey (Element (Node key l r) (AVLNode invl invr b)) | GT with (assert_total $ doInsert newKey (Element r invr)) -- Totality checker not clever enough to see that this is smaller doInsert newKey (Element (Node key l r) (AVLNode invl invr b)) | GT | (Same (Element r' invr')) = Same $ Element (Node key l r') (AVLNode invl invr' b) doInsert newKey (Element (Node key l r) (AVLNode invl invr LHeavy)) | GT | (Grew (Element r' invr')) = Same $ Element (Node key l r') (AVLNode invl invr' Balanced) doInsert newKey (Element (Node key l r) (AVLNode invl invr Balanced)) | GT | (Grew (Element r' invr')) = Grew $ Element (Node key l r') (AVLNode invl invr' RHeavy) doInsert newKey (Element (Node key l r) (AVLNode invl invr RHeavy)) | GT | (Grew (Element r' invr')) = rotLeft key (Element l invl) (Element r' invr') ||| Insert a key value pair into the tree, returning a the new tree ||| and possibly its new height. insert : Ord k => k -> AVLTree n k -> (n : Nat ** AVLTree n k) insert k t = runInsertRes (doInsert k t) ||| AVL instance implementation ||| ||| @ty The type of the elements in the tree. data AVLImpl : (ty : Type) -> Type where MkTree : {a : Type } -> AVLTree n a -> AVLImpl a ||| Insert an element into the Tree. insertImpl : (Ord a) => a -> AVLImpl a -> AVLImpl a insertImpl a (MkTree t) = MkTree (snd $ insert a t)
abstract AbstractInvariant{T<:Number,D<:AbstractDomain} immutable NullInvariant <: AbstractBank end immutable SumInvariant{T<:Number,D<:AbstractDomain} <: AbstractInvariant{T,D} domain::D pathkey::PathKey signaltype::Type{T} end SumInvariant(Ux::ScatteredBlob) = SumInvariant(Ux.nodes[collect(keys(Ux.nodes))[1]]) function SumInvariant{T<:Number}(node::AbstractNode{T}) pathkey = node.ranges[1].first K = sum([r.first == pathkey for r in node.ranges]) domain = SpatialDomain(K) signaltype = T SumInvariant(domain, pathkey, signaltype) end function SumInvariant{T<:Number}(node::AbstractFourierNode{T}) pathkey = node.ranges[1].first K = sum([r.first == pathkey for r in node.ranges]) domain = FourierDomain(K) signaltype = T SumInvariant(domain, pathkey, signaltype) end function (::Type{SumInvariant{T,SpatialDomain{K}}}){T,K,N}( nodes::DataStructures.SortedDict{Path, Node{T,N},Base.Order.ForwardOrdering}) sumnodes = DataStructures.SortedDict{Path,Node{T,N},Base.Order.ForwardOrdering}() for (path, nodevalue) in nodes dims = find([r.first == invariant.pathkey for r in nodevalue.ranges]) sumnodes[path] = Node{T,N}(sum(nodevalue.data, dims), nodevalue.ranges) end return sumnodes end (invariant::SumInvariant)(Ux::ScatteredBlob) = invariant(Ux.nodes) function transform!{T<:Number}( destination::SubArray, invariant::SumInvariant{T,SpatialDomain}, node::AbstractNode{T}, dim::Int) destination[:] = sum(node.data, dim) end
theory Integer_hull_f_to_a imports Matrix_Invertable Faces Linear_Inequalities.Integer_Hull Linear_Inequalities.Farkas_Lemma Integer_Polyhedron Missing_Sums begin context gram_schmidt begin no_notation inner (infix "\<bullet>" 70) no_notation Finite_Cartesian_Product.vec.vec_nth (infixl "$" 90) lemma integer_hull_is_integer_hull: assumes "P \<subseteq> carrier_vec n" shows "integer_hull (integer_hull P) = integer_hull P" proof - have int_in_carr: "P \<inter> \<int>\<^sub>v \<subseteq> carrier_vec n" using assms by auto show ?thesis unfolding integer_hull_def apply rule using convex_convex_hull apply (metis Int_lower1 int_in_carr convex_hull_mono convex_hulls_are_convex) by (simp add:int_in_carr set_in_convex_hull convex_hull_mono) qed lemma integer_hull_in_carrier: assumes "P \<subseteq> carrier_vec n" shows "integer_hull P \<subseteq> carrier_vec n" proof - have int_in_carr: "P \<inter> \<int>\<^sub>v \<subseteq> carrier_vec n" using assms by auto then show ?thesis by (simp add: gram_schmidt.convex_hull_carrier gram_schmidt.integer_hull_def) qed lemma min_face_min_subsyst: fixes A :: "'a mat" assumes A: "A \<in> carrier_mat nr n" assumes b: "b \<in> carrier_vec nr" defines "P \<equiv> polyhedron A b" assumes "min_face P F" obtains A' b' I' where "((A', b') = sub_system A b I')" " F = {x. x \<in> carrier_vec n \<and> A' *\<^sub>v x = b'}" "dim_vec b' = Min {dim_vec d| C d I. (C, d) = sub_system A b I \<and> F = {x. x \<in> carrier_vec n \<and> C *\<^sub>v x = d}}" proof- have "dim_vec b = nr" using b by auto let ?M = "{dim_vec d| C d I. (C, d) = sub_system A b I \<and> F = {x. x \<in> carrier_vec n \<and> C *\<^sub>v x = d}}" have "finite ?M" using subset_set_of_sub_dims_finite[of ?M A b] by blast have "finite ?M" using subset_set_of_sub_dims_finite[of ?M A b] by blast obtain A' b' I where " F \<subseteq> P \<and> F \<noteq> {} \<and> F = {x. x \<in> carrier_vec n \<and> A' *\<^sub>v x = b'} \<and> (A', b') = sub_system A b I" using char_min_face using A P_def assms(4) b by auto then have "dim_vec b' \<in> ?M" by auto then have "?M \<noteq> {}" by blast then have "Min ?M \<in> ?M \<and> (\<forall>a \<in> ?M. a \<ge> (Min ?M))" using eq_Min_iff[of ?M] `?M \<noteq> {}` `finite ?M` by auto then show ?thesis using that by force qed lemma subsyst_indx_neq_syst_indx_neq: assumes "i1 = pick I j1" assumes "i2 = pick I j2" assumes "(A', b') = sub_system A b I" assumes "j1 < dim_row A'" assumes "j2 < dim_row A'" assumes "j1 \<noteq> j2" shows "i1 \<noteq> i2" proof(cases "infinite I") case True then show ?thesis using assms(1) assms(2) assms(6) pick_eq_iff_inf by blast next case False then show ?thesis using dim_row_less_card_I[of I A b] by (metis assms(1) assms(2) assms(3) assms(4) assms(5) assms(6) fst_conv not_less_iff_gr_or_eq order_less_le_trans pick_mono_le) qed lemma elems_ge_min: assumes "finite S" assumes "b \<in> S" assumes "a = Min S" shows "b \<ge> a" by (simp add: assms) lemma bounded_min_faces_are_vertex: fixes A :: "'a mat" fixes bound:: "'a" assumes A: "A \<in> carrier_mat nr n" assumes b: "b \<in> carrier_vec nr" defines "P \<equiv> polyhedron A b" assumes "P \<noteq> {}" assumes "min_face P F" assumes bounded: "\<forall> x \<in> P. \<forall> i < n. x $ i \<le> bound" shows "card F = 1" proof(cases "n = 0") case True have "{x |x. x \<in> carrier_vec 0} = {0\<^sub>v 0}" using eq_vecI ex_in_conv by fastforce then have "P = {0\<^sub>v 0}" using assms(4) unfolding P_def polyhedron_def using True by auto have "F = {0\<^sub>v 0}" using face_subset_polyhedron[OF min_face_elim(1)[OF assms(5)]] face_non_empty[OF min_face_elim(1)[OF assms(5)]] using \<open>P = {0\<^sub>v 0}\<close> by blast then show ?thesis using card_eq_1_iff by blast next case False have bound_scalar:"\<forall> x \<in> P. \<forall> i < n. unit_vec n i \<bullet> x \<le> bound" using bounded scalar_prod_left_unit unfolding P_def polyhedron_def by auto have "n > 0" using False by auto have "F \<noteq> {}" using A P_def assms(5) b char_min_face by blast obtain \<alpha> \<beta> where \<alpha>_\<beta>:"support_hyp P \<alpha> \<beta> \<and> F = P \<inter> {x |x. \<alpha> \<bullet> x = \<beta>}" using assms(5) by (metis faceE min_face_elim(1)) obtain C d where C_d: "F = polyhedron C d" "dim_row C = dim_vec d" "dim_col C = n" using face_is_polyhedron by (metis A P_def assms(5) b min_face_elim(1)) have "\<exists>x\<in>carrier_vec n. C *\<^sub>v x \<le> d" apply (insert assms(5) char_min_face[of A nr b F]) by(auto simp: \<open>F = polyhedron C d\<close> A b P_def polyhedron_def) have "\<forall> i < n. \<exists> \<beta>\<^sub>i. \<forall>x \<in> F. x $ i = \<beta>\<^sub>i" proof(safe) fix i assume "i < n" have "\<forall> x \<in> F. unit_vec n i \<bullet> x \<le> bound" by (simp add: bound_scalar \<open>i < n\<close> \<alpha>_\<beta>) then have "\<forall> x \<in> carrier_vec n. C *\<^sub>v x \<le> d \<longrightarrow> unit_vec n i \<bullet> x \<le> bound" by (simp add: \<open>F = polyhedron C d\<close> gram_schmidt.polyhedron_def) then have "has_Maximum {unit_vec n i \<bullet> x | x. x \<in> carrier_vec n \<and> C *\<^sub>v x \<le> d}" using strong_duality_theorem_primal_sat_bounded_min_max(2)[of C _ n d "unit_vec n i"] C_d `\<exists>x\<in>carrier_vec n. C *\<^sub>v x \<le> d` unit_vec_carrier carrier_dim_vec by blast then obtain \<beta>\<^sub>i where "\<beta>\<^sub>i \<in> {unit_vec n i \<bullet> x | x. x \<in> carrier_vec n \<and> C *\<^sub>v x \<le> d} \<and> \<beta>\<^sub>i = Maximum {unit_vec n i \<bullet> x | x. x \<in> carrier_vec n \<and> C *\<^sub>v x \<le> d}" using has_MaximumD(1) by blast then have "support_hyp F (unit_vec n i) \<beta>\<^sub>i " apply(intro support_hypI) unfolding C_d polyhedron_def using \<open>has_Maximum {unit_vec n i \<bullet> x |x. x \<in> carrier_vec n \<and> C *\<^sub>v x \<le> d}\<close> by auto+ then have "face F (F\<inter>{x |x. (unit_vec n i) \<bullet> x = \<beta>\<^sub>i})" using `F \<noteq> {}` by blast then have "face P (F\<inter>{x |x. (unit_vec n i) \<bullet> x = \<beta>\<^sub>i})" using face_trans[of A nr b F "(F\<inter>{x |x. (unit_vec n i) \<bullet> x = \<beta>\<^sub>i})"] A P_def assms(5) b min_face_elim(1) by presburger then have "\<forall> x \<in> F. (unit_vec n i) \<bullet> x = \<beta>\<^sub>i" using assms(5) unfolding min_face_def using basic_trans_rules(17) by blast then show "(\<exists>\<beta>\<^sub>i. \<forall>x\<in>F. x $ i = \<beta>\<^sub>i)" by (simp add: C_d(1) \<open>i < n\<close> polyhedron_def) qed have "\<exists>! x. x \<in> F" proof(rule ccontr) assume "\<nexists>!x. x \<in> F" then obtain x y where x_y:"x \<in> F \<and> y \<in> F \<and> x \<noteq> y" using \<open>F \<noteq> {}\<close> by blast have "\<forall>x \<in> F. x \<in> carrier_vec n" by (metis (no_types, lifting) C_d(1) polyhedron_def mem_Collect_eq) then obtain i where i:"i < n \<and> x $ i \<noteq> y $ i" using eq_vecI x_y carrier_vecD by metis have "\<exists>\<beta>\<^sub>i. \<forall>x\<in>F. x $ i = \<beta>\<^sub>i" using \<open>\<forall>i<n. \<exists>\<beta>\<^sub>i. \<forall>x\<in>F. x $ i = \<beta>\<^sub>i\<close> i by presburger then show False by (metis i x_y) qed then show "card F = 1" by (metis \<open>F \<noteq> {}\<close> is_singletonI' is_singleton_altdef) qed lemma bounded_min_faces_are_vertex': fixes A :: "'a mat" fixes bound:: "'a" assumes A: "A \<in> carrier_mat nr n" assumes b: "b \<in> carrier_vec nr" defines "P \<equiv> polyhedron A b" assumes "P \<noteq> {}" assumes "min_face P F" assumes bounded: "\<forall> x \<in> P. \<forall> i < n. x $ i \<ge> bound" shows "card F = 1" proof(cases "n = 0") case True have "{x |x. x \<in> carrier_vec 0} = {0\<^sub>v 0}" using eq_vecI ex_in_conv by fastforce then have "P = {0\<^sub>v 0}" using assms(4) unfolding P_def polyhedron_def using True by auto have "F = {0\<^sub>v 0}" using face_subset_polyhedron[OF min_face_elim(1)[OF assms(5)]] face_non_empty[OF min_face_elim(1)[OF assms(5)]] using \<open>P = {0\<^sub>v 0}\<close> by blast then show ?thesis using card_eq_1_iff by blast next case False have bound_scalar:"\<forall> x \<in> P. \<forall> i < n. - unit_vec n i \<bullet> x \<le> - bound" using bounded scalar_prod_left_unit unfolding P_def polyhedron_def by auto have "n > 0" using False by auto have "F \<noteq> {}" using A P_def assms(5) b char_min_face by blast obtain \<alpha> \<beta> where \<alpha>_\<beta>:"support_hyp P \<alpha> \<beta> \<and> F = P \<inter> {x |x. \<alpha> \<bullet> x = \<beta>}" using assms(5) by (metis faceE min_face_elim(1)) obtain C d where C_d: "F = polyhedron C d" "dim_row C = dim_vec d" "dim_col C = n" using face_is_polyhedron by (metis A P_def assms(5) b min_face_elim(1)) have "\<exists>x\<in>carrier_vec n. C *\<^sub>v x \<le> d" apply (insert assms(5) char_min_face[of A nr b F]) by(auto simp: \<open>F = polyhedron C d\<close> A b P_def polyhedron_def) have "\<forall> i < n. \<exists> \<beta>\<^sub>i. \<forall>x \<in> F. x $ i = \<beta>\<^sub>i" proof(safe) fix i assume "i < n" have "\<forall> x \<in> F. - unit_vec n i \<bullet> x \<le> - bound" by (simp add: bound_scalar \<open>i < n\<close> \<alpha>_\<beta>) then have "\<forall> x \<in> carrier_vec n. C *\<^sub>v x \<le> d \<longrightarrow> - unit_vec n i \<bullet> x \<le> - bound" apply (simp add: \<open>F = polyhedron C d\<close> gram_schmidt.polyhedron_def) by (metis neg_le_iff_le uminus_scalar_prod unit_vec_carrier) then have "has_Maximum {- unit_vec n i \<bullet> x | x. x \<in> carrier_vec n \<and> C *\<^sub>v x \<le> d}" using strong_duality_theorem_primal_sat_bounded_min_max(2)[of C _ n d " - unit_vec n i"] C_d `\<exists>x\<in>carrier_vec n. C *\<^sub>v x \<le> d` unit_vec_carrier carrier_dim_vec by (smt (verit, del_insts) carrier_matI index_uminus_vec(2)) then obtain \<beta>\<^sub>i where "\<beta>\<^sub>i \<in> { - unit_vec n i \<bullet> x | x. x \<in> carrier_vec n \<and> C *\<^sub>v x \<le> d} \<and> \<beta>\<^sub>i = Maximum { - unit_vec n i \<bullet> x | x. x \<in> carrier_vec n \<and> C *\<^sub>v x \<le> d}" using has_MaximumD(1) by blast then have "support_hyp F (- unit_vec n i) \<beta>\<^sub>i " apply(intro support_hypI) unfolding C_d polyhedron_def using \<open>has_Maximum { - unit_vec n i \<bullet> x |x. x \<in> carrier_vec n \<and> C *\<^sub>v x \<le> d}\<close> by auto+ then have "face F (F\<inter>{x |x. (- unit_vec n i) \<bullet> x = \<beta>\<^sub>i})" using `F \<noteq> {}` by blast then have "face P (F\<inter>{x |x. (- unit_vec n i) \<bullet> x = \<beta>\<^sub>i})" using face_trans[of A nr b F "(F\<inter>{x |x. (- unit_vec n i) \<bullet> x = \<beta>\<^sub>i})"] A P_def assms(5) b min_face_elim(1) by presburger then have "\<forall> x \<in> F. (- unit_vec n i) \<bullet> x = \<beta>\<^sub>i" using assms(5) unfolding min_face_def using basic_trans_rules(17) by blast then show "(\<exists>\<beta>\<^sub>i. \<forall>x\<in>F. x $ i = \<beta>\<^sub>i)" apply (simp add: C_d(1) \<open>i < n\<close> polyhedron_def) by (metis R.minus_minus \<open>i < n\<close> scalar_prod_left_unit uminus_scalar_prod unit_vec_carrier) qed have "\<exists>! x. x \<in> F" proof(rule ccontr) assume "\<nexists>!x. x \<in> F" then obtain x y where x_y:"x \<in> F \<and> y \<in> F \<and> x \<noteq> y" using \<open>F \<noteq> {}\<close> by blast have "\<forall>x \<in> F. x \<in> carrier_vec n" by (metis (no_types, lifting) C_d(1) polyhedron_def mem_Collect_eq) then obtain i where i:"i < n \<and> x $ i \<noteq> y $ i" using eq_vecI x_y carrier_vecD by metis have "\<exists>\<beta>\<^sub>i. \<forall>x\<in>F. x $ i = \<beta>\<^sub>i" using \<open>\<forall>i<n. \<exists>\<beta>\<^sub>i. \<forall>x\<in>F. x $ i = \<beta>\<^sub>i\<close> i by presburger then show False by (metis i x_y) qed then show "card F = 1" by (metis \<open>F \<noteq> {}\<close> is_singletonI' is_singleton_altdef) qed lemma min_face_distinct: fixes A :: "'a Matrix.mat" assumes A: "A \<in> carrier_mat nr n" assumes b: "b \<in> carrier_vec nr" defines "P \<equiv> polyhedron A b" assumes "P \<noteq> {}" assumes "min_face P F" assumes "dim_vec b' = Min {dim_vec d | C d I'. F = {x. x \<in> carrier_vec n \<and> C *\<^sub>v x = d} \<and> (C, d) = sub_system A b I'}" assumes " F = {x. x \<in> carrier_vec n \<and> A' *\<^sub>v x = b'}" assumes "(A', b') = sub_system A b I" shows "distinct (Matrix.rows A')" proof(rule ccontr) let ?M = "{dim_vec d | C d I'. F = {x. x \<in> carrier_vec n \<and> C *\<^sub>v x = d} \<and> (C, d) = sub_system A b I'}" have dims_eq: "dim_row A = dim_vec b" by (metis assms(1) assms(2) carrier_matD(1) carrier_vecD) assume "\<not> distinct (Matrix.rows A') " then obtain j1 j2 where j1j2: "j1 \<noteq> j2 \<and> j1 < dim_row A' \<and> j2 < dim_row A' \<and> row A' j1 = row A' j2" by (metis distinct_conv_nth length_rows nth_rows) obtain i1 where i1:"i1 < dim_row A \<and> i1 \<in> I \<and> row A i1 = row A' j1 \<and> i1 = (pick I j1) \<and> b' $ j1 = b $ i1" by (metis assms(8) dims_eq dims_subsyst_same exist_index_in_A fst_conv j1j2 snd_conv) obtain i2 where i2: "i2 < dim_row A \<and> i2 \<in> I \<and> row A i2 = row A' j2 \<and> i2 = (pick I j2) \<and> b' $ j2 = b $ i2" by (metis assms(8) dims_eq dims_subsyst_same exist_index_in_A fst_conv j1j2 snd_conv) then have "i1 \<noteq> i2" using subsyst_indx_neq_syst_indx_neq[of i1 I j1 i2 j2 A' b' A b] using i1 j1j2 assms(8) by presburger have " b $ i1 = b $ i2" proof(rule ccontr) assume "b $ i1 \<noteq> b $ i2" then have "b' $ j1 \<noteq> b' $ j2" using i1 i2 by auto obtain x where "x \<in> F" by (metis A P_def assms(5) b equals0I gram_schmidt.char_min_face) then have "x \<in> carrier_vec n \<and> A' *\<^sub>v x = b'" using assms(7) by blast have "row A' j1 = row A' j2" using j1j2 by blast then show False using j1j2 \<open>x \<in> carrier_vec n \<and> A' *\<^sub>v x = b'\<close> index_mult_mat_vec using \<open>b' $ j1 \<noteq> b' $ j2\<close> by metis qed obtain C d where C_d: "(C, d) = sub_system A b (I - {i1})" by (metis surj_pair) have "{x. A' *\<^sub>v x = b'} = {x. C *\<^sub>v x = d \<and> row A i1 \<bullet> x = b $ i1 }" using remove_index_sub_system_eq[of A b i1 I A' b' C d] by (metis A C_d i1 assms(8) b carrier_matD(1) carrier_vecD) have "\<forall>x. C *\<^sub>v x = d \<longrightarrow> row A i1 \<bullet> x = b $ i1" proof(safe) fix x assume "d = C *\<^sub>v x" have "i2 \<in> I - {i1}" using \<open>i1 \<noteq> i2\<close> i2 by blast then obtain j where j: "j < dim_row C \<and> row A i2 = row C j \<and> b $ i2 = d $ j" by (metis C_d dims_eq dims_subsyst_same' exist_index_in_A' fst_conv i2 snd_conv) then have "row A i1 = row C j \<and> b $ i1 = d $ j" by (metis \<open>b $ i1 = b $ i2\<close> i1 i2 j1j2) then have "row C j \<bullet> x = d $ j" using `d = C *\<^sub>v x` j by (metis index_mult_mat_vec) then show "row A i1 \<bullet> x = b $ i1" by (metis \<open>b $ i1 = b $ i2\<close> i1 i2 j j1j2) qed then have "{x. A' *\<^sub>v x = b'} = {x. C *\<^sub>v x = d}" using \<open>{x. A' *\<^sub>v x = b'} = {x. C *\<^sub>v x = d \<and> row A i1 \<bullet> x = b $ i1}\<close> by blast have "dim_vec d + 1 = dim_vec b'" using remove_index_sub_system_dims[of i1 I b A' b' A C d] by (metis C_d assms(8) dims_eq i1) have "dim_vec d \<ge> dim_vec b'" using elems_ge_min[of ?M "dim_vec d" "dim_vec b'"] C_d \<open>{x. A' *\<^sub>v x = b'} = {x. C *\<^sub>v x = d}\<close> assms(7) subset_set_of_sub_dims_finite[of ?M A b] assms(6) by blast then show False using \<open>dim_vec d + 1 = dim_vec b'\<close> by linarith qed lemma subsyst_rows_carr: assumes "A \<in> carrier_mat nr n" assumes "(A', b') = sub_system A b I" shows "set (rows A') \<subseteq> carrier_vec n" using dim_col_subsyst_mat[of A b I] using assms carrier_matD(2) prod.sel(1) rows_carrier by metis lemma itself_is_subsyst_set_idcs: fixes A :: "'a mat" fixes b:: "'a vec" assumes A: "A \<in> carrier_mat nr n" assumes b: "b \<in> carrier_vec nr" shows "(A, b) = sub_system A b {0..<nr}" by (auto simp: itself_is_subsyst same_subsyst_I_intersect_rows[of A nr b UNIV] assms) lemma sum_list_of_map_eq: assumes "\<forall>i \<in> set L. f i = g i" shows "sum_list (map f L) = sum_list (map g L)" by (metis assms map_eq_conv) lemma list_range_lt: "i \<in> set [0..<l] \<longleftrightarrow> i < l" using atLeast_upt by blast lemma sumlist_system_result: assumes "x \<in> carrier_vec n" assumes "C *\<^sub>v x = d" assumes "set (rows C) \<subseteq> carrier_vec n" assumes "u \<in> carrier_vec n" assumes "u = sumlist (map (\<lambda>i. c i \<cdot>\<^sub>v (rows C) ! i) [0..<length (rows C)])" shows "u \<bullet> x = sum_list (map (\<lambda>i. (c i * d $ i)) [0..<length (rows C)])" proof - let ?Cl = "[0..<length (rows C)]" have Cl_map_carr:"(\<And>v. v \<in> set (map (\<lambda>i. c i \<cdot>\<^sub>v (rows C) ! i) ?Cl) \<Longrightarrow> v \<in> carrier_vec n)" using assms(3) lincomb_map_set_carrier by blast have "u \<bullet> x = x \<bullet> u" using assms(1) assms(4) comm_scalar_prod by blast have "u \<bullet> x = sum_list (map ((\<bullet>) x) (map (\<lambda>i. c i \<cdot>\<^sub>v (rows C) ! i) ?Cl))" using scalar_prod_right_sum_distrib[OF Cl_map_carr] by(simp only: `u \<bullet> x = x \<bullet> u`,simp only: assms(5) assms(1)) also have "\<dots> = sum_list (map (\<lambda>i. (c i \<cdot>\<^sub>v (rows C) ! i) \<bullet> x) ?Cl)" apply(simp only: map_map comp_def, intro sum_list_of_map_eq, safe) apply(intro comm_scalar_prod, blast intro: assms(1)) using list_range_lt assms(3) nth_mem by blast also have "\<dots> = sum_list (map (\<lambda>i. (c i * (((rows C) ! i) \<bullet> x))) ?Cl)" apply(intro sum_list_of_map_eq, safe, simp only: list_range_lt) using assms(1) assms(3) nth_mem smult_scalar_prod_distrib by blast also have "\<dots> = sum_list (map (\<lambda>i. (c i * d $ i)) ?Cl)" apply(intro sum_list_of_map_eq, safe, simp only: list_range_lt) using assms(2) by force ultimately show "u \<bullet> x = sum_list (map (\<lambda>i. (c i * d $ i)) ?Cl)" by presburger qed lemma min_face_lin_indpt: fixes A :: "'a mat" fixes b:: "'a vec" assumes A: "A \<in> carrier_mat nr n" assumes b: "b \<in> carrier_vec nr" defines "P \<equiv> polyhedron A b" assumes "P \<noteq> {}" assumes "min_face P F" assumes "dim_vec b' = Min {dim_vec d | C d I'. F = {x. x \<in> carrier_vec n \<and> C *\<^sub>v x = d} \<and> (C, d) = sub_system A b I'}" assumes " F = {x. x \<in> carrier_vec n \<and> A' *\<^sub>v x = b'}" assumes "(A', b') = sub_system A b I" shows "lin_indpt (set (rows A'))" proof let ?M = "{dim_vec d | C d I'. F = {x. x \<in> carrier_vec n \<and> C *\<^sub>v x = d} \<and> (C, d) = sub_system A b I'}" assume lindpA':"lin_dep (set (rows A'))" have carrA': "set (rows A') \<subseteq> carrier_vec n" using subsyst_rows_carr A assms(8) by blast have "finite (set (rows A'))" by simp have dim_sameAb: "dim_row A = dim_vec b" using assms(1) assms(2) carrier_vecD by blast have 1:"(\<exists>u\<in>(set (rows A')). u \<in> span ((set (rows A')) - {u}))" using lindpA' carrA' lindep_span by blast then obtain u where u:"u\<in>(set (rows A'))\<and> u \<in> span ((set (rows A')) - {u})" by auto then obtain j where "j < length (rows A') \<and> rows A' ! j = u" using in_set_conv_nth by metis then have j:"j < dim_row A' \<and> row A' j = u" using nth_rows length_rows by metis obtain i where i:"i < dim_row A \<and> i \<in> I \<and> row A i = row A' j \<and> i = (pick I j) \<and> b $ i = b' $ j" by (metis assms(8) dim_sameAb dims_subsyst_same exist_index_in_A fst_conv j snd_conv) obtain C d where C_d: "(C, d) = sub_system A b (I - {i})" by (metis surj_pair) have 4: "{x. A' *\<^sub>v x = b'} = {x. C *\<^sub>v x = d \<and> row A i \<bullet> x = b $ i }" using remove_index_sub_system_eq[of A b i I A' b' C d] C_d assms(8) dim_sameAb i by linarith have "u \<in> carrier_vec n" using carrA' u by blast have Cd_non_empty: "{x. x \<in> carrier_vec n \<and> C *\<^sub>v x = d \<and> row A' j \<bullet> x = b' $ j } \<noteq> {}" using assms(5) unfolding min_face_def by (smt (verit, best) face_non_empty assms(7) "4" Collect_empty_eq Collect_mono_iff i) have "\<forall>x \<in> carrier_vec n. C *\<^sub>v x = d \<longrightarrow> row A i \<bullet> x = b $ i" proof(cases "u \<in> set (rows C)") case True then obtain j' where "j' < length (rows C) \<and> (rows C) ! j' = u" by (meson in_set_conv_nth) then have j': "j' < dim_row C \<and> row C j' = u" using length_rows nth_rows by metis obtain i' where i':"i' < nr \<and> i' \<in> (I - {i}) \<and> row A i' = row C j' \<and> d $ j' = b $ i'" by (metis exist_index_in_A_carr[of A nr n b C d _ j'] C_d assms(1) b j') then show ?thesis by (smt (verit, best) Cd_non_empty Collect_empty_eq i index_mult_mat_vec j j') next case False have "set (rows C) \<subseteq> carrier_vec n" using subsyst_rows_carr C_d assms(1) by blast have "set (rows C) = set (rows A') - {u}" using remove_index_remove_row[of A b i I A' b' C d] by (metis C_d False assms(8) dim_sameAb i j) then obtain c where "u = lincomb_list c (rows C)" using `set (rows C) \<subseteq> carrier_vec n` by (metis List.finite_set finite_in_span lincomb_then_lincomb_list u) then have "u = sumlist (map (\<lambda>i. c i \<cdot>\<^sub>v (rows C) ! i) [0..<length (rows C)])" using lincomb_list_def by presburger then have 6:"\<forall>x \<in> carrier_vec n. C *\<^sub>v x = d \<longrightarrow> row A' j \<bullet> x = sum_list (map (\<lambda>i. (c i * d $ i)) [0..<length (rows C)])" using sumlist_system_result \<open>set (Matrix.rows C) \<subseteq> carrier_vec n\<close> j `u \<in> carrier_vec n` by presburger have "b' $ j = sum_list (map (\<lambda>i. (c i * d $ i)) [0..<length (rows C)])" apply(rule ccontr) using "6" Cd_non_empty by force then show "\<forall>x \<in> carrier_vec n. C *\<^sub>v x = d \<longrightarrow> row A i \<bullet> x = b $ i" using 6 i by (metis 6 i) qed then have "dim_vec b' \<le> dim_vec d" using elems_ge_min[of ?M "dim_vec d" "dim_vec b'"] C_d assms(6-7) 4 subset_set_of_sub_dims_finite[of ?M A b] by blast have "dim_vec b' = dim_vec d + 1" using remove_index_sub_system_dims[of i I b A' b' A C d] C_d assms(8) dim_sameAb i by linarith then show False using `dim_vec b' \<le> dim_vec d` by linarith qed lemma lin_dep_cols_iff_rows: assumes "A \<in> carrier_mat n n" assumes "distinct (cols A)" assumes "distinct (rows A)" shows "lin_dep (set (rows A)) = lin_dep (set (cols A))" proof show "lin_dep (set (Matrix.rows A)) \<Longrightarrow> lin_dep (set (cols A))" using idom_vec.lin_dep_rows_imp_det_0[OF assms(1)] using assms(1) assms(2) det_rank_iff lin_indpt_full_rank by blast have A_t: "A\<^sup>T \<in> carrier_mat n n" by (simp add: assms(1)) show "lin_dep (set (cols A)) \<Longrightarrow> lin_dep (set (Matrix.rows A))" using idom_vec.lin_dep_rows_imp_det_0[OF A_t] by (metis A_t Matrix.rows_transpose assms(3) cols_transpose det_rank_iff lin_indpt_full_rank) qed lemma mult_unit_vec_is_col: fixes A :: "'a mat" assumes "A \<in> carrier_mat nr n" assumes "i < n" shows "A *\<^sub>v unit_vec n i = col A i" proof show "dim_vec (A *\<^sub>v unit_vec n i) = dim_vec (col A i)" by (metis dim_col dim_mult_mat_vec) fix j assume j_in_dim:"j < dim_vec (col A i)" have "(A *\<^sub>v unit_vec n i) $ j = row A j \<bullet> unit_vec n i" using j_in_dim by fastforce also have "\<dots> = row A j $ i" using assms(2) scalar_prod_right_unit by blast also have "\<dots> = col A i $ j" using assms(1) assms(2) j_in_dim by force ultimately show "(A *\<^sub>v unit_vec n i) $ j = col A i $ j" by presburger qed lemma distinct_cols_append_rows: fixes A :: "'a mat" assumes "A \<in> carrier_mat nr1 n" assumes "B \<in> carrier_mat nr2 n" assumes "distinct (cols A)" shows "distinct (cols (A @\<^sub>r B))" proof - have AB_dim_row: "dim_row (A @\<^sub>r B) = nr1 + nr2" using assms(1) assms(2) carrier_matD(1) by blast have AB_dim_col:"dim_col (A @\<^sub>r B) = n" using assms(1) assms(2) carrier_matD(2) by blast have "(submatrix (A @\<^sub>r B) {0..<nr1} UNIV) = A" proof have "{i. i<dim_row (A @\<^sub>r B) \<and> i\<in> {0..<nr1}} = {0..<nr1}" using AB_dim_row by fastforce then have "(card {i. i<dim_row (A @\<^sub>r B) \<and> i\<in> {0..<nr1}}) = nr1" by auto then show "dim_row (submatrix (A @\<^sub>r B) {0..<nr1} UNIV) = dim_row A" using dim_submatrix[of "(A @\<^sub>r B)" "{0..<nr1}"] carrier_matD(1)[OF assms(1)] by presburger show "dim_col (submatrix (A @\<^sub>r B) {0..<nr1} UNIV) = dim_col A" using dim_col_submatrix_UNIV[of "(A @\<^sub>r B)" "{0..<nr1}"] AB_dim_col carrier_matD(2)[OF assms(1)] by argo fix i j assume i_dimA:"i < dim_row A" assume j_dimA:"j < dim_col A" have i_dimAB:"i < dim_row (A @\<^sub>r B)" by (metis AB_dim_row \<open>i < dim_row A\<close> assms(1) carrier_matD(1) trans_less_add1) have j_dimAB:"j < dim_col (A @\<^sub>r B)" by (metis AB_dim_col \<open>j < dim_col A\<close> assms(1) carrier_matD(2)) show " submatrix (A @\<^sub>r B) {0..<nr1} UNIV $$ (i, j) = A $$ (i, j)" proof - have "i < nr1" using `i < dim_row A` using assms(1) by blast then have "{a\<in>{0..<nr1}. a < i} = {0..<i}" by auto then have "card {a\<in>{0..<nr1}. a < i} = i" by simp then have "submatrix (A @\<^sub>r B) {0..<nr1} UNIV $$ (i, j) = (A @\<^sub>r B) $$ (i, j)" using submatrix_index_card[of i "A @\<^sub>r B" j "{0..<nr1}" UNIV] i_dimAB \<open>i < nr1\<close> j_dimAB by force also have " (A @\<^sub>r B) $$ (i, j) = A $$ (i, j)" using append_rows_index_same[of A nr1 B nr2] assms(1-2) by (metis i_dimA i_dimAB j_dimA j_dimAB index_row(1)) ultimately show "submatrix (A @\<^sub>r B) {0..<nr1} UNIV $$ (i, j) = A $$ (i, j)" by presburger qed qed then show ?thesis by (metis distinct_cols_submatrix_UNIV assms(3)) qed lemma append_rows_eq: assumes A: "A \<in> carrier_mat nr1 nc" and B: "B \<in> carrier_mat nr2 nc" and a: "a \<in> carrier_vec nr1" and v: "v \<in> carrier_vec nc" shows "(A @\<^sub>r B) *\<^sub>v v = (a @\<^sub>v b) \<longleftrightarrow> A *\<^sub>v v = a \<and> B *\<^sub>v v = b" unfolding mat_mult_append[OF A B v] by (rule append_vec_eq[OF _ a], insert A v, auto) lemma mult_vec_in_lin_dep_set: assumes "v \<in> carrier_vec n" assumes "u \<in> carrier_vec n" assumes "v = k \<cdot>\<^sub>v u" assumes "v \<noteq> u" assumes "u \<in> S" assumes "v \<in> S" shows "lin_dep S" proof - have "0\<^sub>v n = v - k \<cdot>\<^sub>v u " using assms(1) assms(3) by force let ?a = "(\<lambda> x. 0)(u:= -k, v:= 1)" have "lincomb ?a {u, v} = lincomb ?a {v} + ?a u \<cdot>\<^sub>v u" using M.add.m_comm assms(1) assms(2) assms(4) lincomb_insert by force then have "lincomb ?a {u, v} = ?a v \<cdot>\<^sub>v v + ?a u \<cdot>\<^sub>v u + lincomb ?a {}" using assms(1) assms(3) lincomb_insert by fastforce then have "lincomb ?a {u, v} = ?a v \<cdot>\<^sub>v v + ?a u \<cdot>\<^sub>v u + 0\<^sub>v n" using lincomb_empty by presburger then have "lincomb ?a {u, v} = 1 \<cdot>\<^sub>v v + (-k)\<cdot>\<^sub>v u" using assms(2) assms(3) assms(4) by force then have "0\<^sub>v n = lincomb ?a {u, v}" using assms(2) assms(3) by force have "finite {u, v}" by auto have "{u, v} \<subseteq> S" using assms(5-6) by auto have "?a v \<noteq> 0" by auto then show ?thesis unfolding lin_dep_def `0\<^sub>v n = lincomb ?a {u, v}` using \<open>finite {u, v}\<close> \<open>{u, v} \<subseteq> S\<close> by blast qed lemma row_in_set_rows: fixes A :: "'a mat" assumes "i < dim_row A" shows "row A i \<in> set (rows A)" by (metis assms in_set_conv_nth length_rows nth_rows) lemma mult_row_lin_dep: fixes A :: "'a mat" assumes"A \<in> carrier_mat nr n" assumes "i < nr" assumes "j < nr" assumes "k \<noteq> 1" assumes "row A i = k \<cdot>\<^sub>v row A j" shows "lin_dep (set (rows A))" proof - have i_dim: "i < dim_row A" using assms(1) assms(2) by blast have j_dim: "j < dim_row A" using assms(1) assms(3) by blast show ?thesis proof(cases "row A j = 0\<^sub>v n") case True then have "0\<^sub>v n \<in> (set (rows A))" apply(simp add: in_set_conv_nth sym[OF nth_rows[OF j_dim]]) using j_dim by blast then show ?thesis using field.one_not_zero one_zeroI zero_lin_dep by presburger next case False have "row A i \<noteq> row A j" proof(rule ccontr) assume " \<not> row A i \<noteq> row A j" then have "row A i = row A j" by auto then have "row A j = k \<cdot>\<^sub>v row A j" using assms(5) by auto then have "(1 - k) \<cdot>\<^sub>v row A j = 0\<^sub>v n" apply(auto simp: diff_smult_distrib_vec) by (meson assms(1) assms(3) minus_cancel_vec row_carrier_vec) then have "1 - k = 0" by (metis False rmult_0 smult_vec_nonneg_eq) then show False by (simp add: assms(4)) qed show ?thesis using mult_vec_in_lin_dep_set[of "row A i" "row A j" k " (set (rows A))"] apply(simp add: assms(3)) apply (simp add: sym[OF assms(5)] `row A i \<noteq> row A j`) using row_in_set_rows i_dim j_dim assms(1) row_carrier_vec by blast qed qed lemma add_left_diff_then_eq: fixes x :: "'a vec" assumes "x \<in> carrier_vec n" assumes "a \<in> carrier_vec n" assumes " b \<in> carrier_vec n" assumes "x = x + a - b" shows "a = b" proof - have "a - b = 0\<^sub>v n" using add.l_cancel_one[of x "a-b"] assms by (simp add: add_diff_eq_vec) then have "a - b + b = 0\<^sub>v n + b" by argo then show ?thesis apply(auto simp: comm_add_vec[OF zero_carrier_vec assms(3)] right_zero_vec[OF assms(3)]) using M.minus_equality assms(2) assms(3) minus_add_uminus_vec by fastforce qed lemma lin_indpt_rows_le_dim_cols: fixes A :: "'a mat" assumes "A \<in> carrier_mat nr n" assumes "lin_indpt (set (rows A))" assumes "distinct (rows A)" shows "nr \<le> n" proof - have "rank A\<^sup>T = nr" by (simp add: assms vec_space.lin_indpt_full_rank) have "set (rows A) \<subseteq> carrier_vec n" using assms(1) set_rows_carrier by blast then have "(set (cols A\<^sup>T)) \<subseteq> carrier_vec n" by simp then have "dim_span (set (cols A\<^sup>T)) \<le> n" using dim_span_le_n by blast have "rank A\<^sup>T = dim_span (set (cols A\<^sup>T))" by (metis \<open>rank A\<^sup>T = nr\<close> \<open>set (cols A\<^sup>T) \<subseteq> carrier_vec n\<close> assms carrier_matD(1) cols_length cols_transpose distinct_card index_transpose_mat(3) same_span_imp_card_eq_dim_span) then show "nr \<le> n" using \<open>dim_span (set (cols A\<^sup>T)) \<le> n\<close> \<open>rank A\<^sup>T = nr\<close> by presburger qed lemma mat_of_rows_rows: assumes "\<forall>x \<in> set l. x \<in> carrier_vec n" shows "rows (mat_of_rows n l) = l" by (simp add: assms subsetI) lemma one_solution_system_sq_mat: fixes A :: "'a mat" assumes "A \<in> carrier_mat nr n" assumes b: "b \<in> carrier_vec nr" assumes "\<exists>! x \<in> carrier_vec n. A *\<^sub>v x = b" assumes "lin_indpt (set (rows A))" assumes "distinct (rows A)" shows "nr = n" proof(cases "nr = 0") case True then have "nr = 0" by auto then have dim_rowA: "dim_row A = 0" using assms(1) by blast have dim_vecb:" dim_vec b = 0" using True assms(2) carrier_vecD by blast then have "\<forall>x \<in> carrier_vec n. A *\<^sub>v x = b" by (insert dim_mult_mat_vec[of A], simp only: dim_rowA vec_of_dim_0, blast) then have "\<exists>!(x:: 'a vec). x \<in> carrier_vec n" using assms(3) by auto have "n = 0" proof(rule ccontr) assume "n \<noteq> 0" have "(1\<^sub>v n:: 'a vec) \<noteq> (0\<^sub>v n:: 'a vec)" by (metis \<open>n \<noteq> 0\<close> index_one_vec(1) index_zero_vec(1) neq0_conv zero_neq_one) then show False using \<open>\<exists>!x. x \<in> carrier_vec n\<close> one_carrier_vec by blast qed then show ?thesis using True by auto next case False then have "nr > 0" by auto have dim_colA: "dim_col A = n" using assms(1) by blast have "distinct (cols A)" proof(rule ccontr) assume "\<not> distinct (cols A)" then obtain i j where "i < length (cols A) \<and> j < length (cols A) \<and> i \<noteq> j \<and> cols A ! i = cols A ! j" using distinct_conv_nth by blast then have i_j:"i < n \<and> j < n \<and> i \<noteq> j \<and> col A i = col A j" by(simp only: cols_length cols_nth, simp add: dim_colA) obtain x where x:"x \<in> carrier_vec n \<and> A *\<^sub>v x = b" using assms(3) by auto let ?y = "x + (unit_vec n i) - (unit_vec n j)" have "?y \<in> carrier_vec n" by (simp add: x) have colA_carr:"col A j \<in> carrier_vec nr" by (meson assms(1) col_carrier_vec i_j) have " A *\<^sub>v ?y= b" proof - have "A *\<^sub>v ?y = A *\<^sub>v x + A *\<^sub>v unit_vec n i - A *\<^sub>v unit_vec n j" apply(insert mult_minus_distrib_mat_vec[of A nr n "(x + unit_vec n i)" "unit_vec n j"]) apply(insert mult_add_distrib_mat_vec[of A nr n "x" "unit_vec n i"]) by (simp add: x assms(1)) then show "A *\<^sub>v ?y= b" apply(simp, insert mult_unit_vec_is_col[OF assms(1)], simp add: i_j) using colA_carr x add_diff_cancel_right_vec b by blast qed have "unit_vec n i \<noteq> unit_vec n j" by (simp add: i_j) have "x \<noteq> ?y" using add_left_diff_then_eq[of x "unit_vec n i" "unit_vec n j"] by (meson \<open>unit_vec n i \<noteq> unit_vec n j\<close> unit_vec_carrier x) then show False using \<open>A *\<^sub>v ?y = b\<close> \<open>?y \<in> carrier_vec n\<close> assms(3) x by blast qed have "nr \<le> n" using lin_indpt_rows_le_dim_cols assms(1) assms(4) assms(5) by blast show "nr = n" proof(cases "nr < n") case True then show ?thesis proof - define fullb where fullb: "fullb = b @\<^sub>v (vec n (\<lambda> k. (of_int k + 2) * b $ 0 ))" define app_rows where app_rows: "app_rows = mat_of_rows n (map (\<lambda> k. (of_int k + 2) \<cdot>\<^sub>v row A 0) [0..<n-nr])" define fullA where fullA: "fullA = A @\<^sub>r app_rows" have app_rows_dims: "app_rows \<in> carrier_mat (n-nr) n" by (simp add: app_rows mat_of_rows_def) have sq_fullA: "fullA \<in> carrier_mat n n" unfolding fullA apply(insert carrier_append_rows[of A nr n app_rows "n-nr"]) by (simp add: app_rows_dims \<open>nr \<le> n\<close> assms(1)) have len_rows: "length (rows A) = nr" using assms(1) length_rows by blast have dim_rowA: "dim_row A = nr" using assms(1) by blast have distinct_rows:"distinct (rows fullA)" proof(rule ccontr) assume "\<not> distinct (rows fullA)" then obtain i j where "i < n \<and> j < n \<and> i \<noteq> j \<and> rows fullA ! i = rows fullA ! j" by (metis carrier_matD(1) distinct_conv_nth length_rows sq_fullA) then have i_j:"i < n \<and> j < n \<and> i \<noteq> j \<and> row fullA i = row fullA j" by (metis sq_fullA carrier_matD(1) nth_rows) show False proof(cases "i < nr") case True have "row fullA i = row A i" unfolding fullA app_rows using append_rows_nth(1) True app_rows_dims app_rows assms(1) by blast show ?thesis proof(cases "j < nr") case True have "row fullA j = row A j" unfolding fullA app_rows using append_rows_nth(1) True app_rows_dims app_rows assms(1) by blast then have "rows A ! i = rows A ! j" apply(auto simp: `i < nr` `j < nr` dim_rowA) using \<open>row fullA i =row A i\<close> i_j by presburger then show ?thesis using len_rows `i < nr` assms(5) distinct_conv_nth i_j True by blast next case False then have "j - nr < dim_row app_rows" by (simp add: app_rows diff_less_mono i_j) have "nr \<le> j" using False by auto have "j < nr + (n - nr)" using False i_j by linarith then have "row fullA j = row app_rows (j-nr)" using fullA append_rows_nth(2) `nr \<le> j` app_rows_dims assms(1) by blast also have "\<dots> = rows app_rows ! (j-nr)" by(auto simp: \<open>j - nr < dim_row app_rows\<close>) also have 1: "\<dots> = (map (\<lambda>k. (of_int k + 2) \<cdot>\<^sub>v row A 0) (map int [0..<n - nr])) ! (j-nr)" using \<open>0 < nr\<close> \<open>j - nr < dim_row app_rows\<close> app_rows assms(1) by auto also have "\<dots> = of_int ((j - nr) + 2) \<cdot>\<^sub>v row A 0" using \<open>j - nr < dim_row app_rows\<close> app_rows by auto finally have "row A i = of_int ((j - nr) + 2) \<cdot>\<^sub>v row A 0" using \<open>row fullA i = row A i\<close> i_j by presburger then show ?thesis using mult_row_lin_dep[of A nr i 0 "of_int ((j - nr) + 2)"] using True assms(1) assms(4) by fastforce qed next case False then have "i \<ge> nr" by auto then have "i - nr < dim_row app_rows" by (simp add: diff_less_mono i_j app_rows) have "i < nr + (n - nr)" using False i_j by linarith then have "row fullA i = row app_rows (i-nr)" using fullA append_rows_nth(2) `nr \<le> i` app_rows_dims assms(1) by blast also have "row app_rows (i-nr) = rows app_rows ! (i-nr)" by (auto simp: \<open>i - nr < dim_row app_rows\<close>) also have 1: "\<dots> = (map (\<lambda>k. (of_int k + 2) \<cdot>\<^sub>v row A 0) (map int [0..<n - nr])) ! (i-nr)" using \<open>0 < nr\<close> \<open>i - nr < dim_row app_rows\<close> app_rows assms(1) by auto also have "\<dots> = of_int ((i - nr) + 2) \<cdot>\<^sub>v row A 0" using \<open>i - nr < dim_row app_rows\<close> app_rows by auto finally have "row fullA i = of_int ((i - nr) + 2) \<cdot>\<^sub>v row A 0" using \<open>row fullA i = row app_rows (i-nr)\<close> i_j by presburger show ?thesis proof(cases "j < nr") case True have "row fullA j = row A j" unfolding fullA app_rows using append_rows_nth(1) True app_rows_dims app_rows assms(1) by blast have "row A j = of_int ((i - nr) + 2) \<cdot>\<^sub>v row A 0" using `row fullA i = of_int ((i - nr) + 2) \<cdot>\<^sub>v row A 0` \<open>row fullA j = row A j\<close> i_j by presburger then show ?thesis using mult_row_lin_dep[of A nr j 0 "of_int ((i - nr) + 2)"] `nr \<noteq> 0` using True assms(1) assms(4) by fastforce next case False then have "j - nr < dim_row app_rows" by (simp add: diff_less_mono i_j app_rows) have "nr \<le> j" using False by auto have "j < nr + (n - nr)" using False i_j by linarith then have "row fullA j = row app_rows (j-nr)" using fullA append_rows_nth(2) `nr \<le> j` app_rows_dims assms(1) by blast also have "\<dots> = rows app_rows ! (j-nr)" by(auto simp: \<open>j - nr < dim_row app_rows\<close>) also have 1: "\<dots> = (map (\<lambda>k. (of_int k + 2) \<cdot>\<^sub>v row A 0) (map int [0..<n - nr])) ! (j-nr)" using \<open>0 < nr\<close> \<open>j - nr < dim_row app_rows\<close> app_rows assms(1) by auto also have "\<dots> = of_int ((j - nr) + 2) \<cdot>\<^sub>v row A 0" using \<open>j - nr < dim_row app_rows\<close> app_rows by auto finally have "row fullA j = of_int ((j - nr) + 2) \<cdot>\<^sub>v row A 0" using i_j by presburger then have "of_int ((i - nr) + 2) \<cdot>\<^sub>v row A 0 = of_int ((j - nr) + 2) \<cdot>\<^sub>v row A 0" using \<open>row fullA i = of_int (int (i - nr + 2)) \<cdot>\<^sub>v row A 0\<close> i_j by presburger then have "of_int ((i - nr) + 2) \<cdot>\<^sub>v row A 0 - of_int ((j - nr) + 2) \<cdot>\<^sub>v row A 0 = 0\<^sub>v n" using \<open>0 < nr\<close> assms(1) by auto then have smult_zero:"(of_int ((i - nr) + 2) - of_int ((j - nr) + 2)) \<cdot>\<^sub>v row A 0 = 0\<^sub>v n" by (metis diff_smult_distrib_vec) show ?thesis proof(cases "row A 0 = 0\<^sub>v n") case True then have "0\<^sub>v n \<in> (set (rows A))" by (metis \<open>0 < nr\<close> dim_rowA row_in_set_rows) then show ?thesis using assms(4) field.one_not_zero zero_lin_dep by blast next case False then show False by (metis False R.minus_other_side smult_zero \<open>nr \<le> i\<close> \<open>nr \<le> j\<close> diff_add_inverse2 eq_diff_iff i_j of_int_of_nat_eq of_nat_eq_iff smult_r_null smult_vec_nonneg_eq) qed qed qed qed have distinct_cols:"distinct (cols fullA)" using \<open>distinct (cols A)\<close> app_rows_dims assms(1) fullA distinct_cols_append_rows by blast have "lin_dep (set (rows fullA))" proof - have "row fullA nr = row app_rows 0" using True app_rows_dims append_rows_index_same' assms(1) fullA by auto have "row app_rows 0 = (map (\<lambda>k. (of_int k + 2) \<cdot>\<^sub>v row A 0) (map int [0..<n - nr])) ! 0" using True assms(1) `nr > 0` app_rows by fastforce then have "row fullA nr = 2 \<cdot>\<^sub>v row A 0" by(simp add: \<open>row fullA nr = row app_rows 0\<close> True) moreover have "row fullA 0 = row A 0" using append_rows_nth(1) \<open>0 < nr\<close> app_rows_dims assms(1) fullA by blast ultimately show ?thesis using mult_row_lin_dep[of fullA n nr 0 2] True sq_fullA by simp qed then have "lin_dep (set (cols fullA))" using lin_dep_cols_iff_rows[of fullA] distinct_rows distinct_cols sq_fullA by fastforce then obtain v where v:"v \<in> carrier_vec n" "v \<noteq> 0\<^sub>v n" "fullA *\<^sub>v v = 0\<^sub>v n" using lin_depE[of fullA] sq_fullA distinct_cols by blast then have "(A @\<^sub>r app_rows) *\<^sub>v v = A *\<^sub>v v @\<^sub>v app_rows *\<^sub>v v" by (meson app_rows_dims assms(1) mat_mult_append) have " 0\<^sub>v nr @\<^sub>v 0\<^sub>v (n - nr) = 0\<^sub>v n" using \<open>nr \<le> n\<close> by fastforce have "A *\<^sub>v v = 0\<^sub>v nr" using append_rows_eq[of A nr n app_rows "n-nr" "0\<^sub>v nr" v "0\<^sub>v (n-nr)" ] apply(simp add: `0\<^sub>v nr @\<^sub>v 0\<^sub>v (n - nr) = 0\<^sub>v n` app_rows_dims assms(1) v(1)) using fullA v(3) by blast+ obtain x where x:"x \<in> carrier_vec n \<and> A *\<^sub>v x = b" using assms(3) by auto then have "x + v \<noteq> x" by (simp add: v(1-2)) have "A *\<^sub>v (x + v) = b" proof - have "A *\<^sub>v (x + v) = A *\<^sub>v x + A *\<^sub>v v" using v(1) x assms(1) mult_add_distrib_mat_vec by blast then show ?thesis by (simp add: \<open>A *\<^sub>v v = 0\<^sub>v nr\<close> x b) qed then show ?thesis by (metis \<open>x + v \<noteq> x\<close> add_carrier_vec assms(3) v(1) x) qed next case False then show ?thesis by (simp add: \<open>nr \<le> n\<close> nless_le) qed qed lemma bounded_min_faces_square_mat: fixes A :: "'a mat" fixes bound:: "'a" assumes A: "A \<in> carrier_mat nr n" assumes b: "b \<in> carrier_vec nr" defines "P \<equiv> polyhedron A b" assumes "P \<noteq> {}" assumes bounded: "(\<forall> x \<in> P. \<forall> i < n. x $ i \<le> bound) \<or> (\<forall> x \<in> P. \<forall> i < n. x $ i \<ge> bound)" assumes "min_face P F" assumes "dim_vec b' = Min {dim_vec d | C d I'. F = {x. x \<in> carrier_vec n \<and> C *\<^sub>v x = d} \<and> (C, d) = sub_system A b I'}" assumes " F = {x. x \<in> carrier_vec n \<and> A' *\<^sub>v x = b'}" assumes "(A', b') = sub_system A b I" shows "dim_row A' = n" proof - have "card F = 1" using bounded_min_faces_are_vertex bounded_min_faces_are_vertex' assms(1-6) by metis then have "\<exists>!x. x \<in> F" using card_eq_Suc_0_ex1 by (metis One_nat_def) then have 1:"\<exists>!x. x \<in> carrier_vec n \<and> A' *\<^sub>v x = b'" using assms(8) by auto have "lin_indpt (set (rows A'))" using min_face_lin_indpt[of A nr b F b' A' I] using A P_def assms(4) assms(6) assms(7) assms(8) assms(9) b by fastforce have "distinct (rows A')" using min_face_distinct using A P_def assms(4) assms(6) assms(7) assms(8) assms(9) b by blast have 2:"A' \<in> carrier_mat (dim_row A') n" by (metis A assms(9) b carrier_matD(1) carrier_matD(2) carrier_mat_subsyst carrier_vecD fst_conv) have "b' \<in> carrier_vec (dim_row A')" by (metis \<open>A' \<in> carrier_mat (dim_row A') n\<close> 1 mult_mat_vec_carrier) then show "dim_row A' = n" using one_solution_system_sq_mat[of A' "dim_row A'" b'] 2 1 \<open>distinct (rows A')\<close> \<open>lin_indpt (set (rows A'))\<close> by blast qed lemma minus_mult_minus_one: fixes v :: "'a vec" shows "- v = - 1 \<cdot>\<^sub>v v" unfolding smult_vec_def proof show "dim_vec (- v) = dim_vec (vec (dim_vec v) (\<lambda>i. - 1 * v $ i))" by simp fix i assume asmi:"i < dim_vec (vec (dim_vec v) (\<lambda>i. - 1 * v $ i))" have "(- v) $ i = - (v $ i)" using \<open>i < dim_vec (vec (dim_vec v) (\<lambda>i. - 1 * v $ i))\<close> by force have "- (v $ i) = - 1 * v $ i" by simp then show " (- v) $ i = vec (dim_vec v) (\<lambda>i. - 1 * v $ i) $ i" by (metis \<open>(- v) $ i = - v $ i\<close> asmi dim_vec index_vec) qed lemma vec_carr_add_mono: fixes x y:: "'a vec" assumes "x \<in> carrier_vec n" assumes "y \<in> carrier_vec n" assumes "a \<in> carrier_vec n" assumes "b \<in> carrier_vec n" assumes "x \<le> a" assumes "y \<le> b" shows "x + y \<le> a + b" by (metis assms(3) assms(4) assms(5) assms(6) carrier_vecD vec_add_mono) lemma bound_vec_smult_bound: fixes S :: "'a vec set" assumes "S \<subseteq> carrier_vec n" assumes "\<forall> x \<in> S. \<forall> i < n. x $ i \<le> 1" assumes "\<forall> x \<in> S. \<forall> i < n. x $ i \<ge> - 1" assumes "n > 0" assumes "c \<in> carrier_vec n" shows "\<exists> bnd. \<forall> x \<in>S. c \<bullet> x \<le> bnd" proof - have "\<forall> x \<in>S. c \<bullet> x \<le> of_int n * Max (abs ` (vec_set c))" proof fix x assume "x \<in> S" have 1:"x \<in> carrier_vec n" using `x \<in> S` using assms(1) by blast have 2:"\<forall> i < n. x $ i \<le> 1" using \<open>x \<in> S\<close> assms(2) by blast have 3:"\<forall> i < n. x $ i \<ge> -1" using \<open>x \<in> S\<close> assms(3) by blast have "set\<^sub>v c \<noteq> {}" using `n > 0` by (metis carrier_vecD equals0D vec_setI assms(5)) have "Max (abs ` (vec_set c)) \<ge> 0" by (metis (mono_tags, lifting) Max_in \<open>set\<^sub>v c \<noteq> {}\<close> abs_ge_zero finite_imageI finite_vec_set imageE image_is_empty) have "c \<bullet> 1\<^sub>v n = sum (\<lambda> i. c $ i) {0..<n}" using assms(5) scalar_prod_right_one by blast have "\<forall> i < n. c $ i * x $ i \<le> abs (c $ i)" proof(safe) fix i assume "i< n" show "c $ i * x $ i \<le> \<bar>c $ i\<bar>" proof(cases "x $ i = 0") case True then show ?thesis by simp next case False then show ?thesis proof(cases "c $ i > 0") case True have "x $ i \<le> 1" by (simp add: "2" \<open>i < n\<close>) then have "c $ i * x $ i \<le> c $ i" by (simp add: True) then show ?thesis by linarith next case False have "x $ i \<ge> - 1" by (simp add: "3" \<open>i < n\<close>) then have "c $ i * x $ i \<le> - c $ i" using False by (metis mult_le_cancel_left mult_minus1_right) then show ?thesis by linarith qed qed qed then have "\<forall> i < n. c $ i * x $ i \<le> Max (abs ` (vec_set c))" by (smt (verit) Max_ge assms(5) carrier_vecD dual_order.order_iff_strict finite_imageI finite_vec_set image_eqI order_less_le_trans vec_setI) then have "(\<And>i. i \<in> {0..<n} \<Longrightarrow> c $ i * x $ i \<le> Max (abs ` set\<^sub>v c))" by auto then have "sum (\<lambda> i. c $ i * x $ i ) {0..<n} \<le> of_int n * Max (abs ` (vec_set c))" using sum_bounded_above[of "{0..<n}" "(\<lambda> i. c $ i * x $ i )" "Max (abs ` (vec_set c))"] by fastforce then have " c \<bullet> x \<le> of_int n * Max (abs ` (vec_set c))" unfolding scalar_prod_def using "1" carrier_vecD by blast then show " c \<bullet> x \<le> of_int (int n) * Max (abs ` set\<^sub>v c)" by blast qed then show " \<exists>bnd. \<forall>x\<in>S. c \<bullet> x \<le> bnd" by auto qed lemma int_mat_replace_col_int_mat: assumes "A \<in> carrier_mat n n" assumes "b \<in> carrier_vec n" assumes "A \<in> \<int>\<^sub>m" assumes "b \<in> \<int>\<^sub>v" assumes "k < n" shows "det (replace_col A b k) \<in> \<int>" proof - have 1:"(replace_col A b k) = mat (dim_row A) (dim_col A) (\<lambda> (i,j). if j = k then b $ i else A $$ (i,j))" unfolding replace_col_def by auto have "(replace_col A b k) \<in> \<int>\<^sub>m" unfolding Ints_mat_def proof(safe) fix i j assume asmi:"i < dim_row (replace_col A b k)" assume asmj:"j < dim_col (replace_col A b k)" show "replace_col A b k $$ (i, j) \<in> \<int>" proof(cases "j = k") case True have "replace_col A b k $$ (i, j) = b $ i" unfolding replace_col_def using "1" True asmi assms(1) assms(5) by auto then show ?thesis by (metis (no_types, lifting) Ints_vec_def asmi 1 assms(1,2,4) carrier_matD(1) carrier_vecD dim_row_mat(1) mem_Collect_eq) next case False have "replace_col A b k $$ (i, j) = A $$ (i,j)" unfolding replace_col_def using "1" False asmi asmj by fastforce then show ?thesis using Ints_mat_def asmi asmj 1 assms(3) by auto qed qed then show "det (replace_col A b k) \<in> \<int>" using Ints_det using Ints_mat_def by blast qed lemma submatrix_int_mat: assumes "A \<in> \<int>\<^sub>m" shows "submatrix A I J \<in> \<int>\<^sub>m" proof - show "submatrix A I J \<in> \<int>\<^sub>m" using assms unfolding Ints_mat_def submatrix_def proof(safe) fix i j assume "\<forall>i<dim_row A. \<forall>j<dim_col A. A $$ (i, j) \<in> \<int>" assume asmi:"i < dim_row (Matrix.mat (card {i. i < dim_row A \<and> i \<in> I}) (card {j. j < dim_col A \<and> j \<in> J}) (\<lambda>(i, j). A $$ (pick I i, pick J j)))" assume asmj:"j < dim_col (Matrix.mat (card {i. i < dim_row A \<and> i \<in> I}) (card {j. j < dim_col A \<and> j \<in> J}) (\<lambda>(i, j). A $$ (pick I i, pick J j)))" show "Matrix.mat (card {i. i < dim_row A \<and> i \<in> I}) (card {j. j < dim_col A \<and> j \<in> J}) (\<lambda>(i, j). A $$ (pick I i, pick J j)) $$ (i, j) \<in> \<int>" proof - have "A $$ (pick I i, pick J j) \<in> \<int>" proof - have "i < (card {i. i < dim_row A \<and> i \<in> I})" using asmi by auto then have "pick I i < dim_row A" using pick_le by presburger have "j < (card {i. i < dim_col A \<and> i \<in> J})" using asmj by fastforce then have "pick J j < dim_col A" using pick_le by presburger then show ?thesis using \<open>\<forall>i<dim_row A. \<forall>j<dim_col A. A $$ (i, j) \<in> \<int>\<close> \<open>pick I i < dim_row A\<close> by blast qed then show ?thesis using asmi asmj by simp qed qed qed lemma append_int_mat_is_int: assumes "A \<in> carrier_mat nr1 n" assumes "B \<in> carrier_mat nr2 n" assumes "A \<in> \<int>\<^sub>m" assumes "B \<in> \<int>\<^sub>m" shows "A @\<^sub>r B \<in> \<int>\<^sub>m" proof - show "A @\<^sub>r B \<in> \<int>\<^sub>m" unfolding Ints_mat_def proof(safe) fix i j assume asmi:"i < dim_row (A @\<^sub>r B)" assume asmj:"j < dim_col (A @\<^sub>r B)" show "(A @\<^sub>r B) $$ (i, j) \<in> \<int>" proof(cases "i<dim_row A") case True have 1:"row (A @\<^sub>r B) i = row A i" using True Missing_Matrix.append_rows_nth(1) assms(1) assms(2) by blast have 2:"(A @\<^sub>r B) $$ (i, j) = row (A @\<^sub>r B) i $ j" by (simp add: asmi asmj) have "j < dim_col A" by (metis 1 asmj index_row(2)) then have "A $$ (i, j) = row A i $ j" by (simp add: True) then have "(A @\<^sub>r B) $$ (i, j) = A $$ (i, j)" using 1 2 by presburger then show ?thesis using assms(3) unfolding Ints_mat_def using True \<open>j < dim_col A\<close> by force next case False have 1:"row (A @\<^sub>r B) i = row B (i - nr1)" using False Missing_Matrix.append_rows_nth(2) assms(1) assms(2) by (metis (no_types, lifting) asmi append_rows_def carrier_matD(1) index_mat_four_block(2) index_zero_mat(2) not_less) have 2:"(A @\<^sub>r B) $$ (i, j) = row (A @\<^sub>r B) i $ j" by (simp add: asmi asmj) have "j < dim_col B" by (metis 1 asmj index_row(2)) then have "B $$ (i-nr1, j) = row B (i-nr1) $ j" using False 1 2 by (metis (mono_tags, lifting) asmi add_0_right append_rows_def assms(1-2) carrier_matD(1) carrier_matD(2) index_mat_four_block(1) index_mat_four_block(2) index_zero_mat(3)) then have "(A @\<^sub>r B) $$ (i, j) = B $$ (i - nr1, j)" using 2 1 by presburger then show ?thesis using assms(4) unfolding Ints_mat_def by (metis (no_types, lifting) False asmi \<open>j < dim_col B\<close> append_rows_def assms(1) carrier_matD(1) index_mat_four_block(2) index_zero_mat(2) le_add_diff_inverse mem_Collect_eq nat_add_left_cancel_less not_less) qed qed qed lemma append_int_vec_is_int: assumes "v \<in> carrier_vec nr1" assumes "w \<in> carrier_vec nr2" assumes "v \<in> \<int>\<^sub>v" assumes "w \<in> \<int>\<^sub>v" shows "v @\<^sub>v w \<in> \<int>\<^sub>v" unfolding Ints_vec_def proof(safe) fix i assume asmi:"i < dim_vec (v @\<^sub>v w) " show "(v @\<^sub>v w) $v i \<in> \<int>" proof(cases "i < nr1") case True have "(v @\<^sub>v w) $v i = v $ i" using True by (metis asmi assms(1) carrier_vecD index_append_vec(1) index_append_vec(2)) then show ?thesis using assms(3) unfolding Ints_vec_def using True assms(1) by auto next case False have "(v @\<^sub>v w) $v i = w $ (i - nr1)" by (metis False asmi assms(1) carrier_vecD index_append_vec(1) index_append_vec(2)) then show ?thesis using assms(4) unfolding Ints_vec_def using False assms(2) using \<open>i < dim_vec (v @\<^sub>v w)\<close> assms(1) by auto qed qed lemma one_mat_int: "1\<^sub>m n \<in> \<int>\<^sub>m" unfolding Ints_mat_def one_mat_def proof(safe) fix i j assume asmi:"i < dim_row (Matrix.mat n n (\<lambda>(i, j). if i = j then 1 else 0))" assume asmj:"j < dim_col (Matrix.mat n n (\<lambda>(i, j). if i = j then 1 else 0))" show "Matrix.mat n n (\<lambda>(i, j). if i = j then 1 else 0) $$ (i, j) \<in> \<int>" proof(cases "i=j") case True have "Matrix.mat n n (\<lambda>(i, j). if i = j then 1 else 0) $$ (i, j) = 1" using True asmi by auto then show ?thesis by (smt (verit, ccfv_SIG) Ints_1) next case False have "Matrix.mat n n (\<lambda>(i, j). if i = j then 1 else 0) $$ (i, j) = 0" using False asmi asmj by simp then show ?thesis by (smt (verit) Ints_0) qed qed lemma subvec_int_int: assumes bI: "b \<in> \<int>\<^sub>v" shows "vec_of_list (nths (list_of_vec b) I) \<in> \<int>\<^sub>v" using assms unfolding Ints_vec_def proof(safe) fix i assume "\<forall>i<dim_vec b. b $v i \<in> \<int> " assume asmi:"i < dim_vec (vec_of_list (nths (list_of_vec b) I))" show " vec_of_list (nths (list_of_vec b) I) $v i \<in> \<int>" proof - have "vec_of_list (nths (list_of_vec b) I) $v i = (nths (list_of_vec b) I) ! i" by (metis vec_of_list_index) obtain j where "j< length (list_of_vec b)" "(list_of_vec b) ! j = (nths (list_of_vec b) I) ! i" by (metis Matrix.dim_vec_of_list asmi in_set_conv_nth notin_set_nthsI) then have "(list_of_vec b) ! j \<in> \<int>" by (metis Matrix.length_list_of_vec \<open>\<forall>i<dim_vec b. b $v i \<in> \<int>\<close> list_of_vec_index) then show ?thesis by (simp add: \<open>list_of_vec b ! j = nths (list_of_vec b) I ! i\<close>) qed qed lemma one_vec_int: "1\<^sub>v n \<in> \<int>\<^sub>v " unfolding Ints_vec_def by fastforce lemma bounded_min_faces_det_non_zero: fixes A :: "'a mat" fixes bound:: "'a" assumes A: "A \<in> carrier_mat nr n" assumes b: "b \<in> carrier_vec nr" defines "P \<equiv> polyhedron A b" assumes "P \<noteq> {}" assumes bounded: "(\<forall> x \<in> P. \<forall> i < n. x $ i \<le> bound) \<or> (\<forall> x \<in> P. \<forall> i < n. x $ i \<ge> bound)" assumes "min_face P F" assumes "dim_vec b' = Min {dim_vec d | C d I'. F = {x. x \<in> carrier_vec n \<and> C *\<^sub>v x = d} \<and> (C, d) = sub_system A b I'}" assumes " F = {x. x \<in> carrier_vec n \<and> A' *\<^sub>v x = b'}" assumes "(A', b') = sub_system A b I" shows "det A' \<noteq> 0" proof - have 1: "polyhedron A b \<noteq> {}" using assms(3) assms(4) by blast have 2: "(\<forall> x \<in> polyhedron A b. \<forall> i < n. x $ i \<le> bound) \<or> (\<forall> x \<in> polyhedron A b. \<forall> i < n. x $ i \<ge> bound)" using assms(3) assms(5) by fastforce have 3: "min_face (polyhedron A b) F" using assms(3) assms(6) by blast have "dim_row A' = n" using bounded_min_faces_square_mat[OF A b 1 2 3] using assms(7-9) by blast then have "A' \<in> carrier_mat n n" using A carrier_matD(2) carrier_matI dim_col_subsyst_mat fst_conv by (metis assms(9)) then have "lin_indpt (set (rows A'))" using min_face_lin_indpt[OF A b 1 3] using assms(7-9) by blast have "distinct (rows A')" using min_face_distinct[OF A b 1 3] using assms(7-9) by blast have "(rows A') = cols (A'\<^sup>T)" by simp have "lin_indpt (set (cols A'\<^sup>T))" using `lin_indpt (set (rows A'))` by auto have "distinct (cols A'\<^sup>T)" using `distinct (rows A')` by auto have "A' \<in> carrier_mat (dim_row A') n" by (metis assms(1,9) carrier_matD(2) carrier_matI dim_col_subsyst_mat fst_conv) then have "rank A'\<^sup>T = dim_row A'" using lin_indpt_full_rank[of "A'\<^sup>T" "dim_row A'"] `lin_indpt (set (cols A'\<^sup>T))` `distinct (cols A'\<^sup>T)` transpose_carrier_mat by blast then show "det A' \<noteq> 0" by (metis \<open>A' \<in> carrier_mat (dim_row A') n\<close> \<open>dim_row A' = n\<close> det_rank_iff det_transpose transpose_carrier_mat) qed lemma min_face_has_int: fixes A :: "'a mat" fixes bound:: "'a" assumes A: "A \<in> carrier_mat nr n" assumes b: "b \<in> carrier_vec nr" assumes AI: "A \<in> \<int>\<^sub>m" assumes bI: "b \<in> \<int>\<^sub>v" defines "P \<equiv> polyhedron A b" assumes "P \<noteq> {}" assumes bounded: "(\<forall> x \<in> P. \<forall> i < n. x $ i \<le> bound) \<or> (\<forall> x \<in> P. \<forall> i < n. x $ i \<ge> bound)" assumes "min_face P F" assumes "dim_vec b' = Min {dim_vec d | C d I'. F = {x. x \<in> carrier_vec n \<and> C *\<^sub>v x = d} \<and> (C, d) = sub_system A b I'}" assumes " F = {x. x \<in> carrier_vec n \<and> A' *\<^sub>v x = b'}" assumes "(A', b') = sub_system A b I" shows "\<exists> x \<in> F. abs(det A') \<cdot>\<^sub>v x \<in> \<int>\<^sub>v" proof - obtain z where "z \<in> F" using assms(8) by (metis ex_in_conv face_non_empty gram_schmidt.min_face_elim(1)) have 1: "polyhedron A b \<noteq> {}" using assms(5) assms(6) by auto have 2: " (\<forall>x\<in>local.polyhedron A b. \<forall>i<n. x $v i \<le> bound) \<or> (\<forall>x\<in>local.polyhedron A b. \<forall>i<n. bound \<le> x $v i) " using assms(5) assms(7) by fastforce have 3: "min_face (polyhedron A b) F " using assms(5) assms(8) by blast have "det A' \<noteq> 0" using bounded_min_faces_det_non_zero[OF A b 1 2 3 assms(9) assms(10) assms(11)] by blast have "dim_row A' = n" using bounded_min_faces_square_mat[OF A b 1 2 3] using assms(9-11) by blast then have "A' \<in> carrier_mat n n" by (metis A assms(11) carrier_matD(2) carrier_matI dim_col_subsyst_mat fst_conv) have 5:"A' *\<^sub>v z = b' \<longleftrightarrow> z = vec n (\<lambda> k. det (replace_col A' b' k) / det A')" using cramer1[of A' n b' z] `det A' \<noteq> 0` `A' \<in> carrier_mat n n` using \<open>z \<in> F\<close> assms(10) by fastforce then have 4:"z = vec n (\<lambda> k. det (replace_col A' b' k) / det A')" using assms(10) \<open>z \<in> F\<close> by force have "det A \<in> \<int>" using Ints_det AI using Ints_mat_def by blast have "dim_vec z = n" using 4 dim_vec by blast have "A' \<in> \<int>\<^sub>m" using submatrix_int_mat[of A I UNIV] assms(11) `A \<in> \<int>\<^sub>m` unfolding sub_system_def by blast have "b' \<in> \<int>\<^sub>v" using subvec_int_int[of b I] assms(11) `b \<in> \<int>\<^sub>v` unfolding sub_system_def by blast have "\<forall> k < n. det (replace_col A' b' k) \<in> \<int>" using int_mat_replace_col_int_mat[of A' b'] dim_mult_mat_vec 5 \<open>A' \<in> \<int>\<^sub>m\<close> \<open>A' \<in> carrier_mat n n\<close> \<open>b' \<in> \<int>\<^sub>v\<close> \<open>dim_row A' = n\<close> 4 carrier_dim_vec by blast let ?z' = "abs(det A') \<cdot>\<^sub>v z" have "?z' \<in> \<int>\<^sub>v" proof - have "\<forall>k < n. z $ k = det (replace_col A' b' k) / det A'" using 4 index_vec by blast then have "\<forall>k < n. (\<lambda>i. \<bar>det A'\<bar> * z $v i) k = (\<lambda>k. \<bar>det A'\<bar> * det (replace_col A' b' k) / det A') k " by (metis times_divide_eq_right) then have 6:"?z' = vec n (\<lambda> k. \<bar>det A'\<bar> * det (replace_col A' b' k) / det A')" unfolding smult_vec_def by (auto simp: `dim_vec z = n` 4) have "\<bar>det A'\<bar> /det A' \<in> \<int>" proof(cases "det A' > 0") case True have "\<bar>det A'\<bar> /det A' = 1" by (metis True \<open>Determinant.det A' \<noteq> 0\<close> abs_of_pos divide_self) then show ?thesis by fastforce next case False have "\<bar>det A'\<bar> /det A' = - 1" using False \<open>Determinant.det A' \<noteq> 0\<close> by (metis abs_if divide_eq_minus_1_iff linorder_neqE_linordered_idom) then show ?thesis by auto qed then have "\<forall>k < n.\<bar>det A'\<bar> * det (replace_col A' b' k) / det A' \<in> \<int>" by (metis Ints_mult \<open>\<forall>k<n. Determinant.det (replace_col A' b' k) \<in> \<int>\<close> times_divide_eq_left) then have "vec n (\<lambda> k. \<bar>det A'\<bar> * det (replace_col A' b' k) / det A') \<in> \<int>\<^sub>v" unfolding Ints_vec_def by simp then show ?thesis using 6 by presburger qed show " \<exists>x\<in>F. \<bar>Determinant.det A'\<bar> \<cdot>\<^sub>v x \<in> \<int>\<^sub>v" using \<open>\<bar>Determinant.det A'\<bar> \<cdot>\<^sub>v z \<in> \<int>\<^sub>v\<close> \<open>z \<in> F\<close> by blast qed end context gram_schmidt_floor begin lemma int_hull_bound_then_poly_bounded: fixes A :: "'a mat" fixes b:: "'a vec" assumes A: "A \<in> carrier_mat nr n" assumes b: "b \<in> carrier_vec nr" defines "P \<equiv> polyhedron A b" assumes c: "c \<in> carrier_vec n" assumes "has_Maximum {c \<bullet> x | x. x \<in> integer_hull P}" assumes AI: "A \<in> \<int>\<^sub>m" assumes bI: "b \<in> \<int>\<^sub>v" assumes "integer_hull P \<noteq> {}" shows "has_Maximum { c \<bullet> x | x. x \<in> P}" proof(rule ccontr) assume "\<not> has_Maximum {c \<bullet> x |x. x \<in> P}" then have "\<not> (\<exists> x. x \<in> {c \<bullet> x |x. x \<in> P} \<and> (\<forall> y \<in> {c \<bullet> x |x. x \<in> P}. y \<le> x))" unfolding has_Maximum_def by blast then have "\<forall>x \<in> {c \<bullet> x |x. x \<in> P}. \<not> (\<forall> y \<in> {c \<bullet> x |x. x \<in> P}. y \<le> x)" by blast then have "\<forall>x \<in> {c \<bullet> x |x. x \<in> P}. (\<exists> y \<in> {c \<bullet> x |x. x \<in> P}. y > x)" by fastforce then have "\<forall>x \<in> P. \<exists> y \<in> P. c \<bullet> y > c \<bullet> x" by auto have "P \<noteq> {}" using assms(8) by (metis P_def assms(1) b gram_schmidt.int_hull_subset subset_empty) have "\<forall> v. \<exists> x \<in> P. c \<bullet> x \<ge> v" proof(rule ccontr) assume "\<not> (\<forall>v. \<exists>x\<in>P. v \<le> c \<bullet> x)" then obtain Bnd where "\<forall> y \<in> P. c \<bullet> y < Bnd" by (meson less_le_not_le linorder_linear) then have "\<forall> x \<in> carrier_vec n. A *\<^sub>v x \<le> b \<longrightarrow> c \<bullet> x \<le> Bnd" unfolding P_def polyhedron_def using order_le_less by auto then have "has_Maximum {c \<bullet> x | x. x \<in> carrier_vec n \<and> A *\<^sub>v x \<le> b}" using strong_duality_theorem_primal_sat_bounded_min_max(2)[OF A b c] by (metis (no_types, lifting) Collect_empty_eq P_def `P \<noteq> {}` local.polyhedron_def) then show False using `\<not> has_Maximum {c \<bullet> x |x. x \<in> P}` unfolding P_def polyhedron_def by fastforce qed then have "\<forall>v. \<exists>x\<in>carrier_vec n. A *\<^sub>v x \<le> b \<and> v \<le> c \<bullet> x" unfolding P_def polyhedron_def by auto then have "\<not> (\<exists> y. y \<ge> 0\<^sub>v nr \<and> A\<^sup>T *\<^sub>v y = c)" using unbounded_primal_solutions[of A nr n b c] A b c by blast then have "\<not> (\<forall> y. y \<in> carrier_vec n \<longrightarrow> A *\<^sub>v y \<ge> 0\<^sub>v nr \<longrightarrow> y \<bullet> c \<ge> 0)" using Farkas_Lemma[of "A\<^sup>T" nr c] c using c A by force then obtain y where y: "y \<in> carrier_vec n \<and> A *\<^sub>v y \<ge> 0\<^sub>v nr \<and> y \<bullet> c < 0" using leI by blast have "(-y) \<bullet> c > 0" using assms(4) y by auto have "A *\<^sub>v (-y) \<le> 0\<^sub>v nr" by (smt (verit, ccfv_SIG) A carrier_matD(1) class_ring.minus_zero dim_mult_mat_vec minus_mult_minus_one index_uminus_vec(1) index_zero_vec(1) less_eq_vec_def mult_mat_vec neg_le_iff_le y) then obtain y' where y': "y' \<in> carrier_vec n \<and> A *\<^sub>v y' \<le> 0\<^sub>v nr \<and> y' \<bullet> c > 0" using \<open>0 < - y \<bullet> c\<close> uminus_carrier_vec y by blast have "y' \<noteq> 0\<^sub>v n" proof assume "y' = 0\<^sub>v n" then have "y' \<bullet> c = 0" using c assms(7) row_carrier scalar_prod_left_zero by blast then show False using y' by linarith qed have "n \<noteq> 0" proof assume "n=0" then have "y' = 0\<^sub>v 0" using carrier_vecD vec_of_dim_0 y' by blast then show False using `y' \<noteq> 0\<^sub>v n` using \<open>n = 0\<close> by blast qed then have "set\<^sub>v y' \<noteq> {}" by (metis carrier_vecD equals0D not_gr_zero vec_setI y') have "Max (abs ` (vec_set y')) > 0" proof(rule ccontr) assume "\<not> 0 < Max (abs ` set\<^sub>v y')" have "\<forall> y \<in> (abs ` set\<^sub>v y'). y \<ge> 0" by fastforce have "finite (abs ` set\<^sub>v y')" by fastforce have "(abs ` set\<^sub>v y') \<noteq> {}" using \<open>set\<^sub>v y' \<noteq> {}\<close> by blast then have " Max (abs ` set\<^sub>v y') \<ge> 0" by (meson Max_in \<open>\<forall>y\<in>abs ` set\<^sub>v y'. 0 \<le> y\<close> \<open>finite (abs ` set\<^sub>v y')\<close>) then have "Max (abs ` (vec_set y')) = 0" using \<open>\<not> 0 < Max (abs ` set\<^sub>v y')\<close> by linarith then have "\<forall> y' \<in> (abs ` set\<^sub>v y'). y' = 0" by (metis Max_ge \<open>\<forall>y'\<in>abs ` set\<^sub>v y'. 0 \<le> y'\<close> \<open>finite (abs ` set\<^sub>v y')\<close> order_antisym_conv) then have "\<forall>y' \<in> set\<^sub>v y'. y' = 0" by auto then have "y' = 0\<^sub>v n" unfolding zero_vec_def by (metis M.zero_closed \<open>y' \<noteq> 0\<^sub>v n\<close> carrier_vecD eq_vecI index_zero_vec(1) vec_setI y') then show False using \<open>y' \<noteq> 0\<^sub>v n\<close> by auto qed let ?y' = " (1/Max (abs ` (vec_set y'))) \<cdot>\<^sub>v y'" let ?fullA = "A @\<^sub>r (1\<^sub>m n) @\<^sub>r (- 1\<^sub>m n)" let ?fullb = "0\<^sub>v nr @\<^sub>v 1\<^sub>v n @\<^sub>v 1\<^sub>v n" let ?c = "c" let ?P' = "polyhedron ?fullA ?fullb" have 2:"?fullA \<in> carrier_mat (nr+2*n) n" by (metis A carrier_append_rows mult_2 one_carrier_mat uminus_carrier_iff_mat) have 3:"?fullb \<in> carrier_vec (nr+2*n)" by (simp add: mult_2) have "?y' \<in> ?P'" proof - have "A *\<^sub>v y' \<le> 0\<^sub>v nr" using y' by auto then have "(1/Max (abs ` (vec_set y'))) \<cdot>\<^sub>v (A *\<^sub>v y') \<le> 0\<^sub>v nr" using \<open>Max (abs ` (vec_set y')) > 0\<close> by (meson divide_nonneg_pos smult_nneg_npos_vec zero_less_one_class.zero_le_one) then have "A *\<^sub>v ?y' \<le> 0\<^sub>v nr" by (metis A mult_mat_vec y') have "\<forall> i < n. row (1\<^sub>m n) i \<bullet> ?y' \<le> 1" proof(safe) fix i assume "i< n" have 2:"row (1\<^sub>m n) i = unit_vec n i" using \<open>i < n\<close> row_one by blast have 1:"unit_vec n i \<bullet> ?y' = ?y' $ i" by (meson \<open>i < n\<close> scalar_prod_left_unit smult_closed y') have "y' $ i \<le> Max (abs ` set\<^sub>v y')" by (metis (mono_tags, lifting) Max_ge \<open>0 < Max (abs ` set\<^sub>v y')\<close> \<open>i < n\<close> abs_of_pos carrier_vecD finite_imageI finite_vec_set image_eqI linorder_le_less_linear order.asym order_less_le_trans vec_setI y') then have "(1 / Max (abs ` set\<^sub>v y')) * (y' $ i) \<le> 1" by (metis \<open>0 < Max (abs ` set\<^sub>v y')\<close> divide_pos_pos mult_le_cancel_left_pos nonzero_eq_divide_eq order_less_irrefl zero_less_one_class.zero_less_one) have "(1 / Max (abs ` set\<^sub>v y') \<cdot>\<^sub>v y') $ i \<le> 1" by (metis \<open>1 / Max (abs ` set\<^sub>v y') * y' $ i \<le> 1\<close> \<open>i < n\<close> carrier_vecD index_smult_vec(1) y') then show "row (1\<^sub>m n) i \<bullet> ?y' \<le> 1" by (simp add: 2 1) qed then have "1\<^sub>m n *\<^sub>v ?y' \<le> 1\<^sub>v n" unfolding mult_mat_vec_def by (simp add: less_eq_vec_def) have "\<forall> i < n. row (- 1\<^sub>m n) i \<bullet> ?y' \<le> 1" proof(safe) fix i assume "i< n" have " row (- 1\<^sub>m n) i = - unit_vec n i" using \<open>i < n\<close> row_one by simp have 3:"- unit_vec n i \<bullet> ?y' = - ?y' $ i" by (metis \<open>i < n\<close> scalar_prod_left_unit smult_closed uminus_scalar_prod unit_vec_carrier y') have "- y' $ i \<le> Max (abs ` set\<^sub>v y')" by (metis Max_ge \<open>i < n\<close> abs_le_D2 carrier_vecD finite_imageI finite_vec_set image_eqI vec_setI y') then have "(1 / Max (abs ` set\<^sub>v y')) * (- y' $ i) \<le> 1" by (metis \<open>0 < Max (abs ` set\<^sub>v y')\<close> divide_pos_pos mult_le_cancel_left_pos nonzero_eq_divide_eq order_less_irrefl zero_less_one_class.zero_less_one) have " - (1 / Max (abs ` set\<^sub>v y') \<cdot>\<^sub>v y') $ i \<le> 1" by (metis \<open>1 / Max (abs ` set\<^sub>v y') * - y' $ i \<le> 1\<close> \<open>i < n\<close> carrier_vecD index_smult_vec(1) mult_minus_right y') then show "row (- 1\<^sub>m n) i \<bullet> ?y' \<le> 1" by (simp add: \<open>row (- 1\<^sub>m n) i = - unit_vec n i\<close> 3) qed then have "- 1\<^sub>m n *\<^sub>v ?y' \<le> 1\<^sub>v n" unfolding mult_mat_vec_def by (simp add: less_eq_vec_def) have "(1\<^sub>m n @\<^sub>r - 1\<^sub>m n) *\<^sub>v ?y' \<le> ( 1\<^sub>v n @\<^sub>v 1\<^sub>v n)" using `- 1\<^sub>m n *\<^sub>v ?y' \<le> 1\<^sub>v n` `1\<^sub>m n *\<^sub>v ?y' \<le> 1\<^sub>v n` append_rows_le by (metis carrier_matI index_one_mat(2) index_one_mat(3) index_uminus_mat(3) one_carrier_vec smult_closed y') then have "(A @\<^sub>r 1\<^sub>m n @\<^sub>r - 1\<^sub>m n) *\<^sub>v ?y' \<le> (0\<^sub>v nr @\<^sub>v 1\<^sub>v n @\<^sub>v 1\<^sub>v n)" using `- 1\<^sub>m n *\<^sub>v ?y' \<le> 1\<^sub>v n` append_rows_le[of "A" nr n "1\<^sub>m n @\<^sub>r - 1\<^sub>m n" "2*n" "0\<^sub>v nr" ?y' "1\<^sub>v n @\<^sub>v 1\<^sub>v n"] by (metis A \<open> A *\<^sub>v (1 / Max (abs ` set\<^sub>v y') \<cdot>\<^sub>v y') \<le> 0\<^sub>v nr\<close> carrier_append_rows mult.commute mult_2_right one_carrier_mat smult_closed uminus_carrier_iff_mat y' zero_carrier_vec) then show "?y' \<in> ?P'" unfolding polyhedron_def using y' by blast qed then have 1:"?P' \<noteq> {}" by auto have "\<exists> x \<in> carrier_vec n. ?fullA *\<^sub>v x \<le> ?fullb" using `?y' \<in> ?P'` unfolding polyhedron_def by auto have 4:"\<forall> x \<in> ?P'. \<forall> i < n. x $ i \<le> 1" proof fix x assume "x \<in> ?P'" have "x \<in> carrier_vec n" using `x \<in> ?P'` unfolding polyhedron_def by auto have "(A @\<^sub>r 1\<^sub>m n @\<^sub>r - 1\<^sub>m n) *\<^sub>v x \<le> (0\<^sub>v nr @\<^sub>v 1\<^sub>v n @\<^sub>v 1\<^sub>v n)" using `x \<in> ?P'` unfolding polyhedron_def by auto then have "(1\<^sub>m n @\<^sub>r - 1\<^sub>m n) *\<^sub>v x \<le> ( 1\<^sub>v n @\<^sub>v 1\<^sub>v n)" using append_rows_le[of "A" nr n "1\<^sub>m n @\<^sub>r - 1\<^sub>m n" "2*n" "0\<^sub>v nr" x "1\<^sub>v n @\<^sub>v 1\<^sub>v n"] by (metis A \<open>x \<in> carrier_vec n\<close> carrier_append_rows mult_2 one_carrier_mat uminus_carrier_mat zero_carrier_vec) then have "1\<^sub>m n *\<^sub>v x \<le> 1\<^sub>v n" using append_rows_le[of "1\<^sub>m n" n n "- 1\<^sub>m n" n "1\<^sub>v n" x "1\<^sub>v n"] by (simp add: \<open>x \<in> carrier_vec n\<close>) then have "\<forall> i < n. row (1\<^sub>m n) i \<bullet> x \<le> 1" unfolding mult_mat_vec_def by (simp add: less_eq_vec_def) then show " \<forall> i < n. x $ i \<le> 1" by (simp add: \<open>x \<in> carrier_vec n\<close>) qed have 5:"\<forall> x \<in> ?P'. \<forall> i < n. x $ i \<ge> - 1" proof fix x assume "x \<in> ?P'" have "x \<in> carrier_vec n" using `x \<in> ?P'` unfolding polyhedron_def by auto have "(A @\<^sub>r 1\<^sub>m n @\<^sub>r - 1\<^sub>m n) *\<^sub>v x \<le> (0\<^sub>v nr @\<^sub>v 1\<^sub>v n @\<^sub>v 1\<^sub>v n)" using `x \<in> ?P'` unfolding polyhedron_def by auto then have "(1\<^sub>m n @\<^sub>r - 1\<^sub>m n) *\<^sub>v x \<le> ( 1\<^sub>v n @\<^sub>v 1\<^sub>v n)" using append_rows_le[of "A" nr n "1\<^sub>m n @\<^sub>r - 1\<^sub>m n" "2*n" "0\<^sub>v nr" x "1\<^sub>v n @\<^sub>v 1\<^sub>v n"] by (metis A \<open>x \<in> carrier_vec n\<close> carrier_append_rows mult_2 one_carrier_mat uminus_carrier_mat zero_carrier_vec) then have " - 1\<^sub>m n *\<^sub>v x \<le> 1\<^sub>v n" using append_rows_le[of "1\<^sub>m n" n n "- 1\<^sub>m n" n "1\<^sub>v n" x "1\<^sub>v n"] by (simp add: \<open>x \<in> carrier_vec n\<close>) then have "\<forall> i < n. row (- 1\<^sub>m n) i \<bullet> x \<le> 1" unfolding mult_mat_vec_def by (simp add: less_eq_vec_def) then have "\<forall> i < n. - unit_vec n i \<bullet> x \<le> 1" by simp then have "\<forall> i < n. - x $ i \<le> 1" by (metis \<open>x \<in> carrier_vec n\<close> carrier_vecD index_unit_vec(3) scalar_prod_left_unit scalar_prod_uminus_left) then show " \<forall> i < n. x $ i \<ge> - 1" by (simp add: \<open>x \<in> carrier_vec n\<close>) qed have "?P' \<subseteq> carrier_vec n" unfolding polyhedron_def by auto have "?c \<in> carrier_vec n" using c by blast have "\<exists> bnd. \<forall> x \<in> carrier_vec n. ?fullA *\<^sub>v x \<le> ?fullb \<longrightarrow> ?c \<bullet> x \<le> bnd" using bound_vec_smult_bound[of ?P' ?c] apply (auto simp: 4 5 `n\<noteq>0` `?P' \<subseteq> carrier_vec n` `?c \<in> carrier_vec n`) unfolding polyhedron_def using \<open>n \<noteq> 0\<close> by auto then have 4:"has_Maximum {?c \<bullet> x | x. x \<in> carrier_vec n \<and> ?fullA *\<^sub>v x \<le> ?fullb}" using strong_duality_theorem_primal_sat_bounded_min_max[of ?fullA "nr+2*n" n ?fullb ?c] using 2 3 assms(7) row_carrier `\<exists> x \<in> carrier_vec n. ?fullA *\<^sub>v x \<le> ?fullb` c by blast then obtain \<beta> where beta: "\<beta> = Maximum {?c \<bullet> x | x. x \<in> carrier_vec n \<and> ?fullA *\<^sub>v x \<le> ?fullb}" by auto then have 4:"support_hyp ?P' ?c \<beta>" unfolding support_hyp_def by (smt (verit, best) c Collect_cong 4 assms(7) mem_Collect_eq polyhedron_def row_carrier) let ?F = " ?P' \<inter> {x |x. ?c \<bullet> x = \<beta>}" have "face ?P' ?F" unfolding face_def using 1 4 by blast then obtain F where F_def:"min_face ?P' F \<and> F \<subseteq> ?F" using 2 3 face_contains_min_face[of ?fullA "nr+2*n" ?fullb ?F] by blast then obtain z where "z \<in> F" by (metis ex_in_conv face_non_empty gram_schmidt.min_face_elim(1)) obtain A' b' I where A'_b':" F = {x. x \<in> carrier_vec n \<and> A' *\<^sub>v x = b'}" "(A', b') = sub_system ?fullA ?fullb I" "dim_vec b' = Min {dim_vec d| C d I. (C, d) = sub_system ?fullA ?fullb I \<and> F = {x. x \<in> carrier_vec n \<and> C *\<^sub>v x = d}}" using F_def min_face_min_subsyst[of ?fullA "(nr + 2*n)" ?fullb F] using 2 3 by (smt (verit, ccfv_SIG)) have 9: "(\<forall>x\<in>local.polyhedron (A @\<^sub>r 1\<^sub>m n @\<^sub>r - 1\<^sub>m n) (0\<^sub>v nr @\<^sub>v 1\<^sub>v n @\<^sub>v 1\<^sub>v n). \<forall>i<n. x $v i \<le> 1) \<or> (\<forall>x\<in>local.polyhedron (A @\<^sub>r 1\<^sub>m n @\<^sub>r - 1\<^sub>m n) (0\<^sub>v nr @\<^sub>v 1\<^sub>v n @\<^sub>v 1\<^sub>v n). \<forall>i<n. 1 \<le> x $v i)" using `\<forall> x \<in> ?P'. \<forall> i < n. x $ i \<le> 1` by blast have 10:"dim_vec b' = Min {dim_vec d| C d I. F = {x. x \<in> carrier_vec n \<and> C *\<^sub>v x = d} \<and> (C, d) = sub_system ?fullA ?fullb I}" by (smt (verit) A'_b'(3) Collect_cong) have "det A' \<noteq> 0" using bounded_min_faces_det_non_zero[OF 2 3 1 9] F_def A'_b' 10 by fast have "dim_row A' = n" using bounded_min_faces_square_mat[of ?fullA "nr+ 2*n" ?fullb 1 F b' A' I] using A'_b' `\<forall> x \<in> ?P'. \<forall> i < n. x $ i \<le> 1` 1 2 3 by (smt (verit, ccfv_SIG) Collect_cong F_def) then have "A' \<in> carrier_mat n n" by (metis "2" A'_b'(2) carrier_matD(2) carrier_matI dim_col_subsyst_mat fst_conv) have 7:"A' *\<^sub>v z = b' \<longleftrightarrow> z = vec n (\<lambda> k. det (replace_col A' b' k) / det A')" using cramer1[of A' n b' z] `det A' \<noteq> 0` `A' \<in> carrier_mat n n` using A'_b'(1) \<open>z \<in> F\<close> carrier_dim_vec dim_mult_mat_vec by blast then have 6:"z = vec n (\<lambda> k. det (replace_col A' b' k) / det A')" using A'_b'(1) \<open>z \<in> F\<close> by force have "det A \<in> \<int>" using Ints_det AI using Ints_mat_def by blast have "dim_vec z = n" using 6 dim_vec by blast have "1\<^sub>m n \<in> \<int>\<^sub>m" using one_mat_int by auto have "- 1\<^sub>m n \<in> \<int>\<^sub>m" using one_mat_int by auto have "?fullA \<in> \<int>\<^sub>m" using append_int_mat_is_int by (metis A \<open>- 1\<^sub>m n \<in> \<int>\<^sub>m\<close> assms(6) carrier_append_rows one_carrier_mat one_mat_int uminus_carrier_mat) have "?fullb \<in> \<int>\<^sub>v" using append_int_vec_is_int one_vec_int by (metis carrier_vec_dim_vec gram_schmidt.zero_vec_is_int) have "A' \<in> \<int>\<^sub>m" using submatrix_int_mat[of ?fullA I UNIV] A'_b'(2) `?fullA \<in> \<int>\<^sub>m` unfolding sub_system_def by blast have "b' \<in> \<int>\<^sub>v" using subvec_int_int[of ?fullb I] A'_b'(2) `?fullb \<in> \<int>\<^sub>v` unfolding sub_system_def by blast have "\<forall> k < n. det (replace_col A' b' k) \<in> \<int>" using int_mat_replace_col_int_mat[of A' b'] dim_mult_mat_vec using 7 \<open>A' \<in> \<int>\<^sub>m\<close> \<open>A' \<in> carrier_mat n n\<close> \<open>b' \<in> \<int>\<^sub>v\<close> \<open>dim_row A' = n\<close> 6 carrier_dim_vec by blast let ?z' = "abs(det A') \<cdot>\<^sub>v z" have "?z' \<in> \<int>\<^sub>v" proof - have "\<forall>k < n. z $ k = det (replace_col A' b' k) / det A'" using 6 index_vec by blast then have "\<forall>k < n. (\<lambda>i. \<bar>det A'\<bar> * z $v i) k = (\<lambda>k. \<bar>det A'\<bar> * det (replace_col A' b' k) / det A') k " by (metis times_divide_eq_right) then have 8:"?z' = vec n (\<lambda> k. \<bar>det A'\<bar> * det (replace_col A' b' k) / det A')" unfolding smult_vec_def using 6 by (auto simp: `dim_vec z = n`) have "\<bar>det A'\<bar> /det A' \<in> \<int>" proof(cases "det A' > 0") case True have "\<bar>det A'\<bar> /det A' = 1" by (metis True \<open>Determinant.det A' \<noteq> 0\<close> abs_of_pos divide_self) then show ?thesis by fastforce next case False have "\<bar>det A'\<bar> /det A' = - 1" using False \<open>Determinant.det A' \<noteq> 0\<close> by (metis abs_if divide_eq_minus_1_iff linorder_neqE_linordered_idom) then show ?thesis by auto qed then have "\<forall>k < n.\<bar>det A'\<bar> * det (replace_col A' b' k) / det A' \<in> \<int>" by (metis Ints_mult \<open>\<forall>k<n. Determinant.det (replace_col A' b' k) \<in> \<int>\<close> times_divide_eq_left) then have "vec n (\<lambda> k. \<bar>det A'\<bar> * det (replace_col A' b' k) / det A') \<in> \<int>\<^sub>v" unfolding Ints_vec_def by simp then show ?thesis using 8 by presburger qed have 9:"?c \<bullet> ?y' = (1 / Max (abs ` set\<^sub>v y')) * (?c \<bullet> y')" using y' assms(7) row_carrier scalar_prod_smult_distrib c by force have "(1 / Max (abs ` set\<^sub>v y')) > 0" using \<open>0 < Max (abs ` set\<^sub>v y')\<close> zero_less_divide_1_iff by blast then have "?c \<bullet> ?y' > 0" using y' by (metis "4" 9 comm_scalar_prod gram_schmidt.support_hyp_def linordered_semiring_strict_class.mult_pos_pos) have "\<beta> \<ge> ?c \<bullet> ?y'" using `?y' \<in> ?P'` unfolding polyhedron_def using beta using "4" \<open>?y' \<in> ?P'\<close> gram_schmidt.support_hyp_is_valid(1) by blast then have "\<beta> > 0" using \<open>0 < c \<bullet> (1 / Max (abs ` set\<^sub>v y') \<cdot>\<^sub>v y')\<close> by linarith have "z \<in> carrier_vec n" using A'_b'(1) \<open>z \<in> F\<close> by force have 12:"z \<in> ?F" using F_def \<open>z \<in> F\<close> by blast then have "A *\<^sub>v z \<le> 0\<^sub>v nr" unfolding polyhedron_def using append_rows_le[of "A" nr n "1\<^sub>m n @\<^sub>r - 1\<^sub>m n" "2*n" "0\<^sub>v nr" z "1\<^sub>v n @\<^sub>v 1\<^sub>v n"] by (simp add: A mult_2 ) then have "(A *\<^sub>v z) \<le> 0\<^sub>v nr" using A A'_b'(1) \<open>z \<in> F\<close> by force then have "A *\<^sub>v ?z' \<le> 0\<^sub>v nr" using A A'_b'(1) \<open>z \<in> F\<close> by (simp add: mult_mat_vec smult_nneg_npos_vec) have "c \<in> carrier_vec n" using c by blast have "P \<subseteq> carrier_vec n" unfolding P_def polyhedron_def by blast then have "integer_hull P \<subseteq> carrier_vec n" by (simp add: gram_schmidt.integer_hull_in_carrier) have "\<forall> \<alpha> \<in> carrier_vec n. has_Maximum { \<alpha> \<bullet> x | x. x \<in> integer_hull P} \<longrightarrow> (\<exists>x. x \<in> integer_hull P \<and> \<alpha> \<bullet> x = Maximum { \<alpha> \<bullet> x | x. x \<in> integer_hull P} \<and> x \<in> \<int>\<^sub>v)" proof - have "integer_hull P = integer_hull (integer_hull P)" using assms(5) unfolding P_def polyhedron_def by (metis (no_types, lifting) integer_hull_is_integer_hull mem_Collect_eq subset_iff) then have "(\<forall> F. face (integer_hull P) F \<longrightarrow> (\<exists> x \<in> F. x \<in> \<int>\<^sub>v))" using P_int_then_face_int \<open>integer_hull P \<subseteq> carrier_vec n\<close> by presburger then show ?thesis using int_face_then_max_suphyp_int `integer_hull P \<subseteq> carrier_vec n` using assms(7) carrier_vec_dim_vec by blast qed then obtain v where v:"v \<in> integer_hull P \<and> ?c \<bullet> v = Maximum { ?c \<bullet> x | x. x \<in> integer_hull P} \<and> v \<in> \<int>\<^sub>v" using assms(5) `c \<in> carrier_vec n` by meson then have "v \<in> integer_hull P" using assms(5) by blast then have "v \<in> P" using A P_def b int_hull_subset by blast have "A *\<^sub>v v \<le> b" using `v \<in> P` unfolding P_def polyhedron_def by auto have "v \<in> carrier_vec n" using v unfolding integer_hull_def P_def polyhedron_def using P_def \<open>v \<in> P\<close> gram_schmidt.polyhedron_def by blast have "?z' \<in> carrier_vec n" using `z \<in> carrier_vec n` by blast have 11:"\<forall> m::nat. v + of_int m \<cdot>\<^sub>v ?z' \<in> P" proof fix m::nat have " m \<ge> 0" by simp have "A *\<^sub>v (of_int m \<cdot>\<^sub>v ?z') = of_int m \<cdot>\<^sub>v ( A *\<^sub>v ?z')" using mult_mat_vec[of A nr n z "of_int m"] using A A'_b'(1) \<open>z \<in> F\<close> by force have "of_int m \<cdot>\<^sub>v ( A *\<^sub>v ?z') \<le> 0\<^sub>v nr" using smult_nneg_npos_vec[of "of_int m" "A *\<^sub>v ?z'" nr] by (simp add: ` m \<ge> 0` `A *\<^sub>v ?z' \<le> 0\<^sub>v nr`) then have "A *\<^sub>v (of_int m \<cdot>\<^sub>v ?z') \<le> 0\<^sub>v nr" using `A *\<^sub>v (of_int m \<cdot>\<^sub>v ?z') = of_int m \<cdot>\<^sub>v ( A *\<^sub>v ?z')` by auto have "v + of_int m \<cdot>\<^sub>v ?z' \<in> carrier_vec n" using \<open>\<bar>det A'\<bar> \<cdot>\<^sub>v z \<in> carrier_vec n\<close> \<open>v \<in> carrier_vec n\<close> by blast have 10:"A *\<^sub>v (v + of_int m \<cdot>\<^sub>v ?z') = A *\<^sub>v v + A *\<^sub>v (of_int m \<cdot>\<^sub>v ?z')" by (meson A \<open>\<bar>det A'\<bar> \<cdot>\<^sub>v z \<in> carrier_vec n\<close> \<open>v \<in> carrier_vec n\<close> mult_add_distrib_mat_vec smult_closed) have "A *\<^sub>v v + A *\<^sub>v (of_int m \<cdot>\<^sub>v ?z') \<le> b + 0\<^sub>v nr" using `A *\<^sub>v v \<le> b` `A *\<^sub>v (of_int m \<cdot>\<^sub>v ?z') \<le> 0\<^sub>v nr` using vec_add_mono by (metis b carrier_vecD index_zero_vec(2)) then have "A *\<^sub>v (v + of_int m \<cdot>\<^sub>v ?z') \<le> b" by (metis 10 b right_zero_vec) then show "v + of_int (int m) \<cdot>\<^sub>v (\<bar>det A'\<bar> \<cdot>\<^sub>v z) \<in> P" unfolding P_def polyhedron_def using \<open>v + of_int (int m) \<cdot>\<^sub>v (\<bar>det A'\<bar> \<cdot>\<^sub>v z) \<in> carrier_vec n\<close> by blast qed have "\<forall> m::nat. v + of_int m \<cdot>\<^sub>v ?z' \<in> \<int>\<^sub>v" proof fix m::nat have " m \<in> \<int>" by simp then have "of_int m \<cdot>\<^sub>v ?z' \<in> \<int>\<^sub>v" using int_mult_int_vec using Ints_of_int \<open>\<bar>det A'\<bar> \<cdot>\<^sub>v z \<in> \<int>\<^sub>v\<close> by blast then show "v + of_int m \<cdot>\<^sub>v ?z' \<in> \<int>\<^sub>v" using v \<open>\<bar>det A'\<bar> \<cdot>\<^sub>v z \<in> carrier_vec n\<close> \<open>v \<in> carrier_vec n\<close> sum_int_is_int by blast qed then have "\<forall> m::nat. v + of_int m \<cdot>\<^sub>v ?z' \<in> integer_hull P" by (metis A Diff_iff P_def 11 b gram_schmidt.not_in_int_hull_not_int) have "?c \<bullet> z = \<beta>" using 12 by blast then have "?c \<bullet> ?z' = abs (det A') * \<beta>" by (metis \<open>\<bar>det A'\<bar> \<cdot>\<^sub>v z \<in> carrier_vec n\<close> \<open>c \<in> carrier_vec n\<close> carrier_vecD index_smult_vec(2) scalar_prod_smult_right) have "v + ?z' \<in> \<int>\<^sub>v" using `\<forall> m::nat. v + of_int m \<cdot>\<^sub>v ?z' \<in> \<int>\<^sub>v` using \<open>\<bar>det A'\<bar> \<cdot>\<^sub>v z \<in> \<int>\<^sub>v\<close> \<open>\<bar>det A'\<bar> \<cdot>\<^sub>v z \<in> carrier_vec n\<close> \<open>v \<in> carrier_vec n\<close> gram_schmidt.sum_int_is_int v by blast have "v + ?z' \<in> P" proof - have " v + of_int 1 \<cdot>\<^sub>v ?z' \<in> P" using `\<forall> m::nat. v + of_int m \<cdot>\<^sub>v ?z' \<in> P` by (metis int_ops(2)) then show ?thesis by (metis of_int_hom.hom_one scalar_vec_one) qed then have "v + ?z' \<in> integer_hull P" by (metis \<open>\<forall>x. v + of_int (int x) \<cdot>\<^sub>v (\<bar>det A'\<bar> \<cdot>\<^sub>v z) \<in> integer_hull P\<close> of_int_hom.hom_one of_nat_1 scalar_vec_one) then have "v + ?z' \<in> integer_hull P " using assms(5) by blast then have "?c \<bullet> (v + ?z') \<le> Maximum { ?c \<bullet> x | x. x \<in> integer_hull P}" using assms(5) has_MaximumD(2) by blast have "?c \<bullet> (v + ?z') = ?c \<bullet> v + ?c \<bullet> ?z'" using \<open>\<bar>det A'\<bar> \<cdot>\<^sub>v z \<in> carrier_vec n\<close> \<open>c \<in> carrier_vec n\<close> \<open>v \<in> carrier_vec n\<close> scalar_prod_add_distrib by blast then have "?c \<bullet> (v + ?z') = Maximum { ?c \<bullet> x | x. x \<in> integer_hull P} + abs (det A') * \<beta>" using `?c \<bullet> ?z' = abs (det A') * \<beta>` v by presburger then have "?c \<bullet> (v + ?z') > Maximum { ?c \<bullet> x | x. x \<in> integer_hull P}" by (simp add: \<open>0 < \<beta>\<close> \<open>det A' \<noteq> 0\<close>) then show False using \<open>c \<bullet> (v + \<bar>det A'\<bar> \<cdot>\<^sub>v z) \<le> Maximum {c \<bullet> x |x. x \<in> integer_hull P}\<close> linorder_not_le by blast qed lemma int_support_hyp_then_int_polyhedron: fixes A :: "'a mat" fixes b:: "'a vec" assumes A: "A \<in> carrier_mat nr n" assumes b: "b \<in> carrier_vec nr" and AI: "A \<in> \<int>\<^sub>m" and bI: "b \<in> \<int>\<^sub>v" defines "P \<equiv> polyhedron A b" assumes "\<forall> \<alpha> \<in> carrier_vec n. has_Maximum { \<alpha> \<bullet> x | x. x \<in> P} \<longrightarrow> (\<exists>x. x \<in> P \<and> \<alpha> \<bullet> x = Maximum { \<alpha> \<bullet> x | x. x \<in> P} \<and> x \<in> \<int>\<^sub>v)" shows "P = integer_hull P" proof(cases "P = {}") case True then show ?thesis by (metis A P_def b int_hull_subset subset_empty) next case False obtain C d nr' where C_d:"C \<in> carrier_mat nr' n \<and> d \<in> carrier_vec nr' \<and> integer_hull P = polyhedron C d" using gram_schmidt_floor.integer_hull_of_polyhedron[of A nr n b P] assms by blast have "\<exists> Bnd. Bnd = Max (abs ` (elements_mat A \<union> vec_set b))" by blast have "integer_hull P \<noteq> {}" proof(rule ccontr) assume "\<not> integer_hull P \<noteq> {}" then have "convex_hull (P \<inter> \<int>\<^sub>v) = {}" unfolding integer_hull_def by argo then have "P \<inter> \<int>\<^sub>v = {}" using set_in_convex_hull by (metis A Diff_empty P_def \<open>\<not> integer_hull P \<noteq> {}\<close> b disjoint_iff_not_equal gram_schmidt.not_in_int_hull_not_int) have "nr > 0" proof(rule ccontr) assume "\<not> 0 < nr" then have "nr = 0" by auto then have "\<forall> x. A *\<^sub>v x \<le> b" by (metis A b carrier_matD(1) carrier_vecD leq_for_all_index_then_eq less_nat_zero_code) then have "P = carrier_vec n " unfolding P_def polyhedron_def by fast have "0\<^sub>v n \<in> \<int>\<^sub>v" using zero_vec_is_int by blast then show False using `P \<inter> \<int>\<^sub>v = {}` using \<open>P = carrier_vec n\<close> by blast qed then obtain i where "i < nr" by auto then have "has_Maximum { row A i \<bullet> x | x. x \<in> P}" using eq_in_P_has_max using A False P_def b by blast then have "\<exists>x. x \<in> P \<and> row A i \<bullet> x = Maximum { row A i \<bullet> x | x. x \<in> P} \<and> x \<in> \<int>\<^sub>v" using assms(6) by (meson A \<open>i < nr\<close> row_carrier_vec) then show False using \<open>P \<inter> \<int>\<^sub>v = {}\<close> by blast qed show ?thesis proof(rule ccontr) assume"P \<noteq> integer_hull P" then obtain y where y: "y \<in> P - integer_hull P" by (metis A Diff_iff P_def b int_hull_subset set_eq_subset subset_iff) then have "y \<in> carrier_vec n" unfolding P_def polyhedron_def by blast have "y \<notin> polyhedron C d" using C_d y by blast then obtain j where "j<nr' \<and> row C j \<bullet> y > d $ j" using y exists_eq_in_P_for_outside_elem [of C nr' d y] C_d `y \<in> carrier_vec n` by blast let ?\<alpha> = "row C j" let ?\<beta> = "d $ j" have "?\<alpha> \<in> carrier_vec n" by (meson C_d \<open>j < nr' \<and> d $ j < row C j \<bullet> y\<close> row_carrier_vec) have " has_Maximum { ?\<alpha> \<bullet> x | x. x \<in> P}" using int_hull_bound_then_poly_bounded[of A nr b ?\<alpha>] using A AI C_d False P_def \<open>integer_hull P \<noteq> {}\<close> \<open>j < nr' \<and> d $ j < row C j \<bullet> y\<close> assms(6) b bI eq_in_P_has_max by force then obtain x where x:"x \<in> P \<and> ?\<alpha> \<bullet> x = Maximum { ?\<alpha> \<bullet> x | x. x \<in> P} \<and> x \<in> \<int>\<^sub>v" using assms(6) by (meson \<open>row C j \<in> carrier_vec n\<close>) then have "?\<alpha> \<bullet> y \<le> ?\<alpha> \<bullet> x" using \<open>has_Maximum {row C j \<bullet> x |x. x \<in> P}\<close> has_MaximumD(2) y by fastforce have "x \<in> integer_hull P" unfolding integer_hull_def by (metis (no_types, lifting) A Diff_iff P_def x b integer_hull_def not_in_int_hull_not_int) have "?\<alpha> \<bullet> x \<le> d $ j" proof - have "x \<in> polyhedron C d" using C_d `x \<in> integer_hull P` by auto then have "x \<in> carrier_vec n \<and> C *\<^sub>v x \<le> d" unfolding polyhedron_def by auto then show ?thesis unfolding mult_mat_vec_def by (metis C_d \<open>j < nr' \<and> d $ j < row C j \<bullet> y\<close> \<open>x \<in> carrier_vec n \<and> C *\<^sub>v x \<le> d\<close> carrier_matD(1) carrier_vecD index_mult_mat_vec less_eq_vec_def) qed then have "?\<alpha> \<bullet> y \<le> d $ j" using \<open>row C j \<bullet> y \<le> row C j \<bullet> x\<close> by linarith then show False using \<open>j < nr' \<and> d $ j < row C j \<bullet> y\<close> linorder_not_le by blast qed qed lemma min_face_iff_int_polyh: fixes A :: "'a mat" fixes b:: "'a vec" assumes A: "A \<in> carrier_mat nr n" assumes b: "b \<in> carrier_vec nr" and AI: "A \<in> \<int>\<^sub>m" and bI: "b \<in> \<int>\<^sub>v" defines "P \<equiv> polyhedron A b" shows "(\<forall> F. min_face P F \<longrightarrow> (\<exists> x \<in> F. x \<in> \<int>\<^sub>v)) \<longleftrightarrow> P = integer_hull P" proof have carr_P: "P \<subseteq> carrier_vec n" unfolding P_def polyhedron_def by auto show " \<forall>F. min_face P F \<longrightarrow> (\<exists>x\<in>F. x \<in> \<int>\<^sub>v) \<Longrightarrow> P = integer_hull P" proof - assume asm: "\<forall>F. min_face P F \<longrightarrow> (\<exists>x\<in>F. x \<in> \<int>\<^sub>v)" have "(\<forall> F. face P F \<longrightarrow> (\<exists> x \<in> F. x \<in> \<int>\<^sub>v))" using A asm assms(2) assms(5) int_all_min_faces_then_int_all_faces by presburger then have "\<forall> \<alpha> \<in> carrier_vec n. has_Maximum { \<alpha> \<bullet> x | x. x \<in> P} \<longrightarrow> (\<exists>x. x \<in> P \<and> \<alpha> \<bullet> x = Maximum { \<alpha> \<bullet> x | x. x \<in> P} \<and> x \<in> \<int>\<^sub>v)" using int_face_then_max_suphyp_int carr_P by fastforce then show "P = integer_hull P" using int_support_hyp_then_int_polyhedron[OF A b AI bI] using assms(5) by fastforce qed show "P = integer_hull P \<Longrightarrow> \<forall>F. min_face P F \<longrightarrow> (\<exists>x\<in>F. x \<in> \<int>\<^sub>v)" using carr_P by (metis P_int_then_face_int gram_schmidt.min_face_elim(1)) qed lemma face_iff_int_polyh: fixes A :: "'a mat" fixes b:: "'a vec" assumes A: "A \<in> carrier_mat nr n" assumes b: "b \<in> carrier_vec nr" and AI: "A \<in> \<int>\<^sub>m" and bI: "b \<in> \<int>\<^sub>v" defines "P \<equiv> polyhedron A b" shows "(\<forall> F. face P F \<longrightarrow> (\<exists> x \<in> F. x \<in> \<int>\<^sub>v)) \<longleftrightarrow> P = integer_hull P" proof have carr_P: "P \<subseteq> carrier_vec n" unfolding P_def polyhedron_def by auto show " \<forall>F. face P F \<longrightarrow> (\<exists>x\<in>F. x \<in> \<int>\<^sub>v) \<Longrightarrow> P = integer_hull P" proof - assume asm: "\<forall>F. face P F \<longrightarrow> (\<exists>x\<in>F. x \<in> \<int>\<^sub>v)" then have "\<forall> \<alpha> \<in> carrier_vec n. has_Maximum { \<alpha> \<bullet> x | x. x \<in> P} \<longrightarrow> (\<exists>x. x \<in> P \<and> \<alpha> \<bullet> x = Maximum { \<alpha> \<bullet> x | x. x \<in> P} \<and> x \<in> \<int>\<^sub>v)" using int_face_then_max_suphyp_int carr_P by fastforce then show "P = integer_hull P" using int_support_hyp_then_int_polyhedron[OF A b AI bI] using assms(5) by fastforce qed show "P = integer_hull P \<Longrightarrow> \<forall>F. face P F \<longrightarrow> (\<exists>x\<in>F. x \<in> \<int>\<^sub>v)" using carr_P by (metis P_int_then_face_int) qed end end
State Before: C : Type u₁ inst✝¹ : Category C D : Type u₂ inst✝ : Category D e : C ≌ D Y : D ⊢ e.inverse.map ((counitInv e).app Y) ≫ (unitInv e).app (e.inverse.obj Y) = 𝟙 (e.inverse.obj Y) State After: C : Type u₁ inst✝¹ : Category C D : Type u₂ inst✝ : Category D e : C ≌ D Y : D ⊢ (e.unitIso.app (e.inverse.obj Y) ≪≫ e.inverse.mapIso (e.counitIso.app Y)).hom = (Iso.refl ((𝟭 C).obj (e.inverse.obj Y))).hom Tactic: erw [Iso.inv_eq_inv (e.unitIso.app (e.inverse.obj Y) ≪≫ e.inverse.mapIso (e.counitIso.app Y)) (Iso.refl _)] State Before: C : Type u₁ inst✝¹ : Category C D : Type u₂ inst✝ : Category D e : C ≌ D Y : D ⊢ (e.unitIso.app (e.inverse.obj Y) ≪≫ e.inverse.mapIso (e.counitIso.app Y)).hom = (Iso.refl ((𝟭 C).obj (e.inverse.obj Y))).hom State After: no goals Tactic: exact e.unit_inverse_comp Y
lemma complex_i_not_neg_numeral [simp]: "\<i> \<noteq> - numeral w"
def foo := @id def bar := @id theorem foo_eq {α} (x : α) : foo x = bar x := rfl example {p : Nat → Prop} {x} (h : x = bar 1) : p x := by simp [*, ← foo_eq] show p (foo 1) admit
module Test.FmtTest import IdrTest.Test import IdrTest.Expectation import Fmt simpleTest : Test simpleTest = test "Simple test" (\_ => assertEq (fmt "Hello") "Hello" ) stringTest : Test stringTest = test "String test" (\_ => assertEq (fmt "Hello %s" "world") "Hello world" ) intTest : Test intTest = test "String test" (\_ => assertEq (fmt "Health %d" 99) "Health 99" ) mixedTest : Test mixedTest = test "String test" (\_ => assertEq (fmt "Name %s Age %d" "Thomas" 50) "Name Thomas Age 50" ) export suite : Test suite = describe "Fmt Tests" [ simpleTest , stringTest , intTest , mixedTest ]
State Before: u : XgcdType hs : IsSpecial u ⊢ IsSpecial (finish u) State After: u : XgcdType hs : u.wp + u.zp + u.wp * u.zp = u.x * u.y ⊢ u.wp + (u.y * qp u + u.zp) + u.wp * (u.y * qp u + u.zp) = ((u.wp + 1) * qp u + u.x) * u.y Tactic: dsimp [IsSpecial, finish] at hs⊢ State Before: u : XgcdType hs : u.wp + u.zp + u.wp * u.zp = u.x * u.y ⊢ u.wp + (u.y * qp u + u.zp) + u.wp * (u.y * qp u + u.zp) = ((u.wp + 1) * qp u + u.x) * u.y State After: u : XgcdType hs : u.wp + u.zp + u.wp * u.zp = u.x * u.y ⊢ u.wp + (u.y * qp u + u.zp) + u.wp * (u.y * qp u + u.zp) = u.wp + u.zp + u.wp * u.zp + (u.wp + 1) * qp u * u.y Tactic: rw [add_mul _ _ u.y, add_comm _ (u.x * u.y), ← hs] State Before: u : XgcdType hs : u.wp + u.zp + u.wp * u.zp = u.x * u.y ⊢ u.wp + (u.y * qp u + u.zp) + u.wp * (u.y * qp u + u.zp) = u.wp + u.zp + u.wp * u.zp + (u.wp + 1) * qp u * u.y State After: no goals Tactic: ring
#include <stdio.h> #include <gsl/gsl_sf_bessel.h> int main( int argc, const char *argv[] ) { double x = 5.0 ; double y = gsl_sf_bessel_J0( x ) ; printf("J0(%g) = % .18e\n", x, y ) ; return 0 ; }
import analysis.calculus.lhopital import order.filter.at_top_bot /-! # Langmuir adsorption model This section defines Langmuir adsorption model from kinetics for a single adsorbate on a single site: <br> $$ θ = \frac{K Pₐ}{1 + K Pₐ} $$ where: - `θ` is the fractional occupancy of the adsorption sites - `K` is the adsorption constant describing the adsorption/desorption rates in equilibrium - `Pₐ` is the partial pressure of the adsorbate ### Assumption The model assumes the rate of adsorption `r_ad = k_ad * Pₐ * S` and <br> the rate of desorption `r_d = k_d * A` are equal at equilibrium conditions where: - `k_ad` is the adsorption constant - `k_d` is the desorption constant - `S` is the concentartion of all sites - `A` is the concentartion of occupied sites ### Constraints generated by Lean - `S ≠ 0` - `k_d ≠ 0` ### To-Do - Proof statistical mechanical derivation of the model - Generalize proof from properties of system -/ theorem Langmuir_single_site_old (Pₐ k_ad k_d A S : ℝ) (hreaction : let r_ad := k_ad*Pₐ*S, r_d := k_d*A in r_ad = r_d) (hS : S ≠ 0) (hk_d : k_d ≠ 0) : let θ := A/(S+A), K := k_ad/k_d in θ = K*Pₐ/(1+K*Pₐ) := begin simp at hreaction, rw [mul_comm k_d A, ← div_eq_div_iff hk_d hS] at hreaction, field_simp [hreaction], end noncomputable def langmuir_single_site_model (equilibrium_constant : ℝ) : ℝ → ℝ := λ P : ℝ, equilibrium_constant*P/(1+equilibrium_constant*P) def hernys_law_model (equilibrium_constant : ℝ) : ℝ → ℝ := λ P, equilibrium_constant*P theorem langmuir_single_site_kinetic_derivation {Pₐ k_ad k_d A S : ℝ} (hreaction : let r_ad := k_ad*Pₐ*S, r_d := k_d*A in r_ad = r_d) (hS : S ≠ 0) (hk_d : k_d ≠ 0) : let θ := A/(S+A), K := k_ad/k_d in θ = langmuir_single_site_model K Pₐ := begin simp [langmuir_single_site_model] at *, rw [mul_comm k_d A, ← div_eq_div_iff hk_d hS] at hreaction, field_simp [hreaction], end lemma lhopital_at_top_div_at_top_transformation (f g : ℝ → ℝ) (l : filter ℝ) : filter.tendsto (λ x, f x / g x) l = filter.tendsto ((λ x, (1 / g x) / (1 / f x))) l := by simp theorem langmuir_approx_henry_law_at_low_pressure {k_ad k_d : ℝ} (hk_ad : 0 < k_ad) (hk_d : 0 < k_d) : filter.tendsto ((langmuir_single_site_model (k_ad/k_d))/(hernys_law_model (k_ad/k_d))) (nhds_within 0 (set.Ioi 0)) (nhds 1) := begin simp [langmuir_single_site_model, hernys_law_model], apply deriv.lhopital_zero_nhds_right, { rw filter.eventually_iff_exists_mem, use (set.Ioi (0 : ℝ)), split, exact self_mem_nhds_within, intros, simp, apply differentiable_at.div, any_goals {simp}, simp at H, apply ne_of_gt, apply add_pos, exact zero_lt_one, apply mul_pos (div_pos hk_ad hk_d) H,}, { rw filter.eventually_iff_exists_mem, use (set.Ioi (0 : ℝ)), split, exact self_mem_nhds_within, intros, simp, apply not_or (ne_of_gt hk_ad) (ne_of_gt hk_d),}, { simp, rw nhds_within, apply filter.tendsto_inf_left, rw [show (0 : ℝ) = 0/1, by norm_num, show (λ (x : ℝ), k_ad / k_d * x / (1 + k_ad / k_d * x)) = (λ (x : ℝ), k_ad / k_d * x) / (λ x, (1 + k_ad / k_d * x)), by finish], apply filter.tendsto.div, rw show 0 = (k_ad/k_d * 0), by simp, apply filter.tendsto.const_mul, finish, rw show nhds (1 : ℝ) = nhds (1 + 0), by simp, apply filter.tendsto.const_add, rw show 0 = (k_ad/k_d * 0), by simp, apply filter.tendsto.const_mul, finish, exact zero_ne_one.symm,}, { rw nhds_within, apply filter.tendsto_inf_left, rw show 0 = (k_ad/k_d * 0), by simp, apply filter.tendsto.const_mul, finish,}, simp, end theorem langmuir_zero_loading_at_zero_pressure {k_ad k_d : ℝ} : langmuir_single_site_model (k_ad/k_d) 0 = 0 := begin field_simp [langmuir_single_site_model], end theorem langmuir_single_site_finite_loading {k_ad k_d : ℝ} (hk_ad : 0 < k_ad) (hk_d : 0 < k_d) : filter.tendsto (langmuir_single_site_model (k_ad/k_d)) filter.at_top (nhds (1 : ℝ)):= begin simp [langmuir_single_site_model], have hk_ad1 : k_ad ≠ 0 := ne_of_gt hk_ad, have hk_d1 : k_d ≠ 0 := ne_of_gt hk_d, -- rw lhopital_at_top_div_at_top_transformation, -- apply deriv.lhopital_zero_at_top, -- { rw filter.eventually_iff_exists_mem, -- use ({-k_d/k_ad}ᶜ), -- rw filter.mem_at_top_sets, -- split, -- use (-k_d/k_ad + 1), -- intros, -- apply ne_of_gt, -- have h : -k_d/k_ad < -k_d/k_ad + 1 := by simp, -- exact lt_of_lt_of_le h H, -- intros, -- apply differentiable_at.div (differentiable_at_const (1 : ℝ)), -- simp [differentiable_at.const_add], -- simp at H, -- field_simp, -- field_simp at H, -- rw [add_comm, add_eq_zero_iff_eq_neg], -- ring, -- exact H,}, -- { rw filter.eventually_iff_exists_mem, -- use (set.Ioi (0)), -- rw filter.mem_at_top_sets, -- split, -- use (k_d/k_ad), -- intros, -- simp, -- apply lt_of_lt_of_le _ H, -- rw lt_div_iff hk_ad, -- simpa using hk_d, -- intros, -- simp, -- push_neg, -- have h : y ≠ 0, -- { simp at H, -- apply ne_of_gt, exact H, -- }, -- exact ⟨h, hk_d1, hk_ad1⟩, -- }, -- { apply filter.tendsto.div_at_top tendsto_const_nhds, -- apply filter.tendsto_at_top_add_const_left, -- apply filter.tendsto.const_mul_at_top, -- rw lt_div_iff hk_d, -- simpa using hk_ad, -- finish, -- exact real.order_topology, -- exact real.topological_ring.to_topological_semiring.to_has_continuous_mul,}, -- { apply filter.tendsto.div_at_top tendsto_const_nhds, -- apply filter.tendsto.const_mul_at_top, -- rw lt_div_iff hk_d, -- simpa using hk_ad, -- finish, -- exact real.order_topology, -- exact real.topological_ring.to_topological_semiring.to_has_continuous_mul,}, -- { have hderiv1 : λ (x : ℝ), deriv (λ (x : ℝ), 1 / (1 + k_ad / k_d * x)) x -- }, end
data Tree : Set where leaf : Tree _∣_ : Tree → Tree → Tree {-# FOREIGN GHC data Tree = Leaf | Tree :| Tree #-} {-# COMPILE GHC Tree = data Tree (Leaf | (:|)) #-}
(** * Coq Proof Environment : Example *) Theorem negation_fn_applied_twice : forall (f : bool -> bool), (forall (x : bool), f x = (negb x)) -> forall (b : bool), f (f b) = b. Proof. intros f H []. - rewrite -> H; rewrite -> H. reflexivity. - rewrite -> H; rewrite -> H. reflexivity. Qed.
lemma locally_connected_1: assumes "\<And>V x. \<lbrakk>openin (top_of_set S) V; x \<in> V\<rbrakk> \<Longrightarrow> \<exists>U. openin (top_of_set S) U \<and> connected U \<and> x \<in> U \<and> U \<subseteq> V" shows "locally connected S"
interface X a where interface X a => Y a where [SomeX] X a => X (List a) where [SomeY] {- X a => -} Y (List a) using SomeX where
using GeometryTypes, StaticArrays, Colors, GLAbstraction """ Hack to quickly make things more consistent inside Makie, without changing GLVisualize too much! So we need to rewrite the attributes, the names and the values a bit! """ function expand_for_glvisualize(kw_args) result = Dict{Symbol, Any}() for (k, v) in kw_args k in (:marker, :positions, always_skip...) && continue if k == :rotations k = :rotation v = Vec4f0(0, 0, 0, 1) result[:billboard] = true end if k == :markersize k = :scale end if k == :glowwidth k = :glow_width end if k == :glowcolor k = :glow_color end if k == :strokewidth k = :stroke_width end if k == :strokecolor k = :stroke_color end if k == :positions k = :position end result[k] = to_signal(v) end result[:fxaa] = false result end # function scatter() # marker # strokecolor # strokewidth # glowcolor # glowwidth # markersize # rotations # if haskey(scene, :positions) # positions = to_positions(positions) # elseif haskey(scene, :z) # xyz = getindex.(scene, (:x, :y, :z)) # positions = to_positions(xyz) # elseif haskey(scene, :y) # xy = getindex.(scene, (:x, :y, :z)) # positions = to_positions(xy) # end # begin # color = to_color(color) # end # begin # colormap = to_colormap(colormap) # intensity = to_intensity(intensity) # colornorm = to_colornorm(colornorm, intensity) # end # end # function _scatter(scene, kw_args) attributes = scatter_defaults(scene, kw_args) gl_data = expand_for_glvisualize(attributes) shape = to_signal(attributes[:marker]) main = (shape, to_signal(attributes[:positions])) viz = visualize(main, Style(:default), gl_data) insert_scene!(scene, :scatter, viz, attributes) end function mesh2glvisualize(kw_args) result = Dict{Symbol, Any}() for (k, v) in kw_args k in (:marker, :positions, always_skip...) && continue if k == :rotations k = :rotation end if k == :markersize k = :scale end if k == :positions k = :position end result[k] = to_signal(v) end result[:fxaa] = true result end function _meshscatter(scene, kw_args) attributes = meshscatter_defaults(scene, kw_args) gl_data = mesh2glvisualize(attributes) shape = to_signal(attributes[:marker]) main = (shape, to_signal(attributes[:positions])) viz = GLVisualize.meshparticle(main, Style(:default), gl_data) viz = GLVisualize.assemble_shader(viz).children[] insert_scene!(scene, :meshscatter, viz, attributes) end for arg in ((:x, :y), (:x, :y, :z), (:positions,)) insert_expr = map(arg) do elem :(attributes[$(QuoteNode(elem))] = $elem) end @eval begin function scatter(scene::makie, $(arg...), attributes::Dict) $(insert_expr...) _scatter(scene, attributes) end @eval begin function meshscatter(scene::makie, $(arg...), attributes::Dict) $(insert_expr...) _meshscatter(scene, attributes) end end end end
malthus <- function(initial_time, initial_population, time_interval, N, growth_rate) { time <- initial_time population <- initial_population times <- c(time) populations <- c(population) for(i in 1:N) { population <- population + growth_rate*time_interval*population time <- time + time_interval times <- c(times, time) populations <- c(populations, population) } return(data.frame(times, populations)) } plot(malthus(1900, 76.2, 1, 300, 0.013))
[STATEMENT] lemma apply_power_left_mult_order [simp]: "(f ^ (n * order f a)) \<langle>$\<rangle> a = a" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (f ^ (n * order f a)) \<langle>$\<rangle> a = a [PROOF STEP] by (induct n) (simp_all add: power_add apply_times)
lemma R_refl [simp]: "R x x"
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' Building blocks of Artificial neural network ''' __author__ = 'François-Guillaume Fernandez' __license__ = 'MIT License' __version__ = '0.1' __maintainer__ = 'François-Guillaume Fernandez' __status__ = 'Development' import numpy as np class NaivePerceptron: def __init__(self, weights, bias, activation): # TODO: set the weights, bias and activation attributes of the NaivePerceptron class using the constructor arguments self.weights = 0 self.bias = 0 self.activation = None def forward(self, x): """ Compute the activation value for a given input Args: x (np.array): 1D-numpy array of the same size as the weights Returns: res (float): the activation value corresponding to the input """ # TODO: compute WX + b where W represents the Weights, X the input and b the bias lin_comb = 0 # TODO: compute the activation of this value res = 0 return res
From stdpp Require Import fin_maps fin_map_dom. Section map_disjoint. Context `{FinMap K M}. Lemma solve_map_disjoint_singleton_1 {A} (m1 m2 : M A) i x : m1 ##ₘ <[i:=x]> m2 → {[ i:= x ]} ∪ m2 ##ₘ m1 ∧ m2 ##ₘ ∅. Proof. intros. solve_map_disjoint. Qed. Lemma solve_map_disjoint_singleton_2 {A} (m1 m2 : M A) i x : m2 !! i = None → m1 ##ₘ {[ i := x ]} ∪ m2 → m2 ##ₘ <[i:=x]> m1 ∧ m1 !! i = None. Proof. intros. solve_map_disjoint. Qed. End map_disjoint. Section map_dom. Context `{FinMapDom K M D}. Lemma set_solver_dom_subseteq {A} (i j : K) (x y : A) : {[i; j]} ⊆ dom D (<[i:=x]> (<[j:=y]> (∅ : M A))). Proof. set_solver. Qed. Lemma set_solver_dom_disjoint {A} (X : D) : dom D (∅ : M A) ## X. Proof. set_solver. Qed. End map_dom.
-- Subtyping is no longer supported for irrelevance. f : {A B : Set} → (.A → B) → A → B f g = λ .x → g x
The Hindustani Vocal Ensemble is a performance class (MUS 148) offered through the UC Davis Music Department. The class is instructed by renowned musician and Berkeley resident http://www.ritasahai.com/ Rita Sahai. The course focuses on the basics of Hindustani music through theory and practice. The twounit class meets Mondays from 4 to 6 pm in the Music Building. Some people like the class so much that they keep taking it for no credit or after theyve graduated. The ensemble is open to all backgrounds and musical abilities there are no prerequisite classes and students dont need previous experience. You wont find the class listed on the Open Courses website or the Course Catalog, but if you just show up on a Monday afternoon, you will be more than welcome to join. For more information, contact Professor Sandra Graham at [email protected].
A set $S$ is compact if and only if every infinite subset of $S$ has a limit point in $S$.
[STATEMENT] lemma fBall_transfer [transfer_rule]: "(rel_fset A ===> (A ===> (=)) ===> (=)) fBall fBall" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (rel_fset A ===> (A ===> (=)) ===> (=)) fBall fBall [PROOF STEP] unfolding rel_fset_alt_def rel_fun_def [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>x y. (\<forall>xa. \<exists>ya. xa |\<in>| x \<longrightarrow> ya |\<in>| y \<and> A xa ya) \<and> (\<forall>ya. \<exists>xa. ya |\<in>| y \<longrightarrow> xa |\<in>| x \<and> A xa ya) \<longrightarrow> (\<forall>xa ya. (\<forall>x y. A x y \<longrightarrow> xa x = ya y) \<longrightarrow> fBall x xa = fBall y ya) [PROOF STEP] by blast
(* Title: ZF/AC/WO2_AC16.thy Author: Krzysztof Grabczewski The proof of WO2 ==> AC16(k #+ m, k) The main part of the proof is the inductive reasoning concerning properties of constructed family T_gamma. The proof deals with three cases for ordinals: 0, succ and limit ordinal. The first instance is trivial, the third not difficult, but the second is very complicated requiring many lemmas. We also need to prove that at any stage gamma the set (s - \<Union>(...) - k_gamma) (Rubin & Rubin page 15) contains m distinct elements (in fact is equipollent to s) *) theory WO2_AC16 imports AC_Equiv AC16_lemmas Cardinal_aux begin (**** A recursive definition used in the proof of WO2 ==> AC16 ****) definition recfunAC16 :: "[i,i,i,i] => i" where "recfunAC16(f,h,i,a) == transrec2(i, 0, %g r. if (\<exists>y \<in> r. h`g \<subseteq> y) then r else r \<union> {f`(\<mu> i. h`g \<subseteq> f`i & (\<forall>b<a. (h`b \<subseteq> f`i \<longrightarrow> (\<forall>t \<in> r. ~ h`b \<subseteq> t))))})" (* ********************************************************************** *) (* Basic properties of recfunAC16 *) (* ********************************************************************** *) lemma recfunAC16_0: "recfunAC16(f,h,0,a) = 0" by (simp add: recfunAC16_def) lemma recfunAC16_succ: "recfunAC16(f,h,succ(i),a) = (if (\<exists>y \<in> recfunAC16(f,h,i,a). h ` i \<subseteq> y) then recfunAC16(f,h,i,a) else recfunAC16(f,h,i,a) \<union> {f ` (\<mu> j. h ` i \<subseteq> f ` j & (\<forall>b<a. (h`b \<subseteq> f`j \<longrightarrow> (\<forall>t \<in> recfunAC16(f,h,i,a). ~ h`b \<subseteq> t))))})" apply (simp add: recfunAC16_def) done lemma recfunAC16_Limit: "Limit(i) ==> recfunAC16(f,h,i,a) = (\<Union>j<i. recfunAC16(f,h,j,a))" by (simp add: recfunAC16_def transrec2_Limit) (* ********************************************************************** *) (* Monotonicity of transrec2 *) (* ********************************************************************** *) lemma transrec2_mono_lemma [rule_format]: "[| !!g r. r \<subseteq> B(g,r); Ord(i) |] ==> j<i \<longrightarrow> transrec2(j, 0, B) \<subseteq> transrec2(i, 0, B)" apply (erule trans_induct) apply (rule Ord_cases, assumption+, fast) apply (simp (no_asm_simp)) apply (blast elim!: leE) apply (simp add: transrec2_Limit) apply (blast intro: OUN_I ltI Ord_in_Ord [THEN le_refl] elim!: Limit_has_succ [THEN ltE]) done lemma transrec2_mono: "[| !!g r. r \<subseteq> B(g,r); j\<le>i |] ==> transrec2(j, 0, B) \<subseteq> transrec2(i, 0, B)" apply (erule leE) apply (rule transrec2_mono_lemma) apply (auto intro: lt_Ord2 ) done (* ********************************************************************** *) (* Monotonicity of recfunAC16 *) (* ********************************************************************** *) lemma recfunAC16_mono: "i\<le>j ==> recfunAC16(f, g, i, a) \<subseteq> recfunAC16(f, g, j, a)" apply (unfold recfunAC16_def) apply (rule transrec2_mono, auto) done (* ********************************************************************** *) (* case of limit ordinal *) (* ********************************************************************** *) lemma lemma3_1: "[| \<forall>y<x. \<forall>z<a. z<y | (\<exists>Y \<in> F(y). f(z)<=Y) \<longrightarrow> (\<exists>! Y. Y \<in> F(y) & f(z)<=Y); \<forall>i j. i\<le>j \<longrightarrow> F(i) \<subseteq> F(j); j\<le>i; i<x; z<a; V \<in> F(i); f(z)<=V; W \<in> F(j); f(z)<=W |] ==> V = W" apply (erule asm_rl allE impE)+ apply (drule subsetD, assumption, blast) done lemma lemma3: "[| \<forall>y<x. \<forall>z<a. z<y | (\<exists>Y \<in> F(y). f(z)<=Y) \<longrightarrow> (\<exists>! Y. Y \<in> F(y) & f(z)<=Y); \<forall>i j. i\<le>j \<longrightarrow> F(i) \<subseteq> F(j); i<x; j<x; z<a; V \<in> F(i); f(z)<=V; W \<in> F(j); f(z)<=W |] ==> V = W" apply (rule_tac j=j in Ord_linear_le [OF lt_Ord lt_Ord], assumption+) apply (erule lemma3_1 [symmetric], assumption+) apply (erule lemma3_1, assumption+) done lemma lemma4: "[| \<forall>y<x. F(y) \<subseteq> X & (\<forall>x<a. x < y | (\<exists>Y \<in> F(y). h(x) \<subseteq> Y) \<longrightarrow> (\<exists>! Y. Y \<in> F(y) & h(x) \<subseteq> Y)); x < a |] ==> \<forall>y<x. \<forall>z<a. z < y | (\<exists>Y \<in> F(y). h(z) \<subseteq> Y) \<longrightarrow> (\<exists>! Y. Y \<in> F(y) & h(z) \<subseteq> Y)" apply (intro oallI impI) apply (drule ospec, assumption, clarify) apply (blast elim!: oallE ) done lemma lemma5: "[| \<forall>y<x. F(y) \<subseteq> X & (\<forall>x<a. x < y | (\<exists>Y \<in> F(y). h(x) \<subseteq> Y) \<longrightarrow> (\<exists>! Y. Y \<in> F(y) & h(x) \<subseteq> Y)); x < a; Limit(x); \<forall>i j. i\<le>j \<longrightarrow> F(i) \<subseteq> F(j) |] ==> (\<Union>x<x. F(x)) \<subseteq> X & (\<forall>xa<a. xa < x | (\<exists>x \<in> \<Union>x<x. F(x). h(xa) \<subseteq> x) \<longrightarrow> (\<exists>! Y. Y \<in> (\<Union>x<x. F(x)) & h(xa) \<subseteq> Y))" apply (rule conjI) apply (rule subsetI) apply (erule OUN_E) apply (drule ospec, assumption, fast) apply (drule lemma4, assumption) apply (rule oallI) apply (rule impI) apply (erule disjE) apply (frule ospec, erule Limit_has_succ, assumption) apply (drule_tac A = a and x = xa in ospec, assumption) apply (erule impE, rule le_refl [THEN disjI1], erule lt_Ord) apply (blast intro: lemma3 Limit_has_succ) apply (blast intro: lemma3) done (* ********************************************************************** *) (* case of successor ordinal *) (* ********************************************************************** *) (* First quite complicated proof of the fact used in the recursive construction of the family T_gamma (WO2 ==> AC16(k #+ m, k)) - the fact that at any stage gamma the set (s - \<Union>(...) - k_gamma) is equipollent to s (Rubin & Rubin page 15). *) (* ********************************************************************** *) (* dbl_Diff_eqpoll_Card *) (* ********************************************************************** *) lemma dbl_Diff_eqpoll_Card: "[| A\<approx>a; Card(a); ~Finite(a); B\<prec>a; C\<prec>a |] ==> A - B - C\<approx>a" by (blast intro: Diff_lesspoll_eqpoll_Card) (* ********************************************************************** *) (* Case of finite ordinals *) (* ********************************************************************** *) lemma Finite_lesspoll_infinite_Ord: "[| Finite(X); ~Finite(a); Ord(a) |] ==> X\<prec>a" apply (unfold lesspoll_def) apply (rule conjI) apply (drule nat_le_infinite_Ord [THEN le_imp_lepoll], assumption) apply (unfold Finite_def) apply (blast intro: leI [THEN le_imp_subset, THEN subset_imp_lepoll] ltI eqpoll_imp_lepoll lepoll_trans) apply (blast intro: eqpoll_sym [THEN eqpoll_trans]) done lemma Union_lesspoll: "[| \<forall>x \<in> X. x \<lesssim> n & x \<subseteq> T; well_ord(T, R); X \<lesssim> b; b<a; ~Finite(a); Card(a); n \<in> nat |] ==> \<Union>(X)\<prec>a" apply (case_tac "Finite (X)") apply (blast intro: Card_is_Ord Finite_lesspoll_infinite_Ord lepoll_nat_imp_Finite Finite_Union) apply (drule lepoll_imp_ex_le_eqpoll) apply (erule lt_Ord) apply (elim exE conjE) apply (frule eqpoll_imp_lepoll [THEN lepoll_infinite], assumption) apply (erule eqpoll_sym [THEN eqpoll_def [THEN def_imp_iff, THEN iffD1], THEN exE]) apply (frule bij_is_surj [THEN surj_image_eq]) apply (drule image_fun [OF bij_is_fun subset_refl]) apply (drule sym [THEN trans], assumption) apply (blast intro: lt_Ord UN_lepoll lt_Card_imp_lesspoll lt_trans1 lesspoll_trans1) done (* ********************************************************************** *) (* recfunAC16_lepoll_index *) (* ********************************************************************** *) lemma Un_sing_eq_cons: "A \<union> {a} = cons(a, A)" by fast lemma Un_lepoll_succ: "A \<lesssim> B ==> A \<union> {a} \<lesssim> succ(B)" apply (simp add: Un_sing_eq_cons succ_def) apply (blast elim!: mem_irrefl intro: cons_lepoll_cong) done lemma Diff_UN_succ_empty: "Ord(a) ==> F(a) - (\<Union>b<succ(a). F(b)) = 0" by (fast intro!: le_refl) lemma Diff_UN_succ_subset: "Ord(a) ==> F(a) \<union> X - (\<Union>b<succ(a). F(b)) \<subseteq> X" by blast lemma recfunAC16_Diff_lepoll_1: "Ord(x) ==> recfunAC16(f, g, x, a) - (\<Union>i<x. recfunAC16(f, g, i, a)) \<lesssim> 1" apply (erule Ord_cases) apply (simp add: recfunAC16_0 empty_subsetI [THEN subset_imp_lepoll]) (*Limit case*) prefer 2 apply (simp add: recfunAC16_Limit Diff_cancel empty_subsetI [THEN subset_imp_lepoll]) (*succ case*) apply (simp add: recfunAC16_succ Diff_UN_succ_empty [of _ "%j. recfunAC16(f,g,j,a)"] empty_subsetI [THEN subset_imp_lepoll]) apply (best intro: Diff_UN_succ_subset [THEN subset_imp_lepoll] singleton_eqpoll_1 [THEN eqpoll_imp_lepoll] lepoll_trans) done lemma in_Least_Diff: "[| z \<in> F(x); Ord(x) |] ==> z \<in> F(\<mu> i. z \<in> F(i)) - (\<Union>j<(\<mu> i. z \<in> F(i)). F(j))" by (fast elim: less_LeastE elim!: LeastI) lemma Least_eq_imp_ex: "[| (\<mu> i. w \<in> F(i)) = (\<mu> i. z \<in> F(i)); w \<in> (\<Union>i<a. F(i)); z \<in> (\<Union>i<a. F(i)) |] ==> \<exists>b<a. w \<in> (F(b) - (\<Union>c<b. F(c))) & z \<in> (F(b) - (\<Union>c<b. F(c)))" apply (elim OUN_E) apply (drule in_Least_Diff, erule lt_Ord) apply (frule in_Least_Diff, erule lt_Ord) apply (rule oexI, force) apply (blast intro: lt_Ord Least_le [THEN lt_trans1]) done lemma two_in_lepoll_1: "[| A \<lesssim> 1; a \<in> A; b \<in> A |] ==> a=b" by (fast dest!: lepoll_1_is_sing) lemma UN_lepoll_index: "[| \<forall>i<a. F(i)-(\<Union>j<i. F(j)) \<lesssim> 1; Limit(a) |] ==> (\<Union>x<a. F(x)) \<lesssim> a" apply (rule lepoll_def [THEN def_imp_iff [THEN iffD2]]) apply (rule_tac x = "\<lambda>z \<in> (\<Union>x<a. F (x)). \<mu> i. z \<in> F (i) " in exI) apply (unfold inj_def) apply (rule CollectI) apply (rule lam_type) apply (erule OUN_E) apply (erule Least_in_Ord) apply (erule ltD) apply (erule lt_Ord2) apply (intro ballI) apply (simp (no_asm_simp)) apply (rule impI) apply (drule Least_eq_imp_ex, assumption+) apply (fast elim!: two_in_lepoll_1) done lemma recfunAC16_lepoll_index: "Ord(y) ==> recfunAC16(f, h, y, a) \<lesssim> y" apply (erule trans_induct3) (*0 case*) apply (simp (no_asm_simp) add: recfunAC16_0 lepoll_refl) (*succ case*) apply (simp (no_asm_simp) add: recfunAC16_succ) apply (blast dest!: succI1 [THEN rev_bspec] intro: subset_succI [THEN subset_imp_lepoll] Un_lepoll_succ lepoll_trans) apply (simp (no_asm_simp) add: recfunAC16_Limit) apply (blast intro: lt_Ord [THEN recfunAC16_Diff_lepoll_1] UN_lepoll_index) done lemma Union_recfunAC16_lesspoll: "[| recfunAC16(f,g,y,a) \<subseteq> {X \<in> Pow(A). X\<approx>n}; A\<approx>a; y<a; ~Finite(a); Card(a); n \<in> nat |] ==> \<Union>(recfunAC16(f,g,y,a))\<prec>a" apply (erule eqpoll_def [THEN def_imp_iff, THEN iffD1, THEN exE]) apply (rule_tac T=A in Union_lesspoll, simp_all) apply (blast intro!: eqpoll_imp_lepoll) apply (blast intro: bij_is_inj Card_is_Ord [THEN well_ord_Memrel] well_ord_rvimage) apply (erule lt_Ord [THEN recfunAC16_lepoll_index]) done lemma dbl_Diff_eqpoll: "[| recfunAC16(f, h, y, a) \<subseteq> {X \<in> Pow(A) . X\<approx>succ(k #+ m)}; Card(a); ~ Finite(a); A\<approx>a; k \<in> nat; y<a; h \<in> bij(a, {Y \<in> Pow(A). Y\<approx>succ(k)}) |] ==> A - \<Union>(recfunAC16(f, h, y, a)) - h`y\<approx>a" apply (rule dbl_Diff_eqpoll_Card, simp_all) apply (simp add: Union_recfunAC16_lesspoll) apply (rule Finite_lesspoll_infinite_Ord) apply (rule Finite_def [THEN def_imp_iff, THEN iffD2]) apply (blast dest: ltD bij_is_fun [THEN apply_type], assumption) apply (blast intro: Card_is_Ord) done (* back to the proof *) lemmas disj_Un_eqpoll_nat_sum = eqpoll_trans [THEN eqpoll_trans, OF disj_Un_eqpoll_sum sum_eqpoll_cong nat_sum_eqpoll_sum] lemma Un_in_Collect: "[| x \<in> Pow(A - B - h`i); x\<approx>m; h \<in> bij(a, {x \<in> Pow(A) . x\<approx>k}); i<a; k \<in> nat; m \<in> nat |] ==> h ` i \<union> x \<in> {x \<in> Pow(A) . x\<approx>k #+ m}" by (blast intro: disj_Un_eqpoll_nat_sum dest: ltD bij_is_fun [THEN apply_type]) (* ********************************************************************** *) (* Lemmas simplifying assumptions *) (* ********************************************************************** *) lemma lemma6: "[| \<forall>y<succ(j). F(y)<=X & (\<forall>x<a. x<y | P(x,y) \<longrightarrow> Q(x,y)); succ(j)<a |] ==> F(j)<=X & (\<forall>x<a. x<j | P(x,j) \<longrightarrow> Q(x,j))" by (blast intro!: lt_Ord succI1 [THEN ltI, THEN lt_Ord, THEN le_refl]) lemma lemma7: "[| \<forall>x<a. x<j | P(x,j) \<longrightarrow> Q(x,j); succ(j)<a |] ==> P(j,j) \<longrightarrow> (\<forall>x<a. x\<le>j | P(x,j) \<longrightarrow> Q(x,j))" by (fast elim!: leE) (* ********************************************************************** *) (* Lemmas needed to prove ex_next_set, which means that for any successor *) (* ordinal there is a set satisfying certain properties *) (* ********************************************************************** *) lemma ex_subset_eqpoll: "[| A\<approx>a; ~ Finite(a); Ord(a); m \<in> nat |] ==> \<exists>X \<in> Pow(A). X\<approx>m" apply (rule lepoll_imp_eqpoll_subset [of m A, THEN exE]) apply (rule lepoll_trans, rule leI [THEN le_imp_lepoll]) apply (blast intro: lt_trans2 [OF ltI nat_le_infinite_Ord] Ord_nat) apply (erule eqpoll_sym [THEN eqpoll_imp_lepoll]) apply (fast elim!: eqpoll_sym) done lemma subset_Un_disjoint: "[| A \<subseteq> B \<union> C; A \<inter> C = 0 |] ==> A \<subseteq> B" by blast lemma Int_empty: "[| X \<in> Pow(A - \<Union>(B) -C); T \<in> B; F \<subseteq> T |] ==> F \<inter> X = 0" by blast (* ********************************************************************** *) (* equipollent subset (and finite) is the whole set *) (* ********************************************************************** *) lemma subset_imp_eq_lemma: "m \<in> nat ==> \<forall>A B. A \<subseteq> B & m \<lesssim> A & B \<lesssim> m \<longrightarrow> A=B" apply (induct_tac "m") apply (fast dest!: lepoll_0_is_0) apply (intro allI impI) apply (elim conjE) apply (rule succ_lepoll_imp_not_empty [THEN not_emptyE], assumption) apply (frule subsetD [THEN Diff_sing_lepoll], assumption+) apply (frule lepoll_Diff_sing) apply (erule allE impE)+ apply (rule conjI) prefer 2 apply fast apply fast apply (blast elim: equalityE) done lemma subset_imp_eq: "[| A \<subseteq> B; m \<lesssim> A; B \<lesssim> m; m \<in> nat |] ==> A=B" by (blast dest!: subset_imp_eq_lemma) lemma bij_imp_arg_eq: "[| f \<in> bij(a, {Y \<in> X. Y\<approx>succ(k)}); k \<in> nat; f`b \<subseteq> f`y; b<a; y<a |] ==> b=y" apply (drule subset_imp_eq) apply (erule_tac [3] nat_succI) apply (unfold bij_def inj_def) apply (blast intro: eqpoll_sym eqpoll_imp_lepoll dest: ltD apply_type)+ done lemma ex_next_set: "[| recfunAC16(f, h, y, a) \<subseteq> {X \<in> Pow(A) . X\<approx>succ(k #+ m)}; Card(a); ~ Finite(a); A\<approx>a; k \<in> nat; m \<in> nat; y<a; h \<in> bij(a, {Y \<in> Pow(A). Y\<approx>succ(k)}); ~ (\<exists>Y \<in> recfunAC16(f, h, y, a). h`y \<subseteq> Y) |] ==> \<exists>X \<in> {Y \<in> Pow(A). Y\<approx>succ(k #+ m)}. h`y \<subseteq> X & (\<forall>b<a. h`b \<subseteq> X \<longrightarrow> (\<forall>T \<in> recfunAC16(f, h, y, a). ~ h`b \<subseteq> T))" apply (erule_tac m1=m in dbl_Diff_eqpoll [THEN ex_subset_eqpoll, THEN bexE], assumption+) apply (erule Card_is_Ord, assumption) apply (frule Un_in_Collect, (erule asm_rl nat_succI)+) apply (erule CollectE) apply (rule rev_bexI, simp) apply (rule conjI, blast) apply (intro ballI impI oallI notI) apply (drule subset_Un_disjoint, rule Int_empty, assumption+) apply (blast dest: bij_imp_arg_eq) done (* ********************************************************************** *) (* Lemma ex_next_Ord states that for any successor *) (* ordinal there is a number of the set satisfying certain properties *) (* ********************************************************************** *) lemma ex_next_Ord: "[| recfunAC16(f, h, y, a) \<subseteq> {X \<in> Pow(A) . X\<approx>succ(k #+ m)}; Card(a); ~ Finite(a); A\<approx>a; k \<in> nat; m \<in> nat; y<a; h \<in> bij(a, {Y \<in> Pow(A). Y\<approx>succ(k)}); f \<in> bij(a, {Y \<in> Pow(A). Y\<approx>succ(k #+ m)}); ~ (\<exists>Y \<in> recfunAC16(f, h, y, a). h`y \<subseteq> Y) |] ==> \<exists>c<a. h`y \<subseteq> f`c & (\<forall>b<a. h`b \<subseteq> f`c \<longrightarrow> (\<forall>T \<in> recfunAC16(f, h, y, a). ~ h`b \<subseteq> T))" apply (drule ex_next_set, assumption+) apply (erule bexE) apply (rule_tac x="converse(f)`X" in oexI) apply (simp add: right_inverse_bij) apply (blast intro: bij_converse_bij bij_is_fun [THEN apply_type] ltI Card_is_Ord) done (* ********************************************************************** *) (* Lemma simplifying assumptions *) (* ********************************************************************** *) lemma lemma8: "[| \<forall>x<a. x<j | (\<exists>xa \<in> F(j). P(x, xa)) \<longrightarrow> (\<exists>! Y. Y \<in> F(j) & P(x, Y)); F(j) \<subseteq> X; L \<in> X; P(j, L) & (\<forall>x<a. P(x, L) \<longrightarrow> (\<forall>xa \<in> F(j). ~P(x, xa))) |] ==> F(j) \<union> {L} \<subseteq> X & (\<forall>x<a. x\<le>j | (\<exists>xa \<in> (F(j) \<union> {L}). P(x, xa)) \<longrightarrow> (\<exists>! Y. Y \<in> (F(j) \<union> {L}) & P(x, Y)))" apply (rule conjI) apply (fast intro!: singleton_subsetI) apply (rule oallI) apply (blast elim!: leE oallE) done (* ********************************************************************** *) (* The main part of the proof: inductive proof of the property of T_gamma *) (* lemma main_induct *) (* ********************************************************************** *) lemma main_induct: "[| b < a; f \<in> bij(a, {Y \<in> Pow(A) . Y\<approx>succ(k #+ m)}); h \<in> bij(a, {Y \<in> Pow(A) . Y\<approx>succ(k)}); ~Finite(a); Card(a); A\<approx>a; k \<in> nat; m \<in> nat |] ==> recfunAC16(f, h, b, a) \<subseteq> {X \<in> Pow(A) . X\<approx>succ(k #+ m)} & (\<forall>x<a. x < b | (\<exists>Y \<in> recfunAC16(f, h, b, a). h ` x \<subseteq> Y) \<longrightarrow> (\<exists>! Y. Y \<in> recfunAC16(f, h, b, a) & h ` x \<subseteq> Y))" apply (erule lt_induct) apply (frule lt_Ord) apply (erule Ord_cases) (* case 0 *) apply (simp add: recfunAC16_0) (* case Limit *) prefer 2 apply (simp add: recfunAC16_Limit) apply (rule lemma5, assumption+) apply (blast dest!: recfunAC16_mono) (* case succ *) apply clarify apply (erule lemma6 [THEN conjE], assumption) apply (simp (no_asm_simp) split del: split_if add: recfunAC16_succ) apply (rule conjI [THEN split_if [THEN iffD2]]) apply (simp, erule lemma7, assumption) apply (rule impI) apply (rule ex_next_Ord [THEN oexE], assumption+, rule le_refl [THEN lt_trans], assumption+) apply (erule lemma8, assumption) apply (rule bij_is_fun [THEN apply_type], assumption) apply (erule Least_le [THEN lt_trans2, THEN ltD]) apply (erule lt_Ord) apply (erule succ_leI) apply (erule LeastI) apply (erule lt_Ord) done (* ********************************************************************** *) (* Lemma to simplify the inductive proof *) (* - the desired property is a consequence of the inductive assumption *) (* ********************************************************************** *) lemma lemma_simp_induct: "[| \<forall>b. b<a \<longrightarrow> F(b) \<subseteq> S & (\<forall>x<a. (x<b | (\<exists>Y \<in> F(b). f`x \<subseteq> Y)) \<longrightarrow> (\<exists>! Y. Y \<in> F(b) & f`x \<subseteq> Y)); f \<in> a->f``(a); Limit(a); \<forall>i j. i\<le>j \<longrightarrow> F(i) \<subseteq> F(j) |] ==> (\<Union>j<a. F(j)) \<subseteq> S & (\<forall>x \<in> f``a. \<exists>! Y. Y \<in> (\<Union>j<a. F(j)) & x \<subseteq> Y)" apply (rule conjI) apply (rule subsetI) apply (erule OUN_E, blast) apply (rule ballI) apply (erule imageE) apply (drule ltI, erule Limit_is_Ord) apply (drule Limit_has_succ, assumption) apply (frule_tac x1="succ(xa)" in spec [THEN mp], assumption) apply (erule conjE) apply (drule ospec) (** LEVEL 10 **) apply (erule leI [THEN succ_leE]) apply (erule impE) apply (fast elim!: leI [THEN succ_leE, THEN lt_Ord, THEN le_refl]) apply (drule apply_equality, assumption) apply (elim conjE ex1E) (** LEVEL 15 **) apply (rule ex1I, blast) apply (elim conjE OUN_E) apply (erule_tac i="succ(xa)" and j=aa in Ord_linear_le [OF lt_Ord lt_Ord], assumption) prefer 2 apply (drule spec [THEN spec, THEN mp, THEN subsetD], assumption+, blast) (** LEVEL 20 **) apply (drule_tac x1=aa in spec [THEN mp], assumption) apply (frule succ_leE) apply (drule spec [THEN spec, THEN mp, THEN subsetD], assumption+, blast) done (* ********************************************************************** *) (* The target theorem *) (* ********************************************************************** *) theorem WO2_AC16: "[| WO2; 0<m; k \<in> nat; m \<in> nat |] ==> AC16(k #+ m,k)" apply (unfold AC16_def) apply (rule allI) apply (rule impI) apply (frule WO2_infinite_subsets_eqpoll_X, assumption+) apply (frule_tac n="k #+ m" in WO2_infinite_subsets_eqpoll_X, simp, simp) apply (frule WO2_imp_ex_Card) apply (elim exE conjE) apply (drule eqpoll_trans [THEN eqpoll_sym, THEN eqpoll_def [THEN def_imp_iff, THEN iffD1]], assumption) apply (drule eqpoll_trans [THEN eqpoll_sym, THEN eqpoll_def [THEN def_imp_iff, THEN iffD1]], assumption+) apply (elim exE) apply (rename_tac h) apply (rule_tac x = "\<Union>j<a. recfunAC16 (h,f,j,a) " in exI) apply (rule_tac P="%z. Y & (\<forall>x \<in> z. Z(x))" for Y Z in bij_is_surj [THEN surj_image_eq, THEN subst], assumption) apply (rule lemma_simp_induct) apply (blast del: conjI notI intro!: main_induct eqpoll_imp_lepoll [THEN lepoll_infinite] ) apply (blast intro: bij_is_fun [THEN surj_image, THEN surj_is_fun]) apply (erule eqpoll_imp_lepoll [THEN lepoll_infinite, THEN infinite_Card_is_InfCard, THEN InfCard_is_Limit], assumption+) apply (blast dest!: recfunAC16_mono) done end
[GOAL] z w : ℂ H : z = w ⊢ z.re = w.re ∧ z.im = w.im [PROOFSTEP] simp [H] [GOAL] z w : ℝ ⊢ z = w → ↑z = ↑w [PROOFSTEP] apply congrArg [GOAL] r s : ℝ ⊢ (↑(r + s)).re = (↑r + ↑s).re ∧ (↑(r + s)).im = (↑r + ↑s).im [PROOFSTEP] simp [ofReal'] [GOAL] r : ℝ ⊢ (↑(bit0 r)).re = (bit0 ↑r).re ∧ (↑(bit0 r)).im = (bit0 ↑r).im [PROOFSTEP] simp [bit0] [GOAL] r : ℝ ⊢ (↑(bit1 r)).re = (bit1 ↑r).re ∧ (↑(bit1 r)).im = (bit1 ↑r).im [PROOFSTEP] simp [bit1] [GOAL] r : ℝ ⊢ (↑(-r)).re = (-↑r).re ∧ (↑(-r)).im = (-↑r).im [PROOFSTEP] simp [ofReal'] [GOAL] r s : ℝ ⊢ (↑(r * s)).re = (↑r * ↑s).re ∧ (↑(r * s)).im = (↑r * ↑s).im [PROOFSTEP] simp [ofReal'] [GOAL] r : ℝ z : ℂ ⊢ (↑r * z).re = r * z.re [PROOFSTEP] simp [ofReal'] [GOAL] r : ℝ z : ℂ ⊢ (↑r * z).im = r * z.im [PROOFSTEP] simp [ofReal'] [GOAL] ⊢ (I * I).re = (-1).re ∧ (I * I).im = (-1).im [PROOFSTEP] simp [GOAL] z : ℂ ⊢ (I * z).re = { re := -z.im, im := z.re }.re ∧ (I * z).im = { re := -z.im, im := z.re }.im [PROOFSTEP] simp [GOAL] a b : ℝ ⊢ { re := a, im := b }.re = (↑a + ↑b * I).re ∧ { re := a, im := b }.im = (↑a + ↑b * I).im [PROOFSTEP] simp [ofReal'] [GOAL] z : ℂ ⊢ (↑z.re + ↑z.im * I).re = z.re ∧ (↑z.re + ↑z.im * I).im = z.im [PROOFSTEP] simp [ofReal'] [GOAL] z : ℂ ⊢ (z * I).re = -z.im [PROOFSTEP] simp [GOAL] z : ℂ ⊢ (z * I).im = z.re [PROOFSTEP] simp [GOAL] z : ℂ ⊢ (I * z).re = -z.im [PROOFSTEP] simp [GOAL] z : ℂ ⊢ (I * z).im = z.re [PROOFSTEP] simp [GOAL] p : ℝ × ℝ ⊢ ↑equivRealProd.symm p = ↑p.fst + ↑p.snd * I [PROOFSTEP] ext [GOAL] case a p : ℝ × ℝ ⊢ (↑equivRealProd.symm p).re = (↑p.fst + ↑p.snd * I).re [PROOFSTEP] simp [Complex.equivRealProd, ofReal'] [GOAL] case a p : ℝ × ℝ ⊢ (↑equivRealProd.symm p).im = (↑p.fst + ↑p.snd * I).im [PROOFSTEP] simp [Complex.equivRealProd, ofReal'] [GOAL] R : Type u_1 inst✝ : SMul R ℝ r : R z : ℂ ⊢ (r • z).re = r • z.re [PROOFSTEP] simp [(· • ·), SMul.smul] [GOAL] R : Type u_1 inst✝ : SMul R ℝ r : R z : ℂ ⊢ (r • z).im = r • z.im [PROOFSTEP] simp [(· • ·), SMul.smul] [GOAL] ⊢ ∀ (a b c : ℂ), a + b + c = a + (b + c) [PROOFSTEP] intros [GOAL] a✝ b✝ c✝ : ℂ ⊢ a✝ + b✝ + c✝ = a✝ + (b✝ + c✝) [PROOFSTEP] ext [GOAL] case a a✝ b✝ c✝ : ℂ ⊢ (a✝ + b✝ + c✝).re = (a✝ + (b✝ + c✝)).re [PROOFSTEP] simp [add_assoc] [GOAL] case a a✝ b✝ c✝ : ℂ ⊢ (a✝ + b✝ + c✝).im = (a✝ + (b✝ + c✝)).im [PROOFSTEP] simp [add_assoc] [GOAL] ⊢ ∀ (a : ℂ), 0 + a = a [PROOFSTEP] intros [GOAL] a✝ : ℂ ⊢ 0 + a✝ = a✝ [PROOFSTEP] ext [GOAL] case a a✝ : ℂ ⊢ (0 + a✝).re = a✝.re [PROOFSTEP] simp [GOAL] case a a✝ : ℂ ⊢ (0 + a✝).im = a✝.im [PROOFSTEP] simp [GOAL] ⊢ ∀ (a : ℂ), a + 0 = a [PROOFSTEP] intros [GOAL] a✝ : ℂ ⊢ a✝ + 0 = a✝ [PROOFSTEP] ext [GOAL] case a a✝ : ℂ ⊢ (a✝ + 0).re = a✝.re [PROOFSTEP] simp [GOAL] case a a✝ : ℂ ⊢ (a✝ + 0).im = a✝.im [PROOFSTEP] simp [GOAL] ⊢ ∀ (x : ℂ), (fun n z => n • z) 0 x = 0 [PROOFSTEP] intros [GOAL] x✝ : ℂ ⊢ (fun n z => n • z) 0 x✝ = 0 [PROOFSTEP] ext [GOAL] case a x✝ : ℂ ⊢ ((fun n z => n • z) 0 x✝).re = 0.re [PROOFSTEP] simp [smul_re, smul_im] [GOAL] case a x✝ : ℂ ⊢ ((fun n z => n • z) 0 x✝).im = 0.im [PROOFSTEP] simp [smul_re, smul_im] [GOAL] ⊢ ∀ (n : ℕ) (x : ℂ), (fun n z => n • z) (n + 1) x = x + (fun n z => n • z) n x [PROOFSTEP] intros [GOAL] n✝ : ℕ x✝ : ℂ ⊢ (fun n z => n • z) (n✝ + 1) x✝ = x✝ + (fun n z => n • z) n✝ x✝ [PROOFSTEP] ext [GOAL] case a n✝ : ℕ x✝ : ℂ ⊢ ((fun n z => n • z) (n✝ + 1) x✝).re = (x✝ + (fun n z => n • z) n✝ x✝).re [PROOFSTEP] simp [AddMonoid.nsmul_succ, add_mul, add_comm, smul_re, smul_im] [GOAL] case a n✝ : ℕ x✝ : ℂ ⊢ ((fun n z => n • z) (n✝ + 1) x✝).im = (x✝ + (fun n z => n • z) n✝ x✝).im [PROOFSTEP] simp [AddMonoid.nsmul_succ, add_mul, add_comm, smul_re, smul_im] [GOAL] ⊢ ∀ (a : ℂ), (fun n z => n • z) 0 a = 0 [PROOFSTEP] intros [GOAL] a✝ : ℂ ⊢ (fun n z => n • z) 0 a✝ = 0 [PROOFSTEP] ext [GOAL] case a a✝ : ℂ ⊢ ((fun n z => n • z) 0 a✝).re = 0.re [PROOFSTEP] simp [smul_re, smul_im] [GOAL] case a a✝ : ℂ ⊢ ((fun n z => n • z) 0 a✝).im = 0.im [PROOFSTEP] simp [smul_re, smul_im] [GOAL] ⊢ ∀ (n : ℕ) (a : ℂ), (fun n z => n • z) (Int.ofNat (Nat.succ n)) a = a + (fun n z => n • z) (Int.ofNat n) a [PROOFSTEP] intros [GOAL] n✝ : ℕ a✝ : ℂ ⊢ (fun n z => n • z) (Int.ofNat (Nat.succ n✝)) a✝ = a✝ + (fun n z => n • z) (Int.ofNat n✝) a✝ [PROOFSTEP] ext [GOAL] case a n✝ : ℕ a✝ : ℂ ⊢ ((fun n z => n • z) (Int.ofNat (Nat.succ n✝)) a✝).re = (a✝ + (fun n z => n • z) (Int.ofNat n✝) a✝).re [PROOFSTEP] simp [SubNegMonoid.zsmul_succ', add_mul, add_comm, smul_re, smul_im] [GOAL] case a n✝ : ℕ a✝ : ℂ ⊢ ((fun n z => n • z) (Int.ofNat (Nat.succ n✝)) a✝).im = (a✝ + (fun n z => n • z) (Int.ofNat n✝) a✝).im [PROOFSTEP] simp [SubNegMonoid.zsmul_succ', add_mul, add_comm, smul_re, smul_im] [GOAL] ⊢ ∀ (n : ℕ) (a : ℂ), (fun n z => n • z) (Int.negSucc n) a = -(fun n z => n • z) (↑(Nat.succ n)) a [PROOFSTEP] intros [GOAL] n✝ : ℕ a✝ : ℂ ⊢ (fun n z => n • z) (Int.negSucc n✝) a✝ = -(fun n z => n • z) (↑(Nat.succ n✝)) a✝ [PROOFSTEP] ext [GOAL] case a n✝ : ℕ a✝ : ℂ ⊢ ((fun n z => n • z) (Int.negSucc n✝) a✝).re = (-(fun n z => n • z) (↑(Nat.succ n✝)) a✝).re [PROOFSTEP] simp [zsmul_neg', add_mul, smul_re, smul_im] [GOAL] case a n✝ : ℕ a✝ : ℂ ⊢ ((fun n z => n • z) (Int.negSucc n✝) a✝).im = (-(fun n z => n • z) (↑(Nat.succ n✝)) a✝).im [PROOFSTEP] simp [zsmul_neg', add_mul, smul_re, smul_im] [GOAL] ⊢ ∀ (a : ℂ), -a + a = 0 [PROOFSTEP] intros [GOAL] a✝ : ℂ ⊢ -a✝ + a✝ = 0 [PROOFSTEP] ext [GOAL] case a a✝ : ℂ ⊢ (-a✝ + a✝).re = 0.re [PROOFSTEP] simp [GOAL] case a a✝ : ℂ ⊢ (-a✝ + a✝).im = 0.im [PROOFSTEP] simp [GOAL] ⊢ ∀ (a b : ℂ), a + b = b + a [PROOFSTEP] intros [GOAL] a✝ b✝ : ℂ ⊢ a✝ + b✝ = b✝ + a✝ [PROOFSTEP] ext [GOAL] case a a✝ b✝ : ℂ ⊢ (a✝ + b✝).re = (b✝ + a✝).re [PROOFSTEP] simp [add_comm] [GOAL] case a a✝ b✝ : ℂ ⊢ (a✝ + b✝).im = (b✝ + a✝).im [PROOFSTEP] simp [add_comm] [GOAL] src✝ : AddCommGroup ℂ := addCommGroup ⊢ NatCast.natCast 0 = 0 [PROOFSTEP] ext [GOAL] case a src✝ : AddCommGroup ℂ := addCommGroup ⊢ (NatCast.natCast 0).re = 0.re [PROOFSTEP] simp [Nat.cast, AddMonoidWithOne.natCast_zero] [GOAL] case a src✝ : AddCommGroup ℂ := addCommGroup ⊢ (NatCast.natCast 0).im = 0.im [PROOFSTEP] simp [Nat.cast, AddMonoidWithOne.natCast_zero] [GOAL] src✝ : AddCommGroup ℂ := addCommGroup x✝ : ℕ ⊢ NatCast.natCast (x✝ + 1) = NatCast.natCast x✝ + 1 [PROOFSTEP] ext [GOAL] case a src✝ : AddCommGroup ℂ := addCommGroup x✝ : ℕ ⊢ (NatCast.natCast (x✝ + 1)).re = (NatCast.natCast x✝ + 1).re [PROOFSTEP] simp [Nat.cast, AddMonoidWithOne.natCast_succ] [GOAL] case a src✝ : AddCommGroup ℂ := addCommGroup x✝ : ℕ ⊢ (NatCast.natCast (x✝ + 1)).im = (NatCast.natCast x✝ + 1).im [PROOFSTEP] simp [Nat.cast, AddMonoidWithOne.natCast_succ] [GOAL] src✝ : AddCommGroup ℂ := addCommGroup x✝ : ℕ ⊢ IntCast.intCast ↑x✝ = ↑x✝ [PROOFSTEP] ext [GOAL] case a src✝ : AddCommGroup ℂ := addCommGroup x✝ : ℕ ⊢ (IntCast.intCast ↑x✝).re = (↑x✝).re [PROOFSTEP] rfl [GOAL] case a src✝ : AddCommGroup ℂ := addCommGroup x✝ : ℕ ⊢ (IntCast.intCast ↑x✝).im = (↑x✝).im [PROOFSTEP] rfl [GOAL] src✝ : AddCommGroup ℂ := addCommGroup n : ℕ ⊢ IntCast.intCast (Int.negSucc n) = -↑(n + 1) [PROOFSTEP] ext [GOAL] case a src✝ : AddCommGroup ℂ := addCommGroup n : ℕ ⊢ (IntCast.intCast (Int.negSucc n)).re = (-↑(n + 1)).re [PROOFSTEP] simp [AddGroupWithOne.intCast_negSucc] [GOAL] case a src✝ : AddCommGroup ℂ := addCommGroup n : ℕ ⊢ -1 + -↑n = -(↑(n + 1)).re [PROOFSTEP] show -(1 : ℝ) + (-n) = -(↑(n + 1)) [GOAL] case a src✝ : AddCommGroup ℂ := addCommGroup n : ℕ ⊢ -1 + -↑n = -↑(n + 1) [PROOFSTEP] simp [Nat.cast_add, add_comm] [GOAL] case a src✝ : AddCommGroup ℂ := addCommGroup n : ℕ ⊢ (IntCast.intCast (Int.negSucc n)).im = (-↑(n + 1)).im [PROOFSTEP] simp [AddGroupWithOne.intCast_negSucc] [GOAL] case a src✝ : AddCommGroup ℂ := addCommGroup n : ℕ ⊢ (↑(n + 1)).im = 0 [PROOFSTEP] show im ⟨n, 0⟩ = 0 [GOAL] case a src✝ : AddCommGroup ℂ := addCommGroup n : ℕ ⊢ { re := ↑n, im := 0 }.im = 0 [PROOFSTEP] rfl [GOAL] src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne ⊢ ∀ (a b : ℂ), a + b = b + a [PROOFSTEP] intros [GOAL] src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ b✝ : ℂ ⊢ a✝ + b✝ = b✝ + a✝ [PROOFSTEP] ext [GOAL] case a src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ b✝ : ℂ ⊢ (a✝ + b✝).re = (b✝ + a✝).re [PROOFSTEP] simp [add_comm] [GOAL] case a src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ b✝ : ℂ ⊢ (a✝ + b✝).im = (b✝ + a✝).im [PROOFSTEP] simp [add_comm] [GOAL] src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne ⊢ ∀ (a b c : ℂ), a * (b + c) = a * b + a * c [PROOFSTEP] intros [GOAL] src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ b✝ c✝ : ℂ ⊢ a✝ * (b✝ + c✝) = a✝ * b✝ + a✝ * c✝ [PROOFSTEP] ext [GOAL] case a src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ b✝ c✝ : ℂ ⊢ (a✝ * (b✝ + c✝)).re = (a✝ * b✝ + a✝ * c✝).re [PROOFSTEP] simp [mul_re, mul_im] [GOAL] case a src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ b✝ c✝ : ℂ ⊢ (a✝ * (b✝ + c✝)).im = (a✝ * b✝ + a✝ * c✝).im [PROOFSTEP] simp [mul_re, mul_im] [GOAL] case a src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ b✝ c✝ : ℂ ⊢ a✝.re * (b✝.re + c✝.re) - a✝.im * (b✝.im + c✝.im) = a✝.re * b✝.re - a✝.im * b✝.im + (a✝.re * c✝.re - a✝.im * c✝.im) [PROOFSTEP] ring [GOAL] case a src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ b✝ c✝ : ℂ ⊢ a✝.re * (b✝.im + c✝.im) + a✝.im * (b✝.re + c✝.re) = a✝.re * b✝.im + a✝.im * b✝.re + (a✝.re * c✝.im + a✝.im * c✝.re) [PROOFSTEP] ring [GOAL] src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne ⊢ ∀ (a b c : ℂ), (a + b) * c = a * c + b * c [PROOFSTEP] intros [GOAL] src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ b✝ c✝ : ℂ ⊢ (a✝ + b✝) * c✝ = a✝ * c✝ + b✝ * c✝ [PROOFSTEP] ext [GOAL] case a src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ b✝ c✝ : ℂ ⊢ ((a✝ + b✝) * c✝).re = (a✝ * c✝ + b✝ * c✝).re [PROOFSTEP] simp [mul_re, mul_im] [GOAL] case a src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ b✝ c✝ : ℂ ⊢ ((a✝ + b✝) * c✝).im = (a✝ * c✝ + b✝ * c✝).im [PROOFSTEP] simp [mul_re, mul_im] [GOAL] case a src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ b✝ c✝ : ℂ ⊢ (a✝.re + b✝.re) * c✝.re - (a✝.im + b✝.im) * c✝.im = a✝.re * c✝.re - a✝.im * c✝.im + (b✝.re * c✝.re - b✝.im * c✝.im) [PROOFSTEP] ring [GOAL] case a src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ b✝ c✝ : ℂ ⊢ (a✝.re + b✝.re) * c✝.im + (a✝.im + b✝.im) * c✝.re = a✝.re * c✝.im + a✝.im * c✝.re + (b✝.re * c✝.im + b✝.im * c✝.re) [PROOFSTEP] ring [GOAL] src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne ⊢ ∀ (a : ℂ), 0 * a = 0 [PROOFSTEP] intros [GOAL] src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ : ℂ ⊢ 0 * a✝ = 0 [PROOFSTEP] ext [GOAL] case a src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ : ℂ ⊢ (0 * a✝).re = 0.re [PROOFSTEP] simp [zero_mul] [GOAL] case a src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ : ℂ ⊢ (0 * a✝).im = 0.im [PROOFSTEP] simp [zero_mul] [GOAL] src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne ⊢ ∀ (a : ℂ), a * 0 = 0 [PROOFSTEP] intros [GOAL] src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ : ℂ ⊢ a✝ * 0 = 0 [PROOFSTEP] ext [GOAL] case a src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ : ℂ ⊢ (a✝ * 0).re = 0.re [PROOFSTEP] simp [mul_zero] [GOAL] case a src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ : ℂ ⊢ (a✝ * 0).im = 0.im [PROOFSTEP] simp [mul_zero] [GOAL] src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne ⊢ ∀ (a b c : ℂ), a * b * c = a * (b * c) [PROOFSTEP] intros [GOAL] src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ b✝ c✝ : ℂ ⊢ a✝ * b✝ * c✝ = a✝ * (b✝ * c✝) [PROOFSTEP] ext [GOAL] case a src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ b✝ c✝ : ℂ ⊢ (a✝ * b✝ * c✝).re = (a✝ * (b✝ * c✝)).re [PROOFSTEP] simp [mul_assoc] [GOAL] case a src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ b✝ c✝ : ℂ ⊢ (a✝ * b✝ * c✝).im = (a✝ * (b✝ * c✝)).im [PROOFSTEP] simp [mul_assoc] [GOAL] case a src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ b✝ c✝ : ℂ ⊢ (a✝.re * b✝.re - a✝.im * b✝.im) * c✝.re - (a✝.re * b✝.im + a✝.im * b✝.re) * c✝.im = a✝.re * (b✝.re * c✝.re - b✝.im * c✝.im) - a✝.im * (b✝.re * c✝.im + b✝.im * c✝.re) [PROOFSTEP] ring [GOAL] case a src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ b✝ c✝ : ℂ ⊢ (a✝.re * b✝.re - a✝.im * b✝.im) * c✝.im + (a✝.re * b✝.im + a✝.im * b✝.re) * c✝.re = a✝.re * (b✝.re * c✝.im + b✝.im * c✝.re) + a✝.im * (b✝.re * c✝.re - b✝.im * c✝.im) [PROOFSTEP] ring [GOAL] src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne ⊢ ∀ (a : ℂ), 1 * a = a [PROOFSTEP] intros [GOAL] src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ : ℂ ⊢ 1 * a✝ = a✝ [PROOFSTEP] ext [GOAL] case a src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ : ℂ ⊢ (1 * a✝).re = a✝.re [PROOFSTEP] simp [one_mul] [GOAL] case a src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ : ℂ ⊢ (1 * a✝).im = a✝.im [PROOFSTEP] simp [one_mul] [GOAL] src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne ⊢ ∀ (a : ℂ), a * 1 = a [PROOFSTEP] intros [GOAL] src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ : ℂ ⊢ a✝ * 1 = a✝ [PROOFSTEP] ext [GOAL] case a src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ : ℂ ⊢ (a✝ * 1).re = a✝.re [PROOFSTEP] simp [mul_one] [GOAL] case a src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ : ℂ ⊢ (a✝ * 1).im = a✝.im [PROOFSTEP] simp [mul_one] [GOAL] src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne ⊢ ∀ (a b : ℂ), a * b = b * a [PROOFSTEP] intros [GOAL] src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ b✝ : ℂ ⊢ a✝ * b✝ = b✝ * a✝ [PROOFSTEP] ext [GOAL] case a src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ b✝ : ℂ ⊢ (a✝ * b✝).re = (b✝ * a✝).re [PROOFSTEP] simp [mul_comm] [GOAL] case a src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ b✝ : ℂ ⊢ (a✝ * b✝).im = (b✝ * a✝).im [PROOFSTEP] simp [mul_comm] [GOAL] case a src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne a✝ b✝ : ℂ ⊢ a✝.re * b✝.im + b✝.re * a✝.im = b✝.re * a✝.im + a✝.re * b✝.im [PROOFSTEP] ring [GOAL] ⊢ Ring ℂ [PROOFSTEP] infer_instance [GOAL] n : ℕ ⊢ I ^ bit0 n = (-1) ^ n [PROOFSTEP] rw [pow_bit0', Complex.I_mul_I] [GOAL] n : ℕ ⊢ I ^ bit1 n = (-1) ^ n * I [PROOFSTEP] rw [pow_bit1', Complex.I_mul_I] [GOAL] x : ℂ ⊢ star (star x) = x [PROOFSTEP] simp only [eta, neg_neg] [GOAL] a b : ℂ ⊢ star (a * b) = star b * star a [PROOFSTEP] ext [GOAL] case a a b : ℂ ⊢ (star (a * b)).re = (star b * star a).re [PROOFSTEP] simp [add_comm] [GOAL] case a a b : ℂ ⊢ (star (a * b)).im = (star b * star a).im [PROOFSTEP] simp [add_comm] [GOAL] case a a b : ℂ ⊢ a.re * b.re - a.im * b.im = b.re * a.re - b.im * a.im [PROOFSTEP] ring [GOAL] case a a b : ℂ ⊢ -(a.re * b.im) + -(a.im * b.re) = -(b.re * a.im) + -(b.im * a.re) [PROOFSTEP] ring [GOAL] a b : ℂ ⊢ star (a + b) = star a + star b [PROOFSTEP] ext [GOAL] case a a b : ℂ ⊢ (star (a + b)).re = (star a + star b).re [PROOFSTEP] simp [add_comm] [GOAL] case a a b : ℂ ⊢ (star (a + b)).im = (star a + star b).im [PROOFSTEP] simp [add_comm] [GOAL] r : ℝ ⊢ (↑(starRingEnd ℂ) ↑r).re = (↑r).re ∧ (↑(starRingEnd ℂ) ↑r).im = (↑r).im [PROOFSTEP] simp [star] [GOAL] ⊢ (↑(starRingEnd ℂ) I).re = (-I).re ∧ (↑(starRingEnd ℂ) I).im = (-I).im [PROOFSTEP] simp [GOAL] z : ℂ ⊢ (↑(starRingEnd ℂ) (bit0 z)).re = (bit0 (↑(starRingEnd ℂ) z)).re ∧ (↑(starRingEnd ℂ) (bit0 z)).im = (bit0 (↑(starRingEnd ℂ) z)).im [PROOFSTEP] simp [bit0] [GOAL] z : ℂ ⊢ (↑(starRingEnd ℂ) (bit1 z)).re = (bit1 (↑(starRingEnd ℂ) z)).re ∧ (↑(starRingEnd ℂ) (bit1 z)).im = (bit1 (↑(starRingEnd ℂ) z)).im [PROOFSTEP] simp [bit0] [GOAL] ⊢ (↑(starRingEnd ℂ) (-I)).re = I.re ∧ (↑(starRingEnd ℂ) (-I)).im = I.im [PROOFSTEP] simp [GOAL] z : ℂ x✝ : ∃ r, z = ↑r h : ℝ e : z = ↑h ⊢ ↑(starRingEnd ℂ) z = z [PROOFSTEP] rw [e, conj_ofReal] [GOAL] z : ℂ ⊢ (∃ r, z = ↑r) → ↑z.re = z [PROOFSTEP] rintro ⟨r, rfl⟩ [GOAL] case intro r : ℝ ⊢ ↑(↑r).re = ↑r [PROOFSTEP] simp [ofReal'] [GOAL] ⊢ (fun z => z.re * z.re + z.im * z.im) 0 = 0 [PROOFSTEP] simp [GOAL] ⊢ ZeroHom.toFun { toFun := fun z => z.re * z.re + z.im * z.im, map_zero' := (_ : 0 * 0 + 0 * 0 = 0) } 1 = 1 [PROOFSTEP] simp [GOAL] z w : ℂ ⊢ ZeroHom.toFun { toFun := fun z => z.re * z.re + z.im * z.im, map_zero' := (_ : 0 * 0 + 0 * 0 = 0) } (z * w) = ZeroHom.toFun { toFun := fun z => z.re * z.re + z.im * z.im, map_zero' := (_ : 0 * 0 + 0 * 0 = 0) } z * ZeroHom.toFun { toFun := fun z => z.re * z.re + z.im * z.im, map_zero' := (_ : 0 * 0 + 0 * 0 = 0) } w [PROOFSTEP] dsimp [GOAL] z w : ℂ ⊢ (z.re * w.re - z.im * w.im) * (z.re * w.re - z.im * w.im) + (z.re * w.im + z.im * w.re) * (z.re * w.im + z.im * w.re) = (z.re * z.re + z.im * z.im) * (w.re * w.re + w.im * w.im) [PROOFSTEP] ring [GOAL] r : ℝ ⊢ ↑normSq ↑r = r * r [PROOFSTEP] simp [normSq, ofReal'] [GOAL] x y : ℝ ⊢ ↑normSq (↑x + ↑y * I) = x ^ 2 + y ^ 2 [PROOFSTEP] rw [← mk_eq_add_mul_I, normSq_mk, sq, sq] [GOAL] z : ℂ ⊢ ↑(↑normSq z) = ↑(starRingEnd ℂ) z * z [PROOFSTEP] ext [GOAL] case a z : ℂ ⊢ (↑(↑normSq z)).re = (↑(starRingEnd ℂ) z * z).re [PROOFSTEP] simp [normSq, mul_comm, ofReal'] [GOAL] case a z : ℂ ⊢ (↑(↑normSq z)).im = (↑(starRingEnd ℂ) z * z).im [PROOFSTEP] simp [normSq, mul_comm, ofReal'] [GOAL] ⊢ ↑normSq I = 1 [PROOFSTEP] simp [normSq] [GOAL] x : ℝ hx : x ∈ Ici 0 ⊢ ↑normSq ↑(Real.sqrt x) = x [PROOFSTEP] rw [normSq_ofReal, Real.mul_self_sqrt hx] [GOAL] z : ℂ ⊢ ↑normSq (-z) = ↑normSq z [PROOFSTEP] simp [normSq] [GOAL] z : ℂ ⊢ ↑normSq (↑(starRingEnd ℂ) z) = ↑normSq z [PROOFSTEP] simp [normSq] [GOAL] z w : ℂ ⊢ ↑normSq (z + w) = ↑normSq z + ↑normSq w + 2 * (z * ↑(starRingEnd ℂ) w).re [PROOFSTEP] dsimp [normSq] [GOAL] z w : ℂ ⊢ (z.re + w.re) * (z.re + w.re) + (z.im + w.im) * (z.im + w.im) = z.re * z.re + z.im * z.im + (w.re * w.re + w.im * w.im) + 2 * (z.re * w.re - z.im * -w.im) [PROOFSTEP] ring [GOAL] z : ℂ ⊢ (z * ↑(starRingEnd ℂ) z).re = (↑(↑normSq z)).re ∧ (z * ↑(starRingEnd ℂ) z).im = (↑(↑normSq z)).im [PROOFSTEP] simp [normSq, mul_comm, sub_eq_neg_add, add_comm, ofReal'] [GOAL] z : ℂ ⊢ (z + ↑(starRingEnd ℂ) z).re = (↑(2 * z.re)).re ∧ (z + ↑(starRingEnd ℂ) z).im = (↑(2 * z.re)).im [PROOFSTEP] simp [two_mul, ofReal'] [GOAL] ⊢ I ^ 2 = -1 [PROOFSTEP] rw [sq, I_mul_I] [GOAL] r s : ℝ ⊢ (↑(r - s)).re = (↑r - ↑s).re ∧ (↑(r - s)).im = (↑r - ↑s).im [PROOFSTEP] simp [ofReal'] [GOAL] r : ℝ n : ℕ ⊢ ↑(r ^ n) = ↑r ^ n [PROOFSTEP] induction n [GOAL] case zero r : ℝ ⊢ ↑(r ^ Nat.zero) = ↑r ^ Nat.zero [PROOFSTEP] simp [*, ofReal_mul, pow_succ] [GOAL] case succ r : ℝ n✝ : ℕ n_ih✝ : ↑(r ^ n✝) = ↑r ^ n✝ ⊢ ↑(r ^ Nat.succ n✝) = ↑r ^ Nat.succ n✝ [PROOFSTEP] simp [*, ofReal_mul, pow_succ] [GOAL] z : ℂ ⊢ (z - ↑(starRingEnd ℂ) z).re = (↑(2 * z.im) * I).re ∧ (z - ↑(starRingEnd ℂ) z).im = (↑(2 * z.im) * I).im [PROOFSTEP] simp [two_mul, sub_eq_add_neg, ofReal'] [GOAL] z w : ℂ ⊢ ↑normSq (z - w) = ↑normSq z + ↑normSq w - 2 * (z * ↑(starRingEnd ℂ) w).re [PROOFSTEP] rw [sub_eq_add_neg, normSq_add] [GOAL] z w : ℂ ⊢ ↑normSq z + ↑normSq (-w) + 2 * (z * ↑(starRingEnd ℂ) (-w)).re = ↑normSq z + ↑normSq w - 2 * (z * ↑(starRingEnd ℂ) w).re [PROOFSTEP] simp only [RingHom.map_neg, mul_neg, neg_re, normSq_neg] [GOAL] z w : ℂ ⊢ ↑normSq z + ↑normSq w + -(2 * (z * ↑(starRingEnd ℂ) w).re) = ↑normSq z + ↑normSq w - 2 * (z * ↑(starRingEnd ℂ) w).re [PROOFSTEP] ring [GOAL] z : ℂ ⊢ z⁻¹.re = z.re / ↑normSq z [PROOFSTEP] simp [inv_def, division_def, ofReal'] [GOAL] z : ℂ ⊢ z⁻¹.im = -z.im / ↑normSq z [PROOFSTEP] simp [inv_def, division_def, ofReal'] [GOAL] r : ℝ ⊢ (↑r⁻¹).re = (↑r)⁻¹.re ∧ (↑r⁻¹).im = (↑r)⁻¹.im [PROOFSTEP] simp [ofReal'] [GOAL] ⊢ 0⁻¹ = 0 [PROOFSTEP] rw [← ofReal_zero, ← ofReal_inv, inv_zero] [GOAL] z : ℂ h : z ≠ 0 ⊢ z * z⁻¹ = 1 [PROOFSTEP] rw [inv_def, ← mul_assoc, mul_conj, ← ofReal_mul, mul_inv_cancel (mt normSq_eq_zero.1 h), ofReal_one] [GOAL] n : ℕ ⊢ (↑n).re = ↑n [PROOFSTEP] rw [← ofReal_nat_cast, ofReal_re] [GOAL] n : ℕ ⊢ (↑n).im = 0 [PROOFSTEP] rw [← ofReal_nat_cast, ofReal_im] [GOAL] n : ℤ ⊢ (↑n).re = ↑n [PROOFSTEP] rw [← ofReal_int_cast, ofReal_re] [GOAL] n : ℤ ⊢ (↑n).im = 0 [PROOFSTEP] rw [← ofReal_int_cast, ofReal_im] [GOAL] q : ℚ ⊢ (↑q).im = 0 [PROOFSTEP] show (Rat.castRec q : ℂ).im = 0 [GOAL] q : ℚ ⊢ (Rat.castRec q).im = 0 [PROOFSTEP] cases q [GOAL] case mk' num✝ : ℤ den✝ : ℕ den_nz✝ : den✝ ≠ 0 reduced✝ : Nat.coprime (Int.natAbs num✝) den✝ ⊢ (Rat.castRec (Rat.mk' num✝ den✝)).im = 0 [PROOFSTEP] simp [Rat.castRec] [GOAL] q : ℚ ⊢ (↑q).re = ↑q [PROOFSTEP] show (Rat.castRec q : ℂ).re = _ [GOAL] q : ℚ ⊢ (Rat.castRec q).re = ↑q [PROOFSTEP] cases q [GOAL] case mk' num✝ : ℤ den✝ : ℕ den_nz✝ : den✝ ≠ 0 reduced✝ : Nat.coprime (Int.natAbs num✝) den✝ ⊢ (Rat.castRec (Rat.mk' num✝ den✝)).re = ↑(Rat.mk' num✝ den✝) [PROOFSTEP] simp [Rat.castRec, normSq, Rat.mk_eq_divInt, Rat.mkRat_eq_div, div_eq_mul_inv, *] [GOAL] n : ℚ z : ℂ ⊢ ((fun n z => n • z) n z).re = (↑n * z).re ∧ ((fun n z => n • z) n z).im = (↑n * z).im [PROOFSTEP] simp [Rat.smul_def, smul_re, smul_im] [GOAL] n : ℤ ⊢ I ^ bit0 n = (-1) ^ n [PROOFSTEP] rw [zpow_bit0', I_mul_I] [GOAL] n : ℤ ⊢ I ^ bit1 n = (-1) ^ n * I [PROOFSTEP] rw [zpow_bit1', I_mul_I] [GOAL] z w : ℂ ⊢ (z / w).re = z.re * w.re / ↑normSq w + z.im * w.im / ↑normSq w [PROOFSTEP] simp [div_eq_mul_inv, mul_assoc, sub_eq_add_neg] [GOAL] z w : ℂ ⊢ (z / w).im = z.im * w.re / ↑normSq w - z.re * w.im / ↑normSq w [PROOFSTEP] simp [div_eq_mul_inv, mul_assoc, sub_eq_add_neg, add_comm] [GOAL] z : ℂ ⊢ -(z * I) * I = z [PROOFSTEP] simp [mul_assoc] [GOAL] ⊢ I⁻¹ = -I [PROOFSTEP] rw [inv_eq_one_div, div_I, one_mul] [GOAL] n : ℕ h : ↑n = 0 ⊢ n = 0 [PROOFSTEP] rwa [← ofReal_nat_cast, ofReal_eq_zero, Nat.cast_eq_zero] at h [GOAL] z : ℂ ⊢ ↑z.re = (z + ↑(starRingEnd ℂ) z) / 2 [PROOFSTEP] have : (↑(↑2 : ℝ) : ℂ) = (2 : ℂ) := by rfl [GOAL] z : ℂ ⊢ ↑2 = 2 [PROOFSTEP] rfl [GOAL] z : ℂ this : ↑2 = 2 ⊢ ↑z.re = (z + ↑(starRingEnd ℂ) z) / 2 [PROOFSTEP] simp only [add_conj, ofReal_mul, ofReal_one, ofReal_bit0, this, mul_div_cancel_left (z.re : ℂ) two_ne_zero] [GOAL] z : ℂ ⊢ ↑z.im = (z - ↑(starRingEnd ℂ) z) / (2 * I) [PROOFSTEP] have : (↑2 : ℝ) * I = 2 * I := by rfl [GOAL] z : ℂ ⊢ ↑2 * I = 2 * I [PROOFSTEP] rfl [GOAL] z : ℂ this : ↑2 * I = 2 * I ⊢ ↑z.im = (z - ↑(starRingEnd ℂ) z) / (2 * I) [PROOFSTEP] simp only [sub_conj, ofReal_mul, ofReal_one, ofReal_bit0, mul_right_comm, this, mul_div_cancel_left _ (mul_ne_zero two_ne_zero I_ne_zero : 2 * I ≠ 0)] [GOAL] z : ℂ ⊢ Real.sqrt (↑normSq (↑(starRingEnd ℂ) z)) = Real.sqrt (↑normSq z) [PROOFSTEP] simp [GOAL] z : ℂ ⊢ |z.re| ≤ Real.sqrt (↑normSq z) [PROOFSTEP] rw [mul_self_le_mul_self_iff (abs_nonneg z.re) (abs_nonneg' _), abs_mul_abs_self, mul_self_abs] [GOAL] z : ℂ ⊢ z.re * z.re ≤ ↑normSq z [PROOFSTEP] apply re_sq_le_normSq [GOAL] z w : ℂ ⊢ Real.sqrt (↑normSq (z * w)) = Real.sqrt (↑normSq z) * Real.sqrt (↑normSq w) [PROOFSTEP] rw [normSq_mul, Real.sqrt_mul (normSq_nonneg _)] [GOAL] z w : ℂ ⊢ Real.sqrt (↑normSq (z + w)) * Real.sqrt (↑normSq (z + w)) ≤ (Real.sqrt (↑normSq z) + Real.sqrt (↑normSq w)) * (Real.sqrt (↑normSq z) + Real.sqrt (↑normSq w)) [PROOFSTEP] rw [mul_self_abs, add_mul_self_eq, mul_self_abs, mul_self_abs, add_right_comm, normSq_add, add_le_add_iff_left, mul_assoc, mul_le_mul_left (zero_lt_two' ℝ), ← Real.sqrt_mul <| normSq_nonneg z, ← normSq_conj w, ← map_mul] [GOAL] z w : ℂ ⊢ (z * ↑(starRingEnd ℂ) w).re ≤ Real.sqrt (↑normSq (z * ↑(starRingEnd ℂ) w)) [PROOFSTEP] exact re_le_abs (z * conj w) [GOAL] r : ℝ ⊢ ↑abs ↑r = |r| [PROOFSTEP] simp [Complex.abs, normSq_ofReal, Real.sqrt_mul_self_eq_abs] [GOAL] n : ℕ ⊢ ↑abs ↑n = ↑abs ↑↑n [PROOFSTEP] rw [ofReal_nat_cast] [GOAL] z : ℂ ⊢ ↑abs z ^ 2 - z.re ^ 2 = z.im ^ 2 [PROOFSTEP] rw [sq_abs, normSq_apply, ← sq, ← sq, add_sub_cancel'] [GOAL] z : ℂ ⊢ ↑abs z ^ 2 - z.im ^ 2 = z.re ^ 2 [PROOFSTEP] rw [← sq_abs_sub_sq_re, sub_sub_cancel] [GOAL] ⊢ ↑abs I = 1 [PROOFSTEP] simp [Complex.abs] [GOAL] ⊢ ↑abs 2 = ↑abs ↑2 [PROOFSTEP] rfl [GOAL] ⊢ 0 ≤ 2 [PROOFSTEP] norm_num [GOAL] ⊢ range ↑abs ⊆ Ici 0 [PROOFSTEP] simp only [range_subset_iff, Ici, mem_setOf_eq, map_nonneg, forall_const] [GOAL] z : ℂ ⊢ z.re ^ 2 ≤ ↑normSq z [PROOFSTEP] rw [normSq_apply, ← sq] [GOAL] z : ℂ ⊢ z.re ^ 2 ≤ z.re ^ 2 + z.im * z.im [PROOFSTEP] exact le_add_of_nonneg_right (mul_self_nonneg _) [GOAL] z : ℂ ⊢ z.im ^ 2 ≤ ↑normSq z [PROOFSTEP] rw [normSq_apply, ← sq, ← sq] [GOAL] z : ℂ ⊢ z.im ^ 2 ≤ z.re ^ 2 + z.im ^ 2 [PROOFSTEP] exact le_add_of_nonneg_left (sq_nonneg _) [GOAL] z : ℂ ⊢ |z.re| < ↑abs z ↔ z.im ≠ 0 [PROOFSTEP] rw [Complex.abs, AbsoluteValue.coe_mk, MulHom.coe_mk, Real.lt_sqrt (abs_nonneg _), normSq_apply, _root_.sq_abs, ← sq, lt_add_iff_pos_right, mul_self_pos] [GOAL] z : ℂ ⊢ |z.im| < ↑abs z ↔ z.re ≠ 0 [PROOFSTEP] simpa using @abs_re_lt_abs (z * I) [GOAL] z : ℂ ⊢ ↑abs z ≤ |z.re| + |z.im| [PROOFSTEP] simpa [re_add_im] using Complex.abs.add_le z.re (z.im * I) [GOAL] ⊢ 1 ≠ 0 [PROOFSTEP] apply one_ne_zero [GOAL] z : ℂ ⊢ ↑abs z ≤ Real.sqrt 2 * max |z.re| |z.im| [PROOFSTEP] cases' z with x y [GOAL] case mk x y : ℝ ⊢ ↑abs { re := x, im := y } ≤ Real.sqrt 2 * max |{ re := x, im := y }.re| |{ re := x, im := y }.im| [PROOFSTEP] simp only [abs_apply, normSq_mk, ← sq] [GOAL] case mk x y : ℝ ⊢ Real.sqrt (x ^ 2 + y ^ 2) ≤ Real.sqrt 2 * max |x| |y| [PROOFSTEP] by_cases hle : |x| ≤ |y| [GOAL] case pos x y : ℝ hle : |x| ≤ |y| ⊢ Real.sqrt (x ^ 2 + y ^ 2) ≤ Real.sqrt 2 * max |x| |y| [PROOFSTEP] calc Real.sqrt (x ^ 2 + y ^ 2) ≤ Real.sqrt (y ^ 2 + y ^ 2) := Real.sqrt_le_sqrt (add_le_add_right (sq_le_sq.2 hle) _) _ = Real.sqrt 2 * max |x| |y| := by rw [max_eq_right hle, ← two_mul, Real.sqrt_mul two_pos.le, Real.sqrt_sq_eq_abs] [GOAL] x y : ℝ hle : |x| ≤ |y| ⊢ Real.sqrt (y ^ 2 + y ^ 2) = Real.sqrt 2 * max |x| |y| [PROOFSTEP] rw [max_eq_right hle, ← two_mul, Real.sqrt_mul two_pos.le, Real.sqrt_sq_eq_abs] [GOAL] case neg x y : ℝ hle : ¬|x| ≤ |y| ⊢ Real.sqrt (x ^ 2 + y ^ 2) ≤ Real.sqrt 2 * max |x| |y| [PROOFSTEP] have hle' := le_of_not_le hle [GOAL] case neg x y : ℝ hle : ¬|x| ≤ |y| hle' : |y| ≤ |x| ⊢ Real.sqrt (x ^ 2 + y ^ 2) ≤ Real.sqrt 2 * max |x| |y| [PROOFSTEP] rw [add_comm] [GOAL] case neg x y : ℝ hle : ¬|x| ≤ |y| hle' : |y| ≤ |x| ⊢ Real.sqrt (y ^ 2 + x ^ 2) ≤ Real.sqrt 2 * max |x| |y| [PROOFSTEP] calc Real.sqrt (y ^ 2 + x ^ 2) ≤ Real.sqrt (x ^ 2 + x ^ 2) := Real.sqrt_le_sqrt (add_le_add_right (sq_le_sq.2 hle') _) _ = Real.sqrt 2 * max |x| |y| := by rw [max_eq_left hle', ← two_mul, Real.sqrt_mul two_pos.le, Real.sqrt_sq_eq_abs] [GOAL] x y : ℝ hle : ¬|x| ≤ |y| hle' : |y| ≤ |x| ⊢ Real.sqrt (x ^ 2 + x ^ 2) = Real.sqrt 2 * max |x| |y| [PROOFSTEP] rw [max_eq_left hle', ← two_mul, Real.sqrt_mul two_pos.le, Real.sqrt_sq_eq_abs] [GOAL] z : ℂ hz : z = 0 ⊢ |z.re / ↑abs z| ≤ 1 [PROOFSTEP] simp [hz, zero_le_one] [GOAL] z : ℂ hz : ¬z = 0 ⊢ |z.re / ↑abs z| ≤ 1 [PROOFSTEP] simp_rw [_root_.abs_div, abs_abs, div_le_iff (AbsoluteValue.pos Complex.abs hz), one_mul, abs_re_le_abs] [GOAL] z : ℂ hz : z = 0 ⊢ |z.im / ↑abs z| ≤ 1 [PROOFSTEP] simp [hz, zero_le_one] [GOAL] z : ℂ hz : ¬z = 0 ⊢ |z.im / ↑abs z| ≤ 1 [PROOFSTEP] simp_rw [_root_.abs_div, abs_abs, div_le_iff (AbsoluteValue.pos Complex.abs hz), one_mul, abs_im_le_abs] [GOAL] n : ℕ ⊢ ↑abs ↑n = ↑n [PROOFSTEP] rw [← ofReal_nat_cast, abs_of_nonneg (Nat.cast_nonneg n)] [GOAL] n : ℤ ⊢ |↑n| = ↑abs ↑n [PROOFSTEP] rw [← ofReal_int_cast, abs_ofReal] [GOAL] x : ℂ ⊢ ↑normSq x = ↑abs x ^ 2 [PROOFSTEP] simp [abs, sq, abs_def, Real.mul_self_sqrt (normSq_nonneg _)] [GOAL] f : CauSeq ℂ ↑abs ε : ℝ ε0 : ε > 0 i : ℕ H : ∀ (j : ℕ), j ≥ i → ↑abs (↑f j - ↑f i) < ε j : ℕ ij : j ≥ i ⊢ abs' ((fun n => (↑f n).re) j - (fun n => (↑f n).re) i) ≤ ↑abs (↑f j - ↑f i) [PROOFSTEP] simpa using abs_re_le_abs (f j - f i) [GOAL] f : CauSeq ℂ ↑abs ε : ℝ ε0 : ε > 0 i : ℕ H : ∀ (j : ℕ), j ≥ i → ↑abs (↑f j - ↑f i) < ε j : ℕ ij : j ≥ i ⊢ abs' ((fun n => (↑f n).im) j - (fun n => (↑f n).im) i) ≤ ↑abs (↑f j - ↑f i) [PROOFSTEP] simpa using abs_im_le_abs (f j - f i) [GOAL] f : CauSeq ℂ ↑abs ε : ℝ ε0 : ε > 0 i : ℕ H : ∀ (j : ℕ), j ≥ i → abs' (↑({ val := fun n => (↑f n).re, property := (_ : IsCauSeq abs' fun n => (↑f n).re) } - CauSeq.const abs' (CauSeq.lim { val := fun n => (↑f n).re, property := (_ : IsCauSeq abs' fun n => (↑f n).re) })) j) < ε / 2 ∧ abs' (↑({ val := fun n => (↑f n).im, property := (_ : IsCauSeq abs' fun n => (↑f n).im) } - CauSeq.const abs' (CauSeq.lim { val := fun n => (↑f n).im, property := (_ : IsCauSeq abs' fun n => (↑f n).im) })) j) < ε / 2 j : ℕ ij : j ≥ i ⊢ ↑abs (↑(f - CauSeq.const (↑abs) (limAux f)) j) < ε [PROOFSTEP] cases' H _ ij with H₁ H₂ [GOAL] case intro f : CauSeq ℂ ↑abs ε : ℝ ε0 : ε > 0 i : ℕ H : ∀ (j : ℕ), j ≥ i → abs' (↑({ val := fun n => (↑f n).re, property := (_ : IsCauSeq abs' fun n => (↑f n).re) } - CauSeq.const abs' (CauSeq.lim { val := fun n => (↑f n).re, property := (_ : IsCauSeq abs' fun n => (↑f n).re) })) j) < ε / 2 ∧ abs' (↑({ val := fun n => (↑f n).im, property := (_ : IsCauSeq abs' fun n => (↑f n).im) } - CauSeq.const abs' (CauSeq.lim { val := fun n => (↑f n).im, property := (_ : IsCauSeq abs' fun n => (↑f n).im) })) j) < ε / 2 j : ℕ ij : j ≥ i H₁ : abs' (↑({ val := fun n => (↑f n).re, property := (_ : IsCauSeq abs' fun n => (↑f n).re) } - CauSeq.const abs' (CauSeq.lim { val := fun n => (↑f n).re, property := (_ : IsCauSeq abs' fun n => (↑f n).re) })) j) < ε / 2 H₂ : abs' (↑({ val := fun n => (↑f n).im, property := (_ : IsCauSeq abs' fun n => (↑f n).im) } - CauSeq.const abs' (CauSeq.lim { val := fun n => (↑f n).im, property := (_ : IsCauSeq abs' fun n => (↑f n).im) })) j) < ε / 2 ⊢ ↑abs (↑(f - CauSeq.const (↑abs) (limAux f)) j) < ε [PROOFSTEP] apply lt_of_le_of_lt (abs_le_abs_re_add_abs_im _) [GOAL] case intro f : CauSeq ℂ ↑abs ε : ℝ ε0 : ε > 0 i : ℕ H : ∀ (j : ℕ), j ≥ i → abs' (↑({ val := fun n => (↑f n).re, property := (_ : IsCauSeq abs' fun n => (↑f n).re) } - CauSeq.const abs' (CauSeq.lim { val := fun n => (↑f n).re, property := (_ : IsCauSeq abs' fun n => (↑f n).re) })) j) < ε / 2 ∧ abs' (↑({ val := fun n => (↑f n).im, property := (_ : IsCauSeq abs' fun n => (↑f n).im) } - CauSeq.const abs' (CauSeq.lim { val := fun n => (↑f n).im, property := (_ : IsCauSeq abs' fun n => (↑f n).im) })) j) < ε / 2 j : ℕ ij : j ≥ i H₁ : abs' (↑({ val := fun n => (↑f n).re, property := (_ : IsCauSeq abs' fun n => (↑f n).re) } - CauSeq.const abs' (CauSeq.lim { val := fun n => (↑f n).re, property := (_ : IsCauSeq abs' fun n => (↑f n).re) })) j) < ε / 2 H₂ : abs' (↑({ val := fun n => (↑f n).im, property := (_ : IsCauSeq abs' fun n => (↑f n).im) } - CauSeq.const abs' (CauSeq.lim { val := fun n => (↑f n).im, property := (_ : IsCauSeq abs' fun n => (↑f n).im) })) j) < ε / 2 ⊢ abs' (↑(f - CauSeq.const (↑abs) (limAux f)) j).re + abs' (↑(f - CauSeq.const (↑abs) (limAux f)) j).im < ε [PROOFSTEP] dsimp [limAux] at * [GOAL] case intro f : CauSeq ℂ ↑abs ε : ℝ ε0 : ε > 0 i : ℕ H : ∀ (j : ℕ), j ≥ i → abs' ((↑f j).re - CauSeq.lim { val := fun n => (↑f n).re, property := (_ : IsCauSeq abs' fun n => (↑f n).re) }) < ε / 2 ∧ abs' ((↑f j).im - CauSeq.lim { val := fun n => (↑f n).im, property := (_ : IsCauSeq abs' fun n => (↑f n).im) }) < ε / 2 j : ℕ ij : j ≥ i H₁ : abs' ((↑f j).re - CauSeq.lim { val := fun n => (↑f n).re, property := (_ : IsCauSeq abs' fun n => (↑f n).re) }) < ε / 2 H₂ : abs' ((↑f j).im - CauSeq.lim { val := fun n => (↑f n).im, property := (_ : IsCauSeq abs' fun n => (↑f n).im) }) < ε / 2 ⊢ abs' ((↑f j).re - CauSeq.lim (cauSeqRe f)) + abs' ((↑f j).im - CauSeq.lim (cauSeqIm f)) < ε [PROOFSTEP] have := add_lt_add H₁ H₂ [GOAL] case intro f : CauSeq ℂ ↑abs ε : ℝ ε0 : ε > 0 i : ℕ H : ∀ (j : ℕ), j ≥ i → abs' ((↑f j).re - CauSeq.lim { val := fun n => (↑f n).re, property := (_ : IsCauSeq abs' fun n => (↑f n).re) }) < ε / 2 ∧ abs' ((↑f j).im - CauSeq.lim { val := fun n => (↑f n).im, property := (_ : IsCauSeq abs' fun n => (↑f n).im) }) < ε / 2 j : ℕ ij : j ≥ i H₁ : abs' ((↑f j).re - CauSeq.lim { val := fun n => (↑f n).re, property := (_ : IsCauSeq abs' fun n => (↑f n).re) }) < ε / 2 H₂ : abs' ((↑f j).im - CauSeq.lim { val := fun n => (↑f n).im, property := (_ : IsCauSeq abs' fun n => (↑f n).im) }) < ε / 2 this : abs' ((↑f j).re - CauSeq.lim { val := fun n => (↑f n).re, property := (_ : IsCauSeq abs' fun n => (↑f n).re) }) + abs' ((↑f j).im - CauSeq.lim { val := fun n => (↑f n).im, property := (_ : IsCauSeq abs' fun n => (↑f n).im) }) < ε / 2 + ε / 2 ⊢ abs' ((↑f j).re - CauSeq.lim (cauSeqRe f)) + abs' ((↑f j).im - CauSeq.lim (cauSeqIm f)) < ε [PROOFSTEP] rwa [add_halves] at this [GOAL] f : CauSeq ℂ ↑abs x✝ : ℕ ⊢ (↑(CauSeq.const (↑abs) (limAux f)) x✝).re = (↑(CauSeq.const (↑abs) (↑(CauSeq.lim (cauSeqRe f)) + ↑(CauSeq.lim (cauSeqIm f)) * I)) x✝).re [PROOFSTEP] simp [limAux, cauSeqRe, ofReal'] [GOAL] f : CauSeq ℂ ↑abs x✝ : ℕ ⊢ (↑(CauSeq.const (↑abs) (limAux f)) x✝).im = (↑(CauSeq.const (↑abs) (↑(CauSeq.lim (cauSeqRe f)) + ↑(CauSeq.lim (cauSeqIm f)) * I)) x✝).im [PROOFSTEP] simp [limAux, cauSeqIm, ofReal'] [GOAL] f : CauSeq ℂ ↑abs ⊢ CauSeq.lim (cauSeqRe f) = (CauSeq.lim f).re [PROOFSTEP] rw [lim_eq_lim_im_add_lim_re] [GOAL] f : CauSeq ℂ ↑abs ⊢ CauSeq.lim (cauSeqRe f) = (↑(CauSeq.lim (cauSeqRe f)) + ↑(CauSeq.lim (cauSeqIm f)) * I).re [PROOFSTEP] simp [ofReal'] [GOAL] f : CauSeq ℂ ↑abs ⊢ CauSeq.lim (cauSeqIm f) = (CauSeq.lim f).im [PROOFSTEP] rw [lim_eq_lim_im_add_lim_re] [GOAL] f : CauSeq ℂ ↑abs ⊢ CauSeq.lim (cauSeqIm f) = (↑(CauSeq.lim (cauSeqRe f)) + ↑(CauSeq.lim (cauSeqIm f)) * I).im [PROOFSTEP] simp [ofReal'] [GOAL] f : CauSeq ℂ ↑abs ε : ℝ ε0 : ε > 0 i : ℕ hi : ∀ (j : ℕ), j ≥ i → ↑abs (↑f j - ↑f i) < ε j : ℕ hj : j ≥ i ⊢ ↑abs ((fun n => ↑(starRingEnd ℂ) (↑f n)) j - (fun n => ↑(starRingEnd ℂ) (↑f n)) i) < ε [PROOFSTEP] rw [← RingHom.map_sub, abs_conj] [GOAL] f : CauSeq ℂ ↑abs ε : ℝ ε0 : ε > 0 i : ℕ hi : ∀ (j : ℕ), j ≥ i → ↑abs (↑f j - ↑f i) < ε j : ℕ hj : j ≥ i ⊢ ↑abs (↑f j - ↑f i) < ε [PROOFSTEP] exact hi j hj [GOAL] f : CauSeq ℂ ↑abs ⊢ (CauSeq.lim (cauSeqConj f)).re = (↑(starRingEnd ℂ) (CauSeq.lim f)).re [PROOFSTEP] simp [cauSeqConj, (lim_re _).symm, cauSeqRe] [GOAL] f : CauSeq ℂ ↑abs ⊢ (CauSeq.lim (cauSeqConj f)).im = (↑(starRingEnd ℂ) (CauSeq.lim f)).im [PROOFSTEP] simp [cauSeqConj, (lim_im _).symm, cauSeqIm, (lim_neg _).symm] [GOAL] f : CauSeq ℂ ↑abs ⊢ CauSeq.lim { val := fun n => -(↑f n).im, property := (_ : (fun f => IsCauSeq abs' f) fun n => -(↑f n).im) } = CauSeq.lim (-{ val := fun n => (↑f n).im, property := (_ : IsCauSeq abs' fun n => (↑f n).im) }) [PROOFSTEP] rfl
function s = tifs2seq(file) %TIFS2SEQ Create a MATLAB sequence from a multi-frame TIFF file. % % Copyright 2002-2020 Gatesmark % % This function, and other functions in the DIPUM Toolbox, are based % on the theoretical and practical foundations established in the % book Digital Image Processing Using MATLAB, 3rd ed., Gatesmark % Press, 2020. % % Book website: http://www.imageprocessingplace.com % License: https://github.com/dipum/dipum-toolbox/blob/master/LICENSE.txt % Get the number of frames in the multi-frame TIFF. frames = size(imfinfo(file), 1); % Read the first frame, preallocate the sequence, and put the first % in it. i = imread(file, 1); s = zeros([size(i) 1 frames], 'uint8'); s(:,:,:,1) = i; % Read the remaining TIFF frames and add to the sequence. for i = 2:frames s(:,:,:,i) = imread(file, i); end
{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE ViewPatterns #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE UnicodeSyntax #-} -- -- | -- Module : Main -- Description : Measures execution time of MC loop for 1D Heisenberg -- Hamiltonian. Try @--help@ to get usage information. -- Copyright : (c) Tom Westerhout, 2018 -- License : BSD3 -- Maintainer : [email protected] -- Stability : experimental module Main where import Prelude hiding ( map , zipWithM ) import Debug.Trace import qualified System.Random.MWC as MWC -- import Control.Lens hiding((<.>)) import Control.Monad.Reader hiding ( zipWithM ) import Control.Monad.Primitive import qualified Data.List as L import Data.Complex import Data.Semigroup import Data.Vector.Storable ( Vector , (!) ) import qualified Data.Vector.Storable as V import qualified Data.Vector.Storable.Mutable as MV import System.Exit import System.IO hiding ( hGetLine ) import System.Environment ( getArgs , getProgName ) import Foreign.Storable import Data.Text ( Text ) import Data.Text.IO ( hGetLine ) import qualified Data.Text.IO as T import Lens.Micro import Lens.Micro.Extras import PSO.Random import PSO.FromPython import NQS.Rbm (Rbm, mkRbm) import NQS.Rbm.Mutable -- (sampleGradients) import NQS.Internal.Hamiltonian import NQS.Internal.Types -- (ℂ, ℝ) import NQS.Internal.Rbm (unsafeThawRbm) import NQS.Internal.LAPACK fromPyFile :: FilePath -> IO Rbm fromPyFile name = withFile name ReadMode toRbm where toRight :: Either String (Vector ℂ) -> Vector ℂ toRight (Right x) = x toRight (Left x) = error x toRbm h = do hGetLine h a <- trace ("a...") $ toRight <$> readVector <$> hGetLine h b <- trace ("b...") $ toRight <$> readVector <$> hGetLine h s <- hGetLine h T.putStrLn s let !w = trace ("w...") $ toRight $ readMatrix s return $ mkRbm a b w randomRbm :: Int -> Int -> (ℝ, ℝ) -> (ℝ, ℝ) -> (ℝ, ℝ) -> IO Rbm randomRbm n m (lowV, highV) (lowH, highH) (lowW, highW) = do g <- mkMWCGen (Just 123) flip runReaderT g $ do visible <- uniformVector n (lowV :+ lowV, highV :+ highV) hidden <- uniformVector m (lowH :+ lowH, highH :+ highH) weights <- uniformVector (n * m) (lowW :+ lowW, highW :+ highW) return $ trace ("mkRbm...") (mkRbm visible hidden weights) numberSteps :: (Int, Int, Int) -> Int numberSteps (low, high, step) = (high - low - 1) `div` step + 1 main = do -- NQS.Internal.LAPACK.test let filename = "/home/tom/src/tcm-swarm/cbits/test/input/rbm_6_6_0.in" rbm <- unsafeThawRbm =<< fromPyFile filename :: IO (MRbm (PrimState IO)) -- rbm <- unsafeThawRbm =<< randomRbm 100 200 (-0.1, 0.1) (-0.1, 0.1) (-0.05, 0.05) let n = sizeVisible rbm config = defaultMCConfig & steps .~ (1000, 21000 * n, n) & magnetisation .~ (Just 0) nParams = size rbm nSteps = numberSteps $ config ^. steps print n hamiltonian <- heisenberg (1, 1) (Just 5.0) (zip [0..] ([1..(n - 1)] ++ [0])) moments <- MV.new 4 -- f <- newDenseVector nParams -- grad <- newDenseMatrix (nSteps * config ^. runs) nParams sampleMoments config hamiltonian rbm moments -- f grad e <- MV.read moments 0 print ["Hello!", show e]
data _ : Set where
= = Second stage = =
State Before: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: have : ∃ ϕ : M →ₗ[R] R, ∀ ψ : M →ₗ[R] R, ¬ϕ.submoduleImage N < ψ.submoduleImage N := by obtain ⟨P, P_eq, P_max⟩ := set_has_maximal_iff_noetherian.mpr (inferInstance : IsNoetherian R R) _ (show (Set.range fun ψ : M →ₗ[R] R ↦ ψ.submoduleImage N).Nonempty from ⟨_, Set.mem_range.mpr ⟨0, rfl⟩⟩) obtain ⟨ϕ, rfl⟩ := Set.mem_range.mp P_eq exact ⟨ϕ, fun ψ hψ ↦ P_max _ ⟨_, rfl⟩ hψ⟩ State Before: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: let ϕ := this.choose State Before: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: have ϕ_max := this.choose_spec State Before: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: let a := generator (ϕ.submoduleImage N) State Before: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: have a_mem : a ∈ ϕ.submoduleImage N := generator_mem _ State Before: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: case pos ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : a = 0 ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) case neg ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: by_cases a_zero : a = 0 State Before: case neg ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: case neg.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: obtain ⟨y, yN, ϕy_eq⟩ := (LinearMap.mem_submoduleImage_of_le N_le_M).mp a_mem State Before: case neg.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: case neg.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: have _ϕy_ne_zero : ϕ ⟨y, N_le_M yN⟩ ≠ 0 := fun h ↦ a_zero (ϕy_eq.symm.trans h) State Before: case neg.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: case neg.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 hdvd : ∀ (i : ι), a ∣ ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: have hdvd : ∀ i, a ∣ b'M.coord i ⟨y, N_le_M yN⟩ := fun i ↦ generator_maximal_submoduleImage_dvd N_le_M ϕ_max y yN ϕy_eq (b'M.coord i) State Before: case neg.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 hdvd : ∀ (i : ι), a ∣ ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: case neg.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: choose c hc using hdvd State Before: case neg.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: cases nonempty_fintype ι State Before: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: let y' : O := ∑ i, c i • b'M i State Before: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: have y'M : y' ∈ M := M.sum_mem fun i _ ↦ M.smul_mem (c i) (b'M i).2 State Before: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: have mk_y' : (⟨y', y'M⟩ : M) = ∑ i, c i • b'M i := Subtype.ext (show y' = M.subtype _ by simp only [LinearMap.map_sum, LinearMap.map_smul] rfl) State Before: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: have a_smul_y' : a • y' = y := by refine Subtype.mk_eq_mk.mp (show (a • ⟨y', y'M⟩ : M) = ⟨y, N_le_M yN⟩ from ?_) rw [← b'M.sum_repr ⟨y, N_le_M yN⟩, mk_y', Finset.smul_sum] refine' Finset.sum_congr rfl fun i _ ↦ _ rw [← mul_smul, ← hc] rfl State Before: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ⊢ ∃ M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: refine' ⟨y', y'M, a, a_smul_y'.symm ▸ yN, _⟩ State Before: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ⊢ ∃ M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ⊢ ∃ M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: have ϕy'_eq : ϕ ⟨y', y'M⟩ = 1 := mul_left_cancel₀ a_zero (calc a • ϕ ⟨y', y'M⟩ = ϕ ⟨a • y', _⟩ := (ϕ.map_smul a ⟨y', y'M⟩).symm _ = ϕ ⟨y, N_le_M yN⟩ := by simp only [a_smul_y'] _ = a := ϕy_eq _ = a * 1 := (mul_one a).symm ) State Before: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ⊢ ∃ M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 ⊢ ∃ M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: have ϕy'_ne_zero : ϕ ⟨y', y'M⟩ ≠ 0 := by simpa only [ϕy'_eq] using one_ne_zero State Before: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 ⊢ ∃ M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) ⊢ ∃ M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: let M' : Submodule R O := ϕ.ker.map M.subtype State Before: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) ⊢ ∃ M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) ⊢ ∃ M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: let N' : Submodule R O := (ϕ.comp (ofLe N_le_M)).ker.map N.subtype State Before: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) ⊢ ∃ M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M ⊢ ∃ M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: have M'_le_M : M' ≤ M := M.map_subtype_le (LinearMap.ker ϕ) State Before: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M ⊢ ∃ M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' ⊢ ∃ M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: have N'_le_M' : N' ≤ M' := by intro x hx simp only [mem_map, LinearMap.mem_ker] at hx⊢ obtain ⟨⟨x, xN⟩, hx, rfl⟩ := hx exact ⟨⟨x, N_le_M xN⟩, hx, rfl⟩ State Before: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' ⊢ ∃ M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N ⊢ ∃ M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: have N'_le_N : N' ≤ N := N.map_subtype_le (LinearMap.ker (ϕ.comp (ofLe N_le_M))) State Before: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N ⊢ ∃ M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N ⊢ ∃ _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: refine' ⟨M', M'_le_M, N', N'_le_N, N'_le_M', _⟩ State Before: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ⊢ ∃ _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 ⊢ ∃ _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: have ay'_ortho_N' : ∀ (c : R), ∀ z ∈ N', c • a • y' + z = 0 → c = 0 := by intro c z zN' hc refine' (mul_eq_zero.mp (y'_ortho_M' (a * c) z (N'_le_M' zN') _)).resolve_left a_zero rw [mul_comm, mul_smul, hc] State Before: case neg.intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 ⊢ ∃ _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: case neg.intro.intro.intro.refine'_1 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } ⊢ Basis (Fin (n' + 1)) R { x // x ∈ N } case neg.intro.intro.intro.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } ⊢ ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑?neg.intro.intro.intro.refine'_1✝ i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: refine' ⟨y'_ortho_M', ay'_ortho_N', fun n' bN' ↦ ⟨_, _⟩⟩ State Before: case neg.intro.intro.intro.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } ⊢ ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑(Basis.mkFinConsOfLe y yN bN' N'_le_N (_ : ∀ (c : R) (z : O), z ∈ N' → c • y + z = 0 → c = 0) (_ : ∀ (z : O), z ∈ N → ∃ c, z + c • y ∈ N')) i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: case neg.intro.intro.intro.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } ⊢ ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑(Basis.mkFinConsOfLe y yN bN' N'_le_N (_ : ∀ (c : R) (z : O), z ∈ N' → c • y + z = 0 → c = 0) (_ : ∀ (z : O), z ∈ N → ∃ c, z + c • y ∈ N')) i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: intro m' hn'm' bM' State Before: case neg.intro.intro.intro.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } ⊢ ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑(Basis.mkFinConsOfLe y yN bN' N'_le_N (_ : ∀ (c : R) (z : O), z ∈ N' → c • y + z = 0 → c = 0) (_ : ∀ (z : O), z ∈ N → ∃ c, z + c • y ∈ N')) i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: case neg.intro.intro.intro.refine'_2.refine'_1 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } ⊢ Basis (Fin (m' + 1)) R { x // x ∈ M } case neg.intro.intro.intro.refine'_2.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } ⊢ ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑(Basis.mkFinConsOfLe y yN bN' N'_le_N (_ : ∀ (c : R) (z : O), z ∈ N' → c • y + z = 0 → c = 0) (_ : ∀ (z : O), z ∈ N → ∃ c, z + c • y ∈ N')) i) = as' i • ↑(↑?neg.intro.intro.intro.refine'_2.refine'_1✝ (↑(Fin.castLE (_ : Nat.succ n' ≤ Nat.succ m')) i)) Tactic: refine' ⟨Nat.succ_le_succ hn'm', _, _⟩ State Before: case neg.intro.intro.intro.refine'_2.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } ⊢ ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑(Basis.mkFinConsOfLe y yN bN' N'_le_N (_ : ∀ (c : R) (z : O), z ∈ N' → c • y + z = 0 → c = 0) (_ : ∀ (z : O), z ∈ N → ∃ c, z + c • y ∈ N')) i) = as' i • ↑(↑(Basis.mkFinConsOfLe y' y'M bM' M'_le_M y'_ortho_M' (_ : ∀ (z : O), z ∈ M → ∃ c, z + c • y' ∈ M')) (↑(Fin.castLE (_ : Nat.succ n' ≤ Nat.succ m')) i)) State After: case neg.intro.intro.intro.refine'_2.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } as : Fin n' → R h : ∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i)) ⊢ ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑(Basis.mkFinConsOfLe y yN bN' N'_le_N (_ : ∀ (c : R) (z : O), z ∈ N' → c • y + z = 0 → c = 0) (_ : ∀ (z : O), z ∈ N → ∃ c, z + c • y ∈ N')) i) = as' i • ↑(↑(Basis.mkFinConsOfLe y' y'M bM' M'_le_M y'_ortho_M' (_ : ∀ (z : O), z ∈ M → ∃ c, z + c • y' ∈ M')) (↑(Fin.castLE (_ : Nat.succ n' ≤ Nat.succ m')) i)) Tactic: intro as h State Before: case neg.intro.intro.intro.refine'_2.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } as : Fin n' → R h : ∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i)) ⊢ ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑(Basis.mkFinConsOfLe y yN bN' N'_le_N (_ : ∀ (c : R) (z : O), z ∈ N' → c • y + z = 0 → c = 0) (_ : ∀ (z : O), z ∈ N → ∃ c, z + c • y ∈ N')) i) = as' i • ↑(↑(Basis.mkFinConsOfLe y' y'M bM' M'_le_M y'_ortho_M' (_ : ∀ (z : O), z ∈ M → ∃ c, z + c • y' ∈ M')) (↑(Fin.castLE (_ : Nat.succ n' ≤ Nat.succ m')) i)) State After: case neg.intro.intro.intro.refine'_2.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } as : Fin n' → R h : ∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i)) ⊢ ∀ (i : Fin (n' + 1)), ↑(↑(Basis.mkFinConsOfLe y yN bN' N'_le_N (_ : ∀ (c : R) (z : O), z ∈ N' → c • y + z = 0 → c = 0) (_ : ∀ (z : O), z ∈ N → ∃ c, z + c • y ∈ N')) i) = Fin.cons a as i • ↑(↑(Basis.mkFinConsOfLe y' y'M bM' M'_le_M y'_ortho_M' (_ : ∀ (z : O), z ∈ M → ∃ c, z + c • y' ∈ M')) (↑(Fin.castLE (_ : Nat.succ n' ≤ Nat.succ m')) i)) Tactic: refine' ⟨Fin.cons a as, _⟩ State Before: case neg.intro.intro.intro.refine'_2.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } as : Fin n' → R h : ∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i)) ⊢ ∀ (i : Fin (n' + 1)), ↑(↑(Basis.mkFinConsOfLe y yN bN' N'_le_N (_ : ∀ (c : R) (z : O), z ∈ N' → c • y + z = 0 → c = 0) (_ : ∀ (z : O), z ∈ N → ∃ c, z + c • y ∈ N')) i) = Fin.cons a as i • ↑(↑(Basis.mkFinConsOfLe y' y'M bM' M'_le_M y'_ortho_M' (_ : ∀ (z : O), z ∈ M → ∃ c, z + c • y' ∈ M')) (↑(Fin.castLE (_ : Nat.succ n' ≤ Nat.succ m')) i)) State After: case neg.intro.intro.intro.refine'_2.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } as : Fin n' → R h : ∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i)) i : Fin (n' + 1) ⊢ ↑(↑(Basis.mkFinConsOfLe y yN bN' N'_le_N (_ : ∀ (c : R) (z : O), z ∈ N' → c • y + z = 0 → c = 0) (_ : ∀ (z : O), z ∈ N → ∃ c, z + c • y ∈ N')) i) = Fin.cons a as i • ↑(↑(Basis.mkFinConsOfLe y' y'M bM' M'_le_M y'_ortho_M' (_ : ∀ (z : O), z ∈ M → ∃ c, z + c • y' ∈ M')) (↑(Fin.castLE (_ : Nat.succ n' ≤ Nat.succ m')) i)) Tactic: intro i State Before: case neg.intro.intro.intro.refine'_2.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } as : Fin n' → R h : ∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i)) i : Fin (n' + 1) ⊢ ↑(↑(Basis.mkFinConsOfLe y yN bN' N'_le_N (_ : ∀ (c : R) (z : O), z ∈ N' → c • y + z = 0 → c = 0) (_ : ∀ (z : O), z ∈ N → ∃ c, z + c • y ∈ N')) i) = Fin.cons a as i • ↑(↑(Basis.mkFinConsOfLe y' y'M bM' M'_le_M y'_ortho_M' (_ : ∀ (z : O), z ∈ M → ∃ c, z + c • y' ∈ M')) (↑(Fin.castLE (_ : Nat.succ n' ≤ Nat.succ m')) i)) State After: case neg.intro.intro.intro.refine'_2.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } as : Fin n' → R h : ∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i)) i : Fin (n' + 1) ⊢ ↑(Fin.cons { val := y, property := yN } (↑(ofLe N'_le_N) ∘ ↑bN') i) = Fin.cons a as i • ↑(Fin.cons { val := y', property := y'M } (↑(ofLe M'_le_M) ∘ ↑bM') (↑(Fin.castLE (_ : Nat.succ n' ≤ Nat.succ m')) i)) Tactic: rw [Basis.coe_mkFinConsOfLe, Basis.coe_mkFinConsOfLe] State Before: case neg.intro.intro.intro.refine'_2.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } as : Fin n' → R h : ∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i)) i : Fin (n' + 1) ⊢ ↑(Fin.cons { val := y, property := yN } (↑(ofLe N'_le_N) ∘ ↑bN') i) = Fin.cons a as i • ↑(Fin.cons { val := y', property := y'M } (↑(ofLe M'_le_M) ∘ ↑bM') (↑(Fin.castLE (_ : Nat.succ n' ≤ Nat.succ m')) i)) State After: case neg.intro.intro.intro.refine'_2.refine'_2.refine'_1 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } as : Fin n' → R h : ∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i)) i : Fin (n' + 1) ⊢ ↑(Fin.cons { val := y, property := yN } (↑(ofLe N'_le_N) ∘ ↑bN') 0) = Fin.cons a as 0 • ↑(Fin.cons { val := y', property := y'M } (↑(ofLe M'_le_M) ∘ ↑bM') (↑(Fin.castLE (_ : Nat.succ n' ≤ Nat.succ m')) 0)) case neg.intro.intro.intro.refine'_2.refine'_2.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } as : Fin n' → R h : ∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i)) i✝ : Fin (n' + 1) i : Fin n' ⊢ ↑(Fin.cons { val := y, property := yN } (↑(ofLe N'_le_N) ∘ ↑bN') (Fin.succ i)) = Fin.cons a as (Fin.succ i) • ↑(Fin.cons { val := y', property := y'M } (↑(ofLe M'_le_M) ∘ ↑bM') (↑(Fin.castLE (_ : Nat.succ n' ≤ Nat.succ m')) (Fin.succ i))) Tactic: refine' Fin.cases _ (fun i ↦ _) i State Before: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M ⊢ ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N State After: case intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M P : Submodule R R P_eq : P ∈ range fun ψ => LinearMap.submoduleImage ψ N P_max : ∀ (I : Submodule R R), (I ∈ range fun ψ => LinearMap.submoduleImage ψ N) → ¬P < I ⊢ ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N Tactic: obtain ⟨P, P_eq, P_max⟩ := set_has_maximal_iff_noetherian.mpr (inferInstance : IsNoetherian R R) _ (show (Set.range fun ψ : M →ₗ[R] R ↦ ψ.submoduleImage N).Nonempty from ⟨_, Set.mem_range.mpr ⟨0, rfl⟩⟩) State Before: case intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M P : Submodule R R P_eq : P ∈ range fun ψ => LinearMap.submoduleImage ψ N P_max : ∀ (I : Submodule R R), (I ∈ range fun ψ => LinearMap.submoduleImage ψ N) → ¬P < I ⊢ ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N State After: case intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M ϕ : { x // x ∈ M } →ₗ[R] R P_eq : LinearMap.submoduleImage ϕ N ∈ range fun ψ => LinearMap.submoduleImage ψ N P_max : ∀ (I : Submodule R R), (I ∈ range fun ψ => LinearMap.submoduleImage ψ N) → ¬LinearMap.submoduleImage ϕ N < I ⊢ ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N Tactic: obtain ⟨ϕ, rfl⟩ := Set.mem_range.mp P_eq State Before: case intro.intro.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M ϕ : { x // x ∈ M } →ₗ[R] R P_eq : LinearMap.submoduleImage ϕ N ∈ range fun ψ => LinearMap.submoduleImage ψ N P_max : ∀ (I : Submodule R R), (I ∈ range fun ψ => LinearMap.submoduleImage ψ N) → ¬LinearMap.submoduleImage ϕ N < I ⊢ ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N State After: no goals Tactic: exact ⟨ϕ, fun ψ hψ ↦ P_max _ ⟨_, rfl⟩ hψ⟩ State Before: case pos ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : a = 0 ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: case pos ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this✝ : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this✝ ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this✝) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : a = 0 this : N = ⊥ ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) Tactic: have := eq_bot_of_generator_maximal_submoduleImage_eq_zero b'M N_le_M ϕ_max a_zero State Before: case pos ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this✝ : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this✝ ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this✝) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : a = 0 this : N = ⊥ ⊢ ∃ y, y ∈ M ∧ ∃ a x M', M' ≤ M ∧ ∃ N', N' ≤ N ∧ ∃ _N'_le_M' _y_ortho_M' _ay_ortho_N', ∀ (n' : ℕ) (bN' : Basis (Fin n') R { x // x ∈ N' }), ∃ bN, ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis (Fin m') R { x // x ∈ M' }), ∃ hnm bM, ∀ (as : Fin n' → R), (∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i))) → ∃ as', ∀ (i : Fin (n' + 1)), ↑(↑bN i) = as' i • ↑(↑bM (↑(Fin.castLE hnm) i)) State After: no goals Tactic: contradiction State Before: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M ⊢ y' = ↑(Submodule.subtype M) (∑ i : ι, c i • ↑b'M i) State After: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M ⊢ ∑ x : ι, ↑(c x • ↑b'M x) = ∑ x : ι, c x • ↑(Submodule.subtype M) (↑b'M x) Tactic: simp only [LinearMap.map_sum, LinearMap.map_smul] State Before: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M ⊢ ∑ x : ι, ↑(c x • ↑b'M x) = ∑ x : ι, c x • ↑(Submodule.subtype M) (↑b'M x) State After: no goals Tactic: rfl State Before: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i ⊢ a • y' = y State After: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i ⊢ a • { val := y', property := y'M } = { val := y, property := (_ : y ∈ M) } Tactic: refine Subtype.mk_eq_mk.mp (show (a • ⟨y', y'M⟩ : M) = ⟨y, N_le_M yN⟩ from ?_) State Before: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i ⊢ a • { val := y', property := y'M } = { val := y, property := (_ : y ∈ M) } State After: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i ⊢ ∑ x : ι, a • c x • ↑b'M x = ∑ i : ι, ↑(↑b'M.repr { val := y, property := (_ : y ∈ M) }) i • ↑b'M i Tactic: rw [← b'M.sum_repr ⟨y, N_le_M yN⟩, mk_y', Finset.smul_sum] State Before: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i ⊢ ∑ x : ι, a • c x • ↑b'M x = ∑ i : ι, ↑(↑b'M.repr { val := y, property := (_ : y ∈ M) }) i • ↑b'M i State After: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i i : ι x✝ : i ∈ Finset.univ ⊢ a • c i • ↑b'M i = ↑(↑b'M.repr { val := y, property := (_ : y ∈ M) }) i • ↑b'M i Tactic: refine' Finset.sum_congr rfl fun i _ ↦ _ State Before: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i i : ι x✝ : i ∈ Finset.univ ⊢ a • c i • ↑b'M i = ↑(↑b'M.repr { val := y, property := (_ : y ∈ M) }) i • ↑b'M i State After: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i i : ι x✝ : i ∈ Finset.univ ⊢ ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } • ↑b'M i = ↑(↑b'M.repr { val := y, property := (_ : y ∈ M) }) i • ↑b'M i Tactic: rw [← mul_smul, ← hc] State Before: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i i : ι x✝ : i ∈ Finset.univ ⊢ ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } • ↑b'M i = ↑(↑b'M.repr { val := y, property := (_ : y ∈ M) }) i • ↑b'M i State After: no goals Tactic: rfl State Before: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ⊢ ↑ϕ { val := a • y', property := (_ : a • ↑{ val := y', property := y'M } ∈ M) } = ↑ϕ { val := y, property := (_ : y ∈ M) } State After: no goals Tactic: simp only [a_smul_y'] State Before: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ⊢ ↑ϕ { val := y', property := y'M } ≠ 0 State After: no goals Tactic: simpa only [ϕy'_eq] using one_ne_zero State Before: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M ⊢ N' ≤ M' State After: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M x : O hx : x ∈ N' ⊢ x ∈ M' Tactic: intro x hx State Before: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M x : O hx : x ∈ N' ⊢ x ∈ M' State After: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M x : O hx : ∃ y, ↑(LinearMap.comp (Exists.choose this) (ofLe N_le_M)) y = 0 ∧ ↑(Submodule.subtype N) y = x ⊢ ∃ y, ↑(Exists.choose this) y = 0 ∧ ↑(Submodule.subtype M) y = x Tactic: simp only [mem_map, LinearMap.mem_ker] at hx⊢ State Before: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M x : O hx : ∃ y, ↑(LinearMap.comp (Exists.choose this) (ofLe N_le_M)) y = 0 ∧ ↑(Submodule.subtype N) y = x ⊢ ∃ y, ↑(Exists.choose this) y = 0 ∧ ↑(Submodule.subtype M) y = x State After: case intro.mk.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M x : O xN : x ∈ N hx : ↑(LinearMap.comp (Exists.choose this) (ofLe N_le_M)) { val := x, property := xN } = 0 ⊢ ∃ y, ↑(Exists.choose this) y = 0 ∧ ↑(Submodule.subtype M) y = ↑(Submodule.subtype N) { val := x, property := xN } Tactic: obtain ⟨⟨x, xN⟩, hx, rfl⟩ := hx State Before: case intro.mk.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M x : O xN : x ∈ N hx : ↑(LinearMap.comp (Exists.choose this) (ofLe N_le_M)) { val := x, property := xN } = 0 ⊢ ∃ y, ↑(Exists.choose this) y = 0 ∧ ↑(Submodule.subtype M) y = ↑(Submodule.subtype N) { val := x, property := xN } State After: no goals Tactic: exact ⟨⟨x, N_le_M xN⟩, hx, rfl⟩ State Before: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N ⊢ ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 State After: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c✝ : ι → R hc✝ : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c✝ i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c✝ i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c✝ i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N c : R x : O xM' : x ∈ M' hc : c • y' + x = 0 ⊢ c = 0 Tactic: intro c x xM' hc State Before: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c✝ : ι → R hc✝ : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c✝ i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c✝ i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c✝ i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N c : R x : O xM' : x ∈ M' hc : c • y' + x = 0 ⊢ c = 0 State After: case intro.mk.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c✝ : ι → R hc✝ : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c✝ i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c✝ i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c✝ i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N c : R x : O xM : x ∈ M hx' : { val := x, property := xM } ∈ LinearMap.ker ϕ xM' : ↑(Submodule.subtype M) { val := x, property := xM } ∈ M' hc : c • y' + ↑(Submodule.subtype M) { val := x, property := xM } = 0 ⊢ c = 0 Tactic: obtain ⟨⟨x, xM⟩, hx', rfl⟩ := Submodule.mem_map.mp xM' State Before: case intro.mk.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c✝ : ι → R hc✝ : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c✝ i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c✝ i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c✝ i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N c : R x : O xM : x ∈ M hx' : { val := x, property := xM } ∈ LinearMap.ker ϕ xM' : ↑(Submodule.subtype M) { val := x, property := xM } ∈ M' hc : c • y' + ↑(Submodule.subtype M) { val := x, property := xM } = 0 ⊢ c = 0 State After: case intro.mk.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c✝ : ι → R hc✝ : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c✝ i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c✝ i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c✝ i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N c : R x : O xM : x ∈ M hx' : ↑ϕ { val := x, property := xM } = 0 xM' : ↑(Submodule.subtype M) { val := x, property := xM } ∈ M' hc : c • y' + ↑(Submodule.subtype M) { val := x, property := xM } = 0 ⊢ c = 0 Tactic: rw [LinearMap.mem_ker] at hx' State Before: case intro.mk.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c✝ : ι → R hc✝ : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c✝ i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c✝ i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c✝ i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N c : R x : O xM : x ∈ M hx' : ↑ϕ { val := x, property := xM } = 0 xM' : ↑(Submodule.subtype M) { val := x, property := xM } ∈ M' hc : c • y' + ↑(Submodule.subtype M) { val := x, property := xM } = 0 hc' : c • { val := y', property := y'M } + { val := x, property := xM } = 0 ⊢ c = 0 State After: no goals Tactic: simpa only [LinearMap.map_add, LinearMap.map_zero, LinearMap.map_smul, smul_eq_mul, add_zero, mul_eq_zero, ϕy'_ne_zero, hx', or_false_iff] using congr_arg ϕ hc' State Before: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ⊢ ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 State After: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c✝ : ι → R hc✝ : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c✝ i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c✝ i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c✝ i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 c : R z : O zN' : z ∈ N' hc : c • a • y' + z = 0 ⊢ c = 0 Tactic: intro c z zN' hc State Before: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c✝ : ι → R hc✝ : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c✝ i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c✝ i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c✝ i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 c : R z : O zN' : z ∈ N' hc : c • a • y' + z = 0 ⊢ c = 0 State After: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c✝ : ι → R hc✝ : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c✝ i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c✝ i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c✝ i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 c : R z : O zN' : z ∈ N' hc : c • a • y' + z = 0 ⊢ (a * c) • y' + z = 0 Tactic: refine' (mul_eq_zero.mp (y'_ortho_M' (a * c) z (N'_le_M' zN') _)).resolve_left a_zero State Before: ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c✝ : ι → R hc✝ : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c✝ i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c✝ i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c✝ i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 c : R z : O zN' : z ∈ N' hc : c • a • y' + z = 0 ⊢ (a * c) • y' + z = 0 State After: no goals Tactic: rw [mul_comm, mul_smul, hc] State Before: case neg.intro.intro.intro.refine'_1 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } ⊢ Basis (Fin (n' + 1)) R { x // x ∈ N } State After: case neg.intro.intro.intro.refine'_1.refine'_1 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } ⊢ ∀ (c : R) (x : O), x ∈ N' → c • y + x = 0 → c = 0 case neg.intro.intro.intro.refine'_1.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } ⊢ ∀ (z : O), z ∈ N → ∃ c, z + c • y ∈ N' Tactic: refine' Basis.mkFinConsOfLe y yN bN' N'_le_N _ _ State Before: case neg.intro.intro.intro.refine'_1.refine'_1 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } ⊢ ∀ (c : R) (x : O), x ∈ N' → c • y + x = 0 → c = 0 State After: case neg.intro.intro.intro.refine'_1.refine'_1 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c✝ : ι → R hc✝ : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c✝ i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c✝ i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c✝ i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } c : R z : O zN' : z ∈ N' hc : c • y + z = 0 ⊢ c = 0 Tactic: intro c z zN' hc State Before: case neg.intro.intro.intro.refine'_1.refine'_1 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c✝ : ι → R hc✝ : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c✝ i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c✝ i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c✝ i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } c : R z : O zN' : z ∈ N' hc : c • y + z = 0 ⊢ c = 0 State After: case neg.intro.intro.intro.refine'_1.refine'_1 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c✝ : ι → R hc✝ : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c✝ i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c✝ i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c✝ i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } c : R z : O zN' : z ∈ N' hc : c • y + z = 0 ⊢ c • a • y' + z = 0 Tactic: refine' ay'_ortho_N' c z zN' _ State Before: case neg.intro.intro.intro.refine'_1.refine'_1 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c✝ : ι → R hc✝ : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c✝ i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c✝ i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c✝ i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } c : R z : O zN' : z ∈ N' hc : c • y + z = 0 ⊢ c • a • y' + z = 0 State After: no goals Tactic: rwa [← a_smul_y'] at hc State Before: case neg.intro.intro.intro.refine'_1.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } ⊢ ∀ (z : O), z ∈ N → ∃ c, z + c • y ∈ N' State After: case neg.intro.intro.intro.refine'_1.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } z : O zN : z ∈ N ⊢ ∃ c, z + c • y ∈ N' Tactic: intro z zN State Before: case neg.intro.intro.intro.refine'_1.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } z : O zN : z ∈ N ⊢ ∃ c, z + c • y ∈ N' State After: case neg.intro.intro.intro.refine'_1.refine'_2.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b✝ : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } z : O zN : z ∈ N b : R hb : ↑ϕ { val := z, property := (_ : z ∈ M) } = generator (LinearMap.submoduleImage ϕ N) * b ⊢ ∃ c, z + c • y ∈ N' Tactic: obtain ⟨b, hb⟩ : _ ∣ ϕ ⟨z, N_le_M zN⟩ := generator_submoduleImage_dvd_of_mem N_le_M ϕ zN State Before: case neg.intro.intro.intro.refine'_1.refine'_2.intro ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b✝ : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } z : O zN : z ∈ N b : R hb : ↑ϕ { val := z, property := (_ : z ∈ M) } = generator (LinearMap.submoduleImage ϕ N) * b ⊢ ∃ c, z + c • y ∈ N' State After: case neg.intro.intro.intro.refine'_1.refine'_2.intro.refine'_1 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b✝ : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } z : O zN : z ∈ N b : R hb : ↑ϕ { val := z, property := (_ : z ∈ M) } = generator (LinearMap.submoduleImage ϕ N) * b ⊢ { val := z - b • y, property := (_ : z - b • y ∈ N) } ∈ LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M)) case neg.intro.intro.intro.refine'_1.refine'_2.intro.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b✝ : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } z : O zN : z ∈ N b : R hb : ↑ϕ { val := z, property := (_ : z ∈ M) } = generator (LinearMap.submoduleImage ϕ N) * b ⊢ ↑(Submodule.subtype N) { val := z - b • y, property := (_ : z - b • y ∈ N) } = z + -b • y Tactic: refine' ⟨-b, Submodule.mem_map.mpr ⟨⟨_, N.sub_mem zN (N.smul_mem b yN)⟩, _, _⟩⟩ State Before: case neg.intro.intro.intro.refine'_1.refine'_2.intro.refine'_1 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b✝ : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } z : O zN : z ∈ N b : R hb : ↑ϕ { val := z, property := (_ : z ∈ M) } = generator (LinearMap.submoduleImage ϕ N) * b ⊢ { val := z - b • y, property := (_ : z - b • y ∈ N) } ∈ LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M)) State After: case neg.intro.intro.intro.refine'_1.refine'_2.intro.refine'_1 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b✝ : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } z : O zN : z ∈ N b : R hb : ↑ϕ { val := z, property := (_ : z ∈ M) } = generator (LinearMap.submoduleImage ϕ N) * b ⊢ ↑ϕ ({ val := z, property := (_ : z ∈ M) } - b • { val := y, property := (_ : y ∈ M) }) = 0 Tactic: refine' LinearMap.mem_ker.mpr (show ϕ (⟨z, N_le_M zN⟩ - b • ⟨y, N_le_M yN⟩) = 0 from _) State Before: case neg.intro.intro.intro.refine'_1.refine'_2.intro.refine'_1 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b✝ : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } z : O zN : z ∈ N b : R hb : ↑ϕ { val := z, property := (_ : z ∈ M) } = generator (LinearMap.submoduleImage ϕ N) * b ⊢ ↑ϕ ({ val := z, property := (_ : z ∈ M) } - b • { val := y, property := (_ : y ∈ M) }) = 0 State After: no goals Tactic: rw [LinearMap.map_sub, LinearMap.map_smul, hb, ϕy_eq, smul_eq_mul, mul_comm, sub_self] State Before: case neg.intro.intro.intro.refine'_1.refine'_2.intro.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b✝ : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } z : O zN : z ∈ N b : R hb : ↑ϕ { val := z, property := (_ : z ∈ M) } = generator (LinearMap.submoduleImage ϕ N) * b ⊢ ↑(Submodule.subtype N) { val := z - b • y, property := (_ : z - b • y ∈ N) } = z + -b • y State After: no goals Tactic: simp only [sub_eq_add_neg, neg_smul, coeSubtype] State Before: case neg.intro.intro.intro.refine'_2.refine'_1 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } ⊢ Basis (Fin (m' + 1)) R { x // x ∈ M } State After: case neg.intro.intro.intro.refine'_2.refine'_1 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } ⊢ ∀ (z : O), z ∈ M → ∃ c, z + c • y' ∈ M' Tactic: refine' Basis.mkFinConsOfLe y' y'M bM' M'_le_M y'_ortho_M' _ State Before: case neg.intro.intro.intro.refine'_2.refine'_1 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } ⊢ ∀ (z : O), z ∈ M → ∃ c, z + c • y' ∈ M' State After: case neg.intro.intro.intro.refine'_2.refine'_1 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } z : O zM : z ∈ M ⊢ ∃ c, z + c • y' ∈ M' Tactic: intro z zM State Before: case neg.intro.intro.intro.refine'_2.refine'_1 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } z : O zM : z ∈ M ⊢ ∃ c, z + c • y' ∈ M' State After: case neg.intro.intro.intro.refine'_2.refine'_1.refine'_1 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } z : O zM : z ∈ M ⊢ ↑ϕ ({ val := z, property := zM } - ↑ϕ { val := z, property := zM } • { val := y', property := y'M }) = 0 case neg.intro.intro.intro.refine'_2.refine'_1.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } z : O zM : z ∈ M ⊢ ↑(Submodule.subtype M) ({ val := z, property := zM } - ↑ϕ { val := z, property := zM } • { val := y', property := y'M }) = z + -↑ϕ { val := z, property := zM } • y' Tactic: refine' ⟨-ϕ ⟨z, zM⟩, ⟨⟨z, zM⟩ - ϕ ⟨z, zM⟩ • ⟨y', y'M⟩, LinearMap.mem_ker.mpr _, _⟩⟩ State Before: case neg.intro.intro.intro.refine'_2.refine'_1.refine'_1 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } z : O zM : z ∈ M ⊢ ↑ϕ ({ val := z, property := zM } - ↑ϕ { val := z, property := zM } • { val := y', property := y'M }) = 0 State After: no goals Tactic: rw [LinearMap.map_sub, LinearMap.map_smul, ϕy'_eq, smul_eq_mul, mul_one, sub_self] State Before: case neg.intro.intro.intro.refine'_2.refine'_1.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } z : O zM : z ∈ M ⊢ ↑(Submodule.subtype M) ({ val := z, property := zM } - ↑ϕ { val := z, property := zM } • { val := y', property := y'M }) = z + -↑ϕ { val := z, property := zM } • y' State After: case neg.intro.intro.intro.refine'_2.refine'_1.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } z : O zM : z ∈ M ⊢ ↑(Submodule.subtype M) { val := z, property := zM } + -(↑ϕ { val := z, property := zM } • ↑(Submodule.subtype M) { val := y', property := y'M }) = z + -(↑ϕ { val := z, property := zM } • y') Tactic: rw [LinearMap.map_sub, LinearMap.map_smul, sub_eq_add_neg, neg_smul] State Before: case neg.intro.intro.intro.refine'_2.refine'_1.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } z : O zM : z ∈ M ⊢ ↑(Submodule.subtype M) { val := z, property := zM } + -(↑ϕ { val := z, property := zM } • ↑(Submodule.subtype M) { val := y', property := y'M }) = z + -(↑ϕ { val := z, property := zM } • y') State After: no goals Tactic: rfl State Before: case neg.intro.intro.intro.refine'_2.refine'_2.refine'_1 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } as : Fin n' → R h : ∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i)) i : Fin (n' + 1) ⊢ ↑(Fin.cons { val := y, property := yN } (↑(ofLe N'_le_N) ∘ ↑bN') 0) = Fin.cons a as 0 • ↑(Fin.cons { val := y', property := y'M } (↑(ofLe M'_le_M) ∘ ↑bM') (↑(Fin.castLE (_ : Nat.succ n' ≤ Nat.succ m')) 0)) State After: case neg.intro.intro.intro.refine'_2.refine'_2.refine'_1 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } as : Fin n' → R h : ∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i)) i : Fin (n' + 1) ⊢ y = generator (LinearMap.submoduleImage (Exists.choose this) N) • ∑ x : ι, ↑(c x • ↑b'M x) Tactic: simp only [Fin.cons_zero, Fin.castLE_zero] State Before: case neg.intro.intro.intro.refine'_2.refine'_2.refine'_1 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } as : Fin n' → R h : ∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i)) i : Fin (n' + 1) ⊢ y = generator (LinearMap.submoduleImage (Exists.choose this) N) • ∑ x : ι, ↑(c x • ↑b'M x) State After: no goals Tactic: exact a_smul_y'.symm State Before: case neg.intro.intro.intro.refine'_2.refine'_2.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } as : Fin n' → R h : ∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i)) i✝ : Fin (n' + 1) i : Fin n' ⊢ ↑(Fin.cons { val := y, property := yN } (↑(ofLe N'_le_N) ∘ ↑bN') (Fin.succ i)) = Fin.cons a as (Fin.succ i) • ↑(Fin.cons { val := y', property := y'M } (↑(ofLe M'_le_M) ∘ ↑bM') (↑(Fin.castLE (_ : Nat.succ n' ≤ Nat.succ m')) (Fin.succ i))) State After: case neg.intro.intro.intro.refine'_2.refine'_2.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } as : Fin n' → R h : ∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i)) i✝ : Fin (n' + 1) i : Fin n' ⊢ ↑(Fin.cons { val := y, property := yN } (↑(ofLe N'_le_N) ∘ ↑bN') (Fin.succ i)) = Fin.cons a as (Fin.succ i) • ↑(Fin.cons { val := y', property := y'M } (↑(ofLe M'_le_M) ∘ ↑bM') (Fin.succ (↑(Fin.castLE (_ : n' ≤ m')) i))) Tactic: rw [Fin.castLE_succ] State Before: case neg.intro.intro.intro.refine'_2.refine'_2.refine'_2 ι : Type u_1 R : Type u_3 inst✝⁷ : CommRing R inst✝⁶ : IsDomain R inst✝⁵ : IsPrincipalIdealRing R M✝ : Type ?u.43078 inst✝⁴ : AddCommGroup M✝ inst✝³ : Module R M✝ b : ι → M✝ inst✝² : Finite ι O : Type u_2 inst✝¹ : AddCommGroup O inst✝ : Module R O M N : Submodule R O b'M : Basis ι R { x // x ∈ M } N_bot : N ≠ ⊥ N_le_M : N ≤ M this : ∃ ϕ, ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage ϕ N < LinearMap.submoduleImage ψ N ϕ : { x // x ∈ M } →ₗ[R] R := Exists.choose this ϕ_max : ∀ (ψ : { x // x ∈ M } →ₗ[R] R), ¬LinearMap.submoduleImage (Exists.choose this) N < LinearMap.submoduleImage ψ N a : R := generator (LinearMap.submoduleImage ϕ N) a_mem : a ∈ LinearMap.submoduleImage ϕ N a_zero : ¬a = 0 y : O yN : y ∈ N ϕy_eq : ↑ϕ { val := y, property := (_ : y ∈ M) } = a _ϕy_ne_zero : ↑ϕ { val := y, property := (_ : y ∈ M) } ≠ 0 c : ι → R hc : ∀ (i : ι), ↑(Basis.coord b'M i) { val := y, property := (_ : y ∈ M) } = a * c i val✝ : Fintype ι y' : O := ∑ i : ι, ↑(c i • ↑b'M i) y'M : y' ∈ M mk_y' : { val := y', property := y'M } = ∑ i : ι, c i • ↑b'M i a_smul_y' : a • y' = y ϕy'_eq : ↑ϕ { val := y', property := y'M } = 1 ϕy'_ne_zero : ↑ϕ { val := y', property := y'M } ≠ 0 M' : Submodule R O := map (Submodule.subtype M) (LinearMap.ker ϕ) N' : Submodule R O := map (Submodule.subtype N) (LinearMap.ker (LinearMap.comp ϕ (ofLe N_le_M))) M'_le_M : M' ≤ M N'_le_M' : N' ≤ M' N'_le_N : N' ≤ N y'_ortho_M' : ∀ (c : R) (z : O), z ∈ M' → c • y' + z = 0 → c = 0 ay'_ortho_N' : ∀ (c : R) (z : O), z ∈ N' → c • a • y' + z = 0 → c = 0 n' : ℕ bN' : Basis (Fin n') R { x // x ∈ N' } m' : ℕ hn'm' : n' ≤ m' bM' : Basis (Fin m') R { x // x ∈ M' } as : Fin n' → R h : ∀ (i : Fin n'), ↑(↑bN' i) = as i • ↑(↑bM' (↑(Fin.castLE hn'm') i)) i✝ : Fin (n' + 1) i : Fin n' ⊢ ↑(Fin.cons { val := y, property := yN } (↑(ofLe N'_le_N) ∘ ↑bN') (Fin.succ i)) = Fin.cons a as (Fin.succ i) • ↑(Fin.cons { val := y', property := y'M } (↑(ofLe M'_le_M) ∘ ↑bM') (Fin.succ (↑(Fin.castLE (_ : n' ≤ m')) i))) State After: no goals Tactic: simp only [Fin.cons_succ, Function.comp_apply, coe_ofLe, map_coe, coeSubtype, h i]
text\<open> 29 October 2021: Exercise for Homework Assignment 08 in CS 511 \<close> text\<open> Your task to remove the invocations of the pre-defined method 'blast' by an equivalent sequence of 'apply' steps \<close> theory HW08 imports Main begin text\<open> 'blast' is invoked three times, once in the proof of each of lemmas K1, L1, and M1 below \<close> (* lemma K1 is the same in Exercise 2.3.9 (k), page 161, in [LCS] *) lemma K1 : "\<forall> x. (P x \<and> Q x) \<Longrightarrow> (\<forall> x. P x) \<and> (\<forall> x. Q x)" apply (rule conjI) apply (rule allI) apply (erule allE) apply (erule conjE) apply assumption apply (rule allI) apply (erule allE) apply (erule conjE) apply assumption done (* lemma L1 is the same in Exercise 2.3.9 (l), page 161, in [LCS] *) lemma L1 : "(\<forall> x. P x) \<or> (\<forall> x. Q x) \<Longrightarrow> \<forall> x. (P x \<or> Q x)" apply (rule allI) apply (erule disjE) apply (rule disjI1) apply (erule allE) apply assumption apply (rule disjI2) apply (erule allE) apply assumption done (* lemma M1 is the same in Exercise 2.3.9 (m), page 161, in [LCS] *) lemma M1 : "\<exists> x. (P x \<and> Q x) \<Longrightarrow> (\<exists> x. P x) \<and> (\<exists> x. Q x)" apply (erule exE) apply (rule conjI) apply (rule exI) apply (erule conjE) apply assumption apply (erule conjE) apply (rule exI) apply assumption done end
State Before: α : Type u β : Type v γ : Type w R : α → β → Prop C : Computation α → Computation β → Prop b : β ca : Computation α ⊢ LiftRelAux R C (destruct ca) (Sum.inl b) ↔ ∃ a, a ∈ ca ∧ R a b State After: no goals Tactic: rw [← LiftRelAux.swap, LiftRelAux.ret_left]
State Before: P Q : Prop ⊢ ¬Xor' P Q ↔ (P ↔ Q) State After: no goals Tactic: simp only [not_and, Xor', not_or, not_not, ← iff_iff_implies_and_implies]
lemma setdist_empty1 [simp]: "setdist {} t = 0"
import data.mv_polynomial import data.mv_polynomial.comm_ring import Rings.ToMathlib.list import Rings.ToMathlib.finset namespace mv_polynomial lemma support_le_total_degree {A σ : Type*} [comm_ring A] {p : mv_polynomial σ A} (x : σ) (f : σ →₀ ℕ) (hf : f ∈ p.support) : f x ≤ mv_polynomial.total_degree p := begin apply le_trans _ (finset.le_sup hf), simp only [finsupp.sum], apply finsupp.le_sum, end lemma total_degree_sum {A : Type*} {ι : Type*} {σ} [comm_semiring A] (s : finset ι) [decidable_eq ι] (ps : ι → mv_polynomial σ A) : (finset.sum s ps).total_degree ≤ finset.sup s (mv_polynomial.total_degree ∘ ps) := finset.induction_on s (zero_le _) (λ a s has hind, by rw finset.sum_insert has; exact le_trans (mv_polynomial.total_degree_add _ _) ( by rw [max_le_iff, finset.sup_insert]; exact ⟨ le_sup_iff.mpr $ or.inl (le_of_eq rfl) , le_sup_iff.mpr $ or.inr hind ⟩)) -- lemma total_degree_monomial -- {A : Type*} [comm_semiring A] [decidable_eq A] -- {σ : Type*} (f : σ →₀ ℕ) (a : A) : -- (mv_polynomial.monomial f a).total_degree -- = -- ite (a = 0) ⊥ (f.sum (λ _ n, n)) := -- dite (a = 0) -- (λ h, by rw [mv_polynomial.total_degree, mv_polynomial.support_monomial, -- if_pos h, if_pos h, finset.sup_empty]) -- (λ h, by rw [mv_polynomial.total_degree, mv_polynomial.support_monomial, -- if_neg h, if_neg h, finset.sup_singleton]) noncomputable def finsupp_coeff_add_zero_hom (A : Type*) [comm_semiring A] {σ} (f : σ →₀ ℕ) : add_zero_hom (mv_polynomial σ A) A := ⟨ (λ p, mv_polynomial.coeff f p) , rfl , λ a b, rfl ⟩ lemma finsupp_coeff_sumr {A : Type*} [comm_semiring A] {σ} (f : σ →₀ ℕ) (ps : list (mv_polynomial σ A)) : mv_polynomial.coeff f ps.sumr = list.sumr (list.map (λ p : mv_polynomial σ A, mv_polynomial.coeff f p) ps) := list.add_zero_hom_sumr (mv_polynomial.finsupp_coeff_add_zero_hom A f) ps lemma eval_mem {K : Type*} [comm_semiring K] {σ : Type*} [decidable_eq K] (p : mv_polynomial σ K) (s : subsemiring K) (hs : ∀ i, p.coeff i ∈ s) (v : σ → K) (hv : ∀ i, v i ∈ s) : mv_polynomial.eval v p ∈ s := begin classical, revert hs, refine mv_polynomial.induction_on''' p _ _, { intros a hs, simpa using hs 0 }, { intros a b f ha hb0 ih hs, rw [map_add], refine subsemiring.add_mem _ _ _, { rw [eval_monomial], refine subsemiring.mul_mem _ _ _, { have := hs a, rwa [coeff_add, coeff_monomial, if_pos rfl, not_mem_support_iff.1 ha, add_zero] at this }, { refine subsemiring.prod_mem _ (λ i hi, _), refine subsemiring.pow_mem _ _ _, exact hv _ } }, { refine ih (λ i, _), have := hs i, rw [coeff_add, coeff_monomial] at this, split_ifs at this with h h, { subst h, rw [not_mem_support_iff.1 ha], exact subsemiring.zero_mem _ }, { rwa zero_add at this } } } end -- variables -- {σ S₁ R : Type*} -- [comm_semiring R] [comm_semiring S₁] -- {p q : mv_polynomial σ R} -- lemma sum_support_eq_sumr {n : ℕ} (p : mv_polynomial (fin n) R) {as : (fin n → ℕ) → R} : -- (p).support.sum -- (λ f, as f) = -- (list.mapr as -- -- (λ (f : fin n → ℕ), -- -- (ys.append (xs.append (poly_map_data.coeffs_dvector' d ps))).nth -- -- (list.index_of' f (n_var_monom_of_deg_le_d_finset n d).to_list + -- -- (↑i * (n_var_monom_of_deg_le_d_finset n d).to_list.length + n + n)) -- -- _ * -- -- n.non_comm_prod -- -- (λ (i : fin n), -- -- (ys.append (xs.append (poly_map_data.coeffs_dvector' d ps))).nth (↑i + 0) inj_formula_aux3 ^ f i)) -- (n_var_monom_of_deg_le n d)).sumr end mv_polynomial
------------------------------------------------------------------------ -- Propositional equality, with some extra bells and whistles -- definable in Cubical Agda ------------------------------------------------------------------------ {-# OPTIONS --erased-cubical --safe #-} module Equality.Propositional.Cubical where import Equality.Path as P open import Equality.Propositional open Equality.Propositional public using (refl; equivalence-relation⁺) -- A family of implementations of P.Equality-with-paths. private equality-with-paths′ : ∀ {a p} → P.Equality-with-paths a p equivalence-relation⁺ equality-with-paths′ = P.Equality-with-J⇒Equality-with-paths equality-with-J -- A family of implementations of P.Equality-with-paths. -- -- The definition has been expanded in order to ensure that it does -- not reduce (unless a projection is applied to it). equality-with-paths : ∀ {a p} → P.Equality-with-paths a p equivalence-relation⁺ equality-with-paths .P.Equality-with-paths.equality-with-J = equality-with-paths′ .P.Equality-with-paths.equality-with-J equality-with-paths {p = p} .P.Equality-with-paths.to-path = equality-with-paths′ {p = p} .P.Equality-with-paths.to-path equality-with-paths {p = p} .P.Equality-with-paths.from-path = equality-with-paths′ {p = p} .P.Equality-with-paths.from-path equality-with-paths {p = p} .P.Equality-with-paths.to-path∘from-path = equality-with-paths′ {p = p} .P.Equality-with-paths.to-path∘from-path equality-with-paths {p = p} .P.Equality-with-paths.from-path∘to-path = equality-with-paths′ {p = p} .P.Equality-with-paths.from-path∘to-path equality-with-paths {p = p} .P.Equality-with-paths.to-path-refl = equality-with-paths′ {p = p} .P.Equality-with-paths.to-path-refl equality-with-paths {p = p} .P.Equality-with-paths.from-path-refl = equality-with-paths′ {p = p} .P.Equality-with-paths.from-path-refl open P.Derived-definitions-and-properties equality-with-paths public hiding (refl) open import Equality.Path.Isomorphisms equality-with-paths public
lemma primes_characterization'_int [rule_format]: "finite {p. p \<ge> 0 \<and> 0 < f (p::int)} \<Longrightarrow> \<forall>p. 0 < f p \<longrightarrow> prime p \<Longrightarrow> prime_factors (\<Prod>p | p \<ge> 0 \<and> 0 < f p. p ^ f p) = {p. p \<ge> 0 \<and> 0 < f p}"
lemma continuous_on_sum [continuous_intros]: fixes f :: "'a \<Rightarrow> 'b::topological_space \<Rightarrow> 'c::topological_comm_monoid_add" shows "(\<And>i. i \<in> I \<Longrightarrow> continuous_on S (f i)) \<Longrightarrow> continuous_on S (\<lambda>x. \<Sum>i\<in>I. f i x)"
Formal statement is: 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})" Informal statement is: The convex hull of a set $S$ and a point $a$ is the set of all points that can be written as a convex combination of $a$ and a point in $S$.
import data.int.basic import data.int.modeq import data.nat.prime_norm_num import data.zmod.basic import tactic.linarith import tactic.ring /- Indian Mathematical Olympiad 1998, problem 1 (a) Show that the product of two numbers of the form a² + 3b² is again of that form. (b) If an integer n is such that 7n is of the form a² + 3b², prove that n is also of that form. -/ theorem india1998_q1a (a₁ a₂ b₁ b₂ : ℤ) : (∃ a₃ b₃, (a₁^2 + 3 * b₁^2) * (a₂^2 + 3 * b₂^2) = (a₃^2 + 3 * b₃^2)) := ⟨a₁ * a₂ + 3 * b₁ * b₂, a₁ * b₂ - b₁ * a₂, by ring⟩ lemma make_nonneg (a b: ℤ) (hb : 0 < b) : 0 ≤ a + b * ((b - a) / b) := by linarith[int.mod_lt_of_pos (b-a) hb, (b - a).mod_add_div b] lemma lemma1' (a : ℤ) (b : ℕ) (hb : 0 < b) : ((a : zmod b).val : ℤ) = a % (b : ℤ) := begin have h1: (a : zmod b) = ((( a + b * ((b - a )/ b)) : ℤ): zmod b) := by simp, rw [←int.add_mul_mod_self_left a b ((b - a)/ b), h1], have h2 : 0 ≤ (( a + b * ((b - a )/ b)) : ℤ) := make_nonneg a ↑b (int.coe_nat_pos.mpr hb), obtain ⟨A, hA⟩ := int.eq_coe_of_zero_le h2, simp [hA, zmod.val_nat_cast A], end lemma lemma1 (a: ℤ) : ((a : zmod 7).val : ℤ) = a % 7 := lemma1' a 7 (by norm_num) theorem india1998_q1b (n a b: ℤ) (hn : a^2 + 3 * b^2 = 7 * n) : (∃ a b : ℤ, a^2 + 3 * b^2 = n) := begin let az : zmod 7 := a, let bz : zmod 7 := b, have h1 := calc az ^ 2 + (-4) * bz ^ 2 = az^2 + ((3:ℤ):zmod 7) * bz^2 : by ring ... = ((a^2 : ℤ) : zmod 7) + ((3:ℤ):zmod 7) * (((b^2) : ℤ) : zmod 7) : by rw [int.cast_pow a 2, int.cast_pow b 2] ... = ((a^2 : ℤ) : zmod 7) + (((3 * b^2) : ℤ) : zmod 7) : by rw [int.cast_mul 3 (b^2)] ... = (((a^2 + 3 * b^2) : ℤ) : zmod 7) : (int.cast_add _ _).symm ... = (((7 * n) : ℤ) : zmod 7) : congr_arg coe hn ... = 0 : by {rw [int.cast_mul], exact zero_mul _}, have h9: az ^ 2 + (-4) * bz ^ 2 + 4 * bz^2 = 0 + 4 * bz^2 := congr_fun (congr_arg has_add.add h1) _, rw [neg_mul, neg_add_cancel_right, fin.zero_add] at h9, have h10 : 4 * bz^2 = (2 * bz) ^ 2 := by ring, rw [h10] at h9, haveI : fact (nat.prime 7) := ⟨by norm_num⟩, obtain (hep : az = 2 * bz) | (hen : az = - (2 * bz)) := eq_or_eq_neg_of_sq_eq_sq _ _ h9, { have h11: (2 * az + 3 * bz) = 0, { rw [hep], ring_nf, have h12: (7 : zmod 7) = 0 := rfl, rw [h12], simp }, have h13: 7 ∣ (2 * a + 3 * b), { have h50 : (2 * az + 3 * bz).val = (0 : zmod 7).val := congr_arg zmod.val h11, have h51 : (2 * az + 3 * bz).val = ((2 * az).val + (3 * bz).val) % 7 := zmod.val_add _ _, have h52 : (2 * az).val = (2 : zmod 7).val * az.val % 7 := zmod.val_mul _ _, have h53 : (3 * bz).val = (3 : zmod 7).val * bz.val % 7 := zmod.val_mul _ _, rw [h51, h52, h53, nat.add_mod_mod, nat.mod_add_mod, zmod.val_zero] at h50, have h52 : ((2 * (az.val:ℤ) + 3 * (bz.val:ℤ))) % 7 = 0, { norm_cast, exact h50}, rw [lemma1 a, lemma1 b] at h52, rw [←int.mod_add_div a 7, ←int.mod_add_div b 7], have h53 : 2 * (a % 7 + 7 * (a / 7)) + 3 * (b % 7 + 7 * (b / 7)) = 2 * (a % 7) + 3 * (b % 7) + 7 * (2 * (a / 7) + 3 * (b / 7)) := by ring, rw [h53], have h54 : 7 ∣ 7 * (2 * (a / 7) + 3 * (b / 7)) := dvd.intro _ rfl, exact dvd_add (int.dvd_of_mod_eq_zero h52) h54 }, obtain ⟨m1, hm1⟩ := exists_eq_mul_right_of_dvd h13, have h15: (az + (- 2) * bz) = 0, { rw [hep], ring_nf }, have h16: 7 ∣ (a + (-2) * b), { have h50 : (az + (-2) * bz).val = (0 : zmod 7).val := congr_arg zmod.val h15, have h51 : (az + (-2) * bz).val = (az.val + ((-2) * bz).val) % 7 := zmod.val_add _ _, have h53 : ((-2) * bz).val = (-2 : zmod 7).val * bz.val % 7 := zmod.val_mul _ _, rw [h51, h53, nat.add_mod_mod, zmod.val_zero] at h50, have h52 : (((az.val:ℤ) + 5 * (bz.val:ℤ))) % 7 = 0, { norm_cast, exact h50}, rw [lemma1 a, lemma1 b] at h52, have h52' : 7 ∣ a % 7 + 5 * (b % 7) := int.dvd_of_mod_eq_zero h52, rw [←int.mod_add_div a 7, ←int.mod_add_div b 7], have h53 : a % 7 + 7 * (a / 7) + (-2) * (b % 7 + 7 * (b / 7)) = a % 7 + 5 * (b % 7) + 7 * (a / 7 - 2 * (b / 7) - (b % 7)) := by ring, rw [h53], have h54 : 7 ∣ 7 * (a / 7 - 2 * (b / 7) - (b % 7)) := dvd.intro _ rfl, exact dvd_add h52' h54 }, obtain ⟨m2, hm2⟩ := exists_eq_mul_right_of_dvd h16, use m1, use m2, have h20 : (7 * m1) ^ 2 + 3 * (7 * m2) ^ 2 = 7 * 7 * n, { rw [←hm1, ←hm2], ring_nf, have h21 : (2 * a + 3 * b) ^ 2 + 3 * (a - 2 * b) ^ 2 = 7 * (a ^2 + 3 * b^2) := by ring, have h18: 7 * (a ^ 2 + 3 * b ^ 2) = 7 * (7 * n) := congr_arg (has_mul.mul 7) hn, ring_nf at h18, rw [h18] }, have h21 : (7 * m1) ^ 2 + 3 * (7 * m2) ^ 2 = 7 * 7 * (m1 ^ 2 + 3 * m2 ^ 2) := by ring, rw[h21] at h20, have h22 : (7:ℤ) * 7 ≠ 0 := by norm_num, exact (mul_right_inj' h22).mp h20 }, { have h11: (2 * az + (-3) * bz) = 0, { rw [hen], ring_nf, simp, have h12: (7 : zmod 7) = 0 := rfl, rw [h12], simp}, have h13: 7 ∣ (2 * a + (-3) * b), { have h50 : (2 * az + (-3) * bz).val = (0 : zmod 7).val := congr_arg zmod.val h11, have h51 : (2 * az + (-3) * bz).val = ((2 * az).val + ((-3) * bz).val) % 7 := zmod.val_add _ _, have h52 : (2 * az).val = (2 : zmod 7).val * az.val % 7 := zmod.val_mul _ _, have h53 : ((-3) * bz).val = (-3 : zmod 7).val * bz.val % 7 := zmod.val_mul _ _, rw [h51, h52, h53] at h50, simp at h50, have h51 : (2 * az.val + 4 * bz.val) % 7 = 0 := h50, have h52 : ((2 * (az.val:ℤ) + 4 * (bz.val:ℤ))) % 7 = 0, { norm_cast, exact h51}, rw [lemma1 a, lemma1 b] at h52, rw [←int.mod_add_div a 7, ←int.mod_add_div b 7], have h53 : 2 * (a % 7 + 7 * (a / 7)) + (-3) * (b % 7 + 7 * (b / 7)) = 2 * (a % 7) + 4 * (b % 7) + 7 * (2 * (a / 7) + (-3) * (b / 7) - (b % 7) ) := by ring, rw [h53], have h54 : 7 ∣ 7 * (2 * (a / 7) + (-3) * (b / 7) - b % 7) := dvd.intro _ rfl, exact dvd_add (int.dvd_of_mod_eq_zero h52) h54 }, have h14 : (∃ m1, 2 * a + (-3) * b = 7 * m1) := exists_eq_mul_right_of_dvd h13, obtain ⟨m1, hm1⟩ := h14, have h15: (az + 2 * bz) = 0, { rw [hen], ring_nf }, have h16: 7 ∣ (a + 2 * b), { have h50 : (az + 2 * bz).val = (0 : zmod 7).val := congr_arg zmod.val h15, have h51 : (az + 2 * bz).val = (az.val + (2 * bz).val) % 7 := zmod.val_add _ _, have h53 : (2 * bz).val = (2 : zmod 7).val * bz.val % 7 := zmod.val_mul _ _, rw [h51, h53] at h50, simp at h50, have h51 : (az.val + 2 * bz.val) % 7 = 0 := h50, have h52 : (((az.val:ℤ) + 2 * (bz.val:ℤ))) % 7 = 0, { norm_cast, exact h51}, rw [lemma1 a, lemma1 b] at h52, --rw [int.add_mod] at h52, have h52' : 7 ∣ a % 7 + 2 * (b % 7) := int.dvd_of_mod_eq_zero h52, rw [←int.mod_add_div a 7, ←int.mod_add_div b 7], have h53 : a % 7 + 7 * (a / 7) + 2 * (b % 7 + 7 * (b / 7)) = a % 7 + 2 * (b % 7) + 7 * (a / 7 + 2 * (b / 7)) := by ring, rw [h53], have h54 : 7 ∣ 7 * (a / 7 + 2 * (b / 7)) := dvd.intro _ rfl, exact dvd_add h52' h54, }, have h17 : (∃ m2, a + 2 * b = 7 * m2) := exists_eq_mul_right_of_dvd h16, obtain ⟨m2, hm2⟩ := h17, use m1, use m2, have h20 : (7 * m1) ^ 2 + 3 * (7 * m2) ^ 2 = 7 * 7 * n, { rw [←hm1, ←hm2], ring_nf, have h18: 7 * (a ^ 2 + 3 * b ^ 2) = 7 * (7 * n) := congr_arg (has_mul.mul 7) hn, ring_nf at h18, rw [h18]}, have h21 : (7 * m1) ^ 2 + 3 * (7 * m2) ^ 2 = 7 * 7 * (m1 ^ 2 + 3 * m2 ^ 2) := by ring, rw[h21] at h20, have h22 : (7:ℤ) * 7 ≠ 0 := by norm_num, exact (mul_right_inj' h22).mp h20 }, end
/- Copyright (c) 2019 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Benjamin Davidson The `even` and `odd` predicates on the integers. -/ import Mathlib.PrePort import Mathlib.Lean3Lib.init.default import Mathlib.data.int.modeq import Mathlib.data.nat.parity import Mathlib.PostPort namespace Mathlib namespace int @[simp] theorem mod_two_ne_one {n : ℤ} : ¬n % bit0 1 = 1 ↔ n % bit0 1 = 0 := sorry theorem mod_two_ne_zero {n : ℤ} : ¬n % bit0 1 = 0 ↔ n % bit0 1 = 1 := sorry @[simp] theorem even_coe_nat (n : ℕ) : even ↑n ↔ even n := sorry theorem even_iff {n : ℤ} : even n ↔ n % bit0 1 = 0 := sorry theorem odd_iff {n : ℤ} : odd n ↔ n % bit0 1 = 1 := sorry theorem not_even_iff {n : ℤ} : ¬even n ↔ n % bit0 1 = 1 := eq.mpr (id (Eq._oldrec (Eq.refl (¬even n ↔ n % bit0 1 = 1)) (propext even_iff))) (eq.mpr (id (Eq._oldrec (Eq.refl (¬n % bit0 1 = 0 ↔ n % bit0 1 = 1)) (propext mod_two_ne_zero))) (iff.refl (n % bit0 1 = 1))) theorem not_odd_iff {n : ℤ} : ¬odd n ↔ n % bit0 1 = 0 := eq.mpr (id (Eq._oldrec (Eq.refl (¬odd n ↔ n % bit0 1 = 0)) (propext odd_iff))) (eq.mpr (id (Eq._oldrec (Eq.refl (¬n % bit0 1 = 1 ↔ n % bit0 1 = 0)) (propext mod_two_ne_one))) (iff.refl (n % bit0 1 = 0))) theorem even_iff_not_odd {n : ℤ} : even n ↔ ¬odd n := eq.mpr (id (Eq._oldrec (Eq.refl (even n ↔ ¬odd n)) (propext not_odd_iff))) (eq.mpr (id (Eq._oldrec (Eq.refl (even n ↔ n % bit0 1 = 0)) (propext even_iff))) (iff.refl (n % bit0 1 = 0))) @[simp] theorem odd_iff_not_even {n : ℤ} : odd n ↔ ¬even n := eq.mpr (id (Eq._oldrec (Eq.refl (odd n ↔ ¬even n)) (propext not_even_iff))) (eq.mpr (id (Eq._oldrec (Eq.refl (odd n ↔ n % bit0 1 = 1)) (propext odd_iff))) (iff.refl (n % bit0 1 = 1))) theorem even_or_odd (n : ℤ) : even n ∨ odd n := or.imp_right (iff.mpr odd_iff_not_even) (em (even n)) theorem even_or_odd' (n : ℤ) : ∃ (k : ℤ), n = bit0 1 * k ∨ n = bit0 1 * k + 1 := sorry theorem even_xor_odd (n : ℤ) : xor (even n) (odd n) := or.dcases_on (even_or_odd n) (fun (h : even n) => Or.inl { left := h, right := iff.mp even_iff_not_odd h }) fun (h : odd n) => Or.inr { left := h, right := iff.mp odd_iff_not_even h } theorem even_xor_odd' (n : ℤ) : ∃ (k : ℤ), xor (n = bit0 1 * k) (n = bit0 1 * k + 1) := sorry theorem ne_of_odd_sum {x : ℤ} {y : ℤ} (h : odd (x + y)) : x ≠ y := sorry @[simp] theorem two_dvd_ne_zero {n : ℤ} : ¬bit0 1 ∣ n ↔ n % bit0 1 = 1 := not_even_iff protected instance even.decidable_pred : decidable_pred even := fun (n : ℤ) => decidable_of_decidable_of_iff (int.decidable_eq (n % bit0 1) 0) sorry protected instance decidable_pred_odd : decidable_pred odd := fun (n : ℤ) => decidable_of_decidable_of_iff not.decidable sorry @[simp] theorem even_zero : even 0 := Exists.intro 0 (of_as_true trivial) @[simp] theorem not_even_one : ¬even 1 := eq.mpr (id (Eq._oldrec (Eq.refl (¬even 1)) (propext even_iff))) one_ne_zero @[simp] theorem even_bit0 (n : ℤ) : even (bit0 n) := Exists.intro n (eq.mpr (id (Eq._oldrec (Eq.refl (bit0 n = bit0 1 * n)) (bit0.equations._eqn_1 n))) (eq.mpr (id (Eq._oldrec (Eq.refl (n + n = bit0 1 * n)) (two_mul n))) (Eq.refl (n + n)))) theorem even_add {m : ℤ} {n : ℤ} : even (m + n) ↔ (even m ↔ even n) := sorry theorem even_neg {n : ℤ} : even (-n) ↔ even n := sorry @[simp] theorem not_even_bit1 (n : ℤ) : ¬even (bit1 n) := sorry theorem even_sub {m : ℤ} {n : ℤ} : even (m - n) ↔ (even m ↔ even n) := sorry theorem even_mul {m : ℤ} {n : ℤ} : even (m * n) ↔ even m ∨ even n := sorry theorem even_pow {m : ℤ} {n : ℕ} : even (m ^ n) ↔ even m ∧ n ≠ 0 := sorry end Mathlib
[STATEMENT] lemma sran_singleton[simp]: "sran {k := vs}. = vs" [PROOF STATE] proof (prove) goal (1 subgoal): 1. sran { k := vs}. = vs [PROOF STEP] by (auto simp add: sran_def smap_singleton_def smap_empty_def)
import numpy as np from .settings import _preferences as prefs from .importing import import_optional def import_plt(): """Import matplotlib.pyplot if available and not skipped. No fallback option exists, because the plot* functions are not added if module import return None. """ return import_optional("matplotlib.pyplot", "MPL") def plotfun(fun, support, ax=None, N=None, **kwds): ax = ax or import_plt().gca() N = N if N is not None else prefs.N_plot xx = np.linspace(*support, N) ff = fun(xx) if fun.iscomplex: ax.plot(np.real(ff), np.imag(ff), **kwds) ax.set_xlabel(kwds.pop("ylabel", "real")) ax.set_ylabel(kwds.pop("xlabel", "imag")) else: ax.plot(xx, ff, **kwds) return ax def plotfuncoeffs(abscoeffs, ax=None, **kwds): ax = ax or import_plt().gca() ax.set_ylabel(kwds.pop("xlabel", "coefficient magnitude")) ax.set_xlabel(kwds.pop("ylabel", "polynomial degree")) ax.semilogy(abscoeffs, ".", **kwds) return ax
module Math.FROG.Retrieval ( retrieve , calcLoss ) where import qualified Numeric.LinearAlgebra as LA import qualified Math.Optimization.SPSA as SPSA import qualified Math.FROG.Tools as FR import Math.FROG.Types retrieve :: Nonlinearity -> Trace -> IO (LA.Vector Double) retrieve nonlin measurement = do let niter = 50000 let a = 0.2 let c = 0.00001 let sz = LA.rows measurement let gainA = SPSA.standardAk a (niter `quot` 10) 0.602 let gainC = SPSA.standardCk c 0.101 let lossFn = calcLoss nonlin measurement spsa <- SPSA.mkUnconstrainedSPSA lossFn gainA gainC (2*sz) initialGuess <- FR.mkInitialGuess sz return $ SPSA.optimize spsa niter initialGuess calcLoss :: Nonlinearity -> Trace -> LA.Vector Double -> Double calcLoss nonlin meas v = (/ (fromIntegral $ LA.rows meas)) . sqrt . LA.sumElements $ sqDiff where field = FR.flatPolar2Complex v (signal, gate) = FR.mkSigGate nonlin field field sqDiff = (^2) . abs $ (meas - FR.mkTrace signal gate)
## Make a joyplot of any scale by any factor variable # wtib = work tibble (data) # fctr = factor variable # fctr_nm = Factor name for axis title # scl = scale variable # title = Plot title # sample_nm = Sample name, e.g., "Vaccines" # sample_num = sample number for filename (e.g., 2016) # # prints the plot to a file with the name format "Joyplot", sample_num, " ", title, ".png", sep = "" joyplot_scale_by_factor <- function(plot_tib, fctr, fctr_nm, scl, scl_nm, title, sample_nm, sample_num) { shhh(library(ggjoy)) shhh(library(ggridges)) shhh(library(scales)) shhh(library(lubridate)) ggplot(plot_tib, aes(y = fctr, x = scl)) + geom_density_ridges(scale = 4, aes(fill = fctr), alpha = 3/4, na.rm = FALSE, quantile_lines = TRUE, quantiles = 2) + scale_x_continuous(scl_nm) + guides(fill = FALSE, color = FALSE) + labs(title = title, y = fctr_nm, x = "How Characteristic", caption = (paste(sample_nm, today(), sep = " "))) + z_theme() plotfile <- paste("Joyplot", " ", title, ".png", sep = "") ggsave(plotfile, height = 8, width = 8, dpi = 120, type = "cairo-png") }
lemma example3 (a b : mynat) (h : succ a = b) : succ(succ(a)) = succ(b) := begin rw h, refl, end
example : x ≠ y → x ∉ [y] := fun hne hin => match hin with | .head _ => hne rfl example : x ≠ y → x ∉ [y] := fun hne (.head _) => hne rfl
Sheboygan's Final Approach This is one of my favorite airport restaurants. It's truly good dining, located right at the SW corner of the field. They have nice prime rib, steaks, seafood, and, if you're there for lunch, sandwiches and a salad bar. Their menu is available on their site.
infixr 6 -* (-*) : Type -> Type -> Type (-*) a b = (1 _ : a) -> b -- Test that the types of holes are not overly generalised wrt the -- multiplicities in the function type foo1 : (((1 _ : a) -> (1 _ : b) -> (1 _ : c) -> ()) -> ()) -> () foo1 f = f ?foo1h foo2 : (((1 _ : a) -> (1 _ : b) -> (1 _ : c) -> ()) -> ()) -> () foo2 f = f (id ?foo2h) foo3 : ((a -* b -* c -* ()) -> ()) -> () foo3 f = f (id ?foo3h)
(* Title: HOL/Hahn_Banach/Hahn_Banach_Sup_Lemmas.thy Author: Gertrud Bauer, TU Munich *) section \<open>The supremum w.r.t.~the function order\<close> theory Hahn_Banach_Sup_Lemmas imports Function_Norm Zorn_Lemma begin text \<open> This section contains some lemmas that will be used in the proof of the Hahn-Banach Theorem. In this section the following context is presumed. Let @{text E} be a real vector space with a seminorm @{text p} on @{text E}. @{text F} is a subspace of @{text E} and @{text f} a linear form on @{text F}. We consider a chain @{text c} of norm-preserving extensions of @{text f}, such that @{text "\<Union>c = graph H h"}. We will show some properties about the limit function @{text h}, i.e.\ the supremum of the chain @{text c}. \medskip Let @{text c} be a chain of norm-preserving extensions of the function @{text f} and let @{text "graph H h"} be the supremum of @{text c}. Every element in @{text H} is member of one of the elements of the chain. \<close> lemmas [dest?] = chainsD lemmas chainsE2 [elim?] = chainsD2 [elim_format] lemma some_H'h't: assumes M: "M = norm_pres_extensions E p F f" and cM: "c \<in> chains M" and u: "graph H h = \<Union>c" and x: "x \<in> H" shows "\<exists>H' h'. graph H' h' \<in> c \<and> (x, h x) \<in> graph H' h' \<and> linearform H' h' \<and> H' \<unlhd> E \<and> F \<unlhd> H' \<and> graph F f \<subseteq> graph H' h' \<and> (\<forall>x \<in> H'. h' x \<le> p x)" proof - from x have "(x, h x) \<in> graph H h" .. also from u have "\<dots> = \<Union>c" . finally obtain g where gc: "g \<in> c" and gh: "(x, h x) \<in> g" by blast from cM have "c \<subseteq> M" .. with gc have "g \<in> M" .. also from M have "\<dots> = norm_pres_extensions E p F f" . finally obtain H' and h' where g: "g = graph H' h'" and * : "linearform H' h'" "H' \<unlhd> E" "F \<unlhd> H'" "graph F f \<subseteq> graph H' h'" "\<forall>x \<in> H'. h' x \<le> p x" .. from gc and g have "graph H' h' \<in> c" by (simp only:) moreover from gh and g have "(x, h x) \<in> graph H' h'" by (simp only:) ultimately show ?thesis using * by blast qed text \<open> \medskip Let @{text c} be a chain of norm-preserving extensions of the function @{text f} and let @{text "graph H h"} be the supremum of @{text c}. Every element in the domain @{text H} of the supremum function is member of the domain @{text H'} of some function @{text h'}, such that @{text h} extends @{text h'}. \<close> lemma some_H'h': assumes M: "M = norm_pres_extensions E p F f" and cM: "c \<in> chains M" and u: "graph H h = \<Union>c" and x: "x \<in> H" shows "\<exists>H' h'. x \<in> H' \<and> graph H' h' \<subseteq> graph H h \<and> linearform H' h' \<and> H' \<unlhd> E \<and> F \<unlhd> H' \<and> graph F f \<subseteq> graph H' h' \<and> (\<forall>x \<in> H'. h' x \<le> p x)" proof - from M cM u x obtain H' h' where x_hx: "(x, h x) \<in> graph H' h'" and c: "graph H' h' \<in> c" and * : "linearform H' h'" "H' \<unlhd> E" "F \<unlhd> H'" "graph F f \<subseteq> graph H' h'" "\<forall>x \<in> H'. h' x \<le> p x" by (rule some_H'h't [elim_format]) blast from x_hx have "x \<in> H'" .. moreover from cM u c have "graph H' h' \<subseteq> graph H h" by blast ultimately show ?thesis using * by blast qed text \<open> \medskip Any two elements @{text x} and @{text y} in the domain @{text H} of the supremum function @{text h} are both in the domain @{text H'} of some function @{text h'}, such that @{text h} extends @{text h'}. \<close> lemma some_H'h'2: assumes M: "M = norm_pres_extensions E p F f" and cM: "c \<in> chains M" and u: "graph H h = \<Union>c" and x: "x \<in> H" and y: "y \<in> H" shows "\<exists>H' h'. x \<in> H' \<and> y \<in> H' \<and> graph H' h' \<subseteq> graph H h \<and> linearform H' h' \<and> H' \<unlhd> E \<and> F \<unlhd> H' \<and> graph F f \<subseteq> graph H' h' \<and> (\<forall>x \<in> H'. h' x \<le> p x)" proof - txt \<open>@{text y} is in the domain @{text H''} of some function @{text h''}, such that @{text h} extends @{text h''}.\<close> from M cM u and y obtain H' h' where y_hy: "(y, h y) \<in> graph H' h'" and c': "graph H' h' \<in> c" and * : "linearform H' h'" "H' \<unlhd> E" "F \<unlhd> H'" "graph F f \<subseteq> graph H' h'" "\<forall>x \<in> H'. h' x \<le> p x" by (rule some_H'h't [elim_format]) blast txt \<open>@{text x} is in the domain @{text H'} of some function @{text h'}, such that @{text h} extends @{text h'}.\<close> from M cM u and x obtain H'' h'' where x_hx: "(x, h x) \<in> graph H'' h''" and c'': "graph H'' h'' \<in> c" and ** : "linearform H'' h''" "H'' \<unlhd> E" "F \<unlhd> H''" "graph F f \<subseteq> graph H'' h''" "\<forall>x \<in> H''. h'' x \<le> p x" by (rule some_H'h't [elim_format]) blast txt \<open>Since both @{text h'} and @{text h''} are elements of the chain, @{text h''} is an extension of @{text h'} or vice versa. Thus both @{text x} and @{text y} are contained in the greater one. \label{cases1}\<close> from cM c'' c' have "graph H'' h'' \<subseteq> graph H' h' \<or> graph H' h' \<subseteq> graph H'' h''" (is "?case1 \<or> ?case2") .. then show ?thesis proof assume ?case1 have "(x, h x) \<in> graph H'' h''" by fact also have "\<dots> \<subseteq> graph H' h'" by fact finally have xh:"(x, h x) \<in> graph H' h'" . then have "x \<in> H'" .. moreover from y_hy have "y \<in> H'" .. moreover from cM u and c' have "graph H' h' \<subseteq> graph H h" by blast ultimately show ?thesis using * by blast next assume ?case2 from x_hx have "x \<in> H''" .. moreover { have "(y, h y) \<in> graph H' h'" by (rule y_hy) also have "\<dots> \<subseteq> graph H'' h''" by fact finally have "(y, h y) \<in> graph H'' h''" . } then have "y \<in> H''" .. moreover from cM u and c'' have "graph H'' h'' \<subseteq> graph H h" by blast ultimately show ?thesis using ** by blast qed qed text \<open> \medskip The relation induced by the graph of the supremum of a chain @{text c} is definite, i.~e.~t is the graph of a function. \<close> lemma sup_definite: assumes M_def: "M \<equiv> norm_pres_extensions E p F f" and cM: "c \<in> chains M" and xy: "(x, y) \<in> \<Union>c" and xz: "(x, z) \<in> \<Union>c" shows "z = y" proof - from cM have c: "c \<subseteq> M" .. from xy obtain G1 where xy': "(x, y) \<in> G1" and G1: "G1 \<in> c" .. from xz obtain G2 where xz': "(x, z) \<in> G2" and G2: "G2 \<in> c" .. from G1 c have "G1 \<in> M" .. then obtain H1 h1 where G1_rep: "G1 = graph H1 h1" unfolding M_def by blast from G2 c have "G2 \<in> M" .. then obtain H2 h2 where G2_rep: "G2 = graph H2 h2" unfolding M_def by blast txt \<open>@{text "G\<^sub>1"} is contained in @{text "G\<^sub>2"} or vice versa, since both @{text "G\<^sub>1"} and @{text "G\<^sub>2"} are members of @{text c}. \label{cases2}\<close> from cM G1 G2 have "G1 \<subseteq> G2 \<or> G2 \<subseteq> G1" (is "?case1 \<or> ?case2") .. then show ?thesis proof assume ?case1 with xy' G2_rep have "(x, y) \<in> graph H2 h2" by blast then have "y = h2 x" .. also from xz' G2_rep have "(x, z) \<in> graph H2 h2" by (simp only:) then have "z = h2 x" .. finally show ?thesis . next assume ?case2 with xz' G1_rep have "(x, z) \<in> graph H1 h1" by blast then have "z = h1 x" .. also from xy' G1_rep have "(x, y) \<in> graph H1 h1" by (simp only:) then have "y = h1 x" .. finally show ?thesis .. qed qed text \<open> \medskip The limit function @{text h} is linear. Every element @{text x} in the domain of @{text h} is in the domain of a function @{text h'} in the chain of norm preserving extensions. Furthermore, @{text h} is an extension of @{text h'} so the function values of @{text x} are identical for @{text h'} and @{text h}. Finally, the function @{text h'} is linear by construction of @{text M}. \<close> lemma sup_lf: assumes M: "M = norm_pres_extensions E p F f" and cM: "c \<in> chains M" and u: "graph H h = \<Union>c" shows "linearform H h" proof fix x y assume x: "x \<in> H" and y: "y \<in> H" with M cM u obtain H' h' where x': "x \<in> H'" and y': "y \<in> H'" and b: "graph H' h' \<subseteq> graph H h" and linearform: "linearform H' h'" and subspace: "H' \<unlhd> E" by (rule some_H'h'2 [elim_format]) blast show "h (x + y) = h x + h y" proof - from linearform x' y' have "h' (x + y) = h' x + h' y" by (rule linearform.add) also from b x' have "h' x = h x" .. also from b y' have "h' y = h y" .. also from subspace x' y' have "x + y \<in> H'" by (rule subspace.add_closed) with b have "h' (x + y) = h (x + y)" .. finally show ?thesis . qed next fix x a assume x: "x \<in> H" with M cM u obtain H' h' where x': "x \<in> H'" and b: "graph H' h' \<subseteq> graph H h" and linearform: "linearform H' h'" and subspace: "H' \<unlhd> E" by (rule some_H'h' [elim_format]) blast show "h (a \<cdot> x) = a * h x" proof - from linearform x' have "h' (a \<cdot> x) = a * h' x" by (rule linearform.mult) also from b x' have "h' x = h x" .. also from subspace x' have "a \<cdot> x \<in> H'" by (rule subspace.mult_closed) with b have "h' (a \<cdot> x) = h (a \<cdot> x)" .. finally show ?thesis . qed qed text \<open> \medskip The limit of a non-empty chain of norm preserving extensions of @{text f} is an extension of @{text f}, since every element of the chain is an extension of @{text f} and the supremum is an extension for every element of the chain. \<close> lemma sup_ext: assumes graph: "graph H h = \<Union>c" and M: "M = norm_pres_extensions E p F f" and cM: "c \<in> chains M" and ex: "\<exists>x. x \<in> c" shows "graph F f \<subseteq> graph H h" proof - from ex obtain x where xc: "x \<in> c" .. from cM have "c \<subseteq> M" .. with xc have "x \<in> M" .. with M have "x \<in> norm_pres_extensions E p F f" by (simp only:) then obtain G g where "x = graph G g" and "graph F f \<subseteq> graph G g" .. then have "graph F f \<subseteq> x" by (simp only:) also from xc have "\<dots> \<subseteq> \<Union>c" by blast also from graph have "\<dots> = graph H h" .. finally show ?thesis . qed text \<open> \medskip The domain @{text H} of the limit function is a superspace of @{text F}, since @{text F} is a subset of @{text H}. The existence of the @{text 0} element in @{text F} and the closure properties follow from the fact that @{text F} is a vector space. \<close> lemma sup_supF: assumes graph: "graph H h = \<Union>c" and M: "M = norm_pres_extensions E p F f" and cM: "c \<in> chains M" and ex: "\<exists>x. x \<in> c" and FE: "F \<unlhd> E" shows "F \<unlhd> H" proof from FE show "F \<noteq> {}" by (rule subspace.non_empty) from graph M cM ex have "graph F f \<subseteq> graph H h" by (rule sup_ext) then show "F \<subseteq> H" .. fix x y assume "x \<in> F" and "y \<in> F" with FE show "x + y \<in> F" by (rule subspace.add_closed) next fix x a assume "x \<in> F" with FE show "a \<cdot> x \<in> F" by (rule subspace.mult_closed) qed text \<open> \medskip The domain @{text H} of the limit function is a subspace of @{text E}. \<close> lemma sup_subE: assumes graph: "graph H h = \<Union>c" and M: "M = norm_pres_extensions E p F f" and cM: "c \<in> chains M" and ex: "\<exists>x. x \<in> c" and FE: "F \<unlhd> E" and E: "vectorspace E" shows "H \<unlhd> E" proof show "H \<noteq> {}" proof - from FE E have "0 \<in> F" by (rule subspace.zero) also from graph M cM ex FE have "F \<unlhd> H" by (rule sup_supF) then have "F \<subseteq> H" .. finally show ?thesis by blast qed show "H \<subseteq> E" proof fix x assume "x \<in> H" with M cM graph obtain H' where x: "x \<in> H'" and H'E: "H' \<unlhd> E" by (rule some_H'h' [elim_format]) blast from H'E have "H' \<subseteq> E" .. with x show "x \<in> E" .. qed fix x y assume x: "x \<in> H" and y: "y \<in> H" show "x + y \<in> H" proof - from M cM graph x y obtain H' h' where x': "x \<in> H'" and y': "y \<in> H'" and H'E: "H' \<unlhd> E" and graphs: "graph H' h' \<subseteq> graph H h" by (rule some_H'h'2 [elim_format]) blast from H'E x' y' have "x + y \<in> H'" by (rule subspace.add_closed) also from graphs have "H' \<subseteq> H" .. finally show ?thesis . qed next fix x a assume x: "x \<in> H" show "a \<cdot> x \<in> H" proof - from M cM graph x obtain H' h' where x': "x \<in> H'" and H'E: "H' \<unlhd> E" and graphs: "graph H' h' \<subseteq> graph H h" by (rule some_H'h' [elim_format]) blast from H'E x' have "a \<cdot> x \<in> H'" by (rule subspace.mult_closed) also from graphs have "H' \<subseteq> H" .. finally show ?thesis . qed qed text \<open> \medskip The limit function is bounded by the norm @{text p} as well, since all elements in the chain are bounded by @{text p}. \<close> lemma sup_norm_pres: assumes graph: "graph H h = \<Union>c" and M: "M = norm_pres_extensions E p F f" and cM: "c \<in> chains M" shows "\<forall>x \<in> H. h x \<le> p x" proof fix x assume "x \<in> H" with M cM graph obtain H' h' where x': "x \<in> H'" and graphs: "graph H' h' \<subseteq> graph H h" and a: "\<forall>x \<in> H'. h' x \<le> p x" by (rule some_H'h' [elim_format]) blast from graphs x' have [symmetric]: "h' x = h x" .. also from a x' have "h' x \<le> p x " .. finally show "h x \<le> p x" . qed text \<open> \medskip The following lemma is a property of linear forms on real vector spaces. It will be used for the lemma @{text abs_Hahn_Banach} (see page \pageref{abs-Hahn_Banach}). \label{abs-ineq-iff} For real vector spaces the following inequations are equivalent: \begin{center} \begin{tabular}{lll} @{text "\<forall>x \<in> H. \<bar>h x\<bar> \<le> p x"} & and & @{text "\<forall>x \<in> H. h x \<le> p x"} \\ \end{tabular} \end{center} \<close> lemma abs_ineq_iff: assumes "subspace H E" and "vectorspace E" and "seminorm E p" and "linearform H h" shows "(\<forall>x \<in> H. \<bar>h x\<bar> \<le> p x) = (\<forall>x \<in> H. h x \<le> p x)" (is "?L = ?R") proof interpret subspace H E by fact interpret vectorspace E by fact interpret seminorm E p by fact interpret linearform H h by fact have H: "vectorspace H" using \<open>vectorspace E\<close> .. { assume l: ?L show ?R proof fix x assume x: "x \<in> H" have "h x \<le> \<bar>h x\<bar>" by arith also from l x have "\<dots> \<le> p x" .. finally show "h x \<le> p x" . qed next assume r: ?R show ?L proof fix x assume x: "x \<in> H" show "\<And>a b :: real. - a \<le> b \<Longrightarrow> b \<le> a \<Longrightarrow> \<bar>b\<bar> \<le> a" by arith from \<open>linearform H h\<close> and H x have "- h x = h (- x)" by (rule linearform.neg [symmetric]) also from H x have "- x \<in> H" by (rule vectorspace.neg_closed) with r have "h (- x) \<le> p (- x)" .. also have "\<dots> = p x" using \<open>seminorm E p\<close> \<open>vectorspace E\<close> proof (rule seminorm.minus) from x show "x \<in> E" .. qed finally have "- h x \<le> p x" . then show "- p x \<le> h x" by simp from r x show "h x \<le> p x" .. qed } qed end
{-# OPTIONS --cubical-compatible #-} record Erased (A : Set) : Set where constructor [_] field @0 erased : A open Erased data W (A : Set) (B : A → Set) : Set where sup : (x : A) → (B x → W A B) → W A B lemma : {A : Set} {B : A → Set} → Erased (W A B) → W (Erased A) (λ x → Erased (B (erased x))) lemma [ sup x f ] = sup [ x ] λ ([ y ]) → lemma [ f y ] data ⊥ : Set where data E : Set where c : E → E magic : @0 E → ⊥ magic (c e) = magic e
import data.rat.basic import data.real.basic import algebra.group_with_zero.basic import algebra.group.hom import for_mathlib.hom -- From Alex J. Best (?) lemma rat_mk_eq_div (x_num : ℤ) (x_denom : ℕ) (x_pos : 0 < x_denom) (x_cop : nat.coprime (int.nat_abs x_num) x_denom) : ({num := x_num, denom := x_denom, pos := x_pos, cop := x_cop}:ℚ) = (↑ x_num)/(↑ x_denom) := begin norm_cast, rw rat.mk, rw rat.mk_nat, rw dif_neg, rw rat.mk_pnat, { simp [x_cop.gcd_eq_one], }, exact ne_of_gt x_pos, end -- Integer values of a morphism `φ` and its value on `-1` completely determines `φ` theorem ext_hom_pnat (φ₁ φ₂: monoid_with_zero_hom ℚ ℝ) (same_on_neg_one: φ₁ (-1) = φ₂ (-1)) (same_on_nat: ∀ n: ℕ, φ₁ n = φ₂ n): (φ₁: ℚ → ℝ) = φ₂ := begin ext, suffices : ∀ z : ℤ, φ₁ z = φ₂ z, begin induction x, rw rat_mk_eq_div, repeat { rw div_eq_mul_inv, }, have x_denom_ne_zero: (x_denom: ℚ) ≠ 0, { symmetry, norm_cast, exact (ne_of_lt x_pos), }, rw monoid_with_zero_hom.map_mul φ₁, rw monoid_with_zero_hom.map_inv φ₁ x_denom x_denom_ne_zero, rw monoid_with_zero_hom.map_mul φ₂, rw monoid_with_zero_hom.map_inv φ₂ x_denom x_denom_ne_zero, rw this x_num, have := this (↑ x_denom), norm_cast at this, rw this, end, intro x, suffices : ∀ z : ℕ, φ₁ z = φ₂ z, begin induction x, simp [this], push_cast, conv { congr, rw neg_eq_neg_one_mul, skip, rw neg_eq_neg_one_mul, skip, }, rw monoid_with_zero_hom.map_mul φ₁, rw monoid_with_zero_hom.map_mul φ₂, rw same_on_neg_one, simp, norm_cast, exact this _, end, intro x, cases x, simp, have := same_on_nat (nat.succ x_1), simp [-add_comm] at this, simp [-add_comm], rw this, end
import LMT variable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)] example {a1 a2 a3 : A I E} : (v3) ≠ (((((a1).write i3 (v1)).write i2 (v3)).write i1 (v3)).read i2) → False := by arr
(* 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 *) Require Import Coq.ZArith.BinInt. Local Open Scope Z. Require Import Utility. Local Open Scope alu_scope. (* Converted imports: *) Require Decode. Require Import Monads. Require Import Program. Require Import Utility. (* No type declarations to convert. *) (* Converted value declarations: *) Definition execute {p} {t} `{(RiscvState p t)} : Decode.InstructionM -> p unit := fun arg_0__ => match arg_0__ with | Decode.Mul rd rs1 rs2 => Bind (getRegister rs1) (fun x => Bind (getRegister rs2) (fun y => setRegister rd (x * y))) | Decode.Mulh rd rs1 rs2 => Bind (getRegister rs1) (fun x => Bind (getRegister rs2) (fun y => setRegister rd (highBits (regToZ_signed x * regToZ_signed y) : t))) | Decode.Mulhsu rd rs1 rs2 => Bind (getRegister rs1) (fun x => Bind (getRegister rs2) (fun y => setRegister rd (highBits (regToZ_signed x * regToZ_unsigned y) : t))) | Decode.Mulhu rd rs1 rs2 => Bind (getRegister rs1) (fun x => Bind (getRegister rs2) (fun y => setRegister rd (highBits (regToZ_unsigned x * regToZ_unsigned y) : t))) | Decode.Div rd rs1 rs2 => Bind (getRegister rs1) (fun x => Bind (getRegister rs2) (fun y => let q := if andb (reg_eqb x minSigned) (reg_eqb y (negate (ZToReg 1))) : bool then x else if reg_eqb y (ZToReg 0) : bool then negate (ZToReg 1) else div x y in setRegister rd q)) | Decode.Divu rd rs1 rs2 => Bind (getRegister rs1) (fun x => Bind (getRegister rs2) (fun y => let q := if reg_eqb y (ZToReg 0) : bool then maxUnsigned else divu x y in setRegister rd q)) | Decode.Rem rd rs1 rs2 => Bind (getRegister rs1) (fun x => Bind (getRegister rs2) (fun y => let r := if andb (reg_eqb x minSigned) (reg_eqb y (negate (ZToReg 1))) : bool then ZToReg 0 else if reg_eqb y (ZToReg 0) : bool then x else rem x y in setRegister rd r)) | Decode.Remu rd rs1 rs2 => Bind (getRegister rs1) (fun x => Bind (getRegister rs2) (fun y => let r := if reg_eqb y (ZToReg 0) : bool then x else remu x y in setRegister rd r)) | inst => Return tt end. (* External variables: Bind Return RiscvState ZToReg andb bool div divu getRegister highBits maxUnsigned minSigned negate op_zt__ regToZ_signed regToZ_unsigned reg_eqb rem remu setRegister tt unit Decode.Div Decode.Divu Decode.InstructionM Decode.Mul Decode.Mulh Decode.Mulhsu Decode.Mulhu Decode.Rem Decode.Remu *)
import hilbert.wr.and_or import hilbert.wr.proofs.or namespace clfrags namespace hilbert namespace wr namespace and_or theorem c₁ {a b : Prop} (h₁ : a) (h₂ : b) : and a b := have h₃ : or (and a b) a, from or.d₁' h₁, have h₄ : or (and a b) b, from or.d₁' h₂, have h₅ : or (and a b) (and a b), from cd₁ h₃ h₄, show and a b, from or.d₂ h₅ theorem c₂ {a b : Prop} (h₁ : and a b) : a := have h₂ : or a (and a b), from or.d₁' h₁, have h₃ : or a a, from cd₂ h₂, show a, from or.d₂ h₃ theorem c₃ {a b : Prop} (h₁ : and a b) : b := have h₂ : or b (and a b), from or.d₁' h₁, have h₃ : or b b, from cd₃ h₂, show b, from or.d₂ h₃ end and_or end wr end hilbert end clfrags
proposition lipschitz_on_closed_Union: assumes "\<And>i. i \<in> I \<Longrightarrow> lipschitz_on M (U i) f" "\<And>i. i \<in> I \<Longrightarrow> closed (U i)" "finite I" "M \<ge> 0" "{u..(v::real)} \<subseteq> (\<Union>i\<in>I. U i)" shows "lipschitz_on M {u..v} f"
State Before: x : ℝ ⊢ arcsin ↑(projIcc (-1) 1 (_ : -1 ≤ 1) x) = arcsin x State After: no goals Tactic: rw [arcsin, Function.comp_apply, IccExtend_val, Function.comp_apply, IccExtend, Function.comp_apply]
! RUN: bbc -emit-fir -o - %s | FileCheck %s ! CHECK-LABEL: func @_QPkagi function kagi(index) ! CHECK: fir.select_case %{{.}} : i32 [#fir.upper, %c-1_i32, ^bb{{.}}, #fir.lower, %c1_i32, ^bb{{.}}, unit, ^bb{{.}}] if (index) 7, 8, 9 kagi = 0; return 7 kagi = 1; return 8 kagi = 2; return 9 kagi = 3; return end ! CHECK-LABEL: func @_QPkagf function kagf(findex) ! CHECK: %[[zero:.+]] = arith.constant 0.0 ! CHECK: %{{.+}} = arith.cmpf olt, %{{.+}}, %[[zero]] : f32 ! CHECK: cond_br % ! CHECK: %{{.+}} = arith.cmpf ogt, %{{.+}}, %[[zero]] : f32 ! CHECK: cond_br % ! CHECK: br ^ if (findex+findex) 7, 8, 9 kagf = 0; return 7 kagf = 1; return 8 kagf = 2; return 9 kagf = 3; return end ! CHECK-LABEL: func @_QQmain print*, kagf(-2.0) print*, kagf(-1.0) print*, kagf(-0.0) print*, kagf( 0.0) print*, kagf(+0.0) print*, kagf(+1.0) print*, kagf(+2.0) end
(*I will introduce you to how to operate with Coq in the very basic steps Coq as a language is very raw and with not many in built structures. Instead, Coq allows for more control by the user (even the equalities are defined by the user!) Coq works with Inductive, Module, Definition and a proof mode. Already implemented Types are: nat naturals, bool booleans, Prop propositions, Set set. Let us work first on Prop. *) Check Prop. Check 2 = 1. Check True -> True. Check False -> False. Eval compute in 10 + 10. Eval compute in true. Compute false. Compute True -> True. (* We enter proof mode by defining a goal/theorem about a proposition. the followint is the structure of a well written proof.*) Goal forall (A:Prop), A -> A. (* Goal, definition of A, Prop.*) Proof. (*Start of your proof.*) intros A. (*Introduces A as a given fact.*) intros Hypoth. (*Same as above*) (*We now know that A is a given fact because of Hypoth, and that we want to prove A.*) exact Hypoth. (* "Same as Hypoth"*) (*Now we can close our proof with Qed.*) Qed. Goal forall A B : Prop, (A -> A) /\ (B -> B). Proof. intros. (*This command introduces everything automatically.*) (*Well, we met this: (A -> A) /\ (B -> B) which is "And".*) refine(conj _ _). (*This separates 1 goal into 2.*) (*In Coq, we always prove the topmost subgoals first. If you want to skip any of them for the time being, you can call the "admit." command, and it eliminates the topmost goal.*) admit. intro H. exact H. (*At this point, the following message displays: No more subgoals, but there are some goals you gave up: A -> A You need to go back and solve them. Let us end our proof and do it the right way.*) Admitted. (*The command Admitted. closes an entire proof under the assumption that it is an axiom/unfinished proof.*) Goal forall A B : Prop, (A -> A) /\ (B -> B). Proof. intros. refine(conj _ _). trivial. auto. Qed. Theorem n_equals_n : forall n:nat, n = n. Proof. (*Whenever we have "forall", it is a good idea to introduce the variables/facts.*) intros. (*To prove this, you can use auto/trivial/intuition etc. The ideal argument instead is "reflexivity.". Let us use that.*) reflexivity. Qed. Goal forall n m:nat, n = n /\ m = m. Proof. intros. refine(conj _ _). (*We can use flexibility again, but let use our recently proven theorem/lemma.*) apply n_equals_n. (*Or, we can introduce our lemma for later.*) pose proof n_equals_n as theorem. (* pose [args]. takes some arguments and generates a new fact object which we can use later.*) apply theorem. Qed. Goal true = true. Proof. (*We could just use reflex. or apply a previous theorem, but let me show you another strategy.*) pose(x := true). (*Declares "obj" defined as "true".*) (*We can create facts which will be added as a subgoal, and we will need to prove such fact.*) assert(x = true). trivial. (*Now, we can rewrite our goal.*) rewrite <- H. pose proof n_equals_n as T. trivial. Qed. Goal 5 < 6. Proof. intuition. Qed. Goal 5 <> 6. (* 5 not equal 6*) Proof. (*reflexivity here fails. lets try unfolding this.*) unfold not. (*you can try autounfold.*) intro H. (*We ended up in false. It means one of our Props is false by nature, and we need to check which one. Thankfully, since the statement H is simple enough, we use discriminate.*) discriminate. Qed. Goal False -> False. Proof. intro. (*One of our facts is false, let us use that.*) exact H. Qed. Goal forall a b:Prop, a -> b \/ a. Proof. intros. pose (H0 := or_intror H : b \/ a). Check H0. (*We created a fact "b \/ a" with the argument H. Only demanding part was "or_intro(l/r)".*) exact H0. Qed. (*Here is a nice exercise:*) Goal (forall A B : Prop, A -> (A->B) -> B). Proof. intros A. intros B. intros proof_of_A. intros A_implies_B. pose (proof_of_B := A_implies_B proof_of_A). (*pose (proof_of_B := proof_of_A A_implies_B). this is the incorrect order.*) exact proof_of_B. Qed. Goal (forall A B : Prop, A\/B -> B\/A). Proof. intros. case H. intro. refine(or_intror _). exact H0. intro. refine(or_introl _). (*this one is different from above*) exact H0. Qed. Goal forall (a b:Prop), exists x:Prop, x -> (a->b) -> b. Proof. intros. (*We have an existence question. we can either prove it, with an example, prove it in a shady way, or disprove it.*) pose(example := a). (*We have our example, let us substitute in our goal.*) refine(ex_intro _ example _). (*refine(ex_intro function example _). more on documentation*) (*We eliminated the existencial condition. we proceed.*) intros. pose(H1 := H0 H). exact H1. Qed. (*We will need the following knowledge.*) Goal True. Proof. exact I. Qed. (*Let us make a tiny exercise.*) Lemma x_not_false_and_x_true : forall x:Prop, x <> False /\ x -> True. Proof. intros. destruct H as []. exact I. Qed. (*Little challenge for you.*) Theorem a_true_false : forall a:Prop, ((a->True)/\(a->False))->False. Proof. (*Write proof here*) Admitted. Goal ~exists x:Prop, x <> False /\ x -> False. Proof. intros. (*It may not tell you, but the negation of existence is for all. Let us use that.*) pose proof x_not_false_and_x_true as H. unfold not. intro. case H0. unfold not in H. (*Okay, now our lemma comes in place to help us. we will use the last two lemmas.*) intros. pose proof a_true_false as T. (*challenge lemma*) pose(s := ((x = False) -> False) /\ x). (*lets make a variable substitution.*) assert(s = (((x = False) -> False) /\ x)). intuition. (*do not forget that we need to prove both are equal.*) (*we are rewriting so that we get the shape that lemma T requires.*) rewrite <- H2 in H1. (*since our prior lemma is for all x, we need to specify one x.*) assert((((x = False) -> False) /\ x) -> True). apply H. rewrite <- H2 in H3. (*we make more asserts to finish with T*) assert((s -> True) /\ (s -> False)). intuition. assert(((s -> True) /\ (s -> False))->False). apply T. pose(finale := H5 H4). exact finale. Qed. (*Since the last proof was on the heavy end of a simple proof, we shall have a break to explore the nat set.*) Print nat. (*Inductive nat : Set := | O : nat | S : nat -> nat.*) (*We define nat as an inductive type, which constructors are O and S (uppercase O, not zero.*) Eval compute in 5 - 3. (*Every simple natural operation except division is defined. With subtraction there is a catch, 3 - 5 = 0.*) Eval compute in 3 - 5. Lemma sub_in_nat_is_weird : 3 - 5 = 0. Proof. simpl. (*This simplifies an expression.*) reflexivity. Qed. (*Proving in naturals function the same way as we did before.*) (*We define 3 as S(S(S(O))).*) Goal S(S(S(0))) = 3. Proof. reflexivity. Qed. (*let us define a function that detects a zero.*) Definition is_zero (n:nat) := (*parameters*) match n with (*works in a similar fashion of switch case*) | O => true (*if base constructor (aka 0), then true*) | S n' => false (* if it is a sucessor of any number, false*) end. Eval compute in is_zero 0. Compute is_zero 11. (*Let us create a definition*) Definition n_not_0 : forall n:nat, is_zero n = false -> n > 0. Admitted. Goal is_zero 0 = true. Proof. simpl. reflexivity. Qed. (*We can define recursive functions.*) Fixpoint evenb (n:nat) : bool := match n with | O => true | S O => false | S (S n') => evenb n' end. Eval compute in evenb 2. Compute evenb 4. (*Let us define some facts.*) Definition a0 : forall b:bool, negb b <> b. Proof. intro b. autounfold. case b. simpl. intro. discriminate. simpl. intro. discriminate. Qed. Definition a0_1 : forall b:bool, b <> negb b. Proof. intro b. autounfold. case b. simpl. intro. discriminate. simpl. intro. discriminate. Qed. Definition a1 : forall (n:nat), evenb n = evenb (n+2). Proof. (*Can you prove it?*) Admitted. Definition a2 : forall (n:nat), evenb n = negb (evenb(n+1)). Proof. (*Yet again another challenge.*) Admitted. Definition a2_1 : forall (n:nat), evenb n <> evenb(n+1). Proof. intro. pose proof a2 as a2. rewrite a2. pose proof a0 as a0. apply a0. Qed. Definition a2_2 : forall n:nat, evenb n = negb (evenb (n + 1)) <-> evenb n <> evenb(n+1). Proof. intro. unfold iff. refine(conj _ _). intro. rewrite H. pose proof a0 as a0. apply a0. intro. autounfold in H. (* did not work for me. destruct H as []. pose proof a2 as a2. rewrite a2. pose proof a0 as a0. pose(x := evenb(n+1)). assert(x = evenb(n+1)). auto. rewrite <- H. case x. simpl. assert(false <> true). intuition. discriminate.*) pose proof a2. apply H0. Qed. Goal 6 = 6. Proof. assert(forall x:nat, x = x). reflexivity. pose(x := 6). assert(6 = x). trivial. rewrite H0. apply H. Qed. Goal evenb 4 = evenb 6. Proof. pose proof a1 as hyp_1. apply hyp_1. Qed. Goal evenb 4 = evenb 820. Proof. pose proof a1 as hyp_1. apply hyp_1. Qed. Goal evenb 4 <> evenb 5. Proof. pose proof a2_1 as hyp_2. apply hyp_2. Qed. Goal evenb 7 = false. Proof. simpl. reflexivity. Qed. (*Here we start the real theorems!*) Theorem two_n_is_even : forall n:nat, evenb(2*n) = true. Proof. intro. elim n. simpl. reflexivity. intros. pose proof a1. rewrite H0 in H. assert(2* S n0 = 2*n0 + 2). auto. rewrite H1. exact H. Qed. (*This one will be really complicated to follow through.*) Theorem a3_1 : forall n:nat, evenb(2*n + 1) = false. Proof. intro. pose proof two_n_is_even as lem1. pose proof a2 as lem2. assert(forall n : nat, evenb (2*n) = negb (evenb (2*n + 1))). intro. pose(x:=2*n0). assert(2*n0 = x). auto. rewrite H. apply lem2. assert(negb(evenb (2 * n + 1)) = true). rewrite <- H. apply lem1. assert(forall b:bool, negb b = true -> b = false). intro b. case b. auto. auto. pose(x:=2 * n + 1). assert(x = 2 * n + 1). auto. rewrite <- H2. assert(negb(evenb(x)) = true). rewrite H2. exact H0. apply H1. exact H3. Qed. (*If you could figure out what was happening there, please tell me!!*) (*Let us stray away from evenb functions.*) Require Import Arith. (*We imported a library!*) Compute 5 mod 3. (*Now we can talk about notations. Let us define a notation.*) Notation "x ! y" := (y mod x =0) (at level 35). Compute 3 ! 7. Goal 3 ! 6. Proof. simpl. reflexivity. Qed. Goal ~ (3 ! 7). Proof. simpl. unfold not. intro. discriminate. Qed. Goal forall (x:nat) (k:nat), x ! (k * x). Proof. intros. elim k. simpl. assert(x * 0 = 0). intuition. admit. intros. simpl.