Datasets:
AI4M
/

text
stringlengths
0
3.34M
------------------------------------------------------------------------ -- The Agda standard library -- -- Some derivable properties ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Algebra.Bundles module Algebra.Properties.DistributiveLattice {dl₁ dl₂} (DL : DistributiveLattice dl₁ dl₂) where open DistributiveLattice DL import Algebra.Properties.Lattice as LatticeProperties open import Algebra.Structures open import Algebra.Definitions _≈_ open import Relation.Binary open import Relation.Binary.Reasoning.Setoid setoid open import Function.Base open import Function.Equality using (_⟨$⟩_) open import Function.Equivalence using (_⇔_; module Equivalence) open import Data.Product using (_,_) ------------------------------------------------------------------------ -- Export properties of lattices open LatticeProperties lattice public hiding (replace-equality) ------------------------------------------------------------------------ -- Other properties ∨-distribˡ-∧ : _∨_ DistributesOverˡ _∧_ ∨-distribˡ-∧ x y z = begin x ∨ y ∧ z ≈⟨ ∨-comm _ _ ⟩ y ∧ z ∨ x ≈⟨ ∨-distribʳ-∧ _ _ _ ⟩ (y ∨ x) ∧ (z ∨ x) ≈⟨ ∨-comm _ _ ⟨ ∧-cong ⟩ ∨-comm _ _ ⟩ (x ∨ y) ∧ (x ∨ z) ∎ ∨-distrib-∧ : _∨_ DistributesOver _∧_ ∨-distrib-∧ = ∨-distribˡ-∧ , ∨-distribʳ-∧ ∧-distribˡ-∨ : _∧_ DistributesOverˡ _∨_ ∧-distribˡ-∨ x y z = begin x ∧ (y ∨ z) ≈⟨ ∧-congʳ $ sym (∧-absorbs-∨ _ _) ⟩ (x ∧ (x ∨ y)) ∧ (y ∨ z) ≈⟨ ∧-congʳ $ ∧-congˡ $ ∨-comm _ _ ⟩ (x ∧ (y ∨ x)) ∧ (y ∨ z) ≈⟨ ∧-assoc _ _ _ ⟩ x ∧ ((y ∨ x) ∧ (y ∨ z)) ≈⟨ ∧-congˡ $ sym (∨-distribˡ-∧ _ _ _) ⟩ x ∧ (y ∨ x ∧ z) ≈⟨ ∧-congʳ $ sym (∨-absorbs-∧ _ _) ⟩ (x ∨ x ∧ z) ∧ (y ∨ x ∧ z) ≈⟨ sym $ ∨-distribʳ-∧ _ _ _ ⟩ x ∧ y ∨ x ∧ z ∎ ∧-distribʳ-∨ : _∧_ DistributesOverʳ _∨_ ∧-distribʳ-∨ x y z = begin (y ∨ z) ∧ x ≈⟨ ∧-comm _ _ ⟩ x ∧ (y ∨ z) ≈⟨ ∧-distribˡ-∨ _ _ _ ⟩ x ∧ y ∨ x ∧ z ≈⟨ ∧-comm _ _ ⟨ ∨-cong ⟩ ∧-comm _ _ ⟩ y ∧ x ∨ z ∧ x ∎ ∧-distrib-∨ : _∧_ DistributesOver _∨_ ∧-distrib-∨ = ∧-distribˡ-∨ , ∧-distribʳ-∨ -- The dual construction is also a distributive lattice. ∧-∨-isDistributiveLattice : IsDistributiveLattice _≈_ _∧_ _∨_ ∧-∨-isDistributiveLattice = record { isLattice = ∧-∨-isLattice ; ∨-distribʳ-∧ = ∧-distribʳ-∨ } ∧-∨-distributiveLattice : DistributiveLattice _ _ ∧-∨-distributiveLattice = record { isDistributiveLattice = ∧-∨-isDistributiveLattice } -- One can replace the underlying equality with an equivalent one. replace-equality : {_≈′_ : Rel Carrier dl₂} → (∀ {x y} → x ≈ y ⇔ (x ≈′ y)) → DistributiveLattice _ _ replace-equality {_≈′_} ≈⇔≈′ = record { _≈_ = _≈′_ ; _∧_ = _∧_ ; _∨_ = _∨_ ; isDistributiveLattice = record { isLattice = Lattice.isLattice (LatticeProperties.replace-equality lattice ≈⇔≈′) ; ∨-distribʳ-∧ = λ x y z → to ⟨$⟩ ∨-distribʳ-∧ x y z } } where open module E {x y} = Equivalence (≈⇔≈′ {x} {y}) ------------------------------------------------------------------------ -- DEPRECATED NAMES ------------------------------------------------------------------------ -- Please use the new names as continuing support for the old names is -- not guaranteed. -- Version 1.1 ∨-∧-distribˡ = ∨-distribˡ-∧ {-# WARNING_ON_USAGE ∨-∧-distribˡ "Warning: ∨-∧-distribˡ was deprecated in v1.1. Please use ∨-distribˡ-∧ instead." #-} ∨-∧-distrib = ∨-distrib-∧ {-# WARNING_ON_USAGE ∨-∧-distrib "Warning: ∨-∧-distrib was deprecated in v1.1. Please use ∨-distrib-∧ instead." #-} ∧-∨-distribˡ = ∧-distribˡ-∨ {-# WARNING_ON_USAGE ∧-∨-distribˡ "Warning: ∧-∨-distribˡ was deprecated in v1.1. Please use ∧-distribˡ-∨ instead." #-} ∧-∨-distribʳ = ∧-distribʳ-∨ {-# WARNING_ON_USAGE ∧-∨-distribʳ "Warning: ∧-∨-distribʳ was deprecated in v1.1. Please use ∧-distribʳ-∨ instead." #-} ∧-∨-distrib = ∧-distrib-∨ {-# WARNING_ON_USAGE ∧-∨-distrib "Warning: ∧-∨-distrib was deprecated in v1.1. Please use ∧-distrib-∨ instead." #-}
||| This module contains an adaptation of the session description language as presented in: ||| ||| <https://dblp.uni-trier.de/rec/html/journals/corr/abs-1904-01288> ||| ||| This implementation differs from the original in that recursive ||| calls and calling of subprograms are achieved using standard idris ||| constructs. To support his natively in resources, one will need to ||| introduce new primitives. As described in the `Resources` paper, ||| however, this requires that now means to reason about the ||| interaction between the type-level state of the caller and callee ||| programs. It would not be correct to assume anything about said ||| interaction with the framework in its current form. ||| ||| Furthermore, as described in the `Resources` paper, there is no ||| handler program to provide projection capabilities. module Example.Sessions import Data.List import Resources %access public export %default total {- [ Actors] Here we define actors/roles in a session description, ensuring that we have a means to compare them. -} data Actor = MkActor String Eq Actor where (==) (MkActor a) (MkActor b) = a == b actorNotEqual : ((x = y) -> Void) -> (MkActor x = MkActor y) -> Void actorNotEqual f Refl = f Refl actorDecEq : (x,y : Actor) -> Dec (x = y) actorDecEq (MkActor x) (MkActor y) with (decEq x y) actorDecEq (MkActor y) (MkActor y) | (Yes Refl) = Yes Refl actorDecEq (MkActor x) (MkActor y) | (No contra) = No (actorNotEqual contra) DecEq Actor where decEq = actorDecEq Ord Actor where compare (MkActor a) (MkActor b) = compare a b -- Here we describe our type-level states. namespace TypeLevel ||| Channels are born free until they are bound. data Usage = Free | Bound ||| Variables in Sessions are either paired actors, or data types. data Ty = CHAN (Actor, Actor) | DATA Type namespace State ||| A channel's state is it's usage. record ChanState where constructor MkChanState usage : Usage ||| A data types state is the type of message and who has seen the message. record DataState where constructor MkDataState knownBy : List Actor type : Type ||| A mapping between variable types and their abstract state. CalcStateType : Ty -> Type CalcStateType (CHAN _) = ChanState CalcStateType (DATA _) = DataState namespace Predicates ||| A predicate to state that all the listed actors are aware of the data item. ||| ||| @actors The actors who know about the item. ||| @var The item the actors know about. ||| @item The abstract state associated with the item. data AllKnow : (actors : List Actor) -> (var : Var Ty (DATA type)) -> (item : StateItem Ty CalcStateType (DATA type)) -> Type where NilKnows : (prf : Elem x actors) -> AllKnow [x] msg (MkStateItem (DATA type) msg (MkDataState actors type)) ConsKnows : (prf : Elem x actors) -> (later : AllKnow xs msg (MkStateItem (DATA type) msg (MkDataState actors type))) -> AllKnow (x::xs) msg (MkStateItem (DATA type) msg (MkDataState actors type)) ||| A predicate to state that the given actor knows about the provided data item. ||| ||| @actor The actor who knows about the item. ||| @var The item the actors know about. ||| @item The abstract state associated with the item. data KnowsData : (actor : Actor) -> (var : Var Ty (DATA type)) -> (item : StateItem Ty CalcStateType (DATA type)) -> Type where DoesKnow : (prf : x = y) -> (prfE : Elem x actors) -> KnowsData y var (MkStateItem (DATA type) var (MkDataState actors type)) ||| A type-level function to record that a particular message has been used by an actor. ExpandWhoKnows : (newActor : Actor) -> (oldState : StateItem Ty CalcStateType (DATA type)) -> (prfState : KnowsData sender label oldState) -> StateItem Ty CalcStateType (DATA type) ExpandWhoKnows newActor (MkStateItem (DATA type) label (MkDataState actors type)) (DoesKnow Refl prfE) = MkStateItem (DATA type) label (MkDataState (newActor::actors) type) ||| Proof that the given sender and receiver are valid participants in the protocol. data AllowedToConnect : (sender, receiver : Actor) -> (actors : List Actor) -> Type where CanConnect : (prfSender : Elem sender actors) -> (prfReceiver : Elem receiver actors) -> AllowedToConnect sender receiver actors ||| An assertion that the given channel has the given state. data ChannelHasState : (assumedState : Usage) -> (chan : Var Ty (CHAN (s,r))) -> (actual : StateItem Ty CalcStateType (CHAN (s,r))) -> Type where YesChanHasState : ChannelHasState state chan (MkStateItem (CHAN (s,r)) chan (MkChanState state)) ||| A type-level function to set a channel's state. SetChannelState : (newState : Usage) -> (oldState : StateItem Ty CalcStateType (CHAN (s,r))) -> (prfState : ChannelHasState oldState' var oldState) -> StateItem Ty CalcStateType (CHAN (s,r)) SetChannelState newState (MkStateItem (CHAN (s,r)) var (MkChanState oldState')) YesChanHasState = MkStateItem (CHAN (s,r)) var (MkChanState newState) ||| A predicate to describe valid end states for data and connections. data EndState : (ty : Ty) -> StateItem Ty CalcStateType ty -> Type where ||| We do not care. EndData : EndState (DATA type) state ||| Connections must be free. EndConn : EndState (CHAN (s,r)) (MkStateItem (CHAN (s,r)) lbl (MkChanState Free)) ||| Our algebraic definition of a Session description language. data Sessions : (participants : List Actor) -> Lang Ty CalcStateType where ||| Describe that the given actor `a` creates a message of type `type`. ||| ||| We also need proof that the actor is allowed to participate in the description. NewData : (a : Actor) -> (type : Type) -> (prf : Elem a ps) -> Sessions ps (Var Ty (DATA type)) old (\lbl => MkStateItem (DATA type) lbl (MkDataState [a] type) :: old) ||| Describe that the given actor `a` creates a message that depends on an earlier message that `a` has seen. ||| ||| The resulting message type will be a dependent pair. NewDataDep : (a : Actor) -> (dep : Var Ty (DATA type)) -> (prfKnows : InContext (DATA type) (KnowsData a dep) old) -> (msgType : (msg : type) -> Type) -> Sessions ps (Var Ty (DATA (x ** msgType x))) old (\lbl => MkStateItem (DATA (x ** msgType x)) lbl (MkDataState [a] (x ** msgType x)) :: old) ||| Specify a new connection between two valid participants in the session. NewConnection : (a,b : Actor) -> (prf : AllowedToConnect a b ps) -> Sessions ps (Var Ty (CHAN (a,b))) old (\lbl => MkStateItem (CHAN (a,b)) lbl (MkChanState Bound) :: old) ||| Close an existing connection. EndConnection : (chan : Var Ty (CHAN (a,b))) -> (prf : InContext (CHAN (a,b)) (ChannelHasState Bound chan) old) -> Sessions ps () old (const $ update old prf (SetChannelState Free)) ||| Send a message that the channel sender knows about (either created or received) to the receiver on the given active channel. SendLeft : (chan : Var Ty (CHAN (s,r))) -> (msg : Var Ty (DATA type)) -> (prfActive : InContext (CHAN (s,r)) (ChannelHasState Bound chan) old) -> (prfKnows : InContext (DATA type) (KnowsData s msg) old) -> Sessions ps () old (const $ update old prfKnows (ExpandWhoKnows r)) ||| Send a message that the receiver on the channel knows about (either created or received) to the sending end on the given active channel. SendRight : (chan : Var Ty (CHAN (s,r))) -> (msg : Var Ty (DATA type)) -> (prfActive : InContext (CHAN (s,r)) (ChannelHasState Bound chan) old) -> (prfKnows : InContext (DATA type) (KnowsData r msg) old) -> Sessions ps () old (const $ update old prfKnows (ExpandWhoKnows s)) ||| If all actors in the session have seen the data then we can access the message's value and depend on it. ReadMsg : (msg : Var Ty (DATA type)) -> (prf : InContext (DATA type) (AllKnow ps msg) old) -> Sessions ps type old (const old) ||| End the session description if all the variables are in the correct end state. ||| ||| This is our check that all channels have been closed. StopSession : AllContext EndState old -> Sessions ps () old (const Nil) {- [ NOTE ] Here we define the language and high-level friendly API. -} ||| Define the `SESSIONS` language. SESSIONS : (ps : List Actor) -> LANG Ty CalcStateType SESSIONS ps = MkLang Ty CalcStateType (Sessions ps) ||| Define a closed session. Session : (m : Type -> Type) -> List Actor -> Type Session m ps = LangM m () (SESSIONS ps) Nil (const Nil) ||| Describe that the given actor `a` creates a message of type `type`. ||| ||| We also need proof that the actor is allowed to participate in the description. msg : (creator : Actor) -> (type : Type) -> {auto prf : Elem creator actors} -> LangM m (Var Ty (DATA type)) (SESSIONS actors) old (\lbl => MkStateItem (DATA type) lbl (MkDataState ([creator]) type) :: old) msg creator type {prf} = Expr $ NewData creator type prf ||| Describe that the given actor `a` creates a message that depends on an earlier message that `a` has seen. ||| ||| The resulting message type will be a dependent pair. msgDep : (creator : Actor) -> (dep : Var Ty (DATA type)) -> {auto prfKnows : InContext (DATA type) (KnowsData creator dep) old} -> (msgType : (msg : type) -> Type) -> LangM m (Var Ty (DATA (x ** msgType x))) (SESSIONS actors) old (\lbl => MkStateItem (DATA (x ** msgType x)) lbl (MkDataState [creator] (x ** msgType x)) :: old) msgDep creator dep {prfKnows} msgType = Expr (NewDataDep creator dep prfKnows msgType) ||| If all actors in the session have seen the data then we can access the message's value and depend on it. read : (msg : Var Ty (DATA type)) -> {auto prf : InContext (DATA type) (AllKnow actors msg) old} -> LangM m type (SESSIONS actors) old (const old) read msg {prf} = Expr $ ReadMsg msg prf ||| End the session description if all the variables are in the correct end state. ||| ||| This is our check that all channels have been closed. end : {auto prf : AllContext EndState old} -> LangM m () (SESSIONS actors) old (const Nil) end {prf} = Expr $ StopSession prf ||| Specify a new connection between two valid participants in the session. setup : (a, b : Actor) -> {auto prf : AllowedToConnect a b actors} -> LangM m (Var Ty (CHAN (a,b))) (SESSIONS actors) old (\lbl => MkStateItem (CHAN (a,b)) lbl (MkChanState Bound) :: old) setup sender receiver {prf} = Expr $ NewConnection sender receiver prf ||| Close an existing connection. destroy : (chan : Var Ty (CHAN (a,b))) -> {auto prf : InContext (CHAN (a,b)) (ChannelHasState Bound chan) old} -> LangM m () (SESSIONS actors) old (const $ update old prf (SetChannelState Free)) destroy chan {prf} = Expr $ EndConnection chan prf ||| Send a message that the channel sender knows about (either created or received) to the receiver on the given active channel. sendLeft : (chan : Var Ty (CHAN (s,r))) -> (msg : Var Ty (DATA type)) -> {auto prfActive : InContext (CHAN (s,r)) (ChannelHasState Bound chan) old} -> {auto prfKnows : InContext (DATA type) (KnowsData s msg) old} -> LangM m () (SESSIONS actors) old (const $ update old prfKnows (ExpandWhoKnows r)) sendLeft chan msg {prfActive} {prfKnows} = Expr (SendLeft chan msg prfActive prfKnows) ||| Send a message that the receiver on the channel knows about (either created or received) to the sending end on the given active channel. sendRight : (chan : Var Ty (CHAN (s,r))) -> (msg : Var Ty (DATA type)) -> {auto prfActive : InContext (CHAN (s,r)) (ChannelHasState Bound chan) old} -> {auto prfKnows : InContext (DATA type) (KnowsData r msg) old} -> LangM m () (SESSIONS actors) old (const $ update old prfKnows (ExpandWhoKnows s)) sendRight chan msg {prfActive} {prfKnows} = Expr (SendRight chan msg prfActive prfKnows) {- [ NOTE ] Let's define some actors. -} Alice : Actor Alice = MkActor "A" Bob : Actor Bob = MkActor "B" Charlie : Actor Charlie = MkActor "C" {- [ NOTE ] Here we define a value dependent version of the well known TCP Handshake. Dependent pairs are used to ensure that the sequence numbers sent are the ones previously seen. There are better ways to encode this, see the PLACES paper linked in the module's documentation. -} data Packet TCPHandshake : Session m [Alice, Bob] TCPHandshake = do chan <- setup Alice Bob m1 <- msg Alice (Packet, Nat) sendLeft chan m1 (p,x) <- read m1 m2 <- msg Bob (Packet, (x' ** x' = x), Nat) sendRight chan m2 (p,xplus,y) <- read m2 m3 <- msg Alice (Packet, (x' ** x' = x), (y' ** y' = y)) sendLeft chan m3 destroy chan end {- [ NOTE ] Here we define a PingPong protocol. In which Alice sends a Ping to Bob who responds with a Pong, and proof that they send a pong, and calls the session description again. If alice sent a Pong then the session ends. This is *a* encoding, there are probably better ways to encode this. -} data PingPong = Ping | Pong pingNotPong : (Ping = Pong) -> Void pingNotPong Refl impossible DecEq PingPong where decEq Ping Ping = Yes Refl decEq Pong Pong = Yes Refl decEq Ping Pong = No pingNotPong decEq Pong Ping = No (negEqSym pingNotPong) RfcPingPong : Session m [Alice, Bob] RfcPingPong = do chan <- setup Alice Bob val <- msg Alice PingPong sendLeft chan val res <- read val case res of Pong => do destroy chan end Ping => do val' <- msg Bob (x : PingPong ** x = Pong) sendRight chan val' destroy chan end assert_total $ RfcPingPong {- [ NOTE ] Here we define a simple varient of the Echo protocol that uses an optional type to act as a quit message in the Empty case. -} Echo : Session m [Alice, Bob] Echo {m} = do chan <- setup Alice Bob val <- msg Alice (Maybe String) sendLeft chan val res <- read val case res of Nothing => do destroy chan end Just _ => do sendRight chan val destroy chan end assert_total $ Echo {m=m} {- [ NOTE ] Here we define a simple Higher-Order-Protocol that emulates an authentication step using a Boolean. -} hoppy : Session m [Alice, Bob] -> Session m [Alice, Bob] hoppy p = do chan <- setup Alice Bob val <- msg Alice String sendLeft chan val resp <- msg Bob Bool sendRight chan resp res <- read resp case res of False => do destroy chan end True => do destroy chan end p -- --------------------------------------------------------------------- [ EOF ]
integer function slstr (from, to, first, chars) integer from (100), to (100) integer first, chars integer len, i, j, k integer length len = length (from) i = first if (.not.(i .lt. 1))goto 23000 i = i + len + 1 23000 continue if (.not.(chars .lt. 0))goto 23002 i = i + chars + 1 chars = - chars 23002 continue j = i + chars - 1 if (.not.(i .lt. 1))goto 23004 i = 1 23004 continue if (.not.(j .gt. len))goto 23006 j = len 23006 continue k = 0 23008 if (.not.(i .le. j))goto 23010 to (k + 1) = from (i) i = i + 1 23009 k = k + 1 goto 23008 23010 continue to (k + 1) = -2 slstr=(k) return end
(* Define a Monad class that can be instantiated *) (** Start with typeclass for [Monad] parameterized over the type [M:Type -> Type]. Note that [M] is a single parameter function. Definition is taken original from the web at *find the link* *) Class Monad (M: Type -> Type):Type := { unit: forall {A}, A -> M A ; bind: forall {A B}, M A -> (A -> (M B)) -> M B ; sequence: forall {A B}, M A -> M B -> M B ; left_unit : forall {A B} (a:A) (f:A -> M B), bind (unit a) f = f a ; right_unit : forall {A} (ma:M A), bind ma unit = ma ; assoc : forall {A B C} (ma:M A) (f:A -> M B) (g:B -> M C), bind (bind ma f) g = bind ma (fun a => bind (f a) g) ; bind_seq_eq : forall {A B} (f:M A) (g:M B), (sequence f g) = (bind f (fun (a:A) => g)) }. Notation "m >>= f" := (bind m f) (left associativity, at level 49). Notation "m >> f" := (sequence m f) (left associativity, at level 49).
theory Aleph_Relative imports CardinalArith_Relative begin definition HAleph :: "[i,i] \<Rightarrow> i" where "HAleph(i,r) \<equiv> if(\<not>(Ord(i)),i,if(i=0, nat, if(\<not>Limit(i) \<and> i\<noteq>0, csucc(r`( \<Union> i )), \<Union>j\<in>i. r`j)))" reldb_add functional "Limit" "Limit" relationalize "Limit" "is_Limit" external synthesize "is_Limit" from_definition arity_theorem for "is_Limit_fm" relativize functional "HAleph" "HAleph_rel" relationalize "HAleph_rel" "is_HAleph" synthesize "is_HAleph" from_definition assuming "nonempty" arity_theorem intermediate for "is_HAleph_fm" lemma arity_is_HAleph_fm_aux: assumes "i \<in> nat" "r \<in> nat" \<comment> \<open>NOTE: assumptions are \<^bold>\<open>not\<close> used, but if omitted, next lemma fails!\<close> shows "arity(Replace_fm(8 +\<^sub>\<omega> i, \<cdot>10 +\<^sub>\<omega> r`0 is 1\<cdot>, 3)) = 9 +\<^sub>\<omega> i \<union> pred(pred(11 +\<^sub>\<omega> r))" using arity_Replace_fm[of "\<cdot> (10+\<^sub>\<omega>r)`0 is 1\<cdot>" "8+\<^sub>\<omega>i" 3 "(11+\<^sub>\<omega>r) \<union> 1 \<union> 2"] ord_simp_union by (auto simp:arity) lemma arity_is_HAleph_fm[arity]: assumes "i \<in> nat" "r \<in> nat" "l \<in> nat" shows "arity(is_HAleph_fm(i, r, l)) = succ(i) \<union> succ(l) \<union> succ(r)" using assms pred_Un arity_is_HAleph_fm_aux arity_is_HAleph_fm' by auto definition Aleph' :: "i => i" where "Aleph'(a) == transrec(a,\<lambda>i r. HAleph(i,r))" relativize functional "Aleph'" "Aleph_rel" relationalize "Aleph_rel" "is_Aleph" txt\<open>The extra assumptions \<^term>\<open>a < length(env)\<close> and \<^term>\<open>c < length(env)\<close> in this schematic goal (and the following results on synthesis that depend on it) are imposed by @{thm [source] is_transrec_iff_sats}.\<close> schematic_goal sats_is_Aleph_fm_auto: "a \<in> nat \<Longrightarrow> c \<in> nat \<Longrightarrow> env \<in> list(A) \<Longrightarrow> a < length(env) \<Longrightarrow> c < length(env) \<Longrightarrow> 0 \<in> A \<Longrightarrow> is_Aleph(##A, nth(a, env), nth(c, env)) \<longleftrightarrow> A, env \<Turnstile> ?fm(a, c)" unfolding is_Aleph_def proof (rule is_transrec_iff_sats, rule_tac [1] is_HAleph_iff_sats) fix a0 a1 a2 a3 a4 a5 a6 a7 let ?env' = "Cons(a0, Cons(a1, Cons(a2, Cons(a3, Cons(a4, Cons(a5, Cons(a6, Cons(a7, env))))))))" show "nth(2, ?env') = a2" "nth(1, ?env') = a1" "nth(0, ?env') = a0" "nth(c, env) = nth(c, env)" by simp_all qed simp_all synthesize_notc "is_Aleph" from_schematic notation is_Aleph_fm (\<open>\<cdot>\<aleph>'(_') is _\<cdot>\<close>) lemma is_Aleph_fm_type [TC]: "a \<in> nat \<Longrightarrow> c \<in> nat \<Longrightarrow> is_Aleph_fm(a, c) \<in> formula" unfolding is_Aleph_fm_def by simp lemma sats_is_Aleph_fm: assumes "f\<in>nat" "r\<in>nat" "env \<in> list(A)" "0\<in>A" "f < length(env)" "r< length(env)" shows "is_Aleph(##A, nth(f, env), nth(r, env)) \<longleftrightarrow> A, env \<Turnstile> is_Aleph_fm(f,r)" using assms sats_is_Aleph_fm_auto unfolding is_Aleph_def is_Aleph_fm_def by simp lemma is_Aleph_iff_sats [iff_sats]: assumes "nth(f, env) = fa" "nth(r, env) = ra" "f < length(env)" "r< length(env)" "f \<in> nat" "r \<in> nat" "env \<in> list(A)" "0\<in>A" shows "is_Aleph(##A,fa,ra) \<longleftrightarrow> A, env \<Turnstile> is_Aleph_fm(f,r)" using assms sats_is_Aleph_fm[of f r env A] by simp arity_theorem for "is_Aleph_fm" lemma (in M_cardinal_arith_jump) is_Limit_iff: assumes "M(a)" shows "is_Limit(M,a) \<longleftrightarrow> Limit(a)" unfolding is_Limit_def Limit_def using lt_abs transM[OF ltD \<open>M(a)\<close>] assms by auto lemma HAleph_eq_Aleph_recursive: "Ord(i) \<Longrightarrow> HAleph(i,r) = (if i = 0 then nat else if \<exists>j. i = succ(j) then csucc(r ` (THE j. i = succ(j))) else \<Union>j<i. r ` j)" proof - assume "Ord(i)" moreover from this have "i = succ(j) \<Longrightarrow> (\<Union>succ(j)) = j" for j using Ord_Union_succ_eq by simp moreover from \<open>Ord(i)\<close> have "(\<exists>j. i = succ(j)) \<longleftrightarrow> \<not>Limit(i) \<and> i \<noteq> 0" using Ord_cases_disj by auto ultimately show ?thesis unfolding HAleph_def OUnion_def by auto qed lemma Aleph'_eq_Aleph: "Ord(a) \<Longrightarrow> Aleph'(a) = Aleph(a)" unfolding Aleph'_def Aleph_def transrec2_def using HAleph_eq_Aleph_recursive by (intro transrec_equal_on_Ord) auto reldb_rem functional "Aleph'" reldb_rem relational "is_Aleph" reldb_add functional "Aleph" "Aleph_rel" reldb_add relational "Aleph" "is_Aleph" abbreviation Aleph_r :: "[i,i\<Rightarrow>o] \<Rightarrow> i" (\<open>\<aleph>\<^bsub>_\<^esub>\<^bsup>_\<^esup>\<close>) where "Aleph_r(a,M) \<equiv> Aleph_rel(M,a)" abbreviation Aleph_r_set :: "[i,i] \<Rightarrow> i" (\<open>\<aleph>\<^bsub>_\<^esub>\<^bsup>_\<^esup>\<close>) where "Aleph_r_set(a,M) \<equiv> Aleph_rel(##M,a)" lemma Aleph_rel_def': "Aleph_rel(M,a) \<equiv> transrec(a, \<lambda>i r. HAleph_rel(M, i, r))" unfolding Aleph_rel_def . lemma succ_mem_Limit: "Limit(j) \<Longrightarrow> i \<in> j \<Longrightarrow> succ(i) \<in> j" using Limit_has_succ[THEN ltD] ltI Limit_is_Ord by auto locale M_pre_aleph = M_eclose + M_cardinal_arith_jump + assumes haleph_transrec_replacement: "M(a) \<Longrightarrow> transrec_replacement(M,is_HAleph(M),a)" begin lemma aux_ex_Replace_funapply: assumes "M(a)" "M(f)" shows "\<exists>x[M]. is_Replace(M, a, \<lambda>j y. f ` j = y, x)" proof - have "{f`j . j\<in>a} = {y . j\<in>a , f ` j=y}" "{y . j\<in>a , f ` j=y} = {y . j\<in>a , y =f ` j}" by auto moreover note assms moreover from calculation have "x \<in> a \<Longrightarrow> y = f `x \<Longrightarrow> M(y)" for x y using transM[OF _ \<open>M(a)\<close>] by auto moreover from assms have "M({f`j . j\<in>a})" using transM[OF _ \<open>M(a)\<close>] RepFun_closed[OF apply_replacement] by simp ultimately have 2:"is_Replace(M, a, \<lambda>j y. y = f ` j, {f`j . j\<in>a})" using Replace_abs[of _ _ "\<lambda>j y. y = f ` j",OF \<open>M(a)\<close>,THEN iffD2] by auto with \<open>M({f`j . j\<in>a})\<close> show ?thesis using is_Replace_cong[of _ _ M "\<lambda>j y. y = f ` j" "\<lambda>j y. f ` j = y", THEN iffD1,OF _ _ _ 2] by auto qed lemma is_HAleph_zero: assumes "M(f)" shows "is_HAleph(M,0,f,res) \<longleftrightarrow> res = nat" unfolding is_HAleph_def using Ord_0 If_abs is_Limit_iff is_csucc_iff assms aux_ex_Replace_funapply by auto lemma is_HAleph_succ: assumes "M(f)" "M(x)" "Ord(x)" "M(res)" shows "is_HAleph(M,succ(x),f,res) \<longleftrightarrow> res = csucc_rel(M,f`x)" unfolding is_HAleph_def using assms is_Limit_iff is_csucc_iff aux_ex_Replace_funapply If_abs Ord_Union_succ_eq by simp lemma is_HAleph_limit: assumes "M(f)" "M(x)" "Limit(x)" "M(res)" shows "is_HAleph(M,x,f,res) \<longleftrightarrow> res = (\<Union>{y . i\<in>x ,M(i) \<and> M(y) \<and> y = f`i})" proof - from assms have "univalent(M, x, \<lambda>j y. y = f ` j )" "(\<And>xa y. xa \<in> x \<Longrightarrow> f ` xa = y \<Longrightarrow> M(y))" "{y . x \<in> x, f ` x = y} = {y . i\<in>x ,M(i) \<and> M(y) \<and> y = f`i}" using univalent_triv[of M x "\<lambda>j .f ` j"] transM[OF _ \<open>M(x)\<close>] by auto moreover from this have "univalent(M, x, \<lambda>j y. f ` j = y )" by (rule_tac univalent_cong[of x x M " \<lambda>j y. y = f ` j" " \<lambda>j y. f ` j=y",THEN iffD1], auto) moreover from this have "univalent(M, x, \<lambda>j y. M(j) \<and> M(y) \<and> f ` j = y )" by auto ultimately show ?thesis unfolding is_HAleph_def using assms is_Limit_iff Limit_is_Ord zero_not_Limit If_abs is_csucc_iff Replace_abs apply_replacement by auto qed lemma is_HAleph_iff: assumes "M(a)" "M(f)" "M(res)" shows "is_HAleph(M, a, f, res) \<longleftrightarrow> res = HAleph_rel(M, a, f)" proof(cases "Ord(a)") case True note Ord_cases[OF \<open>Ord(a)\<close>] then show ?thesis proof(cases ) case 1 with True assms show ?thesis using is_HAleph_zero unfolding HAleph_rel_def by simp next case (2 j) with True assms show ?thesis using is_HAleph_succ Ord_Union_succ_eq unfolding HAleph_rel_def by simp next case 3 with assms show ?thesis using is_HAleph_limit zero_not_Limit Limit_is_Ord unfolding HAleph_rel_def by auto qed next case False then have "\<not>Limit(a)" "a\<noteq>0" "\<And> x . Ord(x) \<Longrightarrow> a\<noteq>succ(x)" using Limit_is_Ord by auto with False show ?thesis unfolding is_HAleph_def HAleph_rel_def using assms is_Limit_iff If_abs is_csucc_iff aux_ex_Replace_funapply by auto qed lemma HAleph_rel_closed [intro,simp]: assumes "function(f)" "M(a)" "M(f)" shows "M(HAleph_rel(M,a,f))" unfolding HAleph_rel_def using assms apply_replacement by simp lemma Aleph_rel_closed[intro, simp]: assumes "Ord(a)" "M(a)" shows "M(Aleph_rel(M,a))" proof - have "relation2(M, is_HAleph(M), HAleph_rel(M))" unfolding relation2_def using is_HAleph_iff assms by simp moreover have "\<forall>x[M]. \<forall>g[M]. function(g) \<longrightarrow> M(HAleph_rel(M, x, g))" using HAleph_rel_closed by simp moreover note assms ultimately show ?thesis unfolding Aleph_rel_def using transrec_closed[of "is_HAleph(M)" a "HAleph_rel(M)"] haleph_transrec_replacement by simp qed lemma Aleph_rel_zero: "\<aleph>\<^bsub>0\<^esub>\<^bsup>M\<^esup> = nat" using def_transrec [OF Aleph_rel_def',of _ 0] unfolding HAleph_rel_def by simp lemma Aleph_rel_succ: "Ord(\<alpha>) \<Longrightarrow> M(\<alpha>) \<Longrightarrow> \<aleph>\<^bsub>succ(\<alpha>)\<^esub>\<^bsup>M\<^esup> = (\<aleph>\<^bsub>\<alpha>\<^esub>\<^bsup>M\<^esup>\<^sup>+)\<^bsup>M\<^esup>" using Ord_Union_succ_eq by (subst def_transrec [OF Aleph_rel_def']) (simp add:HAleph_rel_def) lemma Aleph_rel_limit: assumes "Limit(\<alpha>)" "M(\<alpha>)" shows "\<aleph>\<^bsub>\<alpha>\<^esub>\<^bsup>M\<^esup> = \<Union>{\<aleph>\<^bsub>j\<^esub>\<^bsup>M\<^esup> . j \<in> \<alpha>}" proof - note trans=transM[OF _ \<open>M(\<alpha>)\<close>] from \<open>M(\<alpha>)\<close> have "\<aleph>\<^bsub>\<alpha>\<^esub>\<^bsup>M\<^esup> = HAleph_rel(M, \<alpha>, \<lambda>x\<in>\<alpha>. \<aleph>\<^bsub>x\<^esub>\<^bsup>M\<^esup>)" using def_transrec [OF Aleph_rel_def',of M \<alpha>] by simp also have "... = \<Union>{a . j \<in> \<alpha>, M(a) \<and> a = \<aleph>\<^bsub>j\<^esub>\<^bsup>M\<^esup>}" unfolding HAleph_rel_def using assms zero_not_Limit Limit_is_Ord trans by auto also have "... = \<Union>{\<aleph>\<^bsub>j\<^esub>\<^bsup>M\<^esup> . j \<in> \<alpha>}" using Aleph_rel_closed[OF _ trans] Ord_in_Ord Limit_is_Ord[OF \<open>Limit(\<alpha>)\<close>] by auto finally show ?thesis . qed lemma is_Aleph_iff: assumes "Ord(a)" "M(a)" "M(res)" shows "is_Aleph(M, a, res) \<longleftrightarrow> res = \<aleph>\<^bsub>a\<^esub>\<^bsup>M\<^esup>" proof - have "relation2(M, is_HAleph(M), HAleph_rel(M))" unfolding relation2_def using is_HAleph_iff assms by simp moreover have "\<forall>x[M]. \<forall>g[M]. function(g) \<longrightarrow> M(HAleph_rel(M, x, g))" using HAleph_rel_closed by simp ultimately show ?thesis using assms transrec_abs haleph_transrec_replacement unfolding is_Aleph_def Aleph_rel_def by simp qed end \<comment> \<open>\<^locale>\<open>M_pre_aleph\<close>\<close> locale M_aleph = M_pre_aleph + assumes aleph_rel_separation: "Ord(x) \<Longrightarrow> M(x) \<Longrightarrow> separation(M, \<lambda>y. \<exists>z\<in>x. y = \<aleph>\<^bsub>z\<^esub>\<^bsup>M\<^esup>)" begin lemma Aleph_rel_cont: "Limit(l) \<Longrightarrow> M(l) \<Longrightarrow> \<aleph>\<^bsub>l\<^esub>\<^bsup>M\<^esup> = (\<Union>i<l. \<aleph>\<^bsub>i\<^esub>\<^bsup>M\<^esup>)" using Limit_is_Ord Aleph_rel_limit by (simp add:OUnion_def) lemma Ord_Aleph_rel: assumes "Ord(a)" shows "M(a) \<Longrightarrow> Ord(\<aleph>\<^bsub>a\<^esub>\<^bsup>M\<^esup>)" using \<open>Ord(a)\<close> proof(induct a rule:trans_induct3) case 0 show ?case using Aleph_rel_zero by simp next case (succ x) with \<open>Ord(x)\<close> have "M(x)" "Ord(\<aleph>\<^bsub>x\<^esub>\<^bsup>M\<^esup>)" by simp_all with \<open>Ord(x)\<close> have "Ord(csucc_rel(M,\<aleph>\<^bsub>x\<^esub>\<^bsup>M\<^esup>))" using Card_rel_is_Ord Card_rel_csucc_rel by simp with \<open>Ord(x)\<close> \<open>M(x)\<close> show ?case using Aleph_rel_succ by simp next case (limit x) note trans=transM[OF _ \<open>M(x)\<close>] from limit have "\<aleph>\<^bsub>x\<^esub>\<^bsup>M\<^esup> = (\<Union>i\<in>x. \<aleph>\<^bsub>i\<^esub>\<^bsup>M\<^esup>)" using Aleph_rel_cont OUnion_def Limit_is_Ord by auto with limit show ?case using Ord_UN trans by auto qed lemma Aleph_rel_increasing: assumes "a < b" and types: "M(a)" "M(b)" shows "\<aleph>\<^bsub>a\<^esub>\<^bsup>M\<^esup> < \<aleph>\<^bsub>b\<^esub>\<^bsup>M\<^esup>" proof - { fix x from assms have "Ord(b)" by (blast intro: lt_Ord2) moreover assume "M(x)" moreover note \<open>M(b)\<close> ultimately have "x < b \<Longrightarrow> \<aleph>\<^bsub>x\<^esub>\<^bsup>M\<^esup> < \<aleph>\<^bsub>b\<^esub>\<^bsup>M\<^esup>" proof (induct b arbitrary: x rule: trans_induct3) case 0 thus ?case by simp next case (succ b) then show ?case using Card_rel_csucc_rel Ord_Aleph_rel Ord_Union_succ_eq lt_csucc_rel lt_trans[of _ "\<aleph>\<^bsub>b\<^esub>\<^bsup>M\<^esup>" "csucc\<^bsup>M\<^esup>(\<aleph>\<^bsub>b\<^esub>\<^bsup>M\<^esup>)"] by (subst (2) def_transrec[OF Aleph_rel_def']) (auto simp add: le_iff HAleph_rel_def) next case (limit l) then have sc: "succ(x) < l" by (blast intro: Limit_has_succ) then have "\<aleph>\<^bsub>x\<^esub>\<^bsup>M\<^esup> < (\<Union>j<l. \<aleph>\<^bsub>j\<^esub>\<^bsup>M\<^esup>)" using limit Ord_Aleph_rel Ord_OUN proof(rule_tac OUN_upper_lt,blast intro: Card_rel_is_Ord ltD lt_Ord) from \<open>x<l\<close> \<open>Limit(l)\<close> have "Ord(x)" using Limit_is_Ord Ord_in_Ord by (auto dest!:ltD) with \<open>M(x)\<close> show "\<aleph>\<^bsub>x\<^esub>\<^bsup>M\<^esup> < \<aleph>\<^bsub>succ(x)\<^esub>\<^bsup>M\<^esup>" using Card_rel_csucc_rel Ord_Aleph_rel lt_csucc_rel ltD[THEN [2] Ord_in_Ord] succ_in_MI[OF \<open>M(x)\<close>] Aleph_rel_succ[of x] by (simp) next from \<open>M(l)\<close> \<open>Limit(l)\<close> show "Ord(\<Union>j<l. \<aleph>\<^bsub>j\<^esub>\<^bsup>M\<^esup>)" using Ord_Aleph_rel lt_Ord Limit_is_Ord Ord_in_Ord by (rule_tac Ord_OUN) (auto dest:transM ltD intro!:Ord_Aleph_rel) qed then show ?case using limit Aleph_rel_cont by simp qed } with types assms show ?thesis by simp qed lemma Card_rel_Aleph_rel [simp, intro]: assumes "Ord(a)" and types: "M(a)" shows "Card\<^bsup>M\<^esup>(\<aleph>\<^bsub>a\<^esub>\<^bsup>M\<^esup>)" using assms proof (induct rule:trans_induct3) case 0 then show ?case using Aleph_rel_zero Card_rel_nat by simp next case (succ x) then show ?case using Card_rel_csucc_rel Ord_Aleph_rel Aleph_rel_succ by simp next case (limit x) moreover from this have "Ord(x)" using Limit_is_Ord by simp from this have "{y . z \<in> x, M(y) \<and> M(z) \<and> y = \<aleph>\<^bsub>z\<^esub>\<^bsup>M\<^esup>} = {y . z \<in> x, M(y) \<and> M(z) \<and> Ord(z) \<and> y = \<aleph>\<^bsub>z\<^esub>\<^bsup>M\<^esup>}" using Ord_in_Ord by simp moreover from \<open>Ord(x)\<close> have "{y . z \<in> x, M(y) \<and> M(z) \<and> Ord(z) \<and> y = \<aleph>\<^bsub>z\<^esub>\<^bsup>M\<^esup>} = {y . z \<in> x, M(z) \<and> y = \<aleph>\<^bsub>z\<^esub>\<^bsup>M\<^esup>}" using Ord_in_Ord by blast moreover from \<open>Ord(x)\<close> \<open>M(x)\<close> have "{y . z \<in> x, M(z) \<and> y = \<aleph>\<^bsub>z\<^esub>\<^bsup>M\<^esup>} \<subseteq> \<aleph>\<^bsub>x\<^esub>\<^bsup>M\<^esup>" using Aleph_rel_increasing by (auto dest:ltD transM intro:ltI) with calculation have "{y . z \<in> x, M(z) \<and> y = \<aleph>\<^bsub>z\<^esub>\<^bsup>M\<^esup>} = {y \<in> \<aleph>\<^bsub>x\<^esub>\<^bsup>M\<^esup> . (\<exists>z \<in> x. y = \<aleph>\<^bsub>z\<^esub>\<^bsup>M\<^esup>)}" by (blast dest:transM) with calculation have "{y . z \<in> x, M(y) \<and> M(z) \<and> y = \<aleph>\<^bsub>z\<^esub>\<^bsup>M\<^esup>} = {y \<in> \<aleph>\<^bsub>x\<^esub>\<^bsup>M\<^esup> . (\<exists>z \<in> x. y = \<aleph>\<^bsub>z\<^esub>\<^bsup>M\<^esup>)}" by simp moreover from \<open>Ord(x)\<close> \<open>M(x)\<close> have "M({y \<in> \<aleph>\<^bsub>x\<^esub>\<^bsup>M\<^esup> . (\<exists>z \<in> x. y = \<aleph>\<^bsub>z\<^esub>\<^bsup>M\<^esup>)})" using aleph_rel_separation by simp ultimately show ?case using Ord_Aleph_rel Card_nat Limit_is_Ord Card_relI by (subst def_transrec [OF Aleph_rel_def']) (auto simp add:HAleph_rel_def) qed lemmas nat_subset_Aleph_rel_1 = Ord_lt_subset[OF Ord_Aleph_rel[of 1] Aleph_rel_increasing[of 0 1,simplified],simplified] end \<comment> \<open>\<^locale>\<open>M_aleph\<close>\<close> end
import Quantifiers.main universe u example {α : Type u} (a : α) : α := by main example {α : Type u} (P : α → α → Prop) (h : ∃ x, ∀ y, P x y) : ∀ y, ∃ x, P x y := by main example {α : Type u} (P : α → Prop) (Q : α → Prop) (h₁ : ∃ x, P x) (h₂ : ∀ x, P x → Q x) : ∃ x, Q x := by main example {α β : Type u} (P : α → α → β → α → Prop) (Q : α → α → β → α → Prop) (b : β) (h₁ : ∀ x, ∃ y, ∀ z w, P x y z w) (h₂ : ∃ x, ∀ y z w, P x y z w → Q x y z w) : ∃ x y z, ∀ w, Q x y z w := by main example {α₁ α₂ α₃ α₄ α₅ : Type} (f₁ : α₁ → α₂ → α₅) (a₁ : α₁) (f₂ : α₃ → α₄ → α₂) (a₂ : α₃) (f₃ : α₅ → α₃) (f₄ : α₂ → α₄) (f₅ : α₃ → α₄) : α₅ := by main
||| ||| ||| foldr is the unique solution to the equation: ||| ||| h f e [] = e ||| h f e (x :: xs) = x `h` (foldr f e xs) ||| ||| (This fact is called 'the universal property of foldr'.) ||| ||| Since the prelude defines foldr tail-recursively, this fact isn't immediate ||| and we need some lemmata to prove it. module Data.Vect.Properties.Foldr import Data.Vect import Data.Vect.Elem import Data.Fin import Data.Nat import Data.Nat.Order import Syntax.PreorderReasoning import Syntax.PreorderReasoning.Generic import Control.Order ||| Sum implemented with foldr public export sumR : (Foldable f, Num a) => f a -> a sumR = foldr (+) 0 %transform "sumR/sum" sumR = sum ||| A function H : forall n. Vect n A -> B preserving the structure of vectors over A public export record VectHomomorphismProperty {0 A, B : Type} (F : A -> B -> B) (E : B) (H : forall n . Vect n A -> B) where constructor ShowVectHomomorphismProperty nil : H [] = E cons : {0 n : Nat} -> (x : A) -> (xs : Vect n A) -> H (x :: xs) = x `F` (H xs) ||| There is an extensionally unique function preserving the vector structure export nilConsInitiality : (f : a -> b -> b) -> (e : b) -> (h1, h2 : forall n . Vect n a -> b) -> (prf1 : VectHomomorphismProperty f e h1) -> (prf2 : VectHomomorphismProperty f e h2) -> (xs : Vect n a) -> h1 xs = h2 xs nilConsInitiality f e h1 h2 prf1 prf2 [] = Calc $ |~ h1 [] ~~ e ...(prf1.nil) ~~ h2 [] ...(sym prf2.nil) nilConsInitiality f e h1 h2 prf1 prf2 (x :: xs) = Calc $ |~ h1 (x :: xs) ~~ (x `f` (h1 xs)) ...(prf1.cons _ _) ~~ (x `f` (h2 xs)) ...(cong (x `f`) $ nilConsInitiality f e h1 h2 prf1 prf2 xs) ~~ h2 (x :: xs) ...(sym $ prf2.cons _ _) ||| extensionality is a congruence with respect to Data.Vect.foldrImpl foldrImplExtensional : (f : a -> b -> b) -> (e : b) -> (go1, go2 : b -> b) -> ((y : b) -> go1 y = go2 y) -> (xs : Vect n a) -> foldrImpl f e go1 xs = foldrImpl f e go2 xs foldrImplExtensional f e go1 go2 ext [] = ext e foldrImplExtensional f e go1 go2 ext (x :: xs) = foldrImplExtensional f e _ _ (\y => ext (f x y)) xs ||| foldrImpl f e x : (b -> -) -> - is natural foldrImplNaturality : (f : a -> b -> b) -> (e : b) -> (xs : Vect n a) -> (go1, go2 : b -> b) -> foldrImpl f e (go1 . go2) xs = go1 (foldrImpl f e go2 xs) foldrImplNaturality f e [] go1 go2 = Refl foldrImplNaturality f e (x :: xs) go1 go2 = foldrImplNaturality f e xs go1 (go2 . (f x)) ||| Our tail-recursive foldr preserves the vector structure export foldrVectHomomorphism : VectHomomorphismProperty f e (foldr f e) foldrVectHomomorphism = ShowVectHomomorphismProperty { nil = Refl , cons = \x, xs => Calc $ |~ foldr f e (x :: xs) ~~ foldrImpl f e (id . (f x)) xs ...(Refl) ~~ foldrImpl f e ((f x) . id) xs ...(foldrImplExtensional f e _ _ (\y => Refl) xs) ~~ f x (foldrImpl f e id xs) ...(foldrImplNaturality f e xs (f x) _) ~~ f x (foldr f e xs) ...(Refl) } ||| foldr is the unique function preserving the vector structure export foldrUniqueness : (h : forall n . Vect n a -> b) -> VectHomomorphismProperty f e h -> (xs : Vect n a) -> h xs = foldr f e xs foldrUniqueness {f} h prf xs = irrelevantEq $ nilConsInitiality f e h (foldr f e) prf foldrVectHomomorphism xs ||| Each summand is `LTE` the sum export sumIsGTEtoParts : {x : Nat} -> (xs : Vect n Nat) -> (x `Elem` xs) -> sumR xs `GTE` x sumIsGTEtoParts (x :: xs) Here = CalcWith $ |~ x ~~ x + 0 ...(sym $ plusZeroRightNeutral _) <~ x + (sumR xs) ...(plusLteMonotoneLeft x 0 _ LTEZero) ~~ sumR (x :: xs) ...(sym $ (foldrVectHomomorphism {f = plus} {e = 0}).cons _ _) sumIsGTEtoParts {x} (y :: xs) (There later) = CalcWith $ |~ x <~ sumR xs ...(sumIsGTEtoParts {x} xs later) ~~ 0 + sumR xs ...(Refl) <~ y + (sumR xs) ...(plusLteMonotoneRight (sumR xs) 0 y LTEZero) ~~ sumR (y :: xs) ...(sym $ (foldrVectHomomorphism {f = plus} {e = 0}).cons _ _) ||| `sumR : Vect n Nat -> Nat` is monotone export sumMonotone : {n : Nat} -> (xs, ys : Vect n Nat) -> (prf : (i : Fin n) -> index i xs `LTE` index i ys) -> (sumR xs `LTE` sumR ys) sumMonotone [] [] prf = LTEZero sumMonotone (x :: xs) (y :: ys) prf = let prf' = sumMonotone xs ys (\i => prf (FS i)) in CalcWith $ |~ sumR (x :: xs) ~~ x + sumR xs ...((foldrVectHomomorphism {f = plus} {e = 0}).cons x xs) <~ y + sumR ys ...(plusLteMonotone (prf 0) prf') ~~ sumR (y :: ys) ...(sym $ (foldrVectHomomorphism {f = plus} {e = 0}).cons y ys)
[GOAL] ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹ : HasImage f g : B ⟶ C inst✝ : HasKernel g w : f ≫ g = 0 ⊢ kernel.lift g f w ≫ kernel.ι g = f [PROOFSTEP] simp [GOAL] ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹ : HasImage f g : B ⟶ C inst✝ : HasKernel g w : f ≫ g = 0 ⊢ Mono (imageToKernel f g w) [PROOFSTEP] dsimp only [imageToKernel] [GOAL] ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹ : HasImage f g : B ⟶ C inst✝ : HasKernel g w : f ≫ g = 0 ⊢ Mono (Subobject.ofLE (imageSubobject f) (kernelSubobject g) (_ : imageSubobject f ≤ kernelSubobject g)) [PROOFSTEP] infer_instance [GOAL] ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹ : HasImage f g : B ⟶ C inst✝ : HasKernel g w : f ≫ g = 0 ⊢ imageToKernel f g w ≫ Subobject.arrow (kernelSubobject g) = Subobject.arrow (imageSubobject f) [PROOFSTEP] simp [imageToKernel] [GOAL] ι : Type u_1 V : Type u inst✝⁴ : Category.{v, u} V inst✝³ : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝² : HasImage f g : B ⟶ C inst✝¹ : HasKernel g inst✝ : ConcreteCategory V w : f ≫ g = 0 x : (forget V).obj (Subobject.underlying.obj (imageSubobject f)) ⊢ ↑(Subobject.arrow (kernelSubobject g)) (↑(imageToKernel f g w) x) = ↑(Subobject.arrow (imageSubobject f)) x [PROOFSTEP] rw [← comp_apply, imageToKernel_arrow] -- This is less useful as a `simp` lemma than it initially appears, -- as it "loses" the information the morphism factors through the image. [GOAL] ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹ : HasImage f g : B ⟶ C inst✝ : HasKernel g w : f ≫ g = 0 ⊢ factorThruImageSubobject f ≫ imageToKernel f g w = factorThruKernelSubobject g f w [PROOFSTEP] ext [GOAL] case h ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹ : HasImage f g : B ⟶ C inst✝ : HasKernel g w : f ≫ g = 0 ⊢ (factorThruImageSubobject f ≫ imageToKernel f g w) ≫ Subobject.arrow (kernelSubobject g) = factorThruKernelSubobject g f w ≫ Subobject.arrow (kernelSubobject g) [PROOFSTEP] simp [GOAL] ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C inst✝¹ : HasKernels V inst✝ : HasZeroObject V w : 0 ≫ g = 0 ⊢ imageToKernel 0 g w = 0 [PROOFSTEP] ext [GOAL] case h ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C inst✝¹ : HasKernels V inst✝ : HasZeroObject V w : 0 ≫ g = 0 ⊢ imageToKernel 0 g w ≫ Subobject.arrow (kernelSubobject g) = 0 ≫ Subobject.arrow (kernelSubobject g) [PROOFSTEP] simp [GOAL] ι : Type u_1 V : Type u inst✝² : Category.{v, u} V inst✝¹ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C inst✝ : HasImages V w : f ≫ 0 = 0 ⊢ imageToKernel f 0 w = Subobject.arrow (imageSubobject f) ≫ inv (Subobject.arrow (kernelSubobject 0)) [PROOFSTEP] ext [GOAL] case h ι : Type u_1 V : Type u inst✝² : Category.{v, u} V inst✝¹ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C inst✝ : HasImages V w : f ≫ 0 = 0 ⊢ imageToKernel f 0 w ≫ Subobject.arrow (kernelSubobject 0) = (Subobject.arrow (imageSubobject f) ≫ inv (Subobject.arrow (kernelSubobject 0))) ≫ Subobject.arrow (kernelSubobject 0) [PROOFSTEP] simp [GOAL] ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C inst✝¹ : HasKernels V inst✝ : HasImages V D : V h : C ⟶ D w : f ≫ g = 0 ⊢ f ≫ g ≫ h = 0 [PROOFSTEP] simp [reassoc_of% w] [GOAL] ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C inst✝¹ : HasKernels V inst✝ : HasImages V D : V h : C ⟶ D w : f ≫ g = 0 ⊢ imageToKernel f (g ≫ h) (_ : f ≫ g ≫ h = 0) = imageToKernel f g w ≫ Subobject.ofLE (kernelSubobject g) (kernelSubobject (g ≫ h)) (_ : kernelSubobject g ≤ kernelSubobject (g ≫ h)) [PROOFSTEP] ext [GOAL] case h ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C inst✝¹ : HasKernels V inst✝ : HasImages V D : V h : C ⟶ D w : f ≫ g = 0 ⊢ imageToKernel f (g ≫ h) (_ : f ≫ g ≫ h = 0) ≫ Subobject.arrow (kernelSubobject (g ≫ h)) = (imageToKernel f g w ≫ Subobject.ofLE (kernelSubobject g) (kernelSubobject (g ≫ h)) (_ : kernelSubobject g ≤ kernelSubobject (g ≫ h))) ≫ Subobject.arrow (kernelSubobject (g ≫ h)) [PROOFSTEP] simp [GOAL] ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C inst✝¹ : HasKernels V inst✝ : HasImages V Z : V h : Z ⟶ A w : f ≫ g = 0 ⊢ (h ≫ f) ≫ g = 0 [PROOFSTEP] simp [w] [GOAL] ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C inst✝¹ : HasKernels V inst✝ : HasImages V Z : V h : Z ⟶ A w : f ≫ g = 0 ⊢ imageToKernel (h ≫ f) g (_ : (h ≫ f) ≫ g = 0) = Subobject.ofLE (imageSubobject (h ≫ f)) (imageSubobject f) (_ : imageSubobject (h ≫ f) ≤ imageSubobject f) ≫ imageToKernel f g w [PROOFSTEP] ext [GOAL] case h ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C inst✝¹ : HasKernels V inst✝ : HasImages V Z : V h : Z ⟶ A w : f ≫ g = 0 ⊢ imageToKernel (h ≫ f) g (_ : (h ≫ f) ≫ g = 0) ≫ Subobject.arrow (kernelSubobject g) = (Subobject.ofLE (imageSubobject (h ≫ f)) (imageSubobject f) (_ : imageSubobject (h ≫ f) ≤ imageSubobject f) ≫ imageToKernel f g w) ≫ Subobject.arrow (kernelSubobject g) [PROOFSTEP] simp [GOAL] ι : Type u_1 V : Type u inst✝⁴ : Category.{v, u} V inst✝³ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C inst✝² : HasKernels V inst✝¹ : HasImages V D : V h : C ⟶ D inst✝ : Mono h w : f ≫ g ≫ h = 0 ⊢ (f ≫ g) ≫ h = 0 ≫ h [PROOFSTEP] simpa using w [GOAL] ι : Type u_1 V : Type u inst✝⁴ : Category.{v, u} V inst✝³ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C inst✝² : HasKernels V inst✝¹ : HasImages V D : V h : C ⟶ D inst✝ : Mono h w : f ≫ g ≫ h = 0 ⊢ imageToKernel f (g ≫ h) w = imageToKernel f g (_ : f ≫ g = 0) ≫ (Subobject.isoOfEq (kernelSubobject (g ≫ h)) (kernelSubobject g) (_ : kernelSubobject (g ≫ h) = kernelSubobject g)).inv [PROOFSTEP] ext [GOAL] case h ι : Type u_1 V : Type u inst✝⁴ : Category.{v, u} V inst✝³ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C inst✝² : HasKernels V inst✝¹ : HasImages V D : V h : C ⟶ D inst✝ : Mono h w : f ≫ g ≫ h = 0 ⊢ imageToKernel f (g ≫ h) w ≫ Subobject.arrow (kernelSubobject (g ≫ h)) = (imageToKernel f g (_ : f ≫ g = 0) ≫ (Subobject.isoOfEq (kernelSubobject (g ≫ h)) (kernelSubobject g) (_ : kernelSubobject (g ≫ h) = kernelSubobject g)).inv) ≫ Subobject.arrow (kernelSubobject (g ≫ h)) [PROOFSTEP] simp [GOAL] ι : Type u_1 V : Type u inst✝⁴ : Category.{v, u} V inst✝³ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C inst✝² : HasKernels V inst✝¹ : HasImages V Z : V h : Z ⟶ A inst✝ : Epi h w : (h ≫ f) ≫ g = 0 ⊢ h ≫ f ≫ g = h ≫ 0 [PROOFSTEP] simpa using w [GOAL] ι : Type u_1 V : Type u inst✝⁴ : Category.{v, u} V inst✝³ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C inst✝² : HasKernels V inst✝¹ : HasImages V Z : V h : Z ⟶ A inst✝ : Epi h w : (h ≫ f) ≫ g = 0 ⊢ imageToKernel (h ≫ f) g w = Subobject.ofLE (imageSubobject (h ≫ f)) (imageSubobject f) (_ : imageSubobject (h ≫ f) ≤ imageSubobject f) ≫ imageToKernel f g (_ : f ≫ g = 0) [PROOFSTEP] ext [GOAL] case h ι : Type u_1 V : Type u inst✝⁴ : Category.{v, u} V inst✝³ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C inst✝² : HasKernels V inst✝¹ : HasImages V Z : V h : Z ⟶ A inst✝ : Epi h w : (h ≫ f) ≫ g = 0 ⊢ imageToKernel (h ≫ f) g w ≫ Subobject.arrow (kernelSubobject g) = (Subobject.ofLE (imageSubobject (h ≫ f)) (imageSubobject f) (_ : imageSubobject (h ≫ f) ≤ imageSubobject f) ≫ imageToKernel f g (_ : f ≫ g = 0)) ≫ Subobject.arrow (kernelSubobject g) [PROOFSTEP] simp [GOAL] ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C inst✝¹ : HasEqualizers V inst✝ : HasImages V Z : V i : B ≅ Z w : (f ≫ i.hom) ≫ i.inv ≫ g = 0 ⊢ f ≫ g = 0 [PROOFSTEP] simpa using w [GOAL] ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C inst✝¹ : HasEqualizers V inst✝ : HasImages V Z : V i : B ≅ Z w : (f ≫ i.hom) ≫ i.inv ≫ g = 0 ⊢ imageToKernel (f ≫ i.hom) (i.inv ≫ g) w = (imageSubobjectCompIso f i.hom).hom ≫ imageToKernel f g (_ : f ≫ g = 0) ≫ (kernelSubobjectIsoComp i.inv g).inv [PROOFSTEP] ext [GOAL] case h ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C inst✝¹ : HasEqualizers V inst✝ : HasImages V Z : V i : B ≅ Z w : (f ≫ i.hom) ≫ i.inv ≫ g = 0 ⊢ imageToKernel (f ≫ i.hom) (i.inv ≫ g) w ≫ Subobject.arrow (kernelSubobject (i.inv ≫ g)) = ((imageSubobjectCompIso f i.hom).hom ≫ imageToKernel f g (_ : f ≫ g = 0) ≫ (kernelSubobjectIsoComp i.inv g).inv) ≫ Subobject.arrow (kernelSubobject (i.inv ≫ g)) [PROOFSTEP] simp [GOAL] ι : Type u_1 V : Type u inst✝⁴ : Category.{v, u} V inst✝³ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C inst✝² : HasKernels V inst✝¹ : HasZeroObject V inst✝ : Mono g ⊢ 0 ≫ g = 0 [PROOFSTEP] simp [GOAL] ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C inst✝¹ : HasImages V inst✝ : Epi f ⊢ f ≫ 0 = 0 [PROOFSTEP] simp [GOAL] ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C inst✝¹ : HasImages V inst✝ : Epi f ⊢ Epi (imageToKernel f 0 (_ : f ≫ 0 = 0)) [PROOFSTEP] simp only [imageToKernel_zero_right] [GOAL] ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C inst✝¹ : HasImages V inst✝ : Epi f ⊢ Epi (Subobject.arrow (imageSubobject f) ≫ inv (Subobject.arrow (kernelSubobject 0))) [PROOFSTEP] haveI := epi_image_of_epi f [GOAL] ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C inst✝¹ : HasImages V inst✝ : Epi f this : Epi (image.ι f) ⊢ Epi (Subobject.arrow (imageSubobject f) ≫ inv (Subobject.arrow (kernelSubobject 0))) [PROOFSTEP] rw [← imageSubobject_arrow] [GOAL] ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C inst✝¹ : HasImages V inst✝ : Epi f this : Epi (image.ι f) ⊢ Epi (((imageSubobjectIso f).hom ≫ image.ι f) ≫ inv (Subobject.arrow (kernelSubobject 0))) [PROOFSTEP] refine' @epi_comp _ _ _ _ _ _ (epi_comp _ _) _ _ [GOAL] ι : Type u_1 V : Type u inst✝⁴ : Category.{v, u} V inst✝³ : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝² : HasImage f g : B ⟶ C inst✝¹ : HasKernel g w : f ≫ g = 0 inst✝ : HasCokernel (imageToKernel f g w) D : V k : Subobject.underlying.obj (kernelSubobject g) ⟶ D p : imageToKernel f g w ≫ k = 0 ⊢ π f g w ≫ desc f g w k p = k [PROOFSTEP] simp [homology.π, homology.desc] [GOAL] ι : Type u_1 V : Type u inst✝⁸ : Category.{v, u} V inst✝⁷ : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝⁶ : HasImage f g : B ⟶ C inst✝⁵ : HasKernel g w : f ≫ g = 0 inst✝⁴ : HasCokernel (imageToKernel f g w) inst✝³ : HasCokernel (imageToKernel f 0 (_ : f ≫ 0 = 0)) inst✝² : HasCokernel f inst✝¹ : HasCokernel (image.ι f) inst✝ : Epi (factorThruImage f) ⊢ imageToKernel f 0 (_ : f ≫ 0 = 0) ≫ (kernelSubobjectIso 0 ≪≫ kernelZeroIsoSource).hom = (imageSubobjectIso f).hom ≫ image.ι f [PROOFSTEP] simp [GOAL] ι : Type u_1 V : Type u inst✝⁷ : Category.{v, u} V inst✝⁶ : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝⁵ : HasImage f g : B ⟶ C inst✝⁴ : HasKernel g w : f ≫ g = 0 inst✝³ : HasCokernel (imageToKernel f g w) inst✝² : HasZeroObject V inst✝¹ : HasImage 0 inst✝ : HasCokernel (imageToKernel 0 0 (_ : 0 ≫ 0 = 0)) ⊢ imageToKernel 0 0 (_ : 0 ≫ 0 = 0) ≫ Subobject.arrow (kernelSubobject 0) = 0 [PROOFSTEP] simp [GOAL] ι : Type u_1 V : Type u inst✝¹⁴ : Category.{v, u} V inst✝¹³ : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹² : HasImage f g : B ⟶ C inst✝¹¹ : HasKernel g w : f ≫ g = 0 A' B' C' : V f' : A' ⟶ B' inst✝¹⁰ : HasImage f' g' : B' ⟶ C' inst✝⁹ : HasKernel g' w' : f' ≫ g' = 0 α : Arrow.mk f ⟶ Arrow.mk f' inst✝⁸ : HasImageMap α β : Arrow.mk g ⟶ Arrow.mk g' A₁ B₁ C₁ : V f₁ : A₁ ⟶ B₁ inst✝⁷ : HasImage f₁ g₁ : B₁ ⟶ C₁ inst✝⁶ : HasKernel g₁ w₁ : f₁ ≫ g₁ = 0 A₂ B₂ C₂ : V f₂ : A₂ ⟶ B₂ inst✝⁵ : HasImage f₂ g₂ : B₂ ⟶ C₂ inst✝⁴ : HasKernel g₂ w₂ : f₂ ≫ g₂ = 0 A₃ B₃ C₃ : V f₃ : A₃ ⟶ B₃ inst✝³ : HasImage f₃ g₃ : B₃ ⟶ C₃ inst✝² : HasKernel g₃ w₃ : f₃ ≫ g₃ = 0 α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂ inst✝¹ : HasImageMap α₁ β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂ α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃ inst✝ : HasImageMap α₂ β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃ p : α.right = β.left ⊢ imageToKernel f g w ≫ kernelSubobjectMap β = imageSubobjectMap α ≫ imageToKernel f' g' w' [PROOFSTEP] ext [GOAL] case h ι : Type u_1 V : Type u inst✝¹⁴ : Category.{v, u} V inst✝¹³ : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹² : HasImage f g : B ⟶ C inst✝¹¹ : HasKernel g w : f ≫ g = 0 A' B' C' : V f' : A' ⟶ B' inst✝¹⁰ : HasImage f' g' : B' ⟶ C' inst✝⁹ : HasKernel g' w' : f' ≫ g' = 0 α : Arrow.mk f ⟶ Arrow.mk f' inst✝⁸ : HasImageMap α β : Arrow.mk g ⟶ Arrow.mk g' A₁ B₁ C₁ : V f₁ : A₁ ⟶ B₁ inst✝⁷ : HasImage f₁ g₁ : B₁ ⟶ C₁ inst✝⁶ : HasKernel g₁ w₁ : f₁ ≫ g₁ = 0 A₂ B₂ C₂ : V f₂ : A₂ ⟶ B₂ inst✝⁵ : HasImage f₂ g₂ : B₂ ⟶ C₂ inst✝⁴ : HasKernel g₂ w₂ : f₂ ≫ g₂ = 0 A₃ B₃ C₃ : V f₃ : A₃ ⟶ B₃ inst✝³ : HasImage f₃ g₃ : B₃ ⟶ C₃ inst✝² : HasKernel g₃ w₃ : f₃ ≫ g₃ = 0 α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂ inst✝¹ : HasImageMap α₁ β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂ α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃ inst✝ : HasImageMap α₂ β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃ p : α.right = β.left ⊢ (imageToKernel f g w ≫ kernelSubobjectMap β) ≫ Subobject.arrow (kernelSubobject g') = (imageSubobjectMap α ≫ imageToKernel f' g' w') ≫ Subobject.arrow (kernelSubobject g') [PROOFSTEP] simp [p] [GOAL] ι : Type u_1 V : Type u inst✝¹⁹ : Category.{v, u} V inst✝¹⁸ : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹⁷ : HasImage f g : B ⟶ C inst✝¹⁶ : HasKernel g w : f ≫ g = 0 A' B' C' : V f' : A' ⟶ B' inst✝¹⁵ : HasImage f' g' : B' ⟶ C' inst✝¹⁴ : HasKernel g' w' : f' ≫ g' = 0 α : Arrow.mk f ⟶ Arrow.mk f' inst✝¹³ : HasImageMap α β : Arrow.mk g ⟶ Arrow.mk g' A₁ B₁ C₁ : V f₁ : A₁ ⟶ B₁ inst✝¹² : HasImage f₁ g₁ : B₁ ⟶ C₁ inst✝¹¹ : HasKernel g₁ w₁ : f₁ ≫ g₁ = 0 A₂ B₂ C₂ : V f₂ : A₂ ⟶ B₂ inst✝¹⁰ : HasImage f₂ g₂ : B₂ ⟶ C₂ inst✝⁹ : HasKernel g₂ w₂ : f₂ ≫ g₂ = 0 A₃ B₃ C₃ : V f₃ : A₃ ⟶ B₃ inst✝⁸ : HasImage f₃ g₃ : B₃ ⟶ C₃ inst✝⁷ : HasKernel g₃ w₃ : f₃ ≫ g₃ = 0 α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂ inst✝⁶ : HasImageMap α₁ β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂ α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃ inst✝⁵ : HasImageMap α₂ β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃ inst✝⁴ : HasCokernel (imageToKernel f g w) inst✝³ : HasCokernel (imageToKernel f' g' w') inst✝² : HasCokernel (imageToKernel f₁ g₁ w₁) inst✝¹ : HasCokernel (imageToKernel f₂ g₂ w₂) inst✝ : HasCokernel (imageToKernel f₃ g₃ w₃) p : α.right = β.left ⊢ imageToKernel f g w ≫ kernelSubobjectMap β ≫ cokernel.π (imageToKernel f' g' w') = 0 [PROOFSTEP] rw [imageSubobjectMap_comp_imageToKernel_assoc w w' α β p] [GOAL] ι : Type u_1 V : Type u inst✝¹⁹ : Category.{v, u} V inst✝¹⁸ : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹⁷ : HasImage f g : B ⟶ C inst✝¹⁶ : HasKernel g w : f ≫ g = 0 A' B' C' : V f' : A' ⟶ B' inst✝¹⁵ : HasImage f' g' : B' ⟶ C' inst✝¹⁴ : HasKernel g' w' : f' ≫ g' = 0 α : Arrow.mk f ⟶ Arrow.mk f' inst✝¹³ : HasImageMap α β : Arrow.mk g ⟶ Arrow.mk g' A₁ B₁ C₁ : V f₁ : A₁ ⟶ B₁ inst✝¹² : HasImage f₁ g₁ : B₁ ⟶ C₁ inst✝¹¹ : HasKernel g₁ w₁ : f₁ ≫ g₁ = 0 A₂ B₂ C₂ : V f₂ : A₂ ⟶ B₂ inst✝¹⁰ : HasImage f₂ g₂ : B₂ ⟶ C₂ inst✝⁹ : HasKernel g₂ w₂ : f₂ ≫ g₂ = 0 A₃ B₃ C₃ : V f₃ : A₃ ⟶ B₃ inst✝⁸ : HasImage f₃ g₃ : B₃ ⟶ C₃ inst✝⁷ : HasKernel g₃ w₃ : f₃ ≫ g₃ = 0 α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂ inst✝⁶ : HasImageMap α₁ β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂ α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃ inst✝⁵ : HasImageMap α₂ β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃ inst✝⁴ : HasCokernel (imageToKernel f g w) inst✝³ : HasCokernel (imageToKernel f' g' w') inst✝² : HasCokernel (imageToKernel f₁ g₁ w₁) inst✝¹ : HasCokernel (imageToKernel f₂ g₂ w₂) inst✝ : HasCokernel (imageToKernel f₃ g₃ w₃) p : α.right = β.left ⊢ imageSubobjectMap α ≫ imageToKernel f' g' w' ≫ cokernel.π (imageToKernel f' g' w') = 0 [PROOFSTEP] simp only [cokernel.condition, comp_zero] [GOAL] ι : Type u_1 V : Type u inst✝¹⁹ : Category.{v, u} V inst✝¹⁸ : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹⁷ : HasImage f g : B ⟶ C inst✝¹⁶ : HasKernel g w : f ≫ g = 0 A' B' C' : V f' : A' ⟶ B' inst✝¹⁵ : HasImage f' g' : B' ⟶ C' inst✝¹⁴ : HasKernel g' w' : f' ≫ g' = 0 α : Arrow.mk f ⟶ Arrow.mk f' inst✝¹³ : HasImageMap α β : Arrow.mk g ⟶ Arrow.mk g' A₁ B₁ C₁ : V f₁ : A₁ ⟶ B₁ inst✝¹² : HasImage f₁ g₁ : B₁ ⟶ C₁ inst✝¹¹ : HasKernel g₁ w₁ : f₁ ≫ g₁ = 0 A₂ B₂ C₂ : V f₂ : A₂ ⟶ B₂ inst✝¹⁰ : HasImage f₂ g₂ : B₂ ⟶ C₂ inst✝⁹ : HasKernel g₂ w₂ : f₂ ≫ g₂ = 0 A₃ B₃ C₃ : V f₃ : A₃ ⟶ B₃ inst✝⁸ : HasImage f₃ g₃ : B₃ ⟶ C₃ inst✝⁷ : HasKernel g₃ w₃ : f₃ ≫ g₃ = 0 α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂ inst✝⁶ : HasImageMap α₁ β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂ α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃ inst✝⁵ : HasImageMap α₂ β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃ inst✝⁴ : HasCokernel (imageToKernel f g w) inst✝³ : HasCokernel (imageToKernel f' g' w') inst✝² : HasCokernel (imageToKernel f₁ g₁ w₁) inst✝¹ : HasCokernel (imageToKernel f₂ g₂ w₂) inst✝ : HasCokernel (imageToKernel f₃ g₃ w₃) p : α.right = β.left ⊢ π f g w ≫ map w w' α β p = kernelSubobjectMap β ≫ π f' g' w' [PROOFSTEP] simp only [homology.π, homology.map, cokernel.π_desc] [GOAL] ι : Type u_1 V : Type u inst✝²⁰ : Category.{v, u} V inst✝¹⁹ : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹⁸ : HasImage f g : B ⟶ C inst✝¹⁷ : HasKernel g w : f ≫ g = 0 A' B' C' : V f' : A' ⟶ B' inst✝¹⁶ : HasImage f' g' : B' ⟶ C' inst✝¹⁵ : HasKernel g' w' : f' ≫ g' = 0 α : Arrow.mk f ⟶ Arrow.mk f' inst✝¹⁴ : HasImageMap α β : Arrow.mk g ⟶ Arrow.mk g' A₁ B₁ C₁ : V f₁ : A₁ ⟶ B₁ inst✝¹³ : HasImage f₁ g₁ : B₁ ⟶ C₁ inst✝¹² : HasKernel g₁ w₁ : f₁ ≫ g₁ = 0 A₂ B₂ C₂ : V f₂ : A₂ ⟶ B₂ inst✝¹¹ : HasImage f₂ g₂ : B₂ ⟶ C₂ inst✝¹⁰ : HasKernel g₂ w₂ : f₂ ≫ g₂ = 0 A₃ B₃ C₃ : V f₃ : A₃ ⟶ B₃ inst✝⁹ : HasImage f₃ g₃ : B₃ ⟶ C₃ inst✝⁸ : HasKernel g₃ w₃ : f₃ ≫ g₃ = 0 α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂ inst✝⁷ : HasImageMap α₁ β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂ α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃ inst✝⁶ : HasImageMap α₂ β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃ inst✝⁵ : HasCokernel (imageToKernel f g w) inst✝⁴ : HasCokernel (imageToKernel f' g' w') inst✝³ : HasCokernel (imageToKernel f₁ g₁ w₁) inst✝² : HasCokernel (imageToKernel f₂ g₂ w₂) inst✝¹ : HasCokernel (imageToKernel f₃ g₃ w₃) inst✝ : ConcreteCategory V p : α.right = β.left x : (forget V).obj (Subobject.underlying.obj (kernelSubobject g)) ⊢ ↑(map w w' α β p) (↑(π f g w) x) = ↑(π f' g' w') (↑(kernelSubobjectMap β) x) [PROOFSTEP] simp only [← comp_apply, homology.π_map w w' α β p] [GOAL] ι : Type u_1 V : Type u inst✝¹⁹ : Category.{v, u} V inst✝¹⁸ : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹⁷ : HasImage f g : B ⟶ C inst✝¹⁶ : HasKernel g w : f ≫ g = 0 A' B' C' : V f' : A' ⟶ B' inst✝¹⁵ : HasImage f' g' : B' ⟶ C' inst✝¹⁴ : HasKernel g' w' : f' ≫ g' = 0 α : Arrow.mk f ⟶ Arrow.mk f' inst✝¹³ : HasImageMap α β : Arrow.mk g ⟶ Arrow.mk g' A₁ B₁ C₁ : V f₁ : A₁ ⟶ B₁ inst✝¹² : HasImage f₁ g₁ : B₁ ⟶ C₁ inst✝¹¹ : HasKernel g₁ w₁ : f₁ ≫ g₁ = 0 A₂ B₂ C₂ : V f₂ : A₂ ⟶ B₂ inst✝¹⁰ : HasImage f₂ g₂ : B₂ ⟶ C₂ inst✝⁹ : HasKernel g₂ w₂ : f₂ ≫ g₂ = 0 A₃ B₃ C₃ : V f₃ : A₃ ⟶ B₃ inst✝⁸ : HasImage f₃ g₃ : B₃ ⟶ C₃ inst✝⁷ : HasKernel g₃ w₃ : f₃ ≫ g₃ = 0 α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂ inst✝⁶ : HasImageMap α₁ β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂ α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃ inst✝⁵ : HasImageMap α₂ β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃ inst✝⁴ : HasCokernel (imageToKernel f g w) inst✝³ : HasCokernel (imageToKernel f' g' w') inst✝² : HasCokernel (imageToKernel f₁ g₁ w₁) inst✝¹ : HasCokernel (imageToKernel f₂ g₂ w₂) inst✝ : HasCokernel (imageToKernel f₃ g₃ w₃) p : α.right = β.left D : V k : Subobject.underlying.obj (kernelSubobject g') ⟶ D z : imageToKernel f' g' w' ≫ k = 0 ⊢ imageToKernel f g w ≫ kernelSubobjectMap β ≫ k = 0 [PROOFSTEP] simp only [imageSubobjectMap_comp_imageToKernel_assoc w w' α β p, z, comp_zero] [GOAL] ι : Type u_1 V : Type u inst✝¹⁹ : Category.{v, u} V inst✝¹⁸ : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹⁷ : HasImage f g : B ⟶ C inst✝¹⁶ : HasKernel g w : f ≫ g = 0 A' B' C' : V f' : A' ⟶ B' inst✝¹⁵ : HasImage f' g' : B' ⟶ C' inst✝¹⁴ : HasKernel g' w' : f' ≫ g' = 0 α : Arrow.mk f ⟶ Arrow.mk f' inst✝¹³ : HasImageMap α β : Arrow.mk g ⟶ Arrow.mk g' A₁ B₁ C₁ : V f₁ : A₁ ⟶ B₁ inst✝¹² : HasImage f₁ g₁ : B₁ ⟶ C₁ inst✝¹¹ : HasKernel g₁ w₁ : f₁ ≫ g₁ = 0 A₂ B₂ C₂ : V f₂ : A₂ ⟶ B₂ inst✝¹⁰ : HasImage f₂ g₂ : B₂ ⟶ C₂ inst✝⁹ : HasKernel g₂ w₂ : f₂ ≫ g₂ = 0 A₃ B₃ C₃ : V f₃ : A₃ ⟶ B₃ inst✝⁸ : HasImage f₃ g₃ : B₃ ⟶ C₃ inst✝⁷ : HasKernel g₃ w₃ : f₃ ≫ g₃ = 0 α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂ inst✝⁶ : HasImageMap α₁ β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂ α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃ inst✝⁵ : HasImageMap α₂ β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃ inst✝⁴ : HasCokernel (imageToKernel f g w) inst✝³ : HasCokernel (imageToKernel f' g' w') inst✝² : HasCokernel (imageToKernel f₁ g₁ w₁) inst✝¹ : HasCokernel (imageToKernel f₂ g₂ w₂) inst✝ : HasCokernel (imageToKernel f₃ g₃ w₃) p : α.right = β.left D : V k : Subobject.underlying.obj (kernelSubobject g') ⟶ D z : imageToKernel f' g' w' ≫ k = 0 ⊢ map w w' α β p ≫ desc f' g' w' k z = desc f g w (kernelSubobjectMap β ≫ k) (_ : imageToKernel f g w ≫ kernelSubobjectMap β ≫ k = 0) [PROOFSTEP] ext [GOAL] case p ι : Type u_1 V : Type u inst✝¹⁹ : Category.{v, u} V inst✝¹⁸ : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹⁷ : HasImage f g : B ⟶ C inst✝¹⁶ : HasKernel g w : f ≫ g = 0 A' B' C' : V f' : A' ⟶ B' inst✝¹⁵ : HasImage f' g' : B' ⟶ C' inst✝¹⁴ : HasKernel g' w' : f' ≫ g' = 0 α : Arrow.mk f ⟶ Arrow.mk f' inst✝¹³ : HasImageMap α β : Arrow.mk g ⟶ Arrow.mk g' A₁ B₁ C₁ : V f₁ : A₁ ⟶ B₁ inst✝¹² : HasImage f₁ g₁ : B₁ ⟶ C₁ inst✝¹¹ : HasKernel g₁ w₁ : f₁ ≫ g₁ = 0 A₂ B₂ C₂ : V f₂ : A₂ ⟶ B₂ inst✝¹⁰ : HasImage f₂ g₂ : B₂ ⟶ C₂ inst✝⁹ : HasKernel g₂ w₂ : f₂ ≫ g₂ = 0 A₃ B₃ C₃ : V f₃ : A₃ ⟶ B₃ inst✝⁸ : HasImage f₃ g₃ : B₃ ⟶ C₃ inst✝⁷ : HasKernel g₃ w₃ : f₃ ≫ g₃ = 0 α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂ inst✝⁶ : HasImageMap α₁ β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂ α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃ inst✝⁵ : HasImageMap α₂ β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃ inst✝⁴ : HasCokernel (imageToKernel f g w) inst✝³ : HasCokernel (imageToKernel f' g' w') inst✝² : HasCokernel (imageToKernel f₁ g₁ w₁) inst✝¹ : HasCokernel (imageToKernel f₂ g₂ w₂) inst✝ : HasCokernel (imageToKernel f₃ g₃ w₃) p : α.right = β.left D : V k : Subobject.underlying.obj (kernelSubobject g') ⟶ D z : imageToKernel f' g' w' ≫ k = 0 ⊢ π f g w ≫ map w w' α β p ≫ desc f' g' w' k z = π f g w ≫ desc f g w (kernelSubobjectMap β ≫ k) (_ : imageToKernel f g w ≫ kernelSubobjectMap β ≫ k = 0) [PROOFSTEP] simp only [homology.π_desc, homology.π_map_assoc] [GOAL] ι : Type u_1 V : Type u inst✝¹⁹ : Category.{v, u} V inst✝¹⁸ : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹⁷ : HasImage f g : B ⟶ C inst✝¹⁶ : HasKernel g w : f ≫ g = 0 A' B' C' : V f' : A' ⟶ B' inst✝¹⁵ : HasImage f' g' : B' ⟶ C' inst✝¹⁴ : HasKernel g' w' : f' ≫ g' = 0 α : Arrow.mk f ⟶ Arrow.mk f' inst✝¹³ : HasImageMap α β : Arrow.mk g ⟶ Arrow.mk g' A₁ B₁ C₁ : V f₁ : A₁ ⟶ B₁ inst✝¹² : HasImage f₁ g₁ : B₁ ⟶ C₁ inst✝¹¹ : HasKernel g₁ w₁ : f₁ ≫ g₁ = 0 A₂ B₂ C₂ : V f₂ : A₂ ⟶ B₂ inst✝¹⁰ : HasImage f₂ g₂ : B₂ ⟶ C₂ inst✝⁹ : HasKernel g₂ w₂ : f₂ ≫ g₂ = 0 A₃ B₃ C₃ : V f₃ : A₃ ⟶ B₃ inst✝⁸ : HasImage f₃ g₃ : B₃ ⟶ C₃ inst✝⁷ : HasKernel g₃ w₃ : f₃ ≫ g₃ = 0 α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂ inst✝⁶ : HasImageMap α₁ β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂ α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃ inst✝⁵ : HasImageMap α₂ β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃ inst✝⁴ : HasCokernel (imageToKernel f g w) inst✝³ : HasCokernel (imageToKernel f' g' w') inst✝² : HasCokernel (imageToKernel f₁ g₁ w₁) inst✝¹ : HasCokernel (imageToKernel f₂ g₂ w₂) inst✝ : HasCokernel (imageToKernel f₃ g₃ w₃) ⊢ map w w (𝟙 (Arrow.mk f)) (𝟙 (Arrow.mk g)) (_ : (𝟙 (Arrow.mk f)).right = (𝟙 (Arrow.mk f)).right) = 𝟙 (homology f g w) [PROOFSTEP] ext [GOAL] case p ι : Type u_1 V : Type u inst✝¹⁹ : Category.{v, u} V inst✝¹⁸ : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹⁷ : HasImage f g : B ⟶ C inst✝¹⁶ : HasKernel g w : f ≫ g = 0 A' B' C' : V f' : A' ⟶ B' inst✝¹⁵ : HasImage f' g' : B' ⟶ C' inst✝¹⁴ : HasKernel g' w' : f' ≫ g' = 0 α : Arrow.mk f ⟶ Arrow.mk f' inst✝¹³ : HasImageMap α β : Arrow.mk g ⟶ Arrow.mk g' A₁ B₁ C₁ : V f₁ : A₁ ⟶ B₁ inst✝¹² : HasImage f₁ g₁ : B₁ ⟶ C₁ inst✝¹¹ : HasKernel g₁ w₁ : f₁ ≫ g₁ = 0 A₂ B₂ C₂ : V f₂ : A₂ ⟶ B₂ inst✝¹⁰ : HasImage f₂ g₂ : B₂ ⟶ C₂ inst✝⁹ : HasKernel g₂ w₂ : f₂ ≫ g₂ = 0 A₃ B₃ C₃ : V f₃ : A₃ ⟶ B₃ inst✝⁸ : HasImage f₃ g₃ : B₃ ⟶ C₃ inst✝⁷ : HasKernel g₃ w₃ : f₃ ≫ g₃ = 0 α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂ inst✝⁶ : HasImageMap α₁ β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂ α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃ inst✝⁵ : HasImageMap α₂ β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃ inst✝⁴ : HasCokernel (imageToKernel f g w) inst✝³ : HasCokernel (imageToKernel f' g' w') inst✝² : HasCokernel (imageToKernel f₁ g₁ w₁) inst✝¹ : HasCokernel (imageToKernel f₂ g₂ w₂) inst✝ : HasCokernel (imageToKernel f₃ g₃ w₃) ⊢ π f g w ≫ map w w (𝟙 (Arrow.mk f)) (𝟙 (Arrow.mk g)) (_ : (𝟙 (Arrow.mk f)).right = (𝟙 (Arrow.mk f)).right) = π f g w ≫ 𝟙 (homology f g w) [PROOFSTEP] simp only [homology.π_map, kernelSubobjectMap_id, Category.id_comp, Category.comp_id] [GOAL] ι : Type u_1 V✝ : Type u inst✝²⁰ : Category.{v, u} V✝ inst✝¹⁹ : HasZeroMorphisms V✝ A B C : V✝ f : A ⟶ B inst✝¹⁸ : HasImage f g : B ⟶ C inst✝¹⁷ : HasKernel g w : f ≫ g = 0 A' B' C' : V✝ f' : A' ⟶ B' inst✝¹⁶ : HasImage f' g' : B' ⟶ C' inst✝¹⁵ : HasKernel g' w' : f' ≫ g' = 0 α : Arrow.mk f ⟶ Arrow.mk f' inst✝¹⁴ : HasImageMap α β : Arrow.mk g ⟶ Arrow.mk g' A₁✝ B₁✝ C₁✝ : V✝ f₁✝ : A₁✝ ⟶ B₁✝ inst✝¹³ : HasImage f₁✝ g₁✝ : B₁✝ ⟶ C₁✝ inst✝¹² : HasKernel g₁✝ w₁ : f₁✝ ≫ g₁✝ = 0 A₂✝ B₂✝ C₂✝ : V✝ f₂✝ : A₂✝ ⟶ B₂✝ inst✝¹¹ : HasImage f₂✝ g₂✝ : B₂✝ ⟶ C₂✝ inst✝¹⁰ : HasKernel g₂✝ w₂ : f₂✝ ≫ g₂✝ = 0 A₃✝ B₃✝ C₃✝ : V✝ f₃✝ : A₃✝ ⟶ B₃✝ inst✝⁹ : HasImage f₃✝ g₃✝ : B₃✝ ⟶ C₃✝ inst✝⁸ : HasKernel g₃✝ w₃ : f₃✝ ≫ g₃✝ = 0 α₁✝ : Arrow.mk f₁✝ ⟶ Arrow.mk f₂✝ inst✝⁷ : HasImageMap α₁✝ β₁✝ : Arrow.mk g₁✝ ⟶ Arrow.mk g₂✝ α₂✝ : Arrow.mk f₂✝ ⟶ Arrow.mk f₃✝ inst✝⁶ : HasImageMap α₂✝ β₂✝ : Arrow.mk g₂✝ ⟶ Arrow.mk g₃✝ inst✝⁵ : HasCokernel (imageToKernel f g w) inst✝⁴ : HasCokernel (imageToKernel f' g' w') inst✝³ : HasCokernel (imageToKernel f₁✝ g₁✝ w₁) inst✝² : HasCokernel (imageToKernel f₂✝ g₂✝ w₂) inst✝¹ : HasCokernel (imageToKernel f₃✝ g₃✝ w₃) V : Type u_2 inst✝ : Category.{u_3, u_2} V A₁ B₁ C₁ A₂ B₂ C₂ A₃ B₃ C₃ : V f₁ : A₁ ⟶ B₁ g₁ : B₁ ⟶ C₁ f₂ : A₂ ⟶ B₂ g₂ : B₂ ⟶ C₂ f₃ : A₃ ⟶ B₃ g₃ : B₃ ⟶ C₃ α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂ β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂ α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃ β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃ p₁ : α₁.right = β₁.left p₂ : α₂.right = β₂.left ⊢ (α₁ ≫ α₂).right = (β₁ ≫ β₂).left [PROOFSTEP] simp only [Arrow.comp_left, Arrow.comp_right, p₁, p₂] [GOAL] ι : Type u_1 V : Type u inst✝¹⁹ : Category.{v, u} V inst✝¹⁸ : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹⁷ : HasImage f g : B ⟶ C inst✝¹⁶ : HasKernel g w : f ≫ g = 0 A' B' C' : V f' : A' ⟶ B' inst✝¹⁵ : HasImage f' g' : B' ⟶ C' inst✝¹⁴ : HasKernel g' w' : f' ≫ g' = 0 α : Arrow.mk f ⟶ Arrow.mk f' inst✝¹³ : HasImageMap α β : Arrow.mk g ⟶ Arrow.mk g' A₁ B₁ C₁ : V f₁ : A₁ ⟶ B₁ inst✝¹² : HasImage f₁ g₁ : B₁ ⟶ C₁ inst✝¹¹ : HasKernel g₁ w₁ : f₁ ≫ g₁ = 0 A₂ B₂ C₂ : V f₂ : A₂ ⟶ B₂ inst✝¹⁰ : HasImage f₂ g₂ : B₂ ⟶ C₂ inst✝⁹ : HasKernel g₂ w₂ : f₂ ≫ g₂ = 0 A₃ B₃ C₃ : V f₃ : A₃ ⟶ B₃ inst✝⁸ : HasImage f₃ g₃ : B₃ ⟶ C₃ inst✝⁷ : HasKernel g₃ w₃ : f₃ ≫ g₃ = 0 α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂ inst✝⁶ : HasImageMap α₁ β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂ α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃ inst✝⁵ : HasImageMap α₂ β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃ inst✝⁴ : HasCokernel (imageToKernel f g w) inst✝³ : HasCokernel (imageToKernel f' g' w') inst✝² : HasCokernel (imageToKernel f₁ g₁ w₁) inst✝¹ : HasCokernel (imageToKernel f₂ g₂ w₂) inst✝ : HasCokernel (imageToKernel f₃ g₃ w₃) p₁ : α₁.right = β₁.left p₂ : α₂.right = β₂.left ⊢ map w₁ w₂ α₁ β₁ p₁ ≫ map w₂ w₃ α₂ β₂ p₂ = map w₁ w₃ (α₁ ≫ α₂) (β₁ ≫ β₂) (_ : (α₁ ≫ α₂).right = (β₁ ≫ β₂).left) [PROOFSTEP] ext [GOAL] case p ι : Type u_1 V : Type u inst✝¹⁹ : Category.{v, u} V inst✝¹⁸ : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹⁷ : HasImage f g : B ⟶ C inst✝¹⁶ : HasKernel g w : f ≫ g = 0 A' B' C' : V f' : A' ⟶ B' inst✝¹⁵ : HasImage f' g' : B' ⟶ C' inst✝¹⁴ : HasKernel g' w' : f' ≫ g' = 0 α : Arrow.mk f ⟶ Arrow.mk f' inst✝¹³ : HasImageMap α β : Arrow.mk g ⟶ Arrow.mk g' A₁ B₁ C₁ : V f₁ : A₁ ⟶ B₁ inst✝¹² : HasImage f₁ g₁ : B₁ ⟶ C₁ inst✝¹¹ : HasKernel g₁ w₁ : f₁ ≫ g₁ = 0 A₂ B₂ C₂ : V f₂ : A₂ ⟶ B₂ inst✝¹⁰ : HasImage f₂ g₂ : B₂ ⟶ C₂ inst✝⁹ : HasKernel g₂ w₂ : f₂ ≫ g₂ = 0 A₃ B₃ C₃ : V f₃ : A₃ ⟶ B₃ inst✝⁸ : HasImage f₃ g₃ : B₃ ⟶ C₃ inst✝⁷ : HasKernel g₃ w₃ : f₃ ≫ g₃ = 0 α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂ inst✝⁶ : HasImageMap α₁ β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂ α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃ inst✝⁵ : HasImageMap α₂ β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃ inst✝⁴ : HasCokernel (imageToKernel f g w) inst✝³ : HasCokernel (imageToKernel f' g' w') inst✝² : HasCokernel (imageToKernel f₁ g₁ w₁) inst✝¹ : HasCokernel (imageToKernel f₂ g₂ w₂) inst✝ : HasCokernel (imageToKernel f₃ g₃ w₃) p₁ : α₁.right = β₁.left p₂ : α₂.right = β₂.left ⊢ π f₁ g₁ w₁ ≫ map w₁ w₂ α₁ β₁ p₁ ≫ map w₂ w₃ α₂ β₂ p₂ = π f₁ g₁ w₁ ≫ map w₁ w₃ (α₁ ≫ α₂) (β₁ ≫ β₂) (_ : (α₁ ≫ α₂).right = (β₁ ≫ β₂).left) [PROOFSTEP] simp only [kernelSubobjectMap_comp, homology.π_map_assoc, homology.π_map, Category.assoc] [GOAL] ι : Type u_1 V : Type u inst✝¹⁹ : Category.{v, u} V inst✝¹⁸ : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹⁷ : HasImage f g : B ⟶ C inst✝¹⁶ : HasKernel g w : f ≫ g = 0 A' B' C' : V f' : A' ⟶ B' inst✝¹⁵ : HasImage f' g' : B' ⟶ C' inst✝¹⁴ : HasKernel g' w' : f' ≫ g' = 0 α✝ : Arrow.mk f ⟶ Arrow.mk f' inst✝¹³ : HasImageMap α✝ β✝ : Arrow.mk g ⟶ Arrow.mk g' A₁ B₁ C₁ : V f₁ : A₁ ⟶ B₁ inst✝¹² : HasImage f₁ g₁ : B₁ ⟶ C₁ inst✝¹¹ : HasKernel g₁ w₁ : f₁ ≫ g₁ = 0 A₂ B₂ C₂ : V f₂ : A₂ ⟶ B₂ inst✝¹⁰ : HasImage f₂ g₂ : B₂ ⟶ C₂ inst✝⁹ : HasKernel g₂ w₂ : f₂ ≫ g₂ = 0 A₃ B₃ C₃ : V f₃ : A₃ ⟶ B₃ inst✝⁸ : HasImage f₃ g₃ : B₃ ⟶ C₃ inst✝⁷ : HasKernel g₃ w₃ : f₃ ≫ g₃ = 0 α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂ inst✝⁶ : HasImageMap α₁ β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂ α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃ inst✝⁵ : HasImageMap α₂ β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃ inst✝⁴ : HasCokernel (imageToKernel f g w) inst✝³ : HasCokernel (imageToKernel f' g' w') inst✝² : HasCokernel (imageToKernel f₁ g₁ w₁) inst✝¹ : HasCokernel (imageToKernel f₂ g₂ w₂) inst✝ : HasCokernel (imageToKernel f₃ g₃ w₃) α : Arrow.mk f₁ ≅ Arrow.mk f₂ β : Arrow.mk g₁ ≅ Arrow.mk g₂ p : α.hom.right = β.hom.left ⊢ α.inv.right = β.inv.left [PROOFSTEP] rw [← cancel_mono α.hom.right, ← Comma.comp_right, α.inv_hom_id, Comma.id_right, p, ← Comma.comp_left, β.inv_hom_id, Comma.id_left] [GOAL] ι : Type u_1 V : Type u inst✝¹⁹ : Category.{v, u} V inst✝¹⁸ : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹⁷ : HasImage f g : B ⟶ C inst✝¹⁶ : HasKernel g w : f ≫ g = 0 A' B' C' : V f' : A' ⟶ B' inst✝¹⁵ : HasImage f' g' : B' ⟶ C' inst✝¹⁴ : HasKernel g' w' : f' ≫ g' = 0 α✝ : Arrow.mk f ⟶ Arrow.mk f' inst✝¹³ : HasImageMap α✝ β✝ : Arrow.mk g ⟶ Arrow.mk g' A₁ B₁ C₁ : V f₁ : A₁ ⟶ B₁ inst✝¹² : HasImage f₁ g₁ : B₁ ⟶ C₁ inst✝¹¹ : HasKernel g₁ w₁ : f₁ ≫ g₁ = 0 A₂ B₂ C₂ : V f₂ : A₂ ⟶ B₂ inst✝¹⁰ : HasImage f₂ g₂ : B₂ ⟶ C₂ inst✝⁹ : HasKernel g₂ w₂ : f₂ ≫ g₂ = 0 A₃ B₃ C₃ : V f₃ : A₃ ⟶ B₃ inst✝⁸ : HasImage f₃ g₃ : B₃ ⟶ C₃ inst✝⁷ : HasKernel g₃ w₃ : f₃ ≫ g₃ = 0 α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂ inst✝⁶ : HasImageMap α₁ β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂ α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃ inst✝⁵ : HasImageMap α₂ β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃ inst✝⁴ : HasCokernel (imageToKernel f g w) inst✝³ : HasCokernel (imageToKernel f' g' w') inst✝² : HasCokernel (imageToKernel f₁ g₁ w₁) inst✝¹ : HasCokernel (imageToKernel f₂ g₂ w₂) inst✝ : HasCokernel (imageToKernel f₃ g₃ w₃) α : Arrow.mk f₁ ≅ Arrow.mk f₂ β : Arrow.mk g₁ ≅ Arrow.mk g₂ p : α.hom.right = β.hom.left ⊢ 𝟙 (Arrow.mk f₂).right = 𝟙 (Arrow.mk g₂).left [PROOFSTEP] rfl [GOAL] ι : Type u_1 V : Type u inst✝¹⁹ : Category.{v, u} V inst✝¹⁸ : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹⁷ : HasImage f g : B ⟶ C inst✝¹⁶ : HasKernel g w : f ≫ g = 0 A' B' C' : V f' : A' ⟶ B' inst✝¹⁵ : HasImage f' g' : B' ⟶ C' inst✝¹⁴ : HasKernel g' w' : f' ≫ g' = 0 α✝ : Arrow.mk f ⟶ Arrow.mk f' inst✝¹³ : HasImageMap α✝ β✝ : Arrow.mk g ⟶ Arrow.mk g' A₁ B₁ C₁ : V f₁ : A₁ ⟶ B₁ inst✝¹² : HasImage f₁ g₁ : B₁ ⟶ C₁ inst✝¹¹ : HasKernel g₁ w₁ : f₁ ≫ g₁ = 0 A₂ B₂ C₂ : V f₂ : A₂ ⟶ B₂ inst✝¹⁰ : HasImage f₂ g₂ : B₂ ⟶ C₂ inst✝⁹ : HasKernel g₂ w₂ : f₂ ≫ g₂ = 0 A₃ B₃ C₃ : V f₃ : A₃ ⟶ B₃ inst✝⁸ : HasImage f₃ g₃ : B₃ ⟶ C₃ inst✝⁷ : HasKernel g₃ w₃ : f₃ ≫ g₃ = 0 α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂ inst✝⁶ : HasImageMap α₁ β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂ α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃ inst✝⁵ : HasImageMap α₂ β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃ inst✝⁴ : HasCokernel (imageToKernel f g w) inst✝³ : HasCokernel (imageToKernel f' g' w') inst✝² : HasCokernel (imageToKernel f₁ g₁ w₁) inst✝¹ : HasCokernel (imageToKernel f₂ g₂ w₂) inst✝ : HasCokernel (imageToKernel f₃ g₃ w₃) α : Arrow.mk f₁ ≅ Arrow.mk f₂ β : Arrow.mk g₁ ≅ Arrow.mk g₂ p : α.hom.right = β.hom.left ⊢ map w₁ w₂ α.hom β.hom p ≫ map w₂ w₁ α.inv β.inv (_ : α.inv.right = β.inv.left) = 𝟙 (homology f₁ g₁ w₁) [PROOFSTEP] rw [homology.map_comp, ← homology.map_id] [GOAL] ι : Type u_1 V : Type u inst✝¹⁹ : Category.{v, u} V inst✝¹⁸ : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹⁷ : HasImage f g : B ⟶ C inst✝¹⁶ : HasKernel g w : f ≫ g = 0 A' B' C' : V f' : A' ⟶ B' inst✝¹⁵ : HasImage f' g' : B' ⟶ C' inst✝¹⁴ : HasKernel g' w' : f' ≫ g' = 0 α✝ : Arrow.mk f ⟶ Arrow.mk f' inst✝¹³ : HasImageMap α✝ β✝ : Arrow.mk g ⟶ Arrow.mk g' A₁ B₁ C₁ : V f₁ : A₁ ⟶ B₁ inst✝¹² : HasImage f₁ g₁ : B₁ ⟶ C₁ inst✝¹¹ : HasKernel g₁ w₁ : f₁ ≫ g₁ = 0 A₂ B₂ C₂ : V f₂ : A₂ ⟶ B₂ inst✝¹⁰ : HasImage f₂ g₂ : B₂ ⟶ C₂ inst✝⁹ : HasKernel g₂ w₂ : f₂ ≫ g₂ = 0 A₃ B₃ C₃ : V f₃ : A₃ ⟶ B₃ inst✝⁸ : HasImage f₃ g₃ : B₃ ⟶ C₃ inst✝⁷ : HasKernel g₃ w₃ : f₃ ≫ g₃ = 0 α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂ inst✝⁶ : HasImageMap α₁ β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂ α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃ inst✝⁵ : HasImageMap α₂ β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃ inst✝⁴ : HasCokernel (imageToKernel f g w) inst✝³ : HasCokernel (imageToKernel f' g' w') inst✝² : HasCokernel (imageToKernel f₁ g₁ w₁) inst✝¹ : HasCokernel (imageToKernel f₂ g₂ w₂) inst✝ : HasCokernel (imageToKernel f₃ g₃ w₃) α : Arrow.mk f₁ ≅ Arrow.mk f₂ β : Arrow.mk g₁ ≅ Arrow.mk g₂ p : α.hom.right = β.hom.left ⊢ map w₁ w₁ (α.hom ≫ α.inv) (β.hom ≫ β.inv) (_ : (α.hom ≫ α.inv).right = (β.hom ≫ β.inv).left) = map w₁ w₁ (𝟙 (Arrow.mk f₁)) (𝟙 (Arrow.mk g₁)) (_ : (𝟙 (Arrow.mk f₁)).right = (𝟙 (Arrow.mk f₁)).right) [PROOFSTEP] congr [GOAL] case e_α ι : Type u_1 V : Type u inst✝¹⁹ : Category.{v, u} V inst✝¹⁸ : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹⁷ : HasImage f g : B ⟶ C inst✝¹⁶ : HasKernel g w : f ≫ g = 0 A' B' C' : V f' : A' ⟶ B' inst✝¹⁵ : HasImage f' g' : B' ⟶ C' inst✝¹⁴ : HasKernel g' w' : f' ≫ g' = 0 α✝ : Arrow.mk f ⟶ Arrow.mk f' inst✝¹³ : HasImageMap α✝ β✝ : Arrow.mk g ⟶ Arrow.mk g' A₁ B₁ C₁ : V f₁ : A₁ ⟶ B₁ inst✝¹² : HasImage f₁ g₁ : B₁ ⟶ C₁ inst✝¹¹ : HasKernel g₁ w₁ : f₁ ≫ g₁ = 0 A₂ B₂ C₂ : V f₂ : A₂ ⟶ B₂ inst✝¹⁰ : HasImage f₂ g₂ : B₂ ⟶ C₂ inst✝⁹ : HasKernel g₂ w₂ : f₂ ≫ g₂ = 0 A₃ B₃ C₃ : V f₃ : A₃ ⟶ B₃ inst✝⁸ : HasImage f₃ g₃ : B₃ ⟶ C₃ inst✝⁷ : HasKernel g₃ w₃ : f₃ ≫ g₃ = 0 α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂ inst✝⁶ : HasImageMap α₁ β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂ α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃ inst✝⁵ : HasImageMap α₂ β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃ inst✝⁴ : HasCokernel (imageToKernel f g w) inst✝³ : HasCokernel (imageToKernel f' g' w') inst✝² : HasCokernel (imageToKernel f₁ g₁ w₁) inst✝¹ : HasCokernel (imageToKernel f₂ g₂ w₂) inst✝ : HasCokernel (imageToKernel f₃ g₃ w₃) α : Arrow.mk f₁ ≅ Arrow.mk f₂ β : Arrow.mk g₁ ≅ Arrow.mk g₂ p : α.hom.right = β.hom.left ⊢ α.hom ≫ α.inv = 𝟙 (Arrow.mk f₁) [PROOFSTEP] simp only [Iso.hom_inv_id] [GOAL] case e_β ι : Type u_1 V : Type u inst✝¹⁹ : Category.{v, u} V inst✝¹⁸ : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹⁷ : HasImage f g : B ⟶ C inst✝¹⁶ : HasKernel g w : f ≫ g = 0 A' B' C' : V f' : A' ⟶ B' inst✝¹⁵ : HasImage f' g' : B' ⟶ C' inst✝¹⁴ : HasKernel g' w' : f' ≫ g' = 0 α✝ : Arrow.mk f ⟶ Arrow.mk f' inst✝¹³ : HasImageMap α✝ β✝ : Arrow.mk g ⟶ Arrow.mk g' A₁ B₁ C₁ : V f₁ : A₁ ⟶ B₁ inst✝¹² : HasImage f₁ g₁ : B₁ ⟶ C₁ inst✝¹¹ : HasKernel g₁ w₁ : f₁ ≫ g₁ = 0 A₂ B₂ C₂ : V f₂ : A₂ ⟶ B₂ inst✝¹⁰ : HasImage f₂ g₂ : B₂ ⟶ C₂ inst✝⁹ : HasKernel g₂ w₂ : f₂ ≫ g₂ = 0 A₃ B₃ C₃ : V f₃ : A₃ ⟶ B₃ inst✝⁸ : HasImage f₃ g₃ : B₃ ⟶ C₃ inst✝⁷ : HasKernel g₃ w₃ : f₃ ≫ g₃ = 0 α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂ inst✝⁶ : HasImageMap α₁ β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂ α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃ inst✝⁵ : HasImageMap α₂ β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃ inst✝⁴ : HasCokernel (imageToKernel f g w) inst✝³ : HasCokernel (imageToKernel f' g' w') inst✝² : HasCokernel (imageToKernel f₁ g₁ w₁) inst✝¹ : HasCokernel (imageToKernel f₂ g₂ w₂) inst✝ : HasCokernel (imageToKernel f₃ g₃ w₃) α : Arrow.mk f₁ ≅ Arrow.mk f₂ β : Arrow.mk g₁ ≅ Arrow.mk g₂ p : α.hom.right = β.hom.left ⊢ β.hom ≫ β.inv = 𝟙 (Arrow.mk g₁) [PROOFSTEP] simp only [Iso.hom_inv_id] [GOAL] ι : Type u_1 V : Type u inst✝¹⁹ : Category.{v, u} V inst✝¹⁸ : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹⁷ : HasImage f g : B ⟶ C inst✝¹⁶ : HasKernel g w : f ≫ g = 0 A' B' C' : V f' : A' ⟶ B' inst✝¹⁵ : HasImage f' g' : B' ⟶ C' inst✝¹⁴ : HasKernel g' w' : f' ≫ g' = 0 α✝ : Arrow.mk f ⟶ Arrow.mk f' inst✝¹³ : HasImageMap α✝ β✝ : Arrow.mk g ⟶ Arrow.mk g' A₁ B₁ C₁ : V f₁ : A₁ ⟶ B₁ inst✝¹² : HasImage f₁ g₁ : B₁ ⟶ C₁ inst✝¹¹ : HasKernel g₁ w₁ : f₁ ≫ g₁ = 0 A₂ B₂ C₂ : V f₂ : A₂ ⟶ B₂ inst✝¹⁰ : HasImage f₂ g₂ : B₂ ⟶ C₂ inst✝⁹ : HasKernel g₂ w₂ : f₂ ≫ g₂ = 0 A₃ B₃ C₃ : V f₃ : A₃ ⟶ B₃ inst✝⁸ : HasImage f₃ g₃ : B₃ ⟶ C₃ inst✝⁷ : HasKernel g₃ w₃ : f₃ ≫ g₃ = 0 α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂ inst✝⁶ : HasImageMap α₁ β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂ α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃ inst✝⁵ : HasImageMap α₂ β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃ inst✝⁴ : HasCokernel (imageToKernel f g w) inst✝³ : HasCokernel (imageToKernel f' g' w') inst✝² : HasCokernel (imageToKernel f₁ g₁ w₁) inst✝¹ : HasCokernel (imageToKernel f₂ g₂ w₂) inst✝ : HasCokernel (imageToKernel f₃ g₃ w₃) α : Arrow.mk f₁ ≅ Arrow.mk f₂ β : Arrow.mk g₁ ≅ Arrow.mk g₂ p : α.hom.right = β.hom.left ⊢ map w₂ w₁ α.inv β.inv (_ : α.inv.right = β.inv.left) ≫ map w₁ w₂ α.hom β.hom p = 𝟙 (homology f₂ g₂ w₂) [PROOFSTEP] rw [homology.map_comp, ← homology.map_id] [GOAL] ι : Type u_1 V : Type u inst✝¹⁹ : Category.{v, u} V inst✝¹⁸ : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹⁷ : HasImage f g : B ⟶ C inst✝¹⁶ : HasKernel g w : f ≫ g = 0 A' B' C' : V f' : A' ⟶ B' inst✝¹⁵ : HasImage f' g' : B' ⟶ C' inst✝¹⁴ : HasKernel g' w' : f' ≫ g' = 0 α✝ : Arrow.mk f ⟶ Arrow.mk f' inst✝¹³ : HasImageMap α✝ β✝ : Arrow.mk g ⟶ Arrow.mk g' A₁ B₁ C₁ : V f₁ : A₁ ⟶ B₁ inst✝¹² : HasImage f₁ g₁ : B₁ ⟶ C₁ inst✝¹¹ : HasKernel g₁ w₁ : f₁ ≫ g₁ = 0 A₂ B₂ C₂ : V f₂ : A₂ ⟶ B₂ inst✝¹⁰ : HasImage f₂ g₂ : B₂ ⟶ C₂ inst✝⁹ : HasKernel g₂ w₂ : f₂ ≫ g₂ = 0 A₃ B₃ C₃ : V f₃ : A₃ ⟶ B₃ inst✝⁸ : HasImage f₃ g₃ : B₃ ⟶ C₃ inst✝⁷ : HasKernel g₃ w₃ : f₃ ≫ g₃ = 0 α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂ inst✝⁶ : HasImageMap α₁ β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂ α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃ inst✝⁵ : HasImageMap α₂ β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃ inst✝⁴ : HasCokernel (imageToKernel f g w) inst✝³ : HasCokernel (imageToKernel f' g' w') inst✝² : HasCokernel (imageToKernel f₁ g₁ w₁) inst✝¹ : HasCokernel (imageToKernel f₂ g₂ w₂) inst✝ : HasCokernel (imageToKernel f₃ g₃ w₃) α : Arrow.mk f₁ ≅ Arrow.mk f₂ β : Arrow.mk g₁ ≅ Arrow.mk g₂ p : α.hom.right = β.hom.left ⊢ map w₂ w₂ (α.inv ≫ α.hom) (β.inv ≫ β.hom) (_ : (α.inv ≫ α.hom).right = (β.inv ≫ β.hom).left) = map w₂ w₂ (𝟙 (Arrow.mk f₂)) (𝟙 (Arrow.mk g₂)) (_ : (𝟙 (Arrow.mk f₂)).right = (𝟙 (Arrow.mk f₂)).right) [PROOFSTEP] congr [GOAL] case e_α ι : Type u_1 V : Type u inst✝¹⁹ : Category.{v, u} V inst✝¹⁸ : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹⁷ : HasImage f g : B ⟶ C inst✝¹⁶ : HasKernel g w : f ≫ g = 0 A' B' C' : V f' : A' ⟶ B' inst✝¹⁵ : HasImage f' g' : B' ⟶ C' inst✝¹⁴ : HasKernel g' w' : f' ≫ g' = 0 α✝ : Arrow.mk f ⟶ Arrow.mk f' inst✝¹³ : HasImageMap α✝ β✝ : Arrow.mk g ⟶ Arrow.mk g' A₁ B₁ C₁ : V f₁ : A₁ ⟶ B₁ inst✝¹² : HasImage f₁ g₁ : B₁ ⟶ C₁ inst✝¹¹ : HasKernel g₁ w₁ : f₁ ≫ g₁ = 0 A₂ B₂ C₂ : V f₂ : A₂ ⟶ B₂ inst✝¹⁰ : HasImage f₂ g₂ : B₂ ⟶ C₂ inst✝⁹ : HasKernel g₂ w₂ : f₂ ≫ g₂ = 0 A₃ B₃ C₃ : V f₃ : A₃ ⟶ B₃ inst✝⁸ : HasImage f₃ g₃ : B₃ ⟶ C₃ inst✝⁷ : HasKernel g₃ w₃ : f₃ ≫ g₃ = 0 α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂ inst✝⁶ : HasImageMap α₁ β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂ α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃ inst✝⁵ : HasImageMap α₂ β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃ inst✝⁴ : HasCokernel (imageToKernel f g w) inst✝³ : HasCokernel (imageToKernel f' g' w') inst✝² : HasCokernel (imageToKernel f₁ g₁ w₁) inst✝¹ : HasCokernel (imageToKernel f₂ g₂ w₂) inst✝ : HasCokernel (imageToKernel f₃ g₃ w₃) α : Arrow.mk f₁ ≅ Arrow.mk f₂ β : Arrow.mk g₁ ≅ Arrow.mk g₂ p : α.hom.right = β.hom.left ⊢ α.inv ≫ α.hom = 𝟙 (Arrow.mk f₂) [PROOFSTEP] simp only [Iso.inv_hom_id] [GOAL] case e_β ι : Type u_1 V : Type u inst✝¹⁹ : Category.{v, u} V inst✝¹⁸ : HasZeroMorphisms V A B C : V f : A ⟶ B inst✝¹⁷ : HasImage f g : B ⟶ C inst✝¹⁶ : HasKernel g w : f ≫ g = 0 A' B' C' : V f' : A' ⟶ B' inst✝¹⁵ : HasImage f' g' : B' ⟶ C' inst✝¹⁴ : HasKernel g' w' : f' ≫ g' = 0 α✝ : Arrow.mk f ⟶ Arrow.mk f' inst✝¹³ : HasImageMap α✝ β✝ : Arrow.mk g ⟶ Arrow.mk g' A₁ B₁ C₁ : V f₁ : A₁ ⟶ B₁ inst✝¹² : HasImage f₁ g₁ : B₁ ⟶ C₁ inst✝¹¹ : HasKernel g₁ w₁ : f₁ ≫ g₁ = 0 A₂ B₂ C₂ : V f₂ : A₂ ⟶ B₂ inst✝¹⁰ : HasImage f₂ g₂ : B₂ ⟶ C₂ inst✝⁹ : HasKernel g₂ w₂ : f₂ ≫ g₂ = 0 A₃ B₃ C₃ : V f₃ : A₃ ⟶ B₃ inst✝⁸ : HasImage f₃ g₃ : B₃ ⟶ C₃ inst✝⁷ : HasKernel g₃ w₃ : f₃ ≫ g₃ = 0 α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂ inst✝⁶ : HasImageMap α₁ β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂ α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃ inst✝⁵ : HasImageMap α₂ β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃ inst✝⁴ : HasCokernel (imageToKernel f g w) inst✝³ : HasCokernel (imageToKernel f' g' w') inst✝² : HasCokernel (imageToKernel f₁ g₁ w₁) inst✝¹ : HasCokernel (imageToKernel f₂ g₂ w₂) inst✝ : HasCokernel (imageToKernel f₃ g₃ w₃) α : Arrow.mk f₁ ≅ Arrow.mk f₂ β : Arrow.mk g₁ ≅ Arrow.mk g₂ p : α.hom.right = β.hom.left ⊢ β.inv ≫ β.hom = 𝟙 (Arrow.mk g₂) [PROOFSTEP] simp only [Iso.inv_hom_id] [GOAL] ι : Type u_1 V : Type u inst✝⁵ : Category.{v, u} V inst✝⁴ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w : f ≫ g = 0 f' : A ⟶ B g' : B ⟶ C w' : f' ≫ g' = 0 inst✝³ : HasKernels V inst✝² : HasCokernels V inst✝¹ : HasImages V inst✝ : HasImageMaps V pf : f = f' pg : g = g' ⊢ (𝟭 V).map (𝟙 (Arrow.mk f).left) ≫ (Arrow.mk f').hom = (Arrow.mk f).hom ≫ (𝟭 V).map (𝟙 (Arrow.mk f).right) [PROOFSTEP] aesop_cat [GOAL] ι : Type u_1 V : Type u inst✝⁵ : Category.{v, u} V inst✝⁴ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w : f ≫ g = 0 f' : A ⟶ B g' : B ⟶ C w' : f' ≫ g' = 0 inst✝³ : HasKernels V inst✝² : HasCokernels V inst✝¹ : HasImages V inst✝ : HasImageMaps V pf : f = f' pg : g = g' ⊢ (𝟭 V).map (𝟙 (Arrow.mk g).left) ≫ (Arrow.mk g').hom = (Arrow.mk g).hom ≫ (𝟭 V).map (𝟙 (Arrow.mk g).right) [PROOFSTEP] aesop_cat [GOAL] ι : Type u_1 V : Type u inst✝⁵ : Category.{v, u} V inst✝⁴ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w : f ≫ g = 0 f' : A ⟶ B g' : B ⟶ C w' : f' ≫ g' = 0 inst✝³ : HasKernels V inst✝² : HasCokernels V inst✝¹ : HasImages V inst✝ : HasImageMaps V pf : f = f' pg : g = g' ⊢ (𝟭 V).map (𝟙 (Arrow.mk f').left) ≫ (Arrow.mk f).hom = (Arrow.mk f').hom ≫ (𝟭 V).map (𝟙 (Arrow.mk f').right) [PROOFSTEP] aesop_cat [GOAL] ι : Type u_1 V : Type u inst✝⁵ : Category.{v, u} V inst✝⁴ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w : f ≫ g = 0 f' : A ⟶ B g' : B ⟶ C w' : f' ≫ g' = 0 inst✝³ : HasKernels V inst✝² : HasCokernels V inst✝¹ : HasImages V inst✝ : HasImageMaps V pf : f = f' pg : g = g' ⊢ (𝟭 V).map (𝟙 (Arrow.mk g').left) ≫ (Arrow.mk g).hom = (Arrow.mk g').hom ≫ (𝟭 V).map (𝟙 (Arrow.mk g').right) [PROOFSTEP] aesop_cat [GOAL] ι : Type u_1 V : Type u inst✝⁵ : Category.{v, u} V inst✝⁴ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w : f ≫ g = 0 f' : A ⟶ B g' : B ⟶ C w' : f' ≫ g' = 0 inst✝³ : HasKernels V inst✝² : HasCokernels V inst✝¹ : HasImages V inst✝ : HasImageMaps V pf : f = f' pg : g = g' ⊢ map w w' (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)) (CommaMorphism.mk (𝟙 (Arrow.mk g).left) (𝟙 (Arrow.mk g).right)) (_ : (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)).right = (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)).right) ≫ map w' w (CommaMorphism.mk (𝟙 (Arrow.mk f').left) (𝟙 (Arrow.mk f').right)) (CommaMorphism.mk (𝟙 (Arrow.mk g').left) (𝟙 (Arrow.mk g').right)) (_ : (CommaMorphism.mk (𝟙 (Arrow.mk f').left) (𝟙 (Arrow.mk f').right)).right = (CommaMorphism.mk (𝟙 (Arrow.mk f').left) (𝟙 (Arrow.mk f').right)).right) = 𝟙 (homology f g w) [PROOFSTEP] obtain rfl := pf [GOAL] ι : Type u_1 V : Type u inst✝⁵ : Category.{v, u} V inst✝⁴ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w : f ≫ g = 0 g' : B ⟶ C inst✝³ : HasKernels V inst✝² : HasCokernels V inst✝¹ : HasImages V inst✝ : HasImageMaps V pg : g = g' w' : f ≫ g' = 0 ⊢ map w w' (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)) (CommaMorphism.mk (𝟙 (Arrow.mk g).left) (𝟙 (Arrow.mk g).right)) (_ : (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)).right = (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)).right) ≫ map w' w (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)) (CommaMorphism.mk (𝟙 (Arrow.mk g').left) (𝟙 (Arrow.mk g').right)) (_ : (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)).right = (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)).right) = 𝟙 (homology f g w) [PROOFSTEP] obtain rfl := pg [GOAL] ι : Type u_1 V : Type u inst✝⁵ : Category.{v, u} V inst✝⁴ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w : f ≫ g = 0 inst✝³ : HasKernels V inst✝² : HasCokernels V inst✝¹ : HasImages V inst✝ : HasImageMaps V w' : f ≫ g = 0 ⊢ map w w' (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)) (CommaMorphism.mk (𝟙 (Arrow.mk g).left) (𝟙 (Arrow.mk g).right)) (_ : (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)).right = (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)).right) ≫ map w' w (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)) (CommaMorphism.mk (𝟙 (Arrow.mk g).left) (𝟙 (Arrow.mk g).right)) (_ : (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)).right = (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)).right) = 𝟙 (homology f g w) [PROOFSTEP] rw [homology.map_comp, ← homology.map_id] [GOAL] ι : Type u_1 V : Type u inst✝⁵ : Category.{v, u} V inst✝⁴ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w : f ≫ g = 0 inst✝³ : HasKernels V inst✝² : HasCokernels V inst✝¹ : HasImages V inst✝ : HasImageMaps V w' : f ≫ g = 0 ⊢ map w w (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right) ≫ CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)) (CommaMorphism.mk (𝟙 (Arrow.mk g).left) (𝟙 (Arrow.mk g).right) ≫ CommaMorphism.mk (𝟙 (Arrow.mk g).left) (𝟙 (Arrow.mk g).right)) (_ : (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right) ≫ CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)).right = (CommaMorphism.mk (𝟙 (Arrow.mk g).left) (𝟙 (Arrow.mk g).right) ≫ CommaMorphism.mk (𝟙 (Arrow.mk g).left) (𝟙 (Arrow.mk g).right)).left) = map w w (𝟙 (Arrow.mk f)) (𝟙 (Arrow.mk g)) (_ : (𝟙 (Arrow.mk f)).right = (𝟙 (Arrow.mk f)).right) [PROOFSTEP] congr [GOAL] case e_α ι : Type u_1 V : Type u inst✝⁵ : Category.{v, u} V inst✝⁴ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w : f ≫ g = 0 inst✝³ : HasKernels V inst✝² : HasCokernels V inst✝¹ : HasImages V inst✝ : HasImageMaps V w' : f ≫ g = 0 ⊢ CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right) ≫ CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right) = 𝟙 (Arrow.mk f) [PROOFSTEP] aesop_cat [GOAL] case e_β ι : Type u_1 V : Type u inst✝⁵ : Category.{v, u} V inst✝⁴ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w : f ≫ g = 0 inst✝³ : HasKernels V inst✝² : HasCokernels V inst✝¹ : HasImages V inst✝ : HasImageMaps V w' : f ≫ g = 0 ⊢ CommaMorphism.mk (𝟙 (Arrow.mk g).left) (𝟙 (Arrow.mk g).right) ≫ CommaMorphism.mk (𝟙 (Arrow.mk g).left) (𝟙 (Arrow.mk g).right) = 𝟙 (Arrow.mk g) [PROOFSTEP] aesop_cat [GOAL] ι : Type u_1 V : Type u inst✝⁵ : Category.{v, u} V inst✝⁴ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w : f ≫ g = 0 f' : A ⟶ B g' : B ⟶ C w' : f' ≫ g' = 0 inst✝³ : HasKernels V inst✝² : HasCokernels V inst✝¹ : HasImages V inst✝ : HasImageMaps V pf : f = f' pg : g = g' ⊢ map w' w (CommaMorphism.mk (𝟙 (Arrow.mk f').left) (𝟙 (Arrow.mk f').right)) (CommaMorphism.mk (𝟙 (Arrow.mk g').left) (𝟙 (Arrow.mk g').right)) (_ : (CommaMorphism.mk (𝟙 (Arrow.mk f').left) (𝟙 (Arrow.mk f').right)).right = (CommaMorphism.mk (𝟙 (Arrow.mk f').left) (𝟙 (Arrow.mk f').right)).right) ≫ map w w' (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)) (CommaMorphism.mk (𝟙 (Arrow.mk g).left) (𝟙 (Arrow.mk g).right)) (_ : (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)).right = (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)).right) = 𝟙 (homology f' g' w') [PROOFSTEP] obtain rfl := pf [GOAL] ι : Type u_1 V : Type u inst✝⁵ : Category.{v, u} V inst✝⁴ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w : f ≫ g = 0 g' : B ⟶ C inst✝³ : HasKernels V inst✝² : HasCokernels V inst✝¹ : HasImages V inst✝ : HasImageMaps V pg : g = g' w' : f ≫ g' = 0 ⊢ map w' w (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)) (CommaMorphism.mk (𝟙 (Arrow.mk g').left) (𝟙 (Arrow.mk g').right)) (_ : (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)).right = (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)).right) ≫ map w w' (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)) (CommaMorphism.mk (𝟙 (Arrow.mk g).left) (𝟙 (Arrow.mk g).right)) (_ : (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)).right = (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)).right) = 𝟙 (homology f g' w') [PROOFSTEP] obtain rfl := pg [GOAL] ι : Type u_1 V : Type u inst✝⁵ : Category.{v, u} V inst✝⁴ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w : f ≫ g = 0 inst✝³ : HasKernels V inst✝² : HasCokernels V inst✝¹ : HasImages V inst✝ : HasImageMaps V w' : f ≫ g = 0 ⊢ map w' w (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)) (CommaMorphism.mk (𝟙 (Arrow.mk g).left) (𝟙 (Arrow.mk g).right)) (_ : (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)).right = (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)).right) ≫ map w w' (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)) (CommaMorphism.mk (𝟙 (Arrow.mk g).left) (𝟙 (Arrow.mk g).right)) (_ : (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)).right = (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)).right) = 𝟙 (homology f g w') [PROOFSTEP] rw [homology.map_comp, ← homology.map_id] [GOAL] ι : Type u_1 V : Type u inst✝⁵ : Category.{v, u} V inst✝⁴ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w : f ≫ g = 0 inst✝³ : HasKernels V inst✝² : HasCokernels V inst✝¹ : HasImages V inst✝ : HasImageMaps V w' : f ≫ g = 0 ⊢ map w' w' (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right) ≫ CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)) (CommaMorphism.mk (𝟙 (Arrow.mk g).left) (𝟙 (Arrow.mk g).right) ≫ CommaMorphism.mk (𝟙 (Arrow.mk g).left) (𝟙 (Arrow.mk g).right)) (_ : (CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right) ≫ CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right)).right = (CommaMorphism.mk (𝟙 (Arrow.mk g).left) (𝟙 (Arrow.mk g).right) ≫ CommaMorphism.mk (𝟙 (Arrow.mk g).left) (𝟙 (Arrow.mk g).right)).left) = map w' w' (𝟙 (Arrow.mk f)) (𝟙 (Arrow.mk g)) (_ : (𝟙 (Arrow.mk f)).right = (𝟙 (Arrow.mk f)).right) [PROOFSTEP] congr [GOAL] case e_α ι : Type u_1 V : Type u inst✝⁵ : Category.{v, u} V inst✝⁴ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w : f ≫ g = 0 inst✝³ : HasKernels V inst✝² : HasCokernels V inst✝¹ : HasImages V inst✝ : HasImageMaps V w' : f ≫ g = 0 ⊢ CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right) ≫ CommaMorphism.mk (𝟙 (Arrow.mk f).left) (𝟙 (Arrow.mk f).right) = 𝟙 (Arrow.mk f) [PROOFSTEP] aesop_cat [GOAL] case e_β ι : Type u_1 V : Type u inst✝⁵ : Category.{v, u} V inst✝⁴ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w : f ≫ g = 0 inst✝³ : HasKernels V inst✝² : HasCokernels V inst✝¹ : HasImages V inst✝ : HasImageMaps V w' : f ≫ g = 0 ⊢ CommaMorphism.mk (𝟙 (Arrow.mk g).left) (𝟙 (Arrow.mk g).right) ≫ CommaMorphism.mk (𝟙 (Arrow.mk g).left) (𝟙 (Arrow.mk g).right) = 𝟙 (Arrow.mk g) [PROOFSTEP] aesop_cat [GOAL] ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w✝ : f ≫ g = 0 inst✝¹ : HasKernels V inst✝ : HasImages V w : f ≫ g = 0 ⊢ image.ι f ≫ g = 0 [PROOFSTEP] ext [GOAL] case w ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w✝ : f ≫ g = 0 inst✝¹ : HasKernels V inst✝ : HasImages V w : f ≫ g = 0 ⊢ factorThruImage f ≫ image.ι f ≫ g = factorThruImage f ≫ 0 [PROOFSTEP] simpa using w [GOAL] ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w✝ : f ≫ g = 0 inst✝¹ : HasKernels V inst✝ : HasImages V w : f ≫ g = 0 ⊢ (imageSubobjectIso f).hom ≫ imageToKernel' f g w = imageToKernel f g w ≫ (kernelSubobjectIso g).hom [PROOFSTEP] ext [GOAL] case h ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w✝ : f ≫ g = 0 inst✝¹ : HasKernels V inst✝ : HasImages V w : f ≫ g = 0 ⊢ ((imageSubobjectIso f).hom ≫ imageToKernel' f g w) ≫ equalizer.ι g 0 = (imageToKernel f g w ≫ (kernelSubobjectIso g).hom) ≫ equalizer.ι g 0 [PROOFSTEP] simp [imageToKernel'] [GOAL] ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w✝ : f ≫ g = 0 inst✝¹ : HasKernels V inst✝ : HasImages V w : f ≫ g = 0 ⊢ imageToKernel' f g w ≫ (kernelSubobjectIso g).inv = (imageSubobjectIso f).inv ≫ imageToKernel f g w [PROOFSTEP] ext [GOAL] case h ι : Type u_1 V : Type u inst✝³ : Category.{v, u} V inst✝² : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w✝ : f ≫ g = 0 inst✝¹ : HasKernels V inst✝ : HasImages V w : f ≫ g = 0 ⊢ (imageToKernel' f g w ≫ (kernelSubobjectIso g).inv) ≫ Subobject.arrow (kernelSubobject g) = ((imageSubobjectIso f).inv ≫ imageToKernel f g w) ≫ Subobject.arrow (kernelSubobject g) [PROOFSTEP] simp [imageToKernel'] [GOAL] ι : Type u_1 V : Type u inst✝⁴ : Category.{v, u} V inst✝³ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w✝ : f ≫ g = 0 inst✝² : HasKernels V inst✝¹ : HasImages V inst✝ : HasCokernels V w : f ≫ g = 0 ⊢ imageToKernel f g w ≫ (kernelSubobjectIso g).hom = (imageSubobjectIso f).hom ≫ imageToKernel' f g w [PROOFSTEP] simp only [imageSubobjectIso_imageToKernel'] [GOAL] ι : Type u_1 V : Type u inst✝⁴ : Category.{v, u} V inst✝³ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w✝ : f ≫ g = 0 inst✝² : HasKernels V inst✝¹ : HasImages V inst✝ : HasCokernels V w : f ≫ g = 0 ⊢ imageToKernel' f g w ≫ (kernelSubobjectIso g).inv = (imageSubobjectIso f).inv ≫ imageToKernel f g w [PROOFSTEP] simp only [imageToKernel'_kernelSubobjectIso] [GOAL] ι : Type u_1 V : Type u inst✝⁴ : Category.{v, u} V inst✝³ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w✝ : f ≫ g = 0 inst✝² : HasKernels V inst✝¹ : HasImages V inst✝ : HasCokernels V w : f ≫ g = 0 ⊢ cokernel.map (imageToKernel f g w) (imageToKernel' f g w) (imageSubobjectIso f).hom (kernelSubobjectIso g).hom (_ : imageToKernel f g w ≫ (kernelSubobjectIso g).hom = (imageSubobjectIso f).hom ≫ imageToKernel' f g w) ≫ cokernel.map (imageToKernel' f g w) (imageToKernel f g w) (imageSubobjectIso f).inv (kernelSubobjectIso g).inv (_ : imageToKernel' f g w ≫ (kernelSubobjectIso g).inv = (imageSubobjectIso f).inv ≫ imageToKernel f g w) = 𝟙 (homology f g w) [PROOFSTEP] apply coequalizer.hom_ext [GOAL] case h ι : Type u_1 V : Type u inst✝⁴ : Category.{v, u} V inst✝³ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w✝ : f ≫ g = 0 inst✝² : HasKernels V inst✝¹ : HasImages V inst✝ : HasCokernels V w : f ≫ g = 0 ⊢ coequalizer.π (imageToKernel f g w) 0 ≫ cokernel.map (imageToKernel f g w) (imageToKernel' f g w) (imageSubobjectIso f).hom (kernelSubobjectIso g).hom (_ : imageToKernel f g w ≫ (kernelSubobjectIso g).hom = (imageSubobjectIso f).hom ≫ imageToKernel' f g w) ≫ cokernel.map (imageToKernel' f g w) (imageToKernel f g w) (imageSubobjectIso f).inv (kernelSubobjectIso g).inv (_ : imageToKernel' f g w ≫ (kernelSubobjectIso g).inv = (imageSubobjectIso f).inv ≫ imageToKernel f g w) = coequalizer.π (imageToKernel f g w) 0 ≫ 𝟙 (homology f g w) [PROOFSTEP] simp only [Iso.hom_inv_id_assoc, cokernel.π_desc, cokernel.π_desc_assoc, Category.assoc, coequalizer_as_cokernel] [GOAL] case h ι : Type u_1 V : Type u inst✝⁴ : Category.{v, u} V inst✝³ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w✝ : f ≫ g = 0 inst✝² : HasKernels V inst✝¹ : HasImages V inst✝ : HasCokernels V w : f ≫ g = 0 ⊢ cokernel.π (imageToKernel f g w) = cokernel.π (imageToKernel f g w) ≫ 𝟙 (homology f g w) [PROOFSTEP] exact (Category.comp_id _).symm [GOAL] ι : Type u_1 V : Type u inst✝⁴ : Category.{v, u} V inst✝³ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w✝ : f ≫ g = 0 inst✝² : HasKernels V inst✝¹ : HasImages V inst✝ : HasCokernels V w : f ≫ g = 0 ⊢ cokernel.map (imageToKernel' f g w) (imageToKernel f g w) (imageSubobjectIso f).inv (kernelSubobjectIso g).inv (_ : imageToKernel' f g w ≫ (kernelSubobjectIso g).inv = (imageSubobjectIso f).inv ≫ imageToKernel f g w) ≫ cokernel.map (imageToKernel f g w) (imageToKernel' f g w) (imageSubobjectIso f).hom (kernelSubobjectIso g).hom (_ : imageToKernel f g w ≫ (kernelSubobjectIso g).hom = (imageSubobjectIso f).hom ≫ imageToKernel' f g w) = 𝟙 (cokernel (imageToKernel' f g w)) [PROOFSTEP] ext [GOAL] case h ι : Type u_1 V : Type u inst✝⁴ : Category.{v, u} V inst✝³ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w✝ : f ≫ g = 0 inst✝² : HasKernels V inst✝¹ : HasImages V inst✝ : HasCokernels V w : f ≫ g = 0 ⊢ coequalizer.π (imageToKernel' f g w) 0 ≫ cokernel.map (imageToKernel' f g w) (imageToKernel f g w) (imageSubobjectIso f).inv (kernelSubobjectIso g).inv (_ : imageToKernel' f g w ≫ (kernelSubobjectIso g).inv = (imageSubobjectIso f).inv ≫ imageToKernel f g w) ≫ cokernel.map (imageToKernel f g w) (imageToKernel' f g w) (imageSubobjectIso f).hom (kernelSubobjectIso g).hom (_ : imageToKernel f g w ≫ (kernelSubobjectIso g).hom = (imageSubobjectIso f).hom ≫ imageToKernel' f g w) = coequalizer.π (imageToKernel' f g w) 0 ≫ 𝟙 (cokernel (imageToKernel' f g w)) [PROOFSTEP] simp only [Iso.inv_hom_id_assoc, cokernel.π_desc, Category.comp_id, cokernel.π_desc_assoc, Category.assoc] [GOAL] ι : Type u_1 V : Type u inst✝⁵ : Category.{v, u} V inst✝⁴ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w✝ : f ≫ g = 0 inst✝³ : HasKernels V inst✝² : HasImages V inst✝¹ : HasCokernels V inst✝ : HasEqualizers V w : f ≫ g = 0 ⊢ homology f g w ≅ cokernel (kernel.lift g f w) [PROOFSTEP] refine' homologyIsoCokernelImageToKernel' f g w ≪≫ _ [GOAL] ι : Type u_1 V : Type u inst✝⁵ : Category.{v, u} V inst✝⁴ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w✝ : f ≫ g = 0 inst✝³ : HasKernels V inst✝² : HasImages V inst✝¹ : HasCokernels V inst✝ : HasEqualizers V w : f ≫ g = 0 ⊢ cokernel (imageToKernel' f g w) ≅ cokernel (kernel.lift g f w) [PROOFSTEP] have p : factorThruImage f ≫ imageToKernel' f g w = kernel.lift g f w := by ext simp [imageToKernel'] [GOAL] ι : Type u_1 V : Type u inst✝⁵ : Category.{v, u} V inst✝⁴ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w✝ : f ≫ g = 0 inst✝³ : HasKernels V inst✝² : HasImages V inst✝¹ : HasCokernels V inst✝ : HasEqualizers V w : f ≫ g = 0 ⊢ factorThruImage f ≫ imageToKernel' f g w = kernel.lift g f w [PROOFSTEP] ext [GOAL] case h ι : Type u_1 V : Type u inst✝⁵ : Category.{v, u} V inst✝⁴ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w✝ : f ≫ g = 0 inst✝³ : HasKernels V inst✝² : HasImages V inst✝¹ : HasCokernels V inst✝ : HasEqualizers V w : f ≫ g = 0 ⊢ (factorThruImage f ≫ imageToKernel' f g w) ≫ equalizer.ι g 0 = kernel.lift g f w ≫ equalizer.ι g 0 [PROOFSTEP] simp [imageToKernel'] [GOAL] ι : Type u_1 V : Type u inst✝⁵ : Category.{v, u} V inst✝⁴ : HasZeroMorphisms V A B C : V f : A ⟶ B g : B ⟶ C w✝ : f ≫ g = 0 inst✝³ : HasKernels V inst✝² : HasImages V inst✝¹ : HasCokernels V inst✝ : HasEqualizers V w : f ≫ g = 0 p : factorThruImage f ≫ imageToKernel' f g w = kernel.lift g f w ⊢ cokernel (imageToKernel' f g w) ≅ cokernel (kernel.lift g f w) [PROOFSTEP] exact (cokernelEpiComp _ _).symm ≪≫ cokernelIsoOfEq p
module Test.QuickCheck.Arbitrary ( -- * Arbitrary and CoArbitrary classes Arbitrary(..) , CoArbitrary(..) -- ** Helper functions for implementing arbitrary , arbitrarySizedIntegral -- :: Num a => Gen a , arbitraryBoundedIntegral -- :: (Bounded a, Integral a) => Gen a , arbitrarySizedBoundedIntegral -- :: (Bounded a, Integral a) => Gen a , arbitrarySizedFractional -- :: Fractional a => Gen a , arbitraryBoundedRandom -- :: (Bounded a, Random a) => Gen a -- ** Helper functions for implementing shrink , shrinkNothing -- :: a -> [a] , shrinkList -- :: (a -> [a]) -> [a] -> [[a]] , shrinkIntegral -- :: Integral a => a -> [a] , shrinkRealFrac -- :: RealFrac a => a -> [a] -- ** Helper functions for implementing coarbitrary , (><) , coarbitraryIntegral -- :: Integral a => a -> Gen b -> Gen b , coarbitraryReal -- :: Real a => a -> Gen b -> Gen b , coarbitraryShow -- :: Show a => a -> Gen b -> Gen b -- ** Generators which use arbitrary , vector -- :: Arbitrary a => Int -> Gen [a] , orderedList -- :: (Ord a, Arbitrary a) => Gen [a] ) where -------------------------------------------------------------------------- -- imports import Test.QuickCheck.Gen {- import Data.Generics ( (:*:)(..) , (:+:)(..) , Unit(..) ) -} import Data.Char ( chr , ord , isLower , isUpper , toLower , isDigit , isSpace ) import Data.Ratio ( Ratio , (%) , numerator , denominator ) import Data.Complex ( Complex((:+)) ) import System.Random ( Random ) import Data.List ( sort , nub ) import Control.Monad ( liftM , liftM2 , liftM3 , liftM4 , liftM5 ) import Data.Int(Int8, Int16, Int32, Int64) import Data.Word(Word, Word8, Word16, Word32, Word64) -------------------------------------------------------------------------- -- ** class Arbitrary -- | Random generation and shrinking of values. class Arbitrary a where -- | A generator for values of the given type. arbitrary :: Gen a arbitrary = error "no default generator" -- | Produces a (possibly) empty list of all the possible -- immediate shrinks of the given value. shrink :: a -> [a] shrink _ = [] -- instances instance (CoArbitrary a, Arbitrary b) => Arbitrary (a -> b) where arbitrary = promote (`coarbitrary` arbitrary) instance Arbitrary () where arbitrary = return () instance Arbitrary Bool where arbitrary = choose (False,True) shrink True = [False] shrink False = [] instance Arbitrary a => Arbitrary (Maybe a) where arbitrary = frequency [(1, return Nothing), (3, liftM Just arbitrary)] shrink (Just x) = Nothing : [ Just x' | x' <- shrink x ] shrink _ = [] instance (Arbitrary a, Arbitrary b) => Arbitrary (Either a b) where arbitrary = oneof [liftM Left arbitrary, liftM Right arbitrary] shrink (Left x) = [ Left x' | x' <- shrink x ] shrink (Right y) = [ Right y' | y' <- shrink y ] instance Arbitrary a => Arbitrary [a] where arbitrary = sized $ \n -> do k <- choose (0,n) sequence [ arbitrary | _ <- [1..k] ] shrink xs = shrinkList shrink xs shrinkList :: (a -> [a]) -> [a] -> [[a]] shrinkList shr xs = concat [ removes k n xs | k <- takeWhile (>0) (iterate (`div`2) n) ] ++ shrinkOne xs where n = length xs shrinkOne [] = [] shrinkOne (x:xs) = [ x':xs | x' <- shr x ] ++ [ x:xs' | xs' <- shrinkOne xs ] removes k n xs | k > n = [] | null xs2 = [[]] | otherwise = xs2 : map (xs1 ++) (removes k (n-k) xs2) where xs1 = take k xs xs2 = drop k xs {- -- "standard" definition for lists: shrink [] = [] shrink (x:xs) = [ xs ] ++ [ x:xs' | xs' <- shrink xs ] ++ [ x':xs | x' <- shrink x ] -} instance (Integral a, Arbitrary a) => Arbitrary (Ratio a) where arbitrary = arbitrarySizedFractional shrink = shrinkRealFrac instance (RealFloat a, Arbitrary a) => Arbitrary (Complex a) where arbitrary = liftM2 (:+) arbitrary arbitrary shrink (x :+ y) = [ x' :+ y | x' <- shrink x ] ++ [ x :+ y' | y' <- shrink y ] instance (Arbitrary a, Arbitrary b) => Arbitrary (a,b) where arbitrary = liftM2 (,) arbitrary arbitrary shrink (x,y) = [ (x',y) | x' <- shrink x ] ++ [ (x,y') | y' <- shrink y ] instance (Arbitrary a, Arbitrary b, Arbitrary c) => Arbitrary (a,b,c) where arbitrary = liftM3 (,,) arbitrary arbitrary arbitrary shrink (x,y,z) = [ (x',y,z) | x' <- shrink x ] ++ [ (x,y',z) | y' <- shrink y ] ++ [ (x,y,z') | z' <- shrink z ] instance (Arbitrary a, Arbitrary b, Arbitrary c, Arbitrary d) => Arbitrary (a,b,c,d) where arbitrary = liftM4 (,,,) arbitrary arbitrary arbitrary arbitrary shrink (w,x,y,z) = [ (w',x,y,z) | w' <- shrink w ] ++ [ (w,x',y,z) | x' <- shrink x ] ++ [ (w,x,y',z) | y' <- shrink y ] ++ [ (w,x,y,z') | z' <- shrink z ] instance (Arbitrary a, Arbitrary b, Arbitrary c, Arbitrary d, Arbitrary e) => Arbitrary (a,b,c,d,e) where arbitrary = liftM5 (,,,,) arbitrary arbitrary arbitrary arbitrary arbitrary shrink (v,w,x,y,z) = [ (v',w,x,y,z) | v' <- shrink v ] ++ [ (v,w',x,y,z) | w' <- shrink w ] ++ [ (v,w,x',y,z) | x' <- shrink x ] ++ [ (v,w,x,y',z) | y' <- shrink y ] ++ [ (v,w,x,y,z') | z' <- shrink z ] -- typical instance for primitive (numerical) types instance Arbitrary Integer where arbitrary = arbitrarySizedIntegral shrink = shrinkIntegral instance Arbitrary Int where arbitrary = arbitrarySizedBoundedIntegral shrink = shrinkIntegral instance Arbitrary Int8 where arbitrary = arbitrarySizedBoundedIntegral shrink = shrinkIntegral instance Arbitrary Int16 where arbitrary = arbitrarySizedBoundedIntegral shrink = shrinkIntegral instance Arbitrary Int32 where arbitrary = arbitrarySizedBoundedIntegral shrink = shrinkIntegral instance Arbitrary Int64 where arbitrary = arbitrarySizedBoundedIntegral shrink = shrinkIntegral instance Arbitrary Word where arbitrary = arbitrarySizedBoundedIntegral shrink = shrinkIntegral instance Arbitrary Word8 where arbitrary = arbitrarySizedBoundedIntegral shrink = shrinkIntegral instance Arbitrary Word16 where arbitrary = arbitrarySizedBoundedIntegral shrink = shrinkIntegral instance Arbitrary Word32 where arbitrary = arbitrarySizedBoundedIntegral shrink = shrinkIntegral instance Arbitrary Word64 where arbitrary = arbitrarySizedBoundedIntegral shrink = shrinkIntegral instance Arbitrary Char where arbitrary = chr `fmap` oneof [choose (0,127), choose (0,255)] shrink c = filter (<. c) $ nub $ ['a','b','c'] ++ [ toLower c | isUpper c ] ++ ['A','B','C'] ++ ['1','2','3'] ++ [' ','\n'] where a <. b = stamp a < stamp b stamp a = ( (not (isLower a) , not (isUpper a) , not (isDigit a)) , (not (a==' ') , not (isSpace a) , a) ) instance Arbitrary Float where arbitrary = arbitrarySizedFractional shrink = shrinkRealFrac instance Arbitrary Double where arbitrary = arbitrarySizedFractional shrink = shrinkRealFrac -- ** Helper functions for implementing arbitrary -- | Generates an integral number. The number can be positive or negative -- and its maximum absolute value depends on the size parameter. arbitrarySizedIntegral :: Num a => Gen a arbitrarySizedIntegral = sized $ \n -> let n' = toInteger n in fmap fromInteger (choose (-n', n')) -- | Generates a fractional number. The number can be positive or negative -- and its maximum absolute value depends on the size parameter. arbitrarySizedFractional :: Fractional a => Gen a arbitrarySizedFractional = sized $ \n -> let n' = toInteger n in do a <- choose ((-n') * precision, n' * precision) b <- choose (1, precision) return (fromRational (a % b)) where precision = 9999999999999 :: Integer -- | Generates an integral number. The number is chosen uniformly from -- the entire range of the type. You may want to use -- 'arbitrarySizedBoundedIntegral' instead. arbitraryBoundedIntegral :: (Bounded a, Integral a) => Gen a arbitraryBoundedIntegral = do let mn = minBound mx = maxBound `asTypeOf` mn n <- choose (toInteger mn, toInteger mx) return (fromInteger n `asTypeOf` mn) -- | Generates an element of a bounded type. The element is -- chosen from the entire range of the type. arbitraryBoundedRandom :: (Bounded a, Random a) => Gen a arbitraryBoundedRandom = choose (minBound,maxBound) -- | Generates an integral number from a bounded domain. The number is -- chosen from the entire range of the type, but small numbers are -- generated more often than big numbers. Inspired by demands from -- Phil Wadler. arbitrarySizedBoundedIntegral :: (Bounded a, Integral a) => Gen a arbitrarySizedBoundedIntegral = sized $ \s -> do let mn = minBound mx = maxBound `asTypeOf` mn bits n | n `quot` 2 == 0 = 0 | otherwise = 1 + bits (n `quot` 2) k = 2^(s*(bits mn `max` bits mx `max` 40) `div` 100) n <- choose (toInteger mn `max` (-k), toInteger mx `min` k) return (fromInteger n `asTypeOf` mn) -- ** Helper functions for implementing shrink -- | Returns no shrinking alternatives. shrinkNothing :: a -> [a] shrinkNothing _ = [] -- | Shrink an integral number. shrinkIntegral :: Integral a => a -> [a] shrinkIntegral x = nub $ [ -x | x < 0, -x > x ] ++ [ x' | x' <- takeWhile (<< x) (0:[ x - i | i <- tail (iterate (`quot` 2) x) ]) ] where -- a << b is "morally" abs a < abs b, but taking care of overflow. a << b = case (a >= 0, b >= 0) of (True, True) -> a < b (False, False) -> a > b (True, False) -> a + b < 0 (False, True) -> a + b > 0 -- | Shrink a fraction. shrinkRealFrac :: RealFrac a => a -> [a] shrinkRealFrac x = nub $ [ -x | x < 0 ] ++ [ x' | x' <- [fromInteger (truncate x)] , x' << x ] where a << b = abs a < abs b -------------------------------------------------------------------------- -- ** CoArbitrary -- | Used for random generation of functions. class CoArbitrary a where -- | Used to generate a function of type @a -> c@. The implementation -- should use the first argument to perturb the random generator -- given as the second argument. the returned generator -- is then used to generate the function result. -- You can often use 'variant' and '><' to implement -- 'coarbitrary'. coarbitrary :: a -> Gen c -> Gen c {- -- GHC definition: coarbitrary{| Unit |} Unit = id coarbitrary{| a :*: b |} (x :*: y) = coarbitrary x >< coarbitrary y coarbitrary{| a :+: b |} (Inl x) = variant 0 . coarbitrary x coarbitrary{| a :+: b |} (Inr y) = variant (-1) . coarbitrary y -} -- | Combine two generator perturbing functions, for example the -- results of calls to 'variant' or 'coarbitrary'. (><) :: (Gen a -> Gen a) -> (Gen a -> Gen a) -> (Gen a -> Gen a) (><) f g gen = do n <- arbitrary (g . variant (n :: Int) . f) gen -- for the sake of non-GHC compilers, I have added definitions -- for coarbitrary here. instance (Arbitrary a, CoArbitrary b) => CoArbitrary (a -> b) where coarbitrary f gen = do xs <- arbitrary coarbitrary (map f xs) gen instance CoArbitrary () where coarbitrary _ = id instance CoArbitrary Bool where coarbitrary False = variant 0 coarbitrary True = variant (-1) instance CoArbitrary a => CoArbitrary (Maybe a) where coarbitrary Nothing = variant 0 coarbitrary (Just x) = variant (-1) . coarbitrary x instance (CoArbitrary a, CoArbitrary b) => CoArbitrary (Either a b) where coarbitrary (Left x) = variant 0 . coarbitrary x coarbitrary (Right y) = variant (-1) . coarbitrary y instance CoArbitrary a => CoArbitrary [a] where coarbitrary [] = variant 0 coarbitrary (x:xs) = variant (-1) . coarbitrary (x,xs) instance (Integral a, CoArbitrary a) => CoArbitrary (Ratio a) where coarbitrary r = coarbitrary (numerator r,denominator r) instance (RealFloat a, CoArbitrary a) => CoArbitrary (Complex a) where coarbitrary (x :+ y) = coarbitrary x >< coarbitrary y instance (CoArbitrary a, CoArbitrary b) => CoArbitrary (a,b) where coarbitrary (x,y) = coarbitrary x >< coarbitrary y instance (CoArbitrary a, CoArbitrary b, CoArbitrary c) => CoArbitrary (a,b,c) where coarbitrary (x,y,z) = coarbitrary x >< coarbitrary y >< coarbitrary z instance (CoArbitrary a, CoArbitrary b, CoArbitrary c, CoArbitrary d) => CoArbitrary (a,b,c,d) where coarbitrary (x,y,z,v) = coarbitrary x >< coarbitrary y >< coarbitrary z >< coarbitrary v instance (CoArbitrary a, CoArbitrary b, CoArbitrary c, CoArbitrary d, CoArbitrary e) => CoArbitrary (a,b,c,d,e) where coarbitrary (x,y,z,v,w) = coarbitrary x >< coarbitrary y >< coarbitrary z >< coarbitrary v >< coarbitrary w -- typical instance for primitive (numerical) types instance CoArbitrary Integer where coarbitrary = coarbitraryIntegral instance CoArbitrary Int where coarbitrary = coarbitraryIntegral instance CoArbitrary Int8 where coarbitrary = coarbitraryIntegral instance CoArbitrary Int16 where coarbitrary = coarbitraryIntegral instance CoArbitrary Int32 where coarbitrary = coarbitraryIntegral instance CoArbitrary Int64 where coarbitrary = coarbitraryIntegral instance CoArbitrary Word where coarbitrary = coarbitraryIntegral instance CoArbitrary Word8 where coarbitrary = coarbitraryIntegral instance CoArbitrary Word16 where coarbitrary = coarbitraryIntegral instance CoArbitrary Word32 where coarbitrary = coarbitraryIntegral instance CoArbitrary Word64 where coarbitrary = coarbitraryIntegral instance CoArbitrary Char where coarbitrary = coarbitrary . ord instance CoArbitrary Float where coarbitrary = coarbitraryReal instance CoArbitrary Double where coarbitrary = coarbitraryReal -- ** Helpers for implementing coarbitrary -- | A 'coarbitrary' implementation for integral numbers. coarbitraryIntegral :: Integral a => a -> Gen b -> Gen b coarbitraryIntegral = variant -- | A 'coarbitrary' implementation for real numbers. coarbitraryReal :: Real a => a -> Gen b -> Gen b coarbitraryReal x = coarbitrary (toRational x) -- | 'coarbitrary' helper for lazy people :-). coarbitraryShow :: Show a => a -> Gen b -> Gen b coarbitraryShow x = coarbitrary (show x) -------------------------------------------------------------------------- -- ** arbitrary generators -- these are here and not in Gen because of the Arbitrary class constraint -- | Generates a list of a given length. vector :: Arbitrary a => Int -> Gen [a] vector k = vectorOf k arbitrary -- | Generates an ordered list of a given length. orderedList :: (Ord a, Arbitrary a) => Gen [a] orderedList = sort `fmap` arbitrary -------------------------------------------------------------------------- -- the end.
[GOAL] ⊢ StableUnderComposition @FiniteType [PROOFSTEP] introv R hf hg [GOAL] R S T : Type u_1 inst✝² : CommRing R inst✝¹ : CommRing S inst✝ : CommRing T f : R →+* S g : S →+* T hf : FiniteType f hg : FiniteType g ⊢ FiniteType (comp g f) [PROOFSTEP] exact hg.comp hf [GOAL] ⊢ HoldsForLocalizationAway @FiniteType [PROOFSTEP] introv R _ [GOAL] R S : Type u_1 inst✝³ : CommRing R inst✝² : CommRing S inst✝¹ : Algebra R S r : R inst✝ : IsLocalization.Away r S ⊢ FiniteType (algebraMap R S) [PROOFSTEP] suffices Algebra.FiniteType R S by rw [RingHom.FiniteType] convert this; ext; rw [Algebra.smul_def]; rfl [GOAL] R S : Type u_1 inst✝³ : CommRing R inst✝² : CommRing S inst✝¹ : Algebra R S r : R inst✝ : IsLocalization.Away r S this : Algebra.FiniteType R S ⊢ FiniteType (algebraMap R S) [PROOFSTEP] rw [RingHom.FiniteType] [GOAL] R S : Type u_1 inst✝³ : CommRing R inst✝² : CommRing S inst✝¹ : Algebra R S r : R inst✝ : IsLocalization.Away r S this : Algebra.FiniteType R S ⊢ Algebra.FiniteType R S [PROOFSTEP] convert this [GOAL] case h.e'_5 R S : Type u_1 inst✝³ : CommRing R inst✝² : CommRing S inst✝¹ : Algebra R S r : R inst✝ : IsLocalization.Away r S this : Algebra.FiniteType R S ⊢ toAlgebra (algebraMap R S) = inst✝¹ [PROOFSTEP] ext [GOAL] case h.e'_5.h R S : Type u_1 inst✝³ : CommRing R inst✝² : CommRing S inst✝¹ : Algebra R S r : R inst✝ : IsLocalization.Away r S this : Algebra.FiniteType R S r✝ : R x✝ : S ⊢ (let_fun I := toAlgebra (algebraMap R S); r✝ • x✝) = r✝ • x✝ [PROOFSTEP] rw [Algebra.smul_def] [GOAL] case h.e'_5.h R S : Type u_1 inst✝³ : CommRing R inst✝² : CommRing S inst✝¹ : Algebra R S r : R inst✝ : IsLocalization.Away r S this : Algebra.FiniteType R S r✝ : R x✝ : S ⊢ (let_fun I := toAlgebra (algebraMap R S); r✝ • x✝) = ↑(algebraMap R S) r✝ * x✝ [PROOFSTEP] rfl [GOAL] R S : Type u_1 inst✝³ : CommRing R inst✝² : CommRing S inst✝¹ : Algebra R S r : R inst✝ : IsLocalization.Away r S ⊢ Algebra.FiniteType R S [PROOFSTEP] exact IsLocalization.finiteType_of_monoid_fg (Submonoid.powers r) S [GOAL] ⊢ OfLocalizationSpanTarget @FiniteType [PROOFSTEP] rw [ofLocalizationSpanTarget_iff_finite] [GOAL] ⊢ OfLocalizationFiniteSpanTarget @FiniteType [PROOFSTEP] introv R hs H [GOAL] R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ H : ∀ (r : { x // x ∈ s }), FiniteType (comp (algebraMap S (Localization.Away ↑r)) f) ⊢ FiniteType f [PROOFSTEP] classical letI := f.toAlgebra replace H : ∀ r : s, Algebra.FiniteType R (Localization.Away (r : S)) · intro r; simp_rw [RingHom.FiniteType] at H ; convert H r; ext; simp_rw [Algebra.smul_def]; rfl replace H := fun r => (H r).1 constructor -- Suppose `s : Finset S` spans `S`, and each `Sᵣ` is finitely generated as an `R`-algebra. -- Say `t r : Finset Sᵣ` generates `Sᵣ`. By assumption, we may find `lᵢ` such that -- `∑ lᵢ * sᵢ = 1`. I claim that all `s` and `l` and the numerators of `t` and generates `S`. choose t ht using H obtain ⟨l, hl⟩ := (Finsupp.mem_span_iff_total S (s : Set S) 1).mp (show (1 : S) ∈ Ideal.span (s : Set S) by rw [hs]; trivial) let sf := fun x : s => IsLocalization.finsetIntegerMultiple (Submonoid.powers (x : S)) (t x) use s.attach.biUnion sf ∪ s ∪ l.support.image l rw [eq_top_iff] -- We need to show that every `x` falls in the subalgebra generated by those elements. -- Since all `s` and `l` are in the subalgebra, it suffices to check that `sᵢ ^ nᵢ • x` falls in -- the algebra for each `sᵢ` and some `nᵢ`. rintro x - apply Subalgebra.mem_of_span_eq_top_of_smul_pow_mem _ (s : Set S) l hl _ _ x _ · intro x hx apply Algebra.subset_adjoin rw [Finset.coe_union, Finset.coe_union] exact Or.inl (Or.inr hx) · intro i by_cases h : l i = 0; · rw [h]; exact zero_mem _ apply Algebra.subset_adjoin rw [Finset.coe_union, Finset.coe_image] exact Or.inr (Set.mem_image_of_mem _ (Finsupp.mem_support_iff.mpr h)) · intro r rw [Finset.coe_union, Finset.coe_union, Finset.coe_biUnion] -- Since all `sᵢ` and numerators of `t r` are in the algebra, it suffices to show that the -- image of `x` in `Sᵣ` falls in the `R`-adjoin of `t r`, which is of course true. -- Porting note: The following `obtain` fails because Lean wants to know right away what the -- placeholders are, so we need to provide a little more guidance -- obtain ⟨⟨_, n₂, rfl⟩, hn₂⟩ := IsLocalization.exists_smul_mem_of_mem_adjoin -- (Submonoid.powers (r : S)) x (t r) (Algebra.adjoin R _) _ _ _ rw [show ∀ A : Set S, (∃ n, (r : S) ^ n • x ∈ Algebra.adjoin R A) ↔ (∃ m : (Submonoid.powers (r : S)), (m : S) • x ∈ Algebra.adjoin R A) by {exact fun _ => by simp [Submonoid.mem_powers_iff] }] refine IsLocalization.exists_smul_mem_of_mem_adjoin (Submonoid.powers (r : S)) x (t r) (Algebra.adjoin R _) ?_ ?_ ?_ · intro x hx apply Algebra.subset_adjoin exact Or.inl (Or.inl ⟨_, ⟨r, rfl⟩, _, ⟨s.mem_attach r, rfl⟩, hx⟩) · rw [Submonoid.powers_eq_closure, Submonoid.closure_le, Set.singleton_subset_iff] apply Algebra.subset_adjoin exact Or.inl (Or.inr r.2) · rw [ht]; trivial [GOAL] R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ H : ∀ (r : { x // x ∈ s }), FiniteType (comp (algebraMap S (Localization.Away ↑r)) f) ⊢ FiniteType f [PROOFSTEP] letI := f.toAlgebra [GOAL] R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ H : ∀ (r : { x // x ∈ s }), FiniteType (comp (algebraMap S (Localization.Away ↑r)) f) this : Algebra R S := toAlgebra f ⊢ FiniteType f [PROOFSTEP] replace H : ∀ r : s, Algebra.FiniteType R (Localization.Away (r : S)) [GOAL] case H R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ H : ∀ (r : { x // x ∈ s }), FiniteType (comp (algebraMap S (Localization.Away ↑r)) f) this : Algebra R S := toAlgebra f ⊢ ∀ (r : { x // x ∈ s }), Algebra.FiniteType R (Localization.Away ↑r) [PROOFSTEP] intro r [GOAL] case H R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ H : ∀ (r : { x // x ∈ s }), FiniteType (comp (algebraMap S (Localization.Away ↑r)) f) this : Algebra R S := toAlgebra f r : { x // x ∈ s } ⊢ Algebra.FiniteType R (Localization.Away ↑r) [PROOFSTEP] simp_rw [RingHom.FiniteType] at H [GOAL] case H R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ H : ∀ (r : { x // x ∈ s }), Algebra.FiniteType R (Localization.Away ↑r) this : Algebra R S := toAlgebra f r : { x // x ∈ s } ⊢ Algebra.FiniteType R (Localization.Away ↑r) [PROOFSTEP] convert H r [GOAL] case h.e'_5 R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ H : ∀ (r : { x // x ∈ s }), Algebra.FiniteType R (Localization.Away ↑r) this : Algebra R S := toAlgebra f r : { x // x ∈ s } ⊢ Localization.algebra = toAlgebra (comp (algebraMap S (Localization.Away ↑r)) f) [PROOFSTEP] ext [GOAL] case h.e'_5.h R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ H : ∀ (r : { x // x ∈ s }), Algebra.FiniteType R (Localization.Away ↑r) this : Algebra R S := toAlgebra f r : { x // x ∈ s } r✝ : R x✝ : Localization (Submonoid.powers ↑r) ⊢ (let_fun I := Localization.algebra; r✝ • x✝) = r✝ • x✝ [PROOFSTEP] simp_rw [Algebra.smul_def] [GOAL] case h.e'_5.h R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ H : ∀ (r : { x // x ∈ s }), Algebra.FiniteType R (Localization.Away ↑r) this : Algebra R S := toAlgebra f r : { x // x ∈ s } r✝ : R x✝ : Localization (Submonoid.powers ↑r) ⊢ ↑(algebraMap R (Localization (Submonoid.powers ↑r))) r✝ * x✝ = r✝ • x✝ [PROOFSTEP] rfl [GOAL] R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f H : ∀ (r : { x // x ∈ s }), Algebra.FiniteType R (Localization.Away ↑r) ⊢ FiniteType f [PROOFSTEP] replace H := fun r => (H r).1 [GOAL] R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f H : ∀ (r : { x // x ∈ s }), Subalgebra.FG ⊤ ⊢ FiniteType f [PROOFSTEP] constructor -- Suppose `s : Finset S` spans `S`, and each `Sᵣ` is finitely generated as an `R`-algebra. -- Say `t r : Finset Sᵣ` generates `Sᵣ`. By assumption, we may find `lᵢ` such that -- `∑ lᵢ * sᵢ = 1`. I claim that all `s` and `l` and the numerators of `t` and generates `S`. [GOAL] case out R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f H : ∀ (r : { x // x ∈ s }), Subalgebra.FG ⊤ ⊢ Subalgebra.FG ⊤ [PROOFSTEP] choose t ht using H [GOAL] case out R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ ⊢ Subalgebra.FG ⊤ [PROOFSTEP] obtain ⟨l, hl⟩ := (Finsupp.mem_span_iff_total S (s : Set S) 1).mp (show (1 : S) ∈ Ideal.span (s : Set S) by rw [hs]; trivial) [GOAL] R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ ⊢ 1 ∈ Ideal.span ↑s [PROOFSTEP] rw [hs] [GOAL] R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ ⊢ 1 ∈ ⊤ [PROOFSTEP] trivial [GOAL] case out.intro R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 ⊢ Subalgebra.FG ⊤ [PROOFSTEP] let sf := fun x : s => IsLocalization.finsetIntegerMultiple (Submonoid.powers (x : S)) (t x) [GOAL] case out.intro R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) ⊢ Subalgebra.FG ⊤ [PROOFSTEP] use s.attach.biUnion sf ∪ s ∪ l.support.image l [GOAL] case h R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) ⊢ Algebra.adjoin R ↑(Finset.biUnion (Finset.attach s) sf ∪ s ∪ Finset.image (↑l) l.support) = ⊤ [PROOFSTEP] rw [eq_top_iff] -- We need to show that every `x` falls in the subalgebra generated by those elements. -- Since all `s` and `l` are in the subalgebra, it suffices to check that `sᵢ ^ nᵢ • x` falls in -- the algebra for each `sᵢ` and some `nᵢ`. [GOAL] case h R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) ⊢ ⊤ ≤ Algebra.adjoin R ↑(Finset.biUnion (Finset.attach s) sf ∪ s ∪ Finset.image (↑l) l.support) [PROOFSTEP] rintro x - [GOAL] case h R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) x : S ⊢ x ∈ Algebra.adjoin R ↑(Finset.biUnion (Finset.attach s) sf ∪ s ∪ Finset.image (↑l) l.support) [PROOFSTEP] apply Subalgebra.mem_of_span_eq_top_of_smul_pow_mem _ (s : Set S) l hl _ _ x _ [GOAL] R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) x : S ⊢ ↑s ⊆ ↑(Algebra.adjoin R ↑(Finset.biUnion (Finset.attach s) sf ∪ s ∪ Finset.image (↑l) l.support)) [PROOFSTEP] intro x hx [GOAL] R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) x✝ x : S hx : x ∈ ↑s ⊢ x ∈ ↑(Algebra.adjoin R ↑(Finset.biUnion (Finset.attach s) sf ∪ s ∪ Finset.image (↑l) l.support)) [PROOFSTEP] apply Algebra.subset_adjoin [GOAL] case a R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) x✝ x : S hx : x ∈ ↑s ⊢ x ∈ ↑(Finset.biUnion (Finset.attach s) sf ∪ s ∪ Finset.image (↑l) l.support) [PROOFSTEP] rw [Finset.coe_union, Finset.coe_union] [GOAL] case a R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) x✝ x : S hx : x ∈ ↑s ⊢ x ∈ ↑(Finset.biUnion (Finset.attach s) sf) ∪ ↑s ∪ ↑(Finset.image (↑l) l.support) [PROOFSTEP] exact Or.inl (Or.inr hx) [GOAL] R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) x : S ⊢ ∀ (i : ↑↑s), ↑l i ∈ Algebra.adjoin R ↑(Finset.biUnion (Finset.attach s) sf ∪ s ∪ Finset.image (↑l) l.support) [PROOFSTEP] intro i [GOAL] R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) x : S i : ↑↑s ⊢ ↑l i ∈ Algebra.adjoin R ↑(Finset.biUnion (Finset.attach s) sf ∪ s ∪ Finset.image (↑l) l.support) [PROOFSTEP] by_cases h : l i = 0 [GOAL] case pos R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) x : S i : ↑↑s h : ↑l i = 0 ⊢ ↑l i ∈ Algebra.adjoin R ↑(Finset.biUnion (Finset.attach s) sf ∪ s ∪ Finset.image (↑l) l.support) [PROOFSTEP] rw [h] [GOAL] case pos R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) x : S i : ↑↑s h : ↑l i = 0 ⊢ 0 ∈ Algebra.adjoin R ↑(Finset.biUnion (Finset.attach s) sf ∪ s ∪ Finset.image (↑l) l.support) [PROOFSTEP] exact zero_mem _ [GOAL] case neg R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) x : S i : ↑↑s h : ¬↑l i = 0 ⊢ ↑l i ∈ Algebra.adjoin R ↑(Finset.biUnion (Finset.attach s) sf ∪ s ∪ Finset.image (↑l) l.support) [PROOFSTEP] apply Algebra.subset_adjoin [GOAL] case neg.a R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) x : S i : ↑↑s h : ¬↑l i = 0 ⊢ ↑l i ∈ ↑(Finset.biUnion (Finset.attach s) sf ∪ s ∪ Finset.image (↑l) l.support) [PROOFSTEP] rw [Finset.coe_union, Finset.coe_image] [GOAL] case neg.a R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) x : S i : ↑↑s h : ¬↑l i = 0 ⊢ ↑l i ∈ ↑(Finset.biUnion (Finset.attach s) sf ∪ s) ∪ ↑l '' ↑l.support [PROOFSTEP] exact Or.inr (Set.mem_image_of_mem _ (Finsupp.mem_support_iff.mpr h)) [GOAL] R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) x : S ⊢ ∀ (r : ↑↑s), ∃ n, ↑r ^ n • x ∈ Algebra.adjoin R ↑(Finset.biUnion (Finset.attach s) sf ∪ s ∪ Finset.image (↑l) l.support) [PROOFSTEP] intro r [GOAL] R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) x : S r : ↑↑s ⊢ ∃ n, ↑r ^ n • x ∈ Algebra.adjoin R ↑(Finset.biUnion (Finset.attach s) sf ∪ s ∪ Finset.image (↑l) l.support) [PROOFSTEP] rw [Finset.coe_union, Finset.coe_union, Finset.coe_biUnion] -- Since all `sᵢ` and numerators of `t r` are in the algebra, it suffices to show that the -- image of `x` in `Sᵣ` falls in the `R`-adjoin of `t r`, which is of course true. -- Porting note: The following `obtain` fails because Lean wants to know right away what the -- placeholders are, so we need to provide a little more guidance -- obtain ⟨⟨_, n₂, rfl⟩, hn₂⟩ := IsLocalization.exists_smul_mem_of_mem_adjoin -- (Submonoid.powers (r : S)) x (t r) (Algebra.adjoin R _) _ _ _ [GOAL] R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) x : S r : ↑↑s ⊢ ∃ n, ↑r ^ n • x ∈ Algebra.adjoin R ((⋃ (x : { x // x ∈ s }) (_ : x ∈ ↑(Finset.attach s)), ↑(sf x)) ∪ ↑s ∪ ↑(Finset.image (↑l) l.support)) [PROOFSTEP] rw [show ∀ A : Set S, (∃ n, (r : S) ^ n • x ∈ Algebra.adjoin R A) ↔ (∃ m : (Submonoid.powers (r : S)), (m : S) • x ∈ Algebra.adjoin R A) by {exact fun _ => by simp [Submonoid.mem_powers_iff] }] [GOAL] R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) x : S r : ↑↑s ⊢ ∀ (A : Set S), (∃ n, ↑r ^ n • x ∈ Algebra.adjoin R A) ↔ ∃ m, ↑m • x ∈ Algebra.adjoin R A [PROOFSTEP] {exact fun _ => by simp [Submonoid.mem_powers_iff] } [GOAL] R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) x : S r : ↑↑s ⊢ ∀ (A : Set S), (∃ n, ↑r ^ n • x ∈ Algebra.adjoin R A) ↔ ∃ m, ↑m • x ∈ Algebra.adjoin R A [PROOFSTEP] exact fun _ => by simp [Submonoid.mem_powers_iff] [GOAL] R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) x : S r : ↑↑s x✝ : Set S ⊢ (∃ n, ↑r ^ n • x ∈ Algebra.adjoin R x✝) ↔ ∃ m, ↑m • x ∈ Algebra.adjoin R x✝ [PROOFSTEP] simp [Submonoid.mem_powers_iff] [GOAL] R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) x : S r : ↑↑s ⊢ ∃ m, ↑m • x ∈ Algebra.adjoin R ((⋃ (x : { x // x ∈ s }) (_ : x ∈ ↑(Finset.attach s)), ↑(sf x)) ∪ ↑s ∪ ↑(Finset.image (↑l) l.support)) [PROOFSTEP] refine IsLocalization.exists_smul_mem_of_mem_adjoin (Submonoid.powers (r : S)) x (t r) (Algebra.adjoin R _) ?_ ?_ ?_ [GOAL] case refine_1 R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) x : S r : ↑↑s ⊢ ↑(IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑r) (t r)) ⊆ ↑(Algebra.adjoin R ((⋃ (x : { x // x ∈ s }) (_ : x ∈ ↑(Finset.attach s)), ↑(sf x)) ∪ ↑s ∪ ↑(Finset.image (↑l) l.support))) [PROOFSTEP] intro x hx [GOAL] case refine_1 R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) x✝ : S r : ↑↑s x : S hx : x ∈ ↑(IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑r) (t r)) ⊢ x ∈ ↑(Algebra.adjoin R ((⋃ (x : { x // x ∈ s }) (_ : x ∈ ↑(Finset.attach s)), ↑(sf x)) ∪ ↑s ∪ ↑(Finset.image (↑l) l.support))) [PROOFSTEP] apply Algebra.subset_adjoin [GOAL] case refine_1.a R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) x✝ : S r : ↑↑s x : S hx : x ∈ ↑(IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑r) (t r)) ⊢ x ∈ (⋃ (x : { x // x ∈ s }) (_ : x ∈ ↑(Finset.attach s)), ↑(sf x)) ∪ ↑s ∪ ↑(Finset.image (↑l) l.support) [PROOFSTEP] exact Or.inl (Or.inl ⟨_, ⟨r, rfl⟩, _, ⟨s.mem_attach r, rfl⟩, hx⟩) [GOAL] case refine_2 R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) x : S r : ↑↑s ⊢ Submonoid.powers ↑r ≤ (Algebra.adjoin R ((⋃ (x : { x // x ∈ s }) (_ : x ∈ ↑(Finset.attach s)), ↑(sf x)) ∪ ↑s ∪ ↑(Finset.image (↑l) l.support))).toSubsemiring.toSubmonoid [PROOFSTEP] rw [Submonoid.powers_eq_closure, Submonoid.closure_le, Set.singleton_subset_iff] [GOAL] case refine_2 R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) x : S r : ↑↑s ⊢ ↑r ∈ ↑(Algebra.adjoin R ((⋃ (x : { x // x ∈ s }) (_ : x ∈ ↑(Finset.attach s)), ↑(sf x)) ∪ ↑s ∪ ↑(Finset.image (↑l) l.support))).toSubsemiring.toSubmonoid [PROOFSTEP] apply Algebra.subset_adjoin [GOAL] case refine_2.a R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) x : S r : ↑↑s ⊢ ↑r ∈ (⋃ (x : { x // x ∈ s }) (_ : x ∈ ↑(Finset.attach s)), ↑(sf x)) ∪ ↑s ∪ ↑(Finset.image (↑l) l.support) [PROOFSTEP] exact Or.inl (Or.inr r.2) [GOAL] case refine_3 R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) x : S r : ↑↑s ⊢ ↑(algebraMap S (Localization.Away ↑r)) x ∈ Algebra.adjoin R ↑(t r) [PROOFSTEP] rw [ht] [GOAL] case refine_3 R S : Type u_1 inst✝¹ : CommRing R inst✝ : CommRing S f : R →+* S s : Finset S hs : Ideal.span ↑s = ⊤ this : Algebra R S := toAlgebra f t : (r : { x // x ∈ s }) → Finset (Localization.Away ↑r) ht : ∀ (r : { x // x ∈ s }), Algebra.adjoin R ↑(t r) = ⊤ l : ↑↑s →₀ S hl : ↑(Finsupp.total (↑↑s) S S Subtype.val) l = 1 sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers ↑x) (t x) x : S r : ↑↑s ⊢ ↑(algebraMap S (Localization.Away ↑r)) x ∈ ⊤ [PROOFSTEP] trivial
/- Copyright (c) 2020 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import ring_theory.matrix_algebra import data.polynomial.algebra_map /-! # Algebra isomorphism between matrices of polynomials and polynomials of matrices Given `[comm_ring R] [ring A] [algebra R A]` we show `polynomial A ≃ₐ[R] (A ⊗[R] polynomial R)`. Combining this with the isomorphism `matrix n n A ≃ₐ[R] (A ⊗[R] matrix n n R)` proved earlier in `ring_theory.matrix_algebra`, we obtain the algebra isomorphism ``` def mat_poly_equiv : matrix n n (polynomial R) ≃ₐ[R] polynomial (matrix n n R) ``` which is characterized by ``` coeff (mat_poly_equiv m) k i j = coeff (m i j) k ``` We will use this algebra isomorphism to prove the Cayley-Hamilton theorem. -/ universes u v w open_locale tensor_product open polynomial open tensor_product open algebra.tensor_product (alg_hom_of_linear_map_tensor_product include_left) noncomputable theory variables (R A : Type*) variables [comm_semiring R] variables [semiring A] [algebra R A] namespace poly_equiv_tensor /-- (Implementation detail). The bare function underlying `A ⊗[R] polynomial R →ₐ[R] polynomial A`, on pure tensors. -/ def to_fun (a : A) (p : polynomial R) : polynomial A := p.sum (λ n r, monomial n (a * algebra_map R A r)) /-- (Implementation detail). The function underlying `A ⊗[R] polynomial R →ₐ[R] polynomial A`, as a linear map in the second factor. -/ def to_fun_linear_right (a : A) : polynomial R →ₗ[R] polynomial A := { to_fun := to_fun R A a, map_smul' := λ r p, begin dsimp [to_fun], rw finsupp.sum_smul_index, { dsimp [finsupp.sum], rw finset.smul_sum, apply finset.sum_congr rfl, intros k hk, rw [monomial_eq_smul_X, monomial_eq_smul_X, algebra.smul_def, ← C_mul', ← C_mul', ← mul_assoc], congr' 1, rw [← algebra.commutes, ← algebra.commutes], simp only [ring_hom.map_mul, polynomial.algebra_map_apply, mul_assoc], }, { intro i, simp only [ring_hom.map_zero, mul_zero, monomial_zero_right] }, end, map_add' := λ p q, begin simp only [to_fun], rw finsupp.sum_add_index, { simp only [monomial_zero_right, forall_const, ring_hom.map_zero, mul_zero], }, { intros i r s, simp only [ring_hom.map_add, mul_add, monomial_add], }, end, } /-- (Implementation detail). The function underlying `A ⊗[R] polynomial R →ₐ[R] polynomial A`, as a bilinear function of two arguments. -/ def to_fun_bilinear : A →ₗ[R] polynomial R →ₗ[R] polynomial A := { to_fun := to_fun_linear_right R A, map_smul' := by { intros, unfold to_fun_linear_right, congr, simp only [linear_map.coe_mk], unfold to_fun finsupp.sum, simp_rw [finset.smul_sum, smul_monomial, ← algebra.smul_mul_assoc], refl }, map_add' := by { intros, unfold to_fun_linear_right, congr, simp only [linear_map.coe_mk], unfold to_fun finsupp.sum, simp_rw [← finset.sum_add_distrib, ← monomial_add, ← add_mul], refl } } /-- (Implementation detail). The function underlying `A ⊗[R] polynomial R →ₐ[R] polynomial A`, as a linear map. -/ def to_fun_linear : A ⊗[R] polynomial R →ₗ[R] polynomial A := tensor_product.lift (to_fun_bilinear R A) -- We apparently need to provide the decidable instance here -- in order to successfully rewrite by this lemma. lemma to_fun_linear_mul_tmul_mul_aux_1 (p : polynomial R) (k : ℕ) (h : decidable (¬p.coeff k = 0)) (a : A) : ite (¬coeff p k = 0) (a * (algebra_map R A) (coeff p k)) 0 = a * (algebra_map R A) (coeff p k) := by { classical, split_ifs; simp *, } lemma to_fun_linear_mul_tmul_mul_aux_2 (k : ℕ) (a₁ a₂ : A) (p₁ p₂ : polynomial R) : a₁ * a₂ * (algebra_map R A) ((p₁ * p₂).coeff k) = (finset.nat.antidiagonal k).sum (λ x, a₁ * (algebra_map R A) (coeff p₁ x.1) * (a₂ * (algebra_map R A) (coeff p₂ x.2))) := begin simp_rw [mul_assoc, algebra.commutes, ←finset.mul_sum, mul_assoc, ←finset.mul_sum], congr, simp_rw [algebra.commutes (coeff p₂ _), coeff_mul, ring_hom.map_sum, ring_hom.map_mul], end lemma to_fun_linear_mul_tmul_mul (a₁ a₂ : A) (p₁ p₂ : polynomial R) : (to_fun_linear R A) ((a₁ * a₂) ⊗ₜ[R] (p₁ * p₂)) = (to_fun_linear R A) (a₁ ⊗ₜ[R] p₁) * (to_fun_linear R A) (a₂ ⊗ₜ[R] p₂) := begin dsimp [to_fun_linear], simp only [lift.tmul], dsimp [to_fun_bilinear, to_fun_linear_right, to_fun], ext k, -- TODO This is a bit annoying: the polynomial API is breaking down. have apply_eq_coeff : ∀ {p : ℕ →₀ R} {n : ℕ}, p n = coeff p n := by { intros, refl }, simp_rw [coeff_sum, coeff_monomial, finsupp.sum, finset.sum_ite_eq', finsupp.mem_support_iff, ne.def, coeff_mul, finset_sum_coeff, coeff_monomial, finset.sum_ite_eq', finsupp.mem_support_iff, ne.def, mul_ite, mul_zero, ite_mul, zero_mul, apply_eq_coeff], simp_rw [ite_mul_zero_left (¬coeff p₁ _ = 0) (a₁ * (algebra_map R A) (coeff p₁ _))], simp_rw [ite_mul_zero_right (¬coeff p₂ _ = 0) _ (_ * _)], simp_rw [to_fun_linear_mul_tmul_mul_aux_1, to_fun_linear_mul_tmul_mul_aux_2], end lemma to_fun_linear_algebra_map_tmul_one (r : R) : (to_fun_linear R A) ((algebra_map R A) r ⊗ₜ[R] 1) = (algebra_map R (polynomial A)) r := begin dsimp [to_fun_linear], simp only [lift.tmul], dsimp [to_fun_bilinear, to_fun_linear_right, to_fun], rw [← C_1, ←monomial_zero_left], refine (finsupp.sum_single_index _).trans _; simp [algebra_map_apply] end /-- (Implementation detail). The algebra homomorphism `A ⊗[R] polynomial R →ₐ[R] polynomial A`. -/ def to_fun_alg_hom : A ⊗[R] polynomial R →ₐ[R] polynomial A := alg_hom_of_linear_map_tensor_product (to_fun_linear R A) (to_fun_linear_mul_tmul_mul R A) (to_fun_linear_algebra_map_tmul_one R A) @[simp] lemma to_fun_alg_hom_apply_tmul (a : A) (p : polynomial R) : to_fun_alg_hom R A (a ⊗ₜ[R] p) = p.sum (λ n r, monomial n (a * (algebra_map R A) r)) := by simp [to_fun_alg_hom, to_fun_linear, to_fun_bilinear, to_fun_linear_right, to_fun] /-- (Implementation detail.) The bare function `polynomial A → A ⊗[R] polynomial R`. (We don't need to show that it's an algebra map, thankfully --- just that it's an inverse.) -/ def inv_fun (p : polynomial A) : A ⊗[R] polynomial R := p.eval₂ (include_left : A →ₐ[R] A ⊗[R] polynomial R) ((1 : A) ⊗ₜ[R] (X : polynomial R)) @[simp] lemma inv_fun_add {p q} : inv_fun R A (p + q) = inv_fun R A p + inv_fun R A q := by simp only [inv_fun, eval₂_add] lemma inv_fun_monomial (n : ℕ) (a : A) : inv_fun R A (monomial n a) = include_left a * ((1 : A) ⊗ₜ[R] (X : polynomial R)) ^ n := eval₂_monomial _ _ lemma left_inv (x : A ⊗ polynomial R) : inv_fun R A ((to_fun_alg_hom R A) x) = x := begin apply tensor_product.induction_on x, { simp [inv_fun], }, { intros a p, dsimp only [inv_fun], rw [to_fun_alg_hom_apply_tmul, eval₂_sum], simp_rw [eval₂_monomial, alg_hom.coe_to_ring_hom, algebra.tensor_product.tmul_pow, one_pow, algebra.tensor_product.include_left_apply, algebra.tensor_product.tmul_mul_tmul, mul_one, one_mul, ←algebra.commutes, ←algebra.smul_def'', smul_tmul], rw [finsupp.sum, ←tmul_sum], conv_rhs { rw [←sum_C_mul_X_eq p], }, simp only [algebra.smul_def''], refl, }, { intros p q hp hq, simp only [alg_hom.map_add, inv_fun_add, hp, hq], }, end lemma right_inv (x : polynomial A) : (to_fun_alg_hom R A) (inv_fun R A x) = x := begin apply polynomial.induction_on' x, { intros p q hp hq, simp only [inv_fun_add, alg_hom.map_add, hp, hq], }, { intros n a, rw [inv_fun_monomial, algebra.tensor_product.include_left_apply, algebra.tensor_product.tmul_pow, one_pow, algebra.tensor_product.tmul_mul_tmul, mul_one, one_mul, to_fun_alg_hom_apply_tmul, X_pow_eq_monomial], dsimp [monomial], rw [finsupp.sum_single_index]; simp, } end /-- (Implementation detail) The equivalence, ignoring the algebra structure, `(A ⊗[R] polynomial R) ≃ polynomial A`. -/ def equiv : (A ⊗[R] polynomial R) ≃ polynomial A := { to_fun := to_fun_alg_hom R A, inv_fun := inv_fun R A, left_inv := left_inv R A, right_inv := right_inv R A, } end poly_equiv_tensor open poly_equiv_tensor /-- The `R`-algebra isomorphism `polynomial A ≃ₐ[R] (A ⊗[R] polynomial R)`. -/ def poly_equiv_tensor : polynomial A ≃ₐ[R] (A ⊗[R] polynomial R) := alg_equiv.symm { ..(poly_equiv_tensor.to_fun_alg_hom R A), ..(poly_equiv_tensor.equiv R A) } @[simp] lemma poly_equiv_tensor_apply (p : polynomial A) : poly_equiv_tensor R A p = p.eval₂ (include_left : A →ₐ[R] A ⊗[R] polynomial R) ((1 : A) ⊗ₜ[R] (X : polynomial R)) := rfl @[simp] lemma poly_equiv_tensor_symm_apply_tmul (a : A) (p : polynomial R) : (poly_equiv_tensor R A).symm (a ⊗ₜ p) = p.sum (λ n r, monomial n (a * algebra_map R A r)) := begin simp [poly_equiv_tensor, to_fun_alg_hom, alg_hom_of_linear_map_tensor_product, to_fun_linear], refl, end open dmatrix matrix open_locale big_operators variables {R} variables {n : Type w} [decidable_eq n] [fintype n] /-- The algebra isomorphism stating "matrices of polynomials are the same as polynomials of matrices". (You probably shouldn't attempt to use this underlying definition --- it's an algebra equivalence, and characterised extensionally by the lemma `mat_poly_equiv_coeff_apply` below.) -/ noncomputable def mat_poly_equiv : matrix n n (polynomial R) ≃ₐ[R] polynomial (matrix n n R) := (((matrix_equiv_tensor R (polynomial R) n)).trans (algebra.tensor_product.comm R _ _)).trans (poly_equiv_tensor R (matrix n n R)).symm open finset lemma mat_poly_equiv_coeff_apply_aux_1 (i j : n) (k : ℕ) (x : R) : mat_poly_equiv (std_basis_matrix i j $ monomial k x) = monomial k (std_basis_matrix i j x) := begin simp only [mat_poly_equiv, alg_equiv.trans_apply, matrix_equiv_tensor_apply_std_basis], apply (poly_equiv_tensor R (matrix n n R)).injective, simp only [alg_equiv.apply_symm_apply], convert algebra.tensor_product.comm_tmul _ _ _ _ _, simp only [poly_equiv_tensor_apply], convert eval₂_monomial _ _, simp only [algebra.tensor_product.tmul_mul_tmul, one_pow, one_mul, matrix.mul_one, algebra.tensor_product.tmul_pow, algebra.tensor_product.include_left_apply, mul_eq_mul], rw [monomial_eq_smul_X, ← tensor_product.smul_tmul], congr' with i' j'; simp end lemma mat_poly_equiv_coeff_apply_aux_2 (i j : n) (p : polynomial R) (k : ℕ) : coeff (mat_poly_equiv (std_basis_matrix i j p)) k = std_basis_matrix i j (coeff p k) := begin apply polynomial.induction_on' p, { intros p q hp hq, ext, simp [hp, hq, coeff_add, add_apply, std_basis_matrix_add], }, { intros k x, simp only [mat_poly_equiv_coeff_apply_aux_1, coeff_monomial], split_ifs; { funext, simp, }, } end @[simp] lemma mat_poly_equiv_coeff_apply (m : matrix n n (polynomial R)) (k : ℕ) (i j : n) : coeff (mat_poly_equiv m) k i j = coeff (m i j) k := begin apply matrix.induction_on' m, { simp, }, { intros p q hp hq, simp [hp, hq], }, { intros i' j' x, erw mat_poly_equiv_coeff_apply_aux_2, dsimp [std_basis_matrix], split_ifs, { rcases h with ⟨rfl, rfl⟩, simp [std_basis_matrix], }, { simp [std_basis_matrix, h], }, }, end @[simp] lemma mat_poly_equiv_symm_apply_coeff (p : polynomial (matrix n n R)) (i j : n) (k : ℕ) : coeff (mat_poly_equiv.symm p i j) k = coeff p k i j := begin have t : p = mat_poly_equiv (mat_poly_equiv.symm p) := by simp, conv_rhs { rw t, }, simp only [mat_poly_equiv_coeff_apply], end lemma mat_poly_equiv_smul_one (p : polynomial R) : mat_poly_equiv (p • 1) = p.map (algebra_map R (matrix n n R)) := begin ext m i j, simp only [coeff_map, one_apply, algebra_map_matrix_apply, mul_boole, smul_apply, mat_poly_equiv_coeff_apply], split_ifs; simp, end
SUBROUTINE MGPLOT(IHARD,NL,PDATA) C DIMENSION PDATA(500,3) CHARACTER*20 CH(20) C CH(1) = 'TERMINAL 3' IF(IHARD.EQ.1) CH(1) = 'PRINTER 6' CH(2) = 'LINES 1 359' CH(3) = 'XCOLUMN 1' CH(4) = 'YCOLUMN 2' CH(5) = 'LIMITS' CH(6) = 'CONNECT' CH(7) = 'BOX' CH(8) = 'XLABEL ANGLE TO SUN' CH(9) = 'ID' CH(10) = 'END' IF(IHARD.EQ.1) THEN CH(10) = 'HARDCOPY' CH(11) = 'END' ENDIF CALL MONGO(10+IHARD,CH,500,3,PDATA) RETURN END
module TypeTrans.AST import Data.Vect -- Define Type Aliases Rule : Type Rule = String Name : Type Name = String Value : Type Value = String Assoc : Type Assoc = Bool Performance : Type Performance = Float Cost : Type Cost = Float data Variant = Par | Seq | Stream | Tree implementation Show Variant where show Par = "Par" show Seq = "Seq" show Stream = "Stream" show Tree = "Tree" data TypeT = Vec Nat TypeT | Tuple (List TypeT) | IntT | ByteT | BitT | LongT | FloatT | DoubleT | BoolT | T1 | T2 | T3 implementation Show TypeT where show (Vec i t) = "Vec " ++ show i ++ " (" ++ show t ++ ")" show (Tuple xs) = "Tuple " ++ show xs show IntT = "Int" show ByteT = "Byte" show BitT = "Bit" show LongT = "Long" show FloatT = "Float" show DoubleT = "Double" show BoolT = "Bool" show T1 = "T1" show T2 = "T2" show T3 = "T3" -- Vector with description of its dimensions in the type --NVec : Vect n Nat -> TypeT -> TypeT --NVec Nil t = t --NVec (v::vs) t = Vec v (NVec vs t) -- Calculate the dimension of the given type getDimension : TypeT -> Nat getDimension (Vec i t) = (S Z) + getDimension t getDimension _ = Z -- Non vector types have dimension 0 mutual -- Argument is not a very good name. I mean something of type a as opposed to a -> b for the actions data Argument = Arg Name TypeT | Val Value TypeT | Res Action Argument | Let (List (Argument,Argument)) Argument -- let like this is not an action, it's only an action if I do \x -> let ... x ... in ... i.e. Lambda x (let ...) implementation Show Argument where show (Arg n t) = "Arg " ++ n ++ " " ++ show t show (Val v t) = "Val " ++ v ++ " " ++ show t show (Res act arg) = "Res " ++ show act ++ " " ++ show arg show (Let xs arg) = "Let " ++ show xs ++ " " ++ show arg data Action = Opaque Name (List Argument) Argument TypeT (Performance,Cost) | -- [Type] is for constant args to map or fold, the first Type is the input arg, the last Type the return type OpaqueBin Assoc Name (List Argument) Argument Argument (Performance,Cost) | Map Variant Action | Fold Variant Action Argument | -- Argument here is the accumulator, and action must be a binary operation, not unary Compose (List Action) | -- Lambda (List Argument) (Action) ? Lambda (List Argument) Argument | -- (\(x,y) -> map (g x) y) becomes Lambda [x,y] (Map g x) y so the last Argument is usually a Res Loop Action Action | Split Int | Merge Int | Distr Int Int | Group (List (Argument, List Rule)) | Ungroup (List (Argument, List Rule)) | Zip (List TypeT) | -- this should really only work on a set of vectors and return a Vec (Tuple [Type]) Int Unzip TypeT -- This should really only work on a Tuple [Vec Type Int] implementation Show Action where show (Opaque n xs arg t pc) = "Opaque " ++ n ++ " " ++ show xs ++ " " ++ show arg ++ " "++ show t ++ " " ++ show pc show (OpaqueBin a n xs arg1 arg2 pc) = "Opaque " ++ show a ++ " " ++ n ++ " " ++ show arg1 ++ " " ++ show arg2 ++ " " ++ show pc show (Map v act) = "Map " ++ show v ++ " " ++ show act show (Fold v act arg) = "Fold " ++ show v ++ " " ++ show act ++ " " ++ show arg show (Compose xs) = "Compose " ++ show xs show (Lambda xs act) = "Lambda " ++ show xs ++ " " ++ show act show (Loop act1 act2) = "Loop " ++ show act1 ++ " " ++ show act2 show (Split i) = "Split " ++ show i show (Merge i) = "Merge " ++ show i show (Distr i1 i2) = "Distr " ++ show i1 ++ " " ++ show i2 show (Group xs) = "Group " ++ show xs show (Ungroup xs) = "Ungroup " ++ show xs show (Zip xs) = "Zip " ++ show xs show (Unzip t) = "Unzip " ++ show t -- We also need Zip, Unzip and Let --data FoldAction = deriving Show-- No need for return type as it's b -> a -> b data Program = Prog Action Argument -- So actually Prog is identical to Res implementation Show Program where show (Prog act arg) = "Prog " ++ show act ++ " " ++ show arg -- I also need to represent a while-loop -- We assume we have a loop primitive in the language -- let loop cond action v = (let res = action v in if (cond res) then res else loop cond action res) -- This becomes Loop (Opaque "cond" [] (Arg "res" T2) BoolT) (Opaque "action" [] (Arg "v" T1)) -- and a way to extract values from a tuple, maybe a let? {- let (err, p', p_avg) = fold (0, [], 0) sor p in map (stage3 p_avg) p' rather than simply (map stage3) $ (fold acc stage2) $ (map stage1) p this would be (\(v_in,stage1,stage2) -> let (err, p', p_avg) = fold (0, [], 0) stage1 v_in in map (stage2 p_avg) p') $ map stage1 p The best way is to add a Lambda action (\(x,y) -> map (g x) y) . (foldl f acc ) $ v -- [4,5,6] -} -- (Tuple [IntT,Vec IntT 3]) {- p : Program p = Prog (Compose [ Lambda [Arg "x" IntT, Arg "y" (Vec 3 IntT)] (Map Seq (Opaque "g" [Arg "x" IntT] (Arg "a1" IntT) IntT (0,0))) ] ) {- (Arg "y" (Vec IntT 3)), Fold Seq (OpaqueBin True "f" [] (Arg "acc" (Tuple [IntT,Vec IntT 3])) (Arg "a2" IntT) (0,0)) (Arg "acc" (Tuple [IntT,Vec IntT 3])) ]) -} (Arg "v" (Vec 3 IntT)) -}
module AutoEncoder ( preTrains, preTrain ) where import Numeric.LinearAlgebra import Data.List import Common import Forward import BackProp import ActivFunc import Other -- TODO: refactor preTrains :: R -> Int -> (Matrix R -> Matrix R, Matrix R -> Matrix R) -> Matrix R -> [Matrix R] -> [Matrix R] preTrains rate iter fDf x ws = snd (mapAccumL (preTrain rate iter fDf) x ms) `mappend` [m] where (ms, m) = (init ws, last ws) preTrain :: R -> Int -> (Matrix R -> Matrix R, Matrix R -> Matrix R) -> Matrix R -> Matrix R -> (Matrix R, Matrix R) preTrain rate iter fDf@(f, df) x w = (nx, nw) where nx = forward f nw x [nw, _] = last . take iter $ iterate (backProp f rate fDf (x, x)) [w, mirrorWeight w] mirrorWeight :: Matrix R -> Matrix R mirrorWeight w = w' ||| konst 0 (rows w', 1) -- initial bias: 0 where w' = tr $ weightWithoutBias w
lemma powr_complex_measurable [measurable]: assumes [measurable]: "f \<in> measurable M borel" "g \<in> measurable M borel" shows "(\<lambda>x. f x powr g x :: complex) \<in> measurable M borel"
Require Export List. Require Export Util. Implicit Arguments map_injective. Module Type RED_LANG. Parameters term closure closureC value valueC redex frame frameC : Set. Definition context := list frame. Definition empty : context := nil. Definition contextC := list frameC. Definition emptyC : contextC := nil. Definition env := list closure. Definition envC := list closureC. Parameter atom_plug : closure -> frame -> closure. Definition plug (c : closure) (E : context) : closure := fold_left atom_plug E c. Definition compose (E E0 : context) : context := E ++ E0. Definition composeC (E E0 : contextC) : contextC := E ++ E0. Parameter pair : term -> env -> closure. Parameter pairC : term -> envC -> closureC. Parameter value_to_closure : value -> closure. Parameter redex_to_closure : redex -> closure. Parameter valueC_to_closureC : valueC -> closureC. Parameter valueC_to_value : valueC -> value. Parameter closureC_to_closure : closureC -> closure. Parameter frameC_to_frame : frameC -> frame. Axiom value_to_closure_injective : forall v v0, value_to_closure v = value_to_closure v0 -> v = v0. Axiom redex_to_closure_injective : forall r r0, redex_to_closure r = redex_to_closure r0 -> r = r0. Axiom valueC_to_closureC_injective : forall v v0, valueC_to_closureC v = valueC_to_closureC v0 -> v = v0. Axiom closureC_to_closure_injective : forall c c0, closureC_to_closure c = closureC_to_closure c0 -> c = c0. Axiom valueC_to_value_injective : forall v v0, valueC_to_value v = valueC_to_value v0 -> v = v0. Axiom frameC_to_frame_injective : forall f f0, frameC_to_frame f = frameC_to_frame f0 -> f = f0. Axiom pairC_pair : forall t sC, closureC_to_closure (pairC t sC) = pair t (map closureC_to_closure sC). Axiom pairC_injective : forall t t0 sC sC0, pairC t sC = pairC t0 sC0 -> t = t0 /\ sC = sC0. Axiom valueC_to_closure_commutes : forall vC, value_to_closure (valueC_to_value vC) = closureC_to_closure (valueC_to_closureC vC). Definition envC_to_env : envC -> env := map closureC_to_closure. Definition envC_to_env_injective : forall sC sC0, envC_to_env sC = envC_to_env sC0 -> sC = sC0 := map_injective closureC_to_closure closureC_to_closure_injective. Definition contextC_to_context : contextC -> context := map frameC_to_frame. Definition contextC_to_context_injective : forall E E0, contextC_to_context E = contextC_to_context E0 -> E = E0 := map_injective frameC_to_frame frameC_to_frame_injective. Parameter contract : redex -> option closure. Definition only_empty (c : closure) : Prop := forall c0 E, plug c0 E = c -> E = empty. Definition only_trivial (c : closure) : Prop := forall c0 E, plug c0 E = c -> E = empty \/ exists v, c0 = value_to_closure v. Axiom closureC_only_empty : forall cC, only_empty (closureC_to_closure cC). Axiom value_trivial : forall v : value, only_trivial (value_to_closure v). Axiom redex_trivial : forall r : redex, only_trivial (redex_to_closure r). Axiom value_redex : forall (v : value) (r : redex), value_to_closure v <> redex_to_closure r. Axiom trivial_val_red : forall c : closure, only_trivial c -> (exists v : value, c = value_to_closure v) \/ (exists r : redex, c = redex_to_closure r). Parameter closureC_dec : forall cC : closureC, {p : term * envC + valueC | match p with | inl (t, sC) => cC = pairC t sC | inr vC => cC = valueC_to_closureC vC end}. Axiom dec_pairC : forall t sC, proj1_sig (closureC_dec (pairC t sC)) = inl _ (t, sC). (** Datatype of decompositions -- either a value or a redex in a context (analogous to the decompose lemma) *) Inductive decomp : Set := | d_val : value -> decomp | d_red : redex -> context -> decomp. Inductive interm_dec : Set := | in_red : redex -> interm_dec | in_val : value -> interm_dec | in_clo : closure -> frame -> interm_dec. Definition decomp_to_closure (d : decomp) : closure := match d with | d_val v => value_to_closure v | d_red r c0 => plug (redex_to_closure r) c0 end. End RED_LANG. Module Type LANG_PROP (R : RED_LANG). Import R. Notation " E · E0 " := (compose E E0) (at level 40) : red_scope. Notation " E × E0 " := (composeC E E0) (at level 40) : red_scope. Notation " E [ c ] " := (plug c E) (at level 50) : red_scope. Open Scope red_scope. Axiom plug_empty : forall c, empty [c] = c. Axiom compose_empty : forall c : context, c = c · empty. Axiom composeC_emptyC : forall Ec : contextC, Ec = Ec × emptyC. Axiom plug_compose : forall (E E0 : context) (c : closure), E · E0 [ c ] = E0 [ E [ c ] ]. Axiom composeC_compose : forall Ec Ec0, contextC_to_context (Ec × Ec0) = contextC_to_context Ec · contextC_to_context Ec0. Close Scope red_scope. End LANG_PROP. Module Type RED_REF_LANG. Declare Module Lang : RED_LANG. Import Lang. Parameter dec_closure : closure -> interm_dec. Parameter dec_context : frame -> value -> interm_dec. Inductive subclosure_one_step : closure -> closure -> Prop := | scl : forall cl cl0 f (AP : cl = atom_plug cl0 f), subclosure_one_step cl0 cl. Axiom subclosure_one_step_wf : well_founded subclosure_one_step. Definition closure_order : closure -> closure -> Prop := clos_trans_n1 _ subclosure_one_step. Notation " cl <| cl0 " := (closure_order cl cl0) (at level 40) : red_scope. Definition closure_order_wf : well_founded closure_order := wf_clos_trans_r _ _ subclosure_one_step_wf. Parameter frame_order : frame -> frame -> Prop. Notation " f <: f0 " := (frame_order f f0) (at level 40) : red_scope. Axiom frame_order_wf : well_founded frame_order. Open Scope red_scope. Axiom dec_closure_red_empty : forall c r, dec_closure c = in_red r -> only_empty c. Axiom dec_closure_val_empty : forall c v, dec_closure c = in_val v -> only_empty c. Axiom dec_closure_clo_top : forall c c0 f, dec_closure c = in_clo c0 f -> forall f0, ~f <: f0. Axiom dec_context_red_bot : forall f v r, dec_context f v = in_red r -> forall f0, ~ f0 <: f. Axiom dec_context_val_bot : forall f v v0, dec_context f v = in_val v0 -> forall f0, ~ f0 <: f. Axiom dec_context_clo_next : forall f f0 v c, dec_context f v = in_clo c f0 -> f0 <: f /\ forall f1, f1 <: f -> ~ f0 <: f1. Axiom dec_closure_correct : forall c, match dec_closure c with | in_red r => redex_to_closure r = c | in_val v => value_to_closure v = c | in_clo c0 f => atom_plug c0 f = c end. Axiom dec_context_correct : forall f v, match dec_context f v with | in_red r => redex_to_closure r = atom_plug (value_to_closure v) f | in_val v0 => value_to_closure v0 = atom_plug (value_to_closure v) f | in_clo c f0 => atom_plug c f0 = atom_plug (value_to_closure v) f end. Axiom frame_order_antisym : forall f f0, f <: f0 -> ~ f0 <: f. Axiom dec_frame_ord : forall c c0 f f0, atom_plug c f = atom_plug c0 f0 -> f <: f0 \/ f0 <: f \/ (c = c0 /\ f = f0). Axiom frame_det : forall c c0 f f0, f <: f0 -> atom_plug c f = atom_plug c0 f0 -> exists v, c0 = value_to_closure v. Definition dcl c cC ofC : Prop := match ofC with | None => c = closureC_to_closure cC | Some fC => dec_closure c = in_clo (closureC_to_closure cC) (frameC_to_frame fC) end. Parameter closure_red : forall cC r cl (DCL : dec_closure (closureC_to_closure cC) = in_red r) (CTR : contract r = Some cl), {p : closureC * option frameC | match p with (cC, ofC) => dcl cl cC ofC end }. Parameter context_red : forall fC vC r cl (DCT : dec_context (frameC_to_frame fC) (valueC_to_value vC) = in_red r) (CTR : contract r = Some cl), {p : closureC * option frameC | match p with (cC, ofC) => dcl cl cC ofC end}. Parameter closure_val : forall cC v (DCL : dec_closure (closureC_to_closure cC) = in_val v), { vC : valueC | v = valueC_to_value vC}. Parameter context_val : forall fC vC v (DCT : dec_context (frameC_to_frame fC) (valueC_to_value vC) = in_val v), {vC0 : valueC | v = valueC_to_value vC0}. Parameter context_clo : forall fC vC cl f (DCT : dec_context (frameC_to_frame fC) (valueC_to_value vC) = in_clo cl f), { p : closureC * frameC | match p with (cC, fC) => cl = closureC_to_closure (cC) /\ f = frameC_to_frame fC end}. Close Scope red_scope. End RED_REF_LANG. Ltac prove_st_wf := intro a; constructor; induction a; (intros y H; inversion H as [c c0 f DECT]; subst; destruct f; inversion DECT; subst; constructor; auto). Ltac prove_ec_wf := intro a; destruct a; repeat (constructor; intros f T; destruct f; inversion T; subst; clear T). Module Type ABSTRACT_MACHINE. Parameters term value configuration : Set. Parameter c_init : term -> configuration. Parameter c_final : value -> configuration. Parameter transition : configuration -> configuration -> Prop. Inductive trans_close : configuration -> configuration -> Prop := | one_step : forall (c0 c1 : configuration), transition c0 c1 -> trans_close c0 c1 | multi_step : forall (c0 c1 c2 : configuration), transition c0 c1 -> trans_close c1 c2 -> trans_close c0 c2. Inductive eval : term -> value -> Prop := | e_intro : forall (t : term) (v : value), trans_close (c_init t) (c_final v) -> eval t v. End ABSTRACT_MACHINE.
Require Import FP.CoreData. Require Import FP.Classes. Import CoreDataNotation. Import ClassesNotation. Instance list_GUnit {A} : GUnit (list A) := { gunit := [] }. Instance list_GTimes {A} : GTimes (list A) := { gtimes := app }. Fixpoint list_cofold {X w} `{! Comonad w } {A} (f:X -> w A -> A) (aW:w A) (xs:list X) : A := match xs with | [] => coret aW | x::xs => let aW := codo aW => list_cofold f aW xs in f x aW end. Instance list_Foldable {X} : Foldable X (list X) := { cofold := @list_cofold X }. Fixpoint list_coiter {X w} `{! Comonad w } {A} (f:w A -> X -> A) (aW:w A) (xs:list X) : A := match xs with | [] => coret aW | x::xs => let aW := codo aW => f aW x in list_coiter f aW xs end. Instance list_Iterable {X} : Iterable X (list X) := { coiter := @list_coiter X }. Fixpoint list_mbuild {X m} `{! Monad m } (fld:forall {A}, (X -> A -> A) -> A -> m A) : m (list X) := fld cons nil. Instance list_Buildable {X} : Buildable X (list X) := { mbuild := @list_mbuild X }. Fixpoint list_sequence {u} `{! Applicative u } {A} (xs:list (u A)) : u (list A) := match xs with | nil => fret nil | x::xs' => fret cons <@> x <@> list_sequence xs' end. Instance list_Traversable : Traversable list := { tsequence := @list_sequence }.
State Before: C : Type u₁ inst✝¹ : Category C D : Type u₂ inst✝ : Category D T T' T'' : D Y Y' : C S : C ⥤ D f : CostructuredArrow S T ⊢ (map (𝟙 T)).obj f = f State After: C : Type u₁ inst✝¹ : Category C D : Type u₂ inst✝ : Category D T T' T'' : D Y Y' : C S : C ⥤ D f : CostructuredArrow S T ⊢ (map (𝟙 T)).obj (mk f.hom) = mk f.hom Tactic: rw [eq_mk f] State Before: C : Type u₁ inst✝¹ : Category C D : Type u₂ inst✝ : Category D T T' T'' : D Y Y' : C S : C ⥤ D f : CostructuredArrow S T ⊢ (map (𝟙 T)).obj (mk f.hom) = mk f.hom State After: no goals Tactic: simp
[STATEMENT] theorem Right_Coset_bij: assumes G [simp]: "x \<in> G" "y \<in> G" shows "bij_betw (inverse x \<cdot> y)\<^sub>R (H |\<cdot> x) (H |\<cdot> y)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. bij_betw (inverse x \<cdot> y)\<^sub>R (H |\<cdot> x) (H |\<cdot> y) [PROOF STEP] proof (rule bij_betw_imageI) [PROOF STATE] proof (state) goal (2 subgoals): 1. inj_on (inverse x \<cdot> y)\<^sub>R (H |\<cdot> x) 2. (inverse x \<cdot> y)\<^sub>R ` (H |\<cdot> x) = H |\<cdot> y [PROOF STEP] show "inj_on (inverse x \<cdot> y)\<^sub>R (H |\<cdot> x)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. inj_on (inverse x \<cdot> y)\<^sub>R (H |\<cdot> x) [PROOF STEP] by (fastforce intro: inj_onI simp add: Right_Coset_is_orbit right.translation_apply orbit.block_closed) [PROOF STATE] proof (state) this: inj_on (inverse x \<cdot> y)\<^sub>R (H |\<cdot> x) goal (1 subgoal): 1. (inverse x \<cdot> y)\<^sub>R ` (H |\<cdot> x) = H |\<cdot> y [PROOF STEP] next [PROOF STATE] proof (state) goal (1 subgoal): 1. (inverse x \<cdot> y)\<^sub>R ` (H |\<cdot> x) = H |\<cdot> y [PROOF STEP] show "(inverse x \<cdot> y)\<^sub>R ` (H |\<cdot> x) = H |\<cdot> y" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (inverse x \<cdot> y)\<^sub>R ` (H |\<cdot> x) = H |\<cdot> y [PROOF STEP] by (force simp add: right.translation_apply associative invertible_right_inverse2) [PROOF STATE] proof (state) this: (inverse x \<cdot> y)\<^sub>R ` (H |\<cdot> x) = H |\<cdot> y goal: No subgoals! [PROOF STEP] qed
%PAY Joint forces from payload for SerialLink objects % % Calculates the joint loads due to a payload for SerialLink objects, % It uses the formula Q = J'w, where w is a wrench vector applied at % the end effector, w = [Fx Fy Fz Mxx Myy Mzz]'. The Jacobian can be % supplied or computed by RTB % % Copyright (C) Bryan Moutrie, 2013-2014 % Licensed under the GNU Lesser General Public License % see full file for full statement % % This file requires file(s) from The Robotics Toolbox for MATLAB (RTB) % by Peter Corke (www.petercorke.com), see file for statement % % Syntax: % (1) tauP = pay(w, J) % (2) tauP = robot.pay(q, w, f) % % (1) Uses a supplied Jacobian % (2) Calculates the Jacobian for joint configuration q in frame f, % using either robot.jacob0(q) or robot.jacob0(q) for Jacobian % % Outputs: % tauP : Generalised joint force/torques % % Inputs: % robot : SerialLink object with n joints % w : Wrench vector [Fx Fy Fz Mxx Myy Mzz]' in same frame as J % J : Jacobian (supplied): 6-by-n or 6-by-n-m for trajectory % q : Joint row vector, or trajectory matrix of joint row vectors % f : '0' for world frame, 'n' for end-effector frame % % See also jacob0, jacobn, paycap, SerialLink.payload % LICENSE STATEMENT: % % This file is part of pHRIWARE. % % pHRIWARE is free software: you can redistribute it and/or modify % it under the terms of the GNU Lesser General Public License as % published by the Free Software Foundation, either version 3 of % the License, or (at your option) any later version. % % pHRIWARE 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 Lesser General Public % License along with pHRIWARE. If not, see <http://www.gnu.org/licenses/>. % % RTB LIBRARY: % % Copyright (C) 1993-2014, by Peter I. Corke % http://www.petercorke.com % Released under the GNU Lesser General Public license function tauP = pay(varargin) if length(varargin) == 3 w = varargin{2}; J = varargin{3}; n = size(J,2); elseif length(varargin) == 4 robot = varargin{1}; q = varargin{2}; w = varargin{3}; f = varargin{4}; n = robot.n; J = zeros(6,n,size(q,1)); if f == '0' for i= 1: size(q,1) J(:,:,i) = robot.jacob0(q(i,:)); end elseif f == 'n' for i= 1: size(q,1) J(:,:,i) = robot.jacobn(q(i,:)); end end end tauP = -reshape(J(:,:)'*w,n,[])'; end
module Data.Word.Primitive where postulate Word : Set Word8 : Set Word16 : Set Word32 : Set Word64 : Set {-# IMPORT Data.Word #-} {-# COMPILED_TYPE Word Data.Word.Word #-} {-# COMPILED_TYPE Word8 Data.Word.Word8 #-} {-# COMPILED_TYPE Word16 Data.Word.Word16 #-} {-# COMPILED_TYPE Word32 Data.Word.Word32 #-} {-# COMPILED_TYPE Word64 Data.Word.Word64 #-}
(*:maxLineLen=78:*) section \<open> Classical Propositional Logic \label{sec:classical-propositional-logic}\<close> theory Classical_Logic imports "../Intuitionistic/Implication_Logic" begin sledgehammer_params [smt_proofs = false] text \<open> This theory presents \<^emph>\<open>classical propositional logic\<close>, which is classical logic without quantifiers. \<close> subsection \<open> Axiomatization \<close> text \<open> Classical propositional logic can be given by the following Hilbert-style axiom system. It is @{class implication_logic} extended with \<^emph>\<open>falsum\<close> and double negation. \<close> class classical_logic = implication_logic + fixes falsum :: "'a" ("\<bottom>") assumes double_negation: "\<turnstile> (((\<phi> \<rightarrow> \<bottom>) \<rightarrow> \<bottom>) \<rightarrow> \<phi>)" text \<open> In some cases it is useful to assume consistency as an axiom: \<close> class consistent_classical_logic = classical_logic + assumes consistency: "\<not> \<turnstile> \<bottom>" subsection \<open> Common Rules \<close> text \<open> There are many common tautologies in classical logic. Once we have established \<^emph>\<open>completeness\<close> in \S\ref{sec:classical-propositional-calculus}, we will be able to leverage Isabelle/HOL's automation for proving these elementary results. \<close> text \<open> In order to bootstrap completeness, we develop some common lemmas using classical deduction alone. \<close> lemma (in classical_logic) ex_falso_quodlibet: "\<turnstile> \<bottom> \<rightarrow> \<phi>" using axiom_k double_negation modus_ponens hypothetical_syllogism by blast lemma (in classical_logic) Contraposition: "\<turnstile> ((\<phi> \<rightarrow> \<bottom>) \<rightarrow> (\<psi> \<rightarrow> \<bottom>)) \<rightarrow> \<psi> \<rightarrow> \<phi>" proof - have "[\<phi> \<rightarrow> \<bottom>, \<psi>, (\<phi> \<rightarrow> \<bottom>) \<rightarrow> (\<psi> \<rightarrow> \<bottom>)] :\<turnstile> \<bottom>" using flip_implication list_deduction_theorem list_implication.simps(1) unfolding list_deduction_def by presburger hence "[\<psi>, (\<phi> \<rightarrow> \<bottom>) \<rightarrow> (\<psi> \<rightarrow> \<bottom>)] :\<turnstile> (\<phi> \<rightarrow> \<bottom>) \<rightarrow> \<bottom>" using list_deduction_theorem by blast hence "[\<psi>, (\<phi> \<rightarrow> \<bottom>) \<rightarrow> (\<psi> \<rightarrow> \<bottom>)] :\<turnstile> \<phi>" using double_negation list_deduction_weaken list_deduction_modus_ponens by blast thus ?thesis using list_deduction_base_theory list_deduction_theorem by blast qed lemma (in classical_logic) double_negation_converse: "\<turnstile> \<phi> \<rightarrow> (\<phi> \<rightarrow> \<bottom>) \<rightarrow> \<bottom>" by (meson axiom_k modus_ponens flip_implication) text \<open>The following lemma is sometimes referred to as \<^emph>\<open>The Principle of Pseudo-Scotus\<close>@{cite bobenriethOriginsUseArgument2010}.\<close> lemma (in classical_logic) pseudo_scotus: "\<turnstile> (\<phi> \<rightarrow> \<bottom>) \<rightarrow> \<phi> \<rightarrow> \<psi>" using ex_falso_quodlibet modus_ponens hypothetical_syllogism by blast text \<open>Another popular lemma is attributed to Charles Sanders Peirce, and has come to be known as \<^emph>\<open>Peirces Law\<close>@{cite peirceAlgebraLogicContribution1885}.\<close> lemma (in classical_logic) Peirces_law: "\<turnstile> ((\<phi> \<rightarrow> \<psi>) \<rightarrow> \<phi>) \<rightarrow> \<phi>" proof - have "[\<phi> \<rightarrow> \<bottom>, (\<phi> \<rightarrow> \<psi>) \<rightarrow> \<phi>] :\<turnstile> \<phi> \<rightarrow> \<psi>" using pseudo_scotus list_deduction_theorem list_deduction_weaken by blast hence "[\<phi> \<rightarrow> \<bottom>, (\<phi> \<rightarrow> \<psi>) \<rightarrow> \<phi>] :\<turnstile> \<phi>" by (meson list.set_intros(1) list_deduction_reflection list_deduction_modus_ponens set_subset_Cons subsetCE) hence "[\<phi> \<rightarrow> \<bottom>, (\<phi> \<rightarrow> \<psi>) \<rightarrow> \<phi>] :\<turnstile> \<bottom>" by (meson list.set_intros(1) list_deduction_modus_ponens list_deduction_reflection) hence "[(\<phi> \<rightarrow> \<psi>) \<rightarrow> \<phi>] :\<turnstile> (\<phi> \<rightarrow> \<bottom>) \<rightarrow> \<bottom>" using list_deduction_theorem by blast hence "[(\<phi> \<rightarrow> \<psi>) \<rightarrow> \<phi>] :\<turnstile> \<phi>" using double_negation list_deduction_modus_ponens list_deduction_weaken by blast thus ?thesis using list_deduction_def by auto qed lemma (in classical_logic) excluded_middle_elimination: "\<turnstile> (\<phi> \<rightarrow> \<psi>) \<rightarrow> ((\<phi> \<rightarrow> \<bottom>) \<rightarrow> \<psi>) \<rightarrow> \<psi>" proof - let ?\<Gamma> = "[\<psi> \<rightarrow> \<bottom>, \<phi> \<rightarrow> \<psi>, (\<phi> \<rightarrow> \<bottom>) \<rightarrow> \<psi>]" have "?\<Gamma> :\<turnstile> (\<phi> \<rightarrow> \<bottom>) \<rightarrow> \<psi>" "?\<Gamma> :\<turnstile> \<psi> \<rightarrow> \<bottom>" by (simp add: list_deduction_reflection)+ hence "?\<Gamma> :\<turnstile> (\<phi> \<rightarrow> \<bottom>) \<rightarrow> \<bottom>" by (meson flip_hypothetical_syllogism list_deduction_base_theory list_deduction_monotonic list_deduction_theorem set_subset_Cons) hence "?\<Gamma> :\<turnstile> \<phi>" using double_negation list_deduction_modus_ponens list_deduction_weaken by blast hence "?\<Gamma> :\<turnstile> \<psi>" by (meson list.set_intros(1) list_deduction_modus_ponens list_deduction_reflection set_subset_Cons subsetCE) hence "[\<phi> \<rightarrow> \<psi>, (\<phi> \<rightarrow> \<bottom>) \<rightarrow> \<psi>] :\<turnstile> \<psi>" using Peirces_law list_deduction_modus_ponens list_deduction_theorem list_deduction_weaken by blast thus ?thesis unfolding list_deduction_def by simp qed subsection \<open> Maximally Consistent Sets For Classical Logic \label{subsec:mcs}\<close> text \<open> \<^emph>\<open>Relativized\<close> maximally consistent sets were introduced in \S\ref{sec:implicational-maximally-consistent-sets}. Often this is exactly what we want in a proof. A completeness theorem typically starts by assuming \<^term>\<open>\<phi>\<close> is not provable, then finding a \<^term>\<open>\<phi>-MCS \<Gamma>\<close> which gives rise to a model which does not make \<^term>\<open>\<phi>\<close> true. \<close> text \<open> A more conventional presentation says that \<^term>\<open>\<Gamma>\<close> is maximally consistent if and only if \<^term>\<open>\<not> (\<Gamma> \<tturnstile> \<bottom>)\<close> and \<^term>\<open>\<forall> \<psi>. \<psi> \<in> \<Gamma> \<or> (\<psi> \<rightarrow> \<phi>) \<in> \<Gamma>\<close>. This conventional presentation will come up when formulating \textsc{MaxSAT} in \S\ref{sec:abstract-maxsat}. This in turn allows us to formulate \textsc{MaxSAT} completeness for probability inequalities in \S\ref{sec:maxsat-completeness} and a form of the \<^emph>\<open>Dutch Book Theorem\<close> in \S\ref{subsec:dutch-book-maxsat-reduction}.\<close> definition (in classical_logic) consistent :: "'a set \<Rightarrow> bool" where [simp]: "consistent \<Gamma> \<equiv> \<bottom>-consistent \<Gamma>" definition (in classical_logic) maximally_consistent_set :: "'a set \<Rightarrow> bool" ("MCS") where [simp]: "MCS \<Gamma> \<equiv> \<bottom>-MCS \<Gamma>" lemma (in classical_logic) formula_maximally_consistent_set_def_negation: "\<phi>-MCS \<Gamma> \<Longrightarrow> \<phi> \<rightarrow> \<bottom> \<in> \<Gamma>" proof - assume "\<phi>-MCS \<Gamma>" { assume "\<phi> \<rightarrow> \<bottom> \<notin> \<Gamma>" hence "(\<phi> \<rightarrow> \<bottom>) \<rightarrow> \<phi> \<in> \<Gamma>" using \<open>\<phi>-MCS \<Gamma>\<close> unfolding formula_maximally_consistent_set_def_def by blast hence "\<Gamma> \<tturnstile> (\<phi> \<rightarrow> \<bottom>) \<rightarrow> \<phi>" using set_deduction_reflection by simp hence "\<Gamma> \<tturnstile> \<phi>" using Peirces_law set_deduction_modus_ponens set_deduction_weaken by metis hence "False" using \<open>\<phi>-MCS \<Gamma>\<close> unfolding formula_maximally_consistent_set_def_def formula_consistent_def by simp } thus ?thesis by blast qed text \<open> Relative maximal consistency and conventional maximal consistency in fact coincide in classical logic. \<close> lemma (in classical_logic) formula_maximal_consistency: "(\<exists>\<phi>. \<phi>-MCS \<Gamma>) = MCS \<Gamma>" proof - { fix \<phi> have "\<phi>-MCS \<Gamma> \<Longrightarrow> MCS \<Gamma>" proof - assume "\<phi>-MCS \<Gamma>" have "consistent \<Gamma>" using \<open>\<phi>-MCS \<Gamma>\<close> ex_falso_quodlibet [where \<phi>="\<phi>"] set_deduction_weaken [where \<Gamma>="\<Gamma>"] set_deduction_modus_ponens unfolding formula_maximally_consistent_set_def_def consistent_def formula_consistent_def by metis moreover { fix \<psi> have "\<psi> \<rightarrow> \<bottom> \<notin> \<Gamma> \<Longrightarrow> \<psi> \<in> \<Gamma>" proof - assume "\<psi> \<rightarrow> \<bottom> \<notin> \<Gamma>" hence "(\<psi> \<rightarrow> \<bottom>) \<rightarrow> \<phi> \<in> \<Gamma>" using \<open>\<phi>-MCS \<Gamma>\<close> unfolding formula_maximally_consistent_set_def_def by blast hence "\<Gamma> \<tturnstile> (\<psi> \<rightarrow> \<bottom>) \<rightarrow> \<phi>" using set_deduction_reflection by simp also have "\<Gamma> \<tturnstile> \<phi> \<rightarrow> \<bottom>" using \<open>\<phi>-MCS \<Gamma>\<close> formula_maximally_consistent_set_def_negation set_deduction_reflection by simp hence "\<Gamma> \<tturnstile> (\<psi> \<rightarrow> \<bottom>) \<rightarrow> \<bottom>" using calculation hypothetical_syllogism [where \<phi>="\<psi> \<rightarrow> \<bottom>" and \<psi>="\<phi>" and \<chi>="\<bottom>"] set_deduction_weaken [where \<Gamma>="\<Gamma>"] set_deduction_modus_ponens by metis hence "\<Gamma> \<tturnstile> \<psi>" using double_negation [where \<phi>="\<psi>"] set_deduction_weaken [where \<Gamma>="\<Gamma>"] set_deduction_modus_ponens by metis thus ?thesis using \<open>\<phi>-MCS \<Gamma>\<close> formula_maximally_consistent_set_def_reflection by blast qed } ultimately show ?thesis unfolding maximally_consistent_set_def formula_maximally_consistent_set_def_def formula_consistent_def consistent_def by blast qed } thus ?thesis unfolding maximally_consistent_set_def by metis qed text \<open> Finally, classical logic allows us to strengthen @{thm formula_maximally_consistent_set_def_implication_elimination} to a biconditional. \<close> lemma (in classical_logic) formula_maximally_consistent_set_def_implication: assumes "\<phi>-MCS \<Gamma>" shows "\<psi> \<rightarrow> \<chi> \<in> \<Gamma> = (\<psi> \<in> \<Gamma> \<longrightarrow> \<chi> \<in> \<Gamma>)" proof - { assume hypothesis: "\<psi> \<in> \<Gamma> \<longrightarrow> \<chi> \<in> \<Gamma>" { assume "\<psi> \<notin> \<Gamma>" have "\<forall>\<psi>. \<phi> \<rightarrow> \<psi> \<in> \<Gamma>" by (meson assms formula_maximally_consistent_set_def_negation formula_maximally_consistent_set_def_implication_elimination formula_maximally_consistent_set_def_reflection pseudo_scotus set_deduction_weaken) then have "\<forall>\<chi> \<psi>. insert \<chi> \<Gamma> \<tturnstile> \<psi> \<or> \<chi> \<rightarrow> \<phi> \<notin> \<Gamma>" by (meson assms axiom_k formula_maximally_consistent_set_def_reflection set_deduction_modus_ponens set_deduction_theorem set_deduction_weaken) hence "\<psi> \<rightarrow> \<chi> \<in> \<Gamma>" by (meson \<open>\<psi> \<notin> \<Gamma>\<close> assms formula_maximally_consistent_set_def_def formula_maximally_consistent_set_def_reflection set_deduction_theorem) } moreover { assume "\<chi> \<in> \<Gamma>" hence "\<psi> \<rightarrow> \<chi> \<in> \<Gamma>" by (metis assms calculation insert_absorb formula_maximally_consistent_set_def_reflection set_deduction_theorem) } ultimately have "\<psi> \<rightarrow> \<chi> \<in> \<Gamma>" using hypothesis by blast } thus ?thesis using assms formula_maximally_consistent_set_def_implication_elimination by metis qed end
The film did not perform well at the box office upon its Australian release , taking in a gross of A $ 108 @,@ 330 on its first weekend but only $ 31 @,@ 995 on its second weekend at a screen average of $ 681 on 47 screens .
Formal statement is: lemma complex_i_not_one [simp]: "\<i> \<noteq> 1" Informal statement is: $i$ is not equal to $1$.
[GOAL] M : Type u_1 N : Type u_2 inst✝¹ : Monoid M inst✝ : AddMonoid N P : Submonoid M x✝ : ∃ S, closure S = P ∧ Set.Finite S S : Set M hS : closure S = P hf : Set.Finite S ⊢ closure ↑(Set.Finite.toFinset hf) = P [PROOFSTEP] simp [hS] [GOAL] M : Type u_1 N : Type u_2 inst✝¹ : Monoid M inst✝ : AddMonoid N P : Submonoid M h : FG P S : Set M hS : closure S = P hf : Set.Finite S ⊢ AddSubmonoid.closure (↑Additive.toMul ⁻¹' S) = ↑toAddSubmonoid P [PROOFSTEP] simp [← Submonoid.toAddSubmonoid_closure, hS] [GOAL] M : Type u_1 N : Type u_2 inst✝¹ : Monoid M inst✝ : AddMonoid N P : Submonoid M h : AddSubmonoid.FG (↑toAddSubmonoid P) T : Set (Additive M) hT : AddSubmonoid.closure T = ↑toAddSubmonoid P hf : Set.Finite T ⊢ closure (↑Multiplicative.ofAdd ⁻¹' T) = P [PROOFSTEP] simp [← AddSubmonoid.toSubmonoid'_closure, hT] [GOAL] M : Type u_1 N : Type u_2 inst✝¹ : Monoid M inst✝ : AddMonoid N P : AddSubmonoid N ⊢ FG P ↔ Submonoid.FG (↑toSubmonoid P) [PROOFSTEP] convert (Submonoid.fg_iff_add_fg (toSubmonoid P)).symm [GOAL] M : Type u_1 N : Type u_2 inst✝² : Monoid M inst✝¹ : AddMonoid N inst✝ : Finite M ⊢ FG M [PROOFSTEP] cases nonempty_fintype M [GOAL] case intro M : Type u_1 N : Type u_2 inst✝² : Monoid M inst✝¹ : AddMonoid N inst✝ : Finite M val✝ : Fintype M ⊢ FG M [PROOFSTEP] exact ⟨⟨Finset.univ, by rw [Finset.coe_univ]; exact Submonoid.closure_univ⟩⟩ [GOAL] M : Type u_1 N : Type u_2 inst✝² : Monoid M inst✝¹ : AddMonoid N inst✝ : Finite M val✝ : Fintype M ⊢ Submonoid.closure ↑Finset.univ = ⊤ [PROOFSTEP] rw [Finset.coe_univ] [GOAL] M : Type u_1 N : Type u_2 inst✝² : Monoid M inst✝¹ : AddMonoid N inst✝ : Finite M val✝ : Fintype M ⊢ Submonoid.closure Set.univ = ⊤ [PROOFSTEP] exact Submonoid.closure_univ [GOAL] M : Type u_1 N : Type u_2 inst✝² : Monoid M inst✝¹ : AddMonoid N M' : Type u_3 inst✝ : Monoid M' P : Submonoid M h : FG P e : M →* M' ⊢ FG (Submonoid.map e P) [PROOFSTEP] classical obtain ⟨s, rfl⟩ := h exact ⟨s.image e, by rw [Finset.coe_image, MonoidHom.map_mclosure]⟩ [GOAL] M : Type u_1 N : Type u_2 inst✝² : Monoid M inst✝¹ : AddMonoid N M' : Type u_3 inst✝ : Monoid M' P : Submonoid M h : FG P e : M →* M' ⊢ FG (Submonoid.map e P) [PROOFSTEP] obtain ⟨s, rfl⟩ := h [GOAL] case intro M : Type u_1 N : Type u_2 inst✝² : Monoid M inst✝¹ : AddMonoid N M' : Type u_3 inst✝ : Monoid M' e : M →* M' s : Finset M ⊢ FG (Submonoid.map e (closure ↑s)) [PROOFSTEP] exact ⟨s.image e, by rw [Finset.coe_image, MonoidHom.map_mclosure]⟩ [GOAL] M : Type u_1 N : Type u_2 inst✝² : Monoid M inst✝¹ : AddMonoid N M' : Type u_3 inst✝ : Monoid M' e : M →* M' s : Finset M ⊢ closure ↑(Finset.image (↑e) s) = Submonoid.map e (closure ↑s) [PROOFSTEP] rw [Finset.coe_image, MonoidHom.map_mclosure] [GOAL] M : Type u_1 N : Type u_2 inst✝² : Monoid M inst✝¹ : AddMonoid N M' : Type u_3 inst✝ : Monoid M' P : Submonoid M e : M →* M' he : Function.Injective ↑e h : FG (Submonoid.map e P) ⊢ FG P [PROOFSTEP] obtain ⟨s, hs⟩ := h [GOAL] case intro M : Type u_1 N : Type u_2 inst✝² : Monoid M inst✝¹ : AddMonoid N M' : Type u_3 inst✝ : Monoid M' P : Submonoid M e : M →* M' he : Function.Injective ↑e s : Finset M' hs : closure ↑s = Submonoid.map e P ⊢ FG P [PROOFSTEP] use s.preimage e (he.injOn _) [GOAL] case h M : Type u_1 N : Type u_2 inst✝² : Monoid M inst✝¹ : AddMonoid N M' : Type u_3 inst✝ : Monoid M' P : Submonoid M e : M →* M' he : Function.Injective ↑e s : Finset M' hs : closure ↑s = Submonoid.map e P ⊢ closure ↑(Finset.preimage s ↑e (_ : Set.InjOn (↑e) (↑e ⁻¹' ↑s))) = P [PROOFSTEP] apply Submonoid.map_injective_of_injective he [GOAL] case h.a M : Type u_1 N : Type u_2 inst✝² : Monoid M inst✝¹ : AddMonoid N M' : Type u_3 inst✝ : Monoid M' P : Submonoid M e : M →* M' he : Function.Injective ↑e s : Finset M' hs : closure ↑s = Submonoid.map e P ⊢ Submonoid.map e (closure ↑(Finset.preimage s ↑e (_ : Set.InjOn (↑e) (↑e ⁻¹' ↑s)))) = Submonoid.map e P [PROOFSTEP] rw [← hs, MonoidHom.map_mclosure e, Finset.coe_preimage] [GOAL] case h.a M : Type u_1 N : Type u_2 inst✝² : Monoid M inst✝¹ : AddMonoid N M' : Type u_3 inst✝ : Monoid M' P : Submonoid M e : M →* M' he : Function.Injective ↑e s : Finset M' hs : closure ↑s = Submonoid.map e P ⊢ closure (↑e '' (↑e ⁻¹' ↑s)) = closure ↑s [PROOFSTEP] congr [GOAL] case h.a.e_s M : Type u_1 N : Type u_2 inst✝² : Monoid M inst✝¹ : AddMonoid N M' : Type u_3 inst✝ : Monoid M' P : Submonoid M e : M →* M' he : Function.Injective ↑e s : Finset M' hs : closure ↑s = Submonoid.map e P ⊢ ↑e '' (↑e ⁻¹' ↑s) = ↑s [PROOFSTEP] rw [Set.image_preimage_eq_iff, ← MonoidHom.coe_mrange e, ← Submonoid.closure_le, hs, MonoidHom.mrange_eq_map e] [GOAL] case h.a.e_s M : Type u_1 N : Type u_2 inst✝² : Monoid M inst✝¹ : AddMonoid N M' : Type u_3 inst✝ : Monoid M' P : Submonoid M e : M →* M' he : Function.Injective ↑e s : Finset M' hs : closure ↑s = Submonoid.map e P ⊢ Submonoid.map e P ≤ Submonoid.map e ⊤ [PROOFSTEP] exact Submonoid.monotone_map le_top [GOAL] M : Type u_1 N✝ : Type u_2 inst✝¹ : Monoid M inst✝ : AddMonoid N✝ N : Submonoid M ⊢ FG { x // x ∈ N } ↔ Submonoid.FG N [PROOFSTEP] conv_rhs => rw [← N.range_subtype, MonoidHom.mrange_eq_map] [GOAL] M : Type u_1 N✝ : Type u_2 inst✝¹ : Monoid M inst✝ : AddMonoid N✝ N : Submonoid M | Submonoid.FG N [PROOFSTEP] rw [← N.range_subtype, MonoidHom.mrange_eq_map] [GOAL] M : Type u_1 N✝ : Type u_2 inst✝¹ : Monoid M inst✝ : AddMonoid N✝ N : Submonoid M | Submonoid.FG N [PROOFSTEP] rw [← N.range_subtype, MonoidHom.mrange_eq_map] [GOAL] M : Type u_1 N✝ : Type u_2 inst✝¹ : Monoid M inst✝ : AddMonoid N✝ N : Submonoid M | Submonoid.FG N [PROOFSTEP] rw [← N.range_subtype, MonoidHom.mrange_eq_map] [GOAL] M : Type u_1 N✝ : Type u_2 inst✝¹ : Monoid M inst✝ : AddMonoid N✝ N : Submonoid M ⊢ FG { x // x ∈ N } ↔ Submonoid.FG (Submonoid.map (Submonoid.subtype N) ⊤) [PROOFSTEP] exact ⟨fun h => h.out.map N.subtype, fun h => ⟨h.map_injective N.subtype Subtype.coe_injective⟩⟩ [GOAL] M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N M' : Type u_3 inst✝¹ : Monoid M' inst✝ : FG M f : M →* M' hf : Function.Surjective ↑f ⊢ FG M' [PROOFSTEP] classical obtain ⟨s, hs⟩ := Monoid.fg_def.mp ‹_› use s.image f rwa [Finset.coe_image, ← MonoidHom.map_mclosure, hs, ← MonoidHom.mrange_eq_map, MonoidHom.mrange_top_iff_surjective] [GOAL] M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N M' : Type u_3 inst✝¹ : Monoid M' inst✝ : FG M f : M →* M' hf : Function.Surjective ↑f ⊢ FG M' [PROOFSTEP] obtain ⟨s, hs⟩ := Monoid.fg_def.mp ‹_› [GOAL] case intro M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N M' : Type u_3 inst✝¹ : Monoid M' inst✝ : FG M f : M →* M' hf : Function.Surjective ↑f s : Finset M hs : Submonoid.closure ↑s = ⊤ ⊢ FG M' [PROOFSTEP] use s.image f [GOAL] case h M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N M' : Type u_3 inst✝¹ : Monoid M' inst✝ : FG M f : M →* M' hf : Function.Surjective ↑f s : Finset M hs : Submonoid.closure ↑s = ⊤ ⊢ Submonoid.closure ↑(Finset.image (↑f) s) = ⊤ [PROOFSTEP] rwa [Finset.coe_image, ← MonoidHom.map_mclosure, hs, ← MonoidHom.mrange_eq_map, MonoidHom.mrange_top_iff_surjective] [GOAL] M : Type u_1 N : Type u_2 inst✝¹ : Monoid M inst✝ : AddMonoid N s : Finset M ⊢ FG { x // x ∈ Submonoid.closure ↑s } [PROOFSTEP] refine' ⟨⟨s.preimage Subtype.val (Subtype.coe_injective.injOn _), _⟩⟩ [GOAL] M : Type u_1 N : Type u_2 inst✝¹ : Monoid M inst✝ : AddMonoid N s : Finset M ⊢ Submonoid.closure ↑(Finset.preimage s Subtype.val (_ : Set.InjOn (fun a => ↑a) (Subtype.val ⁻¹' ↑s))) = ⊤ [PROOFSTEP] rw [Finset.coe_preimage, Submonoid.closure_closure_coe_preimage] [GOAL] M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H P : Subgroup G x✝ : ∃ S, closure S = P ∧ Set.Finite S S : Set G hS : closure S = P hf : Set.Finite S ⊢ closure ↑(Set.Finite.toFinset hf) = P [PROOFSTEP] simp [hS] [GOAL] M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H P : Subgroup G ⊢ FG P ↔ Submonoid.FG P.toSubmonoid [PROOFSTEP] constructor [GOAL] case mp M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H P : Subgroup G ⊢ FG P → Submonoid.FG P.toSubmonoid [PROOFSTEP] rintro ⟨S, rfl⟩ [GOAL] case mp.intro M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H S : Finset G ⊢ Submonoid.FG (closure ↑S).toSubmonoid [PROOFSTEP] rw [Submonoid.fg_iff] [GOAL] case mp.intro M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H S : Finset G ⊢ ∃ S_1, Submonoid.closure S_1 = (closure ↑S).toSubmonoid ∧ Set.Finite S_1 [PROOFSTEP] refine' ⟨S ∪ S⁻¹, _, S.finite_toSet.union S.finite_toSet.inv⟩ [GOAL] case mp.intro M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H S : Finset G ⊢ Submonoid.closure (↑S ∪ (↑S)⁻¹) = (closure ↑S).toSubmonoid [PROOFSTEP] exact (Subgroup.closure_toSubmonoid _).symm [GOAL] case mpr M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H P : Subgroup G ⊢ Submonoid.FG P.toSubmonoid → FG P [PROOFSTEP] rintro ⟨S, hS⟩ [GOAL] case mpr.intro M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H P : Subgroup G S : Finset G hS : Submonoid.closure ↑S = P.toSubmonoid ⊢ FG P [PROOFSTEP] refine' ⟨S, le_antisymm _ _⟩ [GOAL] case mpr.intro.refine'_1 M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H P : Subgroup G S : Finset G hS : Submonoid.closure ↑S = P.toSubmonoid ⊢ closure ↑S ≤ P [PROOFSTEP] rw [Subgroup.closure_le, ← Subgroup.coe_toSubmonoid, ← hS] [GOAL] case mpr.intro.refine'_1 M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H P : Subgroup G S : Finset G hS : Submonoid.closure ↑S = P.toSubmonoid ⊢ ↑S ⊆ ↑(Submonoid.closure ↑S) [PROOFSTEP] exact Submonoid.subset_closure [GOAL] case mpr.intro.refine'_2 M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H P : Subgroup G S : Finset G hS : Submonoid.closure ↑S = P.toSubmonoid ⊢ P ≤ closure ↑S [PROOFSTEP] rw [← Subgroup.toSubmonoid_le, ← hS, Submonoid.closure_le] [GOAL] case mpr.intro.refine'_2 M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H P : Subgroup G S : Finset G hS : Submonoid.closure ↑S = P.toSubmonoid ⊢ ↑S ⊆ ↑(closure ↑S).toSubmonoid [PROOFSTEP] exact Subgroup.subset_closure [GOAL] M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H P : Subgroup G ⊢ FG P ↔ AddSubgroup.FG (↑toAddSubgroup P) [PROOFSTEP] rw [Subgroup.fg_iff_submonoid_fg, AddSubgroup.fg_iff_addSubmonoid_fg] [GOAL] M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H P : Subgroup G ⊢ Submonoid.FG P.toSubmonoid ↔ AddSubmonoid.FG (↑toAddSubgroup P).toAddSubmonoid [PROOFSTEP] exact (Subgroup.toSubmonoid P).fg_iff_add_fg [GOAL] M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H P : AddSubgroup H ⊢ FG P ↔ Subgroup.FG (↑toSubgroup P) [PROOFSTEP] rw [AddSubgroup.fg_iff_addSubmonoid_fg, Subgroup.fg_iff_submonoid_fg] [GOAL] M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H P : AddSubgroup H ⊢ AddSubmonoid.FG P.toAddSubmonoid ↔ Submonoid.FG (↑toSubgroup P).toSubmonoid [PROOFSTEP] exact AddSubmonoid.fg_iff_mul_fg (AddSubgroup.toAddSubmonoid P) [GOAL] M : Type u_1 N : Type u_2 inst✝⁴ : Monoid M inst✝³ : AddMonoid N G : Type u_3 H : Type u_4 inst✝² : Group G inst✝¹ : AddGroup H inst✝ : Finite G ⊢ FG G [PROOFSTEP] cases nonempty_fintype G [GOAL] case intro M : Type u_1 N : Type u_2 inst✝⁴ : Monoid M inst✝³ : AddMonoid N G : Type u_3 H : Type u_4 inst✝² : Group G inst✝¹ : AddGroup H inst✝ : Finite G val✝ : Fintype G ⊢ FG G [PROOFSTEP] exact ⟨⟨Finset.univ, by rw [Finset.coe_univ]; exact Subgroup.closure_univ⟩⟩ [GOAL] M : Type u_1 N : Type u_2 inst✝⁴ : Monoid M inst✝³ : AddMonoid N G : Type u_3 H : Type u_4 inst✝² : Group G inst✝¹ : AddGroup H inst✝ : Finite G val✝ : Fintype G ⊢ Subgroup.closure ↑Finset.univ = ⊤ [PROOFSTEP] rw [Finset.coe_univ] [GOAL] M : Type u_1 N : Type u_2 inst✝⁴ : Monoid M inst✝³ : AddMonoid N G : Type u_3 H : Type u_4 inst✝² : Group G inst✝¹ : AddGroup H inst✝ : Finite G val✝ : Fintype G ⊢ Subgroup.closure Set.univ = ⊤ [PROOFSTEP] exact Subgroup.closure_univ [GOAL] M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H s : Finset G ⊢ FG { x // x ∈ Subgroup.closure ↑s } [PROOFSTEP] refine' ⟨⟨s.preimage Subtype.val (Subtype.coe_injective.injOn _), _⟩⟩ [GOAL] M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H s : Finset G ⊢ Subgroup.closure ↑(Finset.preimage s Subtype.val (_ : Set.InjOn (fun a => ↑a) (Subtype.val ⁻¹' ↑s))) = ⊤ [PROOFSTEP] rw [Finset.coe_preimage, ← Subgroup.coeSubtype, Subgroup.closure_preimage_eq_top] [GOAL] M : Type u_1 N : Type u_2 inst✝⁶ : Monoid M inst✝⁵ : AddMonoid N G : Type u_3 H : Type u_4 inst✝⁴ : Group G inst✝³ : AddGroup H G' : Type u_5 inst✝² : Group G' inst✝¹ : FG G inst✝ : FG G' f : G →* G' hf : Function.Surjective ↑f ⊢ rank G' ≤ rank G [PROOFSTEP] classical obtain ⟨S, hS1, hS2⟩ := Group.rank_spec G trans (S.image f).card · apply Group.rank_le rw [Finset.coe_image, ← MonoidHom.map_closure, hS2, Subgroup.map_top_of_surjective f hf] · exact Finset.card_image_le.trans_eq hS1 [GOAL] M : Type u_1 N : Type u_2 inst✝⁶ : Monoid M inst✝⁵ : AddMonoid N G : Type u_3 H : Type u_4 inst✝⁴ : Group G inst✝³ : AddGroup H G' : Type u_5 inst✝² : Group G' inst✝¹ : FG G inst✝ : FG G' f : G →* G' hf : Function.Surjective ↑f ⊢ rank G' ≤ rank G [PROOFSTEP] obtain ⟨S, hS1, hS2⟩ := Group.rank_spec G [GOAL] case intro.intro M : Type u_1 N : Type u_2 inst✝⁶ : Monoid M inst✝⁵ : AddMonoid N G : Type u_3 H : Type u_4 inst✝⁴ : Group G inst✝³ : AddGroup H G' : Type u_5 inst✝² : Group G' inst✝¹ : FG G inst✝ : FG G' f : G →* G' hf : Function.Surjective ↑f S : Finset G hS1 : Finset.card S = rank G hS2 : Subgroup.closure ↑S = ⊤ ⊢ rank G' ≤ rank G [PROOFSTEP] trans (S.image f).card [GOAL] M : Type u_1 N : Type u_2 inst✝⁶ : Monoid M inst✝⁵ : AddMonoid N G : Type u_3 H : Type u_4 inst✝⁴ : Group G inst✝³ : AddGroup H G' : Type u_5 inst✝² : Group G' inst✝¹ : FG G inst✝ : FG G' f : G →* G' hf : Function.Surjective ↑f S : Finset G hS1 : Finset.card S = rank G hS2 : Subgroup.closure ↑S = ⊤ ⊢ rank G' ≤ Finset.card (Finset.image (↑f) S) [PROOFSTEP] apply Group.rank_le [GOAL] case hS M : Type u_1 N : Type u_2 inst✝⁶ : Monoid M inst✝⁵ : AddMonoid N G : Type u_3 H : Type u_4 inst✝⁴ : Group G inst✝³ : AddGroup H G' : Type u_5 inst✝² : Group G' inst✝¹ : FG G inst✝ : FG G' f : G →* G' hf : Function.Surjective ↑f S : Finset G hS1 : Finset.card S = rank G hS2 : Subgroup.closure ↑S = ⊤ ⊢ Subgroup.closure ↑(Finset.image (↑f) S) = ⊤ [PROOFSTEP] rw [Finset.coe_image, ← MonoidHom.map_closure, hS2, Subgroup.map_top_of_surjective f hf] [GOAL] M : Type u_1 N : Type u_2 inst✝⁶ : Monoid M inst✝⁵ : AddMonoid N G : Type u_3 H : Type u_4 inst✝⁴ : Group G inst✝³ : AddGroup H G' : Type u_5 inst✝² : Group G' inst✝¹ : FG G inst✝ : FG G' f : G →* G' hf : Function.Surjective ↑f S : Finset G hS1 : Finset.card S = rank G hS2 : Subgroup.closure ↑S = ⊤ ⊢ Finset.card (Finset.image (↑f) S) ≤ rank G [PROOFSTEP] exact Finset.card_image_le.trans_eq hS1 [GOAL] M : Type u_1 N : Type u_2 inst✝⁵ : Monoid M inst✝⁴ : AddMonoid N G : Type u_3 H✝ : Type u_4 inst✝³ : Group G inst✝² : AddGroup H✝ H K : Subgroup G inst✝¹ : Group.FG { x // x ∈ H } inst✝ : Group.FG { x // x ∈ K } h : H = K ⊢ Group.rank { x // x ∈ H } = Group.rank { x // x ∈ K } [PROOFSTEP] subst h [GOAL] M : Type u_1 N : Type u_2 inst✝⁵ : Monoid M inst✝⁴ : AddMonoid N G : Type u_3 H✝ : Type u_4 inst✝³ : Group G inst✝² : AddGroup H✝ H : Subgroup G inst✝¹ inst✝ : Group.FG { x // x ∈ H } ⊢ Group.rank { x // x ∈ H } = Group.rank { x // x ∈ H } [PROOFSTEP] rfl [GOAL] M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H s : Finset G ⊢ Group.rank { x // x ∈ closure ↑s } ≤ Finset.card s [PROOFSTEP] classical let t : Finset (closure (s : Set G)) := s.preimage Subtype.val (Subtype.coe_injective.injOn _) have ht : closure (t : Set (closure (s : Set G))) = ⊤ := by rw [Finset.coe_preimage] exact closure_preimage_eq_top (s : Set G) apply (Group.rank_le (closure (s : Set G)) ht).trans suffices H : Set.InjOn Subtype.val (t : Set (closure (s : Set G))) rw [← Finset.card_image_of_injOn H, Finset.image_preimage] · apply Finset.card_filter_le · apply Subtype.coe_injective.injOn [GOAL] M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H s : Finset G ⊢ Group.rank { x // x ∈ closure ↑s } ≤ Finset.card s [PROOFSTEP] let t : Finset (closure (s : Set G)) := s.preimage Subtype.val (Subtype.coe_injective.injOn _) [GOAL] M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H s : Finset G t : Finset { x // x ∈ closure ↑s } := Finset.preimage s Subtype.val (_ : Set.InjOn (fun a => ↑a) (Subtype.val ⁻¹' ↑s)) ⊢ Group.rank { x // x ∈ closure ↑s } ≤ Finset.card s [PROOFSTEP] have ht : closure (t : Set (closure (s : Set G))) = ⊤ := by rw [Finset.coe_preimage] exact closure_preimage_eq_top (s : Set G) [GOAL] M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H s : Finset G t : Finset { x // x ∈ closure ↑s } := Finset.preimage s Subtype.val (_ : Set.InjOn (fun a => ↑a) (Subtype.val ⁻¹' ↑s)) ⊢ closure ↑t = ⊤ [PROOFSTEP] rw [Finset.coe_preimage] [GOAL] M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H s : Finset G t : Finset { x // x ∈ closure ↑s } := Finset.preimage s Subtype.val (_ : Set.InjOn (fun a => ↑a) (Subtype.val ⁻¹' ↑s)) ⊢ closure (Subtype.val ⁻¹' ↑s) = ⊤ [PROOFSTEP] exact closure_preimage_eq_top (s : Set G) [GOAL] M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H s : Finset G t : Finset { x // x ∈ closure ↑s } := Finset.preimage s Subtype.val (_ : Set.InjOn (fun a => ↑a) (Subtype.val ⁻¹' ↑s)) ht : closure ↑t = ⊤ ⊢ Group.rank { x // x ∈ closure ↑s } ≤ Finset.card s [PROOFSTEP] apply (Group.rank_le (closure (s : Set G)) ht).trans [GOAL] M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H s : Finset G t : Finset { x // x ∈ closure ↑s } := Finset.preimage s Subtype.val (_ : Set.InjOn (fun a => ↑a) (Subtype.val ⁻¹' ↑s)) ht : closure ↑t = ⊤ ⊢ Finset.card t ≤ Finset.card s [PROOFSTEP] suffices H : Set.InjOn Subtype.val (t : Set (closure (s : Set G))) [GOAL] M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H✝ : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H✝ s : Finset G t : Finset { x // x ∈ closure ↑s } := Finset.preimage s Subtype.val (_ : Set.InjOn (fun a => ↑a) (Subtype.val ⁻¹' ↑s)) ht : closure ↑t = ⊤ H : Set.InjOn Subtype.val ↑t ⊢ Finset.card t ≤ Finset.card s case H M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H s : Finset G t : Finset { x // x ∈ closure ↑s } := Finset.preimage s Subtype.val (_ : Set.InjOn (fun a => ↑a) (Subtype.val ⁻¹' ↑s)) ht : closure ↑t = ⊤ ⊢ Set.InjOn Subtype.val ↑t [PROOFSTEP] rw [← Finset.card_image_of_injOn H, Finset.image_preimage] [GOAL] M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H✝ : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H✝ s : Finset G t : Finset { x // x ∈ closure ↑s } := Finset.preimage s Subtype.val (_ : Set.InjOn (fun a => ↑a) (Subtype.val ⁻¹' ↑s)) ht : closure ↑t = ⊤ H : Set.InjOn Subtype.val ↑t ⊢ Finset.card (Finset.filter (fun x => x ∈ Set.range Subtype.val) s) ≤ Finset.card s [PROOFSTEP] apply Finset.card_filter_le [GOAL] case H M : Type u_1 N : Type u_2 inst✝³ : Monoid M inst✝² : AddMonoid N G : Type u_3 H : Type u_4 inst✝¹ : Group G inst✝ : AddGroup H s : Finset G t : Finset { x // x ∈ closure ↑s } := Finset.preimage s Subtype.val (_ : Set.InjOn (fun a => ↑a) (Subtype.val ⁻¹' ↑s)) ht : closure ↑t = ⊤ ⊢ Set.InjOn Subtype.val ↑t [PROOFSTEP] apply Subtype.coe_injective.injOn [GOAL] M : Type u_1 N : Type u_2 inst✝⁴ : Monoid M inst✝³ : AddMonoid N G : Type u_3 H : Type u_4 inst✝² : Group G inst✝¹ : AddGroup H s : Set G inst✝ : Finite ↑s ⊢ Group.rank { x // x ∈ closure s } ≤ Nat.card ↑s [PROOFSTEP] haveI := Fintype.ofFinite s [GOAL] M : Type u_1 N : Type u_2 inst✝⁴ : Monoid M inst✝³ : AddMonoid N G : Type u_3 H : Type u_4 inst✝² : Group G inst✝¹ : AddGroup H s : Set G inst✝ : Finite ↑s this : Fintype ↑s ⊢ Group.rank { x // x ∈ closure s } ≤ Nat.card ↑s [PROOFSTEP] rw [Nat.card_eq_fintype_card, ← s.toFinset_card, ← rank_congr (congr_arg _ s.coe_toFinset)] [GOAL] M : Type u_1 N : Type u_2 inst✝⁴ : Monoid M inst✝³ : AddMonoid N G : Type u_3 H : Type u_4 inst✝² : Group G inst✝¹ : AddGroup H s : Set G inst✝ : Finite ↑s this : Fintype ↑s ⊢ Group.rank { x // x ∈ closure ↑(Set.toFinset s) } ≤ Finset.card (Set.toFinset s) [PROOFSTEP] exact rank_closure_finset_le_card s.toFinset
#### # Tannistha Nandi # 19th July2018 ###Estimated diversity in the mouse gut and found differences between the various groups. #### #Figure 5C library(dplyr) library(Rcpp) library(tidyr) library(ggplot2) library(ggsignif) library(vegan) library(gridExtra) library(plyr) library(ggpubr) data=read.csv("../Data/Gavage_adjust_diversityV2.txt", header=T, stringsAsFactors = FALSE, sep="\t", row.names = 1) metadata=data[,1:3] data_s=data[,4:887] data_s=t(data_s) data_percent= apply(data_s, 2,function(x) x/sum(x)) data_s=t(data_percent) species = merge(data_s, metadata, by=0) rownames(species) = species$Row.names species = species[,-1] species$Diversity = diversity(species[,1:884], index = "simpson") # function to compute median summary summarySE_2 = function (data = NULL, measurevar, groupvars = NULL, na.rm = FALSE, conf.interval = 0.95, .drop = TRUE) { length2 <- function(x, na.rm = FALSE) { if (na.rm) sum(!is.na(x)) else length(x) } datac <- ddply(data, groupvars, .drop = .drop, .fun = function(xx, col, na.rm) { c(N = length2(xx[, col], na.rm = na.rm), mean = mean(xx[, col], na.rm = na.rm), median = median(xx[, col], na.rm = na.rm), sd = sd(xx[, col], na.rm = na.rm), mad=mad(xx[, col], na.rm = na.rm)) }, measurevar, na.rm) datac <- rename(datac, c(mean = measurevar)) datac$se <- datac$sd/sqrt(datac$N) ciMult <- qt(conf.interval/2 + 0.5, datac$N - 1) datac$ci <- datac$se * ciMult return(datac) } pd <- position_dodge(0.1) tgc <- summarySE_2(species, measurevar="Diversity", .drop= T,groupvars=c("Treatment", "Days")) tgc=filter(tgc,Treatment!="BC"&Treatment!="BCBA") #Filter off BC treated mice p <- ggplot(tgc, aes(x=Days, y=median, colour=Treatment, linetype=Treatment) ) + geom_errorbar(aes(ymin=(median - mad), ymax=(median + mad)), width=.5, position=pd) + geom_line(position=pd,size=1.5)+ geom_point(position=pd,size=4,shape=16) + xlab("Days since start of experiment") + ylab("Simpson Diversity") + scale_linetype_manual("", values=c("twodash", "twodash", "twodash", "twodash"), guide="none")+ scale_color_manual(values=c("darkkhaki", "cyan", "darkblue", "grey"))+ scale_x_continuous(limits=c(-1,23), breaks=c(0,3,6,7,10, 13, 16,19, 22)) + theme_bw() + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),legend.justification="center", legend.box.background = element_rect(), legend.box.margin = margin(6, 6, 6, 6), text=element_text(family="Arial"), legend.text=element_text(family="Arial", size=15),legend.title=element_text(family="Arial", size=20), axis.text.x = element_text(family="Arial", colour="grey20",size=15,angle=0,hjust=0.5,vjust=0.5,face="plain"), axis.text.y = element_text(family="Arial", colour="grey20",size=15,angle=0,hjust=1,vjust=0.5,face="plain"), axis.title.x = element_text(family="Arial", colour="grey20",size=15,angle=0,hjust=.5,vjust=0,face="bold"), axis.title.y = element_text(family="Arial", colour="grey20",size=15,angle=90,hjust=.5,vjust=.5,face="bold")) # Position legend in bottom right p ######### Wilcoxon Test x=species[which(species$Treatment=="BTBA" & species$Days==16 & species$Cage <3),] y=species[which(species$Treatment=="BA" & species$Days==16 | species$Treatment=="BT" & species$Days==16 & species$Cage<3 | species$Treatment=="PBS" & species$Days==16) ,] wilcox.test(x$Diversity, y$Diversity,alternative="g") x=species[which(species$Treatment=="BTBA" & species$Days==19 & species$Cage <3),] y=species[which(species$Treatment=="BA" & species$Days==19 | species$Treatment=="BT" & species$Days==19 & species$Cage<3 | species$Treatment=="PBS" & species$Days==19) ,] wilcox.test(x$Diversity, y$Diversity,alternative="g") x=species[which(species$Treatment=="BTBA" & species$Days==22 & species$Cage <3),] y=species[which(species$Treatment=="BA" & species$Days==22 | species$Treatment=="BT" & species$Days==22 & species$Cage<3 | species$Treatment=="PBS" & species$Days==22) ,] wilcox.test(x$Diversity, y$Diversity,alternative="g")
import analysis.calculus.mean_value import analysis.special_functions.pow_deriv import math.rpow open real theorem deriv_within_div_pow {C x : ℝ} (hx : x ≠ 0) (s : set ℝ) (hu : unique_diff_within_at ℝ s x) : ∀ n : ℕ, 1 < n → deriv_within (λ y : ℝ, C/y^n) s x = -n*C/x^(n+1):= begin intros n hn, conv { find (C) {rw show C = (λ y : ℝ, C) y, by simp}, }, rw deriv_within_div (differentiable_within_at_const C) (differentiable_within_at_pow n) (pow_ne_zero n hx) hu, field_simp [deriv_within_const x s C hu, deriv_within_pow n hu], rw [mul_assoc, mul_assoc, ← pow_add, add_comm n 1, ← add_assoc, nat.sub_add_cancel (le_of_lt hn), pow_two, ← pow_add, ← mul_assoc, mul_comm C _], end theorem has_deriv_at_div_pow {C x : ℝ} (hx : x ≠ 0) : ∀ n : ℕ, 1 < n → has_deriv_at (λ y : ℝ, C/y^n) (-n*C/x^(n+1)) x := begin intros n hn, conv { find (C) {rw show C = (λ y : ℝ, C) y, by simp}, }, rw show -↑n * C / x ^ (n + 1) = (0*x^n-((λ y : ℝ, C) x)*(n*x^(n-1)))/(x^n)^2, by {field_simp, iterate 3 {rw [mul_assoc],}, rw [← pow_add, add_comm n 1, ← add_assoc, nat.sub_add_cancel (le_of_lt hn), pow_two, ← pow_add], ring_exp, }, apply has_deriv_at.div (has_deriv_at_const x C) (has_deriv_at_pow n x), simp [pow_ne_zero n hx], end theorem differentiable_at_div_pow {C x : ℝ} (hx : x ≠ 0) : ∀ n : ℕ, differentiable_at ℝ (λ y : ℝ, C/y^n) x := begin intro, conv { find (C) {rw show C = (λ y : ℝ, C) y, by simp}, }, apply differentiable_at.div (differentiable_at_const C) (differentiable_at_pow n) (pow_ne_zero n hx), end theorem deriv_div_pow {C x : ℝ} (hx : x ≠ 0) : ∀ n : ℕ, 1 < n → deriv (λ y : ℝ, C/y^n) x = -n*C/x^(n+1):= begin intros n hn, apply has_deriv_at.deriv (has_deriv_at_div_pow hx _ hn), end theorem deriv_inv_rpow {C z: ℝ} (hz : 0 < z) : ∀ r:ℝ, 1 ≤ r → deriv (λ x:ℝ, C/x^r) z = -r*C/z^(r+1):= begin intros n hr, have h : (λ x:ℝ, C/x^n) = λ x:ℝ, ((λ x:ℝ, C) x)/((λ x:ℝ, x^n) x) := by simp, rw [h, deriv_div], simp, have h2 : z^(n-1)/(z^n)^2 = 1/z^(n+1), { rw [rpow_sub, rpow_one, pow_two], field_simp, rw [← mul_assoc, div_mul_left, mul_comm z _, ← rpow_add_one], linarith, apply rpow_ne_zero hz, linarith, linarith,}, have h3 : deriv (λ (x : ℝ), x ^ n) z = n*z^(n-1), { rw real.deriv_rpow_const, right, exact hr}, rw [h3, ← mul_assoc, neg_div, mul_div_assoc, pow_two, ← rpow_add hz, ← rpow_sub hz, show n-1-(n+n) = -(n+1), by { rw ← sub_sub, simp, ring_nf}], have hz1 : 0 ≤ z, by linarith, rw [rpow_neg hz1 (n+1), mul_comm C n, neg_div], field_simp, simp, simp, apply has_deriv_at.differentiable_at, apply real.has_deriv_at_rpow_const (or.inr hr), simp, rw ← ne.def, apply rpow_ne_zero hz, linarith, end theorem differentiable_at_inv_rpow {C z: ℝ} (hz : 0 < z) : ∀ r:ℝ, 1 ≤ r → differentiable_at ℝ (λ x:ℝ, C/x^r) z := begin intros n hr, have h : (λ x:ℝ, C/x^n) = λ x:ℝ, ((λ x:ℝ, C) x)/((λ x:ℝ, x^n) x) := by simp, apply has_deriv_at.differentiable_at, rw h, apply has_deriv_at.div, apply has_deriv_at_const, apply has_deriv_at_rpow_const hr.inr, simp, rw ← ne.def, apply ne_of_gt, apply zero_lt_rpow hz, linarith, end lemma deriv_abs_of_nonneg_rpow {z : ℝ} (hpos : ∀ x : ℝ, 0 ≤ x) : ∀ r:ℝ, 1 ≤ r → (deriv (λ x : ℝ, |x^r|) z) = r * z ^ (r - 1):= begin intros r hr, conv { find (|_^r|) {rw [abs_rpow_of_nonneg (hpos x), abs_of_nonneg (hpos x)],}}, rw real.deriv_rpow_const, exact hr.inr, end lemma deriv_inv_abs_rpow {C z: ℝ} (hz : 0 < z) (hC : 0 < C) (hpos : ∀ x : ℝ, 0 < x) : ∀ r:ℝ, 1 ≤ r → deriv (λ x : ℝ , |C|/|x^r|) z = -r*C/z^(r+1):= begin intros r hr, simp only [abs_of_pos hC], have hnonneg : ∀ x : ℝ, 0 ≤ x := by {intro x, refine le_of_lt (hpos x)}, conv { find (|_^r|) {rw [abs_rpow_of_nonneg (hnonneg x), abs_of_nonneg (hnonneg x)],}}, apply deriv_inv_rpow hz _ hr, end theorem differentiable_at_inv_abs_rpow {C z: ℝ} (hz : 0 < z) (hC : 0 < C) (hpos : ∀ x : ℝ, 0 < x) : ∀ r:ℝ, 1 ≤ r → differentiable_at ℝ (λ x:ℝ, |C|/|x^r|) z := begin intros r hr, simp only [abs_of_pos hC], have hnonneg : ∀ x : ℝ, 0 ≤ x := by {intro x, refine le_of_lt (hpos x)}, conv { find (|_^r|) {rw [abs_rpow_of_nonneg (hnonneg x), abs_of_nonneg (hnonneg x)],}}, apply differentiable_at_inv_rpow hz r hr, end
classdef homochoricPlot < axisAnglePlot methods function oP = homochoricPlot(varargin) % create a 3d Euler angle plot oP = oP@axisAnglePlot(varargin{:}); end function [x,y,z] = project(oP,ori,varargin) if ~check_option(varargin,'noBoundaryCheck') switch oP.fRMode case 'project2FundamentalRegion' ori = project2FundamentalRegion(ori); case 'restrict2FundamentalRegion' ori(~oP.oR.checkInside) = NaN; end end [x,y,z] = double(homochoric(ori)); end function ori = iproject(oP,x,y,z,varargin) ori = orientation.id; end function ori = makeGrid(oP,varargin) [ori,S2G,omega] = makeGrid@axisAnglePlot(oP,varargin{:}); [oP.plotGrid.x,oP.plotGrid.y,oP.plotGrid.z] = ... double( S2G .* (3./4 * (omega - sin(omega))).^(1/3)); end end end
#pragma once #define GLM_ENABLE_EXPERIMENTAL #include <glm/glm.hpp> #include <gsl/gsl> namespace Library { class Mesh; template <typename T> struct VertexDeclaration { static constexpr uint32_t VertexSize() { return gsl::narrow_cast<uint32_t>(sizeof(T)); } static constexpr uint32_t VertexBufferByteWidth(size_t vertexCount) { return gsl::narrow_cast<uint32_t>(sizeof(T) * vertexCount); } static void CreateVertexBuffer(const gsl::span<const T>& vertices, GLuint& vertexBuffer); }; struct VertexPosition final : public VertexDeclaration<VertexPosition> { glm::vec4 Position{ 0 }; VertexPosition() = default; VertexPosition(const glm::vec4& position) : Position(position) { } static void CreateVertexBuffer(const Library::Mesh& mesh, GLuint& vertexBuffer); static void CreateVertexBuffer(const gsl::span<const VertexPosition>& vertices, GLuint& vertexBuffer) { VertexDeclaration::CreateVertexBuffer(vertices, vertexBuffer); } }; struct VertexPositionColor final :public VertexDeclaration<VertexPositionColor> { glm::vec4 Position{ 0 }; glm::vec4 Color{ 0 }; VertexPositionColor() = default; VertexPositionColor(const glm::vec4& position, const glm::vec4& color) : Position(position), Color(color) { } static void CreateVertexBuffer(const Library::Mesh& mesh, GLuint& vertexBuffer, bool randomColor = false); static void CreateVertexBuffer(const gsl::span<const VertexPositionColor>& vertices, GLuint& vertexBuffer) { VertexDeclaration::CreateVertexBuffer(vertices, vertexBuffer); } }; struct VertexPositionTexture final : public VertexDeclaration<VertexPositionTexture> { glm::vec4 Position{ 0 }; glm::vec2 TextureCoordinates{ 0 }; VertexPositionTexture() = default; VertexPositionTexture(const glm::vec4& position, const glm::vec2& textureCoordinates) : Position(position), TextureCoordinates(textureCoordinates) { } static void CreateVertexBuffer(const Library::Mesh& mesh, GLuint& vertexBuffer); static void CreateVertexBuffer(const gsl::span<const VertexPositionTexture>& vertices, GLuint& vertexBuffer) { VertexDeclaration::CreateVertexBuffer(vertices, vertexBuffer); } }; struct VertexPositionNormal final : public VertexDeclaration<VertexPositionNormal> { glm::vec4 Position{ 0 }; glm::vec3 Normal{ 0 }; VertexPositionNormal() = default; VertexPositionNormal(const glm::vec4& position, const glm::vec3& normal) : Position(position), Normal(normal) { } static void CreateVertexBuffer(const Library::Mesh& mesh, GLuint& vertexBuffer); static void CreateVertexBuffer(const gsl::span<const VertexPositionNormal>& vertices, GLuint& vertexBuffer) { VertexDeclaration::CreateVertexBuffer(vertices, vertexBuffer); } }; struct VertexPositionTextureNormal final : public VertexDeclaration<VertexPositionTextureNormal> { glm::vec4 Position{ 0 }; glm::vec2 TextureCoordinates{ 0 }; glm::vec3 Normal{ 0 }; VertexPositionTextureNormal() = default; VertexPositionTextureNormal(const glm::vec4& position, const glm::vec2& textureCoordinates, const glm::vec3& normal) : Position(position), TextureCoordinates(textureCoordinates), Normal(normal) { } static void CreateVertexBuffer(const Library::Mesh& mesh, GLuint& vertexBuffer); static void CreateVertexBuffer(const gsl::span<const VertexPositionTextureNormal>& vertices, GLuint& vertexBuffer) { VertexDeclaration::CreateVertexBuffer(vertices, vertexBuffer); } }; struct VertexPositionTextureNormalTangentBinormal final : public VertexDeclaration<VertexPositionTextureNormalTangentBinormal> { glm::vec4 Position{ 0 }; glm::vec2 TextureCoordinates{ 0 }; glm::vec3 Normal{ 0 }; glm::vec3 Tangent{ 0 }; glm::vec3 Binormal{ 0 }; VertexPositionTextureNormalTangentBinormal() = default; VertexPositionTextureNormalTangentBinormal(const glm::vec4& position, const glm::vec2& textureCoordinates, const glm::vec3& normal, const glm::vec3& tangent, const glm::vec3& binormal) : Position(position), TextureCoordinates(textureCoordinates), Normal(normal), Tangent(tangent), Binormal(binormal) { } static void CreateVertexBuffer(const Library::Mesh& mesh, GLuint& vertexBuffer); static void CreateVertexBuffer(const gsl::span<const VertexPositionTextureNormalTangentBinormal>& vertices, GLuint& vertexBuffer) { VertexDeclaration::CreateVertexBuffer(vertices, vertexBuffer); } }; }
module UniDB.Subst.Reg where open import UniDB.Spec open import UniDB.Subst.Core open import UniDB.Morph.Reg open import UniDB.Morph.WeakenPrime module _ {T : STX} {{vrT : Vr T}} {{wkT : Wk T}} {{apTT : Ap T T}} where instance iCompReg : Comp (Reg T) _⊙_ {{iCompReg}} (baseR ξ) ζ = ξ ⊡ ζ _⊙_ {{iCompReg}} (snocR {γ₁} {γ₂} ξ t) ζ = snocR (ξ ⊙ ζ) (ap {T} ζ t) iWkmHomReg : WkmHom (Reg T) wkm-zero {{iWkmHomReg}} = refl wkm-suc {{iWkmHomReg}} δ = refl iWkmBetaReg : WkmBeta T (Reg T) wkm-beta {{iWkmBetaReg}} t = refl reg-zero : (γ : Dom) → Reg T zero γ reg-zero zero = baseR baseW reg-zero (suc γ) = reg-zero γ ⊙ wkm {Reg T} 1 complete : (γ₁ γ₂ : Dom) (f : Ix γ₁ → T γ₂) → Reg T γ₁ γ₂ complete zero γ₂ f = reg-zero γ₂ complete (suc γ₁) γ₂ f = snocR (complete γ₁ γ₂ (f ∘ suc)) (f zero) ⊡-⊙-assoc : {γ₁ γ₂ γ₃ γ₄ : Dom} (ξ₁ : Weaken` γ₁ γ₂) (ξ₂ : Reg T γ₂ γ₃) (ξ₃ : Reg T γ₃ γ₄) → ξ₁ ⊡ (ξ₂ ⊙ ξ₃) ≡ (ξ₁ ⊡ ξ₂) ⊙ ξ₃ ⊡-⊙-assoc ξ₁ (baseR ξ₂) ξ₃ = ⊡-⊡-assoc ξ₁ ξ₂ ξ₃ ⊡-⊙-assoc baseW ξ₂ ξ₃ rewrite idm-⊡ {Weaken`} {Reg T} (ξ₂ ⊙ ξ₃) | idm-⊡ {Weaken`} {Reg T} ξ₂ = refl ⊡-⊙-assoc (stepW ξ₁) (snocR ξ₂ t) ξ₃ = ⊡-⊙-assoc ξ₁ ξ₂ ξ₃ wk₁-⊡ : {γ₁ γ₂ γ₃ : Dom} (ξ₁ : Weaken` γ₁ γ₂) (ξ₂ : Reg T γ₂ γ₃) → wk₁ (_⊡_ {Weaken`} {Reg T} {Reg T} ξ₁ ξ₂) ≡ ξ₁ ⊡ wk₁ ξ₂ wk₁-⊡ ξ₁ (baseR ξ) = refl wk₁-⊡ baseW (snocR ξ₂ t) = refl wk₁-⊡ (stepW ξ₁) (snocR ξ₂ t) = wk₁-⊡ ξ₁ ξ₂ module _ {T : STX} {{vrT : Vr T}} {{wkT : Wk T}} {{apTT : Ap T T}} {{wkVrT : WkVr T}} where instance iCompIdmReg : {{apRelTT : ApRel T T}} {{apIdmTT : ApIdm T T}} → CompIdm (Reg T) ⊙-idm {{iCompIdmReg}} (baseR ξ) = refl ⊙-idm {{iCompIdmReg}} (snocR ξ t) = cong₂ snocR (⊙-idm {Reg T} ξ) (ap-idm` {T} t) idm-⊙ {{iCompIdmReg}} ξ = idm-⊡ {Weaken`} {Reg T} ξ lk-⊡ : {{apVr : ApVr T}} {γ₁ γ₂ γ₃ : Dom} (ξ₁ : Weaken` γ₁ γ₂) (ξ₂ : Reg T γ₂ γ₃) → (i : Ix γ₁) → lk {T} {Reg T} (ξ₁ ⊡ ξ₂) i ≡ ap {T} ξ₂ (lk {T} ξ₁ i) lk-⊡ ξ₁ (baseR ξ₂) i = begin lk (ξ₁ ⊙ ξ₂) i ≡⟨ lk-ren-comp {T} ξ₁ ξ₂ i ⟩ lk ξ₂ (lk ξ₁ i) ≡⟨ sym (ap-vr {T} (baseR ξ₂) (lk ξ₁ i)) ⟩ ap {T} (baseR ξ₂) (vr (lk ξ₁ i)) ≡⟨ cong (ap {T} (baseR ξ₂)) (sym (lk-ren {T} ξ₁ i)) ⟩ ap {T} (baseR ξ₂) (lk ξ₁ i) ∎ lk-⊡ baseW ξ₂ i = begin lk {T} {Reg T} (baseW ⊡ ξ₂) i ≡⟨ cong₂ lk (idm-⊡ {Weaken`} ξ₂) refl ⟩ lk {T} {Reg T} ξ₂ i ≡⟨ sym (ap-vr {T} ξ₂ i) ⟩ ap {T} ξ₂ (vr i) ∎ lk-⊡ (stepW ξ₁) (snocR ξ₂ t) i = begin lk {T} {Reg T} (ξ₁ ⊡ ξ₂) i ≡⟨ lk-⊡ ξ₁ ξ₂ i ⟩ ap {T} ξ₂ (vr (lk ξ₁ i)) ≡⟨ ap-vr {T} ξ₂ (lk ξ₁ i) ⟩ lk ξ₂ (lk ξ₁ i) ≡⟨ refl ⟩ lk (snocR ξ₂ t) (suc (lk ξ₁ i)) ≡⟨ sym (ap-vr {T} (snocR ξ₂ t) (suc (lk ξ₁ i))) ⟩ ap {T} (snocR ξ₂ t) (vr (suc (lk ξ₁ i))) ∎ instance iLkCompApReg : {{apVr : ApVr T}} → LkCompAp T (Reg T) lk-⊙-ap {{iLkCompApReg}} (baseR ξ₁) ξ₂ i = lk-⊡ ξ₁ ξ₂ i lk-⊙-ap {{iLkCompApReg}} (snocR ξ₁ t) ξ₂ zero = refl lk-⊙-ap {{iLkCompApReg}} (snocR ξ₁ t) ξ₂ (suc i) = lk-⊙-ap {T} ξ₁ ξ₂ i wk₁-⊙ : {{apWkTT : ApWk T T}} {γ₁ γ₂ γ₃ : Dom} (ξ₁ : Reg T γ₁ γ₂) (ξ₂ : Reg T γ₂ γ₃) → wk₁ (ξ₁ ⊙ ξ₂) ≡ wk₁ ξ₁ ⊙ snocR (wk₁ ξ₂) (Vr.vr vrT zero) wk₁-⊙ (baseR ξ) ξ₂ = wk₁-⊡ ξ ξ₂ wk₁-⊙ (snocR ξ₁ t) ξ₂ = cong₂ snocR (wk₁-⊙ ξ₁ ξ₂) (sym (ap-wk₁ {T} ξ₂ t)) instance iUpCompReg : {{apVrT : ApVr T}} {{apWkTT : ApWk T T}} → UpComp (Reg T) ⊙-↑₁ {{iUpCompReg}} ξ₁ ξ₂ = cong₂ snocR (wk₁-⊙ ξ₁ ξ₂) (sym (ap-vr {T} (snocR (wk₁ ξ₂) (vr zero)) zero)) iCompAssocReg : {{apVrT : ApVr T}} {{apCompT : ApComp T T}} {{apWkTT : ApWk T T}} → CompAssoc (Reg T) ⊙-assoc {{iCompAssocReg}} (baseR ξ₁) ξ₂ ξ₃ = ⊡-⊙-assoc ξ₁ ξ₂ ξ₃ ⊙-assoc {{iCompAssocReg}} (snocR ξ₁ t) ξ₂ ξ₃ = cong₂ snocR (⊙-assoc {Reg T} ξ₁ ξ₂ ξ₃) (ap-⊙ {T} ξ₂ ξ₃ t) ⊙-wkm₁-reg : {{apWkmWkTT : ApWkmWk T T}} {γ₁ γ₂ : Dom} (ξ : Reg T γ₁ γ₂) → ξ ⊙ wkm {Reg T} 1 ≡ wk₁ ξ ⊙-wkm₁-reg (baseR ξ) = refl ⊙-wkm₁-reg (snocR ξ t) rewrite sym (wk1-wk₁ t) = cong₂ snocR (⊙-wkm₁-reg ξ) (ap-wkm-wk {T} 1 t) instance iWkmCommReg : {{apVr : ApVr T}} {{apCompT : ApComp T T}} {{apWkTT : ApWk T T}} {{apWkmWkTT : ApWkmWk T T}} {{apRelTT : ApRel T T}} {{apIdmTT : ApIdm T T}} → WkmComm (Reg T) wkm₁-comm {{iWkmCommReg}} (baseR baseW) = refl wkm₁-comm {{iWkmCommReg}} (baseR (stepW ξ)) rewrite idm-⊙ {Weaken`} ξ = refl wkm₁-comm {{iWkmCommReg}} (snocR ξ t) = ⊙-wkm₁-reg (snocR ξ t)
Formal statement is: lemma open_ball [intro, simp]: "open (ball x e)" Informal statement is: The open ball of radius $e$ around $x$ is open.
[STATEMENT] lemma "(B \<one> 6) \<otimes> (B 4 5) = B 4 11" [PROOF STATE] proof (prove) goal (1 subgoal): 1. simple_int.B \<one> 6 \<otimes> simple_int.B 4 5 = simple_int.B 4 11 [PROOF STEP] by eval
Sometimes when homeowners lose their homes to the bank, what they leave behind isn’t in good enough condition for sale. That’s when builders like us are called in to help fix things up. The sun room needed a bit of work, but cleaned up nicely. Take a look at how the family room came out. And we also did work in the basement. All in all, this house cleaned up beautifully and we were pleased to leave it ready for new owners.
# .hlpr_create_matrix ---- .hlpr_create_matrix <- function(frame, object, column = "r") { if ("Group" %in% names(object)) { out <- data.frame() for (g in unique(object$Group)) { data <- object[object$Group == g, ] m <- .hlpr_fill_matrix(frame, data, column = column) m$Group <- g out <- rbind(out, m) } out <- out[c("Group", names(out)[names(out) != "Group"])] } else { out <- .hlpr_fill_matrix(frame, object, column = column) } return(out) }
Require Import List. Require Import Program. Lemma exists_Forall2_fw A B (R : A -> B -> Prop) x1 l1 l2 : In x1 l1 -> Forall2 (fun x1 x2 => R x1 x2) l1 l2 -> exists x2, R x1 x2 /\ In x2 l2. revert l2. induction l1. easy. destruct l2. easy. intros. dependent destruction H0. destruct H. exists b. split. rewrite <- H. auto. left. auto. destruct (IHl1 l2); auto. exists x. destruct H2. split. auto. right. auto. Qed. Lemma exists_Forall2_bw A B (R : A -> B -> Prop) x2 l1 l2 : In x2 l2 -> Forall2 (fun x1 x2 => R x1 x2) l1 l2 -> exists x1, R x1 x2 /\ In x1 l1. revert l1. induction l2. easy. destruct l1. easy. intros. dependent destruction H0. destruct H. exists a0. split. rewrite <- H. auto. left. auto. destruct (IHl2 l1); auto. exists x. destruct H2. split. auto. right. auto. Qed. Lemma Forall2_map_com A B C D (R : C -> D -> Prop) (F1 : A -> C) (F2 : B -> D) l1 l2 : Forall2 R (map F1 l1) (map F2 l2) <-> Forall2 (fun x1 x2 => R (F1 x1) (F2 x2)) l1 l2. split; intro. dependent induction H. destruct l1; try easy. destruct l2; try easy. destruct l1; try easy. destruct l2; try easy. simplify_eq x1. simplify_eq x. intros. apply Forall2_cons. rewrite <- H1. rewrite <- H3. auto. auto. dependent induction H. apply Forall2_nil. apply Forall2_cons; auto. Qed. Lemma Forall2_self A (R : A -> A -> Prop) l : (forall x, In x l -> R x x) -> Forall2 (fun x1 x2 => R x1 x2) l l. rewrite <- Forall_forall. induction 1. easy. apply Forall2_cons; easy. Qed. Lemma Forall2_map A B C (R : B -> C -> Prop) (F1 : A -> B) (F2 : A -> C) l : (forall x, In x l -> R (F1 x) (F2 x)) -> Forall2 R (map F1 l) (map F2 l). rewrite <- Forall_forall. intro. dependent induction H. apply Forall2_nil. apply Forall2_cons; auto. Qed. Lemma repeat_app_com A (x : A) n1 n2 : repeat x n1 ++ repeat x n2 = repeat x (n1 + n2). induction n1; auto. simpl. rewrite IHn1. auto. Qed.
Formal statement is: lemma is_real_interval_union: "is_interval (X \<union> Y)" if X: "is_interval X" and Y: "is_interval Y" and I: "(X \<noteq> {} \<Longrightarrow> Y \<noteq> {} \<Longrightarrow> X \<inter> Y \<noteq> {})" for X Y::"real set" Informal statement is: If $X$ and $Y$ are intervals and $X \cap Y \neq \emptyset$, then $X \cup Y$ is an interval.
using JuMP using Gurobi using JLD2 using Suppressor using Printf using XLSX
! This Solver initialize the two DG variable (have to be run to time) RECURSIVE SUBROUTINE InitializeDGVariable(Model, Solver, Timestep, TransientSimulation) USE DefUtils USE Materialmodels !----------------------------------------------------------- IMPLICIT NONE !------------ external variables --------------------------- TYPE(Model_t) :: Model TYPE(Solver_t), TARGET :: Solver LOGICAL :: TransientSimulation REAL(KIND=dp) :: Timestep !------------ internal variables --------------------------- REAL(KIND=dp) :: z, D INTEGER :: i, j, k, t, n, dummyInt, Active, Indexes(128) LOGICAL :: GotIt,UnFoundFatal TYPE(Element_t), POINTER :: Element TYPE(Mesh_t), POINTER :: Mesh TYPE(Nodes_t) :: ElementNodes CHARACTER(LEN=MAX_NAME_LEN) :: VariableName, SolverName TYPE(ValueList_t), POINTER :: SolverParams TYPE(Variable_t), POINTER :: VarSol REAL(KIND=dp), ALLOCATABLE :: Depth(:) SolverName = 'InitializeDGVariable' Mesh => GetMesh() n = Mesh % MaxElementNodes ALLOCATE(ElementNodes % x(n), ElementNodes % y(n), ElementNodes % z(n), & Depth(n)) SolverParams => GetSolverParams() VariableName = GetString(SolverParams,'Initialized Variable Name', GotIt) IF (.NOT.GotIt) THEN WRITE(Message,'(a)')'Keyword >Initialized Variable Name< not found in Solver section' CALL FATAL(SolverName, Message) END IF VarSol => VariableGet(Solver % Mesh % Variables,VariableName,UnFoundFatal=UnFoundFatal) Active = GetNOFActive() DO t = 1, Active Element => GetActiveElement( t ) n = GetElementNOfNodes( Element ) dummyInt = GetElementDOFs( Indexes ) CALL GetElementNodes( ElementNodes ) ! Non DG other variable should be read like this ! Don't use their perm and the j indexes as it will be wrong ! when the solver is called for a DG variable CALL GetScalarLocalSolution(Depth,'Depth') DO i=1,n j = Indexes(i) z = ElementNodes % z(i) D = Depth(i) VarSol % Values(VarSol % Perm(j)) = 1.0_dp - 0.6_dp*z/100.0 write(*,*)t,i,j,k, z+D END DO END DO DEALLOCATE(ElementNodes % x, ElementNodes % y, ElementNodes % z, Depth) END SUBROUTINE InitializeDGVariable
lemma (in first_countable_topology) sequentially_imp_eventually_within: "(\<forall>f. (\<forall>n. f n \<in> s \<and> f n \<noteq> a) \<and> f \<longlonglongrightarrow> a \<longrightarrow> eventually (\<lambda>n. P (f n)) sequentially) \<Longrightarrow> eventually P (at a within s)"
#This script takes the output of the Snakemake pvacseq module for each patient and combines it into one large table to upload to the db (analysis.neoantigens_by_patient table) #Additionally generates a .txt file for backup #First it labels each sample's table with the proper case barcode, then it combines the labelled tables into one large table and uploads #----------------------------------------------------- library(DBI) library(odbc) rm(list=ls()) myDir1 <- "/projects/varnf/GLASS/GLASS/results/pvacseq/neoantigens/" myintDir <- "/projects/varnf/GLASS/GLASS/results/pvacseq/tabular_results/labelled/" myoutf <- "/projects/varnf/GLASS/GLASS/results/pvacseq/tabular_results/final/neoantigens_full.txt" myrun <- dir(myDir1) mysample <- sapply(strsplit(myrun,"_"),function(x)x[1]) myfile <- paste(myDir1,myrun,"/MHC_Class_I/",myrun,".final.tsv",sep="") file.exist <- file.exists(myfile) mysample <- mysample[which(file.exist)] myfile <- myfile[which(file.exist)] myintfile <- paste(myintDir,mysample,".labelled.txt",sep="") for(i in 1:length(myfile)) { tumor_barcode <- sapply(strsplit(myfile[i],"/"),function(x)x[9]) tmp.table <- read.delim(myfile[i],stringsAsFactor=FALSE, colClasses=c(Chromosome="character", Start="numeric",Stop="numeric", Reference="character", Variant="character", Transcript="character", Ensembl.Gene.ID="character", Variant.Type="character",Mutation="character", Protein.Position="character",Gene.Name="character", HLA.Allele="character",Peptide.Length="numeric", Sub.peptide.Position="numeric",Mutation.Position="numeric", MT.Epitope.Seq="character",WT.Epitope.Seq="character", Best.MT.Score.Method="character",Best.MT.Score="numeric", Corresponding.WT.Score="numeric",Corresponding.Fold.Change="numeric", Tumor.DNA.Depth="numeric",Tumor.DNA.VAF="numeric", Tumor.RNA.Depth="numeric",Tumor.RNA.VAF="numeric", Normal.Depth="numeric",Normal.VAF="numeric", Gene.Expression="numeric",Transcript.Expression="numeric", Median.MT.Score="numeric",Median.WT.Score="numeric", Median.Fold.Change="numeric",NetMHCpan.WT.Score="numeric", NetMHCpan.MT.Score="numeric")) tumor_barcode <- rep(tumor_barcode, nrow(tmp.table)) tmp.table <- cbind(tmp.table,tumor_barcode) write.table(tmp.table, myintfile[i], sep="\t", quote=FALSE) } big_table <- do.call(rbind, lapply(myintfile, function(x) read.delim(x, stringsAsFactors = FALSE, colClasses=c(Chromosome="character", Start="integer",Stop="integer", Reference="character", Variant="character", Transcript="character", Ensembl.Gene.ID="character", Variant.Type="character",Mutation="character", Protein.Position="character",Gene.Name="character", HLA.Allele="character",Peptide.Length="integer", Sub.peptide.Position="integer",Mutation.Position="integer", MT.Epitope.Seq="character",WT.Epitope.Seq="character", Best.MT.Score.Method="character",Best.MT.Score="numeric", Corresponding.WT.Score="numeric",Corresponding.Fold.Change="numeric", Tumor.DNA.Depth="numeric",Tumor.DNA.VAF="numeric", Tumor.RNA.Depth="numeric",Tumor.RNA.VAF="numeric", Normal.Depth="numeric",Normal.VAF="numeric", Gene.Expression="numeric",Transcript.Expression="numeric", Median.MT.Score="numeric",Median.WT.Score="numeric", Median.Fold.Change="numeric",NetMHCpan.WT.Score="numeric", NetMHCpan.MT.Score="numeric")))) #Choose columns with information. Note: For this run Best and Median scores/fold-changes are the same because only NetMHCpan was used big_table_edit <- big_table[,c("tumor_barcode","Chromosome","Start","Stop","Reference", "Variant","Transcript","Ensembl.Gene.ID","Variant.Type","Mutation","Protein.Position", "Gene.Name","HLA.Allele","Peptide.Length","Sub.peptide.Position","Mutation.Position", "MT.Epitope.Seq","WT.Epitope.Seq","NetMHCpan.MT.Score","NetMHCpan.WT.Score", "Corresponding.Fold.Change")] colnames(big_table_edit) <- tolower(c("tumor_barcode","chrom","Start","Stop","ref", "alt","Transcript","Ensembl_Gene_ID","Variant_Type","Mutation","Protein_Position", "Gene_Name","HLA_Allele","Peptide_Length","Sub_peptide_Position","Mutation_Position", "MT_Epitope_Seq","WT_Epitope_Seq","NetMHCpan_MT_Score","NetMHCpan_WT_Score", "NetMHCpan_Fold_Change")) #Change X chromosone to 23 for speed big_table_edit[which(big_table_edit[,"chrom"]=='X'),"chrom"] = 23 big_table_edit[,"chrom"] = as.numeric(big_table_edit[,"chrom"]) con <- DBI::dbConnect(odbc::odbc(), "VerhaakDB") dbWriteTable(con, Id(schema="analysis",table="neoantigens_by_patient"), big_table_edit, overwrite=TRUE, row.names=FALSE) write.table(big_table_edit, myoutf,sep="\t",quote=F,row.names=F)
# # Copyright (c) 2017, Massachusetts Institute of Technology All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # # Redistributions in binary form must reproduce the above copyright notice, this # list of conditions and the following disclaimer in the documentation and/or # other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # import numpy as _N import ctypes as _C def _mimport(name, level=1): try: return __import__(name, globals(), level=level) except: return __import__(name, globals()) _ver=_mimport('version') _data=_mimport('mdsdata') _exc=_mimport('mdsExceptions') _mds=_ver.load_library('MdsShr') class MdsshrException(_exc.MDSplusException): pass def getenv(name,*default): """get environment variable value @param name: name of environment variable @type name: str @return: value of environment variable or None if not defined @rtype: str or None """ tl = _mds.TranslateLogical tl.restype=_C.c_void_p ptr = tl(_ver.tobytes(name)) if ptr is None: if len(default)>0: return default[0] return None ptr = _C.c_void_p(ptr) try: return _ver.tostr(_C.cast(ptr,_C.c_char_p).value) finally: _mds.TranslateLogicalFree(ptr) def setenv(name,value): """set environment variable @param name: name of the environment variable @type name: str @param value: value of the environment variable @type value: str """ pe=_mds.MdsPutEnv pe(_ver.tobytes("=".join([str(name),str(value)]))) def DateToQuad(date): ans=_C.c_ulonglong(0) status = _mds.LibConvertDateString(_C.c_char_p(_ver.tobytes(date)),_C.pointer(ans)) if not (status & 1): raise MdsshrException("Cannot parse %s as date. Use dd-mon-yyyy hh:mm:ss.hh format or \"now\",\"today\",\"yesterday\"." % (date,)) return _data.Data(_N.uint64(ans.value))
" Dangerously in Love 2 "
% The COBRA Toolbox: testexportSetToGAMS % % Purpose: % - test exportSetToGAMS function % % Authors: % - Loic Marx, November 2018 % save the current path currentDir = pwd; % initialize the test fileDir = fileparts(which(mfilename)); cd(fileDir); % if nargin < 2 model = getDistributedModel('ecoli_core_model.mat'); fileName = 'refData_reactions.txt'; % read in the file rxnsRef = textread(fileName, '%s', 'delimiter', '\n'); % test if the first and end cells are equal to / assert(isequal(rxnsRef{1}, '/')) assert(isequal(rxnsRef{end}, '/')) % test if all the other cells correspond to the reaction names for k = 2:length(model.rxns)-1 assert(isequal(cellstr(rxnsRef{k}(2:end-1)), model.rxns(k-1))); end % run the function exportSetToGAMS(model.rxns, 'Reactions.txt'); % compare to the ref data refData = textread('Reactions.txt', '%s', 'delimiter', '\n'); assert(isequal(refData, rxnsRef)) % test for 1 input: exportSetToGAMS(model.rxns) assert(verifyCobraFunctionError('exportSetToGAMS', 'inputs', {model.rxns}, 'testMessage', 'All inputs for the function exportSetToGAMS must be specified')) % remove the test file delete('Reactions.txt'); % change back to the current directory cd(currentDir);
function sum_wf(handles,einzelmat) imagefile = get(handles.im_file_edit, 'String'); outpath = get(handles.out_dir_edit, 'String'); if outpath(length(outpath))~='\' outpath = [outpath,'\']; end %Obtain info on image type, etc file_info = get_file_info2(imagefile, handles); load(einzelmat,'image_sum','x_size','y_size','x_offset','y_offset'); exf = str2double(get(handles.exf_edit,'String')); %expansion factor ishift = str2double(get(handles.ishift,'String')); jshift = str2double(get(handles.jshift,'String')); xw_render = str2double(get(handles.xw_render_edit,'String')); yw_render = str2double(get(handles.yw_render_edit,'String')); if xw_render ~= 0 xw=xw_render; else xw=x_size; end if yw_render ~= 0 yw=yw_render; else yw=y_size; end x_off=x_offset+ishift; y_off=y_offset+jshift; wf_sum=zeros(yw,xw); wf_sum=image_sum(y_off:y_off+yw-1,x_off:x_off+xw-1); wf_sum=wf_sum/max(max(wf_sum)); wf_sum=wf_sum/max(max(wf_sum)); imex=zeros(yw*exf,xw*exf); for j=1:yw for i=1:xw x0=(i-1)*exf+1; x1=x0+exf-1; y0=(j-1)*exf+1; y1=y0+exf-1; imex(y0:y1,x0:x1)=wf_sum(j,i); end end figure imagesc(imex) title(['Expanded Widefield Sum: Frames: ',num2str(file_info.start),'-',num2str(file_info.stop)]) colormap gray axis image if get(handles.write_image_checkbox,'Value') %write to file if box is checked if (file_info.part_name(length(file_info.part_name)) == '_') %Avoid saving with repeat seperators wf_sum_file=[outpath,'\',file_info.part_name,num2str(file_info.start),'-',num2str(file_info.stop),'exp',num2str(exf),'_wf.tif']; else wf_sum_file=[outpath,'\',file_info.part_name,num2str(file_info.start),'-',num2str(file_info.stop),'_exp',num2str(exf),'_wf.tif']; end imwrite(uint8(imex*255),wf_sum_file,'Compression','none'); end
function makefigure(y, ThreeDee, PlotOrClose) % Copyright (c) 2009, The MathWorks, Inc. % % Creates / updates /closes a MATLAB figure persistent figureHandle; if ishandle(figureHandle) % If figure exists, use it figure(figureHandle); if (nargin > 2)&&(PlotOrClose < -eps) % close the figure if needed close(figureHandle); return; end; else % If figure doesn't exist and plotting is required, create it. if (nargin > 2)&&(PlotOrClose > eps) figureHandle = figure; else return; end; end; % Clear the figure and plot in 2D or 3D clf; if ThreeDee surf(y); else plot(y); end;
# This file was generated, do not modify it. # hide BayesianQDA = @load BayesianQDA pkg=ScikitLearn
function [tout, info] = transfdiff(opt, tp, tm) % TRANSFDIFF Transform diffusion algorithm for sequence of images. % % This function is part of a larger algorithm that solves the following % registration problem: % % We have a sequence of images I=1,2,...,N. We want to register each image % to its adjacent neighbours to form a volume. But instead of registering % I=2 to I=1, and then I=3 to the result, and then I=4 to the result, etc., % it can be shown that all images can be aligned in parallel using an % iterative process that we call "transform diffusion registration". % % TRANSFDIFF solves the "transform diffusion" step in the algorithm: % % Let's assume that somebody has already registered each image I to its % neighbours I-1 and I+1. TRANSFDIFF takes that set of registration % parameters and "diffuses" them to produce a transform for each image. % Applying these transforms to the images produces the globally aligned % sequence. % % % TRANSFDIFF applies a diffusion process to those neighbour transforms. The % output is the N transforms that applied to the N images best align them. % % [TOUT, INFO] = TRANSFDIFF(OPT, ...) % % OPT is a string with the name of the transform to apply, or a struct % with the transform name and algorithm parameters. Options common to all % transformations: % % 'MaxIter': (def 50) Stopping criterion. The algorithm stops after % MaxIter diffusion iterations. % % 'Alpha': (def 0.45) Diffusion coefficient. The smaller the value of % alpha, more iterations are needed for the same result. But % alpha >0.45 may not smooth high frequencies very well, and % values >=0.5 cause oscillations. % % TOUT is an array with N output transforms for the N slices. % % INFO is a struct with information about the algorithm internals: % % 'NumIter': Number of diffusion iterations until stop condition. % % ------------------------------------------------------------------------- % % * OPT='TranslationTransform' % * OPT.Transform='TranslationTransform' % % [TOUT, INFO] = TRANSFDIFF(OPT, TP) % % TP is a matrix with N-1 rows. TP(I, :) is the translation from slice I % to slice I+1. % % This case assumes that the transforms are symmetric, i.e. the % translation from slice I+1 to I is -TP(I, :). % % Specific OPT options: % % 'Epsilon': (def 0.0) Stopping criterion. It stops when all % translation components are small: % for all t, abs(t)<=Epsilon. % % ------------------------------------------------------------------------- % % * OPT='AffineTransform' % * OPT.Transform='AffineTransform' % % * OPT='EulerTransform' % * OPT.Transform='EulerTransform' % % [TOUT, INFO] = TRANSFDIFF(OPT, TP) % % TP is an array of affine transforms in homogeneous coordinates. TP(I,:) % is the affine transform from slice I to slice I+1. Each transform has % the format % % TP(:, :, I) = [A 0] % [d 1] % % where A is a matrix and d is a translation vector, and the affine % transform of a row vector X is defined as Y=X*TP(:,:,I). % % This case assumes that the transforms are symmetric, i.e. the % transformation from slice I+1 to I is inv(TP(I, :)). % % Specific OPT options: % % 'Epsilon': (def 0.0) Stopping criterion. It stops when the norm of % the difference between the transformation and the identity % matrix is small: % for all t, norm(t-eye(3))<=Epsilon. % % ------------------------------------------------------------------------- % % * OPT.Transform='BsplineTransform' % % [TOUT, INFO] = TRANSFDIFF(OPT, TP, TM) % % TP is a matrix with N-1 rows. Each row contains the B-spline % coefficients with the transformation from slice I to slice I+1. The % format of the B-spline coefficient vector is % [p0x, p1x, ..., pNx, p0y, p1y, ..., pNy]. % % TM is similar to TP, but TM(I, :) is the transformation from slice I+1 % to I. % % Specific OPT options: % % 'Epsilon': (def 0.0) Stopping criterion. It stops when all % coefficient displacement components are small: % for all t, abs(t)<=Epsilon. % % 'tbsp': (def []) For Choi and Lee (2000) injectivity criteria. These % are sufficient criteria that guarantee the B-spline doesn't % fold over. Transform struct in elastix format. The % tbsp.TransformParameters are ignored, only the grid % information is used. If not provided or empty, the conditions % are not used as a stopping criterion, and the resulting % B-splines may fold over. % % % ------------------------------------------------------------------------- % % See also: transdiffreg. % Author: Ramon Casero <[email protected]> % Copyright © 2015-2016 University of Oxford % Version: 0.4.4 % % University of Oxford means the Chancellor, Masters and Scholars of % the University of Oxford, having an administrative office at % Wellington Square, Oxford OX1 2JD, UK. % % This file is part of Gerardus. % % 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. The offer of this % program under the terms of the License is subject to the License % being interpreted in accordance with English Law and subject to any % action against the University of Oxford being under the jurisdiction % of the English Courts. % % You should have received a copy of the GNU General Public License % along with this program. If not, see <http://www.gnu.org/licenses/>. % check arguments switch (opt.Transform) case {'TranslationTransform', 'EulerTransform', 'AffineTransform'} narginchk(2, 2); case {'BSplineTransform'} narginchk(2, 3); otherwise error(['Transform ' opt.Transform ' not implemented']) end nargoutchk(0, 2); % defaults if (isempty(opt)) error('OPT cannot be empty'); elseif (ischar(opt)) aux = opt; clear opt opt.Transform = aux; end if (~isfield(opt, 'Epsilon')) opt.Epsilon = 0.0; end if (~isfield(opt, 'MaxIter')) opt.MaxIter = 50; end if (~isfield(opt, 'Alpha')) opt.Alpha = 0.45; end if (strcmp(opt.Transform, 'BSplineTransform')) if (~isfield(opt, 'tbsp')) opt.tbsp = []; end end if (opt.Alpha < 0 || opt.Alpha > 0.5) warning('alpha must be in the interval [0.0, 0.5]. alpha=0.5 can produce oscillations. We recommend alpha<=0.45') end % convert to array format if transforms are provided in elastix format [tp, tp0] = elastix2mat(tp); if (nargin > 2) [tm, tm0] = elastix2mat(tm); end % preprocessing of inputs switch (opt.Transform) case {'TranslationTransform', 'BSplineTransform'} % compute "tm" from "tp" if (nargin < 3 || isempty(tm)) tm = -tp; end % add dummy transforms at the beginning of "tm" and at the end of % "tp". This makes it easier to operate, because then: % * tp(I) and tm(I) are the neighbours of I for intermediate slices % * extreme slices can be dealt with in the same way as % intermediate slices tp = tp([1:end end], :); tm = tm([1 1:end], :); tp(end, :) = tm(end, :); tm(1, :) = tp(1, :); case {'EulerTransform', 'AffineTransform'} % compute "tm" from "tp" if (nargin < 3 || isempty(tm)) for I = 1:size(tp, 3) tm(:, :, I) = inv(tp(:, :, I)); end end % add dummy transforms at the beginning of "tm" and at the end of % "tp". This makes it easier to operate (see note above) tp = tp(:, :, [1:end end]); tm = tm(:, :, [1 1:end]); tp(:, :, end) = tm(:, :, end); tm(:, :, 1) = tp(:, :, 1); end % check inputs if any(size(tp) ~= size(tm)) error('TP and TM must have the same size') end % if no transforms provided, then we don't need to run the algorithm if (isempty(tp)) tout = []; return end % apply registration diffusion switch (opt.Transform) case {'TranslationTransform', 'BSplineTransform'} [tout, info] = translation_diffusion(opt, tp, tm); case {'EulerTransform', 'AffineTransform'} [tout, info] = affine_diffusion(opt, tp, tm); otherwise error('Transform not implemented') end end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% LOCAL FUNCTIONS %% convert transform from elastix format to array, if necessary function [tout, t0] = elastix2mat(t) if (isstruct(t)) % save copy of input so that we can convert the output back to elastix % format t0 = t; switch (t(1).Transform) case {'TranslationTransform', 'BSplineTransform'} tout = cat(1, t(:).TransformParameters); % TODO: AffineTransform otherwise error('Conversion from this elastix transform to Matlab array not implemented') end else % already in array format % no need to save a copy of the input t0 = []; % output is just the input tout = t; end end %% translation_diffusion: Apply diffusion to translation transforms function [tout, info] = translation_diffusion(opt, tp, tm) % init accumulated transform to apply to each slice tout = zeros(size(tp)); I = 0; while (1) % iteration number I = I + 1; % transform to apply to each slice in this iteration (transform update) t = opt.Alpha * (tp + tm); % stopping criterion: B-spline injectivity if (strcmp(opt.Transform, 'BSplineTransform')) % find control points that don't guarantee injectivity and % constrain them so that they do [info.NConstrained(I), aux] = ... check_bspline_injectivity_choi2000(tout + t, opt.tbsp); % apply the control point modifications to the B-spline update t = aux - tout; end % compose with the previous transforms to obtain a total transform tout = tout + t; % update neighbour transforms ... % ... of internal images tp(1:end-1, :) = t(2:end, :) + tp(1:end-1, :) - t(1:end-1, :); tm(2:end, :) = t(1:end-1, :) + tm(2:end, :) - t(2:end, :); %... of extreme images tp(end, :) = tm(end, :); tm(1, :) = tp(1, :); % stopping criterion: absolute value of each translation component tabs = abs(t(:)); info.MaxAbs(I) = max(tabs); info.MeanAbs(I) = mean(tabs); info.MedAbs(I) = median(tabs); if (info.MaxAbs(I) <= opt.Epsilon) break end % stopping criterion: maximum number of iterations if (I == opt.MaxIter) break end end info.NumIter = I; % DEBUG: % isInjective = check_bspline_injectivity_global(tout + t, opt.tbsp); % nnz(~isInjective) end %% affine_diffusion: Apply diffusion to affine transforms function [tout, info] = affine_diffusion(opt, tp, tm) % init accumulated transform to apply to each slice tout = eye(size(tp(:, :, 1))); tout = repmat(tout, 1, 1, size(tp, 3)); % allocate memory for transform update t = zeros(size(tp)); I = 0; while (1) % iteration number I = I + 1; % compute the transform to apply to each slice in this iteration for J = 1:size(tp, 3) % transform to apply to each slice in this iteration (transform % update) t(:, :, J) = real(expm(opt.Alpha ... * (logm(tp(:, :, J)) + logm(tm(:, :, J))))); % compose with the previous transforms to obtain a total transform tout(:, :, J) = tout(:, :, J) * t(:, :, J); end % update neighbour transforms of internal images for J = 2:size(tm, 3) tm(:, :, J) = t(:, :, J) \ tm(:, :, J) * t(:, :, J-1); end for J = 1:size(tp, 3)-1 tp(:, :, J) = t(:, :, J) \ tp(:, :, J) * t(:, :, J+1); end % update neighbour transforms of extreme images tp(:, :, end) = tm(:, :, end); tm(:, :, 1) = tp(:, :, 1); % stopping criteria... % ... norm of the transform update different from identity tnorm = zeros(1, size(t, 3)); for J = 1:size(t, 3) tnorm(J) = norm(t(:, :, J) - eye(size(t(:, :, 1))), 2); end info.MaxTNorm(I) = max(tnorm); info.MeanTNorm(I) = mean(tnorm); info.MedTNorm(I) = median(tnorm); if (all(tnorm <= opt.Epsilon)) break end % ... maximum number of iterations if (I == opt.MaxIter) break end end info.NumIter = I; end %% check_bspline_injectivity_global: % % Check B-spline global injectivity triangulating the grid and looking for % flipped triangles. % % tout: (N, K)-matrix, N number of slices, K number of B-spline control % points % tbsp: elastix struct with the B-spline info (we need the grid spacing) function isInjective = check_bspline_injectivity_global(tout, tbsp) DEBUG = false; % number of slices N = size(tout, 1); % grid of control points for 0 deformation tbsp.TransformParameters(:) = 0; [gx0, gy0] = elastix_bspline_grid(tbsp); tri = delaunay(gx0(:), gy0(:)); % area of the triangles atri = trifacet_signed_area(tri, [gx0(:), gy0(:)]); % flip triangles with negative area, so that all are positive idx = atri < 0; tri(idx, :) = tri(idx, end:-1:1); % DEBUG: plot control points if (DEBUG) trimesh(tri, gx0(:), gy0(:)) end isInjective = true(1, N); for J = 1:N % transfer coefficients to the B-spline tbsp.TransformParameters = tout(J, :); % apply transformation to the control points (note: aux = transformix_pts(tbsp, [gx0(:) gy0(:)]); gx1 = reshape(aux(:, 1), size(gx0, 1), size(gx0, 2)); gy1 = reshape(aux(:, 2), size(gy0, 1), size(gy0, 2)); % DEBUG: plot control points if (DEBUG) trimesh(tri, gx1(:), gy1(:)) end % area of the triangles atri = trifacet_signed_area(tri, [gx1(:), gy1(:)]); % if any triangle is flipped, the B-spline is not injective isInjective(J) = all(atri > 0); end end %% check_bspline_injectivity_choi2000: % % Check B-spline injectivity using sufficient conditions in Choi and Lee % (2000). Constrain control points to guarantee injectivity. % % This function checks Choi and Lee (2000) conditions for injectivity of % the B-spline. The conditions are sufficient, i.e. if any is fulfilled, % then we know the B-spline is injective. If not, the B-spline may or may % not be injective, but we'll assume it's not. % % tout: (N, K)-matrix, N number of slices, K number of B-spline control % points % tbsp: elastix struct with the B-spline info (we need the grid spacing) % % nConstrained: number of control points that had to be constrained to % guarantee injectivity function [nConstrained, tout] = check_bspline_injectivity_choi2000(tout, tbsp) % constants from Choi and Lee (2000), to check violations K2 = 2.046392675; A2 = sqrt((3/2)^2 + (K2 - 3/2)^2); % number of slices N = size(tout, 1); % Note: the grid has row->x, col->y coordinates, instead of the Matlab % convention, which is the opposite % number of B-spline control points L = length(tbsp.TransformParameters)/2; Nx = tbsp.GridSize(1); Ny = tbsp.GridSize(2); % loop slices isInjective = false(Nx, Ny, N); for J = 1:N %% find control points that are guaranteed to not cause injectivity %% problems % transfer coefficients to the B-spline tbsp.TransformParameters = tout(J, :); % easy nomenclature for x, y coordinates of control points cx = tbsp.TransformParameters(1:L); cy = tbsp.TransformParameters(L+1:end); % reshape coefficients into grid cx = reshape(cx, Nx, Ny); cy = reshape(cy, Nx, Ny); % normalize control point displacement to grid spacing = 1 cx = cx / tbsp.GridSpacing(1); cy = cy / tbsp.GridSpacing(2); % Theorem 1 from Choi and Lee (2000): first sufficient condition % for injectivity cond1 = (abs(cx) < 1 / K2) & (abs(cy) < (1 / K2)); % Theorem 2 from Choi and Lee (2000): second sufficient condition % for injectivity cond2 = cx.^2 + cy.^2 < (1 / A2)^2; % if either condition is fulfilled, then the B-spline is injective isInjective(:, :, J) = cond1 | cond2; %% correct control points that potential can cause non-injectivity % find problematic points (linear index easier than row/column % index) idx = find(~isInjective(:, :, J)); % correction factor for the problematic coefficients S = 1 ./ sqrt(cx(idx).^2 + cy(idx).^2) / (A2 - 0.01); % correct problematic control points cx(idx) = cx(idx) .* S; cy(idx) = cy(idx) .* S; % transfer corrected coefficients to the output aux = tout(J, :); aux(idx) = tbsp.GridSpacing(1)*cx(idx); aux(L + idx) = tbsp.GridSpacing(2)*cy(idx); tout(J, :) = aux; end % count number of control points that had to be constrained to guarantee % they are injective nConstrained = nnz(~isInjective); end %% check_bspline_injectivity_chun2009: % % Check B-spline injectivity using sufficient conditions in Chun and % Fessler (2009). % % This function checks Chun and Fessler (2009) conditions for injectivity % of the B-spline. If all the conditions are fulfilled, then we know the % B-spline is injective. If not, the B-spline may or may not be injective, % but we'll assume it's not. % % Because the conditions check grid edge lengths, it's not trivial to % associate the conditions to vertices. % % tout: (N, K)-matrix, N number of slices, K number of B-spline control % points % tbsp: elastix struct with the B-spline info (we need the grid spacing) function isInjective = check_bspline_injectivity_chun2009(tout, tbsp) DEBUG = false; % constants from Chun and Fessler (2009), to check for violations kx = 0.5 - 0.01; ky = 0.5 - 0.01; % number of slices N = size(tout, 1); % number of B-spline coefficients L = length(tbsp.TransformParameters); Nx = tbsp.GridSize(1); Ny = tbsp.GridSize(2); % DEBUG: plot control points if (DEBUG) % grid of control points for 0 deformation tbsp.TransformParameters(:) = 0; [gx0, gy0] = elastix_bspline_grid(tbsp); tri = delaunay(gx0(:), gy0(:)); trimesh(tri, gx0(:), gy0(:)) end % loop slices isInjective = true; for J = 1:N % transfer coefficients to the B-spline tbsp.TransformParameters = tout(J, :); % easy nomenclature for x, y coordinates of control points cx = tbsp.TransformParameters(1:L/2); cy = tbsp.TransformParameters(L/2+1:end); % reshape coefficients into grid cx = reshape(cx, Nx, Ny); cy = reshape(cy, Nx, Ny); % transpose grid so that we have x->cols, y->rows cx = cx'; cy = cy'; % grid spacing mx = tbsp.GridSpacing(1); my = tbsp.GridSpacing(2); % conditions (i->x, j->y): % -mx * kx <= c_{i+1,j}^x - c_{i,j}^x % we also add a column to the right to account for the lost column cond = (diff(cx, 1, 2) >= -mx * kx); isInjective = isInjective && all(cond(:)); % -my * ky <= c_{i,j+1}^y - c_{i,j}^y % we also add a row to the bottom to account for the lost row cond = (diff(cy, 1, 1) >= -my * ky); isInjective = isInjective && all(cond(:)); % |c_{i,j+1}^x - c_{i,j}^x| <= mx * kx % we also add a row to the bottom to account for the lost row cond = (abs(diff(cx, 1, 1)) <= mx * kx); isInjective = isInjective && all(cond(:)); % |c_{i+1,j}^y - c_{i,j}^y| <= my * ky % we also add a column to the right to account for the lost column cond = (abs(diff(cy, 1, 2)) <= my * ky); isInjective = isInjective && all(cond(:)); end end
{-# LANGUAGE GADTs #-} module HVX.Internal.SymbolicSubgrad where import Numeric.LinearAlgebra hiding (i) import Numeric.LinearAlgebra.Util import HVX.Internal.Matrix import HVX.Internal.Primitives type Vars = [(Var, Mat)] evaluate :: Expr vex mon -> Vars -> Mat evaluate (EConst c) _ = c evaluate (EVar var) vars | Just val <- lookup var vars = val | otherwise = error $ "Variable " ++ show var ++ " not set." evaluate (EFun f e) vars = getFun f (evaluate e vars) evaluate (EAdd l r) vars = evaluate l vars + evaluate r vars jacobianWrtVar :: Expr vex mon -- ^ Expression whose jacobian to take. -> Vars -- ^ Variables appearing in the expression. -> Var -- ^ Variable to take jacobian with respect to. -> Mat -- ^ The jacobian. jacobianWrtVar (EConst c) vars wrtVar | Just wrtVal <- lookup wrtVar vars = zeros (rows c) (rows wrtVal) | otherwise = error $ "Variable " ++ show wrtVar ++ " not set." jacobianWrtVar (EVar var) vars wrtVar | var == wrtVar, Just val <- lookup var vars = ident $ rows val | Just val <- lookup var vars, Just wrtVal <- lookup wrtVar vars = zeros (rows val) (rows wrtVal) | otherwise = error $ "Variable " ++ show var ++ " or " ++ show wrtVar ++ " not set." -- Chain rule: ddx f(e) = dde f * ddx e jacobianWrtVar (EFun f e) vars var = dde_f <> ddx_e where dde_f = getJacobian f val ddx_e = jacobianWrtVar e vars var val = evaluate e vars -- Special case for addition. jacobianWrtVar (EAdd l r) vars var = ddx_l + ddx_r where ddx_l = jacobianWrtVar l vars var ddx_r = jacobianWrtVar r vars var
State Before: α : Type u β : Type v γ : Type w ⊢ head nil = Computation.pure none State After: no goals Tactic: simp [head]
! PR fortran/25219 implicit none save integer :: i, k k = 3 !$omp parallel !$omp do lastprivate (k) do i = 1, 100 k = i end do !$omp end do !$omp end parallel if (k .ne. 100) call abort end
# Copyright (c) 2018-2021, Carnegie Mellon University # See LICENSE for details Class(MD_PRDFT, TaggedNonTerminal, rec( abbrevs := [ (dims) -> Checked(IsList(dims), ForAll(dims, IsPosIntSym), [dims, 1]), (dims,rot) -> Checked(IsList(dims), ForAll(dims, IsPosIntSym), IsIntSym(rot), [dims, rot]) ], terminate := self >> let( n := self.params[1], rot := self.params[2], n0 := DropLast(n, 1), lst := Last(n), res := RC(Tensor(MDDFT(n0), I(Rows(PRDFT(lst))/2))) * Tensor(I(Product(n0)), PRDFT(lst, rot)), When(self.transposed, res.transpose(), res)), toAMat := self >> self.terminate().toAMat(), isReal := True, normalizedArithCost := self >> let(n := Product(self.params[1]), IntDouble(2.5 * n * d_log(n) / d_log(2))), hashAs := self >> let(t:=ObjId(self)(self.params[1], 1).withTags(self.getTags()), When(self.transposed, t.transpose(), t)), dims := self >> let( n := self.params[1], n0 := DropLast(n, 1), lst := Last(n), d := [ Product(n0) * 2*(idiv(lst,2)+1), Product(n)], When(self.transposed, Reversed(d), d)), omega := (N,k,r,c) -> E(N)^(k*r*c), )); NewRulesFor(MD_PRDFT, rec( MD_PRDFT_Base := rec( applicable := t -> true, freedoms := t -> [], child := (t, fr) -> let( n := t.params[1], rot := t.params[2], n0 := DropLast(n, 1), lst := Last(n), RC( GT(MDDFT(n0), GTVec, GTVec, [Rows(PRDFT(lst))/2]).withTags(t.getTags()) ) * GT(PRDFT(lst, rot), GTPar, GTPar, [Product(n0)]).withTags(t.getTags()) ), apply := (self, t, C, Nonterms) >> C[1] ) )); # tst := vec -> let(n := Length(vec), dim := Sqrt(n), cols := 2*(Int(dim/2)+1), # out := TransposedMat(MatSPL(MD_PRDFT([dim,dim], 1)) * TransposedMat([vec]))[1], # outmat := List([0..dim-1], x->out{[1 + x*cols .. cols + x * cols]}), # PrintMat(outmat), # outmat); # ctst := vec -> let(n := Length(vec), dim := Sqrt(n), # out := TransposedMat(MatSPL(MDDFT([dim,dim], 1)) * TransposedMat([vec]))[1], # outmat := List([0..dim-1], x->out{[1 + x*dim .. dim + x * dim]}), # PrintMat((outmat)), # outmat); # CX = X * RE # X^-1 = RE * CX^-1
using Documenter #include("../src/QSWalk.jl") using QSWalk # same for contributing and license cp(normpath(@__FILE__, "../../LICENSE"), normpath(@__FILE__, "../src/license.md"); force=true) makedocs( modules = [QSWalk], format = Documenter.HTML(assets = ["assets/logo.ico"]), sitename = "QSWalk", clean = true, doctest = true, checkdocs = :exports, pages = Any[ "Home" => "index.md", "GKSL master equation" => "gksl.md", "Demoralization" => "demoralization.md", "Contributing" => "contributing.md", "Citing" => "citing.md", "Licence" => "license.md", ] ) deploydocs( deps = nothing, make = nothing, repo = "github.com/iitis/QSWalk.jl", target = "build", ) #rm(normpath(@__FILE__, "src/license.md"))
In the United Kingdom , Lost Horizons peaked at number 20 on the Official Albums Chart , whereas in the United States , it peaked at number 24 on Billboard 's Top Electronic Albums component chart . The album 's two singles , " Space Walk " and " Nice Weather for Ducks " , were also successful , peaking on the UK Singles Chart , at number 36 and 16 respectively . The album , was nominated for the Mercury Music Prize in 2003 , was eventually certified gold by the British Phonographic Industry for shipments exceeding 100 @,@ 000 copies .
# Installation The following instructions were prepared using ```julia versioninfo() ``` Julia Version 1.5.2 Commit 539f3ce943 (2020-09-23 23:17 UTC) Platform Info: OS: Linux (x86_64-pc-linux-gnu) CPU: Intel(R) Core(TM) i9-9900X CPU @ 3.50GHz WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-9.0.1 (ORCJIT, skylake-avx512) Environment: JULIA_NUM_THREADS = 4 Before exploring the notebook you need to clone the main repository: ```bash git clone https://github.com/kalmarek/1812.03456.git ``` This notebook should be located in `1812.03456/notebooks` directory. In the main directory (`1812.03456`) you should run the following code in `julia`s `REPL` console to instantiate the environment for computations: ```julia using Pkg Pkg.activate(".") Pkg.instantiate() ``` (this needs to be done once per installation). Instantiation should install (among others): the [`SCS` solver][1], [`JuMP` package][2] for mathematical programming and `IntervalArithmetic.jl` package from [`ValidatedNumerics.jl`][3]. The environment uses [`Groups.jl`][7], [`GroupRings.jl`][6] (which are built on the framework of [`AbstractAlgebra.jl`][4]) and [`PropertyT.jl`][8] packages. [1]: https://github.com/cvxgrp/scs [2]: https://github.com/JuliaOpt/JuMP.jl [3]: https://github.com/JuliaIntervals/ValidatedNumerics.jl [4]: https://github.com/Nemocas/AbstractAlgebra.jl [5]: https://github.com/Nemocas/Nemo.jl [6]: https://github.com/kalmarek/GroupRings.jl [7]: https://github.com/kalmarek/Groups.jl [8]: https://github.com/kalmarek/PropertyT.jl A jupyter server may be launched then within the directory `1812.03456` by issuing from julia command-line (`REPL`) the following commands. ```julia using Pkg Pkg.activate(".") using IJulia notebook(dir=".") ``` During the first run the user may be asked for installation of `Jupyter` program (a server for running this notebook) within `miniconda` environment, which will happen automatically after confirmation. To execute the commands in the notebook, one needs to navigate to `notebooks` subdirectory of `1812.03456` and click either of the notebooks. > Code "cells" have a label, e.g. `In [1]:` on their left margin. Click somewhere in the proximity of the label to select a cell. The selected cell is _run_ by either clicking the `Run` button in the top toolbar, or by pressing `Shift`+`Enter`. # The computation The following notebook uses the precomputed solutions to certify that $$\operatorname{Adj}_5 + 2\operatorname{Op}_5 - 0.28\Delta_5 \simeq \Sigma_i \xi_i^*\xi_i \in \Sigma^2_2 I\operatorname{SAut}(F_5),$$ and that $$\operatorname{Adj}_5 + 3\operatorname{Op}_5 - 1.4 \Delta_5 \simeq \Sigma_i \xi_i^*\xi_i \in \Sigma^2_2 I\operatorname{SAut}(F_5),$$ where $\simeq \Sigma_i \xi_i^*\xi_i$ means "admits approximate sum of squares decomposition" in the language of [arXiv:1812.03456](https://arxiv.org/abs/1812.03456). These are the computations upon the main results of [arXiv:1812.03456](https://arxiv.org/abs/1812.03456) depend. Additionaly, one may execute the whole program (including the optimization) proving that $$\operatorname{Adj}_4 + 100 \mathrm{Op}_4 - 0.1\Delta_4 \simeq \Sigma_i \xi_i^*\xi_i \in \Sigma^2_2 I\operatorname{SAut}(F_4).$$ This result shows that almost all groups $\operatorname{SAut}(F_n)$ have property (T). While the constants in the result are by no means optimal, is should be achievable fairly quickly (at most an hour) on a standard laptop computer. ```julia using Pkg Pkg.activate("..") using Dates now() ```  Activating environment at `~/1812.03456/Project.toml` 2020-10-21T13:39:54.894 ```julia using SparseArrays import LinearAlgebra: norm using AbstractAlgebra using Groups using GroupRings using PropertyT using PropertyT.JLD using PropertyT.IntervalArithmetic IntervalArithmetic.setrounding(Interval, :tight) IntervalArithmetic.setformat(:standard, sigfigs=6); ``` So far we only made the needed packages available in the notebook. You need to dowload `SAutF5_r2.tar.xz` file from zenodo.org (`doi:10.5281/zenodo.4118043`) and unpack it in the `1812.03456` directory. In the next cell we define the directory where the precomputed solutions should reside and check that required files are in place. ```julia const N = 5 const prefix = abspath(joinpath(@__DIR__, ".." , "SAutF$(N)_r2")) isdir(prefix) || @error "You need to place the precomputed solutions downloaded from zenodo in \n $prefix" const DELTA_FILE = joinpath(prefix,"delta.jld"); const SQADJOP_FILE = joinpath(prefix, "SqAdjOp_coeffs.jld"); const BLOCKDEC_FILE = joinpath(prefix, "BlockDecomposition.jld"); if !(isfile(DELTA_FILE) && isfile(SQADJOP_FILE) && isfile(BLOCKDEC_FILE)) @error "The directory structure must be preserved exactly as in the archive downloaded from zenodo: $prefix \n\t $DELTA_FILE \n\t $SQADJOP_FILE \n\t $ORBITDATA_FILE must exist! " end ``` Below we define a simple function which takes a group ring element `eoi` and a matrix `Q` and computes the the sum of squares `sos` group ring element which `Q` represents (in the parent group ring of `eoi`) and returns the difference `eoi - sos`. This function will be used to compare target elements with the ones obtained through semi-definite optimization. ```julia function SOS_residual(eoi::GroupRingElem, Q::AbstractMatrix) RG = parent(eoi) @time sos = PropertyT.compute_SOS(RG, Q); return eoi - sos end ``` SOS_residual (generic function with 1 method) ## Loading the precomputed group ring elements Below we load $\Delta$, the group Laplacian for $\operatorname{SAut}(F_5)$, vectors of coefficients defining elements $\operatorname{Sq}_5$, $\operatorname{Adj}_5$ and $\operatorname{Op}_5$ and turn these into data structures `GroupRingElem` which represent group ring elements. Note that the vectors of coefficients only have meaning with respect to the particular basis which was used for computations. The basis is not saved and loaded due to space concerns. It can be re-computed using ```julia let basis, sizes = Groups.generate_balls(gens(G), one(G), radius=4) @assert sizes[2] == size(RG.pm, 1) == size(RG.pm, 2) RG.basis, RG.basis_dict = basis, GroupRings.reverse_dict(basis) end ``` ```julia G = SAut(FreeGroup(N)) Δ = PropertyT.loadGRElem(DELTA_FILE, G) RG = parent(Δ) block_decomposition = let od = load(BLOCKDEC_FILE, "BlockDecomposition") block_decomposition = PropertyT.decimate(od, false) # sparsification of projection matrices end Sq, Adj, Op = let (sq_c, adj_c, op_c) = load(SQADJOP_FILE, "Sq", "Adj", "Op") sq = GroupRingElem(sq_c, RG) adj = GroupRingElem(adj_c, RG) op = GroupRingElem(op_c, RG) sq, adj, op end; ``` ## Replicating $\operatorname{Adj}_5 + 2\operatorname{Op}_5 - 0.28\Delta_5 \in \Sigma^2_2 ISAut(F_5)$ Let us define: $\lambda = 0.28$ and $k=2$ and check that precomputed solution file is in place: ```julia const λ = 0.28 const k = 2.0 const fullpath = joinpath(prefix, "$(λ)_K=$k") const SOLUTION_FILE = joinpath(fullpath, "solution.jld") if !(isdir(fullpath) && isfile(SOLUTION_FILE)) @error "Couldn't find the precomputed solution: \n\t$SOLUTION_FILE" end ``` Let us finally define the element of interest (we don't show it by default by placing `;` at the end of line): ```julia elt = Adj + k*Op; ``` `Q` loaded below is the matrix whose columns represent the elements $\xi_i \in \mathbb{R}\operatorname{SAut}(F_5)$ such that $$ \operatorname{Adj}_5 + 2\operatorname{Op}_5 - 0.28 \Delta_5 - \sum_i \xi_i^* \xi_i = b, $$ where $\|b\|_1$ is sufficiently small with respect to $\lambda$ (i.e. `Q` represents _approximate sum of squares_ in the language of [arXiv:1812.03456](https://arxiv.org/abs/1812.03456). ```julia Q = load(SOLUTION_FILE, "Q") ``` 4641×4641 Array{Float64,2}: 2.97397 -0.244942 -0.244942 … 0.0158543 0.0131965 -0.244942 7.72331 -0.311095 0.000722162 -0.000870519 -0.244942 -0.311095 7.72331 -0.00516345 -0.000870519 -0.244942 -0.311095 -0.311095 -0.00615118 -0.00498285 -0.244942 -0.311095 -0.311095 0.000245145 -0.00112319 -0.244942 -0.00261826 -0.136534 … 0.000722162 -0.000870519 -0.244942 -0.136534 -0.161489 -0.00516345 -0.000870519 -0.244942 -0.136534 0.0399134 -0.00615118 -0.00498285 -0.244942 -0.136534 0.0399134 0.000245145 -0.00112319 -0.244942 -0.136534 -0.00261826 -0.00153488 -0.000870519 -0.244942 -0.161489 -0.136534 … -0.00153488 -0.000870519 -0.244942 0.0399134 -0.136534 -0.0101051 -0.00498285 -0.244942 0.0399134 -0.136534 -0.00738246 -0.00112319 ⋮ ⋱ ⋮ -0.00908463 0.000179479 0.000179479 -0.00166578 0.00250892 -0.012501 0.00848923 0.00848923 … 0.0145313 -0.00325656 -0.012501 -0.00724905 -0.000773334 0.0145313 -0.00325656 -0.012501 -0.000773334 -0.00724905 -0.0802158 -0.00325656 -0.00747264 0.00418861 0.00418861 -0.00592741 0.0013943 -0.00747264 -0.00159755 0.00234181 -0.00592741 0.0013943 -0.00747264 0.00234181 -0.00159755 … 0.0254635 0.0013943 -0.0117098 -2.82897e-5 -2.82897e-5 -0.00196401 -0.0401892 0.0158545 -0.00153483 -0.00153483 -0.00165852 -0.00797284 0.0158545 -0.00516343 0.000722191 -0.00165852 -0.00797284 0.0158545 0.000722191 -0.00516343 0.40492 -0.00797284 0.0131965 -0.000870492 -0.000870492 … -0.00797307 0.135697 Below we compute the residual $b$. As we do it in floating-point arithmetic, the result can't be taken too seriously. ```julia let EOI = elt - λ*Δ residual = SOS_residual(EOI, Q) @info "In floating point arithmetic the ℓ₁-norm of the residual" norm(residual, 1); end ``` 28.313046 seconds (245.26 k allocations: 270.780 MiB) ┌ Info: In floating point arithmetic the ℓ₁-norm of the residual │ norm(residual, 1) = 9.173410298989073e-5 └ @ Main In[10]:3 Therefore we resort to interval arithmetic to provide certified upper and lower bounds on the norm of the residual: * We first change entries of `Q` to narrow intervals, * We project columns of `Q` so that $0$ is in the sum of coefficients of each column (i.e. $\xi_i \in I \operatorname{SAut}(F_5)$), * We compute the sum of squares and the $\ell_1$-norm of the residual in the interval arithmetic. The returned `check_columns_augmentation` is a boolean flag to detect if the projection was successful, i.e. if we can guarantee that each column of `Q_aug` can be represented by an element from the augmentation ideal. (If it were not successful, one may project `Q = PropertyT.augIdproj(Q)` in the floating point arithmetic prior to the cell below). ```julia Q_aug, check_columns_augmentation = PropertyT.augIdproj(Interval, Q); @assert check_columns_augmentation Q_aug ``` 4641×4641 Array{Interval{Float64},2}: [2.97397, 2.97398] … [0.0131964, 0.0131965] [-0.244942, -0.244941] [-0.000870514, -0.000870513] [-0.244942, -0.244941] [-0.000870514, -0.000870513] [-0.244942, -0.244941] [-0.00498285, -0.00498284] [-0.244942, -0.244941] [-0.00112319, -0.00112318] [-0.244942, -0.244941] … [-0.000870514, -0.000870513] [-0.244942, -0.244941] [-0.000870514, -0.000870513] [-0.244942, -0.244941] [-0.00498285, -0.00498284] [-0.244942, -0.244941] [-0.00112319, -0.00112318] [-0.244942, -0.244941] [-0.000870514, -0.000870513] [-0.244942, -0.244941] … [-0.000870514, -0.000870513] [-0.244942, -0.244941] [-0.00498285, -0.00498284] [-0.244942, -0.244941] [-0.00112319, -0.00112318] ⋮ ⋱ ⋮ [-0.00908475, -0.00908474] [0.00250892, 0.00250893] [-0.0125012, -0.0125011] … [-0.00325656, -0.00325655] [-0.0125012, -0.0125011] [-0.00325656, -0.00325655] [-0.0125012, -0.0125011] [-0.00325656, -0.00325655] [-0.00747276, -0.00747275] [0.0013943, 0.00139431] [-0.00747276, -0.00747275] [0.0013943, 0.00139431] [-0.00747276, -0.00747275] … [0.0013943, 0.00139431] [-0.0117099, -0.0117098] [-0.0401893, -0.0401892] [0.0158543, 0.0158544] [-0.00797284, -0.00797283] [0.0158543, 0.0158544] [-0.00797284, -0.00797283] [0.0158543, 0.0158544] [-0.00797284, -0.00797283] [0.0131964, 0.0131965] … [0.135696, 0.135697] We now create the element of interest, $\operatorname{Adj}_5 + 2\operatorname{Op}_5 - 0.28 \Delta_5$ with coefficients in real intervals. Note that only $\lambda$ is turned into a non-exact interval, and except the support of $\Delta$ (the first `49` elements) all coefficients are honest integers. ```julia elt_int = elt - @interval(λ)*Δ; elt_int.coeffs ``` 11154301-element SparseVector{Interval{Float64},Int64} with 4161 stored entries: [1 ] = [7657.59, 7657.61] [2 ] = [-191.721, -191.719] [3 ] = [-191.721, -191.719] [4 ] = [-191.721, -191.719] [5 ] = [-191.721, -191.719] [6 ] = [-191.721, -191.719] [7 ] = [-191.721, -191.719] [8 ] = [-191.721, -191.719] [9 ] = [-191.721, -191.719] [10 ] = [-191.721, -191.719] ⋮ [4628 ] = [1, 1] [4629 ] = [1, 1] [4631 ] = [1, 1] [4632 ] = [1, 1] [4633 ] = [1, 1] [4634 ] = [1, 1] [4635 ] = [1, 1] [4636 ] = [1, 1] [4638 ] = [1, 1] [4639 ] = [1, 1] [4640 ] = [1, 1] Finally we compute the $\ell_1$ norm of the residual with interval arithmetic. The result is **guaranteed** to be contained in the resulting interval, i.e. if each entry of `Q` were changed into an honest rational number and all the computations were carried out in rational arithmetic, the rational $\ell_1$-norm will be contained in the interval $\ell_1$-norm. ```julia residual_int = SOS_residual(elt_int, Q_aug) @show norm(residual_int, 1); ``` 953.889613 seconds (520.88 k allocations: 529.781 MiB, 0.00% gc time) norm(residual_int, 1) = [0.000228394, 0.000228496] Using Lemma 4.10 of [arXiv:1812.03456](https://arxiv.org/abs/1812.03456) and the fact that none of the generating transvections of $\operatorname{SAut}(F_N)$ is involutive we obtain ```julia λ_cert = @interval(λ) - 2*norm(residual_int,1) @info "λ is certified to be > " λ_cert.lo @info "i.e Adj_$N + $k·Op_$N - ($(λ_cert.lo))·Δ_$N ∈ Σ²₂ ISAut(F_$N)" ``` ┌ Info: λ is certified to be > │ λ_cert.lo = 0.2795430082668905 └ @ Main In[14]:2 ┌ Info: i.e Adj_5 + 2.0·Op_5 - (0.2795430082668905)·Δ_5 ∈ Σ²₂ ISAut(F_5) └ @ Main In[14]:3 ## Replicating $\operatorname{Adj}_5 + 3\operatorname{Op}_5 - 1.4\Delta_5 \in \Sigma^2_2 ISAut(F_5)$ ```julia const λ = 1.4 const k = 3.0 const fullpath = joinpath(prefix, "$(λ)_K=$k") const SOLUTION_FILE = joinpath(fullpath, "solution.jld") if !(isdir(fullpath) && isfile(SOLUTION_FILE)) @error "Couldn't find the precomputed solution: \n\t$SOLUTION_FILE" end ``` ```julia elt = Adj + k*Op; Q = load(SOLUTION_FILE, "Q"); Q_aug, check_columns_augmentation = PropertyT.augIdproj(Interval, Q); @assert check_columns_augmentation ``` ```julia elt_int = elt - @interval(λ)*Δ; residual_int = SOS_residual(elt_int, Q_aug) @show norm(residual_int, 1); ``` 953.420002 seconds (113.01 k allocations: 512.971 MiB, 0.05% gc time) norm(residual_int, 1) = [0.0149432, 0.0149435] ```julia λ_cert = @interval(λ) - 2*norm(residual_int,1) @info "λ is certified to be > " λ_cert.lo @info "i.e Adj_$N + $k·Op_$N - ($(λ_cert.lo))·Δ_$N ∈ Σ²₂ ISAut(F_$N)" ``` ┌ Info: λ is certified to be > │ λ_cert.lo = 1.3701131734136716 └ @ Main In[18]:2 ┌ Info: i.e Adj_5 + 3.0·Op_5 - (1.3701131734136716)·Δ_5 ∈ Σ²₂ ISAut(F_5) └ @ Main In[18]:3 ## Confirming that $\operatorname{Adj}_4 + 100.0\operatorname{Op}_4 - 0.1\Delta_4$ admits approximate sum of squares decomposition ```julia const λ = 0.1 const k = 100.0 ``` 1 0 0 . 0 Now we will generate the ball $B_R$ of radius $R=4$ in $\operatorname{SAut}(F_4)$, and use it as a (partial) basis of a group ring. Such a group ring also needs a (partial) multiplication table to square elements supported on radius $2$ (it is called `pm`, which is actually a "division table" due to `twisted=true` argument). The table is created as follows: when $x$,$y$ reside at positions `i` and `j` in $B_R$, then `pm[i,j] = k`, where `k` is the position of $x^{-1}y$ in $B_R$. Then we create the Laplace operator $\Delta$. ```julia SAutF₄ = SAut(FreeGroup(4)) Δ₄ = let G = SAutF₄, halfradius = 2 S = gens(G) S = [S; inv.(S)] # generating set must be symmetric B_R, sizes = Groups.wlmetric_ball(S, radius=2*halfradius); B_rdict = GroupRings.reverse_dict(B_R) pm = GroupRings.create_pm(B_R, B_rdict, sizes[halfradius]; twisted=true); RG = GroupRing(G, B_R, B_rdict, pm) @show sizes; Δ = length(S)*one(RG) - sum(RG(s) for s in S) end ``` sizes = [49, 1777, 57725, 1777541] 48(id) - 1ϱ₁₂ - 1ϱ₁₃ - 1ϱ₁₄ - 1ϱ₂₁ - 1ϱ₂₃ - 1ϱ₂₄ - 1ϱ₃₁ - 1ϱ₃₂ - 1ϱ₃₄ - 1ϱ₄₁ - 1ϱ₄₂ - 1ϱ₄₃ - 1λ₁₂ - 1λ₁₃ - 1λ₁₄ - 1λ₂₁ - 1λ₂₃ - 1λ₂₄ - 1λ₃₁ - 1λ₃₂ - 1λ₃₄ - 1λ₄₁ - 1λ₄₂ - 1λ₄₃ - 1ϱ₁₂^-1 - 1ϱ₁₃^-1 - 1ϱ₁₄^-1 - 1ϱ₂₁^-1 - 1ϱ₂₃^-1 - 1ϱ₂₄^-1 - 1ϱ₃₁^-1 - 1ϱ₃₂^-1 - 1ϱ₃₄^-1 - 1ϱ₄₁^-1 - 1ϱ₄₂^-1 - 1ϱ₄₃^-1 - 1λ₁₂^-1 - 1λ₁₃^-1 - 1λ₁₄^-1 - 1λ₂₁^-1 - 1λ₂₃^-1 - 1λ₂₄^-1 - 1λ₃₁^-1 - 1λ₃₂^-1 - 1λ₃₄^-1 - 1λ₄₁^-1 - 1λ₄₂^-1 - 1λ₄₃^-1 In the cell below we compute Wedderburn-Artin decomposition of `pm` with respect to the action of the Weyl group ($S_2 \wr S_4$) and sparsify it numerically. ```julia block_decomposition = let od = PropertyT.BlockDecomposition(parent(Δ₄), WreathProduct(SymmetricGroup(2), SymmetricGroup(4))) PropertyT.decimate(od, false); end; ``` ┌ Info: Decomposing basis of RG into orbits of │ autS = Wreath Product of Full symmetric group over 2 elements by Full symmetric group over 4 elements └ @ PropertyT /home/kalmar/.julia/packages/PropertyT/vcGsE/src/blockdecomposition.jl:15 48.762163 seconds (1.11 G allocations: 76.049 GiB, 37.93% gc time) ┌ Info: The action has 6231 orbits └ @ PropertyT /home/kalmar/.julia/packages/PropertyT/vcGsE/src/blockdecomposition.jl:18 ┌ Info: Finding projections in the Group Ring of │ autS = Wreath Product of Full symmetric group over 2 elements by Full symmetric group over 4 elements └ @ PropertyT /home/kalmar/.julia/packages/PropertyT/vcGsE/src/blockdecomposition.jl:20 4.558152 seconds (6.03 M allocations: 308.531 MiB, 15.56% gc time) ┌ Info: Finding AutS-action matrix representation └ @ PropertyT /home/kalmar/.julia/packages/PropertyT/vcGsE/src/blockdecomposition.jl:23 11.694259 seconds (291.32 M allocations: 19.976 GiB, 34.16% gc time) 0.392333 seconds (1.13 M allocations: 120.585 MiB) ┌ Info: Computing the projection matrices Uπs └ @ PropertyT /home/kalmar/.julia/packages/PropertyT/vcGsE/src/blockdecomposition.jl:27 31.218765 seconds (1.29 M allocations: 8.241 GiB, 2.36% gc time) ┌ Info: │ multiplicities = 6 27 38 23 18 22 56 34 22 23 27 32 9 17 8 1 1 1 2 1 │ dimensions = 1 3 3 2 1 4 8 4 6 6 6 6 4 8 4 1 3 3 2 1 └ @ PropertyT /home/kalmar/.julia/packages/PropertyT/vcGsE/src/blockdecomposition.jl:37 ```julia @time Adj₄ = PropertyT.Adj(parent(Δ₄), 4) @time Op₄ = PropertyT.Op(parent(Δ₄), 4) elt₄ = Adj₄ + k*Op₄ ``` 7.023643 seconds (1.36 M allocations: 71.502 MiB) 1.688224 seconds (190.03 k allocations: 10.537 MiB) 39936(id) - 1664ϱ₁₂ - 1664ϱ₁₃ - 1664ϱ₁₄ - 1664ϱ₂₁ - 1664ϱ₂₃ - 1664ϱ₂₄ - 1664ϱ₃₁ - 1664ϱ₃₂ - 1664ϱ₃₄ - 1664ϱ₄₁ - 1664ϱ₄₂ - 1664ϱ₄₃ - 1664λ₁₂ - 1664λ₁₃ - 1664λ₁₄ - 1664λ₂₁ - 1664λ₂₃ - 1664λ₂₄ - 1664λ₃₁ - 1664λ₃₂ - 1664λ₃₄ - 1664λ₄₁ - 1664λ₄₂ - 1664λ₄₃ - 1664ϱ₁₂^-1 - 1664ϱ₁₃^-1 - 1664ϱ₁₄^-1 - 1664ϱ₂₁^-1 - 1664ϱ₂₃^-1 - 1664ϱ₂₄^-1 - 1664ϱ₃₁^-1 - 1664ϱ₃₂^-1 - 1664ϱ₃₄^-1 - 1664ϱ₄₁^-1 - 1664ϱ₄₂^-1 - 1664ϱ₄₃^-1 - 1664λ₁₂^-1 - 1664λ₁₃^-1 - 1664λ₁₄^-1 - 1664λ₂₁^-1 - 1664λ₂₃^-1 - 1664λ₂₄^-1 - 1664λ₃₁^-1 - 1664λ₃₂^-1 - 1664λ₃₄^-1 - 1664λ₄₁^-1 - 1664λ₄₂^-1 - 1664λ₄₃^-1 + ϱ₁₂*ϱ₁₃ + ϱ₁₂*ϱ₁₄ + ϱ₁₂*ϱ₂₃ + ϱ₁₂*ϱ₂₄ + ϱ₁₂*ϱ₃₁ + 2ϱ₁₂*ϱ₃₂ + 200ϱ₁₂*ϱ₃₄ + ϱ₁₂*ϱ₄₁ + 2ϱ₁₂*ϱ₄₂ + 200ϱ₁₂*ϱ₄₃ + 2ϱ₁₂*λ₁₃ + 2ϱ₁₂*λ₁₄ + ϱ₁₂*λ₂₃ + ϱ₁₂*λ₂₄ + ϱ₁₂*λ₃₁ + 2ϱ₁₂*λ₃₂ + 200ϱ₁₂*λ₃₄ + ϱ₁₂*λ₄₁ + 2ϱ₁₂*λ₄₂ + 200ϱ₁₂*λ₄₃ + ϱ₁₂*ϱ₁₃^-1 + ϱ₁₂*ϱ₁₄^-1 + ϱ₁₂*ϱ₂₃^-1 + ϱ₁₂*ϱ₂₄^-1 + ϱ₁₂*ϱ₃₁^-1 + 2ϱ₁₂*ϱ₃₂^-1 + 200ϱ₁₂*ϱ₃₄^-1 + ϱ₁₂*ϱ₄₁^-1 + 2ϱ₁₂*ϱ₄₂^-1 + 200ϱ₁₂*ϱ₄₃^-1 + 2ϱ₁₂*λ₁₃^-1 + 2ϱ₁₂*λ₁₄^-1 + ϱ₁₂*λ₂₃^-1 + ϱ₁₂*λ₂₄^-1 + ϱ₁₂*λ₃₁^-1 + 2ϱ₁₂*λ₃₂^-1 + 200ϱ₁₂*λ₃₄^-1 + ϱ₁₂*λ₄₁^-1 + 2ϱ₁₂*λ₄₂^-1 + 200ϱ₁₂*λ₄₃^-1 + ϱ₁₃*ϱ₁₂ + ϱ₁₃*ϱ₁₄ + ϱ₁₃*ϱ₂₁ + 2ϱ₁₃*ϱ₂₃ + 200ϱ₁₃*ϱ₂₄ + ϱ₁₃*ϱ₃₂ + ϱ₁₃*ϱ₃₄ + ϱ₁₃*ϱ₄₁ + 200ϱ₁₃*ϱ₄₂ + 2ϱ₁₃*ϱ₄₃ + 2ϱ₁₃*λ₁₂ + 2ϱ₁₃*λ₁₄ + ϱ₁₃*λ₂₁ + 2ϱ₁₃*λ₂₃ + 200ϱ₁₃*λ₂₄ + ϱ₁₃*λ₃₂ + ϱ₁₃*λ₃₄ + ϱ₁₃*λ₄₁ + 200ϱ₁₃*λ₄₂ + 2ϱ₁₃*λ₄₃ + ϱ₁₃*ϱ₁₂^-1 + ϱ₁₃*ϱ₁₄^-1 + ϱ₁₃*ϱ₂₁^-1 + 2ϱ₁₃*ϱ₂₃^-1 + 200ϱ₁₃*ϱ₂₄^-1 + ϱ₁₃*ϱ₃₂^-1 + ϱ₁₃*ϱ₃₄^-1 + ϱ₁₃*ϱ₄₁^-1 + 200ϱ₁₃*ϱ₄₂^-1 + 2ϱ₁₃*ϱ₄₃^-1 + 2ϱ₁₃*λ₁₂^-1 + 2ϱ₁₃*λ₁₄^-1 + ϱ₁₃*λ₂₁^-1 + 2ϱ₁₃*λ₂₃^-1 + 200ϱ₁₃*λ₂₄^-1 + ϱ₁₃*λ₃₂^-1 + ϱ₁₃*λ₃₄^-1 + ϱ₁₃*λ₄₁^-1 + 200ϱ₁₃*λ₄₂^-1 + 2ϱ₁₃*λ₄₃^-1 + ϱ₁₄*ϱ₁₂ + ϱ₁₄*ϱ₁₃ + ϱ₁₄*ϱ₂₁ + 200ϱ₁₄*ϱ₂₃ + 2ϱ₁₄*ϱ₂₄ + ϱ₁₄*ϱ₃₁ + 200ϱ₁₄*ϱ₃₂ + 2ϱ₁₄*ϱ₃₄ + ϱ₁₄*ϱ₄₂ + ϱ₁₄*ϱ₄₃ + 2ϱ₁₄*λ₁₂ + 2ϱ₁₄*λ₁₃ + ϱ₁₄*λ₂₁ + 200ϱ₁₄*λ₂₃ + 2ϱ₁₄*λ₂₄ + ϱ₁₄*λ₃₁ + 200ϱ₁₄*λ₃₂ + 2ϱ₁₄*λ₃₄ + ϱ₁₄*λ₄₂ + ϱ₁₄*λ₄₃ + ϱ₁₄*ϱ₁₂^-1 + ϱ₁₄*ϱ₁₃^-1 + ϱ₁₄*ϱ₂₁^-1 + 200ϱ₁₄*ϱ₂₃^-1 + 2ϱ₁₄*ϱ₂₄^-1 + ϱ₁₄*ϱ₃₁^-1 + 200ϱ₁₄*ϱ₃₂^-1 + 2ϱ₁₄*ϱ₃₄^-1 + ϱ₁₄*ϱ₄₂^-1 + ϱ₁₄*ϱ₄₃^-1 + 2ϱ₁₄*λ₁₂^-1 + 2ϱ₁₄*λ₁₃^-1 + ϱ₁₄*λ₂₁^-1 + 200ϱ₁₄*λ₂₃^-1 + 2ϱ₁₄*λ₂₄^-1 + ϱ₁₄*λ₃₁^-1 + 200ϱ₁₄*λ₃₂^-1 + 2ϱ₁₄*λ₃₄^-1 + ϱ₁₄*λ₄₂^-1 + ϱ₁₄*λ₄₃^-1 + ϱ₂₁*ϱ₁₃ + ϱ₂₁*ϱ₁₄ + ϱ₂₁*ϱ₂₃ + ϱ₂₁*ϱ₂₄ + 2ϱ₂₁*ϱ₃₁ + ϱ₂₁*ϱ₃₂ + 200ϱ₂₁*ϱ₃₄ + 2ϱ₂₁*ϱ₄₁ + ϱ₂₁*ϱ₄₂ + 200ϱ₂₁*ϱ₄₃ + ϱ₂₁*λ₁₃ + ϱ₂₁*λ₁₄ + 2ϱ₂₁*λ₂₃ + 2ϱ₂₁*λ₂₄ + 2ϱ₂₁*λ₃₁ + ϱ₂₁*λ₃₂ + 200ϱ₂₁*λ₃₄ + 2ϱ₂₁*λ₄₁ + ϱ₂₁*λ₄₂ + 200ϱ₂₁*λ₄₃ + ϱ₂₁*ϱ₁₃^-1 + ϱ₂₁*ϱ₁₄^-1 + ϱ₂₁*ϱ₂₃^-1 + ϱ₂₁*ϱ₂₄^-1 + 2ϱ₂₁*ϱ₃₁^-1 + ϱ₂₁*ϱ₃₂^-1 + 200ϱ₂₁*ϱ₃₄^-1 + 2ϱ₂₁*ϱ₄₁^-1 + ϱ₂₁*ϱ₄₂^-1 + 200ϱ₂₁*ϱ₄₃^-1 + ϱ₂₁*λ₁₃^-1 + ϱ₂₁*λ₁₄^-1 + 2ϱ₂₁*λ₂₃^-1 + 2ϱ₂₁*λ₂₄^-1 + 2ϱ₂₁*λ₃₁^-1 + ϱ₂₁*λ₃₂^-1 + 200ϱ₂₁*λ₃₄^-1 + 2ϱ₂₁*λ₄₁^-1 + ϱ₂₁*λ₄₂^-1 + 200ϱ₂₁*λ₄₃^-1 + ϱ₂₃*ϱ₁₂ + ϱ₂₃*ϱ₂₁ + ϱ₂₃*ϱ₂₄ + ϱ₂₃*ϱ₃₁ + ϱ₂₃*ϱ₃₄ + 200ϱ₂₃*ϱ₄₁ + ϱ₂₃*ϱ₄₂ + 2ϱ₂₃*ϱ₄₃ + ϱ₂₃*λ₁₂ + 2ϱ₂₃*λ₁₃ + 200ϱ₂₃*λ₁₄ + 2ϱ₂₃*λ₂₁ + 2ϱ₂₃*λ₂₄ + ϱ₂₃*λ₃₁ + ϱ₂₃*λ₃₄ + 200ϱ₂₃*λ₄₁ + ϱ₂₃*λ₄₂ + 2ϱ₂₃*λ₄₃ + ϱ₂₃*ϱ₁₂^-1 + 2ϱ₂₃*ϱ₁₃^-1 + 200ϱ₂₃*ϱ₁₄^-1 + ϱ₂₃*ϱ₂₁^-1 + ϱ₂₃*ϱ₂₄^-1 + ϱ₂₃*ϱ₃₁^-1 + ϱ₂₃*ϱ₃₄^-1 + 200ϱ₂₃*ϱ₄₁^-1 + ϱ₂₃*ϱ₄₂^-1 + 2ϱ₂₃*ϱ₄₃^-1 + ϱ₂₃*λ₁₂^-1 + 2ϱ₂₃*λ₁₃^-1 + 200ϱ₂₃*λ₁₄^-1 + 2ϱ₂₃*λ₂₁^-1 + 2ϱ₂₃*λ₂₄^-1 + ϱ₂₃*λ₃₁^-1 + ϱ₂₃*λ₃₄^-1 + 200ϱ₂₃*λ₄₁^-1 + ϱ₂₃*λ₄₂^-1 + 2ϱ₂₃*λ₄₃^-1 + ϱ₂₄*ϱ₁₂ + ϱ₂₄*ϱ₂₁ + ϱ₂₄*ϱ₂₃ + 200ϱ₂₄*ϱ₃₁ + ϱ₂₄*ϱ₃₂ + 2ϱ₂₄*ϱ₃₄ + ϱ₂₄*ϱ₄₁ + ϱ₂₄*ϱ₄₃ + ϱ₂₄*λ₁₂ + 200ϱ₂₄*λ₁₃ + 2ϱ₂₄*λ₁₄ + 2ϱ₂₄*λ₂₁ + 2ϱ₂₄*λ₂₃ + 200ϱ₂₄*λ₃₁ + ϱ₂₄*λ₃₂ + 2ϱ₂₄*λ₃₄ + ϱ₂₄*λ₄₁ + ϱ₂₄*λ₄₃ + ϱ₂₄*ϱ₁₂^-1 + 200ϱ₂₄*ϱ₁₃^-1 + 2ϱ₂₄*ϱ₁₄^-1 + ϱ₂₄*ϱ₂₁^-1 + ϱ₂₄*ϱ₂₃^-1 + 200ϱ₂₄*ϱ₃₁^-1 + ϱ₂₄*ϱ₃₂^-1 + 2ϱ₂₄*ϱ₃₄^-1 + ϱ₂₄*ϱ₄₁^-1 + ϱ₂₄*ϱ₄₃^-1 + ϱ₂₄*λ₁₂^-1 + 200ϱ₂₄*λ₁₃^-1 + 2ϱ₂₄*λ₁₄^-1 + 2ϱ₂₄*λ₂₁^-1 + 2ϱ₂₄*λ₂₃^-1 + 200ϱ₂₄*λ₃₁^-1 + ϱ₂₄*λ₃₂^-1 + 2ϱ₂₄*λ₃₄^-1 + ϱ₂₄*λ₄₁^-1 + ϱ₂₄*λ₄₃^-1 + ϱ₃₁*ϱ₁₂ + ϱ₃₁*ϱ₁₄ + ϱ₃₁*ϱ₂₃ + ϱ₃₁*ϱ₃₂ + ϱ₃₁*ϱ₃₄ + 2ϱ₃₁*ϱ₄₁ + 200ϱ₃₁*ϱ₄₂ + ϱ₃₁*ϱ₄₃ + ϱ₃₁*λ₁₂ + ϱ₃₁*λ₁₄ + 2ϱ₃₁*λ₂₁ + ϱ₃₁*λ₂₃ + 200ϱ₃₁*λ₂₄ + 2ϱ₃₁*λ₃₂ + 2ϱ₃₁*λ₃₄ + 2ϱ₃₁*λ₄₁ + 200ϱ₃₁*λ₄₂ + ϱ₃₁*λ₄₃ + ϱ₃₁*ϱ₁₂^-1 + ϱ₃₁*ϱ₁₄^-1 + 2ϱ₃₁*ϱ₂₁^-1 + ϱ₃₁*ϱ₂₃^-1 + 200ϱ₃₁*ϱ₂₄^-1 + ϱ₃₁*ϱ₃₂^-1 + ϱ₃₁*ϱ₃₄^-1 + 2ϱ₃₁*ϱ₄₁^-1 + 200ϱ₃₁*ϱ₄₂^-1 + ϱ₃₁*ϱ₄₃^-1 + ϱ₃₁*λ₁₂^-1 + ϱ₃₁*λ₁₄^-1 + 2ϱ₃₁*λ₂₁^-1 + ϱ₃₁*λ₂₃^-1 + 200ϱ₃₁*λ₂₄^-1 + 2ϱ₃₁*λ₃₂^-1 + 2ϱ₃₁*λ₃₄^-1 + 2ϱ₃₁*λ₄₁^-1 + 200ϱ₃₁*λ₄₂^-1 + ϱ₃₁*λ₄₃^-1 + ϱ₃₂*ϱ₁₃ + ϱ₃₂*ϱ₂₁ + ϱ₃₂*ϱ₂₄ + ϱ₃₂*ϱ₃₁ + ϱ₃₂*ϱ₃₄ + 200ϱ₃₂*ϱ₄₁ + 2ϱ₃₂*ϱ₄₂ + ϱ₃₂*ϱ₄₃ + 2ϱ₃₂*λ₁₂ + ϱ₃₂*λ₁₃ + 200ϱ₃₂*λ₁₄ + ϱ₃₂*λ₂₁ + ϱ₃₂*λ₂₄ + 2ϱ₃₂*λ₃₁ + 2ϱ₃₂*λ₃₄ + 200ϱ₃₂*λ₄₁ + 2ϱ₃₂*λ₄₂ + ϱ₃₂*λ₄₃ + 2ϱ₃₂*ϱ₁₂^-1 + ϱ₃₂*ϱ₁₃^-1 + 200ϱ₃₂*ϱ₁₄^-1 + ϱ₃₂*ϱ₂₁^-1 + ϱ₃₂*ϱ₂₄^-1 + ϱ₃₂*ϱ₃₁^-1 + ϱ₃₂*ϱ₃₄^-1 + 200ϱ₃₂*ϱ₄₁^-1 + 2ϱ₃₂*ϱ₄₂^-1 + ϱ₃₂*ϱ₄₃^-1 + 2ϱ₃₂*λ₁₂^-1 + ϱ₃₂*λ₁₃^-1 + 200ϱ₃₂*λ₁₄^-1 + ϱ₃₂*λ₂₁^-1 + ϱ₃₂*λ₂₄^-1 + 2ϱ₃₂*λ₃₁^-1 + 2ϱ₃₂*λ₃₄^-1 + 200ϱ₃₂*λ₄₁^-1 + 2ϱ₃₂*λ₄₂^-1 + ϱ₃₂*λ₄₃^-1 + ϱ₃₄*ϱ₁₃ + ϱ₃₄*ϱ₂₃ + ϱ₃₄*ϱ₃₁ + ϱ₃₄*ϱ₃₂ + ϱ₃₄*ϱ₄₁ + ϱ₃₄*ϱ₄₂ + 200ϱ₃₄*λ₁₂ + ϱ₃₄*λ₁₃ + 2ϱ₃₄*λ₁₄ + 200ϱ₃₄*λ₂₁ + ϱ₃₄*λ₂₃ + 2ϱ₃₄*λ₂₄ + 2ϱ₃₄*λ₃₁ + 2ϱ₃₄*λ₃₂ + ϱ₃₄*λ₄₁ + ϱ₃₄*λ₄₂ + 200ϱ₃₄*ϱ₁₂^-1 + ϱ₃₄*ϱ₁₃^-1 + 2ϱ₃₄*ϱ₁₄^-1 + 200ϱ₃₄*ϱ₂₁^-1 + ϱ₃₄*ϱ₂₃^-1 + 2ϱ₃₄*ϱ₂₄^-1 + ϱ₃₄*ϱ₃₁^-1 + ϱ₃₄*ϱ₃₂^-1 + ϱ₃₄*ϱ₄₁^-1 + ϱ₃₄*ϱ₄₂^-1 + 200ϱ₃₄*λ₁₂^-1 + ϱ₃₄*λ₁₃^-1 + 2ϱ₃₄*λ₁₄^-1 + 200ϱ₃₄*λ₂₁^-1 + ϱ₃₄*λ₂₃^-1 + 2ϱ₃₄*λ₂₄^-1 + 2ϱ₃₄*λ₃₁^-1 + 2ϱ₃₄*λ₃₂^-1 + ϱ₃₄*λ₄₁^-1 + ϱ₃₄*λ₄₂^-1 + ϱ₄₁*ϱ₁₂ + ϱ₄₁*ϱ₁₃ + ϱ₄₁*ϱ₂₄ + ϱ₄₁*ϱ₃₄ + ϱ₄₁*ϱ₄₂ + ϱ₄₁*ϱ₄₃ + ϱ₄₁*λ₁₂ + ϱ₄₁*λ₁₃ + 2ϱ₄₁*λ₂₁ + 200ϱ₄₁*λ₂₃ + ϱ₄₁*λ₂₄ + 2ϱ₄₁*λ₃₁ + 200ϱ₄₁*λ₃₂ + ϱ₄₁*λ₃₄ + 2ϱ₄₁*λ₄₂ + 2ϱ₄₁*λ₄₃ + ϱ₄₁*ϱ₁₂^-1 + ϱ₄₁*ϱ₁₃^-1 + 2ϱ₄₁*ϱ₂₁^-1 + 200ϱ₄₁*ϱ₂₃^-1 + ϱ₄₁*ϱ₂₄^-1 + 2ϱ₄₁*ϱ₃₁^-1 + 200ϱ₄₁*ϱ₃₂^-1 + ϱ₄₁*ϱ₃₄^-1 + ϱ₄₁*ϱ₄₂^-1 + ϱ₄₁*ϱ₄₃^-1 + ϱ₄₁*λ₁₂^-1 + ϱ₄₁*λ₁₃^-1 + 2ϱ₄₁*λ₂₁^-1 + 200ϱ₄₁*λ₂₃^-1 + ϱ₄₁*λ₂₄^-1 + 2ϱ₄₁*λ₃₁^-1 + 200ϱ₄₁*λ₃₂^-1 + ϱ₄₁*λ₃₄^-1 + 2ϱ₄₁*λ₄₂^-1 + 2ϱ₄₁*λ₄₃^-1 + ϱ₄₂*ϱ₁₄ + ϱ₄₂*ϱ₂₁ + ϱ₄₂*ϱ₂₃ + ϱ₄₂*ϱ₃₄ + ϱ₄₂*ϱ₄₁ + ϱ₄₂*ϱ₄₃ + 2ϱ₄₂*λ₁₂ + 200ϱ₄₂*λ₁₃ + ϱ₄₂*λ₁₄ + ϱ₄₂*λ₂₁ + ϱ₄₂*λ₂₃ + 200ϱ₄₂*λ₃₁ + 2ϱ₄₂*λ₃₂ + ϱ₄₂*λ₃₄ + 2ϱ₄₂*λ₄₁ + 2ϱ₄₂*λ₄₃ + 2ϱ₄₂*ϱ₁₂^-1 + 200ϱ₄₂*ϱ₁₃^-1 + ϱ₄₂*ϱ₁₄^-1 + ϱ₄₂*ϱ₂₁^-1 + ϱ₄₂*ϱ₂₃^-1 + 200ϱ₄₂*ϱ₃₁^-1 + 2ϱ₄₂*ϱ₃₂^-1 + ϱ₄₂*ϱ₃₄^-1 + ϱ₄₂*ϱ₄₁^-1 + ϱ₄₂*ϱ₄₃^-1 + 2ϱ₄₂*λ₁₂^-1 + 200ϱ₄₂*λ₁₃^-1 + ϱ₄₂*λ₁₄^-1 + ϱ₄₂*λ₂₁^-1 + ϱ₄₂*λ₂₃^-1 + 200ϱ₄₂*λ₃₁^-1 + 2ϱ₄₂*λ₃₂^-1 + ϱ₄₂*λ₃₄^-1 + 2ϱ₄₂*λ₄₁^-1 + 2ϱ₄₂*λ₄₃^-1 + ϱ₄₃*ϱ₁₄ + ϱ₄₃*ϱ₂₄ + ϱ₄₃*ϱ₃₁ + ϱ₄₃*ϱ₃₂ + ϱ₄₃*ϱ₄₁ + ϱ₄₃*ϱ₄₂ + 200ϱ₄₃*λ₁₂ + 2ϱ₄₃*λ₁₃ + ϱ₄₃*λ₁₄ + 200ϱ₄₃*λ₂₁ + 2ϱ₄₃*λ₂₃ + ϱ₄₃*λ₂₄ + ϱ₄₃*λ₃₁ + ϱ₄₃*λ₃₂ + 2ϱ₄₃*λ₄₁ + 2ϱ₄₃*λ₄₂ + 200ϱ₄₃*ϱ₁₂^-1 + 2ϱ₄₃*ϱ₁₃^-1 + ϱ₄₃*ϱ₁₄^-1 + 200ϱ₄₃*ϱ₂₁^-1 + 2ϱ₄₃*ϱ₂₃^-1 + ϱ₄₃*ϱ₂₄^-1 + ϱ₄₃*ϱ₃₁^-1 + ϱ₄₃*ϱ₃₂^-1 + ϱ₄₃*ϱ₄₁^-1 + ϱ₄₃*ϱ₄₂^-1 + 200ϱ₄₃*λ₁₂^-1 + 2ϱ₄₃*λ₁₃^-1 + ϱ₄₃*λ₁₄^-1 + 200ϱ₄₃*λ₂₁^-1 + 2ϱ₄₃*λ₂₃^-1 + ϱ₄₃*λ₂₄^-1 + ϱ₄₃*λ₃₁^-1 + ϱ₄₃*λ₃₂^-1 + 2ϱ₄₃*λ₄₁^-1 + 2ϱ₄₃*λ₄₂^-1 + λ₁₂*ϱ₂₃ + λ₁₂*ϱ₂₄ + λ₁₂*ϱ₃₁ + λ₁₂*ϱ₄₁ + λ₁₂*λ₁₃ + λ₁₂*λ₁₄ + λ₁₂*λ₂₃ + λ₁₂*λ₂₄ + λ₁₂*λ₃₁ + 2λ₁₂*λ₃₂ + 200λ₁₂*λ₃₄ + λ₁₂*λ₄₁ + 2λ₁₂*λ₄₂ + 200λ₁₂*λ₄₃ + 2λ₁₂*ϱ₁₃^-1 + 2λ₁₂*ϱ₁₄^-1 + λ₁₂*ϱ₂₃^-1 + λ₁₂*ϱ₂₄^-1 + λ₁₂*ϱ₃₁^-1 + 2λ₁₂*ϱ₃₂^-1 + 200λ₁₂*ϱ₃₄^-1 + λ₁₂*ϱ₄₁^-1 + 2λ₁₂*ϱ₄₂^-1 + 200λ₁₂*ϱ₄₃^-1 + λ₁₂*λ₁₃^-1 + λ₁₂*λ₁₄^-1 + λ₁₂*λ₂₃^-1 + λ₁₂*λ₂₄^-1 + λ₁₂*λ₃₁^-1 + 2λ₁₂*λ₃₂^-1 + 200λ₁₂*λ₃₄^-1 + λ₁₂*λ₄₁^-1 + 2λ₁₂*λ₄₂^-1 + 200λ₁₂*λ₄₃^-1 + λ₁₃*ϱ₂₁ + λ₁₃*ϱ₃₂ + λ₁₃*ϱ₃₄ + λ₁₃*ϱ₄₁ + λ₁₃*λ₁₂ + λ₁₃*λ₁₄ + λ₁₃*λ₂₁ + 2λ₁₃*λ₂₃ + 200λ₁₃*λ₂₄ + λ₁₃*λ₃₂ + λ₁₃*λ₃₄ + λ₁₃*λ₄₁ + 200λ₁₃*λ₄₂ + 2λ₁₃*λ₄₃ + 2λ₁₃*ϱ₁₂^-1 + 2λ₁₃*ϱ₁₄^-1 + λ₁₃*ϱ₂₁^-1 + 2λ₁₃*ϱ₂₃^-1 + 200λ₁₃*ϱ₂₄^-1 + λ₁₃*ϱ₃₂^-1 + λ₁₃*ϱ₃₄^-1 + λ₁₃*ϱ₄₁^-1 + 200λ₁₃*ϱ₄₂^-1 + 2λ₁₃*ϱ₄₃^-1 + λ₁₃*λ₁₂^-1 + λ₁₃*λ₁₄^-1 + λ₁₃*λ₂₁^-1 + 2λ₁₃*λ₂₃^-1 + 200λ₁₃*λ₂₄^-1 + λ₁₃*λ₃₂^-1 + λ₁₃*λ₃₄^-1 + λ₁₃*λ₄₁^-1 + 200λ₁₃*λ₄₂^-1 + 2λ₁₃*λ₄₃^-1 + λ₁₄*ϱ₂₁ + λ₁₄*ϱ₃₁ + λ₁₄*ϱ₄₂ + λ₁₄*ϱ₄₃ + λ₁₄*λ₁₂ + λ₁₄*λ₁₃ + λ₁₄*λ₂₁ + 200λ₁₄*λ₂₃ + 2λ₁₄*λ₂₄ + λ₁₄*λ₃₁ + 200λ₁₄*λ₃₂ + 2λ₁₄*λ₃₄ + λ₁₄*λ₄₂ + λ₁₄*λ₄₃ + 2λ₁₄*ϱ₁₂^-1 + 2λ₁₄*ϱ₁₃^-1 + λ₁₄*ϱ₂₁^-1 + 200λ₁₄*ϱ₂₃^-1 + 2λ₁₄*ϱ₂₄^-1 + λ₁₄*ϱ₃₁^-1 + 200λ₁₄*ϱ₃₂^-1 + 2λ₁₄*ϱ₃₄^-1 + λ₁₄*ϱ₄₂^-1 + λ₁₄*ϱ₄₃^-1 + λ₁₄*λ₁₂^-1 + λ₁₄*λ₁₃^-1 + λ₁₄*λ₂₁^-1 + 200λ₁₄*λ₂₃^-1 + 2λ₁₄*λ₂₄^-1 + λ₁₄*λ₃₁^-1 + 200λ₁₄*λ₃₂^-1 + 2λ₁₄*λ₃₄^-1 + λ₁₄*λ₄₂^-1 + λ₁₄*λ₄₃^-1 + λ₂₁*ϱ₁₃ + λ₂₁*ϱ₁₄ + λ₂₁*ϱ₃₂ + λ₂₁*ϱ₄₂ + λ₂₁*λ₁₃ + λ₂₁*λ₁₄ + λ₂₁*λ₂₃ + λ₂₁*λ₂₄ + 2λ₂₁*λ₃₁ + λ₂₁*λ₃₂ + 200λ₂₁*λ₃₄ + 2λ₂₁*λ₄₁ + λ₂₁*λ₄₂ + 200λ₂₁*λ₄₃ + λ₂₁*ϱ₁₃^-1 + λ₂₁*ϱ₁₄^-1 + 2λ₂₁*ϱ₂₃^-1 + 2λ₂₁*ϱ₂₄^-1 + 2λ₂₁*ϱ₃₁^-1 + λ₂₁*ϱ₃₂^-1 + 200λ₂₁*ϱ₃₄^-1 + 2λ₂₁*ϱ₄₁^-1 + λ₂₁*ϱ₄₂^-1 + 200λ₂₁*ϱ₄₃^-1 + λ₂₁*λ₁₃^-1 + λ₂₁*λ₁₄^-1 + λ₂₁*λ₂₃^-1 + λ₂₁*λ₂₄^-1 + 2λ₂₁*λ₃₁^-1 + λ₂₁*λ₃₂^-1 + 200λ₂₁*λ₃₄^-1 + 2λ₂₁*λ₄₁^-1 + λ₂₁*λ₄₂^-1 + 200λ₂₁*λ₄₃^-1 + λ₂₃*ϱ₁₂ + λ₂₃*ϱ₃₁ + λ₂₃*ϱ₃₄ + λ₂₃*ϱ₄₂ + λ₂₃*λ₁₂ + λ₂₃*λ₂₁ + λ₂₃*λ₂₄ + λ₂₃*λ₃₁ + λ₂₃*λ₃₄ + 200λ₂₃*λ₄₁ + λ₂₃*λ₄₂ + 2λ₂₃*λ₄₃ + λ₂₃*ϱ₁₂^-1 + 2λ₂₃*ϱ₁₃^-1 + 200λ₂₃*ϱ₁₄^-1 + 2λ₂₃*ϱ₂₁^-1 + 2λ₂₃*ϱ₂₄^-1 + λ₂₃*ϱ₃₁^-1 + λ₂₃*ϱ₃₄^-1 + 200λ₂₃*ϱ₄₁^-1 + λ₂₃*ϱ₄₂^-1 + 2λ₂₃*ϱ₄₃^-1 + λ₂₃*λ₁₂^-1 + 2λ₂₃*λ₁₃^-1 + 200λ₂₃*λ₁₄^-1 + λ₂₃*λ₂₁^-1 + λ₂₃*λ₂₄^-1 + λ₂₃*λ₃₁^-1 + λ₂₃*λ₃₄^-1 + 200λ₂₃*λ₄₁^-1 + λ₂₃*λ₄₂^-1 + 2λ₂₃*λ₄₃^-1 + λ₂₄*ϱ₁₂ + λ₂₄*ϱ₃₂ + λ₂₄*ϱ₄₁ + λ₂₄*ϱ₄₃ + λ₂₄*λ₁₂ + λ₂₄*λ₂₁ + λ₂₄*λ₂₃ + 200λ₂₄*λ₃₁ + λ₂₄*λ₃₂ + 2λ₂₄*λ₃₄ + λ₂₄*λ₄₁ + λ₂₄*λ₄₃ + λ₂₄*ϱ₁₂^-1 + 200λ₂₄*ϱ₁₃^-1 + 2λ₂₄*ϱ₁₄^-1 + 2λ₂₄*ϱ₂₁^-1 + 2λ₂₄*ϱ₂₃^-1 + 200λ₂₄*ϱ₃₁^-1 + λ₂₄*ϱ₃₂^-1 + 2λ₂₄*ϱ₃₄^-1 + λ₂₄*ϱ₄₁^-1 + λ₂₄*ϱ₄₃^-1 + λ₂₄*λ₁₂^-1 + 200λ₂₄*λ₁₃^-1 + 2λ₂₄*λ₁₄^-1 + λ₂₄*λ₂₁^-1 + λ₂₄*λ₂₃^-1 + 200λ₂₄*λ₃₁^-1 + λ₂₄*λ₃₂^-1 + 2λ₂₄*λ₃₄^-1 + λ₂₄*λ₄₁^-1 + λ₂₄*λ₄₃^-1 + λ₃₁*ϱ₁₂ + λ₃₁*ϱ₁₄ + λ₃₁*ϱ₂₃ + λ₃₁*ϱ₄₃ + λ₃₁*λ₁₂ + λ₃₁*λ₁₄ + λ₃₁*λ₂₃ + λ₃₁*λ₃₂ + λ₃₁*λ₃₄ + 2λ₃₁*λ₄₁ + 200λ₃₁*λ₄₂ + λ₃₁*λ₄₃ + λ₃₁*ϱ₁₂^-1 + λ₃₁*ϱ₁₄^-1 + 2λ₃₁*ϱ₂₁^-1 + λ₃₁*ϱ₂₃^-1 + 200λ₃₁*ϱ₂₄^-1 + 2λ₃₁*ϱ₃₂^-1 + 2λ₃₁*ϱ₃₄^-1 + 2λ₃₁*ϱ₄₁^-1 + 200λ₃₁*ϱ₄₂^-1 + λ₃₁*ϱ₄₃^-1 + λ₃₁*λ₁₂^-1 + λ₃₁*λ₁₄^-1 + 2λ₃₁*λ₂₁^-1 + λ₃₁*λ₂₃^-1 + 200λ₃₁*λ₂₄^-1 + λ₃₁*λ₃₂^-1 + λ₃₁*λ₃₄^-1 + 2λ₃₁*λ₄₁^-1 + 200λ₃₁*λ₄₂^-1 + λ₃₁*λ₄₃^-1 + λ₃₂*ϱ₁₃ + λ₃₂*ϱ₂₁ + λ₃₂*ϱ₂₄ + λ₃₂*ϱ₄₃ + λ₃₂*λ₁₃ + λ₃₂*λ₂₁ + λ₃₂*λ₂₄ + λ₃₂*λ₃₁ + λ₃₂*λ₃₄ + 200λ₃₂*λ₄₁ + 2λ₃₂*λ₄₂ + λ₃₂*λ₄₃ + 2λ₃₂*ϱ₁₂^-1 + λ₃₂*ϱ₁₃^-1 + 200λ₃₂*ϱ₁₄^-1 + λ₃₂*ϱ₂₁^-1 + λ₃₂*ϱ₂₄^-1 + 2λ₃₂*ϱ₃₁^-1 + 2λ₃₂*ϱ₃₄^-1 + 200λ₃₂*ϱ₄₁^-1 + 2λ₃₂*ϱ₄₂^-1 + λ₃₂*ϱ₄₃^-1 + 2λ₃₂*λ₁₂^-1 + λ₃₂*λ₁₃^-1 + 200λ₃₂*λ₁₄^-1 + λ₃₂*λ₂₁^-1 + λ₃₂*λ₂₄^-1 + λ₃₂*λ₃₁^-1 + λ₃₂*λ₃₄^-1 + 200λ₃₂*λ₄₁^-1 + 2λ₃₂*λ₄₂^-1 + λ₃₂*λ₄₃^-1 + λ₃₄*ϱ₁₃ + λ₃₄*ϱ₂₃ + λ₃₄*ϱ₄₁ + λ₃₄*ϱ₄₂ + λ₃₄*λ₁₃ + λ₃₄*λ₂₃ + λ₃₄*λ₃₁ + λ₃₄*λ₃₂ + λ₃₄*λ₄₁ + λ₃₄*λ₄₂ + 200λ₃₄*ϱ₁₂^-1 + λ₃₄*ϱ₁₃^-1 + 2λ₃₄*ϱ₁₄^-1 + 200λ₃₄*ϱ₂₁^-1 + λ₃₄*ϱ₂₃^-1 + 2λ₃₄*ϱ₂₄^-1 + 2λ₃₄*ϱ₃₁^-1 + 2λ₃₄*ϱ₃₂^-1 + λ₃₄*ϱ₄₁^-1 + λ₃₄*ϱ₄₂^-1 + 200λ₃₄*λ₁₂^-1 + λ₃₄*λ₁₃^-1 + 2λ₃₄*λ₁₄^-1 + 200λ₃₄*λ₂₁^-1 + λ₃₄*λ₂₃^-1 + 2λ₃₄*λ₂₄^-1 + λ₃₄*λ₃₁^-1 + λ₃₄*λ₃₂^-1 + λ₃₄*λ₄₁^-1 + λ₃₄*λ₄₂^-1 + λ₄₁*ϱ₁₂ + λ₄₁*ϱ₁₃ + λ₄₁*ϱ₂₄ + λ₄₁*ϱ₃₄ + λ₄₁*λ₁₂ + λ₄₁*λ₁₃ + λ₄₁*λ₂₄ + λ₄₁*λ₃₄ + λ₄₁*λ₄₂ + λ₄₁*λ₄₃ + λ₄₁*ϱ₁₂^-1 + λ₄₁*ϱ₁₃^-1 + 2λ₄₁*ϱ₂₁^-1 + 200λ₄₁*ϱ₂₃^-1 + λ₄₁*ϱ₂₄^-1 + 2λ₄₁*ϱ₃₁^-1 + 200λ₄₁*ϱ₃₂^-1 + λ₄₁*ϱ₃₄^-1 + 2λ₄₁*ϱ₄₂^-1 + 2λ₄₁*ϱ₄₃^-1 + λ₄₁*λ₁₂^-1 + λ₄₁*λ₁₃^-1 + 2λ₄₁*λ₂₁^-1 + 200λ₄₁*λ₂₃^-1 + λ₄₁*λ₂₄^-1 + 2λ₄₁*λ₃₁^-1 + 200λ₄₁*λ₃₂^-1 + λ₄₁*λ₃₄^-1 + λ₄₁*λ₄₂^-1 + λ₄₁*λ₄₃^-1 + λ₄₂*ϱ₁₄ + λ₄₂*ϱ₂₁ + λ₄₂*ϱ₂₃ + λ₄₂*ϱ₃₄ + λ₄₂*λ₁₄ + λ₄₂*λ₂₁ + λ₄₂*λ₂₃ + λ₄₂*λ₃₄ + λ₄₂*λ₄₁ + λ₄₂*λ₄₃ + 2λ₄₂*ϱ₁₂^-1 + 200λ₄₂*ϱ₁₃^-1 + λ₄₂*ϱ₁₄^-1 + λ₄₂*ϱ₂₁^-1 + λ₄₂*ϱ₂₃^-1 + 200λ₄₂*ϱ₃₁^-1 + 2λ₄₂*ϱ₃₂^-1 + λ₄₂*ϱ₃₄^-1 + 2λ₄₂*ϱ₄₁^-1 + 2λ₄₂*ϱ₄₃^-1 + 2λ₄₂*λ₁₂^-1 + 200λ₄₂*λ₁₃^-1 + λ₄₂*λ₁₄^-1 + λ₄₂*λ₂₁^-1 + λ₄₂*λ₂₃^-1 + 200λ₄₂*λ₃₁^-1 + 2λ₄₂*λ₃₂^-1 + λ₄₂*λ₃₄^-1 + λ₄₂*λ₄₁^-1 + λ₄₂*λ₄₃^-1 + λ₄₃*ϱ₁₄ + λ₄₃*ϱ₂₄ + λ₄₃*ϱ₃₁ + λ₄₃*ϱ₃₂ + λ₄₃*λ₁₄ + λ₄₃*λ₂₄ + λ₄₃*λ₃₁ + λ₄₃*λ₃₂ + λ₄₃*λ₄₁ + λ₄₃*λ₄₂ + 200λ₄₃*ϱ₁₂^-1 + 2λ₄₃*ϱ₁₃^-1 + λ₄₃*ϱ₁₄^-1 + 200λ₄₃*ϱ₂₁^-1 + 2λ₄₃*ϱ₂₃^-1 + λ₄₃*ϱ₂₄^-1 + λ₄₃*ϱ₃₁^-1 + λ₄₃*ϱ₃₂^-1 + 2λ₄₃*ϱ₄₁^-1 + 2λ₄₃*ϱ₄₂^-1 + 200λ₄₃*λ₁₂^-1 + 2λ₄₃*λ₁₃^-1 + λ₄₃*λ₁₄^-1 + 200λ₄₃*λ₂₁^-1 + 2λ₄₃*λ₂₃^-1 + λ₄₃*λ₂₄^-1 + λ₄₃*λ₃₁^-1 + λ₄₃*λ₃₂^-1 + λ₄₃*λ₄₁^-1 + λ₄₃*λ₄₂^-1 + ϱ₁₂^-1*ϱ₁₃ + ϱ₁₂^-1*ϱ₁₄ + ϱ₁₂^-1*ϱ₂₃ + ϱ₁₂^-1*ϱ₂₄ + ϱ₁₂^-1*ϱ₃₁ + ϱ₁₂^-1*ϱ₄₁ + ϱ₁₂^-1*λ₂₃ + ϱ₁₂^-1*λ₂₄ + ϱ₁₂^-1*λ₃₁ + ϱ₁₂^-1*λ₄₁ + ϱ₁₂^-1*ϱ₁₃^-1 + ϱ₁₂^-1*ϱ₁₄^-1 + ϱ₁₂^-1*ϱ₂₃^-1 + ϱ₁₂^-1*ϱ₂₄^-1 + ϱ₁₂^-1*ϱ₃₁^-1 + 2ϱ₁₂^-1*ϱ₃₂^-1 + 200ϱ₁₂^-1*ϱ₃₄^-1 + ϱ₁₂^-1*ϱ₄₁^-1 + 2ϱ₁₂^-1*ϱ₄₂^-1 + 200ϱ₁₂^-1*ϱ₄₃^-1 + 2ϱ₁₂^-1*λ₁₃^-1 + 2ϱ₁₂^-1*λ₁₄^-1 + ϱ₁₂^-1*λ₂₃^-1 + ϱ₁₂^-1*λ₂₄^-1 + ϱ₁₂^-1*λ₃₁^-1 + 2ϱ₁₂^-1*λ₃₂^-1 + 200ϱ₁₂^-1*λ₃₄^-1 + ϱ₁₂^-1*λ₄₁^-1 + 2ϱ₁₂^-1*λ₄₂^-1 + 200ϱ₁₂^-1*λ₄₃^-1 + ϱ₁₃^-1*ϱ₁₂ + ϱ₁₃^-1*ϱ₁₄ + ϱ₁₃^-1*ϱ₂₁ + ϱ₁₃^-1*ϱ₃₂ + ϱ₁₃^-1*ϱ₃₄ + ϱ₁₃^-1*ϱ₄₁ + ϱ₁₃^-1*λ₂₁ + ϱ₁₃^-1*λ₃₂ + ϱ₁₃^-1*λ₃₄ + ϱ₁₃^-1*λ₄₁ + ϱ₁₃^-1*ϱ₁₂^-1 + ϱ₁₃^-1*ϱ₁₄^-1 + ϱ₁₃^-1*ϱ₂₁^-1 + 2ϱ₁₃^-1*ϱ₂₃^-1 + 200ϱ₁₃^-1*ϱ₂₄^-1 + ϱ₁₃^-1*ϱ₃₂^-1 + ϱ₁₃^-1*ϱ₃₄^-1 + ϱ₁₃^-1*ϱ₄₁^-1 + 200ϱ₁₃^-1*ϱ₄₂^-1 + 2ϱ₁₃^-1*ϱ₄₃^-1 + 2ϱ₁₃^-1*λ₁₂^-1 + 2ϱ₁₃^-1*λ₁₄^-1 + ϱ₁₃^-1*λ₂₁^-1 + 2ϱ₁₃^-1*λ₂₃^-1 + 200ϱ₁₃^-1*λ₂₄^-1 + ϱ₁₃^-1*λ₃₂^-1 + ϱ₁₃^-1*λ₃₄^-1 + ϱ₁₃^-1*λ₄₁^-1 + 200ϱ₁₃^-1*λ₄₂^-1 + 2ϱ₁₃^-1*λ₄₃^-1 + ϱ₁₄^-1*ϱ₁₂ + ϱ₁₄^-1*ϱ₁₃ + ϱ₁₄^-1*ϱ₂₁ + ϱ₁₄^-1*ϱ₃₁ + ϱ₁₄^-1*ϱ₄₂ + ϱ₁₄^-1*ϱ₄₃ + ϱ₁₄^-1*λ₂₁ + ϱ₁₄^-1*λ₃₁ + ϱ₁₄^-1*λ₄₂ + ϱ₁₄^-1*λ₄₃ + ϱ₁₄^-1*ϱ₁₂^-1 + ϱ₁₄^-1*ϱ₁₃^-1 + ϱ₁₄^-1*ϱ₂₁^-1 + 200ϱ₁₄^-1*ϱ₂₃^-1 + 2ϱ₁₄^-1*ϱ₂₄^-1 + ϱ₁₄^-1*ϱ₃₁^-1 + 200ϱ₁₄^-1*ϱ₃₂^-1 + 2ϱ₁₄^-1*ϱ₃₄^-1 + ϱ₁₄^-1*ϱ₄₂^-1 + ϱ₁₄^-1*ϱ₄₃^-1 + 2ϱ₁₄^-1*λ₁₂^-1 + 2ϱ₁₄^-1*λ₁₃^-1 + ϱ₁₄^-1*λ₂₁^-1 + 200ϱ₁₄^-1*λ₂₃^-1 + 2ϱ₁₄^-1*λ₂₄^-1 + ϱ₁₄^-1*λ₃₁^-1 + 200ϱ₁₄^-1*λ₃₂^-1 + 2ϱ₁₄^-1*λ₃₄^-1 + ϱ₁₄^-1*λ₄₂^-1 + ϱ₁₄^-1*λ₄₃^-1 + ϱ₂₁^-1*ϱ₁₃ + ϱ₂₁^-1*ϱ₁₄ + ϱ₂₁^-1*ϱ₂₃ + ϱ₂₁^-1*ϱ₂₄ + ϱ₂₁^-1*ϱ₃₂ + ϱ₂₁^-1*ϱ₄₂ + ϱ₂₁^-1*λ₁₃ + ϱ₂₁^-1*λ₁₄ + ϱ₂₁^-1*λ₃₂ + ϱ₂₁^-1*λ₄₂ + ϱ₂₁^-1*ϱ₁₃^-1 + ϱ₂₁^-1*ϱ₁₄^-1 + ϱ₂₁^-1*ϱ₂₃^-1 + ϱ₂₁^-1*ϱ₂₄^-1 + 2ϱ₂₁^-1*ϱ₃₁^-1 + ϱ₂₁^-1*ϱ₃₂^-1 + 200ϱ₂₁^-1*ϱ₃₄^-1 + 2ϱ₂₁^-1*ϱ₄₁^-1 + ϱ₂₁^-1*ϱ₄₂^-1 + 200ϱ₂₁^-1*ϱ₄₃^-1 + ϱ₂₁^-1*λ₁₃^-1 + ϱ₂₁^-1*λ₁₄^-1 + 2ϱ₂₁^-1*λ₂₃^-1 + 2ϱ₂₁^-1*λ₂₄^-1 + 2ϱ₂₁^-1*λ₃₁^-1 + ϱ₂₁^-1*λ₃₂^-1 + 200ϱ₂₁^-1*λ₃₄^-1 + 2ϱ₂₁^-1*λ₄₁^-1 + ϱ₂₁^-1*λ₄₂^-1 + 200ϱ₂₁^-1*λ₄₃^-1 + ϱ₂₃^-1*ϱ₁₂ + ϱ₂₃^-1*ϱ₂₁ + ϱ₂₃^-1*ϱ₂₄ + ϱ₂₃^-1*ϱ₃₁ + ϱ₂₃^-1*ϱ₃₄ + ϱ₂₃^-1*ϱ₄₂ + ϱ₂₃^-1*λ₁₂ + ϱ₂₃^-1*λ₃₁ + ϱ₂₃^-1*λ₃₄ + ϱ₂₃^-1*λ₄₂ + ϱ₂₃^-1*ϱ₁₂^-1 + ϱ₂₃^-1*ϱ₂₁^-1 + ϱ₂₃^-1*ϱ₂₄^-1 + ϱ₂₃^-1*ϱ₃₁^-1 + ϱ₂₃^-1*ϱ₃₄^-1 + 200ϱ₂₃^-1*ϱ₄₁^-1 + ϱ₂₃^-1*ϱ₄₂^-1 + 2ϱ₂₃^-1*ϱ₄₃^-1 + ϱ₂₃^-1*λ₁₂^-1 + 2ϱ₂₃^-1*λ₁₃^-1 + 200ϱ₂₃^-1*λ₁₄^-1 + 2ϱ₂₃^-1*λ₂₁^-1 + 2ϱ₂₃^-1*λ₂₄^-1 + ϱ₂₃^-1*λ₃₁^-1 + ϱ₂₃^-1*λ₃₄^-1 + 200ϱ₂₃^-1*λ₄₁^-1 + ϱ₂₃^-1*λ₄₂^-1 + 2ϱ₂₃^-1*λ₄₃^-1 + ϱ₂₄^-1*ϱ₁₂ + ϱ₂₄^-1*ϱ₂₁ + ϱ₂₄^-1*ϱ₂₃ + ϱ₂₄^-1*ϱ₃₂ + ϱ₂₄^-1*ϱ₄₁ + ϱ₂₄^-1*ϱ₄₃ + ϱ₂₄^-1*λ₁₂ + ϱ₂₄^-1*λ₃₂ + ϱ₂₄^-1*λ₄₁ + ϱ₂₄^-1*λ₄₃ + ϱ₂₄^-1*ϱ₁₂^-1 + ϱ₂₄^-1*ϱ₂₁^-1 + ϱ₂₄^-1*ϱ₂₃^-1 + 200ϱ₂₄^-1*ϱ₃₁^-1 + ϱ₂₄^-1*ϱ₃₂^-1 + 2ϱ₂₄^-1*ϱ₃₄^-1 + ϱ₂₄^-1*ϱ₄₁^-1 + ϱ₂₄^-1*ϱ₄₃^-1 + ϱ₂₄^-1*λ₁₂^-1 + 200ϱ₂₄^-1*λ₁₃^-1 + 2ϱ₂₄^-1*λ₁₄^-1 + 2ϱ₂₄^-1*λ₂₁^-1 + 2ϱ₂₄^-1*λ₂₃^-1 + 200ϱ₂₄^-1*λ₃₁^-1 + ϱ₂₄^-1*λ₃₂^-1 + 2ϱ₂₄^-1*λ₃₄^-1 + ϱ₂₄^-1*λ₄₁^-1 + ϱ₂₄^-1*λ₄₃^-1 + ϱ₃₁^-1*ϱ₁₂ + ϱ₃₁^-1*ϱ₁₄ + ϱ₃₁^-1*ϱ₂₃ + ϱ₃₁^-1*ϱ₃₂ + ϱ₃₁^-1*ϱ₃₄ + ϱ₃₁^-1*ϱ₄₃ + ϱ₃₁^-1*λ₁₂ + ϱ₃₁^-1*λ₁₄ + ϱ₃₁^-1*λ₂₃ + ϱ₃₁^-1*λ₄₃ + ϱ₃₁^-1*ϱ₁₂^-1 + ϱ₃₁^-1*ϱ₁₄^-1 + ϱ₃₁^-1*ϱ₂₃^-1 + ϱ₃₁^-1*ϱ₃₂^-1 + ϱ₃₁^-1*ϱ₃₄^-1 + 2ϱ₃₁^-1*ϱ₄₁^-1 + 200ϱ₃₁^-1*ϱ₄₂^-1 + ϱ₃₁^-1*ϱ₄₃^-1 + ϱ₃₁^-1*λ₁₂^-1 + ϱ₃₁^-1*λ₁₄^-1 + 2ϱ₃₁^-1*λ₂₁^-1 + ϱ₃₁^-1*λ₂₃^-1 + 200ϱ₃₁^-1*λ₂₄^-1 + 2ϱ₃₁^-1*λ₃₂^-1 + 2ϱ₃₁^-1*λ₃₄^-1 + 2ϱ₃₁^-1*λ₄₁^-1 + 200ϱ₃₁^-1*λ₄₂^-1 + ϱ₃₁^-1*λ₄₃^-1 + ϱ₃₂^-1*ϱ₁₃ + ϱ₃₂^-1*ϱ₂₁ + ϱ₃₂^-1*ϱ₂₄ + ϱ₃₂^-1*ϱ₃₁ + ϱ₃₂^-1*ϱ₃₄ + ϱ₃₂^-1*ϱ₄₃ + ϱ₃₂^-1*λ₁₃ + ϱ₃₂^-1*λ₂₁ + ϱ₃₂^-1*λ₂₄ + ϱ₃₂^-1*λ₄₃ + ϱ₃₂^-1*ϱ₁₃^-1 + ϱ₃₂^-1*ϱ₂₁^-1 + ϱ₃₂^-1*ϱ₂₄^-1 + ϱ₃₂^-1*ϱ₃₁^-1 + ϱ₃₂^-1*ϱ₃₄^-1 + 200ϱ₃₂^-1*ϱ₄₁^-1 + 2ϱ₃₂^-1*ϱ₄₂^-1 + ϱ₃₂^-1*ϱ₄₃^-1 + 2ϱ₃₂^-1*λ₁₂^-1 + ϱ₃₂^-1*λ₁₃^-1 + 200ϱ₃₂^-1*λ₁₄^-1 + ϱ₃₂^-1*λ₂₁^-1 + ϱ₃₂^-1*λ₂₄^-1 + 2ϱ₃₂^-1*λ₃₁^-1 + 2ϱ₃₂^-1*λ₃₄^-1 + 200ϱ₃₂^-1*λ₄₁^-1 + 2ϱ₃₂^-1*λ₄₂^-1 + ϱ₃₂^-1*λ₄₃^-1 + ϱ₃₄^-1*ϱ₁₃ + ϱ₃₄^-1*ϱ₂₃ + ϱ₃₄^-1*ϱ₃₁ + ϱ₃₄^-1*ϱ₃₂ + ϱ₃₄^-1*ϱ₄₁ + ϱ₃₄^-1*ϱ₄₂ + ϱ₃₄^-1*λ₁₃ + ϱ₃₄^-1*λ₂₃ + ϱ₃₄^-1*λ₄₁ + ϱ₃₄^-1*λ₄₂ + ϱ₃₄^-1*ϱ₁₃^-1 + ϱ₃₄^-1*ϱ₂₃^-1 + ϱ₃₄^-1*ϱ₃₁^-1 + ϱ₃₄^-1*ϱ₃₂^-1 + ϱ₃₄^-1*ϱ₄₁^-1 + ϱ₃₄^-1*ϱ₄₂^-1 + 200ϱ₃₄^-1*λ₁₂^-1 + ϱ₃₄^-1*λ₁₃^-1 + 2ϱ₃₄^-1*λ₁₄^-1 + 200ϱ₃₄^-1*λ₂₁^-1 + ϱ₃₄^-1*λ₂₃^-1 + 2ϱ₃₄^-1*λ₂₄^-1 + 2ϱ₃₄^-1*λ₃₁^-1 + 2ϱ₃₄^-1*λ₃₂^-1 + ϱ₃₄^-1*λ₄₁^-1 + ϱ₃₄^-1*λ₄₂^-1 + ϱ₄₁^-1*ϱ₁₂ + ϱ₄₁^-1*ϱ₁₃ + ϱ₄₁^-1*ϱ₂₄ + ϱ₄₁^-1*ϱ₃₄ + ϱ₄₁^-1*ϱ₄₂ + ϱ₄₁^-1*ϱ₄₃ + ϱ₄₁^-1*λ₁₂ + ϱ₄₁^-1*λ₁₃ + ϱ₄₁^-1*λ₂₄ + ϱ₄₁^-1*λ₃₄ + ϱ₄₁^-1*ϱ₁₂^-1 + ϱ₄₁^-1*ϱ₁₃^-1 + ϱ₄₁^-1*ϱ₂₄^-1 + ϱ₄₁^-1*ϱ₃₄^-1 + ϱ₄₁^-1*ϱ₄₂^-1 + ϱ₄₁^-1*ϱ₄₃^-1 + ϱ₄₁^-1*λ₁₂^-1 + ϱ₄₁^-1*λ₁₃^-1 + 2ϱ₄₁^-1*λ₂₁^-1 + 200ϱ₄₁^-1*λ₂₃^-1 + ϱ₄₁^-1*λ₂₄^-1 + 2ϱ₄₁^-1*λ₃₁^-1 + 200ϱ₄₁^-1*λ₃₂^-1 + ϱ₄₁^-1*λ₃₄^-1 + 2ϱ₄₁^-1*λ₄₂^-1 + 2ϱ₄₁^-1*λ₄₃^-1 + ϱ₄₂^-1*ϱ₁₄ + ϱ₄₂^-1*ϱ₂₁ + ϱ₄₂^-1*ϱ₂₃ + ϱ₄₂^-1*ϱ₃₄ + ϱ₄₂^-1*ϱ₄₁ + ϱ₄₂^-1*ϱ₄₃ + ϱ₄₂^-1*λ₁₄ + ϱ₄₂^-1*λ₂₁ + ϱ₄₂^-1*λ₂₃ + ϱ₄₂^-1*λ₃₄ + ϱ₄₂^-1*ϱ₁₄^-1 + ϱ₄₂^-1*ϱ₂₁^-1 + ϱ₄₂^-1*ϱ₂₃^-1 + ϱ₄₂^-1*ϱ₃₄^-1 + ϱ₄₂^-1*ϱ₄₁^-1 + ϱ₄₂^-1*ϱ₄₃^-1 + 2ϱ₄₂^-1*λ₁₂^-1 + 200ϱ₄₂^-1*λ₁₃^-1 + ϱ₄₂^-1*λ₁₄^-1 + ϱ₄₂^-1*λ₂₁^-1 + ϱ₄₂^-1*λ₂₃^-1 + 200ϱ₄₂^-1*λ₃₁^-1 + 2ϱ₄₂^-1*λ₃₂^-1 + ϱ₄₂^-1*λ₃₄^-1 + 2ϱ₄₂^-1*λ₄₁^-1 + 2ϱ₄₂^-1*λ₄₃^-1 + ϱ₄₃^-1*ϱ₁₄ + ϱ₄₃^-1*ϱ₂₄ + ϱ₄₃^-1*ϱ₃₁ + ϱ₄₃^-1*ϱ₃₂ + ϱ₄₃^-1*ϱ₄₁ + ϱ₄₃^-1*ϱ₄₂ + ϱ₄₃^-1*λ₁₄ + ϱ₄₃^-1*λ₂₄ + ϱ₄₃^-1*λ₃₁ + ϱ₄₃^-1*λ₃₂ + ϱ₄₃^-1*ϱ₁₄^-1 + ϱ₄₃^-1*ϱ₂₄^-1 + ϱ₄₃^-1*ϱ₃₁^-1 + ϱ₄₃^-1*ϱ₃₂^-1 + ϱ₄₃^-1*ϱ₄₁^-1 + ϱ₄₃^-1*ϱ₄₂^-1 + 200ϱ₄₃^-1*λ₁₂^-1 + 2ϱ₄₃^-1*λ₁₃^-1 + ϱ₄₃^-1*λ₁₄^-1 + 200ϱ₄₃^-1*λ₂₁^-1 + 2ϱ₄₃^-1*λ₂₃^-1 + ϱ₄₃^-1*λ₂₄^-1 + ϱ₄₃^-1*λ₃₁^-1 + ϱ₄₃^-1*λ₃₂^-1 + 2ϱ₄₃^-1*λ₄₁^-1 + 2ϱ₄₃^-1*λ₄₂^-1 + λ₁₂^-1*ϱ₂₃ + λ₁₂^-1*ϱ₂₄ + λ₁₂^-1*ϱ₃₁ + λ₁₂^-1*ϱ₄₁ + λ₁₂^-1*λ₁₃ + λ₁₂^-1*λ₁₄ + λ₁₂^-1*λ₂₃ + λ₁₂^-1*λ₂₄ + λ₁₂^-1*λ₃₁ + λ₁₂^-1*λ₄₁ + λ₁₂^-1*ϱ₂₃^-1 + λ₁₂^-1*ϱ₂₄^-1 + λ₁₂^-1*ϱ₃₁^-1 + λ₁₂^-1*ϱ₄₁^-1 + λ₁₂^-1*λ₁₃^-1 + λ₁₂^-1*λ₁₄^-1 + λ₁₂^-1*λ₂₃^-1 + λ₁₂^-1*λ₂₄^-1 + λ₁₂^-1*λ₃₁^-1 + 2λ₁₂^-1*λ₃₂^-1 + 200λ₁₂^-1*λ₃₄^-1 + λ₁₂^-1*λ₄₁^-1 + 2λ₁₂^-1*λ₄₂^-1 + 200λ₁₂^-1*λ₄₃^-1 + λ₁₃^-1*ϱ₂₁ + λ₁₃^-1*ϱ₃₂ + λ₁₃^-1*ϱ₃₄ + λ₁₃^-1*ϱ₄₁ + λ₁₃^-1*λ₁₂ + λ₁₃^-1*λ₁₄ + λ₁₃^-1*λ₂₁ + λ₁₃^-1*λ₃₂ + λ₁₃^-1*λ₃₄ + λ₁₃^-1*λ₄₁ + λ₁₃^-1*ϱ₂₁^-1 + λ₁₃^-1*ϱ₃₂^-1 + λ₁₃^-1*ϱ₃₄^-1 + λ₁₃^-1*ϱ₄₁^-1 + λ₁₃^-1*λ₁₂^-1 + λ₁₃^-1*λ₁₄^-1 + λ₁₃^-1*λ₂₁^-1 + 2λ₁₃^-1*λ₂₃^-1 + 200λ₁₃^-1*λ₂₄^-1 + λ₁₃^-1*λ₃₂^-1 + λ₁₃^-1*λ₃₄^-1 + λ₁₃^-1*λ₄₁^-1 + 200λ₁₃^-1*λ₄₂^-1 + 2λ₁₃^-1*λ₄₃^-1 + λ₁₄^-1*ϱ₂₁ + λ₁₄^-1*ϱ₃₁ + λ₁₄^-1*ϱ₄₂ + λ₁₄^-1*ϱ₄₃ + λ₁₄^-1*λ₁₂ + λ₁₄^-1*λ₁₃ + λ₁₄^-1*λ₂₁ + λ₁₄^-1*λ₃₁ + λ₁₄^-1*λ₄₂ + λ₁₄^-1*λ₄₃ + λ₁₄^-1*ϱ₂₁^-1 + λ₁₄^-1*ϱ₃₁^-1 + λ₁₄^-1*ϱ₄₂^-1 + λ₁₄^-1*ϱ₄₃^-1 + λ₁₄^-1*λ₁₂^-1 + λ₁₄^-1*λ₁₃^-1 + λ₁₄^-1*λ₂₁^-1 + 200λ₁₄^-1*λ₂₃^-1 + 2λ₁₄^-1*λ₂₄^-1 + λ₁₄^-1*λ₃₁^-1 + 200λ₁₄^-1*λ₃₂^-1 + 2λ₁₄^-1*λ₃₄^-1 + λ₁₄^-1*λ₄₂^-1 + λ₁₄^-1*λ₄₃^-1 + λ₂₁^-1*ϱ₁₃ + λ₂₁^-1*ϱ₁₄ + λ₂₁^-1*ϱ₃₂ + λ₂₁^-1*ϱ₄₂ + λ₂₁^-1*λ₁₃ + λ₂₁^-1*λ₁₄ + λ₂₁^-1*λ₂₃ + λ₂₁^-1*λ₂₄ + λ₂₁^-1*λ₃₂ + λ₂₁^-1*λ₄₂ + λ₂₁^-1*ϱ₁₃^-1 + λ₂₁^-1*ϱ₁₄^-1 + λ₂₁^-1*ϱ₃₂^-1 + λ₂₁^-1*ϱ₄₂^-1 + λ₂₁^-1*λ₁₃^-1 + λ₂₁^-1*λ₁₄^-1 + λ₂₁^-1*λ₂₃^-1 + λ₂₁^-1*λ₂₄^-1 + 2λ₂₁^-1*λ₃₁^-1 + λ₂₁^-1*λ₃₂^-1 + 200λ₂₁^-1*λ₃₄^-1 + 2λ₂₁^-1*λ₄₁^-1 + λ₂₁^-1*λ₄₂^-1 + 200λ₂₁^-1*λ₄₃^-1 + λ₂₃^-1*ϱ₁₂ + λ₂₃^-1*ϱ₃₁ + λ₂₃^-1*ϱ₃₄ + λ₂₃^-1*ϱ₄₂ + λ₂₃^-1*λ₁₂ + λ₂₃^-1*λ₂₁ + λ₂₃^-1*λ₂₄ + λ₂₃^-1*λ₃₁ + λ₂₃^-1*λ₃₄ + λ₂₃^-1*λ₄₂ + λ₂₃^-1*ϱ₁₂^-1 + λ₂₃^-1*ϱ₃₁^-1 + λ₂₃^-1*ϱ₃₄^-1 + λ₂₃^-1*ϱ₄₂^-1 + λ₂₃^-1*λ₁₂^-1 + λ₂₃^-1*λ₂₁^-1 + λ₂₃^-1*λ₂₄^-1 + λ₂₃^-1*λ₃₁^-1 + λ₂₃^-1*λ₃₄^-1 + 200λ₂₃^-1*λ₄₁^-1 + λ₂₃^-1*λ₄₂^-1 + 2λ₂₃^-1*λ₄₃^-1 + λ₂₄^-1*ϱ₁₂ + λ₂₄^-1*ϱ₃₂ + λ₂₄^-1*ϱ₄₁ + λ₂₄^-1*ϱ₄₃ + λ₂₄^-1*λ₁₂ + λ₂₄^-1*λ₂₁ + λ₂₄^-1*λ₂₃ + λ₂₄^-1*λ₃₂ + λ₂₄^-1*λ₄₁ + λ₂₄^-1*λ₄₃ + λ₂₄^-1*ϱ₁₂^-1 + λ₂₄^-1*ϱ₃₂^-1 + λ₂₄^-1*ϱ₄₁^-1 + λ₂₄^-1*ϱ₄₃^-1 + λ₂₄^-1*λ₁₂^-1 + λ₂₄^-1*λ₂₁^-1 + λ₂₄^-1*λ₂₃^-1 + 200λ₂₄^-1*λ₃₁^-1 + λ₂₄^-1*λ₃₂^-1 + 2λ₂₄^-1*λ₃₄^-1 + λ₂₄^-1*λ₄₁^-1 + λ₂₄^-1*λ₄₃^-1 + λ₃₁^-1*ϱ₁₂ + λ₃₁^-1*ϱ₁₄ + λ₃₁^-1*ϱ₂₃ + λ₃₁^-1*ϱ₄₃ + λ₃₁^-1*λ₁₂ + λ₃₁^-1*λ₁₄ + λ₃₁^-1*λ₂₃ + λ₃₁^-1*λ₃₂ + λ₃₁^-1*λ₃₄ + λ₃₁^-1*λ₄₃ + λ₃₁^-1*ϱ₁₂^-1 + λ₃₁^-1*ϱ₁₄^-1 + λ₃₁^-1*ϱ₂₃^-1 + λ₃₁^-1*ϱ₄₃^-1 + λ₃₁^-1*λ₁₂^-1 + λ₃₁^-1*λ₁₄^-1 + λ₃₁^-1*λ₂₃^-1 + λ₃₁^-1*λ₃₂^-1 + λ₃₁^-1*λ₃₄^-1 + 2λ₃₁^-1*λ₄₁^-1 + 200λ₃₁^-1*λ₄₂^-1 + λ₃₁^-1*λ₄₃^-1 + λ₃₂^-1*ϱ₁₃ + λ₃₂^-1*ϱ₂₁ + λ₃₂^-1*ϱ₂₄ + λ₃₂^-1*ϱ₄₃ + λ₃₂^-1*λ₁₃ + λ₃₂^-1*λ₂₁ + λ₃₂^-1*λ₂₄ + λ₃₂^-1*λ₃₁ + λ₃₂^-1*λ₃₄ + λ₃₂^-1*λ₄₃ + λ₃₂^-1*ϱ₁₃^-1 + λ₃₂^-1*ϱ₂₁^-1 + λ₃₂^-1*ϱ₂₄^-1 + λ₃₂^-1*ϱ₄₃^-1 + λ₃₂^-1*λ₁₃^-1 + λ₃₂^-1*λ₂₁^-1 + λ₃₂^-1*λ₂₄^-1 + λ₃₂^-1*λ₃₁^-1 + λ₃₂^-1*λ₃₄^-1 + 200λ₃₂^-1*λ₄₁^-1 + 2λ₃₂^-1*λ₄₂^-1 + λ₃₂^-1*λ₄₃^-1 + λ₃₄^-1*ϱ₁₃ + λ₃₄^-1*ϱ₂₃ + λ₃₄^-1*ϱ₄₁ + λ₃₄^-1*ϱ₄₂ + λ₃₄^-1*λ₁₃ + λ₃₄^-1*λ₂₃ + λ₃₄^-1*λ₃₁ + λ₃₄^-1*λ₃₂ + λ₃₄^-1*λ₄₁ + λ₃₄^-1*λ₄₂ + λ₃₄^-1*ϱ₁₃^-1 + λ₃₄^-1*ϱ₂₃^-1 + λ₃₄^-1*ϱ₄₁^-1 + λ₃₄^-1*ϱ₄₂^-1 + λ₃₄^-1*λ₁₃^-1 + λ₃₄^-1*λ₂₃^-1 + λ₃₄^-1*λ₃₁^-1 + λ₃₄^-1*λ₃₂^-1 + λ₃₄^-1*λ₄₁^-1 + λ₃₄^-1*λ₄₂^-1 + λ₄₁^-1*ϱ₁₂ + λ₄₁^-1*ϱ₁₃ + λ₄₁^-1*ϱ₂₄ + λ₄₁^-1*ϱ₃₄ + λ₄₁^-1*λ₁₂ + λ₄₁^-1*λ₁₃ + λ₄₁^-1*λ₂₄ + λ₄₁^-1*λ₃₄ + λ₄₁^-1*λ₄₂ + λ₄₁^-1*λ₄₃ + λ₄₁^-1*ϱ₁₂^-1 + λ₄₁^-1*ϱ₁₃^-1 + λ₄₁^-1*ϱ₂₄^-1 + λ₄₁^-1*ϱ₃₄^-1 + λ₄₁^-1*λ₁₂^-1 + λ₄₁^-1*λ₁₃^-1 + λ₄₁^-1*λ₂₄^-1 + λ₄₁^-1*λ₃₄^-1 + λ₄₁^-1*λ₄₂^-1 + λ₄₁^-1*λ₄₃^-1 + λ₄₂^-1*ϱ₁₄ + λ₄₂^-1*ϱ₂₁ + λ₄₂^-1*ϱ₂₃ + λ₄₂^-1*ϱ₃₄ + λ₄₂^-1*λ₁₄ + λ₄₂^-1*λ₂₁ + λ₄₂^-1*λ₂₃ + λ₄₂^-1*λ₃₄ + λ₄₂^-1*λ₄₁ + λ₄₂^-1*λ₄₃ + λ₄₂^-1*ϱ₁₄^-1 + λ₄₂^-1*ϱ₂₁^-1 + λ₄₂^-1*ϱ₂₃^-1 + λ₄₂^-1*ϱ₃₄^-1 + λ₄₂^-1*λ₁₄^-1 + λ₄₂^-1*λ₂₁^-1 + λ₄₂^-1*λ₂₃^-1 + λ₄₂^-1*λ₃₄^-1 + λ₄₂^-1*λ₄₁^-1 + λ₄₂^-1*λ₄₃^-1 + λ₄₃^-1*ϱ₁₄ + λ₄₃^-1*ϱ₂₄ + λ₄₃^-1*ϱ₃₁ + λ₄₃^-1*ϱ₃₂ + λ₄₃^-1*λ₁₄ + λ₄₃^-1*λ₂₄ + λ₄₃^-1*λ₃₁ + λ₄₃^-1*λ₃₂ + λ₄₃^-1*λ₄₁ + λ₄₃^-1*λ₄₂ + λ₄₃^-1*ϱ₁₄^-1 + λ₄₃^-1*ϱ₂₄^-1 + λ₄₃^-1*ϱ₃₁^-1 + λ₄₃^-1*ϱ₃₂^-1 + λ₄₃^-1*λ₁₄^-1 + λ₄₃^-1*λ₂₄^-1 + λ₄₃^-1*λ₃₁^-1 + λ₄₃^-1*λ₃₂^-1 + λ₄₃^-1*λ₄₁^-1 + λ₄₃^-1*λ₄₂^-1 We are ready to define the optimisation problem. Function > `PropertyT.SOS_problem(x, Δ, orbit_data; upper_bound=UB)` defines the optimisation problem equivalent to the one of the form \begin{align} \text{ maximize : } \quad & \lambda\\ \text{under constraints : }\quad & 0 \leqslant \lambda \leqslant \operatorname{UB},\\ & x - \lambda \Delta = \sum \xi_i^* \xi_i,\\ & \text{with $\sum \xi_i^* \xi_i$ invariant under the action of $S_2 \wr S_4$}. \end{align} ```julia SDP_problem, varP = PropertyT.SOS_problem_primal(elt₄, Δ₄, block_decomposition; upper_bound=0.1); (SDP_problem,) ``` ┌ Info: Adding 6231 constraints... └ @ PropertyT /home/kalmar/.julia/packages/PropertyT/vcGsE/src/sos_sdps.jl:124 24.120746 seconds (8.20 M allocations: 33.581 GiB, 7.96% gc time) (A JuMP Model Maximization problem with: Variables: 11047 Objective function type: JuMP.VariableRef `JuMP.GenericAffExpr{Float64,JuMP.VariableRef}`-in-`MathOptInterface.EqualTo{Float64}`: 6231 constraints `Array{JuMP.GenericAffExpr{Float64,JuMP.VariableRef},1}`-in-`MathOptInterface.PositiveSemidefiniteConeSquare`: 20 constraints `JuMP.VariableRef`-in-`MathOptInterface.LessThan{Float64}`: 1 constraint Model mode: AUTOMATIC CachingOptimizer state: NO_OPTIMIZER Solver name: No optimizer attached. Names registered in the model: λ,) ### Solving the problem Depending on the actual problem one may need to tweak the parameters given to the solver: * `eps` sets the requested accuracy, * `max_iters` sets the number of iterations to run before solver gives up, * `alpha` is a bias parameter ($\alpha \in (0,2)$) which determines the step size (hence the rate of convergence). $\alpha$ close to $2$ shoudl provide fastest initial convergence, but may introduce numerical noise. * `acceleration_lookback`: if you experience numerical instability in scs log should be changed to `0`. The parameters below should be enough to obtain a decent solution for $\operatorname{Adj}_4 + 100.0\operatorname{Op}_4 - 0.1\Delta_4$ in reasonable time (<10 minutes). ```julia using PropertyT.JuMP using SCS warm = nothing ``` ```julia with_SCS = with_optimizer(SCS.Optimizer, linear_solver=SCS.DirectSolver, eps=1e-10, max_iters=10_000, alpha=1.5, acceleration_lookback=25, warm_start=true) status, warm = PropertyT.solve(SDP_problem, with_SCS, warm); @show status; ``` ---------------------------------------------------------------------------- SCS v2.1.2 - Splitting Conic Solver (c) Brendan O'Donoghue, Stanford University, 2012 ---------------------------------------------------------------------------- Lin-sys: sparse-direct, nnz in A = 8010504 eps = 1.00e-10, alpha = 1.50, max_iters = 10000, normalize = 1, scale = 1.00 acceleration_lookback = 25, rho_x = 1.00e-03 Variables n = 11047, constraints m = 17278 Cones: primal zero / dual free vars: 11570 linear vars: 1 sd vars: 5707, sd blks: 20 Setup time: 8.97e+01s SCS using variable warm-starting ---------------------------------------------------------------------------- Iter | pri res | dua res | rel gap | pri obj | dua obj | kap/tau | time (s) ---------------------------------------------------------------------------- 0| 3.46e+20 2.60e+20 1.00e+00 -2.31e+23 1.87e+21 5.59e+22 1.99e-01 100| 8.05e-04 4.66e-04 5.00e-02 4.02e-02 -1.24e-02 1.95e-15 1.05e+01 200| 3.06e-04 2.06e-04 2.33e-03 3.49e-02 3.24e-02 8.28e-15 2.08e+01 300| 2.20e-04 1.50e-04 7.79e-03 9.21e-03 1.34e-03 5.06e-15 3.12e+01 400| 1.23e-04 9.22e-05 9.82e-04 2.12e-02 2.22e-02 7.79e-16 4.16e+01 500| 1.08e-04 7.81e-05 1.21e-02 1.22e-02 2.47e-02 1.02e-14 5.19e+01 600| 8.40e-05 6.04e-05 1.85e-03 4.37e-03 2.51e-03 5.90e-15 6.23e+01 700| 6.99e-05 5.00e-05 1.01e-03 4.32e-03 5.34e-03 1.13e-15 7.26e+01 800| 5.73e-05 4.39e-05 2.75e-03 2.33e-03 5.10e-03 1.05e-14 8.29e+01 900| 4.30e-05 3.50e-05 1.23e-03 2.11e-03 8.76e-04 6.81e-15 9.32e+01 1000| 3.76e-05 2.80e-05 2.67e-04 2.71e-03 2.97e-03 4.71e-15 1.04e+02 1100| 2.44e-05 1.79e-05 6.35e-04 2.55e-03 3.19e-03 2.63e-15 1.14e+02 1200| 2.55e-05 1.96e-05 3.56e-04 1.82e-03 1.46e-03 2.04e-14 1.24e+02 1300| 1.32e-05 1.16e-05 7.56e-04 -1.02e-03 -1.78e-03 9.40e-15 1.34e+02 1400| 1.08e-05 8.13e-06 6.76e-04 -1.21e-03 -1.88e-03 8.61e-15 1.45e+02 1500| 7.78e-06 7.03e-06 1.07e-04 2.65e-04 1.58e-04 2.42e-14 1.55e+02 1600| 6.93e-06 5.65e-06 2.58e-04 3.38e-04 8.01e-05 2.51e-14 1.65e+02 1700| 5.30e-06 4.94e-06 1.84e-04 -4.83e-04 -2.98e-04 2.34e-14 1.75e+02 1800| 6.58e-06 6.49e-06 4.62e-04 -5.02e-04 -9.65e-04 7.54e-15 1.86e+02 1900| 6.68e-06 6.49e-06 5.31e-04 2.03e-05 -5.11e-04 4.04e-15 1.96e+02 2000| 5.36e-06 5.03e-06 3.51e-04 -8.41e-05 2.67e-04 1.85e-14 2.06e+02 2100| 6.41e-06 4.85e-06 2.48e-04 7.09e-05 -1.77e-04 9.05e-15 2.16e+02 2200| 6.55e-06 6.66e-06 3.96e-04 3.61e-04 -3.59e-05 3.11e-15 2.26e+02 2300| 6.06e-06 6.42e-06 9.80e-04 3.12e-04 1.29e-03 8.79e-15 2.37e+02 2400| 5.02e-06 4.55e-06 1.14e-04 4.07e-04 2.93e-04 1.11e-14 2.47e+02 2500| 1.08e-05 9.33e-06 9.65e-05 1.25e-03 1.35e-03 9.50e-15 2.57e+02 2600| 2.63e-05 2.06e-05 2.72e-03 4.13e-03 6.88e-03 1.14e-14 2.67e+02 2700| 5.67e-06 4.68e-06 1.23e-04 -1.17e-04 6.24e-06 2.69e-14 2.78e+02 2800| 5.19e-06 4.87e-06 3.51e-04 7.82e-05 4.30e-04 1.11e-14 2.88e+02 2900| 6.07e-06 5.66e-06 5.06e-05 -1.05e-04 -1.55e-04 9.22e-15 2.98e+02 3000| 4.78e-06 3.70e-06 1.16e-03 -2.16e-04 9.48e-04 2.63e-14 3.08e+02 3100| 1.80e-06 1.50e-06 3.74e-04 5.71e-05 -3.17e-04 3.64e-15 3.18e+02 3200| 7.36e-12 6.15e-12 3.89e-10 -3.53e-11 -4.24e-10 3.96e-15 3.29e+02 3204| 3.61e-13 2.95e-13 9.02e-11 1.22e-11 -7.80e-11 7.20e-16 3.29e+02 ---------------------------------------------------------------------------- Status: Solved Timing: Solve time: 3.29e+02s Lin-sys: nnz in L factor: 28748612, avg solve time: 9.36e-02s Cones: avg projection time: 3.30e-03s Acceleration: avg step time: 4.10e-03s ---------------------------------------------------------------------------- Error metrics: dist(s, K) = 1.1395e-09, dist(y, K*) = 2.0661e-09, s'y/|s||y| = -7.6432e-14 primal res: |Ax + s - b|_2 / (1 + |b|_2) = 3.6127e-13 dual res: |A'y + c|_2 / (1 + |c|_2) = 2.9493e-13 rel gap: |c'x + b'y| / (1 + |c'x| + |b'y|) = 9.0154e-11 ---------------------------------------------------------------------------- c'x = 0.0000, -b'y = -0.0000 ============================================================================ status = MathOptInterface.OPTIMAL NOTE: if `status = ALMOST_OPTIMAL`, you may need to re-run the cell above. It seems that solver obtained sum of squares decomposition for $\operatorname{Adj}_4 + 100.0\operatorname{Op}_4 - 0.1\Delta_4$ with $\lambda$: ```julia λ₄ = value(SDP_problem[:λ]) ``` 0 . 0 9 9 9 9 9 9 9 9 9 8 7 8 2 1 6 6 To apply the `SOS_residual` function we need to reconstruct matrix `Q` from the semipositive-definite blocks in `SDP_problem`: ```julia Q₄ = let Ps = [value.(P) for P in varP], bd = block_decomposition Qs = real.(sqrt.(Ps)); PropertyT.reconstruct(Qs, block_decomposition); end ``` 1777×1777 Array{Float64,2}: 73.6668 -3.53685 -3.53685 … 0.042403 0.052693 -3.53685 20.088 -0.672753 -0.00720344 -0.0118432 -3.53685 -0.672753 20.088 -0.0412075 4.17635e-5 -3.53685 -0.672753 -0.672753 0.0136568 0.00637814 -3.53685 -0.909577 -0.399332 0.00507484 -0.0118432 -3.53685 -0.399332 -0.431527 … -0.000939495 4.17635e-5 -3.53685 -0.399332 1.35135 0.000623127 0.00637814 -3.53685 -0.399332 -0.909577 0.00937818 -0.000377992 -3.53685 -0.431527 -0.399332 0.00280739 -0.000377992 -3.53685 1.35135 -0.399332 0.00367772 0.00719231 -3.53685 -0.399332 -0.399332 … 0.0318183 0.00811301 -3.53685 -0.431527 1.35135 -0.00728109 0.00811301 -3.53685 1.35135 -0.431527 0.00512306 0.00785316 ⋮ ⋱ ⋮ -0.0181961 0.00308358 0.00426268 … -0.012201 -0.01126 0.00609812 0.00547639 -0.00683407 0.00421675 0.00893611 0.00609812 -0.000991355 -0.00105234 -0.0323998 0.00893611 -0.0179306 -0.00174578 -0.000656216 -0.0022567 -0.012395 -0.0167704 -0.021978 -0.00857865 0.0290574 0.0019202 -0.0167704 -0.0122136 -0.00147366 … -0.0116298 0.0019202 -0.0599944 -0.0119557 -0.0161813 -0.00655492 0.000431544 -0.0599944 -0.0123905 0.00256829 -0.0029705 0.000431544 -0.0195403 0.00735981 -0.000662284 -0.00319418 -0.0453741 0.042403 0.00507484 -0.000939495 0.000746334 0.0175979 0.042403 -0.00720344 -0.0412075 … 0.533857 0.0175979 0.052693 -0.0118432 4.17637e-5 0.0175979 0.16533 ```julia Q₄_aug, check_columns_augmentation = PropertyT.augIdproj(Interval, Q₄); @assert check_columns_augmentation ``` ```julia elt₄_int = elt₄ - @interval(λ₄)*Δ₄; residual₄_int = SOS_residual(elt₄_int, Q₄_aug) @show norm(residual₄_int, 1); λ₄_cert = @interval(λ₄) - 2*norm(residual₄_int, 1) @info "λ₄ is certified to be > " λ₄_cert.lo @info "i.e Adj₄ + $k·Op₄ - ($(λ₄_cert.lo))·Δ₄ ∈ Σ²₂ ISAut(F₄)" ``` 54.242839 seconds (40.43 k allocations: 80.632 MiB) norm(residual₄_int, 1) = [1.08665e-05, 1.09478e-05] ┌ Info: λ₄ is certified to be > │ λ₄_cert.lo = 0.09997810453347668 └ @ Main In[29]:5 ┌ Info: i.e Adj₄ + 100.0·Op₄ - (0.09997810453347668)·Δ₄ ∈ Σ²₂ ISAut(F₄) └ @ Main In[29]:6 ```julia now() ``` 2020-10-21T14:24:45.043
/* * Copyright 2009-2020 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * * 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. * */ #define BOOST_TEST_MAIN #define BOOST_TEST_MODULE qmnblist_test // Third party includes #include <boost/test/unit_test.hpp> // Local VOTCA includes #include "votca/xtp/qmnblist.h" using namespace votca::xtp; BOOST_AUTO_TEST_SUITE(qmnblist_test) BOOST_AUTO_TEST_CASE(constructors_test) { QMNBList qmnb; } BOOST_AUTO_TEST_CASE(add_pair) { Segment seg1("one", 1); Atom atm1(1, "C", Eigen::Vector3d::Ones()); seg1.push_back(atm1); Segment seg2("two", 2); Atom atm2(2, "C", -Eigen::Vector3d::Ones()); seg2.push_back(atm2); Segment seg3("three", 3); Atom atm3(3, "Ca", -Eigen::Vector3d::UnitX()); seg3.push_back(atm3); QMNBList qmnb; BOOST_CHECK_EQUAL(qmnb.empty(), true); qmnb.Add(seg1, seg3, 0.5 * Eigen::Vector3d::Ones()); qmnb.Add(seg1, seg2, -0.5 * Eigen::Vector3d::Ones()); BOOST_CHECK_EQUAL(qmnb.size(), 2); BOOST_CHECK_EQUAL(qmnb.empty(), false); QMPair* p0 = qmnb.FindPair(&seg1, &seg2); QMPair* p1 = qmnb.FindPair(&seg1, &seg3); BOOST_CHECK_EQUAL(p0->R().isApprox(-0.5 * Eigen::Vector3d::Ones(), 1e-5), true); BOOST_CHECK_EQUAL(p0->getId(), 1); BOOST_CHECK_EQUAL(p1->getId(), 0); // sort qmpairs by seg1id and then by seg2id then reindex the pair id // according to that. qmnb.sortAndReindex([](QMPair* a, QMPair* b) { if (a->Seg1()->getId() != b->Seg1()->getId()) { return a->Seg1()->getId() < b->Seg1()->getId(); } return a->Seg2()->getId() < b->Seg2()->getId(); }); BOOST_CHECK_EQUAL(p0->getId(), 0); BOOST_CHECK_EQUAL(p1->getId(), 1); votca::csg::PairList<const Segment*, QMPair>::partners* Partners = qmnb.FindPartners(&seg1); QMPair* p_ref0 = Partners->at(&seg2); QMPair* p_ref1 = Partners->at(&seg3); BOOST_CHECK_EQUAL(p_ref0, p0); BOOST_CHECK_EQUAL(p_ref1, p1); } BOOST_AUTO_TEST_SUITE_END()
= = = Other reactions = = =
\chapter*{RESUMEN} \addcontentsline{toc}{chapter}{RESUMEN}
He’s a funny little thing from Amanda Palmer. Be sure to play the video; it’s quite cute. Amusingly, I tried to find it on YouTube and it wouldn’t let me access it without an account because it had been flagged as “mature” by users. Really, what is so mature about this. It’s just a naked women. I really wish people would just get over it. Some neurotic person somewhere has a problem with the human body that affects the rest of us. I want to start flagging as offensive all those beer ads, car ads, makeup ads, and a million and one things that give a far more damaging message to children than this cute, funny video.
module Markdown.String import Data.Nat import Text.Lexer import Text.Quantity %default total export headingSym : Lexer headingSym = some (is '#') export imageSym : Lexer imageSym = is '!' export newLine : Lexer newLine = is '\n' export italicsSym : Lexer italicsSym = is '_' export boldSym : Lexer boldSym = count (exactly 2) (is '*') export link : Lexer link = surround (is '[') (is ']') any <+> surround (is '(') (is ')') any ||| Note: we currently don't allow attributes ||| To do so, we might need to move this from the lexer into the parser export htmlOpenTag : Lexer htmlOpenTag = surround (is '<') (is '>') alphaNum export htmlCloseTag : Lexer htmlCloseTag = surround (exact "</") (is '>') alphaNum export pre : Lexer pre = quote (is '`') (non newline) export codeFence : Lexer codeFence = quote (exact "```") any -- Grab the next non-newline character (even if it's special, like a *), -- and then consume non-special characters until we find another special marker. export text : Lexer text = (isNot '\n') <+> manyUntil (oneOf "_*\n<>#[]()`") any
Formal statement is: lemma homeomorphism_compose: assumes "homeomorphism S T f g" "homeomorphism T U h k" shows "homeomorphism S U (h o f) (g o k)" Informal statement is: If $f$ is a homeomorphism from $S$ to $T$ and $h$ is a homeomorphism from $T$ to $U$, then $h \circ f$ is a homeomorphism from $S$ to $U$.
From iris_ni.program_logic Require Export dwp. From iris.proofmode Require Import proofmode. Set Default Proof Using "Type". Section lifting. Context `{!irisDG Λ Σ, !invGS Σ}. Implicit Types v : val Λ. Implicit Types e : expr Λ. Implicit Types σ : state Λ. Implicit Types P Q : iProp Σ. Implicit Types Φ : val Λ → val Λ → iProp Σ. Lemma dwp_lift_pure_step `{Inhabited (state Λ)} E1 E1' Φ e1 e2 : (∀ σ1, reducible e1 σ1) → (∀ κ σ1 e1' σ1' efs1, prim_step e1 σ1 κ e1' σ1' efs1 → κ = [] ∧ σ1' = σ1) → (∀ σ2, reducible e2 σ2) → (∀ κ σ2 e2' σ2' efs2, prim_step e2 σ2 κ e2' σ2' efs2 → κ = [] ∧ σ2' = σ2) → (|={E1}[E1']▷=> ∀ κ1 κ2 e1' σ1 efs1 e2' σ2 efs2, ⌜prim_step e1 σ1 κ1 e1' σ1 efs1⌝ → ⌜prim_step e2 σ2 κ2 e2' σ2 efs2⌝ → dwp E1 e1' e2' Φ ∗ [∗ list] ef1;ef2 ∈ efs1;efs2, dwp ⊤ ef1 ef2 (λ _ _, True )) ⊢ dwp E1 e1 e2 Φ. Proof. iIntros (Hsafe1 Hdet1 Hsafe2 Hdet2) "H". rewrite (dwp_unfold _ e1 e2) /dwp_pre. assert (language.to_val e1 = None) as ->. { destruct (Hsafe1 inhabitant) as (?&?&?&?&?). eapply val_stuck; eauto. } assert (language.to_val e2 = None) as ->. { destruct (Hsafe2 inhabitant) as (?&?&?&?&?). eapply val_stuck; eauto. } iIntros (σ1 σ2 κ1 κs1 κ2 κs2) "Hrel". iMod "H" as "H". iMod fupd_mask_subseteq as "Hclose"; last iModIntro; first by set_solver. iSplit; first iPureIntro. { destruct (Hsafe1 σ1) as (xxx&?&?&?&Hst). assert (xxx = []) as ->. { by eapply Hdet1. } do 3 eexists. eauto. } iSplit; first iPureIntro. { destruct (Hsafe2 σ2) as (xxx&?&?&?&Hst). assert (xxx = []) as ->. { by eapply Hdet2. } do 3 eexists. eauto. } iIntros (e1' σ1' efs1 e2' σ2' efs2 Hstep1 Hstep2). iModIntro. iNext. iMod "Hclose" as "_". iMod "H" as "H". assert (σ1' = σ1) as ->. { eapply Hdet1. eauto. } assert (σ2' = σ2) as ->. { eapply Hdet2. eauto. } iSpecialize ("H" $! [] [] with "[//] [//]"). iModIntro. iFrame. Qed. Lemma dwp_lift_pure_det_step `{!Inhabited (state Λ)} {E1 E1' Φ} e1 e1' e2 e2' efs1 efs2 : (∀ σ1, reducible e1 σ1) → (∀ κ σ1 e1'' σ1' efs1', prim_step e1 σ1 κ e1'' σ1' efs1' → κ = [] ∧ σ1' = σ1 ∧ e1'' = e1' ∧ efs1' = efs1) → (∀ σ2, reducible e2 σ2) → (∀ κ σ2 e2'' σ2' efs2', prim_step e2 σ2 κ e2'' σ2' efs2' → κ = [] ∧ σ2' = σ2 ∧ e2'' = e2' ∧ efs2' = efs2) → (|={E1}[E1']▷=> dwp E1 e1' e2' Φ ∗ [∗ list] ef1;ef2 ∈ efs1;efs2, dwp ⊤ ef1 ef2 (λ _ _, True )) ⊢ dwp E1 e1 e2 Φ. Proof. iIntros (? Hpuredet1 ? Hpuredet2) "H". iApply dwp_lift_pure_step; try done. { intros. split; by eapply Hpuredet1. } { intros. split; by eapply Hpuredet2. } iApply (step_fupd_wand with "H"); iIntros "H". iIntros (? ? ? ? ? ? ? ?). iIntros ((->&_&->&->)%Hpuredet1 (->&_&->&->)%Hpuredet2). iApply "H". Qed. Lemma dwp_pure_step_fupd `{!Inhabited (state Λ)} E1 E1' n e1 e1' e2 e2' φ1 φ2 Φ : PureExec φ1 n e1 e1' → PureExec φ2 n e2 e2' → φ1 → φ2 → Nat.iter n (λ P, |={E1}[E1']▷=> P) (dwp E1 e1' e2' Φ) ⊢ dwp E1 e1 e2 Φ. Proof. iIntros (Hexec1 Hexec2 Hφ1 Hφ2) "H". specialize (Hexec1 Hφ1). specialize (Hexec2 Hφ2). iInduction Hexec1 as [e1|n e1 e1' e1'' [Hsafe1 ?]] "IH" forall (e2 e2' Hexec2); simpl; simpl in Hexec2. - by inversion Hexec2. - inversion Hexec2 as [|m t2 t2' e2'' [Hsafe2 ?]]. simplify_eq/=. iApply dwp_lift_pure_det_step. + eauto using reducible_no_obs_reducible. + intros σ1 κ e1_ σ1' efs1' Hstep. specialize (pure_step_det _ _ _ _ _ Hstep). naive_solver. + eauto using reducible_no_obs_reducible. + intros σ1 κ e1_ σ1' efs1' Hstep. specialize (pure_step_det0 _ _ _ _ _ Hstep). naive_solver. + iApply (step_fupd_wand with "H"). rewrite big_sepL2_nil. iIntros "H". iSplitL; last done. by iApply "IH". Qed. Lemma dwp_pure_step_later `{!Inhabited (state Λ)} E1 e1 e1' e2 e2' n φ1 φ2 Φ : PureExec φ1 n e1 e1' → PureExec φ2 n e2 e2' → φ1 → φ2 → ▷^n (dwp E1 e1' e2' Φ) ⊢ dwp E1 e1 e2 Φ. Proof. intros Hexec1 Hexec2 ??. rewrite -(dwp_pure_step_fupd E1 E1) //. clear Hexec1 Hexec2. induction n=>// /=. by rewrite -(step_fupd_intro E1 E1)// IHn. Qed. End lifting.
inductive Term | Var (i : Nat) | Cons (l : Term) (r : Term) def Subst := Nat → Nat def depth : Term → Nat | .Var _ => 0 | .Cons l r => 1 + depth l + depth r def act (f : Subst) (t : Term) := match t with | .Var i => Term.Var (f i) | .Cons l r => Term.Cons (act f l) (act f r) def strangers (u v : Term) := ∀ f : Subst, act f u ≠ act f v abbrev P (c : Option Subst) u v := match c with | none => strangers u v | some f => act f u = act f v def rel : WellFoundedRelation (Term × Term) := measure (λ (u, v) => depth u + depth v) theorem decr_left (l₁ r₁ l₂ r₂ : Term) : rel.rel (l₁, l₂) (Term.Cons l₁ r₁, Term.Cons l₂ r₂) := by suffices h : depth l₁ + depth l₂ < depth (Term.Cons l₁ r₁) + depth (Term.Cons l₂ r₂) from h admit theorem decr_right (l₁ r₁ l₂ r₂ : Term) (f : Subst) : rel.rel (act f r₁, act f r₂) (Term.Cons l₁ r₁, Term.Cons l₂ r₂) := by suffices h : depth (act f r₁) + depth (act f r₂) < depth (Term.Cons l₁ r₁) + depth (Term.Cons l₂ r₂) from h admit def robinson (u v : Term) : { f : Option Subst // P f u v } := match u, v with | .Cons l₁ r₁, .Cons l₂ r₂ => match robinson l₁ l₂ with | ⟨ none, h ⟩ => ⟨ none, sorry ⟩ | ⟨ some f, h ⟩ => match robinson (act f r₁) (act f r₂) with | ⟨ none, h ⟩ => ⟨ none, sorry ⟩ | ⟨ some g, h ⟩ => ⟨ some (g ∘ f), sorry ⟩ | .Var i, .Cons l r => ⟨ none, sorry ⟩ | .Cons l r, .Var i => ⟨ none, sorry ⟩ | .Var i, .Var j => if i = j then ⟨ some id, sorry ⟩ else ⟨ some λ n => if n = i then j else n, sorry ⟩ termination_by' invImage (λ ⟨ u, v ⟩ => (u, v)) rel decreasing_by first | apply decr_left _ _ _ _ | apply decr_right _ _ _ _ _ attribute [simp] robinson set_option pp.proofs true #check robinson._eq_1 #check robinson._eq_2 #check robinson._eq_3 #check robinson._eq_4 theorem ex : (robinson (Term.Var 0) (Term.Var 0)).1 = some id := by unfold robinson admit
# Read a set of vectors stored in the bvec format (int + n * float) # The function returns a set of output uint8 vector (one vector per column) # # Syntax: # v = fvecs_read (filename) -> read all vectors # v = fvecs_read (filename, n) -> read n vectors # v = fvecs_read (filename, [a b]) -> read the vectors from a to b (indices starts from 1) function fvecs_read( bounds::UnitRange, filename::AbstractString="./data/deep/deep10M.fvecs") @assert bounds.start >= 1 # open the file and count the number of descriptors open(filename, "r") do fid # Read the vector size d = read(fid, Int32, 1) @assert length(d) == 1 @show vecsizeof = 1 * 4 + d[1] * 4 # Get the number of vectrors seekend(fid) vecnum = position(fid) / vecsizeof # compute the number of vectors that are really read and go in starting positions @show n = bounds.stop - bounds.start + 1 seekstart(fid) skip(fid, (bounds.start - 1) * vecsizeof) # read n vectors v = read(fid, Float32, (d[1] + 1) * n) v = reshape(v, d[1] + 1, n) # Check if the first column (dimension of the vectors) is correct @assert sum( v[1,2:end] .== v[1, 1]) == n - 1 v = v[2:end, :] return v end end function fvecs_read(n::Integer, filename::AbstractString) return fvecs_read(1:n,filename) end function fvecs_read(n::Integer) return fvecs_read(1:n) end
[STATEMENT] lemma midpoint_collinear: fixes a b c :: "'a::real_normed_vector" assumes "a \<noteq> c" shows "b = midpoint a c \<longleftrightarrow> collinear{a,b,c} \<and> dist a b = dist b c" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (b = midpoint a c) = (collinear {a, b, c} \<and> dist a b = dist b c) [PROOF STEP] proof - [PROOF STATE] proof (state) goal (1 subgoal): 1. (b = midpoint a c) = (collinear {a, b, c} \<and> dist a b = dist b c) [PROOF STEP] have *: "a - (u *\<^sub>R a + (1 - u) *\<^sub>R c) = (1 - u) *\<^sub>R (a - c)" "u *\<^sub>R a + (1 - u) *\<^sub>R c - c = u *\<^sub>R (a - c)" "\<bar>1 - u\<bar> = \<bar>u\<bar> \<longleftrightarrow> u = 1/2" for u::real [PROOF STATE] proof (prove) goal (1 subgoal): 1. a - (u *\<^sub>R a + (1 - u) *\<^sub>R c) = (1 - u) *\<^sub>R (a - c) &&& u *\<^sub>R a + (1 - u) *\<^sub>R c - c = u *\<^sub>R (a - c) &&& (\<bar>1 - u\<bar> = \<bar>u\<bar>) = (u = 1 / 2) [PROOF STEP] by (auto simp: algebra_simps) [PROOF STATE] proof (state) this: a - (?u *\<^sub>R a + (1 - ?u) *\<^sub>R c) = (1 - ?u) *\<^sub>R (a - c) ?u *\<^sub>R a + (1 - ?u) *\<^sub>R c - c = ?u *\<^sub>R (a - c) (\<bar>1 - ?u\<bar> = \<bar>?u\<bar>) = (?u = 1 / 2) goal (1 subgoal): 1. (b = midpoint a c) = (collinear {a, b, c} \<and> dist a b = dist b c) [PROOF STEP] have "b = midpoint a c \<Longrightarrow> collinear{a,b,c}" [PROOF STATE] proof (prove) goal (1 subgoal): 1. b = midpoint a c \<Longrightarrow> collinear {a, b, c} [PROOF STEP] using collinear_midpoint [PROOF STATE] proof (prove) using this: collinear {?a, midpoint ?a ?b, ?b} goal (1 subgoal): 1. b = midpoint a c \<Longrightarrow> collinear {a, b, c} [PROOF STEP] by blast [PROOF STATE] proof (state) this: b = midpoint a c \<Longrightarrow> collinear {a, b, c} goal (1 subgoal): 1. (b = midpoint a c) = (collinear {a, b, c} \<and> dist a b = dist b c) [PROOF STEP] moreover [PROOF STATE] proof (state) this: b = midpoint a c \<Longrightarrow> collinear {a, b, c} goal (1 subgoal): 1. (b = midpoint a c) = (collinear {a, b, c} \<and> dist a b = dist b c) [PROOF STEP] have "b = midpoint a c \<longleftrightarrow> dist a b = dist b c" if "collinear{a,b,c}" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (b = midpoint a c) = (dist a b = dist b c) [PROOF STEP] proof - [PROOF STATE] proof (state) goal (1 subgoal): 1. (b = midpoint a c) = (dist a b = dist b c) [PROOF STEP] consider "a = c" | u where "b = u *\<^sub>R a + (1 - u) *\<^sub>R c" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>a = c \<Longrightarrow> thesis; \<And>u. b = u *\<^sub>R a + (1 - u) *\<^sub>R c \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis [PROOF STEP] using \<open>collinear {a,b,c}\<close> [PROOF STATE] proof (prove) using this: collinear {a, b, c} goal (1 subgoal): 1. \<lbrakk>a = c \<Longrightarrow> thesis; \<And>u. b = u *\<^sub>R a + (1 - u) *\<^sub>R c \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis [PROOF STEP] unfolding collinear_3_expand [PROOF STATE] proof (prove) using this: a = c \<or> (\<exists>u. b = u *\<^sub>R a + (1 - u) *\<^sub>R c) goal (1 subgoal): 1. \<lbrakk>a = c \<Longrightarrow> thesis; \<And>u. b = u *\<^sub>R a + (1 - u) *\<^sub>R c \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis [PROOF STEP] by blast [PROOF STATE] proof (state) this: \<lbrakk>a = c \<Longrightarrow> ?thesis; \<And>u. b = u *\<^sub>R a + (1 - u) *\<^sub>R c \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis goal (1 subgoal): 1. (b = midpoint a c) = (dist a b = dist b c) [PROOF STEP] then [PROOF STATE] proof (chain) picking this: \<lbrakk>a = c \<Longrightarrow> ?thesis; \<And>u. b = u *\<^sub>R a + (1 - u) *\<^sub>R c \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) using this: \<lbrakk>a = c \<Longrightarrow> ?thesis; \<And>u. b = u *\<^sub>R a + (1 - u) *\<^sub>R c \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis goal (1 subgoal): 1. (b = midpoint a c) = (dist a b = dist b c) [PROOF STEP] proof cases [PROOF STATE] proof (state) goal (2 subgoals): 1. a = c \<Longrightarrow> (b = midpoint a c) = (dist a b = dist b c) 2. \<And>u. b = u *\<^sub>R a + (1 - u) *\<^sub>R c \<Longrightarrow> (b = midpoint a c) = (dist a b = dist b c) [PROOF STEP] case 2 [PROOF STATE] proof (state) this: b = u *\<^sub>R a + (1 - u) *\<^sub>R c goal (2 subgoals): 1. a = c \<Longrightarrow> (b = midpoint a c) = (dist a b = dist b c) 2. \<And>u. b = u *\<^sub>R a + (1 - u) *\<^sub>R c \<Longrightarrow> (b = midpoint a c) = (dist a b = dist b c) [PROOF STEP] with assms [PROOF STATE] proof (chain) picking this: a \<noteq> c b = u *\<^sub>R a + (1 - u) *\<^sub>R c [PROOF STEP] have "dist a b = dist b c \<Longrightarrow> b = midpoint a c" [PROOF STATE] proof (prove) using this: a \<noteq> c b = u *\<^sub>R a + (1 - u) *\<^sub>R c goal (1 subgoal): 1. dist a b = dist b c \<Longrightarrow> b = midpoint a c [PROOF STEP] by (simp add: dist_norm * midpoint_def scaleR_add_right del: divide_const_simps) [PROOF STATE] proof (state) this: dist a b = dist b c \<Longrightarrow> b = midpoint a c goal (2 subgoals): 1. a = c \<Longrightarrow> (b = midpoint a c) = (dist a b = dist b c) 2. \<And>u. b = u *\<^sub>R a + (1 - u) *\<^sub>R c \<Longrightarrow> (b = midpoint a c) = (dist a b = dist b c) [PROOF STEP] then [PROOF STATE] proof (chain) picking this: dist a b = dist b c \<Longrightarrow> b = midpoint a c [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) using this: dist a b = dist b c \<Longrightarrow> b = midpoint a c goal (1 subgoal): 1. (b = midpoint a c) = (dist a b = dist b c) [PROOF STEP] by (auto simp: dist_midpoint) [PROOF STATE] proof (state) this: (b = midpoint a c) = (dist a b = dist b c) goal (1 subgoal): 1. a = c \<Longrightarrow> (b = midpoint a c) = (dist a b = dist b c) [PROOF STEP] qed (use assms in auto) [PROOF STATE] proof (state) this: (b = midpoint a c) = (dist a b = dist b c) goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: collinear {a, b, c} \<Longrightarrow> (b = midpoint a c) = (dist a b = dist b c) goal (1 subgoal): 1. (b = midpoint a c) = (collinear {a, b, c} \<and> dist a b = dist b c) [PROOF STEP] ultimately [PROOF STATE] proof (chain) picking this: b = midpoint a c \<Longrightarrow> collinear {a, b, c} collinear {a, b, c} \<Longrightarrow> (b = midpoint a c) = (dist a b = dist b c) [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) using this: b = midpoint a c \<Longrightarrow> collinear {a, b, c} collinear {a, b, c} \<Longrightarrow> (b = midpoint a c) = (dist a b = dist b c) goal (1 subgoal): 1. (b = midpoint a c) = (collinear {a, b, c} \<and> dist a b = dist b c) [PROOF STEP] by blast [PROOF STATE] proof (state) this: (b = midpoint a c) = (collinear {a, b, c} \<and> dist a b = dist b c) goal: No subgoals! [PROOF STEP] qed
State Before: R : Type u_1 S : Type ?u.170489 M : Type u_2 inst✝⁶ : Semiring R inst✝⁵ : Semiring S inst✝⁴ : AddCommMonoid M inst✝³ : Module R M inst✝² : Module S M inst✝¹ : SMul S R inst✝ : IsScalarTower S R M p✝ q p p' : Submodule R M ⊢ (∀ (x : M), x ∈ p ∧ x ∈ p' → x ∈ {0}) ↔ ∀ (x : M), x ∈ p → x ∈ p' → x = 0 State After: no goals Tactic: simp
# Tutorial 4 - Pressure vs Temperature Surfinpy has the functionality to generate phase diagrams as a function of pressure vs temperature based upon the methodology used in Molinari et al. (J. Phys. Chem. C 116, 12, 7073-7082) according to \begin{align} \gamma_{adsorbed, T, P} & = \gamma_{bare} + ( C ( E_{ads, T} - RTln(\frac{p}{p^o}) \end{align} where $\gamma_{adsorbed, T, p}$ is the surface energy of the surface with adsorbed species at temperature (T) and pressure (P), $\gamma_{bare}$ is the suface energy of the bare surface, C is the coverage of adsorbed species, $E_{ads}$ is the adsorption energy, \begin{align} E_{ads, T} & = E_{slab, adsorbant} - (E_{slab, bare} + n_{H_2O} E_{H_2O, T}) / n_{H_2O} \end{align} where $E_{slab, adsorbant}$ is the energy of the surface and the adsorbed species, $n_{H_2O}$ is he number of adsorbed species, \begin{align} E_{H_2O, (T)} & = E_{H_2O, (g)} - TS_{(T)} \end{align} where $S_{(T)}$ is the experimental entropy of gaseous water in the standard state. So let's look at this in action. The module used is called p_vs_t ```python import matplotlib.pyplot as plt from surfinpy import utils as ut from surfinpy import p_vs_t from surfinpy import data ``` There are a number of user inputs that are required, the inputs are similiar to mu_vs_mu but with some small differences. First we need the energy from DFT of the adsorbant (eV), the energy of the surface ($j_m^2$) and the data for each surface. For clarity, in the `surfinpy.data.DataSet` objects for each surface it is always assumed that the adsorbing species is 'Y'. ```python adsorbant = -14.00 ``` ```python SE = 1.40 ``` ```python stoich = data.DataSet(cation = 24, x = 48, y = 0, area = 60.22, energy = -575.00, label = 'Bare') H2O = data.DataSet(cation = 24, x = 48, y = 2, area = 60.22, energy = -605.00, label = '1 Water') H2O_2 = data.DataSet(cation = 24, x = 48, y = 8, area = 60.22, energy = -695.00, label = '2 Water') ``` ```python data = [H2O, H2O_2] ``` The coverage of the adsorbing species (in this case water) is also needed. surfinpy has a built in function within the utils module to do this for you, it takes the number of adsorbing species and the surface area and calculates the coverage for you. ```python cov = ut.calculate_coverage(data) ``` We need the thermochemical data for the adsorbed species in order to make the DFT energy of our adsorbing species a temperature dependent term. This data has been taken directly from the NIST Janaf database and has been cut to just include the temperature and S values within the temperature range that interests us (In this case 0 - 1000 K). ```python thermochem = ut.read_nist("H2O.txt") ``` Now we can generate our phase diagram . ```python system = p_vs_t.calculate(stoich, data, SE, adsorbant, thermochem, coverage=cov) ax = system.plot(colourmap='Spectral', figsize=(6, 4), ylabel='$log_{10} (P_{H_2O})$') plt.savefig("../../../docs/source/Figures/Surfaces_7.png", dpi=600) plt.show() ``` ```python ```
############################################################################# #### ## #W anupqios.gi ANUPQ package Greg Gamble ## ## This file installs core functions used with iostreams. ## #Y Copyright (C) 2001 Lehrstuhl D fuer Mathematik, RWTH Aachen, Germany ## ############################################################################# ## #F PQ_START( <workspace>, <setupfile> ) . . . open a stream for a pq process ## ## ensures the images file written by the `pq' binary when in the Standard ## Presentation menu is empty, opens an io stream to a `pq' process (if ## <setupfile> is `fail') or a file stream for a setup file (if <setupfile> ## is a filename i.e. a string) and returns a record with fields `menu' ## (current menu for the `pq' binary), `opts' (the runtime switches used by ## the `pq' process), `workspace' (the value of <workspace> which should be ## a positive integer), and `stream' (the io or file stream opened). ## InstallGlobalFunction(PQ_START, function( workspace, setupfile ) local opts, iorec, topqlogfile; PrintTo(ANUPQData.SPimages, ""); #to ensure it's empty if setupfile = fail then opts := [ "-G" ]; else opts := [ "-i", "-k", "-g" ]; fi; if workspace <> 10000000 then Append( opts, [ "-s", String(workspace) ] ); fi; iorec := rec( menu := "SP", opts := opts, workspace := workspace ); if setupfile = fail then iorec.stream := InputOutputLocalProcess( ANUPQData.tmpdir, ANUPQData.binary, opts ); if iorec.stream = fail then Error( "failed to launch child process" ); fi; # menus are flushed at InfoANUPQ level 6, prompts at level 5 FLUSH_PQ_STREAM_UNTIL(iorec.stream, 6, 5, PQ_READ_NEXT_LINE, IS_PQ_PROMPT); else iorec.stream := OutputTextFile(setupfile, false); iorec.setupfile := setupfile; ToPQk(iorec, [], [ "#call pq with flags: '", JoinStringsWithSeparator(opts, " "), "'" ]); fi; return iorec; end ); ############################################################################# ## #F PqStart(<G>,<workspace> : <options>) . Initiate interactive ANUPQ session #F PqStart(<G> : <options>) #F PqStart(<workspace> : <options>) #F PqStart( : <options>) ## ## activate an iostream for an interactive {\ANUPQ} process (i.e. `PqStart' ## starts up a `pq' binary process and opens a {\GAP} iostream to ``talk'' ## to that process) and returns an integer <i> that can be used to identify ## that process. The argument <G>, if given, should be an *fp group* or *pc ## group* that the user intends to manipute using interactive {\ANUPQ} ## functions. If `PqStart' is given an integer argument <workspace> then the ## `pq' binary is started up with a workspace (an integer array) of size ## <workspace> (i.e. $4 \times <workspace>$ bytes in a 32-bit environment); ## otherwise, the `pq' binary sets a default workspace of $10000000$. ## ## The only <options> currently recognised by `PqStart' are `Prime' and ## `Exponent' (see~"Pq" for details) and if provided they are essentially ## global for the interactive {\ANUPQ} process, except that any interactive ## function interacting with the process and passing new values for these ## options will over-ride the global values. ## InstallGlobalFunction(PqStart, function(arg) local opts, iorec, procId, G, workspace, optname; if 2 < Length(arg) then Error("at most two arguments expected.\n"); fi; if not IsEmpty(arg) and IsGroup( arg[1] ) then G := arg[1]; if not( IsFpGroup(G) or IsPcGroup(G) ) then Error( "argument <G> should be an fp group or a pc group\n" ); fi; arg := arg{[2 .. Length(arg)]}; fi; if not IsEmpty(arg) then workspace := arg[1]; if not IsPosInt(workspace) then Error("argument <workspace> should be a positive integer.\n"); fi; else workspace := 10000000; fi; iorec := PQ_START( workspace, fail ); if IsBound( G ) then iorec.group := G; fi; iorec.calltype := "interactive"; for optname in ANUPQGlobalOptions do VALUE_PQ_OPTION(optname, iorec); od; procId := Length(ANUPQData.io) + 1; iorec.procId := procId; ANUPQData.io[ procId ] := iorec; return procId; end); ############################################################################# ## #F PqQuit( <i> ) . . . . . . . . . . . . Close an interactive ANUPQ session #F PqQuit() ## ## closes the stream of the <i>th or default interactive {\ANUPQ} process ## and unbinds its `ANUPQData.io' record. ## InstallGlobalFunction(PqQuit, function(arg) local ioIndex; ioIndex := ANUPQ_IOINDEX(arg); # No need to bother about descending through the menus. CloseStream(ANUPQData.io[ioIndex].stream); Unbind(ANUPQData.io[ioIndex]); end); ############################################################################# ## #F PqQuitAll() . . . . . . . . . . . . Close all interactive ANUPQ sessions ## ## closes the streams of all active interactive {\ANUPQ} process and unbinds ## their `ANUPQData.io' records. ## InstallGlobalFunction(PqQuitAll, function() local ioIndex; for ioIndex in [1 .. Length(ANUPQData.io)] do if IsBound(ANUPQData.io[ioIndex]) then CloseStream(ANUPQData.io[ioIndex].stream); Unbind(ANUPQData.io[ioIndex]); fi; od; end); ############################################################################# ## #F ANUPQ_IOINDEX . . . . the number identifying an interactive ANUPQ session ## ## returns the index of the record in the `ANUPQData.io' list corresponding ## to an interactive {\ANUPQ} session. With no argument the first bound ## index in `ANUPQData.io' is returned. With integer (first) argument <i>, ## <i> is returned if `ANUPQData.io[<i>]' is bound. ## InstallGlobalFunction(ANUPQ_IOINDEX, function(arglist) local ioIndex; if IsEmpty(arglist) then # Find the first bound ioIndex ioIndex := 1; while not(IsBound(ANUPQData.io[ioIndex])) and ioIndex < Length(ANUPQData.io) do ioIndex := ioIndex + 1; od; if IsBound(ANUPQData.io[ioIndex]) then return ioIndex; else Info(InfoANUPQ + InfoWarning, 1, "No interactive ANUPQ sessions are currently active"); return fail; fi; elif IsBound(ANUPQData.io[ arglist[1] ]) then return arglist[1]; else Error("no such interactive ANUPQ session\n"); fi; end); ############################################################################# ## #F ANUPQ_IOINDEX_ARG_CHK . Checks ANUPQ_IOINDEX has the right no. of arg'ts ## InstallGlobalFunction(ANUPQ_IOINDEX_ARG_CHK, function(arglist) if Length(arglist) > 1 then Info(InfoANUPQ + InfoWarning, 1, "Expected 0 or 1 arguments, all but first argument ignored"); fi; end); ############################################################################# ## #F ANUPQDataRecord([<i>]) . . . . . . . returns the data record of a process ## InstallGlobalFunction(ANUPQDataRecord, function( arg ) if not IsEmpty(arg) and arg[1] = 0 and IsBound( ANUPQData.ni ) then return ANUPQData.ni; else return ANUPQData.io[ CallFuncList(PqProcessIndex, arg) ]; fi; end); ############################################################################# ## #F PqProcessIndex( <i> ) . . . . . . . . . . . User version of ANUPQ_IOINDEX #F PqProcessIndex() ## ## If given (at least) one integer argument `PqProcessIndex' returns its ## first argument if it corresponds to an active interactive process or ## raises an error; otherwise, with no arguments, it returns the default ## active interactive process. If the user provides more than one argument ## then all arguments other than the first argument are ignored (and a ## warning is issued to `Info' at `InfoANUPQ' or `InfoWarning' level 1). ## InstallGlobalFunction(PqProcessIndex, function(arg) ANUPQ_IOINDEX_ARG_CHK(arg); return ANUPQ_IOINDEX(arg); end); ############################################################################# ## #F PqProcessIndices() . . . . the list of active interactive ANUPQ processes ## ## returns the list of (integer) indices of all active interactive {\ANUPQ} ## processes. ## InstallGlobalFunction(PqProcessIndices, function() return Filtered( [1..Length(ANUPQData.io)], i -> IsBound( ANUPQData.io[i] ) ); end); ############################################################################# ## #F IsPqProcessAlive( <i> ) . . checks an interactive ANUPQ process iostream #F IsPqProcessAlive() ## ## return `true' if the {\GAP} iostream of the <i>th (or default) ## interactive {\ANUPQ} process is alive (i.e. can still be written to), or ## `false', otherwise. ## InstallGlobalFunction(IsPqProcessAlive, function(arg) return not IsEndOfStream( ANUPQData.io[ PqProcessIndex(arg) ].stream ); end); ############################################################################# ## #V PQ_MENUS . . . . . . . . . . . data describing the menus of the pq binary ## ## a record whose fields are abbreviated names of the menus of the `pq' ## binary and whose values are themselves records with fields: ## ## name ## long name of menu; ## depth ## the number of times 0 must be passed to the `pq' binary for it to ## exit; ## prev ## the menu one gets to from the current menu via option 0 (or `""' in ## the case of the menu `SP'; ## nextopt ## a record whose fields are the new menus of greater depth that can ## be reached by an option of the current menu, and whose values are ## the corresponding numbers of the options of the current menu needed ## to get to the new menus. ## InstallValue(PQ_MENUS, rec( SP := rec( name := "Standard Presentation Menu", depth := 1, prev := "", nextopt := rec( pQ := 7 ) ), pQ := rec( name := "(Main) p-Quotient Menu", depth := 2, prev := "SP", nextopt := rec( pG := 9, ApQ := 8 ) ), pG := rec( name := "(Main) p-Group Generation Menu", depth := 3, prev := "pQ", nextopt := rec( ApG := 6 ) ), ApQ := rec( name := "Advanced p-Quotient Menu", depth := 3, prev := "pQ", nextopt := rec() ), ApG := rec( name := "Advanced p-Group Gen'n Menu", depth := 4, prev := "pG", nextopt := rec() ) ) ); ############################################################################# ## #F PQ_MENU( <datarec>, <newmenu> ) . . . . . . change/get menu of pq process #F PQ_MENU( <datarec> ) ## InstallGlobalFunction(PQ_MENU, function(arg) local datarec, newmenu, nextmenu, tomenu, infolev; datarec := arg[1]; if 2 = Length(arg) then newmenu := arg[2]; if datarec.menu in ["SP", "pQ"] and newmenu in ["ApQ", "pG", "ApG"] then PQ_GRP_EXISTS_CHK( datarec ); #We try to avoid seg-faults! fi; while datarec.menu <> newmenu do if PQ_MENUS.(datarec.menu).depth >= PQ_MENUS.(newmenu).depth then datarec.menu := PQ_MENUS.(datarec.menu).prev; tomenu := PQ_MENUS.(datarec.menu).name; ToPQk(datarec, [ 0 ], [ " #to ", tomenu]); infolev := 5; elif datarec.menu = "pQ" and newmenu = "ApQ" then datarec.menu := "ApQ"; tomenu := PQ_MENUS.(datarec.menu).name; ToPQk(datarec, [ PQ_MENUS.pQ.nextopt.ApQ ], [ " #to ", tomenu ]); infolev := 6; else nextmenu := RecNames( PQ_MENUS.(datarec.menu).nextopt )[1]; tomenu := PQ_MENUS.(nextmenu).name; ToPQk(datarec, [ PQ_MENUS.(datarec.menu).nextopt.(nextmenu) ], [ " #to ", tomenu ]); datarec.menu := nextmenu; infolev := 6; fi; # menus are flushed at InfoANUPQ level 6, prompts at level 5 if not IsBound(datarec.setupfile) then FLUSH_PQ_STREAM_UNTIL(datarec.stream, infolev, 5, PQ_READ_NEXT_LINE, IS_PQ_PROMPT); fi; od; fi; return datarec.menu; end); ############################################################################# ## #F IS_PQ_PROMPT( <line> ) . . . . checks whether the line is a prompt of pq ## ## returns `true' if the string <line> is a `pq' prompt, or otherwise ## returns `false'. ## InstallGlobalFunction(IS_PQ_PROMPT, line -> IS_ALL_PQ_LINE(line) and ANUPQData.linetype = "prompt" ); ############################################################################# ## #F IS_ALL_PQ_LINE( <line> ) . checks whether line is a complete line from pq ## ## returns `true' if the string <line> is a `pq' prompt or a request from ## `pq' to {\GAP} to compute stabilisers or simply ends in a newline and ## sets `ANUPQData.linetype' to `"prompt"', `"request"' or `"hasnewline"', ## accordingly; otherwise `ANUPQData.linetype' is set to `"unknown"' and ## `false' is returned. ## InstallGlobalFunction(IS_ALL_PQ_LINE, function( line ) local len; ANUPQData.linetype := "unknown"; len := Length(line); if 0 < len then if line[len] = '\n' then if 4 < len and line{[1 .. 3]} = "GAP" and line[len - 1] = '!' then ANUPQData.linetype := "request"; elif 6 < len and line{[1 .. 6]} in ["Enter ", "Input "] then ANUPQData.linetype := "prompt"; else ANUPQData.linetype := "hasnewline"; fi; elif line = "Select option: " or 1 < len and line{[len - 1 .. len]} = "? " or 8 < len and line{[len - 1 .. len]} = ": " and line{[1 .. 6]} in ["Enter ", "Input ", "Add ne"] then ANUPQData.linetype := "prompt"; fi; fi; return ANUPQData.linetype <> "unknown"; end); ############################################################################# ## #F PQ_READ_ALL_LINE( <iostream> ) . read line from pq but poss. return fail ## ## reads a complete line from <iostream> or return `fail'. ## InstallGlobalFunction(PQ_READ_ALL_LINE, iostream -> ReadAllLine(iostream, false, IS_ALL_PQ_LINE) ); ############################################################################# ## #F PQ_READ_NEXT_LINE( <iostream> ) . read line from pq but never return fail ## ## Essentially, like `PQ_READ_ALL_LINE' but we know there is a complete line ## to be got, so we wait for it, before returning. ## InstallGlobalFunction(PQ_READ_NEXT_LINE, iostream -> ReadAllLine(iostream, true, IS_ALL_PQ_LINE) ); ############################################################################# ## #F FLUSH_PQ_STREAM_UNTIL(<stream>,<infoLev>,<infoLevMy>,<readln>,<IsMyLine>) ## . . . . . . . . . . . . . . read lines from a stream until a wanted line ## ## calls <readln> (which should be one of `ReadLine', `PQ_READ_NEXT_LINE' or ## `PQ_READ_ALL_LINE') to read lines from a stream <stream> and `Info's each ## line read at `InfoANUPQ' level <infoLev> until a line <line> is read for ## which `<IsMyLine>(<line>)' is `true'; <line> is `Info'-ed at `InfoANUPQ' ## level <infoLevMy> and returned. <IsMyLine> should be a boolean-valued ## function that expects a string as its only argument, and <infoLev> and ## <infoLevMy> should be positive integers. An <infoLevMy> of 10 means that ## the line <line> matched by `<IsMyLine>(<line>)' should never be ## `Info'-ed. ## InstallGlobalFunction(FLUSH_PQ_STREAM_UNTIL, function(stream, infoLev, infoLevMy, readln, IsMyLine) local line; line := readln(stream); while not IsMyLine(line) do Info(InfoANUPQ, infoLev, Chomp(line)); line := readln(stream); od; if line <> fail and infoLevMy < 10 then Info(InfoANUPQ, infoLevMy, Chomp(line)); fi; return line; end); ############################################################################# ## #V PQ_ERROR_EXIT_MESSAGES . . . error messages emitted by the pq before exit ## ## A list of the error messages the `pq' emits just before exiting. ## InstallValue(PQ_ERROR_EXIT_MESSAGES, [ "Evaluation in compute_degree may cause integer overflow", "A relation is too long -- increase the value of MAXWORD", "Ran out of space during computation" ]); ############################################################################# ## #F FILTER_PQ_STREAM_UNTIL_PROMPT( <datarec> ) ## ## reads `pq' output from `<datarec>.stream' until a `pq' prompt and `Info's ## any lines that are prompts, blank lines, menu exits or start with the ## strings in the list `<datarec>.filter' (if bound) at `InfoANUPQ' level 5; ## all other lines are either `Info'-ed at `InfoANUPQ' level 3 if ## `datarec.nonuser' is set, or, more usually, are `Info'-ed at `InfoANUPQ' ## level 2 if they are computation times or at `InfoANUPQ' level 1, ## otherwise. ## InstallGlobalFunction(FILTER_PQ_STREAM_UNTIL_PROMPT, function( datarec ) local match, filter, lowlev, ctimelev; filter := ["Exiting", "pq,", "Now enter", "Presentation listing images", "(use generators x1,x2"]; if IsBound(datarec.match) then if datarec.match = true then match := ["Group:", "Group completed"]; else match := [datarec.match]; fi; fi; if IsBound(datarec.filter) then Append(filter, datarec.filter); fi; if ValueOption("nonuser") = true then lowlev := 3; ctimelev := 3; else ctimelev := 2; if not IsBound(datarec.OutputLevel) or datarec.OutputLevel = 0 then lowlev := 3; else lowlev := 1; fi; fi; repeat datarec.line := PQ_READ_NEXT_LINE(datarec.stream); if ANUPQData.linetype in ["prompt", "request"] then Info( InfoANUPQ, 5, Chomp(datarec.line) ); break; elif ForAny(["seconds", "Lused", "*** Final "], s -> PositionSublist(datarec.line, s) <> fail) then Info( InfoANUPQ, ctimelev, Chomp(datarec.line) ); elif datarec.line = "\n" or ForAny( filter, s -> IsMatchingSublist(datarec.line, s) ) then Info( InfoANUPQ, 5, Chomp(datarec.line) ); elif PositionSublist(datarec.line, " saved on file") <> fail then Info( InfoANUPQ, ctimelev, Chomp(datarec.line) ); elif ForAny( PQ_ERROR_EXIT_MESSAGES, s -> IsMatchingSublist(datarec.line, s) ) then Info( InfoANUPQ + InfoWarning, 1, Chomp(datarec.line) ); Error( "pq program terminated, with error condition:\n ", datarec.line ); else Info( InfoANUPQ, lowlev, Chomp(datarec.line) ); fi; if IsBound(match) then if ForAny( match, s -> IsMatchingSublist(datarec.line, s) ) then datarec.matchedline := datarec.line; datarec.complete := IsBound(datarec.complete) and datarec.complete or IsMatchingSublist(datarec.line, "Group completed"); fi; elif IsBound(datarec.matchlist) and ForAny( datarec.matchlist, s -> PositionSublist(datarec.line, s) <> fail ) then Add(datarec.matchedlines, datarec.line); fi; until false; end); ############################################################################# ## #F ToPQk( <datarec>, <cmd>, <comment> ) . . . . . . . writes to a pq stream ## ## writes <cmd> (and <comment>, in setup file case) to stream ## `<datarec>.stream' and `Info's <cmd> and <comment> at `InfoANUPQ' level 3 ## after a ```ToPQ> ''' prompt, and returns `true' if successful and `fail' ## otherwise. The ``k'' at the end of the function name is mnemonic for ## ``keyword'' (for ``keyword'' inputs to the `pq' binary one never wants to ## flush output). ## InstallGlobalFunction(ToPQk, function(datarec, cmd, comment) local ok, line, i, j, closed, fragment, sepchars, words, filterones; if not IsOutputTextStream(datarec.stream) and IsEndOfStream(datarec.stream) then Error("sorry! Process stream has died!\n"); fi; if cmd in ["gens", "rels"] then # these are done specially because of their potential to be enormously long if cmd = "gens" then line := "generators { "; sepchars := ", "; else line := "relators { "; sepchars := "*^, "; fi; words := datarec.(cmd); filterones := cmd = "rels" and not IsBound(datarec.Relators) and (IsFpGroup(datarec.group) or not IsPGroup(datarec.group)); i := 1; while filterones and i <= Length(words) and IsOne(words[i]) do i := i + 1; od; if i <= Length(words) then Append(line, String(words[i])); i := i + 1; fi; ok := true; closed := false; repeat while filterones and i <= Length(words) and IsOne(words[i]) do i := i + 1; od; # i is the index of the next word to be added to line or > #words if i <= Length(words) then # if number of non-trivial words is 0 or 1 no comma is ever added Append(line, ", "); Append(line, String(words[i])); i := i + 1; else Append(line, " }"); if cmd = "rels" then Append(line, ";"); fi; closed := true; # not quite equivalent to: i > Length(words) fi; while ok and (Length(line) >= 69 or (closed and Length(line) > 0)) do if Length(line) >= 69 then # find a nice break if we can j := 68; while j > 4 and not line[j] in sepchars do j := j - 1; od; # no nice break if j = 4 then j := 69; while j < Length(line) and not line[j] in sepchars do j := j + 1; od; fi; fragment := line{[1 .. j]}; else fragment := line; j := Length(line); fi; if j = Length(line) and closed then line := ""; else line := Concatenation(" ", line{[j + 1 .. Length(line)]}); fi; Info(InfoANUPQ, 4, "ToPQ> ", fragment); if IsBound( datarec.setupfile) then ok := WriteLine(datarec.stream, fragment); else ok := WriteLine(datarec.stream, fragment); if IsBound( ANUPQData.topqlogfile ) then WriteLine(ANUPQData.logstream, fragment); fi; fi; od; until closed or not ok; else # We add a null string in case <cmd> or <comment> is [] # ... so that `Concatenation( List(., String) );' statements return strings Add(cmd, ""); Add(comment, ""); cmd := Concatenation( List(cmd, String) ); comment := Concatenation( List(comment, String) ); Info(InfoANUPQ, 4, "ToPQ> ", cmd, comment); if IsBound( datarec.setupfile) then ok := WriteLine(datarec.stream, Concatenation(cmd, comment)); else ok := WriteLine(datarec.stream, cmd); if IsBound( ANUPQData.topqlogfile ) then WriteLine(ANUPQData.logstream, Concatenation(cmd, comment)); fi; fi; fi; if ok = fail then Error("write to stream failed\n"); fi; return ok; end); ############################################################################# ## #F ToPQ(<datarec>, <cmd>, <comment>) . . write to pq (& for iostream flush) ## ## calls `ToPQk' to write <cmd> (and <comment>, in setup file case) to ## stream `<datarec>.stream' and `Info' <cmd> and <comment> at `InfoANUPQ' ## level 3 after a ```ToPQ> ''' prompt, and then, if we are not just writing ## a setup file (determined by checking whether `<datarec>.setupfile' is ## bound), calls `FILTER_PQ_STREAM_UNTIL_PROMPT' to filter lines to `Info' ## at the various `InfoANUPQ' levels. If we are not writing a setup file the ## last line flushed is saved in `<datarec>.line'. ## InstallGlobalFunction(ToPQ, function(datarec, cmd, comment) ToPQk(datarec, cmd, comment); if not IsBound( datarec.setupfile ) then FILTER_PQ_STREAM_UNTIL_PROMPT(datarec); while ANUPQData.linetype = "request" do HideGlobalVariables( "ANUPQglb", "F", "gens", "relativeOrders", "ANUPQsize", "ANUPQagsize" ); Read( Filename( ANUPQData.tmpdir, "GAP_input" ) ); Read( Filename( ANUPQData.tmpdir, "GAP_rep" ) ); UnhideGlobalVariables( "ANUPQglb", "F", "gens", "relativeOrders", "ANUPQsize", "ANUPQagsize" ); ToPQk( datarec, [ "pq, stabiliser is ready!" ], [] ); FILTER_PQ_STREAM_UNTIL_PROMPT(datarec); od; fi; end); ############################################################################# ## #F ToPQ_BOOL( <datarec>, <optval>, <comment> ) . . . . pass a boolean to pq ## ## converts a {\GAP} boolean <optval> to a C boolean and appends the ## appropriate adjustment to the string <comment> before calling `ToPQ' (we ## assume that <optval> is boolean ... `VALUE_PQ_OPTION' should already have ## checked that). ## InstallGlobalFunction( ToPQ_BOOL, function( datarec, optval, comment ) if optval = true then ToPQ( datarec, [ 1 ], [ " #do ", comment ] ); else ToPQ( datarec, [ 0 ], [ " #do not ", comment ] ); fi; end); ############################################################################# ## #F PqRead( <i> ) . . . primitive read of a single line from ANUPQ iostream #F PqRead() ## ## read a complete line of {\ANUPQ} output, from the <i>th or default ## interactive {\ANUPQ} process, if there is output to be read and returns ## `fail' otherwise. When successful, the line is returned as a string ## complete with trailing newline, colon, or question-mark character. Please ## note that it is possible to be ``too quick'' (i.e.~the return can be ## `fail' purely because the output from {\ANUPQ} is not there yet), but if ## `PqRead' finds any output at all, it waits for a complete line. `PqRead' ## also writes the line read via `Info' at `InfoANUPQ' level 2. It doesn't ## try to distinguish banner and menu output from other output of the `pq' ## binary. ## InstallGlobalFunction(PqRead, function(arg) local line; line := PQ_READ_ALL_LINE( ANUPQData.io[ PqProcessIndex(arg) ].stream ); Info(InfoANUPQ, 2, Chomp(line)); return line; end); ############################################################################# ## #F PqReadAll( <i> ) . . . . . read all current output from an ANUPQ iostream #F PqReadAll() ## ## read and return as many *complete* lines of {\ANUPQ} output, from the ## <i>th or default interactive {\ANUPQ} process, as there are to be read, ## *at the time of the call*, as a list of strings with any trailing ## newlines removed and returns the empty list otherwise. `PqReadAll' also ## writes each line read via `Info' at `InfoANUPQ' level 2. It doesn't try ## to distinguish banner and menu output from other output of the `pq' ## binary. Whenever `PqReadAll' finds only a partial line, it waits for the ## complete line, thus increasing the probability that it has captured all ## the output to be had from {\ANUPQ}. ## InstallGlobalFunction(PqReadAll, function(arg) local lines, stream, line; stream := ANUPQData.io[ PqProcessIndex(arg) ].stream; lines := []; line := PQ_READ_ALL_LINE(stream); while line <> fail do line := Chomp(line); Info(InfoANUPQ, 2, line); Add(lines, line); line := PQ_READ_ALL_LINE(stream); od; return lines; end); ############################################################################# ## #F PqReadUntil( <i>, <IsMyLine> ) . read from ANUPQ iostream until a cond'n #F PqReadUntil( <IsMyLine> ) #F PqReadUntil( <i>, <IsMyLine>, <Modify> ) #F PqReadUntil( <IsMyLine>, <Modify> ) ## ## read complete lines of {\ANUPQ} output, from the <i>th or default ## interactive {\ANUPQ} process, ``chomps'' them (i.e.~removes any trailing ## newline character), emits them to `Info' at `InfoANUPQ' level 2 (without ## trying to distinguish banner and menu output from other output of the ## `pq' binary), and applies the function <Modify> (where <Modify> is just ## the identity map/function for the first two forms) until a ``chomped'' ## line <line> for which `<IsMyLine>( <Modify>(<line>) )' is true. ## `PqReadUntil' returns the list of <Modify>-ed ``chomped'' lines read. ## InstallGlobalFunction(PqReadUntil, function(arg) local idx1stfn, stream, IsMyLine, Modify, lines, line; idx1stfn := First([1..Length(arg)], i -> IsFunction(arg[i])); if idx1stfn = fail then Error("expected at least one function argument\n"); elif Length(arg) > idx1stfn + 1 then Error("expected 1 or 2 function arguments, not ", Length(arg) - idx1stfn + 1, "\n"); elif idx1stfn > 2 then Error("expected 0 or 1 integer arguments, not ", idx1stfn - 1, "\n"); else stream := ANUPQData.io[ ANUPQ_IOINDEX(arg{[1..idx1stfn - 1]}) ].stream; IsMyLine := arg[idx1stfn]; if idx1stfn = Length(arg) then Modify := line -> line; # The identity function else Modify := arg[Length(arg)]; fi; lines := []; repeat line := Chomp( PQ_READ_NEXT_LINE(stream) ); Info(InfoANUPQ, 2, line); line := Modify(line); Add(lines, line); until IsMyLine(line); return lines; fi; end); ############################################################################# ## #F PqWrite( <i>, <string> ) . . . . . . . primitive write to ANUPQ iostream #F PqWrite( <string> ) ## ## write <string> to the <i>th or default interactive {\ANUPQ} process; ## <string> must be in exactly the form the {\ANUPQ} standalone expects. The ## command is echoed via `Info' at `InfoANUPQ' level 3 (with a ```ToPQ> ''' ## prompt); i.e.~do `SetInfoLevel(InfoANUPQ, 3);' to see what is transmitted ## to the `pq' binary. `PqWrite' returns `true' if successful in writing to ## the stream of the interactive {\ANUPQ} process, and `fail' otherwise. ## InstallGlobalFunction(PqWrite, function(arg) local ioIndex, line; if Length(arg) in [1, 2] then ioIndex := ANUPQ_IOINDEX(arg{[1..Length(arg) - 1]}); return ToPQk( ANUPQData.io[ioIndex], arg{[Length(arg)..Length(arg)]}, [] ); else Error("expected 1 or 2 arguments ... not ", Length(arg), " arguments\n"); fi; end); ############################################################################# ## #F ANUPQ_ARG_CHK( <funcname>, <args> ) . . . . check args of int/non-int fns ## ## checks the argument list <args> for a function that has both interactive ## and non-interactive versions, where <funcname> is the generic name of the ## function. If <args> has length more than 1 then it contains options for ## the function that have been passed in one of the {\GAP} 3-compatible ways ## only available non-interactively. `ANUPQ_ARG_CHK' returns <datarec> which ## is either `ANUPQData.ni' in the non-interactive case or ## `ANUPQData.io[<i>]' for some <i> in the interactive case, after setting ## <datarec>.calltype' to one of `"interactive"', `"non-interactive"' or ## `"GAP3compatible"'. ## InstallGlobalFunction(ANUPQ_ARG_CHK, function(funcname, args) local ioIndex, datarec, optrec, optnames; PQ_OTHER_OPTS_CHK( funcname, IsEmpty(args) or IsPosInt( args[1] ) ); if IsEmpty(args) or IsPosInt( args[1] ) then datarec := ANUPQData.io[ CallFuncList( PqProcessIndex, args ) ]; datarec.outfname := ANUPQData.outfile; # not always needed #datarec.calltype := "interactive"; # PqStart sets this if not IsBound(datarec.group) then Error( "huh! Interactive process has no group\n" ); elif IsMatchingSublist(funcname, "PqDescendants") then if not IsPcGroup( datarec.group ) then Error( "group of process must be a pc group\n" ); fi; else # Check for Prime, ClassBound if nec. PQ_OPTION_CHECK( funcname, datarec ); fi; elif 1 = Length(args) then if not IsPcGroup( args[1] ) then if IsMatchingSublist(funcname, "PqDescendants") then Error( "first argument <args[1]> must be a pc group\n" ); elif not IsFpGroup( args[1] ) then Error( "first argument <args[1]> must be a pc group or an fp group\n" ); fi; fi; ANUPQData.ni := PQ_START( VALUE_PQ_OPTION( "PqWorkspace", 10000000 ), VALUE_PQ_OPTION( "SetupFile" ) ); datarec := ANUPQData.ni; datarec.group := args[1]; datarec.calltype := "non-interactive"; datarec.procId := 0; PQ_OPTION_CHECK( funcname, datarec ); # Check for Prime, ClassBound if nec. if IsBound( datarec.setupfile ) then datarec.outfname := "PQ_OUTPUT"; else datarec.outfname := ANUPQData.outfile; # not always needed fi; else # GAP 3 way of passing options is supported in non-interactive use if funcname = "PqDescendantsTreeCoclassOne" then Error("GAP 3-compatible ways of passing options not supported"); elif IsRecord(args[2]) then optrec := ShallowCopy(args[2]); optnames := Set( REC_NAMES(optrec) ); SubtractSet( optnames, Set( ANUPQoptions.(funcname) ) ); if not IsEmpty(optnames) then Error(ANUPQoptError( funcname, optnames ), "\n"); fi; else optrec := ANUPQextractOptions(funcname, args{[2 .. Length(args)]}); fi; PushOptions(optrec); PQ_FUNCTION.(funcname)( args{[1]} ); PopOptions(); datarec := ANUPQData.ni; datarec.calltype := "GAP3compatible"; datarec.procId := 0; fi; return datarec; end ); ############################################################################# ## #F PQ_COMPLETE_NONINTERACTIVE_FUNC_CALL( <datarec> ) ## ## writes the final commands to the `pq' setup file so that the `pq' binary ## makes a clean exit, or just closes the stream to kill the `pq' process. ## InstallGlobalFunction(PQ_COMPLETE_NONINTERACTIVE_FUNC_CALL, function(datarec) if IsBound( datarec.setupfile ) then PQ_MENU(datarec, "SP"); ToPQk(datarec, [ 0 ], [ " #exit program" ]); fi; CloseStream(datarec.stream); if IsBound( datarec.setupfile ) then Info(InfoANUPQ, 1, "Input file: '", datarec.setupfile, "' written."); Info(InfoANUPQ, 1, "Run `pq' with '", datarec.opts, "' flags."); Info(InfoANUPQ, 1, "The result will be saved in: '", datarec.outfname, "'."); fi; end ); ############################################################################# ## #F ToPQLog([<filename>]) . . . . . . log or stop logging pq commands to file ## ## With string argument <filename>, `ToPQLog' opens the file with name ## <filename> for logging; all commands written to the `pq' binary (that are ## `Info'-ed behind a ```ToPQ> ''' prompt at `InfoANUPQ' level 4) are then ## also written to that file (but without prompts). With no argument, ## `ToPQLog' stops logging to whatever file was being logged to. If a file ## was already being logged to, that file is closed and the file with name ## <filename> is opened for logging. ## InstallGlobalFunction(ToPQLog, function(arg) if not( IsEmpty(arg) or IsString( arg[1] ) ) then Error( "expected no arguments or one string argument\n" ); fi; if IsBound(ANUPQData.topqlogfile) then CloseStream(ANUPQData.logstream); PQ_UNBIND(ANUPQData, ["topqlogfile", "logstream"]); elif IsEmpty(arg) then Info(InfoANUPQ + InfoWarning, 1, "No file currently being logged to."); return; fi; if not( IsEmpty(arg) ) and IsString(arg[1]) then ANUPQData.topqlogfile := arg[1]; ANUPQData.logstream := OutputTextFile(ANUPQData.topqlogfile, false); fi; end); #E anupqios.gi . . . . . . . . . . . . . . . . . . . . . . . . . . ends here
Require Import ExtLib.Tactics. Require Import ExtLib.Data.POption. Require Import MirrorCore.Views.Ptrns. Require Import MirrorCore.Views.View. Require Import MirrorCore.TypesI. Require Import MirrorCore.SymI. Require Import MirrorCore.syms.SymProd. Set Implicit Arguments. Set Strict Implicit. Set Maximal Implicit Insertion. Set Universe Polymorphism. Section FuncView. Variables func A : Set. Variable FV : PartialView func A. Variable typ : Set. Variable RType_typ : RType typ. Variable Sym_func : RSym func. Variable Sym_A : RSym A. (* Definition FuncView := PartialView func A. *) Definition func_equiv (f : func) (a : A) : Prop := forall t, symAs a t = symAs f t. Definition FuncViewOk : Type := PartialViewOk FV func_equiv. Variable FVO : FuncViewOk. Theorem fv_ok : forall f a, f_view f = pSome a <-> f_insert a = f. Proof. exact (@pv_ok _ _ _ _ FVO). Qed. Theorem fv_compat : forall (a : A) t, symAs a t = symAs (f_insert a) t. Proof. exact (@pv_compat _ _ _ _ FVO). Qed. Lemma fv_okL f a (H : f_view f = pSome a) : f_insert a = f. Proof using FVO. apply fv_ok; assumption. Qed. Variable RTypeOk_typ : RTypeOk. Theorem fv_compat_typ : forall a, typeof_sym (f_insert a) = typeof_sym a. Proof using RTypeOk_typ FVO. intros. generalize (fv_compat a). unfold symAs. intros. generalize dependent (symD a). generalize dependent (symD (f_insert a)). destruct (typeof_sym a). { destruct (typeof_sym (f_insert a)). { intros. specialize (H t). rewrite type_cast_refl in H; eauto. destruct (type_cast t t0); try solve [ inversion H ]. inversion H. subst. f_equal. symmetry. assumption. } { intros. specialize (H t). rewrite type_cast_refl in H; eauto. inversion H. } } { intros. destruct (typeof_sym (f_insert a)); auto. specialize (H t). rewrite type_cast_refl in H. inversion H. eauto. } Defined. Theorem fv_compat_val : forall (a : A), symD a = match fv_compat_typ a in _ = T return match T with | Some t => typD t | None => unit:Type end with | eq_refl => symD (f_insert a) end. Proof using FVO. intros. assert (typeof_sym a = None \/ exists t, typeof_sym a = Some t). { clear. destruct (typeof_sym a); eauto. } destruct H. { generalize (symD a). generalize (symD (f_insert a)). generalize (fv_compat_typ a). rewrite H. intro. rewrite e. clear. destruct y; destruct y; reflexivity. } { destruct H. generalize (fv_compat a x). unfold symAs. generalize dependent (symD a). generalize dependent (symD (f_insert a)). generalize (fv_compat_typ a). destruct e. rewrite H. setoid_rewrite type_cast_refl; eauto. intros. inv_all. assumption. } Qed. Lemma fv_typeof_sym f p t v (Hview : f_view f = pSome p) (Hfunc : symAs f t = Some v) : typeof_sym p = Some t. Proof using FVO. destruct (fv_ok f p) as [H _]. specialize (H Hview); subst. rewrite <- fv_compat in Hfunc. unfold symAs in Hfunc. generalize dependent (symD p). destruct (typeof_sym p); intros; [|congruence]. forward. Defined. Global Instance Injective_exprD'_f_insert (a : A) (t : typ) (v : typD t) : Injective (symAs (f_insert a) t = Some v) := { result := symAs a t = Some v ; injection := fun H => _ }. Proof. rewrite fv_compat; assumption. Defined. Lemma symAs_finsertI (t : typ) (f : A) (P : option (typD t) -> Prop) (H : P (symAs f t)) : P (symAs (f_insert f) t). Proof. rewrite <- fv_compat; assumption. Qed. End FuncView. Theorem FuncViewOk_id {T typ} (RT : RType typ) (RS : RSym T) : @FuncViewOk T T (@PartialView_id T) typ _ _ _. Proof. constructor. { split. inversion 1. reflexivity. intros; subst; reflexivity. } { simpl. unfold func_equiv. reflexivity. } Defined. (* Global Instance PartialView_FuncView {A B} : FuncView A B -> PartialView A B := fun x => x. *) Existing Class FuncViewOk. Export MirrorCore.Views.View. Hint Extern 0 (PartialViewOk ?X _) => match goal with | H : FuncViewOk _ _ _ |- _ => eexact H end : typeclass_instances.
State Before: G : Type u_1 H : Type ?u.193982 inst✝ : CommMonoid G tG : IsTorsion G ⊢ torsion G = ⊤ State After: case h G : Type u_1 H : Type ?u.193982 inst✝ : CommMonoid G tG : IsTorsion G x✝ : G ⊢ x✝ ∈ torsion G ↔ x✝ ∈ ⊤ Tactic: ext State Before: case h G : Type u_1 H : Type ?u.193982 inst✝ : CommMonoid G tG : IsTorsion G x✝ : G ⊢ x✝ ∈ torsion G ↔ x✝ ∈ ⊤ State After: no goals Tactic: tauto
theory flash2Bra imports flash2Rev begin lemma onInv2: assumes a1:"iInv1 \<le> N" and a2:"iInv2 \<le> N" and a3:"iInv1~=iInv2 " and b1:"r \<in> rules N" and b2:"invf=inv2 iInv1 iInv2 " shows "invHoldForRule' s invf r (invariants N)" proof - have c1:"ex1P N (% iRule1 . r=NI_Local_GetX_PutX1 N iRule1 )\<or>ex1P N (% iRule1 . r=NI_Local_GetX_GetX iRule1 )\<or>ex1P N (% iRule1 . r=NI_Replace iRule1 )\<or>ex0P N ( r=NI_ShWb N )\<or>ex0P N ( r=PI_Local_GetX_GetX2 )\<or>ex0P N ( r=NI_Local_PutXAcksDone )\<or>ex1P N (% iRule1 . r=NI_Local_GetX_PutX7 N iRule1 )\<or>ex1P N (% iRule1 . r=NI_Local_Get_Nak2 iRule1 )\<or>ex0P N ( r=NI_ReplaceHomeShrVld )\<or>ex1P N (% iRule1 . r=NI_Remote_Put iRule1 )\<or>ex1P N (% iRule1 . r=NI_Local_GetX_PutX5 N iRule1 )\<or>ex0P N ( r=NI_Wb )\<or>ex1P N (% iRule1 . r=NI_Local_Get_Get iRule1 )\<or>ex0P N ( r=PI_Local_Replace )\<or>ex1P N (% iRule1 . r=NI_ReplaceShrVld iRule1 )\<or>ex2P N (% iRule1 iRule2 . r=NI_Local_GetX_PutX8 N iRule1 iRule2 )\<or>ex1P N (% iRule1 . r=NI_InvAck_2 N iRule1 )\<or>ex2P N (% iRule1 iRule2 . r=NI_Remote_Get_Nak2 iRule1 iRule2 )\<or>ex1P N (% iRule1 . r=PI_Remote_Replace iRule1 )\<or>ex0P N ( r=NI_Nak_Home )\<or>ex1P N (% iRule1 . r=NI_Local_Get_Put2 iRule1 )\<or>ex2P N (% iRule1 iRule2 . r=NI_InvAck_1 iRule1 iRule2 )\<or>ex1P N (% iRule1 . r=NI_Local_GetX_PutX11 N iRule1 )\<or>ex1P N (% iRule1 . r=NI_Local_GetX_PutX6 N iRule1 )\<or>ex2P N (% iRule1 iRule2 . r=NI_Remote_Get_Put2 iRule1 iRule2 )\<or>ex0P N ( r=PI_Local_Get_Put )\<or>ex0P N ( r=PI_Local_GetX_PutX1 N )\<or>ex1P N (% iRule1 . r=NI_InvAck_1_Home iRule1 )\<or>ex1P N (% iRule1 . r=NI_Remote_Get_Nak1 iRule1 )\<or>ex1P N (% iRule1 . r=NI_Local_Get_Nak1 iRule1 )\<or>ex1P N (% iRule1 . r=NI_Local_GetX_Nak2 iRule1 )\<or>ex1P N (% iRule1 . r=NI_Local_GetX_PutX10_home N iRule1 )\<or>ex1P N (% iRule1 . r=PI_Remote_Get iRule1 )\<or>ex1P N (% iRule1 . r=NI_Local_GetX_Nak3 iRule1 )\<or>ex2P N (% iRule1 iRule2 . r=NI_Local_GetX_PutX10 N iRule1 iRule2 )\<or>ex1P N (% iRule1 . r=NI_Local_GetX_PutX2 N iRule1 )\<or>ex1P N (% iRule1 . r=NI_Remote_Get_Put1 iRule1 )\<or>ex1P N (% iRule1 . r=NI_Remote_PutX iRule1 )\<or>ex1P N (% iRule1 . r=Store iRule1 )\<or>ex0P N ( r=NI_FAck )\<or>ex1P N (% iRule1 . r=NI_Local_GetX_PutX3 N iRule1 )\<or>ex0P N ( r=PI_Local_GetX_PutX3 )\<or>ex2P N (% iRule1 iRule2 . r=NI_Remote_GetX_PutX iRule1 iRule2 )\<or>ex1P N (% iRule1 . r=NI_Local_GetX_PutX8_home N iRule1 )\<or>ex1P N (% iRule1 . r=NI_Local_Get_Put1 N iRule1 )\<or>ex0P N ( r=PI_Local_GetX_GetX1 )\<or>ex0P N ( r=StoreHome )\<or>ex2P N (% iRule1 iRule2 . r=NI_Remote_GetX_Nak iRule1 iRule2 )\<or>ex1P N (% iRule1 . r=NI_Inv iRule1 )\<or>ex1P N (% iRule1 . r=PI_Remote_PutX iRule1 )\<or>ex0P N ( r=PI_Local_GetX_PutX4 )\<or>ex1P N (% iRule1 . r=NI_Local_GetX_PutX4 N iRule1 )\<or>ex1P N (% iRule1 . r=NI_Nak iRule1 )\<or>ex0P N ( r=PI_Local_GetX_PutX2 N )\<or>ex0P N ( r=NI_Local_Put )\<or>ex1P N (% iRule1 . r=NI_Local_GetX_Nak1 iRule1 )\<or>ex0P N ( r=NI_Nak_Clear )\<or>ex0P N ( r=PI_Local_PutX )\<or>ex1P N (% iRule1 . r=NI_Local_Get_Nak3 iRule1 )\<or>ex1P N (% iRule1 . r=NI_Remote_GetX_Nak_Home iRule1 )\<or>ex0P N ( r=PI_Local_Get_Get )\<or>ex1P N (% iRule1 . r=NI_Local_GetX_PutX9 N iRule1 )\<or>ex1P N (% iRule1 . r=PI_Remote_GetX iRule1 )\<or>ex0P N ( r=NI_ReplaceHome )\<or>ex1P N (% iRule1 . r=NI_Remote_GetX_PutX_Home iRule1 )\<or>ex1P N (% iRule1 . r=NI_Local_Get_Put3 iRule1 )" apply(cut_tac b1) apply auto done moreover {assume c1: "ex1P N (% iRule1 . r= NI_Local_GetX_PutX1 N iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Local_GetX_PutX1 N iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Local_GetX_PutX1 N iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Local_GetX_PutX1VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Local_GetX_GetX iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Local_GetX_GetX iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Local_GetX_GetX iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Local_GetX_GetXVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Replace iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Replace iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Replace iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_ReplaceVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex0P N ( r= NI_ShWb N ) " from c1 have c2:" r= NI_ShWb N " by (auto simp add: ex0P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_ShWb N ) (invariants N) " apply(cut_tac a1 a2 a3 b2 c2 ) by (metis NI_ShWbVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex0P N ( r= PI_Local_GetX_GetX2 ) " from c1 have c2:" r= PI_Local_GetX_GetX2 " by (auto simp add: ex0P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (PI_Local_GetX_GetX2 ) (invariants N) " apply(cut_tac a1 a2 a3 b2 c2 ) by (metis PI_Local_GetX_GetX2VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex0P N ( r= NI_Local_PutXAcksDone ) " from c1 have c2:" r= NI_Local_PutXAcksDone " by (auto simp add: ex0P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Local_PutXAcksDone ) (invariants N) " apply(cut_tac a1 a2 a3 b2 c2 ) by (metis NI_Local_PutXAcksDoneVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Local_GetX_PutX7 N iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Local_GetX_PutX7 N iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Local_GetX_PutX7 N iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Local_GetX_PutX7VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Local_Get_Nak2 iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Local_Get_Nak2 iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Local_Get_Nak2 iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Local_Get_Nak2VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex0P N ( r= NI_ReplaceHomeShrVld ) " from c1 have c2:" r= NI_ReplaceHomeShrVld " by (auto simp add: ex0P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_ReplaceHomeShrVld ) (invariants N) " apply(cut_tac a1 a2 a3 b2 c2 ) by (metis NI_ReplaceHomeShrVldVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Remote_Put iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Remote_Put iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Remote_Put iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Remote_PutVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Local_GetX_PutX5 N iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Local_GetX_PutX5 N iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Local_GetX_PutX5 N iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Local_GetX_PutX5VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex0P N ( r= NI_Wb ) " from c1 have c2:" r= NI_Wb " by (auto simp add: ex0P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Wb ) (invariants N) " apply(cut_tac a1 a2 a3 b2 c2 ) by (metis NI_WbVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Local_Get_Get iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Local_Get_Get iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Local_Get_Get iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Local_Get_GetVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex0P N ( r= PI_Local_Replace ) " from c1 have c2:" r= PI_Local_Replace " by (auto simp add: ex0P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (PI_Local_Replace ) (invariants N) " apply(cut_tac a1 a2 a3 b2 c2 ) by (metis PI_Local_ReplaceVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_ReplaceShrVld iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_ReplaceShrVld iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_ReplaceShrVld iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_ReplaceShrVldVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex2P N (% iRule1 iRule2 . r= NI_Local_GetX_PutX8 N iRule1 iRule2 ) " from c1 obtain iRule1 iRule2 where c2:" iRule1~=iRule2 \<and> iRule1 \<le> N \<and> iRule2 \<le> N \<and> r= NI_Local_GetX_PutX8 N iRule1 iRule2 " by (auto simp add: ex2P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Local_GetX_PutX8 N iRule1 iRule2 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Local_GetX_PutX8VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_InvAck_2 N iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_InvAck_2 N iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_InvAck_2 N iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_InvAck_2VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex2P N (% iRule1 iRule2 . r= NI_Remote_Get_Nak2 iRule1 iRule2 ) " from c1 obtain iRule1 iRule2 where c2:" iRule1~=iRule2 \<and> iRule1 \<le> N \<and> iRule2 \<le> N \<and> r= NI_Remote_Get_Nak2 iRule1 iRule2 " by (auto simp add: ex2P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Remote_Get_Nak2 iRule1 iRule2 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Remote_Get_Nak2VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= PI_Remote_Replace iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= PI_Remote_Replace iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (PI_Remote_Replace iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis PI_Remote_ReplaceVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex0P N ( r= NI_Nak_Home ) " from c1 have c2:" r= NI_Nak_Home " by (auto simp add: ex0P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Nak_Home ) (invariants N) " apply(cut_tac a1 a2 a3 b2 c2 ) by (metis NI_Nak_HomeVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Local_Get_Put2 iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Local_Get_Put2 iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Local_Get_Put2 iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Local_Get_Put2VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex2P N (% iRule1 iRule2 . r= NI_InvAck_1 iRule1 iRule2 ) " from c1 obtain iRule1 iRule2 where c2:" iRule1~=iRule2 \<and> iRule1 \<le> N \<and> iRule2 \<le> N \<and> r= NI_InvAck_1 iRule1 iRule2 " by (auto simp add: ex2P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_InvAck_1 iRule1 iRule2 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_InvAck_1VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Local_GetX_PutX11 N iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Local_GetX_PutX11 N iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Local_GetX_PutX11 N iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Local_GetX_PutX11VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Local_GetX_PutX6 N iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Local_GetX_PutX6 N iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Local_GetX_PutX6 N iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Local_GetX_PutX6VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex2P N (% iRule1 iRule2 . r= NI_Remote_Get_Put2 iRule1 iRule2 ) " from c1 obtain iRule1 iRule2 where c2:" iRule1~=iRule2 \<and> iRule1 \<le> N \<and> iRule2 \<le> N \<and> r= NI_Remote_Get_Put2 iRule1 iRule2 " by (auto simp add: ex2P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Remote_Get_Put2 iRule1 iRule2 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Remote_Get_Put2VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex0P N ( r= PI_Local_Get_Put ) " from c1 have c2:" r= PI_Local_Get_Put " by (auto simp add: ex0P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (PI_Local_Get_Put ) (invariants N) " apply(cut_tac a1 a2 a3 b2 c2 ) by (metis PI_Local_Get_PutVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex0P N ( r= PI_Local_GetX_PutX1 N ) " from c1 have c2:" r= PI_Local_GetX_PutX1 N " by (auto simp add: ex0P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (PI_Local_GetX_PutX1 N ) (invariants N) " apply(cut_tac a1 a2 a3 b2 c2 ) by (metis PI_Local_GetX_PutX1VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_InvAck_1_Home iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_InvAck_1_Home iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_InvAck_1_Home iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_InvAck_1_HomeVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Remote_Get_Nak1 iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Remote_Get_Nak1 iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Remote_Get_Nak1 iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Remote_Get_Nak1VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Local_Get_Nak1 iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Local_Get_Nak1 iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Local_Get_Nak1 iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Local_Get_Nak1VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Local_GetX_Nak2 iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Local_GetX_Nak2 iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Local_GetX_Nak2 iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Local_GetX_Nak2VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Local_GetX_PutX10_home N iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Local_GetX_PutX10_home N iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Local_GetX_PutX10_home N iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Local_GetX_PutX10_homeVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= PI_Remote_Get iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= PI_Remote_Get iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (PI_Remote_Get iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis PI_Remote_GetVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Local_GetX_Nak3 iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Local_GetX_Nak3 iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Local_GetX_Nak3 iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Local_GetX_Nak3VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex2P N (% iRule1 iRule2 . r= NI_Local_GetX_PutX10 N iRule1 iRule2 ) " from c1 obtain iRule1 iRule2 where c2:" iRule1~=iRule2 \<and> iRule1 \<le> N \<and> iRule2 \<le> N \<and> r= NI_Local_GetX_PutX10 N iRule1 iRule2 " by (auto simp add: ex2P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Local_GetX_PutX10 N iRule1 iRule2 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Local_GetX_PutX10VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Local_GetX_PutX2 N iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Local_GetX_PutX2 N iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Local_GetX_PutX2 N iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Local_GetX_PutX2VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Remote_Get_Put1 iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Remote_Get_Put1 iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Remote_Get_Put1 iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Remote_Get_Put1VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Remote_PutX iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Remote_PutX iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Remote_PutX iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Remote_PutXVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= Store iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= Store iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (Store iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis StoreVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex0P N ( r= NI_FAck ) " from c1 have c2:" r= NI_FAck " by (auto simp add: ex0P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_FAck ) (invariants N) " apply(cut_tac a1 a2 a3 b2 c2 ) by (metis NI_FAckVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Local_GetX_PutX3 N iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Local_GetX_PutX3 N iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Local_GetX_PutX3 N iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Local_GetX_PutX3VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex0P N ( r= PI_Local_GetX_PutX3 ) " from c1 have c2:" r= PI_Local_GetX_PutX3 " by (auto simp add: ex0P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (PI_Local_GetX_PutX3 ) (invariants N) " apply(cut_tac a1 a2 a3 b2 c2 ) by (metis PI_Local_GetX_PutX3VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex2P N (% iRule1 iRule2 . r= NI_Remote_GetX_PutX iRule1 iRule2 ) " from c1 obtain iRule1 iRule2 where c2:" iRule1~=iRule2 \<and> iRule1 \<le> N \<and> iRule2 \<le> N \<and> r= NI_Remote_GetX_PutX iRule1 iRule2 " by (auto simp add: ex2P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Remote_GetX_PutX iRule1 iRule2 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Remote_GetX_PutXVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Local_GetX_PutX8_home N iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Local_GetX_PutX8_home N iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Local_GetX_PutX8_home N iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Local_GetX_PutX8_homeVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Local_Get_Put1 N iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Local_Get_Put1 N iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Local_Get_Put1 N iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Local_Get_Put1VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex0P N ( r= PI_Local_GetX_GetX1 ) " from c1 have c2:" r= PI_Local_GetX_GetX1 " by (auto simp add: ex0P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (PI_Local_GetX_GetX1 ) (invariants N) " apply(cut_tac a1 a2 a3 b2 c2 ) by (metis PI_Local_GetX_GetX1VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex0P N ( r= StoreHome ) " from c1 have c2:" r= StoreHome " by (auto simp add: ex0P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (StoreHome ) (invariants N) " apply(cut_tac a1 a2 a3 b2 c2 ) by (metis StoreHomeVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex2P N (% iRule1 iRule2 . r= NI_Remote_GetX_Nak iRule1 iRule2 ) " from c1 obtain iRule1 iRule2 where c2:" iRule1~=iRule2 \<and> iRule1 \<le> N \<and> iRule2 \<le> N \<and> r= NI_Remote_GetX_Nak iRule1 iRule2 " by (auto simp add: ex2P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Remote_GetX_Nak iRule1 iRule2 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Remote_GetX_NakVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Inv iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Inv iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Inv iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_InvVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= PI_Remote_PutX iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= PI_Remote_PutX iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (PI_Remote_PutX iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis PI_Remote_PutXVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex0P N ( r= PI_Local_GetX_PutX4 ) " from c1 have c2:" r= PI_Local_GetX_PutX4 " by (auto simp add: ex0P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (PI_Local_GetX_PutX4 ) (invariants N) " apply(cut_tac a1 a2 a3 b2 c2 ) by (metis PI_Local_GetX_PutX4VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Local_GetX_PutX4 N iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Local_GetX_PutX4 N iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Local_GetX_PutX4 N iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Local_GetX_PutX4VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Nak iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Nak iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Nak iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_NakVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex0P N ( r= PI_Local_GetX_PutX2 N ) " from c1 have c2:" r= PI_Local_GetX_PutX2 N " by (auto simp add: ex0P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (PI_Local_GetX_PutX2 N ) (invariants N) " apply(cut_tac a1 a2 a3 b2 c2 ) by (metis PI_Local_GetX_PutX2VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex0P N ( r= NI_Local_Put ) " from c1 have c2:" r= NI_Local_Put " by (auto simp add: ex0P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Local_Put ) (invariants N) " apply(cut_tac a1 a2 a3 b2 c2 ) by (metis NI_Local_PutVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Local_GetX_Nak1 iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Local_GetX_Nak1 iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Local_GetX_Nak1 iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Local_GetX_Nak1VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex0P N ( r= NI_Nak_Clear ) " from c1 have c2:" r= NI_Nak_Clear " by (auto simp add: ex0P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Nak_Clear ) (invariants N) " apply(cut_tac a1 a2 a3 b2 c2 ) by (metis NI_Nak_ClearVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex0P N ( r= PI_Local_PutX ) " from c1 have c2:" r= PI_Local_PutX " by (auto simp add: ex0P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (PI_Local_PutX ) (invariants N) " apply(cut_tac a1 a2 a3 b2 c2 ) by (metis PI_Local_PutXVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Local_Get_Nak3 iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Local_Get_Nak3 iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Local_Get_Nak3 iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Local_Get_Nak3VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Remote_GetX_Nak_Home iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Remote_GetX_Nak_Home iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Remote_GetX_Nak_Home iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Remote_GetX_Nak_HomeVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex0P N ( r= PI_Local_Get_Get ) " from c1 have c2:" r= PI_Local_Get_Get " by (auto simp add: ex0P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (PI_Local_Get_Get ) (invariants N) " apply(cut_tac a1 a2 a3 b2 c2 ) by (metis PI_Local_Get_GetVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Local_GetX_PutX9 N iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Local_GetX_PutX9 N iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Local_GetX_PutX9 N iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Local_GetX_PutX9VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= PI_Remote_GetX iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= PI_Remote_GetX iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (PI_Remote_GetX iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis PI_Remote_GetXVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex0P N ( r= NI_ReplaceHome ) " from c1 have c2:" r= NI_ReplaceHome " by (auto simp add: ex0P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_ReplaceHome ) (invariants N) " apply(cut_tac a1 a2 a3 b2 c2 ) by (metis NI_ReplaceHomeVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Remote_GetX_PutX_Home iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Remote_GetX_PutX_Home iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Remote_GetX_PutX_Home iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Remote_GetX_PutX_HomeVsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) } moreover {assume c1: "ex1P N (% iRule1 . r= NI_Local_Get_Put3 iRule1 ) " from c1 obtain iRule1 where c2:" iRule1 \<le> N \<and> r= NI_Local_Get_Put3 iRule1 " by (auto simp add: ex1P_def) have "invHoldForRule' s (inv2 iInv1 iInv2 ) (NI_Local_Get_Put3 iRule1 ) (invariants N) " apply(cut_tac c2 a1 a2 a3 ) by (metis NI_Local_Get_Put3VsInv2 ) then have "invHoldForRule' s invf r (invariants N) " by(cut_tac c2 b2, metis) }ultimately show "invHoldForRule' s invf r (invariants N) " by blast qed end
State Before: z : ℂ ⊢ Angle.toReal ↑(arg z) = arg z State After: z : ℂ ⊢ arg z ∈ Set.Ioc (-π) π Tactic: rw [Real.Angle.toReal_coe_eq_self_iff_mem_Ioc] State Before: z : ℂ ⊢ arg z ∈ Set.Ioc (-π) π State After: no goals Tactic: exact arg_mem_Ioc _
------------------------------------------------------------------------ -- The Agda standard library -- -- Table-related properties ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Table.Properties where open import Data.Table open import Data.Table.Relation.Binary.Equality open import Data.Bool using (true; false; if_then_else_) open import Data.Nat using (zero; suc) open import Data.Empty using (⊥-elim) open import Data.Fin using (Fin; suc; zero; _≟_; punchIn) import Data.Fin.Properties as FP open import Data.Fin.Permutation as Perm using (Permutation; _⟨$⟩ʳ_; _⟨$⟩ˡ_) open import Data.List as L using (List; _∷_; []) open import Data.List.Relation.Unary.Any using (here; there; index) open import Data.List.Membership.Propositional using (_∈_) open import Data.Product as Product using (Σ; ∃; _,_; proj₁; proj₂) open import Data.Vec as V using (Vec; _∷_; []) import Data.Vec.Properties as VP open import Function using (_∘_; flip) open import Function.Inverse using (Inverse) open import Relation.Binary.PropositionalEquality as P using (_≡_; _≢_; refl; sym; cong) open import Relation.Nullary using (yes; no) open import Relation.Nullary.Negation using (contradiction) ------------------------------------------------------------------------ -- select module _ {a} {A : Set a} where -- Selecting from any table is the same as selecting from a constant table. select-const : ∀ {n} (z : A) (i : Fin n) t → select z i t ≗ select z i (replicate (lookup t i)) select-const z i t j with j ≟ i ... | yes _ = refl ... | no _ = refl -- Selecting an element from a table then looking it up is the same as looking -- up the index in the original table select-lookup : ∀ {n x i} (t : Table A n) → lookup (select x i t) i ≡ lookup t i select-lookup {i = i} t with i ≟ i ... | yes _ = refl ... | no i≢i = contradiction refl i≢i -- Selecting an element from a table then removing the same element produces a -- constant table select-remove : ∀ {n x} i (t : Table A (suc n)) → remove i (select x i t) ≗ replicate {n = n} x select-remove i t j with punchIn i j ≟ i ... | yes p = contradiction p (FP.punchInᵢ≢i _ _) ... | no ¬p = refl ------------------------------------------------------------------------ -- permute -- Removing an index 'i' from a table permuted with 'π' is the same as -- removing the element, then permuting with 'π' minus 'i'. remove-permute : ∀ {m n} (π : Permutation (suc m) (suc n)) i (t : Table A (suc n)) → remove (π ⟨$⟩ˡ i) (permute π t) ≗ permute (Perm.remove (π ⟨$⟩ˡ i) π) (remove i t) remove-permute π i t j = P.cong (lookup t) (Perm.punchIn-permute′ π i j) ------------------------------------------------------------------------ -- fromList module _ {a} {A : Set a} where fromList-∈ : ∀ {xs : List A} (i : Fin (L.length xs)) → lookup (fromList xs) i ∈ xs fromList-∈ {[]} () fromList-∈ {x ∷ xs} zero = here refl fromList-∈ {x ∷ xs} (suc i) = there (fromList-∈ i) index-fromList-∈ : ∀ {xs i} → index (fromList-∈ {xs} i) ≡ i index-fromList-∈ {[]} {()} index-fromList-∈ {x ∷ xs} {zero} = refl index-fromList-∈ {x ∷ xs} {suc i} = cong suc index-fromList-∈ fromList-index : ∀ {xs} {x : A} (x∈xs : x ∈ xs) → lookup (fromList xs) (index x∈xs) ≡ x fromList-index (here px) = sym px fromList-index (there x∈xs) = fromList-index x∈xs ------------------------------------------------------------------------ -- There exists an isomorphism between tables and vectors. module _ {a n} {A : Set a} where ↔Vec : Inverse (≡-setoid A n) (P.setoid (Vec A n)) ↔Vec = record { to = record { _⟨$⟩_ = toVec ; cong = VP.tabulate-cong } ; from = P.→-to-⟶ fromVec ; inverse-of = record { left-inverse-of = VP.lookup∘tabulate ∘ lookup ; right-inverse-of = VP.tabulate∘lookup } } ------------------------------------------------------------------------ -- Other module _ {a} {A : Set a} where lookup∈ : ∀ {xs : List A} (i : Fin (L.length xs)) → ∃ λ x → x ∈ xs lookup∈ i = _ , fromList-∈ i
/* * Copyright (c) 2016-2021 lymastee, All rights reserved. * Contact: [email protected] * * This file is part of the gslib project. * * 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 rasm_150d55c1_d63d_40ea_8fd2_9bc280975fe0_h #define rasm_150d55c1_d63d_40ea_8fd2_9bc280975fe0_h #include <gslib\pool.h> #include <gslib\string.h> #include <gslib\std.h> #include <rathen\config.h> /* * @ 2013.02.26 * New assemble tool for rathen. This version we gonna solve the problem that last version of rasm could not support labeled jump. * In this version, every chuck of assembly code would be a separate and independent node, linked to a whole code segment, and the * label would be a particular node in the tree. In this version, we would not need vslen to do the linkage stuff any more. * And the short jump would be available. * Plus, in this way, we could see the machine code correspond to every single assemble instruction, and yet we've been very close * to a disassemble toolkit, but there were still some problems. The rathen didn't use all the x86 machine code. This assemble tool * just concerned about a subset of all the x86 machine codes. I didn't intend to provide such a tool to decode all the machine codes * into assemble, or rathen source code, either. As the optimize work we might probably did in the future, this decode works would * be a hard problem, which was considered unnecessary. */ __rathen_begin__ enum reg { _regzr = 0, _eax = 1, _ecx = 2, _edx, _ebx, _esp, _ebp, _esi, _edi, /* more to come... */ }; #ifdef _GS_X86 inline byte get_register_index(reg r) { switch(r) { case _eax: return 0; case _ecx: return 1; case _edx: return 2; case _ebx: return 3; case _esp: return 4; /* why "no index" */ case _ebp: return 5; case _esi: return 6; case _edi: return 7; default: assert(0); } return -1; } typedef const gchar* lab; #define __rasm_make_type(tname, dname) \ struct tname \ { \ dname _data; \ \ explicit tname(dname d = (dname)0) { _data = d; } \ bool operator == (const tname& d) const { return _data == d._data; } \ dname inner_data() const { return _data; } \ } __rasm_make_type(_bias_, int); __rasm_make_type(_bias8_, int8); __rasm_make_type(_bias16_, int16); __rasm_make_type(_mem_, int); __rasm_make_type(_reg_, reg); enum cccc { cccc_o = 0, cccc_no, cccc_c, cccc_nc, cccc_e, cccc_ne, cccc_be, cccc_a, cccc_s, cccc_ns, cccc_p, cccc_np, cccc_l, cccc_ge, cccc_le, cccc_g, }; struct __gs_novtable rasm_instr abstract { virtual ~rasm_instr() {} virtual const gchar* get_name() const = 0; virtual bool finalize(vessel& vsl) = 0; virtual void to_string(string& str) const = 0; virtual bool compare(const rasm_instr* that) const = 0; }; inline const gchar* nameofreg(reg r) { switch(r) { case _eax: return _t("eax"); case _ecx: return _t("ecx"); case _edx: return _t("edx"); case _ebx: return _t("ebx"); case _esp: return _t("esp"); case _ebp: return _t("ebp"); case _esi: return _t("esi"); case _edi: return _t("edi"); } return 0; } template<class _in> struct rasm_instr0: public _in { virtual void to_string(string& str) const override { print(str, get_name(), _t(";")); } virtual bool compare(const rasm_instr* that) const override { return strtool::compare(get_name(), that->get_name()) == 0; } inline void print(string& str, const gchar* p, const gchar* a) const { if(p) { str += p; } if(a) { str += a; } } inline void print(string& str, int n, const gchar* a) const { string s; s.format(_t("%08x"), n); str += s; if(a) { str += a; } } inline void print(string& str, reg n, const gchar* a) const { string s; s.format(_t("[%s]"), nameofreg(n)); str += s; if(a) { str += a; } } inline void print(string& str, _bias8_ n, const gchar* a) const { string s; s.format(_t("[s8:%02x]"), (int)n.inner_data()); str += s; if(a) { str += a; } } inline void print(string& str, _bias16_ n, const gchar* a) const { string s; s.format(_t("[s16:%04x]"), (int)n.inner_data()); str += s; if(a) { str += a; } } inline void print(string& str, _bias_ n, const gchar* a) const { string s; s.format(_t("[s:%08x]"), (int)n.inner_data()); str += s; if(a) { str += a; } } inline void print(string& str, _mem_ n, const gchar* a) const { string s; s.format(_t("[m:%08x]"), (int)n.inner_data()); str += s; if(a) { str += a; } } inline void print(string& str, _reg_ n, const gchar* a) const { string s; s.format(_t("[%s]"), nameofreg(n.inner_data())); str += s; if(a) { str += a; } } }; template<class c1> struct rasm_instr1: public rasm_instr0<rasm_instr> { typedef c1 type1; typedef rasm_instr1<c1> myref; c1 _data1; rasm_instr1(c1 a) { _data1 = a; } virtual void to_string(string& str) const override { print(str, get_name(), _t(" ")); print(str, _data1, _t(";")); } virtual bool compare(const rasm_instr* that) const override { if(strtool::compare(get_name(), that->get_name()) != 0) return false; const myref* ptr = static_cast<const myref*>(that); return _data1 == ptr->_data1; } }; struct __gs_novtable rasm_link abstract: public rasm_instr { virtual bool is_linker() const = 0; virtual const string& get_label() const = 0; }; struct rasm_linker; struct rasm_label: public rasm_instr0<rasm_link> { typedef rasm_linker linker; typedef gs::vector<linker*> linker_list; string _label; linker_list _linkers; public: rasm_label(lab l) { _label.assign(l); } virtual const gchar* get_name() const override { return _t("label"); } virtual bool finalize(vessel& vsl) override { return true; } virtual void to_string(string& str) const override; virtual bool compare(const rasm_instr* that) const override; virtual bool is_linker() const override { return false; } virtual const string& get_label() const override { return _label; } public: int get_linker_ctr() const { return (int)_linkers.size(); } rasm_linker* get_linker(int i) { return _linkers.at(i); } void add_linker(linker* p) { _linkers.push_back(p); } }; struct rasm_linker: public rasm_instr0<rasm_link> { typedef lab type1; typedef rasm_linker linker; typedef gs::vector<linker*> linker_list; string _label; int _linkeeid; linker_list _affects; public: rasm_linker(lab l): _linkeeid(0) { _label.assign(l); } virtual void to_string(string& str) const override; virtual bool compare(const rasm_instr* that) const override; virtual bool is_linker() const override { return true; } virtual const string& get_label() const override { return _label; } public: void set_linkee_index(int i) { _linkeeid = i; } int get_linkee_index() const { return _linkeeid; } void add_affects(linker* p) { _affects.push_back(p); } }; template<class c1, class c2> struct rasm_instr2: public rasm_instr1<c1> { typedef c2 type2; typedef rasm_instr2<c1, c2> myref; c2 _data2; rasm_instr2(c1 a, c2 b): rasm_instr1(a) { _data2 = b; } virtual void to_string(string& str) const override { print(str, get_name(), _t(" ")); print(str, _data1, _t(",")); print(str, _data2, _t(";")); } virtual bool compare(const rasm_instr* that) const override { if(strtool::compare(get_name(), that->get_name()) != 0) return false; const myref* ptr = static_cast<const myref*>(that); return _data1 == ptr->_data1 && _data2 == ptr->_data2; } }; template<class c1, class c2, class c3> struct rasm_instr3: public rasm_instr2<c1, c2> { typedef c3 type3; typedef rasm_instr3<c1, c2, c3> myref; c3 _data3; rasm_instr3(c1 a, c2 b, c3 c): rasm_instr2(a, b) { _data3 = c; } virtual void to_string(string& str) const override { print(str, get_name(), _t(" ")); print(str, _data1, _t(",")); print(str, _data2, _t(",")); print(str, _data3, _t(";")); } virtual bool compare(const rasm_instr* that) const override { if(strtool::compare(get_name(), that->get_name()) != 0) return false; const myref* ptr = static_cast<const myref*>(that); return _data1 == ptr->_data1 && _data2 == ptr->_data2 && _data3 == ptr->_data3; } }; #define rasm_reginstr(in) \ static rasm_instr* make_##in(); \ void in() { _list.push_back(make_##in()); } #define rasm_reginstr_i_begin(in, c1) \ static rasm_instr* make_##in(c1); \ void in(c1 a) { #define rasm_reginstr_i_end(in) \ _list.push_back(make_##in(a)); } #define rasm_reginstr_i(in, c1) \ rasm_reginstr_i_begin(in, c1) \ rasm_reginstr_i_end(in) #define rasm_reginstr_ii_begin(in, c1, c2) \ static rasm_instr* make_##in(c1, c2); \ void in(c1 a, c2 b) { #define rasm_reginstr_ii_end(in) \ _list.push_back(make_##in(a, b)); } #define rasm_reginstr_ii(in, c1, c2) \ rasm_reginstr_ii_begin(in, c1, c2) \ rasm_reginstr_ii_end(in) #define rasm_reginstr_iii_begin(in, c1, c2, c3) \ static rasm_instr* make_##in(c1, c2, c3); \ void in(c1 a, c2 b, c3 c) { #define rasm_reginstr_iii_end(in) \ _list.push_back(make_##in(a, b, c)); } #define rasm_reginstr_iii(in, c1, c2, c3) \ rasm_reginstr_iii_begin(in, c1, c2, c3) \ rasm_reginstr_iii_end(in) #define rasm_reginstr_lab(in, c1) \ static rasm_instr* make_##in(c1); \ void in(c1 a) \ { \ rasm_label* ptr = static_cast<rasm_label*>(make_##in(a)); \ assert(ptr && "alloc failed."); \ _list.push_back(ptr); \ verify(_label.insert(std::make_pair(ptr->get_label(), get_last_instruction_index())).second && "insert failed."); \ } #define rasm_reginstr_lnk(in, c1) \ static rasm_instr* make_##in(c1); \ void in(c1 a) \ { \ rasm_linker* ptr = static_cast<rasm_linker*>(make_##in(a)); \ assert(ptr && "alloc failed."); \ _list.push_back(ptr); \ _link.push_back(ptr); \ } /* * Only the 8 - bit offsets need this optimization, but DONOT apply such kind of optimizations to immediate operands, * that might cause problems like "mov eax, 1" become "mov ah, 1", which was incorrect */ #define rasm_optimize_b8(calling, bparam) \ if((int)bparam.inner_data() > (int)-0x80 && (int)bparam.inner_data() < (int)0x80) \ return calling; #define rasm_optimize_b16(calling, bparam) \ if((int)bparam.inner_data() > (int)-0x8000 && (int)bparam.inner_data() < (int)0x8000) \ return calling; /* * If a instruction was operated on the eax register, it could be optimized like: */ #define rasm_optimize_acc(calling, rparam) \ if(rparam == _eax) \ return calling; /* * Optimize for inc or dec */ #define rasm_optimize_i1(calling, iparam) \ if(iparam == 1) \ return calling; /* * Optimize for immediate operants less than 1 byte. Instructions like loop need this optimization */ #define rasm_optimize_i8(calling, iparam) \ if((int)iparam > (int)-0x80 && (int)iparam < (int)0x80) \ return calling; class rasm { public: typedef gs::vector<rasm_instr*> instr_list; typedef gs::vector<rasm_link*> link_list; typedef gs::unordered_map<gs::string, int> label_map; /* label name => index in instruction list */ public: rasm() {} ~rasm(); void print(string& str) const; int finalize(vessel& vsl); int get_last_instruction_index() const; //link get_label(lab l) { return _label.find(l); } //link no_label() { return _label.end(); } //const_link get_label(lab l) const { return _label.find(l); } //const_link no_label() const { return _label.end(); } //iterator get_current() { return _list.end(); } //const_iterator get_current() const { return _list.end(); } //iterator get_head() { return _list.begin(); } //const_iterator get_head() const { return _list.begin(); } //void attach(const_iterator pos, rasm& other); //iterator tick() { return _list.size() ? -- _list.end() : _list.end(); } //void tick(iterator& i) { i = tick(); } protected: instr_list _list; label_map _label; link_list _link; public: rasm_reginstr_ii(mov, reg, int8); rasm_reginstr_ii(mov, reg, int); rasm_reginstr_ii(mov, reg, reg); rasm_reginstr_ii(mov, reg, _mem_); rasm_reginstr_ii(mov, reg, _bias8_); rasm_reginstr_ii_begin(mov, reg, _bias_) rasm_optimize_b8(mov(a, (_bias8_)b.inner_data()), b) rasm_reginstr_ii_end(mov); rasm_reginstr_ii(mov, _mem_, reg); rasm_reginstr_ii(mov, _bias8_, reg); rasm_reginstr_ii_begin(mov, _bias_, reg) rasm_optimize_b8(mov((_bias8_)a.inner_data(), b), a) rasm_reginstr_ii_end(mov); rasm_reginstr_ii(mov, _mem_, int); rasm_reginstr_ii(mov, _bias8_, int); rasm_reginstr_ii_begin(mov, _bias_, int) rasm_optimize_b8(mov((_bias8_)a.inner_data(), b), a) rasm_reginstr_ii_end(mov); rasm_reginstr_ii(mov, reg, _reg_); rasm_reginstr_ii(mov, _reg_, reg); rasm_reginstr_ii(lea, reg, _bias8_); rasm_reginstr_ii_begin(lea, reg, _bias_) rasm_optimize_b8(lea(a, (_bias8_)b.inner_data()), b) rasm_reginstr_ii_end(lea); rasm_reginstr(nop); rasm_reginstr(hlt); rasm_reginstr_i(call, int); rasm_reginstr_i(call, reg); rasm_reginstr_i(call, _bias_); rasm_reginstr_lnk(call, lab); rasm_reginstr(ret); rasm_reginstr_i(ret, int); rasm_reginstr_i(push, reg); rasm_reginstr_i(push, int8); rasm_reginstr_i(push, int); rasm_reginstr_i(push, _mem_); rasm_reginstr_i(push, _bias8_); rasm_reginstr_i_begin(push, _bias_) rasm_optimize_b8(push((_bias8_)a.inner_data()), a) rasm_reginstr_i_end(push); rasm_reginstr_i(push, _reg_); rasm_reginstr_i(pushw, _bias8_); rasm_reginstr_i_begin(pushw, _bias_) rasm_optimize_b8(pushw((_bias8_)a.inner_data()), a) rasm_reginstr_i_end(pushw); rasm_reginstr(pushad); rasm_reginstr_i(pop, reg); rasm_reginstr_i(pop, _mem_); rasm_reginstr_i(pop, _bias8_); rasm_reginstr_i_begin(pop, _bias_) rasm_optimize_b8(pop((_bias8_)a.inner_data()), a) rasm_reginstr_i_end(pop); rasm_reginstr(popad); rasm_reginstr_lab(label, lab); rasm_reginstr_i(jmp, _mem_); rasm_reginstr_i(jmp, _bias8_); rasm_reginstr_i_begin(jmp, _bias_) rasm_optimize_b8(jmp((_bias8_)a.inner_data()), a) rasm_reginstr_i_end(jmp); rasm_reginstr_i(jmp, reg); rasm_reginstr_i(jmps, _bias8_); /* jmp bias from ss */ rasm_reginstr_i_begin(jmps, _bias_) rasm_optimize_b8(jmps((_bias8_)a.inner_data()), a) rasm_reginstr_i_end(jmps); //rasm_reginstr_i(jmp, lab); rasm_reginstr_lnk(jmp, lab); rasm_reginstr_i(jes, _bias8_); rasm_reginstr_i_begin(jes, _bias_) rasm_optimize_b8(jes((_bias8_)a.inner_data()), a) rasm_reginstr_i_end(jes); rasm_reginstr_i(jnes, _bias8_); rasm_reginstr_i_begin(jnes, _bias_) rasm_optimize_b8(jnes((_bias8_)a.inner_data()), a) rasm_reginstr_i_end(jnes); rasm_reginstr_i(loop, int8); rasm_reginstr_i_begin(loop, int) /* I'm not sure about this, can the loop instruction operate on a short? */ rasm_optimize_i8(loop((int8)a), (a - 2)) rasm_reginstr_i_end(loop); rasm_reginstr_lnk(loop, lab); rasm_reginstr(cld); rasm_reginstr(std); rasm_reginstr(movsb); rasm_reginstr(movsw); rasm_reginstr(movs); rasm_reginstr(rep); rasm_reginstr_ii(cmp, _bias_, int); rasm_reginstr_ii(cmp, reg, int8); rasm_reginstr_ii(cmp, reg, int); rasm_reginstr_ii(cmp, reg, _bias8_); rasm_reginstr_ii_begin(cmp, reg, _bias_) rasm_optimize_b8(cmp(a, (_bias8_)b.inner_data()), b) rasm_reginstr_ii_end(cmp); rasm_reginstr_ii(cmp, _reg_, int8); rasm_reginstr_ii(cmp, _reg_, int); rasm_reginstr_ii(cmp, reg, _reg_); rasm_reginstr_i(inc, reg); rasm_reginstr_i(inc, _mem_); rasm_reginstr_i(inc, _bias8_); rasm_reginstr_i_begin(inc, _bias_) rasm_optimize_b8(inc((_bias8_)a.inner_data()), a) rasm_reginstr_i_end(inc); rasm_reginstr_ii(add, reg, reg); rasm_reginstr_ii(add, reg, int8); rasm_reginstr_ii(add, reg, int); rasm_reginstr_i(add, int); rasm_reginstr_ii(add, reg, _mem_); rasm_reginstr_ii(add, reg, _bias8_); rasm_reginstr_ii(add, reg, _bias_); rasm_reginstr_ii(add, _mem_, int8); rasm_reginstr_ii(add, _mem_, int); rasm_reginstr_ii(add, _bias8_, int8); rasm_reginstr_ii(add, _bias_, int8); rasm_reginstr_ii(add, _bias8_, int); rasm_reginstr_ii(add, _bias_, int); rasm_reginstr_ii(add, _mem_, reg); rasm_reginstr_ii(add, _bias8_, reg); rasm_reginstr_ii(add, _bias_, reg); rasm_reginstr_ii(add, reg, _reg_); rasm_reginstr_ii(add, _reg_, reg); rasm_reginstr_i(dec, reg); rasm_reginstr_i(dec, _mem_); rasm_reginstr_i(dec, _bias_); rasm_reginstr_ii(sub, reg, reg); rasm_reginstr_ii(sub, reg, int); rasm_reginstr_i(sub, int); rasm_reginstr_ii(sub, reg, _mem_); rasm_reginstr_ii(sub, reg, _bias_); rasm_reginstr_ii(sub, _mem_, int); rasm_reginstr_ii(sub, _bias_, int); rasm_reginstr_ii(sub, _mem_, reg); rasm_reginstr_ii(sub, _bias_, reg); rasm_reginstr_ii(sub, reg, _reg_); rasm_reginstr_ii(sub, _reg_, reg); rasm_reginstr_iii(imul, reg, reg, int); rasm_reginstr_ii(imul, reg, int); rasm_reginstr_i(imul, reg); rasm_reginstr_ii(imul, reg, _mem_); rasm_reginstr_ii(imul, reg, _bias_); rasm_reginstr_iii(imul, reg, _mem_, int); rasm_reginstr_iii(imul, reg, _bias_, int); rasm_reginstr_ii(imul, reg, reg); rasm_reginstr_i(imul, _mem_); rasm_reginstr_i(imul, _bias_); rasm_reginstr_ii(imul, reg, _reg_); rasm_reginstr_i(idiv, reg); rasm_reginstr_i(idiv, _mem_); rasm_reginstr_i(idiv, _bias_); rasm_reginstr_i(idiv, _reg_); rasm_reginstr(cdq); rasm_reginstr_i(neg, reg); rasm_reginstr_i(not, reg); rasm_reginstr_ii(xor, reg, reg); rasm_reginstr_ii(xor, reg, int); rasm_reginstr_ii(xor, reg, _bias_); rasm_reginstr_ii(xor, reg, _reg_); rasm_reginstr_i(shl, reg); rasm_reginstr_ii(shl, reg, int); rasm_reginstr_i(shr, reg); rasm_reginstr_ii(shr, reg, int); //rasm_reginstr //setcc rasm_reginstr_ii(and, reg, int); rasm_reginstr_ii(and, reg, _bias_); rasm_reginstr_ii(and, reg, _reg_); rasm_reginstr_ii(or , reg, int); rasm_reginstr_ii(or , reg, _bias_); rasm_reginstr_ii(or , reg, _reg_); }; #endif __rathen_end__ #endif
Require Import FP.Core. Require Import FP.Data.Unit. Class Monad (m:qtype -> qtype) := { ret : forall {A}, dom (A ⇒ m A) ; bind : forall {A B}, dom (m A ⇒ (A ⇒ m B) ⇒ m B) ; bind_ret_kon : forall {A} (aM:dom (m A)), bind ∙ aM ∙ ret ≃ aM ; bind_ret_arg : forall {A B} (a:dom A) (k:dom (A ⇒ m B)), bind ∙ (ret ∙ a) ∙ k ≃ k ∙ a ; bind_associativity : forall {A B C} (aM:dom (m A)) (k₁:dom (A ⇒ m B)) (k₂:dom (B ⇒ m C)), bind ∙ (bind ∙ aM ∙ k₁) ∙ k₂ ≃ bind ∙ aM ∙ (λ a → bind ∙ (k₁ ∙ a) ∙ k₂) }. Global Opaque ret. Global Opaque bind. Notation "e >>= k" := (bind ∙ e ∙ k). Notation "x ← e₁ ;; e₂" := (bind ∙ e₁ ∙ (λ x → e₂)). Ltac MonadRewrite := match goal with | |- ⟨ ?aM >>= ret IN _ |_| _ ⟩ => ReplaceBy (bind_ret_kon aM) | |- ⟨ ret ∙ ?a >>= ?k IN _ |_| _ ⟩ => ReplaceBy (bind_ret_arg a k) | |- ⟨ bind ∙ (bind ∙ ?aM ∙ ?k₁) ∙ ?k₂ IN _ |_| _ ⟩ => ReplaceBy (bind_associativity aM k₁ k₂) end. Section Monad. Context {m} `{! Monad m }. Definition extend {A B} : dom ((A ⇒ m B) ⇒ (m A ⇒ m B)) := λ f aM → bind ∙ aM ∙ f. Definition mcompose {A B C} : dom ((B ⇒ m C) ⇒ (A ⇒ m B) ⇒ (A ⇒ m C)) := λ g f a → bind ∙ (f ∙ a) ∙ g. Definition mmap {A B} : dom ((A ⇒ B) ⇒ (m A ⇒ m B)) := λ f aM → a ← aM ;; ret $ f ∙ a. Definition seq {A B} : dom (m A ⇒ m B ⇒ m B) := λ aM bM → _ ← aM ;; bM. Definition kret {A B} : dom ((A ⇒ B) ⇒ (A ⇒ m B)) := λ f → ret ⊙ f. End Monad. Notation "k =<< e" := (extend ∙ k ∙ e). Notation "g m⊙ f" := (mcompose ∙ g ∙ f). Notation "e₁ ;; e₂" := (_ ← e₁ ;; e₂). Section Laws. Context {m} `{! Monad m }. Definition mcompose_associativity {A B C D} (h:dom (C ⇒ m D)) (g:dom (B ⇒ m C)) (f:dom (A ⇒ m B)) : ((h m⊙ g) m⊙ f) ≃ (h m⊙ (g m⊙ f)). Proof. Re fail || MonadRewrite. Qed. Definition mcompose_left_unit {A B} (f:dom (A ⇒ m B)) : (ret m⊙ f) ≃ f. Proof. Re fail || MonadRewrite. Qed. Definition mcompose_right_unit {A B} (f:dom (A ⇒ m B)) : (f m⊙ ret) ≃ f. Proof. Re fail || MonadRewrite. Qed. End Laws. Ltac KleisliRewrite := match goal with | |- ⟨ (?h m⊙ ?g) m⊙ ?f IN _ |_| _ ⟩ => ReplaceBy (mcompose_associativity h g f) | |- ⟨ ret m⊙ ?f IN _ |_| _ ⟩ => ReplaceBy (mcompose_left_unit f) | |- ⟨ ?f m⊙ ret IN _ |_| _ ⟩ => ReplaceBy (mcompose_right_unit f) end. Ltac KleisliUnassoc := match goal with | |- ⟨ ?h m⊙ ?g m⊙ ?f IN _ |_| _ ⟩ => ReplaceBy (symmetry (mcompose_associativity h g f)) end. Class MonadPlus m `{! Monad m } := { mzero : forall {A}, dom (m A) ; mplus : forall {A}, dom (m A ⇒ m A ⇒ m A) ; mplus_mzero_left : forall {A} (aM:dom (m A)), mplus ∙ mzero ∙ aM ≃ aM ; mplus_mzero_right : forall {A} (aM:dom (m A)), mplus ∙ aM ∙ mzero ≃ aM ; mplus_distributivity : forall {A B} (aM₁ aM₂:dom (m A)) (k:dom (A ⇒ m B)), bind ∙ (mplus ∙ aM₁ ∙ aM₂) ∙ k ≃ mplus ∙ (bind ∙ aM₁ ∙ k) ∙ (bind ∙ aM₂ ∙ k) ; bind_mzero_left : forall {A B} (k:dom (A ⇒ m B)), bind ∙ mzero ∙ k ≃ mzero ; bind_mzero_right : forall {A B} (aM:dom (m A)), bind ∙ aM ∙ (λ _ → mzero (A:=B)) ≃ mzero }. Ltac MonadPlusRewrite := match goal with | |- ⟨ mzero >>= ?k IN _ |_| _ ⟩ => ReplaceBy (bind_mzero_left k) end. Notation "e₁ m+ e₂" := (mplus ∙ e₁ ∙ e₂). Class MonadMorphism m₁ m₂ `{! Monad m₁ ,! Monad m₁ } := { promote : forall {A}, dom (m₁ A ⇒ m₂ A) }. Class MonadState S m `{! Monad m } := { get : dom (m S) ; put : dom (S ⇒ m unit) }. Class MonadRet t := { mret : forall {m} `{! Monad m }, forall {A}, dom (m A ⇒ t m A) }. Global Opaque mret.
Confirming the hottest travel trend of 2011, Poronui Luxury Sport Lodge now offers an increasing number of guests the chance to go ‘glamping’. The Safari Camp, built well-away from the main facility, offers guests an experience reminiscent of the ‘Poronui pioneers’. Groups of visitors who tire of soaking up the pleasures and refinement of the English hunting style lodge can now opt to flit away for a night or two and enjoy such earthy pleasures as a meal eaten with friends around a campfire. The safari themed tents all feature hot gas showers, crisp cotton sheets and ample space to have meals outdoors while listening to the wild Mohaka River. Guests can cook the food they have caught that day or soothe their bones next to the fire after a strenuous day of riding. Glamping Poronui style includes a visit to sweetly the appointed cabins featuring canvas roofs, with timber walls and floors. The 16,000 acre property representing an untamed slice of New Zealand’s North Island, provides the ‘wild at heart’ a chance to escape. There are vast opportunities to trek, hunt, fly-fish and horse ride within the expansive grounds. Poronui is also equipped with all the modern-cons including; an olympic standard sporting clays course, sauna, gymnasium and underground wine cellar. Purchased by the Westervelt Company in 2007, the property has been developed by American, Mark Blake since 1998 and continues to be an ethically and sustainably maintained property. Poronui Lodge built in 1998, added its original the Safari Camp in 1999 and made the addition of the glamorous Blake House facility during the year 2000. During the ‘return to nature’ trend in tourism Poronui managers says they have recently enjoyed an increase in the number of guests requesting time away from the hotel style facility and guest wishing to customise their experience and try all parts of the estate. Poronui is 4½ hours drive from Auckland, or a 25 minute flight from Auckland and a 40 minute drive from Taupo Airport. A flight from Christchurch to Taupo takes one hour, plus the 40 minute drive from the airport to the property. Poronui is 5 hours drive from Wellington.
Formal statement is: lemma cCons_0_Nil_eq [simp]: "0 ## [] = []" Informal statement is: The list $0$ followed by the empty list is the empty list.
analysis_atm = Dict( :U => "atm_analysis_U.nc", )
Penguin Wellness is a division of Tracktion Healthcare which is a full line wellness and disease management company with complete employee tracking, case management, and predictive modeling capabilities. Developing programs for self funded and fully insured companies. Working with small and large companies. Entry level or comprehensive wellness programs. Disease management and case management. Matt has been in the health and wellness industry for 16 years. His primary focus in his career has been working with athletes on their speed and strength development as one of the nation’s top sports performance specialist. His career path has enabled him to design and implement his wellness beliefs and software programs into a very successful corporate wellness model. He holds a degree in Sociology from the University of Tennessee and a Masters of Science degree in Exercise Science and Health Promotion from the California University of Pennsylvania. He also holds eight other specialty certifications is the areas of nutrition, fitness therapy, youth fitness, sport conditioning, cancer rehabilitation, speed and explosion, performance enhancement, and track and field. Other – Matt is a former football player at the University of Tennessee and is a Unites States Powerlifting Champion. RN, CCM, COHN has been a registered nurse for 32 years. After completing her education at Union University in Jackson, TN, Mrs. Nelson has held a variety of positions including case and disease management, rehabilitation nursing, homecare and acute care management as well as direct patient care services. Ms. Nelson has her own success story in relation to disease management, after reaching 297 pounds and facing diagnoses of pre-diabetes and pre-hypertension, Ms. Nelson made lifestyle changes which resulted in a 115 pound weight loss with normal lab studies and blood pressure. Ms. Nelson has maintained her personal wellness for 28 years and enjoys assisting others in health coaching to realize their health and wellness goals. Over the past twenty three years, Ms. Johnson has been actively involved in the formation of healthcare public policy and established New Horizons Solutions, Inc. in response to employers’ needs and Medicaid’s need to contain health care costs by focusing on prevention, wellness and disease management. Ms. Johnson has been actively involved in legislation affecting health, families and communities lobbying over three hundred pieces of legislation since 1986. She has served on health care public policy workgroups in Washington, D.C. and served on numerous boards and workgroups. Ms. Johnson earned a B.S. degree in Medical Technology and completed postgraduate study in Comparative Medicine. She worked nine years in the field of medical technology and served as the supervisor of the State of Illinois’ Tissue Typing lab in Chicago. Lindsey graduated from Murray State University with degrees in Food, Nutrition, and Dietetics. She has extensive experience in a medical setting as a clinical dietitian. She has also worked with post cardiac patients and cancer patients relative to their nutritional needs and requirements as well as working with patients in a nursing home setting. Her vast knowledge and skills have also been utilized in kidney dialysis centers. She is a registered dietitian and clinical dietitian. Other – Lindsey ran track at Murray State University. Over the past 15 years, Wesley has been heavily involved in the ownership of fitness facilities, the management of businesses, and the leadership of men and women. Wesley has extensive experience in personal training and health coaching professional athletes, country music artists, and other top executives in the Tennessee and the surrounding states. Wesley’s love of training has taken him into the corporate world. He is seen as an authority in wellness, especially his passion to help people manage weight problems such as obesity and the detrimental effects of this condition. Wesley attended Tennessee State University. Other - Wesley is a former natural body building champion and has won titles in many contest like the “Show Me Naturals”, one of the largest bodybuilding competitions in the Unites States. Wesley is also a former US Marine. Buddy graduated in 2003 from High Tech Institute in Nashville with a Associate of Applied Sciences degree in Massage Therapy where he was a member of the Alpha Beta Kappa National Honor Society, received the perfect attendance and classroom leadership awards as well as the Outreach and Dedication Award for the Massage Therapy Program. In the 5 years plus since graduating, he has used his knowledge and natural instinct to provide table and chair massage to hundreds of clients, including members of the Nashville Predators, Tennessee Titans, and members of the music community in Nashville. Integrating a combination of deep tissue, trigger point release and sports massage techniques, Buddy provides a massage that will help relieve the daily aches and pains that your body may experience and leave you feeling revitalized! Licensed Zumba Instructor, ACE Certified Group Fitness Instructor, & Certified Xtend Barre Instructor, Christy has had a lifelong passion for fitness and dance. As a tap, ballet and jazz dance student for six years, she cultivated her natural sense of rhythm and developed a dedication to healthy living. She is an ACE Certified Group Fitness Instructor and a Certified Xtend Barre Instructor. Xtend is Pilates and dance AMPlified. She is also licensed in Zumba Basic I, Basic II, Toning, Gold and Zumbatomic. Zumba is "exercise in disguise", a mix of dance-based cardio and resistance sculpting set to international rhythms. Christy is licensed through Zumba Fitness, LLC and is a member of ZIN (Zumba Instructor Network).
#include <smtbx/refinement/constraints/scatterer_parameters.h> #include <boost/python/class.hpp> #include <boost/python/make_constructor.hpp> #include <boost/python/return_value_policy.hpp> #include <boost/python/return_internal_reference.hpp> #include <boost/python/str.hpp> #include <scitbx/array_family/boost_python/shared_wrapper.h> #include <sstream> #include <iostream> namespace smtbx { namespace refinement { namespace constraints { namespace boost_python { struct scatterer_parameters_wrapper { typedef scatterer_parameters wt; static af::shared<wt> *init_shared_scatterer_parameters(af::const_ref<wt::scatterer_type> const &scatterers) { af::shared<wt> *result = new af::shared<wt>((af::reserve(scatterers.size()))); for (std::size_t i_sc=0; i_sc<scatterers.size(); ++i_sc) { result->push_back(wt(&scatterers[i_sc])); } return result; } static boost::python::str component_annotations(af::const_ref<wt> const &self) { std::ostringstream o; o.str().reserve(50*self.size()); write_component_annotations(self, o); return boost::python::str(o.str()); } static void wrap() { using namespace boost::python; typedef return_internal_reference<> rir_t; rir_t rir; class_<wt>("scatterer_parameters", no_init) .def(init<wt::scatterer_type *>(arg("scatterer"))) .def(init<wt::scatterer_type *, asu_parameter *, asu_parameter *, asu_parameter *, asu_parameter *>( (arg("scatterer"), arg("site"), arg("occupancy"), arg("u"), arg("anharmonic_adp")))) .add_property("scatterer", make_getter(&wt::scatterer, rir)) .add_property("site" , make_getter(&wt::site, rir) , make_setter(&wt::site, rir)) .add_property("occupancy", make_getter(&wt::occupancy, rir) , make_setter(&wt::occupancy, rir)) .add_property("u" , make_getter(&wt::u, rir) , make_setter(&wt::u, rir)) .add_property("anharmonic_adp" , make_getter(&wt::anharmonic_adp, rir) , make_setter(&wt::anharmonic_adp, rir)) .add_property("fp" , make_getter(&wt::fp, rir) , make_setter(&wt::fp, rir)) .add_property("fdp", make_getter(&wt::fdp, rir) , make_setter(&wt::fdp, rir)) ; scitbx::af::boost_python::shared_wrapper<wt, rir_t> ::wrap("shared_scatterer_parameters") .def("__init__", make_constructor(init_shared_scatterer_parameters)) .def("mapping_to_grad_fc", mapping_to_grad_fc) .def("component_annotations", component_annotations, "Comma-separated annotations for each component of each parameter," " in grad Fc order") ; } }; void wrap_scatterer_parameters() { scatterer_parameters_wrapper::wrap(); } }}}}
""" pretty(doc) Pretty print the parsed HTML `doc`. """ function pretty(doc) io = IOBuffer() print(io, doc; pretty=true) return String(take!(io)) end function map!(f::Function, doc::HTMLDocument) for elem in PreOrderDFS(doc.root) if elem isa HTMLElement # Changing elem directly doesn't work, so we loop direct children. children = elem.children for i in 1:length(children) elem.children[i] = f(elem.children[i]) end end # else (isa HTMLText) is handled by the fact that we loop direct children. end return doc end function clean(elem::HTMLElement{T}) where T children = elem.children parent = elem.parent attributes = Dict{AbstractString,AbstractString}() return HTMLElement{T}(children, parent, attributes) end function remove_extra_href_info(entry::Pair) url = last(entry) symbol_loc = findfirst(r"\?|#", url) if isnothing(symbol_loc) return entry else symbol_loc_start = first(findfirst(r"\?|#", url)) stripped = url[1:symbol_loc_start] * "[...]" new_entry::Pair = first(entry) => stripped return new_entry end end function remove_extra_href_info(dic::Dict)::Dict pairs = [remove_extra_href_info(entry) for entry in dic] return Dict(pairs) end function clean(elem::HTMLElement{:a}) children = elem.children parent = elem.parent attributes = filter(entry -> first(entry) == "href", elem.attributes) updated_attributes = remove_extra_href_info(attributes) return HTMLElement{:a}(children, parent, updated_attributes) end function clean(elem::T) where T<:Union{HTMLElement{:style},HTMLElement{:script}} children = [] parent = elem.parent attributes = Dict{AbstractString,AbstractString}() return T(children, parent, attributes) end function contains_title_description(entry) text = string(entry)::String return contains(text, r"title|description") end function clean(elem::HTMLElement{:meta}) children = elem.children parent = elem.parent A = elem.attributes K = keys(A) if !any(contains_title_description(A)) A = Dict{AbstractString,AbstractString}() end return HTMLElement{:meta}(children, parent, A) end function clean_tree(elem::HTMLElement) return clean(elem) end function clean_tree(elem::HTMLText) return elem end """ body(content::String) Return only the body from the HTML `content`. """ function body(content::String) doc = parsehtml(content) for elem in PreOrderDFS(doc.root) if elem isa HTMLElement && tag(elem) == :body return string(elem)::String end end @warn "Couldn't find body in content:\n$content" return content end """ clean(content::String) Return only the parts of the HTML which are visible in the rendered page. This assumes that a page has changed when a reader can see a change, which seems like a reasonable assumption. Note that this assumption may be violated when a elements are updated on the fly via Javascript. """ function clean(content::String) doc = parsehtml(content) map!(clean_tree, doc) text = pretty(doc) return """ <!-- This HTML document was cleaned up (simplified) by `Skans.clean`. --> $text """ end
Speech and language pathologists in Chicago IL for evaluation and treatment of expressive and receptive language, articulation/phonology, oral motor, feeding, social pragmatic skills and sensory integration. Mary has been practicing for over 20 years and is co-owner of Oak Tree Developmental Center. She has worked within the school and private practice. She is a dedicated professional who enjoys working with children and their families. She encourages them in a caring manner to achieve their goals. Mary has extensive experience in the diagnosis and intervention of children with a variety of communication disorders including receptive and expressive language, autism, apraxia of speech, oral motor and articulation. She has additional training in PECS, DIR Floortime, TEACHH, PROMPT and Social Thinking. Mary obtained a Bachelor’s degree in Audiology and Speech Pathology from Michigan State University and a Master’s degree in Speech Language Pathology from Northwestern University. She is a certified member of the American Speech Language Hearing Association (ASHA) and holds a teaching certificate with the Illinois State Board of Education. She is a certified pediatric specialist and evaluator for Early Intervention in Illinois. Carlin has been a practicing pediatric speech-language pathologist since 2012. She is very outgoing and creative, and in turn families and kids love working with her! Carlin is excellent at recognizing how to motivate an individual child in order to achieve their maximum potential. She has experience providing diagnostics and intervention to children with a variety of communication disorders including: receptive and expressive language delays, autism, hearing loss, and articulation disorders. Carlin also has additional training in Picture Exchange Communication System (PECS), Augmentative and Alternative Communication (AAC) systems, social communication, phonological awareness, American Sign Language, and Cued Speech. Carlin holds a Bachelor’s of Science in Audiology and Speech Pathology with a Minor in Linguistics from Miami University and a Master’s of Science in Speech and Language Pathology from Gallaudet University. Katherine received her Bachelor’s and Master’s degrees from the University of Illinois Urbana-Champaign and has been working at Oak Tree Developmental Center since 2010. She has experience working with a variety of disorders including autism spectrum disorders, childhood apraxia of speech, articulation/phonology, fluency, genetic/chromosomal syndromes, and expressive and receptive language delays and deficits. Katherine enjoys leading multiple social groups for both preschool and school aged children at Oak Tree. Targets of the social groups revolve around strengthening pragmatic language, problem solving, teamwork and collaborative play. Katherine’s continuing education experiences include: Social Thinking, PECS Basic Training, and she has completed training for the SOS Feeding approach. She is a member of the American Speech Language Hearing Association (ASHA). Alex has been with Oak Tree Developmental Center since 2013. She has extensive experience in the areas of expressive and receptive language, autism, social/pragmatic language, feeding, fluency and articulation disorders. Alex provides therapy that is tailored to each child’s individual and unique goals and uses a wide variety of therapy techniques to achieve optimal progress. Her welcoming and positive approach to therapy allows children to be comfortable and blossom during their therapy sessions. Alex is a certified Early Intervention specialist and has training in therapeutic intervention to address physiological and motor-based speech disorders. She has her Bachelor’s from the University of Illinois and her Master’s in Speech Language Pathology from Illinois State University.
#' OAuth token objects. #' #' These objects represent the complete set of data needed for OAuth access: #' an app, an endpoint, cached credentials and parameters. They should be #' created through their constructor functions [oauth1.0_token()] #' and [oauth2.0_token()]. #' #' @section Methods: #' * `cache()`: caches token to disk #' * `sign(method, url)`: returns list of url and config #' * `refresh()`: refresh access token (if possible) #' * `validate()`: TRUE if the token is still valid, FALSE otherwise #' #' @section Caching: #' OAuth tokens are cached on disk in a file called `.httr-oauth` #' saved in the current working directory. Caching is enabled if: #' #' * The session is interactive, and the user agrees to it, OR #' * The `.httr-oauth` file is already present, OR #' * `getOption("httr_oauth_cache")` is `TRUE` #' #' You can suppress caching by setting the `httr_oauth_cache` option to #' `FALSE`. #' #' Tokens are cached based on their endpoint and parameters. #' #' The cache file should not be included in source code control or R packages #' (because it contains private information), so httr will automatically add #' the appropriate entries to `.gitignore` and `.Rbuildignore` if needed. #' #' @docType class #' @keywords internal #' @format An R6 class object. #' @importFrom R6 R6Class #' @export #' @name Token-class Token <- R6::R6Class("Token", list( endpoint = NULL, app = NULL, credentials = NULL, params = NULL, cache_path = FALSE, private_key = NULL, initialize = function(app, endpoint, params = list(), credentials = NULL, private_key = NULL, cache_path = getOption("httr_oauth_cache")) { stopifnot( is.oauth_endpoint(endpoint) || !is.null(credentials), is.oauth_app(app), is.list(params) ) self$app <- app self$endpoint <- endpoint self$params <- params self$cache_path <- use_cache(cache_path) self$private_key <- private_key if (!is.null(credentials)) { # Use credentials created elsewhere - usually for tests self$credentials <- credentials return(self) } # Are credentials cache already? if (self$load_from_cache()) { self } else { self$init_credentials() self$cache() } }, print = function(...) { cat("<Token>\n", sep = "") print(self$endpoint) print(self$app) cat("<credentials> ", paste0(names(self$credentials), collapse = ", "), "\n", sep = "" ) cat("---\n") }, cache = function(path = self$cache_path) { cache_token(self, path) self }, load_from_cache = function() { if (is.null(self$cache_path)) return(FALSE) cached <- fetch_cached_token(self$hash(), self$cache_path) if (is.null(cached)) return(FALSE) self$endpoint <- cached$endpoint self$app <- cached$app self$credentials <- cached$credentials self$params <- cached$params TRUE }, hash = function() { # endpoint = which site # app = client identification # params = scope msg <- serialize( list(self$endpoint, self$app, normalize_scopes(self$params$scope)), NULL ) # for compatibility with digest::digest() paste(openssl::md5(msg[-(1:14)]), collapse = "") }, sign = function() { stop("Must be implemented by subclass", call. = FALSE) }, refresh = function() { stop("Must be implemented by subclass", call. = FALSE) }, init_credentials = function() { stop("Must be implemented by subclass", call. = FALSE) } )) #' Generate an oauth1.0 token. #' #' This is the final object in the OAuth dance - it encapsulates the app, #' the endpoint, other parameters and the received credentials. #' #' See [Token()] for full details about the token object, and the #' caching policies used to store credentials across sessions. #' #' @inheritParams init_oauth1.0 #' @param as_header If `TRUE`, the default, sends oauth in header. #' If `FALSE`, adds as parameter to url. #' @param cache A logical value or a string. `TRUE` means to cache #' using the default cache file `.httr-oauth`, `FALSE` means #' don't cache, and `NA` means to guess using some sensible heuristics. #' A string means use the specified path as the cache file. #' @return A `Token1.0` reference class (RC) object. #' @family OAuth #' @export oauth1.0_token <- function(endpoint, app, permission = NULL, as_header = TRUE, private_key = NULL, cache = getOption("httr_oauth_cache")) { params <- list( permission = permission, as_header = as_header ) Token1.0$new( app = app, endpoint = endpoint, params = params, private_key = private_key, cache_path = cache ) } #' @export #' @rdname Token-class Token1.0 <- R6::R6Class("Token1.0", inherit = Token, list( init_credentials = function(force = FALSE) { self$credentials <- init_oauth1.0( self$endpoint, self$app, permission = self$params$permission, private_key = self$private_key ) }, can_refresh = function() { FALSE }, refresh = function() { stop("Not implemented") }, sign = function(method, url) { oauth <- oauth_signature( url, method, self$app, self$credentials$oauth_token, self$credentials$oauth_token_secret, self$private_key ) if (isTRUE(self$params$as_header)) { c(request(url = url), oauth_header(oauth)) } else { url <- parse_url(url) url$query <- c(url$query, oauth) request(url = build_url(url)) } } )) #' Generate an oauth2.0 token. #' #' This is the final object in the OAuth dance - it encapsulates the app, #' the endpoint, other parameters and the received credentials. It is a #' reference class so that it can be seamlessly updated (e.g. using #' `$refresh()`) when access expires. #' #' See [Token()] for full details about the token object, and the #' caching policies used to store credentials across sessions. #' #' @inheritParams init_oauth2.0 #' @param as_header If `TRUE`, the default, configures the token to add #' itself to the bearer header of subsequent requests. If `FALSE`, #' configures the token to add itself as a url parameter of subsequent #' requests. #' @param credentials Advanced use only: allows you to completely customise #' token generation. #' @inheritParams oauth1.0_token #' @return A `Token2.0` reference class (RC) object. #' @family OAuth #' @export oauth2.0_token <- function(endpoint, app, scope = NULL, user_params = NULL, type = NULL, use_oob = getOption("httr_oob_default"), oob_value = NULL, as_header = TRUE, use_basic_auth = FALSE, cache = getOption("httr_oauth_cache"), config_init = list(), client_credentials = FALSE, credentials = NULL, query_authorize_extra = list()) { params <- list( scope = scope, user_params = user_params, type = type, use_oob = use_oob, oob_value = oob_value, as_header = as_header, use_basic_auth = use_basic_auth, config_init = config_init, client_credentials = client_credentials, query_authorize_extra = query_authorize_extra ) Token2.0$new( app = app, endpoint = endpoint, params = params, credentials = credentials, cache_path = if (is.null(credentials)) cache else FALSE ) } #' @export #' @rdname Token-class Token2.0 <- R6::R6Class("Token2.0", inherit = Token, list( init_credentials = function() { self$credentials <- init_oauth2.0(self$endpoint, self$app, scope = self$params$scope, user_params = self$params$user_params, type = self$params$type, use_oob = self$params$use_oob, oob_value = self$params$oob_value, use_basic_auth = self$params$use_basic_auth, config_init = self$params$config_init, client_credentials = self$params$client_credentials, query_authorize_extra = self$params$query_authorize_extra ) }, can_refresh = function() { !is.null(self$credentials$refresh_token) }, refresh = function() { cred <- refresh_oauth2.0( self$endpoint, self$app, self$credentials, self$params$user_params, self$params$use_basic_auth ) if (is.null(cred)) { remove_cached_token(self) } else { self$credentials <- cred self$cache() } self }, sign = function(method, url) { if (self$params$as_header) { request(url = url, headers = c( Authorization = paste("Bearer", self$credentials$access_token) )) } else { url <- parse_url(url) url$query$access_token <- self$credentials$access_token request(url = build_url(url)) } }, validate = function() { validate_oauth2.0(self$endpoint, self$credentials) }, revoke = function() { revoke_oauth2.0(self$endpoint, self$credentials) } )) #' Generate OAuth token for service accounts. #' #' Service accounts provide a way of using OAuth2 without user intervention. #' They instead assume that the server has access to a private key used #' to sign requests. The OAuth app is not needed for service accounts: #' that information is embedded in the account itself. #' #' @inheritParams oauth2.0_token #' @inheritParams jwt_signature #' @param secrets Secrets loaded from JSON file, downloaded from console. #' @param ... any additional claims for the token #' @family OAuth #' @export #' @examples #' \dontrun{ #' endpoint <- oauth_endpoints("google") #' secrets <- jsonlite::fromJSON("~/Desktop/httrtest-45693cbfac92.json") #' scope <- "https://www.googleapis.com/auth/bigquery.readonly" #' #' token <- oauth_service_token(endpoint, secrets, scope) #' } oauth_service_token <- function(endpoint, secrets, scope = NULL, sub = NULL, ...) { if (!is.oauth_endpoint(endpoint)) { stop("`endpoint` must be an OAuth endpoint", call. = FALSE) } if (!is.list(secrets)) { stop("`secrets` must be a list.", call. = FALSE) } scope <- check_scope(scope) TokenServiceAccount$new( endpoint = endpoint, secrets = secrets, params = list(scope = scope, sub = sub, ...) ) } #' @export #' @rdname Token-class TokenServiceAccount <- R6::R6Class("TokenServiceAccount", inherit = Token2.0, list( secrets = NULL, initialize = function(endpoint, secrets, params) { self$endpoint <- endpoint self$secrets <- secrets self$params <- params self$refresh() }, can_refresh = function() { TRUE }, refresh = function() { self$credentials <- do.call(init_oauth_service_account, c(list(secrets = self$secrets), self$params)) self }, sign = function(method, url) { config <- add_headers( Authorization = paste("Bearer", self$credentials$access_token %||% self$credentials$id_token) ) request_build(method = method, url = url, config) }, # Never cache cache = function(path) self, load_from_cache = function() self )) normalize_scopes <- function(x) { stats::setNames(sort(unique(x)), NULL) }
EZ-Builder contains example projects which demonstrate functions and features of the software. The example projects can be accessed by using the File Open button on the main menu. Locate the OPEN button within the FILE section of the top menu. Press it and the Open Dialog window will be displayed. The Example Projects are located in the Examples files section. They can be accessed by pressing the Examples button. You may view the contents of each example folder by double clicking on the folder name within the list. Also, to load a project press the OPEN button. *Note: Pressing OPEN will load a new project, so be sure your current project is saved prior to opening a new one. EZ-Script Examples: This is a folder with examples on how to write code to perform some things. As well as demonstrating some syntax, this folder is more "functional" examples than syntax examples. This also contains examples of every EZ-Script function. For example, if you search for the word "repeat" in this folder, you will find an example that shows how to use ez-script repeat command. Legacy Robots: This folder contains older robot projects created by DJ Sures for these robots. The files in this folder date back to the very beginning of EZ-Robot in 2011. Many of these files are out dated and may not load, however they are included for historical records. Model Templates: The projects within this folder contain 3D assemblies of the revolution robots. These projects do not included movement panels or any code. The search field will allow you search through the files in the current folder.
[STATEMENT] lemma parts_insert_Nonce [simp]: "parts (insert (Nonce N) H) = insert (Nonce N) (parts H)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. parts (insert (Nonce N) H) = insert (Nonce N) (parts H) [PROOF STEP] apply (rule parts_insert_eq_I) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>x. x \<in> parts (insert (Nonce N) H) \<Longrightarrow> x \<in> insert (Nonce N) (parts H) [PROOF STEP] apply (erule parts.induct, auto) [PROOF STATE] proof (prove) goal: No subgoals! [PROOF STEP] done
Teaching a Healthy Environment to our children. Every parent goes through the same mantras with our kids “clean your room, pick up your toys, put your crayons away”. Most times these declarations of parenthood are met with resistance and the struggle begins. Turning cleaning time into a game that children can WIN is an awesome way to get them to want to clean up. Whether you are a Teacher, Parent, Daycare Nanny, or Summer Camp Leader these cleaning games for children are for you. Make sure to have some small prizes or special experiences when the games are over. Some ideas might be stickers, reading a special book together, a special meal together, a walk on the beach, or a trip to the park. Take a look around the mess and make a list of categories that need picking up. Depending on the environment this can include clothes, toys, shoes, or art supplies. Have the children find and put away each item in the categories. Set a timer and see how much they can put away in a 5 or 10 minute time span. What child does not enjoy an afternoon of dress up? Use an old apron and head scarf and play maid for the day. Pretend the children are there to clean up another family’s home. Make a game imagining how happy the family will be when they get home and all their things are put away. Get the kids involved in a cleaning commercial. Let them help with the script and talk about the importance of putting away their things. Grab your phone and take some footage of them cleaning up their room and playing the part. Great memories you will have and a clean room as a result. For young children learning to count can be fun by counting the toys or crayons as they put them away. Pairing socks together is another way to teach children about numbers and similar objects. Making cleaning fun for kids not only helps your Healthy Environment, but it teaches them lifelong skills. Have a great day with the kids and play your way to clean. ABC Sales & Services is here for you. Whatever you need, your Healthy Environment is what we do. Make 2019 Your Kids Year Of Clean!
/* randist/flat.c * * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 James Theiler, 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 <config.h> #include <math.h> #include <gsl/gsl_rng.h> #include <gsl/gsl_randist.h> /* This is the uniform distribution in the range [a, b) p(x) dx = 1/(b-a) dx if a <= x < b ..... = 0 otherwise */ double gsl_ran_flat (const gsl_rng * r, const double a, const double b) { double u = gsl_rng_uniform (r); /* A uniform distribution over [a,b) */ return a * (1 - u) + b * u; } double gsl_ran_flat_pdf (double x, const double a, const double b) { if (x < b && x >= a) { return 1 / (b - a); } else { return 0; } }
\section{Acknowledgments} This research is part of the Blue Waters sustained-petascale computing project, which is supported by the National Science Foundation (awards OCI-0725070 and ACI-1238993) and the state of Illinois. Blue Waters is a joint effort of the University of Illinois at Urbana-Champaign and its National Center for Supercomputing Applications The authors would like to thank members of the \gls{ARFC} group at the University of Illinois - Urbana Champaign who provided valuable code reviews and proofreading. The authors contributed to this work as described below. Andrei Rykhlevskii conceived and designed the simulations, wrote the paper, prepared figures and/or tables, performed the computation work, contributed to the software product, and reviewed drafts of the paper. Jin Whan Bae conceived and designed the simulations, wrote the paper, contributed to the software product, and reviewed drafts of the paper. Andrei Rykhlevskii is supported by DOE ARPA-E MEITNER program award 1798-1576. Jin Whan Bae is supported by funding received from the DOE Nuclear Energy University Program (Project 16-10512) `Demand-Driven Cycamore Archetypes'. Kathryn D. Huff directed and supervised the work, conceived and designed the simulations, contributed to the software product, and reviewed drafts of the paper. Prof. Huff is supported by the Nuclear Regulatory Commission Faculty Development Program, the National Center for Supercomputing Applications, the NNSA Office of Defense Nuclear Nonproliferation R\&D through the Consortium for Verfication Technologies and the Consortium for Nonproliferation Enabling Capabilities, the International Institute for Carbon Neutral Energy Research (WPI-I2CNER), sponsored by the Japanese Ministry of Education, Culture, Sports, Science and Technology, and DOE ARPA-E MEITNER program award 1798-1576.
[GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc I \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc I) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) ⊢ ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc I, ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.upper I i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.lower I i) x) i) [PROOFSTEP] simp only [← set_integral_congr_set_ae (Box.coe_ae_eq_Icc _)] [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc I \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc I) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) ⊢ ∫ (x : Fin (n + 1) → ℝ) in ↑I, ∑ x_1 : Fin (n + 1), ↑(f' x) (e x_1) x_1 = ∑ x : Fin (n + 1), ((∫ (x_1 : Fin n → ℝ) in ↑(Box.face I x), f (Fin.insertNth x (Box.upper I x) x_1) x) - ∫ (x_1 : Fin n → ℝ) in ↑(Box.face I x), f (Fin.insertNth x (Box.lower I x) x_1) x) [PROOFSTEP] have A := (Hi.mono_set Box.coe_subset_Icc).hasBoxIntegral ⊥ rfl [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc I \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc I) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) A : HasIntegral I ⊥ (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (BoxAdditiveMap.toSMul (Measure.toBoxAdditive volume)) (∫ (x : Fin (n + 1) → ℝ) in ↑I, ∑ i : Fin (n + 1), ↑(f' x) (e i) i) ⊢ ∫ (x : Fin (n + 1) → ℝ) in ↑I, ∑ x_1 : Fin (n + 1), ↑(f' x) (e x_1) x_1 = ∑ x : Fin (n + 1), ((∫ (x_1 : Fin n → ℝ) in ↑(Box.face I x), f (Fin.insertNth x (Box.upper I x) x_1) x) - ∫ (x_1 : Fin n → ℝ) in ↑(Box.face I x), f (Fin.insertNth x (Box.lower I x) x_1) x) [PROOFSTEP] have B := hasIntegral_GP_divergence_of_forall_hasDerivWithinAt I f f' (s ∩ Box.Icc I) (hs.mono (inter_subset_left _ _)) (fun x hx => Hc _ hx.2) fun x hx => Hd _ ⟨hx.1, fun h => hx.2 ⟨h, hx.1⟩⟩ [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc I \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc I) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) A : HasIntegral I ⊥ (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (BoxAdditiveMap.toSMul (Measure.toBoxAdditive volume)) (∫ (x : Fin (n + 1) → ℝ) in ↑I, ∑ i : Fin (n + 1), ↑(f' x) (e i) i) B : HasIntegral I IntegrationParams.GP (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) BoxAdditiveMap.volume (∑ i : Fin (n + 1), (BoxIntegral.integral (Box.face I i) IntegrationParams.GP (fun x => f (Fin.insertNth i (Box.upper I i) x) i) BoxAdditiveMap.volume - BoxIntegral.integral (Box.face I i) IntegrationParams.GP (fun x => f (Fin.insertNth i (Box.lower I i) x) i) BoxAdditiveMap.volume)) ⊢ ∫ (x : Fin (n + 1) → ℝ) in ↑I, ∑ x_1 : Fin (n + 1), ↑(f' x) (e x_1) x_1 = ∑ x : Fin (n + 1), ((∫ (x_1 : Fin n → ℝ) in ↑(Box.face I x), f (Fin.insertNth x (Box.upper I x) x_1) x) - ∫ (x_1 : Fin n → ℝ) in ↑(Box.face I x), f (Fin.insertNth x (Box.lower I x) x_1) x) [PROOFSTEP] rw [continuousOn_pi] at Hc [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ∀ (i : Fin (n + 1)), ContinuousOn (fun y => f y i) (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc I \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc I) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) A : HasIntegral I ⊥ (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (BoxAdditiveMap.toSMul (Measure.toBoxAdditive volume)) (∫ (x : Fin (n + 1) → ℝ) in ↑I, ∑ i : Fin (n + 1), ↑(f' x) (e i) i) B : HasIntegral I IntegrationParams.GP (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) BoxAdditiveMap.volume (∑ i : Fin (n + 1), (BoxIntegral.integral (Box.face I i) IntegrationParams.GP (fun x => f (Fin.insertNth i (Box.upper I i) x) i) BoxAdditiveMap.volume - BoxIntegral.integral (Box.face I i) IntegrationParams.GP (fun x => f (Fin.insertNth i (Box.lower I i) x) i) BoxAdditiveMap.volume)) ⊢ ∫ (x : Fin (n + 1) → ℝ) in ↑I, ∑ x_1 : Fin (n + 1), ↑(f' x) (e x_1) x_1 = ∑ x : Fin (n + 1), ((∫ (x_1 : Fin n → ℝ) in ↑(Box.face I x), f (Fin.insertNth x (Box.upper I x) x_1) x) - ∫ (x_1 : Fin n → ℝ) in ↑(Box.face I x), f (Fin.insertNth x (Box.lower I x) x_1) x) [PROOFSTEP] refine' (A.unique B).trans (sum_congr rfl fun i _ => _) [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ∀ (i : Fin (n + 1)), ContinuousOn (fun y => f y i) (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc I \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc I) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) A : HasIntegral I ⊥ (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (BoxAdditiveMap.toSMul (Measure.toBoxAdditive volume)) (∫ (x : Fin (n + 1) → ℝ) in ↑I, ∑ i : Fin (n + 1), ↑(f' x) (e i) i) B : HasIntegral I IntegrationParams.GP (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) BoxAdditiveMap.volume (∑ i : Fin (n + 1), (BoxIntegral.integral (Box.face I i) IntegrationParams.GP (fun x => f (Fin.insertNth i (Box.upper I i) x) i) BoxAdditiveMap.volume - BoxIntegral.integral (Box.face I i) IntegrationParams.GP (fun x => f (Fin.insertNth i (Box.lower I i) x) i) BoxAdditiveMap.volume)) i : Fin (n + 1) x✝ : i ∈ Finset.univ ⊢ BoxIntegral.integral (Box.face I i) IntegrationParams.GP (fun x => f (Fin.insertNth i (Box.upper I i) x) i) BoxAdditiveMap.volume - BoxIntegral.integral (Box.face I i) IntegrationParams.GP (fun x => f (Fin.insertNth i (Box.lower I i) x) i) BoxAdditiveMap.volume = (∫ (x : Fin n → ℝ) in ↑(Box.face I i), f (Fin.insertNth i (Box.upper I i) x) i) - ∫ (x : Fin n → ℝ) in ↑(Box.face I i), f (Fin.insertNth i (Box.lower I i) x) i [PROOFSTEP] refine' congr_arg₂ Sub.sub _ _ [GOAL] case refine'_1 E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ∀ (i : Fin (n + 1)), ContinuousOn (fun y => f y i) (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc I \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc I) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) A : HasIntegral I ⊥ (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (BoxAdditiveMap.toSMul (Measure.toBoxAdditive volume)) (∫ (x : Fin (n + 1) → ℝ) in ↑I, ∑ i : Fin (n + 1), ↑(f' x) (e i) i) B : HasIntegral I IntegrationParams.GP (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) BoxAdditiveMap.volume (∑ i : Fin (n + 1), (BoxIntegral.integral (Box.face I i) IntegrationParams.GP (fun x => f (Fin.insertNth i (Box.upper I i) x) i) BoxAdditiveMap.volume - BoxIntegral.integral (Box.face I i) IntegrationParams.GP (fun x => f (Fin.insertNth i (Box.lower I i) x) i) BoxAdditiveMap.volume)) i : Fin (n + 1) x✝ : i ∈ Finset.univ ⊢ BoxIntegral.integral (Box.face I i) IntegrationParams.GP (fun x => f (Fin.insertNth i (Box.upper I i) x) i) BoxAdditiveMap.volume = ∫ (x : Fin n → ℝ) in ↑(Box.face I i), f (Fin.insertNth i (Box.upper I i) x) i [PROOFSTEP] have := Box.continuousOn_face_Icc (Hc i) (Set.right_mem_Icc.2 (I.lower_le_upper i)) [GOAL] case refine'_1 E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ∀ (i : Fin (n + 1)), ContinuousOn (fun y => f y i) (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc I \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc I) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) A : HasIntegral I ⊥ (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (BoxAdditiveMap.toSMul (Measure.toBoxAdditive volume)) (∫ (x : Fin (n + 1) → ℝ) in ↑I, ∑ i : Fin (n + 1), ↑(f' x) (e i) i) B : HasIntegral I IntegrationParams.GP (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) BoxAdditiveMap.volume (∑ i : Fin (n + 1), (BoxIntegral.integral (Box.face I i) IntegrationParams.GP (fun x => f (Fin.insertNth i (Box.upper I i) x) i) BoxAdditiveMap.volume - BoxIntegral.integral (Box.face I i) IntegrationParams.GP (fun x => f (Fin.insertNth i (Box.lower I i) x) i) BoxAdditiveMap.volume)) i : Fin (n + 1) x✝ : i ∈ Finset.univ this : ContinuousOn ((fun y => f y i) ∘ Fin.insertNth i (Box.upper I i)) (↑Box.Icc (Box.face I i)) ⊢ BoxIntegral.integral (Box.face I i) IntegrationParams.GP (fun x => f (Fin.insertNth i (Box.upper I i) x) i) BoxAdditiveMap.volume = ∫ (x : Fin n → ℝ) in ↑(Box.face I i), f (Fin.insertNth i (Box.upper I i) x) i [PROOFSTEP] have := (this.integrableOn_compact (μ := volume) (Box.isCompact_Icc _)).mono_set Box.coe_subset_Icc [GOAL] case refine'_1 E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ∀ (i : Fin (n + 1)), ContinuousOn (fun y => f y i) (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc I \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc I) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) A : HasIntegral I ⊥ (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (BoxAdditiveMap.toSMul (Measure.toBoxAdditive volume)) (∫ (x : Fin (n + 1) → ℝ) in ↑I, ∑ i : Fin (n + 1), ↑(f' x) (e i) i) B : HasIntegral I IntegrationParams.GP (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) BoxAdditiveMap.volume (∑ i : Fin (n + 1), (BoxIntegral.integral (Box.face I i) IntegrationParams.GP (fun x => f (Fin.insertNth i (Box.upper I i) x) i) BoxAdditiveMap.volume - BoxIntegral.integral (Box.face I i) IntegrationParams.GP (fun x => f (Fin.insertNth i (Box.lower I i) x) i) BoxAdditiveMap.volume)) i : Fin (n + 1) x✝ : i ∈ Finset.univ this✝ : ContinuousOn ((fun y => f y i) ∘ Fin.insertNth i (Box.upper I i)) (↑Box.Icc (Box.face I i)) this : IntegrableOn ((fun y => f y i) ∘ Fin.insertNth i (Box.upper I i)) ↑(Box.face I i) ⊢ BoxIntegral.integral (Box.face I i) IntegrationParams.GP (fun x => f (Fin.insertNth i (Box.upper I i) x) i) BoxAdditiveMap.volume = ∫ (x : Fin n → ℝ) in ↑(Box.face I i), f (Fin.insertNth i (Box.upper I i) x) i [PROOFSTEP] exact (this.hasBoxIntegral ⊥ rfl).integral_eq [GOAL] case refine'_2 E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ∀ (i : Fin (n + 1)), ContinuousOn (fun y => f y i) (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc I \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc I) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) A : HasIntegral I ⊥ (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (BoxAdditiveMap.toSMul (Measure.toBoxAdditive volume)) (∫ (x : Fin (n + 1) → ℝ) in ↑I, ∑ i : Fin (n + 1), ↑(f' x) (e i) i) B : HasIntegral I IntegrationParams.GP (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) BoxAdditiveMap.volume (∑ i : Fin (n + 1), (BoxIntegral.integral (Box.face I i) IntegrationParams.GP (fun x => f (Fin.insertNth i (Box.upper I i) x) i) BoxAdditiveMap.volume - BoxIntegral.integral (Box.face I i) IntegrationParams.GP (fun x => f (Fin.insertNth i (Box.lower I i) x) i) BoxAdditiveMap.volume)) i : Fin (n + 1) x✝ : i ∈ Finset.univ ⊢ BoxIntegral.integral (Box.face I i) IntegrationParams.GP (fun x => f (Fin.insertNth i (Box.lower I i) x) i) BoxAdditiveMap.volume = ∫ (x : Fin n → ℝ) in ↑(Box.face I i), f (Fin.insertNth i (Box.lower I i) x) i [PROOFSTEP] have := Box.continuousOn_face_Icc (Hc i) (Set.left_mem_Icc.2 (I.lower_le_upper i)) [GOAL] case refine'_2 E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ∀ (i : Fin (n + 1)), ContinuousOn (fun y => f y i) (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc I \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc I) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) A : HasIntegral I ⊥ (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (BoxAdditiveMap.toSMul (Measure.toBoxAdditive volume)) (∫ (x : Fin (n + 1) → ℝ) in ↑I, ∑ i : Fin (n + 1), ↑(f' x) (e i) i) B : HasIntegral I IntegrationParams.GP (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) BoxAdditiveMap.volume (∑ i : Fin (n + 1), (BoxIntegral.integral (Box.face I i) IntegrationParams.GP (fun x => f (Fin.insertNth i (Box.upper I i) x) i) BoxAdditiveMap.volume - BoxIntegral.integral (Box.face I i) IntegrationParams.GP (fun x => f (Fin.insertNth i (Box.lower I i) x) i) BoxAdditiveMap.volume)) i : Fin (n + 1) x✝ : i ∈ Finset.univ this : ContinuousOn ((fun y => f y i) ∘ Fin.insertNth i (Box.lower I i)) (↑Box.Icc (Box.face I i)) ⊢ BoxIntegral.integral (Box.face I i) IntegrationParams.GP (fun x => f (Fin.insertNth i (Box.lower I i) x) i) BoxAdditiveMap.volume = ∫ (x : Fin n → ℝ) in ↑(Box.face I i), f (Fin.insertNth i (Box.lower I i) x) i [PROOFSTEP] have := (this.integrableOn_compact (μ := volume) (Box.isCompact_Icc _)).mono_set Box.coe_subset_Icc [GOAL] case refine'_2 E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ∀ (i : Fin (n + 1)), ContinuousOn (fun y => f y i) (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc I \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc I) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) A : HasIntegral I ⊥ (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (BoxAdditiveMap.toSMul (Measure.toBoxAdditive volume)) (∫ (x : Fin (n + 1) → ℝ) in ↑I, ∑ i : Fin (n + 1), ↑(f' x) (e i) i) B : HasIntegral I IntegrationParams.GP (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) BoxAdditiveMap.volume (∑ i : Fin (n + 1), (BoxIntegral.integral (Box.face I i) IntegrationParams.GP (fun x => f (Fin.insertNth i (Box.upper I i) x) i) BoxAdditiveMap.volume - BoxIntegral.integral (Box.face I i) IntegrationParams.GP (fun x => f (Fin.insertNth i (Box.lower I i) x) i) BoxAdditiveMap.volume)) i : Fin (n + 1) x✝ : i ∈ Finset.univ this✝ : ContinuousOn ((fun y => f y i) ∘ Fin.insertNth i (Box.lower I i)) (↑Box.Icc (Box.face I i)) this : IntegrableOn ((fun y => f y i) ∘ Fin.insertNth i (Box.lower I i)) ↑(Box.face I i) ⊢ BoxIntegral.integral (Box.face I i) IntegrationParams.GP (fun x => f (Fin.insertNth i (Box.lower I i) x) i) BoxAdditiveMap.volume = ∫ (x : Fin n → ℝ) in ↑(Box.face I i), f (Fin.insertNth i (Box.lower I i) x) i [PROOFSTEP] exact (this.hasBoxIntegral ⊥ rfl).integral_eq [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) ⊢ ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc I, ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.upper I i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.lower I i) x) i) [PROOFSTEP] rcases I.exists_seq_mono_tendsto with ⟨J, hJ_sub, hJl, hJu⟩ [GOAL] case intro.intro.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : Tendsto (Box.lower ∘ ↑J) atTop (𝓝 I.lower) hJu : Tendsto (Box.upper ∘ ↑J) atTop (𝓝 I.upper) ⊢ ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc I, ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.upper I i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.lower I i) x) i) [PROOFSTEP] have hJ_sub' : ∀ k, Box.Icc (J k) ⊆ Box.Icc I := fun k => (hJ_sub k).trans I.Ioo_subset_Icc [GOAL] case intro.intro.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : Tendsto (Box.lower ∘ ↑J) atTop (𝓝 I.lower) hJu : Tendsto (Box.upper ∘ ↑J) atTop (𝓝 I.upper) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I ⊢ ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc I, ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.upper I i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.lower I i) x) i) [PROOFSTEP] have hJ_le : ∀ k, J k ≤ I := fun k => Box.le_iff_Icc.2 (hJ_sub' k) [GOAL] case intro.intro.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : Tendsto (Box.lower ∘ ↑J) atTop (𝓝 I.lower) hJu : Tendsto (Box.upper ∘ ↑J) atTop (𝓝 I.upper) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I ⊢ ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc I, ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.upper I i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.lower I i) x) i) [PROOFSTEP] have HcJ : ∀ k, ContinuousOn f (Box.Icc (J k)) := fun k => Hc.mono (hJ_sub' k) [GOAL] case intro.intro.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : Tendsto (Box.lower ∘ ↑J) atTop (𝓝 I.lower) hJu : Tendsto (Box.upper ∘ ↑J) atTop (𝓝 I.upper) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) ⊢ ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc I, ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.upper I i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.lower I i) x) i) [PROOFSTEP] have HdJ : ∀ (k), ∀ x ∈ (Box.Icc (J k)) \ s, HasFDerivWithinAt f (f' x) (Box.Icc (J k)) x := fun k x hx => (Hd x ⟨hJ_sub k hx.1, hx.2⟩).hasFDerivWithinAt [GOAL] case intro.intro.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : Tendsto (Box.lower ∘ ↑J) atTop (𝓝 I.lower) hJu : Tendsto (Box.upper ∘ ↑J) atTop (𝓝 I.upper) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x ⊢ ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc I, ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.upper I i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.lower I i) x) i) [PROOFSTEP] have HiJ : ∀ k, IntegrableOn (∑ i, f' · (e i) i) (Box.Icc (J k)) volume := fun k => Hi.mono_set (hJ_sub' k) -- Apply the previous lemma to `J k`. [GOAL] case intro.intro.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : Tendsto (Box.lower ∘ ↑J) atTop (𝓝 I.lower) hJu : Tendsto (Box.upper ∘ ↑J) atTop (𝓝 I.upper) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) ⊢ ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc I, ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.upper I i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.lower I i) x) i) [PROOFSTEP] have HJ_eq := fun k => integral_divergence_of_hasFDerivWithinAt_off_countable_aux₁ (J k) f f' s hs (HcJ k) (HdJ k) (HiJ k) -- Note that the LHS of `HJ_eq k` tends to the LHS of the goal as `k → ∞`. [GOAL] case intro.intro.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : Tendsto (Box.lower ∘ ↑J) atTop (𝓝 I.lower) hJu : Tendsto (Box.upper ∘ ↑J) atTop (𝓝 I.upper) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) ⊢ ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc I, ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.upper I i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.lower I i) x) i) [PROOFSTEP] have hI_tendsto : Tendsto (fun k => ∫ x in Box.Icc (J k), ∑ i, f' x (e i) i) atTop (𝓝 (∫ x in Box.Icc I, ∑ i, f' x (e i) i)) := by simp only [IntegrableOn, ← Measure.restrict_congr_set (Box.Ioo_ae_eq_Icc _)] at Hi ⊢ rw [← Box.iUnion_Ioo_of_tendsto J.monotone hJl hJu] at Hi ⊢ exact tendsto_set_integral_of_monotone (fun k => (J k).measurableSet_Ioo) (Box.Ioo.comp J).monotone Hi [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : Tendsto (Box.lower ∘ ↑J) atTop (𝓝 I.lower) hJu : Tendsto (Box.upper ∘ ↑J) atTop (𝓝 I.upper) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) ⊢ Tendsto (fun k => ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i) atTop (𝓝 (∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc I, ∑ i : Fin (n + 1), ↑(f' x) (e i) i)) [PROOFSTEP] simp only [IntegrableOn, ← Measure.restrict_congr_set (Box.Ioo_ae_eq_Icc _)] at Hi ⊢ [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : Tendsto (Box.lower ∘ ↑J) atTop (𝓝 I.lower) hJu : Tendsto (Box.upper ∘ ↑J) atTop (𝓝 I.upper) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) Hi : Integrable fun x => ∑ x_1 : Fin (n + 1), ↑(f' x) (e x_1) x_1 ⊢ Tendsto (fun k => ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Ioo (↑J k), ∑ x_1 : Fin (n + 1), ↑(f' x) (e x_1) x_1) atTop (𝓝 (∫ (x : Fin (n + 1) → ℝ) in ↑Box.Ioo I, ∑ x_1 : Fin (n + 1), ↑(f' x) (e x_1) x_1)) [PROOFSTEP] rw [← Box.iUnion_Ioo_of_tendsto J.monotone hJl hJu] at Hi ⊢ [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : Tendsto (Box.lower ∘ ↑J) atTop (𝓝 I.lower) hJu : Tendsto (Box.upper ∘ ↑J) atTop (𝓝 I.upper) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) Hi : Integrable fun x => ∑ x_1 : Fin (n + 1), ↑(f' x) (e x_1) x_1 ⊢ Tendsto (fun k => ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Ioo (↑J k), ∑ x_1 : Fin (n + 1), ↑(f' x) (e x_1) x_1) atTop (𝓝 (∫ (x : Fin (n + 1) → ℝ) in ⋃ (n_1 : ℕ), ↑Box.Ioo (↑J n_1), ∑ x_1 : Fin (n + 1), ↑(f' x) (e x_1) x_1)) [PROOFSTEP] exact tendsto_set_integral_of_monotone (fun k => (J k).measurableSet_Ioo) (Box.Ioo.comp J).monotone Hi [GOAL] case intro.intro.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : Tendsto (Box.lower ∘ ↑J) atTop (𝓝 I.lower) hJu : Tendsto (Box.upper ∘ ↑J) atTop (𝓝 I.upper) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) hI_tendsto : Tendsto (fun k => ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i) atTop (𝓝 (∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc I, ∑ i : Fin (n + 1), ↑(f' x) (e i) i)) ⊢ ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc I, ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.upper I i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.lower I i) x) i) [PROOFSTEP] refine' tendsto_nhds_unique_of_eventuallyEq hI_tendsto _ (eventually_of_forall HJ_eq) [GOAL] case intro.intro.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : Tendsto (Box.lower ∘ ↑J) atTop (𝓝 I.lower) hJu : Tendsto (Box.upper ∘ ↑J) atTop (𝓝 I.upper) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) hI_tendsto : Tendsto (fun k => ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i) atTop (𝓝 (∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc I, ∑ i : Fin (n + 1), ↑(f' x) (e i) i)) ⊢ Tendsto (fun x => ∑ i : Fin (n + 1), ((∫ (x_1 : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J x) i), f (Fin.insertNth i (Box.upper (↑J x) i) x_1) i) - ∫ (x_1 : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J x) i), f (Fin.insertNth i (Box.lower (↑J x) i) x_1) i)) atTop (𝓝 (∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.upper I i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.lower I i) x) i))) [PROOFSTEP] clear hI_tendsto [GOAL] case intro.intro.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : Tendsto (Box.lower ∘ ↑J) atTop (𝓝 I.lower) hJu : Tendsto (Box.upper ∘ ↑J) atTop (𝓝 I.upper) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) ⊢ Tendsto (fun x => ∑ i : Fin (n + 1), ((∫ (x_1 : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J x) i), f (Fin.insertNth i (Box.upper (↑J x) i) x_1) i) - ∫ (x_1 : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J x) i), f (Fin.insertNth i (Box.lower (↑J x) i) x_1) i)) atTop (𝓝 (∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.upper I i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.lower I i) x) i))) [PROOFSTEP] rw [tendsto_pi_nhds] at hJl hJu [GOAL] case intro.intro.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) ⊢ Tendsto (fun x => ∑ i : Fin (n + 1), ((∫ (x_1 : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J x) i), f (Fin.insertNth i (Box.upper (↑J x) i) x_1) i) - ∫ (x_1 : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J x) i), f (Fin.insertNth i (Box.lower (↑J x) i) x_1) i)) atTop (𝓝 (∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.upper I i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.lower I i) x) i))) [PROOFSTEP] suffices ∀ (i : Fin (n + 1)) (c : ℕ → ℝ) (d), (∀ k, c k ∈ Icc (I.lower i) (I.upper i)) → Tendsto c atTop (𝓝 d) → Tendsto (fun k => ∫ x in Box.Icc ((J k).face i), f (i.insertNth (c k) x) i) atTop (𝓝 <| ∫ x in Box.Icc (I.face i), f (i.insertNth d x) i) by rw [Box.Icc_eq_pi] at hJ_sub' refine' tendsto_finset_sum _ fun i _ => (this _ _ _ _ (hJu _)).sub (this _ _ _ _ (hJl _)) exacts [fun k => hJ_sub' k (J k).upper_mem_Icc _ trivial, fun k => hJ_sub' k (J k).lower_mem_Icc _ trivial] [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) this : ∀ (i : Fin (n + 1)) (c : ℕ → ℝ) (d : ℝ), (∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i)) → Tendsto c atTop (𝓝 d) → Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (c k) x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) ⊢ Tendsto (fun x => ∑ i : Fin (n + 1), ((∫ (x_1 : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J x) i), f (Fin.insertNth i (Box.upper (↑J x) i) x_1) i) - ∫ (x_1 : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J x) i), f (Fin.insertNth i (Box.lower (↑J x) i) x_1) i)) atTop (𝓝 (∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.upper I i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.lower I i) x) i))) [PROOFSTEP] rw [Box.Icc_eq_pi] at hJ_sub' [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ Set.pi Set.univ fun i => Set.Icc (Box.lower I i) (Box.upper I i) hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) this : ∀ (i : Fin (n + 1)) (c : ℕ → ℝ) (d : ℝ), (∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i)) → Tendsto c atTop (𝓝 d) → Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (c k) x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) ⊢ Tendsto (fun x => ∑ i : Fin (n + 1), ((∫ (x_1 : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J x) i), f (Fin.insertNth i (Box.upper (↑J x) i) x_1) i) - ∫ (x_1 : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J x) i), f (Fin.insertNth i (Box.lower (↑J x) i) x_1) i)) atTop (𝓝 (∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.upper I i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i (Box.lower I i) x) i))) [PROOFSTEP] refine' tendsto_finset_sum _ fun i _ => (this _ _ _ _ (hJu _)).sub (this _ _ _ _ (hJl _)) [GOAL] case refine'_1 E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ Set.pi Set.univ fun i => Set.Icc (Box.lower I i) (Box.upper I i) hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) this : ∀ (i : Fin (n + 1)) (c : ℕ → ℝ) (d : ℝ), (∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i)) → Tendsto c atTop (𝓝 d) → Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (c k) x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) i : Fin (n + 1) x✝ : i ∈ Finset.univ ⊢ ∀ (k : ℕ), (Box.upper ∘ ↑J) k i ∈ Set.Icc (Box.lower I i) (Box.upper I i) case refine'_2 E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ Set.pi Set.univ fun i => Set.Icc (Box.lower I i) (Box.upper I i) hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) this : ∀ (i : Fin (n + 1)) (c : ℕ → ℝ) (d : ℝ), (∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i)) → Tendsto c atTop (𝓝 d) → Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (c k) x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) i : Fin (n + 1) x✝ : i ∈ Finset.univ ⊢ ∀ (k : ℕ), Box.lower (↑J k) i ∈ Set.Icc (Box.lower I i) (Box.upper I i) [PROOFSTEP] exacts [fun k => hJ_sub' k (J k).upper_mem_Icc _ trivial, fun k => hJ_sub' k (J k).lower_mem_Icc _ trivial] [GOAL] case intro.intro.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) ⊢ ∀ (i : Fin (n + 1)) (c : ℕ → ℝ) (d : ℝ), (∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i)) → Tendsto c atTop (𝓝 d) → Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (c k) x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) [PROOFSTEP] intro i c d hc hcd [GOAL] case intro.intro.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) i : Fin (n + 1) c : ℕ → ℝ d : ℝ hc : ∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i) hcd : Tendsto c atTop (𝓝 d) ⊢ Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (c k) x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) [PROOFSTEP] have hd : d ∈ Icc (I.lower i) (I.upper i) := isClosed_Icc.mem_of_tendsto hcd (eventually_of_forall hc) [GOAL] case intro.intro.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) i : Fin (n + 1) c : ℕ → ℝ d : ℝ hc : ∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i) hcd : Tendsto c atTop (𝓝 d) hd : d ∈ Set.Icc (Box.lower I i) (Box.upper I i) ⊢ Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (c k) x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) [PROOFSTEP] have Hic : ∀ k, IntegrableOn (fun x => f (i.insertNth (c k) x) i) (Box.Icc (I.face i)) := fun k => (Box.continuousOn_face_Icc ((continuous_apply i).comp_continuousOn Hc) (hc k)).integrableOn_Icc [GOAL] case intro.intro.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) i : Fin (n + 1) c : ℕ → ℝ d : ℝ hc : ∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i) hcd : Tendsto c atTop (𝓝 d) hd : d ∈ Set.Icc (Box.lower I i) (Box.upper I i) Hic : ∀ (k : ℕ), IntegrableOn (fun x => f (Fin.insertNth i (c k) x) i) (↑Box.Icc (Box.face I i)) ⊢ Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (c k) x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) [PROOFSTEP] have Hid : IntegrableOn (fun x => f (i.insertNth d x) i) (Box.Icc (I.face i)) := (Box.continuousOn_face_Icc ((continuous_apply i).comp_continuousOn Hc) hd).integrableOn_Icc [GOAL] case intro.intro.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) i : Fin (n + 1) c : ℕ → ℝ d : ℝ hc : ∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i) hcd : Tendsto c atTop (𝓝 d) hd : d ∈ Set.Icc (Box.lower I i) (Box.upper I i) Hic : ∀ (k : ℕ), IntegrableOn (fun x => f (Fin.insertNth i (c k) x) i) (↑Box.Icc (Box.face I i)) Hid : IntegrableOn (fun x => f (Fin.insertNth i d x) i) (↑Box.Icc (Box.face I i)) ⊢ Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (c k) x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) [PROOFSTEP] have H : Tendsto (fun k => ∫ x in Box.Icc ((J k).face i), f (i.insertNth d x) i) atTop (𝓝 <| ∫ x in Box.Icc (I.face i), f (i.insertNth d x) i) := by have hIoo : (⋃ k, Box.Ioo ((J k).face i)) = Box.Ioo (I.face i) := Box.iUnion_Ioo_of_tendsto ((Box.monotone_face i).comp J.monotone) (tendsto_pi_nhds.2 fun _ => hJl _) (tendsto_pi_nhds.2 fun _ => hJu _) simp only [IntegrableOn, ← Measure.restrict_congr_set (Box.Ioo_ae_eq_Icc _), ← hIoo] at Hid ⊢ exact tendsto_set_integral_of_monotone (fun k => ((J k).face i).measurableSet_Ioo) (Box.Ioo.monotone.comp ((Box.monotone_face i).comp J.monotone)) Hid [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) i : Fin (n + 1) c : ℕ → ℝ d : ℝ hc : ∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i) hcd : Tendsto c atTop (𝓝 d) hd : d ∈ Set.Icc (Box.lower I i) (Box.upper I i) Hic : ∀ (k : ℕ), IntegrableOn (fun x => f (Fin.insertNth i (c k) x) i) (↑Box.Icc (Box.face I i)) Hid : IntegrableOn (fun x => f (Fin.insertNth i d x) i) (↑Box.Icc (Box.face I i)) ⊢ Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i d x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) [PROOFSTEP] have hIoo : (⋃ k, Box.Ioo ((J k).face i)) = Box.Ioo (I.face i) := Box.iUnion_Ioo_of_tendsto ((Box.monotone_face i).comp J.monotone) (tendsto_pi_nhds.2 fun _ => hJl _) (tendsto_pi_nhds.2 fun _ => hJu _) [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) i : Fin (n + 1) c : ℕ → ℝ d : ℝ hc : ∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i) hcd : Tendsto c atTop (𝓝 d) hd : d ∈ Set.Icc (Box.lower I i) (Box.upper I i) Hic : ∀ (k : ℕ), IntegrableOn (fun x => f (Fin.insertNth i (c k) x) i) (↑Box.Icc (Box.face I i)) Hid : IntegrableOn (fun x => f (Fin.insertNth i d x) i) (↑Box.Icc (Box.face I i)) hIoo : ⋃ (k : ℕ), ↑Box.Ioo (Box.face (↑J k) i) = ↑Box.Ioo (Box.face I i) ⊢ Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i d x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) [PROOFSTEP] simp only [IntegrableOn, ← Measure.restrict_congr_set (Box.Ioo_ae_eq_Icc _), ← hIoo] at Hid ⊢ [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) i : Fin (n + 1) c : ℕ → ℝ d : ℝ hc : ∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i) hcd : Tendsto c atTop (𝓝 d) hd : d ∈ Set.Icc (Box.lower I i) (Box.upper I i) Hic : ∀ (k : ℕ), IntegrableOn (fun x => f (Fin.insertNth i (c k) x) i) (↑Box.Icc (Box.face I i)) hIoo : ⋃ (k : ℕ), ↑Box.Ioo (Box.face (↑J k) i) = ↑Box.Ioo (Box.face I i) Hid : Integrable fun x => f (Fin.insertNth i d x) i ⊢ Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Ioo (Box.face (↑J k) i), f (Fin.insertNth i d x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ⋃ (k : ℕ), ↑Box.Ioo (Box.face (↑J k) i), f (Fin.insertNth i d x) i)) [PROOFSTEP] exact tendsto_set_integral_of_monotone (fun k => ((J k).face i).measurableSet_Ioo) (Box.Ioo.monotone.comp ((Box.monotone_face i).comp J.monotone)) Hid [GOAL] case intro.intro.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) i : Fin (n + 1) c : ℕ → ℝ d : ℝ hc : ∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i) hcd : Tendsto c atTop (𝓝 d) hd : d ∈ Set.Icc (Box.lower I i) (Box.upper I i) Hic : ∀ (k : ℕ), IntegrableOn (fun x => f (Fin.insertNth i (c k) x) i) (↑Box.Icc (Box.face I i)) Hid : IntegrableOn (fun x => f (Fin.insertNth i d x) i) (↑Box.Icc (Box.face I i)) H : Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i d x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) ⊢ Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (c k) x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) [PROOFSTEP] refine' H.congr_dist (Metric.nhds_basis_closedBall.tendsto_right_iff.2 fun ε εpos => _) [GOAL] case intro.intro.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) i : Fin (n + 1) c : ℕ → ℝ d : ℝ hc : ∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i) hcd : Tendsto c atTop (𝓝 d) hd : d ∈ Set.Icc (Box.lower I i) (Box.upper I i) Hic : ∀ (k : ℕ), IntegrableOn (fun x => f (Fin.insertNth i (c k) x) i) (↑Box.Icc (Box.face I i)) Hid : IntegrableOn (fun x => f (Fin.insertNth i d x) i) (↑Box.Icc (Box.face I i)) H : Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i d x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) ε : ℝ εpos : 0 < ε ⊢ ∀ᶠ (x : ℕ) in atTop, dist (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J x) i), f (Fin.insertNth i d x) i) (∫ (x_1 : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J x) i), f (Fin.insertNth i (c x) x_1) i) ∈ Metric.closedBall 0 ε [PROOFSTEP] have hvol_pos : ∀ J : Box (Fin n), 0 < ∏ j, (J.upper j - J.lower j) := fun J => prod_pos fun j hj => sub_pos.2 <| J.lower_lt_upper _ /- Choose `δ > 0` such that for any `x y ∈ I.Icc` at distance at most `δ`, the distance between `f x` and `f y` is at most `ε / volume (I.face i).Icc`, then the distance between the integrals is at most `(ε / volume (I.face i).Icc) * volume ((J k).face i).Icc ≤ ε`. -/ [GOAL] case intro.intro.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) i : Fin (n + 1) c : ℕ → ℝ d : ℝ hc : ∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i) hcd : Tendsto c atTop (𝓝 d) hd : d ∈ Set.Icc (Box.lower I i) (Box.upper I i) Hic : ∀ (k : ℕ), IntegrableOn (fun x => f (Fin.insertNth i (c k) x) i) (↑Box.Icc (Box.face I i)) Hid : IntegrableOn (fun x => f (Fin.insertNth i d x) i) (↑Box.Icc (Box.face I i)) H : Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i d x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) ε : ℝ εpos : 0 < ε hvol_pos : ∀ (J : Box (Fin n)), 0 < ∏ j : Fin n, (Box.upper J j - Box.lower J j) ⊢ ∀ᶠ (x : ℕ) in atTop, dist (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J x) i), f (Fin.insertNth i d x) i) (∫ (x_1 : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J x) i), f (Fin.insertNth i (c x) x_1) i) ∈ Metric.closedBall 0 ε [PROOFSTEP] rcases Metric.uniformContinuousOn_iff_le.1 (I.isCompact_Icc.uniformContinuousOn_of_continuous Hc) (ε / ∏ j, ((I.face i).upper j - (I.face i).lower j)) (div_pos εpos (hvol_pos (I.face i))) with ⟨δ, δpos, hδ⟩ [GOAL] case intro.intro.intro.intro.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) i : Fin (n + 1) c : ℕ → ℝ d : ℝ hc : ∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i) hcd : Tendsto c atTop (𝓝 d) hd : d ∈ Set.Icc (Box.lower I i) (Box.upper I i) Hic : ∀ (k : ℕ), IntegrableOn (fun x => f (Fin.insertNth i (c k) x) i) (↑Box.Icc (Box.face I i)) Hid : IntegrableOn (fun x => f (Fin.insertNth i d x) i) (↑Box.Icc (Box.face I i)) H : Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i d x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) ε : ℝ εpos : 0 < ε hvol_pos : ∀ (J : Box (Fin n)), 0 < ∏ j : Fin n, (Box.upper J j - Box.lower J j) δ : ℝ δpos : δ > 0 hδ : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc I → ∀ (y : Fin (n + 1) → ℝ), y ∈ ↑Box.Icc I → dist x y ≤ δ → dist (f x) (f y) ≤ ε / ∏ j : Fin n, (Box.upper (Box.face I i) j - Box.lower (Box.face I i) j) ⊢ ∀ᶠ (x : ℕ) in atTop, dist (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J x) i), f (Fin.insertNth i d x) i) (∫ (x_1 : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J x) i), f (Fin.insertNth i (c x) x_1) i) ∈ Metric.closedBall 0 ε [PROOFSTEP] refine' (hcd.eventually (Metric.ball_mem_nhds _ δpos)).mono fun k hk => _ [GOAL] case intro.intro.intro.intro.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) i : Fin (n + 1) c : ℕ → ℝ d : ℝ hc : ∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i) hcd : Tendsto c atTop (𝓝 d) hd : d ∈ Set.Icc (Box.lower I i) (Box.upper I i) Hic : ∀ (k : ℕ), IntegrableOn (fun x => f (Fin.insertNth i (c k) x) i) (↑Box.Icc (Box.face I i)) Hid : IntegrableOn (fun x => f (Fin.insertNth i d x) i) (↑Box.Icc (Box.face I i)) H : Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i d x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) ε : ℝ εpos : 0 < ε hvol_pos : ∀ (J : Box (Fin n)), 0 < ∏ j : Fin n, (Box.upper J j - Box.lower J j) δ : ℝ δpos : δ > 0 hδ : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc I → ∀ (y : Fin (n + 1) → ℝ), y ∈ ↑Box.Icc I → dist x y ≤ δ → dist (f x) (f y) ≤ ε / ∏ j : Fin n, (Box.upper (Box.face I i) j - Box.lower (Box.face I i) j) k : ℕ hk : dist (c k) d < δ ⊢ dist (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i d x) i) (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (c k) x) i) ∈ Metric.closedBall 0 ε [PROOFSTEP] have Hsub : Box.Icc ((J k).face i) ⊆ Box.Icc (I.face i) := Box.le_iff_Icc.1 (Box.face_mono (hJ_le _) i) [GOAL] case intro.intro.intro.intro.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) i : Fin (n + 1) c : ℕ → ℝ d : ℝ hc : ∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i) hcd : Tendsto c atTop (𝓝 d) hd : d ∈ Set.Icc (Box.lower I i) (Box.upper I i) Hic : ∀ (k : ℕ), IntegrableOn (fun x => f (Fin.insertNth i (c k) x) i) (↑Box.Icc (Box.face I i)) Hid : IntegrableOn (fun x => f (Fin.insertNth i d x) i) (↑Box.Icc (Box.face I i)) H : Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i d x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) ε : ℝ εpos : 0 < ε hvol_pos : ∀ (J : Box (Fin n)), 0 < ∏ j : Fin n, (Box.upper J j - Box.lower J j) δ : ℝ δpos : δ > 0 hδ : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc I → ∀ (y : Fin (n + 1) → ℝ), y ∈ ↑Box.Icc I → dist x y ≤ δ → dist (f x) (f y) ≤ ε / ∏ j : Fin n, (Box.upper (Box.face I i) j - Box.lower (Box.face I i) j) k : ℕ hk : dist (c k) d < δ Hsub : ↑Box.Icc (Box.face (↑J k) i) ⊆ ↑Box.Icc (Box.face I i) ⊢ dist (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i d x) i) (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (c k) x) i) ∈ Metric.closedBall 0 ε [PROOFSTEP] rw [mem_closedBall_zero_iff, Real.norm_eq_abs, abs_of_nonneg dist_nonneg, dist_eq_norm, ← integral_sub (Hid.mono_set Hsub) ((Hic _).mono_set Hsub)] [GOAL] case intro.intro.intro.intro.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) i : Fin (n + 1) c : ℕ → ℝ d : ℝ hc : ∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i) hcd : Tendsto c atTop (𝓝 d) hd : d ∈ Set.Icc (Box.lower I i) (Box.upper I i) Hic : ∀ (k : ℕ), IntegrableOn (fun x => f (Fin.insertNth i (c k) x) i) (↑Box.Icc (Box.face I i)) Hid : IntegrableOn (fun x => f (Fin.insertNth i d x) i) (↑Box.Icc (Box.face I i)) H : Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i d x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) ε : ℝ εpos : 0 < ε hvol_pos : ∀ (J : Box (Fin n)), 0 < ∏ j : Fin n, (Box.upper J j - Box.lower J j) δ : ℝ δpos : δ > 0 hδ : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc I → ∀ (y : Fin (n + 1) → ℝ), y ∈ ↑Box.Icc I → dist x y ≤ δ → dist (f x) (f y) ≤ ε / ∏ j : Fin n, (Box.upper (Box.face I i) j - Box.lower (Box.face I i) j) k : ℕ hk : dist (c k) d < δ Hsub : ↑Box.Icc (Box.face (↑J k) i) ⊆ ↑Box.Icc (Box.face I i) ⊢ ‖∫ (a : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i d a) i - f (Fin.insertNth i (c k) a) i‖ ≤ ε [PROOFSTEP] calc ‖∫ x in Box.Icc ((J k).face i), f (i.insertNth d x) i - f (i.insertNth (c k) x) i‖ ≤ (ε / ∏ j, ((I.face i).upper j - (I.face i).lower j)) * (volume (Box.Icc ((J k).face i))).toReal := by refine norm_set_integral_le_of_norm_le_const' (((J k).face i).measure_Icc_lt_top _) ((J k).face i).measurableSet_Icc fun x hx => ?_ rw [← dist_eq_norm] calc dist (f (i.insertNth d x) i) (f (i.insertNth (c k) x) i) ≤ dist (f (i.insertNth d x)) (f (i.insertNth (c k) x)) := dist_le_pi_dist (f (i.insertNth d x)) (f (i.insertNth (c k) x)) i _ ≤ ε / ∏ j, ((I.face i).upper j - (I.face i).lower j) := hδ _ (I.mapsTo_insertNth_face_Icc hd <| Hsub hx) _ (I.mapsTo_insertNth_face_Icc (hc _) <| Hsub hx) ?_ rw [Fin.dist_insertNth_insertNth, dist_self, dist_comm] exact max_le hk.le δpos.lt.le _ ≤ ε := by rw [Box.Icc_def, Real.volume_Icc_pi_toReal ((J k).face i).lower_le_upper, ← le_div_iff (hvol_pos _)] refine' div_le_div_of_le_left εpos.le (hvol_pos _) (prod_le_prod (fun j _ => _) fun j _ => _) exacts [sub_nonneg.2 (Box.lower_le_upper _ _), sub_le_sub ((hJ_sub' _ (J _).upper_mem_Icc).2 _) ((hJ_sub' _ (J _).lower_mem_Icc).1 _)] [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) i : Fin (n + 1) c : ℕ → ℝ d : ℝ hc : ∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i) hcd : Tendsto c atTop (𝓝 d) hd : d ∈ Set.Icc (Box.lower I i) (Box.upper I i) Hic : ∀ (k : ℕ), IntegrableOn (fun x => f (Fin.insertNth i (c k) x) i) (↑Box.Icc (Box.face I i)) Hid : IntegrableOn (fun x => f (Fin.insertNth i d x) i) (↑Box.Icc (Box.face I i)) H : Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i d x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) ε : ℝ εpos : 0 < ε hvol_pos : ∀ (J : Box (Fin n)), 0 < ∏ j : Fin n, (Box.upper J j - Box.lower J j) δ : ℝ δpos : δ > 0 hδ : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc I → ∀ (y : Fin (n + 1) → ℝ), y ∈ ↑Box.Icc I → dist x y ≤ δ → dist (f x) (f y) ≤ ε / ∏ j : Fin n, (Box.upper (Box.face I i) j - Box.lower (Box.face I i) j) k : ℕ hk : dist (c k) d < δ Hsub : ↑Box.Icc (Box.face (↑J k) i) ⊆ ↑Box.Icc (Box.face I i) ⊢ ‖∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i d x) i - f (Fin.insertNth i (c k) x) i‖ ≤ (ε / ∏ j : Fin n, (Box.upper (Box.face I i) j - Box.lower (Box.face I i) j)) * ENNReal.toReal (↑↑volume (↑Box.Icc (Box.face (↑J k) i))) [PROOFSTEP] refine norm_set_integral_le_of_norm_le_const' (((J k).face i).measure_Icc_lt_top _) ((J k).face i).measurableSet_Icc fun x hx => ?_ [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) i : Fin (n + 1) c : ℕ → ℝ d : ℝ hc : ∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i) hcd : Tendsto c atTop (𝓝 d) hd : d ∈ Set.Icc (Box.lower I i) (Box.upper I i) Hic : ∀ (k : ℕ), IntegrableOn (fun x => f (Fin.insertNth i (c k) x) i) (↑Box.Icc (Box.face I i)) Hid : IntegrableOn (fun x => f (Fin.insertNth i d x) i) (↑Box.Icc (Box.face I i)) H : Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i d x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) ε : ℝ εpos : 0 < ε hvol_pos : ∀ (J : Box (Fin n)), 0 < ∏ j : Fin n, (Box.upper J j - Box.lower J j) δ : ℝ δpos : δ > 0 hδ : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc I → ∀ (y : Fin (n + 1) → ℝ), y ∈ ↑Box.Icc I → dist x y ≤ δ → dist (f x) (f y) ≤ ε / ∏ j : Fin n, (Box.upper (Box.face I i) j - Box.lower (Box.face I i) j) k : ℕ hk : dist (c k) d < δ Hsub : ↑Box.Icc (Box.face (↑J k) i) ⊆ ↑Box.Icc (Box.face I i) x : Fin n → ℝ hx : x ∈ ↑Box.Icc (Box.face (↑J k) i) ⊢ ‖f (Fin.insertNth i d x) i - f (Fin.insertNth i (c k) x) i‖ ≤ ε / ∏ j : Fin n, (Box.upper (Box.face I i) j - Box.lower (Box.face I i) j) [PROOFSTEP] rw [← dist_eq_norm] [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) i : Fin (n + 1) c : ℕ → ℝ d : ℝ hc : ∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i) hcd : Tendsto c atTop (𝓝 d) hd : d ∈ Set.Icc (Box.lower I i) (Box.upper I i) Hic : ∀ (k : ℕ), IntegrableOn (fun x => f (Fin.insertNth i (c k) x) i) (↑Box.Icc (Box.face I i)) Hid : IntegrableOn (fun x => f (Fin.insertNth i d x) i) (↑Box.Icc (Box.face I i)) H : Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i d x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) ε : ℝ εpos : 0 < ε hvol_pos : ∀ (J : Box (Fin n)), 0 < ∏ j : Fin n, (Box.upper J j - Box.lower J j) δ : ℝ δpos : δ > 0 hδ : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc I → ∀ (y : Fin (n + 1) → ℝ), y ∈ ↑Box.Icc I → dist x y ≤ δ → dist (f x) (f y) ≤ ε / ∏ j : Fin n, (Box.upper (Box.face I i) j - Box.lower (Box.face I i) j) k : ℕ hk : dist (c k) d < δ Hsub : ↑Box.Icc (Box.face (↑J k) i) ⊆ ↑Box.Icc (Box.face I i) x : Fin n → ℝ hx : x ∈ ↑Box.Icc (Box.face (↑J k) i) ⊢ dist (f (Fin.insertNth i d x) i) (f (Fin.insertNth i (c k) x) i) ≤ ε / ∏ j : Fin n, (Box.upper (Box.face I i) j - Box.lower (Box.face I i) j) [PROOFSTEP] calc dist (f (i.insertNth d x) i) (f (i.insertNth (c k) x) i) ≤ dist (f (i.insertNth d x)) (f (i.insertNth (c k) x)) := dist_le_pi_dist (f (i.insertNth d x)) (f (i.insertNth (c k) x)) i _ ≤ ε / ∏ j, ((I.face i).upper j - (I.face i).lower j) := hδ _ (I.mapsTo_insertNth_face_Icc hd <| Hsub hx) _ (I.mapsTo_insertNth_face_Icc (hc _) <| Hsub hx) ?_ [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) i : Fin (n + 1) c : ℕ → ℝ d : ℝ hc : ∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i) hcd : Tendsto c atTop (𝓝 d) hd : d ∈ Set.Icc (Box.lower I i) (Box.upper I i) Hic : ∀ (k : ℕ), IntegrableOn (fun x => f (Fin.insertNth i (c k) x) i) (↑Box.Icc (Box.face I i)) Hid : IntegrableOn (fun x => f (Fin.insertNth i d x) i) (↑Box.Icc (Box.face I i)) H : Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i d x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) ε : ℝ εpos : 0 < ε hvol_pos : ∀ (J : Box (Fin n)), 0 < ∏ j : Fin n, (Box.upper J j - Box.lower J j) δ : ℝ δpos : δ > 0 hδ : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc I → ∀ (y : Fin (n + 1) → ℝ), y ∈ ↑Box.Icc I → dist x y ≤ δ → dist (f x) (f y) ≤ ε / ∏ j : Fin n, (Box.upper (Box.face I i) j - Box.lower (Box.face I i) j) k : ℕ hk : dist (c k) d < δ Hsub : ↑Box.Icc (Box.face (↑J k) i) ⊆ ↑Box.Icc (Box.face I i) x : Fin n → ℝ hx : x ∈ ↑Box.Icc (Box.face (↑J k) i) ⊢ dist (Fin.insertNth i d x) (Fin.insertNth i (c k) x) ≤ δ [PROOFSTEP] rw [Fin.dist_insertNth_insertNth, dist_self, dist_comm] [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) i : Fin (n + 1) c : ℕ → ℝ d : ℝ hc : ∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i) hcd : Tendsto c atTop (𝓝 d) hd : d ∈ Set.Icc (Box.lower I i) (Box.upper I i) Hic : ∀ (k : ℕ), IntegrableOn (fun x => f (Fin.insertNth i (c k) x) i) (↑Box.Icc (Box.face I i)) Hid : IntegrableOn (fun x => f (Fin.insertNth i d x) i) (↑Box.Icc (Box.face I i)) H : Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i d x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) ε : ℝ εpos : 0 < ε hvol_pos : ∀ (J : Box (Fin n)), 0 < ∏ j : Fin n, (Box.upper J j - Box.lower J j) δ : ℝ δpos : δ > 0 hδ : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc I → ∀ (y : Fin (n + 1) → ℝ), y ∈ ↑Box.Icc I → dist x y ≤ δ → dist (f x) (f y) ≤ ε / ∏ j : Fin n, (Box.upper (Box.face I i) j - Box.lower (Box.face I i) j) k : ℕ hk : dist (c k) d < δ Hsub : ↑Box.Icc (Box.face (↑J k) i) ⊆ ↑Box.Icc (Box.face I i) x : Fin n → ℝ hx : x ∈ ↑Box.Icc (Box.face (↑J k) i) ⊢ max (dist (c k) d) 0 ≤ δ [PROOFSTEP] exact max_le hk.le δpos.lt.le [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) i : Fin (n + 1) c : ℕ → ℝ d : ℝ hc : ∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i) hcd : Tendsto c atTop (𝓝 d) hd : d ∈ Set.Icc (Box.lower I i) (Box.upper I i) Hic : ∀ (k : ℕ), IntegrableOn (fun x => f (Fin.insertNth i (c k) x) i) (↑Box.Icc (Box.face I i)) Hid : IntegrableOn (fun x => f (Fin.insertNth i d x) i) (↑Box.Icc (Box.face I i)) H : Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i d x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) ε : ℝ εpos : 0 < ε hvol_pos : ∀ (J : Box (Fin n)), 0 < ∏ j : Fin n, (Box.upper J j - Box.lower J j) δ : ℝ δpos : δ > 0 hδ : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc I → ∀ (y : Fin (n + 1) → ℝ), y ∈ ↑Box.Icc I → dist x y ≤ δ → dist (f x) (f y) ≤ ε / ∏ j : Fin n, (Box.upper (Box.face I i) j - Box.lower (Box.face I i) j) k : ℕ hk : dist (c k) d < δ Hsub : ↑Box.Icc (Box.face (↑J k) i) ⊆ ↑Box.Icc (Box.face I i) ⊢ (ε / ∏ j : Fin n, (Box.upper (Box.face I i) j - Box.lower (Box.face I i) j)) * ENNReal.toReal (↑↑volume (↑Box.Icc (Box.face (↑J k) i))) ≤ ε [PROOFSTEP] rw [Box.Icc_def, Real.volume_Icc_pi_toReal ((J k).face i).lower_le_upper, ← le_div_iff (hvol_pos _)] [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) i : Fin (n + 1) c : ℕ → ℝ d : ℝ hc : ∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i) hcd : Tendsto c atTop (𝓝 d) hd : d ∈ Set.Icc (Box.lower I i) (Box.upper I i) Hic : ∀ (k : ℕ), IntegrableOn (fun x => f (Fin.insertNth i (c k) x) i) (↑Box.Icc (Box.face I i)) Hid : IntegrableOn (fun x => f (Fin.insertNth i d x) i) (↑Box.Icc (Box.face I i)) H : Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i d x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) ε : ℝ εpos : 0 < ε hvol_pos : ∀ (J : Box (Fin n)), 0 < ∏ j : Fin n, (Box.upper J j - Box.lower J j) δ : ℝ δpos : δ > 0 hδ : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc I → ∀ (y : Fin (n + 1) → ℝ), y ∈ ↑Box.Icc I → dist x y ≤ δ → dist (f x) (f y) ≤ ε / ∏ j : Fin n, (Box.upper (Box.face I i) j - Box.lower (Box.face I i) j) k : ℕ hk : dist (c k) d < δ Hsub : ↑Box.Icc (Box.face (↑J k) i) ⊆ ↑Box.Icc (Box.face I i) ⊢ ε / ∏ j : Fin n, (Box.upper (Box.face I i) j - Box.lower (Box.face I i) j) ≤ ε / ∏ j : Fin n, (Box.upper (Box.face (↑J k) i) j - Box.lower (Box.face (↑J k) i) j) [PROOFSTEP] refine' div_le_div_of_le_left εpos.le (hvol_pos _) (prod_le_prod (fun j _ => _) fun j _ => _) [GOAL] case refine'_1 E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) i : Fin (n + 1) c : ℕ → ℝ d : ℝ hc : ∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i) hcd : Tendsto c atTop (𝓝 d) hd : d ∈ Set.Icc (Box.lower I i) (Box.upper I i) Hic : ∀ (k : ℕ), IntegrableOn (fun x => f (Fin.insertNth i (c k) x) i) (↑Box.Icc (Box.face I i)) Hid : IntegrableOn (fun x => f (Fin.insertNth i d x) i) (↑Box.Icc (Box.face I i)) H : Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i d x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) ε : ℝ εpos : 0 < ε hvol_pos : ∀ (J : Box (Fin n)), 0 < ∏ j : Fin n, (Box.upper J j - Box.lower J j) δ : ℝ δpos : δ > 0 hδ : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc I → ∀ (y : Fin (n + 1) → ℝ), y ∈ ↑Box.Icc I → dist x y ≤ δ → dist (f x) (f y) ≤ ε / ∏ j : Fin n, (Box.upper (Box.face I i) j - Box.lower (Box.face I i) j) k : ℕ hk : dist (c k) d < δ Hsub : ↑Box.Icc (Box.face (↑J k) i) ⊆ ↑Box.Icc (Box.face I i) j : Fin n x✝ : j ∈ Finset.univ ⊢ 0 ≤ Box.upper (Box.face (↑J k) i) j - Box.lower (Box.face (↑J k) i) j case refine'_2 E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ I : Box (Fin (n + 1)) f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (↑Box.Icc I) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Ioo I \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc I) J : ℕ →o Box (Fin (n + 1)) hJ_sub : ∀ (n_1 : ℕ), ↑Box.Icc (↑J n_1) ⊆ ↑Box.Ioo I hJl : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.lower ∘ ↑J) i x) atTop (𝓝 (Box.lower I x)) hJu : ∀ (x : Fin (n + 1)), Tendsto (fun i => (Box.upper ∘ ↑J) i x) atTop (𝓝 (Box.upper I x)) hJ_sub' : ∀ (k : ℕ), ↑Box.Icc (↑J k) ⊆ ↑Box.Icc I hJ_le : ∀ (k : ℕ), ↑J k ≤ I HcJ : ∀ (k : ℕ), ContinuousOn f (↑Box.Icc (↑J k)) HdJ : ∀ (k : ℕ) (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc (↑J k) \ s → HasFDerivWithinAt f (f' x) (↑Box.Icc (↑J k)) x HiJ : ∀ (k : ℕ), IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (↑Box.Icc (↑J k)) HJ_eq : ∀ (k : ℕ), ∫ (x : Fin (n + 1) → ℝ) in ↑Box.Icc (↑J k), ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.upper (↑J k) i) x) i) - ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i (Box.lower (↑J k) i) x) i) i : Fin (n + 1) c : ℕ → ℝ d : ℝ hc : ∀ (k : ℕ), c k ∈ Set.Icc (Box.lower I i) (Box.upper I i) hcd : Tendsto c atTop (𝓝 d) hd : d ∈ Set.Icc (Box.lower I i) (Box.upper I i) Hic : ∀ (k : ℕ), IntegrableOn (fun x => f (Fin.insertNth i (c k) x) i) (↑Box.Icc (Box.face I i)) Hid : IntegrableOn (fun x => f (Fin.insertNth i d x) i) (↑Box.Icc (Box.face I i)) H : Tendsto (fun k => ∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face (↑J k) i), f (Fin.insertNth i d x) i) atTop (𝓝 (∫ (x : Fin n → ℝ) in ↑Box.Icc (Box.face I i), f (Fin.insertNth i d x) i)) ε : ℝ εpos : 0 < ε hvol_pos : ∀ (J : Box (Fin n)), 0 < ∏ j : Fin n, (Box.upper J j - Box.lower J j) δ : ℝ δpos : δ > 0 hδ : ∀ (x : Fin (n + 1) → ℝ), x ∈ ↑Box.Icc I → ∀ (y : Fin (n + 1) → ℝ), y ∈ ↑Box.Icc I → dist x y ≤ δ → dist (f x) (f y) ≤ ε / ∏ j : Fin n, (Box.upper (Box.face I i) j - Box.lower (Box.face I i) j) k : ℕ hk : dist (c k) d < δ Hsub : ↑Box.Icc (Box.face (↑J k) i) ⊆ ↑Box.Icc (Box.face I i) j : Fin n x✝ : j ∈ Finset.univ ⊢ Box.upper (Box.face (↑J k) i) j - Box.lower (Box.face (↑J k) i) j ≤ Box.upper (Box.face I i) j - Box.lower (Box.face I i) j [PROOFSTEP] exacts [sub_nonneg.2 (Box.lower_le_upper _ _), sub_le_sub ((hJ_sub' _ (J _).upper_mem_Icc).2 _) ((hJ_sub' _ (J _).lower_mem_Icc).1 _)] [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ a b : Fin (n + 1) → ℝ hle : a ≤ b f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ (Set.pi Set.univ fun i => Set.Ioo (a i) (b i)) \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (Set.Icc a b) ⊢ ∫ (x : Fin (n + 1) → ℝ) in Set.Icc a b, ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in Set.Icc (a ∘ Fin.succAbove i) (b ∘ Fin.succAbove i), f (Fin.insertNth i (b i) x) i) - ∫ (x : Fin n → ℝ) in Set.Icc (a ∘ Fin.succAbove i) (b ∘ Fin.succAbove i), f (Fin.insertNth i (a i) x) i) [PROOFSTEP] rcases em (∃ i, a i = b i) with (⟨i, hi⟩ | hne) [GOAL] case inl.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ a b : Fin (n + 1) → ℝ hle : a ≤ b f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ (Set.pi Set.univ fun i => Set.Ioo (a i) (b i)) \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (Set.Icc a b) i : Fin (n + 1) hi : a i = b i ⊢ ∫ (x : Fin (n + 1) → ℝ) in Set.Icc a b, ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in Set.Icc (a ∘ Fin.succAbove i) (b ∘ Fin.succAbove i), f (Fin.insertNth i (b i) x) i) - ∫ (x : Fin n → ℝ) in Set.Icc (a ∘ Fin.succAbove i) (b ∘ Fin.succAbove i), f (Fin.insertNth i (a i) x) i) [PROOFSTEP] rw [volume_pi, ← set_integral_congr_set_ae Measure.univ_pi_Ioc_ae_eq_Icc] [GOAL] case inl.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ a b : Fin (n + 1) → ℝ hle : a ≤ b f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ (Set.pi Set.univ fun i => Set.Ioo (a i) (b i)) \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (Set.Icc a b) i : Fin (n + 1) hi : a i = b i ⊢ (∫ (x : Fin (n + 1) → ℝ) in Set.pi Set.univ fun i => Set.Ioc (a i) (b i), ∑ i : Fin (n + 1), ↑(f' x) (e i) i ∂Measure.pi fun x => volume) = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in Set.Icc (a ∘ Fin.succAbove i) (b ∘ Fin.succAbove i), f (Fin.insertNth i (b i) x) i) - ∫ (x : Fin n → ℝ) in Set.Icc (a ∘ Fin.succAbove i) (b ∘ Fin.succAbove i), f (Fin.insertNth i (a i) x) i) [PROOFSTEP] have hi' : Ioc (a i) (b i) = ∅ := Ioc_eq_empty hi.not_lt [GOAL] case inl.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ a b : Fin (n + 1) → ℝ hle : a ≤ b f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ (Set.pi Set.univ fun i => Set.Ioo (a i) (b i)) \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (Set.Icc a b) i : Fin (n + 1) hi : a i = b i hi' : Set.Ioc (a i) (b i) = ∅ ⊢ (∫ (x : Fin (n + 1) → ℝ) in Set.pi Set.univ fun i => Set.Ioc (a i) (b i), ∑ i : Fin (n + 1), ↑(f' x) (e i) i ∂Measure.pi fun x => volume) = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in Set.Icc (a ∘ Fin.succAbove i) (b ∘ Fin.succAbove i), f (Fin.insertNth i (b i) x) i) - ∫ (x : Fin n → ℝ) in Set.Icc (a ∘ Fin.succAbove i) (b ∘ Fin.succAbove i), f (Fin.insertNth i (a i) x) i) [PROOFSTEP] have : (pi Set.univ fun j => Ioc (a j) (b j)) = ∅ := univ_pi_eq_empty hi' [GOAL] case inl.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ a b : Fin (n + 1) → ℝ hle : a ≤ b f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ (Set.pi Set.univ fun i => Set.Ioo (a i) (b i)) \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (Set.Icc a b) i : Fin (n + 1) hi : a i = b i hi' : Set.Ioc (a i) (b i) = ∅ this : (Set.pi Set.univ fun j => Set.Ioc (a j) (b j)) = ∅ ⊢ (∫ (x : Fin (n + 1) → ℝ) in Set.pi Set.univ fun i => Set.Ioc (a i) (b i), ∑ i : Fin (n + 1), ↑(f' x) (e i) i ∂Measure.pi fun x => volume) = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in Set.Icc (a ∘ Fin.succAbove i) (b ∘ Fin.succAbove i), f (Fin.insertNth i (b i) x) i) - ∫ (x : Fin n → ℝ) in Set.Icc (a ∘ Fin.succAbove i) (b ∘ Fin.succAbove i), f (Fin.insertNth i (a i) x) i) [PROOFSTEP] rw [this, integral_empty, sum_eq_zero] [GOAL] case inl.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ a b : Fin (n + 1) → ℝ hle : a ≤ b f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ (Set.pi Set.univ fun i => Set.Ioo (a i) (b i)) \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (Set.Icc a b) i : Fin (n + 1) hi : a i = b i hi' : Set.Ioc (a i) (b i) = ∅ this : (Set.pi Set.univ fun j => Set.Ioc (a j) (b j)) = ∅ ⊢ ∀ (x : Fin (n + 1)), x ∈ Finset.univ → (∫ (x_1 : Fin n → ℝ) in Set.Icc (a ∘ Fin.succAbove x) (b ∘ Fin.succAbove x), f (Fin.insertNth x (b x) x_1) x) - ∫ (x_1 : Fin n → ℝ) in Set.Icc (a ∘ Fin.succAbove x) (b ∘ Fin.succAbove x), f (Fin.insertNth x (a x) x_1) x = 0 [PROOFSTEP] rintro j - [GOAL] case inl.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ a b : Fin (n + 1) → ℝ hle : a ≤ b f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ (Set.pi Set.univ fun i => Set.Ioo (a i) (b i)) \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (Set.Icc a b) i : Fin (n + 1) hi : a i = b i hi' : Set.Ioc (a i) (b i) = ∅ this : (Set.pi Set.univ fun j => Set.Ioc (a j) (b j)) = ∅ j : Fin (n + 1) ⊢ (∫ (x : Fin n → ℝ) in Set.Icc (a ∘ Fin.succAbove j) (b ∘ Fin.succAbove j), f (Fin.insertNth j (b j) x) j) - ∫ (x : Fin n → ℝ) in Set.Icc (a ∘ Fin.succAbove j) (b ∘ Fin.succAbove j), f (Fin.insertNth j (a j) x) j = 0 [PROOFSTEP] rcases eq_or_ne i j with (rfl | hne) [GOAL] case inl.intro.inl E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ a b : Fin (n + 1) → ℝ hle : a ≤ b f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ (Set.pi Set.univ fun i => Set.Ioo (a i) (b i)) \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (Set.Icc a b) i : Fin (n + 1) hi : a i = b i hi' : Set.Ioc (a i) (b i) = ∅ this : (Set.pi Set.univ fun j => Set.Ioc (a j) (b j)) = ∅ ⊢ (∫ (x : Fin n → ℝ) in Set.Icc (a ∘ Fin.succAbove i) (b ∘ Fin.succAbove i), f (Fin.insertNth i (b i) x) i) - ∫ (x : Fin n → ℝ) in Set.Icc (a ∘ Fin.succAbove i) (b ∘ Fin.succAbove i), f (Fin.insertNth i (a i) x) i = 0 [PROOFSTEP] simp [hi] [GOAL] case inl.intro.inr E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ a b : Fin (n + 1) → ℝ hle : a ≤ b f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ (Set.pi Set.univ fun i => Set.Ioo (a i) (b i)) \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (Set.Icc a b) i : Fin (n + 1) hi : a i = b i hi' : Set.Ioc (a i) (b i) = ∅ this : (Set.pi Set.univ fun j => Set.Ioc (a j) (b j)) = ∅ j : Fin (n + 1) hne : i ≠ j ⊢ (∫ (x : Fin n → ℝ) in Set.Icc (a ∘ Fin.succAbove j) (b ∘ Fin.succAbove j), f (Fin.insertNth j (b j) x) j) - ∫ (x : Fin n → ℝ) in Set.Icc (a ∘ Fin.succAbove j) (b ∘ Fin.succAbove j), f (Fin.insertNth j (a j) x) j = 0 [PROOFSTEP] rcases Fin.exists_succAbove_eq hne with ⟨i, rfl⟩ [GOAL] case inl.intro.inr.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ a b : Fin (n + 1) → ℝ hle : a ≤ b f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ (Set.pi Set.univ fun i => Set.Ioo (a i) (b i)) \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (Set.Icc a b) this : (Set.pi Set.univ fun j => Set.Ioc (a j) (b j)) = ∅ j : Fin (n + 1) i : Fin n hi : a (Fin.succAbove j i) = b (Fin.succAbove j i) hi' : Set.Ioc (a (Fin.succAbove j i)) (b (Fin.succAbove j i)) = ∅ hne : Fin.succAbove j i ≠ j ⊢ (∫ (x : Fin n → ℝ) in Set.Icc (a ∘ Fin.succAbove j) (b ∘ Fin.succAbove j), f (Fin.insertNth j (b j) x) j) - ∫ (x : Fin n → ℝ) in Set.Icc (a ∘ Fin.succAbove j) (b ∘ Fin.succAbove j), f (Fin.insertNth j (a j) x) j = 0 [PROOFSTEP] have : Icc (a ∘ j.succAbove) (b ∘ j.succAbove) =ᵐ[volume] (∅ : Set ℝⁿ) [GOAL] case this E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ a b : Fin (n + 1) → ℝ hle : a ≤ b f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ (Set.pi Set.univ fun i => Set.Ioo (a i) (b i)) \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (Set.Icc a b) this : (Set.pi Set.univ fun j => Set.Ioc (a j) (b j)) = ∅ j : Fin (n + 1) i : Fin n hi : a (Fin.succAbove j i) = b (Fin.succAbove j i) hi' : Set.Ioc (a (Fin.succAbove j i)) (b (Fin.succAbove j i)) = ∅ hne : Fin.succAbove j i ≠ j ⊢ Set.Icc (a ∘ Fin.succAbove j) (b ∘ Fin.succAbove j) =ᵐ[volume] ∅ [PROOFSTEP] rw [ae_eq_empty, Real.volume_Icc_pi, prod_eq_zero (Finset.mem_univ i)] [GOAL] case this E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ a b : Fin (n + 1) → ℝ hle : a ≤ b f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ (Set.pi Set.univ fun i => Set.Ioo (a i) (b i)) \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (Set.Icc a b) this : (Set.pi Set.univ fun j => Set.Ioc (a j) (b j)) = ∅ j : Fin (n + 1) i : Fin n hi : a (Fin.succAbove j i) = b (Fin.succAbove j i) hi' : Set.Ioc (a (Fin.succAbove j i)) (b (Fin.succAbove j i)) = ∅ hne : Fin.succAbove j i ≠ j ⊢ ENNReal.ofReal ((b ∘ Fin.succAbove j) i - (a ∘ Fin.succAbove j) i) = 0 [PROOFSTEP] simp [hi] [GOAL] case inl.intro.inr.intro E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ a b : Fin (n + 1) → ℝ hle : a ≤ b f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ (Set.pi Set.univ fun i => Set.Ioo (a i) (b i)) \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (Set.Icc a b) this✝ : (Set.pi Set.univ fun j => Set.Ioc (a j) (b j)) = ∅ j : Fin (n + 1) i : Fin n hi : a (Fin.succAbove j i) = b (Fin.succAbove j i) hi' : Set.Ioc (a (Fin.succAbove j i)) (b (Fin.succAbove j i)) = ∅ hne : Fin.succAbove j i ≠ j this : Set.Icc (a ∘ Fin.succAbove j) (b ∘ Fin.succAbove j) =ᵐ[volume] ∅ ⊢ (∫ (x : Fin n → ℝ) in Set.Icc (a ∘ Fin.succAbove j) (b ∘ Fin.succAbove j), f (Fin.insertNth j (b j) x) j) - ∫ (x : Fin n → ℝ) in Set.Icc (a ∘ Fin.succAbove j) (b ∘ Fin.succAbove j), f (Fin.insertNth j (a j) x) j = 0 [PROOFSTEP] rw [set_integral_congr_set_ae this, set_integral_congr_set_ae this, integral_empty, integral_empty, sub_self] [GOAL] case inr E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ a b : Fin (n + 1) → ℝ hle : a ≤ b f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ (Set.pi Set.univ fun i => Set.Ioo (a i) (b i)) \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (Set.Icc a b) hne : ¬∃ i, a i = b i ⊢ ∫ (x : Fin (n + 1) → ℝ) in Set.Icc a b, ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in Set.Icc (a ∘ Fin.succAbove i) (b ∘ Fin.succAbove i), f (Fin.insertNth i (b i) x) i) - ∫ (x : Fin n → ℝ) in Set.Icc (a ∘ Fin.succAbove i) (b ∘ Fin.succAbove i), f (Fin.insertNth i (a i) x) i) [PROOFSTEP] have hlt : ∀ i, a i < b i := fun i => (hle i).lt_of_ne fun hi => hne ⟨i, hi⟩ [GOAL] case inr E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E n : ℕ a b : Fin (n + 1) → ℝ hle : a ≤ b f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E s : Set (Fin (n + 1) → ℝ) hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hd : ∀ (x : Fin (n + 1) → ℝ), x ∈ (Set.pi Set.univ fun i => Set.Ioo (a i) (b i)) \ s → HasFDerivAt f (f' x) x Hi : IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑(f' x) (e i) i) (Set.Icc a b) hne : ¬∃ i, a i = b i hlt : ∀ (i : Fin (n + 1)), a i < b i ⊢ ∫ (x : Fin (n + 1) → ℝ) in Set.Icc a b, ∑ i : Fin (n + 1), ↑(f' x) (e i) i = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in Set.Icc (a ∘ Fin.succAbove i) (b ∘ Fin.succAbove i), f (Fin.insertNth i (b i) x) i) - ∫ (x : Fin n → ℝ) in Set.Icc (a ∘ Fin.succAbove i) (b ∘ Fin.succAbove i), f (Fin.insertNth i (a i) x) i) [PROOFSTEP] exact integral_divergence_of_hasFDerivWithinAt_off_countable_aux₂ ⟨a, b, hlt⟩ f f' s hs Hc Hd Hi [GOAL] E : Type u inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace ℝ E inst✝⁵ : CompleteSpace E n : ℕ F : Type u_1 inst✝⁴ : NormedAddCommGroup F inst✝³ : NormedSpace ℝ F inst✝² : PartialOrder F inst✝¹ : MeasureSpace F inst✝ : BorelSpace F eL : F ≃L[ℝ] Fin (n + 1) → ℝ he_ord : ∀ (x y : F), ↑eL x ≤ ↑eL y ↔ x ≤ y he_vol : MeasurePreserving ↑eL f : Fin (n + 1) → F → E f' : Fin (n + 1) → F → F →L[ℝ] E s : Set F hs : Set.Countable s a b : F hle : a ≤ b Hc : ∀ (i : Fin (n + 1)), ContinuousOn (f i) (Set.Icc a b) Hd : ∀ (x : F), x ∈ interior (Set.Icc a b) \ s → ∀ (i : Fin (n + 1)), HasFDerivAt (f i) (f' i x) x DF : F → E hDF : ∀ (x : F), DF x = ∑ i : Fin (n + 1), ↑(f' i x) (↑(ContinuousLinearEquiv.symm eL) (e i)) Hi : IntegrableOn DF (Set.Icc a b) he_emb : MeasurableEmbedding ↑eL ⊢ ↑eL ⁻¹' Set.Icc (↑eL a) (↑eL b) = Set.Icc a b [PROOFSTEP] ext1 x [GOAL] case h E : Type u inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace ℝ E inst✝⁵ : CompleteSpace E n : ℕ F : Type u_1 inst✝⁴ : NormedAddCommGroup F inst✝³ : NormedSpace ℝ F inst✝² : PartialOrder F inst✝¹ : MeasureSpace F inst✝ : BorelSpace F eL : F ≃L[ℝ] Fin (n + 1) → ℝ he_ord : ∀ (x y : F), ↑eL x ≤ ↑eL y ↔ x ≤ y he_vol : MeasurePreserving ↑eL f : Fin (n + 1) → F → E f' : Fin (n + 1) → F → F →L[ℝ] E s : Set F hs : Set.Countable s a b : F hle : a ≤ b Hc : ∀ (i : Fin (n + 1)), ContinuousOn (f i) (Set.Icc a b) Hd : ∀ (x : F), x ∈ interior (Set.Icc a b) \ s → ∀ (i : Fin (n + 1)), HasFDerivAt (f i) (f' i x) x DF : F → E hDF : ∀ (x : F), DF x = ∑ i : Fin (n + 1), ↑(f' i x) (↑(ContinuousLinearEquiv.symm eL) (e i)) Hi : IntegrableOn DF (Set.Icc a b) he_emb : MeasurableEmbedding ↑eL x : F ⊢ x ∈ ↑eL ⁻¹' Set.Icc (↑eL a) (↑eL b) ↔ x ∈ Set.Icc a b [PROOFSTEP] simp only [Set.mem_preimage, Set.mem_Icc, he_ord] [GOAL] E : Type u inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace ℝ E inst✝⁵ : CompleteSpace E n : ℕ F : Type u_1 inst✝⁴ : NormedAddCommGroup F inst✝³ : NormedSpace ℝ F inst✝² : PartialOrder F inst✝¹ : MeasureSpace F inst✝ : BorelSpace F eL : F ≃L[ℝ] Fin (n + 1) → ℝ he_ord : ∀ (x y : F), ↑eL x ≤ ↑eL y ↔ x ≤ y he_vol : MeasurePreserving ↑eL f : Fin (n + 1) → F → E f' : Fin (n + 1) → F → F →L[ℝ] E s : Set F hs : Set.Countable s a b : F hle : a ≤ b Hc : ∀ (i : Fin (n + 1)), ContinuousOn (f i) (Set.Icc a b) Hd : ∀ (x : F), x ∈ interior (Set.Icc a b) \ s → ∀ (i : Fin (n + 1)), HasFDerivAt (f i) (f' i x) x DF : F → E hDF : ∀ (x : F), DF x = ∑ i : Fin (n + 1), ↑(f' i x) (↑(ContinuousLinearEquiv.symm eL) (e i)) Hi : IntegrableOn DF (Set.Icc a b) he_emb : MeasurableEmbedding ↑eL hIcc : ↑eL ⁻¹' Set.Icc (↑eL a) (↑eL b) = Set.Icc a b ⊢ Set.Icc (↑eL a) (↑eL b) = ↑(ContinuousLinearEquiv.symm eL) ⁻¹' Set.Icc a b [PROOFSTEP] rw [← hIcc, eL.symm_preimage_preimage] [GOAL] E : Type u inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace ℝ E inst✝⁵ : CompleteSpace E n : ℕ F : Type u_1 inst✝⁴ : NormedAddCommGroup F inst✝³ : NormedSpace ℝ F inst✝² : PartialOrder F inst✝¹ : MeasureSpace F inst✝ : BorelSpace F eL : F ≃L[ℝ] Fin (n + 1) → ℝ he_ord : ∀ (x y : F), ↑eL x ≤ ↑eL y ↔ x ≤ y he_vol : MeasurePreserving ↑eL f : Fin (n + 1) → F → E f' : Fin (n + 1) → F → F →L[ℝ] E s : Set F hs : Set.Countable s a b : F hle : a ≤ b Hc : ∀ (i : Fin (n + 1)), ContinuousOn (f i) (Set.Icc a b) Hd : ∀ (x : F), x ∈ interior (Set.Icc a b) \ s → ∀ (i : Fin (n + 1)), HasFDerivAt (f i) (f' i x) x DF : F → E hDF : ∀ (x : F), DF x = ∑ i : Fin (n + 1), ↑(f' i x) (↑(ContinuousLinearEquiv.symm eL) (e i)) Hi : IntegrableOn DF (Set.Icc a b) he_emb : MeasurableEmbedding ↑eL hIcc : ↑eL ⁻¹' Set.Icc (↑eL a) (↑eL b) = Set.Icc a b hIcc' : Set.Icc (↑eL a) (↑eL b) = ↑(ContinuousLinearEquiv.symm eL) ⁻¹' Set.Icc a b ⊢ ∫ (x : F) in Set.Icc a b, DF x = ∫ (x : F) in Set.Icc a b, ∑ i : Fin (n + 1), ↑(f' i x) (↑(ContinuousLinearEquiv.symm eL) (e i)) [PROOFSTEP] simp only [hDF] [GOAL] E : Type u inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace ℝ E inst✝⁵ : CompleteSpace E n : ℕ F : Type u_1 inst✝⁴ : NormedAddCommGroup F inst✝³ : NormedSpace ℝ F inst✝² : PartialOrder F inst✝¹ : MeasureSpace F inst✝ : BorelSpace F eL : F ≃L[ℝ] Fin (n + 1) → ℝ he_ord : ∀ (x y : F), ↑eL x ≤ ↑eL y ↔ x ≤ y he_vol : MeasurePreserving ↑eL f : Fin (n + 1) → F → E f' : Fin (n + 1) → F → F →L[ℝ] E s : Set F hs : Set.Countable s a b : F hle : a ≤ b Hc : ∀ (i : Fin (n + 1)), ContinuousOn (f i) (Set.Icc a b) Hd : ∀ (x : F), x ∈ interior (Set.Icc a b) \ s → ∀ (i : Fin (n + 1)), HasFDerivAt (f i) (f' i x) x DF : F → E hDF : ∀ (x : F), DF x = ∑ i : Fin (n + 1), ↑(f' i x) (↑(ContinuousLinearEquiv.symm eL) (e i)) Hi : IntegrableOn DF (Set.Icc a b) he_emb : MeasurableEmbedding ↑eL hIcc : ↑eL ⁻¹' Set.Icc (↑eL a) (↑eL b) = Set.Icc a b hIcc' : Set.Icc (↑eL a) (↑eL b) = ↑(ContinuousLinearEquiv.symm eL) ⁻¹' Set.Icc a b ⊢ ∫ (x : F) in Set.Icc a b, ∑ i : Fin (n + 1), ↑(f' i x) (↑(ContinuousLinearEquiv.symm eL) (e i)) = ∫ (x : (fun x => Fin (n + 1) → ℝ) a) in Set.Icc (↑eL a) (↑eL b), ∑ i : Fin (n + 1), ↑(f' i (↑(ContinuousLinearEquiv.symm eL) x)) (↑(ContinuousLinearEquiv.symm eL) (e i)) [PROOFSTEP] rw [← he_vol.set_integral_preimage_emb he_emb] [GOAL] E : Type u inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace ℝ E inst✝⁵ : CompleteSpace E n : ℕ F : Type u_1 inst✝⁴ : NormedAddCommGroup F inst✝³ : NormedSpace ℝ F inst✝² : PartialOrder F inst✝¹ : MeasureSpace F inst✝ : BorelSpace F eL : F ≃L[ℝ] Fin (n + 1) → ℝ he_ord : ∀ (x y : F), ↑eL x ≤ ↑eL y ↔ x ≤ y he_vol : MeasurePreserving ↑eL f : Fin (n + 1) → F → E f' : Fin (n + 1) → F → F →L[ℝ] E s : Set F hs : Set.Countable s a b : F hle : a ≤ b Hc : ∀ (i : Fin (n + 1)), ContinuousOn (f i) (Set.Icc a b) Hd : ∀ (x : F), x ∈ interior (Set.Icc a b) \ s → ∀ (i : Fin (n + 1)), HasFDerivAt (f i) (f' i x) x DF : F → E hDF : ∀ (x : F), DF x = ∑ i : Fin (n + 1), ↑(f' i x) (↑(ContinuousLinearEquiv.symm eL) (e i)) Hi : IntegrableOn DF (Set.Icc a b) he_emb : MeasurableEmbedding ↑eL hIcc : ↑eL ⁻¹' Set.Icc (↑eL a) (↑eL b) = Set.Icc a b hIcc' : Set.Icc (↑eL a) (↑eL b) = ↑(ContinuousLinearEquiv.symm eL) ⁻¹' Set.Icc a b ⊢ ∫ (x : F) in Set.Icc a b, ∑ i : Fin (n + 1), ↑(f' i x) (↑(ContinuousLinearEquiv.symm eL) (e i)) = ∫ (x : F) in ↑eL ⁻¹' Set.Icc (↑eL a) (↑eL b), ∑ i : Fin (n + 1), ↑(f' i (↑(ContinuousLinearEquiv.symm eL) (↑eL x))) (↑(ContinuousLinearEquiv.symm eL) (e i)) [PROOFSTEP] simp only [hIcc, eL.symm_apply_apply] [GOAL] E : Type u inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace ℝ E inst✝⁵ : CompleteSpace E n : ℕ F : Type u_1 inst✝⁴ : NormedAddCommGroup F inst✝³ : NormedSpace ℝ F inst✝² : PartialOrder F inst✝¹ : MeasureSpace F inst✝ : BorelSpace F eL : F ≃L[ℝ] Fin (n + 1) → ℝ he_ord : ∀ (x y : F), ↑eL x ≤ ↑eL y ↔ x ≤ y he_vol : MeasurePreserving ↑eL f : Fin (n + 1) → F → E f' : Fin (n + 1) → F → F →L[ℝ] E s : Set F hs : Set.Countable s a b : F hle : a ≤ b Hc : ∀ (i : Fin (n + 1)), ContinuousOn (f i) (Set.Icc a b) Hd : ∀ (x : F), x ∈ interior (Set.Icc a b) \ s → ∀ (i : Fin (n + 1)), HasFDerivAt (f i) (f' i x) x DF : F → E hDF : ∀ (x : F), DF x = ∑ i : Fin (n + 1), ↑(f' i x) (↑(ContinuousLinearEquiv.symm eL) (e i)) Hi : IntegrableOn DF (Set.Icc a b) he_emb : MeasurableEmbedding ↑eL hIcc : ↑eL ⁻¹' Set.Icc (↑eL a) (↑eL b) = Set.Icc a b hIcc' : Set.Icc (↑eL a) (↑eL b) = ↑(ContinuousLinearEquiv.symm eL) ⁻¹' Set.Icc a b ⊢ ∫ (x : (fun x => Fin (n + 1) → ℝ) a) in Set.Icc (↑eL a) (↑eL b), ∑ i : Fin (n + 1), ↑(f' i (↑(ContinuousLinearEquiv.symm eL) x)) (↑(ContinuousLinearEquiv.symm eL) (e i)) = ∑ i : Fin (n + 1), ((∫ (x : Fin n → ℝ) in Set.Icc (↑eL a ∘ Fin.succAbove i) (↑eL b ∘ Fin.succAbove i), f i (↑(ContinuousLinearEquiv.symm eL) (Fin.insertNth i (↑eL b i) x))) - ∫ (x : Fin n → ℝ) in Set.Icc (↑eL a ∘ Fin.succAbove i) (↑eL b ∘ Fin.succAbove i), f i (↑(ContinuousLinearEquiv.symm eL) (Fin.insertNth i (↑eL a i) x))) [PROOFSTEP] refine integral_divergence_of_hasFDerivWithinAt_off_countable' (eL a) (eL b) ((he_ord _ _).2 hle) (fun i x => f i (eL.symm x)) (fun i x => f' i (eL.symm x) ∘L (eL.symm : ℝⁿ⁺¹ →L[ℝ] F)) (eL.symm ⁻¹' s) (hs.preimage eL.symm.injective) ?_ ?_ ?_ [GOAL] case refine_1 E : Type u inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace ℝ E inst✝⁵ : CompleteSpace E n : ℕ F : Type u_1 inst✝⁴ : NormedAddCommGroup F inst✝³ : NormedSpace ℝ F inst✝² : PartialOrder F inst✝¹ : MeasureSpace F inst✝ : BorelSpace F eL : F ≃L[ℝ] Fin (n + 1) → ℝ he_ord : ∀ (x y : F), ↑eL x ≤ ↑eL y ↔ x ≤ y he_vol : MeasurePreserving ↑eL f : Fin (n + 1) → F → E f' : Fin (n + 1) → F → F →L[ℝ] E s : Set F hs : Set.Countable s a b : F hle : a ≤ b Hc : ∀ (i : Fin (n + 1)), ContinuousOn (f i) (Set.Icc a b) Hd : ∀ (x : F), x ∈ interior (Set.Icc a b) \ s → ∀ (i : Fin (n + 1)), HasFDerivAt (f i) (f' i x) x DF : F → E hDF : ∀ (x : F), DF x = ∑ i : Fin (n + 1), ↑(f' i x) (↑(ContinuousLinearEquiv.symm eL) (e i)) Hi : IntegrableOn DF (Set.Icc a b) he_emb : MeasurableEmbedding ↑eL hIcc : ↑eL ⁻¹' Set.Icc (↑eL a) (↑eL b) = Set.Icc a b hIcc' : Set.Icc (↑eL a) (↑eL b) = ↑(ContinuousLinearEquiv.symm eL) ⁻¹' Set.Icc a b ⊢ ∀ (i : Fin (n + 1)), ContinuousOn ((fun i x => f i (↑(ContinuousLinearEquiv.symm eL) x)) i) (Set.Icc (↑eL a) (↑eL b)) [PROOFSTEP] exact fun i => (Hc i).comp eL.symm.continuousOn hIcc'.subset [GOAL] case refine_2 E : Type u inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace ℝ E inst✝⁵ : CompleteSpace E n : ℕ F : Type u_1 inst✝⁴ : NormedAddCommGroup F inst✝³ : NormedSpace ℝ F inst✝² : PartialOrder F inst✝¹ : MeasureSpace F inst✝ : BorelSpace F eL : F ≃L[ℝ] Fin (n + 1) → ℝ he_ord : ∀ (x y : F), ↑eL x ≤ ↑eL y ↔ x ≤ y he_vol : MeasurePreserving ↑eL f : Fin (n + 1) → F → E f' : Fin (n + 1) → F → F →L[ℝ] E s : Set F hs : Set.Countable s a b : F hle : a ≤ b Hc : ∀ (i : Fin (n + 1)), ContinuousOn (f i) (Set.Icc a b) Hd : ∀ (x : F), x ∈ interior (Set.Icc a b) \ s → ∀ (i : Fin (n + 1)), HasFDerivAt (f i) (f' i x) x DF : F → E hDF : ∀ (x : F), DF x = ∑ i : Fin (n + 1), ↑(f' i x) (↑(ContinuousLinearEquiv.symm eL) (e i)) Hi : IntegrableOn DF (Set.Icc a b) he_emb : MeasurableEmbedding ↑eL hIcc : ↑eL ⁻¹' Set.Icc (↑eL a) (↑eL b) = Set.Icc a b hIcc' : Set.Icc (↑eL a) (↑eL b) = ↑(ContinuousLinearEquiv.symm eL) ⁻¹' Set.Icc a b ⊢ ∀ (x : Fin (n + 1) → ℝ), x ∈ (Set.pi Set.univ fun i => Set.Ioo (↑eL a i) (↑eL b i)) \ ↑(ContinuousLinearEquiv.symm eL) ⁻¹' s → ∀ (i : Fin (n + 1)), HasFDerivAt ((fun i x => f i (↑(ContinuousLinearEquiv.symm eL) x)) i) ((fun i x => ContinuousLinearMap.comp (f' i (↑(ContinuousLinearEquiv.symm eL) x)) ↑(ContinuousLinearEquiv.symm eL)) i x) x [PROOFSTEP] refine' fun x hx i => (Hd (eL.symm x) ⟨_, hx.2⟩ i).comp x eL.symm.hasFDerivAt [GOAL] case refine_2 E : Type u inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace ℝ E inst✝⁵ : CompleteSpace E n : ℕ F : Type u_1 inst✝⁴ : NormedAddCommGroup F inst✝³ : NormedSpace ℝ F inst✝² : PartialOrder F inst✝¹ : MeasureSpace F inst✝ : BorelSpace F eL : F ≃L[ℝ] Fin (n + 1) → ℝ he_ord : ∀ (x y : F), ↑eL x ≤ ↑eL y ↔ x ≤ y he_vol : MeasurePreserving ↑eL f : Fin (n + 1) → F → E f' : Fin (n + 1) → F → F →L[ℝ] E s : Set F hs : Set.Countable s a b : F hle : a ≤ b Hc : ∀ (i : Fin (n + 1)), ContinuousOn (f i) (Set.Icc a b) Hd : ∀ (x : F), x ∈ interior (Set.Icc a b) \ s → ∀ (i : Fin (n + 1)), HasFDerivAt (f i) (f' i x) x DF : F → E hDF : ∀ (x : F), DF x = ∑ i : Fin (n + 1), ↑(f' i x) (↑(ContinuousLinearEquiv.symm eL) (e i)) Hi : IntegrableOn DF (Set.Icc a b) he_emb : MeasurableEmbedding ↑eL hIcc : ↑eL ⁻¹' Set.Icc (↑eL a) (↑eL b) = Set.Icc a b hIcc' : Set.Icc (↑eL a) (↑eL b) = ↑(ContinuousLinearEquiv.symm eL) ⁻¹' Set.Icc a b x : Fin (n + 1) → ℝ hx : x ∈ (Set.pi Set.univ fun i => Set.Ioo (↑eL a i) (↑eL b i)) \ ↑(ContinuousLinearEquiv.symm eL) ⁻¹' s i : Fin (n + 1) ⊢ ↑(ContinuousLinearEquiv.symm eL) x ∈ interior (Set.Icc a b) [PROOFSTEP] rw [← hIcc] [GOAL] case refine_2 E : Type u inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace ℝ E inst✝⁵ : CompleteSpace E n : ℕ F : Type u_1 inst✝⁴ : NormedAddCommGroup F inst✝³ : NormedSpace ℝ F inst✝² : PartialOrder F inst✝¹ : MeasureSpace F inst✝ : BorelSpace F eL : F ≃L[ℝ] Fin (n + 1) → ℝ he_ord : ∀ (x y : F), ↑eL x ≤ ↑eL y ↔ x ≤ y he_vol : MeasurePreserving ↑eL f : Fin (n + 1) → F → E f' : Fin (n + 1) → F → F →L[ℝ] E s : Set F hs : Set.Countable s a b : F hle : a ≤ b Hc : ∀ (i : Fin (n + 1)), ContinuousOn (f i) (Set.Icc a b) Hd : ∀ (x : F), x ∈ interior (Set.Icc a b) \ s → ∀ (i : Fin (n + 1)), HasFDerivAt (f i) (f' i x) x DF : F → E hDF : ∀ (x : F), DF x = ∑ i : Fin (n + 1), ↑(f' i x) (↑(ContinuousLinearEquiv.symm eL) (e i)) Hi : IntegrableOn DF (Set.Icc a b) he_emb : MeasurableEmbedding ↑eL hIcc : ↑eL ⁻¹' Set.Icc (↑eL a) (↑eL b) = Set.Icc a b hIcc' : Set.Icc (↑eL a) (↑eL b) = ↑(ContinuousLinearEquiv.symm eL) ⁻¹' Set.Icc a b x : Fin (n + 1) → ℝ hx : x ∈ (Set.pi Set.univ fun i => Set.Ioo (↑eL a i) (↑eL b i)) \ ↑(ContinuousLinearEquiv.symm eL) ⁻¹' s i : Fin (n + 1) ⊢ ↑(ContinuousLinearEquiv.symm eL) x ∈ interior (↑eL ⁻¹' Set.Icc (↑eL a) (↑eL b)) [PROOFSTEP] refine' preimage_interior_subset_interior_preimage eL.continuous _ [GOAL] case refine_2 E : Type u inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace ℝ E inst✝⁵ : CompleteSpace E n : ℕ F : Type u_1 inst✝⁴ : NormedAddCommGroup F inst✝³ : NormedSpace ℝ F inst✝² : PartialOrder F inst✝¹ : MeasureSpace F inst✝ : BorelSpace F eL : F ≃L[ℝ] Fin (n + 1) → ℝ he_ord : ∀ (x y : F), ↑eL x ≤ ↑eL y ↔ x ≤ y he_vol : MeasurePreserving ↑eL f : Fin (n + 1) → F → E f' : Fin (n + 1) → F → F →L[ℝ] E s : Set F hs : Set.Countable s a b : F hle : a ≤ b Hc : ∀ (i : Fin (n + 1)), ContinuousOn (f i) (Set.Icc a b) Hd : ∀ (x : F), x ∈ interior (Set.Icc a b) \ s → ∀ (i : Fin (n + 1)), HasFDerivAt (f i) (f' i x) x DF : F → E hDF : ∀ (x : F), DF x = ∑ i : Fin (n + 1), ↑(f' i x) (↑(ContinuousLinearEquiv.symm eL) (e i)) Hi : IntegrableOn DF (Set.Icc a b) he_emb : MeasurableEmbedding ↑eL hIcc : ↑eL ⁻¹' Set.Icc (↑eL a) (↑eL b) = Set.Icc a b hIcc' : Set.Icc (↑eL a) (↑eL b) = ↑(ContinuousLinearEquiv.symm eL) ⁻¹' Set.Icc a b x : Fin (n + 1) → ℝ hx : x ∈ (Set.pi Set.univ fun i => Set.Ioo (↑eL a i) (↑eL b i)) \ ↑(ContinuousLinearEquiv.symm eL) ⁻¹' s i : Fin (n + 1) ⊢ ↑(ContinuousLinearEquiv.symm eL) x ∈ ↑eL ⁻¹' interior (Set.Icc (↑eL a) (↑eL b)) [PROOFSTEP] simpa only [Set.mem_preimage, eL.apply_symm_apply, ← pi_univ_Icc, interior_pi_set (@finite_univ (Fin _) _), interior_Icc] using hx.1 [GOAL] case refine_3 E : Type u inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace ℝ E inst✝⁵ : CompleteSpace E n : ℕ F : Type u_1 inst✝⁴ : NormedAddCommGroup F inst✝³ : NormedSpace ℝ F inst✝² : PartialOrder F inst✝¹ : MeasureSpace F inst✝ : BorelSpace F eL : F ≃L[ℝ] Fin (n + 1) → ℝ he_ord : ∀ (x y : F), ↑eL x ≤ ↑eL y ↔ x ≤ y he_vol : MeasurePreserving ↑eL f : Fin (n + 1) → F → E f' : Fin (n + 1) → F → F →L[ℝ] E s : Set F hs : Set.Countable s a b : F hle : a ≤ b Hc : ∀ (i : Fin (n + 1)), ContinuousOn (f i) (Set.Icc a b) Hd : ∀ (x : F), x ∈ interior (Set.Icc a b) \ s → ∀ (i : Fin (n + 1)), HasFDerivAt (f i) (f' i x) x DF : F → E hDF : ∀ (x : F), DF x = ∑ i : Fin (n + 1), ↑(f' i x) (↑(ContinuousLinearEquiv.symm eL) (e i)) Hi : IntegrableOn DF (Set.Icc a b) he_emb : MeasurableEmbedding ↑eL hIcc : ↑eL ⁻¹' Set.Icc (↑eL a) (↑eL b) = Set.Icc a b hIcc' : Set.Icc (↑eL a) (↑eL b) = ↑(ContinuousLinearEquiv.symm eL) ⁻¹' Set.Icc a b ⊢ IntegrableOn (fun x => ∑ i : Fin (n + 1), ↑((fun i x => ContinuousLinearMap.comp (f' i (↑(ContinuousLinearEquiv.symm eL) x)) ↑(ContinuousLinearEquiv.symm eL)) i x) (e i)) (Set.Icc (↑eL a) (↑eL b)) [PROOFSTEP] rw [← he_vol.integrableOn_comp_preimage he_emb, hIcc] [GOAL] case refine_3 E : Type u inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace ℝ E inst✝⁵ : CompleteSpace E n : ℕ F : Type u_1 inst✝⁴ : NormedAddCommGroup F inst✝³ : NormedSpace ℝ F inst✝² : PartialOrder F inst✝¹ : MeasureSpace F inst✝ : BorelSpace F eL : F ≃L[ℝ] Fin (n + 1) → ℝ he_ord : ∀ (x y : F), ↑eL x ≤ ↑eL y ↔ x ≤ y he_vol : MeasurePreserving ↑eL f : Fin (n + 1) → F → E f' : Fin (n + 1) → F → F →L[ℝ] E s : Set F hs : Set.Countable s a b : F hle : a ≤ b Hc : ∀ (i : Fin (n + 1)), ContinuousOn (f i) (Set.Icc a b) Hd : ∀ (x : F), x ∈ interior (Set.Icc a b) \ s → ∀ (i : Fin (n + 1)), HasFDerivAt (f i) (f' i x) x DF : F → E hDF : ∀ (x : F), DF x = ∑ i : Fin (n + 1), ↑(f' i x) (↑(ContinuousLinearEquiv.symm eL) (e i)) Hi : IntegrableOn DF (Set.Icc a b) he_emb : MeasurableEmbedding ↑eL hIcc : ↑eL ⁻¹' Set.Icc (↑eL a) (↑eL b) = Set.Icc a b hIcc' : Set.Icc (↑eL a) (↑eL b) = ↑(ContinuousLinearEquiv.symm eL) ⁻¹' Set.Icc a b ⊢ IntegrableOn ((fun x => ∑ i : Fin (n + 1), ↑((fun i x => ContinuousLinearMap.comp (f' i (↑(ContinuousLinearEquiv.symm eL) x)) ↑(ContinuousLinearEquiv.symm eL)) i x) (e i)) ∘ ↑eL) (Set.Icc a b) [PROOFSTEP] simp [← hDF, (· ∘ ·), Hi] [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f f' : ℝ → E a b : ℝ hle : a ≤ b s : Set ℝ hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hd : ∀ (x : ℝ), x ∈ Set.Ioo a b \ s → HasDerivAt f (f' x) x Hi : IntervalIntegrable f' volume a b ⊢ ∫ (x : ℝ) in a..b, f' x = f b - f a [PROOFSTEP] set e : ℝ ≃L[ℝ] ℝ¹ := (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ).symm [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f f' : ℝ → E a b : ℝ hle : a ≤ b s : Set ℝ hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hd : ∀ (x : ℝ), x ∈ Set.Ioo a b \ s → HasDerivAt f (f' x) x Hi : IntervalIntegrable f' volume a b e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ) ⊢ ∫ (x : ℝ) in a..b, f' x = f b - f a [PROOFSTEP] have e_symm : ∀ x, e.symm x = x 0 := fun x => rfl [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f f' : ℝ → E a b : ℝ hle : a ≤ b s : Set ℝ hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hd : ∀ (x : ℝ), x ∈ Set.Ioo a b \ s → HasDerivAt f (f' x) x Hi : IntervalIntegrable f' volume a b e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ) e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0 ⊢ ∫ (x : ℝ) in a..b, f' x = f b - f a [PROOFSTEP] set F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight (1 : ℝ →L[ℝ] ℝ) (f' x) [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f f' : ℝ → E a b : ℝ hle : a ≤ b s : Set ℝ hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hd : ∀ (x : ℝ), x ∈ Set.Ioo a b \ s → HasDerivAt f (f' x) x Hi : IntervalIntegrable f' volume a b e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ) e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0 F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight 1 (f' x) ⊢ ∫ (x : ℝ) in a..b, f' x = f b - f a [PROOFSTEP] have hF' : ∀ x y, F' x y = y • f' x := fun x y => rfl [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f f' : ℝ → E a b : ℝ hle : a ≤ b s : Set ℝ hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hd : ∀ (x : ℝ), x ∈ Set.Ioo a b \ s → HasDerivAt f (f' x) x Hi : IntervalIntegrable f' volume a b e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ) e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0 F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight 1 (f' x) hF' : ∀ (x y : ℝ), ↑(F' x) y = y • f' x ⊢ ∫ (x : ℝ) in a..b, f' x = f b - f a [PROOFSTEP] calc ∫ x in a..b, f' x = ∫ x in Icc a b, f' x := by rw [intervalIntegral.integral_of_le hle, set_integral_congr_set_ae Ioc_ae_eq_Icc] _ = ∑ i : Fin 1, ((∫ x in Icc (e a ∘ i.succAbove) (e b ∘ i.succAbove), f (e.symm <| i.insertNth (e b i) x)) - ∫ x in Icc (e a ∘ i.succAbove) (e b ∘ i.succAbove), f (e.symm <| i.insertNth (e a i) x)) := by simp only [← interior_Icc] at Hd refine' integral_divergence_of_hasFDerivWithinAt_off_countable_of_equiv e _ _ (fun _ => f) (fun _ => F') s hs a b hle (fun _ => Hc) (fun x hx _ => Hd x hx) _ _ _ · exact fun x y => (OrderIso.funUnique (Fin 1) ℝ).symm.le_iff_le · exact (volume_preserving_funUnique (Fin 1) ℝ).symm _ · intro x; rw [Fin.sum_univ_one, hF', e_symm, Pi.single_eq_same, one_smul] · rw [intervalIntegrable_iff_integrable_Ioc_of_le hle] at Hi exact Hi.congr_set_ae Ioc_ae_eq_Icc.symm _ = f b - f a := by simp only [Fin.sum_univ_one, e_symm] have : ∀ c : ℝ, const (Fin 0) c = isEmptyElim := fun c => Subsingleton.elim _ _ simp [this, volume_pi, Measure.pi_of_empty fun _ : Fin 0 => volume] [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f f' : ℝ → E a b : ℝ hle : a ≤ b s : Set ℝ hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hd : ∀ (x : ℝ), x ∈ Set.Ioo a b \ s → HasDerivAt f (f' x) x Hi : IntervalIntegrable f' volume a b e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ) e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0 F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight 1 (f' x) hF' : ∀ (x y : ℝ), ↑(F' x) y = y • f' x ⊢ ∫ (x : ℝ) in a..b, f' x = ∫ (x : ℝ) in Set.Icc a b, f' x [PROOFSTEP] rw [intervalIntegral.integral_of_le hle, set_integral_congr_set_ae Ioc_ae_eq_Icc] [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f f' : ℝ → E a b : ℝ hle : a ≤ b s : Set ℝ hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hd : ∀ (x : ℝ), x ∈ Set.Ioo a b \ s → HasDerivAt f (f' x) x Hi : IntervalIntegrable f' volume a b e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ) e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0 F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight 1 (f' x) hF' : ∀ (x y : ℝ), ↑(F' x) y = y • f' x ⊢ ∫ (x : ℝ) in Set.Icc a b, f' x = ∑ i : Fin 1, ((∫ (x : Fin 0 → ℝ) in Set.Icc (↑e a ∘ Fin.succAbove i) (↑e b ∘ Fin.succAbove i), f (↑(ContinuousLinearEquiv.symm e) (Fin.insertNth i (↑e b i) x))) - ∫ (x : Fin 0 → ℝ) in Set.Icc (↑e a ∘ Fin.succAbove i) (↑e b ∘ Fin.succAbove i), f (↑(ContinuousLinearEquiv.symm e) (Fin.insertNth i (↑e a i) x))) [PROOFSTEP] simp only [← interior_Icc] at Hd [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f f' : ℝ → E a b : ℝ hle : a ≤ b s : Set ℝ hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hi : IntervalIntegrable f' volume a b e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ) e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0 F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight 1 (f' x) hF' : ∀ (x y : ℝ), ↑(F' x) y = y • f' x Hd : ∀ (x : ℝ), x ∈ interior (Set.Icc a b) \ s → HasDerivAt f (f' x) x ⊢ ∫ (x : ℝ) in Set.Icc a b, f' x = ∑ i : Fin 1, ((∫ (x : Fin 0 → ℝ) in Set.Icc (↑e a ∘ Fin.succAbove i) (↑e b ∘ Fin.succAbove i), f (↑(ContinuousLinearEquiv.symm e) (Fin.insertNth i (↑e b i) x))) - ∫ (x : Fin 0 → ℝ) in Set.Icc (↑e a ∘ Fin.succAbove i) (↑e b ∘ Fin.succAbove i), f (↑(ContinuousLinearEquiv.symm e) (Fin.insertNth i (↑e a i) x))) [PROOFSTEP] refine' integral_divergence_of_hasFDerivWithinAt_off_countable_of_equiv e _ _ (fun _ => f) (fun _ => F') s hs a b hle (fun _ => Hc) (fun x hx _ => Hd x hx) _ _ _ [GOAL] case refine'_1 E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f f' : ℝ → E a b : ℝ hle : a ≤ b s : Set ℝ hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hi : IntervalIntegrable f' volume a b e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ) e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0 F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight 1 (f' x) hF' : ∀ (x y : ℝ), ↑(F' x) y = y • f' x Hd : ∀ (x : ℝ), x ∈ interior (Set.Icc a b) \ s → HasDerivAt f (f' x) x ⊢ ∀ (x y : ℝ), ↑e x ≤ ↑e y ↔ x ≤ y [PROOFSTEP] exact fun x y => (OrderIso.funUnique (Fin 1) ℝ).symm.le_iff_le [GOAL] case refine'_2 E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f f' : ℝ → E a b : ℝ hle : a ≤ b s : Set ℝ hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hi : IntervalIntegrable f' volume a b e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ) e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0 F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight 1 (f' x) hF' : ∀ (x y : ℝ), ↑(F' x) y = y • f' x Hd : ∀ (x : ℝ), x ∈ interior (Set.Icc a b) \ s → HasDerivAt f (f' x) x ⊢ MeasurePreserving ↑e [PROOFSTEP] exact (volume_preserving_funUnique (Fin 1) ℝ).symm _ [GOAL] case refine'_3 E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f f' : ℝ → E a b : ℝ hle : a ≤ b s : Set ℝ hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hi : IntervalIntegrable f' volume a b e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ) e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0 F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight 1 (f' x) hF' : ∀ (x y : ℝ), ↑(F' x) y = y • f' x Hd : ∀ (x : ℝ), x ∈ interior (Set.Icc a b) \ s → HasDerivAt f (f' x) x ⊢ ∀ (x : ℝ), f' x = ∑ i : Fin (0 + 1), ↑((fun x => F') i x) (↑(ContinuousLinearEquiv.symm e) (Pi.single i 1)) [PROOFSTEP] intro x [GOAL] case refine'_3 E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f f' : ℝ → E a b : ℝ hle : a ≤ b s : Set ℝ hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hi : IntervalIntegrable f' volume a b e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ) e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0 F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight 1 (f' x) hF' : ∀ (x y : ℝ), ↑(F' x) y = y • f' x Hd : ∀ (x : ℝ), x ∈ interior (Set.Icc a b) \ s → HasDerivAt f (f' x) x x : ℝ ⊢ f' x = ∑ i : Fin (0 + 1), ↑((fun x => F') i x) (↑(ContinuousLinearEquiv.symm e) (Pi.single i 1)) [PROOFSTEP] rw [Fin.sum_univ_one, hF', e_symm, Pi.single_eq_same, one_smul] [GOAL] case refine'_4 E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f f' : ℝ → E a b : ℝ hle : a ≤ b s : Set ℝ hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hi : IntervalIntegrable f' volume a b e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ) e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0 F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight 1 (f' x) hF' : ∀ (x y : ℝ), ↑(F' x) y = y • f' x Hd : ∀ (x : ℝ), x ∈ interior (Set.Icc a b) \ s → HasDerivAt f (f' x) x ⊢ IntegrableOn (fun x => f' x) (Set.Icc a b) [PROOFSTEP] rw [intervalIntegrable_iff_integrable_Ioc_of_le hle] at Hi [GOAL] case refine'_4 E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f f' : ℝ → E a b : ℝ hle : a ≤ b s : Set ℝ hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hi : IntegrableOn f' (Set.Ioc a b) e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ) e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0 F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight 1 (f' x) hF' : ∀ (x y : ℝ), ↑(F' x) y = y • f' x Hd : ∀ (x : ℝ), x ∈ interior (Set.Icc a b) \ s → HasDerivAt f (f' x) x ⊢ IntegrableOn (fun x => f' x) (Set.Icc a b) [PROOFSTEP] exact Hi.congr_set_ae Ioc_ae_eq_Icc.symm [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f f' : ℝ → E a b : ℝ hle : a ≤ b s : Set ℝ hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hd : ∀ (x : ℝ), x ∈ Set.Ioo a b \ s → HasDerivAt f (f' x) x Hi : IntervalIntegrable f' volume a b e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ) e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0 F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight 1 (f' x) hF' : ∀ (x y : ℝ), ↑(F' x) y = y • f' x ⊢ ∑ i : Fin 1, ((∫ (x : Fin 0 → ℝ) in Set.Icc (↑e a ∘ Fin.succAbove i) (↑e b ∘ Fin.succAbove i), f (↑(ContinuousLinearEquiv.symm e) (Fin.insertNth i (↑e b i) x))) - ∫ (x : Fin 0 → ℝ) in Set.Icc (↑e a ∘ Fin.succAbove i) (↑e b ∘ Fin.succAbove i), f (↑(ContinuousLinearEquiv.symm e) (Fin.insertNth i (↑e a i) x))) = f b - f a [PROOFSTEP] simp only [Fin.sum_univ_one, e_symm] [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f f' : ℝ → E a b : ℝ hle : a ≤ b s : Set ℝ hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hd : ∀ (x : ℝ), x ∈ Set.Ioo a b \ s → HasDerivAt f (f' x) x Hi : IntervalIntegrable f' volume a b e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ) e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0 F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight 1 (f' x) hF' : ∀ (x y : ℝ), ↑(F' x) y = y • f' x ⊢ (∫ (x : Fin 0 → ℝ) in Set.Icc (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)) a ∘ Fin.succAbove 0) (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)) b ∘ Fin.succAbove 0), f (Fin.insertNth 0 (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)) b 0) x 0)) - ∫ (x : Fin 0 → ℝ) in Set.Icc (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)) a ∘ Fin.succAbove 0) (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)) b ∘ Fin.succAbove 0), f (Fin.insertNth 0 (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)) a 0) x 0) = f b - f a [PROOFSTEP] have : ∀ c : ℝ, const (Fin 0) c = isEmptyElim := fun c => Subsingleton.elim _ _ [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f f' : ℝ → E a b : ℝ hle : a ≤ b s : Set ℝ hs : Set.Countable s Hc : ContinuousOn f (Set.Icc a b) Hd : ∀ (x : ℝ), x ∈ Set.Ioo a b \ s → HasDerivAt f (f' x) x Hi : IntervalIntegrable f' volume a b e : ℝ ≃L[ℝ] Fin 1 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ) e_symm : ∀ (x : Fin 1 → ℝ), ↑(ContinuousLinearEquiv.symm e) x = x 0 F' : ℝ → ℝ →L[ℝ] E := fun x => smulRight 1 (f' x) hF' : ∀ (x y : ℝ), ↑(F' x) y = y • f' x this : ∀ (c : ℝ), const (Fin 0) c = fun a => isEmptyElim a ⊢ (∫ (x : Fin 0 → ℝ) in Set.Icc (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)) a ∘ Fin.succAbove 0) (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)) b ∘ Fin.succAbove 0), f (Fin.insertNth 0 (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)) b 0) x 0)) - ∫ (x : Fin 0 → ℝ) in Set.Icc (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)) a ∘ Fin.succAbove 0) (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)) b ∘ Fin.succAbove 0), f (Fin.insertNth 0 (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.funUnique (Fin 1) ℝ ℝ)) a 0) x 0) = f b - f a [PROOFSTEP] simp [this, volume_pi, Measure.pi_of_empty fun _ : Fin 0 => volume] [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f f' : ℝ → E a b : ℝ s : Set ℝ hs : Set.Countable s Hc : ContinuousOn f [[a, b]] Hd : ∀ (x : ℝ), x ∈ Set.Ioo (min a b) (max a b) \ s → HasDerivAt f (f' x) x Hi : IntervalIntegrable f' volume a b ⊢ ∫ (x : ℝ) in a..b, f' x = f b - f a [PROOFSTEP] cases' le_total a b with hab hab [GOAL] case inl E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f f' : ℝ → E a b : ℝ s : Set ℝ hs : Set.Countable s Hc : ContinuousOn f [[a, b]] Hd : ∀ (x : ℝ), x ∈ Set.Ioo (min a b) (max a b) \ s → HasDerivAt f (f' x) x Hi : IntervalIntegrable f' volume a b hab : a ≤ b ⊢ ∫ (x : ℝ) in a..b, f' x = f b - f a [PROOFSTEP] simp only [uIcc_of_le hab, min_eq_left hab, max_eq_right hab] at * [GOAL] case inl E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f f' : ℝ → E a b : ℝ s : Set ℝ hs : Set.Countable s Hi : IntervalIntegrable f' volume a b hab : a ≤ b Hc : ContinuousOn f (Set.Icc a b) Hd : ∀ (x : ℝ), x ∈ Set.Ioo a b \ s → HasDerivAt f (f' x) x ⊢ ∫ (x : ℝ) in a..b, f' x = f b - f a [PROOFSTEP] exact integral_eq_of_hasDerivWithinAt_off_countable_of_le f f' hab hs Hc Hd Hi [GOAL] case inr E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f f' : ℝ → E a b : ℝ s : Set ℝ hs : Set.Countable s Hc : ContinuousOn f [[a, b]] Hd : ∀ (x : ℝ), x ∈ Set.Ioo (min a b) (max a b) \ s → HasDerivAt f (f' x) x Hi : IntervalIntegrable f' volume a b hab : b ≤ a ⊢ ∫ (x : ℝ) in a..b, f' x = f b - f a [PROOFSTEP] simp only [uIcc_of_ge hab, min_eq_right hab, max_eq_left hab] at * [GOAL] case inr E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f f' : ℝ → E a b : ℝ s : Set ℝ hs : Set.Countable s Hi : IntervalIntegrable f' volume a b hab : b ≤ a Hc : ContinuousOn f (Set.Icc b a) Hd : ∀ (x : ℝ), x ∈ Set.Ioo b a \ s → HasDerivAt f (f' x) x ⊢ ∫ (x : ℝ) in a..b, f' x = f b - f a [PROOFSTEP] rw [intervalIntegral.integral_symm, neg_eq_iff_eq_neg, neg_sub] [GOAL] case inr E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f f' : ℝ → E a b : ℝ s : Set ℝ hs : Set.Countable s Hi : IntervalIntegrable f' volume a b hab : b ≤ a Hc : ContinuousOn f (Set.Icc b a) Hd : ∀ (x : ℝ), x ∈ Set.Ioo b a \ s → HasDerivAt f (f' x) x ⊢ ∫ (x : ℝ) in b..a, f' x = f a - f b [PROOFSTEP] exact integral_eq_of_hasDerivWithinAt_off_countable_of_le f f' hab hs Hc Hd Hi.symm [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a b : ℝ × ℝ hle : a ≤ b s : Set (ℝ × ℝ) hs : Set.Countable s Hcf : ContinuousOn f (Set.Icc a b) Hcg : ContinuousOn g (Set.Icc a b) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc a b) e : (ℝ × ℝ) ≃L[ℝ] Fin 2 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ) ⊢ ∫ (x : ℝ × ℝ) in Set.Icc a b, ↑(f' x) (1, 0) + ↑(g' x) (0, 1) = ∑ i : Fin 2, ((∫ (x : Fin 1 → ℝ) in Set.Icc (↑e a ∘ Fin.succAbove i) (↑e b ∘ Fin.succAbove i), Matrix.vecCons f ![g] i (↑(ContinuousLinearEquiv.symm e) (Fin.insertNth i (↑e b i) x))) - ∫ (x : Fin 1 → ℝ) in Set.Icc (↑e a ∘ Fin.succAbove i) (↑e b ∘ Fin.succAbove i), Matrix.vecCons f ![g] i (↑(ContinuousLinearEquiv.symm e) (Fin.insertNth i (↑e a i) x))) [PROOFSTEP] refine' integral_divergence_of_hasFDerivWithinAt_off_countable_of_equiv e _ _ ![f, g] ![f', g'] s hs a b hle _ (fun x hx => _) _ _ Hi [GOAL] case refine'_1 E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a b : ℝ × ℝ hle : a ≤ b s : Set (ℝ × ℝ) hs : Set.Countable s Hcf : ContinuousOn f (Set.Icc a b) Hcg : ContinuousOn g (Set.Icc a b) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc a b) e : (ℝ × ℝ) ≃L[ℝ] Fin 2 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ) ⊢ ∀ (x y : ℝ × ℝ), ↑e x ≤ ↑e y ↔ x ≤ y [PROOFSTEP] exact fun x y => (OrderIso.finTwoArrowIso ℝ).symm.le_iff_le [GOAL] case refine'_2 E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a b : ℝ × ℝ hle : a ≤ b s : Set (ℝ × ℝ) hs : Set.Countable s Hcf : ContinuousOn f (Set.Icc a b) Hcg : ContinuousOn g (Set.Icc a b) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc a b) e : (ℝ × ℝ) ≃L[ℝ] Fin 2 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ) ⊢ MeasurePreserving ↑e [PROOFSTEP] exact (volume_preserving_finTwoArrow ℝ).symm _ [GOAL] case refine'_3 E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a b : ℝ × ℝ hle : a ≤ b s : Set (ℝ × ℝ) hs : Set.Countable s Hcf : ContinuousOn f (Set.Icc a b) Hcg : ContinuousOn g (Set.Icc a b) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc a b) e : (ℝ × ℝ) ≃L[ℝ] Fin 2 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ) ⊢ ∀ (i : Fin (1 + 1)), ContinuousOn (Matrix.vecCons f ![g] i) (Set.Icc a b) [PROOFSTEP] exact Fin.forall_fin_two.2 ⟨Hcf, Hcg⟩ [GOAL] case refine'_4 E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a b : ℝ × ℝ hle : a ≤ b s : Set (ℝ × ℝ) hs : Set.Countable s Hcf : ContinuousOn f (Set.Icc a b) Hcg : ContinuousOn g (Set.Icc a b) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc a b) e : (ℝ × ℝ) ≃L[ℝ] Fin 2 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ) x : ℝ × ℝ hx : x ∈ interior (Set.Icc a b) \ s ⊢ ∀ (i : Fin (1 + 1)), HasFDerivAt (Matrix.vecCons f ![g] i) (Matrix.vecCons f' ![g'] i x) x [PROOFSTEP] rw [Icc_prod_eq, interior_prod_eq, interior_Icc, interior_Icc] at hx [GOAL] case refine'_4 E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a b : ℝ × ℝ hle : a ≤ b s : Set (ℝ × ℝ) hs : Set.Countable s Hcf : ContinuousOn f (Set.Icc a b) Hcg : ContinuousOn g (Set.Icc a b) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc a b) e : (ℝ × ℝ) ≃L[ℝ] Fin 2 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ) x : ℝ × ℝ hx : x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s ⊢ ∀ (i : Fin (1 + 1)), HasFDerivAt (Matrix.vecCons f ![g] i) (Matrix.vecCons f' ![g'] i x) x [PROOFSTEP] exact Fin.forall_fin_two.2 ⟨Hdf x hx, Hdg x hx⟩ [GOAL] case refine'_5 E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a b : ℝ × ℝ hle : a ≤ b s : Set (ℝ × ℝ) hs : Set.Countable s Hcf : ContinuousOn f (Set.Icc a b) Hcg : ContinuousOn g (Set.Icc a b) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc a b) e : (ℝ × ℝ) ≃L[ℝ] Fin 2 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ) ⊢ ∀ (x : ℝ × ℝ), ↑(f' x) (1, 0) + ↑(g' x) (0, 1) = ∑ i : Fin (1 + 1), ↑(Matrix.vecCons f' ![g'] i x) (↑(ContinuousLinearEquiv.symm e) (Pi.single i 1)) [PROOFSTEP] intro x [GOAL] case refine'_5 E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a b : ℝ × ℝ hle : a ≤ b s : Set (ℝ × ℝ) hs : Set.Countable s Hcf : ContinuousOn f (Set.Icc a b) Hcg : ContinuousOn g (Set.Icc a b) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc a b) e : (ℝ × ℝ) ≃L[ℝ] Fin 2 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ) x : ℝ × ℝ ⊢ ↑(f' x) (1, 0) + ↑(g' x) (0, 1) = ∑ i : Fin (1 + 1), ↑(Matrix.vecCons f' ![g'] i x) (↑(ContinuousLinearEquiv.symm e) (Pi.single i 1)) [PROOFSTEP] rw [Fin.sum_univ_two] [GOAL] case refine'_5 E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a b : ℝ × ℝ hle : a ≤ b s : Set (ℝ × ℝ) hs : Set.Countable s Hcf : ContinuousOn f (Set.Icc a b) Hcg : ContinuousOn g (Set.Icc a b) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc a b) e : (ℝ × ℝ) ≃L[ℝ] Fin 2 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ) x : ℝ × ℝ ⊢ ↑(f' x) (1, 0) + ↑(g' x) (0, 1) = ↑(Matrix.vecCons f' ![g'] 0 x) (↑(ContinuousLinearEquiv.symm e) (Pi.single 0 1)) + ↑(Matrix.vecCons f' ![g'] 1 x) (↑(ContinuousLinearEquiv.symm e) (Pi.single 1 1)) [PROOFSTEP] rfl [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a b : ℝ × ℝ hle : a ≤ b s : Set (ℝ × ℝ) hs : Set.Countable s Hcf : ContinuousOn f (Set.Icc a b) Hcg : ContinuousOn g (Set.Icc a b) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc a b) e : (ℝ × ℝ) ≃L[ℝ] Fin 2 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ) ⊢ ∑ i : Fin 2, ((∫ (x : Fin 1 → ℝ) in Set.Icc (↑e a ∘ Fin.succAbove i) (↑e b ∘ Fin.succAbove i), Matrix.vecCons f ![g] i (↑(ContinuousLinearEquiv.symm e) (Fin.insertNth i (↑e b i) x))) - ∫ (x : Fin 1 → ℝ) in Set.Icc (↑e a ∘ Fin.succAbove i) (↑e b ∘ Fin.succAbove i), Matrix.vecCons f ![g] i (↑(ContinuousLinearEquiv.symm e) (Fin.insertNth i (↑e a i) x))) = ((∫ (y : ℝ) in Set.Icc a.snd b.snd, f (b.fst, y)) - ∫ (y : ℝ) in Set.Icc a.snd b.snd, f (a.fst, y)) + ((∫ (x : ℝ) in Set.Icc a.fst b.fst, g (x, b.snd)) - ∫ (x : ℝ) in Set.Icc a.fst b.fst, g (x, a.snd)) [PROOFSTEP] have : ∀ (a b : ℝ¹) (f : ℝ¹ → E), ∫ x in Icc a b, f x = ∫ x in Icc (a 0) (b 0), f fun _ => x := fun a b f ↦ by convert (((volume_preserving_funUnique (Fin 1) ℝ).symm _).set_integral_preimage_emb (MeasurableEquiv.measurableEmbedding _) f _).symm exact ((OrderIso.funUnique (Fin 1) ℝ).symm.preimage_Icc a b).symm [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f✝ g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a✝ b✝ : ℝ × ℝ hle : a✝ ≤ b✝ s : Set (ℝ × ℝ) hs : Set.Countable s Hcf : ContinuousOn f✝ (Set.Icc a✝ b✝) Hcg : ContinuousOn g (Set.Icc a✝ b✝) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a✝.fst b✝.fst ×ˢ Set.Ioo a✝.snd b✝.snd \ s → HasFDerivAt f✝ (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a✝.fst b✝.fst ×ˢ Set.Ioo a✝.snd b✝.snd \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc a✝ b✝) e : (ℝ × ℝ) ≃L[ℝ] Fin 2 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ) a b : Fin 1 → ℝ f : (Fin 1 → ℝ) → E ⊢ ∫ (x : Fin 1 → ℝ) in Set.Icc a b, f x = ∫ (x : ℝ) in Set.Icc (a 0) (b 0), f fun x_1 => x [PROOFSTEP] convert (((volume_preserving_funUnique (Fin 1) ℝ).symm _).set_integral_preimage_emb (MeasurableEquiv.measurableEmbedding _) f _).symm [GOAL] case h.e'_3.h.e'_6.h.e'_4 E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f✝ g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a✝ b✝ : ℝ × ℝ hle : a✝ ≤ b✝ s : Set (ℝ × ℝ) hs : Set.Countable s Hcf : ContinuousOn f✝ (Set.Icc a✝ b✝) Hcg : ContinuousOn g (Set.Icc a✝ b✝) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a✝.fst b✝.fst ×ˢ Set.Ioo a✝.snd b✝.snd \ s → HasFDerivAt f✝ (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a✝.fst b✝.fst ×ˢ Set.Ioo a✝.snd b✝.snd \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc a✝ b✝) e : (ℝ × ℝ) ≃L[ℝ] Fin 2 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ) a b : Fin 1 → ℝ f : (Fin 1 → ℝ) → E ⊢ Set.Icc (a 0) (b 0) = ↑(MeasurableEquiv.symm (MeasurableEquiv.funUnique (Fin 1) ℝ)) ⁻¹' Set.Icc a b [PROOFSTEP] exact ((OrderIso.funUnique (Fin 1) ℝ).symm.preimage_Icc a b).symm [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a b : ℝ × ℝ hle : a ≤ b s : Set (ℝ × ℝ) hs : Set.Countable s Hcf : ContinuousOn f (Set.Icc a b) Hcg : ContinuousOn g (Set.Icc a b) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc a b) e : (ℝ × ℝ) ≃L[ℝ] Fin 2 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ) this : ∀ (a b : Fin 1 → ℝ) (f : (Fin 1 → ℝ) → E), ∫ (x : Fin 1 → ℝ) in Set.Icc a b, f x = ∫ (x : ℝ) in Set.Icc (a 0) (b 0), f fun x_1 => x ⊢ ∑ i : Fin 2, ((∫ (x : Fin 1 → ℝ) in Set.Icc (↑e a ∘ Fin.succAbove i) (↑e b ∘ Fin.succAbove i), Matrix.vecCons f ![g] i (↑(ContinuousLinearEquiv.symm e) (Fin.insertNth i (↑e b i) x))) - ∫ (x : Fin 1 → ℝ) in Set.Icc (↑e a ∘ Fin.succAbove i) (↑e b ∘ Fin.succAbove i), Matrix.vecCons f ![g] i (↑(ContinuousLinearEquiv.symm e) (Fin.insertNth i (↑e a i) x))) = ((∫ (y : ℝ) in Set.Icc a.snd b.snd, f (b.fst, y)) - ∫ (y : ℝ) in Set.Icc a.snd b.snd, f (a.fst, y)) + ((∫ (x : ℝ) in Set.Icc a.fst b.fst, g (x, b.snd)) - ∫ (x : ℝ) in Set.Icc a.fst b.fst, g (x, a.snd)) [PROOFSTEP] simp only [Fin.sum_univ_two, this] [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a b : ℝ × ℝ hle : a ≤ b s : Set (ℝ × ℝ) hs : Set.Countable s Hcf : ContinuousOn f (Set.Icc a b) Hcg : ContinuousOn g (Set.Icc a b) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc a b) e : (ℝ × ℝ) ≃L[ℝ] Fin 2 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ) this : ∀ (a b : Fin 1 → ℝ) (f : (Fin 1 → ℝ) → E), ∫ (x : Fin 1 → ℝ) in Set.Icc a b, f x = ∫ (x : ℝ) in Set.Icc (a 0) (b 0), f fun x_1 => x ⊢ ((∫ (x : ℝ) in Set.Icc ((↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ)) a ∘ Fin.succAbove 0) 0) ((↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ)) b ∘ Fin.succAbove 0) 0), Matrix.vecCons f ![g] 0 (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ))) (Fin.insertNth 0 (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ)) b 0) fun x_1 => x))) - ∫ (x : ℝ) in Set.Icc ((↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ)) a ∘ Fin.succAbove 0) 0) ((↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ)) b ∘ Fin.succAbove 0) 0), Matrix.vecCons f ![g] 0 (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ))) (Fin.insertNth 0 (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ)) a 0) fun x_1 => x))) + ((∫ (x : ℝ) in Set.Icc ((↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ)) a ∘ Fin.succAbove 1) 0) ((↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ)) b ∘ Fin.succAbove 1) 0), Matrix.vecCons f ![g] 1 (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ))) (Fin.insertNth 1 (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ)) b 1) fun x_1 => x))) - ∫ (x : ℝ) in Set.Icc ((↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ)) a ∘ Fin.succAbove 1) 0) ((↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ)) b ∘ Fin.succAbove 1) 0), Matrix.vecCons f ![g] 1 (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ))) (Fin.insertNth 1 (↑(ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ)) a 1) fun x_1 => x))) = ((∫ (y : ℝ) in Set.Icc a.snd b.snd, f (b.fst, y)) - ∫ (y : ℝ) in Set.Icc a.snd b.snd, f (a.fst, y)) + ((∫ (x : ℝ) in Set.Icc a.fst b.fst, g (x, b.snd)) - ∫ (x : ℝ) in Set.Icc a.fst b.fst, g (x, a.snd)) [PROOFSTEP] rfl [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a b : ℝ × ℝ hle : a ≤ b s : Set (ℝ × ℝ) hs : Set.Countable s Hcf : ContinuousOn f (Set.Icc a b) Hcg : ContinuousOn g (Set.Icc a b) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc a b) e : (ℝ × ℝ) ≃L[ℝ] Fin 2 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ) ⊢ ((∫ (y : ℝ) in Set.Icc a.snd b.snd, f (b.fst, y)) - ∫ (y : ℝ) in Set.Icc a.snd b.snd, f (a.fst, y)) + ((∫ (x : ℝ) in Set.Icc a.fst b.fst, g (x, b.snd)) - ∫ (x : ℝ) in Set.Icc a.fst b.fst, g (x, a.snd)) = (((∫ (x : ℝ) in a.fst..b.fst, g (x, b.snd)) - ∫ (x : ℝ) in a.fst..b.fst, g (x, a.snd)) + ∫ (y : ℝ) in a.snd..b.snd, f (b.fst, y)) - ∫ (y : ℝ) in a.snd..b.snd, f (a.fst, y) [PROOFSTEP] simp only [intervalIntegral.integral_of_le hle.1, intervalIntegral.integral_of_le hle.2, set_integral_congr_set_ae (Ioc_ae_eq_Icc (α := ℝ) (μ := volume))] [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a b : ℝ × ℝ hle : a ≤ b s : Set (ℝ × ℝ) hs : Set.Countable s Hcf : ContinuousOn f (Set.Icc a b) Hcg : ContinuousOn g (Set.Icc a b) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc a b) e : (ℝ × ℝ) ≃L[ℝ] Fin 2 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ) ⊢ ((∫ (y : ℝ) in Set.Icc a.snd b.snd, f (b.fst, y)) - ∫ (y : ℝ) in Set.Icc a.snd b.snd, f (a.fst, y)) + ((∫ (x : ℝ) in Set.Icc a.fst b.fst, g (x, b.snd)) - ∫ (x : ℝ) in Set.Icc a.fst b.fst, g (x, a.snd)) = (((∫ (x : ℝ) in Set.Icc a.fst b.fst, g (x, b.snd)) - ∫ (x : ℝ) in Set.Icc a.fst b.fst, g (x, a.snd)) + ∫ (y : ℝ) in Set.Icc a.snd b.snd, f (b.fst, y)) - ∫ (y : ℝ) in Set.Icc a.snd b.snd, f (a.fst, y) [PROOFSTEP] abel [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a b : ℝ × ℝ hle : a ≤ b s : Set (ℝ × ℝ) hs : Set.Countable s Hcf : ContinuousOn f (Set.Icc a b) Hcg : ContinuousOn g (Set.Icc a b) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a.fst b.fst ×ˢ Set.Ioo a.snd b.snd \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc a b) e : (ℝ × ℝ) ≃L[ℝ] Fin 2 → ℝ := ContinuousLinearEquiv.symm (ContinuousLinearEquiv.finTwoArrow ℝ ℝ) ⊢ ((∫ (y : ℝ) in Set.Icc a.snd b.snd, f (b.fst, y)) - ∫ (y : ℝ) in Set.Icc a.snd b.snd, f (a.fst, y)) + ((∫ (x : ℝ) in Set.Icc a.fst b.fst, g (x, b.snd)) - ∫ (x : ℝ) in Set.Icc a.fst b.fst, g (x, a.snd)) = (((∫ (x : ℝ) in Set.Icc a.fst b.fst, g (x, b.snd)) - ∫ (x : ℝ) in Set.Icc a.fst b.fst, g (x, a.snd)) + ∫ (y : ℝ) in Set.Icc a.snd b.snd, f (b.fst, y)) - ∫ (y : ℝ) in Set.Icc a.snd b.snd, f (a.fst, y) [PROOFSTEP] abel [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a₁ a₂ b₁ b₂ : ℝ s : Set (ℝ × ℝ) hs : Set.Countable s Hcf : ContinuousOn f ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hcg : ContinuousOn g ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) ⊢ ∫ (x : ℝ) in a₁..b₁, ∫ (y : ℝ) in a₂..b₂, ↑(f' (x, y)) (1, 0) + ↑(g' (x, y)) (0, 1) = (((∫ (x : ℝ) in a₁..b₁, g (x, b₂)) - ∫ (x : ℝ) in a₁..b₁, g (x, a₂)) + ∫ (y : ℝ) in a₂..b₂, f (b₁, y)) - ∫ (y : ℝ) in a₂..b₂, f (a₁, y) [PROOFSTEP] wlog h₁ : a₁ ≤ b₁ generalizing a₁ b₁ [GOAL] case inr E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a₁ a₂ b₁ b₂ : ℝ s : Set (ℝ × ℝ) hs : Set.Countable s Hcf : ContinuousOn f ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hcg : ContinuousOn g ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) this : ∀ (a₁ b₁ : ℝ), ContinuousOn f ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → ContinuousOn g ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → (∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt f (f' x) x) → (∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt g (g' x) x) → IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → a₁ ≤ b₁ → ∫ (x : ℝ) in a₁..b₁, ∫ (y : ℝ) in a₂..b₂, ↑(f' (x, y)) (1, 0) + ↑(g' (x, y)) (0, 1) = (((∫ (x : ℝ) in a₁..b₁, g (x, b₂)) - ∫ (x : ℝ) in a₁..b₁, g (x, a₂)) + ∫ (y : ℝ) in a₂..b₂, f (b₁, y)) - ∫ (y : ℝ) in a₂..b₂, f (a₁, y) h₁ : ¬a₁ ≤ b₁ ⊢ ∫ (x : ℝ) in a₁..b₁, ∫ (y : ℝ) in a₂..b₂, ↑(f' (x, y)) (1, 0) + ↑(g' (x, y)) (0, 1) = (((∫ (x : ℝ) in a₁..b₁, g (x, b₂)) - ∫ (x : ℝ) in a₁..b₁, g (x, a₂)) + ∫ (y : ℝ) in a₂..b₂, f (b₁, y)) - ∫ (y : ℝ) in a₂..b₂, f (a₁, y) [PROOFSTEP] specialize this b₁ a₁ [GOAL] case inr E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a₁ a₂ b₁ b₂ : ℝ s : Set (ℝ × ℝ) hs : Set.Countable s Hcf : ContinuousOn f ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hcg : ContinuousOn g ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) h₁ : ¬a₁ ≤ b₁ this : ContinuousOn f ([[b₁, a₁]] ×ˢ [[a₂, b₂]]) → ContinuousOn g ([[b₁, a₁]] ×ˢ [[a₂, b₂]]) → (∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min b₁ a₁) (max b₁ a₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt f (f' x) x) → (∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min b₁ a₁) (max b₁ a₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt g (g' x) x) → IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) ([[b₁, a₁]] ×ˢ [[a₂, b₂]]) → b₁ ≤ a₁ → ∫ (x : ℝ) in b₁..a₁, ∫ (y : ℝ) in a₂..b₂, ↑(f' (x, y)) (1, 0) + ↑(g' (x, y)) (0, 1) = (((∫ (x : ℝ) in b₁..a₁, g (x, b₂)) - ∫ (x : ℝ) in b₁..a₁, g (x, a₂)) + ∫ (y : ℝ) in a₂..b₂, f (a₁, y)) - ∫ (y : ℝ) in a₂..b₂, f (b₁, y) ⊢ ∫ (x : ℝ) in a₁..b₁, ∫ (y : ℝ) in a₂..b₂, ↑(f' (x, y)) (1, 0) + ↑(g' (x, y)) (0, 1) = (((∫ (x : ℝ) in a₁..b₁, g (x, b₂)) - ∫ (x : ℝ) in a₁..b₁, g (x, a₂)) + ∫ (y : ℝ) in a₂..b₂, f (b₁, y)) - ∫ (y : ℝ) in a₂..b₂, f (a₁, y) [PROOFSTEP] rw [uIcc_comm b₁ a₁, min_comm b₁ a₁, max_comm b₁ a₁] at this [GOAL] case inr E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a₁ a₂ b₁ b₂ : ℝ s : Set (ℝ × ℝ) hs : Set.Countable s Hcf : ContinuousOn f ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hcg : ContinuousOn g ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) h₁ : ¬a₁ ≤ b₁ this : ContinuousOn f ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → ContinuousOn g ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → (∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt f (f' x) x) → (∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt g (g' x) x) → IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → b₁ ≤ a₁ → ∫ (x : ℝ) in b₁..a₁, ∫ (y : ℝ) in a₂..b₂, ↑(f' (x, y)) (1, 0) + ↑(g' (x, y)) (0, 1) = (((∫ (x : ℝ) in b₁..a₁, g (x, b₂)) - ∫ (x : ℝ) in b₁..a₁, g (x, a₂)) + ∫ (y : ℝ) in a₂..b₂, f (a₁, y)) - ∫ (y : ℝ) in a₂..b₂, f (b₁, y) ⊢ ∫ (x : ℝ) in a₁..b₁, ∫ (y : ℝ) in a₂..b₂, ↑(f' (x, y)) (1, 0) + ↑(g' (x, y)) (0, 1) = (((∫ (x : ℝ) in a₁..b₁, g (x, b₂)) - ∫ (x : ℝ) in a₁..b₁, g (x, a₂)) + ∫ (y : ℝ) in a₂..b₂, f (b₁, y)) - ∫ (y : ℝ) in a₂..b₂, f (a₁, y) [PROOFSTEP] simp only [intervalIntegral.integral_symm b₁ a₁] [GOAL] case inr E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a₁ a₂ b₁ b₂ : ℝ s : Set (ℝ × ℝ) hs : Set.Countable s Hcf : ContinuousOn f ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hcg : ContinuousOn g ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) h₁ : ¬a₁ ≤ b₁ this : ContinuousOn f ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → ContinuousOn g ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → (∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt f (f' x) x) → (∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt g (g' x) x) → IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → b₁ ≤ a₁ → ∫ (x : ℝ) in b₁..a₁, ∫ (y : ℝ) in a₂..b₂, ↑(f' (x, y)) (1, 0) + ↑(g' (x, y)) (0, 1) = (((∫ (x : ℝ) in b₁..a₁, g (x, b₂)) - ∫ (x : ℝ) in b₁..a₁, g (x, a₂)) + ∫ (y : ℝ) in a₂..b₂, f (a₁, y)) - ∫ (y : ℝ) in a₂..b₂, f (b₁, y) ⊢ -∫ (x : ℝ) in b₁..a₁, ∫ (y : ℝ) in a₂..b₂, ↑(f' (x, y)) (1, 0) + ↑(g' (x, y)) (0, 1) = (((-∫ (x : ℝ) in b₁..a₁, g (x, b₂)) - -∫ (x : ℝ) in b₁..a₁, g (x, a₂)) + ∫ (y : ℝ) in a₂..b₂, f (b₁, y)) - ∫ (y : ℝ) in a₂..b₂, f (a₁, y) [PROOFSTEP] refine' (congr_arg Neg.neg (this Hcf Hcg Hdf Hdg Hi (le_of_not_le h₁))).trans _ [GOAL] case inr E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a₁ a₂ b₁ b₂ : ℝ s : Set (ℝ × ℝ) hs : Set.Countable s Hcf : ContinuousOn f ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hcg : ContinuousOn g ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) h₁ : ¬a₁ ≤ b₁ this : ContinuousOn f ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → ContinuousOn g ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → (∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt f (f' x) x) → (∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt g (g' x) x) → IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → b₁ ≤ a₁ → ∫ (x : ℝ) in b₁..a₁, ∫ (y : ℝ) in a₂..b₂, ↑(f' (x, y)) (1, 0) + ↑(g' (x, y)) (0, 1) = (((∫ (x : ℝ) in b₁..a₁, g (x, b₂)) - ∫ (x : ℝ) in b₁..a₁, g (x, a₂)) + ∫ (y : ℝ) in a₂..b₂, f (a₁, y)) - ∫ (y : ℝ) in a₂..b₂, f (b₁, y) ⊢ -((((∫ (x : ℝ) in b₁..a₁, g (x, b₂)) - ∫ (x : ℝ) in b₁..a₁, g (x, a₂)) + ∫ (y : ℝ) in a₂..b₂, f (a₁, y)) - ∫ (y : ℝ) in a₂..b₂, f (b₁, y)) = (((-∫ (x : ℝ) in b₁..a₁, g (x, b₂)) - -∫ (x : ℝ) in b₁..a₁, g (x, a₂)) + ∫ (y : ℝ) in a₂..b₂, f (b₁, y)) - ∫ (y : ℝ) in a₂..b₂, f (a₁, y) [PROOFSTEP] abel [GOAL] case inr E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a₁ a₂ b₁ b₂ : ℝ s : Set (ℝ × ℝ) hs : Set.Countable s Hcf : ContinuousOn f ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hcg : ContinuousOn g ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) h₁ : ¬a₁ ≤ b₁ this : ContinuousOn f ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → ContinuousOn g ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → (∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt f (f' x) x) → (∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt g (g' x) x) → IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → b₁ ≤ a₁ → ∫ (x : ℝ) in b₁..a₁, ∫ (y : ℝ) in a₂..b₂, ↑(f' (x, y)) (1, 0) + ↑(g' (x, y)) (0, 1) = (((∫ (x : ℝ) in b₁..a₁, g (x, b₂)) - ∫ (x : ℝ) in b₁..a₁, g (x, a₂)) + ∫ (y : ℝ) in a₂..b₂, f (a₁, y)) - ∫ (y : ℝ) in a₂..b₂, f (b₁, y) ⊢ -((((∫ (x : ℝ) in b₁..a₁, g (x, b₂)) - ∫ (x : ℝ) in b₁..a₁, g (x, a₂)) + ∫ (y : ℝ) in a₂..b₂, f (a₁, y)) - ∫ (y : ℝ) in a₂..b₂, f (b₁, y)) = (((-∫ (x : ℝ) in b₁..a₁, g (x, b₂)) - -∫ (x : ℝ) in b₁..a₁, g (x, a₂)) + ∫ (y : ℝ) in a₂..b₂, f (b₁, y)) - ∫ (y : ℝ) in a₂..b₂, f (a₁, y) [PROOFSTEP] abel [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a₂ b₂ : ℝ s : Set (ℝ × ℝ) hs : Set.Countable s a₁ b₁ : ℝ Hcf : ContinuousOn f ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hcg : ContinuousOn g ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) h₁ : a₁ ≤ b₁ ⊢ ∫ (x : ℝ) in a₁..b₁, ∫ (y : ℝ) in a₂..b₂, ↑(f' (x, y)) (1, 0) + ↑(g' (x, y)) (0, 1) = (((∫ (x : ℝ) in a₁..b₁, g (x, b₂)) - ∫ (x : ℝ) in a₁..b₁, g (x, a₂)) + ∫ (y : ℝ) in a₂..b₂, f (b₁, y)) - ∫ (y : ℝ) in a₂..b₂, f (a₁, y) [PROOFSTEP] wlog h₂ : a₂ ≤ b₂ generalizing a₂ b₂ [GOAL] case inr E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a₂ b₂ : ℝ s : Set (ℝ × ℝ) hs : Set.Countable s a₁ b₁ : ℝ Hcf : ContinuousOn f ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hcg : ContinuousOn g ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) h₁ : a₁ ≤ b₁ this : ∀ (a₂ b₂ : ℝ), ContinuousOn f ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → ContinuousOn g ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → (∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt f (f' x) x) → (∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt g (g' x) x) → IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → a₂ ≤ b₂ → ∫ (x : ℝ) in a₁..b₁, ∫ (y : ℝ) in a₂..b₂, ↑(f' (x, y)) (1, 0) + ↑(g' (x, y)) (0, 1) = (((∫ (x : ℝ) in a₁..b₁, g (x, b₂)) - ∫ (x : ℝ) in a₁..b₁, g (x, a₂)) + ∫ (y : ℝ) in a₂..b₂, f (b₁, y)) - ∫ (y : ℝ) in a₂..b₂, f (a₁, y) h₂ : ¬a₂ ≤ b₂ ⊢ ∫ (x : ℝ) in a₁..b₁, ∫ (y : ℝ) in a₂..b₂, ↑(f' (x, y)) (1, 0) + ↑(g' (x, y)) (0, 1) = (((∫ (x : ℝ) in a₁..b₁, g (x, b₂)) - ∫ (x : ℝ) in a₁..b₁, g (x, a₂)) + ∫ (y : ℝ) in a₂..b₂, f (b₁, y)) - ∫ (y : ℝ) in a₂..b₂, f (a₁, y) [PROOFSTEP] specialize this b₂ a₂ [GOAL] case inr E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a₂ b₂ : ℝ s : Set (ℝ × ℝ) hs : Set.Countable s a₁ b₁ : ℝ Hcf : ContinuousOn f ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hcg : ContinuousOn g ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) h₁ : a₁ ≤ b₁ h₂ : ¬a₂ ≤ b₂ this : ContinuousOn f ([[a₁, b₁]] ×ˢ [[b₂, a₂]]) → ContinuousOn g ([[a₁, b₁]] ×ˢ [[b₂, a₂]]) → (∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min b₂ a₂) (max b₂ a₂) \ s → HasFDerivAt f (f' x) x) → (∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min b₂ a₂) (max b₂ a₂) \ s → HasFDerivAt g (g' x) x) → IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) ([[a₁, b₁]] ×ˢ [[b₂, a₂]]) → b₂ ≤ a₂ → ∫ (x : ℝ) in a₁..b₁, ∫ (y : ℝ) in b₂..a₂, ↑(f' (x, y)) (1, 0) + ↑(g' (x, y)) (0, 1) = (((∫ (x : ℝ) in a₁..b₁, g (x, a₂)) - ∫ (x : ℝ) in a₁..b₁, g (x, b₂)) + ∫ (y : ℝ) in b₂..a₂, f (b₁, y)) - ∫ (y : ℝ) in b₂..a₂, f (a₁, y) ⊢ ∫ (x : ℝ) in a₁..b₁, ∫ (y : ℝ) in a₂..b₂, ↑(f' (x, y)) (1, 0) + ↑(g' (x, y)) (0, 1) = (((∫ (x : ℝ) in a₁..b₁, g (x, b₂)) - ∫ (x : ℝ) in a₁..b₁, g (x, a₂)) + ∫ (y : ℝ) in a₂..b₂, f (b₁, y)) - ∫ (y : ℝ) in a₂..b₂, f (a₁, y) [PROOFSTEP] rw [uIcc_comm b₂ a₂, min_comm b₂ a₂, max_comm b₂ a₂] at this [GOAL] case inr E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a₂ b₂ : ℝ s : Set (ℝ × ℝ) hs : Set.Countable s a₁ b₁ : ℝ Hcf : ContinuousOn f ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hcg : ContinuousOn g ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) h₁ : a₁ ≤ b₁ h₂ : ¬a₂ ≤ b₂ this : ContinuousOn f ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → ContinuousOn g ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → (∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt f (f' x) x) → (∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt g (g' x) x) → IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → b₂ ≤ a₂ → ∫ (x : ℝ) in a₁..b₁, ∫ (y : ℝ) in b₂..a₂, ↑(f' (x, y)) (1, 0) + ↑(g' (x, y)) (0, 1) = (((∫ (x : ℝ) in a₁..b₁, g (x, a₂)) - ∫ (x : ℝ) in a₁..b₁, g (x, b₂)) + ∫ (y : ℝ) in b₂..a₂, f (b₁, y)) - ∫ (y : ℝ) in b₂..a₂, f (a₁, y) ⊢ ∫ (x : ℝ) in a₁..b₁, ∫ (y : ℝ) in a₂..b₂, ↑(f' (x, y)) (1, 0) + ↑(g' (x, y)) (0, 1) = (((∫ (x : ℝ) in a₁..b₁, g (x, b₂)) - ∫ (x : ℝ) in a₁..b₁, g (x, a₂)) + ∫ (y : ℝ) in a₂..b₂, f (b₁, y)) - ∫ (y : ℝ) in a₂..b₂, f (a₁, y) [PROOFSTEP] simp only [intervalIntegral.integral_symm b₂ a₂, intervalIntegral.integral_neg] [GOAL] case inr E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a₂ b₂ : ℝ s : Set (ℝ × ℝ) hs : Set.Countable s a₁ b₁ : ℝ Hcf : ContinuousOn f ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hcg : ContinuousOn g ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) h₁ : a₁ ≤ b₁ h₂ : ¬a₂ ≤ b₂ this : ContinuousOn f ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → ContinuousOn g ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → (∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt f (f' x) x) → (∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt g (g' x) x) → IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → b₂ ≤ a₂ → ∫ (x : ℝ) in a₁..b₁, ∫ (y : ℝ) in b₂..a₂, ↑(f' (x, y)) (1, 0) + ↑(g' (x, y)) (0, 1) = (((∫ (x : ℝ) in a₁..b₁, g (x, a₂)) - ∫ (x : ℝ) in a₁..b₁, g (x, b₂)) + ∫ (y : ℝ) in b₂..a₂, f (b₁, y)) - ∫ (y : ℝ) in b₂..a₂, f (a₁, y) ⊢ -∫ (x : ℝ) in a₁..b₁, ∫ (x_1 : ℝ) in b₂..a₂, ↑(f' (x, x_1)) (1, 0) + ↑(g' (x, x_1)) (0, 1) = (((∫ (x : ℝ) in a₁..b₁, g (x, b₂)) - ∫ (x : ℝ) in a₁..b₁, g (x, a₂)) + -∫ (y : ℝ) in b₂..a₂, f (b₁, y)) - -∫ (y : ℝ) in b₂..a₂, f (a₁, y) [PROOFSTEP] refine' (congr_arg Neg.neg (this Hcf Hcg Hdf Hdg Hi (le_of_not_le h₂))).trans _ [GOAL] case inr E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a₂ b₂ : ℝ s : Set (ℝ × ℝ) hs : Set.Countable s a₁ b₁ : ℝ Hcf : ContinuousOn f ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hcg : ContinuousOn g ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) h₁ : a₁ ≤ b₁ h₂ : ¬a₂ ≤ b₂ this : ContinuousOn f ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → ContinuousOn g ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → (∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt f (f' x) x) → (∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt g (g' x) x) → IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → b₂ ≤ a₂ → ∫ (x : ℝ) in a₁..b₁, ∫ (y : ℝ) in b₂..a₂, ↑(f' (x, y)) (1, 0) + ↑(g' (x, y)) (0, 1) = (((∫ (x : ℝ) in a₁..b₁, g (x, a₂)) - ∫ (x : ℝ) in a₁..b₁, g (x, b₂)) + ∫ (y : ℝ) in b₂..a₂, f (b₁, y)) - ∫ (y : ℝ) in b₂..a₂, f (a₁, y) ⊢ -((((∫ (x : ℝ) in a₁..b₁, g (x, a₂)) - ∫ (x : ℝ) in a₁..b₁, g (x, b₂)) + ∫ (y : ℝ) in b₂..a₂, f (b₁, y)) - ∫ (y : ℝ) in b₂..a₂, f (a₁, y)) = (((∫ (x : ℝ) in a₁..b₁, g (x, b₂)) - ∫ (x : ℝ) in a₁..b₁, g (x, a₂)) + -∫ (y : ℝ) in b₂..a₂, f (b₁, y)) - -∫ (y : ℝ) in b₂..a₂, f (a₁, y) [PROOFSTEP] abel [GOAL] case inr E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E a₂ b₂ : ℝ s : Set (ℝ × ℝ) hs : Set.Countable s a₁ b₁ : ℝ Hcf : ContinuousOn f ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hcg : ContinuousOn g ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) h₁ : a₁ ≤ b₁ h₂ : ¬a₂ ≤ b₂ this : ContinuousOn f ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → ContinuousOn g ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → (∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt f (f' x) x) → (∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt g (g' x) x) → IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) → b₂ ≤ a₂ → ∫ (x : ℝ) in a₁..b₁, ∫ (y : ℝ) in b₂..a₂, ↑(f' (x, y)) (1, 0) + ↑(g' (x, y)) (0, 1) = (((∫ (x : ℝ) in a₁..b₁, g (x, a₂)) - ∫ (x : ℝ) in a₁..b₁, g (x, b₂)) + ∫ (y : ℝ) in b₂..a₂, f (b₁, y)) - ∫ (y : ℝ) in b₂..a₂, f (a₁, y) ⊢ -((((∫ (x : ℝ) in a₁..b₁, g (x, a₂)) - ∫ (x : ℝ) in a₁..b₁, g (x, b₂)) + ∫ (y : ℝ) in b₂..a₂, f (b₁, y)) - ∫ (y : ℝ) in b₂..a₂, f (a₁, y)) = (((∫ (x : ℝ) in a₁..b₁, g (x, b₂)) - ∫ (x : ℝ) in a₁..b₁, g (x, a₂)) + -∫ (y : ℝ) in b₂..a₂, f (b₁, y)) - -∫ (y : ℝ) in b₂..a₂, f (a₁, y) [PROOFSTEP] abel [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E s : Set (ℝ × ℝ) hs : Set.Countable s a₁ b₁ : ℝ h₁ : a₁ ≤ b₁ a₂ b₂ : ℝ Hcf : ContinuousOn f ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hcg : ContinuousOn g ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (min a₁ b₁) (max a₁ b₁) ×ˢ Set.Ioo (min a₂ b₂) (max a₂ b₂) \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) ([[a₁, b₁]] ×ˢ [[a₂, b₂]]) h₂ : a₂ ≤ b₂ ⊢ ∫ (x : ℝ) in a₁..b₁, ∫ (y : ℝ) in a₂..b₂, ↑(f' (x, y)) (1, 0) + ↑(g' (x, y)) (0, 1) = (((∫ (x : ℝ) in a₁..b₁, g (x, b₂)) - ∫ (x : ℝ) in a₁..b₁, g (x, a₂)) + ∫ (y : ℝ) in a₂..b₂, f (b₁, y)) - ∫ (y : ℝ) in a₂..b₂, f (a₁, y) [PROOFSTEP] simp only [uIcc_of_le h₁, uIcc_of_le h₂, min_eq_left, max_eq_right, h₁, h₂] at Hcf Hcg Hdf Hdg Hi [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E s : Set (ℝ × ℝ) hs : Set.Countable s a₁ b₁ : ℝ h₁ : a₁ ≤ b₁ a₂ b₂ : ℝ h₂ : a₂ ≤ b₂ Hcf : ContinuousOn f (Set.Icc a₁ b₁ ×ˢ Set.Icc a₂ b₂) Hcg : ContinuousOn g (Set.Icc a₁ b₁ ×ˢ Set.Icc a₂ b₂) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a₁ b₁ ×ˢ Set.Ioo a₂ b₂ \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a₁ b₁ ×ˢ Set.Ioo a₂ b₂ \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc a₁ b₁ ×ˢ Set.Icc a₂ b₂) ⊢ ∫ (x : ℝ) in a₁..b₁, ∫ (y : ℝ) in a₂..b₂, ↑(f' (x, y)) (1, 0) + ↑(g' (x, y)) (0, 1) = (((∫ (x : ℝ) in a₁..b₁, g (x, b₂)) - ∫ (x : ℝ) in a₁..b₁, g (x, a₂)) + ∫ (y : ℝ) in a₂..b₂, f (b₁, y)) - ∫ (y : ℝ) in a₂..b₂, f (a₁, y) [PROOFSTEP] calc (∫ x in a₁..b₁, ∫ y in a₂..b₂, f' (x, y) (1, 0) + g' (x, y) (0, 1)) = ∫ x in Icc a₁ b₁, ∫ y in Icc a₂ b₂, f' (x, y) (1, 0) + g' (x, y) (0, 1) := by simp only [intervalIntegral.integral_of_le, h₁, h₂, set_integral_congr_set_ae (Ioc_ae_eq_Icc (α := ℝ) (μ := volume))] _ = ∫ x in Icc a₁ b₁ ×ˢ Icc a₂ b₂, f' x (1, 0) + g' x (0, 1) := (set_integral_prod _ Hi).symm _ = (((∫ x in a₁..b₁, g (x, b₂)) - ∫ x in a₁..b₁, g (x, a₂)) + ∫ y in a₂..b₂, f (b₁, y)) - ∫ y in a₂..b₂, f (a₁, y) := by rw [Icc_prod_Icc] at * apply integral_divergence_prod_Icc_of_hasFDerivWithinAt_off_countable_of_le f g f' g' (a₁, a₂) (b₁, b₂) ⟨h₁, h₂⟩ s <;> assumption [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E s : Set (ℝ × ℝ) hs : Set.Countable s a₁ b₁ : ℝ h₁ : a₁ ≤ b₁ a₂ b₂ : ℝ h₂ : a₂ ≤ b₂ Hcf : ContinuousOn f (Set.Icc a₁ b₁ ×ˢ Set.Icc a₂ b₂) Hcg : ContinuousOn g (Set.Icc a₁ b₁ ×ˢ Set.Icc a₂ b₂) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a₁ b₁ ×ˢ Set.Ioo a₂ b₂ \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a₁ b₁ ×ˢ Set.Ioo a₂ b₂ \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc a₁ b₁ ×ˢ Set.Icc a₂ b₂) ⊢ ∫ (x : ℝ) in a₁..b₁, ∫ (y : ℝ) in a₂..b₂, ↑(f' (x, y)) (1, 0) + ↑(g' (x, y)) (0, 1) = ∫ (x : ℝ) in Set.Icc a₁ b₁, ∫ (y : ℝ) in Set.Icc a₂ b₂, ↑(f' (x, y)) (1, 0) + ↑(g' (x, y)) (0, 1) [PROOFSTEP] simp only [intervalIntegral.integral_of_le, h₁, h₂, set_integral_congr_set_ae (Ioc_ae_eq_Icc (α := ℝ) (μ := volume))] [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E s : Set (ℝ × ℝ) hs : Set.Countable s a₁ b₁ : ℝ h₁ : a₁ ≤ b₁ a₂ b₂ : ℝ h₂ : a₂ ≤ b₂ Hcf : ContinuousOn f (Set.Icc a₁ b₁ ×ˢ Set.Icc a₂ b₂) Hcg : ContinuousOn g (Set.Icc a₁ b₁ ×ˢ Set.Icc a₂ b₂) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a₁ b₁ ×ˢ Set.Ioo a₂ b₂ \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a₁ b₁ ×ˢ Set.Ioo a₂ b₂ \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc a₁ b₁ ×ˢ Set.Icc a₂ b₂) ⊢ ∫ (x : ℝ × ℝ) in Set.Icc a₁ b₁ ×ˢ Set.Icc a₂ b₂, ↑(f' x) (1, 0) + ↑(g' x) (0, 1) = (((∫ (x : ℝ) in a₁..b₁, g (x, b₂)) - ∫ (x : ℝ) in a₁..b₁, g (x, a₂)) + ∫ (y : ℝ) in a₂..b₂, f (b₁, y)) - ∫ (y : ℝ) in a₂..b₂, f (a₁, y) [PROOFSTEP] rw [Icc_prod_Icc] at * [GOAL] E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E s : Set (ℝ × ℝ) hs : Set.Countable s a₁ b₁ : ℝ h₁ : a₁ ≤ b₁ a₂ b₂ : ℝ h₂ : a₂ ≤ b₂ Hcf : ContinuousOn f (Set.Icc (a₁, a₂) (b₁, b₂)) Hcg : ContinuousOn g (Set.Icc (a₁, a₂) (b₁, b₂)) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a₁ b₁ ×ˢ Set.Ioo a₂ b₂ \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a₁ b₁ ×ˢ Set.Ioo a₂ b₂ \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc (a₁, a₂) (b₁, b₂)) ⊢ ∫ (x : ℝ × ℝ) in Set.Icc (a₁, a₂) (b₁, b₂), ↑(f' x) (1, 0) + ↑(g' x) (0, 1) = (((∫ (x : ℝ) in a₁..b₁, g (x, b₂)) - ∫ (x : ℝ) in a₁..b₁, g (x, a₂)) + ∫ (y : ℝ) in a₂..b₂, f (b₁, y)) - ∫ (y : ℝ) in a₂..b₂, f (a₁, y) [PROOFSTEP] apply integral_divergence_prod_Icc_of_hasFDerivWithinAt_off_countable_of_le f g f' g' (a₁, a₂) (b₁, b₂) ⟨h₁, h₂⟩ s [GOAL] case hs E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E s : Set (ℝ × ℝ) hs : Set.Countable s a₁ b₁ : ℝ h₁ : a₁ ≤ b₁ a₂ b₂ : ℝ h₂ : a₂ ≤ b₂ Hcf : ContinuousOn f (Set.Icc (a₁, a₂) (b₁, b₂)) Hcg : ContinuousOn g (Set.Icc (a₁, a₂) (b₁, b₂)) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a₁ b₁ ×ˢ Set.Ioo a₂ b₂ \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a₁ b₁ ×ˢ Set.Ioo a₂ b₂ \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc (a₁, a₂) (b₁, b₂)) ⊢ Set.Countable s [PROOFSTEP] assumption [GOAL] case Hcf E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E s : Set (ℝ × ℝ) hs : Set.Countable s a₁ b₁ : ℝ h₁ : a₁ ≤ b₁ a₂ b₂ : ℝ h₂ : a₂ ≤ b₂ Hcf : ContinuousOn f (Set.Icc (a₁, a₂) (b₁, b₂)) Hcg : ContinuousOn g (Set.Icc (a₁, a₂) (b₁, b₂)) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a₁ b₁ ×ˢ Set.Ioo a₂ b₂ \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a₁ b₁ ×ˢ Set.Ioo a₂ b₂ \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc (a₁, a₂) (b₁, b₂)) ⊢ ContinuousOn f (Set.Icc (a₁, a₂) (b₁, b₂)) [PROOFSTEP] assumption [GOAL] case Hcg E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E s : Set (ℝ × ℝ) hs : Set.Countable s a₁ b₁ : ℝ h₁ : a₁ ≤ b₁ a₂ b₂ : ℝ h₂ : a₂ ≤ b₂ Hcf : ContinuousOn f (Set.Icc (a₁, a₂) (b₁, b₂)) Hcg : ContinuousOn g (Set.Icc (a₁, a₂) (b₁, b₂)) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a₁ b₁ ×ˢ Set.Ioo a₂ b₂ \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a₁ b₁ ×ˢ Set.Ioo a₂ b₂ \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc (a₁, a₂) (b₁, b₂)) ⊢ ContinuousOn g (Set.Icc (a₁, a₂) (b₁, b₂)) [PROOFSTEP] assumption [GOAL] case Hdf E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E s : Set (ℝ × ℝ) hs : Set.Countable s a₁ b₁ : ℝ h₁ : a₁ ≤ b₁ a₂ b₂ : ℝ h₂ : a₂ ≤ b₂ Hcf : ContinuousOn f (Set.Icc (a₁, a₂) (b₁, b₂)) Hcg : ContinuousOn g (Set.Icc (a₁, a₂) (b₁, b₂)) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a₁ b₁ ×ˢ Set.Ioo a₂ b₂ \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a₁ b₁ ×ˢ Set.Ioo a₂ b₂ \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc (a₁, a₂) (b₁, b₂)) ⊢ ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (a₁, a₂).fst (b₁, b₂).fst ×ˢ Set.Ioo (a₁, a₂).snd (b₁, b₂).snd \ s → HasFDerivAt f (f' x) x [PROOFSTEP] assumption [GOAL] case Hdg E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E s : Set (ℝ × ℝ) hs : Set.Countable s a₁ b₁ : ℝ h₁ : a₁ ≤ b₁ a₂ b₂ : ℝ h₂ : a₂ ≤ b₂ Hcf : ContinuousOn f (Set.Icc (a₁, a₂) (b₁, b₂)) Hcg : ContinuousOn g (Set.Icc (a₁, a₂) (b₁, b₂)) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a₁ b₁ ×ˢ Set.Ioo a₂ b₂ \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a₁ b₁ ×ˢ Set.Ioo a₂ b₂ \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc (a₁, a₂) (b₁, b₂)) ⊢ ∀ (x : ℝ × ℝ), x ∈ Set.Ioo (a₁, a₂).fst (b₁, b₂).fst ×ˢ Set.Ioo (a₁, a₂).snd (b₁, b₂).snd \ s → HasFDerivAt g (g' x) x [PROOFSTEP] assumption [GOAL] case Hi E : Type u inst✝² : NormedAddCommGroup E inst✝¹ : NormedSpace ℝ E inst✝ : CompleteSpace E f g : ℝ × ℝ → E f' g' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E s : Set (ℝ × ℝ) hs : Set.Countable s a₁ b₁ : ℝ h₁ : a₁ ≤ b₁ a₂ b₂ : ℝ h₂ : a₂ ≤ b₂ Hcf : ContinuousOn f (Set.Icc (a₁, a₂) (b₁, b₂)) Hcg : ContinuousOn g (Set.Icc (a₁, a₂) (b₁, b₂)) Hdf : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a₁ b₁ ×ˢ Set.Ioo a₂ b₂ \ s → HasFDerivAt f (f' x) x Hdg : ∀ (x : ℝ × ℝ), x ∈ Set.Ioo a₁ b₁ ×ˢ Set.Ioo a₂ b₂ \ s → HasFDerivAt g (g' x) x Hi : IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc (a₁, a₂) (b₁, b₂)) ⊢ IntegrableOn (fun x => ↑(f' x) (1, 0) + ↑(g' x) (0, 1)) (Set.Icc (a₁, a₂) (b₁, b₂)) [PROOFSTEP] assumption
library(epimdr) data(ccs) plot(ccs$size, ccs$ext*100, log = "x", xlab = "Community size", ylab = "Percent of time extinct") plot(magono$time, magono$number, ylab = "Cases", xlab = "Year") lines(lowess(x = magono$time, y = magono$number, f=.4)) data(cholera) ses = sesdv = rep(NA, 12) ses[c(7:12, 1:6)] = sapply(split(cholera$Dacca, cholera$Month), mean, na.rm = TRUE) sesdv[c(7:12, 1:6)] = sapply(split(cholera$Dacca, cholera$Month), sd, na.rm = TRUE)/ sqrt(length(split(cholera$Dacca, cholera$Month))) require(plotrix) plotCI(x = 1:12, y = ses, ui = ses+sesdv, li = ses- sesdv, xlab = "Month", ylab = "Deaths") lines(x = 1:12, y = ses)
import simplifier.level_commutator_2 /- Here you might want to use `simp` together with the fact that multiplication is associative (this lemma is called `mul_assoc` as you might have guessed). Recall that you can tell `simp` to use lemma `h` when simplifying by writing `simp[h]`. -/ /- Lemma : -/ lemma commutator_inv {G : Type*} [group G] {x y : G} : [y, x] = [x, y]⁻¹ := begin rw [commutator_def, commutator_def, mul_inv_rev, mul_inv_rev, mul_inv_rev, inv_inv, inv_inv, mul_assoc, mul_assoc], end
In June 2007 , after two weeks of protests , some DePaul students staged a sit @-@ in and hunger strike in support of both professors denied tenure . The Illinois Conference of the American Association of University Professors also sent a letter to the university 's president stating : " It is entirely illegitimate for a university to deny tenure to a professor out of fear that his published research ... might hurt a college 's reputation " and that the association has " explicitly rejected collegiality as an appropriate criterion for evaluating faculty members " . In a 2014 interview , professor Matthew Abraham , author of Out of Bounds : Academic Freedom and the Question of Palestine , described the Finkelstein tenure case as " one of the most significant academic freedom cases in the last fifty years " , claiming the case demonstrated " the substantial pressure outside parties can place on a mid @-@ tier religious institution when the perspectives advanced by a controversial scholar threaten dominant interests " .
module Values where open import Data.Bool open import Data.List open import Data.List.All open import Data.Nat open import Data.Product open import Data.Sum open import Relation.Binary.PropositionalEquality open import Typing open import Syntax open import Global open import Channel mutual -- a value indexed by a *relevant* session context, which is "used up" by the value data Val (G : SCtx) : Type → Set where VUnit : (inaG : Inactive G) → Val G TUnit VInt : (i : ℕ) → (inaG : Inactive G) → Val G TInt VPair : ∀ {t₁ t₂ G₁ G₂} → (ss-GG₁G₂ : SSplit G G₁ G₂) → (v₁ : Val G₁ t₁) → (v₂ : Val G₂ t₂) → Val G (TPair t₁ t₂) VChan : ∀ {s} → (ce : ChannelEnd) → (cr : ChannelRef G ce s) → Val G (TChan s) VFun : ∀ {φ lu t₁ t₂} → (lu ≡ LL ⊎ All Unr φ) → (ϱ : VEnv G φ) → (e : Expr (t₁ ∷ φ) t₂) → Val G (TFun lu t₁ t₂) -- type environment-indexed value environment -- session context G describes the entire environment, it splits over all (channel) values data VEnv (G : SCtx) : TCtx → Set where vnil : (ina : Inactive G) → VEnv G [] vcons : ∀{t φ G₁ G₂} → (ssp : SSplit G G₁ G₂) → (v : Val G₁ t) → (ϱ : VEnv G₂ φ) → VEnv G (t ∷ φ) unrestricted-val : ∀ {t G} → Unr t → Val G t → Inactive G unrestricted-venv : ∀ {φ G} → All Unr φ → VEnv G φ → Inactive G unrestricted-val UUnit (VUnit x) = x unrestricted-val UInt (VInt i x) = x unrestricted-val (UPair unrt unrt₁) (VPair x v v₁) = ssplit-inactive x (unrestricted-val unrt v) (unrestricted-val unrt₁ v₁) unrestricted-val {TFun UU t₁ t₂} UFun (VFun (inj₁ ()) ϱ e) unrestricted-val {TFun UU t₁ t₂} UFun (VFun (inj₂ unr-φ) ϱ e) = unrestricted-venv unr-φ ϱ unrestricted-venv unr-φ (vnil ina) = ina unrestricted-venv (px ∷ unr-φ) (vcons ssp v ϱ) = ssplit-inactive ssp (unrestricted-val px v) (unrestricted-venv unr-φ ϱ) -- access a value in an indexed environment access : ∀ {φ t} {G : SCtx} → VEnv G φ → t ∈ φ → ∃ λ G₁ → ∃ λ G₂ → Inactive G₂ × SSplit G G₁ G₂ × Val G₁ t access (vcons ssp v ϱ) (here allUnr) = _ , _ , unrestricted-venv allUnr ϱ , ssp , v access (vcons ssp x₀ ϱ) (there unrX₀ x) with access ϱ x access (vcons ssp x₀ ϱ) (there unrX₀ x) | G₁ , G₂ , inaG₂ , ssp12 , v with ssplit-compose4 ssp ssp12 ... | Gi , ssp1 , ssp2 = G₁ , Gi , ssplit-inactive ssp2 (unrestricted-val unrX₀ x₀) inaG₂ , ssp1 , v -- coerce a value to a supertype coerce : ∀ {G t t'} → Val G t → SubT t t' → Val G t' coerce (VUnit inaG) sub-unit = VUnit inaG coerce (VInt i inaG) sub-int = VInt i inaG coerce (VPair ss-GG₁G₂ v v₁) (sub-pair t≤t' t≤t'') = VPair ss-GG₁G₂ (coerce v t≤t') (coerce v₁ t≤t'') coerce (VChan b vcr) (sub-chan s≲s') = VChan b (vcr-coerce vcr s≲s') coerce (VFun lu ϱ e) (sub-fun t≤t' t≤t'') = VFun lu ϱ (expr-coerce e t≤t'' t≤t') rewrite-ssplit : ∀ {G G' G₁ G₂} → G ≡ G' → SSplit G G₁ G₂ → SSplit G' G₁ G₂ rewrite-ssplit p ssp rewrite p = ssp rewrite-ssplit1 : ∀ {G G₁ G₁' G₂} → G₁ ≡ G₁' → SSplit G G₁ G₂ → SSplit G G₁' G₂ rewrite-ssplit1 p ssp rewrite p = ssp -- split environment according to type context split split-env : ∀ {Φ Φ₁ Φ₂} {G : SCtx} → Split Φ Φ₁ Φ₂ → VEnv G Φ → Σ (SCtx × SCtx) λ { (G₁ , G₂) → SSplit G G₁ G₂ × VEnv G₁ Φ₁ × VEnv G₂ Φ₂ } split-env{G = G} [] (vnil ina) = (G , G) , inactive-ssplit-trivial ina , vnil ina , vnil ina split-env (dupl unrt sp) (vcons ssp v ϱ) with split-env sp ϱ | unrestricted-val unrt v split-env (dupl unrt sp) (vcons ssp v ϱ) | (G₁' , G₂') , ssp12 , ϱ₁' , ϱ₂' | unr-v rewrite inactive-left-ssplit ssp unr-v with ssplit-compose4 ssp ssp12 | ssplit-compose3 ssp ssp12 ... | Gi , ssp-GG1Gi , ssp-GiG1G2' | Gi-1 , ssp-GGiG2' , ssp-GiG1G1' = let p₁ = (inactive-left-ssplit ssp-GiG1G1' unr-v) in let p₂ = (inactive-left-ssplit ssp-GiG1G2' unr-v) in (G₁' , G₂') , ssp12 , vcons (rewrite-ssplit p₁ ssp-GiG1G1') v ϱ₁' , vcons (rewrite-ssplit p₂ ssp-GiG1G2') v ϱ₂' split-env (drop px sp) (vcons ssp v ϱ) rewrite inactive-left-ssplit ssp (unrestricted-val px v) = split-env sp ϱ split-env (left sp) (vcons ssp v ϱ) with split-env sp ϱ split-env{G = G} (left sp) (vcons ssp v ϱ) | (G₁' , G₂') , ssp12 , ϱ₁' , ϱ₂' with ssplit-compose3 ssp ssp12 ... | Gi , ssp-GiG2' , ssp-GiG1G1' = (Gi , G₂') , ssp-GiG2' , vcons ssp-GiG1G1' v ϱ₁' , ϱ₂' split-env (rght sp) (vcons ssp v ϱ) with split-env sp ϱ split-env (rght sp) (vcons ssp v ϱ) | (G₁' , G₂') , ssp12 , ϱ₁' , ϱ₂' with ssplit-compose4 ssp ssp12 ...| Gi , ssp-GG1'Gi , ssp-GiG1G2' = (G₁' , Gi) , ssp-GG1'Gi , ϱ₁' , vcons ssp-GiG1G2' v ϱ₂'
-- | -- Module : Jeopardy.Graphics -- Description : Rendering functionality for the Jeopardy game -- Copyright : (c) Jonatan H Sundqvist, 2015 -- License : MIT -- Maintainer : Jonatan H Sundqvist -- Stability : experimental|stable -- Portability : POSIX (not sure) -- -- Created July 7 2015 -- TODO | - 'App' type with configurations, event listeners, etc. -- - -- SPEC | - -- - module Jeopardy.Graphics where --------------------------------------------------------------------------------------------------- -- We'll need these --------------------------------------------------------------------------------------------------- import qualified Graphics.Rendering.Cairo as Cairo -- import Control.Monad (when, forM_) -- import Data.Complex import qualified Southpaw.Picasso.Palette as Palette -- import Southpaw.Picasso.RenderUtils -- import Jeopardy.Core -- --------------------------------------------------------------------------------------------------- -- Types --------------------------------------------------------------------------------------------------- type Point = Complex Double --------------------------------------------------------------------------------------------------- -- Data --------------------------------------------------------------------------------------------------- π = pi τ = 2*π --------------------------------------------------------------------------------------------------- -- Functions --------------------------------------------------------------------------------------------------- -- Game specific rendering ------------------------------------------------------------------------ -- | renderGame :: Game -> Cairo.Render () renderGame game = do -- let (dx, padx) = (42, 5) mapM_ (\ (n, cat) -> renderCategory ((50+n*(dx+padx)*2):+50) (dx:+dx) 4 cat) . zip [1..] $ _board game -- | renderAnswerTile :: Point -> Double -> String -> Cairo.Render () renderAnswerTile (cx:+cy) radius answer = do Cairo.arc cx cy radius 0 τ Palette.choose Palette.blue Cairo.fill Cairo.arc cx cy (radius*0.86) 0 τ Palette.choose Palette.cadetblue Cairo.fill Palette.choose Palette.black Cairo.setFontSize 18 renderCentredText (cx:+cy) answer -- | renderCategoryHeading :: Point -> Point -> String -> Cairo.Render () renderCategoryHeading (cx:+cy) (dx:+dy) title = do Cairo.rectangle (cx-dx) (cy-dy) (dx*2) (dy*2) Palette.choose Palette.blue Cairo.fill Cairo.rectangle (cx-(dx*0.86)) (cy-(dy*0.86)) (dx*2*0.86) (dy*2*0.86) Palette.choose Palette.cadetblue Cairo.fill Palette.choose Palette.black Cairo.setFontSize 18 renderCentredText (cx:+cy) title -- | -- TODO: Add layout option parameters renderCategory :: Point -> Point -> Double -> Category -> Cairo.Render () renderCategory (cx:+cy) (dx:+dy) pady (Category { _questions=q, _title=t }) = do renderCategoryHeading (cx:+cy) (dx:+(dy*0.8)) t mapM_ (\ (n, q) -> renderAnswerTile (cx:+(cy+n*(dy+pady)*2)) dx . show $ _value q) . zip [1..] $ q -- General rendering utilities -------------------------------------------------------------------- -- | renderCircle :: Double -> Point -> Cairo.Render () renderCircle radius (cx:+cy) = Cairo.arc cx cy radius 0 τ ---------------------------------------------------------------------------------------------------
import Base: show, ==, push!, append! ## nice-valued ranges for histograms function histrange{T}(v::AbstractArray{T}, n::Integer, closed::Symbol=:right) F = float(T) nv = length(v) if nv == 0 && n < 0 throw(ArgumentError("number of bins must be ≥ 0 for an empty array, got $n")) elseif nv > 0 && n < 1 throw(ArgumentError("number of bins must be ≥ 1 for a non-empty array, got $n")) elseif nv == 0 return zero(F):zero(F) end lo, hi = extrema(v) histrange(F(lo), F(hi), n, closed) end function histrange{F}(lo::F, hi::F, n::Integer, closed::Symbol=:right) if hi == lo start = F(hi) step = one(F) divisor = one(F) len = one(F) else bw = (F(hi) - F(lo)) / n lbw = log10(bw) if lbw >= 0 step = exp10(floor(lbw)) r = bw / step if r <= 1.1 nothing elseif r <= 2.2 step *= 2 elseif r <= 5.5 step *= 5 else step *= 10 end divisor = one(F) start = step*floor(lo/step) len = ceil((hi - start)/step) else divisor = exp10(-floor(lbw)) r = bw * divisor if r <= 1.1 nothing elseif r <= 2.2 divisor /= 2 elseif r <= 5.5 divisor /= 5 else divisor /= 10 end step = one(F) start = floor(lo*divisor) len = ceil(hi*divisor - start) end end # fix up endpoints if closed == :right #(,] while lo <= start/divisor start -= step end while (start + (len-1)*step)/divisor < hi len += one(F) end else while lo < start/divisor start -= step end while (start + (len-1)*step)/divisor <= hi len += one(F) end end FloatRange(start,step,len,divisor) end histrange{N}(vs::NTuple{N,AbstractVector},nbins::NTuple{N,Integer},closed::Symbol) = map((v,n) -> histrange(v,n,closed),vs,nbins) histrange{N}(vs::NTuple{N,AbstractVector},nbins::Integer,closed::Symbol) = map(v -> histrange(v,nbins,closed),vs) ## histograms ## function sturges(n) # Sturges' formula n==0 && return one(n) ceil(Integer, log2(n))+1 end abstract AbstractHistogram{T<:Real,N,E} # N-dimensional histogram object type Histogram{T<:Real,N,E} <: AbstractHistogram{T,N,E} edges::E weights::Array{T,N} closed::Symbol function Histogram(edges::NTuple{N,AbstractArray},weights::Array{T,N},closed::Symbol) closed == :right || closed == :left || error("closed must :left or :right") map(x -> length(x)-1,edges) == size(weights) || error("Histogram edge vectors must be 1 longer than corresponding weight dimensions") new(edges,weights,closed) end end Histogram{T,N}(edges::NTuple{N,AbstractVector},weights::AbstractArray{T,N},closed::Symbol=:right) = Histogram{T,N,typeof(edges)}(edges,weights,closed) Histogram{T,N}(edges::NTuple{N,AbstractVector},::Type{T},closed::Symbol=:right) = Histogram(edges,zeros(T,map(x -> length(x)-1,edges)...),closed) Histogram{N}(edges::NTuple{N,AbstractVector},closed::Symbol=:right) = Histogram(edges,Int,closed) function show(io::IO, h::AbstractHistogram) println(io, typeof(h)) println(io,"edges:") for e in h.edges println(io," ",e) end println(io,"weights: ",h.weights) print(io,"closed: ",h.closed) end (==)(h1::Histogram,h2::Histogram) = (==)(h1.edges,h2.edges) && (==)(h1.weights,h2.weights) && (==)(h1.closed,h2.closed) # 1-dimensional Histogram{T}(edge::AbstractVector, weights::AbstractVector{T}, closed::Symbol=:right) = Histogram((edge,), weights, closed) Histogram{T}(edge::AbstractVector, ::Type{T}, closed::Symbol=:right) = Histogram(edge, zeros(T,length(edge)-1), closed) Histogram(edge::AbstractVector,closed::Symbol=:right) = Histogram(edge, Int, closed) function push!{T,E}(h::Histogram{T,1,E}, x::Real,w::Real) i = if h.closed == :right searchsortedfirst(h.edges[1], x) - 1 else searchsortedlast(h.edges[1], x) end if 1 <= i <= length(h.weights) @inbounds h.weights[i] += w end h end push!{T,E}(h::AbstractHistogram{T,1,E}, x::Real) = push!(h,x,one(T)) function append!{T}(h::AbstractHistogram{T,1}, v::AbstractVector) for x in v push!(h,x) end h end function append!{T}(h::AbstractHistogram{T,1}, v::AbstractVector,wv::WeightVec) for (x,w) in zip(v,wv.values) push!(h,x,w) end h end fit(::Type{Histogram},v::AbstractVector, edg::AbstractVector; closed::Symbol=:right) = append!(Histogram(edg,closed), v) fit(::Type{Histogram},v::AbstractVector; closed::Symbol=:right, nbins=sturges(length(v))) = fit(Histogram, v, histrange(v,nbins,closed); closed=closed) fit{W}(::Type{Histogram},v::AbstractVector, wv::WeightVec{W}, edg::AbstractVector; closed::Symbol=:right) = append!(Histogram(edg,W,closed), v, wv) fit(::Type{Histogram},v::AbstractVector, wv::WeightVec; closed::Symbol=:right, nbins=sturges(length(v))) = fit(Histogram, v, wv, histrange(v,nbins,closed); closed=closed) # N-dimensional function push!{T,N}(h::Histogram{T,N},xs::NTuple{N,Real},w::Real) is = if h.closed == :right map((edge, x) -> searchsortedfirst(edge,x) - 1, h.edges, xs) else map(searchsortedlast, h.edges, xs) end try h.weights[is...] += w catch e isa(e,BoundsError) || rethrow(e) end h end push!{T,N}(h::AbstractHistogram{T,N},xs::NTuple{N,Real}) = push!(h,xs,one(T)) function append!{T,N}(h::AbstractHistogram{T,N}, vs::NTuple{N,AbstractVector}) for xs in zip(vs...) push!(h,xs) end h end function append!{T,N}(h::AbstractHistogram{T,N}, vs::NTuple{N,AbstractVector},wv::WeightVec) for (xs,w) in zip(zip(vs...),wv.values) push!(h,xs,w) end h end fit{N}(::Type{Histogram}, vs::NTuple{N,AbstractVector}, edges::NTuple{N,AbstractVector}; closed::Symbol=:right) = append!(Histogram(edges,closed), vs) fit{N}(::Type{Histogram}, vs::NTuple{N,AbstractVector}; closed::Symbol=:right, nbins=sturges(length(vs[1]))) = fit(Histogram, vs, histrange(vs,nbins,closed); closed=closed) fit{N,W}(::Type{Histogram}, vs::NTuple{N,AbstractVector}, wv::WeightVec{W}, edges::NTuple{N,AbstractVector}; closed::Symbol=:right) = append!(Histogram(edges,W,closed), vs, wv) fit{N}(::Type{Histogram},vs::NTuple{N,AbstractVector}, wv::WeightVec; closed::Symbol=:right, nbins=sturges(length(vs[1]))) = fit(Histogram, vs, wv, histrange(vs,nbins,closed); closed=closed)
export TRMA57_Sham_vs_Nwt_λ function TRMA57_Sham_vs_Nwt_λ(nlp :: AbstractNLPModel, nlpstop :: NLPStopping; corr_ho :: Symbol = :Shamanskii_MA57, nwt_res_fact = 0.25, λfact = 1.0, kwargs... ) return TRARC(nlp, nlpstop; TR = TrustRegion(10.0), c = Combi(hessian_sparse, PDataMA57{eltype(nlp.meta.x0)}, (x, y, z) -> solve_modelTRDiag_HO_vs_Nwt_λ(x, y, z; ho_correction = corr_ho, nwt_res_fact = nwt_res_fact, λfact = λfact), preprocessMA57, decreaseFact, Tparam{eltype(nlp.meta.x0)}()), kwargs... ) end
(* Title: HOL/SMT.thy Author: Sascha Boehme, TU Muenchen Author: Jasmin Blanchette, VU Amsterdam *) section \<open>Bindings to Satisfiability Modulo Theories (SMT) solvers based on SMT-LIB 2\<close> theory SMT imports Divides Numeral_Simprocs keywords "smt_status" :: diag begin subsection \<open>A skolemization tactic and proof method\<close> lemma choices: "\<And>Q. \<forall>x. \<exists>y ya. Q x y ya \<Longrightarrow> \<exists>f fa. \<forall>x. Q x (f x) (fa x)" "\<And>Q. \<forall>x. \<exists>y ya yb. Q x y ya yb \<Longrightarrow> \<exists>f fa fb. \<forall>x. Q x (f x) (fa x) (fb x)" "\<And>Q. \<forall>x. \<exists>y ya yb yc. Q x y ya yb yc \<Longrightarrow> \<exists>f fa fb fc. \<forall>x. Q x (f x) (fa x) (fb x) (fc x)" "\<And>Q. \<forall>x. \<exists>y ya yb yc yd. Q x y ya yb yc yd \<Longrightarrow> \<exists>f fa fb fc fd. \<forall>x. Q x (f x) (fa x) (fb x) (fc x) (fd x)" "\<And>Q. \<forall>x. \<exists>y ya yb yc yd ye. Q x y ya yb yc yd ye \<Longrightarrow> \<exists>f fa fb fc fd fe. \<forall>x. Q x (f x) (fa x) (fb x) (fc x) (fd x) (fe x)" "\<And>Q. \<forall>x. \<exists>y ya yb yc yd ye yf. Q x y ya yb yc yd ye yf \<Longrightarrow> \<exists>f fa fb fc fd fe ff. \<forall>x. Q x (f x) (fa x) (fb x) (fc x) (fd x) (fe x) (ff x)" "\<And>Q. \<forall>x. \<exists>y ya yb yc yd ye yf yg. Q x y ya yb yc yd ye yf yg \<Longrightarrow> \<exists>f fa fb fc fd fe ff fg. \<forall>x. Q x (f x) (fa x) (fb x) (fc x) (fd x) (fe x) (ff x) (fg x)" by metis+ lemma bchoices: "\<And>Q. \<forall>x \<in> S. \<exists>y ya. Q x y ya \<Longrightarrow> \<exists>f fa. \<forall>x \<in> S. Q x (f x) (fa x)" "\<And>Q. \<forall>x \<in> S. \<exists>y ya yb. Q x y ya yb \<Longrightarrow> \<exists>f fa fb. \<forall>x \<in> S. Q x (f x) (fa x) (fb x)" "\<And>Q. \<forall>x \<in> S. \<exists>y ya yb yc. Q x y ya yb yc \<Longrightarrow> \<exists>f fa fb fc. \<forall>x \<in> S. Q x (f x) (fa x) (fb x) (fc x)" "\<And>Q. \<forall>x \<in> S. \<exists>y ya yb yc yd. Q x y ya yb yc yd \<Longrightarrow> \<exists>f fa fb fc fd. \<forall>x \<in> S. Q x (f x) (fa x) (fb x) (fc x) (fd x)" "\<And>Q. \<forall>x \<in> S. \<exists>y ya yb yc yd ye. Q x y ya yb yc yd ye \<Longrightarrow> \<exists>f fa fb fc fd fe. \<forall>x \<in> S. Q x (f x) (fa x) (fb x) (fc x) (fd x) (fe x)" "\<And>Q. \<forall>x \<in> S. \<exists>y ya yb yc yd ye yf. Q x y ya yb yc yd ye yf \<Longrightarrow> \<exists>f fa fb fc fd fe ff. \<forall>x \<in> S. Q x (f x) (fa x) (fb x) (fc x) (fd x) (fe x) (ff x)" "\<And>Q. \<forall>x \<in> S. \<exists>y ya yb yc yd ye yf yg. Q x y ya yb yc yd ye yf yg \<Longrightarrow> \<exists>f fa fb fc fd fe ff fg. \<forall>x \<in> S. Q x (f x) (fa x) (fb x) (fc x) (fd x) (fe x) (ff x) (fg x)" by metis+ ML \<open> fun moura_tac ctxt = Atomize_Elim.atomize_elim_tac ctxt THEN' SELECT_GOAL (Clasimp.auto_tac (ctxt addSIs @{thms choice choices bchoice bchoices}) THEN ALLGOALS (Metis_Tactic.metis_tac (take 1 ATP_Proof_Reconstruct.partial_type_encs) ATP_Proof_Reconstruct.default_metis_lam_trans ctxt [] ORELSE' blast_tac ctxt)) \<close> method_setup moura = \<open> Scan.succeed (SIMPLE_METHOD' o moura_tac) \<close> "solve skolemization goals, especially those arising from Z3 proofs" hide_fact (open) choices bchoices subsection \<open>Triggers for quantifier instantiation\<close> text \<open> Some SMT solvers support patterns as a quantifier instantiation heuristics. Patterns may either be positive terms (tagged by "pat") triggering quantifier instantiations -- when the solver finds a term matching a positive pattern, it instantiates the corresponding quantifier accordingly -- or negative terms (tagged by "nopat") inhibiting quantifier instantiations. A list of patterns of the same kind is called a multipattern, and all patterns in a multipattern are considered conjunctively for quantifier instantiation. A list of multipatterns is called a trigger, and their multipatterns act disjunctively during quantifier instantiation. Each multipattern should mention at least all quantified variables of the preceding quantifier block. \<close> typedecl 'a symb_list consts Symb_Nil :: "'a symb_list" Symb_Cons :: "'a \<Rightarrow> 'a symb_list \<Rightarrow> 'a symb_list" typedecl pattern consts pat :: "'a \<Rightarrow> pattern" nopat :: "'a \<Rightarrow> pattern" definition trigger :: "pattern symb_list symb_list \<Rightarrow> bool \<Rightarrow> bool" where "trigger _ P = P" subsection \<open>Higher-order encoding\<close> text \<open> Application is made explicit for constants occurring with varying numbers of arguments. This is achieved by the introduction of the following constant. \<close> definition fun_app :: "'a \<Rightarrow> 'a" where "fun_app f = f" text \<open> Some solvers support a theory of arrays which can be used to encode higher-order functions. The following set of lemmas specifies the properties of such (extensional) arrays. \<close> lemmas array_rules = ext fun_upd_apply fun_upd_same fun_upd_other fun_upd_upd fun_app_def subsection \<open>Normalization\<close> lemma case_bool_if[abs_def]: "case_bool x y P = (if P then x else y)" by simp lemmas Ex1_def_raw = Ex1_def[abs_def] lemmas Ball_def_raw = Ball_def[abs_def] lemmas Bex_def_raw = Bex_def[abs_def] lemmas abs_if_raw = abs_if[abs_def] lemmas min_def_raw = min_def[abs_def] lemmas max_def_raw = max_def[abs_def] lemma nat_zero_as_int: "0 = nat 0" by simp lemma nat_one_as_int: "1 = nat 1" by simp lemma nat_numeral_as_int: "numeral = (\<lambda>i. nat (numeral i))" by simp lemma nat_less_as_int: "(<) = (\<lambda>a b. int a < int b)" by simp lemma nat_leq_as_int: "(\<le>) = (\<lambda>a b. int a \<le> int b)" by simp lemma Suc_as_int: "Suc = (\<lambda>a. nat (int a + 1))" by (rule ext) simp lemma nat_plus_as_int: "(+) = (\<lambda>a b. nat (int a + int b))" by (rule ext)+ simp lemma nat_minus_as_int: "(-) = (\<lambda>a b. nat (int a - int b))" by (rule ext)+ simp lemma nat_times_as_int: "(*) = (\<lambda>a b. nat (int a * int b))" by (simp add: nat_mult_distrib) lemma nat_div_as_int: "(div) = (\<lambda>a b. nat (int a div int b))" by (simp add: nat_div_distrib) lemma nat_mod_as_int: "(mod) = (\<lambda>a b. nat (int a mod int b))" by (simp add: nat_mod_distrib) lemma int_Suc: "int (Suc n) = int n + 1" by simp lemma int_plus: "int (n + m) = int n + int m" by (rule of_nat_add) lemma int_minus: "int (n - m) = int (nat (int n - int m))" by auto lemma nat_int_comparison: fixes a b :: nat shows "(a = b) = (int a = int b)" and "(a < b) = (int a < int b)" and "(a \<le> b) = (int a \<le> int b)" by simp_all lemma int_ops: fixes a b :: nat shows "int 0 = 0" and "int 1 = 1" and "int (numeral n) = numeral n" and "int (Suc a) = int a + 1" and "int (a + b) = int a + int b" and "int (a - b) = (if int a < int b then 0 else int a - int b)" and "int (a * b) = int a * int b" and "int (a div b) = int a div int b" and "int (a mod b) = int a mod int b" by (auto intro: zdiv_int zmod_int) lemma int_if: fixes a b :: nat shows "int (if P then a else b) = (if P then int a else int b)" by simp subsection \<open>Integer division and modulo for Z3\<close> text \<open> The following Z3-inspired definitions are overspecified for the case where \<open>l = 0\<close>. This Schönheitsfehler is corrected in the \<open>div_as_z3div\<close> and \<open>mod_as_z3mod\<close> theorems. \<close> definition z3div :: "int \<Rightarrow> int \<Rightarrow> int" where "z3div k l = (if l \<ge> 0 then k div l else - (k div - l))" definition z3mod :: "int \<Rightarrow> int \<Rightarrow> int" where "z3mod k l = k mod (if l \<ge> 0 then l else - l)" lemma div_as_z3div: "\<forall>k l. k div l = (if l = 0 then 0 else if l > 0 then z3div k l else z3div (- k) (- l))" by (simp add: z3div_def) lemma mod_as_z3mod: "\<forall>k l. k mod l = (if l = 0 then k else if l > 0 then z3mod k l else - z3mod (- k) (- l))" by (simp add: z3mod_def) subsection \<open>Extra theorems for veriT reconstruction\<close> lemma verit_sko_forall: \<open>(\<forall>x. P x) \<longleftrightarrow> P (SOME x. \<not>P x)\<close> using someI[of \<open>\<lambda>x. \<not>P x\<close>] by auto lemma verit_sko_forall': \<open>P (SOME x. \<not>P x) = A \<Longrightarrow> (\<forall>x. P x) = A\<close> by (subst verit_sko_forall) lemma verit_sko_forall'': \<open>B = A \<Longrightarrow> (SOME x. P x) = A \<equiv> (SOME x. P x) = B\<close> by auto lemma verit_sko_forall_indirect: \<open>x = (SOME x. \<not>P x) \<Longrightarrow> (\<forall>x. P x) \<longleftrightarrow> P x\<close> using someI[of \<open>\<lambda>x. \<not>P x\<close>] by auto lemma verit_sko_forall_indirect2: \<open>x = (SOME x. \<not>P x) \<Longrightarrow> (\<And>x :: 'a. (P x = P' x)) \<Longrightarrow>(\<forall>x. P' x) \<longleftrightarrow> P x\<close> using someI[of \<open>\<lambda>x. \<not>P x\<close>] by auto lemma verit_sko_ex: \<open>(\<exists>x. P x) \<longleftrightarrow> P (SOME x. P x)\<close> using someI[of \<open>\<lambda>x. P x\<close>] by auto lemma verit_sko_ex': \<open>P (SOME x. P x) = A \<Longrightarrow> (\<exists>x. P x) = A\<close> by (subst verit_sko_ex) lemma verit_sko_ex_indirect: \<open>x = (SOME x. P x) \<Longrightarrow> (\<exists>x. P x) \<longleftrightarrow> P x\<close> using someI[of \<open>\<lambda>x. P x\<close>] by auto lemma verit_sko_ex_indirect2: \<open>x = (SOME x. P x) \<Longrightarrow> (\<And>x. P x = P' x) \<Longrightarrow> (\<exists>x. P' x) \<longleftrightarrow> P x\<close> using someI[of \<open>\<lambda>x. P x\<close>] by auto lemma verit_Pure_trans: \<open>P \<equiv> Q \<Longrightarrow> Q \<Longrightarrow> P\<close> by auto lemma verit_if_cong: assumes \<open>b \<equiv> c\<close> and \<open>c \<Longrightarrow> x \<equiv> u\<close> and \<open>\<not> c \<Longrightarrow> y \<equiv> v\<close> shows \<open>(if b then x else y) \<equiv> (if c then u else v)\<close> using assms if_cong[of b c x u] by auto lemma verit_if_weak_cong': \<open>b \<equiv> c \<Longrightarrow> (if b then x else y) \<equiv> (if c then x else y)\<close> by auto lemma verit_or_neg: \<open>(A \<Longrightarrow> B) \<Longrightarrow> B \<or> \<not>A\<close> \<open>(\<not>A \<Longrightarrow> B) \<Longrightarrow> B \<or> A\<close> by auto lemma verit_subst_bool: \<open>P \<Longrightarrow> f True \<Longrightarrow> f P\<close> by auto lemma verit_and_pos: \<open>(a \<Longrightarrow> \<not>(b \<and> c) \<or> A) \<Longrightarrow> \<not>(a \<and> b \<and> c) \<or> A\<close> \<open>(a \<Longrightarrow> b \<Longrightarrow> A) \<Longrightarrow> \<not>(a \<and> b) \<or> A\<close> \<open>(a \<Longrightarrow> A) \<Longrightarrow> \<not>a \<or> A\<close> \<open>(\<not>a \<Longrightarrow> A) \<Longrightarrow> a \<or> A\<close> by blast+ lemma verit_or_pos: \<open>A \<and> A' \<Longrightarrow> (c \<and> A) \<or> (\<not>c \<and> A')\<close> \<open>A \<and> A' \<Longrightarrow> (\<not>c \<and> A) \<or> (c \<and> A')\<close> by blast+ lemma verit_la_generic: \<open>(a::int) \<le> x \<or> a = x \<or> a \<ge> x\<close> by linarith lemma verit_bfun_elim: \<open>(if b then P True else P False) = P b\<close> \<open>(\<forall>b. P' b) = (P' False \<and> P' True)\<close> \<open>(\<exists>b. P' b) = (P' False \<or> P' True)\<close> by (cases b) (auto simp: all_bool_eq ex_bool_eq) lemma verit_eq_true_simplify: \<open>(P = True) \<equiv> P\<close> by auto lemma verit_and_neg: \<open>(a \<Longrightarrow> \<not>b \<or> A) \<Longrightarrow> \<not>(a \<and> b) \<or> A\<close> \<open>(a \<Longrightarrow> A) \<Longrightarrow> \<not>a \<or> A\<close> \<open>(\<not>a \<Longrightarrow> A) \<Longrightarrow> a \<or> A\<close> by blast+ lemma verit_forall_inst: \<open>A \<longleftrightarrow> B \<Longrightarrow> \<not>A \<or> B\<close> \<open>\<not>A \<longleftrightarrow> B \<Longrightarrow> A \<or> B\<close> \<open>A \<longleftrightarrow> B \<Longrightarrow> \<not>B \<or> A\<close> \<open>A \<longleftrightarrow> \<not>B \<Longrightarrow> B \<or> A\<close> \<open>A \<longrightarrow> B \<Longrightarrow> \<not>A \<or> B\<close> \<open>\<not>A \<longrightarrow> B \<Longrightarrow> A \<or> B\<close> by blast+ lemma verit_eq_transitive: \<open>A = B \<Longrightarrow> B = C \<Longrightarrow> A = C\<close> \<open>A = B \<Longrightarrow> C = B \<Longrightarrow> A = C\<close> \<open>B = A \<Longrightarrow> B = C \<Longrightarrow> A = C\<close> \<open>B = A \<Longrightarrow> C = B \<Longrightarrow> A = C\<close> by auto lemma verit_bool_simplify: \<open>\<not>(P \<longrightarrow> Q) \<longleftrightarrow> P \<and> \<not>Q\<close> \<open>\<not>(P \<or> Q) \<longleftrightarrow> \<not>P \<and> \<not>Q\<close> \<open>\<not>(P \<and> Q) \<longleftrightarrow> \<not>P \<or> \<not>Q\<close> \<open>(P \<longrightarrow> (Q \<longrightarrow> R)) \<longleftrightarrow> ((P \<and> Q) \<longrightarrow> R)\<close> \<open>((P \<longrightarrow> Q) \<longrightarrow> Q) \<longleftrightarrow> P \<or> Q\<close> \<open>(Q \<longleftrightarrow> (P \<or> Q)) \<longleftrightarrow> (P \<longrightarrow> Q)\<close> \<comment> \<open>This rule was inverted\<close> \<open>P \<and> (P \<longrightarrow> Q) \<longleftrightarrow> P \<and> Q\<close> \<open>(P \<longrightarrow> Q) \<and> P \<longleftrightarrow> P \<and> Q\<close> (* \<comment>\<open>Additional rules:\<close> * \<open>((P \<longrightarrow> Q) \<longrightarrow> P) \<longleftrightarrow> P\<close> * \<open>((P \<longrightarrow> Q) \<longrightarrow> Q) \<longleftrightarrow> P \<or> Q\<close> * \<open>(P \<longrightarrow> Q) \<or> P\<close> *) unfolding not_imp imp_conjL by auto text \<open>We need the last equation for \<^term>\<open>\<not>(\<forall>a b. \<not>P a b)\<close>\<close> lemma verit_connective_def: \<comment> \<open>the definition of XOR is missing as the operator is not generated by Isabelle\<close> \<open>(A = B) \<longleftrightarrow> ((A \<longrightarrow> B) \<and> (B \<longrightarrow> A))\<close> \<open>(If A B C) = ((A \<longrightarrow> B) \<and> (\<not>A \<longrightarrow> C))\<close> \<open>(\<exists>x. P x) \<longleftrightarrow> \<not>(\<forall>x. \<not>P x)\<close> \<open>\<not>(\<exists>x. P x) \<longleftrightarrow> (\<forall>x. \<not>P x)\<close> by auto lemma verit_ite_simplify: \<open>(If True B C) = B\<close> \<open>(If False B C) = C\<close> \<open>(If A' B B) = B\<close> \<open>(If (\<not>A') B C) = (If A' C B)\<close> \<open>(If c (If c A B) C) = (If c A C)\<close> \<open>(If c C (If c A B)) = (If c C B)\<close> \<open>(If A' True False) = A'\<close> \<open>(If A' False True) \<longleftrightarrow> \<not>A'\<close> \<open>(If A' True B') \<longleftrightarrow> A'\<or>B'\<close> \<open>(If A' B' False) \<longleftrightarrow> A'\<and>B'\<close> \<open>(If A' False B') \<longleftrightarrow> \<not>A'\<and>B'\<close> \<open>(If A' B' True) \<longleftrightarrow> \<not>A'\<or>B'\<close> \<open>x \<and> True \<longleftrightarrow> x\<close> \<open>x \<or> False \<longleftrightarrow> x\<close> for B C :: 'a and A' B' C' :: bool by auto lemma verit_and_simplify1: \<open>True \<and> b \<longleftrightarrow> b\<close> \<open>b \<and> True \<longleftrightarrow> b\<close> \<open>False \<and> b \<longleftrightarrow> False\<close> \<open>b \<and> False \<longleftrightarrow> False\<close> \<open>(c \<and> \<not>c) \<longleftrightarrow> False\<close> \<open>(\<not>c \<and> c) \<longleftrightarrow> False\<close> \<open>\<not>\<not>a = a\<close> by auto lemmas verit_and_simplify = conj_ac de_Morgan_conj disj_not1 lemma verit_or_simplify_1: \<open>False \<or> b \<longleftrightarrow> b\<close> \<open>b \<or> False \<longleftrightarrow> b\<close> \<open>b \<or> \<not>b\<close> \<open>\<not>b \<or> b\<close> by auto lemmas verit_or_simplify = disj_ac lemma verit_not_simplify: \<open>\<not> \<not>b \<longleftrightarrow> b\<close> \<open>\<not>True \<longleftrightarrow> False\<close> \<open>\<not>False \<longleftrightarrow> True\<close> by auto lemma verit_implies_simplify: \<open>(\<not>a \<longrightarrow> \<not>b) \<longleftrightarrow> (b \<longrightarrow> a)\<close> \<open>(False \<longrightarrow> a) \<longleftrightarrow> True\<close> \<open>(a \<longrightarrow> True) \<longleftrightarrow> True\<close> \<open>(True \<longrightarrow> a) \<longleftrightarrow> a\<close> \<open>(a \<longrightarrow> False) \<longleftrightarrow> \<not>a\<close> \<open>(a \<longrightarrow> a) \<longleftrightarrow> True\<close> \<open>(\<not>a \<longrightarrow> a) \<longleftrightarrow> a\<close> \<open>(a \<longrightarrow> \<not>a) \<longleftrightarrow> \<not>a\<close> \<open>((a \<longrightarrow> b) \<longrightarrow> b) \<longleftrightarrow> a \<or> b\<close> by auto lemma verit_equiv_simplify: \<open>((\<not>a) = (\<not>b)) \<longleftrightarrow> (a = b)\<close> \<open>(a = a) \<longleftrightarrow> True\<close> \<open>(a = (\<not>a)) \<longleftrightarrow> False\<close> \<open>((\<not>a) = a) \<longleftrightarrow> False\<close> \<open>(True = a) \<longleftrightarrow> a\<close> \<open>(a = True) \<longleftrightarrow> a\<close> \<open>(False = a) \<longleftrightarrow> \<not>a\<close> \<open>(a = False) \<longleftrightarrow> \<not>a\<close> \<open>\<not>\<not>a \<longleftrightarrow> a\<close> \<open>(\<not> False) = True\<close> for a b :: bool by auto lemmas verit_eq_simplify = semiring_char_0_class.eq_numeral_simps eq_refl zero_neq_one num.simps neg_equal_zero equal_neg_zero one_neq_zero neg_equal_iff_equal lemma verit_minus_simplify: \<open>(a :: 'a :: cancel_comm_monoid_add) - a = 0\<close> \<open>(a :: 'a :: cancel_comm_monoid_add) - 0 = a\<close> \<open>0 - (b :: 'b :: {group_add}) = -b\<close> \<open>- (- (b :: 'b :: group_add)) = b\<close> by auto lemma verit_sum_simplify: \<open>(a :: 'a :: cancel_comm_monoid_add) + 0 = a\<close> by auto lemmas verit_prod_simplify = (* already included: mult_zero_class.mult_zero_right mult_zero_class.mult_zero_left *) mult_1 mult_1_right lemma verit_comp_simplify1: \<open>(a :: 'a ::order) < a \<longleftrightarrow> False\<close> \<open>a \<le> a\<close> \<open>\<not>(b' \<le> a') \<longleftrightarrow> (a' :: 'b :: linorder) < b'\<close> by auto lemmas verit_comp_simplify = verit_comp_simplify1 le_numeral_simps le_num_simps less_numeral_simps less_num_simps zero_less_one zero_le_one less_neg_numeral_simps lemma verit_la_disequality: \<open>(a :: 'a ::linorder) = b \<or> \<not>a \<le> b \<or> \<not>b \<le> a\<close> by auto context begin text \<open>For the reconstruction, we need to keep the order of the arguments.\<close> named_theorems smt_arith_multiplication \<open>Theorems to reconstruct arithmetic theorems.\<close> named_theorems smt_arith_combine \<open>Theorems to reconstruct arithmetic theorems.\<close> named_theorems smt_arith_simplify \<open>Theorems to combine theorems in the LA procedure\<close> lemmas [smt_arith_simplify] = div_add dvd_numeral_simp divmod_steps less_num_simps le_num_simps if_True if_False divmod_cancel dvd_mult dvd_mult2 less_irrefl prod.case numeral_plus_one divmod_step_def order.refl le_zero_eq le_numeral_simps less_numeral_simps mult.right_neutral simp_thms divides_aux_eq mult_nonneg_nonneg dvd_imp_mod_0 dvd_add zero_less_one mod_mult_self4 numeral_mod_numeral divmod_trivial prod.sel mult.left_neutral div_pos_pos_trivial arith_simps div_add div_mult_self1 add_le_cancel_left add_le_same_cancel2 not_one_le_zero le_numeral_simps add_le_same_cancel1 zero_neq_one zero_le_one le_num_simps add_Suc mod_div_trivial nat.distinct mult_minus_right add.inverse_inverse distrib_left_numeral mult_num_simps numeral_times_numeral add_num_simps divmod_steps rel_simps if_True if_False numeral_div_numeral divmod_cancel prod.case add_num_simps one_plus_numeral fst_conv arith_simps sub_num_simps dbl_inc_simps dbl_simps mult_1 add_le_cancel_right left_diff_distrib_numeral add_uminus_conv_diff zero_neq_one zero_le_one One_nat_def add_Suc mod_div_trivial nat.distinct of_int_1 numerals numeral_One of_int_numeral add_uminus_conv_diff zle_diff1_eq add_less_same_cancel2 minus_add_distrib add_uminus_conv_diff mult.left_neutral semiring_class.distrib_right add_diff_cancel_left' add_diff_eq ring_distribs mult_minus_left minus_diff_eq lemma [smt_arith_simplify]: \<open>\<not> (a' :: 'a :: linorder) < b' \<longleftrightarrow> b' \<le> a'\<close> \<open>\<not> (a' :: 'a :: linorder) \<le> b' \<longleftrightarrow> b' < a'\<close> \<open>(c::int) mod Numeral1 = 0\<close> \<open>(a::nat) mod Numeral1 = 0\<close> \<open>(c::int) div Numeral1 = c\<close> \<open>a div Numeral1 = a\<close> \<open>(c::int) mod 1 = 0\<close> \<open>a mod 1 = 0\<close> \<open>(c::int) div 1 = c\<close> \<open>a div 1 = a\<close> \<open>\<not>(a' \<noteq> b') \<longleftrightarrow> a' = b'\<close> by auto lemma div_mod_decomp: "A = (A div n) * n + (A mod n)" for A :: nat by auto lemma div_less_mono: fixes A B :: nat assumes "A < B" "0 < n" and mod: "A mod n = 0""B mod n = 0" shows "(A div n) < (B div n)" proof - show ?thesis using assms(1) apply (subst (asm) div_mod_decomp[of "A" n]) apply (subst (asm) div_mod_decomp[of "B" n]) unfolding mod by (use assms(2,3) in \<open>auto simp: ac_simps\<close>) qed lemma verit_le_mono_div: fixes A B :: nat assumes "A < B" "0 < n" shows "(A div n) + (if B mod n = 0 then 1 else 0) \<le> (B div n)" by (auto simp: ac_simps Suc_leI assms less_mult_imp_div_less div_le_mono less_imp_le_nat) lemmas [smt_arith_multiplication] = verit_le_mono_div[THEN mult_le_mono1, unfolded add_mult_distrib] div_le_mono[THEN mult_le_mono2, unfolded add_mult_distrib] lemma div_mod_decomp_int: "A = (A div n) * n + (A mod n)" for A :: int by auto lemma zdiv_mono_strict: fixes A B :: int assumes "A < B" "0 < n" and mod: "A mod n = 0""B mod n = 0" shows "(A div n) < (B div n)" proof - show ?thesis using assms(1) apply (subst (asm) div_mod_decomp_int[of A n]) apply (subst (asm) div_mod_decomp_int[of B n]) unfolding mod by (use assms(2,3) in \<open>auto simp: ac_simps\<close>) qed lemma verit_le_mono_div_int: \<open>A div n + (if B mod n = 0 then 1 else 0) \<le> B div n\<close> if \<open>A < B\<close> \<open>0 < n\<close> for A B n :: int proof - from \<open>A < B\<close> \<open>0 < n\<close> have \<open>A div n \<le> B div n\<close> by (auto intro: zdiv_mono1) show ?thesis proof (cases \<open>n dvd B\<close>) case False with \<open>A div n \<le> B div n\<close> show ?thesis by auto next case True then obtain C where \<open>B = n * C\<close> .. then have \<open>B div n = C\<close> using \<open>0 < n\<close> by simp from \<open>0 < n\<close> have \<open>A mod n \<ge> 0\<close> by simp have \<open>A div n < C\<close> proof (rule ccontr) assume \<open>\<not> A div n < C\<close> then have \<open>C \<le> A div n\<close> by simp with \<open>B div n = C\<close> \<open>A div n \<le> B div n\<close> have \<open>A div n = C\<close> by simp moreover from \<open>A < B\<close> have \<open>n * (A div n) + A mod n < B\<close> by simp ultimately have \<open>n * C + A mod n < n * C\<close> using \<open>B = n * C\<close> by simp moreover have \<open>A mod n \<ge> 0\<close> using \<open>0 < n\<close> by simp ultimately show False by simp qed with \<open>n dvd B\<close> \<open>B div n = C\<close> show ?thesis by simp qed qed lemma verit_less_mono_div_int2: fixes A B :: int assumes "A \<le> B" "0 < -n" shows "(A div n) \<ge> (B div n)" using assms(1) assms(2) zdiv_mono1_neg by auto lemmas [smt_arith_multiplication] = verit_le_mono_div_int[THEN mult_left_mono, unfolded int_distrib] zdiv_mono1[THEN mult_left_mono, unfolded int_distrib] lemmas [smt_arith_multiplication] = arg_cong[of _ _ \<open>\<lambda>a :: nat. a div n * p\<close> for n p :: nat, THEN sym] arg_cong[of _ _ \<open>\<lambda>a :: int. a div n * p\<close> for n p :: int, THEN sym] lemma [smt_arith_combine]: "a < b \<Longrightarrow> c < d \<Longrightarrow> a + c + 2 \<le> b + d" "a < b \<Longrightarrow> c \<le> d \<Longrightarrow> a + c + 1 \<le> b + d" "a \<le> b \<Longrightarrow> c < d \<Longrightarrow> a + c + 1 \<le> b + d" for a b c :: int by auto lemma [smt_arith_combine]: "a < b \<Longrightarrow> c < d \<Longrightarrow> a + c + 2 \<le> b + d" "a < b \<Longrightarrow> c \<le> d \<Longrightarrow> a + c + 1 \<le> b + d" "a \<le> b \<Longrightarrow> c < d \<Longrightarrow> a + c + 1 \<le> b + d" for a b c :: nat by auto lemmas [smt_arith_combine] = add_strict_mono add_less_le_mono add_mono add_le_less_mono lemma [smt_arith_combine]: \<open>m < n \<Longrightarrow> c = d \<Longrightarrow> m + c < n + d\<close> \<open>m \<le> n \<Longrightarrow> c = d \<Longrightarrow> m + c \<le> n + d\<close> \<open>c = d \<Longrightarrow> m < n \<Longrightarrow> m + c < n + d\<close> \<open>c = d \<Longrightarrow> m \<le> n \<Longrightarrow> m + c \<le> n + d\<close> for m :: \<open>'a :: ordered_cancel_ab_semigroup_add\<close> by (auto intro: ordered_cancel_ab_semigroup_add_class.add_strict_right_mono ordered_ab_semigroup_add_class.add_right_mono) lemma verit_negate_coefficient: \<open>a \<le> (b :: 'a :: {ordered_ab_group_add}) \<Longrightarrow> -a \<ge> -b\<close> \<open>a < b \<Longrightarrow> -a > -b\<close> \<open>a = b \<Longrightarrow> -a = -b\<close> by auto end lemma verit_ite_intro: \<open>(if a then P (if a then a' else b') else Q) \<longleftrightarrow> (if a then P a' else Q)\<close> \<open>(if a then P' else Q' (if a then a' else b')) \<longleftrightarrow> (if a then P' else Q' b')\<close> \<open>A = f (if a then R else S) \<longleftrightarrow> (if a then A = f R else A = f S)\<close> by auto lemma verit_ite_if_cong: fixes x y :: bool assumes "b=c" and "c \<equiv> True \<Longrightarrow> x = u" and "c \<equiv> False \<Longrightarrow> y = v" shows "(if b then x else y) \<equiv> (if c then u else v)" proof - have H: "(if b then x else y) = (if c then u else v)" using assms by (auto split: if_splits) show "(if b then x else y) \<equiv> (if c then u else v)" by (subst H) auto qed subsection \<open>Setup\<close> ML_file \<open>Tools/SMT/smt_util.ML\<close> ML_file \<open>Tools/SMT/smt_failure.ML\<close> ML_file \<open>Tools/SMT/smt_config.ML\<close> ML_file \<open>Tools/SMT/smt_builtin.ML\<close> ML_file \<open>Tools/SMT/smt_datatypes.ML\<close> ML_file \<open>Tools/SMT/smt_normalize.ML\<close> ML_file \<open>Tools/SMT/smt_translate.ML\<close> ML_file \<open>Tools/SMT/smtlib.ML\<close> ML_file \<open>Tools/SMT/smtlib_interface.ML\<close> ML_file \<open>Tools/SMT/smtlib_proof.ML\<close> ML_file \<open>Tools/SMT/smtlib_isar.ML\<close> ML_file \<open>Tools/SMT/z3_proof.ML\<close> ML_file \<open>Tools/SMT/z3_isar.ML\<close> ML_file \<open>Tools/SMT/smt_solver.ML\<close> ML_file \<open>Tools/SMT/cvc_interface.ML\<close> ML_file \<open>Tools/SMT/lethe_proof.ML\<close> ML_file \<open>Tools/SMT/lethe_isar.ML\<close> ML_file \<open>Tools/SMT/lethe_proof_parse.ML\<close> ML_file \<open>Tools/SMT/cvc_proof_parse.ML\<close> ML_file \<open>Tools/SMT/conj_disj_perm.ML\<close> ML_file \<open>Tools/SMT/smt_replay_methods.ML\<close> ML_file \<open>Tools/SMT/smt_replay.ML\<close> ML_file \<open>Tools/SMT/smt_replay_arith.ML\<close> ML_file \<open>Tools/SMT/z3_interface.ML\<close> ML_file \<open>Tools/SMT/z3_replay_rules.ML\<close> ML_file \<open>Tools/SMT/z3_replay_methods.ML\<close> ML_file \<open>Tools/SMT/z3_replay.ML\<close> ML_file \<open>Tools/SMT/lethe_replay_methods.ML\<close> ML_file \<open>Tools/SMT/verit_replay_methods.ML\<close> ML_file \<open>Tools/SMT/verit_strategies.ML\<close> ML_file \<open>Tools/SMT/verit_replay.ML\<close> ML_file \<open>Tools/SMT/smt_systems.ML\<close> subsection \<open>Configuration\<close> text \<open> The current configuration can be printed by the command \<open>smt_status\<close>, which shows the values of most options. \<close> subsection \<open>General configuration options\<close> text \<open> The option \<open>smt_solver\<close> can be used to change the target SMT solver. The possible values can be obtained from the \<open>smt_status\<close> command. \<close> declare [[smt_solver = z3]] text \<open> Since SMT solvers are potentially nonterminating, there is a timeout (given in seconds) to restrict their runtime. \<close> declare [[smt_timeout = 0]] text \<open> SMT solvers apply randomized heuristics. In case a problem is not solvable by an SMT solver, changing the following option might help. \<close> declare [[smt_random_seed = 1]] text \<open> In general, the binding to SMT solvers runs as an oracle, i.e, the SMT solvers are fully trusted without additional checks. The following option can cause the SMT solver to run in proof-producing mode, giving a checkable certificate. This is currently implemented only for veriT and Z3. \<close> declare [[smt_oracle = false]] text \<open> Each SMT solver provides several command-line options to tweak its behaviour. They can be passed to the solver by setting the following options. \<close> declare [[cvc4_options = ""]] declare [[cvc5_options = ""]] declare [[verit_options = ""]] declare [[z3_options = ""]] text \<open> The SMT method provides an inference mechanism to detect simple triggers in quantified formulas, which might increase the number of problems solvable by SMT solvers (note: triggers guide quantifier instantiations in the SMT solver). To turn it on, set the following option. \<close> declare [[smt_infer_triggers = false]] text \<open> Enable the following option to use built-in support for datatypes, codatatypes, and records in CVC4 and cvc5. Currently, this is implemented only in oracle mode. \<close> declare [[cvc_extensions = false]] text \<open> Enable the following option to use built-in support for div/mod, datatypes, and records in Z3. Currently, this is implemented only in oracle mode. \<close> declare [[z3_extensions = false]] subsection \<open>Certificates\<close> text \<open> By setting the option \<open>smt_certificates\<close> to the name of a file, all following applications of an SMT solver a cached in that file. Any further application of the same SMT solver (using the very same configuration) re-uses the cached certificate instead of invoking the solver. An empty string disables caching certificates. The filename should be given as an explicit path. It is good practice to use the name of the current theory (with ending \<open>.certs\<close> instead of \<open>.thy\<close>) as the certificates file. Certificate files should be used at most once in a certain theory context, to avoid race conditions with other concurrent accesses. \<close> declare [[smt_certificates = ""]] text \<open> The option \<open>smt_read_only_certificates\<close> controls whether only stored certificates should be used or invocation of an SMT solver is allowed. When set to \<open>true\<close>, no SMT solver will ever be invoked and only the existing certificates found in the configured cache are used; when set to \<open>false\<close> and there is no cached certificate for some proposition, then the configured SMT solver is invoked. \<close> declare [[smt_read_only_certificates = false]] subsection \<open>Tracing\<close> text \<open> The SMT method, when applied, traces important information. To make it entirely silent, set the following option to \<open>false\<close>. \<close> declare [[smt_verbose = true]] text \<open> For tracing the generated problem file given to the SMT solver as well as the returned result of the solver, the option \<open>smt_trace\<close> should be set to \<open>true\<close>. \<close> declare [[smt_trace = false]] subsection \<open>Schematic rules for Z3 proof reconstruction\<close> text \<open> Several prof rules of Z3 are not very well documented. There are two lemma groups which can turn failing Z3 proof reconstruction attempts into succeeding ones: the facts in \<open>z3_rule\<close> are tried prior to any implemented reconstruction procedure for all uncertain Z3 proof rules; the facts in \<open>z3_simp\<close> are only fed to invocations of the simplifier when reconstructing theory-specific proof steps. \<close> lemmas [z3_rule] = refl eq_commute conj_commute disj_commute simp_thms nnf_simps ring_distribs field_simps times_divide_eq_right times_divide_eq_left if_True if_False not_not NO_MATCH_def lemma [z3_rule]: "(P \<and> Q) = (\<not> (\<not> P \<or> \<not> Q))" "(P \<and> Q) = (\<not> (\<not> Q \<or> \<not> P))" "(\<not> P \<and> Q) = (\<not> (P \<or> \<not> Q))" "(\<not> P \<and> Q) = (\<not> (\<not> Q \<or> P))" "(P \<and> \<not> Q) = (\<not> (\<not> P \<or> Q))" "(P \<and> \<not> Q) = (\<not> (Q \<or> \<not> P))" "(\<not> P \<and> \<not> Q) = (\<not> (P \<or> Q))" "(\<not> P \<and> \<not> Q) = (\<not> (Q \<or> P))" by auto lemma [z3_rule]: "(P \<longrightarrow> Q) = (Q \<or> \<not> P)" "(\<not> P \<longrightarrow> Q) = (P \<or> Q)" "(\<not> P \<longrightarrow> Q) = (Q \<or> P)" "(True \<longrightarrow> P) = P" "(P \<longrightarrow> True) = True" "(False \<longrightarrow> P) = True" "(P \<longrightarrow> P) = True" "(\<not> (A \<longleftrightarrow> \<not> B)) \<longleftrightarrow> (A \<longleftrightarrow> B)" by auto lemma [z3_rule]: "((P = Q) \<longrightarrow> R) = (R \<or> (Q = (\<not> P)))" by auto lemma [z3_rule]: "(\<not> True) = False" "(\<not> False) = True" "(x = x) = True" "(P = True) = P" "(True = P) = P" "(P = False) = (\<not> P)" "(False = P) = (\<not> P)" "((\<not> P) = P) = False" "(P = (\<not> P)) = False" "((\<not> P) = (\<not> Q)) = (P = Q)" "\<not> (P = (\<not> Q)) = (P = Q)" "\<not> ((\<not> P) = Q) = (P = Q)" "(P \<noteq> Q) = (Q = (\<not> P))" "(P = Q) = ((\<not> P \<or> Q) \<and> (P \<or> \<not> Q))" "(P \<noteq> Q) = ((\<not> P \<or> \<not> Q) \<and> (P \<or> Q))" by auto lemma [z3_rule]: "(if P then P else \<not> P) = True" "(if \<not> P then \<not> P else P) = True" "(if P then True else False) = P" "(if P then False else True) = (\<not> P)" "(if P then Q else True) = ((\<not> P) \<or> Q)" "(if P then Q else True) = (Q \<or> (\<not> P))" "(if P then Q else \<not> Q) = (P = Q)" "(if P then Q else \<not> Q) = (Q = P)" "(if P then \<not> Q else Q) = (P = (\<not> Q))" "(if P then \<not> Q else Q) = ((\<not> Q) = P)" "(if \<not> P then x else y) = (if P then y else x)" "(if P then (if Q then x else y) else x) = (if P \<and> (\<not> Q) then y else x)" "(if P then (if Q then x else y) else x) = (if (\<not> Q) \<and> P then y else x)" "(if P then (if Q then x else y) else y) = (if P \<and> Q then x else y)" "(if P then (if Q then x else y) else y) = (if Q \<and> P then x else y)" "(if P then x else if P then y else z) = (if P then x else z)" "(if P then x else if Q then x else y) = (if P \<or> Q then x else y)" "(if P then x else if Q then x else y) = (if Q \<or> P then x else y)" "(if P then x = y else x = z) = (x = (if P then y else z))" "(if P then x = y else y = z) = (y = (if P then x else z))" "(if P then x = y else z = y) = (y = (if P then x else z))" by auto lemma [z3_rule]: "0 + (x::int) = x" "x + 0 = x" "x + x = 2 * x" "0 * x = 0" "1 * x = x" "x + y = y + x" by auto lemma [z3_rule]: (* for def-axiom *) "P = Q \<or> P \<or> Q" "P = Q \<or> \<not> P \<or> \<not> Q" "(\<not> P) = Q \<or> \<not> P \<or> Q" "(\<not> P) = Q \<or> P \<or> \<not> Q" "P = (\<not> Q) \<or> \<not> P \<or> Q" "P = (\<not> Q) \<or> P \<or> \<not> Q" "P \<noteq> Q \<or> P \<or> \<not> Q" "P \<noteq> Q \<or> \<not> P \<or> Q" "P \<noteq> (\<not> Q) \<or> P \<or> Q" "(\<not> P) \<noteq> Q \<or> P \<or> Q" "P \<or> Q \<or> P \<noteq> (\<not> Q)" "P \<or> Q \<or> (\<not> P) \<noteq> Q" "P \<or> \<not> Q \<or> P \<noteq> Q" "\<not> P \<or> Q \<or> P \<noteq> Q" "P \<or> y = (if P then x else y)" "P \<or> (if P then x else y) = y" "\<not> P \<or> x = (if P then x else y)" "\<not> P \<or> (if P then x else y) = x" "P \<or> R \<or> \<not> (if P then Q else R)" "\<not> P \<or> Q \<or> \<not> (if P then Q else R)" "\<not> (if P then Q else R) \<or> \<not> P \<or> Q" "\<not> (if P then Q else R) \<or> P \<or> R" "(if P then Q else R) \<or> \<not> P \<or> \<not> Q" "(if P then Q else R) \<or> P \<or> \<not> R" "(if P then \<not> Q else R) \<or> \<not> P \<or> Q" "(if P then Q else \<not> R) \<or> P \<or> R" by auto hide_type (open) symb_list pattern hide_const (open) Symb_Nil Symb_Cons trigger pat nopat fun_app z3div z3mod end
(* This file is generated by Why3's Coq driver *) (* Beware! Only edit allowed sections below *) Require Import BuiltIn. Require BuiltIn. Require int.Int. Require int.Abs. Require int.EuclideanDivision. (* Why3 assumption *) Definition unit := unit. Parameter fib: Z -> Z. Axiom fib0 : ((fib 0%Z) = 0%Z). Axiom fib1 : ((fib 1%Z) = 1%Z). Axiom fibn : forall (n:Z), (2%Z <= n)%Z -> ((fib n) = ((fib (n - 1%Z)%Z) + (fib (n - 2%Z)%Z))%Z). (* Why3 assumption *) Inductive t := | mk_t : Z -> Z -> Z -> Z -> t. Axiom t_WhyType : WhyType t. Existing Instance t_WhyType. (* Why3 assumption *) Definition a22 (v:t): Z := match v with | (mk_t x x1 x2 x3) => x3 end. (* Why3 assumption *) Definition a21 (v:t): Z := match v with | (mk_t x x1 x2 x3) => x2 end. (* Why3 assumption *) Definition a12 (v:t): Z := match v with | (mk_t x x1 x2 x3) => x1 end. (* Why3 assumption *) Definition a11 (v:t): Z := match v with | (mk_t x x1 x2 x3) => x end. (* Why3 assumption *) Definition mult (x:t) (y:t): t := (mk_t (((a11 x) * (a11 y))%Z + ((a12 x) * (a21 y))%Z)%Z (((a11 x) * (a12 y))%Z + ((a12 x) * (a22 y))%Z)%Z (((a21 x) * (a11 y))%Z + ((a22 x) * (a21 y))%Z)%Z (((a21 x) * (a12 y))%Z + ((a22 x) * (a22 y))%Z)%Z). Axiom Assoc : forall (x:t) (y:t) (z:t), ((mult (mult x y) z) = (mult x (mult y z))). Axiom Unit_def_l : forall (x:t), ((mult (mk_t 1%Z 0%Z 0%Z 1%Z) x) = x). Axiom Unit_def_r : forall (x:t), ((mult x (mk_t 1%Z 0%Z 0%Z 1%Z)) = x). Axiom Comm : forall (x:t) (y:t), ((mult x y) = (mult y x)). Parameter power: t -> Z -> t. Axiom Power_0 : forall (x:t), ((power x 0%Z) = (mk_t 1%Z 0%Z 0%Z 1%Z)). Axiom Power_s : forall (x:t) (n:Z), (0%Z <= n)%Z -> ((power x (n + 1%Z)%Z) = (mult x (power x n))). Axiom Power_s_alt : forall (x:t) (n:Z), (0%Z < n)%Z -> ((power x n) = (mult x (power x (n - 1%Z)%Z))). Axiom Power_1 : forall (x:t), ((power x 1%Z) = x). Axiom Power_sum : forall (x:t) (n:Z) (m:Z), (0%Z <= n)%Z -> ((0%Z <= m)%Z -> ((power x (n + m)%Z) = (mult (power x n) (power x m)))). Axiom Power_mult : forall (x:t) (n:Z) (m:Z), (0%Z <= n)%Z -> ((0%Z <= m)%Z -> ((power x (n * m)%Z) = (power (power x n) m))). Axiom Power_mult2 : forall (x:t) (y:t) (n:Z), (0%Z <= n)%Z -> ((power (mult x y) n) = (mult (power x n) (power y n))). (* Why3 goal *) Theorem WP_parameter_logfib : forall (n:Z), (0%Z <= n)%Z -> ((~ (n = 0%Z)) -> let o := (int.EuclideanDivision.div n 2%Z) in ((0%Z <= o)%Z -> forall (result:Z) (result1:Z), ((power (mk_t 1%Z 1%Z 1%Z 0%Z) o) = (mk_t (result + result1)%Z result1 result1 result)) -> let c := (result + result1)%Z in ((((int.EuclideanDivision.mod1 n 2%Z) = 0%Z) -> let a := ((result * result)%Z + (result1 * result1)%Z)%Z in let b := (result1 * (result + c)%Z)%Z in ((power (mk_t 1%Z 1%Z 1%Z 0%Z) n) = (mk_t (a + b)%Z b b a))) /\ ((~ ((int.EuclideanDivision.mod1 n 2%Z) = 0%Z)) -> let a := (result1 * (result + c)%Z)%Z in let b := ((c * c)%Z + (result1 * result1)%Z)%Z in ((power (mk_t 1%Z 1%Z 1%Z 0%Z) n) = (mk_t (a + b)%Z b b a)))))). (* Why3 intros n h1 h2 o h3 result result1 h4 c. *) (* YOU MAY EDIT THE PROOF BELOW *) Import EuclideanDivision. intros. subst o c. assert (h: (2 <> 0)%Z) by omega. generalize (Div_mod n 2 h)%Z. intuition. rewrite H4 in H3. rewrite H3. replace (2 * div n 2 + 0)%Z with (div n 2 + div n 2)%Z by omega. rewrite Power_sum by exact H1. rewrite H2; simpl. unfold mult; simpl. apply f_equal4; ring. generalize (Mod_bound n 2 h)%Z. simpl. intro. assert (h': (mod1 n 2 = 1)%Z) by omega. rewrite h' in H3. rewrite H3. replace (2 * div n 2 + 1)%Z with ((div n 2 + div n 2) + 1)%Z by omega. rewrite Power_s. rewrite Power_sum by exact H1. rewrite H2; simpl. unfold mult at 2; simpl. unfold mult. apply f_equal4; unfold a11, a12, a21, a22; try ring. intuition. Qed.
program matrix_clip_zero use, intrinsic :: iso_fortran_env, only : dp => REAL64 implicit none integer, parameter :: m = 3, n = 3 real(kind=dp), dimension(m, n) :: A = reshape([ 3.0, 1.0, 4.0, & -3.0, -0.5, -2.0, & -0.5, 2.0, -1.0 ], [m, n]) integer :: i do i = 1, m print *, A(i, :) end do call clip_zeros(A, 1.0_dp) print *, 'clipped' do i = 1, m print *, A(i, :) end do contains subroutine clip_zeros(A, epsilon) use, intrinsic :: iso_fortran_env, only : dp => REAL64 implicit none real(kind=dp), dimension(:, :), intent(inout) :: A real(kind=dp), intent(in) :: epsilon where (abs(A) < epsilon) A = 0.0_dp end where end subroutine clip_zeros end program matrix_clip_zero
printdf <- function(df, n, var, na.print="") { df <- df[,var] print(df, n=n, na.print="") } ## following is an alternate to the above #printdf_merge <- function(df,nrows,var) { #df <- df[,var] ##print(df,na.print=NULL,n=nrows) #entries <- ncol(df) * nrows #print(df,na.print=NULL,max=entries) #} ##printdf(df,5,c('TS_ID','Spacing'))
!*********************************************************************** ! Integrated Water Flow Model (IWFM) ! Copyright (C) 2005-2021 ! State of California, Department of Water Resources ! ! 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 2 ! 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. ! (http://www.gnu.org/copyleft/gpl.html) ! ! 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! ! For tecnical support, e-mail: [email protected] !*********************************************************************** MODULE TileDrainHydrograph USE MessageLogger , ONLY: SetLastMessage , & LogMessage , & iFatal , & iWarn USE GeneralUtilities , ONLY: ConvertID_To_Index , & IntToText , & StripTextUntilCharacter , & ArrangeText , & PrepareTitle , & EstablishAbsolutePathFileName , & CleanSpecialCharacters USE TimeSeriesUtilities , ONLY: TimeStepType , & IncrementTimeStamp USE IOInterface , ONLY: GenericFileType , & iGetFileType_FromName , & DSS USE Package_Misc , ONLY: RealTSDataInFileType , & ReadTSData , & PrepareTSDOutputFile USE AppTileDrain_Parameters , ONLY: f_iTileDrain , & f_iSubIrig IMPLICIT NONE ! ****************************************************************** ! ****************************************************************** ! ****************************************************************** ! *** ! *** VARIABLE DEFINITIONS ! *** ! ****************************************************************** ! ****************************************************************** ! ****************************************************************** ! ------------------------------------------------------------- ! --- PUBLIC ENTITIES ! ------------------------------------------------------------- PRIVATE PUBLIC :: TileDrainHydrographType ! ------------------------------------------------------------- ! --- TILE DRAIN HYDROGRAPH DATA TYPE ! ------------------------------------------------------------- TYPE TileDrainHydrographType TYPE(GenericFileType) :: OutFile LOGICAL :: OutFile_Defined = .FALSE. TYPE(RealTSDataInFileType) :: InFile_ForInquiry LOGICAL :: InFile_ForInquiry_Defined = .FALSE. REAL(8) :: FactFlow = 1.0 CHARACTER(LEN=10) :: UnitFlow = '' INTEGER :: NHyd = 0 INTEGER,ALLOCATABLE :: iHydIndices(:) INTEGER,ALLOCATABLE :: iHydTypes(:) CHARACTER(LEN=30),ALLOCATABLE :: cHydNames(:) CONTAINS PROCEDURE,PASS :: New PROCEDURE,PASS :: Kill PROCEDURE,PASS :: ReadTDHyd_AtHydrographLocation PROCEDURE,PASS :: PrintResults PROCEDURE,PASS :: IsOutFileDefined PROCEDURE,PASS :: GetOutFileName PROCEDURE,PASS :: GetNHydrographs PROCEDURE,PASS :: GetHydrographIDs PROCEDURE,PASS :: GetHydrographCoordinates PROCEDURE,PASS :: GetHydrographNames PROCEDURE,PASS :: Transfer_To_HDF END TYPE TileDrainHydrographType ! ------------------------------------------------------------- ! --- MISC. ENTITIES ! ------------------------------------------------------------- INTEGER,PARAMETER :: ModNameLen = 21 CHARACTER(LEN=ModNameLen),PARAMETER :: ModName = 'TileDrainHydrograph::' CONTAINS ! ****************************************************************** ! ****************************************************************** ! ****************************************************************** ! *** ! *** CONSTRUCTORS ! *** ! ****************************************************************** ! ****************************************************************** ! ****************************************************************** ! ------------------------------------------------------------- ! --- READ TILE DRAIN HYDROGRAPH PRINT DATA FROM FILE ! ------------------------------------------------------------- SUBROUTINE New(TDHyd,IsForInquiry,cWorkingDirectory,NodeIDs,SubIrigIDs,DrainIDs,SubIrigNodes,DrainNodes,TimeStep,InFile,iStat) CLASS(TileDrainHydrographType),INTENT(OUT) :: TDHyd LOGICAL,INTENT(IN) :: IsForInquiry CHARACTER(LEN=*),INTENT(IN) :: cWorkingDirectory INTEGER,INTENT(IN) :: NodeIDs(:),SubIrigIDs(:),DrainIDs(:),SubIrigNodes(:),DrainNodes(:) TYPE(TimeStepType),INTENT(IN) :: TimeStep TYPE(GenericFileType) :: InFile INTEGER,INTENT(OUT) :: iStat !Local variables CHARACTER(LEN=ModNameLen+3) :: ThisProcedure = ModName // 'New' INTEGER :: NHyd,indx,NDrain,NSubIrig,ErrorCode,ID CHARACTER :: cTDOutFile*1000,ALine*1000 CHARACTER(:),ALLOCATABLE :: cAbsPathFileName !Initialize iStat = 0 NDrain = SIZE(DrainNodes) NSubIrig = SIZE(SubIrigNodes) !Read data CALL InFile%ReadData(NHyd,iStat) ; IF (iStat .EQ. -1) RETURN ; TDHyd%NHyd = NHyd IF (NHyd .EQ. 0) RETURN CALL InFile%ReadData(TDHyd%FactFlow,iStat) ; IF (iStat .EQ. -1) RETURN CALL InFile%ReadData(ALine,iStat) ; IF (iStat .EQ. -1) RETURN ; CALL CleanSpecialCharacters(ALine) ; ALine = StripTextUntilCharacter(ALine,'/') TDHyd%UnitFlow = ADJUSTL(TRIM(ALine)) !Output file name CALL InFile%ReadData(cTDOutFile,iStat) ; IF (iStat .EQ. -1) RETURN ; cTDOutFile = StripTextUntilCharacter(cTDOutFile,'/') ; CALL CleanSpecialCharacters(cTDOutFile) IF (cTDOutFile .EQ. '') THEN CALL LogMessage('Tile drain hydrograph printing is suppressed because an output file name is not specified!',iWarn,ThisProcedure) TDHyd%NHyd = 0 RETURN END IF !Allocate memory ALLOCATE (TDHyd%iHydIndices(NHyd) , TDHyd%iHydTypes(NHyd) , TDHyd%cHydNames(NHyd)) TDHyd%cHydNames = '' !Read the hydrograph IDs for printing DO indx=1,NHyd CALL InFile%ReadData(ALine,iStat) ; IF (iStat .EQ. -1) RETURN ; CALL CleanSpecialCharacters(ALine) ; ALine = StripTextUntilCharacter(ALine,'/') ; ALine = ADJUSTL(ALine) READ (ALine,*,IOSTAT=ErrorCode) ID , TDHyd%iHydTypes(indx) , TDHyd%cHydNames(indx) IF (ErrorCode .NE. 0) THEN CALL SetLastMessage('Error in reading tile drain/subsurface irrigation hydrograph data for hydrograph ID '//TRIM(IntToText(indx))//'!',iFatal,ThisProcedure) iStat = -1 RETURN END IF !Make sure hydrograph type is recognized IF (TDHyd%iHydTypes(indx).NE.f_iTileDrain .AND. TDHyd%iHydTypes(indx).NE.f_iSubIrig) THEN CALL SetLastMessage('Hydrograph type for tile drain/subsurface irrigation hydrograph printing is not recognized!',iFatal,ThisProcedure) iStat = -1 RETURN END IF !Convert hydrograph ID to index IF (TDHyd%iHydTypes(indx) .EQ. f_iTileDrain) THEN CALL ConvertID_To_Index(ID,DrainIDs,TDHyd%iHydIndices(indx)) IF (TDHyd%iHydIndices(indx) .EQ. 0) THEN CALL SetLastMessage('Tile drain ID '//TRIM(IntToText(ID))//' listed for hydrograph printing is not simulated!',iFatal,ThisProcedure) iStat = -1 RETURN END IF ELSE CALL ConvertID_To_Index(ID,SubIrigIDs,TDHyd%iHydIndices(indx)) IF (TDHyd%iHydIndices(indx) .EQ. 0) THEN CALL SetLastMessage('Subsurface irrigation ID '//TRIM(IntToText(ID))//' listed for hydrograph printing is not simulated!',iFatal,ThisProcedure) iStat = -1 RETURN END IF END IF END DO !Prepare output file CALL EstablishAbsolutePathFileName(TRIM(ADJUSTL(cTDOutFile)),cWorkingDirectory,cAbsPathFileName) IF (IsForInquiry) THEN CALL PrepTileDrainHydInFile_ForInquiry(TimeStep,NodeIDs,SubIrigNodes,DrainNodes,cAbsPathFileName,TDHyd,iStat) ELSE CALL PrepTileDrainHydOutFile(TimeStep,NodeIDs,SubIrigIDs,DrainIDs,SubIrigNodes,DrainNodes,cAbsPathFileName,TDHyd,iStat) END IF END SUBROUTINE New ! ****************************************************************** ! ****************************************************************** ! ****************************************************************** ! *** ! *** DESTRUCTOR ! *** ! ****************************************************************** ! ****************************************************************** ! ****************************************************************** ! ------------------------------------------------------------- ! --- KILL TILE DRAIN HYDROGRAPH PRINT DATA ! ------------------------------------------------------------- SUBROUTINE Kill(TDHyd) CLASS(TileDrainHydrographType) :: TDHyd !Local variables INTEGER :: ErrorCode TYPE(TileDrainHydrographType) :: Dummy IF (TDHyd%OutFile_Defined) CALL TDHyd%OutFile%Kill() IF (TDHyd%InFile_ForInquiry_Defined) CALL TDHyd%InFile_ForInquiry%Close() DEALLOCATE (TDHyd%iHydIndices , TDHyd%iHydTypes , TDHyd%cHydNames , STAT=ErrorCode) SELECT TYPE (p => TDHyd) TYPE IS (TileDrainHydrographType) p = Dummy END SELECT END SUBROUTINE Kill ! ****************************************************************** ! ****************************************************************** ! ****************************************************************** ! *** ! *** GETTERS ! *** ! ****************************************************************** ! ****************************************************************** ! ****************************************************************** ! ------------------------------------------------------------- ! --- GET THE OUTPUT FILE NAME ! ------------------------------------------------------------- SUBROUTINE GetOutFileName(TDHyd,cName) CLASS(TileDrainHydrographType),INTENT(IN) :: TDHyd CHARACTER(:),ALLOCATABLE,INTENT(OUT) :: cName !Local variables INTEGER :: ErrorCode !Initialize DEALLOCATE (cName , STAT=ErrorCode) IF (TDHyd%OutFile_Defined) THEN CALL TDHyd%OutFile%GetName(cName) ELSEIF (TDHyd%InFile_ForInquiry_Defined) THEN CALL TDHyd%InFile_ForInquiry%GetFileName(cName) END IF END SUBROUTINE GetOutFileName ! ------------------------------------------------------------- ! --- GET NUMBER OF TILE DRAIN HYDROGRAPHS ! ------------------------------------------------------------- PURE FUNCTION GetNHydrographs(TDHyd,iHydType) RESULT(NHyd) CLASS(TileDrainHydrographType),INTENT(IN) :: TDHyd INTEGER,INTENT(IN) :: iHydType INTEGER :: NHyd !No tile drain hydrograph is defined IF (TDHyd%NHyd .EQ. 0) THEN NHyd = 0 RETURN END IF !Return number of tile drain/sub irrigtaion hydrographs NHyd = COUNT(TDHyd%iHydTypes .EQ. iHydType) END FUNCTION GetNHydrographs ! ------------------------------------------------------------- ! --- GET TILE DRAIN HYDROGRAPH IDS ! ------------------------------------------------------------- PURE SUBROUTINE GetHydrographIDs(TDHyd,iHydType,iAllIDs,IDs) CLASS(TileDrainHydrographType),INTENT(IN) :: TDHyd INTEGER,INTENT(IN) :: iHydType,iAllIDs(:) INTEGER,INTENT(OUT) :: IDs(:) !Local variables INTEGER :: iCount,indx iCount = 0 DO indx=1,TDHyd%NHyd IF (TDHyd%iHydTypes(indx) .EQ. iHydType) THEN iCount = iCount + 1 IDs(iCount) = iAllIDs(TDHyd%iHydIndices(indx)) END IF END DO END SUBROUTINE GetHydrographIDs ! ------------------------------------------------------------- ! --- GET HYDROGRAPH COORDINATES ! ------------------------------------------------------------- PURE SUBROUTINE GetHydrographCoordinates(TDHyd,iHydType,iNodes,GridX,GridY,XHyd,YHyd) CLASS(TileDrainHydrographType),INTENT(IN) :: TDHyd INTEGER,INTENT(IN) :: iHydType,iNodes(:) REAL(8),INTENT(IN) :: GridX(:),GridY(:) REAL(8),INTENT(OUT) :: XHyd(:),YHyd(:) !Local variables INTEGER :: iCount,indx,iNode iCount = 0 DO indx=1,TDHyd%NHyd IF (TDHyd%iHydTypes(indx) .EQ. iHydType) THEN iCount = iCount + 1 iNode = iNodes(TDHyd%iHydIndices(indx)) XHyd(iCount) = GridX(iNode) YHyd(iCount) = GridY(iNode) END IF END DO END SUBROUTINE GetHydrographCoordinates ! ------------------------------------------------------------- ! --- GET TILE DRAIN HYDROGRAPH NAMES ! ------------------------------------------------------------- PURE SUBROUTINE GetHydrographNames(TDHyd,cNamesList) CLASS(TileDrainHydrographType),INTENT(IN) :: TDHyd CHARACTER(LEN=*),INTENT(OUT) :: cNamesList(:) !Assumes array is previously dimensioned based on the number of tile drain hydrographs !Local variables INTEGER :: indx,iCount !Get only tile drain hydrograph names iCount = 1 DO indx=1,TDHyd%NHyd IF (TDHyd%iHydTypes(indx) .EQ. f_iTileDrain) THEN cNamesList(iCount) = TDHyd%cHydNames(indx) iCount = iCount + 1 END IF END DO END SUBROUTINE GetHydrographNames ! ****************************************************************** ! ****************************************************************** ! ****************************************************************** ! *** ! *** DATA READERS ! *** ! ****************************************************************** ! ****************************************************************** ! ****************************************************************** ! ------------------------------------------------------------- ! --- READ SIMULATED TILE DRAIN/SUBSURFACE IRRIGATION AT A HYDROGRAPH LOCATION ! --- Note: Assumes InFile_ForInquiry file exists ! ------------------------------------------------------------- SUBROUTINE ReadTDHyd_AtHydrographLocation(TDHyd,iHydIDs,iHydType,iHydID,cOutputBeginDateAndTime,cOutputEndDateAndTime,rConversionFactor,nActualOutput,rOutputDates,rOutputValues,iStat) CLASS(TileDrainHydrographType) :: TDHyd INTEGER,INTENT(IN) :: iHydIDs(:),iHydType,iHydID CHARACTER(LEN=*),INTENT(IN) :: cOutputBeginDateAndTime,cOutputEndDateAndTime REAL(8),INTENT(IN) :: rConversionFactor INTEGER,INTENT(OUT) :: nActualOutput REAL(8),INTENT(OUT) :: rOutputDates(:),rOutputValues(:) INTEGER,INTENT(OUT) :: iStat !Local variables CHARACTER(LEN=ModNameLen+30),PARAMETER :: ThisProcedure = ModName // 'ReadTDHyd_AtHydrographLocation' INTEGER :: ErrorCode,iHydIndex,iPointer,indx REAL(8) :: rEffectiveFactor !Initialize iStat = 0 !Find the index of hydrograph iHydIndex = 0 DO indx=1,TDHyd%NHyd IF (iHydType .EQ. TDHyd%iHydTypes(indx)) THEN iPointer = TDHyd%iHydIndices(indx) IF (iHydID .EQ. iHydIDs(iPointer)) THEN iHydIndex = indx EXIT END IF END IF END DO IF (iHydIndex .EQ. 0) THEN CALL SetLastMessage('Tile drain/subsurface irrigation hydrograph ID '//TRIM(IntToText(iHydID))//' for results retrieval is not in the model!',iFatal,ThisProcedure) iStat = -1 RETURN END IF !Read data CALL TDHyd%InFile_ForInquiry%ReadData(iHydIndex,cOutputBeginDateAndTime,cOutputEndDateAndTime,nActualOutput,rOutputValues,rOutputDates,ErrorCode,iStat) IF (iStat .EQ. -1) RETURN !Convert unit rEffectiveFactor = rConversionFactor / TDHyd%FactFlow IF (rEffectiveFactor .NE. 1d0) rOutputValues = rOutputValues * rEffectiveFactor !Rewind file CALL TDHyd%InFile_ForInquiry%File%RewindFile_To_BeginningOfTSData(iStat) END SUBROUTINE ReadTDHyd_AtHydrographLocation ! ****************************************************************** ! ****************************************************************** ! ****************************************************************** ! *** ! *** DATA WRITERS ! *** ! ****************************************************************** ! ****************************************************************** ! ****************************************************************** ! ------------------------------------------------------------- ! --- PRINT OUT HYDROGRAPHS ! ------------------------------------------------------------- SUBROUTINE PrintResults(TDHyd,rDrainFlows,rSubIrigFlows,TimeStep,lEndOfSimulation) CLASS(TileDrainHydrographType) :: TDHyd REAL(8),INTENT(IN) :: rDrainFlows(:),rSubIrigFlows(:) TYPE(TimeStepType),INTENT(IN) :: TimeStep LOGICAL,INTENT(IN) :: lEndOfSimulation !Local variables INTEGER :: indxHyd,indx REAL(8) :: rFlows(TDHyd%NHyd),rFactor CHARACTER(LEN=21) :: SimulationTime !Initialize rFactor = TDHyd%FactFlow !Create the simulation time IF (TimeStep%TrackTime) THEN SimulationTime=ADJUSTL(TimeStep%CurrentDateAndTime) ELSE WRITE(SimulationTime,'(F10.2,1X,A10)') TimeStep%CurrentTime,ADJUSTL(TimeStep%Unit) END IF !Compile flows DO indxHyd=1,TDHyd%NHyd indx = TDHyd%iHydIndices(indxHyd) IF (TDHyd%iHydTypes(indxHyd) .EQ. f_iTileDrain) THEN rFlows(indxHyd) = rDrainFlows(indx) * rFactor ELSE rFlows(indxHyd) = rSubIrigFlows(indx) * rFactor END IF END DO !Print out the results CALL TDHyd%OutFile%WriteData(SimulationTime,rFlows,FinalPrint=lEndOfSimulation) END SUBROUTINE PrintResults ! ****************************************************************** ! ****************************************************************** ! ****************************************************************** ! *** ! *** MISC. METHODS ! *** ! ****************************************************************** ! ****************************************************************** ! ****************************************************************** ! ------------------------------------------------------------- ! ---CHECK IF OUTPUT FILE IS DEFINED ! ------------------------------------------------------------- FUNCTION IsOutFileDefined(TDHyd) RESULT(lDefined) CLASS(TileDrainHydrographType),INTENT(IN) :: TDHyd LOGICAL :: lDefined lDefined = TDHyd%OutFile_Defined .OR. TDHyd%InFile_ForInquiry_Defined END FUNCTION IsOutFileDefined ! ------------------------------------------------------------- ! --- NEW TILE DRAIN HYDROGRAPH OUTPUT FILE ! ------------------------------------------------------------- SUBROUTINE PrepTileDrainHydOutFile(TimeStep,NodeIDs,SubIrigIDs,DrainIDs,SubIrigNodes,DrainNodes,cOutFileName,TDHyd,iStat) TYPE(TimeStepType),INTENT(IN) :: TimeStep INTEGER,INTENT(IN) :: NodeIDs(:),SubIrigIDs(:),DrainIDs(:),SubIrigNodes(:),DrainNodes(:) CHARACTER(LEN=*),INTENT(IN) :: cOutFileName TYPE(TileDrainHydrographType) :: TDHyd INTEGER,INTENT(OUT) :: iStat !Local variables CHARACTER :: Text*20,FormatSpec*500,DataUnit(1)*10,DataType(1)*10, & CPart(1)*32,FPart(TDHyd%NHyd)*32,Header(3,1+TDHyd%NHyd)*50, & HeaderFormat(3)*500,WorkArray(4)*3000,TitleLines(1)*3000 INTEGER :: NColumnsOfData,NRowsOfData,indx,IOUTTD(TDHyd%NHyd) LOGICAL :: OverwriteNColumnsOfData,PrintColumnNo !Initialize iStat = 0 !Open file CALL TDHyd%OutFile%New(FileName=cOutFileName,InputFile=.FALSE.,IsTSFile=.TRUE.,Descriptor='tile drain and subsurface irrigation hydrographs output file',iStat=iStat) IF (iStat .EQ. -1) RETURN !Prepare output file Text = IntToText(TDHyd%NHyd) NColumnsOfData = TDHyd%NHyd NRowsOfData = 1 OverwriteNColumnsOfData = .TRUE. PrintColumnNo = .FALSE. FormatSpec = '(A21,'//TRIM(Text)//'(2X,F10.2))' DataUnit(1) = ADJUSTL(TDHyd%UnitFlow) DataType(1) = 'PER-CUM' CPart(1) = ADJUSTL('FLOW') DO indx=1,TDHyd%NHyd IF (TDHyd%iHydTypes(indx) .EQ. f_iTileDrain) THEN FPart(indx) = 'TILE_DRAIN_HYDROGRAPH' ELSE FPart(indx) = 'SUBSURFACE_IRIG_HYDROGRAPH' END IF END DO !Prepare header lines WorkArray(1)=ArrangeText('TILE DRAIN/SUBSURFACE IRRIGATION HYDROGRAPH',47) WorkArray(2)=ArrangeText('(UNIT=',TDHyd%UnitFlow,')',47) WorkArray(3)=ArrangeText('[(+): SUBSURFACE IRRIGATION INFLOW]',47) WorkArray(4)=ArrangeText('[(-): TILE DRAIN OUTFLOW ]',47) CALL PrepareTitle(TitleLines(1),WorkArray(1:4),49,42) Header = '' WRITE (Header(1,1),'(A1,5X,A13)') '*','HYDROGRAPH ID' WRITE (Header(2,1),'(A1,14X,A4)') '*','NODE' WRITE (Header(3,1),'(A1,8X,A4)') '*','TIME' DO indx=1,TDHyd%NHyd IF (TDHyd%iHydTypes(indx) .EQ. f_iSubIrig) THEN WRITE (Header(1,indx+1),'(I10)') SubIrigIDs(TDHyd%iHydIndices(indx)) WRITE (Header(2,indx+1),'(I10)') NodeIDs(SubIrigNodes(TDHyd%iHydIndices(indx))) IOUTTD(indx) = NodeIDs(SubIrigNodes(TDHyd%iHydIndices(indx))) ELSE WRITE (Header(1,indx+1),'(I10)') DrainIDs(TDHyd%iHydIndices(indx)) WRITE (Header(2,indx+1),'(I10)') NodeIDs(DrainNodes(TDHyd%iHydIndices(indx))) IOUTTD(indx) = NodeIDs(DrainNodes(TDHyd%iHydIndices(indx))) END IF END DO HeaderFormat(1) = '(A19,2X,'//TRIM(Text)//'(2X,A10))' HeaderFormat(2) = '(A19,2X,'//TRIM(Text)//'(2X,A10))' HeaderFormat(3) = '(A13,'//TRIM(Text)//'(A))' !Prepare the time series output file CALL PrepareTSDOutputFile(TDHyd%OutFile , & NColumnsOfData , & NRowsOfData , & OverwriteNColumnsOfData , & FormatSpec , & TitleLines , & Header , & HeaderFormat , & PrintColumnNo , & DataUnit , & DataType , & CPart , & FPart , & TimeStep%Unit , & GWNodes=IOUTTD , & iStat=iStat ) IF (iStat .EQ. -1) RETURN !Set the flag TDHyd%OutFile_Defined = .TRUE. END SUBROUTINE PrepTileDrainHydOutFile ! ------------------------------------------------------------- ! --- NEW FILE FOR TILE DRAIN HYDROGRAPHS OPENED FOR INPUT FOR POST-PROCESSING ! ------------------------------------------------------------- SUBROUTINE PrepTileDrainHydInFile_ForInquiry(TimeStep,NodeIDs,SubIrigNodes,DrainNodes,cFileName,TDHyd,iStat) TYPE(TimeStepType),INTENT(IN) :: TimeStep INTEGER,INTENT(IN) :: NodeIDs(:),SubIrigNodes(:),DrainNodes(:) CHARACTER(LEN=*),INTENT(IN) :: cFileName TYPE(TileDrainHydrographType) :: TDHyd INTEGER,INTENT(OUT) :: iStat !Local variables INTEGER :: indx CHARACTER :: cPathNames(TDHyd%NHyd)*80 CHARACTER(LEN=32) :: BPart,EPart,FPart !Initialize iStat = 0 !Instantiate file according to its type IF (iGetFileType_FromName(cFileName) .EQ. DSS) THEN EPart = TimeStep%Unit !Form pathnames DO indx=1,TDHyd%NHyd IF (TDHyd%iHydTypes(indx) .EQ. f_iTileDrain) THEN BPart = 'GW' // TRIM(IntToText(NodeIDS(DrainNodes(TDHyd%iHydIndices(indx))))) FPart = 'TILE_DRAIN_HYDROGRAPH' ELSE BPart = 'GW' // TRIM(IntToText(NodeIDs(SubIrigNodes(TDHyd%iHydIndices(indx))))) FPart = 'SUBSURFACE_IRIG_HYDROGRAPH' END IF cPathnames(indx) = '/IWFM/' // TRIM(BPart) // '/FLOW//' // TRIM(EPart) // '/' //TRIM(FPart) // '/' END DO CALL TDHyd%InFile_ForInquiry%Init(cFileName,'tile drain and subsurface irrigation hydrographs file',TimeStep%TrackTime,nCol=TDHyd%NHyd,cPathNames=cPathNames,iStat=iStat) IF (iStat .EQ. -1) RETURN ELSE CALL TDHyd%InFile_ForInquiry%Init(cFileName,'tile drain and subsurface irrigation hydrographs file',BlocksToSkip=0,nCol=TDHyd%NHyd,iStat=iStat) IF (iStat .EQ. -1) RETURN END IF !Set the flag TDHyd%InFile_ForInquiry_Defined = .TRUE. END SUBROUTINE PrepTileDrainHydInFile_ForInquiry ! ------------------------------------------------------------- ! --- TRANSFER HYDROGRAPHS FROM TEXT/DSS FILE TO HDF FILE ! ------------------------------------------------------------- SUBROUTINE Transfer_To_HDF(TDHyd,NTIME,TimeStep,iStat) CLASS(TileDrainHydrographType) :: TDHyd INTEGER,INTENT(IN) :: NTIME TYPE(TimeStepType),INTENT(IN) :: TimeStep INTEGER,INTENT(OUT) :: iStat !Local variables INTEGER :: NColumns(1),FileReadCode,indxTime REAL(8) :: rGWHeads(TDHyd%NHyd,1),rConvFactor CHARACTER :: cDataSetName(1)*50,cHDFFileName*500 TYPE(GenericFileType) :: OutFile CHARACTER(:),ALLOCATABLE :: cFileName TYPE(TimeStepType) :: TimeStep_Local !Initialize iStat = 0 !Return if no output IF (.NOT. TDHyd%InFile_ForInquiry_Defined) RETURN !Get the name of the text/DSS file CALL TDHyd%InFile_ForInquiry%GetFileName(cFileName) !Name for the HDF file cHDFFileName = TRIM(ADJUSTL(StripTextUntilCharacter(cFileName,'.',Back=.TRUE.))) // '.hdf' !Open output file HDF file CALL OutFile%New(FileName=TRIM(cHDFFileName),InputFile=.FALSE.,IsTSFile=.TRUE.,iStat=iStat) IF (iStat .EQ. -1) RETURN !Create dataset NColumns(1) = TDHyd%NHyd cDataSetName(1) = '/Tile_Drain_Hydrographs' CALL OutFile%CreateHDFDataSet(cPathNames=cDataSetName,NColumns=NColumns,NTime=NTIME,TimeStep=TimeStep,DataType=0d0,iStat=iStat) IF (iStat .EQ. -1) RETURN !Conversion factor used when printing out results rConvFactor = 1.0 / TDHyd%FactFlow !Transfer heads to HDF file TimeStep_Local = TimeStep DO indxTime=1,NTIME !Read data CALL ReadTSData(TimeStep_Local,'tile drain hydrographs',TDHyd%InFile_ForInquiry,FileReadCode,iStat) IF (iStat .EQ. -1) RETURN !Transfer values to matrix to be written to HDF file rGWHeads(:,1) = TDHyd%InFile_ForInquiry%rValues !Convert unit back to simulation units IF (TDHyd%FactFlow .NE. 1.0) rGWHeads = rGWHeads * rConvFactor !Store heads into HDF file CALL OutFile%WriteData(rGWHeads) !Advance time TimeStep_Local%CurrentTimeStep = TimeStep_Local%CurrentTimeStep + 1 TimeStep_Local%CurrentDateAndTime = IncrementTimeStamp(TimeStep_Local%CurrentDateAndTime,TimeStep_Local%DELTAT_InMinutes) END DO !Rewind input file CALL TDHyd%InFile_ForInquiry%File%RewindFile_To_BeginningOfTSData(iStat) !Close HDF file CALL OutFile%Kill() END SUBROUTINE Transfer_To_HDF END MODULE