Datasets:
AI4M
/

text
stringlengths
0
3.34M
[STATEMENT] lemma suminf_cong: "(\<And>n. f n = g n) \<Longrightarrow> suminf f = suminf g" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<And>n. f n = g n) \<Longrightarrow> suminf f = suminf g [PROOF STEP] by presburger
Formal statement is: lemma continuous_mult_right: fixes c::"'a::real_normed_algebra" shows "continuous F f \<Longrightarrow> continuous F (\<lambda>x. f x * c)" Informal statement is: If $f$ is a continuous function, then the function $x \mapsto f(x)c$ is continuous.
Formal statement is: lemma filterlim_int_of_nat_at_topD: fixes F assumes "filterlim (\<lambda>x. f (int x)) F at_top" shows "filterlim f F at_top" Informal statement is: If $f(n)$ converges to $L$ as $n \to \infty$, then $f(n)$ converges to $L$ as $n \to \infty$.
[STATEMENT] lemma eq_upred_sym: "(x =\<^sub>u y) = (y =\<^sub>u x)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (x =\<^sub>u y) = (y =\<^sub>u x) [PROOF STEP] by (pred_auto)
{-# OPTIONS --without-K --safe #-} open import Categories.Category using (Category) open import Categories.Category.Monoidal.Core using (Monoidal) open import Categories.Category.Monoidal.Symmetric using (Symmetric) module Categories.Category.Monoidal.Star-Autonomous {o ℓ e} {C : Category o ℓ e} (M : Monoidal C) where open import Level open import Categories.Category.Product using (_⁂_; assocˡ) open import Categories.Functor using (Functor; _∘F_; id) open import Categories.Functor.Properties using (FullyFaithful) open import Categories.NaturalTransformation.NaturalIsomorphism using (_≃_) open import Categories.Functor.Hom open Category C renaming (op to Cᵒᵖ) hiding (id) open Monoidal M open Functor ⊗ renaming (op to ⊗ₒₚ) open Hom C record Star-Autonomous : Set (levelOfTerm M) where field symmetric : Symmetric M Star : Functor Cᵒᵖ C open Functor Star renaming (op to Starₒₚ) public field FF-Star : FullyFaithful Star A**≃A : (Star ∘F Starₒₚ) ≃ id 𝒞[A⊗B,C*]≃𝒞[A,B⊗C*] : Hom[-,-] ∘F (⊗ₒₚ ⁂ Star) ≃ Hom[-,-] ∘F (id ⁂ (Star ∘F ⊗ₒₚ)) ∘F assocˡ _ _ _
struct StableNonLinearLESModel{T} <: AbstractLESModel c::T Δ²::T tau::SymTrTenField{T,3,2,false} reduction::Vector{T} end function StableNonLinearLESModel(c::T,Δ::Real,dim::NTuple{3,Integer}) where {T<:Real} data = SymTrTenField{T}(dim,(LX,LY,LZ)) #fill!(data,0) reduction = zeros(THR ? Threads.nthreads() : 1) return StableNonLinearLESModel{T}(c,Δ^2, data,reduction) end is_stable_nl_model(a::Type{T}) where {T<:StableNonLinearLESModel} = true @inline @par is_stable_nl_model(s::Type{T}) where {T<:@par(AbstractSimulation)} = is_stable_nl_model(LESModelType) @inline is_stable_nl_model(s::T) where {T<:AbstractSimulation} = is_stable_nl_model(T) is_stable_nl_model(a) = false msg(a::StableNonLinearLESModel) = "\nLES model: Stable Non-linear Model\nConstant: $(a.c)\nFilter Width: $(sqrt(a.Δ²))\n" @inline function stable_nl_eddy_viscosity(S::SymTen,W::AntiSymTen,c::Real,Δ2::Real) a = S:S nu = ifelse(a == 0.,zero(eltype(a)), @fastmath max(0.0,c*Δ2*((square(W):S) - (square(S):S))/(2a))) mnu = ifelse(a == 0.,zero(eltype(a)), @fastmath -min(0.0,c*Δ2*((square(W):S) - (square(S):S))/(2a))) return nu,mnu end
{-# OPTIONS --without-K --safe #-} module Categories.Functor.Bifunctor where -- Bifunctor, aka a Functor from C × D to E open import Level open import Categories.Category open import Categories.Functor open import Categories.Functor.Construction.Constant open import Categories.Category.Product private variable o ℓ e o′ ℓ′ e′ o″ ℓ″ e″ : Level C D D₁ D₂ E E₁ E₂ : Category o ℓ e Bifunctor : Category o ℓ e → Category o′ ℓ′ e′ → Category o″ ℓ″ e″ → Set _ Bifunctor C D E = Functor (Product C D) E overlap-× : ∀ (H : Bifunctor D₁ D₂ C) (F : Functor E D₁) (G : Functor E D₂) → Functor E C overlap-× H F G = H ∘F (F ※ G) reduce-× : ∀ (H : Bifunctor D₁ D₂ C) (F : Functor E₁ D₁) (G : Functor E₂ D₂) → Bifunctor E₁ E₂ C reduce-× H F G = H ∘F (F ⁂ G) flip-bifunctor : Bifunctor C D E → Bifunctor D C E flip-bifunctor b = b ∘F Swap appˡ : Bifunctor C D E → Category.Obj C → Functor D E appˡ F c = F ∘F constˡ c appʳ : Bifunctor C D E → Category.Obj D → Functor C E appʳ F d = F ∘F constʳ d
(* Copyright (C) 2017 M.A.L. Marques This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. *) (* type: work_gga_c *) (* prefix: gga_c_sogga11_params *params; assert(p->params != NULL); params = (gga_c_sogga11_params * )(p->params); *) $define lda_c_pw_params $define lda_c_pw_modified_params $include "lda_c_pw.mpl" mbeta := 15.75592*0.004235: (* the usual value of 0.066726 *) malpha := mbeta/(16*2^(2/3)): yy := (rs, z, xt) -> -malpha*mphi(z)*xt^2/(rs*f_pw(rs, z)): f0 := (rs, z, xt) -> 1 - 1/(1 + yy(rs, z, xt)): f1 := (rs, z, xt) -> 1 - exp(-yy(rs, z, xt)): t0 := (rs, z, xt) -> add(params_a_sogga11_a[i]*f0(rs, z, xt)^(i-1), i=1..6): t1 := (rs, z, xt) -> add(params_a_sogga11_b[i]*f1(rs, z, xt)^(i-1), i=1..6): f_sogga11 := (rs, z, xt, xs0, xs1) -> f_pw(rs, z)*(t0(rs, z, xt) + t1(rs, z, xt)): f := (rs, z, xt, xs0, xs1) -> f_sogga11(rs, z, xt, xs0, xs1):
[STATEMENT] lemma equal_3: "equal_3 x y = (real_of_3 x = real_of_3 y)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. equal_3 x y = (real_of_3 x = real_of_3 y) [PROOF STEP] by (transfer, auto)
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Johan Commelin -/ import category_theory.limits.shapes.products import category_theory.limits.shapes.images import category_theory.isomorphism_classes /-! # Zero objects A category "has a zero object" if it has an object which is both initial and terminal. Having a zero object provides zero morphisms, as the unique morphisms factoring through the zero object; see `category_theory.limits.shapes.zero_morphisms`. ## References * [F. Borceux, *Handbook of Categorical Algebra 2*][borceux-vol2] -/ noncomputable theory universes v u v' u' open category_theory open category_theory.category variables {C : Type u} [category.{v} C] variables {D : Type u'} [category.{v'} D] namespace category_theory namespace limits /-- An object `X` in a category is a *zero object* if for every object `Y` there is a unique morphism `to : X → Y` and a unique morphism `from : Y → X`. This is a characteristic predicate for `has_zero_object`. -/ structure is_zero (X : C) : Prop := (unique_to : ∀ Y, nonempty (unique (X ⟶ Y))) (unique_from : ∀ Y, nonempty (unique (Y ⟶ X))) namespace is_zero variables {X Y : C} /-- If `h : is_zero X`, then `h.to Y` is a choice of unique morphism `X → Y`. -/ protected def «to» (h : is_zero X) (Y : C) : X ⟶ Y := @default (X ⟶ Y) $ @unique.inhabited _ $ (h.unique_to Y).some lemma eq_to (h : is_zero X) (f : X ⟶ Y) : f = h.to Y := @unique.eq_default _ (id _) _ lemma to_eq (h : is_zero X) (f : X ⟶ Y) : h.to Y = f := (h.eq_to f).symm /-- If `h : is_zero X`, then `h.from Y` is a choice of unique morphism `Y → X`. -/ protected def «from» (h : is_zero X) (Y : C) : Y ⟶ X := @default (Y ⟶ X) $ @unique.inhabited _ $ (h.unique_from Y).some lemma eq_from (h : is_zero X) (f : Y ⟶ X) : f = h.from Y := @unique.eq_default _ (id _) _ lemma from_eq (h : is_zero X) (f : Y ⟶ X) : h.from Y = f := (h.eq_from f).symm lemma eq_of_src (hX : is_zero X) (f g : X ⟶ Y) : f = g := (hX.eq_to f).trans (hX.eq_to g).symm lemma eq_of_tgt (hX : is_zero X) (f g : Y ⟶ X) : f = g := (hX.eq_from f).trans (hX.eq_from g).symm /-- Any two zero objects are isomorphic. -/ def iso (hX : is_zero X) (hY : is_zero Y) : X ≅ Y := { hom := hX.to Y, inv := hX.from Y, hom_inv_id' := hX.eq_of_src _ _, inv_hom_id' := hY.eq_of_src _ _, } /-- A zero object is in particular initial. -/ protected def is_initial (hX : is_zero X) : is_initial X := @is_initial.of_unique _ _ X $ λ Y, (hX.unique_to Y).some /-- A zero object is in particular terminal. -/ protected def is_terminal (hX : is_zero X) : is_terminal X := @is_terminal.of_unique _ _ X $ λ Y, (hX.unique_from Y).some /-- The (unique) isomorphism between any initial object and the zero object. -/ def iso_is_initial (hX : is_zero X) (hY : is_initial Y) : X ≅ Y := hX.is_initial.unique_up_to_iso hY /-- The (unique) isomorphism between any terminal object and the zero object. -/ def iso_is_terminal (hX : is_zero X) (hY : is_terminal Y) : X ≅ Y := hX.is_terminal.unique_up_to_iso hY lemma of_iso (hY : is_zero Y) (e : X ≅ Y) : is_zero X := begin refine ⟨λ Z, ⟨⟨⟨e.hom ≫ hY.to Z⟩, λ f, _⟩⟩, λ Z, ⟨⟨⟨hY.from Z ≫ e.inv⟩, λ f, _⟩⟩⟩, { rw ← cancel_epi e.inv, apply hY.eq_of_src, }, { rw ← cancel_mono e.hom, apply hY.eq_of_tgt, }, end end is_zero end limits open category_theory.limits lemma iso.is_zero_iff {X Y : C} (e : X ≅ Y) : is_zero X ↔ is_zero Y := ⟨λ h, h.of_iso e.symm, λ h, h.of_iso e⟩ lemma functor.is_zero (F : C ⥤ D) (hF : ∀ X, is_zero (F.obj X)) : is_zero F := begin split; intros G; refine ⟨⟨⟨_⟩, _⟩⟩, { refine { app := λ X, (hF _).to _, naturality' := _ }, intros, exact (hF _).eq_of_src _ _ }, { intro f, ext, apply (hF _).eq_of_src _ _ }, { refine { app := λ X, (hF _).from _, naturality' := _ }, intros, exact (hF _).eq_of_tgt _ _ }, { intro f, ext, apply (hF _).eq_of_tgt _ _ }, end namespace limits variables (C) /-- A category "has a zero object" if it has an object which is both initial and terminal. -/ class has_zero_object : Prop := (zero : ∃ X : C, is_zero X) instance has_zero_object_punit : has_zero_object (discrete punit) := { zero := ⟨⟨⟨⟩⟩, by tidy, by tidy⟩, } section variables [has_zero_object C] /-- Construct a `has_zero C` for a category with a zero object. This can not be a global instance as it will trigger for every `has_zero C` typeclass search. -/ protected def has_zero_object.has_zero : has_zero C := { zero := has_zero_object.zero.some } localized "attribute [instance] category_theory.limits.has_zero_object.has_zero" in zero_object lemma is_zero_zero : is_zero (0 : C) := has_zero_object.zero.some_spec end open_locale zero_object variables {C} lemma is_zero.has_zero_object {X : C} (hX : is_zero X) : has_zero_object C := ⟨⟨X, hX⟩⟩ /-- Every zero object is isomorphic to *the* zero object. -/ def is_zero.iso_zero [has_zero_object C] {X : C} (hX : is_zero X) : X ≅ 0 := hX.iso (is_zero_zero C) lemma is_zero.obj [has_zero_object D] {F : C ⥤ D} (hF : is_zero F) (X : C) : is_zero (F.obj X) := begin let G : C ⥤ D := (category_theory.functor.const C).obj 0, have hG : is_zero G := functor.is_zero _ (λ X, is_zero_zero _), let e : F ≅ G := hF.iso hG, exact (is_zero_zero _).of_iso (e.app X), end namespace has_zero_object variables [has_zero_object C] /-- There is a unique morphism from the zero object to any object `X`. -/ protected def unique_to (X : C) : unique (0 ⟶ X) := ((is_zero_zero C).unique_to X).some /-- There is a unique morphism from any object `X` to the zero object. -/ protected def unique_from (X : C) : unique (X ⟶ 0) := ((is_zero_zero C).unique_from X).some localized "attribute [instance] category_theory.limits.has_zero_object.unique_to" in zero_object localized "attribute [instance] category_theory.limits.has_zero_object.unique_from" in zero_object @[ext] lemma to_zero_ext {X : C} (f g : X ⟶ 0) : f = g := (is_zero_zero C).eq_of_tgt _ _ @[ext] lemma from_zero_ext {X : C} (f g : 0 ⟶ X) : f = g := (is_zero_zero C).eq_of_src _ _ instance (X : C) : subsingleton (X ≅ 0) := by tidy instance {X : C} (f : 0 ⟶ X) : mono f := { right_cancellation := λ Z g h w, by ext, } instance {X : C} (f : X ⟶ 0) : epi f := { left_cancellation := λ Z g h w, by ext, } instance zero_to_zero_is_iso (f : (0 : C) ⟶ 0) : is_iso f := by convert (show is_iso (𝟙 (0 : C)), by apply_instance) /-- A zero object is in particular initial. -/ def zero_is_initial : is_initial (0 : C) := (is_zero_zero C).is_initial /-- A zero object is in particular terminal. -/ def zero_is_terminal : is_terminal (0 : C) := (is_zero_zero C).is_terminal /-- A zero object is in particular initial. -/ @[priority 10] instance has_initial : has_initial C := has_initial_of_unique 0 /-- A zero object is in particular terminal. -/ @[priority 10] instance has_terminal : has_terminal C := has_terminal_of_unique 0 /-- The (unique) isomorphism between any initial object and the zero object. -/ def zero_iso_is_initial {X : C} (t : is_initial X) : 0 ≅ X := zero_is_initial.unique_up_to_iso t /-- The (unique) isomorphism between any terminal object and the zero object. -/ def zero_iso_is_terminal {X : C} (t : is_terminal X) : 0 ≅ X := zero_is_terminal.unique_up_to_iso t /-- The (unique) isomorphism between the chosen initial object and the chosen zero object. -/ def zero_iso_initial [has_initial C] : 0 ≅ ⊥_ C := zero_is_initial.unique_up_to_iso initial_is_initial /-- The (unique) isomorphism between the chosen terminal object and the chosen zero object. -/ def zero_iso_terminal [has_terminal C] : 0 ≅ ⊤_ C := zero_is_terminal.unique_up_to_iso terminal_is_terminal @[priority 100] instance has_strict_initial : initial_mono_class C := initial_mono_class.of_is_initial zero_is_initial (λ X, category_theory.mono _) end has_zero_object end limits open category_theory.limits open_locale zero_object lemma functor.is_zero_iff [has_zero_object D] (F : C ⥤ D) : is_zero F ↔ ∀ X, is_zero (F.obj X) := ⟨λ hF X, hF.obj X, functor.is_zero _⟩ end category_theory
A gold dollar had been proposed several times in the 1830s and 1840s , but was not initially adopted . Congress was finally galvanized into action by the increased supply of bullion caused by the California gold rush , and in 1849 authorized a gold dollar . In its early years , silver coins were being hoarded or exported , and the gold dollar found a ready place in commerce . Silver again circulated after Congress in 1853 required that new coins of that metal be made lighter , and the gold dollar became a rarity in commerce even before federal coins vanished from circulation because of the economic disruption caused by the American Civil War .
lemma continuous_mult_left: fixes c::"'a::real_normed_algebra" shows "continuous F f \<Longrightarrow> continuous F (\<lambda>x. c * f x)"
State Before: Γ : Type u_1 R : Type u_2 inst✝¹ : PartialOrder Γ inst✝ : AddCommMonoid R α : Type u_3 s t : SummableFamily Γ R α ⊢ hsum (s + t) = hsum s + hsum t State After: case coeff.h Γ : Type u_1 R : Type u_2 inst✝¹ : PartialOrder Γ inst✝ : AddCommMonoid R α : Type u_3 s t : SummableFamily Γ R α g : Γ ⊢ coeff (hsum (s + t)) g = coeff (hsum s + hsum t) g Tactic: ext g State Before: case coeff.h Γ : Type u_1 R : Type u_2 inst✝¹ : PartialOrder Γ inst✝ : AddCommMonoid R α : Type u_3 s t : SummableFamily Γ R α g : Γ ⊢ coeff (hsum (s + t)) g = coeff (hsum s + hsum t) g State After: case coeff.h Γ : Type u_1 R : Type u_2 inst✝¹ : PartialOrder Γ inst✝ : AddCommMonoid R α : Type u_3 s t : SummableFamily Γ R α g : Γ ⊢ (∑ᶠ (i : α), coeff (toFun s i) g + coeff (toFun t i) g) = (∑ᶠ (i : α), coeff (toFun s i) g) + ∑ᶠ (i : α), coeff (toFun t i) g Tactic: simp only [hsum_coeff, add_coeff, add_apply] State Before: case coeff.h Γ : Type u_1 R : Type u_2 inst✝¹ : PartialOrder Γ inst✝ : AddCommMonoid R α : Type u_3 s t : SummableFamily Γ R α g : Γ ⊢ (∑ᶠ (i : α), coeff (toFun s i) g + coeff (toFun t i) g) = (∑ᶠ (i : α), coeff (toFun s i) g) + ∑ᶠ (i : α), coeff (toFun t i) g State After: no goals Tactic: exact finsum_add_distrib (s.finite_co_support _) (t.finite_co_support _)
{-# OPTIONS --cubical --no-import-sorts --safe #-} open import Cubical.Core.Everything open import Cubical.Foundations.HLevels module Cubical.Algebra.Magma.Construct.Left {ℓ} (Aˢ : hSet ℓ) where open import Cubical.Foundations.Prelude open import Cubical.Algebra.Magma private A = ⟨ Aˢ ⟩ isSetA = Aˢ .snd _◂_ : Op₂ A x ◂ y = x ------------------------------------------------------------------------ -- Properties ◂-zeroˡ : ∀ x → LeftZero x _◂_ ◂-zeroˡ _ _ = refl ◂-identityʳ : ∀ x → RightIdentity x _◂_ ◂-identityʳ _ _ = refl ------------------------------------------------------------------------ -- Magma definition Left-isMagma : IsMagma A _◂_ Left-isMagma = record { is-set = isSetA } LeftMagma : Magma ℓ LeftMagma = record { isMagma = Left-isMagma }
We all know that the TV shows nowadays are all scripted even though they are said to be reality. I remember that night Sky broke down and talked about her kids..,it even choked me up. Check out the interview below which features Sky's baby daddy and her son.
import tactic /- # Option Much of this part is optional, if you just want to get to the topology. ## The definition If `X : Type` then `option X : Type` is a type with "one more element than `X`". The disadvantage of type theory over set theory is that distinct types are always disjoint. So if `x : X` then `x : option X` can't make sense. The way it's set up is that there's a map called `some : X → option X` which is an injection, and there's exactly one element of `option X` which is not in the image, and it's called `none`. ## The API Injectivity of `some` is `option.some_injective X : injective (some : X → option X)` and it's implied by `option.some_inj : some a = some b ↔ a = b` To define a function `option X → Y` we have to say where `some x` goes for `x : X`, and also where `none` goes. So we need a function `X → Y` for `some` and a term `y : Y` for `none`. You make the function itself with the recursor for `option`, namely `option.rec`. -/ variables {X Y : Type} def g (y : Y) (f : X → Y) : option X → Y := λ t, option.rec y f t -- I claim that `g` is the function we require. Note -- that `g` takes `f` and `y` as explicit inputs -- so it's `g f y`. Its values on `none` and `some x` are *by definition* -- what we want them to be: variables (f : X → Y) (y : Y) example : (g y f) none = y := begin refl end example (x : X) : (g y f) (some x) = f x := begin refl end -- That's all you need to know about `option` really, but -- it turns out that `option` is a `monad` so if you want to put -- off doing topology you could do this instead. -- https://en.wikipedia.org/wiki/Monad_%28category_theory%29 -- look at "formal definition" -- option is a functor `Type → Type`; we've defined it on objects -- so let's define it on morphisms: def option_func (f : X → Y) : option X → option Y := λ t, option.rec none (some ∘ f) t -- now check two axioms for a functor, `option_id` and `option_comp` -- NB you can do `cases ox with x` on `ox : option X` to break down into the -- `none` and `some x` cases. lemma option_id (ox : option X) : option_func (id : X → X) ox = ox := begin sorry end variable (Z : Type) lemma option_comp (f : X → Y) (g : Y → Z) (ox : option X) : option_func (g ∘ f) ox = (option_func g) (option_func f ox) := begin sorry end -- Now we define the structure of a monad, an `eta` and a `mu`. def eta {X : Type} : X → option X := some def mu {X : Type} : option (option X) → option X := -- function which sends `none` to `none` and `some ox` to `ox` λ t, option.rec none id t -- eta is a natural transformation lemma eta_nat (f : X → Y) (x : X) : option_func f (eta x) = eta (f x) := begin sorry end -- mu is a natural transformation lemma mu_nat (f : X → Y) (oox : option (option X)) : option_func f (mu oox) = mu (option_func (option_func f) oox) := begin sorry end -- coherence conditions (if I got them right!) lemma coherence1 (ooox : option (option (option X))) : mu ((option_func mu) ooox) = mu (mu ooox) := begin sorry end lemma coherence2a (ox : option X) : mu (eta ox) = ox := begin sorry end lemma coherence2b (ox : option X) : mu (option_func eta ox) = ox := begin sorry end -- please feel free to check -- I don't know much about monads!
Formal statement is: lemma continuous_on_inversediff: fixes z:: "'a::real_normed_field" shows "z \<notin> S \<Longrightarrow> continuous_on S (\<lambda>w. 1 / (w - z))" Informal statement is: If $z$ is not in $S$, then the function $f(w) = 1/(w-z)$ is continuous on $S$.
/- Copyright (c) 2018 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Kenny Lau, Robert Y. Lewis -/ import algebra.group.basic /-! # Eckmann-Hilton argument The Eckmann-Hilton argument says that if a type carries two monoid structures that distribute over one another, then they are equal, and in addition commutative. The main application lies in proving that higher homotopy groups (`πₙ` for `n ≥ 2`) are commutative. ## Main declarations * `eckmann_hilton.comm_monoid`: If a type carries a unital magma structure that distributes over a unital binary operation, then the magma is a commutative monoid. * `eckmann_hilton.comm_group`: If a type carries a group structure that distributes over a unital binary operation, then the group is commutative. -/ universe u namespace eckmann_hilton variables {X : Type u} local notation a `<`m`>` b := m a b /-- `is_unital m e` expresses that `e : X` is a left and right unit for the binary operation `m : X → X → X`. -/ structure is_unital (m : X → X → X) (e : X) extends is_left_id _ m e, is_right_id _ m e : Prop. @[to_additive eckmann_hilton.add_zero_class.is_unital] lemma mul_one_class.is_unital [G : mul_one_class X] : is_unital (*) (1 : X) := is_unital.mk (by apply_instance) (by apply_instance) variables {m₁ m₂ : X → X → X} {e₁ e₂ : X} variables (h₁ : is_unital m₁ e₁) (h₂ : is_unital m₂ e₂) variables (distrib : ∀ a b c d, ((a <m₂> b) <m₁> (c <m₂> d)) = ((a <m₁> c) <m₂> (b <m₁> d))) include h₁ h₂ distrib /-- If a type carries two unital binary operations that distribute over each other, then they have the same unit elements. In fact, the two operations are the same, and give a commutative monoid structure, see `eckmann_hilton.comm_monoid`. -/ lemma one : e₁ = e₂ := by simpa only [h₁.left_id, h₁.right_id, h₂.left_id, h₂.right_id] using distrib e₂ e₁ e₁ e₂ /-- If a type carries two unital binary operations that distribute over each other, then these operations are equal. In fact, they give a commutative monoid structure, see `eckmann_hilton.comm_monoid`. -/ lemma mul : m₁ = m₂ := begin funext a b, calc m₁ a b = m₁ (m₂ a e₁) (m₂ e₁ b) : by simp only [one h₁ h₂ distrib, h₁.left_id, h₁.right_id, h₂.left_id, h₂.right_id] ... = m₂ a b : by simp only [distrib, h₁.left_id, h₁.right_id, h₂.left_id, h₂.right_id] end /-- If a type carries two unital binary operations that distribute over each other, then these operations are commutative. In fact, they give a commutative monoid structure, see `eckmann_hilton.comm_monoid`. -/ lemma mul_comm : is_commutative _ m₂ := ⟨λ a b, by simpa [mul h₁ h₂ distrib, h₂.left_id, h₂.right_id] using distrib e₂ a b e₂⟩ /-- If a type carries two unital binary operations that distribute over each other, then these operations are associative. In fact, they give a commutative monoid structure, see `eckmann_hilton.comm_monoid`. -/ lemma mul_assoc : is_associative _ m₂ := ⟨λ a b c, by simpa [mul h₁ h₂ distrib, h₂.left_id, h₂.right_id] using distrib a b e₂ c⟩ omit h₁ h₂ distrib /-- If a type carries a unital magma structure that distributes over a unital binary operations, then the magma structure is a commutative monoid. -/ @[to_additive "If a type carries a unital additive magma structure that distributes over a unital binary operations, then the additive magma structure is a commutative additive monoid."] def comm_monoid [h : mul_one_class X] (distrib : ∀ a b c d, ((a * b) <m₁> (c * d)) = ((a <m₁> c) * (b <m₁> d))) : comm_monoid X := { mul := (*), one := 1, mul_comm := (mul_comm h₁ mul_one_class.is_unital distrib).comm, mul_assoc := (mul_assoc h₁ mul_one_class.is_unital distrib).assoc, ..h } /-- If a type carries a group structure that distributes over a unital binary operation, then the group is commutative. -/ @[to_additive "If a type carries an additive group structure that distributes over a unital binary operation, then the additive group is commutative."] def comm_group [G : group X] (distrib : ∀ a b c d, ((a * b) <m₁> (c * d)) = ((a <m₁> c) * (b <m₁> d))) : comm_group X := { ..(eckmann_hilton.comm_monoid h₁ distrib), ..G } end eckmann_hilton
-- @@stderr -- dtrace: failed to compile script test/unittest/speculation/err.D_PRAGMA_OPTSET.HugeNspecValue.d: [D_PRAGMA_OPTSET] line 19: failed to set option 'nspec' to '245566729809009887663': Invalid value for specified option
State Before: R : Type u_2 A : Type u_1 B : Type ?u.27887 inst✝⁴ : CommRing R inst✝³ : Ring A inst✝² : Ring B inst✝¹ : Algebra R A inst✝ : Algebra R B c₁ c₂ : R q : Basis A c₁ c₂ ⊢ q.k * q.j = c₂ • q.i State After: no goals Tactic: rw [← i_mul_j, mul_assoc, j_mul_j, mul_smul_comm, mul_one]
[STATEMENT] lemma (in flowgraph) ntrs_add_context_s: assumes A: "((s,c),e,(s',c'))\<in>ntrs fg" and B: "mon_w fg e \<inter> mon_c fg cn = {}" shows "((s,c+cn),e,(s',c'+cn))\<in>ntrs fg" [PROOF STATE] proof (prove) goal (1 subgoal): 1. ((s, c + cn), e, s', c' + cn) \<in> ntrs fg [PROOF STEP] using ntrs_mon_e_no_ctx[OF A] ntrs_modify_context_s[OF A, of "c+cn"] B [PROOF STATE] proof (prove) using this: mon_w fg e \<inter> mon_c fg c = {} mon_w fg e \<inter> mon_c fg (c + cn) = {} \<Longrightarrow> \<exists>csp. c' = csp + c \<and> mon_c fg csp = {} \<and> ((s, c + cn), e, s', csp + (c + cn)) \<in> ntrs fg mon_w fg e \<inter> mon_c fg cn = {} goal (1 subgoal): 1. ((s, c + cn), e, s', c' + cn) \<in> ntrs fg [PROOF STEP] by (force simp add: mon_c_unconc union_ac)
[STATEMENT] lemma nprv_truI: "F \<subseteq> fmla \<Longrightarrow> finite F \<Longrightarrow> nprv F tru" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>F \<subseteq> fmla; finite F\<rbrakk> \<Longrightarrow> nprv F tru [PROOF STEP] unfolding nprv_def [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>F \<subseteq> fmla; finite F\<rbrakk> \<Longrightarrow> prv (imp (scnj F) tru) [PROOF STEP] by (simp add: prv_imp_tru)
In 1831 , the first gold dollar was minted , at the private mint of Christopher Bechtler in North Carolina . Much of the gold then being produced in the United States came from the mountains of North Carolina and Georgia , and the dollars and other small gold coins issued by Bechtler circulated through that region , and were now and then seen further away . Additional one @-@ dollar pieces were struck by August Bechtler , Christopher 's son .
function W = randInitializeWeights(L_in, L_out) %RANDINITIALIZEWEIGHTS Randomly initialize the weights of a layer with L_in %incoming connections and L_out outgoing connections % W = RANDINITIALIZEWEIGHTS(L_in, L_out) randomly initializes the weights % of a layer with L_in incoming connections and L_out outgoing % connections. % % Note that W should be set to a matrix of size(L_out, 1 + L_in) as % the column row of W handles the "bias" terms % % You need to return the following variables correctly W = zeros(L_out, 1 + L_in); % ====================== YOUR CODE HERE ====================== % Instructions: Initialize W randomly so that we break the symmetry while % training the neural network. % % Note: The first row of W corresponds to the parameters for the bias units % epsilon = 0.12; W = rand(L_out, 1 + L_in) * 2 * epsilon - epsilon; % ========================================================================= end
[GOAL] 𝕜 : Type u_1 inst✝² : NontriviallyNormedField 𝕜 E : Type u_2 inst✝¹ : NormedAddCommGroup E inst✝ : NormedSpace 𝕜 E f : 𝕜 →ᵃ[𝕜] E a b : E L : Filter 𝕜 s : Set 𝕜 x : 𝕜 ⊢ HasStrictDerivAt (↑f) (↑f.linear 1) x [PROOFSTEP] rw [f.decomp] [GOAL] 𝕜 : Type u_1 inst✝² : NontriviallyNormedField 𝕜 E : Type u_2 inst✝¹ : NormedAddCommGroup E inst✝ : NormedSpace 𝕜 E f : 𝕜 →ᵃ[𝕜] E a b : E L : Filter 𝕜 s : Set 𝕜 x : 𝕜 ⊢ HasStrictDerivAt (↑f.linear + fun x => ↑f 0) (↑f.linear 1) x [PROOFSTEP] exact f.linear.hasStrictDerivAt.add_const (f 0) [GOAL] 𝕜 : Type u_1 inst✝² : NontriviallyNormedField 𝕜 E : Type u_2 inst✝¹ : NormedAddCommGroup E inst✝ : NormedSpace 𝕜 E f : 𝕜 →ᵃ[𝕜] E a b : E L : Filter 𝕜 s : Set 𝕜 x : 𝕜 ⊢ HasDerivAtFilter (↑f) (↑f.linear 1) x L [PROOFSTEP] rw [f.decomp] [GOAL] 𝕜 : Type u_1 inst✝² : NontriviallyNormedField 𝕜 E : Type u_2 inst✝¹ : NormedAddCommGroup E inst✝ : NormedSpace 𝕜 E f : 𝕜 →ᵃ[𝕜] E a b : E L : Filter 𝕜 s : Set 𝕜 x : 𝕜 ⊢ HasDerivAtFilter (↑f.linear + fun x => ↑f 0) (↑f.linear 1) x L [PROOFSTEP] exact f.linear.hasDerivAtFilter.add_const (f 0) [GOAL] 𝕜 : Type u_1 inst✝² : NontriviallyNormedField 𝕜 E : Type u_2 inst✝¹ : NormedAddCommGroup E inst✝ : NormedSpace 𝕜 E f : 𝕜 →ᵃ[𝕜] E a b : E L : Filter 𝕜 s : Set 𝕜 x : 𝕜 ⊢ HasStrictDerivAt (↑(lineMap a b)) (b - a) x [PROOFSTEP] simpa using (lineMap a b : 𝕜 →ᵃ[𝕜] E).hasStrictDerivAt
-- @@stderr -- dtrace: failed to compile script test/unittest/printf/err.D_SYNTAX.badconv3.d: [D_SYNTAX] line 18: format conversion #1 is undefined: %Z
proposition separate_point_closed: fixes s :: "'a::heine_borel set" assumes "closed s" and "a \<notin> s" shows "\<exists>d>0. \<forall>x\<in>s. d \<le> dist a x"
! { dg-do compile } ! { dg-options "--param parloops-chunk-size=2 -ftree-parallelize-loops=2 -O1" } program main implicit none real, dimension(:,:),allocatable :: a, b, c real :: sm allocate (a(2,2), b(2,2), c(2,2)) call random_number(a) call random_number(b) c = matmul(a,b) sm = sum(c) deallocate(a,b,c) end program main
module Setoids where open import Eq open import Prelude record Setoid : Set1 where field carrier : Set _≈_ : carrier -> carrier -> Set equiv : Equiv _≈_ record Datoid : Set1 where field setoid : Setoid _≟_ : forall x y -> Dec (Setoid._≈_ setoid x y) Setoid-≡ : Set -> Setoid Setoid-≡ a = record { carrier = a; _≈_ = _≡_; equiv = Equiv-≡ }
-- MIT License -- Copyright (c) 2021 Luca Ciccone and Luca Padovani -- Permission is hereby granted, free of charge, to any person -- obtaining a copy of this software and associated documentation -- files (the "Software"), to deal in the Software without -- restriction, including without limitation the rights to use, -- copy, modify, merge, publish, distribute, sublicense, and/or sell -- copies of the Software, and to permit persons to whom the -- Software is furnished to do so, subject to the following -- conditions: -- The above copyright notice and this permission notice shall be -- included in all copies or substantial portions of the Software. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -- OTHER DEALINGS IN THE SOFTWARE. {-# OPTIONS --guardedness #-} open import Data.Empty open import Data.Product open import Data.List using ([]; _∷_; _∷ʳ_) open import Relation.Unary using (_∈_) open import Relation.Binary.PropositionalEquality using (_≡_; refl) import Relation.Binary.HeterogeneousEquality as Het open import Common module Transitions {ℙ : Set} (message : Message ℙ) where open import SessionType message open import Trace message data Transition : SessionType -> Action -> SessionType -> Set where inp : ∀{f x} -> Transition (inp f) (I x) (f x .force) out : ∀{f x} (!x : x ∈ dom f) -> Transition (out f) (O x) (f x .force) data Transitions : SessionType -> Trace -> SessionType -> Set where refl : ∀{T} -> Transitions T [] T step : ∀{T α T' φ T''} (t : Transition T α T') (tr : Transitions T' φ T'') -> Transitions T (α ∷ φ) T'' transition->defined : ∀{T a S} -> Transition T a S -> Defined T transition->defined inp = inp transition->defined (out _) = out output-transition->defined : ∀{T x S} -> Transition T (O x) S -> Defined S output-transition->defined (out !x) = !x output-transitions->defined : ∀{T φ x S} -> Transitions T (φ ∷ʳ O x) S -> Defined S output-transitions->defined {_} {[]} (step (out fx) refl) = fx output-transitions->defined {_} {_ ∷ _} (step _ tr) = output-transitions->defined tr unsnoc-transitions : ∀{T φ α S} -> Transitions T (φ ∷ʳ α) S -> ∃[ R ] (Transitions T φ R × Transition R α S) unsnoc-transitions {_} {[]} (step t refl) = _ , refl , t unsnoc-transitions {_} {x ∷ φ} (step t tr) with unsnoc-transitions tr ... | _ , sr , s = _ , step t sr , s transitions+defined->defined : ∀{T as S} -> Transitions T as S -> Defined S -> Defined T transitions+defined->defined refl def = def transitions+defined->defined (step t _) _ = transition->defined t transitions-eq : ∀{T T' T'' φ} (tr : Transitions T φ T') (sr : Transitions T φ T'') -> T' ≡ T'' × tr Het.≅ sr transitions-eq refl refl = refl , Het.refl transitions-eq (step inp tr) (step inp sr) with transitions-eq tr sr ... | refl , Het.refl = refl , Het.refl transitions-eq (step (out fx) tr) (step (out gx) sr) with Defined-eq fx gx | transitions-eq tr sr ... | refl | refl , Het.refl = refl , Het.refl win-reduces-⊥ : ∀{S S' α} → Win S → Transition S α S' → ⊥ win-reduces-⊥ (out e) (out !x) = e _ !x
State Before: X : Type u_1 x : X a : FreeAbelianGroup X ⊢ x ∈ support a ↔ ↑(coeff x) a ≠ 0 State After: X : Type u_1 x : X a : FreeAbelianGroup X ⊢ ↑(↑toFinsupp a) x ≠ 0 ↔ ↑(coeff x) a ≠ 0 Tactic: rw [support, Finsupp.mem_support_iff] State Before: X : Type u_1 x : X a : FreeAbelianGroup X ⊢ ↑(↑toFinsupp a) x ≠ 0 ↔ ↑(coeff x) a ≠ 0 State After: no goals Tactic: exact Iff.rfl
module Data.Ref import public Data.IORef import public Control.Monad.ST %default total public export interface Ref m r | m where newRef : {0 a : Type} -> a -> m (r a) readRef : {0 a : Type} -> r a -> m a writeRef : r a -> a -> m () export HasIO io => Ref io IORef where newRef = newIORef readRef = readIORef writeRef = writeIORef export Ref (ST s) (STRef s) where newRef = newSTRef readRef = readSTRef writeRef = writeSTRef
r""" File I/O (:mod:`skbio.io`) ========================== .. currentmodule:: skbio.io This package provides I/O functionality for skbio. For information about extending the I/O functionality of skbio, see the associated Developer Documentation. User Functions -------------- .. autosummary:: :toctree: generated/ write read sniff User Exceptions --------------- .. autosummary:: :toctree: generated/ FileFormatError RecordError FieldError UnrecognizedFormatError User Warnings ------------- .. autosummary:: :toctree: generated/ UnprovenFormatWarning ArgumentOverrideWarning Developer Documentation ----------------------- To extend I/O in skbio, developers should create a submodule in `skbio/io/` named after the file format it implements. For example, if you were to create readers and writers for a `fasta` file, you would create a submodule `skbio/io/fasta.py`. In this submodule you would use the following decorators: ``register_writer``, ``register_reader``, and ``register_sniffer``. These associate your functionality to a format string and potentially an skbio class. Please see the relevant documenation for more information about these functions. Once you are satisfied with the functionality, you will need to ensure that `skbio/io/__init__.py` contains an import of your new submodule, that way the decorators are executed on importing the user functions above. We recommend importing functions that return a generator as they are generally useful and make sense in the context of `skbio.io`. Developer Functions ------------------- .. autosummary:: :toctree: generated/ register_writer register_reader register_sniffer list_write_formats list_read_formats get_writer get_reader get_sniffer Developer Exceptions -------------------- .. autosummary:: :toctree: generated/ DuplicateRegistrationError """ # ---------------------------------------------------------------------------- # Copyright (c) 2013--, scikit-bio development team. # # Distributed under the terms of the Modified BSD License. # # The full license is in the file COPYING.txt, distributed with this software. # ---------------------------------------------------------------------------- from ._warning import UnprovenFormatWarning, ArgumentOverrideWarning from ._exception import (DuplicateRegistrationError, RecordError, FieldError, UnrecognizedFormatError, FileFormatError) from ._registry import (write, read, sniff, get_writer, get_reader, get_sniffer, list_write_formats, list_read_formats, register_writer, register_reader, register_sniffer) __all__ = ['write', 'read', 'sniff', 'get_writer', 'get_reader', 'get_sniffer', 'list_write_formats', 'list_read_formats', 'register_writer', 'register_reader', 'register_sniffer', 'DuplicateRegistrationError', 'RecordError', 'FieldError', 'UnrecognizedFormatError', 'FileFormatError', 'UnprovenFormatWarning', 'ArgumentOverrideWarning'] from numpy.testing import Tester test = Tester().test
module Task.Internal import public Control.Monad.Ref import public Task.Universe import public Task.Input %default total %access export %hide Language.Reflection.Ref %hide Language.Reflection.Universe infix 6 =~, /~ -- Tasks ----------------------------------------------------------------------- public export data TaskT : (m : Type -> Type) -> (r : Ty) -> Type where -- Core Edit : (val : Maybe (typeOf r)) -> TaskT m r Store : MonadRef l m => l (typeOf r) -> TaskT m r -- Parallel And : (left : TaskT m a) -> (right : TaskT m b) -> TaskT m (PAIR a b) -- Choice Or : (left : TaskT m r) -> (right : TaskT m r) -> TaskT m r Xor : (left : TaskT m r) -> (right : TaskT m r) -> TaskT m r Fail : TaskT m r -- Sequence Then : (this : TaskT m a) -> (next : typeOf a -> TaskT m r) -> TaskT m r Next : (this : TaskT m a) -> (next : typeOf a -> TaskT m r) -> TaskT m r -- Labels Label : Label -> (this : TaskT m r) -> TaskT m r -- Lifts Lift : Monad m => m (typeOf a) -> TaskT m a -- Labels ---------------------------------------------------------------------- ||| Get the current label, if one label : TaskT m a -> Maybe Label label (Label l _) = Just l label _ = Nothing ||| Remove as much labels as possible from a task. ||| ||| Usefull to deeply match task constructors while ignoring labels. delabel : TaskT m a -> TaskT m a delabel (Label _ t) = delabel t delabel t = t ||| Match a label to a task. (=~) : Label -> TaskT m a -> Bool (=~) k (Label l _) = l == l (=~) _ _ = False ||| Negation of `(=~)`. (/~) : Label -> TaskT m a -> Bool (/~) l t = not (l =~ t) ||| Collect all labels in an external choice labels : TaskT m a -> List Label labels (Label _ Fail) = [] labels (Label l this) = l :: labels this labels (Xor left right) = labels left ++ labels right -- --FIXME: should we also check for labels on the lhs of a step (see also `find`)? -- labels (Then this _) = labels this -- labels (Next this _) = labels this labels _ = [] ||| Depth first search for a label on a task tree. ||| ||| Returns the path of the found task. find : Label -> TaskT m a -> Maybe Path find k (Label l this) with ( k == l ) | True = Just GoHere | False = find k this find k (Xor left right) = map GoLeft (find k left) <|> map GoRight (find k right) -- --FIXME: should we can send pick-events through to the lhs of a step (see also `labels`)? -- find k (Then this _) = find k this -- find k (Next this _) = find k this find k _ = Nothing ||| Check if a task constructor keeps its label after stepping or loses it. keeper : TaskT m a -> Bool keeper (Edit _) = True keeper (And _ _) = True keeper (Fail) = True keeper _ = False
Formal statement is: lemma starlike_imp_connected: fixes S :: "'a::real_normed_vector set" shows "starlike S \<Longrightarrow> connected S" Informal statement is: Any starlike set is connected.
lemma Bseq_add: fixes f :: "nat \<Rightarrow> 'a::real_normed_vector" assumes "Bseq f" shows "Bseq (\<lambda>x. f x + c)"
[STATEMENT] lemma (in infinite_coin_toss_space) pseudo_proj_True_same_img: assumes "pseudo_proj_True n w = pseudo_proj_True n x" shows "stake n w = stake n x" [PROOF STATE] proof (prove) goal (1 subgoal): 1. stake n w = stake n x [PROOF STEP] by (metis assms pseudo_proj_True_stake)
State Before: α : Type u β : Type v γ : Type w R : Type x inst✝ : NonUnitalNonAssocRing R a b : R h : Commute a b ⊢ a * a - b * b = (a - b) * (a + b) State After: no goals Tactic: rw [mul_add, sub_mul, sub_mul, h.eq, sub_add_sub_cancel]
Formal statement is: corollary isomorphisms_UNIV_UNIV: assumes "DIM('M) = DIM('N)" obtains f::"'M::euclidean_space \<Rightarrow>'N::euclidean_space" and g where "linear f" "linear g" "\<And>x. norm(f x) = norm x" "\<And>y. norm(g y) = norm y" "\<And>x. g (f x) = x" "\<And>y. f(g y) = y" Informal statement is: If two Euclidean spaces have the same dimension, then there exists a linear isomorphism between them.
Formal statement is: lemma enum_inj: "i \<le> n \<Longrightarrow> j \<le> n \<Longrightarrow> enum i = enum j \<longleftrightarrow> i = j" Informal statement is: If $i$ and $j$ are natural numbers less than or equal to $n$, then $enum(i) = enum(j)$ if and only if $i = j$.
Formal statement is: corollary open_bijective_linear_image_eq: fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space" assumes "linear f" "bij f" shows "open(f ` A) \<longleftrightarrow> open A" Informal statement is: If $f$ is a linear bijection, then $f$ maps open sets to open sets.
module DepSec.Labeled import public DepSec.DIO import public DepSec.Poset %access public export ||| Labeled value ||| @ label label ||| @ valueType type of labeled value data Labeled : (label : labelType) -> (valueType : Type) -> Type where ||| TCB MkLabeled : valueType -> Labeled label valueType ||| Label a value ||| @ value value to label label : Poset labelType => {l : labelType} -> (value : a) -> Labeled l a label = MkLabeled ||| Upgrade the security level of a labeled value ||| @ flow evidence that l may flow to l' ||| @ labeled labeled value to relabel relabel : Poset labelType => {l, l' : labelType} -> {auto flow : l `leq` l'} -> (labeled : Labeled l a) -> Labeled l' a relabel (MkLabeled x) = MkLabeled x ||| Unlabel a labeled value ||| @ flow evidence that l may flow to l' ||| @ labeled labeled value to unlabel unlabel : Poset labelType => {l,l' : labelType} -> {auto flow : l `leq` l'} -> (labeled : Labeled l a) -> DIO l' a unlabel (MkLabeled val) = pure val ||| Unlabel a labeled value while retaining a proof of relationship ||| @ flow evidence that l may flow to l' ||| @ labeled labeled value to unlabel unlabel' : Poset labelType => {l,l' : labelType} -> {auto flow : l `leq` l'} -> (labeled : Labeled l a) -> DIO l' (c : a ** label c = labeled) unlabel' (MkLabeled x) = pure (x ** Refl) ||| Plug a secure computation into a less secure computation ||| @ flow evidence that l may flow to l' ||| @ dio secure computation to plug plug : Poset labelType => {l,l' : labelType} -> (dio : DIO l' a) -> {auto flow : l `leq` l'} -> DIO l (Labeled l' a) plug dio = lift . run $ dio >>= pure . MkLabeled
[STATEMENT] lemma rat_of_int_div_dvd: "d dvd n \<Longrightarrow> rat_of_int (n div d) = rat_of_int n / rat_of_int d" [PROOF STATE] proof (prove) goal (1 subgoal): 1. d dvd n \<Longrightarrow> rat_of_int (n div d) = rat_of_int n / rat_of_int d [PROOF STEP] by auto
lemma Janiszewski_weak: fixes a b::complex assumes "compact S" "compact T" and conST: "connected(S \<inter> T)" and ccS: "connected_component (- S) a b" and ccT: "connected_component (- T) a b" shows "connected_component (- (S \<union> T)) a b"
(* Author: Tobias Nipkow (based on Hauke Brinkop's tree proofs) *) subsection \<open>Okasaki's Pairing Heap\<close> theory Pairing_Heap_List1_Analysis imports Pairing_Heap.Pairing_Heap_List1 Amortized_Framework Priority_Queue_ops_merge Lemmas_log begin text \<open>Amortized analysis of pairing heaps as defined by Okasaki \<^cite>\<open>"Okasaki"\<close>.\<close> fun hps where "hps (Hp _ hs) = hs" lemma merge_Empty[simp]: "merge heap.Empty h = h" by(cases h) auto lemma merge2: "merge (Hp x lx) h = (case h of heap.Empty \<Rightarrow> Hp x lx | (Hp y ly) \<Rightarrow> (if x < y then Hp x (Hp y ly # lx) else Hp y (Hp x lx # ly)))" by(auto split: heap.split) lemma pass1_Nil_iff: "pass\<^sub>1 hs = [] \<longleftrightarrow> hs = []" by(cases hs rule: pass\<^sub>1.cases) auto subsubsection \<open>Invariant\<close> fun no_Empty :: "'a :: linorder heap \<Rightarrow> bool" where "no_Empty heap.Empty = False" | "no_Empty (Hp x hs) = (\<forall>h \<in> set hs. no_Empty h)" abbreviation no_Emptys :: "'a :: linorder heap list \<Rightarrow> bool" where "no_Emptys hs \<equiv> \<forall>h \<in> set hs. no_Empty h" fun is_root :: "'a :: linorder heap \<Rightarrow> bool" where "is_root heap.Empty = True" | "is_root (Hp x hs) = no_Emptys hs" lemma is_root_if_no_Empty: "no_Empty h \<Longrightarrow> is_root h" by(cases h) auto lemma no_Emptys_hps: "no_Empty h \<Longrightarrow> no_Emptys(hps h)" by(induction h) auto lemma no_Empty_merge: "\<lbrakk> no_Empty h1; no_Empty h2\<rbrakk> \<Longrightarrow> no_Empty (merge h1 h2)" by (cases "(h1,h2)" rule: merge.cases) auto lemma is_root_merge: "\<lbrakk> is_root h1; is_root h2\<rbrakk> \<Longrightarrow> is_root (merge h1 h2)" by (cases "(h1,h2)" rule: merge.cases) auto lemma no_Emptys_pass1: "no_Emptys hs \<Longrightarrow> no_Emptys (pass\<^sub>1 hs)" by(induction hs rule: pass\<^sub>1.induct)(auto simp: no_Empty_merge) lemma is_root_pass2: "no_Emptys hs \<Longrightarrow> is_root(pass\<^sub>2 hs)" proof(induction hs) case (Cons _ hs) show ?case proof cases assume "hs = []" thus ?thesis using Cons by (auto simp: is_root_if_no_Empty) next assume "hs \<noteq> []" thus ?thesis using Cons by(auto simp: is_root_merge is_root_if_no_Empty) qed qed simp subsubsection \<open>Complexity\<close> fun size_hp :: "'a heap \<Rightarrow> nat" where "size_hp heap.Empty = 0" | "size_hp (Hp x hs) = sum_list(map size_hp hs) + 1" abbreviation size_hps where "size_hps hs \<equiv> sum_list(map size_hp hs)" fun \<Phi>_hps :: "'a heap list \<Rightarrow> real" where "\<Phi>_hps [] = 0" | "\<Phi>_hps (heap.Empty # hs) = \<Phi>_hps hs" | "\<Phi>_hps (Hp x hsl # hsr) = \<Phi>_hps hsl + \<Phi>_hps hsr + log 2 (size_hps hsl + size_hps hsr + 1)" fun \<Phi> :: "'a heap \<Rightarrow> real" where "\<Phi> heap.Empty = 0" | "\<Phi> (Hp _ hs) = \<Phi>_hps hs + log 2 (size_hps(hs)+1)" lemma \<Phi>_hps_ge0: "\<Phi>_hps hs \<ge> 0" by (induction hs rule: \<Phi>_hps.induct) auto lemma no_Empty_ge0: "no_Empty h \<Longrightarrow> size_hp h > 0" by(cases h) auto declare algebra_simps[simp] lemma \<Phi>_hps1: "\<Phi>_hps [h] = \<Phi> h" by(cases h) auto lemma size_hp_merge: "size_hp(merge h1 h2) = size_hp h1 + size_hp h2" by (induction h1 h2 rule: merge.induct) simp_all lemma pass\<^sub>1_size[simp]: "size_hps (pass\<^sub>1 hs) = size_hps hs" by (induct hs rule: pass\<^sub>1.induct) (simp_all add: size_hp_merge) lemma \<Delta>\<Phi>_insert: "\<Phi> (Pairing_Heap_List1.insert x h) - \<Phi> h \<le> log 2 (size_hp h + 1)" by(cases h)(auto simp: size_hp_merge) lemma \<Delta>\<Phi>_merge: "\<Phi> (merge h1 h2) - \<Phi> h1 - \<Phi> h2 \<le> log 2 (size_hp h1 + size_hp h2 + 1) + 1" proof(induction h1 h2 rule: merge.induct) case (3 x lx y ly) thus ?case using ld_le_2ld[of "size_hps lx" "size_hps ly"] log_le_cancel_iff[of 2 "size_hps lx + size_hps ly + 2" "size_hps lx + size_hps ly + 3"] by (auto simp del: log_le_cancel_iff) qed auto fun sum_ub :: "'a heap list \<Rightarrow> real" where "sum_ub [] = 0" | "sum_ub [_] = 0" | "sum_ub [h1, h2] = 2*log 2 (size_hp h1 + size_hp h2)" | "sum_ub (h1 # h2 # hs) = 2*log 2 (size_hp h1 + size_hp h2 + size_hps hs) - 2*log 2 (size_hps hs) - 2 + sum_ub hs" lemma \<Delta>\<Phi>_pass1_sum_ub: "no_Emptys hs \<Longrightarrow> \<Phi>_hps (pass\<^sub>1 hs) - \<Phi>_hps hs \<le> sum_ub hs" (is "_ \<Longrightarrow> ?P hs") proof (induction hs rule: sum_ub.induct) case (3 h1 h2) then obtain x hsx y hsy where [simp]: "h1 = Hp x hsx" "h2 = Hp y hsy" by simp (meson no_Empty.elims(2)) have 0: "\<And>x y::real. 0 \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> x \<le> 2*y" by linarith show ?case using 3 by (auto simp add: add_increasing 0) next case (4 h1 h2 h3 hs) hence IH: "?P(h3#hs)" by auto from "4.prems" obtain x hsx y hsy where [simp]: "h1 = Hp x hsx" "h2 = Hp y hsy" by simp (meson no_Empty.elims(2)) from "4.prems" have s3: "size_hp h3 > 0" apply auto using size_hp.elims by force let ?ry = "h3 # hs" let ?rx = "Hp y hsy # ?ry" let ?h = "Hp x hsx # ?rx" have "\<Phi>_hps(pass\<^sub>1 ?h) - \<Phi>_hps ?h \<le> log 2 (1 + size_hps hsx + size_hps hsy) - log 2 (1 + size_hps hsy + size_hps ?ry) + sum_ub ?ry" using IH by simp also have "log 2 (1 + size_hps hsx + size_hps hsy) - log 2 (1 + size_hps hsy + size_hps ?ry) \<le> 2*log 2 (size_hps ?h) - 2*log 2 (size_hps ?ry) - 2" proof - have "log 2 (1 + size_hps hsx + size_hps hsy) + log 2 (size_hps ?ry) - 2*log 2 (size_hps ?h) = log 2 ((1 + size_hps hsx + size_hps hsy)/(size_hps ?h) ) + log 2 (size_hps ?ry / size_hps ?h)" using s3 by (simp add: log_divide) also have "\<dots> \<le> -2" proof - have "2 + \<dots> \<le> 2*log 2 ((1 + size_hps hsx + size_hps hsy) / size_hps ?h + size_hps ?ry / size_hps ?h)" using ld_sum_inequality [of "(1 + size_hps hsx + size_hps hsy) / size_hps ?h" "(size_hps ?ry / size_hps ?h)"] using s3 by simp also have "\<dots> \<le> 0" by (simp add: field_simps log_divide add_pos_nonneg) finally show ?thesis by linarith qed finally have "log 2 (1 + size_hps hsx + size_hps hsy) + log 2 (size_hps ?ry) + 2 \<le> 2*log 2 (size_hps ?h)" by simp moreover have "log 2 (size_hps ?ry) \<le> log 2 (size_hps ?rx)" using s3 by simp ultimately have "log 2 (1 + size_hps hsx + size_hps hsy) - \<dots> \<le> 2*log 2 (size_hps ?h) - 2*log 2 (size_hps ?ry) - 2" by linarith thus ?thesis by simp qed finally show ?case by (simp) qed simp_all lemma \<Delta>\<Phi>_pass1: assumes "hs \<noteq> []" "no_Emptys hs" shows "\<Phi>_hps (pass\<^sub>1 hs) - \<Phi>_hps hs \<le> 2 * log 2 (size_hps hs) - length hs + 2" proof - have "sum_ub hs \<le> 2 * log 2 (size_hps hs) - length hs + 2" using assms by (induct hs rule: sum_ub.induct) (auto dest: no_Empty_ge0) thus ?thesis using \<Delta>\<Phi>_pass1_sum_ub[OF assms(2)] by linarith qed lemma \<Delta>\<Phi>_pass2: "hs \<noteq> [] \<Longrightarrow> no_Emptys hs \<Longrightarrow> \<Phi> (pass\<^sub>2 hs) - \<Phi>_hps hs \<le> log 2 (size_hps hs)" proof (induction hs) case (Cons h hs) thus ?case proof cases assume "hs = []" thus ?thesis using Cons by (auto simp add: \<Phi>_hps1 dest: no_Empty_ge0) next assume *: "hs \<noteq> []" obtain x hs2 where [simp]: "h = Hp x hs2" using Cons.prems(2)by simp (meson no_Empty.elims(2)) show ?thesis proof (cases "pass\<^sub>2 hs") case Empty thus ?thesis using \<Phi>_hps_ge0[of hs] by(simp add: add_increasing xt1(3)[OF mult_2, OF add_increasing]) next case (Hp y hs3) with Cons * size_hps_pass2[of hs] show ?thesis by(auto simp: add_mono) qed qed qed simp lemma \<Delta>\<Phi>_del_min: assumes "hps h \<noteq> []" "no_Empty h" shows "\<Phi> (del_min h) - \<Phi> h \<le> 3 * log 2 (size_hps(hps h)) - length(hps h) + 2" proof - obtain x hs where [simp]: "h = Hp x hs" using assms(2) by (cases h) auto let ?\<Delta>\<Phi>\<^sub>1 = "\<Phi>_hps(hps h) - \<Phi> h" let ?\<Delta>\<Phi>\<^sub>2 = "\<Phi>(pass\<^sub>2(pass\<^sub>1 (hps h))) - \<Phi>_hps (hps h)" let ?\<Delta>\<Phi> = "\<Phi> (del_min h) - \<Phi> h" have "\<Phi>(pass\<^sub>2(pass\<^sub>1(hps h))) - \<Phi>_hps (pass\<^sub>1(hps h)) \<le> log 2 (size_hps(hps h))" using \<Delta>\<Phi>_pass2[of "pass\<^sub>1(hps h)"] using assms by (auto simp: pass1_Nil_iff no_Emptys_pass1 dest: no_Emptys_hps) moreover have "\<Phi>_hps (pass\<^sub>1 (hps h)) - \<Phi>_hps (hps h) \<le> 2*\<dots> - length (hps h) + 2" using \<Delta>\<Phi>_pass1[OF assms(1) no_Emptys_hps[OF assms(2)]] by blast moreover have "?\<Delta>\<Phi>\<^sub>1 \<le> 0" by simp moreover have "?\<Delta>\<Phi> = ?\<Delta>\<Phi>\<^sub>1 + ?\<Delta>\<Phi>\<^sub>2" by simp ultimately show ?thesis by linarith qed fun exec :: "'a :: linorder op \<Rightarrow> 'a heap list \<Rightarrow> 'a heap" where "exec Empty [] = heap.Empty" | "exec Del_min [h] = del_min h" | "exec (Insert x) [h] = Pairing_Heap_List1.insert x h" | "exec Merge [h1,h2] = merge h1 h2" fun T\<^sub>p\<^sub>a\<^sub>s\<^sub>s\<^sub>1 :: "'a heap list \<Rightarrow> nat" where "T\<^sub>p\<^sub>a\<^sub>s\<^sub>s\<^sub>1 [] = 1" | "T\<^sub>p\<^sub>a\<^sub>s\<^sub>s\<^sub>1 [_] = 1" | "T\<^sub>p\<^sub>a\<^sub>s\<^sub>s\<^sub>1 (_ # _ # hs) = 1 + T\<^sub>p\<^sub>a\<^sub>s\<^sub>s\<^sub>1 hs" fun T\<^sub>p\<^sub>a\<^sub>s\<^sub>s\<^sub>2 :: "'a heap list \<Rightarrow> nat" where "T\<^sub>p\<^sub>a\<^sub>s\<^sub>s\<^sub>2 [] = 1" | "T\<^sub>p\<^sub>a\<^sub>s\<^sub>s\<^sub>2 (_ # hs) = 1 + T\<^sub>p\<^sub>a\<^sub>s\<^sub>s\<^sub>2 hs" fun cost :: "'a :: linorder op \<Rightarrow> 'a heap list \<Rightarrow> nat" where "cost Empty _ = 1" | "cost Del_min [heap.Empty] = 1" | "cost Del_min [Hp x hs] = T\<^sub>p\<^sub>a\<^sub>s\<^sub>s\<^sub>2 (pass\<^sub>1 hs) + T\<^sub>p\<^sub>a\<^sub>s\<^sub>s\<^sub>1 hs" | "cost (Insert a) _ = 1" | "cost Merge _ = 1" fun U :: "'a :: linorder op \<Rightarrow> 'a heap list \<Rightarrow> real" where "U Empty _ = 1" | "U (Insert a) [h] = log 2 (size_hp h + 1) + 1" | "U Del_min [h] = 3*log 2 (size_hp h + 1) + 4" | "U Merge [h1,h2] = log 2 (size_hp h1 + size_hp h2 + 1) + 2" interpretation pairing: Amortized where arity = arity and exec = exec and cost = cost and inv = "is_root" and \<Phi> = \<Phi> and U = U proof (standard, goal_cases) case (1 ss f) show ?case proof (cases f) case Empty with 1 show ?thesis by simp next case Insert thus ?thesis using 1 by(auto simp: is_root_merge) next case Merge thus ?thesis using 1 by(auto simp: is_root_merge numeral_eq_Suc) next case [simp]: Del_min then obtain h where [simp]: "ss = [h]" using 1 by auto show ?thesis proof (cases h) case [simp]: (Hp _ hs) show ?thesis proof cases assume "hs = []" thus ?thesis by simp next assume "hs \<noteq> []" thus ?thesis using 1(1) no_Emptys_pass1 by (auto intro: is_root_pass2) qed qed simp qed next case (2 s) show ?case by (cases s) (auto simp: \<Phi>_hps_ge0) next case (3 ss f) show ?case proof (cases f) case Empty with 3 show ?thesis by(auto) next case Insert thus ?thesis using \<Delta>\<Phi>_insert 3 by auto next case [simp]: Del_min then obtain h where [simp]: "ss = [h]" using 3 by auto show ?thesis proof (cases h) case [simp]: (Hp x hs) have "T\<^sub>p\<^sub>a\<^sub>s\<^sub>s\<^sub>2 (pass\<^sub>1 hs) + T\<^sub>p\<^sub>a\<^sub>s\<^sub>s\<^sub>1 hs \<le> 2 + length hs" by (induct hs rule: pass\<^sub>1.induct) simp_all hence "cost f ss \<le> \<dots>" by simp moreover have "\<Phi> (del_min h) - \<Phi> h \<le> 3*log 2 (size_hp h + 1) - length hs + 2" proof (cases "hs = []") case False hence "\<Phi> (del_min h) - \<Phi> h \<le> 3*log 2 (size_hps hs) - length hs + 2" using \<Delta>\<Phi>_del_min[of h] 3(1) by simp also have "\<dots> \<le> 3*log 2 (size_hp h + 1) - length hs + 2" using False 3(1) size_hps_pass2 by fastforce finally show ?thesis . qed simp ultimately show ?thesis by simp qed simp next case [simp]: Merge then obtain h1 h2 where [simp]: "ss = [h1, h2]" using 3 by(auto simp: numeral_eq_Suc) show ?thesis proof (cases "h1 = heap.Empty \<or> h2 = heap.Empty") case True thus ?thesis by auto next case False then obtain x1 x2 hs1 hs2 where [simp]: "h1 = Hp x1 hs1" "h2 = Hp x2 hs2" by (meson hps.cases) have "\<Phi> (merge h1 h2) - \<Phi> h1 - \<Phi> h2 \<le> log 2 (size_hp h1 + size_hp h2 + 1) + 1" using \<Delta>\<Phi>_merge[of h1 h2] by simp thus ?thesis by(simp) qed qed qed end
lemma compact_components: fixes s :: "'a::heine_borel set" shows "\<lbrakk>compact s; c \<in> components s\<rbrakk> \<Longrightarrow> compact c"
Formal statement is: lemma isCont_inverse_function2: fixes f g :: "real \<Rightarrow> real" shows "\<lbrakk>a < x; x < b; \<And>z. \<lbrakk>a \<le> z; z \<le> b\<rbrakk> \<Longrightarrow> g (f z) = z; \<And>z. \<lbrakk>a \<le> z; z \<le> b\<rbrakk> \<Longrightarrow> isCont f z\<rbrakk> \<Longrightarrow> isCont g (f x)" Informal statement is: Suppose $f$ and $g$ are functions such that $g(f(x)) = x$ for all $x$ in the interval $(a,b)$. If $f$ is continuous at $x$, then $g$ is continuous at $f(x)$.
import algebra.homology.additive import category_theory.abelian.basic import category_theory.limits.constructions.epi_mono open category_theory category_theory.limits namespace homological_complex universes w' w v v' u u' variables {V : Type u} [category.{v} V] {J : Type w} [category.{w'} J] variables {ι : Type u'} {c : complex_shape ι} --move this lemma congr_f [has_zero_morphisms V] {X Y : homological_complex V c} {f g : X ⟶ Y} (h : f = g) (x : ι) : f.f x = g.f x := congr_arg _ h section limits noncomputable theory variables [has_zero_morphisms V] (F : J ⥤ homological_complex V c) include F @[simps] def lift_of_is_limit_eval (t : cone F) (h : ∀ i, is_limit $ (eval V c i).map_cone t) (s : cone F) : s.X ⟶ t.X := begin refine ⟨λ i, is_limit.lift (h i) ⟨_, _⟩, _⟩, refine ⟨λ x, (s.π.app x).f i, _⟩, { intros x y f, dsimp, rw [category.id_comp, ← comp_f], congr, exact (cone.w s f).symm }, { intros i j r, apply (h j).hom_ext, intro x, dsimp, rw [category.assoc, category.assoc], erw [← (t.π.app x).comm, (h j).fac _ x, (h i).fac_assoc _ x, (s.π.app x).comm], refl } end . /-- `eval` jointly reflects (actually creates) limits -/ def is_limit_of_is_limit_eval (t : cone F) (h : ∀ i, is_limit $ (eval V c i).map_cone t) : is_limit t := { lift := lift_of_is_limit_eval F t h, fac' := by { intros s j, ext, dsimp, exact (h x).fac _ j }, uniq' := by { intros s m w, ext, apply (h x).hom_ext, intro j, dsimp, erw (h x).fac _ j, exact congr_f (w j) x } } variables [∀ i : ι, has_limit (F ⋙ eval V c i)] @[simps] def limit_complex : homological_complex V c := begin refine ⟨λ i, limit (F ⋙ eval V c i), λ i j, limit.lift _ ⟨_, _⟩, _, _⟩, refine ⟨λ k, limit.π (F ⋙ eval V c i) k ≫ (F.obj k).d i j, _⟩, { intros x y f, dsimp, rw [category.id_comp, category.assoc, ← hom.comm, ← category.assoc], congr' 1, exact (limit.w _ _).symm }, { intros i j r, ext k, rw [limit.lift_π, zero_comp], dsimp only, rw [(F.obj k).shape _ _ r, comp_zero] }, { intros i j k r r', ext, simp } end . @[simps] def limit_complex_cone : cone F := { X := limit_complex F, π := { app := λ x, { f := λ i, limit.π (F ⋙ eval V c i) x }, naturality' := λ X Y f, by { ext, dsimp, rw category.id_comp, exact (limit.w _ _).symm } } } . def limit_complex_cone_is_limit : is_limit (limit_complex_cone F) := is_limit_of_is_limit_eval _ _ begin intro i, apply (limit.is_limit _).of_iso_limit, exact cones.ext (iso.refl _) (λ _, (category.id_comp _).symm), end def eval_map_limit_complex_cone (i : ι) : (eval V c i).map_cone (limit_complex_cone F) ≅ (get_limit_cone (F ⋙ eval V c i)).1 := cones.ext (iso.refl _) (λ j, by { dsimp, simpa }) instance (i : ι) : preserves_limit F (eval V c i) := preserves_limit_of_preserves_limit_cone (limit_complex_cone_is_limit F) ((limit.is_limit _).of_iso_limit (eval_map_limit_complex_cone F i).symm) instance : has_limit F := ⟨⟨⟨_, limit_complex_cone_is_limit F⟩⟩⟩ omit F instance [has_limits_of_shape J V] : has_limits_of_shape J (homological_complex V c) := {} instance [has_limits_of_size.{w' w} V] : has_limits_of_size.{w' w} (homological_complex V c) := ⟨⟩ instance [has_limits_of_shape J V] (i : ι) : preserves_limits_of_shape J (eval V c i) := {} instance [has_limits_of_size.{w' w} V] (i : ι) : preserves_limits_of_size.{w' w} (eval V c i) := {} end limits section colimits noncomputable theory variables [has_zero_morphisms V] (F : J ⥤ homological_complex V c) include F @[simps] def desc_of_is_colimit_eval (t : cocone F) (h : ∀ i, is_colimit $ (eval V c i).map_cocone t) (s : cocone F) : t.X ⟶ s.X := begin refine ⟨λ i, is_colimit.desc (h i) ⟨_, _⟩, _⟩, refine ⟨λ x, (s.ι.app x).f i, _⟩, { intros x y f, dsimp, rw [category.comp_id, ← comp_f], congr, exact cocone.w s f }, { intros i j r, apply (h i).hom_ext, intro x, dsimp, erw [(t.ι.app x).comm_assoc, (h j).fac _ x, (h i).fac_assoc _ x, (s.ι.app x).comm] } end . /-- `eval` jointly reflects (actually creates) colimits -/ def is_colimit_of_is_colimit_eval (t : cocone F) (h : ∀ i, is_colimit $ (eval V c i).map_cocone t) : is_colimit t := { desc := desc_of_is_colimit_eval F t h, fac' := by { intros s j, ext, dsimp, exact (h x).fac _ j }, uniq' := by { intros s m w, ext, apply (h x).hom_ext, intro j, dsimp, erw (h x).fac _ j, exact congr_f (w j) x } } variable [∀ i : ι, has_colimit (F ⋙ eval V c i)] @[simps] def colimit_complex : homological_complex V c := begin refine ⟨λ i, colimit (F ⋙ eval V c i), λ i j, colimit.desc _ ⟨_, _⟩, _, _⟩, refine ⟨λ x, (F.obj x).d i j ≫ colimit.ι (F ⋙ eval V c j) x, _⟩, { intros x y f, dsimp, rw [category.comp_id, hom.comm_assoc], congr' 1, exact colimit.w (F ⋙ eval V c j) _ }, { intros i j r, ext x, rw [colimit.ι_desc, comp_zero], dsimp only, rw [(F.obj x).shape _ _ r, zero_comp] }, { intros i j k r r', ext, simp } end . @[simps] def colimit_complex_cocone : cocone F := { X := colimit_complex F, ι := { app := λ x, { f := λ i, colimit.ι (F ⋙ eval V c i) x }, naturality' := λ X Y f, by { ext, dsimp, rw category.comp_id, exact colimit.w (F ⋙ eval V c x) _ } } } . def colimit_complex_cocone_is_colimit : is_colimit (colimit_complex_cocone F) := is_colimit_of_is_colimit_eval _ _ begin intro i, apply (colimit.is_colimit _).of_iso_colimit, exact cocones.ext (iso.refl _) (λ _, category.comp_id _), end . def eval_map_colimit_complex_cocone (i : ι) : (eval V c i).map_cocone (colimit_complex_cocone F) ≅ (get_colimit_cocone (F ⋙ eval V c i)).1 := cocones.ext (iso.refl _) (λ j, by { dsimp, simpa }) instance (i : ι) : preserves_colimit F (eval V c i) := preserves_colimit_of_preserves_colimit_cocone (colimit_complex_cocone_is_colimit F) ((colimit.is_colimit _).of_iso_colimit (eval_map_colimit_complex_cocone F i).symm) instance : has_colimit F := ⟨⟨⟨_, colimit_complex_cocone_is_colimit F⟩⟩⟩ omit F instance [has_colimits_of_shape J V] : has_colimits_of_shape J (homological_complex V c) := {} instance [has_colimits_of_size.{w' w} V] : has_colimits_of_size.{w' w} (homological_complex V c) := {} instance [has_colimits_of_shape J V] (i : ι) : preserves_colimits_of_shape J (eval V c i) := {} instance [has_colimits_of_size.{w' w} V] (i : ι) : preserves_colimits_of_size.{w' w} (eval V c i) := {} end colimits section biproduct variables [has_zero_morphisms V] [has_binary_biproducts V] {X Y Z : homological_complex V c} @[simps] def biproduct (X Y : homological_complex V c) : homological_complex V c := { X := λ i, X.X i ⊞ Y.X i, d := λ i j, biprod.map (X.d i j) (Y.d i j), shape' := λ i j r, by ext; simp [X.shape _ _ r, Y.shape _ _ r] } . @[simps] def biproduct.inl : X ⟶ biproduct X Y := { f := λ i, biprod.inl } @[simps] def biproduct.inr : Y ⟶ biproduct X Y := { f := λ i, biprod.inr } @[simps] def biproduct.fst : biproduct X Y ⟶ X := { f := λ i, biprod.fst } @[simps] def biproduct.snd : biproduct X Y ⟶ Y := { f := λ i, biprod.snd } @[simps] def biproduct.lift (f : X ⟶ Y) (g : X ⟶ Z) : X ⟶ biproduct Y Z := { f := λ i, biprod.lift (f.f i) (g.f i) } @[simps] def biproduct.desc (f : X ⟶ Z) (g : Y ⟶ Z) : biproduct X Y ⟶ Z := { f := λ i, biprod.desc (f.f i) (g.f i) } . variables (X Y) @[simps] def biproduct_bicone : binary_bicone X Y := { X := biproduct X Y, fst := biproduct.fst, snd := biproduct.snd, inl := biproduct.inl, inr := biproduct.inr } . local attribute [tidy] tactic.case_bash def biproduct_bicone_is_prod : is_limit (biproduct_bicone X Y).to_cone := { lift := λ (Z : binary_fan _ _), biproduct.lift Z.fst Z.snd, uniq' := by { intros, delta binary_fan.fst binary_fan.snd, ext; simp [← w] } } . def biproduct_bicone_is_coprod : is_colimit (biproduct_bicone X Y).to_cocone := { desc := λ (Z : binary_cofan _ _), biproduct.desc Z.inl Z.inr, uniq' := by { intros, delta binary_cofan.inl binary_cofan.inr, ext; simp [← w] } } . def biproduct_is_biprod : binary_biproduct_data X Y := { bicone := biproduct_bicone X Y, is_bilimit := ⟨biproduct_bicone_is_prod X Y, biproduct_bicone_is_coprod X Y⟩ } instance : has_binary_biproducts (homological_complex V c) := ⟨λ X Y, ⟨⟨biproduct_is_biprod X Y⟩⟩⟩ end biproduct instance [has_zero_morphisms V] [has_finite_products V] : has_finite_products (homological_complex V c) := ⟨λ J _, by exactI infer_instance⟩ -- instance [has_zero_morphisms V] [has_kernels V] : has_kernels (homological_complex V c) := -- begin -- constructor, -- intros X Y f, -- apply_with homological_complex.category_theory.limits.has_limit { instances := ff }, -- intro i, -- let : walking_parallel_pair_op_equiv.{v v}.functor ⋙ walking_parallel_pair_op_equiv.inverse ⋙ -- parallel_pair f 0 ⋙ eval V c i ≅ parallel_pair (f.f i) 0 := -- nat_iso.of_components (λ i, eq_to_iso $ by cases i; refl) -- (by { rintros _ _ (_|_|_); dsimp; simp }), -- have := has_limit_of_iso this.symm, -- exact @@has_limit_of_equivalence_comp _ _ _ -- (walking_parallel_pair_op_equiv.{v v}.trans walking_parallel_pair_op_equiv.symm) this -- end -- instance [has_zero_morphisms V] [has_cokernels V] : -- has_cokernels (homological_complex V c) := -- begin -- constructor, -- intros X Y f, -- apply_with homological_complex.category_theory.limits.has_colimit { instances := ff }, -- intro i, -- let : walking_parallel_pair_op_equiv.{v v}.functor ⋙ walking_parallel_pair_op_equiv.inverse ⋙ -- parallel_pair f 0 ⋙ eval V c i ≅ parallel_pair (f.f i) 0 := -- nat_iso.of_components (λ i, eq_to_iso $ by cases i; refl) -- (by { rintros _ _ (_|_|_); dsimp; simp }), -- have := has_colimit_of_iso this, -- exact @@has_colimit_of_equivalence_comp _ _ _ -- (walking_parallel_pair_op_equiv.{v v}.trans walking_parallel_pair_op_equiv.symm) this -- end section kernel variables [has_zero_morphisms V] {X Y : homological_complex V c} variables (f : X ⟶ Y) [∀ i, has_kernel (f.f i)] @[simps] def kernel_complex : homological_complex V c := { X := λ i, kernel (f.f i), d := λ i j, kernel.map _ _ _ _ (f.comm i j), shape' := by { introv r, ext, simp [X.shape _ _ r] } } . @[simps] def kernel_complex_ι : kernel_complex f ⟶ X := { f := λ i, kernel.ι (f.f i) } . @[simps] def kernel_complex_fork : kernel_fork f := kernel_fork.of_ι (kernel_complex_ι f) (by { ext, simp }) . @[simps] def kernel_complex_lift (s : kernel_fork f) : s.X ⟶ kernel_complex f := { f := λ i, kernel.lift _ (s.ι.f i) (by { rw [← comp_f, kernel_fork.condition], refl }) } def kernel_complex_is_kernel : is_limit (kernel_complex_fork f) := begin apply is_limit_aux (kernel_complex_fork f) (kernel_complex_lift f), { intro s, ext, delta fork.ι, dsimp, simp only [kernel.lift_ι] }, { intros s m h, ext, apply_fun (λ f, hom.f f x) at h, delta fork.ι at h, dsimp at h ⊢, simp [h, kernel.lift_ι] } end . instance : has_kernel f := ⟨⟨⟨_, kernel_complex_is_kernel f⟩⟩⟩ instance [has_kernels V] : has_kernels (homological_complex V c) := {} . end kernel section cokernel variables [has_zero_morphisms V] {X Y : homological_complex V c} variables (f : X ⟶ Y) [∀ i, has_cokernel (f.f i)] @[simps] def cokernel_complex : homological_complex V c := { X := λ i, cokernel (f.f i), d := λ i j, cokernel.map _ _ _ _ (f.comm i j), shape' := by { introv r, ext, simp [Y.shape _ _ r] } } . @[simps] def cokernel_complex_π : Y ⟶ cokernel_complex f := { f := λ i, cokernel.π (f.f i) } . @[simps] def cokernel_complex_cofork : cokernel_cofork f := cokernel_cofork.of_π (cokernel_complex_π f) (by { ext, simp }) . @[simps] def cokernel_complex_desc (s : cokernel_cofork f) : cokernel_complex f ⟶ s.X := { f := λ i, cokernel.desc _ (s.π.f i) (by { rw [← comp_f, cokernel_cofork.condition], refl }) } def cokernel_complex_is_cokernel : is_colimit (cokernel_complex_cofork f) := begin apply is_colimit_aux (cokernel_complex_cofork f) (cokernel_complex_desc f), { intro s, ext, delta cofork.π, dsimp, simp only [cokernel.π_desc] }, { intros s m h, ext, apply_fun (λ f, hom.f f x) at h, delta cofork.π at h, dsimp at h ⊢, simp only [h, cokernel.π_desc] } end . instance : has_cokernel f := ⟨⟨⟨_, cokernel_complex_is_cokernel f⟩⟩⟩ instance [has_cokernels V] : has_cokernels (homological_complex V c) := {} . end cokernel section normal_mono variables [abelian V] {X Y Z : homological_complex V c} variables (f : X ⟶ Y) def is_kernel_of_eval (g : Y ⟶ Z) (w : f ≫ g = 0) (h : ∀ i, is_limit (kernel_fork.of_ι (f.f i) (congr_f w i))) : is_limit (kernel_fork.of_ι f w) := begin refine is_limit.of_iso_limit (kernel_complex_is_kernel g) _, fapply cones.ext, fapply hom.iso_of_components, intro i, exact limit.iso_limit_cone ⟨_, h i⟩, { intros i j r, dsimp, rw [← iso.comp_inv_eq, category.assoc, ← iso.eq_inv_comp], ext, simp }, { rintro (_|_), { ext, dsimp, rw ← iso.inv_comp_eq, simp }, { ext, dsimp, simp [(show f.f x ≫ g.f x = _, from congr_f w x)] } } end def is_cokernel_of_eval (g : Y ⟶ Z) (w : f ≫ g = 0) (h : ∀ i, is_colimit (cokernel_cofork.of_π (g.f i) (congr_f w i))) : is_colimit (cokernel_cofork.of_π g w) := begin refine is_colimit.of_iso_colimit (cokernel_complex_is_cokernel f) _, fapply cocones.ext, fapply hom.iso_of_components, intro i, exact colimit.iso_colimit_cocone ⟨_, h i⟩, { intros i j r, ext, dsimp, simp }, { rintro (_|_), { ext, dsimp, simpa using (congr_arg (λ f, hom.f f x) w).symm }, { ext, dsimp, simp } } end . instance [mono f] (i : ι) : mono (f.f i) := begin change mono ((eval V c i).map f), apply_instance end lemma mono_of_eval [∀ i, mono (f.f i)] : mono f := begin constructor, intros Z g h r, ext i, rw ← cancel_mono (f.f i), exact congr_f r i end lemma mono_iff_eval : mono f ↔ ∀ i, mono (f.f i) := ⟨λ _ i, by exactI infer_instance, λ _, by exactI mono_of_eval f⟩ instance [epi f] (i : ι) : epi (f.f i) := begin change epi ((eval V c i).map f), apply_instance end lemma epi_of_eval [∀ i, epi (f.f i)] : epi f := begin constructor, intros Z g h r, ext i, rw ← cancel_epi (f.f i), exact congr_f r i end lemma epi_iff_eval : epi f ↔ ∀ i, epi (f.f i) := ⟨λ _ i, by exactI infer_instance, λ _, by exactI epi_of_eval f⟩ def normal_mono [mono f] : normal_mono f := { Z := cokernel_complex f, g := cokernel_complex_π f, w := by { ext, simp }, is_limit := begin apply is_kernel_of_eval, intro i, exact abelian.mono_is_kernel_of_cokernel _ (colimit.is_colimit _) end } def normal_epi [epi f] : normal_epi f := { W := kernel_complex f, g := kernel_complex_ι f, w := by { ext, simp }, is_colimit := begin apply is_cokernel_of_eval, intro i, exact abelian.epi_is_cokernel_of_kernel _ (limit.is_limit _) end } . end normal_mono instance [abelian V] : abelian (homological_complex V c) := { normal_mono_of_mono := λ _ _, normal_mono, normal_epi_of_epi := λ _ _, normal_epi } end homological_complex
[STATEMENT] lemma all_tuples_setD: "vs \<in> all_tuples xs n \<Longrightarrow> set vs \<subseteq> xs" [PROOF STATE] proof (prove) goal (1 subgoal): 1. vs \<in> all_tuples xs n \<Longrightarrow> set vs \<subseteq> xs [PROOF STEP] by (auto dest: all_tuplesD)
/- Copyright (c) 2022 Joël Riou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joël Riou -/ import category_theory.comma import category_theory.arrow import category_theory.opposites import category_theory.limits.shapes.binary_products open category_theory open category_theory.category open category_theory.limits open opposite namespace category_theory universes v₁ v₂ v₃ u₁ u₂ u₃ variables {A : Type u₁} [category.{v₁} A] variables {B : Type u₂} [category.{v₂} B] variables {T : Type u₃} [category.{v₃} T] @[simps] def functor_comma_op (L : A ⥤ T) (R : B ⥤ T) : (comma L R)ᵒᵖ ⥤ comma R.op L.op := { obj := λ X, { left := op X.unop.right, right := op X.unop.left, hom := X.unop.hom.op, }, map := λ X Y f, { left := f.unop.right.op, right := f.unop.left.op, w' := by { apply quiver.hom.unop_inj, exact f.unop.w'.symm, }, }, } @[simps] def functor_comma_unop (L : A ⥤ T) (R : B ⥤ T) : comma R.op L.op ⥤ (comma L R)ᵒᵖ := { obj := λ X, op { left := X.right.unop, right := X.left.unop, hom := X.hom.unop, }, map := λ X Y f, quiver.hom.op { left := f.right.unop, right := f.left.unop, w' := by { apply quiver.hom.op_inj, exact f.w'.symm, }, } } @[simps] def equivalence_comma_op (L : A ⥤ T) (R : B ⥤ T) : (comma L R)ᵒᵖ ≌ comma R.op L.op := { functor := functor_comma_op L R, inverse := functor_comma_unop L R, unit_iso := eq_to_iso begin apply functor.ext, { intros X Y f, apply quiver.hom.unop_inj, apply comma_morphism.ext, tidy, }, { intro X, rw ← op_unop X, generalize : X.unop = Y, cases Y, refl, } end, counit_iso := eq_to_iso begin apply functor.ext, { tidy, }, { intro X, cases X, refl, } end, functor_unit_iso_comp' := by tidy, } variable (T) @[simps] def equivalence_arrow_op : (arrow T)ᵒᵖ ≌ arrow Tᵒᵖ := equivalence_comma_op (𝟭 T) (𝟭 T) variable {T} namespace arrow @[simp, protected] def op (f : arrow T) : arrow Tᵒᵖ := ((equivalence_arrow_op T).functor.obj (op f)) @[simp, protected] def unop (f : arrow Tᵒᵖ) : arrow T := ((equivalence_arrow_op T).inverse.obj f).unop lemma unop_op (f : arrow T) : f.op.unop = f := by { cases f, refl, } lemma op_unop (f : arrow Tᵒᵖ) : f.unop.op = f := by { cases f, refl, } end arrow /-#exit lemma mk_eq (f : arrow T) : arrow.mk f.hom = f := by { cases f, dsimp [arrow.mk], refl, } def op_hom {f g : arrow T} (sq : f ⟶ g) : g.op ⟶ f.op := ((equivalence_arrow_op T).functor.map sq).unop def unop_hom' {f g : arrow Tᵒᵖ} (sq : f ⟶ g) : g.unop ⟶ f.unop := ((equivalence_arrow_op T).inverse.map sq.op) def unop_hom {f g : arrow T} (sq : f.op ⟶ g.op) : g ⟶ f := eq_to_hom g.unop_op.symm ≫ unop_hom' sq ≫ eq_to_hom f.unop_op def op_unop_hom {f g : arrow T} (sq : f.op ⟶ g.op) : sq = op_hom (unop_hom sq) := begin cases f, cases g, cases sq, dsimp only [unop_hom], erw [id_comp, comp_id], congr, end end arrow-/ end category_theory
#' guitar #' #' @name guitar #' @docType package NULL
clump<-function(dat, window = 5000, thres1 = 1e-7, thres2 = 5e-5, listProbes = TRUE){ #' takes all significant association less than thres1 in order of significance as an index site and identifies all other associations within specified window less than thres2. If a less significant probe is clumped with a more significant probe it is excluded for consideration as an index site. #' #' @param dat A matrix with the columns ids, pval, chr and pos, #' @param window Distance in bp of region around site to look for other sinificant associations. #' @param thres1 P value threshold to select significant sites to clump. #' @param thres2 P value threshold to select additional sites to clump with site under consideration #' @return a ma tmp<-dat[order(dat$pval),] out<-NULL while(tmp[1,2] < thres1){ chrom<-tmp[1,3] start<-tmp[1,4]-window end<-tmp[1,4]+window index<-which(tmp$chr == chrom & tmp$pos <= end & tmp$pos >= start & tmp$pos != tmp[1,4]) ## remove self from consideration n.sig<-length(which(tmp[index,2] < thres2)) if(n.sig > 0){ probes<-tmp[index,1][which(tmp[index,2] < thres2)] if(n.sig > 1){ probes<-paste(probes, collapse = ";") } } else { probes<-NA } out<-rbind(out, c(unlist(tmp[1,]), length(index), n.sig, probes)) ## remove these probes from furture consideration tmp<-tmp[-c(1,index),] } colnames(out)<-c("Index", "Pvalue", "Chr", "Position", "nSitesinWindow", "nSigSites", "SigDNAmSites") return(out) }
lemma open_translation: fixes S :: "'a::real_normed_vector set" assumes "open S" shows "open((\<lambda>x. a + x) ` S)"
Formal statement is: lemma path_polynomial_function: fixes g :: "real \<Rightarrow> 'b::euclidean_space" shows "polynomial_function g \<Longrightarrow> path g" Informal statement is: If $g$ is a polynomial function, then $g$ is a path.
module Vsurfac11 use Vmeshes real(rprec), dimension(:), allocatable :: x1v, y1v, z1v end module Vsurfac11
Formal statement is: lemma continuous_at_Sup_antimono: fixes f :: "'a::{linorder_topology,conditionally_complete_linorder} \<Rightarrow> 'b::{linorder_topology,conditionally_complete_linorder}" assumes "antimono f" and cont: "continuous (at_left (Sup S)) f" and S: "S \<noteq> {}" "bdd_above S" shows "f (Sup S) = (INF s\<in>S. f s)" Informal statement is: If $f$ is an antimonotone function and $f$ is continuous at the supremum of a nonempty bounded set $S$, then $f$ attains its minimum at the supremum of $S$.
{-# OPTIONS --without-K #-} open import HoTT.Base open import HoTT.Equivalence module HoTT.Identity.Boolean where private variable x y : 𝟐 _=𝟐_ : 𝟐 → 𝟐 → 𝒰₀ 0₂ =𝟐 0₂ = 𝟏 0₂ =𝟐 1₂ = 𝟎 1₂ =𝟐 0₂ = 𝟎 1₂ =𝟐 1₂ = 𝟏 =𝟐-equiv : x == y ≃ x =𝟐 y =𝟐-equiv = f , qinv→isequiv (g , η , ε) where f : x == y → x =𝟐 y f {0₂} p = transport (0₂ =𝟐_) p ★ f {1₂} p = transport (1₂ =𝟐_) p ★ g : x =𝟐 y → x == y g {0₂} {0₂} _ = refl g {0₂} {1₂} () g {1₂} {0₂} () g {1₂} {1₂} _ = refl η : g ∘ f {x} {y} ~ id η {0₂} refl = refl η {1₂} refl = refl ε : f ∘ g {x} {y} ~ id ε {0₂} {0₂} ★ = refl ε {0₂} {1₂} () ε {1₂} {0₂} () ε {1₂} {1₂} ★ = refl
{-# OPTIONS --cubical-compatible #-} open import Common.Prelude open import Common.Equality KNat : {x : Nat} (e : x ≡ x) → e ≡ refl KNat refl = refl KEqNat : {x : Nat} {e : x ≡ x} (p : e ≡ e) → p ≡ refl KEqNat refl = refl KListNat : {x : List Nat} (e : x ≡ x) → e ≡ refl KListNat refl = refl data D (A : Set) : Nat → Set where c : (x : A)(y : Nat) → D A y -- Jesper 2015-12-18: this test case doesn't work yet with the new unifier -- We need generalization of indices when applying the injectivity rule --test : {A : Set} {x₁ x₂ : A} {y : Nat} → c x₁ y ≡ c x₂ y → Set --test refl = Nat
Suppose $f$ is a holomorphic function on an open set $S$, and $\xi \in S$. If $(\xi, f(\xi))$ is a zero of order $n$ of $f$, then there exists a holomorphic function $g$ and a positive real number $r$ such that for all $w \in B(\xi, r)$, we have $f(w) - f(\xi) = (w - \xi)^n g(w)$ and $g(w) \neq 0$.
import algebraic_topology.simplex_category import algebraic_topology.simplicial_object import algebraic_topology.nerve import category_theory.category.basic import category_theory.functor.basic import data.finset.basic import data.fin.basic import data.nat.basic import tactic open category_theory open finset structure finset_hom {n : nat} (x y : fin n) := mk :: (eps : nat) (H : (x.val + eps = y.val)) instance (n : nat) : category (fin n) := by refine { hom := finset_hom, id := λ n, finset_hom.mk 0 rfl, comp := begin intros X Y Z f g, apply finset_hom.mk (f.eps + g.eps), rw ← add_assoc, rw f.H, rw g.H, end, id_comp' := begin intros, unfold category_struct.id, unfold category_struct.comp, simp, destruct f, simp, intros, rw a, end, comp_id' := begin intros, unfold category_struct.id, unfold category_struct.comp, simp, destruct f, simp, intros, rw a, end, assoc' := begin intros, unfold category_struct.comp, simp, rw add_assoc, end } class monotone_function {n m : ℕ} (f : (fin n) → (fin m)) : Prop := (monotone : ∀ (x y : fin n), (x ≤ y) → ((f x) ≤ (f y))) def coface {n} (i : fin (n + 1)) : fin n → fin (n + 1) := λ x, if x.cast_succ < i then x.cast_succ else x.succ -- lemma coface_monotone {n : ℕ} (i : fin $ n + 1) : monotone (coface i) := begin -- end instance {n : ℕ} (i : fin (n + 1)) : monotone_function (coface i) := by refine { monotone := λ x y H, (if x.cast_succ < i then begin end else (if y.cast_succ < i then begin end else begin end)) begin intros x y H, unfold coface, split_ifs, simp, assumption, end } -- def coface (n : ℕ) (i : fin n) : (fin n) → (fin (n + 1)) := -- λ x, if x < i then x else fin.mk (x.val + 1) begin -- destruct x, intro, simp, -- end -- #check ite -- instance (n : ℕ) (i : fin n) : monotone_function (coface n i) := by refine { -- monotone := begin -- intros x y h, -- unfold coface, -- have xi_dec : (decidable (x < i)), apply fin.decidable_lt, -- have yi_dec : (decidable (y < i)), apply fin.decidable_lt, -- cases xi_dec; cases yi_dec, -- -- easy -- rw if_neg, rw if_neg, simp, repeat {assumption}, -- -- disgusting -- rw if_neg, rw if_pos, -- have : x < i, -- cases (lt_or_eq_of_le h), -- apply (lt_trans h_1 yi_dec), -- rw h_1, assumption, -- contradiction, repeat {assumption}, -- -- easy? -- rw if_pos, rw if_neg, simp, -- end -- } -- -- instance ordinal_category : category nat := by refine { -- -- hom := λ n m, (fin n) ⥤ (fin m), -- -- id := λ X, 𝟭 (fin X), -- -- comp := λ X Y Z f g, f ⋙ g, -- -- id_comp' := begin -- -- intros, apply functor.comp_id, -- -- end, -- -- comp_id' := begin -- -- intros, apply functor.comp_id, -- -- end, -- -- assoc' := begin -- -- intros, simp, unfold functor.comp, -- -- end -- -- }
-- Copyright 2017, the blau.io contributors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. module API.Web.HTML.HTMLElement import API.Web.HTML.HTMLCanvasElement import API.Web.HTML.HTMLScriptElement import IdrisScript %access public export %default total ||| The HTMLElement is the interface from which all the HTML elements' ||| interfaces inherit, and which must be used by elements that have no ||| additional requirements. ||| ||| The original specification can be found at ||| https://html.spec.whatwg.org/#htmlelement data HTMLElement : Type where FromHTMLCanvasElement : HTMLCanvasElement -> HTMLElement FromHTMLScriptElement : HTMLScriptElement -> HTMLElement New : (localName : String) -> (self : JSRef)-> HTMLElement ||| htmlElementFromPointer is a helper function for easily creating HTMLElements ||| from JavaScript references. ||| ||| @ ref A pointer to an HTMLElement. htmlElementFromPointer : (ref : JSRef) -> JS_IO $ Maybe HTMLElement htmlElementFromPointer ref = case !maybeLocalName of Nothing => pure Nothing (Just localName) => case localName of "canvas" => case !(htmlCanvasElementFromPointer ref) of Nothing => pure Nothing (Just canvas) => pure $ Just $ FromHTMLCanvasElement canvas "script" => case !(htmlScriptElementFromPointer ref) of Nothing => pure Nothing (Just script) => pure $ Just $ FromHTMLScriptElement script _ => pure $ Just $ New localName ref where maybeLocalName : JS_IO $ Maybe String maybeLocalName = let getLocalName = jscall "%0.localName" (JSRef -> JS_IO JSRef) ref in case !(IdrisScript.pack !getLocalName) of (JSString ** str) => pure $ Just $ fromJS str _ => pure Nothing
Crammed's sub-labels have included the Made To Measure composers' series, world music collection Cramworld, electronic music imprints SSR, Language & Selector, and Ziriguiboom, a collection devoted to new Brazilian music. Nowadays, Crammed would like to believe that borders between genres are no longer indispensable, so most releases tend to come out under the simple "Crammed" banner. Crammed's current roster includes Konono N°1, Cibelle, Koçani Orkestar, Taraf de Haidouks, Bebel Gilberto, Balkan Beat Box, DJ Dolores, Tuxedomoon, Shantel, Kasai Allstars, Think Of One, Mahala Rai Banda, newcomers Lonely Drifter Karen & Allá, and more.
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ import group_theory.subgroup.pointwise import linear_algebra.basic /-! # Pointwise instances on `submodule`s This file provides the actions * `submodule.pointwise_distrib_mul_action` * `submodule.pointwise_mul_action_with_zero` which matches the action of `mul_action_set`. These actions are available in the `pointwise` locale. -/ namespace submodule variables {α : Type*} {R : Type*} {M : Type*} variables [semiring R] [add_comm_monoid M] [module R M] instance pointwise_add_comm_monoid : add_comm_monoid (submodule R M) := { add := (⊔), add_assoc := λ _ _ _, sup_assoc, zero := ⊥, zero_add := λ _, bot_sup_eq, add_zero := λ _, sup_bot_eq, add_comm := λ _ _, sup_comm } @[simp] lemma add_eq_sup (p q : submodule R M) : p + q = p ⊔ q := rfl @[simp] lemma zero_eq_bot : (0 : submodule R M) = ⊥ := rfl section variables [monoid α] [distrib_mul_action α M] [smul_comm_class α R M] /-- The action on a submodule corresponding to applying the action to every element. This is available as an instance in the `pointwise` locale. -/ protected def pointwise_distrib_mul_action : distrib_mul_action α (submodule R M) := { smul := λ a S, S.map (distrib_mul_action.to_linear_map _ _ a), one_smul := λ S, (congr_arg (λ f, S.map f) (linear_map.ext $ by exact one_smul α)).trans S.map_id, mul_smul := λ a₁ a₂ S, (congr_arg (λ f : M →ₗ[R] M, S.map f) (linear_map.ext $ by exact mul_smul _ _)).trans (S.map_comp _ _), smul_zero := λ a, map_bot _, smul_add := λ a S₁ S₂, map_sup _ _ _ } localized "attribute [instance] submodule.pointwise_distrib_mul_action" in pointwise open_locale pointwise @[simp] lemma coe_pointwise_smul (a : α) (S : submodule R M) : ↑(a • S) = a • (S : set M) := rfl @[simp] lemma pointwise_smul_to_add_submonoid (a : α) (S : submodule R M) : (a • S).to_add_submonoid = a • S.to_add_submonoid := rfl @[simp] lemma pointwise_smul_to_add_subgroup {R M : Type*} [ring R] [add_comm_group M] [distrib_mul_action α M] [module R M] [smul_comm_class α R M] (a : α) (S : submodule R M) : (a • S).to_add_subgroup = a • S.to_add_subgroup := rfl lemma smul_mem_pointwise_smul (m : M) (a : α) (S : submodule R M) : m ∈ S → a • m ∈ a • S := (set.smul_mem_smul_set : _ → _ ∈ a • (S : set M)) @[simp] lemma smul_le_self_of_tower {α : Type*} [semiring α] [module α R] [module α M] [smul_comm_class α R M] [is_scalar_tower α R M] (a : α) (S : submodule R M) : a • S ≤ S := begin rintro y ⟨x, hx, rfl⟩, exact smul_of_tower_mem _ a hx, end end section variables [semiring α] [module α M] [smul_comm_class α R M] /-- The action on a submodule corresponding to applying the action to every element. This is available as an instance in the `pointwise` locale. This is a stronger version of `submodule.pointwise_distrib_mul_action`. Note that `add_smul` does not hold so this cannot be stated as a `module`. -/ protected def pointwise_mul_action_with_zero : mul_action_with_zero α (submodule R M) := { zero_smul := λ S, (congr_arg (λ f : M →ₗ[R] M, S.map f) (linear_map.ext $ by exact zero_smul α)).trans S.map_zero, .. submodule.pointwise_distrib_mul_action } localized "attribute [instance] submodule.pointwise_mul_action_with_zero" in pointwise end end submodule
------------------------------------------------------------------------ -- Integers ------------------------------------------------------------------------ -- This module contains some basic definitions with few dependencies -- (in particular, not Groupoid). See Integer for more definitions. -- The definitions below are reexported from Integer. {-# OPTIONS --without-K --safe #-} open import Equality module Integer.Basics {c⁺} (eq : ∀ {a p} → Equality-with-J a p c⁺) where open Derived-definitions-and-properties eq import Agda.Builtin.Int open import Prelude renaming (_+_ to _⊕_) open import Equality.Decidable-UIP eq import Nat eq as Nat -- Integers. open Agda.Builtin.Int public using () hiding (module Int) renaming (Int to ℤ; pos to +_; negsuc to -[1+_]) module ℤ where open Agda.Builtin.Int.Int public using () renaming (pos to +_; negsuc to -[1+_]) private variable m n : ℕ -- Turns natural numbers into the corresponding negative integers. -[_] : ℕ → ℤ -[ zero ] = + 0 -[ suc n ] = -[1+ n ] -- Negation. infix 8 -_ -_ : ℤ → ℤ - + n = -[ n ] - -[1+ n ] = + suc n -- A helper function used to implement addition. +_+-[1+_] : ℕ → ℕ → ℤ + m +-[1+ n ] = if m Nat.<= n then -[1+ n ∸ m ] else + (m ∸ suc n) private -- An alternative implementation of +_+-[1+_]. +_+-[1+_]′ : ℕ → ℕ → ℤ + zero +-[1+ n ]′ = -[1+ n ] + suc m +-[1+ zero ]′ = + m + suc m +-[1+ suc n ]′ = + m +-[1+ n ]′ -- The alternative implementation of +_+-[1+_] is not optimised (it -- does not use builtin functions), but it computes in the same way -- as +_+-[1+_]. ++-[1+]≡++-[1+]′ : ∀ m n → + m +-[1+ n ] ≡ + m +-[1+ n ]′ ++-[1+]≡++-[1+]′ zero n = refl _ ++-[1+]≡++-[1+]′ (suc m) zero = refl _ ++-[1+]≡++-[1+]′ (suc m) (suc n) = ++-[1+]≡++-[1+]′ m n -- Addition. infixl 6 _+_ _+_ : ℤ → ℤ → ℤ + m + + n = + (m ⊕ n) + m + -[1+ n ] = + m +-[1+ n ] -[1+ m ] + + n = + n +-[1+ m ] -[1+ m ] + -[1+ n ] = -[1+ suc m ⊕ n ] -- Subtraction. infixl 6 _-_ _-_ : ℤ → ℤ → ℤ i - j = i + - j -- The +_ constructor is cancellative. +-cancellative : + m ≡ + n → m ≡ n +-cancellative = cong f where f : ℤ → ℕ f (+ n) = n f -[1+ n ] = n -- The -[1+_] constructor is cancellative. -[1+]-cancellative : -[1+ m ] ≡ -[1+ n ] → m ≡ n -[1+]-cancellative = cong f where f : ℤ → ℕ f (+ n) = n f -[1+ n ] = n -- Non-negative integers are not equal to negative integers. +≢-[1+] : + m ≢ -[1+ n ] +≢-[1+] +≡- = subst P +≡- tt where P : ℤ → Type P (+ n) = ⊤ P -[1+ n ] = ⊥ -- Non-positive integers are not equal to positive integers. +[1+]≢- : + suc m ≢ -[ n ] +[1+]≢- {n = zero} = Nat.0≢+ ∘ sym ∘ +-cancellative +[1+]≢- {n = suc _} = +≢-[1+] -- Equality of integers is decidable. infix 4 _≟_ _≟_ : Decidable-equality ℤ + m ≟ + n = ⊎-map (cong (+_)) (_∘ +-cancellative) (m Nat.≟ n) + m ≟ -[1+ n ] = no +≢-[1+] -[1+ m ] ≟ + n = no (+≢-[1+] ∘ sym) -[1+ m ] ≟ -[1+ n ] = ⊎-map (cong -[1+_]) (_∘ -[1+]-cancellative) (m Nat.≟ n) -- The integers form a set. ℤ-set : Is-set ℤ ℤ-set = decidable⇒set _≟_ -- Addition is commutative. +-comm : ∀ i {j} → i + j ≡ j + i +-comm (+ m) {j = + _} = cong (+_) $ Nat.+-comm m +-comm (+ m) {j = -[1+ _ ]} = refl _ +-comm -[1+ m ] {j = + _} = refl _ +-comm -[1+ m ] {j = -[1+ _ ]} = cong (-[1+_] ∘ suc) $ Nat.+-comm m
lemma complete_imp_closed: fixes S :: "'a::metric_space set" assumes "complete S" shows "closed S"
-- @@stderr -- dtrace: failed to compile script test/unittest/printf/err.D_PRINTF_ARG_EXTRA.toomany.d: [D_PRINTF_ARG_EXTRA] line 18: printf( ) prototype mismatch: only 2 arguments required by this format string
Set Implicit Arguments. Require Import Coq.Strings.String. Definition glabel := (string * string)%type.
Formal statement is: lemma open_translation: fixes S :: "'a::real_normed_vector set" assumes "open S" shows "open((\<lambda>x. a + x) ` S)" Informal statement is: If $S$ is an open set, then the set $S + a$ is open.
Formal statement is: lemma closure_approachable: fixes S :: "'a::metric_space set" shows "x \<in> closure S \<longleftrightarrow> (\<forall>e>0. \<exists>y\<in>S. dist y x < e)" Informal statement is: A point $x$ is in the closure of a set $S$ if and only if for every $\epsilon > 0$, there exists a point $y \in S$ such that $d(x,y) < \epsilon$.
[STATEMENT] lemma select_mset_cong: "mset xs = mset ys \<Longrightarrow> select k xs = select k ys" [PROOF STATE] proof (prove) goal (1 subgoal): 1. mset xs = mset ys \<Longrightarrow> select k xs = select k ys [PROOF STEP] using sort_mset_cong[of xs ys] [PROOF STATE] proof (prove) using this: mset xs = mset ys \<Longrightarrow> sort xs = sort ys goal (1 subgoal): 1. mset xs = mset ys \<Longrightarrow> select k xs = select k ys [PROOF STEP] unfolding select_def [PROOF STATE] proof (prove) using this: mset xs = mset ys \<Longrightarrow> sort xs = sort ys goal (1 subgoal): 1. mset xs = mset ys \<Longrightarrow> sort xs ! k = sort ys ! k [PROOF STEP] by auto
open import FRP.JS.Geolocation.Angle using ( Angle ) renaming ( toString to toString° ) open import FRP.JS.String using ( String ; _++_ ) module FRP.JS.Geolocation.Coords where -- Not including the optional fields yet. record Coords : Set where field latitude : Angle longitude : Angle open Coords public toString : Coords → String toString c = toString° (latitude c) ++ "," ++ toString° (longitude c)
module Typed.LTLC where open import Prelude open import Function open import Level open import Category.Monad open import Relation.Unary.PredicateTransformer using (PT; Pt) open import Relation.Ternary.Separation.Construct.Unit open import Relation.Ternary.Separation.Allstar open import Relation.Ternary.Separation.Monad open import Relation.Ternary.Separation.Morphisms open import Relation.Ternary.Separation.Monad.Reader open import Relation.Ternary.Separation.Monad.Delay data Ty : Set where unit : Ty _⊸_ : (a b : Ty) → Ty open import Relation.Ternary.Separation.Construct.List Ty Ctx = List Ty CtxT = List Ty → List Ty infixr 20 _◂_ _◂_ : Ty → CtxT → CtxT (x ◂ f) Γ = x ∷ f Γ variable a b : Ty variable ℓv : Level variable τ : Set ℓv variable Γ Γ₁ Γ₂ Γ₃ : List τ data Exp : Ty → Ctx → Set where -- a base type tt : ε[ Exp unit ] letunit : ∀[ Exp unit ✴ Exp a ⇒ Exp a ] -- the λ-calculus lam : ∀[ (a ◂ id ⊢ Exp b) ⇒ Exp (a ⊸ b) ] ap : ∀[ Exp (a ⊸ b) ✴ Exp a ⇒ Exp b ] var : ∀[ Just a ⇒ Exp a ] module _ {{m : MonoidalSep 0ℓ}} where open MonoidalSep m using (Carrier) CPred : Set₁ CPred = Carrier → Set mutual Env : Ctx → CPred Env = Allstar Val data Val : Ty → CPred where tt : ε[ Val unit ] clos : Exp b (a ∷ Γ) → ∀[ Env Γ ⇒ Val (a ⊸ b) ] module _ {i : Size} where open ReaderTransformer id-morph Val (Delay i) public open Monads.Monad reader-monad public M : Size → (Γ₁ Γ₂ : Ctx) → CPred → CPred M i = Reader {i} open Monads using (str; _&_; typed-str) mutual eval : ∀ {i} → Exp a Γ → ε[ M i Γ ε (Val a) ] eval tt = do return tt eval (letunit (e₁ ×⟨ Γ≺ ⟩ e₂)) = do tt ← frame Γ≺ (►eval e₁) ►eval e₂ eval (lam e) = do env ← ask return (clos e env) eval (ap (f ×⟨ Γ≺ ⟩ e)) = do clos body env ← frame Γ≺ (►eval f) v ×⟨ σ ⟩ env ← ►eval e & env empty ← append (v :⟨ σ ⟩: env) ►eval body eval (var refl) = do lookup ►eval : ∀ {i} → Exp a Γ → ε[ M i Γ ε (Val a) ] app (►eval e) E σ = later (λ where .force → app (eval e) E σ)
Require Import Arith. Fixpoint plus' (n m:nat){struct m} : nat := match m with O => n | S p => S (plus' n p) end. Lemma plus'_assoc : forall n m p, plus' n (plus' m p)= plus' (plus' n m) p. Proof. intros n m p ; elim p; simpl; auto. Qed.
Formal statement is: lemma strict_mono_Suc_iff: "strict_mono f \<longleftrightarrow> (\<forall>n. f n < f (Suc n))" Informal statement is: A function $f$ is strictly monotone if and only if $f(n) < f(n+1)$ for all $n$.
Formal statement is: lemma in_components_subset: "c \<in> components s \<Longrightarrow> c \<subseteq> s" Informal statement is: If $c$ is a component of $s$, then $c$ is a subset of $s$.
||| Miscellaneous functions for getting information about the system. module System.Info %default total %extern prim__os : String %extern prim__codegen : String ||| The current operating system. export os : String os = prim__os ||| The codegen/backend used. export codegen : String codegen = prim__codegen ||| Whether we are running on MS Windows, either directly or with a compability ||| layer (e.g. cygwin). export isWindows : Bool isWindows = os `elem` ["windows", "mingw32", "cygwin32"] %foreign "C:idris2_getNProcessors, libidris2_support, idris_support.h" prim__getNProcessors : PrimIO Int ||| Get the number of processors on the system. Returns `Nothing` if we somehow ||| got 0 processors. export getNProcessors : IO (Maybe Nat) getNProcessors = do i <- fromPrim prim__getNProcessors pure (if i < 0 then Nothing else Just (integerToNat (cast i)))
lemma arc_image_uncountable: fixes g :: "real \<Rightarrow> 'a::metric_space" assumes "arc g" shows "uncountable (path_image g)"
/- Copyright (c) 2022 Devon Tuma. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Devon Tuma -/ import probability.probability_mass_function.basic /-! # Misc Lemmas That Ideally Should Port to Mathlib -/ variables {α β γ : Type*} open_locale ennreal lemma finset.count_to_list [decidable_eq α] (s : finset α) (a : α) : s.to_list.count a = ite (a ∈ s) 1 0 := by simp only [list.count_eq_of_nodup s.nodup_to_list, finset.mem_to_list] lemma vector.cons_eq_cons {n : ℕ} (x y : α) (xs ys : vector α n) : x ::ᵥ xs = y ::ᵥ ys ↔ x = y ∧ xs = ys := ⟨λ h, have x = y ∧ xs.to_list = ys.to_list, by simpa only [vector.to_list_cons] using congr_arg vector.to_list h, ⟨this.1, vector.eq _ _ this.2⟩, λ h, h.1 ▸ h.2 ▸ rfl⟩ section list_stuff variables (x : α) (n : ℕ) section mem /-- Only `x` is a member of `list.repeat x n` (unless `n = 0` which has no members). -/ @[simp] lemma list.mem_repeat_iff (y : α) : y ∈ (list.repeat x n) ↔ 0 < n ∧ y = x := begin induction n with n hn, { rw [lt_self_iff_false, false_and, list.repeat, list.mem_nil_iff] }, { simp [hn] } end lemma list.not_mem_repeat_zero (y : α) : y ∉ (list.repeat x 0) := by simp_rw [list.mem_repeat_iff, lt_self_iff_false, false_and, not_false_iff] lemma list.mem_repeat_succ_iff (y : α) : y ∈ (list.repeat x n.succ) ↔ y = x := by simp_rw [list.mem_repeat_iff, nat.zero_lt_succ, true_and] lemma list.eq_of_mem_repeat {x y : α} {n : ℕ} (hy : y ∈ (list.repeat x n)) : y = x := ((list.mem_repeat_iff x n y).1 hy).2 lemma list.pos_of_mem_repeat {x y : α} {n : ℕ} (hy : y ∈ (list.repeat x n)) : 0 < n := ((list.mem_repeat_iff x n y).1 hy).1 end mem section nth @[simp] lemma list.nth_le_repeat (m : ℕ) (hm : m < (list.repeat x n).length) : (list.repeat x n).nth_le m hm = x := list.eq_of_mem_repeat (list.mem_iff_nth_le.2 ⟨m, hm, rfl⟩) @[simp] lemma list.nth_repeat (m : ℕ) : (list.repeat x n).nth m = if m < n then some x else none := begin split_ifs with h, { exact list.nth_eq_some.2 ⟨(list.length_repeat x n).symm ▸ h, list.nth_le_repeat x n m _⟩ }, { exact list.nth_eq_none_iff.2 (le_of_not_lt $ (list.length_repeat x n).symm ▸ h) } end lemma list.nth_repeat_eq_none_iff (m : ℕ) : (list.repeat x n).nth m = none ↔ n ≤ m := by rw [list.nth_eq_none_iff, list.length_repeat] lemma list.nth_repeat_eq_some_iff (m : ℕ) (y : α) : (list.repeat x n).nth m = some y ↔ m < n ∧ x = y := by simp only [ite_eq_iff, list.nth_repeat, and_false, or_false] end nth section find lemma list.find_repeat (p : α → Prop) [decidable_pred p] : (list.repeat x n).find p = if 0 < n ∧ p x then some x else none := begin split_ifs with hx, { cases n with n, { exact ((lt_self_iff_false 0).1 hx.1).elim }, { exact list.find_cons_of_pos _ hx.2 } }, { refine list.find_eq_none.2 (λ y hy, (list.eq_of_mem_repeat hy).symm ▸ _), simpa only [not_and_distrib, list.pos_of_mem_repeat hy, not_true, false_or] using hx } end @[simp] lemma list.find_repeat_eq_none_iff (p : α → Prop) [decidable_pred p] : (list.repeat x n).find p = none ↔ n = 0 ∨ ¬ p x := by simp_rw [list.find_repeat, ite_eq_right_iff, imp_false, not_and_distrib, not_lt, le_zero_iff] @[simp] lemma list.find_repeat_eq_some_iff (p : α → Prop) [decidable_pred p] (y : α) : (list.repeat x n).find p = some y ↔ 0 < n ∧ p x ∧ y = x := by simp_rw [list.find_repeat, ite_eq_iff, and_assoc, eq_comm, and_false, or_false] end find @[simp] lemma list.all₂_repeat_iff (p : α → Prop) : (list.repeat x n).all₂ p ↔ n = 0 ∨ p x := by simp [list.all₂_iff_forall, lt_iff_not_le, or_iff_not_imp_left] @[simp] lemma list.all_repeat (p : α → bool) : (list.repeat x n).all p = if n = 0 then tt else p x := begin induction n with n hn, { refl }, { simp only [nat.succ_ne_zero, if_false, list.repeat, list.all, list.foldr_cons], by_cases hn' : n = 0, { rw [hn', list.repeat, list.foldr, band_tt] }, { exact (congr_arg ((&&) (p x)) (hn.trans (if_neg hn'))).trans (band_self (p x)) } } end @[simp] lemma list.reverse_repeat : (list.repeat x n).reverse = list.repeat x n := begin refine list.ext_le (list.length_reverse _) (λ m hm hm', _), rw [list.nth_le_repeat, list.nth_le_reverse' _ m, list.nth_le_repeat], exact lt_of_le_of_lt tsub_le_self (tsub_lt_self (lt_of_le_of_lt zero_le' hm') zero_lt_one), end @[simp] lemma list.rotate_repeat (m : ℕ) : (list.repeat x n).rotate m = list.repeat x n := begin refine list.ext_le (list.length_rotate _ _) (λ m hm hm', _), rw [list.nth_le_repeat, list.nth_le_rotate, list.nth_le_repeat], end @[simp] lemma list.concat_self_repeat : (list.repeat x n).concat x = list.repeat x (n + 1) := by rw [list.concat_eq_reverse_cons, list.reverse_repeat, ← list.repeat, list.reverse_repeat] @[simp] lemma list.map_repeat (f : α → β) : (list.repeat x n).map f = list.repeat (f x) n := begin induction n with n hn, { exact rfl }, { exact (list.map_cons f x _).trans (congr_arg ((::) (f x)) hn) } end @[simp] lemma list.filter_repeat (p : α → Prop) [decidable_pred p] : (list.repeat x n).filter p = if p x then list.repeat x n else [] := begin induction n with n hn, { exact (if_t_t _ []).symm }, { split_ifs with hp; simp [hp, hn] } end lemma list.repeat_add (m : ℕ) : list.repeat x (n + m) = list.repeat x n ++ list.repeat x m := begin induction n with n hn, { rw [list.repeat, zero_add, list.nil_append] }, { rw [nat.succ_add, list.repeat, hn, ← list.cons_append, list.repeat] } end lemma list.repeat_sub (m : ℕ) : list.repeat x (n - m) = (list.repeat x n).drop m := begin refine list.ext_le _ (λ m hm hm', _), { simp_rw [list.length_drop, list.length_repeat] }, { simp_rw [list.nth_le_drop', list.nth_le_repeat] } end end list_stuff
module Collections.BSTree.Set.Core import Collections.Util.Bnd import Collections.BSTree.Map.Core as M import Decidable.Order.Strict ||| A verified binary search tree with erased proofs. ||| ||| The keys in the tree are constrained by min/max bounds, which make use of `Bnd` to extend the ||| tree key type with `Top` and `Bot` values. This allows for a natural way to leave bounds ||| unconstrained (by having a minimum of `Bot` or a maximum of `Top`). ||| ||| @ ord The ordering implementations used in the tree. Since these are w.r.t. a type `kTy`, the ||| type of tree keys is defined implicitly by `ord`. ||| @ min The minimum value constraint, proving that `sto min (Mid x)` for all values `x` in the ||| tree. ||| @ max The maximum value constraint, proving that `sto (Mid x) max` for all values `x` in the ||| tree. public export BST : {0 sto : kTy -> kTy -> Type} -> (pre : StrictPreorder kTy sto) -> (tot : StrictOrdered kTy sto) -> (0 min,max : Bnd kTy) -> Type BST pre tot min max = M.BST pre tot () min max %name Collections.BSTree.Set.Core.BST t,u,v ||| A verified binary search tree with erased proofs. ||| ||| This is an alias for the more generic `BST` (which accepts min/max bounds for its contents). ||| The bounds are necessary for verifying the structure of a tree, but the root node of any ||| `BST` will always be unconstrained. So generally, `BST` can be considered an implementation ||| detail. ||| ||| @ ord The strict total ordering used in the tree. Since a `StrictOrdered` impl is w.r.t. a type ||| `kTy`, the type of tree values is defined implicitly by `ord`. public export BSTree : {0 kTy : Type} -> (0 sto : kTy -> kTy -> Type) -> {auto pre : StrictPreorder kTy sto} -> {auto tot : StrictOrdered kTy sto} -> Type BSTree sto {pre} {tot} = M.BST pre tot () Bot Top %name Collections.BSTree.Set.Core.BSTree t,u,v
/************************************************************************************* Copyright 2010 Philip Waldron This file is part of BayRate. BayRate 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. BayRate 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 Foobar. If not, see <http://www.gnu.org/licenses/>. ***************************************************************************************/ #pragma once #include <string> #include <vector> #include <map> #include <gsl/gsl_math.h> #include <gsl/gsl_multimin.h> #include <gsl/gsl_chebyshev.h> #include <gsl/gsl_rng.h> #include <gsl/gsl_randist.h> #include <boost/date_time/gregorian/gregorian.hpp> #include "player.h" #include "game.h" #include "tdListEntry.h" using namespace std; class collection { public: collection(void); ~collection(void); string tournamentCode; map<int, player> playerHash; vector<game> gameList; std::string tournamentName; boost::gregorian::date tournamentDate; double calc_pt(const gsl_vector *v); double calc_pt_df(const gsl_vector *x, gsl_vector *df); void calc_sigma(); void calc_sigma2(); int calc_ratings(); int calc_ratings_fdf(); void reset(); void initSeeding(map<int, tdListEntry> &tdList); void findImprobables(map<int, tdListEntry> &tdList); void setQuiet(bool q); int getFdfIterations(); int getSimplexIterations(); private: double PI; const gsl_rng_type *T; gsl_rng *r; bool quiet; int fdfiterations; int simplexiterations; };
-- @@stderr -- dtrace: failed to compile script test/unittest/struct/err.D_DECL_COMBO.StructWithoutColon.d: [D_DECL_COMBO] line 25: invalid type combination
Formal statement is: lemma (in bounded_bilinear) Zfun_right: "Zfun f F \<Longrightarrow> Zfun (\<lambda>x. a ** f x) F" Informal statement is: If $f$ is a zero function, then $a \cdot f$ is also a zero function.
lemma continuous_at_Inf_antimono: fixes f :: "'a::{linorder_topology,conditionally_complete_linorder} \<Rightarrow> 'b::{linorder_topology,conditionally_complete_linorder}" assumes "antimono f" and cont: "continuous (at_right (Inf S)) f" and S: "S \<noteq> {}" "bdd_below S" shows "f (Inf S) = (SUP s\<in>S. f s)"
Formal statement is: lemma pderiv_pCons: "pderiv (pCons a p) = p + pCons 0 (pderiv p)" Informal statement is: The derivative of a polynomial $a_0 + a_1 x + \cdots + a_n x^n$ is $a_1 + 2 a_2 x + \cdots + n a_n x^{n-1}$.
module Issue204.Dependency where open import Common.Level public renaming (lsuc to suc) record R (ℓ : Level) : Set (suc ℓ) where data D (ℓ : Level) : Set (suc ℓ) where module M {ℓ : Level} (d : D ℓ) where
-- @@stderr -- dtrace: failed to compile script test/unittest/stack/err.D_PROTO_LEN.stack.d: [D_PROTO_LEN] line 19: stack( ) prototype mismatch: 2 args passed, at most 1 expected
lemma infnorm_triangle: fixes x :: "'a::euclidean_space" shows "infnorm (x + y) \<le> infnorm x + infnorm y"
Formal statement is: lemma residue_div: assumes "open s" "z \<in> s" and f_holo: "f holomorphic_on s - {z}" shows "residue (\<lambda>z. (f z) / c) z= residue f z / c " Informal statement is: If $f$ is holomorphic on a punctured neighborhood of $z$, then the residue of $f(z)/c$ at $z$ is equal to the residue of $f$ at $z$ divided by $c$.
Formal statement is: lemma uniformly_continuous_on_cmul[continuous_intros]: fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector" assumes "uniformly_continuous_on s f" shows "uniformly_continuous_on s (\<lambda>x. c *\<^sub>R f(x))" Informal statement is: If $f$ is uniformly continuous on $S$, then $cf$ is uniformly continuous on $S$.
SUBROUTINE elem20(TASK, elsnam, dtime, ttime, istop, ivect, & lnod, flag1, flag2) !master routine for element 20 (TLF) 2-D solid triangular element USE ctrl_db, ONLY: ndofn, npoin, ntype USE outp_db, ONLY: sumat, iwrit USE ele20_db USE npo_db USE sms_db, ONLY : selective_mass_scaling, sms_ns , sms_name, sms_thl, sms_alp IMPLICIT NONE !--- Dummy variables CHARACTER(len=*),INTENT(IN):: TASK ! optional parameters LOGICAL, OPTIONAL :: flag1,flag2 CHARACTER (len=*), OPTIONAL :: elsnam INTEGER (kind=4), OPTIONAL :: istop, ivect(:) INTEGER (kind=4), POINTER, OPTIONAL :: lnod(:,:) REAL (kind=8), OPTIONAL :: dtime,ttime !--- Local variables CHARACTER (len=mnam) :: sname INTEGER (kind=4) :: nreqs, narch, nelem, i TYPE (ele20_set), POINTER :: elset, anter LOGICAL :: sms,esta REAL (kind=8) :: thl,alp IF (.NOT.ASSOCIATED(head)) RETURN !no element sets NULLIFY(anter) !nullify pointer to previous set elset => head !point to first set of elements DO !loop over the element sets ! recover control variables for present element set CALL comm20(1,nelem,nreqs,narch,sname,elset) SELECT CASE(TRIM(task)) !according to the requested task CASE('GAUSSC') !compute initial constants CALL gaus20(elset%head,coord,istop,elset%gauss,elset%angdf,ntype) !CASE('LOADPL') !compute gravity load vector ! CALL load20(igrav,loadv(:,:,iload),gvect,gravy,elset%head,ntype,coord) CASE('CLOSEF') !close output file CALL close1(nreqs,narch) CASE('LUMASS') !compute (lumped) mass vector CALL luma20(elset%head, emass, sumat, ntype, coord) CASE('NEW','NSTRA1','NSTRA2') !release DOFs and other tasks CALL acvd20(ifpre, elset%head, elset%lside, elset%swapc, elset%eside) CALL dist20(elset%head, elset%nelem, elset%eside, coord, .FALSE.) CASE('UPDLON') !update local node numbers CALL updl20(elset%head, oldlb, elset%lside, elset%origl) CASE('OUTDYN') !output variables for post-processing IF (flag1 .OR. flag2) CALL outd20(flag1,flag2,iwrit,elset%head,nreqs,narch, & elset%ngrqs,ttime) CASE('RESVPL') !compute internal nodal forces CALL resv20(nelem,elset%head,ntype,coora,resid,istop,ttime,elset%angdf,coorc,elset%eulrf) CASE('DUMPIN') !dumps variables for restart CALL dump20(elset) CASE('WRTPOS') !writes geometric variables for post-process CALL mase20(ntype,nreqs,nelem,elset%head,elset%ngrqs,narch,elset%angdf,elset%sname) elset%narch = narch !keep output file CASE('INCDLT') !compute critical time increment sms = .FALSE. thl = 0d0 IF( selective_mass_scaling )THEN DO i=1,sms_ns IF(TRIM(sms_name(i)) == TRIM(sname) )THEN alp = sms_alp(i) thl = sms_thl(i) sms = .TRUE. EXIT END IF END DO END IF CALL delt20( nelem, elset%head, dtime, coora, sms, alp) CASE('SEARCH') !search if set named SNAME exists IF (flag2) EXIT flag2 = TRIM(elsnam) == TRIM(sname) IF (flag2) EXIT CASE('SURFAC') IF( flag2 )EXIT flag2 = TRIM(elsnam) == TRIM(sname) IF (flag2) THEN ! get surface definition from the element set CALL surf20(elset%head,elset%nelem) EXIT END IF CASE('BOUNDA') IF( flag2 )EXIT flag2 = TRIM(elsnam) == TRIM(sname) IF (flag2) THEN ! get boundary definition from the element set for remesh CALL boun20(elset%head,elset%nelem) EXIT END IF CASE('SLNODS') !extract connectivities into array IF( flag2 )EXIT flag2 = TRIM(elsnam) == TRIM(sname) IF (flag2) THEN esta = PRESENT(flag1) IF( esta ) esta = flag1 CALL slnods20(elset%head,lnod,nelem,esta) EXIT END IF CASE('SMOOTH') !performs smoothing for remeshing and transfer IF (flag2) EXIT flag2 = TRIM(elsnam) == TRIM(sname) IF (flag2) THEN ! smooth gaussian variables and writes into STRND CALL smth20(npoin,strnd,elset%head,elset%eulrf) EXIT END IF CASE('NODSET') !compute nodes set from element set IF (flag2) EXIT flag2 = TRIM(elsnam) == TRIM(sname) IF (flag2) THEN ! extracts nodes used in the discretization to nodset CALL nods20(npoin, numpo, elset%head, nodset, label) EXIT END IF CASE ('SECDAT') IF( flag2 )EXIT flag2 = TRIM(elsnam) == TRIM(sname) IF (flag2) THEN ! extract SECTIONs used in the set CALL secd20 (elset%head,elset%nelem,ivect) EXIT END IF CASE ('EXPORT') IF( flag2 )EXIT flag2 = TRIM(elsnam) == TRIM(sname) IF (flag2) THEN ! export set data CALL expo20 (elset,flag1,istop) EXIT END IF CASE('INTVAR') IF (flag2) EXIT flag2 = TRIM(elsnam) == TRIM(sname) IF (flag2) THEN ALLOCATE(sg_old(7,1,elset%nelem)) !7:number of transfer variables by element ! get element information to transfer CALL getelv20(elset%head,sg_old,elset%eulrf) EXIT END IF CASE('REALLO') !only for the remeshed set IF( flag2 )EXIT flag2 = TRIM(elsnam) == TRIM(sname) IF (flag2) THEN ! reallocates the element set after remeshing ! exchange mesh - deallocate old mesh and put new mesh, ! interpolate all the Gaussian variables from nodes to Gauss points elset%gauss = .FALSE. elset%lside = .FALSE. elset%plstr = -1 CALL real20(elset%nelem,elset%head,elset%tail,iwrit,elset%eulrf) elset%origl = .TRUE. !connectivities changed to original labels ! restore the neighbour element patch array DEALLOCATE(elset%eside) ALLOCATE(elset%eside(3,elset%nelem)) elset%eside = 0 !reinitializes END IF !CASE('INIGAU') !read initial stresses or internal variables ! IF( flag2 )EXIT ! flag2 = TRIM(elsnam) == TRIM(sname) ! IF (flag2) THEN ! ! read initial internal variables for the element set ! CALL inig20 (elset%head,nelem,iwrit,elset%plstr) ! EXIT ! END IF CASE('ELMDIS') !computes element distorsion for remeshing purposes IF( flag2 )EXIT flag2 = TRIM(elsnam) == TRIM(sname) IF (flag2) THEN CALL dist20(elset%head, elset%nelem, elset%eside, coora, .TRUE.) EXIT END IF END SELECT IF ( ASSOCIATED(elset%next)) THEN !more sets to process elset => elset%next !point to next set ELSE EXIT END IF END DO RETURN END SUBROUTINE elem20
-- ------------------------------------------------------- [ StateMachines.idr ] -- Module : Exercises.StateMachines -- Description : Solutions to the Chapter 13 exercises in Edwin Brady's -- book, "Type-Driven Development with Idris." -- --------------------------------------------------------------------- [ EOH ] module Exercises.StateMachines import public Chapter.StateMachines %access export -- -------------------------------------------------------- [ 13.1.5 Exercises ] public export data GuessCmd : Type -> Nat -> Nat -> Type where Try : Integer -> GuessCmd Ordering (S n) n Pure : ty -> GuessCmd ty state state (>>=) : GuessCmd a state1 state2 -> (a -> GuessCmd b state2 state3) -> GuessCmd b state1 state3 export threeGuesses : GuessCmd () 3 0 threeGuesses = do Try 10 Try 20 Try 15 Pure () -- NOTE: noGuesses should not type check. -- noGuesses : GuessCmd () 0 0 -- noGuesses = do Try 10 -- Pure () namespace Matter public export data Matter = Solid | Liquid | Gas public export data MatterCmd : (ty : Type) -> (beforeState, afterState : Matter) -> Type where Melt : MatterCmd () Solid Liquid Boil : MatterCmd () Liquid Gas Condense : MatterCmd () Gas Liquid Freeze : MatterCmd () Liquid Solid Pure : ty -> MatterCmd ty state state (>>=) : MatterCmd a state1 state2 -> (a -> MatterCmd b state2 state3) -> MatterCmd b state1 state3 export iceSteam : MatterCmd () Solid Gas iceSteam = do Melt Boil export steamIce : MatterCmd () Gas Solid steamIce = do Condense Freeze -- NOTE: overMelt should not type check. -- overMelt : MatterCmd () Solid Gas -- overMelt = do Melt -- Melt -- --------------------------------------------------------------------- [ EOF ]
Formal statement is: lemma islimpt_finite: fixes x :: "'a::t1_space" shows "finite s \<Longrightarrow> \<not> x islimpt s" Informal statement is: If $s$ is a finite set, then $x$ is not a limit point of $s$.
lemma convex_connected: fixes S :: "'a::real_normed_vector set" assumes "convex S" shows "connected S"
State Before: 𝕜 : Type u_1 inst✝¹¹ : NontriviallyNormedField 𝕜 D : Type uD inst✝¹⁰ : NormedAddCommGroup D inst✝⁹ : NormedSpace 𝕜 D E : Type uE inst✝⁸ : NormedAddCommGroup E inst✝⁷ : NormedSpace 𝕜 E F : Type uF inst✝⁶ : NormedAddCommGroup F inst✝⁵ : NormedSpace 𝕜 F G : Type uG inst✝⁴ : NormedAddCommGroup G inst✝³ : NormedSpace 𝕜 G X : Type ?u.59708 inst✝² : NormedAddCommGroup X inst✝¹ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F b : E × F → G m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F inst✝ : Subsingleton F ⊢ ContDiffWithinAt 𝕜 n f s x State After: 𝕜 : Type u_1 inst✝¹¹ : NontriviallyNormedField 𝕜 D : Type uD inst✝¹⁰ : NormedAddCommGroup D inst✝⁹ : NormedSpace 𝕜 D E : Type uE inst✝⁸ : NormedAddCommGroup E inst✝⁷ : NormedSpace 𝕜 E F : Type uF inst✝⁶ : NormedAddCommGroup F inst✝⁵ : NormedSpace 𝕜 F G : Type uG inst✝⁴ : NormedAddCommGroup G inst✝³ : NormedSpace 𝕜 G X : Type ?u.59708 inst✝² : NormedAddCommGroup X inst✝¹ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F b : E × F → G m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F inst✝ : Subsingleton F ⊢ ContDiffWithinAt 𝕜 n (fun x => 0) s x Tactic: rw [Subsingleton.elim f fun _ => 0] State Before: 𝕜 : Type u_1 inst✝¹¹ : NontriviallyNormedField 𝕜 D : Type uD inst✝¹⁰ : NormedAddCommGroup D inst✝⁹ : NormedSpace 𝕜 D E : Type uE inst✝⁸ : NormedAddCommGroup E inst✝⁷ : NormedSpace 𝕜 E F : Type uF inst✝⁶ : NormedAddCommGroup F inst✝⁵ : NormedSpace 𝕜 F G : Type uG inst✝⁴ : NormedAddCommGroup G inst✝³ : NormedSpace 𝕜 G X : Type ?u.59708 inst✝² : NormedAddCommGroup X inst✝¹ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F b : E × F → G m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F inst✝ : Subsingleton F ⊢ ContDiffWithinAt 𝕜 n (fun x => 0) s x State After: no goals Tactic: exact contDiffWithinAt_const
module AtomShell using Sockets using WebIO abstract type Shell end _shell = nothing include("install.jl") include("process.jl") include("window.jl") include("webio.jl") end
[STATEMENT] lemma rawpsubstT_same_Var[simp]: assumes "r \<in> atrm" "set xs \<subseteq> var" shows "rawpsubstT r (map (\<lambda>x. (Var x,x)) xs) = r" [PROOF STATE] proof (prove) goal (1 subgoal): 1. rawpsubstT r (map (\<lambda>x. (Var x, x)) xs) = r [PROOF STEP] using assms [PROOF STATE] proof (prove) using this: r \<in> atrm set xs \<subseteq> var goal (1 subgoal): 1. rawpsubstT r (map (\<lambda>x. (Var x, x)) xs) = r [PROOF STEP] by (induct xs) auto
Formal statement is: lemma is_unit_smult_iff: "smult c p dvd 1 \<longleftrightarrow> c dvd 1 \<and> p dvd 1" Informal statement is: A polynomial $p$ is a unit if and only if $c p$ is a unit for all $c \in \mathbb{Z}$.
[STATEMENT] lemma eqButUIDl_sym: assumes "eqButUIDl uid uidl uidl1" shows "eqButUIDl uid uidl1 uidl" [PROOF STATE] proof (prove) goal (1 subgoal): 1. eqButUIDl uid uidl1 uidl [PROOF STEP] using assms [PROOF STATE] proof (prove) using this: eqButUIDl uid uidl uidl1 goal (1 subgoal): 1. eqButUIDl uid uidl1 uidl [PROOF STEP] by auto
import phase1.basic open set with_bot universe u namespace con_nf variables [params.{u}] (α : Λ) [core_tangle_cumul α] {β : Iio_index α} {s t : set (tangle β)} /-- An `α` code is a type index `β < α` together with a set of tangles of type `β`. -/ @[derive inhabited] def code : Type u := Σ β : Iio_index α, set (tangle β) /-- Nonempty codes. -/ abbreviation nonempty_code : Type u := {c : code α // c.2.nonempty} namespace code variables {α} {c : code α} /-- Constructor for `code`. -/ def mk : Π β : Iio_index α, set (tangle β) → code α := sigma.mk lemma mk_def : mk β s = ⟨β, s⟩ := rfl @[simp] lemma fst_mk (β : Iio_index α) (s : set (tangle β)) : (mk β s).1 = β := rfl @[simp] lemma snd_mk (β : Iio_index α) (s : set (tangle β)) : (mk β s).2 = s := rfl /-- A code is empty if it has no element. -/ protected def is_empty (c : code α) : Prop := c.2 = ∅ protected lemma is_empty.eq : c.is_empty → c.2 = ∅ := id @[simp] lemma is_empty_mk : (mk β s).is_empty ↔ s = ∅ := iff.rfl @[simp] lemma mk_inj : mk β s = mk β t ↔ s = t := by simp [mk] end code end con_nf
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.Matrix where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Foundations.HLevels open import Cubical.Foundations.Transport open import Cubical.Functions.FunExtEquiv import Cubical.Data.Empty as ⊥ open import Cubical.Data.Bool open import Cubical.Data.Nat hiding (_+_ ; +-comm ; +-assoc) open import Cubical.Data.Vec open import Cubical.Data.Sigma.Base open import Cubical.Data.FinData open import Cubical.Relation.Nullary open import Cubical.Algebra.Group hiding (⟨_⟩) open import Cubical.Algebra.AbGroup hiding (⟨_⟩) open import Cubical.Algebra.Monoid hiding (⟨_⟩) open import Cubical.Algebra.Ring open Iso private variable ℓ : Level A : Type ℓ -- Equivalence between Vec matrix and Fin function matrix FinMatrix : (A : Type ℓ) (m n : ℕ) → Type ℓ FinMatrix A m n = FinVec (FinVec A n) m VecMatrix : (A : Type ℓ) (m n : ℕ) → Type ℓ VecMatrix A m n = Vec (Vec A n) m FinMatrix→VecMatrix : {m n : ℕ} → FinMatrix A m n → VecMatrix A m n FinMatrix→VecMatrix M = FinVec→Vec (λ fm → FinVec→Vec (M fm)) VecMatrix→FinMatrix : {m n : ℕ} → VecMatrix A m n → FinMatrix A m n VecMatrix→FinMatrix M fn fm = lookup fm (lookup fn M) FinMatrix→VecMatrix→FinMatrix : {m n : ℕ} (M : FinMatrix A m n) → VecMatrix→FinMatrix (FinMatrix→VecMatrix M) ≡ M FinMatrix→VecMatrix→FinMatrix {m = zero} M = funExt (⊥.rec ∘ ¬Fin0) FinMatrix→VecMatrix→FinMatrix {n = zero} M = funExt₂ (λ _ → ⊥.rec ∘ ¬Fin0) FinMatrix→VecMatrix→FinMatrix {m = suc m} {n = suc n} M = funExt₂ goal where goal : (fm : Fin (suc m)) (fn : Fin (suc n)) → VecMatrix→FinMatrix (_ ∷ FinMatrix→VecMatrix (M ∘ suc)) fm fn ≡ M fm fn goal zero zero = refl goal zero (suc fn) i = FinVec→Vec→FinVec (M zero ∘ suc) i fn goal (suc fm) fn i = FinMatrix→VecMatrix→FinMatrix (M ∘ suc) i fm fn VecMatrix→FinMatrix→VecMatrix : {m n : ℕ} (M : VecMatrix A m n) → FinMatrix→VecMatrix (VecMatrix→FinMatrix M) ≡ M VecMatrix→FinMatrix→VecMatrix {m = zero} [] = refl VecMatrix→FinMatrix→VecMatrix {m = suc m} (M ∷ MS) i = Vec→FinVec→Vec M i ∷ VecMatrix→FinMatrix→VecMatrix MS i FinMatrixIsoVecMatrix : (A : Type ℓ) (m n : ℕ) → Iso (FinMatrix A m n) (VecMatrix A m n) fun (FinMatrixIsoVecMatrix A m n) = FinMatrix→VecMatrix inv (FinMatrixIsoVecMatrix A m n) = VecMatrix→FinMatrix rightInv (FinMatrixIsoVecMatrix A m n) = VecMatrix→FinMatrix→VecMatrix leftInv (FinMatrixIsoVecMatrix A m n) = FinMatrix→VecMatrix→FinMatrix FinMatrix≃VecMatrix : {m n : ℕ} → FinMatrix A m n ≃ VecMatrix A m n FinMatrix≃VecMatrix {_} {A} {m} {n} = isoToEquiv (FinMatrixIsoVecMatrix A m n) FinMatrix≡VecMatrix : (A : Type ℓ) (m n : ℕ) → FinMatrix A m n ≡ VecMatrix A m n FinMatrix≡VecMatrix _ _ _ = ua FinMatrix≃VecMatrix -- Define abelian group structure on matrices module FinMatrixAbGroup (G' : AbGroup {ℓ}) where open AbGroup G' renaming ( Carrier to G ; is-set to isSetG ) zeroFinMatrix : ∀ {m n} → FinMatrix G m n zeroFinMatrix _ _ = 0g negFinMatrix : ∀ {m n} → FinMatrix G m n → FinMatrix G m n negFinMatrix M i j = - M i j addFinMatrix : ∀ {m n} → FinMatrix G m n → FinMatrix G m n → FinMatrix G m n addFinMatrix M N i j = M i j + N i j isSetFinMatrix : ∀ {m n} → isSet (FinMatrix G m n) isSetFinMatrix = isSetΠ2 λ _ _ → isSetG addFinMatrixAssoc : ∀ {m n} → (M N K : FinMatrix G m n) → addFinMatrix M (addFinMatrix N K) ≡ addFinMatrix (addFinMatrix M N) K addFinMatrixAssoc M N K i j k = assoc (M j k) (N j k) (K j k) i addFinMatrix0r : ∀ {m n} → (M : FinMatrix G m n) → addFinMatrix M zeroFinMatrix ≡ M addFinMatrix0r M i j k = rid (M j k) i addFinMatrix0l : ∀ {m n} → (M : FinMatrix G m n) → addFinMatrix zeroFinMatrix M ≡ M addFinMatrix0l M i j k = lid (M j k) i addFinMatrixNegMatrixr : ∀ {m n} → (M : FinMatrix G m n) → addFinMatrix M (negFinMatrix M) ≡ zeroFinMatrix addFinMatrixNegMatrixr M i j k = invr (M j k) i addFinMatrixNegMatrixl : ∀ {m n} → (M : FinMatrix G m n) → addFinMatrix (negFinMatrix M) M ≡ zeroFinMatrix addFinMatrixNegMatrixl M i j k = invl (M j k) i addFinMatrixComm : ∀ {m n} → (M N : FinMatrix G m n) → addFinMatrix M N ≡ addFinMatrix N M addFinMatrixComm M N i k l = comm (M k l) (N k l) i FinMatrixAbGroup : (m n : ℕ) → AbGroup {ℓ} FinMatrixAbGroup m n = makeAbGroup {G = FinMatrix G m n} zeroFinMatrix addFinMatrix negFinMatrix isSetFinMatrix addFinMatrixAssoc addFinMatrix0r addFinMatrixNegMatrixr addFinMatrixComm -- Define a abelian group structure on vector matrices and prove that -- it is equal to FinMatrixAbGroup using the SIP module _ (G' : AbGroup {ℓ}) where open AbGroup G' renaming ( Carrier to G ) zeroVecMatrix : ∀ {m n} → VecMatrix G m n zeroVecMatrix = replicate (replicate 0g) negVecMatrix : ∀ {m n} → VecMatrix G m n → VecMatrix G m n negVecMatrix = map (map (λ x → - x)) addVec : ∀ {m} → Vec G m → Vec G m → Vec G m addVec [] [] = [] addVec (x ∷ xs) (y ∷ ys) = x + y ∷ addVec xs ys addVecMatrix : ∀ {m n} → VecMatrix G m n → VecMatrix G m n → VecMatrix G m n addVecMatrix [] [] = [] addVecMatrix (M ∷ MS) (N ∷ NS) = addVec M N ∷ addVecMatrix MS NS open FinMatrixAbGroup -- Proof that FinMatrix→VecMatrix is a group homorphism FinMatrix→VecMatrixHomAdd : (m n : ℕ) (M N : FinMatrix G m n) → FinMatrix→VecMatrix (addFinMatrix G' M N) ≡ addVecMatrix (FinMatrix→VecMatrix M) (FinMatrix→VecMatrix N) FinMatrix→VecMatrixHomAdd zero n M N = refl FinMatrix→VecMatrixHomAdd (suc m) n M N = λ i → lem n (M zero) (N zero) i ∷ FinMatrix→VecMatrixHomAdd m n (λ i j → M (suc i) j) (λ i j → N (suc i) j) i where lem : (n : ℕ) (V W : FinVec G n) → FinVec→Vec (λ j → V j + W j) ≡ addVec (FinVec→Vec V) (FinVec→Vec W) lem zero V W = refl lem (suc n) V W = λ i → V zero + W zero ∷ lem n (V ∘ suc) (W ∘ suc) i -- Combine everything to get an induced abelian group structure of -- VecMatrix that is equal to the one on FinMatrix VecMatrixAbGroup : (m n : ℕ) → AbGroup VecMatrixAbGroup m n = InducedAbGroup (FinMatrixAbGroup G' m n) (_ , addVecMatrix) FinMatrix≃VecMatrix (FinMatrix→VecMatrixHomAdd m n) FinMatrixAbGroup≡VecMatrixAbGroup : (m n : ℕ) → FinMatrixAbGroup G' m n ≡ VecMatrixAbGroup m n FinMatrixAbGroup≡VecMatrixAbGroup m n = InducedAbGroupPath (FinMatrixAbGroup G' m n) (_ , addVecMatrix) FinMatrix≃VecMatrix (FinMatrix→VecMatrixHomAdd m n) -- Define identity matrix and matrix multiplication for FinMatrix and -- prove that square matrices form a ring module _ (R' : Ring {ℓ}) where open Ring R' renaming ( Carrier to R ; is-set to isSetR ) open Theory R' open FinMatrixAbGroup (abgroup R _ _ _ (R' .Ring.+-isAbGroup)) oneFinMatrix : ∀ {n} → FinMatrix R n n oneFinMatrix i j = if i == j then 1r else 0r -- TODO: upstream and state for monoids ∑ : ∀ {n} → FinVec R n → R ∑ = foldrFin _+_ 0r mulFinMatrix : ∀ {m1 m2 m3} → FinMatrix R m1 m2 → FinMatrix R m2 m3 → FinMatrix R m1 m3 mulFinMatrix M N i k = ∑ λ j → M i j · N j k -- Properties sumVecExt : ∀ {n} → {V W : FinVec R n} → ((i : Fin n) → V i ≡ W i) → ∑ V ≡ ∑ W sumVecExt {n = zero} _ = refl sumVecExt {n = suc n} h i = h zero i + sumVecExt (h ∘ suc) i sumVecSplit : ∀ {n} → (V W : FinVec R n) → ∑ (λ i → V i + W i) ≡ ∑ V + ∑ W sumVecSplit {n = zero} V W = sym (+-rid 0r) sumVecSplit {n = suc n} V W = V zero + W zero + ∑ (λ i → V (suc i) + W (suc i)) ≡⟨ (λ i → V zero + W zero + sumVecSplit (V ∘ suc) (W ∘ suc) i) ⟩ V zero + W zero + (∑ (V ∘ suc) + ∑ (W ∘ suc)) ≡⟨ sym (+-assoc _ _ _) ⟩ V zero + (W zero + (∑ (V ∘ suc) + ∑ (W ∘ suc))) ≡⟨ cong (λ x → V zero + x) (+-assoc-comm1 _ _ _) ⟩ V zero + (∑ (V ∘ suc) + (W zero + (∑ (W ∘ suc)))) ≡⟨ +-assoc _ _ _ ⟩ V zero + ∑ (V ∘ suc) + (W zero + ∑ (W ∘ suc)) ∎ sumVec0r : (n : ℕ) → ∑ (λ (i : Fin n) → 0r) ≡ 0r sumVec0r zero = refl sumVec0r (suc n) = cong (λ x → 0r + x) (sumVec0r n) ∙ +-rid 0r sumVecExchange : ∀ {m n} → (M : FinMatrix R m n) → ∑ (λ i → ∑ (λ j → M i j)) ≡ ∑ (λ j → ∑ (λ i → M i j)) sumVecExchange {m = zero} {n = n} M = sym (sumVec0r n) sumVecExchange {m = suc m} {n = zero} M = cong (λ x → 0r + x) (sumVec0r m) ∙ +-rid 0r sumVecExchange {m = suc m} {n = suc n} M = let a = M zero zero L = ∑ λ j → M zero (suc j) C = ∑ λ i → M (suc i) zero N = ∑ λ i → ∑ λ j → M (suc i) (suc j) -- N reindexed N' = ∑ λ j → ∑ λ i → M (suc i) (suc j) in a + L + ∑ (λ i → ∑ (λ j → M (suc i) j)) ≡⟨ (λ k → a + L + sumVecSplit (λ i → M (suc i) zero) (λ i → ∑ (λ j → M (suc i) (suc j))) k) ⟩ a + L + (C + N) ≡⟨ (λ k → a + L + (C + sumVecExchange (λ i j → M (suc i) (suc j)) k)) ⟩ a + L + (C + N') ≡⟨ sym (+-assoc _ _ _) ⟩ a + (L + (C + N')) ≡⟨ (λ k → a + +-assoc-comm1 L C N' k) ⟩ a + (C + (L + N')) ≡⟨ +-assoc _ _ _ ⟩ a + C + (L + N') ≡⟨ (λ k → a + C + sumVecSplit (λ j → M zero (suc j)) (λ j → ∑ (λ i → M (suc i) (suc j))) (~ k)) ⟩ a + C + ∑ (λ j → ∑ (λ i → M i (suc j))) ∎ sumVecMulrdist : ∀ {n} → (x : R) → (V : FinVec R n) → x · ∑ V ≡ ∑ λ i → x · V i sumVecMulrdist {n = zero} x _ = 0-rightNullifies x sumVecMulrdist {n = suc n} x V = x · (V zero + ∑ (V ∘ suc)) ≡⟨ ·-rdist-+ _ _ _ ⟩ x · V zero + x · ∑ (V ∘ suc) ≡⟨ (λ i → x · V zero + sumVecMulrdist x (V ∘ suc) i) ⟩ x · V zero + ∑ (λ i → x · V (suc i)) ∎ sumVecMulldist : ∀ {n} → (x : R) → (V : FinVec R n) → (∑ V) · x ≡ ∑ λ i → V i · x sumVecMulldist {n = zero} x _ = 0-leftNullifies x sumVecMulldist {n = suc n} x V = (V zero + ∑ (V ∘ suc)) · x ≡⟨ ·-ldist-+ _ _ _ ⟩ V zero · x + (∑ (V ∘ suc)) · x ≡⟨ (λ i → V zero · x + sumVecMulldist x (V ∘ suc) i) ⟩ V zero · x + ∑ (λ i → V (suc i) · x) ∎ sumVecMulr0 : ∀ {n} → (V : FinVec R n) → ∑ (λ i → V i · 0r) ≡ 0r sumVecMulr0 V = sym (sumVecMulldist 0r V) ∙ 0-rightNullifies _ sumVecMul0r : ∀ {n} → (V : FinVec R n) → ∑ (λ i → 0r · V i) ≡ 0r sumVecMul0r V = sym (sumVecMulrdist 0r V) ∙ 0-leftNullifies _ sumVecMulr1 : (n : ℕ) (V : FinVec R n) → (j : Fin n) → ∑ (λ i → V i · (if i == j then 1r else 0r)) ≡ V j sumVecMulr1 (suc n) V zero = (λ k → ·-rid (V zero) k + sumVecMulr0 (V ∘ suc) k) ∙ +-rid (V zero) sumVecMulr1 (suc n) V (suc j) = (λ i → 0-rightNullifies (V zero) i + ∑ (λ x → V (suc x) · (if x == j then 1r else 0r))) ∙∙ +-lid _ ∙∙ sumVecMulr1 n (V ∘ suc) j sumVecMul1r : (n : ℕ) (V : FinVec R n) → (j : Fin n) → ∑ (λ i → (if j == i then 1r else 0r) · V i) ≡ V j sumVecMul1r (suc n) V zero = (λ k → ·-lid (V zero) k + sumVecMul0r (V ∘ suc) k) ∙ +-rid (V zero) sumVecMul1r (suc n) V (suc j) = (λ i → 0-leftNullifies (V zero) i + ∑ (λ i → (if j == i then 1r else 0r) · V (suc i))) ∙∙ +-lid _ ∙∙ sumVecMul1r n (V ∘ suc) j mulFinMatrixAssoc : ∀ {m n k l} → (M : FinMatrix R m n) → (N : FinMatrix R n k) → (K : FinMatrix R k l) → mulFinMatrix M (mulFinMatrix N K) ≡ mulFinMatrix (mulFinMatrix M N) K mulFinMatrixAssoc M N K = funExt₂ λ i j → ∑ (λ k → M i k · ∑ (λ l → N k l · K l j)) ≡⟨ sumVecExt (λ k → sumVecMulrdist (M i k) (λ l → N k l · K l j)) ⟩ ∑ (λ k → ∑ (λ l → M i k · (N k l · K l j))) ≡⟨ sumVecExt (λ k → sumVecExt (λ l → ·-assoc (M i k) (N k l) (K l j))) ⟩ ∑ (λ k → ∑ (λ l → M i k · N k l · K l j)) ≡⟨ sumVecExchange (λ k l → M i k · N k l · K l j) ⟩ ∑ (λ l → ∑ (λ k → M i k · N k l · K l j)) ≡⟨ sumVecExt (λ l → sym (sumVecMulldist (K l j) (λ k → M i k · N k l))) ⟩ ∑ (λ l → ∑ (λ k → M i k · N k l) · K l j) ∎ mulFinMatrixr1 : ∀ {m n} → (M : FinMatrix R m n) → mulFinMatrix M oneFinMatrix ≡ M mulFinMatrixr1 M = funExt₂ λ i j → sumVecMulr1 _ (M i) j mulFinMatrix1r : ∀ {m n} → (M : FinMatrix R m n) → mulFinMatrix oneFinMatrix M ≡ M mulFinMatrix1r M = funExt₂ λ i j → sumVecMul1r _ (λ x → M x j) i mulFinMatrixrDistrAddFinMatrix : ∀ {n} (M N K : FinMatrix R n n) → mulFinMatrix M (addFinMatrix N K) ≡ addFinMatrix (mulFinMatrix M N) (mulFinMatrix M K) mulFinMatrixrDistrAddFinMatrix M N K = funExt₂ λ i j → ∑ (λ k → M i k · (N k j + K k j)) ≡⟨ sumVecExt (λ k → ·-rdist-+ (M i k) (N k j) (K k j)) ⟩ ∑ (λ k → M i k · N k j + M i k · K k j) ≡⟨ sumVecSplit (λ k → M i k · N k j) (λ k → M i k · K k j) ⟩ ∑ (λ k → M i k · N k j) + ∑ (λ k → M i k · K k j) ∎ mulFinMatrixlDistrAddFinMatrix : ∀ {n} (M N K : FinMatrix R n n) → mulFinMatrix (addFinMatrix M N) K ≡ addFinMatrix (mulFinMatrix M K) (mulFinMatrix N K) mulFinMatrixlDistrAddFinMatrix M N K = funExt₂ λ i j → ∑ (λ k → (M i k + N i k) · K k j) ≡⟨ sumVecExt (λ k → ·-ldist-+ (M i k) (N i k) (K k j)) ⟩ ∑ (λ k → M i k · K k j + N i k · K k j) ≡⟨ sumVecSplit (λ k → M i k · K k j) (λ k → N i k · K k j) ⟩ ∑ (λ k → M i k · K k j) + ∑ (λ k → N i k · K k j) ∎ FinMatrixRing : (n : ℕ) → Ring {ℓ} FinMatrixRing n = makeRing {R = FinMatrix R n n} zeroFinMatrix oneFinMatrix addFinMatrix mulFinMatrix negFinMatrix isSetFinMatrix addFinMatrixAssoc addFinMatrix0r addFinMatrixNegMatrixr addFinMatrixComm mulFinMatrixAssoc mulFinMatrixr1 mulFinMatrix1r mulFinMatrixrDistrAddFinMatrix mulFinMatrixlDistrAddFinMatrix