Datasets:
AI4M
/

text
stringlengths
0
3.34M
section "Security Type Systems" subsection "Security Levels and Expressions" theory Sec_Type_Expr imports Big_Step begin type_synonym level = nat class sec = fixes sec :: "'a \<Rightarrow> nat" text\<open>The security/confidentiality level of each variable is globally fixed for simplicity. For the sake of examples --- the general theory does not rely on it! --- a variable of length \<open>n\<close> has security level \<open>n\<close>:\<close> instantiation list :: (type)sec begin definition "sec(x :: 'a list) = length x" instance .. end instantiation aexp :: sec begin fun sec_aexp :: "aexp \<Rightarrow> level" where "sec (N n) = 0" | "sec (V x) = sec x" | "sec (Plus a\<^sub>1 a\<^sub>2) = max (sec a\<^sub>1) (sec a\<^sub>2)" instance .. end instantiation bexp :: sec begin fun sec_bexp :: "bexp \<Rightarrow> level" where "sec (Bc v) = 0" | "sec (Not b) = sec b" | "sec (And b\<^sub>1 b\<^sub>2) = max (sec b\<^sub>1) (sec b\<^sub>2)" | "sec (Less a\<^sub>1 a\<^sub>2) = max (sec a\<^sub>1) (sec a\<^sub>2)" instance .. end abbreviation eq_le :: "state \<Rightarrow> state \<Rightarrow> level \<Rightarrow> bool" ("(_ = _ '(\<le> _'))" [51,51,0] 50) where "s = s' (\<le> l) == (\<forall> x. sec x \<le> l \<longrightarrow> s x = s' x)" abbreviation eq_less :: "state \<Rightarrow> state \<Rightarrow> level \<Rightarrow> bool" ("(_ = _ '(< _'))" [51,51,0] 50) where "s = s' (< l) == (\<forall> x. sec x < l \<longrightarrow> s x = s' x)" lemma aval_eq_if_eq_le: "\<lbrakk> s\<^sub>1 = s\<^sub>2 (\<le> l); sec a \<le> l \<rbrakk> \<Longrightarrow> aval a s\<^sub>1 = aval a s\<^sub>2" by (induct a) auto lemma bval_eq_if_eq_le: "\<lbrakk> s\<^sub>1 = s\<^sub>2 (\<le> l); sec b \<le> l \<rbrakk> \<Longrightarrow> bval b s\<^sub>1 = bval b s\<^sub>2" by (induct b) (auto simp add: aval_eq_if_eq_le) end
function [mu, varsigma] = fgplvmPosteriorMeanVar(model, X); % FGPLVMPOSTERIORMEANVAR Mean and variances of the posterior at points given by X. % FORMAT % DESC returns the posterior mean and variance for a given set of % points. % ARG model : the model for which the posterior will be computed. % ARG x : the input positions for which the posterior will be % computed. % RETURN mu : the mean of the posterior distribution. % RETURN sigma : the variances of the posterior distributions. % % SEEALSO : gpPosteriorMeanVar, fgplvmCreate % % COPYRIGHT : Neil D. Lawrence, 2005, 2006 % FGPLVM [mu, varsigma] = gpPosteriorMeanVar(model, X);
(* Copyright 2021 (C) Mihails Milehins *) section\<open>Further properties of natural numbers\<close> theory CZH_Sets_Nat imports CZH_Sets_Sets begin subsection\<open>Background\<close> text\<open> The section exposes certain fundamental properties of natural numbers and provides convenience utilities for doing arithmetic within the type \<^typ>\<open>V\<close>. Many of the results that are presented in this sections were carried over (with amendments) from the theory \<open>Nat\<close> that can be found in the main library of Isabelle/HOL. \<close> notation ord_of_nat (\<open>_\<^sub>\<nat>\<close> [999] 999) named_theorems nat_omega_simps declare One_nat_def[simp del] abbreviation (input) vpfst where "vpfst a \<equiv> a\<lparr>0\<rparr>" abbreviation (input) vpsnd where "vpsnd a \<equiv> a\<lparr>1\<^sub>\<nat>\<rparr>" abbreviation (input) vpthrd where "vpthrd a \<equiv> a\<lparr>2\<^sub>\<nat>\<rparr>" subsection\<open>Conversion between \<^typ>\<open>V\<close> and \<open>nat\<close>\<close> subsubsection\<open>Primitive arithmetic\<close> lemma ord_of_nat_plus[nat_omega_simps]: "a\<^sub>\<nat> + b\<^sub>\<nat> = (a + b)\<^sub>\<nat>" by (induct b) (simp_all add: plus_V_succ_right) lemma ord_of_nat_times[nat_omega_simps]: "a\<^sub>\<nat> * b\<^sub>\<nat> = (a * b)\<^sub>\<nat>" by (induct b) (simp_all add: mult_succ nat_omega_simps) lemma ord_of_nat_succ[nat_omega_simps]: "succ (a\<^sub>\<nat>) = (Suc a)\<^sub>\<nat>" by auto lemmas [nat_omega_simps] = nat_cadd_eq_add lemma ord_of_nat_csucc[nat_omega_simps]: "csucc (a\<^sub>\<nat>) = succ (a\<^sub>\<nat>)" using finite_csucc by blast lemma ord_of_nat_succ_vempty[nat_omega_simps]: "succ 0 = 1\<^sub>\<nat>" by auto lemma ord_of_nat_vone[nat_omega_simps]: "1 = 1\<^sub>\<nat>" by auto subsubsection\<open>Transfer\<close> definition cr_omega :: "V \<Rightarrow> nat \<Rightarrow> bool" where "cr_omega a b \<longleftrightarrow> (a = ord_of_nat b)" text\<open>Transfer setup.\<close> lemma cr_omega_right_total[transfer_rule]: "right_total cr_omega" unfolding cr_omega_def right_total_def by simp lemma cr_omega_bi_unqie[transfer_rule]: "bi_unique cr_omega" unfolding cr_omega_def bi_unique_def by (simp add: inj_eq inj_ord_of_nat) lemma omega_transfer_domain_rule[transfer_domain_rule]: "Domainp cr_omega = (\<lambda>x. x \<in>\<^sub>\<circ> \<omega>)" unfolding cr_omega_def by (auto simp: elts_\<omega>) lemma omega_transfer[transfer_rule]: "(rel_set cr_omega) (elts \<omega>) (UNIV::nat set)" unfolding cr_omega_def rel_set_def by (simp add: elts_\<omega>) lemma omega_of_real_transfer[transfer_rule]: "cr_omega (ord_of_nat a) a" unfolding cr_omega_def by auto text\<open>Operations.\<close> lemma omega_succ_transfer[transfer_rule]: includes lifting_syntax shows "(cr_omega ===> cr_omega) succ Suc" proof(intro rel_funI, unfold cr_omega_def) fix x y assume prems: "x = y\<^sub>\<nat>" show "succ x = Suc y\<^sub>\<nat>" unfolding prems ord_of_nat_succ[symmetric] .. qed lemma omega_plus_transfer[transfer_rule]: includes lifting_syntax shows "(cr_omega ===> cr_omega ===> cr_omega) (+) (+)" by (intro rel_funI, unfold cr_omega_def) (simp add: nat_omega_simps) lemma omega_mult_transfer[transfer_rule]: includes lifting_syntax shows "(cr_omega ===> cr_omega ===> cr_omega) (*) (*)" by (intro rel_funI, unfold cr_omega_def) (simp add: nat_omega_simps) lemma ord_of_nat_card_transfer[transfer_rule]: includes lifting_syntax shows "(rel_set (=) ===> cr_omega) (\<lambda>x. ord_of_nat (card x)) card" by (intro rel_funI) (simp add: cr_omega_def rel_set_eq) lemma ord_of_nat_transfer[transfer_rule]: "(rel_fun cr_omega (=)) id ord_of_nat" unfolding cr_omega_def by auto subsection\<open>Elementary results\<close> lemma ord_of_nat_vempty: "0 = 0\<^sub>\<nat>" by auto lemma set_vzero_eq_ord_of_nat_vone: "set {0} = 1\<^sub>\<nat>" by (metis elts_1 set_of_elts ord_of_nat_vone) lemma vone_in_omega[simp]: "1 \<in>\<^sub>\<circ> \<omega>" unfolding \<omega>_def by force lemma nat_of_omega: assumes "n \<in>\<^sub>\<circ> \<omega>" obtains m where "n = m\<^sub>\<nat>" using assms unfolding \<omega>_def by clarsimp lemma omega_prev: assumes "n \<in>\<^sub>\<circ> \<omega>" and "0 \<in>\<^sub>\<circ> n" obtains k where "n = succ k" proof- from assms nat_of_omega obtain m where "n = m\<^sub>\<nat>" by auto with assms(2) obtain m' where "m = Suc m'" unfolding less_V_def by (auto dest: gr0_implies_Suc) with that show ?thesis unfolding \<open>n = m\<^sub>\<nat>\<close> using ord_of_nat.simps(2) by blast qed lemma omega_vplus_commutative: assumes "a \<in>\<^sub>\<circ> \<omega>" and "b \<in>\<^sub>\<circ> \<omega>" shows "a + b = b + a" using assms by (metis Groups.add_ac(2) nat_of_omega ord_of_nat_plus) lemma omega_vinetrsection[intro]: assumes "m \<in>\<^sub>\<circ> \<omega>" and "n \<in>\<^sub>\<circ> \<omega>" shows "m \<inter>\<^sub>\<circ> n \<in>\<^sub>\<circ> \<omega>" proof- from nat_into_Ord[OF assms(1)] nat_into_Ord[OF assms(2)] Ord_linear_le consider "m \<subseteq>\<^sub>\<circ> n" | "n \<subseteq>\<^sub>\<circ> m" by auto then show ?thesis by cases (simp_all add: assms inf.absorb1 inf.absorb2) qed subsection\<open>Induction\<close> lemma omega_induct_all[consumes 1, case_names step]: assumes "n \<in>\<^sub>\<circ> \<omega>" and "\<And>x. \<lbrakk>x \<in>\<^sub>\<circ> \<omega>; \<And>y. y \<in>\<^sub>\<circ> x \<Longrightarrow> P y\<rbrakk> \<Longrightarrow> P x" shows "P n" using assms by (metis Ord_\<omega> Ord_induct Ord_linear Ord_trans nat_into_Ord) lemma omega_induct[consumes 1, case_names 0 succ]: assumes "n \<in>\<^sub>\<circ> \<omega>" and "P 0" and "\<And>n. \<lbrakk> n \<in>\<^sub>\<circ> \<omega>; P n \<rbrakk> \<Longrightarrow> P (succ n)" shows "P n" using assms(1,3) proof(induct rule: omega_induct_all) case (step x) show ?case proof(cases \<open>x = 0\<close>) case True with assms(2) show ?thesis by simp next case False with step(1) have "0 \<in>\<^sub>\<circ> x" by (simp add: mem_0_Ord) with \<open>x \<in>\<^sub>\<circ> \<omega>\<close> obtain y where x_def: "x = succ y" by (elim omega_prev) with elts_succ step.hyps(1) have "y \<in>\<^sub>\<circ> \<omega>" by (blast intro: Ord_trans) have "y \<in>\<^sub>\<circ> x" by (simp add: \<open>x = succ y\<close>) have "P y" by (auto intro: step.prems step.hyps(2)[OF \<open>y \<in>\<^sub>\<circ> x\<close>]) from step.prems[OF \<open>y \<in>\<^sub>\<circ> \<omega>\<close> \<open>P y\<close>, folded x_def] show "P x" . qed qed subsection\<open>Methods\<close> text\<open> The following methods provide an infrastructure for working with goals of the form \<open>a \<in>\<^sub>\<circ> n\<^sub>\<nat> \<Longrightarrow> P a\<close>. \<close> lemma in_succE: assumes "a \<in>\<^sub>\<circ> succ n" and "\<And>a. a \<in>\<^sub>\<circ> n \<Longrightarrow> P a" and "P n" shows "P a" using assms by auto method Suc_of_numeral = ( unfold numeral.simps add.assoc, use nothing in \<open>unfold Suc_eq_plus1_left[symmetric], unfold One_nat_def\<close> ) method succ_of_numeral = ( Suc_of_numeral, use nothing in \<open>unfold ord_of_nat_succ[symmetric] ord_of_nat_zero\<close> ) method numeral_of_succ = ( unfold nat_omega_simps, use nothing in \<open> unfold numeral.simps[symmetric] Suc_numeral add_num_simps, (unfold numerals(1))? \<close> ) method elim_in_succ = ( ( elim in_succE; use nothing in \<open>(unfold triv_forall_equality)?; (numeral_of_succ)?\<close> ), simp ) method elim_in_numeral = (succ_of_numeral, use nothing in \<open>elim_in_succ\<close>) subsection\<open>Auxiliary\<close> lemma one: "1\<^sub>\<nat> = set {0}" by auto lemma two: "2\<^sub>\<nat> = set {0, 1\<^sub>\<nat>}" by force lemma three: "3\<^sub>\<nat> = set {0, 1\<^sub>\<nat>, 2\<^sub>\<nat>}" by force lemma four: "4\<^sub>\<nat> = set {0, 1\<^sub>\<nat>, 2\<^sub>\<nat>, 3\<^sub>\<nat>}" by force lemma two_vdiff_zero[simp]: "set {0, 1\<^sub>\<nat>} -\<^sub>\<circ> set {0} = set {1\<^sub>\<nat>}" by auto lemma two_vdiff_one[simp]: "set {0, 1\<^sub>\<nat>} -\<^sub>\<circ> set {1\<^sub>\<nat>} = set {0}" by auto text\<open>\newpage\<close> end
Formal statement is: lemma reduced_labelling_zero: "j < n \<Longrightarrow> x j = 0 \<Longrightarrow> reduced n x \<noteq> j" Informal statement is: If $x_j = 0$ and $j < n$, then $j$ is not the reduced labelling of $x$.
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Homotopy.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv.Properties private variable ℓ ℓ' : Level _∼_ : {X : Type ℓ} {Y : X → Type ℓ'} → (f g : (x : X) → Y x) → Type (ℓ-max ℓ ℓ') _∼_ {X = X} f g = (x : X) → f x ≡ g x funExt∼ : {X : Type ℓ} {Y : X → Type ℓ'} {f g : (x : X) → Y x} (H : f ∼ g) → f ≡ g funExt∼ = funExt ∼-refl : {X : Type ℓ} {Y : X → Type ℓ'} {f : (x : X) → Y x} → f ∼ f ∼-refl {f = f} = λ x → refl {x = f x}
/- Copyright (c) 2022 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies ! This file was ported from Lean 3 source module order.heyting.regular ! leanprover-community/mathlib commit 09597669f02422ed388036273d8848119699c22f ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathlib.Order.GaloisConnection /-! # Heyting regular elements This file defines Heyting regular elements, elements of an Heyting algebra that are their own double complement, and proves that they form a boolean algebra. From a logic standpoint, this means that we can perform classical logic within intuitionistic logic by simply double-negating all propositions. This is practical for synthetic computability theory. ## Main declarations * `IsRegular`: `a` is Heyting-regular if `aᶜᶜ = a`. * `Regular`: The subtype of Heyting-regular elements. * `Regular.BooleanAlgebra`: Heyting-regular elements form a boolean algebra. ## References * [Francis Borceux, *Handbook of Categorical Algebra III*][borceux-vol3] -/ open Function variable {α : Type _} namespace Heyting section HasCompl variable [HasCompl α] {a : α} /-- An element of an Heyting algebra is regular if its double complement is itself. -/ def IsRegular (a : α) : Prop := aᶜᶜ = a #align heyting.is_regular Heyting.IsRegular protected theorem IsRegular.eq : IsRegular a → aᶜᶜ = a := id #align heyting.is_regular.eq Heyting.IsRegular.eq instance IsRegular.decidablePred [DecidableEq α] : @DecidablePred α IsRegular := fun _ => ‹DecidableEq α› _ _ #align heyting.is_regular.decidable_pred Heyting.IsRegular.decidablePred end HasCompl section HeytingAlgebra variable [HeytingAlgebra α] {a b : α} theorem isRegular_bot : IsRegular (⊥ : α) := by rw [IsRegular, compl_bot, compl_top] #align heyting.is_regular_bot Heyting.isRegular_bot theorem isRegular_top : IsRegular (⊤ : α) := by rw [IsRegular, compl_top, compl_bot] #align heyting.is_regular_top Heyting.isRegular_top theorem IsRegular.inf (ha : IsRegular a) (hb : IsRegular b) : IsRegular (a ⊓ b) := by rw [IsRegular, compl_compl_inf_distrib, ha.eq, hb.eq] #align heyting.is_regular.inf Heyting.IsRegular.inf theorem IsRegular.himp (ha : IsRegular a) (hb : IsRegular b) : IsRegular (a ⇨ b) := by rw [IsRegular, compl_compl_himp_distrib, ha.eq, hb.eq] #align heyting.is_regular.himp Heyting.IsRegular.himp theorem isRegular_compl (a : α) : IsRegular (aᶜ) := compl_compl_compl _ #align heyting.is_regular_compl Heyting.isRegular_compl protected theorem IsRegular.disjoint_compl_left_iff (ha : IsRegular a) : Disjoint (aᶜ) b ↔ b ≤ a := by rw [← le_compl_iff_disjoint_left, ha.eq] #align heyting.is_regular.disjoint_compl_left_iff Heyting.IsRegular.disjoint_compl_left_iff protected theorem IsRegular.disjoint_compl_right_iff (hb : IsRegular b) : Disjoint a (bᶜ) ↔ a ≤ b := by rw [← le_compl_iff_disjoint_right, hb.eq] #align heyting.is_regular.disjoint_compl_right_iff Heyting.IsRegular.disjoint_compl_right_iff -- See note [reducible non-instances] /-- A Heyting algebra with regular excluded middle is a boolean algebra. -/ @[reducible] def _root_.BooleanAlgebra.ofRegular (h : ∀ a : α, IsRegular (a ⊔ aᶜ)) : BooleanAlgebra α := have : ∀ a : α, IsCompl a (aᶜ) := fun a => ⟨disjoint_compl_right, codisjoint_iff.2 <| by erw [← (h a), compl_sup, inf_compl_eq_bot, compl_bot]⟩ { ‹HeytingAlgebra α›, GeneralizedHeytingAlgebra.toDistribLattice with himp_eq := fun a b => eq_of_forall_le_iff fun c => le_himp_iff.trans (this _).le_sup_right_iff_inf_left_le.symm inf_compl_le_bot := fun a => (this _).1.le_bot top_le_sup_compl := fun a => (this _).2.top_le } #align boolean_algebra.of_regular BooleanAlgebra.ofRegular variable (α) /-- The boolean algebra of Heyting regular elements. -/ def Regular : Type _ := { a : α // IsRegular a } #align heyting.regular Heyting.Regular variable {α} namespace Regular --Porting note: `val` and `prop` are new /-- The coercion `Regular α → α` -/ @[coe] def val : Regular α → α := Subtype.val theorem prop : ∀ a : Regular α, IsRegular a.val := Subtype.prop instance : Coe (Regular α) α := ⟨Regular.val⟩ theorem coe_injective : Injective ((↑) : Regular α → α) := Subtype.coe_injective #align heyting.regular.coe_injective Heyting.Regular.coe_injective @[simp] theorem coe_inj {a b : Regular α} : (a : α) = b ↔ a = b := Subtype.coe_inj #align heyting.regular.coe_inj Heyting.Regular.coe_inj instance top : Top (Regular α) := ⟨⟨⊤, isRegular_top⟩⟩ instance bot : Bot (Regular α) := ⟨⟨⊥, isRegular_bot⟩⟩ instance inf : Inf (Regular α) := ⟨fun a b => ⟨a ⊓ b, a.2.inf b.2⟩⟩ instance himp : HImp (Regular α) := ⟨fun a b => ⟨a ⇨ b, a.2.himp b.2⟩⟩ instance hasCompl : HasCompl (Regular α) := ⟨fun a => ⟨aᶜ, isRegular_compl _⟩⟩ @[simp, norm_cast] theorem coe_top : ((⊤ : Regular α) : α) = ⊤ := rfl #align heyting.regular.coe_top Heyting.Regular.coe_top @[simp, norm_cast] theorem coe_bot : ((⊥ : Regular α) : α) = ⊥ := rfl #align heyting.regular.coe_bot Heyting.Regular.coe_bot @[simp, norm_cast] theorem coe_inf (a b : Regular α) : (↑(a ⊓ b) : α) = (a : α) ⊓ b := rfl #align heyting.regular.coe_inf Heyting.Regular.coe_inf @[simp, norm_cast] theorem coe_himp (a b : Regular α) : (↑(a ⇨ b) : α) = (a : α) ⇨ b := rfl #align heyting.regular.coe_himp Heyting.Regular.coe_himp @[simp, norm_cast] theorem coe_compl (a : Regular α) : (↑(aᶜ) : α) = (a : α)ᶜ := rfl #align heyting.regular.coe_compl Heyting.Regular.coe_compl instance : Inhabited (Regular α) := ⟨⊥⟩ instance : SemilatticeInf (Regular α) := coe_injective.semilatticeInf _ coe_inf instance boundedOrder : BoundedOrder (Regular α) := BoundedOrder.lift ((↑) : Regular α → α) (fun _ _ => id) coe_top coe_bot @[simp, norm_cast] theorem coe_le_coe {a b : Regular α} : (a : α) ≤ b ↔ a ≤ b := Iff.rfl #align heyting.regular.coe_le_coe Heyting.Regular.coe_le_coe @[simp, norm_cast] theorem coe_lt_coe {a b : Regular α} : (a : α) < b ↔ a < b := Iff.rfl #align heyting.regular.coe_lt_coe Heyting.Regular.coe_lt_coe /-- **Regularization** of `a`. The smallest regular element greater than `a`. -/ def toRegular : α →o Regular α := ⟨fun a => ⟨aᶜᶜ, isRegular_compl _⟩, fun _ _ h => coe_le_coe.1 <| compl_le_compl <| compl_le_compl h⟩ #align heyting.regular.to_regular Heyting.Regular.toRegular @[simp, norm_cast] theorem coe_toRegular (a : α) : (toRegular a : α) = aᶜᶜ := rfl #align heyting.regular.coe_to_regular Heyting.Regular.coe_toRegular @[simp] theorem toRegular_coe (a : Regular α) : toRegular (a : α) = a := coe_injective a.2 #align heyting.regular.to_regular_coe Heyting.Regular.toRegular_coe /-- The Galois insertion between `Regular.toRegular` and `coe`. -/ def gi : GaloisInsertion toRegular ((↑) : Regular α → α) where choice a ha := ⟨a, ha.antisymm le_compl_compl⟩ gc _ b := coe_le_coe.symm.trans <| ⟨le_compl_compl.trans, fun h => (compl_anti <| compl_anti h).trans_eq b.2⟩ le_l_u _ := le_compl_compl choice_eq _ ha := coe_injective <| le_compl_compl.antisymm ha #align heyting.regular.gi Heyting.Regular.gi instance lattice : Lattice (Regular α) := gi.liftLattice @[simp, norm_cast] theorem coe_sup (a b : Regular α) : (↑(a ⊔ b) : α) = ((a : α) ⊔ b)ᶜᶜ := rfl #align heyting.regular.coe_sup Heyting.Regular.coe_sup instance : BooleanAlgebra (Regular α) := { Regular.lattice, Regular.boundedOrder, Regular.himp, Regular.hasCompl with le_sup_inf := fun a b c => coe_le_coe.1 <| by dsimp rw [sup_inf_left, compl_compl_inf_distrib] inf_compl_le_bot := fun a => coe_le_coe.1 <| disjoint_iff_inf_le.1 disjoint_compl_right top_le_sup_compl := fun a => coe_le_coe.1 <| by dsimp rw [compl_sup, inf_compl_eq_bot, compl_bot] himp_eq := fun a b => coe_injective (by dsimp rw [compl_sup, a.prop.eq] refine' eq_of_forall_le_iff fun c => le_himp_iff.trans _ rw [le_compl_iff_disjoint_right, disjoint_left_comm] rw [b.prop.disjoint_compl_left_iff]) } @[simp, norm_cast] theorem coe_sdiff (a b : Regular α) : (↑(a \ b) : α) = (a : α) ⊓ bᶜ := rfl #align heyting.regular.coe_sdiff Heyting.Regular.coe_sdiff end Regular end HeytingAlgebra variable [BooleanAlgebra α] theorem isRegular_of_boolean : ∀ a : α, IsRegular a := compl_compl #align heyting.is_regular_of_boolean Heyting.isRegular_of_boolean /-- A decidable proposition is intuitionistically Heyting-regular. -/ --Porting note: removed @[nolint decidable_classical] theorem isRegular_of_decidable (p : Prop) [Decidable p] : IsRegular p := propext <| Decidable.not_not #align heyting.is_regular_of_decidable Heyting.isRegular_of_decidable end Heyting
If $f$ and $g$ are holomorphic functions on an open set $S$, then the $n$th derivative of $f - g$ is equal to the $n$th derivative of $f$ minus the $n$th derivative of $g$.
1987 : From the Jewish Question to the Jewish State : An Essay on the Theory of Zionism ( thesis ) , Princeton University .
If $f$ and $g$ tend to $a$ and $b$, respectively, then the function $x \mapsto (f(x), g(x))$ tends to $(a, b)$.
Formal statement is: proposition homeomorphic_ball_UNIV: fixes a ::"'a::real_normed_vector" assumes "0 < r" shows "ball a r homeomorphic (UNIV:: 'a set)" Informal statement is: For any $r > 0$, the open ball of radius $r$ centered at $a$ is homeomorphic to $\mathbb{R}^n$.
[STATEMENT] lemma greek_less_app_mono2: assumes "trans r" and "(s, t) \<in> greek_less r" shows "(p @ s, p @ t) \<in> greek_less r" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (p @ s, p @ t) \<in> greek_less r [PROOF STEP] using assms [PROOF STATE] proof (prove) using this: trans r (s, t) \<in> greek_less r goal (1 subgoal): 1. (p @ s, p @ t) \<in> greek_less r [PROOF STEP] by (induct p) (auto simp add: greek_less_cons_mono)
/- Copyright (c) 2021 Riccardo Brasca. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Riccardo Brasca -/ import linear_algebra.free_module.finite.basic import linear_algebra.matrix.charpoly.coeff import field_theory.minpoly /-! # Characteristic polynomial We define the characteristic polynomial of `f : M →ₗ[R] M`, where `M` is a finite and free `R`-module. The proof that `f.charpoly` is the characteristic polynomial of the matrix of `f` in any basis is in `linear_algebra/charpoly/to_matrix`. ## Main definition * `linear_map.charpoly f` : the characteristic polynomial of `f : M →ₗ[R] M`. -/ universes u v w variables {R : Type u} {M : Type v} [comm_ring R] [nontrivial R] variables [add_comm_group M] [module R M] [module.free R M] [module.finite R M] (f : M →ₗ[R] M) open_locale classical matrix polynomial noncomputable theory open module.free polynomial matrix namespace linear_map section basic /-- The characteristic polynomial of `f : M →ₗ[R] M`. -/ def charpoly : R[X] := (to_matrix (choose_basis R M) (choose_basis R M) f).charpoly lemma charpoly_def : f.charpoly = (to_matrix (choose_basis R M) (choose_basis R M) f).charpoly := rfl end basic section coeff lemma charpoly_monic : f.charpoly.monic := charpoly_monic _ end coeff section cayley_hamilton /-- The **Cayley-Hamilton Theorem**, that the characteristic polynomial of a linear map, applied to the linear map itself, is zero. See `matrix.aeval_self_charpoly` for the equivalent statement about matrices. -/ lemma aeval_self_charpoly : aeval f f.charpoly = 0 := begin apply (linear_equiv.map_eq_zero_iff (alg_equiv_matrix _).to_linear_equiv).1, rw [alg_equiv.to_linear_equiv_apply, ← alg_equiv.coe_alg_hom, ← polynomial.aeval_alg_hom_apply _ _ _, charpoly_def], exact aeval_self_charpoly _, end lemma is_integral : is_integral R f := ⟨f.charpoly, ⟨charpoly_monic f, aeval_self_charpoly f⟩⟩ lemma minpoly_dvd_charpoly {K : Type u} {M : Type v} [field K] [add_comm_group M] [module K M] [finite_dimensional K M] (f : M →ₗ[K] M) : minpoly K f ∣ f.charpoly := minpoly.dvd _ _ (aeval_self_charpoly f) /-- Any endomorphism polynomial `p` is equivalent under evaluation to `p %ₘ f.charpoly`; that is, `p` is equivalent to a polynomial with degree less than the dimension of the module. -/ lemma aeval_eq_aeval_mod_charpoly (p : R[X]) : aeval f p = aeval f (p %ₘ f.charpoly) := (aeval_mod_by_monic_eq_self_of_root f.charpoly_monic f.aeval_self_charpoly).symm /-- Any endomorphism power can be computed as the sum of endomorphism powers less than the dimension of the module. -/ lemma pow_eq_aeval_mod_charpoly (k : ℕ) : f^k = aeval f (X^k %ₘ f.charpoly) := by rw [←aeval_eq_aeval_mod_charpoly, map_pow, aeval_X] variable {f} lemma minpoly_coeff_zero_of_injective (hf : function.injective f) : (minpoly R f).coeff 0 ≠ 0 := begin intro h, obtain ⟨P, hP⟩ := X_dvd_iff.2 h, have hdegP : P.degree < (minpoly R f).degree, { rw [hP, mul_comm], refine degree_lt_degree_mul_X (λ h, _), rw [h, mul_zero] at hP, exact minpoly.ne_zero (is_integral f) hP }, have hPmonic : P.monic, { suffices : (minpoly R f).monic, { rwa [monic.def, hP, mul_comm, leading_coeff_mul_X, ← monic.def] at this }, exact minpoly.monic (is_integral f) }, have hzero : aeval f (minpoly R f) = 0 := minpoly.aeval _ _, simp only [hP, mul_eq_comp, ext_iff, hf, aeval_X, map_eq_zero_iff, coe_comp, alg_hom.map_mul, zero_apply] at hzero, exact not_le.2 hdegP (minpoly.min _ _ hPmonic (ext hzero)), end end cayley_hamilton end linear_map
module Modulo import Data.Fin %access export %default total add : Fin k -> Fin k -> Fin k add {k=S k} n m = restrict k $ finToInteger n + finToInteger m negate : Fin k -> Fin k negate {k=S k} n = restrict k $ toIntegerNat (S k) - finToInteger n subt : Fin k -> Fin k -> Fin k subt {k=S k} n m = restrict k $ finToInteger n - finToInteger m + toIntegerNat (S k) mult : Fin k -> Fin k -> Fin k mult {k=S k} n m = restrict k $ finToInteger n * finToInteger m
module Lemmachine.Default where open import Lemmachine resource : Hooks resource = [] main = runResolve (toApp resource)
[STATEMENT] lemma sort_of_Rep_perm: "sort_of (Rep_perm p a) = sort_of a" [PROOF STATE] proof (prove) goal (1 subgoal): 1. sort_of (Rep_perm p a) = sort_of a [PROOF STEP] using Rep_perm [of p] [PROOF STATE] proof (prove) using this: Rep_perm p \<in> perm goal (1 subgoal): 1. sort_of (Rep_perm p a) = sort_of a [PROOF STEP] unfolding perm_def [PROOF STATE] proof (prove) using this: Rep_perm p \<in> {f. bij f \<and> finite {a. f a \<noteq> a} \<and> (\<forall>a. sort_of (f a) = sort_of a)} goal (1 subgoal): 1. sort_of (Rep_perm p a) = sort_of a [PROOF STEP] by simp
{-# LANGUAGE FlexibleContexts #-} -- | -- Module : System.Random.MWC.CondensedTable -- Copyright : (c) 2012 Aleksey Khudyakov -- License : BSD3 -- -- Maintainer : [email protected] -- Stability : experimental -- Portability : portable -- -- Table-driven generation of random variates. This approach can -- generate random variates in /O(1)/ time for the supported -- distributions, at a modest cost in initialization time. module System.Random.MWC.CondensedTable ( -- * Condensed tables CondensedTable , CondensedTableV , CondensedTableU , genFromTable -- * Constructors for tables , tableFromProbabilities , tableFromWeights , tableFromIntWeights -- ** Disrete distributions , tablePoisson , tableBinomial -- * References -- $references ) where import Control.Arrow (second,(***)) import Data.Word import Data.Int import Data.Bits import qualified Data.Vector.Generic as G import Data.Vector.Generic ((++)) import qualified Data.Vector.Generic.Mutable as M import qualified Data.Vector.Unboxed as U import qualified Data.Vector as V import Data.Vector.Generic (Vector) import Numeric.SpecFunctions (logFactorial) import System.Random.Stateful import Prelude hiding ((++)) -- | A lookup table for arbitrary discrete distributions. It allows -- the generation of random variates in /O(1)/. Note that probability -- is quantized in units of @1/2^32@, and all distributions with -- infinite support (e.g. Poisson) should be truncated. data CondensedTable v a = CondensedTable {-# UNPACK #-} !Word64 !(v a) -- Lookup limit and first table {-# UNPACK #-} !Word64 !(v a) -- Second table {-# UNPACK #-} !Word64 !(v a) -- Third table !(v a) -- Last table -- Implementation note. We have to store lookup limit in Word64 since -- we need to accomodate two cases. First is when we have no values in -- lookup table, second is when all elements are there -- -- Both are pretty easy to realize. For first one probability of every -- outcome should be less then 1/256, latter arise when probabilities -- of two outcomes are [0.5,0.5] -- | A 'CondensedTable' that uses unboxed vectors. type CondensedTableU = CondensedTable U.Vector -- | A 'CondensedTable' that uses boxed vectors, and is able to hold -- any type of element. type CondensedTableV = CondensedTable V.Vector -- | Generate a random value using a condensed table. genFromTable :: (StatefulGen g m, Vector v a) => CondensedTable v a -> g -> m a {-# INLINE genFromTable #-} genFromTable table gen = do w <- uniformM gen return $ lookupTable table $ fromIntegral (w :: Word32) lookupTable :: Vector v a => CondensedTable v a -> Word64 -> a {-# INLINE lookupTable #-} lookupTable (CondensedTable na aa nb bb nc cc dd) i | i < na = aa `at` ( i `shiftR` 24) | i < nb = bb `at` ((i - na) `shiftR` 16) | i < nc = cc `at` ((i - nb) `shiftR` 8 ) | otherwise = dd `at` ( i - nc) where at arr j = G.unsafeIndex arr (fromIntegral j) ---------------------------------------------------------------- -- Table generation ---------------------------------------------------------------- -- | Generate a condensed lookup table from a list of outcomes with -- given probabilities. The vector should be non-empty and the -- probabilites should be non-negative and sum to 1. If this is not -- the case, this algorithm will construct a table for some -- distribution that may bear no resemblance to what you intended. tableFromProbabilities :: (Vector v (a,Word32), Vector v (a,Double), Vector v a, Vector v Word32) => v (a, Double) -> CondensedTable v a {-# INLINE tableFromProbabilities #-} tableFromProbabilities v | G.null tbl = pkgError "tableFromProbabilities" "empty vector of outcomes" | otherwise = tableFromIntWeights $ G.map (second $ toWeight . (* mlt)) tbl where -- 2^32. N.B. This number is exatly representable. mlt = 4.294967296e9 -- Drop non-positive probabilities tbl = G.filter ((> 0) . snd) v -- Convert Double weight to Word32 and avoid overflow at the same -- time. It's especially dangerous if one probability is -- approximately 1 and others are 0. toWeight w | w > mlt - 1 = 2^(32::Int) - 1 | otherwise = round w -- | Same as 'tableFromProbabilities' but treats number as weights not -- probilities. Non-positive weights are discarded, and those -- remaining are normalized to 1. tableFromWeights :: (Vector v (a,Word32), Vector v (a,Double), Vector v a, Vector v Word32) => v (a, Double) -> CondensedTable v a {-# INLINE tableFromWeights #-} tableFromWeights = tableFromProbabilities . normalize . G.filter ((> 0) . snd) where normalize v | G.null v = pkgError "tableFromWeights" "no positive weights" | otherwise = G.map (second (/ s)) v where -- Explicit fold is to avoid 'Vector v Double' constraint s = G.foldl' (flip $ (+) . snd) 0 v -- | Generate a condensed lookup table from integer weights. Weights -- should sum to @2^32@ at least approximately. This function will -- correct small deviations from @2^32@ such as arising from rounding -- errors. But for large deviations it's likely to product incorrect -- result with terrible performance. tableFromIntWeights :: (Vector v (a,Word32), Vector v a, Vector v Word32) => v (a, Word32) -> CondensedTable v a {-# INLINE tableFromIntWeights #-} tableFromIntWeights v | n == 0 = pkgError "tableFromIntWeights" "empty table" -- Single element tables should be treated sepately. Otherwise -- they will confuse correctWeights | n == 1 = let m = 2^(32::Int) - 1 -- Works for both Word32 & Word64 in CondensedTable m (G.replicate 256 $ fst $ G.head tbl) m G.empty m G.empty G.empty | otherwise = CondensedTable na aa nb bb nc cc dd where -- We must filter out zero-probability outcomes because they may -- confuse weight correction algorithm tbl = G.filter ((/=0) . snd) v n = G.length tbl -- Corrected table table = uncurry G.zip $ id *** correctWeights $ G.unzip tbl -- Make condensed table mkTable d = G.concatMap (\(x,w) -> G.replicate (fromIntegral $ digit d w) x) table len = fromIntegral . G.length -- Tables aa = mkTable 0 bb = mkTable 1 cc = mkTable 2 dd = mkTable 3 -- Offsets na = len aa `shiftL` 24 nb = na + (len bb `shiftL` 16) nc = nb + (len cc `shiftL` 8) -- Calculate N'th digit base 256 digit :: Int -> Word32 -> Word32 digit 0 x = x `shiftR` 24 digit 1 x = (x `shiftR` 16) .&. 0xff digit 2 x = (x `shiftR` 8 ) .&. 0xff digit 3 x = x .&. 0xff digit _ _ = pkgError "digit" "the impossible happened!?" {-# INLINE digit #-} -- Correct integer weights so they sum up to 2^32. Array of weight -- should contain at least 2 elements. correctWeights :: G.Vector v Word32 => v Word32 -> v Word32 {-# INLINE correctWeights #-} correctWeights v = G.create $ do let -- Sum of weights s = G.foldl' (flip $ (+) . fromIntegral) 0 v :: Int64 -- Array size n = G.length v arr <- G.thaw v -- On first pass over array adjust only entries which are larger -- than `lim'. On second and subsequent passes `lim' is set to 1. -- -- It's possibly to make this algorithm loop endlessly if all -- weights are 1 or 0. let loop lim i delta | delta == 0 = return () | i >= n = loop 1 0 delta | otherwise = do w <- M.read arr i case () of _| w < lim -> loop lim (i+1) delta | delta < 0 -> M.write arr i (w + 1) >> loop lim (i+1) (delta + 1) | otherwise -> M.write arr i (w - 1) >> loop lim (i+1) (delta - 1) loop 255 0 (s - 2^(32::Int)) return arr -- | Create a lookup table for the Poisson distibution. Note that -- table construction may have significant cost. For &#955; < 100 it -- takes as much time to build table as generation of 1000-30000 -- variates. tablePoisson :: Double -> CondensedTableU Int tablePoisson = tableFromProbabilities . make where make lam | lam < 0 = pkgError "tablePoisson" "negative lambda" | lam < 22.8 = U.unfoldr unfoldForward (exp (-lam), 0) | otherwise = U.unfoldr unfoldForward (pMax, nMax) ++ U.tail (U.unfoldr unfoldBackward (pMax, nMax)) where -- Number with highest probability and its probability -- -- FIXME: this is not ideal precision-wise. Check if code -- from statistics gives better precision. nMax = floor lam :: Int pMax = exp $ fromIntegral nMax * log lam - lam - logFactorial nMax -- Build probability list unfoldForward (p,i) | p < minP = Nothing | otherwise = Just ( (i,p) , (p * lam / fromIntegral (i+1), i+1) ) -- Go down unfoldBackward (p,i) | p < minP = Nothing | otherwise = Just ( (i,p) , (p / lam * fromIntegral i, i-1) ) -- Minimal representable probability for condensed tables minP = 1.1641532182693481e-10 -- 2**(-33) -- | Create a lookup table for the binomial distribution. tableBinomial :: Int -- ^ Number of tries -> Double -- ^ Probability of success -> CondensedTableU Int tableBinomial n p = tableFromProbabilities makeBinom where makeBinom | n <= 0 = pkgError "tableBinomial" "non-positive number of tries" | p == 0 = U.singleton (0,1) | p == 1 = U.singleton (n,1) | p > 0 && p < 1 = U.unfoldrN (n + 1) unfolder ((1-p)^n, 0) | otherwise = pkgError "tableBinomial" "probability is out of range" where h = p / (1 - p) unfolder (t,i) = Just ( (i,t) , (t * (fromIntegral $ n + 1 - i1) * h / fromIntegral i1, i1) ) where i1 = i + 1 pkgError :: String -> String -> a pkgError func err = error . concat $ ["System.Random.MWC.CondensedTable.", func, ": ", err] -- $references -- -- * Wang, J.; Tsang, W. W.; G. Marsaglia (2004), Fast Generation of -- Discrete Random Variables, /Journal of Statistical Software, -- American Statistical Association/, vol. 11(i03). -- <http://ideas.repec.org/a/jss/jstsof/11i03.html>
/* @copyright Louis Dionne 2015 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #include <boost/hana/assert.hpp> #include <boost/hana/equal.hpp> #include <boost/hana/integral_constant.hpp> #include <boost/hana/zero.hpp> namespace hana = boost::hana; BOOST_HANA_CONSTANT_CHECK(hana::zero<hana::integral_constant_tag<int>>() == hana::int_c<0>); static_assert(hana::zero<long>() == 0l, ""); int main() { }
Formal statement is: lemma arg_unique: assumes "sgn z = cis x" and "-pi < x" and "x \<le> pi" shows "arg z = x" Informal statement is: If $z$ is a complex number with $|z| = 1$ and $-\pi < x \leq \pi$, then $z = \cos(x) + i \sin(x)$ if and only if $x = \arg(z)$.
[STATEMENT] lemma redT_new_thread: assumes "s -t'\<triangleright>ta\<rightarrow> s'" "thr s' t = \<lfloor>(x, w)\<rfloor>" "thr s t = None" "\<lbrace>ta\<rbrace>\<^bsub>w\<^esub> = []" shows "NewThread t x (shr s') \<in> set \<lbrace>ta\<rbrace>\<^bsub>t\<^esub> \<and> w = no_wait_locks" [PROOF STATE] proof (prove) goal (1 subgoal): 1. NewThread t x (shr s') \<in> set \<lbrace>ta\<rbrace>\<^bsub>t\<^esub> \<and> w = no_wait_locks [PROOF STEP] using assms [PROOF STATE] proof (prove) using this: s -t'\<triangleright>ta\<rightarrow> s' thr s' t = \<lfloor>(x, w)\<rfloor> thr s t = None \<lbrace>ta\<rbrace>\<^bsub>w\<^esub> = [] goal (1 subgoal): 1. NewThread t x (shr s') \<in> set \<lbrace>ta\<rbrace>\<^bsub>t\<^esub> \<and> w = no_wait_locks [PROOF STEP] apply(cases rule: redT_elims) [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<And>xa x' m' ws'. \<lbrakk>thr s' t = \<lfloor>(x, w)\<rfloor>; thr s t = None; \<lbrace>ta\<rbrace>\<^bsub>w\<^esub> = []; t' \<turnstile> \<langle>xa, shr s\<rangle> -ta\<rightarrow> \<langle>x', m'\<rangle>; thr s t' = \<lfloor>(xa, no_wait_locks)\<rfloor>; lock_ok_las (locks s) t' \<lbrace>ta\<rbrace>\<^bsub>l\<^esub>; thread_oks (thr s) \<lbrace>ta\<rbrace>\<^bsub>t\<^esub>; cond_action_oks s t' \<lbrace>ta\<rbrace>\<^bsub>c\<^esub>; wset_actions_ok (wset s) t' \<lbrace>ta\<rbrace>\<^bsub>w\<^esub>; interrupt_actions_ok (interrupts s) \<lbrace>ta\<rbrace>\<^bsub>i\<^esub>; redT_updWs t' (wset s) \<lbrace>ta\<rbrace>\<^bsub>w\<^esub> ws'; s' = (redT_updLs (locks s) t' \<lbrace>ta\<rbrace>\<^bsub>l\<^esub>, (redT_updTs (thr s) \<lbrace>ta\<rbrace>\<^bsub>t\<^esub>(t' \<mapsto> (x', redT_updLns (locks s) t' no_wait_locks \<lbrace>ta\<rbrace>\<^bsub>l\<^esub>)), m'), ws', redT_updIs (interrupts s) \<lbrace>ta\<rbrace>\<^bsub>i\<^esub>)\<rbrakk> \<Longrightarrow> NewThread t x (shr s') \<in> set \<lbrace>ta\<rbrace>\<^bsub>t\<^esub> \<and> w = no_wait_locks 2. \<And>xa ln n. \<lbrakk>thr s' t = \<lfloor>(x, w)\<rfloor>; thr s t = None; \<lbrace>ta\<rbrace>\<^bsub>w\<^esub> = []; thr s t' = \<lfloor>(xa, ln)\<rfloor>; ta = (K$ [], [], [], [], [], convert_RA ln); \<not> waiting (wset s t'); may_acquire_all (locks s) t' ln; 0 < ln $ n; s' = (acquire_all (locks s) t' ln, (thr s(t' \<mapsto> (xa, no_wait_locks)), shr s), wset s, interrupts s)\<rbrakk> \<Longrightarrow> NewThread t x (shr s') \<in> set \<lbrace>ta\<rbrace>\<^bsub>t\<^esub> \<and> w = no_wait_locks [PROOF STEP] apply(auto split: if_split_asm del: conjI elim!: rtrancl3p_cases) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>xa x' m' ws'. \<lbrakk>thr s t = None; \<lbrace>ta\<rbrace>\<^bsub>w\<^esub> = []; t' \<turnstile> \<langle>xa, shr s\<rangle> -ta\<rightarrow> \<langle>x', m'\<rangle>; thr s t' = \<lfloor>(xa, no_wait_locks)\<rfloor>; lock_ok_las (locks s) t' \<lbrace>ta\<rbrace>\<^bsub>l\<^esub>; thread_oks (thr s) \<lbrace>ta\<rbrace>\<^bsub>t\<^esub>; cond_action_oks s t' \<lbrace>ta\<rbrace>\<^bsub>c\<^esub>; wset s t' = None; interrupt_actions_ok (interrupts s) \<lbrace>ta\<rbrace>\<^bsub>i\<^esub>; redT_updWs t' (wset s) [] ws'; s' = (redT_updLs (locks s) t' \<lbrace>ta\<rbrace>\<^bsub>l\<^esub>, (redT_updTs (thr s) \<lbrace>ta\<rbrace>\<^bsub>t\<^esub>(t' \<mapsto> (x', redT_updLns (locks s) t' no_wait_locks \<lbrace>ta\<rbrace>\<^bsub>l\<^esub>)), m'), ws', redT_updIs (interrupts s) \<lbrace>ta\<rbrace>\<^bsub>i\<^esub>); t \<noteq> t'; redT_updTs (thr s) \<lbrace>ta\<rbrace>\<^bsub>t\<^esub> t = \<lfloor>(x, w)\<rfloor>\<rbrakk> \<Longrightarrow> NewThread t x m' \<in> set \<lbrace>ta\<rbrace>\<^bsub>t\<^esub> \<and> w = no_wait_locks [PROOF STEP] apply(drule (2) redT_updTs_new_thread) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>xa x' m' ws'. \<lbrakk>thr s t = None; \<lbrace>ta\<rbrace>\<^bsub>w\<^esub> = []; t' \<turnstile> \<langle>xa, shr s\<rangle> -ta\<rightarrow> \<langle>x', m'\<rangle>; thr s t' = \<lfloor>(xa, no_wait_locks)\<rfloor>; lock_ok_las (locks s) t' \<lbrace>ta\<rbrace>\<^bsub>l\<^esub>; thread_oks (thr s) \<lbrace>ta\<rbrace>\<^bsub>t\<^esub>; cond_action_oks s t' \<lbrace>ta\<rbrace>\<^bsub>c\<^esub>; wset s t' = None; interrupt_actions_ok (interrupts s) \<lbrace>ta\<rbrace>\<^bsub>i\<^esub>; redT_updWs t' (wset s) [] ws'; s' = (redT_updLs (locks s) t' \<lbrace>ta\<rbrace>\<^bsub>l\<^esub>, (redT_updTs (thr s) \<lbrace>ta\<rbrace>\<^bsub>t\<^esub>(t' \<mapsto> (x', redT_updLns (locks s) t' no_wait_locks \<lbrace>ta\<rbrace>\<^bsub>l\<^esub>)), m'), ws', redT_updIs (interrupts s) \<lbrace>ta\<rbrace>\<^bsub>i\<^esub>); t \<noteq> t'; \<exists>m. NewThread t x m \<in> set \<lbrace>ta\<rbrace>\<^bsub>t\<^esub> \<and> w = no_wait_locks\<rbrakk> \<Longrightarrow> NewThread t x m' \<in> set \<lbrace>ta\<rbrace>\<^bsub>t\<^esub> \<and> w = no_wait_locks [PROOF STEP] apply(auto dest: new_thread_memory) [PROOF STATE] proof (prove) goal: No subgoals! [PROOF STEP] done
FUNCTION:NAME open:entry open:entry this is speculative open:entry open:entry this is speculative -- @@stderr -- dtrace: script 'test/demo/spec/spec.d' matched 535 probes
/- Stalk of rings. https://stacks.math.columbia.edu/tag/007L (just says that the category of rings is a type of algebraic structure) Author -- Ramon Fernandez Mir -/ import topology.basic import sheaves.stalk import sheaves.presheaf_of_rings universes u v w open topological_space section stalk_of_rings variables {α : Type u} [topological_space α] variables (F : presheaf_of_rings α) (x : α) definition stalk_of_rings := stalk F.to_presheaf x end stalk_of_rings -- Stalks are rings. section stalk_of_rings_is_ring parameters {α : Type u} [topological_space α] parameters (F : presheaf_of_rings α) (x : α) -- Add. private def stalk_of_rings_add_aux : stalk.elem F.to_presheaf x → stalk.elem F.to_presheaf x → stalk F.to_presheaf x := λ s t, ⟦{U := s.U ∩ t.U, HxU := ⟨s.HxU, t.HxU⟩, s := F.res s.U _ (set.inter_subset_left _ _) s.s + F.res t.U _ (set.inter_subset_right _ _) t.s}⟧ instance stalk_of_rings_has_add : has_add (stalk_of_rings F x) := { add := quotient.lift₂ (stalk_of_rings_add_aux) $ begin intros a1 a2 b1 b2 H1 H2, let F' := F.to_presheaf, rcases H1 with ⟨U1, ⟨HxU1, ⟨HU1a1U, HU1b1U, HresU1⟩⟩⟩, rcases H2 with ⟨U2, ⟨HxU2, ⟨HU2a2U, HU2b2U, HresU2⟩⟩⟩, apply quotient.sound, use [U1 ∩ U2, ⟨HxU1, HxU2⟩], use [set.inter_subset_inter HU1a1U HU2a2U, set.inter_subset_inter HU1b1U HU2b2U], repeat { rw (F.res_is_ring_hom _ _ _).map_add }, have HresU1' : (F'.res U1 (U1 ∩ U2) (set.inter_subset_left _ _) ((F'.res a1.U U1 HU1a1U) (a1.s))) = (F'.res U1 (U1 ∩ U2) (set.inter_subset_left _ _) ((F'.res b1.U U1 HU1b1U) (b1.s))) := by rw HresU1, have HresU2' : (F'.res U2 (U1 ∩ U2) (set.inter_subset_right _ _) ((F'.res a2.U U2 HU2a2U) (a2.s))) = (F'.res U2 (U1 ∩ U2) (set.inter_subset_right _ _) ((F'.res b2.U U2 HU2b2U) (b2.s))) := by rw HresU2, repeat { rw ←(presheaf.Hcomp' F') at HresU1' }, repeat { rw ←(presheaf.Hcomp' F') at HresU2' }, repeat { rw ←(presheaf.Hcomp' F') }, rw [HresU1', HresU2'], end } instance stalk_of_rings_add_semigroup : add_semigroup (stalk_of_rings F x) := { add := stalk_of_rings_has_add.add, add_assoc := begin intros a b c, refine quotient.induction_on₃ a b c _, rintros ⟨U, HxU, sU⟩ ⟨V, HxV, sV⟩ ⟨W, HxW, sW⟩, have HUVWsub : U ∩ V ∩ W ⊆ U ∩ (V ∩ W) := λ x ⟨⟨HxU, HxV⟩, HxW⟩, ⟨HxU, ⟨HxV, HxW⟩⟩, apply quotient.sound, use [U ∩ V ∩ W, ⟨⟨HxU, HxV⟩, HxW⟩], use [set.subset.refl _, HUVWsub], dsimp, repeat { rw (F.res_is_ring_hom _ _ _).map_add }, repeat { erw ←presheaf.Hcomp' }, rw add_assoc, end } instance stalk_of_rings_add_comm_semigroup : add_comm_semigroup (stalk_of_rings F x) := { add_comm := begin intros a b, refine quotient.induction_on₂ a b _, rintros ⟨U, HxU, sU⟩ ⟨V, HxV, sV⟩, apply quotient.sound, have HUVUV : U ∩ V ⊆ U ∩ V := λ x HxUV, HxUV, have HUVVU : U ∩ V ⊆ V ∩ U := λ x ⟨HxU, HxV⟩, ⟨HxV, HxU⟩, use [U ∩ V, ⟨HxU, HxV⟩, HUVUV, HUVVU], repeat { rw (F.res_is_ring_hom _ _ _).map_add }, repeat { rw ←presheaf.Hcomp' }, rw add_comm, end, ..stalk_of_rings_add_semigroup } -- Zero. private def stalk_of_rings_zero : stalk_of_rings F x := ⟦{U := opens.univ, HxU := trivial, s:= 0}⟧ instance stalk_of_rings_has_zero : has_zero (stalk_of_rings F x) := { zero := stalk_of_rings_zero } instance stalk_of_rings_add_comm_monoid : add_comm_monoid (stalk_of_rings F x) := { zero := stalk_of_rings_zero, zero_add := begin intros a, refine quotient.induction_on a _, rintros ⟨U, HxU, sU⟩, apply quotient.sound, have HUsub : U ⊆ opens.univ ∩ U := λ x HxU, ⟨trivial, HxU⟩, use [U, HxU, HUsub, set.subset.refl U], repeat { rw (F.res_is_ring_hom _ _ _).map_add }, repeat { rw ←presheaf.Hcomp' }, erw (is_ring_hom.map_zero ((F.to_presheaf).res _ _ _)); try { apply_instance }, rw zero_add, refl, end, add_zero := begin intros a, refine quotient.induction_on a _, rintros ⟨U, HxU, sU⟩, apply quotient.sound, have HUsub : U ⊆ U ∩ opens.univ := λ x HxU, ⟨HxU, trivial⟩, use [U, HxU, HUsub, set.subset.refl U], repeat { rw (F.res_is_ring_hom _ _ _).map_add }, repeat { erw ←presheaf.Hcomp' }, dsimp, erw (is_ring_hom.map_zero ((F.to_presheaf).res _ _ _)); try { apply_instance }, rw add_zero, refl, end, ..stalk_of_rings_add_comm_semigroup } -- Neg. private def stalk_sub_aux : stalk.elem F.to_presheaf x → stalk F.to_presheaf x := λ s, ⟦{U := s.U, HxU := s.HxU, s := -s.s}⟧ instance stalk_of_rings_has_neg : has_neg (stalk_of_rings F x) := { neg := quotient.lift stalk_sub_aux $ begin intros a b H, rcases H with ⟨U, ⟨HxU, ⟨HUaU, HUbU, HresU⟩⟩⟩, apply quotient.sound, use [U, HxU, HUaU, HUbU], repeat { rw @is_ring_hom.map_neg _ _ _ _ _ (F.res_is_ring_hom _ _ _) }, rw HresU, end } instance stalk_of_rings_add_comm_group : add_comm_group (stalk_of_rings F x) := { neg := stalk_of_rings_has_neg.neg, add_left_neg := begin intros a, refine quotient.induction_on a _, rintros ⟨U, HxU, sU⟩, apply quotient.sound, have HUUU : U ⊆ U ∩ U := λ x HxU, ⟨HxU, HxU⟩, have HUuniv : U ⊆ opens.univ := λ x HxU, trivial, use [U, HxU, HUUU, HUuniv], repeat { rw (F.res_is_ring_hom _ _ _).map_add }, repeat { rw ←presheaf.Hcomp' }, erw (is_ring_hom.map_neg ((F.to_presheaf).res _ _ _)); try { apply_instance }, rw add_left_neg, erw (is_ring_hom.map_zero ((F.to_presheaf).res _ _ _)); try { apply_instance }, end, ..stalk_of_rings_add_comm_monoid } -- Mul. private def stalk_of_rings_mul_aux : stalk.elem F.to_presheaf x → stalk.elem F.to_presheaf x → stalk F.to_presheaf x := λ s t, ⟦{U := s.U ∩ t.U, HxU := ⟨s.HxU, t.HxU⟩, s := F.res s.U _ (set.inter_subset_left _ _) s.s * F.res t.U _ (set.inter_subset_right _ _) t.s}⟧ instance stalk_of_rings_has_mul : has_mul (stalk_of_rings F x) := { mul := quotient.lift₂ (stalk_of_rings_mul_aux) $ begin intros a1 a2 b1 b2 H1 H2, let F' := F.to_presheaf, rcases H1 with ⟨U1, ⟨HxU1, ⟨HU1a1U, HU1b1U, HresU1⟩⟩⟩, rcases H2 with ⟨U2, ⟨HxU2, ⟨HU2a2U, HU2b2U, HresU2⟩⟩⟩, apply quotient.sound, use [U1 ∩ U2, ⟨HxU1, HxU2⟩], use [set.inter_subset_inter HU1a1U HU2a2U, set.inter_subset_inter HU1b1U HU2b2U], repeat { rw (F.res_is_ring_hom _ _ _).map_mul }, have HresU1' : (F'.res U1 (U1 ∩ U2) (set.inter_subset_left _ _) ((F'.res a1.U U1 HU1a1U) (a1.s))) = (F'.res U1 (U1 ∩ U2) (set.inter_subset_left _ _) ((F'.res b1.U U1 HU1b1U) (b1.s))) := by rw HresU1, have HresU2' : (F'.res U2 (U1 ∩ U2) (set.inter_subset_right _ _) ((F'.res a2.U U2 HU2a2U) (a2.s))) = (F'.res U2 (U1 ∩ U2) (set.inter_subset_right _ _) ((F'.res b2.U U2 HU2b2U) (b2.s))) := by rw HresU2, repeat { rw ←(presheaf.Hcomp' F') at HresU1' }, repeat { rw ←(presheaf.Hcomp' F') at HresU2' }, repeat { rw ←(presheaf.Hcomp' F') }, rw [HresU1', HresU2'], end } instance stalk_of_rings_mul_semigroup : semigroup (stalk_of_rings F x) := { mul := stalk_of_rings_has_mul.mul, mul_assoc := begin intros a b c, refine quotient.induction_on₃ a b c _, rintros ⟨U, HxU, sU⟩ ⟨V, HxV, sV⟩ ⟨W, HxW, sW⟩, have HUVWsub : U ∩ V ∩ W ⊆ U ∩ (V ∩ W) := λ x ⟨⟨HxU, HxV⟩, HxW⟩, ⟨HxU, ⟨HxV, HxW⟩⟩, apply quotient.sound, use [U ∩ V ∩ W, ⟨⟨HxU, HxV⟩, HxW⟩], use [set.subset.refl _, HUVWsub], repeat { rw (F.res_is_ring_hom _ _ _).map_mul }, repeat { rw ←presheaf.Hcomp' }, rw mul_assoc, end } instance stalk_of_rings_mul_comm_semigroup : comm_semigroup (stalk_of_rings F x) := { mul_comm := begin intros a b, refine quotient.induction_on₂ a b _, rintros ⟨U, HxU, sU⟩ ⟨V, HxV, sV⟩, apply quotient.sound, have HUVUV : U ∩ V ⊆ U ∩ V := λ x HxUV, HxUV, have HUVVU : U ∩ V ⊆ V ∩ U := λ x ⟨HxU, HxV⟩, ⟨HxV, HxU⟩, use [U ∩ V, ⟨HxU, HxV⟩, HUVUV, HUVVU], repeat { rw (F.res_is_ring_hom _ _ _).map_mul }, repeat { rw ←presheaf.Hcomp' }, rw mul_comm, end, ..stalk_of_rings_mul_semigroup } -- One. private def stalk_of_rings_one : stalk_of_rings F x := ⟦{U := opens.univ, HxU := trivial, s:= 1}⟧ instance stalk_of_rings_has_one : has_one (stalk_of_rings F x) := { one := stalk_of_rings_one } instance stalk_of_rings_mul_comm_monoid : comm_monoid (stalk_of_rings F x) := { one := stalk_of_rings_one, one_mul := begin intros a, refine quotient.induction_on a _, rintros ⟨U, HxU, sU⟩, apply quotient.sound, have HUsub : U ⊆ opens.univ ∩ U := λ x HxU, ⟨trivial, HxU⟩, use [U, HxU, HUsub, set.subset.refl U], repeat { rw (F.res_is_ring_hom _ _ _).map_mul }, repeat { rw ←presheaf.Hcomp' }, erw (is_ring_hom.map_one ((F.to_presheaf).res _ _ _)); try { apply_instance }, rw one_mul, refl, end, mul_one := begin intros a, refine quotient.induction_on a _, rintros ⟨U, HxU, sU⟩, apply quotient.sound, have HUsub : U ⊆ U ∩ opens.univ := λ x HxU, ⟨HxU, trivial⟩, use [U, HxU, HUsub, set.subset.refl U], repeat { rw (F.res_is_ring_hom _ _ _).map_mul }, repeat { rw ←presheaf.Hcomp' }, dsimp, erw (is_ring_hom.map_one ((F.to_presheaf).res _ _ _)); try { apply_instance }, rw mul_one, refl, end, ..stalk_of_rings_mul_comm_semigroup } -- Ring. instance stalk_of_rings_is_comm_ring : comm_ring (stalk_of_rings F x) := { left_distrib := begin intros a b c, refine quotient.induction_on₃ a b c _, rintros ⟨U, HxU, sU⟩ ⟨V, HxV, sV⟩ ⟨W, HxW, sW⟩, have HUVWsub : U ∩ V ∩ W ⊆ U ∩ (V ∩ W) := λ x ⟨⟨HxU, HxV⟩, HxW⟩, ⟨HxU, ⟨HxV, HxW⟩⟩, have HUVWsub2 : U ∩ V ∩ W ⊆ U ∩ V ∩ (U ∩ W) := λ x ⟨⟨HxU, HxV⟩, HxW⟩, ⟨⟨HxU, HxV⟩, ⟨HxU, HxW⟩⟩, apply quotient.sound, use [U ∩ V ∩ W, ⟨⟨HxU, HxV⟩, HxW⟩, HUVWsub, HUVWsub2], repeat { rw (F.res_is_ring_hom _ _ _).map_mul }, repeat { rw (F.res_is_ring_hom _ _ _).map_add }, repeat { rw ←presheaf.Hcomp' }, repeat { rw (F.res_is_ring_hom _ _ _).map_mul }, repeat { rw (F.res_is_ring_hom _ _ _).map_add }, repeat { rw ←presheaf.Hcomp' }, rw mul_add, end, right_distrib := begin intros a b c, refine quotient.induction_on₃ a b c _, rintros ⟨U, HxU, sU⟩ ⟨V, HxV, sV⟩ ⟨W, HxW, sW⟩, have HUVWrfl : U ∩ V ∩ W ⊆ U ∩ V ∩ W := λ x Hx, Hx, have HUVWsub : U ∩ V ∩ W ⊆ U ∩ W ∩ (V ∩ W) := λ x ⟨⟨HxU, HxV⟩, HxW⟩, ⟨⟨HxU, HxW⟩, ⟨HxV, HxW⟩⟩, apply quotient.sound, use [U ∩ V ∩ W, ⟨⟨HxU, HxV⟩, HxW⟩, HUVWrfl, HUVWsub], repeat { rw (F.res_is_ring_hom _ _ _).map_mul }, repeat { rw (F.res_is_ring_hom _ _ _).map_add }, repeat { rw ←presheaf.Hcomp' }, repeat { rw (F.res_is_ring_hom _ _ _).map_mul }, repeat { rw (F.res_is_ring_hom _ _ _).map_add }, repeat { rw ←presheaf.Hcomp' }, rw add_mul, end, ..stalk_of_rings_add_comm_group, ..stalk_of_rings_mul_comm_monoid } end stalk_of_rings_is_ring -- Stalks are colimits. section stalk_colimit variables {α : Type u} [topological_space α] variables (F : presheaf_of_rings α) (x : α) variables (S : Type w) [comm_ring S] [decidable_eq S] variables (G : Π U, x ∈ U → F.F U → S) [HG : ∀ U, ∀ (h : x ∈ U), is_ring_hom (G U h)] variables (hg : ∀ U V (H : U ⊆ V) r, ∀ (h : x ∈ U), G U h (F.res V U H r) = G V (H h) r) def to_stalk (U : opens α) (HxU : x ∈ U) (s : F.F U) : stalk_of_rings F x := ⟦{U := U, HxU := HxU, s := s}⟧ instance to_stalk.is_ring_hom (U) (HxU) : is_ring_hom (to_stalk F x U HxU) := { map_one := quotient.sound $ ⟨U, HxU, set.subset.refl _, λ x Hx, trivial, begin erw (F.res_is_ring_hom _ _ _).map_one, erw (F.res_is_ring_hom _ _ _).map_one, end⟩, map_add := λ y z, quotient.sound $ ⟨U, HxU, set.subset.refl _, λ x Hx, ⟨Hx, Hx⟩, begin erw ←(F.res_is_ring_hom _ _ _).map_add, erw presheaf.Hcomp', end⟩, map_mul := λ y z, quotient.sound $ ⟨U, HxU, set.subset.refl _, λ x Hx, ⟨Hx, Hx⟩, begin erw ←(F.res_is_ring_hom _ _ _).map_mul, erw presheaf.Hcomp', end⟩ } include hg protected def to_stalk.rec (y : stalk_of_rings F x) : S := quotient.lift_on' y (λ Us, G Us.1 Us.2 Us.3) $ λ ⟨U, HxU, s⟩ ⟨V, HxV, t⟩ ⟨W, HxW, HWU, HWV, Hres⟩, begin dsimp, erw [←hg W U HWU s HxW, ←hg W V HWV t HxW, Hres], end /- to_stalk.rec : Π {α : Type u} [_inst_1 : topological_space α] (F : presheaf_of_rings α) (x : α) (S : Type w) [_inst_2 : comm_ring S] [_inst_3 : decidable_eq S] (G : Π (U : opens α), (F.to_presheaf).F U → S), (∀ (U V : opens α) (H : U ⊆ V) (r : (F.to_presheaf).F V), G U ((F.to_presheaf).res V U H r) = G V r) → stalk_of_rings F x → S -/ theorem to_stalk.rec_to_stalk (U HxU s) : to_stalk.rec F x S G hg (to_stalk F x U HxU s) = G U HxU s := rfl include HG instance to_stalk.rec_is_ring_hom : is_ring_hom (to_stalk.rec F x S G hg) := { map_one := (HG opens.univ (set.mem_univ x)).map_one ▸ rfl, map_add := λ y z, quotient.induction_on₂' y z $ λ ⟨U, HxU, s⟩ ⟨V, HxV, t⟩, begin have HxUV : x ∈ U ∩ V := ⟨HxU, HxV⟩, show G (U ∩ V) HxUV (_ + _) = G _ _ _ + G _ _ _, rw (HG (U ∩ V) HxUV).map_add, erw ←hg (U ∩ V) U (set.inter_subset_left _ _), erw ←hg (U ∩ V) V (set.inter_subset_right _ _), end, map_mul := λ y z, quotient.induction_on₂' y z $ λ ⟨U, HxU, s⟩ ⟨V, HxV, t⟩, begin have HxUV : x ∈ U ∩ V := ⟨HxU, HxV⟩, show G (U ∩ V) HxUV (_ * _) = G _ _ _ * G _ _ _, rw (HG (U ∩ V) HxUV).map_mul, erw ←hg (U ∩ V) U (set.inter_subset_left _ _), erw ←hg (U ∩ V) V (set.inter_subset_right _ _), end } end stalk_colimit
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Aug 13 21:53:54 2020 @author: yangyangli """ import numpy as np import torch import gpytorch from ..utils import generate_ranges #import time class GPRegressionModel(gpytorch.models.ExactGP): def __init__(self, train_x, train_y, likelihood, bounds): super(GPRegressionModel, self).__init__(train_x, train_y, likelihood) # SKI requires a grid size hyperparameter. This util can help with that grid_size = gpytorch.utils.grid.choose_grid_size(train_x) self.mean_module = gpytorch.means.ConstantMean() self.covar_module = gpytorch.kernels.ScaleKernel( gpytorch.kernels.GridInterpolationKernel( gpytorch.kernels.RBFKernel(), grid_size=grid_size, num_dims=4, grid_bounds=bounds ) ) def forward(self, x): mean_x = self.mean_module(x) covar_x = self.covar_module(x) return gpytorch.distributions.MultivariateNormal(mean_x, covar_x) class GPInterpolation: """ Gaussian Process regression interpolator (Not fully implemented yet) Parameters ---------- x: list or ndarray, (N,4) [Teff, logg, vt, EW] y: list or ndarray, (N,1) [Fe/H] stellar_type: str The stellar type of your star, like: {spectral type, e.g. F, G, K}/{giant or subgiant or dwarf}/{metal_rich or metal_poor or very_metal_poor} or the estimation of your atmospheric parameters in such form: {T_low}_{T_high}/{logg_low}_{logg_high}/{[Fe/H]_low}_{[Fe/H]_high} training_iter: int number of training iterations """ import torch def __init__(self, x, y, stellar_type, training_iter=50): self.train_x = torch.from_numpy(x).to(torch.float) self.train_y = torch.from_numpy(y).to(torch.float) self.bounds = list(generate_ranges(stellar_type)[:2]) self.bounds.append([0.5, 3.0]) self.bounds.append([max(0, x[:,3].min()-10), x[:,3].max()+10]) self.training_iter = 50 self._model = None self._likelihood = None idx = np.random.choice(range(np.shape(x)[0]), int(np.floor(np.shape(x)[0]*0.3))) self.test_x = torch.from_numpy(x[idx,:]).to(torch.float) self.test_y = torch.from_numpy(y[idx]).to(torch.float) self.th_met = y[idx] def train(self): likelihood = gpytorch.likelihoods.GaussianLikelihood() model = GPRegressionModel(self.train_x, self.train_y, likelihood, self.bounds) #train the model model.train() likelihood.train() # Use the adam optimizer optimizer = torch.optim.Adam([ {'params': model.parameters()}, # Includes GaussianLikelihood parameters ], lr=0.1) # "Loss" for GPs - the marginal log likelihood mll = gpytorch.mlls.ExactMarginalLogLikelihood(likelihood, model) for i in range(self.training_iter): optimizer.zero_grad() output = model(self.train_x) loss = -mll(output, self.train_y) loss.backward() #print('Iter %d/%d - Loss: %.3f' % (i + 1, training_iterations, loss.item())) optimizer.step() self._model = model self._likelihood = likelihood def test(self): self._model.eval() self._likelihood.eval() with torch.no_grad(), gpytorch.settings.fast_pred_var(): prediction = self._likelihood(self._model(self.test_x)) mean = prediction.mean var = prediction.variance delta_mean = mean.tolist()-self.th_met return np.array([delta_mean.tolist(), np.sqrt(var.tolist()).tolist()]) def predict(self, data): self._model.eval() self._likelihood.eval() with torch.no_grad(), gpytorch.settings.fast_pred_var(): #start_time = time.time() prediction = self._likelihood(self._model(data)) mean = prediction.mean # get covariance matrix var = prediction.variance #fast_time_with_cache = time.time() - start_time #print('Time to compute mean + variances (cache): {:.2f}s'.format(fast_time_with_cache)) return [mean.tolist()[0], np.sqrt(var.tolist()).tolist()[0]]
Formal statement is: lemma space_empty_iff: "space N = {} \<longleftrightarrow> sets N = {{}}" Informal statement is: A $\sigma$-algebra is empty if and only if it contains only the empty set.
Require Import Coq.Strings.String. Definition MMIOAction: Type := string. Definition MMInput: MMIOAction := "MMInput"%string. Definition MMOutput: MMIOAction := "MMOutput"%string. Definition isMMInput: MMIOAction -> bool := String.eqb MMInput. Definition isMMOutput: MMIOAction -> bool := String.eqb MMOutput.
{-# OPTIONS --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.Structure 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 renaming ( _+_ to _+ℕ_ ; _·_ to _·ℕ_ ; +-comm to +ℕ-comm ; +-assoc to +ℕ-assoc ; ·-assoc to ·ℕ-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 open import Cubical.Algebra.AbGroup open import Cubical.Algebra.Monoid open import Cubical.Algebra.Ring open import Cubical.Algebra.Ring.BigOps open import Cubical.Algebra.CommRing 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 AbGroupStr (snd G') renaming ( is-set to isSetG ) private G = ⟨ G' ⟩ 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 AbGroupStr (snd G') private G = ⟨ 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 RingStr (snd R') renaming ( is-set to isSetR ) open RingTheory R' open KroneckerDelta R' open Sum R' open FinMatrixAbGroup (_ , abgroupstr _ _ _ (snd R' .RingStr.+IsAbGroup)) private R = ⟨ R' ⟩ oneFinMatrix : ∀ {n} → FinMatrix R n n oneFinMatrix i j = δ i j 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 ∑Exchange : ∀ {m n} → (M : FinMatrix R m n) → ∑ (λ i → ∑ (λ j → M i j)) ≡ ∑ (λ j → ∑ (λ i → M i j)) ∑Exchange {m = zero} {n = n} M = sym (∑0r n) ∑Exchange {m = suc m} {n = zero} M = cong (λ x → 0r + x) (∑0r m) ∙ +Rid 0r ∑Exchange {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 + ∑Split (λ i → M (suc i) zero) (λ i → ∑ (λ j → M (suc i) (suc j))) k) ⟩ a + L + (C + N) ≡⟨ (λ k → a + L + (C + ∑Exchange (λ 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 + ∑Split (λ j → M zero (suc j)) (λ j → ∑ (λ i → M (suc i) (suc j))) (~ k)) ⟩ a + C + ∑ (λ j → ∑ (λ i → M i (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)) ≡⟨ ∑Ext (λ k → ∑Mulrdist (M i k) (λ l → N k l · K l j)) ⟩ ∑ (λ k → ∑ (λ l → M i k · (N k l · K l j))) ≡⟨ ∑Ext (λ k → ∑Ext (λ l → ·Assoc (M i k) (N k l) (K l j))) ⟩ ∑ (λ k → ∑ (λ l → M i k · N k l · K l j)) ≡⟨ ∑Exchange (λ k l → M i k · N k l · K l j) ⟩ ∑ (λ l → ∑ (λ k → M i k · N k l · K l j)) ≡⟨ ∑Ext (λ l → sym (∑Mulldist (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 → ∑Mulr1 _ (M i) j mulFinMatrix1r : ∀ {m n} → (M : FinMatrix R m n) → mulFinMatrix oneFinMatrix M ≡ M mulFinMatrix1r M = funExt₂ λ i j → ∑Mul1r _ (λ 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)) ≡⟨ ∑Ext (λ k → ·Rdist+ (M i k) (N k j) (K k j)) ⟩ ∑ (λ k → M i k · N k j + M i k · K k j) ≡⟨ ∑Split (λ 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) ≡⟨ ∑Ext (λ k → ·Ldist+ (M i k) (N i k) (K k j)) ⟩ ∑ (λ k → M i k · K k j + N i k · K k j) ≡⟨ ∑Split (λ 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 -- Generators of product of two ideals flatten : {n m : ℕ} → FinMatrix A n m → FinVec A (n ·ℕ m) flatten {n = zero} _ () flatten {n = suc n} M = M zero ++Fin flatten (M ∘ suc) flattenElim : {P : A → Type ℓ'} {n m : ℕ} (M : FinMatrix A n m) → (∀ i j → P (M i j)) → (∀ i → P (flatten M i)) flattenElim {n = zero} M PMHyp () flattenElim {n = suc n} {m = zero} M PMHyp ind = ⊥.rec (¬Fin0 (transport (λ i → Fin (0≡m·0 n (~ i))) ind)) flattenElim {n = suc n} {m = suc m} M PMHyp zero = PMHyp zero zero flattenElim {P = P} {n = suc n} {m = suc m} M PMHyp (suc i) = ++FinElim {P = P} (M zero ∘ suc) (flatten (M ∘ suc)) (PMHyp zero ∘ suc) (flattenElim {P = P} (M ∘ suc) (PMHyp ∘ suc)) i module ProdFin (R' : CommRing ℓ) where private R = fst R' open CommRingStr (snd R') renaming ( is-set to isSetR ) open CommRingTheory R' open RingTheory (CommRing→Ring R') open KroneckerDelta (CommRing→Ring R') open Sum (CommRing→Ring R') toMatrix : {n m : ℕ} → FinVec R n → FinVec R m → FinMatrix R n m toMatrix V W i j = V i · W j _··Fin_ : {n m : ℕ} → FinVec R n → FinVec R m → FinVec R (n ·ℕ m) V ··Fin W = flatten (toMatrix V W) Length1··Fin : ∀ (x y : R) → replicateFinVec 1 (x · y) ≡ (replicateFinVec 1 x) ··Fin (replicateFinVec 1 y) Length1··Fin x y = sym (++FinRid (replicateFinVec 1 (x · y)) _) ∑Dist··Fin : {n m : ℕ} (U : FinVec R n) (V : FinVec R m) → (∑ U) · (∑ V) ≡ ∑ (U ··Fin V) ∑Dist··Fin {n = zero} U V = 0LeftAnnihilates _ ∑Dist··Fin {n = suc n} U V = (U zero + ∑ (U ∘ suc)) · (∑ V) ≡⟨ ·Ldist+ _ _ _ ⟩ U zero · (∑ V) + (∑ (U ∘ suc)) · (∑ V) ≡⟨ cong₂ (_+_) (∑Mulrdist _ V) (∑Dist··Fin (U ∘ suc) V) ⟩ ∑ (λ j → U zero · V j) + ∑ ((U ∘ suc) ··Fin V) ≡⟨ sym (∑Split++ (λ j → U zero · V j) _) ⟩ ∑ ((λ j → U zero · V j) ++Fin ((U ∘ suc) ··Fin V)) ∎ ·Dist··Fin : {n m : ℕ} (α U : FinVec R n) (β V : FinVec R m) → ∀ j → ((λ i → α i · U i) ··Fin (λ i → β i · V i)) j ≡ (α ··Fin β) j · (U ··Fin V) j ·Dist··Fin {n = n} {m = m} α U β V = equivΠ e (equivHelper α U β V ) .fst λ _ → ·-commAssocSwap _ _ _ _ where e = (FinProdChar.Equiv n m) equivHelper : {n m : ℕ} (α U : FinVec R n) (β V : FinVec R m) (a : Fin n × Fin m) → (α (fst a) · U (fst a) · (β (snd a) · V (snd a)) ≡ α (fst a) · β (snd a) · (U (fst a) · V (snd a))) ≃ (((λ i → α i · U i) ··Fin (λ i → β i · V i)) (FinProdChar.Equiv n m .fst a) ≡ (α ··Fin β) (FinProdChar.Equiv n m .fst a) · (U ··Fin V) (FinProdChar.Equiv n m .fst a)) equivHelper {n = suc n} {m = suc m} α U β V (zero , zero) = idEquiv _ equivHelper {n = suc n} {m = suc m} α U β V (zero , suc j) = transport (λ 𝕚 → (α zero · U zero · (β (suc j) · V (suc j)) ≡ α zero · β (suc j) · (U zero · V (suc j))) ≃ (FinSumChar.++FinInl m (n ·ℕ suc m) (λ x → α zero · U zero · (β (suc x) · V (suc x))) (flatten (λ x y → α (suc x) · U (suc x) · (β y · V y))) j 𝕚 ≡ (FinSumChar.++FinInl m (n ·ℕ suc m) (λ x → α zero · β (suc x)) (flatten (λ x y → α (suc x) · β y)) j 𝕚) · (FinSumChar.++FinInl m (n ·ℕ suc m) (λ x → U zero · V (suc x)) (flatten (λ x y → U (suc x) · V y)) j 𝕚))) (idEquiv _) equivHelper {n = suc n} {m = suc m} α U β V (suc i , j) = transport (λ 𝕚 → (α (suc i) · U (suc i) · (β j · V j) ≡ α (suc i) · β j · (U (suc i) · V j)) ≃ (FinSumChar.++FinInr m (n ·ℕ suc m) (λ x → α zero · U zero · (β (suc x) · V (suc x))) (flatten (λ x y → α (suc x) · U (suc x) · (β y · V y))) (FinProdChar.Equiv n (suc m) .fst (i , j)) 𝕚 ≡ (FinSumChar.++FinInr m (n ·ℕ suc m) (λ x → α zero · β (suc x)) (flatten (λ x y → α (suc x) · β y)) (FinProdChar.Equiv n (suc m) .fst (i , j)) 𝕚) · (FinSumChar.++FinInr m (n ·ℕ suc m) (λ x → U zero · V (suc x)) (flatten (λ x y → U (suc x) · V y)) (FinProdChar.Equiv n (suc m) .fst (i , j)) 𝕚))) (equivHelper (α ∘ suc) (U ∘ suc) β V _)
||| Projection based on Full Merge. ||| ||| The Tech Report 'A Linear Decomposition of Multiparty Sessions for Safe Distributed Programming' (DTRS12-2) defines a 'full merge' operation. ||| This merge operation improves the expressiveness of projection compared to Plain Merge. ||| module Sessions.Projection.Full import Decidable.Equality import Data.List import Data.List.Elem import Data.List1 import Sessions.Meta import Sessions.Global import Sessions.Global.Involved import Sessions.Local import Sessions.Local.Same import public Sessions.Projection.Error %default total -- [ EOF ]
State Before: α : Type u_1 β : Type ?u.135386 m : MeasurableSpace α μ ν : Measure α inst✝¹ : IsFiniteMeasure μ inst✝ : IsFiniteMeasure ν ⊢ toSignedMeasure μ = toSignedMeasure ν ↔ μ = ν State After: case refine'_1 α : Type u_1 β : Type ?u.135386 m : MeasurableSpace α μ ν : Measure α inst✝¹ : IsFiniteMeasure μ inst✝ : IsFiniteMeasure ν h : toSignedMeasure μ = toSignedMeasure ν ⊢ μ = ν case refine'_2 α : Type u_1 β : Type ?u.135386 m : MeasurableSpace α μ ν : Measure α inst✝¹ : IsFiniteMeasure μ inst✝ : IsFiniteMeasure ν h : μ = ν ⊢ toSignedMeasure μ = toSignedMeasure ν Tactic: refine' ⟨fun h => _, fun h => _⟩ State Before: case refine'_1 α : Type u_1 β : Type ?u.135386 m : MeasurableSpace α μ ν : Measure α inst✝¹ : IsFiniteMeasure μ inst✝ : IsFiniteMeasure ν h : toSignedMeasure μ = toSignedMeasure ν ⊢ μ = ν State After: case refine'_1.h α : Type u_1 β : Type ?u.135386 m : MeasurableSpace α μ ν : Measure α inst✝¹ : IsFiniteMeasure μ inst✝ : IsFiniteMeasure ν h : toSignedMeasure μ = toSignedMeasure ν i : Set α hi : MeasurableSet i ⊢ ↑↑μ i = ↑↑ν i Tactic: ext1 i hi State Before: case refine'_1.h α : Type u_1 β : Type ?u.135386 m : MeasurableSpace α μ ν : Measure α inst✝¹ : IsFiniteMeasure μ inst✝ : IsFiniteMeasure ν h : toSignedMeasure μ = toSignedMeasure ν i : Set α hi : MeasurableSet i ⊢ ↑↑μ i = ↑↑ν i State After: case refine'_1.h α : Type u_1 β : Type ?u.135386 m : MeasurableSpace α μ ν : Measure α inst✝¹ : IsFiniteMeasure μ inst✝ : IsFiniteMeasure ν h : toSignedMeasure μ = toSignedMeasure ν i : Set α hi : MeasurableSet i this : ↑(toSignedMeasure μ) i = ↑(toSignedMeasure ν) i ⊢ ↑↑μ i = ↑↑ν i Tactic: have : μ.toSignedMeasure i = ν.toSignedMeasure i := by rw [h] State Before: case refine'_1.h α : Type u_1 β : Type ?u.135386 m : MeasurableSpace α μ ν : Measure α inst✝¹ : IsFiniteMeasure μ inst✝ : IsFiniteMeasure ν h : toSignedMeasure μ = toSignedMeasure ν i : Set α hi : MeasurableSet i this : ↑(toSignedMeasure μ) i = ↑(toSignedMeasure ν) i ⊢ ↑↑μ i = ↑↑ν i State After: no goals Tactic: rwa [toSignedMeasure_apply_measurable hi, toSignedMeasure_apply_measurable hi, ENNReal.toReal_eq_toReal] at this <;> exact measure_ne_top _ _ State Before: α : Type u_1 β : Type ?u.135386 m : MeasurableSpace α μ ν : Measure α inst✝¹ : IsFiniteMeasure μ inst✝ : IsFiniteMeasure ν h : toSignedMeasure μ = toSignedMeasure ν i : Set α hi : MeasurableSet i ⊢ ↑(toSignedMeasure μ) i = ↑(toSignedMeasure ν) i State After: no goals Tactic: rw [h] State Before: case refine'_2 α : Type u_1 β : Type ?u.135386 m : MeasurableSpace α μ ν : Measure α inst✝¹ : IsFiniteMeasure μ inst✝ : IsFiniteMeasure ν h : μ = ν ⊢ toSignedMeasure μ = toSignedMeasure ν State After: no goals Tactic: congr
\chapter{Background}\label{chap:background} \newpage \input{content/2-background/1-network.tex} \newpage \input{content/2-background/2-mesh.tex} \newpage \input{content/2-background/3-p2p.tex} \newpage \input{content/2-background/4-media-api.tex} \newpage \input{content/2-background/5-webrtc.tex} \newpage \input{content/2-background/6-video-stream.tex} \newpage
module Main import Erlang.System main : IO () main = do ok <- setEnv "HELLO" "HI" True printLn ok Just str <- getEnv "HELLO" | Nothing => pure () putStrLn str ok <- setEnv "HELLO" "HO" False printLn ok Just str <- getEnv "HELLO" | Nothing => pure () putStrLn str ok <- setEnv "HELLO" "EH" True printLn ok Just str <- getEnv "HELLO" | Nothing => pure () putStrLn str ok <- unsetEnv "HELLO" printLn ok Just str <- getEnv "HELLO" | Nothing => putStrLn "Nothing there" pure ()
import tactic /- When writing proofs it's easier to write them in tactic mode. The show_term command will show you the term mode proof for this tactic proof. If the term mode proof is shorter, this is how the proof would be written in mathlib. -/ -- Let P and Q be propositions. variables P Q : Prop -- The following is a simple proof that if we have P ∧ Q, then we also have Q ∧ P example : P ∧ Q → Q ∧ P := begin intro h, split, exact h.right, exact h.left, end -- to write this in term_mode, use the show_term command like this example : P ∧ Q → Q ∧ P := begin show_term { intro h, split, exact h.right, exact h.left, }, end -- Clicking the show_term word above and then clicking the try this command in the infoview window will reduce this to example : P ∧ Q → Q ∧ P := begin exact λ (h : P ∧ Q), ⟨h.right, h.left⟩, end -- Finally we can remove the begin exact and end parts to reduce this to example : P ∧ Q → Q ∧ P := λ (h : P ∧ Q), ⟨h.right, h.left⟩
From Undecidability Require Import PSL.Prelim L.Prelim.MoreBase. From Complexity.Complexity Require Import Monotonic. Require Import smpl.Smpl. Require Import Nat Lia. (** ** O notation *) Definition inO (f g : nat -> nat) : Prop := exists c n0, forall n, n0 <= n -> f n <= c * g n. Notation " f ∈O g" := (inO f g) (at level 70). #[export] Instance inO_PreOrder : PreOrder inO. Proof. split. -exists 1,0. intros. Lia.lia. -intros f g h (c&n0&H) (c'&n0'&H'). exists (c*c'),(max n0 n0'). intros n Hn. rewrite H,H'. all:Lia.lia. Qed. #[export] Instance inO_pointwise_leq : Proper ( Basics.flip (pointwise_relation _ le) ==> (pointwise_relation _ le) ==> Basics.impl) inO. Proof. intros ? ? R1 ? ? R2. unfold inO. hnf in R1,R2|-*. setoid_rewrite R1. setoid_rewrite R2. easy. Qed. #[export] Instance inO_pointwise_eq: Proper ((pointwise_relation _ eq) ==> (pointwise_relation _ eq) ==> iff) inO. Proof. intros ? ? R1 ? ? R2. hnf in R1,R2. unfold inO. setoid_rewrite R1. setoid_rewrite R2. easy. Qed. Lemma inO_add_l f1 f2 g: f1 ∈O g -> f2 ∈O g -> (fun n => f1 n + f2 n) ∈O g. Proof. intros (c1&n1&H1) (c2&n2&H2). eexists (c1 + c2),(max n1 n2). intros. rewrite H1,H2. all:Lia.lia. Qed. Lemma inO_mul_c_l c f1 g: f1 ∈O g -> (fun n => c * f1 n) ∈O g. Proof. intros (c1&n1&H1). eexists (c1*c), (n1). intros. rewrite H1. all:Lia.lia. Qed. Lemma inO_mul_c_r c f1 g: f1 ∈O g -> (fun n => f1 n * c) ∈O g. Proof. intros (c1&n1&H1). eexists (c1*c),(n1). intros. rewrite H1. all:Lia.lia. Qed. Lemma inO_c c f': (fun _ => 1) ∈O f' -> (fun _ => c ) ∈O f'. Proof. intros H'. assert (H:c<= 1*c) by lia. setoid_rewrite H. eapply inO_mul_c_r. easy. Qed. (* Lemma inO_c c n0 f': (forall n', n0 <= n' -> 1 <= f' n') -> (fun _ => c ) ∈O f'. Proof. eexists (c),(n0). intros. rewrite <- H. all:Lia.nia. Qed. *) Lemma inO_leq n0 f' g: (forall n', n0 <= n' -> f' n' <= g n') -> f' ∈O g. Proof. eexists 1,(n0). intros. rewrite <- H. all:Lia.nia. Qed. Smpl Create inO. Smpl Add 11 (smpl monotonic) : inO. Smpl Add 10 (first [ simple eapply inO_add_l | simple eapply inO_mul_c_l | simple eapply inO_mul_c_r | progress (eapply inO_c) | reflexivity]) (* | simple eapply inO_c with (n0:=1);intro;try rewrite <- !f_geq_n;Lia.nia | inO_leq 1])*) : inO. Ltac smpl_inO := repeat (smpl inO). Lemma inO_mul_l f1 f2 g1 g2: f1 ∈O g1 -> f2 ∈O g2 -> (fun n => f1 n * f2 n) ∈O (fun n => g1 n * g2 n). Proof. intros (c1&n1&H1) (c2&n2&H2). eexists (c1 * c2),(max n1 n2). intros. rewrite H1,H2. all:Lia.lia. Qed. Lemma inO_comp_l f1 f2 g1 g2: f1 ∈O g1 -> f2 ∈O g2 -> monotonic f1 -> (forall x, x <= g2 x ) -> (forall c, (fun x => g1 (c*x)) ∈O g1) -> (fun n => f1 (f2 n)) ∈O (fun n => g1 (g2 n)). Proof. intros (c1&n1&H1) (c2&n2&H2) mono2 H' H. specialize (H (c2+n1)) as (c2'&n2'&H). eexists (c1 * c2'),(max (max 1 n2') n2). intros. etransitivity. {hnf in mono2. rewrite mono2. reflexivity. transitivity ((c2+n1)*(g2 n)). 2:reflexivity. rewrite H2. Lia.nia. lia. } specialize (H' n). setoid_rewrite H1. 2:Lia.nia. rewrite H. Lia.nia. Lia.nia. Qed. Lemma inO__bound f g (H:f ∈O g) : exists c, forall n, f n <= c + c * g n. Proof. destruct H as (c0&n0&H). cbn. exists (max c0 (maxl (map f (natsLess n0)))). intros n. decide (n0<=n). -rewrite H. all:Lia.nia. -rewrite (@maxl_leq (f n) (map f (natsLess n0))). Lia.nia. apply in_map_iff. setoid_rewrite natsLess_in_iff. exists n. lia. Qed. (** *** smallO *) (** This variant of smallo does not need real nubers, as we moved the constant to the other side *) Definition ino (f g : nat -> nat) : Prop := forall c__inv, exists n0 , forall n, n0 <= n -> c__inv * f n < g n. Notation " f ∈o g" := (ino f g) (at level 70). (*Definition n__ino f g (H:f ∈o g) c0 (H' : 0 < c0) : nat := proj1_sig (ino__correct H c0 H'). Definition correct_n__ino f g (H:f ∈o g) c0 (H' : 0 < c0) : forall n, n__ino H H' <= n -> f n < c0 * g n := proj2_sig (ino__correct H c0 H'). *) Lemma ino_inO_incl f g : f ∈o g -> f ∈O g. Proof. intros H. specialize (H 1) as (c__ino&H). exists 1,c__ino. intros ? ?%H. lia. Qed. (** ** O(poly)*) Definition inOPoly (f : nat -> nat) : Prop := exists n, f ∈O (fun x => x ^ n). Lemma inOPoly_c c: inOPoly (fun _ => c). Proof. exists 1. eapply inO_c. cbn. eapply (inO_leq (n0:=1)). intros. lia. Qed. Lemma inOPoly_x: inOPoly (fun x => x). Proof. exists 1. cbn. eapply (inO_leq (n0:=1)). intros. lia. Qed. Lemma inOPoly_add f1 f2: inOPoly f1 -> inOPoly f2 -> inOPoly (fun x => f1 x + f2 x). Proof. intros (n1&?) (n2&?). exists (max n1 n2). eapply inO_add_l. all:etransitivity;[eassumption|]. all:eapply inO_leq with (n0:=1). all:intros ? ?. all:eapply Nat.pow_le_mono_r. all:Lia.nia. Qed. Lemma inOPoly_mul f1 f2: inOPoly f1 -> inOPoly f2 -> inOPoly (fun x => f1 x * f2 x). Proof. intros (n1&?) (n2&?). exists (n1+n2). transitivity (fun x : nat => x ^ n1 * x^n2). 1:now eauto using inO_mul_l. all:eapply inO_leq with (n0:=0). all:intros ? _. rewrite Nat.pow_add_r. Lia.nia. Qed. Lemma inOPoly_pow f c: inOPoly f -> inOPoly (fun x => f x ^ c). Proof. intros (n&H). exists (n*c). destruct H as (n0 & n1&H). eexists _, n1. intros ? H'%H. rewrite Nat.pow_le_mono_l. 2:eassumption. rewrite Nat.pow_mul_l,Nat.pow_mul_r. reflexivity. Qed. Lemma inOPoly_S f : inOPoly f -> inOPoly (fun x => S (f x)). Proof. intros H. eapply (@inOPoly_add (fun _ => 1) f). 2: apply H. apply inOPoly_c. Qed. Lemma inOPoly_comp f1 f2: monotonic f1 -> inOPoly f1 -> inOPoly f2 -> inOPoly (fun x => f1 (f2 x)). Proof. intros ? (n1&?) (n2&?). exists ((max 1 n2)*n1). etransitivity. {eapply inO_comp_l with (g2:=(fun x => x ^(max 1 n2))). 1,3:eassumption. -rewrite H1. apply inO_leq with (n0:=1). intros. eapply Nat.pow_le_mono;lia. -intros. replace x with (x^1) at 1 by (cbn;Lia.nia). decide (x=0). 2:now eapply Nat.pow_le_mono;Lia.nia. subst x. rewrite !Nat.pow_0_l. all:Lia.nia. -cbn beta. intros c. exists (c^n1),0. intros. rewrite Nat.pow_mul_l. reflexivity. } cbn beta. eapply inO_leq with (n0:=0). intros. rewrite Nat.pow_mul_r. reflexivity. Qed. Smpl Add 10 (first [ simple eapply inOPoly_add | simple eapply inOPoly_S | simple eapply inOPoly_mul | simple eapply inOPoly_c | simple eapply inOPoly_pow | simple eapply inOPoly_x | eassumption]) : inO. #[export] Instance inO_inOPoly_trans : Proper (Basics.flip inO ==> Basics.impl) inOPoly. Proof. intros ? ? ? [? R2]. unfold inOPoly. eexists. setoid_rewrite <- R2. easy. Qed. #[export] Instance inOPoly_pointwise_leq: Proper (Basics.flip (pointwise_relation _ le) ==> Basics.impl) inOPoly. Proof. unfold inOPoly. intros ? ? R1. hnf in |-*. setoid_rewrite R1. easy. Qed. #[export] Instance inOPoly_pointwise_eq: Proper ((pointwise_relation _ eq) ==> iff) inOPoly. Proof. unfold inOPoly. intros ? ? R1. hnf. setoid_rewrite R1. easy. Qed.
[STATEMENT] lemma idempotent_impl_trans: "idempotent r \<Longrightarrow> trans r" [PROOF STATE] proof (prove) goal (1 subgoal): 1. idempotent r \<Longrightarrow> trans r [PROOF STEP] by(auto simp:trans_def idempotent_def)
-- Pruebas de (A ∩ Bᶜ) ∪ B = A ∪ B -- =============================== -- ---------------------------------------------------- -- Ej. 1. Demostrar -- (A ∩ Bᶜ) ∪ B = A ∪ B -- ---------------------------------------------------- import data.set open set variable U : Type variables A B C : set U -- 1ª demostración -- =============== example : (A ∩ Bᶜ) ∪ B = A ∪ B := calc (A ∩ Bᶜ) ∪ B = (A ∪ B) ∩ (Bᶜ ∪ B) : by rw union_distrib_right ... = (A ∪ B) ∩ univ : by rw compl_union_self ... = A ∪ B : by rw inter_univ example : (A ∩ B) ∪ C = (A ∪ C) ∩ (B ∪ C) := -- by library_search union_distrib_right A B C example : Bᶜ ∪ B = univ := -- by library_search compl_union_self B example : A ∩ univ = A := -- by library_search inter_univ A -- 2ª demostración -- =============== example : (A ∩ Bᶜ) ∪ B = A ∪ B := begin rw union_distrib_right, rw compl_union_self, rw inter_univ, end -- 3ª demostración -- =============== example : (A ∩ Bᶜ) ∪ B = A ∪ B := by rw [union_distrib_right, compl_union_self, inter_univ] -- 4ª demostración -- =============== example : (A ∩ Bᶜ) ∪ B = A ∪ B := by simp [union_distrib_right]
Formal statement is: lemma linear_bounded: fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector" assumes lf: "linear f" shows "\<exists>B. \<forall>x. norm (f x) \<le> B * norm x" Informal statement is: If $f$ is a linear function from a Euclidean space to a normed vector space, then there exists a constant $B$ such that for all $x$, we have $||f(x)|| \leq B ||x||$.
[STATEMENT] lemma headconst_isnormNum: "isnpolyh p n0 \<Longrightarrow> isnormNum (headconst p)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. isnpolyh p n0 \<Longrightarrow> isnormNum (headconst p) [PROOF STEP] by (induct p arbitrary: n0) auto
//================================================================================================== /** Copyright 2016 NumScale SAS Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) **/ //================================================================================================== #ifndef BOOST_SIMD_FUNCTION_DEFINITION_SLIDE_HPP_INCLUDED #define BOOST_SIMD_FUNCTION_DEFINITION_SLIDE_HPP_INCLUDED #include <boost/simd/config.hpp> #include <boost/simd/meta/cardinal_of.hpp> #include <boost/simd/detail/dispatch/function/make_callable.hpp> #include <boost/simd/detail/dispatch/hierarchy/functions.hpp> #include <boost/simd/detail/dispatch.hpp> namespace boost { namespace simd { namespace tag { BOOST_DISPATCH_MAKE_TAG(ext, slide_, boost::dispatch::abstract_<slide_>); } namespace ext { BOOST_DISPATCH_FUNCTION_DECLARATION(tag, slide_) } namespace detail { BOOST_DISPATCH_CALLABLE_DEFINITION(tag::slide_,slide); } } } #include <boost/simd/function/detail/slide.hpp> namespace boost { namespace simd { template<int N, typename T> BOOST_FORCEINLINE T slide(T const& a0, T const& a1) { return detail::slider<T,N,cardinal_of<T>::value,(N>=0)>::call(a0,a1); } template<int N, typename T> BOOST_FORCEINLINE T slide(T const& a0) { return detail::slider<T,N,cardinal_of<T>::value,(N>=0)>::call(a0); } } } #endif
Formal statement is: lemma sums_complex_iff: "f sums x \<longleftrightarrow> ((\<lambda>x. Re (f x)) sums Re x) \<and> ((\<lambda>x. Im (f x)) sums Im x)" Informal statement is: A complex series $\sum_{n=0}^\infty a_n$ converges if and only if both the real series $\sum_{n=0}^\infty \Re(a_n)$ and the imaginary series $\sum_{n=0}^\infty \Im(a_n)$ converge.
(** ** Pre-lB-systems (unital) By Vladimir Voevodsky, split off the file prelBsystems.v on March 3, 2015 *) Unset Automatic Introduction. Require Export lBsystems.prelB_non_unital. Require Export lBsystems.dlt. (** ** pre-lB-systems (unital) *) (** *** The main layers *) (** **** The structure formed by operations dlt *) Definition dlt_layer_0 ( BB : lBsystem_carrier ) := total2 ( fun dlt : dlt_ops_type BB => dlt_ax0_type dlt ) . Definition dlt_layer_0_to_dlt_ops_type ( BB : lBsystem_carrier ) : dlt_layer_0 BB -> dlt_ops_type BB := pr1 . Coercion dlt_layer_0_to_dlt_ops_type : dlt_layer_0 >-> dlt_ops_type . (** **** Complete definition of a (unital) pre-lB-system *) Definition prelBsystem := total2 ( fun BB : prelBsystem_non_unital => dlt_layer_0 BB ) . Definition prelBsystem_pr1 : prelBsystem -> prelBsystem_non_unital := pr1 . Coercion prelBsystem_pr1 : prelBsystem >-> prelBsystem_non_unital . (** *** Access functions for the operation dlt and its zeros axiom *) Definition dlt_op { BB : prelBsystem } : dlt_ops_type BB := pr2 BB . Definition dlt_ax0 { BB : prelBsystem } : dlt_ax0_type ( @dlt_op BB ) := pr2 ( pr2 BB ) . (* End of the file prelB.v *)
Formal statement is: lemma bounded_minus: fixes S ::"'a::real_normed_vector set" assumes "bounded S" "bounded T" shows "bounded ((\<lambda>(x,y). x - y) ` (S \<times> T))" Informal statement is: If $S$ and $T$ are bounded sets, then the set of differences $S - T = \{x - y \mid x \in S, y \in T\}$ is bounded.
/- Copyright (c) 2021 Lu-Ming Zhang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Lu-Ming Zhang -/ import linear_algebra.matrix.trace /-! # Hadamard product of matrices This file defines the Hadamard product `matrix.hadamard` and contains basic properties about them. ## Main definition - `matrix.hadamard`: defines the Hadamard product, which is the pointwise product of two matrices of the same size. ## Notation * `⊙`: the Hadamard product `matrix.hadamard`; ## References * <https://en.wikipedia.org/wiki/hadamard_product_(matrices)> ## Tags hadamard product, hadamard -/ variables {α β γ m n : Type*} variables {R : Type*} namespace matrix open_locale matrix big_operators /-- `matrix.hadamard` defines the Hadamard product, which is the pointwise product of two matrices of the same size.-/ @[simp] def hadamard [has_mul α] (A : matrix m n α) (B : matrix m n α) : matrix m n α | i j := A i j * B i j localized "infix ` ⊙ `:100 := matrix.hadamard" in matrix section basic_properties variables (A : matrix m n α) (B : matrix m n α) (C : matrix m n α) /- commutativity -/ lemma hadamard_comm [comm_semigroup α] : A ⊙ B = B ⊙ A := ext $ λ _ _, mul_comm _ _ /- associativity -/ lemma hadamard_assoc [semigroup α] : A ⊙ B ⊙ C = A ⊙ (B ⊙ C) := ext $ λ _ _, mul_assoc _ _ _ /- distributivity -/ lemma hadamard_add [distrib α] : A ⊙ (B + C) = A ⊙ B + A ⊙ C := ext $ λ _ _, left_distrib _ _ _ lemma add_hadamard [distrib α] : (B + C) ⊙ A = B ⊙ A + C ⊙ A := ext $ λ _ _, right_distrib _ _ _ /- scalar multiplication -/ section scalar @[simp] lemma smul_hadamard [has_mul α] [has_scalar R α] [is_scalar_tower R α α] (k : R) : (k • A) ⊙ B = k • A ⊙ B := ext $ λ _ _, smul_mul_assoc _ _ _ @[simp] lemma hadamard_smul [has_mul α] [has_scalar R α] [smul_comm_class R α α] (k : R): A ⊙ (k • B) = k • A ⊙ B := ext $ λ _ _, mul_smul_comm _ _ _ end scalar section zero variables [mul_zero_class α] @[simp] lemma hadamard_zero : A ⊙ (0 : matrix m n α) = 0 := ext $ λ _ _, mul_zero _ @[simp] lemma zero_hadamard : (0 : matrix m n α) ⊙ A = 0 := ext $ λ _ _, zero_mul _ end zero section one variables [decidable_eq n] [mul_zero_one_class α] variables (M : matrix n n α) lemma hadamard_one : M ⊙ (1 : matrix n n α) = diagonal (λ i, M i i) := by { ext, by_cases h : i = j; simp [h] } lemma one_hadamard : (1 : matrix n n α) ⊙ M = diagonal (λ i, M i i) := by { ext, by_cases h : i = j; simp [h] } end one section diagonal variables [decidable_eq n] [mul_zero_class α] lemma diagonal_hadamard_diagonal (v : n → α) (w : n → α) : diagonal v ⊙ diagonal w = diagonal (v * w) := ext $ λ _ _, (apply_ite2 _ _ _ _ _ _).trans (congr_arg _ $ zero_mul 0) end diagonal section trace variables [fintype m] [fintype n] variables (R) [semiring α] [semiring R] [module R α] lemma sum_hadamard_eq : ∑ (i : m) (j : n), (A ⊙ B) i j = trace m R α (A ⬝ Bᵀ) := rfl lemma dot_product_vec_mul_hadamard [decidable_eq m] [decidable_eq n] (v : m → α) (w : n → α) : dot_product (vec_mul v (A ⊙ B)) w = trace m R α (diagonal v ⬝ A ⬝ (B ⬝ diagonal w)ᵀ) := begin rw [←sum_hadamard_eq, finset.sum_comm], simp [dot_product, vec_mul, finset.sum_mul, mul_assoc], end end trace end basic_properties end matrix
Formal statement is: lemma Bseq_mult: fixes f g :: "nat \<Rightarrow> 'a::real_normed_field" assumes "Bseq f" and "Bseq g" shows "Bseq (\<lambda>x. f x * g x)" Informal statement is: If $f$ and $g$ are bounded sequences, then $f \cdot g$ is a bounded sequence.
State Before: α : Type u_1 β : Type ?u.1258403 γ : Type ?u.1258406 δ : Type ?u.1258409 m : MeasurableSpace α μ ν : Measure α inst✝³ : MeasurableSpace δ inst✝² : NormedAddCommGroup β inst✝¹ : NormedAddCommGroup γ H : Type u_2 inst✝ : NormedAddCommGroup H m0 : MeasurableSpace α μ' : Measure α f : α → H hm : m ≤ m0 hf_int : Integrable f hf : StronglyMeasurable f ⊢ Integrable f State After: α : Type u_1 β : Type ?u.1258403 γ : Type ?u.1258406 δ : Type ?u.1258409 m : MeasurableSpace α μ ν : Measure α inst✝³ : MeasurableSpace δ inst✝² : NormedAddCommGroup β inst✝¹ : NormedAddCommGroup γ H : Type u_2 inst✝ : NormedAddCommGroup H m0 : MeasurableSpace α μ' : Measure α f : α → H hm : m ≤ m0 hf_int : Integrable f hf : StronglyMeasurable f ⊢ HasFiniteIntegral f Tactic: refine' ⟨hf.aestronglyMeasurable, _⟩ State Before: α : Type u_1 β : Type ?u.1258403 γ : Type ?u.1258406 δ : Type ?u.1258409 m : MeasurableSpace α μ ν : Measure α inst✝³ : MeasurableSpace δ inst✝² : NormedAddCommGroup β inst✝¹ : NormedAddCommGroup γ H : Type u_2 inst✝ : NormedAddCommGroup H m0 : MeasurableSpace α μ' : Measure α f : α → H hm : m ≤ m0 hf_int : Integrable f hf : StronglyMeasurable f ⊢ HasFiniteIntegral f State After: α : Type u_1 β : Type ?u.1258403 γ : Type ?u.1258406 δ : Type ?u.1258409 m : MeasurableSpace α μ ν : Measure α inst✝³ : MeasurableSpace δ inst✝² : NormedAddCommGroup β inst✝¹ : NormedAddCommGroup γ H : Type u_2 inst✝ : NormedAddCommGroup H m0 : MeasurableSpace α μ' : Measure α f : α → H hm : m ≤ m0 hf_int : Integrable f hf : StronglyMeasurable f ⊢ (∫⁻ (a : α), ↑‖f a‖₊ ∂μ') < ⊤ α : Type u_1 β : Type ?u.1258403 γ : Type ?u.1258406 δ : Type ?u.1258409 m : MeasurableSpace α μ ν : Measure α inst✝³ : MeasurableSpace δ inst✝² : NormedAddCommGroup β inst✝¹ : NormedAddCommGroup γ H : Type u_2 inst✝ : NormedAddCommGroup H m0 : MeasurableSpace α μ' : Measure α f : α → H hm : m ≤ m0 hf_int : Integrable f hf : StronglyMeasurable f ⊢ Measurable fun a => ↑‖f a‖₊ Tactic: rw [HasFiniteIntegral, lintegral_trim hm _] State Before: α : Type u_1 β : Type ?u.1258403 γ : Type ?u.1258406 δ : Type ?u.1258409 m : MeasurableSpace α μ ν : Measure α inst✝³ : MeasurableSpace δ inst✝² : NormedAddCommGroup β inst✝¹ : NormedAddCommGroup γ H : Type u_2 inst✝ : NormedAddCommGroup H m0 : MeasurableSpace α μ' : Measure α f : α → H hm : m ≤ m0 hf_int : Integrable f hf : StronglyMeasurable f ⊢ (∫⁻ (a : α), ↑‖f a‖₊ ∂μ') < ⊤ State After: no goals Tactic: exact hf_int.2 State Before: α : Type u_1 β : Type ?u.1258403 γ : Type ?u.1258406 δ : Type ?u.1258409 m : MeasurableSpace α μ ν : Measure α inst✝³ : MeasurableSpace δ inst✝² : NormedAddCommGroup β inst✝¹ : NormedAddCommGroup γ H : Type u_2 inst✝ : NormedAddCommGroup H m0 : MeasurableSpace α μ' : Measure α f : α → H hm : m ≤ m0 hf_int : Integrable f hf : StronglyMeasurable f ⊢ Measurable fun a => ↑‖f a‖₊ State After: no goals Tactic: exact @StronglyMeasurable.ennnorm _ m _ _ f hf
(* Title: Designs_And_Graphs.thy Author: Chelsea Edmonds *) section \<open>Graphs and Designs\<close> text \<open>There are many links between graphs and design - most fundamentally that graphs are designs\<close> theory Designs_And_Graphs imports Block_Designs Graph_Theory.Digraph Graph_Theory.Digraph_Component begin subsection \<open>Non-empty digraphs\<close> text \<open>First, we define the concept of a non-empty digraph. This mirrors the idea of a "proper design" in the design theory library\<close> locale non_empty_digraph = wf_digraph + assumes arcs_not_empty: "arcs G \<noteq> {}" begin lemma verts_not_empty: "verts G \<noteq> {}" using wf arcs_not_empty head_in_verts by fastforce end subsection \<open>Arcs to Blocks\<close> text \<open>A digraph uses a pair of points to define an ordered edge. In the case of simple graphs, both possible orderings will be in the arcs set. Blocks are inherently unordered, and as such a method is required to convert between the two representations\<close> context graph begin definition arc_to_block :: "'b \<Rightarrow> 'a set" where "arc_to_block e \<equiv> {tail G e, head G e}" lemma arc_to_block_to_ends: "{fst (arc_to_ends G e), snd (arc_to_ends G e)} = arc_to_block e" by (simp add: arc_to_ends_def arc_to_block_def) lemma arc_to_block_to_ends_swap: "{snd (arc_to_ends G e), fst (arc_to_ends G e)} = arc_to_block e" using arc_to_block_to_ends by (simp add: arc_to_block_to_ends insert_commute) lemma arc_to_ends_to_block: "arc_to_block e = {x, y} \<Longrightarrow> arc_to_ends G e = (x, y) \<or> arc_to_ends G e = (y, x)" by (metis arc_to_block_def arc_to_ends_def doubleton_eq_iff) lemma arc_to_block_sym: "arc_to_ends G e1 = (u, v) \<Longrightarrow> arc_to_ends G e2 = (v, u) \<Longrightarrow> arc_to_block e1 = arc_to_block e2" by (simp add: arc_to_block_def arc_to_ends_def insert_commute) definition arcs_blocks :: "'a set multiset" where "arcs_blocks \<equiv> mset_set (arc_to_block ` (arcs G))" lemma arcs_blocks_ends: "(x, y) \<in> arcs_ends G \<Longrightarrow> {x, y} \<in># arcs_blocks" proof (auto simp add: arcs_ends_def arcs_blocks_def ) fix xa assume assm1: "(x, y) = arc_to_ends G xa" and assm2: "xa \<in> arcs G" obtain z where zin: "z \<in> (arc_to_block ` (arcs G))" and "z = arc_to_block xa" using assm2 by blast thus "{x, y} \<in> arc_to_block ` (arcs G)" using assm1 arc_to_block_to_ends by (metis fst_conv snd_conv) qed lemma arc_ends_blocks_subset: "E \<subseteq> arcs G \<Longrightarrow> (x, y) \<in> ((arc_to_ends G) ` E) \<Longrightarrow> {x, y} \<in> (arc_to_block ` E)" by (auto simp add: arc_to_ends_def arc_to_block_def ) lemma arc_blocks_end_subset: assumes "E \<subseteq> arcs G" and "{x, y} \<in> (arc_to_block ` E)" shows "(x, y) \<in> ((arc_to_ends G) ` E) \<or> (y, x) \<in> ((arc_to_ends G) ` E)" proof - obtain e where "e \<in> E" and "arc_to_block e = {x,y}" using assms by fastforce then have "arc_to_ends G e = (x, y) \<or> arc_to_ends G e = (y, x)" using arc_to_ends_to_block by simp thus ?thesis by (metis \<open>e \<in> E\<close> image_iff) qed lemma arcs_ends_blocks: "{x, y} \<in># arcs_blocks \<Longrightarrow> (x, y) \<in> arcs_ends G \<and> (y, x) \<in> arcs_ends G" proof (auto simp add: arcs_ends_def arcs_blocks_def ) fix xa assume assm1: "{x, y} = arc_to_block xa" and assm2: "xa \<in> (arcs G)" obtain z where zin: "z \<in> (arc_to_ends G ` (arcs G))" and "z = arc_to_ends G xa" using assm2 by blast then have "z = (x, y) \<or> z = (y, x)" using arc_to_block_to_ends assm1 by (metis arc_to_ends_def doubleton_eq_iff fst_conv snd_conv) (* Slow *) thus "(x, y) \<in> arc_to_ends G ` (arcs G)" using assm2 by (metis arcs_ends_def arcs_ends_symmetric sym_arcs zin) next fix xa assume assm1: "{x, y} = arc_to_block xa" and assm2: "xa \<in> (arcs G)" thus "(y, x) \<in> arc_to_ends G ` arcs G" using arcs_ends_def by (metis dual_order.refl graph.arc_blocks_end_subset graph_axioms graph_symmetric imageI) qed lemma arcs_blocks_iff: "{x, y} \<in># arcs_blocks \<longleftrightarrow> (x, y) \<in> arcs_ends G \<and> (y, x) \<in> arcs_ends G" using arcs_ends_blocks arcs_blocks_ends by blast lemma arcs_ends_wf: "(x, y) \<in> arcs_ends G \<Longrightarrow> x \<in> verts G \<and> y \<in> verts G" by auto lemma arcs_blocks_elem: "bl \<in># arcs_blocks \<Longrightarrow> \<exists> x y . bl = {x, y}" apply (auto simp add: arcs_blocks_def) by (meson arc_to_block_def) lemma arcs_ends_blocks_wf: assumes "bl \<in># arcs_blocks" shows "bl \<subseteq> verts G" proof - obtain x y where blpair: "bl = {x, y}" using arcs_blocks_elem assms by fastforce then have "(x, y) \<in> arcs_ends G" using arcs_ends_blocks assms by simp thus ?thesis using arcs_ends_wf blpair by auto qed lemma arcs_blocks_simple: "bl \<in># arcs_blocks \<Longrightarrow> count (arcs_blocks) bl = 1" by (simp add: arcs_blocks_def) lemma arcs_blocks_ne: "arcs G \<noteq> {} \<Longrightarrow> arcs_blocks \<noteq> {#}" by (simp add: arcs_blocks_iff arcs_blocks_def mset_set_empty_iff) end subsection \<open>Graphs are designs\<close> text \<open>Prove that a graph is a number of different types of designs\<close> sublocale graph \<subseteq> design "verts G" "arcs_blocks" using arcs_ends_blocks_wf arcs_blocks_elem by (unfold_locales) (auto) sublocale graph \<subseteq> simple_design "verts G" "arcs_blocks" using arcs_ends_blocks_wf arcs_blocks_elem arcs_blocks_simple by (unfold_locales) (auto) locale non_empty_graph = graph + non_empty_digraph sublocale non_empty_graph \<subseteq> proper_design "verts G" "arcs_blocks" using arcs_blocks_ne arcs_not_empty by (unfold_locales) simp lemma (in graph) graph_block_size: assumes "bl \<in># arcs_blocks" shows "card bl = 2" proof - obtain x y where blrep: "bl = {x, y}" using assms arcs_blocks_elem by fastforce then have "(x, y) \<in> arcs_ends G" using arcs_ends_blocks assms by simp then have "x \<noteq> y" using no_loops using adj_not_same by blast thus ?thesis using blrep by simp qed sublocale non_empty_graph \<subseteq> block_design "verts G" "arcs_blocks" 2 using arcs_not_empty graph_block_size arcs_blocks_ne by (unfold_locales) simp_all subsection \<open>R-regular graphs\<close> text \<open>To reason on r-regular graphs and their link to designs, we require a number of extensions to lemmas reasoning around the degrees of vertices\<close> context sym_digraph begin lemma in_out_arcs_reflexive: "v \<in> verts G \<Longrightarrow> (e \<in> (in_arcs G v) \<Longrightarrow> \<exists> e' . (e' \<in> (out_arcs G v) \<and> head G e' = tail G e))" using symmetric_conv sym_arcs by fastforce lemma out_in_arcs_reflexive: "v \<in> verts G \<Longrightarrow> (e \<in> (out_arcs G v) \<Longrightarrow> \<exists> e' . (e' \<in> (in_arcs G v) \<and> tail G e' = head G e))" using symmetric_conv sym_arcs by fastforce end context nomulti_digraph begin lemma in_arcs_single_per_vert: assumes "v \<in> verts G" and "u \<in> verts G" assumes "e1 \<in> in_arcs G v" and " e2 \<in> in_arcs G v" assumes "tail G e1 = u" and "tail G e2 = u" shows "e1 = e2" proof - have in_arcs1: "e1 \<in> arcs G" and in_arcs2: "e2 \<in> arcs G" using assms by auto have "arc_to_ends G e1 = arc_to_ends G e2" using assms arc_to_ends_def by (metis in_in_arcs_conv) thus ?thesis using in_arcs1 in_arcs2 no_multi_arcs by simp qed lemma out_arcs_single_per_vert: assumes "v \<in> verts G" and "u \<in> verts G" assumes "e1 \<in> out_arcs G v" and " e2 \<in> out_arcs G v" assumes "head G e1 = u" and "head G e2 = u" shows "e1 = e2" proof - have in_arcs1: "e1 \<in> arcs G" and in_arcs2: "e2 \<in> arcs G" using assms by auto have "arc_to_ends G e1 = arc_to_ends G e2" using assms arc_to_ends_def by (metis in_out_arcs_conv) thus ?thesis using in_arcs1 in_arcs2 no_multi_arcs by simp qed end text \<open>Some helpers on the transformation arc definition\<close> context graph begin lemma arc_to_block_is_inj_in_arcs: "inj_on arc_to_block (in_arcs G v)" apply (auto simp add: arc_to_block_def inj_on_def) by (metis arc_to_ends_def doubleton_eq_iff no_multi_arcs) lemma arc_to_block_is_inj_out_arcs: "inj_on arc_to_block (out_arcs G v)" apply (auto simp add: arc_to_block_def inj_on_def) by (metis arc_to_ends_def doubleton_eq_iff no_multi_arcs) lemma in_out_arcs_reflexive_uniq: "v \<in> verts G \<Longrightarrow> (e \<in> (in_arcs G v) \<Longrightarrow> \<exists>! e' . (e' \<in> (out_arcs G v) \<and> head G e' = tail G e))" apply auto using symmetric_conv apply fastforce using out_arcs_single_per_vert by (metis head_in_verts in_out_arcs_conv) lemma out_in_arcs_reflexive_uniq: "v \<in> verts G \<Longrightarrow> e \<in> (out_arcs G v) \<Longrightarrow> \<exists>! e' . (e' \<in> (in_arcs G v) \<and> tail G e' = head G e)" apply auto using symmetric_conv apply fastforce using in_arcs_single_per_vert by (metis tail_in_verts in_in_arcs_conv) lemma in_eq_out_arc_ends: "(u, v) \<in> ((arc_to_ends G) ` (in_arcs G v)) \<longleftrightarrow> (v, u) \<in> ((arc_to_ends G) ` (out_arcs G v))" using arc_to_ends_def in_in_arcs_conv in_out_arcs_conv by (smt (z3) Pair_inject adj_in_verts(1) dominatesI image_iff out_in_arcs_reflexive_uniq) lemma in_degree_eq_card_arc_ends: "in_degree G v = card ((arc_to_ends G) ` (in_arcs G v))" apply (simp add: in_degree_def) using no_multi_arcs by (metis card_image in_arcs_in_arcs inj_onI) lemma in_degree_eq_card_arc_blocks: "in_degree G v = card (arc_to_block ` (in_arcs G v))" apply (simp add: in_degree_def) using no_multi_arcs arc_to_block_is_inj_in_arcs by (simp add: card_image) lemma out_degree_eq_card_arc_blocks: "out_degree G v = card (arc_to_block ` (out_arcs G v))" apply (simp add: out_degree_def) using no_multi_arcs arc_to_block_is_inj_out_arcs by (simp add: card_image) lemma out_degree_eq_card_arc_ends: "out_degree G v = card ((arc_to_ends G) ` (out_arcs G v))" apply (simp add: out_degree_def) using no_multi_arcs by (metis card_image out_arcs_in_arcs inj_onI) lemma bij_betw_in_out_arcs: "bij_betw (\<lambda> (u, v) . (v, u)) ((arc_to_ends G) ` (in_arcs G v)) ((arc_to_ends G) ` (out_arcs G v))" apply (auto simp add: bij_betw_def) apply (simp add: swap_inj_on) apply (metis Pair_inject arc_to_ends_def image_eqI in_eq_out_arc_ends in_in_arcs_conv) by (metis arc_to_ends_def imageI in_eq_out_arc_ends in_out_arcs_conv pair_imageI) lemma in_eq_out_degree: "in_degree G v = out_degree G v" using bij_betw_in_out_arcs bij_betw_same_card in_degree_eq_card_arc_ends out_degree_eq_card_arc_ends by auto lemma in_out_arcs_blocks: "arc_to_block ` (in_arcs G v) = arc_to_block ` (out_arcs G v)" proof (auto) fix xa assume a1: "xa \<in> arcs G" and a2: "v = head G xa" then have "xa \<in> in_arcs G v" by simp then obtain e where out: "e \<in> out_arcs G v" and "head G e = tail G xa" using out_in_arcs_reflexive_uniq by force then have "arc_to_ends G e = (v, tail G xa)" by (simp add: arc_to_ends_def) then have "arc_to_block xa = arc_to_block e" using arc_to_block_sym by (metis a2 arc_to_ends_def) then show "arc_to_block xa \<in> arc_to_block ` out_arcs G (head G xa)" using out a2 by blast next fix xa assume a1: "xa \<in> arcs G" and a2: "v = tail G xa" then have "xa \<in> out_arcs G v" by simp then obtain e where ina: "e \<in> in_arcs G v" and "tail G e = head G xa" using out_in_arcs_reflexive_uniq by force then have "arc_to_ends G e = (head G xa, v)" by (simp add: arc_to_ends_def) then have "arc_to_block xa = arc_to_block e" using arc_to_block_sym by (metis a2 arc_to_ends_def) then show "arc_to_block xa \<in> arc_to_block ` in_arcs G (tail G xa)" using ina a2 by blast qed end text \<open>A regular digraph is defined as one where the in degree equals the out degree which in turn equals some fixed integer $\mathrm{r}$\<close> locale regular_digraph = wf_digraph + fixes \<r> :: nat assumes in_deg_r: "v \<in> verts G \<Longrightarrow> in_degree G v = \<r>" assumes out_deg_r: "v \<in> verts G \<Longrightarrow> out_degree G v = \<r>" locale regular_graph = graph + regular_digraph begin lemma rep_vertices_in_blocks [simp]: assumes "x \<in> verts G" shows "size {# e \<in># arcs_blocks . x \<in> e #} = \<r>" proof - have "\<And> e . e \<in> (arc_to_block ` (arcs G)) \<Longrightarrow> x \<in> e \<Longrightarrow> e \<in> (arc_to_block ` in_arcs G x)" using arc_to_block_def in_in_arcs_conv insert_commute insert_iff singleton_iff sym_arcs symmetric_conv by fastforce then have "{ e \<in> (arc_to_block ` (arcs G)) . x \<in> e} = (arc_to_block ` (in_arcs G x))" using arc_to_block_def by auto then have "card { e \<in> (arc_to_block ` (arcs G)) . x \<in> e} = \<r>" using in_deg_r in_degree_eq_card_arc_blocks assms by auto thus ?thesis using arcs_blocks_def finite_arcs by force qed end text \<open>Intro rules for regular graphs\<close> lemma graph_in_degree_r_imp_reg[intro]: assumes "graph G" assumes "(\<And> v . v \<in> (verts G) \<Longrightarrow> in_degree G v = \<r>)" shows "regular_graph G \<r>" proof - interpret g: graph G using assms by simp interpret wf: wf_digraph G by (simp add: g.wf_digraph_axioms) show ?thesis using assms(2) g.in_eq_out_degree by (unfold_locales) simp_all qed lemma graph_out_degree_r_imp_reg[intro]: assumes "graph G" assumes "(\<And> v . v \<in> (verts G) \<Longrightarrow> out_degree G v = \<r>)" shows "regular_graph G \<r>" proof - interpret g: graph G using assms by simp interpret wf: wf_digraph G by (simp add: g.wf_digraph_axioms) show ?thesis using assms(2) g.in_eq_out_degree by (unfold_locales) simp_all qed text \<open>Regular graphs (non-empty) can be shown to be a constant rep design\<close> locale non_empty_regular_graph = regular_graph + non_empty_digraph sublocale non_empty_regular_graph \<subseteq> non_empty_graph by unfold_locales sublocale non_empty_regular_graph \<subseteq> constant_rep_design "verts G" "arcs_blocks" \<r> using arcs_blocks_ne arcs_not_empty by (unfold_locales)(simp_all add: point_replication_number_def) end
lemma uncountable_cball: fixes a :: "'a::euclidean_space" assumes "r > 0" shows "uncountable (cball a r)"
#' SKDEresultater. #' #' @name SKDEresultater #' @docType package NULL #' Dummy dataset #' #' To be used for testing of the package #' #' @docType data #' @keywords datasets #' @name testdata NULL
-- --------------------------------------------------------------- [ Error.idr ] -- Module : Error.idr -- Copyright : (c) Jan de Muijnck-Hughes -- License : see LICENSE -- --------------------------------------------------------------------- [ EOH ] module ArgParse.Error import public ArgParse.Model import ArgParse.Parser %access public export data ArgParseError : Type where InvalidOption : Arg -> ArgParseError ParseError : ParseError -> ArgParseError implementation (Show Arg) => Show ArgParseError where show (InvalidOption o) = "Invalid Option " ++ show o show (ParseError err) = "Parsing Error\n" ++ show err -- --------------------------------------------------------------------- [ EOF ]
theory Exercise_2_4 imports Main begin fun snoc :: "'a list \<Rightarrow> 'a \<Rightarrow> 'a list" where "snoc [] x = [x]" | "snoc (x#xs) y = (x#(snoc xs y))" value "snoc [1::int,2,3,4] 5" fun reverse :: "'a list \<Rightarrow> 'a list" where "reverse [] = []" | "reverse (x#xs) = snoc (reverse xs) x" lemma reverse_snoc[simp] : "reverse (snoc xs a) = a#(reverse xs)" apply(induction xs) apply(auto) done lemma double_reverse: "reverse(reverse xs) = xs" apply(induction xs) apply(auto) done
open import Agda.Builtin.Equality open import Agda.Builtin.Nat record Eta : Set where constructor _,_ field fst : Nat snd : Nat open Eta data ⊥ : Set where hard-fail : (a : Eta) (x : Nat) → (fst a , x) ≡ a → ⊥ hard-fail a x () -- Should be error (refl is valid) loop : ⊥ loop = hard-fail (0 , 0) 0 refl
lemma dist_commute: "dist x y = dist y x"
We Buy Houses in Folsom, and at Any Price. Check out How It Works. We’re ready to give you a Fair Cash Offer for your House. We help property owners just like you, in all kinds of situations. From divorce, foreclosure, a death of a family member, burdensome rental property, and all kinds of other situations. We buy houses in California… including Folsom and surrounding areas and pay a fair cash price, fast. Sometimes, those who own property simply have lives that are too busy to take the time to do all of the things that typically need to be done to prepare a house to sell on the market… if that describes you, just let us know about the property you’d like to be rid of and sell your house fast for cash. Who can buy my home with cash in Folsom California? Who are the cash house buyers in Folsom California?
%Navigation Navigation superclass % % An abstract superclass for implementing planar grid-based navigation classes. % % Methods:: % plot Display the occupancy grid % visualize Display the occupancy grid (deprecated) % plan Plan a path to goal % path Return/animate a path from start to goal % display Display the parameters in human readable form % char Convert to string % % rand Uniformly distributed random number % randn Normally distributed random number % randi Uniformly distributed random integer % % Properties (read only):: % occgrid Occupancy grid representing the navigation environment % goal Goal coordinate % seed0 Random number state % % Methods that must be provided in subclass:: % plan Generate a plan for motion to goal % next Returns coordinate of next point along path % % Methods that may be overriden in a subclass:: % goal_set The goal has been changed by nav.goal = (a,b) % navigate_init Start of path planning. % % Notes:: % - Subclasses the MATLAB handle class which means that pass by reference semantics % apply. % - A grid world is assumed and vehicle position is quantized to grid cells. % - Vehicle orientation is not considered. % - The initial random number state is captured as seed0 to allow rerunning an % experiment with an interesting outcome. % % See also Dstar, Dxform, PRM, RRT. % Copyright (C) 1993-2014, by Peter I. Corke % % This file is part of The Robotics Toolbox for MATLAB (RTB). % % RTB is free software: you can redistribute it and/or modify % it under the terms of the GNU Lesser General Public License as published by % the Free Software Foundation, either version 3 of the License, or % (at your option) any later version. % % RTB 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 Lesser General Public License for more details. % % You should have received a copy of the GNU Leser General Public License % along with RTB. If not, see <http://www.gnu.org/licenses/>. % % http://www.petercorke.com % Peter Corke 8/2009. % TODO % keep dimensions of workspace in this object, have a setaxes() method % which transfers the dimensions to the current axes. classdef Navigation < handle properties occgrid % occupancy grid goal % goal coordinate navhook % function handle, called on each navigation iteration verbose % verbosity seed % current random seed spincount randstream seed0 end % next() should be protected and abstract, but this doesnt work % properly methods (Abstract) plan(obj) n = next(obj) end % method Abstract methods % TODO fix up set methods for goal % setup argument callback like features, can we inherit from that. % occ grid should be an option % constructor function nav = Navigation(varargin) %Navigation.Navigation Create a Navigation object % % N = Navigation(OCCGRID, OPTIONS) is a Navigation object that holds an % occupancy grid OCCGRID. A number of options can be be passed. % % Options:: % 'navhook',F Specify a function to be called at every step of path % 'goal',G Specify the goal point (2x1) % 'verbose' Display debugging information % 'inflate',K Inflate all obstacles by K cells. % 'private' Use private random number stream. % 'reset' Reset random number stream. % 'seed',S Set the initial state of the random number stream. S must % be a proper random number generator state such as saved in % the seed0 property of an earlier run. % % Notes:: % - In the occupancy grid a value of zero means free space and non-zero means % occupied (not driveable). % - Obstacle inflation is performed with a round structuring element (kcircle) % with radius given by the 'inflate' option. % - The 'private' option creates a private random number stream for the methods % rand, randn and randi. If not given the global stream is used. if nargin >= 1 && isnumeric(varargin{1}) && ~isscalar(varargin{1}) nav.occgrid = varargin{1}; varargin = varargin(2:end); end % default values of options opt.goal = []; opt.inflate = 0; opt.navhook = []; opt.private = false; opt.reset = false; opt.seed = []; [opt,args] = tb_optparse(opt, varargin); % optionally inflate the obstacles if opt.inflate > 0 nav.occgrid = idilate(nav.occgrid, kcircle(opt.inflate)); end % copy other options into the object nav.verbose = opt.verbose; nav.navhook = opt.navhook; if ~isempty(opt.goal) nav.goal = opt.goal(:)'; end % create a private random number stream if required if opt.private nav.randstream = RandStream.create('mt19937ar'); else nav.randstream = RandStream.getGlobalStream(); end % reset the random number stream if required if opt.reset nav.randstream.reset(); end % return the random number stream to known state if required if ~isempty(opt.seed) set(nav.randstream.set(opt.seed)); end % save the current state in case it later turns out to give interesting results nav.seed0 = nav.randstream.State; nav.spincount = 0; end function r = rand(nav, varargin) %Navigation.rand Uniformly distributed random number % % R = N.rand() return a uniformly distributed random number from % a private random number stream. % % R = N.rand(M) as above but return a matrix (MxM) of random numbers. % % R = N.rand(L,M) as above but return a matrix (LxM) of random numbers. % % Notes:: % - Accepts the same arguments as rand(). % - Seed is provided to Navigation constructor. % - Provides an independent sequence of random numbers that does not % interfere with any other randomised algorithms that might be used. % % See also Navigation.randi, Navigation.randn, rand, RandStream. r = nav.randstream.rand(varargin{:}); end function r = randn(nav, varargin) %Navigation.randn Normally distributed random number % % R = N.randn() returns a normally distributed random number from % a private random number stream. % % R = N.randn(M) as above but returns a matrix (MxM) of random numbers. % % R = N.randn(L,M) as above but returns a matrix (LxM) of random numbers. % % % Notes:: % - Accepts the same arguments as randn(). % - Seed is provided to Navigation constructor. % - Provides an independent sequence of random numbers that does not % interfere with any other randomised algorithms that might be used. % % See also Navigation.rand, Navigation.randi, randn, RandStream. r = nav.randstream.randn(varargin{:}); end function r = randi(nav, varargin) %Navigation.randi Integer random number % % I = N.randi(RM) returns a uniformly distributed random integer in the % range 1 to RM from a private random number stream. % % I = N.randi(RM, M) as above but returns a matrix (MxM) of random integers. % % I = N.randn(RM, L,M) as above but returns a matrix (LxM) of random integers. % % % Notes:: % - Accepts the same arguments as randn(). % - Seed is provided to Navigation constructor. % - Provides an independent sequence of random numbers that does not % interfere with any other randomised algorithms that might be used. % % See also Navigation.rand, Navigation.randn, randi, RandStream. r = nav.randstream.randi(varargin{:}); end % invoked whenever the goal is set function set.goal(nav, goal) if ~isempty(nav.occgrid) && nav.occgrid( goal(2), goal(1)) == 1 error('Navigation: cant set goal inside obstacle'); end goal = goal(:); if ~(all(size(goal) == size(nav.goal)) && all(goal == nav.goal)) % goal has changed nav.goal = goal(:); nav.goal_change(); end end function goal_change(nav) %Navigation.goal_change Notify change of goal % % Invoked when the goal property of the object is changed. Typically this % is overriden in a subclass to take particular action such as invalidating % a costmap. end function pp = path(nav, start) %Navigation.path Follow path from start to goal % % N.path(START) animates the robot moving from START (2x1) to the goal (which is a % property of the object). % % N.path() as above but first displays the occupancy grid, and prompts the user to % click a start location. % the object). % % X = N.path(START) returns the path (2xM) from START to the goal (which is a property of % the object). % % The method performs the following steps: % % - Get start position interactively if not given % - Initialize navigation, invoke method N.navigate_init() % - Visualize the environment, invoke method N.plot() % - Iterate on the next() method of the subclass until the goal is % achieved. % % See also Navigation.plot, Navigation.goal. % if no start point given, display the map, and prompt the user to select % a start point if nargin < 2 % display the world nav.plot(); % prompt the user to click a goal point fprintf('** click a starting point '); [x,y] = ginput(1); fprintf('\n'); start = round([x;y]); end start = start(:); % if no output arguments given, then display the world if nargout == 0 % render the world nav.plot(); hold on end nav.navigate_init(start); p = []; % robot is a column vector % if nav.backProp()==1 % % subclass algorithm calls for back propagation % robot = nav.goal(:); % else % robot = start; % end robot = start; % iterate using the next() method until we reach the goal while true if nargout == 0 plot(robot(1), robot(2), 'g.', 'MarkerSize', 12); drawnow end % move to next point on path robot = nav.next(robot); % are we there yet? if isempty(robot) % yes, exit the loop break else % no, append it to the path p = [p; robot(:)']; end % invoke the navhook function if isa(nav.navhook, 'function_handle') nav.navhook(nav, robot(1), robot(2)); end end % only return the path if required if nargout > 0 pp = p; end end function visualize(nav, varargin) warning('visualize method deprecated for Navigation classes, use plot instead'); nav.plot(varargin{:}); end function plot(nav, varargin) %Navigation.plot Visualize navigation environment % % N.plot() displays the occupancy grid in a new figure. % % N.plot(P) as above but overlays the points along the path (2xM) matrix. % % Options:: % 'goal' Superimpose the goal position if set % 'distance',D Display a distance field D behind the obstacle map. D is % a matrix of the same size as the occupancy grid. % % Notes:: % - The distance field at a point encodes its distance from the goal, small % distance is dark, a large distance is bright. Obstacles are encoded as % red. opt.goal = false; opt.distance = []; [opt,args] = tb_optparse(opt, varargin); clf if isempty(opt.distance) % create color map for free space + obstacle: % free space, color index = 1, white, % obstacle, color index = 2, red cmap = [1 1 1; 1 0 0]; % non obstacles are white image(nav.occgrid+1, 'CDataMapping', 'direct'); colormap(cmap) else % create color map for distance field + obstacle: % obstacle, color index = 1, red % free space, color index > 1, greyscale % find maximum distance, ignore infinite values in % obstacles d = opt.distance(isfinite(opt.distance)); maxdist = max(d(:)) + 1; % create the color map cmap = [1 0 0; gray(maxdist)]; % ensure obstacles appear as red pixels opt.distance(nav.occgrid > 0) = 0; % display it with colorbar image(opt.distance+1, 'CDataMapping', 'direct'); set(gcf, 'Renderer', 'Zbuffer') colormap(cmap) colorbar end % label the grid set(gca, 'Ydir', 'normal'); xlabel('x'); ylabel('y'); grid on hold on if ~isempty(args) p = args{1}; if numcols(p) ~= 2 error('expecting Nx2 matrix of points'); end plot(p(:,1), p(:,2), 'g.', 'MarkerSize', 12); end if ~isempty(nav.goal) && opt.goal plot(nav.goal(1), nav.goal(2), 'bd', 'MarkerFaceColor', 'b'); end hold off end function navigate_init(nav, start) %Navigation.navigate_init Notify start of path % % N.navigate_init(start) is called when the path() method is invoked. % Typically overriden in a subclass to take particular action such as % computing some path parameters. start is the initial position for this % path, and nav.goal is the final position. end function display(nav) %Navigation.display Display status of navigation object % % N.display() displays the state of the navigation object in % human-readable form. % % Notes:: % - This method is invoked implicitly at the command line when the result % of an expression is a Navigation object and the command has no trailing % semicolon. % % See also Navigation.char. loose = strcmp( get(0, 'FormatSpacing'), 'loose'); if loose disp(' '); end disp([inputname(1), ' = ']) disp( nav.char() ); end % display() function s = char(nav) %Navigation.char Convert to string % % N.char() is a string representing the state of the navigation % object in human-readable form. s = [class(nav) ' navigation class:']; s = char(s, sprintf(' occupancy grid: %dx%d', size(nav.occgrid))); if ~isempty(nav.goal) if length(nav.goal) == 2 s = char(s, sprintf(' goal: (%d,%d)', nav.goal) ); else s = char(s, sprintf(' goal: (%g,%g, %g)', nav.goal) ); end end end function verbosity(nav, v) %Navigation.verbosity Set verbosity % % N.verbosity(V) set verbosity to V, where 0 is silent and greater % values display more information. nav.verbose = v; end % called at each point on the path as % navhook(nav, robot) % % can be used for logging data, animation, etc. function navhook_set(nav, navhook) nav.navhook = navhook; end function message(nav, varargin) %Navigation.message Print debug message % % N.message(S) displays the string S if the verbose property is true. % % N.message(FMT, ARGS) as above but accepts printf() like semantics. if nav.verbose fprintf([class(nav) ' debug:: ' sprintf(varargin{:}) '\n']); end end function spinner(nav) %Navigation.spinner Update progress spinner % % N.spinner() displays a simple ASCII progress spinner, a rotating bar. spinchars = '-\|/'; nav.spincount = nav.spincount + 1; fprintf('\b%c', spinchars( mod(nav.spincount, length(spinchars))+1 ) ); end end % method end % classde
-- Pruebas en Lean de P ∧ Q → Q ∧ P -- ================================ -- ---------------------------------------------------- -- Ej. 1. Demostrar que -- P ∧ Q → Q ∧ P -- ---------------------------------------------------- import tactic variables (P Q : Prop) -- 1ª demostración example : P ∧ Q → Q ∧ P := assume h : P ∧ Q, have hP : P, from and.left h, have hQ : Q, from and.right h, show Q ∧ P, from and.intro hQ hP -- 2ª demostración example : P ∧ Q → Q ∧ P := assume h : P ∧ Q, have hP : P, from h.left, have hQ : Q, from h.right, show Q ∧ P, from ⟨hQ, hP⟩ -- 3ª demostración example : P ∧ Q → Q ∧ P := assume h : P ∧ Q, have hP : P, from h.1, have hQ : Q, from h.2, show Q ∧ P, from ⟨hQ, hP⟩ -- 4ª demostración example : P ∧ Q → Q ∧ P := assume h : P ∧ Q, have hP : P := h.1, have hQ : Q := h.2, show Q ∧ P, from ⟨hQ, hP⟩ -- 5ª demostración example : P ∧ Q → Q ∧ P := assume h : P ∧ Q, show Q ∧ P, from ⟨h.2, h.1⟩ -- 6ª demostración example : P ∧ Q → Q ∧ P := assume h : P ∧ Q, ⟨h.2, h.1⟩ -- 7ª demostración example : P ∧ Q → Q ∧ P := λ h, ⟨h.2, h.1⟩ -- 8ª demostración example : P ∧ Q → Q ∧ P := begin intro h, cases h with hP hQ, split, { exact hQ, }, { exact hP, }, end -- 9ª demostración example : P ∧ Q → Q ∧ P := begin rintro ⟨hP, hQ⟩, exact ⟨hQ, hP⟩, end -- 10ª demostración example : P ∧ Q → Q ∧ P := λ ⟨hP, hQ⟩, ⟨hQ, hP⟩ -- 11ª demostración example : P ∧ Q → Q ∧ P := -- by library_search and.comm.mp -- 12ª demostración example : P ∧ Q → Q ∧ P := and.swap -- 13ª demostración example : P ∧ Q → Q ∧ P:= -- by hint by tauto -- 13ª demostración example : P ∧ Q → Q ∧ P := by finish
Formal statement is: lemma lim_zero_infinity: fixes l :: "'a::{real_normed_field,field}" shows "((\<lambda>x. f(1 / x)) \<longlongrightarrow> l) (at (0::'a)) \<Longrightarrow> (f \<longlongrightarrow> l) at_infinity" Informal statement is: If the limit of $f(1/x)$ as $x$ approaches $0$ is $l$, then the limit of $f(x)$ as $x$ approaches $\infty$ is $l$.
/- Copyright (c) 2021 Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bhavik Mehta, Alena Gusakov, Yaël Dillies -/ import data.finset.lattice /-! # Shadows This file defines shadows of a set family. The shadow of a set family is the set family of sets we get by removing any element from any set of the original family. If one pictures `finset α` as a big hypercube (each dimension being membership of a given element), then taking the shadow corresponds to projecting each finset down once in all available directions. ## Main definitions The `shadow` of a set family is everything we can get by removing an element from each set. ## Notation `∂ 𝒜` is notation for `shadow 𝒜`. It is situated in locale `finset_family`. We also maintain the convention that `a, b : α` are elements of the ground type, `s, t : finset α` are finsets, and `𝒜, ℬ : finset (finset α)` are finset families. ## References * https://github.com/b-mehta/maths-notes/blob/master/iii/mich/combinatorics.pdf * http://discretemath.imp.fu-berlin.de/DMII-2015-16/kruskal.pdf ## Tags shadow, set family -/ open finset nat variables {α : Type*} namespace finset variables [decidable_eq α] {𝒜 : finset (finset α)} {s t : finset α} {a : α} {k : ℕ} /-- The shadow of a set family `𝒜` is all sets we can get by removing one element from any set in `𝒜`, and the (`k` times) iterated shadow (`shadow^[k]`) is all sets we can get by removing `k` elements from any set in `𝒜`. -/ def shadow (𝒜 : finset (finset α)) : finset (finset α) := 𝒜.sup (λ s, s.image (erase s)) localized "notation `∂ `:90 := finset.shadow" in finset_family /-- The shadow of the empty set is empty. -/ @[simp] lemma shadow_empty : ∂ (∅ : finset (finset α)) = ∅ := rfl /-- The shadow is monotone. -/ @[mono] lemma shadow_monotone : monotone (shadow : finset (finset α) → finset (finset α)) := λ 𝒜 ℬ, sup_mono /-- `s` is in the shadow of `𝒜` iff there is an `t ∈ 𝒜` from which we can remove one element to get `s`. -/ lemma mem_shadow_iff : s ∈ ∂ 𝒜 ↔ ∃ t ∈ 𝒜, ∃ a ∈ t, erase t a = s := by simp only [shadow, mem_sup, mem_image] lemma erase_mem_shadow (hs : s ∈ 𝒜) (ha : a ∈ s) : erase s a ∈ ∂ 𝒜 := mem_shadow_iff.2 ⟨s, hs, a, ha, rfl⟩ /-- `t` is in the shadow of `𝒜` iff we can add an element to it so that the resulting finset is in `𝒜`. -/ lemma mem_shadow_iff_insert_mem : s ∈ ∂ 𝒜 ↔ ∃ a ∉ s, insert a s ∈ 𝒜 := begin refine mem_shadow_iff.trans ⟨_, _⟩, { rintro ⟨s, hs, a, ha, rfl⟩, refine ⟨a, not_mem_erase a s, _⟩, rwa insert_erase ha }, { rintro ⟨a, ha, hs⟩, exact ⟨insert a s, hs, a, mem_insert_self _ _, erase_insert ha⟩ } end /-- `s ∈ ∂ 𝒜` iff `s` is exactly one element less than something from `𝒜` -/ lemma mem_shadow_iff_exists_mem_card_add_one : s ∈ ∂ 𝒜 ↔ ∃ t ∈ 𝒜, s ⊆ t ∧ t.card = s.card + 1 := begin refine mem_shadow_iff_insert_mem.trans ⟨_, _⟩, { rintro ⟨a, ha, hs⟩, exact ⟨insert a s, hs, subset_insert _ _, card_insert_of_not_mem ha⟩ }, { rintro ⟨t, ht, hst, h⟩, obtain ⟨a, ha⟩ : ∃ a, t \ s = {a} := card_eq_one.1 (by rw [card_sdiff hst, h, add_tsub_cancel_left]), exact ⟨a, λ hat, not_mem_sdiff_of_mem_right hat ((ha.ge : _ ⊆ _) $ mem_singleton_self a), by rwa [insert_eq a s, ←ha, sdiff_union_of_subset hst]⟩ } end /-- Being in the shadow of `𝒜` means we have a superset in `𝒜`. -/ lemma exists_subset_of_mem_shadow (hs : s ∈ ∂ 𝒜) : ∃ t ∈ 𝒜, s ⊆ t := let ⟨t, ht, hst⟩ := mem_shadow_iff_exists_mem_card_add_one.1 hs in ⟨t, ht, hst.1⟩ /-- `t ∈ ∂^k 𝒜` iff `t` is exactly `k` elements less than something in `𝒜`. -/ lemma mem_shadow_iff_exists_mem_card_add : s ∈ (∂^[k]) 𝒜 ↔ ∃ t ∈ 𝒜, s ⊆ t ∧ t.card = s.card + k := begin induction k with k ih generalizing 𝒜 s, { refine ⟨λ hs, ⟨s, hs, subset.refl _, rfl⟩, _⟩, rintro ⟨t, ht, hst, hcard⟩, rwa eq_of_subset_of_card_le hst hcard.le }, simp only [exists_prop, function.comp_app, function.iterate_succ], refine ih.trans _, clear ih, split, { rintro ⟨t, ht, hst, hcardst⟩, obtain ⟨u, hu, htu, hcardtu⟩ := mem_shadow_iff_exists_mem_card_add_one.1 ht, refine ⟨u, hu, hst.trans htu, _⟩, rw [hcardtu, hcardst], refl }, { rintro ⟨t, ht, hst, hcard⟩, obtain ⟨u, hsu, hut, hu⟩ := finset.exists_intermediate_set k (by { rw [add_comm, hcard], exact le_succ _ }) hst, rw add_comm at hu, refine ⟨u, mem_shadow_iff_exists_mem_card_add_one.2 ⟨t, ht, hut, _⟩, hsu, hu⟩, rw [hcard, hu], refl } end end finset
Formal statement is: lemma convex_hull_eq: "convex hull s = s \<longleftrightarrow> convex s" Informal statement is: The convex hull of a set $s$ is equal to $s$ if and only if $s$ is convex.
#include <bacs/problem/error.hpp> #include <bacs/problem/statement.hpp> #include <boost/filesystem/path.hpp> #include <string> namespace bacs { namespace problem { namespace statement_versions { class pdflatex : public statement::version { public: pdflatex(const boost::filesystem::path &location, const boost::property_tree::ptree &config); void make_package(const boost::filesystem::path &destination, const bunsan::pm::entry &package, const bunsan::pm::entry &resources_package, const Revision &revision) const override; private: const boost::filesystem::path m_root; const boost::filesystem::path m_source; const boost::filesystem::path m_target; }; } // namespace statement_versions } // namespace problem } // namespace bacs
One day minding my own business i thought of my ex boyfriend the true love of my life and there on the ground was a feather. Very interesting to read about feathers. I just got out of jail last week and have had a recent huge breakup in a relationship but know its nest for my mental health. She is the older sister of finn and. White feathers appearing out of nowhere. In addition here is a quick look at some of the additional meaning certain colored feathers may have. Ravenna is the cruel and tyrannical ruler of the kingdom of tabor as well as a dangerously powerful sorceress. Ravenna also known asthe evil queen or simplythe queen is the primary antagonist of snow white and the huntsman and the huntsman. I asked back in december 09 nothing. Pink feathers are a reminder of the unconditional love of your angels and a reminder of the infinite inspiration available when youre tuned into love. I cannot believe all the feathers that have appeared to me in the last 2 months.
State Before: α : Type u_2 β : Type ?u.279314 E : Type u_1 F : Type ?u.279320 inst✝⁵ : MeasurableSpace α inst✝⁴ : NormedAddCommGroup E f g : α → E s t : Set α μ ν : Measure α l l' : Filter α inst✝³ : CompleteSpace E inst✝² : NormedSpace ℝ E inst✝¹ : PartialOrder α a b : α inst✝ : NoAtoms μ ⊢ (∫ (t : α) in Icc a b, f t ∂μ) = ∫ (t : α) in Ico a b, f t ∂μ State After: no goals Tactic: rw [integral_Icc_eq_integral_Ico, integral_Ico_eq_integral_Ioo]
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Jeremy Avigad, Yury Kudryashov -/ import order.filter.at_top_bot /-! # The cofinite filter In this file we define `cofinite`: the filter of sets with finite complement and prove its basic properties. In particular, we prove that for `ℕ` it is equal to `at_top`. ## TODO Define filters for other cardinalities of the complement. -/ open set open_locale classical variables {α : Type*} namespace filter /-- The cofinite filter is the filter of subsets whose complements are finite. -/ def cofinite : filter α := { sets := {s | finite sᶜ}, univ_sets := by simp only [compl_univ, finite_empty, mem_set_of_eq], sets_of_superset := assume s t (hs : finite sᶜ) (st: s ⊆ t), hs.subset $ compl_subset_compl.2 st, inter_sets := assume s t (hs : finite sᶜ) (ht : finite (tᶜ)), by simp only [compl_inter, finite.union, ht, hs, mem_set_of_eq] } @[simp] lemma mem_cofinite {s : set α} : s ∈ (@cofinite α) ↔ finite sᶜ := iff.rfl @[simp] lemma eventually_cofinite {p : α → Prop} : (∀ᶠ x in cofinite, p x) ↔ finite {x | ¬p x} := iff.rfl instance cofinite_ne_bot [infinite α] : ne_bot (@cofinite α) := ⟨mt empty_in_sets_eq_bot.mpr $ by { simp only [mem_cofinite, compl_empty], exact infinite_univ }⟩ lemma frequently_cofinite_iff_infinite {p : α → Prop} : (∃ᶠ x in cofinite, p x) ↔ set.infinite {x | p x} := by simp only [filter.frequently, filter.eventually, mem_cofinite, compl_set_of, not_not, set.infinite] /-- The coproduct of the cofinite filters on two types is the cofinite filter on their product. -/ lemma coprod_cofinite {β : Type*} : (cofinite : filter α).coprod (cofinite : filter β) = cofinite := begin ext S, simp only [mem_coprod_iff, exists_prop, mem_comap_sets, mem_cofinite], split, { rintro ⟨⟨A, hAf, hAS⟩, B, hBf, hBS⟩, rw [← compl_subset_compl, ← preimage_compl] at hAS hBS, exact (hAf.prod hBf).subset (subset_inter hAS hBS) }, { intro hS, refine ⟨⟨(prod.fst '' Sᶜ)ᶜ, _, _⟩, ⟨(prod.snd '' Sᶜ)ᶜ, _, _⟩⟩, { simpa using hS.image prod.fst }, { simpa [compl_subset_comm] using subset_preimage_image prod.fst Sᶜ }, { simpa using hS.image prod.snd }, { simpa [compl_subset_comm] using subset_preimage_image prod.snd Sᶜ } }, end /-- Finite product of finite sets is finite -/ lemma Coprod_cofinite {δ : Type*} {κ : δ → Type*} [fintype δ] : filter.Coprod (λ d, (cofinite : filter (κ d))) = cofinite := begin ext S, simp only [mem_coprod_iff, exists_prop, mem_comap_sets, mem_cofinite], split, { rintros h, rw mem_Coprod_iff at h, choose t ht1 ht2 using h, have ht1d : ∀ (d : δ), (t d)ᶜ.finite := λ d, mem_cofinite.mp (ht1 d), refine (set.finite.pi ht1d).subset _, have ht2d : ∀ (d : δ), Sᶜ ⊆ ((λ (k : Π (d1 : δ), (λ (d2 : δ), κ d2) d1), k d) ⁻¹' ((t d)ᶜ)) := λ d, compl_subset_compl.mpr (ht2 d), convert set.subset_Inter ht2d, ext, simp }, { intro hS, rw mem_Coprod_iff, intros d, refine ⟨((λ (k : Π (d1 : δ), κ d1), k d) '' (Sᶜ))ᶜ, _, _⟩, { rw [mem_cofinite, compl_compl], exact set.finite.image _ hS }, { intros x, contrapose, intros hx, simp only [not_not, mem_preimage, mem_compl_eq, not_forall], exact ⟨x, hx, rfl⟩ } }, end end filter open filter lemma set.finite.compl_mem_cofinite {s : set α} (hs : s.finite) : sᶜ ∈ (@cofinite α) := mem_cofinite.2 $ (compl_compl s).symm ▸ hs lemma set.finite.eventually_cofinite_nmem {s : set α} (hs : s.finite) : ∀ᶠ x in cofinite, x ∉ s := hs.compl_mem_cofinite lemma finset.eventually_cofinite_nmem (s : finset α) : ∀ᶠ x in cofinite, x ∉ s := s.finite_to_set.eventually_cofinite_nmem lemma set.infinite_iff_frequently_cofinite {s : set α} : set.infinite s ↔ (∃ᶠ x in cofinite, x ∈ s) := frequently_cofinite_iff_infinite.symm lemma filter.eventually_cofinite_ne (x : α) : ∀ᶠ a in cofinite, a ≠ x := (set.finite_singleton x).eventually_cofinite_nmem /-- For natural numbers the filters `cofinite` and `at_top` coincide. -/ lemma nat.cofinite_eq_at_top : @cofinite ℕ = at_top := begin ext s, simp only [mem_cofinite, mem_at_top_sets], split, { assume hs, use (hs.to_finset.sup id) + 1, assume b hb, by_contradiction hbs, have := hs.to_finset.subset_range_sup_succ (hs.mem_to_finset.2 hbs), exact not_lt_of_le hb (finset.mem_range.1 this) }, { rintros ⟨N, hN⟩, apply (finite_lt_nat N).subset, assume n hn, change n < N, exact lt_of_not_ge (λ hn', hn $ hN n hn') } end lemma nat.frequently_at_top_iff_infinite {p : ℕ → Prop} : (∃ᶠ n in at_top, p n) ↔ set.infinite {n | p n} := by simp only [← nat.cofinite_eq_at_top, frequently_cofinite_iff_infinite] lemma filter.tendsto.exists_forall_le {α β : Type*} [nonempty α] [linear_order β] {f : α → β} (hf : tendsto f cofinite at_top) : ∃ a₀, ∀ a, f a₀ ≤ f a := begin rcases em (∃ y, ∃ x, f y < x) with ⟨y, x, hx⟩|not_all_top, { -- the set of points `{y | f y < x}` is nonempty and finite, so we take `min` over this set have : finite {y | ¬x ≤ f y} := (filter.eventually_cofinite.mp (tendsto_at_top.1 hf x)), simp only [not_le] at this, obtain ⟨a₀, ha₀ : f a₀ < x, others_bigger⟩ := exists_min_image _ f this ⟨y, hx⟩, exact ⟨a₀, λ a, (lt_or_le (f a) x).elim (others_bigger _) (le_trans ha₀.le)⟩ }, { -- in this case, f is constant because all values are at top push_neg at not_all_top, inhabit α, exact ⟨default α, λ a, not_all_top a (f $ default α)⟩ } end lemma filter.tendsto.exists_forall_ge {α β : Type*} [nonempty α] [linear_order β] {f : α → β} (hf : tendsto f cofinite at_bot) : ∃ a₀, ∀ a, f a ≤ f a₀ := @filter.tendsto.exists_forall_le _ (order_dual β) _ _ _ hf
[STATEMENT] lemma ptensor_mat_carrier: "ptensor_mat m1 m2 \<in> carrier_mat d0 d0" [PROOF STATE] proof (prove) goal (1 subgoal): 1. ptensor_mat m1 m2 \<in> carrier_mat d0 d0 [PROOF STEP] by (simp add: carrier_matI)
\subsection{Convergence in probability and o-notation} \subsubsection{Introduction} Converges in probability \(P(distance(X_n, X)>\epsilon )\rightarrow 0\) For all \(\epsilon \). \(X_n \rightarrow^P X\) \subsubsection{Little o notation} Little o notation is used to describe convergence in probability. \(X_n=o_p(a_n)\) mean that \(\dfrac{X_n}{a_n}\) Converges to \(0\) and \(n\) approaches something Can be wrtiten: \(\dfrac{X_n}{a_n}=o_p(1)\) \subsubsection{Big O notation} Big O notation is used to describe boundedness. \(X_n=O_p(a_n)\) means that: If something is little o, it is big O.
Formal statement is: lemma Lim_transform_within_set_eq: fixes a :: "'a::metric_space" and l :: "'b::metric_space" shows "eventually (\<lambda>x. x \<in> S \<longleftrightarrow> x \<in> T) (at a) \<Longrightarrow> ((f \<longlongrightarrow> l) (at a within S) \<longleftrightarrow> (f \<longlongrightarrow> l) (at a within T))" Informal statement is: If the sets $S$ and $T$ are eventually equal in a neighborhood of $a$, then the limits of $f$ at $a$ within $S$ and $T$ are equal.
(* Author: Tobias Nipkow *) section \<open>Red-Black Tree Implementation of Maps\<close> theory RBT_Map imports RBT_Set Lookup2 begin fun upd :: "'a::linorder \<Rightarrow> 'b \<Rightarrow> ('a*'b) rbt \<Rightarrow> ('a*'b) rbt" where "upd x y Leaf = R Leaf (x,y) Leaf" | "upd x y (B l (a,b) r) = (case cmp x a of LT \<Rightarrow> bal (upd x y l) (a,b) r | GT \<Rightarrow> bal l (a,b) (upd x y r) | EQ \<Rightarrow> B l (x,y) r)" | "upd x y (R l (a,b) r) = (case cmp x a of LT \<Rightarrow> R (upd x y l) (a,b) r | GT \<Rightarrow> R l (a,b) (upd x y r) | EQ \<Rightarrow> R l (x,y) r)" definition update :: "'a::linorder \<Rightarrow> 'b \<Rightarrow> ('a*'b) rbt \<Rightarrow> ('a*'b) rbt" where "update x y t = paint Black (upd x y t)" fun del :: "'a::linorder \<Rightarrow> ('a*'b)rbt \<Rightarrow> ('a*'b)rbt" and delL :: "'a::linorder \<Rightarrow> ('a*'b)rbt \<Rightarrow> 'a*'b \<Rightarrow> ('a*'b)rbt \<Rightarrow> ('a*'b)rbt" and delR :: "'a::linorder \<Rightarrow> ('a*'b)rbt \<Rightarrow> 'a*'b \<Rightarrow> ('a*'b)rbt \<Rightarrow> ('a*'b)rbt" where "del x Leaf = Leaf" | "del x (Node c t1 (a,b) t2) = (case cmp x a of LT \<Rightarrow> delL x t1 (a,b) t2 | GT \<Rightarrow> delR x t1 (a,b) t2 | EQ \<Rightarrow> combine t1 t2)" | "delL x (B t1 a t2) b t3 = balL (del x (B t1 a t2)) b t3" | "delL x t1 a t2 = R (del x t1) a t2" | "delR x t1 a (B t2 b t3) = balR t1 a (del x (B t2 b t3))" | "delR x t1 a t2 = R t1 a (del x t2)" definition delete :: "'a::linorder \<Rightarrow> ('a*'b) rbt \<Rightarrow> ('a*'b) rbt" where "delete x t = paint Black (del x t)" subsection "Functional Correctness Proofs" lemma inorder_upd: "sorted1(inorder t) \<Longrightarrow> inorder(upd x y t) = upd_list x y (inorder t)" by(induction x y t rule: upd.induct) (auto simp: upd_list_simps inorder_bal) lemma inorder_update: "sorted1(inorder t) \<Longrightarrow> inorder(update x y t) = upd_list x y (inorder t)" by(simp add: update_def inorder_upd inorder_paint) lemma inorder_del: "sorted1(inorder t1) \<Longrightarrow> inorder(del x t1) = del_list x (inorder t1)" and "sorted1(inorder t1) \<Longrightarrow> inorder(delL x t1 a t2) = del_list x (inorder t1) @ a # inorder t2" and "sorted1(inorder t2) \<Longrightarrow> inorder(delR x t1 a t2) = inorder t1 @ a # del_list x (inorder t2)" by(induction x t1 and x t1 a t2 and x t1 a t2 rule: del_delL_delR.induct) (auto simp: del_list_simps inorder_combine inorder_balL inorder_balR) lemma inorder_delete: "sorted1(inorder t) \<Longrightarrow> inorder(delete x t) = del_list x (inorder t)" by(simp add: delete_def inorder_del inorder_paint) interpretation Map_by_Ordered where empty = Leaf and lookup = lookup and update = update and delete = delete and inorder = inorder and inv = "\<lambda>_. True" proof (standard, goal_cases) case 1 show ?case by simp next case 2 thus ?case by(simp add: lookup_map_of) next case 3 thus ?case by(simp add: inorder_update) next case 4 thus ?case by(simp add: inorder_delete) qed auto end
module Control.Effect.Writer import Control.EffectAlgebra import Control.Monad.Writer ||| Writer effect. public export data WriterE : Type -> (Type -> Type) -> Type -> Type where Tell : w -> WriterE w m () export Functor (\w => WriterE w m a) where map f (Tell x) = Tell (f x) ||| Write the value to the context within a monadic computation that supports it. public export tell : Inj (WriterE w) sig => Algebra sig m => w -> m () tell s = send (Tell s) namespace Algebra ||| Successive writes overwrite the preceding state. public export [Overwrite] Algebra sig m => Algebra (WriterE s :+: sig) (WriterT s m) where alg ctx hdl (Inl (Tell s)) = MkWriterT $ \_ => pure (ctx, s) alg ctxx hdl (Inr x) = MkWriterT $ \r => do res <- alg {f = Functor.Compose @{(Functor.LeftPair, %search)}} (ctxx, r) h x pure res where h : Handler ((,s) . ctx) n m h = (~<~) {g = Functor.LeftPair} {ctx1 = (,s), ctx2 = ctx} {l = n} {m = WriterT s m} {n = m} (uncurry unWriterT) hdl ||| Newer writes are concatenated from the left, via the `Monoid` instance. public export [ConcatLeft] Monoid s => Algebra sig m => Algebra (WriterE s :+: sig) (WriterT s m) where alg ctxx hdl (Inl (Tell s)) = MkWriterT $ \s' => pure (ctxx, (s <+> s')) alg ctxx hdl (Inr x) = MkWriterT $ \r => do -- hdl : Hander ctx n (WriterT s m) -- h : Handler (,s) (WriterT s m) m -- h ~<~ hdl : Handler ((, s) . ctx) n m res <- alg {f = Functor.Compose @{(Functor.LeftPair, %search)}} (ctxx, r) h x pure res where h : Handler ((,s) . ctx) n m h = (~<~) {g = Functor.LeftPair} {ctx1 = (,s), ctx2 = ctx} {l = n} {m = WriterT s m} {n = m} (uncurry unWriterT) hdl
module Main main : IO () main = repl "> " reverse
#exit -- this was just a proof of concept import finiteness.is_finite import subgroup.theorems -- in this file we get is_finite working with groups. -- For example we prove that a subgroup of a finite group is finite. -- finiteness of subgroups -- We will prove that if G is a finite group and H is a subgroup -- then the promotion of H to a group is also finite -- remember : (H : subgroup G) -- H is a *term* not a type namespace mygroup variables (G : Type) [group G] -- use is_finite to say a group is finite variable [is_finite G] variable (H : subgroup G) instance : is_finite H := is_finite.set H.carrier example (G : Type) [group G] [is_finite G] (H : subgroup G) : is_finite H := by apply_instance end mygroup
{-# OPTIONS --cubical --no-import-sorts --allow-unsolved-metas #-} module Number.Structures2 where open import Agda.Primitive renaming (_⊔_ to ℓ-max; lsuc to ℓ-suc; lzero to ℓ-zero) open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc) open import Cubical.Relation.Nullary.Base renaming (¬_ to ¬ᵗ_)-- ¬ᵗ_ open import Cubical.Foundations.Logic open import Cubical.Data.Sum.Base renaming (_⊎_ to infixr 4 _⊎_) open import Cubical.Data.Sigma renaming (_×_ to infixr 4 _×_) open import Utils open import MoreLogic.Definitions open import MoreLogic.Properties open import MorePropAlgebra.Definitions open import MorePropAlgebra.Consequences open import MorePropAlgebra.Structures {- | name | struct | apart | abs | order | cauchy | sqrt₀⁺ | exp | final name | |------|---------------------|-------|-----|-------|--------|---------|-----|------------------------------------------------------------------------| | ℕ | CommSemiring | (✓) | (✓) | lin. | | (on x²) | | LinearlyOrderedCommSemiring | | ℤ | CommRing | (✓) | (✓) | lin. | | (on x²) | | LinearlyOrderedCommRing | | ℚ | Field | (✓) | (✓) | lin. | | (on x²) | (✓) | LinearlyOrderedField | | ℝ | Field | (✓) | (✓) | part. | ✓ | ✓ | (✓) | CompletePartiallyOrderedFieldWithSqrt | | ℂ | euclidean 2-Product | (✓) | (✓) | | (✓) | | ? | EuclideanTwoProductOfCompletePartiallyOrderedFieldWithSqrt | | R | Ring | ✓ | ✓ | | | | ? | ApartnessRingWithAbsIntoCompletePartiallyOrderedFieldWithSqrt | | G | Group | ✓ | ✓ | | | | ? | ApartnessGroupWithAbsIntoCompletePartiallyOrderedFieldWithSqrt | | K | Field | ✓ | ✓ | | ✓ | | ? | CompleteApartnessFieldWithAbsIntoCompletePartiallyOrderedFieldWithSqrt | -- NOTE: what about conjugation `conj`? -} -- we usually mean "CommRing" when writing just "Ring" ⇒ TODO: rename this where applicable -- this is ℕ record IsLinearlyOrderedCommSemiring {ℓ ℓ'} {F : Type ℓ} (0f 1f : F) (_+_ _·_ : F → F → F) (_<_ : hPropRel F F ℓ') (min max : F → F → F) : Type (ℓ-max ℓ ℓ') where constructor islinearlyorderedcommsemiring infixl 4 _#_ infixl 4 _≤_ -- ≤, as in Lemma 4.1.7 _≤_ : hPropRel F F ℓ' x ≤ y = ¬ (y < x) field is-CommSemiring : [ isCommSemiring 0f 1f _+_ _·_ ] <-StrictLinearOrder : [ isStrictLinearOrder _<_ ] ≤-Lattice : [ isLattice _≤_ min max ] +-<-ext : ∀ w x y z → [ (w + x) < (y + z) ] → [ (w < y) ⊔ (x < z) ] ·-preserves-< : ∀ x y z → [ 0f < z ] → [ x < y ] → [ (x · z) < (y · z) ] open IsCommSemiring is-CommSemiring public open IsStrictLinearOrder <-StrictLinearOrder public renaming ( is-irrefl to <-irrefl ; is-trans to <-trans ; is-tricho to <-trichoᵗ ) abstract <-asym : ∀ a b → [ a < b ] → [ ¬ b < a ] -- [ isAsym _<_ ] <-asym = irrefl+trans⇒asym _<_ <-irrefl <-trans <-irrefl'' : ∀ a b → ([ a < b ] ⊎ [ b < a ]) → [ ¬(a ≡ₚ b) ] <-irrefl'' = isIrrefl'⇔isIrrefl'' _<_ <-asym .fst (isIrrefl⇔isIrrefl' _<_ .fst <-irrefl) <-irreflˢ'' : ∀ a b → ([ a < b ] ⊎ [ b < a ]) → ¬ᵗ(a ≡ b) <-irreflˢ'' = isIrreflˢ''⇔isIrrefl'' _<_ is-set <-asym .snd <-irrefl'' <-tricho : ∀ a b → ([ a < b ] ⊎ [ b < a ]) ⊎ (a ≡ b) <-tricho = isTrichotomousˢ⇔isTrichotomous _<_ is-set <-irrefl'' <-irreflˢ'' <-asym .snd <-trichoᵗ <-StrictPartialOrder : [ isStrictPartialOrder _<_ ] <-StrictPartialOrder = strictlinearorder⇒strictpartialorder _<_ <-StrictLinearOrder -- ≤-PartialOrder : [ isPartialOrder _≤_ ] -- ≤-PartialOrder = {! linearorder⇒partialorder !} ≤-LinearOrder : [ isLinearOrder _≤_ ] ≤-LinearOrder = ≤'-isLinearOrder <-StrictLinearOrder ≤-Preorder : [ isPreorder _≤_ ] ≤-Preorder = ≤'-isPreorder <-StrictPartialOrder -- # is defined as in Lemma 4.1.7 _#_ : hPropRel F F ℓ' x # y = [ <-asym x y ] (x < y) ⊎ᵖ (y < x) #-ApartnessRel : [ isApartnessRel _#_ ] #-ApartnessRel = #''-isApartnessRel <-StrictPartialOrder <-asym open IsApartnessRel #-ApartnessRel public renaming ( is-irrefl to #-irrefl ; is-sym to #-sym ; is-cotrans to #-cotrans ) _ : [ isCommSemiring 0f 1f _+_ _·_ ]; _ = is-CommSemiring _ : [ isStrictLinearOrder _<_ ]; _ = <-StrictLinearOrder _ : [ isLattice _≤_ min max ]; _ = ≤-Lattice open IsLattice ≤-Lattice renaming (≤-antisym to ≤-antisymᵗ) public ≤-antisym : [ isAntisymˢ _≤_ is-set ] ≤-antisym = isAntisymˢ⇔isAntisym _≤_ is-set .snd ≤-antisymᵗ isLinearlyOrderedCommSemiring : ∀{ℓ ℓ'} {F : Type ℓ} (0f 1f : F) (_+_ _·_ : F → F → F) (_<_ : hPropRel F F ℓ') (min max : F → F → F) → hProp (ℓ-max ℓ ℓ') isLinearlyOrderedCommSemiring 0f 1f _+_ _·_ _<_ min max .fst = IsLinearlyOrderedCommSemiring 0f 1f _+_ _·_ _<_ min max isLinearlyOrderedCommSemiring 0f 1f _+_ _·_ _<_ min max .snd = φ where abstract φ = {! !} -- this is ℤ record IsLinearlyOrderedCommRing {ℓ ℓ'} {F : Type ℓ} (0f 1f : F) (_+_ _·_ : F → F → F) (-_ : F → F) (_<_ : hPropRel F F ℓ') (min max : F → F → F) : Type (ℓ-max ℓ ℓ') where constructor islinearlyorderedcommring field is-LinearlyOrderedCommSemiring : [ isLinearlyOrderedCommSemiring 0f 1f _+_ _·_ _<_ min max ] +-inverse : ∀ x → (x + (- x) ≡ 0f) × ((- x) + x ≡ 0f) infixl 6 _-_ _-_ : F → F → F x - y = x + (- y) +-linv : (x : F) → (- x) + x ≡ 0f +-linv x = +-inverse x .snd +-rinv : (x : F) → x + (- x) ≡ 0f +-rinv x = +-inverse x .fst open IsLinearlyOrderedCommSemiring is-LinearlyOrderedCommSemiring public isLinearlyOrderedCommRing : ∀{ℓ ℓ'} {F : Type ℓ} (0f 1f : F) (_+_ _·_ : F → F → F) (-_ : F → F) (_<_ : hPropRel F F ℓ') (min max : F → F → F) → hProp (ℓ-max ℓ ℓ') isLinearlyOrderedCommRing 0f 1f _+_ _·_ -_ _<_ min max .fst = IsLinearlyOrderedCommRing 0f 1f _+_ _·_ -_ _<_ min max isLinearlyOrderedCommRing 0f 1f _+_ _·_ -_ _<_ min max .snd = φ where abstract φ = {! !} -- this is ℚ record IsLinearlyOrderedField {ℓ ℓ'} {F : Type ℓ} (0f 1f : F) (_+_ _·_ : F → F → F) (-_ : F → F) (_<_ : hPropRel F F ℓ') (min max : F → F → F) : Type (ℓ-max ℓ ℓ') where constructor islinearlyorderedfield field is-LinearlyOrderedCommRing : [ isLinearlyOrderedCommRing 0f 1f _+_ _·_ (-_) _<_ min max ] open IsLinearlyOrderedCommRing is-LinearlyOrderedCommRing public field ·-inv'' : ∀ x → [ (∃[ y ] ([ is-set ] (x · y) ≡ˢ 1f)) ⇔ (x # 0f) ] isLinearlyOrderedField : ∀{ℓ ℓ'} {F : Type ℓ} (0f 1f : F) (_+_ _·_ : F → F → F) (-_ : F → F) (_<_ : hPropRel F F ℓ') (min max : F → F → F) → hProp (ℓ-max ℓ ℓ') isLinearlyOrderedField 0f 1f _+_ _·_ -_ _<_ min max .fst = IsLinearlyOrderedField 0f 1f _+_ _·_ -_ _<_ min max isLinearlyOrderedField 0f 1f _+_ _·_ -_ _<_ min max .snd = φ where abstract φ = {! !} -- this is ℝ record IsCompletePartiallyOrderedFieldWithSqrt {ℓ ℓ'} {F : Type ℓ} (0f 1f : F) (_+_ _·_ : F → F → F) (-_ : F → F) (_<_ : hPropRel F F ℓ') (min max : F → F → F) (sqrt : (x : F) → {{ ! [ ¬(x < 0f) ] }} → F) : Type (ℓ-max ℓ ℓ') where constructor iscompletepartiallyorderedfield field -- 1. 2. 3. 4. 5. 6. (†) and (∗) is-PartiallyOrderedField : [ isPartiallyOrderedField 0f 1f _+_ _·_ -_ _<_ min max ]
-- Andreas, 2013-04-06 -- Interaction point buried in postponed type checking problem module Issue1083 where data Bool : Set where true false : Bool T : Bool → Set T true = Bool → Bool T false = Bool postulate f : {x : Bool} → T x test : (x : Bool) → T x test true = f {!!} test false = {!!} -- Constraints show: _10 := (_ : T _x_9) ? : Bool -- So there is a question mark which has never been seen by the type checker. -- It is buried in a postponed type-checking problem. -- Interaction points should probably be created by the scope checker, -- and then hooked up to meta variables by the type checker. -- This is how it works now.
{-# LANGUAGE FlexibleContexts #-} module Main (main) where import Control.Monad (mzero) import Control.Monad.IO.Class (liftIO) import Data.Complex (Complex) import Data.Foldable (toList) import Data.Typeable (Typeable) import System.Console.GetOpt import Text.PrettyPrint.Mainland import Text.PrettyPrint.Mainland.Class import Spiral import Spiral.Backend.C import Spiral.Config import Spiral.Driver import Spiral.Exp import Spiral.FFT.CooleyTukey import Spiral.Monad import Spiral.OpCount import Spiral.Program import Spiral.SPL import Spiral.SPL.Run import Spiral.Search import Spiral.Search.FFTBreakdowns import Spiral.Util.Uniq main :: IO () main = defaultMainWith' options mempty $ \fs args -> do useComplexType <- asksConfig $ testDynFlag UseComplex n <- case args of [s] -> return (read s) _ -> return 4 f <- formula fs n pprint f if useComplexType then toProgram ("hspiral_dft_" ++ show n) f >>= go else toProgram ("hspiral_dft_" ++ show n) (Re f) >>= go where go :: (Typed a, Num (Exp a)) => Program a -> Spiral () go prog = do pprint prog ops <- countProgramOps prog resetUnique defs <- evalCg $ cgProgram prog outp <- asksConfig output case outp of Nothing -> return () Just{} -> writeOutput (toList defs) liftIO $ putDocLn $ text "Multiplications:" <+> ppr (mulOps ops) </> text " Additions:" <+> ppr (addOps ops) </> text " Total:" <+> ppr (allOps ops) -- The SPL formula for which we generate code and count operations. formula :: MonadSpiral m => [Flag] -> Int -> m (SPL (Exp (Complex Double))) formula fs n = case fs of [Dif] -> return $ dif n [Dit] -> return $ dit n [SplitRadix] -> runSearch () splitRadixSearch (DFT n) [ConjPairSplitRadix] -> runSearch () conjSplitRadixSearch (DFT n) [ImpSplitRadix] -> runSearch () impSplitRadixSearch (DFT n) _ -> fail "Must specify exactly on of --dif, --dit, --split-radix, conj-split-radix, or --improved-split-radix" where splitRadixSearch :: (Typeable a, Typed a, MonadSpiral m) => SPL (Exp a) -> S s m (SPL (Exp a)) splitRadixSearch (F n w) = splitRadixBreakdown n w splitRadixSearch _ = mzero conjSplitRadixSearch :: (Typeable a, Typed a, MonadSpiral m) => SPL (Exp a) -> S s m (SPL (Exp a)) conjSplitRadixSearch (F n w) = conjPairSplitRadixBreakdown n w conjSplitRadixSearch _ = mzero impSplitRadixSearch :: (Typeable a, Typed a, MonadSpiral m) => SPL (Exp a) -> S s m (SPL (Exp a)) impSplitRadixSearch (F n w) = improvedSplitRadixBreakdown n w impSplitRadixSearch _ = mzero data Flag = Dif | Dit | SplitRadix | ConjPairSplitRadix | ImpSplitRadix deriving (Eq, Ord, Show) options :: [OptDescr Flag] options = [ Option [] ["dif"] (NoArg Dif) "Use DIF" , Option [] ["dit"] (NoArg Dit) "Use DIT" , Option [] ["split-radix"] (NoArg SplitRadix) "Use split radix" , Option [] ["conj-split-radix"] (NoArg ConjPairSplitRadix) "Use conjugate pair split radix" , Option [] ["imp-split-radix"] (NoArg ImpSplitRadix) "Use improved split radix" ]
-- @@stderr -- dtrace: failed to compile script test/unittest/types/err.D_DECL_CHARATTR.badtype3.d: [D_DECL_CHARATTR] line 21: invalid type declaration: short and long may not be used with char type
Formal statement is: lemma continuous_discrete_range_constant: fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_algebra_1" assumes S: "connected S" and "continuous_on S f" and "\<And>x. x \<in> S \<Longrightarrow> \<exists>e>0. \<forall>y. y \<in> S \<and> f y \<noteq> f x \<longrightarrow> e \<le> norm (f y - f x)" shows "f constant_on S" Informal statement is: If $f$ is a continuous function from a connected set $S$ to a normed vector space, and for every $x \in S$, there exists an $\epsilon > 0$ such that for all $y \in S$, if $f(y) \neq f(x)$, then $\epsilon \leq \|f(y) - f(x)\|$, then $f$ is constant on $S$.
/- Copyright (c) 2018 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Johan Commelin, Bhavik Mehta -/ import Mathlib.PrePort import Mathlib.Lean3Lib.init.default import Mathlib.category_theory.natural_isomorphism import Mathlib.PostPort universes v₁ v₂ v₃ u₁ u₂ u₃ l namespace Mathlib /-! # Comma categories A comma category is a construction in category theory, which builds a category out of two functors with a common codomain. Specifically, for functors `L : A ⥤ T` and `R : B ⥤ T`, an object in `comma L R` is a morphism `hom : L.obj left ⟶ R.obj right` for some objects `left : A` and `right : B`, and a morphism in `comma L R` between `hom : L.obj left ⟶ R.obj right` and `hom' : L.obj left' ⟶ R.obj right'` is a commutative square ``` L.obj left ⟶ L.obj left' | | hom | | hom' ↓ ↓ R.obj right ⟶ R.obj right', ``` where the top and bottom morphism come from morphisms `left ⟶ left'` and `right ⟶ right'`, respectively. ## Main definitions * `comma L R`: the comma category of the functors `L` and `R`. * `over X`: the over category of the object `X` (developed in `over.lean`). * `under X`: the under category of the object `X` (also developed in `over.lean`). * `arrow T`: the arrow category of the category `T` (developed in `arrow.lean`). ## References * <https://ncatlab.org/nlab/show/comma+category> ## Tags comma, slice, coslice, over, under, arrow -/ namespace category_theory /-- The objects of the comma category are triples of an object `left : A`, an object `right : B` and a morphism `hom : L.obj left ⟶ R.obj right`. -/ structure comma {A : Type u₁} [category A] {B : Type u₂} [category B] {T : Type u₃} [category T] (L : A ⥤ T) (R : B ⥤ T) where left : autoParam A (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring "Mathlib.obviously") (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous "Mathlib") "obviously") []) right : autoParam B (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring "Mathlib.obviously") (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous "Mathlib") "obviously") []) hom : functor.obj L left ⟶ functor.obj R right -- Satisfying the inhabited linter protected instance comma.inhabited {T : Type u₃} [category T] [Inhabited T] : Inhabited (comma 𝟭 𝟭) := { default := comma.mk 𝟙 } /-- A morphism between two objects in the comma category is a commutative square connecting the morphisms coming from the two objects using morphisms in the image of the functors `L` and `R`. -/ structure comma_morphism {A : Type u₁} [category A] {B : Type u₂} [category B] {T : Type u₃} [category T] {L : A ⥤ T} {R : B ⥤ T} (X : comma L R) (Y : comma L R) where left : autoParam (comma.left X ⟶ comma.left Y) (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring "Mathlib.obviously") (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous "Mathlib") "obviously") []) right : autoParam (comma.right X ⟶ comma.right Y) (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring "Mathlib.obviously") (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous "Mathlib") "obviously") []) w' : autoParam (functor.map L left ≫ comma.hom Y = comma.hom X ≫ functor.map R right) (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring "Mathlib.obviously") (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous "Mathlib") "obviously") []) -- Satisfying the inhabited linter protected instance comma_morphism.inhabited {A : Type u₁} [category A] {B : Type u₂} [category B] {T : Type u₃} [category T] {L : A ⥤ T} {R : B ⥤ T} [Inhabited (comma L R)] : Inhabited (comma_morphism Inhabited.default Inhabited.default) := { default := comma_morphism.mk } @[simp] theorem comma_morphism.w {A : Type u₁} [category A] {B : Type u₂} [category B] {T : Type u₃} [category T] {L : A ⥤ T} {R : B ⥤ T} {X : comma L R} {Y : comma L R} (c : comma_morphism X Y) : functor.map L (comma_morphism.left c) ≫ comma.hom Y = comma.hom X ≫ functor.map R (comma_morphism.right c) := sorry @[simp] theorem comma_morphism.w_assoc {A : Type u₁} [category A] {B : Type u₂} [category B] {T : Type u₃} [category T] {L : A ⥤ T} {R : B ⥤ T} {X : comma L R} {Y : comma L R} (c : comma_morphism X Y) {X' : T} (f' : functor.obj R (comma.right Y) ⟶ X') : functor.map L (comma_morphism.left c) ≫ comma.hom Y ≫ f' = comma.hom X ≫ functor.map R (comma_morphism.right c) ≫ f' := sorry protected instance comma_category {A : Type u₁} [category A] {B : Type u₂} [category B] {T : Type u₃} [category T] {L : A ⥤ T} {R : B ⥤ T} : category (comma L R) := category.mk namespace comma @[simp] theorem id_left {A : Type u₁} [category A] {B : Type u₂} [category B] {T : Type u₃} [category T] {L : A ⥤ T} {R : B ⥤ T} {X : comma L R} : comma_morphism.left 𝟙 = 𝟙 := rfl @[simp] theorem id_right {A : Type u₁} [category A] {B : Type u₂} [category B] {T : Type u₃} [category T] {L : A ⥤ T} {R : B ⥤ T} {X : comma L R} : comma_morphism.right 𝟙 = 𝟙 := rfl @[simp] theorem comp_left {A : Type u₁} [category A] {B : Type u₂} [category B] {T : Type u₃} [category T] {L : A ⥤ T} {R : B ⥤ T} {X : comma L R} {Y : comma L R} {Z : comma L R} {f : X ⟶ Y} {g : Y ⟶ Z} : comma_morphism.left (f ≫ g) = comma_morphism.left f ≫ comma_morphism.left g := rfl @[simp] theorem comp_right {A : Type u₁} [category A] {B : Type u₂} [category B] {T : Type u₃} [category T] {L : A ⥤ T} {R : B ⥤ T} {X : comma L R} {Y : comma L R} {Z : comma L R} {f : X ⟶ Y} {g : Y ⟶ Z} : comma_morphism.right (f ≫ g) = comma_morphism.right f ≫ comma_morphism.right g := rfl /-- The functor sending an object `X` in the comma category to `X.left`. -/ def fst {A : Type u₁} [category A] {B : Type u₂} [category B] {T : Type u₃} [category T] (L : A ⥤ T) (R : B ⥤ T) : comma L R ⥤ A := functor.mk (fun (X : comma L R) => left X) fun (_x _x_1 : comma L R) (f : _x ⟶ _x_1) => comma_morphism.left f /-- The functor sending an object `X` in the comma category to `X.right`. -/ @[simp] theorem snd_map {A : Type u₁} [category A] {B : Type u₂} [category B] {T : Type u₃} [category T] (L : A ⥤ T) (R : B ⥤ T) (_x : comma L R) : ∀ (_x_1 : comma L R) (f : _x ⟶ _x_1), functor.map (snd L R) f = comma_morphism.right f := fun (_x_1 : comma L R) (f : _x ⟶ _x_1) => Eq.refl (functor.map (snd L R) f) /-- We can interpret the commutative square constituting a morphism in the comma category as a natural transformation between the functors `fst ⋙ L` and `snd ⋙ R` from the comma category to `T`, where the components are given by the morphism that constitutes an object of the comma category. -/ @[simp] theorem nat_trans_app {A : Type u₁} [category A] {B : Type u₂} [category B] {T : Type u₃} [category T] (L : A ⥤ T) (R : B ⥤ T) (X : comma L R) : nat_trans.app (nat_trans L R) X = hom X := Eq.refl (nat_trans.app (nat_trans L R) X) /-- Construct an isomorphism in the comma category given isomorphisms of the objects whose forward directions give a commutative square. -/ @[simp] theorem iso_mk_inv_left {A : Type u₁} [category A] {B : Type u₂} [category B] {T : Type u₃} [category T] {L₁ : A ⥤ T} {R₁ : B ⥤ T} {X : comma L₁ R₁} {Y : comma L₁ R₁} (l : left X ≅ left Y) (r : right X ≅ right Y) (h : functor.map L₁ (iso.hom l) ≫ hom Y = hom X ≫ functor.map R₁ (iso.hom r)) : comma_morphism.left (iso.inv (iso_mk l r h)) = iso.inv l := Eq.refl (comma_morphism.left (iso.inv (iso_mk l r h))) /-- A natural transformation `L₁ ⟶ L₂` induces a functor `comma L₂ R ⥤ comma L₁ R`. -/ @[simp] theorem map_left_obj_right {A : Type u₁} [category A] {B : Type u₂} [category B] {T : Type u₃} [category T] (R : B ⥤ T) {L₁ : A ⥤ T} {L₂ : A ⥤ T} (l : L₁ ⟶ L₂) (X : comma L₂ R) : right (functor.obj (map_left R l) X) = right X := Eq.refl (right (functor.obj (map_left R l) X)) /-- The functor `comma L R ⥤ comma L R` induced by the identity natural transformation on `L` is naturally isomorphic to the identity functor. -/ @[simp] theorem map_left_id_inv_app_right {A : Type u₁} [category A] {B : Type u₂} [category B] {T : Type u₃} [category T] (L : A ⥤ T) (R : B ⥤ T) (X : comma L R) : comma_morphism.right (nat_trans.app (iso.inv (map_left_id L R)) X) = 𝟙 := Eq.refl (comma_morphism.right (nat_trans.app (iso.inv (map_left_id L R)) X)) /-- The functor `comma L₁ R ⥤ comma L₃ R` induced by the composition of two natural transformations `l : L₁ ⟶ L₂` and `l' : L₂ ⟶ L₃` is naturally isomorphic to the composition of the two functors induced by these natural transformations. -/ @[simp] theorem map_left_comp_hom_app_left {A : Type u₁} [category A] {B : Type u₂} [category B] {T : Type u₃} [category T] (R : B ⥤ T) {L₁ : A ⥤ T} {L₂ : A ⥤ T} {L₃ : A ⥤ T} (l : L₁ ⟶ L₂) (l' : L₂ ⟶ L₃) (X : comma L₃ R) : comma_morphism.left (nat_trans.app (iso.hom (map_left_comp R l l')) X) = 𝟙 := Eq.refl (comma_morphism.left (nat_trans.app (iso.hom (map_left_comp R l l')) X)) /-- A natural transformation `R₁ ⟶ R₂` induces a functor `comma L R₁ ⥤ comma L R₂`. -/ def map_right {A : Type u₁} [category A] {B : Type u₂} [category B] {T : Type u₃} [category T] (L : A ⥤ T) {R₁ : B ⥤ T} {R₂ : B ⥤ T} (r : R₁ ⟶ R₂) : comma L R₁ ⥤ comma L R₂ := functor.mk (fun (X : comma L R₁) => mk (hom X ≫ nat_trans.app r (right X))) fun (X Y : comma L R₁) (f : X ⟶ Y) => comma_morphism.mk /-- The functor `comma L R ⥤ comma L R` induced by the identity natural transformation on `R` is naturally isomorphic to the identity functor. -/ @[simp] theorem map_right_id_inv_app_left {A : Type u₁} [category A] {B : Type u₂} [category B] {T : Type u₃} [category T] (L : A ⥤ T) (R : B ⥤ T) (X : comma L R) : comma_morphism.left (nat_trans.app (iso.inv (map_right_id L R)) X) = 𝟙 := Eq.refl (comma_morphism.left (nat_trans.app (iso.inv (map_right_id L R)) X)) /-- The functor `comma L R₁ ⥤ comma L R₃` induced by the composition of the natural transformations `r : R₁ ⟶ R₂` and `r' : R₂ ⟶ R₃` is naturally isomorphic to the composition of the functors induced by these natural transformations. -/ @[simp] theorem map_right_comp_inv_app_right {A : Type u₁} [category A] {B : Type u₂} [category B] {T : Type u₃} [category T] (L : A ⥤ T) {R₁ : B ⥤ T} {R₂ : B ⥤ T} {R₃ : B ⥤ T} (r : R₁ ⟶ R₂) (r' : R₂ ⟶ R₃) (X : comma L R₁) : comma_morphism.right (nat_trans.app (iso.inv (map_right_comp L r r')) X) = 𝟙 := Eq.refl (comma_morphism.right (nat_trans.app (iso.inv (map_right_comp L r r')) X)) end Mathlib
Formal statement is: lemma locally_compact_Times: fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" shows "\<lbrakk>locally compact S; locally compact T\<rbrakk> \<Longrightarrow> locally compact (S \<times> T)" Informal statement is: If $S$ and $T$ are locally compact, then $S \times T$ is locally compact.
Formal statement is: lemma primitive_part_prim: "content p = 1 \<Longrightarrow> primitive_part p = p" Informal statement is: If the content of a polynomial is 1, then the primitive part of the polynomial is the polynomial itself.
Formal statement is: lemma isometry_subset_subspace: fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" assumes S: "subspace S" and T: "subspace T" and d: "dim S \<le> dim T" obtains f where "linear f" "f ` S \<subseteq> T" "\<And>x. x \<in> S \<Longrightarrow> norm(f x) = norm x" Informal statement is: If $S$ is a subspace of $\mathbb{R}^n$ and $T$ is a subspace of $\mathbb{R}^m$ with $n \leq m$, then there exists a linear map $f: \mathbb{R}^n \to \mathbb{R}^m$ such that $f(S) \subseteq T$ and $||f(x)|| = ||x||$ for all $x \in S$.
[STATEMENT] lemma pderivs_lang_Times_aux2: assumes a: "s \<in> UNIV1" shows "Timess (pderivs s r1) r2 \<subseteq> Timess (pderivs_lang UNIV1 r1) r2" [PROOF STATE] proof (prove) goal (1 subgoal): 1. Timess (pderivs s r1) r2 \<subseteq> Timess (pderivs_lang UNIV1 r1) r2 [PROOF STEP] using a [PROOF STATE] proof (prove) using this: s \<in> UNIV1 goal (1 subgoal): 1. Timess (pderivs s r1) r2 \<subseteq> Timess (pderivs_lang UNIV1 r1) r2 [PROOF STEP] unfolding pderivs_lang_def [PROOF STATE] proof (prove) using this: s \<in> UNIV1 goal (1 subgoal): 1. Timess (pderivs s r1) r2 \<subseteq> Timess (\<Union>x\<in>UNIV1. pderivs x r1) r2 [PROOF STEP] by auto
theory tmpl02_aexp imports Main begin type_synonym vname = string type_synonym state = "string \<Rightarrow> int" type_synonym val = "int" declare algebra_simps[simp] datatype aexp = N int | V vname | Plus aexp aexp | Mult int aexp fun aval :: "aexp \<Rightarrow> state \<Rightarrow> val" where "aval (N n) s = n" | "aval (V x) s = s x" | "aval (Plus a\<^sub>1 a\<^sub>2) s = aval a\<^sub>1 s + aval a\<^sub>2 s" | "aval (Mult i a) s = i * aval a s" text \<open> \textbf{Step A} Implement the function @{text normal} which returns @{const True} only when the arithmetic expression is normalized. \<close> fun normal :: "aexp \<Rightarrow> bool" where "normal a = undefined" text \<open> \textbf{Step B} Implement the function @{text normallize} which translates an arbitrary arithmetic expression intro a normalized arithmetic expression. \<close> fun normalize :: "aexp \<Rightarrow> aexp" where "normalize a = undefined" text \<open> \textbf{Step C} Prove that @{const normalize} does not change the result of the arithmetic expression. \<close> lemma "aval (normalize a) s = aval a s" oops text \<open> \textbf{Step D} Prove that @{const normalize} does indeed return a normalized arithmetic expression. \<close> lemma "normal (normalize a)" oops end
$\i$ is an algebraic integer.
Formal statement is: lemma mem_ball_imp_mem_cball: "x \<in> ball y e \<Longrightarrow> x \<in> cball y e" Informal statement is: If $x$ is in the open ball of radius $e$ centered at $y$, then $x$ is in the closed ball of radius $e$ centered at $y$.
[STATEMENT] lemma rt_fresher_def2: assumes "dip \<in> kD(rt1)" and "dip \<in> kD(rt2)" shows "(rt1 \<sqsubseteq>\<^bsub>dip\<^esub> rt2) = (nsqn rt1 dip < nsqn rt2 dip \<or> (nsqn rt1 dip = nsqn rt2 dip \<and> the (dhops rt1 dip) \<ge> the (dhops rt2 dip)))" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (rt1 \<sqsubseteq>\<^bsub>dip\<^esub> rt2) = (nsqn rt1 dip < nsqn rt2 dip \<or> nsqn rt1 dip = nsqn rt2 dip \<and> the (dhops rt2 dip) \<le> the (dhops rt1 dip)) [PROOF STEP] using assms [PROOF STATE] proof (prove) using this: dip \<in> kD rt1 dip \<in> kD rt2 goal (1 subgoal): 1. (rt1 \<sqsubseteq>\<^bsub>dip\<^esub> rt2) = (nsqn rt1 dip < nsqn rt2 dip \<or> nsqn rt1 dip = nsqn rt2 dip \<and> the (dhops rt2 dip) \<le> the (dhops rt1 dip)) [PROOF STEP] unfolding rt_fresher_def fresher_def [PROOF STATE] proof (prove) using this: dip \<in> kD rt1 dip \<in> kD rt2 goal (1 subgoal): 1. (nsqn\<^sub>r (the (rt1 dip)) < nsqn\<^sub>r (the (rt2 dip)) \<or> nsqn\<^sub>r (the (rt1 dip)) = nsqn\<^sub>r (the (rt2 dip)) \<and> \<pi>\<^sub>5 (the (rt2 dip)) \<le> \<pi>\<^sub>5 (the (rt1 dip))) = (nsqn rt1 dip < nsqn rt2 dip \<or> nsqn rt1 dip = nsqn rt2 dip \<and> the (dhops rt2 dip) \<le> the (dhops rt1 dip)) [PROOF STEP] by (simp add: kD_nsqn proj5_eq_dhops)
-- {-# OPTIONS -v tc.meta.assign:15 #-} -- Ulf, 2011-10-04 -- I still don't quite believe in irrelevant levels. In part because I just proved ⊥: module IrrelevantLevelHurkens where open import Imports.Level data _≡_ {a}{A : Set a}(x : A) : A → Set where refl : x ≡ x data Irr .(i : Level)(A : Set i) : Set where irr : Irr i A data Unit : Set where unit : Unit unirr : ∀ .i (A : Set i) → Irr i A → Unit unirr i A irr = unit ↓_ : ∀ .{i} → Set i → Set foo : ∀ .{i}{A : Set i}(x : Irr i A) → unirr i A x ≡ unirr zero (↓ A) _ ↓ A = _ foo xs = refl {- Andreas, 2011-10-04 Irrelevant Levels do not harmonize with solving type of meta = .{.i : Level} (A : Set .i) → Set solving _39 := λ {.i} A → A term _38 xs := xs passed occursCheck type of meta = ..{i : Level} {A : Set i} (x : Irr .(i) A) → Irr .(zero) (↓ A) solving _38 := λ {i} {A} x → x The solutions x and A for the two holes do not type check, if entered manually. The solver would need to re-type-check to make sure solutions are correct. For now, just do not supply --experimental-irrelevance flag. -} ⊥′ : Set ⊥′ = ↓ ((A : Set) → A) ¬_ : Set → Set ¬ A = A → ⊥′ P : Set → Set P A = ↓ (A → Set) U : Set U = ↓ ((X : Set) → (P (P X) → X) → P (P X)) τ : P (P U) → U τ t = λ X f p → t λ x → p (f (x X f)) σ : U → P (P U) σ s pu = s U (λ t → τ t) pu Δ : P U Δ = λ y → ¬ ((p : P U) → σ y p → p (τ (σ y))) Ω : U Ω X t px = τ (λ p → (x : U) → σ x p → p x) X t px D : Set D = (p : P U) → σ Ω p → p (τ (σ Ω)) lem₁ : (p : P U) → ((x : U) → σ x p → p x) → p Ω lem₁ p H1 = H1 Ω λ x → H1 (τ (σ x)) lem₂ : ¬ D lem₂ d A = lem₁ Δ (λ x H2 H3 → H3 Δ H2 λ p → H3 λ y → p (τ (σ y))) d A lem₃ : D lem₃ p = lem₁ λ y → p (τ (σ y)) loop : ⊥′ loop = λ A → lem₂ lem₃ A data ⊥ : Set where false : ⊥ false = loop ⊥
-- Andreas, 2011-09-12 -- eta for records in unifier -- {-# OPTIONS -v tc.lhs.unify:25 #-} module Issue455 where postulate A : Set a : A record Fork : Set where constructor pair field fst : A snd : A open Fork data D : Fork -> Set where c : (x y : A) -> D (pair x y) postulate p : Fork f : D p -> Set f (c .(fst p) .(snd p)) = A -- should work! {- Unifier gives up on: f z = {!z!} Cannot decide whether there should be a case for the constructor c, since the unification gets stuck on unifying the inferred indices [pair x y] with the expected indices [p] -} record ⊤ : Set where constructor tt data E : ⊤ -> Set where e : E tt postulate q : ⊤ g : E q -> Set g e = ⊤
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Bhavik Mehta -/ import category_theory.monad.adjunction import category_theory.adjunction.limits import category_theory.limits.preserves.shapes.terminal /-! # Limits and colimits in the category of algebras This file shows that the forgetful functor `forget T : algebra T ⥤ C` for a monad `T : C ⥤ C` creates limits and creates any colimits which `T` preserves. This is used to show that `algebra T` has any limits which `C` has, and any colimits which `C` has and `T` preserves. This is generalised to the case of a monadic functor `D ⥤ C`. ## TODO Dualise for the category of coalgebras and comonadic left adjoints. -/ namespace category_theory open category open category_theory.limits universes v u v₁ v₂ u₁ u₂ -- morphism levels before object levels. See note [category_theory universes]. namespace monad variables {C : Type u₁} [category.{v₁} C] variables {T : monad C} variables {J : Type u} [category.{v} J] namespace forget_creates_limits variables (D : J ⥤ algebra T) (c : cone (D ⋙ T.forget)) (t : is_limit c) /-- (Impl) The natural transformation used to define the new cone -/ @[simps] def γ : (D ⋙ T.forget ⋙ ↑T) ⟶ D ⋙ T.forget := { app := λ j, (D.obj j).a } /-- (Impl) This new cone is used to construct the algebra structure -/ @[simps π_app] def new_cone : cone (D ⋙ forget T) := { X := T.obj c.X, π := (functor.const_comp _ _ ↑T).inv ≫ whisker_right c.π T ≫ γ D } /-- The algebra structure which will be the apex of the new limit cone for `D`. -/ @[simps] def cone_point : algebra T := { A := c.X, a := t.lift (new_cone D c), unit' := t.hom_ext $ λ j, begin rw [category.assoc, t.fac, new_cone_π_app, ←T.η.naturality_assoc, functor.id_map, (D.obj j).unit], dsimp, simp -- See library note [dsimp, simp] end, assoc' := t.hom_ext $ λ j, begin rw [category.assoc, category.assoc, t.fac (new_cone D c), new_cone_π_app, ←functor.map_comp_assoc, t.fac (new_cone D c), new_cone_π_app, ←T.μ.naturality_assoc, (D.obj j).assoc, functor.map_comp, category.assoc], refl, end } /-- (Impl) Construct the lifted cone in `algebra T` which will be limiting. -/ @[simps] def lifted_cone : cone D := { X := cone_point D c t, π := { app := λ j, { f := c.π.app j }, naturality' := λ X Y f, by { ext1, dsimp, erw c.w f, simp } } } /-- (Impl) Prove that the lifted cone is limiting. -/ @[simps] def lifted_cone_is_limit : is_limit (lifted_cone D c t) := { lift := λ s, { f := t.lift ((forget T).map_cone s), h' := t.hom_ext $ λ j, begin dsimp, rw [category.assoc, category.assoc, t.fac, new_cone_π_app, ←functor.map_comp_assoc, t.fac, functor.map_cone_π_app], apply (s.π.app j).h, end }, uniq' := λ s m J, begin ext1, apply t.hom_ext, intro j, simpa [t.fac ((forget T).map_cone s) j] using congr_arg algebra.hom.f (J j), end } end forget_creates_limits -- Theorem 5.6.5 from [Riehl][riehl2017] /-- The forgetful functor from the Eilenberg-Moore category creates limits. -/ noncomputable instance forget_creates_limits : creates_limits_of_size (forget T) := { creates_limits_of_shape := λ J 𝒥, by exactI { creates_limit := λ D, creates_limit_of_reflects_iso (λ c t, { lifted_cone := forget_creates_limits.lifted_cone D c t, valid_lift := cones.ext (iso.refl _) (λ j, (id_comp _).symm), makes_limit := forget_creates_limits.lifted_cone_is_limit _ _ _ } ) } } /-- `D ⋙ forget T` has a limit, then `D` has a limit. -/ lemma has_limit_of_comp_forget_has_limit (D : J ⥤ algebra T) [has_limit (D ⋙ forget T)] : has_limit D := has_limit_of_created D (forget T) namespace forget_creates_colimits -- Let's hide the implementation details in a namespace variables {D : J ⥤ algebra T} (c : cocone (D ⋙ forget T)) (t : is_colimit c) -- We have a diagram D of shape J in the category of algebras, and we assume that we are given a -- colimit for its image D ⋙ forget T under the forgetful functor, say its apex is L. -- We'll construct a colimiting coalgebra for D, whose carrier will also be L. -- To do this, we must find a map TL ⟶ L. Since T preserves colimits, TL is also a colimit. -- In particular, it is a colimit for the diagram `(D ⋙ forget T) ⋙ T` -- so to construct a map TL ⟶ L it suffices to show that L is the apex of a cocone for this diagram. -- In other words, we need a natural transformation from const L to `(D ⋙ forget T) ⋙ T`. -- But we already know that L is the apex of a cocone for the diagram `D ⋙ forget T`, so it -- suffices to give a natural transformation `((D ⋙ forget T) ⋙ T) ⟶ (D ⋙ forget T)`: /-- (Impl) The natural transformation given by the algebra structure maps, used to construct a cocone `c` with apex `colimit (D ⋙ forget T)`. -/ @[simps] def γ : ((D ⋙ forget T) ⋙ ↑T) ⟶ (D ⋙ forget T) := { app := λ j, (D.obj j).a } /-- (Impl) A cocone for the diagram `(D ⋙ forget T) ⋙ T` found by composing the natural transformation `γ` with the colimiting cocone for `D ⋙ forget T`. -/ @[simps] def new_cocone : cocone ((D ⋙ forget T) ⋙ ↑T) := { X := c.X, ι := γ ≫ c.ι } variables [preserves_colimit (D ⋙ forget T) (T : C ⥤ C)] /-- (Impl) Define the map `λ : TL ⟶ L`, which will serve as the structure of the coalgebra on `L`, and we will show is the colimiting object. We use the cocone constructed by `c` and the fact that `T` preserves colimits to produce this morphism. -/ @[reducible] def lambda : ((T : C ⥤ C).map_cocone c).X ⟶ c.X := (is_colimit_of_preserves _ t).desc (new_cocone c) /-- (Impl) The key property defining the map `λ : TL ⟶ L`. -/ lemma commuting (j : J) : (T : C ⥤ C).map (c.ι.app j) ≫ lambda c t = (D.obj j).a ≫ c.ι.app j := (is_colimit_of_preserves _ t).fac (new_cocone c) j variables [preserves_colimit ((D ⋙ forget T) ⋙ ↑T) (T : C ⥤ C)] /-- (Impl) Construct the colimiting algebra from the map `λ : TL ⟶ L` given by `lambda`. We are required to show it satisfies the two algebra laws, which follow from the algebra laws for the image of `D` and our `commuting` lemma. -/ @[simps] def cocone_point : algebra T := { A := c.X, a := lambda c t, unit' := begin apply t.hom_ext, intro j, rw [(show c.ι.app j ≫ T.η.app c.X ≫ _ = T.η.app (D.obj j).A ≫ _ ≫ _, from T.η.naturality_assoc _ _), commuting, algebra.unit_assoc (D.obj j)], dsimp, simp -- See library note [dsimp, simp] end, assoc' := begin refine (is_colimit_of_preserves _ (is_colimit_of_preserves _ t)).hom_ext (λ j, _), rw [functor.map_cocone_ι_app, functor.map_cocone_ι_app, (show (T : C ⥤ C).map ((T : C ⥤ C).map _) ≫ _ ≫ _ = _, from T.μ.naturality_assoc _ _), ←functor.map_comp_assoc, commuting, functor.map_comp, category.assoc, commuting], apply (D.obj j).assoc_assoc _, end } /-- (Impl) Construct the lifted cocone in `algebra T` which will be colimiting. -/ @[simps] def lifted_cocone : cocone D := { X := cocone_point c t, ι := { app := λ j, { f := c.ι.app j, h' := commuting _ _ _ }, naturality' := λ A B f, by { ext1, dsimp, rw [comp_id], apply c.w } } } /-- (Impl) Prove that the lifted cocone is colimiting. -/ @[simps] def lifted_cocone_is_colimit : is_colimit (lifted_cocone c t) := { desc := λ s, { f := t.desc ((forget T).map_cocone s), h' := (is_colimit_of_preserves (T : C ⥤ C) t).hom_ext $ λ j, begin dsimp, rw [←functor.map_comp_assoc, ←category.assoc, t.fac, commuting, category.assoc, t.fac], apply algebra.hom.h, end }, uniq' := λ s m J, by { ext1, apply t.hom_ext, intro j, simpa using congr_arg algebra.hom.f (J j) } } end forget_creates_colimits open forget_creates_colimits -- TODO: the converse of this is true as well /-- The forgetful functor from the Eilenberg-Moore category for a monad creates any colimit which the monad itself preserves. -/ noncomputable instance forget_creates_colimit (D : J ⥤ algebra T) [preserves_colimit (D ⋙ forget T) (T : C ⥤ C)] [preserves_colimit ((D ⋙ forget T) ⋙ ↑T) (T : C ⥤ C)] : creates_colimit D (forget T) := creates_colimit_of_reflects_iso $ λ c t, { lifted_cocone := { X := cocone_point c t, ι := { app := λ j, { f := c.ι.app j, h' := commuting _ _ _ }, naturality' := λ A B f, by { ext1, dsimp, erw [comp_id, c.w] } } }, valid_lift := cocones.ext (iso.refl _) (by tidy), makes_colimit := lifted_cocone_is_colimit _ _ } noncomputable instance forget_creates_colimits_of_shape [preserves_colimits_of_shape J (T : C ⥤ C)] : creates_colimits_of_shape J (forget T) := { creates_colimit := λ K, by apply_instance } noncomputable instance forget_creates_colimits [preserves_colimits_of_size.{v u} (T : C ⥤ C)] : creates_colimits_of_size.{v u} (forget T) := { creates_colimits_of_shape := λ J 𝒥₁, by apply_instance } /-- For `D : J ⥤ algebra T`, `D ⋙ forget T` has a colimit, then `D` has a colimit provided colimits of shape `J` are preserved by `T`. -/ lemma forget_creates_colimits_of_monad_preserves [preserves_colimits_of_shape J (T : C ⥤ C)] (D : J ⥤ algebra T) [has_colimit (D ⋙ forget T)] : has_colimit D := has_colimit_of_created D (forget T) end monad variables {C : Type u₁} [category.{v₁} C] {D : Type u₂} [category.{v₂} D] variables {J : Type u} [category.{v} J] instance comp_comparison_forget_has_limit (F : J ⥤ D) (R : D ⥤ C) [monadic_right_adjoint R] [has_limit (F ⋙ R)] : has_limit ((F ⋙ monad.comparison (adjunction.of_right_adjoint R)) ⋙ monad.forget _) := @has_limit_of_iso _ _ _ _ (F ⋙ R) _ _ (iso_whisker_left F (monad.comparison_forget (adjunction.of_right_adjoint R)).symm) instance comp_comparison_has_limit (F : J ⥤ D) (R : D ⥤ C) [monadic_right_adjoint R] [has_limit (F ⋙ R)] : has_limit (F ⋙ monad.comparison (adjunction.of_right_adjoint R)) := monad.has_limit_of_comp_forget_has_limit (F ⋙ monad.comparison (adjunction.of_right_adjoint R)) /-- Any monadic functor creates limits. -/ noncomputable def monadic_creates_limits (R : D ⥤ C) [monadic_right_adjoint R] : creates_limits_of_size.{v u} R := creates_limits_of_nat_iso (monad.comparison_forget (adjunction.of_right_adjoint R)) /-- The forgetful functor from the Eilenberg-Moore category for a monad creates any colimit which the monad itself preserves. -/ noncomputable def monadic_creates_colimit_of_preserves_colimit (R : D ⥤ C) (K : J ⥤ D) [monadic_right_adjoint R] [preserves_colimit (K ⋙ R) (left_adjoint R ⋙ R)] [preserves_colimit ((K ⋙ R) ⋙ left_adjoint R ⋙ R) (left_adjoint R ⋙ R)] : creates_colimit K R := begin apply creates_colimit_of_nat_iso (monad.comparison_forget (adjunction.of_right_adjoint R)), apply category_theory.comp_creates_colimit _ _, apply_instance, let i : ((K ⋙ monad.comparison (adjunction.of_right_adjoint R)) ⋙ monad.forget _) ≅ K ⋙ R := functor.associator _ _ _ ≪≫ iso_whisker_left K (monad.comparison_forget (adjunction.of_right_adjoint R)), apply category_theory.monad.forget_creates_colimit _, { dsimp, refine preserves_colimit_of_iso_diagram _ i.symm }, { dsimp, refine preserves_colimit_of_iso_diagram _ (iso_whisker_right i (left_adjoint R ⋙ R)).symm }, end /-- A monadic functor creates any colimits of shapes it preserves. -/ noncomputable def monadic_creates_colimits_of_shape_of_preserves_colimits_of_shape (R : D ⥤ C) [monadic_right_adjoint R] [preserves_colimits_of_shape J R] : creates_colimits_of_shape J R := begin have : preserves_colimits_of_shape J (left_adjoint R ⋙ R), { apply category_theory.limits.comp_preserves_colimits_of_shape _ _, apply (adjunction.left_adjoint_preserves_colimits (adjunction.of_right_adjoint R)).1, apply_instance }, exactI ⟨λ K, monadic_creates_colimit_of_preserves_colimit _ _⟩, end /-- A monadic functor creates colimits if it preserves colimits. -/ noncomputable def monadic_creates_colimits_of_preserves_colimits (R : D ⥤ C) [monadic_right_adjoint R] [preserves_colimits_of_size.{v u} R] : creates_colimits_of_size.{v u} R := { creates_colimits_of_shape := λ J 𝒥₁, by exactI monadic_creates_colimits_of_shape_of_preserves_colimits_of_shape _ } section lemma has_limit_of_reflective (F : J ⥤ D) (R : D ⥤ C) [has_limit (F ⋙ R)] [reflective R] : has_limit F := by { haveI := monadic_creates_limits.{v u} R, exact has_limit_of_created F R } /-- If `C` has limits of shape `J` then any reflective subcategory has limits of shape `J`. -/ lemma has_limits_of_shape_of_reflective [has_limits_of_shape J C] (R : D ⥤ C) [reflective R] : has_limits_of_shape J D := { has_limit := λ F, has_limit_of_reflective F R } /-- If `C` has limits then any reflective subcategory has limits. -/ lemma has_limits_of_reflective (R : D ⥤ C) [has_limits_of_size.{v u} C] [reflective R] : has_limits_of_size.{v u} D := { has_limits_of_shape := λ J 𝒥₁, by exactI has_limits_of_shape_of_reflective R } /-- If `C` has colimits of shape `J` then any reflective subcategory has colimits of shape `J`. -/ lemma has_colimits_of_shape_of_reflective (R : D ⥤ C) [reflective R] [has_colimits_of_shape J C] : has_colimits_of_shape J D := { has_colimit := λ F, begin let c := (left_adjoint R).map_cocone (colimit.cocone (F ⋙ R)), let h := (adjunction.of_right_adjoint R).left_adjoint_preserves_colimits.1, letI := @h J _, let t : is_colimit c := is_colimit_of_preserves (left_adjoint R) (colimit.is_colimit _), apply has_colimit.mk ⟨_, (is_colimit.precompose_inv_equiv _ _).symm t⟩, apply (iso_whisker_left F (as_iso (adjunction.of_right_adjoint R).counit) : _) ≪≫ F.right_unitor, end } /-- If `C` has colimits then any reflective subcategory has colimits. -/ lemma has_colimits_of_reflective (R : D ⥤ C) [reflective R] [has_colimits_of_size.{v u} C] : has_colimits_of_size.{v u} D := { has_colimits_of_shape := λ J 𝒥, by exactI has_colimits_of_shape_of_reflective R } /-- The reflector always preserves terminal objects. Note this in general doesn't apply to any other limit. -/ noncomputable def left_adjoint_preserves_terminal_of_reflective (R : D ⥤ C) [reflective R] : preserves_limits_of_shape (discrete.{v} pempty) (left_adjoint R) := { preserves_limit := λ K, let F := functor.empty.{v} D in begin apply preserves_limit_of_iso_diagram _ (functor.empty_ext (F ⋙ R) _), fsplit, intros c h, haveI : has_limit (F ⋙ R) := ⟨⟨⟨c,h⟩⟩⟩, haveI : has_limit F := has_limit_of_reflective F R, apply is_limit_change_empty_cone D (limit.is_limit F), apply (as_iso ((adjunction.of_right_adjoint R).counit.app _)).symm.trans, { apply (left_adjoint R).map_iso, letI := monadic_creates_limits.{v v} R, let := (category_theory.preserves_limit_of_creates_limit_and_has_limit F R).preserves, apply (this (limit.is_limit F)).cone_point_unique_up_to_iso h }, apply_instance, end } end end category_theory
[STATEMENT] lemma unit_eq: "(a::unit) \<equiv> b" [PROOF STATE] proof (prove) goal (1 subgoal): 1. a \<equiv> b [PROOF STEP] by simp
[STATEMENT] lemma delete_update: "k \<noteq> l \<Longrightarrow> delete l (update k v al) = update k v (delete l al)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. k \<noteq> l \<Longrightarrow> delete l (update k v al) = update k v (delete l al) [PROOF STEP] by (induct al) simp_all
section \<open>\isaheader{Set Interface}\<close> theory Intf_Set imports Refine_Monadic.Refine_Monadic begin consts i_set :: "interface \<Rightarrow> interface" lemmas [autoref_rel_intf] = REL_INTFI[of set_rel i_set] definition [simp]: "op_set_delete x s \<equiv> s - {x}" definition [simp]: "op_set_isEmpty s \<equiv> s = {}" definition [simp]: "op_set_isSng s \<equiv> card s = 1" definition [simp]: "op_set_size_abort m s \<equiv> min m (card s)" definition [simp]: "op_set_disjoint a b \<equiv> a\<inter>b={}" definition [simp]: "op_set_filter P s \<equiv> {x\<in>s. P x}" definition [simp]: "op_set_sel P s \<equiv> SPEC (\<lambda>x. x\<in>s \<and> P x)" definition [simp]: "op_set_pick s \<equiv> SPEC (\<lambda>x. x\<in>s)" definition [simp]: "op_set_to_sorted_list ordR s \<equiv> SPEC (\<lambda>l. set l = s \<and> distinct l \<and> sorted_wrt ordR l)" definition [simp]: "op_set_to_list s \<equiv> SPEC (\<lambda>l. set l = s \<and> distinct l)" definition [simp]: "op_set_cart x y \<equiv> x \<times> y" (* TODO: Do op_set_pick_remove (like op_map_pick_remove) *) context begin interpretation autoref_syn . "s = {} \<equiv> op_set_isEmpty$s" "{}=s \<equiv> op_set_isEmpty$s" "card s = 1 \<equiv> op_set_isSng$s" "\<exists>x. s={x} \<equiv> op_set_isSng$s" "\<exists>x. {x}=s \<equiv> op_set_isSng$s" "min m (card s) \<equiv> op_set_size_abort$m$s" "min (card s) m \<equiv> op_set_size_abort$m$s" "a\<inter>b={} \<equiv> op_set_disjoint$a$b" "{x\<in>s. P x} \<equiv> op_set_filter$P$s" "SPEC (\<lambda>x. x\<in>s \<and> P x) \<equiv> op_set_sel$P$s" "SPEC (\<lambda>x. P x \<and> x\<in>s) \<equiv> op_set_sel$P$s" "SPEC (\<lambda>x. x\<in>s) \<equiv> op_set_pick$s" by (auto intro!: eq_reflection simp: card_Suc_eq) lemma [autoref_op_pat]: "a \<times> b \<equiv> op_set_cart a b" by (auto intro!: eq_reflection simp: card_Suc_eq) lemma [autoref_op_pat]: "SPEC (\<lambda>(u,v). (u,v)\<in>s) \<equiv> op_set_pick$s" "SPEC (\<lambda>(u,v). P u v \<and> (u,v)\<in>s) \<equiv> op_set_sel$(case_prod P)$s" "SPEC (\<lambda>(u,v). (u,v)\<in>s \<and> P u v) \<equiv> op_set_sel$(case_prod P)$s" by (auto intro!: eq_reflection) lemma [autoref_op_pat]: "SPEC (\<lambda>l. set l = s \<and> distinct l \<and> sorted_wrt ordR l) \<equiv> OP (op_set_to_sorted_list ordR)$s" "SPEC (\<lambda>l. set l = s \<and> sorted_wrt ordR l \<and> distinct l) \<equiv> OP (op_set_to_sorted_list ordR)$s" "SPEC (\<lambda>l. distinct l \<and> set l = s \<and> sorted_wrt ordR l) \<equiv> OP (op_set_to_sorted_list ordR)$s" "SPEC (\<lambda>l. distinct l \<and> sorted_wrt ordR l \<and> set l = s) \<equiv> OP (op_set_to_sorted_list ordR)$s" "SPEC (\<lambda>l. sorted_wrt ordR l \<and> distinct l \<and> set l = s) \<equiv> OP (op_set_to_sorted_list ordR)$s" "SPEC (\<lambda>l. sorted_wrt ordR l \<and> set l = s \<and> distinct l) \<equiv> OP (op_set_to_sorted_list ordR)$s" "SPEC (\<lambda>l. s = set l \<and> distinct l \<and> sorted_wrt ordR l) \<equiv> OP (op_set_to_sorted_list ordR)$s" "SPEC (\<lambda>l. s = set l \<and> sorted_wrt ordR l \<and> distinct l) \<equiv> OP (op_set_to_sorted_list ordR)$s" "SPEC (\<lambda>l. distinct l \<and> s = set l \<and> sorted_wrt ordR l) \<equiv> OP (op_set_to_sorted_list ordR)$s" "SPEC (\<lambda>l. distinct l \<and> sorted_wrt ordR l \<and> s = set l) \<equiv> OP (op_set_to_sorted_list ordR)$s" "SPEC (\<lambda>l. sorted_wrt ordR l \<and> distinct l \<and> s = set l) \<equiv> OP (op_set_to_sorted_list ordR)$s" "SPEC (\<lambda>l. sorted_wrt ordR l \<and> s = set l \<and> distinct l) \<equiv> OP (op_set_to_sorted_list ordR)$s" "SPEC (\<lambda>l. set l = s \<and> distinct l) \<equiv> op_set_to_list$s" "SPEC (\<lambda>l. distinct l \<and> set l = s) \<equiv> op_set_to_list$s" "SPEC (\<lambda>l. s = set l \<and> distinct l) \<equiv> op_set_to_list$s" "SPEC (\<lambda>l. distinct l \<and> s = set l) \<equiv> op_set_to_list$s" by (auto intro!: eq_reflection) end lemma [autoref_itype]: "{} ::\<^sub>i \<langle>I\<rangle>\<^sub>ii_set" "insert ::\<^sub>i I \<rightarrow>\<^sub>i \<langle>I\<rangle>\<^sub>ii_set \<rightarrow>\<^sub>i \<langle>I\<rangle>\<^sub>ii_set" "op_set_delete ::\<^sub>i I \<rightarrow>\<^sub>i \<langle>I\<rangle>\<^sub>ii_set \<rightarrow>\<^sub>i \<langle>I\<rangle>\<^sub>ii_set" "(\<in>) ::\<^sub>i I \<rightarrow>\<^sub>i \<langle>I\<rangle>\<^sub>ii_set \<rightarrow>\<^sub>i i_bool" "op_set_isEmpty ::\<^sub>i \<langle>I\<rangle>\<^sub>ii_set \<rightarrow>\<^sub>i i_bool" "op_set_isSng ::\<^sub>i \<langle>I\<rangle>\<^sub>ii_set \<rightarrow>\<^sub>i i_bool" "(\<union>) ::\<^sub>i \<langle>I\<rangle>\<^sub>ii_set \<rightarrow>\<^sub>i \<langle>I\<rangle>\<^sub>ii_set \<rightarrow>\<^sub>i \<langle>I\<rangle>\<^sub>ii_set" "(\<inter>) ::\<^sub>i \<langle>I\<rangle>\<^sub>ii_set \<rightarrow>\<^sub>i \<langle>I\<rangle>\<^sub>ii_set \<rightarrow>\<^sub>i \<langle>I\<rangle>\<^sub>ii_set" "((-) :: 'a set \<Rightarrow> 'a set \<Rightarrow> 'a set) ::\<^sub>i \<langle>I\<rangle>\<^sub>ii_set \<rightarrow>\<^sub>i \<langle>I\<rangle>\<^sub>ii_set \<rightarrow>\<^sub>i \<langle>I\<rangle>\<^sub>ii_set" "((=) :: 'a set \<Rightarrow> 'a set \<Rightarrow> bool) ::\<^sub>i \<langle>I\<rangle>\<^sub>ii_set \<rightarrow>\<^sub>i \<langle>I\<rangle>\<^sub>ii_set \<rightarrow>\<^sub>i i_bool" "(\<subseteq>) ::\<^sub>i \<langle>I\<rangle>\<^sub>ii_set \<rightarrow>\<^sub>i \<langle>I\<rangle>\<^sub>ii_set \<rightarrow>\<^sub>i i_bool" "op_set_disjoint ::\<^sub>i \<langle>I\<rangle>\<^sub>ii_set \<rightarrow>\<^sub>i \<langle>I\<rangle>\<^sub>ii_set \<rightarrow>\<^sub>i i_bool" "Ball ::\<^sub>i \<langle>I\<rangle>\<^sub>ii_set \<rightarrow>\<^sub>i (I \<rightarrow>\<^sub>i i_bool) \<rightarrow>\<^sub>i i_bool" "Bex ::\<^sub>i \<langle>I\<rangle>\<^sub>ii_set \<rightarrow>\<^sub>i (I \<rightarrow>\<^sub>i i_bool) \<rightarrow>\<^sub>i i_bool" "op_set_filter ::\<^sub>i (I \<rightarrow>\<^sub>i i_bool) \<rightarrow>\<^sub>i \<langle>I\<rangle>\<^sub>ii_set \<rightarrow>\<^sub>i \<langle>I\<rangle>\<^sub>ii_set" "card ::\<^sub>i \<langle>I\<rangle>\<^sub>ii_set \<rightarrow>\<^sub>i i_nat" "op_set_size_abort ::\<^sub>i i_nat \<rightarrow>\<^sub>i \<langle>I\<rangle>\<^sub>ii_set \<rightarrow>\<^sub>i i_nat" "set ::\<^sub>i \<langle>I\<rangle>\<^sub>ii_list \<rightarrow>\<^sub>i \<langle>I\<rangle>\<^sub>ii_set" "op_set_sel ::\<^sub>i (I \<rightarrow>\<^sub>i i_bool) \<rightarrow>\<^sub>i \<langle>I\<rangle>\<^sub>ii_set \<rightarrow>\<^sub>i \<langle>I\<rangle>\<^sub>ii_nres" "op_set_pick ::\<^sub>i \<langle>I\<rangle>\<^sub>ii_set \<rightarrow>\<^sub>i \<langle>I\<rangle>\<^sub>ii_nres" "Sigma ::\<^sub>i \<langle>Ia\<rangle>\<^sub>ii_set \<rightarrow>\<^sub>i (Ia \<rightarrow>\<^sub>i \<langle>Ib\<rangle>\<^sub>ii_set) \<rightarrow>\<^sub>i \<langle>\<langle>Ia,Ib\<rangle>\<^sub>ii_prod\<rangle>\<^sub>ii_set" "(`) ::\<^sub>i (Ia\<rightarrow>\<^sub>iIb) \<rightarrow>\<^sub>i \<langle>Ia\<rangle>\<^sub>ii_set \<rightarrow>\<^sub>i \<langle>Ib\<rangle>\<^sub>ii_set" "op_set_cart ::\<^sub>i \<langle>Ix\<rangle>\<^sub>iIsx \<rightarrow>\<^sub>i \<langle>Iy\<rangle>\<^sub>iIsy \<rightarrow>\<^sub>i \<langle>\<langle>Ix, Iy\<rangle>\<^sub>ii_prod\<rangle>\<^sub>iIsp" "Union ::\<^sub>i \<langle>\<langle>I\<rangle>\<^sub>ii_set\<rangle>\<^sub>ii_set \<rightarrow>\<^sub>i \<langle>I\<rangle>\<^sub>ii_set" "atLeastLessThan ::\<^sub>i i_nat \<rightarrow>\<^sub>i i_nat \<rightarrow>\<^sub>i \<langle>i_nat\<rangle>\<^sub>ii_set" by simp_all lemma hom_set1[autoref_hom]: "CONSTRAINT {} (\<langle>R\<rangle>Rs)" "CONSTRAINT insert (R\<rightarrow>\<langle>R\<rangle>Rs\<rightarrow>\<langle>R\<rangle>Rs)" "CONSTRAINT (\<in>) (R\<rightarrow>\<langle>R\<rangle>Rs\<rightarrow>Id)" "CONSTRAINT (\<union>) (\<langle>R\<rangle>Rs\<rightarrow>\<langle>R\<rangle>Rs\<rightarrow>\<langle>R\<rangle>Rs)" "CONSTRAINT (\<inter>) (\<langle>R\<rangle>Rs\<rightarrow>\<langle>R\<rangle>Rs\<rightarrow>\<langle>R\<rangle>Rs)" "CONSTRAINT (-) (\<langle>R\<rangle>Rs\<rightarrow>\<langle>R\<rangle>Rs\<rightarrow>\<langle>R\<rangle>Rs)" "CONSTRAINT (=) (\<langle>R\<rangle>Rs\<rightarrow>\<langle>R\<rangle>Rs\<rightarrow>Id)" "CONSTRAINT (\<subseteq>) (\<langle>R\<rangle>Rs\<rightarrow>\<langle>R\<rangle>Rs\<rightarrow>Id)" "CONSTRAINT Ball (\<langle>R\<rangle>Rs\<rightarrow>(R\<rightarrow>Id)\<rightarrow>Id)" "CONSTRAINT Bex (\<langle>R\<rangle>Rs\<rightarrow>(R\<rightarrow>Id)\<rightarrow>Id)" "CONSTRAINT card (\<langle>R\<rangle>Rs\<rightarrow>Id)" "CONSTRAINT set (\<langle>R\<rangle>Rl\<rightarrow>\<langle>R\<rangle>Rs)" "CONSTRAINT (`) ((Ra\<rightarrow>Rb) \<rightarrow> \<langle>Ra\<rangle>Rs\<rightarrow>\<langle>Rb\<rangle>Rs)" "CONSTRAINT Union (\<langle>\<langle>R\<rangle>Ri\<rangle>Ro \<rightarrow> \<langle>R\<rangle>Ri)" by simp_all lemma hom_set2[autoref_hom]: "CONSTRAINT op_set_delete (R\<rightarrow>\<langle>R\<rangle>Rs\<rightarrow>\<langle>R\<rangle>Rs)" "CONSTRAINT op_set_isEmpty (\<langle>R\<rangle>Rs\<rightarrow>Id)" "CONSTRAINT op_set_isSng (\<langle>R\<rangle>Rs\<rightarrow>Id)" "CONSTRAINT op_set_size_abort (Id\<rightarrow>\<langle>R\<rangle>Rs\<rightarrow>Id)" "CONSTRAINT op_set_disjoint (\<langle>R\<rangle>Rs\<rightarrow>\<langle>R\<rangle>Rs\<rightarrow>Id)" "CONSTRAINT op_set_filter ((R\<rightarrow>Id)\<rightarrow>\<langle>R\<rangle>Rs\<rightarrow>\<langle>R\<rangle>Rs)" "CONSTRAINT op_set_sel ((R \<rightarrow> Id)\<rightarrow>\<langle>R\<rangle>Rs\<rightarrow>\<langle>R\<rangle>Rn)" "CONSTRAINT op_set_pick (\<langle>R\<rangle>Rs\<rightarrow>\<langle>R\<rangle>Rn)" by simp_all lemma hom_set_Sigma[autoref_hom]: "CONSTRAINT Sigma (\<langle>Ra\<rangle>Rs \<rightarrow> (Ra \<rightarrow> \<langle>Rb\<rangle>Rs) \<rightarrow> \<langle>\<langle>Ra,Rb\<rangle>prod_rel\<rangle>Rs2)" by simp_all definition "finite_set_rel R \<equiv> Range R \<subseteq> Collect (finite)" lemma finite_set_rel_trigger: "finite_set_rel R \<Longrightarrow> finite_set_rel R" . declaration \<open>Tagged_Solver.add_triggers "Relators.relator_props_solver" @{thms finite_set_rel_trigger}\<close> end
State Before: Γ : Type u_1 R : Type u_2 inst✝¹ : PartialOrder Γ inst✝ : Zero R x : HahnSeries Γ R ⊢ Set.Nonempty (support x) ↔ x ≠ 0 State After: no goals Tactic: rw [support, support_nonempty_iff, Ne.def, coeff_fun_eq_zero_iff]
Formal statement is: lemma bounded_scaleR_comp: fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" assumes "bounded (f ` S)" shows "bounded ((\<lambda>x. r *\<^sub>R f x) ` S)" Informal statement is: If $f$ is a function from $S$ to a real normed vector space, and $f(S)$ is bounded, then $r f(S)$ is bounded for any real number $r$.
[STATEMENT] lemma drop_tl: "drop n (tl xs) = tl(drop n xs)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. drop n (tl xs) = tl (drop n xs) [PROOF STEP] by(induct xs arbitrary: n, simp_all add:drop_Cons drop_Suc split:nat.split)
module Main import System.REPL main : IO () main = repl "> " reverse
/- Copyright (c) 2020 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenny Lau ! This file was ported from Lean 3 source module linear_algebra.smodeq ! leanprover-community/mathlib commit 146d3d1fa59c091fedaad8a4afa09d6802886d24 ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathlib.Data.Polynomial.Eval import Mathlib.RingTheory.Ideal.Quotient /-! # modular equivalence for submodule -/ open Submodule open Polynomial variable {R : Type _} [Ring R] variable {M : Type _} [AddCommGroup M] [Module R M] (U U₁ U₂ : Submodule R M) variable {x x₁ x₂ y y₁ y₂ z z₁ z₂ : M} variable {N : Type _} [AddCommGroup N] [Module R N] (V V₁ V₂ : Submodule R N) /-- A predicate saying two elements of a module are equivalent modulo a submodule. -/ def SModEq (x y : M) : Prop := (Submodule.Quotient.mk x : M ⧸ U) = Submodule.Quotient.mk y #align smodeq SModEq -- mathport name: «expr ≡ [SMOD ]» notation:50 x " ≡ " y " [SMOD " N "]" => SModEq N x y variable {U U₁ U₂} protected theorem SModEq.def : x ≡ y [SMOD U] ↔ (Submodule.Quotient.mk x : M ⧸ U) = Submodule.Quotient.mk y := Iff.rfl #align smodeq.def SModEq.def namespace SModEq theorem sub_mem : x ≡ y [SMOD U] ↔ x - y ∈ U := by rw [SModEq.def, Submodule.Quotient.eq] #align smodeq.sub_mem SModEq.sub_mem @[simp] theorem top : x ≡ y [SMOD (⊤ : Submodule R M)] := (Submodule.Quotient.eq ⊤).2 mem_top #align smodeq.top SModEq.top @[simp] theorem bot : x ≡ y [SMOD (⊥ : Submodule R M)] ↔ x = y := by rw [SModEq.def, Submodule.Quotient.eq, mem_bot, sub_eq_zero] #align smodeq.bot SModEq.bot @[mono] theorem mono (HU : U₁ ≤ U₂) (hxy : x ≡ y [SMOD U₁]) : x ≡ y [SMOD U₂] := (Submodule.Quotient.eq U₂).2 <| HU <| (Submodule.Quotient.eq U₁).1 hxy #align smodeq.mono SModEq.mono @[refl] protected theorem refl (x : M) : x ≡ x [SMOD U] := @rfl _ _ #align smodeq.refl SModEq.refl protected theorem rfl : x ≡ x [SMOD U] := SModEq.refl _ #align smodeq.rfl SModEq.rfl instance : IsRefl _ (SModEq U) := ⟨SModEq.refl⟩ @[symm] nonrec theorem symm (hxy : x ≡ y [SMOD U]) : y ≡ x [SMOD U] := hxy.symm #align smodeq.symm SModEq.symm @[trans] nonrec theorem add (hxy₁ : x₁ ≡ y₁ [SMOD U]) (hxy₂ : x₂ ≡ y₂ [SMOD U]) : x₁ + x₂ ≡ y₁ + y₂ [SMOD U] := by rw [SModEq.def] at hxy₁ hxy₂⊢ simp_rw [Quotient.mk_add, hxy₁, hxy₂] #align smodeq.add SModEq.add theorem smul (hxy : x ≡ y [SMOD U]) (c : R) : c • x ≡ c • y [SMOD U] := by rw [SModEq.def] at hxy⊢ simp_rw [Quotient.mk_smul, hxy] #align smodeq.smul SModEq.smul theorem zero : x ≡ 0 [SMOD U] ↔ x ∈ U := by rw [SModEq.def, Submodule.Quotient.eq, sub_zero] #align smodeq.zero SModEq.zero set_option synthInstance.etaExperiment true in -- porting note: workaround for lean4#2074 theorem map (hxy : x ≡ y [SMOD U]) (f : M →ₗ[R] N) : f x ≡ f y [SMOD U.map f] := (Submodule.Quotient.eq _).2 <| f.map_sub x y ▸ mem_map_of_mem <| (Submodule.Quotient.eq _).1 hxy #align smodeq.map SModEq.map set_option synthInstance.etaExperiment true in theorem comap {f : M →ₗ[R] N} (hxy : f x ≡ f y [SMOD V]) : x ≡ y [SMOD V.comap f] := (Submodule.Quotient.eq _).2 <| show f (x - y) ∈ V from (f.map_sub x y).symm ▸ (Submodule.Quotient.eq _).1 hxy #align smodeq.comap SModEq.comap set_option synthInstance.etaExperiment true in theorem eval {R : Type _} [CommRing R] {I : Ideal R} {x y : R} (h : x ≡ y [SMOD I]) (f : R[X]) : f.eval x ≡ f.eval y [SMOD I] := by rw [SModEq.def] at h⊢ show Ideal.Quotient.mk I (f.eval x) = Ideal.Quotient.mk I (f.eval y) replace h : Ideal.Quotient.mk I x = Ideal.Quotient.mk I y := h rw [← Polynomial.eval₂_at_apply, ← Polynomial.eval₂_at_apply, h] #align smodeq.eval SModEq.eval end SModEq
-- {-# OPTIONS -v tc.cover.splittree:10 -v tc.cc.splittree:10 #-} module Issue106 where data ℕ : Set where zero : ℕ suc : ℕ -> ℕ {-# BUILTIN NATURAL ℕ #-} {-# BUILTIN ZERO zero #-} {-# BUILTIN SUC suc #-} _+_ : ℕ -> ℕ -> ℕ zero + m = m suc n + m = suc (n + m) record ⊤ : Set where data C : ℕ -> Set where c : C 0 data D : Set where d : forall s (x : C s) (xs : D) -> D f : D -> ℕ -> ⊤ f (d zero c x) (suc n) = f (d 0 c x) n f (d .zero c x) n = f x (suc n) g : D -> ℕ -> ⊤ g (d .zero c x) (suc n) = g (d zero c x) n g (d .zero c x) n = g x (suc n) h : D -> ℕ -> ⊤ h (d .zero c x) (suc n) = h (d 0 c x) n h (d .zero c x) n = h x (suc n)
theory Partially_Filled_Array imports "Refine_Imperative_HOL.IICF_Array_List" Array_SBlit begin section "Partially Filled Arrays" text \<open>An array that is only partially filled. The number of actual elements contained is kept in a second element. This represents a weakened version of the array\_list from IICF.\<close> type_synonym 'a pfarray = "'a array_list" subsection "Operations on Partly Filled Arrays" definition is_pfa where "is_pfa c l \<equiv> \<lambda>(a,n). \<exists>\<^sub>A l'. a \<mapsto>\<^sub>a l' * \<up>(c = length l' \<and> n \<le> c \<and> l = (take n l'))" lemma is_pfa_prec[safe_constraint_rules]: "precise (is_pfa c)" unfolding is_pfa_def[abs_def] apply(rule preciseI) apply(simp split: prod.splits) using preciseD snga_prec by fastforce definition pfa_init where "pfa_init cap v n \<equiv> do { a \<leftarrow> Array.new cap v; return (a,n) }" lemma pfa_init_rule[sep_heap_rules]: "n \<le> N \<Longrightarrow> < emp > pfa_init N x n <is_pfa N (replicate n x)>" by (sep_auto simp: pfa_init_def is_pfa_def) definition pfa_empty where "pfa_empty cap \<equiv> pfa_init cap default 0" lemma pfa_empty_rule[sep_heap_rules]: "< emp > pfa_empty N <is_pfa N []>" by (sep_auto simp: pfa_empty_def is_pfa_def) definition "pfa_length \<equiv> arl_length" lemma pfa_length_rule[sep_heap_rules]: " <is_pfa c l a> pfa_length a <\<lambda>r. is_pfa c l a * \<up>(r=length l)>" by (sep_auto simp: pfa_length_def arl_length_def is_pfa_def) definition "pfa_capacity \<equiv> \<lambda>(a,n). Array.len a " lemma pfa_capacity_rule[sep_heap_rules]: " <is_pfa c l a> pfa_capacity a <\<lambda>r. is_pfa c l a * \<up>(c=r)>" by (sep_auto simp: pfa_capacity_def arl_length_def is_pfa_def) definition "pfa_is_empty \<equiv> arl_is_empty" lemma pfa_is_empty_rule[sep_heap_rules]: " <is_pfa c l a> pfa_is_empty a <\<lambda>r. is_pfa c l a * \<up>(r\<longleftrightarrow>(l=[]))>" by (sep_auto simp: pfa_is_empty_def arl_is_empty_def is_pfa_def) definition "pfa_append \<equiv> \<lambda>(a,n) x. do { Array.upd n x a; return (a,n+1) }" lemma pfa_append_rule[sep_heap_rules]: " n < c \<Longrightarrow> < is_pfa c l (a,n) > pfa_append (a,n) x <\<lambda>(a',n'). is_pfa c (l@[x]) (a',n') * \<up>(a' = a \<and> n' = n+1) >" by (sep_auto simp: pfa_append_def arl_append_def is_pfa_def take_update_last neq_Nil_conv split: prod.splits nat.split) definition "pfa_last \<equiv> arl_last" lemma pfa_last_rule[sep_heap_rules]: " l\<noteq>[] \<Longrightarrow> <is_pfa c l a> pfa_last a <\<lambda>r. is_pfa c l a * \<up>(r=last l)>" by (sep_auto simp: pfa_last_def arl_last_def is_pfa_def last_take_nth_conv) definition pfa_butlast :: "'a::heap pfarray \<Rightarrow> 'a pfarray Heap" where "pfa_butlast \<equiv> \<lambda>(a,n). return (a,n-1) " lemma pfa_butlast_rule[sep_heap_rules]: " <is_pfa c l (a,n)> pfa_butlast (a,n) <\<lambda>(a',n'). is_pfa c (butlast l) (a',n') * \<up>(a' = a)>" by (sep_auto split: prod.splits simp: pfa_butlast_def is_pfa_def butlast_take) definition "pfa_get \<equiv> arl_get" lemma pfa_get_rule[sep_heap_rules]: " i < length l \<Longrightarrow> < is_pfa c l a> pfa_get a i <\<lambda>r. is_pfa c l a * \<up>((l!i) = r)>" by (sep_auto simp: is_pfa_def pfa_get_def arl_get_def split: prod.split) definition "pfa_set \<equiv> arl_set" lemma pfa_set_rule[sep_heap_rules]: " i<length l \<Longrightarrow> <is_pfa c l a> pfa_set a i x <\<lambda>a'. is_pfa c (l[i:=x]) a' * \<up>(a' = a)>" by (sep_auto simp: pfa_set_def arl_set_def is_pfa_def split: prod.split) definition pfa_shrink :: "nat \<Rightarrow> 'a::heap pfarray \<Rightarrow> 'a pfarray Heap" where "pfa_shrink k \<equiv> \<lambda>(a,n). return (a,k) " lemma pfa_shrink_rule[sep_heap_rules]: " k \<le> length xs \<Longrightarrow> < is_pfa c xs (a,n) > pfa_shrink k (a,n) <\<lambda>(a',n'). is_pfa c (take k xs) (a',n') * \<up>(n' = k \<and> a'=a) >" by (sep_auto simp: pfa_shrink_def is_pfa_def min.absorb1 split: prod.splits nat.split) definition pfa_shrink_cap :: "nat \<Rightarrow> 'a::heap pfarray \<Rightarrow> 'a pfarray Heap" where "pfa_shrink_cap k \<equiv> \<lambda>(a,n). do { a' \<leftarrow> array_shrink a k; return (a',min k n) } " lemma pfa_shrink_cap_rule_preserve[sep_heap_rules]: " \<lbrakk>n \<le> k; k \<le> c\<rbrakk> \<Longrightarrow> < is_pfa c l (a,n) > pfa_shrink_cap k (a,n) <\<lambda>a'. is_pfa k l a' >\<^sub>t" by (sep_auto simp: pfa_shrink_cap_def is_pfa_def min.absorb1 min.absorb2 split: prod.splits nat.split) lemma pfa_shrink_cap_rule: " \<lbrakk>k \<le> c\<rbrakk> \<Longrightarrow> < is_pfa c l a > pfa_shrink_cap k a <\<lambda>a'. is_pfa k (take k l) a' >\<^sub>t" by (sep_auto simp: pfa_shrink_cap_def is_pfa_def min.absorb1 min.absorb2 split: prod.splits nat.split dest: mod_starD) definition "array_ensure a s x \<equiv> do { l\<leftarrow>Array.len a; if l\<ge>s then return a else do { a'\<leftarrow>Array.new s x; blit a 0 a' 0 l; return a' } }" lemma array_ensure_rule[sep_heap_rules]: shows " < a\<mapsto>\<^sub>ala > array_ensure a s x <\<lambda>a'. a'\<mapsto>\<^sub>a (la @ replicate (s-length la) x)>\<^sub>t" unfolding array_ensure_def by sep_auto (* Ensure a certain capacity *) definition pfa_ensure :: "'a::{heap,default} pfarray \<Rightarrow> nat \<Rightarrow> 'a pfarray Heap" where "pfa_ensure \<equiv> \<lambda>(a,n) k. do { a' \<leftarrow> array_ensure a k default; return (a',n) } " lemma pfa_ensure_rule[sep_heap_rules]: " < is_pfa c l (a,n) > pfa_ensure (a,n) k <\<lambda>(a',n'). is_pfa (max c k) l (a',n') * \<up>(n' = n \<and> c \<ge> n)>\<^sub>t" by (sep_auto simp: pfa_ensure_def is_pfa_def) definition "pfa_copy \<equiv> arl_copy" lemma pfa_copy_rule[sep_heap_rules]: "< is_pfa c l a > pfa_copy a <\<lambda>r. is_pfa c l a * is_pfa c l r>\<^sub>t" by (sep_auto simp: pfa_copy_def arl_copy_def is_pfa_def) definition pfa_blit :: "'a::heap pfarray \<Rightarrow> nat \<Rightarrow> 'a::heap pfarray \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> unit Heap" where "pfa_blit \<equiv> \<lambda>(src,sn) si (dst,dn) di l. blit src si dst di l" lemma min_nat: "min a (a+b) = (a::nat)" by auto lemma pfa_blit_rule[sep_heap_rules]: assumes LEN: "si+len \<le> sn" "di \<le> dn" "di+len \<le> dc" shows "< is_pfa sc src (srci,sn) * is_pfa dc dst (dsti,dn) > pfa_blit (srci,sn) si (dsti,dn) di len <\<lambda>_. is_pfa sc src (srci,sn) * is_pfa dc (take di dst @ take len (drop si src) @ drop (di+len) dst) (dsti,max (di+len) dn) >" using LEN apply(sep_auto simp add: min_nat is_pfa_def pfa_blit_def min.commute min.absorb1 heap: blit_rule) apply (simp add: min.absorb1 take_drop) apply (simp add: drop_take max_def) done definition pfa_drop :: "('a::heap) pfarray \<Rightarrow> nat \<Rightarrow> 'a pfarray \<Rightarrow> 'a pfarray Heap" where "pfa_drop \<equiv> \<lambda>(src,sn) si (dst,dn). do { blit src si dst 0 (sn-si); return (dst,(sn-si)) } " lemma pfa_drop_rule[sep_heap_rules]: assumes LEN: "k \<le> sn" "(sn-k) \<le> dc" shows "< is_pfa sc src (srci,sn) * is_pfa dc dst (dsti,dn) > pfa_drop (srci,sn) k (dsti,dn) <\<lambda>(dsti',dn'). is_pfa sc src (srci,sn) * is_pfa dc (drop k src) (dsti',dn') * \<up>(dsti' = dsti) >" using LEN apply (sep_auto simp add: drop_take is_pfa_def pfa_drop_def dest!: mod_starD heap: pfa_blit_rule) done definition "pfa_append_grow \<equiv> \<lambda>(a,n) x. do { l \<leftarrow> pfa_capacity (a,n); a' \<leftarrow> if l = n then array_grow a (l+1) x else Array.upd n x a; return (a',n+1) }" lemma pfa_append_grow_full_rule[sep_heap_rules]: "n = c \<Longrightarrow> <is_pfa c l (a,n)> array_grow a (c+1) x <\<lambda>a'. is_pfa (c+1) (l@[x]) (a',n+1)>\<^sub>t" apply(sep_auto simp add: is_pfa_def heap del: array_grow_rule) apply(vcg heap del: array_grow_rule heap add: array_grow_rule[of l "(Suc (length l))" a x]) apply simp apply(rule ent_ex_postI[where ?x="l@[x]"]) apply sep_auto done lemma pfa_append_grow_less_rule: "n < c \<Longrightarrow> <is_pfa c l (a,n)> Array.upd n x a <\<lambda>a'. is_pfa c (l@[x]) (a',n+1)>\<^sub>t" apply(sep_auto simp add: is_pfa_def take_update_last) done lemma pfa_append_grow_rule[sep_heap_rules]: " <is_pfa c l (a,n)> pfa_append_grow (a,n) x <\<lambda>(a',n'). is_pfa (if c = n then c+1 else c) (l@[x]) (a',n') * \<up>(n'=n+1 \<and> c \<ge> n)>\<^sub>t" apply(subst pfa_append_grow_def) apply(rule hoare_triple_preI) apply (sep_auto heap add: pfa_append_grow_full_rule pfa_append_grow_less_rule) apply(sep_auto simp add: is_pfa_def) apply(sep_auto simp add: is_pfa_def) done (* This definition has only one access to the array length *) definition "pfa_append_grow' \<equiv> \<lambda>(a,n) x. do { a' \<leftarrow> pfa_ensure (a,n) (n+1); a'' \<leftarrow> pfa_append a' x; return a'' }" lemma pfa_append_grow'_rule[sep_heap_rules]: " <is_pfa c l (a,n)> pfa_append_grow' (a,n) x <\<lambda>(a',n'). is_pfa (max (n+1) c) (l@[x]) (a',n') * \<up>(n'=n+1 \<and> c \<ge> n)>\<^sub>t" unfolding pfa_append_grow'_def by (sep_auto simp add: max_def) definition "pfa_insert \<equiv> \<lambda>(a,n) i x. do { a' \<leftarrow> array_shr a i 1; a'' \<leftarrow> Array.upd i x a; return (a'',n+1) }" lemma list_update_last: "length ls = Suc i \<Longrightarrow> ls[i:=x] = (take i ls)@[x]" by (metis append_eq_conv_conj length_Suc_rev_conv list_update_length) lemma pfa_insert_rule[sep_heap_rules]: "\<lbrakk>i \<le> n; n < c\<rbrakk> \<Longrightarrow> <is_pfa c l (a,n)> pfa_insert (a,n) i x <\<lambda>(a',n'). is_pfa c (take i l@x#drop i l) (a',n') * \<up>(n' = n+1 \<and> a=a')>" unfolding pfa_insert_def is_pfa_def by (sep_auto simp add: list_update_append1 list_update_last Suc_diff_le drop_take min_def) definition pfa_insert_grow :: "'a::{heap,default} pfarray \<Rightarrow> nat \<Rightarrow> 'a \<Rightarrow> 'a pfarray Heap" where "pfa_insert_grow \<equiv> \<lambda>(a,n) i x. do { a' \<leftarrow> pfa_ensure (a,n) (n+1); a'' \<leftarrow> pfa_insert a' i x; return a'' }" lemma pfa_insert_grow_rule[sep_heap_rules]: "i \<le> n \<Longrightarrow> <is_pfa c l (a,n)> pfa_insert_grow (a,n) i x <\<lambda>(a',n'). is_pfa (max c (n+1)) (take i l@x#drop i l) (a',n') * \<up>(n'=n+1 \<and> c \<ge> n)>\<^sub>t" unfolding pfa_insert_grow_def by (sep_auto heap add: pfa_insert_rule[of i n "max c (Suc n)"]) definition pfa_extend where "pfa_extend \<equiv> \<lambda> (a,n) (b,m). do{ blit b 0 a n m; return (a,n+m) }" lemma pfa_extend_rule[sep_heap_rules]: "n+m \<le> c \<Longrightarrow> <is_pfa c l1 (a,n) * is_pfa d l2 (b,m)> pfa_extend (a,n) (b,m) <\<lambda>(a',n'). is_pfa c (l1@l2) (a',n') * \<up>(a' = a \<and> n'=n+m) * is_pfa d l2 (b,m)>\<^sub>t" unfolding pfa_extend_def by (sep_auto simp add: is_pfa_def min.absorb1 min.absorb2 heap add: blit_rule) definition pfa_extend_grow where "pfa_extend_grow \<equiv> \<lambda> (a,n) (b,m). do{ a' \<leftarrow> array_ensure a (n+m) default; blit b 0 a' n m; return (a',n+m) }" lemma pfa_extend_grow_rule[sep_heap_rules]: "<is_pfa c l1 (a,n) * is_pfa d l2 (b,m)> pfa_extend_grow (a,n) (b,m) <\<lambda>(a',n'). is_pfa (max c (n+m)) (l1@l2) (a',n') * \<up>(n'=n+m \<and> c \<ge> n) * is_pfa d l2 (b,m)>\<^sub>t" unfolding pfa_extend_grow_def by (sep_auto simp add: is_pfa_def min.absorb1 min.absorb2 heap add: blit_rule) definition pfa_append_extend_grow where "pfa_append_extend_grow \<equiv> \<lambda> (a,n) x (b,m). do{ a' \<leftarrow> array_ensure a (n+m+1) default; a'' \<leftarrow> Array.upd n x a'; blit b 0 a'' (n+1) m; return (a'',n+m+1) }" lemma pfa_append_extend_grow_rule[sep_heap_rules]: "<is_pfa c l1 (a,n) * is_pfa d l2 (b,m)> pfa_append_extend_grow (a,n) x (b,m) <\<lambda>(a',n'). is_pfa (max c (n+m+1)) (l1@x#l2) (a',n') * \<up>(n'=n+m+1 \<and> c \<ge> n) * is_pfa d l2 (b,m)>\<^sub>t" unfolding pfa_append_extend_grow_def by (sep_auto simp add: list_update_last is_pfa_def min.absorb1 min.absorb2 heap add: blit_rule) definition "pfa_delete \<equiv> \<lambda>(a,n) i. do { array_shl a (i+1) 1; return (a,n-1) }" lemma pfa_delete_rule[sep_heap_rules]: "i < n \<Longrightarrow> <is_pfa c l (a,n)> pfa_delete (a,n) i <\<lambda>(a',n'). is_pfa c (take i l@drop (i+1) l) (a',n') * \<up>(n' = n-1 \<and> a=a')>" unfolding pfa_delete_def is_pfa_def apply (sep_auto simp add: drop_take min_def) by (metis Suc_diff_Suc diff_zero dual_order.strict_trans2 le_less_Suc_eq zero_le) end
{-# LANGUAGE FlexibleContexts #-} module Taylor where import Data.Complex -- also this is a vector space data Taylor a = Integ a (Taylor a) instance Show a => Show (Taylor a) where show = show . take 10 . toList toList (Integ x xs) = x:toList xs zero = Integ 0 zero instance Num a => Num (Taylor a) where (a `Integ` as) + (b `Integ` bs) = (a + b) `Integ` (as + bs) (a `Integ` as) * (b `Integ` bs) = (a*b) `Integ` (as * (b `Integ` bs) + (a `Integ` as) * bs) fromInteger x = integ (fromInteger x) 0 negate (a `Integ` as) = negate a `Integ` negate as constant :: Num a => a -> Taylor a constant x = integ x 0 integ :: a -> Taylor a -> Taylor a integ = Integ sinx :: Taylor Integer sinx = integ 0 cosx cosx :: Taylor Integer cosx = integ 1 (-sinx) expx :: Taylor (Complex Double) expx = integ 1 expx -- expkx :: Taylor Double -> Taylor Double -- expkx k = integ 1 (k*expx) varx :: Taylor (Complex Double) varx = integ 0 1 (*^) :: Num t => t -> Taylor t -> Taylor t a *^ (Integ k ks) = Integ (a * k) (a *^ ks) evalPart :: Fractional p => [p] -> p -> p -> p evalPart [] _ _ = 0 evalPart (k:ks) n y = k + evalPart (((y/n) *) <$> ks) (n+1) y eval :: Fractional p => Taylor p -> Int -> p -> p eval t n x = evalPart (take n $ toList t) 1 x -- f . g -- integ ((f . g) 0) (D (f . g)) -- integ (f (g 0)) (D f . g * g') compose :: (Eq a, Num a) => Taylor a -> Taylor a -> Taylor a compose (Integ f0 f') g@(Integ g0 g') = Integ fg0 ((f' `compose` g) * g') where -- fg0 is the evaluation of f at point g0. (An infinite sum in the general case, but...) fg0 = if g0 == 0 then f0 else error "fg0: computation diverges" -- >>> varx -- [0,1,0,0,0,0,0,0,0,0] -- >>> 3 * varx -- [0.0,3.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0] -- >>> expx `compose` ((constant (0 :+ 1) * varx)) -- [1.0 :+ 0.0, -- 0.0 :+ 1.0, -- (-1.0) :+ 0.0, -- 0.0 :+ (-1.0), -- 1.0 :+ 0.0, -- 0.0 :+ 1.0, -- (-1.0) :+ 0.0, -- 0.0 :+ (-1.0), -- 1.0 :+ 0.0, -- 0.0 :+ 1.0]
# Upper envelope This notebook shows how to use the **upperenvelope** module from the **consav** package. # Model Consider a **standard consumption-saving** model \begin{align} v_{t}(m_{t})&=\max_{c_{t}}\frac{c_{t}^{1-\rho}}{1-\rho}+\beta v_{t+1}(m_{t+1}) \end{align} where \begin{align} a_{t} &=m_{t}-c_{t} \\ m_{t+1} &=Ra_{t}+y \\ \end{align} The **Euler equation** is \begin{align} c_{t}^{-\rho} &=\beta Rc_{t+1}^{-\rho} \end{align} Assume that the **t+1 consumption and value functions** are given by \begin{align} c_{t+1}(m_{t}) &= \sqrt{m_{t}}-\eta_{c} \cdot 1\{m_{t}\geq\underline{m}\} \\ v_{t+1}(m_{t}) &= \sqrt{m_{t}}+\eta_{v}\sqrt{m_{t}-\underline{m}} \cdot 1\{m_{t}\geq\underline{m}\} \end{align} This **notebook** shows how to find the **t consumption and value function** using an **upper envelope** code despite the **kink** in the next-period value function. # Algorithm 1. Specify an increasing grid of $m_t$ indexed by $j$, such as {${m_1,m_2,...,m_{\#_m}}$} <br> 2. Specify an increasing grid of $a_t $ indexed by $i$, such as {${a^1,a^2,...,a^{\#_a}}$} <br> 3. For each $i$ compute (using linear interpolation):<br> a. Post-decision value function: $w^i = \beta \breve{v}_{t+1}(Ra^i+y)$ <br> b. Post-decision marginal value of cash: $q^i = \beta R\breve{c}_{t+1}(Ra^i+y)^{-\rho}$ <br> c. Consumption: $c_i = (q^i)^{-1/\rho}$ <br> d. Cash-on-hand: $m^i = a^i + c^i$ <br> 4. For each $j$: <br> a. Constraint: If $m_j < m^1$ then set $c_j = m_j$ <br> b. Find best segment: If $m_j \geq m^1$ then set $c_j =c_j^{i^{\star}(j)} $ where <br> $$ \begin{align} c_j^i=c_j^i+\frac{c^{i+1}-c^i}{m^{i+1}-m^i}(m_j-m^i) \end{align} $$ and $$ \begin{align} i^{\star}(j)=\arg\max_{i\in\{1,\dots\#_{A}-1\}}\frac{(c_{j}^{i})^{1-\rho}}{1-\rho}+\beta w_{j}^{i} \\ \end{align} $$ subject to $$ \begin{align} m_{j} &\in [m^{i},m^{i+1}] \\ a_{j}^{i} &= m_{j}-c_{j}^{i} \\ w_{j}^{i} &= w^{i}+\frac{w^{i+1}-w^{i}}{a^{i+1}-a^{i}}(a_{j}^{i}-a^{i}) \end{align} $$ # Setup ```python import numpy as np from numba import njit import matplotlib.pyplot as plt plt.style.use('seaborn-whitegrid') prop_cycle = plt.rcParams["axes.prop_cycle"] colors = prop_cycle.by_key()["color"] import ipywidgets as widgets ``` Choose parameters and create grids: ```python def setup(): par = dict() # a. model parameters par['beta'] = 0.96 par['rho'] = 2 par['R'] = 1.02 par['y'] = 1 # b. cash-on-hand (exogenous grid) par['Nm'] = 10000 par['m_max'] = 10 # c. end-of-period assets (exogenous grid) par['Na'] = 1000 par['a_max'] = 10 # d. next-period consumption and value function par['eta_v'] = 0.5 par['eta_c'] = 0.5 par['x_ubar'] = 5 return par def create_grids(par): par['grid_a'] = np.linspace(0,par['a_max'],par['Na']) par['grid_m'] = np.linspace(1e-8,par['m_max'],par['Nm']) return par par = setup() par = create_grids(par) ``` # Next-period functions Calculate the next-period consumption and value functions: ```python sol = dict() # a. consumption function sol['c_next'] = np.sqrt(par['grid_m']) - par['eta_c']*(par['grid_m'] >= par['x_ubar']); # b. value function sol['v_next'] = np.sqrt(par['grid_m']) + par['eta_v']*np.sqrt(np.fmax(par['grid_m']-par['x_ubar'],0))*(par['grid_m'] >= par['x_ubar']) ``` ## Figures Plot them to see the jump in consumption and the kink in the value function. ```python # a. next-period consumption function fig = plt.figure() ax = fig.add_subplot(1,1,1) ax.plot(par['grid_m'],sol['c_next'],'o',ms=0.5) ax.set_title('next-period consumption function') ax.set_xlabel('$m_t$') ax.set_ylabel('$c_t$') # b. next-period value function fig = plt.figure() ax = fig.add_subplot(1,1,1) ax.plot(par['grid_m'],sol['v_next'],'o',ms=0.5) ax.set_title('next-period value function') ax.set_xlabel('$m_t$') ax.set_ylabel('$v_t$'); ``` # EGM ```python from consav import linear_interp # linear interpolation ``` Apply the EGM algorithm. ```python @njit def u(c,rho): return c**(1-2)/(1-2) def marg_u(c,par): return c**(-par['rho']) def inv_marg_u(u,par): return u**(-1.0/par['rho']) def EGM(par,sol): # a. next-period cash-on-hand m_plus = par['R']*par['grid_a'] + par['y'] # b. post-decision value function sol['w_vec'] = np.empty(m_plus.size) linear_interp.interp_1d_vec(par['grid_m'],sol['v_next'],m_plus,sol['w_vec']) # c. post-decision marginal value of cash c_next_interp = np.empty(m_plus.size) linear_interp.interp_1d_vec(par['grid_m'],sol['c_next'],m_plus,c_next_interp) q = par['beta']*par['R']*marg_u(c_next_interp,par) # d. EGM sol['c_vec'] = inv_marg_u(q,par) sol['m_vec'] = par['grid_a'] + sol['c_vec'] return sol sol = EGM(par,sol) ``` ## Figures Plot the result of the EGM algorithm to see that the its does not define a consumption function. ```python # a. raw consumption function fig = plt.figure() ax = fig.add_subplot(1,1,1) ax.plot(sol['m_vec'],sol['c_vec'],'o',ms=0.5) ax.set_title('raw consumption points') ax.set_xlabel('$m_t$') ax.set_ylabel('$c_t$') # b. raw value function fig = plt.figure() ax = fig.add_subplot(1,1,1) ax.plot(sol['m_vec'],sol['w_vec'],'o',ms=0.5) ax.set_title('raw value function points') ax.set_xlabel('$m_t$') ax.set_ylabel('$w_t$'); ``` # Upper envelope ```python from consav import upperenvelope # a. create myupperenvelope = upperenvelope.create(u) # where is the utility function # b. apply c_ast_vec = np.empty(par['grid_m'].size) # output v_ast_vec = np.empty(par['grid_m'].size) # output myupperenvelope(par['grid_a'],sol['m_vec'],sol['c_vec'],sol['w_vec'],par['grid_m'],c_ast_vec,v_ast_vec,par['rho']) ``` ## Figures ```python # a. consumption function fig = plt.figure() ax = fig.add_subplot(1,1,1) ax.plot(par['grid_m'],c_ast_vec,'o',ms=0.5) ax.set_title('consumption function') ax.set_xlabel('$m_t$') ax.set_ylabel('$c_t$') # b. value function fig = plt.figure() ax = fig.add_subplot(1,1,1) ax.plot(par['grid_m'],v_ast_vec,'o',ms=0.5) ax.set_title('value function') ax.set_xlabel('$m_t$') ax.set_ylabel('$v_t$') ax.set_ylim((-5,5)); ```
```python import numpy as np import sympy as sy from sympy import init_printing init_printing() import control.matlab as cm ``` # The Fibonacci sequence \begin{equation} y(k+2) - y(k+1) - y(k) = 0 \end{equation} ```python z = sy.symbols('z') y0, y1 = sy.symbols('y0, y1', real=True) ``` ```python den = z*z - z -1 num = z*z Y = num/sy.factor(den) sy.factor(den) ``` ```python sy.factor(Y) ``` ```python sy.apart(Y) ``` ```python sy.apart( z/den) ``` ```python p1 = (1 + sy.sqrt(5))/2 p2 = (1 - sy.sqrt(5))/2 sy.expand((z-p1)*(z-p2)) ``` ```python Y = z/( (z-p1)*(z-p2)) Y ``` ```python sy.apart(Y) ``` ```python ```
module Koans.HigherOrderFunctions -- Complete these functions -- Maps are used to map a function to elements in a list. myFirstMap : Bool myFirstMap = ?fillme1 == map (2*) [1..4] mySecondMap : Bool mySecondMap = [1, 4, 9, 16, 25] == map ?fillme2 [1..5] myThirdMap : Bool myThirdMap = [25, 16, 9, 4, 1] == map ?fillme3 [1..5] -- Folds are used to combine elements in a list from start to finish using a function. myFirstFold : Bool myFirstFold = foldl (+) 0 [1..4] == ?fillme4 mySecondFold : Bool mySecondFold = 5 == foldl ?fillme5 5 [1..4] -- Scans are like fold but you see the intermediate results, and then the result. myFirstScan : Bool myFirstScan = scanl (max) 5 [1,2,3,4] == ?fillme6 mySecondScan : Bool mySecondScan = scanl ?fillme7 5 [1,2,10,1] == [5,5,5,10,10] myThirdScan : Bool myThirdScan = scanl (/) 64 [4,2,4] == ?fillme8 -- TODO Add examples for scanr and foldr -- You can filter things as well. xs : List Int xs = [1,2,3,4,5,6,7,8,9,10] myFirstFilter : Bool myFirstFilter = filter (>5) xs == ?fillme15 mySecondFilter : Bool mySecondFilter = filter ?fillme16 [10,20,30,40,50,60,70,80,90,100] == xs -- You can combine functions as well myFirstCombi : Bool myFirstCombi = ["bang", "boom", "bang", "boom", "bang"] == map ?fillme17 (filter ?fillme18 xs)
-- ------------------------------------------------------------------------ [ ] -- Client Process -- --------------------------------------------------------------------- [ EOH ] module Greeter.Frontend import Effects import Effect.StdIO import Effect.Default import Effect.State import Effect.Msg import System.Protocol import RFC.Greeter import Greeter.Common %access public -- ---------------------------------------------------------- [ Greeter Client ] ||| Get commands from the user. private readCmd : { [STDIO] } Eff Command readCmd = case (process !getStr) of Just cmd => return cmd Nothing => do putStrLn "Bad command" putStr "Try again: " readCmd where process : String -> Maybe Command process str = case words (trim str) of [":greet", str] => Just (GreetMe str) [":?"] => Just Help [":help"] => Just Help [":q"] => Just Quit _ => Nothing ||| Process commands and interact with the backend. private covering clientBody : (proc : PID) -> GreeterFrontend (gBody) () clientBody proc = do setChan 'Bob proc putStrLn !(recvFrom 'Bob) cmd <- readCmd sendTo 'Bob cmd case cmd of GreetMe str => do putStrLn !(recvFrom 'Bob) dropChan 'Bob rec (clientBody proc) Help => do putStrLn !(recvFrom 'Bob) dropChan 'Bob rec (clientBody proc) Quit => do dropChan 'Bob return () ||| A Client process to perform the client greeter interactions. covering greeterClient : (proc : PID) -> GreeterFrontend (greeter gBody) () greeterClient proc = do setChan 'Bob proc sendTo 'Bob "I am a nasty hack" dropChan 'Bob (clientBody proc) return () -- --------------------------------------------------------------------- [ EOF ]
Formal statement is: lemma decseq_SucD: "decseq A \<Longrightarrow> A (Suc i) \<le> A i" Informal statement is: If $A$ is a decreasing sequence, then $A_{i+1} \leq A_i$.
State Before: 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 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 uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hf : HasCompactSupport f n : ℕ ⊢ HasCompactSupport (_root_.iteratedFDeriv 𝕜 n f) State After: case zero 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 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 uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hf : HasCompactSupport f ⊢ HasCompactSupport (_root_.iteratedFDeriv 𝕜 Nat.zero f) case succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 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 uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hf : HasCompactSupport f n : ℕ IH : HasCompactSupport (_root_.iteratedFDeriv 𝕜 n f) ⊢ HasCompactSupport (_root_.iteratedFDeriv 𝕜 (Nat.succ n) f) Tactic: induction' n with n IH State Before: case zero 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 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 uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hf : HasCompactSupport f ⊢ HasCompactSupport (_root_.iteratedFDeriv 𝕜 Nat.zero f) State After: case zero 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 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 uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hf : HasCompactSupport f ⊢ HasCompactSupport (↑(LinearIsometryEquiv.symm (continuousMultilinearCurryFin0 𝕜 E F)) ∘ f) Tactic: rw [iteratedFDeriv_zero_eq_comp] State Before: case zero 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 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 uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hf : HasCompactSupport f ⊢ HasCompactSupport (↑(LinearIsometryEquiv.symm (continuousMultilinearCurryFin0 𝕜 E F)) ∘ f) State After: case zero 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 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 uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hf : HasCompactSupport f ⊢ ↑(LinearIsometryEquiv.symm (continuousMultilinearCurryFin0 𝕜 E F)) 0 = 0 Tactic: apply hf.comp_left State Before: case zero 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 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 uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hf : HasCompactSupport f ⊢ ↑(LinearIsometryEquiv.symm (continuousMultilinearCurryFin0 𝕜 E F)) 0 = 0 State After: no goals Tactic: exact LinearIsometryEquiv.map_zero _ State Before: case succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 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 uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hf : HasCompactSupport f n : ℕ IH : HasCompactSupport (_root_.iteratedFDeriv 𝕜 n f) ⊢ HasCompactSupport (_root_.iteratedFDeriv 𝕜 (Nat.succ n) f) State After: case succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 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 uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hf : HasCompactSupport f n : ℕ IH : HasCompactSupport (_root_.iteratedFDeriv 𝕜 n f) ⊢ HasCompactSupport (↑(continuousMultilinearCurryLeftEquiv 𝕜 (fun x => E) F) ∘ fderiv 𝕜 (_root_.iteratedFDeriv 𝕜 n f)) Tactic: rw [iteratedFDeriv_succ_eq_comp_left] State Before: case succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 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 uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hf : HasCompactSupport f n : ℕ IH : HasCompactSupport (_root_.iteratedFDeriv 𝕜 n f) ⊢ HasCompactSupport (↑(continuousMultilinearCurryLeftEquiv 𝕜 (fun x => E) F) ∘ fderiv 𝕜 (_root_.iteratedFDeriv 𝕜 n f)) State After: case succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 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 uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hf : HasCompactSupport f n : ℕ IH : HasCompactSupport (_root_.iteratedFDeriv 𝕜 n f) ⊢ ↑(continuousMultilinearCurryLeftEquiv 𝕜 (fun x => E) F) 0 = 0 Tactic: apply (IH.fderiv 𝕜).comp_left State Before: case succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 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 uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hf : HasCompactSupport f n : ℕ IH : HasCompactSupport (_root_.iteratedFDeriv 𝕜 n f) ⊢ ↑(continuousMultilinearCurryLeftEquiv 𝕜 (fun x => E) F) 0 = 0 State After: no goals Tactic: exact LinearIsometryEquiv.map_zero _