text
stringlengths 0
3.34M
|
---|
{-# LANGUAGE Rank2Types #-}
import Control.Monad.ST (RealWorld)
import Data.Complex (Complex)
import Data.Vector.Storable (MVector(MVector))
import Foreign (Ptr, Storable, withForeignPtr)
import Text.Printf (printf)
import Blas.Generic.Unsafe (Numeric)
import qualified Data.Vector.Storable as Vector
import qualified Blas.Primitive.Types as Blas
import qualified Blas.Generic.Unsafe as Blas
import qualified TestUtils as T
main :: IO ()
main = T.runTest $ do
sequence_ (mapNumericTypes testGemm)
mapNumericTypes :: (forall a. (Eq a, Numeric a, Show a) => a -> b) -> [b]
mapNumericTypes f =
[ f (dummy :: Float)
, f (dummy :: Double)
, f (dummy :: Complex Float)
, f (dummy :: Complex Double)
]
dummy :: a
dummy = error "dummy value that shouldn't be used"
withMVector :: MVector s a -> (Ptr a -> IO b) -> IO b
withMVector (MVector _ foreignPtr) = withForeignPtr foreignPtr
mVectorFromList :: Storable a => [a] -> IO (MVector RealWorld a)
mVectorFromList = Vector.thaw . Vector.fromList
testGemm :: (Eq a, Numeric a, Show a) => a -> T.Test ()
testGemm numType = do
let order = Blas.RowMajor
transa = Blas.NoTrans
transb = Blas.Trans
n = 2
size = n * n
alpha = 1.0 `asTypeOf` numType
beta = 0.0
a = Vector.fromList [1, 2, 3, 4]
b = Vector.fromList [1, 2, 3, 5]
expected = Vector.fromList [5, 13, 11, 29]
c' <- T.liftIO $ do
c <- mVectorFromList $ take size (repeat 0)
Vector.unsafeWith a $ \ pa ->
Vector.unsafeWith b $ \ pb ->
withMVector c $ \ pc ->
Blas.gemm order transa transb n n n alpha pa n pb n beta pc n
Vector.freeze c
if c' == expected
then T.passTest "testGemm"
else T.failTest $ printf "testGemm: c' does not match: %s != %s"
(show c') (show expected)
|
section\<open>Cofinality\label{sec:cofinality}\<close>
theory Cofinality
imports
ZF_Library
begin
subsection\<open>Basic results and definitions\<close>
text\<open>A set \<^term>\<open>X\<close> is \<^emph>\<open>cofinal\<close> in \<^term>\<open>A\<close> (with respect to the relation
\<^term>\<open>r\<close>) if every element of \<^term>\<open>A\<close> is “bounded
above” by some element of \<^term>\<open>X\<close>. Note that \<^term>\<open>X\<close> does not need
to be a subset of \<^term>\<open>A\<close>.\<close>
definition
cofinal :: "[i,i,i] \<Rightarrow> o" where
"cofinal(X,A,r) \<equiv> \<forall>a\<in>A. \<exists>x\<in>X. \<langle>a,x\<rangle>\<in>r \<or> a = x"
(*
(* Alternative definitions *)
definition
cofinal_predic :: "[i,i,[i,i]\<Rightarrow>o] \<Rightarrow> o" where
"cofinal_predic(X,A,r) \<equiv> \<forall>a\<in>A. \<exists>x\<in>X. r(a,x) \<or> a = x"
definition
f_cofinal :: "[i\<Rightarrow>i,i,i,i] \<Rightarrow> o" where
"f_cofinal(f,C,A,r) \<equiv> \<forall>a\<in>A. \<exists>x\<in>C. \<langle>a,f(x)\<rangle>\<in>r \<or> a = f(x)"
(* The next definition doesn't work if 0 is the top element of A.
But it works for limit ordinals. *)
definition
cofinal_fun' :: "[i,i,i] \<Rightarrow> o" where
"cofinal_fun'(f,A,r) == f_cofinal(\<lambda>x. f`x,domain(f),A, r)"
*)
text\<open>A function is cofinal if it range is.\<close>
definition
cofinal_fun :: "[i,i,i] \<Rightarrow> o" where
"cofinal_fun(f,A,r) \<equiv> \<forall>a\<in>A. \<exists>x\<in>domain(f). \<langle>a,f`x\<rangle>\<in>r \<or> a = f`x"
lemma cofinal_funI:
assumes "\<And>a. a\<in>A \<Longrightarrow> \<exists>x\<in>domain(f). \<langle>a,f`x\<rangle>\<in>r \<or> a = f`x"
shows "cofinal_fun(f,A,r)"
using assms unfolding cofinal_fun_def by simp
lemma cofinal_funD:
assumes "cofinal_fun(f,A,r)" "a\<in>A"
shows "\<exists>x\<in>domain(f). \<langle>a,f`x\<rangle>\<in>r \<or> a = f`x"
using assms unfolding cofinal_fun_def by simp
lemma cofinal_in_cofinal:
assumes
"trans(r)" "cofinal(Y,X,r)" "cofinal(X,A,r)"
shows
"cofinal(Y,A,r)"
unfolding cofinal_def
proof
fix a
assume "a\<in>A"
moreover from \<open>cofinal(X,A,r)\<close>
have "b\<in>A\<Longrightarrow>\<exists>x\<in>X. \<langle>b,x\<rangle>\<in>r \<or> b=x" for b
unfolding cofinal_def by simp
ultimately
obtain y where "y\<in>X" "\<langle>a,y\<rangle>\<in>r \<or> a=y" by auto
moreover from \<open>cofinal(Y,X,r)\<close>
have "c\<in>X\<Longrightarrow>\<exists>y\<in>Y. \<langle>c,y\<rangle>\<in>r \<or> c=y" for c
unfolding cofinal_def by simp
ultimately
obtain x where "x\<in>Y" "\<langle>y,x\<rangle>\<in>r \<or> y=x" by auto
with \<open>a\<in>A\<close> \<open>y\<in>X\<close> \<open>\<langle>a,y\<rangle>\<in>r \<or> a=y\<close> \<open>trans(r)\<close>
show "\<exists>x\<in>Y. \<langle>a,x\<rangle>\<in>r \<or> a=x" unfolding trans_def by auto
qed
lemma codomain_is_cofinal:
assumes "cofinal_fun(f,A,r)" "f:C \<rightarrow> D"
shows "cofinal(D,A,r)"
unfolding cofinal_def
proof
fix b
assume "b \<in> A"
moreover from assms
have "a\<in>A \<Longrightarrow> \<exists>x\<in>domain(f). \<langle>a, f ` x\<rangle> \<in> r \<or> a = f`x" for a
unfolding cofinal_fun_def by simp
ultimately
obtain x where "x\<in>domain(f)" "\<langle>b, f ` x\<rangle> \<in> r \<or> b = f`x"
by blast
moreover from \<open>f:C \<rightarrow> D\<close> \<open>x\<in>domain(f)\<close>
have "f`x\<in>D"
using domain_of_fun apply_rangeI by simp
ultimately
show "\<exists>y\<in>D. \<langle>b, y\<rangle> \<in> r \<or> b = y" by auto
qed
lemma cofinal_range_iff_cofinal_fun:
assumes "function(f)"
shows "cofinal(range(f),A,r) \<longleftrightarrow> cofinal_fun(f,A,r)"
unfolding cofinal_fun_def
proof (intro iffI ballI)
fix a
assume "a\<in>A" \<open>cofinal(range(f),A,r)\<close>
then
obtain y where "y\<in>range(f)" "\<langle>a,y\<rangle> \<in> r \<or> a = y"
unfolding cofinal_def by blast
moreover from this
obtain x where "\<langle>x,y\<rangle>\<in>f"
unfolding range_def domain_def converse_def by blast
moreover
note \<open>function(f)\<close>
ultimately
have "\<langle>a, f ` x\<rangle> \<in> r \<or> a = f ` x"
using function_apply_equality by blast
with \<open>\<langle>x,y\<rangle>\<in>f\<close>
show "\<exists>x\<in>domain(f). \<langle>a, f ` x\<rangle> \<in> r \<or> a = f ` x" by blast
next
assume "\<forall>a\<in>A. \<exists>x\<in>domain(f). \<langle>a, f ` x\<rangle> \<in> r \<or> a = f ` x"
with assms
show "cofinal(range(f), A, r)"
using function_apply_Pair[of f] unfolding cofinal_def by fast
qed
lemma cofinal_comp:
assumes
"f\<in> mono_map(C,s,D,r)" "cofinal_fun(f,D,r)" "h:B \<rightarrow> C" "cofinal_fun(h,C,s)"
"trans(r)"
shows "cofinal_fun(f O h,D,r)"
unfolding cofinal_fun_def
proof
fix a
from \<open>f\<in> mono_map(C,s,D,r)\<close>
have "f:C \<rightarrow> D"
using mono_map_is_fun by simp
with \<open>h:B \<rightarrow> C\<close>
have "domain(f) = C" "domain(h) = B"
using domain_of_fun by simp_all
moreover
assume "a \<in> D"
moreover
note \<open>cofinal_fun(f,D,r)\<close>
ultimately
obtain c where "c\<in>C" "\<langle>a, f ` c\<rangle> \<in> r \<or> a = f ` c"
unfolding cofinal_fun_def by blast
with \<open>cofinal_fun(h,C,s)\<close> \<open>domain(h) = B\<close>
obtain b where "b \<in> B" "\<langle>c, h ` b\<rangle> \<in> s \<or> c = h ` b"
unfolding cofinal_fun_def by blast
moreover from this and \<open>h:B \<rightarrow> C\<close>
have "h`b \<in> C" by simp
moreover
note \<open>f \<in> mono_map(C,s,D,r)\<close> \<open>c\<in>C\<close>
ultimately
have "\<langle>f`c, f` (h ` b)\<rangle> \<in> r \<or> f`c = f` (h ` b)"
unfolding mono_map_def by blast
with \<open>\<langle>a, f ` c\<rangle> \<in> r \<or> a = f ` c\<close> \<open>trans(r)\<close> \<open>h:B \<rightarrow> C\<close> \<open>b\<in>B\<close>
have "\<langle>a, (f O h) ` b\<rangle> \<in> r \<or> a = (f O h) ` b"
using transD by auto
moreover from \<open>h:B \<rightarrow> C\<close> \<open>domain(f) = C\<close> \<open>domain(h) = B\<close>
have "domain(f O h) = B"
using range_fun_subset_codomain by blast
moreover
note \<open>b\<in>B\<close>
ultimately
show "\<exists>x\<in>domain(f O h). \<langle>a, (f O h) ` x\<rangle> \<in> r \<or> a = (f O h) ` x" by blast
qed
definition
cf_fun :: "[i,i] \<Rightarrow> o" where
"cf_fun(f,\<alpha>) \<equiv> cofinal_fun(f,\<alpha>,Memrel(\<alpha>))"
lemma cf_funI[intro!]: "cofinal_fun(f,\<alpha>,Memrel(\<alpha>)) \<Longrightarrow> cf_fun(f,\<alpha>)"
unfolding cf_fun_def by simp
lemma cf_funD[dest!]: "cf_fun(f,\<alpha>) \<Longrightarrow> cofinal_fun(f,\<alpha>,Memrel(\<alpha>))"
unfolding cf_fun_def by simp
lemma cf_fun_comp:
assumes
"Ord(\<alpha>)" "f\<in> mono_map(C,s,\<alpha>,Memrel(\<alpha>))" "cf_fun(f,\<alpha>)"
"h:B \<rightarrow> C" "cofinal_fun(h,C,s)"
shows "cf_fun(f O h,\<alpha>)"
using assms cofinal_comp[OF _ _ _ _ trans_Memrel] by auto
definition
cf :: "i\<Rightarrow>i" where
"cf(\<gamma>) \<equiv> \<mu> \<beta>. \<exists>A. A\<subseteq>\<gamma> \<and> cofinal(A,\<gamma>,Memrel(\<gamma>)) \<and> \<beta> = ordertype(A,Memrel(\<gamma>))"
lemma Ord_cf [TC]: "Ord(cf(\<beta>))"
unfolding cf_def using Ord_Least by simp
lemma gamma_cofinal_gamma:
assumes "Ord(\<gamma>)"
shows "cofinal(\<gamma>,\<gamma>,Memrel(\<gamma>))"
unfolding cofinal_def by auto
lemma cf_is_ordertype:
assumes "Ord(\<gamma>)"
shows "\<exists>A. A\<subseteq>\<gamma> \<and> cofinal(A,\<gamma>,Memrel(\<gamma>)) \<and> cf(\<gamma>) = ordertype(A,Memrel(\<gamma>))"
(is "?P(cf(\<gamma>))")
using gamma_cofinal_gamma LeastI[of ?P \<gamma>] ordertype_Memrel[symmetric] assms
unfolding cf_def by blast
lemma cf_fun_succ':
assumes "Ord(\<beta>)" "Ord(\<alpha>)" "f:\<alpha>\<rightarrow>succ(\<beta>)"
shows "(\<exists>x\<in>\<alpha>. f`x=\<beta>) \<longleftrightarrow> cf_fun(f,succ(\<beta>))"
proof (intro iffI)
assume "(\<exists>x\<in>\<alpha>. f`x=\<beta>)"
with assms
show "cf_fun(f,succ(\<beta>))"
using domain_of_fun[OF \<open>f:\<alpha>\<rightarrow>succ(\<beta>)\<close>]
unfolding cf_fun_def cofinal_fun_def by auto
next
assume "cf_fun(f,succ(\<beta>))"
with assms
obtain x where "x\<in>\<alpha>" "\<langle>\<beta>,f`x\<rangle> \<in> Memrel(succ(\<beta>)) \<or> \<beta> = f ` x"
using domain_of_fun[OF \<open>f:\<alpha>\<rightarrow>succ(\<beta>)\<close>]
unfolding cf_fun_def cofinal_fun_def by auto
moreover from \<open>Ord(\<beta>)\<close>
have "\<langle>\<beta>,y\<rangle> \<notin> Memrel(succ(\<beta>))" for y
using foundation unfolding Memrel_def by blast
ultimately
show "\<exists>x\<in>\<alpha>. f ` x = \<beta>" by blast
qed
lemma cf_fun_succ:
"Ord(\<beta>) \<Longrightarrow> f:1\<rightarrow>succ(\<beta>) \<Longrightarrow> f`0=\<beta> \<Longrightarrow> cf_fun(f,succ(\<beta>))"
using cf_fun_succ' by blast
lemma ordertype_0_not_cofinal_succ:
assumes "ordertype(A,Memrel(succ(i))) = 0" "A\<subseteq>succ(i)" "Ord(i)"
shows "\<not>cofinal(A,succ(i),Memrel(succ(i)))"
proof
have 1:"ordertype(A,Memrel(succ(i))) = ordertype(0,Memrel(0))"
using \<open>ordertype(A,Memrel(succ(i))) = 0\<close> ordertype_0 by simp
from \<open>A\<subseteq>succ(i)\<close> \<open>Ord(i)\<close>
have "\<exists>f. f \<in> \<langle>A, Memrel(succ(i))\<rangle> \<cong> \<langle>0, Memrel(0)\<rangle>"
using well_ord_Memrel well_ord_subset
ordertype_eq_imp_ord_iso[OF 1] Ord_0 by blast
then
have "A=0"
using ord_iso_is_bij bij_imp_eqpoll eqpoll_0_is_0 by blast
moreover
assume "cofinal(A, succ(i), Memrel(succ(i)))"
moreover
note \<open>Ord(i)\<close>
ultimately
show "False"
using not_mem_empty unfolding cofinal_def by auto
qed
text\<open>I thank Edwin Pacheco Rodríguez for the following lemma.\<close>
lemma cf_succ:
assumes "Ord(\<alpha>)"
shows "cf(succ(\<alpha>)) = 1"
proof -
define f where "f \<equiv> {\<langle>0,\<alpha>\<rangle>}"
then
have "f : 1\<rightarrow>succ(\<alpha>)" "f`0 = \<alpha>"
using fun_extend3[of 0 0 "succ(\<alpha>)" 0 \<alpha>] singleton_0 by auto
with assms
have "cf_fun(f,succ(\<alpha>))"
using cf_fun_succ unfolding cofinal_fun_def by simp
from \<open>f:1\<rightarrow>succ(\<alpha>)\<close>
have "0\<in>domain(f)" using domain_of_fun by simp
define A where "A={f`0}"
with \<open>cf_fun(f,succ(\<alpha>))\<close> \<open>0\<in>domain(f)\<close> \<open>f`0=\<alpha>\<close>
have "cofinal(A,succ(\<alpha>),Memrel(succ(\<alpha>)))"
unfolding cofinal_def cofinal_fun_def by simp
moreover from \<open>f`0=\<alpha>\<close> \<open>A={f`0}\<close>
have "A \<subseteq> succ(\<alpha>)" unfolding succ_def by auto
moreover from \<open>Ord(\<alpha>)\<close> \<open>A\<subseteq> succ(\<alpha>)\<close>
have "well_ord(A,Memrel(succ(\<alpha>)))"
using Ord_succ well_ord_Memrel well_ord_subset relation_Memrel by blast
moreover from \<open>Ord(\<alpha>)\<close>
have "\<not>(\<exists>A. A \<subseteq> succ(\<alpha>) \<and> cofinal(A, succ(\<alpha>), Memrel(succ(\<alpha>))) \<and> 0 = ordertype(A, Memrel(succ(\<alpha>))))"
(is "\<not>?P(0)")
using ordertype_0_not_cofinal_succ unfolding cf_def by auto
moreover
have "1 = ordertype(A,Memrel(succ(\<alpha>)))"
proof -
from \<open>A={f`0}\<close>
have "A\<approx>1" using singleton_eqpoll_1 by simp
with \<open>well_ord(A,Memrel(succ(\<alpha>)))\<close>
show ?thesis using nat_1I ordertype_eq_n by simp
qed
ultimately
show "cf(succ(\<alpha>)) = 1" using Ord_1 Least_equality[of ?P 1]
unfolding cf_def by blast
qed
lemma cf_zero [simp]:
"cf(0) = 0"
unfolding cf_def cofinal_def using
ordertype_0 subset_empty_iff Least_le[of _ 0] by auto
lemma surj_is_cofinal: "f \<in> surj(\<delta>,\<gamma>) \<Longrightarrow> cf_fun(f,\<gamma>)"
unfolding surj_def cofinal_fun_def cf_fun_def
using domain_of_fun by force
lemma cf_zero_iff: "Ord(\<alpha>) \<Longrightarrow> cf(\<alpha>) = 0 \<longleftrightarrow> \<alpha> = 0"
proof (intro iffI)
assume "\<alpha> = 0" "Ord(\<alpha>)"
then
show "cf(\<alpha>) = 0" using cf_zero by simp
next
assume "cf(\<alpha>) = 0" "Ord(\<alpha>)"
moreover from this
obtain A where "A\<subseteq>\<alpha>" "cf(\<alpha>) = ordertype(A,Memrel(\<alpha>))"
"cofinal(A,\<alpha>,Memrel(\<alpha>))"
using cf_is_ordertype by blast
ultimately
have "cofinal(0,\<alpha>,Memrel(\<alpha>))"
using ordertype_zero_imp_zero[of A "Memrel(\<alpha>)"] by simp
then
show "\<alpha>=0"
unfolding cofinal_def by blast
qed
\<comment> \<open>TODO: define Succ (predicate for successor ordinals)\<close>
lemma cf_eq_one_iff:
assumes "Ord(\<gamma>)"
shows "cf(\<gamma>) = 1 \<longleftrightarrow> (\<exists>\<alpha>. Ord(\<alpha>) \<and> \<gamma> = succ(\<alpha>))"
proof (intro iffI)
assume "\<exists>\<alpha>. Ord(\<alpha>) \<and> \<gamma> = succ(\<alpha>)"
then
show "cf(\<gamma>) = 1" using cf_succ by auto
next
assume "cf(\<gamma>) = 1"
moreover from assms
obtain A where "A \<subseteq> \<gamma>" "cf(\<gamma>) = ordertype(A,Memrel(\<gamma>))"
"cofinal(A,\<gamma>,Memrel(\<gamma>))"
using cf_is_ordertype by blast
ultimately
have "ordertype(A,Memrel(\<gamma>)) = 1" by simp
moreover
define f where "f\<equiv>converse(ordermap(A,Memrel(\<gamma>)))"
moreover from this \<open>ordertype(A,Memrel(\<gamma>)) = 1\<close> \<open>A \<subseteq> \<gamma>\<close> assms
have "f \<in> surj(1,A)"
using well_ord_subset[OF well_ord_Memrel, THEN ordermap_bij,
THEN bij_converse_bij, of \<gamma> A] bij_is_surj
by simp
with \<open>cofinal(A,\<gamma>,Memrel(\<gamma>))\<close>
have "\<forall>a\<in>\<gamma>. \<langle>a, f`0\<rangle> \<in> Memrel(\<gamma>) \<or> a = f`0"
unfolding cofinal_def surj_def
by auto
with assms \<open>A \<subseteq> \<gamma>\<close> \<open>f \<in> surj(1,A)\<close>
show "\<exists>\<alpha>. Ord(\<alpha>) \<and> \<gamma> = succ(\<alpha>)"
using Ord_has_max_imp_succ[of \<gamma> "f`0"]
surj_is_fun[of f 1 A] apply_type[of f 1 "\<lambda>_.A" 0]
unfolding lt_def
by (auto intro:Ord_in_Ord)
qed
lemma ordertype_in_cf_imp_not_cofinal:
assumes
"ordertype(A,Memrel(\<gamma>)) \<in> cf(\<gamma>)"
"A \<subseteq> \<gamma>"
shows
"\<not> cofinal(A,\<gamma>,Memrel(\<gamma>))"
proof
note \<open>A \<subseteq> \<gamma>\<close>
moreover
assume "cofinal(A,\<gamma>,Memrel(\<gamma>))"
ultimately
have "\<exists>B. B \<subseteq> \<gamma> \<and> cofinal(B, \<gamma>, Memrel(\<gamma>)) \<and> ordertype(A,Memrel(\<gamma>)) = ordertype(B, Memrel(\<gamma>))"
(is "?P(ordertype(A,_))")
by blast
moreover from assms
have "ordertype(A,Memrel(\<gamma>)) < cf(\<gamma>)"
using Ord_cf ltI by blast
ultimately
show "False"
unfolding cf_def using less_LeastE[of ?P "ordertype(A,Memrel(\<gamma>))"]
by auto
qed
lemma cofinal_mono_map_cf:
assumes "Ord(\<gamma>)"
shows "\<exists>j \<in> mono_map(cf(\<gamma>), Memrel(cf(\<gamma>)), \<gamma>, Memrel(\<gamma>)) . cf_fun(j,\<gamma>)"
proof -
note assms
moreover from this
obtain A where "A \<subseteq> \<gamma>" "cf(\<gamma>) = ordertype(A,Memrel(\<gamma>))"
"cofinal(A,\<gamma>,Memrel(\<gamma>))"
using cf_is_ordertype by blast
moreover
define j where "j \<equiv> converse(ordermap(A,Memrel(\<gamma>)))"
moreover from calculation
have "j :cf(\<gamma>) \<rightarrow>\<^sub>< \<gamma>"
using ordertype_ord_iso[THEN ord_iso_sym,
THEN ord_iso_is_mono_map, THEN mono_map_mono,
of A "Memrel(\<gamma>)" \<gamma>] well_ord_Memrel[THEN well_ord_subset]
by simp
moreover from calculation
have "j \<in> surj(cf(\<gamma>),A)"
using well_ord_Memrel[THEN well_ord_subset, THEN ordertype_ord_iso,
THEN ord_iso_sym, of \<gamma> A, THEN ord_iso_is_bij,
THEN bij_is_surj]
by simp
with \<open>cofinal(A,\<gamma>,Memrel(\<gamma>))\<close>
have "cf_fun(j,\<gamma>)"
using cofinal_range_iff_cofinal_fun[of j \<gamma> "Memrel(\<gamma>)"]
surj_range[of j "cf(\<gamma>)" A] surj_is_fun fun_is_function
by fastforce
with \<open>j \<in> mono_map(_,_,_,_)\<close>
show ?thesis by auto
qed
subsection\<open>The factorization lemma\<close>
text\<open>In this subsection we prove a factorization lemma for cofinal functions
into ordinals, which shows that any cofinal function between ordinals can be
“decomposed” in such a way that a commutative triangle of strictly increasing
maps arises.
The factorization lemma has a kind of
fundamental character, in that the rest of the basic results on cofinality
(for, instance, idempotence) follow easily from it, in a more algebraic way.
This is a consequence that the proof encapsulates uses of transfinite
recursion in the basic theory of cofinality; indeed, only one use is needed.
In the setting of Isabelle/ZF, this is convenient since the machinery of
recursion is pretty clumsy. On the downside, this way of presenting things
results in a longer proof of the factorization lemma. This approach was
taken by the author in the notes \cite{apunte_st} for an introductory course
in Set Theory.
To organize the use of the hypotheses of the factorization lemma,
we set up a locale containing all the relevant ingredients.
\<close>
locale cofinal_factor =
fixes j \<delta> \<xi> \<gamma> f
assumes j_mono: "j :\<xi> \<rightarrow>\<^sub>< \<gamma>"
and ords: "Ord(\<delta>)" "Ord(\<xi>)" "Limit(\<gamma>)"
and f_type: "f: \<delta> \<rightarrow> \<gamma>"
begin
text\<open>Here, \<^term>\<open>f\<close> is cofinal function from \<^term>\<open>\<delta>\<close> to \<^term>\<open>\<gamma>\<close>, and the
ordinal \<^term>\<open>\<xi>\<close> is meant to be the cofinality of \<^term>\<open>\<gamma>\<close>. Hence, there exists
an increasing map \<^term>\<open>j\<close> from \<^term>\<open>\<xi>\<close> to \<^term>\<open>\<gamma>\<close> by the last lemma.
The main goal is to construct an increasing function \<^term>\<open>g:\<xi>\<rightarrow>\<delta>\<close> such that
the composition \<^term>\<open>f O g\<close> is still cofinal but also increasing.\<close>
definition
factor_body :: "[i,i,i] \<Rightarrow> o" where
"factor_body(\<beta>,h,x) \<equiv> (x\<in>\<delta> \<and> j`\<beta> \<le> f`x \<and> (\<forall>\<alpha><\<beta> . f`(h`\<alpha>) < f`x)) \<or> x=\<delta>"
definition
factor_rec :: "[i,i] \<Rightarrow> i" where
"factor_rec(\<beta>,h) \<equiv> \<mu> x. factor_body(\<beta>,h,x)"
txt\<open>\<^term>\<open>factor_rec\<close> is the inductive step for the definition by transfinite
recursion of the \<^emph>\<open>factor\<close> function (called \<^term>\<open>g\<close> above), which in
turn is obtained by minimizing the predicate \<^term>\<open>factor_body\<close>. Next we show
that this predicate is monotonous.\<close>
lemma factor_body_mono:
assumes
"\<beta>\<in>\<xi>" "\<alpha><\<beta>"
"factor_body(\<beta>,\<lambda>x\<in>\<beta>. G(x),x)"
shows
"factor_body(\<alpha>,\<lambda>x\<in>\<alpha>. G(x),x)"
proof -
from \<open>\<alpha><\<beta>\<close>
have "\<alpha>\<in>\<beta>" using ltD by simp
moreover
note \<open>\<beta>\<in>\<xi>\<close>
moreover from calculation
have "\<alpha>\<in>\<xi>" using ords ltD Ord_cf Ord_trans by blast
ultimately
have "j`\<alpha> \<in> j`\<beta>" using j_mono mono_map_increasing by blast
moreover from \<open>\<beta>\<in>\<xi>\<close>
have "j`\<beta>\<in>\<gamma>"
using j_mono domain_of_fun apply_rangeI mono_map_is_fun by force
moreover from this
have "Ord(j`\<beta>)"
using Ord_in_Ord ords Limit_is_Ord by auto
ultimately
have "j`\<alpha> \<le> j`\<beta>" unfolding lt_def by blast
then
have "j`\<beta> \<le> f`\<theta> \<Longrightarrow> j`\<alpha> \<le> f`\<theta>" for \<theta> using le_trans by blast
moreover
have "f`((\<lambda>w\<in>\<alpha>. G(w))`y) < f`z" if "z\<in>\<delta>" "\<forall>x<\<beta>. f`((\<lambda>w\<in>\<beta>. G(w))`x) < f`z" "y<\<alpha>" for y z
proof -
note \<open>y<\<alpha>\<close>
also
note \<open>\<alpha><\<beta>\<close>
finally
have "y<\<beta>" by simp
with \<open>\<forall>x<\<beta>. f`((\<lambda>w\<in>\<beta>. G(w))`x) < f`z\<close>
have "f ` ((\<lambda>w\<in>\<beta>. G(w)) ` y) < f ` z" by simp
moreover from \<open>y<\<alpha>\<close> \<open>y<\<beta>\<close>
have "(\<lambda>w\<in>\<beta>. G(w)) ` y = (\<lambda>w\<in>\<alpha>. G(w)) ` y"
using beta_if by (auto dest:ltD)
ultimately show ?thesis by simp
qed
moreover
note \<open>factor_body(\<beta>,\<lambda>x\<in>\<beta>. G(x),x)\<close>
ultimately
show ?thesis
unfolding factor_body_def by blast
qed
lemma factor_body_simp[simp]: "factor_body(\<alpha>,g,\<delta>)"
unfolding factor_body_def by simp
lemma factor_rec_mono:
assumes
"\<beta>\<in>\<xi>" "\<alpha><\<beta>"
shows
"factor_rec(\<alpha>,\<lambda>x\<in>\<alpha>. G(x)) \<le> factor_rec(\<beta>,\<lambda>x\<in>\<beta>. G(x))"
unfolding factor_rec_def
using assms ords factor_body_mono Least_antitone by simp
text\<open>We now define the factor as higher-order function.
Later it will be restricted to a set to obtain a bona fide function of
type @{typ i}.\<close>
definition
factor :: "i \<Rightarrow> i" where
"factor(\<beta>) \<equiv> transrec(\<beta>,factor_rec)"
lemma factor_unfold:
"factor(\<alpha>) = factor_rec(\<alpha>,\<lambda>x\<in>\<alpha>. factor(x))"
using def_transrec[OF factor_def] .
lemma factor_mono:
assumes "\<beta>\<in>\<xi>" "\<alpha><\<beta>" "factor(\<alpha>)\<noteq>\<delta>" "factor(\<beta>)\<noteq>\<delta>"
shows "factor(\<alpha>) \<le> factor(\<beta>)"
proof -
have "factor(\<alpha>) = factor_rec(\<alpha>, \<lambda>x\<in>\<alpha>. factor(x))"
using factor_unfold .
also from assms and factor_rec_mono
have "... \<le> factor_rec(\<beta>, \<lambda>x\<in>\<beta>. factor(x))"
by simp
also
have "factor_rec(\<beta>, \<lambda>x\<in>\<beta>. factor(x)) = factor(\<beta>)"
using def_transrec[OF factor_def, symmetric] .
finally show ?thesis .
qed
text\<open>The factor satisfies the predicate body of the minimization.\<close>
lemma factor_body_factor:
"factor_body(\<alpha>,\<lambda>x\<in>\<alpha>. factor(x),factor(\<alpha>))"
using ords factor_unfold[of \<alpha>]
LeastI[of "factor_body(_,_)" \<delta>]
unfolding factor_rec_def by simp
lemma factor_type [TC]: "Ord(factor(\<alpha>))"
using ords factor_unfold[of \<alpha>]
unfolding factor_rec_def by simp
text\<open>The value \<^term>\<open>\<delta>\<close> in \<^term>\<open>factor_body\<close> (and therefore, in
\<^term>\<open>factor\<close>) is meant to be a “default value”. Whenever it is not
attained, the factor function behaves as expected: It is increasing
and its composition with \<^term>\<open>f\<close> also is.\<close>
lemma f_factor_increasing:
assumes "\<beta>\<in>\<xi>" "\<alpha><\<beta>" "factor(\<beta>)\<noteq>\<delta>"
shows "f`factor(\<alpha>) < f`factor(\<beta>)"
proof -
from assms
have "f ` ((\<lambda>x\<in>\<beta>. factor(x)) ` \<alpha>) < f ` factor(\<beta>)"
using factor_unfold[of \<beta>] ords LeastI[of "factor_body(\<beta>,\<lambda>x\<in>\<beta>. factor(x))"]
unfolding factor_rec_def factor_body_def
by (auto simp del:beta_if)
with \<open>\<alpha><\<beta>\<close>
show ?thesis using ltD by auto
qed
lemma factor_increasing:
assumes "\<beta>\<in>\<xi>" "\<alpha><\<beta>" "factor(\<alpha>)\<noteq>\<delta>" "factor(\<beta>)\<noteq>\<delta>"
shows "factor(\<alpha>)<factor(\<beta>)"
using assms f_factor_increasing factor_mono by (force intro:le_neq_imp_lt)
lemma factor_in_delta:
assumes "factor(\<beta>) \<noteq> \<delta>"
shows "factor(\<beta>) \<in> \<delta>"
using assms factor_body_factor ords
unfolding factor_body_def by auto
text\<open>Finally, we define the (set) factor function as the restriction of
factor to the ordinal \<^term>\<open>\<xi>\<close>.\<close>
definition
fun_factor :: "i" where
"fun_factor \<equiv> \<lambda>\<beta>\<in>\<xi>. factor(\<beta>)"
lemma fun_factor_is_mono_map:
assumes "\<And>\<beta>. \<beta> \<in> \<xi> \<Longrightarrow> factor(\<beta>) \<noteq> \<delta>"
shows "fun_factor \<in> mono_map(\<xi>, Memrel(\<xi>), \<delta>, Memrel(\<delta>))"
unfolding mono_map_def
proof (intro CollectI ballI impI)
(* Proof that \<^term>\<open>fun_factor\<close> respects membership *)
fix \<alpha> \<beta>
assume "\<alpha>\<in>\<xi>" "\<beta>\<in>\<xi>"
moreover
note assms
moreover from calculation
have "factor(\<alpha>)\<noteq>\<delta>" "factor(\<beta>)\<noteq>\<delta>" "Ord(\<beta>)"
using factor_in_delta Ord_in_Ord ords by auto
moreover
assume "\<langle>\<alpha>, \<beta>\<rangle> \<in> Memrel(\<xi>)"
ultimately
show "\<langle>fun_factor ` \<alpha>, fun_factor ` \<beta>\<rangle> \<in> Memrel(\<delta>)"
unfolding fun_factor_def
using ltI factor_increasing[THEN ltD] factor_in_delta
by simp
next
(* Proof of type *)
from assms
show "fun_factor : \<xi> \<rightarrow> \<delta>"
unfolding fun_factor_def
using ltI lam_type factor_in_delta by simp
qed
lemma f_fun_factor_is_mono_map:
assumes "\<And>\<beta>. \<beta> \<in> \<xi> \<Longrightarrow> factor(\<beta>) \<noteq> \<delta>"
shows "f O fun_factor \<in> mono_map(\<xi>, Memrel(\<xi>), \<gamma>, Memrel(\<gamma>))"
unfolding mono_map_def
using f_type
proof (intro CollectI ballI impI comp_fun[of _ _ \<delta>])
from assms
show "fun_factor : \<xi> \<rightarrow> \<delta>"
using fun_factor_is_mono_map mono_map_is_fun by simp
(* Proof that f O ?g respects membership *)
fix \<alpha> \<beta>
assume "\<langle>\<alpha>, \<beta>\<rangle> \<in> Memrel(\<xi>)"
then
have "\<alpha><\<beta>"
using Ord_in_Ord[of "\<xi>"] ltI ords by blast
assume "\<alpha>\<in>\<xi>" "\<beta>\<in>\<xi>"
moreover from this and assms
have "factor(\<alpha>)\<noteq>\<delta>" "factor(\<beta>)\<noteq>\<delta>" by auto
moreover
have "Ord(\<gamma>)" "\<gamma>\<noteq>0" using ords Limit_is_Ord by auto
moreover
note \<open>\<alpha><\<beta>\<close> \<open>fun_factor : \<xi> \<rightarrow> \<delta>\<close>
ultimately
show "\<langle>(f O fun_factor) ` \<alpha>, (f O fun_factor) ` \<beta>\<rangle> \<in> Memrel(\<gamma>)"
using ltD[of "f ` factor(\<alpha>)" "f ` factor(\<beta>)"]
f_factor_increasing apply_in_range f_type
unfolding fun_factor_def by auto
qed
end (* cofinal_factor *)
text\<open>We state next the factorization lemma.\<close>
lemma cofinal_fun_factorization:
notes le_imp_subset [dest] lt_trans2 [trans]
assumes
"Ord(\<delta>)" "Limit(\<gamma>)" "f: \<delta> \<rightarrow> \<gamma>" "cf_fun(f,\<gamma>)"
shows
"\<exists>g \<in> cf(\<gamma>) \<rightarrow>\<^sub>< \<delta>. f O g : cf(\<gamma>) \<rightarrow>\<^sub>< \<gamma> \<and>
cofinal_fun(f O g,\<gamma>,Memrel(\<gamma>))"
proof -
from \<open>Limit(\<gamma>)\<close>
have "Ord(\<gamma>)" using Limit_is_Ord by simp
then
obtain j where "j :cf(\<gamma>) \<rightarrow>\<^sub>< \<gamma>" "cf_fun(j,\<gamma>)"
using cofinal_mono_map_cf by blast
then
have "domain(j) = cf(\<gamma>)"
using domain_of_fun mono_map_is_fun by force
from \<open>j \<in> _\<close> assms
interpret cofinal_factor j \<delta> "cf(\<gamma>)"
by (unfold_locales) (simp_all)
text\<open>The core of the argument is to show that the factor function
indeed maps into \<^term>\<open>\<delta>\<close>, therefore its values satisfy the first
disjunct of \<^term>\<open>factor_body\<close>. This holds in turn because no
restriction of the factor composed with \<^term>\<open>f\<close> to a proper initial
segment of \<^term>\<open>cf(\<gamma>)\<close> can be cofinal in \<^term>\<open>\<gamma>\<close> by definition of
cofinality. Hence there must be a witness that satisfies the first
disjunct.\<close>
have factor_not_delta: "factor(\<beta>)\<noteq>\<delta>" if "\<beta> \<in> cf(\<gamma>)" for \<beta>
text\<open>For this, we induct on \<^term>\<open>\<beta>\<close> ranging over \<^term>\<open>cf(\<gamma>)\<close>.\<close>
proof (induct \<beta> rule:Ord_induct[OF _ Ord_cf[of \<gamma>]])
case 1 with that show ?case .
next
case (2 \<beta>)
then
have IH: "z\<in>\<beta> \<Longrightarrow> factor(z)\<noteq>\<delta>" for z by simp
define h where "h \<equiv> \<lambda>x\<in>\<beta>. f`factor(x)"
from IH
have "z\<in>\<beta> \<Longrightarrow> factor(z) \<in> \<delta>" for z
using factor_in_delta by blast
with \<open>f:\<delta>\<rightarrow>\<gamma>\<close>
have "h : \<beta> \<rightarrow> \<gamma>" unfolding h_def using apply_funtype lam_type by auto
then
have "h : \<beta> \<rightarrow>\<^sub>< \<gamma>"
unfolding mono_map_def
proof (intro CollectI ballI impI)
fix x y
assume "x\<in>\<beta>" "y\<in>\<beta>"
moreover from this and IH
have "factor(y) \<noteq> \<delta>" by simp
moreover from calculation and \<open>h \<in> \<beta> \<rightarrow> \<gamma>\<close>
have "h`x \<in> \<gamma>" "h`y \<in> \<gamma>" by simp_all
moreover from \<open>\<beta>\<in>cf(\<gamma>)\<close> and \<open>y\<in>\<beta>\<close>
have "y \<in> cf(\<gamma>)"
using Ord_trans Ord_cf by blast
moreover from this
have "Ord(y)"
using Ord_cf Ord_in_Ord by blast
moreover
assume "\<langle>x,y\<rangle> \<in> Memrel(\<beta>)"
moreover from calculation
have "x<y" by (blast intro:ltI)
ultimately
show "\<langle>h ` x, h ` y\<rangle> \<in> Memrel(\<gamma>)"
unfolding h_def using f_factor_increasing ltD by (auto)
qed
with \<open>\<beta>\<in>cf(\<gamma>)\<close> \<open>Ord(\<gamma>)\<close>
have "ordertype(h``\<beta>,Memrel(\<gamma>)) = \<beta>" (* Maybe should use range(h) *)
using mono_map_ordertype_image[of \<beta>] Ord_cf Ord_in_Ord by blast
also
note \<open>\<beta> \<in>cf(\<gamma>)\<close>
finally
have "ordertype(h``\<beta>,Memrel(\<gamma>)) \<in> cf(\<gamma>)" by simp
moreover from \<open>h \<in> \<beta> \<rightarrow> \<gamma>\<close>
have "h``\<beta> \<subseteq> \<gamma>"
using mono_map_is_fun Image_sub_codomain by blast
ultimately
have "\<not> cofinal(h``\<beta>,\<gamma>,Memrel(\<gamma>))"
using ordertype_in_cf_imp_not_cofinal by simp
then
obtain \<alpha>_0 where "\<alpha>_0\<in>\<gamma>" "\<forall>x\<in>h `` \<beta>. \<not> \<langle>\<alpha>_0, x\<rangle> \<in> Memrel(\<gamma>) \<and> \<alpha>_0 \<noteq> x"
unfolding cofinal_def by auto
with \<open>Ord(\<gamma>)\<close> \<open>h``\<beta> \<subseteq> \<gamma>\<close>
have "\<forall>x\<in>h `` \<beta>. x \<in> \<alpha>_0"
using well_ord_Memrel[of \<gamma>] well_ord_is_linear[of \<gamma> "Memrel(\<gamma>)"]
unfolding linear_def by blast
from \<open>\<alpha>_0 \<in> \<gamma>\<close> \<open>j \<in> mono_map(_,_,\<gamma>,_)\<close> \<open>Ord(\<gamma>)\<close>
have "j`\<beta> \<in> \<gamma>"
using mono_map_is_fun apply_in_range by force
with \<open>\<alpha>_0 \<in> \<gamma>\<close> \<open>Ord(\<gamma>)\<close>
have "\<alpha>_0 \<union> j`\<beta> \<in> \<gamma>"
using Un_least_mem_iff Ord_in_Ord by auto
with \<open>cf_fun(f,\<gamma>)\<close>
obtain \<theta> where "\<theta>\<in>domain(f)" "\<langle>\<alpha>_0 \<union> j`\<beta>, f ` \<theta>\<rangle> \<in> Memrel(\<gamma>) \<or> \<alpha>_0 \<union> j`\<beta> = f ` \<theta>"
by (auto simp add:cofinal_fun_def) blast
moreover from this and \<open>f:\<delta>\<rightarrow>\<gamma>\<close>
have "\<theta> \<in> \<delta>" using domain_of_fun by auto
moreover
note \<open>Ord(\<gamma>)\<close>
moreover from this and \<open>f:\<delta>\<rightarrow>\<gamma>\<close> \<open>\<alpha>_0 \<in> \<gamma>\<close>
have "Ord(f`\<theta>)"
using apply_in_range Ord_in_Ord by blast
moreover from calculation and \<open>\<alpha>_0 \<in> \<gamma>\<close> and \<open>Ord(\<delta>)\<close> and \<open>j`\<beta> \<in> \<gamma>\<close>
have "Ord(\<alpha>_0)" "Ord(j`\<beta>)" "Ord(\<theta>)"
using Ord_in_Ord by auto
moreover from \<open>\<forall>x\<in>h `` \<beta>. x \<in> \<alpha>_0\<close> \<open>Ord(\<alpha>_0)\<close> \<open>h:\<beta>\<rightarrow>\<gamma>\<close>
have "x\<in>\<beta> \<Longrightarrow> h`x < \<alpha>_0" for x
using fun_is_function[of h \<beta> "\<lambda>_. \<gamma>"]
Image_subset_Ord_imp_lt domain_of_fun[of h \<beta> "\<lambda>_. \<gamma>"]
by blast
moreover
have "x\<in>\<beta> \<Longrightarrow> h`x < f`\<theta>" for x
proof -
fix x
assume "x\<in>\<beta>"
with \<open>\<forall>x\<in>h `` \<beta>. x \<in> \<alpha>_0\<close> \<open>Ord(\<alpha>_0)\<close> \<open>h:\<beta>\<rightarrow>\<gamma>\<close>
have "h`x < \<alpha>_0"
using fun_is_function[of h \<beta> "\<lambda>_. \<gamma>"]
Image_subset_Ord_imp_lt domain_of_fun[of h \<beta> "\<lambda>_. \<gamma>"]
by blast
also from \<open>\<langle>\<alpha>_0 \<union> _, f ` \<theta>\<rangle> \<in> Memrel(\<gamma>) \<or> \<alpha>_0 \<union> _= f ` \<theta>\<close>
\<open>Ord(f`\<theta>)\<close> \<open>Ord(\<alpha>_0)\<close> \<open>Ord(j`\<beta>)\<close>
have "\<alpha>_0 \<le> f`\<theta>"
using Un_leD1[OF leI [OF ltI]] Un_leD1[OF le_eqI] by blast
finally
show "h`x < f`\<theta>" .
qed
ultimately
have "factor_body(\<beta>,\<lambda>x\<in>\<beta>. factor(x),\<theta>)"
unfolding h_def factor_body_def using ltD
by (auto dest:Un_memD2 Un_leD2[OF le_eqI])
with \<open>Ord(\<theta>)\<close>
have "factor(\<beta>) \<le> \<theta>"
using factor_unfold[of \<beta>] Least_le unfolding factor_rec_def by auto
with \<open>\<theta>\<in>\<delta>\<close> \<open>Ord(\<delta>)\<close>
have "factor(\<beta>) \<in> \<delta>"
using leI[of \<theta>] ltI[of \<theta>] by (auto dest:ltD)
then
show ?case by (auto elim:mem_irrefl)
qed
moreover
have "cofinal_fun(f O fun_factor, \<gamma>, Memrel(\<gamma>))"
proof (intro cofinal_funI)
fix a
assume "a \<in> \<gamma>"
with \<open>cf_fun(j,\<gamma>)\<close> \<open>domain(j) = cf(\<gamma>)\<close>
obtain x where "x\<in>cf(\<gamma>)" "a \<in> j`x \<or> a = j`x"
by (auto simp add:cofinal_fun_def) blast
with factor_not_delta
have "x \<in> domain(f O fun_factor)"
using f_fun_factor_is_mono_map mono_map_is_fun domain_of_fun by force
moreover
have "a \<in> (f O fun_factor) `x \<or> a = (f O fun_factor) `x"
proof -
from \<open>x\<in>cf(\<gamma>)\<close> factor_not_delta
have "j ` x \<le> f ` factor(x)"
using mem_not_refl factor_body_factor factor_in_delta
unfolding factor_body_def by auto
with \<open>a \<in> j`x \<or> a = j`x\<close>
have "a \<in> f ` factor(x) \<or> a = f ` factor(x)"
using ltD by blast
with \<open>x\<in>cf(\<gamma>)\<close>
show ?thesis using lam_funtype[of "cf(\<gamma>)" factor]
unfolding fun_factor_def by auto
qed
moreover
note \<open>a \<in> \<gamma>\<close>
moreover from calculation and \<open>Ord(\<gamma>)\<close> and factor_not_delta
have "(f O fun_factor) `x \<in> \<gamma>"
using Limit_nonzero apply_in_range mono_map_is_fun[of "f O fun_factor"]
f_fun_factor_is_mono_map by blast
ultimately
show "\<exists>x \<in> domain(f O fun_factor). \<langle>a, (f O fun_factor) ` x\<rangle> \<in> Memrel(\<gamma>)
\<or> a = (f O fun_factor) `x"
by blast
qed
ultimately
show ?thesis
using fun_factor_is_mono_map f_fun_factor_is_mono_map by blast
qed
text\<open>As a final observation in this part, we note that if the original
cofinal map was increasing, then the factor function is also cofinal.\<close>
lemma factor_is_cofinal:
assumes
"Ord(\<delta>)" "Ord(\<gamma>)"
"f :\<delta> \<rightarrow>\<^sub>< \<gamma>" "f O g \<in> mono_map(\<alpha>,r,\<gamma>,Memrel(\<gamma>))"
"cofinal_fun(f O g,\<gamma>,Memrel(\<gamma>))" "g: \<alpha> \<rightarrow> \<delta>"
shows
"cf_fun(g,\<delta>)"
unfolding cf_fun_def cofinal_fun_def
proof
fix a
assume "a \<in> \<delta>"
with \<open>f \<in> mono_map(\<delta>,_,\<gamma>,_)\<close>
have "f`a \<in> \<gamma>"
using mono_map_is_fun by force
with \<open>cofinal_fun(f O g,\<gamma>,_)\<close>
obtain y where "y\<in>\<alpha>" "\<langle>f`a, (f O g) ` y\<rangle> \<in> Memrel(\<gamma>) \<or> f`a = (f O g) ` y"
unfolding cofinal_fun_def using domain_of_fun[OF \<open>g:\<alpha> \<rightarrow> \<delta>\<close>] by blast
with \<open>g:\<alpha> \<rightarrow> \<delta>\<close>
have "\<langle>f`a, f ` (g ` y)\<rangle> \<in> Memrel(\<gamma>) \<or> f`a = f ` (g ` y)" "g`y \<in> \<delta>"
using comp_fun_apply[of g \<alpha> \<delta> y f] by auto
with assms(1-3) and \<open>a\<in>\<delta>\<close>
have "\<langle>a, g ` y\<rangle> \<in> Memrel(\<delta>) \<or> a = g ` y"
using Memrel_mono_map_reflects Memrel_mono_map_is_inj[of \<delta> f \<gamma> \<gamma>]
inj_apply_equality[of f \<delta> \<gamma>] by blast
with \<open>y\<in>\<alpha>\<close>
show "\<exists>x\<in>domain(g). \<langle>a, g ` x\<rangle> \<in> Memrel(\<delta>) \<or> a = g ` x"
using domain_of_fun[OF \<open>g:\<alpha> \<rightarrow> \<delta>\<close>] by blast
qed
subsection\<open>Classical results on cofinalities\<close>
text\<open>Now the rest of the results follow in a more algebraic way. The
next proof one invokes a case analysis on whether the argument is zero,
a successor ordinal or a limit one; the last case being the most
relevant one and is immediate from the factorization lemma.\<close>
lemma cf_le_domain_cofinal_fun:
assumes
"Ord(\<gamma>)" "Ord(\<delta>)" "f:\<delta> \<rightarrow> \<gamma>" "cf_fun(f,\<gamma>)"
shows
"cf(\<gamma>)\<le>\<delta>"
using assms
proof (cases rule:Ord_cases)
case 0
with \<open>Ord(\<delta>)\<close>
show ?thesis using Ord_0_le by simp
next
case (succ \<gamma>)
with assms
obtain x where "x\<in>\<delta>" "f`x=\<gamma>" using cf_fun_succ' by blast
then
have "\<delta>\<noteq>0" by blast
let ?f="{\<langle>0,f`x\<rangle>}"
from \<open>f`x=\<gamma>\<close>
have "?f:1\<rightarrow>succ(\<gamma>)"
using singleton_0 singleton_fun[of 0 \<gamma>] singleton_subsetI fun_weaken_type by simp
with \<open>Ord(\<gamma>)\<close> \<open>f`x=\<gamma>\<close>
have "cf(succ(\<gamma>)) = 1" using cf_succ by simp
with \<open>\<delta>\<noteq>0\<close> succ
show ?thesis using Ord_0_lt_iff succ_leI \<open>Ord(\<delta>)\<close> by simp
next
case (limit)
with assms
obtain g where "g :cf(\<gamma>) \<rightarrow>\<^sub>< \<delta>"
using cofinal_fun_factorization by blast
with assms
show ?thesis using mono_map_imp_le by simp
qed
lemma cf_ordertype_cofinal:
assumes
"Limit(\<gamma>)" "A\<subseteq>\<gamma>" "cofinal(A,\<gamma>,Memrel(\<gamma>))"
shows
"cf(\<gamma>) = cf(ordertype(A,Memrel(\<gamma>)))"
proof (intro le_anti_sym)
from \<open>Limit(\<gamma>)\<close>
have "Ord(\<gamma>)"
using Limit_is_Ord by simp
with \<open>A \<subseteq> \<gamma>\<close>
have "well_ord(A,Memrel(\<gamma>))"
using well_ord_Memrel well_ord_subset by blast
then
obtain f \<alpha> where "f:\<langle>\<alpha>, Memrel(\<alpha>)\<rangle> \<cong> \<langle>A,Memrel(\<gamma>)\<rangle>" "Ord(\<alpha>)" "\<alpha> = ordertype(A,Memrel(\<gamma>))"
using ordertype_ord_iso Ord_ordertype ord_iso_sym by blast
moreover from this
have "f: \<alpha> \<rightarrow> A"
using ord_iso_is_mono_map mono_map_is_fun[of f _ "Memrel(\<alpha>)"] by blast
moreover from this
have "function(f)"
using fun_is_function by simp
moreover from \<open>f:\<langle>\<alpha>, Memrel(\<alpha>)\<rangle> \<cong> \<langle>A,Memrel(\<gamma>)\<rangle>\<close>
have "range(f) = A"
using ord_iso_is_bij bij_is_surj surj_range by blast
moreover note \<open>cofinal(A,\<gamma>,_)\<close>
ultimately
have "cf_fun(f,\<gamma>)"
using cofinal_range_iff_cofinal_fun by blast
moreover from \<open>Ord(\<alpha>)\<close>
obtain h where "h :cf(\<alpha>) \<rightarrow>\<^sub>< \<alpha>" "cf_fun(h,\<alpha>)"
using cofinal_mono_map_cf by blast
moreover from \<open>Ord(\<gamma>)\<close>
have "trans(Memrel(\<gamma>))"
using trans_Memrel by simp
moreover
note \<open>A\<subseteq>\<gamma>\<close>
ultimately
have "cofinal_fun(f O h,\<gamma>,Memrel(\<gamma>))"
using cofinal_comp ord_iso_is_mono_map[OF \<open>f:\<langle>\<alpha>,_\<rangle> \<cong> \<langle>A,_\<rangle>\<close>] mono_map_is_fun
mono_map_mono by blast
moreover from \<open>f:\<alpha>\<rightarrow>A\<close> \<open>A\<subseteq>\<gamma>\<close> \<open>h\<in>mono_map(cf(\<alpha>),_,\<alpha>,_)\<close>
have "f O h : cf(\<alpha>) \<rightarrow> \<gamma>"
using Pi_mono[of A \<gamma>] comp_fun mono_map_is_fun by blast
moreover
note \<open>Ord(\<gamma>)\<close> \<open>Ord(\<alpha>)\<close> \<open>\<alpha> = ordertype(A,Memrel(\<gamma>))\<close>
ultimately
show "cf(\<gamma>) \<le> cf(ordertype(A,Memrel(\<gamma>)))"
using cf_le_domain_cofinal_fun[of _ _ "f O h"]
by (auto simp add:cf_fun_def)
(********************************************************)
from \<open>f:\<langle>\<alpha>, _\<rangle> \<cong> \<langle>A,_\<rangle>\<close> \<open>A\<subseteq>\<gamma>\<close>
have "f :\<alpha> \<rightarrow>\<^sub>< \<gamma>"
using mono_map_mono[OF ord_iso_is_mono_map] by simp
then
have "f: \<alpha> \<rightarrow> \<gamma>"
using mono_map_is_fun by simp
with \<open>cf_fun(f,\<gamma>)\<close> \<open>Limit(\<gamma>)\<close> \<open>Ord(\<alpha>)\<close>
obtain g where "g :cf(\<gamma>) \<rightarrow>\<^sub>< \<alpha>"
"f O g :cf(\<gamma>) \<rightarrow>\<^sub>< \<gamma>"
"cofinal_fun(f O g,\<gamma>,Memrel(\<gamma>))"
using cofinal_fun_factorization by blast
moreover from this
have "g:cf(\<gamma>)\<rightarrow>\<alpha>"
using mono_map_is_fun by simp
moreover
note \<open>Ord(\<alpha>)\<close>
moreover from calculation and \<open>f :\<alpha> \<rightarrow>\<^sub>< \<gamma>\<close> \<open>Ord(\<gamma>)\<close>
have "cf_fun(g,\<alpha>)"
using factor_is_cofinal by blast
moreover
note \<open>\<alpha> = ordertype(A,Memrel(\<gamma>))\<close>
ultimately
show "cf(ordertype(A,Memrel(\<gamma>))) \<le> cf(\<gamma>)"
using cf_le_domain_cofinal_fun[OF _ Ord_cf mono_map_is_fun] by simp
qed
lemma cf_idemp:
assumes "Limit(\<gamma>)"
shows "cf(\<gamma>) = cf(cf(\<gamma>))"
proof -
from assms
obtain A where "A\<subseteq>\<gamma>" "cofinal(A,\<gamma>,Memrel(\<gamma>))" "cf(\<gamma>) = ordertype(A,Memrel(\<gamma>))"
using Limit_is_Ord cf_is_ordertype by blast
with assms
have "cf(\<gamma>) = cf(ordertype(A,Memrel(\<gamma>)))" using cf_ordertype_cofinal by simp
also
have "... = cf(cf(\<gamma>))"
using \<open>cf(\<gamma>) = ordertype(A,Memrel(\<gamma>))\<close> by simp
finally
show "cf(\<gamma>) = cf(cf(\<gamma>))" .
qed
lemma cf_le_cardinal:
assumes "Limit(\<gamma>)"
shows "cf(\<gamma>) \<le> |\<gamma>|"
proof -
from assms
have \<open>Ord(\<gamma>)\<close> using Limit_is_Ord by simp
then
obtain f where "f \<in> surj(|\<gamma>|,\<gamma>)"
using Ord_cardinal_eqpoll unfolding eqpoll_def bij_def by blast
with \<open>Ord(\<gamma>)\<close>
show ?thesis
using Card_is_Ord[OF Card_cardinal] surj_is_cofinal
cf_le_domain_cofinal_fun[of \<gamma>] surj_is_fun by blast
qed
lemma regular_is_Card:
notes le_imp_subset [dest]
assumes "Limit(\<gamma>)" "\<gamma> = cf(\<gamma>)"
shows "Card(\<gamma>)"
proof -
from assms
have "|\<gamma>| \<subseteq> \<gamma>"
using Limit_is_Ord Ord_cardinal_le by blast
also from \<open>\<gamma> = cf(\<gamma>)\<close>
have "\<gamma> \<subseteq> cf(\<gamma>)" by simp
finally
have "|\<gamma>| \<subseteq> cf(\<gamma>)" .
with assms
show ?thesis unfolding Card_def using cf_le_cardinal by force
qed
lemma Limit_cf: assumes "Limit(\<kappa>)" shows "Limit(cf(\<kappa>))"
using Ord_cf[of \<kappa>, THEN Ord_cases]
\<comment> \<open>\<^term>\<open>cf(\<kappa>)\<close> being 0 or successor leads to contradiction\<close>
proof (cases)
case 1
with \<open>Limit(\<kappa>)\<close>
show ?thesis using cf_zero_iff Limit_is_Ord by simp
next
case (2 \<alpha>)
moreover
note \<open>Limit(\<kappa>)\<close>
moreover from calculation
have "cf(\<kappa>) = 1"
using cf_idemp cf_succ by fastforce
ultimately
show ?thesis
using succ_LimitE cf_eq_one_iff Limit_is_Ord
by auto
qed
lemma InfCard_cf: "Limit(\<kappa>) \<Longrightarrow> InfCard(cf(\<kappa>))"
using regular_is_Card cf_idemp Limit_cf nat_le_Limit Limit_cf
unfolding InfCard_def by simp
lemma cf_le_cf_fun:
notes [dest] = Limit_is_Ord
assumes "cf(\<kappa>) \<le> \<nu>" "Limit(\<kappa>)"
shows "\<exists>f. f:\<nu> \<rightarrow> \<kappa> \<and> cf_fun(f, \<kappa>)"
proof -
note assms
moreover from this
obtain h where h_cofinal_mono: "cf_fun(h,\<kappa>)"
"h :cf(\<kappa>) \<rightarrow>\<^sub>< \<kappa>"
"h : cf(\<kappa>) \<rightarrow> \<kappa>"
using cofinal_mono_map_cf mono_map_is_fun by force
moreover from calculation
obtain g where "g \<in> inj(cf(\<kappa>), \<nu>)"
using le_imp_lepoll by blast
from this and calculation(2,3,5)
obtain f where "f \<in> surj(\<nu>, cf(\<kappa>))" "f: \<nu> \<rightarrow> cf(\<kappa>)"
using inj_imp_surj[OF _ Limit_has_0[THEN ltD]]
surj_is_fun Limit_cf by blast
moreover from this
have "cf_fun(f,cf(\<kappa>))"
using surj_is_cofinal by simp
moreover
note h_cofinal_mono \<open>Limit(\<kappa>)\<close>
moreover from calculation
have "cf_fun(h O f,\<kappa>)"
using cf_fun_comp by blast
moreover from calculation
have "h O f \<in> \<nu> -> \<kappa>"
using comp_fun by simp
ultimately
show ?thesis by blast
qed
lemma Limit_cofinal_fun_lt:
notes [dest] = Limit_is_Ord
assumes "Limit(\<kappa>)" "f: \<nu> \<rightarrow> \<kappa>" "cf_fun(f,\<kappa>)" "n\<in>\<kappa>"
shows "\<exists>\<alpha>\<in>\<nu>. n < f`\<alpha>"
proof -
from \<open>Limit(\<kappa>)\<close> \<open>n\<in>\<kappa>\<close>
have "succ(n) \<in> \<kappa>"
using Limit_has_succ[OF _ ltI, THEN ltD] by auto
moreover
note \<open>f: \<nu> \<rightarrow> _\<close>
moreover from this
have "domain(f) = \<nu>"
using domain_of_fun by simp
moreover
note \<open>cf_fun(f,\<kappa>)\<close>
ultimately
obtain \<alpha> where "\<alpha> \<in> \<nu>" "succ(n) \<in> f`\<alpha> \<or> succ(n) = f `\<alpha>"
using cf_funD[THEN cofinal_funD] by blast
moreover from this
consider (1) "succ(n) \<in> f`\<alpha>" | (2) "succ(n) = f `\<alpha>"
by blast
then
have "n < f`\<alpha>"
proof (cases)
case 1
moreover
have "n \<in> succ(n)" by simp
moreover
note \<open>Limit(\<kappa>)\<close> \<open>f: \<nu> \<rightarrow> _\<close> \<open>\<alpha> \<in> \<nu>\<close>
moreover from this
have "Ord(f ` \<alpha>)"
using apply_type[of f \<nu> "\<lambda>_. \<kappa>", THEN [2] Ord_in_Ord]
by blast
ultimately
show ?thesis
using Ord_trans[of n "succ(n)" "f ` \<alpha>"] ltI by blast
next
case 2
have "n \<in> f ` \<alpha>" by (simp add:2[symmetric])
with \<open>Limit(\<kappa>)\<close> \<open>f: \<nu> \<rightarrow> _\<close> \<open>\<alpha> \<in> \<nu>\<close>
show ?thesis
using ltI
apply_type[of f \<nu> "\<lambda>_. \<kappa>", THEN [2] Ord_in_Ord]
by blast
qed
ultimately
show ?thesis by blast
qed
context
includes Ord_dests Aleph_dests Aleph_intros Aleph_mem_dests mono_map_rules
begin
text\<open>We end this section by calculating the cofinality of Alephs, for
the zero and limit case. The successor case depends on $\AC$.\<close>
lemma cf_nat: "cf(\<omega>) = \<omega>"
using Limit_nat[THEN InfCard_cf] cf_le_cardinal[of \<omega>]
Card_nat[THEN Card_cardinal_eq] le_anti_sym
unfolding InfCard_def by auto
lemma cf_Aleph_zero: "cf(\<aleph>\<^bsub>0\<^esub>) = \<aleph>\<^bsub>0\<^esub>"
using cf_nat unfolding Aleph_def by simp
lemma cf_Aleph_Limit:
assumes "Limit(\<gamma>)"
shows "cf(\<aleph>\<^bsub>\<gamma>\<^esub>) = cf(\<gamma>)"
proof -
note \<open>Limit(\<gamma>)\<close>
moreover from this
have "(\<lambda>x\<in>\<gamma>. \<aleph>\<^bsub>x\<^esub>) : \<gamma> \<rightarrow> \<aleph>\<^bsub>\<gamma>\<^esub>" (is "?f : _ \<rightarrow> _")
using lam_funtype[of _ Aleph] fun_weaken_type[of _ _ _ "\<aleph>\<^bsub>\<gamma>\<^esub>"] by blast
moreover from \<open>Limit(\<gamma>)\<close>
have "x \<in> y \<Longrightarrow> \<aleph>\<^bsub>x\<^esub> \<in> \<aleph>\<^bsub>y\<^esub>" if "x \<in> \<gamma>" "y \<in> \<gamma>" for x y
using that Ord_in_Ord[of \<gamma>] Ord_trans[of _ _ \<gamma>] by blast
ultimately
have "?f \<in> mono_map(\<gamma>,Memrel(\<gamma>),\<aleph>\<^bsub>\<gamma>\<^esub>, Memrel(\<aleph>\<^bsub>\<gamma>\<^esub>))"
by auto
with \<open>Limit(\<gamma>)\<close>
have "?f \<in> \<langle>\<gamma>, Memrel(\<gamma>)\<rangle> \<cong> \<langle>?f``\<gamma>, Memrel(\<aleph>\<^bsub>\<gamma>\<^esub>)\<rangle>"
using mono_map_imp_ord_iso_Memrel[of \<gamma> "\<aleph>\<^bsub>\<gamma>\<^esub>" ?f]
Card_Aleph (* Already an intro rule, but need it explicitly *)
by blast
then
have "converse(?f) \<in> \<langle>?f``\<gamma>, Memrel(\<aleph>\<^bsub>\<gamma>\<^esub>)\<rangle> \<cong> \<langle>\<gamma>, Memrel(\<gamma>)\<rangle>"
using ord_iso_sym by simp
with \<open>Limit(\<gamma>)\<close>
have "ordertype(?f``\<gamma>, Memrel(\<aleph>\<^bsub>\<gamma>\<^esub>)) = \<gamma>"
using ordertype_eq[OF _ well_ord_Memrel]
ordertype_Memrel by auto
moreover from \<open>Limit(\<gamma>)\<close>
have "cofinal(?f``\<gamma>, \<aleph>\<^bsub>\<gamma>\<^esub>, Memrel(\<aleph>\<^bsub>\<gamma>\<^esub>))"
unfolding cofinal_def
proof (standard, intro ballI)
fix a
assume "a\<in>\<aleph>\<^bsub>\<gamma>\<^esub>" "\<aleph>\<^bsub>\<gamma>\<^esub> = (\<Union>i<\<gamma>. \<aleph>\<^bsub>i\<^esub>)"
moreover from this
obtain i where "i<\<gamma>" "a\<in>\<aleph>\<^bsub>i\<^esub>"
by auto
moreover from this and \<open>Limit(\<gamma>)\<close>
have "Ord(i)" using ltD Ord_in_Ord by blast
moreover from \<open>Limit(\<gamma>)\<close> and calculation
have "succ(i) \<in> \<gamma>" using ltD by auto
moreover from this and \<open>Ord(i)\<close>
have "\<aleph>\<^bsub>i\<^esub> < \<aleph>\<^bsub>succ(i)\<^esub>"
by (auto)
ultimately
have "\<langle>a,\<aleph>\<^bsub>i\<^esub>\<rangle> \<in> Memrel(\<aleph>\<^bsub>\<gamma>\<^esub>)"
using ltD by (auto dest:Aleph_increasing)
moreover from \<open>i<\<gamma>\<close>
have "\<aleph>\<^bsub>i\<^esub> \<in> ?f``\<gamma>"
using ltD apply_in_image[OF \<open>?f : _ \<rightarrow> _\<close>] by auto
ultimately
show "\<exists>x\<in>?f `` \<gamma>. \<langle>a, x\<rangle> \<in> Memrel(\<aleph>\<^bsub>\<gamma>\<^esub>) \<or> a = x" by blast
qed
moreover
note \<open>?f: \<gamma> \<rightarrow> \<aleph>\<^bsub>\<gamma>\<^esub>\<close> \<open>Limit(\<gamma>)\<close>
ultimately
show "cf(\<aleph>\<^bsub>\<gamma>\<^esub>) = cf(\<gamma>)"
using cf_ordertype_cofinal[OF Limit_Aleph Image_sub_codomain, of \<gamma> ?f \<gamma> \<gamma> ]
Limit_is_Ord by simp
qed
end (* includes *)
end |
(*
Copyright 2018
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.
*)
theory buddy_get_opt_mem
imports buddy_opt
begin
context assembly
begin
text \<open>
As we want to verify individual function bodies, it seems useful for now to treat the end of a
function's section as the halting point. This may need to be changed if we encounter functions
that are split across sections, but for now that is not an issue. For now, each function gets its
own @{text halted}.
\<close>
(* TODO: need to adapt to the recursion style used for the updated factorial proof *)
value \<open>length (instructions (text_sections assembly!5))\<close>
definition halted :: \<open>state \<Rightarrow> bool\<close> where
\<open>halted \<sigma> \<equiv> pc \<sigma> = 24\<close>
interpretation cfg_system step halted wf_state location
by standard (simp add: wf_state_def det_system.is_weak_invar_def)
declare halted_def[simp]
declare wf_state_def[simp]
declare location_def[simp]
text \<open>
This method runs symbolic execution per instruction.
It unfolds the step function, fetches the next instruction,
inserts master-information and then simplifies until no further let's are in the goal.
Then, the masters are cleaned up again (to prevent littering of the subgoal).
\<close>
method symbolic_execution uses masters add del =
(rule wps_rls)?,
(simp del: del)?,
simp only: assembly_def cong: Let'_weak_cong,
rewrite_one_let',
rewrite_one_let' del: del,
rewrite_one_let' add: exec_instr.simps del: del,
rewrite_one_let' add: unfold_semantics del: del,
insert masters,
(rewrite_one_let' add: add del: del)+,
(thin_tac \<open>master _ _ _\<close>)+,
rule linvar_unfoldI,
simp del: del
text \<open>
Symbolic execution can produce multiple subgoals (e.g., due to conditional jumps).
If one subgoal is finished, call this method once to restart the symbolic execution on the unfinished
next subgoal.
\<close>
method restart_symbolic_execution uses add del =
(rewrite_one_let' add: add del: del)+,
(thin_tac \<open>master _ _ _\<close>)+,
rule linvar_unfoldI,
simp del: del
|
((thin_tac \<open>master _ _ _\<close>)+)?,
rule linvar_unfoldI,
simp del: del
text \<open>If symbolic execution is finished, the subgoal often contains a large term, possibly with let's.
This can be simplified by inserting information on the masters and running simplification.
\<close>
method finish_symbolic_execution uses add del masters =
insert masters,
simp add: simp_rules add del: del,
(rewrite_one_let' add: add del: del)+,
(simp add: simp_rules add del: del; fail)?,
((thin_tac \<open>master _ _ _\<close>)+)?
text \<open>
The Floyd invariant expresses for some locations properties that are invariably true.
Simply expresses that a byte in the memory remains untouched.
\<close>
definition pp_\<Theta> :: \<open>_ \<Rightarrow> _ \<Rightarrow> _ \<Rightarrow> _ \<Rightarrow> _ \<Rightarrow> floyd_invar\<close> where
\<open>pp_\<Theta> rsp\<^sub>0 a v\<^sub>0 ts_ret pc_ret \<equiv> [
(* precondition *)
(5, 0) \<mapsto> \<lambda>\<sigma>. \<sigma> \<turnstile> *[a,1] = v\<^sub>0
\<and> RSP \<sigma> = rsp\<^sub>0, (* fix *)
(* resume *)
(5, 318) \<mapsto> \<lambda>\<sigma>. \<sigma> \<turnstile> *[a,1] = v\<^sub>0, (* fill out *)
(* postcondition *)
(ts_ret, pc_ret - 1) \<mapsto> \<lambda>\<sigma>. \<sigma> \<turnstile> *[a,1] = v\<^sub>0
\<and> RSP \<sigma> = rsp\<^sub>0 + 8
]\<close>
schematic_goal pp_\<Theta>_zero[simp]: \<comment> \<open>@{term 0} is not a numeral\<close>
shows \<open>pp_\<Theta> rsp\<^sub>0 a v\<^sub>0 ts_ret pc_ret (5, 0) = ?x\<close>
unfolding pp_\<Theta>_def
by simp
schematic_goal pp_\<Theta>_one[simp]: \<comment> \<open>@{term 1} is not a numeral\<close>
shows \<open>pp_\<Theta> rsp\<^sub>0 a v\<^sub>0 ts_ret pc_ret (5, 1) = ?x\<close>
unfolding pp_\<Theta>_def
by simp
schematic_goal pp_\<Theta>_numeral[simp]:
shows \<open>pp_\<Theta> rsp\<^sub>0 a v\<^sub>0 ts_ret pc_ret (5, numeral m) = ?x\<close>
unfolding pp_\<Theta>_def
by simp
lemma rewrite_buddy_get:
assumes \<open>seps blocks\<close>
and \<open>(2, a, 1) \<in> blocks\<close>
and \<open>(3, l ''completed.7641'' + 32, 8) \<in> blocks\<close> \<comment> \<open>@{const buddy_lists}\<close>
and \<open>ts_ret \<noteq> 5\<close>
shows \<open>is_std_invar (floyd.invar (pp_\<Theta> rsp\<^sub>0 a v\<^sub>0 ts_ret pc_ret))\<close>
proof -
(* Boilerplate code for setting up the master blocks: *)
have masters:
\<open>master blocks (a, 1) 2\<close>
\<open>master blocks (l ''completed.7641'' + 32, 8) 3\<close>
by (find_master' assms: assms)+
have two's_complement_fix\<^sub>1: \<open>18446744073709551552 = -(64::64 word)\<close>
by simp
have two's_complement_fix\<^sub>2: \<open>4294967290 = -(6::32 word)\<close>
by simp
show ?thesis
(* Boilerplate code to start the VCG *)
apply (rule floyd_invarI)
apply (rewrite at \<open>floyd_vcs \<hole> _\<close> pp_\<Theta>_def)
apply (intro floyd_vcsI; clarsimp?)
(* Subgoal for (ts, pc) = (5, 0) to (5, 0) *)
subgoal premises prems for \<sigma>
proof -
have rsp_min: \<open>64 \<le> RSP \<sigma>\<close>
sorry
note 1 = order_trans[OF _ rsp_min]
note 2 = word_sub_le[OF 1]
have m\<^sub>2:
\<open>master blocks (RSP \<sigma> - 8, 8) 4\<close>
\<open>master blocks (RSP \<sigma> - 16, 8) 4\<close>
\<open>master blocks (RSP \<sigma> - 24, 8) 4\<close>
\<open>master blocks (RSP \<sigma> - 32, 8) 4\<close>
\<open>master blocks (RSP \<sigma> - 40, 8) 4\<close>
\<open>master blocks (RSP \<sigma> - 48, 8) 4\<close>
\<open>master blocks (RSP \<sigma> - 64, 8) 4\<close>
(* \<open>master blocks (RSP \<sigma>, 8) 5\<close> *)
sorry
show ?thesis
(* Insert relevant knowledge *)
apply (insert prems assms rsp_min 1 2)
(* Apply VCG/symb. execution *)
apply (symbolic_execution masters: masters m\<^sub>2) (* push *)
apply (symbolic_execution masters: masters m\<^sub>2) (* push *)
apply (symbolic_execution masters: masters m\<^sub>2) (* push *)
apply (symbolic_execution masters: masters m\<^sub>2) (* movzx *)
apply (symbolic_execution masters: masters m\<^sub>2) (* push *)
apply (symbolic_execution masters: masters m\<^sub>2) (* push *)
apply (symbolic_execution masters: masters m\<^sub>2) (* lea *)
apply (symbolic_execution masters: masters m\<^sub>2) (* push *)
apply (symbolic_execution masters: masters m\<^sub>2) (* lea *)
apply (symbolic_execution masters: masters m\<^sub>2) (* movsxd *)
apply (symbolic_execution masters: masters m\<^sub>2) (* sub *)
apply (symbolic_execution masters: masters m\<^sub>2) (* mov *)
apply (symbolic_execution masters: masters m\<^sub>2) (* test *)
apply (symbolic_execution masters: masters m\<^sub>2) (* je .label_28 *)
apply (symbolic_execution masters: masters m\<^sub>2) (* cmp *)
apply (symbolic_execution masters: masters m\<^sub>2 del: imp_disjL) (* jbe .label_19 *)
apply (symbolic_execution masters: masters m\<^sub>2) (* lea *)
apply (symbolic_execution masters: masters m\<^sub>2) (* movzx *)
apply (symbolic_execution masters: masters m\<^sub>2 add: two's_complement_fix\<^sub>2) (* sub *)
apply (symbolic_execution masters: masters m\<^sub>2) (* movsxd *)
apply (symbolic_execution masters: masters m\<^sub>2) (* mov *)
apply (symbolic_execution masters: masters m\<^sub>2) (* test *)
apply (symbolic_execution masters: masters m\<^sub>2) (* je .label_29 *)
apply (symbolic_execution masters: masters m\<^sub>2) (* cmp *)
apply (symbolic_execution masters: masters m\<^sub>2 del: imp_disjL) (* jbe .label_20 *)
apply (symbolic_execution masters: masters m\<^sub>2) (* add *)
apply (symbolic_execution masters: masters m\<^sub>2) (* movzx *)
apply (symbolic_execution masters: masters m\<^sub>2 add: two's_complement_fix\<^sub>1) (* call buddy_get *)
subgoal sorry (* apply (finish_symbolic_execution masters: masters m\<^sub>2) *)
(* jbe .label_20 not taken *)
apply restart_symbolic_execution
apply (symbolic_execution masters: masters m\<^sub>2) (* cmp *)
apply (symbolic_execution masters: masters m\<^sub>2 del: imp_disjL) (* ja .label_27 *)
apply (symbolic_execution masters: masters m\<^sub>2) (* cmp *)
apply (symbolic_execution masters: masters m\<^sub>2) (* je .label_23 *)
apply (symbolic_execution masters: masters m\<^sub>2) (* mov *)
apply (symbolic_execution masters: masters m\<^sub>2) (* mov *)
apply (symbolic_execution masters: masters m\<^sub>2) (* mov *)
apply (symbolic_execution masters: masters m\<^sub>2) (* shl *)
apply (symbolic_execution masters: masters m\<^sub>2) (* movsxd *)
apply (symbolic_execution masters: masters m\<^sub>2) (* call palloc *)
apply (symbolic_execution masters: masters m\<^sub>2) (* test *)
apply (symbolic_execution masters: masters m\<^sub>2) (* je .label_21 *) \<comment> \<open>\texttt{.label\_21}, \texttt{.label\_22}, \texttt{.label\_23} would be good places to put additional annotations to avoid having to symbolically execute those over and over, maybe\<close>
apply (symbolic_execution masters: masters m\<^sub>2) (* add *)
apply (symbolic_execution masters: masters m\<^sub>2) (* mov *)
apply (symbolic_execution masters: masters m\<^sub>2) (* pop *)
apply (symbolic_execution masters: masters m\<^sub>2) (* pop *)
apply (symbolic_execution masters: masters m\<^sub>2) (* pop *)
apply (symbolic_execution masters: masters m\<^sub>2) (* pop *)
apply (symbolic_execution masters: masters m\<^sub>2) (* pop *)
apply (symbolic_execution masters: masters m\<^sub>2) (* pop *)
apply (symbolic_execution masters: masters m\<^sub>2) (* ret *)
apply (finish_symbolic_execution masters: masters m\<^sub>2)
(* je .label_21 not taken *)
apply restart_symbolic_execution
apply (symbolic_execution masters: masters m\<^sub>2) (* mov *)
apply (symbolic_execution masters: masters m\<^sub>2) (* xor *)
apply (symbolic_execution masters: masters m\<^sub>2) (* mov *)
apply (symbolic_execution masters: masters m\<^sub>2) (* jmp .label_25 *)
apply (symbolic_execution masters: masters m\<^sub>2) (* mov *)
apply (symbolic_execution masters: masters m\<^sub>2) (* mov *)
apply (symbolic_execution masters: masters m\<^sub>2) (* shl *)
apply (symbolic_execution masters: masters m\<^sub>2) (* movsxd *)
apply (symbolic_execution masters: masters m\<^sub>2) (* add *)
apply (symbolic_execution masters: masters m\<^sub>2) (* mov *)
apply (symbolic_execution masters: masters m\<^sub>2) (* mov *)
apply (symbolic_execution masters: masters m\<^sub>2) (* jmp .label_21 *)
apply (symbolic_execution masters: masters m\<^sub>2) (* add *)
apply (symbolic_execution masters: masters m\<^sub>2) (* mov *)
apply (symbolic_execution masters: masters m\<^sub>2) (* pop *)
apply (symbolic_execution masters: masters m\<^sub>2) (* pop *)
apply (symbolic_execution masters: masters m\<^sub>2) (* pop *)
apply (symbolic_execution masters: masters m\<^sub>2) (* pop *)
apply (symbolic_execution masters: masters m\<^sub>2) (* pop *)
apply (symbolic_execution masters: masters m\<^sub>2) (* pop *)
apply (symbolic_execution masters: masters m\<^sub>2) (* ret *)
apply (finish_symbolic_execution masters: masters m\<^sub>2)
(* je .label_23 not taken *)
apply restart_symbolic_execution
(* .... *)
(* ja .label_27 not taken *)
apply restart_symbolic_execution
(* .... *)
(* je .label_29 not taken *)
apply restart_symbolic_execution
apply (symbolic_execution masters: masters m\<^sub>2) (* mov *)
apply (symbolic_execution masters: masters m\<^sub>2) (* mov *)
apply (symbolic_execution masters: masters m\<^sub>2) (* mov *)
apply (symbolic_execution masters: masters m\<^sub>2) (* mov *)
(* .... *)
(* jbe .label_19 not taken *)
apply restart_symbolic_execution
apply (symbolic_execution masters: masters m\<^sub>2) (* cmp *)
apply (symbolic_execution masters: masters m\<^sub>2 del: imp_disjL) (* ja .label_24 *)
(* .... *)
(* je .label_28 not taken *)
apply restart_symbolic_execution
apply (symbolic_execution masters: masters m\<^sub>2) (* mov *)
apply (symbolic_execution masters: masters m\<^sub>2) (* mov *)
apply (symbolic_execution masters: masters m\<^sub>2) (* add *)
apply (symbolic_execution masters: masters m\<^sub>2) (* mov *)
apply (symbolic_execution masters: masters m\<^sub>2) (* pop *)
apply (symbolic_execution masters: masters m\<^sub>2) (* pop *)
apply (symbolic_execution masters: masters m\<^sub>2) (* pop *)
apply (symbolic_execution masters: masters m\<^sub>2) (* pop *)
apply (symbolic_execution masters: masters m\<^sub>2) (* pop *)
apply (symbolic_execution masters: masters m\<^sub>2) (* pop *)
apply (symbolic_execution masters: masters m\<^sub>2) (* ret *)
apply (finish_symbolic_execution masters: masters m\<^sub>2)
done
qed
done
qed
end
end
|
(*
* Copyright 2020, Data61, CSIRO (ABN 41 687 119 230)
*
* SPDX-License-Identifier: BSD-2-Clause
*)
theory Prefix_Refinement
imports
Triv_Refinement
"Lib.TraceMonadLemmas"
begin
section \<open>Definition of prefix fragment refinement.\<close>
text \<open>
This is a notion of refinement/simulation making use of prefix closure.
For a concrete program to refine an abstract program, then for every
trace of the concrete program there must exist a well-formed fragment
of the abstract program that matches (according to the simulation
relation) but which leaves enough decisions available to the abstract
environment to permit parallel composition.
\<close>
text \<open>
Fragments must be self-closed, or enabled. Certain incomplete traces
must be possible to extend by a program step.
\<close>
definition
self_closed :: "((tmid \<times> 's) list \<Rightarrow> bool) \<Rightarrow> 's \<Rightarrow> ('s, 'a) tmonad \<Rightarrow> bool"
where
"self_closed cond s f = (\<forall>xs. (xs, Incomplete) \<in> f s
\<longrightarrow> cond xs \<longrightarrow> (\<exists>s'. (Me, s') # xs \<in> fst ` f s))"
lemmas self_closedD = self_closed_def[THEN iffD1, rule_format]
text \<open>
Fragments must be environment-closed. Certain incomplete traces
must be possible to extend by any environment step that is
compatible with some condition.
\<close>
definition
env_closed :: "((tmid \<times> 's) list \<Rightarrow> 's \<Rightarrow> bool) \<Rightarrow> 's \<Rightarrow> ('s, 'a) tmonad \<Rightarrow> bool"
where
"env_closed cond s f = (\<forall>xs s'. (xs, Incomplete) \<in> f s
\<longrightarrow> cond xs s' \<longrightarrow> ((Env, s') # xs) \<in> fst ` f s)"
lemmas env_closedD = env_closed_def[THEN iffD1, rule_format]
lemma env_closed_strengthen_cond:
"env_closed P s f
\<Longrightarrow> (\<forall>xs s. Q xs s \<longrightarrow> P xs s)
\<Longrightarrow> env_closed Q s f"
by (simp add: env_closed_def)
text \<open>
Two traces match according to some state relation if they match at every step.
\<close>
definition
matching_tr :: "('s \<Rightarrow> 't \<Rightarrow> bool) \<Rightarrow> (tmid \<times> 's) list \<Rightarrow> (tmid \<times> 't) list \<Rightarrow> bool"
where
"matching_tr sr = list_all2 (\<lambda>(aid, as) (cid, cs). aid = cid \<and> sr as cs)"
definition
matching_tr_pfx :: "('s \<Rightarrow> 't \<Rightarrow> bool) \<Rightarrow> (tmid \<times> 's) list \<Rightarrow> (tmid \<times> 't) list \<Rightarrow> bool"
where
"matching_tr_pfx sr atr ctr = (length atr \<le> length ctr
\<and> matching_tr sr (rev atr) (take (length atr) (rev ctr)))"
abbreviation
"matching_tr_tmids_pfx \<equiv> matching_tr_pfx (\<lambda>_ _. True)"
abbreviation(input)
"matching_self_cond ctr \<equiv> (\<lambda>xs. length xs < length ctr \<and> fst (rev ctr ! length xs) = Me)"
abbreviation(input)
"matching_env_cond sr ctr s0 R \<equiv> (\<lambda>xs s. matching_tr_pfx sr ((Env, s) # xs) ctr
\<and> rely_cond R s0 ((Env, s) # xs))"
text \<open>
The collection of properties a fragment must have to match some concrete
trace. It must be prefix, self and environment closed, nonempty, and all
outcomes must be matching. The outcomes (trace and result) must match
the rely condition, the concrete trace (or a prefix), and must either be
a matching result or @{term Incomplete} if a prefix.
\<close>
definition
is_matching_fragment :: "('s \<Rightarrow> 't \<Rightarrow> bool) \<Rightarrow> ('s \<Rightarrow> 't \<Rightarrow> bool)
\<Rightarrow> ('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> (tmid \<times> 't) list \<Rightarrow> ('t, 'b) tmres
\<Rightarrow> 's \<Rightarrow> ('s \<Rightarrow> 's \<Rightarrow> bool) \<Rightarrow> 's \<Rightarrow> ('s, 'a) tmonad \<Rightarrow> bool"
where
"is_matching_fragment sr osr rvr ctr cres s0 R s f
= ((prefix_closed f
\<and> self_closed (matching_self_cond ctr) s f
\<and> env_closed (matching_env_cond sr ctr s0 R) s f)
\<and> (f s \<noteq> {})
\<and> (\<forall>(tr, res) \<in> f s. rely_cond R s0 tr
\<and> matching_tr_pfx sr tr ctr
\<and> (length tr < length ctr \<longrightarrow> res = Incomplete)
\<and> (length tr = length ctr \<longrightarrow> rel_tmres osr rvr res cres)))"
lemmas is_matching_fragmentD = is_matching_fragment_def[THEN iffD1, rule_format]
lemmas is_matching_fragment_wf = is_matching_fragmentD[THEN conjunct1]
lemmas is_matching_fragment_prefix_closed = is_matching_fragment_wf[THEN conjunct1]
lemmas is_matching_fragment_self_closed = is_matching_fragment_wf[THEN conjunct2, THEN conjunct1]
lemmas is_matching_fragment_env_closed = is_matching_fragment_wf[THEN conjunct2, THEN conjunct2]
lemmas is_matching_fragment_defD
= is_matching_fragmentD[THEN conjunct2, THEN conjunct1, rule_format]
lemmas is_matching_fragment_trD
= is_matching_fragmentD[THEN conjunct2, THEN conjunct2,
rule_format, where x="(tr, res)" for tr res, simplified, rule_format]
text \<open>
Prefix fragment refinement. Given the initial conditions, every concrete outcome
(trace and result) must have a matching fragment which is a simple refinement of
the abstract program.
\<close>
definition
prefix_refinement :: "('s \<Rightarrow> 't \<Rightarrow> bool) \<Rightarrow> ('s \<Rightarrow> 't \<Rightarrow> bool) \<Rightarrow> ('s \<Rightarrow> 't \<Rightarrow> bool)
\<Rightarrow> ('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> ('s \<Rightarrow> 's \<Rightarrow> bool) \<Rightarrow> ('t \<Rightarrow> 't \<Rightarrow> bool)
\<Rightarrow> ('s \<Rightarrow> 's \<Rightarrow> bool) \<Rightarrow> ('t \<Rightarrow> 't \<Rightarrow> bool)
\<Rightarrow> ('s, 'a) tmonad \<Rightarrow> ('t, 'b) tmonad \<Rightarrow> bool"
where
"prefix_refinement sr isr osr rvr P Q AR R aprog cprog
= (\<forall>s s0 t0 t. isr s t \<longrightarrow> P s0 s \<longrightarrow> sr s0 t0 \<longrightarrow> Q t0 t
\<longrightarrow> (\<forall>(ctr, cres) \<in> cprog t.
rely_cond R t0 ctr \<longrightarrow> (\<exists>f. is_matching_fragment sr osr rvr ctr cres s0 AR s f
\<and> triv_refinement aprog f)))"
abbreviation
"pfx_refn sr rvr P \<equiv> prefix_refinement sr sr sr rvr P"
lemmas prefix_refinementD = prefix_refinement_def[THEN iffD1, rule_format]
lemmas split_iffD1 = Product_Type.split[THEN iffD1]
lemmas pfx_refnD = prefix_refinementD
lemmas pfx_refnD2 = pfx_refnD[THEN split_iffD1[where a=tr and b=res for tr res], rule_format]
lemma matching_tr_pfx_aCons:
"matching_tr_pfx sr ((tmid, s) # atr) ctr
= (\<exists>s'. length atr < length ctr \<and> rev ctr ! length atr = (tmid, s')
\<and> sr s s' \<and> matching_tr_pfx sr atr ctr)"
apply (simp add: matching_tr_pfx_def matching_tr_def Suc_le_eq
list_all2_conv_all_nth less_Suc_eq all_conj_distrib)
apply (simp add: nth_append prod_eq_iff)
apply auto
done
lemma rely_cond_hd:
"rely_cond R s0 xs \<Longrightarrow> xs \<noteq> []
\<Longrightarrow> fst (hd xs) = Env \<longrightarrow> R (last_st_tr (tl xs) s0) (snd (hd xs))"
by (clarsimp simp: rely_cond_def neq_Nil_conv trace_steps_append
split: if_split_asm)
lemma diff_Suc_eq_if:
"(Suc n - m) = (if m \<le> n then Suc (n - m) else 0)"
by auto
lemma rely_cond_nth:
"rely_cond R s0 tr \<Longrightarrow> n < length tr
\<Longrightarrow> fst (rev tr ! n) = Env \<longrightarrow> R ((if n = 0 then s0 else snd (rev tr ! (n - 1)))) (snd (rev tr ! n))"
by (simp add: rely_cond_def trace_steps_rev_drop_nth[where n=0, simplified])
lemma is_matching_fragment_Nil:
"is_matching_fragment sr osr rvr ctr cres s0 R s f
\<Longrightarrow> [] \<in> fst ` f s"
apply (clarsimp simp: is_matching_fragment_def)
apply (clarsimp simp only: set_eq_iff empty_iff simp_thms not_all)
apply (drule(1) prefix_closed_drop[where tr=tr and n="length tr" for tr])
apply (clarsimp simp add: in_fst_snd_image)
done
section \<open>Implications\<close>
text \<open>
The notions of matching fragment and prefix refinement we have defined
allow us to prove the existence of a matching trace in the abstract
program.
\<close>
theorem matching_fragment_matching_tr:
assumes match: "is_matching_fragment sr osr rvr ctr cres s0 R' s f"
and rely: "rely_cond R t0 ctr"
and sr0: "sr s0 t0"
and sr: "(\<forall>s t t'. sr s t \<longrightarrow> R t t' \<longrightarrow> (\<exists>s'. sr s' t' \<and> R' s s'))"
shows "\<exists>(atr, ares) \<in> f s. matching_tr sr atr ctr
\<and> rel_tmres osr rvr ares cres
\<and> rely_cond R' s0 atr"
proof -
note pfx_closed = is_matching_fragment_prefix_closed[OF match]
note f_prop = is_matching_fragment_trD[OF match]
note env_closed = is_matching_fragment_env_closed[OF match]
note self_closed = is_matching_fragment_self_closed[OF match]
note pfx_closedD = pfx_closed[THEN prefix_closedD]
have extend:
"\<And>tmid s' tr res. ((tmid, s') # tr, res) \<in> f s \<Longrightarrow> rely_cond R' s0 tr
\<Longrightarrow> \<exists>x res. (x # tr, res) \<in> f s \<and> rely_cond R' s0 (x # tr)"
apply (case_tac tmid)
apply (fastforce simp: rely_cond_Cons)
apply (frule f_prop[OF pfx_closedD], clarsimp)
apply (frule f_prop, clarsimp simp: matching_tr_pfx_aCons)
apply (frule rely_cond_nth[rotated], rule rely, simp)
apply (drule_tac s="last_st_tr tr s0" in sr[rule_format, rotated])
apply (clarsimp simp: sr0 neq_Nil_conv matching_tr_pfx_aCons)
apply clarsimp
apply (rename_tac t' s'_rely)
apply (drule_tac s'="s'_rely" in env_closedD[where f=f, OF env_closed, OF prefix_closedD[OF pfx_closed]])
apply (clarsimp simp: matching_tr_pfx_aCons rely_cond_Cons_eq)
apply clarsimp
apply (fastforce intro!: rely_cond_Cons)
done
have extend2:
"\<And>tr res. (tr, res) \<in> f s \<Longrightarrow> rely_cond R' s0 tr
\<Longrightarrow> length tr < length ctr
\<Longrightarrow> \<exists>x res. (x # tr, res) \<in> f s \<and> rely_cond R' s0 (x # tr)"
apply (frule f_prop, clarsimp)
apply (case_tac "fst (rev ctr ! length tr)")
apply (frule self_closed[THEN self_closedD], simp)
apply (fastforce intro: rely_cond_Cons)
apply (frule rely_cond_nth[rotated], rule rely, simp)
apply (drule_tac s="last_st_tr tr s0" in sr[rule_format, rotated])
apply (clarsimp simp: sr0 neq_Nil_conv matching_tr_pfx_aCons)
apply clarsimp
apply (drule_tac s'=s' in env_closedD[OF env_closed])
apply (simp add: matching_tr_pfx_aCons prod_eq_iff rely_cond_Cons)
apply (fastforce intro: rely_cond_Cons)
done
{ fix n
have "\<exists>(tr, res) \<in> f s. (n \<le> length ctr \<longrightarrow> length tr = n)
\<and> rely_cond R' s0 tr"
apply (induct n)
apply (cut_tac f=f in is_matching_fragment_Nil;
(rule sr0 match)?)
apply fastforce
apply clarsimp
apply (case_tac "\<not> (Suc n \<le> length ctr)")
apply fastforce
apply clarsimp
apply (drule(1) extend2, simp)
apply (fastforce elim: rev_bexI)
done
}
note induct = this[rule_format]
show ?thesis
using induct[where n="length ctr"]
apply clarsimp
apply (rule rev_bexI, assumption)
apply clarsimp
apply (frule is_matching_fragment_trD[OF match])
apply (clarsimp simp: matching_tr_pfx_def matching_tr_def)
done
qed
corollary matching_fragment_matching_tr_trivR:
assumes match: "is_matching_fragment sr osr rvr ctr cres s0 R s f"
and sr: "(\<forall>s t t'. sr s t \<longrightarrow> (\<exists>s'. sr s' t' \<and> R s s'))"
and srx: "sr s0 t0"
shows "\<exists>(atr, ares) \<in> f s. matching_tr sr atr ctr
\<and> rel_tmres osr rvr ares cres"
using matching_fragment_matching_tr[where R="\<lambda>_ _. True",
OF match _ srx]
by (auto simp add: rely_cond_def sr)
theorem prefix_refinement_rely_cond_trD:
assumes preds: "prefix_refinement sr isr osr rvr P Q R' R aprog cprog"
"isr s t" "P s0 s" "Q t0 t" "(ctr, cres) \<in> cprog t"
"rely_cond R t0 ctr" "sr s0 t0"
and sr: "(\<forall>s t t'. sr s t \<longrightarrow> R t t' \<longrightarrow> (\<exists>s'. sr s' t' \<and> R' s s'))"
shows "\<exists>(atr, ares) \<in> aprog s. matching_tr sr atr ctr
\<and> rel_tmres osr rvr ares cres
\<and> rely_cond R' s0 atr"
proof -
obtain f where subs: "f s \<subseteq> aprog s"
and match: "is_matching_fragment sr osr rvr ctr cres s0 R' s f"
using prefix_refinementD[OF preds(1-3) _ preds(4-5)] preds(6-)
by (auto simp add: triv_refinement_def)
show ?thesis
using matching_fragment_matching_tr[OF match _ _ sr] preds subs
by blast
qed
lemma rely_cond_True:
"rely_cond (\<lambda>_ _. True) = (\<lambda>_ _. True)"
by (simp add: rely_cond_def fun_eq_iff)
section \<open>Compositionality.\<close>
text \<open>The crucial rules for proving prefix refinement
of parallel and sequential compositions.\<close>
lemma ball_set_zip_conv_nth:
"(\<forall>x \<in> set (zip ys zs). P x)
= (\<forall>n. n < length ys \<longrightarrow> n < length zs \<longrightarrow> P (ys ! n, zs ! n))"
by (auto simp add: Ball_def in_set_zip)
definition
par_tr_fin_principle :: "('s, unit) tmonad \<Rightarrow> bool"
where
"par_tr_fin_principle f = (\<forall>s tr s'. (tr, Result ((), s')) \<in> f s \<longrightarrow> s' = last_st_tr tr s \<and> tr \<noteq> [])"
lemmas par_tr_fin_principleD = par_tr_fin_principle_def[THEN iffD1, rule_format]
lemma tr_in_parallel:
"(tr, res) \<in> parallel f g s
\<Longrightarrow> \<exists>f_tr g_tr. (f_tr, res) \<in> f s \<and> (g_tr, res) \<in> g s
\<and> (tr, res) \<in> parallel (K {(f_tr, res)}) (K {(g_tr, res)}) s"
apply (clarsimp simp: parallel_def)
apply fastforce
done
lemma matching_env_closedD:
"(tr, res) \<in> f s
\<Longrightarrow> is_matching_fragment sr osr rvr ctr cres s0 R s f
\<Longrightarrow> length tr < length ctr
\<Longrightarrow> fst (rev ctr ! length tr) = Env
\<Longrightarrow> sr s' (snd (rev ctr ! length tr))
\<Longrightarrow> R (last_st_tr tr s0) s'
\<Longrightarrow> (Env, s') # tr \<in> fst ` f s"
apply (frule(1) is_matching_fragment_trD, clarsimp)
apply (erule(1) env_closedD[OF is_matching_fragment_env_closed])
apply (clarsimp simp: matching_tr_pfx_aCons rely_cond_Cons_eq prod_eq_iff)
done
lemma par_tr_fin_fragment:
"par_tr_fin_principle f
\<Longrightarrow> (tr, res) \<in> f s
\<Longrightarrow> is_matching_fragment sr osr rvr ctr cres s0 R s f
\<Longrightarrow> res = (case (length ctr - length tr, cres)
of (0, Failed) \<Rightarrow> Failed
| (0, Result _) \<Rightarrow> Result ((), last_st_tr tr s)
| _ \<Rightarrow> Incomplete)"
apply (frule(1) is_matching_fragment_trD)
apply (cases "length tr < length ctr")
apply (clarsimp split: nat.split)
apply (clarsimp simp: matching_tr_pfx_def)
apply (erule tmres.rel_cases; clarsimp)
apply (frule(1) par_tr_fin_principleD)
apply (clarsimp simp: neq_Nil_conv)
done
lemma par_tr_fragment_in_parallel:
"par_tr_fin_principle f
\<Longrightarrow> par_tr_fin_principle g
\<Longrightarrow> is_matching_fragment sr osr rvr ctr1 cres s0 R s f
\<Longrightarrow> is_matching_fragment sr osr' rvr ctr2 cres s0 R' s g
\<Longrightarrow> length ctr1 = length ctr2
\<Longrightarrow> \<exists>f_steps res'. length f_steps = length tr
\<and> (map (\<lambda>(f_step, (id, s)). (if f_step then id else Env, s)) (zip f_steps tr), res) \<in> f s
\<and> (map (\<lambda>(f_step, (id, s)). (if f_step then Env else id, s)) (zip f_steps tr), res') \<in> g s
\<Longrightarrow> (tr, res) \<in> parallel f g s"
apply (clarsimp simp: parallel_def)
apply (rule_tac x=f_steps in exI, clarsimp)
apply (drule(2) par_tr_fin_fragment)+
apply (simp only: list_all2_lengthD)
apply (clarsimp split: nat.split_asm tmres.split_asm)
apply (simp add: last_st_tr_def o_def split_def)
done
lemma par_tr_fragment_parallel_def:
"par_tr_fin_principle f
\<Longrightarrow> par_tr_fin_principle g
\<Longrightarrow> is_matching_fragment sr osr rvr ctr1 cres s0 R s f
\<Longrightarrow> is_matching_fragment sr osr' rvr ctr2 cres s0 R' s g
\<Longrightarrow> length ctr1 = length ctr2
\<Longrightarrow> parallel f g s = {(tr, res). \<exists>f_steps res'. length f_steps = length tr
\<and> (map (\<lambda>(f_step, (id, s)). (if f_step then id else Env, s)) (zip f_steps tr), res) \<in> f s
\<and> (map (\<lambda>(f_step, (id, s)). (if f_step then Env else id, s)) (zip f_steps tr), res') \<in> g s}"
apply (rule equalityI; clarsimp)
apply (auto simp: parallel_def)[1]
apply (erule(4) par_tr_fragment_in_parallel)
apply blast
done
lemmas list_all2_rev_nthD
= list_all2_nthD[OF list_all2_rev[THEN iffD2], simplified]
definition
forward_enabled :: "'s rg_pred \<Rightarrow> bool"
where
"forward_enabled P = (\<forall>s_pre. \<exists>s. P s_pre s)"
lemmas forward_enabledD = forward_enabled_def[THEN iffD1, rule_format]
lemma forward_enabled_mono:
"P \<le> Q \<Longrightarrow> forward_enabled P \<Longrightarrow> forward_enabled Q"
by (fastforce simp: forward_enabled_def le_fun_def)
lemma forward_enabled_reflp:
"reflp P \<Longrightarrow> forward_enabled P"
by (auto simp add: reflp_def forward_enabled_def)
lemma par_tr_fin_principle_triv_refinement:
"par_tr_fin_principle aprog
\<Longrightarrow> triv_refinement aprog cprog
\<Longrightarrow> par_tr_fin_principle cprog"
by (fastforce simp: par_tr_fin_principle_def triv_refinement_def)
lemma matching_tr_pfx_parallel_zip:
"matching_tr_pfx sr a_pfx a_tr
\<Longrightarrow> matching_tr_pfx sr b_pfx b_tr
\<Longrightarrow> length a_pfx = length b_pfx
\<Longrightarrow> list_all2 (\<lambda>y z. (fst y = Env \<or> fst z = Env) \<and> snd y = snd z) a_tr b_tr
\<Longrightarrow> matching_tr_pfx sr (map parallel_mrg (zip a_pfx b_pfx)) (map parallel_mrg (zip a_tr b_tr))"
apply (clarsimp simp: matching_tr_pfx_def matching_tr_def list_all2_lengthD)
apply (clarsimp simp: list_all2_conv_all_nth)
apply (clarsimp simp: rev_map split_def zip_rev[symmetric])
done
lemma drop_sub_Suc_is_Cons:
"n = length xs \<Longrightarrow> m < length xs \<Longrightarrow> drop (n - Suc m) xs = (rev xs ! m) # drop (n - m) xs"
apply (rule nth_equalityI; clarsimp)
apply (clarsimp simp add: nth_Cons' rev_nth)
done
lemma le_sub_eq_0:
"((x :: nat) \<le> x - y) = (x = 0 \<or> y = 0)"
by arith
lemmas rely_cond_append_split
= rely_cond_append[where xs="take n xs" and ys="drop n xs" for n xs, simplified]
lemmas guar_cond_append_split
= guar_cond_append[where xs="take n xs" and ys="drop n xs" for n xs, simplified]
lemma validI_drop_next_G:
"\<lbrakk> \<lbrace>P\<rbrace>, \<lbrace>R\<rbrace> f \<lbrace>G\<rbrace>, \<lbrace>Q\<rbrace>; P s0 s; (tr, res) \<in> f s;
rely_cond R s0 (drop (n - m) tr); n = length tr; m < length tr \<rbrakk>
\<Longrightarrow> fst (rev tr ! m) \<noteq> Env
\<longrightarrow> G (last_st_tr (rev (take m (rev tr))) s0) (snd (rev tr ! m))"
apply clarify
apply (drule(2) validI_GD_drop[where n="n - Suc m"])
apply (simp add: drop_sub_Suc_is_Cons)
apply (rule rely_cond_Cons; simp)
apply (subst(asm) guar_cond_append_split[where n=1])
apply (simp add: take_Suc Suc_diff_Suc)
apply (simp add: guar_cond_def take_rev hd_drop_conv_nth
eq_Me_neq_Env rev_nth)
done
lemma tr_in_parallel_validI:
assumes elem: "(tr, res) \<in> parallel (K {(f_tr, res)}) (K {(g_tr, res)}) s"
and trs: "(f_tr, res) \<in> f s" "(g_tr, res) \<in> g s"
and validI: "\<lbrace>P\<rbrace>, \<lbrace>E Or Gg\<rbrace> f \<lbrace>Gf\<rbrace>, \<lbrace>Q\<rbrace>" "\<lbrace>P\<rbrace>, \<lbrace>E Or Gf\<rbrace> g \<lbrace>Gg\<rbrace>, \<lbrace>Q2\<rbrace>"
and P: "P s0 s" and rel: "rely_cond E s0 tr"
shows "rely_cond (E Or Gg) s0 f_tr \<and> rely_cond (E Or Gf) s0 g_tr"
using parallel_rely_induct0[where R=E and G="\<top>\<top>", OF elem _ _ validI, OF P P]
by (clarsimp simp: rel trs predicate2I)
lemma env_closed_parallel_fragment:
"is_matching_fragment sr osr rvr ctr1 cres1 s0 (E Or Gg) s f
\<Longrightarrow> is_matching_fragment sr osr' rvr ctr2 cres2 s0 (E Or Gf) s g
\<Longrightarrow> par_tr_fin_principle f
\<Longrightarrow> par_tr_fin_principle g
\<Longrightarrow> cres1 = cres2 \<Longrightarrow> length ctr1 = length ctr2
\<Longrightarrow> \<forall>s xs. Q xs s \<longrightarrow> (sr s (snd (rev ctr1 ! length xs)))
\<and> (sr s (snd (rev ctr2 ! length xs)))
\<and> length xs < length ctr2
\<and> fst (rev ctr1 ! length xs) = Env
\<and> fst (rev ctr2 ! length xs) = Env
\<and> E (last_st_tr xs s0) s
\<Longrightarrow> env_closed Q s (parallel f g)"
apply (subst env_closed_def, clarsimp)
apply (frule is_matching_fragment_prefix_closed[where f=f])
apply (frule is_matching_fragment_prefix_closed[where f=g])
apply (subst(asm) parallel_def, clarsimp simp: length_Suc_conv)
apply (strengthen in_fst_snd_image)
apply (simp add: par_tr_fragment_parallel_def)
apply (strengthen exI[where x="x # xs" for x xs])
apply (frule(1) is_matching_fragment_trD[where f=f])
apply (frule(1) is_matching_fragment_trD[where f=g])
apply (clarsimp simp: matching_tr_pfx_aCons rely_cond_Cons_eq
last_st_tr_map_zip bipred_disj_def)
apply (drule spec2, drule(1) mp[where P="Q xs s" for xs s])
apply clarsimp
apply (drule_tac s'=s' in env_closedD[where f=f, OF is_matching_fragment_env_closed, rotated];
simp?)
apply (simp add: matching_tr_pfx_aCons rely_cond_Cons_eq last_st_tr_map_zip prod_eq_iff)
apply (drule_tac s'=s' in env_closedD[where f=g, OF is_matching_fragment_env_closed, rotated];
simp?)
apply (simp add: matching_tr_pfx_aCons rely_cond_Cons_eq last_st_tr_map_zip prod_eq_iff)
apply clarsimp
apply blast
done
lemma self_closed_parallel_fragment:
notes if_split[split del]
shows
"is_matching_fragment sr osr rvr ctr1 cres1 s0 (E Or Gg) s f
\<Longrightarrow> is_matching_fragment sr osr' rvr ctr2 cres2 s0 (E Or Gf) s g
\<Longrightarrow> par_tr_fin_principle f
\<Longrightarrow> par_tr_fin_principle g
\<Longrightarrow> list_all2 (\<lambda>y z. (fst y = Env \<or> fst z = Env) \<and> snd y = snd z) ctr1 ctr2
\<Longrightarrow> \<lbrace>P\<rbrace>,\<lbrace>E Or Gg\<rbrace> f \<lbrace>Gf\<rbrace>,\<lbrace>\<lambda>_ _ _. True\<rbrace>
\<Longrightarrow> \<lbrace>P\<rbrace>,\<lbrace>E Or Gf\<rbrace> g \<lbrace>Gg\<rbrace>,\<lbrace>\<lambda>_ _ _. True\<rbrace>
\<Longrightarrow> P s0 s
\<Longrightarrow> cres1 = cres2
\<Longrightarrow> Q = (\<lambda>xs. length xs < length ctr1 \<and> (fst (rev ctr1 ! length xs) \<noteq> Env
\<or> fst (rev ctr2 ! length xs) \<noteq> Env))
\<Longrightarrow> self_closed Q s (parallel f g)"
apply (subst self_closed_def, clarsimp)
apply (subst(asm) parallel_def, clarsimp)
apply (frule list_all2_lengthD[symmetric])
apply (strengthen in_fst_snd_image)
apply (simp add: par_tr_fragment_parallel_def)
apply (strengthen exI[where x="x # xs" for x xs])
apply (clarsimp simp: length_Suc_conv)
apply (frule(1) list_all2_rev_nthD, clarsimp)
apply (case_tac "fst (rev ctr1 ! length xs) = Env"; simp)
apply (frule is_matching_fragment_self_closed[where f=g],
drule(1) self_closedD, simp add: eq_Me_neq_Env)
apply (thin_tac "v \<in> g s" for v s)
apply clarsimp
apply (frule(1) is_matching_fragment_trD[where f=g])
apply clarsimp
apply (frule(3) validI_GD[where f=g])
apply (clarsimp simp: guar_cond_Cons_eq matching_tr_pfx_aCons)
apply (drule_tac s'=s' in matching_env_closedD[where f=f], simp+)
apply (simp add: last_st_tr_map_zip)
apply (clarsimp simp: ex_bool_eq del: disjCI)
apply (blast intro: in_fst_snd_image)
(* pretty much identical proof for symmetric case. sad. *)
apply (frule is_matching_fragment_self_closed[where f=f],
drule(1) self_closedD, simp add: eq_Me_neq_Env)
apply (thin_tac "v \<in> f s" for v s)
apply clarsimp
apply (frule(1) is_matching_fragment_trD[where f=f])
apply clarsimp
apply (frule(3) validI_GD[where f=f])
apply (clarsimp simp: guar_cond_Cons_eq matching_tr_pfx_aCons)
apply (drule_tac s'=s' in matching_env_closedD[where f=g], simp+)
apply (simp add: last_st_tr_map_zip)
apply (clarsimp simp: ex_bool_eq del: disjCI)
apply (blast intro: in_fst_snd_image)
done
lemma is_matching_fragment_validI_disj:
"is_matching_fragment sr osr rvr b_tr bd_res s0 R s f
\<Longrightarrow> triv_refinement g f
\<Longrightarrow> G = \<top>\<top> \<or> \<lbrace>P\<rbrace>,\<lbrace>R\<rbrace> g \<lbrace>G\<rbrace>,\<lbrace>\<lambda>_ _ _. True\<rbrace>
\<Longrightarrow> \<lbrace>P\<rbrace>,\<lbrace>R\<rbrace> f \<lbrace>G\<rbrace>,\<lbrace>\<lambda>_ _ _. True\<rbrace>"
apply (frule is_matching_fragment_prefix_closed)
apply (erule disjE)
apply (simp add: validI_def guar_cond_def)
apply (erule(2) validI_triv_refinement)
done
lemma rely_prefix_closed:
"prefix_closed f \<Longrightarrow> prefix_closed (rely f R s0)"
apply (subst prefix_closed_def, clarsimp simp: rely_def rely_cond_Cons_eq)
apply (erule(1) prefix_closedD)
done
lemma rely_self_closed:
"self_closed P s f \<Longrightarrow> self_closed P s (rely f R s0)"
apply (subst self_closed_def, clarsimp simp: rely_def rely_cond_Cons_eq)
apply (drule(2) self_closedD)
apply (fastforce simp: rely_cond_Cons_eq)
done
lemma rely_env_closed:
"env_closed P s f
\<Longrightarrow> (\<forall>xs s. P' xs s \<longrightarrow> rely_cond R s0 xs \<longrightarrow> P xs s \<and> R (last_st_tr xs s0) s)
\<Longrightarrow> env_closed P' s (rely f R s0)"
apply (subst env_closed_def, clarsimp simp: rely_def)
apply (drule_tac s'=s' in env_closedD, assumption)
apply simp
apply (clarsimp simp: image_def)
apply (fastforce intro: rely_cond_Cons rev_bexI)
done
theorem prefix_refinement_parallel:
"prefix_refinement sr isr osr rvr P Q (AE Or Gc) (E Or Gd) a b
\<Longrightarrow> prefix_refinement sr isr osr rvr P Q (AE Or Ga) (E Or Gb) c d
\<Longrightarrow> par_tr_fin_principle a
\<Longrightarrow> par_tr_fin_principle c
\<Longrightarrow> \<lbrace>Q\<rbrace>,\<lbrace>E Or Gd\<rbrace> b \<lbrace>Gb\<rbrace>,\<lbrace>\<lambda>_ _ _. True\<rbrace>
\<Longrightarrow> \<lbrace>Q\<rbrace>,\<lbrace>E Or Gb\<rbrace> d \<lbrace>Gd\<rbrace>,\<lbrace>\<lambda>_ _ _. True\<rbrace>
\<Longrightarrow> (Ga = \<top>\<top> \<and> Gc = \<top>\<top>)
\<or> (\<lbrace>P\<rbrace>,\<lbrace>AE Or Gc\<rbrace> a \<lbrace>Ga\<rbrace>,\<lbrace>\<lambda>_ _ _. True\<rbrace>
\<and> \<lbrace>P\<rbrace>,\<lbrace>AE Or Ga\<rbrace> c \<lbrace>Gc\<rbrace>,\<lbrace>\<lambda>_ _ _. True\<rbrace>)
\<Longrightarrow> prefix_refinement sr isr osr rvr P Q AE E (parallel a c) (parallel b d)"
apply (subst prefix_refinement_def, clarsimp)
apply (drule tr_in_parallel, clarify)
apply (frule(6) tr_in_parallel_validI)
apply (clarsimp simp: parallel_def3)
apply (rename_tac b_tr d_tr bd_res)
apply (drule(5) prefix_refinementD)+
apply clarsimp
apply (rename_tac f_a f_c)
apply (rule_tac x="rely (parallel f_a f_c) AE s0" in exI)
apply (rule conjI[rotated])
apply (simp add: parallel_def3 triv_refinement_def rely_def)
apply blast
apply (subst is_matching_fragment_def, clarsimp)
apply (frule(1) is_matching_fragment_validI_disj[where g=a and G=Ga], blast)
apply (frule(1) is_matching_fragment_validI_disj[where g=c and G=Gc], blast)
apply (intro conjI parallel_prefix_closed rely_prefix_closed rely_self_closed,
simp_all add: is_matching_fragment_prefix_closed)
apply (rule self_closed_parallel_fragment,
(assumption | erule par_tr_fin_principle_triv_refinement[rotated])+)
apply simp
apply (frule list_all2_lengthD)
apply (simp add: list_all2_lengthD eq_Me_neq_Env rev_nth split_def fun_eq_iff
cong: conj_cong)
apply (rule rely_env_closed[where P=P and P'=P for P, rotated])
apply (simp add: rely_cond_Cons_eq)
apply (rule env_closed_parallel_fragment,
(assumption | erule par_tr_fin_principle_triv_refinement[rotated])+)
apply simp
apply (simp add: list_all2_lengthD)
apply (clarsimp simp: matching_tr_pfx_aCons rev_map split_def
zip_rev[symmetric] list_all2_lengthD[symmetric]
rely_cond_Cons_eq)
apply (frule list_all2_lengthD)
apply (drule(1) list_all2_rev_nthD, simp)
apply (simp split: if_split_asm)
apply (simp add: rely_def par_tr_fragment_parallel_def list_all2_lengthD
par_tr_fin_principle_triv_refinement set_eq_iff)
apply (strengthen exI[where x=Nil] in_fst_snd_image)+
apply (simp add: is_matching_fragment_Nil[simplified image_def Bex_def, simplified])
apply (clarsimp simp: parallel_def3 rely_def)
apply (drule(1) is_matching_fragment_trD)+
apply (clarsimp simp: list_all2_lengthD)
apply (rule matching_tr_pfx_parallel_zip; assumption?)
apply (simp add: list_all2_lengthD)
done
lemma validI_triv':
"prefix_closed f \<Longrightarrow> \<lbrace>P\<rbrace>,\<lbrace>R\<rbrace> f \<lbrace>\<lambda>_ _. True\<rbrace>,\<lbrace>\<lambda>_ _ _. True\<rbrace>"
by (simp add: validI_def guar_cond_def)
lemmas validI_triv = validI_triv'[where P="\<top>\<top>"]
lemmas prefix_refinement_parallel_ART
= prefix_refinement_parallel[OF _ _ _ _ _ _ disjI1[OF conjI, OF refl refl]]
lemmas prefix_refinement_parallel_triv
= prefix_refinement_parallel_ART[OF _ _ _ _ validI_triv' validI_triv']
lemmas prefix_refinement_parallel'
= prefix_refinement_parallel[OF _ _ _ _ _ _ disjI2[OF conjI]]
lemma pfx_trace_set_allD:
"\<forall>n. \<forall>v\<in>set (take n xs). P n v \<Longrightarrow> v \<in> set (take n xs)
\<Longrightarrow> P n v"
by simp
lemma prefix_closed_UNION:
"(\<forall>s' x. x \<in> S s' \<longrightarrow> prefix_closed (f x))
\<Longrightarrow> prefix_closed (\<lambda>s. \<Union>x \<in> S s. f x s)"
apply (simp add: prefix_closed_def)
apply (blast intro: in_fst_snd_image)
done
lemma is_matching_fragment_UNION:
"(\<forall>x. x \<in> S s \<longrightarrow> is_matching_fragment sr osr rvr ctr cres s0 R s (f x))
\<Longrightarrow> (\<forall>s' x. x \<in> S s' \<longrightarrow> prefix_closed (f x))
\<Longrightarrow> S s \<noteq> {}
\<Longrightarrow> is_matching_fragment sr osr rvr ctr cres s0 R s (\<lambda>s. \<Union>x \<in> S s. f x s)"
apply (clarsimp simp: is_matching_fragment_def prefix_closed_UNION)
apply (intro conjI impI)
apply (clarsimp simp: self_closed_def split_def in_fst_snd_image_eq)
apply blast
apply (clarsimp simp: env_closed_def split_def in_fst_snd_image_eq)
apply blast
done
definition
mbind :: "('s, 'a) tmonad \<Rightarrow> ('s \<Rightarrow> 'a \<Rightarrow> ('s, 'b) tmonad) \<Rightarrow>
's \<Rightarrow> ('s, 'b) tmonad"
where
"mbind f g s0 \<equiv> \<lambda>s. \<Union>(xs, r) \<in> (f s). case r of Failed \<Rightarrow> {(xs, Failed)}
| Incomplete \<Rightarrow> {(xs, Incomplete)}
| Result (rv, s) \<Rightarrow> fst_upd (\<lambda>ys. ys @ xs) ` g (last_st_tr xs s0) rv s"
lemma self_closed_mbind:
"is_matching_fragment sr osr rvr ctr cres s0 R s f
\<Longrightarrow> (\<forall>tr x s'. (tr, Result (x, s')) \<in> f s
\<longrightarrow> self_closed (\<lambda>xs. length xs < length ctr' \<and> fst (rev ctr' ! length xs) = Me) s'
(g (last_st_tr tr s0) x) \<and> [] \<in> fst ` g (last_st_tr tr s0) x s')
\<Longrightarrow> Q = matching_self_cond (ctr' @ ctr)
\<Longrightarrow> cres = Incomplete \<longrightarrow> ctr' = []
\<Longrightarrow> self_closed Q s (mbind f g s0)"
apply (frule is_matching_fragment_self_closed)
apply (subst self_closed_def, clarsimp simp: mbind_def)
apply (rename_tac tr res)
apply (strengthen in_fst_snd_image, simp)
apply (frule(1) is_matching_fragment_trD)
apply (case_tac "length tr < length ctr")
apply clarsimp
apply (drule(1) self_closedD)
apply (simp add: trans[OF nth_append if_P])
apply clarsimp
apply (thin_tac "(x, Incomplete) \<in> S" for x S)
apply (strengthen rev_bexI[mk_strg I E])
apply (clarsimp split: tmres.split)
apply (fastforce elim: image_eqI[rotated] intro: in_mres)
apply (clarsimp simp: matching_tr_pfx_def)
apply (erule tmres.rel_cases; clarsimp)
apply (drule spec2, drule spec, drule(1) mp)
apply clarsimp
apply (drule(1) self_closedD)
apply (simp add: trans[OF nth_append if_not_P])
apply (strengthen rev_bexI[mk_strg I E])
apply simp
apply (fastforce elim: image_eqI[rotated])
done
lemma matching_tr_pfx_rhs_is_extend:
fixes ys ys'
defines "N == length ys' - length ys"
shows
"matching_tr_pfx sr xs ys
\<Longrightarrow> length xs \<le> length ys \<longrightarrow> drop N ys' = ys
\<Longrightarrow> matching_tr_pfx sr xs ys'"
apply (clarsimp simp: matching_tr_pfx_def)
apply (rule context_conjI)
apply simp
apply (simp add: matching_tr_def list_all2_conv_all_nth
min_def)
apply (clarsimp simp: rev_nth)
done
lemma matching_tr_pfx_rhs_is_drop:
fixes ys ys'
defines "N == length ys - length ys'"
shows
"matching_tr_pfx sr xs ys
\<Longrightarrow> drop N ys = ys'
\<Longrightarrow> length xs \<le> length ys'
\<Longrightarrow> matching_tr_pfx sr xs ys'"
apply (clarsimp simp: matching_tr_pfx_def)
apply (simp add: matching_tr_def list_all2_conv_all_nth
min_def)
apply (clarsimp simp: rev_nth)
done
lemma env_closed_mbind:
"is_matching_fragment sr osr rvr ctr' cres s0 R s f
\<Longrightarrow> \<forall>tr x s'. (tr, Result (x, s')) \<in> f s
\<longrightarrow> env_closed (matching_env_cond sr ctr'' (last_st_tr tr s0) R) s' (g (last_st_tr tr s0) x)
\<and> [] \<in> fst ` g (last_st_tr tr s0) x s'
\<Longrightarrow> (if cres \<in> {Incomplete, Failed} then ctr = ctr' else ctr = ctr'' @ ctr')
\<Longrightarrow> Q = matching_env_cond sr ctr s0 R
\<Longrightarrow> env_closed Q s (mbind f g s0)"
apply (simp add: if_bool_eq_conj)
apply (subst env_closed_def, clarsimp simp: mbind_def)
apply (strengthen in_fst_snd_image, simp)
apply (rename_tac f_tr f_res s')
apply (case_tac "f_res = Incomplete")
apply (frule(1) is_matching_fragment_trD)
apply clarsimp
apply (drule is_matching_fragment_env_closed)
apply (drule_tac s'=s' in env_closedD, assumption)
apply (clarsimp simp: matching_tr_pfx_aCons matching_tr_pfx_def)
apply (cases cres; clarsimp)
apply clarsimp
apply (strengthen bexI[where x="(x # xs, r)" for x xs r, mk_strg I _ E])
apply (simp split: tmres.split)
apply clarsimp
apply (drule spec2, drule spec, drule(1) mp)
apply clarsimp
apply (strengthen image_eqI[mk_strg I _ E])
apply simp
apply (frule(1) is_matching_fragment_trD)
apply (case_tac f_res; clarsimp)
apply (cases cres; clarsimp simp: matching_tr_pfx_def)
apply (strengthen bexI[mk_strg I _ E], simp)
apply (drule spec2, drule spec, drule(1) mp)+
apply clarsimp
apply (drule_tac s'=s' in env_closedD, assumption)
apply (simp add: rely_cond_append rely_cond_Cons_eq matching_tr_pfx_aCons)
apply (clarsimp simp: nth_append)
apply (clarsimp simp: matching_tr_def list_all2_append)
apply clarsimp
apply (fastforce elim: image_eqI[rotated])
done
lemma mbind_prefix_closed:
"prefix_closed f
\<Longrightarrow> \<forall>tr x s' s. (tr, Result (x, s')) \<in> f s \<longrightarrow> prefix_closed (g (last_st_tr tr s0) x)
\<Longrightarrow> prefix_closed (mbind f g s0)"
apply (subst prefix_closed_def, clarsimp simp: mbind_def)
apply (split tmres.split_asm; clarsimp;
(drule(1) prefix_closedD, fastforce elim: rev_bexI)?)
apply (simp add: Cons_eq_append_conv, safe)
apply (drule(1) prefix_closedD)
apply (fastforce elim: rev_bexI)
apply (drule spec2, drule mp, blast)
apply (erule rev_bexI, clarsimp)
apply (drule(1) prefix_closedD)
apply fastforce
done
lemma is_matching_fragment_mbind:
"is_matching_fragment sr intsr rvr ctr cres s0 R s f_a
\<Longrightarrow> \<forall>tr x s'. (tr, Result (x, s')) \<in> f_a s
\<longrightarrow> is_matching_fragment sr osr rvr' ctr' cres' (last_st_tr tr s0) R s' (f_b (last_st_tr tr s0) x)
\<Longrightarrow> \<forall>s0' x. prefix_closed (f_b s0' x)
\<Longrightarrow> ctr'' = ctr' @ ctr
\<Longrightarrow> cres'' = (case cres of Failed \<Rightarrow> Failed | Incomplete \<Rightarrow> Incomplete | _ \<Rightarrow> cres')
\<Longrightarrow> (cres = Incomplete \<or> cres = Failed) \<longrightarrow> ctr' = []
\<Longrightarrow> is_matching_fragment sr osr rvr' ctr'' cres'' s0 R s
(mbind f_a f_b s0)"
apply (subst is_matching_fragment_def, clarsimp)
apply (strengthen env_closed_mbind[where ctr''=ctr', mk_strg I E]
mbind_prefix_closed
self_closed_mbind[where ctr'="ctr'", mk_strg I E])
apply (simp add: conj_comms if_bool_eq_conj mres_def split del: if_split)
apply (intro conjI allI impI; clarsimp?;
(blast intro: is_matching_fragment_prefix_closed
is_matching_fragment_env_closed
is_matching_fragment_Nil
is_matching_fragment_self_closed
dest: post_by_hoare)?)
apply (clarsimp simp: mbind_def)
apply (frule_tac s=s in is_matching_fragment_defD)
apply (drule ex_in_conv[THEN iffD2], clarsimp)
apply (drule(1) bspec)
apply (rename_tac res; case_tac res; clarsimp)
apply (drule spec2, drule spec, drule(1) mp)
apply (fastforce dest: is_matching_fragment_defD)
apply (clarsimp simp: mbind_def)
apply (drule(1) is_matching_fragment_trD)
apply (clarsimp simp: matching_tr_pfx_def split: tmres.split_asm)
apply (drule spec2, drule spec, drule(1) mp)
apply (drule(1) is_matching_fragment_trD)
apply (clarsimp simp: matching_tr_pfx_def matching_tr_def
list_all2_appendI rely_cond_append)
done
lemma is_matching_fragment_mbind_union:
"is_matching_fragment sr intsr rvr ctr cres s0 R s f_a
\<Longrightarrow> ctr'' = ctr' @ ctr
\<Longrightarrow> cres'' = (case cres of Failed \<Rightarrow> Failed | Incomplete \<Rightarrow> Incomplete | _ \<Rightarrow> cres')
\<Longrightarrow> cres = Incomplete \<or> cres = Failed \<longrightarrow> ctr' = []
\<Longrightarrow> \<forall>tr x s'. (tr, Result (x, s')) \<in> f_a s
\<longrightarrow> (\<exists>f. is_matching_fragment sr osr rvr' ctr' cres' (last_st_tr tr s0) R s' f
\<and> triv_refinement (aprog x) f)
\<Longrightarrow> is_matching_fragment sr osr rvr' ctr'' cres'' s0 R s
(mbind f_a (\<lambda>s0' rv s. \<Union>f \<in> {f. is_matching_fragment sr osr rvr' ctr' cres' s0' R s f
\<and> triv_refinement (aprog rv) f}. f s) s0)"
apply (rule is_matching_fragment_mbind; assumption?)
apply clarsimp
apply (rule is_matching_fragment_UNION)
apply clarsimp
apply (clarsimp simp: is_matching_fragment_prefix_closed)
apply clarsimp
apply clarsimp
apply (rule prefix_closed_UNION)
apply (clarsimp simp: is_matching_fragment_prefix_closed)
done
lemma is_matching_fragment_mresD:
"is_matching_fragment sr osr rvr ctr cres s0 R s f
\<Longrightarrow> (x, s') \<in> mres (f s)
\<Longrightarrow> \<exists>y s''. cres = Result (y, s'') \<and> osr s' s'' \<and> rvr x y"
apply (clarsimp simp: mres_def)
apply (frule(1) is_matching_fragment_trD)
apply (clarsimp simp: matching_tr_pfx_def)
apply (erule tmres.rel_cases; clarsimp)
done
lemma matching_tr_pfx_sr_hd_append:
"matching_tr_pfx sr tr tr'
\<Longrightarrow> sr s0 t0
\<Longrightarrow> length tr \<ge> length tr'
\<Longrightarrow> sr (hd (map snd tr @ [s0])) (hd (map snd tr' @ [t0]))"
apply (clarsimp simp: matching_tr_pfx_def matching_tr_def)
apply (erule list.rel_cases; clarsimp)
done
lemma matching_tr_pfx_last_st_tr:
"matching_tr_pfx sr tr tr'
\<Longrightarrow> sr s0 t0
\<Longrightarrow> length tr \<ge> length tr'
\<Longrightarrow> sr (last_st_tr tr s0) (last_st_tr tr' t0)"
apply (clarsimp simp: matching_tr_pfx_def matching_tr_def)
apply (erule list.rel_cases; clarsimp)
done
lemma validI_relyT_mresD:
"\<lbrace>P'\<rbrace>,\<lbrace>\<top>\<top>\<rbrace> f \<lbrace>G\<rbrace>,\<lbrace>P''\<rbrace>
\<Longrightarrow> (rv, s') \<in> mres (f s)
\<Longrightarrow> P' s0 s
\<Longrightarrow> \<exists>s0'. P'' rv s0' s'"
apply (clarsimp simp: mres_def)
apply (drule(2) validI_rvD)
apply (simp add: rely_cond_def)
apply blast
done
theorem prefix_refinement_bind_general[rule_format]:
"prefix_refinement sr isr intsr rvr P Q AR R a c
\<Longrightarrow> (\<forall>x y. rvr x y \<longrightarrow> prefix_refinement sr intsr osr rvr' (P'' x) (Q'' y) AR R (b x) (d y))
\<Longrightarrow> \<lbrace>P'\<rbrace>,\<lbrace>AR\<rbrace> a \<lbrace>\<top>\<top>\<rbrace>,\<lbrace>P''\<rbrace> \<or> \<lbrace>\<lambda>s. \<exists>s0. P' s0 s\<rbrace> a \<lbrace>\<lambda>rv s. \<forall>s0. P'' rv s0 s\<rbrace>
\<Longrightarrow> \<lbrace>Q'\<rbrace>,\<lbrace>R\<rbrace> c \<lbrace>\<top>\<top>\<rbrace>,\<lbrace>Q''\<rbrace>
\<Longrightarrow> prefix_refinement sr isr osr rvr' (P And P') (Q And Q') AR R (a >>= b) (c >>= d)"
apply (subst prefix_refinement_def, clarsimp simp: bind_def)
apply (rename_tac c_tr c_res cd_tr cd_res)
apply (drule(5) prefix_refinementD, simp)
apply (drule mp)
apply (erule rely_cond_is_drop, clarsimp split: tmres.split_asm)
apply clarsimp
apply (rename_tac f_a)
apply (case_tac "c_res = Incomplete \<or> c_res = Failed")
apply (intro exI conjI)
apply (rule_tac ctr'=Nil and cres'=Failed and f_b="\<lambda>_ _ _. {}"
in is_matching_fragment_mbind, assumption, simp_all add: prefix_closed_def)[1]
apply clarsimp
apply (frule is_matching_fragment_mresD, erule in_mres)
apply clarsimp
apply (clarsimp split: tmres.split_asm)
apply (clarsimp split: tmres.split_asm)
apply (clarsimp simp: triv_refinement_def mbind_def)
apply (rule rev_bexI, drule spec, erule(1) subsetD)
apply (clarsimp split: tmres.split_asm)
apply (clarsimp split: tmres.split_asm)
apply (frule(2) validI_rvD, simp add: rely_cond_append)
apply (intro exI conjI)
apply (rule is_matching_fragment_mbind_union[where aprog="b"],
assumption, simp_all)[1]
apply clarsimp
apply (frule is_matching_fragment_mresD, erule in_mres)
apply (clarsimp simp: mres_def)
apply (frule(1) is_matching_fragment_trD)
apply clarsimp
apply (rule prefix_refinementD[where x="(a, b)" for a b, simplified, rule_format],
blast, simp_all)[1]
prefer 2
apply (erule(1) matching_tr_pfx_last_st_tr)
apply simp
apply (erule disjE)
apply (drule(1) validI_rvD[OF validI_triv_refinement],
erule is_matching_fragment_prefix_closed, assumption+)
apply (drule(2) use_valid[OF in_mres valid_triv_refinement], blast, simp)
apply (clarsimp simp: rely_cond_append hd_append hd_map cong: if_cong)
apply (clarsimp simp: triv_refinement_def mbind_def)
apply (rule rev_bexI, drule spec, erule(1) subsetD)
apply (clarsimp split: tmres.split_asm)
apply (rule image_eqI[where x="(a, b)" for a b], simp)
apply blast
done
section \<open>Using prefix refinement.\<close>
text \<open>
Using prefix refinement to map the validI Hoare quadruple
(precond/rely/guarantee/postcond). Proofs of quadruples for
abstract programs imply related quadruples for concrete
programs.
\<close>
lemma list_all2_all_trace_steps:
assumes P: "\<forall>x\<in>trace_steps (rev tr) s0. P x"
and lR': "list_all2 (\<lambda>(aid, as) (cid, cs). aid = cid \<and> R' as cs) tr' tr"
and R': "R' s0' s0"
and Q: "\<forall>idn as1 as2 cs1 cs2. R' as1 cs1 \<longrightarrow> R' as2 cs2
\<longrightarrow> P (idn, cs1, cs2) \<longrightarrow> Q (idn, as1, as2)"
shows "\<forall>x\<in>trace_steps (rev tr') s0'. Q x"
proof -
note lR'' = lR'[simplified trans[OF list_all2_rev[symmetric] list_all2_conv_all_nth],
simplified split_def, THEN conjunct2, rule_format]
note len[simp] = lR'[THEN list_all2_lengthD]
show ?thesis
using P R'
apply (clarsimp simp: trace_steps_nth)
apply (drule_tac x=x in bspec, simp)
apply (frule lR''[simplified])
apply (cut_tac i="x - 1" in lR'', simp)
apply (auto simp: Q)
done
qed
theorem prefix_refinement_validI:
"prefix_refinement sr isr osr rvr prP' prP R' R f g
\<Longrightarrow> \<lbrace>P'\<rbrace>,\<lbrace>R'\<rbrace>
f \<lbrace>\<lambda>s0 s. \<forall>cs0 cs. sr s0 cs0 \<and> sr s cs \<longrightarrow> G cs0 cs\<rbrace>,\<lbrace>\<lambda>rv
s0 s. \<forall>rv' cs0 cs. sr s0 cs0 \<and> osr s cs \<and> rvr rv rv' \<longrightarrow> Q rv' cs0 cs\<rbrace>
\<Longrightarrow> \<forall>t0 t. P t0 t \<longrightarrow> (\<exists>s0 s. P' s0 s \<and> prP' s0 s \<and> prP t0 t \<and> isr s t \<and> sr s0 t0)
\<Longrightarrow> \<forall>s0 t0 t. sr s0 t0 \<and> R t0 t \<longrightarrow> (\<exists>s. R' s0 s \<and> sr s t)
\<Longrightarrow> prefix_closed g
\<Longrightarrow> \<lbrace>P\<rbrace>,\<lbrace>R\<rbrace> g \<lbrace>G\<rbrace>,\<lbrace>Q\<rbrace>"
apply (subst validI_def, clarsimp simp: bipred_conj_def rely_def)
apply (drule spec2, drule(1) mp, clarsimp)
apply (drule(6) prefix_refinement_rely_cond_trD[where R'=R', simplified])
apply blast
apply clarsimp
apply (rule conjI)
apply (frule(3) validI_GD)
apply (simp add: guar_cond_def matching_tr_def)
apply (erule_tac R'="\<lambda>cs s. sr s cs" in list_all2_all_trace_steps)
apply (clarsimp simp: list_all2_conv_all_nth split_def)
apply simp
apply clarsimp
apply clarsimp
apply (erule tmres.rel_cases; clarsimp)
apply (drule(1) validI_rvD, simp add: rely_def)
apply simp
apply (case_tac tr; clarsimp simp: list_all2_Cons2 matching_tr_def)
done
lemmas prefix_refinement_validI' = prefix_refinement_validI[OF _ validI_strengthen_guar, OF _ validI_strengthen_post]
section \<open>Building blocks.\<close>
text \<open>
Prefix refinement rules for various basic constructs.
\<close>
lemma prefix_refinement_weaken_pre:
"prefix_refinement sr isr osr rvr P' Q' AR R f g
\<Longrightarrow> \<forall>s s0. P s0 s \<longrightarrow> P' s0 s
\<Longrightarrow> (\<forall>s t s0 t0. isr s t \<longrightarrow> sr s0 t0 \<longrightarrow> P s0 s \<longrightarrow> Q t0 t \<longrightarrow> Q' t0 t)
\<Longrightarrow> prefix_refinement sr isr osr rvr P Q AR R f g"
by (fastforce simp: prefix_refinement_def)
lemma prefix_refinement_name_pre:
"(\<And>s s0 t t0. isr s t \<Longrightarrow> sr s0 t0 \<Longrightarrow> P s0 s \<Longrightarrow> Q t0 t
\<Longrightarrow> prefix_refinement sr isr osr rvr (\<lambda>s0' s'. s0' = s0 \<and> s' = s) (\<lambda>t0' t'. t0' = t0 \<and> t' = t) AR R f g)
\<Longrightarrow> prefix_refinement sr isr osr rvr P Q AR R f g"
by (fastforce simp: prefix_refinement_def)
lemma prefix_refinement_bind_v[rule_format]:
"prefix_refinement sr isr intsr rvr P Q AR R a c
\<Longrightarrow> (\<forall>x y. rvr x y \<longrightarrow> prefix_refinement sr intsr osr rvr' (\<lambda>s0. P'' x) (Q'' y) AR R (b x) (d y))
\<Longrightarrow> \<lbrace>P'\<rbrace> a \<lbrace>P''\<rbrace> \<Longrightarrow> \<lbrace>Q'\<rbrace>,\<lbrace>R\<rbrace> c \<lbrace>\<top>\<top>\<rbrace>,\<lbrace>Q''\<rbrace>
\<Longrightarrow> prefix_refinement sr isr osr rvr' (\<lambda>s0. P s0 and P') (Q And Q') AR R (a >>= b) (c >>= d)"
apply (rule prefix_refinement_weaken_pre,
rule prefix_refinement_bind_general[where P'="\<lambda>_. P'"])
apply assumption
apply (elim allE, erule(1) mp)
apply (rule disjI2)
apply simp
apply assumption
apply clarsimp
apply clarsimp
done
lemmas prefix_refinement_bind
= prefix_refinement_bind_general[OF _ _ disjI1]
lemma default_prefix_refinement_ex:
"is_matching_fragment sr osr rvr ctr cres s0 R s
(\<lambda>s. aprog s \<inter> ({tr'. length tr' \<le> length ctr} \<times> UNIV))
\<Longrightarrow> \<exists>f. is_matching_fragment sr osr rvr ctr cres s0 R s f
\<and> triv_refinement aprog f"
apply (intro exI conjI, assumption)
apply (simp add: triv_refinement_def)
done
lemma default_prefix_refinement_ex_match_iosr_R:
"is_matching_fragment sr osr rvr ctr cres s0 R s
(rely (\<lambda>s. aprog s \<inter> ({tr'. matching_tr_pfx iosr tr' ctr} \<times> UNIV)) R s0)
\<Longrightarrow> \<exists>f. is_matching_fragment sr osr rvr ctr cres s0 R s f
\<and> triv_refinement aprog f"
apply (intro exI conjI, assumption)
apply (clarsimp simp add: triv_refinement_def rely_def)
done
lemma is_matching_fragment_no_trace:
"is_matching_fragment sr osr rvr [] cres s0 R s (\<lambda>s. {([], ares s)})
= rel_tmres osr rvr (ares s) cres"
by (simp add: is_matching_fragment_def prefix_closed_def
self_closed_def env_closed_def
matching_tr_pfx_def matching_tr_def)
lemma prefix_refinement_return_imp:
"(\<forall>s s0 t0 t. P s0 s \<and> Q t0 t \<and> isr s t \<longrightarrow> rvr rv rv' \<and> osr s t)
\<Longrightarrow> prefix_refinement sr isr osr rvr P Q AR R (return rv) (return rv')"
apply (clarsimp simp: prefix_refinement_def)
apply (rule default_prefix_refinement_ex)
apply (auto simp add: return_def is_matching_fragment_no_trace)
done
abbreviation(input)
"dc2 \<equiv> (\<lambda>_ _. True)"
abbreviation
"pfx_refnT sr rvr \<equiv> pfx_refn sr rvr (\<lambda>_ _. True) dc2"
lemma pfx_refn_return:
"rvr rv rv'
\<Longrightarrow> pfx_refnT sr rvr AR R (return rv) (return rv')"
by (rule prefix_refinement_return_imp, simp)
lemma prefix_refinement_get:
"prefix_refinement sr iosr iosr iosr dc2 dc2 AR R get get"
apply (clarsimp simp: prefix_refinement_def get_def)
apply (rule default_prefix_refinement_ex)
apply (simp add: is_matching_fragment_no_trace)
done
lemma prefix_refinement_put:
"osr s t \<Longrightarrow> prefix_refinement sr isr osr dc2 dc2 dc2 AR R (put s) (put t)"
apply (clarsimp simp: prefix_refinement_def put_def)
apply (rule default_prefix_refinement_ex)
apply (simp add: is_matching_fragment_no_trace)
done
lemma prefix_refinement_select:
"(\<forall>x \<in> T. \<exists>y \<in> S. rvr y x)
\<Longrightarrow> prefix_refinement sr iosr iosr rvr dc2 dc2 AR R (select S) (select T)"
apply (clarsimp simp: prefix_refinement_def select_def)
apply (drule(1) bspec, clarsimp)
apply (rule_tac x="return y" in exI)
apply (simp add: is_matching_fragment_def self_closed_def env_closed_def return_def
prefix_closed_def matching_tr_pfx_def matching_tr_def)
apply (auto simp add: triv_refinement_def return_def image_def)
done
lemma Int_insert_left2:
"(insert a B \<inter> C) = ((if a \<in> C then {a} else {}) \<union> (B \<inter> C))"
by auto
definition
rely_stable :: "('t \<Rightarrow> 't \<Rightarrow> bool) \<Rightarrow> ('s \<Rightarrow> 't \<Rightarrow> bool) \<Rightarrow> ('t \<Rightarrow> bool) \<Rightarrow> bool"
where
"rely_stable R sr Q = (\<forall>s t t'. Q t \<and> sr s t \<and> R t t' \<longrightarrow> Q t' \<and> (\<exists>s'. sr s' t'))"
lemmas rely_stableD = rely_stable_def[THEN iffD1, simplified imp_conjL, rule_format]
definition
env_rely_stable_iosr :: "'s rg_pred \<Rightarrow> 't rg_pred
\<Rightarrow> ('s \<Rightarrow> 't \<Rightarrow> bool) \<Rightarrow> ('s \<Rightarrow> 't \<Rightarrow> bool) \<Rightarrow> ('t \<Rightarrow> bool) \<Rightarrow> bool"
where
"env_rely_stable_iosr AR R sr iosr Q
= (\<forall>s0 t0 s t. Q t0 \<longrightarrow> iosr s0 t0 \<longrightarrow> R t0 t \<longrightarrow> AR s0 s \<longrightarrow> sr s t \<longrightarrow> iosr s t)"
lemmas env_rely_stable_iosrD = env_rely_stable_iosr_def[THEN iffD1, rule_format]
definition
env_stable :: "'s rg_pred \<Rightarrow> 't rg_pred
\<Rightarrow> ('s \<Rightarrow> 't \<Rightarrow> bool) \<Rightarrow> ('s \<Rightarrow> 't \<Rightarrow> bool) \<Rightarrow> ('t \<Rightarrow> bool) \<Rightarrow> bool"
where
"env_stable AR R sr iosr Q = (rely_stable R sr Q
\<and> env_rely_stable_iosr AR R sr iosr Q \<and> iosr \<le> sr)"
definition
abs_rely_stable :: "('s \<Rightarrow> 's \<Rightarrow> bool) \<Rightarrow> ('s \<Rightarrow> bool) \<Rightarrow> bool"
where
"abs_rely_stable R P = (\<forall>s s'. P s \<and> R s s' \<longrightarrow> P s')"
lemmas abs_rely_stableD = abs_rely_stable_def[THEN iffD1, simplified imp_conjL, rule_format]
lemma abs_rely_stableT:
"abs_rely_stable AR \<top>"
by (simp add: abs_rely_stable_def)
lemma rely_stable_rtranclp:
"rely_stable R sr Q
\<Longrightarrow> sr s t \<Longrightarrow> Q t
\<Longrightarrow> rtranclp R t t'
\<Longrightarrow> Q t'"
apply (rotate_tac 3, induct arbitrary: s rule: converse_rtranclp_induct)
apply simp
apply (clarsimp simp: rely_stable_def)
apply metis
done
lemma abs_rely_stable_rtranclp:
"abs_rely_stable R P
\<Longrightarrow> P s \<Longrightarrow> rtranclp R s s'
\<Longrightarrow> P s'"
apply (rotate_tac 2, induct rule: converse_rtranclp_induct)
apply simp
apply (clarsimp simp: abs_rely_stable_def)
done
lemma prefix_refinement_env_step:
assumes env_stable: "env_stable AR R sr iosr Q"
shows "prefix_refinement sr iosr iosr dc2 (\<lambda>s0 s. s0 = s) (\<lambda>t0 t. t0 = t \<and> Q t0)
AR R env_step env_step"
proof -
have P: "\<And>S. {xs. length xs = Suc 0} = (\<lambda>x. [x]) ` UNIV"
apply (safe, simp_all)
apply (case_tac x, auto)
done
have st: "rely_stable R sr Q" and est: "env_rely_stable_iosr AR R sr iosr Q"
and sr: "iosr \<le> sr"
using env_stable
by (auto simp: env_stable_def)
show ?thesis
apply (simp add: env_step_def P)
apply (clarsimp simp: prefix_refinement_def get_def select_def P
bind_def return_def put_def put_trace_elem_def Sigma_def)
apply (strengthen default_prefix_refinement_ex_match_iosr_R[where iosr=iosr])
apply (simp add: is_matching_fragment_def rely_cond_def rely_def)
apply (simp add: matching_tr_pfx_def matching_tr_def)
apply (simp only: UN_extend_simps Int_insert_left2)
apply (simp add: is_matching_fragment_def UN_If_distrib)
apply (intro conjI allI impI;
simp add: prefix_closed_def in_fst_snd_image_eq self_closed_def
matching_tr_pfx_def matching_tr_def
env_closed_def)
apply (metis env_rely_stable_iosrD[OF est])
apply clarsimp
apply (auto dest: rely_stableD[OF st] predicate2D[OF sr])[1]
done
qed
lemma prefix_refinement_repeat_n:
"prefix_refinement sr iosr iosr (\<lambda>_ _. True) P Q AR R f g
\<Longrightarrow> \<lbrace>P\<rbrace>,\<lbrace>AR\<rbrace> f \<lbrace>\<top>\<top>\<rbrace>,\<lbrace>\<lambda>_. P\<rbrace>
\<Longrightarrow> \<lbrace>\<lambda>t0 t. Q t0 t \<and> (\<exists>s0 s. sr s0 t0 \<and> iosr s t)\<rbrace>,\<lbrace>R\<rbrace> g \<lbrace>\<top>\<top>\<rbrace>,\<lbrace>\<lambda>_. Q\<rbrace>
\<Longrightarrow> prefix_refinement sr iosr iosr (\<lambda>_ _. True) P Q AR R (repeat_n n f) (repeat_n n g)"
apply (induct n)
apply (simp add: prefix_refinement_return_imp)
apply (rule prefix_refinement_weaken_pre)
apply simp
apply (rule prefix_refinement_bind, assumption+)
apply simp
apply auto
done
lemma prefix_refinement_env_n_steps:
assumes env_stable: "env_stable AR R sr iosr Q"
shows "prefix_refinement sr iosr iosr (\<lambda>_ _. True)
(=) (\<lambda>t0 t. t0 = t \<and> Q t0) AR R (env_n_steps n) (env_n_steps n)"
apply (rule prefix_refinement_repeat_n)
apply (rule prefix_refinement_env_step[OF env_stable])
apply (simp add: env_step_def)
apply (wp put_trace_elem_twp)
apply (clarsimp simp: guar_cond_def)
apply (simp add: env_step_def)
apply (wp put_trace_elem_twp)+
apply simp
apply (clarsimp simp: guar_cond_def length_Suc_conv)
apply (cut_tac env_stable[unfolded env_stable_def])
apply (clarsimp simp: rely_cond_def)
apply (drule(3) rely_stableD)
apply simp
done
lemma prefix_refinement_repeat:
"prefix_refinement sr iosr iosr (\<lambda>_ _. True) P Q AR R f g
\<Longrightarrow> \<lbrace>P\<rbrace>,\<lbrace>AR\<rbrace> f \<lbrace>\<top>\<top>\<rbrace>,\<lbrace>\<lambda>_. P\<rbrace>
\<Longrightarrow> \<lbrace>\<lambda>t0 t. Q t0 t \<and> (\<exists>s0 s. sr s0 t0 \<and> iosr s t)\<rbrace>,\<lbrace>R\<rbrace> g \<lbrace>\<top>\<top>\<rbrace>,\<lbrace>\<lambda>_. Q\<rbrace>
\<Longrightarrow> prefix_refinement sr iosr iosr (\<lambda>_ _. True) P Q AR R (repeat f) (repeat g)"
apply (simp add: repeat_def)
apply (rule prefix_refinement_weaken_pre)
apply (rule prefix_refinement_bind, rule prefix_refinement_select[where rvr="(=)"])
apply simp
apply simp
apply (rule prefix_refinement_repeat_n, assumption+)
apply (rule validI_weaken_pre, assumption, simp)
apply (wp select_wp)
apply wp
apply clarsimp
apply clarsimp
done
lemma prefix_refinement_env_steps:
"env_stable AR R sr iosr Q
\<Longrightarrow> prefix_refinement sr iosr iosr (\<lambda>_ _. True)
(=) (\<lambda>t0 t. t0 = t \<and> Q t0) AR R env_steps env_steps"
apply (simp add: env_steps_repeat)
apply (rule prefix_refinement_repeat)
apply (erule prefix_refinement_env_step)
apply (simp add: env_step_def)
apply (wp put_trace_elem_twp)
apply (clarsimp simp: guar_cond_def)
apply (simp add: env_step_def)
apply (wp put_trace_elem_twp)
apply simp
apply (clarsimp simp: guar_cond_def length_Suc_conv)
apply (clarsimp simp: rely_cond_def env_stable_def)
apply (blast dest: rely_stableD)
done
lemma prefix_refinement_commit_step:
"\<forall>s t. isr s t \<longrightarrow> sr s t \<and> osr s t
\<Longrightarrow> prefix_refinement sr isr osr (\<lambda>_ _. True) (\<top>\<top>) (\<top>\<top>) AR R commit_step commit_step"
apply (clarsimp simp: prefix_refinement_def)
apply (rule default_prefix_refinement_ex)
apply (simp add: commit_step_def bind_def get_def return_def put_trace_elem_def)
apply (erule disjE)
apply (simp add: is_matching_fragment_no_trace)
apply (clarsimp simp: is_matching_fragment_def)
apply (simp add: prefix_closed_def self_closed_def env_closed_def)
apply (simp add: matching_tr_pfx_def matching_tr_def rely_cond_def)
done
lemma prefix_refinement_weaken_srs:
"prefix_refinement sr isr osr r P Q AR R f g
\<Longrightarrow> isr' \<le> isr \<Longrightarrow> osr \<le> osr' \<Longrightarrow> sr \<le> sr
\<Longrightarrow> prefix_refinement sr isr' osr' r P Q AR R f g"
apply (subst prefix_refinement_def, clarsimp)
apply (drule(1) predicate2D)
apply (drule(5) prefix_refinementD)
apply clarsimp
apply (rule exI, rule conjI[rotated], assumption)
apply (clarsimp simp: is_matching_fragment_def)
apply (drule(1) bspec, clarsimp)
apply (erule tmres.rel_cases; clarsimp)
apply (erule(1) predicate2D)
done
lemma prefix_refinement_interference:
"env_stable AR R sr iosr Q
\<Longrightarrow> prefix_refinement sr iosr iosr (\<lambda>_ _. True) \<top>\<top> (\<lambda>t0 t. Q t) AR R interference interference"
apply (simp add: interference_def)
apply (rule prefix_refinement_weaken_pre)
apply (rule prefix_refinement_bind[where intsr=iosr])
apply (rule prefix_refinement_commit_step)
apply (simp add: env_stable_def le_fun_def)
apply (erule prefix_refinement_env_steps)
apply (simp add: commit_step_def del: put_trace.simps)
apply wp
apply (simp add: commit_step_def del: put_trace.simps)
apply wp
apply (simp add: guar_cond_def)
apply (clarsimp simp: guar_cond_def)
done
lemma mapM_x_Cons:
"mapM_x f (x # xs) = do f x; mapM_x f xs od"
by (simp add: mapM_x_def sequence_x_def)
lemmas prefix_refinement_bind_sr = prefix_refinement_bind[where sr=sr
and intsr=sr for sr]
lemmas prefix_refinement_bind_isr = prefix_refinement_bind[where isr=isr
and intsr=isr for isr]
lemmas pfx_refn_bind = prefix_refinement_bind_v[where sr=sr
and isr=sr and osr=sr and intsr=sr for sr]
lemmas pfx_refn_bindT
= pfx_refn_bind[where P'="\<top>" and Q'="\<lambda>_ _. True", OF _ _ hoare_post_taut validI_triv,
simplified bipred_conj_def, simplified]
lemma prefix_refinement_assume_pre:
"(P \<Longrightarrow> prefix_refinement sr isr osr rvr P' Q' AR R f g)
\<Longrightarrow> prefix_refinement sr isr osr rvr (P' And (\<lambda>_ _. P)) Q' AR R f g"
"(P \<Longrightarrow> prefix_refinement sr isr osr rvr P' Q' AR R f g)
\<Longrightarrow> prefix_refinement sr isr osr rvr P' (Q' And (\<lambda>_ _. P)) AR R f g"
by (auto simp: prefix_refinement_def)
lemma prefix_refinement_modify:
"\<forall>s t. isr s t \<longrightarrow> P s \<longrightarrow> Q t \<longrightarrow> osr (f s) (g t)
\<Longrightarrow> prefix_refinement sr isr osr (\<lambda>_ _. True) (\<lambda>_. P) (\<lambda>_. Q) AR R (modify f) (modify g)"
apply (simp add: modify_def)
apply (rule prefix_refinement_weaken_pre)
apply (rule prefix_refinement_bind[where intsr=isr, OF prefix_refinement_get])
apply (rule_tac P="P x" in prefix_refinement_assume_pre(1))
apply (rule_tac P="Q y" in prefix_refinement_assume_pre(2))
apply (rule prefix_refinement_put, simp)
apply wp+
apply clarsimp
apply clarsimp
done
lemmas pfx_refn_modifyT = prefix_refinement_modify[where P="\<top>" and Q="\<top>"]
lemmas prefix_refinement_get_pre
= prefix_refinement_bind[OF prefix_refinement_get _
valid_validI_wp[OF _ get_sp] valid_validI_wp[OF _ get_sp],
simplified bipred_conj_def no_trace_all, simplified]
lemma prefix_refinement_gets:
"\<forall>s t. iosr s t \<and> P s \<and> Q t \<longrightarrow> rvr (f s) (f' t)
\<Longrightarrow> prefix_refinement sr iosr iosr rvr (\<lambda>_. P) (\<lambda>_. Q) AR R (gets f) (gets f')"
apply (simp add: gets_def)
apply (rule prefix_refinement_get_pre)
apply (rule prefix_refinement_return_imp)
apply simp
done
lemma prefix_refinement_fail:
"prefix_refinement sr isr osr rvr \<top>\<top> \<top>\<top> AR R fail fail"
apply (clarsimp simp: prefix_refinement_def fail_def)
apply (rule default_prefix_refinement_ex)
apply (simp add: is_matching_fragment_no_trace)
done
lemma prefix_refinement_assert:
"P = P' \<Longrightarrow> prefix_refinement sr iosr iosr \<top>\<top> \<top>\<top> \<top>\<top> AR R (assert P) (assert P')"
by (simp add: assert_def prefix_refinement_fail prefix_refinement_return_imp)
lemma par_tr_fin_bind:
"(\<forall>x. par_tr_fin_principle (g x)) \<Longrightarrow> par_tr_fin_principle (f >>= g)"
apply (clarsimp simp: par_tr_fin_principle_def bind_def)
apply (clarsimp split: tmres.split_asm)
apply (fastforce simp: last_st_tr_def hd_append)
done
lemma par_tr_fin_add_env_n_steps:
"par_tr_fin_principle f
\<Longrightarrow> par_tr_fin_principle (do x \<leftarrow> f; env_n_steps n od)"
proof (induct n)
case 0
then show ?case by simp
next
case (Suc n)
define f' where "f' \<equiv> (do x \<leftarrow> f; env_n_steps n od)"
from Suc have f': "par_tr_fin_principle f'"
by (simp add: f'_def)
hence "par_tr_fin_principle (do x \<leftarrow> f'; env_n_steps 1 od)"
by (clarsimp simp: par_tr_fin_principle_def env_step_def
bind_def select_def get_def put_def length_Suc_conv
return_def put_trace_elem_def
split: tmres.split_asm)
then show ?case
by (simp add: repeat_n_plus[where m="Suc 0", simplified, symmetric]
f'_def bind_assoc)
qed
lemma par_tr_fin_commit_step:
"par_tr_fin_principle commit_step"
by (simp add: par_tr_fin_principle_def commit_step_def
bind_def get_def return_def put_trace_elem_def
split: tmres.split)
lemma par_tr_fin_interference:
"par_tr_fin_principle interference"
apply (simp add: interference_def env_steps_repeat repeat_def select_early)
apply (rule par_tr_fin_bind[rule_format])
apply (rule par_tr_fin_add_env_n_steps)
apply (rule par_tr_fin_commit_step)
done
lemma prefix_refinement_triv_refinement_abs:
"triv_refinement f f'
\<Longrightarrow> prefix_refinement sr isr osr rvr P Q AR R f' g
\<Longrightarrow> prefix_refinement sr isr osr rvr P Q AR R f g"
apply (clarsimp simp: prefix_refinement_def)
apply (strengthen triv_refinement_trans[mk_strg I E])
apply fastforce
done
lemma prefix_refinement_triv_refinement_conc:
"prefix_refinement sr isr osr rvr P Q AR R f g'
\<Longrightarrow> triv_refinement g' g
\<Longrightarrow> prefix_refinement sr isr osr rvr P Q AR R f g"
apply (clarsimp simp: prefix_refinement_def triv_refinement_def)
apply blast
done
lemmas prefix_refinement_triv_pre
= Pure.asm_rl[where psi="prefix_refinement sr isr osr rvr
(\<lambda>_ _. True) (\<lambda>_ _. True) AR R f g"] for sr isr osr rvr AR R f g
lemma prefix_refinement_mapM:
"list_all2 xyr xs ys
\<Longrightarrow> (\<forall>x y. x \<in> set xs \<longrightarrow> y \<in> set ys \<longrightarrow> xyr x y
\<longrightarrow> prefix_refinement sr intsr intsr rvr P Q AR R (f x) (g y))
\<Longrightarrow> (\<forall>x. x \<in> set xs \<longrightarrow> \<lbrace>P\<rbrace>,\<lbrace>AR\<rbrace> f x \<lbrace>\<lambda>_ _. True\<rbrace>,\<lbrace>\<lambda>_. P\<rbrace>)
\<Longrightarrow> (\<forall>y. y \<in> set ys \<longrightarrow> \<lbrace>Q\<rbrace>,\<lbrace>R\<rbrace> g y \<lbrace>\<lambda>_ _. True\<rbrace>,\<lbrace>\<lambda>_. Q\<rbrace>)
\<Longrightarrow> prefix_refinement sr intsr intsr (list_all2 rvr) P Q AR R (mapM f xs) (mapM g ys)"
apply (induct xs ys rule: list_all2_induct)
apply (simp add: mapM_def sequence_def prefix_refinement_return_imp)
apply (clarsimp simp add: mapM_Cons all_conj_distrib imp_conjR)
apply (rule prefix_refinement_weaken_pre)
apply (rule prefix_refinement_bind, assumption)
apply (rule prefix_refinement_bind, assumption)
apply (rule prefix_refinement_triv_pre, rule prefix_refinement_return_imp, simp)
apply (wp validI_triv)+
apply (blast intro: validI_prefix_closed)
apply (wp validI_triv | simp add: bipred_conj_def
| blast dest: validI_prefix_closed)+
done
lemma prefix_refinement_weaken_rel:
"prefix_refinement sr isr osr r P Q AR R f g
\<Longrightarrow> \<forall>rv rv'. r rv rv' \<longrightarrow> r' rv rv'
\<Longrightarrow> prefix_refinement sr isr osr r' P Q AR R f g"
apply (subst prefix_refinement_def, clarsimp)
apply (drule(5) prefix_refinementD, clarsimp)
apply (rule exI, rule conjI[rotated], assumption)
apply (clarsimp simp: is_matching_fragment_def)
apply (drule(1) bspec, clarsimp)
apply (erule tmres.rel_cases; clarsimp)
done
lemma rely_cond_mono:
"R \<le> R' \<Longrightarrow> rely_cond R \<le> rely_cond R'"
by (simp add: le_fun_def rely_cond_def split_def)
lemma is_matching_fragment_add_rely:
"is_matching_fragment sr osr r ctr cres s0 AR s f
\<Longrightarrow> AR' \<le> AR
\<Longrightarrow> is_matching_fragment sr osr r ctr cres s0 AR' s (rely f AR' s0)"
apply (frule is_matching_fragment_Nil)
apply (clarsimp simp: is_matching_fragment_def rely_prefix_closed
rely_self_closed)
apply (intro conjI)
apply (erule rely_env_closed)
apply (frule rely_cond_mono)
apply (simp add: le_fun_def rely_cond_Cons_eq)
apply (fastforce simp: rely_def)
apply (auto simp: rely_def)[1]
done
lemma prefix_refinement_weaken_rely:
"prefix_refinement sr isr osr r P Q AR R f g
\<Longrightarrow> R' \<le> R \<Longrightarrow> AR' \<le> AR
\<Longrightarrow> prefix_refinement sr isr osr r P Q AR' R' f g"
apply (subst prefix_refinement_def, clarsimp)
apply (drule(3) prefix_refinementD, assumption+)
apply (clarsimp simp: rely_cond_def split_def le_fun_def)
apply (rule exI, rule conjI, erule is_matching_fragment_add_rely)
apply (simp add: le_fun_def)
apply (auto simp add: triv_refinement_def rely_def)
done
text \<open>Using prefix refinement as an in-place calculus, permitting
multiple applications at the same level.\<close>
lemmas trivial = imp_refl[rule_format]
lemma matching_tr_transp:
"transp sr \<Longrightarrow> transp (matching_tr sr)"
apply (simp add: matching_tr_def)
apply (rule list.rel_transp)
apply (rule transpI; clarsimp)
apply (metis transp_def)
done
lemma matching_tr_symp:
"symp sr \<Longrightarrow> symp (matching_tr sr)"
apply (simp add: matching_tr_def rel_prod_conv[symmetric])
apply (intro list.rel_symp prod.rel_symp; simp?)
apply (simp add: sympI)
done
lemma list_all2_is_me:
"list_all2 P tr tr'
\<Longrightarrow> \<forall>x y. P x y \<longrightarrow> fst x = fst y
\<Longrightarrow> (n < length tr \<and> fst (rev tr ! n) = Me)
= (n < length tr' \<and> fst (rev tr' ! n) = Me)"
apply (rule conj_cong, simp add: list_all2_lengthD)
apply (frule list_all2_rev_nthD, simp add: list_all2_lengthD)
apply (cases "rev tr ! n", cases "rev tr' ! n", auto)
done
lemma is_matching_fragment_trans:
assumes assms:
"is_matching_fragment sr osr (=) h_tr h_res t0 R' t frag_g"
"(g_tr, g_res) \<in> frag_g t" "length g_tr = length h_tr"
"is_matching_fragment sr osr (=) g_tr g_res s0 R s frag_f"
assumes sr: "equivp sr" "equivp osr"
shows "is_matching_fragment sr osr (=) h_tr h_res s0 R s frag_f"
proof -
have matching_tr1:
"matching_tr sr (rev g_tr) (rev h_tr)"
using assms
by (auto simp: is_matching_fragment_def matching_tr_pfx_def)
hence matching_tr:
"\<And>n. matching_tr sr (take n (rev g_tr)) (take n (rev h_tr))"
by (simp add: matching_tr_def)
have matching:
"\<And>xs. matching_tr_pfx sr xs g_tr = matching_tr_pfx sr xs h_tr"
apply (rule equivpE, rule sr)
apply (simp add: matching_tr_pfx_def assms)
apply (rule conj_cong; simp?)
apply (strengthen iffI)
apply (metis matching_tr transpD[OF matching_tr_transp]
sympD[OF matching_tr_symp])
done
note is_me = matching_tr1[unfolded matching_tr_def, simplified,
THEN list_all2_is_me, symmetric]
show ?thesis using assms
apply (clarsimp simp: is_matching_fragment_def matching is_me)
apply (drule(1) bspec)+
apply clarsimp
apply (erule tmres.rel_cases | clarsimp)+
apply (rule equivpE, rule sr(2))
apply (metis transpD)
done
qed
lemma matching_tr_rely_cond:
"matching_tr sr (rev tr) (rev tr')
\<Longrightarrow> rely_cond R s0 tr
\<Longrightarrow> sr s0 t0
\<Longrightarrow> rely_cond (\<lambda>t0 t. \<exists>s0 s. sr s0 t0 \<and> sr s t \<and> R s0 s) t0 tr'"
apply (simp add: matching_tr_def)
apply (induct arbitrary: s0 t0 rule: list_all2_induct)
apply simp
apply (clarsimp simp: rely_cond_def trace_steps_append last_st_tr_def hd_append)
apply (intro conjI impI; clarsimp)
apply blast
apply (clarsimp simp: neq_Nil_conv list_all2_Cons2)
apply blast
done
lemma prefix_refinement_in_place_trans:
"prefix_refinement sr isr osr (=) P (\<lambda>_ _. True) AR (\<lambda>t0 t. \<exists>s0 s. sr s0 t0 \<and> sr s t \<and> R s0 s) f g
\<Longrightarrow> prefix_refinement sr isr osr (=) (\<lambda>_ _. True) Q AR R g h
\<Longrightarrow> equivp sr \<Longrightarrow> equivp osr \<Longrightarrow> equivp isr
\<Longrightarrow> (\<forall>s t t'. sr s t \<longrightarrow> R t t' \<longrightarrow> (\<exists>s'. sr s' t' \<and> AR s s'))
\<Longrightarrow> prefix_refinement sr isr osr (=) P Q AR R f h"
apply (subst prefix_refinement_def, clarsimp)
apply (drule_tac s=t and t=t and ?t0.0=t0 and cprog=h in pfx_refnD;
assumption?)
apply (metis equivp_reflp_symp_transp reflpD)
apply metis
apply clarsimp
apply (rename_tac h_tr h_res frag_g)
apply (rule_tac x="\<lambda>s. \<Union>(tr, res) \<in> frag_g t \<inter> ({tr. length tr = length h_tr} \<times> UNIV).
\<Union>frag_f \<in> {frag_f. is_matching_fragment sr osr (=) tr res s0 AR s frag_f
\<and> triv_refinement f frag_f}. frag_f s" in exI)
apply (rule conjI)
apply (rule is_matching_fragment_UNION)
apply clarsimp
apply (rename_tac g_tr g_res)
apply (rule is_matching_fragment_UNION)
apply clarsimp
apply (erule(1) is_matching_fragment_trans; simp)
apply (clarsimp simp: is_matching_fragment_def)
apply clarsimp
apply (drule(1) triv_refinement_elemD)
apply (frule(1) is_matching_fragment_trD)
apply (clarsimp simp: matching_tr_pfx_def)
apply (drule matching_tr_symp[THEN sympD, rotated], metis equivp_reflp_symp_transp)
apply (drule(1) matching_tr_rely_cond)
apply (erule equivp_reflp)
apply (fastforce elim: pfx_refnD2)
apply clarsimp
apply (rule prefix_closed_UNION)
apply (clarsimp simp: is_matching_fragment_def)
apply (drule(2) matching_fragment_matching_tr, simp)
apply (clarsimp simp: matching_tr_def dest!: list_all2_lengthD)
apply blast
apply (clarsimp simp: triv_refinement_def)
apply blast
done
lemma prefix_refinement_Await:
"env_stable AR R sr iosr Q
\<Longrightarrow> abs_rely_stable AR P
\<Longrightarrow> \<forall>s t. P s \<longrightarrow> Q t \<longrightarrow> iosr s t \<longrightarrow> G' t \<longrightarrow> G s
\<Longrightarrow> (\<exists>s. G' s) \<longrightarrow> (\<exists>s. G s)
\<Longrightarrow> prefix_refinement sr iosr iosr (\<lambda>_ _. True) (\<lambda>s0 s. s0 = s \<and> P s)
(\<lambda>t0 t. t0 = t \<and> Q t) AR R
(Await G) (Await G')"
apply (simp add: Await_redef)
apply (rule prefix_refinement_weaken_pre)
apply (rule prefix_refinement_bind[where intsr=iosr]
prefix_refinement_select[where rvr="\<lambda>s s'. G s = G' s'"]
prefix_refinement_env_steps
| simp add: if_split[where P="\<lambda>S. x \<in> S" for x] split del: if_split
| (rule prefix_refinement_get, rename_tac s s',
rule_tac P="P s" in prefix_refinement_assume_pre(1),
rule_tac P="Q s'" in prefix_refinement_assume_pre(2))
| (rule prefix_refinement_select[where rvr=dc2])
| wp)+
apply clarsimp
apply (erule(2) abs_rely_stable_rtranclp)
apply (clarsimp simp: env_stable_def)
apply (erule(3) rely_stable_rtranclp)
done
end
|
#include <boost/asio/windows/basic_handle.hpp>
|
\def \sourcepath {model.als}
\section{Formal analysis using Alloy}
\label{sec:alloy}
\lstinputlisting[language=alloy]{\sourcepath}
\begin{figure}[h!]
\centering
\hspace*{-0cm}
\includegraphics[width=\textwidth]{img/alloy/alloy_acquire.png}
\caption{Acquisition of a new data entry that may trigger a SOS call}
\label{fig:alloy_acquire}
\end{figure}
\begin{figure}[h!]
\centering
\hspace*{-1.5cm}
\includegraphics[width=1.15\textwidth]{img/alloy/alloy_srequest.png}
\caption{Single user requests that may be accepted or refused by users}
\label{fig:alloy_srequest}
\end{figure}
\begin{figure}[h!]
\centering
\hspace*{-0cm}
\includegraphics[width=\textwidth]{img/alloy/alloy_arequest.png}
\caption{Anonymous group requests that may be accepted or refused by the system}
\label{fig:alloy_arequest}
\end{figure}
\begin{figure}[h!]
\centering
\hspace*{-0cm}
\includegraphics[width=\textwidth]{img/alloy/alloy_check.png}
\caption{Model validation}
\label{fig:alloy_check}
\end{figure}
|
#ifndef STAN_MATH_PRIM_SCAL_PROB_STUDENT_T_RNG_HPP
#define STAN_MATH_PRIM_SCAL_PROB_STUDENT_T_RNG_HPP
#include <boost/random/student_t_distribution.hpp>
#include <boost/random/variate_generator.hpp>
#include <stan/math/prim/scal/err/check_consistent_sizes.hpp>
#include <stan/math/prim/scal/err/check_finite.hpp>
#include <stan/math/prim/scal/err/check_not_nan.hpp>
#include <stan/math/prim/scal/err/check_positive_finite.hpp>
#include <stan/math/prim/scal/fun/constants.hpp>
#include <stan/math/prim/scal/fun/square.hpp>
#include <stan/math/prim/scal/fun/value_of.hpp>
#include <stan/math/prim/scal/fun/lbeta.hpp>
#include <stan/math/prim/scal/fun/lgamma.hpp>
#include <stan/math/prim/scal/fun/digamma.hpp>
#include <stan/math/prim/scal/meta/length.hpp>
#include <stan/math/prim/scal/fun/grad_reg_inc_beta.hpp>
#include <stan/math/prim/scal/fun/inc_beta.hpp>
#include <stan/math/prim/scal/meta/include_summand.hpp>
#include <stan/math/prim/scal/meta/VectorBuilder.hpp>
namespace stan {
namespace math {
template <class RNG>
inline double
student_t_rng(double nu,
double mu,
double sigma,
RNG& rng) {
using boost::variate_generator;
using boost::random::student_t_distribution;
static const char* function("student_t_rng");
check_positive_finite(function, "Degrees of freedom parameter", nu);
check_finite(function, "Location parameter", mu);
check_positive_finite(function, "Scale parameter", sigma);
variate_generator<RNG&, student_t_distribution<> >
rng_unit_student_t(rng, student_t_distribution<>(nu));
return mu + sigma * rng_unit_student_t();
}
}
}
#endif
|
module Compiler.Erlang.Utils.String
import Utils.Hex
%default total
export
showSep : String -> List String -> String
showSep sep [] = ""
showSep sep [x] = x
showSep sep (x :: xs) = x ++ sep ++ showSep sep xs
-- TODO: Does not handle multi-codepoint characters
export
escapeChar : Char -> String -> String
escapeChar c acc =
let codepoint = cast c
space = 32
tilde = 126
backslash = 92
doubleQuote = 34
apostrophe = 39
in if codepoint < space || codepoint > tilde ||
codepoint == backslash || codepoint == doubleQuote || codepoint == apostrophe
then "\\x{" ++ asHex (cast c) ++ "}" ++ acc
else strCons c acc
export
escapeString : List Char -> String -> String
escapeString [] = id
escapeString (c :: cs) = escapeChar c . escapeString cs
||| Convert a Double to a String. Includes a decimal separator for all Double numbers.
|||
||| > showDouble 42
||| "42.0"
-- TODO: It may be possible to remove this if all codegens agree on making
-- `show {a=Double}` include a decimal separator.
export
showDouble : Double -> String
showDouble x =
let dblStr = show x
in if '.' `elem` unpack dblStr
then dblStr
else dblStr ++ ".0"
|
(* *********************************************************************)
(* *)
(* 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. *)
(* *)
(* *********************************************************************)
(* *********************************************************************)
(* *)
(* Layers of VMM *)
(* *)
(* Refinement Proof for PProc *)
(* *)
(* Ronghui Gu <[email protected]> *)
(* *)
(* Yale Flint Group *)
(* *)
(* *********************************************************************)
Require Import Coqlib.
Require Import Errors.
Require Import AST.
Require Import Integers.
Require Import Floats.
Require Import Op.
Require Import Asm.
Require Import Events.
Require Import Globalenvs.
Require Import Smallstep.
Require Import Values.
Require Import Memory.
Require Import Maps.
Require Import CommonTactic.
Require Import AuxLemma.
Require Import FlatMemory.
Require Import AuxStateDataType.
Require Import Constant.
Require Import GlobIdent.
Require Import RealParams.
Require Import LoadStoreSem2.
Require Import AsmImplLemma.
Require Import GenSem.
Require Import RefinementTactic.
Require Import PrimSemantics.
Require Import XOmega.
Require Import liblayers.logic.PTreeModules.
Require Import liblayers.logic.LayerLogicImpl.
Require Import liblayers.compcertx.Stencil.
Require Import liblayers.compcertx.MakeProgram.
Require Import liblayers.compat.CompatLayers.
Require Import liblayers.compat.CompatGenSem.
Require Import compcert.cfrontend.Ctypes.
Require Import LAsmModuleSemAux.
Require Import LayerCalculusLemma.
Require Import AbstractDataType.
Require Import PUCtxtIntro.
Require Import PProc.
Require Import ProcGenSpec.
(** * Definition of the refinement relation*)
Section Refinement.
Local Open Scope string_scope.
Local Open Scope error_monad_scope.
Local Open Scope Z_scope.
Context `{real_params: RealParams}.
Notation HDATA := RData.
Notation LDATA := RData.
Notation HDATAOps := (cdata (cdata_ops := pproc_data_ops) HDATA).
Notation LDATAOps := (cdata (cdata_ops := pipc_data_ops) LDATA).
Section WITHMEM.
Context `{Hstencil: Stencil}.
Context `{Hmem: Mem.MemoryModel}.
Context `{Hmwd: UseMemWithData mem}.
(** Relation between raw data at two layers*)
Record relate_RData (f: meminj) (hadt: HDATA) (ladt: LDATA) :=
mkrelate_RData {
flatmem_re: FlatMem.flatmem_inj (HP hadt) (HP ladt);
vmxinfo_re: vmxinfo hadt = vmxinfo ladt;
devout_re: devout hadt = devout ladt;
CR3_re: CR3 hadt = CR3 ladt;
ikern_re: ikern hadt = ikern ladt;
pg_re: pg hadt = pg ladt;
ihost_re: ihost hadt = ihost ladt;
AC_re: AC hadt = AC ladt;
ti_fst_re: (fst (ti hadt)) = (fst (ti ladt));
ti_snd_re: val_inject f (snd (ti hadt)) (snd (ti ladt));
LAT_re: LAT hadt = LAT ladt;
nps_re: nps hadt = nps ladt;
init_re: init hadt = init ladt;
pperm_re: pperm hadt = pperm ladt;
PT_re: PT hadt = PT ladt;
ptp_re: ptpool hadt = ptpool ladt;
idpde_re: idpde hadt = idpde ladt;
ipt_re: ipt hadt = ipt ladt;
smspool_re: smspool hadt = smspool ladt;
kctxt_re: kctxt_inj f num_proc (kctxt hadt) (kctxt ladt);
abtcb_re: abtcb hadt = abtcb ladt;
abq_re: abq hadt = abq ladt;
cid_re: cid hadt = cid ladt;
chpool_re: syncchpool hadt = syncchpool ladt;
uctxt_re: uctxt_inj f (uctxt hadt) (uctxt ladt)
}.
Inductive match_RData: stencil -> HDATA -> mem -> meminj -> Prop :=
| MATCH_RDATA: forall habd m f s, match_RData s habd m f.
Local Hint Resolve MATCH_RDATA.
Global Instance rel_ops: CompatRelOps HDATAOps LDATAOps :=
{
relate_AbData s f d1 d2 := relate_RData f d1 d2;
match_AbData s d1 m f := match_RData s d1 m f;
new_glbl := nil
}.
(** ** Properties of relations*)
Section Rel_Property.
(** Prove that after taking one step, the refinement relation still holds*)
Lemma relate_incr:
forall abd abd' f f',
relate_RData f abd abd'
-> inject_incr f f'
-> relate_RData f' abd abd'.
Proof.
inversion 1; subst; intros; inv H; constructor; eauto.
- eapply kctxt_inj_incr; eauto.
- eapply uctxt_inj_incr; eauto.
Qed.
Lemma relate_kernel_mode:
forall abd abd' f,
relate_RData f abd abd'
-> (kernel_mode abd <-> kernel_mode abd').
Proof.
inversion 1; simpl; split; congruence.
Qed.
Lemma relate_observe:
forall p abd abd' f,
relate_RData f abd abd' ->
observe p abd = observe p abd'.
Proof.
inversion 1; simpl; unfold ObservationImpl.observe; congruence.
Qed.
Global Instance rel_prf: CompatRel HDATAOps LDATAOps.
Proof.
constructor; intros; simpl; trivial.
eapply relate_incr; eauto.
eapply relate_kernel_mode; eauto.
eapply relate_observe; eauto.
Qed.
End Rel_Property.
(** * Proofs the one-step forward simulations for the low level specifications*)
Section OneStep_Forward_Relation.
Section FRESH_PRIM.
Lemma proc_start_user_spec_ref:
compatsim (crel HDATA LDATA)
(primcall_start_user_compatsem proc_start_user_spec)
proc_start_user_spec_low.
Proof.
compatsim_simpl (@match_AbData).
intros.
inv match_extcall_states.
exploit proc_start_user_exist; eauto 1.
eapply valid_curid; eauto.
intros (d2' & rs2' & HM & HR & HReg & He & Hrange').
subst.
refine_split; try econstructor; eauto.
eapply reg_symbol_inject; eassumption.
econstructor; eauto.
constructor.
val_inject_simpl; try (eapply HReg; omega).
Qed.
Lemma proc_exit_user_spec_ref:
compatsim (crel HDATA LDATA)
(primcall_exit_user_compatsem proc_exit_user_spec)
proc_exit_user_spec_low.
Proof.
compatsim_simpl (@match_AbData).
intros.
inv H4. inv match_extcall_states.
exploit proc_exit_user_exist; eauto 1.
- subst uctx4 uctx3 uctx2 uctx1.
intros. inv_proc. rewrite ZMap.gi. constructor.
- intros [d2'[HM HR]].
refine_split; try econstructor; eauto.
eapply reg_symbol_inject; eassumption.
+ exploit (extcall_args_inject (D1:= HDATAOps) (D2:= LDATAOps)); eauto.
instantiate (3:= d1').
apply extcall_args_with_data; eauto.
instantiate (1:= d2).
intros [?[? Hinv]]. inv_val_inject.
apply extcall_args_without_data in H; eauto.
+ specialize (match_reg ESP); unfold Pregmap.get in match_reg.
inv match_reg; congruence.
+ intros.
specialize (match_reg ESP); unfold Pregmap.get in match_reg.
inv match_reg; try congruence.
specialize (HESP_STACK _ _ (eq_sym H1)).
replace b1 with b2 by congruence.
split.
* apply Ple_trans with b0;
[ apply HESP_STACK | apply (match_inject_forward _ _ _ H3) ].
* apply (Mem.valid_block_inject_2 _ _ _ _ _ _ H3 match_inject).
+ econstructor; eauto. constructor.
+ val_inject_simpl.
Qed.
Lemma proc_create_kernel_mode:
forall d2 d2' b b' b2 ofs_uc q,
proc_create_spec d2 b b' b2 ofs_uc q = Some d2'
-> kernel_mode d2.
Proof.
unfold proc_create_spec; intros.
simpl; subdestruct. auto.
Qed.
Lemma proc_create_spec_ref:
compatsim (crel HDATA LDATA) (proc_create_compatsem proc_create_spec) proc_create_spec_low.
Proof.
compatsim_simpl (@match_AbData).
exploit proc_create_exist; eauto 1.
intros (labd' & HP & HM).
destruct H9 as [fun_id Hsymbol].
exploit (stencil_find_symbol_inject' s ι fun_id buc); eauto.
intros HFB.
destruct H10 as [elf_id Hsymbol'].
exploit (stencil_find_symbol_inject' s ι elf_id be); eauto.
intros HFB'.
refine_split; try econstructor; eauto.
- eapply proc_create_kernel_mode; eauto.
- constructor.
Qed.
End FRESH_PRIM.
Section PASSTHROUGH_PRIM.
Global Instance: (LoadStoreProp (hflatmem_store:= flatmem_store) (lflatmem_store:= flatmem_store)).
Proof.
accessor_prop_tac.
- eapply flatmem_store_exists; eauto.
Qed.
Lemma passthrough_correct:
sim (crel HDATA LDATA) pproc_passthrough puctxtintro.
Proof.
sim_oplus.
- apply fload_sim.
- apply fstore_sim.
- apply vmxinfo_get_sim.
- apply device_output_sim.
(*- apply pfree_sim.*)
- apply ptRead_sim.
- apply ptResv_sim.
- apply shared_mem_status_sim.
- apply offer_shared_mem_sim.
- apply get_curid_sim.
- apply thread_wakeup_sim.
(*- apply is_chan_ready_sim.
- apply sendto_chan_sim.
- apply receive_chan_sim.*)
- apply syncreceive_chan_sim.
- apply syncsendto_chan_pre_sim.
- apply syncsendto_chan_post_sim.
- apply proc_init_sim.
- apply uctx_get_sim.
- apply uctx_set_sim.
- apply container_get_nchildren_sim.
- apply container_get_quota_sim.
- apply container_get_usage_sim.
- apply container_can_consume_sim.
- apply alloc_sim.
- apply hostin_sim.
- apply hostout_sim.
- apply trap_info_get_sim.
- apply trap_info_ret_sim.
- apply thread_yield_sim.
- apply thread_sleep_sim.
- layer_sim_simpl.
+ eapply load_correct2.
+ eapply store_correct2.
Qed.
End PASSTHROUGH_PRIM.
End OneStep_Forward_Relation.
End WITHMEM.
End Refinement.
|
/- First-class functions -/
def twice (f : Nat → Nat) (a : Nat) :=
f (f a)
#check twice
-- (Nat → Nat) → Nat → Nat
#eval twice (fun x => x + 2) 10
theorem twice_add_2 (a : Nat) : twice (fun x => x + 2) a = a + 4 := rfl
-- `(· + 2)` is syntax sugar for `(fun x => x + 2)`.
#eval twice (· + 2) 10
|
section \<open>FLPTheorem\<close>
text \<open>
\file{FLPTheorem} combines the results of \file{FLPSystem} with the concept
of fair infinite executions and culminates in showing the impossibility
of a consensus algorithm in the proposed setting.
\<close>
theory FLPTheorem
imports Execution FLPSystem
begin
locale flpPseudoConsensus =
flpSystem trans sends start
for
trans :: "'p \<Rightarrow> 's \<Rightarrow> 'v messageValue \<Rightarrow>'s" and
sends :: "'p \<Rightarrow> 's \<Rightarrow> 'v messageValue \<Rightarrow> ('p, 'v) message multiset" and
start :: "'p \<Rightarrow> 's" +
assumes
Agreement: "\<And> i c . agreementInit i c" and
PseudoTermination: "\<And>cc Q . terminationPseudo 1 cc Q"
begin
subsection \<open>Obtaining non-uniform executions\<close>
text \<open>
Executions which end with a \isb{nonUniform} configuration can be expanded
to a strictly longer execution consuming a particular message.
This lemma connects the previous results to the world of executions,
thereby paving the way to the final contradiction. It covers a big part of
the original proof of the theorem, i.e.\ finding the expansion to a longer
execution where the decision for both values is still possible.
\voelzer{constructing executions using Lemma 2}
\<close>
lemma NonUniformExecutionsConstructable:
fixes
exec :: "('p, 'v, 's ) configuration list " and
trace :: "('p, 'v) message list" and
msg :: "('p, 'v) message" and
p :: 'p
assumes
MsgEnabled: "enabled (last exec) msg" and
PisReceiverOf: "isReceiverOf p msg" and
ExecIsExecution: "execution trans sends start exec trace" and
NonUniformLexec: "nonUniform (last exec)" and
Agree: "\<And> cfg . reachable (last exec) cfg \<longrightarrow> agreement cfg"
shows
"\<exists> exec' trace' . (execution trans sends start exec' trace')
\<and> nonUniform (last exec')
\<and> prefixList exec exec' \<and> prefixList trace trace'
\<and> (\<forall> cfg . reachable (last exec') cfg \<longrightarrow> agreement cfg)
\<and> stepReachable (last exec) msg (last exec')
\<and> (msg \<in> set (drop (length trace) trace'))"
proof -
from NonUniformCanReachSilentBivalence[OF NonUniformLexec PseudoTermination Agree]
obtain c' where C':
"reachable (last exec) c'"
"val[p,c'] = {True, False}"
by blast
show ?thesis
proof (cases "stepReachable (last exec) msg c'")
case True
hence IsStepReachable: "stepReachable (last exec) msg c'" by simp
hence "\<exists> exec' trace'. (execution trans sends start exec' trace')
\<and> prefixList exec exec'
\<and> prefixList trace trace' \<and> (last exec') = c'
\<and> msg \<in> set (drop (length trace) trace')"
using ExecIsExecution expandExecution
by auto
then obtain exec' trace' where NewExec:
"(execution trans sends start exec' trace')"
"prefixList exec exec'" "(last exec') = c'" "prefixList trace trace'"
"msg \<in> set (drop (length trace) trace')" by blast
hence lastExecExec'Reachable: "reachable (last exec) (last exec')"
using C'(1) by simp
hence InitReachLastExec': "initReachable (last exec')"
using NonUniformLexec
by (metis ReachableTrans initReachable_def)
hence nonUniformC': "nonUniform (last exec')" using C'(2) NewExec(3)
by (auto simp add: vUniform_def)
hence isAgreementPreventing:
"(\<forall> cfg . reachable (last exec') cfg \<longrightarrow> agreement cfg)"
using lastExecExec'Reachable Agree by (metis ReachableTrans)
with NewExec nonUniformC' IsStepReachable show ?thesis by auto
next
case False
hence NotStepReachable: "\<not> (stepReachable (last exec) msg c')" by simp
from C'(1) obtain exec' trace' where NewExec:
"execution trans sends start exec' trace'"
"(prefixList exec exec' \<and> prefixList trace trace')
\<or> (exec = exec' \<and> trace = trace')"
"last exec' = c'"
using ExecIsExecution expandExecutionReachable by blast
have lastExecExec'Reachable: "reachable (last exec) (last exec')"
using C'(1) NewExec(3) by simp
with NonUniformLexec have InitReachLastExec':
"initReachable (last exec')"
by (metis ReachableTrans initReachable_def)
with C'(2) NewExec(3) have nonUniformC': "nonUniform (last exec')"
by (auto simp add: vUniform_def)
show "\<exists> exec1 trace1 . (execution trans sends start exec1 trace1)
\<and> nonUniform (last exec1)
\<and> prefixList exec exec1 \<and> prefixList trace trace1
\<and> (\<forall> cfg . reachable (last exec1) cfg \<longrightarrow> agreement cfg)
\<and> stepReachable (last exec) msg (last exec1)
\<and> (msg \<in> set (drop (length trace) trace1))"
proof (cases "enabled (last exec') msg")
case True
hence EnabledMsg: "enabled (last exec') msg" by auto
hence "\<exists> cMsg . ((last exec') \<turnstile> msg \<mapsto> cMsg )"
proof (cases msg)
case (InMsg p' b)
with PisReceiverOf have MsgIsInMsg: "(msg = <p, inM b>)" by auto
define cfgInM where "cfgInM = \<lparr>states = \<lambda>proc. (
if proc = p then
trans p (states (last exec') p) (Bool b)
else states (last exec') proc),
msgs = (((sends p (states (last exec') p) (Bool b))
\<union># (msgs (last exec')-# msg)))\<rparr> "
with UniqueReceiverOf MsgIsInMsg EnabledMsg have
"((last exec') \<turnstile> msg \<mapsto> cfgInM)" by auto
thus "\<exists> cMsg . ((last exec') \<turnstile> msg \<mapsto> cMsg )" by blast
next
case (OutMsg b)
thus "\<exists> cMsg . ((last exec') \<turnstile> msg \<mapsto> cMsg )" using PisReceiverOf
by auto
next
case (Msg p' v')
with PisReceiverOf have MsgIsVMsg: "(msg = <p, v'>)" by auto
define cfgVMsg where "cfgVMsg =
\<lparr>states = \<lambda>proc. (
if proc = p then
trans p (states (last exec') p) (Value v')
else states (last exec') proc),
msgs = (((sends p (states (last exec') p) (Value v'))
\<union># (msgs (last exec') -# msg )))\<rparr> "
with UniqueReceiverOf MsgIsVMsg EnabledMsg noInSends have
"((last exec') \<turnstile> msg \<mapsto> cfgVMsg)" by auto
thus "\<exists> cMsg . ((last exec') \<turnstile> msg \<mapsto> cMsg )" by blast
qed
then obtain cMsg where CMsg:"((last exec') \<turnstile> msg \<mapsto> cMsg )" by auto
define execMsg where "execMsg = exec' @ [cMsg]"
define traceMsg where "traceMsg = trace' @ [msg]"
from NewExec(1) CMsg obtain execMsg traceMsg where isExecution:
"execution trans sends start execMsg traceMsg"
and ExecMsg: "prefixList exec' execMsg" "prefixList trace' traceMsg"
"last execMsg = cMsg" "last traceMsg = msg"
using expandExecutionStep by blast
have isPrefixListExec: "prefixList exec execMsg"
using PrefixListTransitive NewExec(2) ExecMsg(1) by auto
have isPrefixListTrace: "prefixList trace traceMsg"
using PrefixListTransitive NewExec(2) ExecMsg(2) by auto
have cMsgLastReachable: "reachable cMsg (last execMsg)"
by (auto simp add: ExecMsg reachable.init)
hence isStepReachable: "stepReachable (last exec) msg (last execMsg)"
using CMsg lastExecExec'Reachable
by (auto simp add: stepReachable_def)
have InitReachLastExecMsg: "initReachable (last execMsg)"
using CMsg InitReachLastExec' cMsgLastReachable
by (metis ReachableTrans initReachable_def step)
have "val[p, (last exec')] \<subseteq> val[p, cMsg]"
using CMsg PisReceiverOf InitReachLastExec'
ActiveProcessSilentDecisionValuesIncrease[of p p "last exec'" msg cMsg]
by auto
with ExecMsg C'(2) NewExec(3) have
"val[p, (last execMsg)] = {True, False}" by auto
with InitReachLastExecMsg have isNonUniform:
"nonUniform (last execMsg)" by (auto simp add: vUniform_def)
have "reachable (last exec) (last execMsg)"
using lastExecExec'Reachable cMsgLastReachable CMsg
by (metis ReachableTrans step)
hence isAgreementPreventing:
"(\<forall> cfg . reachable (last execMsg) cfg \<longrightarrow> agreement cfg)"
using Agree by (metis ReachableTrans)
have "msg \<in> set (drop (length trace) traceMsg)" using ExecMsg(4)
isPrefixListTrace
by (metis (full_types) PrefixListMonotonicity last_drop last_in_set
length_0_conv length_drop less_zeroE zero_less_diff)
thus ?thesis using isExecution isNonUniform isPrefixListExec
isPrefixListTrace isAgreementPreventing isStepReachable by blast
next
case False
hence notEnabled: "\<not> (enabled (last exec') msg)" by auto
have isStepReachable: "stepReachable (last exec) msg (last exec')"
using MsgEnabled notEnabled lastExecExec'Reachable StepReachable
by auto
with NotStepReachable NewExec(3) show ?thesis by simp
qed
qed
qed
lemma NonUniformExecutionBase:
fixes
cfg
assumes
Cfg: "initial cfg" "nonUniform cfg"
shows
"execution trans sends start [cfg] []
\<and> nonUniform (last [cfg])
\<and> (\<exists> cfgList' msgList'. nonUniform (last cfgList')
\<and> prefixList [cfg] cfgList'
\<and> prefixList [] msgList'
\<and> (execution trans sends start cfgList' msgList')
\<and> (\<exists> msg'. execution.minimalEnabled [cfg] [] msg'
\<and> msg' \<in> set msgList'))"
proof -
have NonUniListCfg: "nonUniform (last [cfg])" using Cfg(2) by auto
have AgreeCfg': "\<forall> cfg' .
reachable (last [cfg]) cfg' \<longrightarrow> agreement cfg'"
using Agreement Cfg(1)
by (auto simp add: agreementInit_def reachable.init agreement_def)
have StartExec: "execution trans sends start [cfg] []"
using Cfg(1) by (unfold_locales, auto)
hence "\<exists> msg . execution.minimalEnabled [cfg] [] msg"
using Cfg execution.ExistImpliesMinEnabled
by (metis enabled_def initial_def isReceiverOf.simps(1)
last.simps zero_less_one)
then obtain msg where MinEnabledMsg:
"execution.minimalEnabled [cfg] [] msg" by blast
hence "\<exists> pMin . isReceiverOf pMin msg" using StartExec
by (auto simp add: execution.minimalEnabled_def)
then obtain pMin where PMin: "isReceiverOf pMin msg" by blast
hence "enabled (last [cfg]) msg \<and> isReceiverOf pMin msg"
using MinEnabledMsg StartExec
by (auto simp add: execution.minimalEnabled_def)
hence Enabled: "enabled (last [cfg]) msg" "isReceiverOf pMin msg"
by auto
from Enabled StartExec NonUniListCfg PseudoTermination AgreeCfg'
have "\<exists> exec' trace' . (execution trans sends start exec' trace')
\<and> nonUniform (last exec')
\<and> prefixList [cfg] exec' \<and> prefixList [] trace'
\<and> (\<forall> cfg' . reachable (last exec') cfg' \<longrightarrow> agreement cfg')
\<and> stepReachable (last [cfg]) msg (last exec')
\<and> (msg \<in> set (drop (length []) trace'))"
using NonUniformExecutionsConstructable[of "[cfg]" "msg" "pMin"
"[]::('p,'v) message list"]
by simp
with StartExec NonUniListCfg MinEnabledMsg show ?thesis by auto
qed
lemma NonUniformExecutionStep:
fixes
cfgList msgList
assumes
Init: "initial (hd cfgList)" and
NonUni: "nonUniform (last cfgList)" and
Execution: "execution trans sends start cfgList msgList"
shows
"(\<exists> cfgList' msgList' .
nonUniform (last cfgList')
\<and> prefixList cfgList cfgList'
\<and> prefixList msgList msgList'
\<and> (execution trans sends start cfgList' msgList')
\<and> (initial (hd cfgList'))
\<and> (\<exists> msg'. execution.minimalEnabled cfgList msgList msg'
\<and> msg' \<in> (set (drop (length msgList ) msgList')) ))"
proof -
have ReachImplAgree: "\<forall> cfg . reachable (last cfgList) cfg
\<longrightarrow> agreement cfg"
using Agreement Init NonUni ReachableTrans
unfolding agreementInit_def agreement_def initReachable_def
by (metis (full_types))
have "\<exists> msg p. enabled (last cfgList) msg \<and> isReceiverOf p msg"
proof -
from PseudoTermination NonUni have
"\<exists>c'. qReachable (last cfgList) Proc c' \<and> decided c'"
using terminationPseudo_def by auto
then obtain c' where C': "reachable (last cfgList) c'"
"decided c'"
using QReachImplReach by blast
have NoOut:
"0 = msgs (last cfgList) <\<bottom>, outM False>"
"0 = msgs (last cfgList) <\<bottom>, outM True>"
using NonUni ReachImplAgree PseudoTermination
by (metis NonUniformImpliesNotDecided neq0_conv)+
with C'(2) have "(last cfgList) \<noteq> c'"
by (metis (full_types) less_zeroE)
thus ?thesis using C'(1) ReachableStepFirst by blast
qed
then obtain msg p where Enabled:
"enabled (last cfgList) msg" "isReceiverOf p msg" by blast
hence "\<exists> msg . execution.minimalEnabled cfgList msgList msg"
using Init execution.ExistImpliesMinEnabled[OF Execution] by auto
then obtain msg' where MinEnabledMsg:
"execution.minimalEnabled cfgList msgList msg'" by blast
hence "\<exists> p' . isReceiverOf p' msg'"
using Execution
by (auto simp add: execution.minimalEnabled_def)
then obtain p' where
P': "isReceiverOf p' msg'" by blast
hence Enabled':
"enabled (last cfgList) msg'" "isReceiverOf p' msg'"
using MinEnabledMsg Execution
by (auto simp add: execution.minimalEnabled_def)
have "\<exists> exec' trace' . (execution trans sends start exec' trace')
\<and> nonUniform (last exec')
\<and> prefixList cfgList exec' \<and> prefixList msgList trace'
\<and> (\<forall> cfg . reachable (last exec') cfg \<longrightarrow> agreement cfg)
\<and> stepReachable (last cfgList) msg' (last exec')
\<and> (msg' \<in> set (drop (length msgList) trace')) "
using NonUniformExecutionsConstructable[OF Enabled' Execution
NonUni] ReachImplAgree by auto
thus ?thesis
using MinEnabledMsg by (metis execution.base)
qed
subsection \<open>Non-uniformity even when demanding fairness\<close>
text \<open>
Using \isb{NonUniformExecutionBase} and \isb{NonUniformExecutionStep} one can obtain
non-uniform executions which are fair.
Proving the fairness turned out quite cumbersome.
\<close>
text \<open>
These two functions construct infinite series of configurations lists
and message lists from two extension functions.
\<close>
fun infiniteExecutionCfg ::
"('p, 'v, 's) configuration \<Rightarrow>
(('p, 'v, 's) configuration list \<Rightarrow> ('p, 'v) message list
\<Rightarrow> ('p, 'v, 's) configuration list) \<Rightarrow>
(('p, 'v, 's) configuration list \<Rightarrow> ('p, 'v) message list
\<Rightarrow>('p, 'v) message list)
\<Rightarrow> nat
\<Rightarrow> (('p, 'v, 's) configuration list)"
and infiniteExecutionMsg ::
"('p, 'v, 's) configuration \<Rightarrow>
(('p, 'v, 's) configuration list \<Rightarrow> ('p, 'v) message list
\<Rightarrow> ('p, 'v, 's) configuration list) \<Rightarrow>
(('p, 'v, 's) configuration list \<Rightarrow> ('p, 'v) message list
\<Rightarrow>('p, 'v) message list)
\<Rightarrow> nat
\<Rightarrow> ('p, 'v) message list"
where
"infiniteExecutionCfg cfg fStepCfg fStepMsg 0 = [cfg]"
| "infiniteExecutionCfg cfg fStepCfg fStepMsg (Suc n) =
fStepCfg (infiniteExecutionCfg cfg fStepCfg fStepMsg n)
(infiniteExecutionMsg cfg fStepCfg fStepMsg n)"
| "infiniteExecutionMsg cfg fStepCfg fStepMsg 0 = []"
| "infiniteExecutionMsg cfg fStepCfg fStepMsg (Suc n) =
fStepMsg (infiniteExecutionCfg cfg fStepCfg fStepMsg n)
(infiniteExecutionMsg cfg fStepCfg fStepMsg n)"
lemma FairNonUniformExecution:
fixes
cfg
assumes
Cfg: "initial cfg" "nonUniform cfg"
shows "\<exists> fe ft.
(fe 0) = [cfg]
\<and> fairInfiniteExecution fe ft
\<and> (\<forall> n . nonUniform (last (fe n))
\<and> prefixList (fe n) (fe (n+1))
\<and> prefixList (ft n) (ft (n+1))
\<and> (execution trans sends start (fe n) (ft n)))"
proof -
have BC:
"execution trans sends start [cfg] []
\<and> nonUniform (last [cfg])
\<and> (\<exists> cfgList' msgList'. nonUniform (last cfgList')
\<and> prefixList [cfg] cfgList'
\<and> prefixList [] msgList'
\<and> (execution trans sends start cfgList' msgList')
\<and> (\<exists> msg'. execution.minimalEnabled [cfg] [] msg'
\<and> msg' \<in> set msgList'))"
using NonUniformExecutionBase[OF assms] .
\<comment> \<open>fStep ... a step leading to a fair execution.\<close>
obtain fStepCfg fStepMsg where FStep: "\<forall> cfgList msgList . \<exists>cfgList' msgList' .
fStepCfg cfgList msgList = cfgList' \<and>
fStepMsg cfgList msgList = msgList' \<and>
(initial (hd cfgList) \<and>
nonUniform (last cfgList) \<and>
execution trans sends start cfgList msgList \<longrightarrow>
(nonUniform (last (fStepCfg cfgList msgList))
\<and> prefixList cfgList (fStepCfg cfgList msgList)
\<and> prefixList msgList (fStepMsg cfgList msgList)
\<and> execution trans sends start (fStepCfg cfgList msgList)
(fStepMsg cfgList msgList)
\<and> (initial (hd (fStepCfg cfgList msgList)))
\<and> (\<exists> msg'. execution.minimalEnabled cfgList msgList msg'
\<and> msg' \<in> (set (drop (length msgList)
(fStepMsg cfgList msgList))))))"
using NonUniformExecutionStep
PredicatePairFunctions2[of
"\<lambda> cfgList msgList cfgList' msgList'.
(initial (hd cfgList)
\<and> nonUniform (last cfgList)
\<and> execution trans sends start cfgList msgList
\<longrightarrow> (nonUniform (last cfgList')
\<and> prefixList cfgList cfgList'
\<and> prefixList msgList msgList'
\<and> execution trans sends start cfgList' msgList'
\<and> (initial (hd cfgList'))
\<and> (\<exists> msg'. execution.minimalEnabled cfgList msgList msg'
\<and> msg' \<in> (set (drop (length msgList ) msgList')))))" "False"] by auto
define fe ft
where "fe = infiniteExecutionCfg cfg fStepCfg fStepMsg"
and "ft = infiniteExecutionMsg cfg fStepCfg fStepMsg"
have BasicProperties: "(\<forall>n. nonUniform (last (fe n))
\<and> prefixList (fe n) (fe (n + 1)) \<and> prefixList (ft n) (ft (n + 1))
\<and> execution trans sends start (fe n) (ft n)
\<and> initial (hd (fe (n + 1))))"
proof (clarify)
fix n
show "nonUniform (last (fe n)) \<and>
prefixList (fe n) (fe (n + (1::nat)))
\<and> prefixList (ft n) (ft (n + (1::nat)))
\<and> execution trans sends start (fe n) (ft n)
\<and> initial (hd (fe (n + 1)))"
proof(induct n)
case 0
hence "fe 0 = [cfg]" "ft 0 = []" "fe 1 = fStepCfg (fe 0) (ft 0)"
"ft 1 = fStepMsg (fe 0) (ft 0)"
using fe_def ft_def
by simp_all
thus ?case
using BC FStep
by (simp, metis execution.base)
next
case (Suc n)
thus ?case
using fe_def ft_def
by (auto, (metis FStep execution.base)+)
qed
qed
have Fair: "fairInfiniteExecution fe ft"
using BasicProperties
unfolding fairInfiniteExecution_def infiniteExecution_def
execution_def flpSystem_def
proof(auto simp add: finiteProcs minimalProcs finiteSends noInSends)
fix n n0 p msg
assume AssumptionFair: "\<forall>n. initReachable (last (fe n)) \<and>
\<not> vUniform False (last (fe n)) \<and>
\<not> vUniform True (last (fe n)) \<and>
prefixList (fe n) (fe (Suc n)) \<and>
prefixList (ft n) (ft (Suc n)) \<and>
Suc 0 \<le> length (fe n) \<and>
length (fe n) - Suc 0 = length (ft n) \<and>
initial (hd (fe n)) \<and>
(\<forall>i<length (fe n) - Suc 0. ((fe n ! i) \<turnstile> (ft n ! i)
\<mapsto> (fe n ! Suc i))) \<and> initial (hd (fe (Suc n)))"
"n0 < length (fe n)"
"enabled (fe n ! n0) msg"
"isReceiverOf p msg"
"correctInfinite fe ft p"
have MessageStaysOrConsumed: "\<And> n n1 n2 msg.
(n1 \<le> n2 \<and> n2 < length (fe n) \<and> (enabled (fe n ! n1) msg))
\<longrightarrow> (enabled (fe n ! n2) msg)
\<or> (\<exists> n0' \<ge> n1. n0' < length (ft n) \<and> ft n ! n0' = msg)"
proof(auto)
fix n n1 n2 msg
assume Ass: "n1 \<le> n2" "n2 < length (fe n)" "enabled (fe n ! n1) msg"
"\<forall>index<length (ft n). n1 \<le> index \<longrightarrow> ft n ! index \<noteq> msg"
have "\<forall> k \<le> n2 - n1 .
msgs (fe n ! n1) msg \<le> msgs (fe n ! (n1 + k)) msg"
proof(auto)
fix k
show "k \<le> n2 - n1 \<Longrightarrow>
msgs (fe n ! n1) msg \<le> msgs (fe n ! (n1 + k)) msg"
proof(induct k, auto)
fix k
assume IV: "msgs (fe n ! n1) msg \<le> msgs (fe n ! (n1 + k)) msg"
"Suc k \<le> n2 - n1"
from BasicProperties have Exec:
"execution trans sends start (fe n) (ft n)" by blast
have "n2 \<le> length (ft n)"
using Exec Ass(2)
execution.length[of trans sends start "fe n" "ft n"]
by simp
hence RightIndex: "n1 + k \<ge> n1 \<and> n1 + k < length (ft n)"
using IV(2) by simp
have Step: "(fe n ! (n1 + k)) \<turnstile> (ft n ! (n1 + k))
\<mapsto> (fe n ! Suc (n1 + k))"
using Exec execution.step[of trans sends start "fe n" "ft n"
"n1 + k" "fe n ! (n1 + k)" "fe n ! (n1 + k + 1)"] IV(2)
Ass(2)
by simp
hence "msg \<noteq> (ft n ! (n1 + k))"
using Ass(4) Ass(2) IV(2) RightIndex Exec
execution.length[of trans sends start "fe n" "ft n"]
by blast
thus "msgs (fe n ! n1) msg \<le> msgs (fe n ! Suc (n1 + k)) msg"
using Step OtherMessagesOnlyGrowing[of "(fe n ! (n1 + k))"
"(ft n ! (n1 + k))" "(fe n ! Suc (n1 + k))" "msg"] IV(1)
by simp
qed
qed
hence "msgs (fe n ! n1) msg \<le> msgs (fe n ! n2) msg"
by (metis Ass(1) le_add_diff_inverse order_refl)
thus "enabled (fe n ! n2) msg" using Ass(3) enabled_def
by (metis gr0I leD)
qed
have EnabledOrConsumed: "enabled (fe n ! (length (fe n) - 1)) msg
\<or> (\<exists>n0'\<ge>n0. n0' < length (ft n) \<and> ft n ! n0' = msg)"
using AssumptionFair(3) AssumptionFair(2)
MessageStaysOrConsumed[of "n0" "length (fe n) - 1" "n" "msg"]
by auto
have EnabledOrConsumedAtLast: "enabled (last (fe n)) msg \<or>
(\<exists> n0' . n0' \<ge> n0 \<and> n0' < length (ft n) \<and> (ft n) ! n0' = msg )"
using EnabledOrConsumed last_conv_nth AssumptionFair(2)
by (metis length_0_conv less_nat_zero_code)
have Case2ImplThesis: "(\<exists> n0' . n0' \<ge> n0 \<and> n0' < length (ft n)
\<and> ft n ! n0' = msg)
\<Longrightarrow> (\<exists>n'\<ge>n. \<exists>n0'\<ge>n0. n0' < length (ft n') \<and> msg = ft n' ! n0')"
by auto
have Case1ImplThesis': "enabled (last (fe n)) msg
\<longrightarrow> (\<exists>n'\<ge>n. \<exists>n0'\<ge> (length (ft n)). n0' < length (ft n')
\<and> msg = ft n' ! n0')"
proof(clarify)
assume AssumptionCase1ImplThesis': "enabled (last (fe n)) msg"
show "\<exists>n'\<ge>n. \<exists>n0'\<ge>length (ft n). n0' < length (ft n')
\<and> msg = ft n' ! n0'"
proof(rule ccontr,simp)
assume AssumptionFairContr: "\<forall>n'\<ge>n. \<forall>n0'<length (ft n').
length (ft n) \<le> n0' \<longrightarrow> msg \<noteq> ft n' ! n0'"
define firstOccSet where "firstOccSet n = { msg1 . \<exists> nMsg .
\<exists> n1 \<le> nMsg .
execution.firstOccurrence (fe n) (ft n) msg1 n1
\<and> execution.firstOccurrence (fe n) (ft n) msg nMsg }" for n
have NotEmpty: "fe n \<noteq> []" using AssumptionFair(2)
by (metis less_nat_zero_code list.size(3))
have FirstToLast':
"\<forall> n . reachable ((fe n) ! 0) ((fe n) ! (length (fe n) - 1))"
using execution.ReachableInExecution BasicProperties execution.notEmpty
by (metis diff_less less_or_eq_imp_le not_gr0 not_one_le_zero)
hence FirstToLast: "\<forall> n . reachable (hd (fe n)) (last (fe n))"
using NotEmpty hd_conv_nth last_conv_nth AssumptionFair(1)
by (metis (full_types) One_nat_def length_0_conv
not_one_le_zero)
hence InitToLast: "\<forall> n . initReachable (last (fe n))"
using BasicProperties by auto
have "\<And> msg n0 . \<forall> n .
(execution.firstOccurrence (fe n) (ft n) msg n0)
\<longrightarrow> 0 < msgs (last (fe n)) msg"
using BasicProperties execution.firstOccurrence_def
enabled_def
by metis
hence "\<forall> n . \<forall> msg' \<in> (firstOccSet n) .
0 < msgs (last (fe n)) msg'" using firstOccSet_def by blast
hence "\<forall> n . firstOccSet n \<subseteq> {msg. 0 < msgs (last (fe n)) msg}"
by (metis (lifting, full_types) mem_Collect_eq subsetI)
hence FiniteMsgs: "\<forall> n . finite (firstOccSet n)"
using FiniteMessages[OF finiteProcs finiteSends] InitToLast
by (metis rev_finite_subset)
have FirstOccSetDecrOrConsumed: "\<forall> index .
(enabled (last (fe index)) msg)
\<longrightarrow> (firstOccSet (Suc index) \<subset> firstOccSet index
\<and> (enabled (last (fe (Suc index))) msg)
\<or> msg \<in> (set (drop (length (ft index)) (ft (Suc index)))))"
proof(clarify)
fix index
assume AssumptionFirstOccSetDecrOrConsumed:
"enabled (last (fe index)) msg"
"msg \<notin> set (drop (length (ft index)) (ft (Suc index)))"
have NotEmpty: "fe (Suc index) \<noteq> []" "fe index \<noteq> []"
using BasicProperties
by (metis AssumptionFair(1) One_nat_def list.size(3)
not_one_le_zero)+
have LengthStep: "length (ft (Suc index)) > length (ft index)"
using AssumptionFair(1)
by (metis PrefixListMonotonicity)
have IPrefixList:
"\<forall> i::nat . prefixList (ft i) (ft (Suc i))"
using AssumptionFair(1) by auto
have IPrefixListEx:
"\<forall> i::nat . prefixList (fe i) (fe (Suc i))"
using AssumptionFair(1) by auto
have LastOfIndex:
"(fe (Suc index) ! (length (fe index) - Suc 0))
= (last (fe index))"
using PrefixSameOnLow[of "fe index" "fe (Suc index)"]
IPrefixListEx[rule_format, of index]
NotEmpty LengthStep
by (auto simp add: last_conv_nth)
have NotConsumedIntermediate:
"\<forall> i::nat < length (ft (Suc index)) .
(i \<ge> length (ft index)
\<longrightarrow> ft (Suc index) ! i \<noteq> msg)"
using AssumptionFirstOccSetDecrOrConsumed(2) ListLenDrop
by auto
hence
"\<not>(\<exists>i. i < length (ft (Suc index)) \<and> i \<ge> length (ft index)
\<and> msg = (ft (Suc index)) ! i)"
using execution.length BasicProperties
by auto
hence "\<not>(\<exists>i. i < length (fe (Suc index)) - 1
\<and> i \<ge> length (fe index) - 1
\<and> msg = (ft (Suc index)) ! i)"
using BasicProperties[rule_format, of "Suc index"]
BasicProperties[rule_format, of "index"]
execution.length[of trans sends start]
by auto
hence EnabledIntermediate:
"\<forall> i < length (fe (Suc index)) . (i \<ge> length (fe index) - 1
\<longrightarrow> enabled (fe (Suc index) ! i) msg)"
using BasicProperties[rule_format, of "Suc index"]
BasicProperties[rule_format, of "index"]
execution.StaysEnabled[of trans sends start
"fe (Suc index)" "ft (Suc index)" "last (fe index)" msg
"length (fe index) - 1 "]
AssumptionFirstOccSetDecrOrConsumed(1)
by (auto, metis AssumptionFair(1) LastOfIndex
MessageStaysOrConsumed)
have "length (fe (Suc index)) - 1 \<ge> length (fe index) - 1"
using PrefixListMonotonicity NotEmpty BasicProperties
by (metis AssumptionFair(1) diff_le_mono less_imp_le)
hence "enabled (fe (Suc index)
! (length (fe (Suc index)) - 1)) msg"
using EnabledIntermediate NotEmpty(1)
by (metis diff_less length_greater_0_conv zero_less_one)
hence EnabledInSuc: "enabled (last (fe (Suc index))) msg"
using NotEmpty last_conv_nth[of "fe (Suc index)"] by simp
have IndexIsExec:
"execution trans sends start (fe index) (ft index)"
using BasicProperties by blast
have SucIndexIsExec:
"execution trans sends start (fe (Suc index))
(ft (Suc index))"
using BasicProperties by blast
have SameCfgOnLow: "\<forall> i < length (fe index) . (fe index) ! i
= (fe (Suc index)) ! i"
using BasicProperties PrefixSameOnLow by auto
have SameMsgOnLow: "\<forall> i < length (ft index) . (ft index) ! i
= (ft (Suc index)) ! i"
using BasicProperties PrefixSameOnLow by auto
have SmallIndex: "\<And> nMsg . execution.firstOccurrence
(fe (Suc index)) (ft (Suc index)) msg nMsg
\<Longrightarrow> nMsg < length (fe index)"
proof(-)
fix nMsg
assume "execution.firstOccurrence (fe (Suc index))
(ft (Suc index)) msg nMsg"
hence AssumptionSubset3:
"\<exists>p. isReceiverOf p msg"
"enabled (last (fe (Suc index))) msg"
"nMsg < length (fe (Suc index))"
"enabled (fe (Suc index) ! nMsg) msg"
"\<forall>n'\<ge>nMsg. n' < length (ft (Suc index))
\<longrightarrow> msg \<noteq> ft (Suc index) ! n'"
"nMsg \<noteq> 0 \<longrightarrow> \<not> enabled (fe (Suc index) ! (nMsg - 1))
msg \<or> msg = ft (Suc index) ! (nMsg - 1)"
using execution.firstOccurrence_def[of "trans" "sends"
"start" "fe (Suc index)" "ft (Suc index)" "msg" "nMsg"]
SucIndexIsExec by auto
show "nMsg < length (fe index)"
proof(rule ccontr)
assume AssumpSmallIndex: "\<not> nMsg < length (fe index)"
have "fe index \<noteq> []" using BasicProperties
AssumptionFair(1)
by (metis One_nat_def list.size(3) not_one_le_zero)
hence "length (fe index) > 0"
by (metis length_greater_0_conv)
hence nMsgNotZero: "nMsg \<noteq> 0"
using AssumpSmallIndex by metis
hence SucCases: "\<not> enabled ((fe (Suc index)) ! (nMsg - 1))
msg \<or> msg = (ft (Suc index)) ! (nMsg - 1)"
using AssumptionSubset3(6) by blast
have Cond1: "nMsg - 1 \<ge> length (fe index) - 1"
using AssumpSmallIndex by (metis diff_le_mono leI)
hence Enabled: "enabled (fe (Suc index) ! (nMsg - 1)) msg"
using EnabledIntermediate AssumptionSubset3(3)
by (metis less_imp_diff_less)
have Cond2: "nMsg - 1 \<ge> length (ft index) \<and> nMsg - 1
< length (ft (Suc index))"
using Cond1 execution.length[of "trans" "sends" "start"
"fe index" "ft index"]
IndexIsExec AssumptionSubset3(3)
by (simp, metis AssumptionFair(1) One_nat_def Suc_diff_1
Suc_eq_plus1 less_diff_conv nMsgNotZero neq0_conv)
hence NotConsumed: "ft (Suc index) ! (nMsg - 1) \<noteq> msg"
using NotConsumedIntermediate by simp
show False using SucCases Enabled NotConsumed
by blast
qed
qed
have Subset: "\<And> msgInSet . msgInSet \<in> firstOccSet (Suc index)
\<Longrightarrow> msgInSet \<in> firstOccSet index"
unfolding firstOccSet_def
proof(auto)
fix msgInSet nMsg n1
assume AssumptionSubset: "n1 \<le> nMsg"
"execution.firstOccurrence (fe (Suc index))
(ft (Suc index)) msgInSet n1"
"execution.firstOccurrence (fe (Suc index))
(ft (Suc index)) msg nMsg"
have AssumptionSubset2:
"\<exists>p. isReceiverOf p msgInSet"
"enabled (last (fe (Suc index))) msgInSet"
"n1 < length (fe (Suc index))"
"enabled (fe (Suc index) ! n1) msgInSet"
"\<forall>n'\<ge>n1. n' < length (ft (Suc index))
\<longrightarrow> msgInSet \<noteq> ft (Suc index) ! n'"
"n1 \<noteq> 0 \<longrightarrow> \<not> enabled (fe (Suc index) ! (n1 - 1))
msgInSet \<or> msgInSet = ft (Suc index) ! (n1 - 1)"
using execution.firstOccurrence_def[of "trans" "sends"
"start" "fe (Suc index)" "ft (Suc index)" "msgInSet"
"n1"] AssumptionSubset(2) SucIndexIsExec by auto
have AssumptionSubset3:
"\<exists>p. isReceiverOf p msg"
"enabled (last (fe (Suc index))) msg"
"nMsg < length (fe (Suc index))"
"enabled (fe (Suc index) ! nMsg) msg"
"\<forall>n'\<ge>nMsg. n' < length (ft (Suc index))
\<longrightarrow> msg \<noteq> ft (Suc index) ! n'"
"nMsg \<noteq> 0 \<longrightarrow> \<not> enabled (fe (Suc index) ! (nMsg - 1))
msg \<or> msg = ft (Suc index) ! (nMsg - 1)"
using execution.firstOccurrence_def[of "trans" "sends"
"start" "fe (Suc index)" "ft (Suc index)" "msg" "nMsg"]
AssumptionSubset(3) SucIndexIsExec by auto
have ShorterTrace: "length (ft index)
< length (ft (Suc index))"
using PrefixListMonotonicity BasicProperties by auto
have FirstOccurrenceMsg: "execution.firstOccurrence
(fe index) (ft index) msg nMsg"
proof-
have Occ1: "\<exists> p . isReceiverOf p msg"
using AssumptionSubset3(1) by blast
have Occ2: "enabled (last (fe index)) msg"
using AssumptionFirstOccSetDecrOrConsumed by blast
have "(fe index) ! nMsg = (fe (Suc index)) ! nMsg"
using SmallIndex AssumptionSubset(3)
PrefixSameOnLow[of "fe index" "fe (Suc index)"]
BasicProperties
by simp
hence Occ4: "enabled ((fe index) ! nMsg) msg"
using AssumptionSubset3(4) by simp
have OccSameMsg: "\<forall> n' \<ge> nMsg . n' < length (ft index)
\<longrightarrow> (ft index) ! n' = (ft (Suc index)) ! n'"
using PrefixSameOnLow BasicProperties by auto
hence Occ5: "\<forall> n' \<ge> nMsg . n' < length (ft index)
\<longrightarrow> msg \<noteq> ((ft index) ! n')"
using AssumptionSubset3(5) ShorterTrace by simp
have Occ6: "nMsg \<noteq> 0 \<longrightarrow> (\<not> enabled ((fe index) !
(nMsg - 1)) msg \<or> msg = (ft index ) ! (nMsg - 1))"
proof(clarify)
assume AssumpOcc6: "0 < nMsg" "msg \<noteq> ft index !
(nMsg - 1)" "enabled (fe index ! (nMsg - 1)) msg"
have "nMsg - (Suc 0) < length (fe index) - (Suc 0)"
using SmallIndex AssumptionSubset(3) AssumpOcc6(1)
by (metis Suc_le_eq diff_less_mono)
hence SmallIndexTrace: "nMsg - 1 < length (ft index)"
using IndexIsExec execution.length
by (metis One_nat_def)
have "\<not> enabled (fe (Suc index) ! (nMsg - 1)) msg
\<or> msg = ft (Suc index) ! (nMsg - 1)"
using AssumptionSubset3(6) AssumpOcc6(1) by blast
moreover have "fe (Suc index) ! (nMsg - 1)
= fe index ! (nMsg - 1)"
using SameCfgOnLow SmallIndex AssumptionSubset(3)
by (metis less_imp_diff_less)
moreover have "ft (Suc index) ! (nMsg - 1)
= ft index ! (nMsg - 1)"
using SameMsgOnLow SmallIndexTrace by metis
ultimately have "\<not> enabled (fe index ! (nMsg - 1)) msg
\<or> msg = ft index ! (nMsg - 1)"
by simp
thus False using AssumpOcc6 by blast
qed
show ?thesis using IndexIsExec Occ1 Occ2 SmallIndex
AssumptionSubset(3) Occ4 Occ5 Occ6
execution.firstOccurrence_def[of "trans" "sends" "start"
"fe index" "ft index"]
by simp
qed
have "execution.firstOccurrence (fe index) (ft index)
msgInSet n1"
using AssumptionSubset2 AssumptionSubset(1)
proof-
have Occ1': "\<exists>p. isReceiverOf p msgInSet"
using AssumptionSubset2(1) by blast
have Occ3': "n1 < length (fe index)"
using SmallIndex AssumptionSubset(3) AssumptionSubset(1)
by (metis le_less_trans)
have "(fe index) ! n1 = (fe (Suc index)) ! n1"
using Occ3' PrefixSameOnLow[of "fe index"
"fe (Suc index)"] BasicProperties by simp
hence Occ4': "enabled (fe index ! n1) msgInSet"
using AssumptionSubset2(4) by simp
have OccSameMsg': "\<forall> n' \<ge> n1 . n' < length (ft index)
\<longrightarrow> (ft index) ! n' = (ft (Suc index)) ! n'"
using PrefixSameOnLow BasicProperties by auto
hence Occ5': "\<forall>n' \<ge> n1. n' < length (ft index)
\<longrightarrow> msgInSet \<noteq> ft index ! n'"
using AssumptionSubset2(5) ShorterTrace by simp
have "length (fe index) > 0" using NotEmpty(2)
by (metis length_greater_0_conv)
hence "length (fe index) - 1 < length (fe index)"
by (metis One_nat_def diff_Suc_less)
hence
"enabled (fe index ! (length (fe index) - 1)) msgInSet
\<or> (\<exists>n0'\<ge>n1. n0' < length (ft index) \<and> ft index ! n0'
= msgInSet)"
using Occ4' Occ3' MessageStaysOrConsumed[of "n1"
"length (fe index) - 1" "index" "msgInSet"]
by (metis Suc_pred' \<open>0 < length (fe index)\<close>
not_le not_less_eq_eq)
hence "enabled ((fe index) ! (length (fe index) - 1))
msgInSet"
using Occ5' by auto
hence Occ2': "enabled (last (fe index)) msgInSet"
using last_conv_nth[of "fe index"] NotEmpty(2) by simp
have Occ6': "n1 \<noteq> 0 \<longrightarrow> \<not> enabled (fe index ! (n1 - 1))
msgInSet \<or> msgInSet = ft index ! (n1 - 1)"
proof(clarify)
assume AssumpOcc6': "0 < n1" "msgInSet \<noteq> ft index !
(n1 - 1)" "enabled (fe index ! (n1 - 1)) msgInSet"
have "n1 - (Suc 0) < length (fe index) - (Suc 0)"
using Occ3' AssumpOcc6'(1)
by (metis Suc_le_eq diff_less_mono)
hence SmallIndexTrace': "n1 - 1 < length (ft index)"
using IndexIsExec execution.length
by (metis One_nat_def)
have "\<not> enabled (fe (Suc index) ! (n1 - 1)) msgInSet
\<or> msgInSet = ft (Suc index) ! (n1 - 1)"
using AssumptionSubset2(6) AssumpOcc6'(1) by blast
moreover have "fe (Suc index) ! (n1 - 1)
= fe index ! (n1 - 1)"
using SameCfgOnLow Occ3' by (metis less_imp_diff_less)
moreover have "ft (Suc index) ! (n1 - 1)
= ft index ! (n1 - 1)"
using SameMsgOnLow SmallIndexTrace' by metis
ultimately have "\<not> enabled (fe index !
(n1 - 1)) msgInSet \<or> msgInSet = ft index ! (n1 - 1)"
by simp
thus False using AssumpOcc6' by blast
qed
show ?thesis using IndexIsExec Occ1' Occ2' Occ3' Occ4'
Occ5' Occ6'
execution.firstOccurrence_def[of "trans" "sends"
"start" "fe index" "ft index"]
by simp
qed
thus "\<exists>nMsg' n1'. n1' \<le> nMsg'
\<and> execution.firstOccurrence (fe index) (ft index)
msgInSet n1'
\<and> execution.firstOccurrence (fe index) (ft index)
msg nMsg'"
using FirstOccurrenceMsg AssumptionSubset(1) by blast
qed
have ProperSubset: "\<exists> msg' .msg' \<in> firstOccSet index
\<and> msg' \<notin> firstOccSet (Suc index)"
proof-
have "initial (hd (fe index))" using AssumptionFair(1)
by blast
hence "\<exists>msg'. execution.minimalEnabled (fe index) (ft index)
msg' \<and> msg' \<in> set (drop (length (ft index))
(fStepMsg (fe index) (ft index)))"
using FStep fe_def ft_def
BasicProperties by simp
then obtain consumedMsg where ConsumedMsg:
"execution.minimalEnabled (fe index) (ft index)
consumedMsg"
"consumedMsg \<in> set (drop (length (ft index))
(fStepMsg (fe index) (ft index)))" by blast
hence ConsumedIsInDrop:
"consumedMsg \<in> set (drop (length (ft index)) (ft (Suc index)))"
using fe_def ft_def FStep
BasicProperties[rule_format, of index]
by auto
have MinImplAllBigger: "\<And> msg' . execution.minimalEnabled
(fe index) (ft index) msg'
\<longrightarrow> (\<exists> OccM' . (execution.firstOccurrence (fe index)
(ft index) msg' OccM' )
\<and> (\<forall> msg . \<forall> OccM . execution.firstOccurrence (fe index)
(ft index) msg OccM
\<longrightarrow> OccM' \<le> OccM))"
proof(auto)
fix msg'
assume AssumpMinImplAllBigger: "execution.minimalEnabled
(fe index) (ft index) msg'"
have IsExecIndex: "execution trans sends start
(fe index) (ft index)"
using BasicProperties[rule_format, of index] by simp
have "(\<exists> p . isReceiverOf p msg') \<and>
(enabled (last (fe index)) msg')
\<and> (\<exists> n . n < length (fe index)
\<and> enabled ( (fe index) ! n) msg'
\<and> (\<forall> n' \<ge> n . n' < length (ft index)
\<longrightarrow> msg' \<noteq> ((ft index)! n'))
\<and> (\<forall> n' msg' . ((\<exists> p . isReceiverOf p msg')
\<and> (enabled (last (fe index)) msg')
\<and> n' < length (ft index)
\<and> enabled ((fe index)! n') msg'
\<and> (\<forall> n'' \<ge> n' . n'' < length (ft index)
\<longrightarrow> msg' \<noteq> ((ft index) ! n''))) \<longrightarrow> n' \<ge> n))"
using execution.minimalEnabled_def[of trans sends start
"(fe index)" "(ft index)" msg']
AssumpMinImplAllBigger IsExecIndex by auto
then obtain OccM' where OccM':
"(\<exists> p . isReceiverOf p msg')"
"(enabled (last (fe index)) msg')"
"OccM' < length (fe index)"
"enabled ( (fe index) ! OccM') msg'"
"(\<forall> n' \<ge> OccM' . n' < length (ft index)
\<longrightarrow> msg' \<noteq> ((ft index)! n'))"
"(\<forall> n' msg' . ((\<exists> p . isReceiverOf p msg')
\<and> (enabled (last (fe index)) msg')
\<and> n' < length (ft index)
\<and> enabled ((fe index)! n') msg'
\<and> (\<forall> n'' \<ge> n' . n'' < length (ft index)
\<longrightarrow> msg' \<noteq> ((ft index) ! n''))) \<longrightarrow> n' \<ge> OccM')"
by blast
have "0 < OccM' \<Longrightarrow> enabled (fe index ! (OccM' - Suc 0)) msg'
\<Longrightarrow> msg' \<noteq> ft index ! (OccM' - Suc 0) \<Longrightarrow> False"
proof(-)
fix p
assume AssumpContr:
"0 < OccM'"
"enabled (fe index ! (OccM' - Suc 0)) msg'"
"msg' \<noteq> ft index ! (OccM' - Suc 0)"
have LengthOccM': "(OccM' - 1) < length (ft index)"
using OccM'(3) IndexIsExec AssumpContr(1)
AssumptionFair(1)
by (metis One_nat_def Suc_diff_1 Suc_eq_plus1_left
Suc_less_eq le_add_diff_inverse)
have BiggerIndices: "(\<forall>n''\<ge>(OccM' - 1).
n'' < length (ft index) \<longrightarrow> msg' \<noteq> ft index ! n'')"
using OccM'(5) by (metis AssumpContr(3) One_nat_def
Suc_eq_plus1 diff_Suc_1 le_SucE le_diff_conv)
have "(\<exists>p. isReceiverOf p msg') \<and> enabled (last
(fe index)) msg' \<and> (OccM' - 1) < length (ft index)
\<and> enabled (fe index ! (OccM' - 1)) msg'
\<and> (\<forall>n''\<ge>(OccM' - 1). n'' < length (ft index)
\<longrightarrow> msg' \<noteq> ft index ! n'')"
using OccM' LengthOccM' AssumpContr BiggerIndices
by simp
hence "OccM' \<le> OccM' - 1" using OccM'(6) by blast
thus False using AssumpContr(1) diff_less leD zero_less_one by blast
qed
hence FirstOccMsg': "execution.firstOccurrence (fe index)
(ft index) msg' OccM'"
unfolding execution_def
execution.firstOccurrence_def[OF IsExecIndex, of msg' OccM']
by (auto simp add: OccM'(1,2,3,4,5))
have "\<forall>msg OccM. execution.firstOccurrence (fe index)
(ft index) msg OccM \<longrightarrow> OccM' \<le> OccM"
proof clarify
fix msg OccM
assume "execution.firstOccurrence (fe index)
(ft index) msg OccM"
hence AssumpOccMFirstOccurrence:
"\<exists> p . isReceiverOf p msg"
"enabled (last (fe index)) msg"
"OccM < (length (fe index))"
"enabled ((fe index) ! OccM) msg"
"(\<forall> n' \<ge> OccM . n' < length (ft index)
\<longrightarrow> msg \<noteq> ((ft index) ! n'))"
"(OccM \<noteq> 0 \<longrightarrow> (\<not> enabled ((fe index) ! (OccM - 1))
msg \<or> msg = (ft index)!(OccM - 1)))"
by (auto simp add: execution.firstOccurrence_def[of
trans sends start "(fe index)" "(ft index)"
msg OccM] IsExecIndex)
hence "(\<exists>p. isReceiverOf p msg) \<and>
enabled (last (fe index)) msg \<and>
enabled (fe index ! OccM) msg \<and>
(\<forall>n''\<ge> OccM. n'' < length (ft index)
\<longrightarrow> msg \<noteq> ft index ! n'')"
by simp
thus "OccM' \<le> OccM" using OccM'
proof(cases "OccM < length (ft index)",auto)
assume "\<not> OccM < length (ft index)"
hence "OccM \<ge> length (fe index) - 1"
using AssumptionFair(1) by (metis One_nat_def leI)
hence "OccM = length (fe index) - 1"
using AssumpOccMFirstOccurrence(3) by simp
thus "OccM' \<le> OccM" using OccM'(3) by simp
qed
qed
with FirstOccMsg' show "\<exists>OccM'.
execution.firstOccurrence (fe index) (ft index)
msg' OccM'
\<and> (\<forall>msg OccM. execution.firstOccurrence (fe index)
(ft index) msg OccM \<longrightarrow> OccM' \<le> OccM)" by blast
qed
have MinImplFirstOcc: "\<And> msg' . execution.minimalEnabled
(fe index) (ft index) msg'
\<Longrightarrow> msg' \<in> firstOccSet index"
proof -
fix msg'
assume AssumpMinImplFirstOcc:
"execution.minimalEnabled (fe index) (ft index) msg'"
then obtain OccM' where OccM':
"execution.firstOccurrence (fe index) (ft index)
msg' OccM'"
"\<forall> msg . \<forall> OccM . execution.firstOccurrence
(fe index) (ft index) msg OccM
\<longrightarrow> OccM' \<le> OccM" using MinImplAllBigger by blast
thus "msg' \<in> firstOccSet index" using OccM'
proof (auto simp add: firstOccSet_def)
have "enabled (last (fe index)) msg"
using AssumptionFirstOccSetDecrOrConsumed(1) by blast
hence "\<exists>nMsg . execution.firstOccurrence (fe index)
(ft index) msg nMsg"
using execution.FirstOccurrenceExists IndexIsExec
AssumptionFair(4) by blast
then obtain nMsg where NMsg: "execution.firstOccurrence
(fe index) (ft index) msg nMsg" by blast
hence "OccM' \<le> nMsg" using OccM' by simp
hence "\<exists>nMsg . OccM' \<le> nMsg \<and>
execution.firstOccurrence (fe index) (ft index) msg'
OccM' \<and>
execution.firstOccurrence (fe index) (ft index) msg
nMsg"
using OccM'(1) NMsg by blast
thus "\<exists>nMsg n1 . n1 \<le> nMsg \<and>
execution.firstOccurrence (fe index) (ft index)
msg' n1 \<and>
execution.firstOccurrence (fe index) (ft index)
msg nMsg" by blast
qed
qed
hence ConsumedInSet: "consumedMsg \<in> firstOccSet index"
using ConsumedMsg by simp
have GreaterOccurrence: "\<And> nMsg n1 .
execution.firstOccurrence (fe (Suc index))
(ft (Suc index)) consumedMsg n1 \<and>
execution.firstOccurrence (fe (Suc index))
(ft (Suc index)) msg nMsg
\<Longrightarrow> nMsg < n1"
proof(rule ccontr,auto)
fix nMsg n1
assume AssumpGreaterOccurrence: "\<not> nMsg < n1"
"execution.firstOccurrence (fe (Suc index))
(ft (Suc index)) consumedMsg n1"
"execution.firstOccurrence (fe (Suc index))
(ft (Suc index)) msg nMsg"
have "nMsg < length (fe index)"
using SmallIndex AssumpGreaterOccurrence(3) by simp
hence "n1 < length (fe index)"
using AssumpGreaterOccurrence(1)
by (metis less_trans nat_neq_iff)
hence N1Small: "n1 \<le> length (ft index)"
using IndexIsExec AssumptionFair(1)
by (metis One_nat_def Suc_eq_plus1 le_diff_conv2
not_le not_less_eq_eq)
have NotConsumed: "\<forall> i \<ge> n1 . i < length (ft (Suc index))
\<longrightarrow> consumedMsg \<noteq> (ft (Suc index)) ! i"
using execution.firstOccurrence_def[of "trans" "sends"
"start" "fe (Suc index)" "ft (Suc index)"
"consumedMsg" "n1"]
AssumpGreaterOccurrence(2) SucIndexIsExec by auto
have "\<exists> i \<ge> length (ft index) .
i < length (ft (Suc index))
\<and> consumedMsg = (ft (Suc index)) ! i"
using DropToIndex[of "consumedMsg" "length (ft index)"]
ConsumedIsInDrop by simp
then obtain i where IDef: "i \<ge> length (ft index)"
"i < length (ft (Suc index))"
"consumedMsg = (ft (Suc index)) ! i" by blast
thus False using NotConsumed N1Small by simp
qed
have "consumedMsg \<notin> firstOccSet (Suc index)"
proof(clarify)
assume AssumpConsumedInSucSet:
"consumedMsg \<in> firstOccSet (Suc index)"
hence "\<exists>nMsg n1. n1 \<le> nMsg \<and>
execution.firstOccurrence (fe (Suc index))
(ft (Suc index)) consumedMsg n1 \<and>
execution.firstOccurrence (fe (Suc index))
(ft (Suc index)) msg nMsg"
using firstOccSet_def by blast
thus False using GreaterOccurrence
by (metis less_le_trans less_not_refl3)
qed
thus ?thesis using ConsumedInSet by blast
qed
hence "firstOccSet (Suc index) \<subset> firstOccSet index"
using Subset by blast
thus "firstOccSet (Suc index) \<subset> firstOccSet index
\<and> enabled (last (fe (Suc index))) msg"
using EnabledInSuc by blast
qed
have NotConsumed: "\<forall> index \<ge> n . \<not> msg \<in>
(set (drop (length (ft index)) (ft (Suc index))))"
proof(clarify)
fix index
assume AssumpMsgNotConsumed: "n \<le> index"
"msg \<in> set (drop (length (ft index)) (ft (Suc index)))"
have "\<exists> n0' \<ge> length (ft index) .
n0' < length (ft (Suc index))
\<and> msg = (ft (Suc index)) ! n0'"
using AssumpMsgNotConsumed(2) DropToIndex[of "msg"
"length (ft index)" "ft (Suc index)"] by auto
then obtain n0' where MessageIndex: "n0' \<ge> length (ft index)"
"n0' < length (ft (Suc index))"
"msg = (ft (Suc index)) ! n0'" by blast
have LengthIncreasing: "length (ft n) \<le> length (ft index)"
using AssumpMsgNotConsumed(1)
proof(induct index,auto)
fix indexa
assume AssumpLengthIncreasing:
"n \<le> indexa \<Longrightarrow> length (ft n) \<le> length (ft indexa)"
"n \<le> Suc indexa" "n \<le> index"
show "length (ft n) \<le> length (ft (Suc indexa))"
proof(cases "n = Suc indexa",auto)
assume "n \<noteq> Suc indexa"
hence "n \<le> indexa" using AssumpLengthIncreasing(2)
by (metis le_SucE)
hence LengthNA: "length (ft n) \<le> length (ft indexa)"
using AssumpLengthIncreasing(1) by blast
have PrefixIndexA: "prefixList (ft indexa) (ft (Suc indexa))"
using BasicProperties by simp
show "length (ft n) \<le> length (ft (Suc indexa))"
using LengthNA PrefixListMonotonicity[OF PrefixIndexA]
by (metis (hide_lams, no_types) antisym le_cases
less_imp_le less_le_trans)
qed
qed
thus False using AssumptionFairContr MessageIndex
AssumpMsgNotConsumed(1)
by (metis \<open>length (ft index) \<le> n0'\<close> le_SucI le_trans)
qed
hence FirstOccSetDecrImpl:
"\<forall> index \<ge> n . (enabled (last (fe index)) msg)
\<longrightarrow> firstOccSet (Suc index) \<subset> firstOccSet index
\<and> (enabled (last (fe (Suc index))) msg)"
using FirstOccSetDecrOrConsumed by blast
hence FirstOccSetDecrImpl: "\<forall> index \<ge> n . firstOccSet
(Suc index) \<subset> firstOccSet index"
using KeepProperty[of "n" "\<lambda>x.(enabled (last (fe x)) msg)"
"\<lambda>x.(firstOccSet (Suc x) \<subset> firstOccSet x)"]
AssumptionCase1ImplThesis' by blast
hence FirstOccSetDecr': "\<forall> index \<ge> n .
card (firstOccSet (Suc index)) < card (firstOccSet index)"
using FiniteMsgs psubset_card_mono by metis
hence "card (firstOccSet (n + (card (firstOccSet n) + 1)))
\<le> card (firstOccSet n) - (card (firstOccSet n) + 1)"
using SmallerMultipleStepsWithLimit[of "n"
"\<lambda>x. card (firstOccSet x)" "card (firstOccSet n) + 1"]
by blast
hence IsNegative:"card (firstOccSet (n + (card
(firstOccSet n) + 1))) < 0"
by (metis FirstOccSetDecr' diff_add_zero leD le_add1
less_nat_zero_code neq0_conv)
thus False by (metis less_nat_zero_code)
qed
qed
hence Case1ImplThesis: "enabled (last (fe n)) msg
\<Longrightarrow> (\<exists>n'\<ge>n. \<exists>n0'\<ge>n0. n0' < length (ft n') \<and> msg = ft n' ! n0')"
using AssumptionFair(2) execution.length[of trans sends start
"fe n" "ft n"] BasicProperties
by (metis One_nat_def Suc_eq_plus1 Suc_lessI leI le_less_trans
less_asym less_diff_conv)
show "\<exists>n'\<ge>n. \<exists>n0'\<ge>n0. n0' < length (ft n') \<and> msg = ft n' ! n0'"
using disjE[OF EnabledOrConsumedAtLast Case1ImplThesis Case2ImplThesis] .
qed
show ?thesis proof (rule exI[of _ fe], rule exI[of _ ft])
show "fe 0 = [cfg] \<and> fairInfiniteExecution fe ft
\<and> (\<forall>n. nonUniform (last (fe n)) \<and> prefixList (fe n) (fe (n + 1))
\<and> prefixList (ft n) (ft (n + 1))
\<and> execution trans sends start (fe n) (ft n))"
using Fair fe_def FStep BasicProperties by auto
qed
qed
subsection \<open>Contradiction\<close>
text \<open>
An infinite execution is said to be a terminating FLP execution if each process
at some point sends a decision message or if it stops, which is expressed
by the process not processing any further messages.
\<close>
definition (in flpSystem) terminationFLP::
"(nat \<Rightarrow> ('p, 'v, 's) configuration list)
\<Rightarrow> (nat \<Rightarrow> ('p, 'v) message list) \<Rightarrow> bool"
where
"terminationFLP fe ft \<equiv> infiniteExecution fe ft \<longrightarrow>
(\<forall> p . \<exists> n .
(\<exists> i0 < length (ft n). \<exists> b .
(<\<bottom>, outM b> \<in># sends p (states ((fe n) ! i0) p) (unpackMessage ((ft n) ! i0)))
\<and> isReceiverOf p ((ft n) ! i0))
\<or> (\<forall> n1 > n . \<forall> m \<in> set (drop (length (ft n)) (ft n1)) . \<not> isReceiverOf p m))"
have AllArePrefixesExec: "\<forall> m . \<forall> n > m . prefixList (fe m) (fe n)"
proof(clarify)
fix m::nat and n::nat
assume MLessN: "m < n"
have "prefixList (fe m) (fe n)" using MLessN
proof(induct n, simp)
fix n
assume IA: "(m < n) \<Longrightarrow> (prefixList (fe m) (fe n))" "m < (Suc n)"
have "m = n \<or> m < n" using IA(2) by (metis less_SucE)
thus "prefixList (fe m) (fe (Suc n))"
proof(cases "m = n", auto)
show "prefixList (fe n) (fe (Suc n))" using FE by simp
next
assume "m < n"
hence IA2: "prefixList (fe m) (fe n)" using IA(1) by simp
have "prefixList (fe n) (fe (n+1))" using FE by simp
thus "prefixList (fe m) (fe (Suc n))" using PrefixListTransitive
IA2 by simp
qed
qed
thus "prefixList (fe m) (fe n)" by simp
qed
have AllArePrefixesTrace: "\<forall> m . \<forall> n > m . prefixList (ft m) (ft n)"
proof(clarify)
fix m::nat and n::nat
assume MLessN: "m < n"
have "prefixList (ft m) (ft n)" using MLessN
proof(induct n, simp)
fix n
assume IA: "(m < n) \<Longrightarrow> (prefixList (ft m) (ft n))" "m < (Suc n)"
have "m = n \<or> m < n" using IA(2) by (metis less_SucE)
thus "prefixList (ft m) (ft (Suc n))"
proof(cases "m = n", auto)
show "prefixList (ft n) (ft (Suc n))" using FE by simp
next
assume "m < n"
hence IA2: "prefixList (ft m) (ft n)" using IA(1) by simp
have "prefixList (ft n) (ft (n+1))" using FE by simp
thus "prefixList (ft m) (ft (Suc n))" using PrefixListTransitive
IA2 by simp
qed
qed
thus "prefixList (ft m) (ft n)" by simp
qed
have Length: "\<forall> n . length (fe n) \<ge> n + 1"
proof(clarify)
fix n
show "length (fe n) \<ge> n + 1"
proof(induct n, simp add: FE(1))
fix n
assume IH: "(n + (1::nat)) \<le> (length (fe n))"
have "length (fe (n+1)) \<ge> length (fe n) + 1" using FE(3)
PrefixListMonotonicity
by (metis Suc_eq_plus1 Suc_le_eq)
thus "(Suc n) + (1::nat) \<le> (length (fe (Suc n)))" using IH by auto
qed
qed
have AllExecsFromInit: "\<forall> n . \<forall> n0 < length (fe n) .
reachable cfg ((fe n) ! n0)"
proof(clarify)
fix n::nat and n0::nat
assume "n0 < length (fe n)"
thus "reachable cfg ((fe n) ! n0)"
proof(cases "0 = n", auto)
assume N0Less: "n0 < length (fe 0)"
have NoStep: "reachable cfg cfg" using reachable.simps by blast
have "length (fe 0) = 1" using FE(1) by simp
hence N0Zero: "n0 = 0" using N0Less FE by simp
hence "(fe 0) ! n0 = cfg" using FE(1) by simp
thus "reachable cfg ((fe 0) ! n0)" using FE(1) NoStep N0Zero by simp
next
assume NNotZero: "0 < n" "n0 < (length (fe n))"
have ZeroCfg: "(fe 0) = [cfg]" using FE by simp
have "prefixList (fe 0) (fe n)" using AllArePrefixesExec NNotZero
by simp
hence PrList: "prefixList [cfg] (fe n)" using ZeroCfg by simp
have CfgFirst: "cfg = (fe n) ! 0"
using prefixList.cases[OF PrList]
by (metis (full_types) ZeroCfg list.distinct(1) nth_Cons_0)
have "reachable ((fe n) ! 0) ((fe n) ! n0)"
using execution.ReachableInExecution FE NNotZero(2) by (metis le0)
thus "(reachable cfg ((fe n) ! n0))" using assms CfgFirst by simp
qed
qed
have NoDecided: "(\<forall> n n0 v . (n0 < length (fe n))
\<longrightarrow> \<not> vDecided v ((fe n) ! n0))"
proof(clarify)
fix n n0 v
assume AssmNoDecided: "n0 < length (fe n)"
"initReachable ((fe n) ! n0)"
"0 < (msgs ((fe n) ! n0) <\<bottom>, outM v>)"
have LastNonUniform: "nonUniform (last (fe n))" using FE by simp
have LastIsLastIndex: "\<And> l . l \<noteq> [] \<longrightarrow> last l = l ! ((length l) - 1)"
by (metis last_conv_nth)
have Fou: "n0 \<le> length (fe n) - 1" using AssmNoDecided by simp
have FeNNotEmpty:"fe n \<noteq> []" using FE(1) AllArePrefixesExec
by (metis AssmNoDecided(1) less_nat_zero_code list.size(3))
hence Fou2: "length (fe n) - 1 < length (fe n)" by simp
have "last (fe n) = (fe n) ! (length (fe n) - 1)"
using LastIsLastIndex FeNNotEmpty by auto
have LastNonUniform: "nonUniform (last (fe n))" using FE by simp
have "reachable ((fe n) ! n0) ((fe n) ! (length (fe n) - 1))"
using FE execution.ReachableInExecution Fou Fou2 by metis
hence N0ToLast: "reachable ((fe n) ! n0) (last (fe n))"
using LastIsLastIndex[of "fe n"] FeNNotEmpty by simp
hence LastVDecided: "vDecided v (last (fe n))"
using NoOutMessageLoss[of "((fe n) ! n0)" "(last (fe n))"]
AssmNoDecided
by (simp,
metis LastNonUniform le_neq_implies_less less_nat_zero_code neq0_conv)
have AllAgree: "\<forall> cfg' . reachable (last (fe n)) cfg'
\<longrightarrow> agreement cfg'"
proof(clarify)
fix cfg'
assume LastToNext: "reachable (last (fe n)) cfg'"
hence "reachable cfg ((fe n) ! (length (fe n) - 1))"
using AllExecsFromInit AssmNoDecided(1) by auto
hence "reachable cfg (last (fe n))" using LastIsLastIndex[of "fe n"]
FeNNotEmpty by simp
hence FirstToLast: "reachable cfg cfg'" using initReachable_def Cfg
LastToNext ReachableTrans by blast
hence "agreementInit cfg cfg'" using Agreement by simp
hence "\<forall>v1. (<\<bottom>, outM v1> \<in># msgs cfg') \<longrightarrow> (\<forall>v2. (<\<bottom>, outM v2> \<in>#
msgs cfg') \<longleftrightarrow> v2 = v1)"
using Cfg FirstToLast
by (simp add: agreementInit_def)
thus "agreement cfg'" by (simp add: agreement_def)
qed
thus "False" using NonUniformImpliesNotDecided LastNonUniform
PseudoTermination LastVDecided by simp
qed
have Termination: "terminationFLP fe ft" using assms(1)[OF FE(2)] .
hence AllDecideOrCrash:
"\<forall>p. \<exists>n .
(\<exists> i0 < length (ft n) . \<exists>b.
(<\<bottom>, outM b> \<in>#
sends p (states (fe n ! i0) p) (unpackMessage (ft n ! i0)))
\<and> isReceiverOf p (ft n ! i0))
\<or> (\<forall> n1 > n . \<forall> m \<in> (set (drop (length (ft n)) (ft n1))) .
\<not> isReceiverOf p m)"
using FE(2)
unfolding terminationFLP_def fairInfiniteExecution_def
by blast
have "\<forall> p . \<exists> n . (\<forall> n1 > n . \<forall> m \<in> (set (drop (length (ft n)) (ft n1))) .
\<not> isReceiverOf p m)"
proof(clarify)
fix p
from AllDecideOrCrash have
"\<exists> n .
(\<exists> i0 < length (ft n) . \<exists>b.
(<\<bottom>, outM b> \<in># sends p (states (fe n ! i0) p) (unpackMessage (ft n ! i0)))
\<and> isReceiverOf p (ft n ! i0))
\<or> (\<forall> n1 > n . \<forall> m \<in> (set (drop (length (ft n)) (ft n1))).
\<not> isReceiverOf p m)" by simp
hence "(\<exists> n . \<exists> i0 < length (ft n) .
(\<exists>b. (<\<bottom>, outM b> \<in>#
sends p (states (fe n ! i0) p) (unpackMessage (ft n ! i0)))
\<and> isReceiverOf p (ft n ! i0)))
\<or> (\<exists> n .\<forall> n1 > n . \<forall> m \<in> (set (drop (length (ft n)) (ft n1))) .
\<not> isReceiverOf p m)" by blast
thus "\<exists>n. (\<forall>n1>n. (\<forall> m \<in> (set (drop (length (ft n)) (ft n1))).
(\<not> (isReceiverOf p m))))"
proof(elim disjE, auto)
fix n i0 b
assume DecidingPoint:
"i0 < length (ft n)"
"isReceiverOf p (ft n ! i0)"
"<\<bottom>, outM b> \<in># sends p (states (fe n ! i0) p) (unpackMessage (ft n ! i0))"
have "i0 < length (fe n) - 1"
using DecidingPoint(1)
by (metis (no_types) FE(3) execution.length)
hence StepN0: "((fe n) ! i0) \<turnstile> ((ft n) ! i0) \<mapsto> ((fe n) ! (i0 + 1))"
using FE by (metis execution.step)
hence "msgs ((fe n) ! (i0 + 1)) <\<bottom>, outM b>
= (msgs ((fe n) ! i0) <\<bottom>, outM b>) +
(sends p (states ((fe n) ! i0) p)
(unpackMessage ((ft n) ! i0)) <\<bottom>, outM b>)"
using DecidingPoint(2) OutOnlyGrowing[of "(fe n) ! i0" "(ft n) ! i0"
"(fe n) ! (i0 + 1)" "p"]
by auto
hence "(sends p (states ((fe n) ! i0) p)
(unpackMessage ((ft n) ! i0)) <\<bottom>, outM b>)
\<le> msgs ((fe n) ! (i0 + 1)) <\<bottom>, outM b>"
using asynchronousSystem.steps_def by auto
hence OutMsgEx: "0 < msgs ((fe n) ! (i0 + 1)) <\<bottom>, outM b>"
using asynchronousSystem.steps_def DecidingPoint(3) by auto
have "(i0 + 1) < length (fe n)"
using DecidingPoint(1) \<open>i0 < length (fe n) - 1\<close> by auto
hence "initReachable ((fe n) ! (i0 + 1))"
using AllExecsFromInit Cfg(1)
by (metis asynchronousSystem.initReachable_def)
hence Decided: "vDecided b ((fe n) ! (i0 + 1))" using OutMsgEx
by auto
have "i0 + 1 < length (fe n)" using DecidingPoint(1)
by (metis \<open>(((i0::nat) + (1::nat)) < (length (
(fe::(nat \<Rightarrow> ('p, 'v, 's) configuration list)) (n::nat))))\<close>)
hence "\<not> vDecided b ((fe n) ! (i0 + 1))" using NoDecided by auto
hence "False" using Decided by auto
thus "\<exists>n. (\<forall>n1>n. (\<forall> m \<in> (set (drop (length (ft n)) (ft n1))).
(\<not> (isReceiverOf p m))))" by simp
qed
qed
hence "\<exists> (crashPoint::'p \<Rightarrow> nat) .
\<forall> p . \<exists> n . crashPoint p = n \<and> (\<forall> n1 > n . \<forall> m \<in> (set (drop
(length (ft n)) (ft n1))) . (\<not> isReceiverOf p m))" by metis
then obtain crashPoint where CrashPoint:
"\<forall> p . (\<forall> n1 > (crashPoint p) . \<forall> m \<in> (set (drop (length
(ft (crashPoint p))) (ft n1))) . (\<not> isReceiverOf p m))"
by blast
define limitSet where "limitSet = {crashPoint p | p . p \<in> Proc}"
have "finite {p. p \<in> Proc}" using finiteProcs by simp
hence "finite limitSet" using limitSet_def finite_image_set[] by blast
hence "\<exists> limit . \<forall> l \<in> limitSet . l < limit" using
finite_nat_set_iff_bounded by auto
hence "\<exists> limit . \<forall> p . (crashPoint p) < limit" using limitSet_def by auto
then obtain limit where Limit: "\<forall> p . (crashPoint p) < limit" by blast
define lengthLimit where "lengthLimit = length (ft limit) - 1"
define lateMessage where "lateMessage = last (ft limit)"
hence "lateMessage = (ft limit) ! (length (ft limit) - 1)"
by (metis AllArePrefixesTrace Limit last_conv_nth less_nat_zero_code
list.size(3) PrefixListMonotonicity)
hence LateIsLast: "lateMessage = (ft limit) ! lengthLimit"
using lateMessage_def lengthLimit_def by auto
have "\<exists> p . isReceiverOf p lateMessage"
proof(rule ccontr)
assume "\<not> (\<exists>(p::'p). (isReceiverOf p lateMessage))"
hence IsOutMsg: "\<exists> v . lateMessage = <\<bottom>, outM v>"
by (metis isReceiverOf.simps(1) isReceiverOf.simps(2) message.exhaust)
have "execution trans sends start (fe limit) (ft limit)" using FE
by auto
hence "length (fe limit) - 1 = length (ft limit)"
using execution.length by simp
hence "lengthLimit < length (fe limit) - 1"
using lengthLimit_def
by (metis (hide_lams, no_types) Length Limit One_nat_def Suc_eq_plus1
Suc_le_eq diff_less
diffs0_imp_equal gr_implies_not0 less_Suc0 neq0_conv)
hence "((fe limit) ! lengthLimit) \<turnstile> ((ft limit) ! lengthLimit)
\<mapsto> ((fe limit) ! (lengthLimit + 1))"
using FE by (metis execution.step)
hence "((fe limit) ! lengthLimit) \<turnstile> lateMessage \<mapsto> ((fe limit) !
(lengthLimit + 1))"
using LateIsLast by auto
thus False using IsOutMsg steps_def by auto
qed
then obtain p where ReceiverOfLate: "isReceiverOf p lateMessage" by blast
have "\<forall> n1 > (crashPoint p) .
\<forall> m \<in> (set (drop (length (ft (crashPoint p))) (ft n1))) .
(\<not> isReceiverOf p m)"
using CrashPoint
by simp
hence NoMsgAfterLimit: "\<forall> m \<in> (set (drop (length (ft (crashPoint p)))
(ft limit))) . (\<not> isReceiverOf p m)"
using Limit
by auto
have "lateMessage \<in> set (drop (length(ft (crashPoint p))) (ft limit))"
proof-
have "crashPoint p < limit" using Limit by simp
hence "prefixList (ft (crashPoint p)) (ft limit)"
using AllArePrefixesTrace by auto
hence CrashShorterLimit: "length (ft (crashPoint p))
< length (ft limit)" using PrefixListMonotonicity by auto
hence "last (drop (length (ft (crashPoint p))) (ft limit))
= last (ft limit)" by (metis last_drop)
hence "lateMessage = last (drop (length (ft (crashPoint p)))
(ft limit))" using lateMessage_def by auto
thus "lateMessage \<in> set (drop (length(ft (crashPoint p))) (ft limit))"
by (metis CrashShorterLimit drop_eq_Nil last_in_set not_le)
qed
hence "\<not> isReceiverOf p lateMessage" using NoMsgAfterLimit by auto
thus "False" using ReceiverOfLate by simp
qed
end
end
|
//
// CI Hello World
//
// Copyright (C) 2017 Assured Information Security, Inc.
// Author: Rian Quinn <[email protected]>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef CONSUMER_H
#define CONSUMER_H
#include <gsl/gsl>
#include <producer.h>
/// Consumer
///
/// A simple example of a consumer that is capable of accepting the real
/// producer, or a mocked version for unit testing.
///
class consumer
{
public:
/// Default Constructor
///
/// @param p the producer that this consumer will use.
///
explicit consumer(gsl::not_null<producer *> p)
{ p->print_msg(); }
/// Default Destructor
///
~consumer() = default;
public:
// We define the copy and move constructors / operators because Clang Tidy
// (legitimately) complains about the definition of a destructor without
// defining the copy and move semantics for this class. In general a class
// should always be marked non-copyable unless such functionality is
// specifically desired.
consumer(consumer &&) noexcept = default; ///< Default move construction
consumer &operator=(consumer &&) noexcept = default; ///< Default move operator
consumer(const consumer &) = delete; ///< Deleted copy construction
consumer &operator=(const consumer &) = delete; ///< Deleted copy operator
};
#endif |
State Before: α : Type u
e : Encoding α
⊢ Function.Injective e.encode State After: α : Type u
e : Encoding α
x✝¹ x✝ : α
h : encode e x✝¹ = encode e x✝
⊢ some x✝¹ = some x✝ Tactic: refine' fun _ _ h => Option.some_injective _ _ State Before: α : Type u
e : Encoding α
x✝¹ x✝ : α
h : encode e x✝¹ = encode e x✝
⊢ some x✝¹ = some x✝ State After: no goals Tactic: rw [← e.decode_encode, ← e.decode_encode, h] |
(* Copyright 2012-2015 by Adam Petcher. *
* Use of this source code is governed by the license described *
* in the LICENSE file at the root of the source tree. *)
Set Implicit Arguments.
Require Import fcf.FCF.
Require Import fcf.CompFold.
Require Import fcf.RndListElem.
Require Import Permutation.
Local Open Scope list_scope.
Theorem removeFirst_In_length :
forall (A : Set)(eqd : EqDec A)(ls : list A)(a : A),
In a ls ->
length (removeFirst (EqDec_dec _ ) ls a) = pred (length ls).
induction ls; intuition; simpl in *.
intuition; subst.
destruct (EqDec_dec eqd a0 a0); intuition.
destruct (EqDec_dec eqd a0 a); subst.
trivial.
simpl.
rewrite IHls.
destruct ls; simpl in *; intuition.
trivial.
Qed.
Fixpoint addInAllLocations(A : Type)(a : A)(ls : list A) :=
match ls with
| nil => (a :: nil) :: nil
| a' :: ls' =>
(a :: ls) :: map (fun x => a' :: x) (addInAllLocations a ls')
end.
Fixpoint getAllPermutations(A : Type)(ls : list A) :=
match ls with
| nil => nil :: nil
| a :: ls' =>
let perms' := getAllPermutations ls' in
flatten (map (addInAllLocations a) perms')
end.
Theorem addInAllLocations_not_nil :
forall (A : Type) l (a : A),
addInAllLocations a l = nil -> False.
induction l; intuition; unfold addInAllLocations in *; simpl in *.
inversion H.
inversion H.
Qed.
Theorem getAllPermutations_not_nil :
forall (A : Type)(ls : list A),
getAllPermutations ls = nil -> False.
induction ls; intuition; simpl in *.
inversion H.
case_eq (getAllPermutations ls); intuition.
rewrite H0 in H.
simpl in *.
apply app_eq_nil in H.
intuition.
eapply addInAllLocations_not_nil; eauto.
Qed.
Theorem addInAllLocations_perm :
forall (A : Type) x0 (a : A) ls2,
In ls2 (addInAllLocations a x0) ->
Permutation ls2 (a :: x0).
induction x0; intuition; simpl in *.
intuition; subst.
eapply Permutation_refl.
intuition; subst.
eapply Permutation_refl.
eapply in_map_iff in H0.
destruct H0.
intuition; subst.
eapply perm_trans.
Focus 2.
eapply perm_swap.
eapply perm_skip.
eapply IHx0.
trivial.
Qed.
Theorem getAllPermutations_perms :
forall (A : Set)(ls1 ls2 : list A),
In ls2 (getAllPermutations ls1) ->
Permutation ls1 ls2.
induction ls1; intuition; simpl in *.
intuition.
subst.
econstructor.
eapply in_flatten in H.
destruct H.
intuition.
eapply in_map_iff in H0.
destruct H0.
intuition.
subst.
eapply addInAllLocations_perm in H1.
eapply perm_trans.
Focus 2.
eapply Permutation_sym.
eauto.
eapply perm_skip.
eapply IHls1.
trivial.
Qed.
Section ShuffleList.
Variable A : Set.
Hypothesis A_EqDec : EqDec A.
Definition shuffle(ls : list A) :=
o <-$ rndListElem _ (getAllPermutations ls);
ret
match o with
| None => nil
| Some x => x
end.
Theorem shuffle_perm :
forall (ls1 ls2 : list A),
In ls2 (getSupport (shuffle ls1)) ->
Permutation ls2 ls1.
intuition.
unfold shuffle in *.
repeat simp_in_support.
destruct x.
eapply Permutation_sym.
eapply getAllPermutations_perms.
apply rndListElem_support in H0.
trivial.
apply rndListElem_support_None in H0.
exfalso.
eapply getAllPermutations_not_nil.
eauto.
Qed.
Fixpoint permute(ls : list A)(sigma : list nat) : list A :=
match sigma with
| nil => nil
| n :: sigma' =>
match (nth_error ls n) with
| None => nil
| Some a => a :: (permute ls sigma')
end
end.
Theorem permute_length_eq :
forall (sigma : list nat)(ls : list A),
(forall n, In n sigma -> n < length ls) ->
length (permute ls sigma) = length sigma.
induction sigma; intuition; simpl in *.
case_eq (nth_error ls a); intuition.
simpl.
f_equal.
eapply IHsigma; intuition.
Theorem nth_error_not_None :
forall (ls : list A)(n : nat),
n < length ls ->
nth_error ls n = None ->
False.
induction ls; destruct n; intuition; simpl in *.
omega.
omega.
inversion H0.
eapply IHls; eauto.
omega.
Qed.
exfalso.
eapply nth_error_not_None.
eapply H.
intuition.
trivial.
Qed.
Theorem shuffle_Permutation :
forall (ls1 ls2 : list A),
In ls2 (getSupport (shuffle ls1)) ->
Permutation ls1 ls2.
intuition.
unfold shuffle in *.
repeat simp_in_support.
destruct x.
eapply rndListElem_support in H0.
eapply getAllPermutations_perms.
trivial.
eapply rndListElem_support_None in H0.
exfalso.
eapply getAllPermutations_not_nil.
eauto.
Qed.
Theorem shuffle_wf :
forall ls,
well_formed_comp (shuffle ls).
intuition.
unfold shuffle.
wftac.
eapply rndListElem_wf.
Qed.
End ShuffleList.
Definition RndPerm(n : nat) :=
shuffle _ (allNatsLt n).
Theorem list_pred_map_both':
forall (A B C D : Set) (lsa : list A) (lsb : list B)
(P : C -> D -> Prop) (f : A -> C)(g : B -> D),
list_pred (fun (a : A) (b : B) => P (f a) (g b)) lsa lsb ->
list_pred P (map f lsa) (map g lsb).
intuition.
eapply list_pred_impl.
eapply list_pred_map_both.
eauto.
intuition.
destruct H0.
destruct H0.
intuition; subst.
trivial.
Qed.
Theorem addInAllLocations_pred :
forall (A B : Set) (R : A -> B -> Prop) (a : list A) (b : list B),
list_pred R a b ->
forall a1 a2,
R a1 a2 ->
list_pred (list_pred R) (addInAllLocations a1 a) (addInAllLocations a2 b).
induction 1; intuition; simpl in *.
econstructor.
econstructor.
trivial.
econstructor.
econstructor.
econstructor.
repeat econstructor;assumption.
eapply list_pred_map_both'.
eapply list_pred_impl.
eauto.
intuition.
econstructor; assumption.
Qed.
Theorem getAllPermutations_pred :
forall (A B : Set)(R : A -> B -> Prop)(lsa : list A)(lsb : list B),
list_pred R lsa lsb ->
list_pred (list_pred R) (getAllPermutations lsa) (getAllPermutations lsb).
induction 1; intuition; simpl in *.
econstructor.
econstructor.
econstructor.
eapply list_pred_flatten_both.
eapply list_pred_map_both'.
eapply list_pred_impl.
eauto.
intuition.
eapply addInAllLocations_pred; intuition.
Qed.
Theorem allNats_nth_pred :
forall (A : Set)(ls : list A),
list_pred (fun (a : A) (b : nat) => nth_error ls b = Some a) ls
(allNatsLt (length ls)).
induction ls using rev_ind; intuition; simpl in *.
econstructor.
rewrite app_length.
simpl.
rewrite plus_comm.
simpl.
eapply list_pred_app_both.
eapply list_pred_impl.
eapply IHls.
intuition.
Theorem nth_error_app_Some :
forall (A : Set)(ls : list A) n (a a' : A),
nth_error ls n = Some a ->
nth_error (ls ++ (a' :: nil)) n = Some a.
induction ls; destruct n; intuition; simpl in *.
inversion H.
inversion H.
eapply IHls.
trivial.
Qed.
eapply nth_error_app_Some; intuition.
econstructor.
Theorem nth_error_app_length :
forall (A : Set)(ls : list A) (a : A),
nth_error (ls ++ (a :: nil)) (length ls) = Some a.
induction ls; intuition; simpl in *.
Qed.
eapply nth_error_app_length .
econstructor.
Qed.
Theorem permute_nth_equiv :
forall (A : Set)(ls : list A) a b,
list_pred (fun (a0 : A) (b0 : nat) => nth_error ls b0 = Some a0) a b ->
a = permute ls b.
induction a; inversion 1; intuition; simpl in *.
subst.
rewrite H2.
f_equal.
eapply IHa.
trivial.
Qed.
Theorem getAllPerms_permute_eq :
forall (A : Set)(ls : list A),
list_pred (fun (a : list A) (b : list nat) => a = permute ls b)
(getAllPermutations ls) (getAllPermutations (allNatsLt (length ls))).
intuition.
generalize (@getAllPermutations_pred _ _ (fun a b => nth_error ls b = Some a) ls (allNatsLt (length ls))) ; intros.
eapply list_pred_impl.
eapply H.
eapply allNats_nth_pred.
intuition.
eapply permute_nth_equiv.
trivial.
Qed.
Theorem rndListElem_pred :
forall (A B : Set)(eqda : EqDec A)(eqdb : EqDec B)(P : A -> B -> Prop)(lsa : list A)(lsb : list B),
list_pred P lsa lsb ->
comp_spec (fun a b =>
match a with
| None => b = None
| Some a' => exists b', b = Some b' /\ P a' b'
end) (rndListElem _ lsa) (rndListElem _ lsb).
intuition.
unfold rndListElem in *.
case_eq (length lsa); intuition.
erewrite <- list_pred_length_eq; eauto.
rewrite H0.
eapply comp_spec_ret; intuition.
erewrite <- list_pred_length_eq; eauto.
rewrite H0.
comp_skip.
apply None.
apply None.
eapply comp_spec_ret; intuition.
case_eq (nth_option lsa b); intuition.
Theorem list_pred_nth_exists :
forall (A B : Set)(P : A -> B -> Prop) lsa lsb,
list_pred P lsa lsb ->
forall n a,
nth_option lsa n = Some a -> exists b, nth_option lsb n = Some b /\ P a b.
induction 1; intuition; simpl in *.
discriminate.
destruct n.
inversion H1; clear H1; subst.
econstructor; intuition.
edestruct IHlist_pred; eauto.
Qed.
edestruct list_pred_nth_exists; eauto.
exfalso.
eapply nth_option_not_None; eauto.
apply RndNat_support_lt in H1.
omega.
Qed.
Theorem shuffle_RndPerm_spec :
forall (A : Set)(eqd : EqDec A)(ls : list A),
comp_spec (fun a b => a = permute ls b)
(shuffle eqd ls)
(shuffle _ (allNatsLt (length ls))).
intuition.
unfold shuffle in *.
comp_skip.
eapply rndListElem_pred.
eapply getAllPerms_permute_eq.
simpl in H1.
eapply comp_spec_ret; intuition.
destruct a.
destruct H1.
intuition.
subst.
trivial.
subst.
simpl.
intuition.
Qed.
Theorem shuffle_RndPerm_spec_eq :
forall (A : Set)(eqd : EqDec A)(ls : list A),
comp_spec eq
(shuffle eqd ls)
(x <-$ RndPerm (length ls); ret permute ls x).
intuition.
eapply comp_spec_eq_trans.
eapply comp_spec_eq_symm.
eapply comp_spec_right_ident.
comp_skip.
eapply shuffle_RndPerm_spec.
eapply comp_spec_ret; intuition.
Qed.
Theorem RndPerm_In_support :
forall n ls,
In ls (getSupport (RndPerm n)) ->
Permutation (allNatsLt n) ls.
intuition.
eapply shuffle_Permutation.
eapply H.
Qed.
Theorem RndPerm_In_support_length :
forall n ls,
In ls (getSupport (RndPerm n)) ->
length ls = n.
intuition.
erewrite Permutation_length.
Focus 2.
eapply Permutation_sym.
eapply RndPerm_In_support.
eauto.
eapply allNatsLt_length.
Qed.
Theorem RndPerm_wf :
forall n,
well_formed_comp (RndPerm n).
intuition.
unfold RndPerm.
eapply shuffle_wf.
Qed. |
lemma emeasure_lborel_Ioc[simp]: assumes [simp]: "l \<le> u" shows "emeasure lborel {l <.. u} = ennreal (u - l)" |
The global economy is on a growth streak that is shaping up to be the broadest and strongest expansion in more than three decades.
Rising spending and investment by consumers and businesses worldwide are boosting national economies on every continent, pushing down unemployment rates in many countries and lifting business earnings and confidence.
Of 60 nations tracked by investment firm Bridgewater Associates, not one is in recession — the first time that has been true since 1969.
Yet this is a different kind of boom from any other in the post-World War II era, analysts say. The soaring economies of China, India, Russia, Brazil and other emerging nations increasingly are setting the pace, overshadowing the slower growth of the United States, Europe and Japan, where the benefits of the expansion have eluded many workers.
"This is the first recovery where developing economies are playing a dominant role," said James Paulsen, chief strategist at Wells Capital Management in Minneapolis, which manages money for big investors such as pension funds.
The trend is being driven by free trade, which has created millions of jobs in emerging nations in recent years, fueling stunning new wealth in those countries.
This is a story not only at odds with the facts--strong US GDP growth and low unemployment--but with itself--the jobs in those developing countries consist of doing the manufacturing and other work [answering phones] we're too wealthy to do ourselves. It does though demonstrate just how powerful the End of History remains -- forcing capitalism upon such a wide array of nations -- even at a time when folks want to dismiss it.
America and China have been serving as twin engines of the global economy, helping to fuel worldwide growth of 4 percent or higher for several years straight.
Our late editor Bob Bartley used to say that critics might forgive you for being wrong, but they'll never forgive you for being right. That psychological insight may be the only way to explain the fierce and bitter opposition this week to extending the tax cuts of 2003 for another two years through 2010.
If ever there was a market test of economic policy, the last three years have been it. The stock market has recovered from its implosion in Bill Clinton's last year in office, unemployment is down to 4.7%, and growth has averaged 3.9% in the three years since those tax cuts passed--well above the post-World War II average and more than twice the growth rate in Euroland.
Realistically, the United States should be counted with the emerging economies, not the European.
"The soaring economies of China, India, Russia, Brazil and other emerging nations increasingly are setting the pace, overshadowing the slower growth of the United States, Europe and Japan..."
And with the utterly inane comparison of the "slow growth" of the US with Europe & Japan, it is officially OK to stop reading, as the writer has proven he doesn't know a thing about economics. |
program prog2
use m2
use m4
implicit none
call proc2
call proc4
end program
|
Formal statement is: lemma sgn_zero [simp]: "sgn (0::'a::real_normed_vector) = 0" Informal statement is: The sign of zero is zero. |
Compounds in this class generally are described as derivatives of Sb3 − . Antimony forms antimonides with metals , such as indium antimonide ( <unk> ) and silver antimonide ( Ag
|
import AssertCmd
import Contractome.Utils
-- @[irreducible] def UInt256.size : Nat := 115792089237316195423570985008687907853269984665640564039457584007913129639936
@[irreducible] def UInt256.size : Nat := 2^256
-- attribute [irreducible] UInt32.size
structure UInt256 where
val : Fin UInt256.size
def UInt256.ofNatCore (n : @& Nat) (h : LT.lt n UInt256.size) : UInt256 := {
val := { val := n, isLt := h }
}
def UInt256.toNat (n : UInt256) : Nat := n.val.val
instance : Repr UInt256 where
reprPrec n _ := repr n.toNat
def UInt256.decEq (a b : UInt256) : Decidable (Eq a b) :=
match a, b with
| ⟨n⟩, ⟨m⟩ =>
dite (Eq n m) (fun h => isTrue (h ▸ rfl)) (fun h => isFalse (fun h' => UInt256.noConfusion h' (fun h' => absurd h' h)))
instance : DecidableEq UInt256 := UInt256.decEq
set_option maxRecDepth 2000
instance : Inhabited UInt256 where
default := UInt256.ofNatCore 0 (by decide)
instance : LT UInt256 where
lt a b := LT.lt a.val b.val
instance : LE UInt256 where
le a b := LE.le a.val b.val
def UInt256.decLt (a b : UInt256) : Decidable (LT.lt a b) :=
match a, b with
| ⟨n⟩, ⟨m⟩ => inferInstanceAs (Decidable (LT.lt n m))
def UInt256.decLe (a b : UInt256) : Decidable (LE.le a b) :=
match a, b with
| ⟨n⟩, ⟨m⟩ => inferInstanceAs (Decidable (LE.le n m))
instance (a b : UInt256) : Decidable (LT.lt a b) := UInt256.decLt a b
instance (a b : UInt256) : Decidable (LE.le a b) := UInt256.decLe a b
instance : Ord UInt256 where
compare x y := compareOfLessAndEq x y
#check UInt32.ofNat
@[irreducible] theorem ofNat_lt (x: Nat) : x % UInt256.size < UInt256.size := by
simp [Nat.mod_lt, Nat.zero_lt_succ]
-- attribute [irreducible] Fin.mlt
-- def UInt256.ofNat (n : @& Nat) : UInt256 := ⟨Fin.ofNat n⟩
def UInt256.ofNat (n : @& Nat) : UInt256 := ⟨⟨n % UInt256.size , ofNat_lt n⟩⟩
def UInt256.ofNat' (n : Nat) (h : n < UInt256.size) : UInt256 := ⟨⟨n, h⟩⟩
def UInt256.ofUInt8 (n : UInt8) : UInt256 := ⟨⟨ n.val, by apply (Nat.lt_trans n.val.isLt); decide ⟩⟩
abbrev Nat.toUInt256 := UInt256.ofNat
@[inline] abbrev wrapOp (f : Nat -> Nat -> Nat) :=
fun (a b : UInt256) => UInt256.mk ⟨ (f a.val.val b.val.val) % UInt256.size, ofNat_lt (f a.val.val b.val.val) ⟩
def UInt256.add := wrapOp Nat.add
def UInt256.sub (a b : UInt256) : UInt256 := ⟨⟨ (a.val.val + (UInt256.size - b.val.val)) % UInt256.size , ofNat_lt _⟩⟩
def UInt256.mul := wrapOp Nat.mul
def UInt256.div := wrapOp Nat.div
def UInt256.mod := wrapOp Nat.mod
set_option maxRecDepth 2000
def UInt256.ones : UInt256 := ⟨⟨ (2^256) - 1, by decide ⟩⟩
def UInt256.modn (a : UInt256) (n : @& Nat) : UInt256 := ⟨⟨ (a.val.val % n) % UInt256.size, ofNat_lt _ ⟩⟩
def UInt256.land := wrapOp Nat.land
def UInt256.lor := wrapOp Nat.lor
def UInt256.xor := wrapOp Nat.xor
def UInt256.shiftLeft (a b : UInt256) : UInt256 := ⟨⟨ (a.val.val <<< (modn b 256).val.val) % UInt256.size, ofNat_lt _ ⟩⟩
def UInt256.shiftRight (a b : UInt256) : UInt256 := ⟨⟨ (a.val.val >>> (modn b 256).val.val) % UInt256.size, ofNat_lt _ ⟩⟩
def UInt256.toUInt8 (a : UInt256) : UInt8 := a.toNat.toUInt8
def UInt256.toUInt16 (a : UInt256) : UInt16 := a.toNat.toUInt16
def UInt8.toUInt256 (a : UInt8) : UInt256 := a.toNat.toUInt256
def UInt16.toUInt256 (a : UInt16) : UInt256 := a.toNat.toUInt256
def UInt32.toUInt256 (a : UInt32) : UInt256 := a.toNat.toUInt256
def UInt64.toUInt256 (a : UInt64) : UInt256 := a.toNat.toUInt256
instance : OfNat UInt256 n := ⟨UInt256.ofNat n⟩
instance : Add UInt256 := ⟨UInt256.add⟩
instance : Sub UInt256 := ⟨UInt256.sub⟩
instance : Mul UInt256 := ⟨UInt256.mul⟩
instance : Mod UInt256 := ⟨UInt256.mod⟩
instance : HMod UInt256 Nat UInt256 := ⟨UInt256.modn⟩
instance : Div UInt256 := ⟨UInt256.div⟩
-- def UInt256.bneg (a : UInt256) : UInt256 := a.xor UInt256.ones
def UInt256.complement (a:UInt256) : UInt256 := 0-(a+1)
def UInt256.sneg (a: UInt256) : UInt256 := a.complement + 1
#assert (UInt256.sneg 3) == (0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD : UInt256)
#assert (UInt256.sneg 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD) == (3 : UInt256)
instance : Complement UInt256 := ⟨UInt256.complement⟩
instance : AndOp UInt256 := ⟨UInt256.land⟩
instance : OrOp UInt256 := ⟨UInt256.lor⟩
instance : Xor UInt256 := ⟨UInt256.xor⟩
instance : ShiftLeft UInt256 := ⟨UInt256.shiftLeft⟩
instance : ShiftRight UInt256 := ⟨UInt256.shiftRight⟩
def UInt256.abs (a : UInt256) : UInt256 :=
if a >>> 255 == 1 then a.sneg else a
def UInt256.sdiv (a b:UInt256) : UInt256 :=
let a' := a.abs
let b' := b.abs
let r := a' / b'
let bit : UInt256 := (a ^^^ b) >>> 255
if bit == 1 then r.sneg else r
def UInt256.smod (a b:UInt256) : UInt256 :=
let a' := a.abs
let b' := b.abs
let r := a' % b'
let bit : UInt256 := a >>> 255
if bit == 1 then r.sneg else r
@[simp]
def Nat.half_is_less (n : Nat) : (Nat.succ n) / 2 < (Nat.succ n) := sorry
--
-- set_option pp.all true
def Nat.powmod_correct (a b N: Nat) : { r : Nat // r = (a.pow b) % N } := match b with
| 0 => by cases N with | zero => exact ⟨ 1, by simp [Nat.pow, Nat.mod_zero] ⟩
| succ N => cases N with
| zero => exact ⟨ 0, by simp [Nat.pow]⟩
| succ N => exact ⟨ 1, by simp [Nat.pow]; rw [Nat.mod_eq_of_lt (_ : 1 < Nat.succ (Nat.succ N))]; apply Nat.succ_le_succ; apply Nat.succ_le_succ; apply Nat.zero_le ⟩
| Nat.succ b =>
if (Nat.succ b) % 2 == 0 then ⟨ powmod_correct ((a * a) % N) ((Nat.succ b) / 2) N , sorry ⟩
else ⟨ (a * powmod_correct ((a * a) % N) ((Nat.succ b) / 2) N) % N , sorry ⟩
termination_by _ => b
decreasing_by apply Nat.half_is_less
#assert ((123 ^ 123) % 8) == (Nat.powmod_correct 123 123 8).val
#assert (Nat.powmod_correct 2 2 8).val == ((2 ^ 2) % 8)
def Fin.pow {h : n > 0} (a b : Fin n) : Fin n :=
let ⟨ val, prop ⟩ := Nat.powmod_correct a b n
⟨ val, by subst prop; exact Nat.mod_lt (Nat.pow a.val b.val) h ⟩
-- #eval Fin.pow ⟨ Fin.mk 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF UInt256.size
-- TODO make faster by modding intermediately
def UInt256.pow (a b:UInt256) : UInt256 := ⟨ Fin.pow (h:=by simp) a.val b.val ⟩
#eval UInt256.pow 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
-- def UInt256.sOfInt (a: Int) := if a
def UInt256.isSpos (a: UInt256) : Bool := if (a >>> 255) == 1 then false else true
def UInt256.slt (a b: UInt256) : Bool :=
let aS := a.isSpos
let bS := b.isSpos
match aS, bS with
| true, false => false
| false, true => true
| _, _ => a < b
#assert (UInt256.slt (UInt256.sneg 1) 5) == true
#assert (UInt256.slt 4 5) == true
#assert (UInt256.slt 5 5) == false
#assert (UInt256.slt 6 5) == false
#assert (UInt256.slt (UInt256.sneg 1) (UInt256.sneg 1)) == false
#assert (UInt256.slt 6 (UInt256.sneg 1)) == false
#assert (UInt256.slt (UInt256.sneg 2) (UInt256.sneg 1)) == true
#assert (UInt256.slt (UInt256.sneg 1) (UInt256.sneg 2)) == false
def UInt256.sgt (a b: UInt256) : Bool := if a == b then false else !UInt256.slt a b
def UInt256.ofBytes! (b: ByteArray) : UInt256 :=
let bs := ByteArray.mkZeros (256 / 8)
let destOff := (256 / 8) - b.size
let bs : ByteArray := ByteArray.copySlice b 0 bs destOff b.size
-- now we can go byte by byte
let p1 := (ByteArray.toUInt64LE! $ bs.extract 0 8).toUInt256
let p2 := (ByteArray.toUInt64LE! $ bs.extract 8 16).toUInt256
let p3 := (ByteArray.toUInt64LE! $ bs.extract 16 24).toUInt256
let p4 := (ByteArray.toUInt64LE! $ bs.extract 24 32).toUInt256
(p1 <<< 192) ||| (p2 <<< 128) ||| (p3 <<< 64) ||| p4
def UInt256.ofBytesL! (l : List UInt8) : UInt256 :=
let rec aux l (acc: UInt256) := match l with
| List.cons b bs => aux bs ((acc <<< 8) ||| (UInt256.ofUInt8 b))
| List.nil => acc
aux l 0
#assert (UInt256.ofBytes! $ ByteArray.mk $ #[01]) == (1:UInt256)
#assert (UInt256.ofBytes! $ ByteArray.mk $ #[0]) == (0:UInt256)
#assert (UInt256.ofBytes! $ ByteArray.mk $ #[0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]) == UInt256.ofNat $ UInt256.size - 1
#assert (UInt256.ofBytes! $ ByteArray.mk $ #[0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]) == UInt256.ofNat $ UInt256.size / 2
#assert (UInt256.ofBytesL! $ [0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]) == UInt256.ofNat $ UInt256.size / 2
def UInt256.toBytes (b: UInt256) : ByteArray := Id.run do
let mut ba := ByteArray.mkEmpty 32
for i in [0:32] do
ba := ba.push $ UInt256.toUInt8 $ (b <<< (8 * (UInt256.ofNat i))) >>> (8*31)
ba
#assert (UInt256.ofBytes! (UInt256.toBytes 5)) == (5:UInt256)
#assert (UInt256.ofBytes! (UInt256.toBytes (UInt256.ofNat $ UInt256.size - 1))) == (UInt256.ofNat $ UInt256.size - 1)
def UInt256.toBytesL (b: UInt256) : List UInt8 := Id.run do
let mut ba := []
for i in [0:32] do
ba := List.cons (UInt256.toUInt8 $ (b <<< (8 * (UInt256.ofNat i))) >>> (8*31)) ba
ba.reverse
#assert (UInt256.ofBytesL! (UInt256.toBytesL 5)) == (5:UInt256)
#assert ((UInt256.toBytesL 5).drop 31).head? == (Option.some (5:UInt8))
#assert (UInt256.ofBytesL! (UInt256.toBytesL (UInt256.ofNat $ UInt256.size - 1))) == (UInt256.ofNat $ UInt256.size - 1)
def UInt256.signextend (byteNum x : UInt256) :=
if byteNum > 31 then x else
let bitNum := byteNum*8+7
let mask := ((1:UInt256) <<< bitNum) - 1
let isBitSet := (x >>> bitNum) &&& 1 == 1
if isBitSet then x ||| (~~~ mask) else x &&& mask
#assert (UInt256.signextend 0 0xFF) == (0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF : UInt256)
#assert (UInt256.signextend 0 0x7F) == (0x7F : UInt256)
def UInt256.sar (x shiftBy : UInt256) :=
if x.isSpos then x >>> shiftBy else
let mask := UInt256.ones <<< (256 - shiftBy)
(x >>> shiftBy) ||| mask
#assert (UInt256.sar 2 1) == (1 : UInt256)
#assert (UInt256.sar 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0 4) ==
(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF : UInt256)
|
A map $f$ from a topological space $X$ to the real numbers is continuous if and only if $f$ is continuous or $f$ is the zero map. |
module builtinInModule where
module Str where
{-# BUILTIN STRING S #-}
primitive primStringAppend : S → S → S
|
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
s : Set (α × α)
⊢ idRel ⊆ s ↔ ∀ (a : α), (a, a) ∈ s
[PROOFSTEP]
simp [subset_def]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
x✝ : α × α
a b : α
⊢ (a, b) ∈ Prod.swap '' idRel ↔ (a, b) ∈ idRel
[PROOFSTEP]
simpa [image_swap_eq_preimage_swap] using eq_comm
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
r : Set (α × α)
x✝ : α × α
a b : α
⊢ (a, b) ∈ idRel ○ r ↔ (a, b) ∈ r
[PROOFSTEP]
simp
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
r s t : Set (α × α)
⊢ r ○ s ○ t = r ○ (s ○ t)
[PROOFSTEP]
ext ⟨a, b⟩
[GOAL]
case h.mk
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
r s t : Set (α × α)
a b : α
⊢ (a, b) ∈ r ○ s ○ t ↔ (a, b) ∈ r ○ (s ○ t)
[PROOFSTEP]
simp only [mem_compRel]
[GOAL]
case h.mk
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
r s t : Set (α × α)
a b : α
⊢ (∃ z, (∃ z_1, (a, z_1) ∈ r ∧ (z_1, z) ∈ s) ∧ (z, b) ∈ t) ↔ ∃ z, (a, z) ∈ r ∧ ∃ z_1, (z, z_1) ∈ s ∧ (z_1, b) ∈ t
[PROOFSTEP]
tauto
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
s t : Set (α × α)
h : idRel ⊆ s
n : ℕ
⊢ t ⊆ (fun x => s ○ x)^[n] t
[PROOFSTEP]
induction' n with n ihn generalizing t
[GOAL]
case zero
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
s t✝ : Set (α × α)
h : idRel ⊆ s
t : Set (α × α)
⊢ t ⊆ (fun x => s ○ x)^[Nat.zero] t
case succ
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
s t✝ : Set (α × α)
h : idRel ⊆ s
n : ℕ
ihn : ∀ {t : Set (α × α)}, t ⊆ (fun x => s ○ x)^[n] t
t : Set (α × α)
⊢ t ⊆ (fun x => s ○ x)^[Nat.succ n] t
[PROOFSTEP]
exacts [Subset.rfl, (right_subset_compRel h).trans ihn]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
V : Set (α × α)
⊢ SymmetricRel (symmetrizeRel V)
[PROOFSTEP]
simp [SymmetricRel, symmetrizeRel, preimage_inter, inter_comm, ← preimage_comp]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
U V : Set (α × α)
hU : SymmetricRel U
hV : SymmetricRel V
⊢ SymmetricRel (U ∩ V)
[PROOFSTEP]
rw [SymmetricRel, preimage_inter, hU.eq, hV.eq]
[GOAL]
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
α : Type u
u : Core α
⊢ (fun s => ∀ (x : α), x ∈ s → {p | p.fst = x → p.snd ∈ s} ∈ u.uniformity) univ
[PROOFSTEP]
simp
[GOAL]
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
α : Type u
u : Core α
s t : Set α
hs : (fun s => ∀ (x : α), x ∈ s → {p | p.fst = x → p.snd ∈ s} ∈ u.uniformity) s
ht : (fun s => ∀ (x : α), x ∈ s → {p | p.fst = x → p.snd ∈ s} ∈ u.uniformity) t
x : α
x✝ : x ∈ s ∩ t
xs : x ∈ s
xt : x ∈ t
⊢ {p | p.fst = x → p.snd ∈ s ∩ t} ∈ u.uniformity
[PROOFSTEP]
filter_upwards [hs x xs, ht x xt] with x hxs hxt hx using ⟨hxs hx, hxt hx⟩
[GOAL]
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
α : Type u
u : Core α
s : Set (Set α)
hs : ∀ (t : Set α), t ∈ s → (fun s => ∀ (x : α), x ∈ s → {p | p.fst = x → p.snd ∈ s} ∈ u.uniformity) t
x : α
x✝ : x ∈ ⋃₀ s
t : Set α
ts : t ∈ s
xt : x ∈ t
⊢ {p | p.fst = x → p.snd ∈ ⋃₀ s} ∈ u.uniformity
[PROOFSTEP]
filter_upwards [hs t ts x xt] with p ph h using ⟨t, ts, ph h⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
u✝ : Core α
t : TopologicalSpace α
h : ∀ (x : α), 𝓝 x = comap (Prod.mk x) u✝.uniformity
u : Set α
⊢ IsOpen u ↔ ∀ (x : α), x ∈ u → {p | p.fst = x → p.snd ∈ u} ∈ u✝.uniformity
[PROOFSTEP]
simp only [isOpen_iff_mem_nhds, h, mem_comap_prod_mk]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
t₁ : TopologicalSpace α
u₁ : UniformSpace.Core α
o₁ : ∀ (s : Set α), IsOpen s ↔ ∀ (x : α), x ∈ s → {p | p.fst = x → p.snd ∈ s} ∈ u₁.uniformity
t₂ : TopologicalSpace α
u₂ : UniformSpace.Core α
o₂ : ∀ (s : Set α), IsOpen s ↔ ∀ (x : α), x ∈ s → {p | p.fst = x → p.snd ∈ s} ∈ u₂.uniformity
h : uniformity α = uniformity α
⊢ UniformSpace.mk' t₁ u₁ o₁ = UniformSpace.mk' t₂ u₂ o₂
[PROOFSTEP]
obtain rfl : u₁ = u₂ := UniformSpace.core_eq h
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
t₁ : TopologicalSpace α
u₁ : UniformSpace.Core α
o₁ : ∀ (s : Set α), IsOpen s ↔ ∀ (x : α), x ∈ s → {p | p.fst = x → p.snd ∈ s} ∈ u₁.uniformity
t₂ : TopologicalSpace α
o₂ : ∀ (s : Set α), IsOpen s ↔ ∀ (x : α), x ∈ s → {p | p.fst = x → p.snd ∈ s} ∈ u₁.uniformity
h : uniformity α = uniformity α
⊢ UniformSpace.mk' t₁ u₁ o₁ = UniformSpace.mk' t₂ u₁ o₂
[PROOFSTEP]
obtain rfl : t₁ = t₂ := topologicalSpace_eq <| funext fun s => by rw [o₁, o₂]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
t₁ : TopologicalSpace α
u₁ : UniformSpace.Core α
o₁ : ∀ (s : Set α), IsOpen s ↔ ∀ (x : α), x ∈ s → {p | p.fst = x → p.snd ∈ s} ∈ u₁.uniformity
t₂ : TopologicalSpace α
o₂ : ∀ (s : Set α), IsOpen s ↔ ∀ (x : α), x ∈ s → {p | p.fst = x → p.snd ∈ s} ∈ u₁.uniformity
h : uniformity α = uniformity α
s : Set α
⊢ IsOpen s = IsOpen s
[PROOFSTEP]
rw [o₁, o₂]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
t₁ : TopologicalSpace α
u₁ : UniformSpace.Core α
o₁ o₂ : ∀ (s : Set α), IsOpen s ↔ ∀ (x : α), x ∈ s → {p | p.fst = x → p.snd ∈ s} ∈ u₁.uniformity
h : uniformity α = uniformity α
⊢ UniformSpace.mk' t₁ u₁ o₁ = UniformSpace.mk' t₁ u₁ o₂
[PROOFSTEP]
rfl
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
α : Type u
β : Type v
inst✝ : OrderedAddCommMonoid β
d : α → α → β
refl : ∀ (x : α), d x x = 0
symm : ∀ (x y : α), d x y = d y x
triangle : ∀ (x y z : α), d x z ≤ d x y + d y z
half : ∀ (ε : β), ε > 0 → ∃ δ, δ > 0 ∧ ∀ (x : β), x < δ → ∀ (y : β), y < δ → x + y < ε
r : β
hr : r > 0
x : α
⊢ (x, x) ∈ {x | d x.fst x.snd < r}
[PROOFSTEP]
simpa [refl]
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
α : Type u
β : Type v
inst✝ : OrderedAddCommMonoid β
d : α → α → β
refl : ∀ (x : α), d x x = 0
symm : ∀ (x y : α), d x y = d y x
triangle : ∀ (x y z : α), d x z ≤ d x y + d y z
half : ∀ (ε : β), ε > 0 → ∃ δ, δ > 0 ∧ ∀ (x : β), x < δ → ∀ (y : β), y < δ → x + y < ε
r : β
x✝ : r > 0
x : α × α
hx : x ∈ {x | d x.fst x.snd < r}
⊢ Prod.swap x ∈ {x | d x.fst x.snd < r}
[PROOFSTEP]
rwa [mem_setOf, symm]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set (α × α)
hs : s ∈ 𝓤 α
n : ℕ
⊢ ∀ᶠ (t : Set (α × α)) in smallSets (𝓤 α), (fun x => t ○ x)^[n] t ⊆ s
[PROOFSTEP]
suffices ∀ᶠ t in (𝓤 α).smallSets, t ⊆ s ∧ (t ○ ·)^[n] t ⊆ s from (eventually_and.1 this).2
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set (α × α)
hs : s ∈ 𝓤 α
n : ℕ
⊢ ∀ᶠ (t : Set (α × α)) in smallSets (𝓤 α), t ⊆ s ∧ (fun x => t ○ x)^[n] t ⊆ s
[PROOFSTEP]
induction' n with n ihn generalizing s
[GOAL]
case zero
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s✝ : Set (α × α)
hs✝ : s✝ ∈ 𝓤 α
s : Set (α × α)
hs : s ∈ 𝓤 α
⊢ ∀ᶠ (t : Set (α × α)) in smallSets (𝓤 α), t ⊆ s ∧ (fun x => t ○ x)^[Nat.zero] t ⊆ s
[PROOFSTEP]
simpa
[GOAL]
case succ
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s✝ : Set (α × α)
hs✝ : s✝ ∈ 𝓤 α
n : ℕ
ihn : ∀ {s : Set (α × α)}, s ∈ 𝓤 α → ∀ᶠ (t : Set (α × α)) in smallSets (𝓤 α), t ⊆ s ∧ (fun x => t ○ x)^[n] t ⊆ s
s : Set (α × α)
hs : s ∈ 𝓤 α
⊢ ∀ᶠ (t : Set (α × α)) in smallSets (𝓤 α), t ⊆ s ∧ (fun x => t ○ x)^[Nat.succ n] t ⊆ s
[PROOFSTEP]
rcases comp_mem_uniformity_sets hs with ⟨t, htU, hts⟩
[GOAL]
case succ.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s✝ : Set (α × α)
hs✝ : s✝ ∈ 𝓤 α
n : ℕ
ihn : ∀ {s : Set (α × α)}, s ∈ 𝓤 α → ∀ᶠ (t : Set (α × α)) in smallSets (𝓤 α), t ⊆ s ∧ (fun x => t ○ x)^[n] t ⊆ s
s : Set (α × α)
hs : s ∈ 𝓤 α
t : Set (α × α)
htU : t ∈ 𝓤 α
hts : t ○ t ⊆ s
⊢ ∀ᶠ (t : Set (α × α)) in smallSets (𝓤 α), t ⊆ s ∧ (fun x => t ○ x)^[Nat.succ n] t ⊆ s
[PROOFSTEP]
refine' (ihn htU).mono fun U hU => _
[GOAL]
case succ.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s✝ : Set (α × α)
hs✝ : s✝ ∈ 𝓤 α
n : ℕ
ihn : ∀ {s : Set (α × α)}, s ∈ 𝓤 α → ∀ᶠ (t : Set (α × α)) in smallSets (𝓤 α), t ⊆ s ∧ (fun x => t ○ x)^[n] t ⊆ s
s : Set (α × α)
hs : s ∈ 𝓤 α
t : Set (α × α)
htU : t ∈ 𝓤 α
hts : t ○ t ⊆ s
U : Set (α × α)
hU : U ⊆ t ∧ (fun x => U ○ x)^[n] U ⊆ t
⊢ U ⊆ s ∧ (fun x => U ○ x)^[Nat.succ n] U ⊆ s
[PROOFSTEP]
rw [Function.iterate_succ_apply']
[GOAL]
case succ.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s✝ : Set (α × α)
hs✝ : s✝ ∈ 𝓤 α
n : ℕ
ihn : ∀ {s : Set (α × α)}, s ∈ 𝓤 α → ∀ᶠ (t : Set (α × α)) in smallSets (𝓤 α), t ⊆ s ∧ (fun x => t ○ x)^[n] t ⊆ s
s : Set (α × α)
hs : s ∈ 𝓤 α
t : Set (α × α)
htU : t ∈ 𝓤 α
hts : t ○ t ⊆ s
U : Set (α × α)
hU : U ⊆ t ∧ (fun x => U ○ x)^[n] U ⊆ t
⊢ U ⊆ s ∧ U ○ (fun x => U ○ x)^[n] U ⊆ s
[PROOFSTEP]
exact ⟨hU.1.trans <| (subset_comp_self <| refl_le_uniformity htU).trans hts, (compRel_mono hU.1 hU.2).trans hts⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
l : Filter β
f₁ f₂ f₃ : β → α
h₁₂ : Tendsto (fun x => (f₁ x, f₂ x)) l (𝓤 α)
h₂₃ : Tendsto (fun x => (f₂ x, f₃ x)) l (𝓤 α)
⊢ Tendsto (fun x => (f₁ x, f₃ x)) l (𝓤 α)
[PROOFSTEP]
refine' le_trans (le_lift'.2 fun s hs => mem_map.2 _) comp_le_uniformity
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
l : Filter β
f₁ f₂ f₃ : β → α
h₁₂ : Tendsto (fun x => (f₁ x, f₂ x)) l (𝓤 α)
h₂₃ : Tendsto (fun x => (f₂ x, f₃ x)) l (𝓤 α)
s : Set (α × α)
hs : s ∈ 𝓤 α
⊢ (fun x => (f₁ x, f₃ x)) ⁻¹' (s ○ s) ∈ l
[PROOFSTEP]
filter_upwards [mem_map.1 (h₁₂ hs), mem_map.1 (h₂₃ hs)] with x hx₁₂ hx₂₃ using ⟨_, hx₁₂, hx₂₃⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
⊢ 𝓤 α ≤ Prod.swap <$> 𝓤 α
[PROOFSTEP]
rw [map_swap_eq_comap_swap]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
⊢ 𝓤 α ≤ comap Prod.swap (𝓤 α)
[PROOFSTEP]
exact tendsto_swap_uniformity.le_comap
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
V : Set (α × α)
h : V ∈ 𝓤 α
⊢ symmetrizeRel V ∈ 𝓤 α
[PROOFSTEP]
apply (𝓤 α).inter_sets h
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
V : Set (α × α)
h : V ∈ 𝓤 α
⊢ Prod.swap ⁻¹' V ∈ (𝓤 α).sets
[PROOFSTEP]
rw [← image_swap_eq_preimage_swap, uniformity_eq_symm]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
V : Set (α × α)
h : V ∈ 𝓤 α
⊢ Prod.swap '' V ∈ (Prod.swap <$> 𝓤 α).sets
[PROOFSTEP]
exact image_mem_map h
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
g : Set (α × α) → Filter β
f : Filter β
hg : Monotone g
h : (Filter.lift (𝓤 α) fun s => g (Prod.swap ⁻¹' s)) ≤ f
⊢ Filter.lift (map Prod.swap (𝓤 α)) g ≤ f
[PROOFSTEP]
rw [map_lift_eq2 hg, image_swap_eq_preimage_swap]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
g : Set (α × α) → Filter β
f : Filter β
hg : Monotone g
h : (Filter.lift (𝓤 α) fun s => g (Prod.swap ⁻¹' s)) ≤ f
⊢ Filter.lift (𝓤 α) (g ∘ preimage Prod.swap) ≤ f
[PROOFSTEP]
exact h
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
f : Set (α × α) → Filter β
h : Monotone f
⊢ (Filter.lift (𝓤 α) fun s => f (s ○ s)) = Filter.lift (Filter.lift' (𝓤 α) fun s => s ○ s) f
[PROOFSTEP]
rw [lift_lift'_assoc]
[GOAL]
case hg
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
f : Set (α × α) → Filter β
h : Monotone f
⊢ Monotone fun s => s ○ s
case hh
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
f : Set (α × α) → Filter β
h : Monotone f
⊢ Monotone f
[PROOFSTEP]
exact monotone_id.compRel monotone_id
[GOAL]
case hh
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
f : Set (α × α) → Filter β
h : Monotone f
⊢ Monotone f
[PROOFSTEP]
exact h
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set (α × α)
hs : s ∈ 𝓤 α
⊢ ∃ t, t ∈ 𝓤 α ∧ SymmetricRel t ∧ t ○ t ⊆ s
[PROOFSTEP]
obtain ⟨w, w_in, w_sub⟩ : ∃ w ∈ 𝓤 α, w ○ w ⊆ s := comp_mem_uniformity_sets hs
[GOAL]
case intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set (α × α)
hs : s ∈ 𝓤 α
w : Set (α × α)
w_in : w ∈ 𝓤 α
w_sub : w ○ w ⊆ s
⊢ ∃ t, t ∈ 𝓤 α ∧ SymmetricRel t ∧ t ○ t ⊆ s
[PROOFSTEP]
use symmetrizeRel w, symmetrize_mem_uniformity w_in, symmetric_symmetrizeRel w
[GOAL]
case right
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set (α × α)
hs : s ∈ 𝓤 α
w : Set (α × α)
w_in : w ∈ 𝓤 α
w_sub : w ○ w ⊆ s
⊢ symmetrizeRel w ○ symmetrizeRel w ⊆ s
[PROOFSTEP]
have : symmetrizeRel w ⊆ w := symmetrizeRel_subset_self w
[GOAL]
case right
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set (α × α)
hs : s ∈ 𝓤 α
w : Set (α × α)
w_in : w ∈ 𝓤 α
w_sub : w ○ w ⊆ s
this : symmetrizeRel w ⊆ w
⊢ symmetrizeRel w ○ symmetrizeRel w ⊆ s
[PROOFSTEP]
calc
symmetrizeRel w ○ symmetrizeRel w
_ ⊆ w ○ w := by mono
_ ⊆ s := w_sub
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set (α × α)
hs : s ∈ 𝓤 α
w : Set (α × α)
w_in : w ∈ 𝓤 α
w_sub : w ○ w ⊆ s
this : symmetrizeRel w ⊆ w
⊢ symmetrizeRel w ○ symmetrizeRel w ⊆ w ○ w
[PROOFSTEP]
mono
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set (α × α)
hs : s ∈ 𝓤 α
⊢ ∃ t, t ∈ 𝓤 α ∧ SymmetricRel t ∧ t ○ t ○ t ⊆ s
[PROOFSTEP]
rcases comp_symm_mem_uniformity_sets hs with ⟨w, w_in, _, w_sub⟩
[GOAL]
case intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set (α × α)
hs : s ∈ 𝓤 α
w : Set (α × α)
w_in : w ∈ 𝓤 α
left✝ : SymmetricRel w
w_sub : w ○ w ⊆ s
⊢ ∃ t, t ∈ 𝓤 α ∧ SymmetricRel t ∧ t ○ t ○ t ⊆ s
[PROOFSTEP]
rcases comp_symm_mem_uniformity_sets w_in with ⟨t, t_in, t_symm, t_sub⟩
[GOAL]
case intro.intro.intro.intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set (α × α)
hs : s ∈ 𝓤 α
w : Set (α × α)
w_in : w ∈ 𝓤 α
left✝ : SymmetricRel w
w_sub : w ○ w ⊆ s
t : Set (α × α)
t_in : t ∈ 𝓤 α
t_symm : SymmetricRel t
t_sub : t ○ t ⊆ w
⊢ ∃ t, t ∈ 𝓤 α ∧ SymmetricRel t ∧ t ○ t ○ t ⊆ s
[PROOFSTEP]
use t, t_in, t_symm
[GOAL]
case right
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set (α × α)
hs : s ∈ 𝓤 α
w : Set (α × α)
w_in : w ∈ 𝓤 α
left✝ : SymmetricRel w
w_sub : w ○ w ⊆ s
t : Set (α × α)
t_in : t ∈ 𝓤 α
t_symm : SymmetricRel t
t_sub : t ○ t ⊆ w
⊢ t ○ t ○ t ⊆ s
[PROOFSTEP]
have : t ⊆ t ○ t := subset_comp_self_of_mem_uniformity t_in
[GOAL]
case right
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set (α × α)
hs : s ∈ 𝓤 α
w : Set (α × α)
w_in : w ∈ 𝓤 α
left✝ : SymmetricRel w
w_sub : w ○ w ⊆ s
t : Set (α × α)
t_in : t ∈ 𝓤 α
t_symm : SymmetricRel t
t_sub : t ○ t ⊆ w
this : t ⊆ t ○ t
⊢ t ○ t ○ t ⊆ s
[PROOFSTEP]
have ht := Subset.refl t
[GOAL]
case right
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set (α × α)
hs : s ∈ 𝓤 α
w : Set (α × α)
w_in : w ∈ 𝓤 α
left✝ : SymmetricRel w
w_sub : w ○ w ⊆ s
t : Set (α × α)
t_in : t ∈ 𝓤 α
t_symm : SymmetricRel t
t_sub : t ○ t ⊆ w
this : t ⊆ t ○ t
ht : t ⊆ t
⊢ t ○ t ○ t ⊆ s
[PROOFSTEP]
have hw := Subset.refl w
[GOAL]
case right
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set (α × α)
hs : s ∈ 𝓤 α
w : Set (α × α)
w_in : w ∈ 𝓤 α
left✝ : SymmetricRel w
w_sub : w ○ w ⊆ s
t : Set (α × α)
t_in : t ∈ 𝓤 α
t_symm : SymmetricRel t
t_sub : t ○ t ⊆ w
this : t ⊆ t ○ t
ht : t ⊆ t
hw : w ⊆ w
⊢ t ○ t ○ t ⊆ s
[PROOFSTEP]
calc
t ○ t ○ t ⊆ w ○ t := by mono
_ ⊆ w ○ (t ○ t) := by mono
_ ⊆ w ○ w := by mono
_ ⊆ s := w_sub
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set (α × α)
hs : s ∈ 𝓤 α
w : Set (α × α)
w_in : w ∈ 𝓤 α
left✝ : SymmetricRel w
w_sub : w ○ w ⊆ s
t : Set (α × α)
t_in : t ∈ 𝓤 α
t_symm : SymmetricRel t
t_sub : t ○ t ⊆ w
this : t ⊆ t ○ t
ht : t ⊆ t
hw : w ⊆ w
⊢ t ○ t ○ t ⊆ w ○ t
[PROOFSTEP]
mono
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set (α × α)
hs : s ∈ 𝓤 α
w : Set (α × α)
w_in : w ∈ 𝓤 α
left✝ : SymmetricRel w
w_sub : w ○ w ⊆ s
t : Set (α × α)
t_in : t ∈ 𝓤 α
t_symm : SymmetricRel t
t_sub : t ○ t ⊆ w
this : t ⊆ t ○ t
ht : t ⊆ t
hw : w ⊆ w
⊢ w ○ t ⊆ w ○ (t ○ t)
[PROOFSTEP]
mono
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set (α × α)
hs : s ∈ 𝓤 α
w : Set (α × α)
w_in : w ∈ 𝓤 α
left✝ : SymmetricRel w
w_sub : w ○ w ⊆ s
t : Set (α × α)
t_in : t ∈ 𝓤 α
t_symm : SymmetricRel t
t_sub : t ○ t ⊆ w
this : t ⊆ t ○ t
ht : t ⊆ t
hw : w ⊆ w
⊢ w ○ (t ○ t) ⊆ w ○ w
[PROOFSTEP]
mono
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
V : Set (β × β)
hV : SymmetricRel V
x y : β
⊢ (x, y) ∈ Prod.swap ⁻¹' V ↔ (x, y) ∈ V
[PROOFSTEP]
unfold SymmetricRel at hV
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
V : Set (β × β)
hV : Prod.swap ⁻¹' V = V
x y : β
⊢ (x, y) ∈ Prod.swap ⁻¹' V ↔ (x, y) ∈ V
[PROOFSTEP]
rw [hV]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
V : Set (β × β)
hV : SymmetricRel V
x : β
⊢ ball x V = {y | (y, x) ∈ V}
[PROOFSTEP]
ext y
[GOAL]
case h
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
V : Set (β × β)
hV : SymmetricRel V
x y : β
⊢ y ∈ ball x V ↔ y ∈ {y | (y, x) ∈ V}
[PROOFSTEP]
rw [mem_ball_symmetry hV]
[GOAL]
case h
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
V : Set (β × β)
hV : SymmetricRel V
x y : β
⊢ x ∈ ball y V ↔ y ∈ {y | (y, x) ∈ V}
[PROOFSTEP]
exact Iff.rfl
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
V W : Set (β × β)
x y z : β
hV : SymmetricRel V
hx : x ∈ ball z V
hy : y ∈ ball z W
⊢ (x, y) ∈ V ○ W
[PROOFSTEP]
rw [mem_ball_symmetry hV] at hx
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
V W : Set (β × β)
x y z : β
hV : SymmetricRel V
hx : z ∈ ball x V
hy : y ∈ ball z W
⊢ (x, y) ∈ V ○ W
[PROOFSTEP]
exact ⟨z, hx, hy⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
V W M : Set (β × β)
hW' : SymmetricRel W
p : β × β
⊢ p ∈ V ○ M ○ W ↔ Set.Nonempty (ball p.fst V ×ˢ ball p.snd W ∩ M)
[PROOFSTEP]
cases' p with x y
[GOAL]
case mk
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
V W M : Set (β × β)
hW' : SymmetricRel W
x y : β
⊢ (x, y) ∈ V ○ M ○ W ↔ Set.Nonempty (ball (x, y).fst V ×ˢ ball (x, y).snd W ∩ M)
[PROOFSTEP]
constructor
[GOAL]
case mk.mp
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
V W M : Set (β × β)
hW' : SymmetricRel W
x y : β
⊢ (x, y) ∈ V ○ M ○ W → Set.Nonempty (ball (x, y).fst V ×ˢ ball (x, y).snd W ∩ M)
[PROOFSTEP]
rintro ⟨z, ⟨w, hpw, hwz⟩, hzy⟩
[GOAL]
case mk.mp.intro.intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
V W M : Set (β × β)
hW' : SymmetricRel W
x y z : β
hzy : (z, (x, y).snd) ∈ W
w : β
hpw : (((x, y).fst, z).fst, w) ∈ V
hwz : (w, ((x, y).fst, z).snd) ∈ M
⊢ Set.Nonempty (ball (x, y).fst V ×ˢ ball (x, y).snd W ∩ M)
[PROOFSTEP]
exact ⟨(w, z), ⟨hpw, by rwa [mem_ball_symmetry hW']⟩, hwz⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
V W M : Set (β × β)
hW' : SymmetricRel W
x y z : β
hzy : (z, (x, y).snd) ∈ W
w : β
hpw : (((x, y).fst, z).fst, w) ∈ V
hwz : (w, ((x, y).fst, z).snd) ∈ M
⊢ (w, z).snd ∈ ball (x, y).snd W
[PROOFSTEP]
rwa [mem_ball_symmetry hW']
[GOAL]
case mk.mpr
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
V W M : Set (β × β)
hW' : SymmetricRel W
x y : β
⊢ Set.Nonempty (ball (x, y).fst V ×ˢ ball (x, y).snd W ∩ M) → (x, y) ∈ V ○ M ○ W
[PROOFSTEP]
rintro ⟨⟨w, z⟩, ⟨w_in, z_in⟩, hwz⟩
[GOAL]
case mk.mpr.intro.mk.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
V W M : Set (β × β)
hW' : SymmetricRel W
x y w z : β
hwz : (w, z) ∈ M
w_in : (w, z).fst ∈ ball (x, y).fst V
z_in : (w, z).snd ∈ ball (x, y).snd W
⊢ (x, y) ∈ V ○ M ○ W
[PROOFSTEP]
rw [mem_ball_symmetry hW'] at z_in
[GOAL]
case mk.mpr.intro.mk.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
V W M : Set (β × β)
hW' : SymmetricRel W
x y w z : β
hwz : (w, z) ∈ M
w_in : (w, z).fst ∈ ball (x, y).fst V
z_in : (x, y).snd ∈ ball (w, z).snd W
⊢ (x, y) ∈ V ○ M ○ W
[PROOFSTEP]
exact ⟨z, ⟨w, w_in, hwz⟩, z_in⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
s : Set α
⊢ s ∈ 𝓝 x ↔ {p | p.fst = x → p.snd ∈ s} ∈ 𝓤 α
[PROOFSTEP]
refine' ⟨_, fun hs => _⟩
[GOAL]
case refine'_1
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
s : Set α
⊢ s ∈ 𝓝 x → {p | p.fst = x → p.snd ∈ s} ∈ 𝓤 α
[PROOFSTEP]
simp only [mem_nhds_iff, isOpen_uniformity, and_imp, exists_imp]
[GOAL]
case refine'_1
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
s : Set α
⊢ ∀ (x_1 : Set α),
x_1 ⊆ s → (∀ (x : α), x ∈ x_1 → {p | p.fst = x → p.snd ∈ x_1} ∈ 𝓤 α) → x ∈ x_1 → {p | p.fst = x → p.snd ∈ s} ∈ 𝓤 α
[PROOFSTEP]
intro t ts ht xt
[GOAL]
case refine'_1
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
s t : Set α
ts : t ⊆ s
ht : ∀ (x : α), x ∈ t → {p | p.fst = x → p.snd ∈ t} ∈ 𝓤 α
xt : x ∈ t
⊢ {p | p.fst = x → p.snd ∈ s} ∈ 𝓤 α
[PROOFSTEP]
filter_upwards [ht x xt] using fun y h eq => ts (h eq)
[GOAL]
case refine'_2
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
s : Set α
hs : {p | p.fst = x → p.snd ∈ s} ∈ 𝓤 α
⊢ s ∈ 𝓝 x
[PROOFSTEP]
refine' mem_nhds_iff.mpr ⟨{x | {p : α × α | p.1 = x → p.2 ∈ s} ∈ 𝓤 α}, _, _, hs⟩
[GOAL]
case refine'_2.refine'_1
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
s : Set α
hs : {p | p.fst = x → p.snd ∈ s} ∈ 𝓤 α
⊢ {x | {p | p.fst = x → p.snd ∈ s} ∈ 𝓤 α} ⊆ s
[PROOFSTEP]
exact fun y hy => refl_mem_uniformity hy rfl
[GOAL]
case refine'_2.refine'_2
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
s : Set α
hs : {p | p.fst = x → p.snd ∈ s} ∈ 𝓤 α
⊢ IsOpen {x | {p | p.fst = x → p.snd ∈ s} ∈ 𝓤 α}
[PROOFSTEP]
refine' isOpen_uniformity.mpr fun y hy => _
[GOAL]
case refine'_2.refine'_2
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
s : Set α
hs : {p | p.fst = x → p.snd ∈ s} ∈ 𝓤 α
y : α
hy : y ∈ {x | {p | p.fst = x → p.snd ∈ s} ∈ 𝓤 α}
⊢ {p | p.fst = y → p.snd ∈ {x | {p | p.fst = x → p.snd ∈ s} ∈ 𝓤 α}} ∈ 𝓤 α
[PROOFSTEP]
rcases comp_mem_uniformity_sets hy with ⟨t, ht, tr⟩
[GOAL]
case refine'_2.refine'_2.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
s : Set α
hs : {p | p.fst = x → p.snd ∈ s} ∈ 𝓤 α
y : α
hy : y ∈ {x | {p | p.fst = x → p.snd ∈ s} ∈ 𝓤 α}
t : Set (α × α)
ht : t ∈ 𝓤 α
tr : t ○ t ⊆ {p | p.fst = y → p.snd ∈ s}
⊢ {p | p.fst = y → p.snd ∈ {x | {p | p.fst = x → p.snd ∈ s} ∈ 𝓤 α}} ∈ 𝓤 α
[PROOFSTEP]
filter_upwards [ht]
[GOAL]
case h
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
s : Set α
hs : {p | p.fst = x → p.snd ∈ s} ∈ 𝓤 α
y : α
hy : y ∈ {x | {p | p.fst = x → p.snd ∈ s} ∈ 𝓤 α}
t : Set (α × α)
ht : t ∈ 𝓤 α
tr : t ○ t ⊆ {p | p.fst = y → p.snd ∈ s}
⊢ ∀ (a : α × α), a ∈ t → a.fst = y → {p | p.fst = a.snd → p.snd ∈ s} ∈ 𝓤 α
[PROOFSTEP]
rintro ⟨a, b⟩ hp' rfl
[GOAL]
case h.mk
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
s : Set α
hs : {p | p.fst = x → p.snd ∈ s} ∈ 𝓤 α
t : Set (α × α)
ht : t ∈ 𝓤 α
a b : α
hp' : (a, b) ∈ t
hy : (a, b).fst ∈ {x | {p | p.fst = x → p.snd ∈ s} ∈ 𝓤 α}
tr : t ○ t ⊆ {p | p.fst = (a, b).fst → p.snd ∈ s}
⊢ {p | p.fst = (a, b).snd → p.snd ∈ s} ∈ 𝓤 α
[PROOFSTEP]
filter_upwards [ht]
[GOAL]
case h
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
s : Set α
hs : {p | p.fst = x → p.snd ∈ s} ∈ 𝓤 α
t : Set (α × α)
ht : t ∈ 𝓤 α
a b : α
hp' : (a, b) ∈ t
hy : (a, b).fst ∈ {x | {p | p.fst = x → p.snd ∈ s} ∈ 𝓤 α}
tr : t ○ t ⊆ {p | p.fst = (a, b).fst → p.snd ∈ s}
⊢ ∀ (a : α × α), a ∈ t → a.fst = b → a.snd ∈ s
[PROOFSTEP]
rintro ⟨a', b'⟩ hp'' rfl
[GOAL]
case h.mk
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
s : Set α
hs : {p | p.fst = x → p.snd ∈ s} ∈ 𝓤 α
t : Set (α × α)
ht : t ∈ 𝓤 α
a a' b' : α
hp'' : (a', b') ∈ t
hp' : (a, (a', b').fst) ∈ t
hy : (a, (a', b').fst).fst ∈ {x | {p | p.fst = x → p.snd ∈ s} ∈ 𝓤 α}
tr : t ○ t ⊆ {p | p.fst = (a, (a', b').fst).fst → p.snd ∈ s}
⊢ (a', b').snd ∈ s
[PROOFSTEP]
exact @tr (a, b') ⟨a', hp', hp''⟩ rfl
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
s : Set α
⊢ s ∈ 𝓝 x ↔ {p | p.snd = x → p.fst ∈ s} ∈ 𝓤 α
[PROOFSTEP]
rw [uniformity_eq_symm, mem_nhds_uniformity_iff_right]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
s : Set α
⊢ {p | p.fst = x → p.snd ∈ s} ∈ 𝓤 α ↔ {p | p.snd = x → p.fst ∈ s} ∈ Prod.swap <$> 𝓤 α
[PROOFSTEP]
simp only [map_def, mem_map, preimage_setOf_eq, Prod.snd_swap, Prod.fst_swap]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
⊢ 𝓝 x = comap (Prod.mk x) (𝓤 α)
[PROOFSTEP]
ext s
[GOAL]
case a
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
s : Set α
⊢ s ∈ 𝓝 x ↔ s ∈ comap (Prod.mk x) (𝓤 α)
[PROOFSTEP]
rw [mem_nhds_uniformity_iff_right, mem_comap_prod_mk]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set α
⊢ IsOpen s ↔ ∀ (x : α), x ∈ s → ∃ V, V ∈ 𝓤 α ∧ ball x V ⊆ s
[PROOFSTEP]
simp_rw [isOpen_iff_mem_nhds, nhds_eq_comap_uniformity, mem_comap, ball]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
s : ι → Set (α × α)
h : HasBasis (𝓤 α) p s
x : α
⊢ HasBasis (𝓝 x) p fun i => ball x (s i)
[PROOFSTEP]
rw [nhds_eq_comap_uniformity]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
s : ι → Set (α × α)
h : HasBasis (𝓤 α) p s
x : α
⊢ HasBasis (comap (Prod.mk x) (𝓤 α)) p fun i => ball x (s i)
[PROOFSTEP]
exact h.comap (Prod.mk x)
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
s : ι → Set (α × α)
h : HasBasis (𝓤 α) p s
x : α
⊢ HasBasis (𝓝 x) p fun i => {y | (y, x) ∈ s i}
[PROOFSTEP]
replace h := h.comap Prod.swap
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
s : ι → Set (α × α)
x : α
h : HasBasis (comap Prod.swap (𝓤 α)) p fun i => Prod.swap ⁻¹' s i
⊢ HasBasis (𝓝 x) p fun i => {y | (y, x) ∈ s i}
[PROOFSTEP]
rw [← map_swap_eq_comap_swap, ← uniformity_eq_symm] at h
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
s : ι → Set (α × α)
x : α
h : HasBasis (𝓤 α) p fun i => Prod.swap ⁻¹' s i
⊢ HasBasis (𝓝 x) p fun i => {y | (y, x) ∈ s i}
[PROOFSTEP]
exact nhds_basis_uniformity' h
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
s : Set α
⊢ s ∈ 𝓝 x ↔ ∃ V, V ∈ 𝓤 α ∧ ball x V ⊆ s
[PROOFSTEP]
rw [nhds_eq_comap_uniformity, mem_comap]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
s : Set α
⊢ (∃ t, t ∈ 𝓤 α ∧ Prod.mk x ⁻¹' t ⊆ s) ↔ ∃ V, V ∈ 𝓤 α ∧ ball x V ⊆ s
[PROOFSTEP]
simp_rw [ball]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
V : Set (α × α)
V_in : V ∈ 𝓤 α
⊢ ball x V ∈ 𝓝 x
[PROOFSTEP]
rw [UniformSpace.mem_nhds_iff]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
V : Set (α × α)
V_in : V ∈ 𝓤 α
⊢ ∃ V_1, V_1 ∈ 𝓤 α ∧ ball x V_1 ⊆ ball x V
[PROOFSTEP]
exact ⟨V, V_in, Subset.rfl⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
s : Set α
⊢ s ∈ 𝓝 x ↔ ∃ V, V ∈ 𝓤 α ∧ SymmetricRel V ∧ ball x V ⊆ s
[PROOFSTEP]
rw [UniformSpace.mem_nhds_iff]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
s : Set α
⊢ (∃ V, V ∈ 𝓤 α ∧ ball x V ⊆ s) ↔ ∃ V, V ∈ 𝓤 α ∧ SymmetricRel V ∧ ball x V ⊆ s
[PROOFSTEP]
constructor
[GOAL]
case mp
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
s : Set α
⊢ (∃ V, V ∈ 𝓤 α ∧ ball x V ⊆ s) → ∃ V, V ∈ 𝓤 α ∧ SymmetricRel V ∧ ball x V ⊆ s
[PROOFSTEP]
rintro ⟨V, V_in, V_sub⟩
[GOAL]
case mp.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
s : Set α
V : Set (α × α)
V_in : V ∈ 𝓤 α
V_sub : ball x V ⊆ s
⊢ ∃ V, V ∈ 𝓤 α ∧ SymmetricRel V ∧ ball x V ⊆ s
[PROOFSTEP]
use symmetrizeRel V, symmetrize_mem_uniformity V_in, symmetric_symmetrizeRel V
[GOAL]
case right
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
s : Set α
V : Set (α × α)
V_in : V ∈ 𝓤 α
V_sub : ball x V ⊆ s
⊢ ball x (symmetrizeRel V) ⊆ s
[PROOFSTEP]
exact Subset.trans (ball_mono (symmetrizeRel_subset_self V) x) V_sub
[GOAL]
case mpr
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
s : Set α
⊢ (∃ V, V ∈ 𝓤 α ∧ SymmetricRel V ∧ ball x V ⊆ s) → ∃ V, V ∈ 𝓤 α ∧ ball x V ⊆ s
[PROOFSTEP]
rintro ⟨V, V_in, _, V_sub⟩
[GOAL]
case mpr.intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
s : Set α
V : Set (α × α)
V_in : V ∈ 𝓤 α
left✝ : SymmetricRel V
V_sub : ball x V ⊆ s
⊢ ∃ V, V ∈ 𝓤 α ∧ ball x V ⊆ s
[PROOFSTEP]
exact ⟨V, V_in, V_sub⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
t : Set α
⊢ t ∈ 𝓝 x ↔ ∃ i, (i ∈ 𝓤 α ∧ SymmetricRel i) ∧ ball x i ⊆ t
[PROOFSTEP]
simp [UniformSpace.mem_nhds_iff_symm, and_assoc]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set α
x : α
⊢ x ∈ closure s ↔ ∀ {V : Set (α × α)}, V ∈ 𝓤 α → SymmetricRel V → Set.Nonempty (s ∩ ball x V)
[PROOFSTEP]
simp [mem_closure_iff_nhds_basis (hasBasis_nhds x), Set.Nonempty]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set α
x : α
⊢ x ∈ closure s ↔ ∀ {V : Set (α × α)}, V ∈ 𝓤 α → Set.Nonempty (ball x V ∩ s)
[PROOFSTEP]
simp [mem_closure_iff_nhds_basis' (nhds_basis_uniformity' (𝓤 α).basis_sets)]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x y : α
⊢ HasBasis (𝓝 (x, y)) (fun s => s ∈ 𝓤 α ∧ SymmetricRel s) fun s => ball x s ×ˢ ball y s
[PROOFSTEP]
rw [nhds_prod_eq]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x y : α
⊢ HasBasis (𝓝 x ×ˢ 𝓝 y) (fun s => s ∈ 𝓤 α ∧ SymmetricRel s) fun s => ball x s ×ˢ ball y s
[PROOFSTEP]
apply (hasBasis_nhds x).prod_same_index (hasBasis_nhds y)
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x y : α
⊢ ∀ {i j : Set (α × α)},
i ∈ 𝓤 α ∧ SymmetricRel i →
j ∈ 𝓤 α ∧ SymmetricRel j → ∃ k, (k ∈ 𝓤 α ∧ SymmetricRel k) ∧ ball x k ⊆ ball x i ∧ ball y k ⊆ ball y j
[PROOFSTEP]
rintro U V ⟨U_in, U_symm⟩ ⟨V_in, V_symm⟩
[GOAL]
case intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x y : α
U V : Set (α × α)
U_in : U ∈ 𝓤 α
U_symm : SymmetricRel U
V_in : V ∈ 𝓤 α
V_symm : SymmetricRel V
⊢ ∃ k, (k ∈ 𝓤 α ∧ SymmetricRel k) ∧ ball x k ⊆ ball x U ∧ ball y k ⊆ ball y V
[PROOFSTEP]
exact ⟨U ∩ V, ⟨(𝓤 α).inter_sets U_in V_in, U_symm.inter V_symm⟩, ball_inter_left x U V, ball_inter_right y U V⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
s : ι → Set (α × α)
hU : HasBasis (𝓤 α) p s
K : Set α
hK : IsCompact K
⊢ HasBasis (𝓝ˢ K) p fun i => ⋃ (x : α) (_ : x ∈ K), ball x (s i)
[PROOFSTEP]
refine' ⟨fun U => _⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
s : ι → Set (α × α)
hU : HasBasis (𝓤 α) p s
K : Set α
hK : IsCompact K
U : Set α
⊢ U ∈ 𝓝ˢ K ↔ ∃ i, p i ∧ ⋃ (x : α) (_ : x ∈ K), ball x (s i) ⊆ U
[PROOFSTEP]
simp only [mem_nhdsSet_iff_forall, (nhds_basis_uniformity' hU).mem_iff, iUnion₂_subset_iff]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
s : ι → Set (α × α)
hU : HasBasis (𝓤 α) p s
K : Set α
hK : IsCompact K
U : Set α
⊢ (∀ (x : α), x ∈ K → ∃ i, p i ∧ ball x (s i) ⊆ U) ↔ ∃ i, p i ∧ ∀ (i_1 : α), i_1 ∈ K → ball i_1 (s i) ⊆ U
[PROOFSTEP]
refine' ⟨fun H => _, fun ⟨i, hpi, hi⟩ x hx => ⟨i, hpi, hi x hx⟩⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
s : ι → Set (α × α)
hU : HasBasis (𝓤 α) p s
K : Set α
hK : IsCompact K
U : Set α
H : ∀ (x : α), x ∈ K → ∃ i, p i ∧ ball x (s i) ⊆ U
⊢ ∃ i, p i ∧ ∀ (i_1 : α), i_1 ∈ K → ball i_1 (s i) ⊆ U
[PROOFSTEP]
replace H : ∀ x ∈ K, ∃ i : { i // p i }, ball x (s i ○ s i) ⊆ U
[GOAL]
case H
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
s : ι → Set (α × α)
hU : HasBasis (𝓤 α) p s
K : Set α
hK : IsCompact K
U : Set α
H : ∀ (x : α), x ∈ K → ∃ i, p i ∧ ball x (s i) ⊆ U
⊢ ∀ (x : α), x ∈ K → ∃ i, ball x (s ↑i ○ s ↑i) ⊆ U
[PROOFSTEP]
intro x hx
[GOAL]
case H
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
s : ι → Set (α × α)
hU : HasBasis (𝓤 α) p s
K : Set α
hK : IsCompact K
U : Set α
H : ∀ (x : α), x ∈ K → ∃ i, p i ∧ ball x (s i) ⊆ U
x : α
hx : x ∈ K
⊢ ∃ i, ball x (s ↑i ○ s ↑i) ⊆ U
[PROOFSTEP]
rcases H x hx with ⟨i, hpi, hi⟩
[GOAL]
case H.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
s : ι → Set (α × α)
hU : HasBasis (𝓤 α) p s
K : Set α
hK : IsCompact K
U : Set α
H : ∀ (x : α), x ∈ K → ∃ i, p i ∧ ball x (s i) ⊆ U
x : α
hx : x ∈ K
i : ι
hpi : p i
hi : ball x (s i) ⊆ U
⊢ ∃ i, ball x (s ↑i ○ s ↑i) ⊆ U
[PROOFSTEP]
rcases comp_mem_uniformity_sets (hU.mem_of_mem hpi) with ⟨t, ht_mem, ht⟩
[GOAL]
case H.intro.intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
s : ι → Set (α × α)
hU : HasBasis (𝓤 α) p s
K : Set α
hK : IsCompact K
U : Set α
H : ∀ (x : α), x ∈ K → ∃ i, p i ∧ ball x (s i) ⊆ U
x : α
hx : x ∈ K
i : ι
hpi : p i
hi : ball x (s i) ⊆ U
t : Set (α × α)
ht_mem : t ∈ 𝓤 α
ht : t ○ t ⊆ s i
⊢ ∃ i, ball x (s ↑i ○ s ↑i) ⊆ U
[PROOFSTEP]
rcases hU.mem_iff.1 ht_mem with ⟨j, hpj, hj⟩
[GOAL]
case H.intro.intro.intro.intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
s : ι → Set (α × α)
hU : HasBasis (𝓤 α) p s
K : Set α
hK : IsCompact K
U : Set α
H : ∀ (x : α), x ∈ K → ∃ i, p i ∧ ball x (s i) ⊆ U
x : α
hx : x ∈ K
i : ι
hpi : p i
hi : ball x (s i) ⊆ U
t : Set (α × α)
ht_mem : t ∈ 𝓤 α
ht : t ○ t ⊆ s i
j : ι
hpj : p j
hj : s j ⊆ t
⊢ ∃ i, ball x (s ↑i ○ s ↑i) ⊆ U
[PROOFSTEP]
exact ⟨⟨j, hpj⟩, Subset.trans (ball_mono ((compRel_mono hj hj).trans ht) _) hi⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
s : ι → Set (α × α)
hU : HasBasis (𝓤 α) p s
K : Set α
hK : IsCompact K
U : Set α
H : ∀ (x : α), x ∈ K → ∃ i, ball x (s ↑i ○ s ↑i) ⊆ U
⊢ ∃ i, p i ∧ ∀ (i_1 : α), i_1 ∈ K → ball i_1 (s i) ⊆ U
[PROOFSTEP]
have : Nonempty { a // p a } := nonempty_subtype.2 hU.ex_mem
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
s : ι → Set (α × α)
hU : HasBasis (𝓤 α) p s
K : Set α
hK : IsCompact K
U : Set α
H : ∀ (x : α), x ∈ K → ∃ i, ball x (s ↑i ○ s ↑i) ⊆ U
this : Nonempty { a // p a }
⊢ ∃ i, p i ∧ ∀ (i_1 : α), i_1 ∈ K → ball i_1 (s i) ⊆ U
[PROOFSTEP]
choose! I hI using H
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
s : ι → Set (α × α)
hU : HasBasis (𝓤 α) p s
K : Set α
hK : IsCompact K
U : Set α
this : Nonempty { a // p a }
I : α → { i // p i }
hI : ∀ (x : α), x ∈ K → ball x (s ↑(I x) ○ s ↑(I x)) ⊆ U
⊢ ∃ i, p i ∧ ∀ (i_1 : α), i_1 ∈ K → ball i_1 (s i) ⊆ U
[PROOFSTEP]
rcases hK.elim_nhds_subcover (fun x => ball x <| s (I x)) fun x _ => ball_mem_nhds _ <| hU.mem_of_mem (I x).2 with
⟨t, htK, ht⟩
[GOAL]
case intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
s : ι → Set (α × α)
hU : HasBasis (𝓤 α) p s
K : Set α
hK : IsCompact K
U : Set α
this : Nonempty { a // p a }
I : α → { i // p i }
hI : ∀ (x : α), x ∈ K → ball x (s ↑(I x) ○ s ↑(I x)) ⊆ U
t : Finset α
htK : ∀ (x : α), x ∈ t → x ∈ K
ht : K ⊆ ⋃ (x : α) (_ : x ∈ t), ball x (s ↑(I x))
⊢ ∃ i, p i ∧ ∀ (i_1 : α), i_1 ∈ K → ball i_1 (s i) ⊆ U
[PROOFSTEP]
obtain ⟨i, hpi, hi⟩ : ∃ i, p i ∧ s i ⊆ ⋂ x ∈ t, s (I x)
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
s : ι → Set (α × α)
hU : HasBasis (𝓤 α) p s
K : Set α
hK : IsCompact K
U : Set α
this : Nonempty { a // p a }
I : α → { i // p i }
hI : ∀ (x : α), x ∈ K → ball x (s ↑(I x) ○ s ↑(I x)) ⊆ U
t : Finset α
htK : ∀ (x : α), x ∈ t → x ∈ K
ht : K ⊆ ⋃ (x : α) (_ : x ∈ t), ball x (s ↑(I x))
⊢ ∃ i, p i ∧ s i ⊆ ⋂ (x : α) (_ : x ∈ t), s ↑(I x)
case intro.intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
s : ι → Set (α × α)
hU : HasBasis (𝓤 α) p s
K : Set α
hK : IsCompact K
U : Set α
this : Nonempty { a // p a }
I : α → { i // p i }
hI : ∀ (x : α), x ∈ K → ball x (s ↑(I x) ○ s ↑(I x)) ⊆ U
t : Finset α
htK : ∀ (x : α), x ∈ t → x ∈ K
ht : K ⊆ ⋃ (x : α) (_ : x ∈ t), ball x (s ↑(I x))
i : ι
hpi : p i
hi : s i ⊆ ⋂ (x : α) (_ : x ∈ t), s ↑(I x)
⊢ ∃ i, p i ∧ ∀ (i_1 : α), i_1 ∈ K → ball i_1 (s i) ⊆ U
[PROOFSTEP]
exact hU.mem_iff.1 ((biInter_finset_mem t).2 fun x _ => hU.mem_of_mem (I x).2)
[GOAL]
case intro.intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
s : ι → Set (α × α)
hU : HasBasis (𝓤 α) p s
K : Set α
hK : IsCompact K
U : Set α
this : Nonempty { a // p a }
I : α → { i // p i }
hI : ∀ (x : α), x ∈ K → ball x (s ↑(I x) ○ s ↑(I x)) ⊆ U
t : Finset α
htK : ∀ (x : α), x ∈ t → x ∈ K
ht : K ⊆ ⋃ (x : α) (_ : x ∈ t), ball x (s ↑(I x))
i : ι
hpi : p i
hi : s i ⊆ ⋂ (x : α) (_ : x ∈ t), s ↑(I x)
⊢ ∃ i, p i ∧ ∀ (i_1 : α), i_1 ∈ K → ball i_1 (s i) ⊆ U
[PROOFSTEP]
rw [subset_iInter₂_iff] at hi
[GOAL]
case intro.intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
s : ι → Set (α × α)
hU : HasBasis (𝓤 α) p s
K : Set α
hK : IsCompact K
U : Set α
this : Nonempty { a // p a }
I : α → { i // p i }
hI : ∀ (x : α), x ∈ K → ball x (s ↑(I x) ○ s ↑(I x)) ⊆ U
t : Finset α
htK : ∀ (x : α), x ∈ t → x ∈ K
ht : K ⊆ ⋃ (x : α) (_ : x ∈ t), ball x (s ↑(I x))
i : ι
hpi : p i
hi : ∀ (i_1 : α), i_1 ∈ t → s i ⊆ s ↑(I i_1)
⊢ ∃ i, p i ∧ ∀ (i_1 : α), i_1 ∈ K → ball i_1 (s i) ⊆ U
[PROOFSTEP]
refine' ⟨i, hpi, fun x hx => _⟩
[GOAL]
case intro.intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
s : ι → Set (α × α)
hU : HasBasis (𝓤 α) p s
K : Set α
hK : IsCompact K
U : Set α
this : Nonempty { a // p a }
I : α → { i // p i }
hI : ∀ (x : α), x ∈ K → ball x (s ↑(I x) ○ s ↑(I x)) ⊆ U
t : Finset α
htK : ∀ (x : α), x ∈ t → x ∈ K
ht : K ⊆ ⋃ (x : α) (_ : x ∈ t), ball x (s ↑(I x))
i : ι
hpi : p i
hi : ∀ (i_1 : α), i_1 ∈ t → s i ⊆ s ↑(I i_1)
x : α
hx : x ∈ K
⊢ ball x (s i) ⊆ U
[PROOFSTEP]
rcases mem_iUnion₂.1 (ht hx) with ⟨z, hzt : z ∈ t, hzx : x ∈ ball z (s (I z))⟩
[GOAL]
case intro.intro.intro.intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
s : ι → Set (α × α)
hU : HasBasis (𝓤 α) p s
K : Set α
hK : IsCompact K
U : Set α
this : Nonempty { a // p a }
I : α → { i // p i }
hI : ∀ (x : α), x ∈ K → ball x (s ↑(I x) ○ s ↑(I x)) ⊆ U
t : Finset α
htK : ∀ (x : α), x ∈ t → x ∈ K
ht : K ⊆ ⋃ (x : α) (_ : x ∈ t), ball x (s ↑(I x))
i : ι
hpi : p i
hi : ∀ (i_1 : α), i_1 ∈ t → s i ⊆ s ↑(I i_1)
x : α
hx : x ∈ K
z : α
hzt : z ∈ t
hzx : x ∈ ball z (s ↑(I z))
⊢ ball x (s i) ⊆ U
[PROOFSTEP]
calc
ball x (s i) ⊆ ball z (s (I z) ○ s (I z)) := fun y hy => ⟨x, hzx, hi z hzt hy⟩
_ ⊆ U := hI z (htK z hzt)
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
A B : Set α
hA : IsCompact A
hB : IsClosed B
h : Disjoint A B
⊢ ∃ V, V ∈ 𝓤 α ∧ Disjoint (⋃ (x : α) (_ : x ∈ A), ball x V) (⋃ (x : α) (_ : x ∈ B), ball x V)
[PROOFSTEP]
have : Bᶜ ∈ 𝓝ˢ A := hB.isOpen_compl.mem_nhdsSet.mpr h.le_compl_right
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
A B : Set α
hA : IsCompact A
hB : IsClosed B
h : Disjoint A B
this : Bᶜ ∈ 𝓝ˢ A
⊢ ∃ V, V ∈ 𝓤 α ∧ Disjoint (⋃ (x : α) (_ : x ∈ A), ball x V) (⋃ (x : α) (_ : x ∈ B), ball x V)
[PROOFSTEP]
rw [(hA.nhdsSet_basis_uniformity (Filter.basis_sets _)).mem_iff] at this
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
A B : Set α
hA : IsCompact A
hB : IsClosed B
h : Disjoint A B
this : ∃ i, i ∈ 𝓤 α ∧ ⋃ (x : α) (_ : x ∈ A), ball x (id i) ⊆ Bᶜ
⊢ ∃ V, V ∈ 𝓤 α ∧ Disjoint (⋃ (x : α) (_ : x ∈ A), ball x V) (⋃ (x : α) (_ : x ∈ B), ball x V)
[PROOFSTEP]
rcases this with ⟨U, hU, hUAB⟩
[GOAL]
case intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
A B : Set α
hA : IsCompact A
hB : IsClosed B
h : Disjoint A B
U : Set (α × α)
hU : U ∈ 𝓤 α
hUAB : ⋃ (x : α) (_ : x ∈ A), ball x (id U) ⊆ Bᶜ
⊢ ∃ V, V ∈ 𝓤 α ∧ Disjoint (⋃ (x : α) (_ : x ∈ A), ball x V) (⋃ (x : α) (_ : x ∈ B), ball x V)
[PROOFSTEP]
rcases comp_symm_mem_uniformity_sets hU with ⟨V, hV, hVsymm, hVU⟩
[GOAL]
case intro.intro.intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
A B : Set α
hA : IsCompact A
hB : IsClosed B
h : Disjoint A B
U : Set (α × α)
hU : U ∈ 𝓤 α
hUAB : ⋃ (x : α) (_ : x ∈ A), ball x (id U) ⊆ Bᶜ
V : Set (α × α)
hV : V ∈ 𝓤 α
hVsymm : SymmetricRel V
hVU : V ○ V ⊆ U
⊢ ∃ V, V ∈ 𝓤 α ∧ Disjoint (⋃ (x : α) (_ : x ∈ A), ball x V) (⋃ (x : α) (_ : x ∈ B), ball x V)
[PROOFSTEP]
refine' ⟨V, hV, Set.disjoint_left.mpr fun x => _⟩
[GOAL]
case intro.intro.intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
A B : Set α
hA : IsCompact A
hB : IsClosed B
h : Disjoint A B
U : Set (α × α)
hU : U ∈ 𝓤 α
hUAB : ⋃ (x : α) (_ : x ∈ A), ball x (id U) ⊆ Bᶜ
V : Set (α × α)
hV : V ∈ 𝓤 α
hVsymm : SymmetricRel V
hVU : V ○ V ⊆ U
x : α
⊢ x ∈ ⋃ (x : α) (_ : x ∈ A), ball x V → ¬x ∈ ⋃ (x : α) (_ : x ∈ B), ball x V
[PROOFSTEP]
simp only [mem_iUnion₂]
[GOAL]
case intro.intro.intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
A B : Set α
hA : IsCompact A
hB : IsClosed B
h : Disjoint A B
U : Set (α × α)
hU : U ∈ 𝓤 α
hUAB : ⋃ (x : α) (_ : x ∈ A), ball x (id U) ⊆ Bᶜ
V : Set (α × α)
hV : V ∈ 𝓤 α
hVsymm : SymmetricRel V
hVU : V ○ V ⊆ U
x : α
⊢ (∃ i j, x ∈ ball i V) → ¬∃ i j, x ∈ ball i V
[PROOFSTEP]
rintro ⟨a, ha, hxa⟩ ⟨b, hb, hxb⟩
[GOAL]
case intro.intro.intro.intro.intro.intro.intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
A B : Set α
hA : IsCompact A
hB : IsClosed B
h : Disjoint A B
U : Set (α × α)
hU : U ∈ 𝓤 α
hUAB : ⋃ (x : α) (_ : x ∈ A), ball x (id U) ⊆ Bᶜ
V : Set (α × α)
hV : V ∈ 𝓤 α
hVsymm : SymmetricRel V
hVU : V ○ V ⊆ U
x a : α
ha : a ∈ A
hxa : x ∈ ball a V
b : α
hb : b ∈ B
hxb : x ∈ ball b V
⊢ False
[PROOFSTEP]
rw [mem_ball_symmetry hVsymm] at hxa hxb
[GOAL]
case intro.intro.intro.intro.intro.intro.intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
A B : Set α
hA : IsCompact A
hB : IsClosed B
h : Disjoint A B
U : Set (α × α)
hU : U ∈ 𝓤 α
hUAB : ⋃ (x : α) (_ : x ∈ A), ball x (id U) ⊆ Bᶜ
V : Set (α × α)
hV : V ∈ 𝓤 α
hVsymm : SymmetricRel V
hVU : V ○ V ⊆ U
x a : α
ha : a ∈ A
hxa : a ∈ ball x V
b : α
hb : b ∈ B
hxb : b ∈ ball x V
⊢ False
[PROOFSTEP]
exact hUAB (mem_iUnion₂_of_mem ha <| hVU <| mem_comp_of_mem_ball hVsymm hxa hxb) hb
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
s : ι → Set (α × α)
hU : HasBasis (𝓤 α) p s
A B : Set α
hA : IsCompact A
hB : IsClosed B
h : Disjoint A B
⊢ ∃ i, p i ∧ Disjoint (⋃ (x : α) (_ : x ∈ A), ball x (s i)) (⋃ (x : α) (_ : x ∈ B), ball x (s i))
[PROOFSTEP]
rcases h.exists_uniform_thickening hA hB with ⟨V, hV, hVAB⟩
[GOAL]
case intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
s : ι → Set (α × α)
hU : HasBasis (𝓤 α) p s
A B : Set α
hA : IsCompact A
hB : IsClosed B
h : Disjoint A B
V : Set (α × α)
hV : V ∈ 𝓤 α
hVAB : Disjoint (⋃ (x : α) (_ : x ∈ A), ball x V) (⋃ (x : α) (_ : x ∈ B), ball x V)
⊢ ∃ i, p i ∧ Disjoint (⋃ (x : α) (_ : x ∈ A), ball x (s i)) (⋃ (x : α) (_ : x ∈ B), ball x (s i))
[PROOFSTEP]
rcases hU.mem_iff.1 hV with ⟨i, hi, hiV⟩
[GOAL]
case intro.intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
s : ι → Set (α × α)
hU : HasBasis (𝓤 α) p s
A B : Set α
hA : IsCompact A
hB : IsClosed B
h : Disjoint A B
V : Set (α × α)
hV : V ∈ 𝓤 α
hVAB : Disjoint (⋃ (x : α) (_ : x ∈ A), ball x V) (⋃ (x : α) (_ : x ∈ B), ball x V)
i : ι
hi : p i
hiV : s i ⊆ V
⊢ ∃ i, p i ∧ Disjoint (⋃ (x : α) (_ : x ∈ A), ball x (s i)) (⋃ (x : α) (_ : x ∈ B), ball x (s i))
[PROOFSTEP]
exact ⟨i, hi, hVAB.mono (iUnion₂_mono fun a _ => ball_mono hiV a) (iUnion₂_mono fun b _ => ball_mono hiV b)⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
g : Set α → Filter β
hg : Monotone g
⊢ Filter.lift (𝓝 x) g = Filter.lift (𝓤 α) fun s => g (ball x s)
[PROOFSTEP]
rw [nhds_eq_comap_uniformity, comap_lift_eq2 hg]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
g : Set α → Filter β
hg : Monotone g
⊢ Filter.lift (𝓤 α) (g ∘ preimage (Prod.mk x)) = Filter.lift (𝓤 α) fun s => g (ball x s)
[PROOFSTEP]
simp_rw [ball, Function.comp]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
g : Set α → Filter β
hg : Monotone g
⊢ Filter.lift (𝓝 x) g = Filter.lift (𝓤 α) fun s => g {y | (y, x) ∈ s}
[PROOFSTEP]
rw [nhds_eq_comap_uniformity', comap_lift_eq2 hg]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
g : Set α → Filter β
hg : Monotone g
⊢ Filter.lift (𝓤 α) (g ∘ preimage fun y => (y, x)) = Filter.lift (𝓤 α) fun s => g {y | (y, x) ∈ s}
[PROOFSTEP]
simp_rw [Function.comp, preimage]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
a b : α
⊢ 𝓝 a ×ˢ 𝓝 b = Filter.lift (𝓤 α) fun s => Filter.lift' (𝓤 α) fun t => {y | (y, a) ∈ s} ×ˢ {y | (b, y) ∈ t}
[PROOFSTEP]
rw [nhds_eq_uniformity', nhds_eq_uniformity, prod_lift'_lift']
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
a b : α
⊢ (Filter.lift (𝓤 α) fun s => Filter.lift' (𝓤 α) fun t => {y | (y, a) ∈ s} ×ˢ ball b t) =
Filter.lift (𝓤 α) fun s => Filter.lift' (𝓤 α) fun t => {y | (y, a) ∈ s} ×ˢ {y | (b, y) ∈ t}
case hg₁
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
a b : α
⊢ Monotone fun s => {y | (y, a) ∈ s}
case hg₂ α : Type ua β : Type ub γ : Type uc δ : Type ud ι : Sort u_1 inst✝ : UniformSpace α a b : α ⊢ Monotone (ball b)
[PROOFSTEP]
exacts [rfl, monotone_preimage, monotone_preimage]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
a b : α
⊢ 𝓝 (a, b) = Filter.lift' (𝓤 α) fun s => {y | (y, a) ∈ s} ×ˢ {y | (b, y) ∈ s}
[PROOFSTEP]
rw [nhds_prod_eq, nhds_nhds_eq_uniformity_uniformity_prod, lift_lift'_same_eq_lift']
[GOAL]
case hg₁
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
a b : α
⊢ ∀ (s : Set (α × α)), Monotone fun t => {y | (y, a) ∈ s} ×ˢ {y | (b, y) ∈ t}
[PROOFSTEP]
exact fun s => monotone_const.set_prod monotone_preimage
[GOAL]
case hg₂
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
a b : α
⊢ ∀ (t : Set (α × α)), Monotone fun s => {y | (y, a) ∈ s} ×ˢ {y | (b, y) ∈ t}
[PROOFSTEP]
refine fun t => Monotone.set_prod ?_ monotone_const
[GOAL]
case hg₂
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
a b : α
t : Set (α × α)
⊢ Monotone fun s => {y | (y, a) ∈ s}
[PROOFSTEP]
exact monotone_preimage (f := fun y => (y, a))
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
d s : Set (α × α)
hd : d ∈ 𝓤 α
⊢ ∃ t, IsOpen t ∧ s ⊆ t ∧ t ⊆ {p | ∃ x y, (p.fst, x) ∈ d ∧ (x, y) ∈ s ∧ (y, p.snd) ∈ d}
[PROOFSTEP]
let cl_d := {p : α × α | ∃ x y, (p.1, x) ∈ d ∧ (x, y) ∈ s ∧ (y, p.2) ∈ d}
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
d s : Set (α × α)
hd : d ∈ 𝓤 α
cl_d : Set (α × α) := {p | ∃ x y, (p.fst, x) ∈ d ∧ (x, y) ∈ s ∧ (y, p.snd) ∈ d}
⊢ ∃ t, IsOpen t ∧ s ⊆ t ∧ t ⊆ {p | ∃ x y, (p.fst, x) ∈ d ∧ (x, y) ∈ s ∧ (y, p.snd) ∈ d}
[PROOFSTEP]
have : ∀ p ∈ s, ∃ t, t ⊆ cl_d ∧ IsOpen t ∧ p ∈ t := fun ⟨x, y⟩ hp =>
mem_nhds_iff.mp <|
show cl_d ∈ 𝓝 (x, y) by
rw [nhds_eq_uniformity_prod, mem_lift'_sets]
· exact ⟨d, hd, fun ⟨a, b⟩ ⟨ha, hb⟩ => ⟨x, y, ha, hp, hb⟩⟩
· exact fun _ _ h _ h' => ⟨h h'.1, h h'.2⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
d s : Set (α × α)
hd : d ∈ 𝓤 α
cl_d : Set (α × α) := {p | ∃ x y, (p.fst, x) ∈ d ∧ (x, y) ∈ s ∧ (y, p.snd) ∈ d}
x✝ : α × α
x y : α
hp : (x, y) ∈ s
⊢ cl_d ∈ 𝓝 (x, y)
[PROOFSTEP]
rw [nhds_eq_uniformity_prod, mem_lift'_sets]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
d s : Set (α × α)
hd : d ∈ 𝓤 α
cl_d : Set (α × α) := {p | ∃ x y, (p.fst, x) ∈ d ∧ (x, y) ∈ s ∧ (y, p.snd) ∈ d}
x✝ : α × α
x y : α
hp : (x, y) ∈ s
⊢ ∃ t, t ∈ 𝓤 α ∧ {y | (y, x) ∈ t} ×ˢ {y_1 | (y, y_1) ∈ t} ⊆ cl_d
[PROOFSTEP]
exact ⟨d, hd, fun ⟨a, b⟩ ⟨ha, hb⟩ => ⟨x, y, ha, hp, hb⟩⟩
[GOAL]
case hh
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
d s : Set (α × α)
hd : d ∈ 𝓤 α
cl_d : Set (α × α) := {p | ∃ x y, (p.fst, x) ∈ d ∧ (x, y) ∈ s ∧ (y, p.snd) ∈ d}
x✝ : α × α
x y : α
hp : (x, y) ∈ s
⊢ Monotone fun s => {y | (y, x) ∈ s} ×ˢ {y_1 | (y, y_1) ∈ s}
[PROOFSTEP]
exact fun _ _ h _ h' => ⟨h h'.1, h h'.2⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
d s : Set (α × α)
hd : d ∈ 𝓤 α
cl_d : Set (α × α) := {p | ∃ x y, (p.fst, x) ∈ d ∧ (x, y) ∈ s ∧ (y, p.snd) ∈ d}
this : ∀ (p : α × α), p ∈ s → ∃ t, t ⊆ cl_d ∧ IsOpen t ∧ p ∈ t
⊢ ∃ t, IsOpen t ∧ s ⊆ t ∧ t ⊆ {p | ∃ x y, (p.fst, x) ∈ d ∧ (x, y) ∈ s ∧ (y, p.snd) ∈ d}
[PROOFSTEP]
choose t ht using this
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
d s : Set (α × α)
hd : d ∈ 𝓤 α
cl_d : Set (α × α) := {p | ∃ x y, (p.fst, x) ∈ d ∧ (x, y) ∈ s ∧ (y, p.snd) ∈ d}
t : (p : α × α) → p ∈ s → Set (α × α)
ht : ∀ (p : α × α) (a : p ∈ s), t p a ⊆ cl_d ∧ IsOpen (t p a) ∧ p ∈ t p a
⊢ ∃ t, IsOpen t ∧ s ⊆ t ∧ t ⊆ {p | ∃ x y, (p.fst, x) ∈ d ∧ (x, y) ∈ s ∧ (y, p.snd) ∈ d}
[PROOFSTEP]
exact
⟨(⋃ p : α × α, ⋃ h : p ∈ s, t p h : Set (α × α)),
isOpen_iUnion fun p : α × α => isOpen_iUnion fun hp => (ht p hp).right.left, fun ⟨a, b⟩ hp => by
simp only [mem_iUnion, Prod.exists]; exact ⟨a, b, hp, (ht (a, b) hp).right.right⟩,
iUnion_subset fun p => iUnion_subset fun hp => (ht p hp).left⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
d s : Set (α × α)
hd : d ∈ 𝓤 α
cl_d : Set (α × α) := {p | ∃ x y, (p.fst, x) ∈ d ∧ (x, y) ∈ s ∧ (y, p.snd) ∈ d}
t : (p : α × α) → p ∈ s → Set (α × α)
ht : ∀ (p : α × α) (a : p ∈ s), t p a ⊆ cl_d ∧ IsOpen (t p a) ∧ p ∈ t p a
x✝ : α × α
a b : α
hp : (a, b) ∈ s
⊢ (a, b) ∈ ⋃ (p : α × α) (h : p ∈ s), t p h
[PROOFSTEP]
simp only [mem_iUnion, Prod.exists]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
d s : Set (α × α)
hd : d ∈ 𝓤 α
cl_d : Set (α × α) := {p | ∃ x y, (p.fst, x) ∈ d ∧ (x, y) ∈ s ∧ (y, p.snd) ∈ d}
t : (p : α × α) → p ∈ s → Set (α × α)
ht : ∀ (p : α × α) (a : p ∈ s), t p a ⊆ cl_d ∧ IsOpen (t p a) ∧ p ∈ t p a
x✝ : α × α
a b : α
hp : (a, b) ∈ s
⊢ ∃ a_1 b_1 i, (a, b) ∈ t (a_1, b_1) i
[PROOFSTEP]
exact ⟨a, b, hp, (ht (a, b) hp).right.right⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
⊢ 𝓝 (x, x) ≤ 𝓤 α
[PROOFSTEP]
intro V V_in
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
V : Set (α × α)
V_in : V ∈ 𝓤 α
⊢ V ∈ 𝓝 (x, x)
[PROOFSTEP]
rcases comp_symm_mem_uniformity_sets V_in with ⟨w, w_in, w_symm, w_sub⟩
[GOAL]
case intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
V : Set (α × α)
V_in : V ∈ 𝓤 α
w : Set (α × α)
w_in : w ∈ 𝓤 α
w_symm : SymmetricRel w
w_sub : w ○ w ⊆ V
⊢ V ∈ 𝓝 (x, x)
[PROOFSTEP]
have : ball x w ×ˢ ball x w ∈ 𝓝 (x, x)
[GOAL]
case this
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
V : Set (α × α)
V_in : V ∈ 𝓤 α
w : Set (α × α)
w_in : w ∈ 𝓤 α
w_symm : SymmetricRel w
w_sub : w ○ w ⊆ V
⊢ ball x w ×ˢ ball x w ∈ 𝓝 (x, x)
[PROOFSTEP]
rw [nhds_prod_eq]
[GOAL]
case this
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
V : Set (α × α)
V_in : V ∈ 𝓤 α
w : Set (α × α)
w_in : w ∈ 𝓤 α
w_symm : SymmetricRel w
w_sub : w ○ w ⊆ V
⊢ ball x w ×ˢ ball x w ∈ 𝓝 x ×ˢ 𝓝 x
[PROOFSTEP]
exact prod_mem_prod (ball_mem_nhds x w_in) (ball_mem_nhds x w_in)
[GOAL]
case intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
V : Set (α × α)
V_in : V ∈ 𝓤 α
w : Set (α × α)
w_in : w ∈ 𝓤 α
w_symm : SymmetricRel w
w_sub : w ○ w ⊆ V
this : ball x w ×ˢ ball x w ∈ 𝓝 (x, x)
⊢ V ∈ 𝓝 (x, x)
[PROOFSTEP]
apply mem_of_superset this
[GOAL]
case intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
V : Set (α × α)
V_in : V ∈ 𝓤 α
w : Set (α × α)
w_in : w ∈ 𝓤 α
w_symm : SymmetricRel w
w_sub : w ○ w ⊆ V
this : ball x w ×ˢ ball x w ∈ 𝓝 (x, x)
⊢ ball x w ×ˢ ball x w ⊆ V
[PROOFSTEP]
rintro ⟨u, v⟩ ⟨u_in, v_in⟩
[GOAL]
case intro.intro.intro.mk.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
x : α
V : Set (α × α)
V_in : V ∈ 𝓤 α
w : Set (α × α)
w_in : w ∈ 𝓤 α
w_symm : SymmetricRel w
w_sub : w ○ w ⊆ V
this : ball x w ×ˢ ball x w ∈ 𝓝 (x, x)
u v : α
u_in : (u, v).fst ∈ ball x w
v_in : (u, v).snd ∈ ball x w
⊢ (u, v) ∈ V
[PROOFSTEP]
exact w_sub (mem_comp_of_mem_ball w_symm u_in v_in)
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set (α × α)
⊢ closure s = ⋂ (V : Set (α × α)) (_ : V ∈ {V | V ∈ 𝓤 α ∧ SymmetricRel V}), V ○ s ○ V
[PROOFSTEP]
ext ⟨x, y⟩
[GOAL]
case h.mk
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set (α × α)
x y : α
⊢ (x, y) ∈ closure s ↔ (x, y) ∈ ⋂ (V : Set (α × α)) (_ : V ∈ {V | V ∈ 𝓤 α ∧ SymmetricRel V}), V ○ s ○ V
[PROOFSTEP]
simp (config := { contextual := true }) only [mem_closure_iff_nhds_basis (UniformSpace.hasBasis_nhds_prod x y),
mem_iInter, mem_setOf_eq, and_imp, mem_comp_comp, exists_prop, ← mem_inter_iff, inter_comm, Set.Nonempty]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
⊢ HasBasis (𝓤 α) (fun V => V ∈ 𝓤 α ∧ IsClosed V) id
[PROOFSTEP]
refine' Filter.hasBasis_self.2 fun t h => _
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
t : Set (α × α)
h : t ∈ 𝓤 α
⊢ ∃ r, r ∈ 𝓤 α ∧ IsClosed r ∧ r ⊆ t
[PROOFSTEP]
rcases comp_comp_symm_mem_uniformity_sets h with ⟨w, w_in, w_symm, r⟩
[GOAL]
case intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
t : Set (α × α)
h : t ∈ 𝓤 α
w : Set (α × α)
w_in : w ∈ 𝓤 α
w_symm : SymmetricRel w
r : w ○ w ○ w ⊆ t
⊢ ∃ r, r ∈ 𝓤 α ∧ IsClosed r ∧ r ⊆ t
[PROOFSTEP]
refine' ⟨closure w, mem_of_superset w_in subset_closure, isClosed_closure, _⟩
[GOAL]
case intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
t : Set (α × α)
h : t ∈ 𝓤 α
w : Set (α × α)
w_in : w ∈ 𝓤 α
w_symm : SymmetricRel w
r : w ○ w ○ w ⊆ t
⊢ closure w ⊆ t
[PROOFSTEP]
refine' Subset.trans _ r
[GOAL]
case intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
t : Set (α × α)
h : t ∈ 𝓤 α
w : Set (α × α)
w_in : w ∈ 𝓤 α
w_symm : SymmetricRel w
r : w ○ w ○ w ⊆ t
⊢ closure w ⊆ w ○ w ○ w
[PROOFSTEP]
rw [closure_eq_uniformity]
[GOAL]
case intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
t : Set (α × α)
h : t ∈ 𝓤 α
w : Set (α × α)
w_in : w ∈ 𝓤 α
w_symm : SymmetricRel w
r : w ○ w ○ w ⊆ t
⊢ ⋂ (V : Set (α × α)) (_ : V ∈ {V | V ∈ 𝓤 α ∧ SymmetricRel V}), V ○ w ○ V ⊆ w ○ w ○ w
[PROOFSTEP]
apply iInter_subset_of_subset
[GOAL]
case intro.intro.intro.h
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
t : Set (α × α)
h : t ∈ 𝓤 α
w : Set (α × α)
w_in : w ∈ 𝓤 α
w_symm : SymmetricRel w
r : w ○ w ○ w ⊆ t
⊢ ⋂ (_ : ?intro.intro.intro.i ∈ {V | V ∈ 𝓤 α ∧ SymmetricRel V}), ?intro.intro.intro.i ○ w ○ ?intro.intro.intro.i ⊆
w ○ w ○ w
case intro.intro.intro.i
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
t : Set (α × α)
h : t ∈ 𝓤 α
w : Set (α × α)
w_in : w ∈ 𝓤 α
w_symm : SymmetricRel w
r : w ○ w ○ w ⊆ t
⊢ Set (α × α)
[PROOFSTEP]
apply iInter_subset
[GOAL]
case intro.intro.intro.h.i
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
t : Set (α × α)
h : t ∈ 𝓤 α
w : Set (α × α)
w_in : w ∈ 𝓤 α
w_symm : SymmetricRel w
r : w ○ w ○ w ⊆ t
⊢ w ∈ {V | V ∈ 𝓤 α ∧ SymmetricRel V}
[PROOFSTEP]
exact ⟨w_in, w_symm⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
t : Set (α × α)
⊢ ⋂ (V : Set (α × α)) (_ : V ∈ 𝓤 α), V ○ t ○ V = ⋂ (V : Set (α × α)) (_ : V ∈ 𝓤 α), V ○ (t ○ V)
[PROOFSTEP]
simp only [compRel_assoc]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
d : Set (α × α)
hd : d ∈ 𝓤 α
⊢ 𝓤 α ≤ (𝓟 ∘ interior) d
[PROOFSTEP]
let ⟨s, hs, hs_comp⟩ := comp3_mem_uniformity hd
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
d : Set (α × α)
hd : d ∈ 𝓤 α
s : Set (α × α)
hs : s ∈ 𝓤 α
hs_comp : s ○ (s ○ s) ⊆ d
⊢ 𝓤 α ≤ (𝓟 ∘ interior) d
[PROOFSTEP]
let ⟨t, ht, hst, ht_comp⟩ := nhdset_of_mem_uniformity s hs
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
d : Set (α × α)
hd : d ∈ 𝓤 α
s : Set (α × α)
hs : s ∈ 𝓤 α
hs_comp : s ○ (s ○ s) ⊆ d
t : Set (α × α)
ht : IsOpen t
hst : s ⊆ t
ht_comp : t ⊆ {p | ∃ x y, (p.fst, x) ∈ s ∧ (x, y) ∈ s ∧ (y, p.snd) ∈ s}
⊢ 𝓤 α ≤ (𝓟 ∘ interior) d
[PROOFSTEP]
have : s ⊆ interior d :=
calc
s ⊆ t := hst
_ ⊆ interior d :=
ht.subset_interior_iff.mpr fun x (hx : x ∈ t) =>
let ⟨x, y, h₁, h₂, h₃⟩ := ht_comp hx
hs_comp ⟨x, h₁, y, h₂, h₃⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
d : Set (α × α)
hd : d ∈ 𝓤 α
s : Set (α × α)
hs : s ∈ 𝓤 α
hs_comp : s ○ (s ○ s) ⊆ d
t : Set (α × α)
ht : IsOpen t
hst : s ⊆ t
ht_comp : t ⊆ {p | ∃ x y, (p.fst, x) ∈ s ∧ (x, y) ∈ s ∧ (y, p.snd) ∈ s}
this : s ⊆ interior d
⊢ 𝓤 α ≤ (𝓟 ∘ interior) d
[PROOFSTEP]
have : interior d ∈ 𝓤 α := by filter_upwards [hs] using this
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
d : Set (α × α)
hd : d ∈ 𝓤 α
s : Set (α × α)
hs : s ∈ 𝓤 α
hs_comp : s ○ (s ○ s) ⊆ d
t : Set (α × α)
ht : IsOpen t
hst : s ⊆ t
ht_comp : t ⊆ {p | ∃ x y, (p.fst, x) ∈ s ∧ (x, y) ∈ s ∧ (y, p.snd) ∈ s}
this : s ⊆ interior d
⊢ interior d ∈ 𝓤 α
[PROOFSTEP]
filter_upwards [hs] using this
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
d : Set (α × α)
hd : d ∈ 𝓤 α
s : Set (α × α)
hs : s ∈ 𝓤 α
hs_comp : s ○ (s ○ s) ⊆ d
t : Set (α × α)
ht : IsOpen t
hst : s ⊆ t
ht_comp : t ⊆ {p | ∃ x y, (p.fst, x) ∈ s ∧ (x, y) ∈ s ∧ (y, p.snd) ∈ s}
this✝ : s ⊆ interior d
this : interior d ∈ 𝓤 α
⊢ 𝓤 α ≤ (𝓟 ∘ interior) d
[PROOFSTEP]
simp [this]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set (α × α)
hs : s ∈ 𝓤 α
⊢ interior s ∈ 𝓤 α
[PROOFSTEP]
rw [uniformity_eq_uniformity_interior]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set (α × α)
hs : s ∈ 𝓤 α
⊢ interior s ∈ Filter.lift' (𝓤 α) interior
[PROOFSTEP]
exact mem_lift' hs
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set α
⊢ IsOpen s ↔ ∀ (x : α), x ∈ s → ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ ball x V ⊆ s
[PROOFSTEP]
rw [isOpen_iff_ball_subset]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set α
⊢ (∀ (x : α), x ∈ s → ∃ V, V ∈ 𝓤 α ∧ ball x V ⊆ s) ↔ ∀ (x : α), x ∈ s → ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ ball x V ⊆ s
[PROOFSTEP]
constructor
[GOAL]
case mp
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set α
⊢ (∀ (x : α), x ∈ s → ∃ V, V ∈ 𝓤 α ∧ ball x V ⊆ s) → ∀ (x : α), x ∈ s → ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ ball x V ⊆ s
[PROOFSTEP]
intro h x hx
[GOAL]
case mpr
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set α
⊢ (∀ (x : α), x ∈ s → ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ ball x V ⊆ s) → ∀ (x : α), x ∈ s → ∃ V, V ∈ 𝓤 α ∧ ball x V ⊆ s
[PROOFSTEP]
intro h x hx
[GOAL]
case mp
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set α
h : ∀ (x : α), x ∈ s → ∃ V, V ∈ 𝓤 α ∧ ball x V ⊆ s
x : α
hx : x ∈ s
⊢ ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ ball x V ⊆ s
[PROOFSTEP]
obtain ⟨V, hV, hV'⟩ := h x hx
[GOAL]
case mp.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set α
h : ∀ (x : α), x ∈ s → ∃ V, V ∈ 𝓤 α ∧ ball x V ⊆ s
x : α
hx : x ∈ s
V : Set (α × α)
hV : V ∈ 𝓤 α
hV' : ball x V ⊆ s
⊢ ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ ball x V ⊆ s
[PROOFSTEP]
exact ⟨interior V, interior_mem_uniformity hV, isOpen_interior, (ball_mono interior_subset x).trans hV'⟩
[GOAL]
case mpr
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set α
h : ∀ (x : α), x ∈ s → ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ ball x V ⊆ s
x : α
hx : x ∈ s
⊢ ∃ V, V ∈ 𝓤 α ∧ ball x V ⊆ s
[PROOFSTEP]
obtain ⟨V, hV, -, hV'⟩ := h x hx
[GOAL]
case mpr.intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set α
h : ∀ (x : α), x ∈ s → ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ ball x V ⊆ s
x : α
hx : x ∈ s
V : Set (α × α)
hV : V ∈ 𝓤 α
hV' : ball x V ⊆ s
⊢ ∃ V, V ∈ 𝓤 α ∧ ball x V ⊆ s
[PROOFSTEP]
exact ⟨V, hV, hV'⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set α
U : Set (α × α)
hs : Dense s
hU : U ∈ 𝓤 α
⊢ ⋃ (x : α) (_ : x ∈ s), ball x U = univ
[PROOFSTEP]
refine' iUnion₂_eq_univ_iff.2 fun y => _
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set α
U : Set (α × α)
hs : Dense s
hU : U ∈ 𝓤 α
y : α
⊢ ∃ i j, y ∈ ball i U
[PROOFSTEP]
rcases hs.inter_nhds_nonempty (mem_nhds_right y hU) with ⟨x, hxs, hxy : (x, y) ∈ U⟩
[GOAL]
case intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set α
U : Set (α × α)
hs : Dense s
hU : U ∈ 𝓤 α
y x : α
hxs : x ∈ s
hxy : (x, y) ∈ U
⊢ ∃ i j, y ∈ ball i U
[PROOFSTEP]
exact ⟨x, hxs, hxy⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : β → Prop
s : β → Set (α × α)
h : HasBasis (𝓤 α) p s
t : Set (α × α)
⊢ (∃ i, p i ∧ s i ⊆ t) ↔ ∃ i, p i ∧ ∀ (a b : α), (a, b) ∈ s i → (a, b) ∈ t
[PROOFSTEP]
simp only [Prod.forall, subset_def]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
⊢ HasBasis (𝓤 α) (fun V => V ∈ 𝓤 α ∧ IsOpen V ∧ SymmetricRel V) id
[PROOFSTEP]
simp only [← and_assoc]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
⊢ HasBasis (𝓤 α) (fun V => (V ∈ 𝓤 α ∧ IsOpen V) ∧ SymmetricRel V) id
[PROOFSTEP]
refine' uniformity_hasBasis_open.restrict fun s hs => ⟨symmetrizeRel s, _⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set (α × α)
hs : s ∈ 𝓤 α ∧ IsOpen s
⊢ (symmetrizeRel s ∈ 𝓤 α ∧ IsOpen (symmetrizeRel s)) ∧ SymmetricRel (symmetrizeRel s) ∧ id (symmetrizeRel s) ⊆ id s
[PROOFSTEP]
exact
⟨⟨symmetrize_mem_uniformity hs.1, IsOpen.inter hs.2 (hs.2.preimage continuous_swap)⟩, symmetric_symmetrizeRel s,
symmetrizeRel_subset_self s⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set (α × α)
hs : s ∈ 𝓤 α
⊢ ∃ t, t ∈ 𝓤 α ∧ IsOpen t ∧ SymmetricRel t ∧ t ○ t ⊆ s
[PROOFSTEP]
obtain ⟨t, ht₁, ht₂⟩ := comp_mem_uniformity_sets hs
[GOAL]
case intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set (α × α)
hs : s ∈ 𝓤 α
t : Set (α × α)
ht₁ : t ∈ 𝓤 α
ht₂ : t ○ t ⊆ s
⊢ ∃ t, t ∈ 𝓤 α ∧ IsOpen t ∧ SymmetricRel t ∧ t ○ t ⊆ s
[PROOFSTEP]
obtain ⟨u, ⟨hu₁, hu₂, hu₃⟩, hu₄ : u ⊆ t⟩ := uniformity_hasBasis_open_symmetric.mem_iff.mp ht₁
[GOAL]
case intro.intro.intro.intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
s : Set (α × α)
hs : s ∈ 𝓤 α
t : Set (α × α)
ht₁ : t ∈ 𝓤 α
ht₂ : t ○ t ⊆ s
u : Set (α × α)
hu₄ : u ⊆ t
hu₁ : u ∈ 𝓤 α
hu₂ : IsOpen u
hu₃ : SymmetricRel u
⊢ ∃ t, t ∈ 𝓤 α ∧ IsOpen t ∧ SymmetricRel t ∧ t ○ t ⊆ s
[PROOFSTEP]
exact ⟨u, hu₁, hu₂, hu₃, (compRel_mono hu₄ hu₄).trans ht₂⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
U : ι → Set (α × α)
h : HasBasis (𝓤 α) p U
s : Set α
⊢ ⋂ (i : ι) (_ : p i), ⋃ (x : α) (_ : x ∈ s), ball x (U i) = closure s
[PROOFSTEP]
ext x
[GOAL]
case h
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
p : ι → Prop
U : ι → Set (α × α)
h : HasBasis (𝓤 α) p U
s : Set α
x : α
⊢ x ∈ ⋂ (i : ι) (_ : p i), ⋃ (x : α) (_ : x ∈ s), ball x (U i) ↔ x ∈ closure s
[PROOFSTEP]
simp [mem_closure_iff_nhds_basis (nhds_basis_uniformity h), ball]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
f : α → β
⊢ UniformContinuousOn f univ ↔ UniformContinuous f
[PROOFSTEP]
rw [UniformContinuousOn, UniformContinuous, univ_prod_univ, principal_univ, inf_top_eq]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
c : α → β
h : ∀ (a b : α), c a = c b
this : (fun x => (c x.fst, c x.snd)) ⁻¹' idRel = univ
⊢ 𝓤 α ≤ comap (fun x => (c x.fst, c x.snd)) (𝓟 idRel)
[PROOFSTEP]
simp [comap_principal, this, univ_mem]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
ι' : Sort u_2
inst✝ : UniformSpace β
p : ι → Prop
s : ι → Set (α × α)
ha : HasBasis (𝓤 α) p s
q : ι' → Prop
t : ι' → Set (β × β)
hb : HasBasis (𝓤 β) q t
f : α → β
⊢ (∀ (ib : ι'), q ib → ∃ ia, p ia ∧ ∀ (x : α × α), x ∈ s ia → (f x.fst, f x.snd) ∈ t ib) ↔
∀ (i : ι'), q i → ∃ j, p j ∧ ∀ (x y : α), (x, y) ∈ s j → (f x, f y) ∈ t i
[PROOFSTEP]
simp only [Prod.forall]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
ι' : Sort u_2
inst✝ : UniformSpace β
p : ι → Prop
s : ι → Set (α × α)
ha : HasBasis (𝓤 α) p s
q : ι' → Prop
t : ι' → Set (β × β)
hb : HasBasis (𝓤 β) q t
f : α → β
S : Set α
⊢ (∀ (ib : ι'), q ib → ∃ ia, p ia ∧ ∀ (x : α × α), x ∈ s ia ∩ S ×ˢ S → (f x.fst, f x.snd) ∈ t ib) ↔
∀ (i : ι'), q i → ∃ j, p j ∧ ∀ (x : α), x ∈ S → ∀ (y : α), y ∈ S → (x, y) ∈ s j → (f x, f y) ∈ t i
[PROOFSTEP]
simp_rw [Prod.forall, Set.inter_comm (s _), ball_mem_comm, mem_inter_iff, mem_prod, and_imp]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
⊢ Tendsto Prod.swap (𝓟 idRel) (𝓟 idRel)
[PROOFSTEP]
simp [Tendsto]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
s : Set α
⊢ IsOpen s ↔
∀ (x : α),
x ∈ s →
{p | p.fst = x → p.snd ∈ s} ∈
{ uniformity := 𝓟 idRel, refl := (_ : 𝓟 idRel ≤ 𝓟 idRel), symm := (_ : map Prod.swap (𝓟 idRel) ≤ 𝓟 idRel),
comp := (_ : (Filter.lift' (𝓟 idRel) fun s => s ○ s) ≤ 𝓟 idRel) }.uniformity
[PROOFSTEP]
let _ : TopologicalSpace α := ⊥
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
s : Set α
x✝ : TopologicalSpace α := ⊥
⊢ IsOpen s ↔
∀ (x : α),
x ∈ s →
{p | p.fst = x → p.snd ∈ s} ∈
{ uniformity := 𝓟 idRel, refl := (_ : 𝓟 idRel ≤ 𝓟 idRel), symm := (_ : map Prod.swap (𝓟 idRel) ≤ 𝓟 idRel),
comp := (_ : (Filter.lift' (𝓟 idRel) fun s => s ○ s) ≤ 𝓟 idRel) }.uniformity
[PROOFSTEP]
have := discreteTopology_bot α
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
s : Set α
x✝ : TopologicalSpace α := ⊥
this : DiscreteTopology α
⊢ IsOpen s ↔
∀ (x : α),
x ∈ s →
{p | p.fst = x → p.snd ∈ s} ∈
{ uniformity := 𝓟 idRel, refl := (_ : 𝓟 idRel ≤ 𝓟 idRel), symm := (_ : map Prod.swap (𝓟 idRel) ≤ 𝓟 idRel),
comp := (_ : (Filter.lift' (𝓟 idRel) fun s => s ○ s) ≤ 𝓟 idRel) }.uniformity
[PROOFSTEP]
simp [subset_def, idRel]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
u₁ u₂ : UniformSpace α
x✝ : α
⊢ 𝓝 x✝ =
comap (Prod.mk x✝)
{ uniformity := u₁.uniformity ⊓ u₂.uniformity, refl := (_ : 𝓟 idRel ≤ u₁.uniformity ⊓ u₂.uniformity),
symm := (_ : Tendsto Prod.swap (u₁.uniformity ⊓ u₂.uniformity) (u₁.uniformity ⊓ u₂.uniformity)),
comp :=
(_ :
(Filter.lift' (u₁.uniformity ⊓ u₂.uniformity) fun s => s ○ s) ≤
u₁.uniformity ⊓ u₂.uniformity) }.uniformity
[PROOFSTEP]
rw [@nhds_inf _ u₁.toTopologicalSpace u₂.toTopologicalSpace, @nhds_eq_comap_uniformity _ u₁,
@nhds_eq_comap_uniformity _ u₂, comap_inf]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
u₁ u₂ : UniformSpace α
x✝ : α
⊢ comap (Prod.mk x✝) (𝓤 α) ⊓ comap (Prod.mk x✝) (𝓤 α) =
comap (Prod.mk x✝) u₁.uniformity ⊓ comap (Prod.mk x✝) u₂.uniformity
[PROOFSTEP]
rfl
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
f : α → β
u : UniformSpace β
⊢ 𝓟 idRel ≤ Filter.comap (fun p => (f p.fst, f p.snd)) (𝓟 idRel)
[PROOFSTEP]
simp
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
f : α → β
u : UniformSpace β
⊢ Tendsto Prod.swap (Filter.comap (fun p => (f p.fst, f p.snd)) (𝓤 β))
(Filter.comap (fun p => (f p.fst, f p.snd)) (𝓤 β))
[PROOFSTEP]
simp only [tendsto_comap_iff, Prod.swap, (· ∘ ·)]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
f : α → β
u : UniformSpace β
⊢ Tendsto (fun x => (f x.snd, f x.fst)) (Filter.comap (fun p => (f p.fst, f p.snd)) (𝓤 β)) (𝓤 β)
[PROOFSTEP]
exact tendsto_swap_uniformity.comp tendsto_comap
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
f : α → β
u : UniformSpace β
⊢ (Filter.lift' (Filter.comap (fun p => (f p.fst, f p.snd)) (𝓤 β)) fun s => s ○ s) ≤
Filter.comap (fun p => (f p.fst, f p.snd)) (Filter.lift' u.uniformity fun s => s ○ s)
[PROOFSTEP]
rw [comap_lift'_eq, comap_lift'_eq2]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
f : α → β
u : UniformSpace β
⊢ Filter.lift' (𝓤 β) ((fun s => s ○ s) ∘ preimage fun p => (f p.fst, f p.snd)) ≤
Filter.lift' u.uniformity ((preimage fun p => (f p.fst, f p.snd)) ∘ fun s => s ○ s)
α : Type ua β : Type ub γ : Type uc δ : Type ud ι : Sort u_1 f : α → β u : UniformSpace β ⊢ Monotone fun s => s ○ s
[PROOFSTEP]
exact lift'_mono' fun s _ ⟨a₁, a₂⟩ ⟨x, h₁, h₂⟩ => ⟨f x, h₁, h₂⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
f : α → β
u : UniformSpace β
⊢ Monotone fun s => s ○ s
[PROOFSTEP]
exact monotone_id.compRel monotone_id
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
f : α → β
u : UniformSpace β
x : α
⊢ 𝓝 x =
Filter.comap (Prod.mk x)
{ uniformity := Filter.comap (fun p => (f p.fst, f p.snd)) (𝓤 β),
refl := (_ : 𝓟 idRel ≤ Filter.comap (fun p => (f p.fst, f p.snd)) (𝓤 β)),
symm :=
(_ :
Tendsto Prod.swap (Filter.comap (fun p => (f p.fst, f p.snd)) (𝓤 β))
(Filter.comap (fun p => (f p.fst, f p.snd)) (𝓤 β))),
comp :=
(_ :
(Filter.lift' (Filter.comap (fun p => (f p.fst, f p.snd)) (𝓤 β)) fun s => s ○ s) ≤
Filter.comap (fun p => (f p.fst, f p.snd)) (𝓤 β)) }.uniformity
[PROOFSTEP]
simp only [nhds_induced, nhds_eq_comap_uniformity, comap_comap, Function.comp]
[GOAL]
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
α : Type u_2
⊢ UniformSpace.comap id = id
[PROOFSTEP]
ext : 2
[GOAL]
case h.a
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
α : Type u_2
x✝ : UniformSpace α
⊢ 𝓤 α = 𝓤 α
[PROOFSTEP]
rw [uniformity_comap, Prod.map_id, comap_id]
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
α : Type u_2
β : Type u_3
γ : Type u_4
uγ : UniformSpace γ
f : α → β
g : β → γ
⊢ comap (g ∘ f) uγ = comap f (comap g uγ)
[PROOFSTEP]
ext1
[GOAL]
case a
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
α : Type u_2
β : Type u_3
γ : Type u_4
uγ : UniformSpace γ
f : α → β
g : β → γ
⊢ 𝓤 α = 𝓤 α
[PROOFSTEP]
simp only [uniformity_comap, Filter.comap_comap, Prod.map_comp_map]
[GOAL]
α✝ : Type ua
β : Type ub
γ✝ : Type uc
δ : Type ud
ι✝ : Sort u_1
ι : Sort u_2
α : Type u_3
γ : Type u_4
u : ι → UniformSpace γ
f : α → γ
⊢ comap f (⨅ (i : ι), u i) = ⨅ (i : ι), comap f (u i)
[PROOFSTEP]
ext : 1
[GOAL]
case a
α✝ : Type ua
β : Type ub
γ✝ : Type uc
δ : Type ud
ι✝ : Sort u_1
ι : Sort u_2
α : Type u_3
γ : Type u_4
u : ι → UniformSpace γ
f : α → γ
⊢ 𝓤 α = 𝓤 α
[PROOFSTEP]
simp [uniformity_comap, iInf_uniformity]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
u v : UniformSpace α
⊢ u ≤ v ↔ UniformContinuous id
[PROOFSTEP]
rw [uniformContinuous_iff, uniformSpace_comap_id, id]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
u₁ u₂ : UniformSpace α
h : u₁ ≤ u₂
a : α
⊢ 𝓝 a ≤ 𝓝 a
[PROOFSTEP]
rw [@nhds_eq_uniformity α u₁ a, @nhds_eq_uniformity α u₂ a]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
u₁ u₂ : UniformSpace α
h : u₁ ≤ u₂
a : α
⊢ Filter.lift' (𝓤 α) (UniformSpace.ball a) ≤ Filter.lift' (𝓤 α) (UniformSpace.ball a)
[PROOFSTEP]
exact lift'_mono h le_rfl
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
ι : Sort u_2
u : ι → UniformSpace α
a : α
⊢ 𝓝 a = 𝓝 a
[PROOFSTEP]
simp only [@nhds_eq_comap_uniformity _ (iInf u), nhds_iInf, iInf_uniformity, @nhds_eq_comap_uniformity _ (u _),
comap_iInf]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
s : Set (UniformSpace α)
⊢ UniformSpace.toTopologicalSpace = ⨅ (i : UniformSpace α) (_ : i ∈ s), UniformSpace.toTopologicalSpace
[PROOFSTEP]
rw [sInf_eq_iInf]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
s : Set (UniformSpace α)
⊢ UniformSpace.toTopologicalSpace = ⨅ (i : UniformSpace α) (_ : i ∈ s), UniformSpace.toTopologicalSpace
[PROOFSTEP]
simp only [← toTopologicalSpace_iInf]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
f : α → β
u₁ : Set (UniformSpace α)
u₂ : UniformSpace β
u : UniformSpace α
h₁ : u ∈ u₁
hf : UniformContinuous f
⊢ UniformContinuous f
[PROOFSTEP]
delta UniformContinuous
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
f : α → β
u₁ : Set (UniformSpace α)
u₂ : UniformSpace β
u : UniformSpace α
h₁ : u ∈ u₁
hf : UniformContinuous f
⊢ Tendsto (fun x => (f x.fst, f x.snd)) (𝓤 α) (𝓤 β)
[PROOFSTEP]
rw [sInf_eq_iInf', iInf_uniformity]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
f : α → β
u₁ : Set (UniformSpace α)
u₂ : UniformSpace β
u : UniformSpace α
h₁ : u ∈ u₁
hf : UniformContinuous f
⊢ Tendsto (fun x => (f x.fst, f x.snd)) (⨅ (i : ↑u₁), 𝓤 α) (𝓤 β)
[PROOFSTEP]
exact tendsto_iInf' ⟨u, h₁⟩ hf
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
f : α → β
u₁ : UniformSpace α
u₂ : Set (UniformSpace β)
⊢ UniformContinuous f ↔ ∀ (u : UniformSpace β), u ∈ u₂ → UniformContinuous f
[PROOFSTEP]
delta UniformContinuous
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
f : α → β
u₁ : UniformSpace α
u₂ : Set (UniformSpace β)
⊢ Tendsto (fun x => (f x.fst, f x.snd)) (𝓤 α) (𝓤 β) ↔
∀ (u : UniformSpace β), u ∈ u₂ → Tendsto (fun x => (f x.fst, f x.snd)) (𝓤 α) (𝓤 β)
[PROOFSTEP]
rw [sInf_eq_iInf', iInf_uniformity, tendsto_iInf, SetCoe.forall]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
f : α → β
u₁ : ι → UniformSpace α
u₂ : UniformSpace β
i : ι
hf : UniformContinuous f
⊢ UniformContinuous f
[PROOFSTEP]
delta UniformContinuous
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
f : α → β
u₁ : ι → UniformSpace α
u₂ : UniformSpace β
i : ι
hf : UniformContinuous f
⊢ Tendsto (fun x => (f x.fst, f x.snd)) (𝓤 α) (𝓤 β)
[PROOFSTEP]
rw [iInf_uniformity]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
f : α → β
u₁ : ι → UniformSpace α
u₂ : UniformSpace β
i : ι
hf : UniformContinuous f
⊢ Tendsto (fun x => (f x.fst, f x.snd)) (⨅ (i : ι), 𝓤 α) (𝓤 β)
[PROOFSTEP]
exact tendsto_iInf' i hf
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
f : α → β
u₁ : UniformSpace α
u₂ : ι → UniformSpace β
⊢ UniformContinuous f ↔ ∀ (i : ι), UniformContinuous f
[PROOFSTEP]
delta UniformContinuous
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
f : α → β
u₁ : UniformSpace α
u₂ : ι → UniformSpace β
⊢ Tendsto (fun x => (f x.fst, f x.snd)) (𝓤 α) (𝓤 β) ↔ ∀ (i : ι), Tendsto (fun x => (f x.fst, f x.snd)) (𝓤 α) (𝓤 β)
[PROOFSTEP]
rw [iInf_uniformity, tendsto_iInf]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
s : Set α
inst✝ : UniformSpace α
⊢ map (Prod.map Subtype.val Subtype.val) (𝓤 ↑s) = 𝓤 α ⊓ 𝓟 (s ×ˢ s)
[PROOFSTEP]
rw [uniformity_setCoe, map_comap, range_prod_map, Subtype.range_val]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
f : α → β
s : Set α
⊢ UniformContinuousOn f s ↔ UniformContinuous (restrict s f)
[PROOFSTEP]
delta UniformContinuousOn UniformContinuous
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
f : α → β
s : Set α
⊢ Tendsto (fun x => (f x.fst, f x.snd)) (𝓤 α ⊓ 𝓟 (s ×ˢ s)) (𝓤 β) ↔
Tendsto (fun x => (restrict s f x.fst, restrict s f x.snd)) (𝓤 ↑s) (𝓤 β)
[PROOFSTEP]
rw [← map_uniformity_set_coe, tendsto_map'_iff]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
f : α → β
s : Set α
⊢ Tendsto ((fun x => (f x.fst, f x.snd)) ∘ Prod.map Subtype.val Subtype.val) (𝓤 ↑s) (𝓤 β) ↔
Tendsto (fun x => (restrict s f x.fst, restrict s f x.snd)) (𝓤 ↑s) (𝓤 β)
[PROOFSTEP]
rfl
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
f : α → β
s : Set α
a : α
hf : UniformContinuous fun x => f ↑x
ha : s ∈ 𝓝 a
⊢ Tendsto f (𝓝 a) (𝓝 (f a))
[PROOFSTEP]
rw [(@map_nhds_subtype_coe_eq_nhds α _ s a (mem_of_mem_nhds ha) ha).symm]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
f : α → β
s : Set α
a : α
hf : UniformContinuous fun x => f ↑x
ha : s ∈ 𝓝 a
⊢ Tendsto f (map Subtype.val (𝓝 { val := a, property := (_ : a ∈ s) })) (𝓝 (f a))
[PROOFSTEP]
exact tendsto_map' hf.continuous.continuousAt
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
f : α → β
s : Set α
h : UniformContinuousOn f s
⊢ ContinuousOn f s
[PROOFSTEP]
rw [uniformContinuousOn_iff_restrict] at h
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
f : α → β
s : Set α
h : UniformContinuous (restrict s f)
⊢ ContinuousOn f s
[PROOFSTEP]
rw [continuousOn_iff_continuous_restrict]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
f : α → β
s : Set α
h : UniformContinuous (restrict s f)
⊢ Continuous (restrict s f)
[PROOFSTEP]
exact h.continuous
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
⊢ comap (fun p => (MulOpposite.op p.fst, MulOpposite.op p.snd)) (𝓤 αᵐᵒᵖ) = 𝓤 α
[PROOFSTEP]
simpa [uniformity_mulOpposite, comap_comap, (· ∘ ·)] using comap_id
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
⊢ 𝓤 (α × β) = comap (fun p => ((p.fst.fst, p.snd.fst), p.fst.snd, p.snd.snd)) (𝓤 α ×ˢ 𝓤 β)
[PROOFSTEP]
dsimp [SProd.sprod]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
⊢ 𝓤 (α × β) = comap (fun p => ((p.fst.fst, p.snd.fst), p.fst.snd, p.snd.snd)) (Filter.prod (𝓤 α) (𝓤 β))
[PROOFSTEP]
rw [uniformity_prod, Filter.prod, comap_inf, comap_comap, comap_comap]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
⊢ comap (fun p => (p.fst.fst, p.snd.fst)) (𝓤 α) ⊓ comap (fun p => (p.fst.snd, p.snd.snd)) (𝓤 β) =
comap (Prod.fst ∘ fun p => ((p.fst.fst, p.snd.fst), p.fst.snd, p.snd.snd)) (𝓤 α) ⊓
comap (Prod.snd ∘ fun p => ((p.fst.fst, p.snd.fst), p.fst.snd, p.snd.snd)) (𝓤 β)
[PROOFSTEP]
rfl
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
⊢ 𝓤 (α × β) = map (fun p => ((p.fst.fst, p.snd.fst), p.fst.snd, p.snd.snd)) (𝓤 α ×ˢ 𝓤 β)
[PROOFSTEP]
rw [map_swap4_eq_comap, uniformity_prod_eq_comap_prod]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
s : Set (β × β)
f : α → α → β
hf : UniformContinuous fun p => f p.fst p.snd
hs : s ∈ 𝓤 β
⊢ ∃ u, u ∈ 𝓤 α ∧ ∀ (a b c : α), (a, b) ∈ u → (f a c, f b c) ∈ s
[PROOFSTEP]
rw [UniformContinuous, uniformity_prod_eq_prod, tendsto_map'_iff] at hf
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
s : Set (β × β)
f : α → α → β
hf :
Tendsto
((fun x => (f x.fst.fst x.fst.snd, f x.snd.fst x.snd.snd)) ∘ fun p =>
((p.fst.fst, p.snd.fst), p.fst.snd, p.snd.snd))
(𝓤 α ×ˢ 𝓤 α) (𝓤 β)
hs : s ∈ 𝓤 β
⊢ ∃ u, u ∈ 𝓤 α ∧ ∀ (a b c : α), (a, b) ∈ u → (f a c, f b c) ∈ s
[PROOFSTEP]
rcases mem_prod_iff.1 (mem_map.1 <| hf hs) with ⟨u, hu, v, hv, huvt⟩
[GOAL]
case intro.intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
s : Set (β × β)
f : α → α → β
hf :
Tendsto
((fun x => (f x.fst.fst x.fst.snd, f x.snd.fst x.snd.snd)) ∘ fun p =>
((p.fst.fst, p.snd.fst), p.fst.snd, p.snd.snd))
(𝓤 α ×ˢ 𝓤 α) (𝓤 β)
hs : s ∈ 𝓤 β
u : Set (α × α)
hu : u ∈ 𝓤 α
v : Set (α × α)
hv : v ∈ 𝓤 α
huvt :
u ×ˢ v ⊆
((fun x => (f x.fst.fst x.fst.snd, f x.snd.fst x.snd.snd)) ∘ fun p =>
((p.fst.fst, p.snd.fst), p.fst.snd, p.snd.snd)) ⁻¹'
s
⊢ ∃ u, u ∈ 𝓤 α ∧ ∀ (a b c : α), (a, b) ∈ u → (f a c, f b c) ∈ s
[PROOFSTEP]
exact ⟨u, hu, fun a b c hab => @huvt ((_, _), (_, _)) ⟨hab, refl_mem_uniformity hv⟩⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
t₁ : UniformSpace α
t₂ : UniformSpace β
a : Set (α × α)
b : Set (β × β)
ha : a ∈ 𝓤 α
hb : b ∈ 𝓤 β
⊢ {p | (p.fst.fst, p.snd.fst) ∈ a ∧ (p.fst.snd, p.snd.snd) ∈ b} ∈ 𝓤 (α × β)
[PROOFSTEP]
rw [uniformity_prod]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
t₁ : UniformSpace α
t₂ : UniformSpace β
a : Set (α × α)
b : Set (β × β)
ha : a ∈ 𝓤 α
hb : b ∈ 𝓤 β
⊢ {p | (p.fst.fst, p.snd.fst) ∈ a ∧ (p.fst.snd, p.snd.snd) ∈ b} ∈
comap (fun p => (p.fst.fst, p.snd.fst)) (𝓤 α) ⊓ comap (fun p => (p.fst.snd, p.snd.snd)) (𝓤 β)
[PROOFSTEP]
exact inter_mem_inf (preimage_mem_comap ha) (preimage_mem_comap hb)
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α
inst✝¹ : UniformSpace β
inst✝ : UniformSpace γ
f₁ : α → β
f₂ : α → γ
h₁ : UniformContinuous f₁
h₂ : UniformContinuous f₂
⊢ UniformContinuous fun a => (f₁ a, f₂ a)
[PROOFSTEP]
rw [UniformContinuous, uniformity_prod]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α
inst✝¹ : UniformSpace β
inst✝ : UniformSpace γ
f₁ : α → β
f₂ : α → γ
h₁ : UniformContinuous f₁
h₂ : UniformContinuous f₂
⊢ Tendsto (fun x => ((f₁ x.fst, f₂ x.fst), f₁ x.snd, f₂ x.snd)) (𝓤 α)
(comap (fun p => (p.fst.fst, p.snd.fst)) (𝓤 β) ⊓ comap (fun p => (p.fst.snd, p.snd.snd)) (𝓤 γ))
[PROOFSTEP]
exact tendsto_inf.2 ⟨tendsto_comap_iff.2 h₁, tendsto_comap_iff.2 h₂⟩
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type ?u.174697
β : Type ?u.174703
γ : Type ?u.174709
f : α → β → γ
ua1 ua2 : UniformSpace α
ub1 ub2 : UniformSpace β
uc1 : UniformSpace γ
⊢ Sort ?u.174711
[PROOFSTEP]
haveI := ua1
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type ?u.174697
β : Type ?u.174703
γ : Type ?u.174709
f : α → β → γ
ua1 ua2 : UniformSpace α
ub1 ub2 : UniformSpace β
uc1 : UniformSpace γ
this : UniformSpace α
⊢ Sort ?u.174711
[PROOFSTEP]
haveI := ub1
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type ?u.174697
β : Type ?u.174703
γ : Type ?u.174709
f : α → β → γ
ua1 ua2 : UniformSpace α
ub1 ub2 : UniformSpace β
uc1 : UniformSpace γ
this✝ : UniformSpace α
this : UniformSpace β
⊢ Sort ?u.174711
[PROOFSTEP]
exact UniformContinuous fun p : α × β => f p.1 p.2
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type ?u.174697
β : Type ?u.174703
γ : Type ?u.174709
f : α → β → γ
ua1 ua2 : UniformSpace α
ub1 ub2 : UniformSpace β
uc1 : UniformSpace γ
h : UniformContinuous fun p => f p.fst p.snd
⊢ Sort ?u.174714
[PROOFSTEP]
haveI := ua1 ⊓ ua2
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type ?u.174697
β : Type ?u.174703
γ : Type ?u.174709
f : α → β → γ
ua1 ua2 : UniformSpace α
ub1 ub2 : UniformSpace β
uc1 : UniformSpace γ
h : UniformContinuous fun p => f p.fst p.snd
this : UniformSpace α
⊢ Sort ?u.174714
[PROOFSTEP]
haveI := ub1 ⊓ ub2
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type ?u.174697
β : Type ?u.174703
γ : Type ?u.174709
f : α → β → γ
ua1 ua2 : UniformSpace α
ub1 ub2 : UniformSpace β
uc1 : UniformSpace γ
h : UniformContinuous fun p => f p.fst p.snd
this✝ : UniformSpace α
this : UniformSpace β
⊢ Sort ?u.174714
[PROOFSTEP]
exact UniformContinuous fun p : α × β => f p.1 p.2
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type u_2
β : Type u_3
γ : Type u_4
f : α → β → γ
ua1 ua2 : UniformSpace α
ub1 ub2 : UniformSpace β
uc1 : UniformSpace γ
h : UniformContinuous fun p => f p.fst p.snd
⊢ UniformContinuous fun p => f p.fst p.snd
[PROOFSTEP]
have ha := @UniformContinuous.inf_dom_left _ _ id ua1 ua2 ua1 (@uniformContinuous_id _ (id _))
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type u_2
β : Type u_3
γ : Type u_4
f : α → β → γ
ua1 ua2 : UniformSpace α
ub1 ub2 : UniformSpace β
uc1 : UniformSpace γ
h : UniformContinuous fun p => f p.fst p.snd
ha : UniformContinuous id
⊢ UniformContinuous fun p => f p.fst p.snd
[PROOFSTEP]
have hb := @UniformContinuous.inf_dom_left _ _ id ub1 ub2 ub1 (@uniformContinuous_id _ (id _))
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type u_2
β : Type u_3
γ : Type u_4
f : α → β → γ
ua1 ua2 : UniformSpace α
ub1 ub2 : UniformSpace β
uc1 : UniformSpace γ
h : UniformContinuous fun p => f p.fst p.snd
ha : UniformContinuous id
hb : UniformContinuous id
⊢ UniformContinuous fun p => f p.fst p.snd
[PROOFSTEP]
have h_unif_cont_id := @UniformContinuous.prod_map _ _ _ _ (ua1 ⊓ ua2) (ub1 ⊓ ub2) ua1 ub1 _ _ ha hb
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type u_2
β : Type u_3
γ : Type u_4
f : α → β → γ
ua1 ua2 : UniformSpace α
ub1 ub2 : UniformSpace β
uc1 : UniformSpace γ
h : UniformContinuous fun p => f p.fst p.snd
ha : UniformContinuous id
hb : UniformContinuous id
h_unif_cont_id : UniformContinuous (Prod.map id id)
⊢ UniformContinuous fun p => f p.fst p.snd
[PROOFSTEP]
exact @UniformContinuous.comp _ _ _ (id _) (id _) _ _ _ h h_unif_cont_id
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type ?u.176203
β : Type ?u.176209
γ : Type ?u.176215
f : α → β → γ
ua1 ua2 : UniformSpace α
ub1 ub2 : UniformSpace β
uc1 : UniformSpace γ
⊢ Sort ?u.176217
[PROOFSTEP]
haveI := ua2
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type ?u.176203
β : Type ?u.176209
γ : Type ?u.176215
f : α → β → γ
ua1 ua2 : UniformSpace α
ub1 ub2 : UniformSpace β
uc1 : UniformSpace γ
this : UniformSpace α
⊢ Sort ?u.176217
[PROOFSTEP]
haveI := ub2
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type ?u.176203
β : Type ?u.176209
γ : Type ?u.176215
f : α → β → γ
ua1 ua2 : UniformSpace α
ub1 ub2 : UniformSpace β
uc1 : UniformSpace γ
this✝ : UniformSpace α
this : UniformSpace β
⊢ Sort ?u.176217
[PROOFSTEP]
exact UniformContinuous fun p : α × β => f p.1 p.2
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type ?u.176203
β : Type ?u.176209
γ : Type ?u.176215
f : α → β → γ
ua1 ua2 : UniformSpace α
ub1 ub2 : UniformSpace β
uc1 : UniformSpace γ
h : UniformContinuous fun p => f p.fst p.snd
⊢ Sort ?u.176220
[PROOFSTEP]
haveI := ua1 ⊓ ua2
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type ?u.176203
β : Type ?u.176209
γ : Type ?u.176215
f : α → β → γ
ua1 ua2 : UniformSpace α
ub1 ub2 : UniformSpace β
uc1 : UniformSpace γ
h : UniformContinuous fun p => f p.fst p.snd
this : UniformSpace α
⊢ Sort ?u.176220
[PROOFSTEP]
haveI := ub1 ⊓ ub2
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type ?u.176203
β : Type ?u.176209
γ : Type ?u.176215
f : α → β → γ
ua1 ua2 : UniformSpace α
ub1 ub2 : UniformSpace β
uc1 : UniformSpace γ
h : UniformContinuous fun p => f p.fst p.snd
this✝ : UniformSpace α
this : UniformSpace β
⊢ Sort ?u.176220
[PROOFSTEP]
exact UniformContinuous fun p : α × β => f p.1 p.2
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type u_2
β : Type u_3
γ : Type u_4
f : α → β → γ
ua1 ua2 : UniformSpace α
ub1 ub2 : UniformSpace β
uc1 : UniformSpace γ
h : UniformContinuous fun p => f p.fst p.snd
⊢ UniformContinuous fun p => f p.fst p.snd
[PROOFSTEP]
have ha := @UniformContinuous.inf_dom_right _ _ id ua1 ua2 ua2 (@uniformContinuous_id _ (id _))
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type u_2
β : Type u_3
γ : Type u_4
f : α → β → γ
ua1 ua2 : UniformSpace α
ub1 ub2 : UniformSpace β
uc1 : UniformSpace γ
h : UniformContinuous fun p => f p.fst p.snd
ha : UniformContinuous id
⊢ UniformContinuous fun p => f p.fst p.snd
[PROOFSTEP]
have hb := @UniformContinuous.inf_dom_right _ _ id ub1 ub2 ub2 (@uniformContinuous_id _ (id _))
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type u_2
β : Type u_3
γ : Type u_4
f : α → β → γ
ua1 ua2 : UniformSpace α
ub1 ub2 : UniformSpace β
uc1 : UniformSpace γ
h : UniformContinuous fun p => f p.fst p.snd
ha : UniformContinuous id
hb : UniformContinuous id
⊢ UniformContinuous fun p => f p.fst p.snd
[PROOFSTEP]
have h_unif_cont_id := @UniformContinuous.prod_map _ _ _ _ (ua1 ⊓ ua2) (ub1 ⊓ ub2) ua2 ub2 _ _ ha hb
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type u_2
β : Type u_3
γ : Type u_4
f : α → β → γ
ua1 ua2 : UniformSpace α
ub1 ub2 : UniformSpace β
uc1 : UniformSpace γ
h : UniformContinuous fun p => f p.fst p.snd
ha : UniformContinuous id
hb : UniformContinuous id
h_unif_cont_id : UniformContinuous (Prod.map id id)
⊢ UniformContinuous fun p => f p.fst p.snd
[PROOFSTEP]
exact @UniformContinuous.comp _ _ _ (id _) (id _) _ _ _ h h_unif_cont_id
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type ?u.177710
β : Type ?u.177714
γ : Type ?u.177723
f : α → β → γ
uas : Set (UniformSpace α)
ubs : Set (UniformSpace β)
ua : UniformSpace α
ub : UniformSpace β
uc : UniformSpace γ
ha : ua ∈ uas
hb : ub ∈ ubs
hf : UniformContinuous fun p => f p.fst p.snd
⊢ Sort ?u.177870
[PROOFSTEP]
haveI := sInf uas
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type ?u.177710
β : Type ?u.177714
γ : Type ?u.177723
f : α → β → γ
uas : Set (UniformSpace α)
ubs : Set (UniformSpace β)
ua : UniformSpace α
ub : UniformSpace β
uc : UniformSpace γ
ha : ua ∈ uas
hb : ub ∈ ubs
hf : UniformContinuous fun p => f p.fst p.snd
this : UniformSpace α
⊢ Sort ?u.177870
[PROOFSTEP]
haveI := sInf ubs
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type ?u.177710
β : Type ?u.177714
γ : Type ?u.177723
f : α → β → γ
uas : Set (UniformSpace α)
ubs : Set (UniformSpace β)
ua : UniformSpace α
ub : UniformSpace β
uc : UniformSpace γ
ha : ua ∈ uas
hb : ub ∈ ubs
hf : UniformContinuous fun p => f p.fst p.snd
this✝ : UniformSpace α
this : UniformSpace β
⊢ Sort ?u.177870
[PROOFSTEP]
exact @UniformContinuous _ _ _ uc fun p : α × β => f p.1 p.2
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type u_2
β : Type u_3
γ : Type u_4
f : α → β → γ
uas : Set (UniformSpace α)
ubs : Set (UniformSpace β)
ua : UniformSpace α
ub : UniformSpace β
uc : UniformSpace γ
ha : ua ∈ uas
hb : ub ∈ ubs
hf : UniformContinuous fun p => f p.fst p.snd
⊢ UniformContinuous fun p => f p.fst p.snd
[PROOFSTEP]
let _ : UniformSpace (α × β) := instUniformSpaceProd
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type u_2
β : Type u_3
γ : Type u_4
f : α → β → γ
uas : Set (UniformSpace α)
ubs : Set (UniformSpace β)
ua : UniformSpace α
ub : UniformSpace β
uc : UniformSpace γ
ha : ua ∈ uas
hb : ub ∈ ubs
hf : UniformContinuous fun p => f p.fst p.snd
x✝ : UniformSpace (α × β) := instUniformSpaceProd
⊢ UniformContinuous fun p => f p.fst p.snd
[PROOFSTEP]
have ha := uniformContinuous_sInf_dom ha uniformContinuous_id
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type u_2
β : Type u_3
γ : Type u_4
f : α → β → γ
uas : Set (UniformSpace α)
ubs : Set (UniformSpace β)
ua : UniformSpace α
ub : UniformSpace β
uc : UniformSpace γ
ha✝ : ua ∈ uas
hb : ub ∈ ubs
hf : UniformContinuous fun p => f p.fst p.snd
x✝ : UniformSpace (α × β) := instUniformSpaceProd
ha : UniformContinuous id
⊢ UniformContinuous fun p => f p.fst p.snd
[PROOFSTEP]
have hb := uniformContinuous_sInf_dom hb uniformContinuous_id
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type u_2
β : Type u_3
γ : Type u_4
f : α → β → γ
uas : Set (UniformSpace α)
ubs : Set (UniformSpace β)
ua : UniformSpace α
ub : UniformSpace β
uc : UniformSpace γ
ha✝ : ua ∈ uas
hb✝ : ub ∈ ubs
hf : UniformContinuous fun p => f p.fst p.snd
x✝ : UniformSpace (α × β) := instUniformSpaceProd
ha : UniformContinuous id
hb : UniformContinuous id
⊢ UniformContinuous fun p => f p.fst p.snd
[PROOFSTEP]
have h_unif_cont_id := @UniformContinuous.prod_map _ _ _ _ (sInf uas) (sInf ubs) ua ub _ _ ha hb
[GOAL]
α✝ : Type ua
β✝ : Type ub
γ✝ : Type uc
δ : Type ud
ι : Sort u_1
inst✝² : UniformSpace α✝
inst✝¹ : UniformSpace β✝
inst✝ : UniformSpace γ✝
α : Type u_2
β : Type u_3
γ : Type u_4
f : α → β → γ
uas : Set (UniformSpace α)
ubs : Set (UniformSpace β)
ua : UniformSpace α
ub : UniformSpace β
uc : UniformSpace γ
ha✝ : ua ∈ uas
hb✝ : ub ∈ ubs
hf : UniformContinuous fun p => f p.fst p.snd
x✝ : UniformSpace (α × β) := instUniformSpaceProd
ha : UniformContinuous id
hb : UniformContinuous id
h_unif_cont_id : UniformContinuous (Prod.map id id)
⊢ UniformContinuous fun p => f p.fst p.snd
[PROOFSTEP]
exact @UniformContinuous.comp _ _ _ (id _) (id _) _ _ _ hf h_unif_cont_id
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
δ' : Type u_2
inst✝⁴ : UniformSpace α
inst✝³ : UniformSpace β
inst✝² : UniformSpace γ
inst✝¹ : UniformSpace δ
inst✝ : UniformSpace δ'
f : α × β → γ
⊢ UniformContinuous₂ (curry f) ↔ UniformContinuous f
[PROOFSTEP]
rw [UniformContinuous₂, uncurry_curry]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
r : Set ((α ⊕ β) × (α ⊕ β))
x✝ : r ∈ map (fun p => (inl p.fst, inl p.snd)) (𝓤 α) ⊔ map (fun p => (inr p.fst, inr p.snd)) (𝓤 β)
x : α ⊕ β
H₁ : r ∈ (map (fun p => (inl p.fst, inl p.snd)) (𝓤 α)).sets
H₂ : r ∈ (map (fun p => (inr p.fst, inr p.snd)) (𝓤 β)).sets
⊢ (x, x) ∈ r
[PROOFSTEP]
cases x <;> [apply refl_mem_uniformity H₁; apply refl_mem_uniformity H₂]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
r : Set ((α ⊕ β) × (α ⊕ β))
x✝ : r ∈ map (fun p => (inl p.fst, inl p.snd)) (𝓤 α) ⊔ map (fun p => (inr p.fst, inr p.snd)) (𝓤 β)
x : α ⊕ β
H₁ : r ∈ (map (fun p => (inl p.fst, inl p.snd)) (𝓤 α)).sets
H₂ : r ∈ (map (fun p => (inr p.fst, inr p.snd)) (𝓤 β)).sets
⊢ (x, x) ∈ r
[PROOFSTEP]
cases x
[GOAL]
case inl
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
r : Set ((α ⊕ β) × (α ⊕ β))
x✝ : r ∈ map (fun p => (inl p.fst, inl p.snd)) (𝓤 α) ⊔ map (fun p => (inr p.fst, inr p.snd)) (𝓤 β)
H₁ : r ∈ (map (fun p => (inl p.fst, inl p.snd)) (𝓤 α)).sets
H₂ : r ∈ (map (fun p => (inr p.fst, inr p.snd)) (𝓤 β)).sets
val✝ : α
⊢ (inl val✝, inl val✝) ∈ r
[PROOFSTEP]
apply refl_mem_uniformity H₁
[GOAL]
case inr
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
r : Set ((α ⊕ β) × (α ⊕ β))
x✝ : r ∈ map (fun p => (inl p.fst, inl p.snd)) (𝓤 α) ⊔ map (fun p => (inr p.fst, inr p.snd)) (𝓤 β)
H₁ : r ∈ (map (fun p => (inl p.fst, inl p.snd)) (𝓤 α)).sets
H₂ : r ∈ (map (fun p => (inr p.fst, inr p.snd)) (𝓤 β)).sets
val✝ : β
⊢ (inr val✝, inr val✝) ∈ r
[PROOFSTEP]
apply refl_mem_uniformity H₂
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
r : Set ((α ⊕ β) × (α ⊕ β))
x✝ : r ∈ map (fun p => (inl p.fst, inl p.snd)) (𝓤 α) ⊔ map (fun p => (inr p.fst, inr p.snd)) (𝓤 β)
Hrα : r ∈ (map (fun p => (inl p.fst, inl p.snd)) (𝓤 α)).sets
Hrβ : r ∈ (map (fun p => (inr p.fst, inr p.snd)) (𝓤 β)).sets
⊢ ∃ t, t ∈ map (fun p => (inl p.fst, inl p.snd)) (𝓤 α) ⊔ map (fun p => (inr p.fst, inr p.snd)) (𝓤 β) ∧ t ○ t ⊆ r
[PROOFSTEP]
rcases comp_mem_uniformity_sets Hrα with ⟨tα, htα, Htα⟩
[GOAL]
case intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
r : Set ((α ⊕ β) × (α ⊕ β))
x✝ : r ∈ map (fun p => (inl p.fst, inl p.snd)) (𝓤 α) ⊔ map (fun p => (inr p.fst, inr p.snd)) (𝓤 β)
Hrα : r ∈ (map (fun p => (inl p.fst, inl p.snd)) (𝓤 α)).sets
Hrβ : r ∈ (map (fun p => (inr p.fst, inr p.snd)) (𝓤 β)).sets
tα : Set (α × α)
htα : tα ∈ 𝓤 α
Htα : tα ○ tα ⊆ (fun p => (inl p.fst, inl p.snd)) ⁻¹' r
⊢ ∃ t, t ∈ map (fun p => (inl p.fst, inl p.snd)) (𝓤 α) ⊔ map (fun p => (inr p.fst, inr p.snd)) (𝓤 β) ∧ t ○ t ⊆ r
[PROOFSTEP]
rcases comp_mem_uniformity_sets Hrβ with ⟨tβ, htβ, Htβ⟩
[GOAL]
case intro.intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
r : Set ((α ⊕ β) × (α ⊕ β))
x✝ : r ∈ map (fun p => (inl p.fst, inl p.snd)) (𝓤 α) ⊔ map (fun p => (inr p.fst, inr p.snd)) (𝓤 β)
Hrα : r ∈ (map (fun p => (inl p.fst, inl p.snd)) (𝓤 α)).sets
Hrβ : r ∈ (map (fun p => (inr p.fst, inr p.snd)) (𝓤 β)).sets
tα : Set (α × α)
htα : tα ∈ 𝓤 α
Htα : tα ○ tα ⊆ (fun p => (inl p.fst, inl p.snd)) ⁻¹' r
tβ : Set (β × β)
htβ : tβ ∈ 𝓤 β
Htβ : tβ ○ tβ ⊆ (fun p => (inr p.fst, inr p.snd)) ⁻¹' r
⊢ ∃ t, t ∈ map (fun p => (inl p.fst, inl p.snd)) (𝓤 α) ⊔ map (fun p => (inr p.fst, inr p.snd)) (𝓤 β) ∧ t ○ t ⊆ r
[PROOFSTEP]
refine'
⟨_,
⟨mem_map_iff_exists_image.2 ⟨tα, htα, subset_union_left _ _⟩,
mem_map_iff_exists_image.2 ⟨tβ, htβ, subset_union_right _ _⟩⟩,
_⟩
[GOAL]
case intro.intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
r : Set ((α ⊕ β) × (α ⊕ β))
x✝ : r ∈ map (fun p => (inl p.fst, inl p.snd)) (𝓤 α) ⊔ map (fun p => (inr p.fst, inr p.snd)) (𝓤 β)
Hrα : r ∈ (map (fun p => (inl p.fst, inl p.snd)) (𝓤 α)).sets
Hrβ : r ∈ (map (fun p => (inr p.fst, inr p.snd)) (𝓤 β)).sets
tα : Set (α × α)
htα : tα ∈ 𝓤 α
Htα : tα ○ tα ⊆ (fun p => (inl p.fst, inl p.snd)) ⁻¹' r
tβ : Set (β × β)
htβ : tβ ∈ 𝓤 β
Htβ : tβ ○ tβ ⊆ (fun p => (inr p.fst, inr p.snd)) ⁻¹' r
⊢ (fun p => (inl p.fst, inl p.snd)) '' tα ∪ (fun p => (inr p.fst, inr p.snd)) '' tβ ○
(fun p => (inl p.fst, inl p.snd)) '' tα ∪ (fun p => (inr p.fst, inr p.snd)) '' tβ ⊆
r
[PROOFSTEP]
rintro ⟨_, _⟩ ⟨z, ⟨⟨a, b⟩, hab, ⟨⟩⟩ | ⟨⟨a, b⟩, hab, ⟨⟩⟩, ⟨⟨_, c⟩, hbc, ⟨⟩⟩ | ⟨⟨_, c⟩, hbc, ⟨⟩⟩⟩
[GOAL]
case intro.intro.intro.intro.mk.intro.intro.inl.intro.mk.intro.refl.inl.intro.mk.intro.refl
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
r : Set ((α ⊕ β) × (α ⊕ β))
x✝ : r ∈ map (fun p => (inl p.fst, inl p.snd)) (𝓤 α) ⊔ map (fun p => (inr p.fst, inr p.snd)) (𝓤 β)
Hrα : r ∈ (map (fun p => (inl p.fst, inl p.snd)) (𝓤 α)).sets
Hrβ : r ∈ (map (fun p => (inr p.fst, inr p.snd)) (𝓤 β)).sets
tα : Set (α × α)
htα : tα ∈ 𝓤 α
Htα : tα ○ tα ⊆ (fun p => (inl p.fst, inl p.snd)) ⁻¹' r
tβ : Set (β × β)
htβ : tβ ∈ 𝓤 β
Htβ : tβ ○ tβ ⊆ (fun p => (inr p.fst, inr p.snd)) ⁻¹' r
a b : α
hab : (a, b) ∈ tα
c : α
hbc : (b, c) ∈ tα
⊢ (inl (a, b).fst, inl (b, c).snd) ∈ r
[PROOFSTEP]
have A : (a, c) ∈ tα ○ tα := ⟨b, hab, hbc⟩
[GOAL]
case intro.intro.intro.intro.mk.intro.intro.inl.intro.mk.intro.refl.inl.intro.mk.intro.refl
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
r : Set ((α ⊕ β) × (α ⊕ β))
x✝ : r ∈ map (fun p => (inl p.fst, inl p.snd)) (𝓤 α) ⊔ map (fun p => (inr p.fst, inr p.snd)) (𝓤 β)
Hrα : r ∈ (map (fun p => (inl p.fst, inl p.snd)) (𝓤 α)).sets
Hrβ : r ∈ (map (fun p => (inr p.fst, inr p.snd)) (𝓤 β)).sets
tα : Set (α × α)
htα : tα ∈ 𝓤 α
Htα : tα ○ tα ⊆ (fun p => (inl p.fst, inl p.snd)) ⁻¹' r
tβ : Set (β × β)
htβ : tβ ∈ 𝓤 β
Htβ : tβ ○ tβ ⊆ (fun p => (inr p.fst, inr p.snd)) ⁻¹' r
a b : α
hab : (a, b) ∈ tα
c : α
hbc : (b, c) ∈ tα
A : (a, c) ∈ tα ○ tα
⊢ (inl (a, b).fst, inl (b, c).snd) ∈ r
[PROOFSTEP]
exact Htα A
[GOAL]
case intro.intro.intro.intro.mk.intro.intro.inr.intro.mk.intro.refl.inr.intro.mk.intro.refl
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
r : Set ((α ⊕ β) × (α ⊕ β))
x✝ : r ∈ map (fun p => (inl p.fst, inl p.snd)) (𝓤 α) ⊔ map (fun p => (inr p.fst, inr p.snd)) (𝓤 β)
Hrα : r ∈ (map (fun p => (inl p.fst, inl p.snd)) (𝓤 α)).sets
Hrβ : r ∈ (map (fun p => (inr p.fst, inr p.snd)) (𝓤 β)).sets
tα : Set (α × α)
htα : tα ∈ 𝓤 α
Htα : tα ○ tα ⊆ (fun p => (inl p.fst, inl p.snd)) ⁻¹' r
tβ : Set (β × β)
htβ : tβ ∈ 𝓤 β
Htβ : tβ ○ tβ ⊆ (fun p => (inr p.fst, inr p.snd)) ⁻¹' r
a b : β
hab : (a, b) ∈ tβ
c : β
hbc : (b, c) ∈ tβ
⊢ (inr (a, b).fst, inr (b, c).snd) ∈ r
[PROOFSTEP]
have A : (a, c) ∈ tβ ○ tβ := ⟨b, hab, hbc⟩
[GOAL]
case intro.intro.intro.intro.mk.intro.intro.inr.intro.mk.intro.refl.inr.intro.mk.intro.refl
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
r : Set ((α ⊕ β) × (α ⊕ β))
x✝ : r ∈ map (fun p => (inl p.fst, inl p.snd)) (𝓤 α) ⊔ map (fun p => (inr p.fst, inr p.snd)) (𝓤 β)
Hrα : r ∈ (map (fun p => (inl p.fst, inl p.snd)) (𝓤 α)).sets
Hrβ : r ∈ (map (fun p => (inr p.fst, inr p.snd)) (𝓤 β)).sets
tα : Set (α × α)
htα : tα ∈ 𝓤 α
Htα : tα ○ tα ⊆ (fun p => (inl p.fst, inl p.snd)) ⁻¹' r
tβ : Set (β × β)
htβ : tβ ∈ 𝓤 β
Htβ : tβ ○ tβ ⊆ (fun p => (inr p.fst, inr p.snd)) ⁻¹' r
a b : β
hab : (a, b) ∈ tβ
c : β
hbc : (b, c) ∈ tβ
A : (a, c) ∈ tβ ○ tβ
⊢ (inr (a, b).fst, inr (b, c).snd) ∈ r
[PROOFSTEP]
exact Htβ A
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
s : Set (α ⊕ β)
hs : IsOpen s
x : α ⊕ β
xs : x ∈ s
⊢ {p | p.fst = x → p.snd ∈ s} ∈ UniformSpace.Core.sum.uniformity
[PROOFSTEP]
cases x
[GOAL]
case inl
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
s : Set (α ⊕ β)
hs : IsOpen s
val✝ : α
xs : inl val✝ ∈ s
⊢ {p | p.fst = inl val✝ → p.snd ∈ s} ∈ UniformSpace.Core.sum.uniformity
[PROOFSTEP]
refine'
mem_of_superset (union_mem_uniformity_sum (mem_nhds_uniformity_iff_right.1 (hs.1.mem_nhds xs)) univ_mem)
(union_subset _ _)
[GOAL]
case inl.refine'_1
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
s : Set (α ⊕ β)
hs : IsOpen s
val✝ : α
xs : inl val✝ ∈ s
⊢ (fun p => (inl p.fst, inl p.snd)) '' {p | p.fst = val✝ → p.snd ∈ inl ⁻¹' s} ⊆ {p | p.fst = inl val✝ → p.snd ∈ s}
[PROOFSTEP]
rintro _ ⟨⟨_, b⟩, h, ⟨⟩⟩ ⟨⟩
[GOAL]
case inl.refine'_2
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
s : Set (α ⊕ β)
hs : IsOpen s
val✝ : α
xs : inl val✝ ∈ s
⊢ (fun p => (inr p.fst, inr p.snd)) '' univ ⊆ {p | p.fst = inl val✝ → p.snd ∈ s}
[PROOFSTEP]
rintro _ ⟨⟨_, b⟩, h, ⟨⟩⟩ ⟨⟩
[GOAL]
case inl.refine'_1.intro.mk.intro.refl.refl
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
s : Set (α ⊕ β)
hs : IsOpen s
fst✝ b : α
xs : inl (fst✝, b).fst ∈ s
h : (fst✝, b) ∈ {p | p.fst = (fst✝, b).fst → p.snd ∈ inl ⁻¹' s}
⊢ ((fun p => (inl p.fst, inl p.snd)) (fst✝, b)).snd ∈ s
[PROOFSTEP]
exact h rfl
[GOAL]
case inr
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
s : Set (α ⊕ β)
hs : IsOpen s
val✝ : β
xs : inr val✝ ∈ s
⊢ {p | p.fst = inr val✝ → p.snd ∈ s} ∈ UniformSpace.Core.sum.uniformity
[PROOFSTEP]
refine'
mem_of_superset (union_mem_uniformity_sum univ_mem (mem_nhds_uniformity_iff_right.1 (hs.2.mem_nhds xs)))
(union_subset _ _)
[GOAL]
case inr.refine'_1
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
s : Set (α ⊕ β)
hs : IsOpen s
val✝ : β
xs : inr val✝ ∈ s
⊢ (fun p => (inl p.fst, inl p.snd)) '' univ ⊆ {p | p.fst = inr val✝ → p.snd ∈ s}
[PROOFSTEP]
rintro _ ⟨⟨a, _⟩, h, ⟨⟩⟩ ⟨⟩
[GOAL]
case inr.refine'_2
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
s : Set (α ⊕ β)
hs : IsOpen s
val✝ : β
xs : inr val✝ ∈ s
⊢ (fun p => (inr p.fst, inr p.snd)) '' {p | p.fst = val✝ → p.snd ∈ inr ⁻¹' s} ⊆ {p | p.fst = inr val✝ → p.snd ∈ s}
[PROOFSTEP]
rintro _ ⟨⟨a, _⟩, h, ⟨⟩⟩ ⟨⟩
[GOAL]
case inr.refine'_2.intro.mk.intro.refl.refl
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
s : Set (α ⊕ β)
hs : IsOpen s
a snd✝ : β
xs : inr (a, snd✝).fst ∈ s
h : (a, snd✝) ∈ {p | p.fst = (a, snd✝).fst → p.snd ∈ inr ⁻¹' s}
⊢ ((fun p => (inr p.fst, inr p.snd)) (a, snd✝)).snd ∈ s
[PROOFSTEP]
exact h rfl
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
s : Set (α ⊕ β)
hs : ∀ (x : α ⊕ β), x ∈ s → {p | p.fst = x → p.snd ∈ s} ∈ UniformSpace.Core.sum.uniformity
⊢ IsOpen s
[PROOFSTEP]
constructor
[GOAL]
case left
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
s : Set (α ⊕ β)
hs : ∀ (x : α ⊕ β), x ∈ s → {p | p.fst = x → p.snd ∈ s} ∈ UniformSpace.Core.sum.uniformity
⊢ s ∈
(↑OrderDual.toDual ∘ (fun t => ↑OrderDual.toDual {s | IsOpen s}) ∘ ↑OrderDual.ofDual)
(TopologicalSpace.coinduced inl UniformSpace.toTopologicalSpace)
[PROOFSTEP]
refine' (@isOpen_iff_mem_nhds α _ _).2 fun a ha => mem_nhds_uniformity_iff_right.2 _
[GOAL]
case left
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
s : Set (α ⊕ β)
hs : ∀ (x : α ⊕ β), x ∈ s → {p | p.fst = x → p.snd ∈ s} ∈ UniformSpace.Core.sum.uniformity
a : α
ha : a ∈ inl ⁻¹' s
⊢ {p | p.fst = a → p.snd ∈ inl ⁻¹' s} ∈ 𝓤 α
[PROOFSTEP]
rcases mem_map_iff_exists_image.1 (hs _ ha).1 with ⟨t, ht, st⟩
[GOAL]
case left.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
s : Set (α ⊕ β)
hs : ∀ (x : α ⊕ β), x ∈ s → {p | p.fst = x → p.snd ∈ s} ∈ UniformSpace.Core.sum.uniformity
a : α
ha : a ∈ inl ⁻¹' s
t : Set (α × α)
ht : t ∈ 𝓤 α
st : (fun p => (inl p.fst, inl p.snd)) '' t ⊆ {p | p.fst = inl a → p.snd ∈ s}
⊢ {p | p.fst = a → p.snd ∈ inl ⁻¹' s} ∈ 𝓤 α
[PROOFSTEP]
refine' mem_of_superset ht _
[GOAL]
case left.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
s : Set (α ⊕ β)
hs : ∀ (x : α ⊕ β), x ∈ s → {p | p.fst = x → p.snd ∈ s} ∈ UniformSpace.Core.sum.uniformity
a : α
ha : a ∈ inl ⁻¹' s
t : Set (α × α)
ht : t ∈ 𝓤 α
st : (fun p => (inl p.fst, inl p.snd)) '' t ⊆ {p | p.fst = inl a → p.snd ∈ s}
⊢ t ⊆ {p | p.fst = a → p.snd ∈ inl ⁻¹' s}
[PROOFSTEP]
rintro p pt rfl
[GOAL]
case left.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
s : Set (α ⊕ β)
hs : ∀ (x : α ⊕ β), x ∈ s → {p | p.fst = x → p.snd ∈ s} ∈ UniformSpace.Core.sum.uniformity
t : Set (α × α)
ht : t ∈ 𝓤 α
p : α × α
pt : p ∈ t
ha : p.fst ∈ inl ⁻¹' s
st : (fun p => (inl p.fst, inl p.snd)) '' t ⊆ {p_1 | p_1.fst = inl p.fst → p_1.snd ∈ s}
⊢ p.snd ∈ inl ⁻¹' s
[PROOFSTEP]
exact st ⟨_, pt, rfl⟩ rfl
[GOAL]
case right
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
s : Set (α ⊕ β)
hs : ∀ (x : α ⊕ β), x ∈ s → {p | p.fst = x → p.snd ∈ s} ∈ UniformSpace.Core.sum.uniformity
⊢ s ∈
(↑OrderDual.toDual ∘ (fun t => ↑OrderDual.toDual {s | IsOpen s}) ∘ ↑OrderDual.ofDual)
(TopologicalSpace.coinduced inr UniformSpace.toTopologicalSpace)
[PROOFSTEP]
refine' (@isOpen_iff_mem_nhds β _ _).2 fun b hb => mem_nhds_uniformity_iff_right.2 _
[GOAL]
case right
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
s : Set (α ⊕ β)
hs : ∀ (x : α ⊕ β), x ∈ s → {p | p.fst = x → p.snd ∈ s} ∈ UniformSpace.Core.sum.uniformity
b : β
hb : b ∈ inr ⁻¹' s
⊢ {p | p.fst = b → p.snd ∈ inr ⁻¹' s} ∈ 𝓤 β
[PROOFSTEP]
rcases mem_map_iff_exists_image.1 (hs _ hb).2 with ⟨t, ht, st⟩
[GOAL]
case right.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
s : Set (α ⊕ β)
hs : ∀ (x : α ⊕ β), x ∈ s → {p | p.fst = x → p.snd ∈ s} ∈ UniformSpace.Core.sum.uniformity
b : β
hb : b ∈ inr ⁻¹' s
t : Set (β × β)
ht : t ∈ 𝓤 β
st : (fun p => (inr p.fst, inr p.snd)) '' t ⊆ {p | p.fst = inr b → p.snd ∈ s}
⊢ {p | p.fst = b → p.snd ∈ inr ⁻¹' s} ∈ 𝓤 β
[PROOFSTEP]
refine' mem_of_superset ht _
[GOAL]
case right.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
s : Set (α ⊕ β)
hs : ∀ (x : α ⊕ β), x ∈ s → {p | p.fst = x → p.snd ∈ s} ∈ UniformSpace.Core.sum.uniformity
b : β
hb : b ∈ inr ⁻¹' s
t : Set (β × β)
ht : t ∈ 𝓤 β
st : (fun p => (inr p.fst, inr p.snd)) '' t ⊆ {p | p.fst = inr b → p.snd ∈ s}
⊢ t ⊆ {p | p.fst = b → p.snd ∈ inr ⁻¹' s}
[PROOFSTEP]
rintro p pt rfl
[GOAL]
case right.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : UniformSpace β
s : Set (α ⊕ β)
hs : ∀ (x : α ⊕ β), x ∈ s → {p | p.fst = x → p.snd ∈ s} ∈ UniformSpace.Core.sum.uniformity
t : Set (β × β)
ht : t ∈ 𝓤 β
p : β × β
pt : p ∈ t
hb : p.fst ∈ inr ⁻¹' s
st : (fun p => (inr p.fst, inr p.snd)) '' t ⊆ {p_1 | p_1.fst = inr p.fst → p_1.snd ∈ s}
⊢ p.snd ∈ inr ⁻¹' s
[PROOFSTEP]
exact st ⟨_, pt, rfl⟩ rfl
[GOAL]
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ (i : ι), c i
⊢ ∃ n, n ∈ 𝓤 α ∧ ∀ (x : α), x ∈ s → ∃ i, {y | (x, y) ∈ n} ⊆ c i
[PROOFSTEP]
let u n := {x | ∃ i, ∃ m ∈ 𝓤 α, {y | (x, y) ∈ m ○ n} ⊆ c i}
[GOAL]
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ (i : ι), c i
u : Set (α × α) → Set α := fun n => {x | ∃ i m, m ∈ 𝓤 α ∧ {y | (x, y) ∈ m ○ n} ⊆ c i}
⊢ ∃ n, n ∈ 𝓤 α ∧ ∀ (x : α), x ∈ s → ∃ i, {y | (x, y) ∈ n} ⊆ c i
[PROOFSTEP]
have hu₁ : ∀ n ∈ 𝓤 α, IsOpen (u n) := by
refine' fun n _ => isOpen_uniformity.2 _
rintro x ⟨i, m, hm, h⟩
rcases comp_mem_uniformity_sets hm with ⟨m', hm', mm'⟩
apply (𝓤 α).sets_of_superset hm'
rintro ⟨x, y⟩ hp rfl
refine' ⟨i, m', hm', fun z hz => h (monotone_id.compRel monotone_const mm' _)⟩
dsimp [-mem_compRel] at hz ⊢
rw [compRel_assoc]
exact ⟨y, hp, hz⟩
[GOAL]
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ (i : ι), c i
u : Set (α × α) → Set α := fun n => {x | ∃ i m, m ∈ 𝓤 α ∧ {y | (x, y) ∈ m ○ n} ⊆ c i}
⊢ ∀ (n : Set (α × α)), n ∈ 𝓤 α → IsOpen (u n)
[PROOFSTEP]
refine' fun n _ => isOpen_uniformity.2 _
[GOAL]
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ (i : ι), c i
u : Set (α × α) → Set α := fun n => {x | ∃ i m, m ∈ 𝓤 α ∧ {y | (x, y) ∈ m ○ n} ⊆ c i}
n : Set (α × α)
x✝ : n ∈ 𝓤 α
⊢ ∀ (x : α), x ∈ u n → {p | p.fst = x → p.snd ∈ u n} ∈ 𝓤 α
[PROOFSTEP]
rintro x ⟨i, m, hm, h⟩
[GOAL]
case intro.intro.intro
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ (i : ι), c i
u : Set (α × α) → Set α := fun n => {x | ∃ i m, m ∈ 𝓤 α ∧ {y | (x, y) ∈ m ○ n} ⊆ c i}
n : Set (α × α)
x✝ : n ∈ 𝓤 α
x : α
i : ι
m : Set (α × α)
hm : m ∈ 𝓤 α
h : {y | (x, y) ∈ m ○ n} ⊆ c i
⊢ {p | p.fst = x → p.snd ∈ u n} ∈ 𝓤 α
[PROOFSTEP]
rcases comp_mem_uniformity_sets hm with ⟨m', hm', mm'⟩
[GOAL]
case intro.intro.intro.intro.intro
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ (i : ι), c i
u : Set (α × α) → Set α := fun n => {x | ∃ i m, m ∈ 𝓤 α ∧ {y | (x, y) ∈ m ○ n} ⊆ c i}
n : Set (α × α)
x✝ : n ∈ 𝓤 α
x : α
i : ι
m : Set (α × α)
hm : m ∈ 𝓤 α
h : {y | (x, y) ∈ m ○ n} ⊆ c i
m' : Set (α × α)
hm' : m' ∈ 𝓤 α
mm' : m' ○ m' ⊆ m
⊢ {p | p.fst = x → p.snd ∈ u n} ∈ 𝓤 α
[PROOFSTEP]
apply (𝓤 α).sets_of_superset hm'
[GOAL]
case intro.intro.intro.intro.intro
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ (i : ι), c i
u : Set (α × α) → Set α := fun n => {x | ∃ i m, m ∈ 𝓤 α ∧ {y | (x, y) ∈ m ○ n} ⊆ c i}
n : Set (α × α)
x✝ : n ∈ 𝓤 α
x : α
i : ι
m : Set (α × α)
hm : m ∈ 𝓤 α
h : {y | (x, y) ∈ m ○ n} ⊆ c i
m' : Set (α × α)
hm' : m' ∈ 𝓤 α
mm' : m' ○ m' ⊆ m
⊢ m' ⊆ {p | p.fst = x → p.snd ∈ u n}
[PROOFSTEP]
rintro ⟨x, y⟩ hp rfl
[GOAL]
case intro.intro.intro.intro.intro.mk
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ (i : ι), c i
u : Set (α × α) → Set α := fun n => {x | ∃ i m, m ∈ 𝓤 α ∧ {y | (x, y) ∈ m ○ n} ⊆ c i}
n : Set (α × α)
x✝ : n ∈ 𝓤 α
i : ι
m : Set (α × α)
hm : m ∈ 𝓤 α
m' : Set (α × α)
hm' : m' ∈ 𝓤 α
mm' : m' ○ m' ⊆ m
x y : α
hp : (x, y) ∈ m'
h : {y_1 | ((x, y).fst, y_1) ∈ m ○ n} ⊆ c i
⊢ (x, y).snd ∈ u n
[PROOFSTEP]
refine' ⟨i, m', hm', fun z hz => h (monotone_id.compRel monotone_const mm' _)⟩
[GOAL]
case intro.intro.intro.intro.intro.mk
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ (i : ι), c i
u : Set (α × α) → Set α := fun n => {x | ∃ i m, m ∈ 𝓤 α ∧ {y | (x, y) ∈ m ○ n} ⊆ c i}
n : Set (α × α)
x✝ : n ∈ 𝓤 α
i : ι
m : Set (α × α)
hm : m ∈ 𝓤 α
m' : Set (α × α)
hm' : m' ∈ 𝓤 α
mm' : m' ○ m' ⊆ m
x y : α
hp : (x, y) ∈ m'
h : {y_1 | ((x, y).fst, y_1) ∈ m ○ n} ⊆ c i
z : α
hz : z ∈ {y_1 | ((x, y).snd, y_1) ∈ m' ○ n}
⊢ ((x, y).fst, z) ∈ (fun x => id x ○ n) (m' ○ m')
[PROOFSTEP]
dsimp [-mem_compRel] at hz ⊢
[GOAL]
case intro.intro.intro.intro.intro.mk
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ (i : ι), c i
u : Set (α × α) → Set α := fun n => {x | ∃ i m, m ∈ 𝓤 α ∧ {y | (x, y) ∈ m ○ n} ⊆ c i}
n : Set (α × α)
x✝ : n ∈ 𝓤 α
i : ι
m : Set (α × α)
hm : m ∈ 𝓤 α
m' : Set (α × α)
hm' : m' ∈ 𝓤 α
mm' : m' ○ m' ⊆ m
x y : α
hp : (x, y) ∈ m'
h : {y_1 | ((x, y).fst, y_1) ∈ m ○ n} ⊆ c i
z : α
hz : (y, z) ∈ m' ○ n
⊢ (x, z) ∈ m' ○ m' ○ n
[PROOFSTEP]
rw [compRel_assoc]
[GOAL]
case intro.intro.intro.intro.intro.mk
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ (i : ι), c i
u : Set (α × α) → Set α := fun n => {x | ∃ i m, m ∈ 𝓤 α ∧ {y | (x, y) ∈ m ○ n} ⊆ c i}
n : Set (α × α)
x✝ : n ∈ 𝓤 α
i : ι
m : Set (α × α)
hm : m ∈ 𝓤 α
m' : Set (α × α)
hm' : m' ∈ 𝓤 α
mm' : m' ○ m' ⊆ m
x y : α
hp : (x, y) ∈ m'
h : {y_1 | ((x, y).fst, y_1) ∈ m ○ n} ⊆ c i
z : α
hz : (y, z) ∈ m' ○ n
⊢ (x, z) ∈ m' ○ (m' ○ n)
[PROOFSTEP]
exact ⟨y, hp, hz⟩
[GOAL]
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ (i : ι), c i
u : Set (α × α) → Set α := fun n => {x | ∃ i m, m ∈ 𝓤 α ∧ {y | (x, y) ∈ m ○ n} ⊆ c i}
hu₁ : ∀ (n : Set (α × α)), n ∈ 𝓤 α → IsOpen (u n)
⊢ ∃ n, n ∈ 𝓤 α ∧ ∀ (x : α), x ∈ s → ∃ i, {y | (x, y) ∈ n} ⊆ c i
[PROOFSTEP]
have hu₂ : s ⊆ ⋃ n ∈ 𝓤 α, u n := fun x hx =>
by
rcases mem_iUnion.1 (hc₂ hx) with ⟨i, h⟩
rcases comp_mem_uniformity_sets (isOpen_uniformity.1 (hc₁ i) x h) with ⟨m', hm', mm'⟩
exact mem_biUnion hm' ⟨i, _, hm', fun y hy => mm' hy rfl⟩
[GOAL]
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ (i : ι), c i
u : Set (α × α) → Set α := fun n => {x | ∃ i m, m ∈ 𝓤 α ∧ {y | (x, y) ∈ m ○ n} ⊆ c i}
hu₁ : ∀ (n : Set (α × α)), n ∈ 𝓤 α → IsOpen (u n)
x : α
hx : x ∈ s
⊢ x ∈ ⋃ (n : Set (α × α)) (_ : n ∈ 𝓤 α), u n
[PROOFSTEP]
rcases mem_iUnion.1 (hc₂ hx) with ⟨i, h⟩
[GOAL]
case intro
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ (i : ι), c i
u : Set (α × α) → Set α := fun n => {x | ∃ i m, m ∈ 𝓤 α ∧ {y | (x, y) ∈ m ○ n} ⊆ c i}
hu₁ : ∀ (n : Set (α × α)), n ∈ 𝓤 α → IsOpen (u n)
x : α
hx : x ∈ s
i : ι
h : x ∈ c i
⊢ x ∈ ⋃ (n : Set (α × α)) (_ : n ∈ 𝓤 α), u n
[PROOFSTEP]
rcases comp_mem_uniformity_sets (isOpen_uniformity.1 (hc₁ i) x h) with ⟨m', hm', mm'⟩
[GOAL]
case intro.intro.intro
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ (i : ι), c i
u : Set (α × α) → Set α := fun n => {x | ∃ i m, m ∈ 𝓤 α ∧ {y | (x, y) ∈ m ○ n} ⊆ c i}
hu₁ : ∀ (n : Set (α × α)), n ∈ 𝓤 α → IsOpen (u n)
x : α
hx : x ∈ s
i : ι
h : x ∈ c i
m' : Set (α × α)
hm' : m' ∈ 𝓤 α
mm' : m' ○ m' ⊆ {p | p.fst = x → p.snd ∈ c i}
⊢ x ∈ ⋃ (n : Set (α × α)) (_ : n ∈ 𝓤 α), u n
[PROOFSTEP]
exact mem_biUnion hm' ⟨i, _, hm', fun y hy => mm' hy rfl⟩
[GOAL]
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ (i : ι), c i
u : Set (α × α) → Set α := fun n => {x | ∃ i m, m ∈ 𝓤 α ∧ {y | (x, y) ∈ m ○ n} ⊆ c i}
hu₁ : ∀ (n : Set (α × α)), n ∈ 𝓤 α → IsOpen (u n)
hu₂ : s ⊆ ⋃ (n : Set (α × α)) (_ : n ∈ 𝓤 α), u n
⊢ ∃ n, n ∈ 𝓤 α ∧ ∀ (x : α), x ∈ s → ∃ i, {y | (x, y) ∈ n} ⊆ c i
[PROOFSTEP]
rcases hs.elim_finite_subcover_image hu₁ hu₂ with ⟨b, bu, b_fin, b_cover⟩
[GOAL]
case intro.intro.intro
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ (i : ι), c i
u : Set (α × α) → Set α := fun n => {x | ∃ i m, m ∈ 𝓤 α ∧ {y | (x, y) ∈ m ○ n} ⊆ c i}
hu₁ : ∀ (n : Set (α × α)), n ∈ 𝓤 α → IsOpen (u n)
hu₂ : s ⊆ ⋃ (n : Set (α × α)) (_ : n ∈ 𝓤 α), u n
b : Set (Set (α × α))
bu : b ⊆ (𝓤 α).sets
b_fin : Set.Finite b
b_cover : s ⊆ ⋃ (i : Set (α × α)) (_ : i ∈ b), u i
⊢ ∃ n, n ∈ 𝓤 α ∧ ∀ (x : α), x ∈ s → ∃ i, {y | (x, y) ∈ n} ⊆ c i
[PROOFSTEP]
refine' ⟨_, (biInter_mem b_fin).2 bu, fun x hx => _⟩
[GOAL]
case intro.intro.intro
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ (i : ι), c i
u : Set (α × α) → Set α := fun n => {x | ∃ i m, m ∈ 𝓤 α ∧ {y | (x, y) ∈ m ○ n} ⊆ c i}
hu₁ : ∀ (n : Set (α × α)), n ∈ 𝓤 α → IsOpen (u n)
hu₂ : s ⊆ ⋃ (n : Set (α × α)) (_ : n ∈ 𝓤 α), u n
b : Set (Set (α × α))
bu : b ⊆ (𝓤 α).sets
b_fin : Set.Finite b
b_cover : s ⊆ ⋃ (i : Set (α × α)) (_ : i ∈ b), u i
x : α
hx : x ∈ s
⊢ ∃ i, {y | (x, y) ∈ ⋂ (i : Set (α × α)) (_ : i ∈ b), i} ⊆ c i
[PROOFSTEP]
rcases mem_iUnion₂.1 (b_cover hx) with ⟨n, bn, i, m, hm, h⟩
[GOAL]
case intro.intro.intro.intro.intro.intro.intro.intro
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ (i : ι), c i
u : Set (α × α) → Set α := fun n => {x | ∃ i m, m ∈ 𝓤 α ∧ {y | (x, y) ∈ m ○ n} ⊆ c i}
hu₁ : ∀ (n : Set (α × α)), n ∈ 𝓤 α → IsOpen (u n)
hu₂ : s ⊆ ⋃ (n : Set (α × α)) (_ : n ∈ 𝓤 α), u n
b : Set (Set (α × α))
bu : b ⊆ (𝓤 α).sets
b_fin : Set.Finite b
b_cover : s ⊆ ⋃ (i : Set (α × α)) (_ : i ∈ b), u i
x : α
hx : x ∈ s
n : Set (α × α)
bn : n ∈ b
i : ι
m : Set (α × α)
hm : m ∈ 𝓤 α
h : {y | (x, y) ∈ m ○ n} ⊆ c i
⊢ ∃ i, {y | (x, y) ∈ ⋂ (i : Set (α × α)) (_ : i ∈ b), i} ⊆ c i
[PROOFSTEP]
refine' ⟨i, fun y hy => h _⟩
[GOAL]
case intro.intro.intro.intro.intro.intro.intro.intro
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ (i : ι), c i
u : Set (α × α) → Set α := fun n => {x | ∃ i m, m ∈ 𝓤 α ∧ {y | (x, y) ∈ m ○ n} ⊆ c i}
hu₁ : ∀ (n : Set (α × α)), n ∈ 𝓤 α → IsOpen (u n)
hu₂ : s ⊆ ⋃ (n : Set (α × α)) (_ : n ∈ 𝓤 α), u n
b : Set (Set (α × α))
bu : b ⊆ (𝓤 α).sets
b_fin : Set.Finite b
b_cover : s ⊆ ⋃ (i : Set (α × α)) (_ : i ∈ b), u i
x : α
hx : x ∈ s
n : Set (α × α)
bn : n ∈ b
i : ι
m : Set (α × α)
hm : m ∈ 𝓤 α
h : {y | (x, y) ∈ m ○ n} ⊆ c i
y : α
hy : y ∈ {y | (x, y) ∈ ⋂ (i : Set (α × α)) (_ : i ∈ b), i}
⊢ y ∈ {y | (x, y) ∈ m ○ n}
[PROOFSTEP]
exact prod_mk_mem_compRel (refl_mem_uniformity hm) (biInter_subset_of_mem bn hy)
[GOAL]
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
c : Set (Set α)
hs : IsCompact s
hc₁ : ∀ (t : Set α), t ∈ c → IsOpen t
hc₂ : s ⊆ ⋃₀ c
⊢ ∃ n, n ∈ 𝓤 α ∧ ∀ (x : α), x ∈ s → ∃ t, t ∈ c ∧ ∀ (y : α), (x, y) ∈ n → y ∈ t
[PROOFSTEP]
rw [sUnion_eq_iUnion] at hc₂
[GOAL]
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
c : Set (Set α)
hs : IsCompact s
hc₁ : ∀ (t : Set α), t ∈ c → IsOpen t
hc₂ : s ⊆ ⋃ (i : ↑c), ↑i
⊢ ∃ n, n ∈ 𝓤 α ∧ ∀ (x : α), x ∈ s → ∃ t, t ∈ c ∧ ∀ (y : α), (x, y) ∈ n → y ∈ t
[PROOFSTEP]
simpa using lebesgue_number_lemma hs (by simpa) hc₂
[GOAL]
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
c : Set (Set α)
hs : IsCompact s
hc₁ : ∀ (t : Set α), t ∈ c → IsOpen t
hc₂ : s ⊆ ⋃ (i : ↑c), ↑i
⊢ ∀ (i : ↑c), IsOpen ↑i
[PROOFSTEP]
simpa
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
K U : Set α
hK : IsCompact K
hU : IsOpen U
hKU : K ⊆ U
⊢ ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ ∀ (x : α), x ∈ K → UniformSpace.ball x V ⊆ U
[PROOFSTEP]
let W : K → Set (α × α) := fun k => Classical.choose <| isOpen_iff_open_ball_subset.mp hU k.1 <| hKU k.2
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
K U : Set α
hK : IsCompact K
hU : IsOpen U
hKU : K ⊆ U
W : ↑K → Set (α × α) := fun k => Classical.choose (_ : ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ UniformSpace.ball (↑k) V ⊆ U)
⊢ ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ ∀ (x : α), x ∈ K → UniformSpace.ball x V ⊆ U
[PROOFSTEP]
have hW : ∀ k, W k ∈ 𝓤 α ∧ IsOpen (W k) ∧ UniformSpace.ball k.1 (W k) ⊆ U :=
by
intro k
obtain ⟨h₁, h₂, h₃⟩ := Classical.choose_spec (isOpen_iff_open_ball_subset.mp hU k.1 (hKU k.2))
exact ⟨h₁, h₂, h₃⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
K U : Set α
hK : IsCompact K
hU : IsOpen U
hKU : K ⊆ U
W : ↑K → Set (α × α) := fun k => Classical.choose (_ : ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ UniformSpace.ball (↑k) V ⊆ U)
⊢ ∀ (k : ↑K), W k ∈ 𝓤 α ∧ IsOpen (W k) ∧ UniformSpace.ball (↑k) (W k) ⊆ U
[PROOFSTEP]
intro k
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
K U : Set α
hK : IsCompact K
hU : IsOpen U
hKU : K ⊆ U
W : ↑K → Set (α × α) := fun k => Classical.choose (_ : ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ UniformSpace.ball (↑k) V ⊆ U)
k : ↑K
⊢ W k ∈ 𝓤 α ∧ IsOpen (W k) ∧ UniformSpace.ball (↑k) (W k) ⊆ U
[PROOFSTEP]
obtain ⟨h₁, h₂, h₃⟩ := Classical.choose_spec (isOpen_iff_open_ball_subset.mp hU k.1 (hKU k.2))
[GOAL]
case intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
K U : Set α
hK : IsCompact K
hU : IsOpen U
hKU : K ⊆ U
W : ↑K → Set (α × α) := fun k => Classical.choose (_ : ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ UniformSpace.ball (↑k) V ⊆ U)
k : ↑K
h₁ : Classical.choose (_ : ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ UniformSpace.ball (↑k) V ⊆ U) ∈ 𝓤 α
h₂ : IsOpen (Classical.choose (_ : ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ UniformSpace.ball (↑k) V ⊆ U))
h₃ : UniformSpace.ball (↑k) (Classical.choose (_ : ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ UniformSpace.ball (↑k) V ⊆ U)) ⊆ U
⊢ W k ∈ 𝓤 α ∧ IsOpen (W k) ∧ UniformSpace.ball (↑k) (W k) ⊆ U
[PROOFSTEP]
exact ⟨h₁, h₂, h₃⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
K U : Set α
hK : IsCompact K
hU : IsOpen U
hKU : K ⊆ U
W : ↑K → Set (α × α) := fun k => Classical.choose (_ : ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ UniformSpace.ball (↑k) V ⊆ U)
hW : ∀ (k : ↑K), W k ∈ 𝓤 α ∧ IsOpen (W k) ∧ UniformSpace.ball (↑k) (W k) ⊆ U
⊢ ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ ∀ (x : α), x ∈ K → UniformSpace.ball x V ⊆ U
[PROOFSTEP]
let c : K → Set α := fun k => UniformSpace.ball k.1 (W k)
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
K U : Set α
hK : IsCompact K
hU : IsOpen U
hKU : K ⊆ U
W : ↑K → Set (α × α) := fun k => Classical.choose (_ : ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ UniformSpace.ball (↑k) V ⊆ U)
hW : ∀ (k : ↑K), W k ∈ 𝓤 α ∧ IsOpen (W k) ∧ UniformSpace.ball (↑k) (W k) ⊆ U
c : ↑K → Set α := fun k => UniformSpace.ball (↑k) (W k)
⊢ ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ ∀ (x : α), x ∈ K → UniformSpace.ball x V ⊆ U
[PROOFSTEP]
have hc₁ : ∀ k, IsOpen (c k) := fun k => UniformSpace.isOpen_ball k.1 (hW k).2.1
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
K U : Set α
hK : IsCompact K
hU : IsOpen U
hKU : K ⊆ U
W : ↑K → Set (α × α) := fun k => Classical.choose (_ : ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ UniformSpace.ball (↑k) V ⊆ U)
hW : ∀ (k : ↑K), W k ∈ 𝓤 α ∧ IsOpen (W k) ∧ UniformSpace.ball (↑k) (W k) ⊆ U
c : ↑K → Set α := fun k => UniformSpace.ball (↑k) (W k)
hc₁ : ∀ (k : ↑K), IsOpen (c k)
⊢ ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ ∀ (x : α), x ∈ K → UniformSpace.ball x V ⊆ U
[PROOFSTEP]
have hc₂ : K ⊆ ⋃ i, c i := by
intro k hk
simp only [mem_iUnion, SetCoe.exists]
exact ⟨k, hk, UniformSpace.mem_ball_self k (hW ⟨k, hk⟩).1⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
K U : Set α
hK : IsCompact K
hU : IsOpen U
hKU : K ⊆ U
W : ↑K → Set (α × α) := fun k => Classical.choose (_ : ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ UniformSpace.ball (↑k) V ⊆ U)
hW : ∀ (k : ↑K), W k ∈ 𝓤 α ∧ IsOpen (W k) ∧ UniformSpace.ball (↑k) (W k) ⊆ U
c : ↑K → Set α := fun k => UniformSpace.ball (↑k) (W k)
hc₁ : ∀ (k : ↑K), IsOpen (c k)
⊢ K ⊆ ⋃ (i : ↑K), c i
[PROOFSTEP]
intro k hk
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
K U : Set α
hK : IsCompact K
hU : IsOpen U
hKU : K ⊆ U
W : ↑K → Set (α × α) := fun k => Classical.choose (_ : ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ UniformSpace.ball (↑k) V ⊆ U)
hW : ∀ (k : ↑K), W k ∈ 𝓤 α ∧ IsOpen (W k) ∧ UniformSpace.ball (↑k) (W k) ⊆ U
c : ↑K → Set α := fun k => UniformSpace.ball (↑k) (W k)
hc₁ : ∀ (k : ↑K), IsOpen (c k)
k : α
hk : k ∈ K
⊢ k ∈ ⋃ (i : ↑K), c i
[PROOFSTEP]
simp only [mem_iUnion, SetCoe.exists]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
K U : Set α
hK : IsCompact K
hU : IsOpen U
hKU : K ⊆ U
W : ↑K → Set (α × α) := fun k => Classical.choose (_ : ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ UniformSpace.ball (↑k) V ⊆ U)
hW : ∀ (k : ↑K), W k ∈ 𝓤 α ∧ IsOpen (W k) ∧ UniformSpace.ball (↑k) (W k) ⊆ U
c : ↑K → Set α := fun k => UniformSpace.ball (↑k) (W k)
hc₁ : ∀ (k : ↑K), IsOpen (c k)
k : α
hk : k ∈ K
⊢ ∃ x h,
k ∈
UniformSpace.ball x
(Classical.choose
(_ : ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ UniformSpace.ball (↑{ val := x, property := (_ : x ∈ K) }) V ⊆ U))
[PROOFSTEP]
exact ⟨k, hk, UniformSpace.mem_ball_self k (hW ⟨k, hk⟩).1⟩
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
K U : Set α
hK : IsCompact K
hU : IsOpen U
hKU : K ⊆ U
W : ↑K → Set (α × α) := fun k => Classical.choose (_ : ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ UniformSpace.ball (↑k) V ⊆ U)
hW : ∀ (k : ↑K), W k ∈ 𝓤 α ∧ IsOpen (W k) ∧ UniformSpace.ball (↑k) (W k) ⊆ U
c : ↑K → Set α := fun k => UniformSpace.ball (↑k) (W k)
hc₁ : ∀ (k : ↑K), IsOpen (c k)
hc₂ : K ⊆ ⋃ (i : ↑K), c i
⊢ ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ ∀ (x : α), x ∈ K → UniformSpace.ball x V ⊆ U
[PROOFSTEP]
have hc₃ : ∀ k, c k ⊆ U := fun k => (hW k).2.2
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
K U : Set α
hK : IsCompact K
hU : IsOpen U
hKU : K ⊆ U
W : ↑K → Set (α × α) := fun k => Classical.choose (_ : ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ UniformSpace.ball (↑k) V ⊆ U)
hW : ∀ (k : ↑K), W k ∈ 𝓤 α ∧ IsOpen (W k) ∧ UniformSpace.ball (↑k) (W k) ⊆ U
c : ↑K → Set α := fun k => UniformSpace.ball (↑k) (W k)
hc₁ : ∀ (k : ↑K), IsOpen (c k)
hc₂ : K ⊆ ⋃ (i : ↑K), c i
hc₃ : ∀ (k : ↑K), c k ⊆ U
⊢ ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ ∀ (x : α), x ∈ K → UniformSpace.ball x V ⊆ U
[PROOFSTEP]
obtain ⟨V, hV, hV'⟩ := lebesgue_number_lemma hK hc₁ hc₂
[GOAL]
case intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
K U : Set α
hK : IsCompact K
hU : IsOpen U
hKU : K ⊆ U
W : ↑K → Set (α × α) := fun k => Classical.choose (_ : ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ UniformSpace.ball (↑k) V ⊆ U)
hW : ∀ (k : ↑K), W k ∈ 𝓤 α ∧ IsOpen (W k) ∧ UniformSpace.ball (↑k) (W k) ⊆ U
c : ↑K → Set α := fun k => UniformSpace.ball (↑k) (W k)
hc₁ : ∀ (k : ↑K), IsOpen (c k)
hc₂ : K ⊆ ⋃ (i : ↑K), c i
hc₃ : ∀ (k : ↑K), c k ⊆ U
V : Set (α × α)
hV : V ∈ 𝓤 α
hV' : ∀ (x : α), x ∈ K → ∃ i, {y | (x, y) ∈ V} ⊆ c i
⊢ ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ ∀ (x : α), x ∈ K → UniformSpace.ball x V ⊆ U
[PROOFSTEP]
refine' ⟨interior V, interior_mem_uniformity hV, isOpen_interior, _⟩
[GOAL]
case intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
K U : Set α
hK : IsCompact K
hU : IsOpen U
hKU : K ⊆ U
W : ↑K → Set (α × α) := fun k => Classical.choose (_ : ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ UniformSpace.ball (↑k) V ⊆ U)
hW : ∀ (k : ↑K), W k ∈ 𝓤 α ∧ IsOpen (W k) ∧ UniformSpace.ball (↑k) (W k) ⊆ U
c : ↑K → Set α := fun k => UniformSpace.ball (↑k) (W k)
hc₁ : ∀ (k : ↑K), IsOpen (c k)
hc₂ : K ⊆ ⋃ (i : ↑K), c i
hc₃ : ∀ (k : ↑K), c k ⊆ U
V : Set (α × α)
hV : V ∈ 𝓤 α
hV' : ∀ (x : α), x ∈ K → ∃ i, {y | (x, y) ∈ V} ⊆ c i
⊢ ∀ (x : α), x ∈ K → UniformSpace.ball x (interior V) ⊆ U
[PROOFSTEP]
intro k hk
[GOAL]
case intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
K U : Set α
hK : IsCompact K
hU : IsOpen U
hKU : K ⊆ U
W : ↑K → Set (α × α) := fun k => Classical.choose (_ : ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ UniformSpace.ball (↑k) V ⊆ U)
hW : ∀ (k : ↑K), W k ∈ 𝓤 α ∧ IsOpen (W k) ∧ UniformSpace.ball (↑k) (W k) ⊆ U
c : ↑K → Set α := fun k => UniformSpace.ball (↑k) (W k)
hc₁ : ∀ (k : ↑K), IsOpen (c k)
hc₂ : K ⊆ ⋃ (i : ↑K), c i
hc₃ : ∀ (k : ↑K), c k ⊆ U
V : Set (α × α)
hV : V ∈ 𝓤 α
hV' : ∀ (x : α), x ∈ K → ∃ i, {y | (x, y) ∈ V} ⊆ c i
k : α
hk : k ∈ K
⊢ UniformSpace.ball k (interior V) ⊆ U
[PROOFSTEP]
obtain ⟨k', hk'⟩ := hV' k hk
[GOAL]
case intro.intro.intro
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
K U : Set α
hK : IsCompact K
hU : IsOpen U
hKU : K ⊆ U
W : ↑K → Set (α × α) := fun k => Classical.choose (_ : ∃ V, V ∈ 𝓤 α ∧ IsOpen V ∧ UniformSpace.ball (↑k) V ⊆ U)
hW : ∀ (k : ↑K), W k ∈ 𝓤 α ∧ IsOpen (W k) ∧ UniformSpace.ball (↑k) (W k) ⊆ U
c : ↑K → Set α := fun k => UniformSpace.ball (↑k) (W k)
hc₁ : ∀ (k : ↑K), IsOpen (c k)
hc₂ : K ⊆ ⋃ (i : ↑K), c i
hc₃ : ∀ (k : ↑K), c k ⊆ U
V : Set (α × α)
hV : V ∈ 𝓤 α
hV' : ∀ (x : α), x ∈ K → ∃ i, {y | (x, y) ∈ V} ⊆ c i
k : α
hk : k ∈ K
k' : ↑K
hk' : {y | (k, y) ∈ V} ⊆ c k'
⊢ UniformSpace.ball k (interior V) ⊆ U
[PROOFSTEP]
exact ((ball_mono interior_subset k).trans hk').trans (hc₃ k')
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
f : Filter β
u : β → α
a : α
⊢ Tendsto u f (𝓝 a) ↔ Tendsto (fun x => (a, u x)) f (𝓤 α)
[PROOFSTEP]
rw [nhds_eq_comap_uniformity, tendsto_comap_iff]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
f : Filter β
u : β → α
a : α
⊢ Tendsto (Prod.mk a ∘ u) f (𝓤 α) ↔ Tendsto (fun x => (a, u x)) f (𝓤 α)
[PROOFSTEP]
rfl
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
f : Filter β
u : β → α
a : α
⊢ Tendsto u f (𝓝 a) ↔ Tendsto (fun x => (u x, a)) f (𝓤 α)
[PROOFSTEP]
rw [nhds_eq_comap_uniformity', tendsto_comap_iff]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
f : Filter β
u : β → α
a : α
⊢ Tendsto ((fun y => (y, a)) ∘ u) f (𝓤 α) ↔ Tendsto (fun x => (u x, a)) f (𝓤 α)
[PROOFSTEP]
rfl
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : TopologicalSpace β
f : β → α
b : β
⊢ ContinuousAt f b ↔ Tendsto (fun x => (f b, f x)) (𝓝 b) (𝓤 α)
[PROOFSTEP]
rw [ContinuousAt, tendsto_nhds_right]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : TopologicalSpace β
f : β → α
b : β
⊢ ContinuousAt f b ↔ Tendsto (fun x => (f x, f b)) (𝓝 b) (𝓤 α)
[PROOFSTEP]
rw [ContinuousAt, tendsto_nhds_left]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : TopologicalSpace β
f : β → α
b : β
s : Set β
⊢ ContinuousWithinAt f s b ↔ Tendsto (fun x => (f b, f x)) (𝓝[s] b) (𝓤 α)
[PROOFSTEP]
rw [ContinuousWithinAt, tendsto_nhds_right]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : TopologicalSpace β
f : β → α
b : β
s : Set β
⊢ ContinuousWithinAt f s b ↔ Tendsto (fun x => (f x, f b)) (𝓝[s] b) (𝓤 α)
[PROOFSTEP]
rw [ContinuousWithinAt, tendsto_nhds_left]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : TopologicalSpace β
f : β → α
s : Set β
⊢ ContinuousOn f s ↔ ∀ (b : β), b ∈ s → Tendsto (fun x => (f b, f x)) (𝓝[s] b) (𝓤 α)
[PROOFSTEP]
simp [ContinuousOn, continuousWithinAt_iff'_right]
[GOAL]
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝¹ : UniformSpace α
inst✝ : TopologicalSpace β
f : β → α
s : Set β
⊢ ContinuousOn f s ↔ ∀ (b : β), b ∈ s → Tendsto (fun x => (f x, f b)) (𝓝[s] b) (𝓤 α)
[PROOFSTEP]
simp [ContinuousOn, continuousWithinAt_iff'_left]
|
If $z$ is a real number, then $|z| = |\Re(z)|$. |
If $z$ is a real number, then $|z| = |\Re(z)|$. |
Formal statement is: lemma holomorphic_contract_to_zero: assumes contf: "continuous_on (cball \<xi> r) f" and holf: "f holomorphic_on ball \<xi> r" and "0 < r" and norm_less: "\<And>z. norm(\<xi> - z) = r \<Longrightarrow> norm(f \<xi>) < norm(f z)" obtains z where "z \<in> ball \<xi> r" "f z = 0" Informal statement is: Suppose $f$ is a holomorphic function on the open ball $B(\xi, r)$ and continuous on the closed ball $\overline{B}(\xi, r)$. If $f(\xi)$ is smaller than $f(z)$ for all $z$ on the boundary of $\overline{B}(\xi, r)$, then $f$ has a zero in $B(\xi, r)$. |
lemma Im_sgn [simp]: "Im(sgn z) = Im(z)/cmod z" |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Support for reflection
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Reflection where
import Agda.Builtin.Reflection as Builtin
------------------------------------------------------------------------
-- Names, Metas, and Literals re-exported publicly
open import Reflection.Abstraction as Abstraction public
using (Abs; abs)
open import Reflection.Argument as Argument public
using (Arg; arg; Args; vArg; hArg; iArg)
open import Reflection.Definition as Definition public
using (Definition)
open import Reflection.Meta as Meta public
using (Meta)
open import Reflection.Name as Name public
using (Name; Names)
open import Reflection.Literal as Literal public
using (Literal)
open import Reflection.Pattern as Pattern public
using (Pattern)
open import Reflection.Term as Term public
using (Term; Type; Clause; Clauses; Sort)
import Reflection.Argument.Relevance as Relevance
import Reflection.Argument.Visibility as Visibility
import Reflection.Argument.Information as Information
open Definition.Definition public
open Information.ArgInfo public
open Literal.Literal public
open Relevance.Relevance public
open Term.Term public
open Visibility.Visibility public
------------------------------------------------------------------------
-- Fixity
open Builtin public
using (non-assoc; related; unrelated; fixity)
renaming
( left-assoc to assocˡ
; right-assoc to assocʳ
; primQNameFixity to getFixity
)
------------------------------------------------------------------------
-- Type checking monad
-- Type errors
open Builtin public using (ErrorPart; strErr; termErr; nameErr)
-- The monad
open Builtin public
using ( TC; bindTC; unify; typeError; inferType; checkType
; normalise; reduce
; catchTC; quoteTC; unquoteTC
; getContext; extendContext; inContext; freshName
; declareDef; declarePostulate; defineFun; getType; getDefinition
; blockOnMeta; commitTC; isMacro; withNormalisation
; debugPrint; noConstraints; runSpeculative)
renaming (returnTC to return)
-- Standard monad operators
open import Reflection.TypeChecking.MonadSyntax public
using (_>>=_; _>>_)
newMeta : Type → TC Term
newMeta = checkType unknown
------------------------------------------------------------------------
-- Show
open import Reflection.Show public
------------------------------------------------------------------------
-- DEPRECATED NAMES
------------------------------------------------------------------------
-- Please use the new names as continuing support for the old names is
-- not guaranteed.
-- Version 1.1
returnTC = return
{-# WARNING_ON_USAGE returnTC
"Warning: returnTC was deprecated in v1.1.
Please use return instead."
#-}
-- Version 1.3
Arg-info = Information.ArgInfo
{-# WARNING_ON_USAGE Arg-info
"Warning: Arg-info was deprecated in v1.3.
Please use Reflection.Argument.Information's ArgInfo instead."
#-}
infix 4 _≟-Lit_ _≟-Name_ _≟-Meta_ _≟-Visibility_ _≟-Relevance_ _≟-Arg-info_
_≟-Pattern_ _≟-ArgPatterns_
_≟-Lit_ = Literal._≟_
{-# WARNING_ON_USAGE _≟-Lit_
"Warning: _≟-Lit_ was deprecated in v1.3.
Please use Reflection.Literal's _≟_ instead."
#-}
_≟-Name_ = Name._≟_
{-# WARNING_ON_USAGE _≟-Name_
"Warning: _≟-Name_ was deprecated in v1.3.
Please use Reflection.Name's _≟_ instead."
#-}
_≟-Meta_ = Meta._≟_
{-# WARNING_ON_USAGE _≟-Meta_
"Warning: _≟-Meta_ was deprecated in v1.3.
Please use Reflection.Meta's _≟_ instead."
#-}
_≟-Visibility_ = Visibility._≟_
{-# WARNING_ON_USAGE _≟-Visibility_
"Warning: _≟-Visibility_ was deprecated in v1.3.
Please use Reflection.Argument.Visibility's _≟_ instead."
#-}
_≟-Relevance_ = Relevance._≟_
{-# WARNING_ON_USAGE _≟-Relevance_
"Warning: _≟-Relevance_ was deprecated in v1.3.
Please use Reflection.Argument.Relevance's _≟_ instead."
#-}
_≟-Arg-info_ = Information._≟_
{-# WARNING_ON_USAGE _≟-Arg-info_
"Warning: _≟-Arg-info_ was deprecated in v1.3.
Please use Reflection.Argument.Information's _≟_ instead."
#-}
_≟-Pattern_ = Pattern._≟_
{-# WARNING_ON_USAGE _≟-Pattern_
"Warning: _≟-Pattern_ was deprecated in v1.3.
Please use Reflection.Pattern's _≟_ instead."
#-}
_≟-ArgPatterns_ = Pattern._≟s_
{-# WARNING_ON_USAGE _≟-ArgPatterns_
"Warning: _≟-ArgPatterns_ was deprecated in v1.3.
Please use Reflection.Pattern's _≟s_ instead."
#-}
map-Abs = Abstraction.map
{-# WARNING_ON_USAGE map-Abs
"Warning: map-Abs was deprecated in v1.3.
Please use Reflection.Abstraction's map instead."
#-}
map-Arg = Argument.map
{-# WARNING_ON_USAGE map-Arg
"Warning: map-Arg was deprecated in v1.3.
Please use Reflection.Argument's map instead."
#-}
map-Args = Argument.map-Args
{-# WARNING_ON_USAGE map-Args
"Warning: map-Args was deprecated in v1.3.
Please use Reflection.Argument's map-Args instead."
#-}
visibility = Information.visibility
{-# WARNING_ON_USAGE visibility
"Warning: visibility was deprecated in v1.3.
Please use Reflection.Argument.Information's visibility instead."
#-}
relevance = Information.relevance
{-# WARNING_ON_USAGE relevance
"Warning: relevance was deprecated in v1.3.
Please use Reflection.Argument.Information's relevance instead."
#-}
infix 4 _≟-AbsTerm_ _≟-AbsType_ _≟-ArgTerm_ _≟-ArgType_ _≟-Args_
_≟-Clause_ _≟-Clauses_ _≟_
_≟-Sort_
_≟-AbsTerm_ = Term._≟-AbsTerm_
{-# WARNING_ON_USAGE _≟-AbsTerm_
"Warning: _≟-AbsTerm_ was deprecated in v1.3.
Please use Reflection.Term's _≟-AbsTerm_ instead."
#-}
_≟-AbsType_ = Term._≟-AbsType_
{-# WARNING_ON_USAGE _≟-AbsType_
"Warning: _≟-AbsType_ was deprecated in v1.3.
Please use Reflection.Term's _≟-AbsType_ instead."
#-}
_≟-ArgTerm_ = Term._≟-ArgTerm_
{-# WARNING_ON_USAGE _≟-ArgTerm_
"Warning: _≟-ArgTerm_ was deprecated in v1.3.
Please use Reflection.Term's _≟-ArgTerm_ instead."
#-}
_≟-ArgType_ = Term._≟-ArgType_
{-# WARNING_ON_USAGE _≟-ArgType_
"Warning: _≟-ArgType_ was deprecated in v1.3.
Please use Reflection.Term's _≟-ArgType_ instead."
#-}
_≟-Args_ = Term._≟-Args_
{-# WARNING_ON_USAGE _≟-Args_
"Warning: _≟-Args_ was deprecated in v1.3.
Please use Reflection.Term's _≟-Args_ instead."
#-}
_≟-Clause_ = Term._≟-Clause_
{-# WARNING_ON_USAGE _≟-Clause_
"Warning: _≟-Clause_ was deprecated in v1.3.
Please use Reflection.Term's _≟-Clause_ instead."
#-}
_≟-Clauses_ = Term._≟-Clauses_
{-# WARNING_ON_USAGE _≟-Clauses_
"Warning: _≟-Clauses_ was deprecated in v1.3.
Please use Reflection.Term's _≟-Clauses_ instead."
#-}
_≟_ = Term._≟_
{-# WARNING_ON_USAGE _≟_
"Warning: _≟_ was deprecated in v1.3.
Please use Reflection.Term's _≟_ instead."
#-}
_≟-Sort_ = Term._≟-Sort_
{-# WARNING_ON_USAGE _≟-Sort_
"Warning: _≟-Sort_ was deprecated in v1.3.
Please use Reflection.Term's _≟-Sort_ instead."
#-}
|
function [stack] = fiff_read_mri(fname,read_data)
%
% [stack] = fiff_read_mri(fname,read_data)
%
% read_data argument is optional, if set to false the pixel data are
% not read. The default is to read the pixel data
%
% Read a fif format MRI description file
%
%
% Author : Matti Hamalainen, MGH Martinos Center
% License : BSD 3-clause
%
%
% Revision 1.5 2009/04/05 13:56:28 msh
% Fixed a typo in the log messages
%
% Revision 1.4 2009/04/05 13:50:08 msh
% Added voxel -> MRI coordinate transform
%
% Revision 1.3 2009/01/18 23:50:52 msh
% Handle ushort embedded data correctly
%
% Revision 1.2 2008/11/17 00:23:51 msh
% Fixed error in the coordinate system transformation between voxel and RAS coordinates
%
% Revision 1.1 2006/04/26 19:50:58 msh
% Added fiff_read_mri
%
global FIFF;
if isempty(FIFF)
FIFF = fiff_define_constants();
end
me='MNE:fiff_read_mri';
if nargin == 1
read_data = true;
elseif nargin ~= 2
error(me,'Incorrect number of arguments');
end
%
% Try to open the file
%
[ fid, tree ] = fiff_open(fname);
%
% Locate the data of interest
% Pick the first MRI set within the first MRI data block
%
mri = fiff_dir_tree_find(tree,FIFF.FIFFB_MRI);
if length(mri) == 0
fclose(fid);
error(me,'Could not find MRI data');
end
mri = mri(1);
%
set = fiff_dir_tree_find(mri,FIFF.FIFFB_MRI_SET);
if length(set) == 0
fclose(fid);
error(me,'Could not find MRI stack');
end
set = set(1);
%
slices = fiff_dir_tree_find(set,FIFF.FIFFB_MRI_SLICE);
if length(slices) == 0
fclose(fid);
error(me,'Could not find MRI slices');
end
%
% Data ID
%
tag = find_tag(mri,FIFF.FIFF_BLOCK_ID);
if ~isempty(tag)
stack.id = tag.data;
end
%
% Head -> MRI coordinate transformation
% MRI (surface RAS) -> MRI (RAS) transformation
%
stack.trans = [];
stack.ras_trans = [];
for p = 1:set.nent
kind = set.dir(p).kind;
if kind == FIFF.FIFF_COORD_TRANS
tag = fiff_read_tag(fid,set.dir(p).pos);
if tag.data.to == FIFF.FIFFV_COORD_MRI && tag.data.from == FIFF.FIFFV_COORD_HEAD
stack.trans = tag.data;
elseif tag.data.to == FIFF.FIFFV_MNE_COORD_RAS && tag.data.from == FIFF.FIFFV_COORD_MRI
stack.ras_trans = tag.data;
end
end
end
if isempty(stack.trans)
stack.trans.from = FIFF.FIFFV_COORD_HEAD;
stack.trans.to = FIFF.FIFFV_COORD_MRI;
stack.trans.trans = eye(4,4);
end
if isempty(stack.ras_trans)
stack.ras_trans.from = FIFF.FIFFV_COORD_MRI;
stack.ras_trans.to = FIFF.FIFFV_MNE_COORD_RAS;
stack.ras_trans.trans = eye(4,4);
end
stack.voxel_trans = [];
stack.nslice = length(slices);
if read_data
fprintf(1,'\tReading slice information and pixel data.');
else
fprintf(1,'\tReading slice information.');
end
for k = 1:stack.nslice
try
stack.slices(k) = read_slice(slices(k));
catch
fclose(fid);
error(me,'%s',mne_omit_first_line(lasterr));
end
if mod(k,50) == 0
fprintf(1,'.%d.',k);
end
end
fprintf(1,'.%d..[done]\n',k);
add_voxel_transform
fclose(fid);
return;
function add_voxel_transform
if stack.nslice < 2
fprintf(1,'\tOnly one slice in the stack. Voxel transformation will not be included\n');
return;
end
%
% Check that the slices really form a stack
%
for k = 1:stack.nslice-1
d = stack.slices(k+1).trans.trans(1:3,4)-stack.slices(k).trans.trans(1:3,4);
d = sqrt(d'*d);
if k == 1
d0 = d;
r0 = stack.slices(k).trans.trans(1:3,4);
n0 = stack.slices(k).trans.trans(1:3,3);
else
if abs(stack.slices(k).pixel_width-stack.slices(1).pixel_width) > 1e-4 || abs(stack.slices(k).pixel_height-stack.slices(1).pixel_height) > 1e-4
fprintf(1,'\tPixel sizes are not equal. Voxel transformation will not be included\n');
return;
end
if stack.slices(k).width ~= stack.slices(1).width || stack.slices(k).height ~= stack.slices(1).height
fprintf(1,'\tImage sizes are not equal. Voxel transformation will not be included\n');
return;
end
if abs(d-d0) > 1e-4
fprintf(1,'\tThe slices are not equally spaced. Voxel transformation will not be included\n');
return;
end
%
% Rectangular volume?
%
r1 = r0 + (k-1)*d0*n0;
d = stack.slices(k).trans.trans(1:3,4) - r1;
d = sqrt(d'*d);
if abs(d) > 1e-4
fprintf(1,'\tThe slices do not form a rectangular volume. Voxel transformation will not be included\n');
return;
end
end
end
%
% Ready to proceed
%
voxel_trans = stack.slices(1).trans;
t = eye(4);
t(1,1) = stack.slices(1).pixel_width;
t(2,2) = stack.slices(1).pixel_height;
d = stack.slices(2).trans.trans(1:3,4)-stack.slices(1).trans.trans(1:3,4);
t(3,3) = sqrt(d'*d);
voxel_trans.trans = voxel_trans.trans*t;
voxel_trans.from = FIFF.FIFFV_MNE_COORD_MRI_VOXEL;
stack.voxel_trans = voxel_trans;
fprintf(1,'\tVoxel transformation added\n');
end
function [slice] = read_slice(node)
%
% Read all components of a single slice
%
tag = find_tag(node,FIFF.FIFF_COORD_TRANS);
if isempty(tag)
error(me,'Could not find slice coordinate transformation');
end
slice.trans = tag.data;
if slice.trans.from ~= FIFF.FIFFV_COORD_MRI_SLICE || ...
slice.trans.to ~= FIFF.FIFFV_COORD_MRI
error(me,'Illegal slice coordinate transformation');
end
%
% Change the coordinate transformation so that
% ex is right
% ey is down (up in the fif file)
% ez steps to the next slice in the series
%
slice.trans.trans(1:3,2) = -slice.trans.trans(1:3,2);
%
% Pixel data info
%
tag = find_tag(node,FIFF.FIFF_MRI_PIXEL_ENCODING);
if isempty(tag)
error(me,'Pixel encoding tag missing');
end
slice.encoding = tag.data;
%
% Offset in the MRI data file if not embedded
%
tag = find_tag(node,FIFF.FIFF_MRI_PIXEL_DATA_OFFSET);
if isempty(tag)
slice.offset = -1;
else
slice.offset = tag.data;
end
%
% Format of the MRI source file
%
tag = find_tag(node,FIFF.FIFF_MRI_SOURCE_FORMAT);
if isempty(tag)
slice.source_format = 0;
else
slice.source_format = tag.data;
end
%
% Suggested scaling for the pixel values
% (not applied here)
%
tag = find_tag(node,FIFF.FIFF_MRI_PIXEL_SCALE);
if isempty(tag)
slice.scale = 1.0;
else
slice.scale = tag.data;
end
%
% Width and height in pixels
%
tag = find_tag(node,FIFF.FIFF_MRI_WIDTH);
if isempty(tag)
error(me,'Slice width missing');
end
slice.width = tag.data;
%
tag = find_tag(node,FIFF.FIFF_MRI_HEIGHT);
if isempty(tag)
error(me,'Slice height missing');
end
slice.height = tag.data;
%
% Pixel sizes
%
tag = find_tag(node,FIFF.FIFF_MRI_WIDTH_M);
if isempty(tag)
error(me,'Pixel width missing');
end
slice.pixel_width = double(tag.data)/double(slice.width);
%
tag = find_tag(node,FIFF.FIFF_MRI_HEIGHT_M);
if isempty(tag)
error(me,'Pixel height missing');
end
slice.pixel_height = double(tag.data)/double(slice.height);
%
% Are the data here or in another file?
%
tag = find_tag(node,FIFF.FIFF_MRI_SOURCE_PATH);
if isempty(tag)
slice.offset = -1;
slice.source = [];
%
% Pixel data are embedded in the fif file
%
if read_data
tag = find_tag(node,FIFF.FIFF_MRI_PIXEL_DATA);
if isempty(tag)
error(me,'Embedded pixel data missing');
end
if slice.encoding == FIFF.FIFFV_MRI_PIXEL_WORD
if tag.type ~= slice.encoding && tag.type ~= FIFF.FIFFT_USHORT
error(me,'Embedded data is in wrong format (expected %d, got %d)',...
slice.encoding,tag.type);
end
else
if tag.type ~= slice.encoding
error(me,'Embedded data is in wrong format (expected %d, got %d)',...
slice.encoding,tag.type);
end
end
if length(tag.data) ~= slice.width*slice.height
error(me,'Wrong length of pixel data');
end
%
% Reshape into an image
%
slice.data = reshape(tag.data,slice.width,slice.height)';
end
else
if slice.offset < 0
error(me,'Offset to external file missing');
end
slice.source = tag.data;
%
% External slice reading follows
%
if read_data
pname = search_pixel_file(slice.source,fname);
if isempty(pname)
error(me,'Could not locate pixel file %s',slice.source);
else
try
slice.data = read_external_pixels(pname,...
slice.offset,slice.encoding,slice.width,slice.height);
catch
error(me,'%s',mne_omit_first_line(lasterr));
end
end
end
end
end
function [name] = search_pixel_file(pname,sname)
%
% First try the file name as it is
%
if exist(pname,'file') == 2
name = pname;
else
%
% Then <set file dir>/../slices/<slice file name>
%
a = findstr(sname,'/');
if isempty(a)
d = pwd;
else
d = sname(1:a(length(a))-1);
end
a = findstr(pname,'/');
if ~isempty(a)
pname = pname(a(length(a))+1:length(pname));
end
pname = sprintf('%s/../slices/%s',d,pname);
if exist(pname,'file') == 2
name = pname;
else
name = [];
end
end
return;
end
function [pixels] = read_external_pixels(pname,offset,encoding,width,height)
%
% Read pixel data from an external file
%
if (encoding == FIFF.FIFFV_MRI_PIXEL_SWAP_WORD)
sfid = fopen(pname,'rb','ieee-le');
else
sfid = fopen(pname,'rb','ieee-be');
end
if sfid < 0
error(me,'Could not open pixel data file : %s',pname);
end
try
fseek(sfid,double(offset),'bof');
catch
error(me,'Could not position to pixel data @ %d',offset);
fclose(sfid);
end
%
% Proceed carefully according to the encoding
%
switch encoding
case FIFF.FIFFV_MRI_PIXEL_BYTE
pixels = fread(sfid,double(width*height),'uint8=>uint8');
case FIFF.FIFFV_MRI_PIXEL_WORD
pixels = fread(sfid,double(width*height),'int16=>int16');
case FIFF.FIFFV_MRI_PIXEL_SWAP_WORD
pixels = fread(sfid,double(width*height),'int16=>int16');
case FIFF.FIFFV_MRI_PIXEL_FLOAT
pixels = fread(sfid,double(width*height),'single=>double');
otherwise
fclose(sfid);
error(me,'Unknown pixel encoding : %d',encoding);
end
fclose(sfid);
%
% Reshape into an image
%
pixels = reshape(pixels,width,height)';
end
function [tag] = find_tag(node,findkind)
for p = 1:node.nent
kind = node.dir(p).kind;
pos = node.dir(p).pos;
if kind == findkind
tag = fiff_read_tag(fid,pos);
return;
end
end
tag = [];
return
end
end
|
[GOAL]
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Fan fun i => f (Fin.succ i)
c₂ : BinaryFan (f 0) c₁.pt
⊢ (b : Fin (n + 1)) → c₂.pt ⟶ f b
[PROOFSTEP]
refine' Fin.cases _ _
[GOAL]
case refine'_1
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Fan fun i => f (Fin.succ i)
c₂ : BinaryFan (f 0) c₁.pt
⊢ c₂.pt ⟶ f 0
[PROOFSTEP]
apply c₂.fst
[GOAL]
case refine'_2
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Fan fun i => f (Fin.succ i)
c₂ : BinaryFan (f 0) c₁.pt
⊢ (i : Fin n) → c₂.pt ⟶ f (Fin.succ i)
[PROOFSTEP]
intro i
[GOAL]
case refine'_2
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Fan fun i => f (Fin.succ i)
c₂ : BinaryFan (f 0) c₁.pt
i : Fin n
⊢ c₂.pt ⟶ f (Fin.succ i)
[PROOFSTEP]
apply c₂.snd ≫ c₁.π.app ⟨i⟩
[GOAL]
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Fan fun i => f (Fin.succ i)
c₂ : BinaryFan (f 0) c₁.pt
t₁ : IsLimit c₁
t₂ : IsLimit c₂
s : Cone (Discrete.functor f)
⊢ s.pt ⟶ (extendFan c₁ c₂).pt
[PROOFSTEP]
apply (BinaryFan.IsLimit.lift' t₂ (s.π.app ⟨0⟩) _).1
[GOAL]
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Fan fun i => f (Fin.succ i)
c₂ : BinaryFan (f 0) c₁.pt
t₁ : IsLimit c₁
t₂ : IsLimit c₂
s : Cone (Discrete.functor f)
⊢ ((Functor.const (Discrete (Fin (n + 1)))).obj s.pt).obj { as := 0 } ⟶ c₁.pt
[PROOFSTEP]
apply t₁.lift ⟨_, Discrete.natTrans fun ⟨i⟩ => s.π.app ⟨i.succ⟩⟩
[GOAL]
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Fan fun i => f (Fin.succ i)
c₂ : BinaryFan (f 0) c₁.pt
t₁ : IsLimit c₁
t₂ : IsLimit c₂
s : Cone (Discrete.functor f)
x✝ : Discrete (Fin (n + 1))
j : Fin (n + 1)
⊢ (fun s =>
↑(BinaryFan.IsLimit.lift' t₂ (NatTrans.app s.π { as := 0 })
(IsLimit.lift t₁
{ pt := s.pt,
π :=
Discrete.natTrans fun x =>
match x with
| { as := i } => NatTrans.app s.π { as := Fin.succ i } })))
s ≫
NatTrans.app (extendFan c₁ c₂).π { as := j } =
NatTrans.app s.π { as := j }
[PROOFSTEP]
refine' Fin.inductionOn j ?_ ?_
[GOAL]
case refine'_1
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Fan fun i => f (Fin.succ i)
c₂ : BinaryFan (f 0) c₁.pt
t₁ : IsLimit c₁
t₂ : IsLimit c₂
s : Cone (Discrete.functor f)
x✝ : Discrete (Fin (n + 1))
j : Fin (n + 1)
⊢ (fun s =>
↑(BinaryFan.IsLimit.lift' t₂ (NatTrans.app s.π { as := 0 })
(IsLimit.lift t₁
{ pt := s.pt,
π :=
Discrete.natTrans fun x =>
match x with
| { as := i } => NatTrans.app s.π { as := Fin.succ i } })))
s ≫
NatTrans.app (extendFan c₁ c₂).π { as := 0 } =
NatTrans.app s.π { as := 0 }
[PROOFSTEP]
apply (BinaryFan.IsLimit.lift' t₂ _ _).2.1
[GOAL]
case refine'_2
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Fan fun i => f (Fin.succ i)
c₂ : BinaryFan (f 0) c₁.pt
t₁ : IsLimit c₁
t₂ : IsLimit c₂
s : Cone (Discrete.functor f)
x✝ : Discrete (Fin (n + 1))
j : Fin (n + 1)
⊢ ∀ (i : Fin n),
(fun s =>
↑(BinaryFan.IsLimit.lift' t₂ (NatTrans.app s.π { as := 0 })
(IsLimit.lift t₁
{ pt := s.pt,
π :=
Discrete.natTrans fun x =>
match x with
| { as := i } => NatTrans.app s.π { as := Fin.succ i } })))
s ≫
NatTrans.app (extendFan c₁ c₂).π { as := Fin.castSucc i } =
NatTrans.app s.π { as := Fin.castSucc i } →
(fun s =>
↑(BinaryFan.IsLimit.lift' t₂ (NatTrans.app s.π { as := 0 })
(IsLimit.lift t₁
{ pt := s.pt,
π :=
Discrete.natTrans fun x =>
match x with
| { as := i } => NatTrans.app s.π { as := Fin.succ i } })))
s ≫
NatTrans.app (extendFan c₁ c₂).π { as := Fin.succ i } =
NatTrans.app s.π { as := Fin.succ i }
[PROOFSTEP]
rintro i -
[GOAL]
case refine'_2
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Fan fun i => f (Fin.succ i)
c₂ : BinaryFan (f 0) c₁.pt
t₁ : IsLimit c₁
t₂ : IsLimit c₂
s : Cone (Discrete.functor f)
x✝ : Discrete (Fin (n + 1))
j : Fin (n + 1)
i : Fin n
⊢ (fun s =>
↑(BinaryFan.IsLimit.lift' t₂ (NatTrans.app s.π { as := 0 })
(IsLimit.lift t₁
{ pt := s.pt,
π :=
Discrete.natTrans fun x =>
match x with
| { as := i } => NatTrans.app s.π { as := Fin.succ i } })))
s ≫
NatTrans.app (extendFan c₁ c₂).π { as := Fin.succ i } =
NatTrans.app s.π { as := Fin.succ i }
[PROOFSTEP]
dsimp only [extendFan_π_app]
[GOAL]
case refine'_2
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Fan fun i => f (Fin.succ i)
c₂ : BinaryFan (f 0) c₁.pt
t₁ : IsLimit c₁
t₂ : IsLimit c₂
s : Cone (Discrete.functor f)
x✝ : Discrete (Fin (n + 1))
j : Fin (n + 1)
i : Fin n
⊢ ↑(BinaryFan.IsLimit.lift' t₂ (NatTrans.app s.π { as := 0 })
(IsLimit.lift t₁ { pt := s.pt, π := Discrete.natTrans fun x => NatTrans.app s.π { as := Fin.succ x.as } })) ≫
Fin.cases (BinaryFan.fst c₂) (fun i => BinaryFan.snd c₂ ≫ NatTrans.app c₁.π { as := i }) (Fin.succ i) =
NatTrans.app s.π { as := Fin.succ i }
[PROOFSTEP]
rw [Fin.cases_succ, ← assoc, (BinaryFan.IsLimit.lift' t₂ _ _).2.2, t₁.fac]
[GOAL]
case refine'_2
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Fan fun i => f (Fin.succ i)
c₂ : BinaryFan (f 0) c₁.pt
t₁ : IsLimit c₁
t₂ : IsLimit c₂
s : Cone (Discrete.functor f)
x✝ : Discrete (Fin (n + 1))
j : Fin (n + 1)
i : Fin n
⊢ NatTrans.app { pt := s.pt, π := Discrete.natTrans fun x => NatTrans.app s.π { as := Fin.succ x.as } }.π { as := i } =
NatTrans.app s.π { as := Fin.succ i }
[PROOFSTEP]
rfl
[GOAL]
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Fan fun i => f (Fin.succ i)
c₂ : BinaryFan (f 0) c₁.pt
t₁ : IsLimit c₁
t₂ : IsLimit c₂
s : Cone (Discrete.functor f)
m : s.pt ⟶ (extendFan c₁ c₂).pt
w : ∀ (j : Discrete (Fin (n + 1))), m ≫ NatTrans.app (extendFan c₁ c₂).π j = NatTrans.app s.π j
⊢ m =
(fun s =>
↑(BinaryFan.IsLimit.lift' t₂ (NatTrans.app s.π { as := 0 })
(IsLimit.lift t₁
{ pt := s.pt,
π :=
Discrete.natTrans fun x =>
match x with
| { as := i } => NatTrans.app s.π { as := Fin.succ i } })))
s
[PROOFSTEP]
apply BinaryFan.IsLimit.hom_ext t₂
[GOAL]
case h₁
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Fan fun i => f (Fin.succ i)
c₂ : BinaryFan (f 0) c₁.pt
t₁ : IsLimit c₁
t₂ : IsLimit c₂
s : Cone (Discrete.functor f)
m : s.pt ⟶ (extendFan c₁ c₂).pt
w : ∀ (j : Discrete (Fin (n + 1))), m ≫ NatTrans.app (extendFan c₁ c₂).π j = NatTrans.app s.π j
⊢ m ≫ BinaryFan.fst c₂ =
(fun s =>
↑(BinaryFan.IsLimit.lift' t₂ (NatTrans.app s.π { as := 0 })
(IsLimit.lift t₁
{ pt := s.pt,
π :=
Discrete.natTrans fun x =>
match x with
| { as := i } => NatTrans.app s.π { as := Fin.succ i } })))
s ≫
BinaryFan.fst c₂
[PROOFSTEP]
rw [(BinaryFan.IsLimit.lift' t₂ _ _).2.1]
[GOAL]
case h₁
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Fan fun i => f (Fin.succ i)
c₂ : BinaryFan (f 0) c₁.pt
t₁ : IsLimit c₁
t₂ : IsLimit c₂
s : Cone (Discrete.functor f)
m : s.pt ⟶ (extendFan c₁ c₂).pt
w : ∀ (j : Discrete (Fin (n + 1))), m ≫ NatTrans.app (extendFan c₁ c₂).π j = NatTrans.app s.π j
⊢ m ≫ BinaryFan.fst c₂ = NatTrans.app s.π { as := 0 }
[PROOFSTEP]
apply w ⟨0⟩
[GOAL]
case h₂
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Fan fun i => f (Fin.succ i)
c₂ : BinaryFan (f 0) c₁.pt
t₁ : IsLimit c₁
t₂ : IsLimit c₂
s : Cone (Discrete.functor f)
m : s.pt ⟶ (extendFan c₁ c₂).pt
w : ∀ (j : Discrete (Fin (n + 1))), m ≫ NatTrans.app (extendFan c₁ c₂).π j = NatTrans.app s.π j
⊢ m ≫ BinaryFan.snd c₂ =
(fun s =>
↑(BinaryFan.IsLimit.lift' t₂ (NatTrans.app s.π { as := 0 })
(IsLimit.lift t₁
{ pt := s.pt,
π :=
Discrete.natTrans fun x =>
match x with
| { as := i } => NatTrans.app s.π { as := Fin.succ i } })))
s ≫
BinaryFan.snd c₂
[PROOFSTEP]
rw [(BinaryFan.IsLimit.lift' t₂ _ _).2.2]
[GOAL]
case h₂
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Fan fun i => f (Fin.succ i)
c₂ : BinaryFan (f 0) c₁.pt
t₁ : IsLimit c₁
t₂ : IsLimit c₂
s : Cone (Discrete.functor f)
m : s.pt ⟶ (extendFan c₁ c₂).pt
w : ∀ (j : Discrete (Fin (n + 1))), m ≫ NatTrans.app (extendFan c₁ c₂).π j = NatTrans.app s.π j
⊢ m ≫ BinaryFan.snd c₂ =
IsLimit.lift t₁
{ pt := s.pt,
π :=
Discrete.natTrans fun x =>
match x with
| { as := i } => NatTrans.app s.π { as := Fin.succ i } }
[PROOFSTEP]
apply t₁.uniq ⟨_, _⟩
[GOAL]
case h₂.x
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Fan fun i => f (Fin.succ i)
c₂ : BinaryFan (f 0) c₁.pt
t₁ : IsLimit c₁
t₂ : IsLimit c₂
s : Cone (Discrete.functor f)
m : s.pt ⟶ (extendFan c₁ c₂).pt
w : ∀ (j : Discrete (Fin (n + 1))), m ≫ NatTrans.app (extendFan c₁ c₂).π j = NatTrans.app s.π j
⊢ ∀ (j : Discrete (Fin n)),
(m ≫ BinaryFan.snd c₂) ≫ NatTrans.app c₁.π j =
NatTrans.app
{ pt := s.1,
π :=
Discrete.natTrans fun x =>
match x with
| { as := i } => NatTrans.app s.π { as := Fin.succ i } }.π
j
[PROOFSTEP]
rintro ⟨j⟩
[GOAL]
case h₂.x.mk
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Fan fun i => f (Fin.succ i)
c₂ : BinaryFan (f 0) c₁.pt
t₁ : IsLimit c₁
t₂ : IsLimit c₂
s : Cone (Discrete.functor f)
m : s.pt ⟶ (extendFan c₁ c₂).pt
w : ∀ (j : Discrete (Fin (n + 1))), m ≫ NatTrans.app (extendFan c₁ c₂).π j = NatTrans.app s.π j
j : Fin n
⊢ (m ≫ BinaryFan.snd c₂) ≫ NatTrans.app c₁.π { as := j } =
NatTrans.app
{ pt := s.1,
π :=
Discrete.natTrans fun x =>
match x with
| { as := i } => NatTrans.app s.π { as := Fin.succ i } }.π
{ as := j }
[PROOFSTEP]
rw [assoc]
[GOAL]
case h₂.x.mk
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Fan fun i => f (Fin.succ i)
c₂ : BinaryFan (f 0) c₁.pt
t₁ : IsLimit c₁
t₂ : IsLimit c₂
s : Cone (Discrete.functor f)
m : s.pt ⟶ (extendFan c₁ c₂).pt
w : ∀ (j : Discrete (Fin (n + 1))), m ≫ NatTrans.app (extendFan c₁ c₂).π j = NatTrans.app s.π j
j : Fin n
⊢ m ≫ BinaryFan.snd c₂ ≫ NatTrans.app c₁.π { as := j } =
NatTrans.app
{ pt := s.1,
π :=
Discrete.natTrans fun x =>
match x with
| { as := i } => NatTrans.app s.π { as := Fin.succ i } }.π
{ as := j }
[PROOFSTEP]
dsimp only [Discrete.natTrans_app]
[GOAL]
case h₂.x.mk
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Fan fun i => f (Fin.succ i)
c₂ : BinaryFan (f 0) c₁.pt
t₁ : IsLimit c₁
t₂ : IsLimit c₂
s : Cone (Discrete.functor f)
m : s.pt ⟶ (extendFan c₁ c₂).pt
w : ∀ (j : Discrete (Fin (n + 1))), m ≫ NatTrans.app (extendFan c₁ c₂).π j = NatTrans.app s.π j
j : Fin n
⊢ m ≫ BinaryFan.snd c₂ ≫ NatTrans.app c₁.π { as := j } = NatTrans.app s.π { as := Fin.succ j }
[PROOFSTEP]
rw [← w ⟨j.succ⟩]
[GOAL]
case h₂.x.mk
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Fan fun i => f (Fin.succ i)
c₂ : BinaryFan (f 0) c₁.pt
t₁ : IsLimit c₁
t₂ : IsLimit c₂
s : Cone (Discrete.functor f)
m : s.pt ⟶ (extendFan c₁ c₂).pt
w : ∀ (j : Discrete (Fin (n + 1))), m ≫ NatTrans.app (extendFan c₁ c₂).π j = NatTrans.app s.π j
j : Fin n
⊢ m ≫ BinaryFan.snd c₂ ≫ NatTrans.app c₁.π { as := j } = m ≫ NatTrans.app (extendFan c₁ c₂).π { as := Fin.succ j }
[PROOFSTEP]
dsimp only [extendFan_π_app]
[GOAL]
case h₂.x.mk
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Fan fun i => f (Fin.succ i)
c₂ : BinaryFan (f 0) c₁.pt
t₁ : IsLimit c₁
t₂ : IsLimit c₂
s : Cone (Discrete.functor f)
m : s.pt ⟶ (extendFan c₁ c₂).pt
w : ∀ (j : Discrete (Fin (n + 1))), m ≫ NatTrans.app (extendFan c₁ c₂).π j = NatTrans.app s.π j
j : Fin n
⊢ m ≫ BinaryFan.snd c₂ ≫ NatTrans.app c₁.π { as := j } =
m ≫ Fin.cases (BinaryFan.fst c₂) (fun i => BinaryFan.snd c₂ ≫ NatTrans.app c₁.π { as := i }) (Fin.succ j)
[PROOFSTEP]
rw [Fin.cases_succ]
[GOAL]
J : Type v
inst✝⁴ : SmallCategory J
C : Type u
inst✝³ : Category.{v, u} C
D : Type u'
inst✝² : Category.{v', u'} D
inst✝¹ : HasBinaryProducts C
inst✝ : HasTerminal C
f : Fin 0 → C
⊢ HasProduct f
[PROOFSTEP]
letI : HasLimitsOfShape (Discrete (Fin 0)) C :=
hasLimitsOfShape_of_equivalence (Discrete.equivalence.{0} finZeroEquiv'.symm)
[GOAL]
J : Type v
inst✝⁴ : SmallCategory J
C : Type u
inst✝³ : Category.{v, u} C
D : Type u'
inst✝² : Category.{v', u'} D
inst✝¹ : HasBinaryProducts C
inst✝ : HasTerminal C
f : Fin 0 → C
this : HasLimitsOfShape (Discrete (Fin 0)) C :=
hasLimitsOfShape_of_equivalence (Discrete.equivalence finZeroEquiv'.symm)
⊢ HasProduct f
[PROOFSTEP]
infer_instance
[GOAL]
J : Type v
inst✝⁴ : SmallCategory J
C : Type u
inst✝³ : Category.{v, u} C
D : Type u'
inst✝² : Category.{v', u'} D
inst✝¹ : HasBinaryProducts C
inst✝ : HasTerminal C
n : ℕ
f : Fin (n + 1) → C
⊢ HasProduct f
[PROOFSTEP]
haveI := hasProduct_fin n
[GOAL]
J : Type v
inst✝⁴ : SmallCategory J
C : Type u
inst✝³ : Category.{v, u} C
D : Type u'
inst✝² : Category.{v', u'} D
inst✝¹ : HasBinaryProducts C
inst✝ : HasTerminal C
n : ℕ
f : Fin (n + 1) → C
this : ∀ (f : Fin n → C), HasProduct f
⊢ HasProduct f
[PROOFSTEP]
apply HasLimit.mk ⟨_, extendFanIsLimit f (limit.isLimit _) (limit.isLimit _)⟩
[GOAL]
J : Type v
inst✝⁴ : SmallCategory J
C : Type u
inst✝³ : Category.{v, u} C
D : Type u'
inst✝² : Category.{v', u'} D
inst✝¹ : HasBinaryProducts C
inst✝ : HasTerminal C
⊢ HasFiniteProducts C
[PROOFSTEP]
refine' ⟨fun n => ⟨fun K => _⟩⟩
[GOAL]
J : Type v
inst✝⁴ : SmallCategory J
C : Type u
inst✝³ : Category.{v, u} C
D : Type u'
inst✝² : Category.{v', u'} D
inst✝¹ : HasBinaryProducts C
inst✝ : HasTerminal C
n : ℕ
K : Discrete (Fin n) ⥤ C
⊢ HasLimit K
[PROOFSTEP]
letI := hasProduct_fin n fun n => K.obj ⟨n⟩
[GOAL]
J : Type v
inst✝⁴ : SmallCategory J
C : Type u
inst✝³ : Category.{v, u} C
D : Type u'
inst✝² : Category.{v', u'} D
inst✝¹ : HasBinaryProducts C
inst✝ : HasTerminal C
n : ℕ
K : Discrete (Fin n) ⥤ C
this : HasProduct fun n_1 => K.obj { as := n_1 } := CategoryTheory.hasProduct_fin n fun n_1 => K.obj { as := n_1 }
⊢ HasLimit K
[PROOFSTEP]
let that : (Discrete.functor fun n => K.obj ⟨n⟩) ≅ K := Discrete.natIso fun ⟨i⟩ => Iso.refl _
[GOAL]
J : Type v
inst✝⁴ : SmallCategory J
C : Type u
inst✝³ : Category.{v, u} C
D : Type u'
inst✝² : Category.{v', u'} D
inst✝¹ : HasBinaryProducts C
inst✝ : HasTerminal C
n : ℕ
K : Discrete (Fin n) ⥤ C
this : HasProduct fun n_1 => K.obj { as := n_1 } := CategoryTheory.hasProduct_fin n fun n_1 => K.obj { as := n_1 }
that : (Discrete.functor fun n_1 => K.obj { as := n_1 }) ≅ K :=
Discrete.natIso fun x =>
match x with
| { as := i } => Iso.refl ((Discrete.functor fun n_1 => K.obj { as := n_1 }).obj { as := i })
⊢ HasLimit K
[PROOFSTEP]
apply @hasLimitOfIso _ _ _ _ _ _ this that
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesLimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesLimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteProducts C
f : Fin 0 → C
⊢ PreservesLimit (Discrete.functor f) F
[PROOFSTEP]
letI : PreservesLimitsOfShape (Discrete (Fin 0)) F :=
preservesLimitsOfShapeOfEquiv.{0, 0} (Discrete.equivalence finZeroEquiv'.symm) _
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesLimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesLimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteProducts C
f : Fin 0 → C
this : PreservesLimitsOfShape (Discrete (Fin 0)) F :=
preservesLimitsOfShapeOfEquiv (Discrete.equivalence finZeroEquiv'.symm) F
⊢ PreservesLimit (Discrete.functor f) F
[PROOFSTEP]
infer_instance
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesLimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesLimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteProducts C
n : ℕ
⊢ (f : Fin (n + 1) → C) → PreservesLimit (Discrete.functor f) F
[PROOFSTEP]
haveI := preservesFinOfPreservesBinaryAndTerminal n
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesLimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesLimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteProducts C
n : ℕ
this : (f : Fin n → C) → PreservesLimit (Discrete.functor f) F
⊢ (f : Fin (n + 1) → C) → PreservesLimit (Discrete.functor f) F
[PROOFSTEP]
intro f
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesLimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesLimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteProducts C
n : ℕ
this : (f : Fin n → C) → PreservesLimit (Discrete.functor f) F
f : Fin (n + 1) → C
⊢ PreservesLimit (Discrete.functor f) F
[PROOFSTEP]
refine' preservesLimitOfPreservesLimitCone (extendFanIsLimit f (limit.isLimit _) (limit.isLimit _)) _
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesLimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesLimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteProducts C
n : ℕ
this : (f : Fin n → C) → PreservesLimit (Discrete.functor f) F
f : Fin (n + 1) → C
⊢ IsLimit
(F.mapCone
(extendFan (limit.cone (Discrete.functor fun i => f (Fin.succ i)))
(limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt))))
[PROOFSTEP]
apply (isLimitMapConeFanMkEquiv _ _ _).symm _
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesLimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesLimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteProducts C
n : ℕ
this : (f : Fin n → C) → PreservesLimit (Discrete.functor f) F
f : Fin (n + 1) → C
⊢ IsLimit
(Fan.mk (F.obj (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt) fun j =>
F.map
(Fin.cases (BinaryFan.fst (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
BinaryFan.snd (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)) ≫
NatTrans.app (limit.cone (Discrete.functor fun i => f (Fin.succ i))).π { as := i })
j))
[PROOFSTEP]
let this :=
extendFanIsLimit (fun i => F.obj (f i)) (isLimitOfHasProductOfPreservesLimit F _)
(isLimitOfHasBinaryProductOfPreservesLimit F _ _)
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesLimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesLimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteProducts C
n : ℕ
this✝ : (f : Fin n → C) → PreservesLimit (Discrete.functor f) F
f : Fin (n + 1) → C
this : IsLimit
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))) :=
extendFanIsLimit (fun i => F.obj (f i)) (isLimitOfHasProductOfPreservesLimit F fun i => f (Fin.succ i))
(isLimitOfHasBinaryProductOfPreservesLimit F (f 0) (∏ fun i => f (Fin.succ i)))
⊢ IsLimit
(Fan.mk (F.obj (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt) fun j =>
F.map
(Fin.cases (BinaryFan.fst (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
BinaryFan.snd (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)) ≫
NatTrans.app (limit.cone (Discrete.functor fun i => f (Fin.succ i))).π { as := i })
j))
[PROOFSTEP]
refine' IsLimit.ofIsoLimit this _
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesLimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesLimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteProducts C
n : ℕ
this✝ : (f : Fin n → C) → PreservesLimit (Discrete.functor f) F
f : Fin (n + 1) → C
this : IsLimit
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))) :=
extendFanIsLimit (fun i => F.obj (f i)) (isLimitOfHasProductOfPreservesLimit F fun i => f (Fin.succ i))
(isLimitOfHasBinaryProductOfPreservesLimit F (f 0) (∏ fun i => f (Fin.succ i)))
⊢ extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd)) ≅
Fan.mk (F.obj (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt) fun j =>
F.map
(Fin.cases (BinaryFan.fst (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
BinaryFan.snd (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)) ≫
NatTrans.app (limit.cone (Discrete.functor fun i => f (Fin.succ i))).π { as := i })
j)
[PROOFSTEP]
apply Cones.ext _ _
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesLimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesLimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteProducts C
n : ℕ
this✝ : (f : Fin n → C) → PreservesLimit (Discrete.functor f) F
f : Fin (n + 1) → C
this : IsLimit
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))) :=
extendFanIsLimit (fun i => F.obj (f i)) (isLimitOfHasProductOfPreservesLimit F fun i => f (Fin.succ i))
(isLimitOfHasBinaryProductOfPreservesLimit F (f 0) (∏ fun i => f (Fin.succ i)))
⊢ (extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))).pt ≅
(Fan.mk (F.obj (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt) fun j =>
F.map
(Fin.cases
(BinaryFan.fst (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
BinaryFan.snd (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)) ≫
NatTrans.app (limit.cone (Discrete.functor fun i => f (Fin.succ i))).π { as := i })
j)).pt
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesLimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesLimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteProducts C
n : ℕ
this✝ : (f : Fin n → C) → PreservesLimit (Discrete.functor f) F
f : Fin (n + 1) → C
this : IsLimit
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))) :=
extendFanIsLimit (fun i => F.obj (f i)) (isLimitOfHasProductOfPreservesLimit F fun i => f (Fin.succ i))
(isLimitOfHasBinaryProductOfPreservesLimit F (f 0) (∏ fun i => f (Fin.succ i)))
⊢ ∀ (j : Discrete (Fin (n + 1))),
NatTrans.app
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))).π
j =
?m.14831.hom ≫
NatTrans.app
(Fan.mk (F.obj (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt)
fun j =>
F.map
(Fin.cases
(BinaryFan.fst (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
BinaryFan.snd (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)) ≫
NatTrans.app (limit.cone (Discrete.functor fun i => f (Fin.succ i))).π { as := i })
j)).π
j
[PROOFSTEP]
apply Iso.refl _
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesLimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesLimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteProducts C
n : ℕ
this✝ : (f : Fin n → C) → PreservesLimit (Discrete.functor f) F
f : Fin (n + 1) → C
this : IsLimit
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))) :=
extendFanIsLimit (fun i => F.obj (f i)) (isLimitOfHasProductOfPreservesLimit F fun i => f (Fin.succ i))
(isLimitOfHasBinaryProductOfPreservesLimit F (f 0) (∏ fun i => f (Fin.succ i)))
⊢ ∀ (j : Discrete (Fin (n + 1))),
NatTrans.app
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))).π
j =
(Iso.refl
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))).pt).hom ≫
NatTrans.app
(Fan.mk (F.obj (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt)
fun j =>
F.map
(Fin.cases
(BinaryFan.fst (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
BinaryFan.snd (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)) ≫
NatTrans.app (limit.cone (Discrete.functor fun i => f (Fin.succ i))).π { as := i })
j)).π
j
[PROOFSTEP]
rintro ⟨j⟩
[GOAL]
case mk
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesLimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesLimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteProducts C
n : ℕ
this✝ : (f : Fin n → C) → PreservesLimit (Discrete.functor f) F
f : Fin (n + 1) → C
this : IsLimit
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))) :=
extendFanIsLimit (fun i => F.obj (f i)) (isLimitOfHasProductOfPreservesLimit F fun i => f (Fin.succ i))
(isLimitOfHasBinaryProductOfPreservesLimit F (f 0) (∏ fun i => f (Fin.succ i)))
j : Fin (n + 1)
⊢ NatTrans.app
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))).π
{ as := j } =
(Iso.refl
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))).pt).hom ≫
NatTrans.app
(Fan.mk (F.obj (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt) fun j =>
F.map
(Fin.cases
(BinaryFan.fst (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
BinaryFan.snd (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)) ≫
NatTrans.app (limit.cone (Discrete.functor fun i => f (Fin.succ i))).π { as := i })
j)).π
{ as := j }
[PROOFSTEP]
refine' Fin.inductionOn j ?_ ?_
[GOAL]
case mk.refine'_1
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesLimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesLimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteProducts C
n : ℕ
this✝ : (f : Fin n → C) → PreservesLimit (Discrete.functor f) F
f : Fin (n + 1) → C
this : IsLimit
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))) :=
extendFanIsLimit (fun i => F.obj (f i)) (isLimitOfHasProductOfPreservesLimit F fun i => f (Fin.succ i))
(isLimitOfHasBinaryProductOfPreservesLimit F (f 0) (∏ fun i => f (Fin.succ i)))
j : Fin (n + 1)
⊢ NatTrans.app
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))).π
{ as := 0 } =
(Iso.refl
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))).pt).hom ≫
NatTrans.app
(Fan.mk (F.obj (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt) fun j =>
F.map
(Fin.cases
(BinaryFan.fst (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
BinaryFan.snd (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)) ≫
NatTrans.app (limit.cone (Discrete.functor fun i => f (Fin.succ i))).π { as := i })
j)).π
{ as := 0 }
[PROOFSTEP]
apply (Category.id_comp _).symm
[GOAL]
case mk.refine'_2
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesLimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesLimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteProducts C
n : ℕ
this✝ : (f : Fin n → C) → PreservesLimit (Discrete.functor f) F
f : Fin (n + 1) → C
this : IsLimit
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))) :=
extendFanIsLimit (fun i => F.obj (f i)) (isLimitOfHasProductOfPreservesLimit F fun i => f (Fin.succ i))
(isLimitOfHasBinaryProductOfPreservesLimit F (f 0) (∏ fun i => f (Fin.succ i)))
j : Fin (n + 1)
⊢ ∀ (i : Fin n),
NatTrans.app
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))).π
{ as := Fin.castSucc i } =
(Iso.refl
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))).pt).hom ≫
NatTrans.app
(Fan.mk (F.obj (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt)
fun j =>
F.map
(Fin.cases
(BinaryFan.fst (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
BinaryFan.snd
(limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)) ≫
NatTrans.app (limit.cone (Discrete.functor fun i => f (Fin.succ i))).π { as := i })
j)).π
{ as := Fin.castSucc i } →
NatTrans.app
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))).π
{ as := Fin.succ i } =
(Iso.refl
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))).pt).hom ≫
NatTrans.app
(Fan.mk (F.obj (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt)
fun j =>
F.map
(Fin.cases
(BinaryFan.fst (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
BinaryFan.snd
(limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)) ≫
NatTrans.app (limit.cone (Discrete.functor fun i => f (Fin.succ i))).π { as := i })
j)).π
{ as := Fin.succ i }
[PROOFSTEP]
rintro i _
[GOAL]
case mk.refine'_2
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesLimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesLimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteProducts C
n : ℕ
this✝ : (f : Fin n → C) → PreservesLimit (Discrete.functor f) F
f : Fin (n + 1) → C
this : IsLimit
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))) :=
extendFanIsLimit (fun i => F.obj (f i)) (isLimitOfHasProductOfPreservesLimit F fun i => f (Fin.succ i))
(isLimitOfHasBinaryProductOfPreservesLimit F (f 0) (∏ fun i => f (Fin.succ i)))
j : Fin (n + 1)
i : Fin n
a✝ :
NatTrans.app
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))).π
{ as := Fin.castSucc i } =
(Iso.refl
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))).pt).hom ≫
NatTrans.app
(Fan.mk (F.obj (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt) fun j =>
F.map
(Fin.cases
(BinaryFan.fst (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
BinaryFan.snd (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)) ≫
NatTrans.app (limit.cone (Discrete.functor fun i => f (Fin.succ i))).π { as := i })
j)).π
{ as := Fin.castSucc i }
⊢ NatTrans.app
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))).π
{ as := Fin.succ i } =
(Iso.refl
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))).pt).hom ≫
NatTrans.app
(Fan.mk (F.obj (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt) fun j =>
F.map
(Fin.cases
(BinaryFan.fst (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
BinaryFan.snd (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)) ≫
NatTrans.app (limit.cone (Discrete.functor fun i => f (Fin.succ i))).π { as := i })
j)).π
{ as := Fin.succ i }
[PROOFSTEP]
dsimp [extendFan_π_app, Iso.refl_hom, Fan.mk_π_app]
[GOAL]
case mk.refine'_2
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesLimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesLimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteProducts C
n : ℕ
this✝ : (f : Fin n → C) → PreservesLimit (Discrete.functor f) F
f : Fin (n + 1) → C
this : IsLimit
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))) :=
extendFanIsLimit (fun i => F.obj (f i)) (isLimitOfHasProductOfPreservesLimit F fun i => f (Fin.succ i))
(isLimitOfHasBinaryProductOfPreservesLimit F (f 0) (∏ fun i => f (Fin.succ i)))
j : Fin (n + 1)
i : Fin n
a✝ :
NatTrans.app
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))).π
{ as := Fin.castSucc i } =
(Iso.refl
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))).pt).hom ≫
NatTrans.app
(Fan.mk (F.obj (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt) fun j =>
F.map
(Fin.cases
(BinaryFan.fst (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
BinaryFan.snd (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)) ≫
NatTrans.app (limit.cone (Discrete.functor fun i => f (Fin.succ i))).π { as := i })
j)).π
{ as := Fin.castSucc i }
⊢ F.map prod.snd ≫ F.map (Pi.π (fun i => f (Fin.succ i)) i) =
𝟙 (F.obj (f 0 ⨯ ∏ fun i => f (Fin.succ i))) ≫
F.map
(BinaryFan.snd (limit.cone (pair (f 0) (limit (Discrete.functor fun i => f (Fin.succ i))))) ≫
limit.π (Discrete.functor fun i => f (Fin.succ i)) { as := i })
[PROOFSTEP]
change F.map _ ≫ _ = 𝟙 _ ≫ _
[GOAL]
case mk.refine'_2
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesLimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesLimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteProducts C
n : ℕ
this✝ : (f : Fin n → C) → PreservesLimit (Discrete.functor f) F
f : Fin (n + 1) → C
this : IsLimit
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))) :=
extendFanIsLimit (fun i => F.obj (f i)) (isLimitOfHasProductOfPreservesLimit F fun i => f (Fin.succ i))
(isLimitOfHasBinaryProductOfPreservesLimit F (f 0) (∏ fun i => f (Fin.succ i)))
j : Fin (n + 1)
i : Fin n
a✝ :
NatTrans.app
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))).π
{ as := Fin.castSucc i } =
(Iso.refl
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))).pt).hom ≫
NatTrans.app
(Fan.mk (F.obj (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt) fun j =>
F.map
(Fin.cases
(BinaryFan.fst (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
BinaryFan.snd (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)) ≫
NatTrans.app (limit.cone (Discrete.functor fun i => f (Fin.succ i))).π { as := i })
j)).π
{ as := Fin.castSucc i }
⊢ F.map prod.snd ≫ F.map (Pi.π (fun i => f (Fin.succ i)) i) =
𝟙 (F.obj (f 0 ⨯ ∏ fun i => f (Fin.succ i))) ≫
F.map
(BinaryFan.snd (limit.cone (pair (f 0) (limit (Discrete.functor fun i => f (Fin.succ i))))) ≫
limit.π (Discrete.functor fun i => f (Fin.succ i)) { as := i })
[PROOFSTEP]
simp only [id_comp, ← F.map_comp]
[GOAL]
case mk.refine'_2
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesLimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesLimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteProducts C
n : ℕ
this✝ : (f : Fin n → C) → PreservesLimit (Discrete.functor f) F
f : Fin (n + 1) → C
this : IsLimit
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))) :=
extendFanIsLimit (fun i => F.obj (f i)) (isLimitOfHasProductOfPreservesLimit F fun i => f (Fin.succ i))
(isLimitOfHasBinaryProductOfPreservesLimit F (f 0) (∏ fun i => f (Fin.succ i)))
j : Fin (n + 1)
i : Fin n
a✝ :
NatTrans.app
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))).π
{ as := Fin.castSucc i } =
(Iso.refl
(extendFan (Fan.mk (F.obj (∏ fun i => f (Fin.succ i))) fun j => F.map (Pi.π (fun i => f (Fin.succ i)) j))
(BinaryFan.mk (F.map prod.fst) (F.map prod.snd))).pt).hom ≫
NatTrans.app
(Fan.mk (F.obj (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt) fun j =>
F.map
(Fin.cases
(BinaryFan.fst (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
BinaryFan.snd (limit.cone (pair (f 0) (limit.cone (Discrete.functor fun i => f (Fin.succ i))).pt)) ≫
NatTrans.app (limit.cone (Discrete.functor fun i => f (Fin.succ i))).π { as := i })
j)).π
{ as := Fin.castSucc i }
⊢ F.map (prod.snd ≫ Pi.π (fun i => f (Fin.succ i)) i) =
F.map
(BinaryFan.snd (limit.cone (pair (f 0) (limit (Discrete.functor fun i => f (Fin.succ i))))) ≫
limit.π (Discrete.functor fun i => f (Fin.succ i)) { as := i })
[PROOFSTEP]
rfl
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesLimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesLimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteProducts C
n : ℕ
K : Discrete (Fin n) ⥤ C
⊢ PreservesLimit K F
[PROOFSTEP]
let that : (Discrete.functor fun n => K.obj ⟨n⟩) ≅ K := Discrete.natIso fun ⟨i⟩ => Iso.refl _
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesLimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesLimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteProducts C
n : ℕ
K : Discrete (Fin n) ⥤ C
that : (Discrete.functor fun n_1 => K.obj { as := n_1 }) ≅ K :=
Discrete.natIso fun x =>
match x with
| { as := i } => Iso.refl ((Discrete.functor fun n_1 => K.obj { as := n_1 }).obj { as := i })
⊢ PreservesLimit K F
[PROOFSTEP]
haveI := preservesFinOfPreservesBinaryAndTerminal F n fun n => K.obj ⟨n⟩
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesLimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesLimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteProducts C
n : ℕ
K : Discrete (Fin n) ⥤ C
that : (Discrete.functor fun n_1 => K.obj { as := n_1 }) ≅ K :=
Discrete.natIso fun x =>
match x with
| { as := i } => Iso.refl ((Discrete.functor fun n_1 => K.obj { as := n_1 }).obj { as := i })
this : PreservesLimit (Discrete.functor fun n_1 => K.obj { as := n_1 }) F
⊢ PreservesLimit K F
[PROOFSTEP]
apply preservesLimitOfIsoDiagram F that
[GOAL]
J✝ : Type v
inst✝⁶ : SmallCategory J✝
C : Type u
inst✝⁵ : Category.{v, u} C
D : Type u'
inst✝⁴ : Category.{v', u'} D
F : C ⥤ D
inst✝³ : PreservesLimitsOfShape (Discrete WalkingPair) F
inst✝² : PreservesLimitsOfShape (Discrete PEmpty) F
inst✝¹ : HasFiniteProducts C
J : Type
inst✝ : Fintype J
⊢ PreservesLimitsOfShape (Discrete J) F
[PROOFSTEP]
classical
let e := Fintype.equivFin J
haveI := preservesShapeFinOfPreservesBinaryAndTerminal F (Fintype.card J)
apply preservesLimitsOfShapeOfEquiv.{0, 0} (Discrete.equivalence e).symm
[GOAL]
J✝ : Type v
inst✝⁶ : SmallCategory J✝
C : Type u
inst✝⁵ : Category.{v, u} C
D : Type u'
inst✝⁴ : Category.{v', u'} D
F : C ⥤ D
inst✝³ : PreservesLimitsOfShape (Discrete WalkingPair) F
inst✝² : PreservesLimitsOfShape (Discrete PEmpty) F
inst✝¹ : HasFiniteProducts C
J : Type
inst✝ : Fintype J
⊢ PreservesLimitsOfShape (Discrete J) F
[PROOFSTEP]
let e := Fintype.equivFin J
[GOAL]
J✝ : Type v
inst✝⁶ : SmallCategory J✝
C : Type u
inst✝⁵ : Category.{v, u} C
D : Type u'
inst✝⁴ : Category.{v', u'} D
F : C ⥤ D
inst✝³ : PreservesLimitsOfShape (Discrete WalkingPair) F
inst✝² : PreservesLimitsOfShape (Discrete PEmpty) F
inst✝¹ : HasFiniteProducts C
J : Type
inst✝ : Fintype J
e : J ≃ Fin (Fintype.card J) := Fintype.equivFin J
⊢ PreservesLimitsOfShape (Discrete J) F
[PROOFSTEP]
haveI := preservesShapeFinOfPreservesBinaryAndTerminal F (Fintype.card J)
[GOAL]
J✝ : Type v
inst✝⁶ : SmallCategory J✝
C : Type u
inst✝⁵ : Category.{v, u} C
D : Type u'
inst✝⁴ : Category.{v', u'} D
F : C ⥤ D
inst✝³ : PreservesLimitsOfShape (Discrete WalkingPair) F
inst✝² : PreservesLimitsOfShape (Discrete PEmpty) F
inst✝¹ : HasFiniteProducts C
J : Type
inst✝ : Fintype J
e : J ≃ Fin (Fintype.card J) := Fintype.equivFin J
this : PreservesLimitsOfShape (Discrete (Fin (Fintype.card J))) F
⊢ PreservesLimitsOfShape (Discrete J) F
[PROOFSTEP]
apply preservesLimitsOfShapeOfEquiv.{0, 0} (Discrete.equivalence e).symm
[GOAL]
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Cofan fun i => f (Fin.succ i)
c₂ : BinaryCofan (f 0) c₁.pt
⊢ (b : Fin (n + 1)) → f b ⟶ c₂.pt
[PROOFSTEP]
refine' Fin.cases _ _
[GOAL]
case refine'_1
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Cofan fun i => f (Fin.succ i)
c₂ : BinaryCofan (f 0) c₁.pt
⊢ f 0 ⟶ c₂.pt
[PROOFSTEP]
apply c₂.inl
[GOAL]
case refine'_2
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Cofan fun i => f (Fin.succ i)
c₂ : BinaryCofan (f 0) c₁.pt
⊢ (i : Fin n) → f (Fin.succ i) ⟶ c₂.pt
[PROOFSTEP]
intro i
[GOAL]
case refine'_2
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Cofan fun i => f (Fin.succ i)
c₂ : BinaryCofan (f 0) c₁.pt
i : Fin n
⊢ f (Fin.succ i) ⟶ c₂.pt
[PROOFSTEP]
apply c₁.ι.app ⟨i⟩ ≫ c₂.inr
[GOAL]
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Cofan fun i => f (Fin.succ i)
c₂ : BinaryCofan (f 0) c₁.pt
t₁ : IsColimit c₁
t₂ : IsColimit c₂
s : Cocone (Discrete.functor f)
⊢ (extendCofan c₁ c₂).pt ⟶ s.pt
[PROOFSTEP]
apply (BinaryCofan.IsColimit.desc' t₂ (s.ι.app ⟨0⟩) _).1
[GOAL]
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Cofan fun i => f (Fin.succ i)
c₂ : BinaryCofan (f 0) c₁.pt
t₁ : IsColimit c₁
t₂ : IsColimit c₂
s : Cocone (Discrete.functor f)
⊢ c₁.pt ⟶ ((Functor.const (Discrete (Fin (n + 1)))).obj s.pt).obj { as := 0 }
[PROOFSTEP]
apply t₁.desc ⟨_, Discrete.natTrans fun i => s.ι.app ⟨i.as.succ⟩⟩
[GOAL]
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Cofan fun i => f (Fin.succ i)
c₂ : BinaryCofan (f 0) c₁.pt
t₁ : IsColimit c₁
t₂ : IsColimit c₂
s : Cocone (Discrete.functor f)
⊢ ∀ (j : Discrete (Fin (n + 1))),
NatTrans.app (extendCofan c₁ c₂).ι j ≫
(fun s =>
↑(BinaryCofan.IsColimit.desc' t₂ (NatTrans.app s.ι { as := 0 })
(IsColimit.desc t₁
{ pt := s.pt, ι := Discrete.natTrans fun i => NatTrans.app s.ι { as := Fin.succ i.as } })))
s =
NatTrans.app s.ι j
[PROOFSTEP]
rintro ⟨j⟩
[GOAL]
case mk
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Cofan fun i => f (Fin.succ i)
c₂ : BinaryCofan (f 0) c₁.pt
t₁ : IsColimit c₁
t₂ : IsColimit c₂
s : Cocone (Discrete.functor f)
j : Fin (n + 1)
⊢ NatTrans.app (extendCofan c₁ c₂).ι { as := j } ≫
(fun s =>
↑(BinaryCofan.IsColimit.desc' t₂ (NatTrans.app s.ι { as := 0 })
(IsColimit.desc t₁
{ pt := s.pt, ι := Discrete.natTrans fun i => NatTrans.app s.ι { as := Fin.succ i.as } })))
s =
NatTrans.app s.ι { as := j }
[PROOFSTEP]
refine' Fin.inductionOn j ?_ ?_
[GOAL]
case mk.refine'_1
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Cofan fun i => f (Fin.succ i)
c₂ : BinaryCofan (f 0) c₁.pt
t₁ : IsColimit c₁
t₂ : IsColimit c₂
s : Cocone (Discrete.functor f)
j : Fin (n + 1)
⊢ NatTrans.app (extendCofan c₁ c₂).ι { as := 0 } ≫
(fun s =>
↑(BinaryCofan.IsColimit.desc' t₂ (NatTrans.app s.ι { as := 0 })
(IsColimit.desc t₁
{ pt := s.pt, ι := Discrete.natTrans fun i => NatTrans.app s.ι { as := Fin.succ i.as } })))
s =
NatTrans.app s.ι { as := 0 }
[PROOFSTEP]
apply (BinaryCofan.IsColimit.desc' t₂ _ _).2.1
[GOAL]
case mk.refine'_2
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Cofan fun i => f (Fin.succ i)
c₂ : BinaryCofan (f 0) c₁.pt
t₁ : IsColimit c₁
t₂ : IsColimit c₂
s : Cocone (Discrete.functor f)
j : Fin (n + 1)
⊢ ∀ (i : Fin n),
NatTrans.app (extendCofan c₁ c₂).ι { as := Fin.castSucc i } ≫
(fun s =>
↑(BinaryCofan.IsColimit.desc' t₂ (NatTrans.app s.ι { as := 0 })
(IsColimit.desc t₁
{ pt := s.pt, ι := Discrete.natTrans fun i => NatTrans.app s.ι { as := Fin.succ i.as } })))
s =
NatTrans.app s.ι { as := Fin.castSucc i } →
NatTrans.app (extendCofan c₁ c₂).ι { as := Fin.succ i } ≫
(fun s =>
↑(BinaryCofan.IsColimit.desc' t₂ (NatTrans.app s.ι { as := 0 })
(IsColimit.desc t₁
{ pt := s.pt, ι := Discrete.natTrans fun i => NatTrans.app s.ι { as := Fin.succ i.as } })))
s =
NatTrans.app s.ι { as := Fin.succ i }
[PROOFSTEP]
rintro i -
[GOAL]
case mk.refine'_2
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Cofan fun i => f (Fin.succ i)
c₂ : BinaryCofan (f 0) c₁.pt
t₁ : IsColimit c₁
t₂ : IsColimit c₂
s : Cocone (Discrete.functor f)
j : Fin (n + 1)
i : Fin n
⊢ NatTrans.app (extendCofan c₁ c₂).ι { as := Fin.succ i } ≫
(fun s =>
↑(BinaryCofan.IsColimit.desc' t₂ (NatTrans.app s.ι { as := 0 })
(IsColimit.desc t₁
{ pt := s.pt, ι := Discrete.natTrans fun i => NatTrans.app s.ι { as := Fin.succ i.as } })))
s =
NatTrans.app s.ι { as := Fin.succ i }
[PROOFSTEP]
dsimp only [extendCofan_ι_app]
[GOAL]
case mk.refine'_2
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Cofan fun i => f (Fin.succ i)
c₂ : BinaryCofan (f 0) c₁.pt
t₁ : IsColimit c₁
t₂ : IsColimit c₂
s : Cocone (Discrete.functor f)
j : Fin (n + 1)
i : Fin n
⊢ Fin.cases (BinaryCofan.inl c₂) (fun i => NatTrans.app c₁.ι { as := i } ≫ BinaryCofan.inr c₂) (Fin.succ i) ≫
↑(BinaryCofan.IsColimit.desc' t₂ (NatTrans.app s.ι { as := 0 })
(IsColimit.desc t₁
{ pt := s.pt, ι := Discrete.natTrans fun i => NatTrans.app s.ι { as := Fin.succ i.as } })) =
NatTrans.app s.ι { as := Fin.succ i }
[PROOFSTEP]
rw [Fin.cases_succ, assoc, (BinaryCofan.IsColimit.desc' t₂ _ _).2.2, t₁.fac]
[GOAL]
case mk.refine'_2
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Cofan fun i => f (Fin.succ i)
c₂ : BinaryCofan (f 0) c₁.pt
t₁ : IsColimit c₁
t₂ : IsColimit c₂
s : Cocone (Discrete.functor f)
j : Fin (n + 1)
i : Fin n
⊢ NatTrans.app { pt := s.pt, ι := Discrete.natTrans fun i => NatTrans.app s.ι { as := Fin.succ i.as } }.ι { as := i } =
NatTrans.app s.ι { as := Fin.succ i }
[PROOFSTEP]
rfl
[GOAL]
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Cofan fun i => f (Fin.succ i)
c₂ : BinaryCofan (f 0) c₁.pt
t₁ : IsColimit c₁
t₂ : IsColimit c₂
s : Cocone (Discrete.functor f)
m : (extendCofan c₁ c₂).pt ⟶ s.pt
w : ∀ (j : Discrete (Fin (n + 1))), NatTrans.app (extendCofan c₁ c₂).ι j ≫ m = NatTrans.app s.ι j
⊢ m =
(fun s =>
↑(BinaryCofan.IsColimit.desc' t₂ (NatTrans.app s.ι { as := 0 })
(IsColimit.desc t₁
{ pt := s.pt, ι := Discrete.natTrans fun i => NatTrans.app s.ι { as := Fin.succ i.as } })))
s
[PROOFSTEP]
apply BinaryCofan.IsColimit.hom_ext t₂
[GOAL]
case h₁
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Cofan fun i => f (Fin.succ i)
c₂ : BinaryCofan (f 0) c₁.pt
t₁ : IsColimit c₁
t₂ : IsColimit c₂
s : Cocone (Discrete.functor f)
m : (extendCofan c₁ c₂).pt ⟶ s.pt
w : ∀ (j : Discrete (Fin (n + 1))), NatTrans.app (extendCofan c₁ c₂).ι j ≫ m = NatTrans.app s.ι j
⊢ BinaryCofan.inl c₂ ≫ m =
BinaryCofan.inl c₂ ≫
(fun s =>
↑(BinaryCofan.IsColimit.desc' t₂ (NatTrans.app s.ι { as := 0 })
(IsColimit.desc t₁
{ pt := s.pt, ι := Discrete.natTrans fun i => NatTrans.app s.ι { as := Fin.succ i.as } })))
s
[PROOFSTEP]
rw [(BinaryCofan.IsColimit.desc' t₂ _ _).2.1]
[GOAL]
case h₁
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Cofan fun i => f (Fin.succ i)
c₂ : BinaryCofan (f 0) c₁.pt
t₁ : IsColimit c₁
t₂ : IsColimit c₂
s : Cocone (Discrete.functor f)
m : (extendCofan c₁ c₂).pt ⟶ s.pt
w : ∀ (j : Discrete (Fin (n + 1))), NatTrans.app (extendCofan c₁ c₂).ι j ≫ m = NatTrans.app s.ι j
⊢ BinaryCofan.inl c₂ ≫ m = NatTrans.app s.ι { as := 0 }
[PROOFSTEP]
apply w ⟨0⟩
[GOAL]
case h₂
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Cofan fun i => f (Fin.succ i)
c₂ : BinaryCofan (f 0) c₁.pt
t₁ : IsColimit c₁
t₂ : IsColimit c₂
s : Cocone (Discrete.functor f)
m : (extendCofan c₁ c₂).pt ⟶ s.pt
w : ∀ (j : Discrete (Fin (n + 1))), NatTrans.app (extendCofan c₁ c₂).ι j ≫ m = NatTrans.app s.ι j
⊢ BinaryCofan.inr c₂ ≫ m =
BinaryCofan.inr c₂ ≫
(fun s =>
↑(BinaryCofan.IsColimit.desc' t₂ (NatTrans.app s.ι { as := 0 })
(IsColimit.desc t₁
{ pt := s.pt, ι := Discrete.natTrans fun i => NatTrans.app s.ι { as := Fin.succ i.as } })))
s
[PROOFSTEP]
rw [(BinaryCofan.IsColimit.desc' t₂ _ _).2.2]
[GOAL]
case h₂
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Cofan fun i => f (Fin.succ i)
c₂ : BinaryCofan (f 0) c₁.pt
t₁ : IsColimit c₁
t₂ : IsColimit c₂
s : Cocone (Discrete.functor f)
m : (extendCofan c₁ c₂).pt ⟶ s.pt
w : ∀ (j : Discrete (Fin (n + 1))), NatTrans.app (extendCofan c₁ c₂).ι j ≫ m = NatTrans.app s.ι j
⊢ BinaryCofan.inr c₂ ≫ m =
IsColimit.desc t₁ { pt := s.pt, ι := Discrete.natTrans fun i => NatTrans.app s.ι { as := Fin.succ i.as } }
[PROOFSTEP]
apply t₁.uniq ⟨_, _⟩
[GOAL]
case h₂.x
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Cofan fun i => f (Fin.succ i)
c₂ : BinaryCofan (f 0) c₁.pt
t₁ : IsColimit c₁
t₂ : IsColimit c₂
s : Cocone (Discrete.functor f)
m : (extendCofan c₁ c₂).pt ⟶ s.pt
w : ∀ (j : Discrete (Fin (n + 1))), NatTrans.app (extendCofan c₁ c₂).ι j ≫ m = NatTrans.app s.ι j
⊢ ∀ (j : Discrete (Fin n)),
NatTrans.app c₁.ι j ≫ BinaryCofan.inr c₂ ≫ m =
NatTrans.app { pt := s.1, ι := Discrete.natTrans fun i => NatTrans.app s.ι { as := Fin.succ i.as } }.ι j
[PROOFSTEP]
rintro ⟨j⟩
[GOAL]
case h₂.x.mk
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Cofan fun i => f (Fin.succ i)
c₂ : BinaryCofan (f 0) c₁.pt
t₁ : IsColimit c₁
t₂ : IsColimit c₂
s : Cocone (Discrete.functor f)
m : (extendCofan c₁ c₂).pt ⟶ s.pt
w : ∀ (j : Discrete (Fin (n + 1))), NatTrans.app (extendCofan c₁ c₂).ι j ≫ m = NatTrans.app s.ι j
j : Fin n
⊢ NatTrans.app c₁.ι { as := j } ≫ BinaryCofan.inr c₂ ≫ m =
NatTrans.app { pt := s.1, ι := Discrete.natTrans fun i => NatTrans.app s.ι { as := Fin.succ i.as } }.ι { as := j }
[PROOFSTEP]
dsimp only [Discrete.natTrans_app]
[GOAL]
case h₂.x.mk
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Cofan fun i => f (Fin.succ i)
c₂ : BinaryCofan (f 0) c₁.pt
t₁ : IsColimit c₁
t₂ : IsColimit c₂
s : Cocone (Discrete.functor f)
m : (extendCofan c₁ c₂).pt ⟶ s.pt
w : ∀ (j : Discrete (Fin (n + 1))), NatTrans.app (extendCofan c₁ c₂).ι j ≫ m = NatTrans.app s.ι j
j : Fin n
⊢ NatTrans.app c₁.ι { as := j } ≫ BinaryCofan.inr c₂ ≫ m = NatTrans.app s.ι { as := Fin.succ j }
[PROOFSTEP]
rw [← w ⟨j.succ⟩]
[GOAL]
case h₂.x.mk
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Cofan fun i => f (Fin.succ i)
c₂ : BinaryCofan (f 0) c₁.pt
t₁ : IsColimit c₁
t₂ : IsColimit c₂
s : Cocone (Discrete.functor f)
m : (extendCofan c₁ c₂).pt ⟶ s.pt
w : ∀ (j : Discrete (Fin (n + 1))), NatTrans.app (extendCofan c₁ c₂).ι j ≫ m = NatTrans.app s.ι j
j : Fin n
⊢ NatTrans.app c₁.ι { as := j } ≫ BinaryCofan.inr c₂ ≫ m = NatTrans.app (extendCofan c₁ c₂).ι { as := Fin.succ j } ≫ m
[PROOFSTEP]
dsimp only [extendCofan_ι_app]
[GOAL]
case h₂.x.mk
J : Type v
inst✝² : SmallCategory J
C : Type u
inst✝¹ : Category.{v, u} C
D : Type u'
inst✝ : Category.{v', u'} D
n : ℕ
f : Fin (n + 1) → C
c₁ : Cofan fun i => f (Fin.succ i)
c₂ : BinaryCofan (f 0) c₁.pt
t₁ : IsColimit c₁
t₂ : IsColimit c₂
s : Cocone (Discrete.functor f)
m : (extendCofan c₁ c₂).pt ⟶ s.pt
w : ∀ (j : Discrete (Fin (n + 1))), NatTrans.app (extendCofan c₁ c₂).ι j ≫ m = NatTrans.app s.ι j
j : Fin n
⊢ NatTrans.app c₁.ι { as := j } ≫ BinaryCofan.inr c₂ ≫ m =
Fin.cases (BinaryCofan.inl c₂) (fun i => NatTrans.app c₁.ι { as := i } ≫ BinaryCofan.inr c₂) (Fin.succ j) ≫ m
[PROOFSTEP]
rw [Fin.cases_succ, assoc]
[GOAL]
J : Type v
inst✝⁴ : SmallCategory J
C : Type u
inst✝³ : Category.{v, u} C
D : Type u'
inst✝² : Category.{v', u'} D
inst✝¹ : HasBinaryCoproducts C
inst✝ : HasInitial C
f : Fin 0 → C
⊢ HasCoproduct f
[PROOFSTEP]
letI : HasColimitsOfShape (Discrete (Fin 0)) C :=
hasColimitsOfShape_of_equivalence (Discrete.equivalence.{0} finZeroEquiv'.symm)
[GOAL]
J : Type v
inst✝⁴ : SmallCategory J
C : Type u
inst✝³ : Category.{v, u} C
D : Type u'
inst✝² : Category.{v', u'} D
inst✝¹ : HasBinaryCoproducts C
inst✝ : HasInitial C
f : Fin 0 → C
this : HasColimitsOfShape (Discrete (Fin 0)) C :=
hasColimitsOfShape_of_equivalence (Discrete.equivalence finZeroEquiv'.symm)
⊢ HasCoproduct f
[PROOFSTEP]
infer_instance
[GOAL]
J : Type v
inst✝⁴ : SmallCategory J
C : Type u
inst✝³ : Category.{v, u} C
D : Type u'
inst✝² : Category.{v', u'} D
inst✝¹ : HasBinaryCoproducts C
inst✝ : HasInitial C
n : ℕ
f : Fin (n + 1) → C
⊢ HasCoproduct f
[PROOFSTEP]
haveI := hasCoproduct_fin n
[GOAL]
J : Type v
inst✝⁴ : SmallCategory J
C : Type u
inst✝³ : Category.{v, u} C
D : Type u'
inst✝² : Category.{v', u'} D
inst✝¹ : HasBinaryCoproducts C
inst✝ : HasInitial C
n : ℕ
f : Fin (n + 1) → C
this : ∀ (f : Fin n → C), HasCoproduct f
⊢ HasCoproduct f
[PROOFSTEP]
apply HasColimit.mk ⟨_, extendCofanIsColimit f (colimit.isColimit _) (colimit.isColimit _)⟩
[GOAL]
J : Type v
inst✝⁴ : SmallCategory J
C : Type u
inst✝³ : Category.{v, u} C
D : Type u'
inst✝² : Category.{v', u'} D
inst✝¹ : HasBinaryCoproducts C
inst✝ : HasInitial C
⊢ HasFiniteCoproducts C
[PROOFSTEP]
refine' ⟨fun n => ⟨fun K => _⟩⟩
[GOAL]
J : Type v
inst✝⁴ : SmallCategory J
C : Type u
inst✝³ : Category.{v, u} C
D : Type u'
inst✝² : Category.{v', u'} D
inst✝¹ : HasBinaryCoproducts C
inst✝ : HasInitial C
n : ℕ
K : Discrete (Fin n) ⥤ C
⊢ HasColimit K
[PROOFSTEP]
letI := hasCoproduct_fin n fun n => K.obj ⟨n⟩
[GOAL]
J : Type v
inst✝⁴ : SmallCategory J
C : Type u
inst✝³ : Category.{v, u} C
D : Type u'
inst✝² : Category.{v', u'} D
inst✝¹ : HasBinaryCoproducts C
inst✝ : HasInitial C
n : ℕ
K : Discrete (Fin n) ⥤ C
this : HasCoproduct fun n_1 => K.obj { as := n_1 } := CategoryTheory.hasCoproduct_fin n fun n_1 => K.obj { as := n_1 }
⊢ HasColimit K
[PROOFSTEP]
let that : K ≅ Discrete.functor fun n => K.obj ⟨n⟩ := Discrete.natIso fun ⟨i⟩ => Iso.refl _
[GOAL]
J : Type v
inst✝⁴ : SmallCategory J
C : Type u
inst✝³ : Category.{v, u} C
D : Type u'
inst✝² : Category.{v', u'} D
inst✝¹ : HasBinaryCoproducts C
inst✝ : HasInitial C
n : ℕ
K : Discrete (Fin n) ⥤ C
this : HasCoproduct fun n_1 => K.obj { as := n_1 } := CategoryTheory.hasCoproduct_fin n fun n_1 => K.obj { as := n_1 }
that : K ≅ Discrete.functor fun n_1 => K.obj { as := n_1 } :=
Discrete.natIso fun x =>
match x with
| { as := i } => Iso.refl (K.obj { as := i })
⊢ HasColimit K
[PROOFSTEP]
apply @hasColimitOfIso _ _ _ _ _ _ this that
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesColimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesColimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteCoproducts C
f : Fin 0 → C
⊢ PreservesColimit (Discrete.functor f) F
[PROOFSTEP]
letI : PreservesColimitsOfShape (Discrete (Fin 0)) F :=
preservesColimitsOfShapeOfEquiv.{0, 0} (Discrete.equivalence finZeroEquiv'.symm) _
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesColimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesColimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteCoproducts C
f : Fin 0 → C
this : PreservesColimitsOfShape (Discrete (Fin 0)) F :=
preservesColimitsOfShapeOfEquiv (Discrete.equivalence finZeroEquiv'.symm) F
⊢ PreservesColimit (Discrete.functor f) F
[PROOFSTEP]
infer_instance
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesColimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesColimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteCoproducts C
n : ℕ
⊢ (f : Fin (n + 1) → C) → PreservesColimit (Discrete.functor f) F
[PROOFSTEP]
haveI := preservesFinOfPreservesBinaryAndInitial n
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesColimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesColimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteCoproducts C
n : ℕ
this : (f : Fin n → C) → PreservesColimit (Discrete.functor f) F
⊢ (f : Fin (n + 1) → C) → PreservesColimit (Discrete.functor f) F
[PROOFSTEP]
intro f
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesColimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesColimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteCoproducts C
n : ℕ
this : (f : Fin n → C) → PreservesColimit (Discrete.functor f) F
f : Fin (n + 1) → C
⊢ PreservesColimit (Discrete.functor f) F
[PROOFSTEP]
refine' preservesColimitOfPreservesColimitCocone (extendCofanIsColimit f (colimit.isColimit _) (colimit.isColimit _)) _
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesColimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesColimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteCoproducts C
n : ℕ
this : (f : Fin n → C) → PreservesColimit (Discrete.functor f) F
f : Fin (n + 1) → C
⊢ IsColimit
(F.mapCocone
(extendCofan (colimit.cocone (Discrete.functor fun i => f (Fin.succ i)))
(colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt))))
[PROOFSTEP]
apply (isColimitMapCoconeCofanMkEquiv _ _ _).symm _
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesColimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesColimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteCoproducts C
n : ℕ
this : (f : Fin n → C) → PreservesColimit (Discrete.functor f) F
f : Fin (n + 1) → C
⊢ IsColimit
(Cofan.mk (F.obj (colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt)
fun j =>
F.map
(Fin.cases
(BinaryCofan.inl (colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
NatTrans.app (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).ι { as := i } ≫
BinaryCofan.inr
(colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)))
j))
[PROOFSTEP]
let this :=
extendCofanIsColimit (fun i => F.obj (f i)) (isColimitOfHasCoproductOfPreservesColimit F _)
(isColimitOfHasBinaryCoproductOfPreservesColimit F _ _)
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesColimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesColimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteCoproducts C
n : ℕ
this✝ : (f : Fin n → C) → PreservesColimit (Discrete.functor f) F
f : Fin (n + 1) → C
this : IsColimit
(extendCofan (Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))) :=
extendCofanIsColimit (fun i => F.obj (f i)) (isColimitOfHasCoproductOfPreservesColimit F fun i => f (Fin.succ i))
(isColimitOfHasBinaryCoproductOfPreservesColimit F (f 0) (∐ fun i => f (Fin.succ i)))
⊢ IsColimit
(Cofan.mk (F.obj (colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt)
fun j =>
F.map
(Fin.cases
(BinaryCofan.inl (colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
NatTrans.app (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).ι { as := i } ≫
BinaryCofan.inr
(colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)))
j))
[PROOFSTEP]
refine' IsColimit.ofIsoColimit this _
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesColimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesColimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteCoproducts C
n : ℕ
this✝ : (f : Fin n → C) → PreservesColimit (Discrete.functor f) F
f : Fin (n + 1) → C
this : IsColimit
(extendCofan (Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))) :=
extendCofanIsColimit (fun i => F.obj (f i)) (isColimitOfHasCoproductOfPreservesColimit F fun i => f (Fin.succ i))
(isColimitOfHasBinaryCoproductOfPreservesColimit F (f 0) (∐ fun i => f (Fin.succ i)))
⊢ extendCofan (Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr)) ≅
Cofan.mk (F.obj (colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt)
fun j =>
F.map
(Fin.cases
(BinaryCofan.inl (colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
NatTrans.app (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).ι { as := i } ≫
BinaryCofan.inr
(colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)))
j)
[PROOFSTEP]
apply Cocones.ext _ _
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesColimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesColimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteCoproducts C
n : ℕ
this✝ : (f : Fin n → C) → PreservesColimit (Discrete.functor f) F
f : Fin (n + 1) → C
this : IsColimit
(extendCofan (Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))) :=
extendCofanIsColimit (fun i => F.obj (f i)) (isColimitOfHasCoproductOfPreservesColimit F fun i => f (Fin.succ i))
(isColimitOfHasBinaryCoproductOfPreservesColimit F (f 0) (∐ fun i => f (Fin.succ i)))
⊢ (extendCofan (Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))).pt ≅
(Cofan.mk (F.obj (colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt)
fun j =>
F.map
(Fin.cases
(BinaryCofan.inl
(colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
NatTrans.app (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).ι { as := i } ≫
BinaryCofan.inr
(colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)))
j)).pt
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesColimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesColimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteCoproducts C
n : ℕ
this✝ : (f : Fin n → C) → PreservesColimit (Discrete.functor f) F
f : Fin (n + 1) → C
this : IsColimit
(extendCofan (Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))) :=
extendCofanIsColimit (fun i => F.obj (f i)) (isColimitOfHasCoproductOfPreservesColimit F fun i => f (Fin.succ i))
(isColimitOfHasBinaryCoproductOfPreservesColimit F (f 0) (∐ fun i => f (Fin.succ i)))
⊢ ∀ (j : Discrete (Fin (n + 1))),
NatTrans.app
(extendCofan
(Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))).ι
j ≫
?m.38703.hom =
NatTrans.app
(Cofan.mk
(F.obj (colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt)
fun j =>
F.map
(Fin.cases
(BinaryCofan.inl
(colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
NatTrans.app (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).ι { as := i } ≫
BinaryCofan.inr
(colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)))
j)).ι
j
[PROOFSTEP]
apply Iso.refl _
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesColimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesColimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteCoproducts C
n : ℕ
this✝ : (f : Fin n → C) → PreservesColimit (Discrete.functor f) F
f : Fin (n + 1) → C
this : IsColimit
(extendCofan (Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))) :=
extendCofanIsColimit (fun i => F.obj (f i)) (isColimitOfHasCoproductOfPreservesColimit F fun i => f (Fin.succ i))
(isColimitOfHasBinaryCoproductOfPreservesColimit F (f 0) (∐ fun i => f (Fin.succ i)))
⊢ ∀ (j : Discrete (Fin (n + 1))),
NatTrans.app
(extendCofan
(Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))).ι
j ≫
(Iso.refl
(extendCofan
(Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))).pt).hom =
NatTrans.app
(Cofan.mk
(F.obj (colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt)
fun j =>
F.map
(Fin.cases
(BinaryCofan.inl
(colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
NatTrans.app (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).ι { as := i } ≫
BinaryCofan.inr
(colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)))
j)).ι
j
[PROOFSTEP]
rintro ⟨j⟩
[GOAL]
case mk
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesColimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesColimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteCoproducts C
n : ℕ
this✝ : (f : Fin n → C) → PreservesColimit (Discrete.functor f) F
f : Fin (n + 1) → C
this : IsColimit
(extendCofan (Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))) :=
extendCofanIsColimit (fun i => F.obj (f i)) (isColimitOfHasCoproductOfPreservesColimit F fun i => f (Fin.succ i))
(isColimitOfHasBinaryCoproductOfPreservesColimit F (f 0) (∐ fun i => f (Fin.succ i)))
j : Fin (n + 1)
⊢ NatTrans.app
(extendCofan (Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))).ι
{ as := j } ≫
(Iso.refl
(extendCofan
(Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))).pt).hom =
NatTrans.app
(Cofan.mk (F.obj (colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt)
fun j =>
F.map
(Fin.cases
(BinaryCofan.inl
(colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
NatTrans.app (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).ι { as := i } ≫
BinaryCofan.inr
(colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)))
j)).ι
{ as := j }
[PROOFSTEP]
refine' Fin.inductionOn j ?_ ?_
[GOAL]
case mk.refine'_1
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesColimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesColimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteCoproducts C
n : ℕ
this✝ : (f : Fin n → C) → PreservesColimit (Discrete.functor f) F
f : Fin (n + 1) → C
this : IsColimit
(extendCofan (Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))) :=
extendCofanIsColimit (fun i => F.obj (f i)) (isColimitOfHasCoproductOfPreservesColimit F fun i => f (Fin.succ i))
(isColimitOfHasBinaryCoproductOfPreservesColimit F (f 0) (∐ fun i => f (Fin.succ i)))
j : Fin (n + 1)
⊢ NatTrans.app
(extendCofan (Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))).ι
{ as := 0 } ≫
(Iso.refl
(extendCofan
(Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))).pt).hom =
NatTrans.app
(Cofan.mk (F.obj (colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt)
fun j =>
F.map
(Fin.cases
(BinaryCofan.inl
(colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
NatTrans.app (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).ι { as := i } ≫
BinaryCofan.inr
(colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)))
j)).ι
{ as := 0 }
[PROOFSTEP]
apply Category.comp_id
[GOAL]
case mk.refine'_2
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesColimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesColimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteCoproducts C
n : ℕ
this✝ : (f : Fin n → C) → PreservesColimit (Discrete.functor f) F
f : Fin (n + 1) → C
this : IsColimit
(extendCofan (Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))) :=
extendCofanIsColimit (fun i => F.obj (f i)) (isColimitOfHasCoproductOfPreservesColimit F fun i => f (Fin.succ i))
(isColimitOfHasBinaryCoproductOfPreservesColimit F (f 0) (∐ fun i => f (Fin.succ i)))
j : Fin (n + 1)
⊢ ∀ (i : Fin n),
NatTrans.app
(extendCofan
(Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))).ι
{ as := Fin.castSucc i } ≫
(Iso.refl
(extendCofan
(Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))).pt).hom =
NatTrans.app
(Cofan.mk
(F.obj (colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt)
fun j =>
F.map
(Fin.cases
(BinaryCofan.inl
(colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
NatTrans.app (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).ι { as := i } ≫
BinaryCofan.inr
(colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)))
j)).ι
{ as := Fin.castSucc i } →
NatTrans.app
(extendCofan
(Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))).ι
{ as := Fin.succ i } ≫
(Iso.refl
(extendCofan
(Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))).pt).hom =
NatTrans.app
(Cofan.mk
(F.obj (colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt)
fun j =>
F.map
(Fin.cases
(BinaryCofan.inl
(colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
NatTrans.app (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).ι { as := i } ≫
BinaryCofan.inr
(colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)))
j)).ι
{ as := Fin.succ i }
[PROOFSTEP]
rintro i _
[GOAL]
case mk.refine'_2
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesColimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesColimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteCoproducts C
n : ℕ
this✝ : (f : Fin n → C) → PreservesColimit (Discrete.functor f) F
f : Fin (n + 1) → C
this : IsColimit
(extendCofan (Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))) :=
extendCofanIsColimit (fun i => F.obj (f i)) (isColimitOfHasCoproductOfPreservesColimit F fun i => f (Fin.succ i))
(isColimitOfHasBinaryCoproductOfPreservesColimit F (f 0) (∐ fun i => f (Fin.succ i)))
j : Fin (n + 1)
i : Fin n
a✝ :
NatTrans.app
(extendCofan (Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))).ι
{ as := Fin.castSucc i } ≫
(Iso.refl
(extendCofan
(Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))).pt).hom =
NatTrans.app
(Cofan.mk (F.obj (colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt)
fun j =>
F.map
(Fin.cases
(BinaryCofan.inl
(colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
NatTrans.app (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).ι { as := i } ≫
BinaryCofan.inr
(colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)))
j)).ι
{ as := Fin.castSucc i }
⊢ NatTrans.app
(extendCofan (Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))).ι
{ as := Fin.succ i } ≫
(Iso.refl
(extendCofan
(Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))).pt).hom =
NatTrans.app
(Cofan.mk (F.obj (colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt)
fun j =>
F.map
(Fin.cases
(BinaryCofan.inl
(colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
NatTrans.app (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).ι { as := i } ≫
BinaryCofan.inr
(colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)))
j)).ι
{ as := Fin.succ i }
[PROOFSTEP]
dsimp [extendCofan_ι_app, Iso.refl_hom, Cofan.mk_ι_app]
[GOAL]
case mk.refine'_2
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesColimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesColimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteCoproducts C
n : ℕ
this✝ : (f : Fin n → C) → PreservesColimit (Discrete.functor f) F
f : Fin (n + 1) → C
this : IsColimit
(extendCofan (Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))) :=
extendCofanIsColimit (fun i => F.obj (f i)) (isColimitOfHasCoproductOfPreservesColimit F fun i => f (Fin.succ i))
(isColimitOfHasBinaryCoproductOfPreservesColimit F (f 0) (∐ fun i => f (Fin.succ i)))
j : Fin (n + 1)
i : Fin n
a✝ :
NatTrans.app
(extendCofan (Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))).ι
{ as := Fin.castSucc i } ≫
(Iso.refl
(extendCofan
(Cofan.mk (F.obj (∐ fun i => f (Fin.succ i))) fun j => F.map (Sigma.ι (fun i => f (Fin.succ i)) j))
(BinaryCofan.mk (F.map coprod.inl) (F.map coprod.inr))).pt).hom =
NatTrans.app
(Cofan.mk (F.obj (colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)).pt)
fun j =>
F.map
(Fin.cases
(BinaryCofan.inl
(colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)))
(fun i =>
NatTrans.app (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).ι { as := i } ≫
BinaryCofan.inr
(colimit.cocone (pair (f 0) (colimit.cocone (Discrete.functor fun i => f (Fin.succ i))).pt)))
j)).ι
{ as := Fin.castSucc i }
⊢ (F.map (Sigma.ι (fun i => f (Fin.succ i)) i) ≫ F.map coprod.inr) ≫ 𝟙 (F.obj (f 0 ⨿ ∐ fun i => f (Fin.succ i))) =
F.map
(colimit.ι (Discrete.functor fun i => f (Fin.succ i)) { as := i } ≫
colimit.ι (pair (f 0) (colimit (Discrete.functor fun i => f (Fin.succ i)))) { as := WalkingPair.right })
[PROOFSTEP]
rw [comp_id, ← F.map_comp]
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesColimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesColimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteCoproducts C
n : ℕ
K : Discrete (Fin n) ⥤ C
⊢ PreservesColimit K F
[PROOFSTEP]
let that : (Discrete.functor fun n => K.obj ⟨n⟩) ≅ K := Discrete.natIso fun ⟨i⟩ => Iso.refl _
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesColimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesColimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteCoproducts C
n : ℕ
K : Discrete (Fin n) ⥤ C
that : (Discrete.functor fun n_1 => K.obj { as := n_1 }) ≅ K :=
Discrete.natIso fun x =>
match x with
| { as := i } => Iso.refl ((Discrete.functor fun n_1 => K.obj { as := n_1 }).obj { as := i })
⊢ PreservesColimit K F
[PROOFSTEP]
haveI := preservesFinOfPreservesBinaryAndInitial F n fun n => K.obj ⟨n⟩
[GOAL]
J : Type v
inst✝⁵ : SmallCategory J
C : Type u
inst✝⁴ : Category.{v, u} C
D : Type u'
inst✝³ : Category.{v', u'} D
F : C ⥤ D
inst✝² : PreservesColimitsOfShape (Discrete WalkingPair) F
inst✝¹ : PreservesColimitsOfShape (Discrete PEmpty) F
inst✝ : HasFiniteCoproducts C
n : ℕ
K : Discrete (Fin n) ⥤ C
that : (Discrete.functor fun n_1 => K.obj { as := n_1 }) ≅ K :=
Discrete.natIso fun x =>
match x with
| { as := i } => Iso.refl ((Discrete.functor fun n_1 => K.obj { as := n_1 }).obj { as := i })
this : PreservesColimit (Discrete.functor fun n_1 => K.obj { as := n_1 }) F
⊢ PreservesColimit K F
[PROOFSTEP]
apply preservesColimitOfIsoDiagram F that
[GOAL]
J✝ : Type v
inst✝⁶ : SmallCategory J✝
C : Type u
inst✝⁵ : Category.{v, u} C
D : Type u'
inst✝⁴ : Category.{v', u'} D
F : C ⥤ D
inst✝³ : PreservesColimitsOfShape (Discrete WalkingPair) F
inst✝² : PreservesColimitsOfShape (Discrete PEmpty) F
inst✝¹ : HasFiniteCoproducts C
J : Type
inst✝ : Fintype J
⊢ PreservesColimitsOfShape (Discrete J) F
[PROOFSTEP]
classical
let e := Fintype.equivFin J
haveI := preservesShapeFinOfPreservesBinaryAndInitial F (Fintype.card J)
apply preservesColimitsOfShapeOfEquiv.{0, 0} (Discrete.equivalence e).symm
[GOAL]
J✝ : Type v
inst✝⁶ : SmallCategory J✝
C : Type u
inst✝⁵ : Category.{v, u} C
D : Type u'
inst✝⁴ : Category.{v', u'} D
F : C ⥤ D
inst✝³ : PreservesColimitsOfShape (Discrete WalkingPair) F
inst✝² : PreservesColimitsOfShape (Discrete PEmpty) F
inst✝¹ : HasFiniteCoproducts C
J : Type
inst✝ : Fintype J
⊢ PreservesColimitsOfShape (Discrete J) F
[PROOFSTEP]
let e := Fintype.equivFin J
[GOAL]
J✝ : Type v
inst✝⁶ : SmallCategory J✝
C : Type u
inst✝⁵ : Category.{v, u} C
D : Type u'
inst✝⁴ : Category.{v', u'} D
F : C ⥤ D
inst✝³ : PreservesColimitsOfShape (Discrete WalkingPair) F
inst✝² : PreservesColimitsOfShape (Discrete PEmpty) F
inst✝¹ : HasFiniteCoproducts C
J : Type
inst✝ : Fintype J
e : J ≃ Fin (Fintype.card J) := Fintype.equivFin J
⊢ PreservesColimitsOfShape (Discrete J) F
[PROOFSTEP]
haveI := preservesShapeFinOfPreservesBinaryAndInitial F (Fintype.card J)
[GOAL]
J✝ : Type v
inst✝⁶ : SmallCategory J✝
C : Type u
inst✝⁵ : Category.{v, u} C
D : Type u'
inst✝⁴ : Category.{v', u'} D
F : C ⥤ D
inst✝³ : PreservesColimitsOfShape (Discrete WalkingPair) F
inst✝² : PreservesColimitsOfShape (Discrete PEmpty) F
inst✝¹ : HasFiniteCoproducts C
J : Type
inst✝ : Fintype J
e : J ≃ Fin (Fintype.card J) := Fintype.equivFin J
this : PreservesColimitsOfShape (Discrete (Fin (Fintype.card J))) F
⊢ PreservesColimitsOfShape (Discrete J) F
[PROOFSTEP]
apply preservesColimitsOfShapeOfEquiv.{0, 0} (Discrete.equivalence e).symm
|
lemma Fract_quot_of_fract [simp]: "Fract (fst (quot_of_fract x)) (snd (quot_of_fract x)) = x" |
/* Author: G. Jungman
*/
#include <config.h>
#include <stdlib.h>
#include <string.h>
#include <gsl/gsl_errno.h>
/* Compile all the inline functions */
#define COMPILE_INLINE_STATIC
#include "build.h"
#include <gsl/gsl_qrng.h>
|
import data.real.basic
import data.set.lattice
import topology.basic
import game.topology.union_open_sets
open set
--begin hide
namespace xena
-- end hide
def is_closed (X : set ℝ) := is_open {x : ℝ | x ∉ X }
-- begin hide
-- Checking mathlib definitions
variable β : Type* -- finite unions only
variable [fintype β]
-- end hide
/- Lemma
Finite union of closed sets is closed -- WIP, to do.
-/
lemma is_closed_fin_union_of_closed (X : β → set ℝ ) ( hj : ∀ j, is_closed (X j) )
: is_closed (Union X) :=
begin
sorry,
end
end xena -- hide |
# Created by Tristan Bester.
import sys
import numpy as np
sys.path.append('../')
from envs import RandomWalk
from functions import LinearValueFunction
from utils import encode_state,create_bar_plot
'''
Semi-gradient TD lambda used to estimate the value function
in a nineteen-state Random Walk MRP. An MRP was used as this
algorithm is focused on the prediction problem and not the
control problem. Therefore, as we are dealing with the prediction
problem there is no need to distinguish the dynamics due to the
environment from those due to the agent. More information
justifying this decision can be found on page 102
of "Reinforcement Learning: An Introduction.". The algorithm
can also be found on page 240 of the same text.
Book reference:
Sutton, R. and Barto, A., 2014. Reinforcement Learning:
An Introduction. 1st ed. London: The MIT Press.
'''
def semi_gradient_td_lambda(env, lamda, alpha, gamma, n_episodes):
# Initialize value function.
v = LinearValueFunction(env.n_states)
for episode in range(n_episodes):
done = False
obs = env.reset()
obs_vec = encode_state(obs, env.n_states)
z = np.zeros(env.n_states)
while not done:
obs_prime, reward, done = env.step()
obs_prime_vec = encode_state(obs_prime, env.n_states)
# Update eligibility traces.
z = gamma * lamda * z + obs_vec
delta = reward + gamma * v.evaluate(obs_prime_vec) - v.evaluate(obs_vec)
# Update weights.
v.weights += alpha * delta * z
obs_vec = obs_prime_vec
return v
if __name__ == '__main__':
gamma = 1
alpha = 0.1
lamda = 0.5
n_episodes = 300
env = RandomWalk(19)
v = semi_gradient_td_lambda(env, lamda, alpha, gamma, n_episodes)
create_bar_plot(range(19), v.weights, 'State index:', 'State value:', \
'Approximate state values in Random Walk MRP:')
|
(* Title: Util_Nat.thy
Date: Oct 2006
Author: David Trachtenherz
*)
header {* Results for natural arithmetics *}
theory Util_Nat
imports Main
begin
subsection {* Some convenience arithmetic lemmata *}
thm Nat.add_Suc_right
lemma add_1_Suc_conv: "m + 1 = Suc m" by simp
lemma sub_Suc0_sub_Suc_conv: "b - a - Suc 0 = b - Suc a" by simp
thm Nat.Suc_pred
lemma Suc_diff_Suc: "m < n \<Longrightarrow> Suc (n - Suc m) = n - m"
apply (rule subst[OF sub_Suc0_sub_Suc_conv])
apply (rule Suc_pred)
apply (simp only: zero_less_diff)
done
lemma nat_grSuc0_conv: "(Suc 0 < n) = (n \<noteq> 0 \<and> n \<noteq> Suc 0)"
by fastforce
lemma nat_geSucSuc0_conv: "(Suc (Suc 0) \<le> n) = (n \<noteq> 0 \<and> n \<noteq> Suc 0)"
by fastforce
lemma nat_lessSucSuc0_conv: "(n < Suc (Suc 0)) = (n = 0 \<or> n = Suc 0)"
by fastforce
lemma nat_leSuc0_conv: "(n \<le> Suc 0) = (n = 0 \<or> n = Suc 0)"
by fastforce
thm Nat.mult_Suc
lemma mult_pred: "(m - Suc 0) * n = m * n - n"
by (simp add: diff_mult_distrib)
thm Nat.mult_Suc_right
lemma mult_pred_right: "m * (n - Suc 0) = m * n - m"
by (simp add: diff_mult_distrib2)
lemma gr_implies_gr0: "m < (n::nat) \<Longrightarrow> 0 < n" by simp
thm
Nat.mult_cancel1
Nat.mult_cancel1
corollary mult_cancel1_gr0: "
(0::nat) < k \<Longrightarrow> (k * m = k * n) = (m = n)" by simp
corollary mult_cancel2_gr0: "
(0::nat) < k \<Longrightarrow> (m * k = n * k) = (m = n)" by simp
thm
Nat.mult_le_cancel1
Nat.mult_le_cancel2
corollary mult_le_cancel1_gr0: "
(0::nat) < k \<Longrightarrow> (k * m \<le> k * n) = (m \<le> n)" by simp
corollary mult_le_cancel2_gr0: "
(0::nat) < k \<Longrightarrow> (m * k \<le> n * k) = (m \<le> n)" by simp
thm mult_le_mono
lemma gr0_imp_self_le_mult1: "0 < (k::nat) \<Longrightarrow> m \<le> m * k"
by (drule Suc_leI, drule mult_le_mono[OF order_refl], simp)
lemma gr0_imp_self_le_mult2: "0 < (k::nat) \<Longrightarrow> m \<le> k * m"
by (subst mult.commute, rule gr0_imp_self_le_mult1)
lemma less_imp_Suc_mult_le: "m < n \<Longrightarrow> Suc m * k \<le> n * k"
by (rule mult_le_mono1, simp)
lemma less_imp_Suc_mult_pred_less: "\<lbrakk> m < n; 0 < k \<rbrakk> \<Longrightarrow> Suc m * k - Suc 0 < n * k"
apply (rule Suc_le_lessD)
apply (simp only: Suc_pred[OF nat_0_less_mult_iff[THEN iffD2, OF conjI, OF zero_less_Suc]])
apply (rule less_imp_Suc_mult_le, assumption)
done
thm Nat.zero_less_diff
lemma ord_zero_less_diff: "(0 < (b::'a::ordered_ab_group_add) - a) = (a < b)"
by (simp add: less_diff_eq)
lemma ord_zero_le_diff: "(0 \<le> (b::'a::ordered_ab_group_add) - a) = (a \<le> b)"
by (simp add: le_diff_eq)
text {* @{text diff_diff_right} in rule format *}
lemmas diff_diff_right = Nat.diff_diff_right[rule_format]
thm Nat.le_add1 Nat.le_add2
lemma less_add1: "(0::nat) < j \<Longrightarrow> i < i + j" by simp
lemma less_add2: "(0::nat) < j \<Longrightarrow> i < j + i" by simp
thm Nat.add_leD1 Nat.add_leD2
thm Nat.add_lessD1
lemma add_lessD2: "i + j < (k::nat) \<Longrightarrow> j < k" by simp
thm Nat.add_le_mono1
lemma add_le_mono2: "i \<le> (j::nat) \<Longrightarrow> k + i \<le> k + j" by simp
thm Nat.add_less_mono1
lemma add_less_mono2: "i < (j::nat) \<Longrightarrow> k + i < k + j" by simp
thm Nat.diff_le_self
lemma diff_less_self: "\<lbrakk> (0::nat) < i; 0 < j \<rbrakk> \<Longrightarrow> i - j < i" by simp
lemma
ge_less_neq_conv: "((a::'a::linorder) \<le> n) = (\<forall>x. x < a \<longrightarrow> n \<noteq> x)" and
le_greater_neq_conv: "(n \<le> (a::'a::linorder)) = (\<forall>x. a < x \<longrightarrow> n \<noteq> x)"
by (subst linorder_not_less[symmetric], blast)+
lemma
greater_le_neq_conv: "((a::'a::linorder) < n) = (\<forall>x. x \<le> a \<longrightarrow> n \<noteq> x)" and
less_ge_neq_conv: "(n < (a::'a::linorder)) = (\<forall>x. a \<le> x \<longrightarrow> n \<noteq> x)"
by (subst linorder_not_le[symmetric], blast)+
text {* Lemmas for @term{abs} function *}
lemma leq_pos_imp_abs_leq: "\<lbrakk> 0 \<le> (a::'a::ordered_ab_group_add_abs); a \<le> b \<rbrakk> \<Longrightarrow> \<bar>a\<bar> \<le> \<bar>b\<bar>"
by simp
lemma leq_neg_imp_abs_geq: "\<lbrakk> (a::'a::ordered_ab_group_add_abs) \<le> 0; b \<le> a \<rbrakk> \<Longrightarrow> \<bar>a\<bar> \<le> \<bar>b\<bar>"
by simp
lemma abs_range: "\<lbrakk> 0 \<le> (a::'a::{ordered_ab_group_add_abs,abs_if}); -a \<le> x; x \<le> a \<rbrakk> \<Longrightarrow> \<bar>x\<bar> \<le> a"
apply (clarsimp simp: abs_if)
thm neg_le_iff_le[THEN iffD1]
apply (rule neg_le_iff_le[THEN iffD1], simp)
done
text {* Lemmas for @term{sgn} function *}
lemma sgn_abs:"(x::'a::linordered_idom) \<noteq> 0 \<Longrightarrow> \<bar>sgn x\<bar> = 1"
by (case_tac "x < 0", simp+)
lemma sgn_mult_abs:"\<bar>x\<bar> * \<bar>sgn (a::'a::linordered_idom)\<bar> = \<bar>x * sgn a\<bar>"
by (fastforce simp add: sgn_if abs_if)
lemma abs_imp_sgn_abs: "\<bar>a\<bar> = \<bar>b\<bar> \<Longrightarrow> \<bar>sgn (a::'a::linordered_idom)\<bar> = \<bar>sgn b\<bar>"
by (fastforce simp add: abs_if)
lemma sgn_mono: "a \<le> b \<Longrightarrow> sgn (a::'a::{linordered_idom,linordered_semidom}) \<le> sgn b"
by (auto simp add: sgn_if)
subsection {* Additional facts about inequalities *}
thm Nat.le_add_diff
lemma add_diff_le: "k \<le> n \<Longrightarrow> m + k - n \<le> (m::nat)"
by (case_tac "m + k < n", simp_all)
thm
Nat.le_add_diff
add_diff_le
lemma less_add_diff: "k < (n::nat) \<Longrightarrow> m < n + m - k"
thm add_less_imp_less_right[of _ k]
by (rule add_less_imp_less_right[of _ k], simp)
thm add_diff_le
lemma add_diff_less: "\<lbrakk> k < n; 0 < m \<rbrakk> \<Longrightarrow> m + k - n < (m::nat)"
by (case_tac "m + k < n", simp_all)
thm
Nat.le_add_diff
add_diff_le
less_add_diff
add_diff_less
thm Nat.less_diff_conv
lemma add_le_imp_le_diff1: "i + k \<le> j \<Longrightarrow> i \<le> j - (k::nat)"
by (case_tac "k \<le> j", simp_all)
lemma add_le_imp_le_diff2: "k + i \<le> j \<Longrightarrow> i \<le> j - (k::nat)" by simp
thm
Nat.less_diff_conv[symmetric]
Nat.le_diff_conv2[symmetric]
add_le_imp_le_diff1
add_le_imp_le_diff2
thm
Nat.le_diff_conv Nat.le_diff_conv2
Nat.less_diff_conv
lemma diff_less_imp_less_add: "j - (k::nat) < i \<Longrightarrow> j < i + k" by simp
thm Nat.le_diff_conv
lemma diff_less_conv: "0 < i \<Longrightarrow> (j - (k::nat) < i) = (j < i + k)"
by (safe, simp_all)
lemma diff_less_imp_swap: "\<lbrakk> 0 < (i::nat); k - i < j \<rbrakk> \<Longrightarrow> (k - j < i)" by simp
lemma diff_less_swap: "\<lbrakk> 0 < (i::nat); 0 < j \<rbrakk> \<Longrightarrow> (k - j < i) = (k - i < j)"
by (blast intro: diff_less_imp_swap)
lemma less_diff_imp_less: "(i::nat) < j - m \<Longrightarrow> i < j" by simp
lemma le_diff_imp_le: "(i::nat) \<le> j - m \<Longrightarrow> i \<le> j" by simp
lemma less_diff_le_imp_less: "\<lbrakk> (i::nat) < j - m; n \<le> m \<rbrakk> \<Longrightarrow> i < j - n" by simp
lemma le_diff_le_imp_le: "\<lbrakk> (i::nat) \<le> j - m; n \<le> m \<rbrakk> \<Longrightarrow> i \<le> j - n" by simp
thm Nat.less_imp_diff_less
lemma le_imp_diff_le: "(j::nat) \<le> k \<Longrightarrow> j - n \<le> k" by simp
subsection {* Inequalities for Suc and pred *}
thm Nat.less_Suc_eq_le
corollary less_eq_le_pred: "0 < (n::nat) \<Longrightarrow> (m < n) = (m \<le> n - Suc 0)"
by (safe, simp_all)
corollary less_imp_le_pred: "m < n \<Longrightarrow> m \<le> n - Suc 0" by simp
corollary le_pred_imp_less: "\<lbrakk> 0 < n; m \<le> n - Suc 0 \<rbrakk> \<Longrightarrow> m < n" by simp
thm Nat.Suc_le_eq
corollary pred_less_eq_le: "0 < m \<Longrightarrow> (m - Suc 0 < n) = (m \<le> n)"
by (safe, simp_all)
corollary pred_less_imp_le: "m - Suc 0 < n \<Longrightarrow> m \<le> n" by simp
corollary le_imp_pred_less: "\<lbrakk> 0 < m; m \<le> n \<rbrakk> \<Longrightarrow> m - Suc 0 < n" by simp
thm Nat.diff_add_inverse
lemma diff_add_inverse_Suc: "n < m \<Longrightarrow> n + (m - Suc n) = m - Suc 0" by simp
thm Nat.Suc_mono
lemma pred_mono: "\<lbrakk> m < n; 0 < m \<rbrakk> \<Longrightarrow> m - Suc 0 < n - Suc 0" by simp
corollary pred_Suc_mono: "\<lbrakk> m < Suc n; 0 < m \<rbrakk> \<Longrightarrow> m - Suc 0 < n" by simp
lemma Suc_less_pred_conv: "(Suc m < n) = (m < n - Suc 0)" by (safe, simp_all)
lemma Suc_le_pred_conv: "0 < n \<Longrightarrow> (Suc m \<le> n) = (m \<le> n - Suc 0)" by (safe, simp_all)
lemma Suc_le_imp_le_pred: "Suc m \<le> n \<Longrightarrow> m \<le> n - Suc 0" by simp
subsection {* Additional facts about cancellation in (in-)equalities *}
lemma diff_cancel_imp_eq: "\<lbrakk> 0 < (n::nat); n + i - j = n \<rbrakk> \<Longrightarrow> i = j" by simp
thm
Nat.nat_add_left_cancel_less
Nat.nat_add_left_cancel_le
Nat.nat_add_right_cancel
Nat.nat_add_left_cancel
Nat.diff_diff_eq
Nat.eq_diff_iff
Nat.less_diff_iff
Nat.le_diff_iff
lemma nat_diff_left_cancel_less: "k - m < k - (n::nat) \<Longrightarrow> n < m" by simp
lemma nat_diff_right_cancel_less: "n - k < (m::nat) - k \<Longrightarrow> n < m" by simp
lemma nat_diff_left_cancel_le1: "\<lbrakk> k - m \<le> k - (n::nat); m < k \<rbrakk> \<Longrightarrow> n \<le> m" by simp
lemma nat_diff_left_cancel_le2: "\<lbrakk> k - m \<le> k - (n::nat); n \<le> k \<rbrakk> \<Longrightarrow> n \<le> m" by simp
lemma nat_diff_right_cancel_le1: "\<lbrakk> m - k \<le> n - (k::nat); k < m \<rbrakk> \<Longrightarrow> m \<le> n" by simp
lemma nat_diff_right_cancel_le2: "\<lbrakk> m - k \<le> n - (k::nat); k \<le> n \<rbrakk> \<Longrightarrow> m \<le> n" by simp
lemma nat_diff_left_cancel_eq1: "\<lbrakk> k - m = k - (n::nat); m < k \<rbrakk> \<Longrightarrow> m = n" by simp
lemma nat_diff_left_cancel_eq2: "\<lbrakk> k - m = k - (n::nat); n < k \<rbrakk> \<Longrightarrow> m = n" by simp
lemma nat_diff_right_cancel_eq1: "\<lbrakk> m - k = n - (k::nat); k < m \<rbrakk> \<Longrightarrow> m = n" by simp
lemma nat_diff_right_cancel_eq2: "\<lbrakk> m - k = n - (k::nat); k < n \<rbrakk> \<Longrightarrow> m = n" by simp
thm eq_diff_iff
lemma eq_diff_left_iff: "\<lbrakk> (m::nat) \<le> k; n \<le> k\<rbrakk> \<Longrightarrow> (k - m = k - n) = (m = n)"
by (safe, simp_all)
thm Nat.nat_add_right_cancel Nat.nat_add_left_cancel
thm Nat.diff_le_mono
lemma eq_imp_diff_eq: "m = (n::nat) \<Longrightarrow> m - k = n - k" by simp
text {* List of definitions and lemmas *}
thm
Nat.add_Suc_right
add_1_Suc_conv
sub_Suc0_sub_Suc_conv
thm
Nat.mult_cancel1
Nat.mult_cancel2
mult_cancel1_gr0
mult_cancel2_gr0
thm
Nat.add_lessD1
add_lessD2
thm
Nat.zero_less_diff
ord_zero_less_diff
ord_zero_le_diff
thm
Nat.le_add_diff
add_diff_le
less_add_diff
add_diff_less
thm
Nat.le_diff_conv Nat.le_diff_conv2
Nat.less_diff_conv
diff_less_imp_less_add
diff_less_conv
thm
le_diff_swap
diff_less_imp_swap
diff_less_swap
thm
less_diff_imp_less
le_diff_imp_le
thm
less_diff_le_imp_less
le_diff_le_imp_le
thm
Nat.less_imp_diff_less
le_imp_diff_le
thm
Nat.less_Suc_eq_le
less_eq_le_pred
less_imp_le_pred
le_pred_imp_less
thm
Nat.Suc_le_eq
pred_less_eq_le
pred_less_imp_le
le_imp_pred_less
thm
diff_cancel_imp_eq
thm
diff_add_inverse_Suc
thm
Nat.nat_add_left_cancel_less
Nat.nat_add_left_cancel_le
Nat.nat_add_right_cancel
Nat.nat_add_left_cancel
Nat.eq_diff_iff
Nat.less_diff_iff
Nat.le_diff_iff
thm
nat_diff_left_cancel_less
nat_diff_right_cancel_less
thm
nat_diff_left_cancel_le1
nat_diff_left_cancel_le2
nat_diff_right_cancel_le1
nat_diff_right_cancel_le2
thm
nat_diff_left_cancel_eq1
nat_diff_left_cancel_eq2
nat_diff_right_cancel_eq1
nat_diff_right_cancel_eq2
thm
Nat.eq_diff_iff
eq_diff_left_iff
thm
Nat.nat_add_right_cancel Nat.nat_add_left_cancel
Nat.diff_le_mono
eq_imp_diff_eq
end
|
module Main
import Data.Strings
lorem : String
lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
partial
main : IO ()
main = do
printLn (prim__strIndex lorem 10)
printLn (prim__strIndex lorem 50)
printLn (prim__strIndex lorem 100)
printLn (prim__strIndex lorem 200)
|
theory Ex031
imports Main
begin
lemma "(A \<longrightarrow> B) \<or> A \<longleftrightarrow> (B \<longrightarrow> A) \<or> B "
proof -
{
assume a:"(A \<longrightarrow> B) \<or> A"
{
assume b:"\<not>((B \<longrightarrow> A) \<or> B)"
{
assume c:A
{
assume B
have A by (rule c)
}
hence "B \<longrightarrow> A" by (rule impI)
hence "(B \<longrightarrow> A) \<or> B" by (rule disjI1)
with b have False by contradiction
hence "(B \<longrightarrow> A) \<or> B" by (rule FalseE)
}
note d=this
{
assume "A \<longrightarrow> B"
{
assume e:B
{
assume "\<not>A"
from e have "(B \<longrightarrow> A) \<or> B" by (rule disjI2)
with b have False by contradiction
}
hence "\<not>\<not>A" by (rule notI)
hence A by (rule notnotD)
}
hence "B \<longrightarrow> A" by (rule impI)
hence "(B \<longrightarrow> A) \<or> B" by (rule disjI1)
}
from a and this and d have "(B \<longrightarrow> A) \<or> B" by (rule disjE)
with b have False by contradiction
}
hence "\<not>\<not>((B \<longrightarrow> A) \<or> B)" by (rule notI)
hence "(B \<longrightarrow> A) \<or> B" by (rule notnotD)
}
moreover
{
assume f:"(B \<longrightarrow> A) \<or> B"
{
assume g:"\<not>((A \<longrightarrow> B) \<or> A)"
{
assume h:B
{
assume A
have B by (rule h)
}
hence "A \<longrightarrow> B" by (rule impI)
hence "(A \<longrightarrow> B) \<or> A" by (rule disjI1)
}
note i=this
{
assume "B \<longrightarrow> A"
{
assume j:A
{
assume "\<not>B"
from j have "(A \<longrightarrow> B) \<or> A" by (rule disjI2)
with g have False by contradiction
}
hence "\<not>\<not>B" by (rule notI)
hence B by (rule notnotD)
}
hence "A \<longrightarrow> B" by (rule impI)
hence "(A \<longrightarrow> B) \<or> A" by (rule disjI1)
}
from f and this and i have "(A \<longrightarrow> B) \<or> A" by (rule disjE)
with g have False by contradiction
}
hence "\<not>\<not>((A \<longrightarrow> B) \<or> A)" by (rule notI)
hence "(A \<longrightarrow> B) \<or> A" by (rule notnotD)
}
ultimately show ?thesis by (rule iffI)
qed
|
(* Title: ZF/Cardinal_AC.thy
Author: Lawrence C Paulson, Cambridge University Computer Laboratory
Copyright 1994 University of Cambridge
These results help justify infinite-branching datatypes
*)
section\<open>Cardinal Arithmetic Using AC\<close>
theory Cardinal_AC imports CardinalArith Zorn begin
subsection\<open>Strengthened Forms of Existing Theorems on Cardinals\<close>
lemma cardinal_eqpoll: "|A| \<approx> A"
apply (rule AC_well_ord [THEN exE])
apply (erule well_ord_cardinal_eqpoll)
done
text\<open>The theorem @{term "||A|| = |A|"}\<close>
lemmas cardinal_idem = cardinal_eqpoll [THEN cardinal_cong, simp]
lemma cardinal_eqE: "|X| = |Y| ==> X \<approx> Y"
apply (rule AC_well_ord [THEN exE])
apply (rule AC_well_ord [THEN exE])
apply (rule well_ord_cardinal_eqE, assumption+)
done
lemma cardinal_eqpoll_iff: "|X| = |Y| \<longleftrightarrow> X \<approx> Y"
by (blast intro: cardinal_cong cardinal_eqE)
lemma cardinal_disjoint_Un:
"[| |A|=|B|; |C|=|D|; A \<inter> C = 0; B \<inter> D = 0 |]
==> |A \<union> C| = |B \<union> D|"
by (simp add: cardinal_eqpoll_iff eqpoll_disjoint_Un)
lemma lepoll_imp_Card_le: "A \<lesssim> B ==> |A| \<le> |B|"
apply (rule AC_well_ord [THEN exE])
apply (erule well_ord_lepoll_imp_Card_le, assumption)
done
lemma cadd_assoc: "(i \<oplus> j) \<oplus> k = i \<oplus> (j \<oplus> k)"
apply (rule AC_well_ord [THEN exE])
apply (rule AC_well_ord [THEN exE])
apply (rule AC_well_ord [THEN exE])
apply (rule well_ord_cadd_assoc, assumption+)
done
lemma cmult_assoc: "(i \<otimes> j) \<otimes> k = i \<otimes> (j \<otimes> k)"
apply (rule AC_well_ord [THEN exE])
apply (rule AC_well_ord [THEN exE])
apply (rule AC_well_ord [THEN exE])
apply (rule well_ord_cmult_assoc, assumption+)
done
lemma cadd_cmult_distrib: "(i \<oplus> j) \<otimes> k = (i \<otimes> k) \<oplus> (j \<otimes> k)"
apply (rule AC_well_ord [THEN exE])
apply (rule AC_well_ord [THEN exE])
apply (rule AC_well_ord [THEN exE])
apply (rule well_ord_cadd_cmult_distrib, assumption+)
done
lemma InfCard_square_eq: "InfCard(|A|) ==> A*A \<approx> A"
apply (rule AC_well_ord [THEN exE])
apply (erule well_ord_InfCard_square_eq, assumption)
done
subsection \<open>The relationship between cardinality and le-pollence\<close>
lemma Card_le_imp_lepoll:
assumes "|A| \<le> |B|" shows "A \<lesssim> B"
proof -
have "A \<approx> |A|"
by (rule cardinal_eqpoll [THEN eqpoll_sym])
also have "... \<lesssim> |B|"
by (rule le_imp_subset [THEN subset_imp_lepoll]) (rule assms)
also have "... \<approx> B"
by (rule cardinal_eqpoll)
finally show ?thesis .
qed
lemma le_Card_iff: "Card(K) ==> |A| \<le> K \<longleftrightarrow> A \<lesssim> K"
apply (erule Card_cardinal_eq [THEN subst], rule iffI,
erule Card_le_imp_lepoll)
apply (erule lepoll_imp_Card_le)
done
lemma cardinal_0_iff_0 [simp]: "|A| = 0 \<longleftrightarrow> A = 0"
apply auto
apply (drule cardinal_0 [THEN ssubst])
apply (blast intro: eqpoll_0_iff [THEN iffD1] cardinal_eqpoll_iff [THEN iffD1])
done
lemma cardinal_lt_iff_lesspoll:
assumes i: "Ord(i)" shows "i < |A| \<longleftrightarrow> i \<prec> A"
proof
assume "i < |A|"
hence "i \<prec> |A|"
by (blast intro: lt_Card_imp_lesspoll Card_cardinal)
also have "... \<approx> A"
by (rule cardinal_eqpoll)
finally show "i \<prec> A" .
next
assume "i \<prec> A"
also have "... \<approx> |A|"
by (blast intro: cardinal_eqpoll eqpoll_sym)
finally have "i \<prec> |A|" .
thus "i < |A|" using i
by (force intro: cardinal_lt_imp_lt lesspoll_cardinal_lt)
qed
lemma cardinal_le_imp_lepoll: " i \<le> |A| ==> i \<lesssim> A"
by (blast intro: lt_Ord Card_le_imp_lepoll Ord_cardinal_le le_trans)
subsection\<open>Other Applications of AC\<close>
lemma surj_implies_inj:
assumes f: "f \<in> surj(X,Y)" shows "\<exists>g. g \<in> inj(Y,X)"
proof -
from f AC_Pi [of Y "%y. f-``{y}"]
obtain z where z: "z \<in> (\<Prod>y\<in>Y. f -`` {y})"
by (auto simp add: surj_def) (fast dest: apply_Pair)
show ?thesis
proof
show "z \<in> inj(Y, X)" using z surj_is_fun [OF f]
by (blast dest: apply_type Pi_memberD
intro: apply_equality Pi_type f_imp_injective)
qed
qed
text\<open>Kunen's Lemma 10.20\<close>
lemma surj_implies_cardinal_le:
assumes f: "f \<in> surj(X,Y)" shows "|Y| \<le> |X|"
proof (rule lepoll_imp_Card_le)
from f [THEN surj_implies_inj] obtain g where "g \<in> inj(Y,X)" ..
thus "Y \<lesssim> X"
by (auto simp add: lepoll_def)
qed
text\<open>Kunen's Lemma 10.21\<close>
lemma cardinal_UN_le:
assumes K: "InfCard(K)"
shows "(!!i. i\<in>K ==> |X(i)| \<le> K) ==> |\<Union>i\<in>K. X(i)| \<le> K"
proof (simp add: K InfCard_is_Card le_Card_iff)
have [intro]: "Ord(K)" by (blast intro: InfCard_is_Card Card_is_Ord K)
assume "!!i. i\<in>K ==> X(i) \<lesssim> K"
hence "!!i. i\<in>K ==> \<exists>f. f \<in> inj(X(i), K)" by (simp add: lepoll_def)
with AC_Pi obtain f where f: "f \<in> (\<Prod>i\<in>K. inj(X(i), K))"
by force
{ fix z
assume z: "z \<in> (\<Union>i\<in>K. X(i))"
then obtain i where i: "i \<in> K" "Ord(i)" "z \<in> X(i)"
by (blast intro: Ord_in_Ord [of K])
hence "(\<mu> i. z \<in> X(i)) \<le> i" by (fast intro: Least_le)
hence "(\<mu> i. z \<in> X(i)) < K" by (best intro: lt_trans1 ltI i)
hence "(\<mu> i. z \<in> X(i)) \<in> K" and "z \<in> X(\<mu> i. z \<in> X(i))"
by (auto intro: LeastI ltD i)
} note mems = this
have "(\<Union>i\<in>K. X(i)) \<lesssim> K \<times> K"
proof (unfold lepoll_def)
show "\<exists>f. f \<in> inj(\<Union>RepFun(K, X), K \<times> K)"
apply (rule exI)
apply (rule_tac c = "%z. \<langle>\<mu> i. z \<in> X(i), f ` (\<mu> i. z \<in> X(i)) ` z\<rangle>"
and d = "%\<langle>i,j\<rangle>. converse (f`i) ` j" in lam_injective)
apply (force intro: f inj_is_fun mems apply_type Perm.left_inverse)+
done
qed
also have "... \<approx> K"
by (simp add: K InfCard_square_eq InfCard_is_Card Card_cardinal_eq)
finally show "(\<Union>i\<in>K. X(i)) \<lesssim> K" .
qed
text\<open>The same again, using @{term csucc}\<close>
lemma cardinal_UN_lt_csucc:
"[| InfCard(K); \<And>i. i\<in>K \<Longrightarrow> |X(i)| < csucc(K) |]
==> |\<Union>i\<in>K. X(i)| < csucc(K)"
by (simp add: Card_lt_csucc_iff cardinal_UN_le InfCard_is_Card Card_cardinal)
text\<open>The same again, for a union of ordinals. In use, j(i) is a bit like rank(i),
the least ordinal j such that i:Vfrom(A,j).\<close>
lemma cardinal_UN_Ord_lt_csucc:
"[| InfCard(K); \<And>i. i\<in>K \<Longrightarrow> j(i) < csucc(K) |]
==> (\<Union>i\<in>K. j(i)) < csucc(K)"
apply (rule cardinal_UN_lt_csucc [THEN Card_lt_imp_lt], assumption)
apply (blast intro: Ord_cardinal_le [THEN lt_trans1] elim: ltE)
apply (blast intro!: Ord_UN elim: ltE)
apply (erule InfCard_is_Card [THEN Card_is_Ord, THEN Card_csucc])
done
subsection\<open>The Main Result for Infinite-Branching Datatypes\<close>
text\<open>As above, but the index set need not be a cardinal. Work
backwards along the injection from @{term W} into @{term K}, given
that @{term"W\<noteq>0"}.\<close>
lemma inj_UN_subset:
assumes f: "f \<in> inj(A,B)" and a: "a \<in> A"
shows "(\<Union>x\<in>A. C(x)) \<subseteq> (\<Union>y\<in>B. C(if y \<in> range(f) then converse(f)`y else a))"
proof (rule UN_least)
fix x
assume x: "x \<in> A"
hence fx: "f ` x \<in> B" by (blast intro: f inj_is_fun [THEN apply_type])
have "C(x) \<subseteq> C(if f ` x \<in> range(f) then converse(f) ` (f ` x) else a)"
using f x by (simp add: inj_is_fun [THEN apply_rangeI])
also have "... \<subseteq> (\<Union>y\<in>B. C(if y \<in> range(f) then converse(f) ` y else a))"
by (rule UN_upper [OF fx])
finally show "C(x) \<subseteq> (\<Union>y\<in>B. C(if y \<in> range(f) then converse(f)`y else a))" .
qed
theorem le_UN_Ord_lt_csucc:
assumes IK: "InfCard(K)" and WK: "|W| \<le> K" and j: "\<And>w. w\<in>W \<Longrightarrow> j(w) < csucc(K)"
shows "(\<Union>w\<in>W. j(w)) < csucc(K)"
proof -
have CK: "Card(K)"
by (simp add: InfCard_is_Card IK)
then obtain f where f: "f \<in> inj(W, K)" using WK
by(auto simp add: le_Card_iff lepoll_def)
have OU: "Ord(\<Union>w\<in>W. j(w))" using j
by (blast elim: ltE)
note lt_subset_trans [OF _ _ OU, trans]
show ?thesis
proof (cases "W=0")
case True \<comment>\<open>solve the easy 0 case\<close>
thus ?thesis by (simp add: CK Card_is_Ord Card_csucc Ord_0_lt_csucc)
next
case False
then obtain x where x: "x \<in> W" by blast
have "(\<Union>x\<in>W. j(x)) \<subseteq> (\<Union>k\<in>K. j(if k \<in> range(f) then converse(f) ` k else x))"
by (rule inj_UN_subset [OF f x])
also have "... < csucc(K)" using IK
proof (rule cardinal_UN_Ord_lt_csucc)
fix k
assume "k \<in> K"
thus "j(if k \<in> range(f) then converse(f) ` k else x) < csucc(K)" using f x j
by (simp add: inj_converse_fun [THEN apply_type])
qed
finally show ?thesis .
qed
qed
end
|
Tickets go on sale October 13th.
The NOVA Open Charitable Foundation’s 2017 Fall Model, Warhammer 40K Commissar was donated & painted by David Faust; visit his facebook page for more work.
Leading men has never been a task this old Commissar desired, but rather a necessity to see his people come through. In the harsh battle field toxic dust and chemicals are almost more harmful than the enemy, but this grizzled veteran see it as a way to feel alive and thus has removed his gas mask, a sign of imminent death in one last glorious charge. |
function diagnostic = callstrul(F,h,options)
F_new = [];
for i = 1:length(F)
if ~is(F(i),'lmi')
F_new = F_new + F(i);
else
X = sdpvar(F(i));
[l,m,r]=factors(X);
if isempty(m)
F_new = F_new + F(i);
else
[L1,R1,A1,M1,negated_cont1,negated_disc1,epsilon1,delta1,numpos1,xindicies,Pindicies] = preprocess_constraint(X);
F_new = F_new + assignschur(F(i),'HKM_schur_LR_structure',L1,R1,A1,M1,negated_cont1,negated_disc1,epsilon1,delta1,numpos1,xindicies,Pindicies);
end
end
end
if nargin < 2
% Equalities are converted internally in SDPT3 to double-sided
% inequalities. This messes up our Schur compiler, hence we do it
% already outside SDPT3
options = sdpsettings('solver','sdpt3','removeequalities',-1);
else
options.solver = 'sdpt3';
options.removeequalities = -1;
end
diagnostic = solvesdp(F_new,h,options);
|
function view = setBrightness(view,val);
%
% view = setBrightness(view,[val]);
%
% Set the brightness of a view, by
% changing the color maps in each
% view mode. Only those parts which
% are used for the anatomical underlay
% image (the first 1:numGrays entries)
% are brightened -- the overlays are
% unchanged.
%
% Val can range from 0 to 1. If omitted,
% it is read off of the view's brightness
% slider (so hopefully, in these circumstances,
% it has one).
%
%
% ras 01/05.
if notDefined('val')
val = get(view.ui.brightness.sliderHandle,'Value');
end
setSlider(view,view.ui.brightness,val);
numGrays = view.ui.mapMode.numGrays;
cmap = gray(numGrays);
delta = 2*val - 1;
if delta ~= 0
cmap = brighten(cmap,delta);
end
view.ui.anatMode.cmap = cmap;
view.ui.ampMode.cmap(1:numGrays,:) = cmap;
view.ui.phMode.cmap(1:numGrays,:) = cmap;
view.ui.coMode.cmap(1:numGrays,:) = cmap;
view.ui.mapMode.cmap(1:numGrays,:) = cmap;
view = refreshScreen(view, 1);
return
|
{-# OPTIONS_GHC -fwarn-unused-imports #-}
module Main(main) where
import Control.Monad
import Control.Monad.Par
import Control.Monad.Par.Internal (runParAsync)
import Control.Monad.Par.Stream as S
import Control.Monad.Par.OpenList
import Control.DeepSeq
import Control.Exception
-- import Data.Array.Unboxed as U
import Data.Array.CArray as C
import Data.Complex
import Data.Int
import Data.Word
import Data.List (intersperse)
import Data.List.Split (chunk)
import System.CPUTime
import System.CPUTime.Rdtsc
import GHC.Conc as Conc
import GHC.IO (unsafePerformIO, unsafeDupablePerformIO, unsafeInterleaveIO)
import Debug.Trace
--------------------------------------------------------------------------------
-- Main script
main = do
-- Generate 20 million elements:
let s = countupWin 1024 (20 * 1000 * 1000) :: Par (WStream Int)
measureRate $ runParAsync s
putStrLn$ "Done with 5 million elements."
|
module Ch20 where
import Data.Complex
dft :: RealFloat a => [Complex a] -> [Complex a]
dft xs =
let lenI = length xs
lenR = fromIntegral lenI
lenC = lenR :+ 0
in [let i = negate 2 * pi * fromIntegral k/lenR
in (1/lenC) * sum [(xs !! n) * exp (0 :+ i * fromIntegral n)
| n <- [0, 1 .. lenI - 1]]
| k <- [0, 1 .. lenI - 1]]
-- This seems to work, but I don't truly understand it
idft :: RealFloat a => [Complex a] -> [Complex a]
idft xs =
let lenI = length xs
lenR = fromIntegral lenI
lenC = lenR :+ 0
in [let i = 2 * pi * fromIntegral k/lenR
in sum [(xs !! n) * exp (0 :+ i * fromIntegral n)
| n <- [0, 1 .. lenI - 1]]
| k <- [0, 1 .. lenI - 1]]
printComplexL :: [Complex Double] -> IO ()
printComplexL xs =
let f (i, rl :+ im) =
do putStr (spaces (3 - length (show i)))
putStr (show i ++ ": (" )
putStr (niceNum rl ++ ", " )
putStr (niceNum im ++ ")\n" )
in mapM_ f (zip [0 .. length xs - 1] xs)
niceNum :: Double -> String
niceNum d =
let d' = fromIntegral (round (1e10 * d))/1e10
(dec, fra) = break (== '.') (show d')
(fra', exp) = break (== 'e') fra
in spaces (3 - length dec) ++ dec ++ take 11 fra'
++ exp ++ spaces (12 - length fra' - length exp)
spaces :: Int -> String
spaces n = take n (repeat ' ')
mkTerm :: Int -> Double -> [Complex Double]
mkTerm num n = let f = 2 * pi/fromIntegral num
in [sin (n * f * fromIntegral i)/n :+ 0
| i <- [0, 1 .. num - 1]]
mkxa, mkxb, mkxc :: Int -> [Complex Double]
mkxa num = mkTerm num 1
mkxb num = zipWith (+) (mkxa num) (mkTerm num 3)
mkxc num = zipWith (+) (mkxb num) (mkTerm num 5)
testXc n = printComplexL (dft (mkxc n))
mkPulse :: Int -> [Complex Double]
mkPulse n = 100 : take (n - 1) (repeat 0)
testPulse n = printComplexL (dft (mkPulse n)) |
#include <boost/assign/std/vector.hpp>
#include <cradle/common.hpp>
#include <cradle/geometry/common.hpp>
#include <cradle/geometry/transformations.hpp>
#include <cradle/math/common.hpp>
#include <vector>
#include <cradle/test.hpp>
using namespace cradle;
TEST_CASE("sizeof_vector")
{
// Check that vectors don't have any size overhead.
REQUIRE(sizeof(vector<3, int>) == 3 * sizeof(int));
REQUIRE(sizeof(vector<1, float>) == sizeof(float));
REQUIRE(sizeof(vector<2, double>) == 2 * sizeof(double));
}
void
f(vector3i const& v)
{
}
// confirm that the vector operators work as expected
TEST_CASE("vector_operators")
{
vector<3, int> p = make_vector<int>(1, 1, 0),
q = make_vector<int>(4, 2, 6);
vector<3, int> v = make_vector<int>(3, 1, 2);
REQUIRE(p - q == make_vector<int>(-3, -1, -6));
REQUIRE(p + v == make_vector<int>(4, 2, 2));
REQUIRE(v * 3 == make_vector<int>(9, 3, 6));
REQUIRE(v / 2 == make_vector<int>(1, 0, 1));
REQUIRE(!(p == q));
REQUIRE(p != q);
REQUIRE(!(p - q == v));
REQUIRE(p - q != v);
}
TEST_CASE("vector_slice")
{
{
vector3i p = make_vector<int>(6, 7, 8);
REQUIRE(slice(p, 0) == make_vector<int>(7, 8));
REQUIRE(slice(p, 1) == make_vector<int>(6, 8));
REQUIRE(slice(p, 2) == make_vector<int>(6, 7));
}
{
vector2f p = make_vector<float>(9, 17);
REQUIRE(slice(p, 0) == make_vector<float>(17));
REQUIRE(slice(p, 1) == make_vector<float>(9));
}
{
vector4i p = make_vector<int>(4, 3, 2, 1);
REQUIRE(slice(p, 0) == make_vector<int>(3, 2, 1));
REQUIRE(slice(p, 1) == make_vector<int>(4, 2, 1));
REQUIRE(slice(p, 2) == make_vector<int>(4, 3, 1));
REQUIRE(slice(p, 3) == make_vector<int>(4, 3, 2));
}
}
TEST_CASE("test_unslice_vector")
{
{
vector3i p = make_vector<int>(6, 7, 8);
REQUIRE(unslice(p, 0, 0) == make_vector<int>(0, 6, 7, 8));
REQUIRE(unslice(p, 1, 0) == make_vector<int>(6, 0, 7, 8));
REQUIRE(unslice(p, 2, 0) == make_vector<int>(6, 7, 0, 8));
REQUIRE(unslice(p, 3, 0) == make_vector<int>(6, 7, 8, 0));
}
{
vector2d p = make_vector<double>(9, 17);
REQUIRE(unslice(p, 0, 2.1) == make_vector<double>(2.1, 9, 17));
REQUIRE(unslice(p, 1, 2.1) == make_vector<double>(9, 2.1, 17));
REQUIRE(unslice(p, 2, 2.1) == make_vector<double>(9, 17, 2.1));
}
}
TEST_CASE("test_uniform_vector")
{
REQUIRE((uniform_vector<3, int>(0)) == make_vector<int>(0, 0, 0));
REQUIRE(
(uniform_vector<4, unsigned>(1)) == make_vector<unsigned>(1, 1, 1, 1));
REQUIRE((uniform_vector<2, float>(6)) == make_vector<float>(6, 6));
}
TEST_CASE("vector_almost_equal")
{
REQUIRE(almost_equal(
make_vector<double>(0, 0, 0),
make_vector<double>(0, 0, default_equality_tolerance<double>() / 2)));
REQUIRE(!almost_equal(
make_vector<float>(0, 0, 0), make_vector<float>(0, 0, 1)));
REQUIRE(almost_equal(
make_vector<float>(0, 0, 0), make_vector<float>(0, 0, 1), 2));
}
TEST_CASE("vector_cross")
{
// with objects
REQUIRE(almost_equal(
cross(make_vector<double>(1, 0, 0), make_vector<double>(0, 1, 0)),
make_vector<double>(0, 0, 1)));
REQUIRE(almost_equal(
cross(make_vector<double>(0, 1, 0), make_vector<double>(1, 0, 0)),
make_vector<double>(0, 0, -1)));
// with expressions
REQUIRE(almost_equal(
cross(
make_vector<double>(1, 0, 0) - make_vector<double>(0, 0, 0),
make_vector<double>(0, 1, 0) - make_vector<double>(0, 0, 0)),
make_vector<double>(0, 0, 1)));
// mixing expressions and objects
REQUIRE(almost_equal(
cross(
make_vector<double>(1, 0, 0) - make_vector<double>(0, 0, 0),
make_vector<double>(0, 1, 0)),
make_vector<double>(0, 0, 1)));
REQUIRE(almost_equal(
cross(
make_vector<double>(1, 0, 0),
make_vector<double>(0, 1, 0) - make_vector<double>(0, 0, 0)),
make_vector<double>(0, 0, 1)));
}
TEST_CASE("vector_dot")
{
// with objects
REQUIRE(almost_equal(
dot(make_vector<double>(1, 1), make_vector<double>(0.7, 0.3)), 1.));
REQUIRE(almost_equal(
dot(make_vector<double>(1, 0, 0), make_vector<double>(0, 1, 0)), 0.));
REQUIRE(almost_equal(
dot(make_vector<double>(1), make_vector<double>(0.6)), 0.6));
REQUIRE(dot(make_vector<int>(1, 2, 0), make_vector<int>(2, 3, 0)) == 8);
// with expressions
REQUIRE(almost_equal(
dot(make_vector<double>(1, 0, 1) - make_vector<double>(0, 0, 0),
make_vector<double>(0.7, 0, 0.3) - make_vector<double>(0, 0, 0)),
1.));
// mixing expressions and objects
REQUIRE(almost_equal(
dot(make_vector<float>(1, 1),
make_vector<float>(0.7f, 0.3f) - make_vector<float>(0, 0)),
1.f));
REQUIRE(almost_equal(
dot(make_vector<double>(1, 0, 1) - make_vector<double>(0, 0, 0),
make_vector<double>(0.7, 0, 0.3)),
1.));
}
TEST_CASE("vector_length")
{
// length2()
REQUIRE(length2(make_vector<int>(2, 0, 1)) == 5);
// length()
REQUIRE(almost_equal(length(make_vector<double>(2, 1)), sqrt(5.)));
// length() with an expression
REQUIRE(almost_equal(
length(make_vector<double>(2, 0, 1) - make_vector<double>(1, 0, 0)),
sqrt(2.)));
}
TEST_CASE("unit_vector")
{
REQUIRE(almost_equal(
unit(make_vector<double>(4, 0, 3)), make_vector<double>(0.8, 0, 0.6)));
// with an expression
REQUIRE(almost_equal(
unit(make_vector<double>(3, 0) - make_vector<double>(0, 4)),
make_vector<double>(0.6, -0.8)));
}
TEST_CASE("perpendicular_vector")
{
for (int x = -1; x < 2; ++x)
{
for (int y = -1; y < 2; ++y)
{
for (int z = -1; z < 2; ++z)
{
if (x != 0 || y != 0 || z != 0)
{
vector<3, double> v = make_vector<double>(x, y, z);
CRADLE_CHECK_ALMOST_EQUAL(
dot(v, get_perpendicular(v)), 0.);
CRADLE_CHECK_ALMOST_EQUAL(
length(get_perpendicular(v)), 1.);
}
}
}
}
}
TEST_CASE("product_test")
{
REQUIRE(product(make_vector<int>(2, 3, 1)) == 6);
REQUIRE(product(make_vector<int>(2, -1, 3, 1)) == -6);
REQUIRE(almost_equal(product(make_vector<float>(2.5, 4, 2)), 20.f));
REQUIRE(almost_equal(product(make_vector<double>(2.5, 4)), 10.));
// with an expression
REQUIRE(
product(make_vector<int>(2, -1, 3, 0) - make_vector<int>(6, 0, 0, 1))
== -12);
}
TEST_CASE("vector_io")
{
vector3i p = make_vector<int>(2, 0, 3);
REQUIRE(to_string(p) == "(2, 0, 3)");
}
TEST_CASE("compute_mean_vector_test")
{
using namespace boost::assign;
std::vector<vector3d> vectors;
vectors += make_vector<double>(2, 0, 3), make_vector<double>(6, 1, 7),
make_vector<double>(0, 0, 0), make_vector<double>(1, 2, 0),
make_vector<double>(3, 2, 1), make_vector<double>(6, 4, 1);
REQUIRE(almost_equal(
compute_mean(vectors, uniform_vector<3>(0.)),
make_vector<double>(3, 1.5, 2)));
}
TEST_CASE("plane_test")
{
plane<double> default_constructed;
vector3d p = make_vector<double>(0, 0, 0);
vector3d normal = make_vector<double>(1, 0, 0);
plane<double> plane(p, normal);
REQUIRE(plane.point == p);
REQUIRE(plane.normal == normal);
vector3d q = make_vector<double>(0, 0, 1);
plane.point = q;
REQUIRE(plane.point == q);
REQUIRE(plane.normal == normal);
normal = make_vector<double>(0, 1, 0);
plane.normal = normal;
REQUIRE(plane.point == q);
REQUIRE(plane.normal == normal);
}
TEST_CASE("simple_box1i_test")
{
box1i b(make_vector<int>(-1), make_vector<int>(4));
REQUIRE(get_center(b)[0] == 1);
REQUIRE(b.corner[0] == -1);
REQUIRE(b.size[0] == 4);
REQUIRE(!is_inside(b, make_vector<int>(-2)));
REQUIRE(is_inside(b, make_vector<int>(-1)));
REQUIRE(is_inside(b, make_vector<int>(2)));
REQUIRE(!is_inside(b, make_vector<int>(3)));
REQUIRE(!is_inside(b, make_vector<int>(4)));
}
TEST_CASE("simple_box1d_test")
{
box1d b(make_vector<double>(-1), make_vector<double>(3));
CRADLE_CHECK_ALMOST_EQUAL(get_center(b), make_vector<double>(0.5));
CRADLE_CHECK_ALMOST_EQUAL(b.corner, make_vector<double>(-1));
CRADLE_CHECK_ALMOST_EQUAL(b.size, make_vector<double>(3));
REQUIRE(!is_inside(b, make_vector<double>(-2)));
REQUIRE(is_inside(b, make_vector<double>(-1)));
REQUIRE(is_inside(b, make_vector<double>(0)));
REQUIRE(is_inside(b, make_vector<double>(1)));
REQUIRE(is_inside(b, make_vector<double>(1.5)));
REQUIRE(is_inside(b, make_vector<double>(1.9)));
REQUIRE(!is_inside(b, make_vector<double>(2)));
REQUIRE(!is_inside(b, make_vector<double>(4)));
}
TEST_CASE("simple_box2d_test")
{
box2d b(make_vector<double>(-1, -1), make_vector<double>(3, 3));
CRADLE_CHECK_ALMOST_EQUAL(area(b), 9.);
CRADLE_CHECK_ALMOST_EQUAL(get_center(b), make_vector<double>(0.5, 0.5));
CRADLE_CHECK_ALMOST_EQUAL(b.corner, make_vector<double>(-1, -1));
CRADLE_CHECK_ALMOST_EQUAL(b.size, make_vector<double>(3, 3));
REQUIRE(!is_inside(b, make_vector<double>(-2, -2)));
REQUIRE(!is_inside(b, make_vector<double>(-2, 0)));
REQUIRE(!is_inside(b, make_vector<double>(0, 4)));
REQUIRE(!is_inside(b, make_vector<double>(0, 2)));
REQUIRE(is_inside(b, make_vector<double>(-1, -1)));
REQUIRE(is_inside(b, make_vector<double>(0, 1.9)));
REQUIRE(is_inside(b, make_vector<double>(0, 0)));
REQUIRE(is_inside(b, make_vector<double>(1.5, 1.5)));
REQUIRE(is_inside(b, make_vector<double>(0, 1)));
}
TEST_CASE("box_slicing_test")
{
REQUIRE(
slice(
box3d(make_vector<double>(0, 2, 1), make_vector<double>(4, 3, 5)),
0)
== box2d(make_vector<double>(2, 1), make_vector<double>(3, 5)));
REQUIRE(
slice(
box3d(make_vector<double>(0, 2, 1), make_vector<double>(4, 3, 5)),
1)
== box2d(make_vector<double>(0, 1), make_vector<double>(4, 5)));
REQUIRE(
slice(
box3d(make_vector<double>(0, 2, 1), make_vector<double>(4, 3, 5)),
2)
== box2d(make_vector<double>(0, 2), make_vector<double>(4, 3)));
REQUIRE(
slice(box2i(make_vector<int>(0, 2), make_vector<int>(4, 3)), 0)
== box1i(make_vector<int>(2), make_vector<int>(3)));
REQUIRE(
slice(box2i(make_vector<int>(0, 2), make_vector<int>(4, 3)), 1)
== box1i(make_vector<int>(0), make_vector<int>(4)));
}
TEST_CASE("add_box_border_test")
{
REQUIRE(
add_border(
box3i(make_vector<int>(0, 2, 1), make_vector<int>(4, 3, 5)), 2)
== box3i(make_vector<int>(-2, 0, -1), make_vector<int>(8, 7, 9)));
REQUIRE(
add_border(
box3i(make_vector<int>(0, 2, 1), make_vector<int>(4, 3, 5)),
make_vector<int>(2, 1, 0))
== box3i(make_vector<int>(-2, 1, 1), make_vector<int>(8, 5, 5)));
}
TEST_CASE("simple_vector_test")
{
circle<double> c(make_vector<double>(0, 0), 1);
CRADLE_CHECK_ALMOST_EQUAL(area(c), pi);
REQUIRE(!is_inside(c, make_vector<double>(0, 2)));
REQUIRE(!is_inside(c, make_vector<double>(2, 0)));
REQUIRE(!is_inside(c, make_vector<double>(1.1, 0)));
REQUIRE(!is_inside(c, make_vector<double>(0.9, 0.9)));
REQUIRE(!is_inside(c, make_vector<double>(0, -1.1)));
REQUIRE(is_inside(c, make_vector<double>(0.9, 0)));
REQUIRE(is_inside(c, make_vector<double>(0, 0)));
REQUIRE(is_inside(c, make_vector<double>(0, -0.9)));
REQUIRE(is_inside(c, make_vector<double>(-0.7, 0.7)));
REQUIRE(is_inside(c, make_vector<double>(0.3, 0.5)));
}
TEST_CASE("off_center_test")
{
circle<double> c(make_vector<double>(4, 1), 2);
CRADLE_CHECK_ALMOST_EQUAL(area(c), 4 * pi);
REQUIRE(!is_inside(c, make_vector<double>(0, 0)));
REQUIRE(!is_inside(c, make_vector<double>(1.9, 1)));
REQUIRE(!is_inside(c, make_vector<double>(6.1, 1)));
REQUIRE(!is_inside(c, make_vector<double>(4, 3.1)));
REQUIRE(!is_inside(c, make_vector<double>(4, -1.1)));
REQUIRE(is_inside(c, make_vector<double>(4, 1)));
REQUIRE(is_inside(c, make_vector<double>(2.6, 2.4)));
}
TEST_CASE("by_value_test")
{
vector2d p0 = make_vector<double>(0, 1), p1 = make_vector<double>(4, 4);
line_segment<2, double> segment(p0, p1);
REQUIRE(segment[0] == p0);
REQUIRE(segment[1] == p1);
CRADLE_CHECK_ALMOST_EQUAL(length(segment), 5.);
}
TEST_CASE("identity_matrix_test")
{
REQUIRE(
(identity_matrix<4, double>())
== make_matrix<double>(
1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1));
REQUIRE(
(identity_matrix<3, double>())
== make_matrix<double>(1, 0, 0, 0, 1, 0, 0, 0, 1));
}
TEST_CASE("matrix_operations_test")
{
matrix<3, 3, double> m, i = identity_matrix<3, double>();
m = i - 2 * i;
REQUIRE(m == make_matrix<double>(-1, 0, 0, 0, -1, 0, 0, 0, -1));
m *= 2;
REQUIRE(m == make_matrix<double>(-2, 0, 0, 0, -2, 0, 0, 0, -2));
m = i;
m /= 2;
REQUIRE(m == make_matrix<double>(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5));
m += i * 3;
REQUIRE(m == make_matrix<double>(3.5, 0, 0, 0, 3.5, 0, 0, 0, 3.5));
m -= 2 * i;
REQUIRE(m == make_matrix<double>(1.5, 0, 0, 0, 1.5, 0, 0, 0, 1.5));
REQUIRE(m == m);
REQUIRE(m != i);
}
TEST_CASE("matrix_conversion_test")
{
matrix<3, 3, double> m(identity_matrix<3, float>());
}
TEST_CASE("matrix_inverse3_test")
{
matrix<4, 4, double> m
= translation(make_vector<double>(4, 3, 7))
* scaling_transformation(make_vector<double>(.1, 2, 1.2))
* rotation_about_x(angle<double, degrees>(90));
matrix<4, 4, double> inv_m = inverse(m);
CRADLE_CHECK_ALMOST_EQUAL(
transform_point(
inv_m, transform_point(m, make_vector<double>(0, 0, 0))),
make_vector<double>(0, 0, 0));
CRADLE_CHECK_ALMOST_EQUAL(
transform_point(
inv_m, transform_point(m, make_vector<double>(2, 1, 7))),
make_vector<double>(2, 1, 7));
CRADLE_CHECK_ALMOST_EQUAL(
transform_point(
inv_m, transform_point(m, make_vector<double>(1, 0, 17))),
make_vector<double>(1, 0, 17));
}
TEST_CASE("matrix_inverse2_test")
{
matrix<3, 3, double> m
= translation(make_vector<double>(3, 7))
* scaling_transformation(make_vector<double>(.1, 1.2))
* rotation(angle<double, degrees>(90));
matrix<3, 3, double> inv_m = inverse(m);
CRADLE_CHECK_ALMOST_EQUAL(
transform_point(inv_m, transform_point(m, make_vector<double>(0, 0))),
make_vector<double>(0, 0));
CRADLE_CHECK_ALMOST_EQUAL(
transform_point(inv_m, transform_point(m, make_vector<double>(1, 7))),
make_vector<double>(1, 7));
CRADLE_CHECK_ALMOST_EQUAL(
transform_point(inv_m, transform_point(m, make_vector<double>(0, 17))),
make_vector<double>(0, 17));
}
TEST_CASE("matrix_inverse1_test")
{
matrix<2, 2, double> m = translation(make_vector<double>(1))
* scaling_transformation(make_vector<double>(.1));
matrix<2, 2, double> inv_m = inverse(m);
CRADLE_CHECK_ALMOST_EQUAL(
transform_point(inv_m, transform_point(m, make_vector<double>(0))),
make_vector<double>(0));
CRADLE_CHECK_ALMOST_EQUAL(
transform_point(inv_m, transform_point(m, make_vector<double>(7))),
make_vector<double>(7));
CRADLE_CHECK_ALMOST_EQUAL(
transform_point(inv_m, transform_point(m, make_vector<double>(17))),
make_vector<double>(17));
CRADLE_CHECK_ALMOST_EQUAL(
transform_point(inv_m, transform_point(m, make_vector<double>(1))),
make_vector<double>(1));
}
|
function qwv_2d_test02 ( )
%*****************************************************************************80
%
%% QWV_2D_TEST02 tests QWV_2D for Padua points.
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 29 May 2014
%
% Author:
%
% John Burkardt
%
a = -1.0;
b = +1.0;
c = -1.0;
d = +1.0;
fprintf ( 1, '\n' );
fprintf ( 1, 'QWV_2D_TEST02:\n' );
fprintf ( 1, ' Compute the weights associated with an interpolatory\n' );
fprintf ( 1, ' quadrature rule defined by N=(T+1)*(T+2)/2 points,\n' );
fprintf ( 1, ' exact for polynomials of total degree T or less.\n' );
fprintf ( 1, '\n' );
fprintf ( 1, ' X Interval = [%g,%g]\n', a, b );
fprintf ( 1, ' Y Interval = [%g,%g]\n', c, d );
for t = 0 : 10
n = ( ( t + 1 ) * ( t + 2 ) ) / 2;
fprintf ( 1, '\n' );
fprintf ( 1, ' Degree T = %d\n', t );
fprintf ( 1, ' Number of points N = %d\n', n );
[ x, y ] = padua_point_set ( t );
%
% Compute the weights.
%
w = qwv_2d ( t, n, a, b, c, d, x, y );
r8vec_print_16 ( n, w, ' Weights:' );
end
return
end
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl
-/
import order.chain
/-!
# Zorn's lemmas
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
This file proves several formulations of Zorn's Lemma.
## Variants
The primary statement of Zorn's lemma is `exists_maximal_of_chains_bounded`. Then it is specialized
to particular relations:
* `(≤)` with `zorn_partial_order`
* `(⊆)` with `zorn_subset`
* `(⊇)` with `zorn_superset`
Lemma names carry modifiers:
* `₀`: Quantifies over a set, as opposed to over a type.
* `_nonempty`: Doesn't ask to prove that the empty chain is bounded and lets you give an element
that will be smaller than the maximal element found (the maximal element is no smaller than any
other element, but it can also be incomparable to some).
## How-to
This file comes across as confusing to those who haven't yet used it, so here is a detailed
walkthrough:
1. Know what relation on which type/set you're looking for. See Variants above. You can discharge
some conditions to Zorn's lemma directly using a `_nonempty` variant.
2. Write down the definition of your type/set, put a `suffices : ∃ m, ∀ a, m ≺ a → a ≺ m, { ... },`
(or whatever you actually need) followed by a `apply some_version_of_zorn`.
3. Fill in the details. This is where you start talking about chains.
A typical proof using Zorn could look like this
```lean
lemma zorny_lemma : zorny_statement :=
begin
let s : set α := {x | whatever x},
suffices : ∃ x ∈ s, ∀ y ∈ s, y ⊆ x → y = x, -- or with another operator
{ exact proof_post_zorn },
apply zorn_subset, -- or another variant
rintro c hcs hc,
obtain rfl | hcnemp := c.eq_empty_or_nonempty, -- you might need to disjunct on c empty or not
{ exact ⟨edge_case_construction,
proof_that_edge_case_construction_respects_whatever,
proof_that_edge_case_construction_contains_all_stuff_in_c⟩ },
exact ⟨construction,
proof_that_construction_respects_whatever,
proof_that_construction_contains_all_stuff_in_c⟩,
end
```
## Notes
Originally ported from Isabelle/HOL. The
[original file](https://isabelle.in.tum.de/dist/library/HOL/HOL/Zorn.html) was written by Jacques D.
Fleuriot, Tobias Nipkow, Christian Sternagel.
-/
open classical set
variables {α β : Type*} {r : α → α → Prop} {c : set α}
local infix ` ≺ `:50 := r
/-- **Zorn's lemma**
If every chain has an upper bound, then there exists a maximal element. -/
lemma exists_maximal_of_chains_bounded (h : ∀ c, is_chain r c → ∃ ub, ∀ a ∈ c, a ≺ ub)
(trans : ∀ {a b c}, a ≺ b → b ≺ c → a ≺ c) :
∃ m, ∀ a, m ≺ a → a ≺ m :=
have ∃ ub, ∀ a ∈ max_chain r, a ≺ ub,
from h _ $ max_chain_spec.left,
let ⟨ub, (hub : ∀ a ∈ max_chain r, a ≺ ub)⟩ := this in
⟨ub, λ a ha,
have is_chain r (insert a $ max_chain r),
from max_chain_spec.1.insert $ λ b hb _, or.inr $ trans (hub b hb) ha,
hub a $ by { rw max_chain_spec.right this (subset_insert _ _), exact mem_insert _ _ }⟩
/-- A variant of Zorn's lemma. If every nonempty chain of a nonempty type has an upper bound, then
there is a maximal element.
-/
theorem exists_maximal_of_nonempty_chains_bounded [nonempty α]
(h : ∀ c, is_chain r c → c.nonempty → ∃ ub, ∀ a ∈ c, a ≺ ub)
(trans : ∀ {a b c}, a ≺ b → b ≺ c → a ≺ c) :
∃ m, ∀ a, m ≺ a → a ≺ m :=
exists_maximal_of_chains_bounded
(λ c hc,
(eq_empty_or_nonempty c).elim
(λ h, ⟨classical.arbitrary α, λ x hx, (h ▸ hx : x ∈ (∅ : set α)).elim⟩)
(h c hc))
(λ a b c, trans)
section preorder
variables [preorder α]
theorem zorn_preorder (h : ∀ c : set α, is_chain (≤) c → bdd_above c) :
∃ m : α, ∀ a, m ≤ a → a ≤ m :=
exists_maximal_of_chains_bounded h (λ a b c, le_trans)
theorem zorn_nonempty_preorder [nonempty α]
(h : ∀ (c : set α), is_chain (≤) c → c.nonempty → bdd_above c) :
∃ (m : α), ∀ a, m ≤ a → a ≤ m :=
exists_maximal_of_nonempty_chains_bounded h (λ a b c, le_trans)
theorem zorn_preorder₀ (s : set α)
(ih : ∀ c ⊆ s, is_chain (≤) c → ∃ ub ∈ s, ∀ z ∈ c, z ≤ ub) :
∃ m ∈ s, ∀ z ∈ s, m ≤ z → z ≤ m :=
let ⟨⟨m, hms⟩, h⟩ := @zorn_preorder s _
(λ c hc,
let ⟨ub, hubs, hub⟩ := ih (subtype.val '' c) (λ _ ⟨⟨x, hx⟩, _, h⟩, h ▸ hx)
(by { rintro _ ⟨p, hpc, rfl⟩ _ ⟨q, hqc, rfl⟩ hpq;
refine hc hpc hqc (λ t, hpq (subtype.ext_iff.1 t)) })
in ⟨⟨ub, hubs⟩, λ ⟨y, hy⟩ hc, hub _ ⟨_, hc, rfl⟩⟩)
in ⟨m, hms, λ z hzs hmz, h ⟨z, hzs⟩ hmz⟩
theorem zorn_nonempty_preorder₀ (s : set α)
(ih : ∀ c ⊆ s, is_chain (≤) c → ∀ y ∈ c, ∃ ub ∈ s, ∀ z ∈ c, z ≤ ub) (x : α) (hxs : x ∈ s) :
∃ m ∈ s, x ≤ m ∧ ∀ z ∈ s, m ≤ z → z ≤ m :=
begin
rcases zorn_preorder₀ {y ∈ s | x ≤ y} (λ c hcs hc, _) with ⟨m, ⟨hms, hxm⟩, hm⟩,
{ exact ⟨m, hms, hxm, λ z hzs hmz, hm _ ⟨hzs, (hxm.trans hmz)⟩ hmz⟩ },
{ rcases c.eq_empty_or_nonempty with rfl|⟨y, hy⟩,
{ exact ⟨x, ⟨hxs, le_rfl⟩, λ z, false.elim⟩ },
{ rcases ih c (λ z hz, (hcs hz).1) hc y hy with ⟨z, hzs, hz⟩,
exact ⟨z, ⟨hzs, (hcs hy).2.trans $ hz _ hy⟩, hz⟩ } }
end
lemma zorn_nonempty_Ici₀ (a : α)
(ih : ∀ c ⊆ Ici a, is_chain (≤) c → ∀ y ∈ c, ∃ ub, a ≤ ub ∧ ∀ z ∈ c, z ≤ ub) (x : α)
(hax : a ≤ x) :
∃ m, x ≤ m ∧ ∀ z, m ≤ z → z ≤ m :=
let ⟨m, hma, hxm, hm⟩ := zorn_nonempty_preorder₀ (Ici a) (by simpa using ih) x hax in
⟨m, hxm, λ z hmz, hm _ (hax.trans $ hxm.trans hmz) hmz⟩
end preorder
section partial_order
variables [partial_order α]
lemma zorn_partial_order (h : ∀ c : set α, is_chain (≤) c → bdd_above c) :
∃ m : α, ∀ a, m ≤ a → a = m :=
let ⟨m, hm⟩ := zorn_preorder h in ⟨m, λ a ha, le_antisymm (hm a ha) ha⟩
theorem zorn_nonempty_partial_order [nonempty α]
(h : ∀ (c : set α), is_chain (≤) c → c.nonempty → bdd_above c) :
∃ (m : α), ∀ a, m ≤ a → a = m :=
let ⟨m, hm⟩ := zorn_nonempty_preorder h in ⟨m, λ a ha, le_antisymm (hm a ha) ha⟩
theorem zorn_partial_order₀ (s : set α)
(ih : ∀ c ⊆ s, is_chain (≤) c → ∃ ub ∈ s, ∀ z ∈ c, z ≤ ub) :
∃ m ∈ s, ∀ z ∈ s, m ≤ z → z = m :=
let ⟨m, hms, hm⟩ := zorn_preorder₀ s ih in ⟨m, hms, λ z hzs hmz, (hm z hzs hmz).antisymm hmz⟩
lemma zorn_nonempty_partial_order₀ (s : set α)
(ih : ∀ c ⊆ s, is_chain (≤) c → ∀ y ∈ c, ∃ ub ∈ s, ∀ z ∈ c, z ≤ ub) (x : α) (hxs : x ∈ s) :
∃ m ∈ s, x ≤ m ∧ ∀ z ∈ s, m ≤ z → z = m :=
let ⟨m, hms, hxm, hm⟩ := zorn_nonempty_preorder₀ s ih x hxs
in ⟨m, hms, hxm, λ z hzs hmz, (hm z hzs hmz).antisymm hmz⟩
end partial_order
lemma zorn_subset (S : set (set α)) (h : ∀ c ⊆ S, is_chain (⊆) c → ∃ ub ∈ S, ∀ s ∈ c, s ⊆ ub) :
∃ m ∈ S, ∀ a ∈ S, m ⊆ a → a = m :=
zorn_partial_order₀ S h
lemma zorn_subset_nonempty (S : set (set α))
(H : ∀ c ⊆ S, is_chain (⊆) c → c.nonempty → ∃ ub ∈ S, ∀ s ∈ c, s ⊆ ub) (x) (hx : x ∈ S) :
∃ m ∈ S, x ⊆ m ∧ ∀ a ∈ S, m ⊆ a → a = m :=
zorn_nonempty_partial_order₀ _ (λ c cS hc y yc, H _ cS hc ⟨y, yc⟩) _ hx
lemma zorn_superset (S : set (set α))
(h : ∀ c ⊆ S, is_chain (⊆) c → ∃ lb ∈ S, ∀ s ∈ c, lb ⊆ s) :
∃ m ∈ S, ∀ a ∈ S, a ⊆ m → a = m :=
@zorn_partial_order₀ (set α)ᵒᵈ _ S $ λ c cS hc, h c cS hc.symm
lemma zorn_superset_nonempty (S : set (set α))
(H : ∀ c ⊆ S, is_chain (⊆) c → c.nonempty → ∃ lb ∈ S, ∀ s ∈ c, lb ⊆ s) (x) (hx : x ∈ S) :
∃ m ∈ S, m ⊆ x ∧ ∀ a ∈ S, a ⊆ m → a = m :=
@zorn_nonempty_partial_order₀ (set α)ᵒᵈ _ S (λ c cS hc y yc, H _ cS hc.symm ⟨y, yc⟩) _ hx
/-- Every chain is contained in a maximal chain. This generalizes Hausdorff's maximality principle.
-/
lemma is_chain.exists_max_chain (hc : is_chain r c) : ∃ M, @is_max_chain _ r M ∧ c ⊆ M :=
begin
obtain ⟨M, ⟨_, hM₀⟩, hM₁, hM₂⟩ :=
zorn_subset_nonempty {s | c ⊆ s ∧ is_chain r s} _ c ⟨subset.rfl, hc⟩,
{ exact ⟨M, ⟨hM₀, λ d hd hMd, (hM₂ _ ⟨hM₁.trans hMd, hd⟩ hMd).symm⟩, hM₁⟩ },
rintros cs hcs₀ hcs₁ ⟨s, hs⟩,
refine ⟨⋃₀ cs, ⟨λ _ ha, set.mem_sUnion_of_mem ((hcs₀ hs).left ha) hs, _⟩,
λ _, set.subset_sUnion_of_mem⟩,
rintros y ⟨sy, hsy, hysy⟩ z ⟨sz, hsz, hzsz⟩ hyz,
obtain rfl | hsseq := eq_or_ne sy sz,
{ exact (hcs₀ hsy).right hysy hzsz hyz },
cases hcs₁ hsy hsz hsseq with h h,
{ exact (hcs₀ hsz).right (h hysy) hzsz hyz },
{ exact (hcs₀ hsy).right hysy (h hzsz) hyz }
end
|
"
Последовательно выполнить операции:
sqrt(2)*sqrt(2)
(sqrt(2)*sqrt(2))-2
Объяснить полученный результат.
"
result <- sqrt(2)*sqrt(2)
print(result)
result1 <- (sqrt(2)*sqrt(2))-2
print(result1)
|
\section{An Example of an Example}
You can also have examples in your document such as in example~\ref{ex:simple_example}.
\begin{example}{An Example of an Example}
\label{ex:simple_example}
Here is an example with some math
\begin{equation}
0 = \exp(i\pi)+1\ .
\end{equation}
You can adjust the colour and the line width in the {\tt macros.tex} file.
\end{example} |
function xval = r8vec_even_select ( n, xlo, xhi, ival )
%*****************************************************************************80
%
%% R8VEC_EVEN_SELECT returns the I-th of N evenly spaced values in [ XLO, XHI ].
%
% Discussion:
%
% XVAL = ( (N-IVAL) * XLO + (IVAL-1) * XHI ) / dble ( N - 1 )
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 29 November 2004
%
% Author:
%
% John Burkardt
%
% Parameters:
%
% Input, integer N, the number of values.
%
% Input, real XLO, XHI, the low and high values.
%
% Input, integer IVAL, the index of the desired point.
% IVAL is normally between 1 and N, but may be any
% integer value.
%
% Output, real XVAL, the IVAL-th of N evenly spaced values
% between XLO and XHI.
%
% Unless N = 1, X(1) = XLO and X(N) = XHI.
%
% If N = 1, then X(1) = 0.5*(XLO+XHI).
%
if ( n == 1 )
xval = 0.5 * ( xlo + xhi );
else
xval = ( ( n - ival ) * xlo ...
+ ( ival - 1 ) * xhi ) ...
/ ( n - 1 );
end
return
end
|
%% RRT*FN Toolbox
% *RRT*FN Toolbox* for solving path/motion planning problems.
% Toolbox provides *RRT*, *RRT** and *RRT*FN* for solving various problems
% (e.g. 2D mobile robot, planar redundant manipulator)
%
% Sampling-based motion planning algorithms got a lot of research attention
% in past decade or so. The main reason of the popularity is an ability
% to solve relatively easy motion planning problems of 2D mobile robot
% as well as hard high dimensional problems both.
%
% *Rapidly-Exporing Random Tree (RRT)* is sampling-based algorithm, solves
% the problem of motion and path planning providing feasible solutions
% however it does not take into account optimality of the solution.
%
% <<rrt_pseudocode.png>>
%
% *RRT** is probabilistically optimal variant of RRT which converges to the
% optimal solution asymtotically. Due to the fact that RRT* takes cost of
% the path into consideration, the computational diffuculty increases with
% each node added to tree, a good example of this problem is finding
% neighbors.
%
% <<rrt_star_pseudocode.png>>
%
% <<rrt_star_pseudocode_1.png>>
%
% *RRT*FN (Fixed Nodes)* is a memory efficient variant of RRT*. It
% inherents all the optimization features of RRT*, but in contrast using
% limited number of nodes i.e. memory is limited.
%
% <<rrt_star_fn_pseudocode.png>>
%
%%
%
% <<rrts_comparison.png>>
%%
% <html><body><table style="border: 2px solid orange;"><tr>
% <td style="font-size:12pt;">Please do not change anything in rrt.m,
% rrt_star.m and rrt_star_fn.m files unless it is a bug. <br/>Everything
% you want to add (e.g. new function or modifications of a model)
% please do it creating/editing classes for models.
% e.g. <strong>FNSimple2D.m</strong> or
% <strong>FNRedundantManipulator.m</strong>
% </td></tr></table></body></html>
% |
# TODO: do bit hacking to make Clongdouble into Cdouble and do math with that (for now)
|
\subsection{Algebraic dual spaces}\label{subsec:algebraic_dual_spaces}
\begin{definition}\label{def:dual_vector_space}\mcite[50]{Knapp2016BasicAlgebra}
Let \( V \) be a \hyperref[def:vector_space]{vector space} over the \hyperref[def:field]{field} \( \BbbK \). By \fullref{thm:functions_over_algebra}, the set \( \hom(V, \BbbK) \) of all \hyperref[def:semimodule/homomorphism]{linear maps} from \( V \) to the underlying field \( \BbbK \) also form a vector space over \( \BbbK \).
We call this space the \term{algebraic dual space} of \( V \) and denote it by \( V^* \). We call the functions in \( V^* \) \term{linear functionals}. The prefix \enquote{algebraic} is important when confusion is possible with \hyperref[def:continuous_dual_space]{continuous dual spaces}.
\end{definition}
\begin{remark}\label{rem:functional}
The term \enquote{functional} as a noun has no definite meaning.
\begin{itemize}
\item In the context of linear algebra, and in particular \fullref{def:dual_vector_space}, the term \enquote{functional} refers to \enquote{linear functional}, i.e. a \hyperref[def:semimodule/homomorphism]{linear map} from a \hyperref[def:vector_space]{vector space} to its base field.
This terminology can be found, for example, in \cite[50]{Knapp2016BasicAlgebra} and \cite[sec. 26.1]{Тыртышников2004Лекции}.
\item In the context of functional analysis, \enquote{linear functional} may refer to either \hyperref[def:continuous_dual_space]{continuous linear functionals} from some \hyperref[def:topological_vector_space]{topological vector space} to its base field, or to arbitrary linear functionals.
This terminology can be found, for example, in \cite[def. 3.1]{Rudin1991Functional} and \cite[sec. 1.3]{Clarke2013}.
An arbitrary map from a topological vector space to its field may also be called a functional --- for example, \cite[102]{KufnerFucik1980} and \cite[223]{Deimling1985} refer to \enquote{nonlinear functionals}. \hyperref[def:minkowski_functional]{Minkowski functionals} are notoriously nonlinear.
\item In the context of recursive functions, for example in \cite{StanfordPlato:recursive_functions}, functionals are defined as \enquote{operations which map one or more functions of type \( \BbbN^k \to \BbbN \) (possibly of different arities) to other functions}.
\end{itemize}
The commonality between linear algebra and functional analysis is that \enquote{functional} refers to a map from a vector space to its base field. The commonality between functional analysis and logic is that \enquote{functional} refers to a map acting on a set of functions.
\end{remark}
\begin{definition}\label{def:duality_pairing}\mimprovised
A \term{duality pairing} \( \inprod \anon \anon: U \times V \to \BbbK \) is a \hyperref[def:multilinear_function]{bilinear function}.
such that, if \( \inprod u v = 0 \) for all \( u \), then \( v = 0 \).
\end{definition}
\begin{definition}\label{thm:natural_duality_pairing}
Given a vector space \( V \), the following function is \hyperref[def:multilinear_function]{bilinear}:
\begin{equation*}
\begin{aligned}
&\inprod \cdot \cdot: V^* \times X \to \BbbK \\
&\inprod {x^*} x \mapsto x^*(x).
\end{aligned}
\end{equation*}
\end{definition}
\begin{proposition}\label{thm:algebraic_dual_basis}
Fix a \hyperref[def:vector_space]{vector space} \( V \) over \( \BbbK \) and a \hyperref[def:hamel_basis]{basis} \( B \) of \( V \). For every basis vector \( e \), the \term{projection functional} \( \pi_e: V \to \BbbK \), defined in \fullref{def:basis_decomposition}, maps an arbitrary vector \( v \) to its \( e \)-th coordinate.
\begin{thmenum}
\thmitem{thm:algebraic_dual_basis/independent} Given basis vectors \( x \) and \( y \) from \( B \), \( \pi_x \) and \( \pi_y \) are \hyperref[def:linear_dependence]{linearly independent} in \( V^* \).
\thmitem{thm:algebraic_dual_basis/finite} Furthermore, if \( e_1, \ldots, e_n \) is a basis of \( V \), then \( \pi_{e_1}, \ldots, \pi_{e_n} \) is a basis for the \hyperref[def:dual_vector_space]{dual space} \( V^* \).
\thmitem{thm:algebraic_dual_basis/infinite} The set \( \set{ \pi_e \given e \in B } \) spans \( V^* \) if and only if \( V \) is finite dimensional.
\end{thmenum}
\end{proposition}
\begin{proof}
\SubProofOf{thm:algebraic_dual_basis/independent} Let \( t_x \) and \( t_y \) be scalars such that
\begin{equation*}
t_x \pi_x + t_y \pi_y = 0_V.
\end{equation*}
Then
\begin{equation*}
0 = t_x \pi_x(x) + t_y \pi_y(x) = t_x \cdot 1 + t_y \cdot 0.
\end{equation*}
Analogously, \( t_y = 0 \). Therefore, the functionals \( \pi_x \) and \( \pi_y \) are linearly independent.
\SubProofOf{thm:algebraic_dual_basis/finite} Let \( l \) be an arbitrary linear functional. Then
\begin{equation*}
l(y)
\end{equation*}
\SubProofOf{thm:algebraic_dual_basis/infinite}
\end{proof}
\begin{proposition}\label{def:double_dual_canonical_embedding}
Fix a vector space \( V \). We define the canonical embedding into the double dual \( V^{**} \) of \( V \) by
\begin{balign*}
& \Phi: V \to V^{**} \\
& \Phi(x) \coloneqq (\varphi \mapsto \varphi(x)),
\end{balign*}
where \( \varphi \in V^* \).
\end{proposition}
\begin{proposition}\label{thm:finite_dimensional_dual_space_is_isomorphic}
The dual vector space of a finite-dimensional vector space has the same dimension.
\end{proposition}
\begin{proof}
Let \( V \) be an \( n \)-dimensional vector space over \( F \) and let \( B \) be a basis of \( V \). For each \( b \in B \), define its dual vector on \( V^* \) as the linear \hyperref[thm:quotient_module_universal_property]{extension} of the functions
\begin{balign*}
& \varphi: B \to F \\
& \varphi(x) \coloneqq \begin{cases}
1, & x = b \\
0, & x \neq b
\end{cases}
\end{balign*}
from the basis to the whole space. Denote the dual basis vector of \( b \) by \( b^* \).
We will now show that the set \( B^* \coloneqq \{ b^* \colon b \in B \} \) forms a basis of \( V^* \).
Fix \( x^* \in V^* \). Define
\begin{equation*}
y^* \coloneqq \sum_{b \in B} x^*(b) b^*.
\end{equation*}
The linear functions \( x^* \) and \( y^* \) evidently agree on the basis \( B \). Hence, they agree on the whole space.
Hence, \( B^* \) is a basis of \( V^* \). Note that it has the same cardinality as the basis of \( B \).
\end{proof}
\begin{remark}\label{rem:finite_dimensional_dual_space_isomorphism}
By \fullref{thm:finite_dimensional_spaces_are_isomorphic}, the vector space \( F^n \) is isomorphic to its dual \( {F^n}^* \).
In practice, it is sometimes useful to distinguish between vectors and functionals. This is why we regard functionals as either
\begin{itemize}
\item functions
\item column vectors
\item row vectors
\end{itemize}
depending on what interpretation suits us best.
This is consistent with \fullref{thm:matrix_and_linear_function_algebras}, where we regard linear operators as matrices that act on vectors by multiplication.
For example, if we have the \hyperref[def:differentiability]{differentiable} function \( f(x, y) = xy \), we can regard its gradient at the point \( (\overline x, \overline y) \) as the row vector
\begin{balign*}
f'(\overline x, \overline y) =
\begin{pmatrix}
\overline y & \overline x
\end{pmatrix}.
\end{balign*}
This is a linear functional that can acts on regular (column) vector by multiplying them from the left.
\end{remark}
\begin{definition}\label{def:dual_linear_operator}
We define the \term{dual linear operator} of \( L: U \to V \) as
\begin{balign*}
& L^*: V^* \to U^* \\
& L^*(v^*) \coloneqq v^* \circ L.
\end{balign*}
\end{definition}
\begin{definition}\label{def:vector_space_annihilator}\mcite[52]{Knapp2016BasicAlgebra}
Fix a subset \( S \subseteq V \) of a vector space \( V \) over \( F \). We define the \term{annihilator} of \( S \) as the vector space of functionals
\begin{equation*}
\op{ann}(S) \coloneqq \{ x^* \in V^* \colon x^*(x) = 0_F \quad\forall x \in S \}.
\end{equation*}
\end{definition}
|
/* poly/demo.c
*
* Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Brian Gough
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <stdio.h>
#include <gsl/gsl_poly.h>
int
main ()
{
int i;
double a[6] = { -1, 0, 0, 0, 0, 1 }; /* P(x) = x^5 - 1 */
double z[10];
gsl_poly_complex_workspace * w = gsl_poly_complex_workspace_alloc (6) ;
gsl_poly_complex_solve (a, 6, w, z) ;
gsl_poly_complex_workspace_free (w) ;
for (i = 0; i < 5 ; i++)
{
printf("z%d = %+.18f %+.18f\n", i, z[2*i], z[2*i+1]) ;
}
}
|
import System.Concurrency.Channels
data Message = Add Nat Nat
data MessagePID = MkMessage PID
data ProcState = Ready | Sent | Looping
data Process : Type -> ProcState -> ProcState -> Type where
Request : MessagePID -> Message -> Process Nat st st
Respond : ((msg : Message) -> Process Nat Ready Ready) ->
Process (Maybe Message) st Sent
Spawn : Process () Ready Looping ->
Process (Maybe MessagePID) st st
Loop : Inf (Process a Ready Looping) ->
Process a Sent Looping
Action : IO a -> Process a st st
Pure : a -> Process a st st
(>>=) : Process a st1 st2 -> (a -> Process b st2 st3) ->
Process b st1 st3
public export
data Fuel = Dry | More (Lazy Fuel)
export partial
forever : Fuel
forever = More forever
total
run : Fuel -> Process t in_state out_state -> IO (Maybe t)
run fuel (Request (MkMessage process) msg)
= do Just chan <- connect process
| _ => pure Nothing
ok <- unsafeSend chan msg
if ok then do Just x <- unsafeRecv Nat chan
| Nothing => pure Nothing
pure (Just x)
else pure Nothing
run fuel (Respond f)
= do Just sender <- listen 1
| Nothing => pure (Just Nothing)
Just msg <- unsafeRecv Message sender
| Nothing => pure (Just Nothing)
Just res <- run fuel (f msg)
| Nothing => pure Nothing
unsafeSend sender res
pure (Just (Just msg))
run (More fuel) (Loop proc) = run fuel proc
run fuel (Spawn proc) = do Just pid <- spawn (do run fuel proc
pure ())
| Nothing => pure (Just Nothing)
pure (Just (Just (MkMessage pid)))
run fuel (Action act) = do res <- act
pure (Just res)
run fuel (Pure val) = pure (Just val)
run fuel (act >>= next) = do Just x <- run fuel act
| Nothing => pure Nothing
run fuel (next x)
run Dry _ = pure Nothing
Service : Type -> Type
Service a = Process a Ready Looping
Client : Type -> Type
Client a = Process a Ready Ready
{-
procAdder_bad1 : Process () Ready Looping
procAdder_bad1 = do Action (putStrLn "I'm out of the office today")
Loop procAdder_bad1
procAdder_bad2 : Process () Ready Looping
procAdder_bad2 = Loop procAdder_bad2
-}
procAdder : Service ()
procAdder = do Respond (\msg => case msg of
Add x y => Pure (x + y))
Loop procAdder
procMain : Client ()
procMain = do Just adder_id <- Spawn procAdder
| Nothing => Action (putStrLn "Spawn failed")
answer <- Request adder_id (Add 2 3)
Action (printLn answer)
partial
runProc : Process () in_state out_state -> IO ()
runProc proc = do run forever proc
pure ()
main : IO ()
main = runProc procMain
|
[STATEMENT]
lemma assign_r_alt_def:
fixes x :: "('a \<Longrightarrow> '\<alpha>)"
shows "x := v = II\<lbrakk>\<lceil>v\<rceil>\<^sub></$x\<rbrakk>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. x := v = II\<lbrakk>\<lceil>v\<rceil>\<^sub></$x\<rbrakk>
[PROOF STEP]
by (rel_auto) |
\documentclass{article}
\usepackage{hyperref}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{hyperref}
\usepackage[section]{placeins}
\hypersetup{
colorlinks,
citecolor=black,
filecolor=black,
linkcolor=black,
urlcolor=blue
}
%\input{../Comments}
\begin{document}
\title{\textbf{SE 3XA3: Development Plan\\CraftMaster}}
\author{\textbf{Group Number: }307\\
\textbf{Group Name: }3 Craftsmen \\
\textbf{Members: }\\
Hongqing Cao 400053625\\
Sida Wang 400072157\\
Weidong Yang 400065354}
\date{}
\maketitle
\thispagestyle{empty}
\newpage
\pagenumbering{roman}
\tableofcontents
\listoftables
\listoffigures
\newpage
\FloatBarrier
\begin{table}
\begin{tabularx}{\textwidth}{llX}
\toprule
\textbf{Date} & \textbf{Editor(s)} & \textbf{Change}\\
\midrule
Jan 27 & Hongqing & Added team information\\
Jan 30 & All & Discussed about the content\\
Jan 30 & Sida Wang & Finished the content of all parts according to the discussion\\
Feb 11 & Hongqing & Renamed the project name \\
Mar 15 & Sida & Finished the refinement for Revision 1\\
Mar 19 & Sida & Fixed a minor error\\
\bottomrule
\end{tabularx}
\caption{\textbf{Revision History}} \label{TblRevisionHistory}
\end{table}
\FloatBarrier
\newpage
\pagenumbering{arabic}
\section{Team Meeting Plan}
Meetings will primarily be held twice a week in the lab room according to the lab schedule. Additional meetings will be held in Thode Library at any time when necessary.
\begin{itemize}
\item \textbf{Monday} 12:30 - 14:20, ITB 236
\item \textbf{Thursday} 12:30 - 14:20, ITB 236
\item Occasionally, Thode Library 1st Floor
\end{itemize}
\subsection{Roles}
\textbf{Chair:} Weidong Yang\\
Responsible for selecting topics and creating the meeting agenda. \\\\
\textbf{Timekeeper:} Hongqing Cao\\
Responsible for ensuring the meeting starts and ends on time and keeping the distribution of time on each topic balanced.\\\\
\textbf{Notetaker:} Sida Wang\\
Responsible for recording valuable information and summarizing the meetings.\\
\subsection{Rules For Agenda}
\textbf{Pre-meeting:}
\begin{itemize}
\item The chair will create an agenda sheet for a specific meeting including general topics, activities, and questions to be discussed. Other team members should preview the agenda sheet before the meeting.
\item An item checklist may be produced by the chair when multiple topics are to be discussed.
\item Any absence for meetings should be reported before the meeting starts.
\end{itemize}
\textbf{During meeting:}
\begin{itemize}
\item The timekeeper should ensure that the meeting starts and ends on time.
\item The chair will record the attendance of each member at the beginning of the meeting.
\item The meeting will start with a review of the agenda sheet. This will ensure that all team members are fully prepared.
\item The meeting will end with a review of the meeting's effectiveness. Each team member should give at least one piece of advice on how to improve the effectiveness of the next meeting. The notetaker will summarize the meeting at the end.
\end{itemize}
\section{Team Communication Plan}
\begin{itemize}
\item \textbf{Facebook Messenger} group chat will be used for internal communications including inquiries, the share of resources, and discussion.
\item \textbf{Gitlab} will be the main tool for communications of development changes and updates.
\end{itemize}
\section{Team Member Roles}
\FloatBarrier
\begin{table}[hbt!]
\centering
\begin{tabular}{ |c|l| } \hline
\textbf{Team Member} & \textbf{Role(s)}\\\hline
Weidong Yang & Software Developer, Tester, Team Leader, Pyglet \& Algorithm Expert\\\hline
Hongqing Cao & Software Developer, Tester, LaTex \& Documentation Expert\\\hline
Sida Wang & Software Developer, Tester, Scribe, Git Project Manager\\\hline
\end{tabular}
\caption{\textbf{Team Member Roles}}
\end{table}
\FloatBarrier
\section{Git Workflow Plan}
\subsection{Overview}
The \textbf{Git Master and Feature Branch} will be used to manage the software development. One team member will create his/her local branch and work on it. This workflow allows different modules to be developed and tested in each team member's localized branch and do not cause conflicts. Sida will be responsible for the git master controls and will ensure all the files are completed and tagged before the deadline.
\subsection{Millstones with Gitlab Tags}
\FloatBarrier
\begin{table}[hbt!]
\centering
\begin{tabular}{ |c|c|c| } \hline
\textbf{Milestones} & \textbf{Deadline} & \textbf{Tag}\\\hline
Requirements Document Draft & February 7 & SRS-Rev.0 \\\hline
Proof of Concept Demonstration & February 13 & N/A\\\hline
Test Plan Draft & February 28 & TP-Rev0 \\\hline
Revision 0 Design and Documentation & March 13 & DD-Rev0 \\\hline
Revision 0 Demonstration & March 19 & N/A \\\hline
Revision 1 Demonstration & April 2 & N/A \\\hline
Revision 1 Design and Documentation & April 6 & DD-Rev1 \\\hline
\end{tabular}
\caption{\textbf{Millstones and Gitlab Tags}}
\end{table}
\FloatBarrier
\section{Proof of Concept Demonstration Plan}
\subsection{Scope and Feasibility}
The original project is implemented using Python within one module. To optimize modularity, our reimplementation will follow the software architecture MVC(Model, View, Controller) model. Since Python is an object-oriented programming language, the modular design is feasible using different classes to implement.
\subsection{Potential Challenges and Risks}
The hardest part of the reimplementation will be adding new categories of blocks. In the original project, all blocks are static and have no other interactions with the player besides being built or destroyed. In our expectation, new blocks with unique properties such as Lava, which will burn the player out, will be added to the game. These new types of blocks will require more complex interactions with the player, which is difficult to implement. To mitigate this challenge, we plan to model the game blocks as objects, and to program unique algorithms to apply to different blocks. Also since the original game is using the content of Minecraft, the customization of the reimplementation heavily depends on the texture resources from the internet. The most difficult part of testing is to test the interaction between the player and the world within the game. Similar to most 3D games, it is hard to mitigate the risk of bugs using traditional testing methods. To make the game stable and enjoyable, our testing team will dynamically test the game by spending a significant amount of time playing it.
\subsection{Software Resources}
The Pyglet package provides cross-platform windowing and multimedia library. With Pyglet, visually rich small games can be feasible to build. Pytest provides powerful unit testing and functional testing but does not fully support solutions to integration testing. All the libraries using by this project will be easily installed on either Windows or Linux machines. The game will be delivered as an executable file(generated by Pyinstaller) in order to optimize the portability.
\subsection{Demonstration}
The demonstration will be done on both Windows and Linux systems. On each machine, one team member will click on the icon of the executable game file and play the game. The player will travel the world for a certain distance and have some interactions between different types of blocks. The flying mode will also be activated to show its functionality. To overcome the risk of 3D bugs, edge case testings will be performed.
\section{Technology}
\begin{itemize}
\item \textbf{Programming Language: }Python
\item \textbf{Graphical User Interface: }Pyglet
\item \textbf{Testing Tools: }Pytest
\item \textbf{Documentation Tools: }Doxygen, Latex
\item \textbf{Version Control: }Gitlab
\item \textbf{Other Tools: }Pyinstaller
\end{itemize}
\section{Coding Style}
The Coding Style is \textbf{PEP-8} for this project.
\section{Project Schedule}
The project schedule can be found \href{https://gitlab.cas.mcmaster.ca/wangs132/minecraft/-/blob/master/ProjectSchedule/ProjectSchedule_3XA3_307.pdf}{\textbf{HERE}}.
\section{Project Review}
\subsection{Overview}
In general, the development process of CraftMaster was successful. All the documentations and code implementations were completed before their deadlines. Team meetings went smoothly according to the meeting plan. Feedbacks were gathered from demonstrations. Refinements on both documentations and code implementations were proposed according to the feedbacks and were completed on time. The team believes that the development process of CraftMaster is a practical experience of software project management on Gitlab. By developing this project, all team members became more familiar with the software development process and git usage.
\subsection{Open Issues}
During the development process, there were some open issues and they are listed below:
\begin{itemize}
\item Due to the time constraint, the initially proposed feature ``Dynamic Block Types" was not implemented and has been added to the ``Anticipated Changes" section in the \href{https://gitlab.cas.mcmaster.ca/wangs132/minecraft/-/blob/master/Doc/Design/MG/MG.pdf}{\bf Module Guide(MG)} for future implementation.
\item The team find it is difficult to give hardware-related specifications, such as the content of ``Hardware-Hiding Modules" in the \href{https://gitlab.cas.mcmaster.ca/wangs132/minecraft/-/blob/master/Doc/Design/MG/MG.pdf}{\bf MG}. The reason is that Pyglet leaves the hardware design concern out. By using Pyglet, the design and development team can design and build the system without knowing the hardware-related specifications. Therefore, the hardware-related specifications in all documents were poorly done.
\item The team also find that the MIS is difficult to be implemented for software games like CraftMaster. The media-related modules cannot be described by mathematical notations. For those modules, the access routines have to be described by natural language, which violates the rigour principle and increases the ambiguity of the documentation.
\end{itemize}
\subsection{Future Reference}
This section acts as a reference for further development. Since Pyglet is a high level software library and the modification on hardware controls is limited. The design team will attempt to find a better substitute that allows more freedom on the hardware controls. The anticipated changes specified in the \href{https://gitlab.cas.mcmaster.ca/wangs132/minecraft/-/blob/master/Doc/Design/MG/MG.pdf}{MG} will be the primary goal for future design. The team will also learn the Gitlab feature \textbf{Continuous Integration(CI)} and apply it to further development process.
\end{document} |
= = Compounds = =
|
# COURSE: A deep understanding of deep learning
## SECTION: Math prerequisites
### LECTURE: Derivatives: intuition and polynomials
#### TEACHER: Mike X Cohen, sincxpress.com
##### COURSE URL: udemy.com/course/dudl/?couponCode=202201
```python
import numpy as np
import matplotlib.pyplot as plt
# sympy = symbolic math in Python
import sympy as sym
import sympy.plotting.plot as symplot
```
```python
# create symbolic variables in sympy
x = sym.symbols('x')
# create a function
fx = 2*x**2
# compute its derivative
df = sym.diff(fx,x)
# print them
print(fx)
print(df)
```
```python
# plot them
symplot(fx,(x,-4,4),title='The function')
plt.show()
symplot(df,(x,-4,4),title='Its derivative')
plt.show()
```
```python
# repeat with relu and sigmoid
# create symbolic functions
relu = sym.Max(0,x)
sigmoid = 1 / (1+sym.exp(-x))
# graph the functions
p = symplot(relu,(x,-4,4),label='ReLU',show=False,line_color='blue')
p.extend( symplot(sigmoid,(x,-4,4),label='Sigmoid',show=False,line_color='red') )
p.legend = True
p.title = 'The functions'
p.show()
# graph their derivatives
p = symplot(sym.diff(relu),(x,-4,4),label='df(ReLU)',show=False,line_color='blue')
p.extend( symplot(sym.diff(sigmoid),(x,-4,4),label='df(Sigmoid)',show=False,line_color='red') )
p.legend = True
p.title = 'The derivatives'
p.show()
```
|
function beta = linearCompressibility(S,x)
% computes the linear compressibility of an elasticity tensor
%
% Description
%
% $$\beta(x) = S_{ijkk} x_i x_j$$
%
% Input
% S - elastic @complianceTensor
% x - list of @vector3d
%
% Output
% beta - linear compressibility in directions v
%
% return a function if required
if nargin == 1 || isempty(x)
beta = S2FunHarmonicSym.quadrature(@(x) linearCompressibility(S,x),'bandwidth',2,S.CS);
return
end
% compute tensor product
beta = EinsteinSum(S,[-1 -2 -3 -3],x,-1,x,-2);
|
/-
Copyright (c) 2022 Henrik Böving. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Henrik Böving, Simon Hudon
-/
import LSpec.SlimCheck.Gen
/-!
# `SampleableExt` Class
This class permits the creation samples of a given type
controlling the size of those values using the `Gen` monad`.
# `Shrinkable` Class
This class helps minimize examples by creating smaller versions of
given values.
When testing a proposition like `∀ n : ℕ, prime n → n ≤ 100`,
`SlimCheck` requires that `ℕ` have an instance of `SampleableExt` and for
`prime n` to be decidable. `SlimCheck` will then use the instance of
`SampleableExt` to generate small examples of ℕ and progressively increase
in size. For each example `n`, `prime n` is tested. If it is false,
the example will be rejected (not a test success nor a failure) and
`SlimCheck` will move on to other examples. If `prime n` is true, `n
≤ 100` will be tested. If it is false, `n` is a counter-example of `∀
n : ℕ, prime n → n ≤ 100` and the test fails. If `n ≤ 100` is true,
the test passes and `SlimCheck` moves on to trying more examples.
This is a port of the Haskell QuickCheck library.
## Main definitions
* `SampleableExt` class
* `Shrinkable` class
### `SampleableExt`
`SampleableExt` can be used in two ways. The first (and most common)
is to simply generate values of a type directly using the `Gen` monad,
if this is what you want to do then `SampleableExt.mkSelfContained` is
the way to go.
Furthermore it makes it possible to express generators for types that
do not lend themselves to introspection, such as `ℕ → ℕ`.
If we test a quantification over functions the
counter-examples cannot be shrunken or printed meaningfully.
For that purpose, `SampleableExt` provides a proxy representation
`proxy` that can be printed and shrunken as well
as interpreted (using `interp`) as an object of the right type. If you
are using it in the first way, this proxy type will simply be the type
itself and the `interp` function `id`.
### `Shrinkable
Given an example `x : α`, `Shrinkable α` gives us a way to shrink it
and suggest simpler examples.
## Shrinking
Shrinking happens when `SlimCheck` find a counter-example to a
property. It is likely that the example will be more complicated than
necessary so `SlimCheck` proceeds to shrink it as much as
possible. Although equally valid, a smaller counter-example is easier
for a user to understand and use.
The `Shrinkable` class, , has a `shrink` function so that we can use
specialized knowledge while shrinking a value. It is not responsible
for the whole shrinking process however. It only has to take one step
in the shrinking process. `SlimCheck` will repeatedly call `shrink`
until no more steps can be taken. Because `shrink` guarantees that the
size of the candidates it produces is strictly smaller than the
argument, we know that `SlimCheck` is guaranteed to terminate.
## Tags
random testing
## References
* https://hackage.haskell.org/package/QuickCheck
-/
namespace SlimCheck
open Random
/-- Given an example `x : α`, `Shrinkable α` gives us a way to shrink it
and suggest simpler examples. -/
class Shrinkable (α : Type u) extends WellFoundedRelation α where
shrink : (x : α) → List α := λ _ => []
/-- `SampleableExt` can be used in two ways. The first (and most common)
is to simply generate values of a type directly using the `Gen` monad,
if this is what you want to do then `SampleableExt.mkSelfContained` is
the way to go.
Furthermore it makes it possible to express generators for types that
do not lend themselves to introspection, such as `ℕ → ℕ`.
If we test a quantification over functions the
counter-examples cannot be shrunken or printed meaningfully.
For that purpose, `SampleableExt` provides a proxy representation
`proxy` that can be printed and shrunken as well
as interpreted (using `interp`) as an object of the right type. -/
class SampleableExt (α : Sort u) where
proxy : Type v
[proxyRepr : Repr proxy]
[shrink : Shrinkable proxy]
sample : Gen proxy
interp : proxy → α
attribute [instance] SampleableExt.proxyRepr
attribute [instance] SampleableExt.shrink
namespace SampleableExt
/-- Use to generate instance whose purpose is to simply generate values
of a type directly using the `Gen` monad -/
def mkSelfContained [Repr α] [Shrinkable α] (sample : Gen α) : SampleableExt α where
proxy := α
proxyRepr := inferInstance
shrink := inferInstance
sample := sample
interp := id
/-- First samples a proxy value and interprets it. Especially useful if
the proxy and target type are the same. -/
def interpSample (α : Type u) [SampleableExt α] : Gen α := SampleableExt.interp <$> SampleableExt.sample
end SampleableExt
section Shrinkers
/-- `Nat.shrink' n` creates a list of smaller natural numbers by
successively dividing `n` by 2 . For example, `Nat.shrink 5 = [2, 1, 0]`. -/
partial def Nat.shrink (n : Nat) : List Nat :=
if 0 < n then
let m := n / 2
let rest := shrink m
m :: rest
else
[]
instance Nat.shrinkable : Shrinkable Nat where
shrink := Nat.shrink
/-- `Fin.shrink` works like `Nat.shrink` but instead operates on `Fin`. -/
partial def Fin.shrink {n : Nat} (m : Fin n.succ) : List (Fin n.succ) :=
if 0 < m then
let m := m / 2
let rest := shrink m
m :: rest
else
[]
instance Fin.shrinkable {n : Nat} : Shrinkable (Fin n.succ) where
shrink := Fin.shrink
local instance Int_sizeOfAbs : SizeOf Int := ⟨Int.natAbs⟩
/-- `Int.shrinkable` operates like `Nat.shrinkable` but also includes the negative variants. -/
instance Int.shrinkable : Shrinkable Int where
shrink n :=
Nat.shrink n.natAbs |>.map fun x => - Int.ofNat x
instance Bool.shrinkable : Shrinkable Bool := {}
instance Char.shrinkable : Shrinkable Char := {}
instance Prod.shrinkable [shrA : Shrinkable α] [shrB : Shrinkable β] : Shrinkable (Prod α β) where
shrink := λ (fst,snd) =>
let shrink1 := shrA.shrink fst |>.map fun x => (x, snd)
let shrink2 := shrB.shrink snd |>.map fun x => (fst, x)
shrink1 ++ shrink2
end Shrinkers
section Samplers
open Gen SampleableExt
instance Nat.sampleableExt : SampleableExt Nat :=
mkSelfContained (do choose Nat 0 (← getSize))
instance Fin.sampleableExt {n : Nat} : SampleableExt (Fin (n.succ)) :=
mkSelfContained (do choose (Fin n.succ) (Fin.ofNat 0) (Fin.ofNat (← getSize)))
instance Int.sampleableExt : SampleableExt Int :=
mkSelfContained (do choose Int (-(← getSize)) (← getSize))
instance Bool.sampleableExt : SampleableExt Bool :=
mkSelfContained $ chooseAny Bool
/-- This can be specialized into customized `SampleableExt Char` instances.
The resulting instance has `1 / length` chances of making an unrestricted choice of characters
and it otherwise chooses a character from `chars` with uniform probabilities. -/
def Char.sampleable (length : Nat) (chars : List Char) : SampleableExt Char :=
mkSelfContained do
let x ← choose Nat 0 length
if x == 0 then
let n ← interpSample Nat
pure $ Char.ofNat n
else
elements chars
instance Char.sampleableDefault : SampleableExt Char :=
Char.sampleable 3 " 0123abcABC:,;`\\/".toList
instance Prod.sampleableExt {α β : Type u} [SampleableExt α] [SampleableExt β] :
SampleableExt (α × β) where
proxy := Prod (proxy α) (proxy β)
proxyRepr := inferInstance
shrink := inferInstance
sample := prodOf sample sample
interp := Prod.map interp interp
instance Prop.sampleableExt : SampleableExt Prop where
proxy := Bool
proxyRepr := inferInstance
sample := interpSample Bool
shrink := inferInstance
interp := Coe.coe
end Samplers
/-- An annotation for values that should never get shrinked. -/
def NoShrink (α : Type u) := α
namespace NoShrink
def mk (x : α) : NoShrink α := x
def get (x : NoShrink α) : α := x
instance inhabited [inst : Inhabited α] : Inhabited (NoShrink α) := inst
instance repr [inst : Repr α] : Repr (NoShrink α) := inst
instance shrinkable : Shrinkable (NoShrink α) where
shrink := λ _ => []
instance sampleableExt [SampleableExt α] [Repr α] : SampleableExt (NoShrink α) :=
SampleableExt.mkSelfContained $ (NoShrink.mk ∘ SampleableExt.interp) <$> SampleableExt.sample
end NoShrink
end SlimCheck |
Formal statement is: lemma orthogonal_scaleR [simp]: "c \<noteq> 0 \<Longrightarrow> orthogonal (c *\<^sub>R x) = orthogonal x" Informal statement is: If $c \neq 0$, then $cx$ is orthogonal to $y$ if and only if $x$ is orthogonal to $y$. |
module Circuits.Idealised.Parser
import Data.Nat
import Data.List1
import Text.Lexer
import Text.Parser
import Toolkit.Data.Whole
import Toolkit.Data.Location
import Toolkit.Text.Lexer.Run
import Toolkit.Text.Parser.Support
import Toolkit.Text.Parser.Location
import Toolkit.Text.Parser.Run
import Ref
import Circuits.Idealised.Types
import Circuits.Idealised.AST
import Circuits.Idealised.Lexer
%default total
namespace Idealised
public export
Rule : Type -> Type
Rule = Rule Unit Token
public export
RuleEmpty : Type -> Type
RuleEmpty = RuleEmpty Unit Token
export
eoi : RuleEmpty Unit
eoi = eoi isEOI
where
isEOI : Token -> Bool
isEOI EndInput = True
isEOI _ = False
namespace API
export
symbol : String -> Rule Unit
symbol str
= terminal ("Expected Symbol '" ++ str ++ "'")
(\x => case x of
Symbol s => if s == str then Just MkUnit
else Nothing
_ => Nothing)
export
nat : Rule Nat
nat = terminal "Expected nat literal"
(\x => case x of
LitNat i => Just i
_ => Nothing)
export
keyword : String -> Rule Builtin.Unit
keyword str
= terminal ("Expected Keyword '" ++ str ++ "'")
(\x => case x of
Keyword s => if s == str then Just Builtin.MkUnit
else Nothing
_ => Nothing)
export
identifier : Rule String
identifier
= terminal "Expected Identifier"
(\x => case x of
ID str => Just str
_ => Nothing)
export
name : Rule String
name = identifier
export
ref : Rule Ref
ref =
do s <- Toolkit.location
n <- name
e <- Toolkit.location
pure (MkRef (newFC s e) n)
export
gives : String -> a -> Rule a
gives s ctor
= do keyword s
pure ctor
export
inserts : Rule a -> (a -> b) -> Rule b
inserts value ctor
= do v <- value
pure (ctor v)
export
whole : Rule Whole
whole =
do n <- nat
isWhole n
where
isWhole : Nat -> RuleEmpty Whole
isWhole Z = fail "expected whole"
isWhole (S n) = pure (W (S n) ItIsSucc)
export
sFooter : Location -> Rule FileContext
sFooter s
= do symbol ")"
symbol ";"
e <- Toolkit.location
pure (newFC s e)
namespace Direction
export
direction : Rule Direction
direction = gives "input" INPUT <|> gives "output" OUTPUT
namespace Types
mutual
logic : Rule DType
logic = gives "logic" LOGIC
array : Rule DType
array
= do ty <- logic
ns <- indices
pure (arraytype ty ns)
where
index : Rule Whole
index
= do symbol "["
n <- whole
symbol "]"
pure n
indices : Rule (List1 Whole)
indices = some index
arraytype : DType -> List1 Whole -> DType
arraytype ty (x:::xs) = foldl (\ty, n => BVECT n ty) ty (x::xs)
export
type : Rule DType
type = array <|> logic
namespace Kinds
export
gateKind : Rule GateKind
gateKind = gives "nand" ANDN
<|> gives "and" AND
<|> gives "xor" XOR
<|> gives "xnor" XORN
<|> gives "ior" IOR
<|> gives "nior" IORN
<|> gives "join" JOIN
namespace Terms
portDecl : Rule (Location, Ref, Direction, DType)
portDecl
= do s <- Toolkit.location
d <- direction
t <- type
r <- ref
pure (s,r,d,t)
portList : Rule (List1 (Location,Ref, Direction, DType))
portList
= do symbol "("
ps <- sepBy1 (symbol ",") portDecl
symbol ")"
symbol ";"
pure ps
data Body = WDecl FileContext DType Ref Ref
| GInst FileContext GateKind Ref Ref Ref
| DInst FileContext Ref Ref Ref
| NInst FileContext Ref Ref
| MInst FileContext Ref Ref Ref Ref
| ISInst FileContext Ref Ref
| IEInst FileContext End Ref Ref Ref
| IPInst FileContext Nat Ref Ref Ref Ref
| ESInst FileContext Ref Ref
| Merge FileContext Ref Ref Ref
gateNot : Rule Body
gateNot
= do s <- Toolkit.location
keyword "not"
symbol "("
o <- ref
symbol ","
i <- ref
fc <- sFooter s
pure (NInst fc o i)
gateBin : Rule Body
gateBin
= do s <- Toolkit.location
k <- gateKind
symbol "("
o <- ref
symbol ","
a <- ref
symbol ","
b <- ref
fc <- sFooter s
e <- Toolkit.location
pure (GInst fc k o a b)
gateCopy : Rule Body
gateCopy
= do s <- Toolkit.location
keyword "copy"
symbol "("
o <- ref
symbol ","
a <- ref
symbol ","
b <- ref
fc <- sFooter s
pure (DInst fc o a b)
gateMux : Rule Body
gateMux
= do s <- Toolkit.location
keyword "mux"
symbol "("
o <- ref
symbol ","
c <- ref
symbol ","
a <- ref
symbol ","
b <- ref
fc <- sFooter s
pure (MInst fc o c a b)
gateMerge : Rule Body
gateMerge
= do s <- Toolkit.location
keyword "merge"
symbol "("
o <- ref
symbol ","
a <- ref
symbol ","
b <- ref
fc <- sFooter s
pure (Merge fc o a b)
gateSplit : Rule Body
gateSplit
= singletonI <|> singletonE <|> edge <|> split
where
singletonE : Rule Body
singletonE
= do s <- Toolkit.location
keyword "extract"
symbol "("
o <- ref
symbol ","
i <- ref
fc <- sFooter s
pure (ISInst fc o i)
singletonI : Rule Body
singletonI
= do s <- Toolkit.location
keyword "insert"
symbol "("
o <- ref
symbol ","
i <- ref
fc <- sFooter s
pure (ESInst fc o i)
kind : Rule End
kind = gives "first" F <|> gives "last" L
edge : Rule Body
edge
= do s <- Toolkit.location
k <- kind
symbol "("
a <- ref
symbol ","
b <- ref
symbol ","
i <- ref
fc <- sFooter s
pure (IEInst fc k a b i)
split : Rule Body
split
= do s <- Toolkit.location
keyword "index"
symbol "["
n <- nat
symbol "]"
symbol "("
a <- ref
symbol ","
b <- ref
symbol ","
x <- ref
symbol ","
y <- ref
fc <- sFooter s
pure (IPInst fc n a b x y)
wireDecl : Rule Body
wireDecl
= do s <- Toolkit.location
keyword "wire"
t <- type
keyword "as"
symbol "("
a <- ref
symbol ","
b <- ref
symbol ")"
symbol ";"
e <- Toolkit.location
pure (WDecl (newFC s e) t a b)
expr : Rule Body
expr = wireDecl
<|> gateNot
<|> gateBin
<|> gateCopy
<|> gateSplit
<|> gateMux
<|> gateSplit
<|> gateMerge
foldBody : Location
-> List Body
-> AST
foldBody l Nil
= Stop (newFC l l)
foldBody l (head :: tail)
= foldr doFold (Stop (newFC l l)) (head :: tail)
where
doFold : Body -> AST -> AST
doFold (WDecl x y z w) accum
= Wire x y z w accum
doFold (MInst v x y z w) accum
= Seq (Mux v (Var x) (Var y) (Var z) (Var w))
accum
doFold (GInst x k y z w) accum
= Seq (Gate x k (Var y) (Var z) (Var w))
accum
doFold (DInst x y z w) accum
= Seq (Dup x (Var y) (Var z) (Var w))
accum
doFold (NInst x y z) accum
= Seq (Not x (Var y) (Var z))
accum
doFold (ISInst x y z) accum
= Seq (IndexS x (Var y) (Var z))
accum
doFold (IEInst v w x y z) accum
= Seq (IndexE v w (Var x) (Var y) (Var z))
accum
doFold (IPInst u v w x y z) accum
= Seq (IndexP u v (Var w) (Var x) (Var y) (Var z))
accum
doFold (ESInst fc o i) accum
= Seq (MergeS fc (Var o) (Var i))
accum
doFold (Merge fc o a b) accum
= Seq (MergeV fc (Var o) (Var a) (Var b))
accum
foldPorts : Location
-> List1 (Location,Ref, Direction, DType)
-> AST
-> AST
foldPorts e (x:::xs) y
= foldr (\(s,r,d,t), body => Input (newFC s e) d t r body) y (x::xs)
export
design : Rule AST
design
= do keyword "module"
n <- ref
ps <- portList
b <- many expr
e <- Toolkit.location
keyword "endmodule"
symbol ";"
pure (foldPorts e ps (foldBody e b))
namespace Idealised
export
fromFile : (fname : String)
-> IO (Either (ParseError Token) AST)
fromFile fname
= case !(parseFile Idealised.Lexer design fname) of
Left err => pure (Left err)
Right ast => pure (Right (setSource fname ast))
-- [ EOF ]
|
subroutine qlI4DNS41(Y,musq,Ival0)
implicit none
include 'qlconstants.f'
c-----Implementation of Eq.~(41) of
c----- %\cite{Denner:1991qq}
c----- %\cite{Denner:1991qq}
c----- \bibitem{Denner:1991qq}
c----- A.~Denner, U.~Nierste and R.~Scharf,
c----- %``A Compact expression for the scalar one loop four point function,''
c----- Nucl.\ Phys.\ B {\bf 367}, 637 (1991).
c----- %%CITATION = NUPHA,B367,637;%%
double complex Ival0,discr,wlog(2),cln,z(2),k(4,4),lnsum,
. qlLi2omprod,a,b,c,d,bsq,fourac
double precision musq,Y(4,4),iep
integer i,j
do i=1,4
do j=1,4
k(i,j)=dcmplx(2d0*Y(i,j)/musq)
enddo
enddo
a=k(2,4)*k(3,4)
b=k(1,3)*k(2,4)+k(1,2)*k(3,4)-k(1,4)*k(2,3)
c=k(1,2)*k(1,3)
d=k(2,3)
bsq=b**2
fourac=4d0*a*c
discr=sqrt(bsq-fourac)
if (abs(discr) .lt. 1d-10*max(dble(bsq),dble(fourac))) then
z(1)=0.5d0*b/a
wlog(1)=dcmplx(dreal(cln(z(1),+1d0)))
Ival0=
. +k(3,4)*(cln(k(3,4),-1d0)+wlog(1)-cln(k(1,3),-1d0))
. /(k(3,4)*z(1)-k(1,3))
. +k(2,4)*(cln(k(2,4),-1d0)+wlog(1)-cln(k(1,2),-1d0))
. /(k(2,4)*z(1)-k(1,2))
. -(wlog(1)
. +cln(k(2,3),-1d0)+cln(k(1,4),-1d0)
. -cln(k(1,3),-1d0)-cln(k(1,2),-1d0))/z(1)
Ival0=Ival0/(musq**2*a)
return
else
C----wlogi=log(-xi),zi=-xi
z(1)=0.5d0*(b-discr)/a
z(2)=0.5d0*(b+discr)/a
iep=sign(1d0,dreal(d))
C-----z(1) comes with + i*ep*d
C-----z(2) comes with - i*ep*d
wlog(1)=cln(z(1),+iep)
wlog(2)=cln(z(2),-iep)
lnsum=+cln(k(1,2),-1d0)+cln(k(1,3),-1d0)
. -cln(k(1,4),-1d0)-cln(k(2,3),-1d0)
Ival0=czip
do j=1,2
iep=-dfloat(2*j-3)*iep
Ival0=Ival0+dfloat(2*j-3)*(
. -0.5d0*wlog(j)**2+wlog(j)*lnsum
. -qlLi2omprod(dble(k(3,4)),dble(k(1,3)),z(j),iep)
. -qlLi2omprod(dble(k(2,4)),dble(k(1,2)),z(j),iep))
enddo
Ival0=Ival0/(musq**2*discr)
endif
return
end
|
```python
%matplotlib inline
```
# Swirl
Image swirling is a non-linear image deformation that creates a whirlpool
effect. This example describes the implementation of this transform in
``skimage``, as well as the underlying warp mechanism.
## Image warping
When applying a geometric transformation on an image, we typically make use of
a reverse mapping, i.e., for each pixel in the output image, we compute its
corresponding position in the input. The reason is that, if we were to do it
the other way around (map each input pixel to its new output position), some
pixels in the output may be left empty. On the other hand, each output
coordinate has exactly one corresponding location in (or outside) the input
image, and even if that position is non-integer, we may use interpolation to
compute the corresponding image value.
## Performing a reverse mapping
To perform a geometric warp in ``skimage``, you simply need to provide the
reverse mapping to the :py:func:`skimage.transform.warp` function. E.g., consider
the case where we would like to shift an image 50 pixels to the left. The reverse
mapping for such a shift would be::
def shift_left(xy):
xy[:, 0] += 50
return xy
The corresponding call to warp is::
from skimage.transform import warp
warp(image, shift_left)
## The swirl transformation
Consider the coordinate $(x, y)$ in the output image. The reverse
mapping for the swirl transformation first computes, relative to a center
$(x_0, y_0)$, its polar coordinates,
\begin{align}\\theta = \\arctan(y/x)
\\rho = \sqrt{(x - x_0)^2 + (y - y_0)^2},\end{align}
and then transforms them according to
\begin{align}r = \ln(2) \, \mathtt{radius} / 5
\phi = \mathtt{rotation}
s = \mathtt{strength}
\\theta' = \phi + s \, e^{-\\rho / r + \\theta}\end{align}
where ``strength`` is a parameter for the amount of swirl, ``radius`` indicates
the swirl extent in pixels, and ``rotation`` adds a rotation angle. The
transformation of ``radius`` into $r$ is to ensure that the
transformation decays to $\\approx 1/1000^{\mathsf{th}}$ within the
specified radius.
```python
import matplotlib.pyplot as plt
from skimage import data
from skimage.transform import swirl
image = data.checkerboard()
swirled = swirl(image, rotation=0, strength=10, radius=120)
fig, (ax0, ax1) = plt.subplots(nrows=1, ncols=2, figsize=(8, 3),
sharex=True, sharey=True)
ax0.imshow(image, cmap=plt.cm.gray)
ax0.axis('off')
ax1.imshow(swirled, cmap=plt.cm.gray)
ax1.axis('off')
plt.show()
```
|
Formal statement is: lemma CauchyD: "Cauchy X \<Longrightarrow> 0 < e \<Longrightarrow> \<exists>M. \<forall>m\<ge>M. \<forall>n\<ge>M. norm (X m - X n) < e" for X :: "nat \<Rightarrow> 'a::real_normed_vector" Informal statement is: If $X$ is a Cauchy sequence, then for every $\epsilon > 0$, there exists an $M$ such that for all $m, n \geq M$, we have $|X_m - X_n| < \epsilon$. |
We have 3 answers for the clue One with a beat. See the results below.
Found an answer for the clue One with a beat that we don't have? Then please submit it to us so we can make the clue database even better! |
import matplotlib.pyplot as plt
import cv2
import numpy as np
from matplotlib.patches import Circle
from scipy.misc import imsave
def scale_abs(x, m = 255):
x = np.absolute(x)
x = np.uint8(m * x / np.max(x))
return x
def roi(gray, mn = 125, mx = 1200):
m = np.copy(gray) + 1
m[:, :mn] = 0
m[:, mx:] = 0
return m
def save_image(img, name, i):
path = "output_images/" + name + str(i) + ".jpg"
imsave(path, img)
def show_images(imgs, per_row = 3, per_col = 2, W = 10, H = 5, tdpi = 80):
fig, ax = plt.subplots(per_col, per_row, figsize = (W, H), dpi = tdpi)
ax = ax.ravel()
for i in range(len(imgs)):
img = imgs[i]
ax[i].imshow(img)
for i in range(per_row * per_col):
ax[i].axis('off')
def show_dotted_image(this_image, points, thickness = 5, color = [255, 0, 255 ], d = 15):
image = this_image.copy()
cv2.line(image, points[0], points[1], color, thickness)
cv2.line(image, points[2], points[3], color, thickness)
fig, ax = plt.subplots(1)
ax.set_aspect('equal')
ax.imshow(image)
for (x, y) in points:
dot = Circle((x, y), d)
ax.add_patch(dot)
plt.show()
|
lemma (in linorder_topology) compact_attains_sup: assumes "compact S" "S \<noteq> {}" shows "\<exists>s\<in>S. \<forall>t\<in>S. t \<le> s" |
extract_name(line) = join(split(line)[2:end-1], " ")
start_testset!(dest, line) =
println(dest, "@testset \"", extract_name(line), "\" begin")
finish_testset!(dest) = println(dest, "end\n")
begins_testset(line) = startswith(line, "testcase")
finishes_testset(line) = line == "}"
begins_decoration_testset(line) = occursin("dec", extract_name(line))
is_comment(line) = startswith(line, "//")
begins_multiline_comment(line) = startswith(line, "/*")
skip_block(src, stopline) = readuntil(src, "\n" * stopline * "\n")
skip_multiline_comment(src) = skip_block(src, "*/")
skip_testset(src) = skip_block(src, "}")
function translate!(dest::IO, src::IO)
while !eof(src)
line = rstrip(strip(readline(src)), ';')
if isempty(line) || is_comment(line)
nothing
elseif begins_multiline_comment(line)
skip_multiline_comment(src)
elseif begins_testset(line)
if begins_decoration_testset(line)
skip_testset(src)
else
start_testset!(dest, line)
end
elseif finishes_testset(line)
finish_testset!(dest)
else
itl_test = line
translate!(dest, itl_test)
end
end
end
tests_decorated_intervals(case) =
occursin("]_", case) ||
occursin("d-numsToInterval", case) ||
occursin("setDec", case) ||
occursin("intervalPart", case)
tests_string_input(case) = occursin("textToInterval", case)
tests_logging(case) = occursin("signal", case)
skip_testcase(case) =
tests_decorated_intervals(case) ||
tests_string_input(case)
indent(io) = print(io, repeat(' ', 4))
function translate!(dest::IO, itl_test::AbstractString)
skip_testcase(itl_test) && return
jl_test = tests_logging(itl_test) ?
translate_logtest(itl_test) : translate(itl_test)
indent(dest)
println(dest, jl_test)
end
function translate_logtest(itl_test)
itl_test, exc = split(itl_test, " signal ")
exc != "UndefinedOperation" && return "# " * itl_test
lhs, rhs = split(itl_test, "=")
jl_test = rebuild(rebuild_lhs(lhs), rebuild_rhs(rhs))
return "@test_throws AssertionError " * jl_test
end
isbroken(expr) = !eval(Meta.parse(expr))
"""
This function parses a line into julia code, e.g.
```
add [1, 2] [1, 2] = [2, 4]
```
is parsed into
```
@test +(Interval(1, 2), Interval(1, 2)) === Interval(2, 4)
```
"""
function translate(itl_test)
lhs, rhs = split(itl_test, "=")
jl_test = rebuild(rebuild_lhs(lhs), rebuild_rhs(rhs))
try
return ifelse(isbroken(jl_test), "@test_broken ", "@test ") * jl_test
catch
@warn "caused exception: " * jl_test
return "# " * itl_test
end
end
const interval_pattern = r"\[([^\]]+)\]"
function rebuild_lhs(lhs)
lhs = strip(lhs)
fname, args = split(lhs, limit = 2)
# input numbers
args = replace(args, "infinity" => "Inf")
args = replace(args, "X" => "x")
if fname == "b-numsToInterval"
args = replace(args, ' ' => ',')
return "Interval($args)"
end
# input intervals
for m in eachmatch(interval_pattern, args)
args = replace(args, m.match => translate_interval(m[1]))
end
args = replace(args, " " => ", ")
args = replace(args, ",," => ",")
args = replace(args, "{" => "[")
args = replace(args, "}" => "]")
return functions[fname](args)
end
isintstring(x) = !isnothing(tryparse(Int, x))
floatstring(x) = x * ifelse(isintstring(x), ".0", "")
function rebuild_rhs(rhs)
rhs = strip(rhs)
rhs = replace(rhs, "infinity" => "Inf")
rhs = replace(rhs, "X" => "x")
if '[' ∉ rhs # one or more scalar/boolean values separated by space
return map(floatstring, split(rhs))
else # one or more intervals
intervals = map(
m -> translate_interval(m[1]),
eachmatch(interval_pattern, rhs)
)
return intervals
end
end
const special_intervals = Dict(
"nai" => "nai()",
"entire" => "entireinterval()",
"empty" => "emptyinterval()"
)
translate_interval(ival) =
haskey(special_intervals, ival) ?
special_intervals[ival] :
"interval($ival)"
const relaxed_functions = [
"sinh",
"cosh",
"tanh",
"coth",
"sech",
"csch",
"asinh",
"acosh",
"atanh",
"acoth",
"atan",
"cot",
"acot",
"sec",
"csc",
"exp2",
"exp10",
"^",
"cbrt"
]
only_requires_validity(lhs) =
any(startswith(lhs, f * "(") for f in relaxed_functions)
function rebuild(lhs, rhs::AbstractString)
rhs == "nai()" && return "isnai($lhs)"
rhs == "NaN" && return "isnan($lhs)"
rhs == "true" && return lhs
rhs == "false" && return lhs[end] == ')' ? "!" * lhs : "!($lhs)"
only_requires_validity(lhs) && return "$lhs ⊇ $rhs"
return "$lhs == $rhs"
end
function rebuild(lhs, rhs::Vector)
length(rhs) == 1 && return rebuild(lhs, rhs[1])
expr = [rebuild(lhs*"[$i]", r) for (i, r) in enumerate(rhs)]
return join(expr, " && ")
end
|
module Data.Void
export
absurdity : Uninhabited t => (0 _ : t) -> s
absurdity x = void (uninhabited x)
export
contradiction : Uninhabited t => (0 _ : x -> t) -> (x -> s)
contradiction since x = absurdity (since x)
|
*=======================================================================
* File: rdistm.f
* Author: Alex Stivala
* Created: August 2008
*
* Read numeric SSE distance matrix.
*
* Each row is a row of the distance matrix, lower triangle
* only (since it is symmetric).
* The diagonal entries are meaningless (self-distance)
* and are included instead to specify the SSE type, with
* the following codes:
*
* 0.000 beta strand
* 1.000 alpha helix
* 2.000 pi helix
* 3.000 3_10 helix
*
* Each entry in matrix is in Angstroms format
* F6.3 with a space between each on a line, and one line
* per row of matrix.
*
* E.g.:
*
* 0.000
* 4.501 0.000
* 11.662 10.386 1.000
* 16.932 17.644 9.779 3.000
* 10.588 13.738 11.815 10.527 0.000
* 15.025 18.692 17.143 15.341 6.466 0.000
* 15.298 17.276 16.276 20.075 13.264 11.610 3.000
* 7.549 11.072 12.248 12.446 4.583 9.903 15.689 0.000
*
*
* This subroutine is used to read the distance matrix from the
* database, where the identifier and order and tableau have already
* been read by subroutine RDTABD.
*
* $Id: rdistm.F 2969 2009-11-22 01:29:39Z astivala $
*=======================================================================
subroutine rdistm(nunit, dmat, ldo, n)
implicit none
*
* rdistm - read a numeric SSE distance matrix
*
*
* .. Scalar Arguments ..
integer nunit,ldo,n
* ..
* .. Array Arguments
double precision dmat(ldo, *)
* ..
*
*
* Arguments
* =========
*
* nunit (input) INTEGER
* Unit number to read numeric distance matrix from
*
* dmat (output) DOUBLE PRECISION array, dimension (ldo, ldo)
* Distance matrix read from the file. Must be dimensioned large
* enough to hold dimension (n,n) data.
* The full symmetric matrix is stored.
*
* ldo (input) INTEGER
* Leading dimension of distance matrix array.
*
* n (input) INTEGER
* Order of distance matrix (dimension of matrix).
* n <= ldo
*
*=======================================================================
*
* .. Parameters ..
* ..
* .. Local Scalars ..
integer i,j
real dist
character line*2048
* ..
* .. Local Arrays ..
* ..
* .. Intrinsic Functions ..
intrinsic dble
* ..
* .. External Subroutines and Functions ..
* ..
* .. Executable Statements ..
*
do 50 i = 1, n
read(nunit,'(a2048)') line
do 40 j = 1, i
read(line((j-1)*7+1:(j-1)*7+7), '(f6.3)') dist
dmat(i,j) = dble(dist)
dmat(j,i) = dmat(i,j)
40 continue
50 continue
return
end
|
{-# OPTIONS --copatterns #-}
-- {-# OPTIONS -v term:20 #-}
-- {-# OPTIONS --no-positivity-check #-}
-- {-# OPTIONS -v tc.def.fun:50 #-}
module CopatternNonterminating where
open import Common.Equality
record Stream (A : Set) : Set where
coinductive
field
head : A
tail : Stream A
module S = Stream
illdefined : {A : Set} -> Stream A
S.head illdefined = S.head illdefined
S.tail illdefined = S.tail illdefined
-- should not termination-check
{-
illRepeat : {A : Set}(a : A) → Stream A
( (S.head (illRepeat a))) = a
(S.head (S.tail (illRepeat a))) = a
(S.tail (S.tail (illRepeat a))) = S.tail (S.tail (illRepeat a))
-}
{-
-- deep copattern matches are not yet translated into something
-- that termination checks
illRepeat : {A : Set}(a : A) → Stream A
( (S.head (illRepeat a))) = a
(S.head (S.tail (illRepeat a))) = a
(S.tail (S.tail (illRepeat a))) = (S.tail (illRepeat a))
record _≈_ {A : Set}(s t : Stream A) : Set where
field
head : S.head s ≡ S.head t
tail : S.tail s ≈ S.tail t
module B = _≈_
repeat : {A : Set}(a : A) → Stream A
S.head (repeat a) = a
S.tail (repeat a) = repeat a
-- THIS SHOULD NOT TERMINATION CHECK WITH CURRENT TRANSLATION SEMANTICS
-- OF COPATTERNS
repeat′ : {A : Set}(a : A) → Stream A
( (S.head (repeat′ a))) = a
(S.head (S.tail (repeat′ a))) = a
(S.tail (S.tail (repeat′ a))) = S.tail (repeat′ a) -- invalid projection
repeat≈repeat′ : {A : Set}(a : A) → repeat a ≈ repeat′ a
( (B.head (repeat≈repeat′ a))) = refl
(B.head (B.tail (repeat≈repeat′ a))) = refl
(B.tail (B.tail (repeat≈repeat′ a))) = repeat≈repeat′ a
-}
|
[STATEMENT]
lemma Spy_see_shrK_D [dest!]:
"[|Key (shrK A) \<in> parts (knows Spy evs); evs \<in> orb|] ==> A \<in> bad"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lbrakk>Key (shrK A) \<in> parts (knows Spy evs); evs \<in> orb\<rbrakk> \<Longrightarrow> A \<in> bad
[PROOF STEP]
by (blast dest: Spy_see_shrK) |
module BioFasta.Common
import Data.List
import Data.Maybe
import Data.Strings
import BioCore.Sequence
||| Splits a character list into a list of newline separated character lists.
|||
||| ```idris example
||| lines' (unpack "\rA BC\nD\r\nE\n")
||| ```
public export
lines' : List Char -> List (List Char)
lines' [] = []
lines' s = case break isNL s of
(l, s') => l :: case s' of
[] => []
_ :: s'' => lines' (assert_smaller s s'')
||| The groupBy function returns a list of lists such that the concatenation
||| of the list is equal to the argument, and each sublist contains only
||| elements that are equal according to the user-supplied predicate.
|||
||| ```idris example
||| groupBy (==) [1, 1, 2, 3, 3]
||| ```
|||
public export
groupBy : (a -> a -> Bool) -> List a -> List (List a)
groupBy _ [] = []
groupBy p' (x'::xs') =
let (ys',zs') = go p' x' xs'
in (x' :: ys') :: zs'
where
go : (a -> a -> Bool) -> a -> List a -> (List a, List (List a))
go p z (x::xs) =
let (ys,zs) = go p x xs
in case p z x of
True => (x :: ys, zs)
False => ([], (x :: ys) :: zs)
go _ _ [] = ([], [])
|
module WrongNamedArgument2 where
postulate
f : {A : Set₁} → A
test : Set
test = f {B = Set}
-- Unsolved meta.
-- It is not an error since A could be instantiated to a function type
-- accepting hidden argument with name B.
|
Require Import Coq.ZArith.BinInt.
Require Import coqutil.Word.LittleEndian.
Require Import riscv.Utility.Monads.
Require Import riscv.Utility.MonadNotations.
Require Import riscv.Spec.Decode.
Require Import riscv.Platform.Memory. (* should go before Program because both define loadByte etc *)
Require Import riscv.Spec.Machine.
Require Import riscv.Spec.Execute.
Require Import riscv.Utility.Utility.
Section Riscv.
Context {mword: Type}.
Context {MW: MachineWidth mword}.
Context {M: Type -> Type}.
Context {MM: Monad M}.
Context {RVP: RiscvProgram M mword}.
Context {RVS: RiscvMachine M mword}.
Definition run1(iset: InstructionSet):
M unit :=
pc <- getPC;
inst <- loadWord Fetch pc;
execute (decode iset (combine 4 inst));;
endCycleNormal.
(* Note: We cannot use
power_func (fun m => run1 iset;; m) n (Return tt)
to obtain a monadic computation executing n instructions,
because if one cycle ends early (due to an exception),
all the remaining operations are skipped.
The lifting from run1 to run-many has to be done in a
monad-specific way. *)
End Riscv.
|
c*************************************************************************
c KICKVH_TP.F
c*************************************************************************
c To kick the velocity components vxh(*) by axh(*)*dt for test particles
c
c Input:
c ntp ==> number of bodies (int scalar)
c vxh,vyh,vzh ==> initial velocity in helio coord
c (real arrays)
c axh,ayh,azh ==> acceleration in helio coord
c (real arrays)
c istat ==> status of the test paricles
c (integer array)
c istat(i) = 0 ==> active: = 1 not
c NOTE: it is really a 2d array but
c we only use the 1st row
c dt ==> time step
c Output:
c vxh,vyh,vzh ==> final velocity in helio coord
c (real arrays)
c
c ALGORITHM: Obvious
c
c AUTHOR: M. Duncan.
c DATE WRITTEN: Feb. 2, 1993.
c REVISIONS: 2/18/93 HFL
subroutine kickvh_tp(ntp,vxht,vyht,vzht,axht,ayht,azht,istat,dt)
include '../../swift.inc'
c... Inputs Only:
integer ntp,istat(ntp)
real*8 axht(ntp),ayht(ntp),azht(ntp)
real*8 dt
c... Inputs and Output:
real*8 vxht(ntp),vyht(ntp),vzht(ntp)
c... Internals:
integer n
c----
c... Executable code
do n= 1, ntp
if(istat(n).eq.0) then
vxht(n) = vxht(n) + axht(n)*dt
vyht(n) = vyht(n) + ayht(n)*dt
vzht(n) = vzht(n) + azht(n)*dt
endif
enddo
return
end ! kickvh_tp
c-----------------------------------------------------------------------------
|
/*
* This file is part of the Visual Computing Library (VCL) release under the
* MIT license.
*
* Copyright (c) 2014 Basil Fierz
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// VCL configuration
#include <vcl/config/global.h>
// C++ standard library
#include <condition_variable>
#include <iostream>
#include <mutex>
#include <thread>
#include <vector>
// Boost library
#include <boost/thread.hpp>
// Qt
#include <QtCore/QMutex>
// Win32
#ifdef VCL_ABI_WINAPI
# include <Windows.h>
#endif
// VCL
#include <vcl/util/precisetimer.h>
// The loop counter
int MaxIterations;
// List of threads trying to obtain the mutexes
std::vector<std::thread> Threads;
// Locking all threads until all are ready
std::mutex m;
std::condition_variable halt;
bool ready = false;
// Various mutexes to test
std::mutex StdMutex;
boost::mutex BoostMutex;
QMutex QtMutex;
#ifdef VCL_ABI_WINAPI
CRITICAL_SECTION CriticalSection;
#endif
// Wait function blocking the threads until everything is setup
void wait(void)
{
std::unique_lock<std::mutex> lk(m);
halt.wait(lk, []{ return ready; });
}
// Functions testing mutexes
void stdMutex()
{
wait();
for (int i = 0; i < MaxIterations; i++)
{
StdMutex.lock();
StdMutex.unlock();
}
}
void boostMutex()
{
wait();
for (int i = 0; i < MaxIterations; i++)
{
BoostMutex.lock();
BoostMutex.unlock();
}
}
void qMutex()
{
wait();
for (int i = 0; i < MaxIterations; i++)
{
QtMutex.lock();
QtMutex.unlock();
}
}
#ifdef VCL_ABI_WINAPI
void winMutex()
{
wait();
for (int i = 0; i < MaxIterations; i++)
{
EnterCriticalSection(&CriticalSection);
LeaveCriticalSection(&CriticalSection);
}
}
#endif
typedef void(*ThreadFunc)(void);
struct Job
{
ThreadFunc Func;
const char* Name;
};
#define JOB(FUNC) { FUNC, #FUNC }
int main(int argc, char* argv[])
{
MaxIterations = 10000;
Job jobs [] =
{
JOB(stdMutex),
JOB(boostMutex),
JOB(qMutex),
#ifdef VCL_ABI_WINAPI
JOB(winMutex),
#endif
};
// Win32
#ifdef VCL_ABI_WINAPI
InitializeCriticalSection(&CriticalSection);
#endif
for (auto job : jobs)
{
// Block all threads
ready = false;
// Clear the threads from the previous run
Threads.clear();
// Queue the new tasks
for (int i = 0; i < 10; i++)
{
Threads.emplace_back(job.Func);
}
// Start the threads
Vcl::Util::PreciseTimer timer;
timer.start();
ready = true;
halt.notify_all();
for (auto& t : Threads)
{
t.join();
}
timer.stop();
std::cout << "Time per mutex (" << job.Name << "): " << timer.interval() << std::endl;
}
// Win32
#ifdef VCL_ABI_WINAPI
DeleteCriticalSection(&CriticalSection);
#endif
return 0;
}
|
"""
House
Data stucture that represents a house and its appliances.
# Attributes
- `index`: Index of that house
- `num_timesteps`: Number of time-steps in the time horizon
- `netload_min`: House's minimum net load, for each time-step
- `netload_max`:
- `price`: Electricity price, in dollar per kWh
- `appliances`: List of appliances in that house
"""
struct House <: Resource
index::Int
num_timesteps::Int
netload_min::Vector{Float64}
netload_max::Vector{Float64}
price::Vector{Float64}
appliances::Vector{Resource}
end
function House(;
index::Integer=0,
T::Integer=0,
netload_min::Vector{Float64}=Vector{Float64}(),
netload_max::Vector{Float64}=Vector{Float64}(),
price::Vector{Float64}=Vector{Float64}(),
appliances::Vector{Resource}=Vector{Resource}()
)
# Dimension checks
T == size(netload_min, 1) || throw(DimensionMismatch("Invalid netload_min"))
T == size(netload_max, 1) || throw(DimensionMismatch("Invalid netload_max"))
T == size(price, 1) || throw(DimensionMismatch("Invalid price"))
House(
index, T,
copy(netload_min), copy(netload_max), copy(price),
appliances
)
end
"""
LindaOracleMIP(h, solver)
Construct a MIP oracle that schedules the House.
"""
function build_model!(h::House, model::MOI.ModelLike)
# Emtpy model
# TODO: use an UninstanitatedOptimizer instead
MOI.empty!(model)
# Minimize
MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE)
# Initial objective function is empty
fobj = MOI.ScalarAffineFunction(MOI.ScalarAffineTerm{Float64}[], 0.0)
MOI.set(model, MOI.ObjectiveFunction{typeof(fobj)}(), fobj)
# TODO: set parameters
T = h.num_timesteps
# Initialize
var2idx = Dict{Tuple{Symbol, Int, Symbol, Int}, MOI.VariableIndex}()
con2idx = Dict{Tuple{Symbol, Int, Symbol, Int}, MOI.ConstraintIndex}()
# ==========================================
# I. Add local variables
# ==========================================
pnet = MOI.add_variables(model, T) # House's net load
# Variable bounds
for t in 1:T
MOI.add_constraint(model,
MOI.SingleVariable(pnet[t]),
MOI.Interval(h.netload_min[t], h.netload_max[t])
)
end
# Set objective coefficients (?)
# append!(obj, h.price)
for t in 1:T
MOI.modify(model,
MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}(),
MOI.ScalarCoefficientChange(pnet[t], h.price[t])
)
end
# Update list of variable indices
for t in 1:T
var2idx[(:house, h.index, :pnet, t)] = pnet[t] # net load
end
# ==========================================
# II. Add local constraints
# ==========================================
# Linking constraint for house's net load
# pnet[h, t] - sum_{r} pnet[r, t] = 0.0
for t in 1:T
cidx = MOI.add_constraint(model,
MOI.ScalarAffineFunction{Float64}(
[MOI.ScalarAffineTerm(1.0, pnet[t])],
0.0
),
MOI.EqualTo(0.0)
)
# Record constraint index
con2idx[(:house, h.index, :link, t)] = cidx
end
# ==========================================
# III. Add sub-resources to current model
# ==========================================
for r in h.appliances
add_resource_to_model!(model, h, r, var2idx, con2idx)
end
return model, var2idx, con2idx
end |
Program read_lemtions
!
! to convert lemt ion file to CSF form
!
! L. C. Tan 04-Oct-11
! L. C. Tan 19-Dec-11 move to UMD
! Add one channel to He
!
! input date format:
!
! 0 1994 307 0001.3 1994 307 0101.1 0.00348 0.000258
! 123456789012345678901234567890123456789012345678901234567890
! length of line = 200
!
! parameter (ni= 6)
!
character (1) :: blank
character (30) :: inpnam
character (15) :: oupnam
character (4) :: sdate, cname
character (43) :: stime
character (3) :: sm, smy(12)
character (200) :: spar
character (7) :: ctit, ctit1, ctit2, ctit3, ctit4, ctit5, ctit6
!
! real*8 doy0, dd21
integer :: is, iy0, iy1, ix, it(6), imy(12), na(6)
real :: fp(7), dfp(7), ea(7), eb(7), ea1(7), ea2(7), ea3(7), &
ea4(6), ea5(7), ea6(7), eb1(7), eb2(7), eb3(7), eb4(6), &
eb5(7), eb6(7), fup(6)
!
data smy/'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', &
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'/
!
data imy/1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12/
!
data na/7, 7, 7, 6, 7, 7/
data ea1/2.00, 2.40, 3.00, 3.70, 4.53, 6.00, 7.40/
data eb1/2.40, 3.00, 3.70, 4.53, 6.00, 7.40, 9.64/
data ea2/2.57, 3.19, 3.85, 4.80, 5.80, 7.20, 9.10/
data eb2/3.19, 3.85, 4.80, 5.80, 7.20, 9.10, 13.70/
data ea3/2.56, 3.17, 3.88, 4.68, 6.00, 7.40, 9.20/
data eb3/3.17, 3.88, 4.68, 6.00, 7.40, 9.20, 13.40/
data ea4/3.27, 3.98, 4.72, 5.92, 7.87, 9.96/
data eb4/3.98, 4.72, 5.92, 7.87, 9.96, 12.70/
data ea5/2.50, 3.20, 4.00, 4.90, 6.00, 7.90, 9.70/
data eb5/3.20, 4.00, 4.90, 6.00, 7.90, 9.70, 13.60/
data ea6/2.40, 3.00, 3.95, 4.80, 5.90, 7.80, 9.30/
data eb6/3.00, 3.95, 4.80, 5.90, 7.80, 9.30, 12.50/
!
data fup/1e4, 2e3, 2e3, 2e3, 2e3, 2e3/
!
data ctit1/'He_omn_'/
data ctit2/'C__omn_'/
data ctit3/'O__omn_'/
data ctit4/'Ne_omn_'/
data ctit5/'Si_omn_'/
data ctit6/'Fe_omn_'/
!
!
write(*, 210)
210 format(' Enter 1[He],2[C],3[O],4[Ne],5[Si],6[Fe]=> ')
read *, is
!
if(is == 1) then
do 220 i= 1, na(is)
ea(i)= ea1(i)
eb(i)= eb1(i)
220 continue
ctit= ctit1
else
if(is == 2) then
do 230 i= 1, na(is)
ea(i)= ea2(i)
eb(i)= eb2(i)
230 continue
ctit= ctit2
else
if(is == 3) then
do 240 i= 1, na(is)
ea(i)= ea3(i)
eb(i)= eb3(i)
240 continue
ctit= ctit3
else
if(is == 4) then
do 250 i= 1, na(is)
ea(i)= ea4(i)
eb(i)= eb4(i)
250 continue
ctit= ctit4
else
if(is == 5) then
do 260 i= 1, na(is)
ea(i)= ea5(i)
eb(i)= eb5(i)
260 continue
ctit= ctit5
else
if(is == 6) then
do 270 i= 1, na(is)
ea(i)= ea6(i)
eb(i)= eb6(i)
270 continue
ctit= ctit6
endif
endif
endif
endif
endif
endif
! print *, 'is=', is
! print *, 'ctit=', ctit
! print *, 'ea=', ea
! print *, 'eb=', eb
!
write(*, 10)
10 format(' Enter name of input file=> ')
read(*, 20) inpnam
20 format(a)
!
open (unit= 3, file= inpnam, status = 'old')
!
! read blank lines
!
2 read (3, 4) sdate
4 format(a)
if(sdate == '#End') then
goto 6
else
goto 2
endif
!
6 continue
!
! iy0= 1994
write(*, 12)
12 format(' Enter name of first year=> ')
read *, iy0
!
write(cname, 80) iy0
80 format(i4)
oupnam= ctit//cname//'.txt'
! print *, oupnam
write(*, 14) oupnam
14 format(a15)
!
open(unit= 4, file= oupnam, status= 'new', recl= 300)
ix= 1
!
if(na(is) == 6) then
write(4, 90) (ea(i), eb(i), i, i=1, na(is))
90 format(1x, 'Year, Month, Day, Hour, DOY, ', &
5(f5.2, '-', f5.2, ', dJ', i1, ', '), &
f5.2, '-', f5.2, ', dJ', i1)
else
write(4, 92) (ea(i), eb(i), i, i=1, na(is))
92 format(1x, 'Year, Month, Day, Hour, DOY, ', &
6(f5.2, '-', f5.2, ', dJ', i1, ', '), &
f5.2, '-', f5.2, ', dJ', i1)
endif
!
!
100 read(3, 110, end= 1000) stime, spar
110 format(a43, a200)
!
read(stime, 120) iy1, idoy1, ih1, rm1, iy2, idoy2, ih2, rm2
120 format(2(4x, i4, 1x, i3, 1x, i2, f4.1))
!
! remove data with sampling period less than 0.5 hr
!
jy1= mod(iy1, 4)
if(jy1.eq. 0) then
iy1f= 366
else
iy1f= 365
endif
!
dd21= iy1f*(iy2- iy1)+ (idoy2- idoy1)+ (ih2- ih1)/ 24. &
+(rm2- rm1)/ (24.* 60.)
!
if(dd21 <= (31./(24.* 60.))) goto 100
!
if(iy1 > iy0) then
close(unit= 4)
iy0= iy1
ix= 0
endif
!
if(ix == 0) then
!
write(cname, 80) iy0
oupnam= ctit//cname//'.txt'
print *, oupnam
!
open(unit= 4, file= oupnam, status= 'new', recl= 300)
ix= 1
!
if(na(is) == 6) then
write(4, 90) (ea(i), eb(i), i, i=1, na(is))
else
write(4, 92) (ea(i), eb(i), i, i=1, na(is))
endif
endif
!
it(1)= iy1
call CALIDM(iy1, idoy1, im1, id1)
it(2)= im1
it(3)= id1
it(4)= nint(ih1+ rm1/ 60.)
doy0= idoy1+ (it(4)+ 0.5)/24.
!
read(spar, *) (fp(i), dfp(i), i=1, na(is))
!
do 178 i=1, na(is)
if((fp(i) > fup(is)).or. (dfp(i) > fup(is))) then
fp(i)= -1.e31
dfp(i)= -1.e31
endif
178 continue
!
if(na(is) == 6) then
write(4, 180) (it(i), i=1, 4), doy0, &
(fp(i), dfp(i), i=1, na(is))
!
180 format(1x, i4, ', ', 3(i2, ', '), f7.3, ', ', &
11(g11.4, ', '), g11.4)
else
write(4, 182) (it(i), i=1, 4), doy0, &
(fp(i), dfp(i), i=1, na(is))
!
182 format(1x, i4, ', ', 3(i2, ', '), f7.3, ', ', &
13(g11.4, ', '), g11.4)
endif
!
goto 100
!
1000 continue
stop
! end
End Program read_lemtions
!
!
!
subroutine daytodoy(it, doy)
!
! real*8 doy
integer :: it(6), idm(12), idma(12), idmb(12)
! dimension it(6), idm(12), idma(12), idmb(12)
!
data idma/31,29,31,30,31,30,31,31,30,31,30,31/
data idmb/31,28,31,30,31,30,31,31,30,31,30,31/
!
iz= it(1)- 1960
jz= mod(iz, 4)
!
if(jz == 0) then
do 10 i=1, 12
idm(i)= idma(i)
10 continue
else
do 20 i=1, 12
idm(i)= idmb(i)
20 continue
endif
!
ndoy= 0
if(it(2) > 1) then
do 30 i=1, (it(2)- 1)
ndoy= ndoy+ idm(i)
30 continue
endif
!
doy= ndoy+ it(3)+ it(4)/24.+ it(5)/1440.+ it(6)/86400.
!
return
end
!
!
!
SUBROUTINE CALIDM(IY0, IDOY, IM0, ID0)
! DIMENSION IDM(12),IDMA(12),IDMB(12)
integer :: IDM(12),IDMA(12),IDMB(12)
!
DATA IDMA/31,29,31,30,31,30,31,31,30,31,30,31/
DATA IDMB/31,28,31,30,31,30,31,31,30,31,30,31/
!
IX= IY0- 1960
JX= MOD(IX, 4)
DO 10 I=1, 12
IF(JX == 0) THEN
IDM(I)= IDMA(I)
ELSE
IDM(I)= IDMB(I)
ENDIF
10 CONTINUE
!
IX= IDOY
DO 20 I= 1, 12
IX= IX-IDM(I)
!
IF(IX == 0) THEN
IM0= I
ID0= IDM(I)
GOTO 30
ENDIF
!
IF(IX < 0) THEN
IM0= I
ID0= IX+ IDM(I)
GOTO 30
ENDIF
20 CONTINUE
30 RETURN
END
! |
\subsection{Expected value}
\subsubsection{Definition}
For a random variable (or vector of random variables), \(x\), we define the expected value of \(f(x)\) as :
\(E[f(x)]:=\sum f(x_i) P(x_i)\)
The expected value of random variable \(x\) is therefore this where \(f(x)=x\).
\(E(x)=\sum_i x_i P(x_i)\)
\subsubsection{Linearity of expectation}
We can show that \(E(x+y)=E(x)+E(y)\):
\(E[x+y]=\sum_i \sum_j (x_i+y_j) P(x_i \land y_j)\)
\(E[x+y]=\sum_i \sum_j x_i [P(x_i \land y_j)]+\sum_i \sum_j [y_j P(x_i \land y_j)]\)
\(E[x+y]=\sum_i x_i \sum_j [P(x_i \land y_j)]+\sum_j y_j \sum_i [P(x_i \land y_j)]\)
\(E[x+y]=\sum_i x_i P(x_i)+\sum_j y_j P(y_j)\)
\(E[x+y]=E[x]+E[y]\)
\subsubsection{Expectations of multiples}
Expectations
\(E(cx)=\sum_i cx P(x_i)\)
\(E(cx)=c\sum_i x P(x_i)\)
\(E(cx)=cE(x)\)
\subsubsection{Expectations of constants}
\(E(c)=\sum_i c_i P(c_i)\)
\(E(c)= cP(c)\)
\(E(c)= c\)
\subsubsection{Conditional expectation}
If \(Y\) is a variable we are interested in understanding, and \(X\) is a vector of other variables, we can create a model for \(Y\) given \(X\).
This is the conditional expectation.
\(E[Y|X]\)
\(E[P(Y|X)Y]\)
In the continuous case this is
\(E(Y|X)=\int_{-\infty }^{\infty }yP(y|X)dy\)
We can then identify an error vector.
\(\epsilon :=Y-E(Y|X)\)
So:
\(Y=E(Y|X)+\epsilon \)
Here \(Y\) is called the dependent variable, and \(X\) is called the dependent variable.
\subsubsection{Iterated expectation}
\(E[E[Y]]=E[Y]\)
\(E[E[Y|X]=E[Y]\)
|
{-# OPTIONS --warning ShadowingInTelescope #-}
postulate
_ : (A A : Set) → Set
|
theory Liminf_Limsup_Lemma_Bucket
imports
Main
"~~/src/HOL/Library/Extended_Real"
"~~/src/HOL/Library/Liminf_Limsup"
Extended_Real_Lemma_Bucket
begin
lemma ge_Limsup_iff:
fixes X :: "_ \<Rightarrow> _ :: complete_linorder"
shows "C \<ge> Limsup F X \<longleftrightarrow> (\<forall>y>C. eventually (\<lambda>x. y > X x) F)"
proof -
{ fix y P assume "eventually P F" "y > SUPREMUM (Collect P) X"
then have "eventually (\<lambda>x. y > X x) F"
by (auto elim!: eventually_mono dest: SUP_lessD) }
moreover
{ fix y P assume "y > C" and y: "\<forall>y>C. eventually (\<lambda>x. y > X x) F"
have "\<exists>P. eventually P F \<and> y > SUPREMUM (Collect P) X"
proof (cases "\<exists>z. C < z \<and> z < y")
case True
then obtain z where z: "C < z \<and> z < y" ..
moreover from z have "z \<ge> SUPREMUM {x. z > X x} X"
by (auto intro!: SUP_least)
ultimately show ?thesis
using y by (intro exI[of _ "\<lambda>x. z > X x"]) auto
next
case False
then have "C \<ge> SUPREMUM {x. y > X x} X"
by (intro SUP_least) (auto simp: not_less)
with \<open>y > C\<close> show ?thesis
using y by (intro exI[of _ "\<lambda>x. y > X x"]) auto
qed }
ultimately show ?thesis
unfolding Limsup_def INF_le_iff by auto
qed
lemma Limsup_ereal_mult_right:
assumes "F \<noteq> bot" "(c::real) \<ge> 0"
shows "Limsup F (\<lambda>n. f n * ereal c) = Limsup F f * ereal c"
proof (cases "c = 0")
assume "c \<noteq> 0"
with assms have c: "c > 0" by simp
show ?thesis
proof (rule Limsup_eqI)
fix P assume P: "eventually P F"
hence "eventually (\<lambda>n. f n \<le> (SUP x:Collect P. f x)) F"
by (rule eventually_mono) (auto intro: SUP_upper)
with assms and P show " Limsup F f * ereal c \<le> (SUP n:Collect P. f n * ereal c)"
by (subst Sup_ereal_mult_right'[symmetric])
(auto dest: eventually_happens' intro!: ereal_mult_right_mono Limsup_bounded SUP_upper)
next
fix C assume C: "\<And>P. eventually P F \<Longrightarrow> C \<le> (SUP n:Collect P. f n * ereal c)"
{
fix P assume P: "eventually P F"
note C[OF P]
also from P assms have "(SUP n:Collect P. f n * ereal c) = SUPREMUM (Collect P) f * ereal c"
by (subst Sup_ereal_mult_right'[symmetric])
(auto dest: eventually_happens' intro!: ereal_mult_right_mono Limsup_bounded SUP_upper)
finally have "C / ereal c \<le> SUPREMUM (Collect P) f" using c
by (subst ereal_divide_le_pos) (simp_all add: mult.commute)
}
hence "C / ereal c \<le> (INF P:{P. eventually P F}. SUPREMUM (Collect P) f)"
by (intro INF_greatest) simp
with c show "C \<le> Limsup F f * ereal c"
unfolding Limsup_def by (simp add: ereal_divide_le_pos mult.commute)
qed
qed (simp add: assms Limsup_const zero_ereal_def[symmetric])
lemma Inf_ereal_mult_right':
assumes nonempty: "Y \<noteq> {}"
and x: "x \<ge> 0"
shows "(INF i:Y. f i) * ereal x = (INF i:Y. f i * ereal x)" (is "?lhs = ?rhs")
proof(cases "x = 0")
case True thus ?thesis by(auto simp add: nonempty zero_ereal_def[symmetric])
next
case False
show ?thesis
proof(rule antisym)
show "?rhs \<ge> ?lhs"
by(rule INF_greatest) (simp add: ereal_mult_right_mono INF_lower x)
next
have "?rhs = ?rhs / ereal x * ereal x" using False
by (simp only: ereal_times_divide_eq_left ereal_times_divide_eq[symmetric] ereal_divide)
(simp add: one_ereal_def[symmetric])
also have "?rhs / ereal x \<le> (INF i:Y. f i)"
proof(rule INF_greatest)
fix i
assume "i \<in> Y"
have "f i = f i * (ereal x / ereal x)" using False by simp
also have "\<dots> = f i * x / x" by(simp only: ereal_times_divide_eq)
also from \<open>i \<in> Y\<close> have "f i * x \<ge> ?rhs" by (rule INF_lower)
hence "f i * x / x \<ge> ?rhs / x" using x False by simp
finally show "f i \<ge> ?rhs / x" .
qed
hence "?rhs / ereal x * ereal x \<le> (INF i:Y. f i) * ereal x" using x
by (intro ereal_mult_right_mono) simp_all
finally show "?lhs \<ge> ?rhs" .
qed
qed
lemma Liminf_ereal_mult_right:
assumes "F \<noteq> bot" "(c::real) \<ge> 0"
shows "Liminf F (\<lambda>n. f n * ereal c) = Liminf F f * ereal c"
proof (cases "c = 0")
assume "c \<noteq> 0"
with assms have c: "c > 0" by simp
show ?thesis
proof (rule Liminf_eqI)
fix P assume P: "eventually P F"
hence "eventually (\<lambda>n. f n \<ge> (INF x:Collect P. f x)) F"
by (rule eventually_mono) (auto intro: INF_lower)
with assms and P show " Liminf F f * ereal c \<ge> (INF n:Collect P. f n * ereal c)"
by (subst Inf_ereal_mult_right'[symmetric])
(auto dest: eventually_happens' intro!: ereal_mult_right_mono Liminf_bounded INF_lower)
next
fix C assume C: "\<And>P. eventually P F \<Longrightarrow> C \<ge> (INF n:Collect P. f n * ereal c)"
{
fix P assume P: "eventually P F"
note C[OF P]
also from P assms have "(INF n:Collect P. f n * ereal c) = INFIMUM (Collect P) f * ereal c"
by (subst Inf_ereal_mult_right'[symmetric])
(auto dest: eventually_happens' intro!: ereal_mult_right_mono Limsup_bounded SUP_upper)
finally have "C / ereal c \<ge> INFIMUM (Collect P) f" using c
by (subst ereal_le_divide_pos) (simp_all add: mult.commute)
}
hence "C / ereal c \<ge> (SUP P:{P. eventually P F}. INFIMUM (Collect P) f)"
by (intro SUP_least) simp
with c show "C \<ge> Liminf F f * ereal c"
unfolding Liminf_def by (simp add: ereal_le_divide_pos mult.commute)
qed
qed (simp add: assms Liminf_const zero_ereal_def[symmetric])
lemma Limsup_ereal_mult_left:
assumes "F \<noteq> bot" "(c::real) \<ge> 0"
shows "Limsup F (\<lambda>n. ereal c * f n) = ereal c * Limsup F f"
using Limsup_ereal_mult_right[OF assms] by (subst (1 2) mult.commute)
lemma limsup_ereal_mult_right:
"(c::real) \<ge> 0 \<Longrightarrow> limsup (\<lambda>n. f n * ereal c) = limsup f * ereal c"
by (rule Limsup_ereal_mult_right) simp_all
lemma limsup_ereal_mult_left:
"(c::real) \<ge> 0 \<Longrightarrow> limsup (\<lambda>n. ereal c * f n) = ereal c * limsup f"
by (subst (1 2) mult.commute, rule limsup_ereal_mult_right) simp_all
lemma Limsup_compose_continuous_antimono:
fixes f :: "'a::{complete_linorder, linorder_topology} \<Rightarrow> 'b::{complete_linorder, linorder_topology}"
assumes c: "continuous_on UNIV f" and am: "antimono f" and F: "F \<noteq> bot"
shows "Limsup F (\<lambda>n. f (g n)) = f (Liminf F g)"
proof -
{ fix P assume "eventually P F"
have "\<exists>x. P x"
proof (rule ccontr)
assume "\<not> (\<exists>x. P x)" then have "P = (\<lambda>x. False)"
by auto
with \<open>eventually P F\<close> F show False
by auto
qed }
note * = this
have "f (Liminf F g) = (INF P : {P. eventually P F}. f (Inf (g ` Collect P)))"
unfolding Liminf_def SUP_def
by (subst continuous_at_Sup_antimono[OF am continuous_on_imp_continuous_within[OF c]])
(auto intro: eventually_True)
also have "\<dots> = (INF P : {P. eventually P F}. SUPREMUM (g ` Collect P) f)"
by (intro INF_cong refl continuous_at_Inf_antimono[OF am continuous_on_imp_continuous_within[OF c]])
(auto dest!: eventually_happens simp: F)
finally show ?thesis
by (auto simp: Limsup_def)
qed
lemma Liminf_compose_continuous_mono:
fixes f :: "'a::{complete_linorder, linorder_topology} \<Rightarrow> 'b::{complete_linorder, linorder_topology}"
assumes c: "continuous_on UNIV f" and am: "mono f" and F: "F \<noteq> bot"
shows "Liminf F (\<lambda>n. f (g n)) = f (Liminf F g)"
proof -
{ fix P assume "eventually P F"
have "\<exists>x. P x"
proof (rule ccontr)
assume "\<not> (\<exists>x. P x)" then have "P = (\<lambda>x. False)"
by auto
with \<open>eventually P F\<close> F show False
by auto
qed }
note * = this
have "f (Liminf F g) = (SUP P : {P. eventually P F}. f (Inf (g ` Collect P)))"
unfolding Liminf_def SUP_def
by (subst continuous_at_Sup_mono[OF am continuous_on_imp_continuous_within[OF c]])
(auto intro: eventually_True)
also have "\<dots> = (SUP P : {P. eventually P F}. INFIMUM (g ` Collect P) f)"
by (intro SUP_cong refl continuous_at_Inf_mono[OF am continuous_on_imp_continuous_within[OF c]])
(auto dest!: eventually_happens simp: F)
finally show ?thesis by (auto simp: Liminf_def)
qed
lemma Limsup_compose_continuous_mono:
fixes f :: "'a::{complete_linorder, linorder_topology} \<Rightarrow> 'b::{complete_linorder, linorder_topology}"
assumes c: "continuous_on UNIV f" and am: "mono f" and F: "F \<noteq> bot"
shows "Limsup F (\<lambda>n. f (g n)) = f (Limsup F g)"
proof -
{ fix P assume "eventually P F"
have "\<exists>x. P x"
proof (rule ccontr)
assume "\<not> (\<exists>x. P x)" then have "P = (\<lambda>x. False)"
by auto
with \<open>eventually P F\<close> F show False
by auto
qed }
note * = this
have "f (Limsup F g) = (INF P : {P. eventually P F}. f (Sup (g ` Collect P)))"
unfolding Limsup_def INF_def
by (subst continuous_at_Inf_mono[OF am continuous_on_imp_continuous_within[OF c]])
(auto intro: eventually_True)
also have "\<dots> = (INF P : {P. eventually P F}. SUPREMUM (g ` Collect P) f)"
by (intro INF_cong refl continuous_at_Sup_mono[OF am continuous_on_imp_continuous_within[OF c]])
(auto dest!: eventually_happens simp: F)
finally show ?thesis by (auto simp: Limsup_def)
qed
lemma Limsup_add_ereal_right:
"F \<noteq> bot \<Longrightarrow> abs c \<noteq> \<infinity> \<Longrightarrow> Limsup F (\<lambda>n. g n + (c :: ereal)) = Limsup F g + c"
by (rule Limsup_compose_continuous_mono) (auto simp: mono_def ereal_add_mono continuous_on_def)
lemma Limsup_add_ereal_left:
"F \<noteq> bot \<Longrightarrow> abs c \<noteq> \<infinity> \<Longrightarrow> Limsup F (\<lambda>n. (c :: ereal) + g n) = c + Limsup F g"
by (subst (1 2) add.commute) (rule Limsup_add_ereal_right)
lemma Liminf_add_ereal_right:
"F \<noteq> bot \<Longrightarrow> abs c \<noteq> \<infinity> \<Longrightarrow> Liminf F (\<lambda>n. g n + (c :: ereal)) = Liminf F g + c"
by (rule Liminf_compose_continuous_mono) (auto simp: mono_def ereal_add_mono continuous_on_def)
lemma Liminf_add_ereal_left:
"F \<noteq> bot \<Longrightarrow> abs c \<noteq> \<infinity> \<Longrightarrow> Liminf F (\<lambda>n. (c :: ereal) + g n) = c + Liminf F g"
by (subst (1 2) add.commute) (rule Liminf_add_ereal_right)
lemma
assumes "F \<noteq> bot"
assumes nonneg: "eventually (\<lambda>x. f x \<ge> (0::ereal)) F"
shows Liminf_inverse_ereal: "Liminf F (\<lambda>x. inverse (f x)) = inverse (Limsup F f)"
and Limsup_inverse_ereal: "Limsup F (\<lambda>x. inverse (f x)) = inverse (Liminf F f)"
proof -
def inv \<equiv> "\<lambda>x. if x \<le> 0 then \<infinity> else inverse x :: ereal"
have "continuous_on ({..0} \<union> {0..}) inv" unfolding inv_def
by (intro continuous_on_If) (auto intro!: continuous_intros)
also have "{..0} \<union> {0..} = (UNIV :: ereal set)" by auto
finally have cont: "continuous_on UNIV inv" .
have antimono: "antimono inv" unfolding inv_def antimono_def
by (auto intro!: ereal_inverse_antimono)
have "Liminf F (\<lambda>x. inverse (f x)) = Liminf F (\<lambda>x. inv (f x))" using nonneg
by (auto intro!: Liminf_eq elim!: eventually_mono simp: inv_def)
also have "... = inv (Limsup F f)"
by (simp add: assms(1) Liminf_compose_continuous_antimono[OF cont antimono])
also from assms have "Limsup F f \<ge> 0" by (intro le_Limsup) simp_all
hence "inv (Limsup F f) = inverse (Limsup F f)" by (simp add: inv_def)
finally show "Liminf F (\<lambda>x. inverse (f x)) = inverse (Limsup F f)" .
have "Limsup F (\<lambda>x. inverse (f x)) = Limsup F (\<lambda>x. inv (f x))" using nonneg
by (auto intro!: Limsup_eq elim!: eventually_mono simp: inv_def)
also have "... = inv (Liminf F f)"
by (simp add: assms(1) Limsup_compose_continuous_antimono[OF cont antimono])
also from assms have "Liminf F f \<ge> 0" by (intro Liminf_bounded) simp_all
hence "inv (Liminf F f) = inverse (Liminf F f)" by (simp add: inv_def)
finally show "Limsup F (\<lambda>x. inverse (f x)) = inverse (Liminf F f)" .
qed
lemma less_LiminfD:
"y < Liminf F (f :: _ \<Rightarrow> 'a :: complete_linorder) \<Longrightarrow> eventually (\<lambda>x. f x > y) F"
using le_Liminf_iff[of "Liminf F f" F f] by simp
lemma gt_LimsupD:
"y > Limsup F (f :: _ \<Rightarrow> 'a :: complete_linorder) \<Longrightarrow> eventually (\<lambda>x. f x < y) F"
using ge_Limsup_iff[of F f "Limsup F f"] by simp
end |
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
⊢ Injective boxes
[PROOFSTEP]
rintro ⟨s₁, h₁, h₁'⟩ ⟨s₂, h₂, h₂'⟩ (rfl : s₁ = s₂)
[GOAL]
case mk.mk
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
s₁ : Finset (Box ι)
h₁ : ∀ (J : Box ι), J ∈ s₁ → J ≤ I
h₁' : Set.Pairwise (↑s₁) (Disjoint on Box.toSet)
h₂ : ∀ (J : Box ι), J ∈ s₁ → J ≤ I
h₂' : Set.Pairwise (↑s₁) (Disjoint on Box.toSet)
⊢ { boxes := s₁, le_of_mem' := h₁, pairwiseDisjoint := h₁' } =
{ boxes := s₁, le_of_mem' := h₂, pairwiseDisjoint := h₂' }
[PROOFSTEP]
rfl
[GOAL]
ι : Type u_1
I✝ J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I✝
x : ι → ℝ
I J : Box ι
h : J ≤ I
⊢ ∀ (J_1 : Box ι), J_1 ∈ {J} → J_1 ≤ I
[PROOFSTEP]
simpa
[GOAL]
ι : Type u_1
I✝ J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I✝
x : ι → ℝ
I J : Box ι
h : J ≤ I
⊢ Set.Pairwise (↑{J}) (Disjoint on Box.toSet)
[PROOFSTEP]
simp
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
⊢ ∀ (a b : Prepartition I), a ≤ b → b ≤ a → a = b
[PROOFSTEP]
suffices : ∀ {π₁ π₂ : Prepartition I}, π₁ ≤ π₂ → π₂ ≤ π₁ → π₁.boxes ⊆ π₂.boxes
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
this : ∀ {π₁ π₂ : Prepartition I}, π₁ ≤ π₂ → π₂ ≤ π₁ → π₁.boxes ⊆ π₂.boxes
⊢ ∀ (a b : Prepartition I), a ≤ b → b ≤ a → a = b
case this
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
⊢ ∀ {π₁ π₂ : Prepartition I}, π₁ ≤ π₂ → π₂ ≤ π₁ → π₁.boxes ⊆ π₂.boxes
[PROOFSTEP]
exact fun π₁ π₂ h₁ h₂ => injective_boxes (Subset.antisymm (this h₁ h₂) (this h₂ h₁))
[GOAL]
case this
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
⊢ ∀ {π₁ π₂ : Prepartition I}, π₁ ≤ π₂ → π₂ ≤ π₁ → π₁.boxes ⊆ π₂.boxes
[PROOFSTEP]
intro π₁ π₂ h₁ h₂ J hJ
[GOAL]
case this
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁✝ π₂✝ : Prepartition I
x : ι → ℝ
π₁ π₂ : Prepartition I
h₁ : π₁ ≤ π₂
h₂ : π₂ ≤ π₁
J : Box ι
hJ : J ∈ π₁.boxes
⊢ J ∈ π₂.boxes
[PROOFSTEP]
rcases h₁ hJ with ⟨J', hJ', hle⟩
[GOAL]
case this.intro.intro
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁✝ π₂✝ : Prepartition I
x : ι → ℝ
π₁ π₂ : Prepartition I
h₁ : π₁ ≤ π₂
h₂ : π₂ ≤ π₁
J : Box ι
hJ : J ∈ π₁.boxes
J' : Box ι
hJ' : J' ∈ π₂
hle : J ≤ J'
⊢ J ∈ π₂.boxes
[PROOFSTEP]
rcases h₂ hJ' with ⟨J'', hJ'', hle'⟩
[GOAL]
case this.intro.intro.intro.intro
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁✝ π₂✝ : Prepartition I
x : ι → ℝ
π₁ π₂ : Prepartition I
h₁ : π₁ ≤ π₂
h₂ : π₂ ≤ π₁
J : Box ι
hJ : J ∈ π₁.boxes
J' : Box ι
hJ' : J' ∈ π₂
hle : J ≤ J'
J'' : Box ι
hJ'' : J'' ∈ π₁
hle' : J' ≤ J''
⊢ J ∈ π₂.boxes
[PROOFSTEP]
obtain rfl : J = J''
[GOAL]
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁✝ π₂✝ : Prepartition I
x : ι → ℝ
π₁ π₂ : Prepartition I
h₁ : π₁ ≤ π₂
h₂ : π₂ ≤ π₁
J : Box ι
hJ : J ∈ π₁.boxes
J' : Box ι
hJ' : J' ∈ π₂
hle : J ≤ J'
J'' : Box ι
hJ'' : J'' ∈ π₁
hle' : J' ≤ J''
⊢ J = J''
case this.intro.intro.intro.intro
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁✝ π₂✝ : Prepartition I
x : ι → ℝ
π₁ π₂ : Prepartition I
h₁ : π₁ ≤ π₂
h₂ : π₂ ≤ π₁
J : Box ι
hJ : J ∈ π₁.boxes
J' : Box ι
hJ' : J' ∈ π₂
hle : J ≤ J'
hJ'' : J ∈ π₁
hle' : J' ≤ J
⊢ J ∈ π₂.boxes
[PROOFSTEP]
exact π₁.eq_of_le hJ hJ'' (hle.trans hle')
[GOAL]
case this.intro.intro.intro.intro
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁✝ π₂✝ : Prepartition I
x : ι → ℝ
π₁ π₂ : Prepartition I
h₁ : π₁ ≤ π₂
h₂ : π₂ ≤ π₁
J : Box ι
hJ : J ∈ π₁.boxes
J' : Box ι
hJ' : J' ∈ π₂
hle : J ≤ J'
hJ'' : J ∈ π₁
hle' : J' ≤ J
⊢ J ∈ π₂.boxes
[PROOFSTEP]
obtain rfl : J' = J
[GOAL]
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁✝ π₂✝ : Prepartition I
x : ι → ℝ
π₁ π₂ : Prepartition I
h₁ : π₁ ≤ π₂
h₂ : π₂ ≤ π₁
J : Box ι
hJ : J ∈ π₁.boxes
J' : Box ι
hJ' : J' ∈ π₂
hle : J ≤ J'
hJ'' : J ∈ π₁
hle' : J' ≤ J
⊢ J' = J
case this.intro.intro.intro.intro
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁✝ π₂✝ : Prepartition I
x : ι → ℝ
π₁ π₂ : Prepartition I
h₁ : π₁ ≤ π₂
h₂ : π₂ ≤ π₁
J' : Box ι
hJ' : J' ∈ π₂
hJ : J' ∈ π₁.boxes
hle : J' ≤ J'
hJ'' : J' ∈ π₁
hle' : J' ≤ J'
⊢ J' ∈ π₂.boxes
[PROOFSTEP]
exact le_antisymm ‹_› ‹_›
[GOAL]
case this.intro.intro.intro.intro
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁✝ π₂✝ : Prepartition I
x : ι → ℝ
π₁ π₂ : Prepartition I
h₁ : π₁ ≤ π₂
h₂ : π₂ ≤ π₁
J' : Box ι
hJ' : J' ∈ π₂
hJ : J' ∈ π₁.boxes
hle : J' ≤ J'
hJ'' : J' ∈ π₁
hle' : J' ≤ J'
⊢ J' ∈ π₂.boxes
[PROOFSTEP]
assumption
[GOAL]
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π✝ π₁ π₂ : Prepartition I
x : ι → ℝ
π : Prepartition I
J : Box ι
hJ : J ∈ π
⊢ I ∈ ⊤
[PROOFSTEP]
simp
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x✝ x : ι → ℝ
⊢ InjOn (fun J => {i | Box.lower J i = x i}) {J | J ∈ π ∧ x ∈ ↑Box.Icc J}
[PROOFSTEP]
rintro J₁ ⟨h₁, hx₁⟩ J₂ ⟨h₂, hx₂⟩ (H : {i | J₁.lower i = x i} = {i | J₂.lower i = x i})
[GOAL]
case intro.intro
ι : Type u_1
I J J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x✝ x : ι → ℝ
J₁ : Box ι
h₁ : J₁ ∈ π
hx₁ : x ∈ ↑Box.Icc J₁
J₂ : Box ι
h₂ : J₂ ∈ π
hx₂ : x ∈ ↑Box.Icc J₂
H : {i | Box.lower J₁ i = x i} = {i | Box.lower J₂ i = x i}
⊢ J₁ = J₂
[PROOFSTEP]
suffices ∀ i, (Ioc (J₁.lower i) (J₁.upper i) ∩ Ioc (J₂.lower i) (J₂.upper i)).Nonempty
by
choose y hy₁ hy₂ using this
exact π.eq_of_mem_of_mem h₁ h₂ hy₁ hy₂
[GOAL]
ι : Type u_1
I J J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x✝ x : ι → ℝ
J₁ : Box ι
h₁ : J₁ ∈ π
hx₁ : x ∈ ↑Box.Icc J₁
J₂ : Box ι
h₂ : J₂ ∈ π
hx₂ : x ∈ ↑Box.Icc J₂
H : {i | Box.lower J₁ i = x i} = {i | Box.lower J₂ i = x i}
this : ∀ (i : ι), Set.Nonempty (Set.Ioc (Box.lower J₁ i) (Box.upper J₁ i) ∩ Set.Ioc (Box.lower J₂ i) (Box.upper J₂ i))
⊢ J₁ = J₂
[PROOFSTEP]
choose y hy₁ hy₂ using this
[GOAL]
ι : Type u_1
I J J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x✝ x : ι → ℝ
J₁ : Box ι
h₁ : J₁ ∈ π
hx₁ : x ∈ ↑Box.Icc J₁
J₂ : Box ι
h₂ : J₂ ∈ π
hx₂ : x ∈ ↑Box.Icc J₂
H : {i | Box.lower J₁ i = x i} = {i | Box.lower J₂ i = x i}
y : ι → ℝ
hy₁ : ∀ (i : ι), y i ∈ Set.Ioc (Box.lower J₁ i) (Box.upper J₁ i)
hy₂ : ∀ (i : ι), y i ∈ Set.Ioc (Box.lower J₂ i) (Box.upper J₂ i)
⊢ J₁ = J₂
[PROOFSTEP]
exact π.eq_of_mem_of_mem h₁ h₂ hy₁ hy₂
[GOAL]
case intro.intro
ι : Type u_1
I J J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x✝ x : ι → ℝ
J₁ : Box ι
h₁ : J₁ ∈ π
hx₁ : x ∈ ↑Box.Icc J₁
J₂ : Box ι
h₂ : J₂ ∈ π
hx₂ : x ∈ ↑Box.Icc J₂
H : {i | Box.lower J₁ i = x i} = {i | Box.lower J₂ i = x i}
⊢ ∀ (i : ι), Set.Nonempty (Set.Ioc (Box.lower J₁ i) (Box.upper J₁ i) ∩ Set.Ioc (Box.lower J₂ i) (Box.upper J₂ i))
[PROOFSTEP]
intro i
[GOAL]
case intro.intro
ι : Type u_1
I J J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x✝ x : ι → ℝ
J₁ : Box ι
h₁ : J₁ ∈ π
hx₁ : x ∈ ↑Box.Icc J₁
J₂ : Box ι
h₂ : J₂ ∈ π
hx₂ : x ∈ ↑Box.Icc J₂
H : {i | Box.lower J₁ i = x i} = {i | Box.lower J₂ i = x i}
i : ι
⊢ Set.Nonempty (Set.Ioc (Box.lower J₁ i) (Box.upper J₁ i) ∩ Set.Ioc (Box.lower J₂ i) (Box.upper J₂ i))
[PROOFSTEP]
simp only [Set.ext_iff, mem_setOf] at H
[GOAL]
case intro.intro
ι : Type u_1
I J J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x✝ x : ι → ℝ
J₁ : Box ι
h₁ : J₁ ∈ π
hx₁ : x ∈ ↑Box.Icc J₁
J₂ : Box ι
h₂ : J₂ ∈ π
hx₂ : x ∈ ↑Box.Icc J₂
i : ι
H : ∀ (x_1 : ι), Box.lower J₁ x_1 = x x_1 ↔ Box.lower J₂ x_1 = x x_1
⊢ Set.Nonempty (Set.Ioc (Box.lower J₁ i) (Box.upper J₁ i) ∩ Set.Ioc (Box.lower J₂ i) (Box.upper J₂ i))
[PROOFSTEP]
cases' (hx₁.1 i).eq_or_lt with hi₁ hi₁
[GOAL]
case intro.intro.inl
ι : Type u_1
I J J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x✝ x : ι → ℝ
J₁ : Box ι
h₁ : J₁ ∈ π
hx₁ : x ∈ ↑Box.Icc J₁
J₂ : Box ι
h₂ : J₂ ∈ π
hx₂ : x ∈ ↑Box.Icc J₂
i : ι
H : ∀ (x_1 : ι), Box.lower J₁ x_1 = x x_1 ↔ Box.lower J₂ x_1 = x x_1
hi₁ : Box.lower J₁ i = x i
⊢ Set.Nonempty (Set.Ioc (Box.lower J₁ i) (Box.upper J₁ i) ∩ Set.Ioc (Box.lower J₂ i) (Box.upper J₂ i))
[PROOFSTEP]
have hi₂ : J₂.lower i = x i := (H _).1 hi₁
[GOAL]
case intro.intro.inl
ι : Type u_1
I J J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x✝ x : ι → ℝ
J₁ : Box ι
h₁ : J₁ ∈ π
hx₁ : x ∈ ↑Box.Icc J₁
J₂ : Box ι
h₂ : J₂ ∈ π
hx₂ : x ∈ ↑Box.Icc J₂
i : ι
H : ∀ (x_1 : ι), Box.lower J₁ x_1 = x x_1 ↔ Box.lower J₂ x_1 = x x_1
hi₁ : Box.lower J₁ i = x i
hi₂ : Box.lower J₂ i = x i
⊢ Set.Nonempty (Set.Ioc (Box.lower J₁ i) (Box.upper J₁ i) ∩ Set.Ioc (Box.lower J₂ i) (Box.upper J₂ i))
[PROOFSTEP]
have H₁ : x i < J₁.upper i := by simpa only [hi₁] using J₁.lower_lt_upper i
[GOAL]
ι : Type u_1
I J J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x✝ x : ι → ℝ
J₁ : Box ι
h₁ : J₁ ∈ π
hx₁ : x ∈ ↑Box.Icc J₁
J₂ : Box ι
h₂ : J₂ ∈ π
hx₂ : x ∈ ↑Box.Icc J₂
i : ι
H : ∀ (x_1 : ι), Box.lower J₁ x_1 = x x_1 ↔ Box.lower J₂ x_1 = x x_1
hi₁ : Box.lower J₁ i = x i
hi₂ : Box.lower J₂ i = x i
⊢ x i < Box.upper J₁ i
[PROOFSTEP]
simpa only [hi₁] using J₁.lower_lt_upper i
[GOAL]
case intro.intro.inl
ι : Type u_1
I J J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x✝ x : ι → ℝ
J₁ : Box ι
h₁ : J₁ ∈ π
hx₁ : x ∈ ↑Box.Icc J₁
J₂ : Box ι
h₂ : J₂ ∈ π
hx₂ : x ∈ ↑Box.Icc J₂
i : ι
H : ∀ (x_1 : ι), Box.lower J₁ x_1 = x x_1 ↔ Box.lower J₂ x_1 = x x_1
hi₁ : Box.lower J₁ i = x i
hi₂ : Box.lower J₂ i = x i
H₁ : x i < Box.upper J₁ i
⊢ Set.Nonempty (Set.Ioc (Box.lower J₁ i) (Box.upper J₁ i) ∩ Set.Ioc (Box.lower J₂ i) (Box.upper J₂ i))
[PROOFSTEP]
have H₂ : x i < J₂.upper i := by simpa only [hi₂] using J₂.lower_lt_upper i
[GOAL]
ι : Type u_1
I J J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x✝ x : ι → ℝ
J₁ : Box ι
h₁ : J₁ ∈ π
hx₁ : x ∈ ↑Box.Icc J₁
J₂ : Box ι
h₂ : J₂ ∈ π
hx₂ : x ∈ ↑Box.Icc J₂
i : ι
H : ∀ (x_1 : ι), Box.lower J₁ x_1 = x x_1 ↔ Box.lower J₂ x_1 = x x_1
hi₁ : Box.lower J₁ i = x i
hi₂ : Box.lower J₂ i = x i
H₁ : x i < Box.upper J₁ i
⊢ x i < Box.upper J₂ i
[PROOFSTEP]
simpa only [hi₂] using J₂.lower_lt_upper i
[GOAL]
case intro.intro.inl
ι : Type u_1
I J J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x✝ x : ι → ℝ
J₁ : Box ι
h₁ : J₁ ∈ π
hx₁ : x ∈ ↑Box.Icc J₁
J₂ : Box ι
h₂ : J₂ ∈ π
hx₂ : x ∈ ↑Box.Icc J₂
i : ι
H : ∀ (x_1 : ι), Box.lower J₁ x_1 = x x_1 ↔ Box.lower J₂ x_1 = x x_1
hi₁ : Box.lower J₁ i = x i
hi₂ : Box.lower J₂ i = x i
H₁ : x i < Box.upper J₁ i
H₂ : x i < Box.upper J₂ i
⊢ Set.Nonempty (Set.Ioc (Box.lower J₁ i) (Box.upper J₁ i) ∩ Set.Ioc (Box.lower J₂ i) (Box.upper J₂ i))
[PROOFSTEP]
rw [Ioc_inter_Ioc, hi₁, hi₂, sup_idem, Set.nonempty_Ioc]
[GOAL]
case intro.intro.inl
ι : Type u_1
I J J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x✝ x : ι → ℝ
J₁ : Box ι
h₁ : J₁ ∈ π
hx₁ : x ∈ ↑Box.Icc J₁
J₂ : Box ι
h₂ : J₂ ∈ π
hx₂ : x ∈ ↑Box.Icc J₂
i : ι
H : ∀ (x_1 : ι), Box.lower J₁ x_1 = x x_1 ↔ Box.lower J₂ x_1 = x x_1
hi₁ : Box.lower J₁ i = x i
hi₂ : Box.lower J₂ i = x i
H₁ : x i < Box.upper J₁ i
H₂ : x i < Box.upper J₂ i
⊢ x i < Box.upper J₁ i ⊓ Box.upper J₂ i
[PROOFSTEP]
exact lt_min H₁ H₂
[GOAL]
case intro.intro.inr
ι : Type u_1
I J J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x✝ x : ι → ℝ
J₁ : Box ι
h₁ : J₁ ∈ π
hx₁ : x ∈ ↑Box.Icc J₁
J₂ : Box ι
h₂ : J₂ ∈ π
hx₂ : x ∈ ↑Box.Icc J₂
i : ι
H : ∀ (x_1 : ι), Box.lower J₁ x_1 = x x_1 ↔ Box.lower J₂ x_1 = x x_1
hi₁ : Box.lower J₁ i < x i
⊢ Set.Nonempty (Set.Ioc (Box.lower J₁ i) (Box.upper J₁ i) ∩ Set.Ioc (Box.lower J₂ i) (Box.upper J₂ i))
[PROOFSTEP]
have hi₂ : J₂.lower i < x i := (hx₂.1 i).lt_of_ne (mt (H _).2 hi₁.ne)
[GOAL]
case intro.intro.inr
ι : Type u_1
I J J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x✝ x : ι → ℝ
J₁ : Box ι
h₁ : J₁ ∈ π
hx₁ : x ∈ ↑Box.Icc J₁
J₂ : Box ι
h₂ : J₂ ∈ π
hx₂ : x ∈ ↑Box.Icc J₂
i : ι
H : ∀ (x_1 : ι), Box.lower J₁ x_1 = x x_1 ↔ Box.lower J₂ x_1 = x x_1
hi₁ : Box.lower J₁ i < x i
hi₂ : Box.lower J₂ i < x i
⊢ Set.Nonempty (Set.Ioc (Box.lower J₁ i) (Box.upper J₁ i) ∩ Set.Ioc (Box.lower J₂ i) (Box.upper J₂ i))
[PROOFSTEP]
exact ⟨x i, ⟨hi₁, hx₁.2 i⟩, ⟨hi₂, hx₂.2 i⟩⟩
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x✝ : ι → ℝ
inst✝ : Fintype ι
x : ι → ℝ
⊢ card (filter (fun J => x ∈ ↑Box.Icc J) π.boxes) ≤ 2 ^ Fintype.card ι
[PROOFSTEP]
rw [← Fintype.card_set]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x✝ : ι → ℝ
inst✝ : Fintype ι
x : ι → ℝ
⊢ card (filter (fun J => x ∈ ↑Box.Icc J) π.boxes) ≤ Fintype.card (Set ι)
[PROOFSTEP]
refine' Finset.card_le_card_of_inj_on (fun J : Box ι => {i | J.lower i = x i}) (fun _ _ => Finset.mem_univ _) _
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x✝ : ι → ℝ
inst✝ : Fintype ι
x : ι → ℝ
⊢ ∀ (a₁ : Box ι),
a₁ ∈ filter (fun J => x ∈ ↑Box.Icc J) π.boxes →
∀ (a₂ : Box ι),
a₂ ∈ filter (fun J => x ∈ ↑Box.Icc J) π.boxes →
(fun J => {i | Box.lower J i = x i}) a₁ = (fun J => {i | Box.lower J i = x i}) a₂ → a₁ = a₂
[PROOFSTEP]
simpa only [Finset.mem_filter] using π.injOn_setOf_mem_Icc_setOf_lower_eq x
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
⊢ x ∈ Prepartition.iUnion π ↔ ∃ J, J ∈ π ∧ x ∈ J
[PROOFSTEP]
convert Set.mem_iUnion₂
[GOAL]
case h.e'_2.h.e'_2.h.a
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
x✝ : Box ι
⊢ x✝ ∈ π ∧ x ∈ x✝ ↔ ∃ j, x ∈ ↑x✝
[PROOFSTEP]
rw [Box.mem_coe, exists_prop]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
h : J ≤ I
⊢ Prepartition.iUnion (single I J h) = ↑J
[PROOFSTEP]
simp [iUnion_def]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
⊢ Prepartition.iUnion ⊤ = ↑I
[PROOFSTEP]
simp [Prepartition.iUnion]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
⊢ Prepartition.iUnion π₁ = ∅ ↔ π₁ = ⊥
[PROOFSTEP]
simp [← injective_boxes.eq_iff, Finset.ext_iff, Prepartition.iUnion, imp_false]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
⊢ π₁ ≤ π₂ ↔
(∀ (J : Box ι), J ∈ π₁ → ∀ (J' : Box ι), J' ∈ π₂ → Set.Nonempty (↑J ∩ ↑J') → J ≤ J') ∧
Prepartition.iUnion π₁ ⊆ Prepartition.iUnion π₂
[PROOFSTEP]
constructor
[GOAL]
case mp
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
⊢ π₁ ≤ π₂ →
(∀ (J : Box ι), J ∈ π₁ → ∀ (J' : Box ι), J' ∈ π₂ → Set.Nonempty (↑J ∩ ↑J') → J ≤ J') ∧
Prepartition.iUnion π₁ ⊆ Prepartition.iUnion π₂
[PROOFSTEP]
refine' fun H => ⟨fun J hJ J' hJ' Hne => _, iUnion_mono H⟩
[GOAL]
case mp
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
H : π₁ ≤ π₂
J : Box ι
hJ : J ∈ π₁
J' : Box ι
hJ' : J' ∈ π₂
Hne : Set.Nonempty (↑J ∩ ↑J')
⊢ J ≤ J'
[PROOFSTEP]
rcases H hJ with ⟨J'', hJ'', Hle⟩
[GOAL]
case mp.intro.intro
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
H : π₁ ≤ π₂
J : Box ι
hJ : J ∈ π₁
J' : Box ι
hJ' : J' ∈ π₂
Hne : Set.Nonempty (↑J ∩ ↑J')
J'' : Box ι
hJ'' : J'' ∈ π₂
Hle : J ≤ J''
⊢ J ≤ J'
[PROOFSTEP]
rcases Hne with ⟨x, hx, hx'⟩
[GOAL]
case mp.intro.intro.intro.intro
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x✝ : ι → ℝ
H : π₁ ≤ π₂
J : Box ι
hJ : J ∈ π₁
J' : Box ι
hJ' : J' ∈ π₂
J'' : Box ι
hJ'' : J'' ∈ π₂
Hle : J ≤ J''
x : ι → ℝ
hx : x ∈ ↑J
hx' : x ∈ ↑J'
⊢ J ≤ J'
[PROOFSTEP]
rwa [π₂.eq_of_mem_of_mem hJ' hJ'' hx' (Hle hx)]
[GOAL]
case mpr
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
⊢ (∀ (J : Box ι), J ∈ π₁ → ∀ (J' : Box ι), J' ∈ π₂ → Set.Nonempty (↑J ∩ ↑J') → J ≤ J') ∧
Prepartition.iUnion π₁ ⊆ Prepartition.iUnion π₂ →
π₁ ≤ π₂
[PROOFSTEP]
rintro ⟨H, HU⟩ J hJ
[GOAL]
case mpr.intro
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
H : ∀ (J : Box ι), J ∈ π₁ → ∀ (J' : Box ι), J' ∈ π₂ → Set.Nonempty (↑J ∩ ↑J') → J ≤ J'
HU : Prepartition.iUnion π₁ ⊆ Prepartition.iUnion π₂
J : Box ι
hJ : J ∈ π₁
⊢ ∃ I', I' ∈ π₂ ∧ J ≤ I'
[PROOFSTEP]
simp only [Set.subset_def, mem_iUnion] at HU
[GOAL]
case mpr.intro
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
H : ∀ (J : Box ι), J ∈ π₁ → ∀ (J' : Box ι), J' ∈ π₂ → Set.Nonempty (↑J ∩ ↑J') → J ≤ J'
J : Box ι
hJ : J ∈ π₁
HU : ∀ (x : ι → ℝ), (∃ J, J ∈ π₁ ∧ x ∈ J) → ∃ J, J ∈ π₂ ∧ x ∈ J
⊢ ∃ I', I' ∈ π₂ ∧ J ≤ I'
[PROOFSTEP]
rcases HU J.upper ⟨J, hJ, J.upper_mem⟩ with ⟨J₂, hJ₂, hx⟩
[GOAL]
case mpr.intro.intro.intro
ι : Type u_1
I J✝ J₁ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
H : ∀ (J : Box ι), J ∈ π₁ → ∀ (J' : Box ι), J' ∈ π₂ → Set.Nonempty (↑J ∩ ↑J') → J ≤ J'
J : Box ι
hJ : J ∈ π₁
HU : ∀ (x : ι → ℝ), (∃ J, J ∈ π₁ ∧ x ∈ J) → ∃ J, J ∈ π₂ ∧ x ∈ J
J₂ : Box ι
hJ₂ : J₂ ∈ π₂
hx : J.upper ∈ J₂
⊢ ∃ I', I' ∈ π₂ ∧ J ≤ I'
[PROOFSTEP]
exact ⟨J₂, hJ₂, H _ hJ _ hJ₂ ⟨_, J.upper_mem, hx⟩⟩
[GOAL]
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi : (J : Box ι) → Prepartition J
J : Box ι
hJ : J ∈ Finset.biUnion π.boxes fun J => (πi J).boxes
⊢ J ≤ I
[PROOFSTEP]
simp only [Finset.mem_biUnion, exists_prop, mem_boxes] at hJ
[GOAL]
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi : (J : Box ι) → Prepartition J
J : Box ι
hJ : ∃ a, a ∈ π ∧ J ∈ πi a
⊢ J ≤ I
[PROOFSTEP]
rcases hJ with ⟨J', hJ', hJ⟩
[GOAL]
case intro.intro
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi : (J : Box ι) → Prepartition J
J J' : Box ι
hJ' : J' ∈ π
hJ : J ∈ πi J'
⊢ J ≤ I
[PROOFSTEP]
exact ((πi J').le_of_mem hJ).trans (π.le_of_mem hJ')
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi : (J : Box ι) → Prepartition J
⊢ Set.Pairwise (↑(Finset.biUnion π.boxes fun J => (πi J).boxes)) (Disjoint on Box.toSet)
[PROOFSTEP]
simp only [Set.Pairwise, Finset.mem_coe, Finset.mem_biUnion]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi : (J : Box ι) → Prepartition J
⊢ ∀ ⦃x : Box ι⦄,
(∃ a, a ∈ π.boxes ∧ x ∈ (πi a).boxes) →
∀ ⦃y : Box ι⦄, (∃ a, a ∈ π.boxes ∧ y ∈ (πi a).boxes) → x ≠ y → (Disjoint on Box.toSet) x y
[PROOFSTEP]
rintro J₁' ⟨J₁, hJ₁, hJ₁'⟩ J₂' ⟨J₂, hJ₂, hJ₂'⟩ Hne
[GOAL]
case intro.intro.intro.intro
ι : Type u_1
I J J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi : (J : Box ι) → Prepartition J
J₁' J₁ : Box ι
hJ₁ : J₁ ∈ π.boxes
hJ₁' : J₁' ∈ (πi J₁).boxes
J₂' J₂ : Box ι
hJ₂ : J₂ ∈ π.boxes
hJ₂' : J₂' ∈ (πi J₂).boxes
Hne : J₁' ≠ J₂'
⊢ (Disjoint on Box.toSet) J₁' J₂'
[PROOFSTEP]
rw [Function.onFun, Set.disjoint_left]
[GOAL]
case intro.intro.intro.intro
ι : Type u_1
I J J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi : (J : Box ι) → Prepartition J
J₁' J₁ : Box ι
hJ₁ : J₁ ∈ π.boxes
hJ₁' : J₁' ∈ (πi J₁).boxes
J₂' J₂ : Box ι
hJ₂ : J₂ ∈ π.boxes
hJ₂' : J₂' ∈ (πi J₂).boxes
Hne : J₁' ≠ J₂'
⊢ ∀ ⦃a : ι → ℝ⦄, a ∈ ↑J₁' → ¬a ∈ ↑J₂'
[PROOFSTEP]
rintro x hx₁ hx₂
[GOAL]
case intro.intro.intro.intro
ι : Type u_1
I J J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x✝ : ι → ℝ
πi : (J : Box ι) → Prepartition J
J₁' J₁ : Box ι
hJ₁ : J₁ ∈ π.boxes
hJ₁' : J₁' ∈ (πi J₁).boxes
J₂' J₂ : Box ι
hJ₂ : J₂ ∈ π.boxes
hJ₂' : J₂' ∈ (πi J₂).boxes
Hne : J₁' ≠ J₂'
x : ι → ℝ
hx₁ : x ∈ ↑J₁'
hx₂ : x ∈ ↑J₂'
⊢ False
[PROOFSTEP]
apply Hne
[GOAL]
case intro.intro.intro.intro
ι : Type u_1
I J J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x✝ : ι → ℝ
πi : (J : Box ι) → Prepartition J
J₁' J₁ : Box ι
hJ₁ : J₁ ∈ π.boxes
hJ₁' : J₁' ∈ (πi J₁).boxes
J₂' J₂ : Box ι
hJ₂ : J₂ ∈ π.boxes
hJ₂' : J₂' ∈ (πi J₂).boxes
Hne : J₁' ≠ J₂'
x : ι → ℝ
hx₁ : x ∈ ↑J₁'
hx₂ : x ∈ ↑J₂'
⊢ J₁' = J₂'
[PROOFSTEP]
obtain rfl : J₁ = J₂
[GOAL]
ι : Type u_1
I J J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x✝ : ι → ℝ
πi : (J : Box ι) → Prepartition J
J₁' J₁ : Box ι
hJ₁ : J₁ ∈ π.boxes
hJ₁' : J₁' ∈ (πi J₁).boxes
J₂' J₂ : Box ι
hJ₂ : J₂ ∈ π.boxes
hJ₂' : J₂' ∈ (πi J₂).boxes
Hne : J₁' ≠ J₂'
x : ι → ℝ
hx₁ : x ∈ ↑J₁'
hx₂ : x ∈ ↑J₂'
⊢ J₁ = J₂
case intro.intro.intro.intro
ι : Type u_1
I J J₁✝ J₂ : Box ι
π π₁ π₂ : Prepartition I
x✝ : ι → ℝ
πi : (J : Box ι) → Prepartition J
J₁' J₁ : Box ι
hJ₁ : J₁ ∈ π.boxes
hJ₁' : J₁' ∈ (πi J₁).boxes
J₂' : Box ι
Hne : J₁' ≠ J₂'
x : ι → ℝ
hx₁ : x ∈ ↑J₁'
hx₂ : x ∈ ↑J₂'
hJ₂ : J₁ ∈ π.boxes
hJ₂' : J₂' ∈ (πi J₁).boxes
⊢ J₁' = J₂'
[PROOFSTEP]
exact π.eq_of_mem_of_mem hJ₁ hJ₂ ((πi J₁).le_of_mem hJ₁' hx₁) ((πi J₂).le_of_mem hJ₂' hx₂)
[GOAL]
case intro.intro.intro.intro
ι : Type u_1
I J J₁✝ J₂ : Box ι
π π₁ π₂ : Prepartition I
x✝ : ι → ℝ
πi : (J : Box ι) → Prepartition J
J₁' J₁ : Box ι
hJ₁ : J₁ ∈ π.boxes
hJ₁' : J₁' ∈ (πi J₁).boxes
J₂' : Box ι
Hne : J₁' ≠ J₂'
x : ι → ℝ
hx₁ : x ∈ ↑J₁'
hx₂ : x ∈ ↑J₂'
hJ₂ : J₁ ∈ π.boxes
hJ₂' : J₂' ∈ (πi J₁).boxes
⊢ J₁' = J₂'
[PROOFSTEP]
exact (πi J₁).eq_of_mem_of_mem hJ₁' hJ₂' hx₁ hx₂
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
⊢ J ∈ biUnion π πi ↔ ∃ J', J' ∈ π ∧ J ∈ πi J'
[PROOFSTEP]
simp [biUnion]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
⊢ (biUnion π fun x => ⊤) = π
[PROOFSTEP]
ext
[GOAL]
case h
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
J✝ : Box ι
⊢ (J✝ ∈ biUnion π fun x => ⊤) ↔ J✝ ∈ π
[PROOFSTEP]
simp
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
h : π₁ = π₂
hi : ∀ (J : Box ι), J ∈ π₁ → πi₁ J = πi₂ J
⊢ biUnion π₁ πi₁ = biUnion π₂ πi₂
[PROOFSTEP]
subst π₂
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
hi : ∀ (J : Box ι), J ∈ π₁ → πi₁ J = πi₂ J
⊢ biUnion π₁ πi₁ = biUnion π₁ πi₂
[PROOFSTEP]
ext J
[GOAL]
case h
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
hi : ∀ (J : Box ι), J ∈ π₁ → πi₁ J = πi₂ J
J : Box ι
⊢ J ∈ biUnion π₁ πi₁ ↔ J ∈ biUnion π₁ πi₂
[PROOFSTEP]
simp only [mem_biUnion]
[GOAL]
case h
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
hi : ∀ (J : Box ι), J ∈ π₁ → πi₁ J = πi₂ J
J : Box ι
⊢ (∃ J', J' ∈ π₁ ∧ J ∈ πi₁ J') ↔ ∃ J', J' ∈ π₁ ∧ J ∈ πi₂ J'
[PROOFSTEP]
constructor
[GOAL]
case h.mp
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
hi : ∀ (J : Box ι), J ∈ π₁ → πi₁ J = πi₂ J
J : Box ι
⊢ (∃ J', J' ∈ π₁ ∧ J ∈ πi₁ J') → ∃ J', J' ∈ π₁ ∧ J ∈ πi₂ J'
[PROOFSTEP]
exact fun ⟨J', h₁, h₂⟩ => ⟨J', h₁, hi J' h₁ ▸ h₂⟩
[GOAL]
case h.mpr
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
hi : ∀ (J : Box ι), J ∈ π₁ → πi₁ J = πi₂ J
J : Box ι
⊢ (∃ J', J' ∈ π₁ ∧ J ∈ πi₂ J') → ∃ J', J' ∈ π₁ ∧ J ∈ πi₁ J'
[PROOFSTEP]
exact fun ⟨J', h₁, h₂⟩ => ⟨J', h₁, hi J' h₁ ▸ h₂⟩
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
⊢ Prepartition.iUnion (biUnion π πi) = ⋃ (J : Box ι) (_ : J ∈ π), Prepartition.iUnion (πi J)
[PROOFSTEP]
simp [Prepartition.iUnion]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π✝ π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ : (J : Box ι) → Prepartition J
M : Type u_2
inst✝ : AddCommMonoid M
π : Prepartition I
πi : (J : Box ι) → Prepartition J
f : Box ι → M
⊢ ∑ J in Finset.biUnion π.boxes fun J => (πi J).boxes, f J = ∑ J in π.boxes, ∑ J' in (πi J).boxes, f J'
[PROOFSTEP]
refine' Finset.sum_biUnion fun J₁ h₁ J₂ h₂ hne => Finset.disjoint_left.2 fun J' h₁' h₂' => _
[GOAL]
ι : Type u_1
I J J₁✝ J₂✝ : Box ι
π✝ π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ : (J : Box ι) → Prepartition J
M : Type u_2
inst✝ : AddCommMonoid M
π : Prepartition I
πi : (J : Box ι) → Prepartition J
f : Box ι → M
J₁ : Box ι
h₁ : J₁ ∈ ↑π.boxes
J₂ : Box ι
h₂ : J₂ ∈ ↑π.boxes
hne : J₁ ≠ J₂
J' : Box ι
h₁' : J' ∈ (fun J => (πi J).boxes) J₁
h₂' : J' ∈ (fun J => (πi J).boxes) J₂
⊢ False
[PROOFSTEP]
exact hne (π.eq_of_le_of_le h₁ h₂ ((πi J₁).le_of_mem h₁') ((πi J₂).le_of_mem h₂'))
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
hJ : J ∈ biUnion π πi
⊢ biUnionIndex π πi J ∈ π
[PROOFSTEP]
rw [biUnionIndex, dif_pos hJ]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
hJ : J ∈ biUnion π πi
⊢ Exists.choose (_ : ∃ J', J' ∈ π ∧ J ∈ πi J') ∈ π
[PROOFSTEP]
exact (π.mem_biUnion.1 hJ).choose_spec.1
[GOAL]
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
J : Box ι
⊢ biUnionIndex π πi J ≤ I
[PROOFSTEP]
by_cases hJ : J ∈ π.biUnion πi
[GOAL]
case pos
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
J : Box ι
hJ : J ∈ biUnion π πi
⊢ biUnionIndex π πi J ≤ I
[PROOFSTEP]
exact π.le_of_mem (π.biUnionIndex_mem hJ)
[GOAL]
case neg
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
J : Box ι
hJ : ¬J ∈ biUnion π πi
⊢ biUnionIndex π πi J ≤ I
[PROOFSTEP]
rw [biUnionIndex, dif_neg hJ]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
hJ : J ∈ biUnion π πi
⊢ J ∈ πi (biUnionIndex π πi J)
[PROOFSTEP]
convert (π.mem_biUnion.1 hJ).choose_spec.2
[GOAL]
case h.e'_2.h.e'_2
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
hJ : J ∈ biUnion π πi
⊢ biUnionIndex π πi J = Exists.choose (_ : ∃ J', J' ∈ π ∧ J ∈ πi J')
[PROOFSTEP]
exact dif_pos hJ
[GOAL]
case h.e'_3.e'_2
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
hJ : J ∈ biUnion π πi
e_2✝ : Prepartition (biUnionIndex π πi J) = Prepartition (Exists.choose (_ : ∃ J', J' ∈ π ∧ J ∈ πi J'))
⊢ biUnionIndex π πi J = Exists.choose (_ : ∃ J', J' ∈ π ∧ J ∈ πi J')
[PROOFSTEP]
exact dif_pos hJ
[GOAL]
case h.e'_5.e'_1
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
hJ : J ∈ biUnion π πi
e_2✝ : Prepartition (biUnionIndex π πi J) = Prepartition (Exists.choose (_ : ∃ J', J' ∈ π ∧ J ∈ πi J'))
⊢ biUnionIndex π πi J = Exists.choose (_ : ∃ J', J' ∈ π ∧ J ∈ πi J')
[PROOFSTEP]
exact dif_pos hJ
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
πi' : Box ι → (J : Box ι) → Prepartition J
⊢ (biUnion π fun J => biUnion (πi J) (πi' J)) = biUnion (biUnion π πi) fun J => πi' (biUnionIndex π πi J) J
[PROOFSTEP]
ext J
[GOAL]
case h
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
πi' : Box ι → (J : Box ι) → Prepartition J
J : Box ι
⊢ (J ∈ biUnion π fun J => biUnion (πi J) (πi' J)) ↔ J ∈ biUnion (biUnion π πi) fun J => πi' (biUnionIndex π πi J) J
[PROOFSTEP]
simp only [mem_biUnion, exists_prop]
[GOAL]
case h
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
πi' : Box ι → (J : Box ι) → Prepartition J
J : Box ι
⊢ (∃ J', J' ∈ π ∧ ∃ J'_1, J'_1 ∈ πi J' ∧ J ∈ πi' J' J'_1) ↔
∃ J', (∃ J'_1, J'_1 ∈ π ∧ J' ∈ πi J'_1) ∧ J ∈ πi' (biUnionIndex π πi J') J'
[PROOFSTEP]
constructor
[GOAL]
case h.mp
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
πi' : Box ι → (J : Box ι) → Prepartition J
J : Box ι
⊢ (∃ J', J' ∈ π ∧ ∃ J'_1, J'_1 ∈ πi J' ∧ J ∈ πi' J' J'_1) →
∃ J', (∃ J'_1, J'_1 ∈ π ∧ J' ∈ πi J'_1) ∧ J ∈ πi' (biUnionIndex π πi J') J'
[PROOFSTEP]
rintro ⟨J₁, hJ₁, J₂, hJ₂, hJ⟩
[GOAL]
case h.mp.intro.intro.intro.intro
ι : Type u_1
I J✝ J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
πi' : Box ι → (J : Box ι) → Prepartition J
J J₁ : Box ι
hJ₁ : J₁ ∈ π
J₂ : Box ι
hJ₂ : J₂ ∈ πi J₁
hJ : J ∈ πi' J₁ J₂
⊢ ∃ J', (∃ J'_1, J'_1 ∈ π ∧ J' ∈ πi J'_1) ∧ J ∈ πi' (biUnionIndex π πi J') J'
[PROOFSTEP]
refine' ⟨J₂, ⟨J₁, hJ₁, hJ₂⟩, _⟩
[GOAL]
case h.mp.intro.intro.intro.intro
ι : Type u_1
I J✝ J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
πi' : Box ι → (J : Box ι) → Prepartition J
J J₁ : Box ι
hJ₁ : J₁ ∈ π
J₂ : Box ι
hJ₂ : J₂ ∈ πi J₁
hJ : J ∈ πi' J₁ J₂
⊢ J ∈ πi' (biUnionIndex π πi J₂) J₂
[PROOFSTEP]
rwa [π.biUnionIndex_of_mem hJ₁ hJ₂]
[GOAL]
case h.mpr
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
πi' : Box ι → (J : Box ι) → Prepartition J
J : Box ι
⊢ (∃ J', (∃ J'_1, J'_1 ∈ π ∧ J' ∈ πi J'_1) ∧ J ∈ πi' (biUnionIndex π πi J') J') →
∃ J', J' ∈ π ∧ ∃ J'_1, J'_1 ∈ πi J' ∧ J ∈ πi' J' J'_1
[PROOFSTEP]
rintro ⟨J₁, ⟨J₂, hJ₂, hJ₁⟩, hJ⟩
[GOAL]
case h.mpr.intro.intro.intro.intro
ι : Type u_1
I J✝ J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
πi' : Box ι → (J : Box ι) → Prepartition J
J J₁ : Box ι
hJ : J ∈ πi' (biUnionIndex π πi J₁) J₁
J₂ : Box ι
hJ₂ : J₂ ∈ π
hJ₁ : J₁ ∈ πi J₂
⊢ ∃ J', J' ∈ π ∧ ∃ J'_1, J'_1 ∈ πi J' ∧ J ∈ πi' J' J'_1
[PROOFSTEP]
refine' ⟨J₂, hJ₂, J₁, hJ₁, _⟩
[GOAL]
case h.mpr.intro.intro.intro.intro
ι : Type u_1
I J✝ J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
πi' : Box ι → (J : Box ι) → Prepartition J
J J₁ : Box ι
hJ : J ∈ πi' (biUnionIndex π πi J₁) J₁
J₂ : Box ι
hJ₂ : J₂ ∈ π
hJ₁ : J₁ ∈ πi J₂
⊢ J ∈ πi' J₂ J₁
[PROOFSTEP]
rwa [π.biUnionIndex_of_mem hJ₂ hJ₁] at hJ
[GOAL]
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
boxes : Finset (WithBot (Box ι))
le_of_mem : ∀ (J : WithBot (Box ι)), J ∈ boxes → J ≤ ↑I
pairwise_disjoint : Set.Pairwise (↑boxes) Disjoint
J : Box ι
hJ : J ∈ ↑eraseNone boxes
⊢ J ≤ I
[PROOFSTEP]
rw [mem_eraseNone] at hJ
[GOAL]
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
boxes : Finset (WithBot (Box ι))
le_of_mem : ∀ (J : WithBot (Box ι)), J ∈ boxes → J ≤ ↑I
pairwise_disjoint : Set.Pairwise (↑boxes) Disjoint
J : Box ι
hJ : some J ∈ boxes
⊢ J ≤ I
[PROOFSTEP]
simpa only [WithBot.some_eq_coe, WithBot.coe_le_coe] using le_of_mem _ hJ
[GOAL]
ι : Type u_1
I J J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
boxes : Finset (WithBot (Box ι))
le_of_mem : ∀ (J : WithBot (Box ι)), J ∈ boxes → J ≤ ↑I
pairwise_disjoint : Set.Pairwise (↑boxes) Disjoint
J₁ : Box ι
h₁ : J₁ ∈ ↑(↑eraseNone boxes)
J₂ : Box ι
h₂ : J₂ ∈ ↑(↑eraseNone boxes)
hne : J₁ ≠ J₂
⊢ (Disjoint on Box.toSet) J₁ J₂
[PROOFSTEP]
simp only [mem_coe, mem_eraseNone] at h₁ h₂
[GOAL]
ι : Type u_1
I J J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
boxes : Finset (WithBot (Box ι))
le_of_mem : ∀ (J : WithBot (Box ι)), J ∈ boxes → J ≤ ↑I
pairwise_disjoint : Set.Pairwise (↑boxes) Disjoint
J₁ J₂ : Box ι
hne : J₁ ≠ J₂
h₁ : some J₁ ∈ boxes
h₂ : some J₂ ∈ boxes
⊢ (Disjoint on Box.toSet) J₁ J₂
[PROOFSTEP]
exact Box.disjoint_coe.1 (pairwise_disjoint h₁ h₂ (mt Option.some_inj.1 hne))
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
boxes : Finset (WithBot (Box ι))
le_of_mem : ∀ (J : WithBot (Box ι)), J ∈ boxes → J ≤ ↑I
pairwise_disjoint : Set.Pairwise (↑boxes) Disjoint
⊢ Prepartition.iUnion (ofWithBot boxes le_of_mem pairwise_disjoint) = ⋃ (J : WithBot (Box ι)) (_ : J ∈ boxes), ↑J
[PROOFSTEP]
suffices ⋃ (J : Box ι) (_ : ↑J ∈ boxes), ↑J = ⋃ J ∈ boxes, (J : Set (ι → ℝ)) by simpa [ofWithBot, Prepartition.iUnion]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
boxes : Finset (WithBot (Box ι))
le_of_mem : ∀ (J : WithBot (Box ι)), J ∈ boxes → J ≤ ↑I
pairwise_disjoint : Set.Pairwise (↑boxes) Disjoint
this : ⋃ (J : Box ι) (_ : ↑J ∈ boxes), ↑J = ⋃ (J : WithBot (Box ι)) (_ : J ∈ boxes), ↑J
⊢ Prepartition.iUnion (ofWithBot boxes le_of_mem pairwise_disjoint) = ⋃ (J : WithBot (Box ι)) (_ : J ∈ boxes), ↑J
[PROOFSTEP]
simpa [ofWithBot, Prepartition.iUnion]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
boxes : Finset (WithBot (Box ι))
le_of_mem : ∀ (J : WithBot (Box ι)), J ∈ boxes → J ≤ ↑I
pairwise_disjoint : Set.Pairwise (↑boxes) Disjoint
⊢ ⋃ (J : Box ι) (_ : ↑J ∈ boxes), ↑J = ⋃ (J : WithBot (Box ι)) (_ : J ∈ boxes), ↑J
[PROOFSTEP]
simp only [← Box.biUnion_coe_eq_coe, @iUnion_comm _ _ (Box ι), @iUnion_comm _ _ (@Eq _ _ _), iUnion_iUnion_eq_right]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
boxes : Finset (WithBot (Box ι))
le_of_mem : ∀ (J : WithBot (Box ι)), J ∈ boxes → J ≤ ↑I
pairwise_disjoint : Set.Pairwise (↑boxes) Disjoint
H : ∀ (J : WithBot (Box ι)), J ∈ boxes → J ≠ ⊥ → ∃ J', J' ∈ π ∧ J ≤ ↑J'
⊢ ofWithBot boxes le_of_mem pairwise_disjoint ≤ π
[PROOFSTEP]
have : ∀ J : Box ι, ↑J ∈ boxes → ∃ J' ∈ π, J ≤ J' := fun J hJ => by
simpa only [WithBot.coe_le_coe] using H J hJ WithBot.coe_ne_bot
[GOAL]
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
boxes : Finset (WithBot (Box ι))
le_of_mem : ∀ (J : WithBot (Box ι)), J ∈ boxes → J ≤ ↑I
pairwise_disjoint : Set.Pairwise (↑boxes) Disjoint
H : ∀ (J : WithBot (Box ι)), J ∈ boxes → J ≠ ⊥ → ∃ J', J' ∈ π ∧ J ≤ ↑J'
J : Box ι
hJ : ↑J ∈ boxes
⊢ ∃ J', J' ∈ π ∧ J ≤ J'
[PROOFSTEP]
simpa only [WithBot.coe_le_coe] using H J hJ WithBot.coe_ne_bot
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
boxes : Finset (WithBot (Box ι))
le_of_mem : ∀ (J : WithBot (Box ι)), J ∈ boxes → J ≤ ↑I
pairwise_disjoint : Set.Pairwise (↑boxes) Disjoint
H : ∀ (J : WithBot (Box ι)), J ∈ boxes → J ≠ ⊥ → ∃ J', J' ∈ π ∧ J ≤ ↑J'
this : ∀ (J : Box ι), ↑J ∈ boxes → ∃ J', J' ∈ π ∧ J ≤ J'
⊢ ofWithBot boxes le_of_mem pairwise_disjoint ≤ π
[PROOFSTEP]
simpa [ofWithBot, le_def]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
boxes : Finset (WithBot (Box ι))
le_of_mem : ∀ (J : WithBot (Box ι)), J ∈ boxes → J ≤ ↑I
pairwise_disjoint : Set.Pairwise (↑boxes) Disjoint
H : ∀ (J : Box ι), J ∈ π → ∃ J', J' ∈ boxes ∧ ↑J ≤ J'
⊢ π ≤ ofWithBot boxes le_of_mem pairwise_disjoint
[PROOFSTEP]
intro J hJ
[GOAL]
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
boxes : Finset (WithBot (Box ι))
le_of_mem : ∀ (J : WithBot (Box ι)), J ∈ boxes → J ≤ ↑I
pairwise_disjoint : Set.Pairwise (↑boxes) Disjoint
H : ∀ (J : Box ι), J ∈ π → ∃ J', J' ∈ boxes ∧ ↑J ≤ J'
J : Box ι
hJ : J ∈ π
⊢ ∃ I', I' ∈ ofWithBot boxes le_of_mem pairwise_disjoint ∧ J ≤ I'
[PROOFSTEP]
rcases H J hJ with ⟨J', J'mem, hle⟩
[GOAL]
case intro.intro
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
boxes : Finset (WithBot (Box ι))
le_of_mem : ∀ (J : WithBot (Box ι)), J ∈ boxes → J ≤ ↑I
pairwise_disjoint : Set.Pairwise (↑boxes) Disjoint
H : ∀ (J : Box ι), J ∈ π → ∃ J', J' ∈ boxes ∧ ↑J ≤ J'
J : Box ι
hJ : J ∈ π
J' : WithBot (Box ι)
J'mem : J' ∈ boxes
hle : ↑J ≤ J'
⊢ ∃ I', I' ∈ ofWithBot boxes le_of_mem pairwise_disjoint ∧ J ≤ I'
[PROOFSTEP]
lift J' to Box ι using ne_bot_of_le_ne_bot WithBot.coe_ne_bot hle
[GOAL]
case intro.intro.intro
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
boxes : Finset (WithBot (Box ι))
le_of_mem : ∀ (J : WithBot (Box ι)), J ∈ boxes → J ≤ ↑I
pairwise_disjoint : Set.Pairwise (↑boxes) Disjoint
H : ∀ (J : Box ι), J ∈ π → ∃ J', J' ∈ boxes ∧ ↑J ≤ J'
J : Box ι
hJ : J ∈ π
J' : Box ι
J'mem : ↑J' ∈ boxes
hle : ↑J ≤ ↑J'
⊢ ∃ I', I' ∈ ofWithBot boxes le_of_mem pairwise_disjoint ∧ J ≤ I'
[PROOFSTEP]
exact ⟨J', mem_ofWithBot.2 J'mem, WithBot.coe_le_coe.1 hle⟩
[GOAL]
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π✝ π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π : Prepartition I
J : Box ι
J' : WithBot (Box ι)
hJ' : J' ∈ Finset.image (fun J' => ↑J ⊓ ↑J') π.boxes
⊢ J' ≤ ↑J
[PROOFSTEP]
rcases Finset.mem_image.1 hJ' with ⟨J', -, rfl⟩
[GOAL]
case intro.intro
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π✝ π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π : Prepartition I
J J' : Box ι
hJ' : ↑J ⊓ ↑J' ∈ Finset.image (fun J' => ↑J ⊓ ↑J') π.boxes
⊢ ↑J ⊓ ↑J' ≤ ↑J
[PROOFSTEP]
exact inf_le_left
[GOAL]
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π✝ π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π : Prepartition I
J : Box ι
⊢ Set.Pairwise (↑(Finset.image (fun J' => ↑J ⊓ ↑J') π.boxes)) Disjoint
[PROOFSTEP]
simp only [Set.Pairwise, onFun, Finset.mem_coe, Finset.mem_image]
[GOAL]
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π✝ π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π : Prepartition I
J : Box ι
⊢ ∀ ⦃x : WithBot (Box ι)⦄,
(∃ a, a ∈ π.boxes ∧ ↑J ⊓ ↑a = x) → ∀ ⦃y : WithBot (Box ι)⦄, (∃ a, a ∈ π.boxes ∧ ↑J ⊓ ↑a = y) → x ≠ y → Disjoint x y
[PROOFSTEP]
rintro _ ⟨J₁, h₁, rfl⟩ _ ⟨J₂, h₂, rfl⟩ Hne
[GOAL]
case intro.intro.intro.intro
ι : Type u_1
I J✝ J₁✝ J₂✝ : Box ι
π✝ π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π : Prepartition I
J J₁ : Box ι
h₁ : J₁ ∈ π.boxes
J₂ : Box ι
h₂ : J₂ ∈ π.boxes
Hne : ↑J ⊓ ↑J₁ ≠ ↑J ⊓ ↑J₂
⊢ Disjoint (↑J ⊓ ↑J₁) (↑J ⊓ ↑J₂)
[PROOFSTEP]
have : J₁ ≠ J₂ := by
rintro rfl
exact Hne rfl
[GOAL]
ι : Type u_1
I J✝ J₁✝ J₂✝ : Box ι
π✝ π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π : Prepartition I
J J₁ : Box ι
h₁ : J₁ ∈ π.boxes
J₂ : Box ι
h₂ : J₂ ∈ π.boxes
Hne : ↑J ⊓ ↑J₁ ≠ ↑J ⊓ ↑J₂
⊢ J₁ ≠ J₂
[PROOFSTEP]
rintro rfl
[GOAL]
ι : Type u_1
I J✝ J₁✝ J₂ : Box ι
π✝ π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π : Prepartition I
J J₁ : Box ι
h₁ h₂ : J₁ ∈ π.boxes
Hne : ↑J ⊓ ↑J₁ ≠ ↑J ⊓ ↑J₁
⊢ False
[PROOFSTEP]
exact Hne rfl
[GOAL]
case intro.intro.intro.intro
ι : Type u_1
I J✝ J₁✝ J₂✝ : Box ι
π✝ π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π : Prepartition I
J J₁ : Box ι
h₁ : J₁ ∈ π.boxes
J₂ : Box ι
h₂ : J₂ ∈ π.boxes
Hne : ↑J ⊓ ↑J₁ ≠ ↑J ⊓ ↑J₂
this : J₁ ≠ J₂
⊢ Disjoint (↑J ⊓ ↑J₁) (↑J ⊓ ↑J₂)
[PROOFSTEP]
exact ((Box.disjoint_coe.2 <| π.disjoint_coe_of_mem h₁ h₂ this).inf_left' _).inf_right' _
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
⊢ J₁ ∈ restrict π J ↔ ∃ J', J' ∈ π ∧ ↑J₁ = ↑J ⊓ ↑J'
[PROOFSTEP]
simp [restrict, eq_comm]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
⊢ J₁ ∈ restrict π J ↔ ∃ J', J' ∈ π ∧ ↑J₁ = ↑J ∩ ↑J'
[PROOFSTEP]
simp only [mem_restrict, ← Box.withBotCoe_inj, Box.coe_inf, Box.coe_coe]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁✝ π₂✝ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π₁ π₂ : Prepartition I
Hle : π₁ ≤ π₂
⊢ restrict π₁ J ≤ restrict π₂ J
[PROOFSTEP]
refine' ofWithBot_mono fun J₁ hJ₁ hne => _
[GOAL]
ι : Type u_1
I J J₁✝ J₂ : Box ι
π π₁✝ π₂✝ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π₁ π₂ : Prepartition I
Hle : π₁ ≤ π₂
J₁ : WithBot (Box ι)
hJ₁ : J₁ ∈ Finset.image (fun J' => ↑J ⊓ ↑J') π₁.boxes
hne : J₁ ≠ ⊥
⊢ ∃ J', J' ∈ Finset.image (fun J' => ↑J ⊓ ↑J') π₂.boxes ∧ J₁ ≤ J'
[PROOFSTEP]
rw [Finset.mem_image] at hJ₁
[GOAL]
ι : Type u_1
I J J₁✝ J₂ : Box ι
π π₁✝ π₂✝ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π₁ π₂ : Prepartition I
Hle : π₁ ≤ π₂
J₁ : WithBot (Box ι)
hJ₁ : ∃ a, a ∈ π₁.boxes ∧ ↑J ⊓ ↑a = J₁
hne : J₁ ≠ ⊥
⊢ ∃ J', J' ∈ Finset.image (fun J' => ↑J ⊓ ↑J') π₂.boxes ∧ J₁ ≤ J'
[PROOFSTEP]
rcases hJ₁ with ⟨J₁, hJ₁, rfl⟩
[GOAL]
case intro.intro
ι : Type u_1
I J J₁✝ J₂ : Box ι
π π₁✝ π₂✝ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π₁ π₂ : Prepartition I
Hle : π₁ ≤ π₂
J₁ : Box ι
hJ₁ : J₁ ∈ π₁.boxes
hne : ↑J ⊓ ↑J₁ ≠ ⊥
⊢ ∃ J', J' ∈ Finset.image (fun J' => ↑J ⊓ ↑J') π₂.boxes ∧ ↑J ⊓ ↑J₁ ≤ J'
[PROOFSTEP]
rcases Hle hJ₁ with ⟨J₂, hJ₂, hle⟩
[GOAL]
case intro.intro.intro.intro
ι : Type u_1
I J J₁✝ J₂✝ : Box ι
π π₁✝ π₂✝ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π₁ π₂ : Prepartition I
Hle : π₁ ≤ π₂
J₁ : Box ι
hJ₁ : J₁ ∈ π₁.boxes
hne : ↑J ⊓ ↑J₁ ≠ ⊥
J₂ : Box ι
hJ₂ : J₂ ∈ π₂
hle : J₁ ≤ J₂
⊢ ∃ J', J' ∈ Finset.image (fun J' => ↑J ⊓ ↑J') π₂.boxes ∧ ↑J ⊓ ↑J₁ ≤ J'
[PROOFSTEP]
exact ⟨_, Finset.mem_image_of_mem _ hJ₂, inf_le_inf_left _ <| WithBot.coe_le_coe.2 hle⟩
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π✝ π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π : Prepartition I
h : I ≤ J
⊢ (restrict π J).boxes = π.boxes
[PROOFSTEP]
simp only [restrict, ofWithBot, eraseNone_eq_biUnion]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π✝ π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π : Prepartition I
h : I ≤ J
⊢ Finset.biUnion (Finset.image (fun J' => ↑J ⊓ ↑J') π.boxes) Option.toFinset = π.boxes
[PROOFSTEP]
refine' Finset.image_biUnion.trans _
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π✝ π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π : Prepartition I
h : I ≤ J
⊢ (Finset.biUnion π.boxes fun a => Option.toFinset (↑J ⊓ ↑a)) = π.boxes
[PROOFSTEP]
refine' (Finset.biUnion_congr rfl _).trans Finset.biUnion_singleton_eq_self
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π✝ π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π : Prepartition I
h : I ≤ J
⊢ ∀ (a : Box ι), a ∈ π.boxes → Option.toFinset (↑J ⊓ ↑a) = {a}
[PROOFSTEP]
intro J' hJ'
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π✝ π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π : Prepartition I
h : I ≤ J
J' : Box ι
hJ' : J' ∈ π.boxes
⊢ Option.toFinset (↑J ⊓ ↑J') = {J'}
[PROOFSTEP]
rw [inf_of_le_right, ← WithBot.some_eq_coe, Option.toFinset_some]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π✝ π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π : Prepartition I
h : I ≤ J
J' : Box ι
hJ' : J' ∈ π.boxes
⊢ ↑J' ≤ ↑J
[PROOFSTEP]
exact WithBot.coe_le_coe.2 ((π.le_of_mem hJ').trans h)
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
⊢ Prepartition.iUnion (restrict π J) = ↑J ∩ Prepartition.iUnion π
[PROOFSTEP]
simp [restrict, ← inter_iUnion, ← iUnion_def]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
hJ : J ∈ π
⊢ restrict (biUnion π πi) J = πi J
[PROOFSTEP]
refine' (eq_of_boxes_subset_iUnion_superset (fun J₁ h₁ => _) _).symm
[GOAL]
case refine'_1
ι : Type u_1
I J J₁✝ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
hJ : J ∈ π
J₁ : Box ι
h₁ : J₁ ∈ (πi J).boxes
⊢ J₁ ∈ (restrict (biUnion π πi) J).boxes
[PROOFSTEP]
refine' (mem_restrict _).2 ⟨J₁, π.mem_biUnion.2 ⟨J, hJ, h₁⟩, (inf_of_le_right _).symm⟩
[GOAL]
case refine'_1
ι : Type u_1
I J J₁✝ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
hJ : J ∈ π
J₁ : Box ι
h₁ : J₁ ∈ (πi J).boxes
⊢ ↑J₁ ≤ ↑J
[PROOFSTEP]
exact WithBot.coe_le_coe.2 (le_of_mem _ h₁)
[GOAL]
case refine'_2
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
hJ : J ∈ π
⊢ Prepartition.iUnion (restrict (biUnion π πi) J) ⊆ Prepartition.iUnion (πi J)
[PROOFSTEP]
simp only [iUnion_restrict, iUnion_biUnion, Set.subset_def, Set.mem_inter_iff, Set.mem_iUnion]
[GOAL]
case refine'_2
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
hJ : J ∈ π
⊢ ∀ (x : ι → ℝ), (x ∈ ↑J ∧ ∃ i i_1, x ∈ Prepartition.iUnion (πi i)) → x ∈ Prepartition.iUnion (πi J)
[PROOFSTEP]
rintro x ⟨hxJ, J₁, h₁, hx⟩
[GOAL]
case refine'_2.intro.intro.intro
ι : Type u_1
I J J₁✝ J₂ : Box ι
π π₁ π₂ : Prepartition I
x✝ : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
hJ : J ∈ π
x : ι → ℝ
hxJ : x ∈ ↑J
J₁ : Box ι
h₁ : J₁ ∈ π
hx : x ∈ Prepartition.iUnion (πi J₁)
⊢ x ∈ Prepartition.iUnion (πi J)
[PROOFSTEP]
obtain rfl : J = J₁
[GOAL]
ι : Type u_1
I J J₁✝ J₂ : Box ι
π π₁ π₂ : Prepartition I
x✝ : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
hJ : J ∈ π
x : ι → ℝ
hxJ : x ∈ ↑J
J₁ : Box ι
h₁ : J₁ ∈ π
hx : x ∈ Prepartition.iUnion (πi J₁)
⊢ J = J₁
case refine'_2.intro.intro.intro
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x✝ : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
hJ : J ∈ π
x : ι → ℝ
hxJ : x ∈ ↑J
h₁ : J ∈ π
hx : x ∈ Prepartition.iUnion (πi J)
⊢ x ∈ Prepartition.iUnion (πi J)
[PROOFSTEP]
exact π.eq_of_mem_of_mem hJ h₁ hxJ (iUnion_subset _ hx)
[GOAL]
case refine'_2.intro.intro.intro
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x✝ : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
hJ : J ∈ π
x : ι → ℝ
hxJ : x ∈ ↑J
h₁ : J ∈ π
hx : x ∈ Prepartition.iUnion (πi J)
⊢ x ∈ Prepartition.iUnion (πi J)
[PROOFSTEP]
exact hx
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
π' : Prepartition I
⊢ biUnion π πi ≤ π' ↔ ∀ (J : Box ι), J ∈ π → πi J ≤ restrict π' J
[PROOFSTEP]
constructor
[GOAL]
case mp
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
π' : Prepartition I
⊢ biUnion π πi ≤ π' → ∀ (J : Box ι), J ∈ π → πi J ≤ restrict π' J
[PROOFSTEP]
intro H J hJ
[GOAL]
case mpr
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
π' : Prepartition I
⊢ (∀ (J : Box ι), J ∈ π → πi J ≤ restrict π' J) → biUnion π πi ≤ π'
[PROOFSTEP]
intro H J hJ
[GOAL]
case mp
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
π' : Prepartition I
H : biUnion π πi ≤ π'
J : Box ι
hJ : J ∈ π
⊢ πi J ≤ restrict π' J
[PROOFSTEP]
rw [← π.restrict_biUnion πi hJ]
[GOAL]
case mp
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
π' : Prepartition I
H : biUnion π πi ≤ π'
J : Box ι
hJ : J ∈ π
⊢ restrict (biUnion π πi) J ≤ restrict π' J
[PROOFSTEP]
exact restrict_mono H
[GOAL]
case mpr
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
π' : Prepartition I
H : ∀ (J : Box ι), J ∈ π → πi J ≤ restrict π' J
J : Box ι
hJ : J ∈ biUnion π πi
⊢ ∃ I', I' ∈ π' ∧ J ≤ I'
[PROOFSTEP]
rw [mem_biUnion] at hJ
[GOAL]
case mpr
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
π' : Prepartition I
H : ∀ (J : Box ι), J ∈ π → πi J ≤ restrict π' J
J : Box ι
hJ : ∃ J', J' ∈ π ∧ J ∈ πi J'
⊢ ∃ I', I' ∈ π' ∧ J ≤ I'
[PROOFSTEP]
rcases hJ with ⟨J₁, h₁, hJ⟩
[GOAL]
case mpr.intro.intro
ι : Type u_1
I J✝ J₁✝ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
π' : Prepartition I
H : ∀ (J : Box ι), J ∈ π → πi J ≤ restrict π' J
J J₁ : Box ι
h₁ : J₁ ∈ π
hJ : J ∈ πi J₁
⊢ ∃ I', I' ∈ π' ∧ J ≤ I'
[PROOFSTEP]
rcases H J₁ h₁ hJ with ⟨J₂, h₂, Hle⟩
[GOAL]
case mpr.intro.intro.intro.intro
ι : Type u_1
I J✝ J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
π' : Prepartition I
H : ∀ (J : Box ι), J ∈ π → πi J ≤ restrict π' J
J J₁ : Box ι
h₁ : J₁ ∈ π
hJ : J ∈ πi J₁
J₂ : Box ι
h₂ : J₂ ∈ restrict π' J₁
Hle : J ≤ J₂
⊢ ∃ I', I' ∈ π' ∧ J ≤ I'
[PROOFSTEP]
rcases π'.mem_restrict.mp h₂ with ⟨J₃, h₃, H⟩
[GOAL]
case mpr.intro.intro.intro.intro.intro.intro
ι : Type u_1
I J✝ J₁✝ J₂✝ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
π' : Prepartition I
H✝ : ∀ (J : Box ι), J ∈ π → πi J ≤ restrict π' J
J J₁ : Box ι
h₁ : J₁ ∈ π
hJ : J ∈ πi J₁
J₂ : Box ι
h₂ : J₂ ∈ restrict π' J₁
Hle : J ≤ J₂
J₃ : Box ι
h₃ : J₃ ∈ π'
H : ↑J₂ = ↑J₁ ⊓ ↑J₃
⊢ ∃ I', I' ∈ π' ∧ J ≤ I'
[PROOFSTEP]
exact ⟨J₃, h₃, Hle.trans <| WithBot.coe_le_coe.1 <| H.trans_le inf_le_right⟩
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
π' : Prepartition I
⊢ π' ≤ biUnion π πi ↔ π' ≤ π ∧ ∀ (J : Box ι), J ∈ π → restrict π' J ≤ πi J
[PROOFSTEP]
refine' ⟨fun H => ⟨H.trans (π.biUnion_le πi), fun J hJ => _⟩, _⟩
[GOAL]
case refine'_1
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
π' : Prepartition I
H : π' ≤ biUnion π πi
J : Box ι
hJ : J ∈ π
⊢ restrict π' J ≤ πi J
[PROOFSTEP]
rw [← π.restrict_biUnion πi hJ]
[GOAL]
case refine'_1
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
π' : Prepartition I
H : π' ≤ biUnion π πi
J : Box ι
hJ : J ∈ π
⊢ restrict π' J ≤ restrict (biUnion π πi) J
[PROOFSTEP]
exact restrict_mono H
[GOAL]
case refine'_2
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
π' : Prepartition I
⊢ (π' ≤ π ∧ ∀ (J : Box ι), J ∈ π → restrict π' J ≤ πi J) → π' ≤ biUnion π πi
[PROOFSTEP]
rintro ⟨H, Hi⟩ J' hJ'
[GOAL]
case refine'_2.intro
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
π' : Prepartition I
H : π' ≤ π
Hi : ∀ (J : Box ι), J ∈ π → restrict π' J ≤ πi J
J' : Box ι
hJ' : J' ∈ π'
⊢ ∃ I', I' ∈ biUnion π πi ∧ J' ≤ I'
[PROOFSTEP]
rcases H hJ' with ⟨J, hJ, hle⟩
[GOAL]
case refine'_2.intro.intro.intro
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
π' : Prepartition I
H : π' ≤ π
Hi : ∀ (J : Box ι), J ∈ π → restrict π' J ≤ πi J
J' : Box ι
hJ' : J' ∈ π'
J : Box ι
hJ : J ∈ π
hle : J' ≤ J
⊢ ∃ I', I' ∈ biUnion π πi ∧ J' ≤ I'
[PROOFSTEP]
have : J' ∈ π'.restrict J := π'.mem_restrict.2 ⟨J', hJ', (inf_of_le_right <| WithBot.coe_le_coe.2 hle).symm⟩
[GOAL]
case refine'_2.intro.intro.intro
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
π' : Prepartition I
H : π' ≤ π
Hi : ∀ (J : Box ι), J ∈ π → restrict π' J ≤ πi J
J' : Box ι
hJ' : J' ∈ π'
J : Box ι
hJ : J ∈ π
hle : J' ≤ J
this : J' ∈ restrict π' J
⊢ ∃ I', I' ∈ biUnion π πi ∧ J' ≤ I'
[PROOFSTEP]
rcases Hi J hJ this with ⟨Ji, hJi, hlei⟩
[GOAL]
case refine'_2.intro.intro.intro.intro.intro
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi✝ πi₁ πi₂ πi : (J : Box ι) → Prepartition J
π' : Prepartition I
H : π' ≤ π
Hi : ∀ (J : Box ι), J ∈ π → restrict π' J ≤ πi J
J' : Box ι
hJ' : J' ∈ π'
J : Box ι
hJ : J ∈ π
hle : J' ≤ J
this : J' ∈ restrict π' J
Ji : Box ι
hJi : Ji ∈ πi J
hlei : J' ≤ Ji
⊢ ∃ I', I' ∈ biUnion π πi ∧ J' ≤ I'
[PROOFSTEP]
exact ⟨Ji, π.mem_biUnion.2 ⟨J, hJ, hJi⟩, hlei⟩
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁✝ π₂✝ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π₁ π₂ : Prepartition I
⊢ J ∈ π₁ ⊓ π₂ ↔ ∃ J₁, J₁ ∈ π₁ ∧ ∃ J₂, J₂ ∈ π₂ ∧ ↑J = ↑J₁ ⊓ ↑J₂
[PROOFSTEP]
simp only [inf_def, mem_biUnion, mem_restrict]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁✝ π₂✝ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π₁ π₂ : Prepartition I
⊢ Prepartition.iUnion (π₁ ⊓ π₂) = Prepartition.iUnion π₁ ∩ Prepartition.iUnion π₂
[PROOFSTEP]
simp only [inf_def, iUnion_biUnion, iUnion_restrict, ← iUnion_inter, ← iUnion_def]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
p : Box ι → Prop
hp : ∀ (J : Box ι), J ∈ π → p J
⊢ filter π p = π
[PROOFSTEP]
ext J
[GOAL]
case h
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
p : Box ι → Prop
hp : ∀ (J : Box ι), J ∈ π → p J
J : Box ι
⊢ J ∈ filter π p ↔ J ∈ π
[PROOFSTEP]
simpa using hp J
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π✝ π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π : Prepartition I
p : Box ι → Prop
⊢ Prepartition.iUnion (filter π fun J => ¬p J) = Prepartition.iUnion π \ Prepartition.iUnion (filter π p)
[PROOFSTEP]
simp only [Prepartition.iUnion]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π✝ π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π : Prepartition I
p : Box ι → Prop
⊢ ⋃ (J : Box ι) (_ : J ∈ filter π fun J => ¬p J), ↑J =
(⋃ (J : Box ι) (_ : J ∈ π), ↑J) \ ⋃ (J : Box ι) (_ : J ∈ filter π p), ↑J
[PROOFSTEP]
convert (@Set.biUnion_diff_biUnion_eq _ (Box ι) π.boxes (π.filter p).boxes (↑) _).symm
[GOAL]
case h.e'_2.h.e'_3.h.pq.a.a
ι : Type u_1
I J J₁ J₂ : Box ι
π✝ π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π : Prepartition I
p : Box ι → Prop
x✝ : Box ι
⊢ (x✝ ∈ filter π fun J => ¬p J) ↔ x✝ ∈ ↑π.boxes \ ↑(filter π p).boxes
[PROOFSTEP]
simp (config := { contextual := true })
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π✝ π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π : Prepartition I
p : Box ι → Prop
⊢ PairwiseDisjoint (↑π.boxes ∪ ↑(filter π p).boxes) Box.toSet
[PROOFSTEP]
rw [Set.PairwiseDisjoint]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π✝ π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π : Prepartition I
p : Box ι → Prop
⊢ Set.Pairwise (↑π.boxes ∪ ↑(filter π p).boxes) (Disjoint on Box.toSet)
[PROOFSTEP]
convert π.pairwiseDisjoint
[GOAL]
case h.e'_2
ι : Type u_1
I J J₁ J₂ : Box ι
π✝ π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π : Prepartition I
p : Box ι → Prop
⊢ ↑π.boxes ∪ ↑(filter π p).boxes = ↑π.boxes
[PROOFSTEP]
rw [Set.union_eq_left_iff_subset, filter_boxes, coe_filter]
[GOAL]
case h.e'_2
ι : Type u_1
I J J₁ J₂ : Box ι
π✝ π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π : Prepartition I
p : Box ι → Prop
⊢ {x | x ∈ π.boxes ∧ p x} ⊆ ↑π.boxes
[PROOFSTEP]
exact fun _ ⟨h, _⟩ => h
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π✝ π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
α : Type u_2
M : Type u_3
inst✝ : AddCommMonoid M
π : Prepartition I
f : Box ι → α
g : Box ι → M
⊢ ∑ y in Finset.image f π.boxes, ∑ J in (filter π fun J => f J = y).boxes, g J = ∑ J in π.boxes, g J
[PROOFSTEP]
convert sum_fiberwise_of_maps_to (fun _ => Finset.mem_image_of_mem f) g
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁✝ π₂✝ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π₁ π₂ : Prepartition I
h : Disjoint (Prepartition.iUnion π₁) (Prepartition.iUnion π₂)
this : ∀ (J₁ : Box ι), J₁ ∈ π₁ → ∀ (J₂ : Box ι), J₂ ∈ π₂ → J₁ ≠ J₂ → Disjoint ↑J₁ ↑J₂
⊢ Set.Pairwise (↑(π₁.boxes ∪ π₂.boxes)) (Disjoint on Box.toSet)
[PROOFSTEP]
simpa [pairwise_union_of_symmetric (symmetric_disjoint.comap _), pairwiseDisjoint]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
h : Disjoint (Prepartition.iUnion π₁) (Prepartition.iUnion π₂)
⊢ Prepartition.iUnion (disjUnion π₁ π₂ h) = Prepartition.iUnion π₁ ∪ Prepartition.iUnion π₂
[PROOFSTEP]
simp [disjUnion, Prepartition.iUnion, iUnion_or, iUnion_union_distrib]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π✝ π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
π : Prepartition I
⊢ IsPartition π ↔ Prepartition.iUnion π = ↑I
[PROOFSTEP]
simp_rw [IsPartition, Set.Subset.antisymm_iff, π.iUnion_subset, true_and_iff, Set.subset_def, mem_iUnion, Box.mem_coe]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
h : J ≤ I
⊢ IsPartition (single I J h) ↔ J = I
[PROOFSTEP]
simp [isPartition_iff_iUnion_eq]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
h : IsPartition π
hx : x ∈ I
⊢ ∃! J x_1, x ∈ J
[PROOFSTEP]
rcases h x hx with ⟨J, h, hx⟩
[GOAL]
case intro.intro
ι : Type u_1
I J✝ J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
h✝ : IsPartition π
hx✝ : x ∈ I
J : Box ι
h : J ∈ π
hx : x ∈ J
⊢ ∃! J x_1, x ∈ J
[PROOFSTEP]
exact ExistsUnique.intro₂ J h hx fun J' h' hx' => π.eq_of_mem_of_mem h' h hx' hx
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
h : IsPartition π
hJ : J ≤ I
⊢ Prepartition.iUnion (restrict π J) = ↑J
[PROOFSTEP]
simp [h.iUnion_eq, hJ]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
h₁ : IsPartition π₁
h₂ : IsPartition π₂
⊢ Prepartition.iUnion (π₁ ⊓ π₂) = ↑I
[PROOFSTEP]
simp [h₁.iUnion_eq, h₂.iUnion_eq]
[GOAL]
ι : Type u_1
I J J₁ J₂ : Box ι
π π₁ π₂ : Prepartition I
x : ι → ℝ
πi πi₁ πi₂ : (J : Box ι) → Prepartition J
h : Prepartition.iUnion π₂ = ↑I \ Prepartition.iUnion π₁
⊢ Prepartition.iUnion π₁ ∪ Prepartition.iUnion π₂ = ↑I
[PROOFSTEP]
simp [h, π₁.iUnion_subset]
|
#include "ros_package_template/Algorithm.hpp"
#include <utility>
#include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics/mean.hpp>
#include <boost/accumulators/statistics/count.hpp>
namespace ros_package_template {
using namespace boost::accumulators;
struct Algorithm::Data {
accumulator_set<double, features<tag::mean, tag::count>> acc;
};
Algorithm::Algorithm() {
data_ = std::make_unique<Data>();
}
Algorithm::~Algorithm() = default;
void Algorithm::addData(const double data)
{
data_->acc(data);
}
void Algorithm::addData(const Eigen::VectorXd& data)
{
for(auto i = 0; i < data.size(); ++i)
addData(data[i]);
}
double Algorithm::getAverage() const
{
return count(data_->acc) ? mean(data_->acc) : 0;
}
} /* namespace */
|
!* 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
* Optimizer bug
* _mp_lcpu2() & _mp_ncpus() cannot be invariant (must call this routines
* using JSR and not QJSR.
program mmul
c
integer i, j, k
integer m, n, p
real*8 a, b, c, arow
allocatable a(:,:), b(:,:), c(:,:), arow(:)
c
integer ntimes, l
real time, mflops
integer hz, clock0, clock1, clock2
integer t
allocatable t(:)
real tarray(2), time0, time1, time2
allocate (t(1))
c
m = 100
n = 100
p = 100
ntimes = 10
c
allocate (a(1:m,1:n),b(1:n,1:p),c(1:m,1:p),arow(1:n))
c
do i = 1, m
do j = 1, n
a(i,j) = 1.0
enddo
enddo
do i = 1, n
do j = 1, p
b(i,j) = 1.0
enddo
enddo
c
call mmul_time(a, b, c, m, n, p, ntimes, arow,
& clock0, clock1, clock2, hz,
& time0, time1, time2, tarray)
c
! print *, nint(c(1,1)) !should be ~100.0
call check(nint(c(1,1)), 100, 1)
c
end
subroutine mmul_time (a, b, c, m, n, p, ntimes, arow,
& clock0, clock1, clock2, hz,
& time0, time1, time2, tarray)
integer m, n, p
real*8 a(m,n), b(n,p), c(m,p), arow(n)
integer clock0, clock1, clock2, hz
real tarray(2), time0, time1, time2
real ettime
time0 = ettime(tarray)
do l = 1, ntimes
do i = 1, m
do j = 1, p
c(i,j) = 0.0
enddo
enddo
!$omp parallel
!$omp do
do i = 1, m
do j = 1, p
do k = 1, n
c(i,j) = c(i,j) + a(i,k) * b(k,j)
enddo
enddo
enddo
!$omp end parallel
call dummy(c)
enddo
time1 = ettime(tarray)
do i = 1, ntimes
call dummy(c)
enddo
time2 = ettime(tarray)
return
end
c
c Dummy subroutine
c
subroutine dummy(c)
return
end
real function ettime(tarray)
real tarray(2)
ettime = 0
end
|
Formal statement is: proposition\<^marker>\<open>tag unimportant\<close> homeomorphism_moving_points_exists: fixes S :: "'a::euclidean_space set" assumes 2: "2 \<le> DIM('a)" "open S" "connected S" "S \<subseteq> T" "finite K" and KS: "\<And>i. i \<in> K \<Longrightarrow> x i \<in> S \<and> y i \<in> S" and pw: "pairwise (\<lambda>i j. (x i \<noteq> x j) \<and> (y i \<noteq> y j)) K" and S: "S \<subseteq> T" "T \<subseteq> affine hull S" "connected S" obtains f g where "homeomorphism T T f g" "\<And>i. i \<in> K \<Longrightarrow> f(x i) = y i" "{x. \<not> (f x = x \<and> g x = x)} \<subseteq> S" "bounded {x. (\<not> (f x = x \<and> g x = x))}" Informal statement is: If $S$ is a connected open subset of $\mathbb{R}^n$ and $K$ is a finite set of points in $S$, then there exists a homeomorphism $f$ of $S$ onto itself such that $f(x_i) = y_i$ for all $i \in K$ and $f$ is bounded on the set of points where it is not the identity. |
Chances are good that I'll post another version at some point to play with a couple other ideas, but it's done. I give you my track machine DeTomaso Pantera! Was lots of fun and I got a chance to play with carbon fiber. It you look at the front and rear spoiler you'll see what I mean. It turned out looking pretty cool I think. I'm also posting an Audi R8 done by my brother just a little while back as well. He put a bunch of little custom tweaks into it and the colors are just perfect. Even the most anti-two-tone enthusiast can dig on this color scheme ... to me, it just works.
I've been taking my sweet time with this project and you can see more updates than this at lateral-g.net but it is progressing along at this point. Here is a http://www.lateral-g.net/forums/showthread.php4?p=347942#post347942 to the actual thread. The body is pretty well complete, now I'll be putting in the stuff that gives it the race car vibe. I've gone back and forth over the rear spoiler but I feel that given the car's theme, it will need a race wing.
Well if you direct your browser to lateral-g.net and go for the artwork section in the forums, you'll find my little community project. It's a trial run, first time. It has come together pretty well and I've got a list of things I'll do differently next time around. It started with the first ten cars that people suggested - they went into a poll with a few styles and colors and everyone started voting. I set the poll to expire in 30 days so you've got unit May 1 2011 to get your vote in. The real question is, why vote? The poll results are public, everyone who votes, goes into a hat and a name will be drawn. That person gets to put the finishing touches on the car. See the deal is, the poll can only handle 18 options which isn't many when you figure all the things that can be done to a car. However, the winner will be choosing wheels and helping me figure out just how to modify the car's looks. Then when it's drawn, that person will receive a signed print of the rendering. Those prints will then go on sale right here at the O'Dell Studios blog in the Prints tab.
For anyone interested, a 70s De Tomaso Pantera is currently in the lead to be rendered as a purpose built track monster which is going to be great fun. I've got visions of fender flares, turn buckle-adjustable front splitters, sponsor decals, roll cages, the works. But I've also got visions of body mods. The car's shape lends itself to modification well and there are a few things (like pop-up head lights) that could use updates to bring the car into the 21st century. BUT! There are a couple other cars creeping up and tied for 2nd at this point, and the Pantera may not be on top in the end.
Got some leftovers from the show and they are now available. We've got a couple versions; the signed and numbered prints are 13x19 high end units. $35 a piece or the set of both cars for $60. The second variety are your average toner-based prints on 11x17, unsigned, for $10. Send me an e-mail at [email protected] and I'll get you fixed up.
Like any project it gets to the point where looking at it just won't help. A couple more ideas out.
I think I'm just about gonna call it done. I'll have to have a proof printed and make sure it looks the way I think it should, but aside from that, not much else to do here unless I see something I hate about it between now and the weekend.
Just wanted to also throw up the sketch of Sasquatch. Nothing amazing, just a quick 20 minute job after doing a few doodles of people in suits with their arms crossed.
Nearer to completion. The Emerald City Comicon itself draws nearer too so the clock is ticking. But I think I'm getting there on my piece. It's actually kinda tough not to leave it a cool bit of automotive art but it felt like more was needed. My Sasquatch sketch (I'll have to post the sketch) turned out pretty good and the final colored version ended up the way I meant for it to so I felt like it deserved to be included. About all I wanted to accomplish was to make him look like he would be found in a comic book. I didn't want him over-rendered and I think it came out just right.
OK so he's gotten pretty far along before I got a post up but this is AJ's portion coming together. Still a WIP but we've got a mild custom Camaro going on in the same hue I used. Getting away from the green overtones but with an obvious Seattle icon for part of the background. We've kept the mods mild on both of these modern muscle cars to maintain recognition but subtle improvements make them even more appealing than they already are.
I still want to try a couple different things with the light streaks but this is my initial layout. Next I'm working on my Sasquatch! |
# Elastic wave equation implementation on a staggered grid
This is a first attempt at implemenenting the elastic wave equation as described in:
[1] Jean Virieux (1986). ”P-SV wave propagation in heterogeneous media: Velocity‐stress finite‐difference method.” GEOPHYSICS, 51(4), 889-901. https://doi.org/10.1190/1.1442147
The current version actually attempts to mirror the FDELMODC implementation by Jan Thorbecke:
[2] https://janth.home.xs4all.nl/Software/fdelmodcManual.pdf
## Explosive source
We will first attempt to replicate the explosive source test case described in [1], Figure 4. We start by defining the source signature $g(t)$, the derivative of a Gaussian pulse, given by Eq 4:
$$g(t) = -2 \alpha(t - t_0)e^{-\alpha(t-t_0)^2}$$
```python
from devito import *
from examples.seismic.source import WaveletSource, RickerSource, GaborSource, TimeAxis
from examples.seismic import plot_image
import numpy as np
from sympy import init_printing, latex
init_printing(use_latex=True)
```
```python
# Initial grid: 1km x 1km, with spacing 100m
extent = (2000., 2000.)
shape = (201, 201)
x = SpaceDimension(name='x', spacing=Constant(name='h_x', value=extent[0]/(shape[0]-1)))
z = SpaceDimension(name='z', spacing=Constant(name='h_z', value=extent[1]/(shape[1]-1)))
grid = Grid(extent=extent, shape=shape, dimensions=(x, z))
```
```python
class DGaussSource(WaveletSource):
def wavelet(self, f0, t):
a = 0.004
return -2.*a*(t - 1/f0) * np.exp(-a * (t - 1/f0)**2)
# Timestep size from Eq. 7 with V_p=6000. and dx=100
t0, tn = 0., 600.
dt = (10. / np.sqrt(2.)) / 6.
time_range = TimeAxis(start=t0, stop=tn, step=dt)
src = RickerSource(name='src', grid=grid, f0=0.01, time_range=time_range)
src.coordinates.data[:] = [1000., 1000.]
src.show()
```
```python
# Now we create the velocity and pressure fields
vx= TimeFunction(name='vx', grid=grid, staggered=(0, 1, 0))
vz = TimeFunction(name='vz', grid=grid, staggered=(0, 0, 1))
txx = TimeFunction(name='txx', grid=grid)
tzz = TimeFunction(name='tzz', grid=grid)
txz = TimeFunction(name='txz', grid=grid, staggered=(0, 1, 1))
# And finally we create the discretized/indexed symbols
VX = vx.indexed
VZ = vz.indexed
TXX = txx.indexed
TZZ = tzz.indexed
TXZ = txz.indexed
```
```python
def derivative(f, dim, order, stagger=centered):
"""
Utility function to generate staggered derivatives
"""
diff = dim.spacing
if stagger == left:
off = -.5
elif stagger == right:
off = .5
else:
off = 0.
idx = [(dim + int(i+.5+off)*diff) for i in range(-int(order / 2), int(order / 2))]
return f.diff(dim).as_finite_difference(idx, x0=dim + off*dim.spacing)
```
```python
# Now let's try and create the staggered updates
t = grid.stepping_dim
time = grid.time_dim
# We need some initial conditions
V_p = 4.0
V_s = 1.0
density = 3.
# The source injection term
src_xx = src.inject(field=txx.forward, expr=src)
src_zz = src.inject(field=tzz.forward, expr=src)
#c1 = 9.0/8.0;
#c2 = -1.0/24.0;
# Thorbecke's parameter notation
cp2 = V_p*V_p
cs2 = V_s*V_s
ro = 1/density
mu = cs2*ro
l = (cp2*ro - 2*mu)
# fdelmodc reference implementation
u_vx = Eq(vx.forward, vx - dt*ro*(derivative(txx, dim=x, order=4, stagger=left)
+ derivative(txz, dim=z, order=4, stagger=right)))
u_vz = Eq(vz.forward, vz - ro*dt*(derivative(txz, dim=x, order=4, stagger=right)
+ derivative(tzz, dim=z, order=4, stagger=left)))
u_txx = Eq(txx.forward, txx - (l+2*mu)*dt * derivative(vx.forward, dim=x, order=4, stagger=right)
- l*dt * derivative(vz.forward, dim=z, order=4, stagger=right))
u_tzz = Eq(tzz.forward, tzz - (l+2*mu)*dt * derivative(vz.forward, dim=z, order=4, stagger=right)
- l*dt * derivative(vx.forward, dim=x, order=4, stagger=right))
u_txz = Eq(txz.forward, txz - mu*dt * (derivative(vx.forward, dim=z, order=4, stagger=left)
+ derivative(vz.forward, dim=x, order=4, stagger=left)))
```
```python
op = Operator([u_vx, u_vz, u_txx, u_tzz, u_txz] + src_xx + src_zz)
```
```python
# Reset the fields
vx.data[:] = 0.
vz.data[:] = 0.
txx.data[:] = 0.
tzz.data[:] = 0.
txz.data[:] = 0.
op()
```
GNUCompiler: cache hit `/tmp/devito-jitcache-uid944902/7180c0ae6fa2af6526472c104fe69c17e8f77f94.c` [0.01 s]
=========================================================================================
section0<<510,197,197>,<510,197,197>> with OI=2.32 computed in 0.077 s [24.15 GFlops/s, 1.28 GPts/s]
section1<510,1> with OI=2.54 computed in 0.001 s [0.05 GFlops/s, 0.00 GPts/s]
=========================================================================================
```python
# Let's see what we got....
plot_image(vx.data[0], vmin=-.5*1e-2, vmax=.5*1e-2, cmap="seismic")
plot_image(vz.data[0], vmin=-.5*1e-2, vmax=.5*1e-2, cmap="seismic")
plot_image(txx.data[0], vmin=-.5*1e-2, vmax=.5*1e-2, cmap="seismic")
plot_image(tzz.data[0], vmin=-.5*1e-2, vmax=.5*1e-2, cmap="seismic")
plot_image(txz.data[0], vmin=-.5*1e-2, vmax=.5*1e-2, cmap="seismic")
```
```python
# Now that looks pretty! But let's do it again with a higher order...
order = 12
u_vx = Eq(vx.forward, vx - dt*ro*(derivative(txx, dim=x, order=order, stagger=left)
+ derivative(txz, dim=z, order=order, stagger=right)))
u_vz = Eq(vz.forward, vz - ro*dt*(derivative(txz, dim=x, order=order, stagger=right)
+ derivative(tzz, dim=z, order=order, stagger=left)))
u_txx = Eq(txx.forward, txx - (l+2*mu)*dt * derivative(vx.forward, dim=x, order=order, stagger=right)
- l*dt * derivative(vz.forward, dim=z, order=order, stagger=right))
u_tzz = Eq(tzz.forward, tzz - (l+2*mu)*dt * derivative(vz.forward, dim=z, order=order, stagger=right)
- l*dt * derivative(vx.forward, dim=x, order=order, stagger=right))
u_txz = Eq(txz.forward, txz - mu*dt * (derivative(vx.forward, dim=z, order=order, stagger=left)
+ derivative(vz.forward, dim=x, order=order, stagger=left)))
op = Operator([u_vx, u_vz, u_txx, u_tzz, u_txz] + src_xx + src_zz)
# Reset the fields
vx.data[:] = 0.
vz.data[:] = 0.
txx.data[:] = 0.
tzz.data[:] = 0.
txz.data[:] = 0.
op()
plot_image(vx.data[0], vmin=-.5*1e-2, vmax=.5*1e-2, cmap="seismic")
plot_image(vz.data[0], vmin=-.5*1e-2, vmax=.5*1e-2, cmap="seismic")
plot_image(txx.data[0], vmin=-.5*1e-2, vmax=.5*1e-2, cmap="seismic")
plot_image(tzz.data[0], vmin=-.5*1e-2, vmax=.5*1e-2, cmap="seismic")
plot_image(txz.data[0], vmin=-.5*1e-2, vmax=.5*1e-2, cmap="seismic")
```
```python
```
|
REBOL [
Title: "Scan Para"
Date: 16-Feb-2009
Author: "Christopher Ross-Gill"
Type: 'paragraph
]
not-in-word any [
some space (emit copy " ") not-in-word
| copy text some alphanum (emit text) in-word
| newline (emit <br />) not-in-word
| #"=" [
block (emit values) in-word
; | string (emit values) in-word
| copy char number "." (
char: load char all [char > 31 char < 65536 emit char]
) in-word
| "b " (emit <b>)
| "b." (emit </b>)
| "i " (emit <i>)
| "i." (emit </i>)
; | "d " (emit <dfn>)
; | "d." (emit </dfn>)
| "q " (emit <q>)
| "q." (emit </q>)
| "x " (emit <del>)
| "x." (emit </del>)
| "w " (emit <var>)
| "w." (emit </var>)
| "n " (emit <ins>)
| "n." (emit </ins>)
| "h " (emit <ins>)
| "h." (emit </ins>)
| "c " (emit <cite>)
| "c." (emit </cite>)
| "." (emit </>)
]
| #"(" [
"c)" (emit 169)
| "r)" (emit 174)
| "o)" (emit 176)
| "tm)" (emit 8482)
| "e)" (emit 8364)
] in-word
| #"[" copy char number "]" (emit reduce ['link to-issue char])
| #"[" (emit <sb>)
| "]" opt [paren (emit values) | (emit </sb>)] in-word
; | #"<" ["i>" (emit <i>) | "/i>" (emit </i>) | "b>" (emit <b>) | "/b>" (emit </b>)]
| #"<" (emit #"<") | #">" (emit #">") | #"&" (emit #"&")
; | #"~" (emit/after <code> </code>)
; | #"*" (emit/after <b> </b>)
| #"`" (emit/after <code> </code>) in-word
| #"'" (emit/after <apos> </apos>) in-word
| #"^"" (emit/after <quot> </quot>) in-word
| #"." ".." (emit 8230) in-word
| #"-" ["--" (emit 8212) | "-" (emit 8211)] in-word
| "\" copy char ["\" | "(" | "=" | "[" | "^"" | "'" | "." | "-"] (emit to-char char)
| copy char ascii (emit char) in-word
| copy char ucs (emit to integer! char/1) in-word
| copy char utf-8 (emit get-ucs-code char) in-word
| extended (emit "[???]")
| skip
] |
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*
*************************************************************/
#include "precompiled_sfx2.hxx"
#include "sfx2/taskpane.hxx"
#include "imagemgr.hxx"
#include "sfx2/sfxsids.hrc"
#include "sfx2/bindings.hxx"
#include "sfx2/dispatch.hxx"
#include "sfxresid.hxx"
#include "sfxlocal.hrc"
#include "helpid.hrc"
/** === begin UNO includes === **/
#include <com/sun/star/frame/XModuleManager.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/ui/XToolPanel.hpp>
#include <com/sun/star/ui/XUIElementFactory.hpp>
#include <com/sun/star/awt/XWindowPeer.hpp>
#include <com/sun/star/awt/PosSize.hpp>
#include <com/sun/star/frame/XModuleManager.hpp>
#include <com/sun/star/graphic/XGraphicProvider.hpp>
#include <com/sun/star/accessibility/XAccessible.hpp>
#include <com/sun/star/awt/XControl.hpp>
/** === end UNO includes === **/
#include <comphelper/componentcontext.hxx>
#include <comphelper/namedvaluecollection.hxx>
#include <comphelper/types.hxx>
#include <comphelper/processfactory.hxx>
#include <tools/diagnose_ex.h>
#include <svtools/toolpanel/toolpaneldeck.hxx>
#include <svtools/toolpanel/tablayouter.hxx>
#include <svtools/toolpanel/drawerlayouter.hxx>
#include <unotools/confignode.hxx>
#include <vcl/menu.hxx>
#include <vcl/svapp.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <tools/urlobj.hxx>
#include <boost/noncopyable.hpp>
//......................................................................................................................
namespace sfx2
{
//......................................................................................................................
/** === begin UNO using === **/
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::XInterface;
using ::com::sun::star::uno::UNO_QUERY;
using ::com::sun::star::uno::UNO_QUERY_THROW;
using ::com::sun::star::uno::UNO_SET_THROW;
using ::com::sun::star::uno::Exception;
using ::com::sun::star::uno::RuntimeException;
using ::com::sun::star::uno::Any;
using ::com::sun::star::uno::makeAny;
using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::Type;
using ::com::sun::star::frame::XModuleManager;
using ::com::sun::star::container::XNameAccess;
using ::com::sun::star::ui::XToolPanel;
using ::com::sun::star::ui::XUIElementFactory;
using ::com::sun::star::ui::XUIElement;
using ::com::sun::star::awt::XWindow;
using ::com::sun::star::frame::XModuleManager;
using ::com::sun::star::frame::XFrame;
using ::com::sun::star::lang::XComponent;
using ::com::sun::star::graphic::XGraphicProvider;
using ::com::sun::star::graphic::XGraphic;
using ::com::sun::star::accessibility::XAccessible;
using ::com::sun::star::awt::XControl;
/** === end UNO using === **/
namespace PosSize = ::com::sun::star::awt::PosSize;
//==================================================================================================================
//= helpers
//==================================================================================================================
namespace
{
//--------------------------------------------------------------------------------------------------------------
::utl::OConfigurationTreeRoot lcl_getModuleUIElementStatesConfig( const ::rtl::OUString& i_rModuleIdentifier,
const ::rtl::OUString& i_rResourceURL = ::rtl::OUString() )
{
const ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
::rtl::OUStringBuffer aPathComposer;
try
{
const Reference< XNameAccess > xModuleAccess( aContext.createComponent( "com.sun.star.frame.ModuleManager" ), UNO_QUERY_THROW );
const ::comphelper::NamedValueCollection aModuleProps( xModuleAccess->getByName( i_rModuleIdentifier ) );
const ::rtl::OUString sWindowStateRef( aModuleProps.getOrDefault( "ooSetupFactoryWindowStateConfigRef", ::rtl::OUString() ) );
aPathComposer.appendAscii( "org.openoffice.Office.UI." );
aPathComposer.append( sWindowStateRef );
aPathComposer.appendAscii( "/UIElements/States" );
if ( i_rResourceURL.getLength() )
{
aPathComposer.appendAscii( "/" );
aPathComposer.append( i_rResourceURL );
}
}
catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION();
}
return ::utl::OConfigurationTreeRoot( aContext, aPathComposer.makeStringAndClear(), false );
}
//--------------------------------------------------------------------------------------------------------------
::rtl::OUString lcl_identifyModule( const Reference< XFrame >& i_rDocumentFrame )
{
::rtl::OUString sModuleName;
try
{
const ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
const Reference< XModuleManager > xModuleManager( aContext.createComponent( "com.sun.star.frame.ModuleManager" ), UNO_QUERY_THROW );
sModuleName = xModuleManager->identify( i_rDocumentFrame );
}
catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION();
}
return sModuleName;
}
//--------------------------------------------------------------------------------------------------------------
Reference< XFrame > lcl_getFrame( const SfxBindings* i_pBindings )
{
const SfxViewFrame* pViewFrame = i_pBindings->GetDispatcher()->GetFrame();
const SfxFrame& rFrame = pViewFrame->GetFrame();
const Reference< XFrame > xFrame( rFrame.GetFrameInterface() );
return xFrame;
}
//--------------------------------------------------------------------------------------------------------------
::rtl::OUString lcl_getPanelHelpURL( const ::utl::OConfigurationNode& i_rPanelConfigNode )
{
const ::rtl::OUString sHelpURL( ::comphelper::getString( i_rPanelConfigNode.getNodeValue( "HelpURL" ) ) );
return sHelpURL;
}
//--------------------------------------------------------------------------------------------------------------
Image lcl_getPanelImage( const Reference< XFrame >& i_rDocFrame, const ::utl::OConfigurationNode& i_rPanelConfigNode )
{
const ::rtl::OUString sImageURL( ::comphelper::getString( i_rPanelConfigNode.getNodeValue( "ImageURL" ) ) );
if ( sImageURL.getLength() )
{
try
{
::comphelper::NamedValueCollection aMediaProperties;
aMediaProperties.put( "URL", sImageURL );
// special handling: if the ImageURL denotes a CommandName, then retrieve the image for that command
const sal_Char* pCommandImagePrefix = "private:commandimage/";
const sal_Int32 nCommandImagePrefixLen = strlen( pCommandImagePrefix );
if ( sImageURL.compareToAscii( pCommandImagePrefix, nCommandImagePrefixLen ) == 0 )
{
::rtl::OUStringBuffer aCommandName;
aCommandName.appendAscii( ".uno:" );
aCommandName.append( sImageURL.copy( nCommandImagePrefixLen ) );
const ::rtl::OUString sCommandName( aCommandName.makeStringAndClear() );
const sal_Bool bHiContrast( Application::GetSettings().GetStyleSettings().GetHighContrastMode() );
const Image aPanelImage( GetImage( i_rDocFrame, sCommandName, sal_False, bHiContrast ) );
return aPanelImage.GetXGraphic();
}
// otherwise, delegate to the GraphicProvider
const ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
const Reference< XGraphicProvider > xGraphicProvider( aContext.createComponent( "com.sun.star.graphic.GraphicProvider" ), UNO_QUERY_THROW );
const Reference< XGraphic > xGraphic( xGraphicProvider->queryGraphic( aMediaProperties.getPropertyValues() ), UNO_SET_THROW );
return Image( xGraphic );
}
catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION();
}
}
return Image();
}
}
//==================================================================================================================
//= TaskPaneDockingWindow
//==================================================================================================================
//------------------------------------------------------------------------------------------------------------------
TaskPaneDockingWindow::TaskPaneDockingWindow( SfxBindings* i_pBindings, TaskPaneWrapper& i_rWrapper, Window* i_pParent, WinBits i_nBits )
:TitledDockingWindow( i_pBindings, &i_rWrapper, i_pParent, i_nBits )
,m_aTaskPane( GetContentWindow(), lcl_getFrame( i_pBindings ) )
,m_aPaneController( m_aTaskPane, *this )
{
m_aTaskPane.Show();
SetText( String( SfxResId( SID_TASKPANE ) ) );
}
//------------------------------------------------------------------------------------------------------------------
void TaskPaneDockingWindow::ActivateToolPanel( const ::rtl::OUString& i_rPanelURL )
{
m_aPaneController.ActivateToolPanel( i_rPanelURL );
}
//------------------------------------------------------------------------------------------------------------------
void TaskPaneDockingWindow::GetFocus()
{
TitledDockingWindow::GetFocus();
m_aTaskPane.GrabFocus();
}
//------------------------------------------------------------------------------------------------------------------
void TaskPaneDockingWindow::onLayoutDone()
{
m_aTaskPane.SetPosSizePixel( Point(), GetContentWindow().GetOutputSizePixel() );
}
//==================================================================================================================
//= TaskPaneWrapper
//==================================================================================================================
//------------------------------------------------------------------------------------------------------------------
SFX_IMPL_DOCKINGWINDOW( TaskPaneWrapper, SID_TASKPANE );
//------------------------------------------------------------------------------------------------------------------
TaskPaneWrapper::TaskPaneWrapper( Window* i_pParent, sal_uInt16 i_nId, SfxBindings* i_pBindings, SfxChildWinInfo* i_pInfo )
:SfxChildWindow( i_pParent, i_nId )
{
pWindow = new TaskPaneDockingWindow( i_pBindings, *this, i_pParent,
WB_STDDOCKWIN | WB_CLIPCHILDREN | WB_SIZEABLE | WB_3DLOOK | WB_ROLLABLE);
eChildAlignment = SFX_ALIGN_RIGHT;
pWindow->SetHelpId( HID_TASKPANE_WINDOW );
pWindow->SetOutputSizePixel( Size( 300, 450 ) );
dynamic_cast< SfxDockingWindow* >( pWindow )->Initialize( i_pInfo );
SetHideNotDelete( sal_True );
pWindow->Show();
}
//------------------------------------------------------------------------------------------------------------------
void TaskPaneWrapper::ActivateToolPanel( const ::rtl::OUString& i_rPanelURL )
{
TaskPaneDockingWindow* pDockingWindow = dynamic_cast< TaskPaneDockingWindow* >( GetWindow() );
ENSURE_OR_RETURN_VOID( pDockingWindow, "TaskPaneWrapper::ActivateToolPanel: invalid docking window implementation!" );
pDockingWindow->ActivateToolPanel( i_rPanelURL );
}
//==================================================================================================================
//= CustomPanelUIElement
//==================================================================================================================
class CustomPanelUIElement
{
public:
CustomPanelUIElement()
:m_xUIElement()
,m_xToolPanel()
,m_xPanelWindow()
{
}
CustomPanelUIElement( const Reference< XUIElement >& i_rUIElement )
:m_xUIElement( i_rUIElement, UNO_SET_THROW )
,m_xToolPanel( i_rUIElement->getRealInterface(), UNO_QUERY_THROW )
,m_xPanelWindow( m_xToolPanel->getWindow(), UNO_SET_THROW )
{
}
bool is() const { return m_xPanelWindow.is(); }
const Reference< XUIElement >& getUIElement() const { return m_xUIElement; }
const Reference< XToolPanel >& getToolPanel() const { return m_xToolPanel; }
const Reference< XWindow >& getPanelWindow() const { return m_xPanelWindow; }
private:
Reference< XUIElement > m_xUIElement;
Reference< XToolPanel > m_xToolPanel;
Reference< XWindow > m_xPanelWindow;
};
//==================================================================================================================
//= CustomToolPanel
//==================================================================================================================
class CustomToolPanel : public ::svt::ToolPanelBase
{
public:
CustomToolPanel( const ::utl::OConfigurationNode& i_rPanelWindowState, const Reference< XFrame >& i_rFrame );
virtual ::rtl::OUString GetDisplayName() const;
virtual Image GetImage() const;
virtual rtl::OString GetHelpID() const;
virtual void Activate( Window& i_rParentWindow );
virtual void Deactivate();
virtual void SetSizePixel( const Size& i_rPanelWindowSize );
virtual void GrabFocus();
virtual void Dispose();
virtual Reference< XAccessible >
CreatePanelAccessible( const Reference< XAccessible >& i_rParentAccessible );
const ::rtl::OUString&
GetResourceURL() const { return m_sResourceURL; }
protected:
~CustomToolPanel();
private:
bool impl_ensureToolPanelWindow( Window& i_rPanelParentWindow );
void impl_updatePanelConfig( const bool i_bVisible ) const;
private:
const ::rtl::OUString m_sUIName;
const Image m_aPanelImage;
const ::rtl::OUString m_aPanelHelpURL;
const ::rtl::OUString m_sResourceURL;
const ::rtl::OUString m_sPanelConfigPath;
Reference< XFrame > m_xFrame;
CustomPanelUIElement m_aCustomPanel;
bool m_bAttemptedCreation;
};
//------------------------------------------------------------------------------------------------------------------
CustomToolPanel::CustomToolPanel( const ::utl::OConfigurationNode& i_rPanelWindowState, const Reference< XFrame >& i_rFrame )
:m_sUIName( ::comphelper::getString( i_rPanelWindowState.getNodeValue( "UIName" ) ) )
,m_aPanelImage( lcl_getPanelImage( i_rFrame, i_rPanelWindowState ) )
,m_aPanelHelpURL( lcl_getPanelHelpURL( i_rPanelWindowState ) )
,m_sResourceURL( i_rPanelWindowState.getLocalName() )
,m_sPanelConfigPath( i_rPanelWindowState.getNodePath() )
,m_xFrame( i_rFrame )
,m_aCustomPanel()
,m_bAttemptedCreation( false )
{
}
//------------------------------------------------------------------------------------------------------------------
CustomToolPanel::~CustomToolPanel()
{
}
//------------------------------------------------------------------------------------------------------------------
bool CustomToolPanel::impl_ensureToolPanelWindow( Window& i_rPanelParentWindow )
{
if ( m_bAttemptedCreation )
return m_aCustomPanel.is();
m_bAttemptedCreation = true;
try
{
const ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
const Reference< XUIElementFactory > xFactory( aContext.createComponent( "com.sun.star.ui.UIElementFactoryManager" ), UNO_QUERY_THROW );
::comphelper::NamedValueCollection aCreationArgs;
aCreationArgs.put( "Frame", makeAny( m_xFrame ) );
aCreationArgs.put( "ParentWindow", makeAny( i_rPanelParentWindow.GetComponentInterface() ) );
const Reference< XUIElement > xElement(
xFactory->createUIElement( m_sResourceURL, aCreationArgs.getPropertyValues() ),
UNO_SET_THROW );
m_aCustomPanel = CustomPanelUIElement( xElement );
}
catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION();
}
return m_aCustomPanel.is();
}
//------------------------------------------------------------------------------------------------------------------
void CustomToolPanel::impl_updatePanelConfig( const bool i_bVisible ) const
{
::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
::utl::OConfigurationTreeRoot aConfig( aContext, m_sPanelConfigPath, true );
aConfig.setNodeValue( "Visible", makeAny( i_bVisible ) );
aConfig.commit();
}
//------------------------------------------------------------------------------------------------------------------
::rtl::OUString CustomToolPanel::GetDisplayName() const
{
return m_sUIName;
}
//------------------------------------------------------------------------------------------------------------------
Image CustomToolPanel::GetImage() const
{
return m_aPanelImage;
}
static rtl::OString lcl_getHelpId( const ::rtl::OUString& _rHelpURL )
{
INetURLObject aHID( _rHelpURL );
if ( aHID.GetProtocol() == INET_PROT_HID )
return rtl::OUStringToOString( aHID.GetURLPath(), RTL_TEXTENCODING_UTF8 );
else
return rtl::OUStringToOString( _rHelpURL, RTL_TEXTENCODING_UTF8 );
}
//------------------------------------------------------------------------------------------------------------------
rtl::OString CustomToolPanel::GetHelpID() const
{
return lcl_getHelpId( m_aPanelHelpURL );
}
//------------------------------------------------------------------------------------------------------------------
void CustomToolPanel::Activate( Window& i_rParentWindow )
{
ENSURE_OR_RETURN_VOID( impl_ensureToolPanelWindow( i_rParentWindow ), "no panel to activate!" );
// TODO: we might need a mechanism to decide whether the panel should be destroyed/re-created, or (as it is
// done now) hidden/shown
m_aCustomPanel.getPanelWindow()->setVisible( sal_True );
// update the panel's configuration
impl_updatePanelConfig( true );
}
//------------------------------------------------------------------------------------------------------------------
void CustomToolPanel::Deactivate()
{
ENSURE_OR_RETURN_VOID( m_aCustomPanel.is(), "no panel to deactivate!" );
m_aCustomPanel.getPanelWindow()->setVisible( sal_False );
// update the panel's configuration
impl_updatePanelConfig( false );
}
//------------------------------------------------------------------------------------------------------------------
void CustomToolPanel::SetSizePixel( const Size& i_rPanelWindowSize )
{
ENSURE_OR_RETURN_VOID( m_aCustomPanel.is(), "no panel/window to position!" );
try
{
m_aCustomPanel.getPanelWindow()->setPosSize( 0, 0, i_rPanelWindowSize.Width(), i_rPanelWindowSize.Height(),
PosSize::POSSIZE );
}
catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION();
}
}
//------------------------------------------------------------------------------------------------------------------
void CustomToolPanel::GrabFocus()
{
ENSURE_OR_RETURN_VOID( m_aCustomPanel.is(), "no panel/window to focus!" );
m_aCustomPanel.getPanelWindow()->setFocus();
}
//------------------------------------------------------------------------------------------------------------------
void CustomToolPanel::Dispose()
{
if ( !m_bAttemptedCreation )
// nothing to dispose
return;
ENSURE_OR_RETURN_VOID( m_aCustomPanel.is(), "no panel to destroy!" );
try
{
Reference< XComponent > xUIElementComponent( m_aCustomPanel.getUIElement(), UNO_QUERY_THROW );
xUIElementComponent->dispose();
}
catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION();
}
}
//------------------------------------------------------------------------------------------------------------------
Reference< XAccessible > CustomToolPanel::CreatePanelAccessible( const Reference< XAccessible >& i_rParentAccessible )
{
ENSURE_OR_RETURN( m_aCustomPanel.is(), "no panel to ask!", NULL );
Reference< XAccessible > xPanelAccessible;
try
{
xPanelAccessible.set( m_aCustomPanel.getToolPanel()->createAccessible( i_rParentAccessible ), UNO_SET_THROW );
}
catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION();
}
return xPanelAccessible;
}
//==================================================================================================================
//= ModuleTaskPane_Impl
//==================================================================================================================
class ModuleTaskPane_Impl : public ::boost::noncopyable
{
public:
ModuleTaskPane_Impl( ModuleTaskPane& i_rAntiImpl, const Reference< XFrame >& i_rDocumentFrame,
const IToolPanelCompare* i_pPanelCompare )
:m_rAntiImpl( i_rAntiImpl )
,m_sModuleIdentifier( lcl_identifyModule( i_rDocumentFrame ) )
,m_xFrame( i_rDocumentFrame )
,m_aPanelDeck( i_rAntiImpl )
{
m_aPanelDeck.Show();
OnResize();
impl_initFromConfiguration( i_pPanelCompare );
}
~ModuleTaskPane_Impl()
{
}
void OnResize();
void OnGetFocus();
static bool ModuleHasToolPanels( const ::rtl::OUString& i_rModuleIdentifier );
::svt::ToolPanelDeck& GetPanelDeck() { return m_aPanelDeck; }
const ::svt::ToolPanelDeck& GetPanelDeck() const { return m_aPanelDeck; }
::boost::optional< size_t >
GetPanelPos( const ::rtl::OUString& i_rResourceURL );
::rtl::OUString
GetPanelResourceURL( const size_t i_nPanelPos ) const;
void SetDrawersLayout();
void SetTabsLayout( const ::svt::TabAlignment i_eTabAlignment, const ::svt::TabItemContent i_eTabContent );
private:
void impl_initFromConfiguration( const IToolPanelCompare* i_pPanelCompare );
static bool
impl_isToolPanelResource( const ::rtl::OUString& i_rResourceURL );
DECL_LINK( OnActivatePanel, void* );
private:
ModuleTaskPane& m_rAntiImpl;
const ::rtl::OUString m_sModuleIdentifier;
const Reference< XFrame > m_xFrame;
::svt::ToolPanelDeck m_aPanelDeck;
};
//------------------------------------------------------------------------------------------------------------------
void ModuleTaskPane_Impl::OnResize()
{
m_aPanelDeck.SetPosSizePixel( Point(), m_rAntiImpl.GetOutputSizePixel() );
}
//------------------------------------------------------------------------------------------------------------------
void ModuleTaskPane_Impl::OnGetFocus()
{
m_aPanelDeck.GrabFocus();
}
//------------------------------------------------------------------------------------------------------------------
IMPL_LINK( ModuleTaskPane_Impl, OnActivatePanel, void*, i_pArg )
{
m_aPanelDeck.ActivatePanel( reinterpret_cast< size_t >( i_pArg ) );
return 1L;
}
//------------------------------------------------------------------------------------------------------------------
bool ModuleTaskPane_Impl::impl_isToolPanelResource( const ::rtl::OUString& i_rResourceURL )
{
return i_rResourceURL.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "private:resource/toolpanel/" ) );
}
//------------------------------------------------------------------------------------------------------------------
void ModuleTaskPane_Impl::impl_initFromConfiguration( const IToolPanelCompare* i_pPanelCompare )
{
const ::utl::OConfigurationTreeRoot aWindowStateConfig( lcl_getModuleUIElementStatesConfig( m_sModuleIdentifier ) );
if ( !aWindowStateConfig.isValid() )
return;
::rtl::OUString sFirstVisiblePanelResource;
::rtl::OUString sFirstPanelResource;
const Sequence< ::rtl::OUString > aUIElements( aWindowStateConfig.getNodeNames() );
for ( const ::rtl::OUString* resource = aUIElements.getConstArray();
resource != aUIElements.getConstArray() + aUIElements.getLength();
++resource
)
{
if ( !impl_isToolPanelResource( *resource ) )
continue;
sFirstPanelResource = *resource;
::utl::OConfigurationNode aResourceNode( aWindowStateConfig.openNode( *resource ) );
::svt::PToolPanel pCustomPanel( new CustomToolPanel( aResourceNode, m_xFrame ) );
size_t nPanelPos = m_aPanelDeck.GetPanelCount();
if ( i_pPanelCompare )
{
// assuming that nobody will insert hundreths of panels, a simple O(n) search should suffice here ...
while ( nPanelPos > 0 )
{
const short nCompare = i_pPanelCompare->compareToolPanelsURLs(
*resource,
GetPanelResourceURL( --nPanelPos )
);
if ( nCompare >= 0 )
{
++nPanelPos;
break;
}
}
}
nPanelPos = m_aPanelDeck.InsertPanel( pCustomPanel, nPanelPos );
if ( ::comphelper::getBOOL( aResourceNode.getNodeValue( "Visible" ) ) )
sFirstVisiblePanelResource = *resource;
}
if ( sFirstVisiblePanelResource.getLength() == 0 )
sFirstVisiblePanelResource = sFirstPanelResource;
if ( sFirstVisiblePanelResource.getLength() )
{
::boost::optional< size_t > aPanelPos( GetPanelPos( sFirstVisiblePanelResource ) );
OSL_ENSURE( !!aPanelPos, "ModuleTaskPane_Impl::impl_isToolPanelResource: just inserted it, and it's not there?!" );
if ( !!aPanelPos )
m_rAntiImpl.PostUserEvent( LINK( this, ModuleTaskPane_Impl, OnActivatePanel ), reinterpret_cast< void* >( *aPanelPos ) );
}
}
//------------------------------------------------------------------------------------------------------------------
bool ModuleTaskPane_Impl::ModuleHasToolPanels( const ::rtl::OUString& i_rModuleIdentifier )
{
const ::utl::OConfigurationTreeRoot aWindowStateConfig( lcl_getModuleUIElementStatesConfig( i_rModuleIdentifier ) );
if ( !aWindowStateConfig.isValid() )
return false;
const Sequence< ::rtl::OUString > aUIElements( aWindowStateConfig.getNodeNames() );
for ( const ::rtl::OUString* resource = aUIElements.getConstArray();
resource != aUIElements.getConstArray() + aUIElements.getLength();
++resource
)
{
if ( impl_isToolPanelResource( *resource ) )
return true;
}
return false;
}
//------------------------------------------------------------------------------------------------------------------
::boost::optional< size_t > ModuleTaskPane_Impl::GetPanelPos( const ::rtl::OUString& i_rResourceURL )
{
::boost::optional< size_t > aPanelPos;
for ( size_t i = 0; i < m_aPanelDeck.GetPanelCount(); ++i )
{
const ::svt::PToolPanel pPanel( m_aPanelDeck.GetPanel( i ) );
const CustomToolPanel* pCustomPanel = dynamic_cast< const CustomToolPanel* >( pPanel.get() );
ENSURE_OR_CONTINUE( pCustomPanel != NULL, "ModuleTaskPane_Impl::GetPanelPos: illegal panel implementation!" );
if ( pCustomPanel->GetResourceURL() == i_rResourceURL )
{
aPanelPos = i;
break;
}
}
return aPanelPos;
}
//------------------------------------------------------------------------------------------------------------------
::rtl::OUString ModuleTaskPane_Impl::GetPanelResourceURL( const size_t i_nPanelPos ) const
{
ENSURE_OR_RETURN( i_nPanelPos < m_aPanelDeck.GetPanelCount(), "ModuleTaskPane_Impl::GetPanelResourceURL: illegal panel position!", ::rtl::OUString() );
const ::svt::PToolPanel pPanel( m_aPanelDeck.GetPanel( i_nPanelPos ) );
const CustomToolPanel* pCustomPanel = dynamic_cast< const CustomToolPanel* >( pPanel.get() );
ENSURE_OR_RETURN( pCustomPanel != NULL, "ModuleTaskPane_Impl::GetPanelPos: illegal panel implementation!", ::rtl::OUString() );
return pCustomPanel->GetResourceURL();
}
//------------------------------------------------------------------------------------------------------------------
void ModuleTaskPane_Impl::SetDrawersLayout()
{
const ::svt::PDeckLayouter pLayouter( m_aPanelDeck.GetLayouter() );
const ::svt::DrawerDeckLayouter* pDrawerLayouter = dynamic_cast< const ::svt::DrawerDeckLayouter* >( pLayouter.get() );
if ( pDrawerLayouter != NULL )
// already have the proper layout
return;
m_aPanelDeck.SetLayouter( new ::svt::DrawerDeckLayouter( m_aPanelDeck, m_aPanelDeck ) );
}
//------------------------------------------------------------------------------------------------------------------
void ModuleTaskPane_Impl::SetTabsLayout( const ::svt::TabAlignment i_eTabAlignment, const ::svt::TabItemContent i_eTabContent )
{
::svt::PDeckLayouter pLayouter( m_aPanelDeck.GetLayouter() );
::svt::TabDeckLayouter* pTabLayouter = dynamic_cast< ::svt::TabDeckLayouter* >( pLayouter.get() );
if ( ( pTabLayouter != NULL )
&& ( pTabLayouter->GetTabAlignment() == i_eTabAlignment )
&& ( pTabLayouter->GetTabItemContent() == i_eTabContent )
)
// already have the requested layout
return;
if ( pTabLayouter && ( pTabLayouter->GetTabAlignment() == i_eTabAlignment ) )
{
// changing only the item content does not require a new layouter instance
pTabLayouter->SetTabItemContent( i_eTabContent );
return;
}
m_aPanelDeck.SetLayouter( new ::svt::TabDeckLayouter( m_aPanelDeck, m_aPanelDeck, i_eTabAlignment, i_eTabContent ) );
}
//==================================================================================================================
//= ModuleTaskPane
//==================================================================================================================
//------------------------------------------------------------------------------------------------------------------
ModuleTaskPane::ModuleTaskPane( Window& i_rParentWindow, const Reference< XFrame >& i_rDocumentFrame )
:Window( &i_rParentWindow, WB_DIALOGCONTROL )
,m_pImpl( new ModuleTaskPane_Impl( *this, i_rDocumentFrame, NULL ) )
{
}
//------------------------------------------------------------------------------------------------------------------
ModuleTaskPane::ModuleTaskPane( Window& i_rParentWindow, const Reference< XFrame >& i_rDocumentFrame,
const IToolPanelCompare& i_rCompare )
:Window( &i_rParentWindow, WB_DIALOGCONTROL )
,m_pImpl( new ModuleTaskPane_Impl( *this, i_rDocumentFrame, &i_rCompare ) )
{
}
//------------------------------------------------------------------------------------------------------------------
ModuleTaskPane::~ModuleTaskPane()
{
}
//------------------------------------------------------------------------------------------------------------------
bool ModuleTaskPane::ModuleHasToolPanels( const ::rtl::OUString& i_rModuleIdentifier )
{
return ModuleTaskPane_Impl::ModuleHasToolPanels( i_rModuleIdentifier );
}
//------------------------------------------------------------------------------------------------------------------
bool ModuleTaskPane::ModuleHasToolPanels( const Reference< XFrame >& i_rDocumentFrame )
{
return ModuleTaskPane_Impl::ModuleHasToolPanels( lcl_identifyModule( i_rDocumentFrame ) );
}
//------------------------------------------------------------------------------------------------------------------
void ModuleTaskPane::Resize()
{
Window::Resize();
m_pImpl->OnResize();
}
//------------------------------------------------------------------------------------------------------------------
void ModuleTaskPane::GetFocus()
{
Window::GetFocus();
m_pImpl->OnGetFocus();
}
//------------------------------------------------------------------------------------------------------------------
::svt::ToolPanelDeck& ModuleTaskPane::GetPanelDeck()
{
return m_pImpl->GetPanelDeck();
}
//------------------------------------------------------------------------------------------------------------------
const ::svt::ToolPanelDeck& ModuleTaskPane::GetPanelDeck() const
{
return m_pImpl->GetPanelDeck();
}
//------------------------------------------------------------------------------------------------------------------
::boost::optional< size_t > ModuleTaskPane::GetPanelPos( const ::rtl::OUString& i_rResourceURL )
{
return m_pImpl->GetPanelPos( i_rResourceURL );
}
//------------------------------------------------------------------------------------------------------------------
::rtl::OUString ModuleTaskPane::GetPanelResourceURL( const size_t i_nPanelPos ) const
{
return m_pImpl->GetPanelResourceURL( i_nPanelPos );
}
//------------------------------------------------------------------------------------------------------------------
void ModuleTaskPane::SetDrawersLayout()
{
m_pImpl->SetDrawersLayout();
}
//------------------------------------------------------------------------------------------------------------------
void ModuleTaskPane::SetTabsLayout( const ::svt::TabAlignment i_eTabAlignment, const ::svt::TabItemContent i_eTabContent )
{
m_pImpl->SetTabsLayout( i_eTabAlignment, i_eTabContent );
}
// =====================================================================================================================
// = PanelSelectorLayout
// =====================================================================================================================
enum PanelSelectorLayout
{
LAYOUT_DRAWERS,
LAYOUT_TABS_RIGHT,
LAYOUT_TABS_LEFT,
LAYOUT_TABS_TOP,
LAYOUT_TABS_BOTTOM
};
//==================================================================================================================
//= helper
//==================================================================================================================
namespace
{
PanelSelectorLayout lcl_getTabLayoutFromAlignment( const SfxChildAlignment i_eAlignment )
{
switch ( i_eAlignment )
{
case SFX_ALIGN_LEFT:
return LAYOUT_TABS_LEFT;
case SFX_ALIGN_TOP:
return LAYOUT_TABS_TOP;
case SFX_ALIGN_BOTTOM:
return LAYOUT_TABS_BOTTOM;
default:
return LAYOUT_TABS_RIGHT;
}
}
}
// =====================================================================================================================
// = PanelDescriptor
// =====================================================================================================================
/** is a helper class for TaskPaneController_Impl, holding the details about a single panel which is not
contained in the IToolPanel implementation itself.
*/
struct PanelDescriptor
{
::svt::PToolPanel pPanel;
bool bHidden;
PanelDescriptor()
:pPanel()
,bHidden( false )
{
}
PanelDescriptor( const ::svt::PToolPanel& i_rPanel )
:pPanel( i_rPanel )
,bHidden( false )
{
}
};
//==================================================================================================================
//= TaskPaneController_Impl
//==================================================================================================================
class TaskPaneController_Impl :public ::boost::noncopyable
,public ::svt::IToolPanelDeckListener
{
public:
TaskPaneController_Impl(
ModuleTaskPane& i_rTaskPane,
TitledDockingWindow& i_rDockingWindow
);
~TaskPaneController_Impl();
void SetDefaultTitle( const String& i_rTitle );
void ActivateToolPanel( const ::rtl::OUString& i_rPanelURL );
protected:
// IToolPanelDeckListener overridables
virtual void PanelInserted( const ::svt::PToolPanel& i_pPanel, const size_t i_nPosition );
virtual void PanelRemoved( const size_t i_nPosition );
virtual void ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive );
virtual void LayouterChanged( const ::svt::PDeckLayouter& i_rNewLayouter );
virtual void Dying();
private:
DECL_LINK( OnToolboxClicked, ToolBox* );
DECL_LINK( OnMenuItemSelected, Menu* );
DECL_LINK( DockingChanged, TitledDockingWindow* );
::std::auto_ptr< PopupMenu > impl_createPopupMenu() const;
/// sets the given layout for the panel selector
void impl_setLayout( const PanelSelectorLayout i_eLayout, const bool i_bForce = false );
/// returns the current layout of the panel selector
PanelSelectorLayout
impl_getLayout() const { return m_eCurrentLayout; }
void impl_updateDockingWindowTitle();
void impl_togglePanelVisibility( const size_t i_nLogicalPanelIndex );
size_t impl_getLogicalPanelIndex( const size_t i_nVisibleIndex );
private:
enum MenuId
{
MID_UNLOCK_TASK_PANEL = 1,
MID_LOCK_TASK_PANEL = 2,
MID_LAYOUT_TABS = 3,
MID_LAYOUT_DRAWERS = 4,
MID_FIRST_PANEL = 5
};
private:
typedef ::std::vector< PanelDescriptor > PanelDescriptors;
ModuleTaskPane& m_rTaskPane;
TitledDockingWindow& m_rDockingWindow;
sal_uInt16 m_nViewMenuID;
PanelSelectorLayout m_eCurrentLayout;
PanelDescriptors m_aPanelRepository;
bool m_bTogglingPanelVisibility;
::rtl::OUString m_sDefaultTitle;
};
//------------------------------------------------------------------------------------------------------------------
TaskPaneController_Impl::TaskPaneController_Impl( ModuleTaskPane& i_rTaskPane, TitledDockingWindow& i_rDockingWindow )
:m_rTaskPane( i_rTaskPane )
,m_rDockingWindow( i_rDockingWindow )
,m_nViewMenuID( 0 )
,m_eCurrentLayout( LAYOUT_DRAWERS )
,m_aPanelRepository()
,m_bTogglingPanelVisibility( false )
,m_sDefaultTitle()
{
m_rDockingWindow.ResetToolBox();
m_nViewMenuID = m_rDockingWindow.AddDropDownToolBoxItem(
String( SfxResId( STR_SFX_TASK_PANE_VIEW ) ),
HID_TASKPANE_VIEW_MENU,
LINK( this, TaskPaneController_Impl, OnToolboxClicked )
);
m_rDockingWindow.SetEndDockingHdl( LINK( this, TaskPaneController_Impl, DockingChanged ) );
impl_setLayout(LAYOUT_TABS_RIGHT, true);
m_rTaskPane.GetPanelDeck().AddListener( *this );
// initialize the panel repository
for ( size_t i = 0; i < m_rTaskPane.GetPanelDeck().GetPanelCount(); ++i )
{
::svt::PToolPanel pPanel( m_rTaskPane.GetPanelDeck().GetPanel( i ) );
m_aPanelRepository.push_back( PanelDescriptor( pPanel ) );
}
SetDefaultTitle( String( SfxResId( STR_SFX_TASKS ) ) );
}
//------------------------------------------------------------------------------------------------------------------
TaskPaneController_Impl::~TaskPaneController_Impl()
{
m_rTaskPane.GetPanelDeck().RemoveListener( *this );
// remove the panels which are not under the control of the panel deck currently
for ( PanelDescriptors::iterator panelPos = m_aPanelRepository.begin();
panelPos != m_aPanelRepository.end();
++panelPos
)
{
if ( panelPos->bHidden )
panelPos->pPanel->Dispose();
}
m_aPanelRepository.clear();
}
// -----------------------------------------------------------------------------------------------------------------
void TaskPaneController_Impl::SetDefaultTitle( const String& i_rTitle )
{
m_sDefaultTitle = i_rTitle;
impl_updateDockingWindowTitle();
}
//------------------------------------------------------------------------------------------------------------------
void TaskPaneController_Impl::ActivateToolPanel( const ::rtl::OUString& i_rPanelURL )
{
::boost::optional< size_t > aPanelPos( m_rTaskPane.GetPanelPos( i_rPanelURL ) );
ENSURE_OR_RETURN_VOID( !!aPanelPos, "TaskPaneController_Impl::ActivateToolPanel: no such panel!" );
if ( aPanelPos == m_rTaskPane.GetPanelDeck().GetActivePanel() )
{
::svt::PToolPanel pPanel( m_rTaskPane.GetPanelDeck().GetPanel( *aPanelPos ) );
pPanel->GrabFocus();
}
else
{
m_rTaskPane.GetPanelDeck().ActivatePanel( aPanelPos );
}
}
// -----------------------------------------------------------------------------------------------------------------
IMPL_LINK( TaskPaneController_Impl, DockingChanged, TitledDockingWindow*, i_pDockingWindow )
{
ENSURE_OR_RETURN( i_pDockingWindow && &m_rDockingWindow, "TaskPaneController_Impl::DockingChanged: where does this come from?", 0L );
if ( impl_getLayout() == LAYOUT_DRAWERS )
return 0L;
impl_setLayout( lcl_getTabLayoutFromAlignment( i_pDockingWindow->GetAlignment() ) );
return 1L;
}
// -----------------------------------------------------------------------------------------------------------------
IMPL_LINK( TaskPaneController_Impl, OnToolboxClicked, ToolBox*, i_pToolBox )
{
if ( i_pToolBox->GetCurItemId() == m_nViewMenuID )
{
i_pToolBox->EndSelection();
::std::auto_ptr< PopupMenu > pMenu = impl_createPopupMenu();
pMenu->SetSelectHdl( LINK( this, TaskPaneController_Impl, OnMenuItemSelected ) );
// pass toolbox button rect so the menu can stay open on button up
Rectangle aMenuRect( i_pToolBox->GetItemRect( m_nViewMenuID ) );
aMenuRect.SetPos( i_pToolBox->GetPosPixel() );
pMenu->Execute( &m_rDockingWindow, aMenuRect, POPUPMENU_EXECUTE_DOWN );
}
return 0;
}
// ---------------------------------------------------------------------------------------------------------------------
IMPL_LINK( TaskPaneController_Impl, OnMenuItemSelected, Menu*, i_pMenu )
{
ENSURE_OR_RETURN( i_pMenu, "TaskPaneController_Impl::OnMenuItemSelected: illegal menu!", 0L );
i_pMenu->Deactivate();
switch ( i_pMenu->GetCurItemId() )
{
case MID_UNLOCK_TASK_PANEL:
m_rDockingWindow.SetFloatingMode( sal_True );
break;
case MID_LOCK_TASK_PANEL:
m_rDockingWindow.SetFloatingMode( sal_False );
break;
case MID_LAYOUT_DRAWERS:
impl_setLayout( LAYOUT_DRAWERS );
break;
case MID_LAYOUT_TABS:
impl_setLayout( lcl_getTabLayoutFromAlignment( m_rDockingWindow.GetAlignment() ) );
break;
default:
{
size_t nPanelIndex = size_t( i_pMenu->GetCurItemId() - MID_FIRST_PANEL );
impl_togglePanelVisibility( nPanelIndex );
}
break;
}
return 1L;
}
// ---------------------------------------------------------------------------------------------------------------------
size_t TaskPaneController_Impl::impl_getLogicalPanelIndex( const size_t i_nVisibleIndex )
{
size_t nLogicalIndex = 0;
size_t nVisibleIndex( i_nVisibleIndex );
for ( size_t i=0; i < m_aPanelRepository.size(); ++i )
{
if ( !m_aPanelRepository[i].bHidden )
{
if ( !nVisibleIndex )
break;
--nVisibleIndex;
}
++nLogicalIndex;
}
return nLogicalIndex;
}
// ---------------------------------------------------------------------------------------------------------------------
void TaskPaneController_Impl::PanelInserted( const ::svt::PToolPanel& i_pPanel, const size_t i_nPosition )
{
if ( m_bTogglingPanelVisibility )
return;
const size_t nLogicalIndex( impl_getLogicalPanelIndex( i_nPosition ) );
m_aPanelRepository.insert( m_aPanelRepository.begin() + nLogicalIndex, PanelDescriptor( i_pPanel ) );
}
// ---------------------------------------------------------------------------------------------------------------------
void TaskPaneController_Impl::PanelRemoved( const size_t i_nPosition )
{
if ( m_bTogglingPanelVisibility )
return;
const size_t nLogicalIndex( impl_getLogicalPanelIndex( i_nPosition ) );
m_aPanelRepository.erase( m_aPanelRepository.begin() + nLogicalIndex );
}
// ---------------------------------------------------------------------------------------------------------------------
void TaskPaneController_Impl::ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive )
{
if ( impl_getLayout() == LAYOUT_DRAWERS )
// no adjustment of the title when we use the classical "drawers" layout
return;
impl_updateDockingWindowTitle( );
(void)i_rOldActive;
(void)i_rNewActive;
}
// ---------------------------------------------------------------------------------------------------------------------
void TaskPaneController_Impl::LayouterChanged( const ::svt::PDeckLayouter& i_rNewLayouter )
{
// not interested in
(void)i_rNewLayouter;
}
// ---------------------------------------------------------------------------------------------------------------------
void TaskPaneController_Impl::Dying()
{
OSL_ENSURE( false, "TaskPaneController_Impl::Dying: unexpected call!" );
// We are expected to live longer than the ToolPanelDeck we work with. Since we remove ourself, in our dtor,
// as listener from the panel deck, this method here should never be called.
}
// ---------------------------------------------------------------------------------------------------------------------
void TaskPaneController_Impl::impl_togglePanelVisibility( const size_t i_nLogicalPanelIndex )
{
ENSURE_OR_RETURN_VOID( i_nLogicalPanelIndex < m_aPanelRepository.size(), "illegal index" );
// get the actual panel index, within the deck
size_t nActualPanelIndex(0);
for ( size_t i=0; i < i_nLogicalPanelIndex; ++i )
{
if ( !m_aPanelRepository[i].bHidden )
++nActualPanelIndex;
}
::boost::optional< size_t > aActivatePanel;
m_bTogglingPanelVisibility = true;
if ( m_aPanelRepository[ i_nLogicalPanelIndex ].bHidden )
{
OSL_VERIFY( m_rTaskPane.GetPanelDeck().InsertPanel( m_aPanelRepository[ i_nLogicalPanelIndex ].pPanel, nActualPanelIndex ) == nActualPanelIndex );
// if there has not been an active panel before, activate the newly inserted one
::boost::optional< size_t > aActivePanel( m_rTaskPane.GetPanelDeck().GetActivePanel() );
if ( !aActivePanel )
aActivatePanel = nActualPanelIndex;
}
else
{
OSL_VERIFY( m_rTaskPane.GetPanelDeck().RemovePanel( nActualPanelIndex ).get() == m_aPanelRepository[ i_nLogicalPanelIndex ].pPanel.get() );
}
m_bTogglingPanelVisibility = false;
m_aPanelRepository[ i_nLogicalPanelIndex ].bHidden = !m_aPanelRepository[ i_nLogicalPanelIndex ].bHidden;
if ( !!aActivatePanel )
m_rTaskPane.GetPanelDeck().ActivatePanel( *aActivatePanel );
}
// ---------------------------------------------------------------------------------------------------------------------
void TaskPaneController_Impl::impl_setLayout( const PanelSelectorLayout i_eLayout, const bool i_bForce )
{
if ( !i_bForce && ( m_eCurrentLayout == i_eLayout ) )
return;
switch ( i_eLayout )
{
case LAYOUT_DRAWERS:
m_rTaskPane.SetDrawersLayout();
break;
case LAYOUT_TABS_TOP:
m_rTaskPane.SetTabsLayout( ::svt::TABS_TOP, ::svt::TABITEM_IMAGE_ONLY );
break;
case LAYOUT_TABS_BOTTOM:
m_rTaskPane.SetTabsLayout( ::svt::TABS_BOTTOM, ::svt::TABITEM_IMAGE_ONLY );
break;
case LAYOUT_TABS_LEFT:
m_rTaskPane.SetTabsLayout( ::svt::TABS_LEFT, ::svt::TABITEM_IMAGE_ONLY );
break;
case LAYOUT_TABS_RIGHT:
m_rTaskPane.SetTabsLayout( ::svt::TABS_RIGHT, ::svt::TABITEM_IMAGE_ONLY );
break;
}
m_eCurrentLayout = i_eLayout;
impl_updateDockingWindowTitle();
}
// ---------------------------------------------------------------------------------------------------------------------
void TaskPaneController_Impl::impl_updateDockingWindowTitle()
{
::boost::optional< size_t > aActivePanel( m_rTaskPane.GetPanelDeck().GetActivePanel() );
if ( !aActivePanel || ( impl_getLayout() == LAYOUT_DRAWERS ) )
m_rDockingWindow.SetTitle( m_sDefaultTitle );
else
{
size_t nNewActive( *aActivePanel );
for ( size_t i=0; i < m_aPanelRepository.size(); ++i )
{
if ( m_aPanelRepository[i].bHidden )
continue;
if ( !nNewActive )
{
m_rDockingWindow.SetTitle( m_aPanelRepository[i].pPanel->GetDisplayName() );
break;
}
--nNewActive;
}
}
}
// ---------------------------------------------------------------------------------------------------------------------
::std::auto_ptr< PopupMenu > TaskPaneController_Impl::impl_createPopupMenu() const
{
::std::auto_ptr<PopupMenu> pMenu( new PopupMenu );
FloatingWindow* pMenuWindow = static_cast< FloatingWindow* >( pMenu->GetWindow() );
if ( pMenuWindow != NULL )
{
pMenuWindow->SetPopupModeFlags ( pMenuWindow->GetPopupModeFlags() | FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE );
}
// Add one entry for every tool panel element to individually make
// them visible or hide them.
sal_uInt16 nIndex = MID_FIRST_PANEL;
for ( size_t i=0; i<m_aPanelRepository.size(); ++i, ++nIndex )
{
const PanelDescriptor& rPanelDesc( m_aPanelRepository[i] );
pMenu->InsertItem( nIndex, rPanelDesc.pPanel->GetDisplayName(), MIB_CHECKABLE );
pMenu->CheckItem( nIndex, !rPanelDesc.bHidden );
}
pMenu->InsertSeparator();
#if OSL_DEBUG_LEVEL > 0
pMenu->InsertItem( MID_LAYOUT_TABS, String::CreateFromAscii( "Tab-Layout (exp.)" ), MIB_CHECKABLE );
pMenu->CheckItem( MID_LAYOUT_TABS, impl_getLayout() != LAYOUT_DRAWERS );
pMenu->InsertItem( MID_LAYOUT_DRAWERS, String::CreateFromAscii( "Drawer-Layout" ), MIB_CHECKABLE );
pMenu->CheckItem( MID_LAYOUT_DRAWERS, impl_getLayout() == LAYOUT_DRAWERS );
pMenu->InsertSeparator();
#endif
// Add entry for docking or un-docking the tool panel.
if ( m_rDockingWindow.IsFloatingMode() )
pMenu->InsertItem(
MID_LOCK_TASK_PANEL,
String( SfxResId( STR_SFX_DOCK ) )
);
else
pMenu->InsertItem(
MID_UNLOCK_TASK_PANEL,
String( SfxResId( STR_SFX_UNDOCK ) )
);
pMenu->RemoveDisabledEntries( sal_False, sal_False );
return pMenu;
}
//==================================================================================================================
//= TaskPaneController
//==================================================================================================================
//------------------------------------------------------------------------------------------------------------------
TaskPaneController::TaskPaneController( ModuleTaskPane& i_rTaskPane, TitledDockingWindow& i_rDockingWindow )
:m_pImpl( new TaskPaneController_Impl( i_rTaskPane, i_rDockingWindow ) )
{
}
//------------------------------------------------------------------------------------------------------------------
TaskPaneController::~TaskPaneController()
{
}
//------------------------------------------------------------------------------------------------------------------
void TaskPaneController::SetDefaultTitle( const String& i_rTitle )
{
m_pImpl->SetDefaultTitle( i_rTitle );
}
//------------------------------------------------------------------------------------------------------------------
void TaskPaneController::ActivateToolPanel( const ::rtl::OUString& i_rPanelURL )
{
m_pImpl->ActivateToolPanel( i_rPanelURL );
}
//......................................................................................................................
} // namespace sfx2
//......................................................................................................................
|
module Chapter7
%default total
{-
interface Functor f => Applicative (f : Type -> Type) where
pure : a -> f a
(<*>) : f (a -> b) -> f a -> f b
interface Applicative m => Monad (m : Type -> Type) where
(>>=) : m a -> (a -> m b) -> m b
join : m (m a) = m a
Monad Maybe where
(>>=) Nothing next = Nothing
(>>=) (Just x) next = next x
-}
|
import data.int.interval
import data.finset.nat_antidiagonal
import laurent_measures.aux_lemmas
import laurent_measures.basic
import laurent_measures.theta
import linear_algebra.basic
import order.filter.at_top_bot tactic.linarith
import for_mathlib.nnreal
/-!
This file introduces the maps
* `θ`, which is the specialization of evaluation-at-ξ map `ϑ` from `laurent_measures.theta`
at `ξ=2⁻¹`.
* `ϕ` which corresponds to multiplying a Laurent series in `ℒ S = (laurent_measures r S)`
for `r = 2^(1/p)` by `T⁻¹-2`.
* `ψ` corresponds to dividing a Laurent series by `(T⁻¹-2)`. It is defined only on series
vanishing at `2⁻¹`, so that it again takes values in `ℒ S`
* The maps `Θ`, `Φ` and `Ψ` are the "measurifications" of `θ`, `ϕ` and `ψ`,
so they are morphisms in the right category (**[FAE]** Not here any more!)
The main results are
* `injective_ϕ` stating that `ϕ` is injective;
* `θ_ϕ_complex` stating that `ϕ ∘ θ = 0`; and
* `θ_ϕ_exact` stating that the kernel of `θ` coincides with the image of `ϕ`.
Together with `ϑ_surjective` from `laurent_measures.theta` (specialized at `ξ=2⁻¹`, so that `ϑ` is
`θ`) this is the statement of Theorem 6.9 of `Analytic.pdf` of interest to us, although only "on
elements" and not yet as a Short Exact Sequence in the right category.
-/
noncomputable theory
open nnreal theta laurent_measures aux_thm69 finset
open_locale nnreal classical big_operators topological_space
section phi
parameter {r : ℝ≥0}
local notation `ℒ` := laurent_measures r
variables [fact (0 < r)]
variable {S : Fintype}
def ϕ : ℒ S → ℒ S :=
λ F, shift (1) F - 2 • F
lemma ϕ_apply (F : ℒ S) (s : S) (n : ℤ) : ϕ F s n = F s (n+1) - 2 * F s n :=
by simp only [ϕ, sub_apply, nsmul_apply, shift_to_fun_to_fun, nsmul_eq_mul]; refl
lemma ϕ_natural (S T : Fintype) (f : S ⟶ T) : --[fact (0 < p)] [fact ( p ≤ 1)] :
ϕ ∘ laurent_measures.map_hom f = laurent_measures.map_hom f ∘ ϕ :=
begin
ext F t n,
simp only [ϕ, sum_sub_distrib, mul_sum, function.comp_app, map_hom_to_fun, sub_apply,
nsmul_apply, shift_to_fun_to_fun,
map_apply, nsmul_eq_mul, mul_ite, mul_zero], -- squeezed for time
end
-- #check @ϕ
-- lemma tsum_reindex (F : ℒ S) (N : ℤ) (s : S) : ∑' (l : ℕ), (F s (N + l) : ℝ) * (2 ^ l)⁻¹ =
-- 2 ^ N * ∑' (m : {m : ℤ // N ≤ m}), (F s m : ℝ) * (2 ^ m.1)⁻¹ :=
-- begin
-- have h_shift := int_tsum_shift (λ n, (F s n : ℝ) * (2 ^ (-n))) N,
-- simp only at h_shift,
-- simp_rw [subtype.val_eq_coe, ← zpow_neg],
-- rw [← h_shift, ← _root_.tsum_mul_left, tsum_congr],
-- intro n,
-- rw [mul_comm (_ ^ N), mul_assoc, ← (zpow_add₀ (@two_ne_zero ℝ _ _)), neg_add_rev,
-- neg_add_cancel_comm, zpow_neg, zpow_coe_nat, add_comm],
-- end
variable [fact (r < 1)]
lemma injective_ϕ (F : ℒ S) (H : ϕ F = 0) : F = 0 :=
begin
dsimp only [ϕ] at H, rw [sub_eq_zero] at H,
replace H : ∀ n : ℤ, ∀ s : S, 2 * F s (n - 1) = F s n,
{ intros n s,
rw laurent_measures.ext_iff at H,
convert (H s (n-1)).symm using 1,
{ rw [two_smul, two_mul], refl, },
{ simp [shift] } },
ext s n,
apply int.induction_on' n (F.d - 1),
{ refine lt_d_eq_zero _ _ (F.d - 1) _,
simp only [sub_lt_self_iff, zero_lt_one], },
{ intros k h hk₀,
simp [← H (k + 1) s, add_sub_cancel, hk₀, mul_zero] },
{ intros k h hk₀,
simpa only [hk₀, mul_eq_zero, bit0_eq_zero, one_ne_zero, false_or, zero_apply] using H k s }
end
lemma injective_ϕ' : function.injective (ϕ : ℒ S → ℒ S) :=
begin
let PHI : comphaus_filtered_pseudo_normed_group_hom (ℒ S) (ℒ S) :=
shift (1) - 2 • comphaus_filtered_pseudo_normed_group_hom.id,
apply (injective_iff_map_eq_zero (PHI.to_add_monoid_hom)).mpr,
exact injective_ϕ
end
end phi
section mem_exact
parameter {p : ℝ≥0}
/-- `r`, or `r(p)`, is `2⁻ᵖ`. -/
def r : ℝ≥0 := 2⁻¹ ^ (p : ℝ)
lemma r_pos : 0 < r :=
suffices 0 < (2 : ℝ≥0)⁻¹ ^ (p : ℝ), by simpa [r],
rpow_pos (nnreal.inv_pos.mpr zero_lt_two)
instance r_pos' : fact (0 < r) := ⟨r_pos⟩
lemma r_coe : (2⁻¹ : ℝ) ^ (p : ℝ) = r :=
begin
have : (2⁻¹ : ℝ) = ((2⁻¹ : ℝ≥0) : ℝ),
simp only [one_div, nonneg.coe_inv, nnreal.coe_bit0, nonneg.coe_one],
rw [this, ← nnreal.coe_rpow, nnreal.coe_eq],
refl,
end
variable [fact(0 < p)]
lemma r_lt_one : r < 1 :=
begin
refine rpow_lt_one nnreal.two_inv_lt_one _,
rw nnreal.coe_pos,
exact fact.out _
end
instance r_lt_one' : fact (r < 1) := ⟨r_lt_one⟩
variable {S : Fintype}
local notation `ℒ` := laurent_measures r
local notation `ℳ` := real_measures p
theorem nnreal.rpow_int_cast (x : nnreal) (n : ℤ) : x ^ (n : ℝ) = x ^ n :=
begin
apply subtype.ext,
simp,
end
def θ : ℒ S → ℳ S := ϑ 2⁻¹ r p S
lemma θ_natural [fact (0 < p)] [fact (p ≤ 1)] (S T : Fintype) (f : S ⟶ T) (F : ℒ S) (t : T) :
θ (map f F) t = real_measures.map f (θ F) t :=
begin
simp only [θ, ϑ, one_div, map_apply, int.cast_sum, inv_zpow', zpow_neg, real_measures.map_apply],
rw ← tsum_sum,
{ congr', ext n, exact sum_mul, },
intros,
rw mem_filter at H,
rcases H with ⟨-, rfl⟩,
have := F.summable i,
refine summable.add_compl (_ : summable (_ ∘ (coe : {n : ℤ | 0 ≤ n} → ℤ))) _,
{ have moo := summable.comp_injective this
(subtype.coe_injective : function.injective (coe : {n : ℤ | 0 ≤ n} → ℤ)),
refine summable_of_norm_bounded _ (moo) _, clear moo this,
rintro ⟨n, (hn : 0 ≤ n)⟩,
simp only [function.comp_app, subtype.coe_mk, norm_mul, norm_inv, norm_zpow, real.norm_two],
rw (F i n).norm_cast_real,
apply mul_le_mul_of_nonneg_left _ (norm_nonneg _),
delta r,
delta r,
rw (by push_cast : ((2 : ℝ) ^ n)⁻¹ = ((2 ^ n)⁻¹ : nnreal)),
norm_cast,
rw [← nnreal.rpow_int_cast, ← inv_rpow],
rw nnreal.rpow_int_cast,
set m := n.nat_abs with hm,
have hmn : n = m := by { rw hm, exact int.eq_nat_abs_of_zero_le hn },
rw hmn,
norm_cast,
apply pow_le_pow_of_le_left', clear hn hmn hm m n,
apply nnreal.le_self_rpow' (nnreal.two_inv_lt_one.le),
norm_cast,
exact fact.out _,
},
{
obtain ⟨d, hd⟩ := exists_bdd_filtration (r_pos) (r_lt_one) F,
apply summable_of_ne_finset_zero, -- missing finset
swap, exact (finset.subtype _ (finset.Ico d 0)),
rintros ⟨z, (hz : ¬ (0 ≤ z))⟩ hz2,
simp only [subtype.coe_mk, mul_eq_zero, int.cast_eq_zero, inv_eq_zero],
left,
apply hd,
simp only [mem_subtype, subtype.coe_mk, mem_Ico, not_and, not_le] at hz2,
by_contra h,
push_neg at h,
apply hz,
specialize hz2 h,
push_neg at hz2,
exact hz2 },
end
variables [fact (p < 1)]
lemma half_lt_r : 2⁻¹ < r :=
calc (2⁻¹:ℝ≥0)
= 2⁻¹ ^ (1:ℝ) : (rpow_one (2⁻¹:ℝ≥0)).symm
... < r : rpow_lt_rpow_of_exponent_gt (begin rw nnreal.inv_pos, norm_num, end)
(begin apply nnreal.inv_lt_one, norm_num end) $
(nnreal.coe_lt_coe.mpr (fact.out _)).trans_le (nnreal.coe_one).le
lemma one_lt_two_r : 1 < 2 * r :=
begin
have := half_lt_r,
have this2 : (2⁻¹ : ℝ) < r,
assumption_mod_cast,
rw inv_pos_lt_iff_one_lt_mul' at this2, assumption_mod_cast,
norm_num,
end
lemma r_inv_lt_2 : r⁻¹ < 2 :=
begin
rw ← inv_inv (2 : ℝ≥0),
exact nnreal.inv_lt_inv (by norm_num) half_lt_r,
end
lemma laurent_measures.summable_half (F : ℒ S) (s : S) :
summable (λ n, ((F s n) : ℝ) * 2⁻¹ ^ n) :=
aux_thm69.summable_smaller_radius F.d (F.summable s) (λ n hn, lt_d_eq_zero _ _ _ hn) half_lt_r
lemma θ_ϕ_complex (F : ℒ S) : (θ ∘ ϕ) F = 0 :=
begin
have t0 : (2 : ℝ)⁻¹ ≠ 0 := inv_ne_zero two_ne_zero,
funext s,
convert_to ∑' (n : ℤ), ((F s (n + 1) - 2 * F s n) : ℝ) * 2⁻¹ ^ n = 0,
{ apply tsum_congr,
intro b,
field_simp [ϕ] },
simp_rw [sub_mul],
rw [tsum_sub, sub_eq_zero],
-- old proof was slicker :-(
{ refine tsum_eq_tsum_of_ne_zero_bij (λ i, (i.val : ℤ) - 1) _ _ _,
{ rintros ⟨x, _⟩ ⟨y, _⟩ h, dsimp at *, linarith },
{ rintros x hx,
refine ⟨⟨x + 1, _⟩, _⟩,
{ rw function.mem_support at ⊢ hx,
convert hx using 1,
simp [zpow_add₀],
ring },
{ simp } },
{ rintro ⟨i, hi⟩,
simp [zpow_sub₀],
ring } },
{ rw ← (equiv.add_group_add (-1 : ℤ)).summable_iff,
simp only [function.comp, one_div, inv_zpow', equiv.add_group_add_apply,
neg_add_cancel_comm],
convert summable.mul_right 2 (F.summable_half s),
ext x,
simp [zpow_add₀], ring },
{ simp_rw [mul_assoc],
convert (F.summable_half s).mul_left 2 },
end
.
/-!
### Definition of ψ
This involves dividing by T⁻¹ - 2 and we have to check that this process converges.
The proof below is pretty icky. It's "do some trivial rearrangements and it boils
down to the fact that you can interchange the order of summation in a ℝ≥0-valued
sum of sums"
-/
lemma nnreal.summable_mul_left_iff {X : Type*} {f : X → ℝ≥0} {a : ℝ≥0} (ha : a ≠ 0) :
summable f ↔ summable (λ (x : X), a * f x) :=
begin
rw [← nnreal.summable_coe, ← nnreal.summable_coe],
rw summable_mul_left_iff (by exact_mod_cast ha : (a : ℝ) ≠ 0),
apply summable_congr,
intro b,
norm_cast,
end
lemma psi_def_summable {S : Fintype} (n : ℕ)
(F : ℒ S)
(s : S) :
summable
(λ (k : ℕ),
r ^ (F.d + ↑n) *
(2⁻¹ ^ (k : ℤ) * ∥F s (F.d + ↑n + ↑k)∥₊)) :=
begin
have := F.summable_half s,
apply summable.mul_left,
have h : (2⁻¹ : ℝ≥0) ≠ 0 := by norm_num,
rw nnreal.summable_mul_left_iff (show ((2⁻¹ : ℝ≥0) ^ (F.d + n) ≠ 0), from zpow_ne_zero _ h),
simp only [← mul_assoc, ← zpow_add₀ h],
have this2 := lt_d_eq_zero F s,
rw ← summable_norm_iff at this,
simp_rw ← _root_.coe_nnnorm at this,
rw summable_coe at this,
rw nnreal.summable_iff_on_nat_less_shift F.d _ (F.d + n) at this,
{ convert this,
ext1 k,
rw mul_comm,
simp only [inv_zpow', neg_add_rev, nnnorm_mul, nnnorm_zpow, real.nnnorm_two],
congr' },
{ intros n hn,
simp [this2 n hn] },
end
lemma psi_def_summable2 {S : Fintype}
[fact (0 < p)]
[fact (p < 1)]
(F : ℒ S)
(s : ↥S) :
∀ (k : ℕ),
summable
(λ (n : ℕ),
r ^ (F.d + ↑n) *
((2⁻¹ : ℝ≥0) ^ (k : ℤ) * ∥F s (F.d + ↑n + ↑k)∥₊)) :=
begin
intro k,
have hhalf : (2⁻¹ : ℝ≥0) ≠ 0, by norm_num,
have hhalf' : (2⁻¹ : ℝ≥0) ≠ 0, by norm_num,
have hr : r ≠ 0 := r_pos.ne.symm,
rw nnreal.summable_mul_left_iff
(show (2⁻¹ : ℝ≥0) ^ (-(k : ℤ)) * r ^ (k : ℤ) ≠ 0, from mul_ne_zero (zpow_ne_zero _ hhalf') (zpow_ne_zero _ hr)),
have : ∀ x : ℕ, 2⁻¹ ^ -(k : ℤ) * r ^ (k : ℤ) * (r ^ (F.d + ↑x) * (2⁻¹ ^ (k : ℤ) * ∥F s (F.d + ↑x + ↑k)∥₊))
= r ^ (F.d + x + k) * ∥F s (F.d + ↑x + ↑k)∥₊,
{ intro x,
rw (show (2⁻¹ : ℝ≥0) ^ -(k : ℤ) * r ^ (k : ℤ) * (r ^ (F.d + ↑x) * (2⁻¹ ^ (k : ℤ) * ∥F s (F.d + ↑x + ↑k)∥₊))
= (2⁻¹ : ℝ≥0) ^ -(k : ℤ) * 2⁻¹ ^ (k : ℤ) * r ^ (k : ℤ) * r ^ (F.d + ↑x) * ∥F s (F.d + ↑x + ↑k)∥₊, by ring),
simp only [zpow_add₀ hr, ← zpow_add₀ hhalf'],
simp,
left,
ring,
},
rw summable_congr this, clear this,
have := F.summable' s,
rw nnreal.summable_iff_on_nat_less_shift F.d _ (F.d + k) at this,
{ convert this,
ext n,
rw [mul_comm, add_right_comm],
refl },
{ intros n hn,
convert zero_mul _,
convert nnnorm_zero,
exact lt_d_eq_zero F s n hn },
end
lemma psi_def_summable3 {S : Fintype}
[fact (0 < p)]
[fact (p < 1)]
(F : ℒ S)
(s : ↥S) :
summable
(λ (k : ℕ),
∑' (n : ℕ),
r ^ (F.d + ↑n) *
(2⁻¹ ^ (k : ℤ) * ∥F s (F.d + ↑n + ↑k)∥₊)) :=
begin
-- take 2⁻¹^k out the tsum,
-- put r^k into the tsum,
-- bounded by sum of GP,
have bdd : ∀ k : ℕ, ∑' (n : ℕ),
r ^ (F.d + ↑n + k) * ∥F s (F.d + ↑n + ↑k)∥₊ ≤
∑' (t : ℤ),
r ^ t * ∥F s t∥₊,
{ intro k,
simp_rw add_right_comm,
have hinj : function.injective (λ (m : ℕ), F.d + k + m),
{ rintros a b (h2 : F.d + k + a = F.d + k + b),
simpa using h2 },
refine tsum_le_tsum_of_inj _ hinj _ _ _ _,
{ intros, apply zero_le' },
{ intro, refl },
{ rw ← @nnreal.summable_iff_on_nat_less_shift (λ (z : ℤ), r ^ z * ∥F s z∥₊) F.d _ (F.d + k),
{ convert F.summable' s,
ext z,
rw mul_comm,
refl },
{ intros n hn,
simp [lt_d_eq_zero F s n hn] } },
{ convert F.summable' s,
ext z,
rw mul_comm,
refl } },
have : ∀ k : ℕ, ∑' (n : ℕ), r ^ (F.d + ↑n) * (2⁻¹ ^ (k : ℤ) * ∥F s (F.d + ↑n + ↑k)∥₊) =
(∑' (n : ℕ), r ^ (F.d + ↑n + k) * (∥F s (F.d + ↑n + ↑k)∥₊)) * (2⁻¹ * r⁻¹) ^ (k : ℤ),
{ intro k,
rw ← nnreal.tsum_mul_right,
apply tsum_congr,
intro n,
simp only [zpow_add₀ r_pos.ne.symm, zpow_coe_nat, one_div, inv_pow, div_zpow],
have foo : (2 * r) ^ k ≠ 0,
{ apply pow_ne_zero, apply mul_ne_zero,
{ norm_num },
{ exact r_pos.ne.symm },
},
field_simp [foo],
rw mul_pow,
ring, },
rw summable_congr this, clear this,
suffices : summable (λ k : ℕ, (∑' (t : ℤ), r ^ t * ∥F s t∥₊) * (2⁻¹ * r⁻¹) ^ k),
{ refine summable_of_le _ this,
intro k,
rw zpow_coe_nat,
apply nnreal.mul_le_mul_right (bdd k),
},
apply summable.mul_left,
apply summable_geometric,
exact div_lt_one_of_lt half_lt_r,
end
lemma psi_def_aux_4 {S : Fintype} [fact (0 < p)] [fact (p < 1)] (F : ℒ S) (s : ↥S) : summable
(λ (m : ℕ),
∥(2 : ℝ) ^ (F.d + ↑m)∥₊ *
((∑' (k : ℕ), ∥F s (F.d + ↑m + ↑k)∥₊ * 2⁻¹ ^ (F.d + ↑m + ↑k)) * r ^ (F.d + ↑m))) :=
begin
-- tidy up
simp_rw [nnnorm_zpow, real.nnnorm_two],
have : ∀ m : ℕ, (2 : ℝ≥0) ^ (F.d + ↑m) *
((∑' (k : ℕ), ∥F s (F.d + ↑m + ↑k)∥₊ * 2⁻¹ ^ (F.d + ↑m + ↑k)) * r ^ (F.d + ↑m)) =
∑' (k : ℕ), (2 : ℝ≥0) ^ (F.d + ↑m) * ∥F s (F.d + ↑m + ↑k)∥₊ * 2⁻¹ ^ (F.d + ↑m + ↑k) * r ^ (F.d + ↑m),
{ intro m,
rw [← nnreal.tsum_mul_right, ← nnreal.tsum_mul_left],
apply tsum_congr,
intro b,
ring },
rw summable_congr this, clear this,
-- TODO : maybe now is the time to tidy up a bit (e.g. cancel the 2^x and 2⁻¹^x)
suffices : summable
(λ (m : ℕ), ∑' (k : ℕ),
∥F s (F.d + ↑m + ↑k)∥₊ *
2⁻¹ ^ (k : ℤ) * r ^ (F.d + ↑m)),
{ refine (summable_congr _).2 this,
intro m,
apply tsum_congr,
intro b,
rw [inv_zpow , inv_zpow],
rw [← zpow_neg, ←zpow_neg],
have h2 : (2 : ℝ≥0) ≠ 0 := two_ne_zero,
simp only [zpow_add₀, ne.def, bit0_eq_zero, one_ne_zero, not_false_iff, zpow_coe_nat, neg_add_rev, zpow_neg,
mul_eq_mul_right_iff],
field_simp [zpow_ne_zero _ h2], left,
ring,
},
simp_rw [mul_comm],
-- change order of summation
apply nnreal.summable_symm,
-- check various things are summable
have := F.summable_half s,
{ intro n,
apply psi_def_summable },
{ apply psi_def_summable2 },
-- sum is then bounded above by a GP.
{ apply psi_def_summable3, },
end
lemma psi_def_aux_3 {S : Fintype} [fact (0 < p)] [fact (p < 1)] (F : ℒ S) (s : ↥S) : summable
(λ (n : ℤ),
∥-(2 : ℝ) ^ (n - 1)∥₊ *
ite (F.d ≤ n) ((∑' (k : ℕ), ∥F s (n + ↑k)∥₊ * 2⁻¹ ^ (n + ↑k)) * r ^ n) 0) :=
begin
-- get rid of factor of -2⁻¹
simp_rw [_root_.nnnorm_neg, zpow_sub₀ (two_ne_zero : (2 : ℝ) ≠ 0), nnnorm_div, zpow_one,
div_eq_mul_inv _ ∥(2 : ℝ)∥₊, mul_comm _ ∥(2 : ℝ)∥₊⁻¹, mul_assoc],
apply summable.mul_left,
have hinj : function.injective (λ (m : ℕ), F.d + m),
{ rintros a b (h2 : F.d + a = F.d + b),
simpa using h2 },
-- change outer sum to m : ℕ with n : ℤ = F.d + m
suffices : summable (λ (m : ℕ),
∥(2 : ℝ) ^ (F.d + m)∥₊ *
((∑' (k : ℕ), ∥F s (F.d + m + ↑k)∥₊ * 2⁻¹ ^ (F.d + m + ↑k)) * r ^ (F.d + m))),
refine nnreal.summable_of_comp_injective hinj _ _,
{ intros a ha,
rw [if_neg], simp,
intro hda, apply ha,
use (a - F.d).to_nat,
simp, rw int.to_nat_of_nonneg, ring, linarith },
{ refine (summable_congr _).1 this,
simp },
exact psi_def_aux_4 F s,
end
lemma psi_def_aux_2 {S : Fintype} [fact (0 < p)] [fact (p < 1)] (F : ℒ S) (s : ↥S) : summable
(λ (n : ℤ),
ite (F.d ≤ n) ∥-(2 : ℝ) ^ (n - 1) * ∑' (k : ℕ), ↑(F s (n + ↑k)) * 2⁻¹ ^ (n + ↑k) * r ^ n∥₊ 0) :=
begin
simp_rw [nnnorm_mul],
-- next : put norm inside inner tsum (a one way implication)
suffices : summable
(λ (n : ℤ), ∥-(2 : ℝ) ^ (n - 1)∥₊ *
ite (F.d ≤ n)
((∑' (k : ℕ), ∥F s (n + ↑k)∥₊ * 2⁻¹ ^ (n + ↑k)) * r ^ n)
0),
refine summable_of_le _ this,
{ intro n,
split_ifs,
{ simp only [_root_.nnnorm_neg, nnnorm_zpow, real.nnnorm_two, one_div, inv_zpow', neg_add_rev],
refine mul_le_mul_of_nonneg_left _ _,
{ refine le_trans (nnnorm_tsum_le _) _,
{ clear this, have := F.summable_half s,
simp_rw nnnorm_mul,
apply summable.mul_right,
rw ← summable_norm_iff at this,
simp_rw ← _root_.coe_nnnorm at this,
rw nnreal.summable_coe at this,
have hinj : function.injective (λ (b : ℕ), n + b),
{ rintros a b (h2 : n + a = n + b),
simpa using h2 },
convert summable_comp_injective this hinj,
ext1 k,
simp [← zpow_neg] },
{ rw ← nnreal.tsum_mul_right,
apply le_of_eq,
apply tsum_congr,
{ intro k,
simp only [nnnorm_mul, nnnorm_zpow, real.nnnorm_two, nnnorm_eq, mul_eq_mul_right_iff],
left, left,
congr } } },
{ simp } },
{ simp } },
exact psi_def_aux_3 _ _,
end
lemma psi_def_aux {S : Fintype} [fact (0 < p)] [fact (p < 1)] (F : ℒ S) (s : ↥S) :
summable (λ (n : ℤ), ∥ite (F.d ≤ n) (-(2 : ℝ) ^ (n - 1) *
∑' (k : ℕ), ↑(F s (n + ↑k)) * 2⁻¹ ^ (n + ↑k)) 0∥₊ * r ^ n) :=
begin
suffices : summable (λ (n : ℤ), ite (F.d ≤ n) ∥-(2 : ℝ) ^ (n - 1) *
∑' (k : ℕ), ↑(F s (n + ↑k)) * 2⁻¹ ^ (n + ↑k) * r ^ n∥₊ 0),
refine summable_of_le _ this,
{ intro n,
split_ifs,
{ apply le_of_eq,
simp_rw _root_.tsum_mul_right,
rw [ ← mul_assoc, nnnorm_mul _ ((r : ℝ) ^ n)],
simp },
{ simp } },
exact psi_def_aux_2 _ _,
end
def ψ (F : ℒ S) (hF : θ F = 0) : ℒ S :=
{ to_fun := λ s n, if F.d ≤ n then
∑ l in range (n - F.d).nat_abs.succ, F s (n - 1 - l) * (2 ^ l)
else 0,
summable' := λ s, begin
-- make everything real
change summable (λ (n : ℤ),
∥((ite (F.d ≤ n)
(∑ (l : ℕ) in range (n - F.d).nat_abs.succ, F s (n - 1 - ↑l) * 2 ^ l) 0 : ℤ) : ℝ)∥₊
* r ^ n),
push_cast,
-- hypothesis that infinite sum converges at r>2⁻¹
-- get hypothesis that infinite sum is 0 at 2⁻¹
simp only [θ, ϑ] at hF,
replace hF := congr_fun hF s, dsimp at hF,
-- change sum from ℤ to ℕ
--rw nnreal.summable_iff_on_nat_less F.d, swap,
--{ intros n hn, simp [if_neg hn.not_le] },
have h1 : ∀ (n : ℤ),
ite (F.d ≤ n) (∑ (l : ℕ) in range (n - F.d).nat_abs.succ, (F s (n - 1 - ↑l) : ℝ) * 2 ^ l) 0 =
ite (F.d ≤ n) (-(2 : ℝ)^(n-1)*∑' (k : ℕ), F s (n + k) * 2⁻¹ ^ (n + k)) 0,
{ intro n,
split_ifs with hn, swap, refl,
rw [← inv_mul_eq_iff_eq_mul₀, ← neg_inv, neg_mul, mul_sum, neg_eq_iff_add_eq_zero, ← hF],
swap, exact neg_ne_zero.2 (zpow_ne_zero _ two_ne_zero),
convert @tsum_add_tsum_compl ℝ ℤ _ _ _ _ _ {x : ℤ | x < n}
(summable.subtype (F.summable_half s) _) (summable.subtype (F.summable_half s) _) using 2,
{ simp_rw [← inv_zpow, mul_comm ((2⁻¹ : ℝ)^(n-1)), mul_assoc],
simp_rw (show ∀ (x : ℕ), (2 : ℝ)^x = 2⁻¹^(-(x : ℤ)), by {intros, simp}),
simp_rw [← zpow_add₀ (by norm_num : (2⁻¹ : ℝ) ≠ 0), add_comm, ← sub_eq_add_neg],
rw ← tsum_eq_sum,
convert @equiv.tsum_eq ℝ _ _ _ _ _
(⟨λ m, ⟨n - 1 - m, lt_of_le_of_lt (sub_le_self _ (int.coe_zero_le m)) (sub_one_lt n)⟩,
(λ z, (n - 1 - z.1).nat_abs), λ m, by simp, λ ⟨z, hz⟩, subtype.ext begin
-- squeeze_simp,
change n - 1 - (n - 1 - z).nat_abs = z,
rw ← int.eq_nat_abs_of_zero_le (sub_nonneg_of_le (int.le_sub_one_of_lt hz)),
ring, end⟩ : ℕ ≃ {z : ℤ // z < n}) _,
{ ext, refl },
{ intros b hb,
rw mul_eq_zero, left,
norm_cast,
apply lt_d_eq_zero,
by_contra h, push_neg at h, apply hb,
rw [mem_range, nat.succ_eq_add_one, ← int.coe_nat_lt, int.coe_nat_add,
← int.eq_nat_abs_of_zero_le]; linarith } },
{ convert @equiv.tsum_eq ℝ _ _ _ _ _
(⟨λ x, ⟨n + x, (int.le.intro rfl).not_lt⟩, (λ z, (z.1 - n).nat_abs),
λ x, by simp, λ ⟨x, hx⟩, subtype.ext begin
change n + _ = x,
rw ← int.eq_nat_abs_of_zero_le (sub_nonneg.2 (le_of_not_lt hx)),
exact add_eq_of_eq_sub' rfl,
end⟩ : ℕ ≃ {z : ℤ // ¬ z < n}) _,
ext, refl },
},
suffices : summable (λ (n : ℤ),
∥ite (F.d ≤ n) (-(2 : ℝ)^(n-1)*∑' (k : ℕ), ↑(F s (n + k)) * 2⁻¹ ^ (n + k)) 0∥₊ *
r ^ n),
{ refine (summable_congr _).2 this,
intro n,
congr' 2,
apply h1 n,
}, clear h1,
clear hF,
exact psi_def_aux F s,
end }
theorem θ_ϕ_split_exact (F : ℒ S) (hF : θ F = 0) : ϕ (ψ F hF) = F :=
begin
ext s n,
simp only [ϕ, ψ, sub_apply, shift_to_fun_to_fun, laurent_measures.coe_mk, nsmul_apply,
nsmul_eq_mul, int.coe_nat_succ, int.coe_nat_zero, zero_add],
split_ifs with h1 h2,
{ rw [sum_range_succ', (by norm_num : (1 : ℤ) + 1 = 2), mul_sum],
convert add_sub_cancel' _ _,
{ rw [nat.succ_eq_add_one, (by ring : n + 1 - F.d = n - F.d + 1)],
obtain ⟨m, hm⟩ := (int.eq_coe_of_zero_le (sub_nonneg.mpr h2)),
rw hm,
norm_cast },
{ ext,
push_cast,
ring_exp,
congr' 2,
ring },
{ simp } },
{ have hF : F.d = n + 1, linarith,
simp [hF] },
{ linarith },
{ exact (lt_d_eq_zero F s n (not_le.mp h)).symm },
end
theorem θ_ϕ_exact (F : ℒ S) (hF : θ F = 0) : ∃ G, ϕ G = F :=
⟨ψ F hF, θ_ϕ_split_exact F hF⟩
end mem_exact
|
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, ScopedTypeVariables, RecordWildCards #-}
import Control.Monad.Primitive
import Control.Monad
import Foreign.C.Types
import Foreign.Ptr
import Unsafe.Coerce
import Data.Complex
import Foreign.Marshal.Array
import qualified Data.Vector.Generic as VG
import qualified Data.Vector.Generic.Mutable as VGM
import qualified Data.Vector.Storable as VS
import qualified Data.Vector.Storable.Mutable as VSM
import qualified Data.Vector.Fusion.Stream as VFS
import qualified Data.Vector.Fusion.Stream.Monadic as VFSM
import Foreign.Storable.Complex
import Criterion.Main
import Test.QuickCheck
import Test.QuickCheck.Monadic
-- | A class for things that can be multiplied by a scalar.
class Mult a b where
mult :: a -> b -> a
instance (Num a) => Mult a a where
mult = (*)
instance (Num a) => Mult (Complex a) a where
mult (x :+ y) z = (x * z) :+ (y * z)
-- | Fill a mutable vector from a monadic stream
{-# INLINE fill #-}
fill :: (PrimMonad m, Functor m, VGM.MVector vm a) => VFS.MStream m a -> vm (PrimState m) a -> m ()
fill str outBuf = void $ VFSM.foldM' put 0 str
where
put i x = do
VGM.unsafeWrite outBuf i x
return $ i + 1
{-# INLINE stride #-}
stride :: VG.Vector v a => Int -> v a -> v a
stride str inv = VG.unstream $ VFS.unfoldr func 0
where
len = VG.length inv
func i | i >= len = Nothing
| otherwise = Just (VG.unsafeIndex inv i, i + str)
-- | The functions to be benchmarked
-- | Filters
filterHighLevel :: (PrimMonad m, Functor m, Num a, Mult a b, VG.Vector v a, VG.Vector v b, VGM.MVector vm a) => Int -> v b -> v a -> vm (PrimState m) a -> m ()
filterHighLevel num coeffs inBuf outBuf = fill (VFSM.generate num dotProd) outBuf
where
dotProd offset = VG.sum $ VG.zipWith mult (VG.unsafeDrop offset inBuf) coeffs
type FilterCRR = CInt -> CInt -> Ptr CFloat -> Ptr CFloat -> Ptr CFloat -> IO ()
type FilterRR = Int -> VS.Vector Float -> VS.Vector Float -> VS.MVector RealWorld Float -> IO ()
type FilterRC = Int -> VS.Vector Float -> VS.Vector (Complex Float) -> VS.MVector RealWorld (Complex Float) -> IO ()
filterFFIR :: FilterCRR -> FilterRR
filterFFIR func num coeffs inBuf outBuf =
VS.unsafeWith (unsafeCoerce coeffs) $ \cPtr ->
VS.unsafeWith (unsafeCoerce inBuf) $ \iPtr ->
VSM.unsafeWith (unsafeCoerce outBuf) $ \oPtr ->
func (fromIntegral num) (fromIntegral $ VG.length coeffs) cPtr iPtr oPtr
filterFFIC :: FilterCRR -> FilterRC
filterFFIC func num coeffs inBuf outBuf =
VS.unsafeWith (unsafeCoerce coeffs) $ \cPtr ->
VS.unsafeWith (unsafeCoerce inBuf) $ \iPtr ->
VSM.unsafeWith (unsafeCoerce outBuf) $ \oPtr ->
func (fromIntegral num) (fromIntegral $ VG.length coeffs) cPtr iPtr oPtr
-- | Decimation
decimateHighLevel :: (PrimMonad m, Functor m, Num a, Mult a b, VG.Vector v a, VG.Vector v b, VGM.MVector vm a) => Int -> Int -> v b -> v a -> vm (PrimState m) a -> m ()
decimateHighLevel num factor coeffs inBuf outBuf = fill x outBuf
where
x = VFSM.map dotProd (VFSM.iterateN num (+ factor) 0)
dotProd offset = VG.sum $ VG.zipWith mult (VG.unsafeDrop offset inBuf) coeffs
type DecimateCRR = CInt -> CInt -> CInt -> Ptr CFloat -> Ptr CFloat -> Ptr CFloat -> IO ()
type DecimateRR = Int -> Int -> VS.Vector Float -> VS.Vector Float -> VS.MVector RealWorld Float -> IO ()
type DecimateRC = Int -> Int -> VS.Vector Float -> VS.Vector (Complex Float) -> VS.MVector RealWorld (Complex Float) -> IO ()
decimateFFIR :: DecimateCRR -> DecimateRR
decimateFFIR func num factor coeffs inBuf outBuf =
VS.unsafeWith (unsafeCoerce coeffs) $ \cPtr ->
VS.unsafeWith (unsafeCoerce inBuf) $ \iPtr ->
VSM.unsafeWith (unsafeCoerce outBuf) $ \oPtr ->
func (fromIntegral num) (fromIntegral factor) (fromIntegral $ VG.length coeffs) cPtr iPtr oPtr
decimateFFIC :: DecimateCRR -> DecimateRC
decimateFFIC func num factor coeffs inBuf outBuf =
VS.unsafeWith (unsafeCoerce coeffs) $ \cPtr ->
VS.unsafeWith (unsafeCoerce inBuf) $ \iPtr ->
VSM.unsafeWith (unsafeCoerce outBuf) $ \oPtr ->
func (fromIntegral num) (fromIntegral factor) (fromIntegral $ VG.length coeffs) cPtr iPtr oPtr
-- | Rational downsampling
resampleHighLevel :: (PrimMonad m, Num a, Mult a b, VG.Vector v a, VG.Vector v b, VGM.MVector vm a) => Int -> Int -> Int -> Int -> v b -> v a -> vm (PrimState m) a -> m Int
resampleHighLevel count interpolation decimation filterOffset coeffs inBuf outBuf = fill 0 filterOffset 0
where
fill i filterOffset inputOffset
| i < count = do
let dp = dotProd filterOffset inputOffset
VGM.unsafeWrite outBuf i dp
let (q, r) = quotRem (decimation - filterOffset - 1) interpolation
inputOffset' = inputOffset + q + 1
filterOffset' = interpolation - 1 - r
filterOffset' `seq` inputOffset' `seq` fill (i + 1) filterOffset' inputOffset'
| otherwise = return filterOffset
dotProd filterOffset offset = VG.sum $ VG.zipWith mult (VG.unsafeDrop offset inBuf) (stride interpolation (VG.unsafeDrop filterOffset coeffs))
pad :: a -> Int -> [a] -> [a]
pad with num list = list ++ replicate (num - length list) with
strideList :: Int -> [a] -> [a]
strideList s xs = go 0 xs
where
go _ [] = []
go 0 (x:xs) = x : go (s-1) xs
go n (x:xs) = go (n - 1) xs
roundUp :: Int -> Int -> Int
roundUp num div = ((num + div - 1) `quot` div) * div
data Coeffs = Coeffs {
numCoeffs :: Int,
numGroups :: Int,
increments :: [Int],
groups :: [[Float]]
}
prepareCoeffs :: Int -> Int -> Int -> [Float] -> Coeffs
prepareCoeffs n interpolation decimation coeffs = Coeffs {..}
where
numCoeffs = maximum $ map (length . snd) dats
numGroups = length groups
increments = map fst dats
groups :: [[Float]]
groups = map (pad 0 (roundUp numCoeffs n)) $ map snd dats
dats :: [(Int, [Float])]
dats = func 0
where
func' 0 = []
func' x = func x
func :: Int -> [(Int, [Float])]
func offset = (increment, strideList interpolation $ drop offset coeffs) : func' offset'
where
(q, r) = quotRem (decimation - offset - 1) interpolation
increment = q + 1
offset' = interpolation - 1 - r
resampleFFIR :: (Ptr CFloat -> Ptr CFloat -> IO ()) -> VS.Vector Float -> VSM.MVector RealWorld Float -> IO ()
resampleFFIR func inBuf outBuf =
VS.unsafeWith (unsafeCoerce inBuf) $ \iPtr ->
VS.unsafeWith (unsafeCoerce outBuf) $ \oPtr ->
func iPtr oPtr
type ResampleR = CInt -> CInt -> CInt -> CInt -> Ptr CInt -> Ptr (Ptr CFloat) -> Ptr CFloat -> Ptr CFloat -> IO ()
mkResampler :: ResampleR -> Int -> Int -> Int -> [Float] -> IO (Int -> Int -> VS.Vector Float -> VS.MVector RealWorld Float -> IO ())
mkResampler func n interpolation decimation coeffs = do
groupsP <- mapM newArray $ map (map realToFrac) groups
groupsPP <- newArray groupsP
incrementsP <- newArray $ map fromIntegral increments
return $ \num offset -> resampleFFIR $ func (fromIntegral num) (fromIntegral numCoeffs) (fromIntegral offset) (fromIntegral numGroups) incrementsP groupsPP
where
Coeffs {..} = prepareCoeffs n interpolation decimation coeffs
theBench :: IO ()
theBench = do
--Setup
let size = 16384
numCoeffs = 128
num = size - numCoeffs + 1
decimation = 4
interpolation = 3
numCoeffsDiv2 = 64
coeffsList :: [Float]
coeffsList = take numCoeffs [0 ..]
coeffs :: VS.Vector Float
coeffs = VG.fromList $ take numCoeffs [0 ..]
coeffsSym :: VS.Vector Float
coeffsSym = VG.fromList $ take numCoeffsDiv2 [0 ..]
inBuf :: VS.Vector Float
inBuf = VG.fromList $ take size [0 ..]
inBufComplex :: VS.Vector (Complex Float)
inBufComplex = VG.fromList $ take size $ do
i <- [0..]
return $ i :+ i
numConv = 16386
inBufConv :: VS.Vector CUChar
inBufConv = VG.fromList $ take size $ concat $ repeat [0 .. 255]
duplicate :: [a] -> [a]
duplicate = concatMap func
where func x = [x, x]
coeffs2 :: VS.Vector Float
coeffs2 = VG.fromList $ duplicate $ take numCoeffs [0 ..]
outBuf :: VS.MVector RealWorld Float <- VGM.new size
outBufComplex :: VS.MVector RealWorld (Complex Float) <- VGM.new size
--Benchmarks
defaultMain [
bgroup "filter" [
bgroup "real" [
bench "highLevel" $ nfIO $ filterHighLevel num coeffs inBuf outBuf
],
bgroup "complex" [
bench "highLevel" $ nfIO $ filterHighLevel num coeffs inBufComplex outBufComplex
]
],
bgroup "decimate" [
bgroup "real" [
bench "highLevel" $ nfIO $ decimateHighLevel (num `quot` decimation) decimation coeffs inBuf outBuf
],
bgroup "complex" [
bench "highLevel" $ nfIO $ decimateHighLevel (num `quot` decimation) decimation coeffs inBufComplex outBufComplex
]
],
bgroup "resample" [
bgroup "real" [
bench "highLevel" $ nfIO $ resampleHighLevel (num `quot` decimation) interpolation decimation 0 coeffs inBuf outBuf
],
bgroup "complex" [
bench "highLevel" $ nfIO $ resampleHighLevel (num `quot` decimation) interpolation decimation 0 coeffs inBufComplex outBufComplex
]
]
]
theTest = quickCheck $ conjoin [propFiltersComplex]
where
sizes = elements [1024, 2048, 4096, 8192, 16384, 32768, 65536]
numCoeffs = elements [32, 64, 128, 256, 512]
factors = elements [1, 2, 3, 4, 7, 9, 12, 15, 21]
factors' = [1, 2, 3, 4, 7, 9, 12, 15, 21]
propFiltersReal = forAll sizes $ \size ->
forAll (vectorOf size (choose (-10, 10))) $ \inBuf ->
forAll numCoeffs $ \numCoeffs ->
forAll (vectorOf numCoeffs (choose (-10, 10))) $ \coeffs ->
testFiltersReal size numCoeffs coeffs inBuf
testFiltersReal :: Int -> Int -> [Float] -> [Float] -> Property
testFiltersReal size numCoeffs coeffs inBuf = monadicIO $ do
let vCoeffsHalf = VS.fromList coeffs
vCoeffs = VS.fromList $ coeffs ++ reverse coeffs
vInput = VS.fromList inBuf
num = size - numCoeffs*2 + 1
r1 <- run $ getResult num $ filterHighLevel num vCoeffs vInput
propFiltersComplex = forAll sizes $ \size ->
forAll (vectorOf size (choose (-10, 10))) $ \inBufR ->
forAll (vectorOf size (choose (-10, 10))) $ \inBufI ->
forAll numCoeffs $ \numCoeffs ->
forAll (vectorOf numCoeffs (choose (-10, 10))) $ \coeffs ->
assert $ all (r1 `eqDelta`) [r1]
testFiltersComplex size numCoeffs coeffs $ zipWith (:+) inBufR inBufI
testFiltersComplex :: Int -> Int -> [Float] -> [Complex Float] -> Property
testFiltersComplex size numCoeffs coeffs inBuf = monadicIO $ do
let vCoeffsHalf = VS.fromList coeffs
vCoeffs = VS.fromList $ coeffs ++ reverse coeffs
vInput = VS.fromList inBuf
num = size - numCoeffs*2 + 1
--vCoeffs2 = VG.fromList $ duplicate $ coeffs ++ reverse coeffs
r1 <- run $ getResult num $ filterHighLevel num vCoeffs vInput
propDecimationReal = forAll sizes $ \size ->
forAll (vectorOf size (choose (-10, 10))) $ \inBuf ->
forAll numCoeffs $ \numCoeffs ->
forAll (vectorOf numCoeffs (choose (-10, 10))) $ \coeffs ->
forAll factors $ \factor ->
assert $ all (r1 `eqDeltaC`) [r1]
testDecimationReal size numCoeffs factor coeffs inBuf
testDecimationReal :: Int -> Int -> Int -> [Float] -> [Float] -> Property
testDecimationReal size numCoeffs factor coeffs inBuf = monadicIO $ do
let vCoeffsHalf = VS.fromList coeffs
vCoeffs = VS.fromList $ coeffs ++ reverse coeffs
vInput = VS.fromList inBuf
num = (size - numCoeffs*2 + 1) `quot` factor
r1 <- run $ getResult num $ decimateHighLevel num factor vCoeffs vInput
propDecimationComplex = forAll sizes $ \size ->
forAll (vectorOf size (choose (-10, 10))) $ \inBufR ->
forAll (vectorOf size (choose (-10, 10))) $ \inBufI ->
forAll numCoeffs $ \numCoeffs ->
forAll (vectorOf numCoeffs (choose (-10, 10))) $ \coeffs ->
forAll factors $ \factor ->
assert $ all (r1 `eqDelta`) [r1]
testDecimationComplex size numCoeffs factor coeffs $ zipWith (:+) inBufR inBufI
testDecimationComplex :: Int -> Int -> Int -> [Float] -> [Complex Float] -> Property
testDecimationComplex size numCoeffs factor coeffs inBuf = monadicIO $ do
let vCoeffsHalf = VS.fromList coeffs
vCoeffs = VS.fromList $ coeffs ++ reverse coeffs
vInput = VS.fromList inBuf
num = (size - numCoeffs*2 + 1) `quot` factor
--vCoeffs2 = VG.fromList $ duplicate $ coeffs ++ reverse coeffs
r1 <- run $ getResult num $ decimateHighLevel num factor vCoeffs vInput
propResamplingReal = forAll sizes $ \size ->
forAll (vectorOf size (choose (-10, 10))) $ \inBuf ->
forAll numCoeffs $ \numCoeffs ->
forAll (vectorOf numCoeffs (choose (-10, 10))) $ \coeffs ->
forAll (elements $ tail factors') $ \decimation ->
forAll (elements $ filter (< decimation) factors') $ \interpolation ->
assert $ all (r1 `eqDeltaC`) [r1]
testResamplingReal size numCoeffs interpolation decimation coeffs inBuf
testResamplingReal :: Int -> Int -> Int -> Int -> [Float] -> [Float] -> Property
testResamplingReal size numCoeffs interpolation decimation coeffs inBuf = monadicIO $ do
let vCoeffsHalf = VS.fromList coeffs
vCoeffs = VS.fromList $ coeffs ++ reverse coeffs
vInput = VS.fromList inBuf
num = (size - numCoeffs*2 + 1) `quot` decimation
r1 <- run $ getResult num $ resampleHighLevel num interpolation decimation 0 vCoeffs vInput
assert $ all (r1 `eqDelta`) [r1]
getResult :: (VSM.Storable a) => Int -> (VS.MVector RealWorld a -> IO b) -> IO [a]
getResult size func = do
outBuf <- VGM.new size
func outBuf
out :: VS.Vector a <- VG.freeze outBuf
return $ VG.toList out
eqDelta x y = all (uncurry eqDelta') $ zip x y
where
eqDelta' x y = abs (x - y) < 0.01
eqDeltaC x y = all (uncurry eqDelta') $ zip x y
where
eqDelta' x y = magnitude (x - y) < 0.01
duplicate :: [a] -> [a]
duplicate = concatMap func
where func x = [x, x]
main = theBench
|
Things that didn't make the chapters
\section{Appendix B-1}\label{app:B-1}
You can refer to sections of the appendix as well. Read all the cool stuff in Appendix \ref{app:B-1} or in Appendix \ref{app:B-2}
\section{Appendix B-2}\label{app:B-2}
\section{Appendix B-3}\label{app:B-3}
\clearpage
|
= = = TOT and CAT Telecom = = =
|
(* Title: ZF/Induct/Brouwer.thy
Author: Lawrence C Paulson, Cambridge University Computer Laboratory
Copyright 1994 University of Cambridge
*)
section \<open>Infinite branching datatype definitions\<close>
theory Brouwer imports ZFC begin
subsection \<open>The Brouwer ordinals\<close>
consts
brouwer :: i
datatype \<subseteq> "Vfrom(0, csucc(nat))"
"brouwer" = Zero | Suc ("b \<in> brouwer") | Lim ("h \<in> nat -> brouwer")
monos Pi_mono
type_intros inf_datatype_intros
lemma brouwer_unfold: "brouwer = {0} + brouwer + (nat -> brouwer)"
by (fast intro!: brouwer.intros [unfolded brouwer.con_defs]
elim: brouwer.cases [unfolded brouwer.con_defs])
lemma brouwer_induct2 [consumes 1, case_names Zero Suc Lim]:
assumes b: "b \<in> brouwer"
and cases:
"P(Zero)"
"\<And>b. \<lbrakk>b \<in> brouwer; P(b)\<rbrakk> \<Longrightarrow> P(Suc(b))"
"\<And>h. \<lbrakk>h \<in> nat -> brouwer; \<forall>i \<in> nat. P(h`i)\<rbrakk> \<Longrightarrow> P(Lim(h))"
shows "P(b)"
\<comment> \<open>A nicer induction rule than the standard one.\<close>
using b
apply induct
apply (rule cases(1))
apply (erule (1) cases(2))
apply (rule cases(3))
apply (fast elim: fun_weaken_type)
apply (fast dest: apply_type)
done
subsection \<open>The Martin-Löf wellordering type\<close>
consts
Well :: "[i, i \<Rightarrow> i] \<Rightarrow> i"
datatype \<subseteq> "Vfrom(A \<union> (\<Union>x \<in> A. B(x)), csucc(nat \<union> |\<Union>x \<in> A. B(x)|))"
\<comment> \<open>The union with \<open>nat\<close> ensures that the cardinal is infinite.\<close>
"Well(A, B)" = Sup ("a \<in> A", "f \<in> B(a) -> Well(A, B)")
monos Pi_mono
type_intros le_trans [OF UN_upper_cardinal le_nat_Un_cardinal] inf_datatype_intros
lemma Well_unfold: "Well(A, B) = (\<Sum>x \<in> A. B(x) -> Well(A, B))"
by (fast intro!: Well.intros [unfolded Well.con_defs]
elim: Well.cases [unfolded Well.con_defs])
lemma Well_induct2 [consumes 1, case_names step]:
assumes w: "w \<in> Well(A, B)"
and step: "\<And>a f. \<lbrakk>a \<in> A; f \<in> B(a) -> Well(A,B); \<forall>y \<in> B(a). P(f`y)\<rbrakk> \<Longrightarrow> P(Sup(a,f))"
shows "P(w)"
\<comment> \<open>A nicer induction rule than the standard one.\<close>
using w
apply induct
apply (assumption | rule step)+
apply (fast elim: fun_weaken_type)
apply (fast dest: apply_type)
done
lemma Well_bool_unfold: "Well(bool, \<lambda>x. x) = 1 + (1 -> Well(bool, \<lambda>x. x))"
\<comment> \<open>In fact it's isomorphic to \<open>nat\<close>, but we need a recursion operator\<close>
\<comment> \<open>for \<open>Well\<close> to prove this.\<close>
apply (rule Well_unfold [THEN trans])
apply (simp add: Sigma_bool succ_def)
done
end
|
Formal statement is: lemma orthogonal_Basis: "pairwise orthogonal Basis" Informal statement is: The vectors in the standard basis of $\mathbb{R}^n$ are pairwise orthogonal. |
using DelimitedFiles
segdata = readdlm("segments.txt",' ')
#@show segdata
function initdisplay()
display = Vector(undef,10)
display[1] = "abcefg"
display[2] = "cf"
display[3] = "acdeg"
display[4] = "acdfg"
display[5] = "bcdf"
display[6] = "abdfg"
display[7] = "abdefg"
display[8] = "acf"
display[9] = "abcdefg"
display[10] = "abcdfg"
#@show display
displaylen = zeros(Int,1,10)
for d in eachindex(display)
displaylen[d] = length(display[d])
end
display,displaylen
end
display,displaylen = initdisplay()
@show displaylen
function findeasydigits(segdata)
uniqseg = 0
for segment in 1:size(segdata,1)
#@show segment,segdata[segment,:]
foundoutput = false
for sigdata in segdata[segment,:]
if foundoutput
#okay, see if it is a unique display
siglen = length(sigdata)
#@show sigdata,siglen
segmatch = count(==(siglen),displaylen)
if segmatch == 1
uniqseg += 1
end
elseif sigdata == "|"
foundoutput = true
end
end
end
uniqseg
end
@show findeasydigits(segdata) |
\section*{Introduction}
Hack session activities are small weekly programming assignments
intended to get you started on full programming assignments.
You may complete the hack on your own, but you are \emph{highly encouraged}
to work with another student and form a hack pair. Groups larger than
2 are not allowed. However, you may discuss the problems \emph{at a
high level} with other students or groups. You may not share code
directly.
If you choose to form a Hack Pair, you \emph{must}:
\begin{enumerate}
\item Both join a hack pair on Canvas (go to People then Hack Pairs)
\item You must both work on the hack equally; it must be an equal effort
by both partners. Do not undermine your partner's learning opportunity and
do not undermine your own by allowing one parter to do all the work.
\item Turn in only one copy of the code under the individual whose last
name comes first (with respect to Canvas).
\end{enumerate}
You are graded based on style, documentation, design and correctness.
For detail, see the general course rubric.
\begin{table}[H]
\center
\begin{tabular}{ll}
Category & Point Value \\
Style & 2 \\
Documentation & 2 \\
Design & 5 \\
Correctness & 16 \\
\textbf{Total} & \textbf{25}
\end{tabular}
\caption{Rubric}
\end{table}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.