Datasets:
AI4M
/

text
stringlengths
0
3.34M
! initialization expression, now allowed in Fortran 2003 ! PR fortran/29962 ! { dg-do run } ! { dg-options "-std=f2003 " } real, parameter :: three = 27.0**(1.0/3.0) if(abs(three-3.0)>epsilon(three)) STOP 1 end
/- Copyright (c) 2020 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn ! This file was ported from Lean 3 source module measure_theory.measure.content ! leanprover-community/mathlib commit d39590fc8728fbf6743249802486f8c91ffe07bc ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathbin.MeasureTheory.Measure.MeasureSpace import Mathbin.MeasureTheory.Measure.Regular import Mathbin.Topology.Sets.Compacts /-! # Contents In this file we work with *contents*. A content `λ` is a function from a certain class of subsets (such as the compact subsets) to `ℝ≥0` that is * additive: If `K₁` and `K₂` are disjoint sets in the domain of `λ`, then `λ(K₁ ∪ K₂) = λ(K₁) + λ(K₂)`; * subadditive: If `K₁` and `K₂` are in the domain of `λ`, then `λ(K₁ ∪ K₂) ≤ λ(K₁) + λ(K₂)`; * monotone: If `K₁ ⊆ K₂` are in the domain of `λ`, then `λ(K₁) ≤ λ(K₂)`. We show that: * Given a content `λ` on compact sets, let us define a function `λ*` on open sets, by letting `λ* U` be the supremum of `λ K` for `K` included in `U`. This is a countably subadditive map that vanishes at `∅`. In Halmos (1950) this is called the *inner content* `λ*` of `λ`, and formalized as `inner_content`. * Given an inner content, we define an outer measure `μ*`, by letting `μ* E` be the infimum of `λ* U` over the open sets `U` containing `E`. This is indeed an outer measure. It is formalized as `outer_measure`. * Restricting this outer measure to Borel sets gives a regular measure `μ`. We define bundled contents as `content`. In this file we only work on contents on compact sets, and inner contents on open sets, and both contents and inner contents map into the extended nonnegative reals. However, in other applications other choices can be made, and it is not a priori clear what the best interface should be. ## Main definitions For `μ : content G`, we define * `μ.inner_content` : the inner content associated to `μ`. * `μ.outer_measure` : the outer measure associated to `μ`. * `μ.measure` : the Borel measure associated to `μ`. We prove that, on a locally compact space, the measure `μ.measure` is regular. ## References * Paul Halmos (1950), Measure Theory, §53 * <https://en.wikipedia.org/wiki/Content_(measure_theory)> -/ universe u v w noncomputable section open Set TopologicalSpace open NNReal ENNReal MeasureTheory namespace MeasureTheory variable {G : Type w} [TopologicalSpace G] /-- A content is an additive function on compact sets taking values in `ℝ≥0`. It is a device from which one can define a measure. -/ structure Content (G : Type w) [TopologicalSpace G] where toFun : Compacts G → ℝ≥0 mono' : ∀ K₁ K₂ : Compacts G, (K₁ : Set G) ⊆ K₂ → to_fun K₁ ≤ to_fun K₂ sup_disjoint' : ∀ K₁ K₂ : Compacts G, Disjoint (K₁ : Set G) K₂ → to_fun (K₁ ⊔ K₂) = to_fun K₁ + to_fun K₂ sup_le' : ∀ K₁ K₂ : Compacts G, to_fun (K₁ ⊔ K₂) ≤ to_fun K₁ + to_fun K₂ #align measure_theory.content MeasureTheory.Content instance : Inhabited (Content G) := ⟨{ toFun := fun K => 0 mono' := by simp sup_disjoint' := by simp sup_le' := by simp }⟩ /-- Although the `to_fun` field of a content takes values in `ℝ≥0`, we register a coercion to functions taking values in `ℝ≥0∞` as most constructions below rely on taking suprs and infs, which is more convenient in a complete lattice, and aim at constructing a measure. -/ instance : CoeFun (Content G) fun _ => Compacts G → ℝ≥0∞ := ⟨fun μ s => μ.toFun s⟩ namespace Content variable (μ : Content G) theorem apply_eq_coe_toFun (K : Compacts G) : μ K = μ.toFun K := rfl #align measure_theory.content.apply_eq_coe_to_fun MeasureTheory.Content.apply_eq_coe_toFun theorem mono (K₁ K₂ : Compacts G) (h : (K₁ : Set G) ⊆ K₂) : μ K₁ ≤ μ K₂ := by simp [apply_eq_coe_to_fun, μ.mono' _ _ h] #align measure_theory.content.mono MeasureTheory.Content.mono theorem sup_disjoint (K₁ K₂ : Compacts G) (h : Disjoint (K₁ : Set G) K₂) : μ (K₁ ⊔ K₂) = μ K₁ + μ K₂ := by simp [apply_eq_coe_to_fun, μ.sup_disjoint' _ _ h] #align measure_theory.content.sup_disjoint MeasureTheory.Content.sup_disjoint theorem sup_le (K₁ K₂ : Compacts G) : μ (K₁ ⊔ K₂) ≤ μ K₁ + μ K₂ := by simp only [apply_eq_coe_to_fun] norm_cast exact μ.sup_le' _ _ #align measure_theory.content.sup_le MeasureTheory.Content.sup_le theorem lt_top (K : Compacts G) : μ K < ∞ := ENNReal.coe_lt_top #align measure_theory.content.lt_top MeasureTheory.Content.lt_top theorem empty : μ ⊥ = 0 := by have := μ.sup_disjoint' ⊥ ⊥ simpa [apply_eq_coe_to_fun] using this #align measure_theory.content.empty MeasureTheory.Content.empty /-- Constructing the inner content of a content. From a content defined on the compact sets, we obtain a function defined on all open sets, by taking the supremum of the content of all compact subsets. -/ def innerContent (U : Opens G) : ℝ≥0∞ := ⨆ (K : Compacts G) (h : (K : Set G) ⊆ U), μ K #align measure_theory.content.inner_content MeasureTheory.Content.innerContent theorem le_innerContent (K : Compacts G) (U : Opens G) (h2 : (K : Set G) ⊆ U) : μ K ≤ μ.innerContent U := le_supᵢ_of_le K <| le_supᵢ _ h2 #align measure_theory.content.le_inner_content MeasureTheory.Content.le_innerContent theorem innerContent_le (U : Opens G) (K : Compacts G) (h2 : (U : Set G) ⊆ K) : μ.innerContent U ≤ μ K := supᵢ₂_le fun K' hK' => μ.mono _ _ (Subset.trans hK' h2) #align measure_theory.content.inner_content_le MeasureTheory.Content.innerContent_le theorem innerContent_of_isCompact {K : Set G} (h1K : IsCompact K) (h2K : IsOpen K) : μ.innerContent ⟨K, h2K⟩ = μ ⟨K, h1K⟩ := le_antisymm (supᵢ₂_le fun K' hK' => μ.mono _ ⟨K, h1K⟩ hK') (μ.le_innerContent _ _ Subset.rfl) #align measure_theory.content.inner_content_of_is_compact MeasureTheory.Content.innerContent_of_isCompact theorem innerContent_bot : μ.innerContent ⊥ = 0 := by refine' le_antisymm _ (zero_le _) rw [← μ.empty] refine' supᵢ₂_le fun K hK => _ have : K = ⊥ := by ext1 rw [subset_empty_iff.mp hK, compacts.coe_bot] rw [this] rfl #align measure_theory.content.inner_content_bot MeasureTheory.Content.innerContent_bot /-- This is "unbundled", because that it required for the API of `induced_outer_measure`. -/ theorem innerContent_mono ⦃U V : Set G⦄ (hU : IsOpen U) (hV : IsOpen V) (h2 : U ⊆ V) : μ.innerContent ⟨U, hU⟩ ≤ μ.innerContent ⟨V, hV⟩ := bsupᵢ_mono fun K hK => hK.trans h2 #align measure_theory.content.inner_content_mono MeasureTheory.Content.innerContent_mono theorem innerContent_exists_compact {U : Opens G} (hU : μ.innerContent U ≠ ∞) {ε : ℝ≥0} (hε : ε ≠ 0) : ∃ K : Compacts G, (K : Set G) ⊆ U ∧ μ.innerContent U ≤ μ K + ε := by have h'ε := ENNReal.coe_ne_zero.2 hε cases le_or_lt (μ.inner_content U) ε · exact ⟨⊥, empty_subset _, le_add_left h⟩ have := ENNReal.sub_lt_self hU h.ne_bot h'ε conv at this => rhs rw [inner_content]; simp only [lt_supᵢ_iff] at this rcases this with ⟨U, h1U, h2U⟩; refine' ⟨U, h1U, _⟩ rw [← tsub_le_iff_right]; exact le_of_lt h2U #align measure_theory.content.inner_content_exists_compact MeasureTheory.Content.innerContent_exists_compact /-- The inner content of a supremum of opens is at most the sum of the individual inner contents. -/ theorem innerContent_Sup_nat [T2Space G] (U : ℕ → Opens G) : μ.innerContent (⨆ i : ℕ, U i) ≤ ∑' i : ℕ, μ.innerContent (U i) := by have h3 : ∀ (t : Finset ℕ) (K : ℕ → compacts G), μ (t.sup K) ≤ t.Sum fun i => μ (K i) := by intro t K refine' Finset.induction_on t _ _ · simp only [μ.empty, nonpos_iff_eq_zero, Finset.sum_empty, Finset.sup_empty] · intro n s hn ih rw [Finset.sup_insert, Finset.sum_insert hn] exact le_trans (μ.sup_le _ _) (add_le_add_left ih _) refine' supᵢ₂_le fun K hK => _ obtain ⟨t, ht⟩ := K.is_compact.elim_finite_subcover _ (fun i => (U i).IsOpen) _ swap · rwa [← opens.coe_supr] rcases K.is_compact.finite_compact_cover t (coe ∘ U) (fun i _ => (U _).IsOpen) (by simp only [ht]) with ⟨K', h1K', h2K', h3K'⟩ let L : ℕ → compacts G := fun n => ⟨K' n, h1K' n⟩ convert le_trans (h3 t L) _ · ext1 rw [compacts.coe_finset_sup, Finset.sup_eq_supᵢ] exact h3K' refine' le_trans (Finset.sum_le_sum _) (ENNReal.sum_le_tsum t) intro i hi refine' le_trans _ (le_supᵢ _ (L i)) refine' le_trans _ (le_supᵢ _ (h2K' i)) rfl #align measure_theory.content.inner_content_Sup_nat MeasureTheory.Content.innerContent_Sup_nat /-- The inner content of a union of sets is at most the sum of the individual inner contents. This is the "unbundled" version of `inner_content_Sup_nat`. It required for the API of `induced_outer_measure`. -/ theorem innerContent_unionᵢ_nat [T2Space G] ⦃U : ℕ → Set G⦄ (hU : ∀ i : ℕ, IsOpen (U i)) : μ.innerContent ⟨⋃ i : ℕ, U i, isOpen_unionᵢ hU⟩ ≤ ∑' i : ℕ, μ.innerContent ⟨U i, hU i⟩ := by have := μ.inner_content_Sup_nat fun i => ⟨U i, hU i⟩ rwa [opens.supr_def] at this #align measure_theory.content.inner_content_Union_nat MeasureTheory.Content.innerContent_unionᵢ_nat theorem innerContent_comap (f : G ≃ₜ G) (h : ∀ ⦃K : Compacts G⦄, μ (K.map f f.Continuous) = μ K) (U : Opens G) : μ.innerContent (Opens.comap f.toContinuousMap U) = μ.innerContent U := by refine' (compacts.equiv f).Surjective.supᵢ_congr _ fun K => supᵢ_congr_Prop image_subset_iff _ intro hK; simp only [Equiv.coe_fn_mk, Subtype.mk_eq_mk, ENNReal.coe_eq_coe, compacts.equiv] apply h #align measure_theory.content.inner_content_comap MeasureTheory.Content.innerContent_comap @[to_additive] theorem is_mulLeft_invariant_innerContent [Group G] [TopologicalGroup G] (h : ∀ (g : G) {K : Compacts G}, μ (K.map _ <| continuous_mul_left g) = μ K) (g : G) (U : Opens G) : μ.innerContent (Opens.comap (Homeomorph.mulLeft g).toContinuousMap U) = μ.innerContent U := by convert μ.inner_content_comap (Homeomorph.mulLeft g) (fun K => h g) U #align measure_theory.content.is_mul_left_invariant_inner_content MeasureTheory.Content.is_mulLeft_invariant_innerContent #align measure_theory.content.is_add_left_invariant_inner_content MeasureTheory.Content.is_add_left_invariant_inner_content @[to_additive] theorem innerContent_pos_of_is_mul_left_invariant [T2Space G] [Group G] [TopologicalGroup G] (h3 : ∀ (g : G) {K : Compacts G}, μ (K.map _ <| continuous_mul_left g) = μ K) (K : Compacts G) (hK : μ K ≠ 0) (U : Opens G) (hU : (U : Set G).Nonempty) : 0 < μ.innerContent U := by have : (interior (U : Set G)).Nonempty rwa [U.is_open.interior_eq] rcases compact_covered_by_mul_left_translates K.2 this with ⟨s, hs⟩ suffices μ K ≤ s.card * μ.inner_content U by exact (ennreal.mul_pos_iff.mp <| hK.bot_lt.trans_le this).2 have : (K : Set G) ⊆ ↑(⨆ g ∈ s, opens.comap (Homeomorph.mulLeft g).toContinuousMap U) := by simpa only [opens.supr_def, opens.coe_comap, Subtype.coe_mk] refine' (μ.le_inner_content _ _ this).trans _ refine' (rel_supᵢ_sum μ.inner_content μ.inner_content_bot (· ≤ ·) μ.inner_content_Sup_nat _ _).trans _ simp only [μ.is_mul_left_invariant_inner_content h3, Finset.sum_const, nsmul_eq_mul, le_refl] #align measure_theory.content.inner_content_pos_of_is_mul_left_invariant MeasureTheory.Content.innerContent_pos_of_is_mul_left_invariant #align measure_theory.content.inner_content_pos_of_is_add_left_invariant MeasureTheory.Content.inner_content_pos_of_is_add_left_invariant theorem innerContent_mono' ⦃U V : Set G⦄ (hU : IsOpen U) (hV : IsOpen V) (h2 : U ⊆ V) : μ.innerContent ⟨U, hU⟩ ≤ μ.innerContent ⟨V, hV⟩ := bsupᵢ_mono fun K hK => hK.trans h2 #align measure_theory.content.inner_content_mono' MeasureTheory.Content.innerContent_mono' section OuterMeasure /-- Extending a content on compact sets to an outer measure on all sets. -/ protected def outerMeasure : OuterMeasure G := inducedOuterMeasure (fun U hU => μ.innerContent ⟨U, hU⟩) isOpen_empty μ.innerContent_bot #align measure_theory.content.outer_measure MeasureTheory.Content.outerMeasure variable [T2Space G] theorem outerMeasure_opens (U : Opens G) : μ.OuterMeasure U = μ.innerContent U := inducedOuterMeasure_eq' (fun _ => isOpen_unionᵢ) μ.innerContent_unionᵢ_nat μ.innerContent_mono U.2 #align measure_theory.content.outer_measure_opens MeasureTheory.Content.outerMeasure_opens theorem outerMeasure_of_isOpen (U : Set G) (hU : IsOpen U) : μ.OuterMeasure U = μ.innerContent ⟨U, hU⟩ := μ.outerMeasure_opens ⟨U, hU⟩ #align measure_theory.content.outer_measure_of_is_open MeasureTheory.Content.outerMeasure_of_isOpen theorem outerMeasure_le (U : Opens G) (K : Compacts G) (hUK : (U : Set G) ⊆ K) : μ.OuterMeasure U ≤ μ K := (μ.outerMeasure_opens U).le.trans <| μ.innerContent_le U K hUK #align measure_theory.content.outer_measure_le MeasureTheory.Content.outerMeasure_le theorem le_outerMeasure_compacts (K : Compacts G) : μ K ≤ μ.OuterMeasure K := by rw [content.outer_measure, induced_outer_measure_eq_infi] · exact le_infᵢ fun U => le_infᵢ fun hU => le_infᵢ <| μ.le_inner_content K ⟨U, hU⟩ · exact μ.inner_content_Union_nat · exact μ.inner_content_mono #align measure_theory.content.le_outer_measure_compacts MeasureTheory.Content.le_outerMeasure_compacts theorem outerMeasure_eq_infᵢ (A : Set G) : μ.OuterMeasure A = ⨅ (U : Set G) (hU : IsOpen U) (h : A ⊆ U), μ.innerContent ⟨U, hU⟩ := inducedOuterMeasure_eq_infᵢ _ μ.innerContent_unionᵢ_nat μ.innerContent_mono A #align measure_theory.content.outer_measure_eq_infi MeasureTheory.Content.outerMeasure_eq_infᵢ theorem outerMeasure_interior_compacts (K : Compacts G) : μ.OuterMeasure (interior K) ≤ μ K := (μ.outerMeasure_opens <| Opens.interior K).le.trans <| μ.innerContent_le _ _ interior_subset #align measure_theory.content.outer_measure_interior_compacts MeasureTheory.Content.outerMeasure_interior_compacts theorem outerMeasure_exists_compact {U : Opens G} (hU : μ.OuterMeasure U ≠ ∞) {ε : ℝ≥0} (hε : ε ≠ 0) : ∃ K : Compacts G, (K : Set G) ⊆ U ∧ μ.OuterMeasure U ≤ μ.OuterMeasure K + ε := by rw [μ.outer_measure_opens] at hU⊢ rcases μ.inner_content_exists_compact hU hε with ⟨K, h1K, h2K⟩ exact ⟨K, h1K, le_trans h2K <| add_le_add_right (μ.le_outer_measure_compacts K) _⟩ #align measure_theory.content.outer_measure_exists_compact MeasureTheory.Content.outerMeasure_exists_compact theorem outerMeasure_exists_open {A : Set G} (hA : μ.OuterMeasure A ≠ ∞) {ε : ℝ≥0} (hε : ε ≠ 0) : ∃ U : Opens G, A ⊆ U ∧ μ.OuterMeasure U ≤ μ.OuterMeasure A + ε := by rcases induced_outer_measure_exists_set _ _ μ.inner_content_mono hA (ENNReal.coe_ne_zero.2 hε) with ⟨U, hU, h2U, h3U⟩ exact ⟨⟨U, hU⟩, h2U, h3U⟩; swap; exact μ.inner_content_Union_nat #align measure_theory.content.outer_measure_exists_open MeasureTheory.Content.outerMeasure_exists_open theorem outerMeasure_preimage (f : G ≃ₜ G) (h : ∀ ⦃K : Compacts G⦄, μ (K.map f f.Continuous) = μ K) (A : Set G) : μ.OuterMeasure (f ⁻¹' A) = μ.OuterMeasure A := by refine' induced_outer_measure_preimage _ μ.inner_content_Union_nat μ.inner_content_mono _ (fun s => f.is_open_preimage) _ intro s hs; convert μ.inner_content_comap f h ⟨s, hs⟩ #align measure_theory.content.outer_measure_preimage MeasureTheory.Content.outerMeasure_preimage theorem outerMeasure_lt_top_of_isCompact [LocallyCompactSpace G] {K : Set G} (hK : IsCompact K) : μ.OuterMeasure K < ∞ := by rcases exists_compact_superset hK with ⟨F, h1F, h2F⟩ calc μ.outer_measure K ≤ μ.outer_measure (interior F) := outer_measure.mono' _ h2F _ ≤ μ ⟨F, h1F⟩ := by apply μ.outer_measure_le ⟨interior F, isOpen_interior⟩ ⟨F, h1F⟩ interior_subset _ < ⊤ := μ.lt_top _ #align measure_theory.content.outer_measure_lt_top_of_is_compact MeasureTheory.Content.outerMeasure_lt_top_of_isCompact @[to_additive] theorem is_mul_left_invariant_outerMeasure [Group G] [TopologicalGroup G] (h : ∀ (g : G) {K : Compacts G}, μ (K.map _ <| continuous_mul_left g) = μ K) (g : G) (A : Set G) : μ.OuterMeasure ((fun h => g * h) ⁻¹' A) = μ.OuterMeasure A := by convert μ.outer_measure_preimage (Homeomorph.mulLeft g) (fun K => h g) A #align measure_theory.content.is_mul_left_invariant_outer_measure MeasureTheory.Content.is_mul_left_invariant_outerMeasure #align measure_theory.content.is_add_left_invariant_outer_measure MeasureTheory.Content.is_add_left_invariant_outer_measure theorem outerMeasure_caratheodory (A : Set G) : measurable_set[μ.OuterMeasure.caratheodory] A ↔ ∀ U : Opens G, μ.OuterMeasure (U ∩ A) + μ.OuterMeasure (U \ A) ≤ μ.OuterMeasure U := by rw [opens.forall] apply induced_outer_measure_caratheodory apply inner_content_Union_nat apply inner_content_mono' #align measure_theory.content.outer_measure_caratheodory MeasureTheory.Content.outerMeasure_caratheodory @[to_additive] theorem outerMeasure_pos_of_is_mul_left_invariant [Group G] [TopologicalGroup G] (h3 : ∀ (g : G) {K : Compacts G}, μ (K.map _ <| continuous_mul_left g) = μ K) (K : Compacts G) (hK : μ K ≠ 0) {U : Set G} (h1U : IsOpen U) (h2U : U.Nonempty) : 0 < μ.OuterMeasure U := by convert μ.inner_content_pos_of_is_mul_left_invariant h3 K hK ⟨U, h1U⟩ h2U exact μ.outer_measure_opens ⟨U, h1U⟩ #align measure_theory.content.outer_measure_pos_of_is_mul_left_invariant MeasureTheory.Content.outerMeasure_pos_of_is_mul_left_invariant #align measure_theory.content.outer_measure_pos_of_is_add_left_invariant MeasureTheory.Content.outer_measure_pos_of_is_add_left_invariant variable [S : MeasurableSpace G] [BorelSpace G] include S /-- For the outer measure coming from a content, all Borel sets are measurable. -/ theorem borel_le_caratheodory : S ≤ μ.OuterMeasure.caratheodory := by rw [@BorelSpace.measurable_eq G _ _] refine' MeasurableSpace.generateFrom_le _ intro U hU rw [μ.outer_measure_caratheodory] intro U' rw [μ.outer_measure_of_is_open ((U' : Set G) ∩ U) (U'.is_open.inter hU)] simp only [inner_content, supᵢ_subtype'] rw [opens.coe_mk] haveI : Nonempty { L : compacts G // (L : Set G) ⊆ U' ∩ U } := ⟨⟨⊥, empty_subset _⟩⟩ rw [ENNReal.supᵢ_add] refine' supᵢ_le _ rintro ⟨L, hL⟩ simp only [subset_inter_iff] at hL have : ↑U' \ U ⊆ U' \ L := diff_subset_diff_right hL.2 refine' le_trans (add_le_add_left (μ.outer_measure.mono' this) _) _ rw [μ.outer_measure_of_is_open (↑U' \ L) (IsOpen.sdiff U'.2 L.2.IsClosed)] simp only [inner_content, supᵢ_subtype'] rw [opens.coe_mk] haveI : Nonempty { M : compacts G // (M : Set G) ⊆ ↑U' \ L } := ⟨⟨⊥, empty_subset _⟩⟩ rw [ENNReal.add_supᵢ] refine' supᵢ_le _ rintro ⟨M, hM⟩ simp only [subset_diff] at hM have : (↑(L ⊔ M) : Set G) ⊆ U' := by simp only [union_subset_iff, compacts.coe_sup, hM, hL, and_self_iff] rw [μ.outer_measure_of_is_open (↑U') U'.2] refine' le_trans (ge_of_eq _) (μ.le_inner_content _ _ this) exact μ.sup_disjoint _ _ hM.2.symm #align measure_theory.content.borel_le_caratheodory MeasureTheory.Content.borel_le_caratheodory /-- The measure induced by the outer measure coming from a content, on the Borel sigma-algebra. -/ protected def measure : Measure G := μ.OuterMeasure.toMeasure μ.borel_le_caratheodory #align measure_theory.content.measure MeasureTheory.Content.measure theorem measure_apply {s : Set G} (hs : MeasurableSet s) : μ.Measure s = μ.OuterMeasure s := toMeasure_apply _ _ hs #align measure_theory.content.measure_apply MeasureTheory.Content.measure_apply /-- In a locally compact space, any measure constructed from a content is regular. -/ instance regular [LocallyCompactSpace G] : μ.Measure.regular := by have : μ.measure.outer_regular := by refine' ⟨fun A hA r (hr : _ < _) => _⟩ rw [μ.measure_apply hA, outer_measure_eq_infi] at hr simp only [infᵢ_lt_iff] at hr rcases hr with ⟨U, hUo, hAU, hr⟩ rw [← μ.outer_measure_of_is_open U hUo, ← μ.measure_apply hUo.measurable_set] at hr exact ⟨U, hAU, hUo, hr⟩ have : is_finite_measure_on_compacts μ.measure := by refine' ⟨fun K hK => _⟩ rw [measure_apply _ hK.measurable_set] exact μ.outer_measure_lt_top_of_is_compact hK refine' ⟨fun U hU r hr => _⟩ rw [measure_apply _ hU.measurable_set, μ.outer_measure_of_is_open U hU] at hr simp only [inner_content, lt_supᵢ_iff] at hr rcases hr with ⟨K, hKU, hr⟩ refine' ⟨K, hKU, K.2, hr.trans_le _⟩ exact (μ.le_outer_measure_compacts K).trans (le_to_measure_apply _ _ _) #align measure_theory.content.regular MeasureTheory.Content.regular end OuterMeasure section RegularContents /-- A content `μ` is called regular if for every compact set `K`, `μ(K) = inf {μ(K') : K ⊂ int K' ⊂ K'`. See Paul Halmos (1950), Measure Theory, §54-/ def ContentRegular := ∀ ⦃K : TopologicalSpace.Compacts G⦄, μ K = ⨅ (K' : TopologicalSpace.Compacts G) (hK : (K : Set G) ⊆ interior (K' : Set G)), μ K' #align measure_theory.content.content_regular MeasureTheory.Content.ContentRegular theorem contentRegular_exists_compact (H : ContentRegular μ) (K : TopologicalSpace.Compacts G) {ε : NNReal} (hε : ε ≠ 0) : ∃ K' : TopologicalSpace.Compacts G, K.carrier ⊆ interior K'.carrier ∧ μ K' ≤ μ K + ε := by by_contra hc simp only [not_exists, not_and, not_le] at hc have lower_bound_infi : μ K + ε ≤ ⨅ (K' : TopologicalSpace.Compacts G) (h : (K : Set G) ⊆ interior (K' : Set G)), μ K' := le_infᵢ fun K' => le_infᵢ fun K'_hyp => le_of_lt (hc K' K'_hyp) rw [← H] at lower_bound_infi exact (lt_self_iff_false (μ K)).mp (lt_of_le_of_lt' lower_bound_infi (ENNReal.lt_add_right (ne_top_of_lt (μ.lt_top K)) (ennreal.coe_ne_zero.mpr hε))) #align measure_theory.content.content_regular_exists_compact MeasureTheory.Content.contentRegular_exists_compact variable [MeasurableSpace G] [T2Space G] [BorelSpace G] /-- If `μ` is a regular content, then the measure induced by `μ` will agree with `μ` on compact sets.-/ theorem measure_eq_content_of_regular (H : MeasureTheory.Content.ContentRegular μ) (K : TopologicalSpace.Compacts G) : μ.Measure ↑K = μ K := by refine' le_antisymm _ _ · apply ENNReal.le_of_forall_pos_le_add intro ε εpos content_K_finite obtain ⟨K', K'_hyp⟩ := content_regular_exists_compact μ H K (ne_bot_of_gt εpos) calc μ.measure ↑K ≤ μ.measure (interior ↑K') := _ _ ≤ μ K' := _ _ ≤ μ K + ε := K'_hyp.right · rw [μ.measure_apply isOpen_interior.MeasurableSet, μ.measure_apply K.is_compact.measurable_set] exact μ.outer_measure.mono K'_hyp.left · rw [μ.measure_apply (IsOpen.measurableSet isOpen_interior)] exact μ.outer_measure_interior_compacts K' · rw [μ.measure_apply (IsCompact.measurableSet K.is_compact)] exact μ.le_outer_measure_compacts K #align measure_theory.content.measure_eq_content_of_regular MeasureTheory.Content.measure_eq_content_of_regular end RegularContents end Content end MeasureTheory
/- Copyright (c) 2021 Patrick Massot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Patrick Massot ! This file was ported from Lean 3 source module topology.algebra.valuation ! leanprover-community/mathlib commit f2ce6086713c78a7f880485f7917ea547a215982 ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathbin.Topology.Algebra.Nonarchimedean.Bases import Mathbin.Topology.Algebra.UniformFilterBasis import Mathbin.RingTheory.Valuation.Basic /-! # The topology on a valued ring In this file, we define the non archimedean topology induced by a valuation on a ring. The main definition is a `valued` type class which equips a ring with a valuation taking values in a group with zero. Other instances are then deduced from this. -/ open Classical Topology uniformity open Set Valuation noncomputable section universe v u variable {R : Type u} [Ring R] {Γ₀ : Type v} [LinearOrderedCommGroupWithZero Γ₀] namespace Valuation variable (v : Valuation R Γ₀) /-- The basis of open subgroups for the topology on a ring determined by a valuation. -/ theorem subgroups_basis : RingSubgroupsBasis fun γ : Γ₀ˣ => (v.ltAddSubgroup γ : AddSubgroup R) := { inter := by rintro γ₀ γ₁ use min γ₀ γ₁ simp [Valuation.ltAddSubgroup] <;> tauto mul := by rintro γ cases' exists_square_le γ with γ₀ h use γ₀ rintro - ⟨r, s, r_in, s_in, rfl⟩ calc (v (r * s) : Γ₀) = v r * v s := Valuation.map_mul _ _ _ _ < γ₀ * γ₀ := (mul_lt_mul₀ r_in s_in) _ ≤ γ := by exact_mod_cast h leftMul := by rintro x γ rcases GroupWithZero.eq_zero_or_unit (v x) with (Hx | ⟨γx, Hx⟩) · use (1 : Γ₀ˣ) rintro y (y_in : (v y : Γ₀) < 1) change v (x * y) < _ rw [Valuation.map_mul, Hx, MulZeroClass.zero_mul] exact Units.zero_lt γ · simp only [image_subset_iff, set_of_subset_set_of, preimage_set_of_eq, Valuation.map_mul] use γx⁻¹ * γ rintro y (vy_lt : v y < ↑(γx⁻¹ * γ)) change (v (x * y) : Γ₀) < γ rw [Valuation.map_mul, Hx, mul_comm] rw [Units.val_mul, mul_comm] at vy_lt simpa using mul_inv_lt_of_lt_mul₀ vy_lt rightMul := by rintro x γ rcases GroupWithZero.eq_zero_or_unit (v x) with (Hx | ⟨γx, Hx⟩) · use 1 rintro y (y_in : (v y : Γ₀) < 1) change v (y * x) < _ rw [Valuation.map_mul, Hx, MulZeroClass.mul_zero] exact Units.zero_lt γ · use γx⁻¹ * γ rintro y (vy_lt : v y < ↑(γx⁻¹ * γ)) change (v (y * x) : Γ₀) < γ rw [Valuation.map_mul, Hx] rw [Units.val_mul, mul_comm] at vy_lt simpa using mul_inv_lt_of_lt_mul₀ vy_lt } #align valuation.subgroups_basis Valuation.subgroups_basis end Valuation /-- A valued ring is a ring that comes equipped with a distinguished valuation. The class `valued` is designed for the situation that there is a canonical valuation on the ring. TODO: show that there always exists an equivalent valuation taking values in a type belonging to the same universe as the ring. See Note [forgetful inheritance] for why we extend `uniform_space`, `uniform_add_group`. -/ class Valued (R : Type u) [Ring R] (Γ₀ : outParam (Type v)) [LinearOrderedCommGroupWithZero Γ₀] extends UniformSpace R, UniformAddGroup R where V : Valuation R Γ₀ is_topological_valuation : ∀ s, s ∈ 𝓝 (0 : R) ↔ ∃ γ : Γ₀ˣ, { x : R | v x < γ } ⊆ s #align valued Valued attribute [nolint dangerous_instance] Valued.toUniformSpace namespace Valued /-- Alternative `valued` constructor for use when there is no preferred `uniform_space` structure. -/ def mk' (v : Valuation R Γ₀) : Valued R Γ₀ := { V toUniformSpace := @TopologicalAddGroup.toUniformSpace R _ v.subgroups_basis.topology _ to_uniformAddGroup := @comm_topologicalAddGroup_is_uniform _ _ v.subgroups_basis.topology _ is_topological_valuation := by letI := @TopologicalAddGroup.toUniformSpace R _ v.subgroups_basis.topology _ intro s rw [filter.has_basis_iff.mp v.subgroups_basis.has_basis_nhds_zero s] exact exists_congr fun γ => by simpa } #align valued.mk' Valued.mk' variable (R Γ₀) [_i : Valued R Γ₀] include _i theorem hasBasis_nhds_zero : (𝓝 (0 : R)).HasBasis (fun _ => True) fun γ : Γ₀ˣ => { x | v x < (γ : Γ₀) } := by simp [Filter.hasBasis_iff, is_topological_valuation] #align valued.has_basis_nhds_zero Valued.hasBasis_nhds_zero theorem hasBasis_uniformity : (𝓤 R).HasBasis (fun _ => True) fun γ : Γ₀ˣ => { p : R × R | v (p.2 - p.1) < (γ : Γ₀) } := by rw [uniformity_eq_comap_nhds_zero] exact (has_basis_nhds_zero R Γ₀).comap _ #align valued.has_basis_uniformity Valued.hasBasis_uniformity theorem toUniformSpace_eq : toUniformSpace = @TopologicalAddGroup.toUniformSpace R _ v.subgroups_basis.topology _ := uniformSpace_eq ((hasBasis_uniformity R Γ₀).eq_of_same_basis <| v.subgroups_basis.hasBasis_nhds_zero.comap _) #align valued.to_uniform_space_eq Valued.toUniformSpace_eq variable {R Γ₀} theorem mem_nhds {s : Set R} {x : R} : s ∈ 𝓝 x ↔ ∃ γ : Γ₀ˣ, { y | (v (y - x) : Γ₀) < γ } ⊆ s := by simp only [← nhds_translation_add_neg x, ← sub_eq_add_neg, preimage_set_of_eq, exists_true_left, ((has_basis_nhds_zero R Γ₀).comap fun y => y - x).mem_iff] #align valued.mem_nhds Valued.mem_nhds theorem mem_nhds_zero {s : Set R} : s ∈ 𝓝 (0 : R) ↔ ∃ γ : Γ₀ˣ, { x | v x < (γ : Γ₀) } ⊆ s := by simp only [mem_nhds, sub_zero] #align valued.mem_nhds_zero Valued.mem_nhds_zero theorem loc_const {x : R} (h : (v x : Γ₀) ≠ 0) : { y : R | v y = v x } ∈ 𝓝 x := by rw [mem_nhds] rcases units.exists_iff_ne_zero.mpr h with ⟨γ, hx⟩ use γ rw [hx] intro y y_in exact Valuation.map_eq_of_sub_lt _ y_in #align valued.loc_const Valued.loc_const instance (priority := 100) : TopologicalRing R := (toUniformSpace_eq R Γ₀).symm ▸ v.subgroups_basis.toRingFilterBasis.is_topologicalRing /- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x y «expr ∈ » M) -/ theorem cauchy_iff {F : Filter R} : Cauchy F ↔ F.ne_bot ∧ ∀ γ : Γ₀ˣ, ∃ M ∈ F, ∀ (x) (_ : x ∈ M) (y) (_ : y ∈ M), (v (y - x) : Γ₀) < γ := by rw [to_uniform_space_eq, AddGroupFilterBasis.cauchy_iff] apply and_congr Iff.rfl simp_rw [valued.v.subgroups_basis.mem_add_group_filter_basis_iff] constructor · intro h γ exact h _ (valued.v.subgroups_basis.mem_add_group_filter_basis _) · rintro h - ⟨γ, rfl⟩ exact h γ #align valued.cauchy_iff Valued.cauchy_iff end Valued
Stout , a kind of porter beer , particularly Guinness , is typically associated with Ireland , although historically it was more closely associated with London . Porter remains very popular , although it has lost sales since the mid @-@ 20th century to lager . Cider , particularly Magners ( marketed in the Republic of Ireland as <unk> ) , is also a popular drink . Red lemonade , a soft @-@ drink , is consumed on its own and as a mixer , particularly with whiskey .
lemma diameter_empty [simp]: "diameter{} = 0"
billcara.com is a website that ranks 1,028,619 in Alexa. billcara.com is ranked 709,474 on statisy and has 111,666 backlinks according to Alexa. The Site was launched at Dec 20 2004 and its old. The hostname or fully qualified domain name (FQDN) billcara.com is identical to the domain name billcara.com. The domain is registered under the domain suffix com and is named billcara. The billcara.com Server is hosted by Virtacore Systems Inc and is located in United States (Virginia). billcara.com is not listed in the dmoz open directory project. After analyzing billcara.com's demographics we have determined that billcara.com average users are 45-54 years old, with Graduate School. We also have determined that billcara.com's average user earns $100K+ a year and is most likely Male. Oh wait it seems like we know a little bit more about billcara.com's average user, they have No Children and browse from Home and are Caucasian.
(* * Copyright 2021, Data61, CSIRO (ABN 41 687 119 230) * * SPDX-License-Identifier: GPL-2.0-only *) theory Init_R imports KHeap_R begin context begin interpretation Arch . (*FIXME: arch_split*) (* This provides a very simple witness that the state relation used in the first refinement proof is non-trivial, by exhibiting a pair of related states. This helps guard against silly mistakes in the state relation, since we currently assume that the system starts in a state satisfying invariants and state relations. Note that the states we exhibit are not intended to be useful states. They are just the simplest possible states that prove non-triviality of the state relation. In particular, these states do not satisfy the respective invariant conditions. In future, this could be improved by exhibiting a tuple of more realistic states that are related across all levels of the refinement, and that also satisfy respective invariant. Ultimately, we would like to prove functional correctness of kernel initialisation. That would allow us to start from a minimal but real configuration that would allow us to make a much smaller set of assumptions about the initial configuration of the system. *) definition zeroed_arch_abstract_state :: arch_state where "zeroed_arch_abstract_state \<equiv> \<lparr> riscv_asid_table = Map.empty, riscv_global_pts = K {}, riscv_kernel_vspace = K RISCVVSpaceUserRegion \<rparr>" definition zeroed_main_abstract_state :: abstract_state where "zeroed_main_abstract_state \<equiv> \<lparr> kheap = Map.empty, cdt = Map.empty, is_original_cap = \<top>, cur_thread = 0, idle_thread = 0, machine_state = init_machine_state, interrupt_irq_node = (\<lambda>irq. ucast irq << cte_level_bits), interrupt_states = (K irq_state.IRQInactive), arch_state = zeroed_arch_abstract_state \<rparr>" definition zeroed_extended_state :: det_ext where "zeroed_extended_state \<equiv> \<lparr> work_units_completed_internal = 0, scheduler_action_internal = resume_cur_thread, ekheap_internal = Map.empty, domain_list_internal = [], domain_index_internal = 0, cur_domain_internal = 0, domain_time_internal = 0, ready_queues_internal = (\<lambda>_ _. []), cdt_list_internal = K [] \<rparr>" definition zeroed_abstract_state :: det_state where "zeroed_abstract_state \<equiv> abstract_state.extend zeroed_main_abstract_state (state.fields zeroed_extended_state)" definition zeroed_arch_intermediate_state :: Arch.kernel_state where "zeroed_arch_intermediate_state \<equiv> RISCVKernelState Map.empty (K []) (K RISCVVSpaceUserRegion)" definition zeroed_intermediate_state :: global.kernel_state where "zeroed_intermediate_state \<equiv> \<lparr> ksPSpace = Map.empty, gsUserPages = Map.empty, gsCNodes = Map.empty, gsUntypedZeroRanges = {}, gsMaxObjectSize = 0, ksDomScheduleIdx = 0, ksDomSchedule = [], ksCurDomain = 0, ksDomainTime = 0, ksReadyQueues = K [], ksReadyQueuesL1Bitmap = K 0, ksReadyQueuesL2Bitmap = K 0, ksCurThread = 0, ksIdleThread = 0, ksSchedulerAction = ResumeCurrentThread, ksInterruptState = (InterruptState 0 (K IRQInactive)), ksWorkUnitsCompleted = 0, ksArchState = zeroed_arch_intermediate_state, ksMachineState = init_machine_state \<rparr>" lemmas zeroed_state_defs = zeroed_main_abstract_state_def zeroed_abstract_state_def zeroed_arch_abstract_state_def zeroed_extended_state_def zeroed_intermediate_state_def abstract_state.defs zeroed_arch_intermediate_state_def lemma non_empty_refine_state_relation: "(zeroed_abstract_state, zeroed_intermediate_state) \<in> state_relation" apply (clarsimp simp: state_relation_def zeroed_state_defs state.defs) apply (intro conjI) apply (clarsimp simp: pspace_relation_def pspace_dom_def) apply (clarsimp simp: ekheap_relation_def) apply (clarsimp simp: ready_queues_relation_def) apply (clarsimp simp: ghost_relation_def) apply (fastforce simp: cdt_relation_def swp_def dest: cte_wp_at_domI) apply (clarsimp simp: cdt_list_relation_def map_to_ctes_def) apply (clarsimp simp: revokable_relation_def map_to_ctes_def) apply (clarsimp simp: zeroed_state_defs arch_state_relation_def) apply (clarsimp simp: interrupt_state_relation_def irq_state_relation_def cte_level_bits_def) done end end
f : {A B : Set} → (@0 A → B) → A → B f g x = g x
The hurricane dropped torrential rainfall over the Southeast United States , causing unprecedented devastation in the region . The storm was considered the worst to impact in the region in at least 29 years . Precipitation peaked at 20 @.@ 65 in ( 525 mm ) in Idlewild , North Carolina . The heavy rainfall caused streams to greatly exceed their respective flood stages , damaging waterfront property . Many of the deaths occurred in North Carolina , where 30 people died . Transportation was disrupted as a result of the debris scattered by the wind and rain . In Caldwell County alone , 90 percent of bridges were swept away . Overall , the storm caused 50 fatalities and $ 13 million in damages .
# After first running snoop_on(), open a new julia session and run this if !isinteractive() error("Because Gadfly uses the display, you must run this interactively") end using SnoopCompile, Gadfly SnoopCompile.@snoop1 "/tmp/gadfly_compiles.csv" begin include(Pkg.dir("Gadfly", "test","runtests.jl")) end snoop_off() data = SnoopCompile.read("/tmp/gadfly_compiles.csv") pc, discards = SnoopCompile.parcel(data[end:-1:1,2]) SnoopCompile.write("/tmp/precompile", pc)
for i in 1:5 println("Hiii number $i") sleep(1.0) end println("DONE")
[STATEMENT] lemma interior_std_simplex_nonempty: obtains a :: "'a::euclidean_space" where "a \<in> interior(convex hull (insert 0 Basis))" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<And>a. a \<in> interior (convex hull insert (0::'a) Basis) \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] proof - [PROOF STATE] proof (state) goal (1 subgoal): 1. (\<And>a. a \<in> interior (convex hull insert (0::'a) Basis) \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] let ?D = "Basis :: 'a set" [PROOF STATE] proof (state) goal (1 subgoal): 1. (\<And>a. a \<in> interior (convex hull insert (0::'a) Basis) \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] let ?a = "sum (\<lambda>b::'a. inverse (2 * real DIM('a)) *\<^sub>R b) Basis" [PROOF STATE] proof (state) goal (1 subgoal): 1. (\<And>a. a \<in> interior (convex hull insert (0::'a) Basis) \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] { [PROOF STATE] proof (state) goal (1 subgoal): 1. (\<And>a. a \<in> interior (convex hull insert (0::'a) Basis) \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] fix i :: 'a [PROOF STATE] proof (state) goal (1 subgoal): 1. (\<And>a. a \<in> interior (convex hull insert (0::'a) Basis) \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] assume i: "i \<in> Basis" [PROOF STATE] proof (state) this: i \<in> Basis goal (1 subgoal): 1. (\<And>a. a \<in> interior (convex hull insert (0::'a) Basis) \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] have "?a \<bullet> i = inverse (2 * real DIM('a))" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<Sum>b\<in>Basis. b /\<^sub>R (2 * real DIM('a))) \<bullet> i = inverse (2 * real DIM('a)) [PROOF STEP] by (rule trans[of _ "sum (\<lambda>j. if i = j then inverse (2 * real DIM('a)) else 0) ?D"]) (simp_all add: sum.If_cases i) [PROOF STATE] proof (state) this: (\<Sum>b\<in>Basis. b /\<^sub>R (2 * real DIM('a))) \<bullet> i = inverse (2 * real DIM('a)) goal (1 subgoal): 1. (\<And>a. a \<in> interior (convex hull insert (0::'a) Basis) \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] } [PROOF STATE] proof (state) this: ?i2 \<in> Basis \<Longrightarrow> (\<Sum>b\<in>Basis. b /\<^sub>R (2 * real DIM('a))) \<bullet> ?i2 = inverse (2 * real DIM('a)) goal (1 subgoal): 1. (\<And>a. a \<in> interior (convex hull insert (0::'a) Basis) \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] note ** = this [PROOF STATE] proof (state) this: ?i2 \<in> Basis \<Longrightarrow> (\<Sum>b\<in>Basis. b /\<^sub>R (2 * real DIM('a))) \<bullet> ?i2 = inverse (2 * real DIM('a)) goal (1 subgoal): 1. (\<And>a. a \<in> interior (convex hull insert (0::'a) Basis) \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) goal (1 subgoal): 1. thesis [PROOF STEP] proof [PROOF STATE] proof (state) goal (1 subgoal): 1. ?a \<in> interior (convex hull insert (0::'a) Basis) [PROOF STEP] show "?a \<in> interior(convex hull (insert 0 Basis))" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<Sum>b\<in>Basis. b /\<^sub>R (2 * real DIM('a))) \<in> interior (convex hull insert (0::'a) Basis) [PROOF STEP] unfolding interior_std_simplex mem_Collect_eq [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<forall>i\<in>Basis. 0 < sum ((*\<^sub>R) (inverse (2 * real DIM('a)))) Basis \<bullet> i) \<and> sum ((\<bullet>) (sum ((*\<^sub>R) (inverse (2 * real DIM('a)))) Basis)) Basis < 1 [PROOF STEP] proof safe [PROOF STATE] proof (state) goal (2 subgoals): 1. \<And>i. i \<in> Basis \<Longrightarrow> 0 < sum ((*\<^sub>R) (inverse (2 * real DIM('a)))) Basis \<bullet> i 2. sum ((\<bullet>) (sum ((*\<^sub>R) (inverse (2 * real DIM('a)))) Basis)) Basis < 1 [PROOF STEP] fix i :: 'a [PROOF STATE] proof (state) goal (2 subgoals): 1. \<And>i. i \<in> Basis \<Longrightarrow> 0 < sum ((*\<^sub>R) (inverse (2 * real DIM('a)))) Basis \<bullet> i 2. sum ((\<bullet>) (sum ((*\<^sub>R) (inverse (2 * real DIM('a)))) Basis)) Basis < 1 [PROOF STEP] assume i: "i \<in> Basis" [PROOF STATE] proof (state) this: i \<in> Basis goal (2 subgoals): 1. \<And>i. i \<in> Basis \<Longrightarrow> 0 < sum ((*\<^sub>R) (inverse (2 * real DIM('a)))) Basis \<bullet> i 2. sum ((\<bullet>) (sum ((*\<^sub>R) (inverse (2 * real DIM('a)))) Basis)) Basis < 1 [PROOF STEP] show "0 < ?a \<bullet> i" [PROOF STATE] proof (prove) goal (1 subgoal): 1. 0 < (\<Sum>b\<in>Basis. b /\<^sub>R (2 * real DIM('a))) \<bullet> i [PROOF STEP] unfolding **[OF i] [PROOF STATE] proof (prove) goal (1 subgoal): 1. 0 < inverse (2 * real DIM('a)) [PROOF STEP] by (auto simp add: Suc_le_eq) [PROOF STATE] proof (state) this: 0 < (\<Sum>b\<in>Basis. b /\<^sub>R (2 * real DIM('a))) \<bullet> i goal (1 subgoal): 1. sum ((\<bullet>) (sum ((*\<^sub>R) (inverse (2 * real DIM('a)))) Basis)) Basis < 1 [PROOF STEP] next [PROOF STATE] proof (state) goal (1 subgoal): 1. sum ((\<bullet>) (sum ((*\<^sub>R) (inverse (2 * real DIM('a)))) Basis)) Basis < 1 [PROOF STEP] have "sum ((\<bullet>) ?a) ?D = sum (\<lambda>i. inverse (2 * real DIM('a))) ?D" [PROOF STATE] proof (prove) goal (1 subgoal): 1. sum ((\<bullet>) (\<Sum>b\<in>Basis. b /\<^sub>R (2 * real DIM('a)))) Basis = (\<Sum>i\<in>Basis. inverse (2 * real DIM('a))) [PROOF STEP] by (auto intro: sum.cong) [PROOF STATE] proof (state) this: sum ((\<bullet>) (\<Sum>b\<in>Basis. b /\<^sub>R (2 * real DIM('a)))) Basis = (\<Sum>i\<in>Basis. inverse (2 * real DIM('a))) goal (1 subgoal): 1. sum ((\<bullet>) (sum ((*\<^sub>R) (inverse (2 * real DIM('a)))) Basis)) Basis < 1 [PROOF STEP] also [PROOF STATE] proof (state) this: sum ((\<bullet>) (\<Sum>b\<in>Basis. b /\<^sub>R (2 * real DIM('a)))) Basis = (\<Sum>i\<in>Basis. inverse (2 * real DIM('a))) goal (1 subgoal): 1. sum ((\<bullet>) (sum ((*\<^sub>R) (inverse (2 * real DIM('a)))) Basis)) Basis < 1 [PROOF STEP] have "\<dots> < 1" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<Sum>i\<in>Basis. inverse (2 * real DIM('a))) < 1 [PROOF STEP] unfolding sum_constant divide_inverse[symmetric] [PROOF STATE] proof (prove) goal (1 subgoal): 1. real DIM('a) / (2 * real DIM('a)) < 1 [PROOF STEP] by (auto simp add: field_simps) [PROOF STATE] proof (state) this: (\<Sum>i\<in>Basis. inverse (2 * real DIM('a))) < 1 goal (1 subgoal): 1. sum ((\<bullet>) (sum ((*\<^sub>R) (inverse (2 * real DIM('a)))) Basis)) Basis < 1 [PROOF STEP] finally [PROOF STATE] proof (chain) picking this: sum ((\<bullet>) (\<Sum>b\<in>Basis. b /\<^sub>R (2 * real DIM('a)))) Basis < 1 [PROOF STEP] show "sum ((\<bullet>) ?a) ?D < 1" [PROOF STATE] proof (prove) using this: sum ((\<bullet>) (\<Sum>b\<in>Basis. b /\<^sub>R (2 * real DIM('a)))) Basis < 1 goal (1 subgoal): 1. sum ((\<bullet>) (\<Sum>b\<in>Basis. b /\<^sub>R (2 * real DIM('a)))) Basis < 1 [PROOF STEP] by auto [PROOF STATE] proof (state) this: sum ((\<bullet>) (\<Sum>b\<in>Basis. b /\<^sub>R (2 * real DIM('a)))) Basis < 1 goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: (\<Sum>b\<in>Basis. b /\<^sub>R (2 * real DIM('a))) \<in> interior (convex hull insert (0::'a) Basis) goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: thesis goal: No subgoals! [PROOF STEP] qed
{-# OPTIONS --no-main #-} data List (A : Set) : Set where [] : List A _∷_ : A → List A → List A {-# COMPILE GHC List = data Non (Sense) #-} -- should result in warning when compiling {-# BUILTIN LIST List #-} {-# BUILTIN NIL [] #-} {-# BUILTIN CONS _∷_ #-}
/** * * RV-GOMEA * * If you use this software for any purpose, please cite the most recent publication: * A. Bouter, C. Witteveen, T. Alderliesten, P.A.N. Bosman. 2017. * Exploiting Linkage Information in Real-Valued Optimization with the Real-Valued * Gene-pool Optimal Mixing Evolutionary Algorithm. In Proceedings of the Genetic * and Evolutionary Computation Conference (GECCO 2017). * DOI: 10.1145/3071178.3071272 * * Copyright (c) 1998-2017 Peter A.N. Bosman * * The software in this file is the proprietary information of * Peter A.N. Bosman. * * IN NO EVENT WILL THE AUTHOR OF THIS SOFTWARE BE LIABLE TO YOU FOR ANY * DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST SAVINGS, OR OTHER * INCIDENTIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR THE INABILITY * TO USE SUCH PROGRAM, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY * OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. THE AUTHOR MAKES NO * REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THE * AUTHOR SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY ANYONE AS A RESULT OF * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. * * The software in this file is the result of (ongoing) scientific research. * The following people have been actively involved in this research over * the years: * - Peter A.N. Bosman * - Dirk Thierens * - Jörn Grahl * - Anton Bouter * */ #pragma once #include <stdio.h> #include <iostream> #include <stdlib.h> #include <math.h> #include <time.h> #include <sys/time.h> #include <eigen3/Eigen/Dense> #include <cblas.h> #include <lapack.h> using Eigen::MatrixXd; #define PI 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798 #define FALSE 0 #define TRUE 1 namespace GOMEA { void * Malloc(long size); void shrunkCovariance(MatrixXd & emp_cov, const double alpha); void shrunkCovarianceOAS(MatrixXd & emp_cov, const int pop_size); float choleskyDecomposition(MatrixXd & result, MatrixXd & matrix, int n); void lowerTriangularMatrixInverse(MatrixXd & A, const int n); int * mergeSort(double * array, int array_size); void mergeSortWithinBounds(double * array, int * sorted, int * tosort, int p, int q); void mergeSortWithinBoundsInt(int * array, int * sorted, int * tosort, int p, int q); void mergeSortMerge(double * array, int * sorted, int * tosort, int p, int r, int q); int * mergeSortInt(int * array, int array_size); void mergeSortMergeInt(int * array, int * sorted, int * tosort, int p, int r, int q); int * getRanks(double * array, int array_size); int * getRanksFromSorted(int * sorted, int array_size); double randomRealUniform01(void); int randomInt(int maximum); double random1DNormalUnit(void); double random1DNormalParameterized(double mean, double variance); void initializeRandomNumberGenerator(void); int * randomPermutation(int n); int ** allPermutations(int length, int * numberOfPermutations); int ** allPermutationsSubroutine(int from, int length, int * numberOfPermutations); double max(double x, double y); double min(double x, double y); double distanceEuclidean(double * solution_a, double * solution_b, int n); double distanceEuclidean2D(double x1, double y1, double x2, double y2); double * matrixVectorPartialMultiplication(double ** matrix, double * vector, int n0, int number_of_elements, int * element_indices); extern int64_t random_seed, /* The seed used for the random-number generator. */ random_seed_changing; /* Internally used variable for randomly setting a random seed. */ extern double haveNextNextGaussian, /* Internally used variable for sampling the normal distribution. */ nextNextGaussian; }
# --------------------------------------------- # Production log lik # --------------------------------------------- function loglik_produce_scalars(obs::ObservationProduce, theta::AbstractVector) αψ = theta_produce_ψ( obs, theta) σ2η = theta_produce_σ2η(obs, theta) σ2u = theta_produce_σ2u(obs, theta) a = σ2η^2 b = σ2u^2 T = length(obs) vpv = _nusumsq(obs) vp1 = _nusum( obs) abT = a + b*T ainv = 1/a c = b *ainv / abT ainv_cT = ainv - c*T A0 = -(T*log2π + (T-1)*log(a) + log(abT) + vpv*ainv - c*vp1^2) / 2 A1 = αψ*vp1*ainv_cT A2 = - (αψ^2*T*ainv_cT)/2 return A0, A1, A2 end function simloglik_produce!(obs::ObservationProduce, theta::AbstractVector, sim::SimulationDrawsVector) a, b, c = loglik_produce_scalars(obs, theta) f(x) = a + (b + c*x)*x qm = _qm(sim) # breaks 1.1.0 qm .+= f.(_psi2(sim)) end # --------------------------------------------- # Production gradient # --------------------------------------------- function grad_simloglik_produce!(grad::AbstractVector, obs::ObservationProduce, theta::AbstractVector, sim::SimulationDrawsVector) αψ = theta_produce_ψ( obs, theta) σ2η = theta_produce_σ2η(obs, theta) σ2u = theta_produce_σ2u(obs, theta) a = σ2η^2 b = σ2u^2 ψbar, ψ2bar = psi2_wtd_sum_and_sumsq(sim) Xpv = _xpnu(obs) Xp1 = _xsum(obs) T = length(obs) vpv = _nusumsq(obs) vp1 = _nusum(obs) vp1sq = vp1^2 abT = a + b*T abTinv = 1/abT abTinvsq = abTinv^2 ainv = 1/a ainvsq = ainv^2 c = b * ainv * abTinv ainv_cT = ainv - c*T αψT = αψ*T c_ainv_abTinv = c*(ainv+abTinv) # ∂log L / ∂α_ψ grad[idx_produce_ψ(obs)] += ainv_cT * (vp1*ψbar - αψT*ψ2bar) # ∂log L / ∂β H = c*vp1 + αψ*ainv_cT*ψbar grad[idx_produce_β(obs)] .+= Xpv.*ainv .- H.*Xp1 # ∂log L / ∂σ²η * ∂σ²η/∂ση E0 = -( (T-1)*ainv + abTinv - vpv*ainvsq + c_ainv_abTinv*vp1sq )/2 Einner = αψ*(-ainvsq + T*c_ainv_abTinv) E1 = Einner*vp1 E2 = -(αψT*Einner)/2 grad[idx_produce_σ2η(obs)] += 2*σ2η*(E0 + E1*ψbar + E2*ψ2bar) # ∂log L / σ²u * * ∂σ²u/∂σu G0 = -(T*abTinv - vp1sq*abTinvsq)/2 G1 = -αψT*vp1*abTinvsq G2 = ((αψT*abTinv)^2)/2 grad[idx_produce_σ2u(obs)] += 2*σ2u*(G0 + G1*ψbar + G2*ψ2bar) end function simloglik!(grad::AbstractVector, grp::ObservationGroupProduce, theta, sim, dograd; kwargs...) for obs in grp simloglik_produce!(obs, theta, sim) end end function grad_simloglik!(grad, grp::ObservationGroupProduce, theta, sim) for obs in grp grad_simloglik_produce!(grad, obs, theta, sim) end end # FOR TESTING ONLY function grad_simloglik_produce!( grad::AbstractVector, data::DataProduce, θ::AbstractVector, sim::SimulationDrawsMatrix, dograd::Bool ) qm = _qm(sim) M = _num_sim(sim) logM = log(M) # given θ update ν = y - X'β update!(data,θ) fill!(grad, 0) LL = 0.0 for (i,grp) in enumerate(data) simi = view(sim, i) fill!(qm, 0) for obs in grp simloglik_produce!(obs, θ, simi) end LL += logsumexp!(qm) - logM if dograd for obs in grp grad_simloglik_produce!(grad, obs, θ, simi) end end end grad .*= -1 return -LL end function solve_model(data::DataProduce, theta; M=500, alg=BFGS()) sim = SimulationDraws(M, length(data)) zvec = zeros(length(theta)) ff(x) = grad_simloglik_produce!(zvec, data, x, sim, false) ffgg!(grad, x) = grad_simloglik_produce!(grad, data, x, sim, true) odfg = OnceDifferentiable(ff, ffgg!, ffgg!, theta) opts = Optim.Options(time_limit = 60, allow_f_increases=true) res = optimize(odfg, theta, alg, opts) return res end
;; -------------------------------------------------------------------- ;; csv_read.jl ;; ;; Mar/02/2011 ;; ;; -------------------------------------------------------------------- (require 'tables) (load-file "/var/www/data_base/common/rep_common/text_manipulate.jl") ;; -------------------------------------------------------------------- (format t "*** 開始 ***") (setq file_in (cadr command-line-args)) (format t file_in) (setq dict_aa (make-table string-hash string=)) (let ((port_in (open-file file_in 'read))) (csv_read_proc port_in dict_aa) ) (table-walk dict_display_proc_single dict_aa) (format t "*** 終了 ***") ;; --------------------------------------------------------------------
variables A B C : Prop variable hA : A variable hB : B theorem and_ : ((A -> C) /\ (B -> not C)) -> not(A /\ B) := assume h1 : (A -> C) /\ (B -> not C), show not(A /\ B), from (assume h7 : A /\ B, have h3 : A -> C, from and.left h1, have h4 : C, from h3 hA, have h6 : B -> not C, from and.right h1, have h5 : not C, from h6 hB, show false, from h5 h4)
import Lean macro "t" t:interpolatedStr(term) : doElem => `(doElem| Macro.trace[Meta.debug] $t) macro "tstcmd" : command => do t "hello" `(example : Nat := 1) set_option trace.Meta.debug true in tstcmd open Lean Meta macro "r" r:interpolatedStr(term) : doElem => `(doElem| trace[Meta.debug] $r) set_option trace.Meta.debug true in #eval show MetaM _ from do r "world"
(* Title: Eisbach_Protocol_Verification.thy Author: Andreas Viktor Hess, DTU Author: Sebastian A. Mödersheim, DTU Author: Achim D. Brucker, University of Exeter Author: Anders Schlichtkrull, DTU SPDX-License-Identifier: BSD-3-Clause *) section \<open>Useful Eisbach Methods for Automating Protocol Verification\<close> theory Eisbach_Protocol_Verification imports Stateful_Protocol_Composition_and_Typing.Stateful_Compositionality "HOL-Eisbach.Eisbach_Tools" begin named_theorems exhausts named_theorems type_class_instance_lemmata named_theorems protocol_checks named_theorems protocol_checks' named_theorems coverage_check_unfold_protocol_lemma named_theorems coverage_check_unfold_transaction_lemma named_theorems coverage_check_unfold_lemmata named_theorems protocol_check_intro_lemmata named_theorems transaction_coverage_lemmata method UNIV_lemma = (rule UNIV_eq_I; (subst insert_iff)+; subst empty_iff; smt exhausts)+ method type_class_instance = (intro_classes; auto simp add: type_class_instance_lemmata) method protocol_model_subgoal = (((rule allI, case_tac f); (erule forw_subst)+)?; simp_all) method protocol_model_interpretation = (unfold_locales; protocol_model_subgoal+) method composable_protocols_intro = (unfold protocol_checks' Let_def; intro comp_par_comp\<^sub>l\<^sub>s\<^sub>s\<^sub>tI'; (simp only: list.map(1,2) prod.sel(1))?; (intro list_set_ballI)?; (simp only: if_P if_not_P)?) method coverage_check_intro = (((unfold coverage_check_unfold_protocol_lemma)?; intro protocol_check_intro_lemmata; simp only: list_all_simps list_all_append list.map concat.simps map_append product_concat_map; intro conjI TrueI); clarsimp?; (intro conjI TrueI)?; (rule transaction_coverage_lemmata)?) method coverage_check_unfold = (unfold coverage_check_unfold_lemmata Let_def case_prod_unfold Product_Type.fst_conv Product_Type.snd_conv; simp only: list_all_simps; intro conjI TrueI) method coverage_check_intro' = (((unfold coverage_check_unfold_protocol_lemma coverage_check_unfold_transaction_lemma)?; intro protocol_check_intro_lemmata; simp only: list_all_simps list_all_append list.map concat.simps map_append product_concat_map; intro conjI TrueI); (clarsimp+)?; (intro conjI TrueI)?; ((rule transaction_coverage_lemmata)+)?; coverage_check_unfold) method check_protocol_intro = (unfold_locales, unfold protocol_checks[symmetric]) method check_protocol_intro' = ((check_protocol_intro; coverage_check_intro?; (unfold protocol_checks'; intro conjI)?), tactic distinct_subgoals_tac) method check_protocol_with methods meth = (check_protocol_intro; meth) method check_protocol = (check_protocol_with \<open>coverage_check_intro?; code_simp\<close>) method check_protocol_nbe = (check_protocol_with \<open>coverage_check_intro?; normalization\<close>) method check_protocol_unsafe = (check_protocol_with \<open>coverage_check_intro?; eval\<close>) end
// Copyright John Maddock 2007. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // Note that this file contains quickbook mark-up as well as code // and comments, don't change any of the special comment mark-ups! //[policy_eg_10 /*` To understand how the rounding policies for the discrete distributions can be used, we'll use the 50-sample binomial distribution with a success fraction of 0.5 once again, and calculate all the possible quantiles at 0.05 and 0.95. Begin by including the needed headers: */ #include <iostream> #include <boost/math/distributions/binomial.hpp> /*` Next we'll bring the needed declarations into scope, and define distribution types for all the available rounding policies: */ using namespace boost::math::policies; using namespace boost::math; typedef binomial_distribution< double, policy<discrete_quantile<integer_round_outwards> > > binom_round_outwards; typedef binomial_distribution< double, policy<discrete_quantile<integer_round_inwards> > > binom_round_inwards; typedef binomial_distribution< double, policy<discrete_quantile<integer_round_down> > > binom_round_down; typedef binomial_distribution< double, policy<discrete_quantile<integer_round_up> > > binom_round_up; typedef binomial_distribution< double, policy<discrete_quantile<integer_round_nearest> > > binom_round_nearest; typedef binomial_distribution< double, policy<discrete_quantile<real> > > binom_real_quantile; /*` Now let's set to work calling those quantiles: */ int main() { std::cout << "Testing rounding policies for a 50 sample binomial distribution,\n" "with a success fraction of 0.5.\n\n" "Lower quantiles are calculated at p = 0.05\n\n" "Upper quantiles at p = 0.95.\n\n"; std::cout << std::setw(25) << std::right << "Policy"<< std::setw(18) << std::right << "Lower Quantile" << std::setw(18) << std::right << "Upper Quantile" << std::endl; // Test integer_round_outwards: std::cout << std::setw(25) << std::right << "integer_round_outwards" << std::setw(18) << std::right << quantile(binom_round_outwards(50, 0.5), 0.05) << std::setw(18) << std::right << quantile(binom_round_outwards(50, 0.5), 0.95) << std::endl; // Test integer_round_inwards: std::cout << std::setw(25) << std::right << "integer_round_inwards" << std::setw(18) << std::right << quantile(binom_round_inwards(50, 0.5), 0.05) << std::setw(18) << std::right << quantile(binom_round_inwards(50, 0.5), 0.95) << std::endl; // Test integer_round_down: std::cout << std::setw(25) << std::right << "integer_round_down" << std::setw(18) << std::right << quantile(binom_round_down(50, 0.5), 0.05) << std::setw(18) << std::right << quantile(binom_round_down(50, 0.5), 0.95) << std::endl; // Test integer_round_up: std::cout << std::setw(25) << std::right << "integer_round_up" << std::setw(18) << std::right << quantile(binom_round_up(50, 0.5), 0.05) << std::setw(18) << std::right << quantile(binom_round_up(50, 0.5), 0.95) << std::endl; // Test integer_round_nearest: std::cout << std::setw(25) << std::right << "integer_round_nearest" << std::setw(18) << std::right << quantile(binom_round_nearest(50, 0.5), 0.05) << std::setw(18) << std::right << quantile(binom_round_nearest(50, 0.5), 0.95) << std::endl; // Test real: std::cout << std::setw(25) << std::right << "real" << std::setw(18) << std::right << quantile(binom_real_quantile(50, 0.5), 0.05) << std::setw(18) << std::right << quantile(binom_real_quantile(50, 0.5), 0.95) << std::endl; } /*` Which produces the program output: [pre Testing rounding policies for a 50 sample binomial distribution, with a success fraction of 0.5. Lower quantiles are calculated at p = 0.05 Upper quantiles at p = 0.95. Testing rounding policies for a 50 sample binomial distribution, with a success fraction of 0.5. Lower quantiles are calculated at p = 0.05 Upper quantiles at p = 0.95. Policy Lower Quantile Upper Quantile integer_round_outwards 18 31 integer_round_inwards 19 30 integer_round_down 18 30 integer_round_up 19 31 integer_round_nearest 19 30 real 18.701 30.299 ] */ //] ends quickbook import
\section{\scshape Sensors deployment} \subsection*{Sensors deployment} \begin{frame}{Sensors deployment} \begin{itemize} \item For making the estimation of the sensor disposition computational feasible, the 3D continuous space was populated with a given set of sensors that were looking at a given point (with the sensor roll either 0º or random) \item Several populations of sensors can be added to the world \begin{itemize} \item The 3D sensor models will be hidden at rendering time to avoid occlusion of sensor data \end{itemize} \item Each population is of a given sensor type and is deployed within a given region of interest \begin{itemize} \item This allows to restrict the spatial distribution of the sensors, for example a given set of sensors should be in the walls or ceiling due to their weight, or they should be close to the target object given their limited depth measurements range \end{itemize} \item Currently supported deployment configurations: \begin{itemize} \item Uniform or random deployment within a box \item Uniform or random deployment within a cylinder \item Uniform within a 2D grid (with a set of rows and columns) \item Uniform along a line \end{itemize} \end{itemize} \end{frame} \begin{frame}{Sensors deployment} \begin{itemize} \item For the active perception environment, 450 sensors were deployed close to the target object, on the top, right and back side of the trolley \item This was done to simulate the closest range in which a dynamically moving sensor attached to a robotic arm could move (taking into consideration the human safety and the sensor minimum measurement distance, that was 0.2 meters) \end{itemize} \begin{figure} \centering \includegraphics[height=.25\textwidth]{sensor-deployment/active-perception/gazebo-front} \includegraphics[height=.25\textwidth]{sensor-deployment/active-perception/gazebo-top} \caption{Sensors deployment on the active perception environment} \end{figure} \end{frame} \begin{frame}{Sensors deployment} \begin{itemize} \item For the single bin picking environments, given that the target object was inside the stacking box, the sensors were deployed close to the target object, but only on top of the trolley, on 3 layers (each with a different type of sensor). \item In the world with minimal occlusions it was deployed 100 sensors while in the world with significant occlusions it was deployed 300 sensors \begin{itemize} \item The sensor density was increased given that the best views have tighter observation regions which could be missed with a sparse sensor deployment \end{itemize} \end{itemize} \begin{figure} \centering \includegraphics[height=.24\textwidth]{sensor-deployment/bin-picking/gazebo-sensors} \includegraphics[height=.24\textwidth]{sensor-deployment/bin-picking-with-occlusions/gazebo-sensors} \caption{Sensors deployment on the single bin picking environments} \end{figure} \end{frame} \begin{frame}{Sensors deployment} \begin{itemize} \item For the multiple bin picking environment, given that there were multiple target objects (1 inside the stacking box, 1 on top and 2 on the shelves of the trolley), it was deployed 450 sensors across 7 populations: \begin{itemize} \item 5 populations simulating fixed sensors on the walls and ceiling \item 2 populations above the trolley, simulating dynamic sensors attached to a robotic arm \end{itemize} \end{itemize} \begin{figure} \centering \includegraphics[height=.3\textwidth]{sensor-deployment/multiple-bin-picking-with-occlusions/gazebo-front}\hspace{2em} \includegraphics[height=.3\textwidth]{sensor-deployment/multiple-bin-picking-with-occlusions/gazebo-top} \caption{Sensors deployment on the multiple bin picking environment} \end{figure} \end{frame}
#= A call to app/render using tiny image. >julia julia> include("render.jl") julia> @time test(image) =# # For "load" local files using FileIO # The tested item include("../../src/apps/render.jl") # mock test data # global so it persists and out of the test image = load("/home/bootch/git/resynthesizerJulia/test/data/in/mediumlighthouse.png") # selection mask for corpus # medium mask = falses(size(image)) mask[15:30,85:100] .= true function test(image, mask) render(image, mask) end # Expect an image with texture of the lighthouse, everywhere
[STATEMENT] lemma norm_isometry_compose: assumes \<open>isometry U\<close> shows \<open>norm (U o\<^sub>C\<^sub>L A) = norm A\<close> [PROOF STATE] proof (prove) goal (1 subgoal): 1. norm (U o\<^sub>C\<^sub>L A) = norm A [PROOF STEP] proof - [PROOF STATE] proof (state) goal (1 subgoal): 1. norm (U o\<^sub>C\<^sub>L A) = norm A [PROOF STEP] have *: \<open>norm (U *\<^sub>V A *\<^sub>V \<psi>) = norm (A *\<^sub>V \<psi>)\<close> for \<psi> [PROOF STATE] proof (prove) goal (1 subgoal): 1. norm (U *\<^sub>V A *\<^sub>V \<psi>) = norm (A *\<^sub>V \<psi>) [PROOF STEP] by (smt (verit, ccfv_threshold) assms cblinfun_apply_cblinfun_compose cinner_adj_right cnorm_eq id_cblinfun_apply isometryD) [PROOF STATE] proof (state) this: norm (U *\<^sub>V A *\<^sub>V ?\<psi>) = norm (A *\<^sub>V ?\<psi>) goal (1 subgoal): 1. norm (U o\<^sub>C\<^sub>L A) = norm A [PROOF STEP] have \<open>norm (U o\<^sub>C\<^sub>L A) = (SUP \<psi>. norm (U *\<^sub>V A *\<^sub>V \<psi>) / norm \<psi>)\<close> [PROOF STATE] proof (prove) goal (1 subgoal): 1. norm (U o\<^sub>C\<^sub>L A) = (\<Squnion>\<psi>. norm (U *\<^sub>V A *\<^sub>V \<psi>) / norm \<psi>) [PROOF STEP] unfolding norm_cblinfun_Sup [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<Squnion>\<psi>. norm ((U o\<^sub>C\<^sub>L A) *\<^sub>V \<psi>) / norm \<psi>) = (\<Squnion>\<psi>. norm (U *\<^sub>V A *\<^sub>V \<psi>) / norm \<psi>) [PROOF STEP] by auto [PROOF STATE] proof (state) this: norm (U o\<^sub>C\<^sub>L A) = (\<Squnion>\<psi>. norm (U *\<^sub>V A *\<^sub>V \<psi>) / norm \<psi>) goal (1 subgoal): 1. norm (U o\<^sub>C\<^sub>L A) = norm A [PROOF STEP] also [PROOF STATE] proof (state) this: norm (U o\<^sub>C\<^sub>L A) = (\<Squnion>\<psi>. norm (U *\<^sub>V A *\<^sub>V \<psi>) / norm \<psi>) goal (1 subgoal): 1. norm (U o\<^sub>C\<^sub>L A) = norm A [PROOF STEP] have \<open>\<dots> = (SUP \<psi>. norm (A *\<^sub>V \<psi>) / norm \<psi>)\<close> [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<Squnion>\<psi>. norm (U *\<^sub>V A *\<^sub>V \<psi>) / norm \<psi>) = (\<Squnion>\<psi>. norm (A *\<^sub>V \<psi>) / norm \<psi>) [PROOF STEP] using * [PROOF STATE] proof (prove) using this: norm (U *\<^sub>V A *\<^sub>V ?\<psi>) = norm (A *\<^sub>V ?\<psi>) goal (1 subgoal): 1. (\<Squnion>\<psi>. norm (U *\<^sub>V A *\<^sub>V \<psi>) / norm \<psi>) = (\<Squnion>\<psi>. norm (A *\<^sub>V \<psi>) / norm \<psi>) [PROOF STEP] by auto [PROOF STATE] proof (state) this: (\<Squnion>\<psi>. norm (U *\<^sub>V A *\<^sub>V \<psi>) / norm \<psi>) = (\<Squnion>\<psi>. norm (A *\<^sub>V \<psi>) / norm \<psi>) goal (1 subgoal): 1. norm (U o\<^sub>C\<^sub>L A) = norm A [PROOF STEP] also [PROOF STATE] proof (state) this: (\<Squnion>\<psi>. norm (U *\<^sub>V A *\<^sub>V \<psi>) / norm \<psi>) = (\<Squnion>\<psi>. norm (A *\<^sub>V \<psi>) / norm \<psi>) goal (1 subgoal): 1. norm (U o\<^sub>C\<^sub>L A) = norm A [PROOF STEP] have \<open>\<dots> = norm A\<close> [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<Squnion>\<psi>. norm (A *\<^sub>V \<psi>) / norm \<psi>) = norm A [PROOF STEP] unfolding norm_cblinfun_Sup [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<Squnion>\<psi>. norm (A *\<^sub>V \<psi>) / norm \<psi>) = (\<Squnion>\<psi>. norm (A *\<^sub>V \<psi>) / norm \<psi>) [PROOF STEP] by auto [PROOF STATE] proof (state) this: (\<Squnion>\<psi>. norm (A *\<^sub>V \<psi>) / norm \<psi>) = norm A goal (1 subgoal): 1. norm (U o\<^sub>C\<^sub>L A) = norm A [PROOF STEP] finally [PROOF STATE] proof (chain) picking this: norm (U o\<^sub>C\<^sub>L A) = norm A [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) using this: norm (U o\<^sub>C\<^sub>L A) = norm A goal (1 subgoal): 1. norm (U o\<^sub>C\<^sub>L A) = norm A [PROOF STEP] by simp [PROOF STATE] proof (state) this: norm (U o\<^sub>C\<^sub>L A) = norm A goal: No subgoals! [PROOF STEP] qed
<?xml version="1.0" encoding="utf-8"?> <serviceModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="FirstCloudProject" generation="1" functional="0" release="0" Id="9bf5b424-137b-4ec9-9329-925099acb772" dslVersion="1.2.0.0" xmlns="http://schemas.microsoft.com/dsltools/RDSM"> <groups> <group name="FirstCloudProjectGroup" generation="1" functional="0" release="0"> <componentports> <inPort name="WebRole1:Endpoint1" protocol="http"> <inToChannel> <lBChannelMoniker name="/FirstCloudProject/FirstCloudProjectGroup/LB:WebRole1:Endpoint1" /> </inToChannel> </inPort> </componentports> <settings> <aCS name="WebRole1:Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" defaultValue=""> <maps> <mapMoniker name="/FirstCloudProject/FirstCloudProjectGroup/MapWebRole1:Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" /> </maps> </aCS> <aCS name="WebRole1Instances" defaultValue="[1,1,1]"> <maps> <mapMoniker name="/FirstCloudProject/FirstCloudProjectGroup/MapWebRole1Instances" /> </maps> </aCS> <aCS name="WorkerRole1:Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" defaultValue=""> <maps> <mapMoniker name="/FirstCloudProject/FirstCloudProjectGroup/MapWorkerRole1:Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" /> </maps> </aCS> <aCS name="WorkerRole1Instances" defaultValue="[1,1,1]"> <maps> <mapMoniker name="/FirstCloudProject/FirstCloudProjectGroup/MapWorkerRole1Instances" /> </maps> </aCS> </settings> <channels> <lBChannel name="LB:WebRole1:Endpoint1"> <toPorts> <inPortMoniker name="/FirstCloudProject/FirstCloudProjectGroup/WebRole1/Endpoint1" /> </toPorts> </lBChannel> </channels> <maps> <map name="MapWebRole1:Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" kind="Identity"> <setting> <aCSMoniker name="/FirstCloudProject/FirstCloudProjectGroup/WebRole1/Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" /> </setting> </map> <map name="MapWebRole1Instances" kind="Identity"> <setting> <sCSPolicyIDMoniker name="/FirstCloudProject/FirstCloudProjectGroup/WebRole1Instances" /> </setting> </map> <map name="MapWorkerRole1:Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" kind="Identity"> <setting> <aCSMoniker name="/FirstCloudProject/FirstCloudProjectGroup/WorkerRole1/Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" /> </setting> </map> <map name="MapWorkerRole1Instances" kind="Identity"> <setting> <sCSPolicyIDMoniker name="/FirstCloudProject/FirstCloudProjectGroup/WorkerRole1Instances" /> </setting> </map> </maps> <components> <groupHascomponents> <role name="WebRole1" generation="1" functional="0" release="0" software="\\vmware-host\Shared Folders\Documents\Visual Studio 2015\Projects\FirstCloudProject\FirstCloudProject\csx\Debug\roles\WebRole1" entryPoint="base\x64\WaHostBootstrapper.exe" parameters="base\x64\WaIISHost.exe " memIndex="-1" hostingEnvironment="frontendadmin" hostingEnvironmentVersion="2"> <componentports> <inPort name="Endpoint1" protocol="http" portRanges="80" /> </componentports> <settings> <aCS name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" defaultValue="" /> <aCS name="__ModelData" defaultValue="&lt;m role=&quot;WebRole1&quot; xmlns=&quot;urn:azure:m:v1&quot;&gt;&lt;r name=&quot;WebRole1&quot;&gt;&lt;e name=&quot;Endpoint1&quot; /&gt;&lt;/r&gt;&lt;r name=&quot;WorkerRole1&quot; /&gt;&lt;/m&gt;" /> </settings> <resourcereferences> <resourceReference name="DiagnosticStore" defaultAmount="[4096,4096,4096]" defaultSticky="true" kind="Directory" /> <resourceReference name="EventStore" defaultAmount="[1000,1000,1000]" defaultSticky="false" kind="LogStore" /> </resourcereferences> </role> <sCSPolicy> <sCSPolicyIDMoniker name="/FirstCloudProject/FirstCloudProjectGroup/WebRole1Instances" /> <sCSPolicyUpdateDomainMoniker name="/FirstCloudProject/FirstCloudProjectGroup/WebRole1UpgradeDomains" /> <sCSPolicyFaultDomainMoniker name="/FirstCloudProject/FirstCloudProjectGroup/WebRole1FaultDomains" /> </sCSPolicy> </groupHascomponents> <groupHascomponents> <role name="WorkerRole1" generation="1" functional="0" release="0" software="\\vmware-host\Shared Folders\Documents\Visual Studio 2015\Projects\FirstCloudProject\FirstCloudProject\csx\Debug\roles\WorkerRole1" entryPoint="base\x64\WaHostBootstrapper.exe" parameters="base\x64\WaWorkerHost.exe " memIndex="-1" hostingEnvironment="consoleroleadmin" hostingEnvironmentVersion="2"> <settings> <aCS name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" defaultValue="" /> <aCS name="__ModelData" defaultValue="&lt;m role=&quot;WorkerRole1&quot; xmlns=&quot;urn:azure:m:v1&quot;&gt;&lt;r name=&quot;WebRole1&quot;&gt;&lt;e name=&quot;Endpoint1&quot; /&gt;&lt;/r&gt;&lt;r name=&quot;WorkerRole1&quot; /&gt;&lt;/m&gt;" /> </settings> <resourcereferences> <resourceReference name="DiagnosticStore" defaultAmount="[4096,4096,4096]" defaultSticky="true" kind="Directory" /> <resourceReference name="EventStore" defaultAmount="[1000,1000,1000]" defaultSticky="false" kind="LogStore" /> </resourcereferences> </role> <sCSPolicy> <sCSPolicyIDMoniker name="/FirstCloudProject/FirstCloudProjectGroup/WorkerRole1Instances" /> <sCSPolicyUpdateDomainMoniker name="/FirstCloudProject/FirstCloudProjectGroup/WorkerRole1UpgradeDomains" /> <sCSPolicyFaultDomainMoniker name="/FirstCloudProject/FirstCloudProjectGroup/WorkerRole1FaultDomains" /> </sCSPolicy> </groupHascomponents> </components> <sCSPolicy> <sCSPolicyUpdateDomain name="WebRole1UpgradeDomains" defaultPolicy="[5,5,5]" /> <sCSPolicyUpdateDomain name="WorkerRole1UpgradeDomains" defaultPolicy="[5,5,5]" /> <sCSPolicyFaultDomain name="WebRole1FaultDomains" defaultPolicy="[2,2,2]" /> <sCSPolicyFaultDomain name="WorkerRole1FaultDomains" defaultPolicy="[2,2,2]" /> <sCSPolicyID name="WebRole1Instances" defaultPolicy="[1,1,1]" /> <sCSPolicyID name="WorkerRole1Instances" defaultPolicy="[1,1,1]" /> </sCSPolicy> </group> </groups> <implements> <implementation Id="4f788f62-4f1e-4cf2-b901-e0fe8b51aa85" ref="Microsoft.RedDog.Contract\ServiceContract\FirstCloudProjectContract@ServiceDefinition"> <interfacereferences> <interfaceReference Id="37b93ef1-ce9c-4545-bd0a-6663908c96e3" ref="Microsoft.RedDog.Contract\Interface\WebRole1:Endpoint1@ServiceDefinition"> <inPort> <inPortMoniker name="/FirstCloudProject/FirstCloudProjectGroup/WebRole1:Endpoint1" /> </inPort> </interfaceReference> </interfacereferences> </implementation> </implements> </serviceModel>
lemma snd_quot_of_fract_nonzero [simp]: "snd (quot_of_fract x) \<noteq> 0"
open import Relation.Binary.Core module TreeSort.Impl1.Correctness.Permutation {A : Set} (_≤_ : A → A → Set) (tot≤ : Total _≤_) where open import BTree {A} open import Data.List open import Data.Sum open import List.Permutation.Base A open import List.Permutation.Base.Concatenation A open import List.Permutation.Base.Equivalence A open import TreeSort.Impl1 _≤_ tot≤ lemma-++∼ : {x : A}{xs ys : List A} → (x ∷ (xs ++ ys)) ∼ (xs ++ (x ∷ ys)) lemma-++∼ {xs = xs} = ∼x /head (lemma++/l {xs = xs} /head) refl∼ lemma-flatten∼ : (x : A) → (t : BTree) → (x ∷ flatten t) ∼ flatten (insert x t) lemma-flatten∼ x leaf = ∼x /head /head ∼[] lemma-flatten∼ x (node y l r) with tot≤ x y ... | inj₁ x≤y = lemma++∼r (lemma-flatten∼ x l) ... | inj₂ y≤x = trans∼ (lemma-++∼ {xs = flatten l}) (lemma++∼l {xs = flatten l} (∼x (/tail /head) /head (lemma-flatten∼ x r))) theorem-treeSort∼ : (xs : List A) → xs ∼ (flatten (treeSort xs)) theorem-treeSort∼ [] = ∼[] theorem-treeSort∼ (x ∷ xs) = trans∼ (∼x /head /head (theorem-treeSort∼ xs)) (lemma-flatten∼ x (treeSort xs))
%!TEX root = ../chapter2.tex %****************************** % Results %****************************** \section{Single-cell RNA sequencing of murine CD4\plus{} T cells} \begin{wrapfigure}{r}{0.5\textwidth} \centering \includegraphics[width=0.48\textwidth]{Fig_1.png} \caption[scRNA-Seq of CD4\plus{} T cells from young and old mice.]{\textbf{scRNA-Seq of unstimulated and activated CD4\plus{} T cells from young and old B6 and CAST animals.} \\ Single cells were isolated from spleens of young (~3 month) and old (~21 month) individuals of two related mouse sub-species (\textit{Mus musculus domesticus}, B6; \textit{Mus musculus castaneus}, CAST). Isolated cells were subjected to single-cell mRNA sequencing (scRNA-Seq) before or after 3 hours of \textit{in vitro} activation using anti-CD3\textepsilon{} and CD28 coated plates.} \label{fig1:overview} \end{wrapfigure} To assess transcriptional changes of the immune activation programme during ageing, we isolated CD4\plus{} T cells from healthy individuals of two inbred mouse sub-species separated by 1 million years of divergence: the reference C57BL/6J, \gls{B6} and CAST/EiJ, \gls{CAST}. Furthermore, we isolated CD4\plus{} T cells from young (~3 months) and old (~21 months) individuals. To characterise their gene expression programme, we performed scRNA-Seq using the C1 Fluidigm system \textbf{(Fig.~\ref{fig1:overview})}. The two sub-species have similar lifespans \citep{Yuan2011}, and CAST mice showed the hallmarks of normal organismal ageing as observed in B6 mice \citep{Rodwell2004}. All mice were healthy at the time of experiments. To assess different CD4\plus{} T cell compartments, we assayed cell populations isolated with different levels of purity. First, we isolated all unstimulated CD4\plus{} T cells from spleens of old and young animals. Secondly, we highly purified naive CD4\plus{} T cells and \gls{EM} CD4\plus{} T cells. For simplification and clarity, purified unstimulated CD4\plus{} T cells will be named naive; stimulated cells will be named activated. Highly purified naive CD4\plus{} T cells will be named FACS-purified naive CD4\plus{} T cells and highly purified EM CD4\plus{} T cell will be referred to as FACS-purified EM CD4\plus{} T cells. For each species/condition, scRNA-Seq experiments were independently performed using cells isolated from two individuals. Full experimental methods can be found in \textbf{Appendix \ref{appA.1}}. \newpage \subsection{Experimental strategy} \subsubsection{Unstimulated CD4\plus{} T cells} \begin{wrapfigure}{rt}{0.5\textwidth} \centering \includegraphics[width=0.48\textwidth]{Fig_2.png} \caption[FACS of naive and effector memory CD4\plus{} T cells]{\textbf{FACS of naive and effector memory CD4\plus{} T cells.} \\ Gating Strategy: lymphocytes were gated by the use of \gls{FSC} and \gls{SSC}. Cell doublets were excluded according to area and height of FSC (FSC-A/FSC-H). Dead cells were removed using viability dye. \Gls{PD1}\plus{} CD4\plus{} T cells were excluded and PD-1$\text{-ve}$ CD4\plus{} T cells were further separated into naive and EM CD4\plus{} T cell subsets according to their CD44 and CD62L expression. Cells with a mature CD24$^\text{lo}$ Qa2$^\text{hi}$ phenotype were then gated from naive and EM subsets and CD69\plus{} cells were removed. From \citep{Martinez-jimenez2017}. Reprinted with permission from AAAS.} \label{fig1:FACS} \vspace{-50mm} \end{wrapfigure} Unstimulated CD4\plus{} T cells were purified from dissociated mouse spleens using cell strainers, cell separation media and a \gls{MACS} CD4\plus{} CD62L\plus{} T Cell Isolation Kit (see \textbf{Appendix \ref{appA.1:isolation}}). \subsubsection{Naive and effector memory CD4\plus{} T cells} Naive and EM CD4\plus{} T cells were purified from spleens of both young and old BL6 mice by \gls{FACS}. Briefly, spleens were harvested from both young and old animals and single cell suspensions were obtained by meshing through a cell strainer. B cells were depleted from cell suspensions by \gls{MACS} using CD19 microbeads and red blood cells were lysed with red blood cell lysis buffer. The enriched cell fraction was then stained with Fixable eFluor 780 viability dye following Fc receptor blocking with TruStain fcXTM and subsequent staining with a panel of fluorescence-conjugated antibodies against CD4, CD44, CD62L, CD24, Qa2, CD69 and PD-1. Stained cells were immediately sorted using FACS with the stringent gating strategy described in \textbf{Fig.~\ref{fig1:FACS}} (see \textbf{Appendix \ref{appA.1:FACS}}). \newpage \subsubsection{Activation of CD4\plus{} T cells} 96-well plates were coated with anti-CD3\textepsilon{} and anti-CD28 antibodies (see \textbf{Appendix \ref{appA.1:isolation}}). After this, naive and FACS-purified naive cells were seeded into these plates at a density of 80,000-120,000 cells/ml, and then cultured in a total volume of 100 \textmu{}l media that did not contain cytokines or additional antibodies. With this strategy, CD4\plus{} T cells are purely activated but do not commit to a T helper cell fate \citep{Stubbington2015, Zhu2010}. \subsubsection{scRNA-Seq using the Fluidigm C1 system} Unstimulated and activated CD4\plus{} T cells were loaded on a 5–10 \textmu{}m Auto Prep IFC to capture single cells using the C1 Single cell Auto Prep System (Fluidigm). All IFCs were visually inspected, and wells with multiple cells or cell debris were marked as low quality. Upon cell capture, reverse transcription and cDNA amplification were performed using the SMARTer PCR cDNA Synthesis Kit and the Advantage 2 PCR Kit. ERCC spike-in RNA (1 \textmu{}L diluted at 1:50,000) was added to the C1 lysis mix. All capture sites were included for the RNA-Seq library preparation (see \textbf{Appendix \ref{appA.1:RNA-Seq}}). \subsection{Computational strategy} \label{sec1:computational} \subsubsection{Read alignment to reference genomes} For all capture sites, read alignment to reference genomes was performed using \emph{gsnap} with default parameters, while supplying splice-site positions \citep{Wu2010a}. Samples taken from B6 were mapped against the mouse reference \gls{GRCm38}. CAST samples were aligned against the \emph{Mus musculus castaneus de novo} genome assembly (\url{ftp://ftp-mouse.sanger.ac.uk/REL-1509-Assembly/}, now available on Ensembl \url{ftp://ftp.ensembl.org/pub/release-92/fasta/mus_musculus_casteij/dna/}), which was used under an advance access agreement (\url{ftp://ftp-mouse.sanger.ac.uk/REL-1509-Assembly/README}). Gene annotation for B6 was taken from the GRCm38 reference; gene annotation for CAST was taken from the newly constructed \emph{Mus musculus castaneus} assembly (\url{http://hgwdev.cse.ucsc.edu/~ifiddes/mouse_genomes_data/}, version 0.2, now available at \url{ftp://ftp.ensembl.org/pub/release-92/gtf/mus_musculus_casteij/}). Additionally, since mitochondrial genes and certain immune genes (e.g., CD28) are absent from the \emph{Mus musculus castaneus} annotation used, and since high mitochondrial gene expression is a well-established signature of low-quality single-cell transcriptome profiles \citep{Ilicic2016}, we also mapped CAST reads against GRCm38 and used the B6 annotation solely for the mitochondrial genes. Gene expression counts were obtained using \emph{HTSeq} with default options \citep{Anders2014}. Only genes with orthologs in both species were considered for downstream analysis. \subsubsection{Quality control and filtering} We visually inspected the cell-capture sites in each C1 IFC using 40x magnification lensing to ensure precise capture of single cells \textbf{(Fig.~\ref{fig1:QC}A and B)}. Low-quality cells were computationally filtered using the following quality control criteria:\\ The percentage of reads mapping to annotated exonic regions was compared to the percentage of reads mapping to ERCC spike-ins. Cells with low genomic reads (< 20\%) and/or high ERCC reads (> 50\%) were excluded \textbf{(Fig.~\ref{fig1:QC}C)}. Additionally, cells with a low total number of mapped reads (< 1,000,000) were excluded. To exclude possible doublets and dying cells, capture sites with > 3000 or < 1250 detected genes were removed \textbf{(Fig.~\ref{fig1:QC}D and E)}. Next, cells with more than 10\% or less than 0.5\% of mitochondrial reads were excluded \textbf{(Fig.~\ref{fig1:QC}F)}. These quality filtered cells were tested for possible batch effects by computing a PCA on both replicates. We detect no batch effect since cells from the two individuals are overlapping (see \textbf{Fig.~\ref{fig1:QC}G} for an example of naive and activated CD4\plus{} T cells of young B6).\\ To control for biological contamination, known markers of lymphocytes were used to filter cells: CD19\plus{}/H2-Aa\plus{} B cells as well as CD8\plus{} T cells were removed \textbf{(Fig.~\ref{fig1:QC}H)}. Finally, we visualised naive and activated CD4\plus{} T cells using \gls{tSNE} and detect a strong grouping depending on the activation status. Here, non-activated T cells that were meant to be activated were removed from downstream analysis \textbf{(Fig.~\ref{fig1:QC}I)}. Read counts were normalised using the BASiCS package \citep{Vallejos2015} incorporating spike-in reads for technical noise estimation. Prior to normalisation, genes not expressed in at least 3 cells (rpm > 20) were filtered out. Similarly, ERCC spike-ins were removed if not detected in the data set. \newpage \begin{figure}[!hb] \centering \includegraphics[width=\textwidth,trim={0 3.5cm 0 0},clip]{Fig_3.png} \caption[Quality control of isolated CD4\plus{} T cells]{\textbf{Quality control of isolated CD4\plus{} T cells (Full legend on next page).}\\} \label{fig1:QC} \end{figure} \newpage \captionsetup[figure]{list=no} \addtocounter{figure}{-1} \captionof{figure}{\textbf{Quality control of isolated CD4\plus{} T cells (continued).}\\ \textbf{(A)} Visual inspection of captured cells at 40x magnification in IFCs (C1, Fluidigm) allows manual removal of empty capture sites, and capture sites holding multiple cells or debris, \textbf{(B)} Percentage of reads mapping to exonic regions displayed for naive and activated CD4\plus{} T cells. Black dots: single cells, yellow dots: 2 cells, red dots: empty wells, green dots: debris, multiple cells, etc., \textbf{(C)} Removal of cells with less than 20\% of mapped exonic reads and more than 50\% of ERCC spike-in reads (red dots), \textbf{(D)} Cells with less than 1 million mapped reads were excluded from downstream analysis (red dots), \textbf{(E)} Cells with more than 3000 or less than 1250 genes were excluded in the analysis (red dots), \textbf{(F)} Cells with more than 10\% or less than 0.5\% of mitochondrial reads were excluded from downstream analysis (red dots), \textbf{(G)} Naive and activated cells isolated from young B6 animals (replicates) were coloured batch-specifically. 4 batches from 2 mice: naive and activated from mouse 1 (red bars), naive and activated from mouse 2 (black bars). Naive condition is represented in horizontal bars and activated condition in vertical bars, \textbf{(H)} Data set was filtered for immune markers to exclude B cell and CD8\plus{} T cell contamination. Cells in columns were labelled based on their activation state (naive in beige, activated in green), their age (old in red, young in blue), and the species of the animals (B6 in black, CAST in yellow). Cells were ordered based on their \gls{H2-Aa} and \gls{Il2ra} expression, \textbf{(I)} tSNE visualisation allowed the removal of not fully activated cells (indicated in grey circles). Cells were labelled based on their activation state (naive: horizontal bar, activated: vertical bar) and the species of the animals (B6 in black, CAST in yellow). From \citep{Martinez-jimenez2017}. Reprinted with permission from AAAS.} \captionsetup[figure]{list=yes} \subsubsection{BASiCS parameter estimation using transcriptomes of CD4\plus{} T cells} \label{sec1:BASiCS} To quantify and assess changes in mean expression and expression variability, we used the Bayesian hierarchical framework BASiCS introduced in \textbf{Section \ref{sec0:BASiCS}} \citep{Vallejos2015BASiCS, Vallejos2016}. The MCMC simulation was run on quality filtered transcriptomes of CD4\plus{} T cells condition-specifically for 40,000 iterations using 20,000 burn-in iterations and a thinning factor of 20. We used posterior medians of $\mu_i$ to capture mean expression and posterior medians of the over-dispersion parameter $\delta_i$ to quantify biological expression variability. Differential mean expression testing was performed using a probabilistic decision rule of $\log_2(\mu_i^{(A)}/\mu_i^{(B)})>\tau_0$ being larger than a given probability threshold (e.g.~80\%). The probability threshold was chosen to keep the EFDR at 5\% \citep{Vallejos2016}. Here, A and B indicate the different conditions and $\tau_0$ is the chosen minimum tolerance threshold. The decision rule associated to differential variability testing is: $\log_2(\delta_i^{(A)}/\delta_i^{(B)})>\omega_0$. Due to the strong confounding between mean expression $\mu_i$ and over-dispersion $\delta_i$ (as described in \textbf{Section \ref{sec0:BASiCS}}), we only consider genes with no changes in mean expression ($\tau_0=0$, EFDR = 5\%) to assess changes in variability. Throughout this chapter, the decision rule is abbreviated with: \gls{log2FC}. \newpage \subsection{Characterisation of isolated CD4\plus{} T cells} \label{sec1:characterization} To avoid biases during quantification of transcriptional variability in homogeneous populations (see \textbf{Box 1} on page \pageref{box1}), careful inspection to remove possible substructures in the isolated cells is needed. Possible drivers for cell-to-cell expression variability include: cell cycle, clonality, cell size, differences in activation state/exhaustion and T cell priming in form of lineage commitment. We therefore assessed these features in the MACS-purified naive CD4\plus{} T cells in their unstimulated and activated state.\\ Firstly, we perfomed computational analysis to determine cell cycle stage, clonality and cell size. We estimated the cell cycle stage of each cell using \emph{cyclone} \citep{Scialdone2015} implemented in the \emph{scran} R package \citep{Lun2016}. In contrast to haematopoeitic cells \citep{Kowalczyk2015}, even when activated, all CD4\plus{} T cells are in G1 phase of cell cycle \textbf{(Fig.~\ref{fig1:characterization}A)}. We reconstructed the sequence of the T cell receptor for each cell \citep{Stubbington2015} and did not detect clonal expansion in CD4\plus{} T cells from aged animals \textbf{(Fig.~\ref{fig1:characterization}B)}. Similarly, we did not detect difference in cell size that could impact analysis of gene expression variability \textbf{(Fig.~\ref{fig1:characterization}C)}. \\ Secondly, using flow cytometry analysis, we assessed the purity and activation state (Il2r\textalpha{} and Cd69) of CD4\plus{} T cells, confirming that 96.4\% of the isolated CD4\plus{} T cells were naive in young B6 \textbf{(Fig.~\ref{fig1:characterization}D)}. Old animals had a small population of CD4\plus{} T cells with slightly elevated CD44 levels, reduced CD62L expression, indicative of memory T cells, and attenuated activation dynamics \textbf{(Fig. \ref{fig1:characterization}E-G)}. We did not detect differences in the proportion of lymphocytes (\gls{Il7r}) and natural killer cells (\gls{Klrg1}) between cells isolated from young and old animals. \\ Lastly, we determined if lineage commitment occurs in naive and activated CD4\plus{} T cells. In our data we do not detect any early differentiation in naive and activated CD4\plus{} T cell subsets. In accordance with the literature we found \textit{Gata3} but not Th2 cytokines expressed in the majority of cells \citep{Ho2009}. Interestingly, the Th1-related genes \textit{Tbx21} and \textit{Ifng} were up-regulated, in an uncoordinated manner, in a small population of activated CD4\plus{} T cells of old animals. This is consistent with a known Th1 bias in CD4\plus{} T cell responses in old mice \citep{Zhang2014} and humans \citep{Sakata-Kaneko2000} \textbf{(Fig.~\ref{fig1:characterization}H)}. \\ Furthermore, we did not detect any difference in TCR components/signalling and importantly, detected no signs of T cell exhaustion \citep{Wherry2011}, especially in cells isolated from old animals \textbf{(Fig.~\ref{fig1:characterization}I)}. We also ruled out species-specific differences in commitment towards T helper cell lineages \textbf{(Fig. \ref{fig1:characterization}J-K)}. \begin{figure}[!hb] \centering \includegraphics[width=0.8\textwidth]{Fig_4.png} \caption[Characterisation of isolated CD4\plus{} T cells]{\textbf{Characterisation of isolated CD4\plus{} T cells (Full legend on next page).}} \label{fig1:characterization} \end{figure} \newpage \captionsetup[figure]{list=no} \addtocounter{figure}{-1} \captionof{figure}{\textbf{Characterisation of isolated CD4\plus{} T cells (continued).}\\ \textbf{(A)} \emph{Cyclone} \citep{Scialdone2015} was used to classify individual naive and activated CD4\plus{} T cells into the cell cycle phases G1, G2/M and S, \textbf{(B)} \emph{TraCeR} \citep{Stubbington2015} constructed T cell receptor sequences from scRNA-Seq data to analyze clonal diversity in naive and activated CD4\plus{} T cells, \textbf{(C)} Cell sizes were estimated for naive and activated CD4\plus{} T cells in young and old B6 animals measured by FSC using flow cytometry, \textbf{(D)-(E)} CD4\plus{} T cells were purified from spleens of young (D) and old (E) B6 animals and stained with antibodies against CD4, CD62L, CD44, CD69, IL2R\textalpha{} (CD25), IL7R (CD127), and KLRG1 as well as viability dye. FACS plots shown are gated on single live cells (top left panel) and single live CD4\plus{} T cells (other panels), and percentages shown relate to total of gated cells, \textbf{(F)-(G)} Naive CD4\plus{} T cells were purified from spleens of five young (F) or two aged (G) B6 mice, and were either directly assayed or activated with plate-bound antibody against CD3\textepsilon{} and CD28 for 3 hours. Cells were stained with antibodies against CD4, CD69, and viability dye. Representative histograms for naive (red) and activated (blue) cells are shown, \textbf{(H)} Characterisation of possible differentiation processes leading to Th1, Th2, Th17, \gls{Treg} and Tfh cell lineages. For each lineage the major regulatory transcription factor (upper row) and an effector cytokine (lower row) is shown. Differential expression testing was performed between activated and naive cells from young B6 animals (left panel) and between activated and naive cells from old B6 animals (right panel). Upward arrow: up-regulation of expression (\gls{log2FC} in $\mu_i$ > 2, EFDR = 5\%) after activation, Downward arrow: down-regulation of expression (log2FC in $\mu_i$ > 2, EFDR = 5\%) after activation, \textbf{(I)} Heatmap showing T cell exhaustion (\textit{Pdcd1}, \textit{Lag3}, \textit{Havcr2}, \textit{Ctla4}) and TCR activation markers (\textit{Cd5}). Differential expression testing was performed in naive cells between young and old B6 animals (left panel) and in activated cells between young and old B6 animals (right panel). Upward arrow: up-regulation of expression (log2FC in $\mu_i$ > 2, EFDR = 5\%) during ageing, \textbf{(J)} Th1 lineage marker (\textit{Tbx21}, \textit{Ifng}) expression was compared between B6 and CAST in following conditions: naive cells from young animals (upper left panel), naive cells from old animals (lower left panel), activated cells from young animals (upper right panel), activated cells from old animals (lower right panel). \#: statistically significant differential expression (log2FC in $\mu_i$ > 2, EFDR = 5\%), \textbf{(K)} Th2 lineage marker (\textit{Gata3}, \textit{Il4}) expression was compared between B6 and CAST in the following conditions: naive cells from young animals (upper left panel), naive cells from old animals (lower left panel), activated cells from young animals (upper right panel), activated cells from old animals (lower right panel). From \citep{Martinez-jimenez2017}. Reprinted with permission from AAAS.\\} \captionsetup[figure]{list=yes} After the above analyses and the experimental characterisation, a total of 1514 high-quality CD4\plus{} T cell transcriptomes from young and old animals were analysed across all conditions (unstimulated and activated; naive, FACS-purified naive, FACS-purified EM) and species (B6 and CAST). An overview of all high-quality transcriptomes can be seen in \textbf{Fig.~\ref{fig1:all_cells}}. We detect that unstimulated and stimulated cells group together \textbf{(Fig.~\ref{fig1:all_cells}A)} while separation is also noticeable between species \textbf{(Fig.~\ref{fig1:all_cells}B)} and experimental methods \textbf{(Fig.~\ref{fig1:all_cells}C)}. As discussed below, cells from young and old animals do not separate when visualising the cells in form of a tSNE \textbf{(Fig. \ref{fig1:all_cells}C)}. \newpage \begin{figure}[!hb] \centering \includegraphics[width=\textwidth]{Fig_5.png} \caption[Visualisation of all isolated CD4\plus{} T cells]{\textbf{Visualisation of all isolated CD4\plus{} T cells.}\\ tSNE dimensionality reduction of 1514 CD4\plus{} T cells isolated from young and old mice of two related species. Cells were labelled based on \textbf{(A)} their activation state, \textbf{(B)} the mouse species, \textbf{(C)} experimental isolation approach and \textbf{(D)} age.} \label{fig1:all_cells} \end{figure} \newpage \section{Species-specific gene expression in naive CD4\plus{} T cells} To characterise the variation observed in \textbf{Fig.~\ref{fig1:all_cells}}, we first dissected differences in gene expression between the two mouse species using naive CD4\plus{} T cells. We also assessed whether possible differences that are detected between the two species are driven by the assembly quality of the genome reference. \subsection{Avoiding transcript counting biases due to incorrect alignment} We used BASiCS \citep{Vallejos2016} to detect differentially expressed genes as described in \textbf{Section \ref{sec1:computational}}. In scRNA-Seq, technical noise is highest for lowly expressed genes \citep{Brennecke2013} and we therefore excluded genes that had an average posterior mean expression < 50 in each population. Subsequently, we applied the differential expression test developed within BASiCS, using a threshold of log2FC in $\mu_i$ > 2 with the EFDR controlled to 5\%. We observed that 15\% of expressed genes were differentially transcribed between CD4\plus{} T cells of the two mouse species \textbf{(Fig. \ref{fig1:spec_spec_mapping}A)}. \begin{figure}[!hb] \centering \includegraphics[width=0.8\textwidth]{Fig_7.png} \caption[Cross-mapping correction between divergent mouse species]{\textbf{Cross-mapping correction between divergent mouse species.}\\ \textbf{(A)} Species-specific gene expression in B6 (blue) or CAST (red). Average gene expression using posterior estimation, threshold of means > 50, log2FC in $\mu_i$ > 2, EFDR = 5\%, \textbf{(B)} Mean, normalised transcript counts of mapped reads from CAST cells (young, naive) using the GRCm38 genome (x-axis) or the CAST genome (y-axis) as reference. Differentially mapped genes were removed from downstream analysis. Average gene expression using posterior estimation, threshold of means > 50, log2FC in $\mu_i$ > 2, EFDR = 5\%. } \label{fig1:spec_spec_mapping} \end{figure} To rule out the possibility that these differences are driven by potential artefacts in the new \textit{Mus musculus castaneus} genome assembly, we also mapped reads from young CAST samples to the GRCm38 genome. To estimate which differentially expressed genes may arise due to errors in the new CAST genome assembly, we performed the same differential expression analysis on CAST samples by mapping these libraries onto both GRCm38 and CAST. Roughly 5\% of all tested genes are detected as differentially expressed even though the samples being compared are identical and only mapped to different genomes \textbf{(Fig. \ref{fig1:spec_spec_mapping}B)}. Comparing this set of genes to the set of species-specific genes, we find that they make up 10\% of differentially expressed genes between the two species. We performed a similar analysis for B6 samples. This approach allowed us to remove genes which show differences in expression from our analyses. This may be driven by the quality of the reference genome. \subsection{Transcriptional dynamics of species-specific genes} \label{sec1:species-spec-dynamics} Similar for \textbf{Fig.~\ref{fig1:all_cells}}, we found that CD4\plus{} T cells cluster by species when only profiling naive cells \textbf{(Fig.~\ref{fig1:species_specific}A)}. As described above, theses differences are driven by the roughly 15\% of differentially expressed genes. To assess the functional role of the species-specific genes that are not due to biases in read alignment, we qualitatively and quantitatively compared their expression across individual cells in both species. Firstly, species-specific genes were only expressed in subsets of the full population of naive CD4\plus{} T cells \textbf{(Fig.~\ref{fig1:species_specific}B)}. Furthermore, we used DAVID \citep{Dennis2003} to test for \gls{GO} enrichment in differentially expressed gene sets. In line with genes being only sporadically expressed across the full population of cells, we did not detect functional enrichment in either B6 or CAST specific genes \textbf{(Fig.~\ref{fig1:species_specific}C)}. Profiling individual cells using scRNA-Seq allows us to detect different patterns of expression for species-specific genes. Within the set of species-specifically expressed genes, we detect some that display low variability and some with high variability \textbf{(Fig.~\ref{fig1:species_specific}D)}. More quantitatively, when profiling expression variability, we detect species-specifically transcribed genes to be generally more variable on a cell-to-cell basis than genes expressed in both species \textbf{(Fig. \ref{fig1:species_specific}E)}. These findings hint that the detected divergence in genes expression might be caused by neutral drift without functional support of the species-specific genes. We therefore argue that profiling transcriptional variability in a homogeneous population of cells is a measure for cell population function such as cell response to stimuli. \newpage \begin{figure}[!h] \centering \includegraphics[width=0.9\textwidth]{Fig_6.png} \caption[Species-specific gene expression in naive CD4\plus{} T cells]{\textbf{Species-specific gene expression in naive CD4\plus{} T cells.}\\ \textbf{(A)} tSNE dimensionality reduction of scRNA-Seq data reveals species-specific clustering of naive CD4\plus{} T cells from young animals, \textbf{(B)} Representative heatmap of 30 genes and 30 cells randomly selected from all species-specifically transcribed genes from young animals shows typical species-specific variations, \textbf{(C)} GO analysis of species-specific genes. Bonferroni corrected p-values (adjusted p-values) were used to visualise GO enrichment. The statistical significance threshold was set to adjusted p-value = 0.1 (red line), \textbf{(D)} Cell-to-cell variability in gene expression levels. Violin plots show distribution of single-cell expression of selected species-specifically transcribed genes (in grey background), ranked from lowest (top) to highest variability (bottom), \textbf{(E)} $\log_{10}$-transformed variability estimates of species-specific genes were compared to variability estimates of all genes expressed in B6 (left) and CAST (right). Mann-Whitney-Wilcoxon test; ***: p<10$^{-10}$}. \label{fig1:species_specific} \end{figure} \newpage \section{Expression dynamics during CD4\plus{} T cell activation} \label{sec1:activation} Functional CD4\plus{} T cell transcriptional responses start with an early, targeted activation of translational machinery and cytokine networks, followed by large-scale transcriptional changes associated with lineage commitment \citep{Shay2013, Asmal2003}. To characterise the immediate early activation programme, we stimulated naive CD4\plus{} T cells of B6 animals for three hours with plate-bound anti-CD3\textepsilon{}/anti-CD28 antibodies, thus inducing a strong and uniform activation mimicking initial contact with an antigen-presenting cell. Importantly, we did not use additional cytokines to commit the naive CD4\plus{} T cells to specific helper cell lineages \citep{Zhu2010}. This was confirmed empirically by the analysis presented in \textbf{Section \ref{sec1:characterization}}. \subsection{Mean expression changes during immune activation} By visualising the dimensionality reduced transcriptional profiles of naive and activated CD4\plus{} T cells, we qualitatively observe strong transcriptional changes during immune activation \textbf{(Fig.~\ref{fig1:immune_activation}A)}. Differential mean expression testing identifies thousands of genes as differentially expressed in CD4\plus{} T cells upon activation (2063 genes, log2FC in $\mu_i$ > 2, EFDR = 5\%) \textbf{(Fig.~\ref{fig1:immune_activation}B)}. We sought to investigate the behaviour of up- and down-regulated genes across the population of naive or activated cells. Initially, we calculated, for each gene, the percentage of cells in which it was expressed (> 0 transcript counts). Genes whose expression is down-regulated after activation are expressed in a median of 18\% naive CD4\plus{} T cells isolated from B6, while genes that are up-regulated are expressed in a median of 36\% activated cells. Before activation, up-regulated genes are only expressed in a median of 5\% naive cells while after activation, down-regulated genes are expressed in a median of 4\% activated cells \textbf{(Fig.~\ref{fig1:immune_activation}C)}. This analysis suggests that the immune response genes are similarly up-regulated across all cells, while genes that are down-regulated upon immune activation are more sporadically expressed in naive cells. \\ Furthermore, we performed GO analysis on genes either up- or down-regulated \textbf{(Fig.~\ref{fig1:immune_activation}D)}. Among the down-regulated genes are components of the intra-cellular signalling network while genes that are up-regulated are mostly part of the translation machinery \citep{Bjur2013}. Furthermore, the transcriptional switch driven by TCR engagement and co-stimulation included classic markers of activation, including (\textit{\gls{Il2ra}}, \textbf{Fig.~\ref{fig1:immune_activation}E}) and \gls{Ccl4} \citep{Asmal2003}. In contrast, we observed the coordinated suppression of \textit{Sell} (\textit{Cd62l}, \textbf{Fig.~\ref{fig1:immune_activation}F}), as expected after activation \citep{Park2005}. \newpage \begin{figure}[!ht] \centering \includegraphics[width=0.9\textwidth]{Fig_8.png} \caption[Mean expression dynamics upon CD4\plus{} T cell activation]{\textbf{Mean expression dynamics upon CD4\plus{} T cell activation.}\\ \textbf{(A)} Activation of CD4\plus{} T cells from young B6 mice induces large-scale transcriptional changes which is visualised using tSNE dimensionality reduction, \textbf{(B)} Genes up-regulated (red) and down-regulated (blue) by immune stimulation in young B6 mice. Non-differentially expressed genes shown in black. Average gene expression using posterior estimation, threshold of means > 50, log2FC in $\mu_i$ > 2, EFDR = 5\%, \textbf{(C)} Fractions of cells in which down- or up-regulated genes are expressed (600 genes were randomly selected, histograms with 50 bins, median value is indicated). Upper panels: fraction of naive (left) and activated (right) cells in which down-regulated genes are expressed. Lower panels: fraction of naive (left) and activated (right) cells in which up-regulated genes are expressed, \textbf{(D)} Bar plots of functional gene categories enriched in up- and down-regulated genes during activation of CD4\plus{} T cells in B6 (Bonferroni multiple testing corrected p-values, red line marking 0.1), \textbf{(E)} Example genes that represent transcriptional changes upon activation of CD4\plus{} T cells: \textit{Il2ra} (CD25) is highly and consistently up-regulated after stimulation, \textbf{(F)} \textit{Cd62l} (\textit{Sell}) is more stochastically expressed in naive CD4\plus{} T cells, and is down-regulated upon activation. } \label{fig1:immune_activation} \end{figure} \newpage \subsection{Changes of expression variability during immune activation} We next profiled changes in expression variability upon immune activation. Due to the strong confounding effect observed between mean expression and variability estimates, we only profiled genes that show no changes in mean expression between the naive and activated state (see \textbf{Section \ref{sec1:computational}}, indicated as black dots in \textbf{Fig. \ref{fig1:immune_variability}A}, log2FC in $\mu_i$ = 0, EFDR = 5\%). When comparing posterior medians of the over-dispersion parameter $\delta_i$ for genes that remain stable in mean expression, we observed a significant reduction in cell-to-cell transcriptional variability (Mann-Whitney-Wilcoxon test, p<10$^{-10}$) \textbf{(Fig.~\ref{fig1:immune_variability}B)}. For example, the \gls{Eif1}, show a marked decrease in cell-to-cell transcriptional variability, consistent with increased regulatory coordination \textbf{(Fig. \ref{fig1:immune_variability}C)}.\\ We next investigated whether genes that are more variably expressed in the naive than the activated condition showed coordinated patterns of expression, which are potentially associated with cryptic substructure. For this, we identified genes with statistically higher expression variability in the naive population compared to activated cells (log2FC in $\delta_i$ > 0.4, EFDR = 5\%, no change in mean expression). Genes with high variability and high pairwise correlation (Spearman’s $\rho$ > 0.8) in the naive population can be used to identify possible sub-populations of CD4\plus{} T cells. A hierarchical clustering analysis did not show any signs of such substructure \textbf{(Fig. \ref{fig1:immune_variability}D)}. This analysis therefore indicates that the collapse in variability is cause by a genuine shift from stochastic to regulated expression between two homogeneous populations of cells.\\ Finally, it has been observed that covariance between cells due to unobserved factors such as the cell cycle can mask potentially interesting biological signals \citep{Stegle2015, Buettner2015}. In our dataset, ribosomal biogenesis is the strongest mediator of CD4\plus{} T cell function upon activation which is strongly and homogeneously expressed across all cells \textbf{(Fig.~\ref{fig1:immune_activation}D and Fig.~\ref{fig1:immune_variability}C)}. We therefore regressed out this factor using the \gls{scLVM} \citep{Buettner2015}) to uncover underlying variance in activated CD4\plus{} T cells. Importantly, performing PCA on the uncorrected and corrected counts after regression did not reveal concealed cellular processes \textbf{(Fig.~\ref{fig1:immune_variability}E)}.\\ \newpage \begin{figure}[!ht] \centering \includegraphics[width=\textwidth]{Fig_9.png} \caption[Changes in transcriptional variability upon immune activation]{\textbf{Changes in transcriptional variability upon immune activation.}\\ \textbf{(A)} Genes up-regulated (red) and down-regulated (blue) by immune stimulation in young B6 mice (log2FC in $\mu_i$ > 2, EFDR = 5\%). Non-differentially expressed genes shown in black (log2FC in $\mu_i$ = 0, EFDR = 5\%). Average gene expression using posterior estimation, threshold of means > 50, \textbf{(B)} Genes with no overall gene expression differences during activation (black dots in (A)) show decreased cell-to-cell variability in transcription (Mann-Whitney-Wilcoxon test, ***: p<10$^{-10}$), \textbf{(C)} \textit{Eif1} is expressed in most cells in both conditions at similar levels, but shifts from stochastic to regulated expression, \textbf{(D)} To detect possible sub-populations in naive or activated CD4\plus{} T cells, differentially variable genes (log2FC in $\delta_i$ > 0.4, EFDR = 5\%) in naive cells with high gene-to-gene correlation (Spearman’s $\rho$ > 0.8) were used for hierarchical cluster analysis, \textbf{(E)} Upper panel: PCA of normalised counts of activated CD4\plus{} T cells from young B6 animals. Lower panel: PCA of activated CD4\plus{} T cells of young B6 animals after removing differences in the translation programme as a confounding factor.} \label{fig1:immune_variability} \end{figure} \newpage \subsection{Response-related transcriptional dynamics in CAST} As described above, activation of CD4\plus{} T cells drives a transcriptional switch that alters the global expression profile from a stochastic to a tightly regulated state. To test whether these transcriptional dynamics are evolutionarily conserved, we performed the same analysis for CD4\plus{} T cells extracted from CAST. Similar to cells isolated from young B6, we detect (i) clustering based on activation state \textbf{(Fig. \ref{fig1:immune_activation_CAST}A)}, (ii) thousands of genes being differentially expressed \textbf{(Fig. \ref{fig1:immune_activation_CAST}B)}, (iii) a decrease in expression variability after immune activation for genes that are stable in mean expression \textbf{(Fig. \ref{fig1:immune_activation_CAST}C)} and (iv) the expression of up-regulated genes in a higher number of activated cells than down-regulated genes in naive cells \textbf{(Fig. \ref{fig1:immune_activation_CAST}D)}. \begin{figure}[!ht] \centering \includegraphics[width=0.65\textwidth]{Fig_10.png} \caption[Immune activation dynamics in young CAST animals]{\textbf{Immune activation dynamics in young CAST animals.}\\ \textbf{(A)} Activation of CD4\plus{} T cells from young CAST mice in anti-CD3\textepsilon{}/CD28 coated plates induces large-scale transcriptional changes, visualised using tSNE dimensionality reduction, \textbf{(B)} Genes up-regulated (red) and down-regulated (blue) by immune stimulation in young CAST mice (log2FC in $\mu_i$ > 2, EFDR = 5\%). Non-differentially expressed genes used in (C) are shown in black (log2FC in $\mu_i$ = 2, EFDR = 5\%). Average gene expression using posterior estimation, threshold of means > 5, \textbf{(C)} Genes with no overall gene expression differences during activation show decreased cell-to-cell variability in transcription (Mann-Whitney-Wilcoxon test, ***: p<10$^{-10}$), \textbf{(D)} Up-regulated genes were expressed in a relatively large fraction of activated CD4\plus{} T cells after stimulation (median 25\%). Down-regulated genes were expressed in a smaller fraction of naive CD4\plus{} T cells (median 17\%). 600 genes of each condition were randomly selected. From \citep{Martinez-jimenez2017}. Reprinted with permission from AAAS.} \label{fig1:immune_activation_CAST} \end{figure} \newpage \section{Conservation of the core activation process} As shown above, we detect similar activation patterns when comparing CD4\plus{} T cell activation between B6 and CAST. To further study the conservation of this immune response, we used the rapid divergence in gene expression between CD4\plus{} T cells from both species to refine the functional set of immune response genes activated upon immune stimulation \citep{Shay2013}. Conserved functionality is assumed when genes are similarly up-regulated upon activation in both species. We hypothesise that such targets would be both conserved between species and expressed in most cells, whereas the genes activated species-specifically would be less likely to be functional targets and more likely to be sporadically expressed. \subsection{Detecting evolutionarily conserved response genes} As described for B6 above, we stimulated naive CD4\plus{} T cells isolated from young CAST males using anti-CD3\textepsilon{}/anti-CD28 antibodies followed by scRNA-Seq. As expected, cells clustered based on their activation state and species of origin \textbf{(Fig.~\ref{fig1:shared_activation}A)}. To find genes that form the evolutionarily conserved, core activation programme, we test for differential expression between the naive and activated state separately in B6 and CAST (log2FC in $\mu_i$ > 2, EFDR = 5\%). Genes that are up-regulated after activation similarly in B6 and CAST form the shared activation programme. Up-regulated genes that are differentially expressed in activated cells between the two species (log2FC in $\mu_i$ > 2, EFDR = 5\%) represent the species-specific response genes. \\ We next ensured that the species-specific differences in transcriptional response are not caused by mapping artefacts between the different genome builds. For this, we quantified gene expression in activated CAST and B6 samples based on the CAST and GRCm38 genome as described above. Genes in the activated state that show differential mapping between the two genomes were excluded from the species-specific lists of response genes. After removing those, we find 1208 genes to be up-regulated across both species. Out of these, we detect 225 genes that are (i) strongly up-regulated upon activation and (ii) up-regulated similarly in B6 and CAST. The latter means that these genes are not detected as differentially expressed in activated cells between the two species. Out of all 1208 response genes, 171 are detected as differentially expressed between the two species forming the set of species-specific response genes \textbf{(Fig. \ref{fig1:shared_activation}B)}. \newpage \begin{figure}[!ht] \centering \includegraphics[width=\textwidth]{Fig_11.png} \caption[Shared CD4\plus{} T cell activation programme]{\textbf{Shared CD4\plus{} T cell activation programme.}\\ \textbf{(A)} CD4\plus{} T cells isolated from B6 (black) and CAST (orange) show similar large-scale transcriptional changes upon immune stimulation, \textbf{(B)} Immune activation of CD4\plus{} T cells triggers up-regulation of both conserved (upper panel), and species-specific (lower panels) transcriptional programmes. For visualisation purposes, genes in shared and species-specific categories were proportionately and randomly selected. 30 cells were randomly selected for each condition/species, \textbf{(C)} Genes up-regulated in both B6 and CAST highly enrich for known T cell functionality. Genes up-regulated in only B6 or CAST have no statistically significant functional enrichment (Bonferroni multiple testing corrected p-values, red line is 0.1), \textbf{(D)} Fractions of cells in which a gene is detected are displayed as histograms. 70 genes were randomly selected from each gene set. While most genes in the shared activation process are expressed in a high percentage of cells, only few cells express species-specific genes of the activation process. From \citep{Martinez-jimenez2017}. Reprinted with permission from AAAS.} \label{fig1:shared_activation} \end{figure} \newpage \subsection{Functional assessment of the conserved response genes} We next estimated functionality of these 225 shared response genes by enrichment and variability analysis. Firstly, when performing GO analysis, the set of shared genes was strongly enriched for cellular processes known to be immediately activated by stimulation of CD4\plus{} T cells. This includes the core translational machinery (ribosome biogenesis and \glspl{rRNA}, \textbf{Fig.~\ref{fig1:shared_activation}C}) and key immune activation genes (such as \textit{Il2ra} and \textit{Tnfrsf9}, \citep{Asmal2003}). Other categories of immune response genes include cytokines, chemokines and their receptors (e.g.\textit{Ccr8}, \textit{Il2}, \textit{Ccl3}, \citep{Turner2014}), members of the \gls{Nr} superfamily (e.g. \textit{Nr4a2}, \textit{Nr4a3}, \textit{Nr4a1}, \citep{Glass2010}), components of NF$\kappa$B signalling (e.g. \textit{Nfkbid}, \textit{Nfkb1}, \textit{Nfkbie}, \textit{Rel}, \citep{Gerondakis2010}) and \gls{TNF} signalling (e.g. \textit{Tnf}, \textit{Tnfsf14}, \textit{Tnfrsf4}, \textit{Tnfrsf1b}, \citep{Croft2009}). In contrast, species-specific genes (96 for B6, 75 for CAST) showed no enrichment for biological function \textbf{(Fig. \ref{fig1:shared_activation}C)}. \\ As described in \textbf{Section \ref{sec1:species-spec-dynamics}}, the degree of heterogeneity to which genes are expressed within a homogeneous population of cells can indicate the functional relevance of these genes for population responses. We therefore calculated the fraction of cells that express shared and species-specific immune response genes (> 0 counts). Shared immune response genes were expressed across most CD4\plus{} T cells in both B6 and CAST after activation. In contrast, species-specific response genes tend to be expressed in a smaller fraction of cells \textbf{(Fig. \ref{fig1:shared_activation}D)}. \\ Our interspecies comparison thus revealed that target genes involved in translational control and immune function represent the conserved signature within the early activation response. These genes are furthermore similarly up-regulated in most cells across the homogeneous population of activated CD4\plus{} T cells. \newpage \section{Destabilisation of CD4\plus{} T cell activation during ageing} Ageing can cause perturbation of cell cycle entry for haematopoietic stem cells, leading to a shift in the functional balance between self-renewal and differentiation \citep{Kowalczyk2015}. We considered whether ageing might similarly perturb the transcriptional response of CD4\plus{} T cells to immune stimulation. For this, we performed differential expression and differential variability analysis between cells isolated from young and old animals. By comparing the activation responses between different sub-species of mice, we could also establish whether any observed impact of ageing is conserved. Lastly, we compare the effect of ageing across different subsets of CD4\plus{} T cells to assess how the effects of ageing differ across the immune system. \subsection{Ageing does not effect CD4\plus{} T cell transcription on a global level} \label{sec1:global_changes} We first asked whether the overall response of CD4\plus{} T cells is perturbed during ageing. For this we (i) performed PCA and (ii) compared mean expression of cells isolated from young and old mice. PCA revealed that the global expression profiles of naive or activated CD4\plus{} T cells not heavily effected by ageing \textbf{(Fig.~\ref{fig1:mean_expression_ageing}A and B)}. Furthermore, we identified differentially expressed genes between young and old animals separately for naive and activated CD4\plus{} T cells \textbf{(Fig.~\ref{fig1:mean_expression_ageing}C and D)}. This analysis was performed separately for each species. Only around 10\% of all tested genes showed changes in mean expression between young and old animals. Additionally, these genes typically showed low expression in naive or activated cells taken from both young and old animals. To further quantify this, we computed the fraction of cells in which each differentially expressed gene was expressed. The distribution of these values was added as inlets to the plots in \textbf{Fig.~\ref{fig1:mean_expression_ageing}C and D} (x-axis ranging from 0\% to 100\% of cells). We detected that differentially expressed genes are enriched for those that are only expressed in subsets of cells. This indicates that changes in mean expression during ageing only affect lowly expressed genes that are detected only in subsets of cells and therefore do not contain functionally relevant genes. These effects can also arise due to increased levels of noise for lowly expressed genes \citep{Brennecke2013}. \\ Nevertheless, to test whether these subtle effects during ageing are shared between the two species, we calculated the Jaccard index, which measures the overlap between sets of elements, separately for up- and down-regulated genes \textbf{(Fig.~\ref{fig1:mean_expression_ageing}E and F)}. We only detect $\sim$3\% of the differentially expressed genes as being shared between the two species either for up-regulated genes or down-regulated genes during ageing. Therefore, we did not find a conserved ageing signature that affects expression levels in CD4\plus{} T cells. \begin{figure}[!ht] \centering \includegraphics[width=0.9\textwidth]{Fig_12.png} \caption[Global immune response during ageing]{\textbf{Global immune response during ageing (full legend on next page).}} \label{fig1:mean_expression_ageing} \end{figure} \newpage \captionsetup[figure]{list=no} \addtocounter{figure}{-1} \captionof{figure}{\textbf{Global immune response during ageing (continued).}\\ PCA reveals no separation between cells isolated from young or old animals in the naive \textbf{(A)} or activated \textbf{(B)} state, \textbf{(C)} 7.1\% of all tested genes in B6 and 10.3\% of genes in CAST are differentially expressed in naive CD4\plus{} T cells between old (red) and young (blue) animals. Average gene expression using posterior estimation, threshold of means > 50, log2FC in $\mu_i$ > 2, EFDR = 5\%. Insets show distributions of fraction of cells in which these genes are expressed. X-axis: 0\% - 100\% of cells, \textbf{(D)} 10\% of all tested genes in B6 and 9\% of genes in CAST are differentially expressed in activated CD4\plus{} T cells between old (red) and young (blue) animals. Average gene expression using posterior estimation, threshold of means > 50, log2FC in $\mu_i$ > 2, EFDR = 5\%. Insets show distributions of fraction of cells in which these genes are expressed. X-axis: 0\% - 100\% of cells, \textbf{(E)-(F)} The overlap of ageing-associated genes in \textbf{(E)} naive or \textbf{(F)} activated cells was calculated using the Jaccard index between gene sets. Genes highly expressed in old animals (red) or genes highly expressed in young animals (blue) show little overlap (2-3\%) between B6 and CAST. From \citep{Martinez-jimenez2017}. Reprinted with permission from AAAS. \\} \captionsetup[figure]{list=yes} \subsection{Ageing increases transcriptional variability in response genes} To further dissect possible ageing effects on the core functionality of CD4\plus{} T cells, we next focused on the conserved activation programme. This analysis is more targeted and allows us to detect subtle changes caused by ageing. Qualitatively, and consistent with the findings in \textbf{Section \ref{sec1:global_changes}}, the majority of genes in the core activation programme responded upon stimulation, irrespective of age \textbf{(Fig.~\ref{fig1:variability_ageing}A)}. We then profiled changes in mean expression of activated cells between young and old animals for both species. This analysis resulted in a subtle decrease in expression for aged individuals while the majority of genes showed similar expression between young and old, as expected \textbf{(Fig.~\ref{fig1:variability_ageing}B)}. \\ We next profiled changes in variability by considering genes with no changes in mean expression in activated cells between between young and old animals (see \textbf{Section \ref{sec1:computational}}). By plotting the log2FC in $\delta_i$ for these genes, we observe an increase in cell-to-cell transcriptional variability of the core activation programme in older animals compared to young animals \textbf{(Fig. \ref{fig1:variability_ageing}C)}. To identify the drivers of the increase in transcriptional variability of the immune response during ageing, we calculated the fraction of activated cells in which genes of the shared activation programme are expressed. By comparing these fractions between activated cells isolated from old or young animals in both species, we identify consistently fewer cells from aged animals that express the shared activation programme \textbf{(Fig. \ref{fig1:variability_ageing}D)}. \\ \newpage \begin{figure}[!ht] \centering \includegraphics[width=\textwidth]{Fig_13.png} \caption[Ageing destabilises the CD4\plus{} T cell response]{\textbf{Ageing destabilises the CD4\plus{} T cell response.} \\ \textbf{(A)} Full heatmap showing all 225 genes of the shared activation programme expressed in all activated cells from young and old CAST and B6. Genes were ordered based on their mean expression, \textbf{(B)} Fold changes in mean expression indicate a consistent trend in lower expression of the shared activation programme in cells from old animals (genes were ordered by mean expression, log2FC of posterior mean estimates), \textbf{(C)} Cells from old animals show higher transcriptional variability compared to young animals (genes were ordered by mean expression, log2FC of posterior over-dispersion estimates), \textbf{(D)} The fraction of cells in which genes of the shared activation process are expressed is reduced in activated CD4\plus{} T cells from old animals. The distribution of fraction values is plotted on each corresponding axis (medians of fraction values are indicated in red); statistically significant changes in the percentage of cells expressing genes of the core activation process were assessed using a binomial test (blue points indicate bonferroni corrected p-values < 0.1). Gene expression in activated cells isolated from old animals was used as the Null-distribution.} \label{fig1:variability_ageing} \end{figure} \newpage These results indicate a destabilisation of the immune response programme during ageing. While most response genes are expressed at similar levels in activated cells of young and old animals, we detect a subset of cells where the expression of these genes is lost in aged mice. These dropouts in expression do not correlate across the population of cells and appear to be more stochastic. \subsection{Validation experiments to confirm changes in variability} We next asked whether the increase in variability is driven by (i) technical factors, (ii) biases in model parameter estimation or (iii) hidden sub-structure within the data. To address the first point, we generated independent replicates of naive and activated CD4\plus{} T cells from young and old B6 animals using Fluidigm C1 machines located at a different research institute. Profiling changes in variability using these biological replicates, we validated the increase in transcriptional variability during ageing \textbf{(Fig. \ref{fig1:validation}A)}.\\ Secondly, quantification of transcriptional variability can be biased based on the number of cells present in each cell population. When assaying homogeneous cell populations with larger sample size, model parameter estimation is more precise compared to populations with smaller sample size (see \textbf{Section \ref{sec2:stabilization}}). We therefore downsampled both young and old activated CD4\plus{} T cells to equal size and detected the same increase in variability during ageing \textbf{(Fig.~\ref{fig1:validation}B)} as previously when comparing the full set of CD4\plus{} T cells \textbf{(Fig.~\ref{fig1:variability_ageing}C)}. \\ Thirdly, in \textbf{Section \ref{sec1:characterization}} we observed that old animals have a small population of CD4\plus{} T cells with slightly elevated CD44 levels, reduced CD62L expression, and attenuated activation dynamics \textbf{(Fig.~\ref{fig1:characterization}E-G)}. We therefore tested whether the global shift in variability is caused by different cell population structures between old and young B6 animals. To that end, cells expressing marker genes that were inconsistent with their activation state as well as cells with a possible Th1 differentiation bias (\textit{Ifng} expressing) were removed. Based on the library size adjusted counts, we removed activated cells with low \textit{Cd69} (< 300 counts), high \textit{Sell} (> 10 counts), low \textit{Trac} (< 100 counts), low \textit{Il2ra} (< 100 counts) and \textit{Ifng} (> 0 counts) expression \textbf{(Fig. \ref{fig1:validation}C)}. The remaining 37 and 26 activated cells in young and old B6 animals showed the same shift in transcriptional variability compared to the non-filtered data \textbf{(Fig. \ref{fig1:validation}D)}. \newpage \begin{figure}[!ht] \centering \includegraphics[width=\textwidth]{Fig_14.png} \caption[Experimental validation of increased transcriptional variability during ageing]{\textbf{Experimental validation of increased transcriptional variability during ageing.} \\ \textbf{(A)} A biological replicate of 115 activated CD4\plus{} T cells from old B6 animals was generated and changes in gene expression variability were compared to activated CD4\plus{} T cells from young B6 animals, \textbf{(B)} 30 out of all activated CD4\plus{} T cells from young or old B6 mice were randomly selected and changes in gene expression variability were compared between the downsampled populations of cells, \textbf{(C)} Expression of CD4\plus{} T cell activation markers in all activated cells from young and old B6 before (left) and after (right) filtering based on \textit{Ifng}, \textit{Sell}, \textit{Trac}, \textit{Il2ra} and \textit{Cd69} expression, \textbf{(D)} Changes in gene expression variability of activated cells between young and old animals are displayed before (left) and after (right) filtering (see (C)).} \label{fig1:validation} \end{figure} \newpage \subsection{Transcriptional variability in CD4\plus{} T cell subsets} It is well known that T cell type composition changes are driven by thymic involution which leads to a reduction of the thymic output in CD4\plus{} T cells over age. After infections, previously activated CD4\plus{} T cells survive and form central memory T cells \cite{Moro-Garcia2013}.\\ We first address if the decrease in thymic output over age induces a reduction of \glspl{RTE} in the spleen and therefore biases expression variability to be higher in aged animals. Maturation of RTEs contributes significantly to the maintenance of the naive CD4\plus{} T cell pool in the periphery and is affected by ageing \citep{Boursalian2004, Hale2006, Fink2013}. To estimate proportions of RTEs within the naive CD4\plus{} T cell pool, we characterised CD4 single positive (SP) thymocytes and splenic naive CD4\plus{} T cells by flow cytometry. RTEs can be identified by their CD24$^{\text{hi}}$ Qa2$^{\text{lo}}$ phenotype \citep{Boursalian2004, Hale2006}. We find the majority of CD4 SP thymocytes showed a CD24$^\text{hi}$ Qa2$^\text{lo}$ phenotype \textbf{(Fig.~\ref{fig1:EM_Naive_CD4}A)}. In contrast, we detected only a very small population of RTEs (~2\%) within splenic naive CD4\plus{} T cell pool similarly in young and old mice \textbf{(Fig.~\ref{fig1:EM_Naive_CD4}A and B)} \citep{Hale2006}. This suggests minimal contamination of RTEs in naive CD4\plus{} T cells purified by MACS and therefore no bias when testing for changes in variability.\\ Next, we examine whether the age-mediated increase in cell-to-cell variability is conserved across different subsets of CD4\plus{} T cells. We therefore sorted naive and EM CD4\plus{} T cells as explained in \textbf{Fig.~\ref{fig1:FACS}}. We detect the decline in naive CD4\plus{} T cells and an enrichment of EM CD4\plus{} T cells in old animals. Furthermore, and as expected, we identify a significantly higher proportion of EM CD4\plus{} T cells in old animals that express the activation markers CD69 and PD-1, indicating that a larger fraction of cells is already in an activated state \textbf{(Fig. \ref{fig1:EM_Naive_CD4}C)}. To avoid this phenomenon, which might interfere with the quantification of transcriptional variability, cells stained positive for CD69 and/or PD-1 were excluded during the sort of EM CD4\plus{} T cells by FACS. After sorting, we compared transcriptional variability of the core set of immune response genes in activated cells between old and young animals. Critically, these genes showed an increase in variability in older animals in both FACS-purified naive and EM CD4\plus{} T cell subsets similar to MACS-purified cells \textbf{(Fig.~\ref{fig1:EM_Naive_CD4}D and E)}.\\ To conclude, ageing reduces the fraction of cells in which immune activation genes are up-regulated, thus increasing cell-to-cell heterogeneity and attenuating the response to stimulation across multiple CD4\plus{} T cell subsets. \newpage \begin{figure}[!ht] \centering \includegraphics[width=\textwidth]{Fig_15.png} \caption[Increased expression variability during ageing in different CD4\plus{} T cell subsets]{\textbf{Increased expression variability during ageing in different CD4\plus{} T cell subsets.} \\ \textbf{(A)} Thymus and spleen were collected from young and old B6 mice, dissociated into single cell suspensions, stained with viability dye and antibodies against CD4, CD8, CD24 and Qa2 for thymocytes or antibodies against CD4, CD44, CD62L, CD24 and Qa2 for splenocytes. FACS plots shown are gated on single, live cells and either CD4\plus{} CD8\textsuperscript{-} CD4 \gls{SP} thymocytes (thymus) or CD44$^\text{lo}$ CD62L$^\text{hi}$ naive CD4\plus{} T cells (spleen). Percentages relate to total gated cells. In the thymus the majority of CD4 SP express markers of recent thymic emigrants (RTEs, CD24$^\text{hi}$ Qa2$^\text{lo}$) while in the spleen naive CD4\plus{} T cells are comprised mainly of mature naive cells (red box), \textbf{(B)} Quantification of flow cytometry data from (A). Significance of difference was calculated by Mann-Whitney test (ns = not significant). MNT = mature naive T cell, \textbf{(C)} Spleens were collected from young and old B6 mice, dissociated into single cell suspensions, stained with viability dye and antibodies against CD4, CD44, CD62L, CD24, Qa2, CD69, and PD-1. FACS plots were gated on single, live, CD4\plus{} T cells and subsequently on either CD44$^\text{lo}$ CD62L$^\text{hi}$ (Naive) or CD44$^\text{hi}$ CD62L$^\text{lo}$ (EM) subsets. Expression of CD69 and PD-1 was analysed in these subsets. Results shown are pooled from 10 independent experiments with spleens harvested from 5 young and 5 old mice. Significance of difference was calculated by two-way ANOVA ($^{\ast{}\ast{}\ast{}\ast}$p $\leq$ 0.0001), \textbf{(D)} Activated, FACS-purified naive CD4\plus{} T cells from old animals showed higher transcriptional variability compared to young animals, \textbf{(E)} Activated, FACS-purified EM CD4\plus{} T cells from old animals showed higher transcriptional variability compared to young animals.} \label{fig1:EM_Naive_CD4} \end{figure}
import quantum_lemmas open Matrix ------------------------------------------------------------------------------ -- Single qubit random number generator circuit meta def solve_rng := `[ intros, unfold quantum.measure, unfold_qubits, simp, try { unfold H }, grind_dot_product; `[try {solve1 {simp <|> dec_trivial}}], repeat {destruct_fin; `[try {simp}; try {solve1 {ring}}]}] -- Simply apply `H` gate to `|0⟩`. The result state has the same probability -- measured in any standard basis. example : ∀ i, ⟦H ⬝ |0⟩⟧ i = 1/2 := by solve_rng -- Same result when `|1⟩` is used as the input state. example : ∀ i, ⟦H ⬝ |1⟩⟧ i = 1/2 := by solve_rng ------------------------------------------------------------------------------ -- Proof automation lemmas -- These ground facts were needed to simplify `H2 ⬝ |00⟩` evaluations. @[simp] lemma fin_one_succ_succ_div_2 : (⟨(1 : ℕ).succ.succ / 2, by dec_trivial⟩ : fin 2) = ⟨1, by dec_trivial⟩ := by norm_num @[simp] lemma fin_one_succ_succ_mod_2 : (⟨(1 : ℕ).succ.succ % 2, by dec_trivial⟩ : fin 2) = ⟨1, by dec_trivial⟩ := by norm_num ------------------------------------------------------------------------------ -- 2 qubit random number generator circuit -- 2-qubit H circut noncomputable def H2 : Square 4 := H ⊗ H meta def solve_rng2 := `[ intros, unfold quantum.measure, unfold_qubits, simp, try { unfold H2 }, try { unfold H }, try { unfold kron kron_div kron_mod }, grind_dot_product; `[try {solve1 {simp <|> dec_trivial}}], repeat {destruct_fin; `[try {simp}; try {solve1 {ring}}]}] -- H2 is a 2-qubit random number generator. The input qubits can be either 0/1 individually. example : ∀ (i : fin 4), ⟦H2 ⬝ |00⟩⟧ i = 1/4 := by solve_rng2 example : ∀ (i : fin 4), ⟦H2 ⬝ |01⟩⟧ i = 1/4 := by solve_rng2 example : ∀ (i : fin 4), ⟦H2 ⬝ |10⟩⟧ i = 1/4 := by solve_rng2 example : ∀ (i : fin 4), ⟦H2 ⬝ |11⟩⟧ i = 1/4 := by solve_rng2
module Test.Suite import IdrTest.Test import Test.FmtTest suite : IO () suite = do runSuites [ Test.FmtTest.suite ]
# 3. faza: Izdelava zemljevida # Uvozimo funkcijo za pobiranje in uvoz zemljevida. source("lib/uvozi.zemljevid.r") # Uvozimo zemljevid. cat("Uvažam zemljevid...\n") svet <- uvozi.zemljevid("http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_map_units.zip", "svet", "ne_110m_admin_0_map_units.shp", mapa = "zemljevid", encoding = "Windows-1252") svet1 <- svet[svet$continent %in% c("Europe", "Africa", "South America", "North America", "Asia", "Oceania"),] #podatki za zemljevid kraj <- table(filmi$KRAJ) stevilo <- unique(kraj) stevilo <- stevilo[order(stevilo)] barve <- rainbow(length(stevilo))[match(kraj, stevilo)] names(barve) <- names(kraj) barve.zemljevid <- barve[as.character(svet1$name_long)] barve.zemljevid[is.na(barve.zemljevid)] <- "white" imena <- names(kraj) aa <- svet1[svet1$name_long %in% imena,] koordinate <- coordinates(aa) imena.krajev <- as.character(aa$name_long) rownames(koordinate) <- imena.krajev koordinate["Canada",2] <- koordinate["Canada",2]+5 koordinate["Canada",1] <- koordinate["Canada",1]-4 koordinate["United States",2] <- koordinate["United States",2]+4.5 koordinate["Guatemala",2] <- koordinate["Guatemala",2]+5 koordinate["Guatemala",1] <- koordinate["Guatemala",1]-7 koordinate["England",2] <- koordinate["England",2]+10.5 koordinate["England",1] <- koordinate["England",1]-1 koordinate["France",2] <- koordinate["France",2]+7.5 koordinate["France",1] <- koordinate["France",1]-2.5 koordinate["Spain",2] <- koordinate["Spain",2]+7 koordinate["Morocco",2] <- koordinate["Morocco",2]+8.5 koordinate["Germany",2] <- koordinate["Germany",2]+7 koordinate["Germany",1] <- koordinate["Germany",1]-7 koordinate["Czech Republic",2] <- koordinate["Czech Republic",2]+8 koordinate["Czech Republic",1] <- koordinate["Czech Republic",1]+16 koordinate["Poland",2] <- koordinate["Poland",2]+9.5 koordinate["Poland",1] <- koordinate["Poland",1]+4.5 koordinate["Austria",2] <- koordinate["Austria",2]+6.5 koordinate["Austria",1] <- koordinate["Austria",1]+7 koordinate["Italy",2] <- koordinate["Italy",2]+6 koordinate["India",2] <- koordinate["India",2]+5 koordinate["Philippines",2] <- koordinate["Philippines",2]+5 koordinate["Sri Lanka",2] <- koordinate["Sri Lanka",2]+5 koordinate["Sri Lanka",1] <- koordinate["Sri Lanka",1]+2 koordinate["New Zealand",2] <- koordinate["New Zealand",2]+7.5 #zemljevid shrani v pdf datoteko cairo_pdf("slike/zemljevid.pdf", family="Arial") plot(svet1, col=barve.zemljevid, bg="lightyellow", border="orange", main="ZEMLJEVID ZA 100 NAJBOLJŠIH FILMOV VSEH ČASOV") text(koordinate, labels=imena.krajev, pos=1, cex=0.4) legend("bottomright", title="ŠTEVILO POSNETIH FILMOV V POSAMEZNI DRŽAVI:", bg="white", text.font=10, legend=stevilo, fill=rainbow(length(stevilo))) dev.off()
lemma complex_cnj_power [simp]: "cnj (x ^ n) = cnj x ^ n"
postulate F G : (Set → Set) → Set !_ : Set → Set infix 2 F infix 1 !_ syntax F (λ X → Y) = X , Y syntax G (λ X → Y) = Y , X -- This parsed when default fixity was 'unrelated', but with -- an actual default fixity (of any strength) in place it really -- should not. Foo : Set Foo = ! X , X
(* * Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) * * SPDX-License-Identifier: BSD-2-Clause *) theory Guess_ExI imports Eisbach_Tools.Eisbach_Methods Eisbach_Tools.Apply_Debug begin (* This file contains the experimental methods guess_exI and guess_spec. Each, as the name suggests, attempts to guess an instantiation for their respective rules. It does so by looking for a matching premise for the quantifying binder, checking that this could be the only match for safety. *) method abs_used for P = (match (P) in "\<lambda>s. ?P" \<Rightarrow> \<open>fail\<close> \<bar> _ \<Rightarrow> \<open>-\<close>) method in_conj for P Q = ( match (Q) in "P" \<Rightarrow> \<open>-\<close> | match (Q) in "\<lambda>y. A y \<and> B y" for A B \<Rightarrow> \<open> match (A) in "(Q' :: 'b)" for Q' \<Rightarrow> \<open>match (B) in "(Q'' :: 'b)" for Q'' \<Rightarrow> \<open> in_conj P Q' | in_conj P Q''\<close>\<close>\<close> ) method guess_exI = (require_determ \<open>(match conclusion in "\<exists>x. Q x" for Q \<Rightarrow> \<open>match premises in "P y" for P y \<Rightarrow> \<open>abs_used P, in_conj P Q, rule exI[where x=y]\<close>\<close>)\<close>) lemma fun_uncurry: "(P \<longrightarrow> Q \<longrightarrow> R) \<longleftrightarrow> (P \<and> Q) \<longrightarrow> R" by auto method guess_spec_inner for P uses I = ((match I in "\<forall>x. C x \<longrightarrow> _ x" for C \<Rightarrow> \<open>in_conj P C\<close> )) method guess_spec = (require_determ \<open>(match premises in I:"\<forall>x. _ x \<longrightarrow> _ x" \<Rightarrow> \<open>match premises in "P y" for P y \<Rightarrow> \<open>abs_used P, guess_spec_inner P I:I[simplified fun_uncurry], insert I, drule spec[where x=y]\<close>\<close>)\<close>) text \<open>Tests and examples\<close> experiment begin lemma assumes Q: "Q x" shows "P x \<Longrightarrow> \<forall>x. Q x \<longrightarrow> P x \<longrightarrow> R \<Longrightarrow> R" by (guess_spec, blast intro: Q) (* Conflicting premises are checked *) lemma assumes Q: "Q x" shows "\<lbrakk> P x; P y \<rbrakk> \<Longrightarrow> \<forall>x. Q x \<longrightarrow> P x \<longrightarrow> R \<Longrightarrow> R" apply (fails \<open>guess_spec\<close>) by (blast intro: Q) (* Conflicts between different conjuncts are checked *) lemma assumes Q: "Q x" shows "\<lbrakk> P x; Q y \<rbrakk> \<Longrightarrow> \<forall>x. Q x \<longrightarrow> P x \<longrightarrow> R \<Longrightarrow> R" apply (fails \<open>guess_spec\<close>) by (blast intro: Q) end text \<open>Tests and examples\<close> experiment begin lemma "P x \<Longrightarrow> \<exists>x. P x" by guess_exI lemma assumes Q: "Q x" shows "P x \<Longrightarrow> \<exists>x. Q x \<and> P x" apply guess_exI by (blast intro: Q) (* Conflicting premises are checked *) lemma assumes Q: "Q x" shows "\<lbrakk> P x; P y \<rbrakk> \<Longrightarrow> \<exists>x. Q x \<and> P x" apply (fails \<open>guess_exI\<close>) by (blast intro: Q) (* Conflicts between different conjuncts are checked *) lemma assumes Q: "Q x" shows "\<lbrakk> P x; Q y \<rbrakk> \<Longrightarrow> \<exists>x. Q x \<and> P x" apply (fails \<open>guess_exI\<close>) by (blast intro: Q) end end
lemma exp_pi_i' [simp]: "exp (\<i> * of_real pi) = -1"
theory Inconsistency_S5U imports QML_S5U begin consts P :: "(\<mu>\<Rightarrow>\<sigma>)\<Rightarrow>\<sigma>" (*P: Positive*) axiomatization where A1a: "\<lfloor>\<^bold>\<forall>\<Phi>. P(\<^sup>\<not>\<Phi>) \<^bold>\<rightarrow> \<^bold>\<not>P(\<Phi>)\<rfloor>" and A1b: "\<lfloor>\<^bold>\<forall>\<Phi>. \<^bold>\<not>P(\<Phi>) \<^bold>\<rightarrow> P(\<^sup>\<not>\<Phi>)\<rfloor>" and A2: "\<lfloor>\<^bold>\<forall>\<Phi> \<Psi>. P(\<Phi>) \<^bold>\<and> \<^bold>\<box>(\<^bold>\<forall>x. \<Phi>(x) \<^bold>\<rightarrow> \<Psi>(x)) \<^bold>\<rightarrow> P(\<Psi>)\<rfloor>" definition G where "G(x) = (\<^bold>\<forall>\<Phi>. P(\<Phi>) \<^bold>\<rightarrow> \<Phi>(x))" axiomatization where A3: "\<lfloor>P(G)\<rfloor>" and A4: "\<lfloor>\<^bold>\<forall>\<Phi>. P(\<Phi>) \<^bold>\<rightarrow> \<^bold>\<box>(P(\<Phi>))\<rfloor>" definition ess (infixl "ess" 85) where "\<Phi> ess x = (\<^bold>\<forall>\<Psi>. \<Psi>(x) \<^bold>\<rightarrow> \<^bold>\<box>(\<^bold>\<forall>y. \<Phi>(y) \<^bold>\<rightarrow> \<Psi>(y)))" definition NE where "NE(x) = (\<^bold>\<forall>\<Phi>. \<Phi> ess x \<^bold>\<rightarrow> \<^bold>\<box>(\<^bold>\<exists> \<Phi>))" axiomatization where A5: "\<lfloor>P(NE)\<rfloor>" lemma False (* Inconsistency *) (* sledgehammer [remote_leo2, verbose] *) sledgehammer by (metis (full_types) A1a A2 A3 A4 A5 G_def NE_def ess_def) end
State Before: ι : Type u' ι' : Type ?u.197690 R : Type u_2 K : Type ?u.197696 M : Type u_1 M' : Type ?u.197702 M'' : Type ?u.197705 V : Type u V' : Type ?u.197710 v : ι → M inst✝⁶ : Semiring R inst✝⁵ : AddCommMonoid M inst✝⁴ : AddCommMonoid M' inst✝³ : AddCommMonoid M'' inst✝² : Module R M inst✝¹ : Module R M' inst✝ : Module R M'' a b : R x y : M s : Set M ⊢ (LinearIndependent R fun x => ↑x) ↔ ∀ (l : M →₀ R), l ∈ Finsupp.supported R R s → ↑(Finsupp.total M M R id) l = 0 → l = 0 State After: no goals Tactic: apply @linearIndependent_comp_subtype _ _ _ id
module module_11 implicit none integer :: i = 1 integer :: j = 2 contains subroutine access_internally() print*, "i = ", i end subroutine access_internally end module module_11 program access_externally use module_11 implicit none print*, "j = ", j call access_internally() end program access_externally
This website is provided and operated by The British Red Cross Society, incorporated by Royal Charter 1908; registered as a charity in England and Wales (220949), Scotland (SC037738) and the Isle of Man (0752) whose national headquarters is at 44 Moorfields, London, EC2Y 9AL ; and Britcross Ltd, registered as a company in England and Wales (00932598) (collectively ‘British Red Cross’) having its registered address at 44 Moorfields, London, EC2Y 9AL. VAT number is 706 9262 27. These terms and conditions (the 'Terms') explain how you may use this website (www.redcross.org.uk, the 'Site') which is provided to you free of charge. This Site and all intellectual property rights in it, including but not limited to any text, images, video, audio or other multimedia content, or other information or material on the Site ('Content'), are owned by us, our licensors or both (as applicable). Intellectual property rights means rights such as copyright, trade marks, domain names, design rights, patents and other intellectual property rights of any kind whether or not they are registered or unregistered (anywhere in the world). The Red Cross and Red Crescent emblems are protected trade marks under international and national laws. Use of these trade marks is strictly prohibited without prior authorisation from us or the relevant trade mark owner. Images from Reuters Alertnet courtesy of AlertNet - humanitarian aid and disasters news. Other than as set out at section c. above, use of these images is strictly prohibited without prior authorisation from the copyright owner. We reserve the right to vary any event registration fees and the prices of any goods or services listed without notice. All event registrations and orders for goods and services are subject to availability. We reserve the right to refuse to accept any registration and to refuse to supply any goods or services to any individual. The Site is provided "as is". We do not promise that the Site will be fit or suitable for any purpose. The Site and the Content are provided for your general information purposes only and to inform you about us and our activities, news, services and other websites that may be of interest. The Content does not constitute technical, financial or legal advice or any other type of advice and neither the Site nor the Content should be relied upon for any purposes. Although the Site uses encryption security software in areas where online payment details are accepted, the security of information and payments transmitted via the internet cannot be guaranteed. You and we both agree that the courts of England and Wales will have exclusive jurisdiction except that if you are a resident of Northern Ireland you may also bring proceedings in Northern Ireland, and if you are resident of Scotland, you may also bring proceedings in Scotland.
Formal statement is: lemma minus_zero_does_nothing: "minus_poly_rev_list x (map ((*) 0) y) = x" for x :: "'a::ring list" Informal statement is: Subtracting a list of zeros from a list does nothing.
[STATEMENT] lemma Borsukian_continuous_logarithm: fixes S :: "'a::real_normed_vector set" shows "Borsukian S \<longleftrightarrow> (\<forall>f. continuous_on S f \<and> f ` S \<subseteq> (- {0::complex}) \<longrightarrow> (\<exists>g. continuous_on S g \<and> (\<forall>x \<in> S. f x = exp(g x))))" [PROOF STATE] proof (prove) goal (1 subgoal): 1. Borsukian S = (\<forall>f. continuous_on S f \<and> f ` S \<subseteq> - {0} \<longrightarrow> (\<exists>g. continuous_on S g \<and> (\<forall>x\<in>S. f x = exp (g x)))) [PROOF STEP] by (simp add: Borsukian_def inessential_eq_continuous_logarithm)
(* Copyright 2014 Cornell University This file is part of VPrl (the Verified Nuprl project). VPrl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. VPrl is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with VPrl. Ifnot, see <http://www.gnu.org/licenses/>. Website: http://nuprl.org/html/verification/ Authors: Abhishek Anand & Vincent Rahli *) Require Export csubst. Require Export cvterm2. Lemma subst_preserves_isprog_vars {o} : forall vs (t : @NTerm o) v u, isprog_vars (vs ++ [v]) t -> isprog u -> isprog_vars vs (subst t v u). Proof. introv ispt ispu. allrw @isprog_vars_eq; repnd. pose proof (isprogram_lsubst1 t [(v,u)]) as h. simpl in h; repeat (autodimp h hyp). { introv k; repndors; cpx; apply isprogram_eq; auto. } repnd. unfold subst. rw h; clear h. dands; auto. apply subvars_remove_nvars; auto. Qed. Hint Resolve subst_preserves_isprog_vars : isprog. Definition substcv {o} vs (u : @CTerm o) (v : NVar) (t : CVTerm (vs ++ [v])) : CVTerm vs := let (a,x) := t in let (b,y) := u in exist (isprog_vars vs) (subst a v b) (subst_preserves_isprog_vars vs a v b x y). Lemma substc_mkcv_function {o} : forall v (t : @CTerm o) (a : CVTerm [v]) x (b : CVTerm [x,v]), v <> x -> substc t v (mkcv_function [v] a x b) = mkc_function (substc t v a) x (substcv [x] t v b). Proof. introv ni. apply cterm_eq; simpl. destruct_cterms; simpl. applydup @closed_if_isprog in i; unfold closed in i2. unfold subst, lsubst; simpl; allrw app_nil_r; rw i2; simpl; boolvar; allsimpl; try (complete (provefalse; tcsp)); tcsp; boolvar; allsimpl; tcsp; allrw not_over_or; repnd; tcsp; boolvar; allsimpl; tcsp. Qed. Lemma combine_map_r : forall (A B : tuniv) (f : A -> B) (l : list A), combine (map f l) l = map (fun a : A => (f a, a)) l. Proof. induction l; simpl; auto. f_equal; auto. Qed. Lemma disjoint_swapbvars_if_remove_nvars : forall vs vs1 vs2 l, disjoint l (remove_nvars vs1 vs) -> disjoint vs2 vs -> disjoint vs2 vs1 -> disjoint vs2 l -> length vs1 = length vs2 -> no_repeats vs2 -> disjoint l (swapbvars (mk_swapping vs1 vs2) vs). Proof. induction vs; introv d1 d2 d3 d4 len norep; allsimpl; auto. allrw disjoint_cons_r; repnd. allrw remove_nvars_cons_r; boolvar; allrw disjoint_cons_r; repnd; dands; tcsp. - intro k. pose proof (swapvar_implies3 vs1 vs2 a) as h. repeat (autodimp h hyp); eauto with slow. apply d4 in h; sp. - rw swapvar_not_in; auto. Qed. Lemma allvars_swap {o} : forall (t : @NTerm o) vs1 vs2, no_repeats vs2 -> disjoint vs1 vs2 -> allvars (swap (mk_swapping vs1 vs2) t) = swapbvars (mk_swapping vs1 vs2) (allvars t). Proof. nterm_ind t as [v|f ind|op bs ind] Case; introv norep disj; allsimpl; auto. Case "oterm". rw flat_map_map; unfold compose. rw @swapbvars_flat_map. apply eq_flat_maps; introv i. destruct x as [l t]; simpl. allrw swapbvars_app; f_equal. erewrite ind; eauto. Qed. Lemma allvars_cswap {o} : forall (t : @NTerm o) vs1 vs2, no_repeats vs2 -> disjoint vs1 vs2 -> allvars (cswap (mk_swapping vs1 vs2) t) = swapbvars (mk_swapping vs1 vs2) (allvars t). Proof. nterm_ind t as [v|f ind|op bs ind] Case; introv norep disj; allsimpl; auto. Case "oterm". rw flat_map_map; unfold compose. rw @swapbvars_flat_map. apply eq_flat_maps; introv i. destruct x as [l t]; simpl. allrw swapbvars_app; f_equal. erewrite ind; eauto. Qed. Lemma alphaeq_cswap_cl {o} : forall (t : @NTerm o) vs1 vs2, disjoint vs1 (free_vars t) -> disjoint vs1 vs2 -> disjoint vs2 (allvars t) -> length vs1 = length vs2 -> no_repeats vs2 -> alphaeq (cswap (mk_swapping vs1 vs2) t) t. Proof. nterm_ind1s t as [v|f ind|op bs ind] Case; introv d1 d2 d3 len norep; allsimpl; eauto 3 with slow. - Case "vterm". allrw disjoint_singleton_r. rw swapvar_not_in; eauto with slow. - Case "oterm". apply alphaeq_eq. apply alpha_eq_oterm_combine; allrw map_length; dands; auto. introv i. destruct b1 as [l1 t1]. destruct b2 as [l2 t2]. apply alphaeqbt_eq. rw combine_map_r in i. rw in_map_iff in i; exrepnd. destruct a as [l t]; allsimpl; ginv. disj_flat_map; allsimpl; allrw disjoint_app_r; repnd. pose proof (fresh_vars (length l) (l ++ vs1 ++ vs2 ++ swapbvars (mk_swapping vs1 vs2) l ++ allvars (cswap (mk_swapping vs1 vs2) t) ++ allvars t ++ free_vars t ) ) as h; exrepnd. allrw disjoint_app_r; repnd. apply (aeqbt _ lvn); allsimpl; auto. { rw length_swapbvars; auto. } { allrw disjoint_app_r; dands; auto. } { rw @cswap_cswap. rw mk_swapping_app; auto. rw <- @cswap_app_cswap; eauto with slow. rw <- mk_swapping_app; auto. rw <- @cswap_cswap. apply (ind t _ l); auto. - rw @osize_cswap; eauto 3 with slow. - rw @free_vars_cswap; eauto 3 with slow. apply disjoint_swapbvars_if_remove_nvars; auto. - rw @allvars_cswap; eauto 3 with slow. apply disjoint_swapbvars_if_remove_nvars; auto. eapply subvars_disjoint_r;[|exact i0]. apply subvars_remove_nvars. apply subvars_app_weak_l; auto. } Qed. Definition range_sw (sw : swapping) : list NVar := map (fun x => snd x) sw. Definition dom_sw (sw : swapping) : list NVar := map (fun x => fst x) sw. Lemma length_range_sw : forall (sw : swapping), length (range_sw sw) = length sw. Proof. introv. unfold range_sw. rw map_length; auto. Qed. Lemma length_dom_sw : forall (sw : swapping), length (dom_sw sw) = length sw. Proof. introv. unfold dom_sw. rw map_length; auto. Qed. Lemma swapping_eta : forall sw, mk_swapping (dom_sw sw) (range_sw sw) = sw. Proof. induction sw; simpl; auto. destruct a; simpl; f_equal; tcsp. Qed. Lemma alphaeq_add_cswap2 {o} : forall (sw : swapping) (t1 t2 : @NTerm o), no_repeats (range_sw sw) -> disjoint (range_sw sw) (dom_sw sw ++ allvars t1 ++ allvars t2) -> alphaeq t1 t2 -> alphaeq (cswap sw t1) (cswap sw t2). Proof. introv norep disj aeq. pose proof (alphaeq_add_cswap [] (dom_sw sw) (range_sw sw) t1 t2) as h. repeat (autodimp h hyp); allrw disjoint_app_r; repnd; dands; tcsp. - allrw length_dom_sw; allrw length_range_sw; auto. - apply alphaeq_implies_alphaeq_vs; auto. - rw @alphaeq_exists. allrw swapping_eta. eexists; eauto. Qed. Lemma alphaeq_cswap_cl2 {o} : forall (t : @NTerm o) sw, disjoint (dom_sw sw) (free_vars t) -> disjoint (dom_sw sw) (range_sw sw) -> disjoint (range_sw sw) (allvars t) -> no_repeats (range_sw sw) -> alphaeq (cswap sw t) t. Proof. introv d1 d2 d3 norep. pose proof (alphaeq_cswap_cl t (dom_sw sw) (range_sw sw)) as h. rw swapping_eta in h. rw length_dom_sw in h. rw length_range_sw in h. repeat (autodimp h hyp). Qed. Lemma substc_mkcv_fun {o} : forall v (t : @CTerm o) (a b : CVTerm [v]), alphaeqc (substc t v (mkcv_fun [v] a b)) (mkc_fun (substc t v a) (substc t v b)). Proof. introv. destruct_cterms. unfold alphaeqc; simpl. applydup @closed_if_isprog in i; unfold closed in i2. unfold subst, lsubst; simpl; allrw app_nil_r; rw i2; simpl; boolvar; allsimpl; try (complete (provefalse; tcsp)); tcsp; boolvar; allsimpl; tcsp; allrw not_over_or; repnd; tcsp; boolvar; allsimpl; tcsp; allrw @lsubst_aux_nil; repndors; tcsp; subst; GC. - apply alphaeq_eq; constructor; simpl; auto. introv k; destruct n;[|destruct n]; cpx; unfold selectbt; simpl. + apply alphaeqbt_eq; auto. + rw @lsubst_aux_trivial_cl_term; simpl; [apply alphaeqbt_eq; auto|]. apply disjoint_singleton_r; intro j. apply newvar_prop in j; sp. - apply alphaeq_eq; constructor; simpl; auto. introv k; destruct n;[|destruct n]; cpx; unfold selectbt; simpl. + apply alphaeqbt_eq; auto. + rw @lsubst_aux_trivial_cl_term; simpl; [apply alphaeqbt_eq; auto|]. apply disjoint_singleton_r; intro j. apply newvar_prop in j; sp. - apply alphaeq_eq; constructor; simpl; auto. introv k; destruct n;[|destruct n]; cpx; unfold selectbt; simpl. + apply alphaeqbt_eq; auto. + rw @lsubst_aux_trivial_cl_term; simpl; [apply alphaeqbt_eq; auto|]. apply disjoint_singleton_r; intro j. pose proof (fresh_var_not_in (all_vars (change_bvars_alpha [] x0))) as h. destruct h. rw in_app_iff; left; rw @free_vars_change_bvars_alpha; auto. - apply alphaeq_eq; constructor; simpl; auto. introv k; destruct n;[|destruct n]; cpx; unfold selectbt; simpl. + apply alphaeqbt_eq; auto. + pose proof (ex_fresh_var ([newvar x0,newvar (lsubst_aux x0 [(v, x)])] ++ allvars (lsubst_aux x0 [(v, x)]))) as h; exrepnd. allsimpl; allrw not_over_or; repnd; GC. apply (aeqbt _ [v0]); simpl; auto. * apply disjoint_singleton_l; simpl; allrw in_app_iff; allrw not_over_or; dands; tcsp. * apply (alphaeq_trans _ (lsubst_aux x0 [(v,x)])). { apply alphaeq_cswap_cl2; simpl; tcsp; apply disjoint_singleton_l; simpl; tcsp. rw @free_vars_lsubst_aux_cl; simpl. - rw in_remove_nvars; simpl; rw not_over_or; intro j; repnd. apply newvar_prop in j0; sp. - apply cl_sub_cons; dands; eauto with slow. } { apply alphaeq_sym. apply alphaeq_cswap_cl2; simpl; tcsp; apply disjoint_singleton_l; simpl; tcsp. rw @free_vars_lsubst_aux_cl; simpl. - rw in_remove_nvars; simpl; rw not_over_or; intro j; repnd. rw @isprog_vars_eq in i0; repnd. rw subvars_prop in i3. apply i3 in j0; allsimpl; sp. - apply cl_sub_cons; dands; eauto with slow. } Qed. Lemma substc_mkcv_isect {o} : forall v (t : @CTerm o) (a : CVTerm [v]) x (b : CVTerm [x,v]), v <> x -> substc t v (mkcv_isect [v] a x b) = mkc_isect (substc t v a) x (substcv [x] t v b). Proof. introv ni. apply cterm_eq; simpl. destruct_cterms; simpl. applydup @closed_if_isprog in i; unfold closed in i2. unfold subst, lsubst; simpl; allrw app_nil_r; rw i2; simpl; boolvar; allsimpl; try (complete (provefalse; tcsp)); tcsp; boolvar; allsimpl; tcsp; allrw not_over_or; repnd; tcsp; boolvar; allsimpl; tcsp. Qed. Lemma substc_mkcv_ufun {o} : forall v (t : @CTerm o) (a b : CVTerm [v]), alphaeqc (substc t v (mkcv_ufun [v] a b)) (mkc_ufun (substc t v a) (substc t v b)). Proof. introv. destruct_cterms. unfold alphaeqc; simpl. applydup @closed_if_isprog in i; unfold closed in i2. unfold subst, lsubst; simpl; allrw app_nil_r; rw i2; simpl; boolvar; allsimpl; try (complete (provefalse; tcsp)); tcsp; boolvar; allsimpl; tcsp; allrw not_over_or; repnd; tcsp; boolvar; allsimpl; tcsp; allrw @lsubst_aux_nil; repndors; tcsp; subst; GC. - apply alphaeq_eq; constructor; simpl; auto. introv k; destruct n;[|destruct n]; cpx; unfold selectbt; simpl. + apply alphaeqbt_eq; auto. + rw @lsubst_aux_trivial_cl_term; simpl; [apply alphaeqbt_eq; auto|]. apply disjoint_singleton_r; intro j. apply newvar_prop in j; sp. - apply alphaeq_eq; constructor; simpl; auto. introv k; destruct n;[|destruct n]; cpx; unfold selectbt; simpl. + apply alphaeqbt_eq; auto. + rw @lsubst_aux_trivial_cl_term; simpl; [apply alphaeqbt_eq; auto|]. apply disjoint_singleton_r; intro j. apply newvar_prop in j; sp. - apply alphaeq_eq; constructor; simpl; auto. introv k; destruct n;[|destruct n]; cpx; unfold selectbt; simpl. + apply alphaeqbt_eq; auto. + rw @lsubst_aux_trivial_cl_term; simpl; [apply alphaeqbt_eq; auto|]. apply disjoint_singleton_r; intro j. pose proof (fresh_var_not_in (all_vars (change_bvars_alpha [] x0))) as h. destruct h. rw in_app_iff; left; rw @free_vars_change_bvars_alpha; auto. - apply alphaeq_eq; constructor; simpl; auto. introv k; destruct n;[|destruct n]; cpx; unfold selectbt; simpl. + apply alphaeqbt_eq; auto. + pose proof (ex_fresh_var ([newvar x0,newvar (lsubst_aux x0 [(v, x)])] ++ allvars (lsubst_aux x0 [(v, x)]))) as h; exrepnd. allsimpl; allrw not_over_or; repnd; GC. apply (aeqbt _ [v0]); simpl; auto. * apply disjoint_singleton_l; simpl; allrw in_app_iff; allrw not_over_or; dands; tcsp. * apply (alphaeq_trans _ (lsubst_aux x0 [(v,x)])). { apply alphaeq_cswap_cl2; simpl; tcsp; apply disjoint_singleton_l; simpl; tcsp. rw @free_vars_lsubst_aux_cl; simpl. - rw in_remove_nvars; simpl; rw not_over_or; intro j; repnd. apply newvar_prop in j0; sp. - apply cl_sub_cons; dands; eauto with slow. } { apply alphaeq_sym. apply alphaeq_cswap_cl2; simpl; tcsp; apply disjoint_singleton_l; simpl; tcsp. rw @free_vars_lsubst_aux_cl; simpl. - rw in_remove_nvars; simpl; rw not_over_or; intro j; repnd. rw @isprog_vars_eq in i0; repnd. rw subvars_prop in i3. apply i3 in j0; allsimpl; sp. - apply cl_sub_cons; dands; eauto with slow. } Qed. Lemma lsubstc_mkc_tnat {o} : forall (w : @wf_term o mk_tnat) s c, lsubstc mk_tnat w s c = mkc_tnat. Proof. introv. apply cterm_eq; simpl. apply csubst_trivial; simpl; auto. Qed. Lemma lsubstc_mk_less {o} : forall (a b c d : @NTerm o) sub, forall wa : wf_term a, forall wb : wf_term b, forall wc : wf_term c, forall wd : wf_term d, forall w : wf_term (mk_less a b c d), forall ca : cover_vars a sub, forall cb : cover_vars b sub, forall cc : cover_vars c sub, forall cd : cover_vars d sub, forall cv : cover_vars (mk_less a b c d) sub, lsubstc (mk_less a b c d) w sub cv = mkc_less (lsubstc a wa sub ca) (lsubstc b wb sub cb) (lsubstc c wc sub cc) (lsubstc d wd sub cd). Proof. introv. apply cterm_eq; simpl. unfold csubst; simpl. change_to_lsubst_aux4; simpl. rw @sub_filter_nil_r; sp. Qed. Lemma lsubstc_mk_less_ex {o} : forall (a b c d : @NTerm o) sub, forall wf : wf_term (mk_less a b c d), forall cv : cover_vars (mk_less a b c d) sub, {wa : wf_term a & {wb : wf_term b & {wc : wf_term c & {wd : wf_term d & {ca : cover_vars a sub & {cb : cover_vars b sub & {cc : cover_vars c sub & {cd : cover_vars d sub & lsubstc (mk_less a b c d) wf sub cv = mkc_less (lsubstc a wa sub ca) (lsubstc b wb sub cb) (lsubstc c wc sub cc) (lsubstc d wd sub cd)}}}}}}}}. Proof. sp. assert (wf_term a) as wa. { allrw <- @wf_less_iff; sp. } assert (wf_term b) as wb. { allrw <- @wf_less_iff; sp. } assert (wf_term c) as wc. { allrw <- @wf_less_iff; sp. } assert (wf_term d) as wd. { allrw <- @wf_less_iff; sp. } exists wa wb wc wd. assert (cover_vars a sub) as ca. { unfold cover_vars in cv. simpl in cv. repeat (rw remove_nvars_nil_l in cv). rw app_nil_r in cv. repeat (rw @over_vars_app_l in cv); sp. } assert (cover_vars b sub) as cb. { unfold cover_vars in cv. simpl in cv. repeat (rw remove_nvars_nil_l in cv). rw app_nil_r in cv. repeat (rw @over_vars_app_l in cv); sp. } assert (cover_vars c sub) as cc. { unfold cover_vars in cv. simpl in cv. repeat (rw remove_nvars_nil_l in cv). rw app_nil_r in cv. repeat (rw @over_vars_app_l in cv); sp. } assert (cover_vars d sub) as cd. { unfold cover_vars in cv. simpl in cv. repeat (rw remove_nvars_nil_l in cv). rw app_nil_r in cv. repeat (rw @over_vars_app_l in cv); sp. } exists ca cb cc cd. apply lsubstc_mk_less. Qed. Lemma csubst_mk_true {o} : forall sub, csubst mk_true sub = @mk_true o. Proof. intro; unfold csubst; simpl; fold @mk_axiom. change_to_lsubst_aux4; simpl; sp. Qed. Lemma lsubstc_mk_true {o} : forall p sub c, lsubstc mk_true p sub c = @mkc_true o. Proof. unfold lsubstc, mkc_true; sp. apply cterm_eq; simpl. apply csubst_mk_true; auto. Qed. Lemma lsubstc_mk_less_than_ex {o} : forall (a b : @NTerm o) sub, forall wf : wf_term (mk_less_than a b), forall cv : cover_vars (mk_less_than a b) sub, {wa : wf_term a & {wb : wf_term b & {ca : cover_vars a sub & {cb : cover_vars b sub & lsubstc (mk_less_than a b) wf sub cv = mkc_less_than (lsubstc a wa sub ca) (lsubstc b wb sub cb)}}}}. Proof. introv. dup wf as w; apply wf_less_iff in w; repnd. dup cv as c. rw @cover_vars_eq in c; simpl in c. allrw remove_nvars_nil_l; allrw app_nil_r. rw subvars_app_l in c; repnd. allrw <- @cover_vars_eq. assert (cover_vars mk_true sub) as ct. { rw @cover_vars_eq; simpl; sp. } assert (cover_vars mk_false sub) as cf. { rw @cover_vars_eq; simpl; sp. } pose proof (lsubstc_mk_less a b mk_true mk_false sub w0 w1 w2 w wf c0 c ct cf cv) as h. exists w0 w1 c0 c. unfold mk_less_than. rw h. rw @mkc_less_than_eq. rw @lsubstc_mk_false. rw @lsubstc_mk_true; auto. Qed. Lemma lsubstc_mk_le_ex {o} : forall (a b : @NTerm o) sub, forall wf : wf_term (mk_le a b), forall cv : cover_vars (mk_le a b) sub, {wa : wf_term a & {wb : wf_term b & {ca : cover_vars a sub & {cb : cover_vars b sub & lsubstc (mk_le a b) wf sub cv = mkc_le (lsubstc a wa sub ca) (lsubstc b wb sub cb)}}}}. Proof. introv. dup wf as w. unfold mk_le in w; rw @wf_not in w. dup w as w'. apply @wf_less_iff in w'; repnd. dup cv as c. rw @cover_vars_eq in c; simpl in c. allrw remove_nvars_nil_l; allrw app_nil_r. rw subvars_app_l in c; repnd. allrw <- @cover_vars_eq. assert (cover_vars (mk_less_than b a) sub) as c'. { rw @cover_vars_eq; simpl; allrw remove_nvars_nil_l; allrw app_nil_r. rw subvars_app_l; sp. } exists w'1 w'0 c c0. pose proof (lsubstc_mk_less_than_ex b a sub w c') as h; exrepnd; clear_irr. allunfold @mk_le. pose proof (lsubstc_mk_not_ex (mk_less_than b a) sub wf cv) as k; exrepnd; clear_irr. rw k1; rw h1. rw @mkc_le_eq; auto. Qed. Lemma csubst_mk_tnat {o} : forall sub, csubst mk_tnat sub = @mk_tnat o. Proof. intro; unfold csubst; simpl; fold @mk_axiom. change_to_lsubst_aux4; simpl; sp. allrw @sub_filter_nil_r. repeat (rw @sub_find_sub_filter; simpl; tcsp). Qed. Lemma lsubstc_mk_tnat {o} : forall p sub c, lsubstc mk_tnat p sub c = @mkc_tnat o. Proof. unfold lsubstc, mkc_tnat; sp. apply cterm_eq; simpl. apply csubst_mk_tnat; auto. Qed. Lemma lsubstc_mk_minus {o} : forall (t : @NTerm o) sub, forall w : wf_term t, forall w' : wf_term (mk_minus t), forall c : cover_vars t sub, forall c' : cover_vars (mk_minus t) sub, lsubstc (mk_minus t) w' sub c' = mkc_minus (lsubstc t w sub c). Proof. sp; unfold lsubstc; simpl. apply cterm_eq; simpl. unfold csubst; simpl. change_to_lsubst_aux4; simpl. rw @sub_filter_nil_r; sp. Qed. Lemma lsubstc_mk_minus_ex {o} : forall (t : @NTerm o) sub, forall w : wf_term (mk_minus t), forall c : cover_vars (mk_minus t) sub, {w1 : wf_term t & {c1 : cover_vars t sub & lsubstc (mk_minus t) w sub c = mkc_minus (lsubstc t w1 sub c1)}}. Proof. sp. assert (wf_term t) as w1. { allrw <- @wf_minus_iff; sp. } assert (cover_vars t sub) as c1. { unfold cover_vars in c. simpl in c. repeat (rw remove_nvars_nil_l in c). rw app_nil_r in c. repeat (rw @over_vars_app_l in c); sp. } exists w1 c1. apply lsubstc_mk_minus. Qed. Tactic Notation "one_lift_lsubst2" constr(T) ident(name) tactic(tac) := match T with | context [lsubstc (mk_less ?a1 ?a2 ?a3 ?a4) ?w ?s ?c] => let w1 := fresh "w1" in let w2 := fresh "w2" in let w3 := fresh "w3" in let w4 := fresh "w4" in let c1 := fresh "c1" in let c2 := fresh "c2" in let c3 := fresh "c3" in let c4 := fresh "c4" in pose proof (lsubstc_mk_less_ex a1 a2 a3 a4 s w c) as name; destruct name as [w1 name]; destruct name as [w2 name]; destruct name as [w3 name]; destruct name as [w4 name]; destruct name as [c1 name]; destruct name as [c2 name]; destruct name as [c3 name]; destruct name as [c4 name]; clear_irr; tac | context [lsubstc (mk_less_than ?a ?b) ?w ?s ?c] => let w1 := fresh "w1" in let w2 := fresh "w2" in let c1 := fresh "c1" in let c2 := fresh "c2" in pose proof (lsubstc_mk_less_than_ex a b s w c) as name; destruct name as [w1 name]; destruct name as [w2 name]; destruct name as [c1 name]; destruct name as [c2 name]; clear_irr; tac | context [lsubstc (mk_le ?a ?b) ?w ?s ?c] => let w1 := fresh "w1" in let w2 := fresh "w2" in let c1 := fresh "c1" in let c2 := fresh "c2" in pose proof (lsubstc_mk_le_ex a b s w c) as name; destruct name as [w1 name]; destruct name as [w2 name]; destruct name as [c1 name]; destruct name as [c2 name]; clear_irr; tac | context [lsubstc (mk_minus ?a) ?w ?s ?c] => let w1 := fresh "w1" in let c1 := fresh "c1" in pose proof (lsubstc_mk_minus_ex a s w c) as name; destruct name as [w1 name]; destruct name as [c1 name]; clear_irr; tac | context [lsubstc mk_tnat ?w ?s ?c] => pose proof (lsubstc_mk_tnat w s c) as name; clear_irr; tac | context [lsubstc mk_true ?w ?s ?c] => pose proof (lsubstc_mk_true w s c) as name; clear_irr; tac | context [lsubstc mk_int ?w ?s ?c] => pose proof (lsubstc_mk_int w s c) as name; clear_irr; tac end. Lemma subst_mk_lam {o} : forall v b x u, @isprog o u -> v <> x -> subst (mk_lam v b) x u = mk_lam v (subst b x u). Proof. introv isp d. unfold subst. change_to_lsubst_aux4; allsimpl; allrw app_nil_r; allrw disjoint_cons_l; sp. boolvar; sp. allrw @isprog_eq; allunfold @isprogram; repnd. allrw isp0; sp. allrw @isprog_eq; allunfold @isprogram; repnd. allrw isp0; sp. Qed. Lemma subst_mk_equality {o} : forall a b T x u, @isprog o u -> subst (mk_equality a b T) x u = mk_equality (subst a x u) (subst b x u) (subst T x u). Proof. introv isp. unfold subst. change_to_lsubst_aux4; allsimpl; allrw app_nil_r; allrw disjoint_app_l; sp; allrw @isprog_eq; allunfold @isprogram; repnd; allrw isp0; sp. Qed. Lemma subst_mk_tequality {o} : forall a b x u, @isprog o u -> subst (mk_tequality a b) x u = mk_tequality (subst a x u) (subst b x u). Proof. introv isp. unfold subst. change_to_lsubst_aux4; allsimpl; allrw app_nil_r; allrw disjoint_app_l; sp; allrw @isprog_eq; allunfold @isprogram; repnd; allrw isp0; sp. Qed. Lemma subst_mk_var1 {o} : forall x u, subst (@mk_var o x) x u = u. Proof. introv. unfold subst. change_to_lsubst_aux4; allsimpl; sp. boolvar; sp. Qed. Lemma subst_mk_var2 {o} : forall v x u, v <> x -> subst (mk_var v) x u = @mk_var o v. Proof. introv. unfold subst. change_to_lsubst_aux4; allsimpl; sp. boolvar; sp. Qed. Lemma subst_trivial {o} : forall t v u, @isprog o u -> isprog t -> subst t v u = t. Proof. sp; apply lsubst_trivial2; allsimpl; sp; cpx; allrw @isprogram_eq; sp. Qed. Lemma subst_mk_function {o} : forall a v b x u, @isprog o u -> v <> x -> subst (mk_function a v b) x u = mk_function (subst a x u) v (subst b x u). Proof. introv isp d. unfold subst. change_to_lsubst_aux4; allsimpl; allrw app_nil_r; allrw disjoint_cons_l; sp. boolvar; sp. allrw @isprog_eq; allunfold @isprogram; repnd. allrw isp0; sp. allrw @isprog_eq; allunfold @isprogram; repnd. allrw isp0; sp. allrw @isprog_eq; allunfold @isprogram; repnd. allrw isp0; sp. Qed. Lemma subst_mk_function2 {o} : forall a v b u, @isprog o u -> subst (mk_function a v b) v u = mk_function (subst a v u) v b. Proof. introv isp. unfold subst. change_to_lsubst_aux4; allsimpl; allrw app_nil_r; allrw disjoint_cons_l; sp. boolvar; sp; try (rw @lsubst_aux_nil); sp; allrw not_over_or; sp. allrw @isprog_eq; allunfold @isprogram; repnd. allrw isp0; sp. allrw @isprog_eq; allunfold @isprogram; repnd. allrw isp0; sp. Qed. Lemma subst_mk_isect {o} : forall a v b x u, @isprog o u -> v <> x -> subst (mk_isect a v b) x u = mk_isect (subst a x u) v (subst b x u). Proof. introv isp d. unfold subst. change_to_lsubst_aux4; allsimpl; allrw app_nil_r; allrw disjoint_cons_l; sp. boolvar; sp. allrw @isprog_eq; allunfold @isprogram; repnd. allrw isp0; sp. allrw @isprog_eq; allunfold @isprogram; repnd. allrw isp0; sp. allrw @isprog_eq; allunfold @isprogram; repnd. allrw isp0; sp. Qed. Lemma subst_mk_isect2 {o} : forall a v b u, @isprog o u -> subst (mk_isect a v b) v u = mk_isect (subst a v u) v b. Proof. introv isp. unfold subst. change_to_lsubst_aux4; allsimpl; allrw app_nil_r; allrw disjoint_cons_l; sp. boolvar; sp; try (rw @lsubst_aux_nil); sp; allrw not_over_or; sp. allrw @isprog_eq; allunfold @isprogram; repnd. allrw isp0; sp. allrw @isprog_eq; allunfold @isprogram; repnd. allrw isp0; sp. Qed. (* *** Local Variables: *** coq-load-path: ("." "./close/") *** End: *)
import pickle import subprocess from sys import argv import numpy as np from pyspark.sql import SparkSession if __name__ == "__main__": """ Run this locally (not with --deploy-mode cluster). This will create a pickle file. To run: spark-submit StackOverflow/analysis/parquet_to_pickle.py INPUT_DIR 2> /dev/null To copy data to local machine: scp [email protected]:output.pickle ./analysis/local/data Replace INPUT_DIR with the input path where the input .parquet files can be found """ print("Converting .parquet to .pickle") spark = SparkSession.builder.getOrCreate() cmd = 'hdfs dfs -ls ' + argv[1] files = subprocess.check_output(cmd, shell=True).strip().split('\n') files.pop(0) for file_listing in files: file_name = file_listing.split('/')[-1] parquet_file = spark.read.parquet(argv[1] + file_name) all_data = np.array(parquet_file.collect()) pickle_data = { "column_names": parquet_file.columns, "data_points": all_data } pickle.dump(pickle_data, open(file_name[:-8] + ".pickle", "wb"))
/- Copyright (c) 2022 Riccardo Brasca. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Riccardo Brasca ! This file was ported from Lean 3 source module number_theory.cyclotomic.rat ! leanprover-community/mathlib commit 2032a878972d5672e7c27c957e7a6e297b044973 ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathbin.NumberTheory.Cyclotomic.Discriminant import Mathbin.RingTheory.Polynomial.Eisenstein.IsIntegral /-! # Ring of integers of `p ^ n`-th cyclotomic fields We gather results about cyclotomic extensions of `ℚ`. In particular, we compute the ring of integers of a `p ^ n`-th cyclotomic extension of `ℚ`. ## Main results * `is_cyclotomic_extension.rat.is_integral_closure_adjoin_singleton_of_prime_pow`: if `K` is a `p ^ k`-th cyclotomic extension of `ℚ`, then `(adjoin ℤ {ζ})` is the integral closure of `ℤ` in `K`. * `is_cyclotomic_extension.rat.cyclotomic_ring_is_integral_closure_of_prime_pow`: the integral closure of `ℤ` inside `cyclotomic_field (p ^ k) ℚ` is `cyclotomic_ring (p ^ k) ℤ ℚ`. -/ universe u open Algebra IsCyclotomicExtension Polynomial NumberField open Cyclotomic NumberField Nat variable {p : ℕ+} {k : ℕ} {K : Type u} [Field K] [CharZero K] {ζ : K} [hp : Fact (p : ℕ).Prime] include hp namespace IsCyclotomicExtension.Rat /-- The discriminant of the power basis given by `ζ - 1`. -/ theorem discr_prime_pow_ne_two' [IsCyclotomicExtension {p ^ (k + 1)} ℚ K] (hζ : IsPrimitiveRoot ζ ↑(p ^ (k + 1))) (hk : p ^ (k + 1) ≠ 2) : discr ℚ (hζ.subOnePowerBasis ℚ).basis = (-1) ^ ((p ^ (k + 1) : ℕ).totient / 2) * p ^ ((p : ℕ) ^ k * ((p - 1) * (k + 1) - 1)) := by rw [← discr_prime_pow_ne_two hζ (cyclotomic.irreducible_rat (p ^ (k + 1)).Pos) hk] exact hζ.discr_zeta_eq_discr_zeta_sub_one.symm #align is_cyclotomic_extension.rat.discr_prime_pow_ne_two' IsCyclotomicExtension.Rat.discr_prime_pow_ne_two' theorem discr_odd_prime' [IsCyclotomicExtension {p} ℚ K] (hζ : IsPrimitiveRoot ζ p) (hodd : p ≠ 2) : discr ℚ (hζ.subOnePowerBasis ℚ).basis = (-1) ^ (((p : ℕ) - 1) / 2) * p ^ ((p : ℕ) - 2) := by rw [← discr_odd_prime hζ (cyclotomic.irreducible_rat hp.out.pos) hodd] exact hζ.discr_zeta_eq_discr_zeta_sub_one.symm #align is_cyclotomic_extension.rat.discr_odd_prime' IsCyclotomicExtension.Rat.discr_odd_prime' /-- The discriminant of the power basis given by `ζ - 1`. Beware that in the cases `p ^ k = 1` and `p ^ k = 2` the formula uses `1 / 2 = 0` and `0 - 1 = 0`. It is useful only to have a uniform result. See also `is_cyclotomic_extension.rat.discr_prime_pow_eq_unit_mul_pow'`. -/ theorem discr_prime_pow' [IsCyclotomicExtension {p ^ k} ℚ K] (hζ : IsPrimitiveRoot ζ ↑(p ^ k)) : discr ℚ (hζ.subOnePowerBasis ℚ).basis = (-1) ^ ((p ^ k : ℕ).totient / 2) * p ^ ((p : ℕ) ^ (k - 1) * ((p - 1) * k - 1)) := by rw [← discr_prime_pow hζ (cyclotomic.irreducible_rat (p ^ k).Pos)] exact hζ.discr_zeta_eq_discr_zeta_sub_one.symm #align is_cyclotomic_extension.rat.discr_prime_pow' IsCyclotomicExtension.Rat.discr_prime_pow' /-- If `p` is a prime and `is_cyclotomic_extension {p ^ k} K L`, then there are `u : ℤˣ` and `n : ℕ` such that the discriminant of the power basis given by `ζ - 1` is `u * p ^ n`. Often this is enough and less cumbersome to use than `is_cyclotomic_extension.rat.discr_prime_pow'`. -/ theorem discr_prime_pow_eq_unit_mul_pow' [IsCyclotomicExtension {p ^ k} ℚ K] (hζ : IsPrimitiveRoot ζ ↑(p ^ k)) : ∃ (u : ℤˣ)(n : ℕ), discr ℚ (hζ.subOnePowerBasis ℚ).basis = u * p ^ n := by rw [hζ.discr_zeta_eq_discr_zeta_sub_one.symm] exact discr_prime_pow_eq_unit_mul_pow hζ (cyclotomic.irreducible_rat (p ^ k).Pos) #align is_cyclotomic_extension.rat.discr_prime_pow_eq_unit_mul_pow' IsCyclotomicExtension.Rat.discr_prime_pow_eq_unit_mul_pow' /-- If `K` is a `p ^ k`-th cyclotomic extension of `ℚ`, then `(adjoin ℤ {ζ})` is the integral closure of `ℤ` in `K`. -/ theorem isIntegralClosure_adjoin_singleton_of_prime_pow [hcycl : IsCyclotomicExtension {p ^ k} ℚ K] (hζ : IsPrimitiveRoot ζ ↑(p ^ k)) : IsIntegralClosure (adjoin ℤ ({ζ} : Set K)) ℤ K := by refine' ⟨Subtype.val_injective, fun x => ⟨fun h => ⟨⟨x, _⟩, rfl⟩, _⟩⟩ swap · rintro ⟨y, rfl⟩ exact IsIntegral.algebraMap (le_integralClosure_iff_isIntegral.1 (adjoin_le_integralClosure (hζ.is_integral (p ^ k).Pos)) _) let B := hζ.sub_one_power_basis ℚ have hint : IsIntegral ℤ B.gen := isIntegral_sub (hζ.is_integral (p ^ k).Pos) isIntegral_one have H := discr_mul_is_integral_mem_adjoin ℚ hint h obtain ⟨u, n, hun⟩ := discr_prime_pow_eq_unit_mul_pow' hζ rw [hun] at H replace H := Subalgebra.smul_mem _ H u.inv rw [← smul_assoc, ← smul_mul_assoc, Units.inv_eq_val_inv, coe_coe, zsmul_eq_mul, ← Int.cast_mul, Units.inv_mul, Int.cast_one, one_mul, show (p : ℚ) ^ n • x = ((p : ℕ) : ℤ) ^ n • x by simp [smul_def]] at H cases k · haveI : IsCyclotomicExtension {1} ℚ K := by simpa using hcycl have : x ∈ (⊥ : Subalgebra ℚ K) := by rw [singleton_one ℚ K] exact mem_top obtain ⟨y, rfl⟩ := mem_bot.1 this replace h := (isIntegral_algebraMap_iff (algebraMap ℚ K).Injective).1 h obtain ⟨z, hz⟩ := IsIntegrallyClosed.isIntegral_iff.1 h rw [← hz, ← IsScalarTower.algebraMap_apply] exact Subalgebra.algebraMap_mem _ _ · have hmin : (minpoly ℤ B.gen).IsEisensteinAt (Submodule.span ℤ {((p : ℕ) : ℤ)}) := by have h₁ := minpoly.isIntegrallyClosed_eq_field_fractions' ℚ hint have h₂ := hζ.minpoly_sub_one_eq_cyclotomic_comp (cyclotomic.irreducible_rat (p ^ _).Pos) rw [IsPrimitiveRoot.subOnePowerBasis_gen] at h₁ rw [h₁, ← map_cyclotomic_int, show Int.castRingHom ℚ = algebraMap ℤ ℚ by rfl, show X + 1 = map (algebraMap ℤ ℚ) (X + 1) by simp, ← map_comp] at h₂ haveI : CharZero ℚ := StrictOrderedSemiring.to_charZero rw [IsPrimitiveRoot.subOnePowerBasis_gen, map_injective (algebraMap ℤ ℚ) (algebraMap ℤ ℚ).injective_int h₂] exact cyclotomic_prime_pow_comp_x_add_one_isEisensteinAt _ _ refine' adjoin_le _ (mem_adjoin_of_smul_prime_pow_smul_of_minpoly_is_eiseinstein_at (Nat.prime_iff_prime_int.1 hp.out) hint h H hmin) simp only [Set.singleton_subset_iff, SetLike.mem_coe] exact Subalgebra.sub_mem _ (self_mem_adjoin_singleton ℤ _) (Subalgebra.one_mem _) #align is_cyclotomic_extension.rat.is_integral_closure_adjoin_singleton_of_prime_pow IsCyclotomicExtension.Rat.isIntegralClosure_adjoin_singleton_of_prime_pow theorem isIntegralClosure_adjoin_singleton_of_prime [hcycl : IsCyclotomicExtension {p} ℚ K] (hζ : IsPrimitiveRoot ζ ↑p) : IsIntegralClosure (adjoin ℤ ({ζ} : Set K)) ℤ K := by rw [← pow_one p] at hζ hcycl exact is_integral_closure_adjoin_singleton_of_prime_pow hζ #align is_cyclotomic_extension.rat.is_integral_closure_adjoin_singleton_of_prime IsCyclotomicExtension.Rat.isIntegralClosure_adjoin_singleton_of_prime attribute [-instance] CyclotomicField.algebra /-- The integral closure of `ℤ` inside `cyclotomic_field (p ^ k) ℚ` is `cyclotomic_ring (p ^ k) ℤ ℚ`. -/ theorem cyclotomicRing_isIntegralClosure_of_prime_pow : IsIntegralClosure (CyclotomicRing (p ^ k) ℤ ℚ) ℤ (CyclotomicField (p ^ k) ℚ) := by haveI : CharZero ℚ := StrictOrderedSemiring.to_charZero have : IsCyclotomicExtension {p ^ k} ℚ (CyclotomicField (p ^ k) ℚ) := by convert CyclotomicField.isCyclotomicExtension (p ^ k) _ · exact Subsingleton.elim _ _ · exact NeZero.charZero have hζ := zeta_spec (p ^ k) ℚ (CyclotomicField (p ^ k) ℚ) refine' ⟨IsFractionRing.injective _ _, fun x => ⟨fun h => ⟨⟨x, _⟩, rfl⟩, _⟩⟩ · have := (is_integral_closure_adjoin_singleton_of_prime_pow hζ).isIntegral_iff obtain ⟨y, rfl⟩ := this.1 h convert adjoin_mono _ y.2 · simp only [eq_iff_true_of_subsingleton] · simp only [eq_iff_true_of_subsingleton] · simp only [PNat.pow_coe, Set.singleton_subset_iff, Set.mem_setOf_eq] exact hζ.pow_eq_one · have : IsCyclotomicExtension {p ^ k} ℤ (CyclotomicRing (p ^ k) ℤ ℚ) := by convert CyclotomicRing.isCyclotomicExtension _ ℤ ℚ · exact Subsingleton.elim _ _ · exact NeZero.charZero rintro ⟨y, rfl⟩ exact IsIntegral.algebraMap ((IsCyclotomicExtension.integral {p ^ k} ℤ _) _) #align is_cyclotomic_extension.rat.cyclotomic_ring_is_integral_closure_of_prime_pow IsCyclotomicExtension.Rat.cyclotomicRing_isIntegralClosure_of_prime_pow theorem cyclotomicRing_isIntegralClosure_of_prime : IsIntegralClosure (CyclotomicRing p ℤ ℚ) ℤ (CyclotomicField p ℚ) := by rw [← pow_one p] exact cyclotomic_ring_is_integral_closure_of_prime_pow #align is_cyclotomic_extension.rat.cyclotomic_ring_is_integral_closure_of_prime IsCyclotomicExtension.Rat.cyclotomicRing_isIntegralClosure_of_prime end IsCyclotomicExtension.Rat section PowerBasis open IsCyclotomicExtension.Rat namespace IsPrimitiveRoot /-- The algebra isomorphism `adjoin ℤ {ζ} ≃ₐ[ℤ] (𝓞 K)`, where `ζ` is a primitive `p ^ k`-th root of unity and `K` is a `p ^ k`-th cyclotomic extension of `ℚ`. -/ @[simps] noncomputable def IsPrimitiveRoot.adjoinEquivRingOfIntegers [hcycl : IsCyclotomicExtension {p ^ k} ℚ K] (hζ : IsPrimitiveRoot ζ ↑(p ^ k)) : adjoin ℤ ({ζ} : Set K) ≃ₐ[ℤ] 𝓞 K := let _ := isIntegralClosure_adjoin_singleton_of_prime_pow hζ IsIntegralClosure.equiv ℤ (adjoin ℤ ({ζ} : Set K)) K (𝓞 K) #align is_primitive_root.adjoin_equiv_ring_of_integers IsPrimitiveRoot.adjoinEquivRingOfIntegers /-- The ring of integers of a `p ^ k`-th cyclotomic extension of `ℚ` is a cyclotomic extension. -/ instance IsCyclotomicExtension.ringOfIntegers [IsCyclotomicExtension {p ^ k} ℚ K] : IsCyclotomicExtension {p ^ k} ℤ (𝓞 K) := let _ := (zeta_spec (p ^ k) ℚ K).adjoin_isCyclotomicExtension ℤ IsCyclotomicExtension.equiv _ ℤ _ (zeta_spec (p ^ k) ℚ K).adjoinEquivRingOfIntegers #align is_cyclotomic_extension.ring_of_integers IsCyclotomicExtension.ringOfIntegers /-- The integral `power_basis` of `𝓞 K` given by a primitive root of unity, where `K` is a `p ^ k` cyclotomic extension of `ℚ`. -/ noncomputable def integralPowerBasis [hcycl : IsCyclotomicExtension {p ^ k} ℚ K] (hζ : IsPrimitiveRoot ζ ↑(p ^ k)) : PowerBasis ℤ (𝓞 K) := (adjoin.powerBasis' (hζ.IsIntegral (p ^ k).Pos)).map hζ.adjoinEquivRingOfIntegers #align is_primitive_root.integral_power_basis IsPrimitiveRoot.integralPowerBasis @[simp] theorem integralPowerBasis_gen [hcycl : IsCyclotomicExtension {p ^ k} ℚ K] (hζ : IsPrimitiveRoot ζ ↑(p ^ k)) : hζ.integralPowerBasis.gen = ⟨ζ, hζ.IsIntegral (p ^ k).Pos⟩ := Subtype.ext <| show algebraMap _ K hζ.integralPowerBasis.gen = _ by simpa [integral_power_basis] #align is_primitive_root.integral_power_basis_gen IsPrimitiveRoot.integralPowerBasis_gen @[simp] theorem integralPowerBasis_dim [hcycl : IsCyclotomicExtension {p ^ k} ℚ K] (hζ : IsPrimitiveRoot ζ ↑(p ^ k)) : hζ.integralPowerBasis.dim = φ (p ^ k) := by simp [integral_power_basis, ← cyclotomic_eq_minpoly hζ, nat_degree_cyclotomic] #align is_primitive_root.integral_power_basis_dim IsPrimitiveRoot.integralPowerBasis_dim /-- The algebra isomorphism `adjoin ℤ {ζ} ≃ₐ[ℤ] (𝓞 K)`, where `ζ` is a primitive `p`-th root of unity and `K` is a `p`-th cyclotomic extension of `ℚ`. -/ @[simps] noncomputable def IsPrimitiveRoot.adjoinEquivRingOfIntegers' [hcycl : IsCyclotomicExtension {p} ℚ K] (hζ : IsPrimitiveRoot ζ p) : adjoin ℤ ({ζ} : Set K) ≃ₐ[ℤ] 𝓞 K := @adjoinEquivRingOfIntegers p 1 K _ _ _ _ (by convert hcycl rw [pow_one]) (by rwa [pow_one]) #align is_primitive_root.adjoin_equiv_ring_of_integers' IsPrimitiveRoot.adjoinEquivRingOfIntegers' /-- The ring of integers of a `p`-th cyclotomic extension of `ℚ` is a cyclotomic extension. -/ instance IsCyclotomicExtension.ring_of_integers' [IsCyclotomicExtension {p} ℚ K] : IsCyclotomicExtension {p} ℤ (𝓞 K) := let _ := (zeta_spec p ℚ K).adjoin_isCyclotomicExtension ℤ IsCyclotomicExtension.equiv _ ℤ _ (zeta_spec p ℚ K).adjoinEquivRingOfIntegers' #align is_cyclotomic_extension.ring_of_integers' IsCyclotomicExtension.ring_of_integers' /-- The integral `power_basis` of `𝓞 K` given by a primitive root of unity, where `K` is a `p`-th cyclotomic extension of `ℚ`. -/ noncomputable def integralPowerBasis' [hcycl : IsCyclotomicExtension {p} ℚ K] (hζ : IsPrimitiveRoot ζ p) : PowerBasis ℤ (𝓞 K) := @integralPowerBasis p 1 K _ _ _ _ (by convert hcycl rw [pow_one]) (by rwa [pow_one]) #align is_primitive_root.integral_power_basis' IsPrimitiveRoot.integralPowerBasis' @[simp] theorem integralPowerBasis'_gen [hcycl : IsCyclotomicExtension {p} ℚ K] (hζ : IsPrimitiveRoot ζ p) : hζ.integralPowerBasis'.gen = ⟨ζ, hζ.IsIntegral p.Pos⟩ := @integralPowerBasis_gen p 1 K _ _ _ _ (by convert hcycl rw [pow_one]) (by rwa [pow_one]) #align is_primitive_root.integral_power_basis'_gen IsPrimitiveRoot.integralPowerBasis'_gen @[simp] theorem power_basis_int'_dim [hcycl : IsCyclotomicExtension {p} ℚ K] (hζ : IsPrimitiveRoot ζ p) : hζ.integralPowerBasis'.dim = φ p := by erw [@integral_power_basis_dim p 1 K _ _ _ _ (by convert hcycl rw [pow_one]) (by rwa [pow_one]), pow_one] #align is_primitive_root.power_basis_int'_dim IsPrimitiveRoot.power_basis_int'_dim /-- The integral `power_basis` of `𝓞 K` given by `ζ - 1`, where `K` is a `p ^ k` cyclotomic extension of `ℚ`. -/ noncomputable def subOneIntegralPowerBasis [IsCyclotomicExtension {p ^ k} ℚ K] (hζ : IsPrimitiveRoot ζ ↑(p ^ k)) : PowerBasis ℤ (𝓞 K) := PowerBasis.ofGenMemAdjoin' hζ.integralPowerBasis (isIntegral_of_mem_ringOfIntegers <| Subalgebra.sub_mem _ (hζ.IsIntegral (p ^ k).Pos) (Subalgebra.one_mem _)) (by simp only [integral_power_basis_gen] convert Subalgebra.add_mem _ (self_mem_adjoin_singleton ℤ (⟨ζ - 1, _⟩ : 𝓞 K)) (Subalgebra.one_mem _) simp) #align is_primitive_root.sub_one_integral_power_basis IsPrimitiveRoot.subOneIntegralPowerBasis @[simp] theorem subOneIntegralPowerBasis_gen [IsCyclotomicExtension {p ^ k} ℚ K] (hζ : IsPrimitiveRoot ζ ↑(p ^ k)) : hζ.subOneIntegralPowerBasis.gen = ⟨ζ - 1, Subalgebra.sub_mem _ (hζ.IsIntegral (p ^ k).Pos) (Subalgebra.one_mem _)⟩ := by simp [sub_one_integral_power_basis] #align is_primitive_root.sub_one_integral_power_basis_gen IsPrimitiveRoot.subOneIntegralPowerBasis_gen /-- The integral `power_basis` of `𝓞 K` given by `ζ - 1`, where `K` is a `p`-th cyclotomic extension of `ℚ`. -/ noncomputable def subOneIntegralPowerBasis' [hcycl : IsCyclotomicExtension {p} ℚ K] (hζ : IsPrimitiveRoot ζ p) : PowerBasis ℤ (𝓞 K) := @subOneIntegralPowerBasis p 1 K _ _ _ _ (by convert hcycl rw [pow_one]) (by rwa [pow_one]) #align is_primitive_root.sub_one_integral_power_basis' IsPrimitiveRoot.subOneIntegralPowerBasis' @[simp] theorem subOneIntegralPowerBasis'_gen [hcycl : IsCyclotomicExtension {p} ℚ K] (hζ : IsPrimitiveRoot ζ p) : hζ.subOneIntegralPowerBasis'.gen = ⟨ζ - 1, Subalgebra.sub_mem _ (hζ.IsIntegral p.Pos) (Subalgebra.one_mem _)⟩ := @subOneIntegralPowerBasis_gen p 1 K _ _ _ _ (by convert hcycl rw [pow_one]) (by rwa [pow_one]) #align is_primitive_root.sub_one_integral_power_basis'_gen IsPrimitiveRoot.subOneIntegralPowerBasis'_gen end IsPrimitiveRoot end PowerBasis
Formal statement is: lemma complex_i_not_numeral [simp]: "\<i> \<noteq> numeral w" Informal statement is: The complex number $\i$ is not a numeral.
module a contains subroutine b() end module
State Before: 𝕜₁ : Type u_3 𝕜₂ : Type u_1 inst✝⁷ : NontriviallyNormedField 𝕜₁ inst✝⁶ : SeminormedRing 𝕜₂ σ₁₂ : 𝕜₁ →+* 𝕜₂ M₁ : Type u_4 M₂ : Type u_2 M₃ : Type ?u.72218 inst✝⁵ : SeminormedAddCommGroup M₁ inst✝⁴ : TopologicalSpace M₂ inst✝³ : AddCommMonoid M₂ inst✝² : NormedSpace 𝕜₁ M₁ inst✝¹ : Module 𝕜₂ M₂ inst✝ : ContinuousConstSMul 𝕜₂ M₂ f : M₁ →ₛₗ[σ₁₂] M₂ hf : IsCompactOperator ↑f S : Set M₁ hS : Metric.Bounded S ⊢ IsVonNBounded 𝕜₁ S State After: no goals Tactic: rwa [NormedSpace.isVonNBounded_iff, ← Metric.bounded_iff_isBounded]
= = Impact = =
= = Impact = =
= = Impact = =
lemma coeff_eq_0: assumes "degree p < n" shows "coeff p n = 0"
Description: Martha's Vineyard & Nantucket is a business categorized under others miscellaneous retail, which is part of the larger category business services. Martha's Vineyard & Nantucket is located at the address 73 Lagoon Pond Road in Vineyard Haven, Massachusetts 02568-5514. The Owner is Barbara St Pierre who can be contacted at (508)693-7200. Location & access map for "Martha's Vineyard & Nantucket"
(** This file is part of the Coquelicot formalization of real analysis in Coq: http://coquelicot.saclay.inria.fr/ Copyright (C) 2011-2015 Sylvie Boldo #<br /># Copyright (C) 2011-2015 Catherine Lelay #<br /># Copyright (C) 2011-2015 Guillaume Melquiond This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the COPYING file for more details. *) Require Import Reals Psatz. Require Import mathcomp.ssreflect.ssreflect mathcomp.ssreflect.ssrbool mathcomp.ssreflect.eqtype mathcomp.ssreflect.seq. Require Import Markov Rcomplements Rbar Lub Lim_seq Derive SF_seq. Require Import Continuity Hierarchy Seq_fct RInt PSeries. (** This file contains results about the integral as a function: continuity, differentiability, and composition. Theorems on parametric integrals are also provided. *) (** * Continuity *) Section Continuity. Context {V : NormedModule R_AbsRing}. Lemma continuous_RInt_0 : forall (f : R -> V) (a : R) If, locally a (fun x => is_RInt f a x (If x)) -> continuous If a. Proof. move => f a If [d1 /= CIf]. assert (forall eps : posreal, norm (If a) < eps). move => eps. generalize (fun Hy => proj1 (filterlim_locally_ball_norm _ _) (CIf a Hy) eps) => /= {CIf} CIf. assert (Rabs (a + - a) < d1). rewrite -/(Rminus _ _) Rminus_eq_0 Rabs_R0. by apply d1. destruct (CIf H) as [d CIf']. assert (exists y : SF_seq, seq_step (SF_lx y) < d /\ pointed_subdiv y /\ SF_h y = Rmin a a /\ seq.last (SF_h y) (SF_lx y) = Rmax a a). apply filter_ex. exists d => y Hy Hy'. now split. case: H0 => {CIf H} ptd [Hstep Hptd]. specialize (CIf' ptd Hstep Hptd). rewrite Rminus_eq_0 sign_0 in CIf'. rewrite -norm_opp. replace (opp (If a)) with (minus (scal 0 (Riemann_sum f ptd)) (If a)). by apply CIf'. replace (scal 0 (Riemann_sum f ptd) : V) with (zero : V). by rewrite /minus plus_zero_l. apply sym_eq ; apply: scal_zero_l. apply filterlim_locally_ball_norm. cut (forall eps : posreal, locally a (fun x : R => norm (If x) < eps)). move => H0 eps. specialize (H (pos_div_2 eps)). specialize (H0 (pos_div_2 eps)). destruct H0 as [d Hd]. exists d => /= y Hy. apply Rle_lt_trans with (norm (If y) + norm (If a))%R. rewrite -(norm_opp (If a)). apply @norm_triangle. rewrite (double_var eps). apply Rplus_lt_compat. now apply Hd. by apply H. clear H. move => eps. destruct (ex_RInt_ub f (a - d1 / 2) (a + d1 / 2)) as [Mf HMf]. apply ex_RInt_Chasles with a. apply ex_RInt_swap ; eexists ; apply CIf. rewrite /ball /= /AbsRing_ball /= /abs /minus /plus /opp /=. field_simplify (a - d1 / 2 + - a)%R. rewrite Rabs_left. apply Rminus_lt_0 ; field_simplify ; rewrite Rdiv_1. by apply is_pos_div_2. apply Ropp_lt_cancel ; field_simplify ; rewrite Rdiv_1. by apply is_pos_div_2. eexists ; apply CIf. rewrite /ball /= /AbsRing_ball /= /abs /minus /plus /opp /=. field_simplify (a + d1 / 2 + - a)%R. rewrite Rabs_pos_eq. apply Rminus_lt_0 ; field_simplify ; rewrite Rdiv_1. by apply is_pos_div_2. apply Rlt_le ; field_simplify ; rewrite Rdiv_1. by apply is_pos_div_2. assert ((a - d1 / 2) <= (a + d1 / 2)). apply Rminus_le_0. replace (a + d1 / 2 - (a - d1 / 2))%R with (d1 : R) by field. by apply Rlt_le, d1. move: HMf ; rewrite /Rmin /Rmax ; case: Rle_dec => // _ HMf. assert (0 <= Mf). eapply Rle_trans. 2: apply (HMf (a - d1 / 2)%R) ; split => // ; by apply Rle_refl. by apply norm_ge_0. generalize (fun y Hy => proj1 (filterlim_locally_ball_norm _ _) (CIf y Hy) (pos_div_2 eps)) => /= {CIf} CIf. assert (0 < Rmin (d1 / 2) (eps / (2 * (Mf + 1)))). apply Rmin_case. by apply is_pos_div_2. apply Rdiv_lt_0_compat. by apply eps. apply Rmult_lt_0_compat. by apply Rlt_0_2. apply Rplus_le_lt_0_compat. by []. by apply Rlt_0_1. set (d2 := mkposreal _ H1). exists d2 => x /= Hx. specialize (CIf x). destruct CIf as [d' CIf]. apply Rlt_trans with (1 := Hx). apply Rle_lt_trans with (1 := Rmin_l _ _). apply Rminus_lt_0 ; field_simplify ; rewrite Rdiv_1 ; by apply is_pos_div_2. assert (exists y0, seq_step (SF_lx y0) < d' /\ pointed_subdiv y0 /\ SF_h y0 = Rmin a x /\ seq.last (SF_h y0) (SF_lx y0) = Rmax a x). apply filter_ex. exists d' => y Hy Hy'. now split. case: H2 => ptd [Hstep Hptd]. specialize (CIf ptd Hstep Hptd). rewrite -norm_opp. replace (opp (If x)) with (minus (minus (scal (sign (x - a)) (Riemann_sum f ptd)) (If x)) (scal (sign (x - a)) (Riemann_sum f ptd))). 2: rewrite /minus plus_comm plus_assoc plus_opp_l. 2: by apply plus_zero_l. apply Rle_lt_trans with (norm (minus (scal (sign (x - a)) (Riemann_sum f ptd)) (If x)) + norm (opp (scal (sign (x - a)) (Riemann_sum f ptd))))%R. rewrite /minus ; by apply @norm_triangle. rewrite norm_opp (double_var eps). apply Rplus_lt_le_compat. by []. apply Rle_trans with (1 := norm_scal (sign (x - a)) _). apply Rle_trans with (1 * norm (Riemann_sum f ptd)). apply Rmult_le_compat_r. apply norm_ge_0. rewrite /abs /= /sign ; case: total_order_T => [[H2|H2]|H2]. rewrite Rabs_R1. apply Rle_refl. rewrite Rabs_R0. apply Rle_0_1. rewrite Rabs_Ropp Rabs_R1. apply Rle_refl. rewrite Rmult_1_l. apply Rle_trans with (Riemann_sum (fun _ => Mf) ptd). apply Riemann_sum_norm. apply Hptd. move => t. rewrite (proj2 (proj2 Hptd)) (proj1 (proj2 Hptd)) => Ht. apply HMf ; split ; eapply Rle_trans ; try apply Ht. apply Rmin_case. apply Rlt_le, Rminus_lt_0 ; field_simplify ; rewrite Rdiv_1 ; by apply is_pos_div_2. apply Rlt_le, Rabs_lt_between'. apply Rlt_le_trans with (1 := Hx). by apply Rmin_l. apply Rmax_case. apply Rlt_le, Rminus_lt_0 ; field_simplify ; rewrite Rdiv_1 ; by apply is_pos_div_2. apply Rlt_le, Rabs_lt_between'. apply Rlt_le_trans with (1 := Hx). by apply Rmin_l. rewrite Riemann_sum_const. rewrite (proj2 (proj2 Hptd)) (proj1 (proj2 Hptd)) /=. apply Rle_trans with (Rabs (x + - a) * Mf)%R. apply Rmult_le_compat_r. by []. rewrite /Rmin /Rmax ; case: Rle_dec => _. apply Rle_abs. rewrite -Ropp_minus_distr. apply Rabs_maj2. apply Rle_trans with (Rabs (x + - a) * (Mf + 1))%R. apply Rmult_le_compat_l. by apply Rabs_pos. apply Rminus_le_0 ; ring_simplify ; by apply Rle_0_1. apply Rle_div_r. apply Rlt_le_trans with (1 := Rlt_0_1). apply Rminus_le_0 ; by ring_simplify. apply Rlt_le, Rlt_le_trans with (1 := Hx). apply Rle_trans with (1 := Rmin_r _ _). apply Req_le ; field. apply Rgt_not_eq, Rlt_le_trans with (1 := Rlt_0_1). apply Rminus_le_0 ; by ring_simplify. Qed. Lemma continuous_RInt_1 (f : R -> V) (a b : R) (If : R -> V) : locally b (fun z : R => is_RInt f a z (If z)) -> continuous If b. Proof. intros. generalize (locally_singleton _ _ H) => /= Hab. apply continuous_ext with (fun z => plus (If b) (minus (If z) (If b))) ; simpl. intros x. by rewrite plus_comm -plus_assoc plus_opp_l plus_zero_r. eapply filterlim_comp_2, filterlim_plus. apply filterlim_const. apply (continuous_RInt_0 f _ (fun x : R_UniformSpace => minus (If x) (If b))). apply: filter_imp H => x Hx. rewrite /minus plus_comm. eapply is_RInt_Chasles, Hx. by apply is_RInt_swap. Qed. Lemma continuous_RInt_2 (f : R -> V) (a b : R) (If : R -> V) : locally a (fun z : R => is_RInt f z b (If z)) -> continuous If a. Proof. intros. generalize (locally_singleton _ _ H) => /= Hab. apply continuous_ext with (fun z => opp (plus (opp (If a)) (minus (If a) (If z)))) ; simpl. intros x. by rewrite /minus plus_assoc plus_opp_l plus_zero_l opp_opp. apply continuous_opp. apply continuous_plus. apply filterlim_const. apply (continuous_RInt_0 f _ (fun x : R_UniformSpace => minus (If a) (If x))). apply: filter_imp H => x Hx. eapply is_RInt_Chasles. by apply Hab. by apply is_RInt_swap. Qed. Lemma continuous_RInt (f : R -> V) (a b : R) (If : R -> R -> V) : locally (a,b) (fun z : R * R => is_RInt f (fst z) (snd z) (If (fst z) (snd z))) -> continuous (fun z : R * R => If (fst z) (snd z)) (a,b). Proof. intros HIf. move: (locally_singleton _ _ HIf) => /= Hab. apply continuous_ext_loc with (fun z : R * R => plus (If (fst z) b) (plus (opp (If a b)) (If a (snd z)))) ; simpl. assert (Ha : locally (a,b) (fun z : R * R => is_RInt f a (snd z) (If a (snd z)))). case: HIf => /= d HIf. exists d => y /= Hy. apply (HIf (a,(snd y))) ; split => //=. by apply ball_center. by apply Hy. assert (Hb : locally (a,b) (fun z : R * R => is_RInt f (fst z) b (If (fst z) b))). case: HIf => /= d HIf. exists d => x /= Hx. apply (HIf (fst x,b)) ; split => //=. by apply Hx. by apply ball_center. generalize (filter_and _ _ HIf (filter_and _ _ Ha Hb)). apply filter_imp => {HIf Ha Hb} /= x [HIf [Ha Hb]]. apply eq_close. eapply filterlim_locally_close. eapply is_RInt_Chasles. by apply Hb. eapply is_RInt_Chasles. by apply is_RInt_swap, Hab. by apply Ha. by apply HIf. eapply filterlim_comp_2, filterlim_plus ; simpl. apply (continuous_comp (fun x => fst x) (fun x => If x b)) ; simpl. apply continuous_fst. eapply (continuous_RInt_2 f _ b). case: HIf => /= d HIf. exists d => x /= Hx. apply (HIf (x,b)). split => //=. by apply ball_center. eapply filterlim_comp_2, filterlim_plus ; simpl. apply filterlim_const. apply (continuous_comp (fun x => snd x) (fun x => If a x)) ; simpl. apply continuous_snd. eapply (continuous_RInt_1 f a b). case: HIf => /= d HIf. exists d => x /= Hx. apply (HIf (a,x)). split => //=. by apply ball_center. Qed. End Continuity. Lemma ex_RInt_locally {V : CompleteNormedModule R_AbsRing} (f : R -> V) (a b : R) : ex_RInt f a b -> (exists eps : posreal, ex_RInt f (a - eps) (a + eps)) -> (exists eps : posreal, ex_RInt f (b - eps) (b + eps)) -> locally (a,b) (fun z : R * R => ex_RInt f (fst z) (snd z)). Proof. intros Hf (ea,Hea) (eb,Heb). exists (mkposreal _ (Rmin_stable_in_posreal ea eb)) => [[a' b'] [Ha' Hb']] ; simpl in *. apply ex_RInt_Chasles with (a - ea). eapply ex_RInt_swap, ex_RInt_Chasles_1 ; try eassumption. apply Rabs_le_between'. eapply Rlt_le, Rlt_le_trans, Rmin_l. by apply Ha'. apply ex_RInt_Chasles with a. eapply ex_RInt_Chasles_1 ; try eassumption. apply Rabs_le_between'. rewrite Rminus_eq_0 Rabs_R0. by apply Rlt_le, ea. apply ex_RInt_Chasles with b => //. apply ex_RInt_Chasles with (b - eb). eapply ex_RInt_swap, ex_RInt_Chasles_1; try eassumption. apply Rabs_le_between'. rewrite Rminus_eq_0 Rabs_R0. by apply Rlt_le, eb. eapply ex_RInt_Chasles_1 ; try eassumption. apply Rabs_le_between'. eapply Rlt_le, Rlt_le_trans, Rmin_r. by apply Hb'. Qed. (** * Riemann integral and differentiability *) Section Derive. Context {V : NormedModule R_AbsRing}. Lemma is_derive_RInt_0 (f If : R -> V) (a : R) : locally a (fun b => is_RInt f a b (If b)) -> continuous f a -> is_derive If a (f a). Proof. intros HIf Hf. split ; simpl. apply is_linear_scal_l. intros y Hy. apply @is_filter_lim_locally_unique in Hy. rewrite -Hy {y Hy}. intros eps. generalize (proj1 (filterlim_locally _ _) Hf) => {Hf} Hf. eapply filter_imp. simpl ; intros y Hy. replace (If a) with (@zero V). rewrite @minus_zero_r. rewrite Rmult_comm ; eapply norm_RInt_le_const_abs ; last first. apply is_RInt_minus. instantiate (1 := f). eapply (proj1 Hy). apply is_RInt_const. simpl. apply (proj2 Hy). apply locally_singleton in HIf. set (HIf_0 := is_RInt_point f a). apply (filterlim_locally_unique _ _ _ HIf_0 HIf). apply filter_and. by apply HIf. assert (0 < eps / @norm_factor _ V). apply Rdiv_lt_0_compat. by apply eps. by apply norm_factor_gt_0. case: (Hf (mkposreal _ H)) => {Hf} delta Hf. exists delta ; intros y Hy z Hz. eapply Rle_trans. apply Rlt_le, norm_compat2. apply Hf. apply Rabs_lt_between'. move/Rabs_lt_between': Hy => Hy. rewrite /Rmin /Rmax in Hz ; destruct (Rle_dec a y) as [Hxy | Hxy]. split. eapply Rlt_le_trans, Hz. apply Rminus_lt_0 ; ring_simplify. by apply delta. eapply Rle_lt_trans, Hy. by apply Hz. split. eapply Rlt_le_trans, Hz. by apply Hy. eapply Rle_lt_trans. apply Hz. apply Rminus_lt_0 ; ring_simplify. by apply delta. simpl ; apply Req_le. field. apply Rgt_not_eq, norm_factor_gt_0. Qed. Lemma is_derive_RInt (f If : R -> V) (a b : R) : locally b (fun b => is_RInt f a b (If b)) -> continuous f b -> is_derive If b (f b). Proof. intros HIf Hf. apply is_derive_ext with (fun y => (plus (minus (If y) (If b)) (If b))). simpl ; intros. rewrite /minus -plus_assoc plus_opp_l. by apply plus_zero_r. evar_last. apply is_derive_plus. apply is_derive_RInt_0. 2: apply Hf. eapply filter_imp. intros y Hy. evar_last. apply is_RInt_Chasles with a. apply is_RInt_swap. 3: by apply plus_comm. by apply locally_singleton in HIf. by apply Hy. by apply HIf. apply is_derive_const. by apply plus_zero_r. Qed. Lemma is_derive_RInt' (f If : R -> V) (a b : R) : locally a (fun a => is_RInt f a b (If a)) -> continuous f a -> is_derive If a (opp (f a)). Proof. intros. apply is_derive_ext with (fun x => opp (opp (If x))). intros ; by rewrite opp_opp. apply is_derive_opp. apply is_derive_RInt with b => //. move: H ; apply filter_imp. intros x Hx. by apply is_RInt_swap. Qed. Lemma filterdiff_RInt (f : R -> V) (If : R -> R -> V) (a b : R) : locally (a,b) (fun u : R * R => is_RInt f (fst u) (snd u) (If (fst u) (snd u))) -> continuous f a -> continuous f b -> filterdiff (fun u : R * R => If (fst u) (snd u)) (locally (a,b)) (fun u : R * R => minus (scal (snd u) (f b)) (scal (fst u) (f a))). Proof. intros Hf Cfa Cfb. assert (Ha : locally a (fun a : R => is_RInt f a b (If a b))). case: Hf => /= e He. exists e => x Hx. apply (He (x,b)). split => //. by apply ball_center. assert (Hb : locally b (fun b : R => is_RInt f a b (If a b))). case: Hf => /= e He. exists e => x Hx. apply (He (a,x)). split => //. by apply ball_center. eapply filterdiff_ext_lin. apply (filterdiff_ext_loc (FF := @filter_filter _ _ (locally_filter _)) (fun u : R * R => plus (If (fst u) b) (minus (If a (snd u)) (If a b)))) ; last first. apply filterdiff_plus_fct. apply (filterdiff_comp' (fun u : R * R => fst u) (fun a : R => If a b)). by apply filterdiff_linear, is_linear_fst. eapply is_derive_RInt', Cfa. by apply Ha. apply filterdiff_plus_fct. apply (filterdiff_comp' (fun u : R * R => snd u) (fun b : R => If a b)). by apply filterdiff_linear, is_linear_snd. eapply is_derive_RInt, Cfb. by apply Hb. apply filterdiff_const. move => /= x Hx. apply @is_filter_lim_locally_unique in Hx. by rewrite -Hx /= minus_eq_zero plus_zero_r. simpl. have : (locally (a,b) (fun u : R * R => is_RInt f (fst u) b (If (fst u) b))) => [ | {Ha} Ha]. case: Ha => /= e He. exists e => y Hy. apply He, Hy. have : (locally (a,b) (fun u : R * R => is_RInt f a (snd u) (If a (snd u)))) => [ | {Hb} Hb]. case: Hb => /= e He. exists e => y Hy. apply He, Hy. move: (locally_singleton _ _ Hf) => /= Hab. generalize (filter_and _ _ Hf (filter_and _ _ Ha Hb)). apply filter_imp => {Hf Ha Hb} /= u [Hf [Ha Hb]]. apply sym_eq, (filterlim_locally_unique _ _ _ Hf). apply is_RInt_Chasles with b => //. rewrite /minus plus_comm. apply is_RInt_Chasles with a => //. by apply is_RInt_swap. simpl => y. rewrite scal_opp_r plus_zero_r. apply plus_comm. Qed. End Derive. Lemma Derive_RInt (f : R -> R) (a b : R) : locally b (ex_RInt f a) -> continuous f b -> Derive (RInt f a) b = f b. Proof. intros If Cf. apply is_derive_unique, (is_derive_RInt _ _ a) => //. move: If ; apply filter_imp => y. exact: RInt_correct. Qed. Lemma Derive_RInt' (f : R -> R) (a b : R) : locally a (fun a => ex_RInt f a b) -> continuous f a -> Derive (fun a => RInt f a b) a = - f a. Proof. intros If Cf. eapply is_derive_unique, (is_derive_RInt' (V := R_NormedModule) _ _ a b) => //. move: If ; apply filter_imp => y. exact: RInt_correct. Qed. Section Derive'. Context {V : CompleteNormedModule R_AbsRing}. Lemma is_RInt_derive (f df : R -> V) (a b : R) : (forall x : R, Rmin a b <= x <= Rmax a b -> is_derive f x (df x)) -> (forall x : R, Rmin a b <= x <= Rmax a b -> continuous df x) -> is_RInt df a b (minus (f b) (f a)). Proof. intros Hf Hdf. wlog Hab: a b Hf Hdf / (a < b). intros H. destruct (Rlt_or_le a b) as [Hab|Hab]. exact: H. destruct Hab as [Hab|Hab]. + rewrite -(opp_opp (minus _ _)). apply: is_RInt_swap. rewrite opp_minus. apply H. by rewrite Rmin_comm Rmax_comm. by rewrite Rmin_comm Rmax_comm. easy. + rewrite Hab. rewrite /minus plus_opp_r. by apply: is_RInt_point. rewrite Rmin_left in Hf; last by lra. rewrite Rmax_right in Hf; last by lra. rewrite Rmin_left in Hdf; last by lra. rewrite Rmax_right in Hdf; last by lra. have Hminab : Rmin a b = a by rewrite Rmin_left; lra. have Hmaxab : Rmax a b = b by rewrite Rmax_right; lra. evar_last. apply RInt_correct. apply (ex_RInt_continuous df) => t Ht. rewrite Hminab Hmaxab in Ht. exact:Hdf. apply (plus_reg_r (opp (f b))). rewrite /minus -plus_assoc (plus_comm (opp _)) plus_assoc plus_opp_r. rewrite -(RInt_point a df). apply: sym_eq. have Hext : forall x : R, Rmin a b < x < Rmax a b -> extension_C0 df a b x = df x. move => x; rewrite Hminab Hmaxab => Hx. by rewrite extension_C0_ext //=; lra. rewrite -(RInt_ext _ _ _ _ Hext). rewrite RInt_point -(RInt_point a (extension_C0 df a b)). rewrite -!(extension_C1_ext f df a b) /=; try lra. apply: (eq_is_derive (fun t => minus (RInt _ a t) (_ t))) => // t Ht. have -> : zero = minus (extension_C0 df a b t) (extension_C0 df a b t) by rewrite minus_eq_zero. apply: is_derive_minus; last first. apply: extension_C1_is_derive => /=; first by lra. by move => x Hax Hxb; apply: Hf; lra. apply: (is_derive_RInt _ _ a). apply: filter_forall. move => x; apply: RInt_correct. apply: ex_RInt_continuous. move => z Hz; apply: extension_C0_continuous => /=; try lra. by move => x0 Hax0 Hx0b; apply: Hdf; lra. apply: extension_C0_continuous => /=; try lra. move => x0 Hax0 Hx0b; apply: Hdf; lra. Qed. End Derive'. Lemma RInt_Derive (f : R -> R) (a b : R): (forall x, Rmin a b <= x <= Rmax a b -> ex_derive f x) -> (forall x, Rmin a b <= x <= Rmax a b -> continuous (Derive f) x) -> RInt (Derive f) a b = f b - f a. Proof. intros Df Cdf. apply is_RInt_unique. apply: is_RInt_derive => //. intros ; by apply Derive_correct, Df. Qed. (** ** Composition *) Section Comp. Context {V : CompleteNormedModule R_AbsRing}. (* Notation consistent version of the lemmas used in is_RInt_comp *) Lemma IVT_gen_consistent (f : R -> R) (a b y : R) : (forall x, continuous f x) -> Rmin (f a) (f b) <= y <= Rmax (f a) (f b) -> { x : R | Rmin a b <= x <= Rmax a b /\ f x = y }. Proof. move => Hf. apply: IVT_gen. move => x. apply continuity_pt_filterlim. exact: Hf. Qed. Lemma continuous_ab_maj_consistent : forall (f : R -> R) (a b : R), a <= b -> (forall c : R, a <= c <= b -> continuous f c) -> exists Mx : R, (forall c : R, a <= c <= b -> f c <= f Mx) /\ a <= Mx <= b. Proof. move => f a b Hab Hc. apply: continuity_ab_maj => // . by move => c Hc1; apply continuity_pt_filterlim; exact: Hc. Qed. Lemma continuous_ab_min_consistent : forall (f : R -> R) (a b : R), a <= b -> (forall c : R, a <= c <= b -> continuous f c) -> exists mx : R, (forall c : R, a <= c <= b -> f mx <= f c) /\ a <= mx <= b. Proof. move => f a b Hab Hc. apply: continuity_ab_min => // . by move => c Hc1; apply continuity_pt_filterlim; exact: Hc. Qed. Lemma is_RInt_comp (f : R -> V) (g dg : R -> R) (a b : R) : (forall x, Rmin a b <= x <= Rmax a b -> continuous f (g x)) -> (forall x, Rmin a b <= x <= Rmax a b -> is_derive g x (dg x) /\ continuous dg x) -> is_RInt (fun y => scal (dg y) (f (g y))) a b (RInt f (g a) (g b)). Proof. wlog: a b / (a < b) => [Hw|Hab]. case: (total_order_T a b) => [[Hab'|Hab']|Hab'] Hf Hg. - exact: Hw. - rewrite Hab'. by rewrite RInt_point; apply: is_RInt_point. - rewrite <- (opp_opp (RInt f _ _)). apply: is_RInt_swap. rewrite opp_RInt_swap. apply Hw => // . by rewrite Rmin_comm Rmax_comm. by rewrite Rmin_comm Rmax_comm. apply: ex_RInt_continuous => z Hz. case: (IVT_gen_consistent (extension_C0 g b a) b a z). + apply: extension_C0_continuous => /=; try lra. move => x Hbx Hxa; apply: ex_derive_continuous. by exists (dg x); apply Hg; rewrite Rmin_right ?Rmax_left; try lra. + rewrite !(extension_C0_ext) /=; try lra. by rewrite Rmin_comm Rmax_comm. + move => x [Hx1 Hx2]. rewrite -Hx2. rewrite Rmin_left ?Rmax_right in Hx1; try lra. rewrite (extension_C0_ext) /=; try lra. apply: Hf. by move: Hx1; rewrite Rmin_right ?Rmax_left; lra. rewrite -> Rmin_left by now apply Rlt_le. rewrite -> Rmax_right by now apply Rlt_le. wlog: g dg / (forall x : R, is_derive g x (dg x) /\ continuous dg x) => [Hw Hf Hg | Hg Hf _]. rewrite -?(extension_C1_ext g dg a b) ; try by [left | right]. set g0 := extension_C1 g dg a b. set dg0 := extension_C0 dg a b. apply is_RInt_ext with (fun y : R => scal (dg0 y) (f (g0 y))). + rewrite /Rmin /Rmax /g0 ; case: Rle_dec (Rlt_le _ _ Hab) => // _ _ x Hx. apply f_equal2. by apply extension_C0_ext ; by apply Rlt_le, Hx. by apply f_equal, extension_C1_ext ; by apply Rlt_le, Hx. + apply Hw. * intros x ; split. apply extension_C1_is_derive. by apply Rlt_le. by intros ; apply Hg ; by split. * apply @extension_C0_continuous. by apply Rlt_le. intros ; apply Hg ; by split. * intros ; rewrite /g0 extension_C1_ext. by apply Hf. by apply H. by apply H. intros ; split. apply extension_C1_is_derive. by apply Rlt_le. intros ; apply Hg ; by split. apply @extension_C0_continuous. by apply Rlt_le. by intros ; apply Hg ; by split. have cg : forall x, continuous g x. move => t Ht; apply: ex_derive_continuous. by exists (dg t); apply Hg. wlog: f Hf / (forall x, continuous f x) => [Hw | {Hf} Hf]. case: (continuous_ab_maj_consistent g a b (Rlt_le _ _ Hab)) => [ | M HM]. move => x Hx; apply: ex_derive_continuous. by exists (dg x); apply Hg. case: (continuous_ab_min_consistent g a b (Rlt_le _ _ Hab)) => [ | m Hm]. move => x Hx; apply: ex_derive_continuous. by exists (dg x) ; apply Hg. have H : g m <= g M. by apply Hm ; intuition. case: (C0_extension_le f (g m) (g M)) => [ y Hy | f0 Hf0]. + case: (IVT_gen_consistent g m M y) => // . rewrite /Rmin /Rmax ; case: Rle_dec => // . move => x [Hx <-]. apply Hf ; split. apply Rle_trans with (2 := proj1 Hx). by apply Rmin_case ; intuition. apply Rle_trans with (1 := proj2 Hx). apply Rmax_case ; intuition. apply is_RInt_ext with (fun y : R => scal (dg y) (f0 (g y))). rewrite /Rmin /Rmax ; case: Rle_dec (Rlt_le _ _ Hab) => // _ _ x Hc. apply f_equal. apply Hf0 ; split. by apply Hm ; split ; apply Rlt_le ; apply Hc. by apply HM ; split ; apply Rlt_le ; apply Hc. rewrite -(RInt_ext f0). + apply Hw. by move => x Hx ; apply Hf0. by move => x ; apply Hf0. + move => x Hx. case: (IVT_gen_consistent g a b x cg) => // . by lra. rewrite Rmin_left ?Rmax_right; try lra. move => x0 Hx0. case: Hx0 => Hx0 Hgx0x; rewrite -Hgx0x. apply Hf0; split. by apply Hm. by apply HM. evar_last. + apply (is_RInt_derive (fun x => RInt f (g a) (g x))). move => x Hx. evar_last. apply is_derive_comp. apply is_derive_RInt with (g a). apply filter_forall => y. apply RInt_correct, @ex_RInt_continuous. by intros ; apply Hf. by apply Hf. by apply Hg. reflexivity. intros x Hx. apply: @continuous_scal. by apply Hg. apply continuous_comp. apply @ex_derive_continuous. by eexists ; apply Hg. by apply Hf. + by rewrite RInt_point minus_zero_r. Qed. Lemma RInt_comp (f : R -> V) (g dg : R -> R) (a b : R) : (forall x, Rmin a b <= x <= Rmax a b -> continuous f (g x)) -> (forall x, Rmin a b <= x <= Rmax a b -> is_derive g x (dg x) /\ continuous dg x) -> RInt (fun y => scal (dg y) (f (g y))) a b = RInt f (g a) (g b). Proof. move => Hfg Hg. have H := (is_RInt_comp _ _ _ _ _ Hfg Hg). exact: is_RInt_unique. Qed. End Comp. Lemma RInt_Chasles_bound_comp_l_loc (f : R -> R -> R) (a : R -> R) (b x : R) : locally x (fun y => ex_RInt (f y) (a x) b) -> (exists eps : posreal, locally x (fun y => ex_RInt (f y) (a x - eps) (a x + eps))) -> continuous a x -> locally x (fun x' => RInt (f x') (a x') (a x) + RInt (f x') (a x) b = RInt (f x') (a x') b). Proof. intros Hab (eps,Hae) Ca. generalize (proj1 (filterlim_locally _ _) Ca) => {Ca} Ca. generalize (filter_and _ _ (Ca eps) (filter_and _ _ Hab Hae)). apply filter_imp => {Ca Hae Hab} y [Hy [Hab Hae]]. apply RInt_Chasles with (2 := Hab). apply ex_RInt_inside with (1 := Hae). now apply Rlt_le. rewrite /Rminus Rplus_opp_r Rabs_R0. apply Rlt_le, cond_pos. Qed. Lemma RInt_Chasles_bound_comp_loc (f : R -> R -> R) (a b : R -> R) (x : R) : locally x (fun y => ex_RInt (f y) (a x) (b x)) -> (exists eps : posreal, locally x (fun y => ex_RInt (f y) (a x - eps) (a x + eps))) -> (exists eps : posreal, locally x (fun y => ex_RInt (f y) (b x - eps) (b x + eps))) -> continuous a x -> continuous b x -> locally x (fun x' => RInt (f x') (a x') (a x) + RInt (f x') (a x) (b x') = RInt (f x') (a x') (b x')). Proof. intros Hab (ea,Hae) (eb,Hbe) Ca Cb. generalize (proj1 (filterlim_locally _ _) Ca) => {Ca} Ca. generalize (proj1 (filterlim_locally _ _) Cb) => {Cb} Cb. set (e := mkposreal _ (Rmin_stable_in_posreal ea eb)). generalize (filter_and _ _ (filter_and _ _ (Ca e) (Cb e)) (filter_and _ _ Hab (filter_and _ _ Hae Hbe))). apply filter_imp => {Ca Cb Hab Hae Hbe} y [[Hay Hby] [Hab [Hae Hbe]]]. apply: RInt_Chasles. apply ex_RInt_inside with (1 := Hae). apply Rlt_le. apply Rlt_le_trans with (1 := Hay). exact: Rmin_l. rewrite /Rminus Rplus_opp_r Rabs_R0. apply Rlt_le, cond_pos. apply ex_RInt_Chasles with (1 := Hab). apply ex_RInt_inside with (1 := Hbe). rewrite /Rminus Rplus_opp_r Rabs_R0. apply Rlt_le, cond_pos. apply Rlt_le. apply Rlt_le_trans with (1 := Hby). exact: Rmin_r. Qed. Section RInt_comp. Context {V : NormedModule R_AbsRing}. Lemma is_derive_RInt_bound_comp (f : R -> V) (If : R -> R -> V) (a b : R -> R) (da db x : R) : locally (a x, b x) (fun u : R * R => is_RInt f (fst u) (snd u) (If (fst u) (snd u))) -> continuous f (a x) -> continuous f (b x) -> is_derive a x da -> is_derive b x db -> is_derive (fun x => If (a x) (b x)) x (minus (scal db (f (b x))) (scal da (f (a x)))). Proof. intros Iab Ca Cb Da Db. unfold is_derive. eapply filterdiff_ext_lin. apply @filterdiff_comp'_2. apply Da. apply Db. eapply filterdiff_ext_lin. apply (filterdiff_RInt f If (a x) (b x)). exact Iab. exact Ca. exact Cb. by case => y z /=. simpl => y. by rewrite -!scal_assoc scal_minus_distr_l. Qed. End RInt_comp. (** * Parametric integrals *) Lemma is_derive_RInt_param_aux : forall (f : R -> R -> R) (a b x : R), locally x (fun x : R => forall t, Rmin a b <= t <= Rmax a b -> ex_derive (fun u : R => f u t) x) -> (forall t, Rmin a b <= t <= Rmax a b -> continuity_2d_pt (fun u v => Derive (fun z => f z v) u) x t) -> locally x (fun y : R => ex_RInt (fun t => f y t) a b) -> ex_RInt (fun t => Derive (fun u => f u t) x) a b -> is_derive (fun x : R => RInt (fun t => f x t) a b) x (RInt (fun t => Derive (fun u => f u t) x) a b). Proof. intros f a b x. wlog: a b / a < b => H. (* *) destruct (total_order_T a b) as [[Hab|Hab]|Hab]. now apply H. intros _ _ _ _. rewrite Hab. rewrite RInt_point. apply is_derive_ext with (fun _ => 0). simpl => t. apply sym_eq. apply: RInt_point. apply: is_derive_const. simpl => H1 H2 H3 H4. apply is_derive_ext_loc with (fun u => - RInt (fun t => f u t) b a). apply: filter_imp H3 => t Ht. apply: opp_RInt_swap. exact: ex_RInt_swap. eapply filterdiff_ext_lin. apply @filterdiff_opp_fct ; try by apply locally_filter. apply H. exact Hab. now rewrite Rmin_comm Rmax_comm. now rewrite Rmin_comm Rmax_comm. move: H3 ; apply filter_imp => y H3. now apply ex_RInt_swap. now apply ex_RInt_swap. rewrite -opp_RInt_swap //=. intros y. by rewrite -scal_opp_r opp_opp. (* *) rewrite Rmin_left. 2: now apply Rlt_le. rewrite Rmax_right. 2: now apply Rlt_le. intros Df Cdf If IDf. split => [ | y Hy]. by apply @is_linear_scal_l. rewrite -(is_filter_lim_locally_unique _ _ Hy) => {y Hy}. assert (Cdf'' : forall t : R, a <= t <= b -> continuity_2d_pt (fun u v : R => Derive (fun z : R => f z u) v) t x). intros t Ht eps. specialize (Cdf t Ht eps). simpl in Cdf. destruct Cdf as (d,Cdf). exists d. intros v u Hv Hu. now apply Cdf. assert (Cdf' := uniform_continuity_2d_1d (fun u v => Derive (fun z => f z u) v) a b x Cdf''). intros eps. (* 8.4/8.5 compatibility: *) try clearbody Cdf'. clear Cdf. assert (H': 0 < eps / Rabs (b - a)). apply Rmult_lt_0_compat. apply cond_pos. apply Rinv_0_lt_compat. apply Rabs_pos_lt. apply Rgt_not_eq. now apply Rgt_minus. move: (Cdf' (mkposreal _ H')) => {Cdf'} [d1 Cdf]. generalize (filter_and _ _ Df If). move => {Df If} [d2 DIf]. exists (mkposreal _ (Rmin_stable_in_posreal d1 (pos_div_2 d2))) => /= y Hy. assert (D1: ex_RInt (fun t => f y t) a b). apply DIf. apply Rlt_le_trans with (1 := Hy). apply Rle_trans with (1 := Rmin_r _ _). apply Rlt_le. apply Rlt_eps2_eps. apply cond_pos. assert (D2: ex_RInt (fun t => f x t) a b). apply DIf. apply ball_center. rewrite -RInt_minus // -RInt_scal //. assert (D3: ex_RInt (fun t => f y t - f x t) a b). apply @ex_RInt_minus. by apply D1. by apply D2. assert (D4: ex_RInt (fun t => (y - x) * Derive (fun u => f u t) x) a b) by now apply @ex_RInt_scal. rewrite -RInt_minus //. assert (D5: ex_RInt (fun t => f y t - f x t - (y - x) * Derive (fun u => f u t) x) a b) by now apply @ex_RInt_minus. rewrite (RInt_Reals _ _ _ (ex_RInt_Reals_0 _ _ _ D5)). assert (D6: ex_RInt (fun t => Rabs (f y t - f x t - (y - x) * Derive (fun u => f u t) x)) a b) by now apply ex_RInt_norm. apply Rle_trans with (1 := RiemannInt_P17 _ (ex_RInt_Reals_0 _ _ _ D6) (Rlt_le _ _ H)). refine (Rle_trans _ _ _ (RiemannInt_P19 _ (RiemannInt_P14 a b (eps / Rabs (b - a) * Rabs (y - x))) (Rlt_le _ _ H) _) _). intros u Hu. destruct (MVT_cor4 (fun t => f t u) (Derive (fun t => f t u)) x) with (eps := pos_div_2 d2) (b := y) as (z,Hz). intros z Hz. apply Derive_correct, DIf. apply Rle_lt_trans with (1 := Hz). apply: Rlt_eps2_eps. apply cond_pos. split ; now apply Rlt_le. apply Rlt_le. apply Rlt_le_trans with (1 := Hy). apply Rmin_r. rewrite (proj1 Hz). rewrite Rmult_comm. rewrite -Rmult_minus_distr_l Rabs_mult. rewrite Rmult_comm. apply Rmult_le_compat_r. apply Rabs_pos. apply Rlt_le. apply Cdf. split ; now apply Rlt_le. apply Rabs_le_between'. rewrite /Rminus Rplus_opp_r Rabs_R0. apply Rlt_le. apply cond_pos. split ; now apply Rlt_le. apply Rabs_le_between'. apply Rle_trans with (1 := proj2 Hz). apply Rlt_le. apply Rlt_le_trans with (1 := Hy). apply Rmin_l. rewrite /Rminus Rplus_opp_r Rabs_R0. apply cond_pos. rewrite RiemannInt_P15. rewrite Rabs_pos_eq. right. change (norm (minus y x)) with (Rabs (y - x)). field. apply Rgt_not_eq. now apply Rgt_minus. apply Rge_le. apply Rge_minus. now apply Rgt_ge. Qed. Lemma is_derive_RInt_param : forall f a b x, locally x (fun x => forall t, Rmin a b <= t <= Rmax a b -> ex_derive (fun u => f u t) x) -> (forall t, Rmin a b <= t <= Rmax a b -> continuity_2d_pt (fun u v => Derive (fun z => f z v) u) x t) -> locally x (fun y => ex_RInt (fun t => f y t) a b) -> is_derive (fun x => RInt (fun t => f x t) a b) x (RInt (fun t => Derive (fun u => f u t) x) a b). Proof. intros f a b x H1 H2 H3. apply is_derive_RInt_param_aux; try easy. apply ex_RInt_Reals_1. clear H1 H3. wlog: a b H2 / a < b => H. case (total_order_T a b). intro Y; case Y. now apply H. intros Heq; rewrite Heq. apply RiemannInt_P7. intros Y. apply RiemannInt_P1. apply H. intros; apply H2. rewrite Rmin_comm Rmax_comm. exact H0. exact Y. rewrite Rmin_left in H2. 2: now left. rewrite Rmax_right in H2. 2: now left. apply continuity_implies_RiemannInt. now left. intros y Hy eps Heps. destruct (H2 _ Hy (mkposreal eps Heps)) as (d,Hd). simpl in Hd. exists d; split. apply cond_pos. unfold dist; simpl; unfold R_dist; simpl. intros z (_,Hz). apply Hd. rewrite /Rminus Rplus_opp_r Rabs_R0. apply cond_pos. exact Hz. Qed. Lemma is_derive_RInt_param_bound_comp_aux1 : forall (f : R -> R -> R) (a : R -> R) (x : R), (exists eps:posreal, locally x (fun y : R => ex_RInt (fun t => f y t) (a x - eps) (a x + eps))) -> (exists eps:posreal, locally x (fun x0 : R => forall t : R, a x-eps <= t <= a x+eps -> ex_derive (fun u : R => f u t) x0)) -> (locally_2d (fun x' t => continuity_2d_pt (fun u v : R => Derive (fun z : R => f z v) u) x' t) x (a x)) -> continuity_2d_pt (fun u v : R => Derive (fun z : R => RInt (fun t : R => f z t) v (a x)) u) x (a x). Proof. intros f a x (d1,(d2,Ia)) (d3,(d4,Df)) Cdf e. assert (J1:(continuity_2d_pt (fun u v : R => Derive (fun z : R => f z v) u) x (a x))) by now apply locally_2d_singleton in Cdf. destruct Cdf as (d5,Cdf). destruct (J1 (mkposreal _ Rlt_0_1)) as (d6,Df1); simpl in Df1. assert (J2: 0 < e / (Rabs (Derive (fun z : R => f z (a x)) x)+1)). apply Rdiv_lt_0_compat. apply cond_pos. apply Rlt_le_trans with (0+1). rewrite Rplus_0_l; apply Rlt_0_1. apply Rplus_le_compat_r; apply Rabs_pos. exists (mkposreal _ (Rmin_stable_in_posreal (mkposreal _ (Rmin_stable_in_posreal d1 (mkposreal _ (Rmin_stable_in_posreal (pos_div_2 d2) d3)))) (mkposreal _ (Rmin_stable_in_posreal (mkposreal _ (Rmin_stable_in_posreal (pos_div_2 d4) d5)) (mkposreal _ (Rmin_stable_in_posreal d6 (mkposreal _ J2))))))). simpl; intros u v Hu Hv. rewrite (Derive_ext (fun z : R => RInt (fun t : R => f z t) (a x) (a x)) (fun z => 0)). 2: intros t; exact: RInt_point. replace (Derive (fun _ : R => 0) x) with 0%R. 2: apply sym_eq, Derive_const. rewrite Rminus_0_r. replace (Derive (fun z : R => RInt (fun t : R => f z t) v (a x)) u) with (RInt (fun z => Derive (fun u => f u z) u) v (a x)). (* *) apply Rle_lt_trans with (Rabs (a x -v) * (Rabs (Derive (fun z : R => f z (a x)) x) +1)). apply (norm_RInt_le_const_abs (fun z : R => Derive (fun u0 : R => f u0 z) u) v (a x)). intros t Ht. apply Rplus_le_reg_r with (-Rabs (Derive (fun z : R => f z (a x)) x)). apply Rle_trans with (1:=Rabs_triang_inv _ _). ring_simplify. left; apply Df1. apply Rlt_le_trans with (1:=Hu). apply Rle_trans with (1:=Rmin_r _ _). apply Rle_trans with (1:=Rmin_r _ _). apply Rmin_l. apply Rle_lt_trans with (Rabs (v - a x)). now apply Rabs_le_between_min_max. apply Rlt_le_trans with (1:=Hv). apply Rle_trans with (1:=Rmin_r _ _). apply Rle_trans with (1:=Rmin_r _ _). apply Rmin_l. apply: RInt_correct. apply: ex_RInt_continuous. intros y Hy ; apply continuity_pt_filterlim. intros eps Heps. assert (Y1:(Rabs (u - x) < d5)). apply Rlt_le_trans with (1:=Hu). apply Rle_trans with (1:=Rmin_r _ _). apply Rle_trans with (1:=Rmin_l _ _). apply Rmin_r. assert (Y2:(Rabs (y - a x) < d5)). apply Rle_lt_trans with (Rabs (v-a x)). now apply Rabs_le_between_min_max. apply Rlt_le_trans with (1:=Hv). apply Rle_trans with (1:=Rmin_r _ _). apply Rle_trans with (1:=Rmin_l _ _). apply Rmin_r. destruct (Cdf u y Y1 Y2 (mkposreal eps Heps)) as (d,Hd); simpl in Hd. exists d; split. apply cond_pos. unfold dist; simpl; unfold R_dist. intros z (_,Hz). apply Hd. rewrite /Rminus Rplus_opp_r Rabs_R0. apply cond_pos. exact Hz. replace (a x -v) with (-(v - a x)) by ring; rewrite Rabs_Ropp. apply Rlt_le_trans with ((e / (Rabs (Derive (fun z : R => f z (a x)) x) + 1)) * (Rabs (Derive (fun z : R => f z (a x)) x) + 1)). apply Rmult_lt_compat_r. apply Rlt_le_trans with (0+1). rewrite Rplus_0_l; apply Rlt_0_1. apply Rplus_le_compat_r; apply Rabs_pos. apply Rlt_le_trans with (1:=Hv). apply Rle_trans with (1:=Rmin_r _ _). apply Rle_trans with (1:=Rmin_r _ _). apply Rmin_r. right; field. apply sym_not_eq, Rlt_not_eq. apply Rlt_le_trans with (0+1). rewrite Rplus_0_l; apply Rlt_0_1. apply Rplus_le_compat_r; apply Rabs_pos. (* *) apply sym_eq, is_derive_unique. apply is_derive_RInt_param. exists (pos_div_2 d4). intros y Hy t Ht. apply Df. rewrite (double_var d4). apply ball_triangle with u. apply Rlt_le_trans with (1:=Hu). apply Rle_trans with (1:=Rmin_r _ _). apply Rle_trans with (1:=Rmin_l _ _). apply Rmin_l. by apply Hy. apply (proj1 (Rabs_le_between' t (a x) d3)). apply Rle_trans with (Rabs (v - a x)). now apply Rabs_le_between_min_max. left; apply Rlt_le_trans with (1:=Hv). apply Rle_trans with (1:=Rmin_l _ _). apply Rle_trans with (1:=Rmin_r _ _). apply Rmin_r. intros t Ht. apply Cdf. apply Rlt_le_trans with (1:=Hu). apply Rle_trans with (1:=Rmin_r _ _). apply Rle_trans with (1:=Rmin_l _ _). apply Rmin_r. apply Rle_lt_trans with (Rabs (v - a x)). now apply Rabs_le_between_min_max. apply Rlt_le_trans with (1:=Hv). apply Rle_trans with (1:=Rmin_r _ _). apply Rle_trans with (1:=Rmin_l _ _). apply Rmin_r. exists (pos_div_2 d2). intros y Hy. apply (ex_RInt_inside (f y)) with (a x) d1. apply Ia. rewrite (double_var d2). apply ball_triangle with u. apply Rlt_le_trans with (1:=Hu). apply Rle_trans with (1:=Rmin_l _ _). apply Rle_trans with (1:=Rmin_r _ _). apply Rmin_l. apply Hy. left; apply Rlt_le_trans with (1:=Hv). apply Rle_trans with (1:=Rmin_l _ _). apply Rmin_l. rewrite /Rminus Rplus_opp_r Rabs_R0. left; apply cond_pos. Qed. Lemma is_derive_RInt_param_bound_comp_aux2 : forall (f : R -> R -> R) (a : R -> R) (b x da : R), (locally x (fun y : R => ex_RInt (fun t => f y t) (a x) b)) -> (exists eps:posreal, locally x (fun y : R => ex_RInt (fun t => f y t) (a x - eps) (a x + eps))) -> is_derive a x da -> (exists eps:posreal, locally x (fun x0 : R => forall t : R, Rmin (a x-eps) b <= t <= Rmax (a x+eps) b -> ex_derive (fun u : R => f u t) x0)) -> (forall t : R, Rmin (a x) b <= t <= Rmax (a x) b -> continuity_2d_pt (fun u v : R => Derive (fun z : R => f z v) u) x t) -> (locally_2d (fun x' t => continuity_2d_pt (fun u v : R => Derive (fun z : R => f z v) u) x' t) x (a x)) -> continuity_pt (fun t => f x t) (a x) -> is_derive (fun x : R => RInt (fun t => f x t) (a x) b) x (RInt (fun t : R => Derive (fun u => f u t) x) (a x) b+(-f x (a x))*da). Proof. intros f a b x da Hi [d0 Ia] Da [d1 Df] Cdf1 Cdf2 Cfa. rewrite Rplus_comm. apply is_derive_ext_loc with (fun x0 => plus (RInt (fun t : R => f x0 t) (a x0) (a x)) (RInt (fun t : R => f x0 t) (a x) b)). apply RInt_Chasles_bound_comp_l_loc. exact Hi. now exists d0. apply: filterdiff_continuous. eexists. apply Da. apply: is_derive_plus. (* *) eapply filterdiff_ext_lin. apply @filterdiff_comp'_2 with (h := fun x0 y => RInt (fun t : R => f x0 t) y (a x)). apply filterdiff_id. apply Da. eapply filterdiff_ext_lin. apply (is_derive_filterdiff (fun u v => RInt (fun t0 : R => f u t0) v (a x)) x (a x) (fun u v => Derive (fun z => RInt (fun t => f z t) v (a x)) u)). (* . *) destruct Df as (d2,Df). destruct Cdf2 as (d3,Cdf2). destruct Ia as (d4,Ia). exists (mkposreal _ (Rmin_stable_in_posreal (mkposreal _ (Rmin_stable_in_posreal d1 (pos_div_2 d2))) (mkposreal _ (Rmin_stable_in_posreal d3 (mkposreal _ (Rmin_stable_in_posreal d0 (pos_div_2 d4))))))). intros [u v] [Hu Hv] ; simpl in *. apply: Derive_correct. eexists ; apply is_derive_RInt_param. exists (pos_div_2 d2). intros y Hy t Ht. apply Df. rewrite (double_var d2). apply: ball_triangle Hy. apply Rlt_le_trans with (1:=Hu). apply Rle_trans with (1:=Rmin_l _ _). apply Rmin_r. split. apply Rle_trans with (2:=proj1 Ht). apply Rle_trans with (1 := Rmin_l _ _). apply Rmin_glb. apply Rabs_le_between'. left; apply Rlt_le_trans with (1:=Hv). apply Rle_trans with (1:=Rmin_l _ _). apply Rmin_l. apply Rplus_le_reg_l with (- a x + d1); ring_simplify. left; apply cond_pos. apply Rle_trans with (1:=proj2 Ht). apply Rle_trans with (a x + d1). apply Rmax_lub. apply Rabs_le_between'. left; apply Rlt_le_trans with (1:=Hv). apply Rle_trans with (1:=Rmin_l _ _). apply Rmin_l. apply Rplus_le_reg_l with (- a x); ring_simplify. left; apply cond_pos. apply Rmax_l. intros t Ht. apply Cdf2. apply Rlt_le_trans with (1:=Hu). apply Rle_trans with (1:=Rmin_r _ _). apply Rmin_l. apply Rle_lt_trans with (Rabs (v - a x)). now apply Rabs_le_between_min_max. apply Rlt_le_trans with (1:=Hv). apply Rle_trans with (1:=Rmin_r _ _). apply Rmin_l. exists (pos_div_2 d4). intros y Hy. apply (ex_RInt_inside (f y)) with (a x) d0. apply Ia. rewrite (double_var d4). apply: ball_triangle Hy. apply Rlt_le_trans with (1:=Hu). apply Rle_trans with (1:=Rmin_r _ _). apply Rle_trans with (1:=Rmin_r _ _). apply Rmin_r. left; apply Rlt_le_trans with (1:=Hv). apply Rle_trans with (1:=Rmin_r _ _). apply Rle_trans with (1:=Rmin_r _ _). apply Rmin_l. rewrite /Rminus Rplus_opp_r Rabs_R0. left; apply cond_pos. (* . *) apply is_derive_RInt' with (a x). apply locally_singleton in Ia. exists d0 => /= y Hy. apply: RInt_correct. generalize (proj1 (Rabs_lt_between' _ _ _) Hy) => {Hy} Hy. eapply ex_RInt_Chasles. eapply ex_RInt_Chasles, Ia. apply ex_RInt_swap. eapply @ex_RInt_Chasles_1, Ia. split ; apply Rlt_le, Hy. apply ex_RInt_swap. eapply @ex_RInt_Chasles_2, Ia. apply Rabs_le_between'. rewrite /Rminus Rplus_opp_r Rabs_R0. left; apply cond_pos. by apply continuity_pt_filterlim, Cfa. (* . *) apply (continuity_2d_pt_filterlim (fun u v => Derive (fun z : R => RInt (fun t0 : R => f z t0) v (a x)) u)). simpl. apply is_derive_RInt_param_bound_comp_aux1; try easy. exists d0; exact Ia. exists d1. move: Df ; apply filter_imp. intros y H t Ht. apply H. split. apply Rle_trans with (2:=proj1 Ht). apply Rmin_l. apply Rle_trans with (1:=proj2 Ht). apply Rmax_l. case => /= u v. erewrite Derive_ext. 2: intros ; by rewrite RInt_point. by rewrite Derive_const scal_zero_r plus_zero_l. move => /= y ; apply Rminus_diag_uniq. rewrite /plus /scal /opp /= /mult /=. ring. (* *) apply is_derive_RInt_param with (2 := Cdf1) (3 := Hi). move: Df ; apply filter_imp. intros y Hy t Ht; apply Hy. split. apply Rle_trans with (2:=proj1 Ht). apply Rle_min_compat_r. apply Rplus_le_reg_l with (-a x+d1); ring_simplify. left; apply cond_pos. apply Rle_trans with (1:=proj2 Ht). apply Rle_max_compat_r. apply Rplus_le_reg_l with (-a x); ring_simplify. left; apply cond_pos. Qed. Lemma is_derive_RInt_param_bound_comp_aux3 : forall (f : R -> R -> R) a (b : R -> R) (x db : R), (locally x (fun y : R => ex_RInt (fun t => f y t) a (b x))) -> (exists eps:posreal, locally x (fun y : R => ex_RInt (fun t => f y t) (b x - eps) (b x + eps))) -> is_derive b x db -> (exists eps:posreal, locally x (fun x0 : R => forall t : R, Rmin a (b x-eps) <= t <= Rmax a (b x+eps) -> ex_derive (fun u : R => f u t) x0)) -> (forall t : R, Rmin a (b x) <= t <= Rmax a (b x) -> continuity_2d_pt (fun u v : R => Derive (fun z : R => f z v) u) x t) -> (locally_2d (fun x' t => continuity_2d_pt (fun u v : R => Derive (fun z : R => f z v) u) x' t) x (b x)) -> continuity_pt (fun t => f x t) (b x) -> is_derive (fun x : R => RInt (fun t => f x t) a (b x)) x (RInt (fun t : R => Derive (fun u => f u t) x) a (b x) +f x (b x)*db). Proof. intros f a b x db If Ib Db Df Cf1 Cf2 Cfb. apply is_derive_ext_loc with (fun x0 => - RInt (fun t : R => f x0 t) (b x0) a). destruct Ib as [eps Ib]. cut (locally x (fun t : R => ex_RInt (fun u => f t u) a (b t))). apply: filter_imp. intros y H. apply: opp_RInt_swap. exact: ex_RInt_swap. assert (locally x (fun t : R => Rabs (b t - b x) <= eps)). generalize (ex_derive_continuous b _ (ex_intro _ _ Db)). move /filterlim_locally /(_ eps). apply: filter_imp => t. exact: Rlt_le. generalize (filter_and _ _ If (filter_and _ _ Ib H)). apply: filter_imp => t [Ht1 [Ht2 Ht3]]. apply ex_RInt_Chasles with (1 := Ht1). apply: ex_RInt_inside Ht2 _ Ht3. rewrite Rminus_eq_0 Rabs_R0. apply Rlt_le, cond_pos. evar_last. apply: is_derive_opp. apply: is_derive_RInt_param_bound_comp_aux2 Ib Db _ _ Cf2 Cfb. apply: filter_imp If => y H. now apply ex_RInt_swap. destruct Df as (e,H). exists e. move: H ; apply filter_imp. intros y H' t Ht. apply H'. now rewrite Rmin_comm Rmax_comm. intros t Ht. apply Cf1. now rewrite Rmin_comm Rmax_comm. rewrite -(opp_RInt_swap _ _ a). rewrite /opp /=. ring. apply ex_RInt_swap. apply ex_RInt_continuous. intros z Hz. specialize (Cf1 z Hz). apply continuity_2d_pt_filterlim in Cf1. intros c Hc. destruct (Cf1 c Hc) as [e He]. exists e. intros d Hd. apply (He (x,d)). split. apply ball_center. apply Hd. Qed. Lemma is_derive_RInt_param_bound_comp : forall (f : R -> R -> R) (a b : R -> R) (x da db : R), (locally x (fun y : R => ex_RInt (fun t => f y t) (a x) (b x))) -> (exists eps:posreal, locally x (fun y : R => ex_RInt (fun t => f y t) (a x - eps) (a x + eps))) -> (exists eps:posreal, locally x (fun y : R => ex_RInt (fun t => f y t) (b x - eps) (b x + eps))) -> is_derive a x da -> is_derive b x db -> (exists eps:posreal, locally x (fun x0 : R => forall t : R, Rmin (a x-eps) (b x -eps) <= t <= Rmax (a x+eps) (b x+eps) -> ex_derive (fun u : R => f u t) x0)) -> (forall t : R, Rmin (a x) (b x) <= t <= Rmax (a x) (b x) -> continuity_2d_pt (fun u v : R => Derive (fun z : R => f z v) u) x t) -> (locally_2d (fun x' t => continuity_2d_pt (fun u v : R => Derive (fun z : R => f z v) u) x' t) x (a x)) -> (locally_2d (fun x' t => continuity_2d_pt (fun u v : R => Derive (fun z : R => f z v) u) x' t) x (b x)) -> continuity_pt (fun t => f x t) (a x) -> continuity_pt (fun t => f x t) (b x) -> is_derive (fun x : R => RInt (fun t => f x t) (a x) (b x)) x (RInt (fun t : R => Derive (fun u => f u t) x) (a x) (b x)+(-f x (a x))*da+(f x (b x))*db). Proof. intros f a b x da db If Ifa Ifb Da Db Df Cf Cfa Cfb Ca Cb. apply is_derive_ext_loc with (fun x0 : R => RInt (fun t : R => f x0 t) (a x0) (a x) + RInt (fun t : R => f x0 t) (a x) (b x0)). apply RInt_Chasles_bound_comp_loc ; trivial. apply @filterdiff_continuous. eexists. apply Da. apply @filterdiff_continuous. eexists. apply Db. eapply filterdiff_ext_lin. apply @filterdiff_plus_fct. by apply locally_filter. (* *) apply is_derive_RInt_param_bound_comp_aux2; try easy. exists (mkposreal _ Rlt_0_1). intros y Hy. apply ex_RInt_point. by apply Da. destruct Df as (e,H). exists e. move: H ; apply filter_imp. intros y H' t Ht. apply H'. split. apply Rle_trans with (2:=proj1 Ht). apply Rle_trans with (1:=Rmin_l _ _). right; apply sym_eq, Rmin_left. apply Rplus_le_reg_l with (-a x + e); ring_simplify. left; apply cond_pos. apply Rle_trans with (1:=proj2 Ht). apply Rle_trans with (2:=Rmax_l _ _). right; apply Rmax_left. apply Rplus_le_reg_l with (-a x); ring_simplify. left; apply cond_pos. intros t Ht. apply Cf. split. apply Rle_trans with (2:=proj1 Ht). apply Rle_trans with (1:=Rmin_l _ _). right; apply sym_eq, Rmin_left. now right. apply Rle_trans with (1:=proj2 Ht). apply Rle_trans with (2:=Rmax_l _ _). right; apply Rmax_left. now right. (* *) apply is_derive_RInt_param_bound_comp_aux3; try easy. by apply Db. destruct Df as (e,H). exists e. move: H ; apply filter_imp. intros y H' t Ht. apply H'. split. apply Rle_trans with (2:=proj1 Ht). apply Rle_min_compat_r. apply Rplus_le_reg_l with (-a x + e); ring_simplify. left; apply cond_pos. apply Rle_trans with (1:=proj2 Ht). apply Rle_max_compat_r. apply Rplus_le_reg_l with (-a x); ring_simplify. left; apply cond_pos. rewrite RInt_point. simpl => y. rewrite /plus /scal /zero /= /mult /=. ring. Qed. (** * Power series *) Definition PS_Int (a : nat -> R) (n : nat) : R := match n with | O => 0 | S n => a n / INR (S n) end. Lemma CV_radius_Int (a : nat -> R) : CV_radius (PS_Int a) = CV_radius a. Proof. rewrite -CV_radius_derive. apply CV_radius_ext. rewrite /PS_derive /PS_Int => n ; rewrite S_INR. field. apply Rgt_not_eq, INRp1_pos. Qed. Lemma is_RInt_PSeries (a : nat -> R) (x : R) : Rbar_lt (Rabs x) (CV_radius a) -> is_RInt (PSeries a) 0 x (PSeries (PS_Int a) x). Proof. move => Hx. have H : forall y, Rmin 0 x <= y <= Rmax 0 x -> Rbar_lt (Rabs y) (CV_radius a). move => y Hy. apply: Rbar_le_lt_trans Hx. apply Rabs_le_between. split. apply Rle_trans with (2 := proj1 Hy). rewrite /Rabs /Rmin. case: Rcase_abs ; case: Rle_dec => // Hx Hx' ; rewrite ?Ropp_involutive. by apply Rlt_le. by apply Req_le. apply Ropp_le_cancel ; by rewrite Ropp_involutive Ropp_0. by apply Rge_le in Hx'. apply Rle_trans with (1 := proj2 Hy). rewrite /Rabs /Rmax. case: Rcase_abs ; case: Rle_dec => // Hx Hx'. by apply Rlt_not_le in Hx'. apply Ropp_le_cancel, Rlt_le ; by rewrite Ropp_involutive Ropp_0. by apply Req_le. by apply Rge_le in Hx'. apply is_RInt_ext with (Derive (PSeries (PS_Int a))). move => y Hy. rewrite Derive_PSeries. apply PSeries_ext ; rewrite /PS_derive /PS_Int => n ; rewrite S_INR. field. apply Rgt_not_eq, INRp1_pos. rewrite CV_radius_Int. by apply H ; split ; apply Rlt_le ; apply Hy. evar_last. apply: is_RInt_derive. move => y Hy. apply Derive_correct, ex_derive_PSeries. rewrite CV_radius_Int. by apply H. move => y Hy. apply continuous_ext_loc with (PSeries a). apply locally_interval with (Rbar_opp (CV_radius a)) (CV_radius a). apply Rbar_opp_lt ; rewrite Rbar_opp_involutive. apply: Rbar_le_lt_trans (H _ Hy). apply Rabs_maj2. apply: Rbar_le_lt_trans (H _ Hy). apply Rle_abs. move => z Hz Hz'. rewrite Derive_PSeries. apply PSeries_ext ; rewrite /PS_derive /PS_Int => n ; rewrite S_INR. field. apply Rgt_not_eq, INRp1_pos. rewrite CV_radius_Int. apply (Rbar_abs_lt_between z) ; by split. apply continuity_pt_filterlim, PSeries_continuity. by apply H. rewrite PSeries_0 /(PS_Int _ 0) ; by rewrite minus_zero_r. Qed. Lemma ex_RInt_PSeries (a : nat -> R) (x : R) : Rbar_lt (Rabs x) (CV_radius a) -> ex_RInt (PSeries a) 0 x. Proof. move => Hx. exists (PSeries (PS_Int a) x). by apply is_RInt_PSeries. Qed. Lemma RInt_PSeries (a : nat -> R) (x : R) : Rbar_lt (Rabs x) (CV_radius a) -> RInt (PSeries a) 0 x = PSeries (PS_Int a) x. Proof. move => Hx. apply is_RInt_unique. by apply is_RInt_PSeries. Qed. Lemma is_pseries_RInt (a : nat -> R) : forall x, Rbar_lt (Rabs x) (CV_radius a) -> is_pseries (PS_Int a) x (RInt (PSeries a) 0 x). Proof. move => x Hx. erewrite is_RInt_unique. apply PSeries_correct. apply CV_radius_inside. by rewrite CV_radius_Int. exact: is_RInt_PSeries. Qed. (** * Integration by parts *) Section ByParts. Context {V : CompleteNormedModule R_AbsRing}. Lemma is_RInt_scal_derive : forall (f : R -> R) (g : R -> V) (f' : R -> R) (g' : R -> V) (a b : R), (forall t, Rmin a b <= t <= Rmax a b -> is_derive f t (f' t)) -> (forall t, Rmin a b <= t <= Rmax a b -> is_derive g t (g' t)) -> (forall t, Rmin a b <= t <= Rmax a b -> continuous f' t) -> (forall t, Rmin a b <= t <= Rmax a b -> continuous g' t) -> is_RInt (fun t => plus (scal (f' t) (g t)) (scal (f t) (g' t))) a b (minus (scal (f b) (g b)) (scal (f a) (g a))). Proof. intros f g f' g' a b Df Dg Cf' Cg' If'g. apply (is_RInt_derive (fun t => scal (f t) (g t))). intros t Ht. refine (_ (filterdiff_scal_fct t f g _ _ _ (Df _ Ht) (Dg _ Ht))). intros H. apply: filterdiff_ext_lin H _ => u. by rewrite scal_distr_l !scal_assoc /mult /= Rmult_comm. exact Rmult_comm. intros t Ht. apply: continuous_plus. apply: continuous_scal. now apply Cf'. apply ex_derive_continuous. eexists. now apply Dg. apply: continuous_scal. apply: ex_derive_continuous. eexists. now apply Df. now apply Cg'. Qed. Lemma is_RInt_scal_derive_r : forall (f : R -> R) (g : R -> V) (f' : R -> R) (g' : R -> V) (a b : R) (l : V), (forall t, Rmin a b <= t <= Rmax a b -> is_derive f t (f' t)) -> (forall t, Rmin a b <= t <= Rmax a b -> is_derive g t (g' t)) -> (forall t, Rmin a b <= t <= Rmax a b -> continuous f' t) -> (forall t, Rmin a b <= t <= Rmax a b -> continuous g' t) -> is_RInt (fun t => scal (f' t) (g t)) a b l -> is_RInt (fun t => scal (f t) (g' t)) a b (minus (minus (scal (f b) (g b)) (scal (f a) (g a))) l). Proof. intros f g f' g' a b l Df Dg Cf' Cg' If'g. apply (is_RInt_ext (fun t => minus (plus (scal (f' t) (g t)) (scal (f t) (g' t))) (scal (f' t) (g t)))). intros x H. by rewrite /minus (plus_comm (scal (f' x) _)) -plus_assoc plus_opp_r plus_zero_r. apply is_RInt_minus with (2 := If'g). exact: is_RInt_scal_derive. Qed. Lemma is_RInt_scal_derive_l : forall (f : R -> R) (g : R -> V) (f' : R -> R) (g' : R -> V) (a b : R) (l : V), (forall t, Rmin a b <= t <= Rmax a b -> is_derive f t (f' t)) -> (forall t, Rmin a b <= t <= Rmax a b -> is_derive g t (g' t)) -> (forall t, Rmin a b <= t <= Rmax a b -> continuous f' t) -> (forall t, Rmin a b <= t <= Rmax a b -> continuous g' t) -> is_RInt (fun t => scal (f t) (g' t)) a b l -> is_RInt (fun t => scal (f' t) (g t)) a b (minus (minus (scal (f b) (g b)) (scal (f a) (g a))) l). Proof. intros f g f' g' a b l Df Dg Cf' Cg' If'g. apply (is_RInt_ext (fun t => minus (plus (scal (f' t) (g t)) (scal (f t) (g' t))) (scal (f t) (g' t)))). intros x H. by rewrite /minus -plus_assoc plus_opp_r plus_zero_r. apply is_RInt_minus with (2 := If'g). exact: is_RInt_scal_derive. Qed. End ByParts.
------------------------------------------------------------------------ -- Streams ------------------------------------------------------------------------ module Data.Stream where open import Coinduction open import Data.Colist using (Colist; []; _∷_) open import Data.Vec using (Vec; []; _∷_) open import Data.Nat using (ℕ; zero; suc) open import Relation.Binary ------------------------------------------------------------------------ -- The type infixr 5 _∷_ data Stream (A : Set) : Set where _∷_ : (x : A) (xs : ∞ (Stream A)) → Stream A ------------------------------------------------------------------------ -- Some operations head : forall {A} -> Stream A -> A head (x ∷ xs) = x tail : forall {A} -> Stream A -> Stream A tail (x ∷ xs) = ♭ xs map : ∀ {A B} → (A → B) → Stream A → Stream B map f (x ∷ xs) = f x ∷ ♯ map f (♭ xs) zipWith : forall {A B C} -> (A -> B -> C) -> Stream A -> Stream B -> Stream C zipWith _∙_ (x ∷ xs) (y ∷ ys) = (x ∙ y) ∷ ♯ zipWith _∙_ (♭ xs) (♭ ys) take : ∀ {A} (n : ℕ) → Stream A → Vec A n take zero xs = [] take (suc n) (x ∷ xs) = x ∷ take n (♭ xs) drop : ∀ {A} -> ℕ -> Stream A -> Stream A drop zero xs = xs drop (suc n) (x ∷ xs) = drop n (♭ xs) repeat : forall {A} -> A -> Stream A repeat x = x ∷ ♯ repeat x iterate : ∀ {A} → (A → A) → A → Stream A iterate f x = x ∷ ♯ iterate f (f x) -- Interleaves the two streams. infixr 5 _⋎_ _⋎_ : ∀ {A} → Stream A → Stream A → Stream A (x ∷ xs) ⋎ ys = x ∷ ♯ (ys ⋎ ♭ xs) toColist : ∀ {A} → Stream A → Colist A toColist (x ∷ xs) = x ∷ ♯ toColist (♭ xs) lookup : ∀ {A} → ℕ → Stream A → A lookup zero (x ∷ xs) = x lookup (suc n) (x ∷ xs) = lookup n (♭ xs) infixr 5 _++_ _++_ : ∀ {A} → Colist A → Stream A → Stream A [] ++ ys = ys (x ∷ xs) ++ ys = x ∷ ♯ (♭ xs ++ ys) ------------------------------------------------------------------------ -- Equality and other relations -- xs ≈ ys means that xs and ys are equal. infix 4 _≈_ data _≈_ {A} : (xs ys : Stream A) → Set where _∷_ : ∀ x {xs ys} (xs≈ : ∞ (♭ xs ≈ ♭ ys)) → x ∷ xs ≈ x ∷ ys -- x ∈ xs means that x is a member of xs. infix 4 _∈_ data _∈_ {A : Set} : A → Stream A → Set where here : ∀ {x xs} → x ∈ x ∷ xs there : ∀ {x y xs} (x∈xs : x ∈ ♭ xs) → x ∈ y ∷ xs -- xs ⊑ ys means that xs is a prefix of ys. infix 4 _⊑_ data _⊑_ {A : Set} : Colist A → Stream A → Set where [] : ∀ {ys} → [] ⊑ ys _∷_ : ∀ x {xs ys} (p : ∞ (♭ xs ⊑ ♭ ys)) → x ∷ xs ⊑ x ∷ ys ------------------------------------------------------------------------ -- Some proofs setoid : Set → Setoid setoid A = record { carrier = Stream A ; _≈_ = _≈_ {A} ; isEquivalence = record { refl = refl ; sym = sym ; trans = trans } } where refl : Reflexive _≈_ refl {x ∷ xs} = x ∷ ♯ refl sym : Symmetric _≈_ sym (x ∷ xs≈) = x ∷ ♯ sym (♭ xs≈) trans : Transitive _≈_ trans (x ∷ xs≈) (.x ∷ ys≈) = x ∷ ♯ trans (♭ xs≈) (♭ ys≈) map-cong : ∀ {A B} (f : A → B) {xs ys : Stream A} → xs ≈ ys → map f xs ≈ map f ys map-cong f (x ∷ xs≈) = f x ∷ ♯ map-cong f (♭ xs≈)
Require Import XR_Rle. Require Import XR_Rabs. Require Import XR_Rabs_left. Require Import XR_Rabs_R0. Require Import XR_Ropp_0. Local Open Scope R_scope. Lemma Rabs_left1 : forall a:R, a <= R0 -> Rabs a = - a. Proof. intros x h. destruct h as [ h | h ]. { apply Rabs_left. exact h. } { subst x. rewrite Rabs_R0. rewrite Ropp_0. reflexivity. } Qed.
Best New Year Deals on WordPress Hosting Till 31st December: We are past Black Friday and Cyber Monday however there are some amazing deals on Web Hosting which are valid till 31st December! We are bringing together these deals for all our readers. 1&1 is a German Web Hosting company that specializes in budget plans for web hosting. 1&1 is offering up to 80% Discount + 1 Free Domain on their Unlimited Plan. iPage offers low-cost web hosting, with plenty of features from its Boston-based data centers. iPage is offering similar up to 80% Discount + 1 Free Domain on their Essential Plan. FatCow, founded in 1998, is one of my top rated hosting companies. FatCow is offering up to 60% Discount + 1 Free Domain on their WP Starter Plan. Bluehost is a popular choice among bloggers for low-cost shared hosting. Thanks to their cpanel interface, it is one of the most newbie friendly hosting provider. Bluehost is offering up to 60% Discount + 1 Free Domain on their Basic Plan. The purpose of this article was to bring the best deals which are available on WordPress hosting for starting a new blog. If you decide to go ahead with Bluehost, then you could refer to our earlier article How to Sign up with Bluehost. I would also recommend you to read our step-by-step guide on How to Start a Free Blog in 6 Easy Steps. Through this guide, you would be able to get your new blog up and running in less than 60 minutes. Celebrations begin with such nice offers and deals. Who Provides the Best WordPress Hosting Service?
[STATEMENT] lemma plan_action_path_Cons[simp]: "plan_action_path M (\<pi>#\<pi>s) M' \<longleftrightarrow> plan_action_enabled \<pi> M \<and> plan_action_path (execute_plan_action \<pi> M) \<pi>s M'" [PROOF STATE] proof (prove) goal (1 subgoal): 1. plan_action_path M (\<pi> # \<pi>s) M' = (plan_action_enabled \<pi> M \<and> plan_action_path (execute_plan_action \<pi> M) \<pi>s M') [PROOF STEP] by (auto simp: plan_action_path_def execute_plan_action_def execute_ground_action_def plan_action_enabled_def)
```python import numpy as np import sympy sympy.init_printing(use_unicode=True) from sympy import * from sympy.solvers import solve from IPython.display import display def simplified(exp): simp = simplify(exp) display(simp) return simp def firstOrderCondition(exp, var, iSelectedSolution=None): diffExp = simplify(diff(exp, var)) display(diffExp) solutions = solve(diffExp, var) display(solutions) if iSelectedSolution is not None: solution = solutions[iSelectedSolution] optimum = exp.subs(var, solution) return simplified(optimum) else: return solutions x = symbols('x') w,A,B = symbols('w A B', Integer=True, Positive=True) n,p,q,d = symbols('n p q d', positive=True) ``` ### Optimal Channel Initialization ```python Xn = simplified(n/(2*p-1) - w/(2*p-1)*(1-(p/(1-p))**n)/(1-(p/(1-p))**w) ) ``` ```python firstOrderCondition(Xn,n) ``` ```python Xn = simplified(n*(1-q**(-w/B)) - w*(1-q**(-n/B))) firstOrderCondition(Xn,n) ``` ```python nopt.subs(B,1) ``` ```python nopt.subs(q,1/2) ``` ```python sympy.simplify(Xn.subs(n,nopt)) ``` ```python cp = (A * x**(A+1) - (A+1)*x**A + 1)/(x-1) cp ``` ```python sympy.simplify(cp.subs(A, 3)) ```
[STATEMENT] lemma unit_ball_vol_pos [simp]: "n \<ge> 0 \<Longrightarrow> unit_ball_vol n > 0" [PROOF STATE] proof (prove) goal (1 subgoal): 1. 0 \<le> n \<Longrightarrow> 0 < unit_ball_vol n [PROOF STEP] by (force simp: unit_ball_vol_def intro: divide_nonneg_pos)
lemma to_fract_mult [simp]: "to_fract (x * y) = to_fract x * to_fract y"
/- Copyright (c) 2020 Aaron Anderson, Jalex Stark. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Aaron Anderson, Jalex Stark -/ import algebra.polynomial.big_operators import data.matrix.char_p import field_theory.finite.basic import group_theory.perm.cycles import linear_algebra.matrix.charpoly.basic import linear_algebra.matrix.trace import linear_algebra.matrix.to_lin import ring_theory.polynomial.basic import ring_theory.power_basis /-! # Characteristic polynomials We give methods for computing coefficients of the characteristic polynomial. ## Main definitions - `matrix.charpoly_degree_eq_dim` proves that the degree of the characteristic polynomial over a nonzero ring is the dimension of the matrix - `matrix.det_eq_sign_charpoly_coeff` proves that the determinant is the constant term of the characteristic polynomial, up to sign. - `matrix.trace_eq_neg_charpoly_coeff` proves that the trace is the negative of the (d-1)th coefficient of the characteristic polynomial, where d is the dimension of the matrix. For a nonzero ring, this is the second-highest coefficient. -/ noncomputable theory universes u v w z open polynomial matrix open_locale big_operators variables {R : Type u} [comm_ring R] variables {n G : Type v} [decidable_eq n] [fintype n] variables {α β : Type v} [decidable_eq α] open finset variable {M : matrix n n R} lemma charmatrix_apply_nat_degree [nontrivial R] (i j : n) : (charmatrix M i j).nat_degree = ite (i = j) 1 0 := by { by_cases i = j; simp [h, ← degree_eq_iff_nat_degree_eq_of_pos (nat.succ_pos 0)], } lemma charmatrix_apply_nat_degree_le (i j : n) : (charmatrix M i j).nat_degree ≤ ite (i = j) 1 0 := by split_ifs; simp [h, nat_degree_X_sub_C_le] namespace matrix variable (M) lemma charpoly_sub_diagonal_degree_lt : (M.charpoly - ∏ (i : n), (X - C (M i i))).degree < ↑(fintype.card n - 1) := begin rw [charpoly, det_apply', ← insert_erase (mem_univ (equiv.refl n)), sum_insert (not_mem_erase (equiv.refl n) univ), add_comm], simp only [charmatrix_apply_eq, one_mul, equiv.perm.sign_refl, id.def, int.cast_one, units.coe_one, add_sub_cancel, equiv.coe_refl], rw ← mem_degree_lt, apply submodule.sum_mem (degree_lt R (fintype.card n - 1)), intros c hc, rw [← C_eq_int_cast, C_mul'], apply submodule.smul_mem (degree_lt R (fintype.card n - 1)) ↑↑(equiv.perm.sign c), rw mem_degree_lt, apply lt_of_le_of_lt degree_le_nat_degree _, rw with_bot.coe_lt_coe, apply lt_of_le_of_lt _ (equiv.perm.fixed_point_card_lt_of_ne_one (ne_of_mem_erase hc)), apply le_trans (polynomial.nat_degree_prod_le univ (λ i : n, (charmatrix M (c i) i))) _, rw card_eq_sum_ones, rw sum_filter, apply sum_le_sum, intros, apply charmatrix_apply_nat_degree_le, end lemma charpoly_coeff_eq_prod_coeff_of_le {k : ℕ} (h : fintype.card n - 1 ≤ k) : M.charpoly.coeff k = (∏ i : n, (X - C (M i i))).coeff k := begin apply eq_of_sub_eq_zero, rw ← coeff_sub, apply polynomial.coeff_eq_zero_of_degree_lt, apply lt_of_lt_of_le (charpoly_sub_diagonal_degree_lt M) _, rw with_bot.coe_le_coe, apply h, end lemma det_of_card_zero (h : fintype.card n = 0) (M : matrix n n R) : M.det = 1 := by { rw fintype.card_eq_zero_iff at h, suffices : M = 1, { simp [this] }, ext i, exact h.elim i } theorem charpoly_degree_eq_dim [nontrivial R] (M : matrix n n R) : M.charpoly.degree = fintype.card n := begin by_cases fintype.card n = 0, { rw h, unfold charpoly, rw det_of_card_zero, {simp}, {assumption} }, rw ← sub_add_cancel M.charpoly (∏ (i : n), (X - C (M i i))), have h1 : (∏ (i : n), (X - C (M i i))).degree = fintype.card n, { rw degree_eq_iff_nat_degree_eq_of_pos, swap, apply nat.pos_of_ne_zero h, rw nat_degree_prod', simp_rw nat_degree_X_sub_C, unfold fintype.card, simp, simp_rw (monic_X_sub_C _).leading_coeff, simp, }, rw degree_add_eq_right_of_degree_lt, exact h1, rw h1, apply lt_trans (charpoly_sub_diagonal_degree_lt M), rw with_bot.coe_lt_coe, rw ← nat.pred_eq_sub_one, apply nat.pred_lt, apply h, end theorem charpoly_nat_degree_eq_dim [nontrivial R] (M : matrix n n R) : M.charpoly.nat_degree = fintype.card n := nat_degree_eq_of_degree_eq_some (charpoly_degree_eq_dim M) lemma charpoly_monic (M : matrix n n R) : M.charpoly.monic := begin nontriviality, by_cases fintype.card n = 0, {rw [charpoly, det_of_card_zero h], apply monic_one}, have mon : (∏ (i : n), (X - C (M i i))).monic, { apply monic_prod_of_monic univ (λ i : n, (X - C (M i i))), simp [monic_X_sub_C], }, rw ← sub_add_cancel (∏ (i : n), (X - C (M i i))) M.charpoly at mon, rw monic at *, rw leading_coeff_add_of_degree_lt at mon, rw ← mon, rw charpoly_degree_eq_dim, rw ← neg_sub, rw degree_neg, apply lt_trans (charpoly_sub_diagonal_degree_lt M), rw with_bot.coe_lt_coe, rw ← nat.pred_eq_sub_one, apply nat.pred_lt, apply h, end theorem trace_eq_neg_charpoly_coeff [nonempty n] (M : matrix n n R) : (trace n R R) M = -M.charpoly.coeff (fintype.card n - 1) := begin nontriviality, rw charpoly_coeff_eq_prod_coeff_of_le, swap, refl, rw [fintype.card, prod_X_sub_C_coeff_card_pred univ (λ i : n, M i i)], simp, rw [← fintype.card, fintype.card_pos_iff], apply_instance, end -- I feel like this should use polynomial.alg_hom_eval₂_algebra_map lemma mat_poly_equiv_eval (M : matrix n n (polynomial R)) (r : R) (i j : n) : (mat_poly_equiv M).eval ((scalar n) r) i j = (M i j).eval r := begin unfold polynomial.eval, unfold eval₂, transitivity polynomial.sum (mat_poly_equiv M) (λ (e : ℕ) (a : matrix n n R), (a * (scalar n) r ^ e) i j), { unfold polynomial.sum, rw sum_apply, dsimp, refl }, { simp_rw [←ring_hom.map_pow, ←(scalar.commute _ _).eq], simp only [coe_scalar, matrix.one_mul, ring_hom.id_apply, pi.smul_apply, smul_eq_mul, mul_eq_mul, algebra.smul_mul_assoc], have h : ∀ x : ℕ, (λ (e : ℕ) (a : R), r ^ e * a) x 0 = 0 := by simp, simp only [polynomial.sum, mat_poly_equiv_coeff_apply, mul_comm], apply (finset.sum_subset (support_subset_support_mat_poly_equiv _ _ _) _).symm, assume n hn h'n, rw not_mem_support_iff at h'n, simp only [h'n, zero_mul] } end lemma eval_det (M : matrix n n (polynomial R)) (r : R) : polynomial.eval r M.det = (polynomial.eval (scalar n r) (mat_poly_equiv M)).det := begin rw [polynomial.eval, ← coe_eval₂_ring_hom, ring_hom.map_det], apply congr_arg det, ext, symmetry, convert mat_poly_equiv_eval _ _ _ _, end theorem det_eq_sign_charpoly_coeff (M : matrix n n R) : M.det = (-1)^(fintype.card n) * M.charpoly.coeff 0:= begin rw [coeff_zero_eq_eval_zero, charpoly, eval_det, mat_poly_equiv_charmatrix, ← det_smul], simp end end matrix variables {p : ℕ} [fact p.prime] lemma mat_poly_equiv_eq_X_pow_sub_C {K : Type*} (k : ℕ) [field K] (M : matrix n n K) : mat_poly_equiv ((expand K (k) : polynomial K →+* polynomial K).map_matrix (charmatrix (M ^ k))) = X ^ k - C (M ^ k) := begin ext m, rw [coeff_sub, coeff_C, mat_poly_equiv_coeff_apply, ring_hom.map_matrix_apply, matrix.map_apply, alg_hom.coe_to_ring_hom, dmatrix.sub_apply, coeff_X_pow], by_cases hij : i = j, { rw [hij, charmatrix_apply_eq, alg_hom.map_sub, expand_C, expand_X, coeff_sub, coeff_X_pow, coeff_C], split_ifs with mp m0; simp only [matrix.one_apply_eq, dmatrix.zero_apply] }, { rw [charmatrix_apply_ne _ _ _ hij, alg_hom.map_neg, expand_C, coeff_neg, coeff_C], split_ifs with m0 mp; simp only [hij, zero_sub, dmatrix.zero_apply, sub_zero, neg_zero, matrix.one_apply_ne, ne.def, not_false_iff] } end @[simp] lemma finite_field.matrix.charpoly_pow_card {K : Type*} [field K] [fintype K] (M : matrix n n K) : (M ^ (fintype.card K)).charpoly = M.charpoly := begin casesI (is_empty_or_nonempty n).symm, { cases char_p.exists K with p hp, letI := hp, rcases finite_field.card K p with ⟨⟨k, kpos⟩, ⟨hp, hk⟩⟩, haveI : fact p.prime := ⟨hp⟩, dsimp at hk, rw hk at *, apply (frobenius_inj (polynomial K) p).iterate k, repeat { rw iterate_frobenius, rw ← hk }, rw ← finite_field.expand_card, unfold charpoly, rw [alg_hom.map_det, ← coe_det_monoid_hom, ← (det_monoid_hom : matrix n n (polynomial K) →* polynomial K).map_pow], apply congr_arg det, refine mat_poly_equiv.injective _, rw [alg_equiv.map_pow, mat_poly_equiv_charmatrix, hk, sub_pow_char_pow_of_commute, ← C_pow], { exact (id (mat_poly_equiv_eq_X_pow_sub_C (p ^ k) M) : _) }, { exact (C M).commute_X } }, { -- TODO[gh-6025]: remove this `haveI` once `subsingleton_of_empty_right` is a global instance haveI : subsingleton (matrix n n K) := subsingleton_of_empty_right, exact congr_arg _ (subsingleton.elim _ _), }, end @[simp] lemma zmod.charpoly_pow_card (M : matrix n n (zmod p)) : (M ^ p).charpoly = M.charpoly := by { have h := finite_field.matrix.charpoly_pow_card M, rwa zmod.card at h, } lemma finite_field.trace_pow_card {K : Type*} [field K] [fintype K] [nonempty n] (M : matrix n n K) : trace n K K (M ^ (fintype.card K)) = (trace n K K M) ^ (fintype.card K) := by rw [matrix.trace_eq_neg_charpoly_coeff, matrix.trace_eq_neg_charpoly_coeff, finite_field.matrix.charpoly_pow_card, finite_field.pow_card] lemma zmod.trace_pow_card {p:ℕ} [fact p.prime] [nonempty n] (M : matrix n n (zmod p)) : trace n (zmod p) (zmod p) (M ^ p) = (trace n (zmod p) (zmod p) M)^p := by { have h := finite_field.trace_pow_card M, rwa zmod.card at h, } namespace matrix theorem is_integral : is_integral R M := ⟨M.charpoly, ⟨charpoly_monic M, aeval_self_charpoly M⟩⟩ theorem minpoly_dvd_charpoly {K : Type*} [field K] (M : matrix n n K) : (minpoly K M) ∣ M.charpoly := minpoly.dvd _ _ (aeval_self_charpoly M) end matrix section power_basis open algebra /-- The characteristic polynomial of the map `λ x, a * x` is the minimal polynomial of `a`. In combination with `det_eq_sign_charpoly_coeff` or `trace_eq_neg_charpoly_coeff` and a bit of rewriting, this will allow us to conclude the field norm resp. trace of `x` is the product resp. sum of `x`'s conjugates. -/ lemma charpoly_left_mul_matrix {K S : Type*} [field K] [comm_ring S] [algebra K S] (h : power_basis K S) : (left_mul_matrix h.basis h.gen).charpoly = minpoly K h.gen := begin apply minpoly.unique, { apply matrix.charpoly_monic }, { apply (left_mul_matrix _).injective_iff.mp (left_mul_matrix_injective h.basis), rw [← polynomial.aeval_alg_hom_apply, aeval_self_charpoly] }, { intros q q_monic root_q, rw [matrix.charpoly_degree_eq_dim, fintype.card_fin, degree_eq_nat_degree q_monic.ne_zero], apply with_bot.some_le_some.mpr, exact h.dim_le_nat_degree_of_root q_monic.ne_zero root_q } end end power_basis
/- Copyright (c) 2021-2022 Julien Marquet. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Julien Marquet -/ import Flows.SolveSets import Flows.Term import Flows.Subst --open Classical set_option codegen false section variable {α β : Type u} def Term.vehicle : Term α β → Fintype β | Term.Cst _ => ∅ | Term.Var x => Fintype.mk [x] | Term.Cons l r => vehicle l ∪ vehicle r instance : HasVehicle (Term α β) (Fintype β) where vehicle := Term.vehicle def Subst.vehicle (θ : Subst α β) : Fintype β := Fintype.image (λ x => 𝒱 ((Term.Var x : Term α β) • θ)) (carrier θ) instance : HasVehicle (Subst α β) (Fintype β) where vehicle := Subst.vehicle theorem vehicle_cons {u v : Term α β} : (𝒱 (Term.Cons u v) : Fintype β) = 𝒱 u ∪ 𝒱 v := rfl theorem vehicle_one : 𝒱 (1 : Subst α β) = (∅ : Fintype β) := by rw [Fintype.ext] intro x apply Iff.intro focus simp only [HasVehicle.vehicle, Subst.vehicle] rw [Fintype.mem_image_iff, carrier_one] intro ⟨ _, p, _ ⟩ exact False.elim <| Fintype.not_mem_empty _ p focus exact λ h => False.elim <| Fintype.not_mem_empty _ h theorem vehicle_elementary {x : β} {u : Term α β} (h : Term.Var x ≠ u) : 𝒱 (Subst.elementary h : Subst α β) = (𝒱 u : Fintype β) := by apply Fintype.ext.2 intro z apply Iff.intro focus intro h' simp only [HasVehicle.vehicle, Subst.vehicle] at h' let ⟨ t, t_in, in_img ⟩ := Fintype.mem_image_iff.1 h' rw [elementary_carrier, Fintype.mem_mk_iff] at t_in rw [show t = x by cases t_in <;> trivial, Subst.elementary_spec₁] at in_img exact in_img focus intro p simp only [HasVehicle.vehicle, Subst.vehicle] apply Fintype.mem_image_iff.2 ⟨ x, (show x ∈ carrier _ from _), _ ⟩ focus rw [elementary_carrier, Fintype.mem_mk_iff] apply List.Mem.head focus rw [Subst.elementary_spec₁] exact p theorem vehicle_on_image {θ : Subst α β} {A : Fintype β} (h₁ : 𝒱 θ ⊆ A) (u : Term α β) : 𝒱 (u • θ) ⊆ A ∪ 𝒱 u := by induction u with | Cst c => cases θ; apply Fintype.empty_included | Var x => by_cases h : (Term.Var x : Term α β) • θ = Term.Var x focus apply Fintype.included_union_l rw [h] exact Fintype.included_refl focus apply Fintype.included_union_r apply Fintype.included_trans _ h₁ intro y h' apply Fintype.in_image_of_is_image <| carrier_spec.2 h exact h' | Cons l r hl hr => rw [subst_cons] simp only [Term.vehicle] apply Fintype.included_trans (Fintype.union_on_included hl hr) rw [vehicle_cons] solve_sets theorem vehicle_on_image_contained {θ : Subst α β} {A : Fintype β} {u : Term α β} (h₁ : 𝒱 θ ⊆ A) (h₂ : 𝒱 u ⊆ A) : 𝒱 (u • θ) ⊆ A := Fintype.included_trans (vehicle_on_image h₁ u) <| Fintype.union_included_iff.2 ⟨ Fintype.included_refl, h₂ ⟩ theorem vehicle_on_comp {θ φ : Subst α β} {A : Fintype β} (h₁ : 𝒱 θ ⊆ A) (h₂ : 𝒱 φ ⊆ A) : 𝒱 (θ * φ) ⊆ A := by simp only [HasVehicle.vehicle, Subst.vehicle] apply Fintype.image_in_of_all_in intro x h rw [carrier_spec] at h simp only [] -- Better way to do it ? rw [← RAction.smul_mul] by_cases hθ : (Term.Var x : Term α β) • θ = Term.Var x focus have hφ := show (Term.Var x : Term α β) • φ ≠ Term.Var x by intro hφ apply h rw [← RAction.smul_mul, hθ, hφ] rw [hθ] apply Fintype.included_trans _ h₂ intro y h' apply Fintype.in_image_of_is_image <| carrier_spec.2 hφ exact h' focus apply vehicle_on_image_contained h₂ -- The pattern of the four following lines occurs often. -- Make it a lemma ? apply Fintype.included_trans _ h₁ intro y h' apply Fintype.in_image_of_is_image <| carrier_spec.2 hθ exact h' theorem vehicle_on_comp₁ (θ φ : Subst α β) : (𝒱 (θ * φ) : Fintype β) ⊆ 𝒱 θ ∪ 𝒱 φ := vehicle_on_comp (Fintype.included_union_r _ <| Fintype.included_refl) (Fintype.included_union_l _ <| Fintype.included_refl) theorem cons_vehicle_in {θ φ : Subst α β} {l₁ r₁ l₂ r₂ : Term α β} (h₁ : (𝒱 θ : Fintype β) ⊆ 𝒱 l₁ ∪ 𝒱 l₂) (h₂ : (𝒱 φ : Fintype β) ⊆ 𝒱 (r₁ • θ) ∪ 𝒱 (r₂ • θ)) : (𝒱 (θ * φ) : Fintype β) ⊆ 𝒱 (Term.Cons l₁ r₁) ∪ 𝒱 (Term.Cons l₂ r₂) := by rw [vehicle_cons, vehicle_cons] apply Fintype.included_trans (vehicle_on_comp₁ θ φ) rw [Fintype.union_included_iff]; apply And.intro focus apply Fintype.included_trans h₁ solve_sets focus apply Fintype.included_trans h₂ apply Fintype.union_included_iff.2 ⟨ _, _ ⟩ <;> apply vehicle_on_image_contained <;> try apply Fintype.included_trans h₁ all_goals solve_sets theorem elementary_on_not_in_vehicle {x : β} {u v : Term α β} (h : Term.Var x ≠ u) (h' : ¬ x ∈ (𝒱 v : Fintype β)) : v • (Subst.elementary h : Subst α β) = v := by induction v with | Cst c => rfl | Var y => apply Subst.elementary_spec₂ intro h apply h' rw [h] apply List.Mem.head | Cons l r hl hr => rw [vehicle_cons, Fintype.mem_union_iff] at h' rw [subst_cons, hl (λ h => h' <| Or.inl h), hr (λ h => h' <| Or.inr h)] end
#include <stdio.h> #include <stdlib.h> #include <gsl/gsl_vector.h> #include <gsl/gsl_statistics_double.h> #include <math.h> #include "tz_error.h" #include "tz_constant.h" #include "tz_voxel_linked_list.h" #include "tz_stack_sampling.h" #include "tz_voxel_graphics.h" #include "tz_neurotrace.h" #include "tz_stack_math.h" #include "tz_stack_utils.h" #include "tz_objdetect.h" #include "tz_voxeltrans.h" #include "tz_stack_stat.h" #include "tz_stack_draw.h" #include "tz_geo3d_vector.h" #include "tz_stack_bwmorph.h" #include "tz_stack_bwdist.h" INIT_EXCEPTION_MAIN(e) int main(int argc, char* argv[]) { #if 1 Stack *stack = Read_Stack("../data/lobster_neuron_seed.tif"); Voxel_List *list = Stack_To_Voxel_List(stack); //Print_Voxel_List(list); Pixel_Array *pa = Pixel_Array_Read("../data/lobster_neuron_seeds.pa"); //Print_Pixel_Array(pa); Voxel *seed; int i; double *pa_array = (double *) pa->array; printf("mean: %g, std: %g\n", gsl_stats_mean(pa_array, 1, pa->size), sqrt(gsl_stats_variance(pa_array, 1, pa->size))); double threshold = gsl_stats_mean(pa_array, 1, pa->size) + 3.0 * sqrt(gsl_stats_variance(pa_array, 1, pa->size)); double max_r = gsl_stats_max(pa_array, 1, pa->size); printf("%g, %g\n", threshold, max_r); max_r = 30.0; Set_Neuroseg_Max_Radius(max_r); dim_type dim[3]; dim[0] = stack->width; dim[1] = stack->height; dim[2] = stack->depth; IMatrix *chord = Make_IMatrix(dim, 3); Stack *code = Make_Stack(GREY16, stack->width, stack->height, stack->depth); Kill_Stack(stack); stack = Read_Stack("../data/lobster_neuron_single.tif"); Rgb_Color color; Set_Color(&color, 255, 0, 0); Stack *signal = Read_Stack("../data/lobster_neuron.tif"); Stack *canvas = Translate_Stack(signal, COLOR, 0); /************** soma detection *************/ #if 0 Struct_Element *se = Make_Ball_Se(((int) threshold)); Stack *stack1 = Stack_Erode_Fast(stack, NULL, se); Stack *soma = Stack_Dilate(stack1, NULL, se); Kill_Stack(stack1); Stack_And(stack, soma, soma); Stack_Label_Bwc(canvas, soma, color); Kill_Stack(soma); Write_Stack("../data/test.tif", canvas); return 0; #endif /*******************************************/ Object_3d *obj = NULL; int seed_offset = -1; Neurochain *chain = NULL; double z_scale = 0.488 / 0.588; Set_Zscale(z_scale); Stack *traced = Make_Stack(GREY, signal->width, signal->height, signal->depth); One_Stack(traced); for (i = 0; i < pa->size; i++) { seed = Voxel_Queue_De(&list); printf("------------------------------------------> seed: %d\n", i); if (*STACK_PIXEL_8(traced, seed->x, seed->y, seed->z, 0) == 0) { continue; } double width = pa_array[i]; if (width > max_r) { continue; } chain = New_Neurochain(); Print_Voxel(seed); printf("%g\n", width); int max_level = (int) (width + 0.5); if (max_level < 6) { max_level = 6; } seed_offset = Stack_Util_Offset(seed->x, seed->y, seed->z, stack->width, stack->height, stack->depth); Stack_Level_Code_Constraint(stack, code, chord->array, &seed_offset, 1, max_level + 1); Voxel_t v; Voxel_To_Tvoxel(seed, v); Print_Tvoxel(v); Stack *tmp_stack = Copy_Stack(stack); obj = Stack_Grow_Object_Constraint(tmp_stack, 1, v, chord, code, max_level); Free_Stack(tmp_stack); Print_Object_3d_Info(obj); double vec[3]; Object_3d_Orientation_Zscale(obj, vec, MAJOR_AXIS, z_scale); double theta, psi; Geo3d_Vector obj_vec; Set_Geo3d_Vector(&obj_vec, vec[0], vec[1], vec[2]); Geo3d_Vector_Orientation(&obj_vec, &theta, &psi); Set_Neuroseg(&(chain->seg), width, width, 10.0, theta, psi); double cpos[3]; cpos[0] = seed->x; cpos[1] = seed->y; cpos[2] = seed->z; cpos[2] *= z_scale; double bpos[3]; Neuroseg_Pos_Center_To_Bottom(&(chain->seg), cpos, bpos); Set_Position(chain->position, bpos[0], bpos[1], bpos[2]); if (Initialize_Tracing(signal, chain, NULL, NULL) >= MIN_SCORE) { if ((chain->seg.r1 < max_r) && (chain->seg.r2 < max_r)) { chain = Trace_Neuron(signal, chain, BOTH, traced); Print_Neurochain(chain); //Stack_Draw_Object_Bwc(canvas, obj, color); Neurochain_Erase(traced, Neurochain_Head(chain)); Neurochain_Label(canvas, Neurochain_Head(chain)); } } Free_Neurochain(chain); free(seed); Kill_Object_3d(obj); } Write_Stack("../data/lobster_neuron_traced.tif", canvas); #endif return 0; }
[STATEMENT] lemma lookup_zero_pp [simp]: "lookup_pp 0 = 0" [PROOF STATE] proof (prove) goal (1 subgoal): 1. lookup_pp 0 = 0 [PROOF STEP] by (transfer, simp add: lookup_zero_fun)
[STATEMENT] lemma Ide_appendI\<^sub>P\<^sub>W\<^sub>E [intro, simp]: assumes "Ide T" and "Ide U" and "Trg T = Src U" shows "Ide (T @ U)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. Ide (T @ U) [PROOF STEP] using assms [PROOF STATE] proof (prove) using this: Ide T Ide U Trg T = Src U goal (1 subgoal): 1. Ide (T @ U) [PROOF STEP] by (metis Ide.simps(1) Ide_append_iff\<^sub>P\<^sub>W\<^sub>E)
lemma measure_lborel_cbox_eq: "measure lborel (cbox l u) = (if \<forall>b\<in>Basis. l \<bullet> b \<le> u \<bullet> b then \<Prod>b\<in>Basis. (u - l) \<bullet> b else 0)"
subroutine s(y) complex*16 y(*) print *,kind(y) end subroutine s program p call s((1.,1.)) end program p
(*<*) theory Hilbert imports Main (* "HOL-Eisbach.Eisbach" *) abbrevs not="\<^bold>\<not>" and disj="\<^bold>\<or>" and conj="\<^bold>\<and>" and impl="\<^bold>\<rightarrow>" and equiv="\<^bold>\<leftrightarrow>" and true="\<^bold>\<top>" and false="\<^bold>\<bottom>" and ob="\<^bold>\<circle>" and perm="\<^bold>P" and forb="\<^bold>F" and derivable="\<turnstile>" begin (*>*) section \<open>Proving first theorems\<close> subsection \<open>Hilbert Calculus for Classical Logic\<close> text \<open>Technical remark at the beginning: In order to distinguish our connectives from the usual logical connectives of the Isabelle/HOL system, we use @{text "\<^bold>b\<^bold>o\<^bold>l\<^bold>d"}-face written versions of them. You may use the abbreviations at the top of the document (in the theory file) to write things down, e.g. if you start writing "dis..." (the abbreviation is "disj"), Isabelle should suggest the autocompletion for @{text "\<^bold>\<or>"}, etc.\<close> typedecl \<sigma> \<comment> \<open>Introduce new type for syntactical formulae (propositions).\<close> declare [[show_types]] text \<open> For our classical propositional language, we introduce two primitive symbols: Implication and negation. The others can be defined in terms of these two. \<close> consts PLimpl :: "\<sigma> \<Rightarrow> \<sigma> \<Rightarrow> \<sigma>" (infixr "\<^bold>\<rightarrow>" 49) PLnot :: "\<sigma> \<Rightarrow> \<sigma>" ("\<^bold>\<not>_" [52]53) consts PLatomicProp :: "\<sigma>" ("p") definition PLdisj :: "\<sigma> \<Rightarrow> \<sigma> \<Rightarrow> \<sigma>" (infixr "\<^bold>\<or>" 50) where "a \<^bold>\<or> b \<equiv> \<^bold>\<not>a \<^bold>\<rightarrow> b" definition PLconj :: "\<sigma> \<Rightarrow> \<sigma> \<Rightarrow> \<sigma>" (infixr "\<^bold>\<and>" 51) where "a \<^bold>\<and> b \<equiv> \<^bold>\<not>(\<^bold>\<not>a \<^bold>\<or> \<^bold>\<not>b)" definition PLequi :: "\<sigma> \<Rightarrow> \<sigma> \<Rightarrow> \<sigma>" (infix "\<^bold>\<leftrightarrow>" 48) where "a \<^bold>\<leftrightarrow> b \<equiv> (a \<^bold>\<rightarrow> b) \<^bold>\<and> (b \<^bold>\<rightarrow> a)" definition PLtop :: "\<sigma>" ("\<^bold>\<top>") where "\<^bold>\<top> \<equiv> p \<^bold>\<or> \<^bold>\<not>p" definition PLbot :: "\<sigma>" ("\<^bold>\<bottom>") where "\<^bold>\<bottom> \<equiv> \<^bold>\<not>\<^bold>\<top>" text \<open>Next we define the notion of syntactical derivability and consequence: \<close> consts derivable :: "\<sigma> \<Rightarrow> bool" ("\<turnstile> _" 40) definition consequence :: "\<sigma> \<Rightarrow> \<sigma> \<Rightarrow> bool" ("_ \<turnstile> _" 40) where "A \<turnstile> B \<equiv> \<turnstile> (A \<^bold>\<rightarrow> B)" text \<open>We can now axiomatize the derivability relation using a Hilbert-style system:\<close> axiomatization where A2: "\<turnstile> A \<^bold>\<rightarrow> (B \<^bold>\<rightarrow> A)" and (* Three Hilbert-style axioms *) A3: "\<turnstile> (A \<^bold>\<rightarrow> (B \<^bold>\<rightarrow> C)) \<^bold>\<rightarrow> ((A \<^bold>\<rightarrow> B) \<^bold>\<rightarrow> (A \<^bold>\<rightarrow> C))" and A4: "\<turnstile> (\<^bold>\<not>A \<^bold>\<rightarrow> \<^bold>\<not>B) \<^bold>\<rightarrow> (B \<^bold>\<rightarrow> A)" and MP: "\<turnstile> (A \<^bold>\<rightarrow> B) \<Longrightarrow> \<turnstile> A \<Longrightarrow> \<turnstile> B" (* One inference rule: Modus ponens *) paragraph \<open>Proof example.\<close> text \<open>Now we are ready to proof first simple theorems:\<close> lemma "\<turnstile> A \<^bold>\<rightarrow> A" proof - have 1: "\<turnstile> (A \<^bold>\<rightarrow> ((B \<^bold>\<rightarrow> A) \<^bold>\<rightarrow> A)) \<^bold>\<rightarrow> ((A \<^bold>\<rightarrow> (B \<^bold>\<rightarrow> A)) \<^bold>\<rightarrow> (A \<^bold>\<rightarrow> A))" using A3 by force have 2: "\<turnstile> A \<^bold>\<rightarrow> ((B \<^bold>\<rightarrow> A) \<^bold>\<rightarrow> A)" by (simp add: A2) from 1 2 have 3: "\<turnstile> (A \<^bold>\<rightarrow> (B \<^bold>\<rightarrow> A)) \<^bold>\<rightarrow> (A \<^bold>\<rightarrow> A)" by (rule MP) have 4: "\<turnstile> A \<^bold>\<rightarrow> (B \<^bold>\<rightarrow> A)" by (rule A2[of _ _]) from 3 4 have "\<turnstile> A \<^bold>\<rightarrow> A" by (rule MP) then show ?thesis . qed text \<open>The same proof a little bit nicer with syntactic sugar:\<close> lemma "\<turnstile> A \<^bold>\<rightarrow> A" proof - have "\<turnstile> (A \<^bold>\<rightarrow> ((B \<^bold>\<rightarrow> A) \<^bold>\<rightarrow> A)) \<^bold>\<rightarrow> ((A \<^bold>\<rightarrow> (B \<^bold>\<rightarrow> A)) \<^bold>\<rightarrow> (A \<^bold>\<rightarrow> A))" by (rule A3[of _ "B \<^bold>\<rightarrow> A" "A"]) moreover have "\<turnstile> A \<^bold>\<rightarrow> ((B \<^bold>\<rightarrow> A) \<^bold>\<rightarrow> A)" by (rule A2[of _ "B \<^bold>\<rightarrow> A"]) ultimately have "\<turnstile> (A \<^bold>\<rightarrow> (B \<^bold>\<rightarrow> A)) \<^bold>\<rightarrow> (A \<^bold>\<rightarrow> A)" by (rule MP) moreover have "\<turnstile> A \<^bold>\<rightarrow> (B \<^bold>\<rightarrow> A)" by (rule A2[of _ _]) ultimately show "\<turnstile> A \<^bold>\<rightarrow> A" by (rule MP) qed subsection \<open>Exercises\<close> paragraph \<open>Exercise 2.\<close> text \<open>Prove one of the following statements by giving an explicit proof within the given Hilbert calculus. Please make sure that every inference step in your proof is fine-grained and annotated with the respective calculus rule name. Hint: Find a proof first by pen-and-paper work and then formalize it within Isabelle.\<close> text \<open> \<^item> @{prop "\<turnstile> \<^bold>\<not>(F \<^bold>\<rightarrow> F) \<^bold>\<rightarrow> G"} \<^item> @{prop "\<turnstile> \<^bold>\<not>\<^bold>\<not>F \<^bold>\<rightarrow> F"} \<close> text "We will later see that many proofs can in fact be done almost automatically by Isabelle, see e.g. the example from further above:" lemma PL1: "\<turnstile> A \<^bold>\<rightarrow> A" using A2 A3 MP by blast lemma PL2: "\<turnstile> \<^bold>\<not>(F \<^bold>\<rightarrow> F) \<^bold>\<rightarrow> G" by (metis A2 A3 A4 MP) lemma PL3: "\<turnstile> \<^bold>\<not>\<^bold>\<not>F \<^bold>\<rightarrow> F" by (metis A2 A3 A4 MP) text \<open>Also, to make things look a bit nicer, we define a compound strategy @{text "PL"} (for "Propositional Logic") that applies an internal automated theorem prover with the respective axioms for propositional logic (A2, A3, A4 and MP)\<close> (*<*) named_theorems add \<comment> \<open>Needed for technical reasons\<close> (*>*) (* method PL declares add = (metis A2 A3 A4 MP add) *) text \<open>In the following, we can simply use @{text "by PL"} for proving propositional tautologies. However, as proofs can be arbitrarily complicated, this method may fail for difficult formulas.\<close> section \<open>Hilbert proofs for MDL\<close> text "We augment the language PL with the new connectives of MDL:" consts ob :: "\<sigma> \<Rightarrow> \<sigma>" ("\<^bold>\<circle>_" [52]53) \<comment> \<open>New atomic connective for obligation\<close> text \<open>The other new deontic logic connective can be defined as usual:\<close> definition perm :: "\<sigma> \<Rightarrow> \<sigma>" ("\<^bold>P_" [52]53) where "\<^bold>P a \<equiv> \<^bold>\<not>(\<^bold>\<circle>(\<^bold>\<not>a))" definition forbidden :: "\<sigma> \<Rightarrow> \<sigma>" ("\<^bold>F_" [52]53) where "\<^bold>F a \<equiv> \<^bold>\<circle>(\<^bold>\<not>a)" text \<open>Next, we additionally augment the axiomatization of our proof system for PL with the rules of the system D for MDL:\<close> axiomatization where K: "\<turnstile> \<^bold>\<circle>(A \<^bold>\<rightarrow> B) \<^bold>\<rightarrow> (\<^bold>\<circle>A \<^bold>\<rightarrow> \<^bold>\<circle>B)" and D: "\<turnstile> \<^bold>\<circle>A \<^bold>\<rightarrow> \<^bold>PA" and NEC: "\<turnstile> A \<Longrightarrow> \<turnstile> (\<^bold>\<circle>A)" subsection \<open>MDL Proof Examples\<close> lemma "\<turnstile> \<^bold>\<circle>(p \<^bold>\<and> q) \<^bold>\<rightarrow> \<^bold>\<circle>p" proof - have 1: "\<turnstile> (p \<^bold>\<and> q) \<^bold>\<rightarrow> p" by (metis A2 A3 A4 MP PL3 PLconj_def PLdisj_def) (* by (PL add: PLconj_def PLdisj_def) *) from 1 have 2: "\<turnstile> \<^bold>\<circle>((p \<^bold>\<and> q) \<^bold>\<rightarrow> p)" by (rule NEC) have 3: "\<turnstile> \<^bold>\<circle>((p \<^bold>\<and> q) \<^bold>\<rightarrow> p) \<^bold>\<rightarrow> \<^bold>\<circle>(p \<^bold>\<and> q) \<^bold>\<rightarrow> \<^bold>\<circle>p" by (rule K) from 3 2 show "\<turnstile> \<^bold>\<circle>(p \<^bold>\<and> q) \<^bold>\<rightarrow> \<^bold>\<circle>p" by (rule MP) qed text \<open>Note that, although we have the necessitation rule @{thm "NEC"} , the formula @{term "A \<^bold>\<rightarrow> \<^bold>\<circle>A"} is not generally valid:\<close> lemma "\<turnstile> a \<^bold>\<rightarrow> \<^bold>\<circle>a" nitpick[user_axioms,expect=genuine] oops subsection \<open>Exercises\<close> paragraph \<open>Exercise 2.\<close> text \<open>Prove the following statement by giving an explicit proof within the given Hilbert calculus. Please make sure that every inference step in your proof is fine-grained and annotated with the respective calculus rule name. You may use the general {method "PL"} method for inferring propositional tautologies. Hint: Reuse your proof from the previous exercise sheet and formalize it within Isabelle.\<close> text \<open> \<^item> @{prop "\<turnstile> \<^bold>\<not>\<^bold>\<circle>\<^bold>\<bottom>"} \<close> lemma "\<turnstile> \<^bold>\<not>\<^bold>\<circle>\<^bold>\<bottom>" sledgehammer oops (*<*) end (*>*)
(* Title: HOL/Algebra/Exact_Sequence.thy Author: Martin Baillon (first part) and LC Paulson (material ported from HOL Light) *) section \<open>Exact Sequences\<close> theory Exact_Sequence imports Elementary_Groups Solvable_Groups begin subsection \<open>Definitions\<close> inductive exact_seq :: "'a monoid list \<times> ('a \<Rightarrow> 'a) list \<Rightarrow> bool" where unity: " group_hom G1 G2 f \<Longrightarrow> exact_seq ([G2, G1], [f])" | extension: "\<lbrakk> exact_seq ((G # K # l), (g # q)); group H ; h \<in> hom G H ; kernel G H h = image g (carrier K) \<rbrakk> \<Longrightarrow> exact_seq (H # G # K # l, h # g # q)" inductive_simps exact_seq_end_iff [simp]: "exact_seq ([G,H], (g # q))" inductive_simps exact_seq_cons_iff [simp]: "exact_seq ((G # K # H # l), (g # h # q))" abbreviation exact_seq_arrow :: "('a \<Rightarrow> 'a) \<Rightarrow> 'a monoid list \<times> ('a \<Rightarrow> 'a) list \<Rightarrow> 'a monoid \<Rightarrow> 'a monoid list \<times> ('a \<Rightarrow> 'a) list" ("(3_ / \<longlongrightarrow>\<index> _)" [1000, 60]) where "exact_seq_arrow f t G \<equiv> (G # (fst t), f # (snd t))" subsection \<open>Basic Properties\<close> lemma exact_seq_length1: "exact_seq t \<Longrightarrow> length (fst t) = Suc (length (snd t))" by (induct t rule: exact_seq.induct) auto lemma exact_seq_length2: "exact_seq t \<Longrightarrow> length (snd t) \<ge> Suc 0" by (induct t rule: exact_seq.induct) auto lemma dropped_seq_is_exact_seq: assumes "exact_seq (G, F)" and "(i :: nat) < length F" shows "exact_seq (drop i G, drop i F)" proof- { fix t i assume "exact_seq t" "i < length (snd t)" hence "exact_seq (drop i (fst t), drop i (snd t))" proof (induction arbitrary: i) case (unity G1 G2 f) thus ?case by (simp add: exact_seq.unity) next case (extension G K l g q H h) show ?case proof (cases) assume "i = 0" thus ?case using exact_seq.extension[OF extension.hyps] by simp next assume "i \<noteq> 0" hence "i \<ge> Suc 0" by simp then obtain k where "k < length (snd (G # K # l, g # q))" "i = Suc k" using Suc_le_D extension.prems by auto thus ?thesis using extension.IH by simp qed qed } thus ?thesis using assms by auto qed lemma truncated_seq_is_exact_seq: assumes "exact_seq (l, q)" and "length l \<ge> 3" shows "exact_seq (tl l, tl q)" using exact_seq_length1[OF assms(1)] dropped_seq_is_exact_seq[OF assms(1), of "Suc 0"] exact_seq_length2[OF assms(1)] assms(2) by (simp add: drop_Suc) lemma exact_seq_imp_exact_hom: assumes "exact_seq (G1 # l,q) \<longlongrightarrow>\<^bsub>g1\<^esub> G2 \<longlongrightarrow>\<^bsub>g2\<^esub> G3" shows "g1 ` (carrier G1) = kernel G2 G3 g2" proof- { fix t assume "exact_seq t" and "length (fst t) \<ge> 3 \<and> length (snd t) \<ge> 2" hence "(hd (tl (snd t))) ` (carrier (hd (tl (tl (fst t))))) = kernel (hd (tl (fst t))) (hd (fst t)) (hd (snd t))" proof (induction) case (unity G1 G2 f) then show ?case by auto next case (extension G l g q H h) then show ?case by auto qed } thus ?thesis using assms by fastforce qed lemma exact_seq_imp_exact_hom_arbitrary: assumes "exact_seq (G, F)" and "Suc i < length F" shows "(F ! (Suc i)) ` (carrier (G ! (Suc (Suc i)))) = kernel (G ! (Suc i)) (G ! i) (F ! i)" proof - have "length (drop i F) \<ge> 2" "length (drop i G) \<ge> 3" using assms(2) exact_seq_length1[OF assms(1)] by auto then obtain l q where "drop i G = (G ! i) # (G ! (Suc i)) # (G ! (Suc (Suc i))) # l" and "drop i F = (F ! i) # (F ! (Suc i)) # q" by (metis Cons_nth_drop_Suc Suc_less_eq assms exact_seq_length1 fst_conv le_eq_less_or_eq le_imp_less_Suc prod.sel(2)) thus ?thesis using dropped_seq_is_exact_seq[OF assms(1), of i] assms(2) exact_seq_imp_exact_hom[of "G ! i" "G ! (Suc i)" "G ! (Suc (Suc i))" l q] by auto qed lemma exact_seq_imp_group_hom : assumes "exact_seq ((G # l, q)) \<longlongrightarrow>\<^bsub>g\<^esub> H" shows "group_hom G H g" proof- { fix t assume "exact_seq t" hence "group_hom (hd (tl (fst t))) (hd (fst t)) (hd(snd t))" proof (induction) case (unity G1 G2 f) then show ?case by auto next case (extension G l g q H h) then show ?case unfolding group_hom_def group_hom_axioms_def by auto qed } note aux_lemma = this show ?thesis using aux_lemma[OF assms] by simp qed lemma exact_seq_imp_group_hom_arbitrary: assumes "exact_seq (G, F)" and "(i :: nat) < length F" shows "group_hom (G ! (Suc i)) (G ! i) (F ! i)" proof - have "length (drop i F) \<ge> 1" "length (drop i G) \<ge> 2" using assms(2) exact_seq_length1[OF assms(1)] by auto then obtain l q where "drop i G = (G ! i) # (G ! (Suc i)) # l" and "drop i F = (F ! i) # q" by (metis Cons_nth_drop_Suc Suc_leI assms exact_seq_length1 fst_conv le_eq_less_or_eq le_imp_less_Suc prod.sel(2)) thus ?thesis using dropped_seq_is_exact_seq[OF assms(1), of i] assms(2) exact_seq_imp_group_hom[of "G ! i" "G ! (Suc i)" l q "F ! i"] by simp qed subsection \<open>Link Between Exact Sequences and Solvable Conditions\<close> lemma exact_seq_solvable_imp : assumes "exact_seq ([G1],[]) \<longlongrightarrow>\<^bsub>g1\<^esub> G2 \<longlongrightarrow>\<^bsub>g2\<^esub> G3" and "inj_on g1 (carrier G1)" and "g2 ` (carrier G2) = carrier G3" shows "solvable G2 \<Longrightarrow> (solvable G1) \<and> (solvable G3)" proof - assume G2: "solvable G2" have "group_hom G1 G2 g1" using exact_seq_imp_group_hom_arbitrary[OF assms(1), of "Suc 0"] by simp hence "solvable G1" using group_hom.inj_hom_imp_solvable[of G1 G2 g1] assms(2) G2 by simp moreover have "group_hom G2 G3 g2" using exact_seq_imp_group_hom_arbitrary[OF assms(1), of 0] by simp hence "solvable G3" using group_hom.surj_hom_imp_solvable[of G2 G3 g2] assms(3) G2 by simp ultimately show ?thesis by simp qed lemma exact_seq_solvable_recip : assumes "exact_seq ([G1],[]) \<longlongrightarrow>\<^bsub>g1\<^esub> G2 \<longlongrightarrow>\<^bsub>g2\<^esub> G3" and "inj_on g1 (carrier G1)" and "g2 ` (carrier G2) = carrier G3" shows "(solvable G1) \<and> (solvable G3) \<Longrightarrow> solvable G2" proof - assume "(solvable G1) \<and> (solvable G3)" hence G1: "solvable G1" and G3: "solvable G3" by auto have g1: "group_hom G1 G2 g1" and g2: "group_hom G2 G3 g2" using exact_seq_imp_group_hom_arbitrary[OF assms(1), of "Suc 0"] exact_seq_imp_group_hom_arbitrary[OF assms(1), of 0] by auto show ?thesis using solvable_condition[OF g1 g2 assms(3)] exact_seq_imp_exact_hom[OF assms(1)] G1 G3 by auto qed proposition exact_seq_solvable_iff : assumes "exact_seq ([G1],[]) \<longlongrightarrow>\<^bsub>g1\<^esub> G2 \<longlongrightarrow>\<^bsub>g2\<^esub> G3" and "inj_on g1 (carrier G1)" and "g2 ` (carrier G2) = carrier G3" shows "(solvable G1) \<and> (solvable G3) \<longleftrightarrow> solvable G2" using exact_seq_solvable_recip exact_seq_solvable_imp assms by blast lemma exact_seq_eq_triviality: assumes "exact_seq ([E,D,C,B,A], [k,h,g,f])" shows "trivial_group C \<longleftrightarrow> f ` carrier A = carrier B \<and> inj_on k (carrier D)" (is "_ = ?rhs") proof assume C: "trivial_group C" with assms have "inj_on k (carrier D)" apply (auto simp: group_hom.image_from_trivial_group trivial_group_def hom_one) apply (simp add: group_hom_def group_hom_axioms_def group_hom.inj_iff_trivial_ker) done with assms C show ?rhs apply (auto simp: group_hom.image_from_trivial_group trivial_group_def hom_one) apply (auto simp: group_hom_def group_hom_axioms_def hom_def kernel_def) done next assume ?rhs with assms show "trivial_group C" apply (simp add: trivial_group_def) by (metis group_hom.inj_iff_trivial_ker group_hom.trivial_hom_iff group_hom_axioms.intro group_hom_def) qed lemma exact_seq_imp_triviality: "\<lbrakk>exact_seq ([E,D,C,B,A], [k,h,g,f]); f \<in> iso A B; k \<in> iso D E\<rbrakk> \<Longrightarrow> trivial_group C" by (metis (no_types, lifting) Group.iso_def bij_betw_def exact_seq_eq_triviality mem_Collect_eq) lemma exact_seq_epi_eq_triviality: "exact_seq ([D,C,B,A], [h,g,f]) \<Longrightarrow> (f ` carrier A = carrier B) \<longleftrightarrow> trivial_homomorphism B C g" by (auto simp: trivial_homomorphism_def kernel_def) lemma exact_seq_mon_eq_triviality: "exact_seq ([D,C,B,A], [h,g,f]) \<Longrightarrow> inj_on h (carrier C) \<longleftrightarrow> trivial_homomorphism B C g" by (auto simp: trivial_homomorphism_def kernel_def group.is_monoid inj_on_one_iff' image_def) blast lemma exact_sequence_sum_lemma: assumes "comm_group G" and h: "h \<in> iso A C" and k: "k \<in> iso B D" and ex: "exact_seq ([D,G,A], [g,i])" "exact_seq ([C,G,B], [f,j])" and fih: "\<And>x. x \<in> carrier A \<Longrightarrow> f(i x) = h x" and gjk: "\<And>x. x \<in> carrier B \<Longrightarrow> g(j x) = k x" shows "(\<lambda>(x, y). i x \<otimes>\<^bsub>G\<^esub> j y) \<in> Group.iso (A \<times>\<times> B) G \<and> (\<lambda>z. (f z, g z)) \<in> Group.iso G (C \<times>\<times> D)" (is "?ij \<in> _ \<and> ?gf \<in> _") proof (rule epi_iso_compose_rev) interpret comm_group G by (rule assms) interpret f: group_hom G C f using ex by (simp add: group_hom_def group_hom_axioms_def) interpret g: group_hom G D g using ex by (simp add: group_hom_def group_hom_axioms_def) interpret i: group_hom A G i using ex by (simp add: group_hom_def group_hom_axioms_def) interpret j: group_hom B G j using ex by (simp add: group_hom_def group_hom_axioms_def) have kerf: "kernel G C f = j ` carrier B" and "group A" "group B" "i \<in> hom A G" using ex by (auto simp: group_hom_def group_hom_axioms_def) then obtain h' where "h' \<in> hom C A" "(\<forall>x \<in> carrier A. h'(h x) = x)" and hh': "(\<forall>y \<in> carrier C. h(h' y) = y)" and "group_isomorphisms A C h h'" using h by (auto simp: group.iso_iff_group_isomorphisms group_isomorphisms_def) have homij: "?ij \<in> hom (A \<times>\<times> B) G" unfolding case_prod_unfold apply (rule hom_group_mult) using ex by (simp_all add: group_hom_def hom_of_fst [unfolded o_def] hom_of_snd [unfolded o_def]) show homgf: "?gf \<in> hom G (C \<times>\<times> D)" using ex by (simp add: hom_paired) show "?ij \<in> epi (A \<times>\<times> B) G" proof (clarsimp simp add: epi_iff_subset homij) fix x assume x: "x \<in> carrier G" with \<open>i \<in> hom A G\<close> \<open>h' \<in> hom C A\<close> have "x \<otimes>\<^bsub>G\<^esub> inv\<^bsub>G\<^esub>(i(h'(f x))) \<in> kernel G C f" by (simp add: kernel_def hom_in_carrier hh' fih) with kerf obtain y where y: "y \<in> carrier B" "j y = x \<otimes>\<^bsub>G\<^esub> inv\<^bsub>G\<^esub>(i(h'(f x)))" by auto have "i (h' (f x)) \<otimes>\<^bsub>G\<^esub> (x \<otimes>\<^bsub>G\<^esub> inv\<^bsub>G\<^esub> i (h' (f x))) = x \<otimes>\<^bsub>G\<^esub> (i (h' (f x)) \<otimes>\<^bsub>G\<^esub> inv\<^bsub>G\<^esub> i (h' (f x)))" by (meson \<open>h' \<in> hom C A\<close> x f.hom_closed hom_in_carrier i.hom_closed inv_closed m_lcomm) also have "\<dots> = x" using \<open>h' \<in> hom C A\<close> hom_in_carrier x by fastforce finally show "x \<in> (\<lambda>(x, y). i x \<otimes>\<^bsub>G\<^esub> j y) ` (carrier A \<times> carrier B)" using x y apply (clarsimp simp: image_def) apply (rule_tac x="h'(f x)" in bexI) apply (rule_tac x=y in bexI, auto) by (meson \<open>h' \<in> hom C A\<close> f.hom_closed hom_in_carrier) qed show "(\<lambda>z. (f z, g z)) \<circ> (\<lambda>(x, y). i x \<otimes>\<^bsub>G\<^esub> j y) \<in> Group.iso (A \<times>\<times> B) (C \<times>\<times> D)" apply (rule group.iso_eq [where f = "\<lambda>(x,y). (h x,k y)"]) using ex apply (auto simp: group_hom_def group_hom_axioms_def DirProd_group iso_paired2 h k fih gjk kernel_def set_eq_iff) apply (metis f.hom_closed f.r_one fih imageI) apply (metis g.hom_closed g.l_one gjk imageI) done qed subsection \<open>Splitting lemmas and Short exact sequences\<close> text\<open>Ported from HOL Light by LCP\<close> definition short_exact_sequence where "short_exact_sequence A B C f g \<equiv> \<exists>T1 T2 e1 e2. exact_seq ([T1,A,B,C,T2], [e1,f,g,e2]) \<and> trivial_group T1 \<and> trivial_group T2" lemma short_exact_sequenceD: assumes "short_exact_sequence A B C f g" shows "exact_seq ([A,B,C], [f,g]) \<and> f \<in> epi B A \<and> g \<in> mon C B" using assms apply (auto simp: short_exact_sequence_def group_hom_def group_hom_axioms_def) apply (simp add: epi_iff_subset group_hom.intro group_hom.kernel_to_trivial_group group_hom_axioms.intro) by (metis (no_types, lifting) group_hom.inj_iff_trivial_ker group_hom.intro group_hom_axioms.intro hom_one image_empty image_insert mem_Collect_eq mon_def trivial_group_def) lemma short_exact_sequence_iff: "short_exact_sequence A B C f g \<longleftrightarrow> exact_seq ([A,B,C], [f,g]) \<and> f \<in> epi B A \<and> g \<in> mon C B" proof - have "short_exact_sequence A B C f g" if "exact_seq ([A, B, C], [f, g])" and "f \<in> epi B A" and "g \<in> mon C B" proof - show ?thesis unfolding short_exact_sequence_def proof (intro exI conjI) have "kernel A (singleton_group \<one>\<^bsub>A\<^esub>) (\<lambda>x. \<one>\<^bsub>A\<^esub>) = f ` carrier B" using that by (simp add: kernel_def singleton_group_def epi_def) moreover have "kernel C B g = {\<one>\<^bsub>C\<^esub>}" using that group_hom.inj_iff_trivial_ker mon_def by fastforce ultimately show "exact_seq ([singleton_group (one A), A, B, C, singleton_group (one C)], [\<lambda>x. \<one>\<^bsub>A\<^esub>, f, g, id])" using that by (simp add: group_hom_def group_hom_axioms_def group.id_hom_singleton) qed auto qed then show ?thesis using short_exact_sequenceD by blast qed lemma very_short_exact_sequence: assumes "exact_seq ([D,C,B,A], [h,g,f])" "trivial_group A" "trivial_group D" shows "g \<in> iso B C" using assms apply simp by (metis (no_types, lifting) group_hom.image_from_trivial_group group_hom.iso_iff group_hom.kernel_to_trivial_group group_hom.trivial_ker_imp_inj group_hom_axioms.intro group_hom_def hom_carrier inj_on_one_iff') lemma splitting_sublemma_gen: assumes ex: "exact_seq ([C,B,A], [g,f])" and fim: "f ` carrier A = H" and "subgroup K B" and 1: "H \<inter> K \<subseteq> {one B}" and eq: "set_mult B H K = carrier B" shows "g \<in> iso (subgroup_generated B K) (subgroup_generated C(g ` carrier B))" proof - interpret KB: subgroup K B by (rule assms) interpret fAB: group_hom A B f using ex by simp interpret gBC: group_hom B C g using ex by (simp add: group_hom_def group_hom_axioms_def) have "group A" "group B" "group C" and kerg: "kernel B C g = f ` carrier A" using ex by (auto simp: group_hom_def group_hom_axioms_def) have ker_eq: "kernel B C g = H" using ex by (simp add: fim) then have "subgroup H B" using ex by (simp add: group_hom.img_is_subgroup) show ?thesis unfolding iso_iff proof (intro conjI) show "g \<in> hom (subgroup_generated B K) (subgroup_generated C(g ` carrier B))" by (metis ker_eq \<open>subgroup K B\<close> eq gBC.hom_between_subgroups gBC.set_mult_ker_hom(2) order_refl subgroup.subset) show "g ` carrier (subgroup_generated B K) = carrier (subgroup_generated C(g ` carrier B))" by (metis assms(3) eq fAB.H.subgroupE(1) gBC.img_is_subgroup gBC.set_mult_ker_hom(2) ker_eq subgroup.carrier_subgroup_generated_subgroup) interpret gKBC: group_hom "subgroup_generated B K" C g apply (auto simp: group_hom_def group_hom_axioms_def \<open>group C\<close>) by (simp add: fAB.H.hom_from_subgroup_generated gBC.homh) have *: "x = \<one>\<^bsub>B\<^esub>" if x: "x \<in> carrier (subgroup_generated B K)" and "g x = \<one>\<^bsub>C\<^esub>" for x proof - have x': "x \<in> carrier B" using that fAB.H.carrier_subgroup_generated_subset by blast moreover have "x \<in> H" using kerg fim x' that by (auto simp: kernel_def set_eq_iff) ultimately show ?thesis by (metis "1" x Int_iff singletonD KB.carrier_subgroup_generated_subgroup subsetCE) qed show "inj_on g (carrier (subgroup_generated B K))" using "*" gKBC.inj_on_one_iff by auto qed qed lemma splitting_sublemma: assumes ex: "short_exact_sequence C B A g f" and fim: "f ` carrier A = H" and "subgroup K B" and 1: "H \<inter> K \<subseteq> {one B}" and eq: "set_mult B H K = carrier B" shows "f \<in> iso A (subgroup_generated B H)" (is ?f) "g \<in> iso (subgroup_generated B K) C" (is ?g) proof - show ?f using short_exact_sequenceD [OF ex] apply (clarsimp simp add: group_hom_def group.iso_onto_image) using fim group.iso_onto_image by blast have "C = subgroup_generated C(g ` carrier B)" using short_exact_sequenceD [OF ex] apply simp by (metis epi_iff_subset group.subgroup_generated_group_carrier hom_carrier subset_antisym) then show ?g using short_exact_sequenceD [OF ex] by (metis "1" \<open>subgroup K B\<close> eq fim splitting_sublemma_gen) qed lemma splitting_lemma_left_gen: assumes ex: "exact_seq ([C,B,A], [g,f])" and f': "f' \<in> hom B A" and iso: "(f' \<circ> f) \<in> iso A A" and injf: "inj_on f (carrier A)" and surj: "g ` carrier B = carrier C" obtains H K where "H \<lhd> B" "K \<lhd> B" "H \<inter> K \<subseteq> {one B}" "set_mult B H K = carrier B" "f \<in> iso A (subgroup_generated B H)" "g \<in> iso (subgroup_generated B K) C" proof - interpret gBC: group_hom B C g using ex by (simp add: group_hom_def group_hom_axioms_def) have "group A" "group B" "group C" and kerg: "kernel B C g = f ` carrier A" using ex by (auto simp: group_hom_def group_hom_axioms_def) then have *: "f ` carrier A \<inter> kernel B A f' = {\<one>\<^bsub>B\<^esub>} \<and> f ` carrier A <#>\<^bsub>B\<^esub> kernel B A f' = carrier B" using group_semidirect_sum_image_ker [of f A B f' A] assms by auto interpret f'AB: group_hom B A f' using assms by (auto simp: group_hom_def group_hom_axioms_def) let ?H = "f ` carrier A" let ?K = "kernel B A f'" show thesis proof show "?H \<lhd> B" by (simp add: gBC.normal_kernel flip: kerg) show "?K \<lhd> B" by (rule f'AB.normal_kernel) show "?H \<inter> ?K \<subseteq> {\<one>\<^bsub>B\<^esub>}" "?H <#>\<^bsub>B\<^esub> ?K = carrier B" using * by auto show "f \<in> Group.iso A (subgroup_generated B ?H)" using ex by (simp add: injf iso_onto_image group_hom_def group_hom_axioms_def) have C: "C = subgroup_generated C(g ` carrier B)" using surj by (simp add: gBC.subgroup_generated_group_carrier) show "g \<in> Group.iso (subgroup_generated B ?K) C" apply (subst C) apply (rule splitting_sublemma_gen [OF ex refl]) using * by (auto simp: f'AB.subgroup_kernel) qed qed lemma splitting_lemma_left: assumes ex: "exact_seq ([C,B,A], [g,f])" and f': "f' \<in> hom B A" and inv: "(\<And>x. x \<in> carrier A \<Longrightarrow> f'(f x) = x)" and injf: "inj_on f (carrier A)" and surj: "g ` carrier B = carrier C" obtains H K where "H \<lhd> B" "K \<lhd> B" "H \<inter> K \<subseteq> {one B}" "set_mult B H K = carrier B" "f \<in> iso A (subgroup_generated B H)" "g \<in> iso (subgroup_generated B K) C" proof - interpret fAB: group_hom A B f using ex by simp interpret gBC: group_hom B C g using ex by (simp add: group_hom_def group_hom_axioms_def) have "group A" "group B" "group C" and kerg: "kernel B C g = f ` carrier A" using ex by (auto simp: group_hom_def group_hom_axioms_def) have iso: "f' \<circ> f \<in> Group.iso A A" using ex by (auto simp: inv intro: group.iso_eq [OF \<open>group A\<close> id_iso]) show thesis by (metis that splitting_lemma_left_gen [OF ex f' iso injf surj]) qed lemma splitting_lemma_right_gen: assumes ex: "short_exact_sequence C B A g f" and g': "g' \<in> hom C B" and iso: "(g \<circ> g') \<in> iso C C" obtains H K where "H \<lhd> B" "subgroup K B" "H \<inter> K \<subseteq> {one B}" "set_mult B H K = carrier B" "f \<in> iso A (subgroup_generated B H)" "g \<in> iso (subgroup_generated B K) C" proof interpret fAB: group_hom A B f using short_exact_sequenceD [OF ex] by (simp add: group_hom_def group_hom_axioms_def) interpret gBC: group_hom B C g using short_exact_sequenceD [OF ex] by (simp add: group_hom_def group_hom_axioms_def) have *: "f ` carrier A \<inter> g' ` carrier C = {\<one>\<^bsub>B\<^esub>}" "f ` carrier A <#>\<^bsub>B\<^esub> g' ` carrier C = carrier B" "group A" "group B" "group C" "kernel B C g = f ` carrier A" using group_semidirect_sum_ker_image [of g g' C C B] short_exact_sequenceD [OF ex] by (simp_all add: g' iso group_hom_def) show "kernel B C g \<lhd> B" by (simp add: gBC.normal_kernel) show "(kernel B C g) \<inter> (g' ` carrier C) \<subseteq> {\<one>\<^bsub>B\<^esub>}" "(kernel B C g) <#>\<^bsub>B\<^esub> (g' ` carrier C) = carrier B" by (auto simp: *) show "f \<in> Group.iso A (subgroup_generated B (kernel B C g))" by (metis "*"(6) fAB.group_hom_axioms group.iso_onto_image group_hom_def short_exact_sequenceD [OF ex]) show "subgroup (g' ` carrier C) B" using splitting_sublemma by (simp add: fAB.H.is_group g' gBC.is_group group_hom.img_is_subgroup group_hom_axioms_def group_hom_def) then show "g \<in> Group.iso (subgroup_generated B (g' ` carrier C)) C" by (metis (no_types, lifting) iso_iff fAB.H.hom_from_subgroup_generated gBC.homh image_comp inj_on_imageI iso subgroup.carrier_subgroup_generated_subgroup) qed lemma splitting_lemma_right: assumes ex: "short_exact_sequence C B A g f" and g': "g' \<in> hom C B" and gg': "\<And>z. z \<in> carrier C \<Longrightarrow> g(g' z) = z" obtains H K where "H \<lhd> B" "subgroup K B" "H \<inter> K \<subseteq> {one B}" "set_mult B H K = carrier B" "f \<in> iso A (subgroup_generated B H)" "g \<in> iso (subgroup_generated B K) C" proof - have *: "group A" "group B" "group C" using group_semidirect_sum_ker_image [of g g' C C B] short_exact_sequenceD [OF ex] by (simp_all add: g' group_hom_def) show thesis apply (rule splitting_lemma_right_gen [OF ex g' group.iso_eq [OF _ id_iso]]) using * apply (auto simp: gg' intro: that) done qed end
[STATEMENT] lemma degree_poly_of_vec_less: fixes v :: "'a :: comm_monoid_add vec" assumes dim: "dim_vec v > 0" shows "degree (poly_of_vec v) < dim_vec v" [PROOF STATE] proof (prove) goal (1 subgoal): 1. degree (poly_of_vec v) < dim_vec v [PROOF STEP] unfolding poly_of_vec_def Let_def [PROOF STATE] proof (prove) goal (1 subgoal): 1. degree (\<Sum>i<dim_vec v. monom (v $ (dim_vec v - Suc i)) i) < dim_vec v [PROOF STEP] apply(rule degree_sum_smaller) [PROOF STATE] proof (prove) goal (3 subgoals): 1. 0 < dim_vec v 2. finite {..<dim_vec v} 3. \<And>i. i \<in> {..<dim_vec v} \<Longrightarrow> degree (monom (v $ (dim_vec v - Suc i)) i) < dim_vec v [PROOF STEP] using dim [PROOF STATE] proof (prove) using this: 0 < dim_vec v goal (3 subgoals): 1. 0 < dim_vec v 2. finite {..<dim_vec v} 3. \<And>i. i \<in> {..<dim_vec v} \<Longrightarrow> degree (monom (v $ (dim_vec v - Suc i)) i) < dim_vec v [PROOF STEP] apply force [PROOF STATE] proof (prove) goal (2 subgoals): 1. finite {..<dim_vec v} 2. \<And>i. i \<in> {..<dim_vec v} \<Longrightarrow> degree (monom (v $ (dim_vec v - Suc i)) i) < dim_vec v [PROOF STEP] apply force [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>i. i \<in> {..<dim_vec v} \<Longrightarrow> degree (monom (v $ (dim_vec v - Suc i)) i) < dim_vec v [PROOF STEP] unfolding lessThan_iff [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>i. i < dim_vec v \<Longrightarrow> degree (monom (v $ (dim_vec v - Suc i)) i) < dim_vec v [PROOF STEP] by (metis degree_0 degree_monom_eq dim monom_eq_0_iff)
[STATEMENT] lemma inext_closed: "n \<in> I \<Longrightarrow> inext n I \<in> I" [PROOF STATE] proof (prove) goal (1 subgoal): 1. n \<in> I \<Longrightarrow> inext n I \<in> I [PROOF STEP] apply (clarsimp simp: inext_def) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>n \<in> I; I \<down>> n \<noteq> {}\<rbrakk> \<Longrightarrow> iMin (I \<down>> n) \<in> I [PROOF STEP] apply (rule subsetD[OF cut_greater_subset]) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>n \<in> I; I \<down>> n \<noteq> {}\<rbrakk> \<Longrightarrow> iMin (I \<down>> n) \<in> I \<down>> ?t8 [PROOF STEP] apply (rule iMinI_ex2, assumption) [PROOF STATE] proof (prove) goal: No subgoals! [PROOF STEP] done
!=============================================================================== ! Copyright 2014-2016 Intel Corporation All Rights Reserved. ! ! The source code, information and material ("Material") contained herein is ! owned by Intel Corporation or its suppliers or licensors, and title to such ! Material remains with Intel Corporation or its suppliers or licensors. The ! Material contains proprietary information of Intel or its suppliers and ! licensors. The Material is protected by worldwide copyright laws and treaty ! provisions. No part of the Material may be used, copied, reproduced, ! modified, published, uploaded, posted, transmitted, distributed or disclosed ! in any way without Intel's prior express written permission. No license under ! any patent, copyright or other intellectual property rights in the Material ! is granted to or conferred upon you, either expressly, by implication, ! inducement, estoppel or otherwise. Any license under such intellectual ! property rights must be express and approved by Intel in writing. ! ! Unless otherwise agreed by Intel in writing, you may not remove or alter this ! notice or any other notice embedded in Materials by Intel or Intel's ! suppliers or licensors in any way. !=============================================================================== ! ! This file contains preliminary version of new SpBLAS API which supports ! two-step execution (inspector-executor) model. ! !******************************************************************************* !******************************************************************************* !*********************************** Basic types and constants ***************** !******************************************************************************* MODULE MKL_SPBLAS USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INTPTR_T, C_INT ! status of the routines ENUM, BIND(C) ENUMERATOR :: SPARSE_STATUS_SUCCESS = 0, & ! SPARSE_STATUS_NOT_INITIALIZED = 1, & ! empty handle or matrix arrays SPARSE_STATUS_ALLOC_FAILED = 2, & ! internal error: memory allocation failed SPARSE_STATUS_INVALID_VALUE = 3, & ! invalid input value SPARSE_STATUS_EXECUTION_FAILED = 4, & ! e.g. 0-diagonal element for triangular solver, etc SPARSE_STATUS_INTERNAL_ERROR = 5, & ! SPARSE_STATUS_NOT_SUPPORTED = 6 ! e.g. operation for double precision don't support other types END ENUM ! sparse matrix operations ENUM, BIND(C) ENUMERATOR :: SPARSE_OPERATION_NON_TRANSPOSE = 10, & ! SPARSE_OPERATION_TRANSPOSE = 11, & ! SPARSE_OPERATION_CONJUGATE_TRANSPOSE= 12 ! END ENUM ! supported matrix types ENUM, BIND(C) ENUMERATOR :: SPARSE_MATRIX_TYPE_GENERAL = 20, & ! general case SPARSE_MATRIX_TYPE_SYMMETRIC = 21, & ! triangular part of SPARSE_MATRIX_TYPE_HERMITIAN = 22, & ! the matrix is to be processed SPARSE_MATRIX_TYPE_TRIANGULAR = 23, & ! SPARSE_MATRIX_TYPE_DIAGONAL = 24 ! diagonal matrix; only diagonal elements should be processed END ENUM ! sparse matrix indexing: C-style or Fortran-style ENUM, BIND(C) ENUMERATOR :: SPARSE_INDEX_BASE_ZERO = 0, & ! C-style SPARSE_INDEX_BASE_ONE = 1 ! Fortran-style END ENUM ! makes sense for triangular matrices only ! ( SPARSE_MATRIX_TYPE_SYMMETRIC, SPARSE_MATRIX_TYPE_HERMITIAN, SPARSE_MATRIX_TYPE_TRIANGULAR ) ENUM, BIND(C) ENUMERATOR :: SPARSE_FILL_MODE_LOWER = 40, & ! lower triangular part of the matrix is stored SPARSE_FILL_MODE_UPPER = 41 ! upper triangular part of the matrix is stored END ENUM ! makes sense for triangular matrices only ! ( SPARSE_MATRIX_TYPE_SYMMETRIC, SPARSE_MATRIX_TYPE_HERMITIAN, SPARSE_MATRIX_TYPE_TRIANGULAR ) ENUM, BIND(C) ENUMERATOR :: SPARSE_DIAG_NON_UNIT = 50, & ! triangular matrix with non-unit diagonal SPARSE_DIAG_UNIT = 51 ! triangular matrix with unit diagonal END ENUM ! applicable for Level 3 operations with dense matrices; describes storage scheme for dense matrix (row major or column major) ENUM, BIND(C) ENUMERATOR :: SPARSE_LAYOUT_ROW_MAJOR = 60, & ! C-style SPARSE_LAYOUT_COLUMN_MAJOR = 61 ! Fortran-style END ENUM ! verbose mode; if verbose mode activated, handle should collect and report profiling / optimization info ENUM, BIND(C) ENUMERATOR :: SPARSE_VERBOSE_OFF = 70, & ! SPARSE_VERBOSE_BASIC = 71, & ! report high-level info about optimization algorithms, issues, etc. SPARSE_VERBOSE_EXTENDED = 72 ! provide detailed information END ENUM ! memory optimization hints from customer: describe how much memory could be used on optimization stage ENUM, BIND(C) ENUMERATOR :: SPARSE_MEMORY_NONE = 80, & ! no memory should be allocated for matrix values and structures ! auxiliary structures could be created only for workload balancing, ! parallelization, etc. PARSE_MEMORY_AGGRESSIVE = 81 ! matrix could be converted to any internal format END ENUM !************************************************************************************************* !*** Opaque structure for sparse matrix in internal format, further D - means double precision *** !************************************************************************************************* ! struct sparse_matrix; ! typedef struct sparse_matrix *sparse_matrix_t; TYPE, BIND(C) :: SPARSE_MATRIX_T INTEGER(C_INTPTR_T) :: PTR END TYPE SPARSE_MATRIX_T ! descriptor of main sparse matrix properties TYPE, BIND(C) :: MATRIX_DESCR INTEGER(C_INT) :: TYPE INTEGER(C_INT) :: MODE INTEGER(C_INT) :: DIAG END TYPE MATRIX_DESCR !***************************************************************************************** !*************************************** Creation routines ******************************* !***************************************************************************************** INTERFACE ! Matrix handle is used for storing information about the matrix and matrix values ! Create matrix from one of the existing sparse formats, just create the handle with matrix info and copy matrix values if ! requested ! Collect high-level info about the matrix. Need to use this interface for the case with several calls in program for ! performance reasons, where optimizations are not required ! coordinate format, ! SPARSE_MATRIX_TYPE_GENERAL by default, pointers to input arrays are stored in the handle FUNCTION MKL_SPARSE_S_CREATE_COO(A,indexing,rows,cols,nnz,row_indx,col_indx,values) & BIND(C, name='MKL_SPARSE_S_CREATE_COO') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_FLOAT IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER(C_INT), INTENT(IN) :: indexing INTEGER, INTENT(IN) :: rows INTEGER, INTENT(IN) :: cols INTEGER, INTENT(IN) :: nnz INTEGER, INTENT(IN), DIMENSION(*) :: row_indx INTEGER, INTENT(IN), DIMENSION(*) :: col_indx REAL(C_FLOAT), INTENT(IN), DIMENSION(*) :: values INTEGER(C_INT) MKL_SPARSE_S_CREATE_COO END FUNCTION FUNCTION MKL_SPARSE_D_CREATE_COO(A,indexing,rows,cols,nnz,row_indx,col_indx,values) & BIND(C, name='MKL_SPARSE_D_CREATE_COO') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER(C_INT), INTENT(IN) :: indexing INTEGER, INTENT(IN) :: rows INTEGER, INTENT(IN) :: cols INTEGER, INTENT(IN) :: nnz INTEGER, INTENT(IN), DIMENSION(*) :: row_indx INTEGER, INTENT(IN), DIMENSION(*) :: col_indx REAL(C_DOUBLE), INTENT(IN), DIMENSION(*) :: values INTEGER(C_INT) MKL_SPARSE_D_CREATE_COO END FUNCTION FUNCTION MKL_SPARSE_C_CREATE_COO(A,indexing,rows,cols,nnz,row_indx,col_indx,values) & BIND(C, name='MKL_SPARSE_C_CREATE_COO') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_FLOAT_COMPLEX IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER(C_INT), INTENT(IN) :: indexing INTEGER, INTENT(IN) :: rows INTEGER, INTENT(IN) :: cols INTEGER, INTENT(IN) :: nnz INTEGER, INTENT(IN), DIMENSION(*) :: row_indx INTEGER, INTENT(IN), DIMENSION(*) :: col_indx COMPLEX(C_FLOAT_COMPLEX), INTENT(IN), DIMENSION(*) :: values INTEGER(C_INT) MKL_SPARSE_C_CREATE_COO END FUNCTION FUNCTION MKL_SPARSE_Z_CREATE_COO(A,indexing,rows,cols,nnz,row_indx,col_indx,values) & BIND(C, name='MKL_SPARSE_Z_CREATE_COO') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE_COMPLEX IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER(C_INT), INTENT(IN) :: indexing INTEGER, INTENT(IN) :: rows INTEGER, INTENT(IN) :: cols INTEGER, INTENT(IN) :: nnz INTEGER, INTENT(IN), DIMENSION(*) :: row_indx INTEGER, INTENT(IN), DIMENSION(*) :: col_indx COMPLEX(C_DOUBLE_COMPLEX), INTENT(IN), DIMENSION(*) :: values INTEGER(C_INT) MKL_SPARSE_Z_CREATE_COO END FUNCTION ! compressed sparse row format (4-arrays version), ! SPARSE_MATRIX_TYPE_GENERAL by default, pointers to input arrays are stored in the handle FUNCTION MKL_SPARSE_S_CREATE_CSR(A,indexing,rows,cols,rows_start,rows_end,col_indx,values) & BIND(C, name='MKL_SPARSE_S_CREATE_CSR') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_FLOAT IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER(C_INT), INTENT(IN) :: indexing INTEGER, INTENT(IN) :: rows INTEGER, INTENT(IN) :: cols INTEGER, INTENT(IN), DIMENSION(*) :: rows_start INTEGER, INTENT(IN), DIMENSION(*) :: rows_end INTEGER, INTENT(IN), DIMENSION(*) :: col_indx REAL(C_FLOAT), INTENT(IN), DIMENSION(*) :: values INTEGER(C_INT) MKL_SPARSE_S_CREATE_CSR END FUNCTION FUNCTION MKL_SPARSE_D_CREATE_CSR(A,indexing,rows,cols,rows_start,rows_end,col_indx,values) & BIND(C, name='MKL_SPARSE_D_CREATE_CSR') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER(C_INT), INTENT(IN) :: indexing INTEGER, INTENT(IN) :: rows INTEGER, INTENT(IN) :: cols INTEGER, INTENT(IN), DIMENSION(*) :: rows_start INTEGER, INTENT(IN), DIMENSION(*) :: rows_end INTEGER, INTENT(IN), DIMENSION(*) :: col_indx REAL(C_DOUBLE), INTENT(IN), DIMENSION(*) :: values INTEGER(C_INT) MKL_SPARSE_D_CREATE_CSR END FUNCTION FUNCTION MKL_SPARSE_C_CREATE_CSR(A,indexing,rows,cols,rows_start,rows_end,col_indx,values) & BIND(C, name='MKL_SPARSE_C_CREATE_CSR') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_FLOAT_COMPLEX IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER(C_INT), INTENT(IN) :: indexing INTEGER, INTENT(IN) :: rows INTEGER, INTENT(IN) :: cols INTEGER, INTENT(IN), DIMENSION(*) :: rows_start INTEGER, INTENT(IN), DIMENSION(*) :: rows_end INTEGER, INTENT(IN), DIMENSION(*) :: col_indx COMPLEX(C_FLOAT_COMPLEX), INTENT(IN), DIMENSION(*) :: values INTEGER(C_INT) MKL_SPARSE_C_CREATE_CSR END FUNCTION FUNCTION MKL_SPARSE_Z_CREATE_CSR(A,indexing,rows,cols,rows_start,rows_end,col_indx,values) & BIND(C, name='MKL_SPARSE_Z_CREATE_CSR') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE_COMPLEX IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER(C_INT), INTENT(IN) :: indexing INTEGER, INTENT(IN) :: rows INTEGER, INTENT(IN) :: cols INTEGER, INTENT(IN), DIMENSION(*) :: rows_start INTEGER, INTENT(IN), DIMENSION(*) :: rows_end INTEGER, INTENT(IN), DIMENSION(*) :: col_indx COMPLEX(C_DOUBLE_COMPLEX), INTENT(IN), DIMENSION(*) :: values INTEGER(C_INT) MKL_SPARSE_Z_CREATE_CSR END FUNCTION ! compressed sparse column format (4-arrays version), ! SPARSE_MATRIX_TYPE_GENERAL by default, pointers to input arrays are stored in the handle FUNCTION MKL_SPARSE_S_CREATE_CSC(A,indexing,rows,cols,rows_start,rows_end,col_indx,values) & BIND(C, name='MKL_SPARSE_S_CREATE_CSC') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_FLOAT IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER(C_INT), INTENT(IN) :: indexing INTEGER, INTENT(IN) :: rows INTEGER, INTENT(IN) :: cols INTEGER, INTENT(IN), DIMENSION(*) :: rows_start INTEGER, INTENT(IN), DIMENSION(*) :: rows_end INTEGER, INTENT(IN), DIMENSION(*) :: col_indx REAL(C_FLOAT), INTENT(IN), DIMENSION(*) :: values INTEGER(C_INT) MKL_SPARSE_S_CREATE_CSC END FUNCTION FUNCTION MKL_SPARSE_D_CREATE_CSC(A,indexing,rows,cols,rows_start,rows_end,col_indx,values) & BIND(C, name='MKL_SPARSE_D_CREATE_CSC') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER(C_INT), INTENT(IN) :: indexing INTEGER, INTENT(IN) :: rows INTEGER, INTENT(IN) :: cols INTEGER, INTENT(IN), DIMENSION(*) :: rows_start INTEGER, INTENT(IN), DIMENSION(*) :: rows_end INTEGER, INTENT(IN), DIMENSION(*) :: col_indx REAL(C_DOUBLE), INTENT(IN), DIMENSION(*) :: values INTEGER(C_INT) MKL_SPARSE_D_CREATE_CSC END FUNCTION FUNCTION MKL_SPARSE_C_CREATE_CSC(A,indexing,rows,cols,rows_start,rows_end,col_indx,values) & BIND(C, name='MKL_SPARSE_C_CREATE_CSC') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_FLOAT_COMPLEX IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER(C_INT), INTENT(IN) :: indexing INTEGER, INTENT(IN) :: rows INTEGER, INTENT(IN) :: cols INTEGER, INTENT(IN), DIMENSION(*) :: rows_start INTEGER, INTENT(IN), DIMENSION(*) :: rows_end INTEGER, INTENT(IN), DIMENSION(*) :: col_indx COMPLEX(C_FLOAT_COMPLEX), INTENT(IN), DIMENSION(*) :: values INTEGER(C_INT) MKL_SPARSE_C_CREATE_CSC END FUNCTION FUNCTION MKL_SPARSE_Z_CREATE_CSC(A,indexing,rows,cols,rows_start,rows_end,col_indx,values) & BIND(C, name='MKL_SPARSE_Z_CREATE_CSC') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE_COMPLEX IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER(C_INT), INTENT(IN) :: indexing INTEGER, INTENT(IN) :: rows INTEGER, INTENT(IN) :: cols INTEGER, INTENT(IN), DIMENSION(*) :: rows_start INTEGER, INTENT(IN), DIMENSION(*) :: rows_end INTEGER, INTENT(IN), DIMENSION(*) :: col_indx COMPLEX(C_DOUBLE_COMPLEX), INTENT(IN), DIMENSION(*) :: values INTEGER(C_INT) MKL_SPARSE_Z_CREATE_CSC END FUNCTION ! compressed block sparse row format (4-arrays version, square blocks), ! SPARSE_MATRIX_TYPE_GENERAL by default, pointers to input arrays are stored in the handle FUNCTION MKL_SPARSE_S_CREATE_BSR(A,indexing,block_layout,rows,cols,block_size,rows_start,rows_end,col_indx,values) & BIND(C, name='MKL_SPARSE_S_CREATE_BSR') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_FLOAT IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER(C_INT), INTENT(IN) :: indexing INTEGER(C_INT), INTENT(IN) :: block_layout INTEGER, INTENT(IN) :: rows INTEGER, INTENT(IN) :: cols INTEGER, INTENT(IN) :: block_size INTEGER, INTENT(IN), DIMENSION(*) :: rows_start INTEGER, INTENT(IN), DIMENSION(*) :: rows_end INTEGER, INTENT(IN), DIMENSION(*) :: col_indx REAL(C_FLOAT), INTENT(IN), DIMENSION(*) :: values INTEGER(C_INT) MKL_SPARSE_S_CREATE_BSR END FUNCTION FUNCTION MKL_SPARSE_D_CREATE_BSR(A,indexing,block_layout,rows,cols,block_size,rows_start,rows_end,col_indx,values) & BIND(C, name='MKL_SPARSE_D_CREATE_BSR') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER(C_INT), INTENT(IN) :: indexing INTEGER(C_INT), INTENT(IN) :: block_layout INTEGER, INTENT(IN) :: rows INTEGER, INTENT(IN) :: cols INTEGER, INTENT(IN) :: block_size INTEGER, INTENT(IN), DIMENSION(*) :: rows_start INTEGER, INTENT(IN), DIMENSION(*) :: rows_end INTEGER, INTENT(IN), DIMENSION(*) :: col_indx REAL(C_DOUBLE), INTENT(IN), DIMENSION(*) :: values INTEGER(C_INT) MKL_SPARSE_D_CREATE_BSR END FUNCTION FUNCTION MKL_SPARSE_C_CREATE_BSR(A,indexing,block_layout,rows,cols,block_size,rows_start,rows_end,col_indx,values) & BIND(C, name='MKL_SPARSE_C_CREATE_BSR') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_FLOAT_COMPLEX IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER(C_INT), INTENT(IN) :: indexing INTEGER(C_INT), INTENT(IN) :: block_layout INTEGER, INTENT(IN) :: rows INTEGER, INTENT(IN) :: cols INTEGER, INTENT(IN) :: block_size INTEGER, INTENT(IN), DIMENSION(*) :: rows_start INTEGER, INTENT(IN), DIMENSION(*) :: rows_end INTEGER, INTENT(IN), DIMENSION(*) :: col_indx COMPLEX(C_FLOAT_COMPLEX), INTENT(IN), DIMENSION(*) :: values INTEGER(C_INT) MKL_SPARSE_C_CREATE_BSR END FUNCTION FUNCTION MKL_SPARSE_Z_CREATE_BSR(A,indexing,block_layout,rows,cols,block_size,rows_start,rows_end,col_indx,values) & BIND(C, name='MKL_SPARSE_Z_CREATE_BSR') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE_COMPLEX IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER(C_INT), INTENT(IN) :: indexing INTEGER(C_INT), INTENT(IN) :: block_layout INTEGER, INTENT(IN) :: rows INTEGER, INTENT(IN) :: cols INTEGER, INTENT(IN) :: block_size INTEGER, INTENT(IN), DIMENSION(*) :: rows_start INTEGER, INTENT(IN), DIMENSION(*) :: rows_end INTEGER, INTENT(IN), DIMENSION(*) :: col_indx COMPLEX(C_DOUBLE_COMPLEX), INTENT(IN), DIMENSION(*) :: values INTEGER(C_INT) MKL_SPARSE_Z_CREATE_BSR END FUNCTION ! Create copy of the existing handle; matrix properties could be changed. ! For example it could be used for extracting triangular or diagonal parts from existing matrix. FUNCTION MKL_SPARSE_COPY(source,descr,dest) & BIND(C, name='MKL_SPARSE_COPY') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT IMPORT SPARSE_MATRIX_T IMPORT MATRIX_DESCR TYPE(SPARSE_MATRIX_T), INTENT(IN) :: source TYPE(MATRIX_DESCR) , INTENT(IN) :: descr TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: dest INTEGER(C_INT) MKL_SPARSE_COPY END FUNCTION ! destroy matrix handle; if sparse matrix was stored inside the handle it also deallocates the matrix ! It is customer responsibility not to delete the handle with the matrix, if this matrix is shared with other handles FUNCTION MKL_SPARSE_DESTROY(A) & BIND(C, name='MKL_SPARSE_DESTROY') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER(C_INT) MKL_SPARSE_DESTROY END FUNCTION ! return extended error information from last operation; ! eg. info about wrong input parameter, memory sizes that couldn't be allocated, etc. FUNCTION MKL_SPARSE_GET_ERROR_INFO(A,info) & BIND(C, name='MKL_SPARSE_GET_ERROR_INFO') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER, INTENT(IN), DIMENSION(*) :: info INTEGER(C_INT) MKL_SPARSE_GET_ERROR_INFO END FUNCTION !**************************************************************************************** !************************ Converters of internal representation ************************ !**************************************************************************************** ! converters from current format to another ! convert original matrix to CSR representation FUNCTION MKL_SPARSE_CONVERT_CSR(source,operation,dest) & BIND(C, name='MKL_SPARSE_CONVERT_CSR') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(IN) :: source INTEGER(C_INT) , INTENT(IN) :: operation ! as is, transposed or conjugate transposed TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: dest INTEGER(C_INT) MKL_SPARSE_CONVERT_CSR END FUNCTION ! convert original matrix to BSR representation FUNCTION MKL_SPARSE_CONVERT_BSR(source,block_size,block_layout,operation,dest) & BIND(C, name='MKL_SPARSE_CONVERT_BSR') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(IN) :: source INTEGER , INTENT(IN) :: block_size INTEGER(C_INT) , INTENT(IN) :: block_layout ! block storage: row-major or column-major INTEGER(C_INT) , INTENT(IN) :: operation ! as is, transposed or conjugate transposed TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: dest INTEGER(C_INT) MKL_SPARSE_CONVERT_BSR END FUNCTION FUNCTION MKL_SPARSE_S_EXPORT_BSR(source,indexing,block_layout,rows,cols,block_size,rows_start,rows_end,col_indx,values) & BIND(C, name='MKL_SPARSE_S_EXPORT_BSR') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_FLOAT IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(IN) :: source INTEGER(C_INT) , INTENT(INOUT) :: indexing INTEGER(C_INT) , INTENT(INOUT) :: block_layout INTEGER(C_INT) , INTENT(INOUT) :: rows INTEGER(C_INT) , INTENT(INOUT) :: cols INTEGER(C_INT) , INTENT(INOUT) :: block_size INTEGER, INTENT(INOUT), DIMENSION(*) :: rows_start INTEGER, INTENT(INOUT), DIMENSION(*) :: rows_end INTEGER, INTENT(INOUT), DIMENSION(*) :: col_indx REAL(C_FLOAT), INTENT(INOUT), DIMENSION(*) :: values INTEGER(C_INT) MKL_SPARSE_S_EXPORT_BSR END FUNCTION FUNCTION MKL_SPARSE_D_EXPORT_BSR(source,indexing,block_layout,rows,cols,block_size,rows_start,rows_end,col_indx,values) & BIND(C, name='MKL_SPARSE_D_EXPORT_BSR') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T) , INTENT(IN) :: source INTEGER(C_INT) , INTENT(INOUT) :: indexing INTEGER(C_INT) , INTENT(INOUT) :: block_layout INTEGER(C_INT) , INTENT(INOUT) :: rows INTEGER(C_INT) , INTENT(INOUT) :: cols INTEGER(C_INT) , INTENT(INOUT) :: block_size INTEGER, INTENT(INOUT), DIMENSION(*) :: rows_start INTEGER, INTENT(INOUT), DIMENSION(*) :: rows_end INTEGER, INTENT(INOUT), DIMENSION(*) :: col_indx REAL(C_DOUBLE), INTENT(INOUT), DIMENSION(*) :: values INTEGER(C_INT) MKL_SPARSE_D_EXPORT_BSR END FUNCTION FUNCTION MKL_SPARSE_C_EXPORT_BSR(source,indexing,block_layout,rows,cols,block_size,rows_start,rows_end,col_indx,values) & BIND(C, name='MKL_SPARSE_C_EXPORT_BSR') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_FLOAT_COMPLEX IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T) , INTENT(IN) :: source INTEGER(C_INT) , INTENT(INOUT) :: indexing INTEGER(C_INT) , INTENT(INOUT) :: block_layout INTEGER(C_INT) , INTENT(INOUT) :: rows INTEGER(C_INT) , INTENT(INOUT) :: cols INTEGER(C_INT) , INTENT(INOUT) :: block_size INTEGER, INTENT(INOUT), DIMENSION(*) :: rows_start INTEGER, INTENT(INOUT), DIMENSION(*) :: rows_end INTEGER, INTENT(INOUT), DIMENSION(*) :: col_indx COMPLEX(C_FLOAT_COMPLEX), INTENT(INOUT), DIMENSION(*) :: values INTEGER(C_INT) MKL_SPARSE_C_EXPORT_BSR END FUNCTION FUNCTION MKL_SPARSE_Z_EXPORT_BSR(source,indexing,block_layout,rows,cols,block_size,rows_start,rows_end,col_indx,values) & BIND(C, name='MKL_SPARSE_Z_EXPORT_BSR') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE_COMPLEX IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T) , INTENT(IN) :: source INTEGER(C_INT) , INTENT(INOUT) :: indexing INTEGER(C_INT) , INTENT(INOUT) :: block_layout INTEGER(C_INT) , INTENT(INOUT) :: rows INTEGER(C_INT) , INTENT(INOUT) :: cols INTEGER(C_INT) , INTENT(INOUT) :: block_size INTEGER, INTENT(INOUT), DIMENSION(*) :: rows_start INTEGER, INTENT(INOUT), DIMENSION(*) :: rows_end INTEGER, INTENT(INOUT), DIMENSION(*) :: col_indx COMPLEX(C_DOUBLE_COMPLEX), INTENT(INOUT), DIMENSION(*) :: values INTEGER(C_INT) MKL_SPARSE_Z_EXPORT_BSR END FUNCTION FUNCTION MKL_SPARSE_S_EXPORT_CSR(source,indexing,rows,cols,rows_start,rows_end,col_indx,values) & BIND(C, name='MKL_SPARSE_S_EXPORT_CSR') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_FLOAT IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(IN) :: source INTEGER(C_INT) , INTENT(INOUT) :: indexing INTEGER(C_INT) , INTENT(INOUT) :: rows INTEGER(C_INT) , INTENT(INOUT) :: cols INTEGER, INTENT(INOUT), DIMENSION(*) :: rows_start INTEGER, INTENT(INOUT), DIMENSION(*) :: rows_end INTEGER, INTENT(INOUT), DIMENSION(*) :: col_indx REAL(C_FLOAT), INTENT(INOUT), DIMENSION(*) :: values INTEGER(C_INT) MKL_SPARSE_S_EXPORT_CSR END FUNCTION FUNCTION MKL_SPARSE_D_EXPORT_CSR(source,indexing,rows,cols,rows_start,rows_end,col_indx,values) & BIND(C, name='MKL_SPARSE_D_EXPORT_CSR') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(IN) :: source INTEGER(C_INT) , INTENT(INOUT) :: indexing INTEGER(C_INT) , INTENT(INOUT) :: rows INTEGER(C_INT) , INTENT(INOUT) :: cols INTEGER, INTENT(INOUT), DIMENSION(*) :: rows_start INTEGER, INTENT(INOUT), DIMENSION(*) :: rows_end INTEGER, INTENT(INOUT), DIMENSION(*) :: col_indx REAL(C_DOUBLE), INTENT(INOUT), DIMENSION(*) :: values INTEGER(C_INT) MKL_SPARSE_D_EXPORT_CSR END FUNCTION FUNCTION MKL_SPARSE_C_EXPORT_CSR(source,indexing,rows,cols,rows_start,rows_end,col_indx,values) & BIND(C, name='MKL_SPARSE_C_EXPORT_CSR') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_FLOAT_COMPLEX IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(IN) :: source INTEGER(C_INT) , INTENT(INOUT) :: indexing INTEGER(C_INT) , INTENT(INOUT) :: rows INTEGER(C_INT) , INTENT(INOUT) :: cols INTEGER, INTENT(INOUT), DIMENSION(*) :: rows_start INTEGER, INTENT(INOUT), DIMENSION(*) :: rows_end INTEGER, INTENT(INOUT), DIMENSION(*) :: col_indx COMPLEX(C_FLOAT_COMPLEX), INTENT(INOUT), DIMENSION(*) :: values INTEGER(C_INT) MKL_SPARSE_C_EXPORT_CSR END FUNCTION FUNCTION MKL_SPARSE_Z_EXPORT_CSR(source,indexing,rows,cols,rows_start,rows_end,col_indx,values) & BIND(C, name='MKL_SPARSE_Z_EXPORT_CSR') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE_COMPLEX IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T) , INTENT(IN) :: source INTEGER(C_INT) , INTENT(INOUT) :: indexing INTEGER(C_INT) , INTENT(INOUT) :: rows INTEGER(C_INT) , INTENT(INOUT) :: cols INTEGER, INTENT(INOUT), DIMENSION(*) :: rows_start INTEGER, INTENT(INOUT), DIMENSION(*) :: rows_end INTEGER, INTENT(INOUT), DIMENSION(*) :: col_indx COMPLEX(C_DOUBLE_COMPLEX), INTENT(INOUT), DIMENSION(*) :: values INTEGER(C_INT) MKL_SPARSE_Z_EXPORT_CSR END FUNCTION !**************************************************************************************** !************************** Step-by-step modification routines ************************** !**************************************************************************************** ! update existing value in the matrix ! ( for internal storage only, should not work with customer-allocated matrices) FUNCTION MKL_SPARSE_S_SET_VALUE(A,row,col,value) & BIND(C, name='MKL_SPARSE_S_SET_VALUE') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_FLOAT IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER, INTENT(IN) :: row INTEGER, INTENT(IN) :: col REAL(C_FLOAT) , INTENT(IN) :: value INTEGER(C_INT) MKL_SPARSE_S_SET_VALUE END FUNCTION FUNCTION MKL_SPARSE_D_SET_VALUE(A,row,col,value) & BIND(C, name='MKL_SPARSE_D_SET_VALUE') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER, INTENT(IN) :: row INTEGER, INTENT(IN) :: col REAL(C_DOUBLE) , INTENT(IN) :: value INTEGER(C_INT) MKL_SPARSE_D_SET_VALUE END FUNCTION FUNCTION MKL_SPARSE_C_SET_VALUE(A,row,col,value) & BIND(C, name='MKL_SPARSE_C_SET_VALUE') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_FLOAT_COMPLEX IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER, INTENT(IN) :: row INTEGER, INTENT(IN) :: col COMPLEX(C_FLOAT_COMPLEX) , INTENT(IN) :: value INTEGER(C_INT) MKL_SPARSE_C_SET_VALUE END FUNCTION FUNCTION MKL_SPARSE_Z_SET_VALUE(A,row,col,value) & BIND(C, name='MKL_SPARSE_Z_SET_VALUE') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE_COMPLEX IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER, INTENT(IN) :: row INTEGER, INTENT(IN) :: col COMPLEX(C_DOUBLE_COMPLEX) , INTENT(IN) :: value INTEGER(C_INT) MKL_SPARSE_Z_SET_VALUE END FUNCTION !**************************************************************************************** !****************************** Verbose mode routine ************************************ !**************************************************************************************** ! allow to switch on/off verbose mode FUNCTION MKL_SPARSE_SET_VERBOSE_MODE(verbose) & BIND(C, name='MKL_SPARSE_SET_VERBOSE_MODE') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT INTEGER(C_INT), INTENT(IN) :: verbose INTEGER(C_INT) MKL_SPARSE_SET_VERBOSE_MODE END FUNCTION !**************************************************************************************** !****************************** Optimization routines *********************************** !**************************************************************************************** ! Describe expected operations with amount of iterations FUNCTION MKL_SPARSE_SET_MV_HINT(A,operation,descr,expected_calls) & BIND(C, name='MKL_SPARSE_SET_MV_HINT') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT IMPORT SPARSE_MATRIX_T IMPORT MATRIX_DESCR TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER(C_INT) , INTENT(IN) :: operation ! SPARSE_OPERATION_NON_TRANSPOSE is default value for ! infinite amount of calls TYPE(MATRIX_DESCR) , INTENT(IN) :: descr ! sparse_matrix_type_t + sparse_fill_mode_t + sparse_diag_type_t INTEGER , INTENT(IN) :: expected_calls INTEGER(C_INT) MKL_SPARSE_SET_MV_HINT END FUNCTION FUNCTION MKL_SPARSE_SET_MM_HINT(A,operation,descr,layout,dense_matrix_size,expected_calls) & BIND(C, name='MKL_SPARSE_SET_MM_HINT') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT IMPORT SPARSE_MATRIX_T IMPORT MATRIX_DESCR TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER(C_INT) , INTENT(IN) :: operation TYPE(MATRIX_DESCR) , INTENT(IN) :: descr ! sparse_matrix_type_t + sparse_fill_mode_t + sparse_diag_type_t INTEGER(C_INT) , INTENT(IN) :: layout ! storage scheme for the dense matrix: C-style or Fortran-style INTEGER , INTENT(IN) :: dense_matrix_size ! amount of columns in dense matrix INTEGER , INTENT(IN) :: expected_calls INTEGER(C_INT) MKL_SPARSE_SET_MM_HINT END FUNCTION FUNCTION MKL_SPARSE_SET_SV_HINT(A,operation,descr,expected_calls) & BIND(C, name='MKL_SPARSE_SET_SV_HINT') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT IMPORT SPARSE_MATRIX_T IMPORT MATRIX_DESCR TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER(C_INT) , INTENT(IN) :: operation ! SPARSE_OPERATION_NON_TRANSPOSE is default value for ! infinite amount of calls TYPE(MATRIX_DESCR) , INTENT(IN) :: descr ! sparse_matrix_type_t + sparse_fill_mode_t + sparse_diag_type_t INTEGER , INTENT(IN) :: expected_calls INTEGER(C_INT) MKL_SPARSE_SET_SV_HINT END FUNCTION FUNCTION MKL_SPARSE_SET_SM_HINT(A,operation,descr,layout,dense_matrix_size,expected_calls) & BIND(C, name='MKL_SPARSE_SET_SM_HINT') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT IMPORT SPARSE_MATRIX_T IMPORT MATRIX_DESCR TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER(C_INT) , INTENT(IN) :: operation TYPE(MATRIX_DESCR) , INTENT(IN) :: descr ! sparse_matrix_type_t + sparse_fill_mode_t + sparse_diag_type_t INTEGER(C_INT) , INTENT(IN) :: layout ! storage scheme for the dense matrix: C-style or Fortran-style INTEGER , INTENT(IN) :: dense_matrix_size ! amount of columns in dense matrix INTEGER , INTENT(IN) :: expected_calls INTEGER(C_INT) MKL_SPARSE_SET_SM_HINT END FUNCTION FUNCTION MKL_SPARSE_SET_MEMORY_HINT(A,policy) & BIND(C, name='MKL_SPARSE_SET_MEMORY_HINT') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER(C_INT) , INTENT(IN) :: policy ! SPARSE_MEMORY_AGGRESSIVE is default value INTEGER(C_INT) MKL_SPARSE_SET_MEMORY_HINT END FUNCTION ! optimize matrix described by the handle. It uses hints (optimization and memory) that should be set up before this call. ! if hints were not explicitly defined, default vales are: ! SPARSE_OPERATION_NON_TRANSPOSE for matrix-vector multiply with infinite amount of expected iterations FUNCTION MKL_SPARSE_OPTIMIZE(A) & BIND(C, name='MKL_SPARSE_OPTIMIZE') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT IMPORT SPARSE_MATRIX_T TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: A INTEGER(C_INT) MKL_SPARSE_OPTIMIZE END FUNCTION !**************************************************************************************** !****************************** Computational routines ********************************** !**************************************************************************************** ! Perform computations based on created matrix handle ! Level 2 ! Computes y = alpha * A * x + beta * y FUNCTION MKL_SPARSE_S_MV(operation,alpha,A,descr,x,beta,y) & BIND(C, name='MKL_SPARSE_S_MV') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_FLOAT IMPORT SPARSE_MATRIX_T IMPORT MATRIX_DESCR INTEGER(C_INT) , INTENT(IN) :: operation REAL(C_FLOAT) , INTENT(IN) :: alpha TYPE(SPARSE_MATRIX_T), INTENT(IN) :: A TYPE(MATRIX_DESCR) , INTENT(IN) :: descr ! sparse_matrix_type_t + sparse_fill_mode_t + sparse_diag_type_t REAL(C_FLOAT), INTENT(IN), DIMENSION(*) :: x REAL(C_FLOAT) , INTENT(IN) :: beta REAL(C_FLOAT), INTENT(INOUT), DIMENSION(*) :: y INTEGER(C_INT) MKL_SPARSE_S_MV END FUNCTION FUNCTION MKL_SPARSE_D_MV(operation,alpha,A,descr,x,beta,y) & BIND(C, name='MKL_SPARSE_D_MV') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE IMPORT SPARSE_MATRIX_T IMPORT MATRIX_DESCR INTEGER(C_INT) , INTENT(IN) :: operation REAL(C_DOUBLE) , INTENT(IN) :: alpha TYPE(SPARSE_MATRIX_T), INTENT(IN) :: A TYPE(MATRIX_DESCR) , INTENT(IN) :: descr ! sparse_matrix_type_t + sparse_fill_mode_t + sparse_diag_type_t REAL(C_DOUBLE), INTENT(IN), DIMENSION(*) :: x REAL(C_DOUBLE) , INTENT(IN) :: beta REAL(C_DOUBLE), INTENT(INOUT), DIMENSION(*) :: y INTEGER(C_INT) MKL_SPARSE_D_MV END FUNCTION FUNCTION MKL_SPARSE_C_MV(operation,alpha,A,descr,x,beta,y) & BIND(C, name='MKL_SPARSE_C_MV') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_FLOAT, C_FLOAT_COMPLEX IMPORT SPARSE_MATRIX_T IMPORT MATRIX_DESCR INTEGER(C_INT) , INTENT(IN) :: operation COMPLEX(C_FLOAT_COMPLEX), INTENT(IN) :: alpha TYPE(SPARSE_MATRIX_T) , INTENT(IN) :: A TYPE(MATRIX_DESCR) , INTENT(IN) :: descr ! sparse_matrix_type_t + sparse_fill_mode_t + sparse_diag_type_t COMPLEX(C_FLOAT_COMPLEX), INTENT(IN), DIMENSION(*) :: x COMPLEX(C_FLOAT_COMPLEX), INTENT(IN) :: beta COMPLEX(C_FLOAT_COMPLEX), INTENT(INOUT), DIMENSION(*) :: y INTEGER(C_INT) MKL_SPARSE_C_MV END FUNCTION FUNCTION MKL_SPARSE_Z_MV(operation,alpha,A,descr,x,beta,y) & BIND(C, name='MKL_SPARSE_Z_MV') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE_COMPLEX IMPORT SPARSE_MATRIX_T IMPORT MATRIX_DESCR INTEGER(C_INT) , INTENT(IN) :: operation COMPLEX(C_DOUBLE_COMPLEX), INTENT(IN) :: alpha TYPE(SPARSE_MATRIX_T), INTENT(IN) :: A TYPE(MATRIX_DESCR) , INTENT(IN) :: descr ! sparse_matrix_type_t + sparse_fill_mode_t + sparse_diag_type_t COMPLEX(C_DOUBLE_COMPLEX), INTENT(IN), DIMENSION(*) :: x COMPLEX(C_DOUBLE_COMPLEX), INTENT(IN) :: beta COMPLEX(C_DOUBLE_COMPLEX), INTENT(INOUT), DIMENSION(*) :: y INTEGER(C_INT) MKL_SPARSE_Z_MV END FUNCTION ! Solves triangular system y = alpha * A^{-1} * x FUNCTION MKL_SPARSE_S_TRSV(operation,alpha,A,descr,x,y) & BIND(C, name='MKL_SPARSE_S_TRSV') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_FLOAT IMPORT SPARSE_MATRIX_T IMPORT MATRIX_DESCR INTEGER(C_INT) , INTENT(IN) :: operation REAL(C_FLOAT) , INTENT(IN) :: alpha TYPE(SPARSE_MATRIX_T), INTENT(IN) :: A TYPE(MATRIX_DESCR) , INTENT(IN) :: descr ! sparse_matrix_type_t + sparse_fill_mode_t + sparse_diag_type_t REAL(C_FLOAT), INTENT(IN), DIMENSION(*) :: x REAL(C_FLOAT), INTENT(INOUT), DIMENSION(*) :: y INTEGER(C_INT) MKL_SPARSE_S_TRSV END FUNCTION FUNCTION MKL_SPARSE_D_TRSV(operation,alpha,A,descr,x,y) & BIND(C, name='MKL_SPARSE_D_TRSV') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE IMPORT SPARSE_MATRIX_T IMPORT MATRIX_DESCR INTEGER(C_INT) , INTENT(IN) :: operation REAL(C_DOUBLE) , INTENT(IN) :: alpha TYPE(SPARSE_MATRIX_T), INTENT(IN) :: A TYPE(MATRIX_DESCR) , INTENT(IN) :: descr ! sparse_matrix_type_t + sparse_fill_mode_t + sparse_diag_type_t REAL(C_DOUBLE), INTENT(IN), DIMENSION(*) :: x REAL(C_DOUBLE), INTENT(INOUT), DIMENSION(*) :: y INTEGER(C_INT) MKL_SPARSE_D_TRSV END FUNCTION FUNCTION MKL_SPARSE_C_TRSV(operation,alpha,A,descr,x,y) & BIND(C, name='MKL_SPARSE_C_TRSV') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_FLOAT_COMPLEX IMPORT SPARSE_MATRIX_T IMPORT MATRIX_DESCR INTEGER(C_INT) , INTENT(IN) :: operation COMPLEX(C_FLOAT_COMPLEX), INTENT(IN) :: alpha TYPE(SPARSE_MATRIX_T) , INTENT(IN) :: A TYPE(MATRIX_DESCR) , INTENT(IN) :: descr ! sparse_matrix_type_t + sparse_fill_mode_t + sparse_diag_type_t COMPLEX(C_FLOAT_COMPLEX), INTENT(IN), DIMENSION(*) :: x COMPLEX(C_FLOAT_COMPLEX), INTENT(INOUT), DIMENSION(*) :: y INTEGER(C_INT) MKL_SPARSE_C_TRSV END FUNCTION FUNCTION MKL_SPARSE_Z_TRSV(operation,alpha,A,descr,x,y) & BIND(C, name='MKL_SPARSE_Z_TRSV') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE_COMPLEX IMPORT SPARSE_MATRIX_T IMPORT MATRIX_DESCR INTEGER(C_INT) , INTENT(IN) :: operation COMPLEX(C_DOUBLE_COMPLEX), INTENT(IN) :: alpha TYPE(SPARSE_MATRIX_T) , INTENT(IN) :: A TYPE(MATRIX_DESCR) , INTENT(IN) :: descr ! sparse_matrix_type_t + sparse_fill_mode_t + sparse_diag_type_t COMPLEX(C_DOUBLE_COMPLEX), INTENT(IN), DIMENSION(*) :: x COMPLEX(C_DOUBLE_COMPLEX), INTENT(INOUT), DIMENSION(*) :: y INTEGER(C_INT) MKL_SPARSE_Z_TRSV END FUNCTION ! Level 3 ! Computes y = alpha * A * x + beta * y FUNCTION MKL_SPARSE_S_MM(operation,alpha,A,descr,layout,x,columns,ldx,beta,y,ldy) & BIND(C, name='MKL_SPARSE_S_MM') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_FLOAT IMPORT SPARSE_MATRIX_T IMPORT MATRIX_DESCR INTEGER(C_INT) , INTENT(IN) :: operation REAL(C_FLOAT) , INTENT(IN) :: alpha TYPE(SPARSE_MATRIX_T), INTENT(IN) :: A TYPE(MATRIX_DESCR) , INTENT(IN) :: descr ! sparse_matrix_type_t + sparse_fill_mode_t + sparse_diag_type_t INTEGER(C_INT) , INTENT(IN) :: layout ! storage scheme for the dense matrix: C-style or Fortran-style REAL(C_FLOAT), INTENT(IN), DIMENSION(*) :: x INTEGER , INTENT(IN) :: columns INTEGER , INTENT(IN) :: ldx REAL(C_FLOAT) , INTENT(IN) :: beta REAL(C_FLOAT), INTENT(INOUT), DIMENSION(*) :: y INTEGER , INTENT(IN) :: ldy INTEGER(C_INT) MKL_SPARSE_S_MM END FUNCTION FUNCTION MKL_SPARSE_D_MM(operation,alpha,A,descr,layout,x,columns,ldx,beta,y,ldy) & BIND(C, name='MKL_SPARSE_D_MM') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE IMPORT SPARSE_MATRIX_T IMPORT MATRIX_DESCR INTEGER(C_INT) , INTENT(IN) :: operation REAL(C_DOUBLE) , INTENT(IN) :: alpha TYPE(SPARSE_MATRIX_T), INTENT(IN) :: A TYPE(MATRIX_DESCR) , INTENT(IN) :: descr ! sparse_matrix_type_t + sparse_fill_mode_t + sparse_diag_type_t INTEGER(C_INT) , INTENT(IN) :: layout ! storage scheme for the dense matrix: C-style or Fortran-style REAL(C_DOUBLE), INTENT(IN), DIMENSION(*) :: x INTEGER , INTENT(IN) :: columns INTEGER , INTENT(IN) :: ldx REAL(C_DOUBLE) , INTENT(IN) :: beta REAL(C_DOUBLE), INTENT(INOUT), DIMENSION(*) :: y INTEGER , INTENT(IN) :: ldy INTEGER(C_INT) MKL_SPARSE_D_MM END FUNCTION FUNCTION MKL_SPARSE_C_MM(operation,alpha,A,descr,layout,x,columns,ldx,beta,y,ldy) & BIND(C, name='MKL_SPARSE_C_MM') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_FLOAT_COMPLEX IMPORT SPARSE_MATRIX_T IMPORT MATRIX_DESCR INTEGER(C_INT) , INTENT(IN) :: operation COMPLEX(C_FLOAT_COMPLEX) , INTENT(IN) :: alpha TYPE(SPARSE_MATRIX_T), INTENT(IN) :: A TYPE(MATRIX_DESCR) , INTENT(IN) :: descr ! sparse_matrix_type_t + sparse_fill_mode_t + sparse_diag_type_t INTEGER(C_INT) , INTENT(IN) :: layout ! storage scheme for the dense matrix: C-style or Fortran-style COMPLEX(C_FLOAT_COMPLEX), INTENT(IN), DIMENSION(*) :: x INTEGER , INTENT(IN) :: columns INTEGER , INTENT(IN) :: ldx COMPLEX(C_FLOAT_COMPLEX) , INTENT(IN) :: beta COMPLEX(C_FLOAT_COMPLEX), INTENT(INOUT), DIMENSION(*) :: y INTEGER , INTENT(IN) :: ldy INTEGER(C_INT) MKL_SPARSE_C_MM END FUNCTION FUNCTION MKL_SPARSE_Z_MM(operation,alpha,A,descr,layout,x,columns,ldx,beta,y,ldy) & BIND(C, name='MKL_SPARSE_Z_MM') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE_COMPLEX IMPORT SPARSE_MATRIX_T IMPORT MATRIX_DESCR INTEGER(C_INT) , INTENT(IN) :: operation COMPLEX(C_DOUBLE_COMPLEX) , INTENT(IN) :: alpha TYPE(SPARSE_MATRIX_T), INTENT(IN) :: A TYPE(MATRIX_DESCR) , INTENT(IN) :: descr ! sparse_matrix_type_t + sparse_fill_mode_t + sparse_diag_type_t INTEGER(C_INT) , INTENT(IN) :: layout ! storage scheme for the dense matrix: C-style or Fortran-style COMPLEX(C_DOUBLE_COMPLEX), INTENT(IN), DIMENSION(*) :: x INTEGER , INTENT(IN) :: columns INTEGER , INTENT(IN) :: ldx COMPLEX(C_DOUBLE_COMPLEX) , INTENT(IN) :: beta COMPLEX(C_DOUBLE_COMPLEX), INTENT(INOUT), DIMENSION(*) :: y INTEGER , INTENT(IN) :: ldy INTEGER(C_INT) MKL_SPARSE_Z_MM END FUNCTION ! Solves triangular system y = alpha * A^{-1} * x FUNCTION MKL_SPARSE_S_TRSM(operation,alpha,A,descr,layout,x,columns,ldx,y,ldy) & BIND(C, name='MKL_SPARSE_S_TRSM') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_FLOAT IMPORT SPARSE_MATRIX_T IMPORT MATRIX_DESCR INTEGER(C_INT) , INTENT(IN) :: operation REAL(C_FLOAT) , INTENT(IN) :: alpha TYPE(SPARSE_MATRIX_T), INTENT(IN) :: A TYPE(MATRIX_DESCR) , INTENT(IN) :: descr ! sparse_matrix_type_t + sparse_fill_mode_t + sparse_diag_type_t INTEGER(C_INT) , INTENT(IN) :: layout ! storage scheme for the dense matrix: C-style or Fortran-style REAL(C_FLOAT), INTENT(IN), DIMENSION(*) :: x INTEGER , INTENT(IN) :: columns INTEGER , INTENT(IN) :: ldx REAL(C_FLOAT), INTENT(INOUT), DIMENSION(*) :: y INTEGER , INTENT(IN) :: ldy INTEGER(C_INT) MKL_SPARSE_S_TRSM END FUNCTION FUNCTION MKL_SPARSE_D_TRSM(operation,alpha,A,descr,layout,x,columns,ldx,y,ldy) & BIND(C, name='MKL_SPARSE_D_TRSM') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE IMPORT SPARSE_MATRIX_T IMPORT MATRIX_DESCR INTEGER(C_INT) , INTENT(IN) :: operation REAL(C_DOUBLE) , INTENT(IN) :: alpha TYPE(SPARSE_MATRIX_T), INTENT(IN) :: A TYPE(MATRIX_DESCR) , INTENT(IN) :: descr ! sparse_matrix_type_t + sparse_fill_mode_t + sparse_diag_type_t INTEGER(C_INT) , INTENT(IN) :: layout ! storage scheme for the dense matrix: C-style or Fortran-style REAL(C_DOUBLE), INTENT(IN), DIMENSION(*) :: x INTEGER , INTENT(IN) :: columns INTEGER , INTENT(IN) :: ldx REAL(C_DOUBLE), INTENT(INOUT), DIMENSION(*) :: y INTEGER , INTENT(IN) :: ldy INTEGER(C_INT) MKL_SPARSE_D_TRSM END FUNCTION FUNCTION MKL_SPARSE_C_TRSM(operation,alpha,A,descr,layout,x,columns,ldx,y,ldy) & BIND(C, name='MKL_SPARSE_C_TRSM') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_FLOAT_COMPLEX IMPORT SPARSE_MATRIX_T IMPORT MATRIX_DESCR INTEGER(C_INT) , INTENT(IN) :: operation COMPLEX(C_FLOAT_COMPLEX), INTENT(IN) :: alpha TYPE(SPARSE_MATRIX_T) , INTENT(IN) :: A TYPE(MATRIX_DESCR) , INTENT(IN) :: descr ! sparse_matrix_type_t + sparse_fill_mode_t + sparse_diag_type_t INTEGER(C_INT) , INTENT(IN) :: layout ! storage scheme for the dense matrix: C-style or Fortran-style COMPLEX(C_FLOAT_COMPLEX), INTENT(IN), DIMENSION(*) :: x INTEGER , INTENT(IN) :: columns INTEGER , INTENT(IN) :: ldx COMPLEX(C_FLOAT_COMPLEX), INTENT(INOUT), DIMENSION(*) :: y INTEGER , INTENT(IN) :: ldy INTEGER(C_INT) MKL_SPARSE_C_TRSM END FUNCTION FUNCTION MKL_SPARSE_Z_TRSM(operation,alpha,A,descr,layout,x,columns,ldx,y,ldy) & BIND(C, name='MKL_SPARSE_Z_TRSM') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE_COMPLEX IMPORT SPARSE_MATRIX_T IMPORT MATRIX_DESCR INTEGER(C_INT) , INTENT(IN) :: operation COMPLEX(C_DOUBLE_COMPLEX), INTENT(IN) :: alpha TYPE(SPARSE_MATRIX_T) , INTENT(IN) :: A TYPE(MATRIX_DESCR) , INTENT(IN) :: descr ! sparse_matrix_type_t + sparse_fill_mode_t + sparse_diag_type_t INTEGER(C_INT) , INTENT(IN) :: layout ! storage scheme for the dense matrix: C-style or Fortran-style COMPLEX(C_DOUBLE_COMPLEX), INTENT(IN), DIMENSION(*) :: x INTEGER , INTENT(IN) :: columns INTEGER , INTENT(IN) :: ldx COMPLEX(C_DOUBLE_COMPLEX), INTENT(INOUT), DIMENSION(*) :: y INTEGER , INTENT(IN) :: ldy INTEGER(C_INT) MKL_SPARSE_Z_TRSM END FUNCTION ! Sparse-sparse functionality ! Computes addition of sparse matrices: C = alpha * op(A) + B, result is sparse FUNCTION MKL_SPARSE_S_ADD(operation,A,alpha,B,C) & BIND(C, name='MKL_SPARSE_S_ADD') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_FLOAT IMPORT SPARSE_MATRIX_T INTEGER(C_INT) , INTENT(IN) :: operation TYPE(SPARSE_MATRIX_T), INTENT(IN) :: A REAL(C_FLOAT) , INTENT(IN) :: alpha TYPE(SPARSE_MATRIX_T), INTENT(IN) :: B TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: C INTEGER(C_INT) MKL_SPARSE_S_ADD END FUNCTION FUNCTION MKL_SPARSE_D_ADD(operation,A,alpha,B,C) & BIND(C, name='MKL_SPARSE_D_ADD') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE IMPORT SPARSE_MATRIX_T INTEGER(C_INT) , INTENT(IN) :: operation TYPE(SPARSE_MATRIX_T), INTENT(IN) :: A REAL(C_DOUBLE) , INTENT(IN) :: alpha TYPE(SPARSE_MATRIX_T), INTENT(IN) :: B TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: C INTEGER(C_INT) MKL_SPARSE_D_ADD END FUNCTION FUNCTION MKL_SPARSE_C_ADD(operation,A,alpha,B,C) & BIND(C, name='MKL_SPARSE_C_ADD') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_FLOAT_COMPLEX IMPORT SPARSE_MATRIX_T INTEGER(C_INT) , INTENT(IN) :: operation TYPE(SPARSE_MATRIX_T) , INTENT(IN) :: A COMPLEX(C_FLOAT_COMPLEX), INTENT(IN) :: alpha TYPE(SPARSE_MATRIX_T) , INTENT(IN) :: B TYPE(SPARSE_MATRIX_T) , INTENT(INOUT) :: C INTEGER(C_INT) MKL_SPARSE_C_ADD END FUNCTION FUNCTION MKL_SPARSE_Z_ADD(operation,A,alpha,B,C) & BIND(C, name='MKL_SPARSE_Z_ADD') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE_COMPLEX IMPORT SPARSE_MATRIX_T INTEGER(C_INT) , INTENT(IN) :: operation TYPE(SPARSE_MATRIX_T), INTENT(IN) :: A COMPLEX(C_DOUBLE_COMPLEX) , INTENT(IN) :: alpha TYPE(SPARSE_MATRIX_T), INTENT(IN) :: B TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: C INTEGER(C_INT) MKL_SPARSE_Z_ADD END FUNCTION ! Computes multiplication of sparse matrices: C = op(A) * B, result is sparse FUNCTION MKL_SPARSE_SPMM(operation,A,B,C) & BIND(C, name='MKL_SPARSE_SPMM') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT IMPORT SPARSE_MATRIX_T INTEGER(C_INT) , INTENT(IN) :: operation TYPE(SPARSE_MATRIX_T), INTENT(IN) :: A TYPE(SPARSE_MATRIX_T), INTENT(IN) :: B TYPE(SPARSE_MATRIX_T), INTENT(INOUT) :: C INTEGER(C_INT) MKL_SPARSE_SPMM END FUNCTION ! Computes multiplication of sparse matrices: C = op(A) * B, result is dense FUNCTION MKL_SPARSE_S_SPMMD(operation,A,B,layout,C,ldc) & BIND(C, name='MKL_SPARSE_S_SPMMD') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_FLOAT IMPORT SPARSE_MATRIX_T INTEGER(C_INT) , INTENT(IN) :: operation TYPE(SPARSE_MATRIX_T), INTENT(IN) :: A TYPE(SPARSE_MATRIX_T), INTENT(IN) :: B INTEGER(C_INT) , INTENT(IN) :: layout REAL(C_FLOAT), INTENT(INOUT), DIMENSION(*) :: C INTEGER , INTENT(IN) :: ldc INTEGER(C_INT) MKL_SPARSE_S_SPMMD END FUNCTION FUNCTION MKL_SPARSE_D_SPMMD(operation,A,B,layout,C,ldc) & BIND(C, name='MKL_SPARSE_D_SPMMD') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE IMPORT SPARSE_MATRIX_T INTEGER(C_INT) , INTENT(IN) :: operation TYPE(SPARSE_MATRIX_T), INTENT(IN) :: A TYPE(SPARSE_MATRIX_T), INTENT(IN) :: B INTEGER(C_INT) , INTENT(IN) :: layout REAL(C_DOUBLE), INTENT(INOUT), DIMENSION(*) :: C INTEGER , INTENT(IN) :: ldc INTEGER(C_INT) MKL_SPARSE_D_SPMMD END FUNCTION FUNCTION MKL_SPARSE_C_SPMMD(operation,A,B,layout,C,ldc) & BIND(C, name='MKL_SPARSE_C_SPMMD') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_FLOAT_COMPLEX IMPORT SPARSE_MATRIX_T INTEGER(C_INT) , INTENT(IN) :: operation TYPE(SPARSE_MATRIX_T), INTENT(IN) :: A TYPE(SPARSE_MATRIX_T), INTENT(IN) :: B INTEGER(C_INT) , INTENT(IN) :: layout COMPLEX(C_FLOAT_COMPLEX), INTENT(INOUT), DIMENSION(*) :: C INTEGER , INTENT(IN) :: ldc INTEGER(C_INT) MKL_SPARSE_C_SPMMD END FUNCTION FUNCTION MKL_SPARSE_Z_SPMMD(operation,A,B,layout,C,ldc) & BIND(C, name='MKL_SPARSE_Z_SPMMD') USE, INTRINSIC :: ISO_C_BINDING , ONLY : C_INT, C_DOUBLE_COMPLEX IMPORT SPARSE_MATRIX_T INTEGER(C_INT) , INTENT(IN) :: operation TYPE(SPARSE_MATRIX_T), INTENT(IN) :: A TYPE(SPARSE_MATRIX_T), INTENT(IN) :: B INTEGER(C_INT) , INTENT(IN) :: layout COMPLEX(C_DOUBLE_COMPLEX), INTENT(INOUT), DIMENSION(*) :: C INTEGER , INTENT(IN) :: ldc INTEGER(C_INT) MKL_SPARSE_Z_SPMMD END FUNCTION END INTERFACE END MODULE MKL_SPBLAS
import .logic class atom_type (α β : Type) := (val : list β → α → Prop) (neg : α → fm α) (neg_nqfree : ∀ (a : α), nqfree (neg a)) (neg_prsv : ∀ (a : α) (xs : list β), (interp val xs (neg a)) ↔ (interp val xs (¬' A' a))) (dep0 : α → Prop) (dec_dep0 : decidable_pred dep0) (decr : α → α) (decr_prsv : ∀ {a : α} {hd : ¬ (dep0 a)} {b : β} {bs : list β}, (val bs (decr a) ↔ val (b::bs) a)) (inh : β) (dec_eq : decidable_eq α) (normal : α → Prop) (dec_normal : decidable_pred normal) (neg_prsv_normal : ∀ a, (normal a → ∀ a' ∈ (atoms (neg a)), normal a')) (decr_prsv_normal : ∀ a, normal a → ¬ dep0 a → normal (decr a)) class atom_eq_type (α β : Type) extends atom_type α β := (solv0 : α → Prop) (dec_solv0 : decidable_pred solv0) (dest_solv0 : ∀ a, solv0 a → nat) (solv0_eq : ∀ {e : α} (He : solv0 e) {b} {bs}, val (b::bs) e → list.nth_dft (atom_type.inh α β) (b::bs) (dest_solv0 e He) = b) (trivial : α → Prop) (dec_triv : decidable_pred trivial) (true_triv : ∀ a, trivial a → ∀ xs, val xs a) (subst0 : α → α → α) (true_subst : ∀ e, solv0 e → ∀ bs, val bs (subst0 e e)) (subst_prsv : ∀ {e : α} (He : solv0 e), ∀ {a : α} {bs : list β}, val bs (subst0 e a) ↔ val ((list.nth_dft (atom_type.inh α β) bs (dest_solv0 e He - 1))::bs) a) (dest_pos : ∀ {a} {Ha : solv0 a}, ¬ trivial a → dest_solv0 a Ha > 0) -- subst_eqn i j k returns the result of taking an -- identity atom of form (i = j) and using it to -- substitute a de Brujin variable k. -- Requires : j = 0 ↔ ¬(i = 0) def subst_eqn : nat → nat → nat → nat | 0 j 0 := j - 1 | (i+1) _ 0 := i | _ _ k := k - 1 def isubst (k) : nat → nat | 0 := k | (i + 1) := i -- Qstn : Why do I need this? (Why doesn't unfold work?) lemma exp_subst_eqn_i0 (i) : subst_eqn (i+1) 0 0 = i := begin refl end variables {α β : Type} def I [atom_type α β] (p : fm α) (xs : list β) := interp (atom_type.val) xs p lemma exp_I [atom_type α β] {p : fm α} {xs : list β} : I p xs = interp (atom_type.val) xs p := refl _ lemma exp_I_and [atom_type α β] (p q : fm α) (xs : list β) : I (p ∧' q) xs = ((I p xs) ∧ (I q xs)) := eq.refl _ lemma exp_I_and_o [atom_type α β] (p q : fm α) (xs : list β) : I (and_o p q) xs = ((I p xs) ∧ (I q xs)) := begin apply (cases_and_o' (λ p q pq, ((I pq xs) = ((I p xs) ∧ (I q xs)))) p q), repeat {unfold I, unfold interp, simp}, unfold I, unfold interp end lemma exp_I_or [atom_type α β] (p q : fm α) (xs : list β) : I (p ∨' q) xs = ((I p xs) ∨ (I q xs)) := eq.refl _ lemma exp_I_or_o [atom_type α β] (p q : fm α) (xs : list β) : I (or_o p q) xs ↔ ((I p xs) ∨ (I q xs)) := begin apply (cases_or_o' (λ p q pq, ((I pq xs) ↔ ((I p xs) ∨ (I q xs)))) p q), repeat {unfold I, unfold interp, simp}, unfold I, unfold interp end lemma exp_I_not [atom_type α β] (p : fm α) (xs : list β) : I (¬' p) xs = ¬ (I p xs) := eq.refl _ lemma exp_I_not_o [atom_type α β] (p : fm α) : ∀ (xs : list β), I (not_o p) xs ↔ ¬ (I p xs) := by cases p; {unfold not_o, unfold I, unfold interp, try {simp}} lemma exp_I_ex [atom_type α β] (p : fm α) (xs) : @I α β _ (∃' p) xs = ∃ x, (I p (x::xs)) := by unfold I; unfold interp lemma exp_I_top [atom_type α β] (xs) : @I α β _ ⊤' xs = true := by unfold I; unfold interp lemma exp_I_bot [atom_type α β] (xs) : @I α β _ ⊥' xs = false := by unfold I; unfold interp lemma I_not_dep0 [atom_type α β] (a : α) (b : β) (bs : list β) : ¬ atom_type.dep0 β a → (I (A' a) (b::bs) ↔ I (A' (atom_type.decr β a)) bs) := begin intro h, unfold I, unfold interp, rewrite atom_type.decr_prsv, apply h end def fnormal_alt (β) [atom_type α β] (p : fm α) := ∀ a ∈ (@atoms _ (atom_type.dec_eq _ β) p), atom_type.normal β a def fnormal (β) [atom_type α β] : fm α → Prop | ⊤' := true | ⊥' := true | (A' a) := atom_type.normal β a | (p ∧' q) := fnormal p ∧ fnormal q | (p ∨' q) := fnormal p ∧ fnormal q | (¬' p) := fnormal p | (∃' p) := fnormal p instance dec_fnormal (β) [atom_type α β] : decidable_pred (@fnormal α β _) | ⊤' := decidable.is_true trivial | ⊥' := decidable.is_true trivial | (A' a) := begin unfold fnormal, apply atom_type.dec_normal α β end | (p ∧' q) := begin unfold fnormal, apply @and.decidable _ _ _ _; apply dec_fnormal end | (p ∨' q) := begin unfold fnormal, apply @and.decidable _ _ _ _; apply dec_fnormal end | (¬' p) := begin unfold fnormal, apply dec_fnormal end | (∃' p) := begin unfold fnormal, apply dec_fnormal end lemma fnormal_iff_fnormal_alt [atom_type α β] : ∀ {p : fm α}, fnormal β p ↔ fnormal_alt β p | ⊤' := true_iff_true trivial (λ a ha, by cases ha) | ⊥' := true_iff_true trivial (λ a ha, by cases ha) | (A' a) := begin unfold fnormal, unfold fnormal_alt, unfold atoms, apply iff.intro; intro h, intros a' ha', cases ha' with he he, subst he, apply h, cases he, apply h, apply or.inl rfl end | (p ∧' q) := begin unfold fnormal, repeat {rewrite fnormal_iff_fnormal_alt}, apply iff.symm, apply list.forall_mem_union end | (p ∨' q) := begin unfold fnormal, repeat {rewrite fnormal_iff_fnormal_alt}, apply iff.symm, apply list.forall_mem_union end | (¬' p) := begin unfold fnormal, rewrite fnormal_iff_fnormal_alt, refl end | (∃' p) := begin unfold fnormal, rewrite fnormal_iff_fnormal_alt, refl end def disj_to_prop (β) [atom_type α β] (as : list α) (bs : list β) : Prop := ∀ a ∈ as, atom_type.val bs a instance atoms_dec_eq [atom_type α β] : decidable_eq α := atom_type.dec_eq α β instance atoms_dec_dep0 [atom_type α β] : decidable_pred (atom_type.dep0 β) := atom_type.dec_dep0 α β def atoms_dep0 (β) [atom_type α β] (p : fm α) := list.filter (atom_type.dep0 β) (atoms p)
/- Copyright (c) 2021 Junyan Xu. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Junyan Xu -/ import topology.sheaves.sheaf_condition.pairwise_intersections /-! # functors between categories of sheaves Show that the pushforward of a sheaf is a sheaf, and define the pushforward functor from the category of C-valued sheaves on X to that of sheaves on Y, given a continuous map between topological spaces X and Y. TODO: pullback for presheaves and sheaves -/ noncomputable theory universes w v u open category_theory open category_theory.limits open topological_space variables {C : Type u} [category.{v} C] variables {X Y : Top.{w}} (f : X ⟶ Y) variables ⦃ι : Type w⦄ {U : ι → opens Y} namespace Top namespace presheaf.sheaf_condition_pairwise_intersections lemma map_diagram : pairwise.diagram U ⋙ opens.map f = pairwise.diagram ((opens.map f).obj ∘ U) := begin apply functor.hext, abstract obj_eq {intro i, cases i; refl}, intros i j g, apply subsingleton.helim, iterate 2 {rw map_diagram.obj_eq}, end lemma map_cocone : (opens.map f).map_cocone (pairwise.cocone U) == pairwise.cocone ((opens.map f).obj ∘ U) := begin unfold functor.map_cocone cocones.functoriality, dsimp, congr, iterate 2 {rw map_diagram, rw opens.map_supr}, apply subsingleton.helim, rw [map_diagram, opens.map_supr], apply proof_irrel_heq, end theorem pushforward_sheaf_of_sheaf {F : presheaf C X} (h : F.is_sheaf_pairwise_intersections) : (f _* F).is_sheaf_pairwise_intersections := λ ι U, begin convert h ((opens.map f).obj ∘ U) using 2, rw ← map_diagram, refl, change F.map_cone ((opens.map f).map_cocone _).op == _, congr, iterate 2 {rw map_diagram}, apply map_cocone, end end presheaf.sheaf_condition_pairwise_intersections namespace sheaf open presheaf /-- The pushforward of a sheaf (by a continuous map) is a sheaf. -/ theorem pushforward_sheaf_of_sheaf {F : X.presheaf C} (h : F.is_sheaf) : (f _* F).is_sheaf := by rw is_sheaf_iff_is_sheaf_pairwise_intersections at h ⊢; exact sheaf_condition_pairwise_intersections.pushforward_sheaf_of_sheaf f h /-- The pushforward functor. -/ def pushforward (f : X ⟶ Y) : X.sheaf C ⥤ Y.sheaf C := { obj := λ ℱ, ⟨f _* ℱ.1, pushforward_sheaf_of_sheaf f ℱ.2⟩, map := λ _ _ g, ⟨pushforward_map f g.1⟩ } end sheaf end Top
[STATEMENT] lemma (in Group) Gp_s_mult_nsg:"\<lbrakk>G \<triangleright> H; G \<triangleright> N; H \<subseteq> N; a \<in> N \<rbrakk> \<Longrightarrow> H \<bullet>\<^bsub>(Gp G N)\<^esub> a = H \<bullet> a" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>G \<triangleright> H; G \<triangleright> N; H \<subseteq> N; a \<in> N\<rbrakk> \<Longrightarrow> H \<bullet>\<^bsub>\<natural>N\<^esub> a = H \<bullet> a [PROOF STEP] by (frule nsg_sg[of "H"], frule nsg_sg[of "N"], rule Gp_rcs[of "H" "N" "a"], assumption+)
What hasn't been explained, is what to use in place of "right_arm"? I build the package with catkin_make, then run it with rosrun mico_move mico_move_node. [FATAL] [1432653194.030197342]: Unable to construct robot model. Please make sure all needed information is on the parameter server. what(): Unable to construct robot model. Please make sure all needed information is on the parameter server. Why am I getting this error, and what do I need to put instead of "right_arm"? The tutorial does not give very much background help!
// Copyright 2018 Your Name <your_email> // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // // Official repository: https://github.com/boostorg/beast // #ifndef INCLUDE_SERTIFICATE_HPP_ #define INCLUDE_SERTIFICATE_HPP_ #include <boost/asio/ssl.hpp> #include <string> /* PLEASE READ These root certificates here are included just to make the SSL client examples work. They are NOT intended to be illustrative of best-practices for performing TLS certificate verification. A REAL program which needs to verify the authenticity of a server IP address resolved from a given DNS name needs to consult the operating system specific certificate store to validate the chain of signatures, compare the domain name properly against the domain name in the certificate, check the certificate revocation list, and probably do some other things. ALL of these operations are entirely outside the scope of both Boost.Beast and Boost.Asio. See (work in progress): https://github.com/djarek/certify tl;dr: root_certificates.hpp should not be used in production code */ namespace ssl = boost::asio::ssl; // from <boost/asio/ssl.hpp> namespace detail { inline void load_root_certificates(ssl::context &ctx, boost::system::error_code &ec) { std::string const cert = /* This is the DigiCert root certificate. CN = DigiCert High Assurance EV Root CA OU = www.digicert.com O = DigiCert Inc C = US Valid to: Sunday, ?November ?9, ?2031 5:00:00 PM Thumbprint(sha1): 5f b7 ee 06 33 e2 59 db ad 0c 4c 9a e6 d3 8f 1a 61 c7 dc 25 */ "-----BEGIN CERTIFICATE-----\n" "MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBs\n" "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" "d3cuZGlnaWNlcnQuY29tMSswKQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5j\n" "ZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAwMFoXDTMxMTExMDAwMDAwMFowbDEL\n" "MAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZMBcGA1UECxMQd3d3\n" "LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFuY2Ug\n" "RVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm\n" "+9S75S0tMqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTW\n" "PNt0OKRKzE0lgvdKpVMSOO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEM\n" "xChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFB\n" "Ik5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQNAQTXKFx01p8VdteZOE3\n" "hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUeh10aUAsg\n" "EsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQF\n" "MAMBAf8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaA\n" "FLE+w2kD+L9HAdSYJhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3Nec\n" "nzyIZgYIVyHbIUf4KmeqvxgydkAQV8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6z\n" "eM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFpmyPInngiK3BD41VHMWEZ71jF\n" "hS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkKmNEVX58Svnw2\n" "Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe\n" "vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep\n" "+OkuE6N36B9K\n" "-----END CERTIFICATE-----\n" "-----BEGIN CERTIFICATE-----\n" "MIIDaDCCAlCgAwIBAgIJAO8vBu8i8exWMA0GCSqGSIb3DQEBCwUAMEkxCzAJBgNV\n" "BAYTAlVTMQswCQYDVQQIDAJDQTEtMCsGA1UEBwwkTG9zIEFuZ2VsZXNPPUJlYXN0\n" "Q049d3d3LmV4YW1wbGUuY29tMB4XDTE3MDUwMzE4MzkxMloXDTQ0MDkxODE4Mzkx\n" "MlowSTELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMS0wKwYDVQQHDCRMb3MgQW5n\n" "ZWxlc089QmVhc3RDTj13d3cuZXhhbXBsZS5jb20wggEiMA0GCSqGSIb3DQEBAQUA\n" "A4IBDwAwggEKAoIBAQDJ7BRKFO8fqmsEXw8v9YOVXyrQVsVbjSSGEs4Vzs4cJgcF\n" "xqGitbnLIrOgiJpRAPLy5MNcAXE1strVGfdEf7xMYSZ/4wOrxUyVw/Ltgsft8m7b\n" "Fu8TsCzO6XrxpnVtWk506YZ7ToTa5UjHfBi2+pWTxbpN12UhiZNUcrRsqTFW+6fO\n" "9d7xm5wlaZG8cMdg0cO1bhkz45JSl3wWKIES7t3EfKePZbNlQ5hPy7Pd5JTmdGBp\n" "yY8anC8u4LPbmgW0/U31PH0rRVfGcBbZsAoQw5Tc5dnb6N2GEIbq3ehSfdDHGnrv\n" "enu2tOK9Qx6GEzXh3sekZkxcgh+NlIxCNxu//Dk9AgMBAAGjUzBRMB0GA1UdDgQW\n" "BBTZh0N9Ne1OD7GBGJYz4PNESHuXezAfBgNVHSMEGDAWgBTZh0N9Ne1OD7GBGJYz\n" "4PNESHuXezAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQCmTJVT\n" "LH5Cru1vXtzb3N9dyolcVH82xFVwPewArchgq+CEkajOU9bnzCqvhM4CryBb4cUs\n" "gqXWp85hAh55uBOqXb2yyESEleMCJEiVTwm/m26FdONvEGptsiCmF5Gxi0YRtn8N\n" "V+KhrQaAyLrLdPYI7TrwAOisq2I1cD0mt+xgwuv/654Rl3IhOMx+fKWKJ9qLAiaE\n" "fQyshjlPP9mYVxWOxqctUdQ8UnsUKKGEUcVrA08i1OAnVKlPFjKBvk+r7jpsTPcr\n" "9pWXTO9JrYMML7d+XRSZA1n3856OqZDX4403+9FnXCvfcLZLLKTBvwwFgEFGpzjK\n" "UEVbkhd5qstF6qWK\n" "-----END CERTIFICATE-----\n"; ctx.add_certificate_authority( boost::asio::buffer(cert.data(), cert.size()), ec); if (ec){ return; } } } // namespace detail inline void load_root_certificates(ssl::context &ctx, boost::system::error_code &ec) { detail::load_root_certificates(ctx, ec); } inline void load_root_certificates(ssl::context &ctx) { boost::system::error_code ec; detail::load_root_certificates(ctx, ec); if (ec){ throw boost::system::system_error{ec}; } } #endif // INCLUDE_SERTIFICATE_HPP_
data Nat : Set where zero : Nat suc : Nat → Nat data Zero : Nat → Set where instance isZero : Zero zero data NonZero : Nat → Set where instance isSuc : ∀ {n : Nat} → NonZero (suc n) pred : ∀ t {{_ : NonZero t}} → Nat pred ._ {{isSuc {n}}} = n test : Nat test = pred (suc zero) data Test (x : Nat) : Set where here : {{_ : Zero x}} → Test x there : {{nz : NonZero x}} → Test (pred x) → Test x broken : Test (suc zero) broken = there here
import MyNat.Definition import MyNat.Addition import AdvancedAdditionWorld.Level1 -- succ_inj namespace MyNat open MyNat /-! # Advanced Addition World ## Level 2: `succ_succ_inj` In the below theorem, we need to apply `succ_inj` twice. Once to prove `succ (succ a) = succ (succ b) ⟹ succ a = succ b`, and then again to prove `succ a = succ b ⟹ a = b`. However `succ a = succ b` is nowhere to be found, it's neither an assumption or a goal when we start this level. You can make it with `have` or you can use `apply`. ## Theorem : succ_succ_inj For all naturals `a` and `b`, if we assume `succ (succ a) = succ (succ b)`, then we can deduce `a = b`. -/ theorem succ_succ_inj {a b : MyNat} (h : succ (succ a) = succ (succ b)) : a = b := by apply succ_inj apply succ_inj exact h /-! ## Other solutions Make sure you understand them all. And remember that `rw` should not be used with `succ_inj` -- `rw` works only with equalities or `↔` statements, not implications or functions. -/ example {a b : MyNat} (h : succ (succ a) = succ (succ b)) : a = b := by apply succ_inj exact succ_inj h example {a b : MyNat} (h : succ (succ a) = succ (succ b)) : a = b := by exact succ_inj (succ_inj h) /-! Next up [Level 3](./Level3.lean.md) -/
module Verified.Functor.List import Verified.Functor instance VerifiedFunctor List where functorIdentity [] = Refl functorIdentity (x :: xs) = let IHxs = functorIdentity xs in ?lemma1 functorComposition [] g1 g2 = Refl functorComposition (x :: xs) g1 g2 = let IHxs = functorComposition xs g1 g2 in ?lemma2 ---------- Proofs ---------- Verified.Functor.List.lemma2 = proof intros rewrite IHxs exact Refl Verified.Functor.List.lemma1 = proof intros rewrite IHxs exact Refl
module Streaming.Encoding.UTF8 import Streaming.Internal as S import Streaming.API as S import Util export data DecodeError = CodepointOutOfRange | InvalidStartByte Bits8 | CodepointEndedEarly export Show DecodeError where show CodepointOutOfRange = "CodepointOutOfRange" show (InvalidStartByte x) = "InvalidStartByte " ++ show x show CodepointEndedEarly = "CodepointEndedEarly" export data EncodeError = EncCodepointOutOfRange export Show EncodeError where show EncCodepointOutOfRange = "CodepointOutOfRange" -- check leading bit, use that to 'split off' the number of extra Bits8 needed. -- Check the split stream to make sure those all have follower bits and .|. them -- together into a larger type (int) after adjusting their position. If they -- don't all match then error out, if they do call it a Char. -- store, conceptually, acts on a copy of the substream we're splitting off -- so we can check validity and roll up the bits at the same time. -- messy messy coding, but working, I really need to learn bits better export decodeUtf8 : Monad m => Stream (Of Bits8) m r -> Stream (Of Char) m (Either DecodeError r) decodeUtf8 str0 = effect $ do Right (b :> str) <- inspect str0 | Left l => pure . pure . pure $ l -- so pure case min 4 (leadingBits b) of 0 => pure $ wrap (bits8ToChar b :> decodeUtf8 str) -- need Delay? 1 => pure . pure . Left $ InvalidStartByte b x => let x' = x - 1 in str &$ splitsAt x' |> store ( maps cast -- Move to Int |> cons (maskMarker x' b) -- add lead bit to stream front |> S.foldl collect 0) -- combine stream's bits |> S.all ((1 ==) . leadingBits) -- requisit bits matched? |> \res => do True :> n :> s <- res | _ => pure . pure . Left $ CodepointEndedEarly pure $ if n < 0 || n > 0x10FFFF then pure . Left $ CodepointOutOfRange else wrap (cast n :> decodeUtf8 s) where -- 😀 = \128512 = 0x1F600 maskMarker : (c : Int) -> Bits8 -> Int maskMarker c b = shiftL (shiftR 0xFF (c+3) .&. cast b) (6 * c+1) collect : Int -> Int -> Int collect acc x = shiftL acc 6 .|. (x .&. 0x3F) private %inline if' : Bool -> a -> a -> a if' x y z = if x then y else z -- determine our codepoint, split into requisite pieces, cast, mask, stream -- phew, how do I clean this up a bit? private encode : Monad m => Char -> Stream (Of Bits8) m (Either EncodeError ()) encode c = let ic = ord c in if' (ic <= 0x00007F) (map Right (enc 1 ic)) $ if' (ic <= 0x0007FF) (map Right (enc 2 ic)) $ if' (ic <= 0x00FFFF) (map Right (enc 3 ic)) $ if' (ic <= 0x10FFFF) (map Right (enc 4 ic)) $ pure (Left EncCodepointOutOfRange) where -- separate our codepoint into a stream of Bits8 then mask it off -- e.g. 32767 is 13 1-bits or 111111111111111 -- our splitting here shifts the number 6 bits each iteration -- step1: 111111111111111 And masked: 10111111 -- step2: 000000111111111 10111111 -- step3: 000000000000111 10000111 shiftedBytes : Int -> Stream (Of Bits8) m r shiftedBytes x = maps (\b => cast (0x80 .|. (b .&. 0x3F))) (iterate (`shiftR`6) x) -- Set up the starting byte that encodes what bytes follow: -- The count of leading 1's, terminated by a 0, says how many parts a -- codepoint has, e.g. codepoint 128512 is a 4 byte codepoint, it happens -- to start with the exact byte 11110000. Conceptually separated as -- 1111|0|000, 4 1's to show the count of bytes that make the codepoint, -- a terminator bit 0, and the first 3 bits of the codepoint. -- I suspect these teminator bits aren't really neccesary and are perhaps -- for utf16's use. encstart : (n : Int) -> (ic : Int) -> Bits8 encstart 1 ic = cast ic encstart n ic = cast $ shiftL 0xFE (8 - (n+1)) -- starting bit mask .|. (shiftR 0xFF (n+1) .&. shiftR ic (8 * n)) -- mask and fill bits -- Combine our starting byte and the shifted follower bytes. enc : (n : Int) -> (ic : Int) -> Stream (Of Bits8) m () enc n ic = encstart n ic `cons` rev (take {r=()} (n - 1) (shiftedBytes ic)) export encodeUtf8 : Monad m => Stream (Of Char) m r -> Stream (Of Bits8) m (Either EncodeError r) encodeUtf8 str0 = effect $ do Right (c :> str) <- inspect str0 | Left l => pure (pure (Right l)) pure $ encode c *> encodeUtf8 str
[STATEMENT] lemma (in Max_impl) Max_spec3: shows "\<forall>n m leq. \<Gamma>\<turnstile> (\<lbrace>\<acute>n=n \<and> \<acute>m=m\<rbrace> \<inter> \<lbrace>(\<forall>\<tau>. \<Gamma>\<turnstile> {\<tau>} \<acute>b :== PROC \<acute>compare(\<acute>n,\<acute>m) \<lbrace>\<acute>b = (leq \<^bsup>\<tau>\<^esup>n \<^bsup>\<tau>\<^esup>m)\<rbrace>) \<and> (\<forall>\<tau>. \<Gamma>\<turnstile> {\<tau>} \<acute>b :== PROC \<acute>compare(\<acute>n,\<acute>m) {t. t may_only_modify_globals \<tau> in []})\<rbrace>) \<acute>k :== PROC Max(\<acute>compare,\<acute>n,\<acute>m) \<lbrace>\<acute>k = mx leq n m\<rbrace>" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>n m leq. \<Gamma>\<turnstile> (\<lbrace>\<acute>n = n \<and> \<acute>m = m\<rbrace> \<inter> \<lbrace>(\<forall>\<tau>. \<Gamma>\<turnstile> {\<tau>} Call \<acute>compare {s. \<^bsup>s\<^esup>b = leq \<^bsup>\<tau>\<^esup>n \<^bsup>\<tau>\<^esup>m}) \<and> (\<forall>\<tau>. \<Gamma>\<turnstile> {\<tau>} Call \<acute>compare {t. t may_not_modify_globals \<tau>})\<rbrace>) \<acute>k :== PROC Max(\<acute>compare,\<acute>n,\<acute>m) \<lbrace>\<acute>k = mx leq n m\<rbrace> [PROOF STEP] apply (hoare_rule HoarePartial.ProcNoRec1) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>n m leq. \<Gamma>\<turnstile> (\<lbrace>\<acute>n = n \<and> \<acute>m = m\<rbrace> \<inter> \<lbrace>(\<forall>\<tau>. \<Gamma>\<turnstile> {\<tau>} Call \<acute>compare {s. \<^bsup>s\<^esup>b = leq \<^bsup>\<tau>\<^esup>n \<^bsup>\<tau>\<^esup>m}) \<and> (\<forall>\<tau>. \<Gamma>\<turnstile> {\<tau>} Call \<acute>compare {t. t may_not_modify_globals \<tau>})\<rbrace>) \<acute>b :== DYNCALL \<acute>compare(\<acute>n,\<acute>m);; IF \<acute>b THEN \<acute>k :== \<acute>n ELSE \<acute>k :== \<acute>m FI \<lbrace>\<acute>k = mx leq n m\<rbrace> [PROOF STEP] apply (intro allI) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>n m leq. \<Gamma>\<turnstile> (\<lbrace>\<acute>n = n \<and> \<acute>m = m\<rbrace> \<inter> \<lbrace>(\<forall>\<tau>. \<Gamma>\<turnstile> {\<tau>} Call \<acute>compare {s. \<^bsup>s\<^esup>b = leq \<^bsup>\<tau>\<^esup>n \<^bsup>\<tau>\<^esup>m}) \<and> (\<forall>\<tau>. \<Gamma>\<turnstile> {\<tau>} Call \<acute>compare {t. t may_not_modify_globals \<tau>})\<rbrace>) \<acute>b :== DYNCALL \<acute>compare(\<acute>n,\<acute>m);; IF \<acute>b THEN \<acute>k :== \<acute>n ELSE \<acute>k :== \<acute>m FI \<lbrace>\<acute>k = mx leq n m\<rbrace> [PROOF STEP] apply (rule conseq_exploit_pre') [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>n m leq. \<forall>s\<in>\<lbrace>(\<forall>\<tau>. \<Gamma>\<turnstile> {\<tau>} Call \<acute>compare {s. \<^bsup>s\<^esup>b = leq \<^bsup>\<tau>\<^esup>n \<^bsup>\<tau>\<^esup>m}) \<and> (\<forall>\<tau>. \<Gamma>\<turnstile> {\<tau>} Call \<acute>compare {t. t may_not_modify_globals \<tau>})\<rbrace>. \<Gamma>\<turnstile> ({s} \<inter> \<lbrace>\<acute>n = n \<and> \<acute>m = m\<rbrace>) \<acute>b :== DYNCALL \<acute>compare(\<acute>n,\<acute>m);; IF \<acute>b THEN \<acute>k :== \<acute>n ELSE \<acute>k :== \<acute>m FI \<lbrace>\<acute>k = mx leq n m\<rbrace> [PROOF STEP] apply (rule) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>n m leq s. s \<in> \<lbrace>(\<forall>\<tau>. \<Gamma>\<turnstile> {\<tau>} Call \<acute>compare {s. \<^bsup>s\<^esup>b = leq \<^bsup>\<tau>\<^esup>n \<^bsup>\<tau>\<^esup>m}) \<and> (\<forall>\<tau>. \<Gamma>\<turnstile> {\<tau>} Call \<acute>compare {t. t may_not_modify_globals \<tau>})\<rbrace> \<Longrightarrow> \<Gamma>\<turnstile> ({s} \<inter> \<lbrace>\<acute>n = n \<and> \<acute>m = m\<rbrace>) \<acute>b :== DYNCALL \<acute>compare(\<acute>n,\<acute>m);; IF \<acute>b THEN \<acute>k :== \<acute>n ELSE \<acute>k :== \<acute>m FI \<lbrace>\<acute>k = mx leq n m\<rbrace> [PROOF STEP] apply clarify [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>n m leq s. \<lbrakk>\<forall>\<tau>. \<Gamma>\<turnstile> {\<tau>} \<acute>b :== PROC \<^bsup>s\<^esup>compare(\<acute>n,\<acute>m) \<lbrace>\<acute>b = leq \<^bsup>\<tau>\<^esup>n \<^bsup>\<tau>\<^esup>m\<rbrace>; \<forall>\<tau>. \<Gamma>\<turnstile> {\<tau>} \<acute>b :== PROC \<^bsup>s\<^esup>compare(\<acute>n,\<acute>m) {t. t may_not_modify_globals \<tau>}\<rbrakk> \<Longrightarrow> \<Gamma>\<turnstile> ({s} \<inter> \<lbrace>\<acute>n = n \<and> \<acute>m = m\<rbrace>) \<acute>b :== DYNCALL \<acute>compare(\<acute>n,\<acute>m);; IF \<acute>b THEN \<acute>k :== \<acute>n ELSE \<acute>k :== \<acute>m FI \<lbrace>\<acute>k = mx leq n m\<rbrace> [PROOF STEP] apply vcg [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>leq compare n m. \<lbrakk>\<forall>\<tau>. \<Gamma>\<turnstile> {\<tau>} Call compare \<lbrace>\<acute>b = leq \<^bsup>\<tau>\<^esup>n \<^bsup>\<tau>\<^esup>m\<rbrace>; \<forall>\<tau>. \<Gamma>\<turnstile> {\<tau>} Call compare {t. t may_not_modify_globals \<tau>}\<rbrakk> \<Longrightarrow> compare = compare \<and> (\<forall>b. b = leq n m \<longrightarrow> (leq n m \<longrightarrow> n = mx leq n m) \<and> (\<not> leq n m \<longrightarrow> m = mx leq n m)) [PROOF STEP] apply (clarsimp simp add: mx_def) [PROOF STATE] proof (prove) goal: No subgoals! [PROOF STEP] done
(* Specification of the following loop back device g -------------------- | ------- | x | | | | y ------|---->| |------| -----> | z | f | z | | -->| |--- | | | | | | | | | ------- | | | | | | | <-------------- | | | -------------------- First step: Notation in Agent Network Description Language (ANDL) ----------------------------------------------------------------- agent f input channel i1:'b i2: ('b,'c) tc output channel o1:'c o2: ('b,'c) tc is Rf(i1,i2,o1,o2) (left open in the example) end f agent g input channel x:'b output channel y:'c is network (y,z) = f$(x,z) end network end g Remark: the type of the feedback depends at most on the types of the input and output of g. (No type miracles inside g) Second step: Translation of ANDL specification to HOLCF Specification --------------------------------------------------------------------- Specification of agent f ist translated to predicate is_f is_f :: ('b stream * ('b,'c) tc stream -> 'c stream * ('b,'c) tc stream) => bool is_f f = !i1 i2 o1 o2. f$(i1,i2) = (o1,o2) --> Rf(i1,i2,o1,o2) Specification of agent g is translated to predicate is_g which uses predicate is_net_g is_net_g :: ('b stream * ('b,'c) tc stream -> 'c stream * ('b,'c) tc stream) => 'b stream => 'c stream => bool is_net_g f x y = ? z. (y,z) = f$(x,z) & !oy hz. (oy,hz) = f$(x,hz) --> z << hz is_g :: ('b stream -> 'c stream) => bool is_g g = ? f. is_f f & (!x y. g$x = y --> is_net_g f x y Third step: (show conservativity) ----------- Suppose we have a model for the theory TH1 which contains the axiom ? f. is_f f In this case there is also a model for the theory TH2 that enriches TH1 by axiom ? g. is_g g The result is proved by showing that there is a definitional extension that extends TH1 by a definition of g. We define: def_g g = (? f. is_f f & g = (LAM x. fst (f$(x,fix$(LAM k. snd (f$(x,k)))))) ) Now we prove: (? f. is_f f ) --> (? g. is_g g) using the theorems loopback_eq) def_g = is_g (real work) L1) (? f. is_f f ) --> (? g. def_g g) (trivial) *) theory Focus_ex imports "HOLCF-Library.Stream" begin typedecl ('a, 'b) tc axiomatization where tc_arity: "OFCLASS(('a::pcpo, 'b::pcpo) tc, pcop_class)" instance tc :: (pcpo, pcpo) pcpo by (rule tc_arity) axiomatization Rf :: "('b stream * ('b,'c) tc stream * 'c stream * ('b,'c) tc stream) \<Rightarrow> bool" definition is_f :: "('b stream * ('b,'c) tc stream \<rightarrow> 'c stream * ('b,'c) tc stream) \<Rightarrow> bool" where "is_f f \<longleftrightarrow> (\<forall>i1 i2 o1 o2. f\<cdot>(i1, i2) = (o1, o2) \<longrightarrow> Rf (i1, i2, o1, o2))" definition is_net_g :: "('b stream * ('b,'c) tc stream \<rightarrow> 'c stream * ('b,'c) tc stream) \<Rightarrow> 'b stream \<Rightarrow> 'c stream \<Rightarrow> bool" where "is_net_g f x y \<equiv> (\<exists>z. (y, z) = f\<cdot>(x,z) \<and> (\<forall>oy hz. (oy, hz) = f\<cdot>(x, hz) \<longrightarrow> z << hz))" definition is_g :: "('b stream \<rightarrow> 'c stream) \<Rightarrow> bool" where "is_g g \<equiv> (\<exists>f. is_f f \<and> (\<forall>x y. g\<cdot>x = y \<longrightarrow> is_net_g f x y))" definition def_g :: "('b stream \<rightarrow> 'c stream) => bool" where "def_g g \<equiv> (\<exists>f. is_f f \<and> g = (LAM x. fst (f\<cdot>(x, fix\<cdot>(LAM k. snd (f\<cdot>(x, k)))))))" (* first some logical trading *) lemma lemma1: "is_g g \<longleftrightarrow> (\<exists>f. is_f(f) \<and> (\<forall>x.(\<exists>z. (g\<cdot>x,z) = f\<cdot>(x,z) \<and> (\<forall>w y. (y, w) = f\<cdot>(x, w) \<longrightarrow> z << w))))" apply (simp add: is_g_def is_net_g_def) apply fast done lemma lemma2: "(\<exists>f. is_f f \<and> (\<forall>x. (\<exists>z. (g\<cdot>x, z) = f\<cdot>(x, z) \<and> (\<forall>w y. (y, w) = f\<cdot>(x,w) \<longrightarrow> z << w)))) \<longleftrightarrow> (\<exists>f. is_f f \<and> (\<forall>x. \<exists>z. g\<cdot>x = fst (f\<cdot>(x, z)) \<and> z = snd (f\<cdot>(x, z)) \<and> (\<forall>w y. (y, w) = f\<cdot>(x, w) \<longrightarrow> z << w)))" apply (rule iffI) apply (erule exE) apply (rule_tac x = "f" in exI) apply (erule conjE)+ apply (erule conjI) apply (intro strip) apply (erule allE) apply (erule exE) apply (rule_tac x = "z" in exI) apply (erule conjE)+ apply (rule conjI) apply (rule_tac [2] conjI) prefer 3 apply (assumption) apply (drule sym) apply (simp) apply (drule sym) apply (simp) apply (erule exE) apply (rule_tac x = "f" in exI) apply (erule conjE)+ apply (erule conjI) apply (intro strip) apply (erule allE) apply (erule exE) apply (rule_tac x = "z" in exI) apply (erule conjE)+ apply (rule conjI) prefer 2 apply (assumption) apply (rule prod_eqI) apply simp apply simp done lemma lemma3: "def_g g \<longrightarrow> is_g g" apply (tactic \<open>simp_tac (put_simpset HOL_ss \<^context> addsimps [@{thm def_g_def}, @{thm lemma1}, @{thm lemma2}]) 1\<close>) apply (rule impI) apply (erule exE) apply (rule_tac x = "f" in exI) apply (erule conjE)+ apply (erule conjI) apply (intro strip) apply (rule_tac x = "fix\<cdot>(LAM k. snd (f\<cdot>(x, k)))" in exI) apply (rule conjI) apply (simp) apply (rule prod_eqI, simp, simp) apply (rule trans) apply (rule fix_eq) apply (simp (no_asm)) apply (intro strip) apply (rule fix_least) apply (simp (no_asm)) apply (erule exE) apply (drule sym) back apply simp done lemma lemma4: "is_g g \<longrightarrow> def_g g" apply (tactic \<open>simp_tac (put_simpset HOL_ss \<^context> delsimps (@{thms HOL.ex_simps} @ @{thms HOL.all_simps}) addsimps [@{thm lemma1}, @{thm lemma2}, @{thm def_g_def}]) 1\<close>) apply (rule impI) apply (erule exE) apply (rule_tac x = "f" in exI) apply (erule conjE)+ apply (erule conjI) apply (rule cfun_eqI) apply (erule_tac x = "x" in allE) apply (erule exE) apply (erule conjE)+ apply (subgoal_tac "fix\<cdot>(LAM k. snd (f\<cdot>(x, k))) = z") apply simp apply (subgoal_tac "\<forall>w y. f\<cdot>(x, w) = (y, w) \<longrightarrow> z << w") apply (rule fix_eqI) apply simp apply (subgoal_tac "f\<cdot>(x, za) = (fst (f\<cdot>(x, za)), za)") apply fast apply (rule prod_eqI, simp, simp) apply (intro strip) apply (erule allE)+ apply (erule mp) apply (erule sym) done (* now we assemble the result *) lemma loopback_eq: "def_g = is_g" apply (rule ext) apply (rule iffI) apply (erule lemma3 [THEN mp]) apply (erule lemma4 [THEN mp]) done lemma L2: "(\<exists>f. is_f (f::'b stream * ('b,'c) tc stream \<rightarrow> 'c stream * ('b,'c) tc stream)) \<longrightarrow> (\<exists>g. def_g (g::'b stream \<rightarrow> 'c stream))" apply (simp add: def_g_def) done theorem conservative_loopback: "(\<exists>f. is_f (f::'b stream * ('b,'c) tc stream \<rightarrow> 'c stream * ('b,'c) tc stream)) \<longrightarrow> (\<exists>g. is_g (g::'b stream \<rightarrow> 'c stream))" apply (rule loopback_eq [THEN subst]) apply (rule L2) done end
program hycom_diff use mod_mean ! HYCOM mean array interface use mod_za ! HYCOM array I/O interface implicit none c c --- Form the difference of two standard or mean HYCOM archive files. c character label*81,text*18,flnm*256 logical meansq,trcout,icegln,icegln2,hisurf integer mntype,iweight c integer narchs,iarch c integer iexpt,jexpt,kkin,nbox,nscale,yrflag real thbase double precision time_min,time_max,time_ave,time(3) c c --- 'trcout' -- tracer input c data trcout/.false./ c lp=6 call xcspmd !define idm,jdm call zaiost call blkinit ! Open blkdat.input on all processors c iexpt = 0 jexpt = 0 iorign = 1 jorign = 1 hisurf = .true. c c --- 'kk ' = number of layers involved c call blkini(kk,'kk ') c c --- array allocation and initialiation c call mean_alloc c c --- land masks. c call getdepth('regional.depth') c call bigrid(depths) c c --- 'nscale' = scale difference by 1.0/nscale c --- 'nbox ' = smooth difference over a 2*nbox+1 square c call blkini(nscale,'nscale') call blkini(nbox, 'nbox ') c if (nbox.ne.0) then if(mnproc.eq.1)then write(lp,'(/a/)') 'error - nbox must be 0 for MPI version' endif call xcstop('error - nbox') stop endif c c --- first archive file c c read (*,'(a)') flnm call blkinc(flnm) if(mnproc.eq.1)then write (lp,'(2a)') ' 1st input file: ',trim(flnm) call flush(lp) endif call getdat(flnm,time,iweight,mntype, & icegln,trcout,jexpt,yrflag,kkin, thbase) if (mntype.eq.0) then call mean_velocity ! calculate full velocity and KE endif if (mntype.gt.1) then if(mnproc.eq.1)then write(lp,'(/a/)') 'error not a std or mean file' endif call xcstop('error not a std or mean file') stop endif time_min = time(3) c call mean_copy c c --- 2nd archive file c c read (*,'(a)') flnm call blkinc(flnm) if(mnproc.eq.1)then write (lp,'(2a)') ' 2nd input file: ',trim(flnm) call flush(lp) endif call getdat(flnm,time,iweight,mntype, & icegln2,trcout,iexpt,yrflag,kkin, thbase) icegln = icegln .and. icegln2 if (mntype.eq.0) then call mean_velocity ! calculate full velocity and KE endif if (mntype.gt.1) then if(mnproc.eq.1)then write(lp,'(/a/)') 'error not a std or mean file' endif call xcstop('error not a std or mean file') stop endif time_max = time(3) time_ave = 0.5*(max(time_min,time_max)+min(time_min,time_max)) c c --- output the diff. archive (1st - 2nd). c call mean_diff(nscale) c call blkinc(flnm) if(mnproc.eq.1)then write (lp,'(2a)') 'output file: ',trim(flnm) call flush(lp) endif mntype = 4 call putdat(flnm,time_min,time_max,time_ave, & mntype,icegln,trcout,iexpt,jexpt,yrflag, kk, thbase) call xcstop('hycom_diff END!') stop end
(* File: Connected.thy Author: Bohua Zhan Connected topological spaces. *) theory Connected imports ProductTopology OrderTopology begin section \<open>Connected spaces\<close> definition separation :: "i \<Rightarrow> i \<Rightarrow> i \<Rightarrow> o" where [rewrite]: "separation(X,U,V) \<longleftrightarrow> (is_open(X,U) \<and> is_open(X,V) \<and> U \<noteq> \<emptyset> \<and> V \<noteq> \<emptyset> \<and> U \<inter> V = \<emptyset> \<and> U \<union> V = carrier(X))" lemma separation_eq_str_top [rewrite]: "eq_str_top(X,Y) \<Longrightarrow> separation(X,A,B) \<longleftrightarrow> separation(Y,A,B)" by auto2 lemma separation_sym [resolve]: "separation(X,A,B) \<Longrightarrow> separation(X,B,A)" by auto2 definition connected :: "i \<Rightarrow> o" where [rewrite]: "connected(X) \<longleftrightarrow> (is_top_space(X) \<and> \<not>(\<exists>U V. separation(X,U,V)))" lemma connectedD1 [forward]: "connected(X) \<Longrightarrow> is_top_space(X)" by auto2 lemma connectedD2 [resolve]: "connected(X) \<Longrightarrow> \<not>separation(X,U,V)" by auto2 lemma connectedI [resolve]: "is_top_space(X) \<Longrightarrow> \<not>connected(X) \<Longrightarrow> \<exists>U V. separation(X,U,V)" by auto2 lemma connected_empty [resolve]: "is_top_space(X) \<Longrightarrow> carrier(X) = \<emptyset> \<Longrightarrow> connected(X)" by auto2 setup {* del_prfstep_thm @{thm connected_def} *} lemma connectedD': "connected(X) \<Longrightarrow> is_open(X,A) \<Longrightarrow> is_closed(X,A) \<Longrightarrow> A = \<emptyset> \<or> A = carrier(X)" @proof @contradiction @have "separation(X,A,carrier(X) \<midarrow> A)" @qed lemma connectedI': "is_top_space(X) \<Longrightarrow> \<forall>A\<in>open_sets(X). is_closed(X,A) \<longrightarrow> A = \<emptyset> \<or> A = carrier(X) \<Longrightarrow> connected(X)" @proof @contradiction @obtain U V where "separation(X,U,V)" @have "U = carrier(X) \<midarrow> V" @qed definition connected_subset :: "i \<Rightarrow> i \<Rightarrow> o" where [rewrite]: "connected_subset(X,Y) \<longleftrightarrow> (Y \<subseteq> carrier(X) \<and> connected(subspace(X,Y)))" lemma connected_subset_sep [forward]: "is_top_space(X) \<Longrightarrow> separation(X,C,D) \<Longrightarrow> connected_subset(X,Y) \<Longrightarrow> Y \<subseteq> C \<or> Y \<subseteq> D" @proof @case "Y \<inter> C \<noteq> \<emptyset> \<and> Y \<inter> D \<noteq> \<emptyset>" @with @have "separation(subspace(X,Y),Y \<inter> C,Y \<inter> D)" @end @qed lemma connected_subset_full [forward]: "is_top_space(X) \<Longrightarrow> connected_subset(X,carrier(X)) \<Longrightarrow> connected(X)" @proof @contradiction @obtain U V where "separation(X,U,V)" @qed lemma connected_union [backward1]: "is_top_space(X) \<Longrightarrow> \<forall>a\<in>A. connected_subset(X,a) \<Longrightarrow> (\<Inter>A) \<noteq> \<emptyset> \<Longrightarrow> connected_subset(X, \<Union>A)" @proof @contradiction @let "Y = (\<Union>A)" @obtain p where "p \<in> (\<Inter>A)" @have (@rule) "\<forall>a\<in>A. connected_subset(subspace(X,Y),a)" @obtain C D where "separation(subspace(X,Y), C, D)" @case "p \<in> C" @with @have "\<forall>a\<in>A. a \<subseteq> C" @end @qed lemma connected_union' [backward1]: "is_top_space(X) \<Longrightarrow> \<forall>a\<in>A. connected_subset(X,a) \<Longrightarrow> carrier(X) \<subseteq> (\<Union>A) \<Longrightarrow> (\<Inter>A) \<noteq> \<emptyset> \<Longrightarrow> connected(X)" @proof @have "carrier(X) = (\<Union>A)" @have "connected_subset(X, carrier(X))" @qed lemma connected_union2 [backward1]: "is_top_space(X) \<Longrightarrow> connected_subset(X,A) \<Longrightarrow> connected_subset(X,B) \<Longrightarrow> A \<inter> B \<noteq> \<emptyset> \<Longrightarrow> connected_subset(X, A \<union> B)" @proof @have "A \<union> B = \<Union>{A,B}" @have "A \<inter> B = \<Inter>{A,B}" @qed lemma connected_continuous_surj [forward,resolve]: "continuous(f) \<Longrightarrow> surjective(f) \<Longrightarrow> connected(source_str(f)) \<Longrightarrow> connected(target_str(f))" @proof @contradiction @obtain U V where "separation(target_str(f),U,V)" @have "separation(source_str(f), f-``U, f-``V)" @qed lemma connected_continuous [backward]: "continuous(f) \<Longrightarrow> connected(source_str(f)) \<Longrightarrow> connected_subset(target_str(f),image(f))" @proof @let "f' = mor_restrict_image_top(f,image(f))" @have "surjective(f')" @qed lemma connected_continuous_subspace [backward]: "continuous(f) \<Longrightarrow> connected_subset(source_str(f),A) \<Longrightarrow> connected_subset(target_str(f),f``A)" @proof @contradiction @have "connected_subset(source(f),image(f |\<^sub>T A))" @qed lemma connected_is_top_prop [forward]: "connected(X) \<Longrightarrow> homeomorphic(X,Y) \<Longrightarrow> connected(Y)" @proof @obtain "f \<in> X \<cong>\<^sub>T Y" @qed lemma connected_is_top_prop2 [forward]: "connected(X) \<Longrightarrow> eq_str_top(X,Y) \<Longrightarrow> connected(Y)" @proof @have "homeomorphic(X,Y)" @qed section \<open>Connected-ness on product spaces\<close> lemma product_connected [forward]: "connected(X) \<Longrightarrow> connected(Y) \<Longrightarrow> connected(X \<times>\<^sub>T Y)" @proof @case "carrier(X) = \<emptyset>" @case "carrier(Y) = \<emptyset>" @obtain "x \<in>. X" @let "A = {{x} \<times> carrier(Y) \<union> carrier(X) \<times> {y}. y\<in>.Y}" @have "(\<Inter>A) \<noteq> \<emptyset>" @with @obtain "y \<in>. Y" @have "\<langle>x,y\<rangle> \<in> (\<Inter>A)" @end @have "carrier(X \<times>\<^sub>T Y) \<subseteq> (\<Union>A)" @with @have "\<forall>p\<in>carrier(X \<times>\<^sub>T Y). p \<in> (\<Union>A)" @with @have "p \<in> {x} \<times> carrier(Y) \<union> carrier(X) \<times> {snd(p)}" @end @end @have "\<forall>a\<in>A. connected_subset(X \<times>\<^sub>T Y,a)" @with @obtain "y\<in>.Y" where "a = {x} \<times> carrier(Y) \<union> carrier(X) \<times> {y}" @have "{x} \<times> carrier(Y) \<inter> carrier(X) \<times> {y} \<noteq> \<emptyset>" @with @have "\<langle>x,y\<rangle> \<in> {x} \<times> carrier(Y) \<inter> carrier(X) \<times> {y}" @end @have "connected_subset(X \<times>\<^sub>T Y, {x} \<times> carrier(Y))" @with @have "homeomorphic(Y, subspace(X \<times>\<^sub>T Y, {x} \<times> carrier(Y)))" @end @have "connected_subset(X \<times>\<^sub>T Y, carrier(X) \<times> {y})" @with @have "homeomorphic(X, subspace(X \<times>\<^sub>T Y, carrier(X) \<times> {y}))" @end @end @qed section \<open>Connected-ness on order topology\<close> lemma connected_convex [resolve]: "order_topology(X) \<Longrightarrow> connected_subset(X,A) \<Longrightarrow> order_convex(X,A)" @proof @have "\<forall>a\<in>A. \<forall>b\<in>A. closed_interval(X,a,b) \<subseteq> A" @with @have "\<forall>c\<in>closed_interval(X,a,b). c \<in> A" @with @contradiction @let "U = A \<inter> less_interval(X,c)" @let "V = A \<inter> greater_interval(X,c)" @have "U \<inter> V = \<emptyset>" @have "U \<union> V = A" @have "separation(subspace(X,A),U,V)" @end @end @qed lemma continuum_connected_aux [backward1]: "order_topology(X) \<Longrightarrow> linear_continuum(X) \<Longrightarrow> a \<in> A \<Longrightarrow> b \<in> B \<Longrightarrow> carrier(X) = closed_interval(X,a,b) \<Longrightarrow> \<not>separation(X,A,B)" @proof @contradiction @have "has_sup(X,A)" @with @have "b \<in> upper_bound(X,A)" @end @let "c = sup(X,A)" @case "c \<in> A" @with @have "c \<noteq> b" @obtain e where "e >\<^sub>X c" "closed_open_interval(X,c,e) \<subseteq> A" @obtain z where "c <\<^sub>X z \<and> z <\<^sub>X e" @have "z \<in> closed_open_interval(X,c,e)" @end @case "c \<in> B" @with @have "c \<noteq> a" @obtain d where "d <\<^sub>X c" "open_closed_interval(X,d,c) \<subseteq> B" @have "d \<in> upper_bound(X,A)" @with @have "\<forall>x\<in>A. d \<ge>\<^sub>X x" @with @have "x \<notin> open_closed_interval(X,d,c)" @end @end @end @qed lemma separation_subspace [backward2]: "C \<subseteq> carrier(X) \<Longrightarrow> separation(X,A,B) \<Longrightarrow> C \<inter> A \<noteq> \<emptyset> \<Longrightarrow> C \<inter> B \<noteq> \<emptyset> \<Longrightarrow> separation(subspace(X,C), C \<inter> A, C \<inter> B)" by auto2 lemma continuum_connected [forward]: "order_topology(X) \<Longrightarrow> linear_continuum(X) \<Longrightarrow> connected(X)" @proof @contradiction @obtain A B where "separation(X,A,B)" @obtain "a \<in> A" @obtain "b \<in> B" @case "a <\<^sub>X b" @with @let "I = closed_interval(X,a,b)" @let "Y = ord_subspace(X,I)" @have "linear_continuum(Y)" @with @have "eq_str_order(suborder(X,I),Y)" @end @have "carrier(Y) = closed_interval(Y,a,b)" @have "separation(Y,I \<inter> A,I \<inter> B)" @with @have "eq_str_top(subspace(X,I),Y)" @end @end @case "b <\<^sub>X a" @with @let "I = closed_interval(X,b,a)" @let "Y = ord_subspace(X,I)" @have "linear_continuum(Y)" @with @have "eq_str_order(suborder(X,I),Y)" @end @have "carrier(Y) = closed_interval(Y,b,a)" @have "separation(X,B,A)" @have "separation(Y,I \<inter> B,I \<inter> A)" @with @have "eq_str_top(subspace(X,I),Y)" @end @end @qed end
[STATEMENT] lemma start_sttp_resp_popST [simp]: "start_sttp_resp (popST n)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. start_sttp_resp (popST n) [PROOF STEP] by (simp add: start_sttp_resp_def)
/- Copyright (c) 2021 OpenAI. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kunhao Zheng, Kudzo Ahegbebu, Stanislas Polu, David Renshaw, OpenAI GPT-f -/ import minif2f_import open_locale big_operators open_locale nat open_locale real open_locale rat theorem mathd_algebra_478 (b h v : ℝ) (h₀ : 0 < b ∧ 0 < h ∧ 0 < v) (h₁ : v = 1 / 3 * (b * h)) (h₂ : b = 30) (h₃ : h = 13 / 2) : v = 65 := begin rw [h₂, h₃] at h₁, rw h₁, norm_num, end theorem numbertheory_4x3m7y3neq2003 (x y : ℤ) : 4 * x^3 - 7 * y^3 ≠ 2003 := begin intro hneq, apply_fun (coe : ℤ → zmod 7) at hneq, push_cast at hneq, have : (2003 : zmod 7) = (1 : zmod 7), dec_trivial, rw this at hneq, have : (7 : zmod 7) = (0 : zmod 7), dec_trivial, rw this at hneq, rw zero_mul at hneq, rw sub_zero at hneq, have main : ∀ (x : zmod 7), x^3 ∈ [(0 : zmod 7), 1, -1], dec_trivial, rcases main x with h' | h' | h' | h, iterate 3 { rw h' at hneq, revert hneq, dec_trivial, }, exact h, end theorem aime_1983_p1 (x y z w : ℕ) (ht : 1 < x ∧ 1 < y ∧ 1 < z) (hw : 0 ≤ w) (h0 : real.log w / real.log x = 24) (h1 : real.log w / real.log y = 40) (h2 : real.log w / real.log (x * y * z) = 12): real.log w / real.log z = 60 := begin sorry end theorem amc12_2001_p5 : finset.prod (finset.filter (λ x, ¬ even x) (finset.range 10000)) (id : ℕ → ℕ) = (10000!) / ((2^5000) * 5000!) := begin sorry end theorem mathd_algebra_141 (a b : ℝ) (h₁ : (a * b)=180) (h₂ : 2 * (a + b)=54) : (a^2 + b^2) = 369 := begin replace h₂ : (a + b) = 27 , linarith, have h₃ : a^2 + b^2 = (a + b)^2 - 2 * (a * b), by ring, rw [h₃, h₂, h₁], norm_num, end theorem mathd_numbertheory_3 : (∑ x in finset.range 10, ((x + 1)^2)) % 10 = 5 := begin dec_trivial!, end theorem imo_1969_p2 (m n : ℝ) (k : ℕ) (a : ℕ → ℝ) (y : ℝ → ℝ) (h₀ : 0 < k) (h₁ : ∀ x, y x = ∑ i in finset.range k, ((real.cos (a i + x)) / (2^i))) (h₂ : y m = 0) (h₃ : y n = 0) : ∃ t : ℤ, m - n = t * π := begin sorry end theorem mathd_algebra_209 (σ : equiv ℝ ℝ) (h₀ : σ.2 2 = 10) (h₁ : σ.2 10 = 1) (h₂ : σ.2 1 = 2) : σ.1 (σ.1 10) = 1 := begin rw [← h₀, ← h₂], simp, end theorem mathd_numbertheory_1124 (n : ℕ) (h₀ : n ≤ 9) (h₁ : 18∣374 * 10 + n) : n = 4 := begin sorry end theorem imo_1983_p6 (a b c : ℝ) (h₀ : 0 < a ∧ 0 < b ∧ 0 < c) (h₁ : c < a + b) (h₂ : b < a + c) (h₃ : a < b + c) : 0 ≤ a^2 * b * (a - b) + b^2 * c * (b - c) + c^2 * a * (c - a) := begin sorry end theorem mathd_numbertheory_237 : (∑ k in (finset.range 101), k) % 6 = 4 := begin sorry end theorem mathd_algebra_33 (x y z : ℝ) (h₀ : x ≠ 0) (h₁ : 2 * x = 5 * y) (h₂ : 7 * y = 10 * z) : z / x = 7 / 25 := begin field_simp, nlinarith, end theorem amc12b_2021_p3 (x : ℝ) (h₀ : 2 + 1 / (1 + 1 / (2 + 2 / (3 + x))) = 144 / 53) : x = 3 / 4 := begin sorry end theorem mathd_numbertheory_299 : (1 * 3 * 5 * 7 * 9 * 11 * 13) % 10 = 5 := begin norm_num, end theorem amc12b_2020_p2 : ((100 ^ 2 - 7 ^ 2):ℝ) / (70 ^ 2 - 11 ^ 2) * ((70 - 11) * (70 + 11) / ((100 - 7) * (100 + 7))) = 1 := begin norm_num, end theorem algebra_sqineq_unitcircatbpabsamblt1 (a b: ℝ) (h₀ : a^2 + b^2 = 1) : a * b + ∥a - b∥ ≤ 1 := begin sorry end theorem imo_1977_p6 (f : ℕ+ → ℕ+) (h₀ : ∀ n, f (f n) < f (n + 1)) : ∀ n, f n = n := begin sorry end theorem mathd_algebra_419 (a b : ℝ) (h₀ : a = -1) (h₁ : b = 5) : -a - b^2 + 3 * (a * b) = -39 := begin rw [h₀, h₁], norm_num, end theorem amc12a_2020_p10 (n : ℕ+) (h₀ : real.log (real.log n / real.log 16) / real.log 2 = real.log (real.log n / real.log 4) / real.log 4) : n = 256 := begin sorry end theorem imo_1960_p2 (x : ℝ) (h₀ : 0 ≤ 1 + 2 * x) (h₁ : (1 - real.sqrt (1 + 2 * x))^2 ≠ 0) (h₂ : (4 * x^2) / (1 - real.sqrt (1 + 2*x))^2 < 2*x + 9) : -(1 / 2) ≤ x ∧ x < 45 / 8 := begin sorry end theorem mathd_numbertheory_427 (a : ℕ) (h₀ : a = (∑ k in (nat.divisors 500), k)) : ∑ k in finset.filter (λ x, nat.prime x) (nat.divisors a), k = 25 := begin sorry end theorem numbertheory_x5neqy2p4 (x y : ℤ) : x^5 ≠ y^2 + 4 := begin sorry end theorem imo_2007_p6 (a : ℕ → nnreal) (h₀ : ∑ x in finset.range 100, ((a (x + 1))^2) = 1) : ∑ x in finset.range 99, ((a (x + 1))^2 * a (x + 2)) + (a 100)^2 * a 1 < 12 / 25 := begin sorry end theorem mathd_algebra_398 (a b c : ℝ) (h₀ : 0 < a ∧ 0 < b ∧ 0 < c) (h₁ : 9 * b = 20 * c) (h₂ : 7 * a = 4 * b) : 63 * a = 80 * c := begin linarith, end theorem imo_1963_p5 : real.cos (π / 7) - real.cos (2 * π / 7) + real.cos (3 * π / 7) = 1 / 2 := begin sorry end theorem mathd_numbertheory_430 (a b c : ℕ) (h₀ : 1 ≤ a ∧ a ≤ 9) (h₁ : 1 ≤ b ∧ b ≤ 9) (h₂ : 1 ≤ c ∧ c ≤ 9) (h₃ : a ≠ b) (h₄ : a ≠ c) (h₅ : b ≠ c) (h₆ : a + b = c) (h₇ : 10 * a + a - b = 2 * c) (h₈ : c * b = 10 * a + a + a) : a + b + c = 8 := begin sorry end theorem mathd_algebra_459 (a b c d : ℚ) (h₀ : 3 * a = b + c + d) (h₁ : 4 * b = a + c + d) (h₂ : 2 * c = a + b + d) (h₃ : 8 * a + 10 * b + 6 * c = 24) : ↑d.denom + d.num = 28 := begin have h₄: d = 13/15, linarith, sorry end theorem induction_12dvd4expnp1p20 (n : ℕ) : 12 ∣ 4^(n+1) + 20 := begin have dvd_of_dvd_add_mul_left : ∀ (a b n : ℕ), a ∣ b + a * n → a ∣ b := begin intros a b n, refine (nat.dvd_add_left _).mp, exact (dvd_mul_right a n), end, induction n with k IH, { dec_trivial }, { rw pow_succ, -- If we add 60 to RHS, then we can factor the 4 to use IH apply dvd_of_dvd_add_mul_left 12 (4 * 4 ^ k.succ + 20) 5, exact dvd_mul_of_dvd_right IH 4, } end theorem mathd_algebra_320 (x : nnreal) (a b c : ℕ+) (h₀ : 2 * x^2 = 4 * x + 9) (h₁ : x = (a + nnreal.sqrt b) / c) : a + b + c = 26 := begin sorry end theorem mathd_algebra_137 (x : ℕ) (h₀ : ↑x + (4:ℝ) / (100:ℝ) * ↑x = 598) : x = 575 := begin have h₁ : ↑x = (575:ℝ), linarith, assumption_mod_cast, end theorem imo_1997_p5 (x y : ℕ) (h₀ : 0 < x ∧ 0 < y) (h₁ : x^(y^2) = y^x) : (x, y) = (1, 1) ∨ (x, y) = (16, 2) ∨ (x, y) = (27, 3) := begin sorry end theorem mathd_numbertheory_277 (m n : ℕ) (h₀ : nat.gcd m n = 6) (h₁ : nat.lcm m n = 126) : 60 ≤ m + n := begin sorry end theorem mathd_numbertheory_559 (x y : ℕ) (h₀ : x % 3 = 2) (h₁ : y % 5 = 4) (h₂ : x % 10 = y % 10) : 14 ≤ x := begin sorry end theorem mathd_algebra_160 (n x : ℝ) (h₀ : n + x = 97) (h₁ : n + 5 * x = 265) : n + 2 * x = 139 := begin linarith, end theorem mathd_algebra_24 (x : ℝ) (h₀ : x / 50 = 40) : x = 2000 := begin nlinarith, end theorem mathd_algebra_176 (x : ℝ) : (x + 1)^2 * x = x^3 + 2 * x^2 + x := begin ring_nf, end theorem induction_nfactltnexpnm1ngt3 (n : ℕ) (h₀ : 3 ≤ n) : nat.factorial n < n^(n - 1) := begin induction h₀ with k h₀ IH, { norm_num }, { have k_ge_one : 1 ≤ k := le_trans dec_trivial h₀, calc k.succ.factorial = k.succ * k.factorial : rfl ... < k.succ * k ^ (k-1) : (mul_lt_mul_left (nat.succ_pos k)).mpr IH ... ≤ k.succ * (k.succ) ^ (k-1): nat.mul_le_mul_left _ $ nat.pow_le_pow_of_le_left (nat.le_succ k) (k-1) ... = k.succ ^ (k-1 + 1): by rw ← (pow_succ k.succ (k-1)) ... = k.succ ^ k: by rw nat.sub_add_cancel k_ge_one, } end theorem mathd_algebra_208 : real.sqrt 1000000 - 1000000^((1:ℝ)/3) = 900 := begin sorry end theorem mathd_numbertheory_353 (s : ℕ) (h₀ : s = ∑ k in finset.range 4019 \ finset.range 2010, k) : s % 2009 = 0 := begin sorry end theorem numbertheory_notequiv2i2jasqbsqdiv8 (a b : ℤ) : ¬ ((∃ i j, a = 2*i ∧ b=2*j) ↔ (∃ k, a^2 + b^2 = 8*k)) := begin sorry end theorem mathd_algebra_156 (x y : ℝ) (f g : ℝ → ℝ) (h₀ : ∀t, f t = t^4) (h₁ : ∀t, g t = 5 * t^2 - 6) (h₂ : f x = g x) (h₃ : f y = g y) (h₄ : x^2 < y^2) : y^2 - x^2 = 1 := begin sorry end theorem mathd_numbertheory_12 : finset.card (finset.filter (λ x, 20∣x) (finset.range 86 \ finset.range 15)) = 4 := begin sorry end theorem mathd_numbertheory_345 : (2000 + 2001 + 2002 + 2003 + 2004 + 2005 + 2006) % 7 = 0 := begin norm_num, end theorem mathd_numbertheory_447 : ∑ k in finset.filter (λ x, 3∣x) (finset.erase (finset.range 50) 0), (k % 10) = 78 := begin sorry end theorem mathd_numbertheory_328 : (5^999999) % 7 = 6 := begin sorry end theorem mathd_numbertheory_451 (h₀ : fintype {n : ℕ | 2010 ≤ n ∧ n ≤ 2019 ∧ ∃ m, (finset.card (nat.divisors m) = 4 ∧ ∑ p in (nat.divisors m), p = n)}) : ∑ k in {n : ℕ | 2010 ≤ n ∧ n ≤ 2019 ∧ ∃ m, (finset.card (nat.divisors m) = 4 ∧ ∑ p in (nat.divisors m), p = n)}.to_finset, k = 2016 := begin sorry end theorem aime_1997_p9 (a : ℝ) (h₀ : 0 < a) (h₁ : 1 / a - int.floor (1 / a) = a^2 - int.floor (a^2)) (h₂ : 2 < a^2) (h₃ : a^2 < 3) : a^12 - 144 * (1 / a) = 233 := begin sorry end theorem algebra_sqineq_at2malt1 (a : ℝ) : a * (2 - a) ≤ 1 := begin suffices: 0 ≤ a^2 - 2*a + 1, nlinarith, suffices: 0 ≤ (a - 1)^2, nlinarith, nlinarith, end theorem algebra_apbmpcneq0_aeq0anbeq0anceq0 (a b c : ℚ) (m n : ℝ) (h₀ : 0 < m ∧ 0 < n) (h₁ : m^3 = 2) (h₂ : n^3 = 4) (h₃ : (a:ℝ) + b * m + c * n = 0) : a = 0 ∧ b = 0 ∧ c = 0 := begin sorry end theorem mathd_algebra_171 (f : ℝ → ℝ) (h₀ : ∀x, f x = 5 * x + 4) : f 1 = 9 := begin rw h₀, linarith, end theorem mathd_numbertheory_227 (x y n : ℕ+) (h₀ : ↑x / (4:ℝ) + y / 6 = (x + y) / n) : n = 5 := begin field_simp at h₀, have h₂ : (6:ℝ) * x * (n - 4) = 4 * y * (6 - n), { field_simp, ring_nf, linarith[h₀], }, have p₁ : (0:ℝ) < y, norm_num, have p₂ : (0:ℝ) < x, norm_num, have repl₁: ↑(6:ℕ+) = (6:ℕ), { apply @pnat.to_pnat'_coe 6, norm_num, }, have repl₂: ↑(4:ℕ+) = (4:ℕ), { apply @pnat.to_pnat'_coe 4, norm_num, }, by_contradiction h, change n ≠ 5 at h, by_cases b₀ : n < 5, { have k₁ : (0:ℝ) < 4 * ↑y * (6 - ↑n), { suffices: (0:ℝ) < (6 - ↑n), { nlinarith [this, p₁], }, norm_num [b₀], norm_cast, rw ← repl₁, norm_cast, clear h₀ h₂ h repl₁, suffices: (5:ℕ+) < 6, { exact lt_trans b₀ this, }, dec_trivial!, }, rw ← h₂ at k₁, have k₂ : 6 * ↑x * (↑n - 4) ≤ (0:ℝ), { suffices: (↑n - 4) ≤ (0:ℝ), { nlinarith [this, p₂], }, norm_num, norm_cast, rw ← repl₂, norm_cast, apply pnat.lt_add_one_iff.mp, suffices : (4 + 1) = (5:ℕ+), { rwa this, }, dec_trivial!, }, revert k₂, contrapose!, intro k₃, exact k₁, }, { have b₁: 5 < n, { push_neg at b₀, exact (ne.symm h).le_iff_lt.mp b₀, }, have k₁ : 4 * ↑y * (6 - ↑n) ≤ (0:ℝ), { suffices: (6 - ↑n) ≤ (0:ℝ), { nlinarith [this, p₁], }, norm_num, norm_cast, rw ← repl₁, norm_cast, exact b₁, }, have k₂ : (0:ℝ) < 6 * ↑x * (↑n - 4), { suffices : (0: ℝ) < (↑n - 4), { nlinarith [this, p₂], }, norm_num, norm_cast, rw ← repl₂, norm_cast, refine lt_trans _ b₁, dec_trivial!, }, rw ← h₂ at k₁, revert k₂, contrapose!, intro k₃, exact k₁, }, end theorem mathd_algebra_188 (σ : equiv ℝ ℝ) (h : σ.1 2 = σ.2 2) : σ.1 (σ.1 2) = 2 := begin simp [h] end theorem mathd_numbertheory_765 (x : ℤ) (h₀ : x < 0) (h₁ : (24 * x) % 1199 = 15) : x ≤ -449 := begin sorry end theorem imo_1959_p1 (n : ℕ+) : nat.gcd (21*n + 4) (14*n + 3) = 1 := begin sorry end theorem mathd_numbertheory_175 : (2^2010) % 10 = 4 := begin sorry end theorem induction_sumkexp3eqsumksq (n : ℕ) : ∑ k in finset.range n, k^3 = (∑ k in finset.range n, k)^2 := begin symmetry, induction n with j IH, { refl, }, { calc (∑ (k : ℕ) in finset.range j.succ, k)^2 = ((∑ (k : ℕ) in finset.range j, k) + j)^2 : by rw finset.sum_range_succ ... = (∑ (k : ℕ) in finset.range j, k)^2 + 2 * (∑ (k : ℕ) in finset.range j, k) * j + j^2 : by rw add_sq _ _ ... = (∑ (k : ℕ) in finset.range j, k)^2 + (∑ (k : ℕ) in finset.range j, k) * 2 * j + j^2 : by ring ... = (∑ (k : ℕ) in finset.range j, k)^2 + (j * (j-1)) * j + j^2 : by rw finset.sum_range_id_mul_two j ... = (∑ (k : ℕ) in finset.range j, k^3) + (j * (j-1)) * j + j^2 : by rw IH ... = (∑ (k : ℕ) in finset.range j, k^3) + j^2 * (j-1) + j^2 : by ring_nf ... = (∑ (k : ℕ) in finset.range j, k^3) + j^3 : by cases j ; [norm_num, ring_nf] ... = (∑ (k : ℕ) in finset.range j.succ, k^3) : by rw ← finset.sum_range_succ, } end theorem numbertheory_fxeq4powxp6powxp9powx_f2powmdvdf2pown (m n : ℕ) (f : ℕ → ℕ) (h₀ : ∀ x, f x = 4^x + 6^x + 9^x) (h₁ : 0 < m ∧ 0 < n) (h₂ : m ≤ n) : f (2^m)∣f (2^n) := begin sorry end theorem imo_1992_p1 (p q r : ℤ) (h₀ : 1 < p ∧ p < q ∧ q < r) (h₁ : (p - 1) * (q - 1) * (r - 1)∣(p * q * r - 1)) : (p, q, r) = (2, 4, 8) ∨ (p, q, r) = (3, 5, 15) := begin sorry end theorem imo_1982_p1 (f : ℕ+ → ℕ) (h₀ : ∀ m n, f (m + n) - f m - f n = 0 ∨ f (m + n) - f m - f n = 1) (h₁ : f 2 = 0) (h₂ : 0 < f 3) (h₃ : f 9999 = 3333) : f 1982 = 660 := begin sorry end theorem aime_1987_p5 (x y : ℤ) (h₀ : y^2 + 3 * (x^2 * y^2) = 30 * x^2 + 517): 3 * (x^2 * y^2) = 588 := begin sorry end theorem mathd_algebra_346 (f g : ℝ → ℝ) (h₀ : ∀ x, f x = 2 * x - 3) (h₁ : ∀ x, g x = x + 1) : g (f 5 - 1) = 7 := begin rw [h₀, h₁], norm_num, end theorem mathd_algebra_487 (a b c d : ℝ) (h₀ : b = a^2) (h₁ : a + b = 1) (h₂ : d = c^2) (h₃ : c + d = 1) : real.sqrt ((a - c)^2 + (b - d)^2)= real.sqrt 10 := begin sorry end theorem mathd_numbertheory_728 : (29^13 - 5^13) % 7 = 0 := begin sorry end theorem mathd_algebra_184 (a b : nnreal) (h₀ : 0 < a ∧ 0 < b) (h₁ : (a^2) = 6*b) (h₂ : (a^2) = 54/b) : a = 3 * nnreal.sqrt 2 := begin have key₁ : b ≠ 0 := ne_of_gt h₀.2, have h₄ : 0 ≤ a, { exact zero_le _ }, suffices : a^2=18, { rw eq_comm, have h₅ : 3 * nnreal.sqrt 2 = nnreal.sqrt 18, { calc 3 * nnreal.sqrt 2 = (nnreal.sqrt 9) * (nnreal.sqrt 2) : by {rw eq_comm, simp, rw nnreal.sqrt_eq_iff_sq_eq, ring} ...= nnreal.sqrt (9 * 2): by {rw ← nnreal.sqrt_mul} ...= nnreal.sqrt 18: by{ring_nf}, }, rw [h₅, nnreal.sqrt_eq_iff_sq_eq], rw ← this, ring, }, have key₂ : (6 * b * b) = 54, { rw h₁ at h₂, exact (eq_div_iff key₁).mp h₂, }, have key₃ : b = 3, { have key₅ : (6 : nnreal) ≠ 0, { refine nnreal.ne_iff.mp _, norm_num, }, calc b = nnreal.sqrt (b * b) : by { rw eq_comm, apply nnreal.sqrt_mul_self} ... = nnreal.sqrt ((6*b*b)/6) : by {refine congr_arg ⇑nnreal.sqrt _, ring_nf, refine (eq_div_iff _).mpr _, {exact key₅}, rw mul_comm, } ... = nnreal.sqrt (54/6): by {rw key₂} ... = nnreal.sqrt(9) : by {refine congr_arg ⇑nnreal.sqrt _, refine (div_eq_iff key₅).mpr _, ring,} ... = 3 : by {rw nnreal.sqrt_eq_iff_sq_eq, ring}, }, rw key₃ at h₁, rw h₁, ring, end theorem mathd_numbertheory_552 (f g h : ℕ+ → ℕ) (h₀ : ∀ x, f x = 12 * x + 7) (h₁ : ∀ x, g x = 5 * x + 2) (h₂ : ∀ x, h x = nat.gcd (f x) (g x)) (h₃ : fintype (h '' {x : ℕ+ | true})) : ∑ k in (h '' {x : ℕ+ | true}).to_finset, k = 12 := begin sorry end theorem amc12b_2021_p9 : (real.log 80 / real.log 2) / (real.log 2 / real.log 40) - (real.log 160 / real.log 2) / (real.log 2 / real.log 20) = 2 := begin sorry end theorem aime_1994_p3 (x : ℤ) (f : ℤ → ℤ) (h0 : f x + f (x-1) = x^2) (h1 : f 19 = 94): f (94) % 1000 = 561 := begin sorry end theorem mathd_algebra_44 (s t : ℝ) (h₀ : s = 9 - 2 * t) (h₁ : t = 3 * s + 1) : s = 1 ∧ t = 4 := begin split; linarith, end theorem mathd_algebra_215 (h₀ : fintype {x : ℝ | (x + 3)^2 = 121}) : ∑ k in {x : ℝ | (x + 3)^2 = 121}.to_finset, k = -6 := begin sorry end theorem mathd_numbertheory_293 (n : ℕ) (h₀ : n ≤ 9) (h₁ : 11∣20 * 100 + 10 * n + 7) : n = 5 := begin sorry end theorem mathd_numbertheory_769 : (129^34 + 96^38) % 11 = 9 := begin sorry end theorem mathd_algebra_452 (a : ℕ+ → ℝ) (h₀ : ∀ n, a (n + 2) - a (n + 1) = a (n + 1) - a n) (h₁ : a 1 = 2 / 3) (h₂ : a 2 = 4 / 5) : a 5 = 11 / 15 := begin sorry end theorem mathd_numbertheory_5 (n : ℕ) (h₀ : 10 ≤ n) (h₁ : ∃ x, x^2 = n) (h₂ : ∃ t, t^3 = n) : 64 ≤ n := begin sorry end theorem mathd_numbertheory_207 : 8 * 9^2 + 5 * 9 + 2 = 695 := begin norm_num, end theorem mathd_numbertheory_342 : 54 % 6 = 0 := begin norm_num, end theorem mathd_numbertheory_483 (a : ℕ+ → ℕ+) (h₀ : a 1 = 1) (h₁ : a 2 = 1) (h₂ : ∀ n, a (n + 2) = a (n + 1) + a n) : ((a 100):ℕ) % 4 = 3 := begin sorry end theorem amc12b_2020_p21 (h₀ : fintype {n : ℕ+ | (↑n + (1000:ℝ)) / (70:ℝ) = int.floor (real.sqrt n)}) : finset.card {n : ℕ+ | (↑n + (1000:ℝ)) / (70:ℝ) = int.floor (real.sqrt n)}.to_finset = 6 := begin sorry end theorem amc12a_2003_p5 (a m c : ℕ) (h₀ : a ≤ 9 ∧ m ≤ 9 ∧ c ≤ 9) (h₁ : 10*(10*(10*(10*a + m) + c) + 1) + 0 + (10*(10*(10*(10*a + m) + c) + 1) + 2) = 123422) : a + m + c = 14 := begin sorry end theorem mathd_numbertheory_495 (a b : ℕ) (h₀ : 0 < a ∧ 0 < b) (h₁ : a % 10 = 2) (h₂ : b % 10 = 4) (h₃ : nat.gcd a b = 6) : 108 ≤ nat.lcm a b := begin sorry end theorem mathd_algebra_296 : abs (((3491 - 60) * (3491 + 60) - 3491^2):ℤ) = 3600 := begin rw abs_of_nonpos, norm_num, norm_num, end theorem algebra_abpbcpcageq3_sumaonsqrtapbgeq3onsqrt2 (a b c : ℝ) (h₀ : 0 < a ∧ 0 < b ∧ 0 < c) (h₁ : 3 ≤ a * b + b * c + c * a) : 3 / real.sqrt 2 ≤ a / real.sqrt (a + b) + b / real.sqrt (b + c) + c / real.sqrt (c + a) := begin sorry end theorem algebra_2varlineareq_fp3zeq11_3tfm1m5zeqn68_feqn10_zeq7 (f z: ℂ) (h₀ : f + 3*z = 11) (h₁ : 3*(f - 1) - 5*z = -68) : f = -10 ∧ z = 7 := begin sorry end theorem mathd_numbertheory_247 (n : ℕ) (h₀ : (3 * n) % 2 = 11) : n % 11 = 8 := begin sorry end theorem induction_pord1p1on2powklt5on2 (n : ℕ) (h₀ : 0 < n) : ∏ k in finset.range (n + 1) \ finset.range 1, (1 + (1:ℝ) / 2^k) < 5 / 2 := begin sorry end theorem mathd_algebra_107 (x y : ℝ) (h₀ : x^2 + 8 * x + y^2 - 6 * y = 0) : (x + 4)^2 + (y-3)^2 = 5^2 := begin linarith, end theorem numbertheory_2pownm1prime_nprime (n : ℕ) (h₀ : 0 < n) (h₁ : nat.prime (2^n - 1)) : nat.prime n := begin sorry end theorem mathd_algebra_412 (x y : ℝ) (h₀ : x + y = 25) (h₁ : x - y = 11) : x = 18 := begin linarith, end theorem amc12a_2013_p4 : (2^2014 + 2^2012) / (2^2014 - 2^2012) = (5:ℝ) / 3 := begin sorry end theorem mathd_algebra_392 (n : ℕ) (h₀ : even n) (h₁ : (↑n - 2)^2 + ↑n^2 + (↑n + 2)^2 = (12296:ℤ)) : ((↑n - 2) * ↑n * (↑n + 2)) / 8 = (32736:ℤ) := begin sorry end theorem mathd_numbertheory_314 (r n : ℕ) (h₀ : r = 1342 % 13) (h₁ : 0 < n) (h₂ : 1342∣n) (h₃ : n % 13 < r) : 6710 ≤ n := begin sorry end theorem induction_prod1p1onk3le3m1onn (n : ℕ) (h₀ : 0 < n) : ∏ k in finset.range (n + 1) \ finset.range 1, (1 + (1:ℝ) / k^3) ≤ (3:ℝ) - 1 / ↑n := begin sorry end theorem mathd_numbertheory_343 : (∏ k in finset.range 6, (2 * k + 1)) % 10 = 5 := begin sorry end theorem mathd_algebra_756 (a b : ℝ) (h₀ : (2:ℝ)^a = 32) (h₁ : a^b = 125) : b^a = 243 := begin sorry end theorem amc12b_2002_p7 (a b c : ℕ+) (h₀ : b = a + 1) (h₁ : c = b + 1) (h₂ : a * b * c = 8 * (a + b + c)) : a^2 + (b^2 + c^2) = 77 := begin sorry end theorem mathd_algebra_80 (x : ℝ) (h₀ : x ≠ -1) (h₁ : (x - 9) / (x + 1) = 2) : x = -11 := begin revert x h₀ h₁, norm_num, intros _ hx, simp [hx, two_mul, sub_eq_add_neg], intro H, rwa [div_eq_iff_mul_eq] at H, linarith, norm_num, intro h, exact hx (add_eq_zero_iff_eq_neg.1 h), end theorem mathd_numbertheory_457 (n : ℕ) (h₀ : 0 < n) (h₁ : 80325∣(n!)) : 17 ≤ n := begin sorry end theorem amc12_2000_p12 (a m c : ℕ) (h₀ : a + m + c = 12) : a*m*c + a*m + m*c + a*c ≤ 112 := begin sorry end theorem mathd_numbertheory_135 (n a b c: ℕ) (h₀ : n = 3^17 + 3^10) (h₁ : 11 ∣ (n + 1)) (h₂ : odd a ∧ odd c) (h₃ : ¬ 3 ∣ b) (h₄ : n = 10*(10*(10*(10*(10*(10*(10*(10*a +b) +c) +a) +c) +c) +b) +a) +b) : 10*(10 * a + b) + c = 129 := begin sorry end theorem mathd_algebra_275 (x : ℝ) (h : ((11:ℝ)^(1 / 4))^(3 * x - 3) = 1 / 5) : ((11:ℝ)^(1 / 4))^(6 * x + 2) = 121 / 25 := begin revert x h, norm_num, end theorem mathd_algebra_388 (x y z : ℝ) (h₀ : 3 * x + 4 * y - 12 * z = 10) (h₁ : -2 * x - 3 * y + 9 * z = -4) : x = 14 := begin linarith, end theorem amc12a_2020_p7 (a : ℕ → ℕ) (h₀ : (a 0)^3 = 1) (h₁ : (a 1)^3 = 8) (h₂ : (a 2)^3 = 27) (h₃ : (a 3)^3 = 64) (h₄ : (a 4)^3 = 125) (h₅ : (a 5)^3 = 216) (h₆ : (a 6)^3 = 343) : ↑∑ k in finset.range 7, (6 * (a k)^2) - ↑(2 * ∑ k in finset.range 6, (a k)^2) = (658:ℤ) := begin sorry end theorem imo_1981_p6 (f : ℕ → ℕ → ℕ) (h₀ : ∀ y, f 0 y = y + 1) (h₁ : ∀ x, f (x + 1) 0 = f x 1) (h₂ : ∀ x y, f (x + 1) (y + 1) = f x (f (x + 1) y)) : ∀ y, f 4 (y + 1) = 2^(f 4 y + 3) - 3 := begin sorry end theorem mathd_algebra_263 (y : ℝ) (h₀ : 0 ≤ 19 + 3 * y) (h₁ : real.sqrt (19 + 3 * y) = 7) : y = 10 := begin revert y h₀ h₁, intros x hx, rw real.sqrt_eq_iff_sq_eq hx, swap, norm_num, intro h, nlinarith, end theorem mathd_numbertheory_34 (x: ℕ) (h₀ : x < 100) (h₁ : x*9 % 100 = 1) : x = 89 := begin sorry end theorem mathd_numbertheory_764 (p : ℕ) (h₀ : nat.prime p) (h₁ : 7 ≤ p) : ∑ k in finset.erase (finset.range (p - 1)) 0, ((k:zmod p)⁻¹ * ((k:zmod p) + 1)⁻¹) = 2 := begin sorry end theorem amc12b_2021_p4 (m a : ℕ+) (h₀ : ↑m / ↑a = (3:ℝ) / 4) : (84 * ↑m + 70 * ↑a) / (↑m + ↑a) = (76:ℝ) := begin sorry end theorem imo_1962_p2 (x : ℝ) (h₀ : 0 ≤ 3 - x) (h₁ : 0 ≤ x + 1) (h₂ : 1 / 2 < real.sqrt (3 - x) - real.sqrt (x + 1)) : -1 ≤ x ∧ x < 1 - real.sqrt 31 / 8 := begin sorry end theorem mathd_algebra_170 (h₀ : fintype {n : ℤ | abs (n - 2) ≤ 5 + 6 / 10}) : finset.card { n : ℤ | abs (n - 2) ≤ 5 + 6 / 10}.to_finset = 11 := begin sorry end theorem mathd_algebra_432 (x : ℝ) : (x + 3) * (2 * x - 6) = 2 * x^2 - 18 := begin linarith, end theorem mathd_algebra_598 (a b c d : ℝ) (h₁ : ((4:ℝ)^a) = 5) (h₂ : ((5:ℝ)^b) = 6) (h₃ : ((6:ℝ)^c) = 7) (h₄ : ((7:ℝ)^d) = 8) : a * b * c * d = 3 / 2 := begin sorry end theorem algebra_bleqa_apbon2msqrtableqambsqon8b (a b : ℝ) (h₀ : 0 < a ∧ 0 < b) (h₁ : b ≤ a) : (a + b) / 2 - real.sqrt (a * b) ≤ (a - b)^2 / (8 * b) := begin sorry end theorem mathd_algebra_276 (a b : ℤ) (h₀ : ∀ x : ℝ, 10 * x^2 - x - 24 = (a * x - 8) * (b * x + 3)) : a + b = 12 := begin sorry end theorem amc12a_2021_p14 : (∑ k in (finset.erase (finset.range 21) 0), (real.log (3^(k^2)) / real.log (5^k))) * ∑ k in (finset.erase (finset.range 101) 0), (real.log (25^k) / real.log (9^k)) = 21000 := begin sorry end theorem algebra_sum1onsqrt2to1onsqrt10000lt198 : ∑ k in finset.range 10001 \ finset.range 2, (1 / real.sqrt k) < 198 := begin sorry end theorem mathd_numbertheory_618 (n : ℕ) (p : ℕ → ℕ) (h₀ : ∀ x, p x = x^2 - x + 41) (h₁ : 1 < nat.gcd (p n) (p (n+1))) : 41 ≤ n := begin sorry end theorem amc12a_2020_p4 (a b c d : ℕ) (h₀ : 1 ≤ a ∧ a ≤ 9 ∧ even a) (h₁ : 0 ≤ b ∧ b ≤ 9 ∧ even b) (h₂ : 0 ≤ c ∧ c ≤ 9 ∧ even c) (h₃ : 0 ≤ d ∧ d ≤ 9 ∧ even d) (h₄ : fintype {n : ℕ | n = 10 * (10*(10*a + b) + c) + d ∧ 5∣n}) : finset.card {n : ℕ | n = 10 * (10*(10*a + b) + c) + d ∧ 5∣n}.to_finset = 100 := begin sorry end theorem amc12b_2020_p6 (n : ℕ) (h₀ : 9 ≤ n) : ∃ x : ℕ, (x:ℝ)^2 = (nat.factorial (n + 2) - nat.factorial (n + 1)) / nat.factorial n := begin sorry end theorem mathd_numbertheory_435 (k : ℕ) (h₀ : 0 < k) (h₁ : ∀ n, gcd (6 * n + k) (6 * n + 3) = 1) (h₂ : ∀ n, gcd (6 * n + k) (6 * n + 2) = 1) (h₃ : ∀ n, gcd (6 * n + k) (6 * n + 1) = 1) : 5 ≤ k := begin sorry end theorem algebra_others_exirrpowirrrat : ∃ a b, irrational a ∧ irrational b ∧ ¬ irrational (a^b) := begin let sqrt_2 := real.sqrt 2, by_cases irrational (sqrt_2^sqrt_2), { have h': ¬ irrational ((sqrt_2^sqrt_2)^sqrt_2), { intro h, rw ← (real.rpow_mul (real.sqrt_nonneg 2) (real.sqrt 2) (real.sqrt 2)) at h, have zlet : 0 ≤ (2 : ℝ), by norm_num, rw ← (real.sqrt_mul zlet 2) at h, rw real.sqrt_mul_self zlet at h, have x : (real.sqrt 2)^(2 : ℕ) = (real.sqrt 2)^(2 : ℝ), by norm_cast, rw ← x at h, rw real.sq_sqrt zlet at h, have tnotira : ¬ irrational 2, { convert rat.not_irrational 2, norm_cast, }, exact tnotira h, }, exact ⟨(sqrt_2^sqrt_2), sqrt_2, h, irrational_sqrt_two, h'⟩, }, { exact ⟨sqrt_2, sqrt_2, irrational_sqrt_two, irrational_sqrt_two, h⟩, } end theorem mathd_algebra_427 (x y z : ℝ) (h₀ : 3 * x + y = 17) (h₁ : 5 * y + z = 14) (h₂ : 3 * x + 5 * z = 41) : x + y + z = 12 := begin have h₃ := congr (congr_arg has_add.add h₀) h₁, linarith, end theorem mathd_algebra_76 (f : ℤ → ℤ) (h₀ : ∀n, odd n → f n = n^2) (h₁ : ∀ n, even n → f n = n^2 - 4*n -1) : f 4 = -1 := begin suffices : f 4 = 4^2 - 4*4 - 1, rw this; ring_nf, apply h₁, refine even_iff_two_dvd.mpr _, exact two_dvd_bit0, end theorem mathd_numbertheory_99 (n : ℕ) (h₀ : (2 * n) % 47 = 15) : n % 47 = 31 := begin sorry end theorem algebra_9onxpypzleqsum2onxpy (x y z : ℝ) (h₀ : 0 < x ∧ 0 < y ∧ 0 < z) : 9 / (x + y + z) ≤ 2 / (x + y) + 2 / (y + z) + 2 / (z + x) := begin sorry end theorem mathd_numbertheory_233 (b : zmod (11^2)) (h₀ : b = 24⁻¹) : b = 116 := begin sorry end theorem algebra_absapbon1pabsapbleqsumabsaon1pabsa (a b : ℝ) : abs (a + b) / (1 + abs (a + b)) ≤ abs a / (1 + abs a) + abs b / (1 + abs b) := begin sorry end theorem imo_1984_p6 (a b c d k m : ℕ) (h₀ : 0 < a ∧ 0 < b ∧ 0 < c ∧ 0 < d) (h₁ : odd a ∧ odd b ∧ odd c ∧ odd d) (h₂ : a < b ∧ b < c ∧ c < d) (h₃ : a * d = b * c) (h₄ : a + d = 2^k) (h₅ : b + c = 2^m) : a = 1 := begin sorry end theorem imo_2001_p6 (a b c d : ℕ) (h₀ : 0 < a ∧ 0 < b ∧ 0 < c ∧ 0 < d) (h₁ : d < c) (h₂ : c < b) (h₃ : b < a) (h₄ : a * c + b * d = (b + d + a - c) * (b + d - a + c)) : ¬ nat.prime (a * b + c * d) := begin sorry end theorem mathd_numbertheory_321 (n : zmod 1399) (h₁ : n = 160⁻¹) : n = 1058 := begin sorry end theorem mathd_algebra_17 (a : ℝ) (h₀ : real.sqrt (4 + real.sqrt (16 + 16 * a)) + real.sqrt (1 + real.sqrt (1 + a)) = 6) : a = 8 := begin sorry end theorem mathd_algebra_153 (n : ℝ) (h₀ : n = 1 / 3) : int.floor (10 * n) + int.floor (100 * n) + int.floor (1000 * n) + int.floor (10000 * n) = 3702 := begin sorry end theorem algebra_sqineq_unitcircatbpamblt1 (a b: ℝ) (h₀ : a^2 + b^2 = 1) : a * b + (a - b) ≤ 1 := begin nlinarith [sq_nonneg (a - b)], end theorem amc12a_2021_p18 (f : ℚ → ℝ) (h₀ : ∀x>0, ∀y>0, f (x * y) = f x + f y) (h₁ : ∀p, nat.prime p → f p = p) : f (25 /. 11) < 0 := begin sorry end theorem mathd_algebra_329 (x y : ℝ) (h₀ : 3 * y = x) (h₁ : 2 * x + 5 * y = 11) : x + y = 4 := begin linarith, end theorem induction_pprime_pdvdapowpma (p a : ℕ) (h₀ : 0 < a) (h₁ : nat.prime p) : p ∣ (a^p - a) := begin sorry, end theorem amc12a_2021_p9 : ∏ k in finset.range 7, (2^(2^k) + 3^(2^k)) = 3^128 - 2^128 := begin simp only [finset.prod_range_succ], norm_num, end -- Sum a sequence by grouping adjacent terms. lemma sum_pairs (n : ℕ) (f : ℕ → ℚ) : ∑ k in (finset.range (2 * n)), f k = ∑ k in (finset.range n), (f (2 * k) + f (2 * k + 1)) := begin induction n with pn hpn, { simp only [finset.sum_empty, finset.range_zero, mul_zero] }, { have hs: (2 * pn.succ) = (2 * pn).succ.succ := rfl, rw [finset.sum_range_succ, ←hpn, hs, finset.sum_range_succ, finset.sum_range_succ], ring }, end theorem aime_1984_p1 (u : ℕ → ℚ) (h₀ : ∀ n, u (n + 1) = u n + 1) (h₁ : ∑ k in finset.range 98, u k.succ = 137) : ∑ k in finset.range 49, u (2 * k.succ) = 93 := begin -- We will use sum_pairs and h₀ to rewrite h₁ and the goal in terms of the quantity -- ∑ k in finset.range 49, u (2 * k + 1). have h₂ : ∀ k, k ∈ finset.range 49 → u (2 * k + 1 + 1) = u (2 * k + 1) + 1 := by { intros k hk, exact h₀ (2 * k + 1) }, have h₃: ∑ (x : ℕ) in finset.range 49, (1:ℚ) = 49 := by simp only [mul_one, nat.cast_bit0, finset.sum_const, nsmul_eq_mul, nat.cast_bit1, finset.card_range, nat.cast_one], have h98 : 98 = 2 * 49 := by norm_num, rw [h98, sum_pairs, finset.sum_add_distrib, finset.sum_congr rfl h₂, finset.sum_add_distrib, h₃, ←add_assoc] at h₁, have h₄ : ∑ (k : ℕ) in finset.range 49, u (2 * k.succ) = ∑ (k : ℕ) in finset.range 49, (u (2 * k + 1) + 1) := finset.sum_congr rfl h₂, rw [h₄, finset.sum_add_distrib, h₃], linarith, end theorem amc12a_2021_p22 (a b c : ℝ) (f : ℝ → ℝ) (h₀ : ∀ x, f x = x^3 + a * x^2 + b * x + c) (h₁ : f⁻¹' {0} = {real.cos (2 * real.pi / 7), real.cos (4 * real.pi / 7), real.cos (6 * real.pi / 7)}) : a * b * c = 1 / 32 := begin sorry end theorem mathd_numbertheory_229 : (5^30) % 7 = 1 := begin have five_to_thirty_is_one : (5^30 : zmod 7) = 1 := begin have five_to_the_six_is_one : (5^6 : zmod 7) = 1, by dec_trivial, have break_power : (5^30 : zmod 7) = (5^6)^5, by norm_num, rw break_power, rw five_to_the_six_is_one, norm_num, end, change 5^30 ≡ 1 [MOD 7], rw ←zmod.eq_iff_modeq_nat, exact_mod_cast five_to_thirty_is_one, end theorem mathd_numbertheory_100 (n : ℕ+) (h₀ : nat.gcd n 40 = 10) (h₁ : nat.lcm n 40 = 280) : n = 70 := begin sorry end theorem mathd_algebra_313 (v i z : ℂ) (h₀ : v = i * z) (h₁ : v = 1 + complex.I) (h₂ : z = 2 - complex.I) : i = 1/5 + 3/5 * complex.I := begin rw [h₁, h₂] at h₀, rw eq_comm at h₀, have h₃ : (2 - complex.I) ≠ 0, { sorry }, have h₄ := (eq_div_iff h₃).mpr h₀, rw h₄, rw eq_comm, apply (eq_div_iff h₃).mpr, sorry end theorem amc12b_2002_p4 (n : ℕ+) (h₀ : (1 /. 2 + 1 /. 3 + 1 /. 7 + 1 /. ↑n).denom = 1) : n = 42 := begin sorry end theorem amc12a_2002_p6 (n : ℕ+) : ∃ m, (m > n ∧ ∃ p, m * p ≤ m + p) := begin use (n : ℕ).succ, { apply nat.succ_pos }, norm_num, split, { exact_mod_cast (nat.lt_succ_self _) }, use 1, rw mul_one, apply nat.succ_le_succ, exact le_of_lt (nat.lt_succ_self n), end theorem amc12a_2003_p23 (h₀ : fintype {k : ℕ+ | ((k * k):ℕ) ∣ (∏ i in (finset.erase (finset.range 10) 0), i!)}) : finset.card {k : ℕ+ | ((k * k):ℕ) ∣ (∏ i in (finset.erase (finset.range 10) 0), i!)}.to_finset = 672 := begin sorry end theorem mathd_algebra_129 (a : ℝ) (h₀ : a ≠ 0) (h₁ : 8⁻¹ / 4⁻¹ - a⁻¹ = 1) : a = -2 := begin field_simp at h₁, linarith, end theorem amc12b_2021_p18 (z : ℂ) (h₀ : 12 * complex.norm_sq z = 2 * complex.norm_sq (z + 2) + complex.norm_sq (z^2 + 1) + 31) : z + 6 / z = -2 := begin sorry end theorem mathd_algebra_484 : real.log 27 / real.log 3 = 3 := begin rw real.log_div_log, have three_to_three : (27 : ℝ) = (3 : ℝ)^(3 : ℝ), by norm_num, rw three_to_three, have trivial_ineq: (0 : ℝ) < (3 : ℝ), by norm_num, have trivial_neq: (3: ℝ) ≠ (1 : ℝ), by norm_num, exact real.logb_rpow trivial_ineq trivial_neq, end theorem mathd_numbertheory_551 : 1529 % 6 = 5 := begin norm_num, end theorem mathd_algebra_304 : 91^2 = 8281 := begin norm_num, end theorem amc12a_2021_p8 (d : ℕ → ℕ) (h₀ : d 0 = 0) (h₁ : d 1 = 0) (h₂ : d 2 = 1) (h₃ : ∀ n≥3, d n = d (n - 1) + d (n - 3)) : even (d 2021) ∧ odd (d 2022) ∧ even (d 2023) := begin sorry end theorem algebra_ineq_nto1onlt2m1on (n : ℕ) : (n:ℝ)^((1:ℝ) / n) < 2 - 1 / n := begin sorry end theorem amc12b_2002_p19 (a b c: ℝ) (h₀ : 0 < a ∧ 0 < b ∧ 0 < c) (h₁ : a * (b + c) = 152) (h₂ : b * (c + a) = 162) (h₃ : c * (a + b) = 170) : a * b * c = 720 := begin nlinarith, end theorem mathd_numbertheory_341 (a b c : ℕ) (h₀ : a ≤ 9 ∧ b ≤ 9 ∧ c ≤ 9) (h₁ : (5^100) % 1000 = 10*(10*a + b) + c) : a + b + c = 13 := begin sorry end theorem mathd_numbertheory_711 (m n : ℕ) (h₀ : 0 < m ∧ 0 < n) (h₁ : gcd m n = 8) (h₂ : lcm m n = 112) : 72 ≤ m + n := begin sorry end theorem amc12b_2020_p22 (t : ℝ) : ((2^t - 3 * t) * t) / (4^t) ≤ 1 / 12 := begin sorry end theorem mathd_algebra_113 (x : ℝ) : x^2 - 14 * x + 3 ≥ 7^2 - 14 * 7 + 3 := begin sorry end theorem amc12a_2020_p9 (h₀ : fintype {x : ℝ | 0 ≤ x ∧ x ≤ 2 * real.pi ∧ real.tan (2 * x) = real.cos (x / 2)}) : finset.card { x : ℝ | 0 ≤ x ∧ x ≤ 2 * real.pi ∧ real.tan (2 * x) = real.cos (x / 2)}.to_finset = 5 := begin sorry end theorem amc12_2000_p1 (i m o : ℕ) (h₀ : i ≠ 0 ∧ m ≠ 0 ∧ o ≠ 0) (h₁ : i*m*o = 2001) : i+m+o ≤ 671 := begin sorry end theorem amc12a_2021_p19 (h₀ : fintype {x : ℝ | 0 ≤ x ∧ x ≤ real.pi ∧ real.sin (real.pi / 2 * real.cos x) = real.cos (real.pi / 2 * real.sin x)}) : finset.card {x : ℝ | 0 ≤ x ∧ x ≤ real.pi ∧ real.sin (real.pi / 2 * real.cos x) = real.cos (real.pi / 2 * real.sin x)}.to_finset = 2 := begin sorry end theorem algebra_amgm_sumasqdivbgeqsuma (a b c d : ℝ) (h₀ : 0 < a ∧ 0 < b ∧ 0 < c ∧ 0 < d) : a^2 / b + b^2 / c + c^2 / d + d^2 / a ≥ a + b + c + d := begin sorry end theorem mathd_numbertheory_212 : (16^17 * 17^18 * 18^19) % 10 = 8 := begin sorry end theorem mathd_numbertheory_320 (n : ℕ) (h₀ : n < 101) (h₁ : 101 ∣ (123456 - n)) : n = 34 := begin sorry end theorem mathd_algebra_125 (x y : ℕ+) (h₀ : 5 * x = y) (h₁ : (↑x - (3:ℤ)) + (y - (3:ℤ)) = 30) : x = 6 := begin sorry end theorem induction_1pxpownlt1pnx (x : ℝ) (n : ℕ+) (h₀ : -1 < x) : (1 + ↑n*x) ≤ (1 + x)^(n:ℕ) := begin sorry end theorem mathd_algebra_148 (c : ℝ) (f : ℝ → ℝ) (h₀ : ∀ x, f x = c * x^3 - 9 * x + 3) (h₁ : f 2 = 9) : c = 3 := begin rw h₀ at h₁, linarith, end theorem amc12a_2019_p12 (x y : ℝ) (h₀ : x ≠ 1 ∧ y ≠ 1) (h₁ : real.log x / real.log 2 = real.log 16 / real.log y) (h₂ : x * y = 64) : real.log (x / y) / real.log 2 = 20 := begin sorry end theorem induction_11div10tonmn1ton (n : ℕ) : 11 ∣ (10^n - (-1 : ℤ)^n) := begin sorry end theorem algebra_amgm_sum1toneqn_prod1tonleq1 (a : ℕ → nnreal) (n : ℕ) (h₀ : ∑ x in finset.range n, a x = n) : ∏ x in finset.range n, a x ≤ 1 := begin sorry end theorem imo_1985_p6 (f : ℕ+ → nnreal → ℝ) (h₀ : ∀ x, f 1 x = x) (h₁ : ∀ x n, f (n + 1) x = f n x * (f n x + 1 / n)) : ∃! a, ∀ n, 0 < f n a ∧ f n a < f (n + 1) a ∧ f (n + 1) a < 1 := begin sorry end theorem amc12a_2020_p15 (a b : ℂ) (h₀ : a^3 - 8 = 0) (h₁ : b^3 - 8 * b^2 - 8 * b + 64 = 0) : complex.abs (a - b) ≤ 2 * real.sqrt 21 := begin sorry end theorem mathd_algebra_332 (x y : nnreal) (h₀ : (x + y) / 2 = 7) (h₁ : real.sqrt (x * y) = real.sqrt 19) : x^2 * y^2 = 158 := begin sorry end theorem algebra_cubrtrp1oncubrtreq3_rcubp1onrcubeq5778 (r : ℝ) (h₀ : r^((1:ℝ) / 3) + 1 / r^((1:ℝ) / 3) = 3) : r^3 + 1 / r^3 = 5778 := begin sorry end theorem mathd_algebra_293 (x : nnreal) : real.sqrt (60 * x) * real.sqrt (12 * x) * real.sqrt (63 * x) = 36 * x * real.sqrt (35 * x) := begin sorry end theorem mathd_algebra_440 (x : ℝ) (h₀ : 3 / 2 / 3 = x / 10) : x = 5 := begin field_simp at h₀, linarith, end theorem mathd_numbertheory_254 : (239 + 174 + 83) % 10 = 6 := begin norm_num, end theorem amc12_2000_p6 (p q : ℕ) (h₀ : nat.prime p ∧ nat.prime q) (h₁ : 4 ≤ p ∧ p ≤ 18) (h₂ : 4 ≤ q ∧ q ≤ 18) : ↑p * ↑q - (↑p + ↑q) ≠ (194:ℤ) := begin revert p q h₀ h₁ h₂, intros p q hpq, rintros ⟨hp, hq⟩, rintro ⟨h, h⟩, intro h, have h₁ := nat.prime.ne_zero hpq.1, have h₂ : q ≠ 0, { rintro rfl, simp * at * }, apply h₁, revert hpq, intro h, simp * at *, apply h₁, have h₃ : q = 10 * q, apply eq.symm, all_goals { dec_trivial! }, end theorem aime_1988_p8 (f : ℕ+ → ℕ+ → ℝ) (h₀ : ∀ x, f x x = x) (h₁ : ∀ x y, f x y = f y x) (h₂ : ∀ x y, (↑x + ↑y) * f x y = y * (f x (x + y))) : f 14 52 = 364 := begin sorry end theorem mathd_algebra_114 (a : ℝ) (h₀ : a = 8) : (16 * (a^2)^((1:ℝ) / 3))^((1:ℝ) / 3) = 4 := begin rw h₀, have k₁ : 0 ≤ (4:ℝ), linarith, have k₂ : 0 < 3, linarith, have k₃ : (64:ℝ) = 4^(3:ℝ), { suffices : (64:ℝ) = 4^((3:ℕ):ℝ), { rw this, norm_cast, }, suffices : (64:ℝ) = 4^(3:ℕ), { rw this, rw eq_comm, exact real.rpow_nat_cast (4:ℝ) 3, }, norm_num, }, have k₄ : (16:ℝ) = 4^2, linarith, have k₆ : 0 ≤ (64:ℝ), linarith, have k₇ : ((1:ℝ)/3) = (↑3)⁻¹, { norm_cast, exact one_div 3, }, have k₈ : ((4:ℝ)^(3:ℝ)) = (4:ℝ)^(3:ℕ), { suffices : ((4:ℝ)^((3:ℕ):ℝ)) = ((4:ℝ)^(3:ℕ)), { rw ← this, norm_num, }, exact real.rpow_nat_cast (4:ℝ) 3, }, have k₅ : ((4:ℝ)^(3:ℝ))^((1:ℝ)/3) = (4:ℝ), { rw k₇, rw k₈, refine real.pow_nat_rpow_nat_inv k₁ k₂, }, norm_num, rw k₃, rw k₄, rw k₅, suffices : (4:ℝ)^2 * (4:ℝ) = 4^3, { rw this, rw k₇, refine real.pow_nat_rpow_nat_inv k₁ k₂, }, norm_num, end theorem imo_2019_p1 (f : ℤ → ℤ) : (∀ a b, f (2 * a) + (2 * f b) = f (f (a + b)) ↔ (∀ z, f z = 0 \/ ∃ c, ∀ z, f z = 2 * z + c)) := begin sorry end theorem mathd_algebra_513 (a b : ℝ) (h₀ : 3 * a + 2 * b = 5) (h₁ : a + b = 2) : a = 1 ∧ b = 1 := begin split; linarith, end theorem mathd_algebra_143 (f g : ℝ → ℝ) (h₀ : ∀ x, f x = x + 1) (h₁ : ∀ x, g x = x^2 + 3) : f (g 2) = 8 := begin rw [h₀, h₁], norm_num, end theorem mathd_algebra_354 (a d : ℝ) (h₀ : a + 6 * d = 30) (h₁ : a + 10 * d = 60) : a + 20 * d = 135 := begin linarith, end theorem aime_1984_p7 (f : ℕ+ → ℕ+) (h₀ : ∀ n, 1000 ≤ n → f n = n - 3) (h₁ : ∀ n, n < 1000 → f n = f (f (n + 5))) : f 84 = 997 := begin sorry end theorem mathd_algebra_246 (a b : ℝ) (f : ℝ → ℝ) (h₀ : ∀ x, f x = a * x^4 - b * x^2 + x + 5) (h₂ : f (-3) = 2) : f 3 = 8 := begin rw h₀ at h₂, simp at h₂, rw h₀, linarith, end theorem aime_1983_p3 (f : ℝ → ℝ) (h₀ : ∀ x, f x = (x^2 + (18 * x + 30) - 2 * real.sqrt (x^2 + (18 * x + 45)))) (h₁ : fintype (f⁻¹' {0})) : ∏ x in (f⁻¹' {0}).to_finset, x = 20 := begin sorry end theorem numbertheory_3pow2pownm1mod2pownp3eq2pownp2 (n : ℕ) (h₀ : 0 < n) : (3^(2^n) - 1) % (2^(n + 3)) = 2^(n + 2) := begin sorry end theorem mathd_numbertheory_85 : 1 * 3^3 + 2 * 3^2 + 2*3 + 2 = 53 := begin norm_num, end theorem amc12_2001_p21 (a b c d : ℕ) (h₀ : a*b*c*d = nat.factorial 8) (h₁ : a*b + a + b = 524) (h₂ : b*c + b + c = 146) (h₃ : c*d + c + d = 104) : ↑a - ↑d = (10:ℤ) := begin sorry end theorem mathd_numbertheory_239 : (∑ k in finset.erase (finset.range 13) 0, k) % 4 = 2 := begin sorry end theorem amc12b_2002_p2 (x : ℤ) (h₀ : x = 4) : (3 * x - 2) * (4 * x + 1) - (3 * x - 2) * (4 * x) + 1 = 11 := begin rw h₀, linarith, end theorem mathd_algebra_196 (h₀ : fintype {x : ℝ | abs (2 - x) = 3}) : ∑ k in {x : ℝ | abs (2 - x) = 3}.to_finset, k = 4 := begin sorry end theorem mathd_algebra_342 (a d: ℝ) (h₀ : ∑ k in (finset.range 5), (a + k * d) = 70) (h₁ : ∑ k in (finset.range 10), (a + k * d) = 210) : a = 42/5 := begin revert h₀ h₁, simp [finset.sum_range_succ, mul_comm d], intros, linarith, end theorem mathd_numbertheory_517 : (121 * 122 * 123) % 4 = 2 := begin sorry end theorem amc12a_2009_p7 (x : ℝ) (n : ℕ+) (a : ℕ+ → ℝ) (h₁ : ∀ n, a (n + 1) - a n = a (n + 2) - a (n + 1)) (h₂ : a 1 = 2 * x - 3) (h₃ : a 2 = 5 * x - 11) (h₄ : a 3 = 3 * x + 1) (h₅ : a n = 2009) : n = 502 := begin sorry end theorem mathd_algebra_270 (f : ℝ → ℝ) (h₀ : ∀ x ≠ -2, f x = 1 / (x + 2)) : f (f 1) = 3/7 := begin rw [h₀, h₀], norm_num, linarith, rw h₀, norm_num, linarith, end theorem amc12a_2021_p12 (a b c d : ℝ) (f : ℂ → ℂ) (h₀ : ∀ z, f z = z^6 - 10 * z^5 + a * z^4 + b * z^3 + c * z^2 + d * z + 16) (h₁ : ∀ z, f z = 0 → (z.im = 0 ∧ 0 < z.re ∧ ↑(int.floor z.re) = z.re)) : b = 88 := begin sorry end theorem mathd_algebra_362 (a b : ℝ) (h₀ : a^2 * b^3 = 32 / 27) (h₁ : a / b^3 = 27 / 4) : a + b = 8 / 3 := begin sorry end theorem mathd_numbertheory_521 (m n : ℕ) (h₀ : even m) (h₁ : even n) (h₂ : m - n = 2) (h₃ : m * n = 288) : m = 18 := begin sorry end theorem amc12a_2002_p13 (a b : ℝ) (h₀ : 0 < a ∧ 0 < b) (h₁ : a ≠ b) (h₂ : abs (a - 1/a) = 1) (h₃ : abs (b - 1/b) = 1) : a + b = real.sqrt 5 := begin sorry end theorem imo_1964_p2 (a b c : ℝ) (h₀ : 0 < a ∧ 0 < b ∧ 0 < c) (h₁ : c < a + b) (h₂ : b < a + c) (h₃ : a < b + c) : a^2 * (b + c - a) + b^2 * (c + a - b) + c^2 * (a + b - c) ≤ 3 * a * b * c := begin sorry end theorem mathd_algebra_289 (k t m n : ℕ) (h₀ : nat.prime m ∧ nat.prime n) (h₁ : t < k) (h₂ : (k^2 : ℤ) - m * k + n = 0) (h₃ : (t^2 : ℤ) - m * t + n = 0) : m^n + n^m + k^t + t^k = 20 := begin sorry end theorem amc12a_2021_p3 (x y : ℕ) (h₀ : x + y = 17402) (h₁ : 10∣x) (h₂ : x / 10 = y) : ↑x - ↑y = (14238:ℤ) := begin sorry end theorem amc12a_2008_p25 (a b : ℕ+ → ℝ) (h₀ : ∀ n, a (n + 1) = real.sqrt 3 * a n - b n) (h₁ : ∀ n, b (n + 1) = real.sqrt 3 * b n + a n) (h₂ : a 100 = 2) (h₃ : b 100 = 4) : a 1 + b 1 = 1 / (2^98) := begin sorry end theorem algebra_apbpceq2_abpbcpcaeq1_aleq1on3anbleq1ancleq4on3 (a b c : ℝ) (h₀ : a ≤ b ∧ b ≤ c) (h₁ : a + b + c = 2) (h₂ : a * b + b * c + c * a = 1) : 0 ≤ a ∧ a ≤ 1 / 3 ∧ 1 / 3 ≤ b ∧ b ≤ 1 ∧ 1 ≤ c ∧ c ≤ 4 / 3 := begin sorry end theorem mathd_numbertheory_66 : 194 % 11 = 7 := begin exact rfl, end theorem amc12b_2021_p1 (h₀ : fintype {x : ℤ | ↑(abs x) < 3 * real.pi}): finset.card {x : ℤ | ↑(abs x) < 3 * real.pi}.to_finset = 19 := begin sorry end theorem algebra_apbon2pownleqapownpbpowon2 (a b : ℝ) (n : ℕ) (h₀ : 0 < a ∧ 0 < b) (h₁ : 0 < n) : ((a + b) / 2)^n ≤ (a^n + b^n) / 2 := begin sorry end theorem imo_1968_p5_1 (a : ℝ) (f : ℝ → ℝ) (h₀ : 0 < a) (h₁ : ∀ x, f (x + a) = 1 / 2 + real.sqrt (f x - (f x)^2)) : ∃ b > 0, ∀ x, f (x + b) = f x := begin sorry end theorem aime_1990_p15 (a b x y : ℝ) (h₀ : a * x + b * y = 3) (h₁ : a * x^2 + b * y^2 = 7) (h₂ : a * x^3 + b * y^3 = 16) (h₃ : a * x^4 + b * y^4 = 42) : a * x^5 + b * y^5 = 20 := begin sorry end theorem mathd_numbertheory_235 : (29 * 79 + 31 * 81) % 10 = 2 := begin norm_num, end theorem amc12b_2020_p13 : real.sqrt (real.log 6 / real.log 2 + real.log 6 / real.log 3) = real.sqrt (real.log 3 / real.log 2) + real.sqrt (real.log 2 / real.log 3) := begin sorry end theorem amc12b_2021_p13 (h₀ : fintype {x : ℝ | 0 < x ∧ x ≤ 2 * real.pi ∧ 1 - 3 * real.sin x + 5 * real.cos (3 * x) = 0}) : finset.card {x : ℝ | 0 < x ∧ x ≤ 2 * real.pi ∧ 1 - 3 * real.sin x + 5 * real.cos (3 * x) = 0}.to_finset = 6 := begin sorry end theorem mathd_numbertheory_234 (a b : ℕ) (h₀ : 1 ≤ a ∧ a ≤ 9 ∧ b ≤ 9) (h₁ : (10 * a + b)^3 = 912673) : a + b = 16 := begin sorry end theorem numbertheory_aoddbdiv4asqpbsqmod8eq1 (a : ℤ) (b : ℕ) (h₀ : odd a) (h₁ : 4 ∣ b) : (a^2 + b^2) % 8 = 1 := begin sorry end theorem mathd_numbertheory_222 (b : ℕ) (h₀ : nat.lcm 120 b = 3720) (h₁ : nat.gcd 120 b = 8) : b = 248 := begin sorry end theorem aime_1999_p11 (m : ℚ) (h₀ : ∑ k in finset.erase (finset.range 36) 0, real.sin (5 * k * π / 180) = real.tan (m * π / 180)) (h₁ : (m.denom:ℝ) / m.num < 90) : ↑m.denom + m.num = 177 := begin sorry end theorem mathd_algebra_359 (y : ℝ) (h₀ : y + 6 + y = 2 * 12) : y = 9 := begin linarith, end theorem imo_1965_p2 (x y z : ℝ) (a : ℕ → ℝ) (h₀ : 0 < a 0 ∧ 0 < a 4 ∧ 0 < a 8) (h₁ : a 1 < 0 ∧ a 2 < 0) (h₂ : a 3 < 0 ∧ a 5 < 0) (h₃ : a 7 < 0 ∧ a 9 < 0) (h₄ : 0 < a 0 + a 1 + a 2) (h₅ : 0 < a 3 + a 4 + a 5) (h₆ : 0 < a 6 + a 7 + a 8) (h₇ : a 0 * x + a 1 * y + a 2 * z = 0) (h₈ : a 3 * x + a 4 * y + a 5 * z = 0) (h₉ : a 6 * x + a 7 * y + a 8 * z = 0) : x = 0 ∧ y = 0 ∧ z = 0 := begin sorry end theorem mathd_algebra_288 (x y : ℝ) (n : nnreal) (h₀ : x < 0 ∧ y < 0) (h₁ : abs x = 6) (h₂ : real.sqrt ((x - 8)^2 + (y - 3)^2) = 15) (h₃ : real.sqrt (x^2 + y^2) = real.sqrt n) : n = 52 := begin sorry end theorem mathd_numbertheory_127 : (∑ k in (finset.range 101), 2^k) % 7 = 3 := begin sorry end theorem imo_1974_p3 (n : ℕ) : ¬ 5∣∑ k in finset.range n, (nat.choose (2 * n + 1) (2 * k + 1)) * (2^(3 * k)) := begin sorry end theorem aime_1991_p9 (x : ℝ) (m : ℚ) (h₀ : 1 / real.cos x + real.tan x = 22 / 7) (h₁ : 1 / real.sin x + 1 / real.tan x = m) : ↑m.denom + m.num = 44 := begin sorry end theorem amc12a_2009_p6 (m n p q : ℝ) (h₀ : p = 2 ^ m) (h₁ : q = 3 ^ n) : p^(2 * n) * (q^m) = 12^(m * n) := begin sorry end theorem mathd_algebra_158 (a : ℕ) (h₀ : even a) (h₁ : ↑∑ k in finset.range 8, (2 * k + 1) - ↑∑ k in finset.range 5, (a + 2 * k) = (4:ℤ)) : a = 8 := begin sorry end theorem algebra_absxm1pabsxpabsxp1eqxp2_0leqxleq1 (x : ℝ) (h₀ : abs (x - 1) + abs x + abs (x + 1) = x + 2) : 0 ≤ x ∧ x ≤ 1 := begin sorry end theorem aime_1990_p4 (x : ℝ) (h₀ : 0 < x) (h₁ : x^2 - 10 * x - 29 ≠ 0) (h₂ : x^2 - 10 * x - 45 ≠ 0) (h₃ : x^2 - 10 * x - 69 ≠ 0) (h₄ : 1 / (x^2 - 10 * x - 29) + 1 / (x^2 - 10 * x - 45) - 2 / (x^2 - 10 * x - 69) = 0) : x = 13 := begin sorry end theorem mathd_numbertheory_541 (m n : ℕ) (h₀ : 1 < m) (h₁ : 1 < n) (h₂ : m * n = 2005) : m + n = 406 := begin sorry end theorem mathd_algebra_314 (n : ℕ) (h₀ : n = 11) : (1 / 4)^(n + 1) * 2^(2 * n) = 1 / 4 := begin rw h₀, norm_num, end theorem amc12_2000_p20 (x y z : ℝ) (h₀ : 0 < x ∧ 0 < y ∧ 0 < z) (h₁ : x + 1/y = 4) (h₂ : y + 1/z = 1) (h₃ : z + 1/x = 7/3) : x*y*z = 1 := begin sorry end theorem mathd_algebra_302 : (complex.I / 2)^2 = -(1 / 4) := begin norm_num, end theorem aime_1983_p2 (x p : ℝ) (f : ℝ → ℝ) (h₀ : 0 < p ∧ p < 15) (h₁ : p ≤ x ∧ x ≤ 15) (h₂ : f x = abs (x - p) + abs (x - 15) + abs (x - p - 15)) : 15 ≤ f x := begin sorry end theorem mathd_algebra_139 (s : ℝ → ℝ → ℝ) (h₀ : ∀ x≠0, ∀y≠0, s x y = (1/y - 1/x) / (x-y)) : s 3 11 = 1/33 := begin norm_num [h₀], end theorem amc12a_2021_p25 (n : ℕ+) (f : ℕ+ → ℝ) (h₀ : ∀ n, f n = (∑ k in (nat.divisors n), 1)/(n^((1:ℝ)/3))) (h₁ : ∀ p ≠ n, f p < f n) : n = 2520 := begin sorry end theorem amc12a_2020_p25 (a : ℚ) (h₀ : fintype {x : ℝ | ↑⌊x⌋ * (x - ↑⌊x⌋) = ↑a * x ^ 2}) (h₁ : ∑ k in {x : ℝ | ↑⌊x⌋ * (x - ↑⌊x⌋) = ↑a * x^2}.to_finset, k = 420) : ↑a.denom + a.num = 929 := begin sorry end theorem mathd_numbertheory_150 (n : ℕ) (h₀ : ¬ nat.prime (7 + 30 * n)) : 6 ≤ n := begin sorry end theorem aime_1989_p8 (a b c d e f g : ℝ) (h₀ : a + 4 * b + 9 * c + 16 * d + 25 * e + 36 * f + 49 * g = 1) (h₁ : 4 * a + 9 * b + 16 * c + 25 * d + 36 * e + 49 * f + 64 * g = 12) (h₂ : 9 * a + 16 * b + 25 * c + 36 * d + 49 * e + 64 * f + 81 * g = 123) : 16 * a + 25 * b + 36 * c + 49 * d + 64 * e + 81 * f + 100 * g = 334 := begin sorry end theorem mathd_numbertheory_296 (n : ℕ) (h₀ : 2 ≤ n) (h₁ : ∃ x, x^3 = n) (h₂ : ∃ t, t^4 = n) : 4096 ≤ n := begin sorry end theorem mathd_algebra_142 (m b : ℝ) (h₀ : m * 7 + b = -1) (h₁ : m * (-1) + b = 7) : m + b = 5 := begin linarith, end theorem numbertheory_exk2powkeqapb2mulbpa2_aeq1 (a b : ℕ+) (h₀ : ∃ k > 0, 2^k = (a + b^2) * (b + a^2)) : a = 1 := begin sorry end theorem mathd_algebra_400 (x : ℝ) (h₀ : 5 + 500 / 100 * 10 = 110 / 100 * x) : x = 50 := begin linarith, end theorem aime_1995_p7 (k m n : ℕ+) (t : ℝ) (h0 : nat.gcd m n = 1) (h1 : (1 + real.sin t) * (1 + real.cos t) = 5/4) (h2 : (1 - real.sin t) * (1- real.cos t) = m/n - real.sqrt k): k + m + n = 27 := begin sorry end theorem mathd_numbertheory_185 (n : ℕ) (h₀ : n % 5 = 3) : (2 * n) % 5 = 1 := begin sorry end theorem mathd_algebra_441 (x : ℝ) (h₀ : x ≠ 0) : 12 / (x * x) * (x^4 / (14 * x)) * (35 / (3 * x)) = 10 := begin field_simp, ring_nf, end theorem mathd_numbertheory_582 (n : ℕ) (h₀ : 0 < n) (h₁ : 3∣n) : ((n + 4) + (n + 6) + (n + 8)) % 9 = 0 := begin sorry end theorem mathd_algebra_338 (a b c : ℝ) (h₀ : 3 * a + b + c = -3) (h₁ : a + 3 * b + c = 9) (h₂ : a + b + 3 * c = 19) : a * b * c = -56 := begin have ha : a = -4, linarith, have hb : b = 2, linarith, have hc : c = 7, linarith, rw [ha, hb, hc], norm_num, end
State Before: α : Type ?u.1062538 n : ℤ ⊢ ↑↑0 = 0 State After: no goals Tactic: simp State Before: α : Type ?u.1062538 n : ℤ ⊢ ∀ (k : ℤ), 0 ≤ k → ↑↑k = k → ↑↑(k + 1) = k + 1 State After: no goals Tactic: simp State Before: α : Type ?u.1062538 n : ℤ ⊢ ∀ (k : ℤ), k ≤ 0 → ↑↑k = k → ↑↑(k - 1) = k - 1 State After: no goals Tactic: simp
def f (x y z : Nat) : Nat := match x, y, z with | 5, _, _ => y | _, 5, _ => y | _, _, 5 => y | _, _, _ => 1 example (x y z : Nat) : x ≠ 5 → y ≠ 5 → z ≠ 5 → f x y z = 1 := by intros simp (config := { iota := false }) [f] split · contradiction · contradiction · contradiction · rfl example (x y z : Nat) : f x y z = y ∨ f x y z = 1 := by intros simp [f] split · exact Or.inl rfl · exact Or.inl rfl · exact Or.inl rfl · exact Or.inr rfl example (x y z : Nat) : f x y z = y ∨ f x y z = 1 := by intros simp [f] split <;> (first | apply Or.inl rfl | apply Or.inr rfl) def g (xs ys : List Nat) : Nat := match xs, ys with | [a, b], _ => Nat.succ (a+b) | _, [b, c] => Nat.succ b | _, _ => 1 example (xs ys : List Nat) : g xs ys > 0 := by simp [g] split next a b => show Nat.succ (a + b) > 0; apply Nat.zero_lt_succ next xs b c _ => show Nat.succ b > 0; apply Nat.zero_lt_succ next => decide
\chapter{Introduction} \label{chap:intro} \citet{Munk1950} says interesting things about the ocean. \newpage \section{An amazing revelation} It's so interesting, that we need to display a separate page. \subsection{More details} Some things deserve their own subsection - this is one of those things. More details can be found in Appendix \ref{app:example}. \subsubsection{Nesting sections is fun} Will this one get listed in the table of contents? It's up to you! Equations, like this one, \begin{equation} a^{2} + b^{2} = c^{2} \end{equation} are numbered only to the chapter level by default.
// -------------------------------------------------------------------------- // OpenMS -- Open-Source Mass Spectrometry // -------------------------------------------------------------------------- // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen, // ETH Zurich, and Freie Universitaet Berlin 2002-2013. // // This software is released under a three-clause BSD license: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of any author or any participating institution // may be used to endorse or promote products derived from this software // without specific prior written permission. // For a full list of authors, refer to the file AUTHORS. // -------------------------------------------------------------------------- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // -------------------------------------------------------------------------- // $Maintainer: Erhan Kenar $ // $Authors: Vipul Patel $ // -------------------------------------------------------------------------- #ifndef OPENMS_COMPARISON_SPECTRA_COMPAREFOURIERTRANSFORM_H #define OPENMS_COMPARISON_SPECTRA_COMPAREFOURIERTRANSFORM_H #include <OpenMS/COMPARISON/SPECTRA/PeakSpectrumCompareFunctor.h> #include <OpenMS/KERNEL/StandardTypes.h> #include <gsl/gsl_errno.h> #include <gsl/gsl_fft_real.h> namespace OpenMS { /** @brief Compare Discrete Cosines value from a Fourier transformation, also known as Discrete Cosines Transformation The Direct Cosines Transformation based on the theory of the Fourier transformation. In this class the Fast Fourier Transformation(FFT) algorithm of the gsl library is used. FFT has a run-time complexity of n (log n). To get the Direct Cosines Transformation from a FFT there is preparation necessary. First the input data has to be mirrored. This is necessary, because FFT needs data which has a periodic nature. After the computation of FFT only the cosine values are important and stored in the Meta Data Array. So an inverse transformation of these values to get the original spectrum is not available. The comparison is done between two Meta Data Arrays, which contain the stored cosine values of their individual spectrum. The advantage of this method is how the comparison works. There is only one sum which has to be count, no multiplication is needed. Attention: only use the compare function, if the Spectrum was transformed earlier, else an error is going to appear. Only use this method of transformation, if you are sure there exists enough free memory. This is a fast estimation, but it only gives one or zero back. @htmlinclude OpenMS_CompareFouriertransform.parameters @ingroup SpectraComparison */ class OPENMS_DLLAPI CompareFouriertransform : public PeakSpectrumCompareFunctor { public: // @name Constructors and Destructors // @{ /// default constructor CompareFouriertransform(); /// copy constructor CompareFouriertransform(const CompareFouriertransform & source); /// destructor virtual ~CompareFouriertransform(); // @} // @name Operators // @{ /// assignment operator CompareFouriertransform & operator=(const CompareFouriertransform & source); /** @brief Dummy function This function only returns 0 for any given PeakSpectrum, please use the other compare operator function */ double operator()(const PeakSpectrum &) const; /** @brief compare two PeakSpectrum by their Discrete Cosines Transformation. This function compares two given PeakSpectrum about their Discrete Cosines Transformation. First, a transformation has to be calculated. Please use the function transform() in this class, before calling this function. The comparison works by summing the subtractions of each coefficient for all elements of both transformations. sum(_i=1) ^n x_i-y_i. If the sum is zero, both Spectra are identical in the real part and one is emitted, otherwise a zero. */ double operator()(const PeakSpectrum & spec1, const PeakSpectrum & spec2) const; /// static PeakSpectrumCompareFunctor * create() { return new CompareFouriertransform(); } ///Returns the name used in the factory static const String getProductName() { return "CompareFouriertransform"; } /** @brief calculate the Discrete Cosines Fourier Transformation. This function transforms a given PeakSpectrum to a Discrete Cosines Fourier Transformation. It stores only the part of the cosines of the FFT in the FloatDataArray which is a container from the PeakSpectrum. Only call this function, if you are sure there is no other transformation done earlier over the same PeakSpectrum, because it isn't checked if there already exists a transformation. */ void transform(PeakSpectrum & spec); protected: /** @brief Search in the PeakSpectrum, if a Discrete Fourier transformation occurs, if not an error is going to be thrown, else the index of the occurrence is returned. This function gives back the position, where the transformation was saved in a FloatDataArray. If there is no entry, an error is thrown to indicate that a transformation has to be calculated before calling this comparison operator. */ UInt searchTransformation_(const PeakSpectrum & spec) const; }; } #endif /*OPENMS_COMPARISON_SPECTRA_COMPAREFOURIERTRANSFORM_H*/
import analysis.real import algebra.archimedean import tactic.norm_num variables {β : Type} [floor_ring β] namespace decimal section parameters {α : Type} [floor_ring α] -- ⌊(real.sqrt 2 : ℝ)⌋ definition chomp (r : α) : ℕ → α | 0 := (r - floor r) * 10 | (n + 1) := (chomp n - floor (chomp n)) * 10 -- tell Mario I'll put the promise in the name definition expansion_nonneg (r : α) : ℕ → ℕ | 0 := int.to_nat (floor r) | (n + 1) := int.to_nat (floor (chomp r n)) -- mario said --local instance decidable_prop lemma chomp_is_zero (n : ℕ) (r : α) : chomp r n = 0 → ∀ m, chomp r (n + m) = 0 := begin intros H m,induction m with d Hd,assumption, show chomp r (nat.succ (n + d)) = 0, unfold chomp,rw Hd,simp, end --set_option pp.notation false lemma int.succ_le_of_lt (a b : ℤ) : a < b → int.succ a ≤ b := id --begin --intro H, --exact H, --end @[simp] theorem rat.cast_floor {α} [linear_ordered_field α] [archimedean α] (x : ℚ) : by haveI := archimedean.floor_ring α; exact ⌊(x:α)⌋ = ⌊x⌋ := begin haveI := archimedean.floor_ring α, apply le_antisymm, { rw [le_floor, ← @rat.cast_le α, rat.cast_coe_int], apply floor_le }, { rw [le_floor, ← rat.cast_coe_int, rat.cast_le], apply floor_le } end lemma floor_of_bounds (r : α) (z : ℤ) : ↑z ≤ r ∧ r < (z + 1) ↔ ⌊ r ⌋ = z := by rw [← le_floor, ← int.cast_one, ← int.cast_add, ← floor_lt, int.lt_add_one_iff, le_antisymm_iff, and.comm] end noncomputable definition s : ℝ := (71/100 : ℝ) theorem sQ : s = ((71/100:ℚ):ℝ) := by unfold s;norm_num --set_option pp.all true theorem floor_s : floor s = 0 := by rw [← floor_of_bounds, s, int.cast_zero]; norm_num theorem floor_10s : floor (71/10 : ℝ) = 7 := begin rw [← floor_of_bounds], split, norm_num, end lemma chomping_s : chomp s 2 = 0 := begin unfold chomp, rw floor_s, unfold s, norm_num, rw floor_10s, norm_num, end theorem chomped (n : ℕ) : chomp s (n + 2) = 0 := begin induction n with d Hd,exact chomping_s, rw chomp.equations._eqn_2, rw Hd, simp, end -- recall s = 71/100 theorem no_eights_in_0_point_71 (n : ℕ) : decimal.expansion_nonneg s n ≠ 8 := begin cases n,unfold expansion_nonneg,rw floor_s,show 0 ≠ 8,by cc, cases n,unfold expansion_nonneg chomp,rw floor_s,unfold s, rw int.cast_zero, have this : ((71 / 100 : ℝ) - 0) * 10 = 71 / 10 := by norm_num, rw this,rw floor_10s,show 7 ≠ 8,by cc, cases n,unfold expansion_nonneg chomp,rw floor_s,unfold s, rw int.cast_zero, norm_num, rw floor_10s, norm_num, show 1 ≠ 8, by cc, unfold expansion_nonneg, rw [chomped,floor_zero], show 0 ≠ 8, by cc, end end decimal
const ntrials = 5 print_output = isempty(ARGS) codespeed = length(ARGS) > 0 && ARGS[1] == "codespeed" if codespeed using JSON using HTTPClient.HTTPC # Ensure that we've got the environment variables we want: if !haskey(ENV, "JULIA_FLAVOR") error( "You must provide the JULIA_FLAVOR environment variable identifying this julia build!" ) end # Setup codespeed data dict for submissions to codespeed's JSON endpoint. These parameters # are constant across all benchmarks, so we'll just let them sit here for now csdata = Dict() csdata["commitid"] = Base.GIT_VERSION_INFO.commit csdata["project"] = "Julia" csdata["branch"] = Base.GIT_VERSION_INFO.branch csdata["executable"] = ENV["JULIA_FLAVOR"] csdata["environment"] = chomp(readall(`hostname`)) csdata["result_date"] = join( split(Base.GIT_VERSION_INFO.date_string)[1:2], " " ) #Cut the timezone out end # Takes in the raw array of values in vals, along with the benchmark name, description, unit and whether less is better function submit_to_codespeed(vals,name,desc,unit,test_group,lessisbetter=true) # Points to the server codespeed_host = "julia-codespeed.csail.mit.edu" csdata["benchmark"] = name csdata["description"] = desc csdata["result_value"] = mean(vals) csdata["std_dev"] = std(vals) csdata["min"] = minimum(vals) csdata["max"] = maximum(vals) csdata["units"] = unit csdata["units_title"] = test_group csdata["lessisbetter"] = lessisbetter println( "$name: $(mean(vals))" ) ret = post( "http://$codespeed_host/result/add/json/", {"json" => json([csdata])} ) if ret.http_code != 200 && ret.http_code != 202 error("Error submitting $name [HTTP code $(ret.http_code)], dumping headers and text: $(ret.headers)\n$(bytestring(ret.body))\n\n") return false end return true end macro output_timings(t,name,desc,group) quote # If we weren't given anything for the test group, infer off of file path! test_group = length($group) == 0 ? basename(dirname(Base.source_path())) : $group[1] if codespeed submit_to_codespeed( $t, $name, $desc, "seconds", test_group ) elseif print_output @printf "julia,%s,%f,%f,%f,%f\n" $name minimum($t) maximum($t) mean($t) std($t) end gc() end end macro timeit(ex,name,desc,group...) quote t = zeros(ntrials) for i=0:ntrials e = 1000*(@elapsed $(esc(ex))) if i > 0 # warm up on first iteration t[i] = e end end @output_timings t $name $desc $group end end macro timeit1(ex,name,desc,group...) quote t = 0.0 for i=0:1 t = 1000*(@elapsed $(esc(ex))) end @output_timings [t] $name $desc $group end end macro timeit_init(ex,init,name,desc,group...) quote t = zeros(ntrials) for i=0:ntrials $(esc(init)) e = 1000*(@elapsed $(esc(ex))) if i > 0 # warm up on first iteration t[i] = e end end @output_timings t $name $desc $group end end # seed rng for more consistent timings srand(1776)
lemma csqrt_minus [simp]: assumes "Im x < 0 \<or> (Im x = 0 \<and> 0 \<le> Re x)" shows "csqrt (- x) = \<i> * csqrt x"
lemma complex_Im_numeral [simp]: "Im (numeral v) = 0"
/- Copyright (c) 2022 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser ! This file was ported from Lean 3 source module algebra.char_zero.quotient ! leanprover-community/mathlib commit d90e4e186f1d18e375dcd4e5b5f6364b01cb3e46 ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathlib.GroupTheory.QuotientGroup /-! # Lemmas about quotients in characteristic zero -/ variable {R : Type _} [DivisionRing R] [CharZero R] {p : R} namespace AddSubgroup /-- `z • r` is a multiple of `p` iff `r` is `pk/z` above a multiple of `p`, where `0 ≤ k < |z|`. -/ theorem zsmul_mem_zmultiples_iff_exists_sub_div {r : R} {z : ℤ} (hz : z ≠ 0) : z • r ∈ AddSubgroup.zmultiples p ↔ ∃ k : Fin z.natAbs, r - (k : ℕ) • (p / z : R) ∈ AddSubgroup.zmultiples p := by rw [AddSubgroup.mem_zmultiples_iff] simp_rw [AddSubgroup.mem_zmultiples_iff, div_eq_mul_inv, ← smul_mul_assoc, eq_sub_iff_add_eq] have hz' : (z : R) ≠ 0 := Int.cast_ne_zero.mpr hz conv_rhs => simp (config := { singlePass := true }) only [← (mul_right_injective₀ hz').eq_iff] simp_rw [← zsmul_eq_mul, smul_add, ← mul_smul_comm, zsmul_eq_mul (z : R)⁻¹, mul_inv_cancel hz', mul_one, ← coe_nat_zsmul, smul_smul, ← add_smul] constructor · rintro ⟨k, h⟩ simp_rw [← h] refine' ⟨⟨(k % z).toNat, _⟩, k / z, _⟩ · rw [← Int.ofNat_lt, Int.toNat_of_nonneg (Int.emod_nonneg _ hz)] exact (Int.emod_lt _ hz).trans_eq (Int.abs_eq_natAbs _) rw [Fin.val_mk, Int.toNat_of_nonneg (Int.emod_nonneg _ hz)] nth_rewrite 3 [← Int.div_add_mod k z] rw [Int.mod_def, ← Int.div_def', Int.emod_def] simp only [add_sub_cancel'_right, zsmul_eq_mul, Int.div_def'] · rintro ⟨k, n, h⟩ exact ⟨_, h⟩ #align add_subgroup.zsmul_mem_zmultiples_iff_exists_sub_div AddSubgroup.zsmul_mem_zmultiples_iff_exists_sub_div theorem nsmul_mem_zmultiples_iff_exists_sub_div {r : R} {n : ℕ} (hn : n ≠ 0) : n • r ∈ AddSubgroup.zmultiples p ↔ ∃ k : Fin n, r - (k : ℕ) • (p / n : R) ∈ AddSubgroup.zmultiples p := by rw [← coe_nat_zsmul r, zsmul_mem_zmultiples_iff_exists_sub_div (Int.coe_nat_ne_zero.mpr hn), Int.cast_ofNat] rfl #align add_subgroup.nsmul_mem_zmultiples_iff_exists_sub_div AddSubgroup.nsmul_mem_zmultiples_iff_exists_sub_div end AddSubgroup namespace quotientAddGroup theorem zmultiples_zsmul_eq_zsmul_iff {ψ θ : R ⧸ AddSubgroup.zmultiples p} {z : ℤ} (hz : z ≠ 0) : z • ψ = z • θ ↔ ∃ k : Fin z.natAbs, ψ = θ + (k : ℕ) • (p / z : R) := by induction ψ using Quotient.inductionOn' induction θ using Quotient.inductionOn' -- Porting note: Introduced Zp notation to shorten lines let Zp := AddSubgroup.zmultiples p have : (Quotient.mk'' : R → R ⧸ Zp) = ((↑) : R → R ⧸ Zp) := rfl simp only [this] simp_rw [← QuotientAddGroup.mk_zsmul, ← QuotientAddGroup.mk_nsmul, ← QuotientAddGroup.mk_add, QuotientAddGroup.eq_iff_sub_mem, ← smul_sub, ← sub_sub] exact AddSubgroup.zsmul_mem_zmultiples_iff_exists_sub_div hz #align quotient_add_group.zmultiples_zsmul_eq_zsmul_iff quotientAddGroup.zmultiples_zsmul_eq_zsmul_iff theorem zmultiples_nsmul_eq_nsmul_iff {ψ θ : R ⧸ AddSubgroup.zmultiples p} {n : ℕ} (hz : n ≠ 0) : n • ψ = n • θ ↔ ∃ k : Fin n, ψ = θ + (k : ℕ) • (p / n : R) := by rw [← coe_nat_zsmul ψ, ← coe_nat_zsmul θ, zmultiples_zsmul_eq_zsmul_iff (Int.coe_nat_ne_zero.mpr hz), Int.cast_ofNat] rfl #align quotient_add_group.zmultiples_nsmul_eq_nsmul_iff quotientAddGroup.zmultiples_nsmul_eq_nsmul_iff end quotientAddGroup
(* Make [omega] work for [N] *) Require Import Coq.Arith.Arith Coq.omega.Omega Coq.NArith.NArith. Global Set Asymmetric Patterns. Local Open Scope N_scope. Hint Rewrite Nplus_0_r nat_of_Nsucc nat_of_Nplus nat_of_Nminus N_of_nat_of_N nat_of_N_of_nat nat_of_P_o_P_of_succ_nat_eq_succ nat_of_P_succ_morphism : N. Theorem nat_of_N_eq : forall n m, nat_of_N n = nat_of_N m -> n = m. intros ? ? H; apply (f_equal N_of_nat) in H; autorewrite with N in *; assumption. Qed. Theorem Nneq_in : forall n m, nat_of_N n <> nat_of_N m -> n <> m. congruence. Qed. Theorem Nneq_out : forall n m, n <> m -> nat_of_N n <> nat_of_N m. intuition. apply nat_of_N_eq in H0; tauto. Qed. Theorem Nlt_out : forall n m, n < m -> (nat_of_N n < nat_of_N m)%nat. unfold Nlt; intros. rewrite nat_of_Ncompare in H. apply nat_compare_Lt_lt; assumption. Qed. Theorem Nlt_in : forall n m, (nat_of_N n < nat_of_N m)%nat -> n < m. unfold Nlt; intros. rewrite nat_of_Ncompare. apply (proj1 (nat_compare_lt _ _)); assumption. Qed. Theorem Nge_out : forall n m, n >= m -> (nat_of_N n >= nat_of_N m)%nat. unfold Nge; intros. rewrite nat_of_Ncompare in H. apply nat_compare_ge; assumption. Qed. Theorem Nge_in : forall n m, (nat_of_N n >= nat_of_N m)%nat -> n >= m. unfold Nge; intros. rewrite nat_of_Ncompare. apply nat_compare_ge; assumption. Qed. Ltac nsimp H := simpl in H; repeat progress (autorewrite with N in H; simpl in H). Ltac pre_nomega := try (apply nat_of_N_eq || apply Nneq_in || apply Nlt_in || apply Nge_in); simpl; repeat (progress autorewrite with N; simpl); repeat match goal with | [ H : _ <> _ |- _ ] => apply Nneq_out in H; nsimp H | [ H : _ = _ -> False |- _ ] => apply Nneq_out in H; nsimp H | [ H : _ |- _ ] => (apply (f_equal nat_of_N) in H || apply Nlt_out in H || apply Nge_out in H); nsimp H end. Ltac nomega := pre_nomega; omega || (unfold nat_of_P in *; simpl in *; omega).
Formal statement is: lemma interior_halfspace_le [simp]: assumes "a \<noteq> 0" shows "interior {x. a \<bullet> x \<le> b} = {x. a \<bullet> x < b}" Informal statement is: If $a \neq 0$, then the interior of the halfspace $\{x \mid a \cdot x \leq b\}$ is the halfspace $\{x \mid a \cdot x < b\}$.
(* Author: René Thiemann Akihisa Yamada License: BSD *) subsection \<open>Order of Polynomial Roots\<close> text \<open>We extend the collection of results on the order of roots of polynomials. Moreover, we provide code-equations to compute the order for a given root and polynomial.\<close> theory Order_Polynomial imports Polynomial_Interpolation.Missing_Polynomial begin lemma order_linear[simp]: "order a [:- a, 1:] = Suc 0" unfolding order_def proof (rule Least_equality, intro notI) assume "[:- a, 1:] ^ Suc (Suc 0) dvd [:- a, 1:]" from dvd_imp_degree_le[OF this] show False by auto next fix n assume *: "\<not> [:- a, 1:] ^ Suc n dvd [:- a, 1:]" thus "Suc 0 \<le> n" by (cases n, auto) qed declare order_power_n_n[simp] lemma linear_power_nonzero: "[: a, 1 :] ^ n \<noteq> 0" proof assume "[: a, 1 :]^n = 0" with arg_cong[OF this, of degree, unfolded degree_linear_power] show False by auto qed lemma order_linear_power': "order a ([: b, 1:]^Suc n) = (if b = -a then Suc n else 0)" proof (cases "b = -a") case True thus ?thesis unfolding True order_power_n_n by simp next case False let ?p = "[: b, 1:]^Suc n" from linear_power_nonzero have "?p \<noteq> 0" . have p: "?p = (\<Prod>a\<leftarrow> replicate (Suc n) b. [:a, 1:])" by auto { assume "order a ?p \<noteq> 0" then obtain m where ord: "order a ?p = Suc m" by (cases "order a ?p", auto) from order[OF \<open>?p \<noteq> 0\<close>, of a, unfolded ord] have dvd: "[:- a, 1:] ^ Suc m dvd ?p" by auto from poly_linear_exp_linear_factors[OF dvd[unfolded p]] False have False by auto } hence "order a ?p = 0" by auto with False show ?thesis by simp qed lemma order_linear_power: "order a ([: b, 1:]^n) = (if b = -a then n else 0)" proof (cases n) case (Suc m) show ?thesis unfolding Suc order_linear_power' by simp qed simp lemma order_linear': "order a [: b, 1:] = (if b = -a then 1 else 0)" using order_linear_power'[of a b 0] by simp lemma degree_div_less: assumes p: "(p::'a::field poly) \<noteq> 0" and dvd: "r dvd p" and deg: "degree r \<noteq> 0" shows "degree (p div r) < degree p" proof - from dvd obtain q where prq: "p = r * q" unfolding dvd_def by auto have "degree p = degree r + degree q" unfolding prq by (rule degree_mult_eq, insert p prq, auto) with deg have deg: "degree q < degree p" by auto from prq have "q = p div r" using deg p by auto with deg show ?thesis by auto qed lemma order_sum_degree: assumes "p \<noteq> 0" shows "sum (\<lambda> a. order a p) { a. poly p a = 0 } \<le> degree p" proof - define n where "n = degree p" have "degree p \<le> n" unfolding n_def by auto thus ?thesis using \<open>p \<noteq> 0\<close> proof (induct n arbitrary: p) case (0 p) define a where "a = coeff p 0" from 0 have "degree p = 0" by auto hence p: "p = [: a :]" unfolding a_def by (metis degree_0_id) with 0 have "a \<noteq> 0" by auto thus ?case unfolding p by auto next case (Suc m p) note order = order[OF \<open>p \<noteq> 0\<close>] show ?case proof (cases "\<exists> a. poly p a = 0") case True then obtain a where root: "poly p a = 0" by auto with order_root[of p a] Suc obtain n where orda: "order a p = Suc n" by (cases "order a p", auto) let ?a = "[: -a, 1 :] ^ Suc n" from order_decomp[OF \<open>p \<noteq> 0\<close>, of a, unfolded orda] obtain q where p: "p = ?a * q" and ndvd: "\<not> [:- a, 1:] dvd q" by auto from \<open>p \<noteq> 0\<close>[unfolded p] have nz: "?a \<noteq> 0" "q \<noteq> 0" by auto hence deg: "degree p = degree ?a + degree q" unfolding p by (subst degree_mult_eq, auto) have ord: "\<And> a. order a p = order a ?a + order a q" unfolding p by (subst order_mult, insert nz, auto) have roots: "{ a. poly p a = 0 } = insert a ({ a. poly q a = 0} - {a})" using root unfolding p poly_mult by auto have fin: "finite {a. poly q a = 0}" by (rule poly_roots_finite[OF \<open>q \<noteq> 0\<close>]) have "Suc n = order a p" using orda by simp also have "\<dots> = Suc n + order a q" unfolding ord order_linear_power' by simp finally have "order a q = 0" by auto with order_root[of q a] \<open>q \<noteq> 0\<close> have qa: "poly q a \<noteq> 0" by auto have "(\<Sum>a\<in>{a. poly q a = 0} - {a}. order a p) = (\<Sum>a\<in>{a. poly q a = 0} - {a}. order a q)" proof (rule sum.cong[OF refl]) fix b assume "b \<in> {a. poly q a = 0} - {a}" hence "b \<noteq> a" by auto hence "order b ?a = 0" unfolding order_linear_power' by simp thus "order b p = order b q" unfolding ord by simp qed also have "\<dots> = (\<Sum>a\<in>{a. poly q a = 0}. order a q)" using qa by auto also have "\<dots> \<le> degree q" by (rule Suc(1)[OF _ \<open>q \<noteq> 0\<close>], insert deg[unfolded degree_linear_power] Suc(2), auto) finally have "(\<Sum>a\<in>{a. poly q a = 0} - {a}. order a p) \<le> degree q" . thus ?thesis unfolding roots deg using fin by (subst sum.insert, simp_all only: degree_linear_power, auto simp: orda) qed auto qed qed lemma order_code[code]: "order (a::'a::idom_divide) p = (if p = 0 then Code.abort (STR ''order of polynomial 0 undefined'') (\<lambda> _. order a p) else if poly p a \<noteq> 0 then 0 else Suc (order a (p div [: -a, 1 :])))" proof (cases "p = 0") case False note p = this note order = order[OF p] show ?thesis proof (cases "poly p a = 0") case True with order_root[of p a] p obtain n where ord: "order a p = Suc n" by (cases "order a p", auto) from this(1) have "[: -a, 1 :] dvd p" using True poly_eq_0_iff_dvd by blast then obtain q where p: "p = [: -a, 1 :] * q" unfolding dvd_def by auto have ord: "order a p = order a [: -a, 1 :] + order a q" using p False order_mult[of "[: -a, 1 :]" q] by auto have q: "p div [: -a, 1 :] = q" using False p by (metis mult_zero_left nonzero_mult_div_cancel_left) show ?thesis unfolding ord q using False True by auto next case False with order_root[of p a] p show ?thesis by auto qed qed auto end
using Polynomials: Polynomial,fit,coeffs using Plots using Distributions: Normal using Random using Statistics: mean, std p = Polynomial([1,2,3]) @show coeffs(p) errstd = 3 errNormal = Normal(0,errstd) x = 0:10 y = 2 .+ 3 .* x .+rand(errNormal,11) scatter(x,y,yerror=errstd,label=false) fit_line = fit(x,y,1) @show coeffs(fit_line) plot!(x,fit_line.(x),label=false) b_list = [] m_list = [] N = 1000 for i in 1:N y = 2 .+ 3 .* x .+rand(errNormal,11) fit_c = coeffs(fit(x,y,1)) push!(b_list,fit_c[1]) push!(m_list,fit_c[2]) end @show mean(b_list) @show mean(m_list) @show std(b_list) @show std(m_list) histogram(b_list,bins=30) histogram(m_list,bins=30)
Formal statement is: lemma content_smult [simp]: fixes c :: "'a :: {normalization_semidom_multiplicative, semiring_gcd}" shows "content (smult c p) = normalize c * content p" Informal statement is: The content of a polynomial multiplied by a constant is the constant times the content of the polynomial.