Datasets:
AI4M
/

text
stringlengths
0
3.34M
SUBROUTINE SN_WDAT ( isnfln, ihhmm, nlev, data, iret ) C************************************************************************ C* SN_WDAT * C* * C* This subroutine writes data to a sounding data file. The time * C* and station must both be set before this subroutine is called. * C* The station time will be stored if the station time flag, STMFLG, * C* was set when the file was created. This subroutine will only * C* write data to a merged data file. The subroutine SN_WPRT must be * C* used to write data to an unmerged file. * C* * C* SN_WDAT ( ISNFLN, IHHMM, NLEV, DATA, IRET ) * C* * C* Input parameters: * C* ISNFLN INTEGER Sounding file number * C* IHHMM INTEGER Station time (HHMM) * C* NLEV INTEGER Number of levels * C* DATA (*) REAL Sounding data array * C* * C* Output parameters: * C* IRET INTEGER Return code * C* 0 = normal return * C* -4 = file not open * C* -8 = station not set * C* -13 = DM error * C* -17 = invalid merge type * C** * C* Log: * C* M. desJardins/GSFC 8/87 * C************************************************************************ INCLUDE 'GEMPRM.PRM' INCLUDE 'GMBDTA.CMN' INCLUDE 'sncmn.cmn' C* REAL data (*) C------------------------------------------------------------------------ CALL SN_CHKF ( isnfln, iret ) IF ( iret .ne. 0 ) RETURN C C* Check that station has been set. C irow = krow ( isnfln ) icol = kcol ( isnfln ) IF ( ( irow .le. 0 ) .or. ( icol .le. 0 ) ) THEN iret = -8 RETURN END IF C C* Check that this is merged data. C IF ( .not. mrgtyp ( isnfln ) ) THEN iret = -17 RETURN END IF C C* Write out the data. C ndata = nlev * kparm ( isnfln ) CALL DM_WDTR ( isnfln, irow, icol, 'SNDT', ihhmm, data, ndata, + ier ) IF ( ier .ne. 0 ) THEN iret = -13 END IF C* RETURN END
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl ! This file was ported from Lean 3 source module topology.algebra.infinite_sum.order ! leanprover-community/mathlib commit 32253a1a1071173b33dc7d6a218cf722c6feb514 ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathlib.Algebra.Order.Archimedean import Mathlib.Topology.Algebra.InfiniteSum.Basic import Mathlib.Topology.Algebra.Order.Field import Mathlib.Topology.Algebra.Order.MonotoneConvergence /-! # Infinite sum in an order This file provides lemmas about the interaction of infinite sums and order operations. -/ open Finset Filter Function BigOperators open scoped Classical variable {ι κ α : Type _} section Preorder variable [Preorder α] [AddCommMonoid α] [TopologicalSpace α] [OrderClosedTopology α] [T2Space α] {f : ℕ → α} {c : α} theorem tsum_le_of_sum_range_le (hf : Summable f) (h : ∀ n, (∑ i in range n, f i) ≤ c) : (∑' n, f n) ≤ c := let ⟨_l, hl⟩ := hf hl.tsum_eq.symm ▸ le_of_tendsto' hl.tendsto_sum_nat h #align tsum_le_of_sum_range_le tsum_le_of_sum_range_le end Preorder section OrderedAddCommMonoid variable [OrderedAddCommMonoid α] [TopologicalSpace α] [OrderClosedTopology α] {f g : ι → α} {a a₁ a₂ : α} theorem hasSum_le (h : ∀ i, f i ≤ g i) (hf : HasSum f a₁) (hg : HasSum g a₂) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto' hf hg fun _ => sum_le_sum fun i _ => h i #align has_sum_le hasSum_le @[mono] theorem hasSum_mono (hf : HasSum f a₁) (hg : HasSum g a₂) (h : f ≤ g) : a₁ ≤ a₂ := hasSum_le h hf hg #align has_sum_mono hasSum_mono theorem hasSum_le_of_sum_le (hf : HasSum f a) (h : ∀ s, (∑ i in s, f i) ≤ a₂) : a ≤ a₂ := le_of_tendsto' hf h #align has_sum_le_of_sum_le hasSum_le_of_sum_le theorem le_hasSum_of_le_sum (hf : HasSum f a) (h : ∀ s, a₂ ≤ ∑ i in s, f i) : a₂ ≤ a := ge_of_tendsto' hf h #align le_has_sum_of_le_sum le_hasSum_of_le_sum theorem hasSum_le_inj {g : κ → α} (e : ι → κ) (he : Injective e) (hs : ∀ c, c ∉ Set.range e → 0 ≤ g c) (h : ∀ i, f i ≤ g (e i)) (hf : HasSum f a₁) (hg : HasSum g a₂) : a₁ ≤ a₂ := by rw [← hasSum_extend_zero he] at hf refine hasSum_le (fun c => ?_) hf hg obtain ⟨i, rfl⟩ | h := em (c ∈ Set.range e) · rw [he.extend_apply] exact h _ · rw [extend_apply' _ _ _ h] exact hs _ h #align has_sum_le_inj hasSum_le_inj theorem tsum_le_tsum_of_inj {g : κ → α} (e : ι → κ) (he : Injective e) (hs : ∀ c, c ∉ Set.range e → 0 ≤ g c) (h : ∀ i, f i ≤ g (e i)) (hf : Summable f) (hg : Summable g) : tsum f ≤ tsum g := hasSum_le_inj _ he hs h hf.hasSum hg.hasSum #align tsum_le_tsum_of_inj tsum_le_tsum_of_inj theorem sum_le_hasSum (s : Finset ι) (hs : ∀ i, i ∉ s → 0 ≤ f i) (hf : HasSum f a) : (∑ i in s, f i) ≤ a := ge_of_tendsto hf (eventually_atTop.2 ⟨s, fun _t hst => sum_le_sum_of_subset_of_nonneg hst fun i _ hbs => hs i hbs⟩) #align sum_le_has_sum sum_le_hasSum theorem isLUB_hasSum (h : ∀ i, 0 ≤ f i) (hf : HasSum f a) : IsLUB (Set.range fun s => ∑ i in s, f i) a := isLUB_of_tendsto_atTop (Finset.sum_mono_set_of_nonneg h) hf #align is_lub_has_sum isLUB_hasSum theorem le_hasSum (hf : HasSum f a) (i : ι) (hb : ∀ j, j ≠ i → 0 ≤ f j) : f i ≤ a := calc f i = ∑ i in {i}, f i := Finset.sum_singleton.symm _ ≤ a := sum_le_hasSum _ (by simpa) hf #align le_has_sum le_hasSum theorem sum_le_tsum {f : ι → α} (s : Finset ι) (hs : ∀ i, i ∉ s → 0 ≤ f i) (hf : Summable f) : (∑ i in s, f i) ≤ ∑' i, f i := sum_le_hasSum s hs hf.hasSum #align sum_le_tsum sum_le_tsum theorem le_tsum (hf : Summable f) (i : ι) (hb : ∀ j, j ≠ i → 0 ≤ f j) : f i ≤ ∑' i, f i := le_hasSum hf.hasSum i hb #align le_tsum le_tsum theorem tsum_le_tsum (h : ∀ i, f i ≤ g i) (hf : Summable f) (hg : Summable g) : (∑' i, f i) ≤ ∑' i, g i := hasSum_le h hf.hasSum hg.hasSum #align tsum_le_tsum tsum_le_tsum @[mono] theorem tsum_mono (hf : Summable f) (hg : Summable g) (h : f ≤ g) : (∑' n, f n) ≤ ∑' n, g n := tsum_le_tsum h hf hg #align tsum_mono tsum_mono theorem tsum_le_of_sum_le (hf : Summable f) (h : ∀ s, (∑ i in s, f i) ≤ a₂) : (∑' i, f i) ≤ a₂ := hasSum_le_of_sum_le hf.hasSum h #align tsum_le_of_sum_le tsum_le_of_sum_le theorem tsum_le_of_sum_le' (ha₂ : 0 ≤ a₂) (h : ∀ s, (∑ i in s, f i) ≤ a₂) : (∑' i, f i) ≤ a₂ := by by_cases hf : Summable f · exact tsum_le_of_sum_le hf h · rw [tsum_eq_zero_of_not_summable hf] exact ha₂ #align tsum_le_of_sum_le' tsum_le_of_sum_le' theorem HasSum.nonneg (h : ∀ i, 0 ≤ g i) (ha : HasSum g a) : 0 ≤ a := hasSum_le h hasSum_zero ha #align has_sum.nonneg HasSum.nonneg theorem HasSum.nonpos (h : ∀ i, g i ≤ 0) (ha : HasSum g a) : a ≤ 0 := hasSum_le h ha hasSum_zero #align has_sum.nonpos HasSum.nonpos theorem tsum_nonneg (h : ∀ i, 0 ≤ g i) : 0 ≤ ∑' i, g i := by by_cases hg : Summable g · exact hg.hasSum.nonneg h · rw [tsum_eq_zero_of_not_summable hg] #align tsum_nonneg tsum_nonneg theorem tsum_nonpos (h : ∀ i, f i ≤ 0) : (∑' i, f i) ≤ 0 := by by_cases hf : Summable f · exact hf.hasSum.nonpos h · rw [tsum_eq_zero_of_not_summable hf] #align tsum_nonpos tsum_nonpos -- porting note: generalized from `OrderedAddCommGroup` to `OrderedAddCommMonoid` theorem hasSum_zero_iff_of_nonneg (hf : ∀ i, 0 ≤ f i) : HasSum f 0 ↔ f = 0 := by refine' ⟨fun hf' => _, _⟩ · ext i exact (hf i).antisymm' (le_hasSum hf' _ fun j _ => hf j) · rintro rfl exact hasSum_zero #align has_sum_zero_iff_of_nonneg hasSum_zero_iff_of_nonneg end OrderedAddCommMonoid section OrderedAddCommGroup variable [OrderedAddCommGroup α] [TopologicalSpace α] [TopologicalAddGroup α] [OrderClosedTopology α] {f g : ι → α} {a₁ a₂ : α} {i : ι} theorem hasSum_lt (h : f ≤ g) (hi : f i < g i) (hf : HasSum f a₁) (hg : HasSum g a₂) : a₁ < a₂ := by have : update f i 0 ≤ update g i 0 := update_le_update_iff.mpr ⟨rfl.le, fun i _ => h i⟩ have : 0 - f i + a₁ ≤ 0 - g i + a₂ := hasSum_le this (hf.update i 0) (hg.update i 0) simpa only [zero_sub, add_neg_cancel_left] using add_lt_add_of_lt_of_le hi this #align has_sum_lt hasSum_lt @[mono] theorem hasSum_strict_mono (hf : HasSum f a₁) (hg : HasSum g a₂) (h : f < g) : a₁ < a₂ := let ⟨hle, _i, hi⟩ := Pi.lt_def.mp h hasSum_lt hle hi hf hg #align has_sum_strict_mono hasSum_strict_mono theorem tsum_lt_tsum (h : f ≤ g) (hi : f i < g i) (hf : Summable f) (hg : Summable g) : (∑' n, f n) < ∑' n, g n := hasSum_lt h hi hf.hasSum hg.hasSum #align tsum_lt_tsum tsum_lt_tsum @[mono] theorem tsum_strict_mono (hf : Summable f) (hg : Summable g) (h : f < g) : (∑' n, f n) < ∑' n, g n := let ⟨hle, _i, hi⟩ := Pi.lt_def.mp h tsum_lt_tsum hle hi hf hg #align tsum_strict_mono tsum_strict_mono theorem tsum_pos (hsum : Summable g) (hg : ∀ i, 0 ≤ g i) (i : ι) (hi : 0 < g i) : 0 < ∑' i, g i := by rw [← tsum_zero] exact tsum_lt_tsum hg hi summable_zero hsum #align tsum_pos tsum_pos end OrderedAddCommGroup section CanonicallyOrderedAddMonoid variable [CanonicallyOrderedAddMonoid α] [TopologicalSpace α] [OrderClosedTopology α] {f : ι → α} {a : α} theorem le_hasSum' (hf : HasSum f a) (i : ι) : f i ≤ a := le_hasSum hf i fun _ _ => zero_le _ #align le_has_sum' le_hasSum' theorem le_tsum' (hf : Summable f) (i : ι) : f i ≤ ∑' i, f i := le_tsum hf i fun _ _ => zero_le _ #align le_tsum' le_tsum' theorem hasSum_zero_iff : HasSum f 0 ↔ ∀ x, f x = 0 := (hasSum_zero_iff_of_nonneg fun _ => zero_le _).trans funext_iff #align has_sum_zero_iff hasSum_zero_iff theorem tsum_eq_zero_iff (hf : Summable f) : (∑' i, f i) = 0 ↔ ∀ x, f x = 0 := by rw [← hasSum_zero_iff, hf.hasSum_iff] #align tsum_eq_zero_iff tsum_eq_zero_iff theorem tsum_ne_zero_iff (hf : Summable f) : (∑' i, f i) ≠ 0 ↔ ∃ x, f x ≠ 0 := by rw [Ne.def, tsum_eq_zero_iff hf, not_forall] #align tsum_ne_zero_iff tsum_ne_zero_iff theorem isLUB_hasSum' (hf : HasSum f a) : IsLUB (Set.range fun s => ∑ i in s, f i) a := isLUB_of_tendsto_atTop (Finset.sum_mono_set f) hf #align is_lub_has_sum' isLUB_hasSum' end CanonicallyOrderedAddMonoid section LinearOrder /-! For infinite sums taking values in a linearly ordered monoid, the existence of a least upper bound for the finite sums is a criterion for summability. This criterion is useful when applied in a linearly ordered monoid which is also a complete or conditionally complete linear order, such as `ℝ`, `ℝ≥0`, `ℝ≥0∞`, because it is then easy to check the existence of a least upper bound. -/ theorem hasSum_of_isLUB_of_nonneg [LinearOrderedAddCommMonoid α] [TopologicalSpace α] [OrderTopology α] {f : ι → α} (i : α) (h : ∀ i, 0 ≤ f i) (hf : IsLUB (Set.range fun s => ∑ i in s, f i) i) : HasSum f i := tendsto_atTop_isLUB (Finset.sum_mono_set_of_nonneg h) hf #align has_sum_of_is_lub_of_nonneg hasSum_of_isLUB_of_nonneg theorem hasSum_of_isLUB [CanonicallyLinearOrderedAddMonoid α] [TopologicalSpace α] [OrderTopology α] {f : ι → α} (b : α) (hf : IsLUB (Set.range fun s => ∑ i in s, f i) b) : HasSum f b := tendsto_atTop_isLUB (Finset.sum_mono_set f) hf #align has_sum_of_is_lub hasSum_of_isLUB theorem summable_abs_iff [LinearOrderedAddCommGroup α] [UniformSpace α] [UniformAddGroup α] [CompleteSpace α] {f : ι → α} : (Summable fun x => |f x|) ↔ Summable f := let s := { x | 0 ≤ f x } have h1 : ∀ x : s, |f x| = f x := fun x => abs_of_nonneg x.2 have h2 : ∀ x : ↑(sᶜ), |f x| = -f x := fun x => abs_of_neg (not_le.1 x.2) calc (Summable fun x => |f x|) ↔ (Summable fun x : s => |f x|) ∧ Summable fun x : ↑(sᶜ) => |f x| := summable_subtype_and_compl.symm _ ↔ (Summable fun x : s => f x) ∧ Summable fun x : ↑(sᶜ) => -f x := by simp only [h1, h2] _ ↔ Summable f := by simp only [summable_neg_iff, summable_subtype_and_compl] #align summable_abs_iff summable_abs_iff alias summable_abs_iff ↔ Summable.of_abs Summable.abs #align summable.of_abs Summable.of_abs #align summable.abs Summable.abs theorem Finite.of_summable_const [LinearOrderedAddCommGroup α] [TopologicalSpace α] [Archimedean α] [OrderClosedTopology α] {b : α} (hb : 0 < b) (hf : Summable fun _ : ι => b) : Finite ι := by have H : ∀ s : Finset ι, s.card • b ≤ ∑' _i : ι, b := fun s => by simpa using sum_le_hasSum s (fun a _ => hb.le) hf.hasSum obtain ⟨n, hn⟩ := Archimedean.arch (∑' _i : ι, b) hb have : ∀ s : Finset ι, s.card ≤ n := fun s => by simpa [nsmul_le_nsmul_iff hb] using (H s).trans hn have : Fintype ι := fintypeOfFinsetCardLe n this infer_instance theorem Set.Finite.of_summable_const [LinearOrderedAddCommGroup α] [TopologicalSpace α] [Archimedean α] [OrderClosedTopology α] {b : α} (hb : 0 < b) (hf : Summable fun _ : ι => b) : (Set.univ : Set ι).Finite := finite_univ_iff.2 <| .of_summable_const hb hf #align finite_of_summable_const Set.Finite.of_summable_const end LinearOrder theorem Summable.tendsto_atTop_of_pos [LinearOrderedField α] [TopologicalSpace α] [OrderTopology α] {f : ℕ → α} (hf : Summable f⁻¹) (hf' : ∀ n, 0 < f n) : Tendsto f atTop atTop := inv_inv f ▸ Filter.Tendsto.inv_tendsto_zero <| tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _ hf.tendsto_atTop_zero <| eventually_of_forall fun _ => inv_pos.2 (hf' _) #align summable.tendsto_top_of_pos Summable.tendsto_atTop_of_pos
/- Copyright (c) 2014 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Author: Floris van Doorn -/ import .basic algebra.relation algebra.binary open eq eq.ops category namespace morphism variables {ob : Type} [C : category ob] include C variables {a b c : ob} {g : b ⟶ c} {f : a ⟶ b} {h : b ⟶ a} inductive is_section [class] (f : a ⟶ b) : Type := mk : ∀{g}, g ∘ f = id → is_section f inductive is_retraction [class] (f : a ⟶ b) : Type := mk : ∀{g}, f ∘ g = id → is_retraction f inductive is_iso [class] (f : a ⟶ b) : Type := mk : ∀{g}, g ∘ f = id → f ∘ g = id → is_iso f attribute is_iso [multiple_instances] definition retraction_of (f : a ⟶ b) [H : is_section f] : hom b a := is_section.rec (λg h, g) H definition section_of (f : a ⟶ b) [H : is_retraction f] : hom b a := is_retraction.rec (λg h, g) H definition inverse (f : a ⟶ b) [H : is_iso f] : hom b a := is_iso.rec (λg h1 h2, g) H postfix `⁻¹` := inverse theorem inverse_compose (f : a ⟶ b) [H : is_iso f] : f⁻¹ ∘ f = id := is_iso.rec (λg h1 h2, h1) H theorem compose_inverse (f : a ⟶ b) [H : is_iso f] : f ∘ f⁻¹ = id := is_iso.rec (λg h1 h2, h2) H theorem retraction_compose (f : a ⟶ b) [H : is_section f] : retraction_of f ∘ f = id := is_section.rec (λg h, h) H theorem compose_section (f : a ⟶ b) [H : is_retraction f] : f ∘ section_of f = id := is_retraction.rec (λg h, h) H theorem iso_imp_retraction [instance] (f : a ⟶ b) [H : is_iso f] : is_section f := is_section.mk !inverse_compose theorem iso_imp_section [instance] (f : a ⟶ b) [H : is_iso f] : is_retraction f := is_retraction.mk !compose_inverse theorem id_is_iso [instance] : is_iso (ID a) := is_iso.mk !id_compose !id_compose theorem inverse_is_iso [instance] (f : a ⟶ b) [H : is_iso f] : is_iso (f⁻¹) := is_iso.mk !compose_inverse !inverse_compose theorem left_inverse_eq_right_inverse {f : a ⟶ b} {g g' : hom b a} (Hl : g ∘ f = id) (Hr : f ∘ g' = id) : g = g' := calc g = g ∘ id : by rewrite id_right ... = g ∘ f ∘ g' : by rewrite -Hr ... = (g ∘ f) ∘ g' : by rewrite assoc ... = id ∘ g' : by rewrite Hl ... = g' : by rewrite id_left theorem retraction_eq_intro [H : is_section f] (H2 : f ∘ h = id) : retraction_of f = h := left_inverse_eq_right_inverse !retraction_compose H2 theorem section_eq_intro [H : is_retraction f] (H2 : h ∘ f = id) : section_of f = h := symm (left_inverse_eq_right_inverse H2 !compose_section) theorem inverse_eq_intro_right [H : is_iso f] (H2 : f ∘ h = id) : f⁻¹ = h := left_inverse_eq_right_inverse !inverse_compose H2 theorem inverse_eq_intro_left [H : is_iso f] (H2 : h ∘ f = id) : f⁻¹ = h := symm (left_inverse_eq_right_inverse H2 !compose_inverse) theorem section_eq_retraction (f : a ⟶ b) [Hl : is_section f] [Hr : is_retraction f] : retraction_of f = section_of f := retraction_eq_intro !compose_section theorem section_retraction_imp_iso (f : a ⟶ b) [Hl : is_section f] [Hr : is_retraction f] : is_iso f := is_iso.mk (subst (section_eq_retraction f) (retraction_compose f)) (compose_section f) theorem inverse_unique (H H' : is_iso f) : @inverse _ _ _ _ f H = @inverse _ _ _ _ f H' := inverse_eq_intro_left !inverse_compose theorem inverse_involutive (f : a ⟶ b) [H : is_iso f] : (f⁻¹)⁻¹ = f := inverse_eq_intro_right !inverse_compose theorem retraction_of_id : retraction_of (ID a) = id := retraction_eq_intro !id_compose theorem section_of_id : section_of (ID a) = id := section_eq_intro !id_compose theorem iso_of_id : (ID a)⁻¹ = id := inverse_eq_intro_left !id_compose theorem composition_is_section [instance] [Hf : is_section f] [Hg : is_section g] : is_section (g ∘ f) := is_section.mk (calc (retraction_of f ∘ retraction_of g) ∘ g ∘ f = retraction_of f ∘ retraction_of g ∘ g ∘ f : by rewrite -assoc ... = retraction_of f ∘ (retraction_of g ∘ g) ∘ f : by rewrite (assoc _ g f) ... = retraction_of f ∘ id ∘ f : by rewrite retraction_compose ... = retraction_of f ∘ f : by rewrite id_left ... = id : by rewrite retraction_compose) theorem composition_is_retraction [instance] [Hf : is_retraction f] [Hg : is_retraction g] : is_retraction (g ∘ f) := is_retraction.mk (calc (g ∘ f) ∘ section_of f ∘ section_of g = g ∘ f ∘ section_of f ∘ section_of g : by rewrite -assoc ... = g ∘ (f ∘ section_of f) ∘ section_of g : by rewrite -assoc ... = g ∘ id ∘ section_of g : by rewrite compose_section ... = g ∘ section_of g : by rewrite id_left ... = id : by rewrite compose_section) theorem composition_is_inverse [instance] [Hf : is_iso f] [Hg : is_iso g] : is_iso (g ∘ f) := !section_retraction_imp_iso structure isomorphic (a b : ob) := (iso : a ⟶ b) [is_iso : is_iso iso] infix `≅`:50 := morphism.isomorphic namespace isomorphic open relation attribute is_iso [instance] theorem refl (a : ob) : a ≅ a := mk id theorem symm ⦃a b : ob⦄ (H : a ≅ b) : b ≅ a := mk (inverse (iso H)) theorem trans ⦃a b c : ob⦄ (H1 : a ≅ b) (H2 : b ≅ c) : a ≅ c := mk (iso H2 ∘ iso H1) theorem is_equivalence_eq [instance] (T : Type) : is_equivalence (isomorphic : ob → ob → Type) := is_equivalence.mk refl symm trans end isomorphic inductive is_mono [class] (f : a ⟶ b) : Prop := mk : (∀c (g h : hom c a), f ∘ g = f ∘ h → g = h) → is_mono f inductive is_epi [class] (f : a ⟶ b) : Prop := mk : (∀c (g h : hom b c), g ∘ f = h ∘ f → g = h) → is_epi f theorem mono_elim [H : is_mono f] {g h : c ⟶ a} (H2 : f ∘ g = f ∘ h) : g = h := match H with is_mono.mk H3 := H3 c g h H2 end theorem epi_elim [H : is_epi f] {g h : b ⟶ c} (H2 : g ∘ f = h ∘ f) : g = h := match H with is_epi.mk H3 := H3 c g h H2 end theorem section_is_mono [instance] (f : a ⟶ b) [H : is_section f] : is_mono f := is_mono.mk (λ c g h H, calc g = id ∘ g : by rewrite id_left ... = (retraction_of f ∘ f) ∘ g : by rewrite -(retraction_compose f) ... = (retraction_of f ∘ f) ∘ h : by rewrite [-assoc, H, -assoc] ... = id ∘ h : by rewrite retraction_compose ... = h : by rewrite id_left) theorem retraction_is_epi [instance] (f : a ⟶ b) [H : is_retraction f] : is_epi f := is_epi.mk (λ c g h H, calc g = g ∘ id : by rewrite id_right ... = g ∘ f ∘ section_of f : by rewrite -(compose_section f) ... = h ∘ f ∘ section_of f : by rewrite [assoc, H, -assoc] ... = h ∘ id : by rewrite compose_section ... = h : by rewrite id_right) --these theorems are now proven automatically using type classes --should they be instances? theorem id_is_mono : is_mono (ID a) theorem id_is_epi : is_epi (ID a) theorem composition_is_mono [instance] [Hf : is_mono f] [Hg : is_mono g] : is_mono (g ∘ f) := is_mono.mk (λ d h₁ h₂ H, have H2 : g ∘ (f ∘ h₁) = g ∘ (f ∘ h₂), begin rewrite *assoc, exact H end, mono_elim (mono_elim H2)) theorem composition_is_epi [instance] [Hf : is_epi f] [Hg : is_epi g] : is_epi (g ∘ f) := is_epi.mk (λ d h₁ h₂ H, have H2 : (h₁ ∘ g) ∘ f = (h₂ ∘ g) ∘ f, begin rewrite -*assoc, exact H end, epi_elim (epi_elim H2)) end morphism namespace morphism --rewrite lemmas for inverses, modified from --https://github.com/JasonGross/HoTT-categories/blob/master/theories/Categories/Category/Morphisms.v namespace iso section variables {ob : Type} [C : category ob] include C variables {a b c d : ob} variables (f : b ⟶ a) (r : c ⟶ d) (q : b ⟶ c) (p : a ⟶ b) variables (g : d ⟶ c) variable [Hq : is_iso q] include Hq theorem compose_pV : q ∘ q⁻¹ = id := !compose_inverse theorem compose_Vp : q⁻¹ ∘ q = id := !inverse_compose theorem compose_V_pp : q⁻¹ ∘ (q ∘ p) = p := calc q⁻¹ ∘ (q ∘ p) = (q⁻¹ ∘ q) ∘ p : by rewrite assoc ... = id ∘ p : by rewrite inverse_compose ... = p : by rewrite id_left theorem compose_p_Vp : q ∘ (q⁻¹ ∘ g) = g := calc q ∘ (q⁻¹ ∘ g) = (q ∘ q⁻¹) ∘ g : by rewrite assoc ... = id ∘ g : by rewrite compose_inverse ... = g : by rewrite id_left theorem compose_pp_V : (r ∘ q) ∘ q⁻¹ = r := calc (r ∘ q) ∘ q⁻¹ = r ∘ q ∘ q⁻¹ : by rewrite assoc ... = r ∘ id : by rewrite compose_inverse ... = r : by rewrite id_right theorem compose_pV_p : (f ∘ q⁻¹) ∘ q = f := calc (f ∘ q⁻¹) ∘ q = f ∘ q⁻¹ ∘ q : by rewrite assoc ... = f ∘ id : by rewrite inverse_compose ... = f : by rewrite id_right theorem inv_pp [H' : is_iso p] : (q ∘ p)⁻¹ = p⁻¹ ∘ q⁻¹ := inverse_eq_intro_left (show (p⁻¹ ∘ (q⁻¹)) ∘ q ∘ p = id, from by rewrite [-assoc, compose_V_pp, inverse_compose]) theorem inv_Vp [H' : is_iso g] : (q⁻¹ ∘ g)⁻¹ = g⁻¹ ∘ q := inverse_involutive q ▸ inv_pp (q⁻¹) g theorem inv_pV [H' : is_iso f] : (q ∘ f⁻¹)⁻¹ = f ∘ q⁻¹ := inverse_involutive f ▸ inv_pp q (f⁻¹) theorem inv_VV [H' : is_iso r] : (q⁻¹ ∘ r⁻¹)⁻¹ = r ∘ q := inverse_involutive r ▸ inv_Vp q (r⁻¹) end section variables {ob : Type} {C : category ob} include C variables {d c b a : ob} variables {i : b ⟶ c} {f : b ⟶ a} {r : c ⟶ d} {q : b ⟶ c} {p : a ⟶ b} {g : d ⟶ c} {h : c ⟶ b} {x : b ⟶ d} {z : a ⟶ c} {y : d ⟶ b} {w : c ⟶ a} variable [Hq : is_iso q] include Hq theorem moveR_Mp (H : y = q⁻¹ ∘ g) : q ∘ y = g := H⁻¹ ▸ compose_p_Vp q g theorem moveR_pM (H : w = f ∘ q⁻¹) : w ∘ q = f := H⁻¹ ▸ compose_pV_p f q theorem moveR_Vp (H : z = q ∘ p) : q⁻¹ ∘ z = p := H⁻¹ ▸ compose_V_pp q p theorem moveR_pV (H : x = r ∘ q) : x ∘ q⁻¹ = r := H⁻¹ ▸ compose_pp_V r q theorem moveL_Mp (H : q⁻¹ ∘ g = y) : g = q ∘ y := (moveR_Mp (H⁻¹))⁻¹ theorem moveL_pM (H : f ∘ q⁻¹ = w) : f = w ∘ q := (moveR_pM (H⁻¹))⁻¹ theorem moveL_Vp (H : q ∘ p = z) : p = q⁻¹ ∘ z := (moveR_Vp (H⁻¹))⁻¹ theorem moveL_pV (H : r ∘ q = x) : r = x ∘ q⁻¹ := (moveR_pV (H⁻¹))⁻¹ theorem moveL_1V (H : h ∘ q = id) : h = q⁻¹ := (inverse_eq_intro_left H)⁻¹ theorem moveL_V1 (H : q ∘ h = id) : h = q⁻¹ := (inverse_eq_intro_right H)⁻¹ theorem moveL_1M (H : i ∘ q⁻¹ = id) : i = q := moveL_1V H ⬝ inverse_involutive q theorem moveL_M1 (H : q⁻¹ ∘ i = id) : i = q := moveL_V1 H ⬝ inverse_involutive q theorem moveR_1M (H : id = i ∘ q⁻¹) : q = i := (moveL_1M (H⁻¹))⁻¹ theorem moveR_M1 (H : id = q⁻¹ ∘ i) : q = i := (moveL_M1 (H⁻¹))⁻¹ theorem moveR_1V (H : id = h ∘ q) : q⁻¹ = h := (moveL_1V (H⁻¹))⁻¹ theorem moveR_V1 (H : id = q ∘ h) : q⁻¹ = h := (moveL_V1 (H⁻¹))⁻¹ end end iso end morphism
filters = haar_filter_bank_2d_spatial; % Initialize signal and meta x = uiuc_sample; U{1}.signal{1} = x; U{1}.meta.j = zeros(0,1); options.J = 5; [A2, W2] = wavelet_layer_2d_pyramid(U{1}, filters, options) U2 = modulus_layer(W2); %% clear x = uiuc_sample; filt_opt.type = 'haar'; scat_opt.J = 5; scat_opt.M = 3; Wop = wavelet_factory_2d_pyramid(filt_opt, scat_opt); Sx = scat(x, Wop);
import analysis.exponential analysis.polynomial import ring_theory.prime_count open complex polynomial finset -- inductive lep (p : polynomial ℂ) : polynomial ℂ → Prop -- | C_mul : ∀ {a}, a ≠ 0 → lep (C a * p) -- | mul : ∀ {q}, lep q → lep (q * X) -- | add : ∀ {q} {a}, lep q → q ≠ -C a → lep (q + C a) -- inductive ltp (p : polynomial ℂ) : polynomial ℂ → Prop -- | mul_X : p ≠ 0 → ltp (p * X) -- | mul_C : ∀ {a q}, a ≠ 0 → ltp q → ltp (C a * q) -- | add : ∀ {q} {a}, ltp q → q.eval 0 ≠ a → ltp (q + C a) -- inductive ltp' : polynomial ℂ → polynomial ℂ → Prop -- | mul_X : ∀ {p}, p ≠ 0 → ltp' p (p * X) -- | mul_C : ∀ {p q a}, a ≠ 0 → ltp' p q → ltp' p (C a * q) -- | add : ∀ {p q a}, ltp' p q → q.eval 0 ≠ a → ltp' p (q + C a) -- lemma growth_lemma_chris1 {p q : polynomial ℂ} (hpq : ltp p q) : -- ∃ r : ℝ, ∀ z : ℂ, r < z.abs → -- abs (p.eval z) < abs (q.eval z) := -- ltp.rec_on hpq -- (λ hq g hpq, ⟨1, λ z hz, by rw [eval_mul, eval_X, complex.abs_mul]; -- exact _⟩) -- _ -- (λ q a hqp hpa ih p, _) -- lemma growth_lemma_chris1 {p q : polynomial ℂ} (hpq : ltp' q p) : -- ∃ r : ℝ, ∀ z : ℂ, r < z.abs → abs (q.eval z) < abs (p.eval z) := -- ltp'.rec_on hpq -- _ -- _ -- (λ p a hqp hpa _, _) -- example : ∀ p : polynomial ℂ, ¬less_than p 0 := -- λ p h, less_than.rec_on h _ _ _ -- lemma polynomial_tendsto_infinity : ∀ {p : polynomial ℂ}, 0 < degree p → -- ∀ x : ℝ, ∃ r : ℝ, ∀ z : ℂ, r < z.abs → x < (p.eval z).abs -- | p := λ hp x, if h : degree p = 1 -- then -- let ⟨n, hn⟩ := archimedean.arch (1 : ℝ) -- (show 0 < abs (leading_coeff p), -- from abs_pos.2 (λ hp0, by simp * at *; contradiction)) in -- ⟨↑n * abs (p.eval 0) + n * (_root_.abs x), λ z hz, -- calc x ≤ _root_.abs x : le_abs_self _ -- ... < abs (p.eval z) : lt_of_mul_lt_mul_left -- (calc (n : ℝ) * _root_.abs x < abs z - n * abs (eval 0 p) : -- lt_sub_iff_add_lt'.2 hz -- ... ≤ n * abs (leading_coeff p * z) - n * abs (p.eval 0) : -- sub_le_sub_right (by rw [complex.abs_mul, ← mul_assoc]; -- exact le_mul_of_ge_one_left (complex.abs_nonneg _) -- (by simpa [mul_comm, add_monoid.smul_eq_mul] using hn)) _ -- ... = ↑n * (abs (leading_coeff p * z) - abs (-eval 0 p)) : by simp [mul_add] -- ... ≤ ↑n * (abs (leading_coeff p * z - -eval 0 p)) : -- mul_le_mul_of_nonneg_left -- (le_trans (le_abs_self _) (complex.abs_abs_sub_le_abs_sub _ _)) -- (nat.cast_nonneg n) -- ... = ↑n * abs (p.eval z) : -- by conv_rhs {rw degree_eq_one h}; simp [coeff_zero_eq_eval_zero]) -- (nat.cast_nonneg n)⟩ -- else -- have wf : degree (p /ₘ X) < degree p, -- from degree_div_by_monic_lt _ monic_X (λ hp0, by simp * at *) -- (by rw degree_X; exact dec_trivial), -- have hp : 1 < degree p, from match degree p, hp, h with -- | none := dec_trivial -- | (some n) := λ h0 h1, lt_of_le_of_ne (with_bot.coe_le_coe.2 (with_bot.coe_lt_coe.1 h0)) (ne.symm h1) -- end, -- have hXp : degree X ≤ degree p, from le_of_lt (by rw @degree_X ℂ; exact hp), -- let ⟨r, hr⟩ := @polynomial_tendsto_infinity (p /ₘ X) -- (@lt_of_add_lt_add_left' _ _ (1 : with_bot ℕ) _ _ -- (calc (1 : with_bot ℕ) + 0 < degree p : hp -- ... = 1 + degree (p /ₘ X) : by rw [← @degree_X ℂ, degree_add_div_by_monic monic_X hXp])) -- (x + (p.eval 0).abs) in -- ⟨max 1 (r + (p.eval 0).abs), λ z hz, -- calc x < abs (eval z (p /ₘ X)) - abs (eval 0 p) : -- lt_sub_iff_add_lt.2 (hr z (lt_of_le_of_lt (le_add_of_nonneg_right (complex.abs_nonneg _)) -- (lt_of_le_of_lt (le_max_right _ _) hz))) -- ... ≤ abs z * abs (eval z (p /ₘ X)) - abs (eval 0 p) : -- sub_le_sub_right (le_mul_of_ge_one_left (complex.abs_nonneg _) (le_trans (le_max_left _ _) (le_of_lt hz))) _ -- ... ≤ _root_.abs (abs (z * eval z (p /ₘ X)) - abs (-eval 0 p)) : by rw [complex.abs_neg, ← complex.abs_mul]; -- exact le_abs_self _ -- ... ≤ abs (z * eval z (p /ₘ X) - -eval 0 p) : abs_abs_sub_le_abs_sub _ _ -- ... = abs (eval z p) : by conv_rhs {rw ← mod_by_monic_add_div p monic_X}; -- simp [coeff_zero_eq_eval_zero, mod_by_monic_X]⟩ -- using_well_founded {dec_tac := tactic.assumption} -- @[elab_as_eliminator] protected lemma induction_on {M : polynomial ℂ → Prop} (p : polynomial ℂ ) -- (h_C : ∀a, M (C a)) -- (h_add : ∀p q, M p → M q → M (p + q)) -- (h_monomial : ∀(n : ℕ) (a : ℂ), M (C a * X^n) → M (C a * X^(n+1))) : -- M p := -- have ∀{n:ℕ} {a}, M (C a * X^n), -- begin -- assume n a, -- induction n with n ih, -- { simp only [pow_zero, mul_one, h_C] }, -- { exact h_monomial _ _ ih } -- end, -- finsupp.induction p -- (suffices M (C 0), by simpa only [C, single_zero], -- h_C 0) -- (assume n a p _ _ hp, suffices M (C a * X^n + p), by rwa [single_eq_C_mul_X], -- h_add _ _ this hp) inductive nonconstant : polynomial ℂ → Prop | X : ∀ {a}, a ≠ 0 → nonconstant (C a * X) | mul : ∀ {p}, nonconstant p → nonconstant (p * X) | add : ∀ {p} (a), nonconstant p → nonconstant (p + C a) lemma nonconstant_of_degree_pos : ∀ {p : polynomial ℂ}, 0 < degree p → nonconstant p | p := λ h, have wf : degree (p /ₘ X) < degree p, from degree_div_by_monic_lt _ monic_X (λ hp0, by simp [hp0, lt_irrefl, *] at *) (by rw degree_X; exact dec_trivial), by rw [← mod_by_monic_add_div p monic_X, add_comm, mod_by_monic_X, mul_comm] at *; exact nonconstant.add _ (if hpX : 0 < degree (p /ₘ X) then nonconstant.mul (nonconstant_of_degree_pos hpX) else by rw [eq_C_of_degree_le_zero (not_lt.1 hpX)] at *; exact if hc : coeff (p /ₘ X) 0 = 0 then by simpa [hc, not_lt_of_ge degree_C_le] using h else nonconstant.X hc) using_well_founded {dec_tac := tactic.assumption} lemma polynomial_tendsto_infinity' {p : polynomial ℂ} (h : 0 < degree p) : ∀ x : ℝ, ∃ r : ℝ, ∀ z : ℂ, r < z.abs → x < (p.eval z).abs := nonconstant.rec_on (nonconstant_of_degree_pos h) (λ a ha x, ⟨x / a.abs, λ z hz, by simpa [(div_lt_iff' (complex.abs_pos.2 ha)).symm]⟩) (λ p hp ih x, let ⟨r, hr⟩ := ih x in ⟨max r 1, λ z hz, by rw [eval_mul, eval_X, complex.abs_mul]; exact lt_of_lt_of_le (hr z (lt_of_le_of_lt (le_max_left _ _) hz)) (le_mul_of_ge_one_right (complex.abs_nonneg _) (le_trans (le_max_right _ _) (le_of_lt hz)))⟩) (λ p a hp ih x, let ⟨r, hr⟩ := ih (x + a.abs) in ⟨r, λ z hz, by rw [eval_add, eval_C, ← sub_neg_eq_add]; exact lt_of_lt_of_le (lt_sub_iff_add_lt.2 (by rw complex.abs_neg; exact (hr z hz))) (le_trans (le_abs_self _) (complex.abs_abs_sub_le_abs_sub _ _))⟩) lemma polynomial.is_unit_iff {p : polynomial ℂ} : is_unit p ↔ degree p = 0 := ⟨λ h, let ⟨q, hq⟩ := is_unit_iff_dvd_one.1 h in have hp0 : p ≠ 0, from λ hp0, by simpa [hp0] using hq, have hq0 : q ≠ 0, from λ hp0, by simpa [hp0] using hq, have nat_degree (1 : polynomial ℂ) = nat_degree (p * q), from congr_arg _ hq, by rw [nat_degree_one, nat_degree_mul_eq hp0 hq0, eq_comm, add_eq_zero_iff, ← with_bot.coe_eq_coe, ← degree_eq_nat_degree hp0] at this; exact this.1, λ h, have degree p ≤ 0, by simp [*, le_refl], have hc : coeff p 0 ≠ 0, from λ hc, by rw [eq_C_of_degree_le_zero this, hc] at h; simpa using h, is_unit_iff_dvd_one.2 ⟨C (coeff p 0)⁻¹, begin conv in p { rw eq_C_of_degree_le_zero this }, rw [← C_mul, _root_.mul_inv_cancel hc, C_1] end⟩⟩ instance decidable_dvd {α : Type*} [comm_ring α] [decidable_eq α] : decidable_rel ((∣) : polynomial α → polynomial α → Prop) := sorry lemma polynomial.finite_of_degree_pos {α : Type*} [integral_domain α] [decidable_eq α] {p q : polynomial α} (hp : (0 : with_bot ℕ) < degree p) (hq : q ≠ 0) : prime_count.finite p q := ⟨nat_degree q, λ ⟨r, hr⟩, have hp0 : p ≠ 0, from λ hp0, by simp [hp0] at hp; contradiction, have hr0 : r ≠ 0, from λ hr0, by simp * at *, have hpn0 : p ^ (nat_degree q + 1) ≠ 0, from pow_ne_zero _ hp0, have hnp : 0 < nat_degree p, by rw [← with_bot.coe_lt_coe, ← degree_eq_nat_degree hp0]; exact hp, begin have := congr_arg nat_degree hr, rw [nat_degree_mul_eq hpn0 hr0, nat_degree_pow_eq, add_mul, add_assoc] at this, exact ne_of_lt (lt_add_of_le_of_pos (le_mul_of_ge_one_right' (nat.zero_le _) hnp) (add_pos_of_pos_of_nonneg (by rwa one_mul) (nat.zero_le _))) this end⟩ def polynomial.multiplicity {α : Type*} [integral_domain α] [decidable_eq α] (p : polynomial α) (a : α) : ℕ := if h0 : p = 0 then 0 else (prime_count (X - C a) p).get (polynomial.finite_of_degree_pos (by rw degree_X_sub_C; exact dec_trivial) h0) lemma pow_multiplicity_dvd {α : Type*} [integral_domain α] [decidable_eq α] (p : polynomial α) (a : α) : (X - C a) ^ polynomial.multiplicity p a ∣ p := if h : p = 0 then by simp [h] else by rw [polynomial.multiplicity, dif_neg h]; exact prime_count.spec _ lemma div_by_monic_mul_pow_multiplicity_eq {α : Type*} [integral_domain α] [decidable_eq α] (p : polynomial α) (a : α) : p /ₘ ((X - C a) ^ polynomial.multiplicity p a) * (X - C a) ^ polynomial.multiplicity p a = p := have monic ((X - C a) ^ polynomial.multiplicity p a), from by rw [monic.def, leading_coeff_pow, (show _ = _, from monic_X_sub_C _), one_pow], by conv_rhs { rw [← mod_by_monic_add_div p this, (dvd_iff_mod_by_monic_eq_zero this).2 (pow_multiplicity_dvd _ _)] }; simp [mul_comm] lemma eval_div_by_monic_pow_multiplicity_ne_zero {α : Type*} [integral_domain α] [decidable_eq α] {p : polynomial α} (a : α) (hp : p ≠ 0) : (p /ₘ ((X - C a) ^ polynomial.multiplicity p a)).eval a ≠ 0 := mt dvd_iff_is_root.2 $ λ ⟨q, hq⟩, begin have := div_by_monic_mul_pow_multiplicity_eq p a, rw [mul_comm, hq, ← mul_assoc, ← pow_succ', polynomial.multiplicity, dif_neg hp] at this, refine prime_count.is_greatest' (polynomial.finite_of_degree_pos (show (0 : with_bot ℕ) < degree (X - C a), by rw degree_X_sub_C; exact dec_trivial) hp) (nat.lt_succ_self _) (dvd_of_mul_right_eq _ this) end axiom attains_infi (p : polynomial ℂ) : ∃ x, (p.eval x).abs = ⨅ y, (p.eval y).abs axiom nth_root (n : ℕ) (z : ℂ) : ℂ axiom nth_root_pow (n : ℕ) (z : ℂ) : nth_root n z ^ n = z axiom abs_nth_root (n : ℕ) (z : ℂ) : abs (nth_root n z) = real.nth_root (abs z) n #print real.nth_root open euclidean_domain local attribute [instance, priority 0] classical.prop_decidable set_option trace.simplify.rewrite true lemma FTA {f : polynomial ℂ} (hf : 0 < degree f) : ∃ z : ℂ, is_root f z := let ⟨z₀, hz₀⟩ := attains_infi f in exists.intro z₀ $ by_contradiction $ λ hf0, have hfX : f - C (f.eval z₀) ≠ 0, from mt sub_eq_zero.1 (λ h, not_le_of_gt hf (h.symm ▸ degree_C_le)), let n := polynomial.multiplicity (f - C (f.eval z₀)) z₀ in let g := (f - C (f.eval z₀)) /ₘ ((X - C z₀) ^ n) in have hg0 : g.eval z₀ ≠ 0, from eval_div_by_monic_pow_multiplicity_ne_zero _ hfX, have hg : g * (X - C z₀) ^ n = f - C (f.eval z₀), from div_by_monic_mul_pow_multiplicity_eq _ _, have hn0 : 0 < n, from nat.pos_of_ne_zero $ λ hn0, by simpa [g, hn0] using hg0, let ⟨δ', hδ'₁, hδ'₂⟩ := continuous_of_metric.1 (polynomial.continuous_eval g) z₀ ((g.eval z₀).abs) (complex.abs_pos.2 hg0) in let δ := min (min (δ' / 2) 1) (((f.eval z₀).abs / (g.eval z₀).abs) / 2) in have hf0' : 0 < (f.eval z₀).abs, from complex.abs_pos.2 hf0, have hfg0 : 0 < abs (eval z₀ f) * (abs (eval z₀ g))⁻¹, from div_pos hf0' (complex.abs_pos.2 hg0), have hδ0 : 0 < δ, from lt_min (lt_min (half_pos hδ'₁) (by norm_num)) (half_pos hfg0), have hδ : ∀ z : ℂ, abs (z - z₀) = δ → abs (g.eval z - g.eval z₀) < (g.eval z₀).abs, from λ z hz, hδ'₂ z (by rw [complex.dist_eq, hz]; exact lt_of_le_of_lt (le_trans (min_le_left _ _) (min_le_left _ _)) (half_lt_self hδ'₁)), have hδ1 : δ ≤ 1, from le_trans (min_le_left _ _) (min_le_right _ _), let F : polynomial ℂ := C (f.eval z₀) + C (g.eval z₀) * (X - C z₀) ^ n in let z' := nth_root n (-f.eval z₀ * (g.eval z₀).abs * δ ^ n / ((f.eval z₀).abs * g.eval z₀)) + z₀ in have hF₁ : F.eval z' = f.eval z₀ - f.eval z₀ * (g.eval z₀).abs * δ ^ n / (f.eval z₀).abs, by simp [F, nth_root_pow, div_eq_mul_inv, eval_pow, mul_assoc, mul_comm (g.eval z₀), mul_left_comm (g.eval z₀), mul_left_comm (g.eval z₀)⁻¹, mul_inv', inv_mul_cancel hg0]; simp [mul_comm, mul_left_comm, mul_assoc], have hδs : (g.eval z₀).abs * δ ^ n / (f.eval z₀).abs < 1, begin rw [div_eq_mul_inv, mul_right_comm, mul_comm, ← @inv_inv' _ _ (complex.abs _ * _), mul_inv', inv_inv', ← div_eq_mul_inv, div_lt_iff hfg0, one_mul], calc δ ^ n ≤ δ ^ 1 : pow_le_pow_of_le_one (le_of_lt hδ0) hδ1 hn0 ... = δ : _root_.pow_one _ ... ≤ ((f.eval z₀).abs / (g.eval z₀).abs) / 2 : min_le_right _ _ ... < _ : half_lt_self hfg0 end, have hF₂ : (F.eval z').abs = (f.eval z₀).abs - (g.eval z₀).abs * δ ^ n, from calc (F.eval z').abs = (f.eval z₀ - f.eval z₀ * (g.eval z₀).abs * δ ^ n / (f.eval z₀).abs).abs : congr_arg abs hF₁ ... = abs (f.eval z₀) * complex.abs (1 - (g.eval z₀).abs * δ ^ n / (f.eval z₀).abs : ℝ) : by rw [← complex.abs_mul]; exact congr_arg complex.abs (by simp [mul_add, add_mul, mul_assoc, div_eq_mul_inv]) ... = _ : by rw [complex.abs_of_nonneg (sub_nonneg.2 (le_of_lt hδs)), mul_sub, mul_div_cancel' _ (ne.symm (ne_of_lt hf0')), mul_one], have hef0 : abs (eval z₀ g) * (eval z₀ f).abs ≠ 0, from mul_ne_zero (mt complex.abs_eq_zero.1 hg0) (mt complex.abs_eq_zero.1 hf0), have hz'z₀ : abs (z' - z₀) = δ := begin simp [z', mul_assoc, mul_left_comm _ (_ ^ n), mul_comm _ (_ ^ n), mul_comm (eval z₀ f).abs, _root_.mul_div_cancel _ hef0, of_real_mul, neg_mul_eq_neg_mul_symm, neg_div, abs_nth_root, is_absolute_value.abv_pow complex.abs], end, have hF₃ : (f.eval z' - F.eval z').abs < (g.eval z₀).abs * δ ^ n, from calc (f.eval z' - F.eval z').abs = (g.eval z' - g.eval z₀).abs * (z' - z₀).abs ^ n : by rw [← eq_sub_iff_add_eq.1 hg, ← is_absolute_value.abv_pow complex.abs, ← complex.abs_mul, sub_mul]; simp [F, eval_pow, eval_add, eval_mul, eval_sub, eval_C, eval_X, eval_neg, add_sub_cancel] ... = (g.eval z' - g.eval z₀).abs * δ ^ n : by rw hz'z₀ ... < _ : (mul_lt_mul_right (pow_pos hδ0 _)).2 (hδ _ hz'z₀), lt_irrefl (f.eval z₀).abs $ calc (f.eval z₀).abs = ⨅ y, (f.eval y).abs : hz₀ ... ≤ (f.eval z').abs : lattice.cinfi_le ⟨0, λ _ ⟨z, hz⟩, by simp [hz.symm, complex.abs_nonneg]⟩ ... = (F.eval z' + (f.eval z' - F.eval z')).abs : by simp ... ≤ (F.eval z').abs + (f.eval z' - F.eval z').abs : complex.abs_add _ _ ... < (f.eval z₀).abs - (g.eval z₀).abs * δ ^ n + (g.eval z₀).abs * δ ^ n : add_lt_add_of_le_of_lt (by rw hF₂) hF₃ ... = _ : by simp
Formal statement is: lemma emeasure_restrict_space: assumes "\<Omega> \<inter> space M \<in> sets M" "A \<subseteq> \<Omega>" shows "emeasure (restrict_space M \<Omega>) A = emeasure M A" Informal statement is: If $\Omega$ is a measurable set, then the restriction of a measure to $\Omega$ is the same as the original measure.
Formal statement is: lemma interior_singleton [simp]: "interior {a} = {}" for a :: "'a::perfect_space" Informal statement is: The interior of a singleton set is empty.
import os import numpy as np import pandas as pd import xarray as xr from oas_erf.util.eusaar_data import p_gen, p_distc, station_codes, subs_codes, years_codes from oas_erf.constants import path_eusaar_outdata savepath_distc_vars = path_eusaar_outdata + 'distc_vars.nc' percs_in_eusaar_files = [5., 16., 50., 84., 95.] # percentiles in files def get_diameter_sized(): p =p_gen +'standard_sizes.dat' diameter = pd.Index(np.loadtxt(p), name='diameter') return diameter d = get_diameter_sized() # %% def get_distc_dataframe(station, year='BOTH', subs='TOT'): rows= ['%.0fth percentile' % p for p in percs_in_eusaar_files]#, '16th percentile', '50th percentile','84th percentile'] diam = get_diameter_sized() p = p_distc + station +'_'+subs+'_DIST_'+year+'.dat' m = np.loadtxt(p) return pd.DataFrame(m.transpose(), index = diam, columns=rows) def get_distc_xarray_station(station, year='BOTH', subs='TOT'): df = get_distc_dataframe(station, year=year, subs=subs) da = df.to_xarray().to_array(dim='percentile') da['diameter'].attrs['units']='nm' da.name = 'dN/dlog10(d$_p$)' return da def get_distc_xarray(year='BOTH', subs='TOT'): ls =[] for station in station_codes: ls.append(get_distc_xarray_station(station, year=year, subs=subs)) da_c =xr.concat(ls, dim='station') da_c['station']=station_codes return da_c def get_distc_xarray_allsubs(year='BOTH'): ls=[] for subs in subs_codes: ls.append(get_distc_xarray(year=year, subs=subs)) da_c = xr.concat(ls, dim='subset') da_c['subset']=subs_codes return da_c def get_distc_xarray_all(from_nc=True): if from_nc and os.path.isfile(savepath_distc_vars): return xr.open_dataset(savepath_distc_vars)#.rename({'':'dN/dlog10(d$_p$)'}) ls=[] for year in years_codes: ls.append(get_distc_xarray_allsubs(year=year)) da_c = xr.concat(ls, dim='year') da_c['year']=years_codes print(da_c) da_c = da_c.rename('dNdlog10dp') da_c.to_netcdf(savepath_distc_vars) return da_c # %% #da_c = get_distc_xarray_all(from_nc=False)
use :: SoybeanClass type(Soybean_) :: soy type(Random_) :: random real(real64),allocatable :: a_field(:) call soy%init(config="Tutorial/obj/soy.json") a_field = soy%getDistanceFromGround() call soy%vtk("soy",scalar_field=a_field,single_file=true) end
/- Copyright (c) 2019 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro ! This file was ported from Lean 3 source module data.rat.init ! leanprover-community/mathlib commit 448144f7ae193a8990cb7473c9e9a01990f64ac7 ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathbin.Tactic.Ext import Mathbin.Logic.Basic /-! # The definition of the Rational Numbers > THIS FILE IS SYNCHRONIZED WITH MATHLIB4. > Any changes to this file require a corresponding PR to mathlib4. ## Summary We define a rational number `q` as a structure `{ num, denom, pos, cop }`, where - `num` is the numerator of `q`, - `denom` is the denominator of `q`, - `pos` is a proof that `denom > 0`, and - `cop` is a proof `num` and `denom` are coprime. Basic constructions and results are set up in `data.rat.defs`. As we transition to Lean 4, these two files can probably be merged again, as so much of the needed material will be in Std4 anyway. For now, this split allows us to give the definitions of division rings and fields without significant theory imports. The definition of the field structure on `ℚ` will be done in `data.rat.basic` once the `field` class has been defined. ## Main Definitions - `rat` is the structure encoding `ℚ`. ## Notations ## Tags rat, rationals, field, ℚ, numerator, denominator, num, denom -/ #print Rat /- /-- `rat`, or `ℚ`, is the type of rational numbers. It is defined as the set of pairs ⟨n, d⟩ of integers such that `d` is positive and `n` and `d` are coprime. This representation is preferred to the quotient because without periodic reduction, the numerator and denominator can grow exponentially (for example, adding 1/2 to itself repeatedly). -/ structure Rat where mk' :: num : ℤ den : ℕ Pos : 0 < denom cop : Num.natAbs.coprime denom #align rat Rat -/ -- mathport name: exprℚ notation "ℚ" => Rat namespace Rat /-- String representation of a rational numbers, used in `has_repr`, `has_to_string`, and `has_to_format` instances. -/ protected def repr : ℚ → String | ⟨n, d, _, _⟩ => if d = 1 then repr n else repr n ++ "/" ++ repr d #align rat.repr Rat.repr instance : Repr ℚ := ⟨Rat.repr⟩ instance : ToString ℚ := ⟨Rat.repr⟩ unsafe instance : has_to_format ℚ := ⟨coe ∘ Rat.repr⟩ #print Rat.ext_iff /- theorem ext_iff {p q : ℚ} : p = q ↔ p.num = q.num ∧ p.den = q.den := by cases p cases q simp #align rat.ext_iff Rat.ext_iff -/ #print Rat.ext /- @[ext] theorem ext {p q : ℚ} (hn : p.num = q.num) (hd : p.den = q.den) : p = q := Rat.ext_iff.mpr ⟨hn, hd⟩ #align rat.ext Rat.ext -/ end Rat
open import Agda.Builtin.List open import Agda.Builtin.Reflection open import Agda.Builtin.Sigma open import Agda.Builtin.Unit @0 m : Name → TC ⊤ m F = defineFun F (clause (( "A" , arg (arg-info visible (modality relevant quantity-0)) (agda-sort (lit 0))) ∷ []) (arg (arg-info visible (modality relevant quantity-0)) (var 0) ∷ []) (var 0 []) ∷ []) F : @0 Set → Set unquoteDef F = m F
(** * Extraction: Extracting OCaml from Coq *) (* ################################################################# *) (** * Basic Extraction *) (** In its simplest form, extracting an efficient program from one written in Coq is completely straightforward. First we say what language we want to extract into. Options are OCaml (the most mature), Haskell (mostly works), and Scheme (a bit out of date). *) Require Coq.extraction.Extraction. Extraction Language OCaml. (** Now we load up the Coq environment with some definitions, either directly or by importing them from other modules. *) From Coq Require Import Arith.Arith. From Coq Require Import Init.Nat. From Coq Require Import Arith.EqNat. From LF Require Import ImpCEvalFun. (** Finally, we tell Coq the name of a definition to extract and the name of a file to put the extracted code into. *) Extraction "imp1.ml" ceval_step. (** When Coq processes this command, it generates a file [imp1.ml] containing an extracted version of [ceval_step], together with everything that it recursively depends on. Compile the present [.v] file and have a look at [imp1.ml] now. *) (* ################################################################# *) (** * Controlling Extraction of Specific Types *) (** We can tell Coq to extract certain [Inductive] definitions to specific OCaml types. For each one, we must say - how the Coq type itself should be represented in OCaml, and - how each constructor should be translated. *) Extract Inductive bool => "bool" [ "true" "false" ]. (** Also, for non-enumeration types (where the constructors take arguments), we give an OCaml expression that can be used as a "recursor" over elements of the type. (Think Church numerals.) *) Extract Inductive nat => "int" [ "0" "(fun x -> x + 1)" ] "(fun zero succ n -> if n=0 then zero () else succ (n-1))". (** We can also extract defined constants to specific OCaml terms or operators. *) Extract Constant plus => "( + )". Extract Constant mult => "( * )". Extract Constant eqb => "( = )". (** Important: It is entirely _your responsibility_ to make sure that the translations you're proving make sense. For example, it might be tempting to include this one Extract Constant minus => "( - )". but doing so could lead to serious confusion! (Why?) *) Extraction "imp2.ml" ceval_step. (** Have a look at the file [imp2.ml]. Notice how the fundamental definitions have changed from [imp1.ml]. *) (* ################################################################# *) (** * A Complete Example *) (** To use our extracted evaluator to run Imp programs, all we need to add is a tiny driver program that calls the evaluator and prints out the result. For simplicity, we'll print results by dumping out the first four memory locations in the final state. Also, to make it easier to type in examples, let's extract a parser from the [ImpParser] Coq module. To do this, we first need to set up the right correspondence between Coq strings and lists of OCaml characters. *) Require Import ExtrOcamlBasic. Require Import ExtrOcamlString. (** We also need one more variant of booleans. *) Extract Inductive sumbool => "bool" ["true" "false"]. (** The extraction is the same as always. *) From LF Require Import Imp. From LF Require Import ImpParser. From LF Require Import Maps. Extraction "imp.ml" empty_st ceval_step parse. (** Now let's run our generated Imp evaluator. First, have a look at [impdriver.ml]. (This was written by hand, not extracted.) Next, compile the driver together with the extracted code and execute it, as follows. ocamlc -w -20 -w -26 -o impdriver imp.mli imp.ml impdriver.ml ./impdriver (The [-w] flags to [ocamlc] are just there to suppress a few spurious warnings.) *) (* ################################################################# *) (** * Discussion *) (** Since we've proved that the [ceval_step] function behaves the same as the [ceval] relation in an appropriate sense, the extracted program can be viewed as a _certified_ Imp interpreter. Of course, the parser we're using is not certified, since we didn't prove anything about it! *) (* ################################################################# *) (** * Going Further *) (** Further details about extraction can be found in the Extract chapter in _Verified Functional Algorithms_ (_Software Foundations_ volume 3). *) (* 2022-08-08 17:13 *)
module FreshPerm import FreshList import Data.Fin import Data.Vect ||| An arrangement is a list of fins of a given length ||| and range. public export Arrangement : Nat -> Nat -> Type Arrangement len range = FreshVect len (Fin range) (/=) ||| A permutation is an arrangement where each fin appears n times ||| and the fins range from 0 to n public export Permutation : Nat -> Type Permutation n = Arrangement n n weakenInj : (x : Fin k) -> (y : Fin k) -> So (not (x == y)) -> So (not (weaken x == weaken y)) weakenInj FZ FZ z = z weakenInj FZ (FS x) z = z weakenInj (FS x) FZ z = z weakenInj (FS x) (FS y) z = weakenInj x y z easyNeq : (y : Fin n) -> So ((Fin.last /= (Fin.weaken y))) easyNeq FZ = Oh easyNeq (FS x) = easyNeq x freshWeakend : (fs : Arrangement l r) -> So ((Fin.last) ## map Fin.weaken {Bneq=(/=)} weakenInj fs) freshWeakend [] = Oh freshWeakend (x :: xs) = andSo (easyNeq _, freshWeakend xs) reversePermutation : (n : Nat) -> Permutation n newFresh : (n : Nat) -> So (Fin.last {n} ## map Fin.weaken {Bneq = (/=)} FreshPerm.weakenInj (reversePermutation n)) reversePermutation 0 = [] reversePermutation (S k) = (::) (last {n=k}) (FreshList.map weaken {Bneq = (/=)} weakenInj (reversePermutation k)) {fresh = newFresh k} newFresh n = freshWeakend (reversePermutation n) flip : {a, b : Fin n} -> So (a /= b) -> So (b /= a) flip {a = FZ} {b = FZ} x = x flip {a = FZ} {b = (FS y)} x = x flip {a = (FS y)} {b = FZ} x = x flip {a = (FS y)} {b = (FS z)} x = flip x export append : (f : Fin n) -> (fs : Arrangement l n) -> {0 notIn : So (f ## fs)} -> Arrangement (S l) n freshlyAppend : {x, f : Fin n} -> {xs : Arrangement l n} -> {fneq : So (f ## xs)} -> (notEq : So (x /= f)) -> (fresh : So (x ## xs)) -> So (x ## append {notIn = fneq} f xs) append f [] = [f] append f ((x :: xs) {fresh}) = let 0 p = soAnd notIn in (::) x (append f {notIn = snd p} xs) {fresh = freshlyAppend (flip $ fst p) fresh} freshlyAppend notEq fresh {xs = []} = andSo (notEq, Oh) freshlyAppend notEq fresh {xs = (y :: xs)} = let (a, b) = soAnd fresh in andSo (a, freshlyAppend notEq b) export reverse : Arrangement l n -> Arrangement l n 0 freshlyReversed : (x, xs : _) -> So (x ## xs) -> So (x ## FreshPerm.reverse xs) reverse [] = [] reverse ((::) x xs {fresh}) = append x (reverse xs) {notIn = freshlyReversed x xs fresh} freshlyReversed x [] y = Oh freshlyReversed x (z :: xs) y with (soAnd y) freshlyReversed x (z :: xs) y | (w, v) = freshlyAppend {xs= reverse xs} {f=z} w (freshlyReversed ? xs v) export identityPermutation : (n : Nat) -> Permutation n identityPermutation n = reverse (reversePermutation n) extractVal : (Fin (S n)) -> Vect (S n) a -> (a, Vect n a) extractVal FZ (x :: xs) = (x, xs) extractVal (FS FZ) (y :: (x :: xs)) = (x, y :: xs) extractVal (FS (FS x)) (y :: (z :: xs)) with (extractVal (FS x) (z :: xs)) extractVal (FS (FS x)) (y :: (z :: xs)) | (k, ks) = (k, y :: ks) applyPermutation : (1 _ : Permutation n) -> (1 _ : Vect n a) -> Vect n a applyPermutation [] [] = [] applyPermutation (x :: xs) (y :: ys) = let (val, res) = extractVal x (y :: ys) in val :: applyPermutation ?kek res
import algebra.ring import data.real.basic import algebra.order.ring import tactic.linarith theorem division_by_2 (a : ℕ) : (exists b : ℕ, a=2*b) ∨ (∃ b : ℕ, a=2*b+1) := begin induction a with d hd, left, use 0, ring, cases hd with hEven hOdd, cases hEven with b, right, use b, exact congr_arg nat.succ hEven_h, left, cases hOdd with b, use (b+1), rw nat.succ_eq_add_one, rw hOdd_h, ring, end
theory SWCommonPatterns_SolidWorksCylByArcExtrusion_is_AffineCylinder imports "$HETS_ISABELLE_LIB/MainHC" uses "$HETS_ISABELLE_LIB/prelude" begin ML "Header.initialize [\"ga_subt_reflexive\", \"ga_subt_transitive\", \"ga_subt_inj_proj\", \"ga_inj_transitive\", \"ga_subt_Int_XLt_Rat\", \"ga_subt_Nat_XLt_Int\", \"ga_subt_NonZero_XLt_Real\", \"ga_subt_Pos_XLt_Nat\", \"ga_subt_Rat_XLt_Real\", \"ga_subt_Real_XLt_Point\", \"ga_subt_Real_XLt_Vector\", \"ga_subt_RealNonNeg_XLt_Real\", \"ga_subt_RealPos_XLt_RealNonNeg\", \"ga_subt_SWArc_XLt_SWSketchObject\", \"ga_subt_SWExtrusion_XLt_SWFeature\", \"ga_subt_SWFeature_XLt_SWObject\", \"ga_subt_SWLine_XLt_SWSketchObject\", \"ga_subt_SWPlane_XLt_SWObject\", \"ga_subt_SWSketch_XLt_SWObject\", \"ga_subt_SWSketchObject_XLt_SWObject\", \"ga_subt_SWSpline_XLt_SWSketchObject\", \"ga_subt_VectorStar_XLt_Vector\", \"ga_assoc___Xx__\", \"ga_right_unit___Xx__\", \"ga_left_unit___Xx__\", \"inv_Group\", \"rinv_Group\", \"ga_comm___Xx__\", \"ga_assoc___Xx___9\", \"ga_right_unit___Xx___7\", \"ga_left_unit___Xx___8\", \"distr1_Ring\", \"distr2_Ring\", \"left_zero\", \"right_zero\", \"ga_comm___Xx___14\", \"noZeroDiv\", \"zeroNeqOne\", \"NonZero_type\", \"ga_assoc___Xx___22\", \"ga_right_unit___Xx___18\", \"ga_left_unit___Xx___20\", \"inv_Group_21\", \"rinv_Group_19\", \"binary_inverse\", \"binary_field_inverse\", \"refl\", \"trans\", \"antisym\", \"dichotomy_TotalOrder\", \"FWO_plus_left\", \"FWO_times_left\", \"FWO_plus_right\", \"FWO_times_right\", \"FWO_plus\", \"inf_def\", \"Real_completeness\", \"geq_def_ExtPartialOrder\", \"less_def_ExtPartialOrder\", \"greater_def_ExtPartialOrder\", \"ga_comm_inf\", \"ga_comm_sup\", \"inf_def_ExtPartialOrder\", \"sup_def_ExtPartialOrder\", \"ga_comm_min\", \"ga_comm_max\", \"ga_assoc_min\", \"ga_assoc_max\", \"ga_left_comm_min\", \"ga_left_comm_max\", \"min_def_ExtTotalOrder\", \"max_def_ExtTotalOrder\", \"min_inf_relation\", \"max_sup_relation\", \"RealNonNeg_pred_def\", \"RealPos_pred_def\", \"RealNonNeg_type\", \"RealPos_type\", \"abs_def\", \"times_cancel_right_nonneg_leq\", \"times_leq_nonneg_cond\", \"sqr_def\", \"sqrt_def\", \"Pos_def\", \"ga_select_C1\", \"ga_select_C2\", \"ga_select_C3\", \"Zero_Point\", \"Point_choice\", \"ga_select_C1_131\", \"ga_select_C2_132\", \"ga_select_C3_133\", \"Zero_Vector\", \"VectorStar_pred_def\", \"VectorStar_type\", \"def_of_vector_addition\", \"def_of_minus_vector\", \"binary_inverse_72\", \"scalar_multiplication\", \"scalar_product\", \"vector_product\", \"ONB1\", \"ONB2\", \"ONB3\", \"cross_left_homogenity\", \"cross_product_antisymmetric\", \"ga_assoc___Xx___82\", \"ga_right_unit___Xx___76\", \"ga_left_unit___Xx___78\", \"inv_Group_79\", \"rinv_Group_77\", \"ga_comm___Xx___80\", \"unit\", \"mix_assoc\", \"distr_Field\", \"distr_Space\", \"zero_by_left_zero\", \"zero_by_right_zero\", \"inverse_by_XMinus1\", \"no_zero_divisor\", \"distributive\", \"homogeneous\", \"symmetric\", \"pos_definite\", \"right_distributive\", \"right_homogeneous\", \"non_degenerate\", \"lindep_def\", \"lindep_reflexivity\", \"lindep_symmetry\", \"simple_lindep_condition\", \"lindep_nonlindep_transitivity\", \"norm_from_inner_prod_def\", \"proj_def\", \"orthcomp_def\", \"orthogonal_def\", \"homogeneous_93\", \"definite\", \"pos_definite_94\", \"pos_homogeneous\", \"orth_symmetric\", \"lindep_orth_transitive\", \"orthogonal_existence_theorem\", \"orthogonal_on_zero_projection\", \"orthogonal_projection_theorem\", \"orthogonal_decomposition_theorem\", \"unique_orthogonal_decomposition\", \"ga_select_first\", \"ga_select_rest\", \"Ax4\", \"Ax5\", \"ga_assoc___Xx___83\", \"ga_right_unit___Xx___81\", \"ga_left_unit___Xx___82\", \"listop_basecase\", \"listop_reccase\", \"cross_product_orthogonal\", \"cross_product_zero_iff_lindep\", \"e1e2_nonlindep\", \"point_vector_map\", \"plus_injective\", \"plus_surjective\", \"point_vector_plus_associative\", \"vec_def\", \"transitivity_of_vec_plus\", \"plus_vec_identity\", \"set_comprehension\", \"abbrev_of_set_comprehension\", \"function_image\", \"emptySet_empty\", \"allSet_contains_all\", \"def_of_isIn\", \"def_of_subset\", \"def_of_union\", \"def_of_bigunion\", \"def_of_intersection\", \"def_of_difference\", \"def_of_disjoint\", \"def_of_productset\", \"emptySet_union_right_unit\", \"function_image_structure\", \"def_of_interval\", \"abbrev_of_interval\", \"plus_PointSet_Vector\", \"plus_Point_VectorSet\", \"plus_PointSet_VectorSet\", \"def_of_Plane\", \"plane_condition_for_2_points\", \"plane_condition_for_point_and_vector\", \"ga_select_SpacePoint\", \"ga_select_NormalVector\", \"ga_select_InnerCS\", \"ga_select_Center\", \"ga_select_Start\", \"ga_select_End\", \"ga_select_From\", \"ga_select_To\", \"ga_select_Points\", \"ga_select_Objects\", \"ga_select_Plane\", \"ga_select_Objects_1\", \"ga_select_SkchCtrtStatus\", \"ga_select_Objects_2\", \"ga_select_Sketch\", \"ga_select_Depth\", \"E1_def\", \"E2_def\", \"E3_def\", \"VLine_constr\", \"VWithLength_constr\", \"VPlane_constr\", \"VPlane2_constr\", \"VConnected_constr\", \"VHalfSpace_constr\", \"VHalfSpace2_constr\", \"VBall_constr\", \"VCircle_constr\", \"ActAttach_constr\", \"ActExtrude_constr\", \"vwl_identity\", \"vwl_length\", \"vwl_lindep\", \"semantics_for_Planes\", \"semantics_for_SketchObject_listsXMinusBaseCase\", \"semantics_for_SketchObject_listsXMinusRecursiveCase\", \"semantics_for_Arcs\", \"semantics_for_Sketches\", \"semantics_for_ArcExtrusion\", \"plane_is_plane\", \"def_of_Cylinder\", \"def_of_given_arc\", \"cylinder_offset\", \"cylinder_radius\", \"cylinder_axis\", \"real_extrusion\", \"real_arc\", \"the_arc_is_wellformed\", \"extrusion_is_cylinder\"]" typedecl NonZero typedecl PointSet typedecl Pos typedecl Rat typedecl Real typedecl RealNonNeg typedecl RealPos typedecl RealSet typedecl SWFeature typedecl SWObject typedecl SWSketchObject typedecl ('a1) Set typedecl VectorSet typedecl VectorStar typedecl X_Int typedecl X_Nat datatype Point = X_P "Real" "Real" "Real" ("P/'(_,/ _,/ _')" [3,3,3] 999) datatype Vector = X_V "Real" "Real" "Real" ("V/'(_,/ _,/ _')" [3,3,3] 999) datatype 'a List = XOSqBrXCSqBr ("['']") | X__XColonXColon__X 'a "'a List" ("(_/ ::''/ _)" [54,54] 52) datatype SWPlane = X_SWPlane "Point" "VectorStar" "Vector" datatype SWArc = X_SWArc "Point" "Point" "Point" datatype SWLine = X_SWLine "Point" "Point" datatype SWSpline = X_SWSpline "Point List" datatype SWSketch = X_SWSketch "SWSketchObject List" "SWPlane" datatype SWSkchCtrtParam = sgANGLE | sgARCANG180 | sgARCANG270 | sgARCANG90 | sgARCANGBOTTOM | sgARCANGLEFT | sgARCANGRIGHT | sgARCANGTOP | sgATINTERSECT | sgATMIDDLE | sgATPIERCE | sgCOINCIDENT | sgCOLINEAR | sgCONCENTRIC | sgCORADIAL | sgDIAMETER | sgDISTANCE | sgFIXXED ("sgFIXED") | sgHORIZONTAL | sgHORIZPOINTS | sgOFFSETEDGE | sgPARALLEL | sgPERPENDICULAR | sgSAMELENGTH | sgSNAPANGLE | sgSNAPGRID | sgSNAPLENGTH | sgSYMMETRIC | sgTANGENT | sgUSEEDGE | sgVERTICAL | sgVERTPOINTS datatype SWSkchCtrtStatus = X_Autosolve_off ("Autosolve'_off") | X_Fully_constrained ("Fully'_constrained") | X_No_solution ("No'_solution") | X_Over_constrained ("Over'_constrained") | X_Under_constrained ("Under'_constrained") datatype SWSkchCtrtObject = X_SWSkchCtrtObject "SWSkchCtrtParam List" datatype SWSkchCtrts = X_SWSkchCtrts "SWSkchCtrtStatus" "SWSkchCtrtObject List" datatype SWExtrusion = X_SWExtrusion "SWSketch" "Real" consts ActAttach :: "Point * (Vector => bool) => Point => bool" ActExtrude :: "Vector * (Point => bool) => Point => bool" C1X1 :: "Point => Real" ("C1''/'(_')" [3] 999) C1X2 :: "Vector => Real" ("C1''''/'(_')" [3] 999) C2X1 :: "Point => Real" ("C2''/'(_')" [3] 999) C2X2 :: "Vector => Real" ("C2''''/'(_')" [3] 999) C3X1 :: "Point => Real" ("C3''/'(_')" [3] 999) C3X2 :: "Vector => Real" ("C3''''/'(_')" [3] 999) Cylinder :: "(Point * RealPos) * VectorStar => Point => bool" E1 :: "SWPlane" E2 :: "SWPlane" E3 :: "SWPlane" ObjectsX1 :: "SWSkchCtrtObject => SWSkchCtrtParam List" ("Objects''/'(_')" [3] 999) ObjectsX2 :: "SWSkchCtrts => SWSkchCtrtObject List" ("Objects''''/'(_')" [3] 999) ObjectsX3 :: "SWSketch => SWSketchObject List" ("Objects'_3/'(_')" [3] 999) Pi :: "RealPos" PlaneX1 :: "SWSketch => SWPlane" ("Plane''/'(_')" [3] 999) PlaneX2 :: "Point * VectorStar => Point => bool" VBall :: "Real => Vector => bool" VCircle :: "Real * Vector => Vector => bool" VConnected :: "(Vector => bool) * Vector => Vector => bool" VHalfSpace :: "Vector => Vector => bool" VHalfSpace2 :: "Vector => Vector => bool" VLine :: "Vector * Vector => Vector => bool" VPlane :: "Vector => Vector => bool" VPlane2 :: "Vector * Vector => Vector => bool" X0X1 :: "X_Int" ("0''") X0X2 :: "X_Nat" ("0''''") X0X3 :: "Point" ("0'_3") X0X4 :: "Rat" ("0'_4") X0X5 :: "Real" ("0'_5") X0X6 :: "Vector" ("0'_6") X1X1 :: "X_Int" ("1''") X1X2 :: "X_Nat" ("1''''") X1X3 :: "NonZero" ("1'_3") X1X4 :: "Pos" ("1'_4") X1X5 :: "Rat" ("1'_5") X1X6 :: "Real" ("1'_6") X2X1 :: "X_Int" ("2''") X2X2 :: "X_Nat" ("2''''") X2X3 :: "Rat" ("2'_3") X3X1 :: "X_Int" ("3''") X3X2 :: "X_Nat" ("3''''") X3X3 :: "Rat" ("3'_3") X4X1 :: "X_Int" ("4''") X4X2 :: "X_Nat" ("4''''") X4X3 :: "Rat" ("4'_3") X5X1 :: "X_Int" ("5''") X5X2 :: "X_Nat" ("5''''") X5X3 :: "Rat" ("5'_3") X6X1 :: "X_Int" ("6''") X6X2 :: "X_Nat" ("6''''") X6X3 :: "Rat" ("6'_3") X7X1 :: "X_Int" ("7''") X7X2 :: "X_Nat" ("7''''") X7X3 :: "Rat" ("7'_3") X8X1 :: "X_Int" ("8''") X8X2 :: "X_Nat" ("8''''") X8X3 :: "Rat" ("8'_3") X9X1 :: "X_Int" ("9''") X9X2 :: "X_Nat" ("9''''") X9X3 :: "Rat" ("9'_3") XLBrace__XRBrace :: "('S => bool) => 'S => bool" XMinus__XX1 :: "X_Int => X_Int" ("(-''/ _)" [56] 56) XMinus__XX2 :: "Rat => Rat" ("(-''''/ _)" [56] 56) XMinus__XX3 :: "Real => Real" ("(-'_3/ _)" [56] 56) XMinus__XX4 :: "Vector => Vector" ("(-'_4/ _)" [56] 56) XOSqBr__XPeriodXPeriodXPeriod__XCSqBr :: "Real * Real => Real => bool" XVBarXVBar__XVBarXVBar :: "Vector => Real" ("(||/ _/ ||)" [10] 999) X_Center :: "SWArc => Point" ("Center/'(_')" [3] 999) X_Depth :: "SWExtrusion => Real" ("Depth/'(_')" [3] 999) X_End :: "SWArc => Point" ("End/'(_')" [3] 999) X_From :: "SWLine => Point" ("From/'(_')" [3] 999) X_InnerCS :: "SWPlane => Vector" ("InnerCS/'(_')" [3] 999) X_NormalVector :: "SWPlane => VectorStar" ("NormalVector/'(_')" [3] 999) X_Points :: "SWSpline => Point List" ("Points/'(_')" [3] 999) X_Pos :: "Real => bool" X_RealNonNeg_pred :: "Real => bool" ("RealNonNeg'_pred/'(_')" [3] 999) X_RealPos_pred :: "Real => bool" ("RealPos'_pred/'(_')" [3] 999) X_SkchCtrtStatus :: "SWSkchCtrts => SWSkchCtrtStatus" ("SkchCtrtStatus/'(_')" [3] 999) X_Sketch :: "SWExtrusion => SWSketch" ("Sketch/'(_')" [3] 999) X_SpacePoint :: "SWPlane => Point" ("SpacePoint/'(_')" [3] 999) X_Start :: "SWArc => Point" ("Start/'(_')" [3] 999) X_To :: "SWLine => Point" ("To/'(_')" [3] 999) X_VWithLength :: "Vector => Real => Vector" ("VWithLength/'(_,/ _')" [3,3] 999) X_VectorStar_pred :: "Vector => bool" ("VectorStar'_pred/'(_')" [3] 999) X__E__X :: "Rat => X_Int => Rat" ("(_/ E/ _)" [54,54] 52) X__XAtXAt__X :: "X_Nat => X_Nat => X_Nat" ("(_/ @@/ _)" [54,54] 52) X__XBslashXBslash__X :: "('S => bool) * ('S => bool) => 'S => bool" X__XCaret__XX1 :: "X_Int => X_Nat => X_Int" ("(_/ ^''/ _)" [54,54] 52) X__XCaret__XX2 :: "X_Nat => X_Nat => X_Nat" ("(_/ ^''''/ _)" [54,54] 52) X__XCaret__XX3 :: "Rat => X_Int => Rat partial" ("(_/ ^'_3/ _)" [54,54] 52) X__XColonXColonXColon__X :: "X_Nat => X_Nat => Rat" ("(_/ :::/ _)" [54,54] 52) X__XExclam :: "X_Nat => X_Nat" ("(_/ !'')" [58] 58) X__XGtXEq__XX1 :: "X_Int => X_Int => bool" ("(_/ >=''/ _)" [44,44] 42) X__XGtXEq__XX2 :: "X_Nat => X_Nat => bool" ("(_/ >=''''/ _)" [44,44] 42) X__XGtXEq__XX3 :: "Rat => Rat => bool" ("(_/ >='_3/ _)" [44,44] 42) X__XGtXEq__XX4 :: "Real => Real => bool" ("(_/ >='_4/ _)" [44,44] 42) X__XGt__XX1 :: "X_Int => X_Int => bool" ("(_/ >''/ _)" [44,44] 42) X__XGt__XX2 :: "X_Nat => X_Nat => bool" ("(_/ >''''/ _)" [44,44] 42) X__XGt__XX3 :: "Rat => Rat => bool" ("(_/ >'_3/ _)" [44,44] 42) X__XGt__XX4 :: "Real => Real => bool" ("(_/ >'_4/ _)" [44,44] 42) X__XHash__X :: "Vector => Vector => Vector" ("(_/ #''/ _)" [54,54] 52) X__XLtXEq__XX1 :: "X_Int => X_Int => bool" ("(_/ <=''/ _)" [44,44] 42) X__XLtXEq__XX2 :: "X_Nat => X_Nat => bool" ("(_/ <=''''/ _)" [44,44] 42) X__XLtXEq__XX3 :: "Rat => Rat => bool" ("(_/ <='_3/ _)" [44,44] 42) X__XLtXEq__XX4 :: "Real => Real => bool" ("(_/ <='_4/ _)" [44,44] 42) X__XLt__XX1 :: "X_Int => X_Int => bool" ("(_/ <''/ _)" [44,44] 42) X__XLt__XX2 :: "X_Nat => X_Nat => bool" ("(_/ <''''/ _)" [44,44] 42) X__XLt__XX3 :: "Rat => Rat => bool" ("(_/ <'_3/ _)" [44,44] 42) X__XLt__XX4 :: "Real => Real => bool" ("(_/ <'_4/ _)" [44,44] 42) X__XMinusXExclam__X :: "X_Nat => X_Nat => X_Nat" ("(_/ -!/ _)" [54,54] 52) X__XMinusXQuest__X :: "X_Nat => X_Nat => X_Nat partial" ("(_/ -?/ _)" [54,54] 52) X__XMinus__XX1 :: "X_Int => X_Int => X_Int" ("(_/ -''/ _)" [54,54] 52) X__XMinus__XX2 :: "X_Nat => X_Nat => X_Int" ("(_/ -''''/ _)" [54,54] 52) X__XMinus__XX3 :: "Rat => Rat => Rat" ("(_/ -'_3/ _)" [54,54] 52) X__XMinus__XX4 :: "Real => Real => Real" ("(_/ -'_4/ _)" [54,54] 52) X__XMinus__XX5 :: "Vector => Vector => Vector" ("(_/ -'_5/ _)" [54,54] 52) X__XPlus__XX1 :: "X_Int => X_Int => X_Int" ("(_/ +''/ _)" [54,54] 52) X__XPlus__XX10 :: "(Point => bool) * Vector => Point => bool" X__XPlus__XX11 :: "(Point => bool) * (Vector => bool) => Point => bool" X__XPlus__XX2 :: "X_Nat => X_Nat => X_Nat" ("(_/ +''''/ _)" [54,54] 52) X__XPlus__XX3 :: "X_Nat => Pos => Pos" ("(_/ +'_3/ _)" [54,54] 52) X__XPlus__XX4 :: "Point => Vector => Point" ("(_/ +'_4/ _)" [54,54] 52) X__XPlus__XX5 :: "Point * (Vector => bool) => Point => bool" X__XPlus__XX6 :: "Pos => X_Nat => Pos" ("(_/ +'_6/ _)" [54,54] 52) X__XPlus__XX7 :: "Rat => Rat => Rat" ("(_/ +'_7/ _)" [54,54] 52) X__XPlus__XX8 :: "Real => Real => Real" ("(_/ +'_8/ _)" [54,54] 52) X__XPlus__XX9 :: "Vector => Vector => Vector" ("(_/ +'_9/ _)" [54,54] 52) X__XSlashXQuest__XX1 :: "X_Int => X_Int => X_Int partial" ("(_/ '/?''/ _)" [54,54] 52) X__XSlashXQuest__XX2 :: "X_Nat => X_Nat => X_Nat partial" ("(_/ '/?''''/ _)" [54,54] 52) X__XSlash__XX1 :: "X_Int => Pos => Rat" ("(_/ '/''/ _)" [54,54] 52) X__XSlash__XX2 :: "Real => NonZero => Real" ("(_/ '/''''/ _)" [54,54] 52) X__XSlash__XX3 :: "Rat => Rat => Rat partial" ("(_/ '/'_3/ _)" [54,54] 52) X__Xx__XX1 :: "X_Int => X_Int => X_Int" ("(_/ *''/ _)" [54,54] 52) X__Xx__XX10 :: "('S => bool) * ('T => bool) => 'S * 'T => bool" X__Xx__XX2 :: "X_Nat => X_Nat => X_Nat" ("(_/ *''''/ _)" [54,54] 52) X__Xx__XX3 :: "NonZero => NonZero => NonZero" ("(_/ *'_3/ _)" [54,54] 52) X__Xx__XX4 :: "Pos => Pos => Pos" ("(_/ *'_4/ _)" [54,54] 52) X__Xx__XX5 :: "Rat => Rat => Rat" ("(_/ *'_5/ _)" [54,54] 52) X__Xx__XX6 :: "Real => Real => Real" ("(_/ *'_6/ _)" [54,54] 52) X__Xx__XX7 :: "Real => Vector => Vector" ("(_/ *'_7/ _)" [54,54] 52) X__Xx__XX8 :: "Vector => Vector => Real" ("(_/ *'_8/ _)" [54,54] 52) X__Xx__XX9 :: "Vector => Vector => Vector" ("(_/ *'_9/ _)" [54,54] 52) X__disjoint__X :: "('S => bool) => ('S => bool) => bool" ("(_/ disjoint/ _)" [44,44] 42) X__div__XX1 :: "X_Int => X_Int => X_Int partial" ("(_/ div''/ _)" [54,54] 52) X__div__XX2 :: "X_Nat => X_Nat => X_Nat partial" ("(_/ div''''/ _)" [54,54] 52) X__dvd__X :: "X_Nat => X_Nat => bool" ("(_/ dvd''/ _)" [44,44] 42) X__intersection__X :: "('S => bool) * ('S => bool) => 'S => bool" X__isIn__X :: "'S => ('S => bool) => bool" ("(_/ isIn/ _)" [44,44] 42) X__mod__XX1 :: "X_Int => X_Int => X_Nat partial" ("(_/ mod''/ _)" [54,54] 52) X__mod__XX2 :: "X_Nat => X_Nat => X_Nat partial" ("(_/ mod''''/ _)" [54,54] 52) X__quot__X :: "X_Int => X_Int => X_Int partial" ("(_/ quot/ _)" [54,54] 52) X__rem__X :: "X_Int => X_Int => X_Int partial" ("(_/ rem/ _)" [54,54] 52) X__subset__X :: "('S => bool) => ('S => bool) => bool" ("(_/ subset/ _)" [44,44] 42) X__union__X :: "('S => bool) * ('S => bool) => 'S => bool" X_absX1 :: "X_Int => X_Nat" ("abs''/'(_')" [3] 999) X_absX2 :: "Rat => Rat" ("abs''''/'(_')" [3] 999) X_absX3 :: "Real => RealNonNeg" ("abs'_3/'(_')" [3] 999) X_allSet :: "'S => bool" ("allSet/'(_')" [3] 999) X_choose :: "(Point => bool) => Point" ("choose''/'(_')" [3] 999) X_emptySet :: "'S => bool" ("emptySet/'(_')" [3] 999) X_evenX1 :: "X_Int => bool" ("even''/'(_')" [3] 999) X_evenX2 :: "X_Nat => bool" ("even''''/'(_')" [3] 999) X_first :: "'a List => 'a partial" ("first/'(_')" [3] 999) X_gn_inj :: "'a => 'b" ("gn'_inj/'(_')" [3] 999) X_gn_proj :: "'a => 'b partial" ("gn'_proj/'(_')" [3] 999) X_gn_subt :: "'a => 'b => bool" ("gn'_subt/'(_,/ _')" [3,3] 999) X_image :: "('S => 'T) * ('S => bool) => 'T => bool" X_inv :: "NonZero => NonZero" ("inv''/'(_')" [3] 999) X_isX1 :: "SWSketchObject * SWPlane => Point => bool" X_isX2 :: "SWSketchObject List * SWPlane => Point => bool" X_lindep :: "Vector => Vector => bool" ("lindep/'(_,/ _')" [3,3] 999) X_map :: "('a => 'b) => 'a List => 'b List" X_maxX1 :: "X_Int => X_Int => X_Int" ("max''/'(_,/ _')" [3,3] 999) X_maxX2 :: "X_Nat => X_Nat => X_Nat" ("max''''/'(_,/ _')" [3,3] 999) X_maxX3 :: "Rat => Rat => Rat" ("max'_3/'(_,/ _')" [3,3] 999) X_maxX4 :: "Real => Real => Real" ("max'_4/'(_,/ _')" [3,3] 999) X_minX1 :: "X_Int => X_Int => X_Int" ("min''/'(_,/ _')" [3,3] 999) X_minX2 :: "X_Nat => X_Nat => X_Nat" ("min''''/'(_,/ _')" [3,3] 999) X_minX3 :: "Rat => Rat => Rat" ("min'_3/'(_,/ _')" [3,3] 999) X_minX4 :: "Real => Real => Real" ("min'_4/'(_,/ _')" [3,3] 999) X_oddX1 :: "X_Int => bool" ("odd''/'(_')" [3] 999) X_oddX2 :: "X_Nat => bool" ("odd''''/'(_')" [3] 999) X_orth :: "Vector => Vector => bool" ("orth/'(_,/ _')" [3,3] 999) X_orthcomp :: "Vector => Vector => Vector" ("orthcomp/'(_,/ _')" [3,3] 999) X_pre :: "X_Nat => X_Nat partial" ("pre/'(_')" [3] 999) X_proj :: "Vector => Vector => Vector" ("proj/'(_,/ _')" [3,3] 999) X_rest :: "'a List => 'a List partial" ("rest/'(_')" [3] 999) X_sign :: "X_Int => X_Int" ("sign/'(_')" [3] 999) X_sqr :: "Real => RealNonNeg" ("sqr/'(_')" [3] 999) X_sqrt :: "RealNonNeg => RealNonNeg" ("sqrt/'(_')" [3] 999) X_sum :: "Vector List => Vector" ("sum/'(_')" [3] 999) X_sup :: "Real => Real => Real partial" ("sup/'(_,/ _')" [3,3] 999) X_vec :: "Point => Point => Vector" ("vec/'(_,/ _')" [3,3] 999) arc :: "SWArc" axis :: "VectorStar" b1 :: "bool" b2 :: "bool" b3 :: "bool" b4 :: "bool" b5 :: "bool" bigunion :: "(('S => bool) => bool) => 'S => bool" boundarypoint :: "Point" center :: "Point" closedinterval :: "Real * Real => Real => bool" e1 :: "Vector" e2 :: "Vector" e3 :: "Vector" height :: "RealPos" iX1 :: "SWFeature => Point => bool" iX2 :: "SWPlane => Point => bool" iX3 :: "SWSketch => Point => bool" infX1 :: "Real => Real => Real partial" ("inf''/'(_,/ _')" [3,3] 999) infX2 :: "(Real => bool) => Real partial" ("inf''''/'(_')" [3] 999) offset :: "Point" plane :: "SWPlane" radius :: "RealPos" setFromProperty :: "('S => bool) => 'S => bool" sucX1 :: "X_Nat => X_Nat" ("suc''/'(_')" [3] 999) sucX2 :: "X_Nat => Pos" ("suc''''/'(_')" [3] 999) x1 :: "Real" x2 :: "Real" x3 :: "Real" axioms ga_subt_reflexive [rule_format] : "ALL (x :: 'a). ALL (y :: 'a). gn_subt(x, y)" ga_subt_transitive [rule_format] : "ALL (x :: 'a). ALL (y :: 'b). ALL (z :: 'c). gn_subt(x, y) & gn_subt(y, z) --> gn_subt(x, z)" ga_subt_inj_proj [rule_format] : "ALL (x :: 'a). ALL (y :: 'b). gn_subt(x, y) --> y = (X_gn_inj :: 'a => 'b) x = (makePartial x = (X_gn_proj :: 'b => 'a partial) y)" ga_inj_transitive [rule_format] : "ALL (x :: 'a). ALL (y :: 'b). ALL (z :: 'c). gn_subt(x, y) & gn_subt(y, z) & y = (X_gn_inj :: 'a => 'b) x --> z = (X_gn_inj :: 'a => 'c) x = (z = (X_gn_inj :: 'b => 'c) y)" ga_subt_Int_XLt_Rat [rule_format] : "ALL (x :: X_Int). ALL (y :: Rat). gn_subt(x, y)" ga_subt_Nat_XLt_Int [rule_format] : "ALL (x :: X_Nat). ALL (y :: X_Int). gn_subt(x, y)" ga_subt_NonZero_XLt_Real [rule_format] : "ALL (x :: NonZero). ALL (y :: Real). gn_subt(x, y)" ga_subt_Pos_XLt_Nat [rule_format] : "ALL (x :: Pos). ALL (y :: X_Nat). gn_subt(x, y)" ga_subt_Rat_XLt_Real [rule_format] : "ALL (x :: Rat). ALL (y :: Real). gn_subt(x, y)" ga_subt_Real_XLt_Point [rule_format] : "ALL (x :: Real). ALL (y :: Point). gn_subt(x, y)" ga_subt_Real_XLt_Vector [rule_format] : "ALL (x :: Real). ALL (y :: Vector). gn_subt(x, y)" ga_subt_RealNonNeg_XLt_Real [rule_format] : "ALL (x :: RealNonNeg). ALL (y :: Real). gn_subt(x, y)" ga_subt_RealPos_XLt_RealNonNeg [rule_format] : "ALL (x :: RealPos). ALL (y :: RealNonNeg). gn_subt(x, y)" ga_subt_SWArc_XLt_SWSketchObject [rule_format] : "ALL (x :: SWArc). ALL (y :: SWSketchObject). gn_subt(x, y)" ga_subt_SWExtrusion_XLt_SWFeature [rule_format] : "ALL (x :: SWExtrusion). ALL (y :: SWFeature). gn_subt(x, y)" ga_subt_SWFeature_XLt_SWObject [rule_format] : "ALL (x :: SWFeature). ALL (y :: SWObject). gn_subt(x, y)" ga_subt_SWLine_XLt_SWSketchObject [rule_format] : "ALL (x :: SWLine). ALL (y :: SWSketchObject). gn_subt(x, y)" ga_subt_SWPlane_XLt_SWObject [rule_format] : "ALL (x :: SWPlane). ALL (y :: SWObject). gn_subt(x, y)" ga_subt_SWSketch_XLt_SWObject [rule_format] : "ALL (x :: SWSketch). ALL (y :: SWObject). gn_subt(x, y)" ga_subt_SWSketchObject_XLt_SWObject [rule_format] : "ALL (x :: SWSketchObject). ALL (y :: SWObject). gn_subt(x, y)" ga_subt_SWSpline_XLt_SWSketchObject [rule_format] : "ALL (x :: SWSpline). ALL (y :: SWSketchObject). gn_subt(x, y)" ga_subt_VectorStar_XLt_Vector [rule_format] : "ALL (x :: VectorStar). ALL (y :: Vector). gn_subt(x, y)" ga_assoc___Xx__ [rule_format] : "ALL (x :: Real). ALL (y :: Real). ALL (z :: Real). (x +_8 y) +_8 z = x +_8 (y +_8 z)" ga_right_unit___Xx__ [rule_format] : "ALL (x :: Real). x +_8 0_5 = x" ga_left_unit___Xx__ [rule_format] : "ALL (x :: Real). 0_5 +_8 x = x" inv_Group [rule_format] : "ALL (x :: Real). -_3 x +_8 x = 0_5" rinv_Group [rule_format] : "ALL (x :: Real). x +_8 -_3 x = 0_5" ga_comm___Xx__ [rule_format] : "ALL (x :: Real). ALL (y :: Real). x +_8 y = y +_8 x" ga_assoc___Xx___9 [rule_format] : "ALL (x :: Real). ALL (y :: Real). ALL (z :: Real). (x *_6 y) *_6 z = x *_6 (y *_6 z)" ga_right_unit___Xx___7 [rule_format] : "ALL (x :: Real). x *_6 1_6 = x" ga_left_unit___Xx___8 [rule_format] : "ALL (x :: Real). 1_6 *_6 x = x" distr1_Ring [rule_format] : "ALL (x :: Real). ALL (y :: Real). ALL (z :: Real). (x +_8 y) *_6 z = (x *_6 z) +_8 (y *_6 z)" distr2_Ring [rule_format] : "ALL (x :: Real). ALL (y :: Real). ALL (z :: Real). z *_6 (x +_8 y) = (z *_6 x) +_8 (z *_6 y)" left_zero [rule_format] : "ALL (x :: Real). 0_5 *_6 x = 0_5" right_zero [rule_format] : "ALL (x :: Real). x *_6 0_5 = 0_5" ga_comm___Xx___14 [rule_format] : "ALL (x :: Real). ALL (y :: Real). x *_6 y = y *_6 x" noZeroDiv [rule_format] : "ALL (x :: Real). ALL (y :: Real). x *_6 y = 0_5 --> x = 0_5 | y = 0_5" zeroNeqOne [rule_format] : "~ 1_6 = 0_5" NonZero_type [rule_format] : "ALL (x :: Real). defOp ((X_gn_proj :: Real => NonZero partial) x) = (~ x = 0_5)" ga_assoc___Xx___22 [rule_format] : "ALL (x :: NonZero). ALL (y :: NonZero). ALL (z :: NonZero). (x *_3 y) *_3 z = x *_3 (y *_3 z)" ga_right_unit___Xx___18 [rule_format] : "ALL (x :: NonZero). x *_3 1_3 = x" ga_left_unit___Xx___20 [rule_format] : "ALL (x :: NonZero). 1_3 *_3 x = x" inv_Group_21 [rule_format] : "ALL (x :: NonZero). inv'(x) *_3 x = 1_3" rinv_Group_19 [rule_format] : "ALL (x :: NonZero). x *_3 inv'(x) = 1_3" binary_inverse [rule_format] : "ALL (x :: Real). ALL (y :: Real). x -_4 y = x +_8 -_3 y" binary_field_inverse [rule_format] : "ALL (x :: Real). ALL (y :: NonZero). x /'' y = x *_6 (X_gn_inj :: NonZero => Real) (inv'(y))" refl [rule_format] : "ALL (x :: Real). x <=_4 x" trans [rule_format] : "ALL (x :: Real). ALL (y :: Real). ALL (z :: Real). x <=_4 y & y <=_4 z --> x <=_4 z" antisym [rule_format] : "ALL (x :: Real). ALL (y :: Real). x <=_4 y & y <=_4 x --> x = y" dichotomy_TotalOrder [rule_format] : "ALL (x :: Real). ALL (y :: Real). x <=_4 y | y <=_4 x" FWO_plus_left [rule_format] : "ALL (a :: Real). ALL (b :: Real). ALL (c :: Real). a <=_4 b --> a +_8 c <=_4 b +_8 c" FWO_times_left [rule_format] : "ALL (a :: Real). ALL (b :: Real). ALL (c :: Real). a <=_4 b & 0_5 <=_4 c --> a *_6 c <=_4 b *_6 c" FWO_plus_right [rule_format] : "ALL (a :: Real). ALL (b :: Real). ALL (c :: Real). b <=_4 c --> a +_8 b <=_4 a +_8 c" FWO_times_right [rule_format] : "ALL (a :: Real). ALL (b :: Real). ALL (c :: Real). b <=_4 c & 0_5 <=_4 a --> a *_6 b <=_4 a *_6 c" FWO_plus [rule_format] : "ALL (a :: Real). ALL (b :: Real). ALL (c :: Real). ALL (d :: Real). a <=_4 c & b <=_4 d --> a +_8 b <=_4 c +_8 d" inf_def [rule_format] : "ALL (S :: Real => bool). ALL (m :: Real). inf''(S) = makePartial m = (ALL (m2 :: Real). (ALL (x :: Real). S x --> x <=_4 m2) --> m <=_4 m2)" Real_completeness [rule_format] : "ALL (S :: Real => bool). (EX (x :: Real). S x) & (EX (B :: Real). ALL (x :: Real). S x --> x <=_4 B) --> (EX (m :: Real). makePartial m = inf''(S))" geq_def_ExtPartialOrder [rule_format] : "ALL (x :: Real). ALL (y :: Real). (x >=_4 y) = (y <=_4 x)" less_def_ExtPartialOrder [rule_format] : "ALL (x :: Real). ALL (y :: Real). (x <_4 y) = (x <=_4 y & ~ x = y)" greater_def_ExtPartialOrder [rule_format] : "ALL (x :: Real). ALL (y :: Real). (x >_4 y) = (y <_4 x)" ga_comm_inf [rule_format] : "ALL (x :: Real). ALL (y :: Real). inf'(x, y) = inf'(y, x)" ga_comm_sup [rule_format] : "ALL (x :: Real). ALL (y :: Real). sup(x, y) = sup(y, x)" inf_def_ExtPartialOrder [rule_format] : "ALL (x :: Real). ALL (y :: Real). ALL (z :: Real). inf'(x, y) = makePartial z = (z <=_4 x & z <=_4 y & (ALL (t :: Real). t <=_4 x & t <=_4 y --> t <=_4 z))" sup_def_ExtPartialOrder [rule_format] : "ALL (x :: Real). ALL (y :: Real). ALL (z :: Real). sup(x, y) = makePartial z = (x <=_4 z & y <=_4 z & (ALL (t :: Real). x <=_4 t & y <=_4 t --> z <=_4 t))" ga_comm_min [rule_format] : "ALL (x :: Real). ALL (y :: Real). min_4(x, y) = min_4(y, x)" ga_comm_max [rule_format] : "ALL (x :: Real). ALL (y :: Real). max_4(x, y) = max_4(y, x)" ga_assoc_min [rule_format] : "ALL (x :: Real). ALL (y :: Real). ALL (z :: Real). min_4(min_4(x, y), z) = min_4(x, min_4(y, z))" ga_assoc_max [rule_format] : "ALL (x :: Real). ALL (y :: Real). ALL (z :: Real). max_4(max_4(x, y), z) = max_4(x, max_4(y, z))" ga_left_comm_min [rule_format] : "ALL (x :: Real). ALL (y :: Real). ALL (z :: Real). min_4(x, min_4(y, z)) = min_4(y, min_4(x, z))" ga_left_comm_max [rule_format] : "ALL (x :: Real). ALL (y :: Real). ALL (z :: Real). max_4(x, max_4(y, z)) = max_4(y, max_4(x, z))" min_def_ExtTotalOrder [rule_format] : "ALL (x :: Real). ALL (y :: Real). min_4(x, y) = (if x <=_4 y then x else y)" max_def_ExtTotalOrder [rule_format] : "ALL (x :: Real). ALL (y :: Real). max_4(x, y) = (if x <=_4 y then y else x)" min_inf_relation [rule_format] : "ALL (x :: Real). ALL (y :: Real). makePartial (min_4(x, y)) = inf'(x, y)" max_sup_relation [rule_format] : "ALL (x :: Real). ALL (y :: Real). makePartial (max_4(x, y)) = sup(x, y)" RealNonNeg_pred_def [rule_format] : "ALL (x :: Real). RealNonNeg_pred(x) = (x >=_4 0_5)" RealPos_pred_def [rule_format] : "ALL (x :: Real). RealPos_pred(x) = (x >_4 0_5)" RealNonNeg_type [rule_format] : "ALL (x :: Real). defOp ((X_gn_proj :: Real => RealNonNeg partial) x) = RealNonNeg_pred(x)" RealPos_type [rule_format] : "ALL (x :: Real). defOp ((X_gn_proj :: Real => RealPos partial) x) = RealPos_pred(x)" abs_def [rule_format] : "ALL (x :: Real). makePartial (abs_3(x)) = (if 0_5 <=_4 x then (X_gn_proj :: Real => RealNonNeg partial) x else (X_gn_proj :: Real => RealNonNeg partial) (-_3 x))" times_cancel_right_nonneg_leq [rule_format] : "ALL (a :: Real). ALL (b :: Real). ALL (c :: Real). a *_6 b <=_4 c *_6 b & b >=_4 0_5 --> a <=_4 c" times_leq_nonneg_cond [rule_format] : "ALL (a :: Real). ALL (b :: Real). 0_5 <=_4 a *_6 b & b >=_4 0_5 --> 0_5 <=_4 a" sqr_def [rule_format] : "ALL (r :: Real). (X_gn_inj :: RealNonNeg => Real) (sqr(r)) = r *_6 r" sqrt_def [rule_format] : "ALL (q :: RealNonNeg). sqr((X_gn_inj :: RealNonNeg => Real) (sqrt(q))) = q" Pos_def [rule_format] : "ALL (x :: Real). X_Pos x = (0_5 <=_4 x)" ga_select_C1 [rule_format] : "ALL (x_1 :: Real). ALL (x_2 :: Real). ALL (x_3 :: Real). C1'(P(x_1, x_2, x_3)) = x_1" ga_select_C2 [rule_format] : "ALL (x_1 :: Real). ALL (x_2 :: Real). ALL (x_3 :: Real). C2'(P(x_1, x_2, x_3)) = x_2" ga_select_C3 [rule_format] : "ALL (x_1 :: Real). ALL (x_2 :: Real). ALL (x_3 :: Real). C3'(P(x_1, x_2, x_3)) = x_3" Zero_Point [rule_format] : "0_3 = P((X_gn_inj :: X_Nat => Real) 0'', (X_gn_inj :: X_Nat => Real) 0'', (X_gn_inj :: X_Nat => Real) 0'')" Point_choice [rule_format] : "ALL (X_P :: Point => bool). (EX (y :: Point). X_P y) --> X_P (choose'(X_P))" ga_select_C1_131 [rule_format] : "ALL (x_1 :: Real). ALL (x_2 :: Real). ALL (x_3 :: Real). C1''(V(x_1, x_2, x_3)) = x_1" ga_select_C2_132 [rule_format] : "ALL (x_1 :: Real). ALL (x_2 :: Real). ALL (x_3 :: Real). C2''(V(x_1, x_2, x_3)) = x_2" ga_select_C3_133 [rule_format] : "ALL (x_1 :: Real). ALL (x_2 :: Real). ALL (x_3 :: Real). C3''(V(x_1, x_2, x_3)) = x_3" Zero_Vector [rule_format] : "0_6 = V((X_gn_inj :: X_Nat => Real) 0'', (X_gn_inj :: X_Nat => Real) 0'', (X_gn_inj :: X_Nat => Real) 0'')" VectorStar_pred_def [rule_format] : "ALL (x :: Vector). VectorStar_pred(x) = (~ x = (X_gn_inj :: X_Nat => Vector) 0'')" VectorStar_type [rule_format] : "ALL (x :: Vector). defOp ((X_gn_proj :: Vector => VectorStar partial) x) = VectorStar_pred(x)" def_of_vector_addition [rule_format] : "ALL (x :: Vector). ALL (y :: Vector). x +_9 y = V(C1''(x) +_8 C1''(y), C2''(x) +_8 C2''(y), C3''(x) +_8 C3''(y))" def_of_minus_vector [rule_format] : "ALL (x :: Vector). -_4 x = V(-_3 C1''(x), -_3 C2''(x), -_3 C3''(x))" binary_inverse_72 [rule_format] : "ALL (x :: Vector). ALL (y :: Vector). x -_5 y = x +_9 -_4 y" scalar_multiplication [rule_format] : "ALL (x :: Real). ALL (y :: Vector). x *_7 y = V(x *_6 C1''(y), x *_6 C2''(y), x *_6 C3''(y))" scalar_product [rule_format] : "ALL (x :: Vector). ALL (y :: Vector). x *_8 y = ((C1''(x) *_6 C1''(y)) +_8 (C2''(x) *_6 C2''(y))) +_8 (C3''(x) *_6 C3''(y))" vector_product [rule_format] : "ALL (x :: Vector). ALL (y :: Vector). x #' y = V(((X_gn_inj :: Real => Vector) (C2''(x)) *_8 (X_gn_inj :: Real => Vector) (C3''(y))) -_4 ((X_gn_inj :: Real => Vector) (C2''(y)) *_8 (X_gn_inj :: Real => Vector) (C3''(x))), ((X_gn_inj :: Real => Vector) (C3''(x)) *_8 (X_gn_inj :: Real => Vector) (C1''(y))) -_4 ((X_gn_inj :: Real => Vector) (C3''(y)) *_8 (X_gn_inj :: Real => Vector) (C1''(x))), ((X_gn_inj :: Real => Vector) (C1''(x)) *_8 (X_gn_inj :: Real => Vector) (C2''(y))) -_4 ((X_gn_inj :: Real => Vector) (C1''(y)) *_8 (X_gn_inj :: Real => Vector) (C2''(x))))" ONB1 [rule_format] : "e1 = V((X_gn_inj :: NonZero => Real) 1_3, (X_gn_inj :: X_Nat => Real) 0'', (X_gn_inj :: X_Nat => Real) 0'')" ONB2 [rule_format] : "e2 = V((X_gn_inj :: X_Nat => Real) 0'', (X_gn_inj :: NonZero => Real) 1_3, (X_gn_inj :: X_Nat => Real) 0'')" ONB3 [rule_format] : "e3 = V((X_gn_inj :: X_Nat => Real) 0'', (X_gn_inj :: X_Nat => Real) 0'', (X_gn_inj :: NonZero => Real) 1_3)" cross_left_homogenity [rule_format] : "ALL (r :: Real). ALL (x :: Vector). ALL (y :: Vector). (X_gn_inj :: Real => Vector) ((X_gn_inj :: Real => Vector) r *_8 (x #' y)) = (X_gn_inj :: Real => Vector) ((X_gn_inj :: Real => Vector) r *_8 x) #' y" cross_product_antisymmetric [rule_format] : "ALL (x :: Vector). ALL (y :: Vector). x #' y = -_4 (y #' x)" ga_assoc___Xx___82 [rule_format] : "ALL (x :: Vector). ALL (y :: Vector). ALL (z :: Vector). (x +_9 y) +_9 z = x +_9 (y +_9 z)" ga_right_unit___Xx___76 [rule_format] : "ALL (x :: Vector). x +_9 0_6 = x" ga_left_unit___Xx___78 [rule_format] : "ALL (x :: Vector). 0_6 +_9 x = x" inv_Group_79 [rule_format] : "ALL (x :: Vector). -_4 x +_9 x = 0_6" rinv_Group_77 [rule_format] : "ALL (x :: Vector). x +_9 -_4 x = 0_6" ga_comm___Xx___80 [rule_format] : "ALL (x :: Vector). ALL (y :: Vector). x +_9 y = y +_9 x" unit [rule_format] : "ALL (x :: Vector). (X_gn_inj :: NonZero => Real) 1_3 *_7 x = x" mix_assoc [rule_format] : "ALL (r :: Real). ALL (s :: Real). ALL (x :: Vector). (r *_6 s) *_7 x = r *_7 (s *_7 x)" distr_Field [rule_format] : "ALL (r :: Real). ALL (s :: Real). ALL (x :: Vector). (r +_8 s) *_7 x = (r *_7 x) +_9 (s *_7 x)" distr_Space [rule_format] : "ALL (r :: Real). ALL (x :: Vector). ALL (y :: Vector). r *_7 (x +_9 y) = (r *_7 x) +_9 (r *_7 y)" zero_by_left_zero [rule_format] : "ALL (x :: Vector). 0_5 *_7 x = 0_6" zero_by_right_zero [rule_format] : "ALL (r :: Real). r *_7 0_6 = 0_6" inverse_by_XMinus1 [rule_format] : "ALL (x :: Vector). -_3 (X_gn_inj :: NonZero => Real) 1_3 *_7 x = -_4 x" no_zero_divisor [rule_format] : "ALL (r :: Real). ALL (x :: Vector). ~ r = 0_5 & ~ x = 0_6 --> ~ r *_7 x = 0_6" distributive [rule_format] : "ALL (v :: Vector). ALL (v' :: Vector). ALL (w :: Vector). (v +_9 v') *_8 w = (v *_8 w) +_8 (v' *_8 w)" homogeneous [rule_format] : "ALL (a :: Real). ALL (v :: Vector). ALL (w :: Vector). (a *_7 v) *_8 w = a *_6 (v *_8 w)" symmetric [rule_format] : "ALL (v :: Vector). ALL (w :: Vector). v *_8 w = w *_8 v" pos_definite [rule_format] : "ALL (v :: Vector). ~ v = 0_6 --> v *_8 v >_4 0_5" right_distributive [rule_format] : "ALL (v :: Vector). ALL (v' :: Vector). ALL (w :: Vector). w *_8 (v +_9 v') = (w *_8 v) +_8 (w *_8 v')" right_homogeneous [rule_format] : "ALL (a :: Real). ALL (v :: Vector). ALL (w :: Vector). v *_8 (a *_7 w) = a *_6 (v *_8 w)" non_degenerate [rule_format] : "ALL (v :: Vector). v *_8 v = 0_5 --> v = 0_6" lindep_def [rule_format] : "ALL (x :: Vector). ALL (y :: Vector). lindep(x, y) = (y = 0_6 | (EX (r :: Real). x = r *_7 y))" lindep_reflexivity [rule_format] : "ALL (x :: Vector). lindep(x, x)" lindep_symmetry [rule_format] : "ALL (x :: Vector). ALL (y :: Vector). lindep(x, y) --> lindep(y, x)" simple_lindep_condition [rule_format] : "ALL (r :: Real). ALL (x :: Vector). ALL (y :: Vector). x = r *_7 y --> lindep(x, y)" lindep_nonlindep_transitivity [rule_format] : "ALL (x :: Vector). ALL (y :: Vector). ALL (z :: Vector). (~ x = 0_6 & lindep(x, y)) & ~ lindep(y, z) --> ~ lindep(x, z)" norm_from_inner_prod_def [rule_format] : "ALL (x :: Vector). makePartial ( || x || ) = restrictOp (makePartial ((X_gn_inj :: RealNonNeg => Real) (sqrt(makeTotal ((X_gn_proj :: Real => RealNonNeg partial) (x *_8 x)))))) (defOp ((X_gn_proj :: Real => RealNonNeg partial) (x *_8 x)))" proj_def [rule_format] : "ALL (v :: Vector). ALL (w :: Vector). makePartial (proj(v, w)) = (if w = 0_6 then makePartial 0_6 else restrictOp (makePartial (((v *_8 w) /'' makeTotal ((X_gn_proj :: Real => NonZero partial) (w *_8 w))) *_7 w)) (defOp ((X_gn_proj :: Real => NonZero partial) (w *_8 w))))" orthcomp_def [rule_format] : "ALL (v :: Vector). ALL (w :: Vector). orthcomp(v, w) = v -_5 proj(v, w)" orthogonal_def [rule_format] : "ALL (x :: Vector). ALL (y :: Vector). orth(x, y) = (x *_8 y = 0_5)" homogeneous_93 [rule_format] : "ALL (r :: Real). ALL (v :: Vector). || r *_7 v || = (X_gn_inj :: RealNonNeg => Real) (abs_3(r)) *_6 || v ||" definite [rule_format] : "ALL (v :: Vector). || v || = 0_5 = (v = 0_6)" pos_definite_94 [rule_format] : "ALL (v :: Vector). 0_5 <=_4 || v ||" pos_homogeneous [rule_format] : "ALL (r :: Real). ALL (v :: Vector). r >=_4 0_5 --> || r *_7 v || = r *_6 || v ||" orth_symmetric [rule_format] : "ALL (x :: Vector). ALL (y :: Vector). orth(x, y) --> orth(y, x)" lindep_orth_transitive [rule_format] : "ALL (x :: Vector). ALL (y :: Vector). ALL (z :: Vector). lindep(x, y) & orth(y, z) --> orth(x, z)" orthogonal_existence_theorem [rule_format] : "ALL (x :: Vector). (EX (a :: Vector). EX (b :: Vector). ~ lindep(a, b)) --> (EX (c :: Vector). ~ c = 0_6 & orth(c, x))" orthogonal_on_zero_projection [rule_format] : "ALL (x :: Vector). ALL (y :: Vector). proj(x, y) = 0_6 --> orth(x, y)" orthogonal_projection_theorem [rule_format] : "ALL (x :: Vector). ALL (y :: Vector). orth(orthcomp(x, y), y)" orthogonal_decomposition_theorem [rule_format] : "ALL (x :: Vector). ALL (y :: Vector). proj(x, y) +_9 orthcomp(x, y) = x" unique_orthogonal_decomposition [rule_format] : "ALL (v :: Vector). ALL (w :: Vector). ALL (x :: Vector). ALL (y :: Vector). ALL (z :: Vector). ((((~ z = 0_6 & x +_9 y = v +_9 w) & lindep(x, z)) & lindep(v, z)) & orth(z, y)) & orth(z, w) --> x = v & y = w" ga_select_first [rule_format] : "ALL (x_1 :: 'a). ALL (x_2 :: 'a List). first(x_1 ::' x_2) = makePartial x_1" ga_select_rest [rule_format] : "ALL (x_1 :: 'a). ALL (x_2 :: 'a List). rest(x_1 ::' x_2) = makePartial x_2" Ax4 [rule_format] : "ALL (f :: 'a => 'b). X_map f ['] = [']" Ax5 [rule_format] : "ALL (f :: 'a => 'b). ALL (l :: 'a List). ALL (x :: 'a). X_map f (x ::' l) = f x ::' X_map f l" ga_assoc___Xx___83 [rule_format] : "ALL (x :: Vector). ALL (y :: Vector). ALL (z :: Vector). (x *_9 y) *_9 z = x *_9 (y *_9 z)" ga_right_unit___Xx___81 [rule_format] : "ALL (x :: Vector). x *_9 0_6 = x" ga_left_unit___Xx___82 [rule_format] : "ALL (x :: Vector). 0_6 *_9 x = x" listop_basecase [rule_format] : "sum([']) = 0_6" listop_reccase [rule_format] : "ALL (l :: Vector List). ALL (x :: Vector). sum(x ::' l) = x *_9 sum(l)" cross_product_orthogonal [rule_format] : "ALL (x :: Vector). ALL (y :: Vector). orth(x, x #' y)" cross_product_zero_iff_lindep [rule_format] : "ALL (x :: Vector). ALL (y :: Vector). lindep(x, y) = (x #' y = (X_gn_inj :: X_Nat => Vector) 0'')" e1e2_nonlindep [rule_format] : "~ lindep(e1, e2)" point_vector_map [rule_format] : "ALL (p :: Point). ALL (v :: Vector). p +_4 v = P(C1'(p) +_8 C1''(v), C2'(p) +_8 C2''(v), C3'(p) +_8 C3''(v))" plus_injective [rule_format] : "ALL (p :: Point). ALL (v :: Vector). ALL (w :: Vector). p +_4 v = p +_4 w --> v = w" plus_surjective [rule_format] : "ALL (p :: Point). ALL (q :: Point). EX (y :: Vector). p +_4 y = q" point_vector_plus_associative [rule_format] : "ALL (p :: Point). ALL (v :: Vector). ALL (w :: Vector). p +_4 (v +_9 w) = (p +_4 v) +_4 w" vec_def [rule_format] : "ALL (p :: Point). ALL (q :: Point). p +_4 vec(p, q) = q" transitivity_of_vec_plus [rule_format] : "ALL (p :: Point). ALL (q :: Point). ALL (r :: Point). vec(p, q) +_9 vec(q, r) = vec(p, r)" plus_vec_identity [rule_format] : "ALL (p :: Point). ALL (q :: Point). ALL (v :: Vector). p +_4 v = q --> v = vec(p, q)" set_comprehension [rule_format] : "ALL (s :: 'S => bool). XLBrace__XRBrace s = s" abbrev_of_set_comprehension [rule_format] : "setFromProperty = XLBrace__XRBrace" function_image [rule_format] : "ALL (XX :: 'S => bool). ALL (f :: 'S => 'T). X_image (f, XX) = (% x. EX (y :: 'S). y isIn XX & f y = x)" emptySet_empty [rule_format] : "ALL (x :: 'S). ~ x isIn X_emptySet" allSet_contains_all [rule_format] : "ALL (x :: 'S). x isIn X_allSet" def_of_isIn [rule_format] : "ALL (s :: 'S => bool). ALL (x :: 'S). (x isIn s) = s x" def_of_subset [rule_format] : "ALL (s :: 'S => bool). ALL (s' :: 'S => bool). (s subset s') = (ALL (x :: 'S). x isIn s --> x isIn s')" def_of_union [rule_format] : "ALL (s :: 'S => bool). ALL (s' :: 'S => bool). ALL (x :: 'S). (x isIn X__union__X (s, s')) = (x isIn s | x isIn s')" def_of_bigunion [rule_format] : "ALL (XXXX :: ('S => bool) => bool). ALL (x :: 'S). (x isIn bigunion XXXX) = (EX (XX :: 'S => bool). XX isIn XXXX & x isIn XX)" def_of_intersection [rule_format] : "ALL (s :: 'S => bool). ALL (s' :: 'S => bool). ALL (x :: 'S). (x isIn X__intersection__X (s, s')) = (x isIn s & x isIn s')" def_of_difference [rule_format] : "ALL (s :: 'S => bool). ALL (s' :: 'S => bool). ALL (x :: 'S). (x isIn X__XBslashXBslash__X (s, s')) = (x isIn s & ~ x isIn s')" def_of_disjoint [rule_format] : "ALL (s :: 'S => bool). ALL (s' :: 'S => bool). (s disjoint s') = (X__intersection__X (s, s') = X_emptySet)" def_of_productset [rule_format] : "ALL (s :: 'S => bool). ALL (t :: 'T => bool). ALL (x :: 'S). ALL (y :: 'T). ((x, y) isIn X__Xx__XX10 (s, t)) = (x isIn s & y isIn t)" emptySet_union_right_unit [rule_format] : "ALL (a :: 'S => bool). X__union__X (a, X_emptySet) = a" function_image_structure [rule_format] : "ALL (a :: 'S => bool). ALL (f :: 'S => 'T). ALL (x :: 'T). (x isIn X_image (f, a)) = (EX (y :: 'S). y isIn a & f y = x)" def_of_interval [rule_format] : "ALL (a :: Real). ALL (b :: Real). XOSqBr__XPeriodXPeriodXPeriod__XCSqBr (a, b) = (% r. r >=_4 a & r <=_4 b)" abbrev_of_interval [rule_format] : "closedinterval = XOSqBr__XPeriodXPeriodXPeriod__XCSqBr" plus_PointSet_Vector [rule_format] : "ALL (X_P :: Point => bool). ALL (v :: Vector). X__XPlus__XX10 (X_P, v) = X_image (% x. x +_4 v, X_P)" plus_Point_VectorSet [rule_format] : "ALL (X_V :: Vector => bool). ALL (p :: Point). X__XPlus__XX5 (p, X_V) = X_image (% x. p +_4 x, X_V)" plus_PointSet_VectorSet [rule_format] : "ALL (X_P :: Point => bool). ALL (X_V :: Vector => bool). X__XPlus__XX11 (X_P, X_V) = bigunion (X_image (% x. X__XPlus__XX10 (X_P, x), X_V))" def_of_Plane [rule_format] : "ALL (normal :: VectorStar). ALL (X_offset :: Point). PlaneX2 (X_offset, normal) = (% x. orth(vec(x, X_offset), (X_gn_inj :: VectorStar => Vector) normal))" plane_condition_for_2_points [rule_format] : "ALL (normal :: VectorStar). ALL (X_offset :: Point). ALL (x :: Point). ALL (y :: Point). let X_plane = PlaneX2 (X_offset, normal) in x isIn X_plane & y isIn X_plane --> orth(vec(x, y), (X_gn_inj :: VectorStar => Vector) normal)" plane_condition_for_point_and_vector [rule_format] : "ALL (normal :: VectorStar). ALL (X_offset :: Point). ALL (v :: Vector). ALL (x :: Point). let X_plane = PlaneX2 (X_offset, normal) in x isIn X_plane & orth(v, (X_gn_inj :: VectorStar => Vector) normal) --> x +_4 v isIn X_plane" ga_select_SpacePoint [rule_format] : "ALL (x_1 :: Point). ALL (x_2 :: VectorStar). ALL (x_3 :: Vector). SpacePoint(X_SWPlane x_1 x_2 x_3) = x_1" ga_select_NormalVector [rule_format] : "ALL (x_1 :: Point). ALL (x_2 :: VectorStar). ALL (x_3 :: Vector). NormalVector(X_SWPlane x_1 x_2 x_3) = x_2" ga_select_InnerCS [rule_format] : "ALL (x_1 :: Point). ALL (x_2 :: VectorStar). ALL (x_3 :: Vector). InnerCS(X_SWPlane x_1 x_2 x_3) = x_3" ga_select_Center [rule_format] : "ALL (x_1 :: Point). ALL (x_2 :: Point). ALL (x_3 :: Point). Center(X_SWArc x_1 x_2 x_3) = x_1" ga_select_Start [rule_format] : "ALL (x_1 :: Point). ALL (x_2 :: Point). ALL (x_3 :: Point). Start(X_SWArc x_1 x_2 x_3) = x_2" ga_select_End [rule_format] : "ALL (x_1 :: Point). ALL (x_2 :: Point). ALL (x_3 :: Point). End(X_SWArc x_1 x_2 x_3) = x_3" ga_select_From [rule_format] : "ALL (x_1 :: Point). ALL (x_2 :: Point). From(X_SWLine x_1 x_2) = x_1" ga_select_To [rule_format] : "ALL (x_1 :: Point). ALL (x_2 :: Point). To(X_SWLine x_1 x_2) = x_2" ga_select_Points [rule_format] : "ALL (x_1 :: Point List). Points(X_SWSpline x_1) = x_1" ga_select_Objects [rule_format] : "ALL (x_1 :: SWSketchObject List). ALL (x_2 :: SWPlane). Objects_3(X_SWSketch x_1 x_2) = x_1" ga_select_Plane [rule_format] : "ALL (x_1 :: SWSketchObject List). ALL (x_2 :: SWPlane). Plane'(X_SWSketch x_1 x_2) = x_2" ga_select_Objects_1 [rule_format] : "ALL (x_1 :: SWSkchCtrtParam List). Objects'(X_SWSkchCtrtObject x_1) = x_1" ga_select_SkchCtrtStatus [rule_format] : "ALL (x_1 :: SWSkchCtrtStatus). ALL (x_2 :: SWSkchCtrtObject List). SkchCtrtStatus(X_SWSkchCtrts x_1 x_2) = x_1" ga_select_Objects_2 [rule_format] : "ALL (x_1 :: SWSkchCtrtStatus). ALL (x_2 :: SWSkchCtrtObject List). Objects''(X_SWSkchCtrts x_1 x_2) = x_2" ga_select_Sketch [rule_format] : "ALL (x_1 :: SWSketch). ALL (x_2 :: Real). Sketch(X_SWExtrusion x_1 x_2) = x_1" ga_select_Depth [rule_format] : "ALL (x_1 :: SWSketch). ALL (x_2 :: Real). Depth(X_SWExtrusion x_1 x_2) = x_2" E1_def [rule_format] : "makePartial E1 = restrictOp (makePartial (X_SWPlane (P((X_gn_inj :: X_Nat => Real) 0'', (X_gn_inj :: X_Nat => Real) 0'', (X_gn_inj :: X_Nat => Real) 0'')) (makeTotal ((X_gn_proj :: Vector => VectorStar partial) (V((X_gn_inj :: X_Nat => Real) 0'', (X_gn_inj :: X_Nat => Real) 0'', (X_gn_inj :: NonZero => Real) 1_3)))) (V((X_gn_inj :: NonZero => Real) 1_3, (X_gn_inj :: X_Nat => Real) 0'', (X_gn_inj :: X_Nat => Real) 0'')))) (defOp ((X_gn_proj :: Vector => VectorStar partial) (V((X_gn_inj :: X_Nat => Real) 0'', (X_gn_inj :: X_Nat => Real) 0'', (X_gn_inj :: NonZero => Real) 1_3))))" E2_def [rule_format] : "makePartial E2 = restrictOp (makePartial (X_SWPlane (P((X_gn_inj :: X_Nat => Real) 0'', (X_gn_inj :: X_Nat => Real) 0'', (X_gn_inj :: X_Nat => Real) 0'')) (makeTotal ((X_gn_proj :: Vector => VectorStar partial) (V((X_gn_inj :: X_Nat => Real) 0'', (X_gn_inj :: NonZero => Real) 1_3, (X_gn_inj :: X_Nat => Real) 0'')))) (V((X_gn_inj :: NonZero => Real) 1_3, (X_gn_inj :: X_Nat => Real) 0'', (X_gn_inj :: X_Nat => Real) 0'')))) (defOp ((X_gn_proj :: Vector => VectorStar partial) (V((X_gn_inj :: X_Nat => Real) 0'', (X_gn_inj :: NonZero => Real) 1_3, (X_gn_inj :: X_Nat => Real) 0''))))" E3_def [rule_format] : "makePartial E3 = restrictOp (makePartial (X_SWPlane (P((X_gn_inj :: X_Nat => Real) 0'', (X_gn_inj :: X_Nat => Real) 0'', (X_gn_inj :: X_Nat => Real) 0'')) (makeTotal ((X_gn_proj :: Vector => VectorStar partial) (V((X_gn_inj :: NonZero => Real) 1_3, (X_gn_inj :: X_Nat => Real) 0'', (X_gn_inj :: X_Nat => Real) 0'')))) (V((X_gn_inj :: X_Nat => Real) 0'', (X_gn_inj :: NonZero => Real) 1_3, (X_gn_inj :: X_Nat => Real) 0'')))) (defOp ((X_gn_proj :: Vector => VectorStar partial) (V((X_gn_inj :: NonZero => Real) 1_3, (X_gn_inj :: X_Nat => Real) 0'', (X_gn_inj :: X_Nat => Real) 0''))))" VLine_constr [rule_format] : "ALL (p1 :: Vector). ALL (p2 :: Vector). VLine (p1, p2) = X_image (% y. p1 +_9 (X_gn_inj :: Real => Vector) ((X_gn_inj :: Real => Vector) y *_8 (p2 -_5 p1)), closedinterval ((X_gn_inj :: X_Nat => Real) 0'', (X_gn_inj :: NonZero => Real) 1_3))" VWithLength_constr [rule_format] : "ALL (s :: Real). ALL (v :: Vector). makePartial (VWithLength(v, s)) = (if v = (X_gn_inj :: X_Nat => Vector) 0'' then makePartial v else restrictOp (makePartial ((X_gn_inj :: Real => Vector) ((X_gn_inj :: Real => Vector) (s /'' makeTotal ((X_gn_proj :: Real => NonZero partial) ( || v || ))) *_8 v))) (defOp ((X_gn_proj :: Real => NonZero partial) ( || v || ))))" VPlane_constr [rule_format] : "ALL (normal :: Vector). VPlane normal = (% y. orth(y, normal))" VPlane2_constr [rule_format] : "ALL (axis1 :: Vector). ALL (axis2 :: Vector). VPlane2 (axis1, axis2) = VPlane (axis1 #' axis2)" VConnected_constr [rule_format] : "ALL (frontier :: Vector => bool). ALL (point :: Vector). VConnected (frontier, point) = (if frontier point then frontier else % y. X__intersection__X (VLine (point, y), frontier) = X_emptySet)" VHalfSpace_constr [rule_format] : "ALL (normal :: Vector). VHalfSpace normal = VConnected (VPlane normal, normal)" VHalfSpace2_constr [rule_format] : "ALL (normal :: Vector). VHalfSpace2 normal = X__union__X (VConnected (VPlane normal, normal), VPlane normal)" VBall_constr [rule_format] : "ALL (r :: Real). VBall r = (% y. || y || <=_4 r)" VCircle_constr [rule_format] : "ALL (X_axis :: Vector). ALL (r :: Real). VCircle (r, X_axis) = X__intersection__X (VPlane X_axis, VBall r)" ActAttach_constr [rule_format] : "ALL (point :: Point). ALL (vectors :: Vector => bool). ActAttach (point, vectors) = X__XPlus__XX5 (point, vectors)" ActExtrude_constr [rule_format] : "ALL (X_axis :: Vector). ALL (points :: Point => bool). ActExtrude (X_axis, points) = (% x. EX (l :: Real). EX (y :: Point). (l isIn closedinterval ((X_gn_inj :: X_Nat => Real) 0'', (X_gn_inj :: NonZero => Real) 1_3) & y isIn points) & x = y +_4 (X_gn_inj :: Real => Vector) ((X_gn_inj :: Real => Vector) l *_8 X_axis))" vwl_identity [rule_format] : "ALL (s :: Real). ALL (v :: Vector). || v || = s --> VWithLength(v, s) = v" vwl_length [rule_format] : "ALL (s :: Real). ALL (v :: Vector). ~ v = (X_gn_inj :: X_Nat => Vector) 0'' --> || VWithLength(v, s) || = (X_gn_inj :: RealNonNeg => Real) (abs_3(s))" vwl_lindep [rule_format] : "ALL (s :: Real). ALL (v :: Vector). lindep(v, VWithLength(v, s))" semantics_for_Planes [rule_format] : "ALL (ics :: Vector). ALL (X_n :: VectorStar). ALL (X_o :: Point). iX2 (X_SWPlane X_o X_n ics) = ActAttach (X_o, VPlane ((X_gn_inj :: VectorStar => Vector) X_n))" semantics_for_SketchObject_listsXMinusBaseCase [rule_format] : "ALL (X_plane :: SWPlane). X_isX2 (['], X_plane) = X_emptySet" semantics_for_SketchObject_listsXMinusRecursiveCase [rule_format] : "ALL (X_plane :: SWPlane). ALL (sko :: SWSketchObject). ALL (skos :: SWSketchObject List). X_isX2 (sko ::' skos, X_plane) = X__union__X (X_isX1 (sko, X_plane), X_isX2 (skos, X_plane))" semantics_for_Arcs [rule_format] : "ALL (X_plane :: SWPlane). ALL (x :: Point). ALL (y :: Point). ALL (z :: Point). X_isX1 ((X_gn_inj :: SWArc => SWSketchObject) (X_SWArc x y z), X_plane) = (let r1 = vec(x, y); ball = ActAttach (x, VBall ( || r1 || )); planeI = iX2 X_plane in X__intersection__X (ball, planeI))" semantics_for_Sketches [rule_format] : "ALL (X_plane :: SWPlane). ALL (skos :: SWSketchObject List). iX3 (X_SWSketch skos X_plane) = X_isX2 (skos, X_plane)" semantics_for_ArcExtrusion [rule_format] : "ALL (l :: Real). ALL (sk :: SWSketch). iX1 ((X_gn_inj :: SWExtrusion => SWFeature) (X_SWExtrusion sk l)) = ActExtrude (VWithLength((X_gn_inj :: VectorStar => Vector) (NormalVector(Plane'(sk))), l), iX3 sk)" plane_is_plane [rule_format] : "ALL (X_plane :: SWPlane). iX2 X_plane = PlaneX2 (SpacePoint(X_plane), NormalVector(X_plane))" def_of_Cylinder [rule_format] : "ALL (X_axis :: VectorStar). ALL (X_offset :: Point). ALL (r :: RealPos). Cylinder ((X_offset, r), X_axis) = (% x. let v = vec(X_offset, x) in ( || proj(v, (X_gn_inj :: VectorStar => Vector) X_axis) || <=_4 || (X_gn_inj :: VectorStar => Vector) X_axis || & || orthcomp(v, (X_gn_inj :: VectorStar => Vector) X_axis) || <=_4 (X_gn_inj :: RealPos => Real) r) & v *_8 (X_gn_inj :: VectorStar => Vector) X_axis >=_4 (X_gn_inj :: X_Nat => Real) 0'')" def_of_given_arc [rule_format] : "arc = X_SWArc center boundarypoint boundarypoint" cylinder_offset [rule_format] : "offset = center" cylinder_radius [rule_format] : "makePartial radius = (X_gn_proj :: Real => RealPos partial) ( || vec(center, boundarypoint) || )" cylinder_axis [rule_format] : "makePartial axis = (X_gn_proj :: Vector => VectorStar partial) (VWithLength((X_gn_inj :: VectorStar => Vector) (NormalVector(plane)), (X_gn_inj :: RealPos => Real) height))" real_extrusion [rule_format] : "(X_gn_inj :: RealPos => Real) height >_4 (X_gn_inj :: X_Nat => Real) 0''" real_arc [rule_format] : "~ center = boundarypoint" the_arc_is_wellformed [rule_format] : "let p = iX2 plane in center isIn p & boundarypoint isIn p" declare ga_subt_reflexive [simp] declare ga_subt_Int_XLt_Rat [simp] declare ga_subt_Nat_XLt_Int [simp] declare ga_subt_NonZero_XLt_Real [simp] declare ga_subt_Pos_XLt_Nat [simp] declare ga_subt_Rat_XLt_Real [simp] declare ga_subt_Real_XLt_Point [simp] declare ga_subt_Real_XLt_Vector [simp] declare ga_subt_RealNonNeg_XLt_Real [simp] declare ga_subt_RealPos_XLt_RealNonNeg [simp] declare ga_subt_SWArc_XLt_SWSketchObject [simp] declare ga_subt_SWExtrusion_XLt_SWFeature [simp] declare ga_subt_SWFeature_XLt_SWObject [simp] declare ga_subt_SWLine_XLt_SWSketchObject [simp] declare ga_subt_SWPlane_XLt_SWObject [simp] declare ga_subt_SWSketch_XLt_SWObject [simp] declare ga_subt_SWSketchObject_XLt_SWObject [simp] declare ga_subt_SWSpline_XLt_SWSketchObject [simp] declare ga_subt_VectorStar_XLt_Vector [simp] declare ga_assoc___Xx__ [simp] declare ga_right_unit___Xx__ [simp] declare ga_left_unit___Xx__ [simp] declare inv_Group [simp] declare rinv_Group [simp] declare ga_comm___Xx__ [simp] declare ga_assoc___Xx___9 [simp] declare ga_right_unit___Xx___7 [simp] declare ga_left_unit___Xx___8 [simp] declare left_zero [simp] declare right_zero [simp] declare ga_comm___Xx___14 [simp] declare ga_assoc___Xx___22 [simp] declare ga_right_unit___Xx___18 [simp] declare ga_left_unit___Xx___20 [simp] declare inv_Group_21 [simp] declare rinv_Group_19 [simp] declare refl [simp] declare FWO_plus_left [simp] declare FWO_plus_right [simp] declare ga_comm_inf [simp] declare ga_comm_sup [simp] declare ga_comm_min [simp] declare ga_comm_max [simp] declare ga_assoc_min [simp] declare ga_assoc_max [simp] declare ga_left_comm_min [simp] declare ga_left_comm_max [simp] declare min_inf_relation [simp] declare max_sup_relation [simp] declare RealNonNeg_type [simp] declare RealPos_type [simp] declare sqrt_def [simp] declare ga_select_C1 [simp] declare ga_select_C2 [simp] declare ga_select_C3 [simp] declare ga_select_C1_131 [simp] declare ga_select_C2_132 [simp] declare ga_select_C3_133 [simp] declare VectorStar_type [simp] declare ga_assoc___Xx___82 [simp] declare ga_right_unit___Xx___76 [simp] declare ga_left_unit___Xx___78 [simp] declare inv_Group_79 [simp] declare rinv_Group_77 [simp] declare ga_comm___Xx___80 [simp] declare unit [simp] declare zero_by_left_zero [simp] declare zero_by_right_zero [simp] declare inverse_by_XMinus1 [simp] declare lindep_reflexivity [simp] declare lindep_symmetry [simp] declare pos_definite_94 [simp] declare orth_symmetric [simp] declare orthogonal_on_zero_projection [simp] declare orthogonal_projection_theorem [simp] declare orthogonal_decomposition_theorem [simp] declare ga_select_first [simp] declare ga_select_rest [simp] declare Ax4 [simp] declare ga_assoc___Xx___83 [simp] declare ga_right_unit___Xx___81 [simp] declare ga_left_unit___Xx___82 [simp] declare listop_basecase [simp] declare cross_product_orthogonal [simp] declare e1e2_nonlindep [simp] declare vec_def [simp] declare transitivity_of_vec_plus [simp] declare emptySet_empty [simp] declare allSet_contains_all [simp] declare def_of_isIn [simp] declare emptySet_union_right_unit [simp] declare ga_select_SpacePoint [simp] declare ga_select_NormalVector [simp] declare ga_select_InnerCS [simp] declare ga_select_Center [simp] declare ga_select_Start [simp] declare ga_select_End [simp] declare ga_select_From [simp] declare ga_select_To [simp] declare ga_select_Points [simp] declare ga_select_Objects [simp] declare ga_select_Plane [simp] declare ga_select_Objects_1 [simp] declare ga_select_SkchCtrtStatus [simp] declare ga_select_Objects_2 [simp] declare ga_select_Sketch [simp] declare ga_select_Depth [simp] declare vwl_identity [simp] declare vwl_lindep [simp] declare semantics_for_SketchObject_listsXMinusBaseCase [simp] declare semantics_for_Sketches [simp] declare real_extrusion [simp] theorem extrusion_is_cylinder : "iX1 ((X_gn_inj :: SWExtrusion => SWFeature) (X_SWExtrusion (X_SWSketch ((X_gn_inj :: SWArc => SWSketchObject) arc ::' [']) plane) ((X_gn_inj :: RealPos => Real) height))) = Cylinder ((offset, radius), axis)" using binary_field_inverse inf_def RealNonNeg_pred_def RealPos_pred_def abs_def sqr_def sqrt_def Pos_def Zero_Point Zero_Vector VectorStar_pred_def scalar_multiplication scalar_product vector_product ONB1 ONB2 ONB3 lindep_def norm_from_inner_prod_def proj_def orthcomp_def orthogonal_def point_vector_map vec_def set_comprehension abbrev_of_set_comprehension function_image def_of_interval abbrev_of_interval plus_PointSet_Vector plus_Point_VectorSet plus_PointSet_VectorSet def_of_Plane E1_def E2_def E3_def VLine_constr VWithLength_constr VPlane_constr VPlane2_constr VConnected_constr VHalfSpace_constr VHalfSpace2_constr VBall_constr VCircle_constr ActAttach_constr ActExtrude_constr def_of_Cylinder def_of_given_arc cylinder_offset cylinder_radius cylinder_axis by (auto) ML "Header.record \"extrusion_is_cylinder\"" end
variables A B : Prop open classical example : ¬ A → false → A := sorry example : ¬ A ∨ ¬ B → ¬ (A ∧ B) := assume h, show ¬ (A ∧ B), from assume h1 : A ∧ B, show false, from or.elim h (assume na : ¬ A, show false, from na h1.left) (assume nb : ¬ B, show false, from nb h1.right) -- Prove ¬ (A ∧ B) → ¬ A ∨ ¬ B by replacing the sorry's below -- by proofs. lemma step1 (h₁ : ¬ (A ∧ B)) (h₂ : A) : ¬ A ∨ ¬ B := have ¬ B, from assume b : B, show false, from h₁ (and.intro h₂ b), show ¬ A ∨ ¬ B, from or.inr this lemma step2 (h₁ : ¬ (A ∧ B)) (h₂ : ¬ (¬ A ∨ ¬ B)) : false := have ¬ A, from assume : A, have ¬ A ∨ ¬ B, from step1 h₁ ‹A›, show false, from h₂ this, show false, from h₂ (or.inl this) theorem step3 (h : ¬ (A ∧ B)) : ¬ A ∨ ¬ B := by_contradiction (assume h' : ¬ (¬ A ∨ ¬ B), show false, from step2 h h') example (h : ¬ B → ¬ A) : A → B := assume a, by_contradiction (assume h1 : ¬ B, show false, from h h1 a) example (h : A → B) : ¬ A ∨ B := by_contradiction (assume h1 : ¬ (¬ A ∨ B), show false, from have a : ¬ A, from assume aa : A, show false, from h1 (or.inr (h aa)), h1 (or.inl a))
------------------------------------------------------------------------ -- The Agda standard library -- -- Data.List.Any.Membership instantiated with propositional equality, -- along with some additional definitions. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.Membership.Propositional {a} {A : Set a} where open import Data.List.Relation.Unary.Any using (Any) open import Relation.Binary.PropositionalEquality using (_≡_; _≢_; setoid; subst) import Data.List.Membership.Setoid as SetoidMembership ------------------------------------------------------------------------ -- Re-export contents of setoid membership open SetoidMembership (setoid A) public hiding (lose) ------------------------------------------------------------------------ -- Different members _≢∈_ : ∀ {x y : A} {xs} → x ∈ xs → y ∈ xs → Set _ _≢∈_ x∈xs y∈xs = ∀ x≡y → subst (_∈ _) x≡y x∈xs ≢ y∈xs ------------------------------------------------------------------------ -- Other operations lose : ∀ {p} {P : A → Set p} {x xs} → x ∈ xs → P x → Any P xs lose = SetoidMembership.lose (setoid A) (subst _)
Require Import Coq.Classes.Morphisms. Require Import Coq.ZArith.ZArith Coq.micromega.Lia. Require Import Crypto.Util.Tactics.BreakMatch. Require Import Crypto.Util.Tactics.DestructHead. Require Import Crypto.Util.ZUtil.Definitions. Require Import Crypto.Util.ZUtil.Hints.PullPush. Require Import Crypto.Util.ZUtil.ZSimplify.Core. Require Import Crypto.Util.ZUtil.ZSimplify.Simple. Require Import Crypto.Util.ZUtil.Tactics.DivModToQuotRem. Require Import Crypto.Util.ZUtil.Tactics.ZeroBounds. Require Import Crypto.Util.ZUtil.Tactics.LtbToLt. Local Open Scope Z_scope. Module Z. #[global] Hint Rewrite Z.log2_pow2 Z.pow_1_r using solve [auto using Z.log2_nonneg with zarith] : push_Zpow. Lemma cc_m_eq_full : forall s x, Z.cc_m s x = if (s =? 1) then x * 2 else x / (s / 2). Proof. intros; cbv [Z.cc_m]. destruct (Decidable.dec (2 < s)). { assert (1 <= Z.log2 s) by (rewrite <-Z.log2_2; auto using Z.log2_le_mono with lia). break_match; Z.ltb_to_lt; try lia; []. match goal with H : _ = s |- _ => rewrite <-H end. autorewrite with Zshift_to_pow push_Zpow. reflexivity. } { assert (s < 0 \/ s = 0 \/ s = 1 \/ s = 2) by lia. destruct_head'_or; (subst s || destruct s); try reflexivity; try (cbn; autorewrite with zsimplify_const; lia). change (Z.log2 1 - 1) with (-1). rewrite (Z.shiftr_opp_r _ 1), Z.shiftl_mul_pow2 by lia. reflexivity. } Qed. Lemma cc_m_eq : forall s x, 2 < s -> Z.cc_m s x = x / (s / 2). Proof. intros; rewrite cc_m_eq_full; break_match; Z.ltb_to_lt; lia. Qed. Lemma cc_m_small : forall s x, s mod 2 = 0 -> 0 <= x < s -> 0 <= Z.cc_m s x < 2. Proof. intros. rewrite cc_m_eq_full. repeat match goal with | _ => break_innermost_match_step | _ => progress Z.ltb_to_lt | _ => split | _ => apply Z.div_lt_upper_bound | _ => solve [Z.zero_bounds] end. Z.div_mod_to_quot_rem_in_goal; lia. Qed. Lemma cc_m_Proper_le_r_gen s : (0 <= s /\ Proper (Z.le ==> Z.le) (Definitions.Z.cc_m s)) \/ (s < 0 /\ Proper (Basics.flip Z.le ==> Z.le) (Definitions.Z.cc_m s)). Proof. cbv [Basics.flip]. destruct (Z_lt_le_dec s 0); [ right | left ]; (split; [ assumption | ]). all: intros x0 x1 H; rewrite !cc_m_eq_full; break_innermost_match; Z.ltb_to_lt; [ nia | ]. all: Z.div_mod_to_quot_rem; nia. Qed. #[global] Hint Resolve cc_m_Proper_le_r_gen : zarith. Lemma cc_m_Proper_le_r s : Proper (Z.le ==> Z.le) (Definitions.Z.cc_m s) \/ Proper (Basics.flip Z.le ==> Z.le) (Definitions.Z.cc_m s). Proof. pose proof (cc_m_Proper_le_r_gen s); tauto. Qed. #[global] Hint Resolve cc_m_Proper_le_r : zarith. Lemma cc_m_Proper_le_r_pos s : Proper (Z.le ==> Z.le) (Definitions.Z.cc_m (Z.pos s)). Proof. pose proof (cc_m_Proper_le_r_gen (Z.pos s)); intuition lia. Qed. #[global] Hint Resolve cc_m_Proper_le_r_pos : zarith. Lemma cc_m_Proper_le_r_neg s : Proper (Basics.flip Z.le ==> Z.le) (Definitions.Z.cc_m (Z.neg s)). Proof. pose proof (cc_m_Proper_le_r_gen (Z.neg s)); intuition lia. Qed. #[global] Hint Resolve cc_m_Proper_le_r_neg : zarith. Lemma cc_m_Proper_le_r_0 : Proper (Z.le ==> Z.le) (Definitions.Z.cc_m 0). Proof. pose proof (cc_m_Proper_le_r_gen 0); intuition lia. Qed. #[global] Hint Resolve cc_m_Proper_le_r_0 : zarith. End Z.
(* Title: HOL/Fields.thy Author: Gertrud Bauer Author: Steven Obua Author: Tobias Nipkow Author: Lawrence C Paulson Author: Markus Wenzel Author: Jeremy Avigad *) section {* Fields *} theory Fields imports Rings begin subsection {* Division rings *} text {* A division ring is like a field, but without the commutativity requirement. *} class inverse = fixes inverse :: "'a \<Rightarrow> 'a" and divide :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "'/" 70) setup {* Sign.add_const_constraint (@{const_name "divide"}, SOME @{typ "'a \<Rightarrow> 'a \<Rightarrow> 'a"}) *} context semiring begin lemma [field_simps]: shows distrib_left_NO_MATCH: "NO_MATCH a (x / y) \<Longrightarrow> a * (b + c) = a * b + a * c" and distrib_right_NO_MATCH: "NO_MATCH c (x / y) \<Longrightarrow> (a + b) * c = a * c + b * c" by (rule distrib_left distrib_right)+ end context ring begin lemma [field_simps]: shows left_diff_distrib_NO_MATCH: "NO_MATCH c (x / y) \<Longrightarrow> (a - b) * c = a * c - b * c" and right_diff_distrib_NO_MATCH: "NO_MATCH a (x / y) \<Longrightarrow> a * (b - c) = a * b - a * c" by (rule left_diff_distrib right_diff_distrib)+ end setup {* Sign.add_const_constraint (@{const_name "divide"}, SOME @{typ "'a::inverse \<Rightarrow> 'a \<Rightarrow> 'a"}) *} text{* Lemmas @{text divide_simps} move division to the outside and eliminates them on (in)equalities. *} named_theorems divide_simps "rewrite rules to eliminate divisions" class division_ring = ring_1 + inverse + assumes left_inverse [simp]: "a \<noteq> 0 \<Longrightarrow> inverse a * a = 1" assumes right_inverse [simp]: "a \<noteq> 0 \<Longrightarrow> a * inverse a = 1" assumes divide_inverse: "a / b = a * inverse b" begin subclass ring_1_no_zero_divisors proof fix a b :: 'a assume a: "a \<noteq> 0" and b: "b \<noteq> 0" show "a * b \<noteq> 0" proof assume ab: "a * b = 0" hence "0 = inverse a * (a * b) * inverse b" by simp also have "\<dots> = (inverse a * a) * (b * inverse b)" by (simp only: mult.assoc) also have "\<dots> = 1" using a b by simp finally show False by simp qed qed lemma nonzero_imp_inverse_nonzero: "a \<noteq> 0 \<Longrightarrow> inverse a \<noteq> 0" proof assume ianz: "inverse a = 0" assume "a \<noteq> 0" hence "1 = a * inverse a" by simp also have "... = 0" by (simp add: ianz) finally have "1 = 0" . thus False by (simp add: eq_commute) qed lemma inverse_zero_imp_zero: "inverse a = 0 \<Longrightarrow> a = 0" apply (rule classical) apply (drule nonzero_imp_inverse_nonzero) apply auto done lemma inverse_unique: assumes ab: "a * b = 1" shows "inverse a = b" proof - have "a \<noteq> 0" using ab by (cases "a = 0") simp_all moreover have "inverse a * (a * b) = inverse a" by (simp add: ab) ultimately show ?thesis by (simp add: mult.assoc [symmetric]) qed lemma nonzero_inverse_minus_eq: "a \<noteq> 0 \<Longrightarrow> inverse (- a) = - inverse a" by (rule inverse_unique) simp lemma nonzero_inverse_inverse_eq: "a \<noteq> 0 \<Longrightarrow> inverse (inverse a) = a" by (rule inverse_unique) simp lemma nonzero_inverse_eq_imp_eq: assumes "inverse a = inverse b" and "a \<noteq> 0" and "b \<noteq> 0" shows "a = b" proof - from `inverse a = inverse b` have "inverse (inverse a) = inverse (inverse b)" by (rule arg_cong) with `a \<noteq> 0` and `b \<noteq> 0` show "a = b" by (simp add: nonzero_inverse_inverse_eq) qed lemma inverse_1 [simp]: "inverse 1 = 1" by (rule inverse_unique) simp lemma nonzero_inverse_mult_distrib: assumes "a \<noteq> 0" and "b \<noteq> 0" shows "inverse (a * b) = inverse b * inverse a" proof - have "a * (b * inverse b) * inverse a = 1" using assms by simp hence "a * b * (inverse b * inverse a) = 1" by (simp only: mult.assoc) thus ?thesis by (rule inverse_unique) qed lemma division_ring_inverse_add: "a \<noteq> 0 \<Longrightarrow> b \<noteq> 0 \<Longrightarrow> inverse a + inverse b = inverse a * (a + b) * inverse b" by (simp add: algebra_simps) lemma division_ring_inverse_diff: "a \<noteq> 0 \<Longrightarrow> b \<noteq> 0 \<Longrightarrow> inverse a - inverse b = inverse a * (b - a) * inverse b" by (simp add: algebra_simps) lemma right_inverse_eq: "b \<noteq> 0 \<Longrightarrow> a / b = 1 \<longleftrightarrow> a = b" proof assume neq: "b \<noteq> 0" { hence "a = (a / b) * b" by (simp add: divide_inverse mult.assoc) also assume "a / b = 1" finally show "a = b" by simp next assume "a = b" with neq show "a / b = 1" by (simp add: divide_inverse) } qed lemma nonzero_inverse_eq_divide: "a \<noteq> 0 \<Longrightarrow> inverse a = 1 / a" by (simp add: divide_inverse) lemma divide_self [simp]: "a \<noteq> 0 \<Longrightarrow> a / a = 1" by (simp add: divide_inverse) lemma divide_zero_left [simp]: "0 / a = 0" by (simp add: divide_inverse) lemma inverse_eq_divide [field_simps, divide_simps]: "inverse a = 1 / a" by (simp add: divide_inverse) lemma add_divide_distrib: "(a+b) / c = a/c + b/c" by (simp add: divide_inverse algebra_simps) lemma divide_1 [simp]: "a / 1 = a" by (simp add: divide_inverse) lemma times_divide_eq_right [simp]: "a * (b / c) = (a * b) / c" by (simp add: divide_inverse mult.assoc) lemma minus_divide_left: "- (a / b) = (-a) / b" by (simp add: divide_inverse) lemma nonzero_minus_divide_right: "b \<noteq> 0 ==> - (a / b) = a / (- b)" by (simp add: divide_inverse nonzero_inverse_minus_eq) lemma nonzero_minus_divide_divide: "b \<noteq> 0 ==> (-a) / (-b) = a / b" by (simp add: divide_inverse nonzero_inverse_minus_eq) lemma divide_minus_left [simp]: "(-a) / b = - (a / b)" by (simp add: divide_inverse) lemma diff_divide_distrib: "(a - b) / c = a / c - b / c" using add_divide_distrib [of a "- b" c] by simp lemma nonzero_eq_divide_eq [field_simps]: "c \<noteq> 0 \<Longrightarrow> a = b / c \<longleftrightarrow> a * c = b" proof - assume [simp]: "c \<noteq> 0" have "a = b / c \<longleftrightarrow> a * c = (b / c) * c" by simp also have "... \<longleftrightarrow> a * c = b" by (simp add: divide_inverse mult.assoc) finally show ?thesis . qed lemma nonzero_divide_eq_eq [field_simps]: "c \<noteq> 0 \<Longrightarrow> b / c = a \<longleftrightarrow> b = a * c" proof - assume [simp]: "c \<noteq> 0" have "b / c = a \<longleftrightarrow> (b / c) * c = a * c" by simp also have "... \<longleftrightarrow> b = a * c" by (simp add: divide_inverse mult.assoc) finally show ?thesis . qed lemma nonzero_neg_divide_eq_eq [field_simps]: "b \<noteq> 0 \<Longrightarrow> - (a / b) = c \<longleftrightarrow> - a = c * b" using nonzero_divide_eq_eq[of b "-a" c] by (simp add: divide_minus_left) lemma nonzero_neg_divide_eq_eq2 [field_simps]: "b \<noteq> 0 \<Longrightarrow> c = - (a / b) \<longleftrightarrow> c * b = - a" using nonzero_neg_divide_eq_eq[of b a c] by auto lemma divide_eq_imp: "c \<noteq> 0 \<Longrightarrow> b = a * c \<Longrightarrow> b / c = a" by (simp add: divide_inverse mult.assoc) lemma eq_divide_imp: "c \<noteq> 0 \<Longrightarrow> a * c = b \<Longrightarrow> a = b / c" by (drule sym) (simp add: divide_inverse mult.assoc) lemma add_divide_eq_iff [field_simps]: "z \<noteq> 0 \<Longrightarrow> x + y / z = (x * z + y) / z" by (simp add: add_divide_distrib nonzero_eq_divide_eq) lemma divide_add_eq_iff [field_simps]: "z \<noteq> 0 \<Longrightarrow> x / z + y = (x + y * z) / z" by (simp add: add_divide_distrib nonzero_eq_divide_eq) lemma diff_divide_eq_iff [field_simps]: "z \<noteq> 0 \<Longrightarrow> x - y / z = (x * z - y) / z" by (simp add: diff_divide_distrib nonzero_eq_divide_eq eq_diff_eq) lemma minus_divide_add_eq_iff [field_simps]: "z \<noteq> 0 \<Longrightarrow> - (x / z) + y = (- x + y * z) / z" by (simp add: add_divide_distrib diff_divide_eq_iff divide_minus_left) lemma divide_diff_eq_iff [field_simps]: "z \<noteq> 0 \<Longrightarrow> x / z - y = (x - y * z) / z" by (simp add: field_simps) lemma minus_divide_diff_eq_iff [field_simps]: "z \<noteq> 0 \<Longrightarrow> - (x / z) - y = (- x - y * z) / z" by (simp add: divide_diff_eq_iff[symmetric] divide_minus_left) end class division_ring_inverse_zero = division_ring + assumes inverse_zero [simp]: "inverse 0 = 0" begin lemma divide_zero [simp]: "a / 0 = 0" by (simp add: divide_inverse) lemma divide_self_if [simp]: "a / a = (if a = 0 then 0 else 1)" by simp lemma inverse_nonzero_iff_nonzero [simp]: "inverse a = 0 \<longleftrightarrow> a = 0" by rule (fact inverse_zero_imp_zero, simp) lemma inverse_minus_eq [simp]: "inverse (- a) = - inverse a" proof cases assume "a=0" thus ?thesis by simp next assume "a\<noteq>0" thus ?thesis by (simp add: nonzero_inverse_minus_eq) qed lemma inverse_inverse_eq [simp]: "inverse (inverse a) = a" proof cases assume "a=0" thus ?thesis by simp next assume "a\<noteq>0" thus ?thesis by (simp add: nonzero_inverse_inverse_eq) qed lemma inverse_eq_imp_eq: "inverse a = inverse b \<Longrightarrow> a = b" by (drule arg_cong [where f="inverse"], simp) lemma inverse_eq_iff_eq [simp]: "inverse a = inverse b \<longleftrightarrow> a = b" by (force dest!: inverse_eq_imp_eq) lemma add_divide_eq_if_simps [divide_simps]: "a + b / z = (if z = 0 then a else (a * z + b) / z)" "a / z + b = (if z = 0 then b else (a + b * z) / z)" "- (a / z) + b = (if z = 0 then b else (-a + b * z) / z)" "a - b / z = (if z = 0 then a else (a * z - b) / z)" "a / z - b = (if z = 0 then -b else (a - b * z) / z)" "- (a / z) - b = (if z = 0 then -b else (- a - b * z) / z)" by (simp_all add: add_divide_eq_iff divide_add_eq_iff diff_divide_eq_iff divide_diff_eq_iff minus_divide_diff_eq_iff) lemma [divide_simps]: shows divide_eq_eq: "b / c = a \<longleftrightarrow> (if c \<noteq> 0 then b = a * c else a = 0)" and eq_divide_eq: "a = b / c \<longleftrightarrow> (if c \<noteq> 0 then a * c = b else a = 0)" and minus_divide_eq_eq: "- (b / c) = a \<longleftrightarrow> (if c \<noteq> 0 then - b = a * c else a = 0)" and eq_minus_divide_eq: "a = - (b / c) \<longleftrightarrow> (if c \<noteq> 0 then a * c = - b else a = 0)" by (auto simp add: field_simps) end subsection {* Fields *} class field = comm_ring_1 + inverse + assumes field_inverse: "a \<noteq> 0 \<Longrightarrow> inverse a * a = 1" assumes field_divide_inverse: "a / b = a * inverse b" begin subclass division_ring proof fix a :: 'a assume "a \<noteq> 0" thus "inverse a * a = 1" by (rule field_inverse) thus "a * inverse a = 1" by (simp only: mult.commute) next fix a b :: 'a show "a / b = a * inverse b" by (rule field_divide_inverse) qed subclass idom .. text{*There is no slick version using division by zero.*} lemma inverse_add: "[| a \<noteq> 0; b \<noteq> 0 |] ==> inverse a + inverse b = (a + b) * inverse a * inverse b" by (simp add: division_ring_inverse_add ac_simps) lemma nonzero_mult_divide_mult_cancel_left [simp]: assumes [simp]: "b\<noteq>0" and [simp]: "c\<noteq>0" shows "(c*a)/(c*b) = a/b" proof - have "(c*a)/(c*b) = c * a * (inverse b * inverse c)" by (simp add: divide_inverse nonzero_inverse_mult_distrib) also have "... = a * inverse b * (inverse c * c)" by (simp only: ac_simps) also have "... = a * inverse b" by simp finally show ?thesis by (simp add: divide_inverse) qed lemma nonzero_mult_divide_mult_cancel_right [simp]: "\<lbrakk>b \<noteq> 0; c \<noteq> 0\<rbrakk> \<Longrightarrow> (a * c) / (b * c) = a / b" by (simp add: mult.commute [of _ c]) lemma times_divide_eq_left [simp]: "(b / c) * a = (b * a) / c" by (simp add: divide_inverse ac_simps) text{*It's not obvious whether @{text times_divide_eq} should be simprules or not. Their effect is to gather terms into one big fraction, like a*b*c / x*y*z. The rationale for that is unclear, but many proofs seem to need them.*} lemmas times_divide_eq = times_divide_eq_right times_divide_eq_left lemma add_frac_eq: assumes "y \<noteq> 0" and "z \<noteq> 0" shows "x / y + w / z = (x * z + w * y) / (y * z)" proof - have "x / y + w / z = (x * z) / (y * z) + (y * w) / (y * z)" using assms by simp also have "\<dots> = (x * z + y * w) / (y * z)" by (simp only: add_divide_distrib) finally show ?thesis by (simp only: mult.commute) qed text{*Special Cancellation Simprules for Division*} lemma nonzero_mult_divide_cancel_right [simp]: "b \<noteq> 0 \<Longrightarrow> a * b / b = a" using nonzero_mult_divide_mult_cancel_right [of 1 b a] by simp lemma nonzero_mult_divide_cancel_left [simp]: "a \<noteq> 0 \<Longrightarrow> a * b / a = b" using nonzero_mult_divide_mult_cancel_left [of 1 a b] by simp lemma nonzero_divide_mult_cancel_right [simp]: "\<lbrakk>a \<noteq> 0; b \<noteq> 0\<rbrakk> \<Longrightarrow> b / (a * b) = 1 / a" using nonzero_mult_divide_mult_cancel_right [of a b 1] by simp lemma nonzero_divide_mult_cancel_left [simp]: "\<lbrakk>a \<noteq> 0; b \<noteq> 0\<rbrakk> \<Longrightarrow> a / (a * b) = 1 / b" using nonzero_mult_divide_mult_cancel_left [of b a 1] by simp lemma nonzero_mult_divide_mult_cancel_left2 [simp]: "\<lbrakk>b \<noteq> 0; c \<noteq> 0\<rbrakk> \<Longrightarrow> (c * a) / (b * c) = a / b" using nonzero_mult_divide_mult_cancel_left [of b c a] by (simp add: ac_simps) lemma nonzero_mult_divide_mult_cancel_right2 [simp]: "\<lbrakk>b \<noteq> 0; c \<noteq> 0\<rbrakk> \<Longrightarrow> (a * c) / (c * b) = a / b" using nonzero_mult_divide_mult_cancel_right [of b c a] by (simp add: ac_simps) lemma diff_frac_eq: "y \<noteq> 0 \<Longrightarrow> z \<noteq> 0 \<Longrightarrow> x / y - w / z = (x * z - w * y) / (y * z)" by (simp add: field_simps) lemma frac_eq_eq: "y \<noteq> 0 \<Longrightarrow> z \<noteq> 0 \<Longrightarrow> (x / y = w / z) = (x * z = w * y)" by (simp add: field_simps) lemma divide_minus1 [simp]: "x / - 1 = - x" using nonzero_minus_divide_right [of "1" x] by simp end class field_inverse_zero = field + assumes field_inverse_zero: "inverse 0 = 0" begin subclass division_ring_inverse_zero proof qed (fact field_inverse_zero) text{*This version builds in division by zero while also re-orienting the right-hand side.*} lemma inverse_mult_distrib [simp]: "inverse (a * b) = inverse a * inverse b" proof cases assume "a \<noteq> 0 & b \<noteq> 0" thus ?thesis by (simp add: nonzero_inverse_mult_distrib ac_simps) next assume "~ (a \<noteq> 0 & b \<noteq> 0)" thus ?thesis by force qed lemma inverse_divide [simp]: "inverse (a / b) = b / a" by (simp add: divide_inverse mult.commute) text {* Calculations with fractions *} text{* There is a whole bunch of simp-rules just for class @{text field} but none for class @{text field} and @{text nonzero_divides} because the latter are covered by a simproc. *} lemma mult_divide_mult_cancel_left: "c \<noteq> 0 \<Longrightarrow> (c * a) / (c * b) = a / b" apply (cases "b = 0") apply simp_all done lemma mult_divide_mult_cancel_right: "c \<noteq> 0 \<Longrightarrow> (a * c) / (b * c) = a / b" apply (cases "b = 0") apply simp_all done lemma divide_divide_eq_right [simp]: "a / (b / c) = (a * c) / b" by (simp add: divide_inverse ac_simps) lemma divide_divide_eq_left [simp]: "(a / b) / c = a / (b * c)" by (simp add: divide_inverse mult.assoc) lemma divide_divide_times_eq: "(x / y) / (z / w) = (x * w) / (y * z)" by simp text {*Special Cancellation Simprules for Division*} lemma mult_divide_mult_cancel_left_if [simp]: shows "(c * a) / (c * b) = (if c = 0 then 0 else a / b)" by (simp add: mult_divide_mult_cancel_left) text {* Division and Unary Minus *} lemma minus_divide_right: "- (a / b) = a / - b" by (simp add: divide_inverse) lemma divide_minus_right [simp]: "a / - b = - (a / b)" by (simp add: divide_inverse) lemma minus_divide_divide: "(- a) / (- b) = a / b" apply (cases "b=0", simp) apply (simp add: nonzero_minus_divide_divide) done lemma inverse_eq_1_iff [simp]: "inverse x = 1 \<longleftrightarrow> x = 1" by (insert inverse_eq_iff_eq [of x 1], simp) lemma divide_eq_0_iff [simp]: "a / b = 0 \<longleftrightarrow> a = 0 \<or> b = 0" by (simp add: divide_inverse) lemma divide_cancel_right [simp]: "a / c = b / c \<longleftrightarrow> c = 0 \<or> a = b" apply (cases "c=0", simp) apply (simp add: divide_inverse) done lemma divide_cancel_left [simp]: "c / a = c / b \<longleftrightarrow> c = 0 \<or> a = b" apply (cases "c=0", simp) apply (simp add: divide_inverse) done lemma divide_eq_1_iff [simp]: "a / b = 1 \<longleftrightarrow> b \<noteq> 0 \<and> a = b" apply (cases "b=0", simp) apply (simp add: right_inverse_eq) done lemma one_eq_divide_iff [simp]: "1 = a / b \<longleftrightarrow> b \<noteq> 0 \<and> a = b" by (simp add: eq_commute [of 1]) lemma times_divide_times_eq: "(x / y) * (z / w) = (x * z) / (y * w)" by simp lemma add_frac_num: "y \<noteq> 0 \<Longrightarrow> x / y + z = (x + z * y) / y" by (simp add: add_divide_distrib) lemma add_num_frac: "y \<noteq> 0 \<Longrightarrow> z + x / y = (x + z * y) / y" by (simp add: add_divide_distrib add.commute) end subsection {* Ordered fields *} class linordered_field = field + linordered_idom begin lemma positive_imp_inverse_positive: assumes a_gt_0: "0 < a" shows "0 < inverse a" proof - have "0 < a * inverse a" by (simp add: a_gt_0 [THEN less_imp_not_eq2]) thus "0 < inverse a" by (simp add: a_gt_0 [THEN less_not_sym] zero_less_mult_iff) qed lemma negative_imp_inverse_negative: "a < 0 \<Longrightarrow> inverse a < 0" by (insert positive_imp_inverse_positive [of "-a"], simp add: nonzero_inverse_minus_eq less_imp_not_eq) lemma inverse_le_imp_le: assumes invle: "inverse a \<le> inverse b" and apos: "0 < a" shows "b \<le> a" proof (rule classical) assume "~ b \<le> a" hence "a < b" by (simp add: linorder_not_le) hence bpos: "0 < b" by (blast intro: apos less_trans) hence "a * inverse a \<le> a * inverse b" by (simp add: apos invle less_imp_le mult_left_mono) hence "(a * inverse a) * b \<le> (a * inverse b) * b" by (simp add: bpos less_imp_le mult_right_mono) thus "b \<le> a" by (simp add: mult.assoc apos bpos less_imp_not_eq2) qed lemma inverse_positive_imp_positive: assumes inv_gt_0: "0 < inverse a" and nz: "a \<noteq> 0" shows "0 < a" proof - have "0 < inverse (inverse a)" using inv_gt_0 by (rule positive_imp_inverse_positive) thus "0 < a" using nz by (simp add: nonzero_inverse_inverse_eq) qed lemma inverse_negative_imp_negative: assumes inv_less_0: "inverse a < 0" and nz: "a \<noteq> 0" shows "a < 0" proof - have "inverse (inverse a) < 0" using inv_less_0 by (rule negative_imp_inverse_negative) thus "a < 0" using nz by (simp add: nonzero_inverse_inverse_eq) qed lemma linordered_field_no_lb: "\<forall>x. \<exists>y. y < x" proof fix x::'a have m1: "- (1::'a) < 0" by simp from add_strict_right_mono[OF m1, where c=x] have "(- 1) + x < x" by simp thus "\<exists>y. y < x" by blast qed lemma linordered_field_no_ub: "\<forall> x. \<exists>y. y > x" proof fix x::'a have m1: " (1::'a) > 0" by simp from add_strict_right_mono[OF m1, where c=x] have "1 + x > x" by simp thus "\<exists>y. y > x" by blast qed lemma less_imp_inverse_less: assumes less: "a < b" and apos: "0 < a" shows "inverse b < inverse a" proof (rule ccontr) assume "~ inverse b < inverse a" hence "inverse a \<le> inverse b" by simp hence "~ (a < b)" by (simp add: not_less inverse_le_imp_le [OF _ apos]) thus False by (rule notE [OF _ less]) qed lemma inverse_less_imp_less: "inverse a < inverse b \<Longrightarrow> 0 < a \<Longrightarrow> b < a" apply (simp add: less_le [of "inverse a"] less_le [of "b"]) apply (force dest!: inverse_le_imp_le nonzero_inverse_eq_imp_eq) done text{*Both premises are essential. Consider -1 and 1.*} lemma inverse_less_iff_less [simp]: "0 < a \<Longrightarrow> 0 < b \<Longrightarrow> inverse a < inverse b \<longleftrightarrow> b < a" by (blast intro: less_imp_inverse_less dest: inverse_less_imp_less) lemma le_imp_inverse_le: "a \<le> b \<Longrightarrow> 0 < a \<Longrightarrow> inverse b \<le> inverse a" by (force simp add: le_less less_imp_inverse_less) lemma inverse_le_iff_le [simp]: "0 < a \<Longrightarrow> 0 < b \<Longrightarrow> inverse a \<le> inverse b \<longleftrightarrow> b \<le> a" by (blast intro: le_imp_inverse_le dest: inverse_le_imp_le) text{*These results refer to both operands being negative. The opposite-sign case is trivial, since inverse preserves signs.*} lemma inverse_le_imp_le_neg: "inverse a \<le> inverse b \<Longrightarrow> b < 0 \<Longrightarrow> b \<le> a" apply (rule classical) apply (subgoal_tac "a < 0") prefer 2 apply force apply (insert inverse_le_imp_le [of "-b" "-a"]) apply (simp add: nonzero_inverse_minus_eq) done lemma less_imp_inverse_less_neg: "a < b \<Longrightarrow> b < 0 \<Longrightarrow> inverse b < inverse a" apply (subgoal_tac "a < 0") prefer 2 apply (blast intro: less_trans) apply (insert less_imp_inverse_less [of "-b" "-a"]) apply (simp add: nonzero_inverse_minus_eq) done lemma inverse_less_imp_less_neg: "inverse a < inverse b \<Longrightarrow> b < 0 \<Longrightarrow> b < a" apply (rule classical) apply (subgoal_tac "a < 0") prefer 2 apply force apply (insert inverse_less_imp_less [of "-b" "-a"]) apply (simp add: nonzero_inverse_minus_eq) done lemma inverse_less_iff_less_neg [simp]: "a < 0 \<Longrightarrow> b < 0 \<Longrightarrow> inverse a < inverse b \<longleftrightarrow> b < a" apply (insert inverse_less_iff_less [of "-b" "-a"]) apply (simp del: inverse_less_iff_less add: nonzero_inverse_minus_eq) done lemma le_imp_inverse_le_neg: "a \<le> b \<Longrightarrow> b < 0 ==> inverse b \<le> inverse a" by (force simp add: le_less less_imp_inverse_less_neg) lemma inverse_le_iff_le_neg [simp]: "a < 0 \<Longrightarrow> b < 0 \<Longrightarrow> inverse a \<le> inverse b \<longleftrightarrow> b \<le> a" by (blast intro: le_imp_inverse_le_neg dest: inverse_le_imp_le_neg) lemma one_less_inverse: "0 < a \<Longrightarrow> a < 1 \<Longrightarrow> 1 < inverse a" using less_imp_inverse_less [of a 1, unfolded inverse_1] . lemma one_le_inverse: "0 < a \<Longrightarrow> a \<le> 1 \<Longrightarrow> 1 \<le> inverse a" using le_imp_inverse_le [of a 1, unfolded inverse_1] . lemma pos_le_divide_eq [field_simps]: "0 < c \<Longrightarrow> a \<le> b / c \<longleftrightarrow> a * c \<le> b" proof - assume less: "0<c" hence "(a \<le> b/c) = (a*c \<le> (b/c)*c)" by (simp add: mult_le_cancel_right less_not_sym [OF less] del: times_divide_eq) also have "... = (a*c \<le> b)" by (simp add: less_imp_not_eq2 [OF less] divide_inverse mult.assoc) finally show ?thesis . qed lemma neg_le_divide_eq [field_simps]: "c < 0 \<Longrightarrow> a \<le> b / c \<longleftrightarrow> b \<le> a * c" proof - assume less: "c<0" hence "(a \<le> b/c) = ((b/c)*c \<le> a*c)" by (simp add: mult_le_cancel_right less_not_sym [OF less] del: times_divide_eq) also have "... = (b \<le> a*c)" by (simp add: less_imp_not_eq [OF less] divide_inverse mult.assoc) finally show ?thesis . qed lemma pos_less_divide_eq [field_simps]: "0 < c \<Longrightarrow> a < b / c \<longleftrightarrow> a * c < b" proof - assume less: "0<c" hence "(a < b/c) = (a*c < (b/c)*c)" by (simp add: mult_less_cancel_right_disj less_not_sym [OF less] del: times_divide_eq) also have "... = (a*c < b)" by (simp add: less_imp_not_eq2 [OF less] divide_inverse mult.assoc) finally show ?thesis . qed lemma neg_less_divide_eq [field_simps]: "c < 0 \<Longrightarrow> a < b / c \<longleftrightarrow> b < a * c" proof - assume less: "c<0" hence "(a < b/c) = ((b/c)*c < a*c)" by (simp add: mult_less_cancel_right_disj less_not_sym [OF less] del: times_divide_eq) also have "... = (b < a*c)" by (simp add: less_imp_not_eq [OF less] divide_inverse mult.assoc) finally show ?thesis . qed lemma pos_divide_less_eq [field_simps]: "0 < c \<Longrightarrow> b / c < a \<longleftrightarrow> b < a * c" proof - assume less: "0<c" hence "(b/c < a) = ((b/c)*c < a*c)" by (simp add: mult_less_cancel_right_disj less_not_sym [OF less] del: times_divide_eq) also have "... = (b < a*c)" by (simp add: less_imp_not_eq2 [OF less] divide_inverse mult.assoc) finally show ?thesis . qed lemma neg_divide_less_eq [field_simps]: "c < 0 \<Longrightarrow> b / c < a \<longleftrightarrow> a * c < b" proof - assume less: "c<0" hence "(b/c < a) = (a*c < (b/c)*c)" by (simp add: mult_less_cancel_right_disj less_not_sym [OF less] del: times_divide_eq) also have "... = (a*c < b)" by (simp add: less_imp_not_eq [OF less] divide_inverse mult.assoc) finally show ?thesis . qed lemma pos_divide_le_eq [field_simps]: "0 < c \<Longrightarrow> b / c \<le> a \<longleftrightarrow> b \<le> a * c" proof - assume less: "0<c" hence "(b/c \<le> a) = ((b/c)*c \<le> a*c)" by (simp add: mult_le_cancel_right less_not_sym [OF less] del: times_divide_eq) also have "... = (b \<le> a*c)" by (simp add: less_imp_not_eq2 [OF less] divide_inverse mult.assoc) finally show ?thesis . qed lemma neg_divide_le_eq [field_simps]: "c < 0 \<Longrightarrow> b / c \<le> a \<longleftrightarrow> a * c \<le> b" proof - assume less: "c<0" hence "(b/c \<le> a) = (a*c \<le> (b/c)*c)" by (simp add: mult_le_cancel_right less_not_sym [OF less] del: times_divide_eq) also have "... = (a*c \<le> b)" by (simp add: less_imp_not_eq [OF less] divide_inverse mult.assoc) finally show ?thesis . qed text{* The following @{text field_simps} rules are necessary, as minus is always moved atop of division but we want to get rid of division. *} lemma pos_le_minus_divide_eq [field_simps]: "0 < c \<Longrightarrow> a \<le> - (b / c) \<longleftrightarrow> a * c \<le> - b" unfolding minus_divide_left by (rule pos_le_divide_eq) lemma neg_le_minus_divide_eq [field_simps]: "c < 0 \<Longrightarrow> a \<le> - (b / c) \<longleftrightarrow> - b \<le> a * c" unfolding minus_divide_left by (rule neg_le_divide_eq) lemma pos_less_minus_divide_eq [field_simps]: "0 < c \<Longrightarrow> a < - (b / c) \<longleftrightarrow> a * c < - b" unfolding minus_divide_left by (rule pos_less_divide_eq) lemma neg_less_minus_divide_eq [field_simps]: "c < 0 \<Longrightarrow> a < - (b / c) \<longleftrightarrow> - b < a * c" unfolding minus_divide_left by (rule neg_less_divide_eq) lemma pos_minus_divide_less_eq [field_simps]: "0 < c \<Longrightarrow> - (b / c) < a \<longleftrightarrow> - b < a * c" unfolding minus_divide_left by (rule pos_divide_less_eq) lemma neg_minus_divide_less_eq [field_simps]: "c < 0 \<Longrightarrow> - (b / c) < a \<longleftrightarrow> a * c < - b" unfolding minus_divide_left by (rule neg_divide_less_eq) lemma pos_minus_divide_le_eq [field_simps]: "0 < c \<Longrightarrow> - (b / c) \<le> a \<longleftrightarrow> - b \<le> a * c" unfolding minus_divide_left by (rule pos_divide_le_eq) lemma neg_minus_divide_le_eq [field_simps]: "c < 0 \<Longrightarrow> - (b / c) \<le> a \<longleftrightarrow> a * c \<le> - b" unfolding minus_divide_left by (rule neg_divide_le_eq) lemma frac_less_eq: "y \<noteq> 0 \<Longrightarrow> z \<noteq> 0 \<Longrightarrow> x / y < w / z \<longleftrightarrow> (x * z - w * y) / (y * z) < 0" by (subst less_iff_diff_less_0) (simp add: diff_frac_eq ) lemma frac_le_eq: "y \<noteq> 0 \<Longrightarrow> z \<noteq> 0 \<Longrightarrow> x / y \<le> w / z \<longleftrightarrow> (x * z - w * y) / (y * z) \<le> 0" by (subst le_iff_diff_le_0) (simp add: diff_frac_eq ) text{* Lemmas @{text sign_simps} is a first attempt to automate proofs of positivity/negativity needed for @{text field_simps}. Have not added @{text sign_simps} to @{text field_simps} because the former can lead to case explosions. *} lemmas sign_simps = algebra_simps zero_less_mult_iff mult_less_0_iff lemmas (in -) sign_simps = algebra_simps zero_less_mult_iff mult_less_0_iff (* Only works once linear arithmetic is installed: text{*An example:*} lemma fixes a b c d e f :: "'a::linordered_field" shows "\<lbrakk>a>b; c<d; e<f; 0 < u \<rbrakk> \<Longrightarrow> ((a-b)*(c-d)*(e-f))/((c-d)*(e-f)*(a-b)) < ((e-f)*(a-b)*(c-d))/((e-f)*(a-b)*(c-d)) + u" apply(subgoal_tac "(c-d)*(e-f)*(a-b) > 0") prefer 2 apply(simp add:sign_simps) apply(subgoal_tac "(c-d)*(e-f)*(a-b)*u > 0") prefer 2 apply(simp add:sign_simps) apply(simp add:field_simps) done *) lemma divide_pos_pos[simp]: "0 < x ==> 0 < y ==> 0 < x / y" by(simp add:field_simps) lemma divide_nonneg_pos: "0 <= x ==> 0 < y ==> 0 <= x / y" by(simp add:field_simps) lemma divide_neg_pos: "x < 0 ==> 0 < y ==> x / y < 0" by(simp add:field_simps) lemma divide_nonpos_pos: "x <= 0 ==> 0 < y ==> x / y <= 0" by(simp add:field_simps) lemma divide_pos_neg: "0 < x ==> y < 0 ==> x / y < 0" by(simp add:field_simps) lemma divide_nonneg_neg: "0 <= x ==> y < 0 ==> x / y <= 0" by(simp add:field_simps) lemma divide_neg_neg: "x < 0 ==> y < 0 ==> 0 < x / y" by(simp add:field_simps) lemma divide_nonpos_neg: "x <= 0 ==> y < 0 ==> 0 <= x / y" by(simp add:field_simps) lemma divide_strict_right_mono: "[|a < b; 0 < c|] ==> a / c < b / c" by (simp add: less_imp_not_eq2 divide_inverse mult_strict_right_mono positive_imp_inverse_positive) lemma divide_strict_right_mono_neg: "[|b < a; c < 0|] ==> a / c < b / c" apply (drule divide_strict_right_mono [of _ _ "-c"], simp) apply (simp add: less_imp_not_eq nonzero_minus_divide_right [symmetric]) done text{*The last premise ensures that @{term a} and @{term b} have the same sign*} lemma divide_strict_left_mono: "[|b < a; 0 < c; 0 < a*b|] ==> c / a < c / b" by (auto simp: field_simps zero_less_mult_iff mult_strict_right_mono) lemma divide_left_mono: "[|b \<le> a; 0 \<le> c; 0 < a*b|] ==> c / a \<le> c / b" by (auto simp: field_simps zero_less_mult_iff mult_right_mono) lemma divide_strict_left_mono_neg: "[|a < b; c < 0; 0 < a*b|] ==> c / a < c / b" by (auto simp: field_simps zero_less_mult_iff mult_strict_right_mono_neg) lemma mult_imp_div_pos_le: "0 < y ==> x <= z * y ==> x / y <= z" by (subst pos_divide_le_eq, assumption+) lemma mult_imp_le_div_pos: "0 < y ==> z * y <= x ==> z <= x / y" by(simp add:field_simps) lemma mult_imp_div_pos_less: "0 < y ==> x < z * y ==> x / y < z" by(simp add:field_simps) lemma mult_imp_less_div_pos: "0 < y ==> z * y < x ==> z < x / y" by(simp add:field_simps) lemma frac_le: "0 <= x ==> x <= y ==> 0 < w ==> w <= z ==> x / z <= y / w" apply (rule mult_imp_div_pos_le) apply simp apply (subst times_divide_eq_left) apply (rule mult_imp_le_div_pos, assumption) apply (rule mult_mono) apply simp_all done lemma frac_less: "0 <= x ==> x < y ==> 0 < w ==> w <= z ==> x / z < y / w" apply (rule mult_imp_div_pos_less) apply simp apply (subst times_divide_eq_left) apply (rule mult_imp_less_div_pos, assumption) apply (erule mult_less_le_imp_less) apply simp_all done lemma frac_less2: "0 < x ==> x <= y ==> 0 < w ==> w < z ==> x / z < y / w" apply (rule mult_imp_div_pos_less) apply simp_all apply (rule mult_imp_less_div_pos, assumption) apply (erule mult_le_less_imp_less) apply simp_all done lemma less_half_sum: "a < b ==> a < (a+b) / (1+1)" by (simp add: field_simps zero_less_two) lemma gt_half_sum: "a < b ==> (a+b)/(1+1) < b" by (simp add: field_simps zero_less_two) subclass unbounded_dense_linorder proof fix x y :: 'a from less_add_one show "\<exists>y. x < y" .. from less_add_one have "x + (- 1) < (x + 1) + (- 1)" by (rule add_strict_right_mono) then have "x - 1 < x + 1 - 1" by simp then have "x - 1 < x" by (simp add: algebra_simps) then show "\<exists>y. y < x" .. show "x < y \<Longrightarrow> \<exists>z>x. z < y" by (blast intro!: less_half_sum gt_half_sum) qed lemma nonzero_abs_inverse: "a \<noteq> 0 ==> \<bar>inverse a\<bar> = inverse \<bar>a\<bar>" apply (auto simp add: neq_iff abs_if nonzero_inverse_minus_eq negative_imp_inverse_negative) apply (blast intro: positive_imp_inverse_positive elim: less_asym) done lemma nonzero_abs_divide: "b \<noteq> 0 ==> \<bar>a / b\<bar> = \<bar>a\<bar> / \<bar>b\<bar>" by (simp add: divide_inverse abs_mult nonzero_abs_inverse) lemma field_le_epsilon: assumes e: "\<And>e. 0 < e \<Longrightarrow> x \<le> y + e" shows "x \<le> y" proof (rule dense_le) fix t assume "t < x" hence "0 < x - t" by (simp add: less_diff_eq) from e [OF this] have "x + 0 \<le> x + (y - t)" by (simp add: algebra_simps) then have "0 \<le> y - t" by (simp only: add_le_cancel_left) then show "t \<le> y" by (simp add: algebra_simps) qed end class linordered_field_inverse_zero = linordered_field + field_inverse_zero begin lemma inverse_positive_iff_positive [simp]: "(0 < inverse a) = (0 < a)" apply (cases "a = 0", simp) apply (blast intro: inverse_positive_imp_positive positive_imp_inverse_positive) done lemma inverse_negative_iff_negative [simp]: "(inverse a < 0) = (a < 0)" apply (cases "a = 0", simp) apply (blast intro: inverse_negative_imp_negative negative_imp_inverse_negative) done lemma inverse_nonnegative_iff_nonnegative [simp]: "0 \<le> inverse a \<longleftrightarrow> 0 \<le> a" by (simp add: not_less [symmetric]) lemma inverse_nonpositive_iff_nonpositive [simp]: "inverse a \<le> 0 \<longleftrightarrow> a \<le> 0" by (simp add: not_less [symmetric]) lemma one_less_inverse_iff: "1 < inverse x \<longleftrightarrow> 0 < x \<and> x < 1" using less_trans[of 1 x 0 for x] by (cases x 0 rule: linorder_cases) (auto simp add: field_simps) lemma one_le_inverse_iff: "1 \<le> inverse x \<longleftrightarrow> 0 < x \<and> x \<le> 1" proof (cases "x = 1") case True then show ?thesis by simp next case False then have "inverse x \<noteq> 1" by simp then have "1 \<noteq> inverse x" by blast then have "1 \<le> inverse x \<longleftrightarrow> 1 < inverse x" by (simp add: le_less) with False show ?thesis by (auto simp add: one_less_inverse_iff) qed lemma inverse_less_1_iff: "inverse x < 1 \<longleftrightarrow> x \<le> 0 \<or> 1 < x" by (simp add: not_le [symmetric] one_le_inverse_iff) lemma inverse_le_1_iff: "inverse x \<le> 1 \<longleftrightarrow> x \<le> 0 \<or> 1 \<le> x" by (simp add: not_less [symmetric] one_less_inverse_iff) lemma [divide_simps]: shows le_divide_eq: "a \<le> b / c \<longleftrightarrow> (if 0 < c then a * c \<le> b else if c < 0 then b \<le> a * c else a \<le> 0)" and divide_le_eq: "b / c \<le> a \<longleftrightarrow> (if 0 < c then b \<le> a * c else if c < 0 then a * c \<le> b else 0 \<le> a)" and less_divide_eq: "a < b / c \<longleftrightarrow> (if 0 < c then a * c < b else if c < 0 then b < a * c else a < 0)" and divide_less_eq: "b / c < a \<longleftrightarrow> (if 0 < c then b < a * c else if c < 0 then a * c < b else 0 < a)" and le_minus_divide_eq: "a \<le> - (b / c) \<longleftrightarrow> (if 0 < c then a * c \<le> - b else if c < 0 then - b \<le> a * c else a \<le> 0)" and minus_divide_le_eq: "- (b / c) \<le> a \<longleftrightarrow> (if 0 < c then - b \<le> a * c else if c < 0 then a * c \<le> - b else 0 \<le> a)" and less_minus_divide_eq: "a < - (b / c) \<longleftrightarrow> (if 0 < c then a * c < - b else if c < 0 then - b < a * c else a < 0)" and minus_divide_less_eq: "- (b / c) < a \<longleftrightarrow> (if 0 < c then - b < a * c else if c < 0 then a * c < - b else 0 < a)" by (auto simp: field_simps not_less dest: antisym) text {*Division and Signs*} lemma shows zero_less_divide_iff: "0 < a / b \<longleftrightarrow> 0 < a \<and> 0 < b \<or> a < 0 \<and> b < 0" and divide_less_0_iff: "a / b < 0 \<longleftrightarrow> 0 < a \<and> b < 0 \<or> a < 0 \<and> 0 < b" and zero_le_divide_iff: "0 \<le> a / b \<longleftrightarrow> 0 \<le> a \<and> 0 \<le> b \<or> a \<le> 0 \<and> b \<le> 0" and divide_le_0_iff: "a / b \<le> 0 \<longleftrightarrow> 0 \<le> a \<and> b \<le> 0 \<or> a \<le> 0 \<and> 0 \<le> b" by (auto simp add: divide_simps) text {* Division and the Number One *} text{*Simplify expressions equated with 1*} lemma zero_eq_1_divide_iff [simp]: "0 = 1 / a \<longleftrightarrow> a = 0" by (cases "a = 0") (auto simp: field_simps) lemma one_divide_eq_0_iff [simp]: "1 / a = 0 \<longleftrightarrow> a = 0" using zero_eq_1_divide_iff[of a] by simp text{*Simplify expressions such as @{text "0 < 1/x"} to @{text "0 < x"}*} lemma zero_le_divide_1_iff [simp]: "0 \<le> 1 / a \<longleftrightarrow> 0 \<le> a" by (simp add: zero_le_divide_iff) lemma zero_less_divide_1_iff [simp]: "0 < 1 / a \<longleftrightarrow> 0 < a" by (simp add: zero_less_divide_iff) lemma divide_le_0_1_iff [simp]: "1 / a \<le> 0 \<longleftrightarrow> a \<le> 0" by (simp add: divide_le_0_iff) lemma divide_less_0_1_iff [simp]: "1 / a < 0 \<longleftrightarrow> a < 0" by (simp add: divide_less_0_iff) lemma divide_right_mono: "[|a \<le> b; 0 \<le> c|] ==> a/c \<le> b/c" by (force simp add: divide_strict_right_mono le_less) lemma divide_right_mono_neg: "a <= b ==> c <= 0 ==> b / c <= a / c" apply (drule divide_right_mono [of _ _ "- c"]) apply auto done lemma divide_left_mono_neg: "a <= b ==> c <= 0 ==> 0 < a * b ==> c / a <= c / b" apply (drule divide_left_mono [of _ _ "- c"]) apply (auto simp add: mult.commute) done lemma inverse_le_iff: "inverse a \<le> inverse b \<longleftrightarrow> (0 < a * b \<longrightarrow> b \<le> a) \<and> (a * b \<le> 0 \<longrightarrow> a \<le> b)" by (cases a 0 b 0 rule: linorder_cases[case_product linorder_cases]) (auto simp add: field_simps zero_less_mult_iff mult_le_0_iff) lemma inverse_less_iff: "inverse a < inverse b \<longleftrightarrow> (0 < a * b \<longrightarrow> b < a) \<and> (a * b \<le> 0 \<longrightarrow> a < b)" by (subst less_le) (auto simp: inverse_le_iff) lemma divide_le_cancel: "a / c \<le> b / c \<longleftrightarrow> (0 < c \<longrightarrow> a \<le> b) \<and> (c < 0 \<longrightarrow> b \<le> a)" by (simp add: divide_inverse mult_le_cancel_right) lemma divide_less_cancel: "a / c < b / c \<longleftrightarrow> (0 < c \<longrightarrow> a < b) \<and> (c < 0 \<longrightarrow> b < a) \<and> c \<noteq> 0" by (auto simp add: divide_inverse mult_less_cancel_right) text{*Simplify quotients that are compared with the value 1.*} lemma le_divide_eq_1: "(1 \<le> b / a) = ((0 < a & a \<le> b) | (a < 0 & b \<le> a))" by (auto simp add: le_divide_eq) lemma divide_le_eq_1: "(b / a \<le> 1) = ((0 < a & b \<le> a) | (a < 0 & a \<le> b) | a=0)" by (auto simp add: divide_le_eq) lemma less_divide_eq_1: "(1 < b / a) = ((0 < a & a < b) | (a < 0 & b < a))" by (auto simp add: less_divide_eq) lemma divide_less_eq_1: "(b / a < 1) = ((0 < a & b < a) | (a < 0 & a < b) | a=0)" by (auto simp add: divide_less_eq) lemma divide_nonneg_nonneg [simp]: "0 \<le> x \<Longrightarrow> 0 \<le> y \<Longrightarrow> 0 \<le> x / y" by (auto simp add: divide_simps) lemma divide_nonpos_nonpos: "x \<le> 0 \<Longrightarrow> y \<le> 0 \<Longrightarrow> 0 \<le> x / y" by (auto simp add: divide_simps) lemma divide_nonneg_nonpos: "0 \<le> x \<Longrightarrow> y \<le> 0 \<Longrightarrow> x / y \<le> 0" by (auto simp add: divide_simps) lemma divide_nonpos_nonneg: "x \<le> 0 \<Longrightarrow> 0 \<le> y \<Longrightarrow> x / y \<le> 0" by (auto simp add: divide_simps) text {*Conditional Simplification Rules: No Case Splits*} lemma le_divide_eq_1_pos [simp]: "0 < a \<Longrightarrow> (1 \<le> b/a) = (a \<le> b)" by (auto simp add: le_divide_eq) lemma le_divide_eq_1_neg [simp]: "a < 0 \<Longrightarrow> (1 \<le> b/a) = (b \<le> a)" by (auto simp add: le_divide_eq) lemma divide_le_eq_1_pos [simp]: "0 < a \<Longrightarrow> (b/a \<le> 1) = (b \<le> a)" by (auto simp add: divide_le_eq) lemma divide_le_eq_1_neg [simp]: "a < 0 \<Longrightarrow> (b/a \<le> 1) = (a \<le> b)" by (auto simp add: divide_le_eq) lemma less_divide_eq_1_pos [simp]: "0 < a \<Longrightarrow> (1 < b/a) = (a < b)" by (auto simp add: less_divide_eq) lemma less_divide_eq_1_neg [simp]: "a < 0 \<Longrightarrow> (1 < b/a) = (b < a)" by (auto simp add: less_divide_eq) lemma divide_less_eq_1_pos [simp]: "0 < a \<Longrightarrow> (b/a < 1) = (b < a)" by (auto simp add: divide_less_eq) lemma divide_less_eq_1_neg [simp]: "a < 0 \<Longrightarrow> b/a < 1 <-> a < b" by (auto simp add: divide_less_eq) lemma eq_divide_eq_1 [simp]: "(1 = b/a) = ((a \<noteq> 0 & a = b))" by (auto simp add: eq_divide_eq) lemma divide_eq_eq_1 [simp]: "(b/a = 1) = ((a \<noteq> 0 & a = b))" by (auto simp add: divide_eq_eq) lemma abs_inverse [simp]: "\<bar>inverse a\<bar> = inverse \<bar>a\<bar>" apply (cases "a=0", simp) apply (simp add: nonzero_abs_inverse) done lemma abs_divide [simp]: "\<bar>a / b\<bar> = \<bar>a\<bar> / \<bar>b\<bar>" apply (cases "b=0", simp) apply (simp add: nonzero_abs_divide) done lemma abs_div_pos: "0 < y ==> \<bar>x\<bar> / y = \<bar>x / y\<bar>" apply (subst abs_divide) apply (simp add: order_less_imp_le) done lemma zero_le_divide_abs_iff [simp]: "(0 \<le> a / abs b) = (0 \<le> a | b = 0)" by (auto simp: zero_le_divide_iff) lemma divide_le_0_abs_iff [simp]: "(a / abs b \<le> 0) = (a \<le> 0 | b = 0)" by (auto simp: divide_le_0_iff) lemma field_le_mult_one_interval: assumes *: "\<And>z. \<lbrakk> 0 < z ; z < 1 \<rbrakk> \<Longrightarrow> z * x \<le> y" shows "x \<le> y" proof (cases "0 < x") assume "0 < x" thus ?thesis using dense_le_bounded[of 0 1 "y/x"] * unfolding le_divide_eq if_P[OF `0 < x`] by simp next assume "\<not>0 < x" hence "x \<le> 0" by simp obtain s::'a where s: "0 < s" "s < 1" using dense[of 0 "1\<Colon>'a"] by auto hence "x \<le> s * x" using mult_le_cancel_right[of 1 x s] `x \<le> 0` by auto also note *[OF s] finally show ?thesis . qed end code_identifier code_module Fields \<rightharpoonup> (SML) Arith and (OCaml) Arith and (Haskell) Arith end
## Day 3: Cells in Silicon Welcome to Day 3! Today, we start with our discussion of Hodgkin Huxley Neurons and how we can simulate them in Python using Tensorflow and Numerical Integration. The electric potential measured across the membranes of excitable cells, such as neurons or heart cells, can undergo transient changes when perturbed by external inputs. When the inputs to a neuron are sufficiently large these transient changes can regeneratively build up into a large deviation from the resting state known as an action potential. Action potentials propagate undiminished along the axon and perturb post-synaptic neurons. The Hodgkin-Huxley model is a system of differential equations that describe the generation an action potential and its propagation along the axon. We provide only a brief overview of the Hodgkin-Huxley model. A number of classic references (Dayan 2005, Johnston 1995) and the original papers by Hodgkin and Huxley (Huxley 1952) chronicle the history and the details of the model. An excellent set of MOOCS and the accompanying textbooks (Gerstner 2014, Dayan 2005) give an accessible introduction to the topic ### What is the Hodgkin Huxley Neuron Model? The cell membrane, a 5nm thick lipid bilayer, separates the inside from the outside of the neuron. The membrane is largely impermeable to charged ions present on either side. The concentration of $\text{Na}^{+}$ ions outside the cell is greater than its concentration inside, while $\text{K}^{+}$ ions are relatively abundant inside compared to the outside. In addition to these there are chloride ($\text{Cl}^{-}$), calcium ($\text{Ca}^{2+}$) and magnesium ions ($\text{Mg}^{+}$) that populate the cellular milieu. The differences in ionic abundances across the membrane cause a net accumulation of positive ions on one side of the membrane and negative ions on the other, and thus a potential difference across the membrane. Embedded on the membrane are ion channels that are highly selective to the ion species it lets across. In the squid axon, Hodgkin and Huxley found that there were only two types of ion channels ($\text{Na}^{+}$ and $\text{K}^{+}$), in addition to a non-specific leak channel. The Hodgkin-Huxley model of neurons can be understood with the help of an equivalent electrical circuit given below. The cell membrane acts as a capacitor. The total injected current ($I$) can be written as the sum of the capacitive current $I_{C}$, ionic currents $I_{Na}$ and $I_{K}$ and the leak current $I_L$. \begin{equation} I = I_{C}(t) + I_{Na}(t) + I_{K}(t) \end{equation} where, \begin{eqnarray} C_m = 1 \mu F/cm^2 \\ I_{Na} = g_{Na}(u-E_{Na})\\ I_{K} = g_{k}(u-E_K)\\ I_{L} = g_{L}(u-E_L) \end{eqnarray} The equation describing the membrane potential can thus be written as follows, \begin{eqnarray} \label{eq:HH} C_m\frac{dV}{dt}=−I_{Na}(t)−I_{K}(t)−I_{L}(t)+I(t) \end{eqnarray} Hodgkin and Huxley discovered that the $Na$ and the $K$ channels do not act as Ohmic conductances, but are modulated by the potential across the membrane. Changes in potential had a nonlinear effect on flow of ionic currents. Based in their experimental results they obtained a system of differential equations that described the temporal evolution of the membrane potential in terms of changes in ionic currents (chiefly $\text{Na}^{+}$ and $\text{K}^{+}$). \begin{eqnarray}\label{d3_2}I_{Na} = g_{Na}m^3h(u−E_{Na})\end{eqnarray} \begin{eqnarray}\label{d3_3}I_K = g_Kn^4(u−E_K)\end{eqnarray} \begin{eqnarray}\label{d3_4}I_L = g_L(u−E_L)\end{eqnarray} where $E_{Na}=50\ mV$, $E_K = -95\ mV$ and $E_L=-55\ mV$ are the reversal potentials; $g_{Na} = 100\ \mu S/cm^2$, $g_K = 10\ \mu S/cm^2$ and $g_L = 0.15\ \mu S/cm^2$ are the channel conductances; and m,h, and n are gating variables that follow the dynamics given by: \begin{eqnarray}\label{d3_5}\frac{dm}{dt} = - \frac{1}{\tau_m}(m-m_0)\end{eqnarray} \begin{eqnarray}\label{d3_6}\frac{dh}{dt} = - \frac{1}{\tau_h}(h-h_0)\end{eqnarray} \begin{eqnarray}\label{d3_7}\frac{dn}{dt} = - \frac{1}{\tau_n}(n-n_0)\end{eqnarray} where $\tau_m$, $\tau_h$ and $\tau_n$ are empirically determined voltage dependent time constants and $m_0$, $h_0$ and $n_0$ are voltage dependent asymptotic gating values. On day 2, we had created a RK4 based numerical integrator. Recall this implementation: ```python import numpy as np import matplotlib.pyplot as plt import tensorflow as tf ## OR for Tensorflow 2.0 and above ## import tensorflow.compat.v1 as tf tf.disable_eager_execution() %matplotlib inline def tf_check_type(t, y0): # Ensure Input is Correct if not (y0.dtype.is_floating and t.dtype.is_floating): raise TypeError('Error in Datatype') class _Tf_Integrator(): def integrate(self, func, y0, t): time_delta_grid = t[1:] - t[:-1] def scan_func(y, t_dt): t, dt = t_dt dy = self._step_func(func,t,dt,y) # Make code more modular. return y + dy y = tf.scan(scan_func, (t[:-1], time_delta_grid),y0) return tf.concat([[y0], y], axis=0) def _step_func(self, func, t, dt, y): k1 = func(y, t) half_step = t + dt / 2 dt_cast = tf.cast(dt, y.dtype) # Failsafe k2 = func(y + dt_cast * k1 / 2, half_step) k3 = func(y + dt_cast * k2 / 2, half_step) k4 = func(y + dt_cast * k3, t + dt) return tf.add_n([k1, 2 * k2, 2 * k3, k4]) * (dt_cast / 6) def odeint(func, y0, t): t = tf.convert_to_tensor(t, name='t') y0 = tf.convert_to_tensor(y0, name='y0') tf_check_type(y0,t) return _Tf_Integrator().integrate(func,y0,t) ``` #### Implementing the Hodgkin-Huxley neuron model The variables of the Hodgkin Huxley neuron model that are updated at each integration time step are, the membrane potential, $V$, the sodium activation gating variable, $m$, the sodium inactivation gating variable, $h$, and the potassium channel gating variable, $n$. The dynamics are given by Equations above. In the following code, we define the parameters associated with the conductances, including the formulae for $\tau_{m}$, $\tau_{h}$, $\tau_{n}$ and the voltage dependent steady state values of the gating variables. ##### Step 1: Defining Parameters of the Neuron ```python C_m = 1 # Membrane Capacitance g_K = 10 E_K = -95 g_Na = 100 E_Na = 50 g_L = 0.15 E_L = -55 ``` ##### Step 2: Defining functions that calculate $\tau_m$, $\tau_h$, $\tau_n$, $m_0$, $h_0$, $n_0$ Note: Always use Tensorflow functions for all mathematical operations. For our Hodgkin Huxley Model, we will determine the values of $\tau_m$, $\tau_h$, $\tau_n$, $m_0$, $h_0$, $n_0$ by the following equations: ```python def K_prop(V): T = 22 phi = 3.0**((T-36.0)/10) V_ = V-(-50) alpha_n = 0.02*(15.0 - V_)/(tf.exp((15.0 - V_)/5.0) - 1.0) beta_n = 0.5*tf.exp((10.0 - V_)/40.0) t_n = 1.0/((alpha_n+beta_n)*phi) n_0 = alpha_n/(alpha_n+beta_n) return n_0, t_n def Na_prop(V): T = 22 phi = 3.0**((T-36)/10) V_ = V-(-50) alpha_m = 0.32*(13.0 - V_)/(tf.exp((13.0 - V_)/4.0) - 1.0) beta_m = 0.28*(V_ - 40.0)/(tf.exp((V_ - 40.0)/5.0) - 1.0) alpha_h = 0.128*tf.exp((17.0 - V_)/18.0) beta_h = 4.0/(tf.exp((40.0 - V_)/5.0) + 1.0) t_m = 1.0/((alpha_m+beta_m)*phi) t_h = 1.0/((alpha_h+beta_h)*phi) m_0 = alpha_m/(alpha_m+beta_m) h_0 = alpha_h/(alpha_h+beta_h) return m_0, t_m, h_0, t_h ``` ##### Step 3: Defining function that calculate Neuronal currents ```python def I_K(V, n): return g_K * n**4 * (V - E_K) def I_Na(V, m, h): return g_Na * m**3 * h * (V - E_Na) def I_L(V): return g_L * (V - E_L) ``` ##### Step 4: Define the function dX/dt where X is the State Vector ```python def dXdt(X, t): V = X[0:1] m = X[1:2] h = X[2:3] n = X[3:4] dVdt = (5 - I_Na(V, m, h) - I_K(V, n) - I_L(V)) / C_m # Here the current injection I_injected = 5 uA m0,tm,h0,th = Na_prop(V) n0,tn = K_prop(V) dmdt = - (1.0/tm)*(m-m0) dhdt = - (1.0/th)*(h-h0) dndt = - (1.0/tn)*(n-n0) out = tf.concat([dVdt,dmdt,dhdt,dndt],0) return out ``` ##### Step 5: Define Initial Condition and Integrate ```python y0 = tf.constant([-71,0,0,0], dtype=tf.float64) epsilon = 0.01 t = np.arange(0,200,epsilon) state = odeint(dXdt,y0,t) with tf.Session() as sess: state = sess.run(state) ``` ##### Step 6: Plot Output ```python plt.plot(t,state.T[0,:]) plt.xlabel("Time (in ms)") plt.ylabel("Voltage (in mV)") plt.show() ``` #### Simulating Multiple Independent HH Neurons at the Same Time Here we illustrate some simple steps that can be used to simulate populations of neurons efficiently. Key to setting up the equations is to order it in a manner that utilizes TensorFlow's algorithms that distribute vector, matrix and tensor computations over multiple cores. Consider a system of 20 independent HH neurons with different input currents that characterise the firing rates. ##### Methods of Parallelization TensorFlow has built-in functions that speed up Tensor computations using available multi-cores, and GPU/TPU setups. There are two major parts of the code where such a speed-up can be effected 1. **RK4 iterations** Our implementation of the integrator utilizes Tensors as inputs. 2. **Functional Evaluations:** The form of the equations that describe the neuronal dynamics, are common across neurons. Only the parameters for differ across neurons. This can be used to `vectorize' the equations. Say $\vec{X}=[V,m,n,h]$ is the state vector of a single neuron and its dynamics are defined using parameters $C_m,g_K,...E_L$ equations of the form: \begin{eqnarray}\frac{d\vec{X}}{dt} = [f_1(\vec{X},C_m,g_K,...E_L),f_2(\vec{X},C_m,g_K,...E_L)...f_m(\vec{X},C_m,g_K,...E_L)]\end{eqnarray} We can convert these equations to a form in which all evaluations are done as vector calculations and NOT scalar calculations. Despite the parameters being different, the functional forms of the equations are similar for the same state variable of different neurons. Thus, the trick is to reorganize $\mathbf{X}$ as $\mathbf{X'}=[(V_1,V_2,...V_n),(m_1,m_2,...m_n),(h_1,h_2,...h_n),(n_1,n_2,...n_n)]=[\vec{V},\vec{m},\vec{h},\vec{n}]$. And the parameters as $[\vec{C_m},\vec{g_K}] = [C_{m_{1}}\dots C_{m_{n}},g_{K_{1}}\dots g_{K_{n}}]$ and so on. The advantage of this re-ordering is that the differential equation of the form, \begin{eqnarray}\frac{dV_i}{dt}=f(V_i,m_i,h_i,n_i,C_{m_i},g_{K_i}...)\end{eqnarray} is now easily parallelizable using a vector computation of the form, \begin{eqnarray}\frac{d\vec{V}}{dt}=f(\vec{V},\vec{m},\vec{h},\vec{n},\vec{C_m},\vec{g_K}...)\end{eqnarray} The equations can now be written in the form, \begin{eqnarray}\frac{d\mathbf{X'}}{dt}= \Big[\frac{d\vec{V}}{dt},\frac{d\vec{m}}{dt},\frac{d\vec{h}}{dt},\frac{d\vec{n}}{dt}\Big]\end{eqnarray} ```python n_n = 20 # number of simultaneous neurons to simulate # parameters will now become n_n-vectors C_m = [1.0]*n_n g_K = [10.0]*n_n E_K = [-95.0]*n_n g_Na = [100]*n_n E_Na = [50]*n_n g_L = [0.15]*n_n E_L = [-55.0]*n_n def K_prop(V): T = 22 phi = 3.0**((T-36.0)/10) V_ = V-(-50) alpha_n = 0.02*(15.0 - V_)/(tf.exp((15.0 - V_)/5.0) - 1.0) beta_n = 0.5*tf.exp((10.0 - V_)/40.0) t_n = 1.0/((alpha_n+beta_n)*phi) n_0 = alpha_n/(alpha_n+beta_n) return n_0, t_n def Na_prop(V): T = 22 phi = 3.0**((T-36)/10) V_ = V-(-50) alpha_m = 0.32*(13.0 - V_)/(tf.exp((13.0 - V_)/4.0) - 1.0) beta_m = 0.28*(V_ - 40.0)/(tf.exp((V_ - 40.0)/5.0) - 1.0) alpha_h = 0.128*tf.exp((17.0 - V_)/18.0) beta_h = 4.0/(tf.exp((40.0 - V_)/5.0) + 1.0) t_m = 1.0/((alpha_m+beta_m)*phi) t_h = 1.0/((alpha_h+beta_h)*phi) m_0 = alpha_m/(alpha_m+beta_m) h_0 = alpha_h/(alpha_h+beta_h) return m_0, t_m, h_0, t_h def I_K(V, n): return g_K * n**4 * (V - E_K) def I_Na(V, m, h): return g_Na * m**3 * h * (V - E_Na) def I_L(V): return g_L * (V - E_L) def dXdt(X, t): V = X[:1*n_n] # First n_n values are Membrane Voltage m = X[1*n_n:2*n_n] # Next n_n values are Sodium Activation Gating Variables h = X[2*n_n:3*n_n] # Next n_n values are Sodium Inactivation Gating Variables n = X[3*n_n:] # Last n_n values are Potassium Gating Variables dVdt = (np.linspace(0,10,n_n) - I_Na(V, m, h) - I_K(V, n) -I_L(V)) / C_m # Input current is linearly varied between 0 and 10 m0,tm,h0,th = Na_prop(V) n0,tn = K_prop(V) dmdt = - (1.0/tm)*(m-m0) dhdt = - (1.0/th)*(h-h0) dndt = - (1.0/tn)*(n-n0) out = tf.concat([dVdt,dmdt,dhdt,dndt],0) return out y0 = tf.constant([-71]*n_n+[0,0,0]*n_n, dtype=tf.float64) epsilon = 0.01 t = np.arange(0,200,epsilon) state = odeint(dXdt,y0,t) with tf.Session() as sess: state = sess.run(state) ``` ```python plt.figure(figsize=(12,17)) for i in range(20): plt.subplot(10,2,i+1) plt.plot(t,state[:,i]) plt.title("Injected Current = {:0.1f}".format(i/2)) plt.ylim([-90,60]) plt.xlabel("Time (in ms)") plt.ylabel("Voltage (in mV)") plt.tight_layout() plt.show() ``` #### Quantifying the Firing Rates against Input Current The firing frequency as a function of the input is shown in the figure below. The code to generate the firing rate is below. ```python plt.plot(np.linspace(0,10,20),np.bitwise_and(state[:-1,:20]<0,state[1:,:20]>0).sum(axis=0)/0.2,"o") plt.xlabel("Injected Current(mA)") plt.ylabel("Firing Rate (Hz)") plt.show() ``` # References (<a id="cit-Dayan2005" href="#call-Dayan2005">Dayan and Abbott, 2005</a>) Peter Dayan and Larry F. Abbott, ``Theoretical Neuroscience - Computational and Mathematical Modeling of Neural Systems``, 2005. (<a id="cit-Johnston1995" href="#call-Johnston1995">Johnston and Wu, 1995</a>) D. Johnston and S. M.S. Wu, ``Foundations of cellular neurophysiology``, 1995. (<a id="cit-Huxley1952" href="#call-Huxley1952">Huxley and Hodgkin, 1952</a>) Huxley A. L. and Hodgkin A. F., ``Quantitative description of nerve current``, Journal of Physiology, vol. , number , pp. , 1952. (<a id="cit-gerstnerMOOC" href="#call-gerstnerMOOC">MOOC</a>) , ``Neuronal dynamics``, . [online](https://www.edx.org/course/neuronal-dynamics) (<a id="cit-compneuroMOOC" href="#call-compneuroMOOC">MOOC</a>) , ``Computational Neuroscience``, . [online](https://www.coursera.org/learn/computational-neuroscience) (<a id="cit-Gerstner2014" href="#call-Gerstner2014">Gerstner, Kistler <em>et al.</em>, 2014</a>) Wulfram Gerstner, Werner M. Kistler, Richard Naud <em>et al.</em>, ``Neuronal dynamics: From single neurons to networks and models of cognition``, 2014.
program helloWorld write(*,*) "Hello World!" end program helloWorld
/- Copyright (c) 2022 Frédéric Dupuis. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Frédéric Dupuis ! This file was ported from Lean 3 source module topology.algebra.module.character_space ! leanprover-community/mathlib commit a148d797a1094ab554ad4183a4ad6f130358ef64 ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathbin.Topology.Algebra.Module.WeakDual import Mathbin.Algebra.Algebra.Spectrum import Mathbin.Topology.ContinuousFunction.Algebra /-! # Character space of a topological algebra The character space of a topological algebra is the subset of elements of the weak dual that are also algebra homomorphisms. This space is used in the Gelfand transform, which gives an isomorphism between a commutative C⋆-algebra and continuous functions on the character space of the algebra. This, in turn, is used to construct the continuous functional calculus on C⋆-algebras. ## Implementation notes We define `character_space 𝕜 A` as a subset of the weak dual, which automatically puts the correct topology on the space. We then define `to_alg_hom` which provides the algebra homomorphism corresponding to any element. We also provide `to_clm` which provides the element as a continuous linear map. (Even though `weak_dual 𝕜 A` is a type copy of `A →L[𝕜] 𝕜`, this is often more convenient.) ## Tags character space, Gelfand transform, functional calculus -/ namespace WeakDual /-- The character space of a topological algebra is the subset of elements of the weak dual that are also algebra homomorphisms. -/ def characterSpace (𝕜 : Type _) (A : Type _) [CommSemiring 𝕜] [TopologicalSpace 𝕜] [ContinuousAdd 𝕜] [ContinuousConstSMul 𝕜 𝕜] [NonUnitalNonAssocSemiring A] [TopologicalSpace A] [Module 𝕜 A] := { φ : WeakDual 𝕜 A | φ ≠ 0 ∧ ∀ x y : A, φ (x * y) = φ x * φ y } #align weak_dual.character_space WeakDual.characterSpace variable {𝕜 : Type _} {A : Type _} namespace CharacterSpace section NonUnitalNonAssocSemiring variable [CommSemiring 𝕜] [TopologicalSpace 𝕜] [ContinuousAdd 𝕜] [ContinuousConstSMul 𝕜 𝕜] [NonUnitalNonAssocSemiring A] [TopologicalSpace A] [Module 𝕜 A] @[simp, norm_cast, protected] theorem coe_coe (φ : characterSpace 𝕜 A) : ⇑(φ : WeakDual 𝕜 A) = φ := rfl #align weak_dual.character_space.coe_coe WeakDual.characterSpace.coe_coe /-- Elements of the character space are continuous linear maps. -/ instance : ContinuousLinearMapClass (characterSpace 𝕜 A) 𝕜 A 𝕜 where coe φ := (φ : A → 𝕜) coe_injective' φ ψ h := by ext exact congr_fun h x map_smulₛₗ φ := (φ : WeakDual 𝕜 A).map_smul map_add φ := (φ : WeakDual 𝕜 A).map_add map_continuous φ := (φ : WeakDual 𝕜 A).cont @[ext] theorem ext {φ ψ : characterSpace 𝕜 A} (h : ∀ x, φ x = ψ x) : φ = ψ := FunLike.ext _ _ h #align weak_dual.character_space.ext WeakDual.characterSpace.ext /-- An element of the character space, as a continuous linear map. -/ def toClm (φ : characterSpace 𝕜 A) : A →L[𝕜] 𝕜 := (φ : WeakDual 𝕜 A) #align weak_dual.character_space.to_clm WeakDual.characterSpace.toClm @[simp] theorem coe_toClm (φ : characterSpace 𝕜 A) : ⇑(toClm φ) = φ := rfl #align weak_dual.character_space.coe_to_clm WeakDual.characterSpace.coe_toClm /-- Elements of the character space are non-unital algebra homomorphisms. -/ instance : NonUnitalAlgHomClass (characterSpace 𝕜 A) 𝕜 A 𝕜 := { characterSpace.continuousLinearMapClass with map_smul := fun φ => map_smul φ map_zero := fun φ => map_zero φ map_mul := fun φ => φ.Prop.2 } /-- An element of the character space, as an non-unital algebra homomorphism. -/ def toNonUnitalAlgHom (φ : characterSpace 𝕜 A) : A →ₙₐ[𝕜] 𝕜 where toFun := (φ : A → 𝕜) map_mul' := map_mul φ map_smul' := map_smul φ map_zero' := map_zero φ map_add' := map_add φ #align weak_dual.character_space.to_non_unital_alg_hom WeakDual.characterSpace.toNonUnitalAlgHom @[simp] theorem coe_toNonUnitalAlgHom (φ : characterSpace 𝕜 A) : ⇑(toNonUnitalAlgHom φ) = φ := rfl #align weak_dual.character_space.coe_to_non_unital_alg_hom WeakDual.characterSpace.coe_toNonUnitalAlgHom instance [Subsingleton A] : IsEmpty (characterSpace 𝕜 A) := ⟨fun φ => φ.Prop.1 <| ContinuousLinearMap.ext fun x => by simp only [Subsingleton.elim x 0, map_zero]⟩ variable (𝕜 A) theorem union_zero : characterSpace 𝕜 A ∪ {0} = { φ : WeakDual 𝕜 A | ∀ x y : A, φ (x * y) = φ x * φ y } := le_antisymm (by rintro φ (hφ | h₀) · exact hφ.2 · exact fun x y => by simp [Set.eq_of_mem_singleton h₀]) fun φ hφ => Or.elim (em <| φ = 0) (fun h₀ => Or.inr h₀) fun h₀ => Or.inl ⟨h₀, hφ⟩ #align weak_dual.character_space.union_zero WeakDual.characterSpace.union_zero /-- The `character_space 𝕜 A` along with `0` is always a closed set in `weak_dual 𝕜 A`. -/ theorem union_zero_isClosed [T2Space 𝕜] [ContinuousMul 𝕜] : IsClosed (characterSpace 𝕜 A ∪ {0}) := by simp only [union_zero, Set.setOf_forall] exact isClosed_interᵢ fun x => isClosed_interᵢ fun y => isClosed_eq (eval_continuous _) <| (eval_continuous _).mul (eval_continuous _) #align weak_dual.character_space.union_zero_is_closed WeakDual.characterSpace.union_zero_isClosed end NonUnitalNonAssocSemiring section Unital variable [CommRing 𝕜] [NoZeroDivisors 𝕜] [TopologicalSpace 𝕜] [ContinuousAdd 𝕜] [ContinuousConstSMul 𝕜 𝕜] [TopologicalSpace A] [Semiring A] [Algebra 𝕜 A] /-- In a unital algebra, elements of the character space are algebra homomorphisms. -/ instance : AlgHomClass (characterSpace 𝕜 A) 𝕜 A 𝕜 := have map_one' : ∀ φ : characterSpace 𝕜 A, φ 1 = 1 := fun φ => by have h₁ : φ 1 * (1 - φ 1) = 0 := by rw [mul_sub, sub_eq_zero, mul_one, ← map_mul φ, one_mul] rcases mul_eq_zero.mp h₁ with (h₂ | h₂) · have : ∀ a, φ (a * 1) = 0 := fun a => by simp only [map_mul φ, h₂, MulZeroClass.mul_zero] exact False.elim (φ.prop.1 <| ContinuousLinearMap.ext <| by simpa only [mul_one] using this) · exact (sub_eq_zero.mp h₂).symm { characterSpace.nonUnitalAlgHomClass with map_one := map_one' commutes := fun φ r => by rw [Algebra.algebraMap_eq_smul_one, Algebra.id.map_eq_id, RingHom.id_apply] change ((φ : WeakDual 𝕜 A) : A →L[𝕜] 𝕜) (r • 1) = r rw [map_smul, Algebra.id.smul_eq_mul, character_space.coe_coe, map_one' φ, mul_one] } /-- An element of the character space of a unital algebra, as an algebra homomorphism. -/ @[simps] def toAlgHom (φ : characterSpace 𝕜 A) : A →ₐ[𝕜] 𝕜 := { toNonUnitalAlgHom φ with map_one' := map_one φ commutes' := AlgHomClass.commutes φ } #align weak_dual.character_space.to_alg_hom WeakDual.characterSpace.toAlgHom theorem eq_set_map_one_map_mul [Nontrivial 𝕜] : characterSpace 𝕜 A = { φ : WeakDual 𝕜 A | φ 1 = 1 ∧ ∀ x y : A, φ (x * y) = φ x * φ y } := by ext x refine' ⟨fun h => ⟨map_one (⟨x, h⟩ : character_space 𝕜 A), h.2⟩, fun h => ⟨_, h.2⟩⟩ rintro rfl simpa using h.1 #align weak_dual.character_space.eq_set_map_one_map_mul WeakDual.characterSpace.eq_set_map_one_map_mul /-- under suitable mild assumptions on `𝕜`, the character space is a closed set in `weak_dual 𝕜 A`. -/ protected theorem isClosed [Nontrivial 𝕜] [T2Space 𝕜] [ContinuousMul 𝕜] : IsClosed (characterSpace 𝕜 A) := by rw [eq_set_map_one_map_mul, Set.setOf_and] refine' IsClosed.inter (isClosed_eq (eval_continuous _) continuous_const) _ simpa only [(union_zero 𝕜 A).symm] using union_zero_is_closed _ _ #align weak_dual.character_space.is_closed WeakDual.characterSpace.isClosed end Unital section Ring variable [CommRing 𝕜] [NoZeroDivisors 𝕜] [TopologicalSpace 𝕜] [ContinuousAdd 𝕜] [ContinuousConstSMul 𝕜 𝕜] [TopologicalSpace A] [Ring A] [Algebra 𝕜 A] theorem apply_mem_spectrum [Nontrivial 𝕜] (φ : characterSpace 𝕜 A) (a : A) : φ a ∈ spectrum 𝕜 a := AlgHom.apply_mem_spectrum φ a #align weak_dual.character_space.apply_mem_spectrum WeakDual.characterSpace.apply_mem_spectrum theorem ext_ker {φ ψ : characterSpace 𝕜 A} (h : RingHom.ker φ = RingHom.ker ψ) : φ = ψ := by ext have : x - algebraMap 𝕜 A (ψ x) ∈ RingHom.ker φ := by simpa only [h, RingHom.mem_ker, map_sub, AlgHomClass.commutes] using sub_self (ψ x) · rwa [RingHom.mem_ker, map_sub, AlgHomClass.commutes, sub_eq_zero] at this #align weak_dual.character_space.ext_ker WeakDual.characterSpace.ext_ker end Ring end CharacterSpace section Kernel variable [Field 𝕜] [TopologicalSpace 𝕜] [ContinuousAdd 𝕜] [ContinuousConstSMul 𝕜 𝕜] variable [Ring A] [TopologicalSpace A] [Algebra 𝕜 A] /-- The `ring_hom.ker` of `φ : character_space 𝕜 A` is maximal. -/ instance ker_isMaximal (φ : characterSpace 𝕜 A) : (RingHom.ker φ).IsMaximal := RingHom.ker_isMaximal_of_surjective φ fun z => ⟨algebraMap 𝕜 A z, by simp only [AlgHomClass.commutes, Algebra.id.map_eq_id, RingHom.id_apply]⟩ #align weak_dual.ker_is_maximal WeakDual.ker_isMaximal end Kernel section GelfandTransform open ContinuousMap variable (𝕜 A) [CommRing 𝕜] [NoZeroDivisors 𝕜] [TopologicalSpace 𝕜] [TopologicalRing 𝕜] [TopologicalSpace A] [Semiring A] [Algebra 𝕜 A] /-- The **Gelfand transform** is an algebra homomorphism (over `𝕜`) from a topological `𝕜`-algebra `A` into the `𝕜`-algebra of continuous `𝕜`-valued functions on the `character_space 𝕜 A`. The character space itself consists of all algebra homomorphisms from `A` to `𝕜`. -/ @[simps] def gelfandTransform : A →ₐ[𝕜] C(characterSpace 𝕜 A, 𝕜) where toFun a := { toFun := fun φ => φ a continuous_toFun := (eval_continuous a).comp continuous_induced_dom } map_one' := by ext simp only [coe_mk, coe_one, Pi.one_apply, map_one a] map_mul' a b := by ext simp only [map_mul, coe_mk, coe_mul, Pi.mul_apply] map_zero' := by ext simp only [map_zero, coe_mk, coe_mul, coe_zero, Pi.zero_apply] map_add' a b := by ext simp only [map_add, coe_mk, coe_add, Pi.add_apply] commutes' k := by ext simp only [AlgHomClass.commutes, Algebra.id.map_eq_id, RingHom.id_apply, coe_mk, algebraMap_apply, Algebra.id.smul_eq_mul, mul_one] #align weak_dual.gelfand_transform WeakDual.gelfandTransform end GelfandTransform end WeakDual
[GOAL] ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : Monoid α inst✝¹ : Monoid β inst✝ : MonoidHomClass F α β f : F a : Set α as : List (Set α) ⊢ ↑f '' List.prod (a :: as) = List.prod (List.map (fun s => ↑f '' s) (a :: as)) [PROOFSTEP] rw [List.map_cons, List.prod_cons, List.prod_cons, image_mul, image_list_prod _ _] [GOAL] ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β f : F ⊢ ∀ (a : List (Set α)), ↑f '' Multiset.prod (Quotient.mk (List.isSetoid (Set α)) a) = Multiset.prod (Multiset.map (fun s => ↑f '' s) (Quotient.mk (List.isSetoid (Set α)) a)) [PROOFSTEP] simpa only [Multiset.quot_mk_to_coe, Multiset.coe_prod, Multiset.coe_map] using image_list_prod f [GOAL] ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β t : Finset ι f : ι → Set α a : α ⊢ a ∈ ∏ i in t, f i ↔ ∃ g x, ∏ i in t, g i = a [PROOFSTEP] classical induction' t using Finset.induction_on with i is hi ih generalizing a · simp_rw [Finset.prod_empty, Set.mem_one] exact ⟨fun h ↦ ⟨fun _ ↦ a, fun hi ↦ False.elim (Finset.not_mem_empty _ hi), h.symm⟩, fun ⟨_, _, hf⟩ ↦ hf.symm⟩ rw [Finset.prod_insert hi, Set.mem_mul] simp_rw [Finset.prod_insert hi] simp_rw [ih] constructor · rintro ⟨x, y, hx, ⟨g, hg, rfl⟩, rfl⟩ refine ⟨Function.update g i x, ?_, ?_⟩ · intro j hj obtain rfl | hj := Finset.mem_insert.mp hj · rwa [Function.update_same] · rw [update_noteq (ne_of_mem_of_not_mem hj hi)] exact hg hj · rw [Finset.prod_update_of_not_mem hi, Function.update_same] · rintro ⟨g, hg, rfl⟩ exact ⟨g i, is.prod g, hg (is.mem_insert_self _), ⟨⟨g, fun hi ↦ hg (Finset.mem_insert_of_mem hi), rfl⟩, rfl⟩⟩ [GOAL] ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β t : Finset ι f : ι → Set α a : α ⊢ a ∈ ∏ i in t, f i ↔ ∃ g x, ∏ i in t, g i = a [PROOFSTEP] induction' t using Finset.induction_on with i is hi ih generalizing a [GOAL] case empty ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β f : ι → Set α a✝ a : α ⊢ a ∈ ∏ i in ∅, f i ↔ ∃ g x, ∏ i in ∅, g i = a [PROOFSTEP] simp_rw [Finset.prod_empty, Set.mem_one] [GOAL] case empty ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β f : ι → Set α a✝ a : α ⊢ a = 1 ↔ ∃ g h, 1 = a [PROOFSTEP] exact ⟨fun h ↦ ⟨fun _ ↦ a, fun hi ↦ False.elim (Finset.not_mem_empty _ hi), h.symm⟩, fun ⟨_, _, hf⟩ ↦ hf.symm⟩ [GOAL] case insert ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β f : ι → Set α a✝ : α i : ι is : Finset ι hi : ¬i ∈ is ih : ∀ (a : α), a ∈ ∏ i in is, f i ↔ ∃ g x, ∏ i in is, g i = a a : α ⊢ a ∈ ∏ i in insert i is, f i ↔ ∃ g x, ∏ i in insert i is, g i = a [PROOFSTEP] rw [Finset.prod_insert hi, Set.mem_mul] [GOAL] case insert ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β f : ι → Set α a✝ : α i : ι is : Finset ι hi : ¬i ∈ is ih : ∀ (a : α), a ∈ ∏ i in is, f i ↔ ∃ g x, ∏ i in is, g i = a a : α ⊢ (∃ x y, x ∈ f i ∧ y ∈ ∏ x in is, f x ∧ x * y = a) ↔ ∃ g x, ∏ i in insert i is, g i = a [PROOFSTEP] simp_rw [Finset.prod_insert hi] [GOAL] case insert ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β f : ι → Set α a✝ : α i : ι is : Finset ι hi : ¬i ∈ is ih : ∀ (a : α), a ∈ ∏ i in is, f i ↔ ∃ g x, ∏ i in is, g i = a a : α ⊢ (∃ x y, x ∈ f i ∧ y ∈ ∏ x in is, f x ∧ x * y = a) ↔ ∃ g h, g i * ∏ i in is, g i = a [PROOFSTEP] simp_rw [ih] [GOAL] case insert ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β f : ι → Set α a✝ : α i : ι is : Finset ι hi : ¬i ∈ is ih : ∀ (a : α), a ∈ ∏ i in is, f i ↔ ∃ g x, ∏ i in is, g i = a a : α ⊢ (∃ x y, x ∈ f i ∧ (∃ g x, ∏ i in is, g i = y) ∧ x * y = a) ↔ ∃ g h, g i * ∏ i in is, g i = a [PROOFSTEP] constructor [GOAL] case insert.mp ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β f : ι → Set α a✝ : α i : ι is : Finset ι hi : ¬i ∈ is ih : ∀ (a : α), a ∈ ∏ i in is, f i ↔ ∃ g x, ∏ i in is, g i = a a : α ⊢ (∃ x y, x ∈ f i ∧ (∃ g x, ∏ i in is, g i = y) ∧ x * y = a) → ∃ g h, g i * ∏ i in is, g i = a [PROOFSTEP] rintro ⟨x, y, hx, ⟨g, hg, rfl⟩, rfl⟩ [GOAL] case insert.mp.intro.intro.intro.intro.intro.intro ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β f : ι → Set α a : α i : ι is : Finset ι hi : ¬i ∈ is ih : ∀ (a : α), a ∈ ∏ i in is, f i ↔ ∃ g x, ∏ i in is, g i = a x : α hx : x ∈ f i g : ι → α hg : ∀ {i : ι}, i ∈ is → g i ∈ f i ⊢ ∃ g_1 h, g_1 i * ∏ i in is, g_1 i = x * ∏ i in is, g i [PROOFSTEP] refine ⟨Function.update g i x, ?_, ?_⟩ [GOAL] case insert.mp.intro.intro.intro.intro.intro.intro.refine_1 ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β f : ι → Set α a : α i : ι is : Finset ι hi : ¬i ∈ is ih : ∀ (a : α), a ∈ ∏ i in is, f i ↔ ∃ g x, ∏ i in is, g i = a x : α hx : x ∈ f i g : ι → α hg : ∀ {i : ι}, i ∈ is → g i ∈ f i ⊢ ∀ {i_1 : ι}, i_1 ∈ insert i is → update g i x i_1 ∈ f i_1 [PROOFSTEP] intro j hj [GOAL] case insert.mp.intro.intro.intro.intro.intro.intro.refine_1 ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β f : ι → Set α a : α i : ι is : Finset ι hi : ¬i ∈ is ih : ∀ (a : α), a ∈ ∏ i in is, f i ↔ ∃ g x, ∏ i in is, g i = a x : α hx : x ∈ f i g : ι → α hg : ∀ {i : ι}, i ∈ is → g i ∈ f i j : ι hj : j ∈ insert i is ⊢ update g i x j ∈ f j [PROOFSTEP] obtain rfl | hj := Finset.mem_insert.mp hj [GOAL] case insert.mp.intro.intro.intro.intro.intro.intro.refine_1.inl ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β f : ι → Set α a : α is : Finset ι ih : ∀ (a : α), a ∈ ∏ i in is, f i ↔ ∃ g x, ∏ i in is, g i = a x : α g : ι → α hg : ∀ {i : ι}, i ∈ is → g i ∈ f i j : ι hi : ¬j ∈ is hx : x ∈ f j hj : j ∈ insert j is ⊢ update g j x j ∈ f j [PROOFSTEP] rwa [Function.update_same] [GOAL] case insert.mp.intro.intro.intro.intro.intro.intro.refine_1.inr ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β f : ι → Set α a : α i : ι is : Finset ι hi : ¬i ∈ is ih : ∀ (a : α), a ∈ ∏ i in is, f i ↔ ∃ g x, ∏ i in is, g i = a x : α hx : x ∈ f i g : ι → α hg : ∀ {i : ι}, i ∈ is → g i ∈ f i j : ι hj✝ : j ∈ insert i is hj : j ∈ is ⊢ update g i x j ∈ f j [PROOFSTEP] rw [update_noteq (ne_of_mem_of_not_mem hj hi)] [GOAL] case insert.mp.intro.intro.intro.intro.intro.intro.refine_1.inr ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β f : ι → Set α a : α i : ι is : Finset ι hi : ¬i ∈ is ih : ∀ (a : α), a ∈ ∏ i in is, f i ↔ ∃ g x, ∏ i in is, g i = a x : α hx : x ∈ f i g : ι → α hg : ∀ {i : ι}, i ∈ is → g i ∈ f i j : ι hj✝ : j ∈ insert i is hj : j ∈ is ⊢ g j ∈ f j [PROOFSTEP] exact hg hj [GOAL] case insert.mp.intro.intro.intro.intro.intro.intro.refine_2 ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β f : ι → Set α a : α i : ι is : Finset ι hi : ¬i ∈ is ih : ∀ (a : α), a ∈ ∏ i in is, f i ↔ ∃ g x, ∏ i in is, g i = a x : α hx : x ∈ f i g : ι → α hg : ∀ {i : ι}, i ∈ is → g i ∈ f i ⊢ update g i x i * ∏ i_1 in is, update g i x i_1 = x * ∏ i in is, g i [PROOFSTEP] rw [Finset.prod_update_of_not_mem hi, Function.update_same] [GOAL] case insert.mpr ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β f : ι → Set α a✝ : α i : ι is : Finset ι hi : ¬i ∈ is ih : ∀ (a : α), a ∈ ∏ i in is, f i ↔ ∃ g x, ∏ i in is, g i = a a : α ⊢ (∃ g h, g i * ∏ i in is, g i = a) → ∃ x y, x ∈ f i ∧ (∃ g x, ∏ i in is, g i = y) ∧ x * y = a [PROOFSTEP] rintro ⟨g, hg, rfl⟩ [GOAL] case insert.mpr.intro.intro ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β f : ι → Set α a : α i : ι is : Finset ι hi : ¬i ∈ is ih : ∀ (a : α), a ∈ ∏ i in is, f i ↔ ∃ g x, ∏ i in is, g i = a g : ι → α hg : ∀ {i_1 : ι}, i_1 ∈ insert i is → g i_1 ∈ f i_1 ⊢ ∃ x y, x ∈ f i ∧ (∃ g x, ∏ i in is, g i = y) ∧ x * y = g i * ∏ i in is, g i [PROOFSTEP] exact ⟨g i, is.prod g, hg (is.mem_insert_self _), ⟨⟨g, fun hi ↦ hg (Finset.mem_insert_of_mem hi), rfl⟩, rfl⟩⟩ [GOAL] ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝³ : CommMonoid α inst✝² : CommMonoid β inst✝¹ : MonoidHomClass F α β inst✝ : Fintype ι f : ι → Set α a : α ⊢ a ∈ ∏ i : ι, f i ↔ ∃ g x, ∏ i : ι, g i = a [PROOFSTEP] rw [mem_finset_prod] [GOAL] ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝³ : CommMonoid α inst✝² : CommMonoid β inst✝¹ : MonoidHomClass F α β inst✝ : Fintype ι f : ι → Set α a : α ⊢ (∃ g x, ∏ i : ι, g i = a) ↔ ∃ g x, ∏ i : ι, g i = a [PROOFSTEP] simp [GOAL] ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β t : List ι f : ι → Set α g : ι → α hg : ∀ (i : ι), i ∈ t → g i ∈ f i ⊢ List.prod (List.map g t) ∈ List.prod (List.map f t) [PROOFSTEP] induction' t with h tl ih [GOAL] case nil ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β t : List ι f : ι → Set α g : ι → α hg✝ : ∀ (i : ι), i ∈ t → g i ∈ f i hg : ∀ (i : ι), i ∈ [] → g i ∈ f i ⊢ List.prod (List.map g []) ∈ List.prod (List.map f []) [PROOFSTEP] simp_rw [List.map_nil, List.prod_nil, Set.mem_one] [GOAL] case cons ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β t : List ι f : ι → Set α g : ι → α hg✝ : ∀ (i : ι), i ∈ t → g i ∈ f i h : ι tl : List ι ih : (∀ (i : ι), i ∈ tl → g i ∈ f i) → List.prod (List.map g tl) ∈ List.prod (List.map f tl) hg : ∀ (i : ι), i ∈ h :: tl → g i ∈ f i ⊢ List.prod (List.map g (h :: tl)) ∈ List.prod (List.map f (h :: tl)) [PROOFSTEP] simp_rw [List.map_cons, List.prod_cons] [GOAL] case cons ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β t : List ι f : ι → Set α g : ι → α hg✝ : ∀ (i : ι), i ∈ t → g i ∈ f i h : ι tl : List ι ih : (∀ (i : ι), i ∈ tl → g i ∈ f i) → List.prod (List.map g tl) ∈ List.prod (List.map f tl) hg : ∀ (i : ι), i ∈ h :: tl → g i ∈ f i ⊢ g h * List.prod (List.map g tl) ∈ f h * List.prod (List.map f tl) [PROOFSTEP] exact mul_mem_mul (hg h <| List.mem_cons_self _ _) (ih fun i hi ↦ hg i <| List.mem_cons_of_mem _ hi) [GOAL] ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β t : List ι f₁ f₂ : ι → Set α hf : ∀ (i : ι), i ∈ t → f₁ i ⊆ f₂ i ⊢ List.prod (List.map f₁ t) ⊆ List.prod (List.map f₂ t) [PROOFSTEP] induction' t with h tl ih [GOAL] case nil ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β t : List ι f₁ f₂ : ι → Set α hf✝ : ∀ (i : ι), i ∈ t → f₁ i ⊆ f₂ i hf : ∀ (i : ι), i ∈ [] → f₁ i ⊆ f₂ i ⊢ List.prod (List.map f₁ []) ⊆ List.prod (List.map f₂ []) [PROOFSTEP] rfl [GOAL] case cons ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β t : List ι f₁ f₂ : ι → Set α hf✝ : ∀ (i : ι), i ∈ t → f₁ i ⊆ f₂ i h : ι tl : List ι ih : (∀ (i : ι), i ∈ tl → f₁ i ⊆ f₂ i) → List.prod (List.map f₁ tl) ⊆ List.prod (List.map f₂ tl) hf : ∀ (i : ι), i ∈ h :: tl → f₁ i ⊆ f₂ i ⊢ List.prod (List.map f₁ (h :: tl)) ⊆ List.prod (List.map f₂ (h :: tl)) [PROOFSTEP] simp_rw [List.map_cons, List.prod_cons] [GOAL] case cons ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β t : List ι f₁ f₂ : ι → Set α hf✝ : ∀ (i : ι), i ∈ t → f₁ i ⊆ f₂ i h : ι tl : List ι ih : (∀ (i : ι), i ∈ tl → f₁ i ⊆ f₂ i) → List.prod (List.map f₁ tl) ⊆ List.prod (List.map f₂ tl) hf : ∀ (i : ι), i ∈ h :: tl → f₁ i ⊆ f₂ i ⊢ f₁ h * List.prod (List.map f₁ tl) ⊆ f₂ h * List.prod (List.map f₂ tl) [PROOFSTEP] exact mul_subset_mul (hf h <| List.mem_cons_self _ _) (ih fun i hi ↦ hf i <| List.mem_cons_of_mem _ hi) [GOAL] ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β t : Multiset ι f : ι → Set α g : ι → α hg : ∀ (i : ι), i ∈ t → g i ∈ f i ⊢ Multiset.prod (Multiset.map g t) ∈ Multiset.prod (Multiset.map f t) [PROOFSTEP] induction t using Quotient.inductionOn [GOAL] case h ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β f : ι → Set α g : ι → α a✝ : List ι hg : ∀ (i : ι), i ∈ Quotient.mk (List.isSetoid ι) a✝ → g i ∈ f i ⊢ Multiset.prod (Multiset.map g (Quotient.mk (List.isSetoid ι) a✝)) ∈ Multiset.prod (Multiset.map f (Quotient.mk (List.isSetoid ι) a✝)) [PROOFSTEP] simp_rw [Multiset.quot_mk_to_coe, Multiset.coe_map, Multiset.coe_prod] [GOAL] case h ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β f : ι → Set α g : ι → α a✝ : List ι hg : ∀ (i : ι), i ∈ Quotient.mk (List.isSetoid ι) a✝ → g i ∈ f i ⊢ List.prod (List.map g a✝) ∈ List.prod (List.map f a✝) [PROOFSTEP] exact list_prod_mem_list_prod _ _ _ hg [GOAL] ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β t : Multiset ι f₁ f₂ : ι → Set α hf : ∀ (i : ι), i ∈ t → f₁ i ⊆ f₂ i ⊢ Multiset.prod (Multiset.map f₁ t) ⊆ Multiset.prod (Multiset.map f₂ t) [PROOFSTEP] induction t using Quotient.inductionOn [GOAL] case h ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β f₁ f₂ : ι → Set α a✝ : List ι hf : ∀ (i : ι), i ∈ Quotient.mk (List.isSetoid ι) a✝ → f₁ i ⊆ f₂ i ⊢ Multiset.prod (Multiset.map f₁ (Quotient.mk (List.isSetoid ι) a✝)) ⊆ Multiset.prod (Multiset.map f₂ (Quotient.mk (List.isSetoid ι) a✝)) [PROOFSTEP] simp_rw [Multiset.quot_mk_to_coe, Multiset.coe_map, Multiset.coe_prod] [GOAL] case h ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β f₁ f₂ : ι → Set α a✝ : List ι hf : ∀ (i : ι), i ∈ Quotient.mk (List.isSetoid ι) a✝ → f₁ i ⊆ f₂ i ⊢ List.prod (List.map f₁ a✝) ⊆ List.prod (List.map f₂ a✝) [PROOFSTEP] exact list_prod_subset_list_prod _ _ _ hf [GOAL] ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β l : Finset ι S : ι → Set α ⊢ (fun f => ∏ i in l, f i) '' pi (↑l) S = ∏ i in l, S i [PROOFSTEP] ext [GOAL] case h ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝² : CommMonoid α inst✝¹ : CommMonoid β inst✝ : MonoidHomClass F α β l : Finset ι S : ι → Set α x✝ : α ⊢ x✝ ∈ (fun f => ∏ i in l, f i) '' pi (↑l) S ↔ x✝ ∈ ∏ i in l, S i [PROOFSTEP] simp_rw [mem_finset_prod, mem_image, mem_pi, exists_prop, Finset.mem_coe] [GOAL] ι : Type u_1 α : Type u_2 β : Type u_3 F : Type u_4 inst✝³ : CommMonoid α inst✝² : CommMonoid β inst✝¹ : MonoidHomClass F α β inst✝ : Fintype ι S : ι → Set α ⊢ (fun f => ∏ i : ι, f i) '' pi univ S = ∏ i : ι, S i [PROOFSTEP] simpa only [Finset.coe_univ] using image_finset_prod_pi Finset.univ S
{- Definition of a homogeneous pointed type, and proofs that pi, product, path, and discrete types are homogeneous Portions of this file adapted from Nicolai Kraus' code here: https://bitbucket.org/nicolaikraus/agda/src/e30d70c72c6af8e62b72eefabcc57623dd921f04/trunc-inverse.lagda -} {-# OPTIONS --safe #-} module Cubical.Foundations.Pointed.Homogeneous where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Foundations.Path open import Cubical.Data.Sigma open import Cubical.Data.Empty as ⊥ open import Cubical.Relation.Nullary open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Pointed.Base open import Cubical.Foundations.Pointed.Properties open import Cubical.Structures.Pointed isHomogeneous : ∀ {ℓ} → Pointed ℓ → Type (ℓ-suc ℓ) isHomogeneous {ℓ} (A , x) = ∀ y → Path (Pointed ℓ) (A , x) (A , y) -- Pointed functions into a homogeneous type are equal as soon as they are equal -- as unpointed functions →∙Homogeneous≡ : ∀ {ℓ ℓ'} {A∙ : Pointed ℓ} {B∙ : Pointed ℓ'} {f∙ g∙ : A∙ →∙ B∙} (h : isHomogeneous B∙) → f∙ .fst ≡ g∙ .fst → f∙ ≡ g∙ →∙Homogeneous≡ {A∙ = A∙@(_ , a₀)} {B∙@(B , _)} {f∙@(_ , f₀)} {g∙@(_ , g₀)} h p = subst (λ Q∙ → PathP (λ i → A∙ →∙ Q∙ i) f∙ g∙) (sym (flipSquare fix)) badPath where badPath : PathP (λ i → A∙ →∙ (B , (sym f₀ ∙∙ funExt⁻ p a₀ ∙∙ g₀) i)) f∙ g∙ badPath i .fst = p i badPath i .snd j = doubleCompPath-filler (sym f₀) (funExt⁻ p a₀) g₀ j i fix : PathP (λ i → B∙ ≡ (B , (sym f₀ ∙∙ funExt⁻ p a₀ ∙∙ g₀) i)) refl refl fix i = hcomp (λ j → λ { (i = i0) → lCancel (h (pt B∙)) j ; (i = i1) → lCancel (h (pt B∙)) j }) (sym (h (pt B∙)) ∙ h ((sym f₀ ∙∙ funExt⁻ p a₀ ∙∙ g₀) i)) →∙Homogeneous≡Path : ∀ {ℓ ℓ'} {A∙ : Pointed ℓ} {B∙ : Pointed ℓ'} {f∙ g∙ : A∙ →∙ B∙} (h : isHomogeneous B∙) → (p q : f∙ ≡ g∙) → cong fst p ≡ cong fst q → p ≡ q →∙Homogeneous≡Path {A∙ = A∙@(A , a₀)} {B∙@(B , b)} {f∙@(f , f₀)} {g∙@(g , g₀)} h p q r = transport (λ k → PathP (λ i → PathP (λ j → (A , a₀) →∙ newPath-refl p q r i j (~ k)) (f , f₀) (g , g₀)) p q) (badPath p q r) where newPath : (p q : f∙ ≡ g∙) (r : cong fst p ≡ cong fst q) → Square (refl {x = b}) refl refl refl newPath p q r i j = hcomp (λ k → λ {(i = i0) → cong snd p j k ; (i = i1) → cong snd q j k ; (j = i0) → f₀ k ; (j = i1) → g₀ k}) (r i j a₀) newPath-refl : (p q : f∙ ≡ g∙) (r : cong fst p ≡ cong fst q) → PathP (λ i → (PathP (λ j → B∙ ≡ (B , newPath p q r i j))) refl refl) refl refl newPath-refl p q r i j k = hcomp (λ w → λ { (i = i0) → lCancel (h b) w k ; (i = i1) → lCancel (h b) w k ; (j = i0) → lCancel (h b) w k ; (j = i1) → lCancel (h b) w k ; (k = i0) → lCancel (h b) w k ; (k = i1) → B , newPath p q r i j}) ((sym (h b) ∙ h (newPath p q r i j)) k) badPath : (p q : f∙ ≡ g∙) (r : cong fst p ≡ cong fst q) → PathP (λ i → PathP (λ j → A∙ →∙ (B , newPath p q r i j)) (f , f₀) (g , g₀)) p q fst (badPath p q r i j) = r i j snd (badPath p q s i j) k = hcomp (λ r → λ { (i = i0) → snd (p j) (r ∧ k) ; (i = i1) → snd (q j) (r ∧ k) ; (j = i0) → f₀ (k ∧ r) ; (j = i1) → g₀ (k ∧ r) ; (k = i0) → s i j a₀}) (s i j a₀) isHomogeneousPi : ∀ {ℓ ℓ'} {A : Type ℓ} {B∙ : A → Pointed ℓ'} → (∀ a → isHomogeneous (B∙ a)) → isHomogeneous (Πᵘ∙ A B∙) isHomogeneousPi h f i .fst = ∀ a → typ (h a (f a) i) isHomogeneousPi h f i .snd a = pt (h a (f a) i) isHomogeneousΠ∙ : ∀ {ℓ ℓ'} (A : Pointed ℓ) (B : typ A → Type ℓ') → (b₀ : B (pt A)) → ((a : typ A) (x : B a) → isHomogeneous (B a , x)) → (f : Π∙ A B b₀) → isHomogeneous (Π∙ A B b₀ , f) fst (isHomogeneousΠ∙ A B b₀ h f g i) = Σ[ r ∈ ((a : typ A) → fst ((h a (fst f a) (fst g a)) i)) ] r (pt A) ≡ hcomp (λ k → λ {(i = i0) → snd f k ; (i = i1) → snd g k}) (snd (h (pt A) (fst f (pt A)) (fst g (pt A)) i)) snd (isHomogeneousΠ∙ A B b₀ h f g i) = (λ a → snd (h a (fst f a) (fst g a) i)) , λ j → hcomp (λ k → λ { (i = i0) → snd f (k ∧ j) ; (i = i1) → snd g (k ∧ j) ; (j = i0) → snd (h (pt A) (fst f (pt A)) (fst g (pt A)) i)}) (snd (h (pt A) (fst f (pt A)) (fst g (pt A)) i)) isHomogeneous→∙ : ∀ {ℓ ℓ'} {A∙ : Pointed ℓ} {B∙ : Pointed ℓ'} → isHomogeneous B∙ → isHomogeneous (A∙ →∙ B∙ ∙) isHomogeneous→∙ {A∙ = A∙} {B∙} h f∙ = ΣPathP ( (λ i → Π∙ A∙ (λ a → T a i) (t₀ i)) , PathPIsoPath _ _ _ .Iso.inv (→∙Homogeneous≡ h (PathPIsoPath (λ i → (a : typ A∙) → T a i) (λ _ → pt B∙) _ .Iso.fun (λ i a → pt (h (f∙ .fst a) i)))) ) where T : ∀ a → typ B∙ ≡ typ B∙ T a i = typ (h (f∙ .fst a) i) t₀ : PathP (λ i → T (pt A∙) i) (pt B∙) (pt B∙) t₀ = cong pt (h (f∙ .fst (pt A∙))) ▷ f∙ .snd isHomogeneousProd : ∀ {ℓ ℓ'} {A∙ : Pointed ℓ} {B∙ : Pointed ℓ'} → isHomogeneous A∙ → isHomogeneous B∙ → isHomogeneous (A∙ ×∙ B∙) isHomogeneousProd hA hB (a , b) i .fst = typ (hA a i) × typ (hB b i) isHomogeneousProd hA hB (a , b) i .snd .fst = pt (hA a i) isHomogeneousProd hA hB (a , b) i .snd .snd = pt (hB b i) isHomogeneousPath : ∀ {ℓ} (A : Type ℓ) {x y : A} (p : x ≡ y) → isHomogeneous ((x ≡ y) , p) isHomogeneousPath A {x} {y} p q = pointed-sip ((x ≡ y) , p) ((x ≡ y) , q) (eqv , compPathr-cancel p q) where eqv : (x ≡ y) ≃ (x ≡ y) eqv = compPathlEquiv (q ∙ sym p) module HomogeneousDiscrete {ℓ} {A∙ : Pointed ℓ} (dA : Discrete (typ A∙)) (y : typ A∙) where -- switches pt A∙ with y switch : typ A∙ → typ A∙ switch x with dA x (pt A∙) ... | yes _ = y ... | no _ with dA x y ... | yes _ = pt A∙ ... | no _ = x switch-ptA∙ : switch (pt A∙) ≡ y switch-ptA∙ with dA (pt A∙) (pt A∙) ... | yes _ = refl ... | no ¬p = ⊥.rec (¬p refl) switch-idp : ∀ x → switch (switch x) ≡ x switch-idp x with dA x (pt A∙) switch-idp x | yes p with dA y (pt A∙) switch-idp x | yes p | yes q = q ∙ sym p switch-idp x | yes p | no _ with dA y y switch-idp x | yes p | no _ | yes _ = sym p switch-idp x | yes p | no _ | no ¬p = ⊥.rec (¬p refl) switch-idp x | no ¬p with dA x y switch-idp x | no ¬p | yes p with dA y (pt A∙) switch-idp x | no ¬p | yes p | yes q = ⊥.rec (¬p (p ∙ q)) switch-idp x | no ¬p | yes p | no _ with dA (pt A∙) (pt A∙) switch-idp x | no ¬p | yes p | no _ | yes _ = sym p switch-idp x | no ¬p | yes p | no _ | no ¬q = ⊥.rec (¬q refl) switch-idp x | no ¬p | no ¬q with dA x (pt A∙) switch-idp x | no ¬p | no ¬q | yes p = ⊥.rec (¬p p) switch-idp x | no ¬p | no ¬q | no _ with dA x y switch-idp x | no ¬p | no ¬q | no _ | yes q = ⊥.rec (¬q q) switch-idp x | no ¬p | no ¬q | no _ | no _ = refl switch-eqv : typ A∙ ≃ typ A∙ switch-eqv = isoToEquiv (iso switch switch switch-idp switch-idp) isHomogeneousDiscrete : ∀ {ℓ} {A∙ : Pointed ℓ} (dA : Discrete (typ A∙)) → isHomogeneous A∙ isHomogeneousDiscrete {ℓ} {A∙} dA y = pointed-sip (typ A∙ , pt A∙) (typ A∙ , y) (switch-eqv , switch-ptA∙) where open HomogeneousDiscrete {ℓ} {A∙} dA y
/- Copyright (c) 2020 Aaron Anderson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Aaron Anderson -/ import data.polynomial.degree.definitions import tactic.compute_degree import data.polynomial.degree.lemmas /-! # Cancel the leading terms of two polynomials > THIS FILE IS SYNCHRONIZED WITH MATHLIB4. > Any changes to this file require a corresponding PR to mathlib4. ## Definition * `cancel_leads p q`: the polynomial formed by multiplying `p` and `q` by monomials so that they have the same leading term, and then subtracting. ## Main Results The degree of `cancel_leads` is less than that of the larger of the two polynomials being cancelled. Thus it is useful for induction or minimal-degree arguments. -/ namespace polynomial noncomputable theory open_locale polynomial variables {R : Type*} section ring variables [ring R] (p q : R[X]) /-- `cancel_leads p q` is formed by multiplying `p` and `q` by monomials so that they have the same leading term, and then subtracting. -/ def cancel_leads : R[X] := C p.leading_coeff * X ^ (p.nat_degree - q.nat_degree) * q - C q.leading_coeff * X ^ (q.nat_degree - p.nat_degree) * p variables {p q} @[simp] lemma neg_cancel_leads : - p.cancel_leads q = q.cancel_leads p := neg_sub _ _ lemma nat_degree_cancel_leads_lt_of_nat_degree_le_nat_degree_of_comm (comm : p.leading_coeff * q.leading_coeff = q.leading_coeff * p.leading_coeff) (h : p.nat_degree ≤ q.nat_degree) (hq : 0 < q.nat_degree) : (p.cancel_leads q).nat_degree < q.nat_degree := begin by_cases hp : p = 0, { convert hq, simp [hp, cancel_leads], }, rw [cancel_leads, sub_eq_add_neg, tsub_eq_zero_iff_le.mpr h, pow_zero, mul_one], by_cases h0 : C p.leading_coeff * q + -(C q.leading_coeff * X ^ (q.nat_degree - p.nat_degree) * p) = 0, { exact (le_of_eq (by simp only [h0, nat_degree_zero])).trans_lt hq }, apply lt_of_le_of_ne, { compute_degree_le, repeat { rwa nat.sub_add_cancel } }, { contrapose! h0, rw [← leading_coeff_eq_zero, leading_coeff, h0, mul_assoc, X_pow_mul, ← tsub_add_cancel_of_le h, add_comm _ p.nat_degree], simp only [coeff_mul_X_pow, coeff_neg, coeff_C_mul, add_tsub_cancel_left, coeff_add], rw [add_comm p.nat_degree, tsub_add_cancel_of_le h, ← leading_coeff, ← leading_coeff, comm, add_right_neg] } end end ring section comm_ring variables [comm_ring R] {p q : R[X]} lemma dvd_cancel_leads_of_dvd_of_dvd {r : R[X]} (pq : p ∣ q) (pr : p ∣ r) : p ∣ q.cancel_leads r := dvd_sub (pr.trans (dvd.intro_left _ rfl)) (pq.trans (dvd.intro_left _ rfl)) lemma nat_degree_cancel_leads_lt_of_nat_degree_le_nat_degree (h : p.nat_degree ≤ q.nat_degree) (hq : 0 < q.nat_degree) : (p.cancel_leads q).nat_degree < q.nat_degree := nat_degree_cancel_leads_lt_of_nat_degree_le_nat_degree_of_comm (mul_comm _ _) h hq end comm_ring end polynomial
import analysis.special_functions.pow open real lemma rpow_ne_zero {x y : ℝ} (hx : 0 < x) (hy : 0 < y) : x^y ≠ 0 := begin have hy2 : y ≠ 0 := by linarith, apply ne_of_gt, rw [← zero_rpow hy2, rpow_lt_rpow_iff], iterate 4 {linarith}, end lemma zero_lt_rpow {x y : ℝ} (hx : 0 < x) (hy : 0 < y) : 0 < x^y := begin have hy2 : y ≠ 0 := by linarith, rw [← zero_rpow hy2, rpow_lt_rpow_iff], iterate 4 {linarith}, end
subroutine trans8 (preeqObj, p, h, am, c1, c2, c3, results) ! ====================================================================== ! ! Calculation of exciton transition rates; c1 for delta-n = +2, ! c2 for delta-n = -2, and c3 for delta-n = 0. ! ! CEM95 written by S. G. Mashnik ! ! Edited by A. J. Sierk, LANL T-2 February, 1996. ! Modified by AJS, March, 1999. ! Modified by SGM, 2000-2001, to get CEM2k ! ! "Last" change: 13-AUG-2003 by NVM ! Edited by A. J. Sierk, LANL T-16 October, 2003. ! Edited by AJS, LANL T-2, December, 2011. ! Edited by LMK, XCP-3, July 2013 (included error protection) ! ! ====================================================================== use, intrinsic :: iso_fortran_env, only: int32, real64 use preequilibriumParams, only: hlf, zro, one, two, thr, four, fortyfive, & & emnucm implicit none class(Preequilibrium), intent(inout) :: preeqObj real(real64), intent(in ) :: p real(real64), intent(in ) :: h real(real64), intent(in ) :: am real(real64), intent( out) :: c1 real(real64), intent( out) :: c2 real(real64), intent( out) :: c3 type(preequilibriumResults), intent(inout) :: results integer(int32) :: n real(real64) :: aph, aph1, b1, b2, b3, en, est, f0, fct, fct0, & & fct2, ge, hm1, hm2, hm3, hp1, pn1, pp1, pp2, sf, spn, spp, & & svv, t, t1, temp ! ====================================================================== t1 = p + h if (t1 < div0Lim .and. t1 > -div0Lim) then t1 = div0Lim write(preeqObj%io%message,1000) "42" call preeqObj%io%print(4, 3, preeqObj%io%message) end if est = 1.6d0*fortyfive + results%residual%kinEnergy/t1 b2 = two*est/emnucm b1 = sqrt(abs(b2)) if (b1 < div0Lim .and. b1 > -div0Lim) then b1 = div0Lim write(preeqObj%io%message,1000) "54, 74" call preeqObj%io%print(4, 3, preeqObj%io%message) end if if (b2 < div0Lim .and. b2 > -div0Lim) then b2 = div0Lim write(preeqObj%io%message,1000) "58" call preeqObj%io%print(4, 3, preeqObj%io%message) end if spp = 10.63d0/b2 - 29.92d0/b1 + 42.9d0 spn = 34.10d0/b2 - 82.20d0/b1 + 82.2d0 sf = (spp + spn)/two if (est < div0Lim .and. est > -div0Lim) then est = div0Lim write(preeqObj%io%message,1000) "64" call preeqObj%io%print(4, 3, preeqObj%io%message) end if b3 = fortyfive/est t = one - 1.4d0*b3 if (b3 > hlf) then fct0 = two - one/b3 !No check needed because of if statement fct = sqrt(fct0)*fct0**2 t = t + 0.4d0*b3*fct endif ! Average value of (sigma * Vrel) over excited states, and using ! exclusion principle; divided by interaction volume. ! (lambda +) from Eq. 18 of Appendix 4 of CEM95 manual. temp = 1.2d0 + one/(4.7d0*b1) if (temp < div0Lim .and. temp > -div0Lim) then temp = div0Lim write(preeqObj%io%message,1000) "79" call preeqObj%io%print(4, 3, preeqObj%io%message) end if svv = 0.00332d0*sf*t*sqrt(abs(est))/(temp)**3 c1 = svv en = t1 + one n = nint(en) ge = am*results%residual%numBaryons*results%residual%kinEnergy pp1 = p + one hp1 = h + one pp2 = p + two hm1 = h - one hm2 = h - two hm3 = h - thr aph = (p*pp1 + h*hm3)/four aph1 = (pp1*pp2 + hp1*hm2)/four f0 = ge - aph temp = ge - aph1 if (temp < div0Lim .and. temp > -div0Lim) then temp = div0Lim write(preeqObj%io%message,1000) "98" call preeqObj%io%print(4, 3, preeqObj%io%message) end if pn1 = (f0/(temp))**n pn1 = min(1.d20, pn1) fct2 = c1*pn1*en ! (lambda -) from Eq. 18 of Appendix 4 of CEM95 manual. if (f0 < div0Lim .and. f0 > -div0Lim) then f0 = div0Lim write(preeqObj%io%message,1000) "107" call preeqObj%io%print(4, 3, preeqObj%io%message) end if c2 = fct2*p*h*(t1 - two)/f0**2 c2 = max (zro, c2) ! (lambda 0) from Eq. 18 of Appendix 4 of CEM95 manual. temp = t1*f0 if (temp < div0Lim .and. temp > -div0Lim) then temp = div0Lim write(preeqObj%io%message,1000) "116" call preeqObj%io%print(4, 3, preeqObj%io%message) end if c3 = fct2*(p*(p - one) + four*p*h + h*hm1)/(temp) return ! ====================================================================== 1000 format("Divide by zero error prevented in 'trans.f90', line ", & & A, ".") ! ====================================================================== end subroutine trans8
\section{Introduction} \label{sec:intro} This document describes StackwalkerAPI, an API and library for walking a call stack. The call stack (also known as the run-time stack) is a stack found in a process that contains the currently active stack frames. Each stack frame is a record of an executing function (or function-like object such as a signal handler or system call). StackwalkerAPI provides an API that allows users to collect a call stack (known as walking the call stack) and access information about its stack frames. The current implementation supports Linux/x86, Linux/x86-64, Linux/Power, Linux/Power-64, Windows/x86, BlueGene/L, and BlueGene/P. StackwalkerAPI is designed to be both easy-to-use and easy-to-extend. Users can easily use StackwalkerAPI to walk a call stack without needing to understand how call stacks are laid out on their platform. Users can easily extend StackwalkerAPI to work with new platforms and types of stack frames by implementing a set of callbacks that can be plugged into StackwalkerAPI. StackwalkerAPI's ease-of-use comes from it providing a platform independent interface that allows users to access detailed information about the call stack. For example, the following C++ code-snippet is all that is needed to walk and print the call stack of the currently running thread. \lstset{language=[GNU]C++,basicstyle=\ttfamily\selectfont\small} \lstset{numbers=none} \begin{lstlisting} std::vector<Frame> stackwalk; string s; Walker *walker = Walker::newWalker(); walker->walkStack(stackwalk); for (unsigned i=0; i<stackwalk.size(); i++) { stackwalk[i].getName(s); cout << "Found function " << s << endl; } \end{lstlisting} StackwalkerAPI can walk a call stack in the same address space as where the StackwalkerAPI library lives (known as a first party stackwalk), or it can walk a call stack in another process (known as a third party stackwalk). To change the above example to perform a third party stackwalk, we would only need to pass a process identifier to newWalker, e.g: \begin{lstlisting} Walker *walker = Walker::newWalker(pid); \end{lstlisting} Our other design goal with StackwalkerAPI is to make it easy-to-extend. The mechanics of how to walk through a stack frame can vary between different platforms, and even between different types of stack frames on the same platform. In addition, different platforms may have different mechanisms for reading the data in a call stack or looking up symbolic names that go with a stack frame. StackwalkerAPI provides a callback interface for plugging in mechanisms for handling new systems and types of stack frames. The callback interface can be used to port StackwalkerAPI to new platforms, extend StackwalkerAPI support on existing systems, or more easily integrate StackwalkerAPI into existing tools. There are callbacks for the following StackwalkerAPI operations: \begin{description} \item[Walk through a stack frame] StackwalkerAPI will find different types of stack frames on different platforms and even within the same platform. For example, on Linux/x86 the stack frame generated by a typical function looks different from the stack frame generated by a signal handler. The callback interface can be used to register a handler with StackwalkerAPI that knows how to walk through a new type of stack frame. For example, the DyninstAPI tool registers an object with StackwalkerAPI that describes how to walk through the stack frames generated by its instrumentation. \item[Access process data] To walk a call stack, StackwalkerAPI needs to be able to read a process' memory and registers. When doing a first party stackwalk, this is done by directly reading them from the current address space. When doing a third party stackwalk, this is done by reading them using a debugger interface. The callback interface can be used to register new objects for accessing process data. This can be used, for example, to port StackwalkerAPI to a new operating system or make it work with a new debugger interface. \item[Look up symbolic names] When StackwalkerAPI finds a stack frame, it gets an address that points into the piece of code that created that stack frame. This address is not necessarily meaningful to a user, so StackwalkerAPI attempts to associate the address with a symbolic name. The callback interface can be used to register an object with StackwalkerAPI that performs an address to name mapping, allowing StackwalkerAPI to associate names with stack frames. \end{description}
/* * This file belongs to the Galois project, a C++ library for exploiting parallelism. * The code is being released under the terms of the 3-Clause BSD License (a * copy is located in LICENSE.txt at the top-level directory). * * Copyright (C) 2018, The University of Texas at Austin. All rights reserved. * UNIVERSITY EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES CONCERNING THIS * SOFTWARE AND DOCUMENTATION, INCLUDING ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR ANY PARTICULAR PURPOSE, NON-INFRINGEMENT AND WARRANTIES OF * PERFORMANCE, AND ANY WARRANTY THAT MIGHT OTHERWISE ARISE FROM COURSE OF * DEALING OR USAGE OF TRADE. NO WARRANTY IS EITHER EXPRESS OR IMPLIED WITH * RESPECT TO THE USE OF THE SOFTWARE OR DOCUMENTATION. Under no circumstances * shall University be liable for incidental, special, indirect, direct or * consequential damages or loss of profits, interruption of business, or * related expenses which may arise from use of Software or Documentation, * including but not limited to those resulting from defects in Software and/or * Documentation, or loss or inaccuracy of data of any kind. */ #include "galois/Galois.h" #include "galois/graphs/Bag.h" #include "Lonestar/BoilerPlate.h" #include <boost/iterator/counting_iterator.hpp> typedef galois::graphs::Bag<int>::pointer IntPtrs; struct InsertBody { IntPtrs pBodies; template <typename Context> void operator()(int i, const Context& ctx) { galois::runtime::LL::gPrint("host: ", galois::runtime::NetworkInterface::ID, " pushing: ", i, "\n"); pBodies->push(i); } // Trivially_copyable typedef int tt_is_copyable; }; struct PrintInt { template <typename Context> void operator()(int i, Context& ctx) { galois::runtime::LL::gPrint("host: ", galois::runtime::NetworkInterface::ID, " received: ", i, "\n"); } }; int main(int argc, char** argv) { LonestarStart(argc, argv, nullptr, nullptr, nullptr); galois::runtime::getSystemNetworkInterface().start(); IntPtrs pBodies = galois::graphs::Bag<int>::allocate(); galois::for_each(boost::counting_iterator<int>(0), boost::counting_iterator<int>(10), InsertBody{pBodies}); galois::for_each(pBodies, PrintInt()); galois::runtime::getSystemNetworkInterface().terminate(); return 0; }
module my_interface implicit none interface pure module subroutine f end subroutine end interface end module submodule(my_interface) my_implementation implicit none contains pure module subroutine f end subroutine end submodule print *,"Test passed." end
function [data_train, labels_train, data_devel, labels_devel, raw_devel, PC, means_norm, stds_norm, devel_ids, devel_success] = ... Prepare_HOG_AU_data_dynamic(train_users, devel_users, au_train, rest_aus, UNBC_dir, features_dir) %% addpath(genpath('../data extraction/')); % First extracting the labels [ labels_train, valid_ids_train, filenames ] = extract_UNBC_labels(UNBC_dir, train_users, au_train); [ labels_other, ~, ~ ] = extract_UNBC_labels(UNBC_dir, train_users, rest_aus); labels_other = cat(1, labels_other{:}); % Reading in the HOG data (of only relevant frames) [train_appearance_data, valid_ids_train_hog, vid_ids_train_string] = Read_HOG_files_dynamic(train_users, features_dir); [train_geom_data] = Read_geom_files_dynamic(train_users, features_dir); % Subsample the data to make training quicker labels_train = cat(1, labels_train{:}); valid_ids_train = logical(cat(1, valid_ids_train{:})); if(numel(train_users) > 0) reduced_inds = false(size(labels_train,1),1); reduced_inds(labels_train > 0) = true; % make sure the same number of positive and negative samples is taken pos_count = sum(labels_train > 0); neg_count = sum(labels_train == 0); num_other = floor(pos_count / (size(labels_other, 2))); inds_all = 1:size(labels_train,1); for i=1:size(labels_other, 2)+1 if(i > size(labels_other, 2)) % fill the rest with a proportion of neutral inds_other = inds_all(sum(labels_other,2)==0 & ~labels_train ); num_other_i = min(numel(inds_other), pos_count - sum(labels_train(reduced_inds,:)==0)); else % take a proportion of each other AU inds_other = inds_all(labels_other(:, i) & ~labels_train ); num_other_i = min(numel(inds_other), num_other); end inds_other_to_keep = inds_other(round(linspace(1, numel(inds_other), num_other_i))); reduced_inds(inds_other_to_keep) = true; end % Remove invalid ids based on CLM failing or AU not being labelled reduced_inds(~valid_ids_train) = false; reduced_inds(~valid_ids_train_hog) = false; labels_other = labels_other(reduced_inds, :); labels_train = labels_train(reduced_inds,:); train_appearance_data = train_appearance_data(reduced_inds,:); train_geom_data = train_geom_data(reduced_inds,:); vid_ids_train_string = vid_ids_train_string(reduced_inds,:); end %% Extract devel data % First extracting the labels [ labels_devel, valid_ids_devel, vid_ids_devel ] = extract_UNBC_labels(UNBC_dir, devel_users, au_train); % Reading in the HOG data (of only relevant frames) [devel_appearance_data, valid_ids_devel_hog, vid_ids_devel_string] = Read_HOG_files_dynamic(devel_users, features_dir); devel_success = valid_ids_devel_hog; devel_ids = vid_ids_devel_string; [devel_geom_data] = Read_geom_files_dynamic(devel_users, features_dir); labels_devel = cat(1, labels_devel{:}); % Peforming zone specific masking if(au_train < 8 || au_train == 43 || au_train == 45) % upper face AUs ignore bottom face % normalise the data pca_file = '../../pca_generation/generic_face_upper.mat'; load(pca_file); elseif(au_train > 9) % lower face AUs ignore upper face and the sides % normalise the data pca_file = '../../pca_generation/generic_face_lower.mat'; load(pca_file); elseif(au_train == 9) % Central face model % normalise the data pca_file = '../../pca_generation/generic_face_rigid.mat'; load(pca_file); end % Grab all data for validation as want good params for all the data raw_devel = cat(2, devel_appearance_data, devel_geom_data); devel_appearance_data = bsxfun(@times, bsxfun(@plus, devel_appearance_data, -means_norm), 1./stds_norm); data_devel = devel_appearance_data * PC; data_devel = cat(2, data_devel, devel_geom_data); if(numel(train_users) > 0) train_appearance_data = bsxfun(@times, bsxfun(@plus, train_appearance_data, -means_norm), 1./stds_norm); data_train = train_appearance_data * PC; data_train = cat(2, data_train, train_geom_data); else data_train = []; end geom_size = max(size(train_geom_data, 2), size(devel_geom_data, 2)); PC_n = zeros(size(PC)+geom_size); PC_n(1:size(PC,1), 1:size(PC,2)) = PC; PC_n(size(PC,1)+1:end, size(PC,2)+1:end) = eye(geom_size); PC = PC_n; means_norm = cat(2, means_norm, zeros(1, geom_size)); stds_norm = cat(2, stds_norm, ones(1, geom_size)); end
[STATEMENT] lemma prod_mset_primes_dvd_imp_subset: assumes "prod_mset A dvd prod_mset B" "\<And>p. p \<in># A \<Longrightarrow> prime p" "\<And>p. p \<in># B \<Longrightarrow> prime p" shows "A \<subseteq># B" [PROOF STATE] proof (prove) goal (1 subgoal): 1. A \<subseteq># B [PROOF STEP] using assms [PROOF STATE] proof (prove) using this: \<Prod>\<^sub># A dvd \<Prod>\<^sub># B ?p1 \<in># A \<Longrightarrow> prime ?p1 ?p1 \<in># B \<Longrightarrow> prime ?p1 goal (1 subgoal): 1. A \<subseteq># B [PROOF STEP] proof (induction A arbitrary: B) [PROOF STATE] proof (state) goal (2 subgoals): 1. \<And>B. \<lbrakk>\<Prod>\<^sub># {#} dvd \<Prod>\<^sub># B; \<And>p. p \<in># {#} \<Longrightarrow> prime p; \<And>p. p \<in># B \<Longrightarrow> prime p\<rbrakk> \<Longrightarrow> {#} \<subseteq># B 2. \<And>x A B. \<lbrakk>\<And>B. \<lbrakk>\<Prod>\<^sub># A dvd \<Prod>\<^sub># B; \<And>p. p \<in># A \<Longrightarrow> prime p; \<And>p. p \<in># B \<Longrightarrow> prime p\<rbrakk> \<Longrightarrow> A \<subseteq># B; \<Prod>\<^sub># (add_mset x A) dvd \<Prod>\<^sub># B; \<And>p. p \<in># add_mset x A \<Longrightarrow> prime p; \<And>p. p \<in># B \<Longrightarrow> prime p\<rbrakk> \<Longrightarrow> add_mset x A \<subseteq># B [PROOF STEP] case empty [PROOF STATE] proof (state) this: \<Prod>\<^sub># {#} dvd \<Prod>\<^sub># B ?p1 \<in># {#} \<Longrightarrow> prime ?p1 ?p1 \<in># B \<Longrightarrow> prime ?p1 goal (2 subgoals): 1. \<And>B. \<lbrakk>\<Prod>\<^sub># {#} dvd \<Prod>\<^sub># B; \<And>p. p \<in># {#} \<Longrightarrow> prime p; \<And>p. p \<in># B \<Longrightarrow> prime p\<rbrakk> \<Longrightarrow> {#} \<subseteq># B 2. \<And>x A B. \<lbrakk>\<And>B. \<lbrakk>\<Prod>\<^sub># A dvd \<Prod>\<^sub># B; \<And>p. p \<in># A \<Longrightarrow> prime p; \<And>p. p \<in># B \<Longrightarrow> prime p\<rbrakk> \<Longrightarrow> A \<subseteq># B; \<Prod>\<^sub># (add_mset x A) dvd \<Prod>\<^sub># B; \<And>p. p \<in># add_mset x A \<Longrightarrow> prime p; \<And>p. p \<in># B \<Longrightarrow> prime p\<rbrakk> \<Longrightarrow> add_mset x A \<subseteq># B [PROOF STEP] thus ?case [PROOF STATE] proof (prove) using this: \<Prod>\<^sub># {#} dvd \<Prod>\<^sub># B ?p1 \<in># {#} \<Longrightarrow> prime ?p1 ?p1 \<in># B \<Longrightarrow> prime ?p1 goal (1 subgoal): 1. {#} \<subseteq># B [PROOF STEP] by simp [PROOF STATE] proof (state) this: {#} \<subseteq># B goal (1 subgoal): 1. \<And>x A B. \<lbrakk>\<And>B. \<lbrakk>\<Prod>\<^sub># A dvd \<Prod>\<^sub># B; \<And>p. p \<in># A \<Longrightarrow> prime p; \<And>p. p \<in># B \<Longrightarrow> prime p\<rbrakk> \<Longrightarrow> A \<subseteq># B; \<Prod>\<^sub># (add_mset x A) dvd \<Prod>\<^sub># B; \<And>p. p \<in># add_mset x A \<Longrightarrow> prime p; \<And>p. p \<in># B \<Longrightarrow> prime p\<rbrakk> \<Longrightarrow> add_mset x A \<subseteq># B [PROOF STEP] next [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>x A B. \<lbrakk>\<And>B. \<lbrakk>\<Prod>\<^sub># A dvd \<Prod>\<^sub># B; \<And>p. p \<in># A \<Longrightarrow> prime p; \<And>p. p \<in># B \<Longrightarrow> prime p\<rbrakk> \<Longrightarrow> A \<subseteq># B; \<Prod>\<^sub># (add_mset x A) dvd \<Prod>\<^sub># B; \<And>p. p \<in># add_mset x A \<Longrightarrow> prime p; \<And>p. p \<in># B \<Longrightarrow> prime p\<rbrakk> \<Longrightarrow> add_mset x A \<subseteq># B [PROOF STEP] case (add p A B) [PROOF STATE] proof (state) this: \<lbrakk>\<Prod>\<^sub># A dvd \<Prod>\<^sub># ?B1; \<And>p. p \<in># A \<Longrightarrow> prime p; \<And>p. p \<in># ?B1 \<Longrightarrow> prime p\<rbrakk> \<Longrightarrow> A \<subseteq># ?B1 \<Prod>\<^sub># (add_mset p A) dvd \<Prod>\<^sub># B ?p1 \<in># add_mset p A \<Longrightarrow> prime ?p1 ?p1 \<in># B \<Longrightarrow> prime ?p1 goal (1 subgoal): 1. \<And>x A B. \<lbrakk>\<And>B. \<lbrakk>\<Prod>\<^sub># A dvd \<Prod>\<^sub># B; \<And>p. p \<in># A \<Longrightarrow> prime p; \<And>p. p \<in># B \<Longrightarrow> prime p\<rbrakk> \<Longrightarrow> A \<subseteq># B; \<Prod>\<^sub># (add_mset x A) dvd \<Prod>\<^sub># B; \<And>p. p \<in># add_mset x A \<Longrightarrow> prime p; \<And>p. p \<in># B \<Longrightarrow> prime p\<rbrakk> \<Longrightarrow> add_mset x A \<subseteq># B [PROOF STEP] hence p: "prime p" [PROOF STATE] proof (prove) using this: \<lbrakk>\<Prod>\<^sub># A dvd \<Prod>\<^sub># ?B1; \<And>p. p \<in># A \<Longrightarrow> prime p; \<And>p. p \<in># ?B1 \<Longrightarrow> prime p\<rbrakk> \<Longrightarrow> A \<subseteq># ?B1 \<Prod>\<^sub># (add_mset p A) dvd \<Prod>\<^sub># B ?p1 \<in># add_mset p A \<Longrightarrow> prime ?p1 ?p1 \<in># B \<Longrightarrow> prime ?p1 goal (1 subgoal): 1. prime p [PROOF STEP] by simp [PROOF STATE] proof (state) this: prime p goal (1 subgoal): 1. \<And>x A B. \<lbrakk>\<And>B. \<lbrakk>\<Prod>\<^sub># A dvd \<Prod>\<^sub># B; \<And>p. p \<in># A \<Longrightarrow> prime p; \<And>p. p \<in># B \<Longrightarrow> prime p\<rbrakk> \<Longrightarrow> A \<subseteq># B; \<Prod>\<^sub># (add_mset x A) dvd \<Prod>\<^sub># B; \<And>p. p \<in># add_mset x A \<Longrightarrow> prime p; \<And>p. p \<in># B \<Longrightarrow> prime p\<rbrakk> \<Longrightarrow> add_mset x A \<subseteq># B [PROOF STEP] define B' where "B' = B - {#p#}" [PROOF STATE] proof (state) this: B' = B - {#p#} goal (1 subgoal): 1. \<And>x A B. \<lbrakk>\<And>B. \<lbrakk>\<Prod>\<^sub># A dvd \<Prod>\<^sub># B; \<And>p. p \<in># A \<Longrightarrow> prime p; \<And>p. p \<in># B \<Longrightarrow> prime p\<rbrakk> \<Longrightarrow> A \<subseteq># B; \<Prod>\<^sub># (add_mset x A) dvd \<Prod>\<^sub># B; \<And>p. p \<in># add_mset x A \<Longrightarrow> prime p; \<And>p. p \<in># B \<Longrightarrow> prime p\<rbrakk> \<Longrightarrow> add_mset x A \<subseteq># B [PROOF STEP] from add.prems [PROOF STATE] proof (chain) picking this: \<Prod>\<^sub># (add_mset p A) dvd \<Prod>\<^sub># B ?p1 \<in># add_mset p A \<Longrightarrow> prime ?p1 ?p1 \<in># B \<Longrightarrow> prime ?p1 [PROOF STEP] have "p dvd prod_mset B" [PROOF STATE] proof (prove) using this: \<Prod>\<^sub># (add_mset p A) dvd \<Prod>\<^sub># B ?p1 \<in># add_mset p A \<Longrightarrow> prime ?p1 ?p1 \<in># B \<Longrightarrow> prime ?p1 goal (1 subgoal): 1. p dvd \<Prod>\<^sub># B [PROOF STEP] by (simp add: dvd_mult_left) [PROOF STATE] proof (state) this: p dvd \<Prod>\<^sub># B goal (1 subgoal): 1. \<And>x A B. \<lbrakk>\<And>B. \<lbrakk>\<Prod>\<^sub># A dvd \<Prod>\<^sub># B; \<And>p. p \<in># A \<Longrightarrow> prime p; \<And>p. p \<in># B \<Longrightarrow> prime p\<rbrakk> \<Longrightarrow> A \<subseteq># B; \<Prod>\<^sub># (add_mset x A) dvd \<Prod>\<^sub># B; \<And>p. p \<in># add_mset x A \<Longrightarrow> prime p; \<And>p. p \<in># B \<Longrightarrow> prime p\<rbrakk> \<Longrightarrow> add_mset x A \<subseteq># B [PROOF STEP] with add.prems [PROOF STATE] proof (chain) picking this: \<Prod>\<^sub># (add_mset p A) dvd \<Prod>\<^sub># B ?p1 \<in># add_mset p A \<Longrightarrow> prime ?p1 ?p1 \<in># B \<Longrightarrow> prime ?p1 p dvd \<Prod>\<^sub># B [PROOF STEP] have "p \<in># B" [PROOF STATE] proof (prove) using this: \<Prod>\<^sub># (add_mset p A) dvd \<Prod>\<^sub># B ?p1 \<in># add_mset p A \<Longrightarrow> prime ?p1 ?p1 \<in># B \<Longrightarrow> prime ?p1 p dvd \<Prod>\<^sub># B goal (1 subgoal): 1. p \<in># B [PROOF STEP] by (subst (asm) (2) prime_dvd_prod_mset_primes_iff) simp_all [PROOF STATE] proof (state) this: p \<in># B goal (1 subgoal): 1. \<And>x A B. \<lbrakk>\<And>B. \<lbrakk>\<Prod>\<^sub># A dvd \<Prod>\<^sub># B; \<And>p. p \<in># A \<Longrightarrow> prime p; \<And>p. p \<in># B \<Longrightarrow> prime p\<rbrakk> \<Longrightarrow> A \<subseteq># B; \<Prod>\<^sub># (add_mset x A) dvd \<Prod>\<^sub># B; \<And>p. p \<in># add_mset x A \<Longrightarrow> prime p; \<And>p. p \<in># B \<Longrightarrow> prime p\<rbrakk> \<Longrightarrow> add_mset x A \<subseteq># B [PROOF STEP] hence B: "B = B' + {#p#}" [PROOF STATE] proof (prove) using this: p \<in># B goal (1 subgoal): 1. B = B' + {#p#} [PROOF STEP] by (simp add: B'_def) [PROOF STATE] proof (state) this: B = B' + {#p#} goal (1 subgoal): 1. \<And>x A B. \<lbrakk>\<And>B. \<lbrakk>\<Prod>\<^sub># A dvd \<Prod>\<^sub># B; \<And>p. p \<in># A \<Longrightarrow> prime p; \<And>p. p \<in># B \<Longrightarrow> prime p\<rbrakk> \<Longrightarrow> A \<subseteq># B; \<Prod>\<^sub># (add_mset x A) dvd \<Prod>\<^sub># B; \<And>p. p \<in># add_mset x A \<Longrightarrow> prime p; \<And>p. p \<in># B \<Longrightarrow> prime p\<rbrakk> \<Longrightarrow> add_mset x A \<subseteq># B [PROOF STEP] from add.prems p [PROOF STATE] proof (chain) picking this: \<Prod>\<^sub># (add_mset p A) dvd \<Prod>\<^sub># B ?p1 \<in># add_mset p A \<Longrightarrow> prime ?p1 ?p1 \<in># B \<Longrightarrow> prime ?p1 prime p [PROOF STEP] have "A \<subseteq># B'" [PROOF STATE] proof (prove) using this: \<Prod>\<^sub># (add_mset p A) dvd \<Prod>\<^sub># B ?p1 \<in># add_mset p A \<Longrightarrow> prime ?p1 ?p1 \<in># B \<Longrightarrow> prime ?p1 prime p goal (1 subgoal): 1. A \<subseteq># B' [PROOF STEP] by (intro add.IH) (simp_all add: B) [PROOF STATE] proof (state) this: A \<subseteq># B' goal (1 subgoal): 1. \<And>x A B. \<lbrakk>\<And>B. \<lbrakk>\<Prod>\<^sub># A dvd \<Prod>\<^sub># B; \<And>p. p \<in># A \<Longrightarrow> prime p; \<And>p. p \<in># B \<Longrightarrow> prime p\<rbrakk> \<Longrightarrow> A \<subseteq># B; \<Prod>\<^sub># (add_mset x A) dvd \<Prod>\<^sub># B; \<And>p. p \<in># add_mset x A \<Longrightarrow> prime p; \<And>p. p \<in># B \<Longrightarrow> prime p\<rbrakk> \<Longrightarrow> add_mset x A \<subseteq># B [PROOF STEP] thus ?case [PROOF STATE] proof (prove) using this: A \<subseteq># B' goal (1 subgoal): 1. add_mset p A \<subseteq># B [PROOF STEP] by (simp add: B) [PROOF STATE] proof (state) this: add_mset p A \<subseteq># B goal: No subgoals! [PROOF STEP] qed
C Copyright(C) 2008-2017 National Technology & Engineering Solutions of C Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with C NTESS, the U.S. Government retains certain rights in this software. C C Redistribution and use in source and binary forms, with or without C modification, are permitted provided that the following conditions are C met: C C * Redistributions of source code must retain the above copyright C notice, this list of conditions and the following disclaimer. C C * Redistributions in binary form must reproduce the above C copyright notice, this list of conditions and the following C disclaimer in the documentation and/or other materials provided C with the distribution. C C * Neither the name of NTESS nor the names of its C contributors may be used to endorse or promote products derived C from this software without specific prior written permission. C C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS C "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT C LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR C A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT C OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, C SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT C LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, C DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY C THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT C (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE C OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. C C======================================================================= subroutine limits(ndim, numnp, cord) C======================================================================= REAL CORD(NUMNP, NDIM) call minmax(numnp, cord(1,1), xmin, xmax) call minmax(numnp, cord(1,2), ymin, ymax) if (ndim .eq. 3) then call minmax(numnp, cord(1,3), zmin, zmax) else zmin = 0 zmax = 0 end if WRITE (*, *) ' ' WRITE (*, *) 'Mesh Limits: ' WRITE (*, 10000) 'X', XMIN, 'X', XMAX, XMAX-XMIN IF (NDIM .GE. 2) THEN WRITE (*, 10000) 'Y', YMIN, 'Y', YMAX, YMAX-YMIN ENDIF IF (NDIM .EQ. 3) THEN WRITE (*, 10000) 'Z', ZMIN, 'Z', ZMAX, ZMAX-ZMIN END IF 10000 FORMAT( ' Min ',A1,' = ',1PE16.9,', Max ',A1,' = ', & 1PE16.9,', Range = ',1PE16.9) return end
module NeuralNet.Net ( NeuralNetDefinition, LayerDefinition (LayerDefinition), WeightsStream, NeuralNet, initNN, buildNNFromList, nnLayers, nnNumInputs, nnForward, nnForwardSet, isExampleSetCompatibleWithNN, isExampleSetCompatibleWithNNDef, updateNNLayers, createLogRegDefinition ) where import NeuralNet.Matrix import NeuralNet.Activation import NeuralNet.Layer import NeuralNet.Example import Numeric.LinearAlgebra type NumNeurons = Int type NumInputs = Int type NeuralNetDefinition = (NumInputs, [LayerDefinition]) type WeightsStream = [Double] data LayerDefinition = LayerDefinition Activation NumNeurons deriving (Show, Eq) data NeuralNet = NeuralNet [NeuronLayer] deriving (Show, Eq) createLogRegDefinition :: NumInputs -> Activation -> NeuralNetDefinition createLogRegDefinition n a = (n, [LayerDefinition a 1]) initNN :: WeightsStream -> NeuralNetDefinition -> NeuralNet initNN _ (_, []) = error "No layer definitions provided" initNN g (numInputs, layerDefs) | numInputs > 0 = NeuralNet (fst (initNeuronLayers g numInputs layerDefs)) | otherwise = error "Need positive num inputs" initNeuronLayers :: WeightsStream -> Int -> [LayerDefinition] -> ([NeuronLayer], WeightsStream) initNeuronLayers weightsStream _ [] = ([], weightsStream) initNeuronLayers weightsStream numInputs (LayerDefinition a numNeurons : ds) = (NeuronLayer a w b : ls, ws2) where numSeeds = numInputs * numNeurons (weights, ws) = splitAt numSeeds weightsStream w = scale (sqrt (2.0 / fromIntegral numInputs)) ((numNeurons >< numInputs) weights) -- * sqrt (2 / numInputs) should be parameterisable b = col (replicate numNeurons 0) (ls, ws2) = initNeuronLayers ws numNeurons ds buildNNFromList :: NeuralNetDefinition -> [Double] -> NeuralNet buildNNFromList def@(numInputs, layerDefs) list | listSize /= defSize = error ("Wrong list size. Expected " ++ show defSize ++ " got " ++ show listSize) | otherwise = NeuralNet (buildLayersFromList numInputs layerDefs list) where defSize = definitionToNNSize def listSize = length list -- TODO: nnToList and include back and forward of buildNNFromList to ensure works definitionToNNSize :: NeuralNetDefinition -> Int definitionToNNSize (numInputs, layerDefs) = defToSizeStep numInputs layerDefs where defToSizeStep :: Int -> [LayerDefinition] -> Int defToSizeStep _ [] = 0 defToSizeStep stepInputs (LayerDefinition _ numNeurons:ds) = (stepInputs * numNeurons) + numNeurons + defToSizeStep numNeurons ds buildLayersFromList :: Int -> [LayerDefinition] -> [Double] -> [NeuronLayer] buildLayersFromList _ [] _ = [] buildLayersFromList numInputs (LayerDefinition a numNeurons:ds) xs = layer : (buildLayersFromList numNeurons ds restXs) where numWeights = numInputs * numNeurons (layerXs, afterLayerXs) = splitAt numWeights xs (bs, restXs) = splitAt numNeurons afterLayerXs layer = NeuronLayer a ((numNeurons><numInputs) layerXs) (col bs) nnLayers :: NeuralNet -> [NeuronLayer] nnLayers (NeuralNet layers) = layers nnForward :: NeuralNet -> [Double] -> [Double] nnForward nn inputs = concat (toLists (forwardPropA (last setResult))) where set = createExampleSet [(inputs, error "Undefined")] setResult = nnForwardSet nn set nnForwardSet :: NeuralNet -> ExampleSet -> [ForwardPropStep] nnForwardSet nn examples = reverse foldResult where x = exampleSetX examples :: Matrix Double input = createInputForwardPropStep x foldResult = foldl (\i l -> layerForwardSet l (forwardPropA (head i)) : i) [input] (nnLayers nn) nnNumInputs :: NeuralNet -> Int nnNumInputs = layerNumInputs . head . nnLayers isExampleSetCompatibleWithNNDef :: ExampleSet -> NeuralNetDefinition -> Bool isExampleSetCompatibleWithNNDef examples def = isExampleSetCompatibleWithNN examples emptyNN where nums = replicate (definitionToNNSize def) 0 emptyNN = buildNNFromList def nums isExampleSetCompatibleWithNN :: ExampleSet -> NeuralNet -> Bool isExampleSetCompatibleWithNN examples nn = nnNumInputs nn == exampleSetN examples updateNNLayers :: NeuralNet -> [NeuronLayer] -> NeuralNet updateNNLayers nn newLayers | layersShapes layers /= layersShapes newLayers = error "Must provide same shaped layers" | otherwise = NeuralNet newLayers where layersShapes :: [NeuronLayer] -> [((Int, Int), (Int, Int))] layersShapes sLayers = map (\l -> (dims (layerW l), dims (layerB l))) sLayers layers = nnLayers nn
[GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι U : Set E ⊢ U ∈ basisSets p ↔ ∃ i r x, U = ball (Finset.sup i p) 0 r [PROOFSTEP] simp only [basisSets, mem_iUnion, mem_singleton_iff] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι i : ι r : ℝ hr : 0 < r ⊢ ball (p i) 0 r = ball (Finset.sup {i} p) 0 r [PROOFSTEP] rw [Finset.sup_singleton] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι ⊢ Set.Nonempty (basisSets p) [PROOFSTEP] let i := Classical.arbitrary ι [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι i : ι := Classical.arbitrary ι ⊢ Set.Nonempty (basisSets p) [PROOFSTEP] refine' nonempty_def.mpr ⟨(p i).ball 0 1, _⟩ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι i : ι := Classical.arbitrary ι ⊢ ball (p i) 0 1 ∈ basisSets p [PROOFSTEP] exact p.basisSets_singleton_mem i zero_lt_one [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι U V : Set E hU : U ∈ basisSets p hV : V ∈ basisSets p ⊢ ∃ z, z ∈ basisSets p ∧ z ⊆ U ∩ V [PROOFSTEP] classical rcases p.basisSets_iff.mp hU with ⟨s, r₁, hr₁, hU⟩ rcases p.basisSets_iff.mp hV with ⟨t, r₂, hr₂, hV⟩ use((s ∪ t).sup p).ball 0 (min r₁ r₂) refine' ⟨p.basisSets_mem (s ∪ t) (lt_min_iff.mpr ⟨hr₁, hr₂⟩), _⟩ rw [hU, hV, ball_finset_sup_eq_iInter _ _ _ (lt_min_iff.mpr ⟨hr₁, hr₂⟩), ball_finset_sup_eq_iInter _ _ _ hr₁, ball_finset_sup_eq_iInter _ _ _ hr₂] exact Set.subset_inter (Set.iInter₂_mono' fun i hi => ⟨i, Finset.subset_union_left _ _ hi, ball_mono <| min_le_left _ _⟩) (Set.iInter₂_mono' fun i hi => ⟨i, Finset.subset_union_right _ _ hi, ball_mono <| min_le_right _ _⟩) [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι U V : Set E hU : U ∈ basisSets p hV : V ∈ basisSets p ⊢ ∃ z, z ∈ basisSets p ∧ z ⊆ U ∩ V [PROOFSTEP] rcases p.basisSets_iff.mp hU with ⟨s, r₁, hr₁, hU⟩ [GOAL] case intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι U V : Set E hU✝ : U ∈ basisSets p hV : V ∈ basisSets p s : Finset ι r₁ : ℝ hr₁ : 0 < r₁ hU : U = ball (Finset.sup s p) 0 r₁ ⊢ ∃ z, z ∈ basisSets p ∧ z ⊆ U ∩ V [PROOFSTEP] rcases p.basisSets_iff.mp hV with ⟨t, r₂, hr₂, hV⟩ [GOAL] case intro.intro.intro.intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι U V : Set E hU✝ : U ∈ basisSets p hV✝ : V ∈ basisSets p s : Finset ι r₁ : ℝ hr₁ : 0 < r₁ hU : U = ball (Finset.sup s p) 0 r₁ t : Finset ι r₂ : ℝ hr₂ : 0 < r₂ hV : V = ball (Finset.sup t p) 0 r₂ ⊢ ∃ z, z ∈ basisSets p ∧ z ⊆ U ∩ V [PROOFSTEP] use((s ∪ t).sup p).ball 0 (min r₁ r₂) [GOAL] case h 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι U V : Set E hU✝ : U ∈ basisSets p hV✝ : V ∈ basisSets p s : Finset ι r₁ : ℝ hr₁ : 0 < r₁ hU : U = ball (Finset.sup s p) 0 r₁ t : Finset ι r₂ : ℝ hr₂ : 0 < r₂ hV : V = ball (Finset.sup t p) 0 r₂ ⊢ ball (Finset.sup (s ∪ t) p) 0 (min r₁ r₂) ∈ basisSets p ∧ ball (Finset.sup (s ∪ t) p) 0 (min r₁ r₂) ⊆ U ∩ V [PROOFSTEP] refine' ⟨p.basisSets_mem (s ∪ t) (lt_min_iff.mpr ⟨hr₁, hr₂⟩), _⟩ [GOAL] case h 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι U V : Set E hU✝ : U ∈ basisSets p hV✝ : V ∈ basisSets p s : Finset ι r₁ : ℝ hr₁ : 0 < r₁ hU : U = ball (Finset.sup s p) 0 r₁ t : Finset ι r₂ : ℝ hr₂ : 0 < r₂ hV : V = ball (Finset.sup t p) 0 r₂ ⊢ ball (Finset.sup (s ∪ t) p) 0 (min r₁ r₂) ⊆ U ∩ V [PROOFSTEP] rw [hU, hV, ball_finset_sup_eq_iInter _ _ _ (lt_min_iff.mpr ⟨hr₁, hr₂⟩), ball_finset_sup_eq_iInter _ _ _ hr₁, ball_finset_sup_eq_iInter _ _ _ hr₂] [GOAL] case h 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι U V : Set E hU✝ : U ∈ basisSets p hV✝ : V ∈ basisSets p s : Finset ι r₁ : ℝ hr₁ : 0 < r₁ hU : U = ball (Finset.sup s p) 0 r₁ t : Finset ι r₂ : ℝ hr₂ : 0 < r₂ hV : V = ball (Finset.sup t p) 0 r₂ ⊢ ⋂ (i : ι) (_ : i ∈ s ∪ t), ball (p i) 0 (min r₁ r₂) ⊆ (⋂ (i : ι) (_ : i ∈ s), ball (p i) 0 r₁) ∩ ⋂ (i : ι) (_ : i ∈ t), ball (p i) 0 r₂ [PROOFSTEP] exact Set.subset_inter (Set.iInter₂_mono' fun i hi => ⟨i, Finset.subset_union_left _ _ hi, ball_mono <| min_le_left _ _⟩) (Set.iInter₂_mono' fun i hi => ⟨i, Finset.subset_union_right _ _ hi, ball_mono <| min_le_right _ _⟩) [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι U : Set E hU : U ∈ basisSets p ⊢ 0 ∈ U [PROOFSTEP] rcases p.basisSets_iff.mp hU with ⟨ι', r, hr, hU⟩ [GOAL] case intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι'✝ : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι U : Set E hU✝ : U ∈ basisSets p ι' : Finset ι r : ℝ hr : 0 < r hU : U = ball (Finset.sup ι' p) 0 r ⊢ 0 ∈ U [PROOFSTEP] rw [hU, mem_ball_zero, map_zero] [GOAL] case intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι'✝ : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι U : Set E hU✝ : U ∈ basisSets p ι' : Finset ι r : ℝ hr : 0 < r hU : U = ball (Finset.sup ι' p) 0 r ⊢ 0 < r [PROOFSTEP] exact hr [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι U : Set E hU : U ∈ basisSets p ⊢ ∃ V, V ∈ basisSets p ∧ V + V ⊆ U [PROOFSTEP] rcases p.basisSets_iff.mp hU with ⟨s, r, hr, hU⟩ [GOAL] case intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι U : Set E hU✝ : U ∈ basisSets p s : Finset ι r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r ⊢ ∃ V, V ∈ basisSets p ∧ V + V ⊆ U [PROOFSTEP] use(s.sup p).ball 0 (r / 2) [GOAL] case h 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι U : Set E hU✝ : U ∈ basisSets p s : Finset ι r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r ⊢ ball (Finset.sup s p) 0 (r / 2) ∈ basisSets p ∧ ball (Finset.sup s p) 0 (r / 2) + ball (Finset.sup s p) 0 (r / 2) ⊆ U [PROOFSTEP] refine' ⟨p.basisSets_mem s (div_pos hr zero_lt_two), _⟩ [GOAL] case h 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι U : Set E hU✝ : U ∈ basisSets p s : Finset ι r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r ⊢ ball (Finset.sup s p) 0 (r / 2) + ball (Finset.sup s p) 0 (r / 2) ⊆ U [PROOFSTEP] refine' Set.Subset.trans (ball_add_ball_subset (s.sup p) (r / 2) (r / 2) 0 0) _ [GOAL] case h 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι U : Set E hU✝ : U ∈ basisSets p s : Finset ι r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r ⊢ ball (Finset.sup s p) (0 + 0) (r / 2 + r / 2) ⊆ U [PROOFSTEP] rw [hU, add_zero, add_halves'] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι U : Set E hU' : U ∈ basisSets p ⊢ ∃ V, V ∈ basisSets p ∧ V ⊆ (fun x => -x) ⁻¹' U [PROOFSTEP] rcases p.basisSets_iff.mp hU' with ⟨s, r, _, hU⟩ [GOAL] case intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι U : Set E hU' : U ∈ basisSets p s : Finset ι r : ℝ w✝ : 0 < r hU : U = ball (Finset.sup s p) 0 r ⊢ ∃ V, V ∈ basisSets p ∧ V ⊆ (fun x => -x) ⁻¹' U [PROOFSTEP] rw [hU, neg_preimage, neg_ball (s.sup p), neg_zero] [GOAL] case intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι U : Set E hU' : U ∈ basisSets p s : Finset ι r : ℝ w✝ : 0 < r hU : U = ball (Finset.sup s p) 0 r ⊢ ∃ V, V ∈ basisSets p ∧ V ⊆ ball (Finset.sup s p) 0 r [PROOFSTEP] exact ⟨U, hU', Eq.subset hU⟩ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι v : E U : Set E hU : U ∈ basisSets p ⊢ ∀ᶠ (x : 𝕜) in 𝓝 0, x • v ∈ U [PROOFSTEP] rcases p.basisSets_iff.mp hU with ⟨s, r, hr, hU⟩ [GOAL] case intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι v : E U : Set E hU✝ : U ∈ basisSets p s : Finset ι r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r ⊢ ∀ᶠ (x : 𝕜) in 𝓝 0, x • v ∈ U [PROOFSTEP] rw [hU, Filter.eventually_iff] [GOAL] case intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι v : E U : Set E hU✝ : U ∈ basisSets p s : Finset ι r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r ⊢ {x | x • v ∈ ball (Finset.sup s p) 0 r} ∈ 𝓝 0 [PROOFSTEP] simp_rw [(s.sup p).mem_ball_zero, map_smul_eq_mul] [GOAL] case intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι v : E U : Set E hU✝ : U ∈ basisSets p s : Finset ι r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r ⊢ {x | ‖x‖ * ↑(Finset.sup s p) v < r} ∈ 𝓝 0 [PROOFSTEP] by_cases h : 0 < (s.sup p) v [GOAL] case pos 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι v : E U : Set E hU✝ : U ∈ basisSets p s : Finset ι r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r h : 0 < ↑(Finset.sup s p) v ⊢ {x | ‖x‖ * ↑(Finset.sup s p) v < r} ∈ 𝓝 0 [PROOFSTEP] simp_rw [(lt_div_iff h).symm] [GOAL] case pos 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι v : E U : Set E hU✝ : U ∈ basisSets p s : Finset ι r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r h : 0 < ↑(Finset.sup s p) v ⊢ {x | ‖x‖ < r / ↑(Finset.sup s p) v} ∈ 𝓝 0 [PROOFSTEP] rw [← _root_.ball_zero_eq] [GOAL] case pos 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι v : E U : Set E hU✝ : U ∈ basisSets p s : Finset ι r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r h : 0 < ↑(Finset.sup s p) v ⊢ Metric.ball 0 (r / ↑(Finset.sup s p) v) ∈ 𝓝 0 [PROOFSTEP] exact Metric.ball_mem_nhds 0 (div_pos hr h) [GOAL] case neg 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι v : E U : Set E hU✝ : U ∈ basisSets p s : Finset ι r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r h : ¬0 < ↑(Finset.sup s p) v ⊢ {x | ‖x‖ * ↑(Finset.sup s p) v < r} ∈ 𝓝 0 [PROOFSTEP] simp_rw [le_antisymm (not_lt.mp h) (map_nonneg _ v), mul_zero, hr] [GOAL] case neg 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝² : NormedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E p : SeminormFamily 𝕜 E ι v : E U : Set E hU✝ : U ∈ basisSets p s : Finset ι r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r h : ¬0 < ↑(Finset.sup s p) v ⊢ {x | True} ∈ 𝓝 0 [PROOFSTEP] exact IsOpen.mem_nhds isOpen_univ (mem_univ 0) [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι U : Set E hU : U ∈ basisSets p ⊢ ∃ V, V ∈ 𝓝 0 ∧ ∃ W, W ∈ AddGroupFilterBasis.toFilterBasis.sets ∧ V • W ⊆ U [PROOFSTEP] rcases p.basisSets_iff.mp hU with ⟨s, r, hr, hU⟩ [GOAL] case intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι U : Set E hU✝ : U ∈ basisSets p s : Finset ι r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r ⊢ ∃ V, V ∈ 𝓝 0 ∧ ∃ W, W ∈ AddGroupFilterBasis.toFilterBasis.sets ∧ V • W ⊆ U [PROOFSTEP] refine' ⟨Metric.ball 0 r.sqrt, Metric.ball_mem_nhds 0 (Real.sqrt_pos.mpr hr), _⟩ [GOAL] case intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι U : Set E hU✝ : U ∈ basisSets p s : Finset ι r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r ⊢ ∃ W, W ∈ AddGroupFilterBasis.toFilterBasis.sets ∧ Metric.ball 0 (Real.sqrt r) • W ⊆ U [PROOFSTEP] refine' ⟨(s.sup p).ball 0 r.sqrt, p.basisSets_mem s (Real.sqrt_pos.mpr hr), _⟩ [GOAL] case intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι U : Set E hU✝ : U ∈ basisSets p s : Finset ι r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r ⊢ Metric.ball 0 (Real.sqrt r) • ball (Finset.sup s p) 0 (Real.sqrt r) ⊆ U [PROOFSTEP] refine' Set.Subset.trans (ball_smul_ball (s.sup p) r.sqrt r.sqrt) _ [GOAL] case intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι U : Set E hU✝ : U ∈ basisSets p s : Finset ι r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r ⊢ ball (Finset.sup s p) 0 (Real.sqrt r * Real.sqrt r) ⊆ U [PROOFSTEP] rw [hU, Real.mul_self_sqrt (le_of_lt hr)] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι x : 𝕜 U : Set E hU : U ∈ basisSets p ⊢ ∃ V, V ∈ AddGroupFilterBasis.toFilterBasis.sets ∧ V ⊆ (fun y => x • y) ⁻¹' U [PROOFSTEP] rcases p.basisSets_iff.mp hU with ⟨s, r, hr, hU⟩ [GOAL] case intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι x : 𝕜 U : Set E hU✝ : U ∈ basisSets p s : Finset ι r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r ⊢ ∃ V, V ∈ AddGroupFilterBasis.toFilterBasis.sets ∧ V ⊆ (fun y => x • y) ⁻¹' U [PROOFSTEP] rw [hU] [GOAL] case intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι x : 𝕜 U : Set E hU✝ : U ∈ basisSets p s : Finset ι r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r ⊢ ∃ V, V ∈ AddGroupFilterBasis.toFilterBasis.sets ∧ V ⊆ (fun y => x • y) ⁻¹' ball (Finset.sup s p) 0 r [PROOFSTEP] by_cases h : x ≠ 0 [GOAL] case pos 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι x : 𝕜 U : Set E hU✝ : U ∈ basisSets p s : Finset ι r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r h : x ≠ 0 ⊢ ∃ V, V ∈ AddGroupFilterBasis.toFilterBasis.sets ∧ V ⊆ (fun y => x • y) ⁻¹' ball (Finset.sup s p) 0 r [PROOFSTEP] rw [(s.sup p).smul_ball_preimage 0 r x h, smul_zero] [GOAL] case pos 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι x : 𝕜 U : Set E hU✝ : U ∈ basisSets p s : Finset ι r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r h : x ≠ 0 ⊢ ∃ V, V ∈ AddGroupFilterBasis.toFilterBasis.sets ∧ V ⊆ ball (Finset.sup s p) 0 (r / ‖x‖) [PROOFSTEP] use(s.sup p).ball 0 (r / ‖x‖) [GOAL] case h 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι x : 𝕜 U : Set E hU✝ : U ∈ basisSets p s : Finset ι r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r h : x ≠ 0 ⊢ ball (Finset.sup s p) 0 (r / ‖x‖) ∈ AddGroupFilterBasis.toFilterBasis.sets ∧ ball (Finset.sup s p) 0 (r / ‖x‖) ⊆ ball (Finset.sup s p) 0 (r / ‖x‖) [PROOFSTEP] exact ⟨p.basisSets_mem s (div_pos hr (norm_pos_iff.mpr h)), Subset.rfl⟩ [GOAL] case neg 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι x : 𝕜 U : Set E hU✝ : U ∈ basisSets p s : Finset ι r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r h : ¬x ≠ 0 ⊢ ∃ V, V ∈ AddGroupFilterBasis.toFilterBasis.sets ∧ V ⊆ (fun y => x • y) ⁻¹' ball (Finset.sup s p) 0 r [PROOFSTEP] refine' ⟨(s.sup p).ball 0 r, p.basisSets_mem s hr, _⟩ [GOAL] case neg 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι x : 𝕜 U : Set E hU✝ : U ∈ basisSets p s : Finset ι r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r h : ¬x ≠ 0 ⊢ ball (Finset.sup s p) 0 r ⊆ (fun y => x • y) ⁻¹' ball (Finset.sup s p) 0 r [PROOFSTEP] simp only [not_ne_iff.mp h, Set.subset_def, mem_ball_zero, hr, mem_univ, map_zero, imp_true_iff, preimage_const_of_mem, zero_smul] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p✝ : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι p : SeminormFamily 𝕜 E ι ⊢ FilterBasis.filter AddGroupFilterBasis.toFilterBasis = ⨅ (i : ι), comap (↑(p i)) (𝓝 0) [PROOFSTEP] refine' le_antisymm (le_iInf fun i => _) _ [GOAL] case refine'_1 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p✝ : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι p : SeminormFamily 𝕜 E ι i : ι ⊢ FilterBasis.filter AddGroupFilterBasis.toFilterBasis ≤ comap (↑(p i)) (𝓝 0) [PROOFSTEP] rw [p.moduleFilterBasis.toFilterBasis.hasBasis.le_basis_iff (Metric.nhds_basis_ball.comap _)] [GOAL] case refine'_1 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p✝ : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι p : SeminormFamily 𝕜 E ι i : ι ⊢ ∀ (i' : ℝ), 0 < i' → ∃ i_1, i_1 ∈ AddGroupFilterBasis.toFilterBasis ∧ id i_1 ⊆ ↑(p i) ⁻¹' Metric.ball 0 i' [PROOFSTEP] intro ε hε [GOAL] case refine'_1 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p✝ : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι p : SeminormFamily 𝕜 E ι i : ι ε : ℝ hε : 0 < ε ⊢ ∃ i_1, i_1 ∈ AddGroupFilterBasis.toFilterBasis ∧ id i_1 ⊆ ↑(p i) ⁻¹' Metric.ball 0 ε [PROOFSTEP] refine' ⟨(p i).ball 0 ε, _, _⟩ [GOAL] case refine'_1.refine'_1 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p✝ : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι p : SeminormFamily 𝕜 E ι i : ι ε : ℝ hε : 0 < ε ⊢ ball (p i) 0 ε ∈ AddGroupFilterBasis.toFilterBasis [PROOFSTEP] rw [← (Finset.sup_singleton : _ = p i)] [GOAL] case refine'_1.refine'_1 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p✝ : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι p : SeminormFamily 𝕜 E ι i : ι ε : ℝ hε : 0 < ε ⊢ ball (Finset.sup {i} p) 0 ε ∈ AddGroupFilterBasis.toFilterBasis [PROOFSTEP] exact p.basisSets_mem { i } hε [GOAL] case refine'_1.refine'_2 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p✝ : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι p : SeminormFamily 𝕜 E ι i : ι ε : ℝ hε : 0 < ε ⊢ id (ball (p i) 0 ε) ⊆ ↑(p i) ⁻¹' Metric.ball 0 ε [PROOFSTEP] rw [id, (p i).ball_zero_eq_preimage_ball] [GOAL] case refine'_2 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p✝ : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι p : SeminormFamily 𝕜 E ι ⊢ ⨅ (i : ι), comap (↑(p i)) (𝓝 0) ≤ FilterBasis.filter AddGroupFilterBasis.toFilterBasis [PROOFSTEP] rw [p.moduleFilterBasis.toFilterBasis.hasBasis.ge_iff] [GOAL] case refine'_2 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p✝ : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι p : SeminormFamily 𝕜 E ι ⊢ ∀ (i' : Set E), i' ∈ AddGroupFilterBasis.toFilterBasis → id i' ∈ ⨅ (i : ι), comap (↑(p i)) (𝓝 0) [PROOFSTEP] rintro U (hU : U ∈ p.basisSets) [GOAL] case refine'_2 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p✝ : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι p : SeminormFamily 𝕜 E ι U : Set E hU : U ∈ basisSets p ⊢ id U ∈ ⨅ (i : ι), comap (↑(p i)) (𝓝 0) [PROOFSTEP] rcases p.basisSets_iff.mp hU with ⟨s, r, hr, rfl⟩ [GOAL] case refine'_2.intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p✝ : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι p : SeminormFamily 𝕜 E ι s : Finset ι r : ℝ hr : 0 < r hU : ball (Finset.sup s p) 0 r ∈ basisSets p ⊢ id (ball (Finset.sup s p) 0 r) ∈ ⨅ (i : ι), comap (↑(p i)) (𝓝 0) [PROOFSTEP] rw [id, Seminorm.ball_finset_sup_eq_iInter _ _ _ hr, s.iInter_mem_sets] [GOAL] case refine'_2.intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E p✝ : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι p : SeminormFamily 𝕜 E ι s : Finset ι r : ℝ hr : 0 < r hU : ball (Finset.sup s p) 0 r ∈ basisSets p ⊢ ∀ (i : ι), i ∈ s → ball (p i) 0 r ∈ ⨅ (i : ι), comap (↑(p i)) (𝓝 0) [PROOFSTEP] exact fun i _ => Filter.mem_iInf_of_mem i ⟨Metric.ball 0 r, Metric.ball_mem_nhds 0 hr, Eq.subset (p i).ball_zero_eq_preimage_ball.symm⟩ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι'✝ : Type u_9 inst✝⁷ : NormedField 𝕜 inst✝⁶ : AddCommGroup E inst✝⁵ : Module 𝕜 E inst✝⁴ : NormedField 𝕜₂ inst✝³ : AddCommGroup F inst✝² : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝¹ : RingHomIsometric σ₁₂ ι' : Type u_10 inst✝ : Nonempty ι' p : ι → Seminorm 𝕜 E q : Seminorm 𝕜₂ F f : E →ₛₗ[σ₁₂] F ⊢ IsBounded p (fun x => q) f ↔ ∃ s C, comp q f ≤ C • Finset.sup s p [PROOFSTEP] simp only [IsBounded, forall_const] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι✝ : Type u_8 ι' : Type u_9 inst✝⁷ : NormedField 𝕜 inst✝⁶ : AddCommGroup E inst✝⁵ : Module 𝕜 E inst✝⁴ : NormedField 𝕜₂ inst✝³ : AddCommGroup F inst✝² : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝¹ : RingHomIsometric σ₁₂ ι : Type u_10 inst✝ : Nonempty ι p : Seminorm 𝕜 E q : ι' → Seminorm 𝕜₂ F f : E →ₛₗ[σ₁₂] F ⊢ IsBounded (fun x => p) q f ↔ ∀ (i : ι'), ∃ C, comp (q i) f ≤ C • p [PROOFSTEP] constructor [GOAL] case mp 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι✝ : Type u_8 ι' : Type u_9 inst✝⁷ : NormedField 𝕜 inst✝⁶ : AddCommGroup E inst✝⁵ : Module 𝕜 E inst✝⁴ : NormedField 𝕜₂ inst✝³ : AddCommGroup F inst✝² : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝¹ : RingHomIsometric σ₁₂ ι : Type u_10 inst✝ : Nonempty ι p : Seminorm 𝕜 E q : ι' → Seminorm 𝕜₂ F f : E →ₛₗ[σ₁₂] F ⊢ IsBounded (fun x => p) q f → ∀ (i : ι'), ∃ C, comp (q i) f ≤ C • p [PROOFSTEP] intro h i [GOAL] case mpr 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι✝ : Type u_8 ι' : Type u_9 inst✝⁷ : NormedField 𝕜 inst✝⁶ : AddCommGroup E inst✝⁵ : Module 𝕜 E inst✝⁴ : NormedField 𝕜₂ inst✝³ : AddCommGroup F inst✝² : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝¹ : RingHomIsometric σ₁₂ ι : Type u_10 inst✝ : Nonempty ι p : Seminorm 𝕜 E q : ι' → Seminorm 𝕜₂ F f : E →ₛₗ[σ₁₂] F ⊢ (∀ (i : ι'), ∃ C, comp (q i) f ≤ C • p) → IsBounded (fun x => p) q f [PROOFSTEP] intro h i [GOAL] case mp 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι✝ : Type u_8 ι' : Type u_9 inst✝⁷ : NormedField 𝕜 inst✝⁶ : AddCommGroup E inst✝⁵ : Module 𝕜 E inst✝⁴ : NormedField 𝕜₂ inst✝³ : AddCommGroup F inst✝² : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝¹ : RingHomIsometric σ₁₂ ι : Type u_10 inst✝ : Nonempty ι p : Seminorm 𝕜 E q : ι' → Seminorm 𝕜₂ F f : E →ₛₗ[σ₁₂] F h : IsBounded (fun x => p) q f i : ι' ⊢ ∃ C, comp (q i) f ≤ C • p [PROOFSTEP] rcases h i with ⟨s, C, h⟩ [GOAL] case mp.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι✝ : Type u_8 ι' : Type u_9 inst✝⁷ : NormedField 𝕜 inst✝⁶ : AddCommGroup E inst✝⁵ : Module 𝕜 E inst✝⁴ : NormedField 𝕜₂ inst✝³ : AddCommGroup F inst✝² : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝¹ : RingHomIsometric σ₁₂ ι : Type u_10 inst✝ : Nonempty ι p : Seminorm 𝕜 E q : ι' → Seminorm 𝕜₂ F f : E →ₛₗ[σ₁₂] F h✝ : IsBounded (fun x => p) q f i : ι' s : Finset ι C : ℝ≥0 h : comp (q i) f ≤ C • Finset.sup s fun x => p ⊢ ∃ C, comp (q i) f ≤ C • p [PROOFSTEP] exact ⟨C, le_trans h (smul_le_smul (Finset.sup_le fun _ _ => le_rfl) le_rfl)⟩ [GOAL] case mpr 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι✝ : Type u_8 ι' : Type u_9 inst✝⁷ : NormedField 𝕜 inst✝⁶ : AddCommGroup E inst✝⁵ : Module 𝕜 E inst✝⁴ : NormedField 𝕜₂ inst✝³ : AddCommGroup F inst✝² : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝¹ : RingHomIsometric σ₁₂ ι : Type u_10 inst✝ : Nonempty ι p : Seminorm 𝕜 E q : ι' → Seminorm 𝕜₂ F f : E →ₛₗ[σ₁₂] F h : ∀ (i : ι'), ∃ C, comp (q i) f ≤ C • p i : ι' ⊢ ∃ s C, comp (q i) f ≤ C • Finset.sup s fun x => p [PROOFSTEP] use{Classical.arbitrary ι} [GOAL] case h 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι✝ : Type u_8 ι' : Type u_9 inst✝⁷ : NormedField 𝕜 inst✝⁶ : AddCommGroup E inst✝⁵ : Module 𝕜 E inst✝⁴ : NormedField 𝕜₂ inst✝³ : AddCommGroup F inst✝² : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝¹ : RingHomIsometric σ₁₂ ι : Type u_10 inst✝ : Nonempty ι p : Seminorm 𝕜 E q : ι' → Seminorm 𝕜₂ F f : E →ₛₗ[σ₁₂] F h : ∀ (i : ι'), ∃ C, comp (q i) f ≤ C • p i : ι' ⊢ ∃ C, comp (q i) f ≤ C • Finset.sup {Classical.arbitrary ι} fun x => p [PROOFSTEP] simp only [h, Finset.sup_singleton] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : ι → Seminorm 𝕜 E q : ι' → Seminorm 𝕜₂ F f : E →ₛₗ[σ₁₂] F hf : IsBounded p q f s' : Finset ι' ⊢ ∃ C s, comp (Finset.sup s' q) f ≤ C • Finset.sup s p [PROOFSTEP] classical obtain rfl | _ := s'.eq_empty_or_nonempty · exact ⟨1, ∅, by simp [Seminorm.bot_eq_zero]⟩ choose fₛ fC hf using hf use s'.card • s'.sup fC, Finset.biUnion s' fₛ have hs : ∀ i : ι', i ∈ s' → (q i).comp f ≤ s'.sup fC • (Finset.biUnion s' fₛ).sup p := by intro i hi refine' (hf i).trans (smul_le_smul _ (Finset.le_sup hi)) exact Finset.sup_mono (Finset.subset_biUnion_of_mem fₛ hi) refine' (comp_mono f (finset_sup_le_sum q s')).trans _ simp_rw [← pullback_apply, map_sum, pullback_apply] refine' (Finset.sum_le_sum hs).trans _ rw [Finset.sum_const, smul_assoc] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : ι → Seminorm 𝕜 E q : ι' → Seminorm 𝕜₂ F f : E →ₛₗ[σ₁₂] F hf : IsBounded p q f s' : Finset ι' ⊢ ∃ C s, comp (Finset.sup s' q) f ≤ C • Finset.sup s p [PROOFSTEP] obtain rfl | _ := s'.eq_empty_or_nonempty [GOAL] case inl 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : ι → Seminorm 𝕜 E q : ι' → Seminorm 𝕜₂ F f : E →ₛₗ[σ₁₂] F hf : IsBounded p q f ⊢ ∃ C s, comp (Finset.sup ∅ q) f ≤ C • Finset.sup s p [PROOFSTEP] exact ⟨1, ∅, by simp [Seminorm.bot_eq_zero]⟩ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : ι → Seminorm 𝕜 E q : ι' → Seminorm 𝕜₂ F f : E →ₛₗ[σ₁₂] F hf : IsBounded p q f ⊢ comp (Finset.sup ∅ q) f ≤ 1 • Finset.sup ∅ p [PROOFSTEP] simp [Seminorm.bot_eq_zero] [GOAL] case inr 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : ι → Seminorm 𝕜 E q : ι' → Seminorm 𝕜₂ F f : E →ₛₗ[σ₁₂] F hf : IsBounded p q f s' : Finset ι' h✝ : Finset.Nonempty s' ⊢ ∃ C s, comp (Finset.sup s' q) f ≤ C • Finset.sup s p [PROOFSTEP] choose fₛ fC hf using hf [GOAL] case inr 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : ι → Seminorm 𝕜 E q : ι' → Seminorm 𝕜₂ F f : E →ₛₗ[σ₁₂] F s' : Finset ι' h✝ : Finset.Nonempty s' fₛ : ι' → Finset ι fC : ι' → ℝ≥0 hf : ∀ (i : ι'), comp (q i) f ≤ fC i • Finset.sup (fₛ i) p ⊢ ∃ C s, comp (Finset.sup s' q) f ≤ C • Finset.sup s p [PROOFSTEP] use s'.card • s'.sup fC, Finset.biUnion s' fₛ [GOAL] case h 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : ι → Seminorm 𝕜 E q : ι' → Seminorm 𝕜₂ F f : E →ₛₗ[σ₁₂] F s' : Finset ι' h✝ : Finset.Nonempty s' fₛ : ι' → Finset ι fC : ι' → ℝ≥0 hf : ∀ (i : ι'), comp (q i) f ≤ fC i • Finset.sup (fₛ i) p ⊢ comp (Finset.sup s' q) f ≤ (Finset.card s' • Finset.sup s' fC) • Finset.sup (Finset.biUnion s' fₛ) p [PROOFSTEP] have hs : ∀ i : ι', i ∈ s' → (q i).comp f ≤ s'.sup fC • (Finset.biUnion s' fₛ).sup p := by intro i hi refine' (hf i).trans (smul_le_smul _ (Finset.le_sup hi)) exact Finset.sup_mono (Finset.subset_biUnion_of_mem fₛ hi) [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : ι → Seminorm 𝕜 E q : ι' → Seminorm 𝕜₂ F f : E →ₛₗ[σ₁₂] F s' : Finset ι' h✝ : Finset.Nonempty s' fₛ : ι' → Finset ι fC : ι' → ℝ≥0 hf : ∀ (i : ι'), comp (q i) f ≤ fC i • Finset.sup (fₛ i) p ⊢ ∀ (i : ι'), i ∈ s' → comp (q i) f ≤ Finset.sup s' fC • Finset.sup (Finset.biUnion s' fₛ) p [PROOFSTEP] intro i hi [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : ι → Seminorm 𝕜 E q : ι' → Seminorm 𝕜₂ F f : E →ₛₗ[σ₁₂] F s' : Finset ι' h✝ : Finset.Nonempty s' fₛ : ι' → Finset ι fC : ι' → ℝ≥0 hf : ∀ (i : ι'), comp (q i) f ≤ fC i • Finset.sup (fₛ i) p i : ι' hi : i ∈ s' ⊢ comp (q i) f ≤ Finset.sup s' fC • Finset.sup (Finset.biUnion s' fₛ) p [PROOFSTEP] refine' (hf i).trans (smul_le_smul _ (Finset.le_sup hi)) [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : ι → Seminorm 𝕜 E q : ι' → Seminorm 𝕜₂ F f : E →ₛₗ[σ₁₂] F s' : Finset ι' h✝ : Finset.Nonempty s' fₛ : ι' → Finset ι fC : ι' → ℝ≥0 hf : ∀ (i : ι'), comp (q i) f ≤ fC i • Finset.sup (fₛ i) p i : ι' hi : i ∈ s' ⊢ Finset.sup (fₛ i) p ≤ Finset.sup (Finset.biUnion s' fₛ) p [PROOFSTEP] exact Finset.sup_mono (Finset.subset_biUnion_of_mem fₛ hi) [GOAL] case h 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : ι → Seminorm 𝕜 E q : ι' → Seminorm 𝕜₂ F f : E →ₛₗ[σ₁₂] F s' : Finset ι' h✝ : Finset.Nonempty s' fₛ : ι' → Finset ι fC : ι' → ℝ≥0 hf : ∀ (i : ι'), comp (q i) f ≤ fC i • Finset.sup (fₛ i) p hs : ∀ (i : ι'), i ∈ s' → comp (q i) f ≤ Finset.sup s' fC • Finset.sup (Finset.biUnion s' fₛ) p ⊢ comp (Finset.sup s' q) f ≤ (Finset.card s' • Finset.sup s' fC) • Finset.sup (Finset.biUnion s' fₛ) p [PROOFSTEP] refine' (comp_mono f (finset_sup_le_sum q s')).trans _ [GOAL] case h 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : ι → Seminorm 𝕜 E q : ι' → Seminorm 𝕜₂ F f : E →ₛₗ[σ₁₂] F s' : Finset ι' h✝ : Finset.Nonempty s' fₛ : ι' → Finset ι fC : ι' → ℝ≥0 hf : ∀ (i : ι'), comp (q i) f ≤ fC i • Finset.sup (fₛ i) p hs : ∀ (i : ι'), i ∈ s' → comp (q i) f ≤ Finset.sup s' fC • Finset.sup (Finset.biUnion s' fₛ) p ⊢ comp (∑ i in s', q i) f ≤ (Finset.card s' • Finset.sup s' fC) • Finset.sup (Finset.biUnion s' fₛ) p [PROOFSTEP] simp_rw [← pullback_apply, map_sum, pullback_apply] [GOAL] case h 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : ι → Seminorm 𝕜 E q : ι' → Seminorm 𝕜₂ F f : E →ₛₗ[σ₁₂] F s' : Finset ι' h✝ : Finset.Nonempty s' fₛ : ι' → Finset ι fC : ι' → ℝ≥0 hf : ∀ (i : ι'), comp (q i) f ≤ fC i • Finset.sup (fₛ i) p hs : ∀ (i : ι'), i ∈ s' → comp (q i) f ≤ Finset.sup s' fC • Finset.sup (Finset.biUnion s' fₛ) p ⊢ ∑ x in s', comp (q x) f ≤ (Finset.card s' • Finset.sup s' fC) • Finset.sup (Finset.biUnion s' fₛ) p [PROOFSTEP] refine' (Finset.sum_le_sum hs).trans _ [GOAL] case h 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : ι → Seminorm 𝕜 E q : ι' → Seminorm 𝕜₂ F f : E →ₛₗ[σ₁₂] F s' : Finset ι' h✝ : Finset.Nonempty s' fₛ : ι' → Finset ι fC : ι' → ℝ≥0 hf : ∀ (i : ι'), comp (q i) f ≤ fC i • Finset.sup (fₛ i) p hs : ∀ (i : ι'), i ∈ s' → comp (q i) f ≤ Finset.sup s' fC • Finset.sup (Finset.biUnion s' fₛ) p ⊢ ∑ i in s', Finset.sup s' fC • Finset.sup (Finset.biUnion s' fₛ) p ≤ (Finset.card s' • Finset.sup s' fC) • Finset.sup (Finset.biUnion s' fₛ) p [PROOFSTEP] rw [Finset.sum_const, smul_assoc] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p ⊢ TopologicalAddGroup E [PROOFSTEP] rw [hp.withSeminorms_eq] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p ⊢ TopologicalAddGroup E [PROOFSTEP] exact AddGroupFilterBasis.isTopologicalAddGroup _ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p ⊢ ContinuousSMul 𝕜 E [PROOFSTEP] rw [hp.withSeminorms_eq] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p ⊢ ContinuousSMul 𝕜 E [PROOFSTEP] exact ModuleFilterBasis.continuousSMul _ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p ⊢ HasBasis (𝓝 0) (fun s => s ∈ SeminormFamily.basisSets p) id [PROOFSTEP] rw [congr_fun (congr_arg (@nhds E) hp.1) 0] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p ⊢ HasBasis (𝓝 0) (fun s => s ∈ SeminormFamily.basisSets p) id [PROOFSTEP] exact AddGroupFilterBasis.nhds_zero_hasBasis _ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p ⊢ HasBasis (𝓝 0) (fun sr => 0 < sr.snd) fun sr => ball (Finset.sup sr.fst p) 0 sr.snd [PROOFSTEP] refine' ⟨fun V => _⟩ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p V : Set E ⊢ V ∈ 𝓝 0 ↔ ∃ i, 0 < i.snd ∧ ball (Finset.sup i.fst p) 0 i.snd ⊆ V [PROOFSTEP] simp only [hp.hasBasis.mem_iff, SeminormFamily.basisSets_iff, Prod.exists] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p V : Set E ⊢ (∃ i, (∃ i_1 r x, i = ball (Finset.sup i_1 p) 0 r) ∧ id i ⊆ V) ↔ ∃ a b, 0 < b ∧ ball (Finset.sup a p) 0 b ⊆ V [PROOFSTEP] constructor [GOAL] case mp 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p V : Set E ⊢ (∃ i, (∃ i_1 r x, i = ball (Finset.sup i_1 p) 0 r) ∧ id i ⊆ V) → ∃ a b, 0 < b ∧ ball (Finset.sup a p) 0 b ⊆ V [PROOFSTEP] rintro ⟨-, ⟨s, r, hr, rfl⟩, hV⟩ [GOAL] case mp.intro.intro.intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p V : Set E s : Finset ι r : ℝ hr : 0 < r hV : id (ball (Finset.sup s p) 0 r) ⊆ V ⊢ ∃ a b, 0 < b ∧ ball (Finset.sup a p) 0 b ⊆ V [PROOFSTEP] exact ⟨s, r, hr, hV⟩ [GOAL] case mpr 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p V : Set E ⊢ (∃ a b, 0 < b ∧ ball (Finset.sup a p) 0 b ⊆ V) → ∃ i, (∃ i_1 r x, i = ball (Finset.sup i_1 p) 0 r) ∧ id i ⊆ V [PROOFSTEP] rintro ⟨s, r, hr, hV⟩ [GOAL] case mpr.intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p V : Set E s : Finset ι r : ℝ hr : 0 < r hV : ball (Finset.sup s p) 0 r ⊆ V ⊢ ∃ i, (∃ i_1 r x, i = ball (Finset.sup i_1 p) 0 r) ∧ id i ⊆ V [PROOFSTEP] exact ⟨_, ⟨s, r, hr, rfl⟩, hV⟩ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p x : E ⊢ HasBasis (𝓝 x) (fun sr => 0 < sr.snd) fun sr => ball (Finset.sup sr.fst p) x sr.snd [PROOFSTEP] have : TopologicalAddGroup E := hp.topologicalAddGroup [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p x : E this : TopologicalAddGroup E ⊢ HasBasis (𝓝 x) (fun sr => 0 < sr.snd) fun sr => ball (Finset.sup sr.fst p) x sr.snd [PROOFSTEP] rw [← map_add_left_nhds_zero] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p x : E this : TopologicalAddGroup E ⊢ HasBasis (Filter.map ((fun x x_1 => x + x_1) x) (𝓝 0)) (fun sr => 0 < sr.snd) fun sr => ball (Finset.sup sr.fst p) x sr.snd [PROOFSTEP] convert hp.hasBasis_zero_ball.map ((· + ·) x) using 1 [GOAL] case h.e'_5 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p x : E this : TopologicalAddGroup E ⊢ (fun sr => ball (Finset.sup sr.fst p) x sr.snd) = fun i => (fun x x_1 => x + x_1) x '' ball (Finset.sup i.fst p) 0 i.snd [PROOFSTEP] ext sr : 1 -- Porting note: extra type ascriptions needed on `0` [GOAL] case h.e'_5.h 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p x : E this : TopologicalAddGroup E sr : Finset ι × ℝ ⊢ ball (Finset.sup sr.fst p) x sr.snd = (fun x x_1 => x + x_1) x '' ball (Finset.sup sr.fst p) 0 sr.snd [PROOFSTEP] have : (sr.fst.sup p).ball (x +ᵥ (0 : E)) sr.snd = x +ᵥ (sr.fst.sup p).ball 0 sr.snd := Eq.symm (Seminorm.vadd_ball (sr.fst.sup p)) [GOAL] case h.e'_5.h 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p x : E this✝ : TopologicalAddGroup E sr : Finset ι × ℝ this : ball (Finset.sup sr.fst p) (x +ᵥ 0) sr.snd = x +ᵥ ball (Finset.sup sr.fst p) 0 sr.snd ⊢ ball (Finset.sup sr.fst p) x sr.snd = (fun x x_1 => x + x_1) x '' ball (Finset.sup sr.fst p) 0 sr.snd [PROOFSTEP] rwa [vadd_eq_add, add_zero] at this [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p x : E U : Set E ⊢ U ∈ 𝓝 x ↔ ∃ s r, r > 0 ∧ ball (Finset.sup s p) x r ⊆ U [PROOFSTEP] rw [hp.hasBasis_ball.mem_iff, Prod.exists] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p U : Set E ⊢ IsOpen U ↔ ∀ (x : E), x ∈ U → ∃ s r, r > 0 ∧ ball (Finset.sup s p) x r ⊆ U [PROOFSTEP] simp_rw [← WithSeminorms.mem_nhds_iff hp _ U, isOpen_iff_mem_nhds] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p h : ∀ (x : E), x ≠ 0 → ∃ i, ↑(p i) x ≠ 0 ⊢ T1Space E [PROOFSTEP] have := hp.topologicalAddGroup [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p h : ∀ (x : E), x ≠ 0 → ∃ i, ↑(p i) x ≠ 0 this : TopologicalAddGroup E ⊢ T1Space E [PROOFSTEP] refine' TopologicalAddGroup.t1Space _ _ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p h : ∀ (x : E), x ≠ 0 → ∃ i, ↑(p i) x ≠ 0 this : TopologicalAddGroup E ⊢ IsClosed {0} [PROOFSTEP] rw [← isOpen_compl_iff, hp.isOpen_iff_mem_balls] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p h : ∀ (x : E), x ≠ 0 → ∃ i, ↑(p i) x ≠ 0 this : TopologicalAddGroup E ⊢ ∀ (x : E), x ∈ {0}ᶜ → ∃ s r, r > 0 ∧ ball (Finset.sup s p) x r ⊆ {0}ᶜ [PROOFSTEP] rintro x (hx : x ≠ 0) [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p h : ∀ (x : E), x ≠ 0 → ∃ i, ↑(p i) x ≠ 0 this : TopologicalAddGroup E x : E hx : x ≠ 0 ⊢ ∃ s r, r > 0 ∧ ball (Finset.sup s p) x r ⊆ {0}ᶜ [PROOFSTEP] cases' h x hx with i pi_nonzero [GOAL] case intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p h : ∀ (x : E), x ≠ 0 → ∃ i, ↑(p i) x ≠ 0 this : TopologicalAddGroup E x : E hx : x ≠ 0 i : ι pi_nonzero : ↑(p i) x ≠ 0 ⊢ ∃ s r, r > 0 ∧ ball (Finset.sup s p) x r ⊆ {0}ᶜ [PROOFSTEP] refine' ⟨{ i }, p i x, by positivity, subset_compl_singleton_iff.mpr _⟩ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p h : ∀ (x : E), x ≠ 0 → ∃ i, ↑(p i) x ≠ 0 this : TopologicalAddGroup E x : E hx : x ≠ 0 i : ι pi_nonzero : ↑(p i) x ≠ 0 ⊢ ↑(p i) x > 0 [PROOFSTEP] positivity [GOAL] case intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p h : ∀ (x : E), x ≠ 0 → ∃ i, ↑(p i) x ≠ 0 this : TopologicalAddGroup E x : E hx : x ≠ 0 i : ι pi_nonzero : ↑(p i) x ≠ 0 ⊢ ¬0 ∈ ball (Finset.sup {i} p) x (↑(p i) x) [PROOFSTEP] rw [Finset.sup_singleton, mem_ball, zero_sub, map_neg_eq_map, not_lt] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁵ : NormedField 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : Nonempty ι inst✝¹ : TopologicalSpace E p : SeminormFamily 𝕜 E ι inst✝ : T1Space E hp : WithSeminorms p x : E hx : x ≠ 0 ⊢ ∃ i, ↑(p i) x ≠ 0 [PROOFSTEP] have := ((t1Space_TFAE E).out 0 9).mp (inferInstanceAs <| T1Space E) [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁵ : NormedField 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : Nonempty ι inst✝¹ : TopologicalSpace E p : SeminormFamily 𝕜 E ι inst✝ : T1Space E hp : WithSeminorms p x : E hx : x ≠ 0 this : ∀ ⦃x y : E⦄, x ⤳ y → x = y ⊢ ∃ i, ↑(p i) x ≠ 0 [PROOFSTEP] by_contra' h [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁵ : NormedField 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : Nonempty ι inst✝¹ : TopologicalSpace E p : SeminormFamily 𝕜 E ι inst✝ : T1Space E hp : WithSeminorms p x : E hx : x ≠ 0 this : ∀ ⦃x y : E⦄, x ⤳ y → x = y h : ∀ (i : ι), ↑(p i) x = 0 ⊢ False [PROOFSTEP] refine' hx (this _) [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁵ : NormedField 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : Nonempty ι inst✝¹ : TopologicalSpace E p : SeminormFamily 𝕜 E ι inst✝ : T1Space E hp : WithSeminorms p x : E hx : x ≠ 0 this : ∀ ⦃x y : E⦄, x ⤳ y → x = y h : ∀ (i : ι), ↑(p i) x = 0 ⊢ x ⤳ 0 [PROOFSTEP] rw [hp.hasBasis_zero_ball.specializes_iff] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁵ : NormedField 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : Nonempty ι inst✝¹ : TopologicalSpace E p : SeminormFamily 𝕜 E ι inst✝ : T1Space E hp : WithSeminorms p x : E hx : x ≠ 0 this : ∀ ⦃x y : E⦄, x ⤳ y → x = y h : ∀ (i : ι), ↑(p i) x = 0 ⊢ ∀ (i : Finset ι × ℝ), 0 < i.snd → x ∈ ball (Finset.sup i.fst p) 0 i.snd [PROOFSTEP] rintro ⟨s, r⟩ (hr : 0 < r) [GOAL] case mk 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁵ : NormedField 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : Nonempty ι inst✝¹ : TopologicalSpace E p : SeminormFamily 𝕜 E ι inst✝ : T1Space E hp : WithSeminorms p x : E hx : x ≠ 0 this : ∀ ⦃x y : E⦄, x ⤳ y → x = y h : ∀ (i : ι), ↑(p i) x = 0 s : Finset ι r : ℝ hr : 0 < r ⊢ x ∈ ball (Finset.sup (s, r).fst p) 0 (s, r).snd [PROOFSTEP] simp only [ball_finset_sup_eq_iInter _ _ _ hr, mem_iInter₂, mem_ball_zero, h, hr, forall_true_iff] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p ⊢ (∀ (x : E), x ≠ 0 → ∃ i, ↑(p i) x ≠ 0) ↔ T1Space E [PROOFSTEP] refine' ⟨WithSeminorms.T1_of_separating hp, _⟩ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p ⊢ T1Space E → ∀ (x : E), x ≠ 0 → ∃ i, ↑(p i) x ≠ 0 [PROOFSTEP] intro [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p a✝ : T1Space E ⊢ ∀ (x : E), x ≠ 0 → ∃ i, ↑(p i) x ≠ 0 [PROOFSTEP] exact WithSeminorms.separating_of_T1 hp [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p u : F → E f : Filter F y₀ : E ⊢ Tendsto u f (𝓝 y₀) ↔ ∀ (s : Finset ι) (ε : ℝ), 0 < ε → ∀ᶠ (x : F) in f, ↑(Finset.sup s p) (u x - y₀) < ε [PROOFSTEP] simp [hp.hasBasis_ball.tendsto_right_iff] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p u : F → E f : Filter F y₀ : E ⊢ Tendsto u f (𝓝 y₀) ↔ ∀ (i : ι) (ε : ℝ), 0 < ε → ∀ᶠ (x : F) in f, ↑(p i) (u x - y₀) < ε [PROOFSTEP] rw [hp.tendsto_nhds' u y₀] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p u : F → E f : Filter F y₀ : E ⊢ (∀ (s : Finset ι) (ε : ℝ), 0 < ε → ∀ᶠ (x : F) in f, ↑(Finset.sup s p) (u x - y₀) < ε) ↔ ∀ (i : ι) (ε : ℝ), 0 < ε → ∀ᶠ (x : F) in f, ↑(p i) (u x - y₀) < ε [PROOFSTEP] exact ⟨fun h i => by simpa only [Finset.sup_singleton] using h { i }, fun h s ε hε => (s.eventually_all.2 fun i _ => h i ε hε).mono fun _ => finset_sup_apply_lt hε⟩ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p u : F → E f : Filter F y₀ : E h : ∀ (s : Finset ι) (ε : ℝ), 0 < ε → ∀ᶠ (x : F) in f, ↑(Finset.sup s p) (u x - y₀) < ε i : ι ⊢ ∀ (ε : ℝ), 0 < ε → ∀ᶠ (x : F) in f, ↑(p i) (u x - y₀) < ε [PROOFSTEP] simpa only [Finset.sup_singleton] using h { i } [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : Nonempty ι inst✝² : TopologicalSpace E p : SeminormFamily 𝕜 E ι inst✝¹ : SemilatticeSup F inst✝ : Nonempty F hp : WithSeminorms p u : F → E y₀ : E ⊢ Tendsto u atTop (𝓝 y₀) ↔ ∀ (i : ι) (ε : ℝ), 0 < ε → ∃ x₀, ∀ (x : F), x₀ ≤ x → ↑(p i) (u x - y₀) < ε [PROOFSTEP] rw [hp.tendsto_nhds u y₀] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : Nonempty ι inst✝² : TopologicalSpace E p : SeminormFamily 𝕜 E ι inst✝¹ : SemilatticeSup F inst✝ : Nonempty F hp : WithSeminorms p u : F → E y₀ : E ⊢ (∀ (i : ι) (ε : ℝ), 0 < ε → ∀ᶠ (x : F) in atTop, ↑(p i) (u x - y₀) < ε) ↔ ∀ (i : ι) (ε : ℝ), 0 < ε → ∃ x₀, ∀ (x : F), x₀ ≤ x → ↑(p i) (u x - y₀) < ε [PROOFSTEP] exact forall₃_congr fun _ _ _ => Filter.eventually_atTop [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι t : TopologicalSpace E inst✝ : TopologicalAddGroup E p : SeminormFamily 𝕜 E ι h : 𝓝 0 = FilterBasis.filter AddGroupFilterBasis.toFilterBasis ⊢ WithSeminorms p [PROOFSTEP] refine' ⟨TopologicalAddGroup.ext inferInstance p.addGroupFilterBasis.isTopologicalAddGroup _⟩ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι t : TopologicalSpace E inst✝ : TopologicalAddGroup E p : SeminormFamily 𝕜 E ι h : 𝓝 0 = FilterBasis.filter AddGroupFilterBasis.toFilterBasis ⊢ 𝓝 0 = 𝓝 0 [PROOFSTEP] rw [AddGroupFilterBasis.nhds_zero_eq] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι t : TopologicalSpace E inst✝ : TopologicalAddGroup E p : SeminormFamily 𝕜 E ι h : 𝓝 0 = FilterBasis.filter AddGroupFilterBasis.toFilterBasis ⊢ 𝓝 0 = FilterBasis.filter AddGroupFilterBasis.toFilterBasis [PROOFSTEP] exact h [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι t : TopologicalSpace E inst✝ : TopologicalAddGroup E p : SeminormFamily 𝕜 E ι ⊢ WithSeminorms p ↔ 𝓝 0 = ⨅ (i : ι), comap (↑(p i)) (𝓝 0) [PROOFSTEP] rw [← p.filter_eq_iInf] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι t : TopologicalSpace E inst✝ : TopologicalAddGroup E p : SeminormFamily 𝕜 E ι ⊢ WithSeminorms p ↔ 𝓝 0 = FilterBasis.filter AddGroupFilterBasis.toFilterBasis [PROOFSTEP] refine' ⟨fun h => _, p.withSeminorms_of_nhds⟩ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι t : TopologicalSpace E inst✝ : TopologicalAddGroup E p : SeminormFamily 𝕜 E ι h : WithSeminorms p ⊢ 𝓝 0 = FilterBasis.filter AddGroupFilterBasis.toFilterBasis [PROOFSTEP] rw [h.topology_eq_withSeminorms] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι t : TopologicalSpace E inst✝ : TopologicalAddGroup E p : SeminormFamily 𝕜 E ι h : WithSeminorms p ⊢ 𝓝 0 = FilterBasis.filter AddGroupFilterBasis.toFilterBasis [PROOFSTEP] exact AddGroupFilterBasis.nhds_zero_eq _ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι t : TopologicalSpace E inst✝ : TopologicalAddGroup E p : SeminormFamily 𝕜 E ι ⊢ WithSeminorms p ↔ t = ⨅ (i : ι), UniformSpace.toTopologicalSpace [PROOFSTEP] rw [p.withSeminorms_iff_nhds_eq_iInf, TopologicalAddGroup.ext_iff inferInstance (topologicalAddGroup_iInf fun i => inferInstance), nhds_iInf] -- Porting note: next three lines was `congrm (_ = ⨅ i, _)` [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι t : TopologicalSpace E inst✝ : TopologicalAddGroup E p : SeminormFamily 𝕜 E ι ⊢ 𝓝 0 = ⨅ (i : ι), comap (↑(p i)) (𝓝 0) ↔ 𝓝 0 = ⨅ (i : ι), 𝓝 0 [PROOFSTEP] refine Eq.to_iff ?_ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι t : TopologicalSpace E inst✝ : TopologicalAddGroup E p : SeminormFamily 𝕜 E ι ⊢ (𝓝 0 = ⨅ (i : ι), comap (↑(p i)) (𝓝 0)) = (𝓝 0 = ⨅ (i : ι), 𝓝 0) [PROOFSTEP] congr [GOAL] case e_a.e_s 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι t : TopologicalSpace E inst✝ : TopologicalAddGroup E p : SeminormFamily 𝕜 E ι ⊢ (fun i => comap (↑(p i)) (𝓝 0)) = fun i => 𝓝 0 [PROOFSTEP] funext i [GOAL] case e_a.e_s.h 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι t : TopologicalSpace E inst✝ : TopologicalAddGroup E p : SeminormFamily 𝕜 E ι i : ι ⊢ comap (↑(p i)) (𝓝 0) = 𝓝 0 [PROOFSTEP] exact @comap_norm_nhds_zero _ (p i).toSeminormedAddGroup [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E inst✝ : Nonempty ι t : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p i : ι ⊢ Continuous ↑(p i) [PROOFSTEP] have := hp.topologicalAddGroup [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E inst✝ : Nonempty ι t : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p i : ι this : TopologicalAddGroup E ⊢ Continuous ↑(p i) [PROOFSTEP] rw [p.withSeminorms_iff_topologicalSpace_eq_iInf.mp hp] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝³ : NormedField 𝕜 inst✝² : AddCommGroup E inst✝¹ : Module 𝕜 E inst✝ : Nonempty ι t : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p i : ι this : TopologicalAddGroup E ⊢ Continuous ↑(p i) [PROOFSTEP] exact continuous_iInf_dom (@continuous_norm _ (p i).toSeminormedAddGroup) [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι u : UniformSpace E inst✝ : UniformAddGroup E p : SeminormFamily 𝕜 E ι ⊢ WithSeminorms p ↔ u = ⨅ (i : ι), PseudoMetricSpace.toUniformSpace [PROOFSTEP] rw [p.withSeminorms_iff_nhds_eq_iInf, UniformAddGroup.ext_iff inferInstance (uniformAddGroup_iInf fun i => inferInstance), toTopologicalSpace_iInf, nhds_iInf] -- Porting note: next three lines was `congrm (_ = ⨅ i, _)` [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι u : UniformSpace E inst✝ : UniformAddGroup E p : SeminormFamily 𝕜 E ι ⊢ 𝓝 0 = ⨅ (i : ι), comap (↑(p i)) (𝓝 0) ↔ 𝓝 0 = ⨅ (i : ι), 𝓝 0 [PROOFSTEP] refine Eq.to_iff ?_ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι u : UniformSpace E inst✝ : UniformAddGroup E p : SeminormFamily 𝕜 E ι ⊢ (𝓝 0 = ⨅ (i : ι), comap (↑(p i)) (𝓝 0)) = (𝓝 0 = ⨅ (i : ι), 𝓝 0) [PROOFSTEP] congr [GOAL] case e_a.e_s 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι u : UniformSpace E inst✝ : UniformAddGroup E p : SeminormFamily 𝕜 E ι ⊢ (fun i => comap (↑(p i)) (𝓝 0)) = fun i => 𝓝 0 [PROOFSTEP] funext i [GOAL] case e_a.e_s.h 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι u : UniformSpace E inst✝ : UniformAddGroup E p : SeminormFamily 𝕜 E ι i : ι ⊢ comap (↑(p i)) (𝓝 0) = 𝓝 0 [PROOFSTEP] exact @comap_norm_nhds_zero _ (p i).toAddGroupSeminorm.toSeminormedAddGroup [GOAL] 𝕜✝ : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E✝ : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 𝕜 : Type u_10 E : Type u_11 inst✝² : NormedField 𝕜 inst✝¹ : SeminormedAddCommGroup E inst✝ : NormedSpace 𝕜 E ⊢ WithSeminorms fun x => normSeminorm 𝕜 E [PROOFSTEP] let p : SeminormFamily 𝕜 E (Fin 1) := fun _ => normSeminorm 𝕜 E [GOAL] 𝕜✝ : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E✝ : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 𝕜 : Type u_10 E : Type u_11 inst✝² : NormedField 𝕜 inst✝¹ : SeminormedAddCommGroup E inst✝ : NormedSpace 𝕜 E p : SeminormFamily 𝕜 E (Fin 1) := fun x => normSeminorm 𝕜 E ⊢ WithSeminorms fun x => normSeminorm 𝕜 E [PROOFSTEP] refine' ⟨SeminormedAddCommGroup.toTopologicalAddGroup.ext p.addGroupFilterBasis.isTopologicalAddGroup _⟩ [GOAL] 𝕜✝ : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E✝ : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 𝕜 : Type u_10 E : Type u_11 inst✝² : NormedField 𝕜 inst✝¹ : SeminormedAddCommGroup E inst✝ : NormedSpace 𝕜 E p : SeminormFamily 𝕜 E (Fin 1) := fun x => normSeminorm 𝕜 E ⊢ 𝓝 0 = 𝓝 0 [PROOFSTEP] refine' Filter.HasBasis.eq_of_same_basis Metric.nhds_basis_ball _ [GOAL] 𝕜✝ : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E✝ : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 𝕜 : Type u_10 E : Type u_11 inst✝² : NormedField 𝕜 inst✝¹ : SeminormedAddCommGroup E inst✝ : NormedSpace 𝕜 E p : SeminormFamily 𝕜 E (Fin 1) := fun x => normSeminorm 𝕜 E ⊢ HasBasis (𝓝 0) (fun x => 0 < x) (Metric.ball 0) [PROOFSTEP] rw [← ball_normSeminorm 𝕜 E] [GOAL] 𝕜✝ : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E✝ : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 𝕜 : Type u_10 E : Type u_11 inst✝² : NormedField 𝕜 inst✝¹ : SeminormedAddCommGroup E inst✝ : NormedSpace 𝕜 E p : SeminormFamily 𝕜 E (Fin 1) := fun x => normSeminorm 𝕜 E ⊢ HasBasis (𝓝 0) (fun x => 0 < x) (ball (normSeminorm 𝕜 E) 0) [PROOFSTEP] refine' Filter.HasBasis.to_hasBasis p.addGroupFilterBasis.nhds_zero_hasBasis _ fun r hr => ⟨(normSeminorm 𝕜 E).ball 0 r, p.basisSets_singleton_mem 0 hr, rfl.subset⟩ [GOAL] 𝕜✝ : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E✝ : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 𝕜 : Type u_10 E : Type u_11 inst✝² : NormedField 𝕜 inst✝¹ : SeminormedAddCommGroup E inst✝ : NormedSpace 𝕜 E p : SeminormFamily 𝕜 E (Fin 1) := fun x => normSeminorm 𝕜 E ⊢ ∀ (i : Set E), i ∈ SeminormFamily.addGroupFilterBasis p → ∃ i', 0 < i' ∧ ball (normSeminorm 𝕜 E) 0 i' ⊆ id i [PROOFSTEP] rintro U (hU : U ∈ p.basisSets) [GOAL] 𝕜✝ : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E✝ : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 𝕜 : Type u_10 E : Type u_11 inst✝² : NormedField 𝕜 inst✝¹ : SeminormedAddCommGroup E inst✝ : NormedSpace 𝕜 E p : SeminormFamily 𝕜 E (Fin 1) := fun x => normSeminorm 𝕜 E U : Set E hU : U ∈ SeminormFamily.basisSets p ⊢ ∃ i', 0 < i' ∧ ball (normSeminorm 𝕜 E) 0 i' ⊆ id U [PROOFSTEP] rcases p.basisSets_iff.mp hU with ⟨s, r, hr, hU⟩ [GOAL] case intro.intro.intro 𝕜✝ : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E✝ : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 𝕜 : Type u_10 E : Type u_11 inst✝² : NormedField 𝕜 inst✝¹ : SeminormedAddCommGroup E inst✝ : NormedSpace 𝕜 E p : SeminormFamily 𝕜 E (Fin 1) := fun x => normSeminorm 𝕜 E U : Set E hU✝ : U ∈ SeminormFamily.basisSets p s : Finset (Fin 1) r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r ⊢ ∃ i', 0 < i' ∧ ball (normSeminorm 𝕜 E) 0 i' ⊆ id U [PROOFSTEP] use r, hr [GOAL] case right 𝕜✝ : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E✝ : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 𝕜 : Type u_10 E : Type u_11 inst✝² : NormedField 𝕜 inst✝¹ : SeminormedAddCommGroup E inst✝ : NormedSpace 𝕜 E p : SeminormFamily 𝕜 E (Fin 1) := fun x => normSeminorm 𝕜 E U : Set E hU✝ : U ∈ SeminormFamily.basisSets p s : Finset (Fin 1) r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r ⊢ ball (normSeminorm 𝕜 E) 0 r ⊆ id U [PROOFSTEP] rw [hU, id.def] [GOAL] case right 𝕜✝ : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E✝ : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 𝕜 : Type u_10 E : Type u_11 inst✝² : NormedField 𝕜 inst✝¹ : SeminormedAddCommGroup E inst✝ : NormedSpace 𝕜 E p : SeminormFamily 𝕜 E (Fin 1) := fun x => normSeminorm 𝕜 E U : Set E hU✝ : U ∈ SeminormFamily.basisSets p s : Finset (Fin 1) r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r ⊢ ball (normSeminorm 𝕜 E) 0 r ⊆ ball (Finset.sup s p) 0 r [PROOFSTEP] by_cases h : s.Nonempty [GOAL] case pos 𝕜✝ : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E✝ : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 𝕜 : Type u_10 E : Type u_11 inst✝² : NormedField 𝕜 inst✝¹ : SeminormedAddCommGroup E inst✝ : NormedSpace 𝕜 E p : SeminormFamily 𝕜 E (Fin 1) := fun x => normSeminorm 𝕜 E U : Set E hU✝ : U ∈ SeminormFamily.basisSets p s : Finset (Fin 1) r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r h : Finset.Nonempty s ⊢ ball (normSeminorm 𝕜 E) 0 r ⊆ ball (Finset.sup s p) 0 r [PROOFSTEP] rw [Finset.sup_const h] [GOAL] case neg 𝕜✝ : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E✝ : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 𝕜 : Type u_10 E : Type u_11 inst✝² : NormedField 𝕜 inst✝¹ : SeminormedAddCommGroup E inst✝ : NormedSpace 𝕜 E p : SeminormFamily 𝕜 E (Fin 1) := fun x => normSeminorm 𝕜 E U : Set E hU✝ : U ∈ SeminormFamily.basisSets p s : Finset (Fin 1) r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r h : ¬Finset.Nonempty s ⊢ ball (normSeminorm 𝕜 E) 0 r ⊆ ball (Finset.sup s p) 0 r [PROOFSTEP] rw [Finset.not_nonempty_iff_eq_empty.mp h, Finset.sup_empty, ball_bot _ hr] [GOAL] case neg 𝕜✝ : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E✝ : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 𝕜 : Type u_10 E : Type u_11 inst✝² : NormedField 𝕜 inst✝¹ : SeminormedAddCommGroup E inst✝ : NormedSpace 𝕜 E p : SeminormFamily 𝕜 E (Fin 1) := fun x => normSeminorm 𝕜 E U : Set E hU✝ : U ∈ SeminormFamily.basisSets p s : Finset (Fin 1) r : ℝ hr : 0 < r hU : U = ball (Finset.sup s p) 0 r h : ¬Finset.Nonempty s ⊢ ball (normSeminorm 𝕜 E) 0 r ⊆ univ [PROOFSTEP] exact Set.subset_univ _ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p ⊢ Bornology.IsVonNBounded 𝕜 s ↔ ∀ (I : Finset ι), ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r [PROOFSTEP] rw [hp.hasBasis.isVonNBounded_basis_iff] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p ⊢ (∀ (i : Set E), i ∈ SeminormFamily.basisSets p → Absorbs 𝕜 (id i) s) ↔ ∀ (I : Finset ι), ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r [PROOFSTEP] constructor [GOAL] case mp 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p ⊢ (∀ (i : Set E), i ∈ SeminormFamily.basisSets p → Absorbs 𝕜 (id i) s) → ∀ (I : Finset ι), ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r [PROOFSTEP] intro h I [GOAL] case mp 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p h : ∀ (i : Set E), i ∈ SeminormFamily.basisSets p → Absorbs 𝕜 (id i) s I : Finset ι ⊢ ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r [PROOFSTEP] simp only [id.def] at h [GOAL] case mp 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p h : ∀ (i : Set E), i ∈ SeminormFamily.basisSets p → Absorbs 𝕜 i s I : Finset ι ⊢ ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r [PROOFSTEP] specialize h ((I.sup p).ball 0 1) (p.basisSets_mem I zero_lt_one) [GOAL] case mp 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p I : Finset ι h : Absorbs 𝕜 (ball (Finset.sup I p) 0 1) s ⊢ ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r [PROOFSTEP] rcases h with ⟨r, hr, h⟩ [GOAL] case mp.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p I : Finset ι r : ℝ hr : 0 < r h : ∀ (a : 𝕜), r ≤ ‖a‖ → s ⊆ a • ball (Finset.sup I p) 0 1 ⊢ ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r [PROOFSTEP] cases' NormedField.exists_lt_norm 𝕜 r with a ha [GOAL] case mp.intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p I : Finset ι r : ℝ hr : 0 < r h : ∀ (a : 𝕜), r ≤ ‖a‖ → s ⊆ a • ball (Finset.sup I p) 0 1 a : 𝕜 ha : r < ‖a‖ ⊢ ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r [PROOFSTEP] specialize h a (le_of_lt ha) [GOAL] case mp.intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p I : Finset ι r : ℝ hr : 0 < r a : 𝕜 ha : r < ‖a‖ h : s ⊆ a • ball (Finset.sup I p) 0 1 ⊢ ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r [PROOFSTEP] rw [Seminorm.smul_ball_zero (norm_pos_iff.1 <| hr.trans ha), mul_one] at h [GOAL] case mp.intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p I : Finset ι r : ℝ hr : 0 < r a : 𝕜 ha : r < ‖a‖ h : s ⊆ ball (Finset.sup I p) 0 ‖a‖ ⊢ ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r [PROOFSTEP] refine' ⟨‖a‖, lt_trans hr ha, _⟩ [GOAL] case mp.intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p I : Finset ι r : ℝ hr : 0 < r a : 𝕜 ha : r < ‖a‖ h : s ⊆ ball (Finset.sup I p) 0 ‖a‖ ⊢ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < ‖a‖ [PROOFSTEP] intro x hx [GOAL] case mp.intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p I : Finset ι r : ℝ hr : 0 < r a : 𝕜 ha : r < ‖a‖ h : s ⊆ ball (Finset.sup I p) 0 ‖a‖ x : E hx : x ∈ s ⊢ ↑(Finset.sup I p) x < ‖a‖ [PROOFSTEP] specialize h hx [GOAL] case mp.intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p I : Finset ι r : ℝ hr : 0 < r a : 𝕜 ha : r < ‖a‖ x : E hx : x ∈ s h : x ∈ ball (Finset.sup I p) 0 ‖a‖ ⊢ ↑(Finset.sup I p) x < ‖a‖ [PROOFSTEP] exact (Finset.sup I p).mem_ball_zero.mp h [GOAL] case mpr 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p ⊢ (∀ (I : Finset ι), ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r) → ∀ (i : Set E), i ∈ SeminormFamily.basisSets p → Absorbs 𝕜 (id i) s [PROOFSTEP] intro h s' hs' [GOAL] case mpr 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p h : ∀ (I : Finset ι), ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r s' : Set E hs' : s' ∈ SeminormFamily.basisSets p ⊢ Absorbs 𝕜 (id s') s [PROOFSTEP] rcases p.basisSets_iff.mp hs' with ⟨I, r, hr, hs'⟩ [GOAL] case mpr.intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p h : ∀ (I : Finset ι), ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r s' : Set E hs'✝ : s' ∈ SeminormFamily.basisSets p I : Finset ι r : ℝ hr : 0 < r hs' : s' = ball (Finset.sup I p) 0 r ⊢ Absorbs 𝕜 (id s') s [PROOFSTEP] rw [id.def, hs'] [GOAL] case mpr.intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p h : ∀ (I : Finset ι), ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r s' : Set E hs'✝ : s' ∈ SeminormFamily.basisSets p I : Finset ι r : ℝ hr : 0 < r hs' : s' = ball (Finset.sup I p) 0 r ⊢ Absorbs 𝕜 (ball (Finset.sup I p) 0 r) s [PROOFSTEP] rcases h I with ⟨r', _, h'⟩ [GOAL] case mpr.intro.intro.intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p h : ∀ (I : Finset ι), ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r s' : Set E hs'✝ : s' ∈ SeminormFamily.basisSets p I : Finset ι r : ℝ hr : 0 < r hs' : s' = ball (Finset.sup I p) 0 r r' : ℝ left✝ : r' > 0 h' : ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r' ⊢ Absorbs 𝕜 (ball (Finset.sup I p) 0 r) s [PROOFSTEP] simp_rw [← (I.sup p).mem_ball_zero] at h' [GOAL] case mpr.intro.intro.intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p h : ∀ (I : Finset ι), ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r s' : Set E hs'✝ : s' ∈ SeminormFamily.basisSets p I : Finset ι r : ℝ hr : 0 < r hs' : s' = ball (Finset.sup I p) 0 r r' : ℝ left✝ : r' > 0 h' : ∀ (x : E), x ∈ s → x ∈ ball (Finset.sup I p) 0 r' ⊢ Absorbs 𝕜 (ball (Finset.sup I p) 0 r) s [PROOFSTEP] refine' Absorbs.mono_right _ h' [GOAL] case mpr.intro.intro.intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p h : ∀ (I : Finset ι), ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r s' : Set E hs'✝ : s' ∈ SeminormFamily.basisSets p I : Finset ι r : ℝ hr : 0 < r hs' : s' = ball (Finset.sup I p) 0 r r' : ℝ left✝ : r' > 0 h' : ∀ (x : E), x ∈ s → x ∈ ball (Finset.sup I p) 0 r' ⊢ Absorbs 𝕜 (ball (Finset.sup I p) 0 r) (ball (Finset.sup I p) 0 r') [PROOFSTEP] exact (Finset.sup I p).ball_zero_absorbs_ball_zero hr [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E f : G → E s : Set G hp : WithSeminorms p ⊢ Bornology.IsVonNBounded 𝕜 (f '' s) ↔ ∀ (I : Finset ι), ∃ r, r > 0 ∧ ∀ (x : G), x ∈ s → ↑(Finset.sup I p) (f x) < r [PROOFSTEP] simp_rw [hp.isVonNBounded_iff_finset_seminorm_bounded, Set.ball_image_iff] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p ⊢ Bornology.IsVonNBounded 𝕜 s ↔ ∀ (i : ι), ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(p i) x < r [PROOFSTEP] rw [hp.isVonNBounded_iff_finset_seminorm_bounded] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p ⊢ (∀ (I : Finset ι), ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r) ↔ ∀ (i : ι), ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(p i) x < r [PROOFSTEP] constructor [GOAL] case mp 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p ⊢ (∀ (I : Finset ι), ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r) → ∀ (i : ι), ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(p i) x < r [PROOFSTEP] intro hI i [GOAL] case mp 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p hI : ∀ (I : Finset ι), ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r i : ι ⊢ ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(p i) x < r [PROOFSTEP] convert hI { i } [GOAL] case h.e'_2.h.h.e'_2.h.h'.h.e'_3.h.e'_5 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p hI : ∀ (I : Finset ι), ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r i : ι x✝ : ℝ a✝¹ : E a✝ : a✝¹ ∈ s ⊢ p i = Finset.sup {i} p [PROOFSTEP] rw [Finset.sup_singleton] [GOAL] case mpr 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p ⊢ (∀ (i : ι), ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(p i) x < r) → ∀ (I : Finset ι), ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r [PROOFSTEP] intro hi I [GOAL] case mpr 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p hi : ∀ (i : ι), ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(p i) x < r I : Finset ι ⊢ ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r [PROOFSTEP] by_cases hI : I.Nonempty [GOAL] case pos 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p hi : ∀ (i : ι), ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(p i) x < r I : Finset ι hI : Finset.Nonempty I ⊢ ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r [PROOFSTEP] choose r hr h using hi [GOAL] case pos 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p I : Finset ι hI : Finset.Nonempty I r : ι → ℝ hr : ∀ (i : ι), r i > 0 h : ∀ (i : ι) (x : E), x ∈ s → ↑(p i) x < r i ⊢ ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r [PROOFSTEP] have h' : 0 < I.sup' hI r := by rcases hI.bex with ⟨i, hi⟩ exact lt_of_lt_of_le (hr i) (Finset.le_sup' r hi) [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p I : Finset ι hI : Finset.Nonempty I r : ι → ℝ hr : ∀ (i : ι), r i > 0 h : ∀ (i : ι) (x : E), x ∈ s → ↑(p i) x < r i ⊢ 0 < Finset.sup' I hI r [PROOFSTEP] rcases hI.bex with ⟨i, hi⟩ [GOAL] case intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p I : Finset ι hI : Finset.Nonempty I r : ι → ℝ hr : ∀ (i : ι), r i > 0 h : ∀ (i : ι) (x : E), x ∈ s → ↑(p i) x < r i i : ι hi : i ∈ I ⊢ 0 < Finset.sup' I hI r [PROOFSTEP] exact lt_of_lt_of_le (hr i) (Finset.le_sup' r hi) [GOAL] case pos 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p I : Finset ι hI : Finset.Nonempty I r : ι → ℝ hr : ∀ (i : ι), r i > 0 h : ∀ (i : ι) (x : E), x ∈ s → ↑(p i) x < r i h' : 0 < Finset.sup' I hI r ⊢ ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r [PROOFSTEP] refine' ⟨I.sup' hI r, h', fun x hx => finset_sup_apply_lt h' fun i hi => _⟩ [GOAL] case pos 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p I : Finset ι hI : Finset.Nonempty I r : ι → ℝ hr : ∀ (i : ι), r i > 0 h : ∀ (i : ι) (x : E), x ∈ s → ↑(p i) x < r i h' : 0 < Finset.sup' I hI r x : E hx : x ∈ s i : ι hi : i ∈ I ⊢ ↑(p i) x < Finset.sup' I hI r [PROOFSTEP] refine' lt_of_lt_of_le (h i x hx) _ [GOAL] case pos 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p I : Finset ι hI : Finset.Nonempty I r : ι → ℝ hr : ∀ (i : ι), r i > 0 h : ∀ (i : ι) (x : E), x ∈ s → ↑(p i) x < r i h' : 0 < Finset.sup' I hI r x : E hx : x ∈ s i : ι hi : i ∈ I ⊢ r i ≤ Finset.sup' I hI r [PROOFSTEP] simp only [Finset.le_sup'_iff, exists_prop] [GOAL] case pos 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p I : Finset ι hI : Finset.Nonempty I r : ι → ℝ hr : ∀ (i : ι), r i > 0 h : ∀ (i : ι) (x : E), x ∈ s → ↑(p i) x < r i h' : 0 < Finset.sup' I hI r x : E hx : x ∈ s i : ι hi : i ∈ I ⊢ ∃ b, b ∈ I ∧ r i ≤ r b [PROOFSTEP] exact ⟨i, hi, (Eq.refl _).le⟩ [GOAL] case neg 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p hi : ∀ (i : ι), ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(p i) x < r I : Finset ι hI : ¬Finset.Nonempty I ⊢ ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(Finset.sup I p) x < r [PROOFSTEP] simp only [Finset.not_nonempty_iff_eq_empty.mp hI, Finset.sup_empty, coe_bot, Pi.zero_apply, exists_prop] [GOAL] case neg 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E s : Set E hp : WithSeminorms p hi : ∀ (i : ι), ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → ↑(p i) x < r I : Finset ι hI : ¬Finset.Nonempty I ⊢ ∃ r, r > 0 ∧ ∀ (x : E), x ∈ s → 0 < r [PROOFSTEP] exact ⟨1, zero_lt_one, fun _ _ => zero_lt_one⟩ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : Nonempty ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E f : G → E s : Set G hp : WithSeminorms p ⊢ Bornology.IsVonNBounded 𝕜 (f '' s) ↔ ∀ (i : ι), ∃ r, r > 0 ∧ ∀ (x : G), x ∈ s → ↑(p i) (f x) < r [PROOFSTEP] simp_rw [hp.isVonNBounded_iff_seminorm_bounded, Set.ball_image_iff] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' q : SeminormFamily 𝕝₂ F ι' inst✝² : TopologicalSpace E inst✝¹ : TopologicalAddGroup E inst✝ : TopologicalSpace F hq : WithSeminorms q f : E →ₛₗ[τ₁₂] F hf : ∀ (i : ι'), Continuous ↑(comp (q i) f) ⊢ Continuous ↑f [PROOFSTEP] have : TopologicalAddGroup F := hq.topologicalAddGroup [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' q : SeminormFamily 𝕝₂ F ι' inst✝² : TopologicalSpace E inst✝¹ : TopologicalAddGroup E inst✝ : TopologicalSpace F hq : WithSeminorms q f : E →ₛₗ[τ₁₂] F hf : ∀ (i : ι'), Continuous ↑(comp (q i) f) this : TopologicalAddGroup F ⊢ Continuous ↑f [PROOFSTEP] refine' continuous_of_continuousAt_zero f _ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' q : SeminormFamily 𝕝₂ F ι' inst✝² : TopologicalSpace E inst✝¹ : TopologicalAddGroup E inst✝ : TopologicalSpace F hq : WithSeminorms q f : E →ₛₗ[τ₁₂] F hf : ∀ (i : ι'), Continuous ↑(comp (q i) f) this : TopologicalAddGroup F ⊢ ContinuousAt (↑f) 0 [PROOFSTEP] simp_rw [ContinuousAt, f.map_zero, q.withSeminorms_iff_nhds_eq_iInf.mp hq, Filter.tendsto_iInf, Filter.tendsto_comap_iff] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' q : SeminormFamily 𝕝₂ F ι' inst✝² : TopologicalSpace E inst✝¹ : TopologicalAddGroup E inst✝ : TopologicalSpace F hq : WithSeminorms q f : E →ₛₗ[τ₁₂] F hf : ∀ (i : ι'), Continuous ↑(comp (q i) f) this : TopologicalAddGroup F ⊢ ∀ (i : ι'), Tendsto (↑(q i) ∘ ↑f) (𝓝 0) (𝓝 0) [PROOFSTEP] intro i [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' q : SeminormFamily 𝕝₂ F ι' inst✝² : TopologicalSpace E inst✝¹ : TopologicalAddGroup E inst✝ : TopologicalSpace F hq : WithSeminorms q f : E →ₛₗ[τ₁₂] F hf : ∀ (i : ι'), Continuous ↑(comp (q i) f) this : TopologicalAddGroup F i : ι' ⊢ Tendsto (↑(q i) ∘ ↑f) (𝓝 0) (𝓝 0) [PROOFSTEP] convert (hf i).continuousAt.tendsto [GOAL] case h.e'_5.h.e'_3 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' q : SeminormFamily 𝕝₂ F ι' inst✝² : TopologicalSpace E inst✝¹ : TopologicalAddGroup E inst✝ : TopologicalSpace F hq : WithSeminorms q f : E →ₛₗ[τ₁₂] F hf : ∀ (i : ι'), Continuous ↑(comp (q i) f) this : TopologicalAddGroup F i : ι' ⊢ 0 = ↑(comp (q i) f) 0 [PROOFSTEP] exact (map_zero _).symm [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹³ : NontriviallyNormedField 𝕜 inst✝¹² : AddCommGroup E inst✝¹¹ : Module 𝕜 E inst✝¹⁰ : NormedField 𝕝 inst✝⁹ : Module 𝕝 E inst✝⁸ : NontriviallyNormedField 𝕜₂ inst✝⁷ : AddCommGroup F inst✝⁶ : Module 𝕜₂ F inst✝⁵ : NormedField 𝕝₂ inst✝⁴ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝³ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝² : RingHomIsometric τ₁₂ inst✝¹ : Nonempty ι inst✝ : Nonempty ι' p : SeminormFamily 𝕝 E ι q : SeminormFamily 𝕝₂ F ι' x✝¹ : TopologicalSpace E hp : WithSeminorms p x✝ : TopologicalSpace F hq : WithSeminorms q f : E →ₛₗ[τ₁₂] F hf : IsBounded p q f ⊢ Continuous ↑f [PROOFSTEP] have : TopologicalAddGroup E := hp.topologicalAddGroup [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹³ : NontriviallyNormedField 𝕜 inst✝¹² : AddCommGroup E inst✝¹¹ : Module 𝕜 E inst✝¹⁰ : NormedField 𝕝 inst✝⁹ : Module 𝕝 E inst✝⁸ : NontriviallyNormedField 𝕜₂ inst✝⁷ : AddCommGroup F inst✝⁶ : Module 𝕜₂ F inst✝⁵ : NormedField 𝕝₂ inst✝⁴ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝³ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝² : RingHomIsometric τ₁₂ inst✝¹ : Nonempty ι inst✝ : Nonempty ι' p : SeminormFamily 𝕝 E ι q : SeminormFamily 𝕝₂ F ι' x✝¹ : TopologicalSpace E hp : WithSeminorms p x✝ : TopologicalSpace F hq : WithSeminorms q f : E →ₛₗ[τ₁₂] F hf : IsBounded p q f this : TopologicalAddGroup E ⊢ Continuous ↑f [PROOFSTEP] refine continuous_of_continuous_comp hq _ fun i => ?_ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹³ : NontriviallyNormedField 𝕜 inst✝¹² : AddCommGroup E inst✝¹¹ : Module 𝕜 E inst✝¹⁰ : NormedField 𝕝 inst✝⁹ : Module 𝕝 E inst✝⁸ : NontriviallyNormedField 𝕜₂ inst✝⁷ : AddCommGroup F inst✝⁶ : Module 𝕜₂ F inst✝⁵ : NormedField 𝕝₂ inst✝⁴ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝³ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝² : RingHomIsometric τ₁₂ inst✝¹ : Nonempty ι inst✝ : Nonempty ι' p : SeminormFamily 𝕝 E ι q : SeminormFamily 𝕝₂ F ι' x✝¹ : TopologicalSpace E hp : WithSeminorms p x✝ : TopologicalSpace F hq : WithSeminorms q f : E →ₛₗ[τ₁₂] F hf : IsBounded p q f this : TopologicalAddGroup E i : ι' ⊢ Continuous ↑(comp (q i) f) [PROOFSTEP] rcases hf i with ⟨s, C, hC⟩ [GOAL] case intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹³ : NontriviallyNormedField 𝕜 inst✝¹² : AddCommGroup E inst✝¹¹ : Module 𝕜 E inst✝¹⁰ : NormedField 𝕝 inst✝⁹ : Module 𝕝 E inst✝⁸ : NontriviallyNormedField 𝕜₂ inst✝⁷ : AddCommGroup F inst✝⁶ : Module 𝕜₂ F inst✝⁵ : NormedField 𝕝₂ inst✝⁴ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝³ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝² : RingHomIsometric τ₁₂ inst✝¹ : Nonempty ι inst✝ : Nonempty ι' p : SeminormFamily 𝕝 E ι q : SeminormFamily 𝕝₂ F ι' x✝¹ : TopologicalSpace E hp : WithSeminorms p x✝ : TopologicalSpace F hq : WithSeminorms q f : E →ₛₗ[τ₁₂] F hf : IsBounded p q f this : TopologicalAddGroup E i : ι' s : Finset ι C : ℝ≥0 hC : comp (q i) f ≤ C • Finset.sup s p ⊢ Continuous ↑(comp (q i) f) [PROOFSTEP] rw [← Seminorm.finset_sup_smul] at hC [GOAL] case intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹³ : NontriviallyNormedField 𝕜 inst✝¹² : AddCommGroup E inst✝¹¹ : Module 𝕜 E inst✝¹⁰ : NormedField 𝕝 inst✝⁹ : Module 𝕝 E inst✝⁸ : NontriviallyNormedField 𝕜₂ inst✝⁷ : AddCommGroup F inst✝⁶ : Module 𝕜₂ F inst✝⁵ : NormedField 𝕝₂ inst✝⁴ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝³ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝² : RingHomIsometric τ₁₂ inst✝¹ : Nonempty ι inst✝ : Nonempty ι' p : SeminormFamily 𝕝 E ι q : SeminormFamily 𝕝₂ F ι' x✝¹ : TopologicalSpace E hp : WithSeminorms p x✝ : TopologicalSpace F hq : WithSeminorms q f : E →ₛₗ[τ₁₂] F hf : IsBounded p q f this : TopologicalAddGroup E i : ι' s : Finset ι C : ℝ≥0 hC : comp (q i) f ≤ Finset.sup s (C • p) ⊢ Continuous ↑(comp (q i) f) [PROOFSTEP] refine Seminorm.continuous_of_le ?_ (hC.trans <| Seminorm.finset_sup_le_sum _ _) [GOAL] case intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹³ : NontriviallyNormedField 𝕜 inst✝¹² : AddCommGroup E inst✝¹¹ : Module 𝕜 E inst✝¹⁰ : NormedField 𝕝 inst✝⁹ : Module 𝕝 E inst✝⁸ : NontriviallyNormedField 𝕜₂ inst✝⁷ : AddCommGroup F inst✝⁶ : Module 𝕜₂ F inst✝⁵ : NormedField 𝕝₂ inst✝⁴ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝³ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝² : RingHomIsometric τ₁₂ inst✝¹ : Nonempty ι inst✝ : Nonempty ι' p : SeminormFamily 𝕝 E ι q : SeminormFamily 𝕝₂ F ι' x✝¹ : TopologicalSpace E hp : WithSeminorms p x✝ : TopologicalSpace F hq : WithSeminorms q f : E →ₛₗ[τ₁₂] F hf : IsBounded p q f this : TopologicalAddGroup E i : ι' s : Finset ι C : ℝ≥0 hC : comp (q i) f ≤ Finset.sup s (C • p) ⊢ Continuous ↑(∑ i in s, (C • p) i) [PROOFSTEP] change Continuous (fun x ↦ Seminorm.coeFnAddMonoidHom _ _ (∑ i in s, C • p i) x) [GOAL] case intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹³ : NontriviallyNormedField 𝕜 inst✝¹² : AddCommGroup E inst✝¹¹ : Module 𝕜 E inst✝¹⁰ : NormedField 𝕝 inst✝⁹ : Module 𝕝 E inst✝⁸ : NontriviallyNormedField 𝕜₂ inst✝⁷ : AddCommGroup F inst✝⁶ : Module 𝕜₂ F inst✝⁵ : NormedField 𝕝₂ inst✝⁴ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝³ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝² : RingHomIsometric τ₁₂ inst✝¹ : Nonempty ι inst✝ : Nonempty ι' p : SeminormFamily 𝕝 E ι q : SeminormFamily 𝕝₂ F ι' x✝¹ : TopologicalSpace E hp : WithSeminorms p x✝ : TopologicalSpace F hq : WithSeminorms q f : E →ₛₗ[τ₁₂] F hf : IsBounded p q f this : TopologicalAddGroup E i : ι' s : Finset ι C : ℝ≥0 hC : comp (q i) f ≤ Finset.sup s (C • p) ⊢ Continuous fun x => ↑(coeFnAddMonoidHom 𝕝 E) (∑ i in s, C • p i) x [PROOFSTEP] simp_rw [map_sum, Finset.sum_apply] [GOAL] case intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹³ : NontriviallyNormedField 𝕜 inst✝¹² : AddCommGroup E inst✝¹¹ : Module 𝕜 E inst✝¹⁰ : NormedField 𝕝 inst✝⁹ : Module 𝕝 E inst✝⁸ : NontriviallyNormedField 𝕜₂ inst✝⁷ : AddCommGroup F inst✝⁶ : Module 𝕜₂ F inst✝⁵ : NormedField 𝕝₂ inst✝⁴ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝³ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝² : RingHomIsometric τ₁₂ inst✝¹ : Nonempty ι inst✝ : Nonempty ι' p : SeminormFamily 𝕝 E ι q : SeminormFamily 𝕝₂ F ι' x✝¹ : TopologicalSpace E hp : WithSeminorms p x✝ : TopologicalSpace F hq : WithSeminorms q f : E →ₛₗ[τ₁₂] F hf : IsBounded p q f this : TopologicalAddGroup E i : ι' s : Finset ι C : ℝ≥0 hC : comp (q i) f ≤ Finset.sup s (C • p) ⊢ Continuous fun x => ∑ c in s, ↑(coeFnAddMonoidHom 𝕝 E) (C • p c) x [PROOFSTEP] exact (continuous_finset_sum _ fun i _ ↦ (hp.continuous_seminorm i).const_smul (C : ℝ)) [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F✝ : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F✝ inst✝⁹ : Module 𝕜₂ F✝ inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F✝ σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' F : Type u_10 inst✝² : SeminormedAddCommGroup F inst✝¹ : NormedSpace 𝕝₂ F inst✝ : TopologicalSpace E p : ι → Seminorm 𝕝 E hp : WithSeminorms p f : E →ₛₗ[τ₁₂] F hf : ∃ s C, comp (normSeminorm 𝕝₂ F) f ≤ C • Finset.sup s p ⊢ Continuous ↑f [PROOFSTEP] rw [← Seminorm.isBounded_const (Fin 1)] at hf [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F✝ : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F✝ inst✝⁹ : Module 𝕜₂ F✝ inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F✝ σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' F : Type u_10 inst✝² : SeminormedAddCommGroup F inst✝¹ : NormedSpace 𝕝₂ F inst✝ : TopologicalSpace E p : ι → Seminorm 𝕝 E hp : WithSeminorms p f : E →ₛₗ[τ₁₂] F hf : IsBounded p (fun x => normSeminorm 𝕝₂ F) f ⊢ Continuous ↑f [PROOFSTEP] exact continuous_from_bounded hp (norm_withSeminorms 𝕝₂ F) f hf [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E✝ : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E✝ inst✝¹⁴ : Module 𝕜 E✝ inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E✝ inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' E : Type u_10 inst✝² : SeminormedAddCommGroup E inst✝¹ : NormedSpace 𝕝 E inst✝ : TopologicalSpace F q : ι → Seminorm 𝕝₂ F hq : WithSeminorms q f : E →ₛₗ[τ₁₂] F hf : ∀ (i : ι), ∃ C, comp (q i) f ≤ C • normSeminorm 𝕝 E ⊢ Continuous ↑f [PROOFSTEP] rw [← Seminorm.const_isBounded (Fin 1)] at hf [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E✝ : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E✝ inst✝¹⁴ : Module 𝕜 E✝ inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E✝ inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' E : Type u_10 inst✝² : SeminormedAddCommGroup E inst✝¹ : NormedSpace 𝕝 E inst✝ : TopologicalSpace F q : ι → Seminorm 𝕝₂ F hq : WithSeminorms q f : E →ₛₗ[τ₁₂] F hf : IsBounded (fun x => normSeminorm 𝕝 E) (fun i => q i) f ⊢ Continuous ↑f [PROOFSTEP] exact continuous_from_bounded (norm_withSeminorms 𝕝 E) hq f hf [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E u : UniformSpace F hu : UniformAddGroup F hq : WithSeminorms q inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F ⊢ TFAE [EquicontinuousAt (FunLike.coe ∘ f) 0, Equicontinuous (FunLike.coe ∘ f), UniformEquicontinuous (FunLike.coe ∘ f), ∀ (i : ι'), ∃ p, Continuous ↑p ∧ ∀ (k : κ), comp (q i) (f k) ≤ p, ∀ (i : ι'), BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k)))] [PROOFSTEP] rw [q.withSeminorms_iff_uniformSpace_eq_iInf.mp hq, uniformEquicontinuous_iInf_rng, equicontinuous_iInf_rng, equicontinuousAt_iInf_rng] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E u : UniformSpace F hu : UniformAddGroup F hq : WithSeminorms q inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F ⊢ TFAE [∀ (k : ι'), EquicontinuousAt (FunLike.coe ∘ f) 0, ∀ (k : ι'), Equicontinuous (FunLike.coe ∘ f), ∀ (k : ι'), UniformEquicontinuous (FunLike.coe ∘ f), ∀ (i : ι'), ∃ p, Continuous ↑p ∧ ∀ (k : κ), comp (q i) (f k) ≤ p, ∀ (i : ι'), BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k)))] [PROOFSTEP] refine forall_tfae [_, _, _, _, _] fun i ↦ ?_ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E u : UniformSpace F hu : UniformAddGroup F hq : WithSeminorms q inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F i : ι' ⊢ TFAE (List.map (fun p => p i) [fun k => EquicontinuousAt (FunLike.coe ∘ f) 0, fun k => Equicontinuous (FunLike.coe ∘ f), fun k => UniformEquicontinuous (FunLike.coe ∘ f), fun i => ∃ p, Continuous ↑p ∧ ∀ (k : κ), comp (q i) (f k) ≤ p, fun i => BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k)))]) [PROOFSTEP] let _ : SeminormedAddCommGroup F := (q i).toSeminormedAddCommGroup [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E u : UniformSpace F hu : UniformAddGroup F hq : WithSeminorms q inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F i : ι' x✝ : SeminormedAddCommGroup F := AddGroupSeminorm.toSeminormedAddCommGroup (q i).toAddGroupSeminorm ⊢ TFAE (List.map (fun p => p i) [fun k => EquicontinuousAt (FunLike.coe ∘ f) 0, fun k => Equicontinuous (FunLike.coe ∘ f), fun k => UniformEquicontinuous (FunLike.coe ∘ f), fun i => ∃ p, Continuous ↑p ∧ ∀ (k : κ), comp (q i) (f k) ≤ p, fun i => BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k)))]) [PROOFSTEP] clear u hu hq [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F i : ι' x✝ : SeminormedAddCommGroup F := AddGroupSeminorm.toSeminormedAddCommGroup (q i).toAddGroupSeminorm ⊢ TFAE (List.map (fun p => p i) [fun k => EquicontinuousAt (FunLike.coe ∘ f) 0, fun k => Equicontinuous (FunLike.coe ∘ f), fun k => UniformEquicontinuous (FunLike.coe ∘ f), fun i => ∃ p, Continuous ↑p ∧ ∀ (k : κ), comp (q i) (f k) ≤ p, fun i => BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k)))]) [PROOFSTEP] simp only [List.map] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F i : ι' x✝ : SeminormedAddCommGroup F := AddGroupSeminorm.toSeminormedAddCommGroup (q i).toAddGroupSeminorm ⊢ TFAE [EquicontinuousAt (FunLike.coe ∘ f) 0, Equicontinuous (FunLike.coe ∘ f), UniformEquicontinuous (FunLike.coe ∘ f), ∃ p, Continuous ↑p ∧ ∀ (k : κ), comp (q i) (f k) ≤ p, BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k)))] [PROOFSTEP] tfae_have 1 → 3 [GOAL] case tfae_1_to_3 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F i : ι' x✝ : SeminormedAddCommGroup F := AddGroupSeminorm.toSeminormedAddCommGroup (q i).toAddGroupSeminorm ⊢ EquicontinuousAt (FunLike.coe ∘ f) 0 → UniformEquicontinuous (FunLike.coe ∘ f) [PROOFSTEP] exact uniformEquicontinuous_of_equicontinuousAt_zero f [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F i : ι' x✝ : SeminormedAddCommGroup F := AddGroupSeminorm.toSeminormedAddCommGroup (q i).toAddGroupSeminorm tfae_1_to_3 : EquicontinuousAt (FunLike.coe ∘ f) 0 → UniformEquicontinuous (FunLike.coe ∘ f) ⊢ TFAE [EquicontinuousAt (FunLike.coe ∘ f) 0, Equicontinuous (FunLike.coe ∘ f), UniformEquicontinuous (FunLike.coe ∘ f), ∃ p, Continuous ↑p ∧ ∀ (k : κ), comp (q i) (f k) ≤ p, BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k)))] [PROOFSTEP] tfae_have 3 → 2 [GOAL] case tfae_3_to_2 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F i : ι' x✝ : SeminormedAddCommGroup F := AddGroupSeminorm.toSeminormedAddCommGroup (q i).toAddGroupSeminorm tfae_1_to_3 : EquicontinuousAt (FunLike.coe ∘ f) 0 → UniformEquicontinuous (FunLike.coe ∘ f) ⊢ UniformEquicontinuous (FunLike.coe ∘ f) → Equicontinuous (FunLike.coe ∘ f) [PROOFSTEP] exact UniformEquicontinuous.equicontinuous [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F i : ι' x✝ : SeminormedAddCommGroup F := AddGroupSeminorm.toSeminormedAddCommGroup (q i).toAddGroupSeminorm tfae_1_to_3 : EquicontinuousAt (FunLike.coe ∘ f) 0 → UniformEquicontinuous (FunLike.coe ∘ f) tfae_3_to_2 : UniformEquicontinuous (FunLike.coe ∘ f) → Equicontinuous (FunLike.coe ∘ f) ⊢ TFAE [EquicontinuousAt (FunLike.coe ∘ f) 0, Equicontinuous (FunLike.coe ∘ f), UniformEquicontinuous (FunLike.coe ∘ f), ∃ p, Continuous ↑p ∧ ∀ (k : κ), comp (q i) (f k) ≤ p, BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k)))] [PROOFSTEP] tfae_have 2 → 1 [GOAL] case tfae_2_to_1 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F i : ι' x✝ : SeminormedAddCommGroup F := AddGroupSeminorm.toSeminormedAddCommGroup (q i).toAddGroupSeminorm tfae_1_to_3 : EquicontinuousAt (FunLike.coe ∘ f) 0 → UniformEquicontinuous (FunLike.coe ∘ f) tfae_3_to_2 : UniformEquicontinuous (FunLike.coe ∘ f) → Equicontinuous (FunLike.coe ∘ f) ⊢ Equicontinuous (FunLike.coe ∘ f) → EquicontinuousAt (FunLike.coe ∘ f) 0 [PROOFSTEP] exact fun H ↦ H 0 [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F i : ι' x✝ : SeminormedAddCommGroup F := AddGroupSeminorm.toSeminormedAddCommGroup (q i).toAddGroupSeminorm tfae_1_to_3 : EquicontinuousAt (FunLike.coe ∘ f) 0 → UniformEquicontinuous (FunLike.coe ∘ f) tfae_3_to_2 : UniformEquicontinuous (FunLike.coe ∘ f) → Equicontinuous (FunLike.coe ∘ f) tfae_2_to_1 : Equicontinuous (FunLike.coe ∘ f) → EquicontinuousAt (FunLike.coe ∘ f) 0 ⊢ TFAE [EquicontinuousAt (FunLike.coe ∘ f) 0, Equicontinuous (FunLike.coe ∘ f), UniformEquicontinuous (FunLike.coe ∘ f), ∃ p, Continuous ↑p ∧ ∀ (k : κ), comp (q i) (f k) ≤ p, BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k)))] [PROOFSTEP] tfae_have 3 → 5 [GOAL] case tfae_3_to_5 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F i : ι' x✝ : SeminormedAddCommGroup F := AddGroupSeminorm.toSeminormedAddCommGroup (q i).toAddGroupSeminorm tfae_1_to_3 : EquicontinuousAt (FunLike.coe ∘ f) 0 → UniformEquicontinuous (FunLike.coe ∘ f) tfae_3_to_2 : UniformEquicontinuous (FunLike.coe ∘ f) → Equicontinuous (FunLike.coe ∘ f) tfae_2_to_1 : Equicontinuous (FunLike.coe ∘ f) → EquicontinuousAt (FunLike.coe ∘ f) 0 ⊢ UniformEquicontinuous (FunLike.coe ∘ f) → BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k))) [PROOFSTEP] intro H [GOAL] case tfae_3_to_5 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F i : ι' x✝ : SeminormedAddCommGroup F := AddGroupSeminorm.toSeminormedAddCommGroup (q i).toAddGroupSeminorm tfae_1_to_3 : EquicontinuousAt (FunLike.coe ∘ f) 0 → UniformEquicontinuous (FunLike.coe ∘ f) tfae_3_to_2 : UniformEquicontinuous (FunLike.coe ∘ f) → Equicontinuous (FunLike.coe ∘ f) tfae_2_to_1 : Equicontinuous (FunLike.coe ∘ f) → EquicontinuousAt (FunLike.coe ∘ f) 0 H : UniformEquicontinuous (FunLike.coe ∘ f) ⊢ BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k))) [PROOFSTEP] have : ∀ᶠ x in 𝓝 0, ∀ k, q i (f k x) ≤ 1 := by filter_upwards [Metric.equicontinuousAt_iff_right.mp (H.equicontinuous 0) 1 one_pos] with x hx k simpa using (hx k).le [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F i : ι' x✝ : SeminormedAddCommGroup F := AddGroupSeminorm.toSeminormedAddCommGroup (q i).toAddGroupSeminorm tfae_1_to_3 : EquicontinuousAt (FunLike.coe ∘ f) 0 → UniformEquicontinuous (FunLike.coe ∘ f) tfae_3_to_2 : UniformEquicontinuous (FunLike.coe ∘ f) → Equicontinuous (FunLike.coe ∘ f) tfae_2_to_1 : Equicontinuous (FunLike.coe ∘ f) → EquicontinuousAt (FunLike.coe ∘ f) 0 H : UniformEquicontinuous (FunLike.coe ∘ f) ⊢ ∀ᶠ (x : E) in 𝓝 0, ∀ (k : κ), ↑(q i) (↑(f k) x) ≤ 1 [PROOFSTEP] filter_upwards [Metric.equicontinuousAt_iff_right.mp (H.equicontinuous 0) 1 one_pos] with x hx k [GOAL] case h 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F i : ι' x✝ : SeminormedAddCommGroup F := AddGroupSeminorm.toSeminormedAddCommGroup (q i).toAddGroupSeminorm tfae_1_to_3 : EquicontinuousAt (FunLike.coe ∘ f) 0 → UniformEquicontinuous (FunLike.coe ∘ f) tfae_3_to_2 : UniformEquicontinuous (FunLike.coe ∘ f) → Equicontinuous (FunLike.coe ∘ f) tfae_2_to_1 : Equicontinuous (FunLike.coe ∘ f) → EquicontinuousAt (FunLike.coe ∘ f) 0 H : UniformEquicontinuous (FunLike.coe ∘ f) x : E hx : ∀ (i_1 : κ), dist ((FunLike.coe ∘ f) i_1 0) ((FunLike.coe ∘ f) i_1 x) < 1 k : κ ⊢ ↑(q i) (↑(f k) x) ≤ 1 [PROOFSTEP] simpa using (hx k).le [GOAL] case tfae_3_to_5 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F i : ι' x✝ : SeminormedAddCommGroup F := AddGroupSeminorm.toSeminormedAddCommGroup (q i).toAddGroupSeminorm tfae_1_to_3 : EquicontinuousAt (FunLike.coe ∘ f) 0 → UniformEquicontinuous (FunLike.coe ∘ f) tfae_3_to_2 : UniformEquicontinuous (FunLike.coe ∘ f) → Equicontinuous (FunLike.coe ∘ f) tfae_2_to_1 : Equicontinuous (FunLike.coe ∘ f) → EquicontinuousAt (FunLike.coe ∘ f) 0 H : UniformEquicontinuous (FunLike.coe ∘ f) this : ∀ᶠ (x : E) in 𝓝 0, ∀ (k : κ), ↑(q i) (↑(f k) x) ≤ 1 ⊢ BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k))) [PROOFSTEP] have bdd : BddAbove (range fun k ↦ (q i).comp (f k)) := Seminorm.bddAbove_of_absorbent (absorbent_nhds_zero this) (fun x hx ↦ ⟨1, forall_range_iff.mpr hx⟩) [GOAL] case tfae_3_to_5 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F i : ι' x✝ : SeminormedAddCommGroup F := AddGroupSeminorm.toSeminormedAddCommGroup (q i).toAddGroupSeminorm tfae_1_to_3 : EquicontinuousAt (FunLike.coe ∘ f) 0 → UniformEquicontinuous (FunLike.coe ∘ f) tfae_3_to_2 : UniformEquicontinuous (FunLike.coe ∘ f) → Equicontinuous (FunLike.coe ∘ f) tfae_2_to_1 : Equicontinuous (FunLike.coe ∘ f) → EquicontinuousAt (FunLike.coe ∘ f) 0 H : UniformEquicontinuous (FunLike.coe ∘ f) this : ∀ᶠ (x : E) in 𝓝 0, ∀ (k : κ), ↑(q i) (↑(f k) x) ≤ 1 bdd : BddAbove (Set.range fun k => comp (q i) (f k)) ⊢ BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k))) [PROOFSTEP] rw [← Seminorm.coe_iSup_eq bdd] [GOAL] case tfae_3_to_5 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F i : ι' x✝ : SeminormedAddCommGroup F := AddGroupSeminorm.toSeminormedAddCommGroup (q i).toAddGroupSeminorm tfae_1_to_3 : EquicontinuousAt (FunLike.coe ∘ f) 0 → UniformEquicontinuous (FunLike.coe ∘ f) tfae_3_to_2 : UniformEquicontinuous (FunLike.coe ∘ f) → Equicontinuous (FunLike.coe ∘ f) tfae_2_to_1 : Equicontinuous (FunLike.coe ∘ f) → EquicontinuousAt (FunLike.coe ∘ f) 0 H : UniformEquicontinuous (FunLike.coe ∘ f) this : ∀ᶠ (x : E) in 𝓝 0, ∀ (k : κ), ↑(q i) (↑(f k) x) ≤ 1 bdd : BddAbove (Set.range fun k => comp (q i) (f k)) ⊢ BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous ↑(⨆ (i_1 : κ), comp (q i) (f i_1)) [PROOFSTEP] refine ⟨bdd, Seminorm.continuous' (r := 1) ?_⟩ [GOAL] case tfae_3_to_5 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F i : ι' x✝ : SeminormedAddCommGroup F := AddGroupSeminorm.toSeminormedAddCommGroup (q i).toAddGroupSeminorm tfae_1_to_3 : EquicontinuousAt (FunLike.coe ∘ f) 0 → UniformEquicontinuous (FunLike.coe ∘ f) tfae_3_to_2 : UniformEquicontinuous (FunLike.coe ∘ f) → Equicontinuous (FunLike.coe ∘ f) tfae_2_to_1 : Equicontinuous (FunLike.coe ∘ f) → EquicontinuousAt (FunLike.coe ∘ f) 0 H : UniformEquicontinuous (FunLike.coe ∘ f) this : ∀ᶠ (x : E) in 𝓝 0, ∀ (k : κ), ↑(q i) (↑(f k) x) ≤ 1 bdd : BddAbove (Set.range fun k => comp (q i) (f k)) ⊢ closedBall (⨆ (i_1 : κ), comp (q i) (f i_1)) 0 1 ∈ 𝓝 0 [PROOFSTEP] filter_upwards [this] with x hx [GOAL] case h 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F i : ι' x✝ : SeminormedAddCommGroup F := AddGroupSeminorm.toSeminormedAddCommGroup (q i).toAddGroupSeminorm tfae_1_to_3 : EquicontinuousAt (FunLike.coe ∘ f) 0 → UniformEquicontinuous (FunLike.coe ∘ f) tfae_3_to_2 : UniformEquicontinuous (FunLike.coe ∘ f) → Equicontinuous (FunLike.coe ∘ f) tfae_2_to_1 : Equicontinuous (FunLike.coe ∘ f) → EquicontinuousAt (FunLike.coe ∘ f) 0 H : UniformEquicontinuous (FunLike.coe ∘ f) this : ∀ᶠ (x : E) in 𝓝 0, ∀ (k : κ), ↑(q i) (↑(f k) x) ≤ 1 bdd : BddAbove (Set.range fun k => comp (q i) (f k)) x : E hx : ∀ (k : κ), ↑(q i) (↑(f k) x) ≤ 1 ⊢ x ∈ closedBall (⨆ (i_1 : κ), comp (q i) (f i_1)) 0 1 [PROOFSTEP] simpa only [closedBall_iSup bdd _ one_pos, mem_iInter, mem_closedBall_zero] using hx [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F i : ι' x✝ : SeminormedAddCommGroup F := AddGroupSeminorm.toSeminormedAddCommGroup (q i).toAddGroupSeminorm tfae_1_to_3 : EquicontinuousAt (FunLike.coe ∘ f) 0 → UniformEquicontinuous (FunLike.coe ∘ f) tfae_3_to_2 : UniformEquicontinuous (FunLike.coe ∘ f) → Equicontinuous (FunLike.coe ∘ f) tfae_2_to_1 : Equicontinuous (FunLike.coe ∘ f) → EquicontinuousAt (FunLike.coe ∘ f) 0 tfae_3_to_5 : UniformEquicontinuous (FunLike.coe ∘ f) → BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k))) ⊢ TFAE [EquicontinuousAt (FunLike.coe ∘ f) 0, Equicontinuous (FunLike.coe ∘ f), UniformEquicontinuous (FunLike.coe ∘ f), ∃ p, Continuous ↑p ∧ ∀ (k : κ), comp (q i) (f k) ≤ p, BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k)))] [PROOFSTEP] tfae_have 5 → 4 [GOAL] case tfae_5_to_4 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F i : ι' x✝ : SeminormedAddCommGroup F := AddGroupSeminorm.toSeminormedAddCommGroup (q i).toAddGroupSeminorm tfae_1_to_3 : EquicontinuousAt (FunLike.coe ∘ f) 0 → UniformEquicontinuous (FunLike.coe ∘ f) tfae_3_to_2 : UniformEquicontinuous (FunLike.coe ∘ f) → Equicontinuous (FunLike.coe ∘ f) tfae_2_to_1 : Equicontinuous (FunLike.coe ∘ f) → EquicontinuousAt (FunLike.coe ∘ f) 0 tfae_3_to_5 : UniformEquicontinuous (FunLike.coe ∘ f) → BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k))) ⊢ BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k))) → ∃ p, Continuous ↑p ∧ ∀ (k : κ), comp (q i) (f k) ≤ p [PROOFSTEP] exact fun H ↦ ⟨⨆ k, (q i).comp (f k), Seminorm.coe_iSup_eq H.1 ▸ H.2, le_ciSup H.1⟩ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F i : ι' x✝ : SeminormedAddCommGroup F := AddGroupSeminorm.toSeminormedAddCommGroup (q i).toAddGroupSeminorm tfae_1_to_3 : EquicontinuousAt (FunLike.coe ∘ f) 0 → UniformEquicontinuous (FunLike.coe ∘ f) tfae_3_to_2 : UniformEquicontinuous (FunLike.coe ∘ f) → Equicontinuous (FunLike.coe ∘ f) tfae_2_to_1 : Equicontinuous (FunLike.coe ∘ f) → EquicontinuousAt (FunLike.coe ∘ f) 0 tfae_3_to_5 : UniformEquicontinuous (FunLike.coe ∘ f) → BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k))) tfae_5_to_4 : BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k))) → ∃ p, Continuous ↑p ∧ ∀ (k : κ), comp (q i) (f k) ≤ p ⊢ TFAE [EquicontinuousAt (FunLike.coe ∘ f) 0, Equicontinuous (FunLike.coe ∘ f), UniformEquicontinuous (FunLike.coe ∘ f), ∃ p, Continuous ↑p ∧ ∀ (k : κ), comp (q i) (f k) ≤ p, BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k)))] [PROOFSTEP] tfae_have 4 → 1 -- This would work over any `NormedField` [GOAL] case tfae_4_to_1 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F i : ι' x✝ : SeminormedAddCommGroup F := AddGroupSeminorm.toSeminormedAddCommGroup (q i).toAddGroupSeminorm tfae_1_to_3 : EquicontinuousAt (FunLike.coe ∘ f) 0 → UniformEquicontinuous (FunLike.coe ∘ f) tfae_3_to_2 : UniformEquicontinuous (FunLike.coe ∘ f) → Equicontinuous (FunLike.coe ∘ f) tfae_2_to_1 : Equicontinuous (FunLike.coe ∘ f) → EquicontinuousAt (FunLike.coe ∘ f) 0 tfae_3_to_5 : UniformEquicontinuous (FunLike.coe ∘ f) → BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k))) tfae_5_to_4 : BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k))) → ∃ p, Continuous ↑p ∧ ∀ (k : κ), comp (q i) (f k) ≤ p ⊢ (∃ p, Continuous ↑p ∧ ∀ (k : κ), comp (q i) (f k) ≤ p) → EquicontinuousAt (FunLike.coe ∘ f) 0 [PROOFSTEP] intro ⟨p, hp, hfp⟩ [GOAL] case tfae_4_to_1 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F i : ι' x✝ : SeminormedAddCommGroup F := AddGroupSeminorm.toSeminormedAddCommGroup (q i).toAddGroupSeminorm tfae_1_to_3 : EquicontinuousAt (FunLike.coe ∘ f) 0 → UniformEquicontinuous (FunLike.coe ∘ f) tfae_3_to_2 : UniformEquicontinuous (FunLike.coe ∘ f) → Equicontinuous (FunLike.coe ∘ f) tfae_2_to_1 : Equicontinuous (FunLike.coe ∘ f) → EquicontinuousAt (FunLike.coe ∘ f) 0 tfae_3_to_5 : UniformEquicontinuous (FunLike.coe ∘ f) → BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k))) tfae_5_to_4 : BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k))) → ∃ p, Continuous ↑p ∧ ∀ (k : κ), comp (q i) (f k) ≤ p p : Seminorm 𝕜 E hp : Continuous ↑p hfp : ∀ (k : κ), comp (q i) (f k) ≤ p ⊢ EquicontinuousAt (FunLike.coe ∘ f) 0 [PROOFSTEP] exact Metric.equicontinuousAt_of_continuity_modulus p (map_zero p ▸ hp.tendsto 0) _ <| eventually_of_forall fun x k ↦ by simpa using hfp k x [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F i : ι' x✝ : SeminormedAddCommGroup F := AddGroupSeminorm.toSeminormedAddCommGroup (q i).toAddGroupSeminorm tfae_1_to_3 : EquicontinuousAt (FunLike.coe ∘ f) 0 → UniformEquicontinuous (FunLike.coe ∘ f) tfae_3_to_2 : UniformEquicontinuous (FunLike.coe ∘ f) → Equicontinuous (FunLike.coe ∘ f) tfae_2_to_1 : Equicontinuous (FunLike.coe ∘ f) → EquicontinuousAt (FunLike.coe ∘ f) 0 tfae_3_to_5 : UniformEquicontinuous (FunLike.coe ∘ f) → BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k))) tfae_5_to_4 : BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k))) → ∃ p, Continuous ↑p ∧ ∀ (k : κ), comp (q i) (f k) ≤ p p : Seminorm 𝕜 E hp : Continuous ↑p hfp : ∀ (k : κ), comp (q i) (f k) ≤ p x : E k : κ ⊢ dist ((FunLike.coe ∘ f) k 0) ((FunLike.coe ∘ f) k x) ≤ ↑p x [PROOFSTEP] simpa using hfp k x [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁶ : NontriviallyNormedField 𝕜 inst✝¹⁵ : AddCommGroup E inst✝¹⁴ : Module 𝕜 E inst✝¹³ : NormedField 𝕝 inst✝¹² : Module 𝕝 E inst✝¹¹ : NontriviallyNormedField 𝕜₂ inst✝¹⁰ : AddCommGroup F inst✝⁹ : Module 𝕜₂ F inst✝⁸ : NormedField 𝕝₂ inst✝⁷ : Module 𝕝₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁶ : RingHomIsometric σ₁₂ τ₁₂ : 𝕝 →+* 𝕝₂ inst✝⁵ : RingHomIsometric τ₁₂ inst✝⁴ : Nonempty ι inst✝³ : Nonempty ι' κ : Type u_10 q : SeminormFamily 𝕜₂ F ι' inst✝² : UniformSpace E inst✝¹ : UniformAddGroup E inst✝ : ContinuousSMul 𝕜 E f : κ → E →ₛₗ[σ₁₂] F i : ι' x✝ : SeminormedAddCommGroup F := AddGroupSeminorm.toSeminormedAddCommGroup (q i).toAddGroupSeminorm tfae_1_to_3 : EquicontinuousAt (FunLike.coe ∘ f) 0 → UniformEquicontinuous (FunLike.coe ∘ f) tfae_3_to_2 : UniformEquicontinuous (FunLike.coe ∘ f) → Equicontinuous (FunLike.coe ∘ f) tfae_2_to_1 : Equicontinuous (FunLike.coe ∘ f) → EquicontinuousAt (FunLike.coe ∘ f) 0 tfae_3_to_5 : UniformEquicontinuous (FunLike.coe ∘ f) → BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k))) tfae_5_to_4 : BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k))) → ∃ p, Continuous ↑p ∧ ∀ (k : κ), comp (q i) (f k) ≤ p tfae_4_to_1 : (∃ p, Continuous ↑p ∧ ∀ (k : κ), comp (q i) (f k) ≤ p) → EquicontinuousAt (FunLike.coe ∘ f) 0 ⊢ TFAE [EquicontinuousAt (FunLike.coe ∘ f) 0, Equicontinuous (FunLike.coe ∘ f), UniformEquicontinuous (FunLike.coe ∘ f), ∃ p, Continuous ↑p ∧ ∀ (k : κ), comp (q i) (f k) ≤ p, BddAbove (Set.range fun k => comp (q i) (f k)) ∧ Continuous (⨆ (k : κ), ↑(comp (q i) (f k)))] [PROOFSTEP] tfae_finish [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁸ : Nonempty ι inst✝⁷ : Nonempty ι' inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : SeminormFamily 𝕜 E ι q : SeminormFamily 𝕜 E ι' t : TopologicalSpace E hp : WithSeminorms p hpq : Seminorm.IsBounded p q LinearMap.id hqp : Seminorm.IsBounded q p LinearMap.id ⊢ WithSeminorms q [PROOFSTEP] constructor [GOAL] case topology_eq_withSeminorms 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁸ : Nonempty ι inst✝⁷ : Nonempty ι' inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : SeminormFamily 𝕜 E ι q : SeminormFamily 𝕜 E ι' t : TopologicalSpace E hp : WithSeminorms p hpq : Seminorm.IsBounded p q LinearMap.id hqp : Seminorm.IsBounded q p LinearMap.id ⊢ t = ModuleFilterBasis.topology (SeminormFamily.moduleFilterBasis q) [PROOFSTEP] rw [hp.topology_eq_withSeminorms] [GOAL] case topology_eq_withSeminorms 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁸ : Nonempty ι inst✝⁷ : Nonempty ι' inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : SeminormFamily 𝕜 E ι q : SeminormFamily 𝕜 E ι' t : TopologicalSpace E hp : WithSeminorms p hpq : Seminorm.IsBounded p q LinearMap.id hqp : Seminorm.IsBounded q p LinearMap.id ⊢ ModuleFilterBasis.topology (SeminormFamily.moduleFilterBasis p) = ModuleFilterBasis.topology (SeminormFamily.moduleFilterBasis q) [PROOFSTEP] clear hp t [GOAL] case topology_eq_withSeminorms 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁸ : Nonempty ι inst✝⁷ : Nonempty ι' inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : SeminormFamily 𝕜 E ι q : SeminormFamily 𝕜 E ι' hpq : Seminorm.IsBounded p q LinearMap.id hqp : Seminorm.IsBounded q p LinearMap.id ⊢ ModuleFilterBasis.topology (SeminormFamily.moduleFilterBasis p) = ModuleFilterBasis.topology (SeminormFamily.moduleFilterBasis q) [PROOFSTEP] refine le_antisymm ?_ ?_ [GOAL] case topology_eq_withSeminorms.refine_1 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁸ : Nonempty ι inst✝⁷ : Nonempty ι' inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : SeminormFamily 𝕜 E ι q : SeminormFamily 𝕜 E ι' hpq : Seminorm.IsBounded p q LinearMap.id hqp : Seminorm.IsBounded q p LinearMap.id ⊢ ModuleFilterBasis.topology (SeminormFamily.moduleFilterBasis p) ≤ ModuleFilterBasis.topology (SeminormFamily.moduleFilterBasis q) [PROOFSTEP] rw [← continuous_id_iff_le] [GOAL] case topology_eq_withSeminorms.refine_2 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁸ : Nonempty ι inst✝⁷ : Nonempty ι' inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : SeminormFamily 𝕜 E ι q : SeminormFamily 𝕜 E ι' hpq : Seminorm.IsBounded p q LinearMap.id hqp : Seminorm.IsBounded q p LinearMap.id ⊢ ModuleFilterBasis.topology (SeminormFamily.moduleFilterBasis q) ≤ ModuleFilterBasis.topology (SeminormFamily.moduleFilterBasis p) [PROOFSTEP] rw [← continuous_id_iff_le] [GOAL] case topology_eq_withSeminorms.refine_1 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁸ : Nonempty ι inst✝⁷ : Nonempty ι' inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : SeminormFamily 𝕜 E ι q : SeminormFamily 𝕜 E ι' hpq : Seminorm.IsBounded p q LinearMap.id hqp : Seminorm.IsBounded q p LinearMap.id ⊢ Continuous id [PROOFSTEP] refine continuous_from_bounded (.mk (topology := _) rfl) (.mk (topology := _) rfl) LinearMap.id (by assumption) [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁸ : Nonempty ι inst✝⁷ : Nonempty ι' inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : SeminormFamily 𝕜 E ι q : SeminormFamily 𝕜 E ι' hpq : Seminorm.IsBounded p q LinearMap.id hqp : Seminorm.IsBounded q p LinearMap.id ⊢ Seminorm.IsBounded p q LinearMap.id [PROOFSTEP] assumption [GOAL] case topology_eq_withSeminorms.refine_2 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁸ : Nonempty ι inst✝⁷ : Nonempty ι' inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : SeminormFamily 𝕜 E ι q : SeminormFamily 𝕜 E ι' hpq : Seminorm.IsBounded p q LinearMap.id hqp : Seminorm.IsBounded q p LinearMap.id ⊢ Continuous id [PROOFSTEP] refine continuous_from_bounded (.mk (topology := _) rfl) (.mk (topology := _) rfl) LinearMap.id (by assumption) [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁸ : Nonempty ι inst✝⁷ : Nonempty ι' inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : SeminormFamily 𝕜 E ι q : SeminormFamily 𝕜 E ι' hpq : Seminorm.IsBounded p q LinearMap.id hqp : Seminorm.IsBounded q p LinearMap.id ⊢ Seminorm.IsBounded q p LinearMap.id [PROOFSTEP] assumption [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁹ : Nonempty ι inst✝⁸ : Nonempty ι' inst✝⁷ : NormedField 𝕜 inst✝⁶ : AddCommGroup E inst✝⁵ : Module 𝕜 E inst✝⁴ : NormedField 𝕜₂ inst✝³ : AddCommGroup F inst✝² : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝¹ : RingHomIsometric σ₁₂ p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E hp : WithSeminorms p ⊢ WithSeminorms fun s => Finset.sup s p [PROOFSTEP] refine hp.congr ?_ ?_ [GOAL] case refine_1 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁹ : Nonempty ι inst✝⁸ : Nonempty ι' inst✝⁷ : NormedField 𝕜 inst✝⁶ : AddCommGroup E inst✝⁵ : Module 𝕜 E inst✝⁴ : NormedField 𝕜₂ inst✝³ : AddCommGroup F inst✝² : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝¹ : RingHomIsometric σ₁₂ p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E hp : WithSeminorms p ⊢ Seminorm.IsBounded p (fun s => Finset.sup s p) LinearMap.id [PROOFSTEP] intro s [GOAL] case refine_1 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁹ : Nonempty ι inst✝⁸ : Nonempty ι' inst✝⁷ : NormedField 𝕜 inst✝⁶ : AddCommGroup E inst✝⁵ : Module 𝕜 E inst✝⁴ : NormedField 𝕜₂ inst✝³ : AddCommGroup F inst✝² : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝¹ : RingHomIsometric σ₁₂ p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E hp : WithSeminorms p s : Finset ι ⊢ ∃ s_1 C, comp ((fun s => Finset.sup s p) s) LinearMap.id ≤ C • Finset.sup s_1 p [PROOFSTEP] refine ⟨s, 1, ?_⟩ [GOAL] case refine_1 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁹ : Nonempty ι inst✝⁸ : Nonempty ι' inst✝⁷ : NormedField 𝕜 inst✝⁶ : AddCommGroup E inst✝⁵ : Module 𝕜 E inst✝⁴ : NormedField 𝕜₂ inst✝³ : AddCommGroup F inst✝² : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝¹ : RingHomIsometric σ₁₂ p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E hp : WithSeminorms p s : Finset ι ⊢ comp ((fun s => Finset.sup s p) s) LinearMap.id ≤ 1 • Finset.sup s p [PROOFSTEP] rw [one_smul] [GOAL] case refine_1 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁹ : Nonempty ι inst✝⁸ : Nonempty ι' inst✝⁷ : NormedField 𝕜 inst✝⁶ : AddCommGroup E inst✝⁵ : Module 𝕜 E inst✝⁴ : NormedField 𝕜₂ inst✝³ : AddCommGroup F inst✝² : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝¹ : RingHomIsometric σ₁₂ p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E hp : WithSeminorms p s : Finset ι ⊢ comp ((fun s => Finset.sup s p) s) LinearMap.id ≤ Finset.sup s p [PROOFSTEP] rfl [GOAL] case refine_2 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁹ : Nonempty ι inst✝⁸ : Nonempty ι' inst✝⁷ : NormedField 𝕜 inst✝⁶ : AddCommGroup E inst✝⁵ : Module 𝕜 E inst✝⁴ : NormedField 𝕜₂ inst✝³ : AddCommGroup F inst✝² : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝¹ : RingHomIsometric σ₁₂ p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E hp : WithSeminorms p ⊢ Seminorm.IsBounded (fun s => Finset.sup s p) p LinearMap.id [PROOFSTEP] intro i [GOAL] case refine_2 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁹ : Nonempty ι inst✝⁸ : Nonempty ι' inst✝⁷ : NormedField 𝕜 inst✝⁶ : AddCommGroup E inst✝⁵ : Module 𝕜 E inst✝⁴ : NormedField 𝕜₂ inst✝³ : AddCommGroup F inst✝² : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝¹ : RingHomIsometric σ₁₂ p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E hp : WithSeminorms p i : ι ⊢ ∃ s C, comp (p i) LinearMap.id ≤ C • Finset.sup s fun s => Finset.sup s p [PROOFSTEP] refine ⟨{{ i }}, 1, ?_⟩ [GOAL] case refine_2 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁹ : Nonempty ι inst✝⁸ : Nonempty ι' inst✝⁷ : NormedField 𝕜 inst✝⁶ : AddCommGroup E inst✝⁵ : Module 𝕜 E inst✝⁴ : NormedField 𝕜₂ inst✝³ : AddCommGroup F inst✝² : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝¹ : RingHomIsometric σ₁₂ p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E hp : WithSeminorms p i : ι ⊢ comp (p i) LinearMap.id ≤ 1 • Finset.sup {{i}} fun s => Finset.sup s p [PROOFSTEP] rw [Finset.sup_singleton, Finset.sup_singleton, one_smul] [GOAL] case refine_2 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁹ : Nonempty ι inst✝⁸ : Nonempty ι' inst✝⁷ : NormedField 𝕜 inst✝⁶ : AddCommGroup E inst✝⁵ : Module 𝕜 E inst✝⁴ : NormedField 𝕜₂ inst✝³ : AddCommGroup F inst✝² : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝¹ : RingHomIsometric σ₁₂ p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E hp : WithSeminorms p i : ι ⊢ comp (p i) LinearMap.id ≤ p i [PROOFSTEP] rfl [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹¹ : Nonempty ι inst✝¹⁰ : Nonempty ι' inst✝⁹ : NormedField 𝕜 inst✝⁸ : AddCommGroup E inst✝⁷ : Module 𝕜 E inst✝⁶ : NormedField 𝕜₂ inst✝⁵ : AddCommGroup F inst✝⁴ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝³ : RingHomIsometric σ₁₂ inst✝² : Preorder ι inst✝¹ : LocallyFiniteOrderBot ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E hp : WithSeminorms p ⊢ WithSeminorms fun i => Finset.sup (Finset.Iic i) p [PROOFSTEP] refine hp.congr ?_ ?_ [GOAL] case refine_1 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹¹ : Nonempty ι inst✝¹⁰ : Nonempty ι' inst✝⁹ : NormedField 𝕜 inst✝⁸ : AddCommGroup E inst✝⁷ : Module 𝕜 E inst✝⁶ : NormedField 𝕜₂ inst✝⁵ : AddCommGroup F inst✝⁴ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝³ : RingHomIsometric σ₁₂ inst✝² : Preorder ι inst✝¹ : LocallyFiniteOrderBot ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E hp : WithSeminorms p ⊢ Seminorm.IsBounded p (fun i => Finset.sup (Finset.Iic i) p) LinearMap.id [PROOFSTEP] intro i [GOAL] case refine_1 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹¹ : Nonempty ι inst✝¹⁰ : Nonempty ι' inst✝⁹ : NormedField 𝕜 inst✝⁸ : AddCommGroup E inst✝⁷ : Module 𝕜 E inst✝⁶ : NormedField 𝕜₂ inst✝⁵ : AddCommGroup F inst✝⁴ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝³ : RingHomIsometric σ₁₂ inst✝² : Preorder ι inst✝¹ : LocallyFiniteOrderBot ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E hp : WithSeminorms p i : ι ⊢ ∃ s C, comp ((fun i => Finset.sup (Finset.Iic i) p) i) LinearMap.id ≤ C • Finset.sup s p [PROOFSTEP] refine ⟨Finset.Iic i, 1, ?_⟩ [GOAL] case refine_1 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹¹ : Nonempty ι inst✝¹⁰ : Nonempty ι' inst✝⁹ : NormedField 𝕜 inst✝⁸ : AddCommGroup E inst✝⁷ : Module 𝕜 E inst✝⁶ : NormedField 𝕜₂ inst✝⁵ : AddCommGroup F inst✝⁴ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝³ : RingHomIsometric σ₁₂ inst✝² : Preorder ι inst✝¹ : LocallyFiniteOrderBot ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E hp : WithSeminorms p i : ι ⊢ comp ((fun i => Finset.sup (Finset.Iic i) p) i) LinearMap.id ≤ 1 • Finset.sup (Finset.Iic i) p [PROOFSTEP] rw [one_smul] [GOAL] case refine_1 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹¹ : Nonempty ι inst✝¹⁰ : Nonempty ι' inst✝⁹ : NormedField 𝕜 inst✝⁸ : AddCommGroup E inst✝⁷ : Module 𝕜 E inst✝⁶ : NormedField 𝕜₂ inst✝⁵ : AddCommGroup F inst✝⁴ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝³ : RingHomIsometric σ₁₂ inst✝² : Preorder ι inst✝¹ : LocallyFiniteOrderBot ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E hp : WithSeminorms p i : ι ⊢ comp ((fun i => Finset.sup (Finset.Iic i) p) i) LinearMap.id ≤ Finset.sup (Finset.Iic i) p [PROOFSTEP] rfl [GOAL] case refine_2 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹¹ : Nonempty ι inst✝¹⁰ : Nonempty ι' inst✝⁹ : NormedField 𝕜 inst✝⁸ : AddCommGroup E inst✝⁷ : Module 𝕜 E inst✝⁶ : NormedField 𝕜₂ inst✝⁵ : AddCommGroup F inst✝⁴ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝³ : RingHomIsometric σ₁₂ inst✝² : Preorder ι inst✝¹ : LocallyFiniteOrderBot ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E hp : WithSeminorms p ⊢ Seminorm.IsBounded (fun i => Finset.sup (Finset.Iic i) p) p LinearMap.id [PROOFSTEP] intro i [GOAL] case refine_2 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹¹ : Nonempty ι inst✝¹⁰ : Nonempty ι' inst✝⁹ : NormedField 𝕜 inst✝⁸ : AddCommGroup E inst✝⁷ : Module 𝕜 E inst✝⁶ : NormedField 𝕜₂ inst✝⁵ : AddCommGroup F inst✝⁴ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝³ : RingHomIsometric σ₁₂ inst✝² : Preorder ι inst✝¹ : LocallyFiniteOrderBot ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E hp : WithSeminorms p i : ι ⊢ ∃ s C, comp (p i) LinearMap.id ≤ C • Finset.sup s fun i => Finset.sup (Finset.Iic i) p [PROOFSTEP] refine ⟨{ i }, 1, ?_⟩ [GOAL] case refine_2 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹¹ : Nonempty ι inst✝¹⁰ : Nonempty ι' inst✝⁹ : NormedField 𝕜 inst✝⁸ : AddCommGroup E inst✝⁷ : Module 𝕜 E inst✝⁶ : NormedField 𝕜₂ inst✝⁵ : AddCommGroup F inst✝⁴ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝³ : RingHomIsometric σ₁₂ inst✝² : Preorder ι inst✝¹ : LocallyFiniteOrderBot ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E hp : WithSeminorms p i : ι ⊢ comp (p i) LinearMap.id ≤ 1 • Finset.sup {i} fun i => Finset.sup (Finset.Iic i) p [PROOFSTEP] rw [Finset.sup_singleton, one_smul] [GOAL] case refine_2 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹¹ : Nonempty ι inst✝¹⁰ : Nonempty ι' inst✝⁹ : NormedField 𝕜 inst✝⁸ : AddCommGroup E inst✝⁷ : Module 𝕜 E inst✝⁶ : NormedField 𝕜₂ inst✝⁵ : AddCommGroup F inst✝⁴ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝³ : RingHomIsometric σ₁₂ inst✝² : Preorder ι inst✝¹ : LocallyFiniteOrderBot ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E hp : WithSeminorms p i : ι ⊢ comp (p i) LinearMap.id ≤ Finset.sup (Finset.Iic i) p [PROOFSTEP] exact (Finset.le_sup (Finset.mem_Iic.mpr le_rfl) : p i ≤ (Finset.Iic i).sup p) [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁸ : Nonempty ι inst✝⁷ : Nonempty ι' inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : SeminormFamily 𝕜 E ι t : TopologicalSpace E hp : WithSeminorms p e : ι' ≃ ι ⊢ WithSeminorms (p ∘ ↑e) [PROOFSTEP] refine hp.congr ?_ ?_ <;> intro i <;> [use{e i}, 1; use{e.symm i}, 1] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁸ : Nonempty ι inst✝⁷ : Nonempty ι' inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : SeminormFamily 𝕜 E ι t : TopologicalSpace E hp : WithSeminorms p e : ι' ≃ ι ⊢ WithSeminorms (p ∘ ↑e) [PROOFSTEP] refine hp.congr ?_ ?_ [GOAL] case refine_1 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁸ : Nonempty ι inst✝⁷ : Nonempty ι' inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : SeminormFamily 𝕜 E ι t : TopologicalSpace E hp : WithSeminorms p e : ι' ≃ ι ⊢ Seminorm.IsBounded p (p ∘ ↑e) LinearMap.id [PROOFSTEP] intro i [GOAL] case refine_2 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁸ : Nonempty ι inst✝⁷ : Nonempty ι' inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : SeminormFamily 𝕜 E ι t : TopologicalSpace E hp : WithSeminorms p e : ι' ≃ ι ⊢ Seminorm.IsBounded (p ∘ ↑e) p LinearMap.id [PROOFSTEP] intro i [GOAL] case refine_1 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁸ : Nonempty ι inst✝⁷ : Nonempty ι' inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : SeminormFamily 𝕜 E ι t : TopologicalSpace E hp : WithSeminorms p e : ι' ≃ ι i : ι' ⊢ ∃ s C, comp ((p ∘ ↑e) i) LinearMap.id ≤ C • Finset.sup s p [PROOFSTEP] use{e i}, 1 [GOAL] case refine_2 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁸ : Nonempty ι inst✝⁷ : Nonempty ι' inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : SeminormFamily 𝕜 E ι t : TopologicalSpace E hp : WithSeminorms p e : ι' ≃ ι i : ι ⊢ ∃ s C, comp (p i) LinearMap.id ≤ C • Finset.sup s (p ∘ ↑e) [PROOFSTEP] use{e.symm i}, 1 [GOAL] case h 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁸ : Nonempty ι inst✝⁷ : Nonempty ι' inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : SeminormFamily 𝕜 E ι t : TopologicalSpace E hp : WithSeminorms p e : ι' ≃ ι i : ι' ⊢ comp ((p ∘ ↑e) i) LinearMap.id ≤ 1 • Finset.sup {↑e i} p [PROOFSTEP] simp [GOAL] case h 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁸ : Nonempty ι inst✝⁷ : Nonempty ι' inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ p : SeminormFamily 𝕜 E ι t : TopologicalSpace E hp : WithSeminorms p e : ι' ≃ ι i : ι ⊢ comp (p i) LinearMap.id ≤ 1 • Finset.sup {↑e.symm i} (p ∘ ↑e) [PROOFSTEP] simp [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : SeminormedAddCommGroup F inst✝ : NormedSpace 𝕜 F p : SeminormFamily 𝕜 E ι q : Seminorm 𝕜 F hq : Continuous ↑q ⊢ ∃ C, 0 < C ∧ ∀ (x : F), ↑q x ≤ C * ‖x‖ [PROOFSTEP] have hq' : Tendsto q (𝓝 0) (𝓝 0) := map_zero q ▸ hq.tendsto 0 [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : SeminormedAddCommGroup F inst✝ : NormedSpace 𝕜 F p : SeminormFamily 𝕜 E ι q : Seminorm 𝕜 F hq : Continuous ↑q hq' : Tendsto (↑q) (𝓝 0) (𝓝 0) ⊢ ∃ C, 0 < C ∧ ∀ (x : F), ↑q x ≤ C * ‖x‖ [PROOFSTEP] rcases NormedAddCommGroup.nhds_zero_basis_norm_lt.mem_iff.mp (hq' $ Iio_mem_nhds one_pos) with ⟨ε, ε_pos, hε⟩ [GOAL] case intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : SeminormedAddCommGroup F inst✝ : NormedSpace 𝕜 F p : SeminormFamily 𝕜 E ι q : Seminorm 𝕜 F hq : Continuous ↑q hq' : Tendsto (↑q) (𝓝 0) (𝓝 0) ε : ℝ ε_pos : 0 < ε hε : {y | ‖y‖ < ε} ⊆ ↑q ⁻¹' Iio 1 ⊢ ∃ C, 0 < C ∧ ∀ (x : F), ↑q x ≤ C * ‖x‖ [PROOFSTEP] rcases NormedField.exists_one_lt_norm 𝕜 with ⟨c, hc⟩ [GOAL] case intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : SeminormedAddCommGroup F inst✝ : NormedSpace 𝕜 F p : SeminormFamily 𝕜 E ι q : Seminorm 𝕜 F hq : Continuous ↑q hq' : Tendsto (↑q) (𝓝 0) (𝓝 0) ε : ℝ ε_pos : 0 < ε hε : {y | ‖y‖ < ε} ⊆ ↑q ⁻¹' Iio 1 c : 𝕜 hc : 1 < ‖c‖ ⊢ ∃ C, 0 < C ∧ ∀ (x : F), ↑q x ≤ C * ‖x‖ [PROOFSTEP] have : 0 < ‖c‖ / ε := by positivity [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : SeminormedAddCommGroup F inst✝ : NormedSpace 𝕜 F p : SeminormFamily 𝕜 E ι q : Seminorm 𝕜 F hq : Continuous ↑q hq' : Tendsto (↑q) (𝓝 0) (𝓝 0) ε : ℝ ε_pos : 0 < ε hε : {y | ‖y‖ < ε} ⊆ ↑q ⁻¹' Iio 1 c : 𝕜 hc : 1 < ‖c‖ ⊢ 0 < ‖c‖ / ε [PROOFSTEP] positivity [GOAL] case intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : SeminormedAddCommGroup F inst✝ : NormedSpace 𝕜 F p : SeminormFamily 𝕜 E ι q : Seminorm 𝕜 F hq : Continuous ↑q hq' : Tendsto (↑q) (𝓝 0) (𝓝 0) ε : ℝ ε_pos : 0 < ε hε : {y | ‖y‖ < ε} ⊆ ↑q ⁻¹' Iio 1 c : 𝕜 hc : 1 < ‖c‖ this : 0 < ‖c‖ / ε ⊢ ∃ C, 0 < C ∧ ∀ (x : F), ↑q x ≤ C * ‖x‖ [PROOFSTEP] refine ⟨‖c‖ / ε, this, fun x ↦ ?_⟩ [GOAL] case intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : SeminormedAddCommGroup F inst✝ : NormedSpace 𝕜 F p : SeminormFamily 𝕜 E ι q : Seminorm 𝕜 F hq : Continuous ↑q hq' : Tendsto (↑q) (𝓝 0) (𝓝 0) ε : ℝ ε_pos : 0 < ε hε : {y | ‖y‖ < ε} ⊆ ↑q ⁻¹' Iio 1 c : 𝕜 hc : 1 < ‖c‖ this : 0 < ‖c‖ / ε x : F ⊢ ↑q x ≤ ‖c‖ / ε * ‖x‖ [PROOFSTEP] by_cases hx : ‖x‖ = 0 [GOAL] case pos 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : SeminormedAddCommGroup F inst✝ : NormedSpace 𝕜 F p : SeminormFamily 𝕜 E ι q : Seminorm 𝕜 F hq : Continuous ↑q hq' : Tendsto (↑q) (𝓝 0) (𝓝 0) ε : ℝ ε_pos : 0 < ε hε : {y | ‖y‖ < ε} ⊆ ↑q ⁻¹' Iio 1 c : 𝕜 hc : 1 < ‖c‖ this : 0 < ‖c‖ / ε x : F hx : ‖x‖ = 0 ⊢ ↑q x ≤ ‖c‖ / ε * ‖x‖ [PROOFSTEP] rw [hx, mul_zero] [GOAL] case pos 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : SeminormedAddCommGroup F inst✝ : NormedSpace 𝕜 F p : SeminormFamily 𝕜 E ι q : Seminorm 𝕜 F hq : Continuous ↑q hq' : Tendsto (↑q) (𝓝 0) (𝓝 0) ε : ℝ ε_pos : 0 < ε hε : {y | ‖y‖ < ε} ⊆ ↑q ⁻¹' Iio 1 c : 𝕜 hc : 1 < ‖c‖ this : 0 < ‖c‖ / ε x : F hx : ‖x‖ = 0 ⊢ ↑q x ≤ 0 [PROOFSTEP] exact le_of_eq (map_eq_zero_of_norm_zero q hq hx) [GOAL] case neg 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : SeminormedAddCommGroup F inst✝ : NormedSpace 𝕜 F p : SeminormFamily 𝕜 E ι q : Seminorm 𝕜 F hq : Continuous ↑q hq' : Tendsto (↑q) (𝓝 0) (𝓝 0) ε : ℝ ε_pos : 0 < ε hε : {y | ‖y‖ < ε} ⊆ ↑q ⁻¹' Iio 1 c : 𝕜 hc : 1 < ‖c‖ this : 0 < ‖c‖ / ε x : F hx : ¬‖x‖ = 0 ⊢ ↑q x ≤ ‖c‖ / ε * ‖x‖ [PROOFSTEP] refine (normSeminorm 𝕜 F).bound_of_shell q ε_pos hc (fun x hle hlt ↦ ?_) hx [GOAL] case neg 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : SeminormedAddCommGroup F inst✝ : NormedSpace 𝕜 F p : SeminormFamily 𝕜 E ι q : Seminorm 𝕜 F hq : Continuous ↑q hq' : Tendsto (↑q) (𝓝 0) (𝓝 0) ε : ℝ ε_pos : 0 < ε hε : {y | ‖y‖ < ε} ⊆ ↑q ⁻¹' Iio 1 c : 𝕜 hc : 1 < ‖c‖ this : 0 < ‖c‖ / ε x✝ : F hx : ¬‖x✝‖ = 0 x : F hle : ε / ‖c‖ ≤ ↑(normSeminorm 𝕜 F) x hlt : ↑(normSeminorm 𝕜 F) x < ε ⊢ ↑q x ≤ ‖c‖ / ε * ↑(normSeminorm 𝕜 F) x [PROOFSTEP] refine (le_of_lt <| show q x < _ from hε hlt).trans ?_ [GOAL] case neg 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁴ : NontriviallyNormedField 𝕜 inst✝³ : AddCommGroup E inst✝² : Module 𝕜 E inst✝¹ : SeminormedAddCommGroup F inst✝ : NormedSpace 𝕜 F p : SeminormFamily 𝕜 E ι q : Seminorm 𝕜 F hq : Continuous ↑q hq' : Tendsto (↑q) (𝓝 0) (𝓝 0) ε : ℝ ε_pos : 0 < ε hε : {y | ‖y‖ < ε} ⊆ ↑q ⁻¹' Iio 1 c : 𝕜 hc : 1 < ‖c‖ this : 0 < ‖c‖ / ε x✝ : F hx : ¬‖x✝‖ = 0 x : F hle : ε / ‖c‖ ≤ ↑(normSeminorm 𝕜 F) x hlt : ↑(normSeminorm 𝕜 F) x < ε ⊢ 1 ≤ ‖c‖ / ε * ↑(normSeminorm 𝕜 F) x [PROOFSTEP] rwa [← div_le_iff' this, one_div_div] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁵ : NontriviallyNormedField 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : SeminormedAddCommGroup F inst✝¹ : NormedSpace 𝕜 F p : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι t : TopologicalSpace E hp : WithSeminorms p q : Seminorm 𝕜 E hq : Continuous ↑q ⊢ ∃ s C, C ≠ 0 ∧ q ≤ C • Finset.sup s p [PROOFSTEP] rcases hp.hasBasis.mem_iff.mp (ball_mem_nhds hq one_pos) with ⟨V, hV, hε⟩ [GOAL] case intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁵ : NontriviallyNormedField 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : SeminormedAddCommGroup F inst✝¹ : NormedSpace 𝕜 F p : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι t : TopologicalSpace E hp : WithSeminorms p q : Seminorm 𝕜 E hq : Continuous ↑q V : Set E hV : V ∈ SeminormFamily.basisSets p hε : id V ⊆ ball q 0 1 ⊢ ∃ s C, C ≠ 0 ∧ q ≤ C • Finset.sup s p [PROOFSTEP] rcases p.basisSets_iff.mp hV with ⟨s, ε, ε_pos, rfl⟩ -- Now forget that `E` already had a topology and view it as the (semi)normed space -- `(E, s.sup p)`. [GOAL] case intro.intro.intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁵ : NontriviallyNormedField 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : SeminormedAddCommGroup F inst✝¹ : NormedSpace 𝕜 F p : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι t : TopologicalSpace E hp : WithSeminorms p q : Seminorm 𝕜 E hq : Continuous ↑q s : Finset ι ε : ℝ ε_pos : 0 < ε hV : ball (Finset.sup s p) 0 ε ∈ SeminormFamily.basisSets p hε : id (ball (Finset.sup s p) 0 ε) ⊆ ball q 0 1 ⊢ ∃ s C, C ≠ 0 ∧ q ≤ C • Finset.sup s p [PROOFSTEP] clear hp hq t [GOAL] case intro.intro.intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁵ : NontriviallyNormedField 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : SeminormedAddCommGroup F inst✝¹ : NormedSpace 𝕜 F p : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι q : Seminorm 𝕜 E s : Finset ι ε : ℝ ε_pos : 0 < ε hV : ball (Finset.sup s p) 0 ε ∈ SeminormFamily.basisSets p hε : id (ball (Finset.sup s p) 0 ε) ⊆ ball q 0 1 ⊢ ∃ s C, C ≠ 0 ∧ q ≤ C • Finset.sup s p [PROOFSTEP] let _ : SeminormedAddCommGroup E := (s.sup p).toSeminormedAddCommGroup [GOAL] case intro.intro.intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁵ : NontriviallyNormedField 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : SeminormedAddCommGroup F inst✝¹ : NormedSpace 𝕜 F p : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι q : Seminorm 𝕜 E s : Finset ι ε : ℝ ε_pos : 0 < ε hV : ball (Finset.sup s p) 0 ε ∈ SeminormFamily.basisSets p hε : id (ball (Finset.sup s p) 0 ε) ⊆ ball q 0 1 x✝ : SeminormedAddCommGroup E := AddGroupSeminorm.toSeminormedAddCommGroup (Finset.sup s p).toAddGroupSeminorm ⊢ ∃ s C, C ≠ 0 ∧ q ≤ C • Finset.sup s p [PROOFSTEP] let _ : NormedSpace 𝕜 E := { norm_smul_le := fun a b ↦ le_of_eq (map_smul_eq_mul (s.sup p) a b) } -- The inclusion `hε` tells us exactly that `q` is *still* continuous for this new topology [GOAL] case intro.intro.intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁵ : NontriviallyNormedField 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : SeminormedAddCommGroup F inst✝¹ : NormedSpace 𝕜 F p : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι q : Seminorm 𝕜 E s : Finset ι ε : ℝ ε_pos : 0 < ε hV : ball (Finset.sup s p) 0 ε ∈ SeminormFamily.basisSets p hε : id (ball (Finset.sup s p) 0 ε) ⊆ ball q 0 1 x✝¹ : SeminormedAddCommGroup E := AddGroupSeminorm.toSeminormedAddCommGroup (Finset.sup s p).toAddGroupSeminorm x✝ : NormedSpace 𝕜 E := NormedSpace.mk (_ : ∀ (a : 𝕜) (b : E), ‖a • b‖ ≤ ‖a‖ * ‖b‖) ⊢ ∃ s C, C ≠ 0 ∧ q ≤ C • Finset.sup s p [PROOFSTEP] have : Continuous q := Seminorm.continuous (r := 1) (mem_of_superset (Metric.ball_mem_nhds _ ε_pos) hε) -- Hence we can conclude by applying `bound_of_continuous_normed_space`. [GOAL] case intro.intro.intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁵ : NontriviallyNormedField 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : SeminormedAddCommGroup F inst✝¹ : NormedSpace 𝕜 F p : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι q : Seminorm 𝕜 E s : Finset ι ε : ℝ ε_pos : 0 < ε hV : ball (Finset.sup s p) 0 ε ∈ SeminormFamily.basisSets p hε : id (ball (Finset.sup s p) 0 ε) ⊆ ball q 0 1 x✝¹ : SeminormedAddCommGroup E := AddGroupSeminorm.toSeminormedAddCommGroup (Finset.sup s p).toAddGroupSeminorm x✝ : NormedSpace 𝕜 E := NormedSpace.mk (_ : ∀ (a : 𝕜) (b : E), ‖a • b‖ ≤ ‖a‖ * ‖b‖) this : Continuous ↑q ⊢ ∃ s C, C ≠ 0 ∧ q ≤ C • Finset.sup s p [PROOFSTEP] rcases bound_of_continuous_normedSpace q this with ⟨C, C_pos, hC⟩ [GOAL] case intro.intro.intro.intro.intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁵ : NontriviallyNormedField 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : SeminormedAddCommGroup F inst✝¹ : NormedSpace 𝕜 F p : SeminormFamily 𝕜 E ι inst✝ : Nonempty ι q : Seminorm 𝕜 E s : Finset ι ε : ℝ ε_pos : 0 < ε hV : ball (Finset.sup s p) 0 ε ∈ SeminormFamily.basisSets p hε : id (ball (Finset.sup s p) 0 ε) ⊆ ball q 0 1 x✝¹ : SeminormedAddCommGroup E := AddGroupSeminorm.toSeminormedAddCommGroup (Finset.sup s p).toAddGroupSeminorm x✝ : NormedSpace 𝕜 E := NormedSpace.mk (_ : ∀ (a : 𝕜) (b : E), ‖a • b‖ ≤ ‖a‖ * ‖b‖) this : Continuous ↑q C : ℝ C_pos : 0 < C hC : ∀ (x : E), ↑q x ≤ C * ‖x‖ ⊢ ∃ s C, C ≠ 0 ∧ q ≤ C • Finset.sup s p [PROOFSTEP] exact ⟨s, ⟨C, C_pos.le⟩, fun H ↦ C_pos.ne.symm (congr_arg NNReal.toReal H), hC⟩ -- Note that the key ingredient for this proof is that, by scaling arguments hidden in -- `seminorm.continuous`, we only have to look at the `q`-ball of radius one, and the `s` we get -- from that will automatically work for all other radii. [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁷ : Nonempty ι inst✝⁶ : NormedField 𝕜 inst✝⁵ : NormedSpace ℝ 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : Module ℝ E inst✝¹ : IsScalarTower ℝ 𝕜 E inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p ⊢ LocallyConvexSpace ℝ E [PROOFSTEP] have := hp.topologicalAddGroup [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁷ : Nonempty ι inst✝⁶ : NormedField 𝕜 inst✝⁵ : NormedSpace ℝ 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : Module ℝ E inst✝¹ : IsScalarTower ℝ 𝕜 E inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p this : TopologicalAddGroup E ⊢ LocallyConvexSpace ℝ E [PROOFSTEP] apply ofBasisZero ℝ E id fun s => s ∈ p.basisSets [GOAL] case hbasis 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁷ : Nonempty ι inst✝⁶ : NormedField 𝕜 inst✝⁵ : NormedSpace ℝ 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : Module ℝ E inst✝¹ : IsScalarTower ℝ 𝕜 E inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p this : TopologicalAddGroup E ⊢ HasBasis (𝓝 0) (fun s => s ∈ SeminormFamily.basisSets p) id [PROOFSTEP] rw [hp.1, AddGroupFilterBasis.nhds_eq _, AddGroupFilterBasis.N_zero] [GOAL] case hbasis 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁷ : Nonempty ι inst✝⁶ : NormedField 𝕜 inst✝⁵ : NormedSpace ℝ 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : Module ℝ E inst✝¹ : IsScalarTower ℝ 𝕜 E inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p this : TopologicalAddGroup E ⊢ HasBasis (FilterBasis.filter AddGroupFilterBasis.toFilterBasis) (fun s => s ∈ SeminormFamily.basisSets p) id [PROOFSTEP] exact FilterBasis.hasBasis _ [GOAL] case hconvex 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁷ : Nonempty ι inst✝⁶ : NormedField 𝕜 inst✝⁵ : NormedSpace ℝ 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : Module ℝ E inst✝¹ : IsScalarTower ℝ 𝕜 E inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p this : TopologicalAddGroup E ⊢ ∀ (i : Set E), i ∈ SeminormFamily.basisSets p → Convex ℝ (id i) [PROOFSTEP] intro s hs [GOAL] case hconvex 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁷ : Nonempty ι inst✝⁶ : NormedField 𝕜 inst✝⁵ : NormedSpace ℝ 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : Module ℝ E inst✝¹ : IsScalarTower ℝ 𝕜 E inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p this : TopologicalAddGroup E s : Set E hs : s ∈ SeminormFamily.basisSets p ⊢ Convex ℝ (id s) [PROOFSTEP] change s ∈ Set.iUnion _ at hs [GOAL] case hconvex 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁷ : Nonempty ι inst✝⁶ : NormedField 𝕜 inst✝⁵ : NormedSpace ℝ 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : Module ℝ E inst✝¹ : IsScalarTower ℝ 𝕜 E inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p this : TopologicalAddGroup E s : Set E hs : s ∈ ⋃ (s : Finset ι) (r : ℝ) (_ : 0 < r), {ball (Finset.sup s p) 0 r} ⊢ Convex ℝ (id s) [PROOFSTEP] simp_rw [Set.mem_iUnion, Set.mem_singleton_iff] at hs [GOAL] case hconvex 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁷ : Nonempty ι inst✝⁶ : NormedField 𝕜 inst✝⁵ : NormedSpace ℝ 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : Module ℝ E inst✝¹ : IsScalarTower ℝ 𝕜 E inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p this : TopologicalAddGroup E s : Set E hs : ∃ i i_1 h, s = ball (Finset.sup i p) 0 i_1 ⊢ Convex ℝ (id s) [PROOFSTEP] rcases hs with ⟨I, r, _, rfl⟩ [GOAL] case hconvex.intro.intro.intro 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁷ : Nonempty ι inst✝⁶ : NormedField 𝕜 inst✝⁵ : NormedSpace ℝ 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : Module ℝ E inst✝¹ : IsScalarTower ℝ 𝕜 E inst✝ : TopologicalSpace E p : SeminormFamily 𝕜 E ι hp : WithSeminorms p this : TopologicalAddGroup E I : Finset ι r : ℝ w✝ : 0 < r ⊢ Convex ℝ (id (ball (Finset.sup I p) 0 r)) [PROOFSTEP] exact convex_ball _ _ _ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ q : SeminormFamily 𝕜₂ F ι s : Finset ι f : E →ₛₗ[σ₁₂] F ⊢ Seminorm.comp (Finset.sup s q) f = Finset.sup s (comp q f) [PROOFSTEP] ext x [GOAL] case h 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ q : SeminormFamily 𝕜₂ F ι s : Finset ι f : E →ₛₗ[σ₁₂] F x : E ⊢ ↑(Seminorm.comp (Finset.sup s q) f) x = ↑(Finset.sup s (comp q f)) x [PROOFSTEP] rw [Seminorm.comp_apply, Seminorm.finset_sup_apply, Seminorm.finset_sup_apply] [GOAL] case h 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁶ : NormedField 𝕜 inst✝⁵ : AddCommGroup E inst✝⁴ : Module 𝕜 E inst✝³ : NormedField 𝕜₂ inst✝² : AddCommGroup F inst✝¹ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝ : RingHomIsometric σ₁₂ q : SeminormFamily 𝕜₂ F ι s : Finset ι f : E →ₛₗ[σ₁₂] F x : E ⊢ ↑(Finset.sup s fun i => { val := ↑(q i) (↑f x), property := (_ : 0 ≤ ↑(q i) (↑f x)) }) = ↑(Finset.sup s fun i => { val := ↑(comp q f i) x, property := (_ : 0 ≤ ↑(comp q f i) x) }) [PROOFSTEP] rfl [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁷ : NormedField 𝕜 inst✝⁶ : AddCommGroup E inst✝⁵ : Module 𝕜 E inst✝⁴ : NormedField 𝕜₂ inst✝³ : AddCommGroup F inst✝² : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝¹ : RingHomIsometric σ₁₂ inst✝ : TopologicalSpace F hι : Nonempty ι q : SeminormFamily 𝕜₂ F ι hq : WithSeminorms q f : E →ₛₗ[σ₁₂] F ⊢ WithSeminorms (SeminormFamily.comp q f) [PROOFSTEP] have := hq.topologicalAddGroup [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁷ : NormedField 𝕜 inst✝⁶ : AddCommGroup E inst✝⁵ : Module 𝕜 E inst✝⁴ : NormedField 𝕜₂ inst✝³ : AddCommGroup F inst✝² : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝¹ : RingHomIsometric σ₁₂ inst✝ : TopologicalSpace F hι : Nonempty ι q : SeminormFamily 𝕜₂ F ι hq : WithSeminorms q f : E →ₛₗ[σ₁₂] F this : TopologicalAddGroup F ⊢ WithSeminorms (SeminormFamily.comp q f) [PROOFSTEP] let _ : TopologicalSpace E := induced f inferInstance [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁷ : NormedField 𝕜 inst✝⁶ : AddCommGroup E inst✝⁵ : Module 𝕜 E inst✝⁴ : NormedField 𝕜₂ inst✝³ : AddCommGroup F inst✝² : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝¹ : RingHomIsometric σ₁₂ inst✝ : TopologicalSpace F hι : Nonempty ι q : SeminormFamily 𝕜₂ F ι hq : WithSeminorms q f : E →ₛₗ[σ₁₂] F this : TopologicalAddGroup F x✝ : TopologicalSpace E := TopologicalSpace.induced (↑f) inferInstance ⊢ WithSeminorms (SeminormFamily.comp q f) [PROOFSTEP] have : TopologicalAddGroup E := topologicalAddGroup_induced f [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁷ : NormedField 𝕜 inst✝⁶ : AddCommGroup E inst✝⁵ : Module 𝕜 E inst✝⁴ : NormedField 𝕜₂ inst✝³ : AddCommGroup F inst✝² : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝¹ : RingHomIsometric σ₁₂ inst✝ : TopologicalSpace F hι : Nonempty ι q : SeminormFamily 𝕜₂ F ι hq : WithSeminorms q f : E →ₛₗ[σ₁₂] F this✝ : TopologicalAddGroup F x✝ : TopologicalSpace E := TopologicalSpace.induced (↑f) inferInstance this : TopologicalAddGroup E ⊢ WithSeminorms (SeminormFamily.comp q f) [PROOFSTEP] rw [(q.comp f).withSeminorms_iff_nhds_eq_iInf, nhds_induced, map_zero, q.withSeminorms_iff_nhds_eq_iInf.mp hq, Filter.comap_iInf] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁷ : NormedField 𝕜 inst✝⁶ : AddCommGroup E inst✝⁵ : Module 𝕜 E inst✝⁴ : NormedField 𝕜₂ inst✝³ : AddCommGroup F inst✝² : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝¹ : RingHomIsometric σ₁₂ inst✝ : TopologicalSpace F hι : Nonempty ι q : SeminormFamily 𝕜₂ F ι hq : WithSeminorms q f : E →ₛₗ[σ₁₂] F this✝ : TopologicalAddGroup F x✝ : TopologicalSpace E := TopologicalSpace.induced (↑f) inferInstance this : TopologicalAddGroup E ⊢ ⨅ (i : ι), comap (↑f) (comap (↑(q i)) (𝓝 0)) = ⨅ (i : ι), comap (↑(SeminormFamily.comp q f i)) (𝓝 0) [PROOFSTEP] refine' iInf_congr fun i => _ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁷ : NormedField 𝕜 inst✝⁶ : AddCommGroup E inst✝⁵ : Module 𝕜 E inst✝⁴ : NormedField 𝕜₂ inst✝³ : AddCommGroup F inst✝² : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝¹ : RingHomIsometric σ₁₂ inst✝ : TopologicalSpace F hι : Nonempty ι q : SeminormFamily 𝕜₂ F ι hq : WithSeminorms q f : E →ₛₗ[σ₁₂] F this✝ : TopologicalAddGroup F x✝ : TopologicalSpace E := TopologicalSpace.induced (↑f) inferInstance this : TopologicalAddGroup E i : ι ⊢ comap (↑f) (comap (↑(q i)) (𝓝 0)) = comap (↑(SeminormFamily.comp q f i)) (𝓝 0) [PROOFSTEP] exact Filter.comap_comap [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁸ : NormedField 𝕜 inst✝⁷ : AddCommGroup E inst✝⁶ : Module 𝕜 E inst✝⁵ : NormedField 𝕜₂ inst✝⁴ : AddCommGroup F inst✝³ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝² : RingHomIsometric σ₁₂ inst✝¹ : TopologicalSpace F hι : Nonempty ι q : SeminormFamily 𝕜₂ F ι hq : WithSeminorms q inst✝ : TopologicalSpace E f : E →ₛₗ[σ₁₂] F hf : Inducing ↑f ⊢ WithSeminorms (SeminormFamily.comp q f) [PROOFSTEP] rw [hf.induced] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁸ : NormedField 𝕜 inst✝⁷ : AddCommGroup E inst✝⁶ : Module 𝕜 E inst✝⁵ : NormedField 𝕜₂ inst✝⁴ : AddCommGroup F inst✝³ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝² : RingHomIsometric σ₁₂ inst✝¹ : TopologicalSpace F hι : Nonempty ι q : SeminormFamily 𝕜₂ F ι hq : WithSeminorms q inst✝ : TopologicalSpace E f : E →ₛₗ[σ₁₂] F hf : Inducing ↑f ⊢ WithSeminorms (SeminormFamily.comp q f) [PROOFSTEP] exact f.withSeminorms_induced hq [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁰ : NormedField 𝕜 inst✝⁹ : AddCommGroup E inst✝⁸ : Module 𝕜 E inst✝⁷ : NormedField 𝕜₂ inst✝⁶ : AddCommGroup F inst✝⁵ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁴ : RingHomIsometric σ₁₂ inst✝³ : TopologicalSpace F κ : ι → Type u_10 inst✝² : Nonempty ((i : ι) × κ i) inst✝¹ : ∀ (i : ι), Nonempty (κ i) p : (i : ι) → SeminormFamily 𝕜 E (κ i) t : ι → TopologicalSpace E inst✝ : ∀ (i : ι), TopologicalAddGroup E hp : ∀ (i : ι), WithSeminorms (p i) ⊢ WithSeminorms (SeminormFamily.sigma p) [PROOFSTEP] have : @TopologicalAddGroup E (⨅ i, t i) _ := topologicalAddGroup_iInf (fun i ↦ inferInstance) [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁰ : NormedField 𝕜 inst✝⁹ : AddCommGroup E inst✝⁸ : Module 𝕜 E inst✝⁷ : NormedField 𝕜₂ inst✝⁶ : AddCommGroup F inst✝⁵ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁴ : RingHomIsometric σ₁₂ inst✝³ : TopologicalSpace F κ : ι → Type u_10 inst✝² : Nonempty ((i : ι) × κ i) inst✝¹ : ∀ (i : ι), Nonempty (κ i) p : (i : ι) → SeminormFamily 𝕜 E (κ i) t : ι → TopologicalSpace E inst✝ : ∀ (i : ι), TopologicalAddGroup E hp : ∀ (i : ι), WithSeminorms (p i) this : TopologicalAddGroup E ⊢ WithSeminorms (SeminormFamily.sigma p) [PROOFSTEP] simp_rw [@SeminormFamily.withSeminorms_iff_topologicalSpace_eq_iInf _ _ _ _ _ _ _ (_)] at hp ⊢ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁰ : NormedField 𝕜 inst✝⁹ : AddCommGroup E inst✝⁸ : Module 𝕜 E inst✝⁷ : NormedField 𝕜₂ inst✝⁶ : AddCommGroup F inst✝⁵ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁴ : RingHomIsometric σ₁₂ inst✝³ : TopologicalSpace F κ : ι → Type u_10 inst✝² : Nonempty ((i : ι) × κ i) inst✝¹ : ∀ (i : ι), Nonempty (κ i) p : (i : ι) → SeminormFamily 𝕜 E (κ i) t : ι → TopologicalSpace E inst✝ : ∀ (i : ι), TopologicalAddGroup E this : TopologicalAddGroup E hp : ∀ (i : ι), t i = ⨅ (i_1 : κ i), UniformSpace.toTopologicalSpace ⊢ ⨅ (i : ι), t i = ⨅ (i : (i : ι) × κ i), UniformSpace.toTopologicalSpace [PROOFSTEP] rw [iInf_sigma] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝¹⁰ : NormedField 𝕜 inst✝⁹ : AddCommGroup E inst✝⁸ : Module 𝕜 E inst✝⁷ : NormedField 𝕜₂ inst✝⁶ : AddCommGroup F inst✝⁵ : Module 𝕜₂ F σ₁₂ : 𝕜 →+* 𝕜₂ inst✝⁴ : RingHomIsometric σ₁₂ inst✝³ : TopologicalSpace F κ : ι → Type u_10 inst✝² : Nonempty ((i : ι) × κ i) inst✝¹ : ∀ (i : ι), Nonempty (κ i) p : (i : ι) → SeminormFamily 𝕜 E (κ i) t : ι → TopologicalSpace E inst✝ : ∀ (i : ι), TopologicalAddGroup E this : TopologicalAddGroup E hp : ∀ (i : ι), t i = ⨅ (i_1 : κ i), UniformSpace.toTopologicalSpace ⊢ ⨅ (i : ι), t i = ⨅ (i : ι) (j : κ i), UniformSpace.toTopologicalSpace [PROOFSTEP] exact iInf_congr hp [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁵ : NontriviallyNormedField 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : Nonempty ι inst✝¹ : Countable ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E hp : WithSeminorms p ⊢ FirstCountableTopology E [PROOFSTEP] have := hp.topologicalAddGroup [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁵ : NontriviallyNormedField 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : Nonempty ι inst✝¹ : Countable ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E hp : WithSeminorms p this : TopologicalAddGroup E ⊢ FirstCountableTopology E [PROOFSTEP] let _ : UniformSpace E := TopologicalAddGroup.toUniformSpace E [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁵ : NontriviallyNormedField 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : Nonempty ι inst✝¹ : Countable ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E hp : WithSeminorms p this : TopologicalAddGroup E x✝ : UniformSpace E := TopologicalAddGroup.toUniformSpace E ⊢ FirstCountableTopology E [PROOFSTEP] have : UniformAddGroup E := comm_topologicalAddGroup_is_uniform [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁵ : NontriviallyNormedField 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : Nonempty ι inst✝¹ : Countable ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E hp : WithSeminorms p this✝ : TopologicalAddGroup E x✝ : UniformSpace E := TopologicalAddGroup.toUniformSpace E this : UniformAddGroup E ⊢ FirstCountableTopology E [PROOFSTEP] have : (𝓝 (0 : E)).IsCountablyGenerated := by rw [p.withSeminorms_iff_nhds_eq_iInf.mp hp] exact Filter.iInf.isCountablyGenerated _ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁵ : NontriviallyNormedField 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : Nonempty ι inst✝¹ : Countable ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E hp : WithSeminorms p this✝ : TopologicalAddGroup E x✝ : UniformSpace E := TopologicalAddGroup.toUniformSpace E this : UniformAddGroup E ⊢ IsCountablyGenerated (𝓝 0) [PROOFSTEP] rw [p.withSeminorms_iff_nhds_eq_iInf.mp hp] [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁵ : NontriviallyNormedField 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : Nonempty ι inst✝¹ : Countable ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E hp : WithSeminorms p this✝ : TopologicalAddGroup E x✝ : UniformSpace E := TopologicalAddGroup.toUniformSpace E this : UniformAddGroup E ⊢ IsCountablyGenerated (⨅ (i : ι), comap (↑(p i)) (𝓝 0)) [PROOFSTEP] exact Filter.iInf.isCountablyGenerated _ [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁵ : NontriviallyNormedField 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : Nonempty ι inst✝¹ : Countable ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E hp : WithSeminorms p this✝¹ : TopologicalAddGroup E x✝ : UniformSpace E := TopologicalAddGroup.toUniformSpace E this✝ : UniformAddGroup E this : IsCountablyGenerated (𝓝 0) ⊢ FirstCountableTopology E [PROOFSTEP] have : (uniformity E).IsCountablyGenerated := UniformAddGroup.uniformity_countably_generated [GOAL] 𝕜 : Type u_1 𝕜₂ : Type u_2 𝕝 : Type u_3 𝕝₂ : Type u_4 E : Type u_5 F : Type u_6 G : Type u_7 ι : Type u_8 ι' : Type u_9 inst✝⁵ : NontriviallyNormedField 𝕜 inst✝⁴ : AddCommGroup E inst✝³ : Module 𝕜 E inst✝² : Nonempty ι inst✝¹ : Countable ι p : SeminormFamily 𝕜 E ι inst✝ : TopologicalSpace E hp : WithSeminorms p this✝² : TopologicalAddGroup E x✝ : UniformSpace E := TopologicalAddGroup.toUniformSpace E this✝¹ : UniformAddGroup E this✝ : IsCountablyGenerated (𝓝 0) this : IsCountablyGenerated (𝓤 E) ⊢ FirstCountableTopology E [PROOFSTEP] exact UniformSpace.firstCountableTopology E
module Control.Monad.Identity public export record Identity (a : Type) where constructor Id runIdentity : a public export Functor Identity where map fn (Id a) = Id (fn a) public export Applicative Identity where pure x = Id x (Id f) <*> (Id g) = Id (f g) public export Monad Identity where (Id x) >>= k = k x public export Show a => Show (Identity a) where showPrec d (Id x) = showCon d "Id" $ showArg x public export Eq a => Eq (Identity a) where (Id x) == (Id y) = x == y public export Ord a => Ord (Identity a) where compare (Id x) (Id y) = compare x y -- public export -- Enum a => Enum (Identity a) where -- toNat (Id x) = toNat x -- fromNat n = Id $ fromNat n -- pred (Id n) = Id $ pred n public export (Semigroup a) => Semigroup (Identity a) where (<+>) x y = Id (runIdentity x <+> runIdentity y) public export (Monoid a) => Monoid (Identity a) where neutral = Id (neutral)
(* Verification of imperative red-black trees. *) theory IHT_Red_Black_Tree imports Auto2_Imperative_HOL.RBTree "../SepLogicTime/SLTC_Main" "../Asymptotics/Asymptotics_2D" begin section \<open>Tree nodes\<close> datatype ('a, 'b) rbt_node = Node (lsub: "('a, 'b) rbt_node ref option") (cl: color) (key: 'a) (val: 'b) (rsub: "('a, 'b) rbt_node ref option") setup \<open>fold add_rewrite_rule @{thms rbt_node.sel}\<close> fun color_encode :: "color \<Rightarrow> nat" where "color_encode B = 0" | "color_encode R = 1" instance color :: heap apply (rule heap_class.intro) apply (rule countable_classI [of "color_encode"]) apply (metis color_encode.simps(1) color_encode.simps(2) not_B zero_neq_one) .. fun rbt_node_encode :: "('a::heap, 'b::heap) rbt_node \<Rightarrow> nat" where "rbt_node_encode (Node l c k v r) = to_nat (l, c, k, v, r)" instance rbt_node :: (heap, heap) heap apply (rule heap_class.intro) apply (rule countable_classI [of "rbt_node_encode"]) apply (case_tac x, simp_all, case_tac y, simp_all) .. fun btree :: "('a::heap, 'b::heap) rbt \<Rightarrow> ('a, 'b) rbt_node ref option \<Rightarrow> assn" where "btree Leaf p = \<up>(p = None)" | "btree (rbt.Node lt c k v rt) (Some p) = (\<exists>\<^sub>Alp rp. p \<mapsto>\<^sub>r Node lp c k v rp * btree lt lp * btree rt rp)" | "btree (rbt.Node lt c k v rt) None = false" setup \<open>fold add_rewrite_ent_rule @{thms btree.simps}\<close> lemma btree_Leaf [forward_ent]: "btree Leaf p \<Longrightarrow>\<^sub>A \<up>(p = None)" by auto2 lemma btree_Node [forward_ent]: "btree (rbt.Node lt c k v rt) p \<Longrightarrow>\<^sub>A (\<exists>\<^sub>Alp rp. the p \<mapsto>\<^sub>r Node lp c k v rp * btree lt lp * btree rt rp * \<up>(p \<noteq> None))" @proof @case "p = None" @qed lemma btree_none: "emp \<Longrightarrow>\<^sub>A btree Leaf None" by auto2 lemma btree_constr_ent: "p \<mapsto>\<^sub>r Node lp c k v rp * btree lt lp * btree rt rp \<Longrightarrow>\<^sub>A btree (rbt.Node lt c k v rt) (Some p)" by auto2 setup \<open>fold add_entail_matcher [@{thm btree_none}, @{thm btree_constr_ent}]\<close> setup \<open>fold del_prfstep_thm @{thms btree.simps}\<close> type_synonym ('a, 'b) btree = "('a, 'b) rbt_node ref option" section \<open>Operations\<close> subsection \<open>Basic operations\<close> definition tree_empty :: "('a, 'b) btree Heap" where "tree_empty = return None" lemma tree_empty_rule [hoare_triple]: "<$1> tree_empty <btree Leaf>" by auto2 definition tree_is_empty :: "('a, 'b) btree \<Rightarrow> bool Heap" where "tree_is_empty b = return (b = None)" definition btree_constr :: "('a::heap, 'b::heap) btree \<Rightarrow> color \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> ('a, 'b) btree \<Rightarrow> ('a, 'b) btree Heap" where "btree_constr lp c k v rp = do { p \<leftarrow> ref (Node lp c k v rp); return (Some p) }" lemma btree_constr_rule [hoare_triple]: "<btree lt lp * btree rt rp * $2> btree_constr lp c k v rp <btree (rbt.Node lt c k v rt)>" by auto2 definition set_color :: "color \<Rightarrow> ('a::heap, 'b::heap) btree \<Rightarrow> unit Heap" where "set_color c p = (case p of None \<Rightarrow> raise ''set_color'' | Some pp \<Rightarrow> do { t \<leftarrow> !pp; pp := Node (lsub t) c (key t) (val t) (rsub t) })" lemma set_color_rule [hoare_triple]: "<btree (rbt.Node a c x v b) p * $2> set_color c' p <\<lambda>_. btree (rbt.Node a c' x v b) p>\<^sub>t" by auto2 definition get_color :: "('a::heap, 'b::heap) btree \<Rightarrow> color Heap" where "get_color p = (case p of None \<Rightarrow> return B | Some pp \<Rightarrow> do { t \<leftarrow> !pp; return (cl t) })" definition paint :: "color \<Rightarrow> ('a::heap, 'b::heap) btree \<Rightarrow> unit Heap" where "paint c p = (case p of None \<Rightarrow> return () | Some pp \<Rightarrow> do { t \<leftarrow> !pp; pp := Node (lsub t) c (key t) (val t) (rsub t) })" lemma paint_rule [hoare_triple]: "<btree t p *$2> paint c p <\<lambda>_. btree (RBTree.paint c t) p>\<^sub>t" @proof @case "t = Leaf" @qed subsection \<open>Rotation\<close> definition btree_rotate_l :: "('a::heap, 'b::heap) btree \<Rightarrow> ('a, 'b) btree Heap" where "btree_rotate_l p = (case p of None \<Rightarrow> raise ''Empty btree'' | Some pp \<Rightarrow> do { t \<leftarrow> !pp; (case rsub t of None \<Rightarrow> raise ''Empty rsub'' | Some rp \<Rightarrow> do { rt \<leftarrow> !rp; pp := Node (lsub t) (cl t) (key t) (val t) (lsub rt); rp := Node p (cl rt) (key rt) (val rt) (rsub rt); return (rsub t) })})" lemma btree_rotate_l_rule [hoare_triple]: "<btree (rbt.Node a c1 x v (rbt.Node b c2 y w c)) p * $5> btree_rotate_l p <btree (rbt.Node (rbt.Node a c1 x v b) c2 y w c)>\<^sub>t" by auto2 definition btree_rotate_r :: "('a::heap, 'b::heap) btree \<Rightarrow> ('a, 'b) btree Heap" where "btree_rotate_r p = (case p of None \<Rightarrow> raise ''Empty btree'' | Some pp \<Rightarrow> do { t \<leftarrow> !pp; (case lsub t of None \<Rightarrow> raise ''Empty lsub'' | Some lp \<Rightarrow> do { lt \<leftarrow> !lp; pp := Node (rsub lt) (cl t) (key t) (val t) (rsub t); lp := Node (lsub lt) (cl lt) (key lt) (val lt) p; return (lsub t) })})" definition btree_rotate_r_time :: "nat" where [rewrite]: "btree_rotate_r_time = 5" lemma btree_rotate_r_rule [hoare_triple]: "<btree (rbt.Node (rbt.Node a c1 x v b) c2 y w c) p * $5> btree_rotate_r p <btree (rbt.Node a c1 x v (rbt.Node b c2 y w c))>" by auto2 lemma btree_rotate_r_time_bound [asym_bound]: "(\<lambda>n::nat. btree_rotate_r_time) \<in> \<Theta>(\<lambda>n. 1)" apply (simp only: btree_rotate_r_time_def) by auto2 subsection \<open>Balance\<close> definition btree_balanceR :: "('a::heap, 'b::heap) btree \<Rightarrow> ('a, 'b) btree Heap" where "btree_balanceR p = (case p of None \<Rightarrow> return None | Some pp \<Rightarrow> do { t \<leftarrow> !pp; cl_r \<leftarrow> get_color (rsub t); if cl_r = R then do { rt \<leftarrow> !(the (rsub t)); cl_lr \<leftarrow> get_color (lsub rt); cl_rr \<leftarrow> get_color (rsub rt); if cl_lr = R then do { rp' \<leftarrow> btree_rotate_r (rsub t); pp := Node (lsub t) (cl t) (key t) (val t) rp'; p' \<leftarrow> btree_rotate_l p; t' \<leftarrow> !(the p'); set_color B (rsub t'); return p' } else if cl_rr = R then do { p' \<leftarrow> btree_rotate_l p; t' \<leftarrow> !(the p'); set_color B (rsub t'); return p' } else return p } else return p})" definition btree_balanceR_time :: "nat" where [rewrite]: "btree_balanceR_time = 24" lemma balanceR_to_fun [hoare_triple]: "<btree (rbt.Node l B k v r) p * $24> btree_balanceR p <btree (balanceR l k v r)>\<^sub>t" @proof @unfold "balanceR l k v r" @qed definition btree_balance :: "('a::heap, 'b::heap) btree \<Rightarrow> ('a, 'b) btree Heap" where "btree_balance p = (case p of None \<Rightarrow> return None | Some pp \<Rightarrow> do { t \<leftarrow> !pp; cl_l \<leftarrow> get_color (lsub t); if cl_l = R then do { lt \<leftarrow> !(the (lsub t)); cl_rl \<leftarrow> get_color (rsub lt); cl_ll \<leftarrow> get_color (lsub lt); if cl_ll = R then do { p' \<leftarrow> btree_rotate_r p; t' \<leftarrow> !(the p'); set_color B (lsub t'); return p' } else if cl_rl = R then do { lp' \<leftarrow> btree_rotate_l (lsub t); pp := Node lp' (cl t) (key t) (val t) (rsub t); p' \<leftarrow> btree_rotate_r p; t' \<leftarrow> !(the p'); set_color B (lsub t'); return p' } else btree_balanceR p } else do { p' \<leftarrow> btree_balanceR p; return p'}})" declare [[print_trace]] subsection \<open>Insertion\<close> partial_function (heap_time) rbt_ins :: "'a::{heap,ord} \<Rightarrow> 'b::heap \<Rightarrow> ('a, 'b) btree \<Rightarrow> ('a, 'b) btree Heap" where "rbt_ins k v p = (case p of None \<Rightarrow> btree_constr None R k v None | Some pp \<Rightarrow> do { t \<leftarrow> !pp; (if cl t = B then (if k = key t then do { pp := Node (lsub t) (cl t) k v (rsub t); return (Some pp) } else if k < key t then do { q \<leftarrow> rbt_ins k v (lsub t); pp := Node q (cl t) (key t) (val t) (rsub t); btree_balance p } else do { q \<leftarrow> rbt_ins k v (rsub t); pp := Node (lsub t) (cl t) (key t) (val t) q; btree_balance p }) else (if k = key t then do { pp := Node (lsub t) (cl t) k v (rsub t); return (Some pp) } else if k < key t then do { q \<leftarrow> rbt_ins k v (lsub t); pp := Node q (cl t) (key t) (val t) (rsub t); return (Some pp) } else do { q \<leftarrow> rbt_ins k v (rsub t); pp := Node (lsub t) (cl t) (key t) (val t) q; return (Some pp) }))})" fun rbt_ins_time' :: "('a, 'b) rbt \<Rightarrow> 'a::ord \<Rightarrow> nat" where "rbt_ins_time' Leaf k = 4" | "rbt_ins_time' (rbt.Node l c ka va r) k = (if c=B then (if k=ka then 4 else (if k<ka then 50 + rbt_ins_time' l k else 100 + rbt_ins_time' r k)) else (if k=ka then 4 else (if k<ka then 100 + rbt_ins_time' l k else 100 + rbt_ins_time' r k)) ) " setup \<open>fold add_rewrite_rule @{thms rbt_ins_time'.simps}\<close> lemma rbt_ins_to_fun'[hoare_triple]: "<btree t p * $(rbt_ins_time' t k)> rbt_ins k v p <btree (ins k v t)>\<^sub>t" @proof @induct t arbitrary p @qed definition rbt_ins_time :: "nat \<Rightarrow> nat" where "rbt_ins_time n = 400 * n + 4" lemma rbt_ins_time'[resolve]: "rbt_ins_time' t k \<le> rbt_ins_time (max_depth t)" by (induct t, auto simp: rbt_ins_time_def) lemma rbt_ins_to_fun[hoare_triple]: "<btree t p * $(rbt_ins_time (max_depth t))> rbt_ins k v p <btree (ins k v t)>\<^sub>t" @proof @have "(rbt_ins_time (max_depth t)) \<ge>\<^sub>t rbt_ins_time' t k" @qed definition rbt_insert :: "'a::{heap,ord} \<Rightarrow> 'b::heap \<Rightarrow> ('a, 'b) btree \<Rightarrow> ('a, 'b) btree Heap" where "rbt_insert k v p = do { p' \<leftarrow> rbt_ins k v p; paint B p'; return p' }" definition rbt_insert_time :: "nat \<Rightarrow> nat" where [rewrite]: "rbt_insert_time n = rbt_ins_time n + 4" lemma rbt_insert_to_fun [hoare_triple]: "<btree t p * $(rbt_insert_time (max_depth t))> rbt_insert k v p <btree (RBTree.rbt_insert k v t)>\<^sub>t" by auto2 subsection \<open>Search\<close> partial_function (heap_time) rbt_search :: "'a::{heap,linorder} \<Rightarrow> ('a, 'b::heap) btree \<Rightarrow> 'b option Heap" where "rbt_search x b = (case b of None \<Rightarrow> return None | Some p \<Rightarrow> do { t \<leftarrow> !p; (if x = key t then return (Some (val t)) else if x < key t then rbt_search x (lsub t) else rbt_search x (rsub t)) })" fun rbt_search_time' :: "('a, 'b) rbt \<Rightarrow> 'a::ord \<Rightarrow> nat" where "rbt_search_time' Leaf k = 1" | "rbt_search_time' (rbt.Node l c ka va r) k = (if k=ka then 2 else (if k<ka then 1 + rbt_search_time' l k else 1 + rbt_search_time' r k)) " setup \<open>fold add_rewrite_rule @{thms rbt_search_time'.simps}\<close> lemma btree_search_correct' [hoare_triple]: (* order of \<up> and $ is important *) "<btree t b * $(rbt_search_time' t x) * \<up>(rbt_sorted t)> rbt_search x b <\<lambda>r. btree t b * \<up>(r = RBTree.rbt_search t x)>\<^sub>t" @proof @induct t arbitrary b @qed abbreviation "searchC == 40" definition rbt_search_time :: "nat \<Rightarrow> nat" where [rewrite]: "rbt_search_time n = searchC * n + 4" lemma rbt_search_time_ub[resolve]: "rbt_search_time (max_depth t) \<ge> rbt_search_time' t k" by(induct t, auto simp: rbt_search_time_def) lemma btree_search_correct [hoare_triple]: "<btree t b * $(rbt_search_time (max_depth t)) * \<up>(rbt_sorted t)> rbt_search x b <\<lambda>r. btree t b * \<up>(r = RBTree.rbt_search t x)>\<^sub>t" @proof @have "rbt_search_time (max_depth t) \<ge>\<^sub>t rbt_search_time' t x" @qed setup \<open>del_prfstep_thm @{thm rbt_search_time_def}\<close> subsection \<open>Delete\<close> definition btree_balL :: "('a::heap, 'b::heap) btree \<Rightarrow> ('a, 'b) btree Heap" where "btree_balL p = (case p of None \<Rightarrow> return None | Some pp \<Rightarrow> do { t \<leftarrow> !pp; cl_l \<leftarrow> get_color (lsub t); if cl_l = R then do { set_color B (lsub t); \<comment> \<open> case 1 \<close> return p} else case rsub t of None \<Rightarrow> return p \<comment> \<open> case 2\<close> | Some rp \<Rightarrow> do { rt \<leftarrow> !rp; if cl rt = B then do { set_color R (rsub t); \<comment> \<open> case 3\<close> set_color B p; btree_balance p} else case lsub rt of None \<Rightarrow> return p \<comment> \<open> case 4 \<close> | Some lrp \<Rightarrow> do { lrt \<leftarrow> !lrp; if cl lrt = B then do { set_color R (lsub rt); \<comment> \<open> case 5 \<close> paint R (rsub rt); set_color B (rsub t); rp' \<leftarrow> btree_rotate_r (rsub t); pp := Node (lsub t) (cl t) (key t) (val t) rp'; p' \<leftarrow> btree_rotate_l p; t' \<leftarrow> !(the p'); set_color B (lsub t'); rp'' \<leftarrow> btree_balance (rsub t'); the p' := Node (lsub t') (cl t') (key t') (val t') rp''; return p'} else return p}}})" lemma balL_to_fun [hoare_triple]: "<btree (rbt.Node l R k v r) p * $60 > btree_balL p <btree (balL l k v r)>\<^sub>t" @proof @unfold "balL l k v r" @qed definition btree_balR :: "('a::heap, 'b::heap) btree \<Rightarrow> ('a, 'b) btree Heap" where "btree_balR p = (case p of None \<Rightarrow> return None | Some pp \<Rightarrow> do { t \<leftarrow> !pp; cl_r \<leftarrow> get_color (rsub t); if cl_r = R then do { set_color B (rsub t); \<comment>\<open>case 1 \<close> return p} else case lsub t of None \<Rightarrow> return p \<comment>\<open>case 2\<close> | Some lp \<Rightarrow> do { lt \<leftarrow> !lp; if cl lt = B then do { set_color R (lsub t); \<comment>\<open>case 3\<close> set_color B p; btree_balance p} else case rsub lt of None \<Rightarrow> return p \<comment>\<open>case 4\<close> | Some rlp \<Rightarrow> do { rlt \<leftarrow> !rlp; if cl rlt = B then do { set_color R (rsub lt); \<comment>\<open>case 5\<close> paint R (lsub lt); set_color B (lsub t); lp' \<leftarrow> btree_rotate_l (lsub t); pp := Node lp' (cl t) (key t) (val t) (rsub t); p' \<leftarrow> btree_rotate_r p; t' \<leftarrow> !(the p'); set_color B (rsub t'); lp'' \<leftarrow> btree_balance (lsub t'); the p' := Node lp'' (cl t') (key t') (val t') (rsub t'); return p'} else return p}}})" lemma balR_to_fun [hoare_triple]: "<btree (rbt.Node l R k v r) p * $60> btree_balR p <btree (balR l k v r)>\<^sub>t" @proof @unfold "balR l k v r" @qed partial_function (heap_time) btree_combine :: "('a::heap, 'b::heap) btree \<Rightarrow> ('a, 'b) btree \<Rightarrow> ('a, 'b) btree Heap" where "btree_combine lp rp = (if lp = None then return rp else if rp = None then return lp else do { lt \<leftarrow> !(the lp); rt \<leftarrow> !(the rp); if cl lt = R then if cl rt = R then do { tmp \<leftarrow> btree_combine (rsub lt) (lsub rt); cl_tm \<leftarrow> get_color tmp; if cl_tm = R then do { tmt \<leftarrow> !(the tmp); the lp := Node (lsub lt) R (key lt) (val lt) (lsub tmt); the rp := Node (rsub tmt) R (key rt) (val rt) (rsub rt); the tmp := Node lp R (key tmt) (val tmt) rp; return tmp} else do { the rp := Node tmp R (key rt) (val rt) (rsub rt); the lp := Node (lsub lt) R (key lt) (val lt) rp; return lp}} else do { tmp \<leftarrow> btree_combine (rsub lt) rp; the lp := Node (lsub lt) R (key lt) (val lt) tmp; return lp} else if cl rt = B then do { tmp \<leftarrow> btree_combine (rsub lt) (lsub rt); cl_tm \<leftarrow> get_color tmp; if cl_tm = R then do { tmt \<leftarrow> !(the tmp); the lp := Node (lsub lt) B (key lt) (val lt) (lsub tmt); the rp := Node (rsub tmt) B (key rt) (val rt) (rsub rt); the tmp := Node lp R (key tmt) (val tmt) rp; return tmp} else do { the rp := Node tmp B (key rt) (val rt) (rsub rt); the lp := Node (lsub lt) R (key lt) (val lt) rp; btree_balL lp}} else do { tmp \<leftarrow> btree_combine lp (lsub rt); the rp := Node tmp R (key rt) (val rt) (rsub rt); return rp}})" fun rbt_combine_time' :: "('a, 'b) rbt \<Rightarrow> ('a, 'b) rbt \<Rightarrow> nat" where "rbt_combine_time' Leaf _ = 1" | "rbt_combine_time' (rbt.Node l c ka va r) Leaf = 1" | "rbt_combine_time' (rbt.Node l1 c1 k1 v1 r1) (rbt.Node l2 c2 k2 v2 r2) = (if c1=R then (if c2=R then 20 + rbt_combine_time' r1 l2 else 20 + rbt_combine_time' r1 (rbt.Node l2 c2 k2 v2 r2) ) else (if c2=B then 80 + rbt_combine_time' r1 l2 else 20 + rbt_combine_time' (rbt.Node l1 c1 k1 v1 r1) l2) ) " setup \<open>fold add_rewrite_rule @{thms rbt_combine_time'.simps}\<close> lemma combine_to_fun' [hoare_triple]: "<btree lt lp * btree rt rp * $(rbt_combine_time' lt rt)> btree_combine lp rp <btree (combine lt rt)>\<^sub>t" @proof @fun_induct "combine lt rt" arbitrary lp rp @with @subgoal "(lt = rbt.Node l1 c1 k1 v1 r1, rt = rbt.Node l2 c2 k2 v2 r2)" @unfold "combine (rbt.Node l1 c1 k1 v1 r1) (rbt.Node l2 c2 k2 v2 r2)" @endgoal @end @qed abbreviation "combineC == 40" definition btree_combine_time :: "nat \<Rightarrow> nat \<Rightarrow> nat" where "btree_combine_time n m = combineC * n + combineC * m + 1" lemma btree_combine_time_ub[resolve]: "btree_combine_time (max_depth t1) (max_depth t2) \<ge> rbt_combine_time' t1 t2" apply(induct rule: rbt_combine_time'.induct) by (auto simp: btree_combine_time_def) lemma combine_to_fun [hoare_triple]: "<btree lt lp * btree rt rp * $(btree_combine_time (max_depth lt) (max_depth rt))> btree_combine lp rp <btree (combine lt rt)>\<^sub>t" @proof @have "btree_combine_time (max_depth lt) (max_depth rt) \<ge>\<^sub>t rbt_combine_time' lt rt" @qed partial_function (heap_time) rbt_del :: "'a::{heap,linorder} \<Rightarrow> ('a, 'b::heap) btree \<Rightarrow> ('a, 'b) btree Heap" where "rbt_del x p = (case p of None \<Rightarrow> return None | Some pp \<Rightarrow> do { t \<leftarrow> !pp; (if x = key t then btree_combine (lsub t) (rsub t) else if x < key t then case lsub t of None \<Rightarrow> do { set_color R p; return p} | Some lp \<Rightarrow> do { lt \<leftarrow> !lp; if cl lt = B then do { q \<leftarrow> rbt_del x (lsub t); pp := Node q R (key t) (val t) (rsub t); btree_balL p } else do { q \<leftarrow> rbt_del x (lsub t); pp := Node q R (key t) (val t) (rsub t); return p }} else case rsub t of None \<Rightarrow> do { set_color R p; return p} | Some rp \<Rightarrow> do { rt \<leftarrow> !rp; if cl rt = B then do { q \<leftarrow> rbt_del x (rsub t); pp := Node (lsub t) R (key t) (val t) q; btree_balR p } else do { q \<leftarrow> rbt_del x (rsub t); pp := Node (lsub t) R (key t) (val t) q; return p }})})" fun rbt_del_time' :: "('a, 'b) rbt \<Rightarrow> 'a::ord \<Rightarrow> nat" where "rbt_del_time' Leaf _ = 1" | "rbt_del_time' (rbt.Node l c ka va r) k = (if k=ka then 2 + btree_combine_time (max_depth l) (max_depth r) else (if k < ka then (if l = Leaf then 10 else 80 + rbt_del_time' l k) else (if r = Leaf then 10 else 80 + rbt_del_time' r k) )) " setup \<open>fold add_rewrite_rule @{thms rbt_del_time'.simps}\<close> lemma rbt_del_to_fun' [hoare_triple]: "<btree t p * $(rbt_del_time' t x)> rbt_del x p <btree (del x t)>\<^sub>t" @proof @induct t arbitrary p @with @subgoal "t = rbt.Node l c k v r" @unfold "del x (rbt.Node l c k v r)" @endgoal @end @qed definition btree_del_time :: "nat \<Rightarrow> nat" where "btree_del_time n = 200 * combineC * n + 8" lemma btree_del_time_ub[resolve]: "btree_del_time (max_depth t) \<ge> rbt_del_time' t k" by (induct t, auto simp: btree_del_time_def btree_combine_time_def) lemma rbt_del_to_fun [hoare_triple]: "<btree t p * $(btree_del_time (max_depth t))> rbt_del x p <btree (del x t)>\<^sub>t" @proof @have "btree_del_time (max_depth t) \<ge>\<^sub>t rbt_del_time' t x" @qed definition rbt_delete :: "'a::{heap,linorder} \<Rightarrow> ('a, 'b::heap) btree \<Rightarrow> ('a, 'b) btree Heap" where "rbt_delete k p = do { p' \<leftarrow> rbt_del k p; paint B p'; return p'}" definition rbt_delete_time :: "nat \<Rightarrow> nat" where [rewrite]: "rbt_delete_time n = btree_del_time n + 4" lemma rbt_delete_to_fun [hoare_triple]: "<btree t p * $(rbt_delete_time (max_depth t))> rbt_delete k p <btree (RBTree.delete k t)>\<^sub>t" by auto2 section \<open>Height-Size Relation\<close> fun size :: "('a, 'b) rbt \<Rightarrow> nat" where "size Leaf = 0" | "size (rbt.Node l c k v r) = 1 + size l + size r" definition size1 :: "('a, 'b) rbt \<Rightarrow> nat" where "size1 t = 1 + size t" lemma bheight_size_bound: "is_rbt t \<Longrightarrow> size1 t \<ge> 2 ^ (black_depth t)" apply(induction t) apply simp apply (auto simp: is_rbt_def size1_def ) subgoal for t1 x2 x3 x4 t2 apply(cases x2) by auto done lemma max_black_aux: "is_rbt t \<Longrightarrow> (if rbt.cl t = R then max_depth t \<le> 2 * black_depth t + 1 else max_depth t \<le> 2 * black_depth t)" @proof @induct t @with @subgoal "t = rbt.Node l c k v r" @case "c = R" @endgoal @end @qed lemma max_black: "is_rbt t \<Longrightarrow> (max_depth t -1)/2 \<le> black_depth t" using max_black_aux apply(cases "rbt.cl t") by fastforce+ lemma rbt_height_le: assumes "is_rbt t" shows "max_depth t \<le> 2 * log 2 (size1 t) + 1" proof - have "2 powr ((max_depth t - 1 )/ 2) \<le> 2 powr black_depth t" using max_black[OF assms] by (simp) also have "\<dots> \<le> size1 t" using assms by (simp add: powr_realpow bheight_size_bound ) finally have "2 powr ((max_depth t -1) / 2) \<le> size1 t" . hence "(max_depth t -1) / 2 \<le> log 2 (size1 t)" by(simp add: le_log_iff size1_def del: divide_le_eq_numeral1(1)) thus ?thesis by simp qed subsection "size1 of operations" lemma size1Leaf[rewrite]: "size1 Leaf = 1" by (simp add: size1_def) lemma size1_paint[simp]: "size1 (RBTree.paint b t) = size1 t" by(induct t, auto simp: size1_def) lemma size_paint[simp]: "size (RBTree.paint b t) = size t" by(induct t, auto) lemma size_red_subs: "rbt.cl t = R \<Longrightarrow> size t = size (rbt.lsub t) + size (rbt.rsub t) + 1" apply(cases t) by auto lemma size_balanceR[simp]: "size (RBTree.balanceR l k v r) = 1 + size l + size r" apply( auto simp: balanceR_def) apply(cases "rbt.cl (rbt.lsub r)") by (auto simp: Let_def size_red_subs) lemma size_balance[simp]: "size (RBTree.balance l k v r) = 1 + size l + size r" by (auto simp: balance_def Let_def size_red_subs) lemma size1_ins[simp]: "size1 (RBTree.ins k v t) \<le> size1 t + 1" by (induct t, auto simp: size1_def) lemma size1_rbt_insert[resolve]: "size1 (RBTree.rbt_insert k v t) \<le> size1 t + 1" apply(simp add: RBTree.rbt_insert_def) using size1_ins by simp section \<open>size of map\<close> lemma map_of_alist_conc: "(map_of_alist (xs @ ys)) = Map (\<lambda>k. (case meval (map_of_alist xs) k of None \<Rightarrow> meval (map_of_alist ys) k | Some v \<Rightarrow> Some v))" by(induct xs, auto intro: meval_ext simp: empty_map_def update_map_def) lemma rbt_set_keys_of: "rbt_sorted t \<Longrightarrow> keys_of (rbt_map t) = rbt_set t" proof(induct t) case Leaf then show ?case by ( auto simp: rbt_map_def empty_map_def keys_of_def) next case (Node t1 x2 x3 x4 t2) have i: " keys_of (rbt_map (rbt.Node t1 x2 x3 x4 t2)) = keys_of (rbt_map t1) \<union> {x3} \<union> (keys_of (rbt_map t2))" unfolding keys_of_def rbt_map_def by (auto split: option.split simp: map_of_alist_conc update_map_def) from Node show ?case unfolding i by auto qed lemma [simp]: "finite (rbt_set t)" by(induct t, auto) lemma rbt_map_card: "rbt_sorted (rbt.Node l c k v r) \<Longrightarrow> card (keys_of (rbt_map (rbt.Node l c k v r))) = card (keys_of (rbt_map l)) + 1 + card (keys_of (rbt_map r))" proof - assume r: "rbt_sorted (rbt.Node l c k v r)" from r have [simp]: "rbt_set l \<inter> rbt_set r = {}" by (auto 3 4) from r have "card (rbt_set (rbt.Node l c k v r)) = Suc (card (rbt_set l \<union> rbt_set r))" by (auto intro: card_insert_disjoint) also have "card (rbt_set l \<union> rbt_set r) = card (rbt_set l) + card (rbt_set r)" apply(rule card_Un_disjoint) by auto finally show ?thesis using r by (auto simp: rbt_set_keys_of) qed lemma card_keysof_size: "RBTree.rbt_sorted t \<Longrightarrow> card (keys_of (rbt_map t)) = size t" apply(induct t) subgoal apply (auto simp: rbt_map_def keys_of_def empty_map_def) done subgoal apply (auto simp: rbt_map_card) done done definition sizeM1 :: "('a, 'b) Mapping_Str.map \<Rightarrow> nat" where "sizeM1 M = 1 + card (keys_of M)" section \<open>Runtime in terms of size of the map\<close> definition rbt_absch :: "nat \<Rightarrow> nat" where "rbt_absch n = (nat (ceiling (2 * log 2 n + 1)))" lemma rbt_absch_bound[asym_bound]: "(\<lambda>x. rbt_absch x) \<in> \<Theta>(\<lambda>n. ln n)" unfolding rbt_absch_def apply(rule ceiling_Theta) unfolding eventually_nonneg_def eventually_sequentially apply(rule exI[where x=1]) unfolding log_def by auto lemma rbt_absch_mono: "x > 0 \<Longrightarrow> x \<le> y \<Longrightarrow> rbt_absch x \<le> rbt_absch y" by (auto simp: rbt_absch_def intro!: ceiling_mono nat_mono) lemma "is_rbt t \<Longrightarrow> size1 t \<le> n \<Longrightarrow> rbt_absch (size1 t) \<le> rbt_absch n" apply(rule rbt_absch_mono) by(auto simp: size1_def) subsection \<open>insert\<close> lemma rbt_insert_time_mono: "x \<le> y \<Longrightarrow> rbt_insert_time x \<le> rbt_insert_time y" unfolding rbt_insert_time_def rbt_ins_time_def by auto definition rbt_insert_logN :: "nat \<Rightarrow> nat" where "rbt_insert_logN n = rbt_insert_time (rbt_absch n)" lemma rbt_insert_logN_gt0[resolve]: "rbt_insert_logN n > 0" by (simp add: rbt_insert_logN_def rbt_absch_def rbt_insert_time_def) lemma rbt_insert_logN_mono: "0 < x \<Longrightarrow> x\<le>y \<Longrightarrow> rbt_insert_logN x \<le> rbt_insert_logN y" by(auto simp: rbt_insert_logN_def intro!: rbt_insert_time_mono rbt_absch_mono) lemma rbt_insert_time_absch: assumes "is_rbt t" "rbt_sorted t" "rbt_map t = M" shows K[backward]: "rbt_insert_time (max_depth t) \<le> rbt_insert_logN (sizeM1 M)" unfolding rbt_insert_logN_def proof (rule rbt_insert_time_mono) have A: "rbt_absch (size1 t) = rbt_absch (sizeM1 M)" using card_keysof_size[OF assms(2)] assms(3) by(auto simp: size1_def sizeM1_def) have B: "max_depth t \<le> rbt_absch (size1 t)" unfolding rbt_absch_def using assms(1) apply(auto dest!: rbt_height_le ) by linarith from A B show "max_depth t \<le> rbt_absch (sizeM1 M)" by auto qed lemma rbt_insert_rule' [hoare_triple]: "is_rbt t \<Longrightarrow> rbt_sorted t \<Longrightarrow> M = rbt_map t \<Longrightarrow> <btree t p * $(rbt_insert_logN (sizeM1 M))> rbt_insert k v p <\<lambda>r. btree (RBTree.rbt_insert k v t) r * \<up>(is_rbt (RBTree.rbt_insert k v t)) * \<up>(rbt_sorted (RBTree.rbt_insert k v t)) * \<up>((M {k \<rightarrow> v}) = rbt_map (RBTree.rbt_insert k v t)) >\<^sub>t" @proof @have " rbt_insert_logN (sizeM1 M) \<ge>\<^sub>t rbt_insert_time (max_depth t)" @qed subsection \<open>search\<close> definition rbt_search_time_logN :: "nat \<Rightarrow> nat" where "rbt_search_time_logN n = rbt_search_time (rbt_absch n)" lemma rbt_search_time_logN_gt0[resolve]: "rbt_search_time_logN n > 0" by (simp add: rbt_search_time_logN_def rbt_absch_def rbt_search_time_def) lemma rbt_search_time_mono: "x \<le> y \<Longrightarrow> rbt_search_time x \<le> rbt_search_time y" unfolding rbt_search_time_def by auto lemma rbt_search_time_logN_mono: "0 < x \<Longrightarrow> x \<le> y \<Longrightarrow> rbt_search_time_logN x \<le> rbt_search_time_logN y" by(auto simp: rbt_search_time_logN_def intro!: rbt_absch_mono rbt_search_time_mono) lemma assumes "is_rbt t" "rbt_sorted t" "rbt_map t = M" shows L[backward]: "rbt_search_time (max_depth t) \<le> rbt_search_time_logN (sizeM1 M)" unfolding rbt_search_time_logN_def proof (rule rbt_search_time_mono) have A: "rbt_absch (size1 t) = rbt_absch (sizeM1 M)" using card_keysof_size[OF assms(2)] assms(3) by(auto simp: size1_def sizeM1_def) have B: "max_depth t \<le> rbt_absch (size1 t)" unfolding rbt_absch_def using assms(1) apply(auto dest!: rbt_height_le ) by linarith from A B show "max_depth t \<le> rbt_absch (sizeM1 M)" by auto qed lemma rbt_search_rule' [hoare_triple]: "is_rbt t \<Longrightarrow> rbt_sorted t \<Longrightarrow> M = rbt_map t \<Longrightarrow> <btree t p * $(rbt_search_time_logN (sizeM1 M))> rbt_search k p <\<lambda>r. btree t p * \<up>(r = RBTree.rbt_search t k)>\<^sub>t" @proof @have " rbt_search_time_logN (sizeM1 M) \<ge>\<^sub>t rbt_search_time (max_depth t)" @qed subsection \<open>delete\<close> definition rbt_delete_time_logN :: "nat \<Rightarrow> nat" where "rbt_delete_time_logN n = rbt_delete_time (rbt_absch n)" lemma rbt_delete_time_logN_gt0[resolve]: "rbt_delete_time_logN n > 0" by (simp add: rbt_delete_time_logN_def rbt_absch_def rbt_delete_time_def) lemma rbt_delete_time_mono: "x \<le> y \<Longrightarrow> rbt_delete_time x \<le> rbt_delete_time y" unfolding rbt_delete_time_def btree_del_time_def by auto lemma rbt_delete_time_logN_mono: "0 < x \<Longrightarrow> x \<le> y \<Longrightarrow> rbt_delete_time_logN x \<le> rbt_delete_time_logN y" by(auto simp: rbt_delete_time_logN_def intro!: rbt_absch_mono rbt_delete_time_mono) lemma assumes "is_rbt t" "rbt_sorted t" "rbt_map t = M" shows rbt_delete_time_absch[backward]: "rbt_delete_time (max_depth t) \<le> rbt_delete_time_logN (sizeM1 M)" unfolding rbt_delete_time_logN_def proof (rule rbt_delete_time_mono) have A: "rbt_absch (size1 t) = rbt_absch (sizeM1 M)" using card_keysof_size[OF assms(2)] assms(3) by(auto simp: size1_def sizeM1_def) have B: "max_depth t \<le> rbt_absch (size1 t)" unfolding rbt_absch_def using assms(1) apply(auto dest!: rbt_height_le ) by linarith from A B show "max_depth t \<le> rbt_absch (sizeM1 M)" by auto qed lemma rbt_delete_rule' [hoare_triple]: "is_rbt t \<Longrightarrow> rbt_sorted t \<Longrightarrow> M = rbt_map t \<Longrightarrow> <btree t p * $(rbt_delete_time_logN (sizeM1 M))> rbt_delete k p <\<lambda>p. btree (RBTree.delete k t) p * \<up>(is_rbt (RBTree.delete k t)) * \<up>(rbt_sorted (RBTree.delete k t)) * \<up>((delete_map k M) = rbt_map (RBTree.delete k t))>\<^sub>t" @proof @have " rbt_delete_time_logN (sizeM1 M) \<ge>\<^sub>t rbt_delete_time (max_depth t)" @qed section \<open>Outer interface\<close> definition rbt_map_assn :: "('a, 'b) map \<Rightarrow> ('a::{heap,linorder}, 'b::heap) rbt_node ref option \<Rightarrow> assn" where "rbt_map_assn M p = (\<exists>\<^sub>At. btree t p * \<up>(is_rbt t) * \<up>(rbt_sorted t) * \<up>(M = rbt_map t))" setup \<open>add_rewrite_ent_rule @{thm rbt_map_assn_def}\<close> subsection \<open>tree empty\<close> subsection \<open>insert\<close> theorem rbt_insert_rule [hoare_triple]: "<rbt_map_assn M b * $(rbt_insert_logN (sizeM1 M))> rbt_insert k v b <rbt_map_assn (M {k \<rightarrow> v})>\<^sub>t" by auto2 lemma rbt_insert_logN_bound[asym_bound]: "(\<lambda>n. rbt_insert_logN n) \<in> \<Theta>(\<lambda>n. ln n)" unfolding rbt_insert_logN_def rbt_insert_time_def rbt_ins_time_def by auto2 subsection \<open>search\<close> lemma rbt_search_time_logN_bound[asym_bound]: "(\<lambda>n. rbt_search_time_logN n) \<in> \<Theta>(\<lambda>n. ln n)" unfolding rbt_search_time_logN_def rbt_search_time_def by auto2 theorem rbt_search [hoare_triple]: "<rbt_map_assn M b * $(rbt_search_time_logN (sizeM1 M))> rbt_search x b <\<lambda>r. rbt_map_assn M b * \<up>(r = M\<langle>x\<rangle>)>\<^sub>t" by auto2 subsection \<open>delete\<close> lemma rbt_delete_time_logN_bound[asym_bound]: "(\<lambda>n. rbt_delete_time_logN n) \<in> \<Theta>(\<lambda>n. ln n)" unfolding rbt_delete_time_logN_def rbt_delete_time_def btree_del_time_def by auto2 theorem rbt_delete_rule [hoare_triple]: "<rbt_map_assn M b * $(rbt_delete_time_logN (sizeM1 M))> rbt_delete k b <rbt_map_assn (delete_map k M)>\<^sub>t" by auto2 end
# -*- coding: utf-8 -*- # # This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative works of this code must retain this # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. # pylint: disable=missing-docstring import unittest import numpy import qiskit from qiskit import QuantumRegister, QuantumCircuit, Aer from qiskit.quantum_info import state_fidelity, Statevector import qiskit.ignis.verification.tomography as tomo import qiskit.ignis.verification.tomography.fitters.cvx_fit as cvx_fit def run_circuit_and_tomography(circuit, qubits): psi = Statevector.from_instruction(circuit) qst = tomo.state_tomography_circuits(circuit, qubits) job = qiskit.execute(qst, Aer.get_backend('qasm_simulator'), shots=5000) tomo_fit = tomo.StateTomographyFitter(job.result(), qst) rho_cvx = tomo_fit.fit(method='cvx') rho_mle = tomo_fit.fit(method='lstsq') return (rho_cvx, rho_mle, psi) class TestFitter(unittest.TestCase): def test_trace_constraint(self): p = numpy.array([1/2, 1/2, 1/2, 1/2, 1/2, 1/2]) # the basis matrix for 1-qubit measurement in the Pauli basis A = numpy.array([ [0.5 + 0.j, 0.5 + 0.j, 0.5 + 0.j, 0.5 + 0.j], [0.5 + 0.j, -0.5 + 0.j, -0.5 + 0.j, 0.5 + 0.j], [0.5 + 0.j, 0. - 0.5j, 0. + 0.5j, 0.5 + 0.j], [0.5 + 0.j, 0. + 0.5j, 0. - 0.5j, 0.5 + 0.j], [1. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j], [0. + 0.j, 0. + 0.j, 0. + 0.j, 1. + 0.j] ]) for trace_value in [1, 0.3, 2, 0, 42]: rho = cvx_fit.cvx_fit(p, A, trace=trace_value) self.assertAlmostEqual(numpy.trace(rho), trace_value, places=3) class TestStateTomography(unittest.TestCase): def test_bell_2_qubits(self): q2 = QuantumRegister(2) bell = QuantumCircuit(q2) bell.h(q2[0]) bell.cx(q2[0], q2[1]) rho_cvx, rho_mle, psi = run_circuit_and_tomography(bell, q2) F_bell_cvx = state_fidelity(psi, rho_cvx, validate=False) self.assertAlmostEqual(F_bell_cvx, 1, places=1) F_bell_mle = state_fidelity(psi, rho_mle, validate=False) self.assertAlmostEqual(F_bell_mle, 1, places=1) def test_bell_3_qubits(self): q3 = QuantumRegister(3) bell = QuantumCircuit(q3) bell.h(q3[0]) bell.cx(q3[0], q3[1]) bell.cx(q3[1], q3[2]) rho_cvx, rho_mle, psi = run_circuit_and_tomography(bell, q3) F_bell_cvx = state_fidelity(psi, rho_cvx, validate=False) self.assertAlmostEqual(F_bell_cvx, 1, places=1) F_bell_mle = state_fidelity(psi, rho_mle, validate=False) self.assertAlmostEqual(F_bell_mle, 1, places=1) def test_complex_1_qubit_circuit(self): q = QuantumRegister(1) circ = QuantumCircuit(q) circ.u3(1, 1, 1, q[0]) rho_cvx, rho_mle, psi = run_circuit_and_tomography(circ, q) F_bell_cvx = state_fidelity(psi, rho_cvx, validate=False) self.assertAlmostEqual(F_bell_cvx, 1, places=1) F_bell_mle = state_fidelity(psi, rho_mle, validate=False) self.assertAlmostEqual(F_bell_mle, 1, places=1) def test_complex_3_qubit_circuit(self): def rand_angles(): # pylint: disable=E1101 return tuple(2 * numpy.pi * numpy.random.random(3) - numpy.pi) q = QuantumRegister(3) circ = QuantumCircuit(q) for j in range(3): circ.u3(*rand_angles(), q[j]) rho_cvx, rho_mle, psi = run_circuit_and_tomography(circ, q) F_bell_cvx = state_fidelity(psi, rho_cvx, validate=False) self.assertAlmostEqual(F_bell_cvx, 1, places=1) F_bell_mle = state_fidelity(psi, rho_mle, validate=False) self.assertAlmostEqual(F_bell_mle, 1, places=1) if __name__ == '__main__': unittest.main()
------------------------------------------------------------------------------ -- Abelian group base ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module GroupTheory.AbelianGroup.Base where -- We use the group theory base open import GroupTheory.Base public ------------------------------------------------------------------------------ -- Abelian group theory axioms -- We only need to add the commutativity axiom. postulate comm : ∀ a b → a · b ≡ b · a {-# ATP axiom comm #-}
lemma pcompose_0 [simp]: "pcompose 0 q = 0"
[STATEMENT] lemma is_nnf_nnf: "is_nnf (nnf F)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. is_nnf (nnf F) [PROOF STEP] by(induction F rule: nnf.induct; simp)
% This is material illustrating the methods from the book % Financial Modelling - Theory, Implementation and Practice with Matlab % source % Wiley Finance Series % ISBN 978-0-470-74489-5 % % Date: 02.05.2012 % % Authors: Joerg Kienitz % Daniel Wetterau % % Please send comments, suggestions, bugs, code etc. to % [email protected] % % (C) Joerg Kienitz, Daniel Wetterau % % Since this piece of code is distributed via the mathworks file-exchange % it is covered by the BSD license % % This code is being provided solely for information and general % illustrative purposes. The authors will not be responsible for the % consequences of reliance upon using the code or for numbers produced % from using the code. function f = RegCoeff(S, g, df, B, Nb, Nr) % calculates regression coefficients to be used with longstaff-schwartz v = g(:,end); % start for backward induction f = zeros(Nb, Nr-1); % backward induction and regression from t_{Nr-1} up to t_1 for i = Nr-1:-1:1 index = find(g(:,i) > 0); % all ITM paths s = S(index,i+1); % values of S at given time point v = v * df(i+1); % option value at t_i Acell = B(s); % evaluate basis function in cell array B A = cell2mat(Acell{:,:}); % convert to matrix f(:,i) = (A'*A)\(A'*v(index)); % determine coefficients c = A*f(:,i); % continuation value exercise = g(index,i) >= c; % early exercise v(index(exercise)) = g(index(exercise),i); end end
Formal statement is: lemma in_smallomega_zero [simp]: "f \<in> \<omega>[F](\<lambda>x. 0)" Informal statement is: The zero function is in the space of small-omega functions.
[STATEMENT] lemma preservation_var: shows "\<Theta>; \<Phi>; {||}; GNil; \<Delta> \<turnstile> VAR u : \<tau>' = v IN s \<Leftarrow> \<tau> \<Longrightarrow> \<Theta> \<turnstile> \<delta> \<sim> \<Delta> \<Longrightarrow> atom u \<sharp> \<delta> \<Longrightarrow> atom u \<sharp> \<Delta> \<Longrightarrow> \<Theta>; \<Phi>; {||}; GNil; (u,\<tau>')#\<^sub>\<Delta>\<Delta> \<turnstile> s \<Leftarrow> \<tau> \<and> \<Theta> \<turnstile> (u,v)#\<delta> \<sim> (u,\<tau>')#\<^sub>\<Delta>\<Delta>" and "check_branch_s \<Theta> \<Phi> {||} GNil \<Delta> tid dc const v cs \<tau> \<Longrightarrow> True" and "check_branch_list \<Theta> \<Phi> {||} \<Gamma> \<Delta> tid dclist v css \<tau> \<Longrightarrow> True" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<lbrakk> \<Theta> ; \<Phi> ; {||} ; GNil ; \<Delta> \<turnstile> VAR u : \<tau>' = v IN s \<Leftarrow> \<tau>; \<Theta> \<turnstile> \<delta> \<sim> \<Delta> ; atom u \<sharp> \<delta>; atom u \<sharp> \<Delta>\<rbrakk> \<Longrightarrow> \<Theta> ; \<Phi> ; {||} ; GNil ; (u, \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s \<Leftarrow> \<tau> \<and> \<Theta> \<turnstile> (u, v) # \<delta> \<sim> (u, \<tau>') #\<^sub>\<Delta> \<Delta> ) &&& ( \<Theta> ; \<Phi> ; {||} ; GNil ; \<Delta> ; tid ; dc ; const ; v \<turnstile> cs \<Leftarrow> \<tau> \<Longrightarrow> True) &&& ( \<Theta> ; \<Phi> ; {||} ; \<Gamma> ; \<Delta> ; tid ; dclist ; v \<turnstile> css \<Leftarrow> \<tau> \<Longrightarrow> True) [PROOF STEP] proof(nominal_induct "{||}::bv fset" GNil \<Delta> "VAR u : \<tau>' = v IN s" \<tau> and \<tau> and \<tau> rule: check_s_check_branch_s_check_branch_list.strong_induct) [PROOF STATE] proof (state) goal (4 subgoals): 1. \<And>\<Theta> \<B> \<Gamma> \<Delta> \<tau> const x \<Phi> tid cons v s. \<lbrakk> \<Theta> ; \<B> ; \<Gamma> \<turnstile>\<^sub>w\<^sub>f \<Delta> ; \<turnstile>\<^sub>w\<^sub>f \<Theta> ; \<Theta> ; \<B> ; \<Gamma> \<turnstile>\<^sub>w\<^sub>f \<tau> ; \<Theta> ; {||} ; GNil \<turnstile>\<^sub>w\<^sub>f const ; atom x \<sharp> \<Theta>; atom x \<sharp> \<Phi>; atom x \<sharp> \<B>; atom x \<sharp> \<Gamma>; atom x \<sharp> \<Delta>; atom x \<sharp> tid; atom x \<sharp> cons; atom x \<sharp> const; atom x \<sharp> v; atom x \<sharp> \<tau>; \<Theta> ; \<Phi> ; \<B> ; (x, b_of const, [ v ]\<^sup>c\<^sup>e == [ V_cons tid cons [ x ]\<^sup>v ]\<^sup>c\<^sup>e AND c_of const x ) #\<^sub>\<Gamma> \<Gamma> ; \<Delta> \<turnstile> s \<Leftarrow> \<tau>\<rbrakk> \<Longrightarrow> True 2. \<And>\<Theta> \<Phi> \<B> \<Gamma> \<Delta> tid cons const v cs \<tau> dclist css. \<lbrakk> \<Theta> ; \<Phi> ; \<B> ; \<Gamma> ; \<Delta> ; tid ; cons ; const ; v \<turnstile> cs \<Leftarrow> \<tau>; True; \<Theta> ; \<Phi> ; \<B> ; \<Gamma> ; \<Delta> ; tid ; dclist ; v \<turnstile> css \<Leftarrow> \<tau>; True\<rbrakk> \<Longrightarrow> True 3. \<And>\<Theta> \<Phi> \<B> \<Gamma> \<Delta> tid cons const v cs \<tau>. \<lbrakk> \<Theta> ; \<Phi> ; \<B> ; \<Gamma> ; \<Delta> ; tid ; cons ; const ; v \<turnstile> cs \<Leftarrow> \<tau>; True\<rbrakk> \<Longrightarrow> True 4. \<And>ua \<Theta> \<Phi> \<Delta> \<tau> sa. \<lbrakk>atom ua \<sharp> \<Theta>; atom ua \<sharp> \<Phi>; atom ua \<sharp> {||}; atom ua \<sharp> GNil; atom ua \<sharp> \<Delta>; atom ua \<sharp> \<tau>'; atom ua \<sharp> v; atom ua \<sharp> \<tau>; \<Theta> ; {||} ; GNil \<turnstile> v \<Leftarrow> \<tau>'; \<Theta> ; \<Phi> ; {||} ; GNil ; (ua, \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> sa \<Leftarrow> \<tau>; \<lbrakk>sa = VAR u : \<tau>' = v IN s; \<Theta> \<turnstile> \<delta> \<sim> (ua, \<tau>') #\<^sub>\<Delta> \<Delta> ; atom u \<sharp> \<delta>; atom u \<sharp> (ua, \<tau>') #\<^sub>\<Delta> \<Delta>\<rbrakk> \<Longrightarrow> \<Theta> ; \<Phi> ; {||} ; GNil ; (u, \<tau>') #\<^sub>\<Delta> (ua, \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s \<Leftarrow> \<tau> \<and> \<Theta> \<turnstile> (u, v) # \<delta> \<sim> (u, \<tau>') #\<^sub>\<Delta> (ua, \<tau>') #\<^sub>\<Delta> \<Delta> ; [[atom ua]]lst. sa = [[atom u]]lst. s; \<Theta> \<turnstile> \<delta> \<sim> \<Delta> ; atom u \<sharp> \<delta>; atom u \<sharp> \<Delta>\<rbrakk> \<Longrightarrow> \<Theta> ; \<Phi> ; {||} ; GNil ; (u, \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s \<Leftarrow> \<tau> \<and> \<Theta> \<turnstile> (u, v) # \<delta> \<sim> (u, \<tau>') #\<^sub>\<Delta> \<Delta> [PROOF STEP] case (check_varI u' \<Theta> \<Phi> \<Delta> \<tau> s') [PROOF STATE] proof (state) this: atom u' \<sharp> \<Theta> atom u' \<sharp> \<Phi> atom u' \<sharp> {||} atom u' \<sharp> GNil atom u' \<sharp> \<Delta> atom u' \<sharp> \<tau>' atom u' \<sharp> v atom u' \<sharp> \<tau> \<Theta> ; {||} ; GNil \<turnstile> v \<Leftarrow> \<tau>' \<Theta> ; \<Phi> ; {||} ; GNil ; (u', \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s' \<Leftarrow> \<tau> \<lbrakk>s' = VAR u : \<tau>' = v IN s; \<Theta> \<turnstile> \<delta> \<sim> (u', \<tau>') #\<^sub>\<Delta> \<Delta> ; atom u \<sharp> \<delta>; atom u \<sharp> (u', \<tau>') #\<^sub>\<Delta> \<Delta>\<rbrakk> \<Longrightarrow> \<Theta> ; \<Phi> ; {||} ; GNil ; (u, \<tau>') #\<^sub>\<Delta> (u', \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s \<Leftarrow> \<tau> \<and> \<Theta> \<turnstile> (u, v) # \<delta> \<sim> (u, \<tau>') #\<^sub>\<Delta> (u', \<tau>') #\<^sub>\<Delta> \<Delta> [[atom u']]lst. s' = [[atom u]]lst. s \<Theta> \<turnstile> \<delta> \<sim> \<Delta> atom u \<sharp> \<delta> atom u \<sharp> \<Delta> goal (4 subgoals): 1. \<And>\<Theta> \<B> \<Gamma> \<Delta> \<tau> const x \<Phi> tid cons v s. \<lbrakk> \<Theta> ; \<B> ; \<Gamma> \<turnstile>\<^sub>w\<^sub>f \<Delta> ; \<turnstile>\<^sub>w\<^sub>f \<Theta> ; \<Theta> ; \<B> ; \<Gamma> \<turnstile>\<^sub>w\<^sub>f \<tau> ; \<Theta> ; {||} ; GNil \<turnstile>\<^sub>w\<^sub>f const ; atom x \<sharp> \<Theta>; atom x \<sharp> \<Phi>; atom x \<sharp> \<B>; atom x \<sharp> \<Gamma>; atom x \<sharp> \<Delta>; atom x \<sharp> tid; atom x \<sharp> cons; atom x \<sharp> const; atom x \<sharp> v; atom x \<sharp> \<tau>; \<Theta> ; \<Phi> ; \<B> ; (x, b_of const, [ v ]\<^sup>c\<^sup>e == [ V_cons tid cons [ x ]\<^sup>v ]\<^sup>c\<^sup>e AND c_of const x ) #\<^sub>\<Gamma> \<Gamma> ; \<Delta> \<turnstile> s \<Leftarrow> \<tau>\<rbrakk> \<Longrightarrow> True 2. \<And>\<Theta> \<Phi> \<B> \<Gamma> \<Delta> tid cons const v cs \<tau> dclist css. \<lbrakk> \<Theta> ; \<Phi> ; \<B> ; \<Gamma> ; \<Delta> ; tid ; cons ; const ; v \<turnstile> cs \<Leftarrow> \<tau>; True; \<Theta> ; \<Phi> ; \<B> ; \<Gamma> ; \<Delta> ; tid ; dclist ; v \<turnstile> css \<Leftarrow> \<tau>; True\<rbrakk> \<Longrightarrow> True 3. \<And>\<Theta> \<Phi> \<B> \<Gamma> \<Delta> tid cons const v cs \<tau>. \<lbrakk> \<Theta> ; \<Phi> ; \<B> ; \<Gamma> ; \<Delta> ; tid ; cons ; const ; v \<turnstile> cs \<Leftarrow> \<tau>; True\<rbrakk> \<Longrightarrow> True 4. \<And>ua \<Theta> \<Phi> \<Delta> \<tau> sa. \<lbrakk>atom ua \<sharp> \<Theta>; atom ua \<sharp> \<Phi>; atom ua \<sharp> {||}; atom ua \<sharp> GNil; atom ua \<sharp> \<Delta>; atom ua \<sharp> \<tau>'; atom ua \<sharp> v; atom ua \<sharp> \<tau>; \<Theta> ; {||} ; GNil \<turnstile> v \<Leftarrow> \<tau>'; \<Theta> ; \<Phi> ; {||} ; GNil ; (ua, \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> sa \<Leftarrow> \<tau>; \<lbrakk>sa = VAR u : \<tau>' = v IN s; \<Theta> \<turnstile> \<delta> \<sim> (ua, \<tau>') #\<^sub>\<Delta> \<Delta> ; atom u \<sharp> \<delta>; atom u \<sharp> (ua, \<tau>') #\<^sub>\<Delta> \<Delta>\<rbrakk> \<Longrightarrow> \<Theta> ; \<Phi> ; {||} ; GNil ; (u, \<tau>') #\<^sub>\<Delta> (ua, \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s \<Leftarrow> \<tau> \<and> \<Theta> \<turnstile> (u, v) # \<delta> \<sim> (u, \<tau>') #\<^sub>\<Delta> (ua, \<tau>') #\<^sub>\<Delta> \<Delta> ; [[atom ua]]lst. sa = [[atom u]]lst. s; \<Theta> \<turnstile> \<delta> \<sim> \<Delta> ; atom u \<sharp> \<delta>; atom u \<sharp> \<Delta>\<rbrakk> \<Longrightarrow> \<Theta> ; \<Phi> ; {||} ; GNil ; (u, \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s \<Leftarrow> \<tau> \<and> \<Theta> \<turnstile> (u, v) # \<delta> \<sim> (u, \<tau>') #\<^sub>\<Delta> \<Delta> [PROOF STEP] hence "\<Theta>; \<Phi>; {||}; GNil; (u, \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s \<Leftarrow> \<tau>" [PROOF STATE] proof (prove) using this: atom u' \<sharp> \<Theta> atom u' \<sharp> \<Phi> atom u' \<sharp> {||} atom u' \<sharp> GNil atom u' \<sharp> \<Delta> atom u' \<sharp> \<tau>' atom u' \<sharp> v atom u' \<sharp> \<tau> \<Theta> ; {||} ; GNil \<turnstile> v \<Leftarrow> \<tau>' \<Theta> ; \<Phi> ; {||} ; GNil ; (u', \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s' \<Leftarrow> \<tau> \<lbrakk>s' = VAR u : \<tau>' = v IN s; \<Theta> \<turnstile> \<delta> \<sim> (u', \<tau>') #\<^sub>\<Delta> \<Delta> ; atom u \<sharp> \<delta>; atom u \<sharp> (u', \<tau>') #\<^sub>\<Delta> \<Delta>\<rbrakk> \<Longrightarrow> \<Theta> ; \<Phi> ; {||} ; GNil ; (u, \<tau>') #\<^sub>\<Delta> (u', \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s \<Leftarrow> \<tau> \<and> \<Theta> \<turnstile> (u, v) # \<delta> \<sim> (u, \<tau>') #\<^sub>\<Delta> (u', \<tau>') #\<^sub>\<Delta> \<Delta> [[atom u']]lst. s' = [[atom u]]lst. s \<Theta> \<turnstile> \<delta> \<sim> \<Delta> atom u \<sharp> \<delta> atom u \<sharp> \<Delta> goal (1 subgoal): 1. \<Theta> ; \<Phi> ; {||} ; GNil ; (u, \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s \<Leftarrow> \<tau> [PROOF STEP] using check_s_abs_u check_v_wf [PROOF STATE] proof (prove) using this: atom u' \<sharp> \<Theta> atom u' \<sharp> \<Phi> atom u' \<sharp> {||} atom u' \<sharp> GNil atom u' \<sharp> \<Delta> atom u' \<sharp> \<tau>' atom u' \<sharp> v atom u' \<sharp> \<tau> \<Theta> ; {||} ; GNil \<turnstile> v \<Leftarrow> \<tau>' \<Theta> ; \<Phi> ; {||} ; GNil ; (u', \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s' \<Leftarrow> \<tau> \<lbrakk>s' = VAR u : \<tau>' = v IN s; \<Theta> \<turnstile> \<delta> \<sim> (u', \<tau>') #\<^sub>\<Delta> \<Delta> ; atom u \<sharp> \<delta>; atom u \<sharp> (u', \<tau>') #\<^sub>\<Delta> \<Delta>\<rbrakk> \<Longrightarrow> \<Theta> ; \<Phi> ; {||} ; GNil ; (u, \<tau>') #\<^sub>\<Delta> (u', \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s \<Leftarrow> \<tau> \<and> \<Theta> \<turnstile> (u, v) # \<delta> \<sim> (u, \<tau>') #\<^sub>\<Delta> (u', \<tau>') #\<^sub>\<Delta> \<Delta> [[atom u']]lst. s' = [[atom u]]lst. s \<Theta> \<turnstile> \<delta> \<sim> \<Delta> atom u \<sharp> \<delta> atom u \<sharp> \<Delta> \<lbrakk>[[atom ?u]]lst. ?s = [[atom ?u']]lst. ?s'; atom ?u \<sharp> ?\<Delta>; atom ?u' \<sharp> ?\<Delta>; ?\<Theta> ; ?B ; ?\<Gamma> \<turnstile>\<^sub>w\<^sub>f ?\<tau>' ; ?\<Theta> ; ?\<Phi> ; ?B ; ?\<Gamma> ; (?u, ?\<tau>') #\<^sub>\<Delta> ?\<Delta> \<turnstile> ?s \<Leftarrow> ?\<tau>\<rbrakk> \<Longrightarrow> ?\<Theta> ; ?\<Phi> ; ?B ; ?\<Gamma> ; (?u', ?\<tau>') #\<^sub>\<Delta> ?\<Delta> \<turnstile> ?s' \<Leftarrow> ?\<tau> ?\<Theta> ; ?\<B> ; ?\<Gamma> \<turnstile> ?v \<Leftarrow> ?\<tau> \<Longrightarrow> ?\<Theta> ; ?\<B> \<turnstile>\<^sub>w\<^sub>f ?\<Gamma> ?\<Theta> ; ?\<B> ; ?\<Gamma> \<turnstile> ?v \<Leftarrow> ?\<tau> \<Longrightarrow> ?\<Theta> ; ?\<B> ; ?\<Gamma> \<turnstile>\<^sub>w\<^sub>f ?v : b_of ?\<tau> ?\<Theta> ; ?\<B> ; ?\<Gamma> \<turnstile> ?v \<Leftarrow> ?\<tau> \<Longrightarrow> ?\<Theta> ; ?\<B> ; ?\<Gamma> \<turnstile>\<^sub>w\<^sub>f ?\<tau> goal (1 subgoal): 1. \<Theta> ; \<Phi> ; {||} ; GNil ; (u, \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s \<Leftarrow> \<tau> [PROOF STEP] by metis [PROOF STATE] proof (state) this: \<Theta> ; \<Phi> ; {||} ; GNil ; (u, \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s \<Leftarrow> \<tau> goal (4 subgoals): 1. \<And>\<Theta> \<B> \<Gamma> \<Delta> \<tau> const x \<Phi> tid cons v s. \<lbrakk> \<Theta> ; \<B> ; \<Gamma> \<turnstile>\<^sub>w\<^sub>f \<Delta> ; \<turnstile>\<^sub>w\<^sub>f \<Theta> ; \<Theta> ; \<B> ; \<Gamma> \<turnstile>\<^sub>w\<^sub>f \<tau> ; \<Theta> ; {||} ; GNil \<turnstile>\<^sub>w\<^sub>f const ; atom x \<sharp> \<Theta>; atom x \<sharp> \<Phi>; atom x \<sharp> \<B>; atom x \<sharp> \<Gamma>; atom x \<sharp> \<Delta>; atom x \<sharp> tid; atom x \<sharp> cons; atom x \<sharp> const; atom x \<sharp> v; atom x \<sharp> \<tau>; \<Theta> ; \<Phi> ; \<B> ; (x, b_of const, [ v ]\<^sup>c\<^sup>e == [ V_cons tid cons [ x ]\<^sup>v ]\<^sup>c\<^sup>e AND c_of const x ) #\<^sub>\<Gamma> \<Gamma> ; \<Delta> \<turnstile> s \<Leftarrow> \<tau>\<rbrakk> \<Longrightarrow> True 2. \<And>\<Theta> \<Phi> \<B> \<Gamma> \<Delta> tid cons const v cs \<tau> dclist css. \<lbrakk> \<Theta> ; \<Phi> ; \<B> ; \<Gamma> ; \<Delta> ; tid ; cons ; const ; v \<turnstile> cs \<Leftarrow> \<tau>; True; \<Theta> ; \<Phi> ; \<B> ; \<Gamma> ; \<Delta> ; tid ; dclist ; v \<turnstile> css \<Leftarrow> \<tau>; True\<rbrakk> \<Longrightarrow> True 3. \<And>\<Theta> \<Phi> \<B> \<Gamma> \<Delta> tid cons const v cs \<tau>. \<lbrakk> \<Theta> ; \<Phi> ; \<B> ; \<Gamma> ; \<Delta> ; tid ; cons ; const ; v \<turnstile> cs \<Leftarrow> \<tau>; True\<rbrakk> \<Longrightarrow> True 4. \<And>ua \<Theta> \<Phi> \<Delta> \<tau> sa. \<lbrakk>atom ua \<sharp> \<Theta>; atom ua \<sharp> \<Phi>; atom ua \<sharp> {||}; atom ua \<sharp> GNil; atom ua \<sharp> \<Delta>; atom ua \<sharp> \<tau>'; atom ua \<sharp> v; atom ua \<sharp> \<tau>; \<Theta> ; {||} ; GNil \<turnstile> v \<Leftarrow> \<tau>'; \<Theta> ; \<Phi> ; {||} ; GNil ; (ua, \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> sa \<Leftarrow> \<tau>; \<lbrakk>sa = VAR u : \<tau>' = v IN s; \<Theta> \<turnstile> \<delta> \<sim> (ua, \<tau>') #\<^sub>\<Delta> \<Delta> ; atom u \<sharp> \<delta>; atom u \<sharp> (ua, \<tau>') #\<^sub>\<Delta> \<Delta>\<rbrakk> \<Longrightarrow> \<Theta> ; \<Phi> ; {||} ; GNil ; (u, \<tau>') #\<^sub>\<Delta> (ua, \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s \<Leftarrow> \<tau> \<and> \<Theta> \<turnstile> (u, v) # \<delta> \<sim> (u, \<tau>') #\<^sub>\<Delta> (ua, \<tau>') #\<^sub>\<Delta> \<Delta> ; [[atom ua]]lst. sa = [[atom u]]lst. s; \<Theta> \<turnstile> \<delta> \<sim> \<Delta> ; atom u \<sharp> \<delta>; atom u \<sharp> \<Delta>\<rbrakk> \<Longrightarrow> \<Theta> ; \<Phi> ; {||} ; GNil ; (u, \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s \<Leftarrow> \<tau> \<and> \<Theta> \<turnstile> (u, v) # \<delta> \<sim> (u, \<tau>') #\<^sub>\<Delta> \<Delta> [PROOF STEP] moreover [PROOF STATE] proof (state) this: \<Theta> ; \<Phi> ; {||} ; GNil ; (u, \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s \<Leftarrow> \<tau> goal (4 subgoals): 1. \<And>\<Theta> \<B> \<Gamma> \<Delta> \<tau> const x \<Phi> tid cons v s. \<lbrakk> \<Theta> ; \<B> ; \<Gamma> \<turnstile>\<^sub>w\<^sub>f \<Delta> ; \<turnstile>\<^sub>w\<^sub>f \<Theta> ; \<Theta> ; \<B> ; \<Gamma> \<turnstile>\<^sub>w\<^sub>f \<tau> ; \<Theta> ; {||} ; GNil \<turnstile>\<^sub>w\<^sub>f const ; atom x \<sharp> \<Theta>; atom x \<sharp> \<Phi>; atom x \<sharp> \<B>; atom x \<sharp> \<Gamma>; atom x \<sharp> \<Delta>; atom x \<sharp> tid; atom x \<sharp> cons; atom x \<sharp> const; atom x \<sharp> v; atom x \<sharp> \<tau>; \<Theta> ; \<Phi> ; \<B> ; (x, b_of const, [ v ]\<^sup>c\<^sup>e == [ V_cons tid cons [ x ]\<^sup>v ]\<^sup>c\<^sup>e AND c_of const x ) #\<^sub>\<Gamma> \<Gamma> ; \<Delta> \<turnstile> s \<Leftarrow> \<tau>\<rbrakk> \<Longrightarrow> True 2. \<And>\<Theta> \<Phi> \<B> \<Gamma> \<Delta> tid cons const v cs \<tau> dclist css. \<lbrakk> \<Theta> ; \<Phi> ; \<B> ; \<Gamma> ; \<Delta> ; tid ; cons ; const ; v \<turnstile> cs \<Leftarrow> \<tau>; True; \<Theta> ; \<Phi> ; \<B> ; \<Gamma> ; \<Delta> ; tid ; dclist ; v \<turnstile> css \<Leftarrow> \<tau>; True\<rbrakk> \<Longrightarrow> True 3. \<And>\<Theta> \<Phi> \<B> \<Gamma> \<Delta> tid cons const v cs \<tau>. \<lbrakk> \<Theta> ; \<Phi> ; \<B> ; \<Gamma> ; \<Delta> ; tid ; cons ; const ; v \<turnstile> cs \<Leftarrow> \<tau>; True\<rbrakk> \<Longrightarrow> True 4. \<And>ua \<Theta> \<Phi> \<Delta> \<tau> sa. \<lbrakk>atom ua \<sharp> \<Theta>; atom ua \<sharp> \<Phi>; atom ua \<sharp> {||}; atom ua \<sharp> GNil; atom ua \<sharp> \<Delta>; atom ua \<sharp> \<tau>'; atom ua \<sharp> v; atom ua \<sharp> \<tau>; \<Theta> ; {||} ; GNil \<turnstile> v \<Leftarrow> \<tau>'; \<Theta> ; \<Phi> ; {||} ; GNil ; (ua, \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> sa \<Leftarrow> \<tau>; \<lbrakk>sa = VAR u : \<tau>' = v IN s; \<Theta> \<turnstile> \<delta> \<sim> (ua, \<tau>') #\<^sub>\<Delta> \<Delta> ; atom u \<sharp> \<delta>; atom u \<sharp> (ua, \<tau>') #\<^sub>\<Delta> \<Delta>\<rbrakk> \<Longrightarrow> \<Theta> ; \<Phi> ; {||} ; GNil ; (u, \<tau>') #\<^sub>\<Delta> (ua, \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s \<Leftarrow> \<tau> \<and> \<Theta> \<turnstile> (u, v) # \<delta> \<sim> (u, \<tau>') #\<^sub>\<Delta> (ua, \<tau>') #\<^sub>\<Delta> \<Delta> ; [[atom ua]]lst. sa = [[atom u]]lst. s; \<Theta> \<turnstile> \<delta> \<sim> \<Delta> ; atom u \<sharp> \<delta>; atom u \<sharp> \<Delta>\<rbrakk> \<Longrightarrow> \<Theta> ; \<Phi> ; {||} ; GNil ; (u, \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s \<Leftarrow> \<tau> \<and> \<Theta> \<turnstile> (u, v) # \<delta> \<sim> (u, \<tau>') #\<^sub>\<Delta> \<Delta> [PROOF STEP] have "\<Theta> \<turnstile> ((u,v)#\<delta>) \<sim> ((u,\<tau>')#\<^sub>\<Delta>\<Delta>)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<Theta> \<turnstile> (u, v) # \<delta> \<sim> (u, \<tau>') #\<^sub>\<Delta> \<Delta> [PROOF STEP] proof [PROOF STATE] proof (state) goal (3 subgoals): 1. \<Theta> \<turnstile> \<delta> \<sim> \<Delta> 2. \<Theta> ; {||} ; GNil \<turnstile> v \<Leftarrow> \<tau>' 3. u \<notin> fst ` set \<delta> [PROOF STEP] show \<open>\<Theta> \<turnstile> \<delta> \<sim> \<Delta> \<close> [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<Theta> \<turnstile> \<delta> \<sim> \<Delta> [PROOF STEP] using check_varI [PROOF STATE] proof (prove) using this: atom u' \<sharp> \<Theta> atom u' \<sharp> \<Phi> atom u' \<sharp> {||} atom u' \<sharp> GNil atom u' \<sharp> \<Delta> atom u' \<sharp> \<tau>' atom u' \<sharp> v atom u' \<sharp> \<tau> \<Theta> ; {||} ; GNil \<turnstile> v \<Leftarrow> \<tau>' \<Theta> ; \<Phi> ; {||} ; GNil ; (u', \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s' \<Leftarrow> \<tau> \<lbrakk>s' = VAR u : \<tau>' = v IN s; \<Theta> \<turnstile> \<delta> \<sim> (u', \<tau>') #\<^sub>\<Delta> \<Delta> ; atom u \<sharp> \<delta>; atom u \<sharp> (u', \<tau>') #\<^sub>\<Delta> \<Delta>\<rbrakk> \<Longrightarrow> \<Theta> ; \<Phi> ; {||} ; GNil ; (u, \<tau>') #\<^sub>\<Delta> (u', \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s \<Leftarrow> \<tau> \<and> \<Theta> \<turnstile> (u, v) # \<delta> \<sim> (u, \<tau>') #\<^sub>\<Delta> (u', \<tau>') #\<^sub>\<Delta> \<Delta> [[atom u']]lst. s' = [[atom u]]lst. s \<Theta> \<turnstile> \<delta> \<sim> \<Delta> atom u \<sharp> \<delta> atom u \<sharp> \<Delta> goal (1 subgoal): 1. \<Theta> \<turnstile> \<delta> \<sim> \<Delta> [PROOF STEP] by auto [PROOF STATE] proof (state) this: \<Theta> \<turnstile> \<delta> \<sim> \<Delta> goal (2 subgoals): 1. \<Theta> ; {||} ; GNil \<turnstile> v \<Leftarrow> \<tau>' 2. u \<notin> fst ` set \<delta> [PROOF STEP] show \<open>\<Theta> ; {||} ; GNil \<turnstile> v \<Leftarrow> \<tau>'\<close> [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<Theta> ; {||} ; GNil \<turnstile> v \<Leftarrow> \<tau>' [PROOF STEP] using check_varI [PROOF STATE] proof (prove) using this: atom u' \<sharp> \<Theta> atom u' \<sharp> \<Phi> atom u' \<sharp> {||} atom u' \<sharp> GNil atom u' \<sharp> \<Delta> atom u' \<sharp> \<tau>' atom u' \<sharp> v atom u' \<sharp> \<tau> \<Theta> ; {||} ; GNil \<turnstile> v \<Leftarrow> \<tau>' \<Theta> ; \<Phi> ; {||} ; GNil ; (u', \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s' \<Leftarrow> \<tau> \<lbrakk>s' = VAR u : \<tau>' = v IN s; \<Theta> \<turnstile> \<delta> \<sim> (u', \<tau>') #\<^sub>\<Delta> \<Delta> ; atom u \<sharp> \<delta>; atom u \<sharp> (u', \<tau>') #\<^sub>\<Delta> \<Delta>\<rbrakk> \<Longrightarrow> \<Theta> ; \<Phi> ; {||} ; GNil ; (u, \<tau>') #\<^sub>\<Delta> (u', \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s \<Leftarrow> \<tau> \<and> \<Theta> \<turnstile> (u, v) # \<delta> \<sim> (u, \<tau>') #\<^sub>\<Delta> (u', \<tau>') #\<^sub>\<Delta> \<Delta> [[atom u']]lst. s' = [[atom u]]lst. s \<Theta> \<turnstile> \<delta> \<sim> \<Delta> atom u \<sharp> \<delta> atom u \<sharp> \<Delta> goal (1 subgoal): 1. \<Theta> ; {||} ; GNil \<turnstile> v \<Leftarrow> \<tau>' [PROOF STEP] by auto [PROOF STATE] proof (state) this: \<Theta> ; {||} ; GNil \<turnstile> v \<Leftarrow> \<tau>' goal (1 subgoal): 1. u \<notin> fst ` set \<delta> [PROOF STEP] show \<open>u \<notin> fst ` set \<delta>\<close> [PROOF STATE] proof (prove) goal (1 subgoal): 1. u \<notin> fst ` set \<delta> [PROOF STEP] using check_varI fresh_d_fst_d [PROOF STATE] proof (prove) using this: atom u' \<sharp> \<Theta> atom u' \<sharp> \<Phi> atom u' \<sharp> {||} atom u' \<sharp> GNil atom u' \<sharp> \<Delta> atom u' \<sharp> \<tau>' atom u' \<sharp> v atom u' \<sharp> \<tau> \<Theta> ; {||} ; GNil \<turnstile> v \<Leftarrow> \<tau>' \<Theta> ; \<Phi> ; {||} ; GNil ; (u', \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s' \<Leftarrow> \<tau> \<lbrakk>s' = VAR u : \<tau>' = v IN s; \<Theta> \<turnstile> \<delta> \<sim> (u', \<tau>') #\<^sub>\<Delta> \<Delta> ; atom u \<sharp> \<delta>; atom u \<sharp> (u', \<tau>') #\<^sub>\<Delta> \<Delta>\<rbrakk> \<Longrightarrow> \<Theta> ; \<Phi> ; {||} ; GNil ; (u, \<tau>') #\<^sub>\<Delta> (u', \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s \<Leftarrow> \<tau> \<and> \<Theta> \<turnstile> (u, v) # \<delta> \<sim> (u, \<tau>') #\<^sub>\<Delta> (u', \<tau>') #\<^sub>\<Delta> \<Delta> [[atom u']]lst. s' = [[atom u]]lst. s \<Theta> \<turnstile> \<delta> \<sim> \<Delta> atom u \<sharp> \<delta> atom u \<sharp> \<Delta> atom ?u \<sharp> ?\<delta> \<Longrightarrow> ?u \<notin> fst ` set ?\<delta> goal (1 subgoal): 1. u \<notin> fst ` set \<delta> [PROOF STEP] by auto [PROOF STATE] proof (state) this: u \<notin> fst ` set \<delta> goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<Theta> \<turnstile> (u, v) # \<delta> \<sim> (u, \<tau>') #\<^sub>\<Delta> \<Delta> goal (4 subgoals): 1. \<And>\<Theta> \<B> \<Gamma> \<Delta> \<tau> const x \<Phi> tid cons v s. \<lbrakk> \<Theta> ; \<B> ; \<Gamma> \<turnstile>\<^sub>w\<^sub>f \<Delta> ; \<turnstile>\<^sub>w\<^sub>f \<Theta> ; \<Theta> ; \<B> ; \<Gamma> \<turnstile>\<^sub>w\<^sub>f \<tau> ; \<Theta> ; {||} ; GNil \<turnstile>\<^sub>w\<^sub>f const ; atom x \<sharp> \<Theta>; atom x \<sharp> \<Phi>; atom x \<sharp> \<B>; atom x \<sharp> \<Gamma>; atom x \<sharp> \<Delta>; atom x \<sharp> tid; atom x \<sharp> cons; atom x \<sharp> const; atom x \<sharp> v; atom x \<sharp> \<tau>; \<Theta> ; \<Phi> ; \<B> ; (x, b_of const, [ v ]\<^sup>c\<^sup>e == [ V_cons tid cons [ x ]\<^sup>v ]\<^sup>c\<^sup>e AND c_of const x ) #\<^sub>\<Gamma> \<Gamma> ; \<Delta> \<turnstile> s \<Leftarrow> \<tau>\<rbrakk> \<Longrightarrow> True 2. \<And>\<Theta> \<Phi> \<B> \<Gamma> \<Delta> tid cons const v cs \<tau> dclist css. \<lbrakk> \<Theta> ; \<Phi> ; \<B> ; \<Gamma> ; \<Delta> ; tid ; cons ; const ; v \<turnstile> cs \<Leftarrow> \<tau>; True; \<Theta> ; \<Phi> ; \<B> ; \<Gamma> ; \<Delta> ; tid ; dclist ; v \<turnstile> css \<Leftarrow> \<tau>; True\<rbrakk> \<Longrightarrow> True 3. \<And>\<Theta> \<Phi> \<B> \<Gamma> \<Delta> tid cons const v cs \<tau>. \<lbrakk> \<Theta> ; \<Phi> ; \<B> ; \<Gamma> ; \<Delta> ; tid ; cons ; const ; v \<turnstile> cs \<Leftarrow> \<tau>; True\<rbrakk> \<Longrightarrow> True 4. \<And>ua \<Theta> \<Phi> \<Delta> \<tau> sa. \<lbrakk>atom ua \<sharp> \<Theta>; atom ua \<sharp> \<Phi>; atom ua \<sharp> {||}; atom ua \<sharp> GNil; atom ua \<sharp> \<Delta>; atom ua \<sharp> \<tau>'; atom ua \<sharp> v; atom ua \<sharp> \<tau>; \<Theta> ; {||} ; GNil \<turnstile> v \<Leftarrow> \<tau>'; \<Theta> ; \<Phi> ; {||} ; GNil ; (ua, \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> sa \<Leftarrow> \<tau>; \<lbrakk>sa = VAR u : \<tau>' = v IN s; \<Theta> \<turnstile> \<delta> \<sim> (ua, \<tau>') #\<^sub>\<Delta> \<Delta> ; atom u \<sharp> \<delta>; atom u \<sharp> (ua, \<tau>') #\<^sub>\<Delta> \<Delta>\<rbrakk> \<Longrightarrow> \<Theta> ; \<Phi> ; {||} ; GNil ; (u, \<tau>') #\<^sub>\<Delta> (ua, \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s \<Leftarrow> \<tau> \<and> \<Theta> \<turnstile> (u, v) # \<delta> \<sim> (u, \<tau>') #\<^sub>\<Delta> (ua, \<tau>') #\<^sub>\<Delta> \<Delta> ; [[atom ua]]lst. sa = [[atom u]]lst. s; \<Theta> \<turnstile> \<delta> \<sim> \<Delta> ; atom u \<sharp> \<delta>; atom u \<sharp> \<Delta>\<rbrakk> \<Longrightarrow> \<Theta> ; \<Phi> ; {||} ; GNil ; (u, \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s \<Leftarrow> \<tau> \<and> \<Theta> \<turnstile> (u, v) # \<delta> \<sim> (u, \<tau>') #\<^sub>\<Delta> \<Delta> [PROOF STEP] ultimately [PROOF STATE] proof (chain) picking this: \<Theta> ; \<Phi> ; {||} ; GNil ; (u, \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s \<Leftarrow> \<tau> \<Theta> \<turnstile> (u, v) # \<delta> \<sim> (u, \<tau>') #\<^sub>\<Delta> \<Delta> [PROOF STEP] show ?case [PROOF STATE] proof (prove) using this: \<Theta> ; \<Phi> ; {||} ; GNil ; (u, \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s \<Leftarrow> \<tau> \<Theta> \<turnstile> (u, v) # \<delta> \<sim> (u, \<tau>') #\<^sub>\<Delta> \<Delta> goal (1 subgoal): 1. \<Theta> ; \<Phi> ; {||} ; GNil ; (u, \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s \<Leftarrow> \<tau> \<and> \<Theta> \<turnstile> (u, v) # \<delta> \<sim> (u, \<tau>') #\<^sub>\<Delta> \<Delta> [PROOF STEP] by simp [PROOF STATE] proof (state) this: \<Theta> ; \<Phi> ; {||} ; GNil ; (u, \<tau>') #\<^sub>\<Delta> \<Delta> \<turnstile> s \<Leftarrow> \<tau> \<and> \<Theta> \<turnstile> (u, v) # \<delta> \<sim> (u, \<tau>') #\<^sub>\<Delta> \<Delta> goal (3 subgoals): 1. \<And>\<Theta> \<B> \<Gamma> \<Delta> \<tau> const x \<Phi> tid cons v s. \<lbrakk> \<Theta> ; \<B> ; \<Gamma> \<turnstile>\<^sub>w\<^sub>f \<Delta> ; \<turnstile>\<^sub>w\<^sub>f \<Theta> ; \<Theta> ; \<B> ; \<Gamma> \<turnstile>\<^sub>w\<^sub>f \<tau> ; \<Theta> ; {||} ; GNil \<turnstile>\<^sub>w\<^sub>f const ; atom x \<sharp> \<Theta>; atom x \<sharp> \<Phi>; atom x \<sharp> \<B>; atom x \<sharp> \<Gamma>; atom x \<sharp> \<Delta>; atom x \<sharp> tid; atom x \<sharp> cons; atom x \<sharp> const; atom x \<sharp> v; atom x \<sharp> \<tau>; \<Theta> ; \<Phi> ; \<B> ; (x, b_of const, [ v ]\<^sup>c\<^sup>e == [ V_cons tid cons [ x ]\<^sup>v ]\<^sup>c\<^sup>e AND c_of const x ) #\<^sub>\<Gamma> \<Gamma> ; \<Delta> \<turnstile> s \<Leftarrow> \<tau>\<rbrakk> \<Longrightarrow> True 2. \<And>\<Theta> \<Phi> \<B> \<Gamma> \<Delta> tid cons const v cs \<tau> dclist css. \<lbrakk> \<Theta> ; \<Phi> ; \<B> ; \<Gamma> ; \<Delta> ; tid ; cons ; const ; v \<turnstile> cs \<Leftarrow> \<tau>; True; \<Theta> ; \<Phi> ; \<B> ; \<Gamma> ; \<Delta> ; tid ; dclist ; v \<turnstile> css \<Leftarrow> \<tau>; True\<rbrakk> \<Longrightarrow> True 3. \<And>\<Theta> \<Phi> \<B> \<Gamma> \<Delta> tid cons const v cs \<tau>. \<lbrakk> \<Theta> ; \<Phi> ; \<B> ; \<Gamma> ; \<Delta> ; tid ; cons ; const ; v \<turnstile> cs \<Leftarrow> \<tau>; True\<rbrakk> \<Longrightarrow> True [PROOF STEP] qed(auto+)
Though Frank recovered from the slide and achieved a peak population of 1 @,@ 000 shortly thereafter , the closure of the mine resulted in a longstanding decline in population . Frank ceased to be an independent community in 1979 when it was amalgamated into the Municipality of Crowsnest Pass along with the neighbouring communities of Blairmore , Coleman , Hillcrest and Bellevue . Frank is now home to about 200 residents .
/** * * @generated d Tue Jan 7 11:45:26 2014 * **/ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> #ifdef USE_MKL #include <mkl_cblas.h> #include <mkl_lapacke.h> #else #include <cblas.h> #include <lapacke.h> #endif #include "plasma.h" #include <core_blas.h> #include "auxiliary.h" /*-------------------------------------------------------------- * Check the solution */ double d_check_solution(int M, int N, int NRHS, double *A, int LDA, double *B, double *X, int LDB) { /* int info_solution; */ double Rnorm = -1.00; double zone = 1.0; double mzone = -1.0; double *work = (double *)malloc(max(M, N)* sizeof(double)); LAPACKE_dlange_work(LAPACK_COL_MAJOR, 'i', M, N, A, LDA, work); LAPACKE_dlange_work(LAPACK_COL_MAJOR, 'i', M, NRHS, X, LDB, work); LAPACKE_dlange_work(LAPACK_COL_MAJOR, 'i', N, NRHS, B, LDB, work); cblas_dgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, M, NRHS, N, (zone), A, LDA, X, LDB, (mzone), B, LDB); Rnorm = LAPACKE_dlange_work(LAPACK_COL_MAJOR, 'i', N, NRHS, B, LDB, work); free(work); return Rnorm; }
The Selenga Pulp & Paper Company operates a zero discharge unbleached Kraft Mill. Located in an enviromnentally sensitive area, the operation is situated on the Selenga River, about 60 kilometers from the south shore of Lake Baikal. The Selenga River is the largest source of water for Lake Baikal, a lake considered by Russians as a natural resource jewel. Lake Baikal is one of the worlds deepest and cleanest lakes and contains one fifth of the worlds fresh water, more water than the Great Lakes combined. Until 1990, the Selenga Pulp & Paper Co. was considered one of the major polluters of the river. However, in August 1990, the mill began effluent recycling. This was accomplished by activated sludge technology in conjunction with chemical - physical treatment. The mill, in partnership with Sibgiprobum, a design institute for the Siberian pulp and paper industry developed the closed cycle system. The regulatory history, and treatment plant design will be reviewed in this paper.
%%%%% Point Pillar Lidar Deep Learning Face Finding %%%%%% %%%%% Karissa Stisser, Zach Larson, Naseem Alfaqueh, Anjali Patil, Adrian Lindsey, Omar Rizk \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{graphicx} \title{Point Pillar Lidar Deep Learning Face Finding} \author{Karissa Stisser, Zach Larson, Naseem Alfaqueh\\ \\Anjali Patil, Adrian Lindsey, Omar Rizk } \date{April 2021- https://github.com/kstisser/DeepLearningPointCloud} \begin{document} \maketitle \section{Introduction} We have created a system that uses deep learning to recognize a face in point cloud data using time series data in real time for surgical applications. As this use case is very specific, we focused on leveraging knowledge of the space and procedure to optimize the output rather than try to create a solution for all scenarios. We build a preprocessing pipeline that eliminated unnecessary points, leveraged the point pillars deep learning architecture\cite{pointpillars}, and modified the output for a point by point decision on whether that pixel belonged to the face. Development was done in two stages. First, separate pieces were developed in Jupyter notebooks. Second those notebooks were integrated into the final product. Many but not all components made it to the second stage. \section{Data Augmentation} As we started with 7 point clouds, we developed a data augmentation plan to be used on both the train and test data that involves background mixing, translation, rotation, scaling, and flipping as we would like the trained algorithm to be more robust to camera placement in relation to the face. We only modified in the x and y directions, as modifications in the z directions would actually add and remove points, which we weren't confident in accurately augmenting. We start by matching each face with each other background points. If we have n point clouds, this creates an additional n choose 2 combination of point clouds. For each of these background mixed point clouds we added translation in a spiral format starting from the face center and moving outwards in 30 different locations. We continually increment the angle by 4 * pi/30 to ensure two spiral loops, and use the following equation for center face placement: \[rt = e^{0.306*angle}\] \[x = rt * cos(angle) + originalX\] \[y = rt * sin(angle) + originalY\] At each different translation we are rotating the face 10 times in addition to the original, which we consider 0 degrees, and we evenly space the other 10 between 0 and 360. We are scaling at ${2\%}$, ${4\%}$, and ${6\%}$, both bigger and smaller to make an additional 6 point clouds, keeping the face a reasonable size within the anticipated space. Because we are using random downsampling the space between the points at these scales are not a concern as it is possible we would randomly increase or decrease the scaling of the proximity of points. Finally, we flopped the face in each of the scaled point clouds, doubling the final count, which is: \[ 3600 * \frac{n!}{2!(n-2)!} + n \] where n = the number of original point clouds. As we started with 7 point clouds, we are able to produce a total of 151,207 point clouds. As all 7 point clouds were of the same face, the next step would be to collect data of different faces with a variation on age, size, races, and distinctive features. \section{Data Preprocessing} \begin{figure}[htp] \centering \includegraphics[scale=0.4]{PreprocessingPipeline.jpg} \caption{Preprocessing Pipeline} \label{fig:preprocessingPipeline} \end{figure} Because we are not able to use all points in the point cloud given due to computational speed, we chose to add preprocessing steps to eliminate unnecessary points. As this problem is meant for a specific application with specific hardware, we were able to make certain assumptions. Because we were told there will be a table or floor under the patient being operated on, we chose to begin our algorithm with a RANSAC plane finder to eliminate all points within a reasonable plane. We then randomly downsampled to 1000 points. Next, we developed a clustering architecture which consists of a Clusterer and Cluster Profiler. The clusterer starts by running DBSCAN with eps = 0.05 and the minimum number of samples are 10. The Cluster Profiler maintains profiles of faces using number of points in the cluster, width of the cluster, and height of the cluster. We store an ideal face (an average of our downsampled data) with 200 points, 0.1907 meters width, and 0.2487 meters height to compute a score to compare each incoming cluster against. Our score calculation is: \[ numPointsScore= \frac{(averageFace.numPoints - incomingFace.numPoints)}{0.5 * (maxFace.numPoints - minFace.numPoints)} \] \[ widthScore= \frac{(averageFace.width - incomingFace.width)}{0.5 * (maxFace.width - minFace.width)} \] \[ heightScore= \frac{(averageFace.height - incomingFace.height)}{0.5 * (maxFace.height - minFace.height)} \] \[ score = numPointsScore + widthScore + heightScore \] We also maintain a profile for a minimum face with 100 points, 0.1 meters width, and 0.2 meters height, and a maximum face with 300 points, 0.4 meters width, and 0.6 meters height. If the incoming cluster has any value lower than the minimum face or larger than the maximum face it is given a score of -1 and is eliminated. If the cluster is not eliminated by this, its score is computed when compared to the average face, and if the score is above the threshold 0.7, it is kept for further parallel evaluation in the Machine Learning pipeline. \begin{figure}[htp] \centering \includegraphics[scale=0.8]{pointPillars.png} \caption{PointPillars} \label{fig:pointPillars} \end{figure} While the clustering seems to be working well, the parameters don't seem consistent enough yet to send each cluster through the model, which was our goal. So, we are currently sending one large cluster of all data through an embedding to become a point pillar\cite{pointpillars}. However, we are using 8 feature variables, not including the reflectance value as it is not available. These pillars are formed by projecting all points in the point cloud onto the x-y plane and binning them with a simple grid. The arithmetic mean of the x, y, z values of the points in each bin are taken, as well as the x and y offset of each point from the center of the pillar (the mean values). These statistics are then combined with the three dimensional coordinates of each point to give an eight dimensional vector for each point. Once processed into point pillars, we normalize the data to be between 0 and 1 before sending it through the deep learning model. The labels also need to be processed to contain a 1 or 0 for each pillar to match in dimensions. Something that was interesting and highlighted when visualizing the point pillars were that about half of them had at least one noisy label away from the face, as shown in figure \ref{fig:pointPillars} where the blue is a pillar with a face label, the red is a pillar which have only non-face points, and the green are empty pillars. This highlights that mislabelled data being fed into the model is accentuated. \section{Architecture} Once the data has been preprocessed, a vector of downsampled, clustered, point pillars are ready to enter the deep learning network. As we are working with 1200 pillars, 20 maximum points per pillar, and 8 features, the incoming shape of the data is (number of samples, 1200, 20, 8). We struggled with our model, as we failed to run due to resource constraints in a Jupyter notebook with and without TPU/GPU, locally, and with several cloud instances. Finally, with reducing to 1 batch, reducing the max points per pillar to 20, which was closer to the max points, and simplifying the model with fewer layers we were able to run locally. This resulted in the following model summary: \begin{figure}[htp] \centering \includegraphics[scale=0.8]{model2.png} \caption{Model Summary} \label{fig:modelSummary} \end{figure} We compiled with an Adam optimizer with a learning rate of 0.0001 and a Binary Crossentropy loss function. We then need to remap that to the point pillars that were fed in before delivering the result. \section{Training} We implement the traditional 80/20 train-test split in dividing the pre-processed data. The training and test data is treated by the point pillar method and the training data is passed to the model. The labels are per pillar where a pillar that includes at least one face point (1) or a pillar that includes no face points (0). Initially we were achieving a low accuracy of 0.2, but were able to increase the accuracy by reducing the learning rate to 0.0001. We also added he{\_}normal initialization weights to the first Dense layer to try to help overcome the problem of vanishing gradients. We analyzed what labels were being labelled incorrectly. For instance, for one face, 75{\%} of the missed labels were incorrectly labelling face labels no-face labels, and another face had 45{\%} face points being labelled incorrectly. This tells me that although we were getting 73{\%} accuracy, much more work needs to be done to improve focusing on the face being labelled accurately. \section{Conclusion} While there are far too many points in a point cloud to process all points in real time, we developed a method to smartly eliminate points through RANSAC, cluster elimination, and downsampling. We developed a simple but efficient model that can achieve an accuracy of 0.73 in labeling each point as a face in the incoming point cloud. Significant speedup is necessary but possible for this system to be able to run in real time. We also have future ideas for kalman filter tracking on the face cluster to predict the location of the face in the next frame, as a face can only move a certain distance at a certain time frame. If the kalman filter has an accurate enough prediction, we will be able to eliminate all points outside of a bounding box barely larger than any head to significantly reduce the number of unnecessary points prior to running the data through the model. \begin{thebibliography}{9} \bibitem{pointpillars} PointPillars: Fast Encoders for Object Detection from Point Clouds, Dec 14, 2018 \\\texttt{arXiv:1812.05784} \bibitem{githubrepo} Point Pillars in TensorFlow (2020), GitHub, https://github.com/tyagi-iiitv/PointPillars \end{thebibliography} \end{document}
# Lagrangian for kuka iiwa via RigidBodyDynamics using LinearAlgebra using ForwardDiff using RigidBodyDynamics using MeshCatMechanisms nq = 7 + 3 # number of states - kuka arm joint positions + particle in 3-space nu = 7 # number of controls - kuka arm joint torques nγ = 1 # contact points/ number of contact forces ns = nγ h = 0.05 # s m_p = 0.01 # kg - mass of particle urdf = "/home/taylor/Research/contact_implicit_trajectory_optimization/models/kuka/temp/kuka.urdf" mechanismkuka = parse_urdf(urdf) visualskuka = URDFVisuals(urdf) function get_kuka_ee(kuka) ee_body = findbody(kuka, "iiwa_link_ee") ee_point = Point3D(default_frame(ee_body),0.,0.,0.) return ee_body, ee_point end function get_kuka_ee_position_fun(kuka::Mechanism,statecache=StateCache(kuka)) where {O} ee_body, ee_point = get_kuka_ee(kuka) world = root_frame(kuka) nn = num_positions(kuka) function ee_position(x::AbstractVector{T}) where T state = statecache[T] set_configuration!(state, x[1:nn]) RigidBodyDynamics.transform(state, ee_point, world).v end end end_effector_function = get_kuka_ee_position_fun(parse_urdf(urdf,remove_fixed_tree_joints=false)) # ee_pos = end_effector_function(zeros(7)) # state = MechanismState(mechanism) const statecachekuka = StateCache(mechanismkuka) function 𝓛(q::AbstractVector{T},q̇::AbstractVector{T}) where T q_kuka = q[1:7] q̇_kuka = q̇[1:7] q_p = q[8:10] q̇_p = q̇[8:10] state = statecachekuka[T] set_configuration!(state,q_kuka) set_velocity!(state,q̇_kuka) kinetic_energy(state) + 0.5*m_p*q̇_p'*q̇_p - m_p*9.81*q_p[3] - gravitational_potential_energy(state) end 𝓛d(q1,q2) = let 𝓛=𝓛, h=h h*𝓛(0.5*(q1+q2),(q2-q1)/h) end 𝓛d(z) = 𝓛d(z[1:nq],z[nq .+ (1:nq)]) D𝓛d(z) = ForwardDiff.gradient(𝓛d,z) D1𝓛d(z) = D𝓛d(z)[1:nq] D2𝓛d(z) = D𝓛d(z)[nq .+ (1:nq)] D1𝓛d(q1,q2) = D1𝓛d([q1;q2]) D2𝓛d(q1,q2) = D2𝓛d([q1;q2]) δD1𝓛dδq2(z) = ForwardDiff.jacobian(D1𝓛d,z)[1:nq,nq .+ (1:nq)] δD1𝓛dδq2(q1,q2) = δD1𝓛dδq2([q1;q2]) d = 0.5 ϕ(q) = let d=d q_kuka = q[1:7] ee = end_effector_function(q_kuka) q_p = q[8:10] # println(ee) # println(q_p) d - norm(ee - q_p) end ∇ϕ(q) = ForwardDiff.gradient(ϕ,q) B = zeros(nq,nu) B[1:nu,1:nu] = Diagonal(ones(nu)) B F(q,q̇) = let m=mass,g=9.81 zero(q) end Fd(q1,q2) = let F=F, h=h h*F(0.5*(q1+q2), (q2-q1)/h) end var_int(q1,q2,u,γ,s,q⁺) = let B=B D2𝓛d(q1,q2) + D1𝓛d(q2,q⁺) + 0.5*(Fd(q1,q2) + Fd(q2,q⁺)) + B[:,:]*u[:] + ∇ϕ(q⁺)[:,:]*γ[:] end var_int(rand(nq),rand(nq),rand(nu),rand(nγ),rand(ns),rand(nq)) function var_int(z) q1 = z[1:nq] q2 = z[nq .+ (1:nq)] u = z[2nq .+ (1:nu)] γ = z[(2nq + nu) .+ (1:nγ)] s = z[(2nq + nu + nγ) .+ (1:ns)] q⁺ = z[(2nq + nu + nγ + ns) .+ (1:nq)] var_int(q1,q2,u,γ,s,q⁺) end ∇var_int(z) = ForwardDiff.jacobian(var_int,z) ∇var_int(q1,q2,u,γ,s,q⁺) = ∇var_int([q1;q2;u;γ;s;q⁺]) ∇var_int(rand(nq),rand(nq),rand(nu),rand(nγ),rand(ns),rand(nq))
(* Title: HOL/Hoare/Hoare_Tac.thy Author: Leonor Prensa Nieto & Tobias Nipkow Author: Walter Guttmann (extension to total-correctness proofs) *) section \<open>Hoare logic VCG tactic\<close> theory Hoare_Tac imports Main begin context begin qualified named_theorems BasicRule qualified named_theorems SkipRule qualified named_theorems AbortRule qualified named_theorems SeqRule qualified named_theorems CondRule qualified named_theorems WhileRule qualified named_theorems BasicRuleTC qualified named_theorems SkipRuleTC qualified named_theorems SeqRuleTC qualified named_theorems CondRuleTC qualified named_theorems WhileRuleTC lemma Compl_Collect: "-(Collect b) = {x. \<not>(b x)}" by blast ML_file \<open>hoare_tac.ML\<close> end end
Require Import RamifyCoq.CertiGC.gc_spec. Ltac hif_tac H := match type of H with context [if ?a then _ else _] => destruct a eqn: ?H end. Lemma body_Is_block: semax_body Vprog Gprog f_Is_block Is_block_spec. Proof. start_function. assert (eqb_type (Tpointer Tvoid {| attr_volatile := false; attr_alignas := Some 2%N |}) int_or_ptr_type = true) by (rewrite eqb_type_spec; unfold int_or_ptr_type; f_equal). forward_call x. forward. hif_tac H1. 2: inversion H0. destruct x; simpl in *; entailer!. Qed.
{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE ViewPatterns #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE FlexibleContexts #-} -------------------------------------------------------------------------------- -- | -- Module : ArrayFire.Data -- Copyright : David Johnson (c) 2019-2020 -- License : BSD 3 -- Maintainer : David Johnson <[email protected]> -- Stability : Experimental -- Portability : GHC -- -- Functions for populating 'Array' with Data. -- -- @ -- >>> constant @Double [2,2] 2.0 -- ArrayFire Array -- [2 2 1 1] -- 2.0000 2.0000 -- 2.0000 2.0000 -- @ -- -------------------------------------------------------------------------------- module ArrayFire.Data where import Control.Exception import Control.Monad import Data.Complex import Data.Int import Data.Proxy import Data.Word import Foreign.C.Types import Foreign.ForeignPtr import Foreign.Marshal hiding (void) import Foreign.Storable import System.IO.Unsafe import Unsafe.Coerce import ArrayFire.Exception import ArrayFire.FFI import ArrayFire.Internal.Data import ArrayFire.Internal.Defines import ArrayFire.Internal.Types import ArrayFire.Arith -- | Creates an 'Array' from a scalar value from given dimensions -- -- >>> constant @Double [2,2] 2.0 -- ArrayFire Array -- [2 2 1 1] -- 2.0000 2.0000 -- 2.0000 2.0000 constant :: forall a . AFType a => [Int] -- ^ Dimensions -> a -- ^ Scalar value -> Array a constant dims val = case dtyp of x | x == c64 -> cast $ constantComplex dims (unsafeCoerce val :: Complex Double) | x == c32 -> cast $ constantComplex dims (unsafeCoerce val :: Complex Float) | x == s64 -> cast $ constantLong dims (unsafeCoerce val :: Int) | x == u64 -> cast $ constantULong dims (unsafeCoerce val :: Word64) | x == s32 -> cast $ constant' dims (fromIntegral (unsafeCoerce val :: Int32) :: Double) | x == s16 -> cast $ constant' dims (fromIntegral (unsafeCoerce val :: Int16) :: Double) | x == u32 -> cast $ constant' dims (fromIntegral (unsafeCoerce val :: Word32) :: Double) | x == u8 -> cast $ constant' dims (fromIntegral (unsafeCoerce val :: Word8) :: Double) | x == u16 -> cast $ constant' dims (fromIntegral (unsafeCoerce val :: Word16) :: Double) | x == f64 -> cast $ constant' dims (unsafeCoerce val :: Double) | x == b8 -> cast $ constant' dims (fromIntegral (unsafeCoerce val :: CBool) :: Double) | x == f32 -> cast $ constant' dims (realToFrac (unsafeCoerce val :: Float)) | otherwise -> error "constant: Invalid array fire type" where dtyp = afType (Proxy @ a) constant' :: [Int] -- ^ Dimensions -> Double -- ^ Scalar value -> Array Double constant' dims' val' = unsafePerformIO . mask_ $ do ptr <- alloca $ \ptrPtr -> do zeroOutArray ptrPtr withArray (fromIntegral <$> dims') $ \dimArray -> do throwAFError =<< af_constant ptrPtr val' n dimArray typ peek ptrPtr Array <$> newForeignPtr af_release_array_finalizer ptr where n = fromIntegral (length dims') typ = afType (Proxy @ Double) -- | Creates an 'Array (Complex Double)' from a scalar val'ue -- -- @ -- >>> constantComplex [2,2] (2.0 :+ 2.0) -- @ -- constantComplex :: forall arr . (Real arr, AFType (Complex arr)) => [Int] -- ^ Dimensions -> Complex arr -- ^ Scalar val'ue -> Array (Complex arr) constantComplex dims' ((realToFrac -> x) :+ (realToFrac -> y)) = unsafePerformIO . mask_ $ do ptr <- alloca $ \ptrPtr -> do zeroOutArray ptrPtr withArray (fromIntegral <$> dims') $ \dimArray -> do throwAFError =<< af_constant_complex ptrPtr x y n dimArray typ peek ptrPtr Array <$> newForeignPtr af_release_array_finalizer ptr where n = fromIntegral (length dims') typ = afType (Proxy @ (Complex arr)) -- | Creates an 'Array Int64' from a scalar val'ue -- -- @ -- >>> constantLong [2,2] 2.0 -- @ -- constantLong :: [Int] -- ^ Dimensions -> Int -- ^ Scalar val'ue -> Array Int constantLong dims' val' = unsafePerformIO . mask_ $ do ptr <- alloca $ \ptrPtr -> do zeroOutArray ptrPtr withArray (fromIntegral <$> dims') $ \dimArray -> do throwAFError =<< af_constant_long ptrPtr (fromIntegral val') n dimArray peek ptrPtr Array <$> newForeignPtr af_release_array_finalizer ptr where n = fromIntegral (length dims') -- | Creates an 'Array Word64' from a scalar val'ue -- -- @ -- >>> constantULong [2,2] 2.0 -- @ -- constantULong :: [Int] -> Word64 -> Array Word64 constantULong dims' val' = unsafePerformIO . mask_ $ do ptr <- alloca $ \ptrPtr -> do zeroOutArray ptrPtr withArray (fromIntegral <$> dims') $ \dimArray -> do throwAFError =<< af_constant_ulong ptrPtr (fromIntegral val') n dimArray peek ptrPtr Array <$> newForeignPtr af_release_array_finalizer ptr where n = fromIntegral (length dims') -- | Creates a range of values in an Array -- -- >>> range @Double [10] (-1) -- ArrayFire Array -- [10 1 1 1] -- 0.0000 -- 1.0000 -- 2.0000 -- 3.0000 -- 4.0000 -- 5.0000 -- 6.0000 -- 7.0000 -- 8.0000 -- 9.0000 range :: forall a . AFType a => [Int] -> Int -> Array a range dims (fromIntegral -> k) = unsafePerformIO $ do ptr <- alloca $ \ptrPtr -> mask_ $ do withArray (fromIntegral <$> dims) $ \dimArray -> do throwAFError =<< af_range ptrPtr n dimArray k typ peek ptrPtr Array <$> newForeignPtr af_release_array_finalizer ptr where n = fromIntegral (length dims) typ = afType (Proxy @ a) -- | Create an sequence [0, dims.elements() - 1] and modify to specified dimensions dims and then tile it according to tile_dims. -- -- <http://arrayfire.org/docs/group__data__func__iota.htm> -- -- >>> iota @Double [5,3] [] -- ArrayFire Array -- [5 3 1 1] -- 0.0000 5.0000 10.0000 -- 1.0000 6.0000 11.0000 -- 2.0000 7.0000 12.0000 -- 3.0000 8.0000 13.0000 -- 4.0000 9.0000 14.0000 -- -- >>> iota @Double [5,3] [1,2] -- ArrayFire Array -- [5 6 1 1] -- 0.0000 5.0000 10.0000 0.0000 5.0000 10.0000 -- 1.0000 6.0000 11.0000 1.0000 6.0000 11.0000 -- 2.0000 7.0000 12.0000 2.0000 7.0000 12.0000 -- 3.0000 8.0000 13.0000 3.0000 8.0000 13.0000 -- 4.0000 9.0000 14.0000 4.0000 9.0000 14.0000 iota :: forall a . AFType a => [Int] -- ^ is the array containing sizes of the dimension -> [Int] -- ^ is array containing the number of repetitions of the unit dimensions -> Array a -- ^ is the generated array iota dims tdims = unsafePerformIO $ do let dims' = take 4 (dims ++ repeat 1) tdims' = take 4 (tdims ++ repeat 1) ptr <- alloca $ \ptrPtr -> mask_ $ do zeroOutArray ptrPtr withArray (fromIntegral <$> dims') $ \dimArray -> withArray (fromIntegral <$> tdims') $ \tdimArray -> do throwAFError =<< af_iota ptrPtr 4 dimArray 4 tdimArray typ peek ptrPtr Array <$> newForeignPtr af_release_array_finalizer ptr where typ = afType (Proxy @ a) -- | Creates the identity `Array` from given dimensions -- -- >>> identity [2,2] -- ArrayFire Array -- [2 2 1 1] -- 1.0000 0.0000 -- 0.0000 1.0000 identity :: forall a . AFType a => [Int] -- ^ Dimensions -> Array a identity dims = unsafePerformIO . mask_ $ do let dims' = take 4 (dims ++ repeat 1) ptr <- alloca $ \ptrPtr -> mask_ $ do zeroOutArray ptrPtr withArray (fromIntegral <$> dims') $ \dimArray -> do throwAFError =<< af_identity ptrPtr n dimArray typ peek ptrPtr Array <$> newForeignPtr af_release_array_finalizer ptr where n = fromIntegral (length dims) typ = afType (Proxy @ a) -- | Create a diagonal matrix from input array when extract is set to false -- -- >>> diagCreate (vector @Double 2 [1..]) 0 -- ArrayFire Array -- [2 2 1 1] -- 1.0000 0.0000 -- 0.0000 2.0000 diagCreate :: AFType (a :: *) => Array a -- ^ is the input array which is the diagonal -> Int -- ^ is the diagonal index -> Array a diagCreate x (fromIntegral -> n) = x `op1` (\p a -> af_diag_create p a n) -- | Create a diagonal matrix from input array when extract is set to false -- -- >>> diagExtract (matrix @Double (2,2) [[1,2],[3,4]]) 0 -- ArrayFire Array -- [2 1 1 1] -- 1.0000 -- 4.0000 diagExtract :: AFType (a :: *) => Array a -> Int -> Array a diagExtract x (fromIntegral -> n) = x `op1` (\p a -> af_diag_extract p a n) -- | Join two Arrays together along a specified dimension -- -- >>> join 0 (matrix @Double (2,2) [[1,2],[3,4]]) (matrix @Double (2,2) [[5,6],[7,8]]) -- ArrayFire Array -- [4 2 1 1] -- 1.0000 3.0000 -- 2.0000 4.0000 -- 5.0000 7.0000 -- 6.0000 8.0000 -- join :: Int -> Array (a :: *) -> Array a -> Array a join (fromIntegral -> n) arr1 arr2 = op2 arr1 arr2 (\p a b -> af_join p n a b) -- | Join many Arrays together along a specified dimension -- -- *FIX ME* -- -- >>> joinMany 0 [1,2,3] -- ArrayFire Array -- [3 1 1 1] -- 1.0000 2.0000 3.0000 -- joinMany :: Int -> [Array a] -> Array a joinMany (fromIntegral -> n) arrays = unsafePerformIO . mask_ $ do fptrs <- forM arrays $ \(Array fptr) -> pure fptr newPtr <- alloca $ \fPtrsPtr -> do forM_ fptrs $ \fptr -> withForeignPtr fptr (poke fPtrsPtr) alloca $ \aPtr -> do zeroOutArray aPtr throwAFError =<< af_join_many aPtr n nArrays fPtrsPtr peek aPtr Array <$> newForeignPtr af_release_array_finalizer newPtr where nArrays = fromIntegral (length arrays) -- | Tiles an Array according to specified dimensions -- -- >>> tile @Double (scalar 22.0) [5,5] -- ArrayFire Array -- [5 5 1 1] -- 22.0000 22.0000 22.0000 22.0000 22.0000 -- 22.0000 22.0000 22.0000 22.0000 22.0000 -- 22.0000 22.0000 22.0000 22.0000 22.0000 -- 22.0000 22.0000 22.0000 22.0000 22.0000 -- 22.0000 22.0000 22.0000 22.0000 22.0000 -- tile :: Array (a :: *) -> [Int] -> Array a tile a (take 4 . (++repeat 1) -> [x,y,z,w]) = a `op1` (\p k -> af_tile p k (fromIntegral x) (fromIntegral y) (fromIntegral z) (fromIntegral w)) tile _ _ = error "impossible" -- | Reorders an Array according to newly specified dimensions -- -- *FIX ME* -- -- >>> reorder @Double (scalar 22.0) [5,5] -- ArrayFire Array -- [5 5 1 1] -- 22.0000 22.0000 22.0000 22.0000 22.0000 -- 22.0000 22.0000 22.0000 22.0000 22.0000 -- 22.0000 22.0000 22.0000 22.0000 22.0000 -- 22.0000 22.0000 22.0000 22.0000 22.0000 -- 22.0000 22.0000 22.0000 22.0000 22.0000 -- reorder :: Array (a :: *) -> [Int] -> Array a reorder a (take 4 . (++ repeat 0) -> [x,y,z,w]) = a `op1` (\p k -> af_reorder p k (fromIntegral x) (fromIntegral y) (fromIntegral z) (fromIntegral w)) reorder _ _ = error "impossible" -- | Shift elements in an Array along a specified dimension (elements will wrap). -- -- >>> shift (vector @Double 4 [1..]) 2 0 0 0 -- ArrayFire Array -- [4 1 1 1] -- 3.0000 -- 4.0000 -- 1.0000 -- 2.0000 -- shift :: Array (a :: *) -> Int -> Int -> Int -> Int -> Array a shift a (fromIntegral -> x) (fromIntegral -> y) (fromIntegral -> z) (fromIntegral -> w) = a `op1` (\p k -> af_shift p k x y z w) -- | Modify dimensions of array -- -- >>> moddims (vector @Double 3 [1..]) [1,3] -- ArrayFire Array -- [1 3 1 1] -- 1.0000 2.0000 3.0000 -- moddims :: forall a . Array (a :: *) -> [Int] -> Array a moddims (Array fptr) dims = unsafePerformIO . mask_ . withForeignPtr fptr $ \ptr -> do newPtr <- alloca $ \aPtr -> do zeroOutArray aPtr withArray (fromIntegral <$> dims) $ \dimsPtr -> do throwAFError =<< af_moddims aPtr ptr n dimsPtr peek aPtr Array <$> newForeignPtr af_release_array_finalizer newPtr where n = fromIntegral (length dims) -- | Flatten an Array into a single dimension -- -- >>> flat (matrix @Double (2,2) [[1..],[1..]]) -- ArrayFire Array -- [4 1 1 1] -- 1.0000 -- 2.0000 -- 1.0000 -- 2.0000 -- -- >>> flat $ cube @Int (2,2,2) [[[1,1],[1,1]],[[1,1],[1,1]]] -- ArrayFire Array -- [8 1 1 1] -- 1 -- 1 -- 1 -- 1 -- 1 -- 1 -- 1 -- 1 -- flat :: Array a -> Array a flat = (`op1` af_flat) -- | Flip the values of an Array along a specified dimension -- -- >>> matrix @Double (2,2) [[2,2],[3,3]] -- ArrayFire Array -- [2 2 1 1] -- 2.0000 3.0000 -- 2.0000 3.0000 -- -- >>> A.flip (matrix @Double (2,2) [[2,2],[3,3]]) 1 -- ArrayFire Array -- [2 2 1 1] -- 3.0000 2.0000 -- 3.0000 2.0000 -- flip :: Array a -> Int -> Array a flip a (fromIntegral -> dim) = a `op1` (\p k -> af_flip p k dim) -- | Create a lower triangular matrix from input array. -- -- >>> lower (constant [2,2] 10 :: Array Double) True -- ArrayFire Array -- [2 2 1 1] -- 1.0000 0.0000 -- 10.0000 1.0000 -- lower :: Array a -- ^ is the input matrix -> Bool -- ^ boolean parameter specifying if the diagonal elements should be 1 -> Array a lower a (fromIntegral . fromEnum -> b) = a `op1` (\p k -> af_lower p k b) -- | Create an upper triangular matrix from input array. -- -- >>> upper (constant [2,2] 10 :: Array Double) True -- ArrayFire Array -- [2 2 1 1] -- 1.0000 10.0000 -- 0.0000 1.0000 -- upper :: Array a -> Bool -> Array a upper a (fromIntegral . fromEnum -> b) = a `op1` (\p k -> af_upper p k b) -- | Selects elements from two arrays based on the values of a binary conditional array. -- -- >>> cond = vector @CBool 5 [1,0,1,0,1] -- >>> arr1 = vector @Double 5 (repeat 1) -- >>> arr2 = vector @Double 5 (repeat 2) -- >>> select cond arr1 arr2 -- ArrayFire Array -- [5 1 1 1] -- 1.0000 -- 2.0000 -- 1.0000 -- 2.0000 -- 1.0000 -- select :: Array CBool -- ^ is the conditional array -> Array a -- ^ is the array containing elements from the true part of the condition -> Array a -- ^ is the array containing elements from the false part of the condition -> Array a -- ^ is the output containing elements of a when cond is true else elements from b select a b c = op3 a b c af_select -- | Selects elements from two arrays based on the values of a binary conditional array. -- -- <http://arrayfire.org/docs/group__data__func__select.htm#gab6886120d0bac4717276910e468bbe88> -- -- >>> cond = vector @CBool 5 [1,0,1,0,1] -- >>> arr1 = vector @Double 5 (repeat 1) -- >>> x = 99 -- >>> selectScalarR cond arr1 x -- ArrayFire Array -- [5 1 1 1] -- 1.0000 -- 99.0000 -- 1.0000 -- 99.0000 -- 1.0000 -- selectScalarR :: Array CBool -- ^ is the conditional array -> Array a -- ^ is the array containing elements from the true part of the condition -> Double -- ^ is a scalar assigned to out when cond is false -> Array a -- ^ the output containing elements of a when cond is true else elements from b selectScalarR a b c = op2 a b (\p w x -> af_select_scalar_r p w x c) -- | Selects elements from two arrays based on the values of a binary conditional array. -- -- [ArrayFire Docs](http://arrayfire.org/docs/group__data__func__select.htm#ga0ccdc05779f88cab5095bce987c2da9d) -- -- >>> cond = vector @CBool 5 [1,0,1,0,1] -- >>> arr1 = vector @Double 5 (repeat 1) -- >>> x = 99 -- >>> selectScalarL cond x arr1 -- ArrayFire Array -- [5 1 1 1] -- 99.0000 -- 1.0000 -- 99.0000 -- 1.0000 -- 99.0000 -- selectScalarL :: Array CBool -- ^ the conditional array -> Double -- ^ a scalar assigned to out when cond is true -> Array a -- ^ the array containing elements from the false part of the condition -> Array a -- ^ is the output containing elements of a when cond is true else elements from b selectScalarL a n b = op2 a b (\p w x -> af_select_scalar_l p w n x) -- af_err af_replace(af_array a, const af_array cond, const af_array b); -- af_err af_replace_scalar(af_array a, const af_array cond, const double b);
(* Copyright (c) 2012-2017, Coq-std++ developers. *) (* This file is distributed under the terms of the BSD license. *) From stdpp Require Import gmap. Set Default Proof Using "Type". Record gmultiset A `{Countable A} := GMultiSet { gmultiset_car : gmap A nat }. Arguments GMultiSet {_ _ _} _ : assert. Arguments gmultiset_car {_ _ _} _ : assert. Instance gmultiset_eq_dec `{Countable A} : EqDecision (gmultiset A). Proof. solve_decision. Defined. Program Instance gmultiset_countable `{Countable A} : Countable (gmultiset A) := {| encode X := encode (gmultiset_car X); decode p := GMultiSet <$> decode p |}. Next Obligation. intros A ?? [X]; simpl. by rewrite decode_encode. Qed. Section definitions. Context `{Countable A}. Definition multiplicity (x : A) (X : gmultiset A) : nat := match gmultiset_car X !! x with Some n => S n | None => 0 end. Global Instance gmultiset_elem_of : ElemOf A (gmultiset A) := λ x X, 0 < multiplicity x X. Global Instance gmultiset_subseteq : SubsetEq (gmultiset A) := λ X Y, ∀ x, multiplicity x X ≤ multiplicity x Y. Global Instance gmultiset_elements : Elements A (gmultiset A) := λ X, let (X) := X in ''(x,n) ← map_to_list X; replicate (S n) x. Global Instance gmultiset_size : Size (gmultiset A) := length ∘ elements. Global Instance gmultiset_empty : Empty (gmultiset A) := GMultiSet ∅. Global Instance gmultiset_singleton : Singleton A (gmultiset A) := λ x, GMultiSet {[ x := 0 ]}. Global Instance gmultiset_union : Union (gmultiset A) := λ X Y, let (X) := X in let (Y) := Y in GMultiSet $ union_with (λ x y, Some (S (x + y))) X Y. Global Instance gmultiset_difference : Difference (gmultiset A) := λ X Y, let (X) := X in let (Y) := Y in GMultiSet $ difference_with (λ x y, let z := x - y in guard (0 < z); Some (pred z)) X Y. Global Instance gmultiset_dom : Dom (gmultiset A) (gset A) := λ X, let (X) := X in dom _ X. End definitions. Typeclasses Opaque gmultiset_elem_of gmultiset_subseteq. Typeclasses Opaque gmultiset_elements gmultiset_size gmultiset_empty. Typeclasses Opaque gmultiset_singleton gmultiset_union gmultiset_difference. Typeclasses Opaque gmultiset_dom. Section lemmas. Context `{Countable A}. Implicit Types x y : A. Implicit Types X Y : gmultiset A. Lemma gmultiset_eq X Y : X = Y ↔ ∀ x, multiplicity x X = multiplicity x Y. Proof. split; [by intros ->|intros HXY]. destruct X as [X], Y as [Y]; f_equal; apply map_eq; intros x. specialize (HXY x); unfold multiplicity in *; simpl in *. repeat case_match; naive_solver. Qed. (* Multiplicity *) Lemma multiplicity_empty x : multiplicity x ∅ = 0. Proof. done. Qed. Lemma multiplicity_singleton x : multiplicity x {[ x ]} = 1. Proof. unfold multiplicity; simpl. by rewrite lookup_singleton. Qed. Lemma multiplicity_singleton_ne x y : x ≠ y → multiplicity x {[ y ]} = 0. Proof. intros. unfold multiplicity; simpl. by rewrite lookup_singleton_ne. Qed. Lemma multiplicity_union X Y x : multiplicity x (X ∪ Y) = multiplicity x X + multiplicity x Y. Proof. destruct X as [X], Y as [Y]; unfold multiplicity; simpl. rewrite lookup_union_with. destruct (X !! _), (Y !! _); simpl; omega. Qed. Lemma multiplicity_difference X Y x : multiplicity x (X ∖ Y) = multiplicity x X - multiplicity x Y. Proof. destruct X as [X], Y as [Y]; unfold multiplicity; simpl. rewrite lookup_difference_with. destruct (X !! _), (Y !! _); simplify_option_eq; omega. Qed. (* Collection *) Lemma elem_of_multiplicity x X : x ∈ X ↔ 0 < multiplicity x X. Proof. done. Qed. Global Instance gmultiset_simple_collection : SimpleCollection A (gmultiset A). Proof. split. - intros x. rewrite elem_of_multiplicity, multiplicity_empty. omega. - intros x y. destruct (decide (x = y)) as [->|]. + rewrite elem_of_multiplicity, multiplicity_singleton. split; auto with lia. + rewrite elem_of_multiplicity, multiplicity_singleton_ne by done. by split; auto with lia. - intros X Y x. rewrite !elem_of_multiplicity, multiplicity_union. omega. Qed. Global Instance gmultiset_elem_of_dec : RelDecision (@elem_of _ (gmultiset A) _). Proof. refine (λ x X, cast_if (decide (0 < multiplicity x X))); done. Defined. (* Algebraic laws *) Global Instance gmultiset_comm : Comm (@eq (gmultiset A)) (∪). Proof. intros X Y. apply gmultiset_eq; intros x. rewrite !multiplicity_union; omega. Qed. Global Instance gmultiset_assoc : Assoc (@eq (gmultiset A)) (∪). Proof. intros X Y Z. apply gmultiset_eq; intros x. rewrite !multiplicity_union; omega. Qed. Global Instance gmultiset_left_id : LeftId (@eq (gmultiset A)) ∅ (∪). Proof. intros X. apply gmultiset_eq; intros x. by rewrite multiplicity_union, multiplicity_empty. Qed. Global Instance gmultiset_right_id : RightId (@eq (gmultiset A)) ∅ (∪). Proof. intros X. by rewrite (comm_L (∪)), (left_id_L _ _). Qed. Global Instance gmultiset_union_inj_1 X : Inj (=) (=) (X ∪). Proof. intros Y1 Y2. rewrite !gmultiset_eq. intros HX x; generalize (HX x). rewrite !multiplicity_union. omega. Qed. Global Instance gmultiset_union_inj_2 X : Inj (=) (=) (∪ X). Proof. intros Y1 Y2. rewrite <-!(comm_L _ X). apply (inj _). Qed. Lemma gmultiset_non_empty_singleton x : {[ x ]} ≠ (∅ : gmultiset A). Proof. rewrite gmultiset_eq. intros Hx; generalize (Hx x). by rewrite multiplicity_singleton, multiplicity_empty. Qed. (* Properties of the elements operation *) Lemma gmultiset_elements_empty : elements (∅ : gmultiset A) = []. Proof. unfold elements, gmultiset_elements; simpl. by rewrite map_to_list_empty. Qed. Lemma gmultiset_elements_empty_inv X : elements X = [] → X = ∅. Proof. destruct X as [X]; unfold elements, gmultiset_elements; simpl. intros; apply (f_equal GMultiSet). destruct (map_to_list X) as [|[]] eqn:?. - by apply map_to_list_empty_inv. - naive_solver. Qed. Lemma gmultiset_elements_empty' X : elements X = [] ↔ X = ∅. Proof. split; intros HX; [by apply gmultiset_elements_empty_inv|]. by rewrite HX, gmultiset_elements_empty. Qed. Lemma gmultiset_elements_singleton x : elements ({[ x ]} : gmultiset A) = [ x ]. Proof. unfold elements, gmultiset_elements; simpl. by rewrite map_to_list_singleton. Qed. Lemma gmultiset_elements_union X Y : elements (X ∪ Y) ≡ₚ elements X ++ elements Y. Proof. destruct X as [X], Y as [Y]; unfold elements, gmultiset_elements. set (f xn := let '(x, n) := xn in replicate (S n) x); simpl. revert Y; induction X as [|x n X HX IH] using map_ind; intros Y. { by rewrite (left_id_L _ _ Y), map_to_list_empty. } destruct (Y !! x) as [n'|] eqn:HY. - rewrite <-(insert_id Y x n'), <-(insert_delete Y) by done. erewrite <-insert_union_with by done. rewrite !map_to_list_insert, !bind_cons by (by rewrite ?lookup_union_with, ?lookup_delete, ?HX). rewrite (assoc_L _), <-(comm (++) (f (_,n'))), <-!(assoc_L _), <-IH. rewrite (assoc_L _). f_equiv. rewrite (comm _); simpl. by rewrite replicate_plus, Permutation_middle. - rewrite <-insert_union_with_l, !map_to_list_insert, !bind_cons by (by rewrite ?lookup_union_with, ?HX, ?HY). by rewrite <-(assoc_L (++)), <-IH. Qed. Lemma gmultiset_elem_of_elements x X : x ∈ elements X ↔ x ∈ X. Proof. destruct X as [X]. unfold elements, gmultiset_elements. set (f xn := let '(x, n) := xn in replicate (S n) x); simpl. unfold elem_of at 2, gmultiset_elem_of, multiplicity; simpl. rewrite elem_of_list_bind. split. - intros [[??] [[<- ?]%elem_of_replicate ->%elem_of_map_to_list]]; lia. - intros. destruct (X !! x) as [n|] eqn:Hx; [|omega]. exists (x,n); split; [|by apply elem_of_map_to_list]. apply elem_of_replicate; auto with omega. Qed. Lemma gmultiset_elem_of_dom x X : x ∈ dom (gset A) X ↔ x ∈ X. Proof. unfold dom, gmultiset_dom, elem_of at 2, gmultiset_elem_of, multiplicity. destruct X as [X]; simpl; rewrite elem_of_dom, <-not_eq_None_Some. destruct (X !! x); naive_solver omega. Qed. (* Properties of the size operation *) Lemma gmultiset_size_empty : size (∅ : gmultiset A) = 0. Proof. done. Qed. Lemma gmultiset_size_empty_inv X : size X = 0 → X = ∅. Proof. unfold size, gmultiset_size; simpl. rewrite length_zero_iff_nil. apply gmultiset_elements_empty_inv. Qed. Lemma gmultiset_size_empty_iff X : size X = 0 ↔ X = ∅. Proof. split; [apply gmultiset_size_empty_inv|]. by intros ->; rewrite gmultiset_size_empty. Qed. Lemma gmultiset_size_non_empty_iff X : size X ≠ 0 ↔ X ≠ ∅. Proof. by rewrite gmultiset_size_empty_iff. Qed. Lemma gmultiset_choose_or_empty X : (∃ x, x ∈ X) ∨ X = ∅. Proof. destruct (elements X) as [|x l] eqn:HX; [right|left]. - by apply gmultiset_elements_empty_inv. - exists x. rewrite <-gmultiset_elem_of_elements, HX. by left. Qed. Lemma gmultiset_choose X : X ≠ ∅ → ∃ x, x ∈ X. Proof. intros. by destruct (gmultiset_choose_or_empty X). Qed. Lemma gmultiset_size_pos_elem_of X : 0 < size X → ∃ x, x ∈ X. Proof. intros Hsz. destruct (gmultiset_choose_or_empty X) as [|HX]; [done|]. contradict Hsz. rewrite HX, gmultiset_size_empty; lia. Qed. Lemma gmultiset_size_singleton x : size ({[ x ]} : gmultiset A) = 1. Proof. unfold size, gmultiset_size; simpl. by rewrite gmultiset_elements_singleton. Qed. Lemma gmultiset_size_union X Y : size (X ∪ Y) = size X + size Y. Proof. unfold size, gmultiset_size; simpl. by rewrite gmultiset_elements_union, app_length. Qed. (* Order stuff *) Global Instance gmultiset_po : PartialOrder (@subseteq (gmultiset A) _). Proof. split; [split|]. - by intros X x. - intros X Y Z HXY HYZ x. by trans (multiplicity x Y). - intros X Y HXY HYX; apply gmultiset_eq; intros x. by apply (anti_symm (≤)). Qed. Lemma gmultiset_subseteq_alt X Y : X ⊆ Y ↔ map_relation (≤) (λ _, False) (λ _, True) (gmultiset_car X) (gmultiset_car Y). Proof. apply forall_proper; intros x. unfold multiplicity. destruct (gmultiset_car X !! x), (gmultiset_car Y !! x); naive_solver omega. Qed. Global Instance gmultiset_subseteq_dec : RelDecision (@subseteq (gmultiset A) _). Proof. refine (λ X Y, cast_if (decide (map_relation (≤) (λ _, False) (λ _, True) (gmultiset_car X) (gmultiset_car Y)))); by rewrite gmultiset_subseteq_alt. Defined. Lemma gmultiset_subset_subseteq X Y : X ⊂ Y → X ⊆ Y. Proof. apply strict_include. Qed. Hint Resolve gmultiset_subset_subseteq. Lemma gmultiset_empty_subseteq X : ∅ ⊆ X. Proof. intros x. rewrite multiplicity_empty. omega. Qed. Lemma gmultiset_union_subseteq_l X Y : X ⊆ X ∪ Y. Proof. intros x. rewrite multiplicity_union. omega. Qed. Lemma gmultiset_union_subseteq_r X Y : Y ⊆ X ∪ Y. Proof. intros x. rewrite multiplicity_union. omega. Qed. Lemma gmultiset_union_mono X1 X2 Y1 Y2 : X1 ⊆ X2 → Y1 ⊆ Y2 → X1 ∪ Y1 ⊆ X2 ∪ Y2. Proof. intros ?? x. rewrite !multiplicity_union. by apply Nat.add_le_mono. Qed. Lemma gmultiset_union_mono_l X Y1 Y2 : Y1 ⊆ Y2 → X ∪ Y1 ⊆ X ∪ Y2. Proof. intros. by apply gmultiset_union_mono. Qed. Lemma gmultiset_union_mono_r X1 X2 Y : X1 ⊆ X2 → X1 ∪ Y ⊆ X2 ∪ Y. Proof. intros. by apply gmultiset_union_mono. Qed. Lemma gmultiset_subset X Y : X ⊆ Y → size X < size Y → X ⊂ Y. Proof. intros. apply strict_spec_alt; split; naive_solver auto with omega. Qed. Lemma gmultiset_union_subset_l X Y : Y ≠ ∅ → X ⊂ X ∪ Y. Proof. intros HY%gmultiset_size_non_empty_iff. apply gmultiset_subset; auto using gmultiset_union_subseteq_l. rewrite gmultiset_size_union; omega. Qed. Lemma gmultiset_union_subset_r X Y : X ≠ ∅ → Y ⊂ X ∪ Y. Proof. rewrite (comm_L (∪)). apply gmultiset_union_subset_l. Qed. Lemma gmultiset_elem_of_singleton_subseteq x X : x ∈ X ↔ {[ x ]} ⊆ X. Proof. rewrite elem_of_multiplicity. split. - intros Hx y; destruct (decide (x = y)) as [->|]. + rewrite multiplicity_singleton; omega. + rewrite multiplicity_singleton_ne by done; omega. - intros Hx. generalize (Hx x). rewrite multiplicity_singleton. omega. Qed. Lemma gmultiset_elem_of_subseteq X1 X2 x : x ∈ X1 → X1 ⊆ X2 → x ∈ X2. Proof. rewrite !gmultiset_elem_of_singleton_subseteq. by intros ->. Qed. Lemma gmultiset_union_difference X Y : X ⊆ Y → Y = X ∪ Y ∖ X. Proof. intros HXY. apply gmultiset_eq; intros x; specialize (HXY x). rewrite multiplicity_union, multiplicity_difference; omega. Qed. Lemma gmultiset_union_difference' x Y : x ∈ Y → Y = {[ x ]} ∪ Y ∖ {[ x ]}. Proof. intros. by apply gmultiset_union_difference, gmultiset_elem_of_singleton_subseteq. Qed. Lemma gmultiset_size_difference X Y : Y ⊆ X → size (X ∖ Y) = size X - size Y. Proof. intros HX%gmultiset_union_difference. rewrite HX at 2; rewrite gmultiset_size_union. omega. Qed. Lemma gmultiset_non_empty_difference X Y : X ⊂ Y → Y ∖ X ≠ ∅. Proof. intros [_ HXY2] Hdiff; destruct HXY2; intros x. generalize (f_equal (multiplicity x) Hdiff). rewrite multiplicity_difference, multiplicity_empty; omega. Qed. Lemma gmultiset_difference_subset X Y : X ≠ ∅ → X ⊆ Y → Y ∖ X ⊂ Y. Proof. intros. eapply strict_transitive_l; [by apply gmultiset_union_subset_r|]. by rewrite <-(gmultiset_union_difference X Y). Qed. (* Mononicity *) Lemma gmultiset_elements_submseteq X Y : X ⊆ Y → elements X ⊆+ elements Y. Proof. intros ->%gmultiset_union_difference. rewrite gmultiset_elements_union. by apply submseteq_inserts_r. Qed. Lemma gmultiset_subseteq_size X Y : X ⊆ Y → size X ≤ size Y. Proof. intros. by apply submseteq_length, gmultiset_elements_submseteq. Qed. Lemma gmultiset_subset_size X Y : X ⊂ Y → size X < size Y. Proof. intros HXY. assert (size (Y ∖ X) ≠ 0). { by apply gmultiset_size_non_empty_iff, gmultiset_non_empty_difference. } rewrite (gmultiset_union_difference X Y), gmultiset_size_union by auto. lia. Qed. (* Well-foundedness *) Lemma gmultiset_wf : wf (strict (@subseteq (gmultiset A) _)). Proof. apply (wf_projected (<) size); auto using gmultiset_subset_size, lt_wf. Qed. Lemma gmultiset_ind (P : gmultiset A → Prop) : P ∅ → (∀ x X, P X → P ({[ x ]} ∪ X)) → ∀ X, P X. Proof. intros Hemp Hinsert X. induction (gmultiset_wf X) as [X _ IH]. destruct (gmultiset_choose_or_empty X) as [[x Hx]| ->]; auto. rewrite (gmultiset_union_difference' x X) by done. apply Hinsert, IH, gmultiset_difference_subset, gmultiset_elem_of_singleton_subseteq; auto using gmultiset_non_empty_singleton. Qed. End lemmas.
theory prop_25 imports Main "$HIPSTER_HOME/IsaHipster" begin datatype Nat = Z | S "Nat" fun max2 :: "Nat => Nat => Nat" where "max2 (Z) y = y" | "max2 (S z) (Z) = S z" | "max2 (S z) (S x2) = S (max2 z x2)" fun le :: "Nat => Nat => bool" where "le (Z) y = True" | "le (S z) (Z) = False" | "le (S z) (S x2) = le z x2" fun equal2 :: "Nat => Nat => bool" where "equal2 (Z) (Z) = True" | "equal2 (Z) (S z) = False" | "equal2 (S x2) (Z) = False" | "equal2 (S x2) (S y2) = equal2 x2 y2" (*hipster max2 le equal2 *) lemma lemma_a [thy_expl]: "equal2 x4 y4 = equal2 y4 x4" by (hipster_induct_schemes prop_25.equal2.simps) lemma lemma_aa [thy_expl]: "equal2 x2 x2 = True" by (hipster_induct_schemes prop_25.equal2.simps) lemma lemma_ab [thy_expl]: "equal2 x2 (S x2) = False" by (hipster_induct_schemes prop_25.equal2.simps) theorem x0 : "(equal2 (max2 a b) b) = (le a b)" by (tactic \<open>Subgoal.FOCUS_PARAMS (K (Tactic_Data.hard_tac @{context})) @{context} 1\<close>) end
POSTGRESQL_HOST='127.0.0.1' POSTGRESQL_PORT=5432 POSTGRESQL_USER='postgres' POSTGRESQL_DB='postgres' POSTGRESQL_PASS='yourPassword'
[STATEMENT] lemma SN_rel_on_alt_s_empty : "SN_rel_on_alt R {} = SN_on R" [PROOF STATE] proof (prove) goal (1 subgoal): 1. SN_rel_on_alt R {} = SN_on R [PROOF STEP] by (intro ext, unfold SN_rel_defs SN_defs, auto)
import combinatorics.simple_graph.coloring --OUTPUT 1 theorem bipartite_iff_two_colorable {V : Type*} (G : simple_graph V) [fintype V] : (G.colorable 2) ↔ (∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)) := begin apply iff.intro, assume h1 : G.colorable 2, cases h1 with f hf, let A := f ⁻¹' {1}, let B := f ⁻¹' {2}, have h1 : (A ⊕ B) = V, from by auto [set.ext], let f2 := cast (congr_arg _ h1) (λ (t : A ⊕ B), (if t.is_inl then 1 else 2)), have h2 : f2 : V → fin 2, from by auto [set.ext, set.image_preimage_eq_of_inverse (λ (x : ℕ), x ∈ ({1, 2} : set ℕ)) (λ (x : ℕ), x ∈ {1, 2}) (@fin.of_nat 2) (λ (x : ℕ), by auto [fin.of_nat_inj])], have h3 : (∀ (v : A ⊕ B), (f2 v).val = (if v.is_inl then 1 else 2)), from by auto [fin.coe_val_of_ne_zero], have h4 : (f2 = cast (congr_arg _ h1) (λ (t : A ⊕ B), (if t.is_inl then 1 else 2))), from rfl, have h5 : f2 = f, from by auto [h1, h4, funext_iff, h3, cast_eq f], have h6 : (∀ (v w : A ⊕ B), (f2 v).val ≠ (f2 w).val → (∃ (x : A) (y : B), v = x ⊕ y ∧ degree G x ≠ 0 ∧ degree G y ≠ 0)), from by auto using [hf, h5, fin.coe_val_of_ne_zero, fin.coe_val_of_ne_zero], have h7 : (∀ (v w : A ⊕ B), ((v.is_inl) ∧ (w.is_inl)) ∨ ((v.is_inl) ∧ (w.is_inr)) ∨ ((v.is_inr) ∧ (w.is_inl)) ∨ ((v.is_inr) ∧ (w.is_inr))), from by auto [or.left_comm], have h8 : (∀ (v w : A ⊕ B), (f2 v).val ≠ (f2 w).val → (((v.is_inl) ∧ (w.is_inl)) ∨ ((v.is_inl) ∧ (w.is_inr)) ∨ ((v.is_inr) ∧ (w.is_inl)) ∨ ((v.is_inr) ∧ (w.is_inr)))), from by auto [h7], have h9 : (∀ (v w : V), w ≠ v → (∃ (x : A) (y : B), v = x ⊕ y ∧ degree G x ≠ 0 ∧ degree G y ≠ 0)), from by auto using [h1, h8, h6], have h10 : (∀ (v : V), degree G v ≠ 0 → (∃ (p : A) (q : B), v = p ⊕ q ∧ degree G p ≠ 0 ∧ degree G q ≠ 0)), from by auto [h9], have h11 : (∀ (v : V), v = v ∧ degree G v ≠ 0 → (∃ (p : A) (q : B), v = p ⊕ q ∧ degree G p ≠ 0 ∧ degree G q ≠ 0)), from by auto [h10], have h12 : (∀ (v : V), (∃ (p : A) (q : B), v = p ⊕ q ∧ degree G p ≠ 0 ∧ degree G q ≠ 0)), from let v := v in by auto [h11], have h13 : (∀ (v : V), (∃ (p : A) (q : B), v = p ⊕ q ∧ degree G p ≠ 0 ∧ degree G q ≠ 0) → (∃ (v : A ⊕ B), (λ (t : A ⊕ B), (if t.is_inl then 1 else 2)) v ≠ 0)), from begin assume (v : V), assume h13 : (∃ (p : A) (q : B), v = p ⊕ q ∧ degree G p ≠ 0 ∧ degree G q ≠ 0), cases h13 with p h13, cases h13 with q h13, cases h13 with h13 h13, cases h13 with h13 h13, suffices : (λ (t : A ⊕ B), (if t.is_inl then 1 else 2)) (p ⊕ q) ≠ 0, from ⟨p ⊕ q, this⟩, suffices : (λ (t : A ⊕ B), (if t.is_inl then 1 else 2)) (p ⊕ q) = 1, from by auto [congr_arg], end, have h14 : (∀ (v : A ⊕ B), (λ (t : A ⊕ B), (if t.is_inl then 1 else 2)) v ≠ 0), from by auto [h12, h13], have h15 : (∀ (v : A ⊕ B), (λ (t : A ⊕ B), (if t.is_inl then 1 else 2)) v ≠ 0 → (∃ (x : A) (y : B), v = x ⊕ y ∧ degree G x ≠ 0 ∧ degree G y ≠ 0)), from begin assume (v : A ⊕ B), assume h15 : (λ (t : A ⊕ B), (if t.is_inl then 1 else 2)) v ≠ 0, suffices : (λ (t : A ⊕ B), (if t.is_inl then 1 else 2)) v = 1, from by auto [congr_arg], cases v, show (λ (t : A ⊕ B), (if t.is_inl then 1 else 2)) ⟨a, or.inl h⟩ = 1, from rfl, assume h : b, show (λ (t : A ⊕ B), (if t.is_inl then 1 else 2)) ⟨a, or.inr h⟩ = 2, from rfl, end, have h16 : (∃ (v : A ⊕ B), (λ (t : A ⊕ B), (if t.is_inl then 1 else 2)) v ≠ 0), from classical.by_contradiction (λ h17, by auto [h14, not_exists.elim h17]), have h17 : (∃ (v : A ⊕ B), (λ (t : A ⊕ B), (if t.is_inl then 1 else 2)) v ≠ 0 → (∃ (x : A) (y : B), v = x ⊕ y ∧ degree G x ≠ 0 ∧ degree G y ≠ 0)), from by auto [h15], have h18 : (∃ (x : A) (y : B), (exists.elim h16 (λ (v : A ⊕ B), (exists.elim (h17 v (exists.elim h16 (λ (v' : A ⊕ B), (exists.elim h16 (λ (h18 : v' = v), h18.symm))))) (λ (v' : A ⊕ B), v')))) ∧ degree G x ≠ 0 ∧ degree G y ≠ 0), from let v := (exists.elim h16 (λ (v : A ⊕ B), v)) in let h19 := (exists.elim h16 (λ (v : A ⊕ B), exists.elim (h17 v (exists.elim h16 (λ (v' : A ⊕ B), (exists.elim h16 (λ (h end --Needs more than 2000 tokens! --OUTPUT 2 theorem bipartite_iff_two_colorable {V : Type*} (G : simple_graph V) [fintype V] : (G.colorable 2) ↔ (∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)) := begin have h1 : ∀ n, n ≥ 1 → n-1 < n, from by auto [nat.sub_one], split, { assume h, cases h, cases h with f h1, cases h1 with hf h1, cases h1 with h2 h3, have h4 : fintype (Σ (x : G.V), (f x) ≠ f x), from by auto [@fintype.of_equiv], have h5 : fintype.card (Σ (x : G.V), (f x) ≠ f x) = 2, from by auto [fintype.card_congr, nat.sub_eq_of_eq_add, nat.add_sub_cancel (nat.pos_of_ne_zero h2)] using [@fintype.card_sigma, @fintype.card_sigma, @fintype.card_sigma, @fintype.card_sigma], have h6 : fintype.card ((Σ (x : G.V), (f x) ≠ f x) : set (G.V)) < fintype.card G.V, from by auto [fintype.card_congr, nat.le_of_lt, fintype.card_lt_iff_not_eq_empty], have h7 : (∀ (A B : fintype.card ((Σ (x : G.V), (f x) ≠ f x))), ∀ (f : (Σ (x : G.V), (f x) ≠ f x) → G.V), ∃ (H : G.V), ∀ (x : G.V), (x = H) ∨ (x ≠ H)), from by auto [fintype.card_lt_iff_not_eq_empty, fintype.card_congr, @fintype.card_sigma, @fintype.card_sigma, @fintype.card_sigma, @fintype.card_sigma, nat.le_of_lt], have h8 : (∃ (H : G.V), ∀ (x : G.V), (x = H) ∨ (x ≠ H)), from by auto [h7], cases h8 with H h9, have h10 : (f H) ≠ f H, from by auto [h9], have h11 : (f H) ≠ (f H), from by auto [h10], have h12 : G.V ≃ (Σ (x : G.V), (f x) ≠ f x), from begin apply equiv.of_bijective _ _, { assume a, cases a with x h13, apply subtype.eq, show (f x) ≠ f x, from by auto [h13] }, { assume a, cases a with x h13, have h14 : ∃ (a : G.V), a = x ∧ (f a) ≠ (f a), from by auto [set.mem_univ, @exists_prop, h13], cases h14 with h14 h15, cases h15 with h15 h16, show ∃ (a : G.V), (f a) ≠ (f a), from by auto [h14] }, { assume a ha, cases a with x h13, have h14 : ∃ (a : G.V), a = x ∧ (f a) ≠ (f a), from by auto [set.mem_univ, @exists_prop, h13], cases h14 with h14 h15, cases h15 with h15 h16, show (f h14) ≠ (f h14), from by auto [h14, h15, h16] } end, have h13 : fintype.card G.V = fintype.card (Σ (x : G.V), (f x) ≠ f x), from by auto [fintype.card_congr, h12], have h14 : (Σ (x : G.V), (f x) ≠ f x) ≃ (sigma G.V (λ x, x ≠ x)), from by auto [is_equiv.equiv_sigma_eq_sigma], have h15 : sigma G.V (λ x, x ≠ x) ≃ (sigma G.V (λ x, x.1 ≠ x.2)), from by auto [equiv.trans, h14] using [@is_equiv.sigma_equiv_sigma_of_equiv], have h16 : fintype.card (sigma G.V (λ x, x ≠ x)) = (fintype.card G.V)*(fintype.card G.V), from by auto [fintype.card_congr, h15], have h17 : fintype.card G.V = 2, from by auto [eq_comm, eq.trans, h5, h13, h16, nat.mul_left_cancel, nat.pos_of_ne_zero h2], have h18 : G.V ≃ (ulift bool), from by auto [function.funext_iff, @equiv_bool_ulift_def, h17], have h19 : (ulift bool) ≃ (bool : Type*), from by auto [equiv.trans, h18, @equiv_ulift_def], have h20 : G.V ≃ (bool : Type*), from by auto [h19, eq_comm], let g : G.V → bool := by auto [h20], use g, split, { cases h3 with h3 h3a, assume a b h21, have h22 : (g a) ≠ (g b), from by auto [h20, h3, h21], apply subtype.eq, show (g a) ≠ (g b), from by auto [h22] }, { split, { assume a, apply subtype.eq, show f a = g a, from by auto [h20, h1, h2], }, { assume a, apply subtype.eq, show g a = f a, from by auto [h20, h1, h2], } } }, { assume h, cases h with A B h1, cases h1, have h2 : fintype (A ⊕ B), from by auto [@fintype.of_equiv], have h3 : ((equiv.ulift : bool ↝ ulift bool) : bool ↝ A ⊕ B) = (cast (congr_arg _ h1) (equiv.bool_bool : bool ↝ bool)), from by auto [funext], let f : G.V → A ⊕ B := cast (congr_arg _ h1) (equiv.bool_bool), have h6 : fintype G.V, from by auto [@fintype.of_equiv], have h7 : ((equiv.ulift : bool ↝ ulift bool) : bool ↝ A ⊕ B) = (cast (congr_arg _ h1) (equiv.bool_bool : bool ↝ bool)) := begin auto [funext], end, have h4 : fintype.card G.V = fintype.card A ⊕ B, from by auto [fintype.card_congr, h3], have h5 : fintype.card A ⊕ B = 2, from by auto [@fintype.card_sigma, h2, @fintype.card_sigma, @fintype.card_sigma, nat.mul_left_cancel, nat.pos_of_ne_zero, mul_one], have h8 : (fintype.card A = 1 ∧ fintype.card B = 1), from by auto [nat.le_add_right, nat.le_add_left, fintype.card_le_one_iff, h4, h end --Needs more than 2000 tokens! --OUTPUT 3 theorem bipartite_iff_two_colorable {V : Type*} (G : simple_graph V) [fintype V] : (G.colorable 2) ↔ (∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)) := begin split, { intros h1, have h2 : ∃ R B : set V, ∀ v : V, (v ∈ R) ∨ (v ∈ B), from h1.to_has_decidable_eq, let R := h2.1, let B := h2.2, have h3 : ∀ a b : V, a ≠ b → a ∈ R → b ∈ B, from begin assume (a b : V) (h4 : a ≠ b) (h5 : a ∈ R), have h6 : (a ∈ B) ∨ (b ∈ R), from h2.3 a, have h7 : (a ∈ B) → (b ∈ R), from begin intro h8, have h9 : a ∈ B ∧ b ∈ R, from by auto [h8, h5], have h10 : (a = b), from by auto, show b ∈ R, from by auto [h10, h4], end, show b ∈ B, from by auto [h6, h7], end, have h4 : ∀ a b : V, a ∈ R → b ∈ B → a ≠ b, from begin assume (a b : V) (h5 : a ∈ R) (h6 : b ∈ B), assume h7 : a = b, have h8 : a ∈ R ∧ b ∈ R, from by auto [h5, h7], show false, from h2.3 a h8, end, have h5 : ∀ (a b : V) (h6 : G.adj a b), a ∈ R → b ∈ B, from begin assume (a b : V) (h6 : G.adj a b), show a ∈ R → b ∈ B, from begin intro h7, have h8 : (a ∈ B) ∨ (b ∈ R), from h2.3 a, have h9 : a ∈ B → b ∈ R, from begin intro h10, have h11 : a ∈ B ∧ b ∈ R, from by auto [h10, h7], have h12 : (a = b), from by auto, show b ∈ R, from by auto [h12, h4], end, show b ∈ B, from by auto [h8, h9], end, end, have h6 : ∀ (a b : V) (h7 : G.adj a b), a ∈ R → b ∈ B, from begin assume (a b : V) (h7 : G.adj a b), show a ∈ R → b ∈ B, from begin intro h8, have h9 : (a ∈ B) ∨ (b ∈ R), from h2.3 a, have h10 : a ∈ B → b ∈ R, from begin intro h11, have h12 : a ∈ B ∧ b ∈ R, from by auto [h11, h8], have h13 : (a = b), from by auto, show b ∈ R, from by auto [h13, h4], end, show b ∈ B, from by auto [h9, h10], end end, have h7 : ∀ (a b : V) (h8 : G.adj a b), a ∈ B → b ∈ R, from begin assume (a b : V) (h8 : G.adj a b), show a ∈ B → b ∈ R, from begin intro h9, have h10 : (a ∈ R) ∨ (b ∈ B), from h2.3 a, have h11 : a ∈ R → b ∈ B, from begin intro h12, have h13 : a ∈ R ∧ b ∈ B, from by auto [h12, h9], have h14 : (a = b), from by auto, show b ∈ B, from by auto [h14, h4], end, show b ∈ R, from by auto [h10, h11], end end, have h8 : ∀ (a b : V) (h9 : G.adj a b), a ∈ R → b ∈ B, from begin assume (a b : V) (h9 : G.adj a b), show a ∈ R → b ∈ B, from begin intro h10, have h11 : (a ∈ B) ∨ (b ∈ R), from h2.3 a, have h12 : a ∈ B → b ∈ R, from begin intro h13, have h14 : a ∈ B ∧ b ∈ R, from by auto [h13, h10], have h15 : (a = b), from by auto, show b ∈ R, from by auto [h15, h4], end, show b ∈ B, from by auto [h11, h12], end end, have h9 : ∀ (a b : V) (h10 : G.adj a b), a ∈ B → b ∈ R, from begin assume (a b : V) (h10 : G.adj a b), show a ∈ B → b ∈ R, from begin intro h11, have h12 : (a ∈ R) ∨ (b ∈ B), from h2.3 a, have h13 : a ∈ R → b ∈ B, from begin intro h14, have h15 : a ∈ R ∧ b ∈ B, from by auto [h14, h11], have h16 : (a = b), from by auto, show b ∈ B, from by auto [h16, h4], end, show b ∈ R, from by auto [h12, h13], end end, have h11 : ∀ (a b : V) (h12 : G.adj a b), a ∈ B → b ∈ R, from begin assume (a b : V) (h12 : G.adj a b), show a ∈ B → b ∈ R, from begin intro h13, have h14 : (a ∈ R) ∨ (b ∈ B), from h2.3 a, have h15 : a ∈ R → b ∈ B, from begin intro h16, have h17 : a ∈ R ∧ b ∈ B, from by auto [h16, h13], have h18 : (a = b), from by auto, show b ∈ B, from by auto [h18, h4], end, show b ∈ R, from by auto [h14, h15], end end, have h12 : ∀ (a b : V) (h13 : G.adj a b), a ∈ R → b ∈ B, from begin assume (a b : V) (h13 : G.adj a b), show a ∈ R → b ∈ B, from begin intro h14, have h15 : (a ∈ B) ∨ (b ∈ R), from h2.3 a, have h16 : a ∈ B → b ∈ R, from begin intro h17, have h18 : a ∈ B ∧ b ∈ R, from by auto [h17, h14], have h19 : (a = b), from by auto, show b ∈ R, from by auto [h19, h4], end, show b ∈ B, from by auto [h15, h16], end end, have h14 : ∀ (a b : V) (h15 : G.adj a b), a ∈ B → b ∈ R, from begin assume (a b : end --Needs more than 2000 tokens! --OUTPUT 4 theorem bipartite_iff_two_colorable {V : Type*} (G : simple_graph V) [fintype V] : (G.colorable 2) ↔ (∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)) := begin split, { assume h1 : G.colorable 2, show ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from begin let h2 : V → fin 2 := (λ (v : V), classical.some (h1 v).is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some.is_some), let A : Type* := (fin 2 ⟶ V), let B : Type* := V, let h3 : (A ⊕ B) = V := by tidy, let h4 : finset A → finset B → finset ℕ, h5 : finset A → finset B → finset V := λ x y, ⟨x.1.to_fun ⁻¹' y.1, sorry⟩, h6 : finset A → finset B → finset V → Prop := λ x y z, ∃ x' ∈ x.1, ∃ y' ∈ y.1, z.1 = G.adj x' y', let h7 : (finset A → finset B → finset V) = (finset A → finset B → finset V → Prop), h8 : finset A → finset B → finset V → Prop := by apply_instance, h9 : (finset A → finset B → finset V) = (finset A → finset B → finset V → Prop), h10 : finset A → finset B → finset V → Prop := by apply_instance, let h11 : (finset A → finset B → finset ℕ) = (finset A → finset B → finset V), h12 : finset A → finset B → finset V := by apply_instance, h13 : (finset A → finset B → finset ℕ) = (finset A → finset B → finset V), h14 : finset A → finset B → finset V := by apply_instance, let h15 : (finset A → finset B) = (finset A → finset B → finset ℕ), h16 : finset A → finset B → finset ℕ := by apply_instance, h17 : (finset A → finset B) = (finset A → finset B → finset ℕ), h18 : finset A → finset B → finset ℕ := by apply_instance, let h19 : (finset A) = (finset A → finset B), h20 : finset A → finset B := by apply_instance, h21 : (finset A) = (finset A → finset B), h22 : finset A → finset B := by apply_instance, let h23 : ∀ x, ∃! y, x = y, h24 : ∀ x, ∃! y, x = y := by apply_instance, let h25 : (finset A) = finset A, h26 : finset A := by apply_instance, let h27 : (finset B) = finset B, h28 : finset B := by apply_instance, let h29 : (finset V) = finset V, h30 : finset V := by apply_instance, let h31 : (finset ℕ) = finset ℕ, h32 : finset ℕ := by apply_instance, have h33 : (finset A → finset B → finset V) = (finset A → finset B → finset ℕ), from by tidy, have h34 : ∀ x, ∃! y, x = y, from by apply_instance, show ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by tidy end }, { assume h1 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), show G.colorable 2, from begin cases h1 with h2 h3, cases h3 with h4 h5, cases h4 with h6 h7, have h8 : ∀ x, ∃! y, x = y, from by apply_instance, let h9 := by apply_instance, let h10 := by apply_instance, let h11 := by apply_instance, let h12 := by apply_instance, let h13 := by apply_instance, let h14 := by apply_instance, let h15 := by apply_instance, let h16 := by apply_instance, let h17 := by apply_instance, let h18 := by apply_instance, let h19 := by apply_instance, let h20 := by apply_instance, let h21 := by apply_instance, let h22 := by apply_instance, let h23 := by apply_instance, let h24 := by apply_instance, let h25 := by apply_instance, let h26 := by apply_instance, let h27 := by apply_instance, let h28 := by apply_instance, let h29 := by apply_instance, let h30 := by apply_instance, let h31 := by apply_instance, let h32 := by apply_instance, let h33 := by apply_instance, let h34 := by apply_instance, let h35 := by apply_instance, let h36 := by apply_instance, let h37 := by apply_instance, let h38 := by apply_instance, let h39 := by apply_instance, let h40 := by apply_instance, let h41 := by apply_instance, let h42 := by apply_instance, let h43 := by apply_instance, let h44 := by apply_instance, let h45 := by apply_instance, let h46 := by apply_instance, let h47 := by apply_instance, let h48 := by apply_instance, let h49 := by apply_instance, let h50 := by apply_instance, let h51 := by apply_instance, let h52 := by apply_instance, let h53 := by apply_instance, let h54 := by apply_instance, let h55 := by apply_instance, let h56 := by apply_instance, let h57 := by apply_instance, let h58 := by apply_instance, let h59 := by apply_instance, let h60 := by apply_instance, let h61 := by apply end --Needs more than 2000 tokens! --OUTPUT 5 theorem bipartite_iff_two_colorable {V : Type*} (G : simple_graph V) [fintype V] : (G.colorable 2) ↔ (∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)) := begin split, assume h1 : G.colorable 2, rcases h1 with ⟨f, h2, h3, h4⟩, have h5 : ∀ (v : V), (f v) = 1 ∨ (f v) = 2, from and.elim_right h3 v, let A : set V := {v | (f v) = 1}, let B : set V := {v | (f v) = 2}, have h6 : ∀ (v : V), f v = 1 ↔ (v ∈ A), from by intros v; split; intro h; auto [mem_set_of_eq], have h7 : ∀ (v : V), f v = 2 ↔ (v ∈ B), from by intros v; split; intro h; auto [mem_set_of_eq], have h8 : ∀ (v : V), (v ∉ A) ↔ (v ∈ B), from by intros v; split; intro h; rcases h5 v with ⟨h8, h9⟩; auto [exfalso, h8]; auto [h9], have h9 : ∀ (v : V), (v ∉ B) ↔ (v ∈ A), from by intros v; split; intro h; rcases h5 v with ⟨h8, h9⟩; auto [h8]; auto [exfalso, h9], have h10 : disjoint A B, from by intros v hv; auto [exfalso, h4 v, hv], have h11 : A ⊆ V, from by auto [subset_univ], have h12 : B ⊆ V, from by auto [subset_univ], have h13 : ∅ ∈ {x|x ⊆ V}, from by auto [subset_empty], have h14 : A ∈ {x|x ⊆ V}, from by auto [h11], have h15 : B ∈ {x|x ⊆ V}, from by auto [h12], have h16 : fintype A, from by auto [fintype.of_subset h11], have h17 : fintype B, from by auto [fintype.of_subset h12], have h18 : fintype {x | x ⊆ V}, from by auto [set.finite_subset (fintype.powerset (fintype.univ V)), set.subset_univ], have h19 : ∃ (y : {x | x ⊆ V}), (1 : ℕ) ≤ y.card ∧ (y.card + 1) ≤ A.card + B.card, from by auto [fintype.card_ne_zero, h16, h17, h13, h14, h15, card_union_of_disjoint, h10, exists.intro _ (and.intro (le_of_succ_le_succ (nat.zero_le _) (nat.le_add_right _ _)) (le_add_of_nonneg_right _ (nat.zero_le _)))], rcases h19 with ⟨y, h19t⟩, have h20 : (1 : ℕ) ≤ y.card, from and.elim_left h19t, have h21 : 2 ≤ A.card + B.card, from by auto [le_of_add_le_add_right, h19t], have h22 : ∀ (x : {x | x ⊆ V}), (x ⊆ A ∨ x ⊆ B) → ∃! e : {x | x ⊆ V}, 1 ≤ e.card ∧ (e.card + 1) ≤ x.card, { assume x, intro h23, have h24 : ∃ (e : {x | x ⊆ V}), 1 ≤ e.card ∧ (e.card + 1) ≤ x.card, from by auto [h18.card_le_card_of_subset h23], show ∃! e : {x | x ⊆ V}, 1 ≤ e.card ∧ (e.card + 1) ≤ x.card, from by auto [exists_unique.intro _ h24], }, have h25 : ∃! (e : {x | x ⊆ V}), 1 ≤ e.card ∧ (e.card + 1) ≤ A.card ∧ (e.card + 1) ≤ B.card, from by auto [exists_unique.intro y, h20, h21, and.left, and.right], rcases h25 with ⟨e, h26, h27⟩, have h28 : ∀ (y : {x | x ⊆ V}), (1 ≤ y.card ∧ (y.card + 1) ≤ A.card ∧ (y.card + 1) ≤ B.card) → y = e, from and.elim_left h26, have h29 : ∀ (v : V), (v ∈ A) → (v ∈ e), from by auto [le_of_add_le_add_right, h27, h6, h14], have h30 : ∀ (v : V), (v ∈ B) → (v ∈ e), from by auto [le_of_add_le_add_right, h27, h7, h15], have h31 : ∀ (v : V), (v ∈ e) → (v ∈ A ∨ v ∈ B), from by auto [h29, h30], have h32 : ∀ (v : V), (v ∈ A) ≃ (v ∈ e), from by auto [h29, h8, h9], have h33 : ∀ (v : V), (v ∈ B) ≃ (v ∈ e), from by auto [h30, h8, h9], have h34 : ∀ (v : V), (v ∈ e) ↔ (v ∈ A ∨ v ∈ B), from by auto [h31, h29, h30], have h35 : ∀ (v : V), (v ∈ A) ↔ (v ∈ e), from by auto [h7, h32, h34], have h36 : ∀ (v : V), (v ∈ B) ↔ (v ∈ e), from by auto [h7, h33, h34], have h37 : A = e, from ext_bijective.ext (λ v, v ∈ A) (λ v, v ∈ e) h35, have h38 : B = e, from ext_bijective.ext (λ v, v ∈ B) (λ v, v ∈ e) h36, have h39 : exist.intro (λ (v : V), v ∈ e) (begin intros v hv, have h : v ∈ e, from hv, rcases h with ⟨h⟩, show v ∈ A ∨ v ∈ B, from h, end) = exist.intro (λ (v : V), v ∈ A ∨ v ∈ B) (begin intros v hv, show v ∈ e, from or.elim hv (λ h, h) (λ h, h), end), from funext (λ v, propext (or_iff_not_and_not.elim_left v)), have h40 : exist.intro (λ (v : V), v ∈ e) (begin intros v hv, have h : v ∈ e, from hv, rcases h with ⟨h⟩, show v ∈ A ∨ v ∈ B, from h, end) = exist.intro (λ (v : V), v ∈ B) (begin intros v hv, have h : v ∈ e, from hv, rcases h with ⟨h⟩, show v ∈ A ∨ v ∈ B, from h, end), from funext (λ v, propext (or_iff_not_and_not.elim_right v)), have h41 : exist.intro (λ (v : V), v ∈ A) (begin intros v hv, show v ∈ end --Needs more than 2000 tokens! --OUTPUT 6 theorem bipartite_iff_two_colorable {V : Type*} (G : simple_graph V) [fintype V] : (G.colorable 2) ↔ (∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)) := begin sorry, end --OUTPUT 7 theorem bipartite_iff_two_colorable {V : Type*} (G : simple_graph V) [fintype V] : (G.colorable 2) ↔ (∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)) := begin split, { assume : ℕ, intro H, cases H with f H, cases H with H1 H2, cases H1 with hf hf, have H1 : (f '' G.vertices) ⊆ ({0, 1} : set ℕ), from set.image_subset_iff.mpr H2, have H2 : f '' G.vertices = {0,1}, from set.eq_singleton_iff_eq_empty.mp (set.eq_empty_iff_forall_not_mem.mpr (λ a h, by {cases h with b hb, cases hb with hb1 hb2, rw hb1 at hb2,exact H1 hb2})), have H1 : (set.range f) ⊆ ({0, 1} : set ℕ), from set.range_subset_iff.mpr H2, have H2 : set.range f = {0, 1}, from set.eq_singleton_iff_eq_empty.mp (set.eq_empty_iff_forall_not_mem.mpr (λ a h, by {cases h with b hb, cases hb with hb1 hb2, rw ← hb1 at hb2,exact H1 hb2})), let α : Type* := by {cases H2, assumption}, let β : Type* := by {cases H2, assumption}, let h : (α ⊕ β) = V := by {exact congr_arg _ (set.range_eq_univ.mp (set.eq_univ_singleton.mp H2))}, let f₂ : (α ⊕ β) → ℕ := λ x, f x, have H1 : (f '' G.vertices) ⊆ ({0, 1} : set ℕ), from set.image_subset_iff.mpr H2, have H2 : f₂ '' (α ⊕ β) = {0,1}, from set.eq_singleton_iff_eq_empty.mp (set.eq_empty_iff_forall_not_mem.mpr (λ a h, by {cases h with b hb, cases hb with hb1 hb2, rw hb1 at hb2,exact H1 hb2})), have H1 : (set.range f₂) ⊆ ({0, 1} : set ℕ), from set.range_subset_iff.mpr H2, have H2 : set.range f₂ = {0, 1}, from set.eq_singleton_iff_eq_empty.mp (set.eq_empty_iff_forall_not_mem.mpr (λ a h, by {cases h with b hb, cases hb with hb1 hb2, rw ← hb1 at hb2,exact H1 hb2})), let f₃ : V → ℕ := by {exact congr_arg _ (set.range_eq_univ.mp (set.eq_univ_singleton.mp H2))}, have H1 : (f₃ '' V) ⊆ ({0, 1} : set ℕ), from set.image_subset_iff.mpr H2, have H2 : f₃ '' V = {0,1}, from set.eq_singleton_iff_eq_empty.mp (set.eq_empty_iff_forall_not_mem.mpr (λ a h, by {cases h with b hb, cases hb with hb1 hb2, rw hb1 at hb2,exact H1 hb2})), have H3 : (f₂ '' (α ⊕ β)) = (f₃ '' V), from congr_arg _ (set.range_eq_univ.mp (set.eq_univ_singleton.mp H2)), let f₄ : (α ⊕ β) → V := by {exact congr_arg _ (set.range_eq_univ.mp (set.eq_univ_singleton.mp H3))}, have H4 : set.range f₄ = V, from set.range_eq_univ.mpr (set.eq_univ_singleton.mpr H3), have H5 : f₄ '' (α ⊕ β) = V := by {exact congr_arg _ H4}, let A : Type* := @classical.some (fintype (α ⊕ β)) _ (fintype.exists_fintype_iff.mp (fintype.fintype_image ((α ⊕ β)) V f₄)), let B : Type* := @classical.some (fintype (α ⊕ β)) _ (fintype.exists_fintype_iff.mp (fintype.fintype_image ((α ⊕ β)) V f₄)), let h1 : (α ⊕ β) = A ⊕ B := by {exact classical.some_spec (fintype.exists_fintype_iff.mp (fintype.fintype_image ((α ⊕ β)) V f₄))}, let h2 : A ∈ set.powerset (α ⊕ β), from by {rw ← h1 at *, exact simple_graph.fintype_edge_set G}, let h3 : B ∈ set.powerset (α ⊕ β), from by {rw ← h1 at *, exact simple_graph.fintype_edge_set G}, let h4 : A ∩ B = ∅ := (set.pairwise_disjoint_of_nonempty_inter_eq_empty (set.inter_subset_left _ _) (set.inter_subset_right _ _) (by {rw ← h1, exact simple_graph.fintype_edge_set G})), let f₅ : (α ⊕ β) → α ⊕ β := λ x, by {have H6 : x ∈ (fintype.fintype_image (α ⊕ β) V f₄).fintype := by {rw ← h1 at *, exact (set.fintype_of_fintype_image_fintype f₄) x},rw ← h1 at *, exact (classical.some_spec (fintype.exists_fintype_iff.mp (fintype.fintype_image ((α ⊕ β)) V f₄))) x}, have H5 : (f₅ '' α ⊕ β) ⊆ V, from (set.image_subset_iff.mpr H4), have H6 : f₅ '' α ⊕ β = V := set.eq_univ_of_univ_subset H5, have H7 : set.range f₅ = V := set.range_eq_univ.mpr (set.eq_univ_singleton.mpr H6), let f₆ : α ⊕ β → V := λ x, by {have H6 : x ∈ (fintype.fintype_image (α ⊕ β) V f₄).fintype := by {rw ← h1 at *, exact (set.fintype_of_fintype_image_fintype f₄) x},rw ← h1 at *, exact (classical.some_spec (fintype.exists_fintype_iff.mp (fintype.fintype_image ((α ⊕ β)) V f₄))) x}, have H5 : (f₆ '' α ⊕ β) ⊆ V, from (set.image_subset_iff.mpr H4), have H6 : f₆ '' α ⊕ β = V := set.eq_univ_of_univ_subset H5, have H7 : set.range f₆ = V := set.range_eq_univ.mpr (set.eq_univ_singleton.mpr end --Needs more than 2000 tokens! --OUTPUT 8 theorem bipartite_iff_two_colorable {V : Type*} (G : simple_graph V) [fintype V] : (G.colorable 2) ↔ (∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)) := begin admit, end --OUTPUT 9 theorem bipartite_iff_two_colorable {V : Type*} (G : simple_graph V) [fintype V] : (G.colorable 2) ↔ (∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)) := begin split, assume h, have h1 := G.colorable_iff_edge_disjoint_complete_graph h, have h2 := G.edge_disjoint_complete_graph_iff_complete_bipartite h1, cases h2 with A B (hA : A = G.edge_disjoint_component 0) (hB : B = G.edge_disjoint_component 1), rw ←hA, rw ←hB, let tmp := disjoint_union_type.mk A B, have h3 : (A ⊕ B) = G.V, from disjoint_union_type.mk_ne_empty A B, let tmp2 := cast (congr_arg _ h3) (complete_bipartite_graph A B), have h4 : G ≤ tmp2, by exact h2, exact ⟨A, B, h3, h4⟩, end --OUTPUT 10 theorem bipartite_iff_two_colorable {V : Type*} (G : simple_graph V) [fintype V] : (G.colorable 2) ↔ (∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)) := begin split, { assume H : G.colorable 2, have H1 : (powerset V).card = fintype.card (powerset V), from by { simp [powerset, card_powerset] }, have H2 : (powerset V).card = 2 ^ V.card, from by { simp }, have H3 : V.card = (finset.range 2).card, from congr_arg card H1.symm.trans H2.symm, have H4 : V.card = 2, from by { simp [card_range_eq_succ_pred_of_nat, *] at H3 }, have H5 : (finset.range 2) ≃ V, from by { have H5 : fintype.card (finset.range 2) = 2, by { simp }, simp [fintype.equiv_fin, *] at H5, exact H5.trans H4 }, have H6 : V ≃ (finset.range 2), from equiv.symm H5, have H7 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by { simp [*, @add_congr_arg] at H6, exact ⟨ (fin 2), (fin 2), H6, eq.trans (simple_graph.eq_complete_bipartite_graph_iff_is_bipartite G H6) (simple_graph.is_bipartite_iff_two_colors G H H6)⟩ }, exact H7, }, { assume H : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), let ⟨ A, B, H1, H2 ⟩ := H in let h := by { convert H1, simp }, let f := by { simp [h, *] }, have H3 : G.colorable 2, from by exact ⟨ 2, f ⟩, exact H3, } end /- FEW SHOT PROMPTS TO CODEX(START) /--`theorem` Power Set is Closed under Intersection Let $S$ be a set. Let $\powerset S$ be the power set of $S$. Then: :$\forall A, B \in \powerset S: A \cap B \in \powerset S$ `proof` Let $A, B \in \powerset S$. Then by the definition of power set, $A \subseteq S$ and $B \subseteq S$. From Intersection is Subset we have that $A \cap B \subseteq A$. It follows from Subset Relation is Transitive that $A \cap B \subseteq S$. Thus $A \cap B \in \powerset S$ and closure is proved. {{qed}} -/ theorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S := begin assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S), have h1 : (A ⊆ S) ∧ (B ⊆ S), from by auto [set.subset_of_mem_powerset, set.subset_of_mem_powerset], have h2 : (A ∩ B) ⊆ A, from by auto [set.inter_subset_left], have h3 : (A ∩ B) ⊆ S, from by auto [set.subset.trans], show (A ∩ B) ∈ 𝒫 S, from by auto [set.mem_powerset], end /--`theorem` Square of Sum :$\forall x, y \in \R: \paren {x + y}^2 = x^2 + 2 x y + y^2$ `proof` Follows from the distribution of multiplication over addition: {{begin-eqn}} {{eqn | l = \left({x + y}\right)^2 | r = \left({x + y}\right) \cdot \left({x + y}\right) }} {{eqn | r = x \cdot \left({x + y}\right) + y \cdot \left({x + y}\right) | c = Real Multiplication Distributes over Addition }} {{eqn | r = x \cdot x + x \cdot y + y \cdot x + y \cdot y | c = Real Multiplication Distributes over Addition }} {{eqn | r = x^2 + 2xy + y^2 | c = }} {{end-eqn}} {{qed}} -/ theorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := begin calc (x + y)^2 = (x+y)*(x+y) : by auto [sq] ... = x*(x+y) + y*(x+y) : by auto [add_mul] ... = x*x + x*y + y*x + y*y : by auto [mul_comm, add_mul] using [ring] ... = x^2 + 2*x*y + y^2 : by auto [sq, mul_comm] using [ring] end /--`theorem` Identity of Group is Unique Let $\struct {G, \circ}$ be a group. Then there is a unique identity element $e \in G$. `proof` From Group has Latin Square Property, there exists a unique $x \in G$ such that: :$a x = b$ and there exists a unique $y \in G$ such that: :$y a = b$ Setting $b = a$, this becomes: There exists a unique $x \in G$ such that: :$a x = a$ and there exists a unique $y \in G$ such that: :$y a = a$ These $x$ and $y$ are both $e$, by definition of identity element. {{qed}} -/ theorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a := begin have h1 : ∀ a b : G, ∃! x : G, a * x = b, from by auto using [use (a⁻¹ * b)], have h2 : ∀ a b : G, ∃! y : G, y * a = b, from by auto using [use b * a⁻¹], have h3 : ∀ a : G, ∃! x : G, a * x = a, from by auto [h1], have h4 : ∀ a : G, ∃! y : G, y * a = a, from by auto [h2], have h5 : ∀ a : G, classical.some (h3 a).exists = (1 : G), from by auto [exists_unique.unique, h3, classical.some_spec, exists_unique.exists, mul_one], have h6 : ∀ a : G, classical.some (h4 a).exists = (1 : G), from by auto [exists_unique.unique, h4, classical.some_spec, exists_unique.exists, one_mul], show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by auto [h3, h4, exists_unique.unique, classical.some_spec, exists_unique.exists] using [use (1 : G)], end /--`theorem` Bipartite Graph is two colorable Let $G$ be a graph. Then $G$ is 2-colorable if and only if $G$ is bipartite. `proof` Let $G$ be a 2-colorable graph, which means we can color every vertex either red or blue, and no edge will have both endpoints colored the same color. Let $A$ denote the subset of vertices colored red, and let $B$ denote the subset of vertices colored blue. Since all vertices of $A$ are red, there are no edges within $A$, and similarly for $B$. This implies that every edge has one endpoint in $A$ and the other in $B$, which means $G$ is bipartite. Conversely, suppose $G$ is bipartite, that is, we can partition the vertices into two subsets $V_{1}, V_{2}$ every edge has one endpoint in $V_{1}$ and the other in $V_{2}$. Then coloring every vertex of $V_{1}$ red and every vertex of $V_{2}$ blue yields a valid coloring, so $G$ is 2-colorable. QED -/ theorem bipartite_iff_two_colorable {V : Type*} (G : simple_graph V) [fintype V] : (G.colorable 2) ↔ (∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)) := FEW SHOT PROMPTS TO CODEX(END)-/
variables (α : Type) (p q : α → Prop) example : (∀ x, p x ∧ q x) ↔ (∀ x, p x) ∧ (∀ x, q x) := ⟨ assume h: (∀ x, p x ∧ q x), show (∀ x, p x) ∧ (∀ x, q x), from ( have h1: ∀ x, p x, from λ x, (h x).left, have h2: ∀ x, q x, from λ x, (h x).right, ⟨h1, h2⟩ ), assume h: (∀ x, p x) ∧ (∀ x, q x), λ x, ⟨(h.left x), (h.right x)⟩ ⟩ example : (∀ x, p x → q x) → (∀ x, p x) → (∀ x, q x) := ( assume (h1: ∀ x, p x → q x) (h2: ∀ x, p x), λ x, (h1 x) (h2 x) ) example : (∀ x, p x) ∨ (∀ x, q x) → ∀ x, p x ∨ q x := ( assume h: (∀ x, p x) ∨ (∀ x, q x), or.elim h ( assume hp: ∀ x, p x, λ x, or.inl (hp x) ) ( assume hq: ∀ x, q x, λ x, or.inr (hq x) ) )
module Object.Vertex (Vertex (..), createVertex) where import Numeric.Vector import Types createVertex :: Vec3d -> Vec3d -> Vec2d -> Vec3d -> Vec3d -> Vertex createVertex pos color texcoord normal tangent = Vertex { v_getPos = pos , v_getColor = color , v_getTexCoord = texcoord , v_getNormal = normal , v_getTangent = tangent , v_getBitangent = tangent × normal }
From Coq.Logic Require Import FunctionalExtensionality ProofIrrelevance. From mathcomp Require Import ssreflect ssrfun eqtype bigop choice path seq fintype. Set Warnings "-parsing". (* Some weird bug in ssrbool throws out parsing warnings*) From mathcomp Require Import ssrbool. Set Warnings "parsing". Set Warnings "-ambiguous-paths". (* Some weird bug in ssralg throws out coercion warnings*) From mathcomp Require Import ssralg. Set Warnings "ambiguous-paths". Require Export Path ntPathPairs PathAlgebraMul PathAlgebra. Require Export Algebras Basis Submodule FreeModules Quiver FormalLC. Open Scope ring_scope. Set Implicit Arguments. Unset Strict Implicit. Module PAlgBasis. Include ntPath.NTPath.Exports. Section Def. Variable (R : comRingType) (Q : finQuiverType). Definition pathAlgBasis := formalLC.basis R (Path.eqType Q). Section Element. Definition elem : pathType Q -> pathAlgType R Q := pathAlgBasis. Lemma idemR : forall (p : pathType Q), (elem p) * (elem \e_(Path.tail p)) = (elem p). Proof. move=>p; rewrite /(GRing.mul _)=>/=. rewrite /PAMul.Mul/elem=>/=. rewrite /formalLC.elem=>/=. apply functional_extensionality=>p'. case (p' == p) as []eqn:E. apply (rwP eqP) in E; rewrite E. case p as [i|r]eqn:P. by rewrite /Path.BuildPairs big_cons big_nil eq_refl GRing.mul1r GRing.addr0=>/=. destruct r as [[a r] H]. clear P E. Admitted. Lemma idemL : forall (p : pathType Q), (elem \e_(Path.head p)) * (elem p) = (elem p). Proof. move=> p. Admitted. Lemma idem : forall (i : \V_Q), (elem \e_i) * (elem \e_i) = (elem \e_i). Proof. move=>i; apply(idemR \e_i). Qed. End Element. (* Definition pathAlgBasisSet := formalLC.genSet R (Path.Path_eqType Q). Definition pathAlgBasis := lmodBasisSet.Pack (lmodBasisSet.Class (lmodBasisSet.Mixin (fun p : pathAlgBasisSet => @formalLC.pathApplyLin R (Path.Path_eqType Q) p) )).*) Definition freePathAlgType := freeLmod.Build pathAlgBasis. End Def. Lemma OneIsFiniteSum (R : comRingType) {Q : finQuiverType} : 1%R = \big[+%R/0%R]_(i : \V_Q)(elem R \e_i). Proof. rewrite/(GRing.one _)=>/=. apply functional_extensionality=>p. assert(formalLC.pathApplyLin p (PAMul.One R Q) = formalLC.pathApplyLin p(\big[+%R/0]_i elem R \e_ (i))). { rewrite GRing.raddf_sum=>/=. rewrite /formalLC.pathApply/PAMul.One/elem. case p as [a|a]. { rewrite -big_mkcond=>/=. rewrite (eq_bigl _ _ (inj_eq _ a)). by rewrite (eq_bigl _ _ (eq_sym _)) big_pred1_eq. by move=>x y H; inversion H. } { rewrite big_mkcond=>/=. by rewrite big1_eq. } } by rewrite /formalLC.pathApply in H. Qed. Module Exports. Notation "\B[ R ]( p )" := (elem R p) (at level 0). Notation pathAlgBasis := pathAlgBasis. Notation freePathAlgType := freePathAlgType. End Exports. End PAlgBasis. Export PAlgBasis.Exports. Module PAlgSub. Module Rmul. Section Def. Variable (R : comRingType) (Q : finQuiverType) (i : \V_Q). Definition inSet := fun x : (lmods.ringMod (pathAlgType R Q)) => x == (x*\B[R](\e_i)). Lemma subModule : GRing.submod_closed (subLmod.qualSubElem inSet). Proof. split=>[|a x y];rewrite qualifE !unfold_in. by rewrite GRing.mul0r eq_refl. rewrite -!(rwP eqP)=>Hx Hy; by rewrite Hx Hy GRing.mulrDl -!GRing.mulrA !PAlgBasis.idem. Qed. Canonical lmodType := subLmod.Pack subModule. End Def. Section Basis. Variable (R : comRingType) (Q : finQuiverType) (i : \V_Q). Definition elem (p : {p : pathType Q | (Path.tail p == i)}) : pathAlgType R Q := fun p' => if p' == (sval p) then 1 else 0. Lemma elem_inj : injective elem. Proof. move=> x y. destruct x as [x Hx], y as [y Hy]=>H. refine (eq_sig_hprop _ _ _ _). move=> x' p' q'; apply proof_irrelevance=>/=. rewrite /elem in H. simpl in H. assert (A := equal_f H x); rewrite eq_refl in A. case(x == y) as []eqn:E; [by apply (rwP eqP) in E|apply (rwP eqP) in A]. assert (P := GRing.oner_eq0 R). by rewrite A in P. Qed. Lemma elem_nondeg : non_degenerate elem. Proof. rewrite /elem=> x. apply (rwP negP); rewrite /not -(rwP eqP)=>H. destruct x as [x Hx]. assert (A := equal_f H x); rewrite eq_refl in A. rewrite /(GRing.zero _) in A; simpl in A. rewrite /formalLC.Zero in A. apply (rwP eqP) in A. by rewrite (GRing.oner_eq0 R) in A. Qed. (* Lemma elem_li : lmodBasis.LISet.axiom (lmodSet.Build elem_inj elem_nondeg). Proof. rewrite /elem=> f coef =>H finb; move:H. rewrite -(rwP eqP)=>H. Admitted. Lemma span : @inf_spanning _ _ (lmodSet.Build elem_inj elem_nondeg) (fun x => (@PAlgBasis.pathApplyLin R Q (sval x))). Proof. move=>el. Admitted. *) (* Lemma coef_one : lmodBasis.axiom_coef_one (infGenSet.Mixin span). Proof. move=>b; rewrite/infGenCoef=>/=; by rewrite/PAlgBasis.pathApply/elem !eq_refl. Qed. Lemma coef_zero : infBasis.axiom_coef_zero (infGenSet.Mixin span). Proof. move=>b1 b2; rewrite/infGenCoef=>/=; rewrite/PAlgBasis.pathApply/elem/not=>H. case (sval b1 == sval b2) as []eqn:E; [apply (rwP eqP) in E | rewrite eq_refl]. Admitted. *) (* by contradict(H (@eq_sig_hprop _ _ 5 b1 b2 E)). Qed. Lemma pathApplyLin_one : forall b, PAlgBasis.pathApplyLin R (sval b) (elem b) == 1. Proof. simpl; rewrite /PAlgBasis.pathApply/elem=>b/=; by rewrite !eq_refl. Qed. Lemma pathApplyLin_zero : forall b1 b2, b1 <> b2 -> PAlgBasis.pathApplyLin R (sval b1) (elem b2) == 0. Proof. rewrite /PAlgBasis.pathApply/elem=>b1 b2/=; rewrite /not=> H. case(b1 == b2) as []eqn:E=>//. by apply (rwP eqP) in E. rewrite /PAlgBasis.pathApply. Admitted. *) (* Definition basis : lmodBasisType _ := lmodBasis.Build elem_li span.*) End Basis. End Rmul. Close Scope ring_scope. Module Exports. Canonical Rmul.lmodType. (*Notation AlgModToRingMod := AlgModToRingMod.*) Notation Rmul := Rmul.lmodType. Notation "'[alg ' R Q '\e_' i ']'" := (Rmul.lmodType R Q i) (at level 0). End Exports. End PAlgSub. Export PAlgSub.Exports.
Require Import String List. Import ListNotations. From ASUB Require Import HOASParser monad. Import HOASNotation. Open Scope string. Open Scope hoas_scope. Definition test_5_3_sorts := [ "sort0" := Sort ; "sort1" := Sort ; "sort2" := Sort ; "sort3" := Sort ; "sort4" := Sort ; "sort5" := Sort ; "sort6" := Sort ; "sort7" := Sort ; "sort8" := Sort ; "sort9" := Sort ; "sort10" := Sort ; "sort11" := Sort ; "sort12" := Sort ; "sort13" := Sort ; "sort14" := Sort ]. Definition test_5_3_ctors := [ "cmix0" := "sort0" -> "sort1" -> "sort2" -> "sort3" -> "sort4" -> "sort0" ; "cmix1" := "sort0" -> "sort1" -> "sort2" -> "sort3" -> "sort4" -> "sort1" ; "cmix2" := "sort0" -> "sort1" -> "sort2" -> "sort3" -> "sort4" -> "sort2" ; "cmix3" := "sort0" -> "sort1" -> "sort2" -> "sort3" -> "sort4" -> "sort3" ; "cmix4" := "sort0" -> "sort1" -> "sort2" -> "sort3" -> "sort4" -> "sort4" ; "cmix5" := "sort5" -> "sort6" -> "sort7" -> "sort8" -> "sort9" -> "sort5" ; "cmix6" := "sort5" -> "sort6" -> "sort7" -> "sort8" -> "sort9" -> "sort6" ; "cmix7" := "sort5" -> "sort6" -> "sort7" -> "sort8" -> "sort9" -> "sort7" ; "cmix8" := "sort5" -> "sort6" -> "sort7" -> "sort8" -> "sort9" -> "sort8" ; "cmix9" := "sort5" -> "sort6" -> "sort7" -> "sort8" -> "sort9" -> "sort9" ; "cmix10" := "sort10" -> "sort11" -> "sort12" -> "sort13" -> "sort14" -> "sort10" ; "cmix11" := "sort10" -> "sort11" -> "sort12" -> "sort13" -> "sort14" -> "sort11" ; "cmix12" := "sort10" -> "sort11" -> "sort12" -> "sort13" -> "sort14" -> "sort12" ; "cmix13" := "sort10" -> "sort11" -> "sort12" -> "sort13" -> "sort14" -> "sort13" ; "cmix14" := "sort10" -> "sort11" -> "sort12" -> "sort13" -> "sort14" -> "sort14" ; "clam5" := {{"sort2" -> "sort3"}} -> "sort1" ; "clam10" := {{"sort9" -> "sort6"}} -> "sort7" ; "clam15" := {{"sort10" -> "sort11"}} -> "sort12" ].
[STATEMENT] lemma implies_subdist_sup: "(x \<leadsto> y) \<squnion> (x \<leadsto> z) \<le> x \<leadsto> (y \<squnion> z)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. x \<leadsto> y \<squnion> (x \<leadsto> z) \<le> x \<leadsto> (y \<squnion> z) [PROOF STEP] by (simp add: implies_isotone)
import GMLInit.Meta.Prelude import GMLInit.Logic.Cast import GMLInit.Logic.Congr import GMLInit.Logic.HEq import Lean open Lean open Lean.Meta open Lean.Parser.Tactic (location) open Lean.Elab open Lean.Elab.Tactic (Location expandLocation joinLocation) namespace Meta syntax termOrHole := term <|> hole <|> syntheticHole syntax termList := "[" (term <|> hole <|> syntheticHole),* ("|" (term <|> hole <|> syntheticHole))? "]" macro mods:declModifiers "lemma" n:declId sig:declSig val:declVal : command => `($mods:declModifiers theorem $n $sig $val) syntax (name := clean) "clean " (colGt tactic)? (colGe location)? : tactic macro_rules | `(tactic| clean $[$loc:location]?) => `(tactic| simp only [clean] $[$loc]?) | `(tactic| clean $tac $[$loc:location]?) => do let mut loc : Location := match loc with | some loc => expandLocation loc | none => .targets #[] false for stx in Lean.Syntax.filter tac fun stx => stx.getKind == ``location do loc := joinLocation loc (expandLocation stx) match loc with | .wildcard => `(tactic| $tac; simp only [clean] at *) | .targets hs true => let locs := hs.map Lean.TSyntax.mk `(tactic| $tac; simp only [clean] at $[$locs]* ⊢) | .targets hs false => let locs := hs.map Lean.TSyntax.mk `(tactic| $tac; simp only [clean] at $[$locs]*) syntax "elim_casts" (location)? : tactic set_option hygiene false in macro_rules | `(tactic| elim_casts $[$loc]?) => `(tactic| first | rw [←heq_iff_eq] $[$loc]?; simp only [elim_casts] $[$loc]?; rw [heq_iff_eq] $[$loc]? | simp only [elim_casts] $[$loc]?) macro "exfalso" : tactic => `(tactic| apply False.elim) macro "absurd " h:term : tactic => `(tactic| first | apply absurd _ $h | apply absurd $h) def Tactic.constr (mvarId : MVarId) : MetaM (List MVarId) := do mvarId.withContext do mvarId.checkNotAssigned `constr let target ← mvarId.getType' matchConstStruct target.getAppFn (fun _ => throwTacticEx `constr mvarId "target is not an inductive datatype with one constructor") fun _ us cval => do let ctor := mkAppN (Lean.mkConst cval.name us) target.getAppArgs[:cval.numParams] let ctorType ← inferType ctor let (mvars, _, _) ← forallMetaTelescopeReducing ctorType (some cval.numFields) mvarId.apply <| mkAppN ctor mvars elab "constr" : tactic => Tactic.withMainContext do let gs ← Tactic.constr (← Tactic.getMainGoal) Term.synthesizeSyntheticMVarsNoPostponing Tactic.replaceMainGoal gs def Tactic.left (mvarId : MVarId) : MetaM (List MVarId) := do mvarId.withContext do mvarId.checkNotAssigned `left let target ← mvarId.getType' matchConstInduct target.getAppFn (fun _ => throwTacticEx `left mvarId "target is not an inductive datatype") fun ival us => do match ival.ctors with | [ctor,_] => mvarId.apply (mkConst ctor us) | _ => throwTacticEx `left mvarId "target is not an inductive datatype with two constructors" elab "left" : tactic => Tactic.withMainContext do let gs ← Tactic.left (← Tactic.getMainGoal) Term.synthesizeSyntheticMVarsNoPostponing Tactic.replaceMainGoal gs def Tactic.right (mvarId : MVarId) : MetaM (List MVarId) := do mvarId.withContext do mvarId.checkNotAssigned `right let target ← mvarId.getType' matchConstInduct target.getAppFn (fun _ => throwTacticEx `right mvarId "target is not an inductive datatype") fun ival us => do match ival.ctors with | [_,ctor] => mvarId.apply (mkConst ctor us) | _ => throwTacticEx `right mvarId "target is not an inductive datatype with two constructors" elab "right" : tactic => Tactic.withMainContext do let gs ← Tactic.right (← Tactic.getMainGoal) Term.synthesizeSyntheticMVarsNoPostponing Tactic.replaceMainGoal gs end Meta
# qnoise R API # # mat - input data matrix # noiseType - # 0: Missing # 1: Inconsistency # 2: Outlier # 3: Error # 4: Duplicate # percentage - percentage of the noise seed # granularity - # 0: ROW # 1: CELL # model - tuple picking model # 0: Random # 1: Histogram # filteredColumn - the columns to be filtered, a list of string. # seed - seed for duplicatations [0 - 1] # distance - distance from active domain, a list of double. # constraints - string constraints # logFile - logFile inject <- function( mat, noiseType, percentage, granularity=0L, model=0L, filteredColumns=NULL, seed=0.0, distance=NULL, constraints=NULL, logFile=NULL ) { library(rJava) .jinit() .jaddClassPath("out/bin/qnoise.jar") .jaddClassPath("out/bin/guava-14.0.1.jar") .jaddClassPath("out/bin/opencsv-2.3.jar") .jaddClassPath("out/bin/javatuples-1.2.jar") # convert data mat[] <- as.character(mat) data <- .jarray(mat, dispatch=TRUE) data <- .jcast(data, "[[Ljava/lang/String;") # filtered columns if (is.null(filteredColumns)) { filteredColumns <- .jcast(.jnull(), "[Ljava/lang/String;") } else { filteredColumns <- .jarray(filteredColumns) } # distance if (is.null(distance)) { distance <- .jcast(.jnull(), "[D") } else { distance <- .jarray(distance) } # constraints if (is.null(constraints)) { constraints <- .jcast(.jnull(), "[Ljava/lang/String;") } else { constraints <- .jarray(constraints) } # logFile if (is.null(logFile)) { logFile <- .jcast(.jnull(), "java/lang/String") } # convert mat result <- .jcall( "qa.qcri.qnoise.QnoiseFacade", "[[Ljava/lang/String;", "inject", data, noiseType, granularity, percentage, model, filteredColumns, seed, distance, constraints, logFile ) return (lapply(result, .jevalArray)) }
# comment x <- 1
State Road 878 ( SR 878 ) , named the Snapper Creek Expressway or the Snapper Creek Tollway for its entire length , is a 2 @.@ 7 @-@ mile @-@ long ( 4 @.@ 3 km ) east – west electronic toll road south of Miami , Florida . The expressway is named for the nearby Snapper Creek which runs parallel to SR 878 . It acts as a spur route of the Don Shula Expressway ( SR 874 ) , providing access to U.S. Route 1 ( US 1 ) near South Miami and local access to the eastern Kendall area while bypassing the <unk> district . The road is maintained and tolled by the Miami @-@ Dade Expressway Authority ( MDX ) .
Formal statement is: lemma cball_empty [simp]: "e < 0 \<Longrightarrow> cball x e = {}" Informal statement is: If $e < 0$, then the closed ball of radius $e$ centered at $x$ is empty.
State Before: α : Type u β : Type v γ : Type ?u.42166 f : α → β ι : Sort u_1 t₁ : TopologicalSpace α t₂ : ι → TopologicalSpace β ⊢ Continuous f ↔ ∀ (i : ι), Continuous f State After: no goals Tactic: simp only [continuous_iff_coinduced_le, le_iInf_iff]
/- ****************** -/ /- *** PREDICATES *** -/ /- ****************** -/ /- Define a function called isOdd that takes an argument, n : ℕ, and returns a proposition that asserts that n is odd. The function will thus be a predicate on values of type ℕ. Hint: a number is odd if it's one more than an even number. -/ def isOdd (n :ℕ) : Prop := ∃ m : nat, 2 * m + 1 = n /- To test your predicate, use "example" to write and prove isOdd(15). -/ example : isOdd 15 := begin unfold isOdd, apply exists.intro 7, apply rfl, end /- Define isSmall : ℕ → Prop, to be a predicate that is true exactly when the argument, n, is such that n = 0 ∨ n = 1 ∨ n = 2 ∨ n = 3 ∨ n = 4 ∨ n = 5. (Don't try to rewrite this proposition as an inequality; just use it as is.) -/ def isSmall (n :ℕ) : Prop := n = 0 ∨ n = 1 ∨ n = 2 ∨ n = 3 ∨ n = 4 ∨ n = 5 /- Define a predicate, isBoth(n:ℕ) that is true exacly when n satisfies both the isOdd and isSmall predicates. Use isOdd and isSmall in your answer. -/ def isBoth (n : ℕ) : Prop := isOdd n ∧ isSmall n /- ******************* -/ /- *** DISJUNCTIONS ***-/ /- ******************* -/ /- Jane walks to school or she carries her lunch. In either case, she uses a bag. If she walks, she uses a bag for her books. If she carries her lunch, she uses a bag to carry her food. So if she walks, she uses a bag, and if she carries her lunch, she uses a bag. From the fact that she walks or carries her lunch, and from the added facts that in either case she uses a bag, we can conclude that she uses a bag. Using Walks, Carries, and Bag as names of propositions, write a Lean example that asserts the following proposition; then prove it. If Walks, Carries, and Bag are propositions, then if (Walks ∨ Carries) is true, and then if (Walks implies Bag) is true, and then if (Carries implies Bag) is true, then Bag is true. -/ example : ∀ (Walks Carries Bag : Prop), ((Walks ∨ Carries) ∧ (Walks → Bag) ∧ (Carries → Bag)) → Bag := begin assume W C B f, have f1 := f.1, cases f1 with w c, exact f.2.1 w, exact f.2.2 c, end /- Prove the following proposition. -/ example : ∀ (P Q R : Prop), (P ∧ Q) → (Q ∨ R) → (P ∨ R) := begin assume P Q R paq qar, exact or.inl paq.1, end /- ********************* -/ /- *** EXISTENTIALS *** -/ /- ********************* -/ /- Referring to the isBoth predicate you defined in question #1, state and prove the proposition that there *exists* a number, n, that satisfies isBoth. Remember that you can use the unfold tactic to expand the name of a predicate in a goal. Use "example" to state the proposition. -/ lemma pf3isOdd : isOdd 3 := begin unfold isOdd, apply exists.intro 1, apply rfl, end lemma pf3isSmall : isSmall 3 := begin unfold isSmall, apply or.intro_right, apply or.intro_right, apply or.intro_right, apply or.intro_left, apply rfl, end example : ∃ n : ℕ, isBoth n := begin unfold isBoth, apply exists.intro 3, have pfOdd := pf3isOdd, have pfSmall := pf3isSmall, exact and.intro pfOdd pfSmall, end /- Suppose that Heavy and Round are predicates on values of any type, T. Prove the proposition that if every t : T is Heavy (satisfies the Heavy predicate) and if there exists some t : T that is Round (satisfies the Round predicate) then there exists some t : T is both Heavy and Round (satisfies the conjunction of the two properties). -/ example : ∀ T : Type, ∀ (Heavy Round : T → Prop), (∀ t, Heavy t) → (∃ t, Round t) → (∃ t, Heavy t ∧ Round t) := begin assume T h r aht ert, apply exists.elim ert, assume x rt, apply exists.intro x, exact and.intro (aht x) rt, end
Program Ejemplo06 !Aqui probaremos la definicion y uso de una Subroutine ! que se inlcuye en el mismo archivo, fuera del programa Implicit None Call LeeX End Program Ejemplo06 Subroutine LeeX() Real(8) :: X Print *,'Por favor ingrese un Numero Real' Read *, X Print *, X End Subroutine LeeX
/- Copyright (c) 2015 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Author: Jeremy Avigad The power operation on monoids and groups. We separate this from group, because it depends on nat, which in turn depends on other parts of algebra. We have "pow a n" for natural number powers, and "gpow a i" for integer powers. The notation a^n is used for the first, but users can locally redefine it to gpow when needed. Note: power adopts the convention that 0^0=1. -/ import data.nat.basic data.int.basic variables {A : Type} structure has_pow_nat [class] (A : Type) := (pow_nat : A → nat → A) definition pow_nat {A : Type} [s : has_pow_nat A] : A → nat → A := has_pow_nat.pow_nat infix ` ^ ` := pow_nat structure has_pow_int [class] (A : Type) := (pow_int : A → int → A) definition pow_int {A : Type} [s : has_pow_int A] : A → int → A := has_pow_int.pow_int /- monoid -/ section monoid open nat variable [s : monoid A] include s definition monoid.pow (a : A) : ℕ → A | 0 := 1 | (n+1) := a * monoid.pow n definition monoid_has_pow_nat [instance] : has_pow_nat A := has_pow_nat.mk monoid.pow theorem pow_zero (a : A) : a^0 = 1 := rfl theorem pow_succ (a : A) (n : ℕ) : a^(succ n) = a * a^n := rfl theorem pow_one (a : A) : a^1 = a := !mul_one theorem pow_two (a : A) : a^2 = a * a := calc a^2 = a * (a * 1) : rfl ... = a * a : mul_one theorem pow_three (a : A) : a^3 = a * (a * a) := calc a^3 = a * (a * (a * 1)) : rfl ... = a * (a * a) : mul_one theorem pow_four (a : A) : a^4 = a * (a * (a * a)) := calc a^4 = a * a^3 : rfl ... = a * (a * (a * a)) : pow_three theorem pow_succ' (a : A) : ∀n, a^(succ n) = a^n * a | 0 := by rewrite [pow_succ, *pow_zero, one_mul, mul_one] | (succ n) := by rewrite [pow_succ, pow_succ' at {1}, pow_succ, mul.assoc] theorem one_pow : ∀ n : ℕ, 1^n = (1:A) | 0 := rfl | (succ n) := by rewrite [pow_succ, one_mul, one_pow] theorem pow_add (a : A) (m n : ℕ) : a^(m + n) = a^m * a^n := begin induction n with n ih, {krewrite [nat.add_zero, pow_zero, mul_one]}, rewrite [add_succ, *pow_succ', ih, mul.assoc] end theorem pow_mul (a : A) (m : ℕ) : ∀ n, a^(m * n) = (a^m)^n | 0 := by rewrite [nat.mul_zero, pow_zero] | (succ n) := by rewrite [nat.mul_succ, pow_add, pow_succ', pow_mul] theorem pow_comm (a : A) (m n : ℕ) : a^m * a^n = a^n * a^m := by rewrite [-*pow_add, add.comm] end monoid /- commutative monoid -/ section comm_monoid open nat variable [s : comm_monoid A] include s theorem mul_pow (a b : A) : ∀ n, (a * b)^n = a^n * b^n | 0 := by rewrite [*pow_zero, mul_one] | (succ n) := by rewrite [*pow_succ', mul_pow, *mul.assoc, mul.left_comm a] end comm_monoid section group variable [s : group A] include s section nat open nat theorem inv_pow (a : A) : ∀n, (a⁻¹)^n = (a^n)⁻¹ | 0 := by rewrite [*pow_zero, one_inv] | (succ n) := by rewrite [pow_succ, pow_succ', inv_pow, mul_inv] theorem pow_sub (a : A) {m n : ℕ} (H : m ≥ n) : a^(m - n) = a^m * (a^n)⁻¹ := have H1 : m - n + n = m, from nat.sub_add_cancel H, have H2 : a^(m - n) * a^n = a^m, by rewrite [-pow_add, H1], eq_mul_inv_of_mul_eq H2 theorem pow_inv_comm (a : A) : ∀m n, (a⁻¹)^m * a^n = a^n * (a⁻¹)^m | 0 n := by rewrite [*pow_zero, one_mul, mul_one] | m 0 := by rewrite [*pow_zero, one_mul, mul_one] | (succ m) (succ n) := by rewrite [pow_succ' at {1}, pow_succ at {1}, pow_succ', pow_succ, *mul.assoc, inv_mul_cancel_left, mul_inv_cancel_left, pow_inv_comm] end nat open int definition gpow (a : A) : ℤ → A | (of_nat n) := a^n | -[1+n] := (a^(nat.succ n))⁻¹ open nat private lemma gpow_add_aux (a : A) (m n : nat) : gpow a ((of_nat m) + -[1+n]) = gpow a (of_nat m) * gpow a (-[1+n]) := or.elim (nat.lt_or_ge m (nat.succ n)) (assume H : (m < nat.succ n), have H1 : (#nat nat.succ n - m > nat.zero), from nat.sub_pos_of_lt H, calc gpow a ((of_nat m) + -[1+n]) = gpow a (sub_nat_nat m (nat.succ n)) : rfl ... = gpow a (-[1+ nat.pred (nat.sub (nat.succ n) m)]) : {sub_nat_nat_of_lt H} ... = (a ^ (nat.succ (nat.pred (nat.sub (nat.succ n) m))))⁻¹ : rfl ... = (a ^ (nat.succ n) * (a ^ m)⁻¹)⁻¹ : by krewrite [succ_pred_of_pos H1, pow_sub a (nat.le_of_lt H)] ... = a ^ m * (a ^ (nat.succ n))⁻¹ : by rewrite [mul_inv, inv_inv] ... = gpow a (of_nat m) * gpow a (-[1+n]) : rfl) (assume H : (m ≥ nat.succ n), calc gpow a ((of_nat m) + -[1+n]) = gpow a (sub_nat_nat m (nat.succ n)) : rfl ... = gpow a (#nat m - nat.succ n) : {sub_nat_nat_of_ge H} ... = a ^ m * (a ^ (nat.succ n))⁻¹ : pow_sub a H ... = gpow a (of_nat m) * gpow a (-[1+n]) : rfl) theorem gpow_add (a : A) : ∀i j : int, gpow a (i + j) = gpow a i * gpow a j | (of_nat m) (of_nat n) := !pow_add | (of_nat m) -[1+n] := !gpow_add_aux | -[1+m] (of_nat n) := by rewrite [add.comm, gpow_add_aux, ↑gpow, -*inv_pow, pow_inv_comm] | -[1+m] -[1+n] := calc gpow a (-[1+m] + -[1+n]) = (a^(#nat nat.succ m + nat.succ n))⁻¹ : rfl ... = (a^(nat.succ m))⁻¹ * (a^(nat.succ n))⁻¹ : by rewrite [pow_add, pow_comm, mul_inv] ... = gpow a (-[1+m]) * gpow a (-[1+n]) : rfl theorem gpow_comm (a : A) (i j : ℤ) : gpow a i * gpow a j = gpow a j * gpow a i := by rewrite [-*gpow_add, add.comm] end group section ordered_ring open nat variable [s : linear_ordered_ring A] include s theorem pow_pos {a : A} (H : a > 0) (n : ℕ) : a ^ n > 0 := begin induction n, krewrite pow_zero, apply zero_lt_one, rewrite pow_succ', apply mul_pos, apply v_0, apply H end theorem pow_ge_one_of_ge_one {a : A} (H : a ≥ 1) (n : ℕ) : a ^ n ≥ 1 := begin induction n, krewrite pow_zero, apply le.refl, rewrite [pow_succ', -mul_one 1], apply mul_le_mul v_0 H zero_le_one, apply le_of_lt, apply pow_pos, apply gt_of_ge_of_gt H zero_lt_one end theorem pow_two_add (n : ℕ) : (2:A)^n + 2^n = 2^(succ n) := by rewrite [pow_succ', -one_add_one_eq_two, left_distrib, *mul_one] end ordered_ring /- additive monoid -/ section add_monoid variable [s : add_monoid A] include s local attribute add_monoid.to_monoid [trans_instance] open nat definition nmul : ℕ → A → A := λ n a, a^n infix [priority algebra.prio] `⬝` := nmul theorem zero_nmul (a : A) : (0:ℕ) ⬝ a = 0 := pow_zero a theorem succ_nmul (n : ℕ) (a : A) : nmul (succ n) a = a + (nmul n a) := pow_succ a n theorem succ_nmul' (n : ℕ) (a : A) : succ n ⬝ a = nmul n a + a := pow_succ' a n theorem nmul_zero (n : ℕ) : n ⬝ 0 = (0:A) := one_pow n theorem one_nmul (a : A) : 1 ⬝ a = a := pow_one a theorem add_nmul (m n : ℕ) (a : A) : (m + n) ⬝ a = (m ⬝ a) + (n ⬝ a) := pow_add a m n theorem mul_nmul (m n : ℕ) (a : A) : (m * n) ⬝ a = m ⬝ (n ⬝ a) := eq.subst (mul.comm n m) (pow_mul a n m) theorem nmul_comm (m n : ℕ) (a : A) : (m ⬝ a) + (n ⬝ a) = (n ⬝ a) + (m ⬝ a) := pow_comm a m n end add_monoid /- additive commutative monoid -/ section add_comm_monoid open nat variable [s : add_comm_monoid A] include s local attribute add_comm_monoid.to_comm_monoid [trans_instance] theorem nmul_add (n : ℕ) (a b : A) : n ⬝ (a + b) = (n ⬝ a) + (n ⬝ b) := mul_pow a b n end add_comm_monoid section add_group variable [s : add_group A] include s local attribute add_group.to_group [trans_instance] section nat open nat theorem nmul_neg (n : ℕ) (a : A) : n ⬝ (-a) = -(n ⬝ a) := inv_pow a n theorem sub_nmul {m n : ℕ} (a : A) (H : m ≥ n) : (m - n) ⬝ a = (m ⬝ a) + -(n ⬝ a) := pow_sub a H theorem nmul_neg_comm (m n : ℕ) (a : A) : (m ⬝ (-a)) + (n ⬝ a) = (n ⬝ a) + (m ⬝ (-a)) := pow_inv_comm a m n end nat open int definition imul : ℤ → A → A := λ i a, gpow a i theorem add_imul (i j : ℤ) (a : A) : imul (i + j) a = imul i a + imul j a := gpow_add a i j theorem imul_comm (i j : ℤ) (a : A) : imul i a + imul j a = imul j a + imul i a := gpow_comm a i j end add_group
##### Numeric simplification """ simplify(x; rewriter=default_simplifier(), threaded=false, polynorm=true, thread_subtree_cutoff=100) Simplify an expression (`x`) by applying `rewriter` until there are no changes. `polynorm=true` applies `polynormalize` in the beginning of each fixpoint iteration. """ function simplify(x; polynorm=false, threaded=false, thread_subtree_cutoff=100, rewriter=nothing) f = if rewriter === nothing if threaded threaded_simplifier(thread_subtree_cutoff) elseif polynorm serial_polynormal_simplifier else serial_simplifier end else Fixpoint(rewriter) end PassThrough(f)(x) end Base.@deprecate simplify(x, ctx; kwargs...) simplify(x; rewriter=ctx, kwargs...) """ substitute(expr, dict) substitute any subexpression that matches a key in `dict` with the corresponding value. """ function substitute(expr, dict; fold=true) haskey(dict, expr) && return dict[expr] if istree(expr) if fold canfold=true args = map(arguments(expr)) do x x′ = substitute(x, dict; fold=fold) canfold = canfold && !(x′ isa Symbolic) x′ end canfold && return operation(expr)(args...) args else args = map(x->substitute(x, dict), arguments(expr)) end similarterm(expr, operation(expr), args) else expr end end
[GOAL] α : Type u_1 ⊢ LeftInverse toList ofList [PROOFSTEP] intro xs [GOAL] α : Type u_1 xs : List α ⊢ toList (ofList xs) = xs [PROOFSTEP] induction xs [GOAL] case nil α : Type u_1 ⊢ toList (ofList []) = [] [PROOFSTEP] rfl [GOAL] case cons α : Type u_1 head✝ : α tail✝ : List α tail_ih✝ : toList (ofList tail✝) = tail✝ ⊢ toList (ofList (head✝ :: tail✝)) = head✝ :: tail✝ [PROOFSTEP] simpa [ofList, toList] [GOAL] α : Type u_1 ⊢ Function.RightInverse toList ofList [PROOFSTEP] intro xs [GOAL] α : Type u_1 xs : LazyList α ⊢ ofList (toList xs) = xs [PROOFSTEP] induction' xs using LazyList.rec with _ _ _ _ ih [GOAL] case nil α : Type u_1 ⊢ ofList (toList nil) = nil [PROOFSTEP] rfl [GOAL] case cons α : Type u_1 xs : LazyList α hd✝ : α tl✝ : Thunk (LazyList α) tl_ih✝ : ?m.1024 tl✝ ⊢ ofList (toList (cons hd✝ tl✝)) = cons hd✝ tl✝ [PROOFSTEP] simpa only [toList, ofList, cons.injEq, true_and] [GOAL] case mk α : Type u_1 xs : LazyList α fn✝ : Unit → LazyList α ih : ∀ (a : Unit), ofList (toList (fn✝ a)) = fn✝ a ⊢ { fn := fun x => ofList (toList (Thunk.get { fn := fn✝ })) } = { fn := fn✝ } [PROOFSTEP] rw [Thunk.get, ih] [GOAL] α : Type u inst✝ : DecidableEq α x : α xs : Thunk (LazyList α) y : α ys : Thunk (LazyList α) h : x = y h2 : ¬Thunk.get xs = Thunk.get ys ⊢ Decidable (cons x xs = cons y ys) [PROOFSTEP] apply isFalse [GOAL] case h α : Type u inst✝ : DecidableEq α x : α xs : Thunk (LazyList α) y : α ys : Thunk (LazyList α) h : x = y h2 : ¬Thunk.get xs = Thunk.get ys ⊢ ¬cons x xs = cons y ys [PROOFSTEP] simp only [cons.injEq, not_and] [GOAL] case h α : Type u inst✝ : DecidableEq α x : α xs : Thunk (LazyList α) y : α ys : Thunk (LazyList α) h : x = y h2 : ¬Thunk.get xs = Thunk.get ys ⊢ x = y → ¬xs = ys [PROOFSTEP] intro _ xs_ys [GOAL] case h α : Type u inst✝ : DecidableEq α x : α xs : Thunk (LazyList α) y : α ys : Thunk (LazyList α) h : x = y h2 : ¬Thunk.get xs = Thunk.get ys a✝ : x = y xs_ys : xs = ys ⊢ False [PROOFSTEP] apply h2 [GOAL] case h α : Type u inst✝ : DecidableEq α x : α xs : Thunk (LazyList α) y : α ys : Thunk (LazyList α) h : x = y h2 : ¬Thunk.get xs = Thunk.get ys a✝ : x = y xs_ys : xs = ys ⊢ Thunk.get xs = Thunk.get ys [PROOFSTEP] rw [xs_ys] [GOAL] α : Type u inst✝ : DecidableEq α x : α xs : Thunk (LazyList α) y : α ys : Thunk (LazyList α) h : x = y h2 : Thunk.get xs = Thunk.get ys ⊢ Decidable (cons x xs = cons y ys) [PROOFSTEP] apply isTrue [GOAL] case h α : Type u inst✝ : DecidableEq α x : α xs : Thunk (LazyList α) y : α ys : Thunk (LazyList α) h : x = y h2 : Thunk.get xs = Thunk.get ys ⊢ cons x xs = cons y ys [PROOFSTEP] congr [GOAL] case h.e_tl α : Type u inst✝ : DecidableEq α x : α xs : Thunk (LazyList α) y : α ys : Thunk (LazyList α) h : x = y h2 : Thunk.get xs = Thunk.get ys ⊢ xs = ys [PROOFSTEP] ext [GOAL] case h.e_tl.eq α : Type u inst✝ : DecidableEq α x : α xs : Thunk (LazyList α) y : α ys : Thunk (LazyList α) h : x = y h2 : Thunk.get xs = Thunk.get ys ⊢ Thunk.get xs = Thunk.get ys [PROOFSTEP] exact h2 [GOAL] α : Type u inst✝ : DecidableEq α x : α xs : Thunk (LazyList α) y : α ys : Thunk (LazyList α) h : ¬x = y ⊢ Decidable (cons x xs = cons y ys) [PROOFSTEP] apply isFalse [GOAL] case h α : Type u inst✝ : DecidableEq α x : α xs : Thunk (LazyList α) y : α ys : Thunk (LazyList α) h : ¬x = y ⊢ ¬cons x xs = cons y ys [PROOFSTEP] simp only [cons.injEq, not_and] [GOAL] case h α : Type u inst✝ : DecidableEq α x : α xs : Thunk (LazyList α) y : α ys : Thunk (LazyList α) h : ¬x = y ⊢ x = y → ¬xs = ys [PROOFSTEP] intro [GOAL] case h α : Type u inst✝ : DecidableEq α x : α xs : Thunk (LazyList α) y : α ys : Thunk (LazyList α) h : ¬x = y a✝ : x = y ⊢ ¬xs = ys [PROOFSTEP] contradiction [GOAL] α : Type u inst✝ : DecidableEq α hd✝ : α tl✝ : Thunk (LazyList α) ⊢ Decidable (nil = cons hd✝ tl✝) [PROOFSTEP] apply isFalse [GOAL] case h α : Type u inst✝ : DecidableEq α hd✝ : α tl✝ : Thunk (LazyList α) ⊢ ¬nil = cons hd✝ tl✝ [PROOFSTEP] simp [GOAL] α : Type u inst✝ : DecidableEq α hd✝ : α tl✝ : Thunk (LazyList α) ⊢ Decidable (cons hd✝ tl✝ = nil) [PROOFSTEP] apply isFalse [GOAL] case h α : Type u inst✝ : DecidableEq α hd✝ : α tl✝ : Thunk (LazyList α) ⊢ ¬cons hd✝ tl✝ = nil [PROOFSTEP] simp [GOAL] ⊢ LawfulTraversable LazyList [PROOFSTEP] apply Equiv.isLawfulTraversable' listEquivLazyList [GOAL] case h₀ ⊢ ∀ {α β : Type ?u.19468} (f : α → β), Functor.map f = Equiv.map listEquivLazyList f [PROOFSTEP] intros [GOAL] case h₁ ⊢ ∀ {α β : Type ?u.19468} (f : β), Functor.mapConst f = (Equiv.map listEquivLazyList ∘ const α) f [PROOFSTEP] intros [GOAL] case h₂ ⊢ ∀ {F : Type ?u.19468 → Type ?u.19468} [inst : Applicative F] [inst_1 : LawfulApplicative F] {α β : Type ?u.19468} (f : α → F β), traverse f = Equiv.traverse listEquivLazyList f [PROOFSTEP] intros [GOAL] case h₀ α✝ β✝ : Type ?u.19468 f✝ : α✝ → β✝ ⊢ Functor.map f✝ = Equiv.map listEquivLazyList f✝ [PROOFSTEP] ext [GOAL] case h₁ α✝ β✝ : Type ?u.19468 f✝ : β✝ ⊢ Functor.mapConst f✝ = (Equiv.map listEquivLazyList ∘ const α✝) f✝ [PROOFSTEP] ext [GOAL] case h₂ F✝ : Type ?u.19468 → Type ?u.19468 inst✝¹ : Applicative F✝ inst✝ : LawfulApplicative F✝ α✝ β✝ : Type ?u.19468 f✝ : α✝ → F✝ β✝ ⊢ traverse f✝ = Equiv.traverse listEquivLazyList f✝ [PROOFSTEP] ext [GOAL] case h₀.h α✝ β✝ : Type ?u.19468 f✝ : α✝ → β✝ x✝ : LazyList α✝ ⊢ f✝ <$> x✝ = Equiv.map listEquivLazyList f✝ x✝ [PROOFSTEP] rename_i f xs [GOAL] case h₁.h α✝ β✝ : Type ?u.19468 f✝ : β✝ x✝ : LazyList α✝ ⊢ Functor.mapConst f✝ x✝ = (Equiv.map listEquivLazyList ∘ const α✝) f✝ x✝ [PROOFSTEP] rename_i f xs [GOAL] case h₂.h F✝ : Type ?u.19468 → Type ?u.19468 inst✝¹ : Applicative F✝ inst✝ : LawfulApplicative F✝ α✝ β✝ : Type ?u.19468 f✝ : α✝ → F✝ β✝ x✝ : LazyList α✝ ⊢ traverse f✝ x✝ = Equiv.traverse listEquivLazyList f✝ x✝ [PROOFSTEP] rename_i f xs [GOAL] case h₀.h α✝ β✝ : Type ?u.19468 f : α✝ → β✝ xs : LazyList α✝ ⊢ f <$> xs = Equiv.map listEquivLazyList f xs [PROOFSTEP] induction' xs using LazyList.rec with _ _ _ _ ih [GOAL] case h₀.h.nil α✝ β✝ : Type ?u.19468 f : α✝ → β✝ ⊢ f <$> nil = Equiv.map listEquivLazyList f nil [PROOFSTEP] rfl [GOAL] case h₀.h.cons α✝ β✝ : Type ?u.19468 f : α✝ → β✝ xs : LazyList α✝ hd✝ : α✝ tl✝ : Thunk (LazyList α✝) tl_ih✝ : ?m.19696 tl✝ ⊢ f <$> cons hd✝ tl✝ = Equiv.map listEquivLazyList f (cons hd✝ tl✝) [PROOFSTEP] simpa only [Equiv.map, Functor.map, listEquivLazyList, Equiv.coe_fn_symm_mk, Equiv.coe_fn_mk, LazyList.traverse, Seq.seq, toList, ofList, cons.injEq, true_and] [GOAL] case h₀.h.mk α✝ β✝ : Type ?u.19468 f : α✝ → β✝ xs : LazyList α✝ fn✝ : Unit → LazyList α✝ ih : ∀ (a : Unit), f <$> fn✝ a = Equiv.map listEquivLazyList f (fn✝ a) ⊢ Thunk.pure (LazyList.traverse f (Thunk.get { fn := fn✝ })) = { fn := fun x => ofList (List.map f (toList (Thunk.get { fn := fn✝ }))) } [PROOFSTEP] ext [GOAL] case h₀.h.mk.eq α✝ β✝ : Type ?u.19468 f : α✝ → β✝ xs : LazyList α✝ fn✝ : Unit → LazyList α✝ ih : ∀ (a : Unit), f <$> fn✝ a = Equiv.map listEquivLazyList f (fn✝ a) ⊢ Thunk.get (Thunk.pure (LazyList.traverse f (Thunk.get { fn := fn✝ }))) = Thunk.get { fn := fun x => ofList (List.map f (toList (Thunk.get { fn := fn✝ }))) } [PROOFSTEP] apply ih [GOAL] case h₁.h α✝ β✝ : Type ?u.19468 f : β✝ xs : LazyList α✝ ⊢ Functor.mapConst f xs = (Equiv.map listEquivLazyList ∘ const α✝) f xs [PROOFSTEP] simp only [Equiv.map, listEquivLazyList, Equiv.coe_fn_symm_mk, Equiv.coe_fn_mk, comp, Functor.mapConst] [GOAL] case h₁.h α✝ β✝ : Type ?u.19468 f : β✝ xs : LazyList α✝ ⊢ LazyList.traverse (const α✝ f) xs = ofList (const α✝ f <$> toList xs) [PROOFSTEP] induction' xs using LazyList.rec with _ _ _ _ ih [GOAL] case h₁.h.nil α✝ β✝ : Type ?u.19468 f : β✝ ⊢ LazyList.traverse (const α✝ f) nil = ofList (const α✝ f <$> toList nil) [PROOFSTEP] rfl [GOAL] case h₁.h.cons α✝ β✝ : Type ?u.19468 f : β✝ xs : LazyList α✝ hd✝ : α✝ tl✝ : Thunk (LazyList α✝) tl_ih✝ : ?m.21260 tl✝ ⊢ LazyList.traverse (const α✝ f) (cons hd✝ tl✝) = ofList (const α✝ f <$> toList (cons hd✝ tl✝)) [PROOFSTEP] simpa only [toList, ofList, LazyList.traverse, Seq.seq, Functor.map, cons.injEq, true_and] [GOAL] case h₁.h.mk α✝ β✝ : Type ?u.19468 f : β✝ xs : LazyList α✝ fn✝ : Unit → LazyList α✝ ih : ∀ (a : Unit), LazyList.traverse (const α✝ f) (fn✝ a) = ofList (const α✝ f <$> toList (fn✝ a)) ⊢ Thunk.pure (LazyList.traverse (const α✝ f) (Thunk.get { fn := fn✝ })) = { fn := fun x => ofList (List.map (const α✝ f) (toList (Thunk.get { fn := fn✝ }))) } [PROOFSTEP] congr [GOAL] case h₁.h.mk.e_a α✝ β✝ : Type ?u.19468 f : β✝ xs : LazyList α✝ fn✝ : Unit → LazyList α✝ ih : ∀ (a : Unit), LazyList.traverse (const α✝ f) (fn✝ a) = ofList (const α✝ f <$> toList (fn✝ a)) ⊢ LazyList.traverse (const α✝ f) (Thunk.get { fn := fn✝ }) = ofList (List.map (const α✝ f) (toList (Thunk.get { fn := fn✝ }))) [PROOFSTEP] apply ih [GOAL] case h₂.h F✝ : Type ?u.19468 → Type ?u.19468 inst✝¹ : Applicative F✝ inst✝ : LawfulApplicative F✝ α✝ β✝ : Type ?u.19468 f : α✝ → F✝ β✝ xs : LazyList α✝ ⊢ traverse f xs = Equiv.traverse listEquivLazyList f xs [PROOFSTEP] simp only [traverse, Equiv.traverse, listEquivLazyList, Equiv.coe_fn_mk, Equiv.coe_fn_symm_mk] [GOAL] case h₂.h F✝ : Type ?u.19468 → Type ?u.19468 inst✝¹ : Applicative F✝ inst✝ : LawfulApplicative F✝ α✝ β✝ : Type ?u.19468 f : α✝ → F✝ β✝ xs : LazyList α✝ ⊢ LazyList.traverse f xs = ofList <$> List.traverse f (toList xs) [PROOFSTEP] induction' xs using LazyList.rec with _ tl ih _ ih [GOAL] case h₂.h.nil F✝ : Type ?u.19468 → Type ?u.19468 inst✝¹ : Applicative F✝ inst✝ : LawfulApplicative F✝ α✝ β✝ : Type ?u.19468 f : α✝ → F✝ β✝ ⊢ LazyList.traverse f nil = ofList <$> List.traverse f (toList nil) [PROOFSTEP] simp only [List.traverse, map_pure] [GOAL] case h₂.h.nil F✝ : Type ?u.19468 → Type ?u.19468 inst✝¹ : Applicative F✝ inst✝ : LawfulApplicative F✝ α✝ β✝ : Type ?u.19468 f : α✝ → F✝ β✝ ⊢ LazyList.traverse f nil = pure (ofList []) [PROOFSTEP] rfl [GOAL] case h₂.h.cons F✝ : Type ?u.19468 → Type ?u.19468 inst✝¹ : Applicative F✝ inst✝ : LawfulApplicative F✝ α✝ β✝ : Type ?u.19468 f : α✝ → F✝ β✝ xs : LazyList α✝ hd✝ : α✝ tl : Thunk (LazyList α✝) ih : ?m.22684 tl ⊢ LazyList.traverse f (cons hd✝ tl) = ofList <$> List.traverse f (toList (cons hd✝ tl)) [PROOFSTEP] have : tl.get.traverse f = ofList <$> tl.get.toList.traverse f := ih [GOAL] case h₂.h.cons F✝ : Type ?u.19468 → Type ?u.19468 inst✝¹ : Applicative F✝ inst✝ : LawfulApplicative F✝ α✝ β✝ : Type ?u.19468 f : α✝ → F✝ β✝ xs : LazyList α✝ hd✝ : α✝ tl : Thunk (LazyList α✝) ih this : LazyList.traverse f (Thunk.get tl) = ofList <$> List.traverse f (toList (Thunk.get tl)) ⊢ LazyList.traverse f (cons hd✝ tl) = ofList <$> List.traverse f (toList (cons hd✝ tl)) [PROOFSTEP] simp only [traverse._eq_2, ih, Functor.map_map, seq_map_assoc, toList, List.traverse, map_seq] [GOAL] case h₂.h.cons F✝ : Type ?u.19468 → Type ?u.19468 inst✝¹ : Applicative F✝ inst✝ : LawfulApplicative F✝ α✝ β✝ : Type ?u.19468 f : α✝ → F✝ β✝ xs : LazyList α✝ hd✝ : α✝ tl : Thunk (LazyList α✝) ih this : LazyList.traverse f (Thunk.get tl) = ofList <$> List.traverse f (toList (Thunk.get tl)) ⊢ (Seq.seq (((fun x => x ∘ Thunk.pure ∘ ofList) ∘ cons) <$> f hd✝) fun x => List.traverse f (toList (Thunk.get tl))) = Seq.seq (((fun x => ofList ∘ x) ∘ List.cons) <$> f hd✝) fun x => List.traverse f (toList (Thunk.get tl)) [PROOFSTEP] rfl [GOAL] case h₂.h.mk F✝ : Type ?u.19468 → Type ?u.19468 inst✝¹ : Applicative F✝ inst✝ : LawfulApplicative F✝ α✝ β✝ : Type ?u.19468 f : α✝ → F✝ β✝ xs : LazyList α✝ fn✝ : Unit → LazyList α✝ ih : ∀ (a : Unit), LazyList.traverse f (fn✝ a) = ofList <$> List.traverse f (toList (fn✝ a)) ⊢ LazyList.traverse f (Thunk.get { fn := fn✝ }) = ofList <$> List.traverse f (toList (Thunk.get { fn := fn✝ })) [PROOFSTEP] apply ih [GOAL] α : Type u_1 xs : LazyList α ⊢ append xs (Thunk.pure nil) = xs [PROOFSTEP] induction' xs using LazyList.rec with _ _ _ _ ih [GOAL] case nil α : Type u_1 ⊢ append nil (Thunk.pure nil) = nil [PROOFSTEP] rfl [GOAL] case cons α : Type u_1 xs : LazyList α hd✝ : α tl✝ : Thunk (LazyList α) tl_ih✝ : ?m.62141 tl✝ ⊢ append (cons hd✝ tl✝) (Thunk.pure nil) = cons hd✝ tl✝ [PROOFSTEP] simpa only [append, cons.injEq, true_and] [GOAL] case mk α : Type u_1 xs : LazyList α fn✝ : Unit → LazyList α ih : ∀ (a : Unit), append (fn✝ a) (Thunk.pure nil) = fn✝ a ⊢ { fn := fun x => append (Thunk.get { fn := fn✝ }) (Thunk.pure nil) } = { fn := fn✝ } [PROOFSTEP] ext [GOAL] case mk.eq α : Type u_1 xs : LazyList α fn✝ : Unit → LazyList α ih : ∀ (a : Unit), append (fn✝ a) (Thunk.pure nil) = fn✝ a ⊢ Thunk.get { fn := fun x => append (Thunk.get { fn := fn✝ }) (Thunk.pure nil) } = Thunk.get { fn := fn✝ } [PROOFSTEP] apply ih [GOAL] α : Type u_1 xs ys zs : LazyList α ⊢ append (append xs { fn := fun x => ys }) { fn := fun x => zs } = append xs { fn := fun x => append ys { fn := fun x => zs } } [PROOFSTEP] induction' xs using LazyList.rec with _ _ _ _ ih [GOAL] case nil α : Type u_1 ys zs : LazyList α ⊢ append (append nil { fn := fun x => ys }) { fn := fun x => zs } = append nil { fn := fun x => append ys { fn := fun x => zs } } [PROOFSTEP] rfl [GOAL] case cons α : Type u_1 xs ys zs : LazyList α hd✝ : α tl✝ : Thunk (LazyList α) tl_ih✝ : ?m.65384 tl✝ ⊢ append (append (cons hd✝ tl✝) { fn := fun x => ys }) { fn := fun x => zs } = append (cons hd✝ tl✝) { fn := fun x => append ys { fn := fun x => zs } } [PROOFSTEP] simpa only [append, cons.injEq, true_and] [GOAL] case mk α : Type u_1 xs ys zs : LazyList α fn✝ : Unit → LazyList α ih : ∀ (a : Unit), append (append (fn✝ a) { fn := fun x => ys }) { fn := fun x => zs } = append (fn✝ a) { fn := fun x => append ys { fn := fun x => zs } } ⊢ { fn := fun x => append (Thunk.get { fn := fun x => append (Thunk.get { fn := fn✝ }) { fn := fun x => ys } }) { fn := fun x => zs } } = { fn := fun x => append (Thunk.get { fn := fn✝ }) { fn := fun x => append ys { fn := fun x => zs } } } [PROOFSTEP] ext [GOAL] case mk.eq α : Type u_1 xs ys zs : LazyList α fn✝ : Unit → LazyList α ih : ∀ (a : Unit), append (append (fn✝ a) { fn := fun x => ys }) { fn := fun x => zs } = append (fn✝ a) { fn := fun x => append ys { fn := fun x => zs } } ⊢ Thunk.get { fn := fun x => append (Thunk.get { fn := fun x => append (Thunk.get { fn := fn✝ }) { fn := fun x => ys } }) { fn := fun x => zs } } = Thunk.get { fn := fun x => append (Thunk.get { fn := fn✝ }) { fn := fun x => append ys { fn := fun x => zs } } } [PROOFSTEP] apply ih [GOAL] α : Type u_1 β : Type u_2 xs : LazyList α ys : Thunk (LazyList α) f : α → LazyList β ⊢ LazyList.bind (append xs ys) f = append (LazyList.bind xs f) { fn := fun x => LazyList.bind (Thunk.get ys) f } [PROOFSTEP] match xs with | LazyList.nil => rfl | LazyList.cons x xs => simp only [append, Thunk.get, LazyList.bind] have := append_bind xs.get ys f simp only [Thunk.get] at this rw [this, append_assoc] [GOAL] α : Type u_1 β : Type u_2 xs : LazyList α ys : Thunk (LazyList α) f : α → LazyList β ⊢ LazyList.bind (append nil ys) f = append (LazyList.bind nil f) { fn := fun x => LazyList.bind (Thunk.get ys) f } [PROOFSTEP] rfl [GOAL] α : Type u_1 β : Type u_2 xs✝ : LazyList α ys : Thunk (LazyList α) f : α → LazyList β x : α xs : Thunk (LazyList α) ⊢ LazyList.bind (append (cons x xs) ys) f = append (LazyList.bind (cons x xs) f) { fn := fun x => LazyList.bind (Thunk.get ys) f } [PROOFSTEP] simp only [append, Thunk.get, LazyList.bind] [GOAL] α : Type u_1 β : Type u_2 xs✝ : LazyList α ys : Thunk (LazyList α) f : α → LazyList β x : α xs : Thunk (LazyList α) ⊢ append (f x) { fn := fun x => LazyList.bind (append (Thunk.fn xs ()) ys) f } = append (append (f x) { fn := fun x => LazyList.bind (Thunk.fn xs ()) f }) { fn := fun x => LazyList.bind (Thunk.fn ys ()) f } [PROOFSTEP] have := append_bind xs.get ys f [GOAL] α : Type u_1 β : Type u_2 xs✝ : LazyList α ys : Thunk (LazyList α) f : α → LazyList β x : α xs : Thunk (LazyList α) this : LazyList.bind (append (Thunk.get xs) ys) f = append (LazyList.bind (Thunk.get xs) f) { fn := fun x => LazyList.bind (Thunk.get ys) f } ⊢ append (f x) { fn := fun x => LazyList.bind (append (Thunk.fn xs ()) ys) f } = append (append (f x) { fn := fun x => LazyList.bind (Thunk.fn xs ()) f }) { fn := fun x => LazyList.bind (Thunk.fn ys ()) f } [PROOFSTEP] simp only [Thunk.get] at this [GOAL] α : Type u_1 β : Type u_2 xs✝ : LazyList α ys : Thunk (LazyList α) f : α → LazyList β x : α xs : Thunk (LazyList α) this : LazyList.bind (append (Thunk.fn xs ()) ys) f = append (LazyList.bind (Thunk.fn xs ()) f) { fn := fun x => LazyList.bind (Thunk.fn ys ()) f } ⊢ append (f x) { fn := fun x => LazyList.bind (append (Thunk.fn xs ()) ys) f } = append (append (f x) { fn := fun x => LazyList.bind (Thunk.fn xs ()) f }) { fn := fun x => LazyList.bind (Thunk.fn ys ()) f } [PROOFSTEP] rw [this, append_assoc] [GOAL] ⊢ ∀ {α : Type ?u.75696} (x : LazyList α), id <$> x = x [PROOFSTEP] intro _ xs [GOAL] α✝ : Type ?u.75696 xs : LazyList α✝ ⊢ id <$> xs = xs [PROOFSTEP] induction' xs using LazyList.rec with _ _ _ _ ih [GOAL] case nil α✝ : Type ?u.75696 ⊢ id <$> nil = nil [PROOFSTEP] rfl [GOAL] case cons α✝ : Type ?u.75696 xs : LazyList α✝ hd✝ : α✝ tl✝ : Thunk (LazyList α✝) tl_ih✝ : ?m.75815 tl✝ ⊢ id <$> cons hd✝ tl✝ = cons hd✝ tl✝ [PROOFSTEP] simpa only [Functor.map, traverse._eq_2, id_eq, Id.map_eq, Seq.seq, cons.injEq, true_and] [GOAL] case mk α✝ : Type ?u.75696 xs : LazyList α✝ fn✝ : Unit → LazyList α✝ ih : ∀ (a : Unit), id <$> fn✝ a = fn✝ a ⊢ Thunk.pure (LazyList.traverse id (Thunk.get { fn := fn✝ })) = { fn := fn✝ } [PROOFSTEP] ext [GOAL] case mk.eq α✝ : Type ?u.75696 xs : LazyList α✝ fn✝ : Unit → LazyList α✝ ih : ∀ (a : Unit), id <$> fn✝ a = fn✝ a ⊢ Thunk.get (Thunk.pure (LazyList.traverse id (Thunk.get { fn := fn✝ }))) = Thunk.get { fn := fn✝ } [PROOFSTEP] apply ih [GOAL] ⊢ ∀ {α β : Type ?u.75696} (x : α) (f : α → LazyList β), pure x >>= f = f x [PROOFSTEP] intros [GOAL] α✝ β✝ : Type ?u.75696 x✝ : α✝ f✝ : α✝ → LazyList β✝ ⊢ pure x✝ >>= f✝ = f✝ x✝ [PROOFSTEP] simp only [bind, pure, singleton, LazyList.bind] [GOAL] α✝ β✝ : Type ?u.75696 x✝ : α✝ f✝ : α✝ → LazyList β✝ ⊢ append (f✝ x✝) { fn := fun x => LazyList.bind (Thunk.get (Thunk.pure nil)) f✝ } = f✝ x✝ [PROOFSTEP] apply append_nil [GOAL] ⊢ ∀ {α β γ : Type ?u.75696} (x : LazyList α) (f : α → LazyList β) (g : β → LazyList γ), x >>= f >>= g = x >>= fun x => f x >>= g [PROOFSTEP] intro _ _ _ xs _ _ [GOAL] α✝ β✝ γ✝ : Type ?u.75696 xs : LazyList α✝ f✝ : α✝ → LazyList β✝ g✝ : β✝ → LazyList γ✝ ⊢ xs >>= f✝ >>= g✝ = xs >>= fun x => f✝ x >>= g✝ [PROOFSTEP] induction' xs using LazyList.rec with _ _ _ _ ih [GOAL] case nil α✝ β✝ γ✝ : Type ?u.75696 f✝ : α✝ → LazyList β✝ g✝ : β✝ → LazyList γ✝ ⊢ nil >>= f✝ >>= g✝ = nil >>= fun x => f✝ x >>= g✝ [PROOFSTEP] rfl [GOAL] case cons α✝ β✝ γ✝ : Type ?u.75696 xs : LazyList α✝ f✝ : α✝ → LazyList β✝ g✝ : β✝ → LazyList γ✝ hd✝ : α✝ tl✝ : Thunk (LazyList α✝) tl_ih✝ : ?m.76333 tl✝ ⊢ cons hd✝ tl✝ >>= f✝ >>= g✝ = cons hd✝ tl✝ >>= fun x => f✝ x >>= g✝ [PROOFSTEP] simp only [bind, LazyList.bind, append_bind] [GOAL] case cons α✝ β✝ γ✝ : Type ?u.75696 xs : LazyList α✝ f✝ : α✝ → LazyList β✝ g✝ : β✝ → LazyList γ✝ hd✝ : α✝ tl✝ : Thunk (LazyList α✝) tl_ih✝ : ?m.76333 tl✝ ⊢ append (LazyList.bind (f✝ hd✝) g✝) { fn := fun x => LazyList.bind (Thunk.get { fn := fun x => LazyList.bind (Thunk.get tl✝) f✝ }) g✝ } = append (LazyList.bind (f✝ hd✝) g✝) { fn := fun x => LazyList.bind (Thunk.get tl✝) fun x => LazyList.bind (f✝ x) g✝ } [PROOFSTEP] congr [GOAL] case mk α✝ β✝ γ✝ : Type ?u.75696 xs : LazyList α✝ f✝ : α✝ → LazyList β✝ g✝ : β✝ → LazyList γ✝ fn✝ : Unit → LazyList α✝ ih : ∀ (a : Unit), fn✝ a >>= f✝ >>= g✝ = fn✝ a >>= fun x => f✝ x >>= g✝ ⊢ { fn := fun x => LazyList.bind (Thunk.get { fn := fun x => LazyList.bind (Thunk.get { fn := fn✝ }) f✝ }) g✝ } = { fn := fun x => LazyList.bind (Thunk.get { fn := fn✝ }) fun x => LazyList.bind (f✝ x) g✝ } [PROOFSTEP] congr [GOAL] case mk.e_fn α✝ β✝ γ✝ : Type ?u.75696 xs : LazyList α✝ f✝ : α✝ → LazyList β✝ g✝ : β✝ → LazyList γ✝ fn✝ : Unit → LazyList α✝ ih : ∀ (a : Unit), fn✝ a >>= f✝ >>= g✝ = fn✝ a >>= fun x => f✝ x >>= g✝ ⊢ (fun x => LazyList.bind (Thunk.get { fn := fun x => LazyList.bind (Thunk.get { fn := fn✝ }) f✝ }) g✝) = fun x => LazyList.bind (Thunk.get { fn := fn✝ }) fun x => LazyList.bind (f✝ x) g✝ [PROOFSTEP] funext [GOAL] case mk.e_fn.h α✝ β✝ γ✝ : Type ?u.75696 xs : LazyList α✝ f✝ : α✝ → LazyList β✝ g✝ : β✝ → LazyList γ✝ fn✝ : Unit → LazyList α✝ ih : ∀ (a : Unit), fn✝ a >>= f✝ >>= g✝ = fn✝ a >>= fun x => f✝ x >>= g✝ x✝ : Unit ⊢ LazyList.bind (Thunk.get { fn := fun x => LazyList.bind (Thunk.get { fn := fn✝ }) f✝ }) g✝ = LazyList.bind (Thunk.get { fn := fn✝ }) fun x => LazyList.bind (f✝ x) g✝ [PROOFSTEP] apply ih [GOAL] ⊢ ∀ {α β : Type ?u.75696} (f : α → β) (x : LazyList α), (do let y ← x pure (f y)) = f <$> x [PROOFSTEP] intro _ _ f xs [GOAL] α✝ β✝ : Type ?u.75696 f : α✝ → β✝ xs : LazyList α✝ ⊢ (do let y ← xs pure (f y)) = f <$> xs [PROOFSTEP] simp only [bind, Functor.map, pure, singleton] [GOAL] α✝ β✝ : Type ?u.75696 f : α✝ → β✝ xs : LazyList α✝ ⊢ (LazyList.bind xs fun y => cons (f y) (Thunk.pure nil)) = LazyList.traverse f xs [PROOFSTEP] induction' xs using LazyList.rec with _ _ _ _ ih [GOAL] case nil α✝ β✝ : Type ?u.75696 f : α✝ → β✝ ⊢ (LazyList.bind nil fun y => cons (f y) (Thunk.pure nil)) = LazyList.traverse f nil [PROOFSTEP] rfl [GOAL] case cons α✝ β✝ : Type ?u.75696 f : α✝ → β✝ xs : LazyList α✝ hd✝ : α✝ tl✝ : Thunk (LazyList α✝) tl_ih✝ : ?m.77095 tl✝ ⊢ (LazyList.bind (cons hd✝ tl✝) fun y => cons (f y) (Thunk.pure nil)) = LazyList.traverse f (cons hd✝ tl✝) [PROOFSTEP] simp only [bind._eq_2, append, traverse._eq_2, Id.map_eq, cons.injEq, true_and] [GOAL] case cons α✝ β✝ : Type ?u.75696 f : α✝ → β✝ xs : LazyList α✝ hd✝ : α✝ tl✝ : Thunk (LazyList α✝) tl_ih✝ : ?m.77095 tl✝ ⊢ cons (f hd✝) { fn := fun x => append (Thunk.get (Thunk.pure nil)) { fn := fun x => LazyList.bind (Thunk.get tl✝) fun y => cons (f y) (Thunk.pure nil) } } = Seq.seq (cons (f hd✝)) fun x => Thunk.pure (LazyList.traverse f (Thunk.get tl✝)) [PROOFSTEP] congr [GOAL] case mk α✝ β✝ : Type ?u.75696 f : α✝ → β✝ xs : LazyList α✝ fn✝ : Unit → LazyList α✝ ih : ∀ (a : Unit), (LazyList.bind (fn✝ a) fun y => cons (f y) (Thunk.pure nil)) = LazyList.traverse f (fn✝ a) ⊢ { fn := fun x => append (Thunk.get (Thunk.pure nil)) { fn := fun x => LazyList.bind (Thunk.get { fn := fn✝ }) fun y => cons (f y) (Thunk.pure nil) } } = (fun x => Thunk.pure (LazyList.traverse f (Thunk.get { fn := fn✝ }))) () [PROOFSTEP] ext [GOAL] case mk.eq α✝ β✝ : Type ?u.75696 f : α✝ → β✝ xs : LazyList α✝ fn✝ : Unit → LazyList α✝ ih : ∀ (a : Unit), (LazyList.bind (fn✝ a) fun y => cons (f y) (Thunk.pure nil)) = LazyList.traverse f (fn✝ a) ⊢ Thunk.get { fn := fun x => append (Thunk.get (Thunk.pure nil)) { fn := fun x => LazyList.bind (Thunk.get { fn := fn✝ }) fun y => cons (f y) (Thunk.pure nil) } } = Thunk.get ((fun x => Thunk.pure (LazyList.traverse f (Thunk.get { fn := fn✝ }))) ()) [PROOFSTEP] apply ih [GOAL] α : Type ?u.93639 inst✝ : DecidableEq α x : α ⊢ Decidable (x ∈ nil) [PROOFSTEP] apply Decidable.isFalse [GOAL] case h α : Type ?u.93639 inst✝ : DecidableEq α x : α ⊢ ¬x ∈ nil [PROOFSTEP] simp [Membership.mem, LazyList.Mem] [GOAL] α : Type ?u.93639 inst✝ : DecidableEq α x y : α ys : Thunk (LazyList α) h : x = y ⊢ Decidable (x ∈ cons y ys) [PROOFSTEP] apply Decidable.isTrue [GOAL] case h α : Type ?u.93639 inst✝ : DecidableEq α x y : α ys : Thunk (LazyList α) h : x = y ⊢ x ∈ cons y ys [PROOFSTEP] simp only [Membership.mem, LazyList.Mem] [GOAL] case h α : Type ?u.93639 inst✝ : DecidableEq α x y : α ys : Thunk (LazyList α) h : x = y ⊢ x = y ∨ LazyList.Mem x (Thunk.get ys) [PROOFSTEP] exact Or.inl h [GOAL] α : Type ?u.93639 inst✝ : DecidableEq α x y : α ys : Thunk (LazyList α) h : ¬x = y ⊢ Decidable (x ∈ cons y ys) [PROOFSTEP] have := Mem.decidable x ys.get [GOAL] α : Type ?u.93639 inst✝ : DecidableEq α x y : α ys : Thunk (LazyList α) h : ¬x = y this : Decidable (x ∈ Thunk.get ys) ⊢ Decidable (x ∈ cons y ys) [PROOFSTEP] have : (x ∈ ys.get) ↔ (x ∈ cons y ys) := by simp [(· ∈ ·), LazyList.Mem, h] [GOAL] α : Type ?u.93639 inst✝ : DecidableEq α x y : α ys : Thunk (LazyList α) h : ¬x = y this : Decidable (x ∈ Thunk.get ys) ⊢ x ∈ Thunk.get ys ↔ x ∈ cons y ys [PROOFSTEP] simp [(· ∈ ·), LazyList.Mem, h] [GOAL] α : Type ?u.93639 inst✝ : DecidableEq α x y : α ys : Thunk (LazyList α) h : ¬x = y this✝ : Decidable (x ∈ Thunk.get ys) this : x ∈ Thunk.get ys ↔ x ∈ cons y ys ⊢ Decidable (x ∈ cons y ys) [PROOFSTEP] exact decidable_of_decidable_of_iff this [GOAL] α : Type u_1 x y : α ys : Thunk (LazyList α) ⊢ x ∈ cons y ys ↔ x = y ∨ x ∈ Thunk.get ys [PROOFSTEP] simp [Membership.mem, LazyList.Mem] [GOAL] α : Type u_1 p : α → Prop a : α l : Thunk (LazyList α) ⊢ (∀ (x : α), x ∈ cons a l → p x) ↔ p a ∧ ∀ (x : α), x ∈ Thunk.get l → p x [PROOFSTEP] simp only [Membership.mem, LazyList.Mem, or_imp, forall_and, forall_eq]
# The idiomatic way to compute with polynomials x := Indeterminate(Rationals, "x"); # This is a value in a polynomial ring, not a function p := 6*x^3 - 4*x^2 + 7*x - 19; Value(p, 3); # 128 u := CoefficientsOfUnivariatePolynomial(p); # [ -19, 7, -4, 6 ] # One may also create the polynomial from coefficients q := UnivariatePolynomial(Rationals, [-19, 7, -4, 6], x); # 6*x^3-4*x^2+7*x-19 p = q; # true # Now a Horner implementation Horner := function(coef, x) local v, c; v := 0; for c in Reversed(coef) do v := x*v + c; od; return v; end; Horner(u, 3); # 128
{- | Module : Numeric.GSL.ODE Copyright : (c) Alberto Ruiz 2010 License : GPL Maintainer : Alberto Ruiz (aruiz at um dot es) Stability : provisional Portability : uses ffi Solution of ordinary differential equation (ODE) initial value problems. <http://www.gnu.org/software/gsl/manual/html_node/Ordinary-Differential-Equations.html> A simple example: @import Numeric.GSL import Numeric.LinearAlgebra import Graphics.Plot xdot t [x,v] = [v, -0.95*x - 0.1*v] ts = linspace 100 (0,20 :: Double) sol = odeSolve xdot [10,0] ts main = mplot (ts : toColumns sol)@ -} ----------------------------------------------------------------------------- module Numeric.GSL.ODE ( odeSolve, odeSolveV, ODEMethod(..), Jacobian ) where import Data.Packed.Internal import Numeric.GSL.Internal import Foreign.Ptr(FunPtr, nullFunPtr, freeHaskellFunPtr) import Foreign.C.Types import System.IO.Unsafe(unsafePerformIO) ------------------------------------------------------------------------- type Jacobian = Double -> Vector Double -> Matrix Double -- | Stepping functions data ODEMethod = RK2 -- ^ Embedded Runge-Kutta (2, 3) method. | RK4 -- ^ 4th order (classical) Runge-Kutta. The error estimate is obtained by halving the step-size. For more efficient estimate of the error, use the embedded methods. | RKf45 -- ^ Embedded Runge-Kutta-Fehlberg (4, 5) method. This method is a good general-purpose integrator. | RKck -- ^ Embedded Runge-Kutta Cash-Karp (4, 5) method. | RK8pd -- ^ Embedded Runge-Kutta Prince-Dormand (8,9) method. | RK2imp Jacobian -- ^ Implicit 2nd order Runge-Kutta at Gaussian points. | RK4imp Jacobian -- ^ Implicit 4th order Runge-Kutta at Gaussian points. | BSimp Jacobian -- ^ Implicit Bulirsch-Stoer method of Bader and Deuflhard. The method is generally suitable for stiff problems. | RK1imp Jacobian -- ^ Implicit Gaussian first order Runge-Kutta. Also known as implicit Euler or backward Euler method. Error estimation is carried out by the step doubling method. | MSAdams -- ^ A variable-coefficient linear multistep Adams method in Nordsieck form. This stepper uses explicit Adams-Bashforth (predictor) and implicit Adams-Moulton (corrector) methods in P(EC)^m functional iteration mode. Method order varies dynamically between 1 and 12. | MSBDF Jacobian -- ^ A variable-coefficient linear multistep backward differentiation formula (BDF) method in Nordsieck form. This stepper uses the explicit BDF formula as predictor and implicit BDF formula as corrector. A modified Newton iteration method is used to solve the system of non-linear equations. Method order varies dynamically between 1 and 5. The method is generally suitable for stiff problems. -- | A version of 'odeSolveV' with reasonable default parameters and system of equations defined using lists. odeSolve :: (Double -> [Double] -> [Double]) -- ^ xdot(t,x) -> [Double] -- ^ initial conditions -> Vector Double -- ^ desired solution times -> Matrix Double -- ^ solution odeSolve xdot xi ts = odeSolveV RKf45 hi epsAbs epsRel (l2v xdot) (fromList xi) ts where hi = (ts@>1 - ts@>0)/100 epsAbs = 1.49012e-08 epsRel = 1.49012e-08 l2v f = \t -> fromList . f t . toList -- | Evolution of the system with adaptive step-size control. odeSolveV :: ODEMethod -> Double -- ^ initial step size -> Double -- ^ absolute tolerance for the state vector -> Double -- ^ relative tolerance for the state vector -> (Double -> Vector Double -> Vector Double) -- ^ xdot(t,x) -> Vector Double -- ^ initial conditions -> Vector Double -- ^ desired solution times -> Matrix Double -- ^ solution odeSolveV RK2 = odeSolveV' 0 Nothing odeSolveV RK4 = odeSolveV' 1 Nothing odeSolveV RKf45 = odeSolveV' 2 Nothing odeSolveV RKck = odeSolveV' 3 Nothing odeSolveV RK8pd = odeSolveV' 4 Nothing odeSolveV (RK2imp jac) = odeSolveV' 5 (Just jac) odeSolveV (RK4imp jac) = odeSolveV' 6 (Just jac) odeSolveV (BSimp jac) = odeSolveV' 7 (Just jac) odeSolveV (RK1imp jac) = odeSolveV' 8 (Just jac) odeSolveV MSAdams = odeSolveV' 9 Nothing odeSolveV (MSBDF jac) = odeSolveV' 10 (Just jac) odeSolveV' :: CInt -> Maybe (Double -> Vector Double -> Matrix Double) -- ^ optional jacobian -> Double -- ^ initial step size -> Double -- ^ absolute tolerance for the state vector -> Double -- ^ relative tolerance for the state vector -> (Double -> Vector Double -> Vector Double) -- ^ xdot(t,x) -> Vector Double -- ^ initial conditions -> Vector Double -- ^ desired solution times -> Matrix Double -- ^ solution odeSolveV' method mbjac h epsAbs epsRel f xiv ts = unsafePerformIO $ do let n = dim xiv fp <- mkDoubleVecVecfun (\t -> aux_vTov (checkdim1 n . f t)) jp <- case mbjac of Just jac -> mkDoubleVecMatfun (\t -> aux_vTom (checkdim2 n . jac t)) Nothing -> return nullFunPtr sol <- vec xiv $ \xiv' -> vec (checkTimes ts) $ \ts' -> createMIO (dim ts) n (ode_c (method) h epsAbs epsRel fp jp // xiv' // ts' ) "ode" freeHaskellFunPtr fp return sol foreign import ccall safe "ode" ode_c :: CInt -> Double -> Double -> Double -> FunPtr (Double -> TVV) -> FunPtr (Double -> TVM) -> TVVM ------------------------------------------------------- checkdim1 n v | dim v == n = v | otherwise = error $ "Error: "++ show n ++ " components expected in the result of the function supplied to odeSolve" checkdim2 n m | rows m == n && cols m == n = m | otherwise = error $ "Error: "++ show n ++ "x" ++ show n ++ " Jacobian expected in odeSolve" checkTimes ts | dim ts > 1 && all (>0) (zipWith subtract ts' (tail ts')) = ts | otherwise = error "odeSolve requires increasing times" where ts' = toList ts
{-# OPTIONS_GHC -Wall #-} module Numeric.FFT.HMatrix.Matrix ( -- * Complex-to-complex transforms dft , idft -- * Real-to-complex transforms , dftR2C , dftC2R -- * Real-to-real transforms -- ** Discrete cosine transforms , dct1 , dct2 , dct3 , dct4 -- ** Discrete sine transforms , dst1 , dst2 , dst3 , dst4 ) where import Foreign.Storable ( Storable ) import Numeric.LinearAlgebra.Data ( Matrix, Complex ) import Numeric.LinearAlgebra ( Element ) import qualified Numeric.LinearAlgebra.Data as M import Numeric.FFT.Vector.Unnormalized ( Transform ) import qualified Numeric.FFT.Vector.Unnormalized as FFT transResize :: (Storable a, Element b) => (Matrix b -> Int) -> ((Int, Int) -> Transform b a) -> Matrix b -> Matrix a transResize calcCols f m = M.reshape newcols . FFT.run (f (r, c)) $ M.flatten m where c = M.cols m r = M.rows m newcols = calcCols m trans :: (Storable a, Element b) => ((Int, Int) -> Transform b a) -> Matrix b -> Matrix a trans = transResize (M.cols) -- | -- >>> M.toLists . dft $ M.fromLists [[1, 2, 3], [4, 5, 6], [7, 8, 9]] -- [[45.0 :+ 0.0,(-4.5) :+ 2.598076211353316,(-4.5) :+ (-2.598076211353316)],[(-13.5) :+ 7.794228634059947,0.0 :+ 0.0,0.0 :+ 0.0],[(-13.5) :+ (-7.794228634059947),0.0 :+ 0.0,0.0 :+ 0.0]] dft :: Matrix (Complex Double) -> Matrix (Complex Double) dft = trans FFT.dft2d -- | -- >>> M.toLists . idft $ M.fromLists [[1, 2, 3], [4, 5, 6], [7, 8, 9]] -- [[45.0 :+ 0.0,(-4.5) :+ (-2.598076211353316),(-4.5) :+ 2.598076211353316],[(-13.5) :+ (-7.794228634059947),0.0 :+ 0.0,0.0 :+ 0.0],[(-13.5) :+ 7.794228634059947,0.0 :+ 0.0,0.0 :+ 0.0]] idft :: Matrix (Complex Double) -> Matrix (Complex Double) idft = trans FFT.idft2d -- | -- >>> M.toLists . dftR2C $ M.fromLists [[1, 2, 3], [4, 5, 6], [7, 8, 9]] -- [[45.0 :+ 0.0,(-4.5) :+ 2.598076211353316],[(-13.5) :+ 7.794228634059947,0.0 :+ 0.0],[(-13.5) :+ (-7.794228634059947),0.0 :+ 0.0]] dftR2C :: Matrix Double -> Matrix (Complex Double) dftR2C = transResize (\m -> M.cols m `div` 2 + 1) FFT.dftR2C2D -- | -- -- >>> let m = M.fromLists [[1, 2, 3], [4, 5, 6], [7, 8, 9]] -- >>> let mtest = M.fromLists [[33,-3,-3,-9],[3,-3,-9,-3],[3,0,0,0]] -- >>> M.maxElement (mtest - dftC2R m) < 1e-12 -- True dftC2R :: Matrix (Complex Double) -> Matrix Double dftC2R = transResize (\m -> 2 * (M.cols m - 1)) FFT.dftC2R2D dct1 :: Matrix Double -> Matrix Double dct1 = trans FFT.dct1_2D dct2 :: Matrix Double -> Matrix Double dct2 = trans FFT.dct2_2D dct3 :: Matrix Double -> Matrix Double dct3 = trans FFT.dct3_2D dct4 :: Matrix Double -> Matrix Double dct4 = trans FFT.dct4_2D dst1 :: Matrix Double -> Matrix Double dst1 = trans FFT.dst1_2D dst2 :: Matrix Double -> Matrix Double dst2 = trans FFT.dst2_2D dst3 :: Matrix Double -> Matrix Double dst3 = trans FFT.dst3_2D dst4 :: Matrix Double -> Matrix Double dst4 = trans FFT.dst4_2D
REBOL [ Title: {Demo tunneling of REBVAL* through routine to callback in FFI} Description: { There are two versions of quicksort in the C library. Plain `qsort` is written in such a way that if your comparator needs any information besides the two items to compare, it has to get that from global variables. `qsort_r` takes an additional void pointer parameter which it passes through to the comparator, which could hold some state information and thus eliminate the requirement to use global variables for any parameterization of the comparator. This demonstrates the use of the FFI argument type of REBVAL. While the purpose of the FFI is to talk to libraries that likely are not linked to any Rebol APIs (and hence would not be able to make use of a REBVAL), this shows the use of it to "tunnel" a Rebol value through to a written-in-Rebol comparator callback. } See-Also: { More details about callbacks are mentioned in the demo file for the "plain" qsort, in the %qsort.r demo file. } ] recycle/torture ; Note: Plain qsort demo tests WRAP-CALLBACK independently. ; cb: make-callback/fallback [ return: [int64] a [pointer] b [pointer] arg [rebval] ][ assert [integer? a] assert [integer? b] comment [ fail "testing fallback behavior" ] print mold arg i: make struct! compose/deep [ [raw-memory: (a)] i [int32] ] j: make struct! compose/deep [ [raw-memory: (b)] i [int32] ] case [ i/i = j/i [0] i/i < j/i [-1] i/i > j/i [1] ] ] 0 libc: make library! %libc.so.6 x64?: 40 = fifth system/version size_t: either x64? ['int64]['int32] qsort_r: make-routine libc "qsort_r" compose/deep [ base [pointer] nmemb [(size_t)] size [(size_t)] comp [pointer] arg [rebval] ] array: make vector! [integer! 32 5 [10 8 2 9 5]] print ["before:" mold array] probe (addr-of :cb) qsort_r array 5 4 :cb <A Tunneled Tag> print ["after:" mold array] assert [array = make vector! [integer! 32 5 [2 5 8 9 10]]] close libc
c---------------------------------------------------------- subroutine elb(txt,len) c c eliminate leading blanks from a character string c character*(*) txt character*80 save do 9000 i=1,len if(txt(i:i).ne.' ') then nonb = i go to 100 end if 9000 continue return 100 continue save = txt(nonb:len) txt = save return end
% % Calculate u-v for general vectors u and v in a product space % % Syntax: >> w = VectorMinus(u,v) % % Input: u, v --- (matrix/string/cell) vectors in a product space given as % (i) mxn matrices of the sime dimension % (ii) polynomials in character strings % (iii) cell array of (i) or (ii) % % Output: w --- (matrix/string/cell) the result of u-v stored in the same % way as u and v % % Example: % >> u = {[1 2 3; 4 5 6], '7+8*x*y+9*z^3'}; % >> v = {[1 1 1; 1 1 1],'1+x+x*y+z^3'}; % >> w = VectorMinus(u,v); % >> w{:} % ans = % % 0 1 2 % 3 4 5 % ans = % 6 - x + 7*x*y + 8*z^3 %
Formal statement is: lemma coeff_1 [simp]: "coeff 1 n = of_bool (n = 0)" Informal statement is: The coefficient of $x^n$ in the polynomial $1$ is $1$ if $n = 0$ and $0$ otherwise.
[STATEMENT] lemma conv_radius_cong': assumes "eventually (\<lambda>x. f x = g x) sequentially" shows "conv_radius f = conv_radius g" [PROOF STATE] proof (prove) goal (1 subgoal): 1. conv_radius f = conv_radius g [PROOF STEP] unfolding conv_radius_altdef [PROOF STATE] proof (prove) goal (1 subgoal): 1. liminf (\<lambda>n. inverse (ereal (root n (norm (f n))))) = liminf (\<lambda>n. inverse (ereal (root n (norm (g n))))) [PROOF STEP] by (intro Liminf_eq eventually_mono [OF assms]) auto
theory Reactive imports Temporal Refinement begin section\<open>Reactive Systems\<close> text\<open> In this section we introduce reactive systems which are modeled as monotonic property transformers where properties are predicates on traces. We start with introducing some examples that uses LTL to specify global behaviour on traces, and later we introduce property transformers based on symbolic transition systems. \<close> definition "HAVOC = [:x \<leadsto> y . True:]" definition "ASSERT_LIVE = {. \<box> \<diamond> (\<lambda> x . x 0).}" definition "GUARANTY_LIVE = [:x \<leadsto> y . \<box> \<diamond> (\<lambda> y . y 0):]" definition "AE = ASSERT_LIVE o HAVOC" definition "SKIP = [:x \<leadsto> y . x = y:]" definition "REQ_RESP = [: \<box>(\<lambda> xs ys . xs (0::nat) \<longrightarrow> (\<diamond> (\<lambda> ys . ys (0::nat))) ys) :]" definition "FAIL = \<bottom>" lemma "HAVOC o ASSERT_LIVE = FAIL" by (auto simp add: HAVOC_def AE_def FAIL_def ASSERT_LIVE_def fun_eq_iff assert_def demonic_def always_def at_fun_def le_fun_def eventually_def) lemma "HAVOC o AE = FAIL" by (auto simp add: HAVOC_def AE_def FAIL_def ASSERT_LIVE_def fun_eq_iff assert_def demonic_def always_def at_fun_def le_fun_def eventually_def) lemma "HAVOC o ASSERT_LIVE = FAIL" by (auto simp add: HAVOC_def AE_def FAIL_def ASSERT_LIVE_def fun_eq_iff assert_def demonic_def always_def at_fun_def eventually_def) lemma "SKIP o AE = AE" by simp lemma "(REQ_RESP o AE) = AE" proof (auto simp add: fun_eq_iff HAVOC_def AE_def FAIL_def REQ_RESP_def ASSERT_LIVE_def assert_def demonic_def always_def le_fun_def eventually_def at_fun_def) fix x :: "'a \<Rightarrow> bool" fix xa :: "nat \<Rightarrow> bool" fix xb :: nat assume "\<forall>xb::nat \<Rightarrow> bool . (\<forall>x. xa x \<longrightarrow> Ex (xb[x ..])) \<longrightarrow> (\<forall>x. \<exists>a. xb (x + a)) \<and> All x" then have "(\<forall>x. xa x \<longrightarrow> Ex (xa[x ..])) \<longrightarrow> (\<forall>x. \<exists>a. xa (x + a)) \<and> All x" by auto then show "\<exists>x. xa (xb + x)" by (auto, rule_tac x = 0 in exI, simp) next fix x :: "'a \<Rightarrow> bool" fix xa :: "nat \<Rightarrow> bool" fix xb :: 'a assume "\<forall>xb::nat \<Rightarrow> bool . (\<forall>x. xa x \<longrightarrow> Ex (xb[x ..])) \<longrightarrow> (\<forall>x. \<exists>a. xb (x + a)) \<and> All x" from this show "x xb" by (metis at_trace_def le0) next fix x :: "'a \<Rightarrow> bool" and xa :: "nat \<Rightarrow> bool" and xb :: "nat \<Rightarrow> bool" and xc :: nat assume A: "\<forall>x. xa x \<longrightarrow> Ex (xb[x ..])" assume B: "\<forall>x. \<exists>xb. xa (x + xb)" have "\<exists>x1. xc \<le> AbsNat x1" by (metis (full_types) le_add2 plus_Nat_def) thus "\<exists>x. xb (xc + x)" using A B by (metis AbsNat_plus add.commute at_trace_def le_Suc_ex trans_le_add2) qed subsection\<open>Symbolic transition systems\<close> text\<open> In this section we introduce property transformers basend on symbolic transition systems. These are systems with local state. The execution starts in some initial state, and with some input value the system computes a new state and an output value. Then using the current state, and a new input value the system computes a new state, and a new output, and so on. The system may fail if at some point the input and the current state do not statisfy a required predicate. In the folowing definitions the variables $u$, $x$, $y$ stand for the state of the system, the input, and the output respectively. The $init$ is the property that the initial state should satisfy. The predicate $p$ is the precondition of the input and the current state, and the relation $r$ gives the next state and the output based on the input and the current state. \<close> definition "fail_sys init p r x = (\<exists> n u y . u \<in> init \<and> (\<forall> i < n . r (u i) (u (Suc i)) (x i) (y i)) \<and> (\<not> p (u n) (u (Suc n)) (x n)))" definition "run r u x y = (\<forall> i . r (u i) (u (Suc i)) (x i) (y i))" definition "LocalSystem init p r q x = (\<not> fail_sys init p r x \<and> (\<forall> u y . (u \<in> init \<and> run r u x y) \<longrightarrow> q y))" lemma "fail (LocalSystem init p r) = fail_sys init p r" by (simp add: fun_eq_iff LocalSystem_def fail_def fail_sys_def run_def) definition "inpt_st r u u' x = (\<exists> y . r u u' x y)" definition "lft_pred_st p u x = p (u (0::nat)) (u 1) (x (0::nat))" definition "lft_pred_loc_st p u x = p (u (0::nat)) (x (0::nat))" definition "lft_rel_st r u x y = r (u (0::nat)) (u 1) (x (0::nat)) (y (0::nat))" definition "prec_st p r = -((lft_pred_st (inpt_st r)) until -(lft_pred_st p))" lemma prec_st_simp: "prec_st p r u x = (\<forall> n . (\<forall> i < n . inpt_st r (u i) (u (Suc i)) (x i)) \<longrightarrow> p (u n) (u (Suc n)) (x n))" by (simp add: prec_st_def until_def lft_pred_st_def inpt_st_def at_fun_def, metis) definition "SymSystem init p r = [:z \<leadsto> u, x . u \<in> init \<and> z = x:] o {.u, x . prec_st p r u x.} o [:u, x \<leadsto> y . (\<box> (lft_rel_st r)) u x y :]" lemma SymSystem_rel: "SymSystem init p r = {. x . \<forall>u. u \<in> init \<longrightarrow> prec_st p r u x .} \<circ> [: x \<leadsto> y . \<exists> u . u \<in> init \<and> (\<box> lft_rel_st r) u x y :] " proof - have [simp]: "((\<lambda>z (u, x). u \<in> init \<and> z = x) OO (\<lambda>(x, y). (\<box> lft_rel_st r) x y)) = (\<lambda>x y. \<exists>u. u \<in> init \<and> (\<box> lft_rel_st r) u x y)" by auto show ?thesis by (simp add: SymSystem_def demonic_assert_comp comp_assoc demonic_demonic) qed theorem "SymSystem init p r q x = LocalSystem init p r q x" proof assume "SymSystem init p r q x" then show "LocalSystem init p r q x" apply (auto simp add: SymSystem_def LocalSystem_def assert_def demonic_def prec_st_simp lft_rel_st_def lft_pred_st_def inpt_st_def always_def le_fun_def fail_sys_def run_def at_fun_def) by metis next assume "LocalSystem init p r q x" then show "SymSystem init p r q x" apply (auto simp add: SymSystem_def LocalSystem_def assert_def demonic_def prec_st_simp lft_rel_st_def lft_pred_st_def inpt_st_def always_def le_fun_def fail_sys_def run_def at_fun_def) by metis qed definition "local_init init S = Inf (S ` init)" definition "zip_set A B = {u . ((fst o u) \<in> A) \<and> ((snd o u) \<in> B)}" definition nzip:: "('x \<Rightarrow> 'a) \<Rightarrow> ('x \<Rightarrow> 'b) \<Rightarrow> 'x \<Rightarrow> ('a\<times>'b)" (infixl "||" 65) where "(xs || ys) i = (xs i, ys i)" lemma [simp]: "fst \<circ> x || y = x" by (simp add: fun_eq_iff nzip_def) lemma [simp]: "snd \<circ> x || y = y" by (simp add: fun_eq_iff nzip_def) lemma [simp]: "x \<in> A \<Longrightarrow> y \<in> B \<Longrightarrow> (x || y) \<in> zip_set A B" by (simp add: zip_set_def) lemma local_demonic_init: "local_init init (\<lambda> u . {. x . p u x.} o [:x \<leadsto> y . r u x y :]) = [:z \<leadsto> u, x . u \<in> init \<and> z = x:] o {.u, x . p u x.} o [:u, x \<leadsto> y . r u x y :]" by (auto simp add: fun_eq_iff demonic_def assert_def local_init_def le_fun_def) lemma local_init_comp: "u' \<in> init' \<Longrightarrow> (\<forall> u. sconjunctive (S u)) \<Longrightarrow> (local_init init S) o (local_init init' S') = local_init (zip_set init init') (\<lambda> u . (S (fst o u)) o (S' (snd o u)))" proof (subst fun_eq_iff, auto) fix x :: 'f assume A: "u' \<in> init'" assume "\<forall> u . sconjunctive (S u)" from this have [simp]: "\<And> u . sconjunctive (S u)" by simp from A have [simp]: "\<And> y . S y (INF y' \<in> init'. S' y' x) = (INF y' \<in> init' . S y (S' y' x))" by (simp add: sconjunctive_INF_simp image_comp) have [simp]: "(INF y \<in> init . (INF y' \<in> init' . S y (S' y' x))) \<le> (INF u \<in> zip_set init init'. S (fst \<circ> u) (S' (snd \<circ> u) x))" proof (rule INF_greatest, auto simp add: zip_set_def) fix u :: "'a \<Rightarrow> 'c \<times> 'b" assume [simp]: "fst \<circ> u \<in> init" assume [simp]: "snd \<circ> u \<in> init'" have "(INF y \<in> init. INF y' \<in> init'. S y (S' y' x)) \<le> (INF y' \<in> init'. S (fst o u) (S' y' x))" by (rule INF_lower, simp) also have "... \<le> S (fst o u) (S' (snd o u) x)" by (rule INF_lower, simp) finally show "(INF y \<in> init. INF y' \<in> init'. S y (S' y' x)) \<le> S (fst o u) (S' (snd o u) x)" by simp qed have [simp]: "(INF u \<in> zip_set init init'. S (fst \<circ> u) (S' (snd \<circ> u) x)) \<le> (INF y \<in> init . (INF y' \<in> init' . S y (S' y' x)))" proof (rule INF_greatest, rule INF_greatest) fix y :: "'a \<Rightarrow> 'c" and y':: "'a \<Rightarrow> 'b" assume [simp]: "y \<in> init" assume [simp]: "y' \<in> init'" have "(INF u \<in> zip_set init init'. S (fst \<circ> u) (S' (snd \<circ> u) x)) \<le> S (fst o (y || y')) (S' (snd o (y || y')) x)" by (rule INF_lower, simp) also have "... \<le> S y (S' y' x)" by simp finally show "(INF u :: 'a \<Rightarrow> 'c \<times> 'b \<in> zip_set init init'. S (fst \<circ> u) (S' (snd \<circ> u) x)) \<le> S y (S' y' x)" by simp qed have "local_init init S (local_init init' S' x) = (INF y \<in> init. S y (INF y' \<in> init'. S' y' x)) " by (simp add: local_init_def image_comp) also have "... = (INF y \<in> init . (INF y' \<in> init' . S y (S' y' x)))" by simp also have "... = (INF u \<in> zip_set init init'. S (fst \<circ> u) \<circ> S' (snd \<circ> u)) x" by (rule antisym) (simp_all add: image_comp) also have "... = local_init (zip_set init init') (\<lambda> u . (S (fst o u)) o (S' (snd o u))) x" by (simp add: local_init_def) finally show "local_init init S (local_init init' S' x) = local_init (zip_set init init') (\<lambda>u::'a \<Rightarrow> 'c \<times> 'b. S (fst \<circ> u) \<circ> S' (snd \<circ> u)) x" by simp qed lemma init_state: "[:z \<leadsto> u, x . u \<in> init \<and> z = x:] o {.u, x . p u x.} o [:u, x \<leadsto> y . r u x y :] = [:z \<leadsto> u, x . z = x:] o {.u, x . u \<in> init \<longrightarrow> p u x.} o [:u, x \<leadsto> y . u \<in> init \<and> r u x y :]" by (auto simp add: fun_eq_iff demonic_def assert_def local_init_def le_fun_def) lemma always_lft_rel_comp: "(\<box> lft_rel_st r) (fst \<circ> u) OO (\<box> lft_rel_st r') (snd \<circ> u) = (\<box> lft_rel_st (\<lambda> (u, v) (u', v') . ((r u u') OO (r' v v')))) u" proof (auto simp add: fun_eq_iff lft_rel_st_def always_def at_fun_def relcompp_exists) fix x::"nat \<Rightarrow>'a" and y::"nat \<Rightarrow> 'b" and v::"nat \<Rightarrow> 'c" and n:: nat assume "\<forall>i . r (fst (u i)) (fst (u (Suc i))) (x i) (v i)" and "\<forall>i . r' (snd (u i)) (snd (u (Suc i))) (v i) (y i)" from this show "(case u n of (u, v) \<Rightarrow> \<lambda>(u', v'). r u u' OO r' v v') (u (Suc n)) (x n) (y n)" by (metis (mono_tags, lifting) prod.case_eq_if relcompp.relcompI) next fix x::"nat \<Rightarrow>'a" and z::"nat \<Rightarrow> 'b" define a where "a n = (SOME y . r (fst (u n)) (fst (u (Suc n))) (x n) y \<and> r' (snd (u n)) (snd (u (Suc n))) y (z n))" for n assume "\<forall>i . (case u i of (u, v) \<Rightarrow> \<lambda>(u', v'). r u u' OO r' v v') (u (Suc i)) (x i) (z i)" from this and a_def have "(\<forall>i :: nat. r (fst (u i)) (fst (u (Suc i))) (x i) (a i)) \<and> (\<forall>i :: nat. r' (snd (u i)) (snd (u (Suc i))) (a i) (z i))" apply auto apply (metis (mono_tags, lifting) pick_middlep prod.collapse split_conv tfl_some) by (metis (mono_tags, lifting) pick_middlep prod.collapse split_conv tfl_some) from this show "\<exists> a . (\<forall>i . r (fst (u i)) (fst (u (Suc i))) (x i) (a i)) \<and> (\<forall>i . r' (snd (u i)) (snd (u (Suc i))) (a i) (z i))" by blast qed theorem SymSystem_comp: "u' \<in> init' \<Longrightarrow> SymSystem init p r o SymSystem init' p' r' = [:z \<leadsto> u, x . fst o u \<in> init \<and> snd o u \<in> init' \<and> z = x:] o {. u, x . prec_st p r (fst \<circ> u) x \<and> (\<forall>y. (\<box> lft_rel_st r) (fst \<circ> u) x y \<longrightarrow> prec_st p' r' (snd \<circ> u) y) .} o [: u, x \<leadsto> y . (\<box> lft_rel_st (\<lambda>(u, v) (u', v'). r u u' OO r' v v')) u x y :]" (is "?p \<Longrightarrow> ?S = ?T") proof - assume A: "?p" have "?S = [: z \<leadsto> (u, x) . u \<in> init \<and> z = x :] \<circ> {.x, y. prec_st p r x y.} \<circ> [: id (\<lambda>(u, x). id ((\<box> lft_rel_st r) u x)) :] \<circ> ([: z \<leadsto> u, x . u \<in> init' \<and> z = x :] \<circ> {.x, y. prec_st p' r' x y.} \<circ> [: id (\<lambda>(u, x). id ((\<box> lft_rel_st r') u x)) :])" by (unfold SymSystem_def, simp) also have "... = local_init init (\<lambda>u::nat \<Rightarrow> 'e. {. id (prec_st p r u) .} \<circ> [: id (\<lambda>x. id ((\<box> lft_rel_st r) u x)) :]) \<circ> local_init init' (\<lambda>u. {. id (prec_st p' r' u) .} \<circ> [: id (\<lambda>x::nat \<Rightarrow> 'd. id ((\<box> lft_rel_st r') u x)) :])" by (unfold local_demonic_init [THEN sym], simp) also from A have "... = local_init (zip_set init init') (\<lambda>u. {. prec_st p r (fst \<circ> u) .} \<circ> [: (\<box> lft_rel_st r) (fst \<circ> u) :] \<circ> ({. prec_st p' r' (snd \<circ> u) .} \<circ> [: (\<box> lft_rel_st r') (snd \<circ> u) :]))" by (simp add: local_init_comp) also have " ... = local_init (zip_set init init') (\<lambda>u. {. prec_st p r (fst \<circ> u) .} \<circ> [: (\<box> lft_rel_st r) (fst \<circ> u) :] \<circ> {. prec_st p' r' (snd \<circ> u) .} \<circ> [: (\<box> lft_rel_st r') (snd \<circ> u) :])" by (simp add: comp_assoc [THEN sym]) also have "... = local_init (zip_set init init') (\<lambda>u.{. x . prec_st p r (fst \<circ> u) x \<and> (\<forall>y. (\<box> lft_rel_st r) (fst \<circ> u) x y \<longrightarrow> prec_st p' r' (snd \<circ> u) y) .} \<circ> [: (\<box> lft_rel_st (\<lambda>(u, v) (u', v'). r u u' OO r' v v')) u :]) " by (simp add: assert_demonic_comp always_lft_rel_comp) also have "... = local_init (zip_set init init') (\<lambda>u.{.x. prec_st p r (fst \<circ> u) x \<and> (\<forall>y::nat \<Rightarrow> 'd. (\<box> lft_rel_st r) (fst \<circ> u) x y \<longrightarrow> prec_st p' r' (snd \<circ> u) y).} \<circ> [: id (\<lambda>x::nat \<Rightarrow> 'c. id ((\<box> lft_rel_st (\<lambda>(u, v) (u', v'). r u u' OO r' v v')) u x)) :])" by simp also have "... = ?T" by (unfold local_demonic_init, simp add: zip_set_def) finally show ?thesis by simp qed lemma always_lft_rel_comp_a: "(\<box> lft_rel_st r) u OO (\<box> lft_rel_st r') v = (\<box> lft_rel_st (\<lambda> (u, v) (u', v') . ((r u u') OO (r' v v')))) (u || v)" by (unfold always_lft_rel_comp [THEN sym], auto) theorem SymSystem_comp_a: "u' \<in> init' \<Longrightarrow> SymSystem init p r o SymSystem init' p' r' = {.x . \<forall> u v . u \<in> init \<and> v \<in> init' \<longrightarrow> (prec_st p r u x \<and> (\<forall>y. (\<box> lft_rel_st r) u x y \<longrightarrow> prec_st p' r' v y)) .} o [: x \<leadsto> y . \<exists> u v . u \<in> init \<and> v \<in> init' \<and> (\<box> lft_rel_st (\<lambda>(u, v) (u', v'). r u u' OO r' v v')) (u || v) x y :]" (is "?p \<Longrightarrow> ?S = ?T") proof - assume A: "u' \<in> init'" from A have [simp]: "(\<lambda>x. (\<forall>u. u \<in> init \<longrightarrow> prec_st p r u x) \<and> (\<forall>y. (\<exists>u. u \<in> init \<and> (\<box> lft_rel_st r) u x y) \<longrightarrow> (\<forall>u. u \<in> init' \<longrightarrow> prec_st p' r' u y))) = (\<lambda>x. \<forall>u v. u \<in> init \<and> v \<in> init' \<longrightarrow> prec_st p r u x \<and> (\<forall>y. (\<box> lft_rel_st r) u x y \<longrightarrow> prec_st p' r' v y))" by (auto simp add: fun_eq_iff) have [simp]: "(\<lambda>x y. \<exists>u. u \<in> init \<and> (\<box> lft_rel_st r) u x y) OO (\<lambda>x y. \<exists>u. u \<in> init' \<and> (\<box> lft_rel_st r') u x y) = (\<lambda> x y . \<exists> u v . u \<in> init \<and> v \<in> init' \<and> (((\<box> lft_rel_st r) u) OO ((\<box> lft_rel_st r') v)) x y)" by (auto simp add: fun_eq_iff) from A have "?S = {.x . \<forall>u . u \<in> init \<longrightarrow> prec_st p r u x.} \<circ> [: x \<leadsto> y . \<exists>u::nat \<Rightarrow> 'e. u \<in> init \<and> (\<box> lft_rel_st r) u x y :] \<circ> ({.x. \<forall>u . u \<in> init' \<longrightarrow> prec_st p' r' u x.} \<circ> [: x \<leadsto> y . \<exists>u . u \<in> init' \<and> (\<box> lft_rel_st r') u x y :])" by (simp add: SymSystem_rel) also have "... = {. \<lambda>x . \<forall>u . u \<in> init \<longrightarrow> prec_st p r u x .} \<circ> [: x \<leadsto> y . \<exists>u . u \<in> init \<and> (\<box> lft_rel_st r) u x y :] \<circ> {. x . \<forall>u . u \<in> init' \<longrightarrow> prec_st p' r' u x .} \<circ> [: x \<leadsto> y . \<exists>u . u \<in> init' \<and> (\<box> lft_rel_st r') u x y :]" by (simp add: comp_assoc [THEN sym]) also have "... = ?T" by (simp add: assert_demonic_comp always_lft_rel_comp_a) finally show ?thesis by simp qed text\<open>We show next that the composition of two SymSystem $S$ and $S'$ is not equal to the SymSystem of the compostion of local transitions of $S$ and $S'$\<close> definition "initS = {u . fst (u (0::nat)) = (0::nat)}" definition "localPrecS = (\<top>:: nat \<times> nat \<Rightarrow> nat \<times> nat \<Rightarrow> nat \<Rightarrow> bool)" definition "localRelS = (\<lambda> (u::nat, v) (u', v'::nat) (x::nat) (y::nat) . u = 0 \<and> u' = 1 \<and> v = v')" definition "initS' = (\<top>::(nat \<Rightarrow> (nat \<times> nat)) set)" definition "localPrecS' = (\<bottom>:: nat \<times> nat \<Rightarrow> nat \<times> nat \<Rightarrow> nat \<Rightarrow> bool)" definition "localRelS' = (\<lambda> (u::nat, v) (u', v'::nat) (x::nat) (y::nat) . u = u')" definition "symbS = SymSystem initS localPrecS localRelS" definition "symbS' = SymSystem initS' localPrecS' localRelS'" definition "localPrecSS' = (\<lambda>(u::nat, v::nat) (u', v') (x::nat) . 0 < u)" definition "localRelSS' = (\<lambda> (u, v::nat) (u'::nat, v'::nat) (x::nat) (z::nat) . (u::nat) = 0 \<and> u' = 1)" lemma localSS'_aux: "( \<lambda>x. \<forall> (a::nat) (aa::nat) (b::nat). \<not> (case x of (x::nat, u::nat, v::nat) \<Rightarrow> \<lambda>ab. u = 0 \<and> (case ab of (y, u', v') \<Rightarrow> u' = Suc 0 \<and> v = v')) (a, aa, b)) = (\<lambda> (x, u, v) . u > 0)" by (auto simp add: fun_eq_iff) lemma localSS'_aux_b: "((\<lambda>(x, u, v) ab. u = 0 \<and> (case ab of (y, u', v') \<Rightarrow> u' = Suc 0 \<and> v = v')) OO (\<lambda>(x, u, v) (y, u', v'). u = u')) = (\<lambda> (x, u, v) (y, u', v') . u = 0 \<and> u' = 1)" by (simp add: fun_eq_iff relcompp_exists) lemma "{.x, (u, v) . localPrecS (u, v) (a,b) x.} o [:x, (u,v) \<leadsto> y, (u',v') . localRelS (u,v) (u',v') x y:] o {.x, (u, v) . localPrecS' (u, v) (c, d) x.} o [:x, (u,v) \<leadsto> y, (u',v') . localRelS' (u,v) (u',v') x y:] = {.x, (u, v) . localPrecSS' (u, v) (e, f) x.} o [:x, (u,v) \<leadsto> y, (u',v') . localRelSS' (u,v) (u',v') x y:]" by (simp add: assert_demonic_comp localPrecS'_def localPrecS_def localRelS_def localRelS'_def relcompp_exists localPrecSS'_def localRelSS'_def localSS'_aux localSS'_aux_b) lemma [simp]: "[: \<bottom>::('a \<Rightarrow> 'b => ('c::boolean_algebra)) :] = \<top>" by (simp add: fun_eq_iff demonic_def) definition "symbSS' = SymSystem initS localPrecSS' localRelSS'" lemma symbSS'_aux: "( \<lambda>x. \<forall>u. fst (u 0) = 0 \<longrightarrow> (\<forall>n. (\<forall>i<n. Ex ((case u i of (u, v) \<Rightarrow> \<lambda>(u', v'::nat) x z. u = 0 \<and> u' = Suc 0) (u (Suc i)) (x i))) \<longrightarrow> (case u n of (u, v) \<Rightarrow> \<lambda>(u', v') x. 0 < u) (u (Suc n)) (x n)) ) = \<bottom>" apply (auto simp add: fun_eq_iff) by (rule_tac x = "\<lambda> i . (i::nat, i)" in exI, simp) lemma symbSS': "symbSS' = \<bottom>" by (simp add: symbSS'_def SymSystem_rel initS_def localPrecSS'_def localRelSS'_def prec_st_simp inpt_st_def symbSS'_aux) lemma symbS: "symbS = \<top>" proof (simp add: symbS_def SymSystem_rel initS_def localPrecS_def localRelS_def) have [simp]: "(\<lambda>x. \<forall>u. fst (u 0) = 0 \<longrightarrow> prec_st \<top> (\<lambda> (u, v) (u', v') x y . u = 0 \<and> u' = Suc 0 \<and> v = v') u x) = \<top>" by (simp_all add: fun_eq_iff prec_st_def always_def lft_rel_st_def at_fun_def lft_pred_st_def inpt_st_def until_def) have [simp]: "(\<lambda>x y. \<exists>u. fst (u 0) = 0 \<and> (\<box> lft_rel_st (\<lambda> (u, v) (u', v') (x) (y). u = 0 \<and> u' = Suc 0 \<and> v = v')) u x y) = \<bottom>" proof (auto simp add: fun_eq_iff always_def lft_rel_st_def at_fun_def) fix x::"nat \<Rightarrow> 'a" and xa :: "nat \<Rightarrow> 'b" and u::"nat \<Rightarrow> nat \<times> 'c" assume A: "\<forall>a . (case u a of (e, f) \<Rightarrow> \<lambda>(u', v') x y. e = 0 \<and> u' = Suc 0 \<and> f = v') (u (Suc a)) (x a) (xa a)" {fix n:: nat from A have "fst (u n) = 0 \<and> fst (u (Suc n)) = Suc 0" by (drule_tac x = n in spec, case_tac "u n", case_tac "u (Suc n)", auto) } note B = this then have "fst (u (Suc 0)) = 0" by auto moreover have "fst (u (Suc 0)) = Suc 0" using B [of 0] by auto ultimately show "(0) < fst (u (0))" by auto qed show "{. \<lambda>x. \<forall>u. fst (u 0) = 0 \<longrightarrow> prec_st \<top> (\<lambda>(u, v) (u', v') x y. u = 0 \<and> u' = Suc 0 \<and> v = v') u x .} \<circ> [: \<lambda> x y . \<exists>u . fst (u 0) = 0 \<and> (\<box> lft_rel_st (\<lambda>(u, v) (u', v') x y. u = 0 \<and> u' = Suc 0 \<and> v = v')) u x y :] = \<top>" by simp qed lemma "symbS o symbS' \<noteq> symbSS'" by (simp add: symbSS' symbS fun_eq_iff) lemma prec_st_inpt: "prec_st (inpt_st r) r = (\<box> (lft_pred_st (inpt_st r)))" by (simp add: prec_st_def neg_until_always) lemma "grd (SymSystem init p r) = Sup ((- prec_st p r \<squnion> (\<box> (lft_pred_st (inpt_st r)))) ` init)" proof (unfold fun_eq_iff, auto simp add: grd_def SymSystem_rel demonic_def assert_def) fix x :: "nat \<Rightarrow> 'a" and xa :: "nat \<Rightarrow> 'b" and u :: "nat \<Rightarrow> 'c" assume "\<forall>xa::nat \<Rightarrow> 'c\<in>init. prec_st p r xa x \<and> \<not> (\<box> lft_pred_st (inpt_st r)) xa x" and "u \<in> init" and "(\<box> lft_rel_st r) u x xa" then show "False" by (auto simp add: always_def lft_pred_st_def inpt_st_def at_fun_def lft_rel_st_def) next fix x :: "nat \<Rightarrow> 'a" and xa :: "nat \<Rightarrow> 'c" assume B: "xa \<in> init" assume "(\<lambda>y . \<exists>u . u \<in> init \<and> (\<box> lft_rel_st r) u x y) \<le> \<bottom>" then have A: "\<forall> y u . u \<notin> init \<or> \<not> (\<box> lft_rel_st r) u x y" by auto let ?y = "\<lambda> n . (SOME z . r (xa n) (xa (Suc n)) (x n) z)" from B and A have "\<not> (\<box> lft_rel_st r) xa x ?y" by simp moreover assume "(\<box> lft_pred_st (inpt_st r)) xa x" ultimately show "False" apply (simp add: always_def lft_pred_st_def inpt_st_def at_fun_def lft_rel_st_def) by (metis (full_types) tfl_some) qed definition "guard S = {.((grd S)::'a\<Rightarrow>bool).} o S" lemma "((grd (local_init init S))::'a\<Rightarrow>bool) = Sup ((grd o S) ` init)" by (simp add: fun_eq_iff local_init_def assert_def grd_def) lemma "u \<in> init \<Longrightarrow> guard ([:z \<leadsto> u, x . u \<in> init \<and> z = x:] o {.u, x . p u x.} o [:u, x \<leadsto> y . r u x y :]) = [:z \<leadsto> u, x . u \<in> init \<and> z = x:] o {.u, x . u \<in> init \<and> (\<exists>a. a \<in> init \<and> (p a x \<longrightarrow> Ex (r a x))) \<and> p u x.} o [:u, x \<leadsto> y . ((r u x y)::bool) :]" by (auto simp add: fun_eq_iff local_init_def guard_def grd_def assert_def demonic_def le_fun_def) lemma inpt_str_comp_aux: "(\<forall>n. (\<forall>i<n. inpt_st (\<lambda>(u, v) (u', v'). r u u' OO r' v v') (u i) (u (Suc i)) (x i)) \<longrightarrow> inpt_st r (fst (u n)) (fst (u (Suc n))) (x n) \<and> (\<forall>y. r (fst (u n)) (fst (u (Suc n))) (x n) y \<longrightarrow> inpt_st r' (snd (u n)) (snd (u (Suc n))) y)) \<longrightarrow> (\<forall> i < n . inpt_st r ((fst o u) i) ((fst o u) (Suc i)) (x i) \<and> (\<forall>y. r (fst (u i)) (fst (u (Suc i))) (x i) y \<longrightarrow> inpt_st r' (snd (u i)) (snd (u (Suc i))) y))" (is "(\<forall> n . ?p n) \<longrightarrow> ?q n") proof (induction n) case 0 show ?case by auto next case (Suc n) show ?case proof auto fix i::nat assume B: "\<forall> n . ?p n" then have A: "?p n" (is "?A \<longrightarrow> ?B") by simp from Suc and B have C: "?q n" by simp assume "i < Suc n" then show "inpt_st r (fst (u i)) (fst (u (Suc i))) (x i)" proof cases assume "i < n" then show ?thesis by (metis Suc.IH B comp_apply) next assume "\<not> i < n" from this and \<open>i < Suc n\<close> have [simp]: "i = n" by simp show ?thesis proof cases assume "?A" from this and A have D: "?B" by simp from D show ?thesis by (metis \<open>i = n\<close>) next assume "\<not> ?A" then obtain j where j: "j < n \<and> \<not> inpt_st (\<lambda> (u, v) . \<lambda> (u', v') . r u u' OO r' v v') (u j) (u (Suc j)) (x j)" by auto with C have "inpt_st r (fst (u j)) (fst (u (Suc j))) (x j) \<and> (\<forall>y. r (fst (u j)) (fst (u (Suc j))) (x j) y \<longrightarrow> inpt_st r' (snd (u j)) (snd (u (Suc j))) y)" by auto with j show ?thesis apply (case_tac "u j") apply (case_tac "u (Suc j)") apply (simp add: inpt_st_def) by (metis relcompp.relcompI) qed qed next fix i::nat fix y :: 'e assume B: "\<forall> n . ?p n" then have A: "?p n" (is "?A \<longrightarrow> ?B") by simp from Suc and B have C: "\<forall>i<n. inpt_st r (fst (u i)) (fst (u (Suc i))) (x i) \<and> (\<forall>y. r (fst (u i)) (fst (u (Suc i))) (x i) y \<longrightarrow> inpt_st r' (snd (u i)) (snd (u (Suc i))) y)" by simp assume E: "r (fst (u i)) (fst (u (Suc i))) (x i) y" assume "i < Suc n" then show "inpt_st r' (snd (u i)) (snd (u (Suc i))) y" proof cases assume "i < n" from this and E and C show ?thesis by simp next assume "\<not> i < n" from this and \<open>i < Suc n\<close> have [simp]: "i = n" by simp show ?thesis proof (cases ?A) case True with A have D: "?B" by simp from D and E show ?thesis by (metis \<open>i = n\<close>) next case False then obtain j where j: "j < n \<and> \<not> inpt_st (\<lambda> (u, v) . \<lambda> (u', v') . r u u' OO r' v v') (u j) (u (Suc j)) (x j)" by auto with C have "inpt_st r (fst (u j)) (fst (u (Suc j))) (x j) \<and> (\<forall>y. r (fst (u j)) (fst (u (Suc j))) (x j) y \<longrightarrow> inpt_st r' (snd (u j)) (snd (u (Suc j))) y)" by auto with j show ?thesis by (case_tac "u j", case_tac "u (Suc j)", simp add: inpt_st_def, metis relcompp.relcompI) qed qed qed qed lemma inpt_str_comp_aux_a: "(\<forall>n. (\<forall>i<n. inpt_st (\<lambda>(u, v) (u', v'). r u u' OO r' v v') (u i) (u (Suc i)) (x i)) \<longrightarrow> inpt_st r (fst (u n)) (fst (u (Suc n))) (x n) \<and> (\<forall>y. r (fst (u n)) (fst (u (Suc n))) (x n) y \<longrightarrow> inpt_st r' (snd (u n)) (snd (u (Suc n))) y)) \<Longrightarrow> inpt_st r ((fst o u) n) ((fst o u) (Suc n)) (x n) \<and> (\<forall>y. r (fst (u n)) (fst (u (Suc n))) (x n) y \<longrightarrow> inpt_st r' (snd (u n)) (snd (u (Suc n))) y)" by (cut_tac n = "Suc n" and r = r and r' = r' and u = u and x = x in inpt_str_comp_aux, simp) definition "rel_st r r' = (\<lambda> (u, v) (u', v') x z . inpt_st r u u' x \<and> (\<forall> y . r u u' x y \<longrightarrow> inpt_st r' v v' y) \<and> (r u u' OO r' v v') x z)" lemma inpt_str_comp_a: "(prec_st (inpt_st r) r (fst \<circ> u) x \<and> (\<forall>y. (\<box> lft_rel_st r) (fst \<circ> u) x y \<longrightarrow> prec_st (inpt_st r') r' (snd \<circ> u) y)) = prec_st (\<lambda> u u' x . inpt_st r (fst u) (fst u') x \<and> (\<forall> y . r (fst u) (fst u') x y \<longrightarrow> (inpt_st r' (snd u) (snd u') y))) (\<lambda>(u, v) (u', v'). r u u' OO r' v v') u x" proof (auto simp add: prec_st_inpt prec_st_simp) fix n:: nat assume "(\<box> lft_pred_st (inpt_st r)) (fst \<circ> u) x" then show "inpt_st r (fst (u n)) (fst (u (Suc n))) (x n)" by (simp add: always_def lft_pred_st_def at_fun_def) next fix n:: nat and y :: 'c assume A: "(\<box> lft_pred_st (inpt_st r)) (fst \<circ> u) x" assume B: "r (fst (u n)) (fst (u (Suc n))) (x n) y" assume C: "\<forall>i<n. inpt_st (\<lambda>(u::'a, v::'d) (u'::'a, v'::'d). r u u' OO r' v v') (u i) (u (Suc i)) (x i)" let ?y = "\<lambda> i . (if i = n then y else (SOME y . r ((fst o u) i) ((fst o u) (Suc i)) (x i) y))" assume "\<forall>y . (\<box> lft_rel_st r) (fst \<circ> u) x y \<longrightarrow> (\<box> lft_pred_st (inpt_st r')) (snd \<circ> u) y" then have D: "(\<box> lft_rel_st r) (fst \<circ> u) x ?y \<longrightarrow> (\<box> lft_pred_st (inpt_st r')) (snd \<circ> u) ?y" by simp from A and B have E: "(\<box> lft_rel_st r) (fst \<circ> u) x ?y" apply (auto simp add: always_def at_fun_def lft_rel_st_def lft_pred_st_def inpt_st_def) by (metis tfl_some) from D and E have "(\<box> lft_pred_st (inpt_st r')) (snd \<circ> u) ?y" by simp from A and E and this show "inpt_st r' (snd (u n)) (snd (u (Suc n))) y" apply (simp add: always_def lft_pred_st_def at_fun_def) apply (drule_tac x = n in spec) apply (drule_tac x = n in spec) by (drule_tac x = n in spec, simp) next assume "\<forall> n . (\<forall>i<n. inpt_st (\<lambda>(u::'a, v::'d) (u'::'a, v'::'d). r u u' OO r' v v') (u i) (u (Suc i)) (x i)) \<longrightarrow> inpt_st r (fst (u n)) (fst (u (Suc n))) (x n) \<and> (\<forall>y::'c. r (fst (u n)) (fst (u (Suc n))) (x n) y \<longrightarrow> inpt_st r' (snd (u n)) (snd (u (Suc n))) y)" then show "(\<box> lft_pred_st (inpt_st r)) (fst \<circ> u) x" apply (auto simp add: always_def lft_pred_st_def at_fun_def) apply (drule inpt_str_comp_aux_a) by auto next fix y::"nat \<Rightarrow> 'c" assume "\<forall> n . (\<forall>i<n. inpt_st (\<lambda>(u::'a, v::'d) (u'::'a, v'::'d). r u u' OO r' v v') (u i) (u (Suc i)) (x i)) \<longrightarrow> inpt_st r (fst (u n)) (fst (u (Suc n))) (x n) \<and> (\<forall>y::'c. r (fst (u n)) (fst (u (Suc n))) (x n) y \<longrightarrow> inpt_st r' (snd (u n)) (snd (u (Suc n))) y)" moreover assume " (\<box> lft_rel_st r) (fst \<circ> u) x y" ultimately show "(\<box> lft_pred_st (inpt_st r')) (snd \<circ> u) y" apply (auto simp add: always_def lft_pred_st_def at_fun_def) apply (drule inpt_str_comp_aux_a) by (auto simp add: lft_rel_st_def) qed lemma inpt_str_comp_b: "prec_st (\<lambda> u u' x . inpt_st r (fst u) (fst u') x \<and> (\<forall> y . r (fst u) (fst u') x y \<longrightarrow> (inpt_st r' (snd u) (snd u') y))) (\<lambda>(u, v) (u', v'). r u u' OO r' v v') u x = (\<box> (lft_pred_st (inpt_st (rel_st r r')))) u x" proof (auto simp add: prec_st_simp always_def lft_pred_st_def at_fun_def rel_st_def) fix m::nat assume A: "\<forall>n . (\<forall>i<n. inpt_st (\<lambda>(u, v) (u', v'). r u u' OO r' v v') (u i) (u (Suc i)) (x i)) \<longrightarrow> inpt_st r (fst (u n)) (fst (u (Suc n))) (x n) \<and> (\<forall>y. r (fst (u n)) (fst (u (Suc n))) (x n) y \<longrightarrow> inpt_st r' (snd (u n)) (snd (u (Suc n))) y)" (is "\<forall> n . ?p n \<longrightarrow> ?q n \<and> ?r n") then have "?q m" by (drule_tac n = m in inpt_str_comp_aux_a, simp) then obtain y where B: "r ((fst \<circ> u) m) ((fst \<circ> u) (Suc m)) (x m) y" by (auto simp add: inpt_st_def) from A have "?r m" by (drule_tac n = m in inpt_str_comp_aux_a, simp) from this B show "inpt_st (\<lambda>(u, v) (u', v') (x::'c) z. inpt_st r u u' x \<and> (\<forall>y. r u u' x y \<longrightarrow> inpt_st r' v v' y) \<and> (r u u' OO r' v v') x z) (u m) (u (Suc m)) (x m)" apply (case_tac "u m") apply (case_tac "u (Suc m)") apply (simp add: inpt_st_def) by (metis relcompp.relcompI) next fix m::nat assume " \<forall> m. inpt_st (\<lambda>(u, v) (u', v') (x) z. inpt_st r u u' x \<and> (\<forall>y. r u u' x y \<longrightarrow> inpt_st r' v v' y) \<and> (r u u' OO r' v v') x z) (u m) (u (Suc m)) (x m)" (is "\<forall> m . ?p m") then have "?p m" by simp then show " inpt_st r (fst (u m)) (fst (u (Suc m))) (x m)" apply (simp add: inpt_st_def) by (case_tac "u m", case_tac "u (Suc m)", simp) next fix m::nat and y :: 'e assume " \<forall> m. inpt_st (\<lambda>(u, v) (u', v') (x) z. inpt_st r u u' x \<and> (\<forall>y. r u u' x y \<longrightarrow> inpt_st r' v v' y) \<and> (r u u' OO r' v v') x z) (u m) (u (Suc m)) (x m)" (is "\<forall> m . ?p m") then have "?p m" by simp moreover assume "r (fst (u m)) (fst (u (Suc m))) (x m) y" ultimately show " inpt_st r' (snd (u m)) (snd (u (Suc m))) y" apply (simp add: inpt_st_def) by (case_tac "u m", case_tac "u (Suc m)", simp) qed lemma inpt_str_comp: "(prec_st (inpt_st r) r (fst \<circ> u) x \<and> (\<forall>y. (\<box> lft_rel_st r) (fst \<circ> u) x y \<longrightarrow> prec_st (inpt_st r') r' (snd \<circ> u) y)) = (\<box> (lft_pred_st (inpt_st (rel_st r r')))) u x" by (simp add: inpt_str_comp_a inpt_str_comp_b) lemma RSysTmp_inpt_comp: "u' \<in> init' \<Longrightarrow> SymSystem init (inpt_st r) r o SymSystem init'(inpt_st r') r' = SymSystem (zip_set init init') (inpt_st (rel_st r r')) (rel_st r r')" proof - assume A : "u' \<in> init'" have [simp]: "( \<lambda>x y. (case x of (x, xa) \<Rightarrow> (\<box> lft_pred_st (inpt_st (rel_st r r'))) x xa) \<and> (case x of (x, xa) \<Rightarrow> (\<box> lft_rel_st (\<lambda>(u, v) (u', v'). r u u' OO r' v v')) x xa) y) = (\<lambda>(x, y). (\<box> lft_rel_st (rel_st r r')) x y)" (is "?a = ?b") proof (auto simp add: fun_eq_iff always_def at_fun_def lft_pred_st_def lft_rel_st_def rel_st_def inpt_st_def) fix a :: "nat \<Rightarrow> 'e \<times> 'a" and b :: "nat \<Rightarrow> 'c" and x :: "nat \<Rightarrow> 'b" and xa :: nat assume "\<forall>xa::nat. (case a xa of (u::'e, v::'a) \<Rightarrow> \<lambda>(u'::'e, v'::'a). r u u' OO r' v v') (a (Suc xa)) (b xa) (x xa)" (is "\<forall> xa . ?P xa") then have A: "?P xa" by simp assume "\<forall>x . Ex ((case a x of (u, v) \<Rightarrow> \<lambda>(u', v') (x) z. Ex (r u u' x) \<and> (\<forall>y. r u u' x y \<longrightarrow> Ex (r' v v' y)) \<and> (r u u' OO r' v v') x z) (a (Suc x)) (b x))" (is "\<forall> xa . ?Q xa") then have "?Q xa" by simp from this and A show "(case a xa of (u, v) \<Rightarrow> \<lambda>(u', v') (x) z. Ex (r u u' x) \<and> (\<forall>y. r u u' x y \<longrightarrow> Ex (r' v v' y)) \<and> (r u u' OO r' v v') x z) (a (Suc xa)) (b xa) (x xa)" by (case_tac "a xa", case_tac "a (Suc xa)", simp) next fix a :: "nat \<Rightarrow> 'e \<times> 'a" and b :: "nat \<Rightarrow> 'c" and x :: "nat \<Rightarrow> 'b" and xa :: nat assume "\<forall>xa . (case a xa of (u::'e, v::'a) \<Rightarrow> \<lambda>(u'::'e, v'::'a) (x::'c) z::'b. Ex (r u u' x) \<and> (\<forall>y::'d. r u u' x y \<longrightarrow> Ex (r' v v' y)) \<and> (r u u' OO r' v v') x z) (a (Suc xa)) (b xa) (x xa)" (is "\<forall> xa . ?Q xa") then have "?Q xa" by simp then show "(case a xa of (u::'e, v::'a) \<Rightarrow> \<lambda>(u'::'e, v'::'a). r u u' OO r' v v') (a (Suc xa)) (b xa) (x xa)" by (case_tac "a xa", case_tac "a (Suc xa)", simp) qed from A have "SymSystem init (inpt_st r) r o SymSystem init'(inpt_st r') r' = [: z \<leadsto> u, x . fst \<circ> u \<in> init \<and> snd \<circ> u \<in> init' \<and> z = x :] \<circ> ({.u, x . prec_st (inpt_st r) r (fst \<circ> u) x \<and> (\<forall>y::nat \<Rightarrow> 'd. (\<box> lft_rel_st r) (fst \<circ> u) x y \<longrightarrow> prec_st (inpt_st r') r' (snd \<circ> u) y).} \<circ> [: (\<lambda>(u, x). ((\<box> lft_rel_st (\<lambda>(u, v) (u', v'). r u u' OO r' v v')) u x)) :])" by (unfold SymSystem_comp, simp add: comp_assoc) also have "... = [: z \<leadsto> u, x . fst \<circ> u \<in> init \<and> snd \<circ> u \<in> init' \<and> z = x :] \<circ> ({. x, y . (\<box> lft_pred_st (inpt_st (rel_st r r'))) x y .} \<circ> [: ?b :])" by (subst assert_demonic, simp add: inpt_str_comp) also have "... = SymSystem (zip_set init init') (inpt_st (rel_st r r')) (rel_st r r')" by (simp add: SymSystem_def prec_st_inpt comp_assoc zip_set_def) finally show ?thesis by simp qed definition "GrdSymSystem init r = [:z \<leadsto> u, x . u \<in> init \<and> z = x:] o trs (\<lambda> (u, x) y . (\<box>(lft_rel_st r)) u x y)" lemma inpt_always: "inpt (\<lambda>(x, y). (\<box> lft_rel_st r) x y) = (\<lambda>(x, y). (\<box> lft_pred_st (inpt_st r)) x y)" proof (auto simp add: fun_eq_iff) fix a :: "nat \<Rightarrow> 'a" and b :: "nat \<Rightarrow> 'b" assume "inpt (\<lambda>(x, y).(\<box> lft_rel_st r) x y) (a, b)" then show "(\<box> lft_pred_st (inpt_st r)) a b" by (auto simp add: inpt_def lft_pred_st_def inpt_st_def always_def at_fun_def lft_rel_st_def) next fix a :: "nat \<Rightarrow> 'a" and b :: "nat \<Rightarrow> 'b" let ?y = "\<lambda> n . (SOME y . r (a n) (a (Suc n)) (b n) y)" assume "(\<box> lft_pred_st (inpt_st r)) a b" then have "(\<box> lft_rel_st r) a b ?y" apply (auto simp add: always_def at_fun_def lft_rel_st_def inpt_st_def lft_pred_st_def) by (metis tfl_some) then show "inpt (\<lambda>(x, y). (\<box> lft_rel_st r) x y) (a, b)" by (auto simp add: inpt_def) qed lemma "GrdSymSystem init r = SymSystem init (inpt_st r) r" by (simp add: GrdSymSystem_def SymSystem_def trs_def prec_st_inpt comp_assoc inpt_always) subsection\<open>Example: COUNTER\<close> text\<open> In this section we introduce an example counter that counts how many times the input variable $x$ is true. The input is a sequence of boolen values and the output is a sequence of natural numbers. The output at some moment in time is the number of true values seen so far in the input. We defined the system counter in two different ways and we show that the two definitions are equivalent. The first definition takes the entire input sequence and it computes the corresponding output sequence. We introduce the second version of the counter as a reactive system based on a symbolic transition system. We use a local variable to record the number of true values seen so far, and initially the local variable is zero. At every step we increase the local variable if the input is true. The output of the system at every step is equal to the local variable. \<close> primrec count :: "bool trace \<Rightarrow> nat trace" where "count x 0 = (if x 0 then 1 else 0)" | "count x (Suc n) = (if x (Suc n) then count x n + 1 else count x n)" definition "Counter_global n = {.x . (\<forall> k . count x k \<le> n).} o [:x \<leadsto> y . y = count x:]" definition "prec_count M u u' x = (u \<le> M)" definition "rel_count u u' x y = ((x \<longrightarrow> u' = Suc u) \<and> (\<not> x \<longrightarrow> u' = u) \<and> y = u')" lemma counter_a_aux: "u 0 = 0 \<Longrightarrow> \<forall>i < n. (x i \<longrightarrow> u (Suc i) = Suc (u i)) \<and> (\<not> x i \<longrightarrow> u (Suc i) = u i) \<Longrightarrow> (\<forall> i < n . count x i = u (Suc i))" proof (induction n) case 0 show ?case by simp next case (Suc n) {fix j::nat assume "\<forall>i<Suc n. (x i \<longrightarrow> u (Suc i) = Suc (u i)) \<and> (\<not> x i \<longrightarrow> u (Suc i) = u i)" and "j < Suc n" and "u (0::nat) = (0::nat)" from this and Suc have "count x j = u (Suc j)" by (case_tac j, auto) } from Suc and this show ?case by auto qed lemma counter_b_aux: "u 0 = 0 \<Longrightarrow> \<forall>n. (xa n \<longrightarrow> u (Suc n) = Suc (u n)) \<and> (\<not> xa n \<longrightarrow> u (Suc n) = u n) \<and> xb n = u (Suc n) \<Longrightarrow> count xa n = u (Suc n)" by (induction n, simp_all) definition "COUNTER M = SymSystem {u . u 0 = 0} (prec_count M) rel_count" lemma "COUNTER = Counter_global" proof - have A:"(\<lambda>x y . \<exists>u::nat \<Rightarrow> nat. u (0::nat) = (0::nat) \<and> (\<box> lft_rel_st rel_count) u x y) = (\<lambda> x y . y = count x)" proof (simp add: fun_eq_iff lft_rel_st_def rel_count_def always_def at_fun_def, safe) fix x :: "nat \<Rightarrow> bool" and xa :: "nat \<Rightarrow> nat" and u:: "nat \<Rightarrow> nat" and xb :: nat assume A: "u 0 = 0" assume B: "\<forall>xb . (x xb \<longrightarrow> u (Suc xb) = Suc (u xb)) \<and> (\<not> x xb \<longrightarrow> u (Suc xb) = u xb) \<and> xa xb = u (Suc xb)" from A and this have "count x xb = xa xb" by (drule_tac counter_b_aux, auto) then show "xa xb = count x xb" by simp next fix x::"nat \<Rightarrow> bool" and xa::"nat \<Rightarrow> nat" define u where "u i = (if i = 0 then 0 else count x (i - 1))" for i assume B: "\<forall>xb::nat. xa xb = count x xb" {fix xb::nat from u_def and B have "u 0 = 0 \<and> ( (x xb \<longrightarrow> u (Suc xb) = Suc (u xb)) \<and> (\<not> x xb \<longrightarrow> u (Suc xb) = u xb) \<and> xa xb = u (Suc xb))" by (case_tac xb, auto) } then show "\<exists>u::nat \<Rightarrow> nat. u 0 = 0 \<and> (\<forall>xb. (x xb \<longrightarrow> u (Suc xb) = Suc (u xb)) \<and> (\<not> x xb \<longrightarrow> u (Suc xb) = u xb) \<and> xa xb = u (Suc xb))" by auto qed {fix x :: nat have "(\<lambda>xa . \<forall>u . u (0::nat) = (0::nat) \<longrightarrow> prec_st (prec_count x) rel_count u xa) = (\<lambda>xa::nat \<Rightarrow> bool. \<forall>k::nat. count xa k \<le> x)" proof (simp add: fun_eq_iff lft_rel_st_def prec_st_def until_def lft_pred_st_def prec_count_def at_fun_def inpt_st_def rel_count_def, safe) fix xa::"nat \<Rightarrow> bool" and k:: nat define uu where "uu i = (if i = 0 then 0 else count xa (i - 1))" for i assume "(\<forall>u . u 0 = 0 \<longrightarrow> (\<forall>xb . (\<exists>x<xb. xa x \<and> u (Suc x) \<noteq> Suc (u x) \<or> \<not> xa x \<and> u (Suc x) \<noteq> u x) \<or> u xb \<le> x))" (is "\<forall> u . ?s u") then have "?s uu" (is "?p \<longrightarrow> (\<forall>xb . (\<exists> x < xb . ?q xb x) \<or> ?r xb)") by auto from this and uu_def have "(\<forall>xb . (\<exists> x < xb . ?q xb x) \<or> ?r xb)" by simp then have "(\<exists> x < (Suc k) . ?q (Suc k) x) \<or> ?r (Suc k)" by simp then obtain xb where "xb < (Suc k) \<and> (?q (Suc k) xb \<or> ?r (Suc k))" by auto from this and uu_def show "count xa k \<le> x" by (case_tac xb, auto) next fix xa:: "nat \<Rightarrow> bool" and u::"nat \<Rightarrow> nat" and xaa::nat assume C: "\<forall>k::nat. count xa k \<le> x" assume A: "u (0::nat) = (0::nat)" assume B: "\<not> u xaa \<le> x" from A and B have D: "xaa > 0" by (metis le0 neq0_conv) from this and B and C have "count xa (xaa - 1) \<noteq> u xaa" by metis from this and D have E: "\<exists>i < xaa. count xa i \<noteq> u (Suc i)" by (metis One_nat_def Suc_diff_1 diff_Suc_less) have "u 0 = 0 \<Longrightarrow> \<forall>i<xaa. (xa i \<longrightarrow> u (Suc i) = Suc (u i)) \<and> (\<not> xa i \<longrightarrow> u (Suc i) = u i) \<Longrightarrow> \<forall>i<xaa. count xa i = u (Suc i)" by (rule counter_a_aux, simp) from this and A and E show "(\<exists>x<xaa. xa x \<and> u (Suc x) \<noteq> Suc (u x) \<or> \<not> xa x \<and> u (Suc x) \<noteq> u x)" by auto qed } note B = this show ?thesis by (simp add: fun_eq_iff COUNTER_def SymSystem_rel Counter_global_def A B) qed subsection\<open>Example: LIVE\<close> text\<open> The last example of this formalization introduces a system which does some local computation, and ensures some global liveness property. We show that this example is the fusion of a symbolic transition system and a demonic choice which ensures the liveness property of the output sequence. We also show that asumming some liveness property for the input, we can refine the example into an executable system that does not ensure the liveness property of the output on its own, but relies on the liveness of the input. \<close> definition "rel_ex u u' x y = (((x \<and> u' = u + (1::int)) \<or> (\<not> x \<and> u' = u - 1) \<or> u' = 0) \<and> (y = (u' = 0)))" definition "prec_ex u u' x = (-1 \<le> u \<and> u \<le> 3)" definition "LIVE = [:x \<leadsto> u, x' . u (0::nat) = 0 \<and> x = x':] o {.u, x . prec_st prec_ex rel_ex u x.} o [:u, x \<leadsto> y . (\<box>(\<lambda> u x y . rel_ex (u 0) (u 1) (x 0) (y 0))) u x y \<and> (\<box> (\<diamond> (\<lambda> y . y 0))) y :]" lemma LIVE_fusion: "LIVE = (SymSystem {u . u 0 = 0} prec_ex rel_ex) \<parallel> [:x \<leadsto> y . (\<box> (\<diamond> (\<lambda> y . y 0))) y:]" proof - define init where "init = {u . u (0::nat) = (0::int)}" then have A: "(\<lambda> i::nat . 0::int) \<in> init" by simp then have "([: x \<leadsto> (u, y). u \<in> init \<and> x = y :] \<circ> {.(x, y). prec_st prec_ex rel_ex x y .} \<circ> [: \<lambda>(x, y). (\<box> lft_rel_st rel_ex) x y :]) \<parallel> [: \<lambda>x. \<box> \<diamond> (\<lambda>y. y 0) :] = [: x \<leadsto> (u, y). u \<in> init \<and> x = y :] \<circ> {. (x, y). prec_st prec_ex rel_ex x y .} \<circ> [: (u, x) \<leadsto> y. (\<box> lft_rel_st rel_ex) u x y \<and> (\<box> \<diamond> (\<lambda>y. y 0)) y :]" by (unfold fusion_spec_local_a, auto) then show ?thesis by (simp add: init_def SymSystem_def) (auto simp add: LIVE_def lft_rel_st_def always_def at_fun_def) qed definition "preca_ex x = (x 1 = (\<not>x 0))" lemma monotonic_SymSystem[simp]: "mono (SymSystem init p r)" by (simp add: SymSystem_def) lemma event_ex_aux_a: "a 0 = (0::int) \<Longrightarrow> \<forall>n. xa (Suc n) = (\<not> xa n) \<Longrightarrow> \<forall>n. (xa n \<and> a (Suc n) = a n + 1 \<or> \<not> xa n \<and> a (Suc n) = a n - 1 \<or> a (Suc n) = 0) \<Longrightarrow> (a n = -1 \<longrightarrow> xa n) \<and> (a n = 1 \<longrightarrow> \<not> xa n) \<and> -1 \<le> a n \<and> a n \<le> 1" proof (induction n) case 0 show ?case by (metis "0.prems"(1) le_minus_one_simps(1) minus_zero zero_le_one zero_neq_neg_one) next case (Suc n) {assume "a (Suc n) = - (1::int)" from this and Suc have "xa (Suc n)" by (metis add.commute add_le_same_cancel2 not_one_le_zero zero_neq_neg_one)} note A = this {assume "a (Suc n) = (1::int)" and "xa (Suc n)" from this and Suc have "False" by (metis eq_iff le_iff_diff_le_0 not_one_le_zero)} note B = this {assume "a n \<noteq> - (1::int)" from this and Suc have " - (1::int) \<le> a (Suc n)" by (metis add.commute monoid_add_class.add.left_neutral le_less not_le right_minus uminus_add_conv_diff zle_add1_eq_le)} note C = this {assume "a n = - (1::int)" from this and Suc have " - (1::int) \<le> a (Suc n)" by (metis add.commute le_minus_one_simps(4) monoid_add_class.add.right_neutral not_le right_minus zle_add1_eq_le)} note D = this from C and D and Suc have E: " - (1::int) \<le> a (Suc n)" by auto from Suc have F: "a (Suc n) \<le> (1::int)" by (metis eq_iff int_one_le_iff_zero_less le_iff_diff_le_0 le_less not_le zle_add1_eq_le) from A B E F show ?case by auto qed lemma event_ex_aux: "a 0 = (0::int) \<Longrightarrow> \<forall>n. xa (Suc n) = (\<not> xa n) \<Longrightarrow> \<forall>n. (xa n \<and> a (Suc n) = a n + 1 \<or> \<not> xa n \<and> a (Suc n) = a n - 1 \<or> a (Suc n) = 0) \<Longrightarrow> (\<forall> n . (a n = -1 \<longrightarrow> xa n) \<and> (a n = 1 \<longrightarrow> \<not> xa n) \<and> -1 \<le> a n \<and> a n \<le> 1)" by (clarify, drule event_ex_aux_a, auto) lemma "{.\<box> preca_ex.} o LIVE \<le> SymSystem {u . u 0 = 0} prec_ex rel_ex" proof (unfold LIVE_fusion SymSystem_def, rule fusion_local_refinement, simp_all) fix z::"nat \<Rightarrow> bool" and u :: "nat \<Rightarrow> int" and x::"nat \<Rightarrow> bool" assume A: "u 0 = 0" assume "(\<box> preca_ex) z" then have B: "\<forall>x::nat. z (Suc x) = (\<not> z x)" by (auto simp add: preca_ex_def lft_rel_st_def rel_ex_def always_def at_fun_def) assume "(\<box> lft_rel_st rel_ex) u z x" then have C: "\<forall>xa . (z xa \<and> u (Suc xa) = u xa + 1 \<or> \<not> z xa \<and> u (Suc xa) = u xa - 1 \<or> u (Suc xa) = 0) \<and> x xa = (u (Suc xa) = 0)" by (auto simp add: preca_ex_def lft_rel_st_def rel_ex_def always_def at_fun_def) have D: "(\<forall> n . (u n = -1 \<longrightarrow> z n) \<and> (u n = 1 \<longrightarrow> \<not> z n) \<and> -1 \<le> u n \<and> u n \<le> 1)" by (cut_tac A B C, rule event_ex_aux, auto) { fix a::nat {assume "u (Suc a) = 0" from this A B C have "\<exists>b . u (Suc (a + b)) = 0" by (metis monoid_add_class.add.right_neutral)} note 1 = this {assume "u (Suc a) = -1" from this A B C D have "\<exists>b . u (Suc (a + b)) = 0" by (metis add_Suc_right diff_minus_eq_add diff_self monoid_add_class.add.right_neutral)} note 2 = this {assume "u (Suc a) = 1" from this A B C D have "\<exists>b . u (Suc (a + b)) = 0" by (metis add_Suc_right diff_self monoid_add_class.add.right_neutral)} note 3 = this from 1 2 3 A B C D have "\<exists>b . x (a + b)" by (simp, metis diff_0 int_one_le_iff_zero_less le_less not_le zle_diff1_eq) } then show "(\<box> \<diamond> (\<lambda>y . y 0)) x" by (simp add: always_def eventually_def preca_ex_def at_fun_def rel_ex_def lft_rel_st_def) qed end
module Issue524 %logging totality 20 data Bad = MkBad (Not Bad) hmmm : Bad -> Not Bad hmmm (MkBad n) = n ok : Not Bad ok bad = hmmm bad bad bad : Bad bad = MkBad ok total ohno : Void ohno = ok bad
#!/usr/sbin/julia import Primes: nextprime struct Data g::BigInt q::BigInt sks::Array{Array{BigInt}} pks::Array{BigInt} secret::Array{UInt8} end function create_key(len::Int, data::Data) sk::Array{BigInt} = [] pk::BigInt = 1 if length(data.pks) ≥ 10 println("Enough of key creation!") return end for i in 1:len push!(sk, rand(1:data.q)) pk = powermod(data.g, sk[i], data.q) * pk % data.q end push!(data.sks, sk) push!(data.pks, pk) println("Key created sucessfully!") end function create_secret(len::Int, data::Data) println("Tell me your secret: ") readbytes!(stdin, data.secret, len) end function show_data(data::Data) println("g = ", data.g) println("q = ", data.q) println("secret = ", data.secret) println("pks = ", data.pks) end function encrypt(flag::String, data::Data) i::Int = 0 c::BigInt = 1 d::BigInt = 1 r::BigInt = 1 s::Int = 0 if length(data.pks) < 4 println("Error: You don't have enough keys to encrypt.") return end if length(data.secret) ≠ length(flag) println("Error: Invalid secret. Make sure you create a secret first!") return end println("Which char index you want to encrypt?") try i = parse(Int, readline()) catch e i = -1 end if !(1 ≤ i ≤ length(flag)) println("Error: Invalid char index!") return end for ki in 1:2:(length(data.pks)-1) c = powermod(data.pks[ki], data.sks[ki + 1][i], data.q) * c % data.q d = powermod(data.pks[ki + 1], data.sks[ki][i], data.q) * d % data.q end r = rand(1:data.q) s = data.secret[i] ⊻ Int(flag[i]) c = powermod(data.g, s + r, data.q) * c % data.q d = powermod(data.g, r, data.q) * d % data.q println("Here we go: ", (c, d)) end function menu()::Int println() println("1- Create Key") println("2- Create Secret") println("3- Show data") println("4- Encrypt Flag") println("5- Exit") println() option::Int = 0 try option = parse(Int, readline()) catch e return -1 end return option end function main() flag::String = strip(open(f->read(f, String), "flag.txt")) data::Data = Data(2, nextprime(rand(0: big(2)^1024)), [], [], []) @assert length(flag) == 40 println("\nWelcome! What's your plan for today?") while true option::Int = menu() if option == 1 create_key(length(flag), data) elseif option == 2 create_secret(length(flag), data) elseif option == 3 show_data(data) elseif option == 4 encrypt(flag, data) elseif option == 5 println("Bye!") return else println("Invalid option!") end end end main()
import ReactorModel.Objects.Reactor.Theorems.Equivalent namespace ReactorType theorem UniqueIDs.updated [ReactorType.WellFounded α] {rtr₁ rtr₂ : α} (u : LawfulUpdate cpt i f rtr₁ rtr₂) (h : UniqueIDs rtr₁) : UniqueIDs rtr₂ where allEq m₁ m₂ := open Member in h.allEq (.fromLawfulUpdate m₁ u) (.fromLawfulUpdate m₂ u) ▸ Equivalent.from_lawfulUpdate u m₁ |>.trans (Equivalent.from_lawfulUpdate u m₂).symm |>.to_eq end ReactorType
{-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- We can use a propositional equality parametrized on Set instead of -- using two "different" equalities on D and M. module LogicalFramework.SetEquality where -- We add 3 to the fixities of the Agda standard library 0.8.1 (see -- Relation/Binary/Core.agda). infix 7 _≡D_ _≡M_ ------------------------------------------------------------------------------ -- Domain universe D postulate D : Set -- Propositional equality on D. data _≡D_ (x : D) : D → Set where refl : x ≡D x ≡D-thm : ∀ {d e} → d ≡D e → e ≡D d ≡D-thm refl = refl ------------------------------------------------------------------------------ -- Domain universe M data M : Set where zero : M succ : M → M -- Propositional equality on M. data _≡M_ (n : M) : M → Set where refl : n ≡M n ≡M-thm : ∀ {m n} → m ≡M n → n ≡M m ≡M-thm refl = refl ------------------------------------------------------------------------------ -- Propositional equality on Set. data _≡_ {A : Set}(a : A) : A → Set where refl : a ≡ a ≡-thm₁ : ∀ {d e : D} → d ≡ e → e ≡ d ≡-thm₁ refl = refl ≡-thm₂ : ∀ {m n : M} → m ≡ n → n ≡ m ≡-thm₂ refl = refl
lemma closed_Ints [simp]: "closed (\<int> :: 'a :: real_normed_algebra_1 set)"
C FUNCTION AGAUSS (NEXT) FUNCTION AGAUSS (XFUNCT, H2) C C AGAUSS - GAUSSIAN INTEGRATION IN WHICH 48 ABSCISSAS AND WEIGHT C FACTORS ARE USED. XFUNCT IS THE FUNCTION TO BE INTEGRATED AND C H2 IS THE ELEMENT LENGTH WHICH DETERMINES THE INTEGRATION C LIMITS. C SEE ABRAMOWITZ AND STEGUN, HANDBOOK OF MATHEMATICAL FUNCTIONS, C P 887 (EQU 25.4.30), P917 (WEIGHT AND ABSCISSA VALUES). C THE WEIGHTS AND ABSCISSAS ARE IN COMMON /WEIGHT/ AND ARE SET C IN SUBROUTINE GAIN IN A DATA STATEMENT. C COMMON /WAITS /HH (48), XI (48) C EXTERNAL XFUNCT C C C.....INITIALIZE, INTEGRATE, AND TEST................................... DATA TESTD / 5.0E-08/ M = 1 ANS = 0.0 CHECK = 1000.0 IF (H2 .EQ. 0.0) GO TO 125 100 AGAUSS = 0.0 IF (M .LT. 1) GO TO 130 DO 110 L = 1, M FL = L FM = M BOLIM = - H2 + 2.0 * H2 * (FL - 1.0) / FM UPLIM = - H2 + 2.0 * H2 * FL / FM SUM = 0.0 DO 105 I = 1, 48 S = 0.5 * ((UPLIM - BOLIM) * XI (I) + UPLIM + BOLIM) 105 SUM = SUM + HH (I) * XFUNCT (S) SUM = 0.5 * (UPLIM - BOLIM) * SUM 110 AGAUSS = AGAUSS + SUM 130 CONTINUE TEST = ABS ((AGAUSS - ANS) / AGAUSS) IF (TEST .GT. 0.0005) GO TO 115 IF (TEST .LE. TESTD) GO TO 125 115 IF (M .GE. 10) GO TO 120 CHECK = TEST - TESTD M = M + 1 ANS = AGAUSS GO TO 100 120 IF (CHECK .GE. TEST) GO TO 125 AGAUSS = ANS 125 RETURN END
/- Copyright (c) 2021 Kevin Buzzard. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kevin Buzzard -/ import algebra.module.basic import linear_algebra.finsupp import linear_algebra.basis /-! # Projective modules This file contains a definition of a projective module, the proof that our definition is equivalent to a lifting property, and the proof that all free modules are projective. ## Main definitions Let `R` be a ring (or a semiring) and let `M` be an `R`-module. * `is_projective R M` : the proposition saying that `M` is a projective `R`-module. ## Main theorems * `is_projective.lifting_property` : a map from a projective module can be lifted along a surjection. * `is_projective.of_lifting_property` : If for all R-module surjections `A →ₗ B`, all maps `M →ₗ B` lift to `M →ₗ A`, then `M` is projective. * `is_projective.of_free` : Free modules are projective ## Implementation notes The actual definition of projective we use is that the natural R-module map from the free R-module on the type M down to M splits. This is more convenient than certain other definitions which involve quantifying over universes, and also universe-polymorphic (the ring and module can be in different universes). Everything works for semirings and modules except that apparently we don't have free modules over semirings, so here we stick to rings. ## References https://en.wikipedia.org/wiki/Projective_module ## TODO - Direct sum of two projective modules is projective. - Arbitrary sum of projective modules is projective. - Any module admits a surjection from a projective module. All of these should be relatively straightforward. ## Tags projective module -/ universes u v /- The actual implementation we choose: `P` is projective if the natural surjection from the free `R`-module on `P` to `P` splits. -/ /-- An R-module is projective if it is a direct summand of a free module, or equivalently if maps from the module lift along surjections. There are several other equivalent definitions. -/ def is_projective (R : Type u) [semiring R] (P : Type v) [add_comm_monoid P] [module R P] : Prop := ∃ s : P →ₗ[R] (P →₀ R), function.left_inverse (finsupp.total P P R id) s namespace is_projective section semiring variables {R : Type u} [semiring R] {P : Type v} [add_comm_monoid P] [module R P] {M : Type*} [add_comm_group M] [module R M] {N : Type*} [add_comm_group N] [module R N] /-- A projective R-module has the property that maps from it lift along surjections. -/ theorem lifting_property (h : is_projective R P) (f : M →ₗ[R] N) (g : P →ₗ[R] N) (hf : function.surjective f) : ∃ (h : P →ₗ[R] M), f.comp h = g := begin /- Here's the first step of the proof. Recall that `X →₀ R` is Lean's way of talking about the free `R`-module on a type `X`. The universal property `finsupp.total` says that to a map `X → N` from a type to an `R`-module, we get an associated R-module map `(X →₀ R) →ₗ N`. Apply this to a (noncomputable) map `P → M` coming from the map `P →ₗ N` and a random splitting of the surjection `M →ₗ N`, and we get a map `φ : (P →₀ R) →ₗ M`. -/ let φ : (P →₀ R) →ₗ[R] M := finsupp.total _ _ _ (λ p, function.surj_inv hf (g p)), -- By projectivity we have a map `P →ₗ (P →₀ R)`; cases h with s hs, -- Compose to get `P →ₗ M`. This works. use φ.comp s, ext p, conv_rhs {rw ← hs p}, simp [φ, finsupp.total_apply, function.surj_inv_eq hf], end /-- A module which satisfies the universal property is projective. Note that the universe variables in `huniv` are somewhat restricted. -/ theorem of_lifting_property {R : Type u} [semiring R] {P : Type v} [add_comm_monoid P] [module R P] -- If for all surjections of `R`-modules `M →ₗ N`, all maps `P →ₗ N` lift to `P →ₗ M`, (huniv : ∀ {M : Type (max v u)} {N : Type v} [add_comm_monoid M] [add_comm_monoid N], by exactI ∀ [module R M] [module R N], by exactI ∀ (f : M →ₗ[R] N) (g : P →ₗ[R] N), function.surjective f → ∃ (h : P →ₗ[R] M), f.comp h = g) : -- then `P` is projective. is_projective R P := begin -- let `s` be the universal map `(P →₀ R) →ₗ P` coming from the identity map `P →ₗ P`. obtain ⟨s, hs⟩ : ∃ (s : P →ₗ[R] P →₀ R), (finsupp.total P P R id).comp s = linear_map.id := huniv (finsupp.total P P R (id : P → P)) (linear_map.id : P →ₗ[R] P) _, -- This `s` works. { use s, rwa linear_map.ext_iff at hs }, { intro p, use finsupp.single p 1, simp }, end end semiring section ring variables {R : Type u} [ring R] {P : Type v} [add_comm_group P] [module R P] /-- Free modules are projective. -/ theorem of_free {ι : Type*} {b : ι → P} (hb : is_basis R b) : is_projective R P := begin -- need P →ₗ (P →₀ R) for definition of projective. -- get it from `ι → (P →₀ R)` coming from `b`. use hb.constr (λ i, finsupp.single (b i) 1), intro m, simp only [hb.constr_apply, mul_one, id.def, finsupp.smul_single', finsupp.total_single, linear_map.map_finsupp_sum], exact hb.total_repr m, end end ring end is_projective
[STATEMENT] lemma class_add_subtype: "\<lbrakk> subtype P x y; \<not> is_class P C \<rbrakk> \<Longrightarrow> subtype (class_add P (C, cdec)) x y" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>subtype P x y; \<not> is_class P C\<rbrakk> \<Longrightarrow> subtype (class_add P (C, cdec)) x y [PROOF STEP] proof(induct rule: widen.induct) [PROOF STATE] proof (state) goal (3 subgoals): 1. \<And>T. \<not> is_class P C \<Longrightarrow> subtype (class_add P (C, cdec)) T T 2. \<And>Ca D. \<lbrakk>P \<turnstile> Ca \<preceq>\<^sup>* D; \<not> is_class P C\<rbrakk> \<Longrightarrow> subtype (class_add P (C, cdec)) (Class Ca) (Class D) 3. \<And>Ca. \<not> is_class P C \<Longrightarrow> subtype (class_add P (C, cdec)) NT (Class Ca) [PROOF STEP] case (widen_subcls C D) [PROOF STATE] proof (state) this: P \<turnstile> C \<preceq>\<^sup>* D \<not> is_class P C goal (3 subgoals): 1. \<And>T. \<not> is_class P C \<Longrightarrow> subtype (class_add P (C, cdec)) T T 2. \<And>Ca D. \<lbrakk>P \<turnstile> Ca \<preceq>\<^sup>* D; \<not> is_class P C\<rbrakk> \<Longrightarrow> subtype (class_add P (C, cdec)) (Class Ca) (Class D) 3. \<And>Ca. \<not> is_class P C \<Longrightarrow> subtype (class_add P (C, cdec)) NT (Class Ca) [PROOF STEP] then [PROOF STATE] proof (chain) picking this: P \<turnstile> C \<preceq>\<^sup>* D \<not> is_class P C [PROOF STEP] show ?case [PROOF STATE] proof (prove) using this: P \<turnstile> C \<preceq>\<^sup>* D \<not> is_class P C goal (1 subgoal): 1. subtype (class_add P (C, cdec)) (Class C) (Class D) [PROOF STEP] using class_add_subcls [PROOF STATE] proof (prove) using this: P \<turnstile> C \<preceq>\<^sup>* D \<not> is_class P C \<lbrakk>?P \<turnstile> ?D \<preceq>\<^sup>* ?D'; \<not> is_class ?P ?C\<rbrakk> \<Longrightarrow> class_add ?P (?C, ?cdec) \<turnstile> ?D \<preceq>\<^sup>* ?D' goal (1 subgoal): 1. subtype (class_add P (C, cdec)) (Class C) (Class D) [PROOF STEP] by simp [PROOF STATE] proof (state) this: subtype (class_add P (C, cdec)) (Class C) (Class D) goal (2 subgoals): 1. \<And>T. \<not> is_class P C \<Longrightarrow> subtype (class_add P (C, cdec)) T T 2. \<And>Ca. \<not> is_class P C \<Longrightarrow> subtype (class_add P (C, cdec)) NT (Class Ca) [PROOF STEP] qed(simp+)
[STATEMENT] lemma set_spmf_S [simp]: "y \<in> set_spmf I \<longrightarrow> set_spmf (S (fst y)) = range (fst y)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. y \<in> set_spmf I \<longrightarrow> set_spmf (S (fst y)) = range (fst y) [PROOF STEP] by (simp add: S_def finite_range)
You may have heard about “black hat” SEO tactics. Essentially, these tactics take advantage of the traditional use of keywords and key phrases and warps them through different techniques that are often called “keyword stuffing”. In essence, black hat techniques violate the spirit in of the current system. For several years Google has been focusing much of their effort to eliminating black hat SEO techniques. With so much literature pouring out about how such tricks are being dealt with, it may surprise you to know that not only are black hat SEO still around, but they are still alive and working for thousands of online business owners this year. The reason why black hat tactics are still being used is a simple one. They still generate a great deal of sales. You see it in the blogs, forums and other places where marketers who use these techniques tell the world that sales are still pouring into their websites. Even the efforts of the vaunted Google Penguin which highlights the online businesses that use such tactics, the money they generate keeps pouring in not because of their ranking, but because every time such tactics get used the sales increase or the leads come in by the bushel. Amazingly enough, there are still many websites using black hat techniques that still have high rankings even with their bad profiles. The new algorithms sported by Google are still not good enough to catch all of these businesses. For the past year, Google has focused the efforts of their spam team and associated contractors to check forums used by black hat online business and other places in order to see what SEO tactics they are using and eliminate them. This is one reason why the blog networks which was a haven for black hat businesses was caught. However, despite all of their efforts and Google changing their algorithms to throw off these black hat tactics, it still is not enough. Negative SEO is still around although Google incorporated RankBrain and black hat SEO, for all of its connotations, still works in selling products. You can always use disavow links tool to ignore bad links pointing to your website. Why exactly is a webpage that contains bad backlinks can still be ranked so highly in today’s internet world? There is no simple answer to that question since there are many reasons why it continues to be true. Unfortunately, too many online business owners who attempt black hat tactics do so poorly and get caught easily. One of blackhat SEO is called wikipedia injection. As soon as those large SEO websites post an article, right away they inject their link on wikipedia to keep their ranking stable. Just check seo related posts on wikipedia, there are a lot of websites from small to large ones injected their links there. Wikipedia’s consultants are not doing their job right to remove them. so these black hat seo still is a trend among SEOs. These SEO companies keep monitoring their links on wikipedia so as soon as one removes their links, they replace them. One example is if you have a forum or guest blog, your first instinct would be to spread that to the most popular forums or WordPress commenting sections because all WordPress bloggers will see your ad when they want to publish their articles. This is how many marketers land a large number of sales in a single night I am talking about spreading over 2 million or more sites. There are more ways of landing sales. I would recommend using Google Adwords PPC and Facebook advertising. Because you’re playing your cards right and if you use the right PPC ad management strategies, you will generate leads and sales. As forum posting, I am not suggesting to use this blackhat tactic because it will hurt your website’s ranking, and it won’t work but from sales perspective large niche forum posting helps with sales if it is done right. Blog commenting is another way of driving in sales, but if you want to use it for black hat SEO then this also won’t help with ranking anymore. Bottom line, black hat SEO can get your website banned and it’s not worth it. Remember! It’s not about ranking, its about getting more targeted people see your products or services and buy from you. This is why you should use whitehat SEO, paid advertisement and social media marketing strategies. If you run an ecommerce website, use influencer marketing strategies to get more love to your products and services.
lemma closed_substandard: "closed {x::'a::euclidean_space. \<forall>i\<in>Basis. P i \<longrightarrow> x\<bullet>i = 0}" (is "closed ?A")
lemma and_trans (P Q R : Prop) : P ∧ Q → Q ∧ R → P ∧ R := begin intro h1, cases h1, intro h2, cases h2, split, exact h1_left, exact h2_right, end
\chapter{Lorem ipsum} Hi there, here are some basic examples. \input{Chapters/Chapter1/Section1} \input{Chapters/Chapter1/Section2} \input{Chapters/Chapter1/Section3}
lemma open_imp_locally_compact: fixes S :: "'a :: heine_borel set" assumes "open S" shows "locally compact S"
Module Type LocalNat. Inductive nat : Set := | O : nat | S : nat->nat. Check nat. Check O. Check S. End LocalNat. Print nat. Print le. Theorem zero_leq_three: 0 <= 3. Proof. constructor 2. constructor 2. constructor 2. constructor 1. Qed. Print zero_leq_three. Lemma zero_leq_three': 0 <= 3. repeat constructor. Qed. Lemma zero_lt_three : 0 < 3. Proof. unfold lt. repeat constructor. Qed. Require Import List. Print list. Check list. Check (nil (A:=nat)). Check (nil (A:= nat -> nat)). Check (fun A: Set => (cons (A:=A))). Check (cons 3 (cons 2 nil)). Require Import Bvector. Print Vector.t. Check (Vector.nil nat). Check (fun (A:Set)(a:A)=> Vector.cons _ a _ (Vector.nil _)). Check (Vector.cons _ 5 _ (Vector.cons _ 3 _ (Vector.nil _))). Lemma eq_3_3 : 2 + 1 = 3. Proof. reflexivity. Qed. Print eq_3_3. Lemma eq_proof_proof : refl_equal (2*6) = refl_equal (3*4). Proof. reflexivity. Qed. Print eq_proof_proof. Lemma eq_lt_le : ( 2 < 4) = (3 <= 4). Proof. reflexivity. Qed. Lemma eq_nat_nat : nat = nat. Proof. reflexivity. Qed. Lemma eq_Set_Set : Set = Set. Proof. reflexivity. Qed. Lemma eq_Type_Type : Type = Type. Proof. reflexivity. Qed. Check (2 + 1 = 3). Check (Type = Type). Goal Type = Type. reflexivity. Qed. Print or. Print and. Print sumbool. Print ex. Require Import ZArith. Require Import Compare_dec. Check le_lt_dec. Definition max (n p :nat) := match le_lt_dec n p with | left _ => p | right _ => n end. Theorem le_max : forall n p, n <= p -> max n p = p. Proof. intros n p ; unfold max ; case (le_lt_dec n p); simpl. trivial. intros; absurd (p < p); eauto with arith. Qed. Require Coq.extraction.Extraction. Extraction max. Inductive tree(A:Set) : Set := node : A -> forest A -> tree A with forest (A: Set) : Set := nochild : forest A | addchild : tree A -> forest A -> forest A. Inductive even : nat->Prop := evenO : even O | evenS : forall n, odd n -> even (S n) with odd : nat->Prop := oddS : forall n, even n -> odd (S n). Lemma odd_49 : odd (7 * 7). simpl; repeat constructor. Qed. Definition nat_case := fun (Q : Type)(g0 : Q)(g1 : nat -> Q)(n:nat) => match n return Q with | 0 => g0 | S p => g1 p end. Eval simpl in (nat_case nat 0 (fun p => p) 34). Eval simpl in (fun g0 g1 => nat_case nat g0 g1 34). Eval simpl in (fun g0 g1 => nat_case nat g0 g1 0). Definition pred (n:nat) := match n with O => O | S m => m end. Eval simpl in pred 56. Eval simpl in pred 0. Eval simpl in fun p => pred (S p). Definition xorb (b1 b2:bool) := match b1, b2 with | false, true => true | true, false => true | _ , _ => false end. Definition pred_spec (n:nat) := {m:nat | n=0 /\ m=0 \/ n = S m}. Definition predecessor : forall n:nat, pred_spec n. intro n;case n. unfold pred_spec;exists 0;auto. unfold pred_spec; intro n0;exists n0; auto. Defined. Print predecessor. Extraction predecessor. Theorem nat_expand : forall n:nat, n = match n with 0 => 0 | S p => S p end. intro n;case n;simpl;auto. Qed. Check (fun p:False => match p return 2=3 with end). Theorem fromFalse : False -> 0=1. intro absurd. contradiction. Qed. Section equality_elimination. Variables (A: Type) (a b : A) (p : a = b) (Q : A -> Type). Check (fun H : Q a => match p in (eq _ y) return Q y with refl_equal => H end). End equality_elimination. Theorem trans : forall n m p:nat, n=m -> m=p -> n=p. Proof. intros n m p eqnm. case eqnm. trivial. Qed. Lemma Rw : forall x y: nat, y = y * x -> y * x * x = y. intros x y e; do 2 rewrite <- e. reflexivity. Qed. Require Import Arith. Check mult_1_l. (* mult_1_l : forall n : nat, 1 * n = n *) Check mult_plus_distr_r. (* mult_plus_distr_r : forall n m p : nat, (n + m) * p = n * p + m * p *) Lemma mult_distr_S : forall n p : nat, n * p + p = (S n)* p. simpl;auto with arith. Qed. Lemma four_n : forall n:nat, n+n+n+n = 4*n. intro n;rewrite <- (mult_1_l n). Undo. intro n; pattern n at 1. rewrite <- mult_1_l. repeat rewrite mult_distr_S. trivial. Qed. Section Le_case_analysis. Variables (n p : nat) (H : n <= p) (Q : nat -> Prop) (H0 : Q n) (HS : forall m, n <= m -> Q (S m)). Check ( match H in (_ <= q) return (Q q) with | le_n _ => H0 | le_S _ m Hm => HS m Hm end ). End Le_case_analysis. Lemma predecessor_of_positive : forall n, 1 <= n -> exists p:nat, n = S p. Proof. intros n H; case H. exists 0; trivial. intros m Hm; exists m;trivial. Qed. Definition Vtail_total (A : Set) (n : nat) (v : Vector.t A n) : Vector.t A (pred n):= match v in (Vector.t _ n0) return (Vector.t A (pred n0)) with | Vector.nil _ => Vector.nil A | Vector.cons _ _ n0 v0 => v0 end. Definition Vtail' (A:Set)(n:nat)(v:Vector.t A n) : Vector.t A (pred n). case v. simpl. exact (Vector.nil A). simpl. auto. Defined. (* Inductive Lambda : Set := lambda : (Lambda -> False) -> Lambda. Error: Non strictly positive occurrence of "Lambda" in "(Lambda -> False) -> Lambda" *) Section Paradox. Variable Lambda : Set. Variable lambda : (Lambda -> False) ->Lambda. Variable matchL : Lambda -> forall Q:Prop, ((Lambda ->False) -> Q) -> Q. (* understand matchL Q l (fun h : Lambda -> False => t) as match l return Q with lambda h => t end *) Definition application (f x: Lambda) :False := matchL f False (fun h => h x). Definition Delta : Lambda := lambda (fun x : Lambda => application x x). Definition loop : False := application Delta Delta. Theorem two_is_three : 2 = 3. Proof. elim loop. Qed. End Paradox. Require Import ZArith. Inductive itree : Set := | ileaf : itree | inode : Z-> (nat -> itree) -> itree. Definition isingle l := inode l (fun i => ileaf). Definition t1 := inode 0 (fun n => isingle (Z.of_nat (2*n))). Definition t2 := inode 0 (fun n : nat => inode (Z.of_nat n) (fun p => isingle (Z.of_nat (n*p)))). Inductive itree_le : itree-> itree -> Prop := | le_leaf : forall t, itree_le ileaf t | le_node : forall l l' s s', Z.le l l' -> (forall i, exists j:nat, itree_le (s i) (s' j)) -> itree_le (inode l s) (inode l' s'). Theorem itree_le_trans : forall t t', itree_le t t' -> forall t'', itree_le t' t'' -> itree_le t t''. induction t. constructor 1. intros t'; case t'. inversion 1. intros z0 i0 H0. intro t'';case t''. inversion 1. intros. inversion_clear H1. constructor 2. inversion_clear H0;eauto with zarith. inversion_clear H0. intro i2; case (H4 i2). intros. generalize (H i2 _ H0). intros. case (H3 x);intros. generalize (H5 _ H6). exists x0;auto. Qed. Inductive itree_le' : itree-> itree -> Prop := | le_leaf' : forall t, itree_le' ileaf t | le_node' : forall l l' s s' g, Z.le l l' -> (forall i, itree_le' (s i) (s' (g i))) -> itree_le' (inode l s) (inode l' s'). Lemma t1_le_t2 : itree_le t1 t2. unfold t1, t2. constructor. auto with zarith. intro i; exists (2 * i). unfold isingle. constructor. auto with zarith. exists i;constructor. Qed. Lemma t1_le'_t2 : itree_le' t1 t2. unfold t1, t2. constructor 2 with (fun i : nat => 2 * i). auto with zarith. unfold isingle; intro i ; constructor 2 with (fun i :nat => i). auto with zarith. constructor . Qed. Require Import List. Inductive ltree (A:Set) : Set := lnode : A -> list (ltree A) -> ltree A. Inductive prop : Prop := prop_intro : Prop -> prop. Lemma prop_inject: prop. Proof prop_intro prop. Inductive ex_Prop (P : Prop -> Prop) : Prop := exP_intro : forall X : Prop, P X -> ex_Prop P. Lemma ex_Prop_inhabitant : ex_Prop (fun P => P -> P). Proof. exists (ex_Prop (fun P => P -> P)). trivial. Qed. Fail Check (fun (P:Prop->Prop)(p: ex_Prop P) => match p with exP_intro X HX => X end). (* Error: Incorrect elimination of "p" in the inductive type "ex_Prop", the return type has sort "Type" while it should be "Prop" Elimination of an inductive object of sort "Prop" is not allowed on a predicate in sort "Type" because proofs can be eliminated only to build proofs *) Fail Check (match prop_inject with (prop_intro p) => p end). (* Error: Incorrect elimination of "prop_inject" in the inductive type "prop", the return type has sort "Type" while it should be "Prop" Elimination of an inductive object of sort "Prop" is not allowed on a predicate in sort "Type" because proofs can be eliminated only to build proofs *) Print prop_inject. (* prop_inject = prop_inject = prop_intro prop : prop *) Inductive typ : Type := typ_intro : Type -> typ. Definition typ_inject: typ. split. Fail exact typ. (* Error: Universe Inconsistency. *) Abort. Fail Inductive aSet : Set := aSet_intro: Set -> aSet. (* User error: Large non-propositional inductive types must be in Type *) Inductive ex_Set (P : Set -> Prop) : Type := exS_intro : forall X : Set, P X -> ex_Set P. Module Type Version1. Inductive comes_from_the_left (P Q:Prop): P \/ Q -> Prop := c1 : forall p, comes_from_the_left P Q (or_introl (A:=P) Q p). Goal (comes_from_the_left _ _ (or_introl True I)). split. Qed. Goal ~(comes_from_the_left _ _ (or_intror True I)). red;inversion 1. (* discriminate H0. *) Abort. End Version1. Fail Definition comes_from_the_left (P Q:Prop)(H:P \/ Q): Prop := match H with | or_introl p => True | or_intror q => False end. (* Error: Incorrect elimination of "H" in the inductive type "or", the return type has sort "Type" while it should be "Prop" Elimination of an inductive object of sort "Prop" is not allowed on a predicate in sort "Type" because proofs can be eliminated only to build proofs *) Definition comes_from_the_left_sumbool (P Q:Prop)(x:{P}+{Q}): Prop := match x with | left p => True | right q => False end. Close Scope Z_scope. Theorem S_is_not_O : forall n, S n <> 0. Set Nested Proofs Allowed. Definition Is_zero (x:nat):= match x with | 0 => True | _ => False end. Lemma O_is_zero : forall m, m = 0 -> Is_zero m. Proof. intros m H; subst m. (* ============================ Is_zero 0 *) simpl;trivial. Qed. red; intros n Hn. apply O_is_zero with (m := S n). assumption. Qed. Theorem disc2 : forall n, S (S n) <> 1. Proof. intros n Hn; discriminate. Qed. Theorem disc3 : forall n, S (S n) = 0 -> forall Q:Prop, Q. Proof. intros n Hn Q. discriminate. Qed. Theorem inj_succ : forall n m, S n = S m -> n = m. Proof. Lemma inj_pred : forall n m, n = m -> pred n = pred m. Proof. intros n m eq_n_m. rewrite eq_n_m. trivial. Qed. intros n m eq_Sn_Sm. apply inj_pred with (n:= S n) (m := S m); assumption. Qed. Lemma list_inject : forall (A:Set)(a b :A)(l l':list A), a :: b :: l = b :: a :: l' -> a = b /\ l = l'. Proof. intros A a b l l' e. injection e. auto. Qed. Theorem not_le_Sn_0 : forall n:nat, ~ (S n <= 0). Proof. red; intros n H. case H. Undo. Lemma not_le_Sn_0_with_constraints : forall n p , S n <= p -> p = 0 -> False. Proof. intros n p H; case H ; intros; discriminate. Qed. eapply not_le_Sn_0_with_constraints; eauto. Qed. Theorem not_le_Sn_0' : forall n:nat, ~ (S n <= 0). Proof. red; intros n H ; inversion H. Qed. Derive Inversion le_Sn_0_inv with (forall n :nat, S n <= 0). Check le_Sn_0_inv. Theorem le_Sn_0'' : forall n p : nat, ~ S n <= 0 . Proof. intros n p H; inversion H using le_Sn_0_inv. Qed. Derive Inversion_clear le_Sn_0_inv' with (forall n :nat, S n <= 0). Check le_Sn_0_inv'. Theorem le_reverse_rules : forall n m:nat, n <= m -> n = m \/ exists p, n <= p /\ m = S p. Proof. intros n m H; inversion H. left;trivial. right; exists m0; split; trivial. Restart. intros n m H; inversion_clear H. left;trivial. right; exists m0; split; trivial. Qed. Inductive ArithExp : Set := Zero : ArithExp | Succ : ArithExp -> ArithExp | Plus : ArithExp -> ArithExp -> ArithExp. Inductive RewriteRel : ArithExp -> ArithExp -> Prop := RewSucc : forall e1 e2 :ArithExp, RewriteRel e1 e2 -> RewriteRel (Succ e1) (Succ e2) | RewPlus0 : forall e:ArithExp, RewriteRel (Plus Zero e) e | RewPlusS : forall e1 e2:ArithExp, RewriteRel e1 e2 -> RewriteRel (Plus (Succ e1) e2) (Succ (Plus e1 e2)). Fixpoint plus (n p:nat) {struct n} : nat := match n with | 0 => p | S m => S (plus m p) end. Fixpoint plus' (n p:nat) {struct p} : nat := match p with | 0 => n | S q => S (plus' n q) end. Fixpoint plus'' (n p:nat) {struct n} : nat := match n with | 0 => p | S m => plus'' m (S p) end. Module Type even_test_v1. Fixpoint even_test (n:nat) : bool := match n with 0 => true | 1 => false | S (S p) => even_test p end. End even_test_v1. Module even_test_v2. Fixpoint even_test (n:nat) : bool := match n with | 0 => true | S p => odd_test p end with odd_test (n:nat) : bool := match n with | 0 => false | S p => even_test p end. Eval simpl in even_test. Eval simpl in (fun x : nat => even_test x). Eval simpl in (fun x : nat => plus 5 x). Eval simpl in (fun x : nat => even_test (plus 5 x)). Eval simpl in (fun x : nat => even_test (plus x 5)). End even_test_v2. Section Principle_of_Induction. Variable P : nat -> Prop. Hypothesis base_case : P 0. Hypothesis inductive_step : forall n:nat, P n -> P (S n). Fixpoint nat_ind (n:nat) : (P n) := match n return P n with | 0 => base_case | S m => inductive_step m (nat_ind m) end. End Principle_of_Induction. Scheme Even_induction := Minimality for even Sort Prop with Odd_induction := Minimality for odd Sort Prop. Theorem even_plus_four : forall n:nat, even n -> even (4+n). Proof. intros n H. elim H using Even_induction with (P0 := fun n => odd (4+n)); simpl;repeat constructor;assumption. Qed. Section Principle_of_Double_Induction. Variable P : nat -> nat ->Prop. Hypothesis base_case1 : forall x:nat, P 0 x. Hypothesis base_case2 : forall x:nat, P (S x) 0. Hypothesis inductive_step : forall n m:nat, P n m -> P (S n) (S m). Fixpoint nat_double_ind (n m:nat){struct n} : P n m := match n, m return P n m with | 0 , x => base_case1 x | (S x), 0 => base_case2 x | (S x), (S y) => inductive_step x y (nat_double_ind x y) end. End Principle_of_Double_Induction. Section Principle_of_Double_Recursion. Variable P : nat -> nat -> Set. Hypothesis base_case1 : forall x:nat, P 0 x. Hypothesis base_case2 : forall x:nat, P (S x) 0. Hypothesis inductive_step : forall n m:nat, P n m -> P (S n) (S m). Fixpoint nat_double_rec (n m:nat){struct n} : P n m := match n, m return P n m with | 0 , x => base_case1 x | (S x), 0 => base_case2 x | (S x), (S y) => inductive_step x y (nat_double_rec x y) end. End Principle_of_Double_Recursion. Definition min : nat -> nat -> nat := nat_double_rec (fun (x y:nat) => nat) (fun (x:nat) => 0) (fun (y:nat) => 0) (fun (x y r:nat) => S r). Eval compute in (min 5 8). Eval compute in (min 8 5). Lemma not_circular : forall n:nat, n <> S n. Proof. intro n. apply nat_ind with (P:= fun n => n <> S n). discriminate. red; intros n0 Hn0 eqn0Sn0;injection eqn0Sn0;auto. Qed. Definition eq_nat_dec : forall n p:nat , {n=p}+{n <> p}. Proof. intros n p. apply nat_double_rec with (P:= fun (n q:nat) => {q=p}+{q <> p}). Undo. pattern p,n. elim n using nat_double_rec. destruct x; auto. destruct x; auto. intros n0 m H; case H. intro eq; rewrite eq ; auto. intro neg; right; red ; injection 1; auto. Defined. Definition eq_nat_dec' : forall n p:nat, {n=p}+{n <> p}. decide equality. Defined. Print Acc. Require Import Minus. Fail Fixpoint div (x y:nat){struct x}: nat := if eq_nat_dec x 0 then 0 else if eq_nat_dec y 0 then x else S (div (x-y) y). (* Error: Recursive definition of div is ill-formed. In environment div : nat -> nat -> nat x : nat y : nat _ : x <> 0 _ : y <> 0 Recursive call to div has principal argument equal to "x - y" instead of a subterm of x *) Lemma minus_smaller_S: forall x y:nat, x - y < S x. Proof. intros x y; pattern y, x; elim x using nat_double_ind. destruct x0; auto with arith. simpl; auto with arith. simpl; auto with arith. Qed. Lemma minus_smaller_positive : forall x y:nat, x <>0 -> y <> 0 -> x - y < x. Proof. destruct x; destruct y; ( simpl;intros; apply minus_smaller_S || intros; absurd (0=0); auto). Qed. Definition minus_decrease : forall x y:nat, Acc lt x -> x <> 0 -> y <> 0 -> Acc lt (x-y). Proof. intros x y H; case H. intros Hz posz posy. apply Hz; apply minus_smaller_positive; assumption. Defined. Print minus_decrease. Fixpoint div_aux (x y:nat)(H: Acc lt x):nat. refine (if eq_nat_dec x 0 then 0 else if eq_nat_dec y 0 then y else div_aux (x-y) y _). apply (minus_decrease x y H);assumption. Defined. Print div_aux. (* div_aux = (fix div_aux (x y : nat) (H : Acc lt x) {struct H} : nat := match eq_nat_dec x 0 with | left _ => 0 | right _ => match eq_nat_dec y 0 with | left _ => y | right _0 => div_aux (x - y) y (minus_decrease x y H _ _0) end end) : forall x : nat, nat -> Acc lt x -> nat *) Require Import Wf_nat. Definition div x y := div_aux x y (lt_wf x). Extraction div. (* let div x y = div_aux x y *) Extraction div_aux. (* let rec div_aux x y = match eq_nat_dec x O with | Left -> O | Right -> (match eq_nat_dec y O with | Left -> y | Right -> div_aux (minus x y) y) *) Lemma vector0_is_vnil : forall (A:Set)(v:Vector.t A 0), v = Vector.nil A. Proof. intros A v;inversion v. Abort. Fail Lemma vector0_is_vnil_aux : forall (A:Set)(n:nat)(v:Vector.t A n), n= 0 -> v = Vector.nil A. (* Error: In environment A : Set n : nat v : Vector.t A n The term "[]" has type "Vector.t A 0" while it is expected to have type "Vector.t A n" *) Require Import JMeq. Lemma vector0_is_vnil_aux : forall (A:Set)(n:nat)(v:Vector.t A n), n= 0 -> JMeq v (Vector.nil A). Proof. destruct v. auto. intro; discriminate. Qed. Lemma vector0_is_vnil : forall (A:Set)(v:Vector.t A 0), v = Vector.nil A. Proof. intros a v;apply JMeq_eq. apply vector0_is_vnil_aux. trivial. Qed. Arguments Vector.cons [A] _ [n]. Arguments Vector.nil [A]. Arguments Vector.hd [A n]. Arguments Vector.tl [A n]. Definition Vid : forall (A : Type)(n:nat), Vector.t A n -> Vector.t A n. Proof. destruct n; intro v. exact Vector.nil. exact (Vector.cons (Vector.hd v) (Vector.tl v)). Defined. Eval simpl in (fun (A:Set)(v:Vector.t A 0) => (Vid _ _ v)). Eval simpl in (fun (A:Set)(v:Vector.t A 0) => v). Lemma Vid_eq : forall (n:nat) (A:Type)(v:Vector.t A n), v=(Vid _ n v). Proof. destruct v. reflexivity. reflexivity. Defined. Theorem zero_nil : forall A (v:Vector.t A 0), v = Vector.nil. Proof. intros. change (Vector.nil (A:=A)) with (Vid _ 0 v). apply Vid_eq. Defined. Theorem decomp : forall (A : Set) (n : nat) (v : Vector.t A (S n)), v = Vector.cons (Vector.hd v) (Vector.tl v). Proof. intros. change (Vector.cons (Vector.hd v) (Vector.tl v)) with (Vid _ (S n) v). apply Vid_eq. Defined. Definition vector_double_rect : forall (A:Set) (P: forall (n:nat),(Vector.t A n)->(Vector.t A n) -> Type), P 0 Vector.nil Vector.nil -> (forall n (v1 v2 : Vector.t A n) a b, P n v1 v2 -> P (S n) (Vector.cons a v1) (Vector.cons b v2)) -> forall n (v1 v2 : Vector.t A n), P n v1 v2. induction n. intros; rewrite (zero_nil _ v1); rewrite (zero_nil _ v2). auto. intros v1 v2; rewrite (decomp _ _ v1);rewrite (decomp _ _ v2). apply X0; auto. Defined. Require Import Bool. Definition bitwise_or n v1 v2 : Vector.t bool n := vector_double_rect bool (fun n v1 v2 => Vector.t bool n) Vector.nil (fun n v1 v2 a b r => Vector.cons (orb a b) r) n v1 v2. Fixpoint vector_nth (A:Set)(n:nat)(p:nat)(v:Vector.t A p){struct v} : option A := match n,v with _ , Vector.nil => None | 0 , Vector.cons b _ => Some b | S n', Vector.cons _ v' => vector_nth A n' _ v' end. Arguments vector_nth [A] _ [p]. Lemma nth_bitwise : forall (n:nat) (v1 v2: Vector.t bool n) i a b, vector_nth i v1 = Some a -> vector_nth i v2 = Some b -> vector_nth i (bitwise_or _ v1 v2) = Some (orb a b). Proof. intros n v1 v2; pattern n,v1,v2. apply vector_double_rect. simpl. destruct i; discriminate 1. destruct i; simpl;auto. injection 1 as ->; injection 1 as ->; auto. Qed. Set Implicit Arguments. CoInductive Stream (A:Set) : Set := | Cons : A -> Stream A -> Stream A. CoInductive LList (A: Set) : Set := | LNil : LList A | LCons : A -> LList A -> LList A. Definition head (A:Set)(s : Stream A) := match s with Cons a s' => a end. Definition tail (A : Set)(s : Stream A) := match s with Cons a s' => s' end. CoFixpoint repeat (A:Set)(a:A) : Stream A := Cons a (repeat a). CoFixpoint iterate (A: Set)(f: A -> A)(a : A) : Stream A:= Cons a (iterate f (f a)). CoFixpoint map (A B:Set)(f: A -> B)(s : Stream A) : Stream B:= match s with Cons a tl => Cons (f a) (map f tl) end. Eval simpl in (fun (A:Set)(a:A) => repeat a). Eval simpl in (fun (A:Set)(a:A) => head (repeat a)). CoInductive EqSt (A: Set) : Stream A -> Stream A -> Prop := eqst : forall s1 s2: Stream A, head s1 = head s2 -> EqSt (tail s1) (tail s2) -> EqSt s1 s2. Section Parks_Principle. Variable A : Set. Variable R : Stream A -> Stream A -> Prop. Hypothesis bisim1 : forall s1 s2:Stream A, R s1 s2 -> head s1 = head s2. Hypothesis bisim2 : forall s1 s2:Stream A, R s1 s2 -> R (tail s1) (tail s2). CoFixpoint park_ppl : forall s1 s2:Stream A, R s1 s2 -> EqSt s1 s2 := fun s1 s2 (p : R s1 s2) => eqst s1 s2 (bisim1 p) (park_ppl (bisim2 p)). End Parks_Principle. Theorem map_iterate : forall (A:Set)(f:A->A)(x:A), EqSt (iterate f (f x)) (map f (iterate f x)). Proof. intros A f x. apply park_ppl with (R:= fun s1 s2 => exists x: A, s1 = iterate f (f x) /\ s2 = map f (iterate f x)). intros s1 s2 (x0,(eqs1,eqs2));rewrite eqs1;rewrite eqs2;reflexivity. intros s1 s2 (x0,(eqs1,eqs2)). exists (f x0);split;[rewrite eqs1|rewrite eqs2]; reflexivity. exists x;split; reflexivity. Qed. Ltac infiniteproof f := cofix f; constructor; [clear f| simpl; try (apply f; clear f)]. Theorem map_iterate' : forall (A:Set)(f:A->A)(x:A), EqSt (iterate f (f x)) (map f (iterate f x)). infiniteproof map_iterate'. reflexivity. Qed. Arguments LNil [A]. Lemma Lnil_not_Lcons : forall (A:Set)(a:A)(l:LList A), LNil <> (LCons a l). intros;discriminate. Qed. Lemma injection_demo : forall (A:Set)(a b : A)(l l': LList A), LCons a (LCons b l) = LCons b (LCons a l') -> a = b /\ l = l'. Proof. intros A a b l l' e; injection e; auto. Qed. Inductive Finite (A:Set) : LList A -> Prop := | Lnil_fin : Finite (LNil (A:=A)) | Lcons_fin : forall a l, Finite l -> Finite (LCons a l). CoInductive Infinite (A:Set) : LList A -> Prop := | LCons_inf : forall a l, Infinite l -> Infinite (LCons a l). Lemma LNil_not_Infinite : forall (A:Set), ~ Infinite (LNil (A:=A)). Proof. intros A H;inversion H. Qed. Lemma Finite_not_Infinite : forall (A:Set)(l:LList A), Finite l -> ~ Infinite l. Proof. intros A l H; elim H. apply LNil_not_Infinite. intros a l0 F0 I0' I1. case I0'; inversion_clear I1. trivial. Qed. Lemma Not_Finite_Infinite : forall (A:Set)(l:LList A), ~ Finite l -> Infinite l. Proof. cofix H. destruct l. intro; absurd (Finite (LNil (A:=A)));[auto|constructor]. constructor. apply H. red; intro H1;case H0. constructor. trivial. Qed.
{-# LANGUAGE MultiParamTypeClasses #-} -- | Defines intersection tests for a varity of geometry. module Game.Physics.Collision ( Point , point2D , AABB , aabb2D , OBB , obb2DCorners , Intersectable(..) ) where import Prelewd hiding (toList, (<>)) import Impure import Data.Tuple import Storage.List import Numeric.LinearAlgebra -- | "Axis-aligned bounding box." -- -- Use the smart constructor 'aabb2D' to build AABBs. -- -- * Implementation details: -- -- An AABB is an Nx2 matrix. X[0] is the lower limit on the x-th dimension -- and X[1] is the upper limit on the x-th dimension. -- -- The number of rows is the number of dimensions of the box. The number of -- columns is always 2. This is enforced by the smart constructor(s). newtype AABB = AABB (Matrix Double) -- | A point in the physics universe is just a list of the object's -- coordinates. The length of the vector is the number of dimensions its's -- defined for. -- -- Use the smart constructor 'point2D' to build points. newtype Point = Point (Vector Double) -- | "Oriented Bounding Box." A bounding box with any arbitrary orientation. -- -- Use smart constructor 'obb2D' to build OBBs. -- -- * Implementation Notes: -- -- An oriented bounding box consists of a rotation/translation matrix, -- and a vector of n-dimensional extents. For example, a 2x2 bounding box -- would have the extents [1,1]. -- -- We take a simplified approach in 2D - we just use the four corners of the -- box, specified in a clockwise orientation. This turns our point-OBB -- intersection test into 8 vector subtractions, and 4 dot products. Needles -- to say, that's ridiculously cheap. data OBB = OBB2D {-# UNPACK #-} !Point {-# UNPACK #-} !Point {-# UNPACK #-} !Point {-# UNPACK #-} !Point | OBB !(Matrix Double) -- The transformation matrix. !(Vector Double) -- The extent matrix. -- | Builds a 2D point out of a tuple. point2D :: Integral a => (a, a) -> Point point2D (x, y) = Point . fromList $ map fromIntegral [x, y] -- | Constructs a 2-dimensional axis-aligned bounding box. aabb2D :: (Double, Double) -> (Double, Double) -> AABB aabb2D (xa, xb) (ya, yb) = AABB $ (2 >< 2) [ min xa xb, max xa xb , min ya yb, max ya yb ] -- | Constructs a 2D oriented bounding box from a list of verticies, specified -- in a clockwise direction. -- -- Seriously - clockwise. Don't fuck this up. It's _very_ important. No -- checks are done. -- -- Clockwise. obb2DCorners :: Point -> Point -> Point -> Point -> OBB obb2DCorners = OBB2D -- | The type class for our 'intersects' method. This lets us perform double -- dispatch on the types of both of intersects' arguments. class Intersectable a b where -- | We define intersects for as many pairs of geometry as possibly, -- allowing us to do double-dispatch collision detection. intersects :: a -> b -> Bool between :: Ord a => (a, a) -> a -> Bool between (l, r) x = l < x && x < r {-# INLINE between #-} instance Intersectable AABB AABB where -- | Two AABBs intersect if any of their edges lie between the other's -- edges. intersects (AABB ba) (AABB bb) = any testDim . zip (toRows ba) $ toRows bb where testDim :: (Vector Double, Vector Double) -> Bool testDim (a, b) = let a'@(lx, hx) = (a @> 0, a @> 1) b'@(ly, hy) = (b @> 0, b @> 1) in between a' ly || between a' hy || between b' lx || between b' hx {-# INLINE intersects #-} instance Intersectable AABB Point where intersects (AABB bs) (Point p) = all inRange . zip (toRows bs) $ toList p where inRange :: (Vector Double, Double) -> Bool inRange (bnds, x) = between (bnds @> 0, bnds @> 1) x {-# INLINE intersects #-} instance Intersectable Point AABB where intersects x y = intersects y x {-# INLINE intersects #-} obbBadInput :: a obbBadInput = error "Invalid dimensions in the OOB intersection vectors being tested." instance Intersectable OBB Point where intersects (OBB2D (Point w) (Point x) (Point y) (Point z)) (Point p) | any (/= 2) [ dp, dw, dx, dy, dz ] = obbBadInput | otherwise = all (>= 0) [ (p - w) <.> (x - w) , (p - x) <.> (y - x) , (p - y) <.> (z - y) , (p - z) <.> (w - z) ] where dp = dim p dw = dim w dx = dim x dy = dim y dz = dim z intersects (OBB lm exts) (Point p) | allEqual [ dlmx, dlmy, dp ] = obbBadInput | otherwise = intersects aabb transformed where transformed :: Point transformed = Point $ inv lm <> p aabb :: AABB aabb = AABB . fromRows . map (\e -> fromList [-e, e]) $ toList exts (dlmx, dlmy) = (cols lm, rows lm) dp = dim p -- | Are all elements in the list equal? allEqual :: Eq a => [a] -> Bool allEqual [] = True allEqual (x:xs) = fst $ foldl' (\(b, v) v' -> (b && v == v', v)) (True, x) xs -- we use foldl', since in most cases, the elements _will_ be equal. If the -- converse were true, I would prefer foldr since && is lazy. instance Intersectable Point OBB where intersects x y = intersects y x {-# INLINE intersects #-}
function score = grade(board,goal,solutionVector) modSolutionVector = validateSolutionVector(solutionVector,board); boardToScore = runSolutionVector(modSolutionVector, board, goal, false); score = sum(boardToScore(:)) + sum(modSolutionVector);
lemma mul_pow (a b n : mynat) : (a * b) ^ n = a ^ n * b ^ n := begin induction n with m hm, repeat {rw pow_zero}, simp, repeat {rw pow_succ}, rw hm, simp, end