Datasets:
AI4M
/

text
stringlengths
0
3.34M
__precompile__() module LightGBM using Libdl using Dates import StatsBase # if LIGHTGBM_PATH is difined, automatical define LIGHTGBM_PATH function lgbm_librarysetup() try println("ENV[\"LIGHTGBM_PATH\"] is ",ENV["LIGHTGBM_PATH"]) return ENV["LIGHTGBM_PATH"] catch println("Don't find ENV[\"LIGHTGBM_PATH\"].LightGBM library setup start...") global ligthgbmpath=joinpath(abspath(joinpath(dirname(Base.find_package("LightGBM")), "..")),"deps/usr/lib") if Sys.islinux() global prefix=joinpath(ligthgbmpath,"lib_lightgbm.so") elseif Sys.iswindows() global prefix=joinpath(ligthgbmpath,"lib_lightgbm.dll") elseif Sys.isapple() global prefix=joinpath(ligthgbmpath,"lib_lightgbm.dylib") else global prefix="" end if !isfile(prefix) println("Instaling library") include(joinpath(abspath(joinpath(dirname(Base.find_package("LightGBM")), "..")),"deps/build.jl")) end if isfile(prefix) println("Set library path:",ligthgbmpath) return ligthgbmpath else println("Not find LightGBM library") end end end # pre initialization ENV["LIGHTGBM_PATH"] = lgbm_librarysetup(); function __init__() println("Start __init__") try println("LIGHTGBM_PATH:",ENV["LIGHTGBM_PATH"]); catch println("LIGHTGBM_PATH setup1...") ENV["LIGHTGBM_PATH"] = lgbm_librarysetup() global LGBM_library = Libdl.find_library(["lib_lightgbm.so", "lib_lightgbm.dll", "lib_lightgbm.dylib"], [ENV["LIGHTGBM_PATH"]]) end if !haskey(ENV, "LIGHTGBM_PATH") error("Environment variable LIGHTGBM_PATH not found. ", "Set this variable to point to the LightGBM directory prior to loading LightGBM.jl ", "(e.g. `ENV[\"LIGHTGBM_PATH\"] = \"../LightGBM\"`).") end println("Finished __init__()") end const LGBM_library = find_library(["lib_lightgbm.so", "lib_lightgbm.dll", "lib_lightgbm.dylib"], [ENV["LIGHTGBM_PATH"]]) include("wrapper.jl") include("estimators.jl") include("utils.jl") include("fit.jl") include("predict.jl") include("cv.jl") include("search_cv.jl") include("LightGBM-util2.jl") export fit, predict, cv, search_cv, savemodel, loadmodel export LGBMEstimator, LGBMRegression, LGBMBinary, LGBMMulticlass export metaformattedclassresult, metaformattedclassresult, formattedclassfit, predict2 end # module LightGBM
# Decision Lens API # # No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # # OpenAPI spec version: 1.0 # # Generated by: https://github.com/swagger-api/swagger-codegen.git #' Attributes Class #' #' @field timeInterval #' #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export Attributes <- R6::R6Class( 'Attributes', public = list( `timeInterval` = NULL, initialize = function(`timeInterval`){ if (!missing(`timeInterval`)) { stopifnot(R6::is.R6(`timeInterval`)) self$`timeInterval` <- `timeInterval` } }, toJSON = function() { AttributesObject <- list() if (!is.null(self$`timeInterval`)) { AttributesObject[['timeInterval']] <- self$`timeInterval`$toJSON() } AttributesObject }, fromJSON = function(AttributesJson) { AttributesObject <- dlensFromJSON(AttributesJson) if (!is.null(AttributesObject$`timeInterval`)) { timeIntervalObject <- TimeInterval$new() timeIntervalObject$fromJSON(jsonlite::toJSON(AttributesObject$timeInterval, auto_unbox = TRUE)) self$`timeInterval` <- timeIntervalObject } }, toJSONString = function() { sprintf( '{ "timeInterval": %s }', self$`timeInterval`$toJSON() ) }, fromJSONString = function(AttributesJson) { AttributesObject <- dlensFromJSON(AttributesJson) TimeIntervalObject <- TimeInterval$new() self$`timeInterval` <- TimeIntervalObject$fromJSON(jsonlite::toJSON(AttributesObject$timeInterval, auto_unbox = TRUE)) } ) )
{-# OPTIONS --without-K --rewriting #-} open import Base using (Type; Typeβ‚€; _==_; idp) module PathInductionSimplified where {-<pathinduction>-} record Coh {i} (A : Type i) : Type i where field & : A open Coh public instance J : βˆ€ {i j} {A : Type i} {a : A} {B : (a' : A) β†’ a == a' β†’ Type j} β†’ Coh (B a idp) β†’ Coh ({a' : A} (p : a == a') β†’ B a' p) & (J d) idp = & d idp-Coh : βˆ€ {i} {A : Type i} {a : A} β†’ Coh (a == a) & idp-Coh = idp path-induction : βˆ€ {i} {A : Type i} {{a : A}} β†’ A path-induction {{a}} = a composition : βˆ€ {i} {A : Type i} {a : A} β†’ Coh ({b : A} (p : a == b) {c : A} (q : b == c) β†’ a == c) composition = path-induction postulate A : Typeβ‚€ a b c : A p : a == b q : b == c pq : a == c pq = & composition p q {-</>-}
[STATEMENT] lemma minGraphProps12: "minGraphProps g \<Longrightarrow> f \<in> \<F> g \<Longrightarrow> (a,b) \<in> \<E> f \<Longrightarrow> (b,a) \<notin> \<E> f" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> (b, a) \<notin> \<E> f [PROOF STEP] apply (subgoal_tac "distinct (vertices f)") [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f; distinct (vertices f)\<rbrakk> \<Longrightarrow> (b, a) \<notin> \<E> f 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (simp add: is_nextElem_def) [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> vertices f \<noteq> [] \<and> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f)\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> vertices f = [] \<or> a \<noteq> hd (vertices f)) 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (case_tac "vertices f = []") [PROOF STATE] proof (prove) goal (3 subgoals): 1. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> vertices f \<noteq> [] \<and> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f = []\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> vertices f = [] \<or> a \<noteq> hd (vertices f)) 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> vertices f \<noteq> [] \<and> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> vertices f = [] \<or> a \<noteq> hd (vertices f)) 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (drule minGraphProps2) [PROOF STATE] proof (prove) goal (4 subgoals): 1. \<lbrakk>f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> vertices f \<noteq> [] \<and> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f = []\<rbrakk> \<Longrightarrow> ?f2 \<in> \<F> g 2. \<lbrakk>f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> vertices f \<noteq> [] \<and> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f = []; 2 < |vertices ?f2|\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> vertices f = [] \<or> a \<noteq> hd (vertices f)) 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> vertices f \<noteq> [] \<and> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> vertices f = [] \<or> a \<noteq> hd (vertices f)) 4. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply simp [PROOF STATE] proof (prove) goal (3 subgoals): 1. \<lbrakk>f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> vertices f \<noteq> [] \<and> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f = []; 2 < |vertices ?f2|\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> vertices f = [] \<or> a \<noteq> hd (vertices f)) 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> vertices f \<noteq> [] \<and> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> vertices f = [] \<or> a \<noteq> hd (vertices f)) 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply simp [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> vertices f \<noteq> [] \<and> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> vertices f = [] \<or> a \<noteq> hd (vertices f)) 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply simp [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (case_tac "a = last (vertices f) \<and> b = hd (vertices f)") [PROOF STATE] proof (prove) goal (3 subgoals): 1. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; a = last (vertices f) \<and> b = hd (vertices f)\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (case_tac "vertices f") [PROOF STATE] proof (prove) goal (4 subgoals): 1. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; a = last (vertices f) \<and> b = hd (vertices f); vertices f = []\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 2. \<And>aa list. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; a = last (vertices f) \<and> b = hd (vertices f); vertices f = aa # list\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 4. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply simp [PROOF STATE] proof (prove) goal (3 subgoals): 1. \<And>aa list. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; a = last (vertices f) \<and> b = hd (vertices f); vertices f = aa # list\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (case_tac "list" rule: rev_exhaust) [PROOF STATE] proof (prove) goal (4 subgoals): 1. \<And>aa list. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; a = last (vertices f) \<and> b = hd (vertices f); vertices f = aa # list; list = []\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 2. \<And>aa list ys y. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; a = last (vertices f) \<and> b = hd (vertices f); vertices f = aa # list; list = ys @ [y]\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 4. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (drule minGraphProps2) [PROOF STATE] proof (prove) goal (5 subgoals): 1. \<And>aa list. \<lbrakk>f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; a = last (vertices f) \<and> b = hd (vertices f); vertices f = aa # list; list = []\<rbrakk> \<Longrightarrow> ?f12 aa list \<in> \<F> g 2. \<And>aa list. \<lbrakk>f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; a = last (vertices f) \<and> b = hd (vertices f); vertices f = aa # list; list = []; 2 < |vertices (?f12 aa list)|\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 3. \<And>aa list ys y. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; a = last (vertices f) \<and> b = hd (vertices f); vertices f = aa # list; list = ys @ [y]\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 4. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 5. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply simp [PROOF STATE] proof (prove) goal (4 subgoals): 1. \<And>aa list. \<lbrakk>f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; a = last (vertices f) \<and> b = hd (vertices f); vertices f = aa # list; list = []; 2 < |vertices f|\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 2. \<And>aa list ys y. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; a = last (vertices f) \<and> b = hd (vertices f); vertices f = aa # list; list = ys @ [y]\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 4. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply simp [PROOF STATE] proof (prove) goal (3 subgoals): 1. \<And>aa list ys y. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; a = last (vertices f) \<and> b = hd (vertices f); vertices f = aa # list; list = ys @ [y]\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (case_tac "ys") [PROOF STATE] proof (prove) goal (4 subgoals): 1. \<And>aa list ys y. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; a = last (vertices f) \<and> b = hd (vertices f); vertices f = aa # list; list = ys @ [y]; ys = []\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 2. \<And>aa list ys y aaa lista. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; a = last (vertices f) \<and> b = hd (vertices f); vertices f = aa # list; list = ys @ [y]; ys = aaa # lista\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 4. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (drule minGraphProps2) [PROOF STATE] proof (prove) goal (5 subgoals): 1. \<And>aa list ys y. \<lbrakk>f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; a = last (vertices f) \<and> b = hd (vertices f); vertices f = aa # list; list = ys @ [y]; ys = []\<rbrakk> \<Longrightarrow> ?f16 aa list ys y \<in> \<F> g 2. \<And>aa list ys y. \<lbrakk>f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; a = last (vertices f) \<and> b = hd (vertices f); vertices f = aa # list; list = ys @ [y]; ys = []; 2 < |vertices (?f16 aa list ys y)|\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 3. \<And>aa list ys y aaa lista. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; a = last (vertices f) \<and> b = hd (vertices f); vertices f = aa # list; list = ys @ [y]; ys = aaa # lista\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 4. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 5. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply simp [PROOF STATE] proof (prove) goal (4 subgoals): 1. \<And>aa list ys y. \<lbrakk>f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; a = last (vertices f) \<and> b = hd (vertices f); vertices f = aa # list; list = ys @ [y]; ys = []; 2 < |vertices f|\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 2. \<And>aa list ys y aaa lista. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; a = last (vertices f) \<and> b = hd (vertices f); vertices f = aa # list; list = ys @ [y]; ys = aaa # lista\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 4. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply simp [PROOF STATE] proof (prove) goal (3 subgoals): 1. \<And>aa list ys y aaa lista. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; a = last (vertices f) \<and> b = hd (vertices f); vertices f = aa # list; list = ys @ [y]; ys = aaa # lista\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (simp del: distinct_append distinct.simps) [PROOF STATE] proof (prove) goal (3 subgoals): 1. \<And>aa list ys aaa lista. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (aa # aaa # lista @ [a]); b = aa; vertices f = aa # aaa # lista @ [a]; list = aaa # lista @ [a]; ys = aaa # lista\<rbrakk> \<Longrightarrow> \<not> is_sublist [aa, a] (aa # aaa # lista @ [a]) \<and> aa \<noteq> a 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (rule conjI) [PROOF STATE] proof (prove) goal (4 subgoals): 1. \<And>aa list ys aaa lista. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (aa # aaa # lista @ [a]); b = aa; vertices f = aa # aaa # lista @ [a]; list = aaa # lista @ [a]; ys = aaa # lista\<rbrakk> \<Longrightarrow> \<not> is_sublist [aa, a] (aa # aaa # lista @ [a]) 2. \<And>aa list ys aaa lista. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (aa # aaa # lista @ [a]); b = aa; vertices f = aa # aaa # lista @ [a]; list = aaa # lista @ [a]; ys = aaa # lista\<rbrakk> \<Longrightarrow> aa \<noteq> a 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 4. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (rule ccontr) [PROOF STATE] proof (prove) goal (4 subgoals): 1. \<And>aa list ys aaa lista. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (aa # aaa # lista @ [a]); b = aa; vertices f = aa # aaa # lista @ [a]; list = aaa # lista @ [a]; ys = aaa # lista; \<not> \<not> is_sublist [aa, a] (aa # aaa # lista @ [a])\<rbrakk> \<Longrightarrow> False 2. \<And>aa list ys aaa lista. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (aa # aaa # lista @ [a]); b = aa; vertices f = aa # aaa # lista @ [a]; list = aaa # lista @ [a]; ys = aaa # lista\<rbrakk> \<Longrightarrow> aa \<noteq> a 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 4. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (simp del: distinct_append distinct.simps) [PROOF STATE] proof (prove) goal (4 subgoals): 1. \<And>aa list ys aaa lista. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (aa # aaa # lista @ [a]); b = aa; vertices f = aa # aaa # lista @ [a]; list = aaa # lista @ [a]; ys = aaa # lista; is_sublist [aa, a] (aa # aaa # lista @ [a])\<rbrakk> \<Longrightarrow> False 2. \<And>aa list ys aaa lista. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (aa # aaa # lista @ [a]); b = aa; vertices f = aa # aaa # lista @ [a]; list = aaa # lista @ [a]; ys = aaa # lista\<rbrakk> \<Longrightarrow> aa \<noteq> a 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 4. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (drule is_sublist_distinct_prefix) [PROOF STATE] proof (prove) goal (5 subgoals): 1. \<And>aa list ys aaa lista. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (aa # aaa # lista @ [a]); b = aa; vertices f = aa # aaa # lista @ [a]; list = aaa # lista @ [a]; ys = aaa # lista\<rbrakk> \<Longrightarrow> distinct (aa # aaa # lista @ [a]) 2. \<And>aa list ys aaa lista. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (aa # aaa # lista @ [a]); b = aa; vertices f = aa # aaa # lista @ [a]; list = aaa # lista @ [a]; ys = aaa # lista; is_prefix [a] (aaa # lista @ [a])\<rbrakk> \<Longrightarrow> False 3. \<And>aa list ys aaa lista. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (aa # aaa # lista @ [a]); b = aa; vertices f = aa # aaa # lista @ [a]; list = aaa # lista @ [a]; ys = aaa # lista\<rbrakk> \<Longrightarrow> aa \<noteq> a 4. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 5. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply simp [PROOF STATE] proof (prove) goal (4 subgoals): 1. \<And>aa list ys aaa lista. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (aa # aaa # lista @ [a]); b = aa; vertices f = aa # aaa # lista @ [a]; list = aaa # lista @ [a]; ys = aaa # lista; is_prefix [a] (aaa # lista @ [a])\<rbrakk> \<Longrightarrow> False 2. \<And>aa list ys aaa lista. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (aa # aaa # lista @ [a]); b = aa; vertices f = aa # aaa # lista @ [a]; list = aaa # lista @ [a]; ys = aaa # lista\<rbrakk> \<Longrightarrow> aa \<noteq> a 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 4. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (simp add: is_prefix_def) [PROOF STATE] proof (prove) goal (3 subgoals): 1. \<And>aa list ys aaa lista. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (aa # aaa # lista @ [a]); b = aa; vertices f = aa # aaa # lista @ [a]; list = aaa # lista @ [a]; ys = aaa # lista\<rbrakk> \<Longrightarrow> aa \<noteq> a 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply simp [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) \<and> (b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f)) 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (rule conjI) [PROOF STATE] proof (prove) goal (3 subgoals): 1. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> \<not> is_sublist [b, a] (vertices f) 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f) 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (simp add: is_sublist_def) [PROOF STATE] proof (prove) goal (3 subgoals): 1. \<lbrakk>minGraphProps g; f \<in> \<F> g; \<exists>as bs. vertices f = as @ a # b # bs; distinct (vertices f); vertices f \<noteq> []; a = last (vertices f) \<longrightarrow> b \<noteq> hd (vertices f)\<rbrakk> \<Longrightarrow> \<forall>as bs. vertices f \<noteq> as @ b # a # bs 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f) 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (elim exE) [PROOF STATE] proof (prove) goal (3 subgoals): 1. \<And>as bs. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; a = last (vertices f) \<longrightarrow> b \<noteq> hd (vertices f); vertices f = as @ a # b # bs\<rbrakk> \<Longrightarrow> \<forall>as bs. vertices f \<noteq> as @ b # a # bs 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f) 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (intro allI) [PROOF STATE] proof (prove) goal (3 subgoals): 1. \<And>as bs asa bsa. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; a = last (vertices f) \<longrightarrow> b \<noteq> hd (vertices f); vertices f = as @ a # b # bs\<rbrakk> \<Longrightarrow> vertices f \<noteq> asa @ b # a # bsa 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f) 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (rule ccontr) [PROOF STATE] proof (prove) goal (3 subgoals): 1. \<And>as bs asa bsa. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; a = last (vertices f) \<longrightarrow> b \<noteq> hd (vertices f); vertices f = as @ a # b # bs; \<not> vertices f \<noteq> asa @ b # a # bsa\<rbrakk> \<Longrightarrow> False 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f) 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (simp del: distinct_append distinct.simps) [PROOF STATE] proof (prove) goal (3 subgoals): 1. \<And>as bs asa bsa. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (asa @ b # a # bsa); a = (if bs = [] then b else last bs) \<longrightarrow> b \<noteq> hd (as @ (if bs = [] then b else last bs) # b # bs); vertices f = asa @ b # a # bsa; as @ a # b # bs = asa @ b # a # bsa\<rbrakk> \<Longrightarrow> False 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f) 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (subgoal_tac "asa = as @ [a]") [PROOF STATE] proof (prove) goal (4 subgoals): 1. \<And>as bs asa bsa. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (asa @ b # a # bsa); a = (if bs = [] then b else last bs) \<longrightarrow> b \<noteq> hd (as @ (if bs = [] then b else last bs) # b # bs); vertices f = asa @ b # a # bsa; as @ a # b # bs = asa @ b # a # bsa; asa = as @ [a]\<rbrakk> \<Longrightarrow> False 2. \<And>as bs asa bsa. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (asa @ b # a # bsa); a = (if bs = [] then b else last bs) \<longrightarrow> b \<noteq> hd (as @ (if bs = [] then b else last bs) # b # bs); vertices f = asa @ b # a # bsa; as @ a # b # bs = asa @ b # a # bsa\<rbrakk> \<Longrightarrow> asa = as @ [a] 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f) 4. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply simp [PROOF STATE] proof (prove) goal (3 subgoals): 1. \<And>as bs asa bsa. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (asa @ b # a # bsa); a = (if bs = [] then b else last bs) \<longrightarrow> b \<noteq> hd (as @ (if bs = [] then b else last bs) # b # bs); vertices f = asa @ b # a # bsa; as @ a # b # bs = asa @ b # a # bsa\<rbrakk> \<Longrightarrow> asa = as @ [a] 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f) 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (rule dist_at1) [PROOF STATE] proof (prove) goal (5 subgoals): 1. \<And>as bs asa bsa. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (asa @ b # a # bsa); a = (if bs = [] then b else last bs) \<longrightarrow> b \<noteq> hd (as @ (if bs = [] then b else last bs) # b # bs); vertices f = asa @ b # a # bsa; as @ a # b # bs = asa @ b # a # bsa\<rbrakk> \<Longrightarrow> distinct (?vs38 as bs asa bsa) 2. \<And>as bs asa bsa. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (asa @ b # a # bsa); a = (if bs = [] then b else last bs) \<longrightarrow> b \<noteq> hd (as @ (if bs = [] then b else last bs) # b # bs); vertices f = asa @ b # a # bsa; as @ a # b # bs = asa @ b # a # bsa\<rbrakk> \<Longrightarrow> ?vs38 as bs asa bsa = asa @ ?r38 as bs asa bsa # ?b38 as bs asa bsa 3. \<And>as bs asa bsa. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (asa @ b # a # bsa); a = (if bs = [] then b else last bs) \<longrightarrow> b \<noteq> hd (as @ (if bs = [] then b else last bs) # b # bs); vertices f = asa @ b # a # bsa; as @ a # b # bs = asa @ b # a # bsa\<rbrakk> \<Longrightarrow> ?vs38 as bs asa bsa = (as @ [a]) @ ?r38 as bs asa bsa # ?d38 as bs asa bsa 4. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f) 5. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply assumption [PROOF STATE] proof (prove) goal (4 subgoals): 1. \<And>as bs asa bsa. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (asa @ b # a # bsa); a = (if bs = [] then b else last bs) \<longrightarrow> b \<noteq> hd (as @ (if bs = [] then b else last bs) # b # bs); vertices f = asa @ b # a # bsa; as @ a # b # bs = asa @ b # a # bsa\<rbrakk> \<Longrightarrow> asa @ b # a # bsa = asa @ ?r38 as bs asa bsa # ?b38 as bs asa bsa 2. \<And>as bs asa bsa. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (asa @ b # a # bsa); a = (if bs = [] then b else last bs) \<longrightarrow> b \<noteq> hd (as @ (if bs = [] then b else last bs) # b # bs); vertices f = asa @ b # a # bsa; as @ a # b # bs = asa @ b # a # bsa\<rbrakk> \<Longrightarrow> asa @ b # a # bsa = (as @ [a]) @ ?r38 as bs asa bsa # ?d38 as bs asa bsa 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f) 4. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply force [PROOF STATE] proof (prove) goal (3 subgoals): 1. \<And>as bs asa bsa. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (asa @ b # a # bsa); a = (if bs = [] then b else last bs) \<longrightarrow> b \<noteq> hd (as @ (if bs = [] then b else last bs) # b # bs); vertices f = asa @ b # a # bsa; as @ a # b # bs = asa @ b # a # bsa\<rbrakk> \<Longrightarrow> asa @ b # a # bsa = (as @ [a]) @ b # ?d38 as bs asa bsa 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f) 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (rule sym) [PROOF STATE] proof (prove) goal (3 subgoals): 1. \<And>as bs asa bsa. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (asa @ b # a # bsa); a = (if bs = [] then b else last bs) \<longrightarrow> b \<noteq> hd (as @ (if bs = [] then b else last bs) # b # bs); vertices f = asa @ b # a # bsa; as @ a # b # bs = asa @ b # a # bsa\<rbrakk> \<Longrightarrow> (as @ [a]) @ b # ?d38 as bs asa bsa = asa @ b # a # bsa 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f) 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply simp [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f) 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (subgoal_tac "is_sublist [a, b] (vertices f)") [PROOF STATE] proof (prove) goal (3 subgoals): 1. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f)); is_sublist [a, b] (vertices f)\<rbrakk> \<Longrightarrow> b = last (vertices f) \<longrightarrow> a \<noteq> hd (vertices f) 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> is_sublist [a, b] (vertices f) 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (rule impI) [PROOF STATE] proof (prove) goal (3 subgoals): 1. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f)); is_sublist [a, b] (vertices f); b = last (vertices f)\<rbrakk> \<Longrightarrow> a \<noteq> hd (vertices f) 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> is_sublist [a, b] (vertices f) 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (rule ccontr) [PROOF STATE] proof (prove) goal (3 subgoals): 1. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f)); is_sublist [a, b] (vertices f); b = last (vertices f); \<not> a \<noteq> hd (vertices f)\<rbrakk> \<Longrightarrow> False 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> is_sublist [a, b] (vertices f) 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (simp add: is_sublist_def del: distinct_append distinct.simps) [PROOF STATE] proof (prove) goal (3 subgoals): 1. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); \<exists>as bs. vertices f = as @ hd (vertices f) # last (vertices f) # bs; b = last (vertices f); a = hd (vertices f)\<rbrakk> \<Longrightarrow> False 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> is_sublist [a, b] (vertices f) 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (subgoal_tac "last (vertices f) = b \<and> hd (vertices f) = a") [PROOF STATE] proof (prove) goal (4 subgoals): 1. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); \<exists>as bs. vertices f = as @ hd (vertices f) # last (vertices f) # bs; b = last (vertices f); a = hd (vertices f); last (vertices f) = b \<and> hd (vertices f) = a\<rbrakk> \<Longrightarrow> False 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); \<exists>as bs. vertices f = as @ hd (vertices f) # last (vertices f) # bs; b = last (vertices f); a = hd (vertices f)\<rbrakk> \<Longrightarrow> last (vertices f) = b \<and> hd (vertices f) = a 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> is_sublist [a, b] (vertices f) 4. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (thin_tac "a = hd (vertices f)") [PROOF STATE] proof (prove) goal (4 subgoals): 1. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); \<exists>as bs. vertices f = as @ hd (vertices f) # last (vertices f) # bs; b = last (vertices f); last (vertices f) = b \<and> hd (vertices f) = a\<rbrakk> \<Longrightarrow> False 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); \<exists>as bs. vertices f = as @ hd (vertices f) # last (vertices f) # bs; b = last (vertices f); a = hd (vertices f)\<rbrakk> \<Longrightarrow> last (vertices f) = b \<and> hd (vertices f) = a 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> is_sublist [a, b] (vertices f) 4. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (thin_tac "b = last (vertices f)") [PROOF STATE] proof (prove) goal (4 subgoals): 1. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); \<exists>as bs. vertices f = as @ hd (vertices f) # last (vertices f) # bs; last (vertices f) = b \<and> hd (vertices f) = a\<rbrakk> \<Longrightarrow> False 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); \<exists>as bs. vertices f = as @ hd (vertices f) # last (vertices f) # bs; b = last (vertices f); a = hd (vertices f)\<rbrakk> \<Longrightarrow> last (vertices f) = b \<and> hd (vertices f) = a 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> is_sublist [a, b] (vertices f) 4. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (elim conjE) [PROOF STATE] proof (prove) goal (4 subgoals): 1. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); \<exists>as bs. vertices f = as @ hd (vertices f) # last (vertices f) # bs; last (vertices f) = b; hd (vertices f) = a\<rbrakk> \<Longrightarrow> False 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); \<exists>as bs. vertices f = as @ hd (vertices f) # last (vertices f) # bs; b = last (vertices f); a = hd (vertices f)\<rbrakk> \<Longrightarrow> last (vertices f) = b \<and> hd (vertices f) = a 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> is_sublist [a, b] (vertices f) 4. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (elim exE) [PROOF STATE] proof (prove) goal (4 subgoals): 1. \<And>as bs. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); last (vertices f) = b; hd (vertices f) = a; vertices f = as @ hd (vertices f) # last (vertices f) # bs\<rbrakk> \<Longrightarrow> False 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); \<exists>as bs. vertices f = as @ hd (vertices f) # last (vertices f) # bs; b = last (vertices f); a = hd (vertices f)\<rbrakk> \<Longrightarrow> last (vertices f) = b \<and> hd (vertices f) = a 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> is_sublist [a, b] (vertices f) 4. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (case_tac "as") [PROOF STATE] proof (prove) goal (5 subgoals): 1. \<And>as bs. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); last (vertices f) = b; hd (vertices f) = a; vertices f = as @ hd (vertices f) # last (vertices f) # bs; as = []\<rbrakk> \<Longrightarrow> False 2. \<And>as bs aa list. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); last (vertices f) = b; hd (vertices f) = a; vertices f = as @ hd (vertices f) # last (vertices f) # bs; as = aa # list\<rbrakk> \<Longrightarrow> False 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); \<exists>as bs. vertices f = as @ hd (vertices f) # last (vertices f) # bs; b = last (vertices f); a = hd (vertices f)\<rbrakk> \<Longrightarrow> last (vertices f) = b \<and> hd (vertices f) = a 4. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> is_sublist [a, b] (vertices f) 5. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (case_tac "bs" rule: rev_exhaust) [PROOF STATE] proof (prove) goal (6 subgoals): 1. \<And>as bs. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); last (vertices f) = b; hd (vertices f) = a; vertices f = as @ hd (vertices f) # last (vertices f) # bs; as = []; bs = []\<rbrakk> \<Longrightarrow> False 2. \<And>as bs ys y. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); last (vertices f) = b; hd (vertices f) = a; vertices f = as @ hd (vertices f) # last (vertices f) # bs; as = []; bs = ys @ [y]\<rbrakk> \<Longrightarrow> False 3. \<And>as bs aa list. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); last (vertices f) = b; hd (vertices f) = a; vertices f = as @ hd (vertices f) # last (vertices f) # bs; as = aa # list\<rbrakk> \<Longrightarrow> False 4. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); \<exists>as bs. vertices f = as @ hd (vertices f) # last (vertices f) # bs; b = last (vertices f); a = hd (vertices f)\<rbrakk> \<Longrightarrow> last (vertices f) = b \<and> hd (vertices f) = a 5. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> is_sublist [a, b] (vertices f) 6. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (drule minGraphProps2) [PROOF STATE] proof (prove) goal (7 subgoals): 1. \<And>as bs. \<lbrakk>f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); last (vertices f) = b; hd (vertices f) = a; vertices f = as @ hd (vertices f) # last (vertices f) # bs; as = []; bs = []\<rbrakk> \<Longrightarrow> ?f64 as bs \<in> \<F> g 2. \<And>as bs. \<lbrakk>f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); last (vertices f) = b; hd (vertices f) = a; vertices f = as @ hd (vertices f) # last (vertices f) # bs; as = []; bs = []; 2 < |vertices (?f64 as bs)|\<rbrakk> \<Longrightarrow> False 3. \<And>as bs ys y. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); last (vertices f) = b; hd (vertices f) = a; vertices f = as @ hd (vertices f) # last (vertices f) # bs; as = []; bs = ys @ [y]\<rbrakk> \<Longrightarrow> False 4. \<And>as bs aa list. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); last (vertices f) = b; hd (vertices f) = a; vertices f = as @ hd (vertices f) # last (vertices f) # bs; as = aa # list\<rbrakk> \<Longrightarrow> False 5. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); \<exists>as bs. vertices f = as @ hd (vertices f) # last (vertices f) # bs; b = last (vertices f); a = hd (vertices f)\<rbrakk> \<Longrightarrow> last (vertices f) = b \<and> hd (vertices f) = a 6. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> is_sublist [a, b] (vertices f) 7. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply simp [PROOF STATE] proof (prove) goal (6 subgoals): 1. \<And>as bs. \<lbrakk>f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); last (vertices f) = b; hd (vertices f) = a; vertices f = as @ hd (vertices f) # last (vertices f) # bs; as = []; bs = []; 2 < |vertices f|\<rbrakk> \<Longrightarrow> False 2. \<And>as bs ys y. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); last (vertices f) = b; hd (vertices f) = a; vertices f = as @ hd (vertices f) # last (vertices f) # bs; as = []; bs = ys @ [y]\<rbrakk> \<Longrightarrow> False 3. \<And>as bs aa list. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); last (vertices f) = b; hd (vertices f) = a; vertices f = as @ hd (vertices f) # last (vertices f) # bs; as = aa # list\<rbrakk> \<Longrightarrow> False 4. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); \<exists>as bs. vertices f = as @ hd (vertices f) # last (vertices f) # bs; b = last (vertices f); a = hd (vertices f)\<rbrakk> \<Longrightarrow> last (vertices f) = b \<and> hd (vertices f) = a 5. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> is_sublist [a, b] (vertices f) 6. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply simp [PROOF STATE] proof (prove) goal (5 subgoals): 1. \<And>as bs ys y. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); last (vertices f) = b; hd (vertices f) = a; vertices f = as @ hd (vertices f) # last (vertices f) # bs; as = []; bs = ys @ [y]\<rbrakk> \<Longrightarrow> False 2. \<And>as bs aa list. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); last (vertices f) = b; hd (vertices f) = a; vertices f = as @ hd (vertices f) # last (vertices f) # bs; as = aa # list\<rbrakk> \<Longrightarrow> False 3. \<lbrakk>minGraphProps g; f \<in> \<F> g; distinct (vertices f); vertices f \<noteq> []; hd (vertices f) \<noteq> last (vertices f); \<exists>as bs. vertices f = as @ hd (vertices f) # last (vertices f) # bs; b = last (vertices f); a = hd (vertices f)\<rbrakk> \<Longrightarrow> last (vertices f) = b \<and> hd (vertices f) = a 4. \<lbrakk>minGraphProps g; f \<in> \<F> g; is_sublist [a, b] (vertices f) \<or> a = last (vertices f) \<and> b = hd (vertices f); distinct (vertices f); vertices f \<noteq> []; \<not> (a = last (vertices f) \<and> b = hd (vertices f))\<rbrakk> \<Longrightarrow> is_sublist [a, b] (vertices f) 5. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply simp+ [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> distinct (vertices f) [PROOF STEP] apply (rule minGraphProps3) [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> minGraphProps ?g68 2. \<lbrakk>minGraphProps g; f \<in> \<F> g; (a, b) \<in> \<E> f\<rbrakk> \<Longrightarrow> f \<in> \<F> ?g68 [PROOF STEP] by simp+
universe u def concat {Ξ±} : List Ξ± β†’ Ξ± β†’ List Ξ± | [], a => [a] | x::xs, a => x :: concat xs a def last {Ξ±} : (xs : List Ξ±) β†’ xs β‰  [] β†’ Ξ± | [], h => by contradiction | [a], h => a | _::a::as, h => last (a::as) (fun h => by injection h) def dropLast {Ξ±} : List Ξ± β†’ List Ξ± | [] => [] | [a] => [] | a::as => a :: dropLast as variable {Ξ±} theorem concatEq (xs : List Ξ±) (h : xs β‰  []) : concat (dropLast xs) (last xs h) = xs := by match xs, h with | [], h => contradiction | [x], h => rfl | x₁::xβ‚‚::xs, h => simp [concat, last, concatEq (xβ‚‚::xs) List.noConfusion] theorem lengthCons {Ξ±} (x : Ξ±) (xs : List Ξ±) : (x::xs).length = xs.length + 1 := let rec aux (a : Ξ±) (xs : List Ξ±) : (n : Nat) β†’ (a::xs).lengthAux n = xs.lengthAux n + 1 := match xs with | [] => fun _ => rfl | x::xs => fun n => aux a xs (n+1) aux x xs 0 theorem eqNilOfLengthZero {Ξ±} : (xs : List Ξ±) β†’ xs.length = 0 β†’ xs = [] | [], h => rfl | x::xs, h => by rw [lengthCons] at h; contradiction theorem dropLastLen {Ξ±} (xs : List Ξ±) : (n : Nat) β†’ xs.length = n+1 β†’ (dropLast xs).length = n := by match xs with | [] => intros; contradiction | [a] => intro n h have : 1 = n + 1 := h have : 0 = n := by injection this; assumption subst this rfl | x₁::xβ‚‚::xs => intro n h cases n with | zero => simp [lengthCons] at h injection h | succ n => have : (x₁ :: xβ‚‚ :: xs).length = xs.length + 2 := by simp [lengthCons] have : xs.length = n := by rw [this] at h; injection h with h; injection h with h; assumption simp [dropLast, lengthCons, dropLastLen (xβ‚‚::xs) xs.length (lengthCons ..), this] @[inline] def concatElim {Ξ±} (motive : List Ξ± β†’ Sort u) (base : Unit β†’ motive []) (ind : (xs : List Ξ±) β†’ (a : Ξ±) β†’ motive xs β†’ motive (concat xs a)) (xs : List Ξ±) : motive xs := let rec @[specialize] aux : (n : Nat) β†’ (xs : List Ξ±) β†’ xs.length = n β†’ motive xs | 0, xs, h => by have aux := eqNilOfLengthZero _ h subst aux apply base () | n+1, xs, h => by have notNil : xs β‰  [] := by intro h1; subst h1; injection h let ih := aux n (dropLast xs) (dropLastLen _ _ h) let aux := ind (dropLast xs) (last xs notNil) ih rw [concatEq] at aux exact aux aux xs.length xs rfl -- The generated code is tail recursive def test (xs : List Nat) : IO Unit := concatElim (motive := fun _ => IO Unit) (fun _ => pure ()) (fun xs x r => do IO.println s!"step xs: {xs} x: {x}"; r) xs #eval test [1, 2, 3, 4]
[GOAL] a b x : β„€ ⊒ x ∈ (fun a b => map (Function.Embedding.trans Nat.castEmbedding (addLeftEmbedding a)) (range (toNat (b + 1 - a)))) a b ↔ a ≀ x ∧ x ≀ b [PROOFSTEP] simp_rw [mem_map, mem_range, Int.lt_toNat, Function.Embedding.trans_apply, Nat.castEmbedding_apply, addLeftEmbedding_apply] [GOAL] a b x : β„€ ⊒ (βˆƒ a_1, ↑a_1 < b + 1 - a ∧ a + ↑a_1 = x) ↔ a ≀ x ∧ x ≀ b [PROOFSTEP] constructor [GOAL] case mp a b x : β„€ ⊒ (βˆƒ a_1, ↑a_1 < b + 1 - a ∧ a + ↑a_1 = x) β†’ a ≀ x ∧ x ≀ b [PROOFSTEP] rintro ⟨a, h, rfl⟩ [GOAL] case mp.intro.intro a✝ b : β„€ a : β„• h : ↑a < b + 1 - a✝ ⊒ a✝ ≀ a✝ + ↑a ∧ a✝ + ↑a ≀ b [PROOFSTEP] rw [lt_sub_iff_add_lt, Int.lt_add_one_iff, add_comm] at h [GOAL] case mp.intro.intro a✝ b : β„€ a : β„• h : a✝ + ↑a ≀ b ⊒ a✝ ≀ a✝ + ↑a ∧ a✝ + ↑a ≀ b [PROOFSTEP] exact ⟨Int.le.intro a rfl, h⟩ [GOAL] case mpr a b x : β„€ ⊒ a ≀ x ∧ x ≀ b β†’ βˆƒ a_2, ↑a_2 < b + 1 - a ∧ a + ↑a_2 = x [PROOFSTEP] rintro ⟨ha, hb⟩ [GOAL] case mpr.intro a b x : β„€ ha : a ≀ x hb : x ≀ b ⊒ βˆƒ a_1, ↑a_1 < b + 1 - a ∧ a + ↑a_1 = x [PROOFSTEP] use(x - a).toNat [GOAL] case h a b x : β„€ ha : a ≀ x hb : x ≀ b ⊒ ↑(toNat (x - a)) < b + 1 - a ∧ a + ↑(toNat (x - a)) = x [PROOFSTEP] rw [← lt_add_one_iff] at hb [GOAL] case h a b x : β„€ ha : a ≀ x hb : x < b + 1 ⊒ ↑(toNat (x - a)) < b + 1 - a ∧ a + ↑(toNat (x - a)) = x [PROOFSTEP] rw [toNat_sub_of_le ha] [GOAL] case h a b x : β„€ ha : a ≀ x hb : x < b + 1 ⊒ x - a < b + 1 - a ∧ a + (x - a) = x [PROOFSTEP] exact ⟨sub_lt_sub_right hb _, add_sub_cancel'_right _ _⟩ [GOAL] a b x : β„€ ⊒ x ∈ (fun a b => map (Function.Embedding.trans Nat.castEmbedding (addLeftEmbedding a)) (range (toNat (b - a)))) a b ↔ a ≀ x ∧ x < b [PROOFSTEP] simp_rw [mem_map, mem_range, Int.lt_toNat, Function.Embedding.trans_apply, Nat.castEmbedding_apply, addLeftEmbedding_apply] [GOAL] a b x : β„€ ⊒ (βˆƒ a_1, ↑a_1 < b - a ∧ a + ↑a_1 = x) ↔ a ≀ x ∧ x < b [PROOFSTEP] constructor [GOAL] case mp a b x : β„€ ⊒ (βˆƒ a_1, ↑a_1 < b - a ∧ a + ↑a_1 = x) β†’ a ≀ x ∧ x < b [PROOFSTEP] rintro ⟨a, h, rfl⟩ [GOAL] case mp.intro.intro a✝ b : β„€ a : β„• h : ↑a < b - a✝ ⊒ a✝ ≀ a✝ + ↑a ∧ a✝ + ↑a < b [PROOFSTEP] exact ⟨Int.le.intro a rfl, lt_sub_iff_add_lt'.mp h⟩ [GOAL] case mpr a b x : β„€ ⊒ a ≀ x ∧ x < b β†’ βˆƒ a_2, ↑a_2 < b - a ∧ a + ↑a_2 = x [PROOFSTEP] rintro ⟨ha, hb⟩ [GOAL] case mpr.intro a b x : β„€ ha : a ≀ x hb : x < b ⊒ βˆƒ a_1, ↑a_1 < b - a ∧ a + ↑a_1 = x [PROOFSTEP] use(x - a).toNat [GOAL] case h a b x : β„€ ha : a ≀ x hb : x < b ⊒ ↑(toNat (x - a)) < b - a ∧ a + ↑(toNat (x - a)) = x [PROOFSTEP] rw [toNat_sub_of_le ha] [GOAL] case h a b x : β„€ ha : a ≀ x hb : x < b ⊒ x - a < b - a ∧ a + (x - a) = x [PROOFSTEP] exact ⟨sub_lt_sub_right hb _, add_sub_cancel'_right _ _⟩ [GOAL] a b x : β„€ ⊒ x ∈ (fun a b => map (Function.Embedding.trans Nat.castEmbedding (addLeftEmbedding (a + 1))) (range (toNat (b - a)))) a b ↔ a < x ∧ x ≀ b [PROOFSTEP] simp_rw [mem_map, mem_range, Int.lt_toNat, Function.Embedding.trans_apply, Nat.castEmbedding_apply, addLeftEmbedding_apply] [GOAL] a b x : β„€ ⊒ (βˆƒ a_1, ↑a_1 < b - a ∧ a + 1 + ↑a_1 = x) ↔ a < x ∧ x ≀ b [PROOFSTEP] constructor [GOAL] case mp a b x : β„€ ⊒ (βˆƒ a_1, ↑a_1 < b - a ∧ a + 1 + ↑a_1 = x) β†’ a < x ∧ x ≀ b [PROOFSTEP] rintro ⟨a, h, rfl⟩ [GOAL] case mp.intro.intro a✝ b : β„€ a : β„• h : ↑a < b - a✝ ⊒ a✝ < a✝ + 1 + ↑a ∧ a✝ + 1 + ↑a ≀ b [PROOFSTEP] rw [← add_one_le_iff, le_sub_iff_add_le', add_comm _ (1 : β„€), ← add_assoc] at h [GOAL] case mp.intro.intro a✝ b : β„€ a : β„• h : a✝ + 1 + ↑a ≀ b ⊒ a✝ < a✝ + 1 + ↑a ∧ a✝ + 1 + ↑a ≀ b [PROOFSTEP] exact ⟨Int.le.intro a rfl, h⟩ [GOAL] case mpr a b x : β„€ ⊒ a < x ∧ x ≀ b β†’ βˆƒ a_2, ↑a_2 < b - a ∧ a + 1 + ↑a_2 = x [PROOFSTEP] rintro ⟨ha, hb⟩ [GOAL] case mpr.intro a b x : β„€ ha : a < x hb : x ≀ b ⊒ βˆƒ a_1, ↑a_1 < b - a ∧ a + 1 + ↑a_1 = x [PROOFSTEP] use(x - (a + 1)).toNat [GOAL] case h a b x : β„€ ha : a < x hb : x ≀ b ⊒ ↑(toNat (x - (a + 1))) < b - a ∧ a + 1 + ↑(toNat (x - (a + 1))) = x [PROOFSTEP] rw [toNat_sub_of_le ha, ← add_one_le_iff, sub_add, add_sub_cancel] [GOAL] case h a b x : β„€ ha : a < x hb : x ≀ b ⊒ x - a ≀ b - a ∧ a + 1 + (x - (a + 1)) = x [PROOFSTEP] exact ⟨sub_le_sub_right hb _, add_sub_cancel'_right _ _⟩ [GOAL] a b x : β„€ ⊒ x ∈ (fun a b => map (Function.Embedding.trans Nat.castEmbedding (addLeftEmbedding (a + 1))) (range (toNat (b - a - 1)))) a b ↔ a < x ∧ x < b [PROOFSTEP] simp_rw [mem_map, mem_range, Int.lt_toNat, Function.Embedding.trans_apply, Nat.castEmbedding_apply, addLeftEmbedding_apply] [GOAL] a b x : β„€ ⊒ (βˆƒ a_1, ↑a_1 < b - a - 1 ∧ a + 1 + ↑a_1 = x) ↔ a < x ∧ x < b [PROOFSTEP] constructor [GOAL] case mp a b x : β„€ ⊒ (βˆƒ a_1, ↑a_1 < b - a - 1 ∧ a + 1 + ↑a_1 = x) β†’ a < x ∧ x < b [PROOFSTEP] rintro ⟨a, h, rfl⟩ [GOAL] case mp.intro.intro a✝ b : β„€ a : β„• h : ↑a < b - a✝ - 1 ⊒ a✝ < a✝ + 1 + ↑a ∧ a✝ + 1 + ↑a < b [PROOFSTEP] rw [sub_sub, lt_sub_iff_add_lt'] at h [GOAL] case mp.intro.intro a✝ b : β„€ a : β„• h : a✝ + 1 + ↑a < b ⊒ a✝ < a✝ + 1 + ↑a ∧ a✝ + 1 + ↑a < b [PROOFSTEP] exact ⟨Int.le.intro a rfl, h⟩ [GOAL] case mpr a b x : β„€ ⊒ a < x ∧ x < b β†’ βˆƒ a_2, ↑a_2 < b - a - 1 ∧ a + 1 + ↑a_2 = x [PROOFSTEP] rintro ⟨ha, hb⟩ [GOAL] case mpr.intro a b x : β„€ ha : a < x hb : x < b ⊒ βˆƒ a_1, ↑a_1 < b - a - 1 ∧ a + 1 + ↑a_1 = x [PROOFSTEP] use(x - (a + 1)).toNat [GOAL] case h a b x : β„€ ha : a < x hb : x < b ⊒ ↑(toNat (x - (a + 1))) < b - a - 1 ∧ a + 1 + ↑(toNat (x - (a + 1))) = x [PROOFSTEP] rw [toNat_sub_of_le ha, sub_sub] [GOAL] case h a b x : β„€ ha : a < x hb : x < b ⊒ x - (a + 1) < b - (a + 1) ∧ a + 1 + (x - (a + 1)) = x [PROOFSTEP] exact ⟨sub_lt_sub_right hb _, add_sub_cancel'_right _ _⟩ [GOAL] a b : β„€ ⊒ ofNat (card (range (toNat (a βŠ” b + 1 - a βŠ“ b)))) = ofNat (natAbs (b - a) + 1) [PROOFSTEP] change ((↑) : β„• β†’ β„€) _ = ((↑) : β„• β†’ β„€) _ [GOAL] a b : β„€ ⊒ ↑(card (range (toNat (a βŠ” b + 1 - a βŠ“ b)))) = ↑(natAbs (b - a) + 1) [PROOFSTEP] rw [card_range, sup_eq_max, inf_eq_min, Int.toNat_of_nonneg (sub_nonneg_of_le <| le_add_one min_le_max), Int.ofNat_add, Int.coe_natAbs, add_comm, add_sub_assoc, max_sub_min_eq_abs, add_comm, Int.ofNat_one] [GOAL] a b : β„€ h : a ≀ b + 1 ⊒ ↑(card (Icc a b)) = b + 1 - a [PROOFSTEP] rw [card_Icc, toNat_sub_of_le h] [GOAL] a b : β„€ h : a ≀ b ⊒ ↑(card (Ico a b)) = b - a [PROOFSTEP] rw [card_Ico, toNat_sub_of_le h] [GOAL] a b : β„€ h : a ≀ b ⊒ ↑(card (Ioc a b)) = b - a [PROOFSTEP] rw [card_Ioc, toNat_sub_of_le h] [GOAL] a b : β„€ h : a < b ⊒ ↑(card (Ioo a b)) = b - a - 1 [PROOFSTEP] rw [card_Ioo, sub_sub, toNat_sub_of_le h] [GOAL] a b : β„€ ⊒ Fintype.card ↑(Set.Icc a b) = toNat (b + 1 - a) [PROOFSTEP] rw [← card_Icc, Fintype.card_ofFinset] [GOAL] a b : β„€ ⊒ Fintype.card ↑(Set.Ico a b) = toNat (b - a) [PROOFSTEP] rw [← card_Ico, Fintype.card_ofFinset] [GOAL] a b : β„€ ⊒ Fintype.card ↑(Set.Ioc a b) = toNat (b - a) [PROOFSTEP] rw [← card_Ioc, Fintype.card_ofFinset] [GOAL] a b : β„€ ⊒ Fintype.card ↑(Set.Ioo a b) = toNat (b - a - 1) [PROOFSTEP] rw [← card_Ioo, Fintype.card_ofFinset] [GOAL] a b : β„€ ⊒ Fintype.card ↑(Set.uIcc a b) = natAbs (b - a) + 1 [PROOFSTEP] rw [← card_uIcc, Fintype.card_ofFinset] [GOAL] a b : β„€ h : a ≀ b + 1 ⊒ ↑(Fintype.card ↑(Set.Icc a b)) = b + 1 - a [PROOFSTEP] rw [card_fintype_Icc, toNat_sub_of_le h] [GOAL] a b : β„€ h : a ≀ b ⊒ ↑(Fintype.card ↑(Set.Ico a b)) = b - a [PROOFSTEP] rw [card_fintype_Ico, toNat_sub_of_le h] [GOAL] a b : β„€ h : a ≀ b ⊒ ↑(Fintype.card ↑(Set.Ioc a b)) = b - a [PROOFSTEP] rw [card_fintype_Ioc, toNat_sub_of_le h] [GOAL] a b : β„€ h : a < b ⊒ ↑(Fintype.card ↑(Set.Ioo a b)) = b - a - 1 [PROOFSTEP] rw [card_fintype_Ioo, sub_sub, toNat_sub_of_le h] [GOAL] a✝ b n a : β„€ h : 0 ≀ a ⊒ image (fun x => x % a) (Ico n (n + a)) = Ico 0 a [PROOFSTEP] obtain rfl | ha := eq_or_lt_of_le h [GOAL] case inl a b n : β„€ h : 0 ≀ 0 ⊒ image (fun x => x % 0) (Ico n (n + 0)) = Ico 0 0 [PROOFSTEP] simp [GOAL] case inr a✝ b n a : β„€ h : 0 ≀ a ha : 0 < a ⊒ image (fun x => x % a) (Ico n (n + a)) = Ico 0 a [PROOFSTEP] ext i [GOAL] case inr.a a✝ b n a : β„€ h : 0 ≀ a ha : 0 < a i : β„€ ⊒ i ∈ image (fun x => x % a) (Ico n (n + a)) ↔ i ∈ Ico 0 a [PROOFSTEP] simp only [mem_image, mem_range, mem_Ico] [GOAL] case inr.a a✝ b n a : β„€ h : 0 ≀ a ha : 0 < a i : β„€ ⊒ (βˆƒ a_1, (n ≀ a_1 ∧ a_1 < n + a) ∧ a_1 % a = i) ↔ 0 ≀ i ∧ i < a [PROOFSTEP] constructor [GOAL] case inr.a.mp a✝ b n a : β„€ h : 0 ≀ a ha : 0 < a i : β„€ ⊒ (βˆƒ a_1, (n ≀ a_1 ∧ a_1 < n + a) ∧ a_1 % a = i) β†’ 0 ≀ i ∧ i < a [PROOFSTEP] rintro ⟨i, _, rfl⟩ [GOAL] case inr.a.mp.intro.intro a✝ b n a : β„€ h : 0 ≀ a ha : 0 < a i : β„€ left✝ : n ≀ i ∧ i < n + a ⊒ 0 ≀ i % a ∧ i % a < a [PROOFSTEP] exact ⟨emod_nonneg i ha.ne', emod_lt_of_pos i ha⟩ [GOAL] case inr.a.mpr a✝ b n a : β„€ h : 0 ≀ a ha : 0 < a i : β„€ ⊒ 0 ≀ i ∧ i < a β†’ βˆƒ a_2, (n ≀ a_2 ∧ a_2 < n + a) ∧ a_2 % a = i [PROOFSTEP] intro hia [GOAL] case inr.a.mpr a✝ b n a : β„€ h : 0 ≀ a ha : 0 < a i : β„€ hia : 0 ≀ i ∧ i < a ⊒ βˆƒ a_1, (n ≀ a_1 ∧ a_1 < n + a) ∧ a_1 % a = i [PROOFSTEP] have hn := Int.emod_add_ediv n a [GOAL] case inr.a.mpr a✝ b n a : β„€ h : 0 ≀ a ha : 0 < a i : β„€ hia : 0 ≀ i ∧ i < a hn : n % a + a * (n / a) = n ⊒ βˆƒ a_1, (n ≀ a_1 ∧ a_1 < n + a) ∧ a_1 % a = i [PROOFSTEP] obtain hi | hi := lt_or_le i (n % a) [GOAL] case inr.a.mpr.inl a✝ b n a : β„€ h : 0 ≀ a ha : 0 < a i : β„€ hia : 0 ≀ i ∧ i < a hn : n % a + a * (n / a) = n hi : i < n % a ⊒ βˆƒ a_1, (n ≀ a_1 ∧ a_1 < n + a) ∧ a_1 % a = i [PROOFSTEP] refine' ⟨i + a * (n / a + 1), ⟨_, _⟩, _⟩ [GOAL] case inr.a.mpr.inl.refine'_1 a✝ b n a : β„€ h : 0 ≀ a ha : 0 < a i : β„€ hia : 0 ≀ i ∧ i < a hn : n % a + a * (n / a) = n hi : i < n % a ⊒ n ≀ i + a * (n / a + 1) [PROOFSTEP] rw [add_comm (n / a), mul_add, mul_one, ← add_assoc] [GOAL] case inr.a.mpr.inl.refine'_1 a✝ b n a : β„€ h : 0 ≀ a ha : 0 < a i : β„€ hia : 0 ≀ i ∧ i < a hn : n % a + a * (n / a) = n hi : i < n % a ⊒ n ≀ i + a + a * (n / a) [PROOFSTEP] refine' hn.symm.le.trans (add_le_add_right _ _) [GOAL] case inr.a.mpr.inl.refine'_1 a✝ b n a : β„€ h : 0 ≀ a ha : 0 < a i : β„€ hia : 0 ≀ i ∧ i < a hn : n % a + a * (n / a) = n hi : i < n % a ⊒ n % a ≀ i + a [PROOFSTEP] simpa only [zero_add] using add_le_add hia.left (Int.emod_lt_of_pos n ha).le [GOAL] case inr.a.mpr.inl.refine'_2 a✝ b n a : β„€ h : 0 ≀ a ha : 0 < a i : β„€ hia : 0 ≀ i ∧ i < a hn : n % a + a * (n / a) = n hi : i < n % a ⊒ i + a * (n / a + 1) < n + a [PROOFSTEP] refine' lt_of_lt_of_le (add_lt_add_right hi (a * (n / a + 1))) _ [GOAL] case inr.a.mpr.inl.refine'_2 a✝ b n a : β„€ h : 0 ≀ a ha : 0 < a i : β„€ hia : 0 ≀ i ∧ i < a hn : n % a + a * (n / a) = n hi : i < n % a ⊒ n % a + a * (n / a + 1) ≀ n + a [PROOFSTEP] rw [mul_add, mul_one, ← add_assoc, hn] [GOAL] case inr.a.mpr.inl.refine'_3 a✝ b n a : β„€ h : 0 ≀ a ha : 0 < a i : β„€ hia : 0 ≀ i ∧ i < a hn : n % a + a * (n / a) = n hi : i < n % a ⊒ (i + a * (n / a + 1)) % a = i [PROOFSTEP] rw [Int.add_mul_emod_self_left, Int.emod_eq_of_lt hia.left hia.right] [GOAL] case inr.a.mpr.inr a✝ b n a : β„€ h : 0 ≀ a ha : 0 < a i : β„€ hia : 0 ≀ i ∧ i < a hn : n % a + a * (n / a) = n hi : n % a ≀ i ⊒ βˆƒ a_1, (n ≀ a_1 ∧ a_1 < n + a) ∧ a_1 % a = i [PROOFSTEP] refine' ⟨i + a * (n / a), ⟨_, _⟩, _⟩ [GOAL] case inr.a.mpr.inr.refine'_1 a✝ b n a : β„€ h : 0 ≀ a ha : 0 < a i : β„€ hia : 0 ≀ i ∧ i < a hn : n % a + a * (n / a) = n hi : n % a ≀ i ⊒ n ≀ i + a * (n / a) [PROOFSTEP] exact hn.symm.le.trans (add_le_add_right hi _) [GOAL] case inr.a.mpr.inr.refine'_2 a✝ b n a : β„€ h : 0 ≀ a ha : 0 < a i : β„€ hia : 0 ≀ i ∧ i < a hn : n % a + a * (n / a) = n hi : n % a ≀ i ⊒ i + a * (n / a) < n + a [PROOFSTEP] rw [add_comm n a] [GOAL] case inr.a.mpr.inr.refine'_2 a✝ b n a : β„€ h : 0 ≀ a ha : 0 < a i : β„€ hia : 0 ≀ i ∧ i < a hn : n % a + a * (n / a) = n hi : n % a ≀ i ⊒ i + a * (n / a) < a + n [PROOFSTEP] refine' add_lt_add_of_lt_of_le hia.right (le_trans _ hn.le) [GOAL] case inr.a.mpr.inr.refine'_2 a✝ b n a : β„€ h : 0 ≀ a ha : 0 < a i : β„€ hia : 0 ≀ i ∧ i < a hn : n % a + a * (n / a) = n hi : n % a ≀ i ⊒ a * (n / a) ≀ n % a + a * (n / a) [PROOFSTEP] simp only [zero_le, le_add_iff_nonneg_left] [GOAL] case inr.a.mpr.inr.refine'_2 a✝ b n a : β„€ h : 0 ≀ a ha : 0 < a i : β„€ hia : 0 ≀ i ∧ i < a hn : n % a + a * (n / a) = n hi : n % a ≀ i ⊒ 0 ≀ n % a [PROOFSTEP] exact Int.emod_nonneg n (ne_of_gt ha) [GOAL] case inr.a.mpr.inr.refine'_3 a✝ b n a : β„€ h : 0 ≀ a ha : 0 < a i : β„€ hia : 0 ≀ i ∧ i < a hn : n % a + a * (n / a) = n hi : n % a ≀ i ⊒ (i + a * (n / a)) % a = i [PROOFSTEP] rw [Int.add_mul_emod_self_left, Int.emod_eq_of_lt hia.left hia.right]
program nc_marquee ! @(#) example of inserting characters with insch(3c) !(LICENSE:PD) use M_ncurses implicit none character(len=80) :: text = "NEWS: *** Congressman indicted ***" integer :: i,j integer :: ierr integer(C_LONG) :: ich !------------------------------------------------------------------------------- stdscr=initscr() !------------------------------------------------------------------------------- ! set up some color pairs ierr=start_color() ierr=init_pair(1_C_SHORT,COLOR_WHITE,COLOR_BLUE) ierr=init_pair(2_C_SHORT,COLOR_RED,COLOR_YELLOW) ierr=init_pair(3_C_SHORT,COLOR_GREEN,COLOR_YELLOW) ierr=init_pair(4_C_SHORT,COLOR_BLUE,COLOR_YELLOW) ierr=init_pair(5_C_SHORT,COLOR_BLACK,COLOR_YELLOW) !------------------------------------------------------------------------------- ! change background to field of "+" chars. so the insert change is seen clearly ierr=wbkgd(stdscr,ior(ichar("+",C_LONG),COLOR_PAIR(2))) ierr=refresh() ! post background change to the display !------------------------------------------------------------------------------- ! insert a string onto the screen one character at a time from end to beginning do i=len_trim(text),1,-1 ! work through string backwards do j=1,5 ierr=move(5+j,5) ! always insert at the same spot ich=int(ichar(text(i:i)),C_LONG) ! convert char to INTEGER(C_LONG) ich=ior(ich,COLOR_PAIR(j)) ierr=insch(ich) ierr=refresh() ! post change to the display enddo ierr=napms(100) ! 0.1 sec. delay enddo ierr=getch() ierr=endwin() end program nc_marquee !-------------------------------------------------------------------------------
[STATEMENT] lemma (in \<Z>) arr_Rel_id_RelI: assumes "A \<in>\<^sub>\<circ> Vset \<alpha>" shows "arr_Rel \<alpha> (id_Rel A)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. arr_Rel \<alpha> (id_Rel A) [PROOF STEP] by (intro arr_RelI) (auto simp: id_Rel_components(1) assms dg_Rel_cs_intros dg_Rel_cs_simps)
#!/usr/bin/env python3 import networkx as nx import sys import utils from argparse import ArgumentParser class Options: def __init__(self): self._init_parser() def _init_parser(self): usage = 'filter_by_edge_weight.py -i <in.graphml> -o <out.graphml> -mw <weight> [--dry-run]' self.parser = ArgumentParser(usage=usage) self.parser.add_argument( '-i', required=True, dest='in_file', help='A weighted network' ) self.parser.add_argument( '-o', required=False, default=None, dest='out_file', help='The filtered network (default: modified in file name)' ) self.parser.add_argument( '-mw', '--min-weight', required=True, type=float, dest='min_weight', help='Minimum edge weight to retain' ) self.parser.add_argument( '-p', '--weight-property', required=False, default='weight', dest='weight_property', help='Name of weight property (default "weight")' ) self.parser.add_argument( '--dry-run', dest='dry_run', action='store_true', default=False, help='Dry run - will not write to disk (default: False)' ) self.parser.add_argument( '-v', '--verbose', dest='verbose', action='store_true', default=False, help='Verbose logging (default: False)' ) def parse(self, args=None): return self.parser.parse_args(args) DEBUG=False OVERRIDE=True def log(msg, override=False): if DEBUG or override: utils.eprint('[%s] %s' % (utils.now_str(), msg)) if __name__=='__main__': options = Options() opts = options.parse(sys.argv[1:]) DEBUG=opts.verbose STARTING_TIME = utils.now_str() log('Starting', OVERRIDE) if len(sys.argv) < 2: print('Usage: filter_by_edge_weight.py <in.graphml> <out.graphml>') sys.exit(1) in_gfn = opts.in_file out_gfn = opts.out_file if not out_gfn: out_gfn = f'{in_gfn[:in_gfn.rindex(".")]}-min{opts.min_weight}.graphml' # print(out_gfn) # sys.exit(0) in_g = nx.read_graphml(in_gfn) print(f'Min weight: {opts.min_weight}') print(f'In file: {in_gfn}') print(f'Out file: {out_gfn}') print(f'In: V={in_g.number_of_nodes():>8,} E={in_g.number_of_edges():>8,}') for u, v, _ in [ (u, v, w) for u, v, w in in_g.edges(data=opts.weight_property) if w < opts.min_weight ]: in_g.remove_edge(u, v) for n, _ in [(n, d) for n, d in in_g.degree() if d == 0 ]: in_g.remove_node(n) print(f'Out: V={in_g.number_of_nodes():>8,} E={in_g.number_of_edges():>8,}') if not opts.dry_run: nx.write_graphml(in_g, out_gfn) log('DONE having started at %s,' % STARTING_TIME, OVERRIDE)
section relation inductive rtc {Ξ± : Sort*} (r : Ξ± β†’ Ξ± β†’ Prop) : Ξ± β†’ Ξ± β†’ Prop | refl : βˆ€ a, rtc a a | base : βˆ€ a b, r a b β†’ rtc a b | trans : βˆ€ a b c, rtc a b β†’ rtc b c β†’ rtc a c section variables {Ξ± : Sort*} {r : Ξ± β†’ Ξ± β†’ Prop} {a b c : Ξ±} lemma rtc.refl' : rtc r a a := rtc.refl _ _ lemma rtc.base' (h : r a b) : rtc r a b := rtc.base _ _ h lemma rtc.trans' (h₁ : rtc r a b) (hβ‚‚ : rtc r b c) : rtc r a c := rtc.trans _ _ _ h₁ hβ‚‚ lemma rtc.base_trans (h₁ : r a b) (hβ‚‚ : rtc r b c) : rtc r a c := rtc.trans _ _ _ (rtc.base _ _ h₁) hβ‚‚ lemma rtc.trans_base (h₁ : rtc r a b) (hβ‚‚ : r b c) : rtc r a c := rtc.trans _ _ _ h₁ (rtc.base _ _ hβ‚‚) end end relation
(* Title: HOL/Algebra/Multiplicative_Group.thy Author: Simon Wimmer Author: Lars Noschinski *) theory Multiplicative_Group imports Complex_Main Group Coset UnivPoly Generated_Groups Elementary_Groups begin section \<open>Simplification Rules for Polynomials\<close> text_raw \<open>\label{sec:simp-rules}\<close> lemma (in ring_hom_cring) hom_sub[simp]: assumes "x \<in> carrier R" "y \<in> carrier R" shows "h (x \<ominus> y) = h x \<ominus>\<^bsub>S\<^esub> h y" using assms by (simp add: R.minus_eq S.minus_eq) context UP_ring begin lemma deg_nzero_nzero: assumes deg_p_nzero: "deg R p \<noteq> 0" shows "p \<noteq> \<zero>\<^bsub>P\<^esub>" using deg_zero deg_p_nzero by auto lemma deg_add_eq: assumes c: "p \<in> carrier P" "q \<in> carrier P" assumes "deg R q \<noteq> deg R p" shows "deg R (p \<oplus>\<^bsub>P\<^esub> q) = max (deg R p) (deg R q)" proof - let ?m = "max (deg R p) (deg R q)" from assms have "coeff P p ?m = \<zero> \<longleftrightarrow> coeff P q ?m \<noteq> \<zero>" by (metis deg_belowI lcoeff_nonzero[OF deg_nzero_nzero] linear max.absorb_iff2 max.absorb1) then have "coeff P (p \<oplus>\<^bsub>P\<^esub> q) ?m \<noteq> \<zero>" using assms by auto then have "deg R (p \<oplus>\<^bsub>P\<^esub> q) \<ge> ?m" using assms by (blast intro: deg_belowI) with deg_add[OF c] show ?thesis by arith qed lemma deg_minus_eq: assumes "p \<in> carrier P" "q \<in> carrier P" "deg R q \<noteq> deg R p" shows "deg R (p \<ominus>\<^bsub>P\<^esub> q) = max (deg R p) (deg R q)" using assms by (simp add: deg_add_eq a_minus_def) end context UP_cring begin lemma evalRR_add: assumes "p \<in> carrier P" "q \<in> carrier P" assumes x: "x \<in> carrier R" shows "eval R R id x (p \<oplus>\<^bsub>P\<^esub> q) = eval R R id x p \<oplus> eval R R id x q" proof - interpret UP_pre_univ_prop R R id by unfold_locales simp interpret ring_hom_cring P R "eval R R id x" by unfold_locales (rule eval_ring_hom[OF x]) show ?thesis using assms by simp qed lemma evalRR_sub: assumes "p \<in> carrier P" "q \<in> carrier P" assumes x: "x \<in> carrier R" shows "eval R R id x (p \<ominus>\<^bsub>P\<^esub> q) = eval R R id x p \<ominus> eval R R id x q" proof - interpret UP_pre_univ_prop R R id by unfold_locales simp interpret ring_hom_cring P R "eval R R id x" by unfold_locales (rule eval_ring_hom[OF x]) show ?thesis using assms by simp qed lemma evalRR_mult: assumes "p \<in> carrier P" "q \<in> carrier P" assumes x: "x \<in> carrier R" shows "eval R R id x (p \<otimes>\<^bsub>P\<^esub> q) = eval R R id x p \<otimes> eval R R id x q" proof - interpret UP_pre_univ_prop R R id by unfold_locales simp interpret ring_hom_cring P R "eval R R id x" by unfold_locales (rule eval_ring_hom[OF x]) show ?thesis using assms by simp qed lemma evalRR_monom: assumes a: "a \<in> carrier R" and x: "x \<in> carrier R" shows "eval R R id x (monom P a d) = a \<otimes> x [^] d" proof - interpret UP_pre_univ_prop R R id by unfold_locales simp show ?thesis using assms by (simp add: eval_monom) qed lemma evalRR_one: assumes x: "x \<in> carrier R" shows "eval R R id x \<one>\<^bsub>P\<^esub> = \<one>" proof - interpret UP_pre_univ_prop R R id by unfold_locales simp interpret ring_hom_cring P R "eval R R id x" by unfold_locales (rule eval_ring_hom[OF x]) show ?thesis using assms by simp qed lemma carrier_evalRR: assumes x: "x \<in> carrier R" and "p \<in> carrier P" shows "eval R R id x p \<in> carrier R" proof - interpret UP_pre_univ_prop R R id by unfold_locales simp interpret ring_hom_cring P R "eval R R id x" by unfold_locales (rule eval_ring_hom[OF x]) show ?thesis using assms by simp qed lemmas evalRR_simps = evalRR_add evalRR_sub evalRR_mult evalRR_monom evalRR_one carrier_evalRR end section \<open>Properties of the Euler \<open>\<phi>\<close>-function\<close> text_raw \<open>\label{sec:euler-phi}\<close> text\<open> In this section we prove that for every positive natural number the equation $\sum_{d | n}^n \varphi(d) = n$ holds. \<close> lemma dvd_div_ge_1: fixes a b :: nat assumes "a \<ge> 1" "b dvd a" shows "a div b \<ge> 1" proof - from \<open>b dvd a\<close> obtain c where "a = b * c" .. with \<open>a \<ge> 1\<close> show ?thesis by simp qed lemma dvd_nat_bounds: fixes n p :: nat assumes "p > 0" "n dvd p" shows "n > 0 \<and> n \<le> p" using assms by (simp add: dvd_pos_nat dvd_imp_le) (* TODO FIXME: This is the "totient" function from HOL-Number_Theory, but since part of HOL-Number_Theory depends on HOL-Algebra.Multiplicative_Group, there would be a cyclic dependency. *) definition phi' :: "nat => nat" where "phi' m = card {x. 1 \<le> x \<and> x \<le> m \<and> coprime x m}" notation (latex output) phi' ("\<phi> _") lemma phi'_nonzero: assumes "m > 0" shows "phi' m > 0" proof - have "1 \<in> {x. 1 \<le> x \<and> x \<le> m \<and> coprime x m}" using assms by simp hence "card {x. 1 \<le> x \<and> x \<le> m \<and> coprime x m} > 0" by (auto simp: card_gt_0_iff) thus ?thesis unfolding phi'_def by simp qed lemma dvd_div_eq_1: fixes a b c :: nat assumes "c dvd a" "c dvd b" "a div c = b div c" shows "a = b" using assms dvd_mult_div_cancel[OF \<open>c dvd a\<close>] dvd_mult_div_cancel[OF \<open>c dvd b\<close>] by presburger lemma dvd_div_eq_2: fixes a b c :: nat assumes "c>0" "a dvd c" "b dvd c" "c div a = c div b" shows "a = b" proof - have "a > 0" "a \<le> c" using dvd_nat_bounds[OF assms(1-2)] by auto have "a*(c div a) = c" using assms dvd_mult_div_cancel by fastforce also have "\<dots> = b*(c div a)" using assms dvd_mult_div_cancel by fastforce finally show "a = b" using \<open>c>0\<close> dvd_div_ge_1[OF _ \<open>a dvd c\<close>] by fastforce qed lemma div_mult_mono: fixes a b c :: nat assumes "a > 0" "a\<le>d" shows "a * b div d \<le> b" proof - have "a*b div d \<le> b*a div a" using assms div_le_mono2 mult.commute[of a b] by presburger thus ?thesis using assms by force qed text\<open> We arrive at the main result of this section: For every positive natural number the equation $\sum_{d | n}^n \varphi(d) = n$ holds. The outline of the proof for this lemma is as follows: We count the $n$ fractions $1/n$, $\ldots$, $(n-1)/n$, $n/n$. We analyze the reduced form $a/d = m/n$ for any of those fractions. We want to know how many fractions $m/n$ have the reduced form denominator $d$. The condition $1 \leq m \leq n$ is equivalent to the condition $1 \leq a \leq d$. Therefore we want to know how many $a$ with $1 \leq a \leq d$ exist, s.t. \<^term>\<open>gcd a d = 1\<close>. This number is exactly \<^term>\<open>phi' d\<close>. Finally, by counting the fractions $m/n$ according to their reduced form denominator, we get: @{term [display] "(\<Sum>d | d dvd n . phi' d) = n"}. To formalize this proof in Isabelle, we analyze for an arbitrary divisor $d$ of $n$ \begin{itemize} \item the set of reduced form numerators \<^term>\<open>{a. (1::nat) \<le> a \<and> a \<le> d \<and> coprime a d}\<close> \item the set of numerators $m$, for which $m/n$ has the reduced form denominator $d$, i.e. the set \<^term>\<open>{m \<in> {1::nat .. n}. n div gcd m n = d}\<close> \end{itemize} We show that \<^term>\<open>\<lambda>a. a*n div d\<close> with the inverse \<^term>\<open>\<lambda>a. a div gcd a n\<close> is a bijection between theses sets, thus yielding the equality @{term [display] "phi' d = card {m \<in> {1 .. n}. n div gcd m n = d}"} This gives us @{term [display] "(\<Sum>d | d dvd n . phi' d) = card (\<Union>d \<in> {d. d dvd n}. {m \<in> {1 .. n}. n div gcd m n = d})"} and by showing \<^term>\<open>(\<Union>d \<in> {d. d dvd n}. {m \<in> {1::nat .. n}. n div gcd m n = d}) \<supseteq> {1 .. n}\<close> (this is our counting argument) the thesis follows. \<close> lemma sum_phi'_factors: fixes n :: nat assumes "n > 0" shows "(\<Sum>d | d dvd n. phi' d) = n" proof - { fix d assume "d dvd n" then obtain q where q: "n = d * q" .. have "card {a. 1 \<le> a \<and> a \<le> d \<and> coprime a d} = card {m \<in> {1 .. n}. n div gcd m n = d}" (is "card ?RF = card ?F") proof (rule card_bij_eq) { fix a b assume "a * n div d = b * n div d" hence "a * (n div d) = b * (n div d)" using dvd_div_mult[OF \<open>d dvd n\<close>] by (fastforce simp add: mult.commute) hence "a = b" using dvd_div_ge_1[OF _ \<open>d dvd n\<close>] \<open>n>0\<close> by (simp add: mult.commute nat_mult_eq_cancel1) } thus "inj_on (\<lambda>a. a*n div d) ?RF" unfolding inj_on_def by blast { fix a assume a: "a\<in>?RF" hence "a * (n div d) \<ge> 1" using \<open>n>0\<close> dvd_div_ge_1[OF _ \<open>d dvd n\<close>] by simp hence ge_1: "a * n div d \<ge> 1" by (simp add: \<open>d dvd n\<close> div_mult_swap) have le_n: "a * n div d \<le> n" using div_mult_mono a by simp have "gcd (a * n div d) n = n div d * gcd a d" by (simp add: gcd_mult_distrib_nat q ac_simps) hence "n div gcd (a * n div d) n = d*n div (d*(n div d))" using a by simp hence "a * n div d \<in> ?F" using ge_1 le_n by (fastforce simp add: \<open>d dvd n\<close>) } thus "(\<lambda>a. a*n div d) ` ?RF \<subseteq> ?F" by blast { fix m l assume A: "m \<in> ?F" "l \<in> ?F" "m div gcd m n = l div gcd l n" hence "gcd m n = gcd l n" using dvd_div_eq_2[OF assms] by fastforce hence "m = l" using dvd_div_eq_1[of "gcd m n" m l] A(3) by fastforce } thus "inj_on (\<lambda>a. a div gcd a n) ?F" unfolding inj_on_def by blast { fix m assume "m \<in> ?F" hence "m div gcd m n \<in> ?RF" using dvd_div_ge_1 by (fastforce simp add: div_le_mono div_gcd_coprime) } thus "(\<lambda>a. a div gcd a n) ` ?F \<subseteq> ?RF" by blast qed force+ } hence phi'_eq: "\<And>d. d dvd n \<Longrightarrow> phi' d = card {m \<in> {1 .. n}. n div gcd m n = d}" unfolding phi'_def by presburger have fin: "finite {d. d dvd n}" using dvd_nat_bounds[OF \<open>n>0\<close>] by force have "(\<Sum>d | d dvd n. phi' d) = card (\<Union>d \<in> {d. d dvd n}. {m \<in> {1 .. n}. n div gcd m n = d})" using card_UN_disjoint[OF fin, of "(\<lambda>d. {m \<in> {1 .. n}. n div gcd m n = d})"] phi'_eq by fastforce also have "(\<Union>d \<in> {d. d dvd n}. {m \<in> {1 .. n}. n div gcd m n = d}) = {1 .. n}" (is "?L = ?R") proof show "?L \<supseteq> ?R" proof fix m assume m: "m \<in> ?R" thus "m \<in> ?L" using dvd_triv_right[of "n div gcd m n" "gcd m n"] by simp qed qed fastforce finally show ?thesis by force qed section \<open>Order of an Element of a Group\<close> text_raw \<open>\label{sec:order-elem}\<close> context group begin definition (in group) ord :: "'a \<Rightarrow> nat" where "ord x \<equiv> (@d. \<forall>n::nat. x [^] n = \<one> \<longleftrightarrow> d dvd n)" lemma (in group) pow_eq_id: assumes "x \<in> carrier G" shows "x [^] n = \<one> \<longleftrightarrow> (ord x) dvd n" proof (cases "\<forall>n::nat. pow G x n = one G \<longrightarrow> n = 0") case True show ?thesis unfolding ord_def by (rule someI2 [where a=0]) (auto simp: True) next case False define N where "N \<equiv> LEAST n::nat. x [^] n = \<one> \<and> n > 0" have N: "x [^] N = \<one> \<and> N > 0" using False apply (simp add: N_def) by (metis (mono_tags, lifting) LeastI) have eq0: "n = 0" if "x [^] n = \<one>" "n < N" for n using N_def not_less_Least that by fastforce show ?thesis unfolding ord_def proof (rule someI2 [where a = N], rule allI) fix n :: "nat" show "(x [^] n = \<one>) \<longleftrightarrow> (N dvd n)" proof (cases "n = 0") case False show ?thesis unfolding dvd_def proof safe assume 1: "x [^] n = \<one>" have "x [^] n = x [^] (n mod N + N * (n div N))" by simp also have "\<dots> = x [^] (n mod N) \<otimes> x [^] (N * (n div N))" by (simp add: assms nat_pow_mult) also have "\<dots> = x [^] (n mod N)" by (metis N assms l_cancel_one nat_pow_closed nat_pow_one nat_pow_pow) finally have "x [^] (n mod N) = \<one>" by (simp add: "1") then have "n mod N = 0" using N eq0 mod_less_divisor by blast then show "\<exists>k. n = N * k" by blast next fix k :: "nat" assume "n = N * k" with N show "x [^] (N * k) = \<one>" by (metis assms nat_pow_one nat_pow_pow) qed qed simp qed blast qed lemma (in group) pow_ord_eq_1 [simp]: "x \<in> carrier G \<Longrightarrow> x [^] ord x = \<one>" by (simp add: pow_eq_id) lemma (in group) int_pow_eq_id: assumes "x \<in> carrier G" shows "(pow G x i = one G \<longleftrightarrow> int (ord x) dvd i)" proof (cases i rule: int_cases2) case (nonneg n) then show ?thesis by (simp add: int_pow_int pow_eq_id assms) next case (nonpos n) then have "x [^] i = inv (x [^] n)" by (simp add: assms int_pow_int int_pow_neg) then show ?thesis by (simp add: assms pow_eq_id nonpos) qed lemma (in group) int_pow_eq: "x \<in> carrier G \<Longrightarrow> (x [^] m = x [^] n) \<longleftrightarrow> int (ord x) dvd (n - m)" apply (simp flip: int_pow_eq_id) by (metis int_pow_closed int_pow_diff inv_closed r_inv right_cancel) lemma (in group) ord_eq_0: "x \<in> carrier G \<Longrightarrow> (ord x = 0 \<longleftrightarrow> (\<forall>n::nat. n \<noteq> 0 \<longrightarrow> x [^] n \<noteq> \<one>))" by (auto simp: pow_eq_id) lemma (in group) ord_unique: "x \<in> carrier G \<Longrightarrow> ord x = d \<longleftrightarrow> (\<forall>n. pow G x n = one G \<longleftrightarrow> d dvd n)" by (meson dvd_antisym dvd_refl pow_eq_id) lemma (in group) ord_eq_1: "x \<in> carrier G \<Longrightarrow> (ord x = 1 \<longleftrightarrow> x = \<one>)" by (metis pow_eq_id nat_dvd_1_iff_1 nat_pow_eone) lemma (in group) ord_id [simp]: "ord (one G) = 1" using ord_eq_1 by blast lemma (in group) ord_inv [simp]: "x \<in> carrier G \<Longrightarrow> ord (m_inv G x) = ord x" by (simp add: ord_unique pow_eq_id nat_pow_inv) lemma (in group) ord_pow: assumes "x \<in> carrier G" "k dvd ord x" "k \<noteq> 0" shows "ord (pow G x k) = ord x div k" proof - have "(x [^] k) [^] (ord x div k) = \<one>" using assms by (simp add: nat_pow_pow) moreover have "ord x dvd k * ord (x [^] k)" by (metis assms(1) pow_ord_eq_1 pow_eq_id nat_pow_closed nat_pow_pow) ultimately show ?thesis by (metis assms div_dvd_div dvd_antisym dvd_triv_left pow_eq_id nat_pow_closed nonzero_mult_div_cancel_left) qed lemma (in group) ord_mul_divides: assumes eq: "x \<otimes> y = y \<otimes> x" and xy: "x \<in> carrier G" "y \<in> carrier G" shows "ord (x \<otimes> y) dvd (ord x * ord y)" apply (simp add: xy flip: pow_eq_id eq) by (metis dvd_triv_left dvd_triv_right eq pow_eq_id one_closed pow_mult_distrib r_one xy) lemma (in comm_group) abelian_ord_mul_divides: "\<lbrakk>x \<in> carrier G; y \<in> carrier G\<rbrakk> \<Longrightarrow> ord (x \<otimes> y) dvd (ord x * ord y)" by (simp add: ord_mul_divides m_comm) lemma ord_inj: assumes a: "a \<in> carrier G" shows "inj_on (\<lambda> x . a [^] x) {0 .. ord a - 1}" proof - let ?M = "Max (ord ` carrier G)" have "finite {d \<in> {..?M}. a [^] d = \<one>}" by auto have *: False if A: "x < y" "x \<in> {0 .. ord a - 1}" "y \<in> {0 .. ord a - 1}" "a [^] x = a [^] y" for x y proof - have "y - x < ord a" using that by auto moreover have "a [^] (y-x) = \<one>" using a A by (simp add: pow_eq_div2) ultimately have "min (y - x) (ord a) = ord a" using A(1) a pow_eq_id by auto with \<open>y - x < ord a\<close> show False by linarith qed show ?thesis unfolding inj_on_def by (metis nat_neq_iff *) qed lemma ord_inj': assumes a: "a \<in> carrier G" shows "inj_on (\<lambda> x . a [^] x) {1 .. ord a}" proof (rule inj_onI, rule ccontr) fix x y :: nat assume A: "x \<in> {1 .. ord a}" "y \<in> {1 .. ord a}" "a [^] x = a [^] y" "x\<noteq>y" { assume "x < ord a" "y < ord a" hence False using ord_inj[OF assms] A unfolding inj_on_def by fastforce } moreover { assume "x = ord a" "y < ord a" hence "a [^] y = a [^] (0::nat)" using pow_ord_eq_1 A by (simp add: a) hence "y=0" using ord_inj[OF assms] \<open>y < ord a\<close> unfolding inj_on_def by force hence False using A by fastforce } moreover { assume "y = ord a" "x < ord a" hence "a [^] x = a [^] (0::nat)" using pow_ord_eq_1 A by (simp add: a) hence "x=0" using ord_inj[OF assms] \<open>x < ord a\<close> unfolding inj_on_def by force hence False using A by fastforce } ultimately show False using A by force qed lemma (in group) ord_ge_1: assumes finite: "finite (carrier G)" and a: "a \<in> carrier G" shows "ord a \<ge> 1" proof - have "((\<lambda>n::nat. a [^] n) ` {0<..}) \<subseteq> carrier G" using a by blast then have "finite ((\<lambda>n::nat. a [^] n) ` {0<..})" using finite_subset finite by auto then have "\<not> inj_on (\<lambda>n::nat. a [^] n) {0<..}" using finite_imageD infinite_Ioi by blast then obtain i j::nat where "i \<noteq> j" "a [^] i = a [^] j" by (auto simp: inj_on_def) then have "\<exists>n::nat. n>0 \<and> a [^] n = \<one>" by (metis a diffs0_imp_equal pow_eq_div2 neq0_conv) then have "ord a \<noteq> 0" by (simp add: ord_eq_0 [OF a]) then show ?thesis by simp qed lemma ord_elems: assumes "finite (carrier G)" "a \<in> carrier G" shows "{a[^]x | x. x \<in> (UNIV :: nat set)} = {a[^]x | x. x \<in> {0 .. ord a - 1}}" (is "?L = ?R") proof show "?R \<subseteq> ?L" by blast { fix y assume "y \<in> ?L" then obtain x::nat where x: "y = a[^]x" by auto define r q where "r = x mod ord a" and "q = x div ord a" then have "x = q * ord a + r" by (simp add: div_mult_mod_eq) hence "y = (a[^]ord a)[^]q \<otimes> a[^]r" using x assms by (metis mult.commute nat_pow_mult nat_pow_pow) hence "y = a[^]r" using assms by (simp add: pow_ord_eq_1) have "r < ord a" using ord_ge_1[OF assms] by (simp add: r_def) hence "r \<in> {0 .. ord a - 1}" by (force simp: r_def) hence "y \<in> {a[^]x | x. x \<in> {0 .. ord a - 1}}" using \<open>y=a[^]r\<close> by blast } thus "?L \<subseteq> ?R" by auto qed lemma (in group) assumes "x \<in> carrier G" shows finite_cyclic_subgroup: "finite(carrier(subgroup_generated G {x})) \<longleftrightarrow> (\<exists>n::nat. n \<noteq> 0 \<and> x [^] n = \<one>)" (is "?fin \<longleftrightarrow> ?nat1") and infinite_cyclic_subgroup: "infinite(carrier(subgroup_generated G {x})) \<longleftrightarrow> (\<forall>m n::nat. x [^] m = x [^] n \<longrightarrow> m = n)" (is "\<not> ?fin \<longleftrightarrow> ?nateq") and finite_cyclic_subgroup_int: "finite(carrier(subgroup_generated G {x})) \<longleftrightarrow> (\<exists>i::int. i \<noteq> 0 \<and> x [^] i = \<one>)" (is "?fin \<longleftrightarrow> ?int1") and infinite_cyclic_subgroup_int: "infinite(carrier(subgroup_generated G {x})) \<longleftrightarrow> (\<forall>i j::int. x [^] i = x [^] j \<longrightarrow> i = j)" (is "\<not> ?fin \<longleftrightarrow> ?inteq") proof - have 1: "\<not> ?fin" if ?nateq proof - have "infinite (range (\<lambda>n::nat. x [^] n))" using that range_inj_infinite [of "(\<lambda>n::nat. x [^] n)"] by (auto simp: inj_on_def) moreover have "range (\<lambda>n::nat. x [^] n) \<subseteq> range (\<lambda>i::int. x [^] i)" apply clarify by (metis assms group.int_pow_neg int_pow_closed int_pow_neg_int is_group local.inv_equality nat_pow_closed r_inv rangeI) ultimately show ?thesis using carrier_subgroup_generated_by_singleton [OF assms] finite_subset by auto qed have 2: "m = n" if mn: "x [^] m = x [^] n" and eq [rule_format]: "?inteq" for m n::nat using eq [of "int m" "int n"] by (simp add: int_pow_int mn) have 3: ?nat1 if non: "\<not> ?inteq" proof - obtain i j::int where eq: "x [^] i = x [^] j" and "i \<noteq> j" using non by auto show ?thesis proof (cases i j rule: linorder_cases) case less then have [simp]: "x [^] (j - i) = \<one>" by (simp add: eq assms int_pow_diff) show ?thesis using less by (rule_tac x="nat (j-i)" in exI) auto next case greater then have [simp]: "x [^] (i - j) = \<one>" by (simp add: eq assms int_pow_diff) then show ?thesis using greater by (rule_tac x="nat (i-j)" in exI) auto qed (use \<open>i \<noteq> j\<close> in auto) qed have 4: "\<exists>i::int. (i \<noteq> 0) \<and> x [^] i = \<one>" if "n \<noteq> 0" "x [^] n = \<one>" for n::nat apply (rule_tac x="int n" in exI) by (simp add: int_pow_int that) have 5: "finite (carrier (subgroup_generated G {x}))" if "i \<noteq> 0" and 1: "x [^] i = \<one>" for i::int proof - obtain n::nat where n: "n > 0" "x [^] n = \<one>" using "1" "3" \<open>i \<noteq> 0\<close> by fastforce have "x [^] a \<in> ([^]) x ` {0..<n}" for a::int proof show "x [^] a = x [^] nat (a mod int n)" using n by simp (metis (no_types, lifting) assms dvd_minus_mod dvd_trans int_pow_eq int_pow_eq_id int_pow_int) show "nat (a mod int n) \<in> {0..<n}" using n by (simp add: nat_less_iff) qed then have "carrier (subgroup_generated G {x}) \<subseteq> ([^]) x ` {0..<n}" using carrier_subgroup_generated_by_singleton [OF assms] by auto then show ?thesis using finite_surj by blast qed show "?fin \<longleftrightarrow> ?nat1" "\<not> ?fin \<longleftrightarrow> ?nateq" "?fin \<longleftrightarrow> ?int1" "\<not> ?fin \<longleftrightarrow> ?inteq" using 1 2 3 4 5 by meson+ qed lemma (in group) finite_cyclic_subgroup_order: "x \<in> carrier G \<Longrightarrow> finite(carrier(subgroup_generated G {x})) \<longleftrightarrow> ord x \<noteq> 0" by (simp add: finite_cyclic_subgroup ord_eq_0) lemma (in group) infinite_cyclic_subgroup_order: "x \<in> carrier G \<Longrightarrow> infinite (carrier(subgroup_generated G {x})) \<longleftrightarrow> ord x = 0" by (simp add: finite_cyclic_subgroup_order) lemma generate_pow_on_finite_carrier: \<^marker>\<open>contributor \<open>Paulo EmΓ­lio de Vilhena\<close>\<close> assumes "finite (carrier G)" and a: "a \<in> carrier G" shows "generate G { a } = { a [^] k | k. k \<in> (UNIV :: nat set) }" proof show "{ a [^] k | k. k \<in> (UNIV :: nat set) } \<subseteq> generate G { a }" proof fix b assume "b \<in> { a [^] k | k. k \<in> (UNIV :: nat set) }" then obtain k :: nat where "b = a [^] k" by blast hence "b = a [^] (int k)" by (simp add: int_pow_int) thus "b \<in> generate G { a }" unfolding generate_pow[OF a] by blast qed next show "generate G { a } \<subseteq> { a [^] k | k. k \<in> (UNIV :: nat set) }" proof fix b assume "b \<in> generate G { a }" then obtain k :: int where k: "b = a [^] k" unfolding generate_pow[OF a] by blast show "b \<in> { a [^] k | k. k \<in> (UNIV :: nat set) }" proof (cases "k < 0") assume "\<not> k < 0" hence "b = a [^] (nat k)" by (simp add: k) thus ?thesis by blast next assume "k < 0" hence b: "b = inv (a [^] (nat (- k)))" using k a by (auto simp: int_pow_neg) obtain m where m: "ord a * m \<ge> nat (- k)" by (metis assms mult.left_neutral mult_le_mono1 ord_ge_1) hence "a [^] (ord a * m) = \<one>" by (metis a nat_pow_one nat_pow_pow pow_ord_eq_1) then obtain k' :: nat where "(a [^] (nat (- k))) \<otimes> (a [^] k') = \<one>" using m a nat_le_iff_add nat_pow_mult by auto hence "b = a [^] k'" using b a by (metis inv_unique' nat_pow_closed nat_pow_comm) thus "b \<in> { a [^] k | k. k \<in> (UNIV :: nat set) }" by blast qed qed qed lemma ord_elems_inf_carrier: assumes "a \<in> carrier G" "ord a \<noteq> 0" shows "{a[^]x | x. x \<in> (UNIV :: nat set)} = {a[^]x | x. x \<in> {0 .. ord a - 1}}" (is "?L = ?R") proof show "?R \<subseteq> ?L" by blast { fix y assume "y \<in> ?L" then obtain x::nat where x: "y = a[^]x" by auto define r q where "r = x mod ord a" and "q = x div ord a" then have "x = q * ord a + r" by (simp add: div_mult_mod_eq) hence "y = (a[^]ord a)[^]q \<otimes> a[^]r" using x assms by (metis mult.commute nat_pow_mult nat_pow_pow) hence "y = a[^]r" using assms by simp have "r < ord a" using assms by (simp add: r_def) hence "r \<in> {0 .. ord a - 1}" by (force simp: r_def) hence "y \<in> {a[^]x | x. x \<in> {0 .. ord a - 1}}" using \<open>y=a[^]r\<close> by blast } thus "?L \<subseteq> ?R" by auto qed lemma generate_pow_nat: assumes a: "a \<in> carrier G" and "ord a \<noteq> 0" shows "generate G { a } = { a [^] k | k. k \<in> (UNIV :: nat set) }" proof show "{ a [^] k | k. k \<in> (UNIV :: nat set) } \<subseteq> generate G { a }" proof fix b assume "b \<in> { a [^] k | k. k \<in> (UNIV :: nat set) }" then obtain k :: nat where "b = a [^] k" by blast hence "b = a [^] (int k)" by (simp add: int_pow_int) thus "b \<in> generate G { a }" unfolding generate_pow[OF a] by blast qed next show "generate G { a } \<subseteq> { a [^] k | k. k \<in> (UNIV :: nat set) }" proof fix b assume "b \<in> generate G { a }" then obtain k :: int where k: "b = a [^] k" unfolding generate_pow[OF a] by blast show "b \<in> { a [^] k | k. k \<in> (UNIV :: nat set) }" proof (cases "k < 0") assume "\<not> k < 0" hence "b = a [^] (nat k)" by (simp add: k) thus ?thesis by blast next assume "k < 0" hence b: "b = inv (a [^] (nat (- k)))" using k a by (auto simp: int_pow_neg) obtain m where m: "ord a * m \<ge> nat (- k)" by (metis assms(2) dvd_imp_le dvd_triv_right le_zero_eq mult_eq_0_iff not_gr_zero) hence "a [^] (ord a * m) = \<one>" by (metis a nat_pow_one nat_pow_pow pow_ord_eq_1) then obtain k' :: nat where "(a [^] (nat (- k))) \<otimes> (a [^] k') = \<one>" using m a nat_le_iff_add nat_pow_mult by auto hence "b = a [^] k'" using b a by (metis inv_unique' nat_pow_closed nat_pow_comm) thus "b \<in> { a [^] k | k. k \<in> (UNIV :: nat set) }" by blast qed qed qed lemma generate_pow_card: assumes a: "a \<in> carrier G" shows "ord a = card (generate G { a })" proof (cases "ord a = 0") case True then have "infinite (carrier (subgroup_generated G {a}))" using infinite_cyclic_subgroup_order[OF a] by auto then have "infinite (generate G {a})" unfolding subgroup_generated_def using a by simp then show ?thesis using \<open>ord a = 0\<close> by auto next case False note finite_subgroup = this then have "generate G { a } = (([^]) a) ` {0..ord a - 1}" using generate_pow_nat ord_elems_inf_carrier a by auto hence "card (generate G {a}) = card {0..ord a - 1}" using ord_inj[OF a] card_image by metis also have "... = ord a" using finite_subgroup by auto finally show ?thesis.. qed lemma (in group) cyclic_order_is_ord: assumes "g \<in> carrier G" shows "ord g = order (subgroup_generated G {g})" unfolding order_def subgroup_generated_def using assms generate_pow_card by simp lemma ord_dvd_group_order: assumes "a \<in> carrier G" shows "(ord a) dvd (order G)" using lagrange[OF generate_is_subgroup[of "{a}"]] assms unfolding generate_pow_card[OF assms] by (metis dvd_triv_right empty_subsetI insert_subset) lemma (in group) pow_order_eq_1: assumes "a \<in> carrier G" shows "a [^] order G = \<one>" using assms by (metis nat_pow_pow ord_dvd_group_order pow_ord_eq_1 dvdE nat_pow_one) lemma dvd_gcd: fixes a b :: nat obtains q where "a * (b div gcd a b) = b*q" proof have "a * (b div gcd a b) = (a div gcd a b) * b" by (simp add: div_mult_swap dvd_div_mult) also have "\<dots> = b * (a div gcd a b)" by simp finally show "a * (b div gcd a b) = b * (a div gcd a b) " . qed lemma (in group) ord_le_group_order: assumes finite: "finite (carrier G)" and a: "a \<in> carrier G" shows "ord a \<le> order G" by (simp add: a dvd_imp_le local.finite ord_dvd_group_order order_gt_0_iff_finite) lemma (in group) ord_pow_gen: assumes "x \<in> carrier G" shows "ord (pow G x k) = (if k = 0 then 1 else ord x div gcd (ord x) k)" proof - have "ord (x [^] k) = ord x div gcd (ord x) k" if "0 < k" proof - have "(d dvd k * n) = (d div gcd (d) k dvd n)" for d n using that by (simp add: div_dvd_iff_mult gcd_mult_distrib_nat mult.commute) then show ?thesis using that by (auto simp add: assms ord_unique nat_pow_pow pow_eq_id) qed then show ?thesis by auto qed lemma (in group) assumes finite': "finite (carrier G)" "a \<in> carrier G" shows pow_ord_eq_ord_iff: "group.ord G (a [^] k) = ord a \<longleftrightarrow> coprime k (ord a)" (is "?L \<longleftrightarrow> ?R") using assms ord_ge_1 [OF assms] by (auto simp: div_eq_dividend_iff ord_pow_gen coprime_iff_gcd_eq_1 gcd.commute split: if_split_asm) lemma element_generates_subgroup: assumes finite[simp]: "finite (carrier G)" assumes a[simp]: "a \<in> carrier G" shows "subgroup {a [^] i | i. i \<in> {0 .. ord a - 1}} G" using generate_is_subgroup[of "{ a }"] assms(2) generate_pow_on_finite_carrier[OF assms] unfolding ord_elems[OF assms] by auto end section \<open>Number of Roots of a Polynomial\<close> text_raw \<open>\label{sec:number-roots}\<close> definition mult_of :: "('a, 'b) ring_scheme \<Rightarrow> 'a monoid" where "mult_of R \<equiv> \<lparr> carrier = carrier R - {\<zero>\<^bsub>R\<^esub>}, mult = mult R, one = \<one>\<^bsub>R\<^esub>\<rparr>" lemma carrier_mult_of [simp]: "carrier (mult_of R) = carrier R - {\<zero>\<^bsub>R\<^esub>}" by (simp add: mult_of_def) lemma mult_mult_of [simp]: "mult (mult_of R) = mult R" by (simp add: mult_of_def) lemma nat_pow_mult_of: "([^]\<^bsub>mult_of R\<^esub>) = (([^]\<^bsub>R\<^esub>) :: _ \<Rightarrow> nat \<Rightarrow> _)" by (simp add: mult_of_def fun_eq_iff nat_pow_def) lemma one_mult_of [simp]: "\<one>\<^bsub>mult_of R\<^esub> = \<one>\<^bsub>R\<^esub>" by (simp add: mult_of_def) lemmas mult_of_simps = carrier_mult_of mult_mult_of nat_pow_mult_of one_mult_of context field begin lemma mult_of_is_Units: "mult_of R = units_of R" unfolding mult_of_def units_of_def using field_Units by auto lemma m_inv_mult_of: "\<And>x. x \<in> carrier (mult_of R) \<Longrightarrow> m_inv (mult_of R) x = m_inv R x" using mult_of_is_Units units_of_inv unfolding units_of_def by simp lemma (in field) field_mult_group: "group (mult_of R)" proof (rule groupI) show "\<exists>y\<in>carrier (mult_of R). y \<otimes>\<^bsub>mult_of R\<^esub> x = \<one>\<^bsub>mult_of R\<^esub>" if "x \<in> carrier (mult_of R)" for x using group.l_inv_ex mult_of_is_Units that units_group by fastforce qed (auto simp: m_assoc dest: integral) lemma finite_mult_of: "finite (carrier R) \<Longrightarrow> finite (carrier (mult_of R))" by simp lemma order_mult_of: "finite (carrier R) \<Longrightarrow> order (mult_of R) = order R - 1" unfolding order_def carrier_mult_of by (simp add: card.remove) end lemma (in monoid) Units_pow_closed : fixes d :: nat assumes "x \<in> Units G" shows "x [^] d \<in> Units G" by (metis assms group.is_monoid monoid.nat_pow_closed units_group units_of_carrier units_of_pow) lemma (in ring) r_right_minus_eq[simp]: assumes "a \<in> carrier R" "b \<in> carrier R" shows "a \<ominus> b = \<zero> \<longleftrightarrow> a = b" using assms by (metis a_minus_def add.inv_closed minus_equality r_neg) context UP_cring begin lemma is_UP_cring: "UP_cring R" by (unfold_locales) lemma is_UP_ring: shows "UP_ring R" by (unfold_locales) end context UP_domain begin lemma roots_bound: assumes f [simp]: "f \<in> carrier P" assumes f_not_zero: "f \<noteq> \<zero>\<^bsub>P\<^esub>" assumes finite: "finite (carrier R)" shows "finite {a \<in> carrier R . eval R R id a f = \<zero>} \<and> card {a \<in> carrier R . eval R R id a f = \<zero>} \<le> deg R f" using f f_not_zero proof (induction "deg R f" arbitrary: f) case 0 have "\<And>x. eval R R id x f \<noteq> \<zero>" proof - fix x have "(\<Oplus>i\<in>{..deg R f}. id (coeff P f i) \<otimes> x [^] i) \<noteq> \<zero>" using 0 lcoeff_nonzero_nonzero[where p = f] by simp thus "eval R R id x f \<noteq> \<zero>" using 0 unfolding eval_def P_def by simp qed then have *: "{a \<in> carrier R. eval R R (\<lambda>a. a) a f = \<zero>} = {}" by (auto simp: id_def) show ?case by (simp add: *) next case (Suc x) show ?case proof (cases "\<exists> a \<in> carrier R . eval R R id a f = \<zero>") case True then obtain a where a_carrier[simp]: "a \<in> carrier R" and a_root: "eval R R id a f = \<zero>" by blast have R_not_triv: "carrier R \<noteq> {\<zero>}" by (metis R.one_zeroI R.zero_not_one) obtain q where q: "(q \<in> carrier P)" and f: "f = (monom P \<one>\<^bsub>R\<^esub> 1 \<ominus>\<^bsub> P\<^esub> monom P a 0) \<otimes>\<^bsub>P\<^esub> q \<oplus>\<^bsub>P\<^esub> monom P (eval R R id a f) 0" using remainder_theorem[OF Suc.prems(1) a_carrier R_not_triv] by auto hence lin_fac: "f = (monom P \<one>\<^bsub>R\<^esub> 1 \<ominus>\<^bsub> P\<^esub> monom P a 0) \<otimes>\<^bsub>P\<^esub> q" using q by (simp add: a_root) have deg: "deg R (monom P \<one>\<^bsub>R\<^esub> 1 \<ominus>\<^bsub> P\<^esub> monom P a 0) = 1" using a_carrier by (simp add: deg_minus_eq) hence mon_not_zero: "(monom P \<one>\<^bsub>R\<^esub> 1 \<ominus>\<^bsub> P\<^esub> monom P a 0) \<noteq> \<zero>\<^bsub>P\<^esub>" by (fastforce simp del: r_right_minus_eq) have q_not_zero: "q \<noteq> \<zero>\<^bsub>P\<^esub>" using Suc by (auto simp add : lin_fac) hence "deg R q = x" using Suc deg deg_mult[OF mon_not_zero q_not_zero _ q] by (simp add : lin_fac) hence q_IH: "finite {a \<in> carrier R . eval R R id a q = \<zero>} \<and> card {a \<in> carrier R . eval R R id a q = \<zero>} \<le> x" using Suc q q_not_zero by blast have subs: "{a \<in> carrier R . eval R R id a f = \<zero>} \<subseteq> {a \<in> carrier R . eval R R id a q = \<zero>} \<union> {a}" (is "?L \<subseteq> ?R \<union> {a}") using a_carrier \<open>q \<in> _\<close> by (auto simp: evalRR_simps lin_fac R.integral_iff) have "{a \<in> carrier R . eval R R id a f = \<zero>} \<subseteq> insert a {a \<in> carrier R . eval R R id a q = \<zero>}" using subs by auto hence "card {a \<in> carrier R . eval R R id a f = \<zero>} \<le> card (insert a {a \<in> carrier R . eval R R id a q = \<zero>})" using q_IH by (blast intro: card_mono) also have "\<dots> \<le> deg R f" using q_IH \<open>Suc x = _\<close> by (simp add: card_insert_if) finally show ?thesis using q_IH \<open>Suc x = _\<close> using finite by force next case False hence "card {a \<in> carrier R. eval R R id a f = \<zero>} = 0" using finite by auto also have "\<dots> \<le> deg R f" by simp finally show ?thesis using finite by auto qed qed end lemma (in domain) num_roots_le_deg : fixes p d :: nat assumes finite: "finite (carrier R)" assumes d_neq_zero: "d \<noteq> 0" shows "card {x \<in> carrier R. x [^] d = \<one>} \<le> d" proof - let ?f = "monom (UP R) \<one>\<^bsub>R\<^esub> d \<ominus>\<^bsub> (UP R)\<^esub> monom (UP R) \<one>\<^bsub>R\<^esub> 0" have one_in_carrier: "\<one> \<in> carrier R" by simp interpret R: UP_domain R "UP R" by (unfold_locales) have "deg R ?f = d" using d_neq_zero by (simp add: R.deg_minus_eq) hence f_not_zero: "?f \<noteq> \<zero>\<^bsub>UP R\<^esub>" using d_neq_zero by (auto simp add : R.deg_nzero_nzero) have roots_bound: "finite {a \<in> carrier R . eval R R id a ?f = \<zero>} \<and> card {a \<in> carrier R . eval R R id a ?f = \<zero>} \<le> deg R ?f" using finite by (intro R.roots_bound[OF _ f_not_zero]) simp have subs: "{x \<in> carrier R. x [^] d = \<one>} \<subseteq> {a \<in> carrier R . eval R R id a ?f = \<zero>}" by (auto simp: R.evalRR_simps) then have "card {x \<in> carrier R. x [^] d = \<one>} \<le> card {a \<in> carrier R. eval R R id a ?f = \<zero>}" using finite by (simp add : card_mono) thus ?thesis using \<open>deg R ?f = d\<close> roots_bound by linarith qed section \<open>The Multiplicative Group of a Field\<close> text_raw \<open>\label{sec:mult-group}\<close> text \<open> In this section we show that the multiplicative group of a finite field is generated by a single element, i.e. it is cyclic. The proof is inspired by the first proof given in the survey~\<^cite>\<open>"conrad-cyclicity"\<close>. \<close> context field begin lemma num_elems_of_ord_eq_phi': assumes finite: "finite (carrier R)" and dvd: "d dvd order (mult_of R)" and exists: "\<exists>a\<in>carrier (mult_of R). group.ord (mult_of R) a = d" shows "card {a \<in> carrier (mult_of R). group.ord (mult_of R) a = d} = phi' d" proof - note mult_of_simps[simp] have finite': "finite (carrier (mult_of R))" using finite by (rule finite_mult_of) interpret G:group "mult_of R" rewrites "([^]\<^bsub>mult_of R\<^esub>) = (([^]) :: _ \<Rightarrow> nat \<Rightarrow> _)" and "\<one>\<^bsub>mult_of R\<^esub> = \<one>" by (rule field_mult_group) simp_all from exists obtain a where a: "a \<in> carrier (mult_of R)" and ord_a: "group.ord (mult_of R) a = d" by (auto simp add: card_gt_0_iff) have set_eq1: "{a[^]n| n. n \<in> {1 .. d}} = {x \<in> carrier (mult_of R). x [^] d = \<one>}" proof (rule card_seteq) show "finite {x \<in> carrier (mult_of R). x [^] d = \<one>}" using finite by auto show "{a[^]n| n. n \<in> {1 ..d}} \<subseteq> {x \<in> carrier (mult_of R). x[^]d = \<one>}" proof fix x assume "x \<in> {a[^]n | n. n \<in> {1 .. d}}" then obtain n where n: "x = a[^]n \<and> n \<in> {1 .. d}" by auto have "x[^]d =(a[^]d)[^]n" using n a ord_a by (simp add:nat_pow_pow mult.commute) hence "x[^]d = \<one>" using ord_a G.pow_ord_eq_1[OF a] by fastforce thus "x \<in> {x \<in> carrier (mult_of R). x[^]d = \<one>}" using G.nat_pow_closed[OF a] n by blast qed show "card {x \<in> carrier (mult_of R). x [^] d = \<one>} \<le> card {a[^]n | n. n \<in> {1 .. d}}" proof - have *: "{a[^]n | n. n \<in> {1 .. d }} = ((\<lambda> n. a[^]n) ` {1 .. d})" by auto have "0 < order (mult_of R)" unfolding order_mult_of[OF finite] using card_mono[OF finite, of "{\<zero>, \<one>}"] by (simp add: order_def) have "card {x \<in> carrier (mult_of R). x [^] d = \<one>} \<le> card {x \<in> carrier R. x [^] d = \<one>}" using finite by (auto intro: card_mono) also have "\<dots> \<le> d" using \<open>0 < order (mult_of R)\<close> num_roots_le_deg[OF finite, of d] by (simp add : dvd_pos_nat[OF _ \<open>d dvd order (mult_of R)\<close>]) finally show ?thesis using G.ord_inj'[OF a] ord_a * by (simp add: card_image) qed qed have set_eq2: "{x \<in> carrier (mult_of R) . group.ord (mult_of R) x = d} = (\<lambda> n . a[^]n) ` {n \<in> {1 .. d}. group.ord (mult_of R) (a[^]n) = d}" (is "?L = ?R") proof { fix x assume x: "x \<in> (carrier (mult_of R)) \<and> group.ord (mult_of R) x = d" hence "x \<in> {x \<in> carrier (mult_of R). x [^] d = \<one>}" by (simp add: G.pow_ord_eq_1[of x, symmetric]) then obtain n where n: "x = a[^]n \<and> n \<in> {1 .. d}" using set_eq1 by blast hence "x \<in> ?R" using x by fast } thus "?L \<subseteq> ?R" by blast show "?R \<subseteq> ?L" using a by (auto simp add: carrier_mult_of[symmetric] simp del: carrier_mult_of) qed have "inj_on (\<lambda> n . a[^]n) {n \<in> {1 .. d}. group.ord (mult_of R) (a[^]n) = d}" using G.ord_inj'[OF a, unfolded ord_a] unfolding inj_on_def by fast hence "card ((\<lambda>n. a[^]n) ` {n \<in> {1 .. d}. group.ord (mult_of R) (a[^]n) = d}) = card {k \<in> {1 .. d}. group.ord (mult_of R) (a[^]k) = d}" using card_image by blast thus ?thesis using set_eq2 G.pow_ord_eq_ord_iff[OF finite' \<open>a \<in> _\<close>, unfolded ord_a] by (simp add: phi'_def) qed end theorem (in field) finite_field_mult_group_has_gen : assumes finite: "finite (carrier R)" shows "\<exists> a \<in> carrier (mult_of R) . carrier (mult_of R) = {a[^]i | i::nat . i \<in> UNIV}" proof - note mult_of_simps[simp] have finite': "finite (carrier (mult_of R))" using finite by (rule finite_mult_of) interpret G: group "mult_of R" rewrites "([^]\<^bsub>mult_of R\<^esub>) = (([^]) :: _ \<Rightarrow> nat \<Rightarrow> _)" and "\<one>\<^bsub>mult_of R\<^esub> = \<one>" by (rule field_mult_group) (simp_all add: fun_eq_iff nat_pow_def) let ?N = "\<lambda> x . card {a \<in> carrier (mult_of R). group.ord (mult_of R) a = x}" have "0 < order R - 1" unfolding order_def using card_mono[OF finite, of "{\<zero>, \<one>}"] by simp then have *: "0 < order (mult_of R)" using assms by (simp add: order_mult_of) have fin: "finite {d. d dvd order (mult_of R) }" using dvd_nat_bounds[OF *] by force have "(\<Sum>d | d dvd order (mult_of R). ?N d) = card (UN d:{d . d dvd order (mult_of R) }. {a \<in> carrier (mult_of R). group.ord (mult_of R) a = d})" (is "_ = card ?U") using fin finite by (subst card_UN_disjoint) auto also have "?U = carrier (mult_of R)" proof { fix x assume x: "x \<in> carrier (mult_of R)" hence x': "x\<in>carrier (mult_of R)" by simp then have "group.ord (mult_of R) x dvd order (mult_of R)" using G.ord_dvd_group_order by blast hence "x \<in> ?U" using dvd_nat_bounds[of "order (mult_of R)" "group.ord (mult_of R) x"] x by blast } thus "carrier (mult_of R) \<subseteq> ?U" by blast qed auto also have "card ... = order (mult_of R)" using order_mult_of finite' by (simp add: order_def) finally have sum_Ns_eq: "(\<Sum>d | d dvd order (mult_of R). ?N d) = order (mult_of R)" . { fix d assume d: "d dvd order (mult_of R)" have "card {a \<in> carrier (mult_of R). group.ord (mult_of R) a = d} \<le> phi' d" proof cases assume "card {a \<in> carrier (mult_of R). group.ord (mult_of R) a = d} = 0" thus ?thesis by presburger next assume "card {a \<in> carrier (mult_of R). group.ord (mult_of R) a = d} \<noteq> 0" hence "\<exists>a \<in> carrier (mult_of R). group.ord (mult_of R) a = d" by (auto simp: card_eq_0_iff) thus ?thesis using num_elems_of_ord_eq_phi'[OF finite d] by auto qed } hence all_le: "\<And>i. i \<in> {d. d dvd order (mult_of R) } \<Longrightarrow> (\<lambda>i. card {a \<in> carrier (mult_of R). group.ord (mult_of R) a = i}) i \<le> (\<lambda>i. phi' i) i" by fast hence le: "(\<Sum>i | i dvd order (mult_of R). ?N i) \<le> (\<Sum>i | i dvd order (mult_of R). phi' i)" using sum_mono[of "{d . d dvd order (mult_of R)}" "\<lambda>i. card {a \<in> carrier (mult_of R). group.ord (mult_of R) a = i}"] by presburger have "order (mult_of R) = (\<Sum>d | d dvd order (mult_of R). phi' d)" using * by (simp add: sum_phi'_factors) hence eq: "(\<Sum>i | i dvd order (mult_of R). ?N i) = (\<Sum>i | i dvd order (mult_of R). phi' i)" using le sum_Ns_eq by presburger have "\<And>i. i \<in> {d. d dvd order (mult_of R) } \<Longrightarrow> ?N i = (\<lambda>i. phi' i) i" proof (rule ccontr) fix i assume i1: "i \<in> {d. d dvd order (mult_of R)}" and "?N i \<noteq> phi' i" hence "?N i = 0" using num_elems_of_ord_eq_phi'[OF finite, of i] by (auto simp: card_eq_0_iff) moreover have "0 < i" using * i1 by (simp add: dvd_nat_bounds[of "order (mult_of R)" i]) ultimately have "?N i < phi' i" using phi'_nonzero by presburger hence "(\<Sum>i | i dvd order (mult_of R). ?N i) < (\<Sum>i | i dvd order (mult_of R). phi' i)" using sum_strict_mono_ex1[OF fin, of "?N" "\<lambda> i . phi' i"] i1 all_le by auto thus False using eq by force qed hence "?N (order (mult_of R)) > 0" using * by (simp add: phi'_nonzero) then obtain a where a: "a \<in> carrier (mult_of R)" and a_ord: "group.ord (mult_of R) a = order (mult_of R)" by (auto simp add: card_gt_0_iff) hence set_eq: "{a[^]i | i::nat. i \<in> UNIV} = (\<lambda>x. a[^]x) ` {0 .. group.ord (mult_of R) a - 1}" using G.ord_elems[OF finite'] by auto have card_eq: "card ((\<lambda>x. a[^]x) ` {0 .. group.ord (mult_of R) a - 1}) = card {0 .. group.ord (mult_of R) a - 1}" by (intro card_image G.ord_inj finite' a) hence "card ((\<lambda> x . a[^]x) ` {0 .. group.ord (mult_of R) a - 1}) = card {0 ..order (mult_of R) - 1}" using assms by (simp add: card_eq a_ord) hence card_R_minus_1: "card {a[^]i | i::nat. i \<in> UNIV} = order (mult_of R)" using * by (subst set_eq) auto have **: "{a[^]i | i::nat. i \<in> UNIV} \<subseteq> carrier (mult_of R)" using G.nat_pow_closed[OF a] by auto with _ have "carrier (mult_of R) = {a[^]i|i::nat. i \<in> UNIV}" by (rule card_seteq[symmetric]) (simp_all add: card_R_minus_1 finite order_def del: UNIV_I) thus ?thesis using a by blast qed end
# int foo(void) { # int n = 1; # int i; # for (i=1; i<10; i++) # n = n * i; # } func $foo (var %i i32) i32 { while ( lt i32 i32 ( dread i32 %i, constval i32 10) ) { dassign %i ( mul i32 (dread i32 %i, dread i32 %i)) dassign %i ( add i32 (dread i32 %i, constval i32 1) )} return ( constval i32 1 ) } # EXEC: %irbuild Main.mpl # EXEC: %irbuild Main.irb.mpl # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl
lemma homeomorphic_to_disc_imp_simply_connected: assumes "S = {} \<or> S homeomorphic ball (0::complex) 1" shows "simply_connected S"
[STATEMENT] lemma N1_leadsto_b: "\<turnstile> \<box>($PsiInv \<and> [(N1 \<or> N2) \<and> \<not>beta1]_(x,y,sem,pc1,pc2)) \<and> SF(N1)_(x,y,sem,pc1,pc2) \<and> \<box> SF(N2)_(x,y,sem,pc1,pc2) \<longrightarrow> (pc1 = #b \<or> pc1 = #g \<or> pc1 = #a \<leadsto> pc1 = #b)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<turnstile> \<box>($PsiInv \<and> [(N1 \<or> N2) \<and> \<not> beta1]_(x, y, sem, pc1, pc2)) \<and> SF(N1)_(x, y, sem, pc1, pc2) \<and> \<box>SF(N2)_(x, y, sem, pc1, pc2) \<longrightarrow> (pc1 = #b \<or> pc1 = #g \<or> pc1 = #a \<leadsto> pc1 = #b) [PROOF STEP] apply (auto intro!: LatticeDisjunctionIntro [temp_use]) [PROOF STATE] proof (prove) goal (3 subgoals): 1. \<And>sigma. \<lbrakk>sigma \<Turnstile> \<box>($PsiInv \<and> [(N1 \<or> N2) \<and> \<not> beta1]_(x, y, sem, pc1, pc2)); sigma \<Turnstile> SF(N1)_(x, y, sem, pc1, pc2); sigma \<Turnstile> \<box>SF(N2)_(x, y, sem, pc1, pc2)\<rbrakk> \<Longrightarrow> sigma \<Turnstile> pc1 = #b \<leadsto> pc1 = #b 2. \<And>sigma. \<lbrakk>sigma \<Turnstile> \<box>($PsiInv \<and> [(N1 \<or> N2) \<and> \<not> beta1]_(x, y, sem, pc1, pc2)); sigma \<Turnstile> SF(N1)_(x, y, sem, pc1, pc2); sigma \<Turnstile> \<box>SF(N2)_(x, y, sem, pc1, pc2)\<rbrakk> \<Longrightarrow> sigma \<Turnstile> pc1 = #g \<leadsto> pc1 = #b 3. \<And>sigma. \<lbrakk>sigma \<Turnstile> \<box>($PsiInv \<and> [(N1 \<or> N2) \<and> \<not> beta1]_(x, y, sem, pc1, pc2)); sigma \<Turnstile> SF(N1)_(x, y, sem, pc1, pc2); sigma \<Turnstile> \<box>SF(N2)_(x, y, sem, pc1, pc2)\<rbrakk> \<Longrightarrow> sigma \<Turnstile> pc1 = #a \<leadsto> pc1 = #b [PROOF STEP] apply (rule LatticeReflexivity [temp_use]) [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<And>sigma. \<lbrakk>sigma \<Turnstile> \<box>($PsiInv \<and> [(N1 \<or> N2) \<and> \<not> beta1]_(x, y, sem, pc1, pc2)); sigma \<Turnstile> SF(N1)_(x, y, sem, pc1, pc2); sigma \<Turnstile> \<box>SF(N2)_(x, y, sem, pc1, pc2)\<rbrakk> \<Longrightarrow> sigma \<Turnstile> pc1 = #g \<leadsto> pc1 = #b 2. \<And>sigma. \<lbrakk>sigma \<Turnstile> \<box>($PsiInv \<and> [(N1 \<or> N2) \<and> \<not> beta1]_(x, y, sem, pc1, pc2)); sigma \<Turnstile> SF(N1)_(x, y, sem, pc1, pc2); sigma \<Turnstile> \<box>SF(N2)_(x, y, sem, pc1, pc2)\<rbrakk> \<Longrightarrow> sigma \<Turnstile> pc1 = #a \<leadsto> pc1 = #b [PROOF STEP] apply (rule LatticeTransitivity [temp_use]) [PROOF STATE] proof (prove) goal (3 subgoals): 1. \<And>sigma. \<lbrakk>sigma \<Turnstile> \<box>($PsiInv \<and> [(N1 \<or> N2) \<and> \<not> beta1]_(x, y, sem, pc1, pc2)); sigma \<Turnstile> SF(N1)_(x, y, sem, pc1, pc2); sigma \<Turnstile> \<box>SF(N2)_(x, y, sem, pc1, pc2)\<rbrakk> \<Longrightarrow> sigma \<Turnstile> ?G9 sigma \<leadsto> pc1 = #b 2. \<And>sigma. \<lbrakk>sigma \<Turnstile> \<box>($PsiInv \<and> [(N1 \<or> N2) \<and> \<not> beta1]_(x, y, sem, pc1, pc2)); sigma \<Turnstile> SF(N1)_(x, y, sem, pc1, pc2); sigma \<Turnstile> \<box>SF(N2)_(x, y, sem, pc1, pc2)\<rbrakk> \<Longrightarrow> sigma \<Turnstile> pc1 = #g \<leadsto> ?G9 sigma 3. \<And>sigma. \<lbrakk>sigma \<Turnstile> \<box>($PsiInv \<and> [(N1 \<or> N2) \<and> \<not> beta1]_(x, y, sem, pc1, pc2)); sigma \<Turnstile> SF(N1)_(x, y, sem, pc1, pc2); sigma \<Turnstile> \<box>SF(N2)_(x, y, sem, pc1, pc2)\<rbrakk> \<Longrightarrow> sigma \<Turnstile> pc1 = #a \<leadsto> pc1 = #b [PROOF STEP] apply (auto intro!: a1_leadsto_b1 [temp_use] g1_leadsto_a1 [temp_use] simp: split_box_conj) [PROOF STATE] proof (prove) goal: No subgoals! [PROOF STEP] done
[STATEMENT] lemma comp_MkArr [simp]: assumes "arr (MkArr A B F)" and "arr (MkArr B C G)" shows "COMP (MkArr B C G) (MkArr A B F) = MkArr A C (Comp C B A G F)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. COMP (MkArr B C G) (MkArr A B F) = MkArr A C (Comp C B A G F) [PROOF STEP] using assms comp_char [of "MkArr B C G" "MkArr A B F"] [PROOF STATE] proof (prove) using this: arr (MkArr A B F) arr (MkArr B C G) COMP (MkArr B C G) (MkArr A B F) = (if seq (MkArr B C G) (MkArr A B F) then MkArr (Dom (MkArr A B F)) (Cod (MkArr B C G)) (Comp (Cod (MkArr B C G)) (Dom (MkArr B C G)) (Dom (MkArr A B F)) (Map (MkArr B C G)) (Map (MkArr A B F))) else null) goal (1 subgoal): 1. COMP (MkArr B C G) (MkArr A B F) = MkArr A C (Comp C B A G F) [PROOF STEP] by simp
(** This is Keccak-256 and SHA3-256 ported from Go's golang.org/x/crypto/sha3 *) From Coq Require Import List. From Coq Require HexString. From Coq Require Import String. From Coq Require Import NArith ZArith Lia. From Vyper Require UInt64 Tuplevector. From Vyper Require Import Nibble. Local Open Scope string_scope. Local Definition rc_hex: list string := "0x0000000000000001" :: "0x0000000000008082" :: "0x800000000000808A" :: "0x8000000080008000" :: "0x000000000000808B" :: "0x0000000080000001" :: "0x8000000080008081" :: "0x8000000000008009" :: "0x000000000000008A" :: "0x0000000000000088" :: "0x0000000080008009" :: "0x000000008000000A" :: "0x000000008000808B" :: "0x800000000000008B" :: "0x8000000000008089" :: "0x8000000000008003" :: "0x8000000000008002" :: "0x8000000000000080" :: "0x000000000000800A" :: "0x800000008000000A" :: "0x8000000080008081" :: "0x8000000000008080" :: "0x0000000080000001" :: "0x8000000080008008" :: nil. Local Definition rc := map UInt64.uint64_of_Z_mod (map HexString.to_Z rc_hex). Local Lemma rc_ok: map UInt64.Z_of_uint64 rc = map HexString.to_Z rc_hex. Proof. trivial. Qed. Local Definition rc_quads_backwards := Tuplevector.gather rc 6 4 eq_refl. Inductive vec25 (T: Type) := Vec25 (a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24: T). Arguments Vec25 {_}. Definition vec25_fill {T: Type} (x: T) := Vec25 x x x x x x x x x x x x x x x x x x x x x x x x x. Local Definition uint64 := UInt64.uint64. Definition vec25_zeros := vec25_fill (UInt64.uint64_0). Section Permutation. Local Notation "x ^ y" := (UInt64.bitwise_xor x y). Local Definition vec25_xor_tuple17_backwards (a: vec25 uint64) (b: Tuplevector.t uint64 17) := match a with | Vec25 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 => match b with | (b16, b15, b14, b13, b12, b11, b10, b9, b8, b7, b6, b5, b4, b3, b2, b1, b0) => Vec25 ( a0 ^ b0) (a1 ^ b1) (a2 ^ b2) (a3 ^ b3) (a4 ^ b4) ( a5 ^ b5) (a6 ^ b6) (a7 ^ b7) (a8 ^ b8) (a9 ^ b9) (a10 ^ b10) (a11 ^ b11) (a12 ^ b12) (a13 ^ b13) (a14 ^ b14) (a15 ^ b15) (a16 ^ b16) a17 a18 a19 a20 a21 a22 a23 a24 end end. Local Notation "x << y" := (UInt64.shl x y) (at level 30, no associativity). Local Notation "x >> y" := (UInt64.shr x y) (at level 30, no associativity). Local Notation "x | y" := (UInt64.bitwise_or x y) (at level 30). (* dangerous! messes up match! *) Local Notation "x & y" := (UInt64.bitwise_and x y) (at level 30). Local Notation "~ x" := (UInt64.bitwise_not x). (* here a - b = a + ~b + 1 *) Local Definition rot x k := ((x << k) | (x >> (UInt64.add (UInt64.uint64_of_Z_mod 65) (UInt64.bitwise_not k)))). Local Definition round (rc: uint64) (a: vec25 uint64) (b: vec25 uint64) : vec25 uint64 := match a, b with | Vec25 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24, Vec25 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 b18 b19 b20 b21 b22 b23 b24 => let bc0 := a0 ^ a5 ^ a10 ^ a15 ^ a20 in let bc1 := a1 ^ a6 ^ a11 ^ a16 ^ a21 in let bc2 := a2 ^ a7 ^ a12 ^ a17 ^ a22 in let bc3 := a3 ^ a8 ^ a13 ^ a18 ^ a23 in let bc4 := a4 ^ a9 ^ a14 ^ a19 ^ a24 in let d0 := bc4 ^ rot bc1 UInt64.uint64_1 in let d1 := bc0 ^ rot bc2 UInt64.uint64_1 in let d2 := bc1 ^ rot bc3 UInt64.uint64_1 in let d3 := bc2 ^ rot bc4 UInt64.uint64_1 in let d4 := bc3 ^ rot bc0 UInt64.uint64_1 in let p0 := b0 ^ d0 in let p1 := rot (b1 ^ d1) (UInt64.uint64_of_Z_mod 44) in let p2 := rot (b2 ^ d2) (UInt64.uint64_of_Z_mod 43) in let p3 := rot (b3 ^ d3) (UInt64.uint64_of_Z_mod 21) in let p4 := rot (b4 ^ d4) (UInt64.uint64_of_Z_mod 14) in let z0 := p0 ^ (p2 & ~ p1) ^ rc in let z1 := p1 ^ (p3 & ~ p2) in let z2 := p2 ^ (p4 & ~ p3) in let z3 := p3 ^ (p0 & ~ p4) in let z4 := p4 ^ (p1 & ~ p0) in let q2 := rot (b5 ^ d0) (UInt64.uint64_of_Z_mod 3) in let q3 := rot (b6 ^ d1) (UInt64.uint64_of_Z_mod 45) in let q4 := rot (b7 ^ d2) (UInt64.uint64_of_Z_mod 61) in let q0 := rot (b8 ^ d3) (UInt64.uint64_of_Z_mod 28) in let q1 := rot (b9 ^ d4) (UInt64.uint64_of_Z_mod 20) in let z5 := q0 ^ (q2 & ~ q1) in let z6 := q1 ^ (q3 & ~ q2) in let z7 := q2 ^ (q4 & ~ q3) in let z8 := q3 ^ (q0 & ~ q4) in let z9 := q4 ^ (q1 & ~ q0) in let r4 := rot (b10 ^ d0) (UInt64.uint64_of_Z_mod 18) in let r0 := rot (b11 ^ d1) UInt64.uint64_1 in let r1 := rot (b12 ^ d2) (UInt64.uint64_of_Z_mod 6) in let r2 := rot (b13 ^ d3) (UInt64.uint64_of_Z_mod 25) in let r3 := rot (b14 ^ d4) UInt64.uint64_8 in let z10 := r0 ^ (r2 & ~ r1) in let z11 := r1 ^ (r3 & ~ r2) in let z12 := r2 ^ (r4 & ~ r3) in let z13 := r3 ^ (r0 & ~ r4) in let z14 := r4 ^ (r1 & ~ r0) in let s1 := rot (b15 ^ d0) (UInt64.uint64_of_Z_mod 36) in let s2 := rot (b16 ^ d1) (UInt64.uint64_of_Z_mod 10) in let s3 := rot (b17 ^ d2) (UInt64.uint64_of_Z_mod 15) in let s4 := rot (b18 ^ d3) UInt64.uint64_56 in let s0 := rot (b19 ^ d4) (UInt64.uint64_of_Z_mod 27) in let z15 := s0 ^ (s2 & ~ s1) in let z16 := s1 ^ (s3 & ~ s2) in let z17 := s2 ^ (s4 & ~ s3) in let z18 := s3 ^ (s0 & ~ s4) in let z19 := s4 ^ (s1 & ~ s0) in let t3 := rot (b20 ^ d0) (UInt64.uint64_of_Z_mod 41) in let t4 := rot (b21 ^ d1) UInt64.uint64_2 in let t0 := rot (b22 ^ d2) (UInt64.uint64_of_Z_mod 62) in let t1 := rot (b23 ^ d3) (UInt64.uint64_of_Z_mod 55) in let t2 := rot (b24 ^ d4) (UInt64.uint64_of_Z_mod 39) in let z20 := t0 ^ (t2 & ~ t1) in let z21 := t1 ^ (t3 & ~ t2) in let z22 := t2 ^ (t4 & ~ t3) in let z23 := t3 ^ (t0 & ~ t4) in let z24 := t4 ^ (t1 & ~ t0) in Vec25 z0 z1 z2 z3 z4 z5 z6 z7 z8 z9 z10 z11 z12 z13 z14 z15 z16 z17 z18 z19 z20 z21 z22 z23 z24 end. Local Definition permute1 {T} (a: vec25 T) := match a with | Vec25 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 => Vec25 a0 a11 a22 a8 a19 a15 a1 a12 a23 a9 a5 a16 a2 a13 a24 a20 a6 a17 a3 a14 a10 a21 a7 a18 a4 end. Local Definition permute2 {T} (a: vec25 T) := match a with | Vec25 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 => Vec25 a0 a16 a7 a23 a14 a20 a11 a2 a18 a9 a15 a6 a22 a13 a4 a10 a1 a17 a8 a24 a5 a21 a12 a3 a19 end. Local Definition permute3 {T} (a: vec25 T) := match a with | Vec25 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 => Vec25 a0 a6 a12 a18 a24 a10 a16 a22 a3 a9 a20 a1 a7 a13 a19 a5 a11 a17 a23 a4 a15 a21 a2 a8 a14 end. Local Lemma permute1_of_permute3 {T} (a: vec25 T): permute1 (permute3 a) = a. Proof. now destruct a. Qed. Local Lemma permute3_of_permute1 {T} (a: vec25 T): permute3 (permute1 a) = a. Proof. now destruct a. Qed. Local Lemma permute2_of_permute2 {T} (a: vec25 T): permute2 (permute2 a) = a. Proof. now destruct a. Qed. Local Definition quad_round (a: vec25 uint64) (rcs: Tuplevector.t uint64 4) : vec25 uint64 := match rcs with | (rc4, rc3, rc2, rc1) => let a1 := permute1 (round rc1 a (permute3 a)) in let a2 := permute2 (round rc2 a1 (permute2 a1)) in let a3 := permute3 (round rc3 a2 (permute1 a2)) in round rc4 a3 a3 end. Local Definition F1600 := fold_left quad_round rc_quads_backwards. End Permutation. (* Create padding of the given length (of the padding, not of the data). *) Local Definition padding (len: positive) (start: uint64) (* start is 1 for Ethereum's Keccak, otherwise 6 *) : list byte := match len with | 1%positive => UInt64.byte_of_uint64 (UInt64.bitwise_or UInt64.uint64_128 start) :: nil | _ => (UInt64.byte_of_uint64 start) :: repeat (UInt64.byte_of_uint64 UInt64.uint64_0) (N.to_nat (N.pos len - 2)) ++ UInt64.byte_of_uint64 UInt64.uint64_128 :: nil end. (* The padding has the requested length *) Local Lemma padding_ok (len: positive) (start: uint64): List.length (padding len start) = Pos.to_nat len. Proof. unfold padding. remember (UInt64.byte_of_uint64 start :: repeat (UInt64.byte_of_uint64 UInt64.uint64_0) (N.to_nat (N.pos len - 2)) ++ UInt64.byte_of_uint64 UInt64.uint64_128 :: nil) as l. assert (cons_length: forall {T} h (t: list T), List.length (h :: t) = S (List.length t)) by easy. destruct len; cbn; subst; repeat (rewrite List.app_length || rewrite List.repeat_length || rewrite cons_length); replace (List.length (@nil byte)) with 0 by trivial; lia. Qed. (** Calculate the padding length given the data length. *) Definition padding_length (data_length: N) (rate: positive) : positive := match (data_length mod N.pos rate)%N with | 0%N => rate | Npos p => rate - p end. Local Lemma padding_length_ok (data_length: N) (rate: positive): ((data_length + N.pos (padding_length data_length rate)) mod N.pos rate = 0)%N. Proof. unfold padding_length. remember (data_length mod N.pos rate)%N as m. destruct m; rewrite N.add_mod by discriminate; rewrite<- Heqm. { rewrite N.add_0_l. rewrite N.mod_same by discriminate. apply N.mod_0_l. discriminate. } assert(L: (N.pos p < N.pos rate)%N). { rewrite Heqm. apply N.mod_upper_bound. discriminate. } replace (N.pos (rate - p) mod N.pos rate)%N with (N.pos (rate - p)). 2:{ symmetry. apply N.mod_small. lia. } replace (N.pos p + N.pos (rate - p))%N with (N.pos rate) by lia. apply N.mod_same. discriminate. Qed. Local Definition pad (unpadded_data: list byte) (rate: positive) (start: uint64) : list byte := (unpadded_data ++ padding (padding_length (N.of_nat (List.length unpadded_data)) rate) start)%list. Local Lemma pad_ok_mod (data: list byte) (rate: positive) (start: uint64): (N.of_nat (List.length (pad data rate start)) mod N.pos rate = 0)%N. Proof. unfold pad. rewrite List.app_length. rewrite Nat2N.inj_add. remember (List.length data) as n. rewrite padding_ok. rewrite positive_nat_N. rewrite padding_length_ok. trivial. Qed. Local Lemma pad_ok (data: list byte) (rate: positive) (start: uint64): let d := List.length (pad data rate start) / Pos.to_nat rate in List.length (pad data rate start) = d * Pos.to_nat rate. Proof. apply Nat2N.inj. assert (M := pad_ok_mod data rate start). remember (List.length _) as len. clear Heqlen. match goal with |- ?lhs = ?rhs => rewrite<- (N.add_0_r rhs) end. rewrite<- M. rewrite Nat.mul_comm. rewrite Nat2N.inj_mul. rewrite Arith2.Nat2N_inj_div. remember (Pos.to_nat rate) as r. assert (R: N.pos rate = N.of_nat r). { subst. symmetry. apply positive_nat_N. } rewrite R. rewrite R in M. apply N.div_mod. subst. assert(P := Pos2Nat.is_pos rate). destruct (Pos.to_nat rate). { now apply Nat.lt_irrefl in P. } discriminate. Qed. Local Lemma can_gather_by_8 (n: nat): n = n / 136 * 136 -> n = (n / 136 * 17) * 8. Proof. now rewrite<- Nat.mul_assoc. Qed. Local Definition pad_by_136_and_gather_into_uint64s (data: list byte) (padding_start: uint64) := let padded := pad data 136%positive padding_start in let PadOk := pad_ok data 136%positive padding_start in List.map UInt64.uint64_of_be_bytes (Tuplevector.gather padded _ 8 (can_gather_by_8 _ PadOk)). Local Lemma pad_by_136_and_gather_into_uint64s_length (data: list byte) (s: uint64): List.length (pad_by_136_and_gather_into_uint64s data s) = (List.length (pad data 136 s)) / 136 * 17. Proof. unfold pad_by_136_and_gather_into_uint64s. rewrite List.map_length. apply (Tuplevector.gather_length (pad data 136 s) (Datatypes.length (pad data 136 s) / 136 * 17) 8 (can_gather_by_8 (Datatypes.length (pad data 136 s)) (pad_ok data 136 s))). Qed. Local Definition blocks (data: list byte) (padding_start: uint64) := Tuplevector.gather (pad_by_136_and_gather_into_uint64s data padding_start) _ 17 (pad_by_136_and_gather_into_uint64s_length data padding_start). Local Definition absorb (data: list byte) (padding_start: uint64) := fold_left (fun state block => F1600 (vec25_xor_tuple17_backwards state block)) (blocks data padding_start) vec25_zeros. Local Definition squeeze_256 (a: vec25 uint64) := match a with | Vec25 a0 a1 a2 a3 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ => let eights: list (Tuplevector.t byte 8) := map UInt64.uint64_to_le_bytes (a0 :: a1 :: a2 :: a3 :: nil) in fold_right Tuplevector.app_to_list nil eights end. Local Lemma squeeze_256_length a: List.length (squeeze_256 a) = 32. Proof. now destruct a. Qed. Definition keccak_256 (data: list byte): list byte := squeeze_256 (absorb data UInt64.uint64_1). Definition sha3_256 (data: list byte): list byte := squeeze_256 (absorb data (UInt64.uint64_of_Z_mod 6)). Lemma keccak_256_length (data: list byte): List.length (keccak_256 data) = 32. Proof. unfold keccak_256. apply squeeze_256_length. Qed. Lemma sha3_256_length (data: list byte): List.length (sha3_256 data) = 32. Proof. unfold sha3_256. apply squeeze_256_length. Qed. Definition keccak_256_of_string (s: String.string) := keccak_256 (bytes_of_string s). Definition sha3_256_of_string (s: String.string) := sha3_256 (bytes_of_string s). Lemma keccak_256_of_string_length (s: String.string): List.length (keccak_256_of_string s) = 32. Proof. unfold keccak_256_of_string. apply keccak_256_length. Qed. Lemma sha3_256_of_string_length (s: String.string): List.length (sha3_256_of_string s) = 32. Proof. unfold sha3_256_of_string. apply sha3_256_length. Qed. Local Fixpoint N_of_bytes_rec (start: N) (bytes: list byte) := match bytes with | nil => start | (h :: t)%list => N_of_bytes_rec (N.shiftl start 8 + N_of_byte h) t end. Definition N_of_bytes := N_of_bytes_rec 0. Definition keccak_256_N (data: list byte): N := N_of_bytes (keccak_256 data). Definition keccak_256_N_of_string (s: String.string): N := N_of_bytes (keccak_256_of_string s). Definition keccak_256_hex (data: list byte) : String.string := hex_of_bytes (keccak_256 data) true. Definition sha3_256_hex (data: list byte) : String.string := hex_of_bytes (sha3_256 data) true. Definition keccak_256_hex_of_string (s: String.string) : String.string := hex_of_bytes (keccak_256_of_string s) true. Definition sha3_256_hex_of_string (s: String.string) : String.string := hex_of_bytes (sha3_256_of_string s) true. (* This test is from Go's sha3_test.go. *) Local Example keccak_256_smoke_test: keccak_256_hex_of_string "abc" = "4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45". Proof. trivial. Qed. (* A byte-long test from XKCP's ShortMsgKAT_SHA3-256.txt. *) Local Example sha3_256_test_CC: sha3_256_hex (byte_of_N (HexString.to_N "0xCC") :: nil) = "677035391cd3701293d385f037ba32796252bb7ce180b00b582dd9b20aaad7f0". Proof. trivial. Qed. (* We won't prove this for everything. *) Example keccak_256_N_smoke_test: HexString.to_N ("0x" ++ keccak_256_hex_of_string "foo") = keccak_256_N_of_string "foo". Proof. trivial. Qed.
/- Copyright (c) 2023 Kevin Buzzard. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Author : Kevin Buzzard -/ import tactic -- imports all the Lean tactics import measure_theory.measurable_space /- # The extended nonnegative reals [0,∞] The big dilemma when a designer is faced with "minor modifications" of a standard type, is whether to just stick with the standard type and make do, or whether to make a new type and then be faced with the problem of having to make all the API for that type. Example: in measure theory a key role is played by the "extended non-negative reals", namely {x : ℝ | 0 ≀ x} βˆͺ {∞}. In Lean these are their own type, called `ennreal`. There is a "locale" containing standard notation associated for this type. Let's open it. localized "notation (name := ennreal) `ℝβ‰₯0∞` := ennreal" in ennreal localized "notation (name := ennreal.top) `∞` := (⊀ : ennreal)" in ennreal -/ open_locale ennreal #print notation ℝβ‰₯0∞ #check ennreal #check ℝβ‰₯0∞ -- [0,∞] #check ∞ -- it's the ∞ in ℝβ‰₯0∞ -- What can we do with extended non-negative reals? variables (a b : ℝβ‰₯0∞) #check a + b #check a - b -- surprising? #check a * b -- what is 0 * ∞ then? #check a / b -- is 1 / 0 = 0 or ∞? In ℝ it's 0 but here there's another possibility example : (0 : ℝβ‰₯0∞) * ∞ = 0 := begin norm_num, end example : (1 : ℝβ‰₯0∞) / 0 = ∞ := begin simp, end example (a b c : ℝβ‰₯0∞) : (a + b) * c = a * c + b * c := begin ring, end
section {* Domain Quantales *} theory Domain_Quantale imports "$AFP/KAD/Modal_Kleene_Algebra" begin subsection {* Notation *} notation times (infixl "\<cdot>" 70) notation bot ("\<bottom>") and top ("\<top>") and inf (infixl "\<sqinter>" 65) and sup (infixl "\<squnion>" 65) and Inf ("\<Sqinter>_" [900] 900) and Sup ("\<Squnion>_" [900] 900) syntax "_INF1" :: "pttrns \<Rightarrow> 'b \<Rightarrow> 'b" ("(3\<Sqinter>_./ _)" [0, 10] 10) "_INF" :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b" ("(3\<Sqinter>_\<in>_./ _)" [0, 0, 10] 10) "_SUP1" :: "pttrns \<Rightarrow> 'b \<Rightarrow> 'b" ("(3\<Squnion>_./ _)" [0, 10] 10) "_SUP" :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b" ("(3\<Squnion>_\<in>_./ _)" [0, 0, 10] 10) subsection {* Definitions of Lattice-Ordered Monoids with Domain*} class bd_lattice_ordered_monoid = bounded_lattice + distrib_lattice + monoid_mult + assumes left_distrib: "x \<cdot> (y \<squnion> z) = x \<cdot> y \<squnion> x \<cdot> z" and right_distrib: "(x \<squnion> y) \<cdot> z = x \<cdot> z \<squnion> y \<cdot> z" and bot_annil [simp]: "\<bottom> \<cdot> x = \<bottom>" and bot_annir [simp]: "x \<cdot> \<bottom> = \<bottom>" begin sublocale semiring_one_zero "op \<squnion>" "op \<cdot>" "1" "bot" by (standard, auto simp: sup.assoc sup.commute sup_left_commute left_distrib right_distrib sup_absorb1) sublocale dioid_one_zero "op \<squnion>" "op \<cdot>" "1" bot "op \<le>" "op <" by (standard, simp add: local.le_iff_sup, auto) end no_notation ads_d ("d") and ars_r ("r") and antirange_op ("ar _" [999] 1000) class domain_bdlo_monoid = bd_lattice_ordered_monoid + assumes rdv: "(z \<sqinter> x \<cdot> top) \<cdot> y = z \<cdot> y \<sqinter> x \<cdot> top" begin definition "d x = 1 \<sqinter> x \<cdot> \<top>" sublocale ds: domain_semiring "op \<squnion>" "op \<cdot>" "1" "\<bottom>" "d" "op \<le>" "op <" proof standard fix x y show "x \<squnion> d x \<cdot> x = d x \<cdot> x" by (metis d_def local.inf_sup_absorb local.left_distrib local.mult_1_left local.mult_1_right local.rdv local.sup.absorb_iff1 local.sup.idem local.sup.left_commute top_greatest) show "d (x \<cdot> d y) = d (x \<cdot> y)" by (simp add: d_def local.inf_absorb2 local.rdv mult_assoc) show "d x \<squnion> 1 = 1" by (simp add: d_def local.sup.commute) show "d bot = bot" by (simp add: d_def local.inf.absorb1 local.inf.commute) show "d (x \<squnion> y) = d x \<squnion> d y" by (simp add: d_def local.inf_sup_distrib1) qed end class boolean_monoid = boolean_algebra + monoid_mult + assumes left_distrib': "x \<cdot> (y \<squnion> z) = x \<cdot> y \<squnion> x \<cdot> z" and right_distrib': "(x \<squnion> y) \<cdot> z = x \<cdot> z \<squnion> y \<cdot> z" and bot_annil' [simp]: "\<bottom> \<cdot> x = \<bottom>" and bot_annir' [simp]: "x \<cdot> \<bottom> = \<bottom>" begin subclass bd_lattice_ordered_monoid by (standard, simp_all add: local.left_distrib' local.right_distrib') lemma inf_bot_iff_le: "x \<sqinter> y = \<bottom> \<longleftrightarrow> x \<le> -y" by (metis le_iff_inf inf_sup_distrib1 inf_top_right sup_bot.left_neutral sup_compl_top compl_inf_bot inf.assoc inf_bot_right) end class domain_boolean_monoid = boolean_monoid + assumes rdv': "(z \<sqinter> x \<cdot> \<top>) \<cdot> y = z \<cdot> y \<sqinter> x \<cdot> \<top>" begin sublocale dblo: domain_bdlo_monoid "1" "op \<cdot>" "op \<sqinter>" "op \<le>" "op <" "op \<squnion>" "\<bottom>" "\<top>" by (standard, simp add: local.rdv') definition "a x = 1 \<sqinter> -(dblo.d x)" lemma a_d_iff: "a x = 1 \<sqinter> -(x \<cdot> \<top>)" by (auto simp: a_def dblo.d_def inf_sup_distrib1) lemma topr: "-(x \<cdot> \<top>) \<cdot> \<top> = -(x \<cdot> \<top>)" proof (rule antisym) show "-(x \<cdot> \<top>) \<le> -(x \<cdot> \<top>) \<cdot> \<top>" by (metis local.mult_isol_var local.mult_oner local.order_refl local.top_greatest) have "-(x \<cdot> \<top>) \<sqinter> (x \<cdot> \<top>) = \<bottom>" by simp hence "(-(x \<cdot> \<top>) \<sqinter> (x \<cdot> \<top>)) \<cdot> \<top> = \<bottom>" by simp hence "-(x \<cdot> \<top>) \<cdot> \<top> \<sqinter> (x \<cdot> \<top>) = \<bottom>" by (metis local.rdv') thus "-(x \<cdot> \<top>) \<cdot> \<top> \<le> -(x \<cdot> \<top>)" by (simp add: local.inf_bot_iff_le) qed lemma dd_a: "dblo.d x = a (a x)" by (metis a_d_iff dblo.d_def local.double_compl local.inf_top.left_neutral local.mult_1_left local.rdv' topr) lemma ad_a [simp]: "a (dblo.d x) = a x" by (simp add: a_def) lemma da_a [simp]: "dblo.d (a x) = a x" using ad_a dd_a by auto lemma a1 [simp]: "a x \<cdot> x = \<bottom>" proof - have "a x \<cdot> x \<cdot> \<top> = \<bottom>" by (metis a_d_iff local.inf_compl_bot local.mult_1_left local.rdv' topr) then show ?thesis by (metis (no_types) dblo.d_def dblo.ds.domain_very_strict local.inf_bot_right) qed lemma a2 [simp]: "a (x \<cdot> y) \<squnion> a (x \<cdot> a (a y)) = a (x \<cdot> a (a y))" by (metis a_def dblo.ds.dsr2 dd_a local.sup.idem) lemma a3 [simp]: "a (a x) \<squnion> a x = 1" by (metis a_def da_a local.inf.commute local.sup.commute local.sup_compl_top local.sup_inf_absorb local.sup_inf_distrib1) subclass domain_bdlo_monoid .. sublocale ad: antidomain_semiring a "op \<squnion>" "op \<cdot>" "1" "\<bottom>" "op \<le>" "op <" rewrites ad_eq: "ad.ads_d x = d x" proof - show "class.antidomain_semiring a op \<squnion> op \<cdot> 1 \<bottom> op \<le> op <" by (standard, simp_all) then interpret ad: antidomain_semiring a "op \<squnion>" "op \<cdot>" "1" "\<bottom>" "op \<le>" "op <" . show "ad.ads_d x = d x" by (simp add: ad.ads_d_def dd_a) qed end class range_boolean_monoid = boolean_monoid + assumes ldv': "y \<cdot> (z \<sqinter> \<top> \<cdot> x) = y \<cdot> z \<sqinter> \<top> \<cdot> x" begin definition "r x = 1 \<sqinter> \<top> \<cdot> x" definition "ar x = 1 \<sqinter> -(r x)" lemma ar_r_iff: "ar x = 1 \<sqinter> -(\<top> \<cdot> x)" by (simp add: ar_def local.inf_sup_distrib1 r_def) lemma topl: "\<top>\<cdot>(-(\<top> \<cdot> x)) = -(\<top> \<cdot> x)" proof (rule antisym) show "\<top> \<cdot> - (\<top> \<cdot> x) \<le> - (\<top> \<cdot> x)" by (metis local.bot_annir' local.compl_inf_bot local.inf_bot_iff_le local.ldv') show "- (\<top> \<cdot> x) \<le> \<top> \<cdot> - (\<top> \<cdot> x)" by (metis local.inf_le2 local.inf_top.right_neutral local.mult_1_left local.mult_isor) qed lemma r_ar: "r x = ar (ar x)" by (metis ar_r_iff local.double_compl local.inf.commute local.inf_top.right_neutral local.ldv' local.mult_1_right r_def topl) lemma ar_ar [simp]: "ar (r x) = ar x" by (simp add: ar_def local.ldv' r_def) lemma rar_ar [simp]: "r (ar x) = ar x" using r_ar ar_ar by auto lemma ar1 [simp]: "x \<cdot> ar x = \<bottom>" proof - have "\<top> \<cdot> x \<cdot> ar x = \<bottom>" by (metis ar_r_iff local.inf_compl_bot local.ldv' local.mult_oner topl) then show ?thesis by (metis ar_r_iff local.double_compl local.inf_bot_iff_le local.inf_le2 local.inf_top.right_neutral local.ldv' local.mult_1_left local.mult_isor local.mult_oner topl) qed lemma ars: "r (r x \<cdot> y) = r (x \<cdot> y)" by (metis local.inf.commute local.inf_top.right_neutral local.ldv' local.mult_oner mult_assoc r_def) lemma ar2 [simp]: "ar (x \<cdot> y) \<squnion> ar (ar (ar x) \<cdot> y) = ar (ar (ar x) \<cdot> y)" by (metis ar_def ars r_ar local.sup.idem) lemma ar3 [simp]: "ar (ar x) \<squnion> ar x = 1 " by (metis ar_def rar_ar local.inf.commute local.sup.commute local.sup_compl_top local.sup_inf_absorb local.sup_inf_distrib1) sublocale ar: antirange_semiring "op \<squnion>" "op \<cdot>" "1" "\<bottom>" ar "op \<le>" "op <" rewrites ar_eq: "ar.ars_r x = r x" proof - show "class.antirange_semiring op \<squnion> op \<cdot> 1 \<bottom> ar op \<le> op <" by (standard, simp_all) then interpret ar: antirange_semiring "op \<squnion>" "op \<cdot>" "1" "\<bottom>" ar "op \<le>" "op <" . show "ar.ars_r x = r x" by (simp add: ar.ars_r_def r_ar) qed end subsection {* Definition of Quantale *} class quantale = complete_lattice + monoid_mult + assumes Sup_distr: "\<Squnion> X \<cdot> y = \<Squnion> {z. \<exists>x \<in> X. z = x \<cdot> y}" and Sup_distl: "x \<cdot> \<Squnion> Y = \<Squnion> {z. \<exists>y \<in> Y. z = x \<cdot> y}" begin lemma bot_annil'' [simp]: "\<bottom> \<cdot> x = \<bottom>" using Sup_distr[where X="{}"] by auto lemma bot_annirr'' [simp]: "x \<cdot> \<bottom> = \<bottom>" using Sup_distl[where Y="{}"] by auto lemma sup_distl: "x \<cdot> (y \<squnion> z) = x \<cdot> y \<squnion> x \<cdot> z" using Sup_distl[where Y="{y, z}"] by (fastforce intro!: Sup_eqI) lemma sup_distr: "(x \<squnion> y) \<cdot> z = x \<cdot> z \<squnion> y \<cdot> z" using Sup_distr[where X="{x, y}"] by (fastforce intro!: Sup_eqI) sublocale semiring_one_zero "op \<squnion>" "op \<cdot>" "1" "\<bottom>" by (standard, auto simp: sup.assoc sup.commute sup_left_commute sup_distl sup_distr) sublocale dioid_one_zero "op \<squnion>" "op \<cdot>" "1" "\<bottom>" "op \<le>" "op <" by (standard, simp add: local.le_iff_sup, auto) lemma Sup_sup_pred: "x \<squnion> \<Squnion>{y. P y} = \<Squnion>{y. y = x \<or> P y}" apply (rule antisym) apply (simp add: Collect_mono local.Sup_subset_mono local.Sup_upper) using local.Sup_least local.Sup_upper local.le_supI2 by fastforce definition star :: "'a \<Rightarrow> 'a" where "star x = (\<Squnion>i. x ^ i)" lemma star_def_var1: "star x = \<Squnion>{y. \<exists>i. y = x ^ i}" by (simp add: star_def full_SetCompr_eq) lemma star_def_var2: "star x = \<Squnion>{x ^ i |i. True}" by (simp add: star_def full_SetCompr_eq) lemma star_unfoldl' [simp]: "1 \<squnion> x \<cdot> (star x) = star x" proof - have "1 \<squnion> x \<cdot> (star x) = x ^ 0 \<squnion> x \<cdot> \<Squnion>{y. \<exists>i. y = x ^ i}" by (simp add: star_def_var1) also have "... = x ^ 0 \<squnion> \<Squnion>{y. \<exists>i. y = x ^ (i + 1)}" by (simp add: Sup_distl, metis) also have "... = \<Squnion>{y. y = x ^ 0 \<or> (\<exists>i. y = x ^ (i + 1))}" using Sup_sup_pred by auto also have "... = \<Squnion>{y. \<exists>i. y = x ^ i}" by (metis Suc_eq_plus1 power.power.power_Suc power.power_eq_if) finally show ?thesis by (simp add: star_def_var1) qed lemma star_unfoldr' [simp]: "1 \<squnion> (star x) \<cdot> x = star x" proof - have "1 \<squnion> (star x) \<cdot> x = x ^ 0 \<squnion> \<Squnion>{y. \<exists>i. y = x ^ i} \<cdot> x" by (simp add: star_def_var1) also have "... = x ^ 0 \<squnion> \<Squnion>{y. \<exists>i. y = x ^ i \<cdot> x}" by (simp add: Sup_distr, metis) also have "... = x ^ 0 \<squnion> \<Squnion>{y. \<exists>i. y = x ^ (i + 1)}" using local.power_Suc2 by auto also have "... = \<Squnion>{y. y = x ^ 0 \<or> (\<exists>i. y = x ^ (i + 1))}" using Sup_sup_pred by auto also have "... = \<Squnion>{y. \<exists>i. y = x ^ i}" by (metis Suc_eq_plus1 power.power.power_Suc power.power_eq_if) finally show ?thesis by (simp add: star_def_var1) qed lemma (in dioid_one_zero) power_inductl: "z + x \<cdot> y \<le> y \<Longrightarrow> (x ^ n) \<cdot> z \<le> y" proof (induct n) case 0 show ?case using "0.prems" by auto case Suc thus ?case by (auto, metis mult.assoc mult_isol order_trans) qed lemma (in dioid_one_zero) power_inductr: "z + y \<cdot> x \<le> y \<Longrightarrow> z \<cdot> (x ^ n) \<le> y" proof (induct n) case 0 show ?case using "0.prems" by auto case Suc { fix n assume "z + y \<cdot> x \<le> y \<Longrightarrow> z \<cdot> x ^ n \<le> y" and "z + y \<cdot> x \<le> y" hence "z \<cdot> x ^ n \<le> y" by auto also have "z \<cdot> x ^ Suc n = z \<cdot> x \<cdot> x ^ n" by (metis mult.assoc power_Suc) moreover have "... = (z \<cdot> x ^ n) \<cdot> x" by (metis mult.assoc power_commutes) moreover have "... \<le> y \<cdot> x" by (metis calculation(1) mult_isor) moreover have "... \<le> y" using `z + y \<cdot> x \<le> y` by auto ultimately have "z \<cdot> x ^ Suc n \<le> y" by auto } thus ?case by (metis Suc) qed lemma star_inductl': "z \<squnion> x \<cdot> y \<le> y \<Longrightarrow> (star x) \<cdot> z \<le> y" proof - assume "z \<squnion> x \<cdot> y \<le> y" hence "\<forall>i. x ^ i \<cdot> z \<le> y" by (simp add: local.power_inductl) hence "\<Squnion>{w. \<exists>i. w = x ^ i \<cdot> z} \<le> y" by (intro Sup_least, auto) hence "\<Squnion>{w. \<exists>i. w = x ^ i} \<cdot> z \<le> y" using local.Sup_distr local.Sup_le_iff by auto thus "(star x) \<cdot> z \<le> y" by (simp add: local.star_def_var1) qed lemma star_inductr': "z \<squnion> y \<cdot> x \<le> y \<Longrightarrow> z \<cdot> (star x) \<le> y" proof - assume "z \<squnion> y \<cdot> x \<le> y" hence "\<forall>i. z \<cdot> x ^ i \<le> y" by (simp add: local.power_inductr) hence "\<Squnion>{w. \<exists>i. w = z \<cdot> x ^ i} \<le> y" by (intro Sup_least, auto) hence "z \<cdot> \<Squnion>{w. \<exists>i. w = x ^ i} \<le> y" using local.Sup_distl local.Sup_le_iff by auto thus "z \<cdot> (star x) \<le> y" by (simp add: local.star_def_var1) qed sublocale ka: kleene_algebra "op \<squnion>" "op \<cdot>" "1" "\<bottom>" "op \<le>" "op <" star by standard (simp_all add: star_inductl' local.star_inductr') end class distributive_quantale = quantale + distrib_lattice (* this is probably not true as we need infinite distributivity laws ! *) begin subclass bd_lattice_ordered_monoid by (standard, simp_all add: local.distrib_left) lemma "(1 \<sqinter> x \<cdot> \<top>) \<cdot> x = x" nitpick oops end subsection {* Domain Quantales *} class domain_quantale = distributive_quantale + assumes rdv'': "(z \<sqinter> x \<cdot> \<top>) \<cdot> y = z \<cdot> y \<sqinter> x \<cdot> \<top>" begin subclass domain_bdlo_monoid by (standard, simp add: local.rdv'') end class range_quantale = distributive_quantale + assumes ldv'': "y \<cdot> (z \<sqinter> \<top> \<cdot> x) = y \<cdot> z \<sqinter> \<top> \<cdot> x" class boolean_quantale = quantale + complete_boolean_algebra begin subclass boolean_monoid by (standard, simp_all add: local.sup_distl) lemma "(1 \<sqinter> x \<cdot> \<top>) \<cdot> x = x" nitpick oops lemma "(1 \<sqinter> -(x \<cdot> \<top>)) \<cdot> x = \<bottom>" nitpick oops end class domain_boolean_quantale = domain_quantale + boolean_quantale begin subclass domain_boolean_monoid by (standard, simp add: local.rdv'') lemma fbox_eq: "ad.fbox x q = Sup{d(p)| p. d(p)*x \<le> x*d(q)}" apply (rule Sup_eqI[symmetric]) apply clarsimp using local.ad.fbox_demodalisation3 local.ad.fbox_simp apply auto[1] apply clarsimp by (metis local.ad.fbox_def local.ad.fbox_demodalisation3 local.ad.fbox_simp local.da_a local.eq_refl) lemma fdia_eq: "ad.fdia x p = Inf{d(q)|q. x*d(p) \<le> d(q)*x}" apply (rule Inf_eqI[symmetric]) apply clarsimp using local.ds.fdemodalisation2 apply auto[1] apply clarsimp by (metis local.ad.fd_eq_fdia local.ad.fdia_def local.da_a local.double_compl local.ds.fdemodalisation2 local.inf_bot_iff_le local.inf_compl_bot) (* proof of axioms for RKAT -- H p x q \<longleftrightarrow> p \<le> fbox x q *) definition R :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" where "R p q \<equiv> Sup{x. d(p)*x \<le> x*d(q)}" lemma "x \<le> R p q \<Longrightarrow> d(p) \<le> ad.fbox x (d q)" proof (simp add: R_def ad.kat_1_equiv ad.kat_2_equiv) assume "x \<le> \<Squnion>{x. d p \<cdot> x \<cdot> a q = \<bottom>}" hence "d p \<cdot> x \<cdot> a q \<le> d p \<cdot> \<Squnion>{x. d p \<cdot> x \<cdot> a q = \<bottom>} \<cdot> a q " using local.mult_double_iso by blast also have "... = \<Squnion>{d p \<cdot> x \<cdot> a q | x. d p \<cdot> x \<cdot> a q = \<bottom>}" apply (subst Sup_distl) apply (subst Sup_distr) apply clarsimp apply metis done also have "... = \<bottom>" by (auto simp: Sup_eqI) finally show ?thesis using ad.fbox_demodalisation3 local.ad.kat_3 local.ad.kat_4 local.le_bot by blast qed lemma "d(p) \<le> ad.fbox x (d q) \<Longrightarrow> x \<le> R p q" apply (simp add: R_def) apply (rule Sup_upper) apply simp using local.ad.fbox_demodalisation3 local.ad.fbox_simp apply auto[1] done end interpretation rel_dbq: domain_boolean_quantale Inter Union "op \<inter>" "op \<subseteq>" "op \<subset>" "op \<union>" "{}" UNIV minus uminus Id "op O" apply (standard, simp_all add: O_assoc) by blast + class range_boolean_quantale = range_quantale + boolean_quantale begin subclass range_boolean_monoid by (standard, simp add: local.ldv'') lemma fbox_eq: "ar.bbox x (r q) = Sup{r(p)| p. x*r(p) \<le> r(q)*x}" apply (rule Sup_eqI[symmetric]) apply clarsimp using ar.ardual.fbox_demodalisation3 local.ar.ardual.fbox_simp apply auto[1] apply clarsimp by (metis local.ar.ardual.fbox_def local.ar.ardual.fbox_demodalisation3 local.eq_refl local.rar_ar) lemma fdia_eq: "ar.bdia x (r p) = Inf{r(q)|q. r(p)*x \<le> x*r(q)}" apply (rule Inf_eqI[symmetric]) apply clarsimp using ar.ars_r_def local.ar.ardual.fdemodalisation22 local.ar.ardual.kat_3_equiv_opp local.ar.ardual.kat_4_equiv_opp apply auto[1] apply clarsimp using ar.bdia_def local.ar.ardual.ds.fdemodalisation2 local.r_ar by fastforce end class modal_boolean_quantale = domain_boolean_quantale + range_boolean_quantale + assumes domrange' [simp]: "d (r x) = r x" and rangedom' [simp]: "r (d x) = d x" begin sublocale mka: modal_kleene_algebra "op \<squnion>" "op \<cdot>" 1 \<bottom> "op \<le>" "op <" star a ar by standard (simp_all add: ar_eq ad_eq) end no_notation fbox ("( |_] _)" [61,81] 82) and antidomain_semiringl_class.fbox ("( |_] _)" [61,81] 82) notation ad.fbox ("( |_] _)" [61,81] 82) lemma recursion: "mono (f :: 'a \<Rightarrow> 'a :: domain_boolean_quantale) \<Longrightarrow> (\<And>x. d p \<le> |x] d q \<Longrightarrow> d p \<le> |f x] d q) \<Longrightarrow> d p \<le> |lfp f] d q" apply (erule lfp_ordinal_induct [where f=f], simp) apply (auto simp: ad.addual.ardual.fbox_demodalisation3 Sup_distr Sup_distl intro: Sup_mono) done end
#ifndef __SAMPLER_H__ #define __SAMPLER_H__ #include <dSFMT.h> #include <gsl/gsl_randist.h> #include <gsl/gsl_rng.h> class Sampler { dsfmt_t dsfmt; void init_random(unsigned params_random_seed) { #ifdef USE_MT_RANDOM dsfmt_init_gen_rand(&dsfmt, params_random_seed); #else srand(params_random_seed); #endif }; protected: /* gsl random number generator */ gsl_rng* _gsl_rng; /* default constructor */ Sampler(unsigned int random_seed) { /* do i still need this ? */ init_random(random_seed); /* init gsl random number generator */ _gsl_rng = gsl_rng_alloc( gsl_rng_taus ); }; double sample_uniform(); unsigned long int sample_integer_uniform(unsigned int from, unsigned int to); }; #endif
Formal statement is: lemma convex_set_sum: assumes "\<And>i. i \<in> A \<Longrightarrow> convex (B i)" shows "convex (\<Sum>i\<in>A. B i)" Informal statement is: If each $B_i$ is convex, then $\sum_{i \in A} B_i$ is convex.
/- Copyright (c) 2020 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Robert Y. Lewis -/ import algebra.char_p.invertible import data.mv_polynomial.variables import data.mv_polynomial.comm_ring import data.mv_polynomial.expand import data.zmod.basic /-! # Witt polynomials To endow `witt_vector p R` with a ring structure, we need to study the so-called Witt polynomials. Fix a base value `p : β„•`. The `p`-adic Witt polynomials are an infinite family of polynomials indexed by a natural number `n`, taking values in an arbitrary ring `R`. The variables of these polynomials are represented by natural numbers. The variable set of the `n`th Witt polynomial contains at most `n+1` elements `{0, ..., n}`, with exactly these variables when `R` has characteristic `0`. These polynomials are used to define the addition and multiplication operators on the type of Witt vectors. (While this type itself is not complicated, the ring operations are what make it interesting.) When the base `p` is invertible in `R`, the `p`-adic Witt polynomials form a basis for `mv_polynomial β„• R`, equivalent to the standard basis. ## Main declarations * `witt_polynomial p R n`: the `n`-th Witt polynomial, viewed as polynomial over the ring `R` * `X_in_terms_of_W p R n`: if `p` is invertible, the polynomial `X n` is contained in the subalgebra generated by the Witt polynomials. `X_in_terms_of_W p R n` is the explicit polynomial, which upon being bound to the Witt polynomials yields `X n`. * `bind₁_witt_polynomial_X_in_terms_of_W`: the proof of the claim that `bind₁ (X_in_terms_of_W p R) (W_ R n) = X n` * `bind₁_X_in_terms_of_W_witt_polynomial`: the converse of the above statement ## Notation In this file we use the following notation * `p` is a natural number, typically assumed to be prime. * `R` and `S` are commutative rings * `W n` (and `W_ R n` when the ring needs to be explicit) denotes the `n`th Witt polynomial ## References * [Hazewinkel, *Witt Vectors*][Haze09] * [Commelin and Lewis, *Formalizing the Ring of Witt Vectors*][CL21] -/ open mv_polynomial open finset (hiding map) open finsupp (single) open_locale big_operators local attribute [-simp] coe_evalβ‚‚_hom variables (p : β„•) variables (R : Type*) [comm_ring R] /-- `witt_polynomial p R n` is the `n`-th Witt polynomial with respect to a prime `p` with coefficients in a commutative ring `R`. It is defined as: `βˆ‘_{i ≀ n} p^i X_i^{p^{n-i}} ∈ R[X_0, X_1, X_2, …]`. -/ noncomputable def witt_polynomial (n : β„•) : mv_polynomial β„• R := βˆ‘ i in range (n+1), monomial (single i (p ^ (n - i))) (p ^ i) lemma witt_polynomial_eq_sum_C_mul_X_pow (n : β„•) : witt_polynomial p R n = βˆ‘ i in range (n+1), C (p ^ i : R) * X i ^ (p ^ (n - i)) := begin apply sum_congr rfl, rintro i -, rw [monomial_eq, finsupp.prod_single_index], rw pow_zero, end /-! We set up notation locally to this file, to keep statements short and comprehensible. This allows us to simply write `W n` or `W_ β„€ n`. -/ -- Notation with ring of coefficients explicit localized "notation `W_` := witt_polynomial p" in witt -- Notation with ring of coefficients implicit localized "notation `W` := witt_polynomial p _" in witt open_locale witt open mv_polynomial /- The first observation is that the Witt polynomial doesn't really depend on the coefficient ring. If we map the coefficients through a ring homomorphism, we obtain the corresponding Witt polynomial over the target ring. -/ section variables {R} {S : Type*} [comm_ring S] @[simp] lemma map_witt_polynomial (f : R β†’+* S) (n : β„•) : map f (W n) = W n := begin rw [witt_polynomial, ring_hom.map_sum, witt_polynomial, sum_congr rfl], intros i hi, rw [map_monomial, ring_hom.map_pow, ring_hom.map_nat_cast], end variables (R) @[simp] lemma constant_coeff_witt_polynomial [hp : fact p.prime] (n : β„•) : constant_coeff (witt_polynomial p R n) = 0 := begin simp only [witt_polynomial, ring_hom.map_sum, constant_coeff_monomial], rw [sum_eq_zero], rintro i hi, rw [if_neg], rw [finsupp.single_eq_zero], exact ne_of_gt (pow_pos hp.1.pos _) end @[simp] lemma witt_polynomial_zero : witt_polynomial p R 0 = X 0 := by simp only [witt_polynomial, X, sum_singleton, range_one, pow_zero] @[simp] lemma witt_polynomial_one : witt_polynomial p R 1 = C ↑p * X 1 + (X 0) ^ p := by simp only [witt_polynomial_eq_sum_C_mul_X_pow, sum_range_succ_comm, range_one, sum_singleton, one_mul, pow_one, C_1, pow_zero] lemma aeval_witt_polynomial {A : Type*} [comm_ring A] [algebra R A] (f : β„• β†’ A) (n : β„•) : aeval f (W_ R n) = βˆ‘ i in range (n+1), p^i * (f i) ^ (p ^ (n-i)) := by simp [witt_polynomial, alg_hom.map_sum, aeval_monomial, finsupp.prod_single_index] /-- Over the ring `zmod (p^(n+1))`, we produce the `n+1`st Witt polynomial by expanding the `n`th witt polynomial by `p`. -/ @[simp] lemma witt_polynomial_zmod_self (n : β„•) : W_ (zmod (p ^ (n + 1))) (n + 1) = expand p (W_ (zmod (p^(n + 1))) n) := begin simp only [witt_polynomial_eq_sum_C_mul_X_pow], rw [sum_range_succ, ← nat.cast_pow, char_p.cast_eq_zero (zmod (p^(n+1))) (p^(n+1)), C_0, zero_mul, add_zero, alg_hom.map_sum, sum_congr rfl], intros k hk, rw [alg_hom.map_mul, alg_hom.map_pow, expand_X, alg_hom_C, ← pow_mul, ← pow_succ], congr, rw mem_range at hk, rw [add_comm, nat.add_sub_assoc (nat.lt_succ_iff.mp hk), ← add_comm], end section p_prime -- in fact, `0 < p` would be sufficient variables [hp : fact p.prime] include hp lemma witt_polynomial_vars [char_zero R] (n : β„•) : (witt_polynomial p R n).vars = range (n + 1) := begin have : βˆ€ i, (monomial (finsupp.single i (p ^ (n - i))) (p ^ i : R)).vars = {i}, { intro i, rw vars_monomial_single, { rw ← pos_iff_ne_zero, apply pow_pos hp.1.pos }, { rw [← nat.cast_pow, nat.cast_ne_zero], apply ne_of_gt, apply pow_pos hp.1.pos i } }, rw [witt_polynomial, vars_sum_of_disjoint], { simp only [this, int.nat_cast_eq_coe_nat, bUnion_singleton_eq_self], }, { simp only [this, int.nat_cast_eq_coe_nat], intros a b h, apply singleton_disjoint.mpr, rwa mem_singleton, }, end lemma witt_polynomial_vars_subset (n : β„•) : (witt_polynomial p R n).vars βŠ† range (n + 1) := begin rw [← map_witt_polynomial p (int.cast_ring_hom R), ← witt_polynomial_vars p β„€], apply vars_map, end end p_prime end /-! ## Witt polynomials as a basis of the polynomial algebra If `p` is invertible in `R`, then the Witt polynomials form a basis of the polynomial algebra `mv_polynomial β„• R`. The polynomials `X_in_terms_of_W` give the coordinate transformation in the backwards direction. -/ /-- The `X_in_terms_of_W p R n` is the polynomial on the basis of Witt polynomials that corresponds to the ordinary `X n`. -/ noncomputable def X_in_terms_of_W [invertible (p : R)] : β„• β†’ mv_polynomial β„• R | n := (X n - (βˆ‘ i : fin n, have _ := i.2, (C (p^(i : β„•) : R) * (X_in_terms_of_W i)^(p^(n-i))))) * C (β…Ÿp ^ n : R) lemma X_in_terms_of_W_eq [invertible (p : R)] {n : β„•} : X_in_terms_of_W p R n = (X n - (βˆ‘ i in range n, C (p^i : R) * X_in_terms_of_W p R i ^ p ^ (n - i))) * C (β…Ÿp ^ n : R) := by { rw [X_in_terms_of_W, ← fin.sum_univ_eq_sum_range] } @[simp] lemma constant_coeff_X_in_terms_of_W [hp : fact p.prime] [invertible (p : R)] (n : β„•) : constant_coeff (X_in_terms_of_W p R n) = 0 := begin apply nat.strong_induction_on n; clear n, intros n IH, rw [X_in_terms_of_W_eq, mul_comm, ring_hom.map_mul, ring_hom.map_sub, ring_hom.map_sum, constant_coeff_C, sum_eq_zero], { simp only [constant_coeff_X, sub_zero, mul_zero] }, { intros m H, rw mem_range at H, simp only [ring_hom.map_mul, ring_hom.map_pow, constant_coeff_C, IH m H], rw [zero_pow, mul_zero], apply pow_pos hp.1.pos, } end @[simp] lemma X_in_terms_of_W_zero [invertible (p : R)] : X_in_terms_of_W p R 0 = X 0 := by rw [X_in_terms_of_W_eq, range_zero, sum_empty, pow_zero, C_1, mul_one, sub_zero] section p_prime variables [hp : fact p.prime] include hp lemma X_in_terms_of_W_vars_aux (n : β„•) : n ∈ (X_in_terms_of_W p β„š n).vars ∧ (X_in_terms_of_W p β„š n).vars βŠ† range (n + 1) := begin apply nat.strong_induction_on n, clear n, intros n ih, rw [X_in_terms_of_W_eq, mul_comm, vars_C_mul, vars_sub_of_disjoint, vars_X, range_succ, insert_eq], swap 3, { apply nonzero_of_invertible }, work_on_goal 0 { simp only [true_and, true_or, eq_self_iff_true, mem_union, mem_singleton], intro i, rw [mem_union, mem_union], apply or.imp id }, work_on_goal 1 { rw [vars_X, singleton_disjoint] }, all_goals { intro H, replace H := vars_sum_subset _ _ H, rw mem_bUnion at H, rcases H with ⟨j, hj, H⟩, rw vars_C_mul at H, swap, { apply pow_ne_zero, exact_mod_cast hp.1.ne_zero }, rw mem_range at hj, replace H := (ih j hj).2 (vars_pow _ _ H), rw mem_range at H }, { rw mem_range, exact lt_of_lt_of_le H hj }, { exact lt_irrefl n (lt_of_lt_of_le H hj) }, end lemma X_in_terms_of_W_vars_subset (n : β„•) : (X_in_terms_of_W p β„š n).vars βŠ† range (n + 1) := (X_in_terms_of_W_vars_aux p n).2 end p_prime lemma X_in_terms_of_W_aux [invertible (p : R)] (n : β„•) : X_in_terms_of_W p R n * C (p^n : R) = X n - βˆ‘ i in range n, C (p^i : R) * (X_in_terms_of_W p R i)^p^(n-i) := by rw [X_in_terms_of_W_eq, mul_assoc, ← C_mul, ← mul_pow, inv_of_mul_self, one_pow, C_1, mul_one] @[simp] lemma bind₁_X_in_terms_of_W_witt_polynomial [invertible (p : R)] (k : β„•) : bind₁ (X_in_terms_of_W p R) (W_ R k) = X k := begin rw [witt_polynomial_eq_sum_C_mul_X_pow, alg_hom.map_sum], simp only [alg_hom.map_pow, C_pow, alg_hom.map_mul, alg_hom_C], rw [sum_range_succ_comm, nat.sub_self, pow_zero, pow_one, bind₁_X_right, mul_comm, ← C_pow, X_in_terms_of_W_aux], simp only [C_pow, bind₁_X_right, sub_add_cancel], end @[simp] lemma bind₁_witt_polynomial_X_in_terms_of_W [invertible (p : R)] (n : β„•) : bind₁ (W_ R) (X_in_terms_of_W p R n) = X n := begin apply nat.strong_induction_on n, clear n, intros n H, rw [X_in_terms_of_W_eq, alg_hom.map_mul, alg_hom.map_sub, bind₁_X_right, alg_hom_C, alg_hom.map_sum], have : W_ R n - βˆ‘ i in range n, C (p ^ i : R) * (X i) ^ p ^ (n - i) = C (p ^ n : R) * X n, by simp only [witt_polynomial_eq_sum_C_mul_X_pow, nat.sub_self, sum_range_succ_comm, pow_one, add_sub_cancel, pow_zero], rw [sum_congr rfl, this], { -- this is really slow for some reason rw [mul_right_comm, ← C_mul, ← mul_pow, mul_inv_of_self, one_pow, C_1, one_mul] }, { intros i h, rw mem_range at h, simp only [alg_hom.map_mul, alg_hom.map_pow, alg_hom_C, H i h] }, end
(* vim: filetype=coq *) (* Copyright (C) 2016-2018 Philip H. Smith This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. *) Require Import Way.StaleAtoms. Require Import Way.Tactics. Require Import Way.Open. Require Import Way.Preterm. (* A preterm is locally closed if every bound variable refers to some abstraction. Local closure is the only criterion needed to establish a preterm as a term, so the type here is named "term". A proof of local closure reflects the shape of its preterm, with two key differences. First, we transform abstraction bodies before demanding local closure of the result. The transformation is to open a "sufficiently fresh" free variable for the new bound variable. This bound variable will therefore not appear in the preterm of the required subproof. Since abstraction annotations should not refer to the new abstraction variable, no substitution is performed on them. Second, there is no local closure constructor for bound variables. If all bound variables properly refer to some abstraction, then by the first point they will all be replaced by free variables by the time we consider the proof of their local closure. Any bound variables that remain must be dangling. By the second point, preterms with dangling bound variables will be unable to prove local closure, due to the lack of a suitable constructor. Preterms without dangling bound variables will have no need of one. "Sufficiently fresh" means exclusion from an arbitrary list of free variables, but think "free variables of the abstraction body". Leaving it unspecified here makes proofs somewhat easier later, per the "cofinite induction" pattern. *) Inductive term : preterm -> Set := | free_variable : forall (a : atom), term (free_variable a) | product : forall (l : list atom) (p q : preterm), term p -> (fresh (a : l), term (open_free a q)) -> term (product p q) | abstraction : forall (l : list atom) (p q : preterm), term p -> (fresh (a : l), term (open_free a q)) -> term (abstraction p q) | application : forall (p q : preterm), term p -> term q -> term (application p q) | type : forall (n : nat), term (type n). Hint Resolve free_variable application type : way. Hint Extern 7 (term (Preterm.product _ _)) => let stale := stale_atoms in apply (Term.product stale) : way. Hint Extern 7 (term (Preterm.abstraction _ _)) => let stale := stale_atoms in apply (Term.abstraction stale) : way. Module Examples. Import Aliases. Example omega : term Preterm.Examples.omega. Proof. unfold Preterm.Examples.omega; infer. Defined. Example polymorphic_identity : term Preterm.Examples.polymorphic_identity. Proof. unfold Preterm.Examples.polymorphic_identity; infer. Defined. Example fvar_is_term : forall (a : atom), term (fvar a). Proof. infer. Defined. Example prod_can_be_term : term (prod (type 0) (bvar 0)). Proof. infer. Defined. Example prod_can_be_not_term : notT (term (prod (type 0) (bvar 1))). Proof. intro H; inversion H as [ | stale ? ? ? CFH | | | ]; subst; destruct (fresh_atom stale) as [a Hfresh]; pose proof (CFH a Hfresh) as Himpossible; infer. Defined. Example abs_can_be_term : term (abs (type 0) (bvar 0)). Proof. infer. Defined. Example abs_can_be_not_term : notT (term (abs (type 0) (bvar 1))). Proof. intro H; inversion H as [ | | stale ? ? ? CFH | | ]; subst; destruct (fresh_atom stale) as [a Hfresh]; pose proof (CFH a Hfresh) as Himpossible; infer. Defined. Example app_can_be_term : forall (a : atom), term (app (fvar a) (fvar a)). Proof. infer. Defined. Example app_can_be_not_term : notT (term (app (bvar 0) (bvar 0))). Proof. infer. Defined. Example type_is_term : term (type 0). Proof. infer. Defined. End Examples.
State Before: a b c d e : Nat he : b = a * e f : Nat hf : d = c * f ⊒ b * d = a * c * (e * f) State After: no goals Tactic: simp [he, hf, Nat.mul_assoc, Nat.mul_left_comm, Nat.mul_comm]
lemma open_Collect_ex: "(\<And>i. open {x. P i x}) \<Longrightarrow> open {x. \<exists>i. P i x}"
lemma measurable_iff_measure_of: assumes "N \<subseteq> Pow \<Omega>" "f \<in> space M \<rightarrow> \<Omega>" shows "f \<in> measurable M (measure_of \<Omega> N \<mu>) \<longleftrightarrow> (\<forall>A\<in>N. f -` A \<inter> space M \<in> sets M)"
/** * @file zheevd.c * * PLASMA computational routines * Release Date: November, 15th 2009 * PLASMA is a software package provided by Univ. of Tennessee, * Univ. of California Berkeley and Univ. of Colorado Denver * * @version 2.6.0 * @author Azzam Haidar * @author Hatem Ltaief * @date 2010-11-15 * @precisions normal z -> s d c * **/ #include <lapacke.h> #include "common.h" /***************************************************************************//** * * @ingroup PLASMA_Complex64_t * * PLASMA_zheevd - Computes all eigenvalues and, optionally, * eigenvectors of a complex Hermitian matrix A. The matrix A is * preliminary reduced to tridiagonal form using a two-stage * approach: * First stage: reduction to band tridiagonal form; * Second stage: reduction from band to tridiagonal form. * ******************************************************************************* * * @param[in] jobz * Intended usage: * = PlasmaNoVec: computes eigenvalues only; * = PlasmaVec: computes eigenvalues and eigenvectors. * * @param[in] uplo * Specifies whether the matrix A is upper triangular or * lower triangular: * = PlasmaUpper: Upper triangle of A is stored; * = PlasmaLower: Lower triangle of A is stored. * * @param[in] N * The order of the matrix A. N >= 0. * * @param[in,out] A * On entry, the symmetric (or Hermitian) matrix A. * If uplo = PlasmaUpper, the leading N-by-N upper triangular * part of A contains the upper triangular part of the matrix * A, and the strictly lower triangular part of A is not * referenced. * If uplo = PlasmaLower, the leading N-by-N lower triangular * part of A contains the lower triangular part of the matrix * A, and the strictly upper triangular part of A is not * referenced. * On exit, the lower triangle (if uplo = PlasmaLower) or the * upper triangle (if uplo = PlasmaUpper) of A, including the * diagonal, is destroyed. * * @param[in] LDA * The leading dimension of the array A. LDA >= max(1,N). * * @param[out] W * On exit, if info = 0, the eigenvalues. * * @param[in, out] descT * On entry, descriptor as return by PLASMA_Alloc_Workspace_zheevd * On exit, contains auxiliary factorization data. * * @param[out] Q * On exit, if jobz = PlasmaVec and info = 0, the eigenvectors. * * @param[in] LDQ * The leading dimension of the array Q. LDQ >= max(1,N). * ******************************************************************************* * * @return * \retval PLASMA_SUCCESS successful exit * \retval <0 if -i, the i-th argument had an illegal value * \retval >0 if INFO = i, the algorithm failed to converge; i * off-diagonal elements of an intermediate tridiagonal * form did not converge to zero. * ******************************************************************************* * * @sa PLASMA_zheevd_Tile * @sa PLASMA_zheevd_Tile_Async * @sa PLASMA_cheevd * @sa PLASMA_dsyev * @sa PLASMA_ssyev * ******************************************************************************/ int PLASMA_zheevd(PLASMA_enum jobz, PLASMA_enum uplo, int N, PLASMA_Complex64_t *A, int LDA, double *W, PLASMA_desc *descT, PLASMA_Complex64_t *Q, int LDQ) { int NB; int status; plasma_context_t *plasma; PLASMA_sequence *sequence = NULL; PLASMA_request request = PLASMA_REQUEST_INITIALIZER; PLASMA_desc descA; plasma = plasma_context_self(); if (plasma == NULL) { plasma_error("PLASMA_zheevd", "PLASMA not initialized"); return PLASMA_ERR_NOT_INITIALIZED; } /* Check input arguments */ if (jobz != PlasmaNoVec && jobz != PlasmaVec) { plasma_error("PLASMA_zheevd", "illegal value of jobz"); return -1; } if (uplo != PlasmaLower && uplo != PlasmaUpper) { plasma_error("PLASMA_zheevd", "illegal value of uplo"); return -2; } if (N < 0) { plasma_error("PLASMA_zheevd", "illegal value of N"); return -3; } if (LDA < max(1, N)) { plasma_error("PLASMA_zheevd", "illegal value of LDA"); return -5; } if (LDQ < max(1, N)) { plasma_error("PLASMA_zheevd", "illegal value of LDQ"); return -9; } /* Quick return */ if (N == 0) return PLASMA_SUCCESS; /* Tune NB & IB depending on N; Set NBNB */ status = plasma_tune(PLASMA_FUNC_ZHEEVD, N, N, 0); if (status != PLASMA_SUCCESS) { plasma_error("PLASMA_zheevd", "plasma_tune() failed"); return status; } /* Set NT */ NB = PLASMA_NB; plasma_sequence_create(plasma, &sequence); if ( PLASMA_TRANSLATION == PLASMA_OUTOFPLACE ) { plasma_zooplap2tile( descA, A, NB, NB, LDA, N, 0, 0, N, N, sequence, &request, plasma_desc_mat_free(&(descA)) ); } else { plasma_ziplap2tile( descA, A, NB, NB, LDA, N, 0, 0, N, N, sequence, &request); } /* Call the tile interface */ PLASMA_zheevd_Tile_Async(jobz, uplo, &descA, W, descT, Q, LDQ, sequence, &request); if ( PLASMA_TRANSLATION == PLASMA_OUTOFPLACE ) { plasma_zooptile2lap( descA, A, NB, NB, LDA, N, sequence, &request); plasma_dynamic_sync(); plasma_desc_mat_free(&descA); } else { plasma_ziptile2lap( descA, A, NB, NB, LDA, N, sequence, &request); plasma_dynamic_sync(); } status = sequence->status; plasma_sequence_destroy(plasma, sequence); return status; } /***************************************************************************//** * * @ingroup PLASMA_Complex64_t_Tile * * PLASMA_zheevd_Tile - Computes all eigenvalues and, optionally, eigenvectors of a * complex Hermitian matrix A using a two-stage approach: * First stage: reduction to band tridiagonal form; * Second stage: reduction from band to tridiagonal form. * * Operates on matrices stored by tiles. * All matrices are passed through descriptors. * All dimensions are taken from the descriptors. * ******************************************************************************* * * @param[in] jobz * Intended usage: * = PlasmaNoVec: computes eigenvalues only; * = PlasmaVec: computes eigenvalues and eigenvectors. * * @param[in] uplo * Specifies whether the matrix A is upper triangular or * lower triangular: * = PlasmaUpper: Upper triangle of A is stored; * = PlasmaLower: Lower triangle of A is stored. * * @param[in,out] A * On entry, the symmetric (or Hermitian) matrix A. * If uplo = PlasmaUpper, the leading N-by-N upper triangular * part of A contains the upper triangular part of the matrix * A, and the strictly lower triangular part of A is not * referenced. * If UPLO = 'L', the leading N-by-N lower triangular part of * A contains the lower triangular part of the matrix A, and * the strictly upper triangular part of A is not referenced. * On exit, if jobz = PlasmaVec, then if return value = 0, A * contains the orthonormal eigenvectors of the matrix A. * If jobz = PlasmaNoVec, then on exit the lower triangle (if * uplo = PlasmaLower) or the upper triangle (if uplo = * PlasmaUpper) of A, including the diagonal, is destroyed.* * * @param[out] W * On exit, if info = 0, the eigenvalues. * * @param[in,out] T * On entry, descriptor as return by * PLASMA_Alloc_Workspace_zheevd * On exit, contains auxiliary factorization data. * * @param[out] Q * On exit, if jobz = PlasmaVec and info = 0, the eigenvectors. * * @param[in] LDQ * The leading dimention of the eigenvectors matrix Q. LDQ >= max(1,N). * ******************************************************************************* * * @return * \retval PLASMA_SUCCESS successful exit * \retval <0 if -i, the i-th argument had an illegal value * \retval >0 if INFO = i, the algorithm failed to converge; i * off-diagonal elements of an intermediate tridiagonal * form did not converge to zero. * ******************************************************************************* * * @sa PLASMA_zheevd_Tile * @sa PLASMA_zheevd_Tile_Async * @sa PLASMA_cheevd * @sa PLASMA_dsyev * @sa PLASMA_ssyev * ******************************************************************************/ int PLASMA_zheevd_Tile(PLASMA_enum jobz, PLASMA_enum uplo, PLASMA_desc *A, double *W, PLASMA_desc *T, PLASMA_Complex64_t *Q, int LDQ) { plasma_context_t *plasma; PLASMA_sequence *sequence = NULL; PLASMA_request request = PLASMA_REQUEST_INITIALIZER; int status; plasma = plasma_context_self(); if (plasma == NULL) { plasma_fatal_error("PLASMA_zheevd_Tile", "PLASMA not initialized"); return PLASMA_ERR_NOT_INITIALIZED; } plasma_sequence_create(plasma, &sequence); PLASMA_zheevd_Tile_Async(jobz, uplo, A, W, T, Q, LDQ, sequence, &request); plasma_dynamic_sync(); status = sequence->status; plasma_sequence_destroy(plasma, sequence); return status; } /***************************************************************************//** * * @ingroup PLASMA_Complex64_t_Tile_Async * * PLASMA_zheevd_Tile_Async - Computes all eigenvalues and, * optionally, eigenvectors of a complex Hermitian matrix A using a * two-stage approach: * First stage: reduction to band tridiagonal form; * Second stage: reduction from band to tridiagonal form. * * May return before the computation is finished. * Allows for pipelining of operations at runtime. * ******************************************************************************* * * @param[in] jobz * Intended usage: * = PlasmaNoVec: computes eigenvalues only; * = PlasmaVec: computes eigenvalues and eigenvectors. * * @param[in] uplo * Specifies whether the matrix A is upper triangular or * lower triangular: * = PlasmaUpper: Upper triangle of A is stored; * = PlasmaLower: Lower triangle of A is stored. * * @param[in,out] A * On entry, the symmetric (or Hermitian) matrix A. * If uplo = PlasmaUpper, the leading N-by-N upper triangular * part of A contains the upper triangular part of the matrix * A, and the strictly lower triangular part of A is not * referenced. * If UPLO = 'L', the leading N-by-N lower triangular part of * A contains the lower triangular part of the matrix A, and * the strictly upper triangular part of A is not referenced. * On exit, if jobz = PlasmaVec, then if return value = 0, A * contains the orthonormal eigenvectors of the matrix A. * If jobz = PlasmaNoVec, then on exit the lower triangle (if * uplo = PlasmaLower) or the upper triangle (if uplo = * PlasmaUpper) of A, including the diagonal, is destroyed.* * * @param[out] W * On exit, if info = 0, the eigenvalues. * * @param[in,out] T * On entry, descriptor as return by * PLASMA_Alloc_Workspace_zheevd * On exit, contains auxiliary factorization data. * * @param[out] Q * On exit, if jobz = PlasmaVec and info = 0, the eigenvectors. * * @param[in] LDQ * The leading dimention of the eigenvectors matrix Q. LDQ >= max(1,N). * * @param[in] sequence * Identifies the sequence of function calls that this call belongs to * (for completion checks and exception handling purposes). * * @param[out] request * Identifies this function call (for exception handling purposes). * ******************************************************************************* * * @sa PLASMA_zheevd * @sa PLASMA_zheevd_Tile * @sa PLASMA_cheevd_Tile_Async * @sa PLASMA_dsyev_Tile_Async * @sa PLASMA_ssyev_Tile_Async * ******************************************************************************/ int PLASMA_zheevd_Tile_Async(PLASMA_enum jobz, PLASMA_enum uplo, PLASMA_desc *A, double *W, PLASMA_desc *T, PLASMA_Complex64_t *Q, int LDQ, PLASMA_sequence *sequence, PLASMA_request *request) { plasma_context_t *plasma; PLASMA_desc descA; PLASMA_desc descT; PLASMA_desc descQ; PLASMA_Complex64_t *AB; double *E; int N; int NB; int LDAB; int status; plasma = plasma_context_self(); if (plasma == NULL) { plasma_fatal_error("PLASMA_zheevd_Tile_Async", "PLASMA not initialized"); return PLASMA_ERR_NOT_INITIALIZED; } if (sequence == NULL) { plasma_fatal_error("PLASMA_zheevd_Tile_Async", "NULL sequence"); return PLASMA_ERR_UNALLOCATED; } if (request == NULL) { plasma_fatal_error("PLASMA_zheevd_Tile_Async", "NULL request"); return PLASMA_ERR_UNALLOCATED; } /* Check sequence status */ if (sequence->status == PLASMA_SUCCESS) request->status = PLASMA_SUCCESS; else return plasma_request_fail(sequence, request, PLASMA_ERR_SEQUENCE_FLUSHED); /* Check descriptors for correctness */ if (plasma_desc_check(A) != PLASMA_SUCCESS) { plasma_error("PLASMA_zheevd_Tile_Async", "invalid descriptor"); return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE); } else { descA = *A; } if (plasma_desc_check(T) != PLASMA_SUCCESS) { plasma_error("PLASMA_zheevd_Tile_Async", "invalid descriptor"); return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE); } else { descT = *T; } /* Check input arguments */ if (jobz != PlasmaNoVec && jobz != PlasmaVec) { plasma_error("PLASMA_zheevd_Tile_Async", "illegal value of jobz"); return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE); } if (uplo != PlasmaLower && uplo != PlasmaUpper) { plasma_error("PLASMA_zheevd_Tile_Async", "illegal value of uplo"); return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE); } if (descA.m != descA.n) { plasma_error("PLASMA_zheevd_Tile_Async", "matrix need to be square"); return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE); } if (descA.nb != descA.mb) { plasma_error("PLASMA_zheevd_Tile_Async", "only square tiles supported"); return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE); } N = descA.m; NB = min(descA.mb,descA.m); LDAB = 2*NB+1; /* Allocate workspace for band storage of the band matrix A and for the off diagonal after tridiagonalisation */ AB = (PLASMA_Complex64_t *)plasma_shared_alloc(plasma, LDAB*N, PlasmaComplexDouble); memset( AB, 0, LDAB * N * sizeof(PLASMA_Complex64_t) ); if (AB == NULL) { plasma_error("PLASMA_zheevd_Tile_Async", "plasma_shared_alloc(AB) failed"); plasma_shared_free(plasma, AB); return PLASMA_ERR_OUT_OF_RESOURCES; } E = (double *)plasma_shared_alloc(plasma, N, PlasmaRealDouble); if (E == NULL) { plasma_error("PLASMA_zheevd_Tile_Async", "plasma_shared_alloc(E) failed"); plasma_shared_free(plasma, E); return PLASMA_ERR_OUT_OF_RESOURCES; } #if defined(ENABLE_TIMER) PLASMA_Double_t timelpk=0.0,timeaplQ2=0.0, timeT=0.0; PLASMA_Double_t timeB=0.0,timeblg=0.0,timeaplQ1=0.0,timeconv1=0.0,timeconv2=0.0,timeall=0.0; timeall = PLASMA_Wtime(); timeB = PLASMA_Wtime(); #endif /* Reduction to tridiagonal form * with a two-stage approach. */ /*======================================= * calling Reduction to BAND * then convert matrix to band form *=======================================*/ plasma_dynamic_call_5(plasma_pzhetrd_he2hb, PLASMA_enum, uplo, PLASMA_desc, descA, PLASMA_desc, descT, PLASMA_sequence*, sequence, PLASMA_request*, request); plasma_dynamic_call_6( plasma_pzhbcpy_t2bl, PLASMA_enum, uplo, PLASMA_desc, descA, PLASMA_Complex64_t*, AB, int, LDAB, PLASMA_sequence*, sequence, PLASMA_request*, request); plasma_dynamic_sync(); status = sequence->status; if (status != PLASMA_SUCCESS) { plasma_error("PLASMA_zheevd","pzhetrd_he2hb+pzcopy"); return status; } /*======================================= * END of calling Reduction to BAND *=======================================*/ #if defined(ENABLE_TIMER) timeB = PLASMA_Wtime()-timeB; printf("\n Finish Band red timing= %lf \n",timeB); #endif /*======================================= * calling bulge chasing *=======================================*/ PLASMA_Complex64_t *TAU2 = NULL; PLASMA_Complex64_t *V2 = NULL; PLASMA_Complex64_t *T2 = NULL; int Vblksiz, blkcnt, LDT, LDV; int WANTZ = 0; int blguplo = PlasmaLower; /* int NE = N; // for later use when a portion of the eigenvectors are requested*/ if( jobz == PlasmaNoVec ) WANTZ=0; else WANTZ=2; /* Vblksiz correspond to the blocking used when applying V2 to the matrix Q * it is similar to IB in LAPACK ZUNMQR. * blkcnt is the number of losange or tile of Vs */ /* Note that in case PlamaVec requested, the V2 and T2 are stored by the * bulgechasing function in a special format: * for V2s: it store the V2(LDV,Vblksiz) of each losange in a tile storage meaning * that V2_1 is stored then V2_2,..., V2_blkcnt. * blkcnt is the number of losange. * */ Vblksiz = min(NB,48); LDT = Vblksiz; if( jobz == PlasmaVec ) { findVTsiz(N, NB, Vblksiz, &blkcnt, &LDV); TAU2 = (PLASMA_Complex64_t *) plasma_shared_alloc(plasma, blkcnt*Vblksiz, PlasmaComplexDouble); V2 = (PLASMA_Complex64_t *) plasma_shared_alloc(plasma, LDV*blkcnt*Vblksiz, PlasmaComplexDouble); T2 = (PLASMA_Complex64_t *) plasma_shared_alloc(plasma, LDT*blkcnt*Vblksiz, PlasmaComplexDouble); if ( (TAU2 == NULL) || (V2 == NULL) || (T2 == NULL) ) { plasma_error("PLASMA_zheevd", "plasma_shared_alloc() failed"); plasma_shared_free(plasma, TAU2); plasma_shared_free(plasma, V2); plasma_shared_free(plasma, T2); return PLASMA_ERR_OUT_OF_RESOURCES; } memset(TAU2, 0, blkcnt*Vblksiz*sizeof(PLASMA_Complex64_t)); memset(V2, 0, LDV*blkcnt*Vblksiz*sizeof(PLASMA_Complex64_t)); memset(T2, 0, LDT*blkcnt*Vblksiz*sizeof(PLASMA_Complex64_t)); } else { TAU2 = (PLASMA_Complex64_t *) plasma_shared_alloc(plasma, 2*N, PlasmaComplexDouble); V2 = (PLASMA_Complex64_t *) plasma_shared_alloc(plasma, 2*N, PlasmaComplexDouble); if ( (TAU2 == NULL) || (V2 == NULL) ) { plasma_error("PLASMA_zheevd", "plasma_shared_alloc() failed"); plasma_shared_free(plasma, TAU2); plasma_shared_free(plasma, V2); return PLASMA_ERR_OUT_OF_RESOURCES; } memset(TAU2, 0, 2*N*sizeof(PLASMA_Complex64_t)); memset(V2, 0, 2*N*sizeof(PLASMA_Complex64_t)); } #if defined(ENABLE_TIMER) timeblg = PLASMA_Wtime(); #endif plasma_static_call_13(plasma_pzhetrd_hb2st_v1, PLASMA_enum, blguplo, int, N, int, NB, int, Vblksiz, PLASMA_Complex64_t*, AB, int, LDAB, PLASMA_Complex64_t*, V2, PLASMA_Complex64_t*, TAU2, double*, W, double*, E, int, WANTZ, PLASMA_sequence*, sequence, PLASMA_request*, request); /* WARNING: If plasma_pzhetrd_hb2st is implemented through a dynamic call, don't * forget to synchronize */ plasma_dynamic_sync(); /*======================================= * END of calling bulge chasing *=======================================*/ #if defined(ENABLE_TIMER) timeblg = PLASMA_Wtime()-timeblg; printf(" Finish Bulge timing= %lf \n" ,timeblg); timelpk = PLASMA_Wtime(); #endif /*======================================= * calling eigensolver *=======================================*/ /* call eigensolver using lapack routine for our resulting tridiag [D E] */ plasma_setlapack_multithreads(plasma->world_size); /* status = LAPACKE_zstevd( LAPACK_COL_MAJOR, lapack_const(jobz), N, W, E, Q, LDQ ); */ if(jobz == PlasmaNoVec){ status = LAPACKE_zstedc( LAPACK_COL_MAJOR, lapack_const(PlasmaNoVec), N, W, E, Q, LDQ ); } else { status = LAPACKE_zstedc( LAPACK_COL_MAJOR, lapack_const(PlasmaIvec), N, W, E, Q, LDQ ); } if(status != 0){ plasma_error("PLASMA_zstedc","ZSTEDC"); return status; } sequence->status = status; plasma_setlapack_sequential(plasma); /*======================================= * END of calling eigensolver *=======================================*/ #if defined(ENABLE_TIMER) timelpk = PLASMA_Wtime()-timelpk; printf(" Finish Eigensolver timing= %lf WANTZ %d threads %d\n" ,timelpk, WANTZ, plasma->world_size); #endif if (jobz == PlasmaVec){ /*======================================= * apply Q2 from the bulge *=======================================*/ /* compute T2 */ #if defined(ENABLE_TIMER) timeT = PLASMA_Wtime(); #endif plasma_static_call_8(plasma_pzlarft_blgtrd, int, N, int, NB, int, Vblksiz, PLASMA_Complex64_t*, V2, PLASMA_Complex64_t*, T2, PLASMA_Complex64_t*, TAU2, PLASMA_sequence*, sequence, PLASMA_request*, request); #if defined(ENABLE_TIMER) plasma_dynamic_sync(); timeT = PLASMA_Wtime()-timeT; printf(" Finish compute T2 timing= %lf \n" ,timeT); timeaplQ2 = PLASMA_Wtime(); #endif /* apply Q2 from Left */ plasma_static_call_14(plasma_pzunmqr_blgtrd, PLASMA_enum, PlasmaLeft, PLASMA_enum, PlasmaNoTrans, int, N, int, NB, int, N, int, Vblksiz, int, WANTZ, PLASMA_Complex64_t*, V2, PLASMA_Complex64_t*, T2, PLASMA_Complex64_t*, TAU2, PLASMA_Complex64_t*, Q, int, LDQ, PLASMA_sequence*, sequence, PLASMA_request*, request); #if defined(ENABLE_TIMER) plasma_dynamic_sync(); timeaplQ2 = PLASMA_Wtime()-timeaplQ2; printf(" Finish compute Q2 timing= %lf \n" ,timeaplQ2); #endif /*======================================= * apply Q1 from the reduction to band *=======================================*/ /* CASE NB>N, Q1 doesn't need to be applied, only bulge chasing has been done */ if( NB < N ){ #if defined(ENABLE_TIMER) plasma_dynamic_sync(); timeconv1 = PLASMA_Wtime(); #endif if ( PLASMA_TRANSLATION == PLASMA_OUTOFPLACE ) { plasma_zooplap2tile( descQ, Q, NB, NB, LDQ, N, 0, 0, N, N, sequence, request, plasma_desc_mat_free(&(descQ)) ); }else { plasma_ziplap2tile( descQ, Q, NB, NB, LDQ, N, 0, 0, N, N, sequence, request ); } #if defined(ENABLE_TIMER) timeconv1 = PLASMA_Wtime()-timeconv1; timeaplQ1 = PLASMA_Wtime(); #endif /* Accumulate the transformations from the first stage */ if(uplo==PlasmaLower){ plasma_dynamic_call_7(plasma_pzunmqr, PLASMA_enum, PlasmaLeft, PLASMA_enum, PlasmaNoTrans, PLASMA_desc, plasma_desc_submatrix(descA, descA.mb, 0, descA.m-descA.mb, descA.n-descA.nb), PLASMA_desc, plasma_desc_submatrix(descQ, descQ.mb, 0, descQ.m-descQ.mb, descQ.n), PLASMA_desc, plasma_desc_submatrix(descT, descT.mb, 0, descT.m-descT.mb, descT.n-descT.nb), PLASMA_sequence*, sequence, PLASMA_request*, request); } else { plasma_dynamic_call_7(plasma_pzunmlq, PLASMA_enum, PlasmaLeft, PLASMA_enum, PlasmaConjTrans, PLASMA_desc, plasma_desc_submatrix(descA, 0, descA.nb, descA.m-descA.mb, descA.n-descA.nb), PLASMA_desc, plasma_desc_submatrix(descQ, descQ.mb, 0, descQ.m-descQ.mb, descQ.n ), PLASMA_desc, plasma_desc_submatrix(descT, 0, descT.nb, descT.m-descT.mb, descT.n-descT.nb), PLASMA_sequence*, sequence, PLASMA_request*, request); } #if defined(ENABLE_TIMER) plasma_dynamic_sync(); timeaplQ1 = PLASMA_Wtime()-timeaplQ1; printf(" Finish compute Q1 timing= %lf \n" ,timeaplQ1); timeconv2 = PLASMA_Wtime(); #endif if ( PLASMA_TRANSLATION == PLASMA_OUTOFPLACE ) { plasma_zooptile2lap( descQ, Q, NB, NB, LDQ, N, sequence, request ); plasma_dynamic_sync(); plasma_desc_mat_free(&descQ); } else { plasma_ziptile2lap( descQ, Q, NB, NB, LDQ, N, sequence, request ); plasma_dynamic_sync(); } #if defined(ENABLE_TIMER) plasma_dynamic_sync(); timeconv2 = PLASMA_Wtime()-timeconv2; printf(" Finish convert timing= %lf \n" ,timeconv1+timeconv2); #endif } /* END of ( NB < N ) */ } #if defined(ENABLE_TIMER) timeall = PLASMA_Wtime()-timeall; printf(" Finish full eigenproblem threads %d N %d timeall= %lf \n", plasma->world_size, N, timeall); #endif if( jobz == PlasmaVec ) plasma_shared_free(plasma, T2); plasma_shared_free(plasma, V2); plasma_shared_free(plasma, TAU2); plasma_shared_free(plasma, E); plasma_shared_free(plasma, AB); return PLASMA_SUCCESS; }
function results = vl_test_imsmooth(varargin) % VL_TEST_IMSMOOTH vl_test_init ; function s = setup() I = im2double(imread(fullfile(vl_root,'data','spots.jpg'))) ; I = max(min(vl_imdown(I),1),0) ; s.I = single(I) ; function test_pad_by_continuity(s) % Convolving a constant signal padded with continuity does not change % the signal. I = ones(3) ; for ker = {'triangular', 'gaussian'} ker = char(ker) ; J = vl_imsmooth(I, 2, ... 'kernel', ker, ... 'padding', 'continuity') ; vl_assert_almost_equal(J, I, 1e-4, ... 'padding by continutiy with kernel = %s', ker) ; end function test_kernels(s) for ker = {'triangular', 'gaussian'} ker = char(ker) ; for type = {@single, @double} for simd = [0 1] for sigma = [1 2 7] for step = [1 2 3] vl_simdctrl(simd) ; conv = type{1} ; g = equivalent_kernel(ker, sigma) ; J = vl_imsmooth(conv(s.I), sigma, ... 'kernel', ker, ... 'padding', 'zero', ... 'subsample', step) ; J_ = conv(convolve(s.I, g, step)) ; vl_assert_almost_equal(J, J_, 1e-4, ... 'kernel=%s sigma=%f step=%d simd=%d', ... ker, sigma, step, simd) ; end end end end end function g = equivalent_kernel(ker, sigma) switch ker case 'gaussian' W = ceil(4*sigma) ; g = exp(-.5*((-W:W)/(sigma+eps)).^2) ; case 'triangular' W = max(round(sigma),1) ; g = W - abs(-W+1:W-1) ; end g = g / sum(g) ; function I = convolve(I, g, step) if strcmp(class(I),'single') g = single(g) ; else g = double(g) ; end for k=1:size(I,3) I(:,:,k) = conv2(g,g,I(:,:,k),'same'); end I = I(1:step:end,1:step:end,:) ;
State Before: case zero Ξ± Ξ² : Type u a : Cardinal ⊒ Nat.zero β€’ a < β„΅β‚€ ↔ Nat.zero = 0 ∨ a < β„΅β‚€ State After: no goals Tactic: simpa using nat_lt_aleph0 0 State Before: case succ Ξ± Ξ² : Type u a : Cardinal n : β„• ⊒ Nat.succ n β€’ a < β„΅β‚€ ↔ Nat.succ n = 0 ∨ a < β„΅β‚€ State After: case succ Ξ± Ξ² : Type u a : Cardinal n : β„• ⊒ Nat.succ n β€’ a < β„΅β‚€ ↔ a < β„΅β‚€ Tactic: simp only [Nat.succ_ne_zero, false_or_iff] State Before: case succ Ξ± Ξ² : Type u a : Cardinal n : β„• ⊒ Nat.succ n β€’ a < β„΅β‚€ ↔ a < β„΅β‚€ State After: case succ.zero Ξ± Ξ² : Type u a : Cardinal ⊒ Nat.succ Nat.zero β€’ a < β„΅β‚€ ↔ a < β„΅β‚€ case succ.succ Ξ± Ξ² : Type u a : Cardinal n : β„• ih : Nat.succ n β€’ a < β„΅β‚€ ↔ a < β„΅β‚€ ⊒ Nat.succ (Nat.succ n) β€’ a < β„΅β‚€ ↔ a < β„΅β‚€ Tactic: induction' n with n ih State Before: case succ.succ Ξ± Ξ² : Type u a : Cardinal n : β„• ih : Nat.succ n β€’ a < β„΅β‚€ ↔ a < β„΅β‚€ ⊒ Nat.succ (Nat.succ n) β€’ a < β„΅β‚€ ↔ a < β„΅β‚€ State After: no goals Tactic: rw [succ_nsmul, add_lt_aleph0_iff, ih, and_self_iff] State Before: case succ.zero Ξ± Ξ² : Type u a : Cardinal ⊒ Nat.succ Nat.zero β€’ a < β„΅β‚€ ↔ a < β„΅β‚€ State After: no goals Tactic: simp
Require Import SpecCert.x86.Architecture. Require Import SpecCert.Address. Definition receive_interrupt_post {Label: Type} (i: Interrupt) (a a':Architecture Label) := let p' := receive_interrupt (proc a) i in a' = update_proc a p'.
# # ---------- Group Arithmetics ---------- # InstallMethod(Subword, "Subword of a unipotent element by total degree of coefficients", [IsUnipotent,IsPosInt], function(u,degree) local sys, coeffs,poly_degree; sys:=chevalleyAdj(u); if not IsPolynomialRing(ring(sys)) then Error("Subword: The ring is not a polynomial ring to evaluate!\n"); fi; coeffs:=Filtered(coefficients(u),i->TotalDegree(i[2])=degree); return Unipotent(sys,coeffs,Ordering(u)); end); # # ---------- Algebraic Operations ---------- # InstallMethod(Value, "Evaluation of the parameter polynomials", [IsUnipotent,IsList,IsList], function(u,vars,vals) local sys, lista,i,len; sys:=chevalleyAdj(u); if not IsPolynomialRing(ring(sys)) then Error("Value: The ring is not a polynomial ring to evaluate."); fi; lista:=List(coefficients(u),i->[i[1],One(ring(sys))*Value(i[2],vars,vals)]); i:=1; len:=Length(lista); while i <= len do if lista[i][2]=Zero(ring(sys)) then Remove(lista,i); len:=len-1; else i:=i+1; fi; od; return Unipotent(sys,lista,Ordering(u)); #return Unipotent(chevalleyAdj(sys),lista,Ordering(u)); # which one is better? I multiply by One(ring(sys)) end); InstallMethod(Descend, "Changes the parameters from the polynomial ring to the coefficients ring", [IsUnipotent], function(u) local sys, check; sys:=chevalleyAdj(u); if not IsPolynomialRing(ring(sys)) then Error("The ring is not a polynomial ring to evaluate."); fi; if IsAlgebraicU(sys) then sys:=chevalleyAdj(u); else sys:=ChevalleyAdj(sys,CoefficientsRing(ring(sys))); fi; check:=List(coefficients(u),i->LeadingMonomial(i[2])); check:=List(check,i->Sum(i{2*[1..Length(i)/2]})); check:=Filtered(check,i->i<>0); if check=[] then return Unipotent(sys, List(coefficients(u),i->[i[1],LeadingCoefficient(i[2])]), Ordering(u), Order(u)); fi; return fail; end); InstallMethod(Descend, "If possible changes the parameters from the polynomial ring to the coefficients ring", [IsUnipotent,IsChevalleyAdj], function(u,sys) local sysu, check; sysu:=chevalleyAdj(u); if not IsPolynomialRing(ring(sysu)) then Error("The ring is not a polynomial ring to evaluate."); elif CoefficientsRing(ring(sysu))<>ring(sys) then Error("Cannot descend unipotent to given simple adjoint system"); fi; check:=List(coefficients(u),i->LeadingMonomial(i[2])); check:=List(check,i->Sum(i{2*[1..Length(i)/2]})); check:=Filtered(check,i->i<>0); if check=[] then return Unipotent(sys, List(coefficients(u),i->[i[1],LeadingCoefficient(i[2])]), Ordering(u), Order(u)); fi; return u; end); InstallMethod(Ascend, "If possible embed Unipotent into AlgebraicU", [IsUnipotent,IsAlgebraicU], function(u,sys) local sysu, check; if chevalleyAdj(u)<>chevalleyAdj(sys) then Error("Cannot ascend Unipotent to AlgebraicU: different chevalleyAdj!\n"); fi; return Unipotent(sys, List(coefficients(u),i->[i[1],One(ring(sys))*i[2]]), Ordering(u), Order(u)); end); InstallMethod(Ascend, "If possible embed the parameters in a polynomial ring with coefficients ring the base ring", [IsUnipotent,IsChevalleyAdj], function(u,sys) local sysu, check; sysu:=chevalleyAdj(u); if not IsPolynomialRing(ring(sys)) then Error("The new ring is not a polynomial ring to embed in."); elif CoefficientsRing(ring(sys))<>ring(sysu) then Error("CoefficientsRing and ring(sysu) do not coincide."); fi; return Unipotent(sys, List(coefficients(u),i->[i[1],One(ring(sys))*i[2]]), Ordering(u), Order(u)); end); InstallMethod(Ascend, "If possible embed the parameters in a polynomial ring with coefficients ring the base ring", [IsUnipotent,IsPolynomialRing], function(u,inel) local sys, check; sys:=chevalleyAdj(u); if not IsPolynomialRing(inel) then Error("The new ring is not a polynomial ring to embed in."); elif CoefficientsRing(inel)<>ring(sys) then Error("CoefficientsRing and ring(sys) do not coincide."); fi; return Unipotent(ChevalleyAdj(sys,inel), List(coefficients(u),i->[i[1],One(inel)*i[2]]), Ordering(u), Order(u)); end); InstallMethod(UnipotentCentralizer, "Centralizer of unipotent element in algebraicU", [IsUnipotent], function(u) local result, sys,pr,pr_len,uu, APR,avars,avars_free,generic, relations,sol,torsion, i,new_indices; sys:=chevalleyAdj(u); if not IsAlgebraicU(sys) then sys:=AlgebraicU(sys); u:=Ascend(u,sys); fi; pr:=positiveRoots(sys); pr_len:=Length(pr); APR:=ring(sys); avars:=IndeterminatesOfPolynomialRing(APR){[1..pr_len]}; generic:=Unipotent(sys,List([1..pr_len],i->[i,avars[pr_len-i+1]]),[1..pr_len],0); result:=List([1..pr_len],i->avars[i]); torsion:=[]; for i in [2..pr_len] do #relations:=coefficients(CommMod(generic,u,i)); relations:=coefficients(CommMod(u,generic,i)); #!!!ATENTIE CommMod(a,b,i) foloseste Ordering lui b care tre sa fie [1..pr_len] relations:=List(relations,i->i[2]); #Print("\nsolving ",i,": ",relations,"\n"); #if i=8 then Error("!"); fi; sol:=SolveRelations(relations,avars,result,APR); if sol[2]<>[] then Print(" >>>",i," UnipotentCentralizer: could not solve all relations!",relations,"\n"); fi; Add(torsion,sol[3]); result:=sol[1]; result:=List(result,i->i*One(APR)); #Print("result :",result,"\n"); generic:=Unipotent(sys,List([1..pr_len],i->[i,result[pr_len-i+1]]),[1..pr_len],0); od; avars_free:=result{Filtered([1..pr_len],i->result[i] in avars)}; avars_free:=avars_free{Filtered([1..Length(avars_free)],i->not avars_free[i] in avars_free{[1..i-1]})}; new_indices:=Reversed([1..Length(avars_free)]); result:=List(result,i->Value(i,avars_free,avars{new_indices})*One(APR)); generic:=Unipotent(sys,List([1..pr_len],i->[i,result[pr_len-i+1]]),[1..pr_len],0); return [generic,u,Concatenation(torsion),relations]; end); # # # THIS DOES NOT WORK # # InstallMethod(UnipotentCentralizer2, "Centralizer of unipotent element in algebraicU", [IsUnipotent], function(u) local result, sys,pr,pr_len,uu, APR,avars,avars_free,generic, relations,sol,torsion, root_support,other_roots, i,new_indices; sys:=chevalleyAdj(u); if not IsAlgebraicU(sys) then sys:=AlgebraicU(sys); u:=Ascend(u,sys); fi; pr:=positiveRoots(sys); pr_len:=Length(pr); APR:=ring(sys); avars:=IndeterminatesOfPolynomialRing(APR){[1..pr_len]}; root_support:=[]; for i in [1..pr_len] do generic:=Unipotent(sys,[[i,avars[1]]]); generic:=Conj(generic,u); if Length(coefficients(generic))=1 and coefficients(generic)[1][2]=avars[1] then Add(root_support,i); fi; od; other_roots:=Difference([1..pr_len],root_support); #generic:=Unipotent(sys,List([1..pr_len],i->[i,avars[pr_len-i+1]]),[1..pr_len],0); #generic:=Subword(generic,other_roots); generic:=Unipotent(sys,List(other_roots,i->[i,avars[pr_len-i+1]]),[1..pr_len],0); result:=List([1..pr_len],i->avars[i]); for i in root_support do result[pr_len-i+1]:=Zero(APR); od; torsion:=[]; for i in [2..pr_len] do #relations:=coefficients(CommMod(generic,u,i)); relations:=coefficients(CommMod(u,generic,i)); #!!!ATENTIE CommMod(a,b,i) foloseste Ordering lui b care tre sa fie [1..pr_len] relations:=List(relations,i->i[2]); #Print("\nsolving ",i,": ",relations,"\n"); #if i=8 then Error("!"); fi; sol:=SolveRelations(relations,avars,result,APR); if sol[2]<>[] then Print(" >>>",i," UnipotentCentralizer: could not solve all relations!",relations,"\n"); fi; Add(torsion,sol[3]); result:=sol[1]; result:=List(result,i->i*One(APR)); #Print("result :",result,"\n"); generic:=Unipotent(sys,List([1..pr_len],i->[i,result[pr_len-i+1]]),[1..pr_len],0); od; Error("!"); for i in root_support do result[pr_len-i+1]:=avars[pr_len-i+1]; od; avars_free:=result{Filtered([1..pr_len],i->result[i] in avars)}; avars_free:=avars_free{Filtered([1..Length(avars_free)],i->not avars_free[i] in avars_free{[1..i-1]})}; new_indices:=Reversed([1..Length(avars_free)]); result:=List(result,i->Value(i,avars_free,avars{new_indices})*One(APR)); generic:=Unipotent(sys,List([1..pr_len],i->[i,result[pr_len-i+1]]),[1..pr_len],0); return [generic,u,Concatenation(torsion),relations]; end); InstallMethod(TangentSpace, "Returns a basis of Nilpotents representing for the tangent space", [IsUnipotent], function(u) local result, sysAPR,APR,avars, dim,BPR,xvars, order,exp,vals,tmp,tmp_len,i,j,monoms; sysAPR:=chevalleyAdj(u); APR:=ring(sysAPR); avars:=IndeterminatesOfPolynomialRing(APR){[1..Length(positiveRoots(sysAPR))]}; dim:=Length(Set(List(Filtered(coefficients(u),i->i[2] in avars),j->j[2]))); avars:=avars{[1..dim]}; vals:=List([1..dim],i->Zero(APR)); result:=[]; for i in [1..dim] do vals[i]:=avars[1]; tmp:=Value(u,avars,vals); #SetOrder(tmp,Order(u)); tmp:=ShallowCopy(coefficients(tmp)); tmp_len:=Length(tmp); j:=1; while j <= tmp_len do monoms:=ExtRepPolynomialRatFun(tmp[j][2]); monoms:=List(2*[1..Length(monoms)/2]-1,i->[monoms[i],monoms[i+1]]); monoms:=Filtered(monoms,i->i[1][2]=1); if monoms<>[] then tmp[j]:=[tmp[j][1],monoms[1][2]*One(APR)]; j:=j+1; else Remove(tmp,j); tmp_len:=tmp_len-1; fi; od; Add(result,tmp); vals[i]:=Zero(APR); od; result:=List(result,i->NilpotentChv(sysAPR,i)); return result; end); InstallMethod(Zentrum, "Centre of connected unipotent algebraic group", [IsUnipotent], function(u) local result, APR,avars, relations, tang,adu_res,unu; APR:=ring(chevalleyAdj(u)); avars:=IndeterminatesOfPolynomialRing(APR); avars:=Filtered(coefficients(u),i->i[2] in avars); avars:=Set(List(avars,i->i[2])); tang:=TangentSpace(u); #Error("!"); adu_res:=RestrictedAdu(u,tang); unu:=DiagonalMat(List([1..Length(avars)],i->One(APR))); relations:=Concatenation(adu_res-unu); relations:=Filtered(relations,i->i<>Zero(APR)); #return relations; #Print(avars," with ",relations,"\n"); result:=SolveRelations(relations,avars,avars,APR); if result[2]<>[] then Print("Zentrum: could not solve all relations! ",result[2],"\n"); fi; return Value(u,avars,result[1]); end); InstallMethod(ParameterPieces, "Subvarieties for each parameter", [IsUnipotent], function(u) local result, sysAPR,APR,avars,avar, dim,BPR,xvars, order,exp,vals,tmp,tmp_len,i,j,monoms; sysAPR:=chevalleyAdj(u); APR:=ring(sysAPR); avars:=IndeterminatesOfPolynomialRing(APR){[1..Length(positiveRoots(sysAPR))]}; avar:=avars[1]; avars:=Set(List(Filtered(coefficients(u),i->i[2] in avars),j->j[2])); Sort(avars,function(a,b) return ExtRepPolynomialRatFun(a)[1][1]<ExtRepPolynomialRatFun(b)[1][1]; end); dim:=Length(avars); #avars:=avars{[1..dim]}; vals:=List([1..dim],i->Zero(APR)); result:=[]; for i in [1..dim] do vals[i]:=avar;#avars[1]; tmp:=Value(u,avars,vals); #Print(coefficients(tmp)); #SetOrder(tmp,Order(u)); tmp:=ShallowCopy(coefficients(tmp)); tmp_len:=Length(tmp); Add(result,tmp); vals[i]:=Zero(APR); od; result:=List(result,i->Unipotent(sysAPR,i,Ordering(u),-2)); return result; end); InstallMethod(Dimension, "Dimension of subvariety in unipotent group", [IsUnipotent], function(u) local avars_free; avars_free:=List(coefficients(u),i->i[2]); avars_free:=List(avars_free,i->ExtRepPolynomialRatFun(i)); avars_free:=Concatenation(avars_free); avars_free:=avars_free{2*[1..Length(avars_free)/2]-1}; avars_free:=Concatenation(avars_free); avars_free:=avars_free{2*[1..Length(avars_free)/2]-1}; return Length(Set(avars_free)); end); # # ---------- Witt Group Operations ---------- # InstallMethod(GenericWittGroup, "Witt group with generic polynomials along the unipotent group gr", [IsUnipotent,IsWitt,IsList], function(gr,w,values) local result, coeffs, APR,avars,avars_free,avars_free_len,avars_ext, BPR,bvars, CPR,cvarnames,cvars, poly,monom,i,j,k,pos; coeffs:=coefficients(gr); # APR's APR:=ring(chevalleyAdj(gr)); avars:=IndeterminatesOfPolynomialRing(APR); avars_free:=Filtered(coeffs,i->i[2] in avars); avars_free:=Set(List(avars_free,i->i[2])); Sort(avars_free,function(a,b) return ExtRepPolynomialRatFun(a)[1][1]<ExtRepPolynomialRatFun(b)[1][1]; end); avars_free_len:=Length(avars_free); avars_ext:=List(avars_free,i->ExtRepPolynomialRatFun(i)); avars_ext:=List(avars_ext,i->i[1][1]); # BPR's BPR:=ring(chevalleyAdjBPR(w)); # CPR's cvarnames:=List([1..avars_free_len],i->Concatenation("c_",String(i))); CPR:=PolynomialRing(BPR,cvarnames); cvars:=IndeterminatesOfPolynomialRing(CPR); coeffs:=List(coeffs,i->[i[1],List(ExtRepPolynomialRatFun(i[2]))]); result:=[]; for i in [1..Length(coeffs)] do poly:=Zero(CPR); for j in [1..Length(coeffs[i][2])/2] do monom:=One(CPR); for k in [1..Length(coeffs[i][2][2*j-1])/2] do pos:=Position(avars_ext,coeffs[i][2][2*j-1][2*k-1]); monom:=monom*cvars[pos]^coeffs[i][2][2*j-1][2*k]; od; monom:=monom*((coeffs[i][2][2*j]*One(APR))*One(BPR)); poly:=poly+monom; od; Add(result,[coeffs[i][1],poly]); od; result:=List(result,i->[i[1],Value(i[2],cvars,values)]); return Unipotent(chevalleyAdjBPR(w),result,Ordering(gr),-2); end); InstallMethod(SolveWittRoot, "Solution for witt group construction at certain root", [IsUnipotent,IsWitt,IsPosInt,IsList,IsInt], function(wx,w,root,values,step) local result, APR,avars,avars_free,avars_free_len, BPR,dim,xvar,yvar,wy, gws,gen_poly,gen_poly_len,xy_poly,total_degree,relations,i; gws:=GenericSum(w); # BPR's BPR:=ring(chevalleyAdjBPR(w)); dim:=Dimension(w); xvar:=IndeterminatesOfPolynomialRing(BPR){[1..dim]}; yvar:=IndeterminatesOfPolynomialRing(BPR){dim+[1..dim]}; wy:=Value(wx,xvar,yvar); xy_poly:=coefficients(Subword(wx*wy,[root])); if xy_poly=[] then return [Zero(BPR),values,step]; else xy_poly:=xy_poly[1][2]; fi; # APR's APR:=ring(algebraicU(w)); avars:=IndeterminatesOfPolynomialRing(APR); result:=ShallowCopy(values); # construct generic polynomial total_degree:=TotalDegree(xy_poly); gen_poly:=Concatenation(GenericLevelPolynomials(w){[1..total_degree]}); gen_poly_len:=Length(gen_poly); gen_poly:=Sum(List([1..gen_poly_len],i->result[step+i]*gen_poly[i])); # contruct relations relations:=Value(gen_poly,xvar,gws)-gen_poly-Value(gen_poly,xvar,yvar)-xy_poly; relations:=ExtRepPolynomialRatFun(relations); relations:=relations{2*[1..Length(relations)/2]}; # solve relations result:=SolveRelations(relations,avars,result,APR); if result[2]<>[] then Error("SolveWittRoot: coulde not solve all relations!"); return fail; fi; result:=result[1]; # rearrange free variables avars_free:=Filtered([1..gen_poly_len+step],i->result[i] in avars); avars_free:=result{avars_free}; avars_free_len:=Length(avars_free); # result:=List(result,i->i*One(APR)); # result:=List(result,i->Value(i,avars_free,avars{[1..avars_free_len]})*One(APR)); gen_poly:=Concatenation(GenericLevelPolynomials(w){[1..total_degree]}); gen_poly:=Sum(List([1..Length(gen_poly)],i->result[i+step]*gen_poly[i])); return [gen_poly,result,step+gen_poly_len]; end); InstallMethod(WittGroup, "Witt group of unipotent inside group", [IsUnipotent,IsUnipotent,IsWitt], function(u,centralizer,w) local result,u_ordered, APR,avars,avars_free,avars_ext, BPR,dim,xvars,xvars_ext, coeffs, i,j,k,pos,sol,step,values,update_poly,monom, wg; # APR's #APR:=ring(algebraicU(w)); asta de ce nu merge? APR:=ring(chevalleyAdj(u)); avars:=IndeterminatesOfPolynomialRing(APR); # BPR's BPR:=ring(chevalleyAdjBPR(w)); dim:=Dimension(w); xvars:=IndeterminatesOfPolynomialRing(BPR){[1..dim]}; # centralizer #centralizer:=UnipotentCentralizer(algebraicAdj(w),u,distP); avars_free:=Set(List(Filtered(coefficients(centralizer),i->i[2] in avars),j->j[2])); Sort(avars_free,function(a,b) return ExtRepPolynomialRatFun(a)[1][1]<ExtRepPolynomialRatFun(b)[1][1]; end); avars_ext:=List(avars_free,i->ExtRepPolynomialRatFun(i)); avars_ext:=List(avars_ext,i->i[1][1]); result:=List(avars_free,i->Zero(BPR)); coeffs:=coefficients(centralizer); u_ordered:=Unipotent(chevalleyAdj(u),#algebraicU(w), asta de ce nu merge? coefficients(u),#coefficients(Ascend(u,simpleAdjAPR(algebraicAdj(w)))), [1..Length(positiveRoots(chevalleyAdjBPR(w)))], -2); for i in coefficients(u_ordered) do k:=Filtered(coeffs,j->j[1]=i[1]); if k = [] then return fail; fi; k:=k[1]; if k[2] in avars_free then pos:=Position(avars_free,k[2]); result[pos]:=xvars[1]; fi; od; wg:=GenericWittGroup(centralizer,w,result); # function for handeling free variables udpate xvars_ext:=List(xvars,i->ExtRepPolynomialRatFun(i)); xvars_ext:=List(xvars_ext,i->i[1][1]); update_poly:=function(poly,values) local result, monom,ext,j,k,pos; result:=Zero(BPR); ext:=ExtRepPolynomialRatFun(poly); for j in [1..Length(ext)/2] do monom:=One(BPR); for k in [1..Length(ext[2*j-1])/2] do pos:=Position(xvars_ext,ext[2*j-1][2*k-1]); monom:=monom*xvars[pos]^ext[2*j-1][2*k]; od; monom:=monom*(Value(ext[2*j],avars,values)*One(APR)); result:=result+monom; od; return result; end; values:=ShallowCopy(avars); step:=0; for i in coeffs do if i[2] in avars_free then pos:=Position(avars_free,i[2]); if result[pos]=Zero(BPR) then # value of free variable sol:=SolveWittRoot(wg,w,i[1],values,step); #if sol=fail then return fail; fi; values:=sol[2]; step:=sol[3]; # update the construction made so far result:=List(result,i->update_poly(i,values)); # set free variable result[pos]:=sol[1]; # rebuild group wg:=GenericWittGroup(centralizer,w,result); fi; fi; od; return wg; end); InstallMethod(TestWittGroup, "Test if the given unipotent element has the structure of a given witt group", [IsUnipotent,IsWitt], function(ux,w) local dim,p,BPR,xvar,yvar, uy,uxy,xcoeff,xycoeff, gws,i; dim:=Dimension(w); BPR:=ring(chevalleyAdjBPR(w)); xvar:=IndeterminatesOfPolynomialRing(BPR){[1..dim]}; yvar:=IndeterminatesOfPolynomialRing(BPR){dim+[1..dim]}; uy:=Value(ux,xvar,yvar); gws:=GenericSum(w); uxy:=ux*uy; for i in [1..Length(positiveRoots(chevalleyAdj(ux)))] do xcoeff:=coefficients(Subword(ux,[i])); xycoeff:=coefficients(Subword(uxy,[i])); if xcoeff=[] and xycoeff<>[] then return i; elif xcoeff<>[] and xycoeff=[] then return i; elif xcoeff<>[] and xycoeff<>[] and Value(xcoeff[1][2],xvar,gws)<>xycoeff[1][2] then return i; fi; od; return true; end); InstallMethod(WittDecomposition, "Decomposition of abelian algebraic group into witt group factors", [IsUnipotent,IsWitt], function(abelian,w) local result, APR,avars,p,vals,i,tmp,dim,exp, handled,support; APR:=ring(chevalleyAdj(abelian)); avars:=IndeterminatesOfPolynomialRing(APR); avars:=Filtered(coefficients(abelian),i->i[2] in avars); avars:=Set(List(avars,i->i[2])); Sort(avars,function(a,b) return ExtRepPolynomialRatFun(a)[1][1]<ExtRepPolynomialRatFun(b)[1][1]; end); dim:=Length(avars); # Print("dim=",dim,"\n"); p:=Characteristic(APR); exp:=Maximum(List(ParameterPieces(abelian),i->OrderOp(i))); exp:=LogInt(exp,p); vals:=List([1..dim],i->Zero(APR)); result:=[]; handled:=[]; for i in [1..dim] do vals[i]:=One(APR);#avars[1]; tmp:=Value(abelian,avars,vals); support:=List(coefficients(tmp),i->i[1]); if not IsSubset(handled,support) then #tmp:=WittGr(tmp,abelian,w[LogInt(OrderOp(tmp),p)]); tmp:=WittGroup(tmp,abelian,w); Add(result,tmp); support:=List(coefficients(tmp),i->i[1]); handled:=Concatenation(handled,support); fi; vals[i]:=Zero(APR); od; # result:=List(result,i->UnipotentLieElement(sysAPR,i,0,ordering(u),1)); return result; end);
abstract type Simulation end function iterate!( sim::Simulation ) move_dogs!( sim.world, sim.dt ) move_sheep!( sim ) work!( sim.world, sim.dt ) sim.time[] += sim.dt end # function function move_sheep!( sim::Simulation ) if sim.time[] >= sim.t_sheep_boredom[] i,j = Tuple(getRandomSheep( sim.world.sheeps )) diffuseSheep!( sim.world.sheeps, i, j ) sim.t_sheep_boredom[] = sim.time[] + rand( Exponential( sim.world.meanSheepDiffusionTime / sim.world.sheeps.current_sheep[] ) ) kickSheep!( sim.world.sheeps ) return true endΒ #Β if return false end # function
[STATEMENT] lemma main_0_Return_reachable [simp]: "(P, C0, Main) \<turnstile> \<Rightarrow>(ClassMain P, MethodMain P, \<lfloor>0\<rfloor>, Return)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (P, C0, Main) \<turnstile> \<Rightarrow>(ClassMain P, MethodMain P, \<lfloor>0\<rfloor>, nodeType.Return) [PROOF STEP] by (rule reachable_step [where n="(ClassMain P, MethodMain P, \<lfloor>0\<rfloor>, Normal)"], simp) (fastforce intro: JVMCFG_reachable.intros)
lemma emeasure_lborel_UNIV [simp]: "emeasure lborel (UNIV::'a::euclidean_space set) = \<infinity>"
lemma dist_triangle_third: assumes "dist x1 x2 < e/3" "dist x2 x3 < e/3" "dist x3 x4 < e/3" shows "dist x1 x4 < e"
(************************************************************************) (* *) (* Micromega: A reflexive tactic using the Positivstellensatz *) (* *) (* FrΓ©dΓ©ric Besson (Irisa/Inria) 2006-2008 *) (* *) (************************************************************************) Require Import ZArith Zwf Psatz QArith. Open Scope Z_scope. Lemma Zabs_square : forall x, (Zabs x)^2 = x^2. Proof. intros ; case (Zabs_dec x) ; intros ; psatz Z 2. Qed. Hint Resolve Zabs_pos Zabs_square. Lemma integer_statement : ~exists n, exists p, n^2 = 2*p^2 /\ n <> 0. Proof. intros [n [p [Heq Hnz]]]; pose (n' := Zabs n); pose (p':=Zabs p). assert (facts : 0 <= Zabs n /\ 0 <= Zabs p /\ Zabs n^2=n^2 /\ Zabs p^2 = p^2) by auto. assert (H : (0 < n' /\ 0 <= p' /\ n' ^2 = 2* p' ^2)) by (destruct facts as [Hf1 [Hf2 [Hf3 Hf4]]]; unfold n', p' ; psatz Z 2). generalize p' H; elim n' using (well_founded_ind (Zwf_well_founded 0)); clear. intros n IHn p [Hn [Hp Heq]]. assert (Hzwf : Zwf 0 (2*p-n) n) by (unfold Zwf; psatz Z 2). assert (Hdecr : 0 < 2*p-n /\ 0 <= n-p /\ (2*p-n)^2=2*(n-p)^2) by psatz Z 2. apply (IHn (2*p-n) Hzwf (n-p) Hdecr). Qed. Open Scope Q_scope. Lemma QnumZpower : forall x : Q, Qnum (x ^ 2)%Q = ((Qnum x) ^ 2) %Z. Proof. intros. destruct x. cbv beta iota zeta delta - [Zmult]. ring. Qed. Lemma QdenZpower : forall x : Q, ' Qden (x ^ 2)%Q = ('(Qden x) ^ 2) %Z. Proof. intros. destruct x. simpl. unfold Zpower_pos. simpl. rewrite Pmult_1_r. reflexivity. Qed. Theorem sqrt2_not_rational : ~exists x:Q, x^2==2#1. Proof. unfold Qeq; intros [x p]; revert p; simpl (Qden (2#1)); rewrite Zmult_1_r. intros HQeq. assert (Heq : (Qnum x ^ 2 = 2 * ' Qden x ^ 2%Q)%Z) by (rewrite QnumZpower in HQeq ; rewrite QdenZpower in HQeq ; auto). assert (Hnx : (Qnum x <> 0)%Z) by (intros Hx; simpl in HQeq; rewrite Hx in HQeq; discriminate HQeq). apply integer_statement; exists (Qnum x); exists (' Qden x); auto. Qed.
theory func_cor_OSMemPut imports func_cor_other begin lemma OSMemPut_satRG1: " \<turnstile>\<^sub>I (W\<acute>OS_MEM_info := \<acute>OS_MEM_info(pmem := \<acute>OS_MEM_info pmem\<lparr>OSMemFreeList := pblk # OSMemFreeList (\<acute>OS_MEM_info pmem)\<rparr>);; \<acute>OS_MEM_info := \<acute>OS_MEM_info(pmem := \<acute>OS_MEM_info pmem\<lparr>OSMemNFree := OSMemNFree (\<acute>OS_MEM_info pmem) + 1\<rparr>);; \<acute>ret := \<acute>ret (t := OS_ERR_NONE)) sat\<^sub>p [OSMemPut_pre t \<inter> \<lbrace>pmem \<in> \<acute>OS_MEMs\<rbrace> \<inter> \<lbrace>\<acute>cur = Some t\<rbrace> \<inter> {V} \<inter> {Va} \<inter> - \<lbrace>OSMemNBlks (\<acute>OS_MEM_info pmem) \<le> OSMemNFree (\<acute>OS_MEM_info pmem)\<rbrace>, {(s, t). s = t}, UNIV, \<lbrace>\<acute>(Pair V) \<in> OSMemPut_guar t\<rbrace> \<inter> OSMemPut_post t]" apply (case_tac "OSMemPut_pre t \<inter> \<lbrace>pmem \<in> \<acute>OS_MEMs\<rbrace> \<inter> \<lbrace>\<acute>cur = Some t\<rbrace> \<inter> {V} \<inter> {Va} \<inter> - \<lbrace>OSMemNBlks (\<acute>OS_MEM_info pmem) \<le> OSMemNFree (\<acute>OS_MEM_info pmem)\<rbrace> = {}") using Emptyprecond apply auto[1] apply (simp add: Emptyprecond) apply (rule Seq[where mid = "{V\<lparr>OS_MEM_info := (OS_MEM_info V)(pmem := OS_MEM_info V pmem \<lparr>OSMemFreeList := pblk # OSMemFreeList (OS_MEM_info V pmem), OSMemNFree := OSMemNFree (OS_MEM_info V pmem) + 1\<rparr>)\<rparr>}"]) apply (rule Seq[where mid = " {V\<lparr>OS_MEM_info := (OS_MEM_info V)(pmem := OS_MEM_info V pmem\<lparr>OSMemFreeList := pblk # OSMemFreeList (OS_MEM_info V pmem)\<rparr>)\<rparr>}"]) apply (rule Basic) apply(simp add:OSMemPut_pre_def inv_def) apply (simp add: inv_cur_def) apply (simp add:inv_OS_Mem_info_def inv_OS_Mem_info_mp_def) apply clarify apply (simp add: stable_id2) apply (simp add: stable_id2) using stable_id2 apply blast apply (rule Basic) apply(simp add:OSMemPut_pre_def inv_def) apply (simp add: inv_cur_def) using stable_id2 apply blast using stable_id2 apply blast apply (rule Basic) apply (simp add: OSMemPut_guar_def) apply (case_tac "cur V \<noteq> Some t") apply auto apply (simp add: gvars_conf_stable_def gvars_conf_def) apply (simp add: inv_def inv_cur_def inv_OS_Mem_info_def inv_OS_Mem_info_mp_def inv_thd_waitq_def) apply auto apply meson apply smt apply meson apply (simp add: lvars_nochange_def) apply (simp add: OSMemPut_pre_def OSMemPut_post_def) apply (simp add: inv_def inv_cur_def inv_OS_Mem_info_def inv_OS_Mem_info_mp_def inv_thd_waitq_def) apply auto apply meson apply smt apply meson apply (simp add: stable_id2) by (simp add: stable_id2) lemma OSMemPut_satRG: "\<Gamma> (OSMemPut t pmem pblk) \<turnstile> OSMemPut_RGCond t" apply (simp add:Evt_sat_RG_def) apply (simp add:OSMemPut_def OSMemPut_RGCond_def) apply (rule BasicEvt) apply(simp add:body_def Pre\<^sub>f_def Post\<^sub>f_def guard_def Rely\<^sub>f_def Guar\<^sub>f_def getrgformula_def) apply(unfold stm_def)[1] apply(rule Await) apply (simp add: OSMemPut_pre_def OSMemPut_rely_def gvars_conf_def gvars_conf_stable_def stable_def) apply (simp add: OSMemPut_post_def stable_inv_free_rely1) apply (rule allI) apply(rule Await) apply (simp add: stable_id2) apply (simp add: stable_id2) apply (rule allI) apply (rule Cond) using stable_id2 apply blast apply (rule Basic) apply (simp add: OSMemPut_post_def OSMemPut_guar_def) apply(simp add:gvars_nochange_def lvars_nochange_def) apply(simp add:inv_def inv_cur_def gvars_conf_stable_def) apply(simp add:inv_OS_Mem_info_def inv_OS_Mem_info_mp_def inv_thd_waitq_def) apply auto apply (simp add: gvars_conf_def) using OSMemPut_pre_def inv_cur_def invariant.inv_def apply blast apply (simp add: OSMemPut_pre_def inv_cur_def inv_def) apply (simp add: OSMemPut_pre_def inv_OS_Mem_info_def inv_OS_Mem_info_mp_def inv_def inv_thd_waitq_def) using OSMemPut_pre_def inv_thd_waitq_def invariant.inv_def apply blast apply (simp add: OSMemPut_pre_def inv_thd_waitq_def invariant.inv_def) using OSMemPut_pre_def inv_thd_waitq_def invariant.inv_def apply blast using OSMemPut_pre_def inv_thd_waitq_def invariant.inv_def apply blast using stable_id2 apply blast apply (simp add: stable_id2) using OSMemPut_satRG1 apply simp apply(simp add:body_def Pre\<^sub>f_def Post\<^sub>f_def guard_def Rely\<^sub>f_def Guar\<^sub>f_def getrgformula_def) using OSMemPut_pre_stb apply simp apply (simp add:getrgformula_def OSMemPut_guar_def) apply(simp add:body_def Pre\<^sub>f_def Post\<^sub>f_def guard_def Rely\<^sub>f_def Guar\<^sub>f_def getrgformula_def) done end
(* File: Shift_Operator.thy Author: Manuel Eberl, TU MΓΌnchen *) section \<open>The shift operator on an infinite product measure\<close> theory Shift_Operator imports Ergodicity ME_Library_Complement begin text \<open> Let \<open>P\<close> be an an infinite product of i.i.d. instances of the distribution \<open>M\<close>. Then the shift operator is the map \[T(x_0, x_1, x_2, \ldots) = T(x_1, x_2, \ldots)\ .\] In this section, we define this operator and show that it is ergodic using Kolmogorov's 0--1 law. \<close> locale shift_operator_ergodic = prob_space + fixes T :: "(nat \<Rightarrow> 'a) \<Rightarrow> (nat \<Rightarrow> 'a)" and P :: "(nat \<Rightarrow> 'a) measure" defines "T \<equiv> (\<lambda>f. f \<circ> Suc)" defines "P \<equiv> PiM (UNIV :: nat set) (\<lambda>_. M)" begin sublocale P: product_prob_space "\<lambda>_. M" UNIV by unfold_locales sublocale P: prob_space P by (simp add: prob_space_PiM prob_space_axioms P_def) lemma measurable_T [measurable]: "T \<in> P \<rightarrow>\<^sub>M P" unfolding P_def T_def o_def by (rule measurable_abs_UNIV[OF measurable_compose[OF measurable_component_singleton]]) auto text \<open> The \<open>n\<close>-th tail algebra $\mathcal{T}_n$ is, in some sense, the algebra in which we forget all information about all $x_i$ with \<open>i < n\<close>. We simply change the product algebra of \<open>P\<close> by replacing the algebra for each \<open>i < n\<close> with the trivial algebra that contains only the empty set and the entire space. \<close> definition tail_algebra :: "nat \<Rightarrow> (nat \<Rightarrow> 'a) measure" where "tail_algebra n = PiM UNIV (\<lambda>i. if i < n then trivial_measure (space M) else M)" lemma tail_algebra_0 [simp]: "tail_algebra 0 = P" by (simp add: tail_algebra_def P_def) lemma space_tail_algebra [simp]: "space (tail_algebra n) = PiE UNIV (\<lambda>_. space M)" by (simp add: tail_algebra_def space_PiM PiE_def Pi_def) lemma measurable_P_component [measurable]: "P.random_variable M (\<lambda>f. f i)" unfolding P_def by measurable lemma P_component [simp]: "distr P M (\<lambda>f. f i) = M" unfolding P_def by (subst P.PiM_component) auto lemma indep_vars: "P.indep_vars (\<lambda>_. M) (\<lambda>i f. f i) UNIV" by (subst P.indep_vars_iff_distr_eq_PiM) (simp_all add: restrict_def distr_id2 P.PiM_component P_def) text \<open> The shift operator takes us from $\mathcal{T}_n$ to $\mathcal{T}_{n+1}$ (it forgets the information about one more variable): \<close> lemma measurable_T_tail: "T \<in> tail_algebra (Suc n) \<rightarrow>\<^sub>M tail_algebra n" unfolding T_def tail_algebra_def o_def by (rule measurable_abs_UNIV[OF measurable_compose[OF measurable_component_singleton]]) simp_all lemma measurable_funpow_T: "T ^^ n \<in> tail_algebra (m + n) \<rightarrow>\<^sub>M tail_algebra m" proof (induction n) case (Suc n) have "(T ^^ n) \<circ> T \<in> tail_algebra (m + Suc n) \<rightarrow>\<^sub>M tail_algebra m" by (rule measurable_comp[OF _ Suc]) (simp_all add: measurable_T_tail) thus ?case by (simp add: o_def funpow_swap1) qed auto lemma measurable_funpow_T': "T ^^ n \<in> tail_algebra n \<rightarrow>\<^sub>M P" using measurable_funpow_T[of n 0] by simp text \<open> The shift operator is clearly measure-preserving: \<close> lemma measure_preserving: "T \<in> measure_preserving P P" proof fix A :: "(nat \<Rightarrow> 'a) set" assume "A \<in> P.events" hence "emeasure P (T -` A \<inter> space P) = emeasure (distr P P T) A" by (subst emeasure_distr) simp_all also have "distr P P T = P" unfolding P_def T_def o_def using distr_PiM_reindex[of UNIV "\<lambda>_. M" Suc UNIV] by (simp add: prob_space_axioms restrict_def) finally show "emeasure P (T -` A \<inter> space P) = emeasure P A" . qed auto sublocale fmpt P T by unfold_locales (use measure_preserving in \<open>blast intro: measure_preserving_is_quasi_measure_preserving\<close>)+ lemma indep_sets_vimage_algebra: "P.indep_sets (\<lambda>i. sets (vimage_algebra (space P) (\<lambda>f. f i) M)) UNIV" using indep_vars unfolding P.indep_vars_def sets_vimage_algebra by blast text \<open> We can now show that the tail algebra $\mathcal{T}_n$ is a subalgebra of the algebra generated by the algebras induced by all the variables \<open>x\<^sub>i\<close> with \<open>i \<ge> n\<close>: \<close> lemma tail_algebra_subset: "sets (tail_algebra n) \<subseteq> sigma_sets (space P) (\<Union>i\<in>{n..}. sets (vimage_algebra (space P) (\<lambda>f. f i) M))" proof - have "sets (tail_algebra n) = sigma_sets (space P) (prod_algebra UNIV (\<lambda>i. if i < n then trivial_measure (space M) else M))" by (simp add: tail_algebra_def sets_PiM PiE_def Pi_def P_def space_PiM) also have "\<dots> \<subseteq> sigma_sets (space P) (\<Union>i\<in>{n..}. sets (vimage_algebra (space P) (\<lambda>f. f i) M))" proof (intro sigma_sets_mono subsetI) fix C assume "C \<in> prod_algebra UNIV (\<lambda>i. if i < n then trivial_measure (space M) else M)" then obtain C' where C': "C = Pi\<^sub>E UNIV C'" "C' \<in> (\<Pi> i\<in>UNIV. sets (if i < n then trivial_measure (space M) else M))" by (elim prod_algebraE_all) have C'_1: "C' i \<in> {{}, space M}" if "i < n" for i using C'(2) that by (auto simp: Pi_def sets_trivial_measure split: if_splits) have C'_2: "C' i \<in> sets M" if "i \<ge> n" for i proof - from that have "\<not>(i < n)" by auto with C'(2) show ?thesis by (force simp: Pi_def sets_trivial_measure split: if_splits) qed have "C' i \<in> events" for i using C'_1[of i] C'_2[of i] by (cases "i \<ge> n") auto hence "C \<in> sets P" unfolding P_def C'(1) by (intro sets_PiM_I_countable) auto hence "C \<subseteq> space P" using sets.sets_into_space by blast show "C \<in> sigma_sets (space P) (\<Union>i\<in>{n..}. sets (vimage_algebra (space P) (\<lambda>f. f i) M))" proof (cases "C = {}") case False have "C = (\<Inter>i\<in>{n..}. (\<lambda>f. f i) -` C' i) \<inter> space P" proof (intro equalityI subsetI, goal_cases) case (1 f) hence "f \<in> space P" using 1 \<open>C \<subseteq> space P\<close> by blast thus ?case using C' 1 by (auto simp: Pi_def sets_trivial_measure split: if_splits) next case (2 f) hence f: "f i \<in> C' i" if "i \<ge> n" for i using that by auto have "f i \<in> C' i" for i proof (cases "i \<ge> n") case True thus ?thesis using C'_2[of i] f[of i] by auto next case False thus ?thesis using C'_1[of i] C'(1) \<open>C \<noteq> {}\<close> 2 by (auto simp: P_def space_PiM) qed thus "f \<in> C" using C' by auto qed also have "(\<Inter>i\<in>{n..}. (\<lambda>f. f i) -` C' i) \<inter> space P = (\<Inter>i\<in>{n..}. (\<lambda>f. f i) -` C' i \<inter> space P)" by blast also have "\<dots> \<in> sigma_sets (space P) (\<Union>i\<in>{n..}. sets (vimage_algebra (space P) (\<lambda>f. f i) M))" (is "_ \<in> ?rhs") proof (intro sigma_sets_INTER, goal_cases) fix i show "(\<lambda>f. f i) -` C' i \<inter> space P \<in> ?rhs" proof (cases "i \<ge> n") case False hence "C' i = {} \<or> C' i = space M" using C'_1[of i] by auto thus ?thesis proof assume [simp]: "C' i = space M" have "space P \<subseteq> (\<lambda>f. f i) -` C' i" by (auto simp: P_def space_PiM) hence "(\<lambda>f. f i) -` C' i \<inter> space P = space P" by blast thus ?thesis using sigma_sets_top by metis qed (auto intro: sigma_sets.Empty) next case i: True have "(\<lambda>f. f i) -` C' i \<inter> space P \<in> sets (vimage_algebra (space P) (\<lambda>f. f i) M)" using C'_2[OF i] by (blast intro: in_vimage_algebra) thus ?thesis using i by blast qed next have "C \<subseteq> space P" if "C \<in> sets (vimage_algebra (space P) (\<lambda>f. f i) M)" for i C using sets.sets_into_space[OF that] by simp thus "(\<Union>i\<in>{n..}. sets (vimage_algebra (space P) (\<lambda>f. f i) M)) \<subseteq> Pow (space P)" by auto qed auto finally show ?thesis . qed (auto simp: sigma_sets.Empty) qed finally show ?thesis . qed text \<open> It now follows that the \<open>T\<close>-invariant events are a subset of the tail algebra induced by the variables: \<close> lemma Invariants_subset_tail_algebra: "sets Invariants \<subseteq> P.tail_events (\<lambda>i. sets (vimage_algebra (space P) (\<lambda>f. f i) M))" proof fix A assume A: "A \<in> sets Invariants" have A': "A \<in> P.events" using A unfolding Invariants_sets by simp_all show "A \<in> P.tail_events (\<lambda>i. sets (vimage_algebra (space P) (\<lambda>f. f i) M))" unfolding P.tail_events_def proof safe fix n :: nat have "vimage_restr T A = A" using A by (simp add: Invariants_vrestr) hence "A = vimage_restr (T ^^ n) A" using A' by (induction n) (simp_all add: vrestr_comp) also have "vimage_restr (T ^^ n) A = (T ^^ n) -` (A \<inter> space P) \<inter> space P" unfolding vimage_restr_def .. also have "A \<inter> space P = A" using A' by simp also have "space P = space (tail_algebra n)" by (simp add: P_def space_PiM) also have "(T ^^ n) -` A \<inter> space (tail_algebra n) \<in> sets (tail_algebra n)" by (rule measurable_sets[OF measurable_funpow_T' A']) also have "sets (tail_algebra n) \<subseteq> sigma_sets (space P) (\<Union>i\<in>{n..}. sets (vimage_algebra (space P) (\<lambda>f. f i) M))" by (rule tail_algebra_subset) finally show "A \<in> sigma_sets (space P) (\<Union>i\<in>{n..}. sets (vimage_algebra (space P) (\<lambda>f. f i) M))" . qed qed text \<open> A simple invocation of Kolmogorov's 0--1 law now proves that \<open>T\<close> is indeed ergodic: \<close> sublocale ergodic_fmpt P T proof fix A assume A: "A \<in> sets Invariants" have A': "A \<in> P.events" using A unfolding Invariants_sets by simp_all have "sigma_algebra (space P) (sets (vimage_algebra (space P) (\<lambda>f. f i) M))" for i by (metis sets.sigma_algebra_axioms space_vimage_algebra) hence "P.prob A = 0 \<or> P.prob A = 1" using indep_sets_vimage_algebra by (rule P.kolmogorov_0_1_law) (use A Invariants_subset_tail_algebra in blast) thus "A \<in> null_sets P \<or> space P - A \<in> null_sets P" by (rule disj_forward) (use A'(1) P.prob_compl[of A] in \<open>auto simp: P.emeasure_eq_measure\<close>) qed end end
Last week I wrote about the construction, and the challenges, of the creation of a guest virtual machine -based snapshot management solution (or β€œtool”) for Hyper-V environments. As promised, it’s now available for downloading. As with our other free tools, the download(s) for HyperSnapshot can be found from here, our community tools page. While both the host -based and guest -based components are really small in size, we decided to have a separate ZIP file for each. For the Hyper-V host machine(s) you will need to have HyperSnapshot’s host -package, which has one [service] executable (HyperSnapshotService.exe) and installation + removal scripts. Once installed, the service will run in the background responding automatically to the requests made from the virtual machine (guest systems), with zero configuration necessary. The service is engineered so that it try and use as little of resources possible on the host system, which in effect means no continuous polling of VMs but rather responding to changes as indicated by WMI eventing system. For all the virtual machines you wish to have guest-based snapshot functionality enabled, guest -package needs to be downloaded and extracted to. Since we do not have an installer – at least at this point in time – the client executable (HyperSnapshotGui.exe) has to be started manually by the user or shortcut created for it. Please note that like written in the previous article, the client executable needs elevation in order to function properly. As with the host-side component running on the Hyper-V host machine, the client component does not need any explicit configuration. Data Exchange service is enabled for the VM (it is by default). I hope that you find the tool useful, especially in context of App-V packaging!
import Pkg @inline function _with_temp_dir(f::F) where F <: Base.Callable original_directory = pwd() my_tmp_dir = mktempdir(; cleanup=false) cd(my_tmp_dir) result = f(my_tmp_dir) cd(original_directory) rm(my_tmp_dir; force = true, recursive = true) return result end # @inline function _with_temp_depot(f::F) where F <: Base.Callable # return _with_temp_dir() do my_temp_depot # original_depot_path = deepcopy(Base.DEPOT_PATH) # empty!(Base.DEPOT_PATH) # push!(Base.DEPOT_PATH, my_temp_depot) # result = f(my_temp_depot) # empty!(Base.DEPOT_PATH) # for x in original_depot_path # push!(Base.DEPOT_PATH, x) # end # return result # end # end @inline function _with_temp_project(f::F) where F <: Base.Callable return _with_temp_dir() do my_temp_project original_active_project = Base.active_project() Pkg.activate(my_temp_project; shared = false) result = f(my_temp_project) Pkg.activate(original_active_project; shared = false) return result end end @inline function _activate_possibly_shared_project(project::AbstractString; shared_project::Bool = false) if length(project) > 0 && project[1] == '@' Pkg.activate(project[2:end]; shared = true) else Pkg.activate(project; shared = shared_project) end Pkg.instantiate() return nothing end @inline function _with_different_project(f::F, project::AbstractString; shared_project::Bool = false) where F <: Base.Callable original_active_project = Base.active_project() _activate_possibly_shared_project(project; shared_project = shared_project) result = f(Base.active_project()) Pkg.activate(original_active_project; shared = false) return result end
module HelloWorldPrim where open import IO.Primitive.Infinite open import Codata.Musical.Costring main = putStrLn (toCostring "Hello World!")
import analysis.complex.isometry import analysis.complex.real_deriv section fderiv open continuous_linear_map variables (π•œ : Type*) [nondiscrete_normed_field π•œ] variables {π•œ' : Type*} [nondiscrete_normed_field π•œ'] [normed_algebra π•œ π•œ'] variables {E : Type*} [normed_group E] [normed_space π•œ E] [normed_space π•œ' E] variables [is_scalar_tower π•œ π•œ' E] variables {F : Type*} [normed_group F] [normed_space π•œ F] [normed_space π•œ' F] variables [is_scalar_tower π•œ π•œ' F] variables {f : E β†’ F} {f' : E β†’L[π•œ'] F} {s : set E} {x : E} lemma has_fderiv_within_at_of_eq {s : set E} {g' : E β†’L[π•œ] F} (h : has_fderiv_within_at f g' s x) (H : f'.restrict_scalars π•œ = g') : has_fderiv_within_at f f' s x := by { simp only [has_fderiv_within_at, has_fderiv_at_filter] at h ⊒, rwa [← f'.coe_restrict_scalars', H] } lemma has_fderiv_at_of_eq {g' : E β†’L[π•œ] F} (h : has_fderiv_at f g' x) (H : f'.restrict_scalars π•œ = g') : has_fderiv_at f f' x := by simp only [has_fderiv_at, has_fderiv_at_filter] at h ⊒; rwa [← f'.coe_restrict_scalars', H] lemma fderiv_eq_fderiv (h : differentiable_at π•œ' f x) : (fderiv π•œ f x : E β†’ F) = fderiv π•œ' f x := by rw [(h.restrict_scalars π•œ).has_fderiv_at.unique (h.has_fderiv_at.restrict_scalars π•œ), coe_restrict_scalars'] lemma differentiable_within_at_iff_exists_linear_map {s : set E} (hf : differentiable_within_at π•œ f s x) (hs : unique_diff_within_at π•œ s x) : differentiable_within_at π•œ' f s x ↔ βˆƒ (g' : E β†’L[π•œ'] F), g'.restrict_scalars π•œ = fderiv_within π•œ f s x := begin split, { rintros ⟨g', hg'⟩, exact ⟨g', hs.eq (hg'.restrict_scalars π•œ) hf.has_fderiv_within_at⟩, }, { rintros ⟨f', hf'⟩, exact ⟨f', has_fderiv_within_at_of_eq π•œ hf.has_fderiv_within_at hf'⟩, }, end lemma differentiable_at_iff_exists_linear_map (hf : differentiable_at π•œ f x) : differentiable_at π•œ' f x ↔ βˆƒ (g' : E β†’L[π•œ'] F), g'.restrict_scalars π•œ = fderiv π•œ f x := by { rw [← differentiable_within_at_univ, ← fderiv_within_univ], exact differentiable_within_at_iff_exists_linear_map π•œ hf.differentiable_within_at unique_diff_within_at_univ, } end fderiv section complex_real_deriv /-! ### Antiholomorphy of complex functions -/ open complex continuous_linear_map variables {E : Type*} [normed_group E] [normed_space ℝ E] {z : β„‚} {f : β„‚ β†’ E} lemma has_fderiv_at_conj (z : β„‚) : has_fderiv_at conj conj_cle.to_continuous_linear_map z := conj_cle.has_fderiv_at lemma fderiv_conj_eq_conj_fderiv {z : β„‚} (h : differentiable_at ℝ f z) : (fderiv ℝ f z).comp conj_cle.to_continuous_linear_map = fderiv ℝ (f ∘ conj) (conj z) := begin rw ← conj_conj z at h, let p := fderiv.comp (conj z) h (has_fderiv_at_conj $ conj z).differentiable_at, rw [conj_conj, (has_fderiv_at_conj $ conj z).fderiv] at p, exact p.symm, end /-- A (real-differentiable) complex function `f` is antiholomorphic if and only if there exists some complex linear map `g'` that equals to the composition of `f`'s differential and the conjugate function -/ lemma antiholomorph_at_iff_exists_complex_linear_conj [normed_space β„‚ E] [is_scalar_tower ℝ β„‚ E] (hf : differentiable_at ℝ f z) : differentiable_at β„‚ (f ∘ conj) (conj z) ↔ βˆƒ (g' : β„‚ β†’L[β„‚] E), g'.restrict_scalars ℝ = (fderiv ℝ f z).comp conj_cle.to_continuous_linear_map := begin split, { intros h, rw ← conj_conj z at hf, rcases (differentiable_at_iff_exists_linear_map ℝ $ hf.comp (conj z) (has_fderiv_at_conj $ conj z).differentiable_at).mp h with ⟨f', hf'⟩, rw conj_conj at hf, rw ← fderiv_conj_eq_conj_fderiv hf at hf', exact ⟨f', hf'⟩, }, { rintros ⟨g', hg'⟩, rw ← conj_conj z at hf hg', exact ⟨g', has_fderiv_at_of_eq ℝ (hf.has_fderiv_at.comp (conj z) $ has_fderiv_at_conj $ conj z) hg'⟩, }, end end complex_real_deriv
(* Title: ZF/AC/AC15_WO6.thy Author: Krzysztof Grabczewski The proofs needed to state that AC10, ..., AC15 are equivalent to the rest. We need the following: WO1 \<Longrightarrow> AC10(n) \<Longrightarrow> AC11 \<Longrightarrow> AC12 \<Longrightarrow> AC15 \<Longrightarrow> WO6 In order to add the formulations AC13 and AC14 we need: AC10(succ(n)) \<Longrightarrow> AC13(n) \<Longrightarrow> AC14 \<Longrightarrow> AC15 or AC1 \<Longrightarrow> AC13(1); AC13(m) \<Longrightarrow> AC13(n) \<Longrightarrow> AC14 \<Longrightarrow> AC15 (m\<le>n) So we don't have to prove all implications of both cases. Moreover we don't need to prove AC13(1) \<Longrightarrow> AC1 and AC11 \<Longrightarrow> AC14 as Rubin & Rubin do. *) theory AC15_WO6 imports HH Cardinal_aux begin (* ********************************************************************** *) (* Lemmas used in the proofs in which the conclusion is AC13, AC14 *) (* or AC15 *) (* - cons_times_nat_not_Finite *) (* - ex_fun_AC13_AC15 *) (* ********************************************************************** *) lemma lepoll_Sigma: "A\<noteq>0 \<Longrightarrow> B \<lesssim> A*B" unfolding lepoll_def apply (erule not_emptyE) apply (rule_tac x = "\<lambda>z \<in> B. \<langle>x,z\<rangle>" in exI) apply (fast intro!: snd_conv lam_injective) done lemma cons_times_nat_not_Finite: "0\<notin>A \<Longrightarrow> \<forall>B \<in> {cons(0,x*nat). x \<in> A}. \<not>Finite(B)" apply clarify apply (rule nat_not_Finite [THEN notE] ) apply (subgoal_tac "x \<noteq> 0") apply (blast intro: lepoll_Sigma [THEN lepoll_Finite])+ done lemma lemma1: "\<lbrakk>\<Union>(C)=A; a \<in> A\<rbrakk> \<Longrightarrow> \<exists>B \<in> C. a \<in> B \<and> B \<subseteq> A" by fast lemma lemma2: "\<lbrakk>pairwise_disjoint(A); B \<in> A; C \<in> A; a \<in> B; a \<in> C\<rbrakk> \<Longrightarrow> B=C" by (unfold pairwise_disjoint_def, blast) lemma lemma3: "\<forall>B \<in> {cons(0, x*nat). x \<in> A}. pairwise_disjoint(f`B) \<and> sets_of_size_between(f`B, 2, n) \<and> \<Union>(f`B)=B \<Longrightarrow> \<forall>B \<in> A. \<exists>! u. u \<in> f`cons(0, B*nat) \<and> u \<subseteq> cons(0, B*nat) \<and> 0 \<in> u \<and> 2 \<lesssim> u \<and> u \<lesssim> n" unfolding sets_of_size_between_def apply (rule ballI) apply (erule_tac x="cons(0, B*nat)" in ballE) apply (blast dest: lemma1 intro!: lemma2, blast) done lemma lemma4: "\<lbrakk>A \<lesssim> i; Ord(i)\<rbrakk> \<Longrightarrow> {P(a). a \<in> A} \<lesssim> i" unfolding lepoll_def apply (erule exE) apply (rule_tac x = "\<lambda>x \<in> RepFun(A,P). \<mu> j. \<exists>a\<in>A. x=P(a) \<and> f`a=j" in exI) apply (rule_tac d = "\<lambda>y. P (converse (f) `y) " in lam_injective) apply (erule RepFunE) apply (frule inj_is_fun [THEN apply_type], assumption) apply (fast intro: LeastI2 elim!: Ord_in_Ord inj_is_fun [THEN apply_type]) apply (erule RepFunE) apply (rule LeastI2) apply fast apply (fast elim!: Ord_in_Ord inj_is_fun [THEN apply_type]) apply (fast elim: sym left_inverse [THEN ssubst]) done lemma lemma5_1: "\<lbrakk>B \<in> A; 2 \<lesssim> u(B)\<rbrakk> \<Longrightarrow> (\<lambda>x \<in> A. {fst(x). x \<in> u(x)-{0}})`B \<noteq> 0" apply simp apply (fast dest: lepoll_Diff_sing elim: lepoll_trans [THEN succ_lepoll_natE] ssubst intro!: lepoll_refl) done lemma lemma5_2: "\<lbrakk>B \<in> A; u(B) \<subseteq> cons(0, B*nat)\<rbrakk> \<Longrightarrow> (\<lambda>x \<in> A. {fst(x). x \<in> u(x)-{0}})`B \<subseteq> B" apply auto done lemma lemma5_3: "\<lbrakk>n \<in> nat; B \<in> A; 0 \<in> u(B); u(B) \<lesssim> succ(n)\<rbrakk> \<Longrightarrow> (\<lambda>x \<in> A. {fst(x). x \<in> u(x)-{0}})`B \<lesssim> n" apply simp apply (fast elim!: Diff_lepoll [THEN lemma4 [OF _ nat_into_Ord]]) done lemma ex_fun_AC13_AC15: "\<lbrakk>\<forall>B \<in> {cons(0, x*nat). x \<in> A}. pairwise_disjoint(f`B) \<and> sets_of_size_between(f`B, 2, succ(n)) \<and> \<Union>(f`B)=B; n \<in> nat\<rbrakk> \<Longrightarrow> \<exists>f. \<forall>B \<in> A. f`B \<noteq> 0 \<and> f`B \<subseteq> B \<and> f`B \<lesssim> n" by (fast del: subsetI notI dest!: lemma3 theI intro!: lemma5_1 lemma5_2 lemma5_3) (* ********************************************************************** *) (* The target proofs *) (* ********************************************************************** *) (* ********************************************************************** *) (* AC10(n) \<Longrightarrow> AC11 *) (* ********************************************************************** *) theorem AC10_AC11: "\<lbrakk>n \<in> nat; 1\<le>n; AC10(n)\<rbrakk> \<Longrightarrow> AC11" by (unfold AC10_def AC11_def, blast) (* ********************************************************************** *) (* AC11 \<Longrightarrow> AC12 *) (* ********************************************************************** *) theorem AC11_AC12: "AC11 \<Longrightarrow> AC12" by (unfold AC10_def AC11_def AC11_def AC12_def, blast) (* ********************************************************************** *) (* AC12 \<Longrightarrow> AC15 *) (* ********************************************************************** *) theorem AC12_AC15: "AC12 \<Longrightarrow> AC15" unfolding AC12_def AC15_def apply (blast del: ballI intro!: cons_times_nat_not_Finite ex_fun_AC13_AC15) done (* ********************************************************************** *) (* AC15 \<Longrightarrow> WO6 *) (* ********************************************************************** *) lemma OUN_eq_UN: "Ord(x) \<Longrightarrow> (\<Union>a<x. F(a)) = (\<Union>a \<in> x. F(a))" by (fast intro!: ltI dest!: ltD) lemma AC15_WO6_aux1: "\<forall>x \<in> Pow(A)-{0}. f`x\<noteq>0 \<and> f`x \<subseteq> x \<and> f`x \<lesssim> m \<Longrightarrow> (\<Union>i<\<mu> x. HH(f,A,x)={A}. HH(f,A,i)) = A" apply (simp add: Ord_Least [THEN OUN_eq_UN]) apply (rule equalityI) apply (fast dest!: less_Least_subset_x) apply (blast del: subsetI intro!: f_subsets_imp_UN_HH_eq_x [THEN Diff_eq_0_iff [THEN iffD1]]) done lemma AC15_WO6_aux2: "\<forall>x \<in> Pow(A)-{0}. f`x\<noteq>0 \<and> f`x \<subseteq> x \<and> f`x \<lesssim> m \<Longrightarrow> \<forall>x < (\<mu> x. HH(f,A,x)={A}). HH(f,A,x) \<lesssim> m" apply (rule oallI) apply (drule ltD [THEN less_Least_subset_x]) apply (frule HH_subset_imp_eq) apply (erule ssubst) apply (blast dest!: HH_subset_x_imp_subset_Diff_UN [THEN not_emptyI2]) (*but can't use del: DiffE despite the obvious conflict*) done theorem AC15_WO6: "AC15 \<Longrightarrow> WO6" unfolding AC15_def WO6_def apply (rule allI) apply (erule_tac x = "Pow (A) -{0}" in allE) apply (erule impE, fast) apply (elim bexE conjE exE) apply (rule bexI) apply (rule conjI, assumption) apply (rule_tac x = "\<mu> i. HH (f,A,i) ={A}" in exI) apply (rule_tac x = "\<lambda>j \<in> (\<mu> i. HH (f,A,i) ={A}) . HH (f,A,j) " in exI) apply (simp_all add: ltD) apply (fast intro!: Ord_Least lam_type [THEN domain_of_fun] elim!: less_Least_subset_x AC15_WO6_aux1 AC15_WO6_aux2) done (* ********************************************************************** *) (* The proof needed in the first case, not in the second *) (* ********************************************************************** *) (* ********************************************************************** *) (* AC10(n) \<Longrightarrow> AC13(n-1) if 2\<le>n *) (* *) (* Because of the change to the formal definition of AC10(n) we prove *) (* the following obviously equivalent theorem \<in> *) (* AC10(n) implies AC13(n) for (1\<le>n) *) (* ********************************************************************** *) theorem AC10_AC13: "\<lbrakk>n \<in> nat; 1\<le>n; AC10(n)\<rbrakk> \<Longrightarrow> AC13(n)" apply (unfold AC10_def AC13_def, safe) apply (erule allE) apply (erule impE [OF _ cons_times_nat_not_Finite], assumption) apply (fast elim!: impE [OF _ cons_times_nat_not_Finite] dest!: ex_fun_AC13_AC15) done (* ********************************************************************** *) (* The proofs needed in the second case, not in the first *) (* ********************************************************************** *) (* ********************************************************************** *) (* AC1 \<Longrightarrow> AC13(1) *) (* ********************************************************************** *) lemma AC1_AC13: "AC1 \<Longrightarrow> AC13(1)" unfolding AC1_def AC13_def apply (rule allI) apply (erule allE) apply (rule impI) apply (drule mp, assumption) apply (elim exE) apply (rule_tac x = "\<lambda>x \<in> A. {f`x}" in exI) apply (simp add: singleton_eqpoll_1 [THEN eqpoll_imp_lepoll]) done (* ********************************************************************** *) (* AC13(m) \<Longrightarrow> AC13(n) for m \<subseteq> n *) (* ********************************************************************** *) lemma AC13_mono: "\<lbrakk>m\<le>n; AC13(m)\<rbrakk> \<Longrightarrow> AC13(n)" unfolding AC13_def apply (drule le_imp_lepoll) apply (fast elim!: lepoll_trans) done (* ********************************************************************** *) (* The proofs necessary for both cases *) (* ********************************************************************** *) (* ********************************************************************** *) (* AC13(n) \<Longrightarrow> AC14 if 1 \<subseteq> n *) (* ********************************************************************** *) theorem AC13_AC14: "\<lbrakk>n \<in> nat; 1\<le>n; AC13(n)\<rbrakk> \<Longrightarrow> AC14" by (unfold AC13_def AC14_def, auto) (* ********************************************************************** *) (* AC14 \<Longrightarrow> AC15 *) (* ********************************************************************** *) theorem AC14_AC15: "AC14 \<Longrightarrow> AC15" by (unfold AC13_def AC14_def AC15_def, fast) (* ********************************************************************** *) (* The redundant proofs; however cited by Rubin & Rubin *) (* ********************************************************************** *) (* ********************************************************************** *) (* AC13(1) \<Longrightarrow> AC1 *) (* ********************************************************************** *) lemma lemma_aux: "\<lbrakk>A\<noteq>0; A \<lesssim> 1\<rbrakk> \<Longrightarrow> \<exists>a. A={a}" by (fast elim!: not_emptyE lepoll_1_is_sing) lemma AC13_AC1_lemma: "\<forall>B \<in> A. f(B)\<noteq>0 \<and> f(B)<=B \<and> f(B) \<lesssim> 1 \<Longrightarrow> (\<lambda>x \<in> A. THE y. f(x)={y}) \<in> (\<Prod>X \<in> A. X)" apply (rule lam_type) apply (drule bspec, assumption) apply (elim conjE) apply (erule lemma_aux [THEN exE], assumption) apply (simp add: the_equality) done theorem AC13_AC1: "AC13(1) \<Longrightarrow> AC1" unfolding AC13_def AC1_def apply (fast elim!: AC13_AC1_lemma) done (* ********************************************************************** *) (* AC11 \<Longrightarrow> AC14 *) (* ********************************************************************** *) theorem AC11_AC14: "AC11 \<Longrightarrow> AC14" unfolding AC11_def AC14_def apply (fast intro!: AC10_AC13) done end
MailChimp is a third-party newsletter platform that many store owners use to keep their customers up to date with their store. Now you should see a box for you to copy and paste the code. Inside this box there is a section that starts with action=”” and inside the action is the URL you’ll want to copy. 8. Copy it to your clipboard with cmd + c on a Mac or ctrl + c on a PC.
State Before: t : Type u β†’ Type u inst✝⁡ : Traversable t inst✝⁴ : IsLawfulTraversable t F G : Type u β†’ Type u inst✝³ : Applicative F inst✝² : LawfulApplicative F inst✝¹ : Applicative G inst✝ : LawfulApplicative G Ξ± Ξ² Ξ³ : Type u g✝ : Ξ± β†’ F Ξ² h✝ : Ξ² β†’ G Ξ³ f : Ξ² β†’ Ξ³ x : t Ξ² g : Ξ± β†’ Ξ² h : Ξ² β†’ G Ξ³ ⊒ traverse (h ∘ g) = traverse h ∘ map g State After: case h t : Type u β†’ Type u inst✝⁡ : Traversable t inst✝⁴ : IsLawfulTraversable t F G : Type u β†’ Type u inst✝³ : Applicative F inst✝² : LawfulApplicative F inst✝¹ : Applicative G inst✝ : LawfulApplicative G Ξ± Ξ² Ξ³ : Type u g✝ : Ξ± β†’ F Ξ² h✝ : Ξ² β†’ G Ξ³ f : Ξ² β†’ Ξ³ x : t Ξ² g : Ξ± β†’ Ξ² h : Ξ² β†’ G Ξ³ x✝ : t Ξ± ⊒ traverse (h ∘ g) x✝ = (traverse h ∘ map g) x✝ Tactic: ext State Before: case h t : Type u β†’ Type u inst✝⁡ : Traversable t inst✝⁴ : IsLawfulTraversable t F G : Type u β†’ Type u inst✝³ : Applicative F inst✝² : LawfulApplicative F inst✝¹ : Applicative G inst✝ : LawfulApplicative G Ξ± Ξ² Ξ³ : Type u g✝ : Ξ± β†’ F Ξ² h✝ : Ξ² β†’ G Ξ³ f : Ξ² β†’ Ξ³ x : t Ξ² g : Ξ± β†’ Ξ² h : Ξ² β†’ G Ξ³ x✝ : t Ξ± ⊒ traverse (h ∘ g) x✝ = (traverse h ∘ map g) x✝ State After: no goals Tactic: rw [comp_apply, traverse_map]
Require Import Omega. Require Import Wf_nat. Definition f1_aux : forall x, (forall z, z < x ->{y:nat | z=0 \/ y < z})->{y:nat | x=0\/ y< x}. intros x; case x. (* value for 0 *) intros rec; exists 0; auto. intros x'; case x'. (* value for 1 *) intros rec; exists 0; auto. (* value for x > 1 *) refine (fun x'' rec => match rec (S x'') _ with | (exist _ v H) => match rec (S v) _ with | (exist _ v' H') => (exist _ (S v') _) end end); omega. Defined. Definition f1' : forall x, {y:nat | x=0 \/ y<x} := (well_founded_induction lt_wf (fun x:nat => {y:nat | x=0\/ y<x}) f1_aux). Definition f1 (x:nat): nat := match f1' x with (exist _ v _) => v end.
\section*{Versioning and contribution history} \begin{tabular*}{\textwidth}{|l|@{\extracolsep{\fill}}l|p{2.2in}|p{2.2in}|} \hline Version & Date & Authors & Notes \\ \hline % Version 0.5 & % Date DD.MM.YYYY & % Contributor Contributor (Institution) & % Description Description \\ \hline % Version 0.6 & % Date DD.MM.YYYY & % Contributor Contributor (Institution) & % Description Description \\ \hline \end{tabular*} \clearpage
(* This file is generated by Cogent *) theory Random_seed_ShallowTuplesProof imports "Random_seed_Shallow_Desugar" "Random_seed_Shallow_Desugar_Tuples" "CogentShallow.ShallowTuples" begin ML \<open> structure ShallowTuplesRules_Random_seed = Named_Thms ( val name = Binding.name "ShallowTuplesRules_Random_seed" val description = "" ) \<close> setup \<open> ShallowTuplesRules_Random_seed.setup \<close> ML \<open> structure ShallowTuplesThms_Random_seed = Named_Thms ( val name = Binding.name "ShallowTuplesThms_Random_seed" val description = "" ) \<close> setup \<open> ShallowTuplesThms_Random_seed.setup \<close> overloading shallow_tuples_rel_SeedValue \<equiv> shallow_tuples_rel begin definition "shallow_tuples_rel_SeedValue (x :: ('x1, 'x2) Random_seed_ShallowShared.SeedValue) (xt :: ('xt1, 'xt2) Random_seed_ShallowShared_Tuples.SeedValue) \<equiv> shallow_tuples_rel (Random_seed_ShallowShared.SeedValue.seed\<^sub>f x) (Random_seed_ShallowShared_Tuples.SeedValue.seed\<^sub>f xt) \<and> shallow_tuples_rel (Random_seed_ShallowShared.SeedValue.value\<^sub>f x) (Random_seed_ShallowShared_Tuples.SeedValue.value\<^sub>f xt)" end lemma shallow_tuples_rule_make__SeedValue [ShallowTuplesRules_Random_seed]: "\<lbrakk> shallow_tuples_rel x1 xt1; shallow_tuples_rel x2 xt2 \<rbrakk> \<Longrightarrow> shallow_tuples_rel (Random_seed_ShallowShared.SeedValue.make x1 x2) \<lparr>Random_seed_ShallowShared_Tuples.SeedValue.seed\<^sub>f = xt1, value\<^sub>f = xt2\<rparr>" by (simp add: shallow_tuples_rel_SeedValue_def Random_seed_ShallowShared.SeedValue.defs Random_seed_ShallowShared_Tuples.SeedValue.defs) lemma shallow_tuples_rule__SeedValue__seed\<^sub>f [ShallowTuplesThms_Random_seed]: "shallow_tuples_rel (x :: ('x1, 'x2) Random_seed_ShallowShared.SeedValue) (xt :: ('xt1, 'xt2) Random_seed_ShallowShared_Tuples.SeedValue) \<Longrightarrow> shallow_tuples_rel (Random_seed_ShallowShared.SeedValue.seed\<^sub>f x) (Random_seed_ShallowShared_Tuples.SeedValue.seed\<^sub>f xt)" by (simp add: shallow_tuples_rel_SeedValue_def) lemma shallow_tuples_rule__SeedValue__value\<^sub>f [ShallowTuplesThms_Random_seed]: "shallow_tuples_rel (x :: ('x1, 'x2) Random_seed_ShallowShared.SeedValue) (xt :: ('xt1, 'xt2) Random_seed_ShallowShared_Tuples.SeedValue) \<Longrightarrow> shallow_tuples_rel (Random_seed_ShallowShared.SeedValue.value\<^sub>f x) (Random_seed_ShallowShared_Tuples.SeedValue.value\<^sub>f xt)" by (simp add: shallow_tuples_rel_SeedValue_def) lemma shallow_tuples_rule__SeedValue__seed\<^sub>f__update [ShallowTuplesRules_Random_seed]: "\<lbrakk> shallow_tuples_rel (x :: ('x1, 'x2) Random_seed_ShallowShared.SeedValue) (xt :: ('xt1, 'xt2) Random_seed_ShallowShared_Tuples.SeedValue); shallow_tuples_rel v vt \<rbrakk> \<Longrightarrow> shallow_tuples_rel (Random_seed_ShallowShared.SeedValue.seed\<^sub>f_update (\<lambda>_. v) x) (Random_seed_ShallowShared_Tuples.SeedValue.seed\<^sub>f_update (\<lambda>_. vt) xt)" by (simp add: shallow_tuples_rel_SeedValue_def) lemma shallow_tuples_rule__SeedValue__value\<^sub>f__update [ShallowTuplesRules_Random_seed]: "\<lbrakk> shallow_tuples_rel (x :: ('x1, 'x2) Random_seed_ShallowShared.SeedValue) (xt :: ('xt1, 'xt2) Random_seed_ShallowShared_Tuples.SeedValue); shallow_tuples_rel v vt \<rbrakk> \<Longrightarrow> shallow_tuples_rel (Random_seed_ShallowShared.SeedValue.value\<^sub>f_update (\<lambda>_. v) x) (Random_seed_ShallowShared_Tuples.SeedValue.value\<^sub>f_update (\<lambda>_. vt) xt)" by (simp add: shallow_tuples_rel_SeedValue_def) lemma shallow_tuples__rand_with_seed [ShallowTuplesThms_Random_seed]: "shallow_tuples_rel Random_seed_ShallowShared.rand_with_seed Random_seed_ShallowShared_Tuples.rand_with_seed" sorry lemma shallow_tuples__main [ShallowTuplesThms_Random_seed]: "shallow_tuples_rel Random_seed_Shallow_Desugar.main Random_seed_Shallow_Desugar_Tuples.main" apply (rule shallow_tuples_rel_funI) apply (unfold Random_seed_Shallow_Desugar.main_def Random_seed_Shallow_Desugar_Tuples.main_def id_def) apply ((unfold take\<^sub>c\<^sub>o\<^sub>g\<^sub>e\<^sub>n\<^sub>t_def Let\<^sub>d\<^sub>s_def Let_def split_def)?,(simp only: fst_conv snd_conv)?) by (assumption | rule shallow_tuples_basic_bucket ShallowTuplesRules_Random_seed ShallowTuplesThms_Random_seed ShallowTuplesThms_Random_seed[THEN shallow_tuples_rel_funD])+ end
export propagate, get_actions!, tick!, reset_hidden_states!, simulate! include("driver_models.jl") include("simulation.jl") include("callbacks.jl") include("actions.jl") include("features.jl")
// @@@LICENSE // // Copyright (c) 2010-2013 LG Electronics, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // LICENSE@@@ #include "util/ObjectTracker.h" #include <boost/foreach.hpp> #include "exceptions/Backtrace.h" #include <typeinfo> #include "core/MojRefCount.h" using namespace std; set<const TrackedObject*> ObjectTracker::s_objects; void ObjectTracker::Dump() { DumpClass(NULL); } void ObjectTracker::DumpClass(const char* className) { BOOST_FOREACH(const TrackedObject* obj, s_objects) { const std::type_info& info = typeid(*obj); // Need to use dynamic_cast to get the right pointer due to multiple inheritance const void* basePtr = dynamic_cast<const void*>(obj); string demangled = Backtrace::Demangle(info.name()); if(className == NULL || demangled == className) { fprintf(stderr, "(%s*) %p\n", demangled.c_str(), basePtr); } } } template<typename T> void ObjectTracker::Inspect(T* obj) { const std::type_info& info = typeid(*obj); string demangled = Backtrace::Demangle(info.name()); // Need to use dynamic_cast to get the right pointer due to multiple inheritance const void* ptr = dynamic_cast<const void*>(obj); fprintf(stderr, "(%s*) %p\n", demangled.c_str(), ptr); } // Useful debug function void Inspect(MojRefCounted* ptr) { ObjectTracker::Inspect<MojRefCounted>(ptr); }
(* Author: Mohammad Abdulaziz, Fred Kurz, Florian Keßler *) theory SAS_Plus_Plus imports "Verified_SAT_Based_AI_Planning.SAS_Plus_Representation" "Verified_SAT_Based_AI_Planning.SAS_Plus_Semantics" begin section "SAS++ Representation" text \<open> We introduce SAS++, an adopted version of SAS+ that allows for partial initial states where not all variables need to have a defined value. \<close> definition "is_valid_problem_sas_plus_plus \<Psi> \<equiv> let ops = operators_of \<Psi> ; vs = variables_of \<Psi> ; I = initial_of \<Psi> ; G = goal_of \<Psi> ; D = range_of \<Psi> in list_all (\<lambda>v. D v \<noteq> None) vs \<and> list_all (is_valid_operator_sas_plus \<Psi>) ops \<and> list_all (\<lambda> v. length (the (D v)) > 0) vs \<and> (\<forall>v. I v \<noteq> None \<longrightarrow> ListMem v vs) \<and> (\<forall>v. I v \<noteq> None \<longrightarrow> ListMem (the (I v)) (the (D v))) \<and> (\<forall>v. G v \<noteq> None \<longrightarrow> ListMem v vs) \<and> (\<forall>v. G v \<noteq> None \<longrightarrow> ListMem (the (G v)) (the (D v)))" lemma is_valid_problem_sas_plus_plus_then: fixes \<Psi>::"('v,'d) sas_plus_problem" assumes "is_valid_problem_sas_plus_plus \<Psi>" shows "\<forall>v \<in> set ((\<Psi>)\<^sub>\<V>\<^sub>+). (\<R>\<^sub>+ \<Psi> v) \<noteq> {}" and "\<forall>op \<in> set ((\<Psi>)\<^sub>\<O>\<^sub>+). is_valid_operator_sas_plus \<Psi> op" and "dom ((\<Psi>)\<^sub>I\<^sub>+) \<subseteq> set ((\<Psi>)\<^sub>\<V>\<^sub>+)" and "\<forall>v \<in> dom ((\<Psi>)\<^sub>I\<^sub>+). the (((\<Psi>)\<^sub>I\<^sub>+) v) \<in> \<R>\<^sub>+ \<Psi> v" and "dom ((\<Psi>)\<^sub>G\<^sub>+) \<subseteq> set ((\<Psi>)\<^sub>\<V>\<^sub>+)" and "\<forall>v \<in> dom ((\<Psi>)\<^sub>G\<^sub>+). the (((\<Psi>)\<^sub>G\<^sub>+) v) \<in> \<R>\<^sub>+ \<Psi> v" proof - let ?vs = "sas_plus_problem.variables_of \<Psi>" and ?ops = "sas_plus_problem.operators_of \<Psi>" and ?I = "sas_plus_problem.initial_of \<Psi>" and ?G = "sas_plus_problem.goal_of \<Psi>" and ?D = "sas_plus_problem.range_of \<Psi>" { fix v have "(?D v \<noteq> None \<and> ?D v \<noteq> Some []) \<longleftrightarrow> ((\<R>\<^sub>+ \<Psi> v) \<noteq> {})" by (cases "?D v"; (auto simp: range_of'_def)) } note nb = this have nb\<^sub>1: "\<forall>v \<in> set ?vs. ?D v \<noteq> None" and nb\<^sub>4: "\<forall>v \<in> set ?vs. length (the (?D v)) > 0" and "\<forall>op \<in> set ?ops. is_valid_operator_sas_plus \<Psi> op" and "\<forall>v. ?I v \<noteq> None \<longrightarrow> v \<in> set ?vs" and nb\<^sub>2: "\<forall>v. ?I v \<noteq> None \<longrightarrow> the (?I v) \<in> set (the (?D v))" and "\<forall>v. ?G v \<noteq> None \<longrightarrow> v \<in> set ?vs" and nb\<^sub>3: "\<forall>v. ?G v \<noteq> None \<longrightarrow> the (?G v) \<in> set (the (?D v))" using assms unfolding SAS_Plus_Plus.is_valid_problem_sas_plus_plus_def Let_def list_all_iff ListMem_iff by argo+ then have G3: "\<forall>op \<in> set ((\<Psi>)\<^sub>\<O>\<^sub>+). is_valid_operator_sas_plus \<Psi> op" and G4: "dom ((\<Psi>)\<^sub>I\<^sub>+) \<subseteq> set ((\<Psi>)\<^sub>\<V>\<^sub>+)" and G5: "dom ((\<Psi>)\<^sub>G\<^sub>+) \<subseteq> set ((\<Psi>)\<^sub>\<V>\<^sub>+)" unfolding variables_of_def operators_of_def by auto+ moreover { fix v assume "v \<in> set ((\<Psi>)\<^sub>\<V>\<^sub>+)" then have "?D v \<noteq> None" using nb\<^sub>1 by force+ } note G6 = this moreover { fix v assume "v \<in> set ((\<Psi>)\<^sub>\<V>\<^sub>+)" then have "(\<R>\<^sub>+ \<Psi> v) \<noteq> {}" using G6 nb\<^sub>4 by(auto simp: range_of'_def split: option.splits) } moreover { fix v assume "v \<in> dom ((\<Psi>)\<^sub>I\<^sub>+)" moreover have "((\<Psi>)\<^sub>I\<^sub>+) v \<noteq> None" using calculation by blast+ moreover { have "v \<in> set ((\<Psi>)\<^sub>\<V>\<^sub>+)" using G4 calculation(1) by fast then have "sas_plus_problem.range_of \<Psi> v \<noteq> None" using range_of_not_empty unfolding range_of'_def using G6 by fast+ hence "set (the (?D v)) = \<R>\<^sub>+ \<Psi> v" by (simp add: \<open>sas_plus_problem.range_of \<Psi> v \<noteq> None\<close> option.case_eq_if range_of'_def) } ultimately have "the (((\<Psi>)\<^sub>I\<^sub>+) v) \<in> \<R>\<^sub>+ \<Psi> v" using nb\<^sub>2 by force } moreover { fix v assume "v \<in> dom ((\<Psi>)\<^sub>G\<^sub>+)" then have "((\<Psi>)\<^sub>G\<^sub>+) v \<noteq> None" by blast moreover { have "v \<in> set ((\<Psi>)\<^sub>\<V>\<^sub>+)" using G5 calculation(1) by fast then have "sas_plus_problem.range_of \<Psi> v \<noteq> None" using range_of_not_empty using G6 by fast+ hence "set (the (?D v)) = \<R>\<^sub>+ \<Psi> v" by (simp add: \<open>sas_plus_problem.range_of \<Psi> v \<noteq> None\<close> option.case_eq_if range_of'_def) } ultimately have "the (((\<Psi>)\<^sub>G\<^sub>+) v) \<in> \<R>\<^sub>+ \<Psi> v" using nb\<^sub>3 by auto } ultimately show "\<forall>v \<in> set ((\<Psi>)\<^sub>\<V>\<^sub>+). (\<R>\<^sub>+ \<Psi> v) \<noteq> {}" and "\<forall>op \<in> set((\<Psi>)\<^sub>\<O>\<^sub>+). is_valid_operator_sas_plus \<Psi> op" and "dom ((\<Psi>)\<^sub>I\<^sub>+) \<subseteq> set ((\<Psi>)\<^sub>\<V>\<^sub>+)" and "\<forall>v \<in> dom ((\<Psi>)\<^sub>I\<^sub>+). the (((\<Psi>)\<^sub>I\<^sub>+) v) \<in> \<R>\<^sub>+ \<Psi> v" and "dom ((\<Psi>)\<^sub>G\<^sub>+) \<subseteq> set ((\<Psi>)\<^sub>\<V>\<^sub>+)" and "\<forall>v \<in> dom ((\<Psi>)\<^sub>G\<^sub>+). the (((\<Psi>)\<^sub>G\<^sub>+) v) \<in> \<R>\<^sub>+ \<Psi> v" by auto qed section "SAS++ Semantics" subsection "Serial Execution Semantics" text \<open> Similarly, serial SAS++ solutions are defined like in SAS+, but instead of having a single initial state, we assert that there exists one that conforms to the partial initial state, and from which a goal state is reachable, using the SAS+ definition of executing a plan. \<close> definition is_serial_solution_for_problem_sas_plus_plus :: "('variable, 'domain) sas_plus_problem \<Rightarrow> ('variable, 'domain) sas_plus_plan \<Rightarrow> bool" where "is_serial_solution_for_problem_sas_plus_plus \<Psi> \<psi> \<equiv> let I = sas_plus_problem.initial_of \<Psi> ; G = sas_plus_problem.goal_of \<Psi> ; ops = sas_plus_problem.operators_of \<Psi> in (\<exists>I'. I \<subseteq>\<^sub>m I' \<and> dom I' = set ((\<Psi>)\<^sub>\<V>\<^sub>+) \<and> (\<forall> v \<in> set ((\<Psi>)\<^sub>\<V>\<^sub>+). the (I' v) \<in> range_of' \<Psi> v) \<and> G \<subseteq>\<^sub>m execute_serial_plan_sas_plus I' \<psi> \<and> list_all (\<lambda>op. ListMem op ops) \<psi>)" fun chain_applicable where "chain_applicable s [] = True" | "chain_applicable s (op # ops) = (is_operator_applicable_in s op \<and> chain_applicable (s \<then>\<^sub>+ op) ops)" fun chain_applicable_prefix where "chain_applicable_prefix s [] = []" | "chain_applicable_prefix s (op # ops) = (if is_operator_applicable_in s op then op # (chain_applicable_prefix (s \<then>\<^sub>+ op) ops) else [])" lemma chain_applicable_append[simp]: "chain_applicable s (as @ bs) \<longleftrightarrow> (chain_applicable s as \<and> (chain_applicable (execute_serial_plan_sas_plus s as) bs))" apply(induction as arbitrary: s) by(auto) lemma chain_applicable_prefix_chain_applicable[simp]: "chain_applicable s (chain_applicable_prefix s ops)" apply(induction ops arbitrary: s) by(auto) lemma execute_chain_applicable_prefix: "execute_serial_plan_sas_plus s (chain_applicable_prefix s ops) = execute_serial_plan_sas_plus s ops" apply(induction ops arbitrary: s) by(auto) lemma set_of_chain_applicable_prefix: "set (chain_applicable_prefix s ops) \<subseteq> set ops" apply(induction ops arbitrary: s) by(auto) lemma length_of_chain_applicable_prefix: "length (chain_applicable_prefix s ops) \<le> length ops" apply(induction ops arbitrary: s) by(auto) lemma execute_serial_plan_sas_plus_append[simp]: "chain_applicable s as \<Longrightarrow> execute_serial_plan_sas_plus s (as @ bs) = execute_serial_plan_sas_plus (execute_serial_plan_sas_plus s as) bs" apply(induction as arbitrary: s) by auto lemma dom_of_execute_serial_plan_sas_plus: "is_valid_problem_sas_plus P \<Longrightarrow> \<forall>op \<in> set ops. op \<in> set ((P)\<^sub>\<O>\<^sub>+) \<Longrightarrow> dom s = set ((P)\<^sub>\<V>\<^sub>+) \<Longrightarrow> dom (execute_serial_plan_sas_plus s ops) = set ((P)\<^sub>\<V>\<^sub>+)" proof(induction ops arbitrary: s) case Nil then show ?case by auto next case (Cons op ops) hence "\<forall>(v, a)\<in>set (effect_of op). v \<in> set ((P)\<^sub>\<V>\<^sub>+)" apply - apply(rule is_valid_operator_sas_plus_then(3)) by (auto simp: is_valid_problem_sas_plus_def Let_def list_all_def) hence "dom (s \<then>\<^sub>+ op) = set ((P)\<^sub>\<V>\<^sub>+)" using Cons apply(auto) using map_of_SomeD by fastforce thus ?case using Cons by simp qed end
library(igraph) e <- read.csv("../edges.csv", header=FALSE) names(e) <- c("from", "to") v <- read.csv("../vertices.csv", header=FALSE) names(v) <- c("name", "timestamp") mask1 <- e$from %in% v$name mask2 <- e$to %in% v$name mask <- mask1 & mask2 e <- e[mask,] g <- graph.data.frame(e, vertices = v) g <- delete.vertices(g, V(g)[degree(g)==0]) la <- layout_with_fr(g) g <- add_layout_(g, in_circle(), component_wise()) memberships.eigen <- cluster_leading_eigen(as.undirected(g))$membership indegrees <- degree(g, mode="in") q_degree <- quantile(indegrees, 0.9) V(g)$label.cex <- ifelse(degree(g, mode="in")>0, 1+0.5*tanh(indegrees-q_degree), 0) V(g)$name[degree(g, mode="in")<10] = "" # Size proportional to degree V(g)$size <- 1+0.5*tanh(indegrees-q_degree) plot(g, layout = la, vertex.color = memberships.eigen, edge.width = 0.2, edge.arrow.size=0.02, asp=9/16, margin=-0.15)
[STATEMENT] lemma Interleaves_all_nil: "xs \<cong> {xs, [], P} = (\<forall>n < length xs. P (xs ! n) (drop (Suc n) xs))" [PROOF STATE] proof (prove) goal (1 subgoal): 1. xs \<cong> {xs, [], P} = (\<forall>n<length xs. P (xs ! n) (drop (Suc n) xs)) [PROOF STEP] proof (rule iffI, rule allI, rule impI, rule Interleaves_all_nil_1, assumption+) [PROOF STATE] proof (state) goal (1 subgoal): 1. \<forall>n<length xs. P (xs ! n) (drop (Suc n) xs) \<Longrightarrow> xs \<cong> {xs, [], P} [PROOF STEP] qed (rule Interleaves_all_nil_2, simp)
[STATEMENT] lemma SD_empty [simp]: "SD (\<lambda>_ _. False) = (\<lambda>_ _. False)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. SD (\<lambda>_ _. False) = (\<lambda>_ _. False) [PROOF STEP] by (auto simp: fun_eq_iff SD_def lotteries_on_def set_pmf_not_empty)
PROGRAM prog use Circle IMPLICIT NONE END PROGRAM prog
(* *********************************************************************) (* *) (* The CertiKOS Certified Kit Operating System *) (* *) (* The FLINT Group, Yale University *) (* *) (* Copyright The FLINT Group, Yale University. All rights reserved. *) (* This file is distributed under the terms of the Yale University *) (* Non-Commercial License Agreement. *) (* *) (* *********************************************************************) (** This file provide the semantics for the [Asm] instructions. Since we introduce paging mechanisms, the semantics of memory load and store are different from [Compcert Asm]*) Require Import Coqlib. Require Import Maps. Require Import ASTExtra. Require Import Integers. Require Import Floats. Require Import Values. Require Import Memory. Require Import Events. Require Import Globalenvs. Require Import Smallstep. Require Import AsmX. Require Import Conventions. Require Import Machregs. Require Import AuxLemma. Require Import CommonTactic. Require Import liblayers.logic.PTreeModules. Require Import liblayers.logic.PTreeSemantics. Require Import liblayers.compcertx.MemWithData. Require Import liblayers.compcertx.Stencil. Require Import liblayers.compcertx.MakeProgram. Require Import liblayers.compat.CompatData. Require Import liblayers.compat.CompatPrimSem. Require Import liblayers.compat.CompatLayers. Require Import liblayers.compat.CompatExternalCalls. Require Import CompCertBuiltins. Require Import LAsm. Require Import MemoryExtra. Require Import LAsmModuleSemDef. Require Import Observation. (** ** Invariants preserved by LAsm modules *) Section ModuleSemantics_High_Invariant. Context `{Hobs: Observation}. Context `{Hstencil: Stencil}. Context `{Hmem: Mem.MemoryModel}. Context `{Hmwd: UseMemWithData mem}. Context `{make_program_ops: !MakeProgramOps function Ctypes.type fundef unit}. Context `{make_program_prf: !MakeProgram function Ctypes.type fundef unit}. Section HIGH_INVARIANT. Lemma exec_load_high_level_invariant {D: compatdata} {L} `{acc_def_prf: !AccessorsDefined (D:= D) L}: forall {F V} (ge: Genv.t F V) d rs rs' m m' d' rd chunk a, high_level_invariant d -> (acc_exec_load L) F V ge chunk (m, d) a rs rd = Next rs' (m', d') -> high_level_invariant d'. Proof. unfold acc_exec_load; intros. destruct (acc_exec_load_strong (acc_def:= acc_def_prf) L). destruct x. simpl in *. exploit (exec_load_high_level_invariant ge); simpl; eauto. Qed. Lemma exec_store_high_level_invariant {D: compatdata} {L} `{acc_def_prf: !AccessorsDefined (D:= D) L}: forall {F V} (ge: Genv.t F V) d rs rs' m m' d' rd chunk a rl, high_level_invariant d -> (acc_exec_store L) F V ge chunk (m, d) a rs rd rl = Next rs' (m', d') -> high_level_invariant d'. Proof. unfold acc_exec_store; intros. destruct (acc_exec_store_strong (acc_def:= acc_def_prf) L). destruct x. simpl in *. exploit (exec_store_high_level_invariant ge); simpl; eauto. Qed. Lemma goto_label_high_level_invariant {D: compatdata} {L} `{acc_def_prf: !AccessorsDefined (D:= D) L}: forall d rs m rs' m' d' f0 l, high_level_invariant d -> goto_label (Hfl:= FindLabels_instance_0) f0 l rs (m, d) = Next (mem:= mwd D) rs' (m', d') -> high_level_invariant d'. Proof. unfold goto_label; intros. destruct (label_pos l 0 (fn_code f0)); try discriminate. destruct (rs PC); contra_inv. inv H0; trivial. Qed. Lemma exec_instr_high_level_invariant {D: compatdata} {L} `{acc_def_prf: !AccessorsDefined (D:= D) L}: forall ge rs rs' m m' d d' f0 i, (exec_instr (lcfg_ops:= LC L)) ge f0 i rs (m, d) = Next rs' (m', d') -> high_level_invariant d -> high_level_invariant d'. Proof. intros. unfold exec_instr in *. destruct i; lazymatch goal with | H: context[exec_loadex _ _ _ _ _ _] |- _ => simpl in *; eapply exec_load_high_level_invariant; eauto 1 | H: context[exec_storeex _ _ _ _ _ _ _] |- _ => simpl in *; eapply exec_store_high_level_invariant; eauto 1 | H: context[Asm.exec_instr _ _ _ _ _] |- _ => idtac | [HW: _ = Next _ _ |- _]=> inv HW; eauto end. destruct i; simpl in *; match goal with | H: context[(acc_exec_load _)] |-_ => eapply exec_load_high_level_invariant; eauto 1 | H: context[(acc_exec_store _)] |- _ => eapply exec_store_high_level_invariant; eauto 1 | HW: _ = Next _ _ |- _ => try (inv HW; trivial; fail) | _ => idtac end; lift_unfold; subdestruct; match goal with | HW: _ = Next _ _ |- _ => inv HW; trivial; eapply goto_label_high_level_invariant; eauto 1 end. Qed. Lemma external_call_high_level_invariant' {D: compatdata} {L} `{acc_def_prf: !AccessorsDefined (D:= D) L}: forall {F V} (ge: Genv.t F V) ef args m m' t vl d d' (BUILTIN_ENABLED : match ef with | EF_external _ _ => False | _ => True end), external_call' (mem:= mwd D) (external_calls_ops:= (compatlayer_extcall_ops L)) (fun b => True) ef ge args (m, d) t vl (m', d') -> high_level_invariant d -> high_level_invariant d'. Proof. intros. Opaque decode_longs encode_long. destruct ef; inv BUILTIN_ENABLED; inv H; simpl in *; inv H1; trivial. - (* volatile store *) exploit (volatile_store_without_d (D:=D) ge); eauto. intros [_ ?]; subst; trivial. - (* volatile store global *) exploit (volatile_store_without_d (D:=D) ge); eauto. intros [_ ?]; subst; trivial. - (* malloc *) lift_unfold. destruct H2 as [_ ?]. destruct H3 as [_ ?]. congruence. - (* mfree *) lift_unfold. destruct H4 as [_ ?]. congruence. - (* memcpy *) lift_unfold. destruct H9 as [_ ?]. congruence. Qed. Lemma step_high_level_invariant {D: compatdata} {L} `{acc_def_prf: !AccessorsDefined L}: forall `{extcall_inv_avail_prf: !ExtcallInvariantsAvailable L}, forall `{primcall_inv_avail_prf: !PrimcallInvariantsAvailable L}, forall ge rs rs' m m' d d' t, forall (Hge_external: forall b ef, Genv.find_funct_ptr ge b = Some (External ef) -> exists i sg, ef = EF_external i sg), (step (mem:= mwd D) (lcfg_ops:= LC L)) ge (State rs (m, d)) t (State rs' (m', d')) -> high_level_invariant d -> high_level_invariant d'. Proof. intros until ge. inversion 2; subst. - (* exec_instr *) eapply exec_instr_high_level_invariant; eauto. - (* builtin *) eapply external_call_high_level_invariant'; eauto. - (* annot *) eapply external_call_high_level_invariant'; eauto. - (* external call *) destruct (Hge_external _ _ H5) as [i[sg ?]]; subst. inv H8. inv H0. destruct H1 as [? Hsem]. inv Hsem. destruct H1 as [?[_[Hsem'[?[? ?]]]]]; subst. pose proof (extcall_invariants_available _ _ H0). eapply external_call_high_level_invariant; eauto. - (* prim call *) destruct (Hge_external _ _ H6) as [i[sg ?]]; subst. inv H7. destruct H0 as [?[?[?[? Hsem]]]]; subst. inv Hsem. pose proof (primcall_invariants_available _ _ H1). eapply primitive_call_high_level_invariant; eauto. Qed. End HIGH_INVARIANT. End ModuleSemantics_High_Invariant.
[GOAL] c : Char ⊒ 0 < utf8Size c [PROOFSTEP] simp only [utf8Size] [GOAL] c : Char ⊒ 0 < if c.val ≀ UInt32.ofNatCore 127 utf8Size.proof_1 then UInt32.ofNatCore 1 utf8Size.proof_2 else if c.val ≀ UInt32.ofNatCore 2047 utf8Size.proof_3 then UInt32.ofNatCore 2 utf8Size.proof_4 else if c.val ≀ UInt32.ofNatCore 65535 utf8Size.proof_5 then UInt32.ofNatCore 3 utf8Size.proof_6 else UInt32.ofNatCore 4 utf8Size.proof_7 [PROOFSTEP] repeat (split; decide) [GOAL] c : Char ⊒ 0 < if c.val ≀ UInt32.ofNatCore 127 utf8Size.proof_1 then UInt32.ofNatCore 1 utf8Size.proof_2 else if c.val ≀ UInt32.ofNatCore 2047 utf8Size.proof_3 then UInt32.ofNatCore 2 utf8Size.proof_4 else if c.val ≀ UInt32.ofNatCore 65535 utf8Size.proof_5 then UInt32.ofNatCore 3 utf8Size.proof_6 else UInt32.ofNatCore 4 utf8Size.proof_7 [PROOFSTEP] split [GOAL] case inl c : Char h✝ : c.val ≀ UInt32.ofNatCore 127 utf8Size.proof_1 ⊒ 0 < UInt32.ofNatCore 1 utf8Size.proof_2 case inr c : Char h✝ : Β¬c.val ≀ UInt32.ofNatCore 127 utf8Size.proof_1 ⊒ 0 < if c.val ≀ UInt32.ofNatCore 2047 utf8Size.proof_3 then UInt32.ofNatCore 2 utf8Size.proof_4 else if c.val ≀ UInt32.ofNatCore 65535 utf8Size.proof_5 then UInt32.ofNatCore 3 utf8Size.proof_6 else UInt32.ofNatCore 4 utf8Size.proof_7 [PROOFSTEP] decide [GOAL] case inr c : Char h✝ : Β¬c.val ≀ UInt32.ofNatCore 127 utf8Size.proof_1 ⊒ 0 < if c.val ≀ UInt32.ofNatCore 2047 utf8Size.proof_3 then UInt32.ofNatCore 2 utf8Size.proof_4 else if c.val ≀ UInt32.ofNatCore 65535 utf8Size.proof_5 then UInt32.ofNatCore 3 utf8Size.proof_6 else UInt32.ofNatCore 4 utf8Size.proof_7 [PROOFSTEP] split [GOAL] case inr.inl c : Char h✝¹ : Β¬c.val ≀ UInt32.ofNatCore 127 utf8Size.proof_1 h✝ : c.val ≀ UInt32.ofNatCore 2047 utf8Size.proof_3 ⊒ 0 < UInt32.ofNatCore 2 utf8Size.proof_4 case inr.inr c : Char h✝¹ : Β¬c.val ≀ UInt32.ofNatCore 127 utf8Size.proof_1 h✝ : Β¬c.val ≀ UInt32.ofNatCore 2047 utf8Size.proof_3 ⊒ 0 < if c.val ≀ UInt32.ofNatCore 65535 utf8Size.proof_5 then UInt32.ofNatCore 3 utf8Size.proof_6 else UInt32.ofNatCore 4 utf8Size.proof_7 [PROOFSTEP] decide [GOAL] case inr.inr c : Char h✝¹ : Β¬c.val ≀ UInt32.ofNatCore 127 utf8Size.proof_1 h✝ : Β¬c.val ≀ UInt32.ofNatCore 2047 utf8Size.proof_3 ⊒ 0 < if c.val ≀ UInt32.ofNatCore 65535 utf8Size.proof_5 then UInt32.ofNatCore 3 utf8Size.proof_6 else UInt32.ofNatCore 4 utf8Size.proof_7 [PROOFSTEP] split [GOAL] case inr.inr.inl c : Char h✝² : Β¬c.val ≀ UInt32.ofNatCore 127 utf8Size.proof_1 h✝¹ : Β¬c.val ≀ UInt32.ofNatCore 2047 utf8Size.proof_3 h✝ : c.val ≀ UInt32.ofNatCore 65535 utf8Size.proof_5 ⊒ 0 < UInt32.ofNatCore 3 utf8Size.proof_6 case inr.inr.inr c : Char h✝² : Β¬c.val ≀ UInt32.ofNatCore 127 utf8Size.proof_1 h✝¹ : Β¬c.val ≀ UInt32.ofNatCore 2047 utf8Size.proof_3 h✝ : Β¬c.val ≀ UInt32.ofNatCore 65535 utf8Size.proof_5 ⊒ 0 < UInt32.ofNatCore 4 utf8Size.proof_7 [PROOFSTEP] decide [GOAL] case inr.inr.inr c : Char h✝² : Β¬c.val ≀ UInt32.ofNatCore 127 utf8Size.proof_1 h✝¹ : Β¬c.val ≀ UInt32.ofNatCore 2047 utf8Size.proof_3 h✝ : Β¬c.val ≀ UInt32.ofNatCore 65535 utf8Size.proof_5 ⊒ 0 < UInt32.ofNatCore 4 utf8Size.proof_7 [PROOFSTEP] split [GOAL] case inr.inr.inr c : Char h✝² : Β¬c.val ≀ UInt32.ofNatCore 127 utf8Size.proof_1 h✝¹ : Β¬c.val ≀ UInt32.ofNatCore 2047 utf8Size.proof_3 h✝ : Β¬c.val ≀ UInt32.ofNatCore 65535 utf8Size.proof_5 ⊒ 0 < UInt32.ofNatCore 4 utf8Size.proof_7 [PROOFSTEP] decide [GOAL] c : Char h : isValidCharNat (toNat c) ⊒ ofNat (toNat c) = c [PROOFSTEP] rw [Char.ofNat, dif_pos h] [GOAL] c : Char h : isValidCharNat (toNat c) ⊒ ofNatAux (toNat c) h = c [PROOFSTEP] rfl
/- Copyright 2019 Kevin Sullivan and Ben Hocking. -/ /- Every term has exactly one type in Lean. -/ namespace Types.ex1 #check 2 #check 2 + 2 def x : nat := 2 #check x #check tt #check "Hello, Lean!" #check "Hello, " ++ "Lean!" end Types.ex1 /- All terms are type checked for type correctness. The following code does not type check. -/ namespace Types.ex2 def x : nat := "Hello, Lean!" -- type error #check "Hello, Lean!" + 3 -- type error end Types.ex2 /- Proof checking in Lean is done by type checking. Propositions are types. Proofs are values of these types. If a variable is defined to be of type P, where P is a proposition, then the only kind of proof that can be bound to that variable is a proof term (a value) of type P. You can see a proof checking error in this code. -/ namespace Types.ex3 axioms (P Q : Prop) (p : P) (q : Q) def pf_P : P := p def pf_P' : P := q end Types.ex3 /- You can define your own types in Lean. We will get into this topic in detail later in the course. Each type comes with its own namespace, with the same name as the type itself. If you want to refer to constructors of a type without writing the type name as a namespace prefix, you can "open" the namespace. -/ namespace Types.ex4 inductive day : Type | Sunday : day | Monday : day | Tuesday : day | Wednesday : day | Thursday : day | Friday : day | Saturday : day #check day.Monday open day #check Monday end Types.ex4 /- Types are terms so they too have types. There are two "sorts" of types in Lean: logical types are propositions; computational types are for programming. Computation types include basic data types as well as function types. You can see here that function types are all of type "Type". -/ namespace Types.ex5a -- computational data types #check nat #check string #check bool -- computational function types #check nat β†’ nat #check string β†’ nat #check string β†’ bool end Types.ex5a /- And all propostions are of type, "Prop". -/ namespace Types.ex5b #check true #check false #check 0 = 1 axioms P Q : Prop #check P #check Q #check P ∧ Q #check P ∨ Q #check P β†’ Q #check Β¬ P end Types.ex5b /- Proofs really are just values (terms) of their corresponding types. -/ namespace Terms.ex8 axioms (P : Prop) (p : P) example : P := p end Terms.ex8
Require Import Unicode.Utf8. (* Welcome. Here is some code: *) Inductive bool : Type := | true : bool | false : bool . (* Here is a theorem: *) Theorem bools_are_true_or_false : βˆ€ b, b = true \/ b = false. Proof. intro. destruct b. { left. reflexivity. } { right. reflexivity. } Qed. Theorem bools_are_not_true_and_false : βˆ€ b, Β¬ (b = true ∧ b = false). Proof. intro. intro. destruct H. destruct b. inversion H0. inversion H. Qed. (* Yet another theorem: *) Theorem t : False. Proof. Admitted.
import Meta.Util open Nat List Classical theorem notImplies1 : βˆ€ {P Q : Prop}, Β¬ (P β†’ Q) β†’ P := by intros P Q h cases Classical.em P with | inl p => exact p | inr np => apply False.elim apply h intro p exact False.elim (np p) theorem notImplies2 : βˆ€ {P Q : Prop}, Β¬ (P β†’ Q) β†’ Β¬ Q := by intros P Q h cases Classical.em Q with | inl q => exact False.elim (h (Ξ» _ => q)) | inr nq => exact nq theorem contradiction : βˆ€ {P : Prop}, P β†’ Β¬ P β†’ False := Ξ» p np => np p theorem orComm : βˆ€ {P Q : Prop}, P ∨ Q β†’ Q ∨ P := by intros P Q h cases h with | inl hp => exact Or.inr hp | inr hq => exact Or.inl hq theorem orAssocDir : βˆ€ {P Q R: Prop}, P ∨ Q ∨ R β†’ (P ∨ Q) ∨ R := by intros P Q R h cases h with | inl h₁ => exact Or.inl (Or.inl h₁) | inr hβ‚‚ => cases hβ‚‚ with | inl h₃ => exact Or.inl (Or.inr h₃) | inr hβ‚„ => exact Or.inr hβ‚„ theorem orAssocConv : βˆ€ {P Q R : Prop}, (P ∨ Q) ∨ R β†’ P ∨ Q ∨ R := by intros P Q R h cases h with | inl h₁ => cases h₁ with | inl h₃ => exact Or.inl h₃ | inr hβ‚„ => exact (Or.inr (Or.inl hβ‚„)) | inr hβ‚‚ => exact Or.inr (Or.inr hβ‚‚) theorem congOrRight : βˆ€ {P Q R : Prop}, (P β†’ Q) β†’ P ∨ R β†’ Q ∨ R := by intros P Q R h₁ hβ‚‚ cases hβ‚‚ with | inl h₃ => exact Or.inl (h₁ h₃) | inr hβ‚„ => exact Or.inr hβ‚„ theorem congOrLeft : βˆ€ {R P Q : Prop}, (P β†’ Q) β†’ R ∨ P β†’ R ∨ Q := by intros P Q R h₁ hβ‚‚ apply orComm exact congOrRight h₁ (orComm hβ‚‚) theorem orImplies : βˆ€ {p q : Prop}, (Β¬ p β†’ q) β†’ p ∨ q := by intros p q h exact match em p with | Or.inl pp => Or.inl pp | Or.inr npp => match em q with | Or.inl pq => Or.inr pq | Or.inr npq => False.elim (npq (h npp)) theorem orImpliesβ‚‚ : βˆ€ {p q : Prop}, (Β¬ p) ∨ q β†’ p β†’ q := by intros P Q h p cases h with | inl np => exact False.elim (np p) | inr q => exact q theorem orImplies₃ : βˆ€ {p q : Prop}, p ∨ q β†’ Β¬ p β†’ q := by intros P Q h np cases h with | inl p => exact False.elim (np p) | inr q => exact q theorem scope : βˆ€ {p q : Prop}, (p β†’ q) β†’ Β¬ p ∨ q := by intros p q h exact match em p with | Or.inl pp => Or.inr (h pp) | Or.inr npp => Or.inl npp def impliesElim : βˆ€ {p q : Prop}, (p β†’ q) β†’ Β¬ p ∨ q := scope theorem deMorganSmall : βˆ€ {p q : Prop}, Β¬ (p ∨ q) β†’ Β¬ p ∧ Β¬ q := by intros p q h exact match em p, em q with | Or.inl pp, _ => False.elim (h (Or.inl pp)) | Or.inr _, Or.inl pq => False.elim (h (Or.inr pq)) | Or.inr npp, Or.inr npq => And.intro npp npq theorem deMorganSmallβ‚‚ : βˆ€ {p q : Prop}, Β¬ p ∧ Β¬ q β†’ Β¬ (p ∨ q) := by intros p q h have ⟨np, nq⟩ := h exact match em p, em q with | Or.inl pp, _ => False.elim (np pp) | _ , Or.inl pq => False.elim (nq pq) | Or.inr npp, Or.inr npq => Ξ» hβ‚‚ => match hβ‚‚ with | Or.inl pp => False.elim (npp pp) | Or.inr pq => False.elim (npq pq) theorem doubleNeg : βˆ€ {p : Prop}, Β¬ Β¬ p β†’ p := by intros p h exact match em p with | Or.inl pp => pp | Or.inr np => False.elim (h (Ξ» p => np p)) theorem doubleNegβ‚‚ : βˆ€ {p : Prop}, p β†’ Β¬ Β¬ p := Ξ» p np => np p theorem deMorgan : βˆ€ {l : List Prop}, Β¬ orN (notList l) β†’ andN l := by intros l h exact match l with | [] => True.intro | [t] => by simp [andN] simp [notList, orN, map] at h cases em t with | inl tt => exact tt | inr ntt => exact False.elim (h ntt) | h₁::hβ‚‚::t => by simp [orN, notList, map] at h have ⟨ t₁, tβ‚‚ ⟩ := deMorganSmall h simp [orN] at tβ‚‚ have ih := @deMorgan (hβ‚‚::t) tβ‚‚ simp [andN] have t₁' := doubleNeg t₁ exact ⟨ t₁', ih ⟩ theorem deMorganβ‚‚ : βˆ€ {l : List Prop}, andN l β†’ Β¬ orN (notList l) := by intros l h exact match l with | [] => by simp [orN, notList] | [t] => by simp [orN, notList]; simp [andN] at h; exact doubleNegβ‚‚ h | h₁::hβ‚‚::t => by simp [orN, notList, map] simp [andN] at h apply deMorganSmallβ‚‚ have nnh₁ := doubleNegβ‚‚ (And.left h) have ih := @deMorganβ‚‚ (hβ‚‚::t) (And.right h) exact ⟨nnh₁, ih⟩ theorem cnfAndNeg : βˆ€ (l : List Prop), andN l ∨ orN (notList l) := by intro l apply orComm apply orImplies intro h exact deMorgan h theorem cnfAndPos : βˆ€ (l : List Prop) (i : Nat), Β¬ (andN l) ∨ List.getD l i True := by intros l i apply orImplies intro h have h' := doubleNeg h match l with | [] => exact True.intro | [p] => match i with | 0 => exact h' | _ + 1 => exact True.intro | p₁::pβ‚‚::ps => match i with | zero => exact And.left h' | succ i' => simp [List.getD] have IH := cnfAndPos (pβ‚‚::ps) i' exact orImpliesβ‚‚ IH (And.right h') theorem cong : βˆ€ {A B : Type u} {f₁ fβ‚‚ : A β†’ B} {t₁ tβ‚‚ : A}, f₁ = fβ‚‚ β†’ t₁ = tβ‚‚ β†’ f₁ t₁ = fβ‚‚ tβ‚‚ := by intros A B f₁ fβ‚‚ t₁ tβ‚‚ h₁ hβ‚‚ rewrite [h₁, hβ‚‚] exact rfl theorem eqResolve {P Q : Prop} : P β†’ (P ↔ Q) β†’ Q := by intros h₁ hβ‚‚ rewrite [← hβ‚‚] exact h₁ theorem dupOr {P Q : Prop} : P ∨ P ∨ Q β†’ P ∨ Q := Ξ» h => match h with | Or.inl p => Or.inl p | Or.inr (Or.inl p) => Or.inl p | Or.inr (Or.inr q) => Or.inr q theorem dupOrβ‚‚ {P : Prop} : P ∨ P β†’ P := Ξ» h => match h with | Or.inl p => p | Or.inr p => p
{-# OPTIONS --rewriting #-} module Examples where import Examples.Syntax import Examples.OpSem import Examples.Run import Examples.Type
[GOAL] X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝⁡ : TopologicalSpace X inst✝⁴ : TopologicalSpace R inst✝³ : Fintype n inst✝² : DecidableEq n inst✝¹ : CommRing R inst✝ : TopologicalRing R A : X β†’ Matrix n n R hA : Continuous A ⊒ Continuous fun x => det (A x) [PROOFSTEP] simp_rw [Matrix.det_apply] [GOAL] X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝⁡ : TopologicalSpace X inst✝⁴ : TopologicalSpace R inst✝³ : Fintype n inst✝² : DecidableEq n inst✝¹ : CommRing R inst✝ : TopologicalRing R A : X β†’ Matrix n n R hA : Continuous A ⊒ Continuous fun x => Finset.sum Finset.univ fun x_1 => ↑Equiv.Perm.sign x_1 β€’ Finset.prod Finset.univ fun x_2 => A x (↑x_1 x_2) x_2 [PROOFSTEP] refine' continuous_finset_sum _ fun l _ => Continuous.const_smul _ _ [GOAL] X : Type u_1 Ξ± : Type u_2 l✝ : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l✝ β†’ Type u_9 n' : l✝ β†’ Type u_10 inst✝⁡ : TopologicalSpace X inst✝⁴ : TopologicalSpace R inst✝³ : Fintype n inst✝² : DecidableEq n inst✝¹ : CommRing R inst✝ : TopologicalRing R A : X β†’ Matrix n n R hA : Continuous A l : Equiv.Perm n x✝ : l ∈ Finset.univ ⊒ Continuous fun x => Finset.prod Finset.univ fun x_1 => A x (↑l x_1) x_1 [PROOFSTEP] refine' continuous_finset_prod _ fun l _ => hA.matrix_elem _ _ [GOAL] X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝¹ : TopologicalSpace X inst✝ : TopologicalSpace R A : X β†’ Matrix n l R B : X β†’ Matrix n m R C : X β†’ Matrix p l R D : X β†’ Matrix p m R hA : Continuous A hB : Continuous B hC : Continuous C hD : Continuous D ⊒ βˆ€ (i : n βŠ• p) (j : l βŠ• m), Continuous fun a => fromBlocks (A a) (B a) (C a) (D a) i j [PROOFSTEP] rintro (i | i) (j | j) [GOAL] case inl.inl X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝¹ : TopologicalSpace X inst✝ : TopologicalSpace R A : X β†’ Matrix n l R B : X β†’ Matrix n m R C : X β†’ Matrix p l R D : X β†’ Matrix p m R hA : Continuous A hB : Continuous B hC : Continuous C hD : Continuous D i : n j : l ⊒ Continuous fun a => fromBlocks (A a) (B a) (C a) (D a) (Sum.inl i) (Sum.inl j) [PROOFSTEP] refine' Continuous.matrix_elem _ i j [GOAL] case inl.inr X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝¹ : TopologicalSpace X inst✝ : TopologicalSpace R A : X β†’ Matrix n l R B : X β†’ Matrix n m R C : X β†’ Matrix p l R D : X β†’ Matrix p m R hA : Continuous A hB : Continuous B hC : Continuous C hD : Continuous D i : n j : m ⊒ Continuous fun a => fromBlocks (A a) (B a) (C a) (D a) (Sum.inl i) (Sum.inr j) [PROOFSTEP] refine' Continuous.matrix_elem _ i j [GOAL] case inr.inl X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝¹ : TopologicalSpace X inst✝ : TopologicalSpace R A : X β†’ Matrix n l R B : X β†’ Matrix n m R C : X β†’ Matrix p l R D : X β†’ Matrix p m R hA : Continuous A hB : Continuous B hC : Continuous C hD : Continuous D i : p j : l ⊒ Continuous fun a => fromBlocks (A a) (B a) (C a) (D a) (Sum.inr i) (Sum.inl j) [PROOFSTEP] refine' Continuous.matrix_elem _ i j [GOAL] case inr.inr X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝¹ : TopologicalSpace X inst✝ : TopologicalSpace R A : X β†’ Matrix n l R B : X β†’ Matrix n m R C : X β†’ Matrix p l R D : X β†’ Matrix p m R hA : Continuous A hB : Continuous B hC : Continuous C hD : Continuous D i : p j : m ⊒ Continuous fun a => fromBlocks (A a) (B a) (C a) (D a) (Sum.inr i) (Sum.inr j) [PROOFSTEP] refine' Continuous.matrix_elem _ i j [GOAL] case inl.inl X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝¹ : TopologicalSpace X inst✝ : TopologicalSpace R A : X β†’ Matrix n l R B : X β†’ Matrix n m R C : X β†’ Matrix p l R D : X β†’ Matrix p m R hA : Continuous A hB : Continuous B hC : Continuous C hD : Continuous D i : n j : l ⊒ Continuous fun a => A a [PROOFSTEP] assumption [GOAL] case inl.inr X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝¹ : TopologicalSpace X inst✝ : TopologicalSpace R A : X β†’ Matrix n l R B : X β†’ Matrix n m R C : X β†’ Matrix p l R D : X β†’ Matrix p m R hA : Continuous A hB : Continuous B hC : Continuous C hD : Continuous D i : n j : m ⊒ Continuous fun a => B a [PROOFSTEP] assumption [GOAL] case inr.inl X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝¹ : TopologicalSpace X inst✝ : TopologicalSpace R A : X β†’ Matrix n l R B : X β†’ Matrix n m R C : X β†’ Matrix p l R D : X β†’ Matrix p m R hA : Continuous A hB : Continuous B hC : Continuous C hD : Continuous D i : p j : l ⊒ Continuous fun a => C a [PROOFSTEP] assumption [GOAL] case inr.inr X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝¹ : TopologicalSpace X inst✝ : TopologicalSpace R A : X β†’ Matrix n l R B : X β†’ Matrix n m R C : X β†’ Matrix p l R D : X β†’ Matrix p m R hA : Continuous A hB : Continuous B hC : Continuous C hD : Continuous D i : p j : m ⊒ Continuous fun a => D a [PROOFSTEP] assumption [GOAL] X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝³ : TopologicalSpace X inst✝² : TopologicalSpace R inst✝¹ : Zero R inst✝ : DecidableEq l A : X β†’ (i : l) β†’ Matrix (m' i) (n' i) R hA : Continuous A x✝¹ : (i : l) Γ— m' i x✝ : (i : l) Γ— n' i i₁ : l iβ‚‚ : m' i₁ j₁ : l jβ‚‚ : n' j₁ ⊒ Continuous fun a => blockDiagonal' (A a) { fst := i₁, snd := iβ‚‚ } { fst := j₁, snd := jβ‚‚ } [PROOFSTEP] dsimp only [blockDiagonal'_apply'] [GOAL] X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝³ : TopologicalSpace X inst✝² : TopologicalSpace R inst✝¹ : Zero R inst✝ : DecidableEq l A : X β†’ (i : l) β†’ Matrix (m' i) (n' i) R hA : Continuous A x✝¹ : (i : l) Γ— m' i x✝ : (i : l) Γ— n' i i₁ : l iβ‚‚ : m' i₁ j₁ : l jβ‚‚ : n' j₁ ⊒ Continuous fun a => if h : i₁ = j₁ then A a i₁ iβ‚‚ (cast (_ : n' j₁ = n' i₁) jβ‚‚) else 0 [PROOFSTEP] split_ifs with h [GOAL] case pos X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝³ : TopologicalSpace X inst✝² : TopologicalSpace R inst✝¹ : Zero R inst✝ : DecidableEq l A : X β†’ (i : l) β†’ Matrix (m' i) (n' i) R hA : Continuous A x✝¹ : (i : l) Γ— m' i x✝ : (i : l) Γ— n' i i₁ : l iβ‚‚ : m' i₁ j₁ : l jβ‚‚ : n' j₁ h : i₁ = j₁ ⊒ Continuous fun a => A a i₁ iβ‚‚ (cast (_ : n' j₁ = n' i₁) jβ‚‚) [PROOFSTEP] subst h [GOAL] case pos X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝³ : TopologicalSpace X inst✝² : TopologicalSpace R inst✝¹ : Zero R inst✝ : DecidableEq l A : X β†’ (i : l) β†’ Matrix (m' i) (n' i) R hA : Continuous A x✝¹ : (i : l) Γ— m' i x✝ : (i : l) Γ— n' i i₁ : l iβ‚‚ : m' i₁ jβ‚‚ : n' i₁ ⊒ Continuous fun a => A a i₁ iβ‚‚ (cast (_ : n' i₁ = n' i₁) jβ‚‚) [PROOFSTEP] exact ((continuous_apply i₁).comp hA).matrix_elem iβ‚‚ jβ‚‚ [GOAL] case neg X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝³ : TopologicalSpace X inst✝² : TopologicalSpace R inst✝¹ : Zero R inst✝ : DecidableEq l A : X β†’ (i : l) β†’ Matrix (m' i) (n' i) R hA : Continuous A x✝¹ : (i : l) Γ— m' i x✝ : (i : l) Γ— n' i i₁ : l iβ‚‚ : m' i₁ j₁ : l jβ‚‚ : n' j₁ h : Β¬i₁ = j₁ ⊒ Continuous fun a => 0 [PROOFSTEP] exact continuous_const [GOAL] X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝⁴ : Semiring Ξ± inst✝³ : AddCommMonoid R inst✝² : TopologicalSpace R inst✝¹ : Module Ξ± R inst✝ : T2Space R f : X β†’ Matrix m n R ⊒ (βˆ‘' (x : X), f x)α΅€ = βˆ‘' (x : X), (f x)α΅€ [PROOFSTEP] by_cases hf : Summable f [GOAL] case pos X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝⁴ : Semiring Ξ± inst✝³ : AddCommMonoid R inst✝² : TopologicalSpace R inst✝¹ : Module Ξ± R inst✝ : T2Space R f : X β†’ Matrix m n R hf : Summable f ⊒ (βˆ‘' (x : X), f x)α΅€ = βˆ‘' (x : X), (f x)α΅€ [PROOFSTEP] exact hf.hasSum.matrix_transpose.tsum_eq.symm [GOAL] case neg X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝⁴ : Semiring Ξ± inst✝³ : AddCommMonoid R inst✝² : TopologicalSpace R inst✝¹ : Module Ξ± R inst✝ : T2Space R f : X β†’ Matrix m n R hf : Β¬Summable f ⊒ (βˆ‘' (x : X), f x)α΅€ = βˆ‘' (x : X), (f x)α΅€ [PROOFSTEP] have hft := summable_matrix_transpose.not.mpr hf [GOAL] case neg X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝⁴ : Semiring Ξ± inst✝³ : AddCommMonoid R inst✝² : TopologicalSpace R inst✝¹ : Module Ξ± R inst✝ : T2Space R f : X β†’ Matrix m n R hf : Β¬Summable f hft : Β¬Summable fun x => (f x)α΅€ ⊒ (βˆ‘' (x : X), f x)α΅€ = βˆ‘' (x : X), (f x)α΅€ [PROOFSTEP] rw [tsum_eq_zero_of_not_summable hf, tsum_eq_zero_of_not_summable hft, transpose_zero] [GOAL] X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝⁢ : Semiring Ξ± inst✝⁡ : AddCommMonoid R inst✝⁴ : TopologicalSpace R inst✝³ : Module Ξ± R inst✝² : StarAddMonoid R inst✝¹ : ContinuousStar R inst✝ : T2Space R f : X β†’ Matrix m n R ⊒ (βˆ‘' (x : X), f x)α΄΄ = βˆ‘' (x : X), (f x)α΄΄ [PROOFSTEP] by_cases hf : Summable f [GOAL] case pos X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝⁢ : Semiring Ξ± inst✝⁡ : AddCommMonoid R inst✝⁴ : TopologicalSpace R inst✝³ : Module Ξ± R inst✝² : StarAddMonoid R inst✝¹ : ContinuousStar R inst✝ : T2Space R f : X β†’ Matrix m n R hf : Summable f ⊒ (βˆ‘' (x : X), f x)α΄΄ = βˆ‘' (x : X), (f x)α΄΄ [PROOFSTEP] exact hf.hasSum.matrix_conjTranspose.tsum_eq.symm [GOAL] case neg X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝⁢ : Semiring Ξ± inst✝⁡ : AddCommMonoid R inst✝⁴ : TopologicalSpace R inst✝³ : Module Ξ± R inst✝² : StarAddMonoid R inst✝¹ : ContinuousStar R inst✝ : T2Space R f : X β†’ Matrix m n R hf : Β¬Summable f ⊒ (βˆ‘' (x : X), f x)α΄΄ = βˆ‘' (x : X), (f x)α΄΄ [PROOFSTEP] have hft := summable_matrix_conjTranspose.not.mpr hf [GOAL] case neg X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝⁢ : Semiring Ξ± inst✝⁡ : AddCommMonoid R inst✝⁴ : TopologicalSpace R inst✝³ : Module Ξ± R inst✝² : StarAddMonoid R inst✝¹ : ContinuousStar R inst✝ : T2Space R f : X β†’ Matrix m n R hf : Β¬Summable f hft : Β¬Summable fun x => (f x)α΄΄ ⊒ (βˆ‘' (x : X), f x)α΄΄ = βˆ‘' (x : X), (f x)α΄΄ [PROOFSTEP] rw [tsum_eq_zero_of_not_summable hf, tsum_eq_zero_of_not_summable hft, conjTranspose_zero] [GOAL] X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝⁡ : Semiring Ξ± inst✝⁴ : AddCommMonoid R inst✝³ : TopologicalSpace R inst✝² : Module Ξ± R inst✝¹ : DecidableEq n inst✝ : T2Space R f : X β†’ n β†’ R ⊒ diagonal (βˆ‘' (x : X), f x) = βˆ‘' (x : X), diagonal (f x) [PROOFSTEP] by_cases hf : Summable f [GOAL] case pos X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝⁡ : Semiring Ξ± inst✝⁴ : AddCommMonoid R inst✝³ : TopologicalSpace R inst✝² : Module Ξ± R inst✝¹ : DecidableEq n inst✝ : T2Space R f : X β†’ n β†’ R hf : Summable f ⊒ diagonal (βˆ‘' (x : X), f x) = βˆ‘' (x : X), diagonal (f x) [PROOFSTEP] exact hf.hasSum.matrix_diagonal.tsum_eq.symm [GOAL] case neg X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝⁡ : Semiring Ξ± inst✝⁴ : AddCommMonoid R inst✝³ : TopologicalSpace R inst✝² : Module Ξ± R inst✝¹ : DecidableEq n inst✝ : T2Space R f : X β†’ n β†’ R hf : Β¬Summable f ⊒ diagonal (βˆ‘' (x : X), f x) = βˆ‘' (x : X), diagonal (f x) [PROOFSTEP] have hft := summable_matrix_diagonal.not.mpr hf [GOAL] case neg X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝⁡ : Semiring Ξ± inst✝⁴ : AddCommMonoid R inst✝³ : TopologicalSpace R inst✝² : Module Ξ± R inst✝¹ : DecidableEq n inst✝ : T2Space R f : X β†’ n β†’ R hf : Β¬Summable f hft : Β¬Summable fun x => diagonal (f x) ⊒ diagonal (βˆ‘' (x : X), f x) = βˆ‘' (x : X), diagonal (f x) [PROOFSTEP] rw [tsum_eq_zero_of_not_summable hf, tsum_eq_zero_of_not_summable hft] [GOAL] case neg X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝⁡ : Semiring Ξ± inst✝⁴ : AddCommMonoid R inst✝³ : TopologicalSpace R inst✝² : Module Ξ± R inst✝¹ : DecidableEq n inst✝ : T2Space R f : X β†’ n β†’ R hf : Β¬Summable f hft : Β¬Summable fun x => diagonal (f x) ⊒ diagonal 0 = 0 [PROOFSTEP] exact diagonal_zero [GOAL] X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝⁡ : Semiring Ξ± inst✝⁴ : AddCommMonoid R inst✝³ : TopologicalSpace R inst✝² : Module Ξ± R inst✝¹ : DecidableEq p inst✝ : T2Space R f : X β†’ p β†’ Matrix m n R ⊒ blockDiagonal (βˆ‘' (x : X), f x) = βˆ‘' (x : X), blockDiagonal (f x) [PROOFSTEP] by_cases hf : Summable f [GOAL] case pos X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝⁡ : Semiring Ξ± inst✝⁴ : AddCommMonoid R inst✝³ : TopologicalSpace R inst✝² : Module Ξ± R inst✝¹ : DecidableEq p inst✝ : T2Space R f : X β†’ p β†’ Matrix m n R hf : Summable f ⊒ blockDiagonal (βˆ‘' (x : X), f x) = βˆ‘' (x : X), blockDiagonal (f x) [PROOFSTEP] exact hf.hasSum.matrix_blockDiagonal.tsum_eq.symm [GOAL] case neg X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝⁡ : Semiring Ξ± inst✝⁴ : AddCommMonoid R inst✝³ : TopologicalSpace R inst✝² : Module Ξ± R inst✝¹ : DecidableEq p inst✝ : T2Space R f : X β†’ p β†’ Matrix m n R hf : Β¬Summable f ⊒ blockDiagonal (βˆ‘' (x : X), f x) = βˆ‘' (x : X), blockDiagonal (f x) [PROOFSTEP] have hft := summable_matrix_blockDiagonal.not.mpr hf [GOAL] case neg X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝⁡ : Semiring Ξ± inst✝⁴ : AddCommMonoid R inst✝³ : TopologicalSpace R inst✝² : Module Ξ± R inst✝¹ : DecidableEq p inst✝ : T2Space R f : X β†’ p β†’ Matrix m n R hf : Β¬Summable f hft : Β¬Summable fun x => blockDiagonal (f x) ⊒ blockDiagonal (βˆ‘' (x : X), f x) = βˆ‘' (x : X), blockDiagonal (f x) [PROOFSTEP] rw [tsum_eq_zero_of_not_summable hf, tsum_eq_zero_of_not_summable hft] [GOAL] case neg X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝⁡ : Semiring Ξ± inst✝⁴ : AddCommMonoid R inst✝³ : TopologicalSpace R inst✝² : Module Ξ± R inst✝¹ : DecidableEq p inst✝ : T2Space R f : X β†’ p β†’ Matrix m n R hf : Β¬Summable f hft : Β¬Summable fun x => blockDiagonal (f x) ⊒ blockDiagonal 0 = 0 [PROOFSTEP] exact blockDiagonal_zero [GOAL] X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝⁡ : Semiring Ξ± inst✝⁴ : AddCommMonoid R inst✝³ : TopologicalSpace R inst✝² : Module Ξ± R inst✝¹ : DecidableEq l inst✝ : T2Space R f : X β†’ (i : l) β†’ Matrix (m' i) (n' i) R ⊒ blockDiagonal' (βˆ‘' (x : X), f x) = βˆ‘' (x : X), blockDiagonal' (f x) [PROOFSTEP] by_cases hf : Summable f [GOAL] case pos X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝⁡ : Semiring Ξ± inst✝⁴ : AddCommMonoid R inst✝³ : TopologicalSpace R inst✝² : Module Ξ± R inst✝¹ : DecidableEq l inst✝ : T2Space R f : X β†’ (i : l) β†’ Matrix (m' i) (n' i) R hf : Summable f ⊒ blockDiagonal' (βˆ‘' (x : X), f x) = βˆ‘' (x : X), blockDiagonal' (f x) [PROOFSTEP] exact hf.hasSum.matrix_blockDiagonal'.tsum_eq.symm [GOAL] case neg X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝⁡ : Semiring Ξ± inst✝⁴ : AddCommMonoid R inst✝³ : TopologicalSpace R inst✝² : Module Ξ± R inst✝¹ : DecidableEq l inst✝ : T2Space R f : X β†’ (i : l) β†’ Matrix (m' i) (n' i) R hf : Β¬Summable f ⊒ blockDiagonal' (βˆ‘' (x : X), f x) = βˆ‘' (x : X), blockDiagonal' (f x) [PROOFSTEP] have hft := summable_matrix_blockDiagonal'.not.mpr hf [GOAL] case neg X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝⁡ : Semiring Ξ± inst✝⁴ : AddCommMonoid R inst✝³ : TopologicalSpace R inst✝² : Module Ξ± R inst✝¹ : DecidableEq l inst✝ : T2Space R f : X β†’ (i : l) β†’ Matrix (m' i) (n' i) R hf : Β¬Summable f hft : Β¬Summable fun x => blockDiagonal' (f x) ⊒ blockDiagonal' (βˆ‘' (x : X), f x) = βˆ‘' (x : X), blockDiagonal' (f x) [PROOFSTEP] rw [tsum_eq_zero_of_not_summable hf, tsum_eq_zero_of_not_summable hft] [GOAL] case neg X : Type u_1 Ξ± : Type u_2 l : Type u_3 m : Type u_4 n : Type u_5 p : Type u_6 S : Type u_7 R : Type u_8 m' : l β†’ Type u_9 n' : l β†’ Type u_10 inst✝⁡ : Semiring Ξ± inst✝⁴ : AddCommMonoid R inst✝³ : TopologicalSpace R inst✝² : Module Ξ± R inst✝¹ : DecidableEq l inst✝ : T2Space R f : X β†’ (i : l) β†’ Matrix (m' i) (n' i) R hf : Β¬Summable f hft : Β¬Summable fun x => blockDiagonal' (f x) ⊒ blockDiagonal' 0 = 0 [PROOFSTEP] exact blockDiagonal'_zero
** Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. ** See https://llvm.org/LICENSE.txt for license information. ** SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception * Vectorizer - argonne loop s343 * cpgi$g novector program kv13 integer ld, nloops parameter (ld=100,nloops=135) !PGI, ld=1000 real dtime, ctime double precision array integer ntimes common /cdata/ array(1000*1000) !PGI, ld*ld double precision a(ld),b(ld),c(ld),d(ld),e(ld),aa(ld,ld), + bb(ld,ld),cc(ld,ld) n = 10 ntimes = 100000 call s343 (ntimes,ld,n,ctime,dtime,a,b,c,d,e,aa,bb,cc) end subroutine set2d(n,array,value,stride) c c -- initialize two-dimensional arrays c integer i, j, n, stride, frac, frac2, ld parameter(frac=-1, frac2=-2, ld=100) !PGI, ld=1000 double precision array(ld,n),value if ( stride .eq. frac ) then do 10 j=1,n do 20 i=1,n array(i,j) = 1.0d0/dble(i) 20 continue 10 continue elseif ( stride .eq. frac2 ) then do 30 j=1,n do 40 i=1,n array(i,j) = 1.0d0/dble(i*i) 40 continue 30 continue else do 50 j=1,n,stride do 60 i=1,n array(i,j) = value 60 continue 50 continue endif return end subroutine chk (chksum,totit,n,t2,name) c c -- called by each loop to record and report results c -- chksum is the computed checksum c -- totit is the number of times the loop was executed c -- n is the length of the loop c -- t2 is the time to execute loop 'name' c integer nloops, nvl, i, totit, n double precision epslon, chksum, rnorm parameter (nloops=135,nvl=3,epslon=1.d-10) character*5 name double precision res integer ifail integer expect ifail = 1 res = 2.9289682539682541D+01 rnorm = sqrt((res-chksum)*(res-chksum))/chksum if ( ( rnorm .gt. epslon) .or. ( rnorm .lt. -epslon) ) then d write(*,98)name,n,chksum,res,rnorm,i ifail = 1 else d write(*,99)name,n,chksum,res,i ifail = 0 endif d98 format(a6,i5,5x,'no time',2x,1p,e22.16,1x,1p,e22.16,1p,d13.4 d +,9x,i3) d99 format(a6,i5,5x,'no time',2x,1p,e22.16,1x,1p,e22.16,22x,i3) data expect/0/ call check(ifail, expect, 1) return end double precision function cs1d(n,a) c c -- calculate one-dimensional checksum c integer i,n double precision a(n), sum sum = 0.0d0 do 10 i = 1,n sum = sum + a(i) 10 continue cs1d = sum return end subroutine dummy(ld,n,a,b,c,d,e,aa,bb,cc,s) c c -- called in each loop to make all computations appear required c integer ld, n double precision a(n), b(n), c(n), d(n), e(n), aa(ld,n), + bb(ld,n), cc(ld,n) double precision s return end subroutine init(ld,n,a,b,c,d,e,aa,bb,cc,name) double precision zero, small, half, one, two, any, array parameter(any=0.0d0,zero=0.0d0,half=.5d0,one=1.0d0, + two=2.0d0,small=.000001d0) integer unit, frac, frac2, ld, n parameter(unit=1, frac=-1, frac2=-2) double precision a(n), b(n), c(n), d(n), e(n), aa(ld,n), + bb(ld,n), cc(ld,n) common /cdata/ array(1000*1000) character*5 name call set2d(n,aa, any,frac) call set2d(n,bb, one,unit) end cpgi$g vector subroutine s343 (ntimes,ld,n,ctime,dtime,a,b,c,d,e,aa,bb,cc) c c packing c pack 2-d array into one dimension c integer ntimes, ld, n, i, nl, j, k, nn double precision a(n), b(n), c(n), d(n), e(n), aa(ld,n), + bb(ld,n), cc(ld,n) double precision chksum, cs1d, array real t2, ctime, dtime parameter(nn=1000) common /cdata/ array(nn*nn) call init(ld,n,a,b,c,d,e,aa,bb,cc,'s343 ') do 1 nl = 1,ntimes/n k = 0 do 10 i = 1,n do 20 j= 1,n if (bb(i,j) .gt. 0.d0) then k = k + 1 array(k) = aa(i,j) endif 20 continue 10 continue call dummy(ld,n,a,b,c,d,e,aa,bb,cc,1.d0) 1 continue chksum = cs1d(n*n,array) call chk (chksum,(ntimes/n)*n*n,n,t2,'s343 ') return end
theory Proof_5_5 imports Requirements VCTheoryLemmas begin abbreviation s where "s s0 requestButton_value \<equiv> (toEnv (setVarAny s0 requestButton_value)) " lemma VC5_R5_aux1: "toEnvP s2 \<and> toEnvP s0 \<and> substate s2 s0 \<and> toEnvNum s2 s3 < T1 \<and> s3 = s s0 requestButton_value \<Longrightarrow> toEnvNum s2 s0 < T1" apply auto apply(simp split: if_splits) using substate_refl substate_asym[of s0 "s s0 requestButton_value"] by auto lemma VC5_R5: " (toEnvP s0 \<and> (\<forall>s1 s2 s3. substate s1 s2 \<and> substate s2 s3 \<and> substate s3 s0 \<and> toEnvP s1 \<and> toEnvP s2 \<and> toEnvP s3 \<and> toEnvNum s1 s2 = Ctrl \<and> toEnvNum s2 s3 < T1 \<and> getVarBool s1 minimalRed \<noteq> NOT_PRESSED \<and> getVarBool s2 minimalRed = NOT_PRESSED \<longrightarrow> getVarBool s3 minimalRed = NOT_PRESSED)) \<and> env (setVarAny s0 requestButton_value) requestButton_value \<and> getPstate (setVarAny s0 requestButton_value) Ctrl = minimalRed \<and> \<not> getVarBool (setVarAny s0 requestButton_value) Ctrl \<and> \<not> MINIMAL_RED_TIME_LIMIT \<le> ltimeEnv (setVarAny s0 requestButton_value) Ctrl \<Longrightarrow> substate s1 s2 \<and> substate s2 s3 \<and> substate s3 (s s0 requestButton_value) \<and> toEnvP s1 \<and> toEnvP s2 \<and> toEnvP s3 \<and> toEnvNum s1 s2 = Ctrl \<and> toEnvNum s2 s3 < T1 \<and> getVarBool s1 minimalRed \<noteq> NOT_PRESSED \<and> getVarBool s2 minimalRed = NOT_PRESSED \<Longrightarrow> getVarBool s3 minimalRed = NOT_PRESSED" apply(cases "s3 = s s0 requestButton_value") apply(cases "s2 = s s0 requestButton_value") apply blast apply(rule cut_rl[of "substate s2 s0"]) apply(rule cut_rl[of "getVarBool s0 trafficLight = RED"]) apply (metis getVarBool.simps(2) getVarBool.simps(4) getVarBool.simps(6) getVarBool.simps(7) numeral_eq_iff one_eq_numeral_iff semiring_norm(85) semiring_norm(89)) apply(drule conjE) prefer 2 apply assumption apply(drule conjE) prefer 2 apply assumption apply(drule conjE) prefer 2 apply assumption apply(drule allE[of _ s1]) prefer 2 apply assumption apply(drule allE[of _ s2]) prefer 2 apply assumption apply(drule allE[of _ s0]) prefer 2 apply assumption apply(rule cut_rl[of "toEnvNum s2 s0 < T1"]) using substate_refl apply fast apply((rule VC5_R5_aux1);fast) apply (metis substate.simps(2) substate.simps(4) substate.simps(6) substate.simps(7) toEnvP.simps(4) toEnvP.simps(6) toEnvP.simps(7)) apply(rule cut_rl [of "substate s3 s0"]) apply blast by (metis substate.simps(2) substate.simps(4) substate.simps(6) substate.simps(7) toEnvP.simps(4) toEnvP.simps(6) toEnvP.simps(7)) theorem proof_5_5: "VC5 R5 s0 requestButton_value" apply(simp only: VC5_def R5_def) apply(rule impI) apply(rule conjI) apply simp apply((rule allI);(rule allI);(rule allI)) apply(rule impI) by ((rule VC5_R5);assumption)
------------------------------------------------------------------------ -- Strings ------------------------------------------------------------------------ {-# OPTIONS --without-K #-} module String where open import Prelude ------------------------------------------------------------------------ -- Helper code used below private -- A variant of Maybe that matches the Haskell Maybe type. data HMaybe (A : Type) : Type where Nothing : HMaybe A Just : A β†’ HMaybe A {-# COMPILE GHC HMaybe = data Maybe (Nothing | Just) #-} -- A conversion function. hmaybe-to-maybe : βˆ€ {A} β†’ HMaybe A β†’ Maybe A hmaybe-to-maybe Nothing = nothing hmaybe-to-maybe (Just x) = just x ------------------------------------------------------------------------ -- Operations on strings -- Implemented using the FFI. These operations do not compute at -- compile-time, and are only supported by the GHC backend. {-# FOREIGN GHC import qualified Data.Text #-} mutual -- Tries to parse the given string as a natural number. Accepts -- whatever the Haskell Read instance for Integer accepts, except -- for negative numbers. parseβ„• : String β†’ Maybe β„• parseβ„• = hmaybe-to-maybe ∘ parseβ„•β€² private postulate parseβ„•β€² : String β†’ HMaybe β„• {-# COMPILE GHC parseβ„•β€² = \s -> case reads (Data.Text.unpack s) of { [(x, "")] | x >= 0 -> Just (x :: Integer) ; _ -> Nothing } #-} -- Turns natural numbers into strings. postulate prettyβ„• : β„• β†’ String {-# COMPILE GHC prettyβ„• = \n -> Data.Text.pack (show (n :: Integer)) #-}
lemma (in linorder_topology) tendsto_min[tendsto_intros]: assumes X: "(X \<longlongrightarrow> x) net" and Y: "(Y \<longlongrightarrow> y) net" shows "((\<lambda>x. min (X x) (Y x)) \<longlongrightarrow> min x y) net"
%% Copyright (C) 2014, 2016 Colin B. Macdonald %% %% This file is part of OctSymPy. %% %% OctSymPy is free software; you can redistribute it and/or modify %% it under the terms of the GNU General Public License as published %% by the Free Software Foundation; either version 3 of the License, %% or (at your option) any later version. %% %% This software is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied warranty %% of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See %% the GNU General Public License for more details. %% %% You should have received a copy of the GNU General Public %% License along with this software; see the file COPYING. %% If not, see <http://www.gnu.org/licenses/>. %% -*- texinfo -*- %% @defmethod @@symfun private_disp_name (@var{f}, @var{name}) %% A string appropriate for representing the name of this symfun. %% %% Private method: this is not the method you are looking for. %% %% @end defmethod function s = private_disp_name(f, input_name) if (isempty(input_name)) s = input_name; return end vars = f.vars; if length(vars) == 0 varstr = ''; else v = vars{1}; varstr = v.flat; end for i = 2:length(vars); v = vars{i}; varstr = [varstr ', ' v.flat]; end s = [input_name, '(', varstr, ')']; end %!test %! syms f(x) %! s = private_disp_name(f, 'f'); %! assert (strcmp (s, 'f(x)')) %!test %! syms x y %! g(y, x) = x + y; %! s = private_disp_name(g, 'g'); %! assert (strcmp (s, 'g(y, x)')) %!test %! syms f(x) %! assert (isempty (private_disp_name(f, '')))
/* 2019.03.28 by Aurora. Contact:[email protected] Read in parameters from file. Return code: 0: No errors. */ #include <stdio.h> #include <stdlib.h> #include "struct.h" #include "template_func.h" #include <boost/property_tree/ptree.hpp> #include <boost/property_tree/json_parser.hpp> /*****************MACRO FOR DEBUG*****************/ #define DEBUG_PARAM #ifdef DEBUG_PARAM #define printf_d printf #else #define printf_d // #endif /***************MACRO FOR DEBUG END***************/ /*Read the array values in a json file and returns a std::vector<T>*/ int read_parameters(frame_info_struct * frame_info, parameters_info_struct * parameters_info, char * filename) { FILE * fp_param = NULL; int i, j, k; int N_Atoms_max; int NUM_FILTER_LAYER; int NUM_FITTING_LAYER; FILE * tmp; boost::property_tree::ptree PARAMS; boost::property_tree::ptree PARAMS_ITEMS; tmp = fopen(filename, "r"); if (tmp == NULL) { printf("Please provide %s!\n", filename); return 21; } fclose(tmp); boost::property_tree::read_json<boost::property_tree::ptree>(filename, PARAMS); parameters_info->cutoff_1 = PARAMS.get<double>("cutoff_1"); parameters_info->cutoff_2 = PARAMS.get<double>("cutoff_2"); parameters_info->cutoff_3 = PARAMS.get<double>("cutoff_3"); parameters_info->cutoff_max = PARAMS.get<double>("cutoff_max"); if (PARAMS.count("N_types_all_frame") != 0) { parameters_info->N_types_all_frame = PARAMS.get<int>("N_types_all_frame"); parameters_info->type_index_all_frame = (int *)calloc(parameters_info->N_types_all_frame, sizeof(int)); std::vector<int> TYPE_INDEX_ALL_FRAME = as_vector<int>(PARAMS, "type_index_all_frame"); for (i = 0; i <= parameters_info->N_types_all_frame - 1; i++) { parameters_info->type_index_all_frame[i] = TYPE_INDEX_ALL_FRAME[i]; } } // if (PARAMS.count("N_Atoms_max") != 0) // { // parameters_info->N_Atoms_max = PARAMS.get<int>("N_Atoms_max"); // } if (frame_info != NULL) { N_Atoms_max = 0; for (i = 0; i <= parameters_info->Nframes_tot - 1; i++) { N_Atoms_max = (N_Atoms_max <= frame_info[i].N_Atoms ? frame_info[i].N_Atoms : N_Atoms_max); printf_d("N_Atoms: %d\n", frame_info[i].N_Atoms); } parameters_info->N_Atoms_max = N_Atoms_max; } else { parameters_info->N_Atoms_max = PARAMS.get<int>("N_Atoms_max"); } if (PARAMS.count("SEL_A_max") != 0) { parameters_info->SEL_A_max = PARAMS.get<int>("SEL_A_max"); } std::vector<int> SEL_A_ELE = as_vector<int>(PARAMS, "SEL_A_ele"); parameters_info->SEL_A_ele = (int *)calloc(SEL_A_ELE.size(), sizeof(int)); for (i = 0; i <= SEL_A_ELE.size() - 1; i++) { parameters_info->SEL_A_ele[i] = SEL_A_ELE[i]; } parameters_info->N_types_all_frame = SEL_A_ELE.size();//For temp use. Just to record the size of SEL_A_ele array. It should be exactly equal to the number of types of elements in the training set. If this number is different from the count_types function, then an error will occur. for (i = 0; i <= SEL_A_ELE.size() - 1; i++) { parameters_info->SEL_A_max += SEL_A_ELE[i]; } if ((PARAMS.count("Nframes_tot") != 0) && (parameters_info->Nframes_tot == 0)) { parameters_info->Nframes_tot = PARAMS.get<int>("Nframes_tot"); } parameters_info->sym_coord_type = PARAMS.get<int>("sym_coord_type"); if ((parameters_info->sym_coord_type != 1) && (parameters_info->sym_coord_type != 2)) { printf("sym_coord_type %d not supported!\n", parameters_info->sym_coord_type); return 22; } if (parameters_info->sym_coord_type == 1) { parameters_info->N_sym_coord = 4 * parameters_info->SEL_A_max; } if (PARAMS.count("N_sym_coord") != 0) { parameters_info->N_sym_coord = PARAMS.get<int>("N_sym_coord"); } // if (frame_info != NULL) // { // N_Atoms_max = 0; // for (i = 0; i <= parameters_info->Nframes_tot - 1; i++) // { // N_Atoms_max = (N_Atoms_max <= frame_info[i].N_Atoms ? frame_info[i].N_Atoms : N_Atoms_max); // printf_d("N_Atoms: %d\n", frame_info[i].N_Atoms); // } // parameters_info->N_Atoms_max = N_Atoms_max; // } // else // { // parameters_info->N_Atoms_max = PARAMS.get<int>("N_Atoms_max"); // } parameters_info->batch_size = PARAMS.get<int>("batch_size"); parameters_info->stop_epoch = PARAMS.get<int>("stop_epoch"); parameters_info->num_filter_layer = PARAMS.get<int>("num_filter_layer"); std::vector<int> FILTER_NEURON = as_vector<int>(PARAMS, "filter_neuron"); if (FILTER_NEURON.size() != parameters_info->num_filter_layer) { printf("WARNING: num_filter_layer %3d is not equal to the number of layers defined in filter_neuron %3d !\n", parameters_info->num_filter_layer, FILTER_NEURON.size()); parameters_info->num_filter_layer = FILTER_NEURON.size(); } parameters_info->filter_neuron = (int *)calloc(parameters_info->num_filter_layer, sizeof(int)); for (i = 0; i <= parameters_info->num_filter_layer - 1; i++) { parameters_info->filter_neuron[i] = FILTER_NEURON[i]; } parameters_info->axis_neuron = PARAMS.get<int>("axis_neuron"); parameters_info->num_fitting_layer = PARAMS.get<int>("num_fitting_layer"); std::vector<int> FITTING_NEURON = as_vector<int>(PARAMS, "fitting_neuron"); if (FITTING_NEURON.size() != parameters_info->num_fitting_layer) { printf("WARNING: num_fitting_layer %3d is not equal to the number of layers defined in fitting_neuron %3d !\n", parameters_info->num_fitting_layer, FITTING_NEURON.size()); parameters_info->num_fitting_layer = FITTING_NEURON.size(); } parameters_info->fitting_neuron = (int *)calloc(parameters_info->num_fitting_layer, sizeof(int)); for (i = 0; i <= parameters_info->num_fitting_layer - 1; i++) { parameters_info->fitting_neuron[i] = FITTING_NEURON[i]; } parameters_info->start_lr = PARAMS.get<double>("start_lr"); parameters_info->decay_steps = -1; parameters_info->decay_epoch = PARAMS.get<int>("decay_epoch"); parameters_info->decay_rate = PARAMS.get<double>("decay_rate"); parameters_info->start_pref_e = PARAMS.get<double>("start_pref_e"); parameters_info->limit_pref_e = PARAMS.get<double>("limit_pref_e"); parameters_info->start_pref_f = PARAMS.get<double>("start_pref_f"); parameters_info->limit_pref_f = PARAMS.get<double>("limit_pref_f"); parameters_info->check_step = PARAMS.get<int>("check_step"); parameters_info->check_batch = -1; parameters_info->check_epoch = -1; parameters_info->output_step = -1; parameters_info->output_batch = -1; parameters_info->output_epoch = PARAMS.get<int>("output_epoch"); parameters_info->save_step = -1; parameters_info->save_batch = -1; parameters_info->save_epoch = PARAMS.get<int>("save_epoch"); // fp_param = fopen("./INPUT.raw","r"); // if (fp_param != NULL) // { // int sym_coord_type; // fscanf(fp_param, "%d", &sym_coord_type); // printf_d("sym_coord_type read from file: %d\n", sym_coord_type); // parameters_info->sym_coord_type = (((sym_coord_type == 1) || (sym_coord_type == 2)) ? sym_coord_type : parameters_info->sym_coord_type); // fclose(fp_param); // } // else // { // parameters_info->sym_coord_type = 1; // } return 0; }
record R₁ : Set₁ where field A : Set open R₁ ⦃ … ⦄ record Rβ‚‚ : Set₁ where field ⦃ r₁ ⦄ : R₁ B : Set B = A
-- 2010-10-14 {-# OPTIONS --universe-polymorphism #-} module ProjectionsPreserveGuardednessTrivialExample where -- Coinduction is only available with universe polymorphism postulate Level : Set zero : Level suc : (i : Level) β†’ Level _βŠ”_ : Level β†’ Level β†’ Level {-# BUILTIN LEVEL Level #-} {-# BUILTIN LEVELZERO zero #-} {-# BUILTIN LEVELSUC suc #-} {-# BUILTIN LEVELMAX _βŠ”_ #-} infixl 6 _βŠ”_ -- Coinduction infix 1000 β™―_ postulate ∞ : βˆ€ {a} (A : Set a) β†’ Set a β™―_ : βˆ€ {a} {A : Set a} β†’ A β†’ ∞ A β™­ : βˆ€ {a} {A : Set a} β†’ ∞ A β†’ A {-# BUILTIN INFINITY ∞ #-} {-# BUILTIN SHARP β™―_ #-} {-# BUILTIN FLAT β™­ #-} -- Products infixr 4 _,_ infixr 2 _Γ—_ record Ξ£ {a b} (A : Set a) (B : A β†’ Set b) : Set (a βŠ” b) where constructor _,_ field proj₁ : A projβ‚‚ : B proj₁ open Ξ£ public syntax Ξ£ A (Ξ» x β†’ B) = Ξ£[ x ∢ A ] B _Γ—_ : βˆ€ {a b} (A : Set a) (B : Set b) β†’ Set (a βŠ” b) A Γ— B = Ξ£[ x ∢ A ] B -- Streams infixr 5 _∷_ data Stream (A : Set) : Set where _∷_ : (x : A) (xs : ∞ (Stream A)) β†’ Stream A mutual repeat : {A : Set}(a : A) β†’ Stream A repeat a = a ∷ projβ‚‚ (repeat' a) repeat' : {A : Set}(a : A) β†’ A Γ— ∞ (Stream A) repeat' a = a , β™― repeat a
/- Copyright (c) 2018 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison Transport through constant families. -/ universes u₁ uβ‚‚ @[simp] lemma plift.rec.constant {Ξ± : Sort u₁} {Ξ² : Sort uβ‚‚} (b : Ξ²) : @plift.rec Ξ± (Ξ» _, Ξ²) (Ξ» _, b) = Ξ» _, b := funext (Ξ» x, plift.cases_on x (Ξ» a, eq.refl (plift.rec (Ξ» a', b) {down := a}))) @[simp] lemma ulift.rec.constant {Ξ± : Type u₁} {Ξ² : Sort uβ‚‚} (b : Ξ²) : @ulift.rec Ξ± (Ξ» _, Ξ²) (Ξ» _, b) = Ξ» _, b := funext (Ξ» x, ulift.cases_on x (Ξ» a, eq.refl (ulift.rec (Ξ» a', b) {down := a})))
import analysis.analytic.basic import hp.tactic.hp_interactive universe u namespace examples lemma x_sub_x_union_y {Ξ± : Type} {A B : set Ξ±} : A βŠ† A βˆͺ B := Ξ» a h, or.inl h lemma y_sub_x_union_y {Ξ± : Type} {A B : set Ξ±} : B βŠ† A βˆͺ B := Ξ» a h, or.inr h class met_space (X : Type) extends has_dist X := (dist_self : βˆ€ x, dist x x = 0) (dist_comm : βˆ€ x y, dist x y = dist y x) (dist_triangle : βˆ€ x y z, dist x z ≀ dist x y + dist y z) attribute [classnoun "metric space"] met_space open met_space variables {X Y: Type} [met_space X] [met_space Y] {A B : set X} def open_ball (Ξ΅ : ℝ) (x : X) := {y | dist x y < Ξ΅} def is_open (A : set X) : Prop := βˆ€ (y : X), y ∈ A β†’ βˆƒ (Ξ΅ : ℝ), (Ξ΅ > 0) ∧ βˆ€ (x : X), dist x y < Ξ΅ β†’ x ∈ A @[relational_noun_predicate "uniform limit" "uniform limits" "of"] def is_uniform_limit (f : β„• β†’ X β†’ Y) (g : X β†’ Y) := βˆ€ (Ξ΅ : ℝ), Ξ΅ > 0 β†’ βˆƒ (N : β„•), βˆ€ (x : X), βˆ€ (n : β„•), (n β‰₯ N) β†’ dist (f n x) (g x) < Ξ΅ @[adjective "continuous"] def continuous (f : X β†’ Y) := βˆ€ (x : X), βˆ€ (Ξ΅ : ℝ), (Ξ΅ > 0) β†’ βˆƒ (Ξ΄ : ℝ), (Ξ΄ > 0) ∧ βˆ€ (y : X), dist x y < Ξ΄ β†’ dist (f x) (f y) < Ξ΅ @[relational_noun "sequence" "sequences" "of"] def sequence (X : Type) := β„• β†’ X lemma dist_helper {Ξ΅ Ξ· ΞΈ} {x y z : X} (h₁ : dist x y < Ξ·) (hβ‚‚ : dist y z < ΞΈ) (h₃ : Ξ· + ΞΈ ≀ Ξ΅) : dist x z < Ξ΅ := calc _ ≀ dist x y + dist y z : dist_triangle _ _ _ ... < Ξ· + ΞΈ : add_lt_add h₁ hβ‚‚ ... ≀ Ξ΅ : h₃ example (f : sequence (X β†’ Y)) (g : X β†’ Y) (h₁ : is_uniform_limit f g) (hβ‚‚ : βˆ€ n, continuous (f n)) : continuous g := begin assume (x : X) (Ξ΅ : ℝ) (Ξ΅_pos : Ξ΅ > 0), have hβ‚„ : Ξ΅ / 3 > 0, show Ξ΅ / 3 > 0, apply div_pos Ξ΅_pos, show 0 < (3 : ℝ), norm_num, obtain ⟨N, hβ‚…βŸ© : βˆƒ N, βˆ€ (x : X) (n : β„•), n β‰₯ N β†’ dist (f n x) (g x) < Ξ΅ / 3, apply h₁ (Ξ΅ / 3) hβ‚„, obtain ⟨δ, Ξ΄_pos, hβ‚†βŸ© : βˆƒ Ξ΄, Ξ΄ > 0 ∧ βˆ€ y, dist x y < Ξ΄ β†’ dist (f N x) (f N y) < Ξ΅ / 3, apply hβ‚‚ N x (Ξ΅ / 3) hβ‚„, existsi Ξ΄, existsi Ξ΄_pos, assume (y : X) (h₃ : dist x y < Ξ΄), show dist (g x) (g y) < Ξ΅, apply dist_helper, calc dist (g x) (f N x) = dist (f N x) (g x) : by rw examples.met_space.dist_comm ... < Ξ΅ / 3 : by apply hβ‚… x N (le_refl N), show dist (f N x) (g y) < (Ξ΅ / 3 + Ξ΅ / 3), apply dist_helper, show dist (f N x) (f N y) < Ξ΅ / 3, apply h₆ y h₃, show dist (f N y) (g y) < Ξ΅ / 3, apply hβ‚… y N (le_refl N), show Ξ΅ / 3 + Ξ΅ / 3 ≀ Ξ΅ / 3 + Ξ΅ / 3, apply le_refl, show Ξ΅ / 3 + (Ξ΅ / 3 + Ξ΅ / 3) ≀ Ξ΅, apply le_of_eq, show Ξ΅ / 3 + (Ξ΅ / 3 + Ξ΅ / 3) = Ξ΅, by ring end example {A B : set X} : is_open A β†’ is_open B β†’ is_open (A ∩ B) | oa ob y ⟨ha, hb⟩ := let ⟨Ρa, h2a, h3a⟩ := oa y ha in let ⟨Ρb, h2b, h3b⟩ := ob y hb in ⟨ Ξ΅a βŠ“ Ξ΅b , lt_min h2a h2b , Ξ» x dh, ⟨ h3a _ $ lt_of_lt_of_le dh $ min_le_left _ _ , h3b _ $ lt_of_lt_of_le dh $ min_le_right _ _ ⟩ ⟩ end examples
lemma nonneg_bounded: "\<exists>K\<ge>0. \<forall>a b. norm (a ** b) \<le> norm a * norm b * K"
State Before: θ : Angle ⊒ sign (-θ) = -sign θ State After: no goals Tactic: simp_rw [sign, sin_neg, Left.sign_neg]
% This is material illustrating the methods from the book % Financial Modelling - Theory, Implementation and Practice with Matlab % source % Wiley Finance Series % ISBN 978-0-470-74489-5 % % Date: 02.05.2012 % % Authors: Joerg Kienitz % Daniel Wetterau % % Please send comments, suggestions, bugs, code etc. to % [email protected] % % (C) Joerg Kienitz, Daniel Wetterau % % Since this piece of code is distributed via the mathworks file-exchange % it is covered by the BSD license % % This code is being provided solely for information and general % illustrative purposes. The authors will not be responsible for the % consequences of reliance upon using the code or for numbers produced % from using the code. function y = RegCoeff_M(S, M, Ns, g, df, B, Nb, Nr) % Calculates the regression coefficiients v = g(:,end); % start for backward induction f = zeros(Nb,Nr-1); % backward induction and regression from t_{Nr-1} up to t_1 for i = Nr-1:-1:1 index = find(g(:,i+1) > 0); % all ITM paths s = S(index,i+1); % values of S at given time points m = M(index,i+1); % values of M at given time points v = v * df(i+1); % option value at t_i Acell = B(s,m); % evaluate basis function in cell array B A = cell2mat(Acell{:,:}); % convert to matrix f(:,i) = (A'*A)\(A'*v(index)); % determine coefficients c = A*f(:,i); % continuation value exercise = g(index,i+1) >= c; % early exercise v(index(exercise)) = g(index(exercise),i+1); end y = f; end
/- Copyright (c) 2022 Felix Weilacher. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Felix Weilacher -/ import topology.separation import topology.bases /-! # Perfect Sets > THIS FILE IS SYNCHRONIZED WITH MATHLIB4. > Any changes to this file require a corresponding PR to mathlib4. In this file we define perfect subsets of a topological space, and prove some basic properties, including a version of the Cantor-Bendixson Theorem. ## Main Definitions * `perfect C`: A set `C` is perfect, meaning it is closed and every point of it is an accumulation point of itself. ## Main Statements * `perfect.splitting`: A perfect nonempty set contains two disjoint perfect nonempty subsets. The main inductive step in the construction of an embedding from the Cantor space to a perfect nonempty complete metric space. * `exists_countable_union_perfect_of_is_closed`: One version of the **Cantor-Bendixson Theorem**: A closed set in a second countable space can be written as the union of a countable set and a perfect set. ## Implementation Notes We do not require perfect sets to be nonempty. We define a nonstandard predicate, `preperfect`, which drops the closed-ness requirement from the definition of perfect. In T1 spaces, this is equivalent to having a perfect closure, see `preperfect_iff_perfect_closure`. ## References * [kechris1995] (Chapter 6) ## Tags accumulation point, perfect set, Cantor-Bendixson. -/ open_locale topology filter open topological_space filter set variables {Ξ± : Type*} [topological_space Ξ±] {C : set Ξ±} /-- If `x` is an accumulation point of a set `C` and `U` is a neighborhood of `x`, then `x` is an accumulation point of `U ∩ C`. -/ theorem acc_pt.nhds_inter {x : Ξ±} {U : set Ξ±} (h_acc : acc_pt x (π“Ÿ C)) (hU : U ∈ 𝓝 x) : acc_pt x (π“Ÿ (U ∩ C)) := begin have : 𝓝[β‰ ] x ≀ π“Ÿ U, { rw le_principal_iff, exact mem_nhds_within_of_mem_nhds hU, }, rw [acc_pt, ← inf_principal, ← inf_assoc, inf_of_le_left this], exact h_acc, end /-- A set `C` is preperfect if all of its points are accumulation points of itself. If `C` is nonempty and `Ξ±` is a T1 space, this is equivalent to the closure of `C` being perfect. See `preperfect_iff_perfect_closure`.-/ def preperfect (C : set Ξ±) : Prop := βˆ€ x ∈ C, acc_pt x (π“Ÿ C) /-- A set `C` is called perfect if it is closed and all of its points are accumulation points of itself. Note that we do not require `C` to be nonempty.-/ structure perfect (C : set Ξ±) : Prop := (closed : is_closed C) (acc : preperfect C) lemma preperfect_iff_nhds : preperfect C ↔ βˆ€ x ∈ C, βˆ€ U ∈ 𝓝 x, βˆƒ y ∈ U ∩ C, y β‰  x := by simp only [preperfect, acc_pt_iff_nhds] /-- The intersection of a preperfect set and an open set is preperfect-/ theorem preperfect.open_inter {U : set Ξ±} (hC : preperfect C) (hU : is_open U) : preperfect (U ∩ C) := begin rintros x ⟨xU, xC⟩, apply (hC _ xC).nhds_inter, exact hU.mem_nhds xU, end /-- The closure of a preperfect set is perfect. For a converse, see `preperfect_iff_perfect_closure`-/ theorem preperfect.perfect_closure (hC : preperfect C) : perfect (closure C) := begin split, { exact is_closed_closure }, intros x hx, by_cases h : x ∈ C; apply acc_pt.mono _ (principal_mono.mpr subset_closure), { exact hC _ h }, have : {x}ᢜ ∩ C = C := by simp [h], rw [acc_pt, nhds_within, inf_assoc, inf_principal, this], rw [closure_eq_cluster_pts] at hx, exact hx, end /-- In a T1 space, being preperfect is equivalent to having perfect closure.-/ theorem preperfect_iff_perfect_closure [t1_space Ξ±] : preperfect C ↔ perfect (closure C) := begin split; intro h, { exact h.perfect_closure }, intros x xC, have H : acc_pt x (π“Ÿ (closure C)) := h.acc _ (subset_closure xC), rw acc_pt_iff_frequently at *, have : βˆ€ y , y β‰  x ∧ y ∈ closure C β†’ βˆƒαΆ  z in 𝓝 y, z β‰  x ∧ z ∈ C, { rintros y ⟨hyx, yC⟩, simp only [← mem_compl_singleton_iff, @and_comm _ (_ ∈ C) , ← frequently_nhds_within_iff, hyx.nhds_within_compl_singleton, ← mem_closure_iff_frequently], exact yC, }, rw ← frequently_frequently_nhds, exact H.mono this, end theorem perfect.closure_nhds_inter {U : set Ξ±} (hC : perfect C) (x : Ξ±) (xC : x ∈ C) (xU : x ∈ U) (Uop : is_open U) : perfect (closure (U ∩ C)) ∧ (closure (U ∩ C)).nonempty := begin split, { apply preperfect.perfect_closure, exact (hC.acc).open_inter Uop, }, apply nonempty.closure, exact ⟨x, ⟨xU, xC⟩⟩, end /-- Given a perfect nonempty set in a T2.5 space, we can find two disjoint perfect subsets This is the main inductive step in the proof of the Cantor-Bendixson Theorem-/ lemma perfect.splitting [t2_5_space Ξ±] (hC : perfect C) (hnonempty : C.nonempty) : βˆƒ Cβ‚€ C₁ : set Ξ±, (perfect Cβ‚€ ∧ Cβ‚€.nonempty ∧ Cβ‚€ βŠ† C) ∧ (perfect C₁ ∧ C₁.nonempty ∧ C₁ βŠ† C) ∧ disjoint Cβ‚€ C₁ := begin cases hnonempty with y yC, obtain ⟨x, xC, hxy⟩ : βˆƒ x ∈ C, x β‰  y, { have := hC.acc _ yC, rw acc_pt_iff_nhds at this, rcases this univ (univ_mem) with ⟨x, xC, hxy⟩, exact ⟨x, xC.2, hxy⟩, }, obtain ⟨U, xU, Uop, V, yV, Vop, hUV⟩ := exists_open_nhds_disjoint_closure hxy, use [closure (U ∩ C), closure (V ∩ C)], split; rw ← and_assoc, { refine ⟨hC.closure_nhds_inter x xC xU Uop, _⟩, rw hC.closed.closure_subset_iff, exact inter_subset_right _ _, }, split, { refine ⟨hC.closure_nhds_inter y yC yV Vop, _⟩, rw hC.closed.closure_subset_iff, exact inter_subset_right _ _, }, apply disjoint.mono _ _ hUV; apply closure_mono; exact inter_subset_left _ _, end section kernel /-- The **Cantor-Bendixson Theorem**: Any closed subset of a second countable space can be written as the union of a countable set and a perfect set.-/ theorem exists_countable_union_perfect_of_is_closed [second_countable_topology Ξ±] (hclosed : is_closed C) : βˆƒ V D : set Ξ±, (V.countable) ∧ (perfect D) ∧ (C = V βˆͺ D) := begin obtain ⟨b, bct, bnontrivial, bbasis⟩ := topological_space.exists_countable_basis Ξ±, let v := {U ∈ b | (U ∩ C).countable}, let V := ⋃ U ∈ v, U, let D := C \ V, have Vct : (V ∩ C).countable, { simp only [Union_inter, mem_sep_iff], apply countable.bUnion, { exact countable.mono (inter_subset_left _ _) bct, }, { exact inter_subset_right _ _, }, }, refine ⟨V ∩ C, D, Vct, ⟨_, _⟩, _⟩, { refine hclosed.sdiff (is_open_bUnion (Ξ» U, _)), exact Ξ» ⟨Ub, _⟩, is_topological_basis.is_open bbasis Ub, }, { rw preperfect_iff_nhds, intros x xD E xE, have : Β¬ (E ∩ D).countable, { intro h, obtain ⟨U, hUb, xU, hU⟩ : βˆƒ U ∈ b, x ∈ U ∧ U βŠ† E, { exact (is_topological_basis.mem_nhds_iff bbasis).mp xE, }, have hU_cnt : (U ∩ C).countable, { apply @countable.mono _ _ ((E ∩ D) βˆͺ (V ∩ C)), { rintros y ⟨yU, yC⟩, by_cases y ∈ V, { exact mem_union_right _ (mem_inter h yC), }, { exact mem_union_left _ (mem_inter (hU yU) ⟨yC, h⟩), }, }, exact countable.union h Vct, }, have : U ∈ v := ⟨hUb, hU_cnt⟩, apply xD.2, exact mem_bUnion this xU, }, by_contradiction h, push_neg at h, exact absurd (countable.mono h (set.countable_singleton _)) this, }, { rw [inter_comm, inter_union_diff], }, end /-- Any uncountable closed set in a second countable space contains a nonempty perfect subset.-/ theorem exists_perfect_nonempty_of_is_closed_of_not_countable [second_countable_topology Ξ±] (hclosed : is_closed C) (hunc : Β¬ C.countable) : βˆƒ D : set Ξ±, perfect D ∧ D.nonempty ∧ D βŠ† C := begin rcases exists_countable_union_perfect_of_is_closed hclosed with ⟨V, D, Vct, Dperf, VD⟩, refine ⟨D, ⟨Dperf, _⟩⟩, split, { rw nonempty_iff_ne_empty, by_contradiction, rw [h, union_empty] at VD, rw VD at hunc, contradiction, }, rw VD, exact subset_union_right _ _, end end kernel
/- Copyright (c) 2020 Aaron Anderson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Aaron Anderson -/ import order.complete_boolean_algebra import order.cover import order.modular_lattice import data.fintype.basic /-! # Atoms, Coatoms, and Simple Lattices This module defines atoms, which are minimal non-`βŠ₯` elements in bounded lattices, simple lattices, which are lattices with only two elements, and related ideas. ## Main definitions ### Atoms and Coatoms * `is_atom a` indicates that the only element below `a` is `βŠ₯`. * `is_coatom a` indicates that the only element above `a` is `⊀`. ### Atomic and Atomistic Lattices * `is_atomic` indicates that every element other than `βŠ₯` is above an atom. * `is_coatomic` indicates that every element other than `⊀` is below a coatom. * `is_atomistic` indicates that every element is the `Sup` of a set of atoms. * `is_coatomistic` indicates that every element is the `Inf` of a set of coatoms. ### Simple Lattices * `is_simple_order` indicates that an order has only two unique elements, `βŠ₯` and `⊀`. * `is_simple_order.bounded_order` * `is_simple_order.distrib_lattice` * Given an instance of `is_simple_order`, we provide the following definitions. These are not made global instances as they contain data : * `is_simple_order.boolean_algebra` * `is_simple_order.complete_lattice` * `is_simple_order.complete_boolean_algebra` ## Main results * `is_atom_dual_iff_is_coatom` and `is_coatom_dual_iff_is_atom` express the (definitional) duality of `is_atom` and `is_coatom`. * `is_simple_order_iff_is_atom_top` and `is_simple_order_iff_is_coatom_bot` express the connection between atoms, coatoms, and simple lattices * `is_compl.is_atom_iff_is_coatom` and `is_compl.is_coatom_if_is_atom`: In a modular bounded lattice, a complement of an atom is a coatom and vice versa. * `is_atomic_iff_is_coatomic`: A modular complemented lattice is atomic iff it is coatomic. * `fintype.to_is_atomic`, `fintype.to_is_coatomic`: Finite partial orders with bottom resp. top are atomic resp. coatomic. -/ variable {Ξ± : Type*} section atoms section is_atom /-- An atom of an `order_bot` is an element with no other element between it and `βŠ₯`, which is not `βŠ₯`. -/ def is_atom [preorder Ξ±] [order_bot Ξ±] (a : Ξ±) : Prop := a β‰  βŠ₯ ∧ (βˆ€ b, b < a β†’ b = βŠ₯) variables [partial_order Ξ±] [order_bot Ξ±] {a b x : Ξ±} lemma eq_bot_or_eq_of_le_atom (ha : is_atom a) (hab : b ≀ a) : b = βŠ₯ ∨ b = a := hab.lt_or_eq.imp_left (ha.2 b) lemma is_atom.Iic (ha : is_atom a) (hax : a ≀ x) : is_atom (⟨a, hax⟩ : set.Iic x) := ⟨λ con, ha.1 (subtype.mk_eq_mk.1 con), Ξ» ⟨b, hb⟩ hba, subtype.mk_eq_mk.2 (ha.2 b hba)⟩ lemma is_atom.of_is_atom_coe_Iic {a : set.Iic x} (ha : is_atom a) : is_atom (a : Ξ±) := ⟨λ con, ha.1 (subtype.ext con), Ξ» b hba, subtype.mk_eq_mk.1 (ha.2 ⟨b, hba.le.trans a.prop⟩ hba)⟩ @[simp] lemma bot_covby_iff : βŠ₯ β‹– a ↔ is_atom a := ⟨λ h, ⟨h.lt.ne', Ξ» b hba, not_not.1 $ Ξ» hb, h.2 (ne.bot_lt hb) hba⟩, Ξ» h, ⟨h.1.bot_lt, Ξ» b hb hba, hb.ne' $ h.2 _ hba⟩⟩ alias bot_covby_iff ↔ covby.is_atom is_atom.bot_covby end is_atom section is_coatom /-- A coatom of an `order_top` is an element with no other element between it and `⊀`, which is not `⊀`. -/ def is_coatom [preorder Ξ±] [order_top Ξ±] (a : Ξ±) : Prop := a β‰  ⊀ ∧ (βˆ€ b, a < b β†’ b = ⊀) variables [partial_order Ξ±] [order_top Ξ±] {a b x : Ξ±} lemma eq_top_or_eq_of_coatom_le (ha : is_coatom a) (hab : a ≀ b) : b = ⊀ ∨ b = a := hab.lt_or_eq.imp (ha.2 b) eq_comm.2 lemma is_coatom.Ici (ha : is_coatom a) (hax : x ≀ a) : is_coatom (⟨a, hax⟩ : set.Ici x) := ⟨λ con, ha.1 (subtype.mk_eq_mk.1 con), Ξ» ⟨b, hb⟩ hba, subtype.mk_eq_mk.2 (ha.2 b hba)⟩ lemma is_coatom.of_is_coatom_coe_Ici {a : set.Ici x} (ha : is_coatom a) : is_coatom (a : Ξ±) := ⟨λ con, ha.1 (subtype.ext con), Ξ» b hba, subtype.mk_eq_mk.1 (ha.2 ⟨b, le_trans a.prop hba.le⟩ hba)⟩ @[simp] lemma covby_top_iff : a β‹– ⊀ ↔ is_coatom a := ⟨λ h, ⟨h.ne, Ξ» b hab, not_not.1 $ Ξ» hb, h.2 hab $ ne.lt_top hb⟩, Ξ» h, ⟨h.1.lt_top, Ξ» b hab hb, hb.ne $ h.2 _ hab⟩⟩ alias covby_top_iff ↔ covby.is_coatom is_coatom.covby_top end is_coatom section pairwise lemma is_atom.inf_eq_bot_of_ne [semilattice_inf Ξ±] [order_bot Ξ±] {a b : Ξ±} (ha : is_atom a) (hb : is_atom b) (hab : a β‰  b) : a βŠ“ b = βŠ₯ := or.elim (eq_bot_or_eq_of_le_atom ha inf_le_left) id (Ξ» h1, or.elim (eq_bot_or_eq_of_le_atom hb inf_le_right) id (Ξ» h2, false.rec _ (hab (le_antisymm (inf_eq_left.mp h1) (inf_eq_right.mp h2))))) lemma is_atom.disjoint_of_ne [semilattice_inf Ξ±] [order_bot Ξ±] {a b : Ξ±} (ha : is_atom a) (hb : is_atom b) (hab : a β‰  b) : disjoint a b := disjoint_iff.mpr (is_atom.inf_eq_bot_of_ne ha hb hab) lemma is_coatom.sup_eq_top_of_ne [semilattice_sup Ξ±] [order_top Ξ±] {a b : Ξ±} (ha : is_coatom a) (hb : is_coatom b) (hab : a β‰  b) : a βŠ” b = ⊀ := or.elim (eq_top_or_eq_of_coatom_le ha le_sup_left) id (Ξ» h1, or.elim (eq_top_or_eq_of_coatom_le hb le_sup_right) id (Ξ» h2, false.rec _ (hab (le_antisymm (sup_eq_right.mp h2) (sup_eq_left.mp h1))))) end pairwise variables [preorder Ξ±] {a : Ξ±} @[simp] lemma is_coatom_dual_iff_is_atom [order_bot Ξ±] : is_coatom (order_dual.to_dual a) ↔ is_atom a := iff.rfl @[simp] lemma is_atom_dual_iff_is_coatom [order_top Ξ±] : is_atom (order_dual.to_dual a) ↔ is_coatom a := iff.rfl end atoms section atomic variables [partial_order Ξ±] (Ξ±) /-- A lattice is atomic iff every element other than `βŠ₯` has an atom below it. -/ class is_atomic [order_bot Ξ±] : Prop := (eq_bot_or_exists_atom_le : βˆ€ (b : Ξ±), b = βŠ₯ ∨ βˆƒ (a : Ξ±), is_atom a ∧ a ≀ b) /-- A lattice is coatomic iff every element other than `⊀` has a coatom above it. -/ class is_coatomic [order_top Ξ±] : Prop := (eq_top_or_exists_le_coatom : βˆ€ (b : Ξ±), b = ⊀ ∨ βˆƒ (a : Ξ±), is_coatom a ∧ b ≀ a) export is_atomic (eq_bot_or_exists_atom_le) is_coatomic (eq_top_or_exists_le_coatom) variable {Ξ±} @[simp] theorem is_coatomic_dual_iff_is_atomic [order_bot Ξ±] : is_coatomic (order_dual Ξ±) ↔ is_atomic Ξ± := ⟨λ h, ⟨λ b, by apply h.eq_top_or_exists_le_coatom⟩, Ξ» h, ⟨λ b, by apply h.eq_bot_or_exists_atom_le⟩⟩ @[simp] theorem is_atomic_dual_iff_is_coatomic [order_top Ξ±] : is_atomic (order_dual Ξ±) ↔ is_coatomic Ξ± := ⟨λ h, ⟨λ b, by apply h.eq_bot_or_exists_atom_le⟩, Ξ» h, ⟨λ b, by apply h.eq_top_or_exists_le_coatom⟩⟩ namespace is_atomic variables [order_bot Ξ±] [is_atomic Ξ±] instance is_coatomic_dual : is_coatomic (order_dual Ξ±) := is_coatomic_dual_iff_is_atomic.2 β€Ήis_atomic Ξ±β€Ί instance {x : Ξ±} : is_atomic (set.Iic x) := ⟨λ ⟨y, hy⟩, (eq_bot_or_exists_atom_le y).imp subtype.mk_eq_mk.2 (Ξ» ⟨a, ha, hay⟩, ⟨⟨a, hay.trans hy⟩, ha.Iic (hay.trans hy), hay⟩)⟩ end is_atomic namespace is_coatomic variables [order_top Ξ±] [is_coatomic Ξ±] instance is_coatomic : is_atomic (order_dual Ξ±) := is_atomic_dual_iff_is_coatomic.2 β€Ήis_coatomic Ξ±β€Ί instance {x : Ξ±} : is_coatomic (set.Ici x) := ⟨λ ⟨y, hy⟩, (eq_top_or_exists_le_coatom y).imp subtype.mk_eq_mk.2 (Ξ» ⟨a, ha, hay⟩, ⟨⟨a, le_trans hy hay⟩, ha.Ici (le_trans hy hay), hay⟩)⟩ end is_coatomic theorem is_atomic_iff_forall_is_atomic_Iic [order_bot Ξ±] : is_atomic Ξ± ↔ βˆ€ (x : Ξ±), is_atomic (set.Iic x) := ⟨@is_atomic.set.Iic.is_atomic _ _ _, Ξ» h, ⟨λ x, ((@eq_bot_or_exists_atom_le _ _ _ (h x)) (⊀ : set.Iic x)).imp subtype.mk_eq_mk.1 (exists_imp_exists' coe (Ξ» ⟨a, ha⟩, and.imp_left (is_atom.of_is_atom_coe_Iic)))⟩⟩ theorem is_coatomic_iff_forall_is_coatomic_Ici [order_top Ξ±] : is_coatomic Ξ± ↔ βˆ€ (x : Ξ±), is_coatomic (set.Ici x) := is_atomic_dual_iff_is_coatomic.symm.trans $ is_atomic_iff_forall_is_atomic_Iic.trans $ forall_congr (Ξ» x, is_coatomic_dual_iff_is_atomic.symm.trans iff.rfl) end atomic section atomistic variables (Ξ±) [complete_lattice Ξ±] /-- A lattice is atomistic iff every element is a `Sup` of a set of atoms. -/ class is_atomistic : Prop := (eq_Sup_atoms : βˆ€ (b : Ξ±), βˆƒ (s : set Ξ±), b = Sup s ∧ βˆ€ a, a ∈ s β†’ is_atom a) /-- A lattice is coatomistic iff every element is an `Inf` of a set of coatoms. -/ class is_coatomistic : Prop := (eq_Inf_coatoms : βˆ€ (b : Ξ±), βˆƒ (s : set Ξ±), b = Inf s ∧ βˆ€ a, a ∈ s β†’ is_coatom a) export is_atomistic (eq_Sup_atoms) is_coatomistic (eq_Inf_coatoms) variable {Ξ±} @[simp] theorem is_coatomistic_dual_iff_is_atomistic : is_coatomistic (order_dual Ξ±) ↔ is_atomistic Ξ± := ⟨λ h, ⟨λ b, by apply h.eq_Inf_coatoms⟩, Ξ» h, ⟨λ b, by apply h.eq_Sup_atoms⟩⟩ @[simp] theorem is_atomistic_dual_iff_is_coatomistic : is_atomistic (order_dual Ξ±) ↔ is_coatomistic Ξ± := ⟨λ h, ⟨λ b, by apply h.eq_Sup_atoms⟩, Ξ» h, ⟨λ b, by apply h.eq_Inf_coatoms⟩⟩ namespace is_atomistic instance is_coatomistic_dual [h : is_atomistic Ξ±] : is_coatomistic (order_dual Ξ±) := is_coatomistic_dual_iff_is_atomistic.2 h variable [is_atomistic Ξ±] @[priority 100] instance : is_atomic Ξ± := ⟨λ b, by { rcases eq_Sup_atoms b with ⟨s, rfl, hs⟩, cases s.eq_empty_or_nonempty with h h, { simp [h] }, { exact or.intro_right _ ⟨h.some, hs _ h.some_spec, le_Sup h.some_spec⟩ } } ⟩ end is_atomistic section is_atomistic variables [is_atomistic Ξ±] @[simp] theorem Sup_atoms_le_eq (b : Ξ±) : Sup {a : Ξ± | is_atom a ∧ a ≀ b} = b := begin rcases eq_Sup_atoms b with ⟨s, rfl, hs⟩, exact le_antisymm (Sup_le (Ξ» _, and.right)) (Sup_le_Sup (Ξ» a ha, ⟨hs a ha, le_Sup ha⟩)), end @[simp] theorem Sup_atoms_eq_top : Sup {a : Ξ± | is_atom a} = ⊀ := begin refine eq.trans (congr rfl (set.ext (Ξ» x, _))) (Sup_atoms_le_eq ⊀), exact (and_iff_left le_top).symm, end theorem le_iff_atom_le_imp {a b : Ξ±} : a ≀ b ↔ βˆ€ c : Ξ±, is_atom c β†’ c ≀ a β†’ c ≀ b := ⟨λ ab c hc ca, le_trans ca ab, Ξ» h, begin rw [← Sup_atoms_le_eq a, ← Sup_atoms_le_eq b], exact Sup_le_Sup (Ξ» c hc, ⟨hc.1, h c hc.1 hc.2⟩), end⟩ end is_atomistic namespace is_coatomistic instance is_atomistic_dual [h : is_coatomistic Ξ±] : is_atomistic (order_dual Ξ±) := is_atomistic_dual_iff_is_coatomistic.2 h variable [is_coatomistic Ξ±] @[priority 100] instance : is_coatomic Ξ± := ⟨λ b, by { rcases eq_Inf_coatoms b with ⟨s, rfl, hs⟩, cases s.eq_empty_or_nonempty with h h, { simp [h] }, { exact or.intro_right _ ⟨h.some, hs _ h.some_spec, Inf_le h.some_spec⟩ } } ⟩ end is_coatomistic end atomistic /-- An order is simple iff it has exactly two elements, `βŠ₯` and `⊀`. -/ class is_simple_order (Ξ± : Type*) [has_le Ξ±] [bounded_order Ξ±] extends nontrivial Ξ± : Prop := (eq_bot_or_eq_top : βˆ€ (a : Ξ±), a = βŠ₯ ∨ a = ⊀) export is_simple_order (eq_bot_or_eq_top) theorem is_simple_order_iff_is_simple_order_order_dual [has_le Ξ±] [bounded_order Ξ±] : is_simple_order Ξ± ↔ is_simple_order (order_dual Ξ±) := begin split; intro i; haveI := i, { exact { exists_pair_ne := @exists_pair_ne Ξ± _, eq_bot_or_eq_top := Ξ» a, or.symm (eq_bot_or_eq_top ((order_dual.of_dual a)) : _ ∨ _) } }, { exact { exists_pair_ne := @exists_pair_ne (order_dual Ξ±) _, eq_bot_or_eq_top := Ξ» a, or.symm (eq_bot_or_eq_top (order_dual.to_dual a)) } } end lemma is_simple_order.bot_ne_top [has_le Ξ±] [bounded_order Ξ±] [is_simple_order Ξ±] : (βŠ₯ : Ξ±) β‰  (⊀ : Ξ±) := begin obtain ⟨a, b, h⟩ := exists_pair_ne Ξ±, rcases eq_bot_or_eq_top a with rfl|rfl; rcases eq_bot_or_eq_top b with rfl|rfl; simpa <|> simpa using h.symm end section is_simple_order variables [partial_order Ξ±] [bounded_order Ξ±] [is_simple_order Ξ±] instance {Ξ±} [has_le Ξ±] [bounded_order Ξ±] [is_simple_order Ξ±] : is_simple_order (order_dual Ξ±) := is_simple_order_iff_is_simple_order_order_dual.1 (by apply_instance) /-- A simple `bounded_order` induces a preorder. This is not an instance to prevent loops. -/ protected def is_simple_order.preorder {Ξ±} [has_le Ξ±] [bounded_order Ξ±] [is_simple_order Ξ±] : preorder Ξ± := { le := (≀), le_refl := Ξ» a, by rcases eq_bot_or_eq_top a with rfl|rfl; simp, le_trans := Ξ» a b c, begin rcases eq_bot_or_eq_top a with rfl|rfl, { simp }, { rcases eq_bot_or_eq_top b with rfl|rfl, { rcases eq_bot_or_eq_top c with rfl|rfl; simp }, { simp } } end } /-- A simple partial ordered `bounded_order` induces a linear order. This is not an instance to prevent loops. -/ protected def is_simple_order.linear_order [decidable_eq Ξ±] : linear_order Ξ± := { le_total := Ξ» a b, by rcases eq_bot_or_eq_top a with rfl|rfl; simp, decidable_le := Ξ» a b, if ha : a = βŠ₯ then is_true (ha.le.trans bot_le) else if hb : b = ⊀ then is_true (le_top.trans hb.ge) else is_false (Ξ» H, hb (top_unique (le_trans (top_le_iff.mpr (or.resolve_left (eq_bot_or_eq_top a) ha)) H))), decidable_eq := by assumption, ..(infer_instance : partial_order Ξ±) } @[simp] lemma is_atom_top : is_atom (⊀ : Ξ±) := ⟨top_ne_bot, Ξ» a ha, or.resolve_right (eq_bot_or_eq_top a) (ne_of_lt ha)⟩ @[simp] lemma is_coatom_bot : is_coatom (βŠ₯ : Ξ±) := is_atom_dual_iff_is_coatom.1 is_atom_top lemma bot_covby_top : (βŠ₯ : Ξ±) β‹– ⊀ := is_atom_top.bot_covby end is_simple_order namespace is_simple_order section preorder variables [preorder Ξ±] [bounded_order Ξ±] [is_simple_order Ξ±] {a b : Ξ±} (h : a < b) lemma eq_bot_of_lt : a = βŠ₯ := (is_simple_order.eq_bot_or_eq_top _).resolve_right h.ne_top lemma eq_top_of_lt : b = ⊀ := (is_simple_order.eq_bot_or_eq_top _).resolve_left h.ne_bot alias eq_bot_of_lt ← has_lt.lt.eq_bot alias eq_top_of_lt ← has_lt.lt.eq_top end preorder section bounded_order variables [lattice Ξ±] [bounded_order Ξ±] [is_simple_order Ξ±] /-- A simple partial ordered `bounded_order` induces a lattice. This is not an instance to prevent loops -/ protected def lattice {Ξ±} [decidable_eq Ξ±] [partial_order Ξ±] [bounded_order Ξ±] [is_simple_order Ξ±] : lattice Ξ± := @linear_order.to_lattice Ξ± (is_simple_order.linear_order) /-- A lattice that is a `bounded_order` is a distributive lattice. This is not an instance to prevent loops -/ protected def distrib_lattice : distrib_lattice Ξ± := { le_sup_inf := Ξ» x y z, by { rcases eq_bot_or_eq_top x with rfl | rfl; simp }, .. (infer_instance : lattice Ξ±) } @[priority 100] -- see Note [lower instance priority] instance : is_atomic Ξ± := ⟨λ b, (eq_bot_or_eq_top b).imp_right (Ξ» h, ⟨⊀, ⟨is_atom_top, ge_of_eq h⟩⟩)⟩ @[priority 100] -- see Note [lower instance priority] instance : is_coatomic Ξ± := is_atomic_dual_iff_is_coatomic.1 is_simple_order.is_atomic end bounded_order /- It is important that in this section `is_simple_order` is the last type-class argument. -/ section decidable_eq variables [decidable_eq Ξ±] [partial_order Ξ±] [bounded_order Ξ±] [is_simple_order Ξ±] /-- Every simple lattice is isomorphic to `bool`, regardless of order. -/ @[simps] def equiv_bool {Ξ±} [decidable_eq Ξ±] [has_le Ξ±] [bounded_order Ξ±] [is_simple_order Ξ±] : Ξ± ≃ bool := { to_fun := Ξ» x, x = ⊀, inv_fun := Ξ» x, cond x ⊀ βŠ₯, left_inv := Ξ» x, by { rcases (eq_bot_or_eq_top x) with rfl | rfl; simp [bot_ne_top] }, right_inv := Ξ» x, by { cases x; simp [bot_ne_top] } } /-- Every simple lattice over a partial order is order-isomorphic to `bool`. -/ def order_iso_bool : Ξ± ≃o bool := { map_rel_iff' := Ξ» a b, begin rcases (eq_bot_or_eq_top a) with rfl | rfl, { simp [bot_ne_top] }, { rcases (eq_bot_or_eq_top b) with rfl | rfl, { simp [bot_ne_top.symm, bot_ne_top, bool.ff_lt_tt] }, { simp [bot_ne_top] } } end, ..equiv_bool } /- It is important that `is_simple_order` is the last type-class argument of this instance, so that type-class inference fails quickly if it doesn't apply. -/ @[priority 200] instance {Ξ±} [decidable_eq Ξ±] [has_le Ξ±] [bounded_order Ξ±] [is_simple_order Ξ±] : fintype Ξ± := fintype.of_equiv bool equiv_bool.symm /-- A simple `bounded_order` is also a `boolean_algebra`. -/ protected def boolean_algebra {Ξ±} [decidable_eq Ξ±] [lattice Ξ±] [bounded_order Ξ±] [is_simple_order Ξ±] : boolean_algebra Ξ± := { compl := Ξ» x, if x = βŠ₯ then ⊀ else βŠ₯, sdiff := Ξ» x y, if x = ⊀ ∧ y = βŠ₯ then ⊀ else βŠ₯, sdiff_eq := Ξ» x y, by rcases eq_bot_or_eq_top x with rfl | rfl; simp [bot_ne_top, has_sdiff.sdiff, compl], inf_compl_le_bot := Ξ» x, begin rcases eq_bot_or_eq_top x with rfl | rfl, { simp }, { simp only [top_inf_eq], split_ifs with h h; simp [h] } end, top_le_sup_compl := Ξ» x, by rcases eq_bot_or_eq_top x with rfl | rfl; simp, sup_inf_sdiff := Ξ» x y, by rcases eq_bot_or_eq_top x with rfl | rfl; rcases eq_bot_or_eq_top y with rfl | rfl; simp [bot_ne_top], inf_inf_sdiff := Ξ» x y, begin rcases eq_bot_or_eq_top x with rfl | rfl, { simpa }, rcases eq_bot_or_eq_top y with rfl | rfl, { simpa }, { simp only [true_and, top_inf_eq, eq_self_iff_true], split_ifs with h h; simpa [h] } end, .. (show bounded_order Ξ±, by apply_instance), .. is_simple_order.distrib_lattice } end decidable_eq variables [lattice Ξ±] [bounded_order Ξ±] [is_simple_order Ξ±] open_locale classical /-- A simple `bounded_order` is also complete. -/ protected noncomputable def complete_lattice : complete_lattice Ξ± := { Sup := Ξ» s, if ⊀ ∈ s then ⊀ else βŠ₯, Inf := Ξ» s, if βŠ₯ ∈ s then βŠ₯ else ⊀, le_Sup := Ξ» s x h, by { rcases eq_bot_or_eq_top x with rfl | rfl, { exact bot_le }, { rw if_pos h } }, Sup_le := Ξ» s x h, by { rcases eq_bot_or_eq_top x with rfl | rfl, { rw if_neg, intro con, exact bot_ne_top (eq_top_iff.2 (h ⊀ con)) }, { exact le_top } }, Inf_le := Ξ» s x h, by { rcases eq_bot_or_eq_top x with rfl | rfl, { rw if_pos h }, { exact le_top } }, le_Inf := Ξ» s x h, by { rcases eq_bot_or_eq_top x with rfl | rfl, { exact bot_le }, { rw if_neg, intro con, exact top_ne_bot (eq_bot_iff.2 (h βŠ₯ con)) } }, .. (infer_instance : lattice Ξ±), .. (infer_instance : bounded_order Ξ±) } /-- A simple `bounded_order` is also a `complete_boolean_algebra`. -/ protected noncomputable def complete_boolean_algebra : complete_boolean_algebra Ξ± := { infi_sup_le_sup_Inf := Ξ» x s, by { rcases eq_bot_or_eq_top x with rfl | rfl, { simp only [bot_sup_eq, ← Inf_eq_infi], exact le_rfl }, { simp only [top_sup_eq, le_top] }, }, inf_Sup_le_supr_inf := Ξ» x s, by { rcases eq_bot_or_eq_top x with rfl | rfl, { simp only [bot_inf_eq, bot_le] }, { simp only [top_inf_eq, ← Sup_eq_supr], exact le_rfl } }, .. is_simple_order.complete_lattice, .. is_simple_order.boolean_algebra } end is_simple_order namespace is_simple_order variables [complete_lattice Ξ±] [is_simple_order Ξ±] set_option default_priority 100 instance : is_atomistic Ξ± := ⟨λ b, (eq_bot_or_eq_top b).elim (Ξ» h, βŸ¨βˆ…, ⟨h.trans Sup_empty.symm, Ξ» a ha, false.elim (set.not_mem_empty _ ha)⟩⟩) (Ξ» h, ⟨{⊀}, h.trans Sup_singleton.symm, Ξ» a ha, (set.mem_singleton_iff.1 ha).symm β–Έ is_atom_top⟩)⟩ instance : is_coatomistic Ξ± := is_atomistic_dual_iff_is_coatomistic.1 is_simple_order.is_atomistic end is_simple_order namespace fintype namespace is_simple_order variables [partial_order Ξ±] [bounded_order Ξ±] [is_simple_order Ξ±] [decidable_eq Ξ±] lemma univ : (finset.univ : finset Ξ±) = {⊀, βŠ₯} := begin change finset.map _ (finset.univ : finset bool) = _, rw fintype.univ_bool, simp only [finset.map_insert, function.embedding.coe_fn_mk, finset.map_singleton], refl, end lemma card : fintype.card Ξ± = 2 := (fintype.of_equiv_card _).trans fintype.card_bool end is_simple_order end fintype namespace bool instance : is_simple_order bool := ⟨λ a, begin rw [← finset.mem_singleton, or.comm, ← finset.mem_insert, top_eq_tt, bot_eq_ff, ← fintype.univ_bool], apply finset.mem_univ, end⟩ end bool theorem is_simple_order_iff_is_atom_top [partial_order Ξ±] [bounded_order Ξ±] : is_simple_order Ξ± ↔ is_atom (⊀ : Ξ±) := ⟨λ h, @is_atom_top _ _ _ h, Ξ» h, { exists_pair_ne := ⟨⊀, βŠ₯, h.1⟩, eq_bot_or_eq_top := Ξ» a, ((eq_or_lt_of_le le_top).imp_right (h.2 a)).symm }⟩ theorem is_simple_order_iff_is_coatom_bot [partial_order Ξ±] [bounded_order Ξ±] : is_simple_order Ξ± ↔ is_coatom (βŠ₯ : Ξ±) := is_simple_order_iff_is_simple_order_order_dual.trans is_simple_order_iff_is_atom_top namespace set theorem is_simple_order_Iic_iff_is_atom [partial_order Ξ±] [order_bot Ξ±] {a : Ξ±} : is_simple_order (Iic a) ↔ is_atom a := is_simple_order_iff_is_atom_top.trans $ and_congr (not_congr subtype.mk_eq_mk) ⟨λ h b ab, subtype.mk_eq_mk.1 (h ⟨b, le_of_lt ab⟩ ab), Ξ» h ⟨b, hab⟩ hbotb, subtype.mk_eq_mk.2 (h b (subtype.mk_lt_mk.1 hbotb))⟩ theorem is_simple_order_Ici_iff_is_coatom [partial_order Ξ±] [order_top Ξ±] {a : Ξ±} : is_simple_order (Ici a) ↔ is_coatom a := is_simple_order_iff_is_coatom_bot.trans $ and_congr (not_congr subtype.mk_eq_mk) ⟨λ h b ab, subtype.mk_eq_mk.1 (h ⟨b, le_of_lt ab⟩ ab), Ξ» h ⟨b, hab⟩ hbotb, subtype.mk_eq_mk.2 (h b (subtype.mk_lt_mk.1 hbotb))⟩ end set namespace order_iso variables {Ξ² : Type*} @[simp] lemma is_atom_iff [partial_order Ξ±] [order_bot Ξ±] [partial_order Ξ²] [order_bot Ξ²] (f : Ξ± ≃o Ξ²) (a : Ξ±) : is_atom (f a) ↔ is_atom a := and_congr (not_congr ⟨λ h, f.injective (f.map_bot.symm β–Έ h), Ξ» h, f.map_bot β–Έ (congr rfl h)⟩) ⟨λ h b hb, f.injective ((h (f b) ((f : Ξ± β†ͺo Ξ²).lt_iff_lt.2 hb)).trans f.map_bot.symm), Ξ» h b hb, f.symm.injective begin rw f.symm.map_bot, apply h, rw [← f.symm_apply_apply a], exact (f.symm : Ξ² β†ͺo Ξ±).lt_iff_lt.2 hb, end⟩ @[simp] lemma is_coatom_iff [partial_order Ξ±] [order_top Ξ±] [partial_order Ξ²] [order_top Ξ²] (f : Ξ± ≃o Ξ²) (a : Ξ±) : is_coatom (f a) ↔ is_coatom a := f.dual.is_atom_iff a lemma is_simple_order_iff [partial_order Ξ±] [bounded_order Ξ±] [partial_order Ξ²] [bounded_order Ξ²] (f : Ξ± ≃o Ξ²) : is_simple_order Ξ± ↔ is_simple_order Ξ² := by rw [is_simple_order_iff_is_atom_top, is_simple_order_iff_is_atom_top, ← f.is_atom_iff ⊀, f.map_top] lemma is_simple_order [partial_order Ξ±] [bounded_order Ξ±] [partial_order Ξ²] [bounded_order Ξ²] [h : is_simple_order Ξ²] (f : Ξ± ≃o Ξ²) : is_simple_order Ξ± := f.is_simple_order_iff.mpr h lemma is_atomic_iff [partial_order Ξ±] [order_bot Ξ±] [partial_order Ξ²] [order_bot Ξ²] (f : Ξ± ≃o Ξ²) : is_atomic Ξ± ↔ is_atomic Ξ² := begin suffices : (βˆ€ b : Ξ±, b = βŠ₯ ∨ βˆƒ (a : Ξ±), is_atom a ∧ a ≀ b) ↔ (βˆ€ b : Ξ², b = βŠ₯ ∨ βˆƒ (a : Ξ²), is_atom a ∧ a ≀ b), from ⟨λ ⟨p⟩, ⟨this.mp p⟩, Ξ» ⟨p⟩, ⟨this.mpr p⟩⟩, apply f.to_equiv.forall_congr, simp_rw [rel_iso.coe_fn_to_equiv], intro b, apply or_congr, { rw [f.apply_eq_iff_eq_symm_apply, map_bot], }, { split, { exact Ξ» ⟨a, ha⟩, ⟨f a, ⟨(f.is_atom_iff a).mpr ha.1, f.le_iff_le.mpr ha.2⟩⟩, }, { rintros ⟨b, ⟨hb1, hb2⟩⟩, refine ⟨f.symm b, ⟨(f.symm.is_atom_iff b).mpr hb1, _⟩⟩, rwa [←f.le_iff_le, f.apply_symm_apply], }, }, end lemma is_coatomic_iff [partial_order Ξ±] [order_top Ξ±] [partial_order Ξ²] [order_top Ξ²] (f : Ξ± ≃o Ξ²) : is_coatomic Ξ± ↔ is_coatomic Ξ² := by { rw [←is_atomic_dual_iff_is_coatomic, ←is_atomic_dual_iff_is_coatomic], exact f.dual.is_atomic_iff } end order_iso section is_modular_lattice variables [lattice Ξ±] [bounded_order Ξ±] [is_modular_lattice Ξ±] namespace is_compl variables {a b : Ξ±} (hc : is_compl a b) include hc lemma is_atom_iff_is_coatom : is_atom a ↔ is_coatom b := set.is_simple_order_Iic_iff_is_atom.symm.trans $ hc.Iic_order_iso_Ici.is_simple_order_iff.trans set.is_simple_order_Ici_iff_is_coatom lemma is_coatom_iff_is_atom : is_coatom a ↔ is_atom b := hc.symm.is_atom_iff_is_coatom.symm end is_compl variables [is_complemented Ξ±] lemma is_coatomic_of_is_atomic_of_is_complemented_of_is_modular [is_atomic Ξ±] : is_coatomic Ξ± := ⟨λ x, begin rcases exists_is_compl x with ⟨y, xy⟩, apply (eq_bot_or_exists_atom_le y).imp _ _, { rintro rfl, exact eq_top_of_is_compl_bot xy }, { rintro ⟨a, ha, ay⟩, rcases exists_is_compl (xy.symm.Iic_order_iso_Ici ⟨a, ay⟩) with ⟨⟨b, xb⟩, hb⟩, refine βŸ¨β†‘(⟨b, xb⟩ : set.Ici x), is_coatom.of_is_coatom_coe_Ici _, xb⟩, rw [← hb.is_atom_iff_is_coatom, order_iso.is_atom_iff], apply ha.Iic } end⟩ lemma is_atomic_of_is_coatomic_of_is_complemented_of_is_modular [is_coatomic Ξ±] : is_atomic Ξ± := is_coatomic_dual_iff_is_atomic.1 is_coatomic_of_is_atomic_of_is_complemented_of_is_modular theorem is_atomic_iff_is_coatomic : is_atomic Ξ± ↔ is_coatomic Ξ± := ⟨λ h, @is_coatomic_of_is_atomic_of_is_complemented_of_is_modular _ _ _ _ _ h, Ξ» h, @is_atomic_of_is_coatomic_of_is_complemented_of_is_modular _ _ _ _ _ h⟩ end is_modular_lattice section fintype open finset @[priority 100] -- see Note [lower instance priority] instance fintype.to_is_coatomic [partial_order Ξ±] [order_top Ξ±] [fintype Ξ±] : is_coatomic Ξ± := begin refine is_coatomic.mk (Ξ» b, or_iff_not_imp_left.2 (Ξ» ht, _)), obtain ⟨c, hc, hmax⟩ := set.finite.exists_maximal_wrt id { x : Ξ± | b ≀ x ∧ x β‰  ⊀ } (set.finite.of_fintype _) ⟨b, le_rfl, ht⟩, refine ⟨c, ⟨hc.2, Ξ» y hcy, _⟩, hc.1⟩, by_contra hyt, obtain rfl : c = y := hmax y ⟨hc.1.trans hcy.le, hyt⟩ hcy.le, exact (lt_self_iff_false _).mp hcy end @[priority 100] -- see Note [lower instance priority] instance fintype.to_is_atomic [partial_order Ξ±] [order_bot Ξ±] [fintype Ξ±] : is_atomic Ξ± := is_coatomic_dual_iff_is_atomic.mp fintype.to_is_coatomic end fintype
/- Just some random additions to `Core.lean` that look like they would actually belong there. -/ theorem Iff.isEquivalence : Equivalence Iff := ⟨Iff.refl, Iff.symm, Iff.trans⟩ theorem Eq.isEquivalence {Ξ± : Sort u} : Equivalence (@Eq Ξ±) := ⟨Eq.refl, Eq.symm, Eq.trans⟩ theorem Setoid.of_Eq {Ξ± : Sort u} [Setoid Ξ±] {a b : Ξ±} (h : a = b) : a β‰ˆ b := h β–Έ Setoid.refl a class Mem (Ξ± : outParam $ Type u) (Ξ³ : Type v) where mem : Ξ± β†’ Ξ³ β†’ Prop infix:50 " ∈ " => Mem.mem class Subset (Ξ± : Type u) where subset : Ξ± β†’ Ξ± β†’ Prop infix:50 " βŠ† " => Subset.subset namespace List protected def mem : Ξ± β†’ List Ξ± β†’ Prop | a, [] => False | a, b :: l => a = b ∨ List.mem a l instance : Mem Ξ± (List Ξ±) := ⟨List.mem⟩ theorem mem_cons_self (a : Ξ±) (l : List Ξ±) : a ∈ a :: l := Or.inl rfl @[simp] theorem mem_cons_iff (a y : Ξ±) (l : List Ξ±) : a ∈ y :: l ↔ (a = y ∨ a ∈ l) := Iff.rfl protected def subset (l₁ lβ‚‚ : List Ξ±) := βˆ€ {a : Ξ±}, a ∈ l₁ β†’ a ∈ lβ‚‚ instance : Subset (List Ξ±) := ⟨List.subset⟩ theorem eq_nil_of_length_eq_zero {l : List Ξ±} (hl : length l = 0) : l = [] := match l with | [] => rfl | x :: m => False.elim $ Nat.succNeZero (m.length) (List.length_cons x m β–Έ hl) end List def symmetric (r : Ξ± β†’ Ξ± β†’ Prop) := βˆ€ {x y}, r x y β†’ r y x
{-# OPTIONS --without-K --safe #-} module Reader where -- The reader monad (mainly used for nice syntax with idiom brackets) open import Level Reader : βˆ€ {r a} β†’ Set r β†’ Set a β†’ Set (a βŠ” r) Reader R A = R β†’ A module _ {r} {Rβ€² : Set r} where R : βˆ€ {a} β†’ Set a β†’ Set (a βŠ” r) R = Reader Rβ€² pure : βˆ€ {a} {A : Set a} β†’ A β†’ R A pure x = Ξ» _ β†’ x {-# INLINE pure #-} _<*>_ : βˆ€ {a b} {A : Set a} {B : Set b} β†’ R (A β†’ B) β†’ R A β†’ R B f <*> g = Ξ» x β†’ f x (g x) {-# INLINE _<*>_ #-} _>>=_ : βˆ€ {a b} {A : Set a} {B : Set b} β†’ R A β†’ (A β†’ R B) β†’ R B f >>= k = Ξ» x β†’ k (f x) x {-# INLINE _>>=_ #-}
A set $S$ is locally closed if and only if it is locally compact.
/- Copyright (c) 2020 SΓ©bastien GouΓ«zel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: SΓ©bastien GouΓ«zel ! This file was ported from Lean 3 source module topology.uniform_space.uniform_convergence ! leanprover-community/mathlib commit 0a0ec35061ed9960bf0e7ffb0335f44447b58977 ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathbin.Topology.Separation import Mathbin.Topology.UniformSpace.Basic import Mathbin.Topology.UniformSpace.Cauchy /-! # Uniform convergence > THIS FILE IS SYNCHRONIZED WITH MATHLIB4. > Any changes to this file require a corresponding PR to mathlib4. A sequence of functions `Fβ‚™` (with values in a metric space) converges uniformly on a set `s` to a function `f` if, for all `Ξ΅ > 0`, for all large enough `n`, one has for all `y ∈ s` the inequality `dist (f y, Fβ‚™ y) < Ξ΅`. Under uniform convergence, many properties of the `Fβ‚™` pass to the limit, most notably continuity. We prove this in the file, defining the notion of uniform convergence in the more general setting of uniform spaces, and with respect to an arbitrary indexing set endowed with a filter (instead of just `β„•` with `at_top`). ## Main results Let `Ξ±` be a topological space, `Ξ²` a uniform space, `Fβ‚™` and `f` be functions from `Ξ±`to `Ξ²` (where the index `n` belongs to an indexing type `ΞΉ` endowed with a filter `p`). * `tendsto_uniformly_on F f p s`: the fact that `Fβ‚™` converges uniformly to `f` on `s`. This means that, for any entourage `u` of the diagonal, for large enough `n` (with respect to `p`), one has `(f y, Fβ‚™ y) ∈ u` for all `y ∈ s`. * `tendsto_uniformly F f p`: same notion with `s = univ`. * `tendsto_uniformly_on.continuous_on`: a uniform limit on a set of functions which are continuous on this set is itself continuous on this set. * `tendsto_uniformly.continuous`: a uniform limit of continuous functions is continuous. * `tendsto_uniformly_on.tendsto_comp`: If `Fβ‚™` tends uniformly to `f` on a set `s`, and `gβ‚™` tends to `x` within `s`, then `Fβ‚™ gβ‚™` tends to `f x` if `f` is continuous at `x` within `s`. * `tendsto_uniformly.tendsto_comp`: If `Fβ‚™` tends uniformly to `f`, and `gβ‚™` tends to `x`, then `Fβ‚™ gβ‚™` tends to `f x`. We also define notions where the convergence is locally uniform, called `tendsto_locally_uniformly_on F f p s` and `tendsto_locally_uniformly F f p`. The previous theorems all have corresponding versions under locally uniform convergence. Finally, we introduce the notion of a uniform Cauchy sequence, which is to uniform convergence what a Cauchy sequence is to the usual notion of convergence. ## Implementation notes We derive most of our initial results from an auxiliary definition `tendsto_uniformly_on_filter`. This definition in and of itself can sometimes be useful, e.g., when studying the local behavior of the `Fβ‚™` near a point, which would typically look like `tendsto_uniformly_on_filter F f p (𝓝 x)`. Still, while this may be the "correct" definition (see `tendsto_uniformly_on_iff_tendsto_uniformly_on_filter`), it is somewhat unwieldy to work with in practice. Thus, we provide the more traditional definition in `tendsto_uniformly_on`. Most results hold under weaker assumptions of locally uniform approximation. In a first section, we prove the results under these weaker assumptions. Then, we derive the results on uniform convergence from them. ## Tags Uniform limit, uniform convergence, tends uniformly to -/ noncomputable section open Topology Classical uniformity Filter open Set Filter universe u v w variable {Ξ± Ξ² Ξ³ ΞΉ : Type _} [UniformSpace Ξ²] variable {F : ΞΉ β†’ Ξ± β†’ Ξ²} {f : Ξ± β†’ Ξ²} {s s' : Set Ξ±} {x : Ξ±} {p : Filter ΞΉ} {p' : Filter Ξ±} {g : ΞΉ β†’ Ξ±} /-! ### Different notions of uniform convergence We define uniform convergence and locally uniform convergence, on a set or in the whole space. -/ #print TendstoUniformlyOnFilter /- /-- A sequence of functions `Fβ‚™` converges uniformly on a filter `p'` to a limiting function `f` with respect to the filter `p` if, for any entourage of the diagonal `u`, one has `p Γ—αΆ  p'`-eventually `(f x, Fβ‚™ x) ∈ u`. -/ def TendstoUniformlyOnFilter (F : ΞΉ β†’ Ξ± β†’ Ξ²) (f : Ξ± β†’ Ξ²) (p : Filter ΞΉ) (p' : Filter Ξ±) := βˆ€ u ∈ 𝓀 Ξ², βˆ€αΆ  n : ΞΉ Γ— Ξ± in p Γ—αΆ  p', (f n.snd, F n.fst n.snd) ∈ u #align tendsto_uniformly_on_filter TendstoUniformlyOnFilter -/ #print tendstoUniformlyOnFilter_iff_tendsto /- /-- A sequence of functions `Fβ‚™` converges uniformly on a filter `p'` to a limiting function `f` w.r.t. filter `p` iff the function `(n, x) ↦ (f x, Fβ‚™ x)` converges along `p Γ—αΆ  p'` to the uniformity. In other words: one knows nothing about the behavior of `x` in this limit besides it being in `p'`. -/ theorem tendstoUniformlyOnFilter_iff_tendsto : TendstoUniformlyOnFilter F f p p' ↔ Tendsto (fun q : ΞΉ Γ— Ξ± => (f q.2, F q.1 q.2)) (p Γ—αΆ  p') (𝓀 Ξ²) := forallβ‚‚_congr fun u u_in => by simp [mem_map, Filter.Eventually, mem_prod_iff, preimage] #align tendsto_uniformly_on_filter_iff_tendsto tendstoUniformlyOnFilter_iff_tendsto -/ #print TendstoUniformlyOn /- /-- A sequence of functions `Fβ‚™` converges uniformly on a set `s` to a limiting function `f` with respect to the filter `p` if, for any entourage of the diagonal `u`, one has `p`-eventually `(f x, Fβ‚™ x) ∈ u` for all `x ∈ s`. -/ def TendstoUniformlyOn (F : ΞΉ β†’ Ξ± β†’ Ξ²) (f : Ξ± β†’ Ξ²) (p : Filter ΞΉ) (s : Set Ξ±) := βˆ€ u ∈ 𝓀 Ξ², βˆ€αΆ  n in p, βˆ€ x : Ξ±, x ∈ s β†’ (f x, F n x) ∈ u #align tendsto_uniformly_on TendstoUniformlyOn -/ #print tendstoUniformlyOn_iff_tendstoUniformlyOnFilter /- theorem tendstoUniformlyOn_iff_tendstoUniformlyOnFilter : TendstoUniformlyOn F f p s ↔ TendstoUniformlyOnFilter F f p (π“Ÿ s) := by simp only [TendstoUniformlyOn, TendstoUniformlyOnFilter] apply forallβ‚‚_congr simp_rw [eventually_prod_principal_iff] simp #align tendsto_uniformly_on_iff_tendsto_uniformly_on_filter tendstoUniformlyOn_iff_tendstoUniformlyOnFilter -/ alias tendstoUniformlyOn_iff_tendstoUniformlyOnFilter ↔ TendstoUniformlyOn.tendstoUniformlyOnFilter TendstoUniformlyOnFilter.tendstoUniformlyOn #align tendsto_uniformly_on.tendsto_uniformly_on_filter TendstoUniformlyOn.tendstoUniformlyOnFilter #align tendsto_uniformly_on_filter.tendsto_uniformly_on TendstoUniformlyOnFilter.tendstoUniformlyOn #print tendstoUniformlyOn_iff_tendsto /- /-- A sequence of functions `Fβ‚™` converges uniformly on a set `s` to a limiting function `f` w.r.t. filter `p` iff the function `(n, x) ↦ (f x, Fβ‚™ x)` converges along `p Γ—αΆ  π“Ÿ s` to the uniformity. In other words: one knows nothing about the behavior of `x` in this limit besides it being in `s`. -/ theorem tendstoUniformlyOn_iff_tendsto {F : ΞΉ β†’ Ξ± β†’ Ξ²} {f : Ξ± β†’ Ξ²} {p : Filter ΞΉ} {s : Set Ξ±} : TendstoUniformlyOn F f p s ↔ Tendsto (fun q : ΞΉ Γ— Ξ± => (f q.2, F q.1 q.2)) (p Γ—αΆ  π“Ÿ s) (𝓀 Ξ²) := by simp [tendstoUniformlyOn_iff_tendstoUniformlyOnFilter, tendstoUniformlyOnFilter_iff_tendsto] #align tendsto_uniformly_on_iff_tendsto tendstoUniformlyOn_iff_tendsto -/ #print TendstoUniformly /- /-- A sequence of functions `Fβ‚™` converges uniformly to a limiting function `f` with respect to a filter `p` if, for any entourage of the diagonal `u`, one has `p`-eventually `(f x, Fβ‚™ x) ∈ u` for all `x`. -/ def TendstoUniformly (F : ΞΉ β†’ Ξ± β†’ Ξ²) (f : Ξ± β†’ Ξ²) (p : Filter ΞΉ) := βˆ€ u ∈ 𝓀 Ξ², βˆ€αΆ  n in p, βˆ€ x : Ξ±, (f x, F n x) ∈ u #align tendsto_uniformly TendstoUniformly -/ /- warning: tendsto_uniformly_iff_tendsto_uniformly_on_filter -> tendstoUniformly_iff_tendstoUniformlyOnFilter is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {p : Filter.{u3} ΞΉ}, Iff (TendstoUniformly.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F f p) (TendstoUniformlyOnFilter.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F f p (Top.top.{u1} (Filter.{u1} Ξ±) (Filter.hasTop.{u1} Ξ±))) but is expected to have type forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {p : Filter.{u3} ΞΉ}, Iff (TendstoUniformly.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F f p) (TendstoUniformlyOnFilter.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F f p (Top.top.{u1} (Filter.{u1} Ξ±) (Filter.instTopFilter.{u1} Ξ±))) Case conversion may be inaccurate. Consider using '#align tendsto_uniformly_iff_tendsto_uniformly_on_filter tendstoUniformly_iff_tendstoUniformlyOnFilterβ‚“'. -/ theorem tendstoUniformly_iff_tendstoUniformlyOnFilter : TendstoUniformly F f p ↔ TendstoUniformlyOnFilter F f p ⊀ := by simp only [TendstoUniformly, TendstoUniformlyOnFilter] apply forallβ‚‚_congr simp_rw [← principal_univ, eventually_prod_principal_iff] simp #align tendsto_uniformly_iff_tendsto_uniformly_on_filter tendstoUniformly_iff_tendstoUniformlyOnFilter /- warning: tendsto_uniformly.tendsto_uniformly_on_filter -> TendstoUniformly.tendstoUniformlyOnFilter is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {p : Filter.{u3} ΞΉ}, (TendstoUniformly.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F f p) -> (TendstoUniformlyOnFilter.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F f p (Top.top.{u1} (Filter.{u1} Ξ±) (Filter.hasTop.{u1} Ξ±))) but is expected to have type forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {p : Filter.{u3} ΞΉ}, (TendstoUniformly.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F f p) -> (TendstoUniformlyOnFilter.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F f p (Top.top.{u1} (Filter.{u1} Ξ±) (Filter.instTopFilter.{u1} Ξ±))) Case conversion may be inaccurate. Consider using '#align tendsto_uniformly.tendsto_uniformly_on_filter TendstoUniformly.tendstoUniformlyOnFilterβ‚“'. -/ theorem TendstoUniformly.tendstoUniformlyOnFilter (h : TendstoUniformly F f p) : TendstoUniformlyOnFilter F f p ⊀ := by rwa [← tendstoUniformly_iff_tendstoUniformlyOnFilter] #align tendsto_uniformly.tendsto_uniformly_on_filter TendstoUniformly.tendstoUniformlyOnFilter #print tendstoUniformlyOn_iff_tendstoUniformly_comp_coe /- theorem tendstoUniformlyOn_iff_tendstoUniformly_comp_coe : TendstoUniformlyOn F f p s ↔ TendstoUniformly (fun i (x : s) => F i x) (f ∘ coe) p := by apply forallβ‚‚_congr intro u hu simp #align tendsto_uniformly_on_iff_tendsto_uniformly_comp_coe tendstoUniformlyOn_iff_tendstoUniformly_comp_coe -/ /- warning: tendsto_uniformly_iff_tendsto -> tendstoUniformly_iff_tendsto is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {p : Filter.{u3} ΞΉ}, Iff (TendstoUniformly.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F f p) (Filter.Tendsto.{max u3 u1, u2} (Prod.{u3, u1} ΞΉ Ξ±) (Prod.{u2, u2} Ξ² Ξ²) (fun (q : Prod.{u3, u1} ΞΉ Ξ±) => Prod.mk.{u2, u2} Ξ² Ξ² (f (Prod.snd.{u3, u1} ΞΉ Ξ± q)) (F (Prod.fst.{u3, u1} ΞΉ Ξ± q) (Prod.snd.{u3, u1} ΞΉ Ξ± q))) (Filter.prod.{u3, u1} ΞΉ Ξ± p (Top.top.{u1} (Filter.{u1} Ξ±) (Filter.hasTop.{u1} Ξ±))) (uniformity.{u2} Ξ² _inst_1)) but is expected to have type forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {p : Filter.{u3} ΞΉ}, Iff (TendstoUniformly.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F f p) (Filter.Tendsto.{max u1 u3, u2} (Prod.{u3, u1} ΞΉ Ξ±) (Prod.{u2, u2} Ξ² Ξ²) (fun (q : Prod.{u3, u1} ΞΉ Ξ±) => Prod.mk.{u2, u2} Ξ² Ξ² (f (Prod.snd.{u3, u1} ΞΉ Ξ± q)) (F (Prod.fst.{u3, u1} ΞΉ Ξ± q) (Prod.snd.{u3, u1} ΞΉ Ξ± q))) (Filter.prod.{u3, u1} ΞΉ Ξ± p (Top.top.{u1} (Filter.{u1} Ξ±) (Filter.instTopFilter.{u1} Ξ±))) (uniformity.{u2} Ξ² _inst_1)) Case conversion may be inaccurate. Consider using '#align tendsto_uniformly_iff_tendsto tendstoUniformly_iff_tendstoβ‚“'. -/ /-- A sequence of functions `Fβ‚™` converges uniformly to a limiting function `f` w.r.t. filter `p` iff the function `(n, x) ↦ (f x, Fβ‚™ x)` converges along `p Γ—αΆ  ⊀` to the uniformity. In other words: one knows nothing about the behavior of `x` in this limit. -/ theorem tendstoUniformly_iff_tendsto {F : ΞΉ β†’ Ξ± β†’ Ξ²} {f : Ξ± β†’ Ξ²} {p : Filter ΞΉ} : TendstoUniformly F f p ↔ Tendsto (fun q : ΞΉ Γ— Ξ± => (f q.2, F q.1 q.2)) (p Γ—αΆ  ⊀) (𝓀 Ξ²) := by simp [tendstoUniformly_iff_tendstoUniformlyOnFilter, tendstoUniformlyOnFilter_iff_tendsto] #align tendsto_uniformly_iff_tendsto tendstoUniformly_iff_tendsto /- warning: tendsto_uniformly_on_filter.tendsto_at -> TendstoUniformlyOnFilter.tendsto_at is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {x : Ξ±} {p : Filter.{u3} ΞΉ} {p' : Filter.{u1} Ξ±}, (TendstoUniformlyOnFilter.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F f p p') -> (LE.le.{u1} (Filter.{u1} Ξ±) (Preorder.toLE.{u1} (Filter.{u1} Ξ±) (PartialOrder.toPreorder.{u1} (Filter.{u1} Ξ±) (Filter.partialOrder.{u1} Ξ±))) (Filter.principal.{u1} Ξ± (Singleton.singleton.{u1, u1} Ξ± (Set.{u1} Ξ±) (Set.hasSingleton.{u1} Ξ±) x)) p') -> (Filter.Tendsto.{u3, u2} ΞΉ Ξ² (fun (n : ΞΉ) => F n x) p (nhds.{u2} Ξ² (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) (f x))) but is expected to have type forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {x : Ξ±} {p : Filter.{u3} ΞΉ} {p' : Filter.{u1} Ξ±}, (TendstoUniformlyOnFilter.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F f p p') -> (LE.le.{u1} (Filter.{u1} Ξ±) (Preorder.toLE.{u1} (Filter.{u1} Ξ±) (PartialOrder.toPreorder.{u1} (Filter.{u1} Ξ±) (Filter.instPartialOrderFilter.{u1} Ξ±))) (Filter.principal.{u1} Ξ± (Singleton.singleton.{u1, u1} Ξ± (Set.{u1} Ξ±) (Set.instSingletonSet.{u1} Ξ±) x)) p') -> (Filter.Tendsto.{u3, u2} ΞΉ Ξ² (fun (n : ΞΉ) => F n x) p (nhds.{u2} Ξ² (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) (f x))) Case conversion may be inaccurate. Consider using '#align tendsto_uniformly_on_filter.tendsto_at TendstoUniformlyOnFilter.tendsto_atβ‚“'. -/ /-- Uniform converence implies pointwise convergence. -/ theorem TendstoUniformlyOnFilter.tendsto_at (h : TendstoUniformlyOnFilter F f p p') (hx : π“Ÿ {x} ≀ p') : Tendsto (fun n => F n x) p <| 𝓝 (f x) := by refine' uniform.tendsto_nhds_right.mpr fun u hu => mem_map.mpr _ filter_upwards [(h u hu).curry] intro i h simpa using h.filter_mono hx #align tendsto_uniformly_on_filter.tendsto_at TendstoUniformlyOnFilter.tendsto_at #print TendstoUniformlyOn.tendsto_at /- /-- Uniform converence implies pointwise convergence. -/ theorem TendstoUniformlyOn.tendsto_at (h : TendstoUniformlyOn F f p s) {x : Ξ±} (hx : x ∈ s) : Tendsto (fun n => F n x) p <| 𝓝 (f x) := h.TendstoUniformlyOnFilter.tendsto_at (le_principal_iff.mpr <| mem_principal.mpr <| singleton_subset_iff.mpr <| hx) #align tendsto_uniformly_on.tendsto_at TendstoUniformlyOn.tendsto_at -/ #print TendstoUniformly.tendsto_at /- /-- Uniform converence implies pointwise convergence. -/ theorem TendstoUniformly.tendsto_at (h : TendstoUniformly F f p) (x : Ξ±) : Tendsto (fun n => F n x) p <| 𝓝 (f x) := h.TendstoUniformlyOnFilter.tendsto_at le_top #align tendsto_uniformly.tendsto_at TendstoUniformly.tendsto_at -/ #print tendstoUniformlyOn_univ /- theorem tendstoUniformlyOn_univ : TendstoUniformlyOn F f p univ ↔ TendstoUniformly F f p := by simp [TendstoUniformlyOn, TendstoUniformly] #align tendsto_uniformly_on_univ tendstoUniformlyOn_univ -/ /- warning: tendsto_uniformly_on_filter.mono_left -> TendstoUniformlyOnFilter.mono_left is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {p : Filter.{u3} ΞΉ} {p' : Filter.{u1} Ξ±} {p'' : Filter.{u3} ΞΉ}, (TendstoUniformlyOnFilter.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F f p p') -> (LE.le.{u3} (Filter.{u3} ΞΉ) (Preorder.toLE.{u3} (Filter.{u3} ΞΉ) (PartialOrder.toPreorder.{u3} (Filter.{u3} ΞΉ) (Filter.partialOrder.{u3} ΞΉ))) p'' p) -> (TendstoUniformlyOnFilter.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F f p'' p') but is expected to have type forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {p : Filter.{u3} ΞΉ} {p' : Filter.{u1} Ξ±} {p'' : Filter.{u3} ΞΉ}, (TendstoUniformlyOnFilter.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F f p p') -> (LE.le.{u3} (Filter.{u3} ΞΉ) (Preorder.toLE.{u3} (Filter.{u3} ΞΉ) (PartialOrder.toPreorder.{u3} (Filter.{u3} ΞΉ) (Filter.instPartialOrderFilter.{u3} ΞΉ))) p'' p) -> (TendstoUniformlyOnFilter.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F f p'' p') Case conversion may be inaccurate. Consider using '#align tendsto_uniformly_on_filter.mono_left TendstoUniformlyOnFilter.mono_leftβ‚“'. -/ theorem TendstoUniformlyOnFilter.mono_left {p'' : Filter ΞΉ} (h : TendstoUniformlyOnFilter F f p p') (hp : p'' ≀ p) : TendstoUniformlyOnFilter F f p'' p' := fun u hu => (h u hu).filter_mono (p'.prod_mono_left hp) #align tendsto_uniformly_on_filter.mono_left TendstoUniformlyOnFilter.mono_left /- warning: tendsto_uniformly_on_filter.mono_right -> TendstoUniformlyOnFilter.mono_right is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {p : Filter.{u3} ΞΉ} {p' : Filter.{u1} Ξ±} {p'' : Filter.{u1} Ξ±}, (TendstoUniformlyOnFilter.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F f p p') -> (LE.le.{u1} (Filter.{u1} Ξ±) (Preorder.toLE.{u1} (Filter.{u1} Ξ±) (PartialOrder.toPreorder.{u1} (Filter.{u1} Ξ±) (Filter.partialOrder.{u1} Ξ±))) p'' p') -> (TendstoUniformlyOnFilter.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F f p p'') but is expected to have type forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {p : Filter.{u3} ΞΉ} {p' : Filter.{u1} Ξ±} {p'' : Filter.{u1} Ξ±}, (TendstoUniformlyOnFilter.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F f p p') -> (LE.le.{u1} (Filter.{u1} Ξ±) (Preorder.toLE.{u1} (Filter.{u1} Ξ±) (PartialOrder.toPreorder.{u1} (Filter.{u1} Ξ±) (Filter.instPartialOrderFilter.{u1} Ξ±))) p'' p') -> (TendstoUniformlyOnFilter.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F f p p'') Case conversion may be inaccurate. Consider using '#align tendsto_uniformly_on_filter.mono_right TendstoUniformlyOnFilter.mono_rightβ‚“'. -/ theorem TendstoUniformlyOnFilter.mono_right {p'' : Filter Ξ±} (h : TendstoUniformlyOnFilter F f p p') (hp : p'' ≀ p') : TendstoUniformlyOnFilter F f p p'' := fun u hu => (h u hu).filter_mono (p.prod_mono_right hp) #align tendsto_uniformly_on_filter.mono_right TendstoUniformlyOnFilter.mono_right #print TendstoUniformlyOn.mono /- theorem TendstoUniformlyOn.mono {s' : Set Ξ±} (h : TendstoUniformlyOn F f p s) (h' : s' βŠ† s) : TendstoUniformlyOn F f p s' := tendstoUniformlyOn_iff_tendstoUniformlyOnFilter.mpr (h.TendstoUniformlyOnFilter.mono_right (le_principal_iff.mpr <| mem_principal.mpr h')) #align tendsto_uniformly_on.mono TendstoUniformlyOn.mono -/ #print TendstoUniformlyOnFilter.congr /- theorem TendstoUniformlyOnFilter.congr {F' : ΞΉ β†’ Ξ± β†’ Ξ²} (hf : TendstoUniformlyOnFilter F f p p') (hff' : βˆ€αΆ  n : ΞΉ Γ— Ξ± in p Γ—αΆ  p', F n.fst n.snd = F' n.fst n.snd) : TendstoUniformlyOnFilter F' f p p' := by refine' fun u hu => ((hf u hu).And hff').mono fun n h => _ rw [← h.right] exact h.left #align tendsto_uniformly_on_filter.congr TendstoUniformlyOnFilter.congr -/ #print TendstoUniformlyOn.congr /- theorem TendstoUniformlyOn.congr {F' : ΞΉ β†’ Ξ± β†’ Ξ²} (hf : TendstoUniformlyOn F f p s) (hff' : βˆ€αΆ  n in p, Set.EqOn (F n) (F' n) s) : TendstoUniformlyOn F' f p s := by rw [tendstoUniformlyOn_iff_tendstoUniformlyOnFilter] at hf⊒ refine' hf.congr _ rw [eventually_iff] at hff'⊒ simp only [Set.EqOn] at hff' simp only [mem_prod_principal, hff', mem_set_of_eq] #align tendsto_uniformly_on.congr TendstoUniformlyOn.congr -/ #print TendstoUniformlyOn.congr_right /- theorem TendstoUniformlyOn.congr_right {g : Ξ± β†’ Ξ²} (hf : TendstoUniformlyOn F f p s) (hfg : EqOn f g s) : TendstoUniformlyOn F g p s := fun u hu => by filter_upwards [hf u hu]with i hi a ha using hfg ha β–Έ hi a ha #align tendsto_uniformly_on.congr_right TendstoUniformlyOn.congr_right -/ #print TendstoUniformly.tendstoUniformlyOn /- protected theorem TendstoUniformly.tendstoUniformlyOn (h : TendstoUniformly F f p) : TendstoUniformlyOn F f p s := (tendstoUniformlyOn_univ.2 h).mono (subset_univ s) #align tendsto_uniformly.tendsto_uniformly_on TendstoUniformly.tendstoUniformlyOn -/ #print TendstoUniformlyOnFilter.comp /- /-- Composing on the right by a function preserves uniform convergence on a filter -/ theorem TendstoUniformlyOnFilter.comp (h : TendstoUniformlyOnFilter F f p p') (g : Ξ³ β†’ Ξ±) : TendstoUniformlyOnFilter (fun n => F n ∘ g) (f ∘ g) p (p'.comap g) := by intro u hu obtain ⟨pa, hpa, pb, hpb, hpapb⟩ := eventually_prod_iff.mp (h u hu) rw [eventually_prod_iff] simp_rw [eventually_comap] exact ⟨pa, hpa, pb ∘ g, ⟨hpb.mono fun x hx y hy => by simp only [hx, hy, Function.comp_apply], fun x hx y hy => hpapb hx hy⟩⟩ #align tendsto_uniformly_on_filter.comp TendstoUniformlyOnFilter.comp -/ #print TendstoUniformlyOn.comp /- /-- Composing on the right by a function preserves uniform convergence on a set -/ theorem TendstoUniformlyOn.comp (h : TendstoUniformlyOn F f p s) (g : Ξ³ β†’ Ξ±) : TendstoUniformlyOn (fun n => F n ∘ g) (f ∘ g) p (g ⁻¹' s) := by rw [tendstoUniformlyOn_iff_tendstoUniformlyOnFilter] at h⊒ simpa [TendstoUniformlyOn, comap_principal] using TendstoUniformlyOnFilter.comp h g #align tendsto_uniformly_on.comp TendstoUniformlyOn.comp -/ #print TendstoUniformly.comp /- /-- Composing on the right by a function preserves uniform convergence -/ theorem TendstoUniformly.comp (h : TendstoUniformly F f p) (g : Ξ³ β†’ Ξ±) : TendstoUniformly (fun n => F n ∘ g) (f ∘ g) p := by rw [tendstoUniformly_iff_tendstoUniformlyOnFilter] at h⊒ simpa [principal_univ, comap_principal] using h.comp g #align tendsto_uniformly.comp TendstoUniformly.comp -/ #print UniformContinuous.comp_tendstoUniformlyOnFilter /- /-- Composing on the left by a uniformly continuous function preserves uniform convergence on a filter -/ theorem UniformContinuous.comp_tendstoUniformlyOnFilter [UniformSpace Ξ³] {g : Ξ² β†’ Ξ³} (hg : UniformContinuous g) (h : TendstoUniformlyOnFilter F f p p') : TendstoUniformlyOnFilter (fun i => g ∘ F i) (g ∘ f) p p' := fun u hu => h _ (hg hu) #align uniform_continuous.comp_tendsto_uniformly_on_filter UniformContinuous.comp_tendstoUniformlyOnFilter -/ #print UniformContinuous.comp_tendstoUniformlyOn /- /-- Composing on the left by a uniformly continuous function preserves uniform convergence on a set -/ theorem UniformContinuous.comp_tendstoUniformlyOn [UniformSpace Ξ³] {g : Ξ² β†’ Ξ³} (hg : UniformContinuous g) (h : TendstoUniformlyOn F f p s) : TendstoUniformlyOn (fun i => g ∘ F i) (g ∘ f) p s := fun u hu => h _ (hg hu) #align uniform_continuous.comp_tendsto_uniformly_on UniformContinuous.comp_tendstoUniformlyOn -/ #print UniformContinuous.comp_tendstoUniformly /- /-- Composing on the left by a uniformly continuous function preserves uniform convergence -/ theorem UniformContinuous.comp_tendstoUniformly [UniformSpace Ξ³] {g : Ξ² β†’ Ξ³} (hg : UniformContinuous g) (h : TendstoUniformly F f p) : TendstoUniformly (fun i => g ∘ F i) (g ∘ f) p := fun u hu => h _ (hg hu) #align uniform_continuous.comp_tendsto_uniformly UniformContinuous.comp_tendstoUniformly -/ /- warning: tendsto_uniformly_on_filter.prod_map -> TendstoUniformlyOnFilter.prod_map is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {p : Filter.{u3} ΞΉ} {p' : Filter.{u1} Ξ±} {ΞΉ' : Type.{u4}} {Ξ±' : Type.{u5}} {Ξ²' : Type.{u6}} [_inst_2 : UniformSpace.{u6} Ξ²'] {F' : ΞΉ' -> Ξ±' -> Ξ²'} {f' : Ξ±' -> Ξ²'} {q : Filter.{u4} ΞΉ'} {q' : Filter.{u5} Ξ±'}, (TendstoUniformlyOnFilter.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F f p p') -> (TendstoUniformlyOnFilter.{u5, u6, u4} Ξ±' Ξ²' ΞΉ' _inst_2 F' f' q q') -> (TendstoUniformlyOnFilter.{max u1 u5, max u2 u6, max u3 u4} (Prod.{u1, u5} Ξ± Ξ±') (Prod.{u2, u6} Ξ² Ξ²') (Prod.{u3, u4} ΞΉ ΞΉ') (Prod.uniformSpace.{u2, u6} Ξ² Ξ²' _inst_1 _inst_2) (fun (i : Prod.{u3, u4} ΞΉ ΞΉ') => Prod.map.{u1, u2, u5, u6} Ξ± Ξ² Ξ±' Ξ²' (F (Prod.fst.{u3, u4} ΞΉ ΞΉ' i)) (F' (Prod.snd.{u3, u4} ΞΉ ΞΉ' i))) (Prod.map.{u1, u2, u5, u6} Ξ± Ξ² Ξ±' Ξ²' f f') (Filter.prod.{u3, u4} ΞΉ ΞΉ' p q) (Filter.prod.{u1, u5} Ξ± Ξ±' p' q')) but is expected to have type forall {Ξ± : Type.{u4}} {Ξ² : Type.{u5}} {ΞΉ : Type.{u6}} [_inst_1 : UniformSpace.{u5} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {p : Filter.{u6} ΞΉ} {p' : Filter.{u4} Ξ±} {ΞΉ' : Type.{u3}} {Ξ±' : Type.{u2}} {Ξ²' : Type.{u1}} [_inst_2 : UniformSpace.{u1} Ξ²'] {F' : ΞΉ' -> Ξ±' -> Ξ²'} {f' : Ξ±' -> Ξ²'} {q : Filter.{u3} ΞΉ'} {q' : Filter.{u2} Ξ±'}, (TendstoUniformlyOnFilter.{u4, u5, u6} Ξ± Ξ² ΞΉ _inst_1 F f p p') -> (TendstoUniformlyOnFilter.{u2, u1, u3} Ξ±' Ξ²' ΞΉ' _inst_2 F' f' q q') -> (TendstoUniformlyOnFilter.{max u2 u4, max u1 u5, max u6 u3} (Prod.{u4, u2} Ξ± Ξ±') (Prod.{u5, u1} Ξ² Ξ²') (Prod.{u6, u3} ΞΉ ΞΉ') (instUniformSpaceProd.{u5, u1} Ξ² Ξ²' _inst_1 _inst_2) (fun (i : Prod.{u6, u3} ΞΉ ΞΉ') => Prod.map.{u4, u5, u2, u1} Ξ± Ξ² Ξ±' Ξ²' (F (Prod.fst.{u6, u3} ΞΉ ΞΉ' i)) (F' (Prod.snd.{u6, u3} ΞΉ ΞΉ' i))) (Prod.map.{u4, u5, u2, u1} Ξ± Ξ² Ξ±' Ξ²' f f') (Filter.prod.{u6, u3} ΞΉ ΞΉ' p q) (Filter.prod.{u4, u2} Ξ± Ξ±' p' q')) Case conversion may be inaccurate. Consider using '#align tendsto_uniformly_on_filter.prod_map TendstoUniformlyOnFilter.prod_mapβ‚“'. -/ theorem TendstoUniformlyOnFilter.prod_map {ΞΉ' Ξ±' Ξ²' : Type _} [UniformSpace Ξ²'] {F' : ΞΉ' β†’ Ξ±' β†’ Ξ²'} {f' : Ξ±' β†’ Ξ²'} {q : Filter ΞΉ'} {q' : Filter Ξ±'} (h : TendstoUniformlyOnFilter F f p p') (h' : TendstoUniformlyOnFilter F' f' q q') : TendstoUniformlyOnFilter (fun i : ΞΉ Γ— ΞΉ' => Prod.map (F i.1) (F' i.2)) (Prod.map f f') (p.Prod q) (p'.Prod q') := by intro u hu rw [uniformity_prod_eq_prod, mem_map, mem_prod_iff] at hu obtain ⟨v, hv, w, hw, hvw⟩ := hu apply (tendsto_swap4_prod.eventually ((h v hv).prod_mk (h' w hw))).mono simp only [Prod_map, and_imp, Prod.forall] intro n n' x hxv hxw have hout : ((f x.fst, F n x.fst), (f' x.snd, F' n' x.snd)) ∈ { x : (Ξ² Γ— Ξ²) Γ— Ξ²' Γ— Ξ²' | ((x.fst.fst, x.snd.fst), x.fst.snd, x.snd.snd) ∈ u } := mem_of_mem_of_subset (set.mem_prod.mpr ⟨hxv, hxw⟩) hvw exact hout #align tendsto_uniformly_on_filter.prod_map TendstoUniformlyOnFilter.prod_map /- warning: tendsto_uniformly_on.prod_map -> TendstoUniformlyOn.prod_map is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {s : Set.{u1} Ξ±} {p : Filter.{u3} ΞΉ} {ΞΉ' : Type.{u4}} {Ξ±' : Type.{u5}} {Ξ²' : Type.{u6}} [_inst_2 : UniformSpace.{u6} Ξ²'] {F' : ΞΉ' -> Ξ±' -> Ξ²'} {f' : Ξ±' -> Ξ²'} {p' : Filter.{u4} ΞΉ'} {s' : Set.{u5} Ξ±'}, (TendstoUniformlyOn.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F f p s) -> (TendstoUniformlyOn.{u5, u6, u4} Ξ±' Ξ²' ΞΉ' _inst_2 F' f' p' s') -> (TendstoUniformlyOn.{max u1 u5, max u2 u6, max u3 u4} (Prod.{u1, u5} Ξ± Ξ±') (Prod.{u2, u6} Ξ² Ξ²') (Prod.{u3, u4} ΞΉ ΞΉ') (Prod.uniformSpace.{u2, u6} Ξ² Ξ²' _inst_1 _inst_2) (fun (i : Prod.{u3, u4} ΞΉ ΞΉ') => Prod.map.{u1, u2, u5, u6} Ξ± Ξ² Ξ±' Ξ²' (F (Prod.fst.{u3, u4} ΞΉ ΞΉ' i)) (F' (Prod.snd.{u3, u4} ΞΉ ΞΉ' i))) (Prod.map.{u1, u2, u5, u6} Ξ± Ξ² Ξ±' Ξ²' f f') (Filter.prod.{u3, u4} ΞΉ ΞΉ' p p') (Set.prod.{u1, u5} Ξ± Ξ±' s s')) but is expected to have type forall {Ξ± : Type.{u4}} {Ξ² : Type.{u5}} {ΞΉ : Type.{u6}} [_inst_1 : UniformSpace.{u5} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {s : Set.{u4} Ξ±} {p : Filter.{u6} ΞΉ} {ΞΉ' : Type.{u3}} {Ξ±' : Type.{u2}} {Ξ²' : Type.{u1}} [_inst_2 : UniformSpace.{u1} Ξ²'] {F' : ΞΉ' -> Ξ±' -> Ξ²'} {f' : Ξ±' -> Ξ²'} {p' : Filter.{u3} ΞΉ'} {s' : Set.{u2} Ξ±'}, (TendstoUniformlyOn.{u4, u5, u6} Ξ± Ξ² ΞΉ _inst_1 F f p s) -> (TendstoUniformlyOn.{u2, u1, u3} Ξ±' Ξ²' ΞΉ' _inst_2 F' f' p' s') -> (TendstoUniformlyOn.{max u2 u4, max u1 u5, max u6 u3} (Prod.{u4, u2} Ξ± Ξ±') (Prod.{u5, u1} Ξ² Ξ²') (Prod.{u6, u3} ΞΉ ΞΉ') (instUniformSpaceProd.{u5, u1} Ξ² Ξ²' _inst_1 _inst_2) (fun (i : Prod.{u6, u3} ΞΉ ΞΉ') => Prod.map.{u4, u5, u2, u1} Ξ± Ξ² Ξ±' Ξ²' (F (Prod.fst.{u6, u3} ΞΉ ΞΉ' i)) (F' (Prod.snd.{u6, u3} ΞΉ ΞΉ' i))) (Prod.map.{u4, u5, u2, u1} Ξ± Ξ² Ξ±' Ξ²' f f') (Filter.prod.{u6, u3} ΞΉ ΞΉ' p p') (Set.prod.{u4, u2} Ξ± Ξ±' s s')) Case conversion may be inaccurate. Consider using '#align tendsto_uniformly_on.prod_map TendstoUniformlyOn.prod_mapβ‚“'. -/ /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/ theorem TendstoUniformlyOn.prod_map {ΞΉ' Ξ±' Ξ²' : Type _} [UniformSpace Ξ²'] {F' : ΞΉ' β†’ Ξ±' β†’ Ξ²'} {f' : Ξ±' β†’ Ξ²'} {p' : Filter ΞΉ'} {s' : Set Ξ±'} (h : TendstoUniformlyOn F f p s) (h' : TendstoUniformlyOn F' f' p' s') : TendstoUniformlyOn (fun i : ΞΉ Γ— ΞΉ' => Prod.map (F i.1) (F' i.2)) (Prod.map f f') (p.Prod p') (s Γ—Λ’ s') := by rw [tendstoUniformlyOn_iff_tendstoUniformlyOnFilter] at h h'⊒ simpa only [prod_principal_principal] using h.prod_map h' #align tendsto_uniformly_on.prod_map TendstoUniformlyOn.prod_map /- warning: tendsto_uniformly.prod_map -> TendstoUniformly.prod_map is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {p : Filter.{u3} ΞΉ} {ΞΉ' : Type.{u4}} {Ξ±' : Type.{u5}} {Ξ²' : Type.{u6}} [_inst_2 : UniformSpace.{u6} Ξ²'] {F' : ΞΉ' -> Ξ±' -> Ξ²'} {f' : Ξ±' -> Ξ²'} {p' : Filter.{u4} ΞΉ'}, (TendstoUniformly.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F f p) -> (TendstoUniformly.{u5, u6, u4} Ξ±' Ξ²' ΞΉ' _inst_2 F' f' p') -> (TendstoUniformly.{max u1 u5, max u2 u6, max u3 u4} (Prod.{u1, u5} Ξ± Ξ±') (Prod.{u2, u6} Ξ² Ξ²') (Prod.{u3, u4} ΞΉ ΞΉ') (Prod.uniformSpace.{u2, u6} Ξ² Ξ²' _inst_1 _inst_2) (fun (i : Prod.{u3, u4} ΞΉ ΞΉ') => Prod.map.{u1, u2, u5, u6} Ξ± Ξ² Ξ±' Ξ²' (F (Prod.fst.{u3, u4} ΞΉ ΞΉ' i)) (F' (Prod.snd.{u3, u4} ΞΉ ΞΉ' i))) (Prod.map.{u1, u2, u5, u6} Ξ± Ξ² Ξ±' Ξ²' f f') (Filter.prod.{u3, u4} ΞΉ ΞΉ' p p')) but is expected to have type forall {Ξ± : Type.{u4}} {Ξ² : Type.{u5}} {ΞΉ : Type.{u6}} [_inst_1 : UniformSpace.{u5} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {p : Filter.{u6} ΞΉ} {ΞΉ' : Type.{u3}} {Ξ±' : Type.{u2}} {Ξ²' : Type.{u1}} [_inst_2 : UniformSpace.{u1} Ξ²'] {F' : ΞΉ' -> Ξ±' -> Ξ²'} {f' : Ξ±' -> Ξ²'} {p' : Filter.{u3} ΞΉ'}, (TendstoUniformly.{u4, u5, u6} Ξ± Ξ² ΞΉ _inst_1 F f p) -> (TendstoUniformly.{u2, u1, u3} Ξ±' Ξ²' ΞΉ' _inst_2 F' f' p') -> (TendstoUniformly.{max u2 u4, max u1 u5, max u6 u3} (Prod.{u4, u2} Ξ± Ξ±') (Prod.{u5, u1} Ξ² Ξ²') (Prod.{u6, u3} ΞΉ ΞΉ') (instUniformSpaceProd.{u5, u1} Ξ² Ξ²' _inst_1 _inst_2) (fun (i : Prod.{u6, u3} ΞΉ ΞΉ') => Prod.map.{u4, u5, u2, u1} Ξ± Ξ² Ξ±' Ξ²' (F (Prod.fst.{u6, u3} ΞΉ ΞΉ' i)) (F' (Prod.snd.{u6, u3} ΞΉ ΞΉ' i))) (Prod.map.{u4, u5, u2, u1} Ξ± Ξ² Ξ±' Ξ²' f f') (Filter.prod.{u6, u3} ΞΉ ΞΉ' p p')) Case conversion may be inaccurate. Consider using '#align tendsto_uniformly.prod_map TendstoUniformly.prod_mapβ‚“'. -/ theorem TendstoUniformly.prod_map {ΞΉ' Ξ±' Ξ²' : Type _} [UniformSpace Ξ²'] {F' : ΞΉ' β†’ Ξ±' β†’ Ξ²'} {f' : Ξ±' β†’ Ξ²'} {p' : Filter ΞΉ'} (h : TendstoUniformly F f p) (h' : TendstoUniformly F' f' p') : TendstoUniformly (fun i : ΞΉ Γ— ΞΉ' => Prod.map (F i.1) (F' i.2)) (Prod.map f f') (p.Prod p') := by rw [← tendstoUniformlyOn_univ, ← univ_prod_univ] at * exact h.prod_map h' #align tendsto_uniformly.prod_map TendstoUniformly.prod_map /- warning: tendsto_uniformly_on_filter.prod -> TendstoUniformlyOnFilter.prod is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {p : Filter.{u3} ΞΉ} {p' : Filter.{u1} Ξ±} {ΞΉ' : Type.{u4}} {Ξ²' : Type.{u5}} [_inst_2 : UniformSpace.{u5} Ξ²'] {F' : ΞΉ' -> Ξ± -> Ξ²'} {f' : Ξ± -> Ξ²'} {q : Filter.{u4} ΞΉ'}, (TendstoUniformlyOnFilter.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F f p p') -> (TendstoUniformlyOnFilter.{u1, u5, u4} Ξ± Ξ²' ΞΉ' _inst_2 F' f' q p') -> (TendstoUniformlyOnFilter.{u1, max u2 u5, max u3 u4} Ξ± (Prod.{u2, u5} Ξ² Ξ²') (Prod.{u3, u4} ΞΉ ΞΉ') (Prod.uniformSpace.{u2, u5} Ξ² Ξ²' _inst_1 _inst_2) (fun (i : Prod.{u3, u4} ΞΉ ΞΉ') (a : Ξ±) => Prod.mk.{u2, u5} Ξ² Ξ²' (F (Prod.fst.{u3, u4} ΞΉ ΞΉ' i) a) (F' (Prod.snd.{u3, u4} ΞΉ ΞΉ' i) a)) (fun (a : Ξ±) => Prod.mk.{u2, u5} Ξ² Ξ²' (f a) (f' a)) (Filter.prod.{u3, u4} ΞΉ ΞΉ' p q) p') but is expected to have type forall {Ξ± : Type.{u3}} {Ξ² : Type.{u4}} {ΞΉ : Type.{u5}} [_inst_1 : UniformSpace.{u4} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {p : Filter.{u5} ΞΉ} {p' : Filter.{u3} Ξ±} {ΞΉ' : Type.{u2}} {Ξ²' : Type.{u1}} [_inst_2 : UniformSpace.{u1} Ξ²'] {F' : ΞΉ' -> Ξ± -> Ξ²'} {f' : Ξ± -> Ξ²'} {q : Filter.{u2} ΞΉ'}, (TendstoUniformlyOnFilter.{u3, u4, u5} Ξ± Ξ² ΞΉ _inst_1 F f p p') -> (TendstoUniformlyOnFilter.{u3, u1, u2} Ξ± Ξ²' ΞΉ' _inst_2 F' f' q p') -> (TendstoUniformlyOnFilter.{u3, max u1 u4, max u5 u2} Ξ± (Prod.{u4, u1} Ξ² Ξ²') (Prod.{u5, u2} ΞΉ ΞΉ') (instUniformSpaceProd.{u4, u1} Ξ² Ξ²' _inst_1 _inst_2) (fun (i : Prod.{u5, u2} ΞΉ ΞΉ') (a : Ξ±) => Prod.mk.{u4, u1} Ξ² Ξ²' (F (Prod.fst.{u5, u2} ΞΉ ΞΉ' i) a) (F' (Prod.snd.{u5, u2} ΞΉ ΞΉ' i) a)) (fun (a : Ξ±) => Prod.mk.{u4, u1} Ξ² Ξ²' (f a) (f' a)) (Filter.prod.{u5, u2} ΞΉ ΞΉ' p q) p') Case conversion may be inaccurate. Consider using '#align tendsto_uniformly_on_filter.prod TendstoUniformlyOnFilter.prodβ‚“'. -/ theorem TendstoUniformlyOnFilter.prod {ΞΉ' Ξ²' : Type _} [UniformSpace Ξ²'] {F' : ΞΉ' β†’ Ξ± β†’ Ξ²'} {f' : Ξ± β†’ Ξ²'} {q : Filter ΞΉ'} (h : TendstoUniformlyOnFilter F f p p') (h' : TendstoUniformlyOnFilter F' f' q p') : TendstoUniformlyOnFilter (fun (i : ΞΉ Γ— ΞΉ') a => (F i.1 a, F' i.2 a)) (fun a => (f a, f' a)) (p.Prod q) p' := fun u hu => ((h.Prod_map h') u hu).diag_of_prod_right #align tendsto_uniformly_on_filter.prod TendstoUniformlyOnFilter.prod /- warning: tendsto_uniformly_on.prod -> TendstoUniformlyOn.prod is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {s : Set.{u1} Ξ±} {p : Filter.{u3} ΞΉ} {ΞΉ' : Type.{u4}} {Ξ²' : Type.{u5}} [_inst_2 : UniformSpace.{u5} Ξ²'] {F' : ΞΉ' -> Ξ± -> Ξ²'} {f' : Ξ± -> Ξ²'} {p' : Filter.{u4} ΞΉ'}, (TendstoUniformlyOn.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F f p s) -> (TendstoUniformlyOn.{u1, u5, u4} Ξ± Ξ²' ΞΉ' _inst_2 F' f' p' s) -> (TendstoUniformlyOn.{u1, max u2 u5, max u3 u4} Ξ± (Prod.{u2, u5} Ξ² Ξ²') (Prod.{u3, u4} ΞΉ ΞΉ') (Prod.uniformSpace.{u2, u5} Ξ² Ξ²' _inst_1 _inst_2) (fun (i : Prod.{u3, u4} ΞΉ ΞΉ') (a : Ξ±) => Prod.mk.{u2, u5} Ξ² Ξ²' (F (Prod.fst.{u3, u4} ΞΉ ΞΉ' i) a) (F' (Prod.snd.{u3, u4} ΞΉ ΞΉ' i) a)) (fun (a : Ξ±) => Prod.mk.{u2, u5} Ξ² Ξ²' (f a) (f' a)) (Filter.prod.{u3, u4} ΞΉ ΞΉ' p p') s) but is expected to have type forall {Ξ± : Type.{u3}} {Ξ² : Type.{u4}} {ΞΉ : Type.{u5}} [_inst_1 : UniformSpace.{u4} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {s : Set.{u3} Ξ±} {p : Filter.{u5} ΞΉ} {ΞΉ' : Type.{u2}} {Ξ²' : Type.{u1}} [_inst_2 : UniformSpace.{u1} Ξ²'] {F' : ΞΉ' -> Ξ± -> Ξ²'} {f' : Ξ± -> Ξ²'} {p' : Filter.{u2} ΞΉ'}, (TendstoUniformlyOn.{u3, u4, u5} Ξ± Ξ² ΞΉ _inst_1 F f p s) -> (TendstoUniformlyOn.{u3, u1, u2} Ξ± Ξ²' ΞΉ' _inst_2 F' f' p' s) -> (TendstoUniformlyOn.{u3, max u1 u4, max u5 u2} Ξ± (Prod.{u4, u1} Ξ² Ξ²') (Prod.{u5, u2} ΞΉ ΞΉ') (instUniformSpaceProd.{u4, u1} Ξ² Ξ²' _inst_1 _inst_2) (fun (i : Prod.{u5, u2} ΞΉ ΞΉ') (a : Ξ±) => Prod.mk.{u4, u1} Ξ² Ξ²' (F (Prod.fst.{u5, u2} ΞΉ ΞΉ' i) a) (F' (Prod.snd.{u5, u2} ΞΉ ΞΉ' i) a)) (fun (a : Ξ±) => Prod.mk.{u4, u1} Ξ² Ξ²' (f a) (f' a)) (Filter.prod.{u5, u2} ΞΉ ΞΉ' p p') s) Case conversion may be inaccurate. Consider using '#align tendsto_uniformly_on.prod TendstoUniformlyOn.prodβ‚“'. -/ theorem TendstoUniformlyOn.prod {ΞΉ' Ξ²' : Type _} [UniformSpace Ξ²'] {F' : ΞΉ' β†’ Ξ± β†’ Ξ²'} {f' : Ξ± β†’ Ξ²'} {p' : Filter ΞΉ'} (h : TendstoUniformlyOn F f p s) (h' : TendstoUniformlyOn F' f' p' s) : TendstoUniformlyOn (fun (i : ΞΉ Γ— ΞΉ') a => (F i.1 a, F' i.2 a)) (fun a => (f a, f' a)) (p.Prod p') s := (congr_arg _ s.inter_self).mp ((h.Prod_map h').comp fun a => (a, a)) #align tendsto_uniformly_on.prod TendstoUniformlyOn.prod /- warning: tendsto_uniformly.prod -> TendstoUniformly.prod is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {p : Filter.{u3} ΞΉ} {ΞΉ' : Type.{u4}} {Ξ²' : Type.{u5}} [_inst_2 : UniformSpace.{u5} Ξ²'] {F' : ΞΉ' -> Ξ± -> Ξ²'} {f' : Ξ± -> Ξ²'} {p' : Filter.{u4} ΞΉ'}, (TendstoUniformly.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F f p) -> (TendstoUniformly.{u1, u5, u4} Ξ± Ξ²' ΞΉ' _inst_2 F' f' p') -> (TendstoUniformly.{u1, max u2 u5, max u3 u4} Ξ± (Prod.{u2, u5} Ξ² Ξ²') (Prod.{u3, u4} ΞΉ ΞΉ') (Prod.uniformSpace.{u2, u5} Ξ² Ξ²' _inst_1 _inst_2) (fun (i : Prod.{u3, u4} ΞΉ ΞΉ') (a : Ξ±) => Prod.mk.{u2, u5} Ξ² Ξ²' (F (Prod.fst.{u3, u4} ΞΉ ΞΉ' i) a) (F' (Prod.snd.{u3, u4} ΞΉ ΞΉ' i) a)) (fun (a : Ξ±) => Prod.mk.{u2, u5} Ξ² Ξ²' (f a) (f' a)) (Filter.prod.{u3, u4} ΞΉ ΞΉ' p p')) but is expected to have type forall {Ξ± : Type.{u3}} {Ξ² : Type.{u4}} {ΞΉ : Type.{u5}} [_inst_1 : UniformSpace.{u4} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {p : Filter.{u5} ΞΉ} {ΞΉ' : Type.{u2}} {Ξ²' : Type.{u1}} [_inst_2 : UniformSpace.{u1} Ξ²'] {F' : ΞΉ' -> Ξ± -> Ξ²'} {f' : Ξ± -> Ξ²'} {p' : Filter.{u2} ΞΉ'}, (TendstoUniformly.{u3, u4, u5} Ξ± Ξ² ΞΉ _inst_1 F f p) -> (TendstoUniformly.{u3, u1, u2} Ξ± Ξ²' ΞΉ' _inst_2 F' f' p') -> (TendstoUniformly.{u3, max u1 u4, max u5 u2} Ξ± (Prod.{u4, u1} Ξ² Ξ²') (Prod.{u5, u2} ΞΉ ΞΉ') (instUniformSpaceProd.{u4, u1} Ξ² Ξ²' _inst_1 _inst_2) (fun (i : Prod.{u5, u2} ΞΉ ΞΉ') (a : Ξ±) => Prod.mk.{u4, u1} Ξ² Ξ²' (F (Prod.fst.{u5, u2} ΞΉ ΞΉ' i) a) (F' (Prod.snd.{u5, u2} ΞΉ ΞΉ' i) a)) (fun (a : Ξ±) => Prod.mk.{u4, u1} Ξ² Ξ²' (f a) (f' a)) (Filter.prod.{u5, u2} ΞΉ ΞΉ' p p')) Case conversion may be inaccurate. Consider using '#align tendsto_uniformly.prod TendstoUniformly.prodβ‚“'. -/ theorem TendstoUniformly.prod {ΞΉ' Ξ²' : Type _} [UniformSpace Ξ²'] {F' : ΞΉ' β†’ Ξ± β†’ Ξ²'} {f' : Ξ± β†’ Ξ²'} {p' : Filter ΞΉ'} (h : TendstoUniformly F f p) (h' : TendstoUniformly F' f' p') : TendstoUniformly (fun (i : ΞΉ Γ— ΞΉ') a => (F i.1 a, F' i.2 a)) (fun a => (f a, f' a)) (p.Prod p') := (h.Prod_map h').comp fun a => (a, a) #align tendsto_uniformly.prod TendstoUniformly.prod #print tendsto_prod_filter_iff /- /-- Uniform convergence on a filter `p'` to a constant function is equivalent to convergence in `p Γ—αΆ  p'`. -/ theorem tendsto_prod_filter_iff {c : Ξ²} : Tendsto (β†ΏF) (p Γ—αΆ  p') (𝓝 c) ↔ TendstoUniformlyOnFilter F (fun _ => c) p p' := by simp_rw [tendsto, nhds_eq_comap_uniformity, map_le_iff_le_comap.symm, map_map, le_def, mem_map] exact forallβ‚‚_congr fun u hu => by simpa [eventually_iff] #align tendsto_prod_filter_iff tendsto_prod_filter_iff -/ #print tendsto_prod_principal_iff /- /-- Uniform convergence on a set `s` to a constant function is equivalent to convergence in `p Γ—αΆ  π“Ÿ s`. -/ theorem tendsto_prod_principal_iff {c : Ξ²} : Tendsto (β†ΏF) (p Γ—αΆ  π“Ÿ s) (𝓝 c) ↔ TendstoUniformlyOn F (fun _ => c) p s := by rw [tendstoUniformlyOn_iff_tendstoUniformlyOnFilter] exact tendsto_prod_filter_iff #align tendsto_prod_principal_iff tendsto_prod_principal_iff -/ /- warning: tendsto_prod_top_iff -> tendsto_prod_top_iff is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {p : Filter.{u3} ΞΉ} {c : Ξ²}, Iff (Filter.Tendsto.{max u3 u1, u2} (Prod.{u3, u1} ΞΉ Ξ±) Ξ² (Function.HasUncurry.uncurry.{max u3 u1 u2, max u3 u1, u2} (ΞΉ -> Ξ± -> Ξ²) (Prod.{u3, u1} ΞΉ Ξ±) Ξ² (Function.hasUncurryInduction.{u3, max u1 u2, u1, u2} ΞΉ (Ξ± -> Ξ²) Ξ± Ξ² (Function.hasUncurryBase.{u1, u2} Ξ± Ξ²)) F) (Filter.prod.{u3, u1} ΞΉ Ξ± p (Top.top.{u1} (Filter.{u1} Ξ±) (Filter.hasTop.{u1} Ξ±))) (nhds.{u2} Ξ² (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) c)) (TendstoUniformly.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F (fun (_x : Ξ±) => c) p) but is expected to have type forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {p : Filter.{u3} ΞΉ} {c : Ξ²}, Iff (Filter.Tendsto.{max u1 u3, u2} (Prod.{u3, u1} ΞΉ Ξ±) Ξ² (Function.HasUncurry.uncurry.{max (max u1 u2) u3, max u1 u3, u2} (ΞΉ -> Ξ± -> Ξ²) (Prod.{u3, u1} ΞΉ Ξ±) Ξ² (Function.hasUncurryInduction.{u3, max u1 u2, u1, u2} ΞΉ (Ξ± -> Ξ²) Ξ± Ξ² (Function.hasUncurryBase.{u1, u2} Ξ± Ξ²)) F) (Filter.prod.{u3, u1} ΞΉ Ξ± p (Top.top.{u1} (Filter.{u1} Ξ±) (Filter.instTopFilter.{u1} Ξ±))) (nhds.{u2} Ξ² (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) c)) (TendstoUniformly.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F (fun (_x : Ξ±) => c) p) Case conversion may be inaccurate. Consider using '#align tendsto_prod_top_iff tendsto_prod_top_iffβ‚“'. -/ /-- Uniform convergence to a constant function is equivalent to convergence in `p Γ—αΆ  ⊀`. -/ theorem tendsto_prod_top_iff {c : Ξ²} : Tendsto (β†ΏF) (p Γ—αΆ  ⊀) (𝓝 c) ↔ TendstoUniformly F (fun _ => c) p := by rw [tendstoUniformly_iff_tendstoUniformlyOnFilter] exact tendsto_prod_filter_iff #align tendsto_prod_top_iff tendsto_prod_top_iff #print tendstoUniformlyOn_empty /- /-- Uniform convergence on the empty set is vacuously true -/ theorem tendstoUniformlyOn_empty : TendstoUniformlyOn F f p βˆ… := fun u hu => by simp #align tendsto_uniformly_on_empty tendstoUniformlyOn_empty -/ #print tendstoUniformlyOn_singleton_iff_tendsto /- /-- Uniform convergence on a singleton is equivalent to regular convergence -/ theorem tendstoUniformlyOn_singleton_iff_tendsto : TendstoUniformlyOn F f p {x} ↔ Tendsto (fun n : ΞΉ => F n x) p (𝓝 (f x)) := by simp_rw [tendstoUniformlyOn_iff_tendsto, Uniform.tendsto_nhds_right, tendsto_def] exact forallβ‚‚_congr fun u hu => by simp [mem_prod_principal, preimage] #align tendsto_uniformly_on_singleton_iff_tendsto tendstoUniformlyOn_singleton_iff_tendsto -/ #print Filter.Tendsto.tendstoUniformlyOnFilter_const /- /-- If a sequence `g` converges to some `b`, then the sequence of constant functions `Ξ» n, Ξ» a, g n` converges to the constant function `Ξ» a, b` on any set `s` -/ theorem Filter.Tendsto.tendstoUniformlyOnFilter_const {g : ΞΉ β†’ Ξ²} {b : Ξ²} (hg : Tendsto g p (𝓝 b)) (p' : Filter Ξ±) : TendstoUniformlyOnFilter (fun n : ΞΉ => fun a : Ξ± => g n) (fun a : Ξ± => b) p p' := by rw [tendstoUniformlyOnFilter_iff_tendsto] rw [Uniform.tendsto_nhds_right] at hg exact (hg.comp (tendsto_fst.comp ((@tendsto_id ΞΉ p).Prod_map (@tendsto_id Ξ± p')))).congr fun x => by simp #align filter.tendsto.tendsto_uniformly_on_filter_const Filter.Tendsto.tendstoUniformlyOnFilter_const -/ #print Filter.Tendsto.tendstoUniformlyOn_const /- /-- If a sequence `g` converges to some `b`, then the sequence of constant functions `Ξ» n, Ξ» a, g n` converges to the constant function `Ξ» a, b` on any set `s` -/ theorem Filter.Tendsto.tendstoUniformlyOn_const {g : ΞΉ β†’ Ξ²} {b : Ξ²} (hg : Tendsto g p (𝓝 b)) (s : Set Ξ±) : TendstoUniformlyOn (fun n : ΞΉ => fun a : Ξ± => g n) (fun a : Ξ± => b) p s := tendstoUniformlyOn_iff_tendstoUniformlyOnFilter.mpr (hg.tendstoUniformlyOnFilter_const (π“Ÿ s)) #align filter.tendsto.tendsto_uniformly_on_const Filter.Tendsto.tendstoUniformlyOn_const -/ /- warning: uniform_continuous_on.tendsto_uniformly -> UniformContinuousOn.tendstoUniformly is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {Ξ³ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] [_inst_2 : UniformSpace.{u1} Ξ±] [_inst_3 : UniformSpace.{u3} Ξ³] {x : Ξ±} {U : Set.{u1} Ξ±}, (Membership.Mem.{u1, u1} (Set.{u1} Ξ±) (Filter.{u1} Ξ±) (Filter.hasMem.{u1} Ξ±) U (nhds.{u1} Ξ± (UniformSpace.toTopologicalSpace.{u1} Ξ± _inst_2) x)) -> (forall {F : Ξ± -> Ξ² -> Ξ³}, (UniformContinuousOn.{max u1 u2, u3} (Prod.{u1, u2} Ξ± Ξ²) Ξ³ (Prod.uniformSpace.{u1, u2} Ξ± Ξ² _inst_2 _inst_1) _inst_3 (Function.HasUncurry.uncurry.{max u1 u2 u3, max u1 u2, u3} (Ξ± -> Ξ² -> Ξ³) (Prod.{u1, u2} Ξ± Ξ²) Ξ³ (Function.hasUncurryInduction.{u1, max u2 u3, u2, u3} Ξ± (Ξ² -> Ξ³) Ξ² Ξ³ (Function.hasUncurryBase.{u2, u3} Ξ² Ξ³)) F) (Set.prod.{u1, u2} Ξ± Ξ² U (Set.univ.{u2} Ξ²))) -> (TendstoUniformly.{u2, u3, u1} Ξ² Ξ³ Ξ± _inst_3 F (F x) (nhds.{u1} Ξ± (UniformSpace.toTopologicalSpace.{u1} Ξ± _inst_2) x))) but is expected to have type forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {Ξ³ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] [_inst_2 : UniformSpace.{u1} Ξ±] [_inst_3 : UniformSpace.{u3} Ξ³] {x : Ξ±} {U : Set.{u1} Ξ±}, (Membership.mem.{u1, u1} (Set.{u1} Ξ±) (Filter.{u1} Ξ±) (instMembershipSetFilter.{u1} Ξ±) U (nhds.{u1} Ξ± (UniformSpace.toTopologicalSpace.{u1} Ξ± _inst_2) x)) -> (forall {F : Ξ± -> Ξ² -> Ξ³}, (UniformContinuousOn.{max u1 u2, u3} (Prod.{u1, u2} Ξ± Ξ²) Ξ³ (instUniformSpaceProd.{u1, u2} Ξ± Ξ² _inst_2 _inst_1) _inst_3 (Function.HasUncurry.uncurry.{max (max u1 u2) u3, max u1 u2, u3} (Ξ± -> Ξ² -> Ξ³) (Prod.{u1, u2} Ξ± Ξ²) Ξ³ (Function.hasUncurryInduction.{u1, max u2 u3, u2, u3} Ξ± (Ξ² -> Ξ³) Ξ² Ξ³ (Function.hasUncurryBase.{u2, u3} Ξ² Ξ³)) F) (Set.prod.{u1, u2} Ξ± Ξ² U (Set.univ.{u2} Ξ²))) -> (TendstoUniformly.{u2, u3, u1} Ξ² Ξ³ Ξ± _inst_3 F (F x) (nhds.{u1} Ξ± (UniformSpace.toTopologicalSpace.{u1} Ξ± _inst_2) x))) Case conversion may be inaccurate. Consider using '#align uniform_continuous_on.tendsto_uniformly UniformContinuousOn.tendstoUniformlyβ‚“'. -/ /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/ theorem UniformContinuousOn.tendstoUniformly [UniformSpace Ξ±] [UniformSpace Ξ³] {x : Ξ±} {U : Set Ξ±} (hU : U ∈ 𝓝 x) {F : Ξ± β†’ Ξ² β†’ Ξ³} (hF : UniformContinuousOn (β†ΏF) (U Γ—Λ’ (univ : Set Ξ²))) : TendstoUniformly F (F x) (𝓝 x) := by let Ο† := fun q : Ξ± Γ— Ξ² => ((x, q.2), q) rw [tendstoUniformly_iff_tendsto, show (fun q : Ξ± Γ— Ξ² => (F x q.2, F q.1 q.2)) = Prod.map (β†ΏF) β†ΏF ∘ Ο† by ext <;> simpa] apply hF.comp (tendsto_inf.mpr ⟨_, _⟩) Β· rw [uniformity_prod, tendsto_inf, tendsto_comap_iff, tendsto_comap_iff, show (fun p : (Ξ± Γ— Ξ²) Γ— Ξ± Γ— Ξ² => (p.1.1, p.2.1)) ∘ Ο† = (fun a => (x, a)) ∘ Prod.fst by ext simp, show (fun p : (Ξ± Γ— Ξ²) Γ— Ξ± Γ— Ξ² => (p.1.2, p.2.2)) ∘ Ο† = (fun b => (b, b)) ∘ Prod.snd by ext simp] exact ⟨tendsto_left_nhds_uniformity.comp tendsto_fst, (tendsto_diag_uniformity id ⊀).comp tendsto_top⟩ Β· rw [tendsto_principal] apply mem_of_superset (prod_mem_prod hU (mem_top.mpr rfl)) fun q h => _ simp [h.1, mem_of_mem_nhds hU] #align uniform_continuous_on.tendsto_uniformly UniformContinuousOn.tendstoUniformly #print UniformContinuousβ‚‚.tendstoUniformly /- theorem UniformContinuousβ‚‚.tendstoUniformly [UniformSpace Ξ±] [UniformSpace Ξ³] {f : Ξ± β†’ Ξ² β†’ Ξ³} (h : UniformContinuousβ‚‚ f) {x : Ξ±} : TendstoUniformly f (f x) (𝓝 x) := UniformContinuousOn.tendstoUniformly univ_mem <| by rwa [univ_prod_univ, uniformContinuousOn_univ] #align uniform_continuousβ‚‚.tendsto_uniformly UniformContinuousβ‚‚.tendstoUniformly -/ #print UniformCauchySeqOnFilter /- /-- A sequence is uniformly Cauchy if eventually all of its pairwise differences are uniformly bounded -/ def UniformCauchySeqOnFilter (F : ΞΉ β†’ Ξ± β†’ Ξ²) (p : Filter ΞΉ) (p' : Filter Ξ±) : Prop := βˆ€ u : Set (Ξ² Γ— Ξ²), u ∈ 𝓀 Ξ² β†’ βˆ€αΆ  m : (ΞΉ Γ— ΞΉ) Γ— Ξ± in p Γ—αΆ  p Γ—αΆ  p', (F m.fst.fst m.snd, F m.fst.snd m.snd) ∈ u #align uniform_cauchy_seq_on_filter UniformCauchySeqOnFilter -/ #print UniformCauchySeqOn /- /-- A sequence is uniformly Cauchy if eventually all of its pairwise differences are uniformly bounded -/ def UniformCauchySeqOn (F : ΞΉ β†’ Ξ± β†’ Ξ²) (p : Filter ΞΉ) (s : Set Ξ±) : Prop := βˆ€ u : Set (Ξ² Γ— Ξ²), u ∈ 𝓀 Ξ² β†’ βˆ€αΆ  m : ΞΉ Γ— ΞΉ in p Γ—αΆ  p, βˆ€ x : Ξ±, x ∈ s β†’ (F m.fst x, F m.snd x) ∈ u #align uniform_cauchy_seq_on UniformCauchySeqOn -/ #print uniformCauchySeqOn_iff_uniformCauchySeqOnFilter /- theorem uniformCauchySeqOn_iff_uniformCauchySeqOnFilter : UniformCauchySeqOn F p s ↔ UniformCauchySeqOnFilter F p (π“Ÿ s) := by simp only [UniformCauchySeqOn, UniformCauchySeqOnFilter] refine' forallβ‚‚_congr fun u hu => _ rw [eventually_prod_principal_iff] #align uniform_cauchy_seq_on_iff_uniform_cauchy_seq_on_filter uniformCauchySeqOn_iff_uniformCauchySeqOnFilter -/ #print UniformCauchySeqOn.uniformCauchySeqOnFilter /- theorem UniformCauchySeqOn.uniformCauchySeqOnFilter (hF : UniformCauchySeqOn F p s) : UniformCauchySeqOnFilter F p (π“Ÿ s) := by rwa [← uniformCauchySeqOn_iff_uniformCauchySeqOnFilter] #align uniform_cauchy_seq_on.uniform_cauchy_seq_on_filter UniformCauchySeqOn.uniformCauchySeqOnFilter -/ #print TendstoUniformlyOnFilter.uniformCauchySeqOnFilter /- /-- A sequence that converges uniformly is also uniformly Cauchy -/ theorem TendstoUniformlyOnFilter.uniformCauchySeqOnFilter (hF : TendstoUniformlyOnFilter F f p p') : UniformCauchySeqOnFilter F p p' := by intro u hu rcases comp_symm_of_uniformity hu with ⟨t, ht, htsymm, htmem⟩ have := tendsto_swap4_prod.eventually ((hF t ht).prod_mk (hF t ht)) apply this.diag_of_prod_right.mono simp only [and_imp, Prod.forall] intro n1 n2 x hl hr exact Set.mem_of_mem_of_subset (prod_mk_mem_compRel (htsymm hl) hr) htmem #align tendsto_uniformly_on_filter.uniform_cauchy_seq_on_filter TendstoUniformlyOnFilter.uniformCauchySeqOnFilter -/ #print TendstoUniformlyOn.uniformCauchySeqOn /- /-- A sequence that converges uniformly is also uniformly Cauchy -/ theorem TendstoUniformlyOn.uniformCauchySeqOn (hF : TendstoUniformlyOn F f p s) : UniformCauchySeqOn F p s := uniformCauchySeqOn_iff_uniformCauchySeqOnFilter.mpr hF.TendstoUniformlyOnFilter.UniformCauchySeqOnFilter #align tendsto_uniformly_on.uniform_cauchy_seq_on TendstoUniformlyOn.uniformCauchySeqOn -/ #print UniformCauchySeqOnFilter.tendstoUniformlyOnFilter_of_tendsto /- /-- A uniformly Cauchy sequence converges uniformly to its limit -/ theorem UniformCauchySeqOnFilter.tendstoUniformlyOnFilter_of_tendsto [NeBot p] (hF : UniformCauchySeqOnFilter F p p') (hF' : βˆ€αΆ  x : Ξ± in p', Tendsto (fun n => F n x) p (𝓝 (f x))) : TendstoUniformlyOnFilter F f p p' := by -- Proof idea: |f_n(x) - f(x)| ≀ |f_n(x) - f_m(x)| + |f_m(x) - f(x)|. We choose `n` -- so that |f_n(x) - f_m(x)| is uniformly small across `s` whenever `m β‰₯ n`. Then for -- a fixed `x`, we choose `m` sufficiently large such that |f_m(x) - f(x)| is small. intro u hu rcases comp_symm_of_uniformity hu with ⟨t, ht, htsymm, htmem⟩ -- We will choose n, x, and m simultaneously. n and x come from hF. m comes from hF' -- But we need to promote hF' to the full product filter to use it have hmc : βˆ€αΆ  x : (ΞΉ Γ— ΞΉ) Γ— Ξ± in p Γ—αΆ  p Γ—αΆ  p', tendsto (fun n : ΞΉ => F n x.snd) p (𝓝 (f x.snd)) := by rw [eventually_prod_iff] refine' ⟨fun x => True, by simp, _, hF', by simp⟩ -- To apply filter operations we'll need to do some order manipulation rw [Filter.eventually_swap_iff] have := tendsto_prod_assoc.eventually (tendsto_prod_swap.eventually ((hF t ht).And hmc)) apply this.curry.mono simp only [Equiv.prodAssoc_apply, eventually_and, eventually_const, Prod.snd_swap, Prod.fst_swap, and_imp, Prod.forall] -- Complete the proof intro x n hx hm' refine' Set.mem_of_mem_of_subset (mem_comp_rel.mpr _) htmem rw [Uniform.tendsto_nhds_right] at hm' have := hx.and (hm' ht) obtain ⟨m, hm⟩ := this.exists exact ⟨F m x, ⟨hm.2, htsymm hm.1⟩⟩ #align uniform_cauchy_seq_on_filter.tendsto_uniformly_on_filter_of_tendsto UniformCauchySeqOnFilter.tendstoUniformlyOnFilter_of_tendsto -/ #print UniformCauchySeqOn.tendstoUniformlyOn_of_tendsto /- /-- A uniformly Cauchy sequence converges uniformly to its limit -/ theorem UniformCauchySeqOn.tendstoUniformlyOn_of_tendsto [NeBot p] (hF : UniformCauchySeqOn F p s) (hF' : βˆ€ x : Ξ±, x ∈ s β†’ Tendsto (fun n => F n x) p (𝓝 (f x))) : TendstoUniformlyOn F f p s := tendstoUniformlyOn_iff_tendstoUniformlyOnFilter.mpr (hF.UniformCauchySeqOnFilter.tendstoUniformlyOnFilter_of_tendsto hF') #align uniform_cauchy_seq_on.tendsto_uniformly_on_of_tendsto UniformCauchySeqOn.tendstoUniformlyOn_of_tendsto -/ /- warning: uniform_cauchy_seq_on_filter.mono_left -> UniformCauchySeqOnFilter.mono_left is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {p : Filter.{u3} ΞΉ} {p' : Filter.{u1} Ξ±} {p'' : Filter.{u3} ΞΉ}, (UniformCauchySeqOnFilter.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F p p') -> (LE.le.{u3} (Filter.{u3} ΞΉ) (Preorder.toLE.{u3} (Filter.{u3} ΞΉ) (PartialOrder.toPreorder.{u3} (Filter.{u3} ΞΉ) (Filter.partialOrder.{u3} ΞΉ))) p'' p) -> (UniformCauchySeqOnFilter.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F p'' p') but is expected to have type forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {p : Filter.{u3} ΞΉ} {p' : Filter.{u1} Ξ±} {p'' : Filter.{u3} ΞΉ}, (UniformCauchySeqOnFilter.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F p p') -> (LE.le.{u3} (Filter.{u3} ΞΉ) (Preorder.toLE.{u3} (Filter.{u3} ΞΉ) (PartialOrder.toPreorder.{u3} (Filter.{u3} ΞΉ) (Filter.instPartialOrderFilter.{u3} ΞΉ))) p'' p) -> (UniformCauchySeqOnFilter.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F p'' p') Case conversion may be inaccurate. Consider using '#align uniform_cauchy_seq_on_filter.mono_left UniformCauchySeqOnFilter.mono_leftβ‚“'. -/ theorem UniformCauchySeqOnFilter.mono_left {p'' : Filter ΞΉ} (hf : UniformCauchySeqOnFilter F p p') (hp : p'' ≀ p) : UniformCauchySeqOnFilter F p'' p' := by intro u hu have := (hf u hu).filter_mono (p'.prod_mono_left (Filter.prod_mono hp hp)) exact this.mono (by simp) #align uniform_cauchy_seq_on_filter.mono_left UniformCauchySeqOnFilter.mono_left /- warning: uniform_cauchy_seq_on_filter.mono_right -> UniformCauchySeqOnFilter.mono_right is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {p : Filter.{u3} ΞΉ} {p' : Filter.{u1} Ξ±} {p'' : Filter.{u1} Ξ±}, (UniformCauchySeqOnFilter.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F p p') -> (LE.le.{u1} (Filter.{u1} Ξ±) (Preorder.toLE.{u1} (Filter.{u1} Ξ±) (PartialOrder.toPreorder.{u1} (Filter.{u1} Ξ±) (Filter.partialOrder.{u1} Ξ±))) p'' p') -> (UniformCauchySeqOnFilter.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F p p'') but is expected to have type forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {p : Filter.{u3} ΞΉ} {p' : Filter.{u1} Ξ±} {p'' : Filter.{u1} Ξ±}, (UniformCauchySeqOnFilter.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F p p') -> (LE.le.{u1} (Filter.{u1} Ξ±) (Preorder.toLE.{u1} (Filter.{u1} Ξ±) (PartialOrder.toPreorder.{u1} (Filter.{u1} Ξ±) (Filter.instPartialOrderFilter.{u1} Ξ±))) p'' p') -> (UniformCauchySeqOnFilter.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F p p'') Case conversion may be inaccurate. Consider using '#align uniform_cauchy_seq_on_filter.mono_right UniformCauchySeqOnFilter.mono_rightβ‚“'. -/ theorem UniformCauchySeqOnFilter.mono_right {p'' : Filter Ξ±} (hf : UniformCauchySeqOnFilter F p p') (hp : p'' ≀ p') : UniformCauchySeqOnFilter F p p'' := by intro u hu have := (hf u hu).filter_mono ((p Γ—αΆ  p).prod_mono_right hp) exact this.mono (by simp) #align uniform_cauchy_seq_on_filter.mono_right UniformCauchySeqOnFilter.mono_right #print UniformCauchySeqOn.mono /- theorem UniformCauchySeqOn.mono {s' : Set Ξ±} (hf : UniformCauchySeqOn F p s) (hss' : s' βŠ† s) : UniformCauchySeqOn F p s' := by rw [uniformCauchySeqOn_iff_uniformCauchySeqOnFilter] at hf⊒ exact hf.mono_right (le_principal_iff.mpr <| mem_principal.mpr hss') #align uniform_cauchy_seq_on.mono UniformCauchySeqOn.mono -/ /- warning: uniform_cauchy_seq_on_filter.comp -> UniformCauchySeqOnFilter.comp is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {p : Filter.{u3} ΞΉ} {p' : Filter.{u1} Ξ±} {Ξ³ : Type.{u4}}, (UniformCauchySeqOnFilter.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F p p') -> (forall (g : Ξ³ -> Ξ±), UniformCauchySeqOnFilter.{u4, u2, u3} Ξ³ Ξ² ΞΉ _inst_1 (fun (n : ΞΉ) => Function.comp.{succ u4, succ u1, succ u2} Ξ³ Ξ± Ξ² (F n) g) p (Filter.comap.{u4, u1} Ξ³ Ξ± g p')) but is expected to have type forall {Ξ± : Type.{u2}} {Ξ² : Type.{u3}} {ΞΉ : Type.{u4}} [_inst_1 : UniformSpace.{u3} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {p : Filter.{u4} ΞΉ} {p' : Filter.{u2} Ξ±} {Ξ³ : Type.{u1}}, (UniformCauchySeqOnFilter.{u2, u3, u4} Ξ± Ξ² ΞΉ _inst_1 F p p') -> (forall (g : Ξ³ -> Ξ±), UniformCauchySeqOnFilter.{u1, u3, u4} Ξ³ Ξ² ΞΉ _inst_1 (fun (n : ΞΉ) => Function.comp.{succ u1, succ u2, succ u3} Ξ³ Ξ± Ξ² (F n) g) p (Filter.comap.{u1, u2} Ξ³ Ξ± g p')) Case conversion may be inaccurate. Consider using '#align uniform_cauchy_seq_on_filter.comp UniformCauchySeqOnFilter.compβ‚“'. -/ /-- Composing on the right by a function preserves uniform Cauchy sequences -/ theorem UniformCauchySeqOnFilter.comp {Ξ³ : Type _} (hf : UniformCauchySeqOnFilter F p p') (g : Ξ³ β†’ Ξ±) : UniformCauchySeqOnFilter (fun n => F n ∘ g) p (p'.comap g) := by intro u hu obtain ⟨pa, hpa, pb, hpb, hpapb⟩ := eventually_prod_iff.mp (hf u hu) rw [eventually_prod_iff] refine' ⟨pa, hpa, pb ∘ g, _, fun x hx y hy => hpapb hx hy⟩ exact eventually_comap.mpr (hpb.mono fun x hx y hy => by simp only [hx, hy, Function.comp_apply]) #align uniform_cauchy_seq_on_filter.comp UniformCauchySeqOnFilter.comp /- warning: uniform_cauchy_seq_on.comp -> UniformCauchySeqOn.comp is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {s : Set.{u1} Ξ±} {p : Filter.{u3} ΞΉ} {Ξ³ : Type.{u4}}, (UniformCauchySeqOn.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F p s) -> (forall (g : Ξ³ -> Ξ±), UniformCauchySeqOn.{u4, u2, u3} Ξ³ Ξ² ΞΉ _inst_1 (fun (n : ΞΉ) => Function.comp.{succ u4, succ u1, succ u2} Ξ³ Ξ± Ξ² (F n) g) p (Set.preimage.{u4, u1} Ξ³ Ξ± g s)) but is expected to have type forall {Ξ± : Type.{u2}} {Ξ² : Type.{u3}} {ΞΉ : Type.{u4}} [_inst_1 : UniformSpace.{u3} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {s : Set.{u2} Ξ±} {p : Filter.{u4} ΞΉ} {Ξ³ : Type.{u1}}, (UniformCauchySeqOn.{u2, u3, u4} Ξ± Ξ² ΞΉ _inst_1 F p s) -> (forall (g : Ξ³ -> Ξ±), UniformCauchySeqOn.{u1, u3, u4} Ξ³ Ξ² ΞΉ _inst_1 (fun (n : ΞΉ) => Function.comp.{succ u1, succ u2, succ u3} Ξ³ Ξ± Ξ² (F n) g) p (Set.preimage.{u1, u2} Ξ³ Ξ± g s)) Case conversion may be inaccurate. Consider using '#align uniform_cauchy_seq_on.comp UniformCauchySeqOn.compβ‚“'. -/ /-- Composing on the right by a function preserves uniform Cauchy sequences -/ theorem UniformCauchySeqOn.comp {Ξ³ : Type _} (hf : UniformCauchySeqOn F p s) (g : Ξ³ β†’ Ξ±) : UniformCauchySeqOn (fun n => F n ∘ g) p (g ⁻¹' s) := by rw [uniformCauchySeqOn_iff_uniformCauchySeqOnFilter] at hf⊒ simpa only [UniformCauchySeqOn, comap_principal] using hf.comp g #align uniform_cauchy_seq_on.comp UniformCauchySeqOn.comp #print UniformContinuous.comp_uniformCauchySeqOn /- /-- Composing on the left by a uniformly continuous function preserves uniform Cauchy sequences -/ theorem UniformContinuous.comp_uniformCauchySeqOn [UniformSpace Ξ³] {g : Ξ² β†’ Ξ³} (hg : UniformContinuous g) (hf : UniformCauchySeqOn F p s) : UniformCauchySeqOn (fun n => g ∘ F n) p s := fun u hu => hf _ (hg hu) #align uniform_continuous.comp_uniform_cauchy_seq_on UniformContinuous.comp_uniformCauchySeqOn -/ /- warning: uniform_cauchy_seq_on.prod_map -> UniformCauchySeqOn.prod_map is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {s : Set.{u1} Ξ±} {p : Filter.{u3} ΞΉ} {ΞΉ' : Type.{u4}} {Ξ±' : Type.{u5}} {Ξ²' : Type.{u6}} [_inst_2 : UniformSpace.{u6} Ξ²'] {F' : ΞΉ' -> Ξ±' -> Ξ²'} {p' : Filter.{u4} ΞΉ'} {s' : Set.{u5} Ξ±'}, (UniformCauchySeqOn.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F p s) -> (UniformCauchySeqOn.{u5, u6, u4} Ξ±' Ξ²' ΞΉ' _inst_2 F' p' s') -> (UniformCauchySeqOn.{max u1 u5, max u2 u6, max u3 u4} (Prod.{u1, u5} Ξ± Ξ±') (Prod.{u2, u6} Ξ² Ξ²') (Prod.{u3, u4} ΞΉ ΞΉ') (Prod.uniformSpace.{u2, u6} Ξ² Ξ²' _inst_1 _inst_2) (fun (i : Prod.{u3, u4} ΞΉ ΞΉ') => Prod.map.{u1, u2, u5, u6} Ξ± Ξ² Ξ±' Ξ²' (F (Prod.fst.{u3, u4} ΞΉ ΞΉ' i)) (F' (Prod.snd.{u3, u4} ΞΉ ΞΉ' i))) (Filter.prod.{u3, u4} ΞΉ ΞΉ' p p') (Set.prod.{u1, u5} Ξ± Ξ±' s s')) but is expected to have type forall {Ξ± : Type.{u4}} {Ξ² : Type.{u5}} {ΞΉ : Type.{u6}} [_inst_1 : UniformSpace.{u5} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {s : Set.{u4} Ξ±} {p : Filter.{u6} ΞΉ} {ΞΉ' : Type.{u3}} {Ξ±' : Type.{u2}} {Ξ²' : Type.{u1}} [_inst_2 : UniformSpace.{u1} Ξ²'] {F' : ΞΉ' -> Ξ±' -> Ξ²'} {p' : Filter.{u3} ΞΉ'} {s' : Set.{u2} Ξ±'}, (UniformCauchySeqOn.{u4, u5, u6} Ξ± Ξ² ΞΉ _inst_1 F p s) -> (UniformCauchySeqOn.{u2, u1, u3} Ξ±' Ξ²' ΞΉ' _inst_2 F' p' s') -> (UniformCauchySeqOn.{max u2 u4, max u1 u5, max u6 u3} (Prod.{u4, u2} Ξ± Ξ±') (Prod.{u5, u1} Ξ² Ξ²') (Prod.{u6, u3} ΞΉ ΞΉ') (instUniformSpaceProd.{u5, u1} Ξ² Ξ²' _inst_1 _inst_2) (fun (i : Prod.{u6, u3} ΞΉ ΞΉ') => Prod.map.{u4, u5, u2, u1} Ξ± Ξ² Ξ±' Ξ²' (F (Prod.fst.{u6, u3} ΞΉ ΞΉ' i)) (F' (Prod.snd.{u6, u3} ΞΉ ΞΉ' i))) (Filter.prod.{u6, u3} ΞΉ ΞΉ' p p') (Set.prod.{u4, u2} Ξ± Ξ±' s s')) Case conversion may be inaccurate. Consider using '#align uniform_cauchy_seq_on.prod_map UniformCauchySeqOn.prod_mapβ‚“'. -/ /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/ theorem UniformCauchySeqOn.prod_map {ΞΉ' Ξ±' Ξ²' : Type _} [UniformSpace Ξ²'] {F' : ΞΉ' β†’ Ξ±' β†’ Ξ²'} {p' : Filter ΞΉ'} {s' : Set Ξ±'} (h : UniformCauchySeqOn F p s) (h' : UniformCauchySeqOn F' p' s') : UniformCauchySeqOn (fun i : ΞΉ Γ— ΞΉ' => Prod.map (F i.1) (F' i.2)) (p.Prod p') (s Γ—Λ’ s') := by intro u hu rw [uniformity_prod_eq_prod, mem_map, mem_prod_iff] at hu obtain ⟨v, hv, w, hw, hvw⟩ := hu simp_rw [mem_prod, Prod_map, and_imp, Prod.forall] rw [← Set.image_subset_iff] at hvw apply (tendsto_swap4_prod.eventually ((h v hv).prod_mk (h' w hw))).mono intro x hx a b ha hb refine' hvw ⟨_, mk_mem_prod (hx.1 a ha) (hx.2 b hb), rfl⟩ #align uniform_cauchy_seq_on.prod_map UniformCauchySeqOn.prod_map /- warning: uniform_cauchy_seq_on.prod -> UniformCauchySeqOn.prod is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {s : Set.{u1} Ξ±} {p : Filter.{u3} ΞΉ} {ΞΉ' : Type.{u4}} {Ξ²' : Type.{u5}} [_inst_2 : UniformSpace.{u5} Ξ²'] {F' : ΞΉ' -> Ξ± -> Ξ²'} {p' : Filter.{u4} ΞΉ'}, (UniformCauchySeqOn.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F p s) -> (UniformCauchySeqOn.{u1, u5, u4} Ξ± Ξ²' ΞΉ' _inst_2 F' p' s) -> (UniformCauchySeqOn.{u1, max u2 u5, max u3 u4} Ξ± (Prod.{u2, u5} Ξ² Ξ²') (Prod.{u3, u4} ΞΉ ΞΉ') (Prod.uniformSpace.{u2, u5} Ξ² Ξ²' _inst_1 _inst_2) (fun (i : Prod.{u3, u4} ΞΉ ΞΉ') (a : Ξ±) => Prod.mk.{u2, u5} Ξ² Ξ²' (F (Prod.fst.{u3, u4} ΞΉ ΞΉ' i) a) (F' (Prod.snd.{u3, u4} ΞΉ ΞΉ' i) a)) (Filter.prod.{u3, u4} ΞΉ ΞΉ' p p') s) but is expected to have type forall {Ξ± : Type.{u3}} {Ξ² : Type.{u4}} {ΞΉ : Type.{u5}} [_inst_1 : UniformSpace.{u4} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {s : Set.{u3} Ξ±} {p : Filter.{u5} ΞΉ} {ΞΉ' : Type.{u2}} {Ξ²' : Type.{u1}} [_inst_2 : UniformSpace.{u1} Ξ²'] {F' : ΞΉ' -> Ξ± -> Ξ²'} {p' : Filter.{u2} ΞΉ'}, (UniformCauchySeqOn.{u3, u4, u5} Ξ± Ξ² ΞΉ _inst_1 F p s) -> (UniformCauchySeqOn.{u3, u1, u2} Ξ± Ξ²' ΞΉ' _inst_2 F' p' s) -> (UniformCauchySeqOn.{u3, max u1 u4, max u5 u2} Ξ± (Prod.{u4, u1} Ξ² Ξ²') (Prod.{u5, u2} ΞΉ ΞΉ') (instUniformSpaceProd.{u4, u1} Ξ² Ξ²' _inst_1 _inst_2) (fun (i : Prod.{u5, u2} ΞΉ ΞΉ') (a : Ξ±) => Prod.mk.{u4, u1} Ξ² Ξ²' (F (Prod.fst.{u5, u2} ΞΉ ΞΉ' i) a) (F' (Prod.snd.{u5, u2} ΞΉ ΞΉ' i) a)) (Filter.prod.{u5, u2} ΞΉ ΞΉ' p p') s) Case conversion may be inaccurate. Consider using '#align uniform_cauchy_seq_on.prod UniformCauchySeqOn.prodβ‚“'. -/ theorem UniformCauchySeqOn.prod {ΞΉ' Ξ²' : Type _} [UniformSpace Ξ²'] {F' : ΞΉ' β†’ Ξ± β†’ Ξ²'} {p' : Filter ΞΉ'} (h : UniformCauchySeqOn F p s) (h' : UniformCauchySeqOn F' p' s) : UniformCauchySeqOn (fun (i : ΞΉ Γ— ΞΉ') a => (F i.fst a, F' i.snd a)) (p Γ—αΆ  p') s := (congr_arg _ s.inter_self).mp ((h.Prod_map h').comp fun a => (a, a)) #align uniform_cauchy_seq_on.prod UniformCauchySeqOn.prod /- warning: uniform_cauchy_seq_on.prod' -> UniformCauchySeqOn.prod' is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {s : Set.{u1} Ξ±} {p : Filter.{u3} ΞΉ} {Ξ²' : Type.{u4}} [_inst_2 : UniformSpace.{u4} Ξ²'] {F' : ΞΉ -> Ξ± -> Ξ²'}, (UniformCauchySeqOn.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 F p s) -> (UniformCauchySeqOn.{u1, u4, u3} Ξ± Ξ²' ΞΉ _inst_2 F' p s) -> (UniformCauchySeqOn.{u1, max u2 u4, u3} Ξ± (Prod.{u2, u4} Ξ² Ξ²') ΞΉ (Prod.uniformSpace.{u2, u4} Ξ² Ξ²' _inst_1 _inst_2) (fun (i : ΞΉ) (a : Ξ±) => Prod.mk.{u2, u4} Ξ² Ξ²' (F i a) (F' i a)) p s) but is expected to have type forall {Ξ± : Type.{u2}} {Ξ² : Type.{u3}} {ΞΉ : Type.{u4}} [_inst_1 : UniformSpace.{u3} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {s : Set.{u2} Ξ±} {p : Filter.{u4} ΞΉ} {Ξ²' : Type.{u1}} [_inst_2 : UniformSpace.{u1} Ξ²'] {F' : ΞΉ -> Ξ± -> Ξ²'}, (UniformCauchySeqOn.{u2, u3, u4} Ξ± Ξ² ΞΉ _inst_1 F p s) -> (UniformCauchySeqOn.{u2, u1, u4} Ξ± Ξ²' ΞΉ _inst_2 F' p s) -> (UniformCauchySeqOn.{u2, max u1 u3, u4} Ξ± (Prod.{u3, u1} Ξ² Ξ²') ΞΉ (instUniformSpaceProd.{u3, u1} Ξ² Ξ²' _inst_1 _inst_2) (fun (i : ΞΉ) (a : Ξ±) => Prod.mk.{u3, u1} Ξ² Ξ²' (F i a) (F' i a)) p s) Case conversion may be inaccurate. Consider using '#align uniform_cauchy_seq_on.prod' UniformCauchySeqOn.prod'β‚“'. -/ theorem UniformCauchySeqOn.prod' {Ξ²' : Type _} [UniformSpace Ξ²'] {F' : ΞΉ β†’ Ξ± β†’ Ξ²'} (h : UniformCauchySeqOn F p s) (h' : UniformCauchySeqOn F' p s) : UniformCauchySeqOn (fun (i : ΞΉ) a => (F i a, F' i a)) p s := by intro u hu have hh : tendsto (fun x : ΞΉ => (x, x)) p (p Γ—αΆ  p) := tendsto_diag exact (hh.prod_map hh).Eventually ((h.prod h') u hu) #align uniform_cauchy_seq_on.prod' UniformCauchySeqOn.prod' #print UniformCauchySeqOn.cauchy_map /- /-- If a sequence of functions is uniformly Cauchy on a set, then the values at each point form a Cauchy sequence. -/ theorem UniformCauchySeqOn.cauchy_map [hp : NeBot p] (hf : UniformCauchySeqOn F p s) (hx : x ∈ s) : Cauchy (map (fun i => F i x) p) := by simp only [cauchy_map_iff, hp, true_and_iff] intro u hu rw [mem_map] filter_upwards [hf u hu]with p hp using hp x hx #align uniform_cauchy_seq_on.cauchy_map UniformCauchySeqOn.cauchy_map -/ section SeqTendsto #print tendstoUniformlyOn_of_seq_tendstoUniformlyOn /- theorem tendstoUniformlyOn_of_seq_tendstoUniformlyOn {l : Filter ΞΉ} [l.IsCountablyGenerated] (h : βˆ€ u : β„• β†’ ΞΉ, Tendsto u atTop l β†’ TendstoUniformlyOn (fun n => F (u n)) f atTop s) : TendstoUniformlyOn F f l s := by rw [tendstoUniformlyOn_iff_tendsto, tendsto_iff_seq_tendsto] intro u hu rw [tendsto_prod_iff'] at hu specialize h (fun n => (u n).fst) hu.1 rw [tendstoUniformlyOn_iff_tendsto] at h have : (fun q : ΞΉ Γ— Ξ± => (f q.snd, F q.fst q.snd)) ∘ u = (fun q : β„• Γ— Ξ± => (f q.snd, F ((fun n : β„• => (u n).fst) q.fst) q.snd)) ∘ fun n => (n, (u n).snd) := by ext1 n simp rw [this] refine' tendsto.comp h _ rw [tendsto_prod_iff'] exact ⟨tendsto_id, hu.2⟩ #align tendsto_uniformly_on_of_seq_tendsto_uniformly_on tendstoUniformlyOn_of_seq_tendstoUniformlyOn -/ #print TendstoUniformlyOn.seq_tendstoUniformlyOn /- theorem TendstoUniformlyOn.seq_tendstoUniformlyOn {l : Filter ΞΉ} (h : TendstoUniformlyOn F f l s) (u : β„• β†’ ΞΉ) (hu : Tendsto u atTop l) : TendstoUniformlyOn (fun n => F (u n)) f atTop s := by rw [tendstoUniformlyOn_iff_tendsto] at h⊒ have : (fun q : β„• Γ— Ξ± => (f q.snd, F (u q.fst) q.snd)) = (fun q : ΞΉ Γ— Ξ± => (f q.snd, F q.fst q.snd)) ∘ fun p : β„• Γ— Ξ± => (u p.fst, p.snd) := by ext1 x simp rw [this] refine' h.comp _ rw [tendsto_prod_iff'] exact ⟨hu.comp tendsto_fst, tendsto_snd⟩ #align tendsto_uniformly_on.seq_tendsto_uniformly_on TendstoUniformlyOn.seq_tendstoUniformlyOn -/ #print tendstoUniformlyOn_iff_seq_tendstoUniformlyOn /- theorem tendstoUniformlyOn_iff_seq_tendstoUniformlyOn {l : Filter ΞΉ} [l.IsCountablyGenerated] : TendstoUniformlyOn F f l s ↔ βˆ€ u : β„• β†’ ΞΉ, Tendsto u atTop l β†’ TendstoUniformlyOn (fun n => F (u n)) f atTop s := ⟨TendstoUniformlyOn.seq_tendstoUniformlyOn, tendstoUniformlyOn_of_seq_tendstoUniformlyOn⟩ #align tendsto_uniformly_on_iff_seq_tendsto_uniformly_on tendstoUniformlyOn_iff_seq_tendstoUniformlyOn -/ #print tendstoUniformly_iff_seq_tendstoUniformly /- theorem tendstoUniformly_iff_seq_tendstoUniformly {l : Filter ΞΉ} [l.IsCountablyGenerated] : TendstoUniformly F f l ↔ βˆ€ u : β„• β†’ ΞΉ, Tendsto u atTop l β†’ TendstoUniformly (fun n => F (u n)) f atTop := by simp_rw [← tendstoUniformlyOn_univ] exact tendstoUniformlyOn_iff_seq_tendstoUniformlyOn #align tendsto_uniformly_iff_seq_tendsto_uniformly tendstoUniformly_iff_seq_tendstoUniformly -/ end SeqTendsto variable [TopologicalSpace Ξ±] #print TendstoLocallyUniformlyOn /- /-- A sequence of functions `Fβ‚™` converges locally uniformly on a set `s` to a limiting function `f` with respect to a filter `p` if, for any entourage of the diagonal `u`, for any `x ∈ s`, one has `p`-eventually `(f y, Fβ‚™ y) ∈ u` for all `y` in a neighborhood of `x` in `s`. -/ def TendstoLocallyUniformlyOn (F : ΞΉ β†’ Ξ± β†’ Ξ²) (f : Ξ± β†’ Ξ²) (p : Filter ΞΉ) (s : Set Ξ±) := βˆ€ u ∈ 𝓀 Ξ², βˆ€ x ∈ s, βˆƒ t ∈ 𝓝[s] x, βˆ€αΆ  n in p, βˆ€ y ∈ t, (f y, F n y) ∈ u #align tendsto_locally_uniformly_on TendstoLocallyUniformlyOn -/ #print TendstoLocallyUniformly /- /-- A sequence of functions `Fβ‚™` converges locally uniformly to a limiting function `f` with respect to a filter `p` if, for any entourage of the diagonal `u`, for any `x`, one has `p`-eventually `(f y, Fβ‚™ y) ∈ u` for all `y` in a neighborhood of `x`. -/ def TendstoLocallyUniformly (F : ΞΉ β†’ Ξ± β†’ Ξ²) (f : Ξ± β†’ Ξ²) (p : Filter ΞΉ) := βˆ€ u ∈ 𝓀 Ξ², βˆ€ x : Ξ±, βˆƒ t ∈ 𝓝 x, βˆ€αΆ  n in p, βˆ€ y ∈ t, (f y, F n y) ∈ u #align tendsto_locally_uniformly TendstoLocallyUniformly -/ #print tendstoLocallyUniformlyOn_iff_tendstoLocallyUniformly_comp_coe /- theorem tendstoLocallyUniformlyOn_iff_tendstoLocallyUniformly_comp_coe : TendstoLocallyUniformlyOn F f p s ↔ TendstoLocallyUniformly (fun i (x : s) => F i x) (f ∘ coe) p := by refine' forallβ‚‚_congr fun V hV => _ simp only [exists_prop, Function.comp_apply, SetCoe.forall, Subtype.coe_mk] refine' forallβ‚‚_congr fun x hx => ⟨_, _⟩ Β· rintro ⟨t, ht₁, htβ‚‚βŸ© obtain ⟨u, hu₁, huβ‚‚βŸ© := mem_nhds_within_iff_exists_mem_nhds_inter.mp ht₁ exact ⟨coe ⁻¹' u, (mem_nhds_subtype _ _ _).mpr ⟨u, hu₁, rfl.subset⟩, htβ‚‚.mono fun i hi y hy₁ hyβ‚‚ => hi y (huβ‚‚ ⟨hyβ‚‚, hyβ‚βŸ©)⟩ Β· rintro ⟨t, ht₁, htβ‚‚βŸ© obtain ⟨u, hu₁, huβ‚‚βŸ© := (mem_nhds_subtype _ _ _).mp ht₁ exact ⟨u ∩ s, mem_nhds_within_iff_exists_mem_nhds_inter.mpr ⟨u, hu₁, rfl.subset⟩, htβ‚‚.mono fun i hi y hy => hi y hy.2 (huβ‚‚ (by simp [hy.1]))⟩ #align tendsto_locally_uniformly_on_iff_tendsto_locally_uniformly_comp_coe tendstoLocallyUniformlyOn_iff_tendstoLocallyUniformly_comp_coe -/ #print tendstoLocallyUniformly_iff_forall_tendsto /- theorem tendstoLocallyUniformly_iff_forall_tendsto : TendstoLocallyUniformly F f p ↔ βˆ€ x, Tendsto (fun y : ΞΉ Γ— Ξ± => (f y.2, F y.1 y.2)) (p Γ—αΆ  𝓝 x) (𝓀 Ξ²) := by simp only [TendstoLocallyUniformly, Filter.forall_in_swap, tendsto_def, mem_prod_iff, Set.prod_subset_iff] refine' forall₃_congr fun x u hu => ⟨_, _⟩ Β· rintro ⟨n, hn, hp⟩ exact ⟨_, hp, n, hn, fun i hi a ha => hi a ha⟩ Β· rintro ⟨I, hI, n, hn, hu⟩ exact ⟨n, hn, by filter_upwards [hI]using hu⟩ #align tendsto_locally_uniformly_iff_forall_tendsto tendstoLocallyUniformly_iff_forall_tendsto -/ #print TendstoUniformlyOn.tendstoLocallyUniformlyOn /- protected theorem TendstoUniformlyOn.tendstoLocallyUniformlyOn (h : TendstoUniformlyOn F f p s) : TendstoLocallyUniformlyOn F f p s := fun u hu x hx => ⟨s, self_mem_nhdsWithin, by simpa using h u hu⟩ #align tendsto_uniformly_on.tendsto_locally_uniformly_on TendstoUniformlyOn.tendstoLocallyUniformlyOn -/ #print TendstoUniformly.tendstoLocallyUniformly /- protected theorem TendstoUniformly.tendstoLocallyUniformly (h : TendstoUniformly F f p) : TendstoLocallyUniformly F f p := fun u hu x => ⟨univ, univ_mem, by simpa using h u hu⟩ #align tendsto_uniformly.tendsto_locally_uniformly TendstoUniformly.tendstoLocallyUniformly -/ #print TendstoLocallyUniformlyOn.mono /- theorem TendstoLocallyUniformlyOn.mono (h : TendstoLocallyUniformlyOn F f p s) (h' : s' βŠ† s) : TendstoLocallyUniformlyOn F f p s' := by intro u hu x hx rcases h u hu x (h' hx) with ⟨t, ht, H⟩ exact ⟨t, nhdsWithin_mono x h' ht, H.mono fun n => id⟩ #align tendsto_locally_uniformly_on.mono TendstoLocallyUniformlyOn.mono -/ /- warning: tendsto_locally_uniformly_on_Union -> tendstoLocallyUniformlyOn_unionα΅’ is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {Ξ³ : Type.{u3}} {ΞΉ : Type.{u4}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {p : Filter.{u4} ΞΉ} [_inst_2 : TopologicalSpace.{u1} Ξ±] {S : Ξ³ -> (Set.{u1} Ξ±)}, (forall (i : Ξ³), IsOpen.{u1} Ξ± _inst_2 (S i)) -> (forall (i : Ξ³), TendstoLocallyUniformlyOn.{u1, u2, u4} Ξ± Ξ² ΞΉ _inst_1 _inst_2 F f p (S i)) -> (TendstoLocallyUniformlyOn.{u1, u2, u4} Ξ± Ξ² ΞΉ _inst_1 _inst_2 F f p (Set.unionα΅’.{u1, succ u3} Ξ± Ξ³ (fun (i : Ξ³) => S i))) but is expected to have type forall {Ξ± : Type.{u2}} {Ξ² : Type.{u3}} {Ξ³ : Type.{u4}} [ΞΉ : UniformSpace.{u3} Ξ²] {_inst_1 : Ξ³ -> Ξ± -> Ξ²} {F : Ξ± -> Ξ²} {f : Filter.{u4} Ξ³} [p : TopologicalSpace.{u2} Ξ±] {_inst_2 : Sort.{u1}} {S : _inst_2 -> (Set.{u2} Ξ±)}, (forall (i : _inst_2), IsOpen.{u2} Ξ± p (S i)) -> (forall (i : _inst_2), TendstoLocallyUniformlyOn.{u2, u3, u4} Ξ± Ξ² Ξ³ ΞΉ p _inst_1 F f (S i)) -> (TendstoLocallyUniformlyOn.{u2, u3, u4} Ξ± Ξ² Ξ³ ΞΉ p _inst_1 F f (Set.unionα΅’.{u2, u1} Ξ± _inst_2 (fun (i : _inst_2) => S i))) Case conversion may be inaccurate. Consider using '#align tendsto_locally_uniformly_on_Union tendstoLocallyUniformlyOn_unionα΅’β‚“'. -/ theorem tendstoLocallyUniformlyOn_unionα΅’ {S : Ξ³ β†’ Set Ξ±} (hS : βˆ€ i, IsOpen (S i)) (h : βˆ€ i, TendstoLocallyUniformlyOn F f p (S i)) : TendstoLocallyUniformlyOn F f p (⋃ i, S i) := by rintro v hv x ⟨_, ⟨i, rfl⟩, hi : x ∈ S i⟩ obtain ⟨t, ht, ht'⟩ := h i v hv x hi refine' ⟨t, _, ht'⟩ rw [(hS _).nhdsWithin_eq hi] at ht exact mem_nhdsWithin_of_mem_nhds ht #align tendsto_locally_uniformly_on_Union tendstoLocallyUniformlyOn_unionα΅’ #print tendstoLocallyUniformlyOn_bunionα΅’ /- theorem tendstoLocallyUniformlyOn_bunionα΅’ {s : Set Ξ³} {S : Ξ³ β†’ Set Ξ±} (hS : βˆ€ i ∈ s, IsOpen (S i)) (h : βˆ€ i ∈ s, TendstoLocallyUniformlyOn F f p (S i)) : TendstoLocallyUniformlyOn F f p (⋃ i ∈ s, S i) := by rw [bUnion_eq_Union] exact tendstoLocallyUniformlyOn_unionα΅’ (fun i => hS _ i.2) fun i => h _ i.2 #align tendsto_locally_uniformly_on_bUnion tendstoLocallyUniformlyOn_bunionα΅’ -/ #print tendstoLocallyUniformlyOn_unionβ‚› /- theorem tendstoLocallyUniformlyOn_unionβ‚› (S : Set (Set Ξ±)) (hS : βˆ€ s ∈ S, IsOpen s) (h : βˆ€ s ∈ S, TendstoLocallyUniformlyOn F f p s) : TendstoLocallyUniformlyOn F f p (⋃₀ S) := by rw [sUnion_eq_bUnion] exact tendstoLocallyUniformlyOn_bunionα΅’ hS h #align tendsto_locally_uniformly_on_sUnion tendstoLocallyUniformlyOn_unionβ‚› -/ /- warning: tendsto_locally_uniformly_on.union -> TendstoLocallyUniformlyOn.union is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {p : Filter.{u3} ΞΉ} [_inst_2 : TopologicalSpace.{u1} Ξ±] {s₁ : Set.{u1} Ξ±} {sβ‚‚ : Set.{u1} Ξ±}, (IsOpen.{u1} Ξ± _inst_2 s₁) -> (IsOpen.{u1} Ξ± _inst_2 sβ‚‚) -> (TendstoLocallyUniformlyOn.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 _inst_2 F f p s₁) -> (TendstoLocallyUniformlyOn.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 _inst_2 F f p sβ‚‚) -> (TendstoLocallyUniformlyOn.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 _inst_2 F f p (Union.union.{u1} (Set.{u1} Ξ±) (Set.hasUnion.{u1} Ξ±) s₁ sβ‚‚)) but is expected to have type forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {p : Filter.{u3} ΞΉ} [_inst_2 : TopologicalSpace.{u1} Ξ±] {s₁ : Set.{u1} Ξ±} {sβ‚‚ : Set.{u1} Ξ±}, (IsOpen.{u1} Ξ± _inst_2 s₁) -> (IsOpen.{u1} Ξ± _inst_2 sβ‚‚) -> (TendstoLocallyUniformlyOn.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 _inst_2 F f p s₁) -> (TendstoLocallyUniformlyOn.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 _inst_2 F f p sβ‚‚) -> (TendstoLocallyUniformlyOn.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 _inst_2 F f p (Union.union.{u1} (Set.{u1} Ξ±) (Set.instUnionSet.{u1} Ξ±) s₁ sβ‚‚)) Case conversion may be inaccurate. Consider using '#align tendsto_locally_uniformly_on.union TendstoLocallyUniformlyOn.unionβ‚“'. -/ theorem TendstoLocallyUniformlyOn.union {s₁ sβ‚‚ : Set Ξ±} (hs₁ : IsOpen s₁) (hsβ‚‚ : IsOpen sβ‚‚) (h₁ : TendstoLocallyUniformlyOn F f p s₁) (hβ‚‚ : TendstoLocallyUniformlyOn F f p sβ‚‚) : TendstoLocallyUniformlyOn F f p (s₁ βˆͺ sβ‚‚) := by rw [← sUnion_pair] refine' tendstoLocallyUniformlyOn_unionβ‚› _ _ _ <;> simp [*] #align tendsto_locally_uniformly_on.union TendstoLocallyUniformlyOn.union #print tendstoLocallyUniformlyOn_univ /- theorem tendstoLocallyUniformlyOn_univ : TendstoLocallyUniformlyOn F f p univ ↔ TendstoLocallyUniformly F f p := by simp [TendstoLocallyUniformlyOn, TendstoLocallyUniformly, nhdsWithin_univ] #align tendsto_locally_uniformly_on_univ tendstoLocallyUniformlyOn_univ -/ #print TendstoLocallyUniformly.tendstoLocallyUniformlyOn /- protected theorem TendstoLocallyUniformly.tendstoLocallyUniformlyOn (h : TendstoLocallyUniformly F f p) : TendstoLocallyUniformlyOn F f p s := (tendstoLocallyUniformlyOn_univ.mpr h).mono (subset_univ _) #align tendsto_locally_uniformly.tendsto_locally_uniformly_on TendstoLocallyUniformly.tendstoLocallyUniformlyOn -/ #print tendstoLocallyUniformly_iff_tendstoUniformly_of_compactSpace /- /-- On a compact space, locally uniform convergence is just uniform convergence. -/ theorem tendstoLocallyUniformly_iff_tendstoUniformly_of_compactSpace [CompactSpace Ξ±] : TendstoLocallyUniformly F f p ↔ TendstoUniformly F f p := by refine' ⟨fun h V hV => _, TendstoUniformly.tendstoLocallyUniformly⟩ choose U hU using h V hV obtain ⟨t, ht⟩ := is_compact_univ.elim_nhds_subcover' (fun k hk => U k) fun k hk => (hU k).1 replace hU := fun x : t => (hU x).2 rw [← eventually_all] at hU refine' hU.mono fun i hi x => _ specialize ht (mem_univ x) simp only [exists_prop, mem_Union, SetCoe.exists, exists_and_right, Subtype.coe_mk] at ht obtain ⟨y, ⟨hy₁, hyβ‚‚βŸ©, hyβ‚ƒβŸ© := ht exact hi ⟨⟨y, hyβ‚βŸ©, hyβ‚‚βŸ© x hy₃ #align tendsto_locally_uniformly_iff_tendsto_uniformly_of_compact_space tendstoLocallyUniformly_iff_tendstoUniformly_of_compactSpace -/ #print tendstoLocallyUniformlyOn_iff_tendstoUniformlyOn_of_compact /- /-- For a compact set `s`, locally uniform convergence on `s` is just uniform convergence on `s`. -/ theorem tendstoLocallyUniformlyOn_iff_tendstoUniformlyOn_of_compact (hs : IsCompact s) : TendstoLocallyUniformlyOn F f p s ↔ TendstoUniformlyOn F f p s := by haveI : CompactSpace s := is_compact_iff_compact_space.mp hs refine' ⟨fun h => _, TendstoUniformlyOn.tendstoLocallyUniformlyOn⟩ rwa [tendstoLocallyUniformlyOn_iff_tendstoLocallyUniformly_comp_coe, tendstoLocallyUniformly_iff_tendstoUniformly_of_compactSpace, ← tendstoUniformlyOn_iff_tendstoUniformly_comp_coe] at h #align tendsto_locally_uniformly_on_iff_tendsto_uniformly_on_of_compact tendstoLocallyUniformlyOn_iff_tendstoUniformlyOn_of_compact -/ #print TendstoLocallyUniformlyOn.comp /- theorem TendstoLocallyUniformlyOn.comp [TopologicalSpace Ξ³] {t : Set Ξ³} (h : TendstoLocallyUniformlyOn F f p s) (g : Ξ³ β†’ Ξ±) (hg : MapsTo g t s) (cg : ContinuousOn g t) : TendstoLocallyUniformlyOn (fun n => F n ∘ g) (f ∘ g) p t := by intro u hu x hx rcases h u hu (g x) (hg hx) with ⟨a, ha, H⟩ have : g ⁻¹' a ∈ 𝓝[t] x := (cg x hx).preimage_mem_nhds_within' (nhdsWithin_mono (g x) hg.image_subset ha) exact ⟨g ⁻¹' a, this, H.mono fun n hn y hy => hn _ hy⟩ #align tendsto_locally_uniformly_on.comp TendstoLocallyUniformlyOn.comp -/ #print TendstoLocallyUniformly.comp /- theorem TendstoLocallyUniformly.comp [TopologicalSpace Ξ³] (h : TendstoLocallyUniformly F f p) (g : Ξ³ β†’ Ξ±) (cg : Continuous g) : TendstoLocallyUniformly (fun n => F n ∘ g) (f ∘ g) p := by rw [← tendstoLocallyUniformlyOn_univ] at h⊒ rw [continuous_iff_continuousOn_univ] at cg exact h.comp _ (maps_to_univ _ _) cg #align tendsto_locally_uniformly.comp TendstoLocallyUniformly.comp -/ /- warning: tendsto_locally_uniformly_on_tfae -> tendstoLocallyUniformlyOn_TFAE is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {s : Set.{u1} Ξ±} [_inst_2 : TopologicalSpace.{u1} Ξ±] [_inst_3 : LocallyCompactSpace.{u1} Ξ± _inst_2] (G : ΞΉ -> Ξ± -> Ξ²) (g : Ξ± -> Ξ²) (p : Filter.{u3} ΞΉ), (IsOpen.{u1} Ξ± _inst_2 s) -> (List.TFAE (List.cons.{0} Prop (TendstoLocallyUniformlyOn.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 _inst_2 G g p s) (List.cons.{0} Prop (forall (K : Set.{u1} Ξ±), (HasSubset.Subset.{u1} (Set.{u1} Ξ±) (Set.hasSubset.{u1} Ξ±) K s) -> (IsCompact.{u1} Ξ± _inst_2 K) -> (TendstoUniformlyOn.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 G g p K)) (List.cons.{0} Prop (forall (x : Ξ±), (Membership.Mem.{u1, u1} Ξ± (Set.{u1} Ξ±) (Set.hasMem.{u1} Ξ±) x s) -> (Exists.{succ u1} (Set.{u1} Ξ±) (fun (v : Set.{u1} Ξ±) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} Ξ±) (Filter.{u1} Ξ±) (Filter.hasMem.{u1} Ξ±) v (nhdsWithin.{u1} Ξ± _inst_2 x s)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} Ξ±) (Filter.{u1} Ξ±) (Filter.hasMem.{u1} Ξ±) v (nhdsWithin.{u1} Ξ± _inst_2 x s)) => TendstoUniformlyOn.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 G g p v)))) (List.nil.{0} Prop))))) but is expected to have type forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {s : Set.{u1} Ξ±} [_inst_2 : TopologicalSpace.{u1} Ξ±] [_inst_3 : LocallyCompactSpace.{u1} Ξ± _inst_2] (G : ΞΉ -> Ξ± -> Ξ²) (g : Ξ± -> Ξ²) (p : Filter.{u3} ΞΉ), (IsOpen.{u1} Ξ± _inst_2 s) -> (List.TFAE (List.cons.{0} Prop (TendstoLocallyUniformlyOn.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 _inst_2 G g p s) (List.cons.{0} Prop (forall (K : Set.{u1} Ξ±), (HasSubset.Subset.{u1} (Set.{u1} Ξ±) (Set.instHasSubsetSet.{u1} Ξ±) K s) -> (IsCompact.{u1} Ξ± _inst_2 K) -> (TendstoUniformlyOn.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 G g p K)) (List.cons.{0} Prop (forall (x : Ξ±), (Membership.mem.{u1, u1} Ξ± (Set.{u1} Ξ±) (Set.instMembershipSet.{u1} Ξ±) x s) -> (Exists.{succ u1} (Set.{u1} Ξ±) (fun (v : Set.{u1} Ξ±) => And (Membership.mem.{u1, u1} (Set.{u1} Ξ±) (Filter.{u1} Ξ±) (instMembershipSetFilter.{u1} Ξ±) v (nhdsWithin.{u1} Ξ± _inst_2 x s)) (TendstoUniformlyOn.{u1, u2, u3} Ξ± Ξ² ΞΉ _inst_1 G g p v)))) (List.nil.{0} Prop))))) Case conversion may be inaccurate. Consider using '#align tendsto_locally_uniformly_on_tfae tendstoLocallyUniformlyOn_TFAEβ‚“'. -/ /- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (K Β«expr βŠ† Β» s) -/ theorem tendstoLocallyUniformlyOn_TFAE [LocallyCompactSpace Ξ±] (G : ΞΉ β†’ Ξ± β†’ Ξ²) (g : Ξ± β†’ Ξ²) (p : Filter ΞΉ) (hs : IsOpen s) : TFAE [TendstoLocallyUniformlyOn G g p s, βˆ€ (K) (_ : K βŠ† s), IsCompact K β†’ TendstoUniformlyOn G g p K, βˆ€ x ∈ s, βˆƒ v ∈ 𝓝[s] x, TendstoUniformlyOn G g p v] := by tfae_have 1 β†’ 2 Β· rintro h K hK1 hK2 exact (tendstoLocallyUniformlyOn_iff_tendstoUniformlyOn_of_compact hK2).mp (h.mono hK1) tfae_have 2 β†’ 3 Β· rintro h x hx obtain ⟨K, ⟨hK1, hK2⟩, hK3⟩ := (compact_basis_nhds x).mem_iff.mp (hs.mem_nhds hx) refine' ⟨K, nhdsWithin_le_nhds hK1, h K hK3 hK2⟩ tfae_have 3 β†’ 1 Β· rintro h u hu x hx obtain ⟨v, hv1, hv2⟩ := h x hx exact ⟨v, hv1, hv2 u hu⟩ tfae_finish #align tendsto_locally_uniformly_on_tfae tendstoLocallyUniformlyOn_TFAE /- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (K Β«expr βŠ† Β» s) -/ #print tendstoLocallyUniformlyOn_iff_forall_isCompact /- theorem tendstoLocallyUniformlyOn_iff_forall_isCompact [LocallyCompactSpace Ξ±] (hs : IsOpen s) : TendstoLocallyUniformlyOn F f p s ↔ βˆ€ (K) (_ : K βŠ† s), IsCompact K β†’ TendstoUniformlyOn F f p K := (tendstoLocallyUniformlyOn_TFAE F f p hs).out 0 1 #align tendsto_locally_uniformly_on_iff_forall_is_compact tendstoLocallyUniformlyOn_iff_forall_isCompact -/ #print tendstoLocallyUniformlyOn_iff_filter /- theorem tendstoLocallyUniformlyOn_iff_filter : TendstoLocallyUniformlyOn F f p s ↔ βˆ€ x ∈ s, TendstoUniformlyOnFilter F f p (𝓝[s] x) := by simp only [TendstoUniformlyOnFilter, eventually_prod_iff] constructor Β· rintro h x hx u hu obtain ⟨s, hs1, hs2⟩ := h u hu x hx exact ⟨_, hs2, _, eventually_of_mem hs1 fun x => id, fun i hi y hy => hi y hy⟩ Β· rintro h u hu x hx obtain ⟨pa, hpa, pb, hpb, h⟩ := h x hx u hu refine' ⟨pb, hpb, eventually_of_mem hpa fun i hi y hy => h hi hy⟩ #align tendsto_locally_uniformly_on_iff_filter tendstoLocallyUniformlyOn_iff_filter -/ #print tendstoLocallyUniformly_iff_filter /- theorem tendstoLocallyUniformly_iff_filter : TendstoLocallyUniformly F f p ↔ βˆ€ x, TendstoUniformlyOnFilter F f p (𝓝 x) := by simpa [← tendstoLocallyUniformlyOn_univ, ← nhdsWithin_univ] using @tendstoLocallyUniformlyOn_iff_filter _ _ _ _ F f univ p _ #align tendsto_locally_uniformly_iff_filter tendstoLocallyUniformly_iff_filter -/ #print TendstoLocallyUniformlyOn.tendsto_at /- theorem TendstoLocallyUniformlyOn.tendsto_at (hf : TendstoLocallyUniformlyOn F f p s) {a : Ξ±} (ha : a ∈ s) : Tendsto (fun i => F i a) p (𝓝 (f a)) := by refine' ((tendsto_locally_uniformly_on_iff_filter.mp hf) a ha).tendsto_at _ simpa only [Filter.principal_singleton] using pure_le_nhdsWithin ha #align tendsto_locally_uniformly_on.tendsto_at TendstoLocallyUniformlyOn.tendsto_at -/ #print TendstoLocallyUniformlyOn.unique /- theorem TendstoLocallyUniformlyOn.unique [p.ne_bot] [T2Space Ξ²] {g : Ξ± β†’ Ξ²} (hf : TendstoLocallyUniformlyOn F f p s) (hg : TendstoLocallyUniformlyOn F g p s) : s.EqOn f g := fun a ha => tendsto_nhds_unique (hf.tendsto_at ha) (hg.tendsto_at ha) #align tendsto_locally_uniformly_on.unique TendstoLocallyUniformlyOn.unique -/ #print TendstoLocallyUniformlyOn.congr /- theorem TendstoLocallyUniformlyOn.congr {G : ΞΉ β†’ Ξ± β†’ Ξ²} (hf : TendstoLocallyUniformlyOn F f p s) (hg : βˆ€ n, s.EqOn (F n) (G n)) : TendstoLocallyUniformlyOn G f p s := by rintro u hu x hx obtain ⟨t, ht, h⟩ := hf u hu x hx refine' ⟨s ∩ t, inter_mem self_mem_nhdsWithin ht, _⟩ filter_upwards [h]with i hi y hy using hg i hy.1 β–Έ hi y hy.2 #align tendsto_locally_uniformly_on.congr TendstoLocallyUniformlyOn.congr -/ #print TendstoLocallyUniformlyOn.congr_right /- theorem TendstoLocallyUniformlyOn.congr_right {g : Ξ± β†’ Ξ²} (hf : TendstoLocallyUniformlyOn F f p s) (hg : s.EqOn f g) : TendstoLocallyUniformlyOn F g p s := by rintro u hu x hx obtain ⟨t, ht, h⟩ := hf u hu x hx refine' ⟨s ∩ t, inter_mem self_mem_nhdsWithin ht, _⟩ filter_upwards [h]with i hi y hy using hg hy.1 β–Έ hi y hy.2 #align tendsto_locally_uniformly_on.congr_right TendstoLocallyUniformlyOn.congr_right -/ /-! ### Uniform approximation In this section, we give lemmas ensuring that a function is continuous if it can be approximated uniformly by continuous functions. We give various versions, within a set or the whole space, at a single point or at all points, with locally uniform approximation or uniform approximation. All the statements are derived from a statement about locally uniform approximation within a set at a point, called `continuous_within_at_of_locally_uniform_approx_of_continuous_within_at`. -/ /- warning: continuous_within_at_of_locally_uniform_approx_of_continuous_within_at -> continuousWithinAt_of_locally_uniform_approx_of_continuousWithinAt is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} [_inst_1 : UniformSpace.{u2} Ξ²] {f : Ξ± -> Ξ²} {s : Set.{u1} Ξ±} {x : Ξ±} [_inst_2 : TopologicalSpace.{u1} Ξ±], (Membership.Mem.{u1, u1} Ξ± (Set.{u1} Ξ±) (Set.hasMem.{u1} Ξ±) x s) -> (forall (u : Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)), (Membership.Mem.{u2, u2} (Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Filter.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Filter.hasMem.{u2} (Prod.{u2, u2} Ξ² Ξ²)) u (uniformity.{u2} Ξ² _inst_1)) -> (Exists.{succ u1} (Set.{u1} Ξ±) (fun (t : Set.{u1} Ξ±) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} Ξ±) (Filter.{u1} Ξ±) (Filter.hasMem.{u1} Ξ±) t (nhdsWithin.{u1} Ξ± _inst_2 x s)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} Ξ±) (Filter.{u1} Ξ±) (Filter.hasMem.{u1} Ξ±) t (nhdsWithin.{u1} Ξ± _inst_2 x s)) => Exists.{max (succ u1) (succ u2)} (Ξ± -> Ξ²) (fun (F : Ξ± -> Ξ²) => And (ContinuousWithinAt.{u1, u2} Ξ± Ξ² _inst_2 (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) F s x) (forall (y : Ξ±), (Membership.Mem.{u1, u1} Ξ± (Set.{u1} Ξ±) (Set.hasMem.{u1} Ξ±) y t) -> (Membership.Mem.{u2, u2} (Prod.{u2, u2} Ξ² Ξ²) (Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Set.hasMem.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Prod.mk.{u2, u2} Ξ² Ξ² (f y) (F y)) u))))))) -> (ContinuousWithinAt.{u1, u2} Ξ± Ξ² _inst_2 (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) f s x) but is expected to have type forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} [_inst_1 : UniformSpace.{u2} Ξ²] {f : Ξ± -> Ξ²} {s : Set.{u1} Ξ±} {x : Ξ±} [_inst_2 : TopologicalSpace.{u1} Ξ±], (Membership.mem.{u1, u1} Ξ± (Set.{u1} Ξ±) (Set.instMembershipSet.{u1} Ξ±) x s) -> (forall (u : Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)), (Membership.mem.{u2, u2} (Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Filter.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (instMembershipSetFilter.{u2} (Prod.{u2, u2} Ξ² Ξ²)) u (uniformity.{u2} Ξ² _inst_1)) -> (Exists.{succ u1} (Set.{u1} Ξ±) (fun (t : Set.{u1} Ξ±) => And (Membership.mem.{u1, u1} (Set.{u1} Ξ±) (Filter.{u1} Ξ±) (instMembershipSetFilter.{u1} Ξ±) t (nhdsWithin.{u1} Ξ± _inst_2 x s)) (Exists.{max (succ u1) (succ u2)} (Ξ± -> Ξ²) (fun (F : Ξ± -> Ξ²) => And (ContinuousWithinAt.{u1, u2} Ξ± Ξ² _inst_2 (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) F s x) (forall (y : Ξ±), (Membership.mem.{u1, u1} Ξ± (Set.{u1} Ξ±) (Set.instMembershipSet.{u1} Ξ±) y t) -> (Membership.mem.{u2, u2} (Prod.{u2, u2} Ξ² Ξ²) (Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Set.instMembershipSet.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Prod.mk.{u2, u2} Ξ² Ξ² (f y) (F y)) u))))))) -> (ContinuousWithinAt.{u1, u2} Ξ± Ξ² _inst_2 (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) f s x) Case conversion may be inaccurate. Consider using '#align continuous_within_at_of_locally_uniform_approx_of_continuous_within_at continuousWithinAt_of_locally_uniform_approx_of_continuousWithinAtβ‚“'. -/ /-- A function which can be locally uniformly approximated by functions which are continuous within a set at a point is continuous within this set at this point. -/ theorem continuousWithinAt_of_locally_uniform_approx_of_continuousWithinAt (hx : x ∈ s) (L : βˆ€ u ∈ 𝓀 Ξ², βˆƒ t ∈ 𝓝[s] x, βˆƒ F : Ξ± β†’ Ξ², ContinuousWithinAt F s x ∧ βˆ€ y ∈ t, (f y, F y) ∈ u) : ContinuousWithinAt f s x := by apply Uniform.continuousWithinAt_iff'_left.2 fun uβ‚€ huβ‚€ => _ obtain ⟨u₁, h₁, uβ‚β‚€βŸ© : βˆƒ (u : Set (Ξ² Γ— Ξ²))(H : u ∈ 𝓀 Ξ²), compRel u u βŠ† uβ‚€ := comp_mem_uniformity_sets huβ‚€ obtain ⟨uβ‚‚, hβ‚‚, hsymm, uβ‚‚β‚βŸ© : βˆƒ (u : Set (Ξ² Γ— Ξ²))(H : u ∈ 𝓀 Ξ²), (βˆ€ {a b}, (a, b) ∈ u β†’ (b, a) ∈ u) ∧ compRel u u βŠ† u₁ := comp_symm_of_uniformity h₁ rcases L uβ‚‚ hβ‚‚ with ⟨t, tx, F, hFc, hF⟩ have A : βˆ€αΆ  y in 𝓝[s] x, (f y, F y) ∈ uβ‚‚ := eventually.mono tx hF have B : βˆ€αΆ  y in 𝓝[s] x, (F y, F x) ∈ uβ‚‚ := Uniform.continuousWithinAt_iff'_left.1 hFc hβ‚‚ have C : βˆ€αΆ  y in 𝓝[s] x, (f y, F x) ∈ u₁ := (A.and B).mono fun y hy => u₂₁ (prod_mk_mem_compRel hy.1 hy.2) have : (F x, f x) ∈ u₁ := u₂₁ (prod_mk_mem_compRel (refl_mem_uniformity hβ‚‚) (hsymm (A.self_of_nhds_within hx))) exact C.mono fun y hy => u₁₀ (prod_mk_mem_compRel hy this) #align continuous_within_at_of_locally_uniform_approx_of_continuous_within_at continuousWithinAt_of_locally_uniform_approx_of_continuousWithinAt /- warning: continuous_at_of_locally_uniform_approx_of_continuous_at -> continuousAt_of_locally_uniform_approx_of_continuousAt is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} [_inst_1 : UniformSpace.{u2} Ξ²] {f : Ξ± -> Ξ²} {x : Ξ±} [_inst_2 : TopologicalSpace.{u1} Ξ±], (forall (u : Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)), (Membership.Mem.{u2, u2} (Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Filter.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Filter.hasMem.{u2} (Prod.{u2, u2} Ξ² Ξ²)) u (uniformity.{u2} Ξ² _inst_1)) -> (Exists.{succ u1} (Set.{u1} Ξ±) (fun (t : Set.{u1} Ξ±) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} Ξ±) (Filter.{u1} Ξ±) (Filter.hasMem.{u1} Ξ±) t (nhds.{u1} Ξ± _inst_2 x)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} Ξ±) (Filter.{u1} Ξ±) (Filter.hasMem.{u1} Ξ±) t (nhds.{u1} Ξ± _inst_2 x)) => Exists.{max (succ u1) (succ u2)} (Ξ± -> Ξ²) (fun (F : Ξ± -> Ξ²) => And (ContinuousAt.{u1, u2} Ξ± Ξ² _inst_2 (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) F x) (forall (y : Ξ±), (Membership.Mem.{u1, u1} Ξ± (Set.{u1} Ξ±) (Set.hasMem.{u1} Ξ±) y t) -> (Membership.Mem.{u2, u2} (Prod.{u2, u2} Ξ² Ξ²) (Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Set.hasMem.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Prod.mk.{u2, u2} Ξ² Ξ² (f y) (F y)) u))))))) -> (ContinuousAt.{u1, u2} Ξ± Ξ² _inst_2 (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) f x) but is expected to have type forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} [_inst_1 : UniformSpace.{u2} Ξ²] {f : Ξ± -> Ξ²} {x : Ξ±} [_inst_2 : TopologicalSpace.{u1} Ξ±], (forall (u : Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)), (Membership.mem.{u2, u2} (Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Filter.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (instMembershipSetFilter.{u2} (Prod.{u2, u2} Ξ² Ξ²)) u (uniformity.{u2} Ξ² _inst_1)) -> (Exists.{succ u1} (Set.{u1} Ξ±) (fun (t : Set.{u1} Ξ±) => And (Membership.mem.{u1, u1} (Set.{u1} Ξ±) (Filter.{u1} Ξ±) (instMembershipSetFilter.{u1} Ξ±) t (nhds.{u1} Ξ± _inst_2 x)) (Exists.{max (succ u2) (succ u1)} (Ξ± -> Ξ²) (fun (F : Ξ± -> Ξ²) => And (ContinuousAt.{u1, u2} Ξ± Ξ² _inst_2 (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) F x) (forall (y : Ξ±), (Membership.mem.{u1, u1} Ξ± (Set.{u1} Ξ±) (Set.instMembershipSet.{u1} Ξ±) y t) -> (Membership.mem.{u2, u2} (Prod.{u2, u2} Ξ² Ξ²) (Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Set.instMembershipSet.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Prod.mk.{u2, u2} Ξ² Ξ² (f y) (F y)) u))))))) -> (ContinuousAt.{u1, u2} Ξ± Ξ² _inst_2 (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) f x) Case conversion may be inaccurate. Consider using '#align continuous_at_of_locally_uniform_approx_of_continuous_at continuousAt_of_locally_uniform_approx_of_continuousAtβ‚“'. -/ /-- A function which can be locally uniformly approximated by functions which are continuous at a point is continuous at this point. -/ theorem continuousAt_of_locally_uniform_approx_of_continuousAt (L : βˆ€ u ∈ 𝓀 Ξ², βˆƒ t ∈ 𝓝 x, βˆƒ F, ContinuousAt F x ∧ βˆ€ y ∈ t, (f y, F y) ∈ u) : ContinuousAt f x := by rw [← continuousWithinAt_univ] apply continuousWithinAt_of_locally_uniform_approx_of_continuousWithinAt (mem_univ _) _ simpa only [exists_prop, nhdsWithin_univ, continuousWithinAt_univ] using L #align continuous_at_of_locally_uniform_approx_of_continuous_at continuousAt_of_locally_uniform_approx_of_continuousAt /- warning: continuous_on_of_locally_uniform_approx_of_continuous_within_at -> continuousOn_of_locally_uniform_approx_of_continuousWithinAt is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} [_inst_1 : UniformSpace.{u2} Ξ²] {f : Ξ± -> Ξ²} {s : Set.{u1} Ξ±} [_inst_2 : TopologicalSpace.{u1} Ξ±], (forall (x : Ξ±), (Membership.Mem.{u1, u1} Ξ± (Set.{u1} Ξ±) (Set.hasMem.{u1} Ξ±) x s) -> (forall (u : Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)), (Membership.Mem.{u2, u2} (Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Filter.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Filter.hasMem.{u2} (Prod.{u2, u2} Ξ² Ξ²)) u (uniformity.{u2} Ξ² _inst_1)) -> (Exists.{succ u1} (Set.{u1} Ξ±) (fun (t : Set.{u1} Ξ±) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} Ξ±) (Filter.{u1} Ξ±) (Filter.hasMem.{u1} Ξ±) t (nhdsWithin.{u1} Ξ± _inst_2 x s)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} Ξ±) (Filter.{u1} Ξ±) (Filter.hasMem.{u1} Ξ±) t (nhdsWithin.{u1} Ξ± _inst_2 x s)) => Exists.{max (succ u1) (succ u2)} (Ξ± -> Ξ²) (fun (F : Ξ± -> Ξ²) => And (ContinuousWithinAt.{u1, u2} Ξ± Ξ² _inst_2 (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) F s x) (forall (y : Ξ±), (Membership.Mem.{u1, u1} Ξ± (Set.{u1} Ξ±) (Set.hasMem.{u1} Ξ±) y t) -> (Membership.Mem.{u2, u2} (Prod.{u2, u2} Ξ² Ξ²) (Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Set.hasMem.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Prod.mk.{u2, u2} Ξ² Ξ² (f y) (F y)) u)))))))) -> (ContinuousOn.{u1, u2} Ξ± Ξ² _inst_2 (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) f s) but is expected to have type forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} [_inst_1 : UniformSpace.{u2} Ξ²] {f : Ξ± -> Ξ²} {s : Set.{u1} Ξ±} [_inst_2 : TopologicalSpace.{u1} Ξ±], (forall (x : Ξ±), (Membership.mem.{u1, u1} Ξ± (Set.{u1} Ξ±) (Set.instMembershipSet.{u1} Ξ±) x s) -> (forall (u : Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)), (Membership.mem.{u2, u2} (Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Filter.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (instMembershipSetFilter.{u2} (Prod.{u2, u2} Ξ² Ξ²)) u (uniformity.{u2} Ξ² _inst_1)) -> (Exists.{succ u1} (Set.{u1} Ξ±) (fun (t : Set.{u1} Ξ±) => And (Membership.mem.{u1, u1} (Set.{u1} Ξ±) (Filter.{u1} Ξ±) (instMembershipSetFilter.{u1} Ξ±) t (nhdsWithin.{u1} Ξ± _inst_2 x s)) (Exists.{max (succ u2) (succ u1)} (Ξ± -> Ξ²) (fun (F : Ξ± -> Ξ²) => And (ContinuousWithinAt.{u1, u2} Ξ± Ξ² _inst_2 (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) F s x) (forall (y : Ξ±), (Membership.mem.{u1, u1} Ξ± (Set.{u1} Ξ±) (Set.instMembershipSet.{u1} Ξ±) y t) -> (Membership.mem.{u2, u2} (Prod.{u2, u2} Ξ² Ξ²) (Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Set.instMembershipSet.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Prod.mk.{u2, u2} Ξ² Ξ² (f y) (F y)) u)))))))) -> (ContinuousOn.{u1, u2} Ξ± Ξ² _inst_2 (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) f s) Case conversion may be inaccurate. Consider using '#align continuous_on_of_locally_uniform_approx_of_continuous_within_at continuousOn_of_locally_uniform_approx_of_continuousWithinAtβ‚“'. -/ /-- A function which can be locally uniformly approximated by functions which are continuous on a set is continuous on this set. -/ theorem continuousOn_of_locally_uniform_approx_of_continuousWithinAt (L : βˆ€ x ∈ s, βˆ€ u ∈ 𝓀 Ξ², βˆƒ t ∈ 𝓝[s] x, βˆƒ F, ContinuousWithinAt F s x ∧ βˆ€ y ∈ t, (f y, F y) ∈ u) : ContinuousOn f s := fun x hx => continuousWithinAt_of_locally_uniform_approx_of_continuousWithinAt hx (L x hx) #align continuous_on_of_locally_uniform_approx_of_continuous_within_at continuousOn_of_locally_uniform_approx_of_continuousWithinAt #print continuousOn_of_uniform_approx_of_continuousOn /- /-- A function which can be uniformly approximated by functions which are continuous on a set is continuous on this set. -/ theorem continuousOn_of_uniform_approx_of_continuousOn (L : βˆ€ u ∈ 𝓀 Ξ², βˆƒ F, ContinuousOn F s ∧ βˆ€ y ∈ s, (f y, F y) ∈ u) : ContinuousOn f s := continuousOn_of_locally_uniform_approx_of_continuousWithinAt fun x hx u hu => ⟨s, self_mem_nhdsWithin, (L u hu).imp fun F hF => ⟨hF.1.ContinuousWithinAt hx, hF.2⟩⟩ #align continuous_on_of_uniform_approx_of_continuous_on continuousOn_of_uniform_approx_of_continuousOn -/ /- warning: continuous_of_locally_uniform_approx_of_continuous_at -> continuous_of_locally_uniform_approx_of_continuousAt is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} [_inst_1 : UniformSpace.{u2} Ξ²] {f : Ξ± -> Ξ²} [_inst_2 : TopologicalSpace.{u1} Ξ±], (forall (x : Ξ±) (u : Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)), (Membership.Mem.{u2, u2} (Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Filter.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Filter.hasMem.{u2} (Prod.{u2, u2} Ξ² Ξ²)) u (uniformity.{u2} Ξ² _inst_1)) -> (Exists.{succ u1} (Set.{u1} Ξ±) (fun (t : Set.{u1} Ξ±) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} Ξ±) (Filter.{u1} Ξ±) (Filter.hasMem.{u1} Ξ±) t (nhds.{u1} Ξ± _inst_2 x)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} Ξ±) (Filter.{u1} Ξ±) (Filter.hasMem.{u1} Ξ±) t (nhds.{u1} Ξ± _inst_2 x)) => Exists.{max (succ u1) (succ u2)} (Ξ± -> Ξ²) (fun (F : Ξ± -> Ξ²) => And (ContinuousAt.{u1, u2} Ξ± Ξ² _inst_2 (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) F x) (forall (y : Ξ±), (Membership.Mem.{u1, u1} Ξ± (Set.{u1} Ξ±) (Set.hasMem.{u1} Ξ±) y t) -> (Membership.Mem.{u2, u2} (Prod.{u2, u2} Ξ² Ξ²) (Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Set.hasMem.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Prod.mk.{u2, u2} Ξ² Ξ² (f y) (F y)) u))))))) -> (Continuous.{u1, u2} Ξ± Ξ² _inst_2 (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) f) but is expected to have type forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} [_inst_1 : UniformSpace.{u2} Ξ²] {f : Ξ± -> Ξ²} [_inst_2 : TopologicalSpace.{u1} Ξ±], (forall (x : Ξ±) (u : Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)), (Membership.mem.{u2, u2} (Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Filter.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (instMembershipSetFilter.{u2} (Prod.{u2, u2} Ξ² Ξ²)) u (uniformity.{u2} Ξ² _inst_1)) -> (Exists.{succ u1} (Set.{u1} Ξ±) (fun (t : Set.{u1} Ξ±) => And (Membership.mem.{u1, u1} (Set.{u1} Ξ±) (Filter.{u1} Ξ±) (instMembershipSetFilter.{u1} Ξ±) t (nhds.{u1} Ξ± _inst_2 x)) (Exists.{max (succ u2) (succ u1)} (Ξ± -> Ξ²) (fun (F : Ξ± -> Ξ²) => And (ContinuousAt.{u1, u2} Ξ± Ξ² _inst_2 (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) F x) (forall (y : Ξ±), (Membership.mem.{u1, u1} Ξ± (Set.{u1} Ξ±) (Set.instMembershipSet.{u1} Ξ±) y t) -> (Membership.mem.{u2, u2} (Prod.{u2, u2} Ξ² Ξ²) (Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Set.instMembershipSet.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Prod.mk.{u2, u2} Ξ² Ξ² (f y) (F y)) u))))))) -> (Continuous.{u1, u2} Ξ± Ξ² _inst_2 (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) f) Case conversion may be inaccurate. Consider using '#align continuous_of_locally_uniform_approx_of_continuous_at continuous_of_locally_uniform_approx_of_continuousAtβ‚“'. -/ /-- A function which can be locally uniformly approximated by continuous functions is continuous. -/ theorem continuous_of_locally_uniform_approx_of_continuousAt (L : βˆ€ x : Ξ±, βˆ€ u ∈ 𝓀 Ξ², βˆƒ t ∈ 𝓝 x, βˆƒ F, ContinuousAt F x ∧ βˆ€ y ∈ t, (f y, F y) ∈ u) : Continuous f := continuous_iff_continuousAt.2 fun x => continuousAt_of_locally_uniform_approx_of_continuousAt (L x) #align continuous_of_locally_uniform_approx_of_continuous_at continuous_of_locally_uniform_approx_of_continuousAt #print continuous_of_uniform_approx_of_continuous /- /-- A function which can be uniformly approximated by continuous functions is continuous. -/ theorem continuous_of_uniform_approx_of_continuous (L : βˆ€ u ∈ 𝓀 Ξ², βˆƒ F, Continuous F ∧ βˆ€ y, (f y, F y) ∈ u) : Continuous f := continuous_iff_continuousOn_univ.mpr <| continuousOn_of_uniform_approx_of_continuousOn <| by simpa [continuous_iff_continuousOn_univ] using L #align continuous_of_uniform_approx_of_continuous continuous_of_uniform_approx_of_continuous -/ /-! ### Uniform limits From the previous statements on uniform approximation, we deduce continuity results for uniform limits. -/ #print TendstoLocallyUniformlyOn.continuousOn /- /-- A locally uniform limit on a set of functions which are continuous on this set is itself continuous on this set. -/ protected theorem TendstoLocallyUniformlyOn.continuousOn (h : TendstoLocallyUniformlyOn F f p s) (hc : βˆ€αΆ  n in p, ContinuousOn (F n) s) [NeBot p] : ContinuousOn f s := by apply continuousOn_of_locally_uniform_approx_of_continuousWithinAt fun x hx u hu => _ rcases h u hu x hx with ⟨t, ht, H⟩ rcases(hc.and H).exists with ⟨n, hFc, hF⟩ exact ⟨t, ht, ⟨F n, hFc.continuous_within_at hx, hF⟩⟩ #align tendsto_locally_uniformly_on.continuous_on TendstoLocallyUniformlyOn.continuousOn -/ #print TendstoUniformlyOn.continuousOn /- /-- A uniform limit on a set of functions which are continuous on this set is itself continuous on this set. -/ protected theorem TendstoUniformlyOn.continuousOn (h : TendstoUniformlyOn F f p s) (hc : βˆ€αΆ  n in p, ContinuousOn (F n) s) [NeBot p] : ContinuousOn f s := h.TendstoLocallyUniformlyOn.ContinuousOn hc #align tendsto_uniformly_on.continuous_on TendstoUniformlyOn.continuousOn -/ #print TendstoLocallyUniformly.continuous /- /-- A locally uniform limit of continuous functions is continuous. -/ protected theorem TendstoLocallyUniformly.continuous (h : TendstoLocallyUniformly F f p) (hc : βˆ€αΆ  n in p, Continuous (F n)) [NeBot p] : Continuous f := continuous_iff_continuousOn_univ.mpr <| h.TendstoLocallyUniformlyOn.ContinuousOn <| hc.mono fun n hn => hn.ContinuousOn #align tendsto_locally_uniformly.continuous TendstoLocallyUniformly.continuous -/ #print TendstoUniformly.continuous /- /-- A uniform limit of continuous functions is continuous. -/ protected theorem TendstoUniformly.continuous (h : TendstoUniformly F f p) (hc : βˆ€αΆ  n in p, Continuous (F n)) [NeBot p] : Continuous f := h.TendstoLocallyUniformly.Continuous hc #align tendsto_uniformly.continuous TendstoUniformly.continuous -/ /-! ### Composing limits under uniform convergence In general, if `Fβ‚™` converges pointwise to a function `f`, and `gβ‚™` tends to `x`, it is not true that `Fβ‚™ gβ‚™` tends to `f x`. It is true however if the convergence of `Fβ‚™` to `f` is uniform. In this paragraph, we prove variations around this statement. -/ /- warning: tendsto_comp_of_locally_uniform_limit_within -> tendsto_comp_of_locally_uniform_limit_within is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {s : Set.{u1} Ξ±} {x : Ξ±} {p : Filter.{u3} ΞΉ} {g : ΞΉ -> Ξ±} [_inst_2 : TopologicalSpace.{u1} Ξ±], (ContinuousWithinAt.{u1, u2} Ξ± Ξ² _inst_2 (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) f s x) -> (Filter.Tendsto.{u3, u1} ΞΉ Ξ± g p (nhdsWithin.{u1} Ξ± _inst_2 x s)) -> (forall (u : Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)), (Membership.Mem.{u2, u2} (Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Filter.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Filter.hasMem.{u2} (Prod.{u2, u2} Ξ² Ξ²)) u (uniformity.{u2} Ξ² _inst_1)) -> (Exists.{succ u1} (Set.{u1} Ξ±) (fun (t : Set.{u1} Ξ±) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} Ξ±) (Filter.{u1} Ξ±) (Filter.hasMem.{u1} Ξ±) t (nhdsWithin.{u1} Ξ± _inst_2 x s)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} Ξ±) (Filter.{u1} Ξ±) (Filter.hasMem.{u1} Ξ±) t (nhdsWithin.{u1} Ξ± _inst_2 x s)) => Filter.Eventually.{u3} ΞΉ (fun (n : ΞΉ) => forall (y : Ξ±), (Membership.Mem.{u1, u1} Ξ± (Set.{u1} Ξ±) (Set.hasMem.{u1} Ξ±) y t) -> (Membership.Mem.{u2, u2} (Prod.{u2, u2} Ξ² Ξ²) (Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Set.hasMem.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Prod.mk.{u2, u2} Ξ² Ξ² (f y) (F n y)) u)) p)))) -> (Filter.Tendsto.{u3, u2} ΞΉ Ξ² (fun (n : ΞΉ) => F n (g n)) p (nhds.{u2} Ξ² (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) (f x))) but is expected to have type forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {s : Set.{u1} Ξ±} {x : Ξ±} {p : Filter.{u3} ΞΉ} {g : ΞΉ -> Ξ±} [_inst_2 : TopologicalSpace.{u1} Ξ±], (ContinuousWithinAt.{u1, u2} Ξ± Ξ² _inst_2 (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) f s x) -> (Filter.Tendsto.{u3, u1} ΞΉ Ξ± g p (nhdsWithin.{u1} Ξ± _inst_2 x s)) -> (forall (u : Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)), (Membership.mem.{u2, u2} (Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Filter.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (instMembershipSetFilter.{u2} (Prod.{u2, u2} Ξ² Ξ²)) u (uniformity.{u2} Ξ² _inst_1)) -> (Exists.{succ u1} (Set.{u1} Ξ±) (fun (t : Set.{u1} Ξ±) => And (Membership.mem.{u1, u1} (Set.{u1} Ξ±) (Filter.{u1} Ξ±) (instMembershipSetFilter.{u1} Ξ±) t (nhdsWithin.{u1} Ξ± _inst_2 x s)) (Filter.Eventually.{u3} ΞΉ (fun (n : ΞΉ) => forall (y : Ξ±), (Membership.mem.{u1, u1} Ξ± (Set.{u1} Ξ±) (Set.instMembershipSet.{u1} Ξ±) y t) -> (Membership.mem.{u2, u2} (Prod.{u2, u2} Ξ² Ξ²) (Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Set.instMembershipSet.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Prod.mk.{u2, u2} Ξ² Ξ² (f y) (F n y)) u)) p)))) -> (Filter.Tendsto.{u3, u2} ΞΉ Ξ² (fun (n : ΞΉ) => F n (g n)) p (nhds.{u2} Ξ² (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) (f x))) Case conversion may be inaccurate. Consider using '#align tendsto_comp_of_locally_uniform_limit_within tendsto_comp_of_locally_uniform_limit_withinβ‚“'. -/ /-- If `Fβ‚™` converges locally uniformly on a neighborhood of `x` within a set `s` to a function `f` which is continuous at `x` within `s `, and `gβ‚™` tends to `x` within `s`, then `Fβ‚™ (gβ‚™)` tends to `f x`. -/ theorem tendsto_comp_of_locally_uniform_limit_within (h : ContinuousWithinAt f s x) (hg : Tendsto g p (𝓝[s] x)) (hunif : βˆ€ u ∈ 𝓀 Ξ², βˆƒ t ∈ 𝓝[s] x, βˆ€αΆ  n in p, βˆ€ y ∈ t, (f y, F n y) ∈ u) : Tendsto (fun n => F n (g n)) p (𝓝 (f x)) := by apply Uniform.tendsto_nhds_right.2 fun uβ‚€ huβ‚€ => _ obtain ⟨u₁, h₁, uβ‚β‚€βŸ© : βˆƒ (u : Set (Ξ² Γ— Ξ²))(H : u ∈ 𝓀 Ξ²), compRel u u βŠ† uβ‚€ := comp_mem_uniformity_sets huβ‚€ rcases hunif u₁ h₁ with ⟨s, sx, hs⟩ have A : βˆ€αΆ  n in p, g n ∈ s := hg sx have B : βˆ€αΆ  n in p, (f x, f (g n)) ∈ u₁ := hg (Uniform.continuousWithinAt_iff'_right.1 h h₁) refine' ((hs.and A).And B).mono fun y hy => _ rcases hy with ⟨⟨H1, H2⟩, H3⟩ exact u₁₀ (prod_mk_mem_compRel H3 (H1 _ H2)) #align tendsto_comp_of_locally_uniform_limit_within tendsto_comp_of_locally_uniform_limit_within /- warning: tendsto_comp_of_locally_uniform_limit -> tendsto_comp_of_locally_uniform_limit is a dubious translation: lean 3 declaration is forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {x : Ξ±} {p : Filter.{u3} ΞΉ} {g : ΞΉ -> Ξ±} [_inst_2 : TopologicalSpace.{u1} Ξ±], (ContinuousAt.{u1, u2} Ξ± Ξ² _inst_2 (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) f x) -> (Filter.Tendsto.{u3, u1} ΞΉ Ξ± g p (nhds.{u1} Ξ± _inst_2 x)) -> (forall (u : Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)), (Membership.Mem.{u2, u2} (Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Filter.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Filter.hasMem.{u2} (Prod.{u2, u2} Ξ² Ξ²)) u (uniformity.{u2} Ξ² _inst_1)) -> (Exists.{succ u1} (Set.{u1} Ξ±) (fun (t : Set.{u1} Ξ±) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} Ξ±) (Filter.{u1} Ξ±) (Filter.hasMem.{u1} Ξ±) t (nhds.{u1} Ξ± _inst_2 x)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} Ξ±) (Filter.{u1} Ξ±) (Filter.hasMem.{u1} Ξ±) t (nhds.{u1} Ξ± _inst_2 x)) => Filter.Eventually.{u3} ΞΉ (fun (n : ΞΉ) => forall (y : Ξ±), (Membership.Mem.{u1, u1} Ξ± (Set.{u1} Ξ±) (Set.hasMem.{u1} Ξ±) y t) -> (Membership.Mem.{u2, u2} (Prod.{u2, u2} Ξ² Ξ²) (Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Set.hasMem.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Prod.mk.{u2, u2} Ξ² Ξ² (f y) (F n y)) u)) p)))) -> (Filter.Tendsto.{u3, u2} ΞΉ Ξ² (fun (n : ΞΉ) => F n (g n)) p (nhds.{u2} Ξ² (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) (f x))) but is expected to have type forall {Ξ± : Type.{u1}} {Ξ² : Type.{u2}} {ΞΉ : Type.{u3}} [_inst_1 : UniformSpace.{u2} Ξ²] {F : ΞΉ -> Ξ± -> Ξ²} {f : Ξ± -> Ξ²} {x : Ξ±} {p : Filter.{u3} ΞΉ} {g : ΞΉ -> Ξ±} [_inst_2 : TopologicalSpace.{u1} Ξ±], (ContinuousAt.{u1, u2} Ξ± Ξ² _inst_2 (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) f x) -> (Filter.Tendsto.{u3, u1} ΞΉ Ξ± g p (nhds.{u1} Ξ± _inst_2 x)) -> (forall (u : Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)), (Membership.mem.{u2, u2} (Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Filter.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (instMembershipSetFilter.{u2} (Prod.{u2, u2} Ξ² Ξ²)) u (uniformity.{u2} Ξ² _inst_1)) -> (Exists.{succ u1} (Set.{u1} Ξ±) (fun (t : Set.{u1} Ξ±) => And (Membership.mem.{u1, u1} (Set.{u1} Ξ±) (Filter.{u1} Ξ±) (instMembershipSetFilter.{u1} Ξ±) t (nhds.{u1} Ξ± _inst_2 x)) (Filter.Eventually.{u3} ΞΉ (fun (n : ΞΉ) => forall (y : Ξ±), (Membership.mem.{u1, u1} Ξ± (Set.{u1} Ξ±) (Set.instMembershipSet.{u1} Ξ±) y t) -> (Membership.mem.{u2, u2} (Prod.{u2, u2} Ξ² Ξ²) (Set.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Set.instMembershipSet.{u2} (Prod.{u2, u2} Ξ² Ξ²)) (Prod.mk.{u2, u2} Ξ² Ξ² (f y) (F n y)) u)) p)))) -> (Filter.Tendsto.{u3, u2} ΞΉ Ξ² (fun (n : ΞΉ) => F n (g n)) p (nhds.{u2} Ξ² (UniformSpace.toTopologicalSpace.{u2} Ξ² _inst_1) (f x))) Case conversion may be inaccurate. Consider using '#align tendsto_comp_of_locally_uniform_limit tendsto_comp_of_locally_uniform_limitβ‚“'. -/ /-- If `Fβ‚™` converges locally uniformly on a neighborhood of `x` to a function `f` which is continuous at `x`, and `gβ‚™` tends to `x`, then `Fβ‚™ (gβ‚™)` tends to `f x`. -/ theorem tendsto_comp_of_locally_uniform_limit (h : ContinuousAt f x) (hg : Tendsto g p (𝓝 x)) (hunif : βˆ€ u ∈ 𝓀 Ξ², βˆƒ t ∈ 𝓝 x, βˆ€αΆ  n in p, βˆ€ y ∈ t, (f y, F n y) ∈ u) : Tendsto (fun n => F n (g n)) p (𝓝 (f x)) := by rw [← continuousWithinAt_univ] at h rw [← nhdsWithin_univ] at hunif hg exact tendsto_comp_of_locally_uniform_limit_within h hg hunif #align tendsto_comp_of_locally_uniform_limit tendsto_comp_of_locally_uniform_limit #print TendstoLocallyUniformlyOn.tendsto_comp /- /-- If `Fβ‚™` tends locally uniformly to `f` on a set `s`, and `gβ‚™` tends to `x` within `s`, then `Fβ‚™ gβ‚™` tends to `f x` if `f` is continuous at `x` within `s` and `x ∈ s`. -/ theorem TendstoLocallyUniformlyOn.tendsto_comp (h : TendstoLocallyUniformlyOn F f p s) (hf : ContinuousWithinAt f s x) (hx : x ∈ s) (hg : Tendsto g p (𝓝[s] x)) : Tendsto (fun n => F n (g n)) p (𝓝 (f x)) := tendsto_comp_of_locally_uniform_limit_within hf hg fun u hu => h u hu x hx #align tendsto_locally_uniformly_on.tendsto_comp TendstoLocallyUniformlyOn.tendsto_comp -/ #print TendstoUniformlyOn.tendsto_comp /- /-- If `Fβ‚™` tends uniformly to `f` on a set `s`, and `gβ‚™` tends to `x` within `s`, then `Fβ‚™ gβ‚™` tends to `f x` if `f` is continuous at `x` within `s`. -/ theorem TendstoUniformlyOn.tendsto_comp (h : TendstoUniformlyOn F f p s) (hf : ContinuousWithinAt f s x) (hg : Tendsto g p (𝓝[s] x)) : Tendsto (fun n => F n (g n)) p (𝓝 (f x)) := tendsto_comp_of_locally_uniform_limit_within hf hg fun u hu => ⟨s, self_mem_nhdsWithin, h u hu⟩ #align tendsto_uniformly_on.tendsto_comp TendstoUniformlyOn.tendsto_comp -/ #print TendstoLocallyUniformly.tendsto_comp /- /-- If `Fβ‚™` tends locally uniformly to `f`, and `gβ‚™` tends to `x`, then `Fβ‚™ gβ‚™` tends to `f x`. -/ theorem TendstoLocallyUniformly.tendsto_comp (h : TendstoLocallyUniformly F f p) (hf : ContinuousAt f x) (hg : Tendsto g p (𝓝 x)) : Tendsto (fun n => F n (g n)) p (𝓝 (f x)) := tendsto_comp_of_locally_uniform_limit hf hg fun u hu => h u hu x #align tendsto_locally_uniformly.tendsto_comp TendstoLocallyUniformly.tendsto_comp -/ #print TendstoUniformly.tendsto_comp /- /-- If `Fβ‚™` tends uniformly to `f`, and `gβ‚™` tends to `x`, then `Fβ‚™ gβ‚™` tends to `f x`. -/ theorem TendstoUniformly.tendsto_comp (h : TendstoUniformly F f p) (hf : ContinuousAt f x) (hg : Tendsto g p (𝓝 x)) : Tendsto (fun n => F n (g n)) p (𝓝 (f x)) := h.TendstoLocallyUniformly.tendsto_comp hf hg #align tendsto_uniformly.tendsto_comp TendstoUniformly.tendsto_comp -/
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <omp.h> #include <timerlib.h> #ifndef NOBLAS #ifdef MKL #include <mkl_cblas.h> #else #include <cblas.h> #endif #endif #include "gdrdgemm.h" #define NMAT 2048 void gdr_check_and_restart(double a[][NMAT], double b[][NMAT], double c[][NMAT]) { int try =0; static int initialized = 0; if (initialized) return; while(1){ int i,j; for(i=0;i<NMAT;i++){ for(j=0;j<NMAT;j++){ a[i][j]=0; b[i][j]=i*NMAT+j; c[i][j]=0; } } for(i=0;i<NMAT;i++)a[i][i]=1; cblas_dgemm( CblasRowMajor, CblasNoTrans, CblasNoTrans, NMAT,NMAT, NMAT, 1.0, a, NMAT, b, NMAT, 0.0, c, NMAT); cblas_dgemm( CblasRowMajor, CblasNoTrans, CblasNoTrans, NMAT,NMAT, NMAT, 1.0, a, NMAT, b, NMAT, 0.0, c, NMAT); mygdrdgemm(NMAT, NMAT, NMAT, 1.0, (double*)a, NMAT, (double*)b, NMAT, 0.0, (double*) c, NMAT); int err = 0; for(i=0;i<NMAT;i++){ for(j=0;j<NMAT;j++){ if (b[i][j] != c[i][j]){ err ++; } } } if (err == 0){ fprintf(stderr,"gdr_check_and_restart passed %d\n", try); initialized=1; return; } try++; fprintf(stderr, "gdr_check_and_restart, err=%d try=%d\n", err, try); gdr_free(); gdr_init(); } } void gdrblas_dgemm ( #ifndef MKL const enum CBLAS_ORDER ORDER, const enum CBLAS_TRANSPOSE TRANSA, const enum CBLAS_TRANSPOSE TRANSB, #else const CBLAS_ORDER ORDER, const CBLAS_TRANSPOSE TRANSA, const CBLAS_TRANSPOSE TRANSB, #endif const int M, const int N, const int K, const double ALPHA, const double * A, const int LDA, const double * B, const int LDB, const double BETA, double * C, const int LDC ) { int NOTA, NOTB,gdrdoneflag; double alpha = ALPHA, beta = BETA; int F77M=M, F77N=N, F77K=K, F77lda=LDA, F77ldb=LDB, F77ldc=LDC; if( TRANSA == CblasNoTrans ){ NOTA = 1; }else{ NOTA = 0; } if( TRANSB == CblasNoTrans ){ NOTB = 1; }else{ NOTB = 0; } if( ORDER == CblasColMajor ){ gdrdoneflag=0; gdr_dgemm_(&NOTA,&NOTB,&F77M,&F77N,&F77K, &alpha, &beta, &F77lda, &F77ldb, &F77ldc,A,B,C, &gdrdoneflag); } else { gdrdoneflag=0; gdr_dgemm_(&NOTA,&NOTB,&F77N,&F77M,&F77K, &alpha, &beta, &F77ldb, &F77lda, &F77ldc,B,A,C, &gdrdoneflag); } if(gdrdoneflag!=1){ cblas_dgemm(ORDER, TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC); } /* * End of HPL_dgemm */ } void dumpcmat(int m, int n, int nc, double c[][nc]) { static int callcount = 0; static FILE* fid; if (callcount == 0){ fid = fopen("/tmp/matdata", "w"); } callcount ++; if(callcount < 8){ fprintf(fid,"\nPrint CMAT callcount=%d\n",callcount); int i, j; for(i=0;i<m;i++){ fprintf(fid,"\ni=%d\n", i); for(j=0;j<n;j++){ if ((j%8)==0 )fprintf(fid,"\n%5d:", j); fprintf(fid," %20.12e",c[i][j]); } } } } double touchcmat(int m, int n, int nc, double c[][nc]) { double sum=0; int i, j; for(i=0;i<m;i++){ for(j=0;j<n;j++){ sum += c[i][j]*c[i][j]; } } return sum; } double ssum = 0.0; void mygdrdgemm(int m, int n, int k, double alpha, double * a, int na, double * b, int nb, double beta, double * c, int nc) { int nota=1, notb=1; int gdrdoneflag = 0; static int first_call = 1; if (first_call){ gdrdgemm_set_procname(MP_myprocid()); first_call=0; init_current_time(); } // char str[128]; // sprintf(str,"before sums = %25.20e %25.20e %25.20e", // touchcmat(m,k,na,a), touchcmat(k,n,nb,b), touchcmat(m,n,nc,c)); // MP_message(str); // dprintf(9,"mygdrdgemm omp_max_threads=%d procs=%d\n", // omp_get_max_threads(),omp_get_num_procs()); double zero=0.0; // int tmp=0; // gdr_dgemm_(&nota, &notb, &n, &m, &k, &zero, &beta, &nb, &na, &nc, // b, a, c, &tmp); gdr_dgemm_(&nota, &notb, &n, &m, &k, &alpha, &beta, &nb, &na, &nc, b, a, c, &gdrdoneflag); // cblas_dgemm( CblasRowMajor, CblasNoTrans, CblasNoTrans, // m,n, k, alpha, a, na, b, nb, beta, c, nc); // gdrdoneflag=1; // fprintf(stderr,"gdrflag=%d\n", gdrdoneflag); if(gdrdoneflag!=1){ cblas_dgemm( CblasRowMajor, CblasNoTrans, CblasNoTrans, m,n, k, alpha, a, na, b, nb, beta, c, nc); } // dumpcmat(m,n,nc,c); // sprintf(str,"after sums = %25.20e %25.20e %25.20e", // touchcmat(m,k,na,a), touchcmat(k,n,nb,b), touchcmat(m,n,nc,c)); // MP_message(str); }
--- output: pdf_document: default html_document: default --- \documentclass[oneside,12pt]{book} \usepackage{SAGI3} \begin{document} \frontmatter %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% start titlepage \thispagestyle{empty} \vspace*{25mm} \begin{flushright} \HRule\\[5mm] %%% logos go here ... \begin{tabular}{rrrr} \includegraphics[height = 1.5cm]{UoA} & \includegraphics[height = 2.0cm]{GRDC} & \includegraphics[height = 2.0cm]{SARDI} & \includegraphics[height = 1.5cm]{SAGI-STH} \end{tabular}\\[5mm] \huge \textcolor{blue}{\sbf Statistics for the Australian\\ Grains Industry (Southern Region)\\ Technical Report Series: SS001} \\[6mm] {\sbf Informative report title}\\ \Large \vspace{2mm}{\sbf Report for UA000001}\\[5mm] \sf\normalsize Julian Taylor\\ Senior Biometrician, SAGI-STH\\ PMB 1 Glen Osmond 5064\\ email: [email protected]\\[8mm] \today\\ \HRule \end{flushright} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% end titlepage \clearpage \pagestyle{plain} \setcounter{page}{1} \tableofcontents %% other lists of tables or figures %\listoftables %\addcontentsline{toc}{chapter}{List of Tables} %\listoffigures %\addcontentsline{toc}{chapter}{List of Figures} \clearpage \section*{Executive Summary} \addcontentsline{toc}{section}{Executive summary} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Start document \mainmatter \pagestyle{fancy} %%%%%%%%%%%% Book class \chapter{Chapter 1} \section{This is a section heading} \subsection{This is a subsection heading} \subsubsection{This is a subsubsection heading} \chapter{Next Chapter} This shows a smooth transition to the next chapter. \addcontentsline{toc}{chapter}{References} \bibliographystyle{biom} \bibliography{references} %%%%%%%%%%%% Article class % \section{This is a section heading} % \subsection{This is a subsection heading} % \subsubsection{This is a subsubsection heading} % \section{Next section heading} % This shows a smooth transition to the next chapter. % \addcontentsline{toc}{section}{References} % \bibliographystyle{biom} % \bibliography{references} %%%%%%%%%%%% \end{document}
From Coq Require Export ZArith List. Import ListNotations. #[global] Open Scope Z_scope. Inductive cmd := | forward | up | down . Declare Custom Entry aoc02. Notation "'input' x .. y" := (cons x .. (cons y nil) ..) (at level 200, x custom aoc02, y custom aoc02, only parsing). Notation "x y" := (x, y) (in custom aoc02 at level 0, x constr at level 0, y constr at level 0). Definition example := input forward 5 down 5 forward 8 up 3 down 8 forward 2 . (* Part One *) Definition position : Type := Z * Z. Definition eval1 (c : cmd) (n : Z) '((hpos, zpos) : position) : position := match c with | forward => (hpos + n, zpos) | up => (hpos, zpos - n) | down => (hpos, zpos + n) end. Fixpoint eval (xs : list (cmd * Z)) (current : position) : position := match xs with | [] => current | (c, n) :: xs => eval xs (eval1 c n current) end. Definition solve (xs : list (cmd * Z)) : Z := let '(hpos, zpos) := eval xs (0, 0) in hpos * zpos. (* Compute solve example. *) (* Part Two *) Definition position_2 : Type := Z * Z * Z. Definition eval1_2 (c : cmd) (n : Z) '((hpos, zpos, aim) : position_2) : position_2 := match c with | forward => (hpos + n, zpos + n * aim, aim) | up => (hpos, zpos, aim - n) | down => (hpos, zpos, aim + n) end. Fixpoint eval_2 (xs : list (cmd * Z)) (current : position_2) : position_2 := match xs with | [] => current | (c, n) :: xs => eval_2 xs (eval1_2 c n current) end. Definition solve2 (xs : list (cmd * Z)) : Z := let '(hpos, zpos, _aim) := eval_2 xs (0, 0, 0) in hpos * zpos. Definition solve12 (i : list (cmd * Z)) : Z * Z := (solve i, solve2 i). (* Compute solve2 example. *) (* The second part generalizes the first: the [aim] in Part Two plays the role of depth ([zpos]) in Part One. *) (* We could prove this directly, but just to be fancy, let's make it explicit that it relies on a _simulation argument_: the single-step functions [eval1] and [eval1_2] preserve a relation [R] between [position] and [position_2], so the iterated-step functions [eval] and [eval_2] also preserve [R]. *) Lemma eval_sim : forall (R : position -> position_2 -> Prop), (forall c n p p2, R p p2 -> R (eval1 c n p) (eval1_2 c n p2)) -> forall xs p p2, R p p2 -> R (eval xs p) (eval_2 xs p2). Proof. intros R SIM; induction xs as [ | [c n] xs IH ]; cbn. - trivial. - intros * H; apply IH, SIM, H. Qed. Lemma eval1_fact : forall c n hpos zpos aim, eval1 c n (hpos, aim) = let '(hpos', _, aim') := eval1_2 c n (hpos, zpos, aim) in (hpos', aim'). Proof. destruct c; reflexivity. Qed. Theorem eval_fact : forall xs hpos zpos aim, eval xs (hpos, aim) = let '(hpos', _, aim') := eval_2 xs (hpos, zpos, aim) in (hpos', aim'). Proof. intros xs hpos zpos aim; apply eval_sim. - intros c n _ [[? ?] ?] ->. apply eval1_fact. - reflexivity. Qed.
(* Copyright 2014 Cornell University Copyright 2015 Cornell University Copyright 2016 Cornell University Copyright 2017 Cornell University This file is part of VPrl (the Verified Nuprl project). VPrl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. VPrl is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with VPrl. If not, see <http://www.gnu.org/licenses/>. Websites: http://nuprl.org/html/verification/ http://nuprl.org/html/Nuprl2Coq https://github.com/vrahli/NuprlInCoq Authors: Abhishek Anand & Vincent Rahli *) Require Export close_type_sys. Require Export Peano. (** printing # $\times$ #Γ—# *) (** printing <=> $\Leftrightarrow$ #&hArr;# *) (** printing ~<~ $\preceq$ *) (** printing ~=~ $\sim$ *) (** printing ===> $\Downarrow$ *) (** printing [[ $[$ *) (** printing ]] $]$ *) (** printing \\ $\backslash$ *) (** printing mkc_axiom $\mathtt{Ax}$ *) (** printing mkc_base $\mathtt{Base}$ *) (** printing mkc_int $\intg$ *) (** printing mkc_integer $\mathtt{int}$ *) (* begin hide *) Lemma defines_only_universes_univi {o} : forall lib i, @defines_only_universes o lib (univi lib i). Proof. unfold defines_only_universes; sp. allrw @univi_exists_iff; sp. exists j; sp. Qed. Lemma defines_only_universes_univ {o} : forall lib, @defines_only_universes o lib (univ lib). Proof. unfold defines_only_universes, univ; sp. induction i; allsimpl; sp. exists i; sp. Qed. (* end hide *) (** We prove that all the Nuprl universes satisfy the type system properties. *) Lemma univi_type_system {o} : forall lib (i : nat), @type_system o lib (univi lib i). Proof. induction i using comp_ind_type. unfold type_system; sp. - unfold uniquely_valued, eq_term_equals; sp. allrw @univi_exists_iff; sp. spcast; computes_to_eqval. allrw; sp. - introv q h. allrw @univi_exists_iff; exrepnd. exists j; sp. rw <- h; auto. - unfold type_symmetric; sp. allrw @univi_exists_iff; sp. exists j; sp. - unfold type_transitive; sp. allrw @univi_exists_iff; sp. spcast; computes_to_eqval. eexists; sp; spcast; sp. - unfold type_value_respecting; sp. allrw @univi_exists_iff; sp. exists j; sp; thin_trivials. spcast; apply cequivc_uni with (t := T); auto. - unfold term_symmetric, term_equality_symmetric; sp. allrw @univi_exists_iff; sp; spcast. discover; sp. allrw. exists eqa; auto. generalize (@close_type_system o lib (univi lib j)); intro k. repeat (dest_imp k hyp). apply defines_only_universes_univi. inversion k; sp. - unfold term_transitive, term_equality_transitive; sp. allrw @univi_exists_iff; sp. discover; sp; spcast. allrw. generalize (@close_type_system o lib (univi lib j)); intro k. repeat (dest_imp k hyp). apply defines_only_universes_univi. inversion k; sp. exists eqa0. apply uniquely_valued_trans4 with (T2 := t2) (eq1 := eqa); sp. - unfold term_value_respecting, term_equality_respecting; sp. allrw @univi_exists_iff; sp. discover; sp; spcast; GC. allrw. exists eqa. generalize (@close_type_system o lib (univi lib j)); intro k. repeat (dest_imp k hyp). apply defines_only_universes_univi. inversion k; sp. Qed. (* begin hide *) Lemma nuprli_type_system {o} : forall lib (i : nat), @type_system o lib (nuprli lib i). Proof. unfold nuprli; sp. apply close_type_system. apply univi_type_system. apply defines_only_universes_univi. Qed. Lemma nuprli_uniquely_valued {o} : forall lib i1 i2 (T T' : @CTerm o) eq eq', nuprli lib i1 T T' eq -> nuprli lib i2 T T' eq' -> eq_term_equals eq eq'. Proof. sp. assert (nuprli lib (i2 + i1) T T' eq) as c1 by (apply typable_in_higher_univ; auto). assert (nuprli lib (i1 + i2) T T' eq') as c2 by (apply typable_in_higher_univ; auto). assert (i1 + i2 = i2 + i1) as e by omega. rww e. generalize (@nuprli_type_system o lib (i2 + i1)); intro nts. destruct nts; sp. unfold uniquely_valued in u. apply u with (T := T) (T' := T'); auto. Qed. Lemma nuprli_type_transitive {o} : forall lib i1 i2 (T1 T2 T3 : @CTerm o) eq, nuprli lib i1 T1 T2 eq -> nuprli lib i2 T2 T3 eq -> {i : nat & nuprli lib i T1 T3 eq # i1 <= i # i2 <= i}. Proof. sp. assert (nuprli lib (i1 + i2) T1 T2 eq) as c1 by (apply typable_in_higher_univ_r; auto). assert (nuprli lib (i1 + i2) T2 T3 eq) as c2 by (apply typable_in_higher_univ; auto). exists (i1 + i2); sp; try omega. generalize (@nuprli_type_system o lib (i1 + i2)); intro nts. destruct nts; sp. apply p2 with (T2 := T2); sp. Qed. Lemma univi_uniquely_valued {o} : forall lib i1 i2 (T T' : @CTerm o) eq eq', univi lib i1 T T' eq -> univi lib i2 T T' eq' -> eq_term_equals eq eq'. Proof. sp. assert (univi lib (i2 + i1) T T' eq) as c1 by (apply uni_in_higher_univ; auto). assert (univi lib (i1 + i2) T T' eq') as c2 by (apply uni_in_higher_univ; auto). assert (i1 + i2 = i2 + i1) as e by omega. rww e. generalize (@univi_type_system o lib (i2 + i1)); intro uts. destruct uts; sp. unfold uniquely_valued in u. apply u with (T := T) (T' := T'); auto. Qed. (* end hide *) (** We prove that that [univ] satisfies the type system properties. *) Lemma univ_type_system {o} : forall lib, @type_system o lib (univ lib). Proof. unfold univ, type_system; sp. - unfold uniquely_valued; sp. apply (univi_uniquely_valued lib) with (i1 := i0) (i2 := i) (T := T) (T' := T'); auto. - unfold type_extensionality; sp. exists i. generalize (@univi_type_system o lib i); intro uts. dest_ts uts. unfold type_extensionality in ts_ext. apply ts_ext with (eq := eq); auto. - unfold type_symmetric; sp. exists i. generalize (@univi_type_system o lib i); intro uts. dest_ts uts; auto. - unfold type_transitive; introv u1 u2; exrepnd. apply uni_in_higher_univ with (k := i0) in u0. apply uni_in_higher_univ_r with (k := i) in u2. exists (i0 + i). generalize (@univi_type_system o lib (i0 + i)); intro uts. dest_ts uts; auto. apply ts_tyt with (T2 := T2); auto. - unfold type_value_respecting; sp. exists i. generalize (@univi_type_system o lib i); intro uts. dest_ts uts; sp. - unfold term_symmetric, term_equality_symmetric; introv u e1; exrepnd. generalize (@univi_type_system o lib i); intro uts. dest_ts uts; sp. apply ts_tes in u0. apply u0; auto. - unfold term_transitive, term_equality_transitive; introv u e1 e2; exrepnd. generalize (@univi_type_system o lib i); intro uts. dest_ts uts; sp. apply ts_tet in u0. apply u0 with (t2 := t2); auto. - unfold term_value_respecting, term_equality_respecting; introv u e1 c1; exrepnd. generalize (@univi_type_system o lib i); intro uts. dest_ts uts; sp. apply ts_tev in u0. apply u0; auto. Qed. (** Finally, we prove that that [nuprl] satisfies the type system properties. *) Lemma nuprl_type_system {p} : forall lib, @type_system p lib (nuprl lib). Proof. introv. apply close_type_system. apply univ_type_system. apply defines_only_universes_univ. Qed. (* begin hide *) (** Here is a tactic to use the fact that nuprl is a type system *) Ltac nts := match goal with [ p : POpid , lib : library |- _ ] => pose proof (@nuprl_type_system p lib) as nts; destruct nts as [ nts_uv nts ]; destruct nts as [ nts_ext nts ]; destruct nts as [ nts_tys nts ]; destruct nts as [ nts_tyt nts ]; destruct nts as [ nts_tyv nts ]; destruct nts as [ nts_tes nts ]; destruct nts as [ nts_tet nts_tev ] end. Lemma nuprl_refl {p} : forall lib (t1 t2 : @CTerm p) eq, nuprl lib t1 t2 eq -> nuprl lib t1 t1 eq. Proof. intros. nts. assert (nuprl lib t2 t1 eq); sp. use_trans t2; sp. Qed. Lemma nuprl_sym {p} : forall lib (t1 t2 : @CTerm p) eq, nuprl lib t1 t2 eq -> nuprl lib t2 t1 eq. Proof. intros; nts; sp. Qed. Lemma nuprl_trans {p} : forall lib (t1 t2 t3 : @CTerm p) eq1 eq2, nuprl lib t1 t2 eq1 -> nuprl lib t2 t3 eq2 -> nuprl lib t1 t3 eq1. Proof. introv n1 n2; nts. use_trans t2; sp. use_ext eq2; sp. apply uniquely_valued_eq with (ts := nuprl lib) (T := t2) (T1 := t3) (T2 := t1); sp. Qed. Lemma nuprl_uniquely_valued {p} : forall lib (t : @CTerm p) eq1 eq2, nuprl lib t t eq1 -> nuprl lib t t eq2 -> eq_term_equals eq1 eq2. Proof. introv n1 n2; nts. apply nts_uv with (T := t) (T' := t); sp. Qed. Lemma nuprl_value_respecting_left {p} : forall lib (t1 t2 t3 : @CTerm p) eq, nuprl lib t1 t2 eq -> cequivc lib t1 t3 -> nuprl lib t3 t2 eq. Proof. intros. nts. assert (nuprl lib t1 t3 eq) as eq13 by (apply nts_tyv; auto; apply nts_tyt with (T2 := t2); auto). apply nts_tyt with (T2 := t1); auto. Qed. Lemma nuprl_value_respecting_right {p} : forall lib t1 t2 t3 eq, @nuprl p lib t1 t2 eq -> cequivc lib t2 t3 -> nuprl lib t1 t3 eq. Proof. intros. nts. assert (nuprl lib t2 t3 eq) as eq23 by (apply nts_tyv; auto; apply nts_tyt with (T2 := t1); auto). apply nts_tyt with (T2 := t2); auto. Qed. Lemma nuprl_eq_implies_eqorceq_refl {p} : forall lib T1 T2 eq t1 t2, @nuprl p lib T1 T2 eq -> eq t1 t2 -> eqorceq lib eq t1 t1 # eqorceq lib eq t2 t2. Proof. introv n e. nts; sp; left. unfold term_transitive, term_equality_transitive in nts_tet. apply nts_tet with (t2 := t2) (T := T1) (T' := T2); sp. unfold term_symmetric, term_equality_symmetric in nts_tes. apply nts_tes with (T := T1) (T' := T2); sp. unfold term_transitive, term_equality_transitive in nts_tet. apply nts_tet with (t2 := t1) (T := T1) (T' := T2); sp. unfold term_symmetric, term_equality_symmetric in nts_tes. apply nts_tes with (T := T1) (T' := T2); sp. Qed. (* end hide *)
lemma summable_complex_of_real [simp]: "summable (\<lambda>n. complex_of_real (f n)) \<longleftrightarrow> summable f"
open import Agda.Primitive record Order {β„“} β„“' (A : Set β„“) : Set (β„“ βŠ” lsuc β„“') where field _≀_ : A β†’ A β†’ Set β„“' open Order {{...}} public data β„• : Set where Zero : β„• Succ : β„• β†’ β„• data _≀ⁿ_ : β„• β†’ β„• β†’ Set where Zero : βˆ€ {n} β†’ Zero ≀ⁿ n Succ : βˆ€ {n₁ nβ‚‚} β†’ n₁ ≀ⁿ nβ‚‚ β†’ Succ n₁ ≀ⁿ Succ nβ‚‚ instance Order[β„•] : Order lzero β„• Order[β„•] = record { _≀_ = _≀ⁿ_ } subtract : βˆ€ (n₁ nβ‚‚ : β„•) β†’ nβ‚‚ ≀ n₁ β†’ β„• subtract n₁ .Zero Zero = n₁ subtract .(Succ _) .(Succ _) (Succ P) = subtract _ _ P
Ann Marie Sanchez unsuccessfully ran for ASUCD ASUCD Senate Senate on the LEAD slate in the Winter 2005 ASUCD Election. She is one of the 20072008 Student Assistants to the Chancellor.
theory Calculus imports Complex_Main begin theorem mvt: fixes \<phi> :: "real \<Rightarrow> real" assumes "a < b" and contf: "continuous_on {a..b} \<phi>" and derf: "\<And>x. \<lbrakk>a < x; x < b\<rbrakk> \<Longrightarrow> (\<phi> has_derivative \<phi>' x) (at x)" obtains \<xi> where "a < \<xi>" "\<xi> < b" "\<phi> b - \<phi> a = (\<phi>' \<xi>) (b-a)" proof - define f where "f \<equiv> \<lambda>x. \<phi> x - (\<phi> b - \<phi> a) / (b-a) * x" have "\<exists>\<xi>. a < \<xi> \<and> \<xi> < b \<and> (\<lambda>y. \<phi>' \<xi> y - (\<phi> b - \<phi> a) / (b-a) * y) = (\<lambda>v. 0)" proof (intro Rolle_deriv[OF \<open>a < b\<close>]) fix x assume x: "a < x" "x < b" show "(f has_derivative (\<lambda>y. \<phi>' x y - (\<phi> b - \<phi> a) / (b-a) * y)) (at x)" unfolding f_def by (intro derivative_intros derf x) next show "f a = f b" using assms by (simp add: f_def field_simps) next show "continuous_on {a..b} f" unfolding f_def by (intro continuous_intros assms) qed then show ?thesis by (smt (verit, ccfv_SIG) pos_le_divide_eq pos_less_divide_eq that) qed end
-- | Post-mortem tool main. import Universum import Data.List (last) import qualified Data.Map.Strict as M import System.FilePath import System.IO (hPutStrLn) import Text.Printf (hPrintf) import Pos.Util.Util (histogram) import Options import Statistics import Types main :: IO () main = parseOptions >>= \case Overview sampleProb logDirs -> do showLogDirs logDirs err $ "sample probability: " ++ show sampleProb err "" xs <- forM logDirs $ flip processLogDirOverview sampleProb chart xs "times.png" err "wrote times chart" Focus txHash logDir -> do err $ "transaction hash: " ++ show txHash err $ "logs directory: " ++ show logDir let focusFile = ("focus_" ++ extractName logDir ++ "_" ++ toString txHash) <.> "csv" runJSONFold logDir (focusF txHash) >>= focusToCSV focusFile err $ "wrote result to " ++ show focusFile TxRelay logDirs -> do showLogDirs logDirs err "" for_ logDirs processLogDirTxRelay Throughput txWindow waitWindow logDirs -> do showLogDirs logDirs err $ "tx window: " ++ show txWindow err $ "wait window: " ++ show waitWindow err "" for_ logDirs $ processLogDirThroughput txWindow waitWindow showLogDirs :: [FilePath] -> IO () showLogDirs logDirs = do err "log directories: " for_ logDirs $ \d -> err $ " - " ++ show d processLogDirOverview :: FilePath -> Double -> IO (String, Map TxHash (Maybe Timestamp)) processLogDirOverview logDir sampleProb = do err $ "processing log directory " ++ show logDir ++ " ..." (rc, g, mp, cr, ft) <- runJSONFold logDir $ (,,,,) <$> receivedCreatedF <*> graphF <*> memPoolF <*> txCntInChainF <*> txFateF let total = M.size rc included = sort $ mapMaybe snd $ M.toList rc lost = total - length included err $ "total number of received transactions: " ++ show total err $ "included in blockchain: " ++ show (length included) err $ "lost transactions: " ++ show lost err $ "blocks in chain: " ++ show (length cr) err $ "mem pool entries: " ++ show (length mp) let dirName = extractName logDir let graphFile = getName "graph" dirName "png" b <- writeGraph graphFile g when b $ err $ "wrote graph png to " ++ show graphFile let csvFile = getName "csv" dirName "csv" txCntInChainMemPoolToCSV csvFile sampleProb cr mp err $ "wrote csv file to " ++ show csvFile let reportFile = getName "report" dirName "txt" void (reportTxFate reportFile ft) err $ "wrote report file to " ++ show reportFile err $ "processing log directory " ++ show logDir ++ " done" err "" return (dirName, rc) processLogDirTxRelay :: FilePath -> IO () processLogDirTxRelay logDir = do err $ "processing log directory " ++ show logDir ++ " ..." m <- runJSONFold logDir txReceivedF err $ "total number of received transactions: " ++ show (M.size m) let xs = sortBy (compare `on` \(_, ys) -> negate $ length ys) $ M.toList m dirName = extractName logDir relaysFile = getName "relays" dirName "txt" withFile relaysFile WriteMode $ \h -> for_ xs $ \(tx, ys) -> hPutStrLn h $ toString tx ++ ": " ++ show ys err $ "wrote relay data to " ++ show relaysFile let hist = M.toList $ histogram $ map (length . snd) xs histFile = getName "histogram" dirName "txt" withFile histFile WriteMode $ \h -> for_ hist $ uncurry $ hPrintf h "%4d:%6d\n" err $ "wrote histogram to " ++ show histFile processLogDirThroughput :: Double -> Double -> FilePath -> IO () processLogDirThroughput txWindow waitWindow logDir = do err $ "processing log directory " ++ show logDir ++ " ..." (xs, ys) <- runJSONFold logDir $ (,) <$> txCntInChainF <*> memPoolF err $ "chain length: " ++ show (length xs) ++ " block(s)" err $ show (length ys) ++ " mem pool event(s)" let svgFile = getName "throughput" (extractName logDir) "svg" throughput svgFile txWindow waitWindow 1000 xs ys err $ "wrote chart to " ++ show svgFile err :: String -> IO () err = hPutStrLn stderr getName :: FilePath -> String -> String -> FilePath getName template name ext = let dir = takeDirectory template base = takeBaseName template base' = base ++ "_" ++ name in dir </> base' <.> ext extractName :: FilePath -> String extractName = last . splitDirectories
lemma poly_cutoff_0 [simp]: "poly_cutoff n 0 = 0"
Require Import Omega. Require Import List. Require Import FunctionalExtensionality. Require Import Eqdep_dec. Require Import RelationClasses. Record pos := mkPos { row : nat; col : nat }. Notation "x & y" := (mkPos x y) (at level 50). Inductive pos_le : pos -> pos -> Prop := | Pos_le : forall n m n' m', n <= n' -> m <= m' -> pos_le (n & m) (n' & m'). Hint Constructors pos_le. Hint Extern 4 (_ <= _) => omega. Ltac destruct_pos := match reverse goal with | [ p: pos |- _ ] => let n := fresh "n" in let m := fresh "m" in destruct p as [n m] end. Ltac invert_pos_le := match goal with | [ H: pos_le _ _ |- _ ] => inversion H; subst; clear H end. Instance pos_le_preoroder : PreOrder pos_le. Proof. constructor; hnf; intros; repeat invert_pos_le; repeat destruct_pos; eauto. Qed. Definition pos_le_dec (p1 p2: pos) : {pos_le p1 p2} + {~pos_le p1 p2}. Proof. repeat destruct_pos. destruct (le_dec n n0); destruct (le_dec m m0); try solve [ left; eauto ]; try solve [ right; intro; invert_pos_le; eauto ]. Defined. Definition Board := pos -> bool. Definition invariant (b:Board) := forall p, b p = false -> forall p', pos_le p p' -> b p' = false. Inductive State := | mkState : forall (b:Board), invariant b -> State. Theorem invariant_prop_ext : forall (b:Board) (H1 H2: invariant b), H1 = H2. Proof. intros. extensionality p. extensionality Hbp. extensionality p'. extensionality Hle. apply (UIP_dec Bool.bool_dec). Qed. Implicit Type (sigma:State). Implicit Type (b:Board). Implicit Type (p:pos). Definition getBoard sigma : Board := let (b, _) := sigma in b. Theorem State_eq : forall sigma sigma', getBoard sigma = getBoard sigma' -> sigma = sigma'. Proof. destruct sigma, sigma'; intros; simpl in *; subst. pose proof (invariant_prop_ext _ i i0); subst. auto. Qed. Definition remove' (b:Board) p : Board := fun p' => if pos_le_dec p p' then false else b p'. Lemma remove_preserves_invariant : forall b p, invariant b -> invariant (remove' b p). Proof. unfold invariant; intros. unfold remove' in *. destruct (pos_le_dec p p'); eauto. destruct (pos_le_dec p p0); eauto. contradiction n. etransitivity; eassumption. Qed. Definition remove (sigma:State) (p: pos) : State. Proof. destruct sigma. apply (mkState (remove' b p)). auto using remove_preserves_invariant. Defined. Inductive move : State -> State -> Prop := | isMove : forall sigma sigma' p, getBoard sigma p = true -> getBoard sigma' = getBoard (remove sigma p) -> move sigma sigma'. Inductive Elements b (l: list pos) : Prop := | ElementsAre : (forall p, b p = true -> In p l) -> Elements b l. Theorem sumbool_bool_eq : forall P Q (x: {P} + {Q}) (b: bool), (if x then true else false) = b -> if b then P else Q. Proof. destruct x, b; congruence. Qed. (* rectangle with top-right corner p *) Definition rectangle p : State. apply (mkState (fun p' => if pos_le_dec p' p then true else false)). unfold invariant; intros. apply sumbool_bool_eq in H. destruct (pos_le_dec p' p); eauto. contradiction H. etransitivity; eauto. Defined. Inductive LoseFrom : State -> Prop := | AllWin : forall sigma sigma'', move sigma sigma'' -> (forall sigma', move sigma sigma' -> WinFrom sigma') -> LoseFrom sigma with WinFrom : State -> Prop := | NoMoves : forall sigma, (forall sigma', ~move sigma sigma') -> WinFrom sigma | CanForce : forall sigma sigma', move sigma sigma' -> LoseFrom sigma' -> WinFrom sigma. Definition empty : State. apply (mkState (fun _ => false)). unfold invariant; intros. auto. Defined. Lemma empty_nomoves : forall sigma sigma', getBoard sigma = getBoard empty -> ~move sigma sigma'. Proof. inversion 2; subst. rewrite H in H1. simpl in *; congruence. Qed. Theorem empty_win : forall sigma, getBoard sigma = getBoard empty -> WinFrom sigma. Proof. intros. apply NoMoves; intros. apply empty_nomoves; auto. Qed. Theorem empty_not_lose : forall sigma, getBoard sigma = getBoard empty -> ~LoseFrom sigma. Proof. inversion 2; subst. inversion H1; subst. rewrite H in H3; simpl in *; congruence. Qed. Ltac econstructor_with e := unshelve econstructor; [ exact e | .. ]. Lemma pos_le_0 : forall p, pos_le p (0 & 0) -> p = (0 & 0). Proof. intros. destruct_pos; invert_pos_le. f_equal; omega. Qed. Lemma remove_0_from_corner : getBoard (remove (rectangle (0 & 0)) (0 & 0)) = getBoard empty. Proof. extensionality p; simpl. unfold remove'. destruct (pos_le_dec (0 & 0) p); auto. destruct (pos_le_dec p (0 & 0)); auto. apply pos_le_0 in p0; subst. contradict n. reflexivity. Qed. Theorem bottom_good : LoseFrom (rectangle (0 & 0)) /\ ~WinFrom (rectangle (0 & 0)). Proof. split. - econstructor_with empty. econstructor_with (0 & 0); auto. rewrite remove_0_from_corner; auto. intros. inversion H; subst. inversion H0; subst. apply sumbool_bool_eq in H3. apply pos_le_0 in H3; subst. rewrite remove_0_from_corner in H1. apply empty_win; auto. - inversion 1; subst. apply (H0 empty). econstructor_with (0 & 0); auto. rewrite remove_0_from_corner; auto. Search move. inversion H0; subst. inversion H2. apply sumbool_bool_eq in H5. apply pos_le_0 in H5; subst. rewrite remove_0_from_corner in *. eapply empty_not_lose; eauto. Qed. (* Local Variables: *) (* company-coq-local-symbols: (("sigma" . ?Οƒ) ("sigma'" . (?Οƒ (Br . Bl) ?')) ("sigma''" . (?Οƒ (Br . Bl) ?' (Br . Bl) ?')) ("State" . ?Ξ£)) *) (* End: *)
\<^marker>\<open>creator "Josh Chen"\<close> \<^marker>\<open>creator "Kevin Kappelmann"\<close> section \<open>Typed Set-Theoretic Binary Relations\<close> theory TSBinary_Relations imports HOTG.SBinary_Relations TSPairs begin subsection \<open>Dependent Binary Relations\<close> definition [typedef]: "Dep_Bin_Rel A B \<equiv> Collection (\<Sum>x : A. (B x))" abbreviation "Bin_Rel A B \<equiv> Dep_Bin_Rel A (\<lambda>_. B)" lemma subset_dep_pairs_iff_Dep_Bin_Rel: "R \<subseteq> (\<Sum>x \<in> A. (B x)) \<longleftrightarrow> R : Dep_Bin_Rel (Element A) (\<lambda>x. Element (B x))" by unfold_types auto soft_type_translation "R \<subseteq> (\<Sum>x \<in> A. (B x))" \<rightleftharpoons> "R : Dep_Bin_Rel (Element A) (\<lambda>x. Element (B x))" using subset_dep_pairs_iff_Dep_Bin_Rel by auto lemma Dep_Bin_RelI: "(\<And>p. p \<in> R \<Longrightarrow> p : \<Sum>x : A. (B x)) \<Longrightarrow> R : Dep_Bin_Rel A B" unfolding Dep_Bin_Rel_def by (rule CollectionI) lemma Dep_Bin_Rel_memE [elim]: assumes "R : Dep_Bin_Rel A B" and "p \<in> R" obtains x y where "x : A" "y : B x" "p = \<langle>x, y\<rangle>" using assms unfolding Dep_Bin_Rel_def by (auto dest: Collection_memD) lemma Dep_Bin_Rel_covariant_dom: "R : Dep_Bin_Rel A B \<Longrightarrow> (\<And>x. x : A \<Longrightarrow> x : A') \<Longrightarrow> R : Dep_Bin_Rel A' B" unfolding Dep_Bin_Rel_def by (elim Collection_covariant) (blast intro: Dep_Pair_covariant_fst) lemma Dep_Bin_Rel_covariant_rng: assumes "R : Dep_Bin_Rel A B" and "\<And>x y. x : A \<Longrightarrow> y : B x \<Longrightarrow> \<langle>x, y\<rangle> \<in> R \<Longrightarrow> y : B' x" shows "R : Dep_Bin_Rel A B'" using assms unfolding Dep_Bin_Rel_def by (elim Collection_covariant) (auto intro: Dep_Pair_covariant_snd) subsection \<open>Predicates on Binary Relations\<close> overloading set_injective_on_type \<equiv> "set_injective_on :: set type \<Rightarrow> set \<Rightarrow> bool" begin definition "set_injective_on_type (T :: set type) R \<equiv> set_injective_on (type_pred T) R" end lemma set_injective_on_type_iff_set_injective_on [iff]: "set_injective_on (T :: set type) R \<longleftrightarrow> set_injective_on (type_pred T) R" unfolding set_injective_on_type_def by simp overloading set_right_unique_on_type \<equiv> "set_right_unique_on :: set type \<Rightarrow> set \<Rightarrow> bool" begin definition "set_right_unique_on_type (T :: set type) R \<equiv> set_right_unique_on (type_pred T) R" end lemma set_right_unique_on_type_iff_set_right_unique_on [iff]: "set_right_unique_on (T :: set type) R \<longleftrightarrow> set_right_unique_on (type_pred T) R" unfolding set_right_unique_on_type_def by simp overloading set_left_total_on_type \<equiv> "set_left_total_on :: set type \<Rightarrow> set \<Rightarrow> bool" begin definition "set_left_total_on_type (T :: set type) R \<equiv> set_left_total_on (type_pred T) R" end lemma set_left_total_on_type_iff_set_left_total_on [iff]: "set_left_total_on (T :: set type) R \<longleftrightarrow> set_left_total_on (type_pred T) R" unfolding set_left_total_on_type_def by simp overloading set_surjective_at_type \<equiv> "set_surjective_at :: set type \<Rightarrow> set \<Rightarrow> bool" begin definition "set_surjective_at_type (T :: set type) R \<equiv> set_surjective_at (type_pred T) R" end lemma set_surjective_at_type_iff_set_surjective_at [iff]: "set_surjective_at (T :: set type) R \<longleftrightarrow> set_surjective_at (type_pred T) R" unfolding set_surjective_at_type_def by simp subsection \<open>Functions on Binary Relations\<close> lemma extend_type [type]: "extend : (x : A) \<Rightarrow> B x \<Rightarrow> Dep_Bin_Rel A B \<Rightarrow> Dep_Bin_Rel A B" by unfold_types auto lemma glue_type [type]: "glue : Collection (Dep_Bin_Rel A B) \<Rightarrow> Dep_Bin_Rel A B" by unfold_types auto overloading set_restrict_left_type \<equiv> "set_restrict_left :: set \<Rightarrow> set type \<Rightarrow> set" begin definition "set_restrict_left_type R (T :: set type) \<equiv> set_restrict_left R (type_pred T)" end lemma set_restrict_left_type_eq_set_restrict_left [simp]: "set_restrict_left R (T :: set type) = set_restrict_left R (type_pred T)" unfolding set_restrict_left_type_def by simp lemma set_restrict_left_set_eq_set_restrict_left_type [simp]: "set_restrict_left R S = set_restrict_left R (Element S)" by (auto iff: mem_iff_Element) lemma set_restrict_left_type [type]: "set_restrict_left : Dep_Bin_Rel A B \<Rightarrow> (P : Set \<Rightarrow> Bool) \<Rightarrow> Dep_Bin_Rel (A & type P) B" by unfold_types force lemma set_restrict_left_set_type [type]: "set_restrict_left : Dep_Bin_Rel A B \<Rightarrow> (A' : Set) \<Rightarrow> Dep_Bin_Rel (A & Element A') B" (*TODO: should be proved with lemma above*) by unfold_types force lemma set_restrict_left_type_type [type]: "set_restrict_left : Dep_Bin_Rel A B \<Rightarrow> (T : Any) \<Rightarrow> Dep_Bin_Rel (A & T) B" (*TODO: should be proved with lemma above*) by unfold_types force lemma agree_type_iff_agree [iff]: "agree (T :: set type) \<R> \<longleftrightarrow> agree (type_pred T) \<R>" unfolding agree_def by simp lemma dom_type [type]: "dom : Dep_Bin_Rel A B \<Rightarrow> Collection A" by (auto intro: CollectionI) lemma rng_type: "rng : Dep_Bin_Rel A B \<Rightarrow> Collection (type (\<lambda>y. \<exists>x : A. y : B x))" by (auto intro!: CollectionI elim!: Dep_Bin_Rel_memE simp: meaning_of_type) lemma rng_type' [type]: "rng : Bin_Rel A B \<Rightarrow> Collection B" by (auto intro: CollectionI) lemma set_rel_inv_type: "set_rel_inv : Dep_Bin_Rel A B \<Rightarrow> Bin_Rel (type (\<lambda>y. \<exists>x : A. y : B x)) A" by unfold_types force lemma set_rel_inv_type' [type]: "set_rel_inv : Bin_Rel A B \<Rightarrow> Bin_Rel B A" by unfold_types auto lemma Dep_Bin_Rel_mem_set_rel_invE [elim]: assumes "R : Dep_Bin_Rel A B" and "p \<in> set_rel_inv R" obtains x y where "x : A" "y : B x" "\<langle>x, y\<rangle> \<in> R" "p = \<langle>y, x\<rangle>" using assms by auto lemma Dep_Bin_Rel_pair_mem_set_rel_inv_iff [iff]: "R : Dep_Bin_Rel A B \<Longrightarrow> \<langle>a, b\<rangle> \<in> set_rel_inv R \<longleftrightarrow> \<langle>b, a\<rangle> \<in> R" by auto lemma Dep_Bin_Rel_set_rel_inv_set_rel_inv_eq_self [simp]: "R : Dep_Bin_Rel A B \<Longrightarrow> set_rel_inv (set_rel_inv R) = R" by (rule eqI) (auto simp: set_rel_inv_inv_eq) lemma diag_type [type]: "diag : (A : Set) \<Rightarrow> Bin_Rel (Element A) (Element A)" by (auto intro: Dep_Bin_RelI) lemma set_comp_type [type]: "set_comp : (S : Bin_Rel B C) \<Rightarrow> (R : Bin_Rel A B) \<Rightarrow> Bin_Rel A C" by unfold_types auto end
SUBROUTINE zrrtpa6 (IFLTAB, CPATH, VALUES, NVALS, CUNITS, * CTYPE, IUHEAD, KHEADU, NUHEAD, ISTAT) C C C C Retrieve regular interval time series pattern data, C time series data that has no specific date associated with it C such as a unit hydorgraph, or a cyclic data set, such as C daily average maximum temperatues C CHARACTER CPATH*(*), CTYPE*(*), CUNITS*(*) INTEGER IFLTAB(*), IUHEAD(*) REAL VALUES(*) integer kvals, nvals, nheadi, headc, ipan, istat C CHARACTER CSCRAT*20 LOGICAL LFOUND C INCLUDE 'zdssts.h' C INCLUDE 'zdssmz.h' integer khead, nuhead, iplan, NHEADC, KHEADU C C Developmental. C for now, just read the bloody thing in! C (Assume no time span, but this is the entire block!) C C Set the dimension limit KVALS = NVALS C C Read the data CALL zreadx6 (IFLTAB, CPATH, INTBUF, NIBUFF, NHEADI, * HEADC, 0, NHEADC, IUHEAD, KHEADU, NUHEAD, * VALUES, KVALS, NVALS, IPLAN, LFOUND) C C IF (LFOUND) THEN ISTAT = 0 C Get the Header Information CALL HOLCHR (INTBUF(2), 1, 8, CSCRAT, 1) call strcpy(CUNITS, CSCRAT) CALL HOLCHR (INTBUF(4), 1, 8, CSCRAT, 1) call strcpy(CTYPE, CSCRAT) ELSE ISTAT = 5 ENDIF C RETURN END
Additional vocals recorded at The Hit Factory ( New York City , New York )
State Before: ⊒ Pairwise fun x y => 1 ≀ dist ↑x ↑y State After: no goals Tactic: simpa using Nat.pairwise_one_le_dist
Mother vexed did whip her next
#ifndef BIND_ALLOCATOR_HPP #define BIND_ALLOCATOR_HPP #include <boost/asio/associated_allocator.hpp> #include <boost/asio/associated_executor.hpp> namespace async_utils { // Associates an object of type T with an allocator. template <typename T, typename Allocator> struct allocator_binder { allocator_binder(T &&target, Allocator &&allocator) : target{std::move(target)}, allocator{std::move(allocator)} {} using target_type = T; using allocator_type = Allocator; target_type &get() noexcept { return this->target; } target_type const &get() const noexcept { return this->target; } allocator_type get_allocator() const noexcept { return this->allocator; } template <class... Args> decltype(auto) operator()(Args &&... args) const { return std::invoke(target, std::forward<Args>(args)...); } template <class... Args> decltype(auto) operator()(Args &&... args) { return std::invoke(target, std::forward<Args>(args)...); } target_type target; allocator_type allocator; }; // Associates an object of type T with an allocator. // Similar to boost::asio::bind_executor template <typename Allocator, typename T> inline decltype(auto) bind_allocator(Allocator const &allocator, T &&target) { auto a = allocator; return allocator_binder<typename std::decay_t<T>, Allocator>(std::forward<T>(target), std::move(a)); } } // namespace async_utils namespace boost { namespace asio { template <typename T, typename Allocator, typename Allocator1> struct associated_allocator<async_utils::allocator_binder<T, Allocator>, Allocator1> { using type = Allocator; static type get(async_utils::allocator_binder<T, Allocator> const &b, Allocator1 const & /*unused*/ = Allocator1()) noexcept { return b.get_allocator(); } }; template <typename T, typename Allocator, typename Executor1> struct associated_executor<async_utils::allocator_binder<T, Allocator>, Executor1> { using type = typename associated_executor<T, Executor1>::type; static type get(async_utils::allocator_binder<T, Allocator> const &b, Executor1 const &e = Executor1()) noexcept { return associated_executor<T, Executor1>::get(b.get(), e); } }; } // namespace asio } // namespace boost #endif
from os.path import expandvars import numpy as N from astopy.io import fits as PF from types import FunctionType,MethodType from skymaps import SkyDir from fitstools import rad_extract TWOPI = 2*N.pi def phase_cut(eventfile,outputfile=None,phaseranges=[[0,1]],phase_col_name='PULSE_PHASE'): """Select phases within a set of intervals. outputfile - set to change the default output (eventfile_PHASECUT.fits) phaseranges - a set of ranges on which to make inclusive cuts NB -- there was a problem with using the mask as below. Seems to be resolved, but check for consistency in output FITS file to be safe.""" from numpy import array ef = PF.open(expandvars(eventfile)) ph = array(ef['EVENTS'].data.field(phase_col_name)).astype(float) mask = array([False]*len(ph)) for r in phaseranges: for i,myph in enumerate(ph): if (r[0]<= myph) and (myph <= r[1]): mask[i]=True duty_cycle = sum( (x[1] - x[0] for x in phaseranges) ) print ('Selecting %d / %d photons (duty cycle = %.2f)'%(mask.sum(),len(mask),duty_cycle)) hdu = PF.new_table(ef['EVENTS'].columns,nrows=mask.sum()) for i in xrange(len(ef['EVENTS'].columns)): hdu.data.field(i)[:]=ef['EVENTS'].data.field(i)[mask] ef['EVENTS'].data=hdu.data if outputfile: ef.writeto(outputfile,clobber=True) else: ef.writeto(eventfile.replace('.fits','_PHASECUT.fits'),clobber=True) ef.close() def phase_ltcube(ltcube,outputfile,phase): """ Multiply the ltcube by the phase fraction. This is useful for studying the DC component in the off pulse window. N.B. phase can be a float between 0 and 1 or must be an instance of uw.pulsar.phase_range.PhaseRange Also, the 'EXPOSURE' and 'WEIGHTED_EXPOUSRE' table's header is updated so PHASE=the weighted phase fraction Disclaimer: I have no prove that this is the correct way to weight an exposure cube, but it feels right to me (and has been tested fairly well) --Josh """ from uw.pulsar.phase_range import PhaseRange ltcube = PF.open(expandvars(ltcube)) for table in ['exposure', 'weighted_exposure']: cb=ltcube[table].data.field('cosbins') fraction=phase.phase_fraction if isinstance(phase,PhaseRange) else phase cb*=fraction ltcube[table].header.update('PHASE',fraction) ltcube.writeto(outputfile,clobber=True) ltcube.close() def constant_count_histogram(phases,photons_per_bin=100): """Return a set of bins and rates for a 'constant count' lightcurve. phases -- a list of photon phases""" from collections import deque counter = 0 ev = N.asarray(phases) ev.sort() edges = deque() edges.append(0) for i,j in enumerate(ev): if counter == photons_per_bin-1: edges.append(j) counter = 0 else: counter += 1 edges.append(1) edges = N.asarray(edges) delta_phi = edges[1:]-edges[:-1] rates = photons_per_bin/delta_phi rates[-1] = counter/delta_phi[-1] return [edges[:-1],rates,delta_phi] #Left edges, rates, and widths, appropriate for a bar chart class PulsarLightCurve(object): def init(self): self.cookie_cutter_radius = None self.energy_range = [100,2e5] self.phase_col_name = 'PULSE_PHASE' self.psf_irf = 'P6_v3_diff' self.max_radius = [5.,5.] #front, back self.percentage = 68. self.tyrel = False self.damien = False self.psr_cat_ap = -1 def __init__(self,**kwargs): self.init() self.__dict__.update(kwargs) self.set_radius_function() def set_radius_function(self): if self.damien: def r(e,event_class=0): return N.minimum((e/1000.)**-0.85,2.2) elif self.tyrel: def r(e,event_class=0): return N.where(event_class,4.9,2.8)*(e/100)**-0.75 elif self.psr_cat_ap > 0: def r(e,event_class=0): return N.maximum(N.minimum(self.psr_cat_ap,0.8*(1000./e)**0.75),0.35) elif self.cookie_cutter_radius is not None: def r(e,event_class=0): return N.where(event_class,self.cookie_cutter_radius[1],self.cookie_cutter_radius[0]) else: from psf import PSF psf_obj = PSF(psf_irf = self.psf_irf) b = N.logspace(N.log10(self.energy_range[0]),N.log10(self.energy_range[1])) bin_cents = (b[:-1]*b[1:])**0.5 radii = N.append([psf_obj.conf_region(e,event_class=0,percentage=self.percentage) for e in bin_cents],\ [psf_obj.conf_region(e,event_class=1) for e in bin_cents]) def r(e,event_class=0): rads = N.zeros_like(e) for i in xrange(len(e)): for j in xrange(len(b)-1): if b[j]<= e[i] and e[i] < b[j+1]: rads[i] = radii[j*(1+event_class[i])] break rads = N.minimum(N.where(event_class,self.max_radius[1],self.max_radius[0]),rads) return rads self.radius_function = r def get_phases(self,event_files,skydir): self.event_files = event_files #what is this used for? results = rad_extract(event_files,skydir,self.radius_function,return_cols=['PULSE_PHASE','TIME','ENERGY']) ens = results['ENERGY'] mask = N.logical_and(ens >= self.energy_range[0], ens < self.energy_range[1]) self.phases = results['PULSE_PHASE'][mask] self.times = results['TIME'][mask] self.differences = results['DIFFERENCES'][mask] def get_npb(self): return max(int(round(len(self.phases)/30.)),20) def plot(self,fignum=2,show_trend=True,show_errorbars=False,outfile=None,num_per_bin=None, two_cycles=False,point_source=None,relative=True,**kwargs): if 'linecolor' not in kwargs: kwargs['linecolor'] = 'black' if 'errorcolor' not in kwargs: kwargs['errorcolor']='red' if 'fill' not in kwargs: kwargs['fill'] = False import pylab as P #if show_trend: P.figure(fignum,(6,10)) if show_trend: P.figure(fignum, (10,6)) else: P.figure(fignum) npb = num_per_bin or self.get_npb() ev_cop = self.phases.copy() times = (self.times-self.times.min())/(24*3600.) #in days phases,rates,delta_phi = constant_count_histogram(ev_cop,npb) rates_pre = rates.copy() if relative: rates = rates/rates[rates>0].min() #ax1 = P.axes([0.15,0.1,0.75,0.4]) if show_trend else P.axes() ax1 = P.subplot(121) if show_trend else P.axes() label = '%d cts/bin'%(npb) if kwargs['fill']: ax1.bar(phases,rates,N.append(phases[1:],1)-phases,alpha=1.0,fc='red',ec='red') ax1.step(N.append(phases,1),N.append(rates[0],rates),where='pre',color=kwargs['linecolor'],label=label) ax = ax1.axis() ax1.axis([0,1,0,ax[3]]) if two_cycles: ax1.step(N.append(phases,1)+1,N.append(rates[0],rates),where='pre',color=kwargs['linecolor']) ax1.axis([0,2,0,ax[3]]) ax1.set_ylabel('Relative Count Rate') ax1.set_xlabel('Phase') ax1.grid(b=True) ax1.legend(loc=0) if show_errorbars: tph = N.append(phases,1) delta_phi = tph[1:]-tph[:-1] if relative: errs = ((rates_pre*delta_phi)**0.5/rates_pre[rates_pre>0].min())/delta_phi else: errs = ((rates_pre*delta_phi)**0.5)/delta_phi tph = (tph[:-1]+tph[1:])/2. P.errorbar(tph,rates,yerr=errs,ls=' ',capsize=0,color=kwargs['errorcolor']) if two_cycles: P.errorbar(tph+1,rates,yerr=errs,ls=' ',capsize=0,color=kwargs['errorcolor']) if show_trend: ax2 = P.subplot(122) stride = max(1,int(len(ev_cop)/500.)) stride = 1 ax2.scatter(times[::stride],self.phases[::stride],marker='+',color='red',s=10) ax2.axis([0,times[::stride].max(),0,1]) ax2.grid(b=True) ax2.set_xlabel('Days') ax2.set_ylabel('Phase',color='red') for tl in ax2.get_yticklabels(): tl.set_color('red') #Do H-statistic trend ax3 = ax2.twinx() t0 = self.times.min() delta_t = (self.times.max() - t0)/10 ts = N.asarray([t0 + i*delta_t for i in xrange(10+1)]) hs = [] for t in ts[1:]: hs += [h_statistic(self.phases[self.times <= t]) ] ts = (ts - ts[0])/(24.*3600.) #ax3.plot(hs,ts[1:],marker='o',color='k',label='$\mathrm{Observed}$',ls=' ',ms=5) ax3.plot(ts[1:],hs,marker='o',color='blue',ls='-',ms=6) #fit a trend line from scipy import polyval,polyfit pfit = polyfit(ts[1:],hs,1) #ax3.plot(polyval(pfit,ts[1:]),ts[1:],linestyle='--',color='blue',label='$\mathrm{Linear\ Trend}$',lw=2) ax3.plot(ts[1:],polyval(pfit,ts[1:]),linestyle='--',color='blue',lw=3) #ax3.set_ylabel('Integration Time (Days)') sig = r'>5\sigma' if hs[-1] > 50 else '%.1f\sigma'%(sig2sigma(h_sig(hs[-1]))) if point_source is not None: wh,wsig = self.weighted_h(point_source) tit = '$\mathrm{Aperture\ H:\ %s,\ Weighted\ H:\ %.1f\sigma}$'%(sig,wsig) else: tit = '$\mathrm{Aperture\ H:\ %s}$'%(sig) ax3.axhline(hs[-1],linestyle='-',color='blue',label='$\mathrm{Aperture\ H=%.1f\ (%s)}$'%(hs[-1],sig),lw=2) ax3.set_ylabel('H Test Statistic',color='blue') ax = ax3.axis() ax3.axis([0,times.max(),ax[2],ax[3]]) for tl in ax3.get_yticklabels(): tl.set_color('blue') #ax3.legend(loc=0) ax3.set_title(tit) #P.xlabel('Phase') if outfile is not None: P.savefig(outfile) def h_trend(self,intervals=10,fignum=1,outfile=None,show=True,point_source=None): import pylab as P t0 = self.times.min() delta_t = (self.times.max() - t0)/intervals ts = N.asarray([t0 + i*delta_t for i in xrange(intervals+1)]) hs = [] for t in ts[1:]: hs += [h_statistic(self.phases[self.times <= t]) ] P.figure(fignum) ts = (ts - ts[0])/(24.*3600.) #fit a trend line from scipy import polyval,polyfit pfit = polyfit(ts[1:],hs,1) if point_source is not None: wh,wsig = self.weighted_h(point_source) P.plot(ts[1:],hs,marker='o',color='k',label='$\mathrm{Observed}$',ls=' ',ms=9) P.xlabel('Integration Time (Days)') P.ylabel('H Test Statistic') sig = r'>5\sigma' if hs[-1] > 50 else '%.1f\sigma'%(sig2sigma(h_sig(hs[-1]))) P.axhline(hs[-1],linestyle='-',color='red',label='$\mathrm{Aperture\ H=%.1f\ (%s)}$'%(hs[-1],sig),lw=2) if point_source is not None: P.axhline(hs[-1],linestyle='',color='green',label='$\mathrm{Weighted\ Test:\ %.1f\sigma}$'%(wsig),lw=2) P.plot(ts[1:],polyval(pfit,ts[1:]),linestyle='--',color='blue',label='$\mathrm{Linear\ Trend}$',lw=2) P.legend(loc=0) P.grid(b=True) if outfile is not None: P.savefig(outfile) #if show: P.show() def weighted_h(self,point_source,mc_iterations=1000): pp = PhotonProbability(max_radius=2) v,diffs,phs,ens = pp.get_probs(self.event_files,point_source,return_cols=['PULSE_PHASE','ENERGY']) lam = 1./N.mean( [h_statistic(N.random.rand(len(v)),v) for x in xrange(mc_iterations)] ) weighted_h = h_statistic(phs,v) sig = N.exp(-lam*weighted_h) h_equiv = sig2h(sig) sigma = sig2sigma(sig) return h_equiv,sigma def h_sig(h): """Convert the H-test statistic to a chance probability.""" if h <= 23: return 0.9999755*N.exp(-0.39802*h) if h > 50: return 4e-8 return 1.210597*N.exp(-0.45901*h + 0.0022900*h**2) def sig2h(sig): if sig <= 4e-8: return 50. if sig >= h_sig(23): return N.log(sig/0.9999755)/(-0.39802) def invhsig(x,*args): return h_sig(x) - args[0] from scipy.optimize import fsolve return fsolve(invhsig,[30],args=(sig,)) def sig2sigma(sig): from scipy.special import erfc,erfcinv if sig > 1e-15: return erfcinv(sig)*2**0.5 def inverfc(x,*args): return erfc(x/2**0.5)-args[0] from scipy.optimize import fsolve return fsolve(inverfc,[8],(sig,)) def sigma2sig(sigma): # this appears to handle up to machine precision with no problem from scipy.special import erfc return erfc(sigma/2**0.5) def sigma_trials(sigma,trials): # correct a sigmal value for a trials factor if sigma < 20: p = sigma2sig(sigma)*trials if p >= 1: return 0 return sig2sigma(p) else: # use an asymptotic expansion -- this needs to be checked! return (sigma**2 - 2*N.log(trials))**0.5 def z2m(phases,m=2): """ Return the Z_m^2 test for each harmonic up to the specified m.""" phases = N.asarray(phases)*TWOPI #phase in radians n = len(phases) if n < 5e3: #faster for 100s to 1000s of phases, but requires ~20x memory of alternative s = (N.cos(N.outer(N.arange(1,m+1),phases))).sum(axis=1)**2 +\ (N.sin(N.outer(N.arange(1,m+1),phases))).sum(axis=1)**2 else: s = (N.asarray([(N.cos(k*phases)).sum() for k in xrange(1,m+1)]))**2 +\ (N.asarray([(N.sin(k*phases)).sum() for k in xrange(1,m+1)]))**2 return 2./n*N.cumsum(s) def z2mw(phases,weights,m=2): """ Return the Z_m^2 test for each harmonic up to the specified m. The user provides a list of weights. In the case that they are well-distributed or assumed to be fixed, the CLT applies and the statistic remains calibrated. Nice! NB -- the phases must be uniformly distributed, i.e., have 0 mean and a variance of 0.5. Then, the 2nd central moment is just 0.5 * the expectation of the square of the weights. """ phases = N.asarray(phases)*(2*N.pi) #phase in radians s = (N.asarray([(N.cos(k*phases)*weights).sum() for k in xrange(1,m+1)]))**2 +\ (N.asarray([(N.sin(k*phases)*weights).sum() for k in xrange(1,m+1)]))**2 return N.cumsum(s) / (0.5*(weights**2).sum()) def em_four(phases,m=2,weights=None): """ Return the empirical Fourier coefficients up to the mth harmonic.""" phases = N.asarray(phases)*TWOPI #phase in radians n = len(phases) if weights is None else weights.sum() weights = 1. if weights is None else weights aks = (1./n)*N.asarray([(weights*N.cos(k*phases)).sum() for k in xrange(1,m+1)]) bks = (1./n)*N.asarray([(weights*N.sin(k*phases)).sum() for k in xrange(1,m+1)]) return aks,bks def em_lc(coeffs,dom): dom = N.asarray(dom)*(2*N.pi) aks,bks = coeffs rval = N.ones_like(dom) for i in xrange(1,len(aks)+1): rval += 2*(aks[i-1]*N.cos(i*dom) + bks[i-1]*N.sin(i*dom)) return rval def weighted_z1(phases,weights): """ Return the Z_1^2 test with weights.""" phases = N.asarray(phases)*(2*N.pi) #phase in radians a = ((N.cos(phases)*weights).sum())**2 b = ((N.sin(phases)*weights).sum())**2 return 2/weights.sum()*(a + b) def h_statistic(phases,m=20): phases = N.asarray(phases)*(2*N.pi) #phase in radians n = len(phases) if n < 5e3: #faster for 100s to 1000s of phases, but requires ~20x memory of alternative s = (N.cos(N.outer(N.arange(1,m+1),phases))).sum(axis=1)**2 +\ (N.sin(N.outer(N.arange(1,m+1),phases))).sum(axis=1)**2 else: s = (N.asarray([(N.cos(k*phases)).sum() for k in xrange(1,m+1)]))**2 +\ (N.asarray([(N.sin(k*phases)).sum() for k in xrange(1,m+1)]))**2 return (2./n*N.cumsum(s) - 4*N.arange(0,m)).max() def simple_h_statistic(phases): phases = N.asarray(phases)*(2*N.pi) #phase in radians n = len(phases) s = (N.asarray([(N.cos(k*phases)).sum() for k in xrange(1,21)]))**2 +\ (N.asarray([(N.sin(k*phases)).sum() for k in xrange(1,21)]))**2 return (2./n*N.cumsum(s) - 4*N.arange(0,20)).max() def weighted_h_statistic(phases,weights,m=20): phases = N.asarray(phases)*(2*N.pi) #phase in radians n = len(phases) s = (N.asarray([(weights*N.cos(k*phases)).sum() for k in xrange(1,m+1)]))**2 +\ (N.asarray([(weights*N.sin(k*phases)).sum() for k in xrange(1,m+1)]))**2 return ((2./(weights**2).sum())*N.cumsum(s) - 4*N.arange(0,m)).max()
-- Testing the version option on a file with errors. -- -- N.B. It is necessary to change the Issue1244a.out file when using -- different versions of Agda. foo : Set β†’ Set foo a = b
# # script, or "quip", to run the CIRQ # push!(LOAD_PATH, homedir()*"/projects/QuIPS/src") using QuIPS M₁ = Measurement(1) quip = [ (:X, 1), (:H, 1) ] QC = QCircuit(quip, 1) run!(QC) println(abs.(QC.wfn)) ψ, out = M₁(QC.wfn, QC.N) println("Measurement Result: ", out)