Datasets:
AI4M
/

text
stringlengths
0
3.34M
""" AccelDesang An action type with a longitudinal acceleration and a desired heading angle # Fields - `a::Float64` longitudinal acceleration [m/s^2] - `Ο•des::Float64` desired heading angle """ struct AccelDesang a::Float64 # accel [m/sΒ²] Ο•des::Float64 # Desired heading angle end Base.show(io::IO, a::AccelDesang) = @printf(io, "AccelDesang(%6.3f,%6.3f)", a.a, a.Ο•des) Base.length(::Type{AccelDesang}) = 2 """ Base.convert(::Type{AccelDesang}, v::Vector{Float64}) Convert a vector containing the acceleration and desired heading angle into AccelDesang type """ Base.convert(::Type{AccelDesang}, v::Vector{Float64}) = AccelDesang(v[1], v[2]) """ Base.copyto!(v::Vector{Float64}, a::AccelDesang) Extract the AccelDesang components into a vector and return the vector """ function Base.copyto!(v::Vector{Float64}, a::AccelDesang) v[1] = a.a v[2] = a.Ο•des v end """ propagate(veh::Entity{VehicleState,D,I}, action::AccelDesang, roadway::Roadway, Ξ”t::Float64; n_integration_steps::Int=4) where {D,I} Propagate vehicle forward in time using a desired acceleration and heading angle """ function propagate(veh::Entity{VehicleState,D,I}, action::AccelDesang, roadway::Roadway, Ξ”t::Float64; n_integration_steps::Int=4) where {D,I} a = action.a # accel Ο•des = action.Ο•des # desired heading angle x = veh.state.posG.x y = veh.state.posG.y ΞΈ = veh.state.posG.ΞΈ v = veh.state.v Ξ΄t = Ξ”t/n_integration_steps for i in 1 : n_integration_steps posF = Frenet(VecSE2(x, y, ΞΈ), roadway) Ο‰ = Ο•des - posF.Ο• x += v*cos(ΞΈ)*Ξ΄t y += v*sin(ΞΈ)*Ξ΄t ΞΈ += Ο‰*Ξ΄t v += a*Ξ΄t end posG = VecSE2(x, y, ΞΈ) VehicleState(posG, roadway, v) end
[STATEMENT] lemma affine_hull_insert_subset_span: "affine hull (insert a S) \<subseteq> {a + v| v . v \<in> span {x - a | x . x \<in> S}}" [PROOF STATE] proof (prove) goal (1 subgoal): 1. affine hull insert a S \<subseteq> {a + v |v. v \<in> span {x - a |x. x \<in> S}} [PROOF STEP] proof - [PROOF STATE] proof (state) goal (1 subgoal): 1. affine hull insert a S \<subseteq> {a + v |v. v \<in> span {x - a |x. x \<in> S}} [PROOF STEP] have "\<exists>v T u. x = a + v \<and> (finite T \<and> T \<subseteq> {x - a |x. x \<in> S} \<and> (\<Sum>v\<in>T. u v *\<^sub>R v) = v)" if "finite F" "F \<noteq> {}" "F \<subseteq> insert a S" "sum u F = 1" "(\<Sum>v\<in>F. u v *\<^sub>R v) = x" for x F u [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<exists>v T u. x = a + v \<and> finite T \<and> T \<subseteq> {x - a |x. x \<in> S} \<and> (\<Sum>v\<in>T. u v *\<^sub>R v) = v [PROOF STEP] proof - [PROOF STATE] proof (state) goal (1 subgoal): 1. \<exists>v T u. x = a + v \<and> finite T \<and> T \<subseteq> {x - a |x. x \<in> S} \<and> (\<Sum>v\<in>T. u v *\<^sub>R v) = v [PROOF STEP] have *: "(\<lambda>x. x - a) ` (F - {a}) \<subseteq> {x - a |x. x \<in> S}" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<lambda>x. x - a) ` (F - {a}) \<subseteq> {x - a |x. x \<in> S} [PROOF STEP] using that [PROOF STATE] proof (prove) using this: finite F F \<noteq> {} F \<subseteq> insert a S sum u F = 1 (\<Sum>v\<in>F. u v *\<^sub>R v) = x goal (1 subgoal): 1. (\<lambda>x. x - a) ` (F - {a}) \<subseteq> {x - a |x. x \<in> S} [PROOF STEP] by auto [PROOF STATE] proof (state) this: (\<lambda>x. x - a) ` (F - {a}) \<subseteq> {x - a |x. x \<in> S} goal (1 subgoal): 1. \<exists>v T u. x = a + v \<and> finite T \<and> T \<subseteq> {x - a |x. x \<in> S} \<and> (\<Sum>v\<in>T. u v *\<^sub>R v) = v [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<exists>v T u. x = a + v \<and> finite T \<and> T \<subseteq> {x - a |x. x \<in> S} \<and> (\<Sum>v\<in>T. u v *\<^sub>R v) = v [PROOF STEP] proof (intro exI conjI) [PROOF STATE] proof (state) goal (4 subgoals): 1. x = a + ?v 2. finite ?T1 3. ?T1 \<subseteq> {x - a |x. x \<in> S} 4. (\<Sum>v\<in>?T1. ?u2 v *\<^sub>R v) = ?v [PROOF STEP] show "finite ((\<lambda>x. x - a) ` (F - {a}))" [PROOF STATE] proof (prove) goal (1 subgoal): 1. finite ((\<lambda>x. x - a) ` (F - {a})) [PROOF STEP] by (simp add: that(1)) [PROOF STATE] proof (state) this: finite ((\<lambda>x. x - a) ` (F - {a})) goal (3 subgoals): 1. x = a + ?v 2. (\<lambda>x. x - a) ` (F - {a}) \<subseteq> {x - a |x. x \<in> S} 3. (\<Sum>v\<in>(\<lambda>x. x - a) ` (F - {a}). ?u2 v *\<^sub>R v) = ?v [PROOF STEP] show "(\<Sum>v\<in>(\<lambda>x. x - a) ` (F - {a}). u(v+a) *\<^sub>R v) = x-a" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<Sum>v\<in>(\<lambda>x. x - a) ` (F - {a}). u (v + a) *\<^sub>R v) = x - a [PROOF STEP] by (simp add: sum.reindex[unfolded inj_on_def] algebra_simps sum_subtractf scaleR_left.sum[symmetric] sum_diff1 that) [PROOF STATE] proof (state) this: (\<Sum>v\<in>(\<lambda>x. x - a) ` (F - {a}). u (v + a) *\<^sub>R v) = x - a goal (2 subgoals): 1. x = a + (x - a) 2. (\<lambda>x. x - a) ` (F - {a}) \<subseteq> {x - a |x. x \<in> S} [PROOF STEP] qed (use \<open>F \<subseteq> insert a S\<close> in auto) [PROOF STATE] proof (state) this: \<exists>v T u. x = a + v \<and> finite T \<and> T \<subseteq> {x - a |x. x \<in> S} \<and> (\<Sum>v\<in>T. u v *\<^sub>R v) = v goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<lbrakk>finite ?F; ?F \<noteq> {}; ?F \<subseteq> insert a S; sum ?u ?F = 1; (\<Sum>v\<in>?F. ?u v *\<^sub>R v) = ?x\<rbrakk> \<Longrightarrow> \<exists>v T u. ?x = a + v \<and> finite T \<and> T \<subseteq> {x - a |x. x \<in> S} \<and> (\<Sum>v\<in>T. u v *\<^sub>R v) = v goal (1 subgoal): 1. affine hull insert a S \<subseteq> {a + v |v. v \<in> span {x - a |x. x \<in> S}} [PROOF STEP] then [PROOF STATE] proof (chain) picking this: \<lbrakk>finite ?F; ?F \<noteq> {}; ?F \<subseteq> insert a S; sum ?u ?F = 1; (\<Sum>v\<in>?F. ?u v *\<^sub>R v) = ?x\<rbrakk> \<Longrightarrow> \<exists>v T u. ?x = a + v \<and> finite T \<and> T \<subseteq> {x - a |x. x \<in> S} \<and> (\<Sum>v\<in>T. u v *\<^sub>R v) = v [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) using this: \<lbrakk>finite ?F; ?F \<noteq> {}; ?F \<subseteq> insert a S; sum ?u ?F = 1; (\<Sum>v\<in>?F. ?u v *\<^sub>R v) = ?x\<rbrakk> \<Longrightarrow> \<exists>v T u. ?x = a + v \<and> finite T \<and> T \<subseteq> {x - a |x. x \<in> S} \<and> (\<Sum>v\<in>T. u v *\<^sub>R v) = v goal (1 subgoal): 1. affine hull insert a S \<subseteq> {a + v |v. v \<in> span {x - a |x. x \<in> S}} [PROOF STEP] unfolding affine_hull_explicit span_explicit [PROOF STATE] proof (prove) using this: \<lbrakk>finite ?F; ?F \<noteq> {}; ?F \<subseteq> insert a S; sum ?u ?F = 1; (\<Sum>v\<in>?F. ?u v *\<^sub>R v) = ?x\<rbrakk> \<Longrightarrow> \<exists>v T u. ?x = a + v \<and> finite T \<and> T \<subseteq> {x - a |x. x \<in> S} \<and> (\<Sum>v\<in>T. u v *\<^sub>R v) = v goal (1 subgoal): 1. {y. \<exists>Sa u. finite Sa \<and> Sa \<noteq> {} \<and> Sa \<subseteq> insert a S \<and> sum u Sa = 1 \<and> (\<Sum>v\<in>Sa. u v *\<^sub>R v) = y} \<subseteq> {a + v |v. v \<in> {\<Sum>a\<in>t. r a *\<^sub>R a |t r. finite t \<and> t \<subseteq> {x - a |x. x \<in> S}}} [PROOF STEP] by fast [PROOF STATE] proof (state) this: affine hull insert a S \<subseteq> {a + v |v. v \<in> span {x - a |x. x \<in> S}} goal: No subgoals! [PROOF STEP] qed
Require Import ssreflect. From Coq.Relations Require Import Relations Relation_Operators. Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. (* A stupid property of the transitive closure. *) (* We have two sub-relations A and B of V, which we now is a strict partial order: then we want to show that if V is a strict partial order, then thw tranisitive closure of A union B cannot have cycles *) (* e.g. A is PO, B is RF, AUBT is CO/HB and V = is visibility *) Section RelFacts. Variable X : Type. Variables (A B V: relation X). Definition irreflexive (f : relation X) := forall x, f x x -> False. Hypothesis AinV: inclusion X A V. Hypothesis BinV: inclusion X B V. Hypothesis transV: transitive X V. Hypothesis irrV: irreflexive V. Hypothesis transA: transitive X A. Hypothesis irrA: irreflexive A. Definition AUBT : relation X := clos_trans _ (union _ A B). (* Transitive + IRR => Anti *) Lemma antiV: antisymmetric _ V. Proof. move=>x y /transV H1 /H1 /irrV //. Qed. Lemma AUBTinV : inclusion _ AUBT V. Proof. move=> x y /= H; elim:H=>{x y}x0 y0; first by case; [move/AinV|move/BinV]. by move=>z _ /transV H1 _ /H1. Qed. (* AUBT cannot have cycles, because V does not have them *) Lemma irrAUBT : irreflexive AUBT. Proof. by move=>x /= /AUBTinV /irrV. Qed. (* AUBT trans: this should be trivial *) Lemma transAUBT : transitive _ AUBT. Proof. by exact:t_trans. Qed. (* AUBT anti: this is trivial as it is irreflexive and transitive*) Lemma antiAUBT : antisymmetric _ AUBT. Proof. move=>x y /transAUBT H2 /H2 /irrAUBT //. Qed. Definition close {X} (r:relation X) (o:X) := fun x y => r x o /\ r y o /\ r x y. End RelFacts.
! ! This files tests halting failure in FrontEnd where ! the FrontEnd repeatedly prints "Parser exiting normally" ! without halting. ! include "bug-3053141_inc.f90"
theory prop_60 imports Main "$HIPSTER_HOME/IsaHipster" begin datatype 'a list = Nil2 | Cons2 "'a" "'a list" datatype Nat = Z | S "Nat" fun null2 :: "Nat list => bool" where "null2 (Nil2) = True" | "null2 (Cons2 y z) = False" fun last :: "Nat list => Nat" where "last (Nil2) = Z" | "last (Cons2 y (Nil2)) = y" | "last (Cons2 y (Cons2 x2 x3)) = last (Cons2 x2 x3)" fun append :: "Nat list => Nat list => Nat list" where "append (Nil2) y = y" | "append (Cons2 z xs) y = Cons2 z (append xs y)" (*hipster null last append *) (*hipster last null2 append*)(* lemma lemma_a []: "append x2 Nil2 = x2" by (hipster_induct_schemes last.simps null2.simps append.simps) lemma lemma_aa []: "append (append x2 y2) z2 = append x2 (append y2 z2)" by (hipster_induct_schemes last.simps null2.simps append.simps) lemma lemma_ab []: "null2 (append x2 x2) = null2 x2" by (hipster_induct_schemes last.simps null2.simps append.simps) (*hipster null2 append*) lemma unknown []: "null2 (append x y) = null2 (append y x)" by (hipster_induct_schemes last.simps null2.simps append.simps list.exhaust) (*hipster_cond null2 append*) lemma lemma_ac []: "null2 x2 \<Longrightarrow> append x2 y2 = y2" by (hipster_induct_schemes null2.simps append.simps)*) theorem x0 : "(~ (null2 ys)) ==> ((last (append xs ys)) = (last ys))" by (hipster_induct_schemes last.simps null2.simps append.simps list.exhaust) (* by (tactic {* Subgoal.FOCUS_PARAMS (K (Tactic_Data.hard_tac @{context})) @{context} 1 *})*) end
/** * @file * $Revision: 6513 $ * $Date: 2016-01-14 16:04:44 -0700 (Thu, 14 Jan 2016) $ * $Id: CalculatorStrategy.cpp 6513 2016-01-14 23:04:44Z [email protected] $ * * Unless noted otherwise, the portions of Isis written by the USGS are * public domain. See individual third-party library and package descriptions * for intellectual property information, user agreements, and related * information. * * Although Isis has been used by the USGS, no warranty, expressed or * implied, is made by the USGS as to the accuracy and functioning of such * software and related material nor shall the fact of distribution * constitute any such warranty, and no responsibility is assumed by the * USGS in connection therewith. * * For additional information, launch * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html * in a browser or see the Privacy &amp; Disclaimers page on the Isis website, * http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on * http://www.usgs.gov/privacy.html. */ #include "CalculatorStrategy.h" // boost library #include <boost/foreach.hpp> // other ISIS #include "IException.h" #include "InlineCalculator.h" #include "PvlFlatMap.h" #include "PvlObject.h" #include "Resource.h" #include "SpecialPixel.h" using namespace std; namespace Isis { /** * Default constructor. */ CalculatorStrategy::CalculatorStrategy() : Strategy("Calculator", "Calculator"), m_equations(), m_initializers(0), m_initArgs(), m_calculator(0), m_result(0.0) { } /** * @brief Constructor loads from a Strategy object CalculatorStrategy * definition * * This constructor loads and retains processing parameters form the * Calculator Strategy object definition as (typically) read form the * configuration file. * * @param definitnion Calculator Strategy PVL definition * @param globals Global Resource of keywords */ CalculatorStrategy::CalculatorStrategy(const PvlObject &definition, const ResourceList &globals) : Strategy(definition, globals), m_equations(), m_initializers(0), m_initArgs(), m_calculator(0), m_result(0.0) { if ( getDefinition().hasGroup("Initializers") ) { const PvlObject &keydefs = getDefinition(); PvlFlatMap *vars = new PvlFlatMap(keydefs.findGroup("Initializers")); m_initializers = QSharedPointer<PvlFlatMap> (vars); // Get initializer argument keyword replacement values if ( keydefs.hasKeyword("InitializersArgs") ) { PvlFlatMap args; args.add(keydefs["InitializersArgs"]); m_initArgs = args.allValues("InitializersArgs"); } } PvlFlatMap parms( getDefinitionMap() ); if ( parms.exists("Equation") ) { Equation eqn; eqn.equation = parms.get("Equation"); InlineCalculator *calc = new InlineCalculator(eqn.equation); eqn.calculator = QSharedPointer<InlineCalculator> (calc); if ( parms.exists("Result") ) { eqn.store = parms.get("Result"); } m_equations.append(eqn); } if ( definition.hasGroup("Equations") ) { PvlGroup eqns = getDefinition().findGroup("Equations"); PvlGroup::PvlKeywordIterator i; for (i = eqns.begin(); i != eqns.end(); i++) { Equation eqn; eqn.equation = QString(*i); InlineCalculator *calc = new InlineCalculator(eqn.equation); eqn.calculator = QSharedPointer<InlineCalculator> (calc); eqn.store = i->name(); m_equations.append(eqn); } } return; } /** * Destructor */ CalculatorStrategy::~CalculatorStrategy() { } /** * @brief Calculates the result for a resoruce and stores it in the resource * * Calculates the result of the calculation for a resource and stores it in * the specified key in the resource. If there is an error in the calculation, * such as if the value of a variable is invalid, then the resource is * discarded. * * @param resource SharedResource to be written to * @param globals Global Resource of keywords * * @return int The number of keys written to the resource */ int CalculatorStrategy::apply(SharedResource &resource, const ResourceList &globals) { int nInits = initialize(resource, globals); ResourceList variables = getGlobals(resource, globals); int ntotal = 0; BOOST_FOREACH ( Equation eqn, m_equations) { try { m_calculator = eqn.calculator; m_result = calculate(variables); if ( !eqn.store.isEmpty() ) { resource->add(eqn.store, QString::number(m_result)); } ntotal++; } // Discard on error catch (IException &ie) { if ( isDebug() ) { cout << "Calculator error on " << resource->name() << " with equation " << eqn.equation << ": " << ie.what() << "\n"; } m_result = Null; resource->discard(); ntotal = 0; break; } } // Check for initialization only and return success if ( (0 == m_equations.size()) && (nInits > 0) ) { return (1); } return ((ntotal == 0) ? 0 : 1); } /** * Returns the result of the calculation. * * @return double The result of the calculation */ double CalculatorStrategy::result() const { return (m_result); } /** * @brief Initializes a Resource. * * Initializes a resource based on the keys in the list of initializers. * Each key in the list of initializers is added to the resource. Returns the * number of keys added. * * @param resource SharedResource to be initialized * * @return int The number of keys added to the resource */ int CalculatorStrategy::initialize(SharedResource &resource, const ResourceList &globals) { int ntotal(0); if ( !m_initializers.isNull() ) { ResourceList myGlobals = getGlobals(resource, globals); BOOST_FOREACH ( PvlKeyword key, *m_initializers) { PvlKeyword newkey(key.name()); for (int i = 0 ; i < key.size() ; i++) { QString value = processArgs(key[i], m_initArgs, myGlobals); newkey.addValue(value); if ( isDebug() ) { cout << "Initializing " << key.name() << "[" << i << "] = " << value << "\n"; } } resource->add(newkey); ntotal++; } } return (ntotal); } /** * Calculates the result of the equation for a resource and returns the * result. * * @param resource SharedResource to be used for the calculation. * * @return double The result of the calculation. */ double CalculatorStrategy::calculate(SharedResource &resource) { ResourceCalculatorVariablePool vars(resource); QVector<double> values = m_calculator->evaluate(&vars); return (values[0]); } /** * Calculates the result of the equation for a list of resource and returns * the result. * * @param resources List of Resources to be used for the calculation. * * @return double The result of the calculation. */ double CalculatorStrategy::calculate(ResourceList &resources) { ResourceCalculatorVariablePool vars(resources); QVector<double> values = m_calculator->evaluate(&vars); return (values[0]); } /** * @brief Initializes a PvlFlatMap. * * Initializes a PvlFlatMap based on the keys in the list of initializers. * Each key in the list of initializers is added to the PvlFlatMap. Returns * the number of keys added. * * @param pvl PvlFlatMap to be initialized * * @return int The number of keys added to the PvlFlatMap */ int CalculatorStrategy::initialize(PvlFlatMap &pvl) { int ntotal(0); if ( !m_initializers.isNull() ) { BOOST_FOREACH ( PvlKeyword key, *m_initializers) { pvl.add(key); ntotal++; } } return (ntotal); } /** * Calculates the result of the equation for a PvlFlatMap and returns the * result. * * @param pvl PvlFlatMap to be used for the calculation. * * @return double The result of the calculation. */ double CalculatorStrategy::calculate(PvlFlatMap &pvl) { PvlFlatMapCalculatorVariablePool vars(pvl); QVector<double> values = m_calculator->evaluate(&vars); return (values[0]); } /** * Construct ResourceCalculatorVariablePool with a SharedResource. * * @param resource SharedResource of the resource */ ResourceCalculatorVariablePool::ResourceCalculatorVariablePool( SharedResource &resource) { m_resources.push_back(resource); } /** * Construct ResourceCalculatorVariablePool with a SharedResource. * * @param resource SharedResource of the resource */ ResourceCalculatorVariablePool::ResourceCalculatorVariablePool( ResourceList &resources) { m_resources.append(resources); } /** * Destruct ResourceCalculatorVariablePool. */ ResourceCalculatorVariablePool::~ResourceCalculatorVariablePool() { } /** * Check existance of variable. * * @param variable QString of the variable. */ bool ResourceCalculatorVariablePool::exists(const QString &variable) const { BOOST_FOREACH ( SharedResource resource, m_resources ) { if ( resource->exists(variable) ) { return (true); } } return (false); } /** * Returns a vector associated to a variable request from the * calculator. * * @param variable QString of the variable * * @param index int of the index */ QVector<double> ResourceCalculatorVariablePool::value(const QString &variable, const int &index) const { QVector<double> vars; BOOST_FOREACH ( SharedResource resource, m_resources ) { if ( resource->exists(variable) ) { vars.push_back(toDouble(resource->value(variable, index))); break; } } return (vars); } /** * Construct PvlFlatMapCalculatorVariablePool with a PvlFlatMap. * * @param pvl PvlFlatMap */ PvlFlatMapCalculatorVariablePool::PvlFlatMapCalculatorVariablePool( PvlFlatMap &pvl) : m_pvl(pvl) { } /** * Destruct PvlFlatMapCalculatorVariablePool. */ PvlFlatMapCalculatorVariablePool::~PvlFlatMapCalculatorVariablePool() { } /** * Check existance of variable. * * @param variable QString of the variable. */ bool PvlFlatMapCalculatorVariablePool::exists(const QString &variable) const { return (m_pvl.exists(variable)); } /** * Returns a vector associated to a variable request from the * calculator. * * @param variable QString of the variable * @param index int of the index */ QVector<double> PvlFlatMapCalculatorVariablePool::value(const QString &variable, const int &index) const { QVector<double> vars; vars.push_back(toDouble(m_pvl.get(variable, index))); return (vars); } } // namespace Isis
# 17 PDEs: Waves (See *Computational Physics* Ch 21 and *Computational Modeling* Ch 6.5.) ## Background: waves on a string Assume a 1D string of length $L$ with mass density per unit length $\rho$ along the $x$ direction. It is held under constant tension $T$ (force per unit length). Ignore frictional forces and the tension is so high that we can ignore sagging due to gravity. ### 1D wave equation The string is displaced in the $y$ direction from its rest position, i.e., the displacement $y(x, t)$ is a function of space $x$ and time $t$. For small relative displacements $y(x, t)/L \ll 1$ and therefore small slopes $\partial y/\partial x$ we can describe $y(x, t)$ with a *linear* equation of motion: Newton's second law applied to short elements of the string with length $\Delta x$ and mass $\Delta m = \rho \Delta x$: the left hand side contains the *restoring force* that opposes the displacement, the right hand side is the acceleration of the string element: \begin{align} \sum F_{y}(x) &= \Delta m\, a(x, t)\\ T \sin\theta(x+\Delta x) - T \sin\theta(x) &= \rho \Delta x \frac{\partial^2 y(x, t)}{\partial t^2} \end{align} The angle $\theta$ measures by how much the string is bent away from the resting configuration. Because we assume small relative displacements, the angles are small ($\theta \ll 1$) and we can make the small angle approximation $$ \sin\theta \approx \tan\theta = \frac{\partial y}{\partial x} $$ and hence \begin{align} T \left.\frac{\partial y}{\partial x}\right|_{x+\Delta x} - T \left.\frac{\partial y}{\partial x}\right|_{x} &= \rho \Delta x \frac{\partial^2 y(x, t)}{\partial t^2}\\ \frac{T \left.\frac{\partial y}{\partial x}\right|_{x+\Delta x} - T \left.\frac{\partial y}{\partial x}\right|_{x}}{\Delta x} &= \rho \frac{\partial^2 y}{\partial t^2} \end{align} or in the limit $\Delta x \rightarrow 0$ a linear hyperbolic PDE results: \begin{gather} \frac{\partial^2 y(x, t)}{\partial x^2} = \frac{1}{c^2} \frac{\partial^2 y(x, t)}{\partial t^2}, \quad c = \sqrt{\frac{T}{\rho}} \end{gather} where $c$ has the dimension of a velocity. This is the (linear) **wave equation**. ### General solution: waves General solutions are propagating waves: If $f(x)$ is a solution at $t=0$ then $$ y_{\mp}(x, t) = f(x \mp ct) $$ are also solutions at later $t > 0$. Because of linearity, any linear combination is also a solution, so the most general solution contains both right and left propagating waves $$ y(x, t) = A f(x - ct) + B g(x + ct) $$ (If $f$ and/or $g$ are present depends on the initial conditions.) In three dimensions the wave equation is $$ \boldsymbol{\nabla}^2 y(\mathbf{x}, t) - \frac{1}{c^2} \frac{\partial^2 y(\mathbf{x}, t)}{\partial t^2} = 0\ $$ ### Boundary and initial conditions * The boundary conditions could be that the ends are fixed $$y(0, t) = y(L, t) = 0$$ * The *initial condition* is a shape for the string, e.g., a Gaussian at the center $$ y(x, t=0) = g(x) = y_0 \frac{1}{\sqrt{2\pi\sigma}} \exp\left[-\frac{(x - x_0)^2}{2\sigma^2}\right] $$ at time 0. * Because the wave equation is *second order in time* we need a second initial condition, for instance, the string is released from rest: $$ \frac{\partial y(x, t=0)}{\partial t} = 0 $$ (The derivative, i.e., the initial displacement velocity is provided.) ### Analytical solution Solve (as always) with *separation of variables*. $$ y(x, t) = X(x) T(t) $$ and this yields the general solution (with boundary conditions of fixed string ends and initial condition of zero velocity) as a superposition of normal modes $$ y(x, t) = \sum_{n=0}^{+\infty} B_n \sin k_n x\, \cos\omega_n t, \quad \omega_n = ck_n,\ k_n = n \frac{2\pi}{L} = n k_0. $$ (The angular frequency $\omega$ and the wave vector $k$ are determined from the boundary conditions.) The coefficients $B_n$ are obtained from the initial shape: $$ y(x, t=0) = \sum_{n=0}^{+\infty} B_n \sin n k_0 x = g(x) $$ In principle one can use the fact that $\int_0^L dx \sin m k_0 x \, \sin n k_0 x = \pi \delta_{mn}$ (orthogonality) to calculate the coefficients: \begin{align} \int_0^L dx \sin m k_0 x \sum_{n=0}^{+\infty} B_n \sin n k_0 x &= \int_0^L dx \sin(m k_0 x) \, g(x)\\ \pi \sum_{n=0}^{+\infty} B_n \delta_{mn} &= \dots \\ B_m &= \pi^{-1} \dots \end{align} (but the analytical solution is ugly and I cannot be bothered to put it down here.) ## Numerical solution 1. discretize wave equation 2. time stepping: leap frog algorithm (iterate) Use the central difference approximation for the second order derivatives: \begin{align} \frac{\partial^2 y}{\partial t^2} &\approx \frac{y(x, t+\Delta t) + y(x, t-\Delta t) - 2y(x, t)}{\Delta t ^2} = \frac{y_{i, j+1} + y_{i, j-1} - 2y_{i,j}}{\Delta t^2}\\ \frac{\partial^2 y}{\partial x^2} &\approx \frac{y(x+\Delta x, t) + y(x-\Delta x, t) - 2y(x, t)}{\Delta x ^2} = \frac{y_{i+1, j} + y_{i-1, j} - 2y_{i,j}}{\Delta x^2} \end{align} and substitute into the wave equation to yield the *discretized* wave equation: $$ \frac{y_{i+1, j} + y_{i-1, j} - 2y_{i,j}}{\Delta x^2} = \frac{1}{c^2} \frac{y_{i, j+1} + y_{i, j-1} - 2y_{i,j}}{\Delta t^2} $$ Re-arrange so that the future terms $j+1$ can be calculated from the present $j$ and past $j-1$ terms: $$ y_{i,j+1} = 2(1 - \beta^2)y_{i,j} - y_{i, j-1} + \beta^2 (y_{i+1,j} + y_{i-1,j}), \quad \beta := \frac{c}{\Delta x/\Delta t} $$ This is the time stepping algorithm for the wave equation. ## Numerical implementation ```python import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D plt.style.use('ggplot') ``` ### Student version ```python L = 0.5 # m Nx = 50 Nt = 100 Dx = L/Nx Dt = 1e-4 # s rho = 1.5e-2 # kg/m tension = 150 # N c = np.sqrt(tension/rho) # TODO: calculate beta beta = c*Dt/Dx beta2 = beta**2 print("c = {0} m/s".format(c)) print("Dx = {0} m, Dt = {1} s, Dx/Dt = {2} m/s".format(Dx, Dt, Dx/Dt)) print("beta = {}".format(beta)) X = np.linspace(0, L, Nx+1) # need N+1! def gaussian(x, y0=0.05, x0=L/2, sigma=0.1*L): return y0/np.sqrt(2*np.pi*sigma) * np.exp(-(x-x0)**2/(2*sigma**2)) # displacements at j-1, j, j+1 y0 = np.zeros_like(X) y1 = np.zeros_like(y0) y2 = np.zeros_like(y0) # save array y_t = np.zeros((Nt+1, Nx+1)) # boundary conditions y0[0] = y0[-1] = y1[0] = y1[-1] = 0 y2[:] = y0 # initial conditions: velocity 0, i.e. no difference between y0 and y1 y0[1:-1] = y1[1:-1] = gaussian(X)[1:-1] # save initial t_index = 0 y_t[t_index, :] = y0 t_index += 1 y_t[t_index, :] = y1 for jt in range(2, Nt): y2[1:-1] = 2*(1-beta2)*y1[1:-1] - y0[1:-1] + beta2*(y1[2:] + y1[:-2]) y0[:], y1[:] = y1, y2 t_index += 1 y_t[t_index, :] = y2 print("Iteration {0:5d}".format(jt), end="\r") else: print("Completed {0:5d} iterations: t={1} s".format(jt, jt*Dt)) ``` c = 100.0 m/s Dx = 0.01 m, Dt = 0.0001 s, Dx/Dt = 100.0 m/s beta = 1.0 Completed 99 iterations: t=0.0099 s ### Fancy version Package as a function and can use `step` to only save every `step` time steps. ```python def wave(L=0.5, Nx=50, Dt=1e-4, Nt=100, step=1, rho=1.5e-2, tension=150.): Dx = L/Nx #rho = 1.5e-2 # kg/m #tension = 150 # N c = np.sqrt(tension/rho) beta = c*Dt/Dx beta2 = beta**2 print("c = {0} m/s".format(c)) print("Dx = {0} m, Dt = {1} s, Dx/Dt = {2} m/s".format(Dx, Dt, Dx/Dt)) print("beta = {}".format(beta)) X = np.linspace(0, L, Nx+1) # need N+1! def gaussian(x, y0=0.05, x0=L/2, sigma=0.1*L): return y0/np.sqrt(2*np.pi*sigma) * np.exp(-(x-x0)**2/(2*sigma**2)) # displacements at j-1, j, j+1 y0 = np.zeros_like(X) y1 = np.zeros_like(y0) y2 = np.zeros_like(y0) # save array y_t = np.zeros((int(np.ceil(Nt/step)) + 1, Nx+1)) # boundary conditions y0[0] = y0[-1] = y1[0] = y1[-1] = 0 y2[:] = y0 # initial conditions: velocity 0, i.e. no difference between y0 and y1 y0[1:-1] = y1[1:-1] = gaussian(X)[1:-1] # save initial t_index = 0 y_t[t_index, :] = y0 if step == 1: t_index += 1 y_t[t_index, :] = y1 for jt in range(2, Nt): y2[1:-1] = 2*(1-beta2)*y1[1:-1] - y0[1:-1] + beta2*(y1[2:] + y1[:-2]) y0[:], y1[:] = y1, y2 if jt % step == 0 or jt == Nt-1: t_index += 1 y_t[t_index, :] = y2 print("Iteration {0:5d}".format(jt), end="\r") else: print("Completed {0:5d} iterations: t={1} s".format(jt, jt*Dt)) return y_t, X, Dx, Dt, step ``` ```python y_t, X, Dx, Dt, step = wave() ``` c = 100.0 m/s Dx = 0.01 m, Dt = 0.0001 s, Dx/Dt = 100.0 m/s beta = 1.0 Completed 99 iterations: t=0.0099 s ### 1D plot Plot the output in the save array `y_t`. Vary the time steps that you look at with `y_t[start:end]`. We indicate time by color changing. ```python ax = plt.subplot(111) ax.set_prop_cycle("color", [plt.cm.viridis(i) for i in np.linspace(0, 1, len(y_t))]) ax.plot(X, y_t[:40].T, alpha=0.5); ``` ### 1D Animation For 1D animation to work in a Jupyter notebook, use ```python %matplotlib widget ``` If no animations are visible, restart kernel and execute the `%matplotlib notebook` cell as the very first one in the notebook. We use `matplotlib.animation` to look at movies of our solution: ```python import matplotlib.animation as animation ``` Generate one full period: ```python y_t, X, Dx, Dt, step = wave(Nt=100) ``` c = 100.0 m/s Dx = 0.01 m, Dt = 0.0001 s, Dx/Dt = 100.0 m/s beta = 1.0 Completed 99 iterations: t=0.0099 s The `update_wave()` function simply re-draws our image for every `frame`. ```python y_limits = 1.05*y_t.min(), 1.05*y_t.max() fig1 = plt.figure(figsize=(5,5)) ax = fig1.add_subplot(111) ax.set_aspect(1) def update_wave(frame, data): global ax, Dt, y_limits ax.clear() ax.set_xlabel("x (m)") ax.set_ylabel("y (m)") ax.plot(X, data[frame]) ax.set_ylim(y_limits) ax.text(0.1, 0.9, "t = {0:3.1f} ms".format(frame*Dt*1e3), transform=ax.transAxes) wave_anim = animation.FuncAnimation(fig1, update_wave, frames=len(y_t), fargs=(y_t,), interval=30, blit=True, repeat_delay=100) ``` Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous … If you have ffmpeg installed then you can export to a MP4 movie file: ```python wave_anim.save("string.mp4", fps=30, dpi=300) ``` The whole video can be incoroporated into an html page (uses the HTML5 `<video>` tag). ```python with open("string.html", "w") as html: html.write(wave_anim.to_html5_video()) ``` ```python ``` ### 3D plot (Uses functions from previous lessons.) ```python def plot_y(y_t, Dt, Dx, step=1): T, X = np.meshgrid(range(y_t.shape[0]), range(y_t.shape[1])) Y = y_t.T[X, T] # intepret index 0 as "t" and index 1 as "x", but plot x along axis 1 and t along axis 2 fig = plt.figure() ax = fig.add_subplot(111, projection="3d") ax.plot_wireframe(X*Dx, T*Dt*step, Y) ax.set_ylabel(r"time $t$ (s)") ax.set_xlabel(r"position $x$ (m)") ax.set_zlabel(r"displacement $y$ (m)") fig.tight_layout() return ax def plot_surf(y_t, Dt, Dx, step=1, filename=None, offset=-1, zlabel=r'displacement', elevation=40, azimuth=-20, cmap=plt.cm.coolwarm): """Plot y_t as a 3D plot with contour plot underneath. Arguments --------- y_t : 2D array displacement y(t, x) filename : string or None, optional (default: None) If `None` then show the figure and return the axes object. If a string is given (like "contour.png") it will only plot to the filename and close the figure but return the filename. offset : float, optional (default: 20) position the 2D contour plot by offset along the Z direction under the minimum Z value zlabel : string, optional label for the Z axis and color scale bar elevation : float, optional choose elevation for initial viewpoint azimuth : float, optional chooze azimuth angle for initial viewpoint """ t = np.arange(y_t.shape[0], dtype=int) x = np.arange(y_t.shape[1], dtype=int) T, X = np.meshgrid(t, x) Y = y_t.T[X, T] fig = plt.figure() ax = fig.add_subplot(111, projection='3d') surf = ax.plot_surface(X*Dx, T*Dt*step, Y, cmap=cmap, rstride=1, cstride=1, alpha=1) cset = ax.contourf(X*Dx, T*Dt*step, Y, 20, zdir='z', offset=offset+Y.min(), cmap=cmap) ax.set_xlabel('x') ax.set_ylabel('t') ax.set_zlabel(zlabel) ax.set_zlim(offset + Y.min(), Y.max()) ax.view_init(elev=elevation, azim=azimuth) cb = fig.colorbar(surf, shrink=0.5, aspect=5) cb.set_label(zlabel) if filename: fig.savefig(filename) plt.close(fig) return filename else: return ax ``` ```python plot_y(y_t, Dt, Dx) ``` ```python plot_surf(y_t, Dt, Dx, offset=-0.04, cmap=plt.cm.coolwarm) ``` ## von Neumann stability analysis: Courant condition Assume that the solutions of the discretized equation can be written as normal modes $$ y_{m,j} = \xi(k)^j e^{ikm\Delta x}, \quad t=j\Delta t,\ x=m\Delta x $$ The time stepping algorith is stable if $$ |\xi(k)| < 1 $$ Insert normal modes into the discretized equation $$ y_{i,j+1} = 2(1 - \beta^2)y_{i,j} - y_{i, j-1} + \beta^2 (y_{i+1,j} + y_{i-1,j}), \quad \beta := \frac{c}{\Delta x/\Delta t} $$ and simplify (use $1-\cos x = 2\sin^2\frac{x}{2}$): $$ \xi^2 - 2(1-2\beta^2 s^2)\xi + 1 = 0, \quad s=\sin(k\Delta x/2) $$ The characteristic equation has roots $$ \xi_{\pm} = 1 - 2\beta^2 s^2 \pm \sqrt{(1-2\beta^2 s^2)^2 - 1}. $$ It has one root for $$ \left|1-2\beta^2 s^2\right| = 1, $$ i.e., for $$ \beta s = 1 $$ We have two real roots for $$ \left|1-2\beta^2 s^2\right| < 1 \\ \beta s > 1 $$ but one of the roots is always $|\xi| > 1$ and hence these solutions will diverge and not be stable. For $$ \left|1-2\beta^2 s^2\right| β‰₯ 1 \\ \beta s ≀ 1 $$ the roots will be *complex conjugates of each other* $$ \xi_\pm = 1 - 2\beta^2s^2 \pm i\sqrt{1-(1-2\beta^2s^2)^2} $$ and the *magnitude* $$ |\xi_{\pm}|^2 = (1 - 2\beta^2s^2)^2 - (1-(1-2\beta^2s^2)^2) = 1 $$ is unity: Thus the solutions will not grow and will be *stable* for $$ \beta s ≀ 1\\ \frac{c}{\frac{\Delta x}{\Delta t}} \sin\frac{k \Delta x}{2} ≀ 1 $$ Assuming the "worst case" for the $\sin$ factor (namely, 1), the **condition for stability** is $$ c ≀ \frac{\Delta x}{\Delta t} $$ or $$ \beta ≀ 1. $$ This is also known as the **Courant condition**. When written as $$ \Delta t ≀ \frac{\Delta x}{c} $$ it means that the time step $\Delta t$ (for a given $\Delta x$) must be *smaller than the time that the wave takes to travel one grid step*. ## Simplified simulation The above example used real numbers for a cello string. Below is bare-bones where we just set $\beta$. ```python L = 10.0 Nx = 100 Nt = 200 step = 1 Dx = L/Nx beta2 = 1.0 X = np.linspace(0, L, Nx+1) # need N+1! def gaussian(x): return np.exp(-(x-5)**2) # displacements at j-1, j, j+1 y0 = np.zeros_like(X) y1 = np.zeros_like(y0) y2 = np.zeros_like(y0) # save array y_t = np.zeros((int(np.ceil(Nt/step)) + 1, Nx+1)) # boundary conditions y0[0] = y0[-1] = y1[0] = y1[-1] = 0 y2[:] = y0 # initial conditions: velocity 0, i.e. no difference between y0 and y1 y0[:] = y1[:] = gaussian(X) # save initial t_index = 0 y_t[t_index, :] = y0 if step == 1: t_index += 1 y_t[t_index, :] = y1 for jt in range(2, Nt): y2[1:-1] = 2*(1-beta2)*y1[1:-1] - y0[1:-1] + beta2*(y1[2:] + y1[:-2]) y0[:], y1[:] = y1, y2 if jt % step == 0 or jt == Nt-1: t_index += 1 y_t[t_index, :] = y2 print("Iteration {0:5d}".format(jt), end="\r") else: print("Completed {0:5d} iterations: t={1} s".format(jt, jt*Dt)) ``` Completed 199 iterations: t=0.0199 s ```python ax = plt.subplot(111) ax.set_prop_cycle("color", [plt.cm.viridis_r(i) for i in np.linspace(0, 1, len(y_t))]) ax.plot(X, y_t.T); ``` ```python ```
= = = Rear = = =
(* Title: HOL/Imperative_HOL/ex/Imperative_Quicksort.thy Author: Lukas Bulwahn, TU Muenchen *) section \<open>An imperative implementation of Quicksort on arrays\<close> theory Imperative_Quicksort imports "~~/src/HOL/Imperative_HOL/Imperative_HOL" Subarray "HOL-Library.Multiset" "HOL-Library.Code_Target_Numeral" begin text \<open>We prove QuickSort correct in the Relational Calculus.\<close> definition swap :: "'a::heap array \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> unit Heap" where "swap arr i j = do { x \<leftarrow> Array.nth arr i; y \<leftarrow> Array.nth arr j; Array.upd i y arr; Array.upd j x arr; return () }" lemma effect_swapI [effect_intros]: assumes "i < Array.length h a" "j < Array.length h a" "x = Array.get h a ! i" "y = Array.get h a ! j" "h' = Array.update a j x (Array.update a i y h)" shows "effect (swap a i j) h h' r" unfolding swap_def using assms by (auto intro!: effect_intros) lemma swap_permutes: assumes "effect (swap a i j) h h' rs" shows "mset (Array.get h' a) = mset (Array.get h a)" using assms unfolding swap_def by (auto simp add: Array.length_def mset_swap dest: sym [of _ "h'"] elim!: effect_bindE effect_nthE effect_returnE effect_updE) function part1 :: "'a::{heap,ord} array \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> 'a \<Rightarrow> nat Heap" where "part1 a left right p = ( if (right \<le> left) then return right else do { v \<leftarrow> Array.nth a left; (if (v \<le> p) then (part1 a (left + 1) right p) else (do { swap a left right; part1 a left (right - 1) p })) })" by pat_completeness auto termination by (relation "measure (\<lambda>(_,l,r,_). r - l )") auto declare part1.simps[simp del] lemma part_permutes: assumes "effect (part1 a l r p) h h' rs" shows "mset (Array.get h' a) = mset (Array.get h a)" using assms proof (induct a l r p arbitrary: h h' rs rule:part1.induct) case (1 a l r p h h' rs) thus ?case unfolding part1.simps [of a l r p] by (elim effect_bindE effect_ifE effect_returnE effect_nthE) (auto simp add: swap_permutes) qed lemma part_returns_index_in_bounds: assumes "effect (part1 a l r p) h h' rs" assumes "l \<le> r" shows "l \<le> rs \<and> rs \<le> r" using assms proof (induct a l r p arbitrary: h h' rs rule:part1.induct) case (1 a l r p h h' rs) note cr = \<open>effect (part1 a l r p) h h' rs\<close> show ?case proof (cases "r \<le> l") case True (* Terminating case *) with cr \<open>l \<le> r\<close> show ?thesis unfolding part1.simps[of a l r p] by (elim effect_bindE effect_ifE effect_returnE effect_nthE) auto next case False (* recursive case *) note rec_condition = this let ?v = "Array.get h a ! l" show ?thesis proof (cases "?v \<le> p") case True with cr False have rec1: "effect (part1 a (l + 1) r p) h h' rs" unfolding part1.simps[of a l r p] by (elim effect_bindE effect_nthE effect_ifE effect_returnE) auto from rec_condition have "l + 1 \<le> r" by arith from 1(1)[OF rec_condition True rec1 \<open>l + 1 \<le> r\<close>] show ?thesis by simp next case False with rec_condition cr obtain h1 where swp: "effect (swap a l r) h h1 ()" and rec2: "effect (part1 a l (r - 1) p) h1 h' rs" unfolding part1.simps[of a l r p] by (elim effect_bindE effect_nthE effect_ifE effect_returnE) auto from rec_condition have "l \<le> r - 1" by arith from 1(2) [OF rec_condition False rec2 \<open>l \<le> r - 1\<close>] show ?thesis by fastforce qed qed qed lemma part_length_remains: assumes "effect (part1 a l r p) h h' rs" shows "Array.length h a = Array.length h' a" using assms proof (induct a l r p arbitrary: h h' rs rule:part1.induct) case (1 a l r p h h' rs) note cr = \<open>effect (part1 a l r p) h h' rs\<close> show ?case proof (cases "r \<le> l") case True (* Terminating case *) with cr show ?thesis unfolding part1.simps[of a l r p] by (elim effect_bindE effect_ifE effect_returnE effect_nthE) auto next case False (* recursive case *) with cr 1 show ?thesis unfolding part1.simps [of a l r p] swap_def by (auto elim!: effect_bindE effect_ifE effect_nthE effect_returnE effect_updE) fastforce qed qed lemma part_outer_remains: assumes "effect (part1 a l r p) h h' rs" shows "\<forall>i. i < l \<or> r < i \<longrightarrow> Array.get h (a::'a::{heap,linorder} array) ! i = Array.get h' a ! i" using assms proof (induct a l r p arbitrary: h h' rs rule:part1.induct) case (1 a l r p h h' rs) note cr = \<open>effect (part1 a l r p) h h' rs\<close> show ?case proof (cases "r \<le> l") case True (* Terminating case *) with cr show ?thesis unfolding part1.simps[of a l r p] by (elim effect_bindE effect_ifE effect_returnE effect_nthE) auto next case False (* recursive case *) note rec_condition = this let ?v = "Array.get h a ! l" show ?thesis proof (cases "?v \<le> p") case True with cr False have rec1: "effect (part1 a (l + 1) r p) h h' rs" unfolding part1.simps[of a l r p] by (elim effect_bindE effect_nthE effect_ifE effect_returnE) auto from 1(1)[OF rec_condition True rec1] show ?thesis by fastforce next case False with rec_condition cr obtain h1 where swp: "effect (swap a l r) h h1 ()" and rec2: "effect (part1 a l (r - 1) p) h1 h' rs" unfolding part1.simps[of a l r p] by (elim effect_bindE effect_nthE effect_ifE effect_returnE) auto from swp rec_condition have "\<forall>i. i < l \<or> r < i \<longrightarrow> Array.get h a ! i = Array.get h1 a ! i" unfolding swap_def by (elim effect_bindE effect_nthE effect_updE effect_returnE) auto with 1(2) [OF rec_condition False rec2] show ?thesis by fastforce qed qed qed lemma part_partitions: assumes "effect (part1 a l r p) h h' rs" shows "(\<forall>i. l \<le> i \<and> i < rs \<longrightarrow> Array.get h' (a::'a::{heap,linorder} array) ! i \<le> p) \<and> (\<forall>i. rs < i \<and> i \<le> r \<longrightarrow> Array.get h' a ! i \<ge> p)" using assms proof (induct a l r p arbitrary: h h' rs rule:part1.induct) case (1 a l r p h h' rs) note cr = \<open>effect (part1 a l r p) h h' rs\<close> show ?case proof (cases "r \<le> l") case True (* Terminating case *) with cr have "rs = r" unfolding part1.simps[of a l r p] by (elim effect_bindE effect_ifE effect_returnE effect_nthE) auto with True show ?thesis by auto next case False (* recursive case *) note lr = this let ?v = "Array.get h a ! l" show ?thesis proof (cases "?v \<le> p") case True with lr cr have rec1: "effect (part1 a (l + 1) r p) h h' rs" unfolding part1.simps[of a l r p] by (elim effect_bindE effect_nthE effect_ifE effect_returnE) auto from True part_outer_remains[OF rec1] have a_l: "Array.get h' a ! l \<le> p" by fastforce have "\<forall>i. (l \<le> i = (l = i \<or> Suc l \<le> i))" by arith with 1(1)[OF False True rec1] a_l show ?thesis by auto next case False with lr cr obtain h1 where swp: "effect (swap a l r) h h1 ()" and rec2: "effect (part1 a l (r - 1) p) h1 h' rs" unfolding part1.simps[of a l r p] by (elim effect_bindE effect_nthE effect_ifE effect_returnE) auto from swp False have "Array.get h1 a ! r \<ge> p" unfolding swap_def by (auto simp add: Array.length_def elim!: effect_bindE effect_nthE effect_updE effect_returnE) with part_outer_remains [OF rec2] lr have a_r: "Array.get h' a ! r \<ge> p" by fastforce have "\<forall>i. (i \<le> r = (i = r \<or> i \<le> r - 1))" by arith with 1(2)[OF lr False rec2] a_r show ?thesis by auto qed qed qed fun partition :: "'a::{heap,linorder} array \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat Heap" where "partition a left right = do { pivot \<leftarrow> Array.nth a right; middle \<leftarrow> part1 a left (right - 1) pivot; v \<leftarrow> Array.nth a middle; m \<leftarrow> return (if (v \<le> pivot) then (middle + 1) else middle); swap a m right; return m }" declare partition.simps[simp del] lemma partition_permutes: assumes "effect (partition a l r) h h' rs" shows "mset (Array.get h' a) = mset (Array.get h a)" proof - from assms part_permutes swap_permutes show ?thesis unfolding partition.simps by (elim effect_bindE effect_returnE effect_nthE effect_ifE effect_updE) fastforce qed lemma partition_length_remains: assumes "effect (partition a l r) h h' rs" shows "Array.length h a = Array.length h' a" proof - from assms part_length_remains show ?thesis unfolding partition.simps swap_def by (elim effect_bindE effect_returnE effect_nthE effect_ifE effect_updE) auto qed lemma partition_outer_remains: assumes "effect (partition a l r) h h' rs" assumes "l < r" shows "\<forall>i. i < l \<or> r < i \<longrightarrow> Array.get h (a::'a::{heap,linorder} array) ! i = Array.get h' a ! i" proof - from assms part_outer_remains part_returns_index_in_bounds show ?thesis unfolding partition.simps swap_def by (elim effect_bindE effect_returnE effect_nthE effect_ifE effect_updE) fastforce qed lemma partition_returns_index_in_bounds: assumes effect: "effect (partition a l r) h h' rs" assumes "l < r" shows "l \<le> rs \<and> rs \<le> r" proof - from effect obtain middle h'' p where part: "effect (part1 a l (r - 1) p) h h'' middle" and rs_equals: "rs = (if Array.get h'' a ! middle \<le> Array.get h a ! r then middle + 1 else middle)" unfolding partition.simps by (elim effect_bindE effect_returnE effect_nthE effect_ifE effect_updE) simp from \<open>l < r\<close> have "l \<le> r - 1" by arith from part_returns_index_in_bounds[OF part this] rs_equals \<open>l < r\<close> show ?thesis by auto qed lemma partition_partitions: assumes effect: "effect (partition a l r) h h' rs" assumes "l < r" shows "(\<forall>i. l \<le> i \<and> i < rs \<longrightarrow> Array.get h' (a::'a::{heap,linorder} array) ! i \<le> Array.get h' a ! rs) \<and> (\<forall>i. rs < i \<and> i \<le> r \<longrightarrow> Array.get h' a ! rs \<le> Array.get h' a ! i)" proof - let ?pivot = "Array.get h a ! r" from effect obtain middle h1 where part: "effect (part1 a l (r - 1) ?pivot) h h1 middle" and swap: "effect (swap a rs r) h1 h' ()" and rs_equals: "rs = (if Array.get h1 a ! middle \<le> ?pivot then middle + 1 else middle)" unfolding partition.simps by (elim effect_bindE effect_returnE effect_nthE effect_ifE effect_updE) simp from swap have h'_def: "h' = Array.update a r (Array.get h1 a ! rs) (Array.update a rs (Array.get h1 a ! r) h1)" unfolding swap_def by (elim effect_bindE effect_returnE effect_nthE effect_updE) simp from swap have in_bounds: "r < Array.length h1 a \<and> rs < Array.length h1 a" unfolding swap_def by (elim effect_bindE effect_returnE effect_nthE effect_updE) simp from swap have swap_length_remains: "Array.length h1 a = Array.length h' a" unfolding swap_def by (elim effect_bindE effect_returnE effect_nthE effect_updE) auto from \<open>l < r\<close> have "l \<le> r - 1" by simp note middle_in_bounds = part_returns_index_in_bounds[OF part this] from part_outer_remains[OF part] \<open>l < r\<close> have "Array.get h a ! r = Array.get h1 a ! r" by fastforce with swap have right_remains: "Array.get h a ! r = Array.get h' a ! rs" unfolding swap_def by (auto simp add: Array.length_def elim!: effect_bindE effect_returnE effect_nthE effect_updE) (cases "r = rs", auto) from part_partitions [OF part] show ?thesis proof (cases "Array.get h1 a ! middle \<le> ?pivot") case True with rs_equals have rs_equals: "rs = middle + 1" by simp { fix i assume i_is_left: "l \<le> i \<and> i < rs" with swap_length_remains in_bounds middle_in_bounds rs_equals \<open>l < r\<close> have i_props: "i < Array.length h' a" "i \<noteq> r" "i \<noteq> rs" by auto from i_is_left rs_equals have "l \<le> i \<and> i < middle \<or> i = middle" by arith with part_partitions[OF part] right_remains True have "Array.get h1 a ! i \<le> Array.get h' a ! rs" by fastforce with i_props h'_def in_bounds have "Array.get h' a ! i \<le> Array.get h' a ! rs" unfolding Array.update_def Array.length_def by simp } moreover { fix i assume "rs < i \<and> i \<le> r" hence "(rs < i \<and> i \<le> r - 1) \<or> (rs < i \<and> i = r)" by arith hence "Array.get h' a ! rs \<le> Array.get h' a ! i" proof assume i_is: "rs < i \<and> i \<le> r - 1" with swap_length_remains in_bounds middle_in_bounds rs_equals have i_props: "i < Array.length h' a" "i \<noteq> r" "i \<noteq> rs" by auto from part_partitions[OF part] rs_equals right_remains i_is have "Array.get h' a ! rs \<le> Array.get h1 a ! i" by fastforce with i_props h'_def show ?thesis by fastforce next assume i_is: "rs < i \<and> i = r" with rs_equals have "Suc middle \<noteq> r" by arith with middle_in_bounds \<open>l < r\<close> have "Suc middle \<le> r - 1" by arith with part_partitions[OF part] right_remains have "Array.get h' a ! rs \<le> Array.get h1 a ! (Suc middle)" by fastforce with i_is True rs_equals right_remains h'_def show ?thesis using in_bounds unfolding Array.update_def Array.length_def by auto qed } ultimately show ?thesis by auto next case False with rs_equals have rs_equals: "middle = rs" by simp { fix i assume i_is_left: "l \<le> i \<and> i < rs" with swap_length_remains in_bounds middle_in_bounds rs_equals have i_props: "i < Array.length h' a" "i \<noteq> r" "i \<noteq> rs" by auto from part_partitions[OF part] rs_equals right_remains i_is_left have "Array.get h1 a ! i \<le> Array.get h' a ! rs" by fastforce with i_props h'_def have "Array.get h' a ! i \<le> Array.get h' a ! rs" unfolding Array.update_def by simp } moreover { fix i assume "rs < i \<and> i \<le> r" hence "(rs < i \<and> i \<le> r - 1) \<or> i = r" by arith hence "Array.get h' a ! rs \<le> Array.get h' a ! i" proof assume i_is: "rs < i \<and> i \<le> r - 1" with swap_length_remains in_bounds middle_in_bounds rs_equals have i_props: "i < Array.length h' a" "i \<noteq> r" "i \<noteq> rs" by auto from part_partitions[OF part] rs_equals right_remains i_is have "Array.get h' a ! rs \<le> Array.get h1 a ! i" by fastforce with i_props h'_def show ?thesis by fastforce next assume i_is: "i = r" from i_is False rs_equals right_remains h'_def show ?thesis using in_bounds unfolding Array.update_def Array.length_def by auto qed } ultimately show ?thesis by auto qed qed function quicksort :: "'a::{heap,linorder} array \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> unit Heap" where "quicksort arr left right = (if (right > left) then do { pivotNewIndex \<leftarrow> partition arr left right; pivotNewIndex \<leftarrow> assert (\<lambda>x. left \<le> x \<and> x \<le> right) pivotNewIndex; quicksort arr left (pivotNewIndex - 1); quicksort arr (pivotNewIndex + 1) right } else return ())" by pat_completeness auto (* For termination, we must show that the pivotNewIndex is between left and right *) termination by (relation "measure (\<lambda>(a, l, r). (r - l))") auto declare quicksort.simps[simp del] lemma quicksort_permutes: assumes "effect (quicksort a l r) h h' rs" shows "mset (Array.get h' a) = mset (Array.get h a)" using assms proof (induct a l r arbitrary: h h' rs rule: quicksort.induct) case (1 a l r h h' rs) with partition_permutes show ?case unfolding quicksort.simps [of a l r] by (elim effect_ifE effect_bindE effect_assertE effect_returnE) auto qed lemma length_remains: assumes "effect (quicksort a l r) h h' rs" shows "Array.length h a = Array.length h' a" using assms proof (induct a l r arbitrary: h h' rs rule: quicksort.induct) case (1 a l r h h' rs) with partition_length_remains show ?case unfolding quicksort.simps [of a l r] by (elim effect_ifE effect_bindE effect_assertE effect_returnE) fastforce+ qed lemma quicksort_outer_remains: assumes "effect (quicksort a l r) h h' rs" shows "\<forall>i. i < l \<or> r < i \<longrightarrow> Array.get h (a::'a::{heap,linorder} array) ! i = Array.get h' a ! i" using assms proof (induct a l r arbitrary: h h' rs rule: quicksort.induct) case (1 a l r h h' rs) note cr = \<open>effect (quicksort a l r) h h' rs\<close> thus ?case proof (cases "r > l") case False with cr have "h' = h" unfolding quicksort.simps [of a l r] by (elim effect_ifE effect_returnE) auto thus ?thesis by simp next case True { fix h1 h2 p ret1 ret2 i assume part: "effect (partition a l r) h h1 p" assume qs1: "effect (quicksort a l (p - 1)) h1 h2 ret1" assume qs2: "effect (quicksort a (p + 1) r) h2 h' ret2" assume pivot: "l \<le> p \<and> p \<le> r" assume i_outer: "i < l \<or> r < i" from partition_outer_remains [OF part True] i_outer have 2: "Array.get h a !i = Array.get h1 a ! i" by fastforce moreover from 1(1) [OF True pivot qs1] pivot i_outer 2 have 3: "Array.get h1 a ! i = Array.get h2 a ! i" by auto moreover from qs2 1(2) [of p h2 h' ret2] True pivot i_outer 3 have "Array.get h2 a ! i = Array.get h' a ! i" by auto ultimately have "Array.get h a ! i= Array.get h' a ! i" by simp } with cr show ?thesis unfolding quicksort.simps [of a l r] by (elim effect_ifE effect_bindE effect_assertE effect_returnE) auto qed qed lemma quicksort_is_skip: assumes "effect (quicksort a l r) h h' rs" shows "r \<le> l \<longrightarrow> h = h'" using assms unfolding quicksort.simps [of a l r] by (elim effect_ifE effect_returnE) auto lemma quicksort_sorts: assumes "effect (quicksort a l r) h h' rs" assumes l_r_length: "l < Array.length h a" "r < Array.length h a" shows "sorted (subarray l (r + 1) a h')" using assms proof (induct a l r arbitrary: h h' rs rule: quicksort.induct) case (1 a l r h h' rs) note cr = \<open>effect (quicksort a l r) h h' rs\<close> thus ?case proof (cases "r > l") case False hence "l \<ge> r + 1 \<or> l = r" by arith with length_remains[OF cr] 1(5) show ?thesis by (auto simp add: subarray_Nil subarray_single) next case True { fix h1 h2 p assume part: "effect (partition a l r) h h1 p" assume qs1: "effect (quicksort a l (p - 1)) h1 h2 ()" assume qs2: "effect (quicksort a (p + 1) r) h2 h' ()" from partition_returns_index_in_bounds [OF part True] have pivot: "l\<le> p \<and> p \<le> r" . note length_remains = length_remains[OF qs2] length_remains[OF qs1] partition_length_remains[OF part] from quicksort_outer_remains [OF qs2] quicksort_outer_remains [OF qs1] pivot quicksort_is_skip[OF qs1] have pivot_unchanged: "Array.get h1 a ! p = Array.get h' a ! p" by (cases p, auto) (*-- First of all, by induction hypothesis both sublists are sorted. *) from 1(1)[OF True pivot qs1] length_remains pivot 1(5) have IH1: "sorted (subarray l p a h2)" by (cases p, auto simp add: subarray_Nil) from quicksort_outer_remains [OF qs2] length_remains have left_subarray_remains: "subarray l p a h2 = subarray l p a h'" by (simp add: subarray_eq_samelength_iff) with IH1 have IH1': "sorted (subarray l p a h')" by simp from 1(2)[OF True pivot qs2] pivot 1(5) length_remains have IH2: "sorted (subarray (p + 1) (r + 1) a h')" by (cases "Suc p \<le> r", auto simp add: subarray_Nil) (* -- Secondly, both sublists remain partitioned. *) from partition_partitions[OF part True] have part_conds1: "\<forall>j. j \<in> set (subarray l p a h1) \<longrightarrow> j \<le> Array.get h1 a ! p " and part_conds2: "\<forall>j. j \<in> set (subarray (p + 1) (r + 1) a h1) \<longrightarrow> Array.get h1 a ! p \<le> j" by (auto simp add: all_in_set_subarray_conv) from quicksort_outer_remains [OF qs1] quicksort_permutes [OF qs1] True length_remains 1(5) pivot mset_nths [of l p "Array.get h1 a" "Array.get h2 a"] have multiset_partconds1: "mset (subarray l p a h2) = mset (subarray l p a h1)" unfolding Array.length_def subarray_def by (cases p, auto) with left_subarray_remains part_conds1 pivot_unchanged have part_conds2': "\<forall>j. j \<in> set (subarray l p a h') \<longrightarrow> j \<le> Array.get h' a ! p" by (simp, subst set_mset_mset[symmetric], simp) (* -- These steps are the analogous for the right sublist \<dots> *) from quicksort_outer_remains [OF qs1] length_remains have right_subarray_remains: "subarray (p + 1) (r + 1) a h1 = subarray (p + 1) (r + 1) a h2" by (auto simp add: subarray_eq_samelength_iff) from quicksort_outer_remains [OF qs2] quicksort_permutes [OF qs2] True length_remains 1(5) pivot mset_nths [of "p + 1" "r + 1" "Array.get h2 a" "Array.get h' a"] have multiset_partconds2: "mset (subarray (p + 1) (r + 1) a h') = mset (subarray (p + 1) (r + 1) a h2)" unfolding Array.length_def subarray_def by auto with right_subarray_remains part_conds2 pivot_unchanged have part_conds1': "\<forall>j. j \<in> set (subarray (p + 1) (r + 1) a h') \<longrightarrow> Array.get h' a ! p \<le> j" by (simp, subst set_mset_mset[symmetric], simp) (* -- Thirdly and finally, we show that the array is sorted following from the facts above. *) from True pivot 1(5) length_remains have "subarray l (r + 1) a h' = subarray l p a h' @ [Array.get h' a ! p] @ subarray (p + 1) (r + 1) a h'" by (simp add: subarray_nth_array_Cons, cases "l < p") (auto simp add: subarray_append subarray_Nil) with IH1' IH2 part_conds1' part_conds2' pivot have ?thesis unfolding subarray_def apply (auto simp add: sorted_append all_in_set_nths'_conv) by (auto simp add: set_nths' dest: order.trans [of _ "Array.get h' a ! p"]) } with True cr show ?thesis unfolding quicksort.simps [of a l r] by (elim effect_ifE effect_returnE effect_bindE effect_assertE) auto qed qed lemma quicksort_is_sort: assumes effect: "effect (quicksort a 0 (Array.length h a - 1)) h h' rs" shows "Array.get h' a = sort (Array.get h a)" proof (cases "Array.get h a = []") case True with quicksort_is_skip[OF effect] show ?thesis unfolding Array.length_def by simp next case False from quicksort_sorts [OF effect] False have "sorted (nths' 0 (List.length (Array.get h a)) (Array.get h' a))" unfolding Array.length_def subarray_def by auto with length_remains[OF effect] have "sorted (Array.get h' a)" unfolding Array.length_def by simp with quicksort_permutes [OF effect] properties_for_sort show ?thesis by fastforce qed subsection \<open>No Errors in quicksort\<close> text \<open>We have proved that quicksort sorts (if no exceptions occur). We will now show that exceptions do not occur.\<close> lemma success_part1I: assumes "l < Array.length h a" "r < Array.length h a" shows "success (part1 a l r p) h" using assms proof (induct a l r p arbitrary: h rule: part1.induct) case (1 a l r p) thus ?case unfolding part1.simps [of a l r] apply (auto intro!: success_intros simp add: not_le) apply (auto intro!: effect_intros) done qed lemma success_bindI' [success_intros]: (*FIXME move*) assumes "success f h" assumes "\<And>h' r. effect f h h' r \<Longrightarrow> success (g r) h'" shows "success (f \<bind> g) h" using assms(1) proof (rule success_effectE) fix h' r assume *: "effect f h h' r" with assms(2) have "success (g r) h'" . with * show "success (f \<bind> g) h" by (rule success_bind_effectI) qed lemma success_partitionI: assumes "l < r" "l < Array.length h a" "r < Array.length h a" shows "success (partition a l r) h" using assms unfolding partition.simps swap_def apply (auto intro!: success_bindI' success_ifI success_returnI success_nthI success_updI success_part1I elim!: effect_bindE effect_updE effect_nthE effect_returnE simp add:) apply (frule part_length_remains) apply (frule part_returns_index_in_bounds) apply auto apply (frule part_length_remains) apply (frule part_returns_index_in_bounds) apply auto apply (frule part_length_remains) apply auto done lemma success_quicksortI: assumes "l < Array.length h a" "r < Array.length h a" shows "success (quicksort a l r) h" using assms proof (induct a l r arbitrary: h rule: quicksort.induct) case (1 a l ri h) thus ?case unfolding quicksort.simps [of a l ri] apply (auto intro!: success_ifI success_bindI' success_returnI success_nthI success_updI success_assertI success_partitionI) apply (frule partition_returns_index_in_bounds) apply auto apply (frule partition_returns_index_in_bounds) apply auto apply (auto elim!: effect_assertE dest!: partition_length_remains length_remains) apply (subgoal_tac "Suc r \<le> ri \<or> r = ri") apply (erule disjE) apply auto unfolding quicksort.simps [of a "Suc ri" ri] apply (auto intro!: success_ifI success_returnI) done qed subsection \<open>Example\<close> definition "qsort a = do { k \<leftarrow> Array.len a; quicksort a 0 (k - 1); return a }" code_reserved SML upto definition "example = do { a \<leftarrow> Array.of_list ([42, 2, 3, 5, 0, 1705, 8, 3, 15] :: nat list); qsort a }" ML_val \<open>@{code example} ()\<close> export_code qsort checking SML SML_imp OCaml? OCaml_imp? Haskell? Scala Scala_imp end
[STATEMENT] lemma ovsi (*[simp]*):"ov \<inter> s^-1 = {}" [PROOF STATE] proof (prove) goal (1 subgoal): 1. ov \<inter> s\<inverse> = {} [PROOF STEP] apply (auto simp:ov s) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>a b k ka l u ua v va t. \<lbrakk>k \<parallel> a; ka \<parallel> b; a \<parallel> u; b \<parallel> ua; u \<parallel> v; ua \<parallel> va; k \<parallel> l; ka \<parallel> a; a \<parallel> va; l \<parallel> b; b \<parallel> v; l \<parallel> t; t \<parallel> u\<rbrakk> \<Longrightarrow> False [PROOF STEP] by (meson M1 elimmeets)
[STATEMENT] lemma leadsto_infinite: "\<turnstile> \<box>\<diamond>F \<and> (F \<leadsto> G) \<longrightarrow> \<box>\<diamond>G" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<turnstile> \<box>\<diamond>F \<and> (F \<leadsto> G) \<longrightarrow> \<box>\<diamond>G [PROOF STEP] apply clarsimp [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>sigma. \<lbrakk>sigma \<Turnstile> \<box>\<diamond>F; sigma \<Turnstile> F \<leadsto> G\<rbrakk> \<Longrightarrow> sigma \<Turnstile> \<box>\<diamond>G [PROOF STEP] apply (erule InitDmd [temp_use, THEN streett_leadsto [temp_unlift, THEN iffD2, THEN mp]]) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>sigma. sigma \<Turnstile> \<box>\<diamond>F \<Longrightarrow> sigma \<Turnstile> \<box>\<diamond>Init F [PROOF STEP] apply (simp add: dmdInitD) [PROOF STATE] proof (prove) goal: No subgoals! [PROOF STEP] done
Earn 10% of all revenue on the lifetime of customers you refer to Goldfish. Do you want to earn generous revenue for customer that your refer? Then join our generous affiliate programme and we will pay you for customers that you refer to us. What’s more, we won’t simply pay you a one off fee; as many others do. We will pay you a 10% share of the revenue from every customer you refer to us for the lifetime of that customer. That’s the whole time they are with us. Right now, we’re offering our affiliates 10% of the revenue received from any customer that they refer to us. That’s 10% of all revenues that we receive from any customer that you refer to us through the affiliate program for as long as that customer is with us. Click on β€˜sign up now’ to register your details with us and get started. Sign up now – click here.
Jamie Delano returned to the title on several occasions . Between the Garth Ennis and Paul Jenkins runs on Hellblazer , he finally told the story of why John 's best friend Chas ' owes ' him , and he returned again for one of the five Christmas stories in issue # 250 . He also wrote the mini series The <unk> in 1995 , and Bad Blood in 2000 , both featuring John Constantine . A more substantial return was made in 2010 for a hardcover graphic novel Hellblazer : Pandemonium with artist Jock to commemorate the 25th anniversary of John Constantine 's first appearance in Swamp Thing .
lemma not_irreducible_zero [simp]: "\<not>irreducible 0"
I’m very pleased to announce that we have expanded the AlienVault certification program. Our newest certificationβ€”AlienVault USM Appliance Technicianβ€”is now the first level of certification in our program. The AlienVault Certified Security Engineer (ACSE), introduced in 2015, remains the capstone certification in our lineup. Today, I thought I’d discuss why we introduced this new certification, how it works (which is a little different than many tech certifications), and why this matters for those who already hold our ACSE certification. Security and IT professionals have varying reasons for choosing to pursue an industry certification. Gaining recognition among peers, building credentials when seeking employment, and advancing in one’s career are all mentioned frequently. However, there’s another reason to pursue a certification, one that’s often overlooked. There’s plenty of evidence showing that testing helps you to learn, and the deeper you learn USM Appliance, the more you’ll get use of its powerful capabilities! When you take our comprehensive, five-day AlienVault USM Appliance for Security Engineers course, you’ll learn the core skills to design, implement, and operate AlienVault USM Appliance in your environment. This will prepare you for the AlienVault USM Appliance Technician certification, which was designed to focus entirely on testing the skills and knowledge that we teach in the class. By preparing for the exam, and passing it, you can have confidence that you have a strong foundation to start using USM Appliance and growing your understanding of the security visibility that it offers. Our newest certification works a bit differently than the current ACSE, and differently than many other tech certifications. It’s entirely based on the skills and knowledge that we teach in our five-day AlienVault USM Appliance for Security Engineers course. All of the questions on the AlienVault USM Appliance Technician exam are derived from knowledge and skills acquired during the class. Therefore, it serves as the ideal way to validate learning immediately after completing our comprehensive training class. In contrast, the ACSE certification tests knowledge and skills that typically require months of hands-on product experience to acquire. The AlienVault USM Appliance Technician certification is only available to those who complete the AlienVault USM Appliance for Security Engineers course. For a certification based entirely on the class, we believe it’s most appropriate to require two thingsβ€”completing the class and passing the exam--in order to earn the certification. The AlienVault USM Appliance Technician certification that you earn never expires or requires recertification. Some other aspects of the AlienVault USM Appliance Technician will seem more familiar. The exam is delivered in a proctored environment. For this exam, all testing is via online proctoring, which provide a secure environment as you take the exam from your own computer. If you pass, you’ll receive a personalized certificate and an AlienVault USM Appliance Technician logo that you can use on your resume, CV, or business card. The capstone certification in our lineup, ACSE, is valid for three years from the date earned. Until now, the only way to recertify an ACSE was to pass the ACSE exam again. Now, we’re expanding the options. Any ACSE holder can now recertify their ACSE by passing the ACSE Recertification exam instead. The ACSE Recertification exam is identical, in content, to the AlienVault USM Appliance Technician exam. If you hold an ACSE certification, you have already validated a high level of skill with USM Appliance. By passing the ACSE Recertification exam, you’re demonstrating that your skills remain current with the latest features covered in our training curriculum. Since the ACSE Recertification exam is entirely based on the AlienVault USM Appliance for Security Engineers course, the course materialsβ€”which contain the instructor’s slides and extensive student notesβ€”serve as a great study aid for the exam. Therefore, when an ACSE holder purchases a voucher for the ACSE Recertification exam, we provide a current copy of those materials at no additional cost. Ultimately, we want you to be successful in realizing the business value from USM Appliance that led you to purchase the product. If you’re better able to use the product and its many features, you’re much more likely to achieve that success. I hope that introducing the new AlienVault USM Appliance Technician is a step toward that end. Once you gain significant experience with USM Appliance or complete our more advance training, I hope you’ll consider earning ACSE to achieve the highest level of skills validation that we offer. As our company has grown, we’re pleased to provide this more robust certification path to help you build confidenceβ€”and certificationsβ€”as you progress in your skills with security and USM Appliance. Please feel free to reach out to me at [email protected] if you have any comments, questions, or suggestions. Get started with your AlienVault certification today!
(* Title: ZF/Induct/FoldSet.thy Author: Sidi O Ehmety, Cambridge University Computer Laboratory A "fold" functional for finite sets. For n non-negative we have fold f e {x1,...,xn} = f x1 (... (f xn e)) where f is at least left-commutative. *) theory FoldSet imports ZF begin consts fold_set :: "[i, i, [i,i]\<Rightarrow>i, i] \<Rightarrow> i" inductive domains "fold_set(A, B, f,e)" \<subseteq> "Fin(A)*B" intros emptyI: "e\<in>B \<Longrightarrow> \<langle>0, e\<rangle>\<in>fold_set(A, B, f,e)" consI: "\<lbrakk>x\<in>A; x \<notin>C; \<langle>C,y\<rangle> \<in> fold_set(A, B,f,e); f(x,y):B\<rbrakk> \<Longrightarrow> <cons(x,C), f(x,y)>\<in>fold_set(A, B, f, e)" type_intros Fin.intros definition fold :: "[i, [i,i]\<Rightarrow>i, i, i] \<Rightarrow> i" (\<open>fold[_]'(_,_,_')\<close>) where "fold[B](f,e, A) \<equiv> THE x. \<langle>A, x\<rangle>\<in>fold_set(A, B, f,e)" definition setsum :: "[i\<Rightarrow>i, i] \<Rightarrow> i" where "setsum(g, C) \<equiv> if Finite(C) then fold[int](\<lambda>x y. g(x) $+ y, #0, C) else #0" (** foldSet **) inductive_cases empty_fold_setE: "\<langle>0, x\<rangle> \<in> fold_set(A, B, f,e)" inductive_cases cons_fold_setE: "<cons(x,C), y> \<in> fold_set(A, B, f,e)" (* add-hoc lemmas *) lemma cons_lemma1: "\<lbrakk>x\<notin>C; x\<notin>B\<rbrakk> \<Longrightarrow> cons(x,B)=cons(x,C) \<longleftrightarrow> B = C" by (auto elim: equalityE) lemma cons_lemma2: "\<lbrakk>cons(x, B)=cons(y, C); x\<noteq>y; x\<notin>B; y\<notin>C\<rbrakk> \<Longrightarrow> B - {y} = C-{x} \<and> x\<in>C \<and> y\<in>B" apply (auto elim: equalityE) done (* fold_set monotonicity *) lemma fold_set_mono_lemma: "\<langle>C, x\<rangle> \<in> fold_set(A, B, f, e) \<Longrightarrow> \<forall>D. A<=D \<longrightarrow> \<langle>C, x\<rangle> \<in> fold_set(D, B, f, e)" apply (erule fold_set.induct) apply (auto intro: fold_set.intros) done lemma fold_set_mono: " C<=A \<Longrightarrow> fold_set(C, B, f, e) \<subseteq> fold_set(A, B, f, e)" apply clarify apply (frule fold_set.dom_subset [THEN subsetD], clarify) apply (auto dest: fold_set_mono_lemma) done lemma fold_set_lemma: "\<langle>C, x\<rangle>\<in>fold_set(A, B, f, e) \<Longrightarrow> \<langle>C, x\<rangle>\<in>fold_set(C, B, f, e) \<and> C<=A" apply (erule fold_set.induct) apply (auto intro!: fold_set.intros intro: fold_set_mono [THEN subsetD]) done (* Proving that fold_set is deterministic *) lemma Diff1_fold_set: "\<lbrakk><C-{x},y> \<in> fold_set(A, B, f,e); x\<in>C; x\<in>A; f(x, y):B\<rbrakk> \<Longrightarrow> <C, f(x, y)> \<in> fold_set(A, B, f, e)" apply (frule fold_set.dom_subset [THEN subsetD]) apply (erule cons_Diff [THEN subst], rule fold_set.intros, auto) done locale fold_typing = fixes A and B and e and f assumes ftype [intro,simp]: "\<lbrakk>x \<in> A; y \<in> B\<rbrakk> \<Longrightarrow> f(x,y) \<in> B" and etype [intro,simp]: "e \<in> B" and fcomm: "\<lbrakk>x \<in> A; y \<in> A; z \<in> B\<rbrakk> \<Longrightarrow> f(x, f(y, z))=f(y, f(x, z))" lemma (in fold_typing) Fin_imp_fold_set: "C\<in>Fin(A) \<Longrightarrow> (\<exists>x. \<langle>C, x\<rangle> \<in> fold_set(A, B, f,e))" apply (erule Fin_induct) apply (auto dest: fold_set.dom_subset [THEN subsetD] intro: fold_set.intros etype ftype) done lemma Diff_sing_imp: "\<lbrakk>C - {b} = D - {a}; a \<noteq> b; b \<in> C\<rbrakk> \<Longrightarrow> C = cons(b,D) - {a}" by (blast elim: equalityE) lemma (in fold_typing) fold_set_determ_lemma [rule_format]: "n\<in>nat \<Longrightarrow> \<forall>C. |C|<n \<longrightarrow> (\<forall>x. \<langle>C, x\<rangle> \<in> fold_set(A, B, f,e)\<longrightarrow> (\<forall>y. \<langle>C, y\<rangle> \<in> fold_set(A, B, f,e) \<longrightarrow> y=x))" apply (erule nat_induct) apply (auto simp add: le_iff) apply (erule fold_set.cases) apply (force elim!: empty_fold_setE) apply (erule fold_set.cases) apply (force elim!: empty_fold_setE, clarify) (*force simplification of "|C| < |cons(...)|"*) apply (frule_tac a = Ca in fold_set.dom_subset [THEN subsetD, THEN SigmaD1]) apply (frule_tac a = Cb in fold_set.dom_subset [THEN subsetD, THEN SigmaD1]) apply (simp add: Fin_into_Finite [THEN Finite_imp_cardinal_cons]) apply (case_tac "x=xb", auto) apply (simp add: cons_lemma1, blast) txt\<open>case \<^term>\<open>x\<noteq>xb\<close>\<close> apply (drule cons_lemma2, safe) apply (frule Diff_sing_imp, assumption+) txt\<open>* LEVEL 17\<close> apply (subgoal_tac "|Ca| \<le> |Cb|") prefer 2 apply (rule succ_le_imp_le) apply (simp add: Fin_into_Finite Finite_imp_succ_cardinal_Diff Fin_into_Finite [THEN Finite_imp_cardinal_cons]) apply (rule_tac C1 = "Ca-{xb}" in Fin_imp_fold_set [THEN exE]) apply (blast intro: Diff_subset [THEN Fin_subset]) txt\<open>* LEVEL 24 *\<close> apply (frule Diff1_fold_set, blast, blast) apply (blast dest!: ftype fold_set.dom_subset [THEN subsetD]) apply (subgoal_tac "ya = f(xb,xa) ") prefer 2 apply (blast del: equalityCE) apply (subgoal_tac "<Cb-{x}, xa> \<in> fold_set(A,B,f,e)") prefer 2 apply simp apply (subgoal_tac "yb = f (x, xa) ") apply (drule_tac [2] C = Cb in Diff1_fold_set, simp_all) apply (blast intro: fcomm dest!: fold_set.dom_subset [THEN subsetD]) apply (blast intro: ftype dest!: fold_set.dom_subset [THEN subsetD], blast) done lemma (in fold_typing) fold_set_determ: "\<lbrakk>\<langle>C, x\<rangle>\<in>fold_set(A, B, f, e); \<langle>C, y\<rangle>\<in>fold_set(A, B, f, e)\<rbrakk> \<Longrightarrow> y=x" apply (frule fold_set.dom_subset [THEN subsetD], clarify) apply (drule Fin_into_Finite) apply (unfold Finite_def, clarify) apply (rule_tac n = "succ (n)" in fold_set_determ_lemma) apply (auto intro: eqpoll_imp_lepoll [THEN lepoll_cardinal_le]) done (** The fold function **) lemma (in fold_typing) fold_equality: "\<langle>C,y\<rangle> \<in> fold_set(A,B,f,e) \<Longrightarrow> fold[B](f,e,C) = y" unfolding fold_def apply (frule fold_set.dom_subset [THEN subsetD], clarify) apply (rule the_equality) apply (rule_tac [2] A=C in fold_typing.fold_set_determ) apply (force dest: fold_set_lemma) apply (auto dest: fold_set_lemma) apply (simp add: fold_typing_def, auto) apply (auto dest: fold_set_lemma intro: ftype etype fcomm) done lemma fold_0 [simp]: "e \<in> B \<Longrightarrow> fold[B](f,e,0) = e" unfolding fold_def apply (blast elim!: empty_fold_setE intro: fold_set.intros) done text\<open>This result is the right-to-left direction of the subsequent result\<close> lemma (in fold_typing) fold_set_imp_cons: "\<lbrakk>\<langle>C, y\<rangle> \<in> fold_set(C, B, f, e); C \<in> Fin(A); c \<in> A; c\<notin>C\<rbrakk> \<Longrightarrow> <cons(c, C), f(c,y)> \<in> fold_set(cons(c, C), B, f, e)" apply (frule FinD [THEN fold_set_mono, THEN subsetD]) apply assumption apply (frule fold_set.dom_subset [of A, THEN subsetD]) apply (blast intro!: fold_set.consI intro: fold_set_mono [THEN subsetD]) done lemma (in fold_typing) fold_cons_lemma [rule_format]: "\<lbrakk>C \<in> Fin(A); c \<in> A; c\<notin>C\<rbrakk> \<Longrightarrow> <cons(c, C), v> \<in> fold_set(cons(c, C), B, f, e) \<longleftrightarrow> (\<exists>y. \<langle>C, y\<rangle> \<in> fold_set(C, B, f, e) \<and> v = f(c, y))" apply auto prefer 2 apply (blast intro: fold_set_imp_cons) apply (frule_tac Fin.consI [of c, THEN FinD, THEN fold_set_mono, THEN subsetD], assumption+) apply (frule_tac fold_set.dom_subset [of A, THEN subsetD]) apply (drule FinD) apply (rule_tac A1 = "cons(c,C)" and f1=f and B1=B and C1=C and e1=e in fold_typing.Fin_imp_fold_set [THEN exE]) apply (blast intro: fold_typing.intro ftype etype fcomm) apply (blast intro: Fin_subset [of _ "cons(c,C)"] Finite_into_Fin dest: Fin_into_Finite) apply (rule_tac x = x in exI) apply (auto intro: fold_set.intros) apply (drule_tac fold_set_lemma [of C], blast) apply (blast intro!: fold_set.consI intro: fold_set_determ fold_set_mono [THEN subsetD] dest: fold_set.dom_subset [THEN subsetD]) done lemma (in fold_typing) fold_cons: "\<lbrakk>C\<in>Fin(A); c\<in>A; c\<notin>C\<rbrakk> \<Longrightarrow> fold[B](f, e, cons(c, C)) = f(c, fold[B](f, e, C))" unfolding fold_def apply (simp add: fold_cons_lemma) apply (rule the_equality, auto) apply (subgoal_tac [2] "\<langle>C, y\<rangle> \<in> fold_set(A, B, f, e)") apply (drule Fin_imp_fold_set) apply (auto dest: fold_set_lemma simp add: fold_def [symmetric] fold_equality) apply (blast intro: fold_set_mono [THEN subsetD] dest!: FinD) done lemma (in fold_typing) fold_type [simp,TC]: "C\<in>Fin(A) \<Longrightarrow> fold[B](f,e,C):B" apply (erule Fin_induct) apply (simp_all add: fold_cons ftype etype) done lemma (in fold_typing) fold_commute [rule_format]: "\<lbrakk>C\<in>Fin(A); c\<in>A\<rbrakk> \<Longrightarrow> (\<forall>y\<in>B. f(c, fold[B](f, y, C)) = fold[B](f, f(c, y), C))" apply (erule Fin_induct) apply (simp_all add: fold_typing.fold_cons [of A B _ f] fold_typing.fold_type [of A B _ f] fold_typing_def fcomm) done lemma (in fold_typing) fold_nest_Un_Int: "\<lbrakk>C\<in>Fin(A); D\<in>Fin(A)\<rbrakk> \<Longrightarrow> fold[B](f, fold[B](f, e, D), C) = fold[B](f, fold[B](f, e, (C \<inter> D)), C \<union> D)" apply (erule Fin_induct, auto) apply (simp add: Un_cons Int_cons_left fold_type fold_commute fold_typing.fold_cons [of A _ _ f] fold_typing_def fcomm cons_absorb) done lemma (in fold_typing) fold_nest_Un_disjoint: "\<lbrakk>C\<in>Fin(A); D\<in>Fin(A); C \<inter> D = 0\<rbrakk> \<Longrightarrow> fold[B](f,e,C \<union> D) = fold[B](f, fold[B](f,e,D), C)" by (simp add: fold_nest_Un_Int) lemma Finite_cons_lemma: "Finite(C) \<Longrightarrow> C\<in>Fin(cons(c, C))" apply (drule Finite_into_Fin) apply (blast intro: Fin_mono [THEN subsetD]) done subsection\<open>The Operator \<^term>\<open>setsum\<close>\<close> lemma setsum_0 [simp]: "setsum(g, 0) = #0" by (simp add: setsum_def) lemma setsum_cons [simp]: "Finite(C) \<Longrightarrow> setsum(g, cons(c,C)) = (if c \<in> C then setsum(g,C) else g(c) $+ setsum(g,C))" apply (auto simp add: setsum_def Finite_cons cons_absorb) apply (rule_tac A = "cons (c, C)" in fold_typing.fold_cons) apply (auto intro: fold_typing.intro Finite_cons_lemma) done lemma setsum_K0: "setsum((\<lambda>i. #0), C) = #0" apply (case_tac "Finite (C) ") prefer 2 apply (simp add: setsum_def) apply (erule Finite_induct, auto) done (*The reversed orientation looks more natural, but LOOPS as a simprule!*) lemma setsum_Un_Int: "\<lbrakk>Finite(C); Finite(D)\<rbrakk> \<Longrightarrow> setsum(g, C \<union> D) $+ setsum(g, C \<inter> D) = setsum(g, C) $+ setsum(g, D)" apply (erule Finite_induct) apply (simp_all add: Int_cons_right cons_absorb Un_cons Int_commute Finite_Un Int_lower1 [THEN subset_Finite]) done lemma setsum_type [simp,TC]: "setsum(g, C):int" apply (case_tac "Finite (C) ") prefer 2 apply (simp add: setsum_def) apply (erule Finite_induct, auto) done lemma setsum_Un_disjoint: "\<lbrakk>Finite(C); Finite(D); C \<inter> D = 0\<rbrakk> \<Longrightarrow> setsum(g, C \<union> D) = setsum(g, C) $+ setsum(g,D)" apply (subst setsum_Un_Int [symmetric]) apply (subgoal_tac [3] "Finite (C \<union> D) ") apply (auto intro: Finite_Un) done lemma Finite_RepFun [rule_format (no_asm)]: "Finite(I) \<Longrightarrow> (\<forall>i\<in>I. Finite(C(i))) \<longrightarrow> Finite(RepFun(I, C))" apply (erule Finite_induct, auto) done lemma setsum_UN_disjoint [rule_format (no_asm)]: "Finite(I) \<Longrightarrow> (\<forall>i\<in>I. Finite(C(i))) \<longrightarrow> (\<forall>i\<in>I. \<forall>j\<in>I. i\<noteq>j \<longrightarrow> C(i) \<inter> C(j) = 0) \<longrightarrow> setsum(f, \<Union>i\<in>I. C(i)) = setsum (\<lambda>i. setsum(f, C(i)), I)" apply (erule Finite_induct, auto) apply (subgoal_tac "\<forall>i\<in>B. x \<noteq> i") prefer 2 apply blast apply (subgoal_tac "C (x) \<inter> (\<Union>i\<in>B. C (i)) = 0") prefer 2 apply blast apply (subgoal_tac "Finite (\<Union>i\<in>B. C (i)) \<and> Finite (C (x)) \<and> Finite (B) ") apply (simp (no_asm_simp) add: setsum_Un_disjoint) apply (auto intro: Finite_Union Finite_RepFun) done lemma setsum_addf: "setsum(\<lambda>x. f(x) $+ g(x),C) = setsum(f, C) $+ setsum(g, C)" apply (case_tac "Finite (C) ") prefer 2 apply (simp add: setsum_def) apply (erule Finite_induct, auto) done lemma fold_set_cong: "\<lbrakk>A=A'; B=B'; e=e'; (\<forall>x\<in>A'. \<forall>y\<in>B'. f(x,y) = f'(x,y))\<rbrakk> \<Longrightarrow> fold_set(A,B,f,e) = fold_set(A',B',f',e')" apply (simp add: fold_set_def) apply (intro refl iff_refl lfp_cong Collect_cong disj_cong ex_cong, auto) done lemma fold_cong: "\<lbrakk>B=B'; A=A'; e=e'; \<And>x y. \<lbrakk>x\<in>A'; y\<in>B'\<rbrakk> \<Longrightarrow> f(x,y) = f'(x,y)\<rbrakk> \<Longrightarrow> fold[B](f,e,A) = fold[B'](f', e', A')" apply (simp add: fold_def) apply (subst fold_set_cong) apply (rule_tac [5] refl, simp_all) done lemma setsum_cong: "\<lbrakk>A=B; \<And>x. x\<in>B \<Longrightarrow> f(x) = g(x)\<rbrakk> \<Longrightarrow> setsum(f, A) = setsum(g, B)" by (simp add: setsum_def cong add: fold_cong) lemma setsum_Un: "\<lbrakk>Finite(A); Finite(B)\<rbrakk> \<Longrightarrow> setsum(f, A \<union> B) = setsum(f, A) $+ setsum(f, B) $- setsum(f, A \<inter> B)" apply (subst setsum_Un_Int [symmetric], auto) done lemma setsum_zneg_or_0 [rule_format (no_asm)]: "Finite(A) \<Longrightarrow> (\<forall>x\<in>A. g(x) $\<le> #0) \<longrightarrow> setsum(g, A) $\<le> #0" apply (erule Finite_induct) apply (auto intro: zneg_or_0_add_zneg_or_0_imp_zneg_or_0) done lemma setsum_succD_lemma [rule_format]: "Finite(A) \<Longrightarrow> \<forall>n\<in>nat. setsum(f,A) = $# succ(n) \<longrightarrow> (\<exists>a\<in>A. #0 $< f(a))" apply (erule Finite_induct) apply (auto simp del: int_of_0 int_of_succ simp add: not_zless_iff_zle int_of_0 [symmetric]) apply (subgoal_tac "setsum (f, B) $\<le> #0") apply simp_all prefer 2 apply (blast intro: setsum_zneg_or_0) apply (subgoal_tac "$# 1 $\<le> f (x) $+ setsum (f, B) ") apply (drule zdiff_zle_iff [THEN iffD2]) apply (subgoal_tac "$# 1 $\<le> $# 1 $- setsum (f,B) ") apply (drule_tac x = "$# 1" in zle_trans) apply (rule_tac [2] j = "#1" in zless_zle_trans, auto) done lemma setsum_succD: "\<lbrakk>setsum(f, A) = $# succ(n); n\<in>nat\<rbrakk>\<Longrightarrow> \<exists>a\<in>A. #0 $< f(a)" apply (case_tac "Finite (A) ") apply (blast intro: setsum_succD_lemma) unfolding setsum_def apply (auto simp del: int_of_0 int_of_succ simp add: int_succ_int_1 [symmetric] int_of_0 [symmetric]) done lemma g_zpos_imp_setsum_zpos [rule_format]: "Finite(A) \<Longrightarrow> (\<forall>x\<in>A. #0 $\<le> g(x)) \<longrightarrow> #0 $\<le> setsum(g, A)" apply (erule Finite_induct) apply (simp (no_asm)) apply (auto intro: zpos_add_zpos_imp_zpos) done lemma g_zpos_imp_setsum_zpos2 [rule_format]: "\<lbrakk>Finite(A); \<forall>x. #0 $\<le> g(x)\<rbrakk> \<Longrightarrow> #0 $\<le> setsum(g, A)" apply (erule Finite_induct) apply (auto intro: zpos_add_zpos_imp_zpos) done lemma g_zspos_imp_setsum_zspos [rule_format]: "Finite(A) \<Longrightarrow> (\<forall>x\<in>A. #0 $< g(x)) \<longrightarrow> A \<noteq> 0 \<longrightarrow> (#0 $< setsum(g, A))" apply (erule Finite_induct) apply (auto intro: zspos_add_zspos_imp_zspos) done lemma setsum_Diff [rule_format]: "Finite(A) \<Longrightarrow> \<forall>a. M(a) = #0 \<longrightarrow> setsum(M, A) = setsum(M, A-{a})" apply (erule Finite_induct) apply (simp_all add: Diff_cons_eq Finite_Diff) done end
data 'carb' (0) { $"0000 0000" /* g... */ };
\par \section{Data Structure} \label{section:Tree:dataStructure} \par The {\tt Tree} object has a very simple data structure. The value {\tt -1} is used to denote a null pointer for the parent, first child and sibling fields. \begin{itemize} \item {\tt int n} : size of the tree \item {\tt int root} : root of the tree, in range {\tt [0,n-1]}, in the range {\tt [-1,n-1]} \item {\tt int *par} : pointer to parent vector, size {\tt n}, entries in the range {\tt [-1,n-1]} \item {\tt int *fch} : pointer to first child vector, size {\tt n}, entries in the range {\tt [-1,n-1]} \item {\tt int *sib} : pointer to sibling vector, size {\tt n}, entries in the range {\tt [-1,n-1]} \end{itemize} The user should rarely if ever change these five fields. In particular, throughout the code we assume that the {\tt Tree} object was correctly initialized using one of the three initializer methods. Inside almost every method we check to ensure $n > 0$. If $n > 0$ then we assume that the structure was intialized correctly and that the {\tt par}, {\tt fch} and {\tt sib} fields point to storage that was allocated by the initializer method.
State Before: a b c : β„š n : β„€ ⊒ mkRat n 1 = ↑n State After: no goals Tactic: simp [Rat.mkRat_eq, Rat.divInt_one]
(* Author(s): Andrej Dudenhefner (1) Affiliation(s): (1) TU Dortmund University, Dortmund, Germany *) (* If a relation R is MMA_mon_computable then it is TM_computable. Monotonicity of the first counter is needed because a TM cannot erase (only replace) type symbols. *) From Undecidability.TM Require Import TM. From Undecidability.TM Require Util.TM_facts Util.TM_computable. From Undecidability.MinskyMachines Require Import MM MMA.mma_defs Reductions.MMA_computable_to_MMA_mon_computable. From Undecidability.Shared.Libs.DLW Require Import Vec.pos Vec.vec Code.sss Code.subcode. Require Import Undecidability.Shared.Libs.PSL.FiniteTypes.FinTypesDef. From Undecidability.Shared.Libs.PSL Require Import CompoundFinTypes. Require Import Undecidability.Shared.Libs.PSL.EqDec. From Undecidability Require Shared.deterministic_simulation. Module Sim := deterministic_simulation. Require Import List Lia PeanoNat Compare_dec Relations. Import ListNotations. Require Import ssreflect ssrbool ssrfun. Set Default Goal Selector "!". #[local] Unset Implicit Arguments. #[local] Notation enc := (encNatTM true false). (* generic auxiliary facts *) Module Facts. (* transforms a goal (A -> B) -> C into goals A and B -> C *) Lemma unnest : forall (A B C : Type), A -> (B -> C) -> (A -> B) -> C. Proof. auto. Qed. Lemma vec_Forall2_append {X Y : Type} {P : X -> Y -> Prop} {n m : nat} {v : Vector.t X n} {w : Vector.t X m} {v' w'} : Vector.Forall2 P v v' -> Vector.Forall2 P w w' -> Vector.Forall2 P (Vector.append v w) (Vector.append v' w'). Proof. elim. { done. } move=> > ? _ /[apply] ?. by constructor. Qed. Lemma vec_Forall2_forall {X Y : Type} {P : X -> Y -> Prop} {n : nat} {v : Vector.t X n} {w : Vector.t Y n} : (forall i, P (Vector.nth v i) (Vector.nth w i)) <-> Vector.Forall2 P v w. Proof. split. - elim: v w. + move=> w ?. rewrite (vec_0_nil w). by constructor. + move=> > IH w. rewrite (Vector.eta w) => IH'. constructor. * by apply: (IH' pos0). * apply: IH => i. by apply: (IH' (pos_nxt i)). - elim. { by apply: Fin.case0. } move=> > ? _ IH i. have [->|[j ->]] := pos_S_inv i. + done. + by apply: IH. Qed. Lemma split_nth_error {X : Type} {l : list X} {ls x rs} : l = ls ++ x :: rs -> nth_error l (length ls) = Some x. Proof. move=> ->. by elim: ls. Qed. Lemma vec_pos_nth_eq {X : Type} {n} {v : Vector.t X n} {i} : vec_pos v i = Vector.nth v i. Proof. elim: v i. { by apply: Fin.case0. } move=> > IH i. have [->|[? ->]] := pos_S_inv i. - done. - apply: IH. Qed. End Facts. Import Facts. Module Argument. Section HaltTM_MMA_HALTING. Context {n : nat} (M : list (mm_instr (Fin.t (S n)))). Context (M_mon : forall l x q r, M = l ++ DEC x q :: r -> x <> pos0). #[local] Notation maxState := (S (length M)). Definition Ξ£ : finType := finType_CS bool. Definition state' : finType := finType_CS (bool * Fin.t maxState). Definition toAddress (p : nat) : Fin.t maxState := if le_lt_dec maxState p is right H then Fin.of_nat_lt H else Fin.F1. Definition toState (d : bool) (p : nat) : state' := (d, toAddress p). (* INC : write true, move left; write false DEC : move right ; write false *) Definition trans' : state' * Vector.t (option Ξ£) (S n) -> state' * Vector.t (option Ξ£ * move) (S n) := fun '((d, p), bs) => match sval (Fin.to_nat p) with | 0 => match d with | false => ((d, p), TM_facts.nop_action) | true => (toState false 1, Vector.const (Some false, Nmove) (S n)) end | S m' => match nth_error M m' with | None => ((d, p), TM_facts.nop_action) | Some (mm_inc i) => match d with | false => ((true, p), vec_change TM_facts.nop_action i (Some true, Lmove)) | true => (toState false (S (S m')), vec_change TM_facts.nop_action i (Some false, Nmove)) end | Some (mm_dec i q) => match d with | false => ((true, p), vec_change TM_facts.nop_action i (None, Rmove)) | true => match Vector.nth bs i with | Some true => (toState false q, vec_change TM_facts.nop_action i (Some false, Nmove)) | _ => (toState false (S (S m')), vec_change TM_facts.nop_action i (Some false, Nmove)) end end end end. #[local] Opaque le_lt_dec Fin.of_nat_lt. Definition halt' (q : bool * Fin.t maxState) := (negb (fst q)) && Fin.eqb (@Fin.F1 (length M)) (snd q). Definition P : TM Ξ£ (S n) := {| state := state'; trans := trans'; start := (true, pos0); halt := halt' |}. Inductive encodes_counter (c : nat) : tape Ξ£ -> Prop := | encodes_counter_intro m : encodes_counter c (midtape (repeat false m) false (repeat true c)). #[local] Notation encodes_counters cs ts := (Vector.Forall2 encodes_counter cs ts). #[local] Notation step1 := (sss_step (@mma_sss (S n)) (1, M)). #[local] Notation step2 := (fun x y => halt' (TM_facts.cstate x) = false /\ y = @TM_facts.step _ _ P x). #[local] Notation "P // s ->> t" := (sss_compute (@mma_sss _) P s t). Inductive sync : nat * Vector.t nat (S n) -> TM_facts.mconfig Ξ£ (state P) (S n) -> Prop := | sync_intro i v bs : encodes_counters v bs -> Vector.nth bs pos0 = enc (Vector.nth v pos0) -> sync (i, v) (TM_facts.mk_mconfig (toState false i) bs). Lemma syncE i v p bs : sync (i, v) (TM_facts.mk_mconfig p bs) -> encodes_counters v bs /\ Vector.nth bs pos0 = enc (Vector.nth v pos0) /\ p = toState false i. Proof. intros H. now inversion H. Qed. Definition inc_bs {n} x (ts : Vector.t (tape Ξ£) (S n)) := TM_facts.doAct_multi (TM_facts.doAct_multi ts (vec_change TM_facts.nop_action x (Some true, Lmove))) (vec_change TM_facts.nop_action x (Some false, Nmove)). Definition dec_bs {n} x (ts : Vector.t (tape Ξ£) (S n)) := TM_facts.doAct_multi (TM_facts.doAct_multi ts (vec_change TM_facts.nop_action x (None, Rmove))) (vec_change TM_facts.nop_action x (Some false, Nmove)). Lemma to_nat_toAddress {l instr r} : M = l ++ instr :: r -> sval (Fin.to_nat (toAddress (S (length l)))) = S (length l). Proof. move=> HM. rewrite /toAddress /=. case: (le_lt_dec maxState (S (length l))). - move: HM => /(f_equal (@length _)). rewrite app_length /=. lia. - move=> ?. by rewrite Fin.to_nat_of_nat. Qed. Lemma sync_inc p v i ts : Vector.nth ts pos0 = enc (Vector.nth v pos0) -> encodes_counters v ts -> sync (p, vec_change v i (S (Vector.nth v i))) (TM_facts.mk_mconfig (toState false p) (inc_bs i ts)). Proof. move=> H0vts /vec_Forall2_forall Hvts. apply: sync_intro. - rewrite /inc_bs. apply /vec_Forall2_forall => j. have [<-|Hij] := pos_eq_dec i j. + rewrite /TM_facts.doAct_multi. rewrite !TM_facts.nth_map2'. rewrite -!vec_pos_nth_eq. rewrite !(vec_change_eq _ _ erefl). rewrite !vec_pos_nth_eq. move: (Vector.nth v i) (Vector.nth ts i) (Hvts i). move=> ? ? [] [|?]. * by apply: (encodes_counter_intro _ 0). * by apply: encodes_counter_intro. + rewrite /TM_facts.doAct_multi. rewrite !TM_facts.nth_map2'. rewrite -!vec_pos_nth_eq. rewrite !(vec_change_neq _ _ Hij). rewrite !vec_pos_nth_eq !TM_facts.nth_nop_action. by apply: Hvts. - rewrite /inc_bs. move: H0vts. rewrite (Vector.eta v) (Vector.eta ts). have [->|[j ->]] := pos_S_inv i. + move=> /= ->. by case: (VectorDef.hd v) => /=. + by move=> /= ->. Qed. Lemma sync_dec_0 p v i ts : Vector.nth ts pos0 = enc (Vector.nth v pos0) -> encodes_counters v ts -> Vector.nth v i = 0 -> i <> pos0 -> sync (p, v) (TM_facts.mk_mconfig (toState false p) (dec_bs i ts)). Proof. move=> H0vts /vec_Forall2_forall Hvts Hvi Hi. apply: sync_intro. - rewrite /dec_bs. apply /vec_Forall2_forall => j. have [<-|Hij] := pos_eq_dec i j. + rewrite /TM_facts.doAct_multi. rewrite !TM_facts.nth_map2'. rewrite -!vec_pos_nth_eq. rewrite !(vec_change_eq _ _ erefl). rewrite !vec_pos_nth_eq. move: (Vector.nth v i) (Vector.nth ts i) Hvi (Hvts i). move=> > -> [] m. by apply: (encodes_counter_intro _ (S m)). + rewrite /TM_facts.doAct_multi. rewrite !TM_facts.nth_map2'. rewrite -!vec_pos_nth_eq. rewrite !(vec_change_neq _ _ Hij). rewrite !vec_pos_nth_eq !TM_facts.nth_nop_action. by apply: Hvts. - rewrite /dec_bs. move: H0vts Hi. rewrite (Vector.eta v) (Vector.eta ts). have [->|[j ->]] := pos_S_inv i. + done. + by move=> /= ->. Qed. Lemma sync_dec_S p v i ts k : Vector.nth ts pos0 = enc (Vector.nth v pos0) -> encodes_counters v ts -> Vector.nth v i = S k -> i <> pos0 -> sync (p, vec_change v i k) (TM_facts.mk_mconfig (toState false p) (dec_bs i ts)). Proof. move=> H0vts /vec_Forall2_forall Hvts Hvi Hi. apply: sync_intro. - rewrite /dec_bs. apply /vec_Forall2_forall => j. have [<-|Hij] := pos_eq_dec i j. + rewrite /TM_facts.doAct_multi. rewrite !TM_facts.nth_map2'. rewrite -!vec_pos_nth_eq. rewrite !(vec_change_eq _ _ erefl). rewrite !vec_pos_nth_eq. move: (Vector.nth v i) (Vector.nth ts i) Hvi (Hvts i). move=> > -> [] m. by apply: (encodes_counter_intro _ (S m)). + rewrite /TM_facts.doAct_multi. rewrite !TM_facts.nth_map2'. rewrite -!vec_pos_nth_eq. rewrite !(vec_change_neq _ _ Hij). rewrite !vec_pos_nth_eq !TM_facts.nth_nop_action. by apply: Hvts. - rewrite /dec_bs. move: H0vts Hi. rewrite (Vector.eta v) (Vector.eta ts). have [->|[j ->]] := pos_S_inv i. + done. + by move=> /= ->. Qed. Lemma current_chars_act k (ts : Vector.t (tape Ξ£) k) i actions action : Vector.nth (TM_facts.current_chars (TM_facts.doAct_multi ts (vec_change actions i action))) i = current (TM_facts.doAct (Vector.nth ts i) action). Proof. elim: ts i actions. { by apply: Fin.case0. } move=> t ? ts IH i actions. rewrite (Vector.eta actions). have [->|[j ->]] := pos_S_inv i. - done. - by apply: IH. Qed. Lemma Vector_nth_tapes {k v ts} (i : Fin.t k) : encodes_counters v ts -> exists m, Vector.nth ts i = midtape (repeat false m) false (repeat true (Vector.nth v i)). Proof. move=> H. elim: H i. { by apply: Fin.case0. } move=> > [] > ? IH i. have [->|[j ->]] := pos_S_inv i. - by eexists. - by apply: (IH j). Qed. #[local] Opaque toAddress. #[local] Opaque vec_change TM_facts.nop_action. Lemma fstep (s t : nat * vec nat (S n)) (s' : TM_facts.mconfig Ξ£ (state P) (S n)) : sss_step (@mma_sss _) (1, M) s t -> sync s s' -> exists t', clos_trans _ step2 s' t' /\ sync t t'. Proof using M_mon. move=> [?] [l] [instr] [r] [{}v] [[<- HM]] [->]. move E: ((1 + (length l), v)) => st H. case: H HM E. - (* inc *) move=> ? x ? HM [<- <-]. move: s' => [p ts] /syncE [Hvts [E0 ->]]. exists (TM_facts.mk_mconfig (toState false (1 + (1 + (length l)))) (inc_bs x ts)). split; [apply: t_trans; (apply: t_step; split)|]. + cbn. have := to_nat_toAddress HM. by case: (toAddress (S (length l))). + by rewrite /TM_facts.step /= (to_nat_toAddress HM) (split_nth_error HM). + done. + by rewrite /TM_facts.step /= (to_nat_toAddress HM) (split_nth_error HM). + rewrite vec_pos_nth_eq. by apply: sync_inc. - (* dec_0 *) move=> ? x q v' Hx HM [<- ?]. subst v'. rewrite vec_pos_nth_eq in Hx. move: s' => [p ts] /syncE [Hvts [E0 ->]]. exists (TM_facts.mk_mconfig (toState false (1 + (1 + (length l)))) (dec_bs x ts)). move: (HM) => /M_mon ?. split; [apply: t_trans; (apply: t_step; split)|]. + cbn. have := to_nat_toAddress HM. by case: (toAddress (S (length l))). + by rewrite /TM_facts.step /= (to_nat_toAddress HM) (split_nth_error HM). + done. + rewrite /TM_facts.step /= (to_nat_toAddress HM) (split_nth_error HM). rewrite current_chars_act. have [? ->] := Vector_nth_tapes x Hvts. by rewrite Hx /=. + by apply: sync_dec_0. - (* dec_1 *) move=> ? x q v' ? Hx HM [<- ?]. subst v'. rewrite vec_pos_nth_eq in Hx. move: s' => [p ts] /syncE [Hvts [E0 ->]]. exists (TM_facts.mk_mconfig (toState false q) (dec_bs x ts)). move: (HM) => /M_mon ?. split; [apply: t_trans; (apply: t_step; split)|]. + cbn. have := to_nat_toAddress HM. by case: (toAddress (S (length l))). + by rewrite /TM_facts.step /= (to_nat_toAddress HM) (split_nth_error HM). + done. + rewrite /TM_facts.step /= (to_nat_toAddress HM) (split_nth_error HM). rewrite current_chars_act. have [? ->] := Vector_nth_tapes x Hvts. by rewrite Hx /=. + by apply: sync_dec_S. Qed. Lemma simulation i v i' v' st : (1, M) // (i, v) ->> (i', v') -> sync (i, v) st -> exists st', sync (i', v') st' /\ clos_refl_trans _ step2 st st'. Proof using M_mon. move=> /sss_compute_iff H1 H2. by apply: (Sim.clos_refl_trans_transport fstep H2 H1). Qed. Lemma step2_det s t1 t2 : step2 s t1 -> step2 s t2 -> t1 = t2. Proof. by move=> /= [_ ->] [_ ->]. Qed. Lemma step1_intro s : (exists t, step1 s t) \/ (Sim.stuck step1 s). Proof. have [|] := subcode.in_out_code_dec (fst s) (1, M). - move=> /in_code_step ?. by left. - move=> /out_code_iff ?. by right. Qed. Lemma halt'_terminates s' : halt' (TM_facts.cstate s') = true -> Sim.terminates step2 s'. Proof. move:s' => [[[] p] ts] /=; [done|]. rewrite /halt' /=. have [->|[q ->]] := pos_S_inv p; [|done]. rewrite Nat.eqb_refl /= => _. eexists. split; [apply: rt_refl|]. move=> {}t' /=. rewrite Nat.eqb_refl. by case. Qed. Lemma terminates2I k {s' t' : TM_facts.mconfig Ξ£ (state P) (S n)} : TM_facts.loopM s' k = Some t' -> Sim.terminates step2 s'. Proof. elim: k s'. { move=> s' /= Hs'. apply: halt'_terminates. by case: (halt' (TM_facts.cstate s')) Hs'. } move=> k IH s' /=. case E: (halt' (TM_facts.cstate s')) => []. - move=> ?. by apply: halt'_terminates. - move=> /IH [u'] [? ?]. exists u'. split; [|done]. by apply: rt_trans; [apply: rt_step|eassumption]. Qed. Lemma stuck_step2E s' : Sim.stuck step2 s' -> halt' (TM_facts.cstate s') = true. Proof. move=> Hs'. case E: (halt' (TM_facts.cstate s')); [done|]. exfalso. by apply: (Hs' (@TM_facts.step _ _ P s')). Qed. Lemma terminates2E {s' t' : TM_facts.mconfig Ξ£ (state P) (S n)} : clos_refl_trans _ step2 s' t' -> Sim.stuck step2 t' -> exists k, TM_facts.loopM s' k = Some t'. Proof. move=> /clos_rt_rt1n_iff. elim. - move=> {}s' /stuck_step2E Hs'. exists 0. by rewrite /= Hs'. - move=> > [E ->] _ /[apply] - [k] ?. exists (S k). by rewrite /= E. Qed. #[local] Transparent toAddress. Lemma stuck_step2I {s s'} : sync s s' -> out_code (fst s) (1, M) -> Sim.stuck step2 s'. Proof. case => i v bs _ _ /= Hi t' /=. rewrite /halt' /= /toAddress. case: (le_lt_dec maxState i) => /=. { rewrite Nat.eqb_refl => ?. by case. } move=> H'i. have ? : i = 0 by lia. subst i. suff -> : Fin.of_nat_lt H'i = pos0. { rewrite Nat.eqb_refl. by case. } rewrite [RHS](esym (Fin.of_nat_to_nat_inv pos0)). by apply: Fin.of_nat_ext. Qed. End HaltTM_MMA_HALTING. End Argument. Import Argument. Lemma P_init {k k'} {M : list (mm_instr (pos (1+k+k')))} {v : Vector.t nat k} : @TM_facts.step _ _ (P M) (TM_facts.mk_mconfig (true, pos0) (niltape ## Vector.append (Vector.map enc v) (Vector.const niltape k'))) = TM_facts.mk_mconfig (toState M false 1) (enc 0 ## Vector.append (Vector.map enc v) (Vector.const (enc 0) k')). Proof. cbn. congr TM_facts.mk_mconfig. congr Vector.cons. elim: v. - cbn. elim: (k'). { done. } by move=> > /= ->. - by move=> > /= ->. Qed. Lemma sync_init {k k'} {M : list (mm_instr (pos (1+k+k')))} {v : Vector.t nat k} : @sync _ M (1, Vector.append (0 ## v) (Vector.const 0 k')) (TM_facts.mk_mconfig (toState M false 1) (Vector.append ((enc 0) ## Vector.map enc v) (Vector.const (enc 0) k'))). Proof. apply: sync_intro; [|done] => /=. constructor. { by apply: (encodes_counter_intro _ 0). } apply: vec_Forall2_append. - elim: v. { by constructor. } move=> *. constructor; [|done]. by apply: (encodes_counter_intro _ 0). - clear. elim: k'. { by constructor. } move=> *. constructor; [|done]. by apply: (encodes_counter_intro _ 0). Qed. Theorem MMA_mon_computable_to_TM_computable k (R : Vector.t nat k -> nat -> Prop) : MMA_mon_computable R -> TM_computable R. Proof. move=> /MMA_mon_computable_iff [k'] [M] [H1M [H2M H3M]]. have : forall l x q r, M = l ++ DEC x q :: r -> x <> pos0. { move=> > HM Hi. by move: HM Hi H1M => -> -> /Forall_app [_] /Forall_cons_iff []. } move=> {}H1M. apply /TM_computable.TM_computable_iff. exists k', Argument.Ξ£, true, false. split; [done|]. exists (Argument.P M). split. - move=> v m /H2M [c] [v'] [] /(simulation M H1M) => /(_ _ sync_init). move=> [[p' b's]] [Hst'] /terminates2E + ?. apply: unnest. { by apply: stuck_step2I; eassumption. } move=> [n] Hn. exists p', b's. split. + apply /TM_facts.TM_eval_iff. exists (S n) => /=. by rewrite P_init. + move: Hst' => /syncE. rewrite (Vector.eta b's) /=. by move=> [_ []]. - move=> v q ts /TM_facts.TM_eval_iff [n HPn]. apply: H3M. apply /sss_terminates_iff. apply /(Sim.terminates_reflection (step2_det M) (fstep M H1M) (step1_intro M) sync_init). move: n HPn => [|n]. { done. } rewrite /= P_init. by apply: terminates2I. Qed.
Analysts at B. Riley upgraded Guess?, Inc. (NYSE: GES) from Neutral to Buy. Guess? shares gained 1.35 percent to close at $15.02 on Friday. Analysts at Bank of America upgraded Schlumberger Limited. (NYSE: SLB) from Neutral to Buy. Schlumberger shares rose 1.20 percent to $67.30 in pre-market trading. Raymond James upgraded Dine Brands Global Inc (NYSE: DIN) from Market Perform to Outperform. Dine Brands Global shares rose 1.46 percent to $70.00 in pre-market trading. JP Morgan upgraded Acceleron Pharma Inc (NASDAQ: XLRN) from Neutral to Overweight. Acceleron Pharma shares rose 2.17 percent to close at $42.91 on Friday. Gabelli & Co. upgraded Visteon Corp (NASDAQ: VC) from Hold to Buy. Visteon shares fell 0.74 percent to close at $126.64 on Friday. Wells Fargo upgraded American Water Works Company Inc (NYSE: AWK) from Market Perform to Outperform. American Water Works shares rose 2.40 percent to close at $80.63 on Friday. Susquehanna upgraded Finish Line Inc (NASDAQ: FINL) from Neutral to Positive. Finish Line shares rose 1.26 percent to close at $10.48 on Friday. Analysts at Loop Capital upgraded United Parcel Service, Inc. (NYSE: UPS) from Hold to Buy. UPS shares rose 1.32 percent to $107.00 in pre-market trading. RBC upgraded BP plc (ADR) (NYSE: BP) from Sector Perform to Outperform. BP shares rose 0.62 percent to $40.35 in pre-market trading. Bank of America upgraded Baker Hughes, a GE company (NYSE: BHGE) from Underperform to Neutral. Baker Hughes shares fell 0.04 percent to close at $28.03 on Friday. Analysts at Bank of America downgraded Halliburton Company (NYSE: HAL) from Buy to Neutral. Halliburton shares fell 0.97 percent to $47.98 in pre-market trading. JP Morgan downgraded Zebra Technologies Corp. (NASDAQ: ZBRA) from Overweight to Neutral. Zebra Technologies shares rose 4.92 percent to close at $141.90 on Friday. Societe Generale downgraded General Mills, Inc. (NYSE: GIS) from Hold to Sell. General Mills shares fell 0.91 percent to $52.50 in pre-market trading. JMP Securities downgraded Endo International plc (NASDAQ: ENDP) from Outperform to Market Perform. Endo International shares rose 4.57 percent to close at $6.86 on Friday. Wells Fargo downgraded Aqua America Inc (NYSE: WTR) from Outperform to Market Perform. Aqua America shares rose 2.79 percent to close at $35.00 on Friday. Jefferies downgraded Mattel, Inc. (NASDAQ: MAT) from Hold to Underperform. Mattel shares fell 3.25 percent to $16.10 in pre-market trading. Morgan Stanley downgraded Albemarle Corporation (NYSE: ALB) from Equal-Weight to Underweight. Albemarle shares fell 3.58 percent to $114.50 in pre-market trading. Compass Point downgraded AmTrust Financial Services Inc (NASDAQ: AFSI) from Buy to Neutral. AmTrust Financial shares dropped 1.24 percent to $12.77 in pre-market trading. Lake Street downgraded MiMedx Group Inc (NASDAQ: MDXG) from Buy to Hold. MiMedx shares rose 0.26 percent to $7.85 in pre-market trading. Imperial Capital downgraded Blue Buffalo Pet Products Inc (NASDAQ: BUFF) from Outperform to In-Line. Blue Buffalo Pet Products shares gained 17.23 percent to close at $40.00 on Friday. Morgan Stanley initiated coverage on SAGE Therapeutics Inc (NASDAQ: SAGE) with an Overweight rating. The price target for SAGE Therapeutics is set to $225. SAGE Therapeutics shares closed at $164.15 on Friday. Oppenheimer initiated coverage on Corporacion America Airports SA (NYSE: CAAP) with an Outperform rating. The price target for Corporacion America Airports is set to $23. Corporacion America Airports shares closed at $15.55 on Friday. Analysts at JMP Securities initiated coverage on Sol Gel Technologies Ltd (NASDAQ: SLGL) with a Market Outperform rating. The price target for Sol Gel Technologies is set to $20. Sol Gel Technologies shares closed at $11.13 on Friday. Analysts at Wells Fargo initiated coverage on Landmark Infrastructure Partners LP (NASDAQ: LMRK) with a Market Perform rating. The price target for Landmark Infrastructure Partners is set to $18.50. Landmark Infrastructure Partners closed at $17.75 on Friday. Barclays initiated coverage on VICI Properties Inc (NYSE: VICI) with an Equal-Weight rating. The price target for VICI Properties is set to $22. VICI Properties shares closed at $19.82 on Friday. Morgan Stanley initiated coverage on Chegg Inc (NYSE: CHGG) with an Equal-Weight rating. The price target for Chegg is set to $23. Chegg shares closed at $20.35 on Friday. Analysts at H.C. Wainwright initiated coverage on Intec Pharma Ltd (NASDAQ: NTEC) with a Buy rating. The price target for Intec Pharma is set to $16. Intec Pharma shares closed at $5.70 on Friday.
[STATEMENT] lemma iprop11a: "Fr_1 \<F> \<Longrightarrow> Fr_2 \<F> \<Longrightarrow> Fr_3 \<F> \<Longrightarrow> \<forall>a b. (a \<^bold>\<Rightarrow> (a \<^bold>\<Rightarrow> b)) \<^bold>\<Rightarrow> (a \<^bold>\<Rightarrow> b) \<^bold>\<approx> \<^bold>\<top>" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>Fr_1 \<F>; Fr_2 \<F>; Fr_3 \<F>\<rbrakk> \<Longrightarrow> \<forall>a b w. ((b \<^bold>\<Leftarrow> a) \<^bold>\<Leftarrow> ((b \<^bold>\<Leftarrow> a) \<^bold>\<Leftarrow> a)) w = \<^bold>\<top> w [PROOF STEP] using DTw2 iprop11a' [PROOF STATE] proof (prove) using this: \<lbrakk>Fr_2 \<F>; Fr_3 \<F>\<rbrakk> \<Longrightarrow> \<forall>a. contains (\<lambda>b. \<forall>w. (b \<^bold>\<Leftarrow> a) w = \<^bold>\<top> w) (\<lambda>b. contains b a) Fr_1 \<F> \<Longrightarrow> \<forall>a b. contains (b \<^bold>\<Leftarrow> a) ((b \<^bold>\<Leftarrow> a) \<^bold>\<Leftarrow> a) goal (1 subgoal): 1. \<lbrakk>Fr_1 \<F>; Fr_2 \<F>; Fr_3 \<F>\<rbrakk> \<Longrightarrow> \<forall>a b w. ((b \<^bold>\<Leftarrow> a) \<^bold>\<Leftarrow> ((b \<^bold>\<Leftarrow> a) \<^bold>\<Leftarrow> a)) w = \<^bold>\<top> w [PROOF STEP] by blast
#include <boost/thread/latch.hpp>
(*<*) (* * Copyright 2015, NICTA * * This software may be distributed and modified according to the terms of * the BSD 2-Clause license. Note that NO WARRANTY is provided. * See "LICENSE_BSD2.txt" for details. * * @TAG(NICTA_BSD) *) theory TSO imports Global_Invariants_Lemmas Local_Invariants_Lemmas Tactics begin (*>*) section\<open> Coarse TSO invariants \<close> context gc begin lemma tso_lock_invL[intro]: "\<lbrace> tso_lock_invL \<rbrace> gc" by vcg_jackhammer lemma tso_store_inv[intro]: "\<lbrace> LSTP tso_store_inv \<rbrace> gc" unfolding tso_store_inv_def by vcg_jackhammer lemma mut_tso_lock_invL[intro]: "\<lbrace> mut_m.tso_lock_invL m \<rbrace> gc" by (vcg_chainsaw mut_m.tso_lock_invL_def) end context mut_m begin lemma tso_store_inv[intro]: notes fun_upd_apply[simp] shows "\<lbrace> LSTP tso_store_inv \<rbrace> mutator m" unfolding tso_store_inv_def by vcg_jackhammer lemma gc_tso_lock_invL[intro]: "\<lbrace> gc.tso_lock_invL \<rbrace> mutator m" by (vcg_chainsaw gc.tso_lock_invL_def) lemma tso_lock_invL[intro]: "\<lbrace> tso_lock_invL \<rbrace> mutator m" by vcg_jackhammer end context mut_m' begin lemma tso_lock_invL[intro]: "\<lbrace> tso_lock_invL \<rbrace> mutator m'" by (vcg_chainsaw tso_lock_invL) end context sys begin lemma tso_gc_store_inv[intro]: notes fun_upd_apply[simp] shows "\<lbrace> LSTP tso_store_inv \<rbrace> sys" apply (vcg_chainsaw tso_store_inv_def) apply (metis (no_types) list.set_intros(2)) done lemma gc_tso_lock_invL[intro]: "\<lbrace> gc.tso_lock_invL \<rbrace> sys" by (vcg_chainsaw gc.tso_lock_invL_def) lemma mut_tso_lock_invL[intro]: "\<lbrace> mut_m.tso_lock_invL m \<rbrace> sys" by (vcg_chainsaw mut_m.tso_lock_invL_def) end (*<*) end (*>*)
(* Title: Test Iterings Author: Walter Guttmann Maintainer: Walter Guttmann <walter.guttmann at canterbury.ac.nz> *) section \<open>Test Iterings\<close> theory Test_Iterings imports Stone_Kleene_Relation_Algebras.Iterings Tests begin class test_itering = itering + tests + while + assumes while_def: "p \<star> y = (p * y)\<^sup>\<circ> * -p" begin lemma wnf_lemma_5: "(-p \<squnion> -q) * (-q * x \<squnion> --q * y) = -q * x \<squnion> --q * -p * y" by (smt (z3) mult_left_dist_sup sup_commute tests_dual.sba_dual.sub_sup_closed tests_dual.sba_dual.sup_complement_intro tests_dual.sba_dual.sup_idempotent tests_dual.sup_idempotent mult_assoc tests_dual.wnf_lemma_3) lemma test_case_split_left_equal: "-z * x = -z * y \<Longrightarrow> --z * x = --z * y \<Longrightarrow> x = y" by (metis case_split_left_equal tests_dual.inf_complement) lemma preserves_equation: "-y * x \<le> x * -y \<longleftrightarrow> -y * x = -y * x * -y" apply (rule iffI) apply (simp add: test_preserves_equation tests_dual.sub_bot_least) by (simp add: test_preserves_equation tests_dual.sub_bot_least) text \<open>Theorem 5\<close> lemma preserve_test: "-y * x \<le> x * -y \<Longrightarrow> -y * x\<^sup>\<circ> = -y * x\<^sup>\<circ> * -y" using circ_simulate preserves_equation by blast text \<open>Theorem 5\<close> lemma import_test: "-y * x \<le> x * -y \<Longrightarrow> -y * x\<^sup>\<circ> = -y * (-y * x)\<^sup>\<circ>" by (simp add: circ_import tests_dual.sub_bot_least) definition ite :: "'a \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'a" ("_ \<lhd> _ \<rhd> _" [58,58,58] 57) where "x \<lhd> p \<rhd> y \<equiv> p * x \<squnion> -p * y" definition it :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" ("_ \<rhd> _" [58,58] 57) where "p \<rhd> x \<equiv> p * x \<squnion> -p" (* definition while :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixr "\<star>" 59) where "p \<star> y \<equiv> (p * y)\<^sup>\<circ> * -p" *) definition assigns :: "'a \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> bool" where "assigns x p q \<equiv> x = x * (p * q \<squnion> -p * -q)" definition preserves :: "'a \<Rightarrow> 'a \<Rightarrow> bool" where "preserves x p \<equiv> p * x \<le> x * p \<and> -p * x \<le> x * -p" lemma ite_neg: "x \<lhd> -p \<rhd> y = y \<lhd> --p \<rhd> x" by (simp add: ite_def sup_commute) lemma ite_import_true: "x \<lhd> -p \<rhd> y = -p * x \<lhd> -p \<rhd> y" by (metis ite_def tests_dual.sup_idempotent mult_assoc) lemma ite_import_false: "x \<lhd> -p \<rhd> y = x \<lhd> -p \<rhd> --p * y" by (metis ite_import_true ite_neg) lemma ite_import_true_false: "x \<lhd> -p \<rhd> y = -p * x \<lhd> -p \<rhd> --p * y" using ite_import_false ite_import_true by auto lemma ite_context_true: "-p * (x \<lhd> -p \<rhd> y) = -p * x" by (metis sup_monoid.add_0_left tests_dual.sup_right_zero tests_dual.top_double_complement wnf_lemma_5 sup_bot_right ite_def mult_assoc mult_left_zero) lemma ite_context_false: "--p * (x \<lhd> -p \<rhd> y) = --p * y" by (metis ite_neg ite_context_true) lemma ite_context_import: "-p * (x \<lhd> -q \<rhd> y) = -p * (x \<lhd> -p * -q \<rhd> y)" by (smt ite_def mult_assoc tests_dual.sup_complement_intro tests_dual.sub_sup_demorgan tests_dual.sup_idempotent mult_left_dist_sup) lemma ite_conjunction: "(x \<lhd> -q \<rhd> y) \<lhd> -p \<rhd> y = x \<lhd> -p * -q \<rhd> y" by (smt sup_assoc sup_commute ite_def mult_assoc tests_dual.sub_sup_demorgan mult_left_dist_sup mult_right_dist_sup tests_dual.inf_complement_intro) lemma ite_disjunction: "x \<lhd> -p \<rhd> (x \<lhd> -q \<rhd> y) = x \<lhd> -p \<squnion> -q \<rhd> y" by (smt (z3) tests_dual.sba_dual.sub_sup_closed sup_assoc ite_def mult_assoc tests_dual.sup_complement_intro tests_dual.sub_sup_demorgan mult_left_dist_sup mult_right_dist_sup tests_dual.inf_demorgan) lemma wnf_lemma_6: "(-p \<squnion> -q) * (x \<lhd> --p * -q \<rhd> y) = (-p \<squnion> -q) * (y \<lhd> -p \<rhd> x)" by (smt (z3) ite_conjunction ite_context_false ite_context_true semiring.distrib_right tests_dual.sba_dual.inf_cases_2 tests_dual.sba_dual.sub_inf_def tests_dual.sba_dual.sup_complement_intro tests_dual.sub_complement) lemma it_ite: "-p \<rhd> x = x \<lhd> -p \<rhd> 1" by (simp add: it_def ite_def) lemma it_neg: "--p \<rhd> x = 1 \<lhd> -p \<rhd> x" using it_ite ite_neg by auto lemma it_import_true: "-p \<rhd> x = -p \<rhd> -p * x" using it_ite ite_import_true by auto lemma it_context_true: "-p * (-p \<rhd> x) = -p * x" by (simp add: it_ite ite_context_true) lemma it_context_false: "--p * (-p \<rhd> x) = --p" using it_ite ite_context_false by force lemma while_unfold_it: "-p \<star> x = -p \<rhd> x * (-p \<star> x)" by (metis circ_loop_fixpoint it_def mult_assoc while_def) lemma while_context_false: "--p * (-p \<star> x) = --p" by (metis it_context_false while_unfold_it) lemma while_context_true: "-p * (-p \<star> x) = -p * x * (-p \<star> x)" by (metis it_context_true mult_assoc while_unfold_it) lemma while_zero: "bot \<star> x = 1" by (metis circ_zero mult_left_one mult_left_zero one_def while_def) lemma wnf_lemma_7: "1 * (bot \<star> 1) = 1" by (simp add: while_zero) lemma while_import_condition: "-p \<star> x = -p \<star> -p * x" by (metis mult_assoc tests_dual.sup_idempotent while_def) lemma while_import_condition_2: "-p * -q \<star> x = -p * -q \<star> -p * x" by (metis mult_assoc tests_dual.sup_idempotent sub_comm while_def) lemma wnf_lemma_8: "-r * (-p \<squnion> --p * -q) \<star> (x \<lhd> --p * -q \<rhd> y) = -r * (-p \<squnion> -q) \<star> (y \<lhd> -p \<rhd> x)" by (metis mult_assoc while_def wnf_lemma_6 tests_dual.sba_dual.sup_complement_intro) text \<open>Theorem 6 - see Theorem 31 on page 329 of Back and von Wright, Acta Informatica 36:295-334, 1999\<close> lemma split_merge_loops: assumes "--p * y \<le> y * --p" shows "(-p \<squnion> -q) \<star> (x \<lhd> -p \<rhd> y) = (-p \<star> x) * (-q \<star> y)" proof - have "-p \<squnion> -q \<star> (x \<lhd> -p \<rhd> y) = (-p * x \<squnion> --p * -q * y)\<^sup>\<circ> * --p * --q" by (smt ite_def mult_assoc sup_commute tests_dual.inf_demorgan while_def wnf_lemma_5) thus ?thesis by (smt assms circ_sup_1 circ_slide import_test mult_assoc preserves_equation sub_comm while_context_false while_def) qed lemma assigns_same: "assigns x (-p) (-p)" by (simp add: assigns_def) lemma preserves_equation_test: "preserves x (-p) \<longleftrightarrow> -p * x = -p * x * -p \<and> --p * x = --p * x * --p" using preserves_def preserves_equation by auto lemma preserves_test: "preserves (-q) (-p)" using tests_dual.sub_commutative preserves_def by auto lemma preserves_zero: "preserves bot (-p)" using tests_dual.sba_dual.sub_bot_def preserves_test by blast lemma preserves_one: "preserves 1 (-p)" using preserves_def by force lemma preserves_sup: "preserves x (-p) \<Longrightarrow> preserves y (-p) \<Longrightarrow> preserves (x \<squnion> y) (-p)" by (simp add: mult_left_dist_sup mult_right_dist_sup preserves_equation_test) lemma preserves_mult: "preserves x (-p) \<Longrightarrow> preserves y (-p) \<Longrightarrow> preserves (x * y) (-p)" by (smt (verit, best) mult_assoc preserves_equation_test) lemma preserves_ite: "preserves x (-p) \<Longrightarrow> preserves y (-p) \<Longrightarrow> preserves (x \<lhd> -q \<rhd> y) (-p)" by (simp add: ite_def preserves_mult preserves_sup preserves_test) lemma preserves_it: "preserves x (-p) \<Longrightarrow> preserves (-q \<rhd> x) (-p)" by (simp add: it_ite preserves_ite preserves_one) lemma preserves_circ: "preserves x (-p) \<Longrightarrow> preserves (x\<^sup>\<circ>) (-p)" by (meson circ_simulate preserves_def) lemma preserves_while: "preserves x (-p) \<Longrightarrow> preserves (-q \<star> x) (-p)" using while_def preserves_circ preserves_mult preserves_test by auto lemma preserves_test_neg: "preserves x (-p) \<Longrightarrow> preserves x (--p)" using preserves_def by auto lemma preserves_import_circ: "preserves x (-p) \<Longrightarrow> -p * x\<^sup>\<circ> = -p * (-p * x)\<^sup>\<circ>" using import_test preserves_def by blast lemma preserves_simulate: "preserves x (-p) \<Longrightarrow> -p * x\<^sup>\<circ> = -p * x\<^sup>\<circ> * -p" using preserve_test preserves_def by auto lemma preserves_import_ite: assumes "preserves z (-p)" shows "z * (x \<lhd> -p \<rhd> y) = z * x \<lhd> -p \<rhd> z * y" proof - have 1: "-p * z * (x \<lhd> -p \<rhd> y) = -p * (z * x \<lhd> -p \<rhd> z * y)" by (smt assms ite_context_true mult_assoc preserves_equation_test) have "--p * z * (x \<lhd> -p \<rhd> y) = --p * (z * x \<lhd> -p \<rhd> z * y)" by (smt (z3) assms ite_context_false mult_assoc preserves_equation_test) thus ?thesis using 1 by (metis mult_assoc test_case_split_left_equal) qed lemma preserves_while_context: "preserves x (-p) \<Longrightarrow> -p * (-q \<star> x) = -p * (-p * -q \<star> x)" by (smt (verit, del_insts) mult_assoc tests_dual.sup_complement_intro tests_dual.sub_sup_demorgan preserves_import_circ preserves_mult preserves_simulate preserves_test while_def) lemma while_ite_context_false: assumes "preserves y (-p)" shows "--p * (-p \<squnion> -q \<star> (x \<lhd> -p \<rhd> y)) = --p * (-q \<star> y)" proof - have "--p * (-p \<squnion> -q \<star> (x \<lhd> -p \<rhd> y)) = --p * (--p * -q * y)\<^sup>\<circ> * -(-p \<squnion> -q)" by (smt (z3) assms import_test mult_assoc preserves_equation preserves_equation_test sub_comm while_def tests_dual.sba_dual.sub_sup_demorgan preserves_test split_merge_loops while_context_false) thus ?thesis by (metis (no_types, lifting) assms preserves_def mult.assoc split_merge_loops while_context_false) qed text \<open>Theorem 7.1\<close> lemma while_ite_norm: assumes "assigns z (-p) (-q)" and "preserves x1 (-q)" and "preserves x2 (-q)" and "preserves y1 (-q)" and "preserves y2 (-q)" shows "z * (x1 * (-r1 \<star> y1) \<lhd> -p \<rhd> x2 * (-r2 \<star> y2)) = z * (x1 \<lhd> -q \<rhd> x2) * ((-q * -r1 \<squnion> --q * -r2) \<star> (y1 \<lhd> -q \<rhd> y2))" proof - have 1: "-(-q * -r1 \<squnion> --q * -r2) = -q * --r1 \<squnion> --q * --r2" by (smt (z3) tests_dual.complement_2 tests_dual.sub_sup_closed tests_dual.case_duality tests_dual.sub_sup_demorgan) have "-p * -q * x1 * (-q * -r1 * y1 \<squnion> --q * -r2 * y2)\<^sup>\<circ> * (-q * --r1 \<squnion> --q * --r2) = -p * -q * x1 * -q * (-q * (-q * -r1 * y1 \<squnion> --q * -r2 * y2))\<^sup>\<circ> * (-q * --r1 \<squnion> --q * --r2)" by (smt (verit, del_insts) assms(2,4,5) mult_assoc preserves_sup preserves_equation_test preserves_import_circ preserves_mult preserves_test) also have "... = -p * -q * x1 * -q * (-q * -r1 * y1)\<^sup>\<circ> * (-q * --r1 \<squnion> --q * --r2)" using ite_context_true ite_def mult_assoc by auto finally have 2: "-p * -q * x1 * (-q * -r1 * y1 \<squnion> --q * -r2 * y2)\<^sup>\<circ> * (-q * --r1 \<squnion> --q * --r2) = -p * -q * x1 * (-r1 * y1)\<^sup>\<circ> * --r1" by (smt (verit, del_insts) assms ite_context_true ite_def mult_assoc preserves_equation_test preserves_import_circ preserves_mult preserves_simulate preserves_test) have "--p * --q * x2 * (-q * -r1 * y1 \<squnion> --q * -r2 * y2)\<^sup>\<circ> * (-q * --r1 \<squnion> --q * --r2) = --p * --q * x2 * --q * (--q * (-q * -r1 * y1 \<squnion> --q * -r2 * y2))\<^sup>\<circ> * (-q * --r1 \<squnion> --q * --r2)" by (smt (verit, del_insts) assms mult_assoc preserves_sup preserves_equation_test preserves_import_circ preserves_mult preserves_test preserves_test_neg) also have "... = --p * --q * x2 * --q * (--q * -r2 * y2)\<^sup>\<circ> * (-q * --r1 \<squnion> --q * --r2)" using ite_context_false ite_def mult_assoc by auto finally have "--p * --q * x2 * (-q * -r1 * y1 \<squnion> --q * -r2 * y2)\<^sup>\<circ> * (-q * --r1 \<squnion> --q * --r2) = --p * --q * x2 * (-r2 * y2)\<^sup>\<circ> * --r2" by (smt (verit, del_insts) assms(3,5) ite_context_false ite_def mult_assoc preserves_equation_test preserves_import_circ preserves_mult preserves_simulate preserves_test preserves_test_neg) thus ?thesis using 1 2 by (smt (z3) assms(1) assigns_def mult_assoc mult_right_dist_sup while_def ite_context_false ite_context_true tests_dual.sub_commutative) qed lemma while_it_norm: "assigns z (-p) (-q) \<Longrightarrow> preserves x (-q) \<Longrightarrow> preserves y (-q) \<Longrightarrow> z * (-p \<rhd> x * (-r \<star> y)) = z * (-q \<rhd> x) * (-q * -r \<star> y)" by (metis sup_bot_right tests_dual.sup_right_zero it_context_true it_ite tests_dual.complement_bot preserves_one while_import_condition_2 while_ite_norm wnf_lemma_7) lemma while_else_norm: "assigns z (-p) (-q) \<Longrightarrow> preserves x (-q) \<Longrightarrow> preserves y (-q) \<Longrightarrow> z * (1 \<lhd> -p \<rhd> x * (-r \<star> y)) = z * (1 \<lhd> -q \<rhd> x) * (--q * -r \<star> y)" by (metis sup_bot_left tests_dual.sup_right_zero ite_context_false tests_dual.complement_bot preserves_one while_import_condition_2 while_ite_norm wnf_lemma_7) lemma while_while_pre_norm: "-p \<star> x * (-q \<star> y) = -p \<rhd> x * (-p \<squnion> -q \<star> (y \<lhd> -q \<rhd> x))" by (smt sup_commute circ_sup_1 circ_left_unfold circ_slide it_def ite_def mult_assoc mult_left_one mult_right_dist_sup tests_dual.inf_demorgan while_def wnf_lemma_5) text \<open>Theorem 7.2\<close> lemma while_while_norm: "assigns z (-p) (-r) \<Longrightarrow> preserves x (-r) \<Longrightarrow> preserves y (-r) \<Longrightarrow> z * (-p \<star> x * (-q \<star> y)) = z * (-r \<rhd> x) * (-r * (-p \<squnion> -q) \<star> (y \<lhd> -q \<rhd> x))" by (smt tests_dual.double_negation tests_dual.sub_sup_demorgan tests_dual.inf_demorgan preserves_ite while_it_norm while_while_pre_norm) lemma while_seq_replace: "assigns z (-p) (-q) \<Longrightarrow> z * (-p \<star> x * z) * y = z * (-q \<star> x * z) * y" by (smt assigns_def circ_slide mult_assoc tests_dual.wnf_lemma_1 tests_dual.wnf_lemma_2 tests_dual.wnf_lemma_3 tests_dual.wnf_lemma_4 while_def) lemma while_ite_replace: "assigns z (-p) (-q) \<Longrightarrow> z * (x \<lhd> -p \<rhd> y) = z * (x \<lhd> -q \<rhd> y)" by (smt assigns_def ite_def mult_assoc mult_left_dist_sup sub_comm tests_dual.wnf_lemma_1 tests_dual.wnf_lemma_3) lemma while_post_norm_an: assumes "preserves y (-p)" shows "(-p \<star> x) * y = y \<lhd> --p \<rhd> (-p \<star> x * (--p \<rhd> y))" proof - have "-p * (-p * x * (--p * y \<squnion> -p))\<^sup>\<circ> * --p = -p * x * ((--p * y \<squnion> -p) * -p * x)\<^sup>\<circ> * (--p * y \<squnion> -p) * --p" by (metis circ_slide_1 while_def mult_assoc while_context_true) also have "... = -p * x * (--p * y * bot \<squnion> -p * x)\<^sup>\<circ> * --p * y" by (smt assms sup_bot_right mult_assoc tests_dual.sup_complement tests_dual.sup_idempotent mult_left_zero mult_right_dist_sup preserves_equation_test sub_comm) finally have "-p * (-p * x * (--p * y \<squnion> -p))\<^sup>\<circ> * --p = -p * x * (-p * x)\<^sup>\<circ> * --p * y" by (metis circ_sup_mult_zero sup_commute mult_assoc) thus ?thesis by (smt circ_left_unfold tests_dual.double_negation it_def ite_def mult_assoc mult_left_one mult_right_dist_sup while_def) qed lemma while_post_norm: "preserves y (-p) \<Longrightarrow> (-p \<star> x) * y = -p \<star> x * (1 \<lhd> -p \<rhd> y) \<lhd> -p \<rhd> y" using it_neg ite_neg while_post_norm_an by force lemma wnf_lemma_9: assumes "assigns z (-p) (-q)" and "preserves x1 (-q)" and "preserves y1 (-q)" and "preserves x2 (-q)" and "preserves y2 (-q)" and "preserves x2 (-p)" and "preserves y2 (-p)" shows "z * (x1 \<lhd> -q \<rhd> x2) * (-q * -p \<squnion> -r \<star> (y1 \<lhd> -q * -p \<rhd> y2)) = z * (x1 \<lhd> -p \<rhd> x2) * (-p \<squnion> -r \<star> (y1 \<lhd> -p \<rhd> y2))" proof - have "z * --p * --q * (x1 \<lhd> -q \<rhd> x2) * (-q * -p \<squnion> -r \<star> (y1 \<lhd> -q * -p \<rhd> y2)) = z * --p * --q * x2 * --q * (--q * (-q * -p \<squnion> -r) \<star> (y1 \<lhd> -q * -p \<rhd> y2))" by (smt (verit, del_insts) assms(3-5) tests_dual.double_negation ite_context_false mult_assoc tests_dual.sub_sup_demorgan tests_dual.inf_demorgan preserves_equation_test preserves_ite preserves_while_context) also have "... = z * --p * --q * x2 * --q * (--q * -r \<star> --q * y2)" by (smt sup_bot_left tests_dual.double_negation ite_conjunction ite_context_false mult_assoc tests_dual.sup_complement mult_left_dist_sup mult_left_zero while_import_condition_2) also have "... = z * --p * --q * x2 * (-r \<star> y2)" by (metis assms(4,5) mult_assoc preserves_equation_test preserves_test_neg preserves_while_context while_import_condition_2) finally have 1: "z * --p * --q * (x1 \<lhd> -q \<rhd> x2) * (-q * -p \<squnion> -r \<star> (y1 \<lhd> -q * -p \<rhd> y2)) = z * --p * --q * (x1 \<lhd> -q \<rhd> x2) * (-p \<squnion> -r \<star> (y1 \<lhd> -p \<rhd> y2))" by (smt assms(6,7) ite_context_false mult_assoc preserves_equation_test sub_comm while_ite_context_false) have "z * -p * -q * (x1 \<lhd> -q \<rhd> x2) * (-q * -p \<squnion> -r \<star> (y1 \<lhd> -q * -p \<rhd> y2)) = z * -p * -q * (x1 \<lhd> -q \<rhd> x2) * -q * (-q * (-p \<squnion> -r) \<star> -q * (y1 \<lhd> -p \<rhd> y2))" by (smt (verit, del_insts) assms(2-5) tests_dual.double_negation ite_context_import mult_assoc tests_dual.sub_sup_demorgan tests_dual.sup_idempotent mult_left_dist_sup tests_dual.inf_demorgan preserves_equation_test preserves_ite preserves_while_context while_import_condition_2) hence "z * -p * -q * (x1 \<lhd> -q \<rhd> x2) * (-q * -p \<squnion> -r \<star> (y1 \<lhd> -q * -p \<rhd> y2)) = z * -p * -q * (x1 \<lhd> -q \<rhd> x2) * (-p \<squnion> -r \<star> (y1 \<lhd> -p \<rhd> y2))" by (smt assms(2-5) tests_dual.double_negation mult_assoc tests_dual.sub_sup_demorgan tests_dual.sup_idempotent preserves_equation_test preserves_ite preserves_while_context while_import_condition_2) thus ?thesis using 1 by (smt assms(1) assigns_def mult_assoc mult_left_dist_sup mult_right_dist_sup while_ite_replace) qed text \<open>Theorem 7.3\<close> lemma while_seq_norm: assumes "assigns z1 (-r1) (-q)" and "preserves x2 (-q)" and "preserves y2 (-q)" and "preserves z2 (-q)" and "z1 * z2 = z2 * z1" and "assigns z2 (-q) (-r)" and "preserves y1 (-r)" and "preserves z1 (-r)" and "preserves x2 (-r)" and "preserves y2 (-r)" shows "x1 * z1 * z2 * (-r1 \<star> y1 * z1) * x2 * (-r2 \<star> y2) = x1 * z1 * z2 * (y1 * z1 * (1 \<lhd> -q \<rhd> x2) \<lhd> -q \<rhd> x2) * (-q \<squnion> -r2 \<star> (y1 * z1 * (1 \<lhd> -q \<rhd> x2) \<lhd> -q \<rhd> y2))" proof - have 1: "preserves (y1 * z1 * (1 \<lhd> -q \<rhd> x2)) (-r)" by (simp add: assms(7-9) ite_def preserves_mult preserves_sup preserves_test) hence 2: "preserves (y1 * z1 * (1 \<lhd> -q \<rhd> x2) \<lhd> -q \<rhd> y2) (-r)" by (simp add: assms(10) preserves_ite) have "x1 * z1 * z2 * (-r1 \<star> y1 * z1) * x2 * (-r2 \<star> y2) = x1 * z1 * z2 * (-q \<star> y1 * z1) * x2 * (-r2 \<star> y2)" using assms(1,5) mult_assoc while_seq_replace by auto also have "... = x1 * z1 * z2 * (-q \<star> y1 * z1 * (1 \<lhd> -q \<rhd> x2 * (-r2 \<star> y2)) \<lhd> -q \<rhd> x2 * (-r2 \<star> y2))" by (smt assms(2,3) mult_assoc preserves_mult preserves_while while_post_norm) also have "... = x1 * z1 * (z2 * (-q \<star> y1 * z1 * (1 \<lhd> -q \<rhd> x2) * (--q * -r2 \<star> y2)) \<lhd> -q \<rhd> z2 * x2 * (-r2 \<star> y2))" by (smt assms(2-4) assigns_same mult_assoc preserves_import_ite while_else_norm) also have "... = x1 * z1 * (z2 * (-r \<rhd> y1 * z1 * (1 \<lhd> -q \<rhd> x2)) * (-r * (-q \<squnion> -r2) \<star> (y1 * z1 * (1 \<lhd> -q \<rhd> x2) \<lhd> -q \<rhd> y2)) \<lhd> -q \<rhd> z2 * x2 * (-r2 \<star> y2))" by (smt assms(6-10) tests_dual.double_negation tests_dual.sub_sup_demorgan tests_dual.inf_demorgan preserves_ite preserves_mult preserves_one while_while_norm wnf_lemma_8) also have "... = x1 * z1 * z2 * ((-r \<rhd> y1 * z1 * (1 \<lhd> -q \<rhd> x2)) * (-r * (-q \<squnion> -r2) \<star> (y1 * z1 * (1 \<lhd> -q \<rhd> x2) \<lhd> -q \<rhd> y2)) \<lhd> -r \<rhd> x2 * (-r2 \<star> y2))" by (smt assms(4,6) mult_assoc preserves_import_ite while_ite_replace) also have "... = x1 * z1 * z2 * (-r * (y1 * z1 * (1 \<lhd> -q \<rhd> x2)) * (-r * (-q \<squnion> -r2) \<star> (y1 * z1 * (1 \<lhd> -q \<rhd> x2) \<lhd> -q \<rhd> y2)) \<lhd> -r \<rhd> x2 * (-r2 \<star> y2))" by (smt mult_assoc it_context_true ite_import_true) also have "... = x1 * z1 * z2 * (-r * (y1 * z1 * (1 \<lhd> -q \<rhd> x2)) * -r * (-r * (-q \<squnion> -r2) \<star> (y1 * z1 * (1 \<lhd> -q \<rhd> x2) \<lhd> -q \<rhd> y2)) \<lhd> -r \<rhd> x2 * (-r2 \<star> y2))" using 1 by (simp add: preserves_equation_test) also have "... = x1 * z1 * z2 * (-r * (y1 * z1 * (1 \<lhd> -q \<rhd> x2)) * -r * (-q \<squnion> -r2 \<star> (y1 * z1 * (1 \<lhd> -q \<rhd> x2) \<lhd> -q \<rhd> y2)) \<lhd> -r \<rhd> x2 * (-r2 \<star> y2))" using 2 by (smt (z3) tests_dual.sba_dual.sub_sup_closed mult_assoc preserves_while_context) also have "... = x1 * z1 * z2 * (y1 * z1 * (1 \<lhd> -q \<rhd> x2) * (-q \<squnion> -r2 \<star> (y1 * z1 * (1 \<lhd> -q \<rhd> x2) \<lhd> -q \<rhd> y2)) \<lhd> -q \<rhd> x2 * (-r2 \<star> y2))" by (smt assms(6-9) tests_dual.double_negation ite_import_true mult_assoc tests_dual.sup_idempotent preserves_equation_test preserves_ite preserves_one while_ite_replace) also have "... = x1 * z1 * z2 * (y1 * z1 * (1 \<lhd> -q \<rhd> x2) \<lhd> -r \<rhd> x2) * ((-r * (-q \<squnion> -r2) \<squnion> --r * -r2) \<star> ((y1 * z1 * (1 \<lhd> -q \<rhd> x2) \<lhd> -q \<rhd> y2) \<lhd> -r \<rhd> y2))" by (smt assms(6-10) tests_dual.double_negation mult_assoc tests_dual.sub_sup_demorgan tests_dual.inf_demorgan preserves_ite preserves_mult preserves_one while_ite_norm) also have "... = x1 * z1 * z2 * (y1 * z1 * (1 \<lhd> -q \<rhd> x2) \<lhd> -r \<rhd> x2) * ((-r * (-q \<squnion> -r2) \<squnion> --r * -r2) \<star> (y1 * z1 * (1 \<lhd> -q \<rhd> x2) \<lhd> -r * -q \<rhd> y2))" using ite_conjunction by simp also have "... = x1 * z1 * z2 * (y1 * z1 * (1 \<lhd> -q \<rhd> x2) \<lhd> -r \<rhd> x2) * ((-r * -q \<squnion> -r2) \<star> (y1 * z1 * (1 \<lhd> -q \<rhd> x2) \<lhd> -r * -q \<rhd> y2))" by (smt (z3) mult_left_dist_sup sup_assoc tests_dual.sba_dual.sup_cases tests_dual.sub_commutative) also have "... = x1 * z1 * z2 * (y1 * z1 * (1 \<lhd> -q \<rhd> x2) \<lhd> -q \<rhd> x2) * (-q \<squnion> -r2 \<star> (y1 * z1 * (1 \<lhd> -q \<rhd> x2) \<lhd> -q \<rhd> y2))" using 1 by (metis assms(2,3,6,9,10) mult_assoc wnf_lemma_9) finally show ?thesis . qed end end
print("\tmodel.jl") m = 8 n = 8 A = sprand(m, n, 0.5) c = 1.0 - 2.0*rand(n) b = 1.0 + rand(m) u = 10.0 + sprand(n, 0.8) p = nnz(u) # Tests for PrimalDualPoint v1 = Tulip.PrimalDualPoint(rand(n), rand(p), rand(m), rand(n), rand(p)) v2 = copy(v1) @test n == sum(v1.x .== v2.x) @test p == sum(v1.w .== v2.w) @test m == sum(v1.y .== v2.y) @test n == sum(v1.s .== v2.s) @test p == sum(v1.z .== v2.z) v3 = v1 + v2 @test n == sum(v3.x .== (v1.x + v2.x)) @test p == sum(v3.w .== (v1.w + v2.w)) @test m == sum(v3.y .== (v1.y + v2.y)) @test n == sum(v3.s .== (v1.s + v2.s)) @test p == sum(v3.z .== (v1.z + v2.z)) # Create random instance and run checks model = Tulip.Model(A, b, c, u.nzind, u.nzval) @test m == model.nconstr @test n == model.nvars @test model.status == :Built sol = model.sol @test typeof(sol) <: Tulip.PrimalDualPoint @test n == size(sol.x, 1) @test p == size(sol.w, 1) @test m == size(sol.y, 1) @test n == size(sol.s, 1) @test p == size(sol.z, 1) println("\tPassed.")
using LazySets, MathematicalPredicates, SparseArrays function heat_specification() # initial set: xα΅’ ∈ [0.6, 0.625] for i ≀ 2 and xα΅’ = 0 for i > 2 X0 = Hyperrectangle(low=[fill(0.6, 2); zeros(198)], high=[fill(0.625, 2); zeros(198)]) # safety property: x133 ≀ 0.1 property = is_contained_in(HalfSpace(sparsevec([133], [1.0], 200), 0.1)) # time horizon: 20 time units time_horizon = 20.0 # specification O = Dict(:T => time_horizon, :property => property) return X0, O end
%{ Tests the extended "analysis" form of basis pursuit de-noising min_1 alpha*||W_1 x||_1 + beta*|| W_2 x ||_1 s.t. || A(x) - b || <= eps The solvers solve a regularized version see also test_sBP.m and test_sBPDN.m and test_sBPDN_W.m %} % Before running this, please add the TFOCS base directory to your path myAwgn = @(x,snr) x + ... 10^( (10*log10(sum(abs(x(:)).^2)/length(x(:))) - snr)/20 )*randn(size(x)); % Try to load the problem from disk fileName = fullfile('reference_solutions','basispursuit_WW_problem1_smoothed_noisy'); randn('state',34324); rand('state',34324); N = 512; M = round(N/2); K = round(M/5); A = randn(M,N); x = zeros(N,1); % introduce a sparsifying transform "W" d = round(4*N); % redundant Wf = @(x) dct(x,d); % zero-padded DCT downsample = @(x) x(1:N,:); Wt = @(y) downsample( idct(y) ); % transpose of W W = Wf(eye(N)); % make an explicit matrix for CVX % and add another transform: d2 = round(2*N); W2 = randn(d2,N); if exist([fileName,'.mat'],'file') load(fileName); fprintf('Loaded problem from %s\n', fileName ); else % Generate a new problem alpha = 1; beta = 2; % the signal x consists of several pure tones at random frequencies for k = 1:K x = x + randn()*sin( rand()*pi*(1:N) + 2*pi*rand() ).'; end b_original = A*x; snr = 40; % SNR in dB b = myAwgn(b_original,snr); EPS = norm(b-b_original); x_original = x; mu = .01*norm(Wf(x),Inf); x0 = zeros(N,1); % get reference via CVX tic cvx_begin cvx_precision high variable xcvx(N,1) minimize alpha*norm(W*xcvx,1) + beta*norm(W2*xcvx,1) + ... mu/2*sum_square(xcvx-x0) subject to norm(A*xcvx - b ) <= EPS cvx_end time_IPM = toc; x_ref = xcvx; objF = @(x)alpha*norm(W*x,1) +beta*norm(W2*x,1)+ mu/2*norm(x-x0).^2; obj_ref = objF(x_ref); save(fileName,'x_ref','b','x_original','mu',... 'EPS','b_original','obj_ref','x0','time_IPM','snr',... 'd','d2','alpha','beta'); fprintf('Saved data to file %s\n', fileName); end [M,N] = size(A); norm_x_ref = norm(x_ref); norm_x_orig = norm(x_original); er_ref = @(x) norm(x-x_ref)/norm_x_ref; er_signal = @(x) norm(x-x_original)/norm_x_orig; resid = @(x) norm(A*x-b)/norm(b); % change if b is noisy fprintf('\tA is %d x %d\n', M, N ); fprintf('\tl1-norm solution and original signal differ by %.2e (mu = %.2e)\n', ... norm(x_ref - x_original)/norm(x_original),mu ); %% Call the TFOCS solver objF = @(x)alpha*norm(W*x,1) +beta*norm(W2*x,1)+ mu/2*norm(x-x0).^2; infeasF = @(x)norm(A*x-b) - EPS; er = er_ref; % error with reference solution (from IPM) opts = []; opts.errFcn = { @(f,dual,primal) er(primal), ... @(f,dual,primal) obj_ref - f, ... @(f,dual,primal) infeasF(primal) }; opts.maxIts = 2000; opts.tol = 1e-10; % opts.normA2 = norm(A*A'); % opts.normW2 = norm(W'*W); z0 = []; % we don't have a good guess for the dual tic; [ x, out, optsOut ] = solver_sBPDN_WW( A, alpha,W,beta,W2,b, EPS, mu, x0, z0, opts ); time_TFOCS = toc; fprintf('x is sub-optimal by %.2e, and infeasible by %.2e\n',... objF(x) - obj_ref, infeasF(x) ); fprintf('Solution has %d nonzeros. Error vs. IPM solution is %.2e\n',... nnz(x), er(x) ); % Check that we are within allowable bounds if out.err(end,1) < 1e-3 disp('Everything is working'); else error('Failed the test'); end % TFOCS v1.3 by Stephen Becker, Emmanuel Candes, and Michael Grant. % Copyright 2013 California Institute of Technology and CVX Research. % See the file LICENSE for full license information.
Launchpad currently recommends translating svgpart in Ubuntu Disco. Either this project has not been set up to use Launchpad for translation, or svgpart in Ubuntu Disco does not have any strings to be translated through Launchpad. If you think this is incorrect, please see if the subject has already come up under Answers. If it hasn't, file a new question there. Thank you.
SUBROUTINE DP_PACK ( ipkno, data, ibitst, iret ) C************************************************************************ C* DP_PACK * C* * C* This subroutine packs an array of real values into a continuous * C* bit string which is returned in the IBITST integer array. The * C* subroutine DP_SETP must be called first to define the data * C* packing terms. * C* * C* DP_PACK ( IPKNO, DATA, IBITST, IRET ) * C* * C* Input parameters: * C* IPKNO INTEGER Packing number * C* DATA (*) REAL Data values to be packed * C* * C* Output parameters: * C* IBITST (*) INTEGER Packed data * C* IRET INTEGER Return code * C* 0 = normal return * C* -1 = packing terms undefined * C** * C* Log: * C* M. desJardins/GSFC 3/86 Written without system services * C* M. desJardins/GSFC 10/86 Added GEMPAK parameter names * C* M. desJardins/GSFC 4/87 GEMPAK4 * C* T. Piper/GSC 3/99 Corrected prolog * C************************************************************************ INCLUDE 'GEMPRM.PRM' INCLUDE 'GMBDTA.CMN' INCLUDE 'dpcmn.cmn' C* REAL data (*) INTEGER ibitst (*) C* INCLUDE 'ERMISS.FNC' C------------------------------------------------------------------------ C* Check that DP_SETP was called. C iret = 0 IF (( ipkno .lt. 1) .or. (ipkno .gt. MMFLDP) .or. + ( iflgdp (ipkno) .ne. 1)) THEN iret = -1 RETURN ELSE C C* Initialize output bitstring. C DO i = 1, nwordc (ipkno) ibitst (i) = 0 END DO C C* Add each data value to bit string. C DO idata = 1, ndatac ( ipkno ) C C* Compute packed data field value according to formula. C* If outside available range, set missing data field. C IF ( ERMISS (data (idata))) THEN ipack = imissc (idata, ipkno) ELSE ipack = NINT (data (idata) / scalec (idata,ipkno) ) * - koffst (idata,ipkno) maxpac = imissc (idata,ipkno) - 1 IF ( (ipack .lt. 0) .or. (ipack .gt. maxpac) ) + ipack = imissc ( idata, ipkno ) END IF C C* Add bits to bitstring by shifting to correct position. C jbit = nbitsc ( idata, ipkno ) jsbit = isbitc ( idata, ipkno ) jword = iswrdc ( idata, ipkno ) jshift = jsbit - 1 ipack2 = ISHFT ( ipack, jshift ) ibitst ( jword ) = IOR ( ibitst ( jword ), ipack2 ) C C* Check to see if some bits overflow into next word. C IF ( (jsbit + jbit - 1) .gt. 32 ) THEN jshift = jshift - 32 ibitst ( jword + 1 ) = ISHFT ( ipack, jshift ) END IF C* END DO END IF C* RETURN END
From CoreErlang Require Export SideEffects Scoping Equalities. Require Export Coq.Sorting.Permutation. Import ListNotations. (** Built-in function simulation BIFCode: we need it in order to enable better pattern-matching on strings *) (* Inductive PrimopCode := | PMatchFail | PNothing . *) Inductive BIFCode := | BPlus | BMinus | BMult | BDivide | BRem | BDiv | BSl | BSr | BAbs | BFwrite | BFread | BAnd | BOr | BNot | BEq | BTypeEq | BNeq | BTypeNeq | BApp | BMinusMinus | BTupleToList | BListToTuple | BLt | BLe | BGt | BGe | BLength | BTupleSize | BTl | BHd | BElement | BSetElement | BIsNumber | BIsInteger | BIsAtom | BIsBoolean | BError | PMatchFail | BNothing . Definition convert_primop_to_code (s : string) : BIFCode := match s with (** primops *) | ("match_fail"%string) => PMatchFail | _ => BNothing end. Definition convert_string_to_code (s : string * string) : BIFCode := match s with | ("erlang"%string, "+"%string) => BPlus | ("erlang"%string, "-"%string) => BMinus | ("erlang"%string, "*"%string) => BMult | ("erlang"%string, "/"%string) => BDivide | ("erlang"%string, "bsl"%string) => BSl | ("erlang"%string, "bsr"%string) => BSr | ("erlang"%string, "rem"%string) => BRem | ("erlang"%string, "div"%string) => BDiv | ("erlang"%string, "abs"%string) => BAbs | ("io"%string, "fwrite"%string) => BFwrite | ("io"%string, "fread"%string) => BFread | ("erlang"%string, "and"%string) => BAnd | ("erlang"%string, "or"%string) => BOr | ("erlang"%string, "not"%string) => BNot | ("erlang"%string, "=="%string) => BEq | ("erlang"%string, "=:="%string) => BTypeEq | ("erlang"%string, "/="%string) => BNeq | ("erlang"%string, "=/="%string) => BTypeNeq | ("erlang"%string, "++"%string) => BApp | ("erlang"%string, "--"%string) => BMinusMinus | ("erlang"%string, "tuple_to_list"%string) => BTupleToList | ("erlang"%string, "list_to_tuple"%string) => BListToTuple | ("erlang"%string, "<"%string) => BLt | ("erlang"%string, ">"%string) => BGt | ("erlang"%string, "=<"%string) => BLe | ("erlang"%string, ">="%string) => BGe | ("erlang"%string, "length"%string) => BLength | ("erlang"%string, "tuple_size"%string) => BTupleSize | ("erlang"%string, "hd"%string) => BHd | ("erlang"%string, "tl"%string) => BTl | ("erlang"%string, "element"%string) => BElement | ("erlang"%string, "setelement"%string) => BSetElement | ("erlang"%string, "is_number"%string) => BIsNumber | ("erlang"%string, "is_integer"%string) => BIsInteger | ("erlang"%string, "is_atom"%string) => BIsAtom | ("erlang"%string, "is_boolean"%string) => BIsBoolean | ("erlang"%string, "error"%string) => BError (** anything else *) | _ => BNothing end. (** For built-in arithmetic calls *) Definition eval_arith (mname : string) (fname : string) (params : list Val) : Redex := match convert_string_to_code (mname, fname), params with (** addition *) | BPlus, [VLit (Integer a); VLit (Integer b)] => RValSeq [VLit (Integer (a + b))] | BPlus, [a; b] => RExc (badarith (VTuple [VLit (Atom fname); a; b])) (** subtraction *) | BMinus, [VLit (Integer a); VLit (Integer b)] => RValSeq [VLit (Integer (a - b))] | BMinus, [a; b] => RExc (badarith (VTuple [VLit (Atom fname); a; b])) (** unary minus *) | BMinus, [VLit (Integer a)] => RValSeq [VLit (Integer (0 - a))] | BMinus, [a] => RExc (badarith (VTuple [VLit (Atom fname); a])) (** unary plus *) | BPlus, [VLit (Integer a)] => RValSeq [VLit (Integer a)] | BPlus, [a] => RExc (badarith (VTuple [VLit (Atom fname); a])) (** multiplication *) | BMult, [VLit (Integer a); VLit (Integer b)] => RValSeq [VLit (Integer (a * b))] | BMult, [a; b] => RExc (badarith (VTuple [VLit (Atom fname); a; b])) (** division *) | BDivide, [VLit (Integer a); VLit (Integer 0)] => RExc (badarith (VTuple [VLit (Atom fname); VLit (Integer a); VLit (Integer 0)])) | BDivide, [VLit (Integer a); VLit (Integer b)] => RValSeq [VLit (Integer (a / b))] | BDivide, [a; b] => RExc (badarith (VTuple [VLit (Atom fname); a; b])) (** rem *) | BRem, [VLit (Integer a); VLit (Integer 0)] => RExc (badarith (VTuple [VLit (Atom fname); VLit (Integer a); VLit (Integer 0)])) | BRem, [VLit (Integer a); VLit (Integer b)] => RValSeq [VLit (Integer (Z.rem a b))] | BRem, [a; b] => RExc (badarith (VTuple [VLit (Atom fname); a; b])) (** div *) | BDiv, [VLit (Integer a); VLit (Integer 0)] => RExc (badarith (VTuple [VLit (Atom fname); VLit (Integer a); VLit (Integer 0)])) | BDiv, [VLit (Integer a); VLit (Integer b)] => RValSeq [VLit (Integer (Z.quot a b))] | BDiv, [a; b] => RExc (badarith (VTuple [VLit (Atom fname); a; b])) (** bsl *) | BSl, [VLit (Integer a); VLit (Integer b)] => RValSeq [VLit (Integer (Z.shiftl a b))] | BSl, [a; b] => RExc (badarith (VTuple [VLit (Atom fname); a; b])) (** bsr *) | BSr, [VLit (Integer a); VLit (Integer b)] => RValSeq [VLit (Integer (Z.shiftr a b))] | BSr, [a; b] => RExc (badarith (VTuple [VLit (Atom fname); a; b])) (** abs *) | BAbs, [VLit (Integer a)] => RValSeq [VLit (Integer (Z.abs a))] | BAbs, [a] => RExc (badarg (VTuple [VLit (Atom fname); a])) (** anything else *) | _ , _ => RExc (undef (VLit (Atom fname))) end. (** For IO maniputaion: *) Definition eval_io (mname : string) (fname : string) (params : list Val) (eff : SideEffectList) : ((Redex) * SideEffectList) := match convert_string_to_code (mname, fname), length params, params with (** writing *) | BFwrite, 1, _ => (RValSeq [ok] , eff ++ [(Output, params)]) (** reading *) | BFread, 2, e => (RValSeq [VTuple [ok; nth 1 params ErrorVal]], eff ++ [(Input, params)]) (** anything else *) | _ , _, _ => (RExc (undef (VLit (Atom fname))) , eff) end. Definition eval_logical (mname fname : string) (params : list Val) : Redex := match convert_string_to_code (mname, fname), params with (** logical and *) | BAnd, [a; b] => (*match a, b with | VLit (Atom "true") , VLit (Atom "true") => RValSeq [ttrue] | VLit (Atom "false"), VLit (Atom "true") => RValSeq [ffalse] | VLit (Atom "true") , VLit (Atom "false") => RValSeq [ffalse] | VLit (Atom "false"), VLit (Atom "false") => RValSeq [ffalse] | _ , _ => RExc (badarg (VTuple [VLit (Atom fname); a; b])) end*) if Val_eqb a ttrue then if Val_eqb b ttrue then RValSeq [ttrue] else if Val_eqb b ffalse then RValSeq [ffalse] else RExc (badarg (VTuple [VLit (Atom fname); a; b])) else if Val_eqb a ffalse then if Val_eqb b ttrue then RValSeq [ffalse] else if Val_eqb b ffalse then RValSeq [ffalse] else RExc (badarg (VTuple [VLit (Atom fname); a; b])) else RExc (badarg (VTuple [VLit (Atom fname); a; b])) (** logical or *) | BOr, [a; b] => (*match a, b with | VLit (Atom "true") , VLit (Atom "true") => RValSeq [ttrue] | VLit (Atom "false"), VLit (Atom "true") => RValSeq [ttrue] | VLit (Atom "true") , VLit (Atom "false") => RValSeq [ttrue] | VLit (Atom "false"), VLit (Atom "false") => RValSeq [ffalse] | _ , _ => RExc (badarg (VTuple [VLit (Atom fname); a; b])) end *) if Val_eqb a ttrue then if Val_eqb b ttrue then RValSeq [ttrue] else if Val_eqb b ffalse then RValSeq [ttrue] else RExc (badarg (VTuple [VLit (Atom fname); a; b])) else if Val_eqb a ffalse then if Val_eqb b ttrue then RValSeq [ttrue] else if Val_eqb b ffalse then RValSeq [ffalse] else RExc (badarg (VTuple [VLit (Atom fname); a; b])) else RExc (badarg (VTuple [VLit (Atom fname); a; b])) (** logical not *) | BNot, [a] => (* match a with | VLit (Atom "true") => RValSeq [ffalse] | VLit (Atom "false") => RValSeq [ttrue] | _ => RExc (badarg (VTuple [VLit (Atom fname); a])) end *) if Val_eqb a ttrue then RValSeq [ffalse] else if Val_eqb a ffalse then RValSeq [ttrue] else RExc (badarg (VTuple [VLit (Atom fname); a])) (** anything else *) | _ , _ => RExc (undef (VLit (Atom fname))) end. Definition eval_equality (mname : string) (fname : string) (params : list Val) : Redex := match convert_string_to_code (mname, fname), params with | BEq, [v1; v2] (* TODO: with floats, this one should be adjusted *) | BTypeEq, [v1; v2] => if Val_eqb v1 v2 then RValSeq [ttrue] else RValSeq [ffalse] | BNeq, [v1; v2] (* TODO: with floats, this one should be adjusted *) | BTypeNeq, [v1; v2] => if Val_eqb v1 v2 then RValSeq [ffalse] else RValSeq [ttrue] (** anything else *) | _ , _ => RExc (undef (VLit (Atom fname))) end. Fixpoint is_shallow_proper_list (v : Val) : bool := match v with | VNil => true | VCons x y => is_shallow_proper_list y | _ => false end. Fixpoint eval_append (v1 v2 : Val) : Redex := match v1, v2 with | VNil, x => RValSeq [x] | VCons x y, x' => match eval_append y x' with | RExc ex => RExc (badarg (VTuple [VLit (Atom "++"); v1; v2])) | RValSeq [res] => RValSeq [VCons x res] | _ => RExc (badarg (VTuple [VLit (Atom "++"); v1; v2])) end | _, _ => RExc (badarg (VTuple [VLit (Atom "++"); v1; v2])) end. Fixpoint subtract_elem (v1 v2 : Val) : Val := match v1 with | VNil => VNil | VCons x y => match y with | VNil => if Val_eqb x v2 then VNil else VCons x y | VCons z w => if Val_eqb x v2 then y else VCons x (subtract_elem y v2) | z => if Val_eqb x v2 then VCons z VNil else if Val_eqb z v2 then VCons x VNil else VCons x y end | _ => ErrorVal end. Fixpoint eval_subtract (v1 v2 : Val) : Redex := if andb (is_shallow_proper_list v1) (is_shallow_proper_list v2) then match v1, v2 with | VNil, VNil => RValSeq [VNil] | VNil, VCons x y => RValSeq [VNil] | VCons x y, VNil => RValSeq [VCons x y] | VCons x y, VCons x' y' => match y' with | VNil => RValSeq [subtract_elem (VCons x y) x'] | VCons z w => eval_subtract (subtract_elem (VCons x y) x') y' | z => RValSeq [subtract_elem (subtract_elem (VCons x y) x') z] end | _ , _ => RExc (badarg (VTuple [VLit (Atom "--"); v1; v2])) end else RExc (badarg (VTuple [VLit (Atom "--"); v1; v2])). Definition eval_transform_list (mname : string) (fname : string) (params : list Val) : Redex := match convert_string_to_code (mname, fname), params with | BApp, [v1; v2] => eval_append v1 v2 | BMinusMinus, [v1; v2] => eval_subtract v1 v2 | _ , _ => RExc (undef (VLit (Atom fname))) end. Definition transform_tuple (v : Val) : Redex := match v with | VTuple l => RValSeq [((fix unfold_list l := match l with | [] => VNil | x::xs => VCons x (unfold_list xs) end) l)] | _ => RExc (badarg (VTuple [VLit (Atom "tuple_to_list"); v])) end. Fixpoint transform_list (v : Val) : list Val + Exception := match v with | VNil => inl [] | VCons x y => match y with | VNil => inl [x] | VCons z w => match (transform_list y) with | inr ex => inr ex | inl res => inl (x::res) end | _ => inr (badarg (VTuple [VLit (Atom "list_to_tuple"); v])) end | _ => inr (badarg (VTuple [VLit (Atom "list_to_tuple"); v])) end. Definition eval_list_tuple (mname : string) (fname : string) (params : list Val) : Redex := match convert_string_to_code (mname, fname), params with | BTupleToList, [v] => transform_tuple v | BListToTuple, [v] => match (transform_list v) with | inr ex => RExc ex | inl l => RValSeq [VTuple l] end | _ , _ => RExc (undef (VLit (Atom fname))) end. Definition eval_cmp (mname : string) (fname : string) (params : list Val) : Redex := match convert_string_to_code (mname, fname), params with | BLt, [v1; v2] => if Val_ltb v1 v2 then RValSeq [ttrue] else RValSeq [ffalse] | BLe, [v1; v2] => if orb (Val_ltb v1 v2) (Val_eqb v1 v2) then RValSeq [ttrue] else RValSeq [ffalse] | BGt, [v1; v2] => if Val_ltb v2 v1 then RValSeq [ttrue] else RValSeq [ffalse] | BGe, [v1; v2] => if orb (Val_ltb v2 v1) (Val_eqb v1 v2) then RValSeq [ttrue] else RValSeq [ffalse] (** anything else *) | _ , _ => RExc (undef (VLit (Atom fname))) end. Definition eval_length (params : list Val) : Redex := match params with | [v] => let res := (fix len val := match val with | VNil => Some Z.zero | VCons x y => let res := len y in match res with | Some n => Some (Z.add 1 n) | None => None end | _ => None end) v in match res with | Some n => RValSeq [VLit (Integer n)] | None => RExc (badarg (VTuple [VLit (Atom "length"); v])) end | _ => RExc (undef (VLit (Atom "length"))) end. Definition eval_tuple_size (params : list Val) : Redex := match params with | [VTuple l] => RValSeq [VLit (Integer (Z.of_nat (length l)))] | [v] => RExc (badarg (VTuple [VLit (Atom "tuple_size"); v])) | _ => RExc (undef (VLit (Atom "tuple_size"))) end. Definition eval_hd_tl (mname : string) (fname : string) (params : list Val) : Redex := match convert_string_to_code (mname, fname), params with | BHd, [VCons x y] => RValSeq [x] | BHd, [v] => RExc (badarg (VTuple [VLit (Atom fname); v])) | BTl, [VCons x y] => RValSeq [y] | BTl, [v] => RExc (badarg (VTuple [VLit (Atom fname); v])) | _, _ => RExc (undef (VLit (Atom fname))) end. Fixpoint replace_nth_error {A : Type} (l : list A) (i : nat) (e : A) : option (list A) := match i, l with | 0, x::xs => Some (e::xs) | _, [] => None | S n, x::xs => match (replace_nth_error xs n e) with | None => None | Some l' => Some (x::l') end end. Definition eval_elem_tuple (mname : string) (fname : string) (params : list Val) : Redex := match convert_string_to_code (mname, fname), params with | BElement, [VLit (Integer i); VTuple l] => match i with | Z.pos p => match nth_error l (pred (Pos.to_nat p)) with | None => RExc (badarg (VTuple [VLit (Atom fname); VLit (Integer i); VTuple l])) | Some v => RValSeq [v] end | _ => RExc (badarg (VTuple [VLit (Atom fname); VLit (Integer i); VTuple l])) end | BElement, [v1; v2] => RExc (badarg (VTuple [VLit (Atom fname); v1; v2])) | BSetElement, [VLit (Integer i); VTuple l; val] => match i with | Z.pos p => match replace_nth_error l (pred (Pos.to_nat p)) val with | None => RExc (badarg (VTuple [VLit (Atom fname); VLit (Integer i); VTuple l; val])) | Some l' => RValSeq [VTuple l'] end | _ => RExc (badarg (VTuple [VLit (Atom fname); VLit (Integer i); VTuple l])) end | BSetElement, [v1; v2; v3] => RExc (badarg (VTuple [VLit (Atom fname); v1; v2; v3])) | _, _ => RExc (undef (VLit (Atom fname))) end. Definition eval_check (mname fname : string) (params : list Val) : Redex := match convert_string_to_code (mname, fname), params with | BIsNumber, [VLit (Integer i)] => RValSeq [ttrue] | BIsNumber, [_] => RValSeq [ffalse] | BIsInteger, [VLit (Integer i)] => RValSeq [ttrue] | BIsInteger, [_] => RValSeq [ffalse] | BIsAtom, [VLit (Atom a)] => RValSeq [ttrue] | BIsAtom, [_] => RValSeq [ffalse] (*| BIsBoolean, [VLit (Atom "true")] | BIsBoolean, [VLit (Atom "false")] => RValSeq [ttrue] *) | BIsBoolean, [v] => if orb (Val_eqb v ttrue) (Val_eqb v ffalse) then RValSeq [ttrue] else RValSeq [ffalse] | _, _ => RExc (undef (VLit (Atom fname))) end. Definition eval_error (mname : string) (fname : string) (params : list Val) : Exception := match params with | [VTuple [val]] => (Error, val, VNil) | [VTuple [val; reas]] => (Error, val, reas) | [val] => (Error, val, VNil) | [val1; val2] => (Error, val1, val2) | _ => undef (VLit (Atom fname)) end. Definition eval_primop_error (fname : string) (params : list Val) : Exception := match params with | [VTuple [val]] => (Error, val, VNil) | [VTuple [val; reas]] => (Error, val, reas) | [val] => (Error, val, VNil) | [val1; val2] => (Error, val1, val2) | _ => undef (VLit (Atom fname)) end. (* Eval for primary operations *) Definition primop_eval (fname : string) (params : list Val) (eff : SideEffectList) : ((Redex) * SideEffectList) := match convert_primop_to_code ( fname) with | PMatchFail => (RExc (eval_primop_error fname params), eff) | _ => (RExc (undef (VLit (Atom fname))), eff) end. (* TODO: Always can be extended, this function simulates inter-module calls *) Definition eval (mname : string) (fname : string) (params : list Val) (eff : SideEffectList) : ((Redex) * SideEffectList) := match convert_string_to_code (mname, fname) with | BPlus | BMinus | BMult | BDivide | BRem | BDiv | BSl | BSr | BAbs => (eval_arith mname fname params, eff) | BFwrite | BFread => eval_io mname fname params eff | BAnd | BOr | BNot => (eval_logical mname fname params, eff) | BEq | BTypeEq | BNeq | BTypeNeq => (eval_equality mname fname params, eff) | BApp | BMinusMinus => (eval_transform_list mname fname params, eff) | BTupleToList | BListToTuple => (eval_list_tuple mname fname params, eff) | BLt | BGt | BLe | BGe => (eval_cmp mname fname params, eff) | BLength => (eval_length params, eff) | BTupleSize => (eval_tuple_size params, eff) | BHd | BTl => (eval_hd_tl mname fname params, eff) | BElement | BSetElement => (eval_elem_tuple mname fname params, eff) | BIsNumber | BIsInteger | BIsAtom | BIsBoolean => (eval_check mname fname params, eff) | BError => (RExc (eval_error mname fname params), eff) (** anything else *) | BNothing | PMatchFail => (RExc (undef (VLit (Atom fname))), eff) end. Theorem primop_eval_effect_extension fname vals eff1 res eff2 : primop_eval fname vals eff1 = (res, eff2) -> exists l', eff2 = eff1 ++ l'. Proof. intros. unfold primop_eval in H. destruct (convert_primop_to_code fname) eqn:Hfname; simpl in H. all: try (unfold eval_arith, eval_logical, eval_equality, eval_transform_list, eval_list_tuple, eval_cmp, eval_hd_tl, eval_elem_tuple, eval_check, eval_error in H; rewrite Hfname in H; destruct vals; [ inversion H; exists []; rewrite app_nil_r; auto | destruct v; try (destruct vals; inversion H; exists []; rewrite app_nil_r; auto) ]). 1-39 : inversion H; exists []; rewrite app_nil_r; auto. Qed. Theorem eval_effect_extension mname fname vals eff1 res eff2 : eval mname fname vals eff1 = (res, eff2) -> exists l', eff2 = eff1 ++ l'. Proof. intros. unfold eval in H. destruct (convert_string_to_code (mname,fname)) eqn:Hfname; simpl in H. all: try (unfold eval_arith, eval_logical, eval_equality, eval_transform_list, eval_list_tuple, eval_cmp, eval_hd_tl, eval_elem_tuple, eval_check, eval_error in H; rewrite Hfname in H; destruct vals; [ inversion H; exists []; rewrite app_nil_r; auto | destruct v; try (destruct vals; inversion H; exists []; rewrite app_nil_r; auto) ]). * unfold eval_io in H; rewrite Hfname in H; destruct (length vals) eqn:Hl; inversion H. - exists []; rewrite app_nil_r. auto. - destruct n. + inversion H. exists [(Output, vals)]. auto. + inversion H. exists []; rewrite app_nil_r. auto. * unfold eval_io in H; rewrite Hfname in H; destruct (length vals) eqn:Hl; inversion H. - exists []; rewrite app_nil_r. auto. - destruct n. + inversion H. exists []; rewrite app_nil_r. auto. + destruct n. ** inversion H. exists [(Input, vals)]. auto. ** inversion H. exists []; rewrite app_nil_r. auto. * unfold eval_length in H. destruct vals; inversion H; exists []; rewrite app_nil_r; auto. * unfold eval_tuple_size in H. destruct vals; inversion H; exists []; rewrite app_nil_r; auto. * inversion H. exists []; rewrite app_nil_r; auto. * inversion H. exists []; rewrite app_nil_r; auto. * inversion H. exists []; rewrite app_nil_r; auto. Qed. Theorem primop_eval_effect_exists_snd {mname fname vals eff} : exists eff', snd (eval mname fname vals eff) = eff'. Proof. unfold eval. destruct (convert_string_to_code (mname, fname)) eqn:Hfname. all: try ( unfold eval_arith, eval_logical, eval_equality, eval_transform_list, eval_list_tuple, eval_cmp, eval_hd_tl, eval_elem_tuple, eval_check, eval_error; rewrite Hfname; destruct vals; [ exists eff | simpl; auto ]). all: simpl; auto. 1-9, 12-39: exists eff; auto. * unfold eval_io. rewrite Hfname. destruct (length vals). - exists eff. auto. - destruct n. eexists. simpl. reflexivity. eexists. reflexivity. * unfold eval_io. rewrite Hfname. destruct (length vals). - exists eff. auto. - destruct n. eexists. simpl. reflexivity. eexists. reflexivity. Qed. Theorem eval_effect_irrelevant_snd {mname fname vals eff eff'}: snd (eval mname fname vals eff) = eff ++ eff' -> forall eff0, snd (eval mname fname vals eff0) = eff0 ++ eff'. Proof. intros. unfold eval in *. destruct (convert_string_to_code (mname, fname)) eqn:Hfname. all: try (unfold eval_arith, eval_logical, eval_equality, eval_transform_list, eval_list_tuple, eval_cmp, eval_hd_tl, eval_elem_tuple, eval_check in *; rewrite Hfname in *; destruct vals; simpl in *; rewrite <- app_nil_r in H at 1; apply app_inv_head in H; subst; rewrite app_nil_r; reflexivity). * unfold eval_io in *. rewrite Hfname in *. destruct (length vals). - simpl in *; rewrite <- app_nil_r in H at 1; apply app_inv_head in H; subst; rewrite app_nil_r; reflexivity. - destruct n; simpl in *. + apply app_inv_head in H. rewrite H. reflexivity. + rewrite <- app_nil_r in H at 1; apply app_inv_head in H; subst; rewrite app_nil_r; reflexivity. * unfold eval_io in *. rewrite Hfname in *. destruct (length vals). - simpl in *; rewrite <- app_nil_r in H at 1; apply app_inv_head in H; subst; rewrite app_nil_r; reflexivity. - destruct n; simpl in *. + simpl in *; rewrite <- app_nil_r in H at 1; apply app_inv_head in H; subst; rewrite app_nil_r; reflexivity. + destruct n. ** apply app_inv_head in H. rewrite H. reflexivity. ** rewrite <- app_nil_r in H at 1; apply app_inv_head in H; subst; rewrite app_nil_r; reflexivity. * unfold eval_length. simpl in *. rewrite <- app_nil_r in H at 1; apply app_inv_head in H; subst; rewrite app_nil_r; reflexivity. * unfold eval_tuple_size in *. rewrite <- app_nil_r in H at 1; apply app_inv_head in H; subst; rewrite app_nil_r; reflexivity. * rewrite <- app_nil_r in H at 1; apply app_inv_head in H; subst; rewrite app_nil_r; reflexivity. * rewrite <- app_nil_r in H at 1; apply app_inv_head in H; subst; rewrite app_nil_r; reflexivity. * rewrite <- app_nil_r in H at 1; apply app_inv_head in H; subst; rewrite app_nil_r; reflexivity. Qed. Theorem primop_eval_effect_irrelevant_snd {fname vals eff eff'}: snd (primop_eval fname vals eff) = eff ++ eff' -> forall eff0, snd (primop_eval fname vals eff0) = eff0 ++ eff'. Proof. intros. unfold primop_eval in *. destruct (convert_primop_to_code fname) eqn:Hfname. all: rewrite <- app_nil_r in H at 1; apply app_inv_head in H; subst; rewrite app_nil_r; reflexivity. Qed. Theorem eval_effect_irrelevant_fst {mname fname vals eff eff0}: fst (eval mname fname vals eff) = fst (eval mname fname vals eff0). Proof. unfold eval. destruct (convert_string_to_code (mname, fname)) eqn:Hfname. all: try (unfold eval_arith, eval_logical, eval_equality, eval_transform_list, eval_list_tuple, eval_cmp, eval_hd_tl, eval_elem_tuple, eval_check; rewrite Hfname; destruct vals; [ reflexivity | destruct v; try (destruct vals; auto) ]). * unfold eval_io. rewrite Hfname. destruct (length vals). - reflexivity. - destruct n; reflexivity. * unfold eval_io. rewrite Hfname. destruct (length vals). - reflexivity. - destruct n. reflexivity. + destruct n; reflexivity. * unfold eval_length. reflexivity. * reflexivity. * reflexivity. * reflexivity. * reflexivity. Qed. Theorem primop_eval_effect_irrelevant_fst {fname vals eff eff0}: fst (primop_eval fname vals eff) = fst (primop_eval fname vals eff0). Proof. unfold primop_eval. destruct (convert_primop_to_code fname) eqn:Hfname. all: reflexivity. Qed. Theorem eval_effect_extension_snd mname fname vals eff1 eff2 : snd (eval mname fname vals eff1) = eff2 -> exists l', eff2 = eff1 ++ l'. Proof. intros. pose (eval_effect_extension mname fname vals eff1 (fst (eval mname fname vals eff1)) eff2). assert (eval mname fname vals eff1 = (fst (eval mname fname vals eff1), eff2)). { rewrite surjective_pairing at 1. rewrite H. auto. } apply e. assumption. Qed. Theorem primop_eval_effect_extension_snd fname vals eff1 eff2 : snd (primop_eval fname vals eff1) = eff2 -> exists l', eff2 = eff1 ++ l'. Proof. intros. pose (primop_eval_effect_extension fname vals eff1 (fst (primop_eval fname vals eff1)) eff2). assert (primop_eval fname vals eff1 = (fst (primop_eval fname vals eff1), eff2)). { rewrite surjective_pairing at 1. rewrite H. auto. } apply e. assumption. Qed. Theorem eval_effect_permutation m f vals eff eff' : Permutation eff eff' -> Permutation (snd (eval m f vals eff)) (snd (eval m f vals eff')). Proof. intros. unfold eval. destruct (convert_string_to_code (m,f)) eqn:Hfname. all: try (unfold eval_arith, eval_logical, eval_equality, eval_transform_list, eval_list_tuple, eval_cmp, eval_hd_tl, eval_elem_tuple, eval_check; rewrite Hfname; destruct vals; auto). * unfold eval_io. rewrite Hfname. destruct (length vals). - simpl. auto. - destruct n. + simpl. apply Permutation_app_tail. auto. + auto. * unfold eval_io. rewrite Hfname. destruct (length vals). - auto. - destruct n. auto. destruct n. + simpl. apply Permutation_app_tail. auto. + auto. * unfold eval_length. auto. * auto. * auto. * auto. * auto. Qed. Proposition plus_comm_basic {e1 e2 t : Val} {eff : SideEffectList} : eval "erlang"%string "+"%string [e1 ; e2] eff = (RValSeq [t], eff) -> eval "erlang"%string "+"%string [e2; e1] eff = (RValSeq [t], eff). Proof. simpl. case_eq e1; case_eq e2; intros. all: try(reflexivity || inversion H1). all: try(destruct l); try(destruct l0); try(reflexivity || inversion H1). * unfold eval, eval_arith. simpl. rewrite <- Z.add_comm. reflexivity. Qed. Proposition plus_comm_basic_Val {e1 e2 v : Val} (eff eff2 : SideEffectList) : eval "erlang"%string "+"%string [e1 ; e2] eff = (RValSeq [v], eff) -> eval "erlang"%string "+"%string [e2; e1] eff2 = (RValSeq [v], eff2). Proof. simpl. case_eq e1; case_eq e2; intros. all: try(reflexivity || inversion H1). all: try(destruct l); try(destruct l0); try(reflexivity || inversion H1). * unfold eval, eval_arith. simpl. rewrite <- Z.add_comm. reflexivity. Qed. Proposition plus_comm_extended {e1 e2 : Val} (v : Redex) (eff eff2 : SideEffectList) : eval "erlang"%string "+"%string [e1 ; e2] eff = (v, eff) -> exists v', eval "erlang"%string "+"%string [e2; e1] eff2 = (v', eff2). Proof. simpl. case_eq e1; case_eq e2; intros. all: try(inversion H1; eexists; reflexivity). Qed. Proposition plus_effect_unmodified {e1 e2 : Val} (v' : Redex) (eff eff2 : SideEffectList) : eval "erlang"%string "+"%string [e1 ; e2] eff = (v', eff2) -> eff = eff2. Proof. simpl. case_eq e1; case_eq e2; intros. all: try(inversion H1; reflexivity). all: try(destruct l); try(inversion H1; reflexivity). all: destruct l0. Qed. Proposition plus_effect_changeable {v1 v2 : Val} (v' : Redex) (eff eff2 : SideEffectList) : eval "erlang"%string "+"%string [v1; v2] eff = (v', eff) -> eval "erlang"%string "+"%string [v1; v2] eff2 = (v', eff2). Proof. intros. simpl in *. case_eq v1; case_eq v2; intros; subst. all: try(inversion H; reflexivity). all: try(destruct l); try(inversion H; reflexivity). all: destruct l0; inversion H; auto. Qed. Lemma subtract_elem_closed Ξ“: forall v1 v2, VAL Ξ“ ⊒ v1 -> VAL Ξ“ ⊒ v2 -> VAL Ξ“ ⊒ (subtract_elem v1 v2). Proof. induction v1; intros; cbn; try constructor. repeat break_match_goal; destruct_redex_scopes; auto. Qed. Theorem closed_primop_eval : forall f vl eff, Forall (fun v => VALCLOSED v) vl -> REDCLOSED (fst (primop_eval f vl eff)). Proof. intros. unfold primop_eval. break_match_goal; simpl; try constructor; auto. inv H; simpl; try constructor; auto. destruct x; inv H1; try constructor; auto. all: try inv H2; try constructor; auto. all: inv H0; destruct l0; try constructor; auto. all: destruct l0; try constructor; auto. 2-4: destruct l0; try constructor; auto. 1-2: apply (H2 0); slia. apply (H2 1); slia. Qed. Theorem closed_eval : forall m f vl eff, Forall (fun v => VALCLOSED v) vl -> REDCLOSED (fst (eval m f vl eff)). Proof. intros. unfold eval. break_match_goal; unfold eval_arith, eval_logical, eval_equality, eval_transform_list, eval_list_tuple, eval_cmp, eval_io, eval_hd_tl, eval_elem_tuple, eval_check, eval_error; try rewrite Heqb. all: try destruct vl; try destruct vl. all: simpl; try (now (constructor; constructor)). all: repeat break_match_goal. all: try (constructor; constructor); auto. all: try now constructor; auto. all: destruct_foralls; destruct_redex_scopes; auto. all: try (apply indexed_to_forall; repeat constructor; auto). * constructor. apply indexed_to_forall. repeat constructor. auto. * clear Heqb eff m f. induction v; cbn. all: try (do 2 constructor; apply indexed_to_forall; do 2 constructor; now auto). - now do 2 constructor. - destruct_redex_scopes. apply IHv1 in H4 as H4'. break_match_goal. 2: break_match_goal. 3: break_match_goal. all: try (do 2 constructor; apply indexed_to_forall; now repeat constructor). do 3 constructor; subst; auto. apply IHv2 in H5. destruct_redex_scopes. now destruct_foralls. * clear Heqb eff m f. generalize dependent v. induction v0; intros; cbn; break_match_goal; try destruct v. all: try (do 2 constructor; apply indexed_to_forall; do 2 constructor; now auto). 1-3: destruct_redex_scopes; do 3 constructor; auto. destruct_redex_scopes. destruct v0_2; cbn in *. 3: { apply IHv0_2; auto. repeat break_match_goal; auto. constructor; auto. now apply subtract_elem_closed. } all: repeat break_match_goal; auto. all: constructor; constructor; auto. all: try apply subtract_elem_closed; auto. all: constructor; auto; now apply subtract_elem_closed. * clear Heqb eff m f. induction v; cbn. all: destruct_redex_scopes; try (do 2 constructor; apply indexed_to_forall; now repeat constructor). do 2 constructor; auto. induction l; constructor. - apply (H1 0). simpl. lia. - apply IHl. intros. apply (H1 (S i)). simpl. lia. * clear Heqb eff m f. generalize dependent v. induction l; cbn; intros. - constructor. simpl. lia. - destruct v; cbn in Heqs; try congruence. destruct_redex_scopes. repeat break_match_hyp; inversion Heqs; subst. constructor. apply indexed_to_forall. constructor; auto. apply IHl in Heqs0; auto. constructor. apply indexed_to_forall. constructor; auto. inversion Heqs0. now rewrite <- indexed_to_forall in H1. * clear Heqb eff m f. generalize dependent e. induction v; cbn; intros. all: try congruence. all: try inversion Heqs; subst; clear Heqs. all: try (do 2 constructor; apply indexed_to_forall; do 2 constructor; now auto). destruct (transform_list v2) eqn:Eq. - destruct v2; try congruence; inversion H0; subst. all: try (do 2 constructor; apply indexed_to_forall; do 2 constructor; now auto). - destruct v2; try congruence; inversion H0; subst. all: try (do 2 constructor; apply indexed_to_forall; do 2 constructor; now auto). apply IHv2; auto. destruct_redex_scopes. auto. * epose proof (proj1 (nth_error_Some l0 (Init.Nat.pred (Pos.to_nat p))) _). Unshelve. 2: { intro. rewrite H in Heqo. congruence. } eapply nth_error_nth with (d := VNil) in Heqo. subst. now apply H2. * remember (Init.Nat.pred (Pos.to_nat p)) as k. clear Heqk Heqb m f p eff. generalize dependent l2. revert k. induction l0; intros; simpl in *. - destruct k; congruence. - destruct k. + inversion Heqo. subst. constructor. intros. destruct i; simpl in *. auto. apply (H2 (S i)). lia. + break_match_hyp. 2: congruence. inversion Heqo; subst; clear Heqo. constructor. simpl. intros. destruct i. apply (H2 0). lia. apply IHl0 in Heqo0. inversion Heqo0. apply (H4 i). lia. intros. apply (H2 (S i0)). lia. * apply indexed_to_forall in H1. destruct_foralls. now constructor. * apply indexed_to_forall in H1. destruct_foralls. now constructor. Qed. Lemma primop_eval_is_result : forall f vl eff, is_result (fst (primop_eval f vl eff)). Proof. intros. unfold primop_eval. break_match_goal; simpl; constructor. Qed. Lemma eval_is_result : forall f m vl eff, is_result (fst (eval m f vl eff)). Proof. intros. unfold eval. break_match_goal; unfold eval_arith, eval_logical, eval_equality, eval_transform_list, eval_list_tuple, eval_cmp, eval_io, eval_hd_tl, eval_elem_tuple, eval_check, eval_error; try rewrite Heqb. all: repeat break_match_goal. all: simpl; try (now (constructor; constructor)). all: subst; clear Heqb m f eff. * induction v; simpl; auto. repeat break_match_goal; auto. * revert v. induction v0; destruct v; cbn; auto. 1-3, 5-9: repeat break_match_goal; auto. repeat (break_match_goal; auto; subst); simpl. * induction v; simpl; auto. * induction vl; simpl; auto. repeat break_match_goal; auto. * induction vl; simpl; auto. repeat break_match_goal; auto. Qed. Proposition eval_length_number : forall vs vs', eval_length vs = RValSeq vs' -> (exists (n : Z), vs' = [VLit n]) /\ (vs = [VNil] \/ exists v1 v2, vs = [VCons v1 v2]). Proof. intros. destruct vs; inv H. destruct vs; inv H1. revert vs' H0 ; induction v; intros; auto; inv H0. * intuition. eexists. reflexivity. * break_match_hyp; inv H1. split. - eexists. reflexivity. - break_match_hyp; try congruence. inv Heqo. specialize (IHv2 _ eq_refl) as [_ H]. destruct H. + right. do 2 eexists. reflexivity. + right. do 2 eexists. reflexivity. Qed. Proposition eval_length_positive : forall v1 v2 (x : Z), eval_length [VCons v1 v2] = RValSeq [VLit x] -> (x > 0)%Z. Proof. induction v2; intros; simpl in *; inv H; try lia. break_match_hyp; try congruence. inv H1. break_match_hyp; try congruence. destruct z; inv Heqo; try lia. specialize (IHv2_2 _ eq_refl). lia. Qed. Section Tests. (** Tests *) Goal (eval "erlang" "+" [VLit (Integer 1); VLit (Integer 2)]) [] = (RValSeq [VLit (Integer 3)], []). Proof. reflexivity. Qed. Goal (eval "erlang" "-" [VLit (Integer 1); VLit (Integer 2)]) [] = (RValSeq [VLit (Integer (-1))], []). Proof. reflexivity. Qed. Goal (eval "erlang" "+" [VLit (Atom "foo"); VLit (Integer 2)]) [] = (RExc (badarith (VTuple [VLit (Atom "+"); VLit (Atom "foo"); VLit (Integer 2)])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "+" [VLit (Integer 1); VLit (Atom "foo")]) [] = (RExc (badarith (VTuple [VLit (Atom "+"); VLit (Integer 1); VLit (Atom "foo")])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "-" [VLit (Atom "foo"); VLit (Integer 2)]) [] = (RExc (badarith (VTuple [VLit (Atom "-"); VLit (Atom "foo"); VLit (Integer 2)])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "-" [VLit (Integer 1); VLit (Atom "foo")]) [] = (RExc (badarith (VTuple [VLit (Atom "-"); VLit (Integer 1); VLit (Atom "foo")])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "-" [VLit (Atom "foo")]) [] = (RExc (badarith (VTuple [VLit (Atom "-"); VLit (Atom "foo")])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "+" [VLit (Atom "foo")]) [] = (RExc (badarith (VTuple [VLit (Atom "+"); VLit (Atom "foo")])), []). Proof. unfold eval, eval_arith. simpl. reflexivity. Qed. Goal (eval "erlang" "bsl" [VLit (Integer 10); VLit (Integer 20)]) [] = (RValSeq [VLit (Integer 10485760)], []). Proof. reflexivity. Qed. Goal (eval "erlang" "bsr" [VLit (Integer 10); VLit (Integer 20)]) [] = (RValSeq [VLit (Integer 0)], []). Proof. reflexivity. Qed. Goal (eval "erlang" "bsl" [VLit (Atom "foo"); VLit (Integer 2)]) [] = (RExc (badarith (VTuple [VLit (Atom "bsl"); VLit (Atom "foo"); VLit (Integer 2)])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "bsl" [VLit (Integer 1); VLit (Atom "foo")]) [] = (RExc (badarith (VTuple [VLit (Atom "bsl"); VLit (Integer 1); VLit (Atom "foo")])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "bsr" [VLit (Atom "foo"); VLit (Integer 2)]) [] = (RExc (badarith (VTuple [VLit (Atom "bsr"); VLit (Atom "foo"); VLit (Integer 2)])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "bsr" [VLit (Integer 1); VLit (Atom "foo")]) [] = (RExc (badarith (VTuple [VLit (Atom "bsr"); VLit (Integer 1); VLit (Atom "foo")])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "bsl" [VLit (Atom "foo")]) [] = (RExc (undef (VLit (Atom "bsl"))), []). Proof. unfold eval, eval_arith. simpl. reflexivity. Qed. Goal (eval "erlang" "bsr" [VLit (Atom "foo")]) [] = (RExc (undef (VLit (Atom "bsr"))), []). Proof. unfold eval, eval_arith. simpl. reflexivity. Qed. Goal (eval "erlang" "not" [ttrue]) [] = (RValSeq [ffalse], []). Proof. reflexivity. Qed. Goal (eval "erlang" "not" [ffalse]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" "not" [VLit (Integer 5)]) [] = (RExc (badarg (VTuple [VLit (Atom "not"); VLit (Integer 5)])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "not" [VLit (Integer 5); VEmptyTuple]) [] = (RExc (undef (VLit (Atom "not"))), []). Proof. reflexivity. Qed. Goal (eval "erlang" "and" [ttrue; ttrue]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" "and" [ttrue; ffalse]) [] = (RValSeq [ffalse], []). Proof. reflexivity. Qed. Goal (eval "erlang" "and" [ffalse; ttrue]) [] = (RValSeq [ffalse], []). Proof. reflexivity. Qed. Goal (eval "erlang" "and" [ffalse; ffalse]) [] = (RValSeq [ffalse], []). Proof. reflexivity. Qed. Goal (eval "erlang" "and" [ttrue; VEmptyTuple]) [] = (RExc (badarg (VTuple [VLit (Atom "and"); ttrue; VTuple []])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "and" [ttrue]) [] = (RExc (undef (VLit (Atom "and"))), []). Proof. reflexivity. Qed. Goal (eval "erlang" "or" [ttrue; ttrue]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" "or" [ttrue; ffalse]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" "or" [ffalse; ttrue]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" "or" [ffalse; ffalse]) [] = (RValSeq [ffalse], []). Proof. reflexivity. Qed. Goal (eval "erlang" "or" [ttrue; VEmptyTuple]) [] = (RExc (badarg (VTuple [VLit (Atom "or"); ttrue; VTuple []])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "or" [ttrue]) [] = (RExc (undef (VLit (Atom "or"))), []). Proof. reflexivity. Qed. Goal (eval "io" "fwrite" [ttrue]) [] = (RValSeq [ok], [(Output, [ttrue])]). Proof. reflexivity. Qed. Goal (eval "io" "fwrite" [VMap [(ttrue, ttrue)]]) [] = (RValSeq [ok], [(Output, [VMap [(ttrue, ttrue)]])]). Proof. reflexivity. Qed. Goal (eval "io" "fwrite" []) [] = (RExc (undef (VLit (Atom "fwrite"))), []). Proof. reflexivity. Qed. Goal (eval "io" "fread" [VLit (Atom "foo.txt"); ttrue]) [] = (RValSeq [VTuple [ok; ttrue]], [(Input, [VLit (Atom "foo.txt"); ttrue])]). Proof. reflexivity. Qed. Goal (eval "io" "fread" [VLit (Atom "foo.txt"); VMap [(ttrue, ttrue)]]) [] = (RValSeq [VTuple [ok; VMap [(ttrue, ttrue)]]], [(Input, [VLit (Atom "foo.txt"); VMap [(ttrue, ttrue)]])]). Proof. reflexivity. Qed. Goal (eval "io" "fread" []) [] = (RExc (undef (VLit (Atom "fread"))), []). Proof. reflexivity. Qed. Goal (eval "erlang" "==" [ttrue; ttrue]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" "==" [ttrue; ffalse]) [] = (RValSeq [ffalse], []). Proof. reflexivity. Qed. Goal (eval "erlang" "==" [VClos [] 1 0 EEmptyMap; ttrue]) [] = (RValSeq [ffalse], []). Proof. reflexivity. Qed. Goal (eval "erlang" "==" [VClos [] 1 0 EEmptyMap; VClos [] 2 0 EEmptyMap]) [] = (RValSeq [ffalse], []). Proof. reflexivity. Qed. Goal (eval "erlang" "==" [VClos [] 1 0 EEmptyMap; VClos [] 1 0 EEmptyMap]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" "/=" [ttrue; ttrue]) [] = (RValSeq [ffalse], []). Proof. reflexivity. Qed. Goal (eval "erlang" "/=" [ttrue; ffalse]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" "/=" [VClos [] 1 0 EEmptyMap; ttrue]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" "/=" [VClos [] 1 0 EEmptyMap; VClos [] 2 0 EEmptyMap]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" "/=" [VClos [] 1 0 EEmptyMap; VClos [] 1 0 EEmptyMap]) [] = (RValSeq [ffalse], []). Proof. reflexivity. Qed. Goal (eval "erlang" "/=" [ttrue]) [] = (RExc (undef (VLit (Atom "/="))), []). Proof. reflexivity. Qed. Definition l1 : Val := VCons ttrue VNil. Definition l2 : Val := VCons ttrue ttrue. Definition l3 : Val := VCons (VCons ttrue ttrue) ttrue. Definition l4 : Val := VCons ttrue (VCons ttrue (VCons ttrue VNil)). Definition l5 : Val := VCons ttrue (VCons ttrue ttrue). Goal (eval "erlang" "++" [ttrue; ttrue]) [] = (RExc (badarg (VTuple [VLit (Atom "++"); ttrue; ttrue])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "++" [l1; l1]) [] = (RValSeq [VCons ttrue (VCons ttrue VNil)], []). Proof. reflexivity. Qed. Goal (eval "erlang" "++" [l1; l2]) [] = (RValSeq [VCons ttrue (VCons ttrue ttrue)], []). Proof. reflexivity. Qed. Goal (eval "erlang" "++" [l1; l3]) [] = (RValSeq [VCons ttrue (VCons (VCons ttrue ttrue) ttrue)], []). Proof. reflexivity. Qed. Goal (eval "erlang" "++" [l3; l3]) [] = (RExc (badarg (VTuple [VLit (Atom "++"); VCons (VCons ttrue ttrue) ttrue; VCons (VCons ttrue ttrue) ttrue])), []). Proof. unfold eval, eval_transform_list. simpl. reflexivity. Qed. Goal (eval "erlang" "++" [l1; ErrorVal]) [] = (RValSeq [VCons ttrue ErrorVal], []). Proof. unfold eval, eval_transform_list. simpl. reflexivity. Qed. Goal (eval "erlang" "--" [ttrue; ttrue]) [] = (RExc (badarg (VTuple [VLit (Atom "--"); ttrue; ttrue])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "--" [l1; l1]) [] = (RValSeq [VNil], []). Proof. reflexivity. Qed. Goal (eval "erlang" "--" [l1; l2]) [] = (RExc (badarg (VTuple [VLit (Atom "--"); VCons ttrue VNil; VCons ttrue ttrue])), []). Proof. unfold eval, eval_transform_list. simpl. reflexivity. Qed. Goal (eval "erlang" "--" [l1; l3]) [] = (RExc (badarg (VTuple [VLit (Atom "--"); VCons ttrue VNil; VCons (VCons ttrue ttrue) ttrue])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "--" [l3; l3]) [] = (RExc (badarg (VTuple [VLit (Atom "--"); VCons (VCons ttrue ttrue) ttrue; VCons (VCons ttrue ttrue) ttrue])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "--" [l3; l1]) [] = (RExc (badarg (VTuple [VLit (Atom "--"); VCons (VCons ttrue ttrue) ttrue; VCons ttrue VNil])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "--" [l4; l4]) [] = (RValSeq [VNil], []). Proof. reflexivity. Qed. Goal (eval "erlang" "--" [VCons (VLit (Integer 0)) (VCons (VLit (Atom "HIGH")) (VCons ffalse (VCons (VLit (Atom "FERTILE")) (VCons VNil VNil)))); VCons VNil (VCons (VLit (Integer 0)) VNil) ] []) = (RValSeq [(VCons (VLit (Atom "HIGH")) (VCons ffalse (VCons (VLit (Atom "FERTILE")) VNil)))], []). Proof. unfold eval, eval_transform_list, eval_subtract. simpl. reflexivity. Qed. Goal (eval "erlang" "tuple_to_list" [VTuple [ttrue; ttrue; ttrue; l1]] []) = (RValSeq [VCons ttrue (VCons ttrue (VCons ttrue (VCons (VCons ttrue VNil) VNil)))], []). Proof. reflexivity. Qed. Goal (eval "erlang" "tuple_to_list" [VTuple [ttrue; ttrue; l5; l1]] []) = (RValSeq [VCons ttrue (VCons ttrue (VCons (VCons ttrue (VCons ttrue ttrue)) (VCons (VCons ttrue VNil) VNil)))], []). Proof. reflexivity. Qed. Goal (eval "erlang" "tuple_to_list" [VTuple [ttrue; l3; ttrue; l1]] []) = (RValSeq [VCons ttrue (VCons (VCons (VCons ttrue ttrue) ttrue) (VCons ttrue (VCons (VCons ttrue VNil) VNil)))], []). Proof. reflexivity. Qed. Goal (eval "erlang" "tuple_to_list" [VTuple [ttrue; ttrue; l2; l1]] []) = (RValSeq [VCons ttrue (VCons ttrue (VCons (VCons ttrue ttrue) (VCons (VCons ttrue VNil) VNil)))], []). Proof. reflexivity. Qed. Goal (eval "erlang" "tuple_to_list" [ttrue] []) = (RExc (badarg (VTuple [VLit (Atom "tuple_to_list"); ttrue])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "list_to_tuple" [l1] []) = (RValSeq [VTuple [VLit (Atom "true")]], []). Proof. reflexivity. Qed. Goal (eval "erlang" "list_to_tuple" [l2] []) = (RExc (badarg (VTuple [VLit (Atom "list_to_tuple"); VCons ttrue ttrue])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "list_to_tuple" [l3] []) = (RExc (badarg (VTuple [VLit (Atom "list_to_tuple"); VCons (VCons ttrue ttrue) ttrue])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "list_to_tuple" [l4] []) = (RValSeq [VTuple [VLit (Atom "true"); VLit (Atom "true"); VLit (Atom "true")]], []). Proof. reflexivity. Qed. Goal (eval "erlang" "list_to_tuple" [l5] []) = (RExc (badarg (VTuple [VLit (Atom "list_to_tuple"); VCons ttrue ttrue])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "<" [ttrue; ttrue]) [] = (RValSeq [ffalse], []). Proof. reflexivity. Qed. Goal (eval "erlang" "<" [ttrue; ffalse]) [] = (RValSeq [ffalse], []). Proof. reflexivity. Qed. Goal (eval "erlang" "<" [VClos [] 1 0 EEmptyMap; VEmptyMap]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" "<" [VClos [] 1 0 EEmptyMap; VClos [] 2 0 EEmptyMap]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" "<" [VClos [] 1 0 EEmptyMap; VClos [] 1 0 EEmptyMap]) [] = (RValSeq [ffalse], []). Proof. reflexivity. Qed. Goal (eval "erlang" "=<" [ttrue; ttrue]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" "=<" [ttrue; ffalse]) [] = (RValSeq [ffalse], []). Proof. reflexivity. Qed. Goal (eval "erlang" "=<" [VClos [] 1 0 EEmptyMap; VEmptyMap]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" "=<" [VClos [] 1 0 EEmptyMap; VClos [] 2 0 EEmptyMap]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" "=<" [VClos [] 1 0 EEmptyMap; VClos [] 1 0 EEmptyMap]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" ">" [ttrue; ttrue]) [] = (RValSeq [ffalse], []). Proof. reflexivity. Qed. Goal (eval "erlang" ">" [ffalse; ttrue]) [] = (RValSeq [ffalse], []). Proof. reflexivity. Qed. Goal (eval "erlang" ">" [VEmptyMap; VClos [] 1 0 EEmptyMap]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" ">" [VClos [] 2 0 EEmptyMap; VClos [] 1 0 EEmptyMap]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" ">" [VClos [] 1 0 EEmptyMap; VClos [] 1 0 EEmptyMap]) [] = (RValSeq [ffalse], []). Proof. reflexivity. Qed. Goal (eval "erlang" ">=" [ttrue; ttrue]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" ">=" [ffalse; ttrue]) [] = (RValSeq [ffalse], []). Proof. reflexivity. Qed. Goal (eval "erlang" ">=" [VEmptyMap; VClos [] 1 0 EEmptyMap]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" ">=" [VClos [] 2 0 EEmptyMap; VClos [] 1 0 EEmptyMap]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" ">=" [VClos [] 1 0 EEmptyMap; VClos [] 1 0 EEmptyMap]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" "length" [l1]) [] = (RValSeq [VLit (Integer 1)], []). Proof. reflexivity. Qed. Goal (eval "erlang" "length" [l2]) [] = (RExc (badarg (VTuple [VLit (Atom "length");l2])), []). Proof. cbn. reflexivity. Qed. Goal (eval "erlang" "length" [l3]) [] = (RExc (badarg (VTuple [VLit (Atom "length");l3])), []). Proof. cbn. reflexivity. Qed. Goal (eval "erlang" "length" [l4]) [] = (RValSeq [VLit (Integer 3)], []). Proof. reflexivity. Qed. Goal (eval "erlang" "length" [l5]) [] = (RExc (badarg (VTuple [VLit (Atom "length");l5])), []). Proof. cbn. reflexivity. Qed. Goal (eval "erlang" "length" [ttrue]) [] = (RExc (badarg (VTuple [VLit (Atom "length");ttrue])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "length" [l5;l3]) [] = (RExc (undef (VLit (Atom "length"))), []). Proof. reflexivity. Qed. Goal (eval "erlang" "tuple_size" [l3]) [] = (RExc (badarg (VTuple [VLit (Atom "tuple_size");l3])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "tuple_size" [VTuple []]) [] = (RValSeq [VLit (Integer 0)], []). Proof. reflexivity. Qed. Goal (eval "erlang" "tuple_size" [VTuple [ttrue;ttrue;ttrue]]) [] = (RValSeq [VLit (Integer 3)], []). Proof. reflexivity. Qed. Goal (eval "erlang" "tuple_size" [VTuple [ttrue;ttrue;ttrue]; ErrorVal]) [] = (RExc (undef (VLit (Atom "tuple_size"))), []). Proof. reflexivity. Qed. Goal (eval "erlang" "hd" [l1]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" "hd" [VNil]) [] = (RExc (badarg (VTuple [VLit (Atom "hd");VNil])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "hd" [l2]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" "hd" [l3]) [] = (RValSeq [(VCons ttrue ttrue)], []). Proof. reflexivity. Qed. Goal (eval "erlang" "hd" [l4]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" "hd" [l5]) [] = (RValSeq [ttrue], []). Proof. unfold l5. reflexivity. Qed. Goal (eval "erlang" "hd" [ttrue]) [] = (RExc (badarg (VTuple [VLit (Atom "hd");ttrue])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "hd" [l5;l3]) [] = (RExc (undef (VLit (Atom "hd"))), []). Proof. reflexivity. Qed. Goal (eval "erlang" "tl" [l1]) [] = (RValSeq [VNil], []). Proof. reflexivity. Qed. Goal (eval "erlang" "tl" [VNil]) [] = (RExc (badarg (VTuple [VLit (Atom "tl");VNil])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "tl" [l2]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" "tl" [l3]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" "tl" [l4]) [] = (RValSeq [(VCons ttrue (VCons ttrue VNil))], []). Proof. reflexivity. Qed. Goal (eval "erlang" "tl" [l5]) [] = (RValSeq [VCons ttrue ttrue], []). Proof. unfold l5. reflexivity. Qed. Goal (eval "erlang" "tl" [ttrue]) [] = (RExc (badarg (VTuple [VLit (Atom "tl");ttrue])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "tl" [l5;l3]) [] = (RExc (undef (VLit (Atom "tl"))), []). Proof. reflexivity. Qed. Goal (eval "erlang" "element" [VLit (Integer 2); VTuple [ttrue]]) [] = (RExc (badarg (VTuple [VLit (Atom "element"); VLit (Integer 2); VTuple [ttrue]])), []). Proof. unfold eval, eval_elem_tuple. simpl. reflexivity. Qed. Goal (eval "erlang" "element" [VLit (Integer 1); VTuple [ttrue]]) [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal (eval "erlang" "element" [ttrue; ttrue]) [] = (RExc (badarg (VTuple [VLit (Atom "element"); ttrue; ttrue])), []). Proof. reflexivity. Qed. Goal (eval "erlang" "element" [ttrue]) [] = (RExc (undef (VLit (Atom "element"))), []). Proof. reflexivity. Qed. Goal (eval "erlang" "setelement" [VLit (Integer 2); VTuple [ttrue]; ffalse]) [] = (RExc (badarg (VTuple [VLit (Atom "setelement"); VLit (Integer 2); VTuple [ttrue]; ffalse])), []). Proof. unfold eval, eval_elem_tuple. simpl. reflexivity. Qed. Goal (eval "erlang" "setelement" [VLit (Integer 1); VTuple [ttrue]; ffalse]) [] = (RValSeq [VTuple [ffalse]], []). Proof. reflexivity. Qed. Goal (eval "erlang" "setelement" [ttrue; ttrue; ttrue]) [] = (RExc (badarg (VTuple [VLit (Atom "setelement"); ttrue; ttrue; ttrue])), []). Proof. unfold eval, eval_elem_tuple. simpl. reflexivity. Qed. Goal (eval "erlang" "setelement" [ttrue]) [] = (RExc (undef (VLit (Atom "setelement"))), []). Proof. reflexivity. Qed. Goal eval "erlang" "is_number" [VLit (Integer 2)] [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal eval "erlang" "is_number" [ffalse] [] = (RValSeq [ffalse], []). Proof. reflexivity. Qed. Goal eval "erlang" "is_number" [ffalse; ffalse] [] = (RExc (undef (VLit (Atom "is_number"))), []). Proof. reflexivity. Qed. Goal eval "erlang" "is_integer" [VLit (Integer 2)] [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal eval "erlang" "is_integer" [ffalse] [] = (RValSeq [ffalse], []). Proof. reflexivity. Qed. Goal eval "erlang" "is_integer" [ffalse; ffalse] [] = (RExc (undef (VLit (Atom "is_integer"))), []). Proof. reflexivity. Qed. Goal eval "erlang" "is_atom" [VLit (Integer 2)] [] = (RValSeq [ffalse], []). Proof. reflexivity. Qed. Goal eval "erlang" "is_atom" [VLit (Atom "foo")] [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal eval "erlang" "is_atom" [ffalse; ffalse] [] = (RExc (undef (VLit (Atom "is_atom"))), []). Proof. reflexivity. Qed. Goal eval "erlang" "is_boolean" [VLit (Integer 2)] [] = (RValSeq [ffalse], []). Proof. reflexivity. Qed. Goal eval "erlang" "is_boolean" [ttrue] [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal eval "erlang" "is_boolean" [ffalse] [] = (RValSeq [ttrue], []). Proof. reflexivity. Qed. Goal eval "erlang" "is_boolean" [ffalse; ffalse] [] = (RExc (undef (VLit (Atom "is_boolean"))), []). Proof. reflexivity. Qed. Goal eval "erlang" "error" [ffalse; ffalse] [] = (RExc (Error, ffalse, ffalse), []). Proof. reflexivity. Qed. Goal eval "erlang" "error" [ffalse] [] = (RExc (Error, ffalse, VNil), []). Proof. reflexivity. Qed. Goal eval "erlang" "error" [] [] = (RExc (undef ErrorVal), []). Proof. reflexivity. Qed. End Tests.
The use of Sb as the standard chemical symbol for antimony is due to JΓΆns Jakob Berzelius , who used this abbreviation of the name stibium . The medieval Latin form , from which the modern languages and late Byzantine Greek take their names for antimony , is antimonium . The origin of this is uncertain ; all suggestions have some difficulty either of form or interpretation . The popular etymology , from <unk> anti @-@ <unk> or French <unk> , still has adherents ; this would mean " monk @-@ killer " , and is explained by many early alchemists being monks , and antimony being poisonous .
import tactic import tactic.swap_var import data.set.basic -- mathlib defines `symm_diff` in the general context -- of Heyting algebras, but I choose to roll out my own -- definition catered to the concrete setting of `set Ξ±`. def symm_diff {Ξ± : Type*} (A B : set Ξ±) : set Ξ± := (A \ B) βˆͺ (B \ A) infix ` βˆ† `:100 := symm_diff theorem inter_sdiff {Ξ± : Type*} (A B C : set Ξ±) : A ∩ (B βˆ† C) = (A ∩ B) βˆ† (A ∩ C) := begin ext, split; intro hx, { cases hx.2, work_on_goal 1 { refine or.inl ⟨⟨hx.1, h.1⟩, _⟩ }, work_on_goal 2 { refine or.inr ⟨⟨hx.1, h.1⟩, _⟩ }, all_goals { simpa using (Ξ» _, h.2) } }, { cases hx, work_on_goal 1 { refine ⟨hx.1.1, or.inl ⟨hx.1.2, _⟩⟩ }, work_on_goal 2 { refine ⟨hx.1.1, or.inr ⟨hx.1.2, _⟩⟩ }, all_goals { have h := hx.2, rw set.mem_inter_iff at h, push_neg at h, exact h hx.1.1 } } end -- Needed for the following result @[simp] theorem symm_diff_self {Ξ± : Type*} (A : set Ξ±) : A βˆ† A = βˆ… := set.ext_iff.mpr (Ξ» x, ⟨λ hx, (false.elim $ or.elim hx (Ξ» h, h.2 h.1) (Ξ» h, h.2 h.1)), Ξ» hx, (false.elim $ (set.not_mem_empty x) hx)⟩ ) example : βˆƒ (Ξ± : Type*) (A B C : set Ξ±), A βˆͺ (B βˆ† C) β‰  (A βˆͺ B) βˆ† (A βˆͺ C) := by { use [β„•, set.univ, set.univ, set.univ], simp }
State Before: a b c : Int h : c < a + b ⊒ -a < b - c State After: a b c : Int h✝ : c < a + b h : -a < -c + b ⊒ -a < b - c Tactic: have h := Int.lt_neg_add_of_add_lt (Int.sub_left_lt_of_lt_add h) State Before: a b c : Int h✝ : c < a + b h : -a < -c + b ⊒ -a < b - c State After: no goals Tactic: rwa [Int.add_comm] at h
import ring_theory.is_tensor_product import category_theory.limits.shapes.comm_sq import ring_theory.polynomial.basic import algebra.category.Ring.constructions section variables (R S : Type*) [comm_ring R] [comm_ring S] [algebra R S] open_locale polynomial @[reducible] noncomputable def polynomial.polynomial_algebra_of_algebra : algebra R[X] S[X] := (polynomial.map_ring_hom $ algebra_map R S).to_algebra local attribute [instance] polynomial.polynomial_algebra_of_algebra @[simp] lemma polynomial.polynomial_algebra_of_algebra_algebra_map_apply (p : R[X]) : algebra_map R[X] S[X] p = p.map (algebra_map R S) := rfl instance polynomial.is_scalar_tower_of_algebra : is_scalar_tower R R[X] S[X] := is_scalar_tower.of_algebra_map_eq (Ξ» x, (@polynomial.map_C _ _ x _ _ $ algebra_map R S).symm) lemma algebra.is_pushout_iff_bijective {R S R' S' : Type*} [comm_ring R] [comm_ring S] [comm_ring R'] [comm_ring S'] [algebra R S] [algebra R R'] [algebra S S'] [algebra R' S'] [algebra R S'] [is_scalar_tower R R' S'] [is_scalar_tower R S S'] : algebra.is_pushout R R' S S' ↔ function.bijective (algebra.tensor_product.product_map (is_scalar_tower.to_alg_hom R R' S') (is_scalar_tower.to_alg_hom R S S')) := begin rw algebra.is_pushout_iff, change _ ↔ function.bijective (algebra.tensor_product.product_map _ _).to_linear_map, delta is_base_change is_tensor_product, congr', apply tensor_product.ext', intros x y, simp only [algebra.of_id_apply, tensor_product.lift.tmul, alg_hom.to_linear_map_apply, linear_map.smul_apply, module.algebra_map_End_apply, is_scalar_tower.coe_to_alg_hom', algebra.smul_def, algebra.tensor_product.product_map_apply_tmul, linear_map.coe_restrict_scalars_eq_coe, linear_map.flip_apply], end lemma algebra.tensor_product.ring_hom_ext {R A B S : Type*} [comm_ring R] [comm_ring A] [comm_ring B] [comm_ring S] [algebra R A] [algebra R B] (f g : tensor_product R A B β†’+* S) (h : f.comp algebra.tensor_product.include_left.to_ring_hom = g.comp algebra.tensor_product.include_left.to_ring_hom) (h' : f.comp algebra.tensor_product.include_right.to_ring_hom = g.comp algebra.tensor_product.include_right.to_ring_hom) : f = g := begin ext x, induction x using tensor_product.induction_on with x y x y hx hy, { rw [map_zero, map_zero] }, { rw [← mul_one x, ← one_mul y, ← algebra.tensor_product.tmul_mul_tmul, map_mul, map_mul], congr' 1, exacts [(ring_hom.congr_fun h x : _), (ring_hom.congr_fun h' y : _)] }, { rw [map_add, map_add, hx, hy] } end noncomputable def tensor_product_polynomial_equiv : tensor_product R S R[X] ≃ₐ[S] S[X] := { inv_fun := (polynomial.evalβ‚‚_ring_hom (algebra.tensor_product.include_left.to_ring_hom : S β†’+* tensor_product R S R[X]) (1 βŠ—β‚œ polynomial.X) : _) , left_inv := begin intro x, rw [alg_hom.to_fun_eq_coe, ← alg_hom.coe_to_ring_hom, ← ring_hom.comp_apply], conv_rhs { rw ← ring_hom.id_apply x }, congr' 1, convert algebra.tensor_product.ring_hom_ext _ (ring_hom.id (tensor_product R S R[X])) _ _, { ext x, simp only [algebra.of_id_apply, polynomial.evalβ‚‚_C, mul_one, ring_hom_comp_triple.comp_eq, algebra.tensor_product.product_left_alg_hom_apply, polynomial.polynomial_algebra_of_algebra_algebra_map_apply, algebra.id.map_eq_id, ring_hom.to_fun_eq_coe, ring_hom.id_apply, alg_hom.coe_to_ring_hom, eq_self_iff_true, function.comp_app, polynomial.map_one, polynomial.coe_evalβ‚‚_ring_hom, ring_hom.coe_comp, is_scalar_tower.coe_to_alg_hom', algebra.tensor_product.include_left_apply, algebra.tensor_product.product_map_apply_tmul, alg_hom.coe_restrict_scalars', alg_hom.to_ring_hom_eq_coe, polynomial.algebra_map_apply]}, ext y, { suffices : algebra_map R S y βŠ—β‚œ[R] 1 = 1 βŠ—β‚œ[R] polynomial.C y, { simpa only [polynomial.map_C, polynomial.evalβ‚‚_C, ring_hom_comp_triple.comp_eq, one_mul, algebra.tensor_product.product_left_alg_hom_apply, polynomial.polynomial_algebra_of_algebra_algebra_map_apply, ring_hom.to_fun_eq_coe, alg_hom.coe_to_ring_hom, function.comp_app, map_one, algebra.tensor_product.include_right_apply, polynomial.coe_evalβ‚‚_ring_hom, ring_hom.coe_comp, is_scalar_tower.coe_to_alg_hom', algebra.tensor_product.include_left_apply, algebra.tensor_product.product_map_apply_tmul, alg_hom.coe_restrict_scalars', alg_hom.to_ring_hom_eq_coe] using this }, rw [algebra.algebra_map_eq_smul_one, tensor_product.smul_tmul, ← algebra.algebra_map_eq_smul_one, polynomial.algebra_map_apply], refl }, { simp only [ring_hom_comp_triple.comp_eq, polynomial.map_X, one_mul, algebra.tensor_product.product_left_alg_hom_apply, polynomial.polynomial_algebra_of_algebra_algebra_map_apply, polynomial.evalβ‚‚_X, ring_hom.to_fun_eq_coe, alg_hom.coe_to_ring_hom, eq_self_iff_true, function.comp_app, map_one, algebra.tensor_product.include_right_apply, polynomial.coe_evalβ‚‚_ring_hom, ring_hom.coe_comp, is_scalar_tower.coe_to_alg_hom', algebra.tensor_product.product_map_apply_tmul, alg_hom.coe_restrict_scalars', alg_hom.to_ring_hom_eq_coe] } end, right_inv := begin intro x, rw [alg_hom.to_fun_eq_coe, ← alg_hom.coe_to_ring_hom, ← ring_hom.comp_apply], conv_rhs { rw ← ring_hom.id_apply x }, congr' 1, ext y; simp only [ alg_hom.coe_restrict_scalars', alg_hom.coe_to_ring_hom, alg_hom.to_ring_hom_eq_coe, algebra.id.map_eq_id, algebra.of_id_apply, algebra.tensor_product.include_left_apply, algebra.tensor_product.product_left_alg_hom_apply, algebra.tensor_product.product_map_apply_tmul, polynomial.polynomial_algebra_of_algebra_algebra_map_apply, function.comp_app, is_scalar_tower.coe_to_alg_hom', map_one, mul_one, one_mul, polynomial.algebra_map_apply, polynomial.map_X, polynomial.coe_evalβ‚‚_ring_hom, polynomial.evalβ‚‚_C, polynomial.evalβ‚‚_X, polynomial.map_one, ring_hom.coe_comp, ring_hom.id_apply, ring_hom.to_fun_eq_coe, ring_hom_comp_triple.comp_eq] end, ..(algebra.tensor_product.product_left_alg_hom (algebra.of_id S S[X]) (is_scalar_tower.to_alg_hom R R[X] S[X]) : _) } . @[instance] lemma is_pushout_CommRing_polynomial (R S : Type*) [comm_ring R] [comm_ring S] [algebra R S] : algebra.is_pushout R S R[X] S[X] := begin rw algebra.is_pushout_iff_bijective, exact (tensor_product_polynomial_equiv R S).bijective, end open category_theory category_theory.limits lemma algebra.is_pushout.to_is_pushout (R S R' S' : Type*) [comm_ring R] [comm_ring S] [comm_ring R'] [comm_ring S'] [algebra R S] [algebra R R'] [algebra S S'] [algebra R' S'] [algebra R S'] [is_scalar_tower R R' S'] [is_scalar_tower R S S'] [H : algebra.is_pushout R S R' S'] : is_pushout (CommRing.of_hom $ algebra_map R S) (CommRing.of_hom $ algebra_map R R') (CommRing.of_hom $ algebra_map S S') (CommRing.of_hom $ algebra_map R' S') := begin refine ⟨⟨_⟩, ⟨pushout_cocone.is_colimit_aux' _ _⟩⟩, { ext x, refine (is_scalar_tower.algebra_map_apply R S S' x) .symm.trans (is_scalar_tower.algebra_map_apply R R' S' x : _) }, { intro s, let T := s.X, letI : algebra R T := (s.ΞΉ.app $ walking_span.zero).to_algebra, let f : S →ₐ[R] T := { commutes' := ring_hom.congr_fun (s.ΞΉ.naturality walking_span.hom.fst), ..s.inl }, let g : R' →ₐ[R] T := { commutes' := ring_hom.congr_fun (s.ΞΉ.naturality walking_span.hom.snd), ..s.inr }, refine ⟨(algebra.pushout_desc S' f g $ Ξ» _ _, mul_comm _ _).to_ring_hom, _, _, _⟩, { ext, exact algebra.pushout_desc_left S' f g (Ξ» _ _, mul_comm _ _) x }, { ext, exact algebra.pushout_desc_right S' f g (Ξ» _ _, mul_comm _ _) x }, { intros m hm₁ hmβ‚‚, ext x, apply H.1.induction_on x, { simp only [map_zero] }, { intro y, exact (ring_hom.congr_fun hmβ‚‚ y).trans (algebra.pushout_desc_right S' f g (Ξ» _ _, mul_comm _ _) y).symm }, { intros y y' e, rw [algebra.smul_def, map_mul, map_mul, e], congr' 1, exact (ring_hom.congr_fun hm₁ y).trans (algebra.pushout_desc_left S' f g (Ξ» _ _, mul_comm _ _) y).symm }, { intros s₁ sβ‚‚ e₁ eβ‚‚, rw [map_add, map_add, e₁, eβ‚‚] } } } end end
# open Demo/ViewController/ViewController.xcworkspace # Run using Swifter iphone = initial("http://192.168.0.9:8080") simul = initial("http://localhost:8080") @query iphone.view.backgroundColor = UIColor.cyanColor() sleep(0.5) @query simul.view.backgroundColor = iphone.view.backgroundColor sleep(0.5) for vc in [iphone, simul] @query vc.view.backgroundColor = UIColor.orangeColor() sleep(0.5) end @query simul.view.backgroundColor = UIColor.blueColor() sleep(0.5) @query iphone.view.backgroundColor = simul.view.backgroundColor sleep(0.5) for vc in [iphone, simul] @query vc.view.backgroundColor = UIColor.whiteColor() sleep(0.5) end @query iphone.label.text = "Julia" sleep(0.5) @query simul.label.text = "Swift" sleep(0.5) temporal = @query iphone.label.text sleep(0.5) @query iphone.label.text = simul.label.text sleep(0.5) @query simul.label.text = temporal sleep(0.5) for vc in [iphone, simul] @query vc.label.text = "Julia & Swift" sleep(0.5) end map([iphone, simul]) do vc @query vc.label.text end
State Before: ι✝ : Type ?u.46874 α✝ : Type u Ξ² : Type v Ξ³ : Type w Ο€ : ι✝ β†’ Type ?u.46885 r : α✝ β†’ α✝ β†’ Prop ΞΉ : Type u Ξ± : ΞΉ β†’ Type v inst✝ : (i : ΞΉ) β†’ Preorder (Ξ± i) x y : (i : ΞΉ) β†’ Ξ± i ⊒ x < y ↔ x ≀ y ∧ βˆƒ i, x i < y i State After: no goals Tactic: simp (config := { contextual := true }) [lt_iff_le_not_le, Pi.le_def]
/- Copyright (c) 2020 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Alexander Bentkamp, Yury Kudryashov -/ import analysis.convex.combination import analysis.convex.strict import topology.path_connected import topology.algebra.affine import topology.algebra.module.basic /-! # Topological properties of convex sets We prove the following facts: * `convex.interior` : interior of a convex set is convex; * `convex.closure` : closure of a convex set is convex; * `set.finite.compact_convex_hull` : convex hull of a finite set is compact; * `set.finite.is_closed_convex_hull` : convex hull of a finite set is closed. -/ assert_not_exists has_norm open metric set open_locale pointwise convex variables {ΞΉ π•œ E : Type*} lemma real.convex_iff_is_preconnected {s : set ℝ} : convex ℝ s ↔ is_preconnected s := convex_iff_ord_connected.trans is_preconnected_iff_ord_connected.symm alias real.convex_iff_is_preconnected ↔ _ is_preconnected.convex /-! ### Standard simplex -/ section std_simplex variables [fintype ΞΉ] /-- Every vector in `std_simplex π•œ ΞΉ` has `max`-norm at most `1`. -/ lemma std_simplex_subset_closed_ball : std_simplex ℝ ΞΉ βŠ† metric.closed_ball 0 1 := begin assume f hf, rw [metric.mem_closed_ball, dist_pi_le_iff zero_le_one], intros x, rw [pi.zero_apply, real.dist_0_eq_abs, abs_of_nonneg $ hf.1 x], exact (mem_Icc_of_mem_std_simplex hf x).2, end variable (ΞΉ) /-- `std_simplex ℝ ΞΉ` is bounded. -/ lemma bounded_std_simplex : metric.bounded (std_simplex ℝ ΞΉ) := (metric.bounded_iff_subset_ball 0).2 ⟨1, std_simplex_subset_closed_ball⟩ /-- `std_simplex ℝ ΞΉ` is closed. -/ lemma is_closed_std_simplex : is_closed (std_simplex ℝ ΞΉ) := (std_simplex_eq_inter ℝ ΞΉ).symm β–Έ is_closed.inter (is_closed_Inter $ Ξ» i, is_closed_le continuous_const (continuous_apply i)) (is_closed_eq (continuous_finset_sum _ $ Ξ» x _, continuous_apply x) continuous_const) /-- `std_simplex ℝ ΞΉ` is compact. -/ lemma is_compact_std_simplex : is_compact (std_simplex ℝ ΞΉ) := metric.is_compact_iff_is_closed_bounded.2 ⟨is_closed_std_simplex ΞΉ, bounded_std_simplex ι⟩ end std_simplex /-! ### Topological vector space -/ section topological_space variables [linear_ordered_ring π•œ] [densely_ordered π•œ] [topological_space π•œ] [order_topology π•œ] [add_comm_group E] [topological_space E] [has_continuous_add E] [module π•œ E] [has_continuous_smul π•œ E] {x y : E} lemma segment_subset_closure_open_segment : [x -[π•œ] y] βŠ† closure (open_segment π•œ x y) := begin rw [segment_eq_image, open_segment_eq_image, ←closure_Ioo (zero_ne_one' π•œ)], exact image_closure_subset_closure_image (by continuity), end end topological_space section pseudo_metric_space variables [linear_ordered_ring π•œ] [densely_ordered π•œ] [pseudo_metric_space π•œ] [order_topology π•œ] [proper_space π•œ] [compact_Icc_space π•œ] [add_comm_group E] [topological_space E] [t2_space E] [has_continuous_add E] [module π•œ E] [has_continuous_smul π•œ E] @[simp] lemma closure_open_segment (x y : E) : closure (open_segment π•œ x y) = [x -[π•œ] y] := begin rw [segment_eq_image, open_segment_eq_image, ←closure_Ioo (zero_ne_one' π•œ)], exact (image_closure_of_is_compact (bounded_Ioo _ _).is_compact_closure $ continuous.continuous_on $ by continuity).symm, end end pseudo_metric_space section has_continuous_const_smul variables [linear_ordered_field π•œ] [add_comm_group E] [module π•œ E] [topological_space E] [topological_add_group E] [has_continuous_const_smul π•œ E] /-- If `s` is a convex set, then `a β€’ interior s + b β€’ closure s βŠ† interior s` for all `0 < a`, `0 ≀ b`, `a + b = 1`. See also `convex.combo_interior_self_subset_interior` for a weaker version. -/ lemma convex.combo_interior_closure_subset_interior {s : set E} (hs : convex π•œ s) {a b : π•œ} (ha : 0 < a) (hb : 0 ≀ b) (hab : a + b = 1) : a β€’ interior s + b β€’ closure s βŠ† interior s := interior_smulβ‚€ ha.ne' s β–Έ calc interior (a β€’ s) + b β€’ closure s βŠ† interior (a β€’ s) + closure (b β€’ s) : add_subset_add subset.rfl (smul_closure_subset b s) ... = interior (a β€’ s) + b β€’ s : by rw is_open_interior.add_closure (b β€’ s) ... βŠ† interior (a β€’ s + b β€’ s) : subset_interior_add_left ... βŠ† interior s : interior_mono $ hs.set_combo_subset ha.le hb hab /-- If `s` is a convex set, then `a β€’ interior s + b β€’ s βŠ† interior s` for all `0 < a`, `0 ≀ b`, `a + b = 1`. See also `convex.combo_interior_closure_subset_interior` for a stronger version. -/ lemma convex.combo_interior_self_subset_interior {s : set E} (hs : convex π•œ s) {a b : π•œ} (ha : 0 < a) (hb : 0 ≀ b) (hab : a + b = 1) : a β€’ interior s + b β€’ s βŠ† interior s := calc a β€’ interior s + b β€’ s βŠ† a β€’ interior s + b β€’ closure s : add_subset_add subset.rfl $ image_subset _ subset_closure ... βŠ† interior s : hs.combo_interior_closure_subset_interior ha hb hab /-- If `s` is a convex set, then `a β€’ closure s + b β€’ interior s βŠ† interior s` for all `0 ≀ a`, `0 < b`, `a + b = 1`. See also `convex.combo_self_interior_subset_interior` for a weaker version. -/ lemma convex.combo_closure_interior_subset_interior {s : set E} (hs : convex π•œ s) {a b : π•œ} (ha : 0 ≀ a) (hb : 0 < b) (hab : a + b = 1) : a β€’ closure s + b β€’ interior s βŠ† interior s := by { rw add_comm, exact hs.combo_interior_closure_subset_interior hb ha (add_comm a b β–Έ hab) } /-- If `s` is a convex set, then `a β€’ s + b β€’ interior s βŠ† interior s` for all `0 ≀ a`, `0 < b`, `a + b = 1`. See also `convex.combo_closure_interior_subset_interior` for a stronger version. -/ lemma convex.combo_self_interior_subset_interior {s : set E} (hs : convex π•œ s) {a b : π•œ} (ha : 0 ≀ a) (hb : 0 < b) (hab : a + b = 1) : a β€’ s + b β€’ interior s βŠ† interior s := by { rw add_comm, exact hs.combo_interior_self_subset_interior hb ha (add_comm a b β–Έ hab) } lemma convex.combo_interior_closure_mem_interior {s : set E} (hs : convex π•œ s) {x y : E} (hx : x ∈ interior s) (hy : y ∈ closure s) {a b : π•œ} (ha : 0 < a) (hb : 0 ≀ b) (hab : a + b = 1) : a β€’ x + b β€’ y ∈ interior s := hs.combo_interior_closure_subset_interior ha hb hab $ add_mem_add (smul_mem_smul_set hx) (smul_mem_smul_set hy) lemma convex.combo_interior_self_mem_interior {s : set E} (hs : convex π•œ s) {x y : E} (hx : x ∈ interior s) (hy : y ∈ s) {a b : π•œ} (ha : 0 < a) (hb : 0 ≀ b) (hab : a + b = 1) : a β€’ x + b β€’ y ∈ interior s := hs.combo_interior_closure_mem_interior hx (subset_closure hy) ha hb hab lemma convex.combo_closure_interior_mem_interior {s : set E} (hs : convex π•œ s) {x y : E} (hx : x ∈ closure s) (hy : y ∈ interior s) {a b : π•œ} (ha : 0 ≀ a) (hb : 0 < b) (hab : a + b = 1) : a β€’ x + b β€’ y ∈ interior s := hs.combo_closure_interior_subset_interior ha hb hab $ add_mem_add (smul_mem_smul_set hx) (smul_mem_smul_set hy) lemma convex.combo_self_interior_mem_interior {s : set E} (hs : convex π•œ s) {x y : E} (hx : x ∈ s) (hy : y ∈ interior s) {a b : π•œ} (ha : 0 ≀ a) (hb : 0 < b) (hab : a + b = 1) : a β€’ x + b β€’ y ∈ interior s := hs.combo_closure_interior_mem_interior (subset_closure hx) hy ha hb hab lemma convex.open_segment_interior_closure_subset_interior {s : set E} (hs : convex π•œ s) {x y : E} (hx : x ∈ interior s) (hy : y ∈ closure s) : open_segment π•œ x y βŠ† interior s := begin rintro _ ⟨a, b, ha, hb, hab, rfl⟩, exact hs.combo_interior_closure_mem_interior hx hy ha hb.le hab end lemma convex.open_segment_interior_self_subset_interior {s : set E} (hs : convex π•œ s) {x y : E} (hx : x ∈ interior s) (hy : y ∈ s) : open_segment π•œ x y βŠ† interior s := hs.open_segment_interior_closure_subset_interior hx (subset_closure hy) lemma convex.open_segment_closure_interior_subset_interior {s : set E} (hs : convex π•œ s) {x y : E} (hx : x ∈ closure s) (hy : y ∈ interior s) : open_segment π•œ x y βŠ† interior s := begin rintro _ ⟨a, b, ha, hb, hab, rfl⟩, exact hs.combo_closure_interior_mem_interior hx hy ha.le hb hab end lemma convex.open_segment_self_interior_subset_interior {s : set E} (hs : convex π•œ s) {x y : E} (hx : x ∈ s) (hy : y ∈ interior s) : open_segment π•œ x y βŠ† interior s := hs.open_segment_closure_interior_subset_interior (subset_closure hx) hy /-- If `x ∈ closure s` and `y ∈ interior s`, then the segment `(x, y]` is included in `interior s`. -/ lemma convex.add_smul_sub_mem_interior' {s : set E} (hs : convex π•œ s) {x y : E} (hx : x ∈ closure s) (hy : y ∈ interior s) {t : π•œ} (ht : t ∈ Ioc (0 : π•œ) 1) : x + t β€’ (y - x) ∈ interior s := by simpa only [sub_smul, smul_sub, one_smul, add_sub, add_comm] using hs.combo_interior_closure_mem_interior hy hx ht.1 (sub_nonneg.mpr ht.2) (add_sub_cancel'_right _ _) /-- If `x ∈ s` and `y ∈ interior s`, then the segment `(x, y]` is included in `interior s`. -/ lemma convex.add_smul_sub_mem_interior {s : set E} (hs : convex π•œ s) {x y : E} (hx : x ∈ s) (hy : y ∈ interior s) {t : π•œ} (ht : t ∈ Ioc (0 : π•œ) 1) : x + t β€’ (y - x) ∈ interior s := hs.add_smul_sub_mem_interior' (subset_closure hx) hy ht /-- If `x ∈ closure s` and `x + y ∈ interior s`, then `x + t y ∈ interior s` for `t ∈ (0, 1]`. -/ lemma convex.add_smul_mem_interior' {s : set E} (hs : convex π•œ s) {x y : E} (hx : x ∈ closure s) (hy : x + y ∈ interior s) {t : π•œ} (ht : t ∈ Ioc (0 : π•œ) 1) : x + t β€’ y ∈ interior s := by simpa only [add_sub_cancel'] using hs.add_smul_sub_mem_interior' hx hy ht /-- If `x ∈ s` and `x + y ∈ interior s`, then `x + t y ∈ interior s` for `t ∈ (0, 1]`. -/ lemma convex.add_smul_mem_interior {s : set E} (hs : convex π•œ s) {x y : E} (hx : x ∈ s) (hy : x + y ∈ interior s) {t : π•œ} (ht : t ∈ Ioc (0 : π•œ) 1) : x + t β€’ y ∈ interior s := hs.add_smul_mem_interior' (subset_closure hx) hy ht /-- In a topological vector space, the interior of a convex set is convex. -/ protected lemma convex.interior {s : set E} (hs : convex π•œ s) : convex π•œ (interior s) := convex_iff_open_segment_subset.mpr $ Ξ» x hx y hy, hs.open_segment_closure_interior_subset_interior (interior_subset_closure hx) hy /-- In a topological vector space, the closure of a convex set is convex. -/ protected lemma convex.closure {s : set E} (hs : convex π•œ s) : convex π•œ (closure s) := Ξ» x hx y hy a b ha hb hab, let f : E β†’ E β†’ E := Ξ» x' y', a β€’ x' + b β€’ y' in have hf : continuous (function.uncurry f), from (continuous_fst.const_smul _).add (continuous_snd.const_smul _), show f x y ∈ closure s, from map_mem_closureβ‚‚ hf hx hy (Ξ» x' hx' y' hy', hs hx' hy' ha hb hab) open affine_map /-- A convex set `s` is strictly convex provided that for any two distinct points of `s \ interior s`, the line passing through these points has nonempty intersection with `interior s`. -/ protected lemma convex.strict_convex' {s : set E} (hs : convex π•œ s) (h : (s \ interior s).pairwise $ Ξ» x y, βˆƒ c : π•œ, line_map x y c ∈ interior s) : strict_convex π•œ s := begin refine strict_convex_iff_open_segment_subset.2 _, intros x hx y hy hne, by_cases hx' : x ∈ interior s, { exact hs.open_segment_interior_self_subset_interior hx' hy }, by_cases hy' : y ∈ interior s, { exact hs.open_segment_self_interior_subset_interior hx hy' }, rcases h ⟨hx, hx'⟩ ⟨hy, hy'⟩ hne with ⟨c, hc⟩, refine (open_segment_subset_union x y ⟨c, rfl⟩).trans (insert_subset.2 ⟨hc, union_subset _ _⟩), exacts [hs.open_segment_self_interior_subset_interior hx hc, hs.open_segment_interior_self_subset_interior hc hy] end /-- A convex set `s` is strictly convex provided that for any two distinct points `x`, `y` of `s \ interior s`, the segment with endpoints `x`, `y` has nonempty intersection with `interior s`. -/ protected lemma convex.strict_convex {s : set E} (hs : convex π•œ s) (h : (s \ interior s).pairwise $ Ξ» x y, ([x -[π•œ] y] \ frontier s).nonempty) : strict_convex π•œ s := begin refine (hs.strict_convex' $ h.imp_on $ Ξ» x hx y hy hne, _), simp only [segment_eq_image_line_map, ← self_diff_frontier], rintro ⟨_, ⟨⟨c, hc, rfl⟩, hcs⟩⟩, refine ⟨c, hs.segment_subset hx.1 hy.1 _, hcs⟩, exact (segment_eq_image_line_map π•œ x y).symm β–Έ mem_image_of_mem _ hc end end has_continuous_const_smul section has_continuous_smul variables [add_comm_group E] [module ℝ E] [topological_space E] [topological_add_group E] [has_continuous_smul ℝ E] /-- Convex hull of a finite set is compact. -/ lemma set.finite.compact_convex_hull {s : set E} (hs : s.finite) : is_compact (convex_hull ℝ s) := begin rw [hs.convex_hull_eq_image], apply (is_compact_std_simplex _).image, haveI := hs.fintype, apply linear_map.continuous_on_pi end /-- Convex hull of a finite set is closed. -/ lemma set.finite.is_closed_convex_hull [t2_space E] {s : set E} (hs : s.finite) : is_closed (convex_hull ℝ s) := hs.compact_convex_hull.is_closed open affine_map /-- If we dilate the interior of a convex set about a point in its interior by a scale `t > 1`, the result includes the closure of the original set. TODO Generalise this from convex sets to sets that are balanced / star-shaped about `x`. -/ lemma convex.closure_subset_image_homothety_interior_of_one_lt {s : set E} (hs : convex ℝ s) {x : E} (hx : x ∈ interior s) (t : ℝ) (ht : 1 < t) : closure s βŠ† homothety x t '' interior s := begin intros y hy, have hne : t β‰  0, from (one_pos.trans ht).ne', refine ⟨homothety x t⁻¹ y, hs.open_segment_interior_closure_subset_interior hx hy _, (affine_equiv.homothety_units_mul_hom x (units.mk0 t hne)).apply_symm_apply y⟩, rw [open_segment_eq_image_line_map, ← inv_one, ← inv_Ioi (zero_lt_one' ℝ), ← image_inv, image_image, homothety_eq_line_map], exact mem_image_of_mem _ ht end /-- If we dilate a convex set about a point in its interior by a scale `t > 1`, the interior of the result includes the closure of the original set. TODO Generalise this from convex sets to sets that are balanced / star-shaped about `x`. -/ lemma convex.closure_subset_interior_image_homothety_of_one_lt {s : set E} (hs : convex ℝ s) {x : E} (hx : x ∈ interior s) (t : ℝ) (ht : 1 < t) : closure s βŠ† interior (homothety x t '' s) := (hs.closure_subset_image_homothety_interior_of_one_lt hx t ht).trans $ (homothety_is_open_map x t (one_pos.trans ht).ne').image_interior_subset _ /-- If we dilate a convex set about a point in its interior by a scale `t > 1`, the interior of the result includes the closure of the original set. TODO Generalise this from convex sets to sets that are balanced / star-shaped about `x`. -/ lemma convex.subset_interior_image_homothety_of_one_lt {s : set E} (hs : convex ℝ s) {x : E} (hx : x ∈ interior s) (t : ℝ) (ht : 1 < t) : s βŠ† interior (homothety x t '' s) := subset_closure.trans $ hs.closure_subset_interior_image_homothety_of_one_lt hx t ht /-- A nonempty convex set is path connected. -/ protected lemma convex.is_path_connected {s : set E} (hconv : convex ℝ s) (hne : s.nonempty) : is_path_connected s := begin refine is_path_connected_iff.mpr ⟨hne, _⟩, intros x x_in y y_in, have H := hconv.segment_subset x_in y_in, rw segment_eq_image_line_map at H, exact joined_in.of_line affine_map.line_map_continuous.continuous_on (line_map_apply_zero _ _) (line_map_apply_one _ _) H end /-- A nonempty convex set is connected. -/ protected lemma convex.is_connected {s : set E} (h : convex ℝ s) (hne : s.nonempty) : is_connected s := (h.is_path_connected hne).is_connected /-- A convex set is preconnected. -/ protected lemma convex.is_preconnected {s : set E} (h : convex ℝ s) : is_preconnected s := s.eq_empty_or_nonempty.elim (Ξ» h, h.symm β–Έ is_preconnected_empty) (Ξ» hne, (h.is_connected hne).is_preconnected) /-- Every topological vector space over ℝ is path connected. Not an instance, because it creates enormous TC subproblems (turn on `pp.all`). -/ protected lemma topological_add_group.path_connected : path_connected_space E := path_connected_space_iff_univ.mpr $ convex_univ.is_path_connected ⟨(0 : E), trivial⟩ end has_continuous_smul
\subsection{Make-flag} \begin{frame}[fragile] \frametitle{Make-flag} \Highlight{Make-flag} generates a flag function for a mutual-recursion \begin{itemize} \item Non-executable; multiple-values and stobjs are fine \item Measure inferred from existing definitions \item Efficient proof of equivalence theorem \item Adds a macro for proving new theorems about these functions \end{itemize} \end{frame} \begin{frame}[fragile] \frametitle{Make-flag example} \begin{verbatim} (include-book "tools/flag" :dir :system) (FLAG::make-flag flag-pseudo-termp pseudo-termp :flag-var flag :flag-mapping ((pseudo-termp . term) (pseudo-term-listp . list)) :hints(( {for the measure theorem} )) :defthm-macro-name defthm-pseudo-termp) (defthm-pseudo-termp type-of-pseudo-termp (term (booleanp (pseudo-termp x))) (list (booleanp (pseudo-term-listp lst))) :hints(("Goal" :induct (flag-pseudo-termp flag x lst)))) \end{verbatim} \end{frame}
-- 2012-03-15, example by Nisse module Issue585-11 where data D₁ : Set where d₁ : D₁ f₁ : D₁ β†’ D₁ β†’ D₁ f₁ x d₁ = x data Dβ‚‚ : Set where dβ‚‚ : Dβ‚‚ β†’ Dβ‚‚ postulate P : D₁ β†’ Set fβ‚‚ : βˆ€ {n₁ nβ‚‚} β†’ P n₁ β†’ P nβ‚‚ β†’ P (f₁ n₁ nβ‚‚) mutual f₃ : D₁ β†’ Dβ‚‚ β†’ D₁ f₃ _ (dβ‚‚ _) = _ fβ‚„ : βˆ€ {n} β†’ P n β†’ (i : Dβ‚‚) β†’ P (f₃ n i) fβ‚„ p (dβ‚‚ i) = fβ‚‚ p (fβ‚„ p i) -- This worked until Agda 2.3.0 -- Now, recursive solutions [here: f₃ n (dβ‚‚ i) = f₁ n (f₃ n i)] -- are no longer found, since termination is not be guaranteed by the occurs check.
-- Reported by stevan.andjelkovic, 2014-10-23 -- Case splitting on n in the goal g produces the wrong output, it -- seems like {n} in f is the problem... data β„• : Set where zero : β„• suc : β„• β†’ β„• f : {_ : β„•} β†’ Set₁ f {n} = Set where g : β„• β†’ Set g n = {!n!}
```python from collections import OrderedDict import warnings from IPython.display import display import sympy as sp import matplotlib.pyplot as plt from chempy.chemistry import Equilibrium, ReactionSystem, Substance from chempy.kinetics.integrated import binary_rev from chempy.kinetics.ode import get_odesys %matplotlib inline sp.init_printing() ``` ```python t, kf, kb, X, Y, Z = sp.symbols('t k_f k_b X Y Z') binary_rev(t, kf, kb, Y, Z, X, sp) ``` ```python eq = Equilibrium.from_string('Fe+3 + SCN- = FeSCN+2; 10**2.065') rsys = ReactionSystem(eq.as_reactions(kf=900)) rsys ``` ```python odesys, extra = get_odesys(rsys) ``` ```python def plot_against_analytic(odsy, c0, tend=1, integrator='cvode', atol=1e-12, rtol=1e-10): xout, yout, info = odsy.integrate(tend, c0, integrator=integrator, atol=atol, rtol=rtol) ref = binary_rev(xout[1:], rsys.rxns[0].param, rsys.rxns[1].param, c0['FeSCN+2'], c0['Fe+3'], c0['SCN-']) {k: v for k, v in info.items() if not k.startswith('internal')} plt.figure(figsize=(14, 4)) plt.subplot(1, 2, 1) plt.plot(xout[1:], ref, alpha=0.3, linewidth=3) _ = odsy.plot_result() plt.subplot(1, 2, 2) plt.plot(xout[1:], yout[1:, odsy.names.index('FeSCN+2')] - ref) ref[:3], ref[-3:] return {k: v for k, v in info.items() if not k.startswith('internal')} ``` ```python conc = {'Fe+3': 10e-3, 'SCN-': 2e-3, 'FeSCN+2': 2e-4} plot_against_analytic(odesys, conc) ``` Below are the derivations for ``binary_rev``: ```python x, a, b, c, U, V, S = sp.symbols('x a b c U V S') u, v = 2*a*x + b, sp.sqrt(b**2 - 4*a*c) # b**2 > 4*a*c Prim = sp.log((U-V)/(U+V))/V # primitive recip. 2nd order polynomial prim = sp.log((u-v)/(u+v))/v # primitive recip. 2nd order polynomial prim.diff(x).simplify() ``` ```python y = Y + X - x z = Z + X - x ``` ```python dxdt = kf*y*z - kb*x dxdt ``` ```python dxdt.expand() ``` ```python expr2 = dxdt.expand().collect(x) expr2 ``` ```python coeffs = expr2.as_poly(x).coeffs() coeffs ``` ```python eq = (sp.exp(Prim) - sp.exp(t + S)) eq ``` ```python sp.Eq(Prim*V, (t+S)*V) ``` ```python eq = sp.exp(Prim*V) - sp.exp((t+S)*V) eq ``` ```python eq2 = eq.subs({U: u}) eq2 ``` ```python sol, = sp.solve(eq2, x) sol ``` ```python s, = sp.solve(sol.subs(t, 0) - X, S) s ``` ```python sol2 = sol.subs(S, s).simplify() sol2 ``` ```python R, W = sp.symbols('R W') r = b + 2*X*a w = sp.exp(-V*t) sol3 = sol2.subs({w: W, r: R}).simplify().collect(W) sol3 ``` ```python exprs = [ sp.Eq(x, sol3), sp.Eq(R, r), sp.Eq(W, w), sp.Eq(V, v), sp.Eq(a, coeffs[0]), sp.Eq(b, coeffs[1]), sp.Eq(c, coeffs[2]), ] for expr in exprs: display(expr) ``` ```python master = exprs[0] for e in exprs[1:]: master = master.subs(e.lhs, e.rhs) master ``` ```python cses, (reform,) = sp.cse(master) reform ``` ```python cses ``` ```python ``` ```python ret = 'return ' + str(reform.rhs).replace('k_f', 'kf').replace('k_b', 'kb') for key, val in cses: print('%s = %s' % (key, str(val).replace('k_f', 'kf').replace('k_b', 'kb').replace('exp', 'be.exp').replace('sqrt', 'be.sqrt'))) print(ret) ``` ```python with warnings.catch_warnings(): warnings.filterwarnings('error') binary_rev(1.0, 1e10, 1e-4, 0, 3e-7, 2e-7) # check that our formulation avoids overflow ``` Below we will test ``get_native``: ```python from chempy.kinetics._native import get_native ``` ```python print({k: v.composition for k, v in rsys.substances.items()}) rsys.substances = OrderedDict([(k, Substance.from_formula(v.name)) for k, v in rsys.substances.items()]) print({k: v.composition for k, v in rsys.substances.items()}) ``` ```python nsys = get_native(rsys, odesys, 'gsl') ``` ```python plot_against_analytic(nsys, conc, integrator='gsl', atol=1e-16, rtol=1e-16) ``` ```python ```
classdef VideoMaker_Physical_Problem < VideoMaker properties end methods (Access = public) function Make_video_stress(obj,output_video_name,component) post = Postprocess_PhysicalProblem; field2print = post.stress_name; componentfield = [post.stress_component,component]; obj.Make_video_standard_field(field2print,componentfield,output_video_name) end function Make_video_strain(obj,output_video_name,component) post = Postprocess_PhysicalProblem; field2print = post.strain_name; componentfield = [post.strain_component,component]; obj.Make_video_standard_field(field2print,componentfield,output_video_name) end function Make_video_displacement(obj,output_video_name,component) post = Postprocess_PhysicalProblem; field2print = post.displ_name; componentfield = [post.displ_component,component]; obj.Make_video_standard_field(field2print,componentfield,output_video_name) end end methods (Access = private) function Make_video_standard_field(obj,field2print,componentfield,output_video_name_in) file_tcl_name = 'tcl_gid.tcl'; file_list = obj.create_file_list(obj.iterations_to_print,obj.file_name,obj.files_folder); [output_video_name] = obj.replace_special_character(output_video_name_in); [file_list] = obj.replace_special_character(file_list); file_tcl_name_with_path = fullfile(obj.files_folder,file_tcl_name); file_path_in = fullfile(pwd,'FEM','PostProcess','Make_Video_stress.tcl'); filepath = obj.replace_special_character(file_path_in); fid = fopen(file_tcl_name_with_path,'w+'); fprintf(fid,'GiD_Process PostProcess \n'); fprintf(fid,'%s\n',['set arg1 "',file_list,'"']); fprintf(fid,'%s\n',['set arg2 "',output_video_name,'"']); fprintf(fid,'%s\n',['set arg3 "',field2print,'"']); fprintf(fid,'%s\n',['set arg4 "',componentfield,'"']); fprintf(fid,'%s\n',['source "',filepath,'"']); fprintf(fid,'%s\n',['Make_Video_stress $arg1 $arg2 $arg3 $arg4']); fprintf(fid,'%s\n',['GiD_Process Mescape Quit']); fclose(fid); obj.executeTclFiles(obj.gidPath,file_tcl_name_with_path) end end end
Require Import IRLemmasAsCR. Lemma demo : √((cos Β½)) < exp (cos (sin (arctan Ο€))). Proof. exists 1%nat. vm_compute. reflexivity. Qed.
module Issue936 where -- The highlighting generated for this file should not contain -- any references to Agda.Primitive.
Inductive Maybe a : Set := Nothing : Maybe a | Just a : Maybe a.
lemma mult_smult_left [simp]: "smult a p * q = smult a (p * q)"
[STATEMENT] lemma parts_idem [simp]: "parts (parts H) = parts H" [PROOF STATE] proof (prove) goal (1 subgoal): 1. parts (parts H) = parts H [PROOF STEP] by blast
State Before: Ξ± : Type u lt : Ξ± β†’ Ξ± β†’ Prop inst✝ : DecidableRel lt a b : Ξ± ⊒ (cmpUsing lt a b = Ordering.eq) = (Β¬lt a b ∧ Β¬lt b a) State After: no goals Tactic: simp
import numpy as np x0=np.zeros(4) TOL=10**(-5) NMAX=100 A=np.ones((4,4)) A[0,0]=6 A[1,1]=7 A[2,2]=8 A[3,3]=9 x_sol=np.ones((4)) b=np.dot(A,x_sol) def Gauss_Seidel(A,b,NMAX,TOL,x0): m=A.shape[0] D=np.diag(np.diag(A)) U=np.triu(-A,1) L=np.tril(-A,-1) y=np.dot(U,x0)+b x=np.linalg.solve(D-L,y) e=np.linalg.norm(x-x0) M=(D-L) N=(U) n=1 while ( n < NMAX) and (e > TOL ): x0=x y=np.dot(N,x0)+b x=np.linalg.solve(M,y) e=np.linalg.norm(x-x0) n=n+1 return x,n,e print(Gauss_Seidel(A,b,NMAX,TOL,x0))
From stdpp Require Export strings. From stdpp Require Import relations numbers. From Coq Require Import Ascii. From stdpp Require Import options. Class Pretty A := pretty : A β†’ string. Definition pretty_N_char (x : N) : ascii := match x with | 0 => "0" | 1 => "1" | 2 => "2" | 3 => "3" | 4 => "4" | 5 => "5" | 6 => "6" | 7 => "7" | 8 => "8" | _ => "9" end%char%N. Fixpoint pretty_N_go_help (x : N) (acc : Acc (<)%N x) (s : string) : string := match decide (0 < x)%N with | left H => pretty_N_go_help (x `div` 10)%N (Acc_inv acc (N.div_lt x 10 H eq_refl)) (String (pretty_N_char (x `mod` 10)) s) | right _ => s end. Definition pretty_N_go (x : N) : string β†’ string := pretty_N_go_help x (wf_guard 32 N.lt_wf_0 x). Lemma pretty_N_go_0 s : pretty_N_go 0 s = s. Proof. done. Qed. Lemma pretty_N_go_help_irrel x acc1 acc2 s : pretty_N_go_help x acc1 s = pretty_N_go_help x acc2 s. Proof. revert x acc1 acc2 s; fix FIX 2; intros x [acc1] [acc2] s; simpl. destruct (decide (0 < x)%N); auto. Qed. Lemma pretty_N_go_step x s : (0 < x)%N β†’ pretty_N_go x s = pretty_N_go (x `div` 10) (String (pretty_N_char (x `mod` 10)) s). Proof. unfold pretty_N_go; intros; destruct (wf_guard 32 N.lt_wf_0 x). destruct wf_guard. (* this makes coqchk happy. *) unfold pretty_N_go_help at 1; fold pretty_N_go_help. by destruct (decide (0 < x)%N); auto using pretty_N_go_help_irrel. Qed. Instance pretty_N : Pretty N := Ξ» x, pretty_N_go x ""%string. Lemma pretty_N_unfold x : pretty x = pretty_N_go x "". Proof. done. Qed. Instance pretty_N_inj : Inj (=@{N}) (=) pretty. Proof. assert (βˆ€ x y, x < 10 β†’ y < 10 β†’ pretty_N_char x = pretty_N_char y β†’ x = y)%N. { compute; intros. by repeat (discriminate || case_match). } cut (βˆ€ x y s s', pretty_N_go x s = pretty_N_go y s' β†’ String.length s = String.length s' β†’ x = y ∧ s = s'). { intros help x y Hp. eapply (help x y "" ""); [by rewrite <-!pretty_N_unfold|done]. } assert (βˆ€ x s, Β¬String.length (pretty_N_go x s) < String.length s) as help. { setoid_rewrite <-Nat.le_ngt. intros x; induction (N.lt_wf_0 x) as [x _ IH]; intros s. assert (x = 0 ∨ 0 < x)%N as [->|?] by lia; [by rewrite pretty_N_go_0|]. rewrite pretty_N_go_step by done. etrans; [|by eapply IH, N.div_lt]; simpl; lia. } intros x; induction (N.lt_wf_0 x) as [x _ IH]; intros y s s'. assert ((x = 0 ∨ 0 < x) ∧ (y = 0 ∨ 0 < y))%N as [[->|?] [->|?]] by lia; rewrite ?pretty_N_go_0, ?pretty_N_go_step, ?(pretty_N_go_step y) by done. { done. } { intros -> Hlen; edestruct help; rewrite Hlen; simpl; lia. } { intros <- Hlen; edestruct help; rewrite <-Hlen; simpl; lia. } intros Hs Hlen; apply IH in Hs; destruct Hs; simplify_eq/=; split_and?; auto using N.div_lt_upper_bound with lia. rewrite (N.div_mod x 10), (N.div_mod y 10) by done. auto using N.mod_lt with f_equal. Qed. Instance pretty_Z : Pretty Z := Ξ» x, match x with | Z0 => "" | Zpos x => pretty (Npos x) | Zneg x => "-" +:+ pretty (Npos x) end%string. Instance pretty_nat : Pretty nat := Ξ» x, pretty (N.of_nat x). Instance pretty_nat_inj : Inj (=@{nat}) (=) pretty. Proof. apply _. Qed.
function this = MrDataNd_split_epoch(this) %Tests split_epoch by creating artificial trials for fmri_short example % % Y = MrUnitTest() % run(Y, 'MrDataNd_split_epoch'); % % This is a method of class MrUnitTest. % % IN % % OUT % % EXAMPLE % MrDataNd_split_epoch % % See also MrUnitTest % Author: Lars Kasper % Created: 2019-03-25 % Copyright (C) 2019 Institute for Biomedical Engineering % University of Zurich and ETH Zurich % % This file is part of the TAPAS UniQC Toolbox, which is released % under the terms of the GNU General Public License (GPL), version 3. % You can redistribute it and/or modify it under the terms of the GPL % (either version 3 or, at your option, any later version). % For further details, see the file COPYING or % <http://www.gnu.org/licenses/>. doPlotRoi = 0; doPlotTrialsActiveVoxel = true; % plot active voxel for all events %% Load short fMRI example pathExample = tapas_uniqc_get_path('examples'); %pathExample = fullfile(pathExample, 'nifti', 'rest'); %fileExample = fullfile(pathExample, 'fmri_short.nii'); pathExample = fullfile(pathExample, 'nifti', 'paradigm_visual'); fileExample = fullfile(pathExample, 'fmri.nii.gz'); fileBehav = fullfile(pathExample, 'behav.mat'); x = MrImage(fileExample); TR = 3; % s % update erroneous TR x.dimInfo.set_dims('t', 'resolutions', TR, 'samplingWidths', TR, ... 'firstSamplingPoint', 0); %% Create mask for time series evaluation; central voxel in all slices nSamplesXY = x.dimInfo.nSamples({'x', 'y'}); M = x.select('t',1); %iActiveVoxelXY = round([nSamplesXY/2, nSamplesXY/2]); idxActiveVoxel = [67 109 7]; % visual voxel M.data(:) = 0; % spherical ROI around active voxel M.data(idxActiveVoxel(1), idxActiveVoxel(2), idxActiveVoxel(3)) = 1; M = M.imdilate(strel('sphere', 5), '3D'); %% Split into epochs % alternative [onsets, durations, names] = ... % get_multiple_conditions_visual('bevav.log') % and use onsets{1} and durations{1} for the 10 blocks load(fileBehav); onsetTimes = relativeTimeBlockStartSeconds(1:4:end); % first blocks of same kind newPeriStimulusOnsets = 10; % number of bins, if single number, duration of stimulation block: 14.925 s y = x.split_epoch(onsetTimes, newPeriStimulusOnsets); %% Plot all PST time courses from active voxel if doPlotTrialsActiveVoxel stringTitle = sprintf('All trials from active voxel [%d %d %d]', ... idxActiveVoxel(1), idxActiveVoxel(2), idxActiveVoxel(3)); figure('Name', stringTitle); ally = squeeze(y.data(idxActiveVoxel(1),idxActiveVoxel(2),idxActiveVoxel(3),:,:)); plot(y.dimInfo.samplingPoints{4}, ally); hold all; meany = mean(ally,2); stdy = std(ally,0,2); plot(y.dimInfo.samplingPoints{4}, meany, 'g-', 'LineWidth',4) plot(y.dimInfo.samplingPoints{4}, meany-stdy,'k:', 'LineWidth',2) plot(y.dimInfo.samplingPoints{4}, meany+stdy,'k:', 'LineWidth',2) title(stringTitle); end %% evaluate time series: extract roi from both raw and epoched data x.extract_rois(M); x.compute_roi_stats(); y.extract_rois(M); y.compute_roi_stats(); % plot with corresponding time vector if doPlotRoi x.rois{1}.plot() y.rois{1}.plot() end %% Actual unit test expSolution = 0; actSolution.data = 0; absTol = 10e-7; %% verify equality of expected and actual solution % import matlab.unittests to apply tolerances for objects this.verifyEqual(actSolution.data, expSolution, 'absTol', absTol);
\documentclass{beamer} \usepackage{dcolumn} \usepackage{listings} \lstset{basicstyle=\scriptsize, showspaces=false, showtabs=false, showstringspaces=false, breaklines, prebreak=..., tabsize=2} \usepackage{graphicx} \usepackage{textcomp} \usepackage{url} \usepackage{hanging} \urlstyle{rm} \newcolumntype{.}{D{.}{.}{-1}} \newcolumntype{d}[1]{D{.}{.}{#1}} \usetheme{JuanLesPins} \setbeamertemplate{footnote}{% \hangpara{2em}{1}% \makebox[2em][l]{\insertfootnotemark}\footnotesize\insertfootnotetext\par% } \beamertemplatenavigationsymbolsempty \title[]{Getting Started} \subtitle{Introduction to Java} \author{Alan Hohn\\ \texttt{[email protected]}} \date{25 June 2013} \begin{document} \begin{frame} \titlepage \end{frame} \begin{frame} \frametitle{Contents} \tableofcontents[] \end{frame} \section{Introduction to the Course} \begin{frame} \frametitle{Course Purpose} \begin{itemize} \item This course is an introduction to Java \item Assumes programming experience, but little or no Java background \item Tries to prepare software engineers for real-world Java \begin{itemize} \item Large-scale applications \item Distributed communications \item Commonly-used Java build tools \end{itemize} \item Originally delivered to help a team of about 30 experienced software engineers who were new to Java and had a large-scale application to build \end{itemize} \end{frame} \begin{frame} \frametitle{Course Contents} \begin{itemize} \item Getting started writing Java programs (today) \item Java programming language basics (4 sessions) \item Packaging Java programs (1 session) \item Core library features (6 sessions) \item Java user interfaces (2 sessions) \end{itemize} \end{frame} \section{About Java} \begin{frame} \frametitle{Java Portability} \begin{itemize} \item A key motivation for Java is portability (ability to run on different platforms without recompiling) \item This is accomplished by compiling for a ``virtual machine'' with its own instruction set \begin{itemize} \item Known, appropriately, as the Java Virtual Machine (JVM) \item JVM instructions are called ``bytecode'' \item Looks like assembly / machine language, but with added features like virtual function calls \end{itemize} \item The JVM provides a way to run bytecode on a specific operating system / machine instruction set \item Generally, the same bytecode can be run unmodified on any JVM \end{itemize} \end{frame} \begin{frame} \frametitle{Interpreted vs. Compiled} \begin{itemize} \item Java is not really an interpreted language \begin{itemize} \item Java source code must be compiled to bytecode before it can be run \item Bytecode is sometimes translated on-the-fly to machine instructions \item Most JVMs provide a Just-In-Time compiler so ``hotspots'' are compiled down to machine instructions for speed \end{itemize} \end{itemize} \end{frame} \begin{frame} \frametitle{Java vs. JVM} \begin{itemize} \item Java is a programming language \item The JVM is a general-purpose environment for running bytecode \item In theory, any language could be compiled to bytecode \item There are many scripting languages that can be run on the JVM \begin{itemize} \item Groovy, Ruby (via JRuby), Scala, etc. \item \url{http://en.wikipedia.org/wiki/List_of_JVM_languages} \end{itemize} \item It's important to understand the distinction between source code (e.g. Java) compiled to bytecode and a scripting language with a runtime interpreter in the JVM \end{itemize} \end{frame} \begin{frame} \frametitle{JRE vs. JDK} \begin{itemize} \item JVMs typically come in two different packages \item The Java Runtime Environment (JRE) provides just the JVM plus some core libraries \item The Java Development Kit (JDK) provides a JRE plus the Java compiler (javac), documentation tools, and various other useful things \item Integrated Development Environments (IDEs) such as Eclipse often also include a built-in Java compiler, debugger, or other tools \end{itemize} \end{frame} \section{Basic Java Syntax} \begin{frame}[fragile] \frametitle{Hello World in Java} \lstinputlisting[language=Java]{../examples/src/org/anvard/introtojava/HelloWorld.java} \end{frame} \begin{frame}[fragile] \frametitle{A Little More Syntax} \lstinputlisting[language=Java]{../examples/src/org/anvard/introtojava/HelloName.java} \end{frame} \begin{frame} \frametitle{Java Memory Management} \begin{itemize} \item That program raises questions about memory management \begin{itemize} \item We used the \texttt{new} keyword to make some objects \item We didn't ``free'' those objects, set them to \texttt{null}, or otherwise worry about them \end{itemize} \item In Java, new objects are allocated on the ``heap'' \begin{itemize} \item The JVM manages the heap \item When the heap (or part of it) gets full, the JVM does ``garbage collection'' \item This means identifying objects that are no longer referenced from live code and freeing the memory \end{itemize} \item Object allocation happens all the time in Java \begin{itemize} \item Most objects are short-lived \item For example, the \texttt{readLine} method and the \texttt{+} operator both instantiated new string objects \item Modern JVMs are optimized for lots of short-lived objects, so this is surprisingly performant \item We'll talk later about how to avoid performance issues with object instantiation \end{itemize} \end{itemize} \end{frame} \section{Getting Started} \begin{frame}[fragile] \frametitle{Editing in Eclipse} \begin{picture}(0,0)(-20,120) \put(0,0){\includegraphics[width=0.9\textwidth]{screens/Slide1.png}} \end{picture} \end{frame} \begin{frame}[fragile] \frametitle{Running in Eclipse} \begin{picture}(0,0)(-20,120) \put(0,0){\includegraphics[width=0.9\textwidth]{screens/Slide2.png}} \end{picture} \end{frame} \begin{frame}[fragile] \frametitle{Debugging in Eclipse} \begin{picture}(0,0)(-20,120) \put(0,0){\includegraphics[width=0.9\textwidth]{screens/Slide3.png}} \end{picture} \end{frame} \begin{frame} \frametitle{Working in Eclipse} \begin{itemize} \item Eclipse performs continuous background compiling \begin{itemize} \item Errors are displayed immediately \item The compiled class files are kept in an ``output'' folder (\texttt{bin} by default) \end{itemize} \item As dependencies are added to the ``build path'' for the project, they automatically become available for compiling and running \item Eclipse can also connect to externally running Java programs (locally or on a network) for debugging \end{itemize} \end{frame} \begin{frame}[fragile] \frametitle{Compiling from the command line} \begin{itemize} \item The \texttt{javac} command is used for compiling from the command line \begin{itemize} \item For all but simple examples, it is not usually used directly \item Later we will discuss build tools such as Apache Ant \end{itemize} \item Command line compiling must be done from the top level, not inside any packages \item Any required libraries must be specified in the ``classpath'' \end{itemize} This command creates a HelloWorld.class in the same directory as HelloWorld.java \lstset{language=} \begin{lstlisting} $ javac org/anvard/introtojava/HelloWorld.java \end{lstlisting} \end{frame} \begin{frame}[fragile] \frametitle{Running from the command line} \begin{itemize} \item Java programs can be run directly using the command \texttt{java} \item Later we will talk about packaging applications to avoid the command line \item When running a Java program, we specify the ``main class'', so it is OK for multiple Java classes to have a ``main'' method \end{itemize} \lstset{language=} \begin{lstlisting} $ java -cp . org.anvard.introtojava.HelloWorld Hello world \end{lstlisting} \lstset{language=} \begin{lstlisting} $ java -cp . org.anvard.introtojava.HelloName What is your name? John Jacob Jingleheimer Schmidt You have a long name. Hello, John Jacob Jingleheimer Schmidt \end{lstlisting} \end{frame} \begin{frame}[fragile] \frametitle{The Java ``Classpath''} \begin{itemize} \item The classpath tells Java where to look for class files \begin{itemize} \item For compiling, this means already compiled code used as a dependency \item For running, this means all classes the Java program will need \end{itemize} \item The ``classpath'' is just a list of locations to search for class files and other resources \item The individual items can be directories, archive files, or arbitrary URLs \item The standard Java library is always on the classpath \item For our simple example, we just needed the current directory on the classpath \end{itemize} \lstset{language=} \begin{lstlisting} $ java -cp . org.anvard.introtojava.HelloWorld Hello world \end{lstlisting} \end{frame} \begin{frame} \frametitle{Java Classpath issues} \begin{itemize} \item Classpath issues can be a source of frustration in running Java programs \item Classes are found and loaded dynamically, so classpath issues might not be discovered until the program is running \item Multiple classes on the classpath can have the same name \begin{itemize} \item The ``first'' one will be used \item This can be confusing \item Good package naming and organization will usually avoid this problem \end{itemize} \end{itemize} \end{frame} \begin{frame} \frametitle{Next Time} \begin{itemize} \item Java Objects and Classes \item Brief overview of Object-Oriented Programming \item Distinction between primitive types and objects \item Distinction between static and instance variables \end{itemize} \end{frame} \begin{frame} \frametitle{Credit in LMPeople} \begin{center} LMPeople Course Code: 071409ILT01 \end{center} \end{frame} \end{document}
import numpy as np from gpkit import Model, Variable, SignomialsEnabled, SignomialEquality, VarKey, units, Vectorize # Importing atmospheric model from gpkitmodels.SP.atmosphere.atmosphere import Atmosphere # SimPleAC with mission design and flight segments, and lapse rate and BSFC model (3.4.2) class SimPleAC(Model): def setup(self): self.engine = Engine() self.wing = Wing() self.fuse = Fuselage() self.components = [self.engine, self.wing, self.fuse] # Environmental constants g = Variable("g", 9.81, "m/s^2", "gravitational acceleration") rho_f = Variable("\\rho_f", 817, "kg/m^3", "density of fuel") # Free Variables W = Variable("W", "N", "maximum takeoff weight") W_f = Variable("W_f", "N", "maximum fuel weight") V_f = Variable("V_f", "m^3", "maximum fuel volume") V_f_avail = Variable("V_{f_{avail}}", "m^3", "fuel volume available") constraints = [] # Fuel volume model with SignomialsEnabled(): constraints += [V_f == W_f / g / rho_f, V_f_avail <= self.wing['V_{f_{wing}}'] + self.fuse['V_{f_{fuse}}'], #[SP] V_f_avail >= V_f] return constraints, self.components def dynamic(self,state): return SimPleACP(self,state) class SimPleACP(Model): def setup(self,aircraft,state): self.aircraft = aircraft self.engineP = aircraft.engine.dynamic(state) self.wingP = aircraft.wing.dynamic(state) self.fuseP = aircraft.fuse.dynamic(state) self.Pmodels = [self.engineP, self.wingP, self.fuseP] # Free variables C_D = Variable("C_D", "-", "drag coefficient") D = Variable("D", "N", "total drag force") LoD = Variable('L/D','-','lift-to-drag ratio') V = Variable("V", "m/s", "cruising speed") constraints = [] constraints += [self.engineP['T'] * V <= self.aircraft.engine['\\eta_{prop}'] * self.engineP['P_{shaft}'], C_D >= self.fuseP['C_{D_{fuse}}'] + self.wingP['C_{D_{wpar}}'] + self.wingP['C_{D_{ind}}'], D >= 0.5 * state['\\rho'] * self.aircraft['S'] * C_D * V ** 2, self.wingP['Re'] == (state['\\rho'] / state['\\mu']) * V * (self.aircraft['S'] / self.aircraft['A']) ** 0.5, self.fuseP['Re_{fuse}'] == state['\\rho']*V*self.aircraft.fuse['l_{fuse}']/state['\\mu'], LoD == self.wingP['C_L'] / C_D] return constraints, self.Pmodels class Fuselage(Model): def setup(self): # Free Variables S = Variable('S_{fuse}', 'm^2', 'fuselage surface area') l = Variable('l_{fuse}', 'm', 'fuselage length') r = Variable('r_{fuse}', 'm', 'fuselage minor radius') f = Variable('f_{fuse}', '-', 'fuselage fineness ratio', fix = True) k = Variable('k_{fuse}', '-', 'fuselage form factor') # Free variables (fixed for performance eval.) V = Variable('V_{fuse}', 'm^3', 'total volume in the fuselage', fix = True) V_f_fuse = Variable('V_{f_{fuse}}','m^3','fuel volume in the fuselage') W_fuse = Variable('W_{fuse}', 'N', 'fuselage weight') p = 1.6075 constraints = [f == l/r/2, f <= 6, k >= 1 + 60/f**3 + f/400, 3*(S/np.pi)**p >= 2*(l*2*r)**p + (2*r)**(2*p), V == 4./6.*np.pi*r**2*l, V_f_fuse >= 1*10**-10*units('m^3'), ] return constraints def dynamic(self,state): return FuselageP(self,state) class FuselageP(Model): def setup(self,fuselage,state): # Constants Cfref = Variable('C_{f_{fuse,ref}}', 0.455, '-', 'fuselage reference skin friction coefficient', pr=10.) # Free Variables Re = Variable('Re_{fuse}', '-', 'fuselage Reynolds number') Cf = Variable('C_{f_{fuse}}', '-', 'fuselage skin friction coefficient') Cd = Variable('C_{D_{fuse}}', '-', 'fuselage drag coefficient') constraints = [Cf >= Cfref/Re**0.3, Cd >= fuselage['k_{fuse}']*Cf, ] return constraints class Wing(Model): def setup(self): # Non-dimensional constants C_Lmax = Variable("C_{L,max}", 1.6, "-", "lift coefficient at stall", pr=5.) e = Variable("e", 0.92, "-", "Oswald efficiency factor", pr=3.) # k = Variable("k", "-", "form factor") N_ult = Variable("N_{ult}", 3, "-", "ultimate load factor", pr=15.) # S_wetratio = Variable("(\\frac{S}{S_{wet}})", "-", "wetted area ratio") tau = Variable("\\tau", "-", "airfoil thickness to chord ratio") tau_ref = Variable("\\tau_{ref}", 0.12, "-", "reference airfoil thickness to chord ratio") # Dimensional constants W_w_coeff1 = Variable("W_{w_{coeff1}}", 2e-5, "1/m", "wing weight coefficient 1", pr= 30.) #orig 12e-5 W_w_coeff2 = Variable("W_{w_{coeff2}}", 60., "Pa", "wing weight coefficient 2", pr=10.) # Free Variables (fixed for performance eval.) A = Variable("A", "-", "aspect ratio",fix = True) S = Variable("S", "m^2", "total wing area", fix = True) W_w = Variable("W_w", "N", "wing weight") W_w_strc = Variable('W_{w_{strc}}','N','wing structural weight', fix = True) W_w_surf = Variable('W_{w_{surf}}','N','wing skin weight', fix = True) V_f_wing = Variable("V_{f_{wing}}",'m^3','fuel volume in the wing', fix = True) constraints = [] # Structural model constraints += [W_w_surf >= W_w_coeff2 * S, W_w >= W_w_surf + W_w_strc] # Wing fuel and form factor model constraints += [V_f_wing**2 <= 0.0009*S**3/A*tau**2, # linear with b and tau, quadratic with chord tau >= 0.08, tau <= 0.23, ] # Form factor model return constraints def dynamic(self,state): return WingP(self,state) class WingP(Model): def setup(self,wing,state): self.wing = wing # Free Variables C_D_ind = Variable('C_{D_{ind}}', '-', "wing induced drag coefficient") C_D_wpar = Variable('C_{D_{wpar}}', '-', "wing profile drag coefficient") C_L = Variable("C_L", "-", "wing lift coefficient") Re = Variable("Re", "-", "Reynolds number") Re_ref = Variable("Re_{ref}", 1500000, "-", "reference Reynolds number") constraints = [] # Drag model w = C_D_wpar u_1 = C_L u_2 = Re/Re_ref u_3 = self.wing['\\tau']/self.wing['\\tau_{ref}'] constraints += [C_D_ind == C_L ** 2 / (np.pi * self.wing['A'] * self.wing['e']), w**0.00488697 >= 0.000347324 * (u_1)**6.64787 * (u_2)**-0.00842527 * (u_3)**-0.406817 + 0.974515 * (u_1)**-0.00206058 * (u_2)**-0.00117649 * (u_3)**-0.000597604 + 0.000211504 * (u_1)**1.35483 * (u_2)**-0.252459 * (u_3)**3.91243] return constraints class Engine(Model): def setup(self): # Dimensional constants BSFC_ref = Variable("BSFC_{ref}", 0.32, "lbf/(hp*hr)", "reference brake specific fuel consumption") eta_prop = Variable("\\eta_{prop}",0.8,'-',"propeller efficiency") P_shaft_ref = Variable("P_{shaft,ref}", 10, "hp", "reference MSL maximum shaft power") W_e_ref = Variable("W_{e,ref}", 10, "lbf","reference engine weight") h_ref = Variable("h_{ref}", 15000,'ft','engine lapse reference altitude') # Free variables P_shaft_max = Variable("P_{shaft,max}","kW","MSL maximum shaft power") W_e = Variable("W_e","N","engine weight") constraints = [(W_e/W_e_ref) == 1.27847 * (P_shaft_max/P_shaft_ref)**0.772392] return constraints def dynamic(self,state): return EngineP(self,state) class EngineP(Model): def setup(self,engine,state): self.engine = engine # Dimensional constants # Free variables BSFC = Variable("BSFC", "lbf/(hp*hr)", "brake specific fuel consumption") P_shaft = Variable("P_{shaft}","kW","shaft power") P_shaft_alt = Variable("P_{shaft,alt}","kW",'maximum shaft power at altitude') Thrust = Variable("T","N","propeller thrust") L = Variable("L","-","power lapse percentage") constraints = [] with SignomialsEnabled(): constraints += [P_shaft <= P_shaft_alt, L == (0.937 * (state['h']/self.engine['h_{ref}'])**0.0922)**10, SignomialEquality(1, L + P_shaft_alt / self.engine['P_{shaft,max}']), (BSFC/self.engine['BSFC_{ref}'])**(0.1) >= 0.984*(P_shaft/P_shaft_alt)**-0.0346, BSFC/self.engine['BSFC_{ref}'] >= 1., ] return constraints class Mission(Model): def setup(self,aircraft,Nsegments): self.aircraft = aircraft W_f_m = Variable('W_{f_m}','N','total mission fuel') t_m = Variable('t_m','hr','total mission time') with Vectorize(Nsegments): Wavg = Variable('W_{avg}','N','segment average weight') Wstart = Variable('W_{start}', 'N', 'weight at the beginning of flight segment') Wend = Variable('W_{end}', 'N', 'weight at the end of flight segment') h = Variable('h','m','final segment flight altitude') havg = Variable('h_{avg}','m','average segment flight altitude') dhdt = Variable('\\frac{dh}{dt}','m/hr','climb rate') W_f_s = Variable('W_{f_s}','N', 'segment fuel burn') t_s = Variable('t_s','hr','time spent in flight segment') R_s = Variable('R_s','km','range flown in segment') state = Atmosphere() self.aircraftP = self.aircraft.dynamic(state) # Mission variables hcruise = Variable('h_{cruise_m}', 'm', 'minimum cruise altitude') Range = Variable("Range_m", "km", "aircraft range") W_p = Variable("W_{p_m}", "N", "payload weight", pr=20.) rho_p = Variable("\\rho_{p_m}", "kg/m^3", "payload density", pr = 10.) V_min = Variable("V_{min_m}", "m/s", "takeoff speed", pr=20.) TOfac = Variable('T/O factor_m', '-','takeoff thrust factor') cost_index = Variable("C_m", '1/hr','hourly cost index') constraints = [] # Setting up the mission with SignomialsEnabled(): constraints += [havg == state['h'], # Linking states h[1:Nsegments-1] >= hcruise, # Adding minimum cruise altitude # Weights at beginning and end of mission Wstart[0] >= W_p + self.aircraft.wing['W_w'] + self.aircraft.engine['W_e'] + self.aircraft.fuse['W_{fuse}'] + W_f_m, Wend[Nsegments-1] >= W_p + self.aircraft.wing['W_w'] + self.aircraft.engine['W_e'] + self.aircraft.fuse['W_{fuse}'], # Lift, and linking segment start and end weights Wavg <= 0.5 * state['\\rho'] * self.aircraft['S'] * self.aircraftP.wingP['C_L'] * self.aircraftP['V'] ** 2, Wstart >= Wend + W_f_s, # Making sure fuel gets burnt! Wstart[1:Nsegments] == Wend[:Nsegments-1], Wavg == Wstart ** 0.5 * Wend ** 0.5, # Altitude changes h[0] == t_s[0]*dhdt[0], # Starting altitude dhdt >= 1.*units('m/hr'), havg[0] == 0.5*h[0], havg[1:Nsegments] == (h[1:Nsegments]*h[0:Nsegments-1])**(0.5), SignomialEquality(h[1:Nsegments],h[:Nsegments-1] + t_s[1:Nsegments]*dhdt[1:Nsegments]), # Thrust and fuel burn W_f_s >= self.aircraftP.engineP['BSFC'] * self.aircraftP.engineP['P_{shaft}'] * t_s, self.aircraftP.engineP['T'] * self.aircraftP['V'] >= self.aircraftP['D'] * self.aircraftP['V'] + Wavg * dhdt, # Max MSL thrust at least 2*climb thrust self.aircraft.engine['P_{shaft,max}'] >= TOfac*self.aircraftP.engineP['P_{shaft}'][0], # Flight time t_s == R_s/self.aircraftP['V'], # Aggregating segment variables self.aircraft['W_f'] >= W_f_m, R_s == Range/Nsegments, # Dividing into equal range segments W_f_m >= sum(W_f_s), t_m >= sum(t_s) ] # Maximum takeoff weight constraints += [self.aircraft['W'] >= W_p + self.aircraft.wing['W_w'] + self.aircraft['W_f'] + self.aircraft.engine['W_e'] + self.aircraft.fuse['W_{fuse}']] # Stall constraint constraints += [self.aircraft['W'] <= 0.5 * state['\\rho'] * self.aircraft['S'] * self.aircraft['C_{L,max}'] * V_min ** 2] # Wing weight model constraints += [self.aircraft.wing['W_{w_{strc}}']**2. >= self.aircraft.wing['W_{w_{coeff1}}']**2. / self.aircraft.wing['\\tau']**2. * (self.aircraft.wing['N_{ult}']**2. * self.aircraft.wing['A'] ** 3. * ((W_p + self.aircraft.fuse['W_{fuse}'] + self.aircraft['W_e'] + self.aircraft.fuse['V_{f_{fuse}}']*self.aircraft['g']*self.aircraft['\\rho_f']) * self.aircraft['W'] * self.aircraft.wing['S']))] # Fuselage volume and weight constraints += [self.aircraft.fuse['V_{fuse}'] >= self.aircraft.fuse['V_{f_{fuse}}'] + W_p/(rho_p*self.aircraft['g']), self.aircraft.fuse['W_{fuse}'] == self.aircraft.fuse['S_{fuse}']*self.aircraft.wing['W_{w_{coeff2}}'], ] # Upper bounding variables constraints += [t_m <= 100000*units('hr'), W_f_m <= 1e10*units('N'), cost_index >= 1e-10*units('1/hr')] return constraints, state, self.aircraft, self.aircraftP def test(): m = Mission(SimPleAC(),4) m.substitutions.update({ 'h_{cruise_m}' :5000*units('m'), 'Range_m' :3000*units('km'), 'W_{p_m}' :3000*units('N'), '\\rho_{p_m}' :1500*units('kg/m^3'), 'C_m' :120*units('1/hr'), 'V_{min_m}' :35*units('m/s'), 'T/O factor_m' :2, }) m.cost = m['W_{f_m}']*units('1/N') + m['C_m']*m['t_m'] sol = m.localsolve(verbosity = 2) if __name__ == "__main__": # Most basic way to execute the model m = Mission(SimPleAC(),4) m.substitutions.update({ 'h_{cruise_m}' :5000*units('m'), 'Range_m' :3000*units('km'), 'W_{p_m}' :3000*units('N'), '\\rho_{p_m}' :1500*units('kg/m^3'), 'C_m' :120*units('1/hr'), 'V_{min_m}' :35*units('m/s'), 'T/O factor_m' :2, }) m.cost = m['W_{f_m}']*units('1/N') + m['C_m']*m['t_m'] sol = m.localsolve(verbosity = 4) #print sol.table()
```python from skydy.connectors import DOF, Connection, Joint from skydy.multibody import MultiBody from skydy.rigidbody import ( Body, BodyCoordinate, BodyForce, BodyTorque, Ground, GroundCoordinate, ) ``` ```python l_pen = 2 w_pen = 0 h_pen = 0 pen_name = "1" # Define the body b_pen = Body(pen_name) # Instantiate the pen's dimensions b_pen.dims.assign_values([l_pen, w_pen, h_pen]) # Add torque to pen about the pen's y-coordinaate. T1 = BodyTorque(name="1", y_dir=True) # Torque is applied at the COM torque_loc = BodyCoordinate("PF1", 0, 0, 0) # Add the Torque at the location b_pen.add_torque(T1, torque_loc) # Instantiate the ground b_gnd = Ground() p_gnd = GroundCoordinate() # Location of pen wrt ground p_pen = BodyCoordinate("G1/O", l_pen / 2, 0, 0) # Degrees of freedom pen_dofs = [DOF(4)] # Ground to pen joint j1 = Joint(p_gnd, p_pen, pen_dofs, name=p_gnd.name) # The connection of the bodies through the joint cnx_pen = Connection(b_gnd, j1, b_pen) # The multibody object oned_pen = MultiBody([cnx_pen], "pen") ``` ```python poles = oned_pen.poles(True) poles ``` {-3.13209195267317*sqrt(-sin(theta^1_y(t))): 1, 3.13209195267317*sqrt(-sin(theta^1_y(t))): 1} ```python import sympy as sym sym.Matrix(list(poles.keys())) ``` $\displaystyle \left[\begin{matrix}- 3.13209195267317 \sqrt{- \sin{\left(\theta^{1}_{y}{\left(t \right)} \right)}}\\3.13209195267317 \sqrt{- \sin{\left(\theta^{1}_{y}{\left(t \right)} \right)}}\end{matrix}\right]$ ```python c_eum, f_eum = oned_pen.get_equilibria() ``` ```python oned_pen.controllable() ``` True ```python oned_pen.is_stable() ``` [[{theta^1_y(t): pi/2}, True], [{theta^1_y(t): 3*pi/2}, False]]
import analysis.inner_product_space.pi_L2 import topology.paracompact --OUTPUT 1 theorem ℝn_paracompact (n : β„•) : paracompact_space (euclidean_space ℝ (fin n)) := begin assume (U : set (euclidean_space ℝ (fin n))) (hU : is_open U) (hcover : βˆ€ x : euclidean_space ℝ (fin n), βˆƒ V ∈ U, x ∈ V), have h1 : βˆ€ m : β„•, βˆƒ (Cm : set (euclidean_space ℝ (fin n))), (βˆ€ (V : set (euclidean_space ℝ (fin n))), V ∈ Cm β†’ V βŠ† (euclidean_space ℝ (fin n)) βˆ– (closure (ball (0 : euclidean_space ℝ (fin n)) m))) ∧ (βˆ€ (V : set (euclidean_space ℝ (fin n))), V ∈ Cm β†’ βˆƒ (W : set (euclidean_space ℝ (fin n))), W ∈ U ∧ V βŠ† W) ∧ (βˆ€ (V : set (euclidean_space ℝ (fin n))), V ∈ Cm β†’ βˆƒ (W : set (euclidean_space ℝ (fin n))), W ∈ U ∧ V ∩ (closure (ball (0 : euclidean_space ℝ (fin n)) m)) βŠ† W) ∧ (βˆ€ (V : set (euclidean_space ℝ (fin n))), V ∈ Cm β†’ βˆƒ (W : set (euclidean_space ℝ (fin n))), W ∈ U ∧ V ∩ (ball (0 : euclidean_space ℝ (fin n)) m) βŠ† W), from assume m : β„•, have h1 : βˆƒ (Cm : set (euclidean_space ℝ (fin n))), (βˆ€ (V : set (euclidean_space ℝ (fin n))), V ∈ Cm β†’ V βŠ† (euclidean_space ℝ (fin n)) βˆ– (closure (ball (0 : euclidean_space ℝ (fin n)) m))) ∧ (βˆ€ (V : set (euclidean_space ℝ (fin n))), V ∈ Cm β†’ βˆƒ (W : set (euclidean_space ℝ (fin n))), W ∈ U ∧ V βŠ† W) ∧ (βˆ€ (V : set (euclidean_space ℝ (fin n))), V ∈ Cm β†’ βˆƒ (W : set (euclidean_space ℝ (fin n))), W ∈ U ∧ V ∩ (closure (ball (0 : euclidean_space ℝ (fin n)) m)) βŠ† W), from have h1 : βˆƒ (Cm : set (euclidean_space ℝ (fin n))), (βˆ€ (V : set (euclidean_space ℝ (fin n))), V ∈ Cm β†’ V βŠ† (euclidean_space ℝ (fin n)) βˆ– (closure (ball (0 : euclidean_space ℝ (fin n)) m))) ∧ (βˆ€ (V : set (euclidean_space ℝ (fin n))), V ∈ Cm β†’ βˆƒ (W : set (euclidean_space ℝ (fin n))), W ∈ U ∧ V βŠ† W), from have h1 : βˆƒ (Cm : set (euclidean_space ℝ (fin n))), (βˆ€ (V : set (euclidean_space ℝ (fin n))), V ∈ Cm β†’ V βŠ† (euclidean_space ℝ (fin n)) βˆ– (closure (ball (0 : euclidean_space ℝ (fin n)) m))) ∧ (βˆ€ (V : set (euclidean_space ℝ (fin n))), V ∈ Cm β†’ βˆƒ (W : set (euclidean_space ℝ (fin n))), W ∈ U ∧ V βŠ† W), from have h1 : βˆƒ (Cm : set (euclidean_space ℝ (fin n))), (βˆ€ (V : set (euclidean_space ℝ (fin n))), V ∈ Cm β†’ V βŠ† (euclidean_space ℝ (fin n)) βˆ– (closure (ball (0 : euclidean_space ℝ (fin n)) m))), from have h1 : βˆƒ (Cm : set (euclidean_space ℝ (fin n))), (βˆ€ (V : set (euclidean_space ℝ (fin n))), V ∈ Cm β†’ V βŠ† (euclidean_space ℝ (fin n)) βˆ– (closure (ball (0 : euclidean_space ℝ (fin n)) m))), from have h1 : βˆƒ (Cm : set (euclidean_space ℝ (fin n))), (βˆ€ (V : set (euclidean_space ℝ (fin n))), V ∈ Cm β†’ V βŠ† (euclidean_space ℝ (fin n)) βˆ– (closure (ball (0 : euclidean_space ℝ (fin n)) m))), from have h1 : βˆƒ (Cm : set (euclidean_space ℝ (fin n))), (βˆ€ (V : set (euclidean_space ℝ (fin n))), V ∈ Cm β†’ V βŠ† (euclidean_space ℝ (fin n)) βˆ– (closure (ball (0 : euclidean_space ℝ (fin n)) m))), from have h1 : βˆƒ (Cm : set (euclidean_space ℝ (fin n))), (βˆ€ (V : set (euclidean_space ℝ (fin n))), V ∈ Cm β†’ V βŠ† (euclidean_space ℝ (fin n)) βˆ– (closure (ball (0 : euclidean_space ℝ (fin n)) m))), from have h1 : βˆƒ (Cm : set (euclidean_space ℝ (fin n))), (βˆ€ (V : set (euclidean_space ℝ (fin n))), V ∈ Cm β†’ V βŠ† (euclidean_space ℝ (fin n)) βˆ– (closure (ball (0 : euclidean_space ℝ (fin n)) m))), from have h1 : βˆƒ (Cm : set (euclidean_space ℝ (fin n))), (βˆ€ (V : set (euclidean_space ℝ (fin n))), V ∈ Cm β†’ V βŠ† (euclidean_space ℝ (fin n)) βˆ– (closure (ball (0 : euclidean_space ℝ (fin n)) m))), from have h1 : βˆƒ (Cm : set (euclidean_space ℝ (fin n))), (βˆ€ (V : set (euclidean_space ℝ (fin n))), V ∈ Cm β†’ V βŠ† (euclidean_space ℝ (fin n)) βˆ– (closure (ball (0 : euclidean_space ℝ (fin n)) m))), from have h1 : βˆƒ (Cm : set (euclidean_space ℝ (fin n))), (βˆ€ (V : set (euclidean_space ℝ (fin n))), V ∈ Cm β†’ V βŠ† (euclidean_space ℝ (fin n)) βˆ– (closure (ball (0 : euclidean_space ℝ (fin n)) m))), from have h1 : βˆƒ (Cm : set (euclidean_space ℝ (fin n))), (βˆ€ (V : set (euclidean_space ℝ (fin n))), V ∈ Cm β†’ V βŠ† (euclidean_space ℝ (fin n)) βˆ– (closure (ball (0 : euclidean_space ℝ (fin n)) m))), from have h1 : βˆƒ end --Needs more than 2000 tokens! /- FEW SHOT PROMPTS TO CODEX(START) /--`theorem` Power Set is Closed under Intersection Let $S$ be a set. Let $\powerset S$ be the power set of $S$. Then: :$\forall A, B \in \powerset S: A \cap B \in \powerset S$ `proof` Let $A, B \in \powerset S$. Then by the definition of power set, $A \subseteq S$ and $B \subseteq S$. From Intersection is Subset we have that $A \cap B \subseteq A$. It follows from Subset Relation is Transitive that $A \cap B \subseteq S$. Thus $A \cap B \in \powerset S$ and closure is proved. {{qed}} -/ theorem power_set_intersection_closed {Ξ± : Type*} (S : set Ξ±) : βˆ€ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S := begin assume (A : set Ξ±) (hA : A ∈ 𝒫 S) (B : set Ξ±) (hB : B ∈ 𝒫 S), have h1 : (A βŠ† S) ∧ (B βŠ† S), from by {split,apply set.subset_of_mem_powerset,exact hA,apply set.subset_of_mem_powerset,exact hB}, have h2 : (A ∩ B) βŠ† A, from by apply set.inter_subset_left, have h3 : (A ∩ B) βŠ† S, from by {apply set.subset.trans h2 h1.left}, show (A ∩ B) ∈ 𝒫 S, from by {apply set.mem_powerset h3}, end /--`theorem` Square of Sum :$\forall x, y \in \R: \paren {x + y}^2 = x^2 + 2 x y + y^2$ `proof` Follows from the distribution of multiplication over addition: {{begin-eqn}} {{eqn | l = \left({x + y}\right)^2 | r = \left({x + y}\right) \cdot \left({x + y}\right) }} {{eqn | r = x \cdot \left({x + y}\right) + y \cdot \left({x + y}\right) | c = Real Multiplication Distributes over Addition }} {{eqn | r = x \cdot x + x \cdot y + y \cdot x + y \cdot y | c = Real Multiplication Distributes over Addition }} {{eqn | r = x^2 + 2xy + y^2 | c = }} {{end-eqn}} {{qed}} -/ theorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := begin calc (x + y)^2 = (x+y)*(x+y) : by rw sq ... = x*(x+y) + y*(x+y) : by rw add_mul ... = x*x + x*y + y*x + y*y : by {rw [mul_comm x (x+y),mul_comm y (x+y)], rw [add_mul,add_mul], ring} ... = x^2 + 2*x*y + y^2 : by {repeat {rw ← sq}, rw mul_comm y x, ring} end /--`theorem` Identity of Group is Unique Let $\struct {G, \circ}$ be a group. Then there is a unique identity element $e \in G$. `proof` From Group has Latin Square Property, there exists a unique $x \in G$ such that: :$a x = b$ and there exists a unique $y \in G$ such that: :$y a = b$ Setting $b = a$, this becomes: There exists a unique $x \in G$ such that: :$a x = a$ and there exists a unique $y \in G$ such that: :$y a = a$ These $x$ and $y$ are both $e$, by definition of identity element. {{qed}} -/ theorem group_identity_unique {G : Type*} [group G] : βˆƒ! e : G, βˆ€ a : G, e * a = a ∧ a * e = a := begin have h1 : βˆ€ a b : G, βˆƒ! x : G, a * x = b, from by { assume a b : G, use a⁻¹ * b, obviously, }, have h2 : βˆ€ a b : G, βˆƒ! y : G, y * a = b, from by { assume a b : G, use b * a⁻¹, obviously, }, have h3 : βˆ€ a : G, βˆƒ! x : G, a * x = a, from assume a : G, h1 a a, have h4 : βˆ€ a : G, βˆƒ! y : G, y * a = a, from assume a : G, h2 a a, have h5 : βˆ€ a : G, classical.some (h3 a).exists = (1 : G), from assume a :G, exists_unique.unique (h3 a) (classical.some_spec (exists_unique.exists (h3 a))) (mul_one a), have h6 : βˆ€ a : G, classical.some (h4 a).exists = (1 : G), from assume a : G, exists_unique.unique (h4 a) (classical.some_spec (exists_unique.exists (h4 a))) (one_mul a), show βˆƒ! e : G, βˆ€ a : G, e * a = a ∧ a * e = a, from by { use (1 : G), have h7 : βˆ€ e : G, (βˆ€ a : G, e * a = a ∧ a * e = a) β†’ e = 1, from by { assume (e : G) (hident : βˆ€ a : G, e * a = a ∧ a * e = a), have h8 : βˆ€ a : G, e = classical.some (h3 a).exists, from assume (a : G), exists_unique.unique (h3 a) (hident a).right (classical.some_spec (exists_unique.exists (h3 a))), have h9 : βˆ€ a : G, e = classical.some (h4 a).exists, from assume (a : G), exists_unique.unique (h4 a) (hident a).left (classical.some_spec (exists_unique.exists (h4 a))), show e = (1 : G), from eq.trans (h9 e) (h6 _), }, exact ⟨by obviously, h7⟩, } end /--`theorem` \mathbb{R}^n is paracompact $\mathbb{R}^n$ is paracompact for all $n$. `proof` Let $\mathcal{A}$ be an open covering of $\mathbb{R}^n$. We now construct a locally finite open refinement $\mathcal{C}$ of $\mathcal{A}$ that covers $\mathbb{R}^n$. First, we define a collection of pen balls. Let $B_0 = \phi$, and for each $n \in \mathbb{N}$, let $B_m$ denote the ball of radius $m$ centered at 0. Given $m$, set $\Bar{B_m}$ is compact in $\mathbb{R}^n$ by the Heine-Borel theorem, so choose finitely many elements of $\mathcal{A}$ that cover $\Bar{B_m}$ and intersect each one with the open set $\mathbb{R}^n \setminus \Bar{B_{m - 1}}$, and let $\mathcal{C}_{m}$ denote this collection of open sets (each an open subset of an element of $\mathcal{A}$). So $\mathcal{C} = \bigcup_{m = 0}^{\infty} \mathcal{C}_m$ is an open refinement of $\mathcal{A}$. Note that $\mathcal{C}$ covers $\mathbb{R}^n$ since for any $x \in \mathbb{R}^n$, there is a smallest $m \in \mathbb{N}$ such that $x \in \Bar{B_{m}}$ (namely, some $m$ where $\rVert x \lVert \leq m \leq \rVert x \lVert + 1$), and so $x$ is an element of $\mathcal{C}_m$. Now collection $\mathcal{C}$ is locally finite since for given $x \in \mathbb{R}^n$, neighborhood $B_m$ intersects only finitely many elements of $\mathcal{C}$, namely those elements in collection $\mathcal{C}_1 \cup \mathcal{C}_2 \cup \cdots \mathcal{C}_m$. So $\mathcal{C}$ is a locally finite open refinement of $\mathcal{A}$ that covers $\mathbb{R}^n$, hence $\mathbb{R}^n$ is paracompact. QED -/ theorem ℝn_paracompact (n : β„•) : paracompact_space (euclidean_space ℝ (fin n)) := FEW SHOT PROMPTS TO CODEX(END)-/
[STATEMENT] lemma update_acyclic_3: assumes "acyclic (p - 1)" and "point y" and "point w" and "y \<le> p\<^sup>T\<^sup>\<star> * w" shows "acyclic ((p[w\<longmapsto>y]) - 1)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. pd_kleene_allegory_class.acyclic ((p[w\<longmapsto>y]) - (1::'a)) [PROOF STEP] by (simp add: assms bijective_reverse conv_star_commute update_acyclic_1)
lemma smult_one [simp]: "smult c 1 = [:c:]"
[STATEMENT] lemma cinner_minus_right [simp]: "cinner x (- y) = - cinner x y" [PROOF STATE] proof (prove) goal (1 subgoal): 1. cinner x (- y) = - cinner x y [PROOF STEP] using cinner_minus_left [of y x] [PROOF STATE] proof (prove) using this: cinner (- y) x = - cinner y x goal (1 subgoal): 1. cinner x (- y) = - cinner x y [PROOF STEP] by (metis complex_cnj_minus local.cinner_commute)
subroutine amrex_probinit (init,name,namlen,problo,probhi) bind(c) use amrex_fort_module, only : rt => amrex_real implicit none integer :: init, namlen integer :: name(namlen) real(rt) :: problo(2), probhi(2) end subroutine amrex_probinit ! ::: ----------------------------------------------------------- !> @brief This routine is called at problem setup time and is used !! to initialize data on each grid. !! !! @note all arrays have one cell of ghost zones surrounding !! the grid interior. Values in these cells need not !! be set here. !! !! INPUTS/OUTPUTS: !! !! level => amr level of grid !! time => time at which to init data !! lo,hi => index limits of grid interior (cell centered) !! nvar => number of state components. !! state <= scalar array !! dx => cell size !! xlo, xhi => physical locations of lower left and upper !! right hand corner of grid. (does not include !! ghost region). ! ::: ----------------------------------------------------------- subroutine ca_initdata(level,time,lo,hi,nvar, & state,state_l1,state_l2,state_h1,state_h2, & dx,xlo,xhi) use amrex_error_module use amrex_fort_module, only : rt => amrex_real implicit none integer :: level, nvar integer :: lo(2), hi(2) integer :: state_l1,state_l2,state_h1,state_h2 real(rt) :: xlo(2), xhi(2), time, dx(2) real(rt) :: state(state_l1:state_h1,state_l2:state_h2,nvar) ! Remove this call if you're defining your own problem; it is here to ! ensure that you cannot run Castro if you haven't got your own copy of this function. call amrex_error("Prob_2d.f90 has not been defined for this problem!") end subroutine ca_initdata
Formal statement is: lemma (in finite_measure) finite_measure_subadditive: assumes m: "A \<in> sets M" "B \<in> sets M" shows "measure M (A \<union> B) \<le> measure M A + measure M B" Informal statement is: If $A$ and $B$ are measurable sets, then the measure of their union is less than or equal to the sum of their measures.
character*6 function f (x) result ( z ) character :: c*3 = "abc" z = c c = z end
-- namespace hidden /- In this lecture we solve the problem of ensuring that argument values to foldr are properly coordinated. In the process we introduce *ad hoc* polymorphism (also called "operator overloading") as distinct from the *parametric* polymorphism (also called generics in Java and template classes in C++) that we've been using all semester long. - We introduce a new mechanism, typeclasses, which support ad hoc polymorphism - We see how instances of a given typeclass provide the information needed to implement an overloaded operator for a specified type of element - We see how Lean's support for typeclasss enables lookup and passing of typec lass *instances* as implicit arguments - We then see how these ideas support the representation of abstract algebraic structures. - As an example, we formalize the abstract algebraic structure known as a "monoid," as a typeclass, and we define a typeclasses instance to establish the monoid comprising the natural numbers under addition with 0 as a proven identity element. -/ /- As a first motivating example, suppose that we want to abstract the concept of being an inhabited type. A type is inhabited if it has at least one value, so one way to show that a type is inhabited it to give a particular value of that type. For example, we could show that the bool, nat, and string types are inhabited by creating instances of the following polymorphic type, with bool, nat, and string as values of Ξ±. What this type says is that you can have an instance of this type by applying the mk constructor to some specific value of the Ξ± type. -/ inductive inhabited''' (Ξ± : Type) | mk (a : Ξ±) : inhabited''' /- We can thus "show" that bool, nat, and string are all inhabited types by creating one instance of this polymorphic type for each of the type values, bool, nat, and string. -/ example : inhabited''' bool := inhabited'''.mk tt example : inhabited''' nat := inhabited'''.mk 0 example : inhabited''' string := inhabited'''.mk "" /- The next concept in line is new syntax for defining a new type in the special case where the type has just one constructor. In this case, we can use the "structure" keyword instead of inductive. Then any type arguments followed (in this example) by a := and then the definition of the *one* constructor that is allowed when using "structure." First the name is given, then :: then the *named fields* of the type are listed. The essential benefit of using "structure" is that Lean converts the field names into "accessor" functions to retrieve the field values from an instance of such a structure (a.k.a., "struct" in C and C++ or "record" in a relational database). Here then is an example equivalent to the preceding example except that "a" can now be used as the name of a function that takes an instance and returns the value of its "a" field. -/ structure inhabited'' (Ξ± : Type) := mk :: (a : Ξ±) def bool_inhab'' : inhabited'' bool := inhabited''.mk tt def nat_inhab'' : inhabited'' nat := inhabited''.mk 0 def string_inhab'' : inhabited'' string := inhabited''.mk "" open inhabited'' #eval a string_inhab'' /- Lean also provides a nice "dot" notation for applying a function to an object, so we can also write the following equivalent expression -/ #eval bool_inhab''.a -- expect tt #eval nat_inhab''.a -- expect 0 #eval string_inhab''.a -- expect "" /- Our next step is easy: When defining a structure type, you can leave out the constructor name and :: and Lean will use "mk" as a default constructor name -/ example : inhabited'' bool := inhabited''.mk tt structure inhabited' (Ξ± : Type) := (a : Ξ±) example : inhabited' bool := inhabited'.mk tt /- With what we've done already, we can now write a (parametrically) polymorphic function, "default,"" that returns a defaul value for any *type*. A type is the argument to "default" and its return value is a *value* of that type. Of course not every type is inhabited, so not every type can have a default value. We need a way to limit the application of the default function to types for which some value shows that the type is inhabited. One way to impose this constraint on the type that can be passed to the "default" function is to have it take, as a second argument, an instance of the type, (inhabited Ξ±), for whatever type, Ξ±, is given as its first argument. -/ def default''' (Ξ± : Type) (i : inhabited'' Ξ±): Ξ± := i.a #reduce default''' bool bool_inhab'' #reduce default''' nat nat_inhab'' #reduce default''' string string_inhab'' /- We can make these function applications expressions even easier to read by making the first type argument implicit, letting it be inferred from the second inhabited' argument. -/ def default'' {Ξ± : Type} (i : inhabited'' Ξ±): Ξ± := i.a #reduce default'' bool_inhab'' #reduce default'' nat_inhab'' #reduce default'' string_inhab'' /- Now we turn the world on its head. What if we wanted to keep the first *type* argument explicit and have the value of the second, instance, argument implicit? How could a value argument be passed implicitly? What we'd need is a mechanism that could find an instance value based on the type argument. Voila, typeclasses! -/ /- A typeclass is an ordinary structure type that supports this kind of lookup operation. The mechanism allows us to associate typeclass instances with types and to look them up based on these types so that they can be passed implicitly to functions that require them. The following example continues our running example. We append _ to the typename only to distinguish it from our final solution, following this example. -/ /- The verbose way to tell Lean that a structure type should support instance lookup is to annotate the "structure" definition with @[class], as seen next. -/ @[class] structure inhabited_ (Ξ± : Type) := (a : Ξ±) /- With inhabited_ defined as a class, we can now create values of this type -- instances -- while also having them entered into Lean's database of available instances of this class. -/ instance bool_inhab_ : inhabited_ bool := inhabited_.mk tt instance nat_inhab_ : inhabited_ nat := inhabited_.mk 0 instance string_inhab_ : inhabited_ string := inhabited_.mk "" /- Finally now we can rewrite default so that it takes a type argument explicitly and *implicitly* finds and passes instances, if they've been defined, for the given type argument values. -/ def default (Ξ± : Type) [i : inhabited_ Ξ±] := i.a /- You can see here that Ξ± is an explicit type argument. The square brackets ask Lean to find an implicitly pass an instance of type inhabited_ Ξ±. If not instance for Ξ± has been registered, then Lean will issue and error message saying that it can't synthesize (find) the required typeclass instance. -/ #eval default bool -- implicitly receives bool_inhab_ #eval default nat -- implicitly receives nat_inhab_ #eval default string -- implicitly receives string_inhab_ #eval default empty -- OOPS. No instance for empty type #eval default int -- OOPS. No instance for int type /- As a final syntactic sugar, you can write "class <name>" rather than @[class] structure <name>. -/ class inhabited (Ξ± : Type) := (a : Ξ±) /- You don't even have to give instances names, since they will be looked up and passed implicitly. -/ instance : inhabited bool := inhabited.mk tt instance : inhabited nat := inhabited.mk 0 instance : inhabited string := inhabited.mk "" /- A takeaway message is that we can now use the type system to enforce conditions on the type values that are passed to a function, restricting them only to those type values for which metadata *for that type* have been registered as typeclass instances. -/ /- We now show how these ideas can be used to solve the problem we had with our initial type signature for the right fold function: it is possible for clients to pass inconsistent operator and identity element arguments when they are passed separate. We can do much better. A key is to recognize that the same algebraic structure: a binary operator on values of a type and a bona fide identity element for that operator. Algebraists call such a structure a monoid. We've already seen that the natural numbers along with addition and 0 are a monoid; as are the natural numbers along with multiplication and 1; as well as Booleans with and and tt; along with strings, the append operation, and "". -/ /- Our solution is to define monoid as a typeclass, with instances for each type of value on which we can impose a monoid structure by providing a correspond binary operation, identity element, and proof that it really is an identity element. -/ class monoid' (Ξ± : Type) := (op : Ξ± β†’ Ξ± β†’ Ξ±) (id : Ξ±) (pf : βˆ€ (a : Ξ±), op a id = a) /- OOPS! Initial version, given just above, left out the requirement that op be associative. We fix that in the following definition. -/ class monoid (Ξ± : Type) := (op : Ξ± β†’ Ξ± β†’ Ξ±) (assoc : βˆ€ a b c, op a (op b c) = op (op a b) c) (id : Ξ±) (pf : βˆ€ (a : Ξ±), op a id = a) instance add_monoid : monoid nat := monoid.mk nat.add _ -- now need proof here; exercise 0 nat.add_zero instance and_monoid : monoid bool := monoid.mk band _ tt begin intros, cases a, repeat { apply rfl }, end instance append_monoid : monoid string := monoid.mk append _ "" begin sorry end /- We are now completely positioned to write a beautiful parametric and ad hoc polymorphic foldr function that (1) takes a type (of list value) implicitly, (2) looks up an instance, if there is one for that type and passes it implicitly, and (3) uses the field values to access the operator and identity element to be associated with that type. -/ def foldr {Ξ± : Type} [m : monoid Ξ±] : list Ξ± β†’ Ξ± | [] := m.id | (h::t) := let x:= m.op in x h (foldr t) #eval foldr [tt,ff,tt] #eval foldr [tt,tt,tt] #eval foldr [1,2,3,4,5] #eval foldr ["Hello", ", ", "Lean", "!"] /- We've now understood ad hoc polymorphism, its use to to define typeclasses and instances that enable implicit instance lookup, and to use these capabilities to impose *constraints* on the values of arguments passed as types: in this case that the type has an overloaded definition of a monoid algebraic structure for that type. You can now read the definition of foldr as saying "if you give me any type and if I can find a monoid instance for that type, then I will return a function that takes a list of values of that type and reduces it to a single value of that type using the operator and the identity element found in that type instance." With all this machinery in place, we now get an elegant, easy to use foldr function that is in effect overloaded to apply to values of at least three different types. If you want to do foldr operations on lists of values of other types, just define monoid type instances for them. Yay! -/ end hidden
import numpy as np from bokeh.models import ColorBar from bokeh.plotting import figure, show from bokeh.util.compiler import TypeScript from bokeh.io import show, output_notebook TS_CODE = """ import * as p from "core/properties" import {ColorBar, ColorBarView} from "models/annotations/color_bar" import {PanEvent} from "core/ui_events" import {ScrollEvent} from "core/ui_events" declare const window: any export class InteractiveColorBarView extends ColorBarView { model: InteractiveColorBar low: any high: any ev: PanEvent interactive_hit(sx: number, sy: number): boolean { let size = this.compute_legend_dimensions() let loc = this.compute_legend_location() return sx >= loc.sx && sx <= loc.sx + size.width && sy >= loc.sy && sy <= loc.sy + size.height } on_hit(_sx: number, _sy: number): boolean { return true; } cursor(_sx: number, _sy: number): string | null { return null; } _pan_start(ev: PanEvent, _dimension: string) { this.low = this.model.color_mapper.low this.high = this.model.color_mapper.high this.ev = ev } _pan(ev: PanEvent, _dimension: string) { let size = this.compute_legend_dimensions() var dist = (ev.sy - this.ev.sy) / size.height if (this.model.color_mapper.type == "LogColorMapper") { var high = Math.log10(this.high); var low = Math.log10(this.low) var change = (high - low) * dist low = low + dist high = high + dist this.model.color_mapper.low = Math.pow(10, low) this.model.color_mapper.high = Math.pow(10, high) } else { var change = (this.high - this.low) * dist this.model.color_mapper.low = this.low + change this.model.color_mapper.high = this.high + change } this._fixRange() } _pan_end(_ev: PanEvent, _dimension: string) { } _scroll(ev: ScrollEvent) { // This zooms around the mouse position if (this.model.color_mapper.low === null || this.model.color_mapper.high === null) return let size = this.compute_legend_dimensions() let loc = this.compute_legend_location() var pos = (ev.sy - loc.sy) / size.height var high = this.model.color_mapper.high var low = this.model.color_mapper.low if (this.model.color_mapper.type == "LogColorMapper") { high = Math.log10(high); low = Math.log10(low) } var value = high * (1 - pos) + low * pos var low = low - value var high = high - value var delta = 1 - ev.delta*1/600 low = low * delta + value high = high * delta + value if (this.model.color_mapper.type == "LogColorMapper") { high = Math.pow(10, high) low = Math.pow(10, low) } this.model.color_mapper.low = low this.model.color_mapper.high = high this._fixRange() } _fixRange() { if (this.model.color_mapper.low === null || this.model.color_mapper.high === null) return if (this.model.color_mapper.type == "LogColorMapper") { if (this.model.color_mapper.low <= 0) this.model.color_mapper.low = 1e-100 } if (this.model.color_mapper.high <= this.model.color_mapper.low) { this.model.color_mapper.high = this.model.color_mapper.low + 1e-100 } } } export namespace InteractiveColorBar { export type Attrs = p.AttrsOf<Props> export type Props = ColorBar.Props } export interface InteractiveColorBar extends InteractiveColorBar.Attrs {} export class InteractiveColorBar extends ColorBar { properties: InteractiveColorBar.Props __view_type__: InteractiveColorBarView constructor(attrs?: Partial<InteractiveColorBar.Attrs>) { super(attrs) } static init_InteractiveColorBar() { this.prototype.default_view = InteractiveColorBarView } } """ class InteractiveColorBar(ColorBar): __implementation__ = TypeScript(TS_CODE)
With the recognition that 2002 – 03 would be Jordan 's final season , tributes were paid to him throughout the NBA . In his final game at his old home court , the United Center in Chicago , Jordan received a four @-@ minute standing ovation . The Miami Heat retired the number 23 jersey on April 11 , 2003 , even though Jordan never played for the team . At the 2003 All @-@ Star Game , Jordan was offered a starting spot from Tracy McGrady and Allen Iverson , but refused both . In the end he accepted the spot of Vince Carter , who decided to give it up under great public pressure .
Load LFindLoad. From lfind Require Import LFind. From adtind Require Import goal34. Set Printing Depth 1000. Definition lfind_eval a z:= plus z a. Compute lfind_eval (Succ Zero) (Zero). Compute lfind_eval (Succ Zero) (Succ (Succ Zero)). Compute lfind_eval (Zero) (Zero). Compute lfind_eval (Succ (Succ Zero)) (Zero). Compute lfind_eval (Zero) (Zero). Compute lfind_eval (Zero) (Zero). Compute lfind_eval (Succ (Succ Zero)) (Zero). Compute lfind_eval (Zero) (Succ (Succ Zero)). Compute lfind_eval (Zero) (Succ (Succ Zero)). Compute lfind_eval (Succ (Succ (Succ (Succ Zero)))) (Succ Zero). Compute lfind_eval (Succ Zero) (Zero). Compute lfind_eval (Zero) (Succ (Succ Zero)). Compute lfind_eval (Succ (Succ (Succ (Succ Zero)))) (Zero). Compute lfind_eval (Zero) (Succ (Succ (Succ Zero))). Compute lfind_eval (Zero) (Zero). Compute lfind_eval (Succ Zero) (Succ Zero). Compute lfind_eval (Zero) (Succ Zero). Compute lfind_eval (Zero) (Zero). Compute lfind_eval (Succ (Succ (Succ (Succ Zero)))) (Succ Zero). Compute lfind_eval (Succ (Succ (Succ (Succ Zero)))) (Succ (Succ (Succ Zero))). Compute lfind_eval (Succ (Succ (Succ Zero))) (Succ (Succ Zero)). Compute lfind_eval (Succ Zero) (Succ Zero). Compute lfind_eval (Zero) (Zero). Compute lfind_eval (Succ Zero) (Succ (Succ (Succ Zero))). Compute lfind_eval (Succ Zero) (Zero). Compute lfind_eval (Succ Zero) (Succ Zero). Compute lfind_eval (Succ Zero) (Succ Zero). Compute lfind_eval (Zero) (Succ Zero). Compute lfind_eval (Zero) (Succ (Succ (Succ Zero))). Compute lfind_eval (Succ Zero) (Succ (Succ (Succ Zero))). Compute lfind_eval (Succ (Succ Zero)) (Succ (Succ (Succ (Succ Zero)))). Compute lfind_eval (Zero) (Zero).
[GOAL] Ξ± : Type u_1 p q : β„šβ‰₯0 h : q ≀ p ⊒ ↑q ≀ ↑p - 0 [PROOFSTEP] rwa [sub_zero] [GOAL] Ξ± : Type u_1 p q : β„šβ‰₯0 ⊒ ↑q = 0 ↔ q = 0 [PROOFSTEP] norm_cast [GOAL] Ξ± : Type u_1 p q : β„šβ‰₯0 n : β„• ⊒ ↑(toNNRat ↑n) = ↑↑n [PROOFSTEP] simp only [Nat.cast_nonneg, Rat.coe_toNNRat] [GOAL] Ξ± : Type u_1 p q : β„šβ‰₯0 n : β„• ⊒ ↑n = ↑↑n [PROOFSTEP] rfl [GOAL] Ξ± : Type u_1 p q : β„šβ‰₯0 s : Finset Ξ± f : Ξ± β†’ β„š hf : βˆ€ (a : Ξ±), a ∈ s β†’ 0 ≀ f a ⊒ toNNRat (βˆ‘ a in s, f a) = βˆ‘ a in s, toNNRat (f a) [PROOFSTEP] rw [← coe_inj, coe_sum, Rat.coe_toNNRat _ (Finset.sum_nonneg hf)] [GOAL] Ξ± : Type u_1 p q : β„šβ‰₯0 s : Finset Ξ± f : Ξ± β†’ β„š hf : βˆ€ (a : Ξ±), a ∈ s β†’ 0 ≀ f a ⊒ βˆ‘ i in s, f i = βˆ‘ a in s, ↑(toNNRat (f a)) [PROOFSTEP] exact Finset.sum_congr rfl fun x hxs ↦ by rw [Rat.coe_toNNRat _ (hf x hxs)] [GOAL] Ξ± : Type u_1 p q : β„šβ‰₯0 s : Finset Ξ± f : Ξ± β†’ β„š hf : βˆ€ (a : Ξ±), a ∈ s β†’ 0 ≀ f a x : Ξ± hxs : x ∈ s ⊒ f x = ↑(toNNRat (f x)) [PROOFSTEP] rw [Rat.coe_toNNRat _ (hf x hxs)] [GOAL] Ξ± : Type u_1 p q : β„šβ‰₯0 s : Finset Ξ± f : Ξ± β†’ β„š hf : βˆ€ (a : Ξ±), a ∈ s β†’ 0 ≀ f a ⊒ toNNRat (∏ a in s, f a) = ∏ a in s, toNNRat (f a) [PROOFSTEP] rw [← coe_inj, coe_prod, Rat.coe_toNNRat _ (Finset.prod_nonneg hf)] [GOAL] Ξ± : Type u_1 p q : β„šβ‰₯0 s : Finset Ξ± f : Ξ± β†’ β„š hf : βˆ€ (a : Ξ±), a ∈ s β†’ 0 ≀ f a ⊒ ∏ i in s, f i = ∏ a in s, ↑(toNNRat (f a)) [PROOFSTEP] exact Finset.prod_congr rfl fun x hxs ↦ by rw [Rat.coe_toNNRat _ (hf x hxs)] [GOAL] Ξ± : Type u_1 p q : β„šβ‰₯0 s : Finset Ξ± f : Ξ± β†’ β„š hf : βˆ€ (a : Ξ±), a ∈ s β†’ 0 ≀ f a x : Ξ± hxs : x ∈ s ⊒ f x = ↑(toNNRat (f x)) [PROOFSTEP] rw [Rat.coe_toNNRat _ (hf x hxs)] [GOAL] p q : β„š ⊒ 0 < toNNRat q ↔ 0 < q [PROOFSTEP] simp [toNNRat, ← coe_lt_coe] [GOAL] p q : β„š ⊒ toNNRat q = 0 ↔ q ≀ 0 [PROOFSTEP] simpa [-toNNRat_pos] using (@toNNRat_pos q).not [GOAL] p q : β„š hp : 0 ≀ p ⊒ toNNRat q ≀ toNNRat p ↔ q ≀ p [PROOFSTEP] simp [← coe_le_coe, toNNRat, hp] [GOAL] p q : β„š ⊒ toNNRat q < toNNRat p ↔ q < p ∧ 0 < p [PROOFSTEP] simp [← coe_lt_coe, toNNRat, lt_irrefl] [GOAL] p q : β„š hq : 0 ≀ q hp : 0 ≀ p ⊒ ↑(toNNRat (q + p)) = ↑(toNNRat q + toNNRat p) [PROOFSTEP] simp [toNNRat, hq, hp, add_nonneg] [GOAL] p q✝ : β„š q : β„šβ‰₯0 hp : 0 ≀ p ⊒ q ≀ toNNRat p ↔ ↑q ≀ p [PROOFSTEP] rw [← coe_le_coe, Rat.coe_toNNRat p hp] [GOAL] p q✝ : β„š q : β„šβ‰₯0 hq : 0 < q hp : p < 0 ⊒ q ≀ toNNRat p ↔ ↑q ≀ p [PROOFSTEP] simp only [(hp.trans_le q.coe_nonneg).not_le, toNNRat_eq_zero.2 hp.le, hq.not_le] [GOAL] p✝ q : β„š p : β„šβ‰₯0 hq : 0 ≀ q ⊒ toNNRat q < p ↔ q < ↑p [PROOFSTEP] rw [← coe_lt_coe, Rat.coe_toNNRat q hq] [GOAL] p q : β„š hp : 0 ≀ p ⊒ toNNRat (p * q) = toNNRat p * toNNRat q [PROOFSTEP] cases' le_total 0 q with hq hq [GOAL] case inl p q : β„š hp : 0 ≀ p hq : 0 ≀ q ⊒ toNNRat (p * q) = toNNRat p * toNNRat q [PROOFSTEP] ext [GOAL] case inl.a.num p q : β„š hp : 0 ≀ p hq : 0 ≀ q ⊒ (↑(toNNRat (p * q))).num = (↑(toNNRat p * toNNRat q)).num [PROOFSTEP] simp [toNNRat, hp, hq, max_eq_left, mul_nonneg] [GOAL] case inl.a.den p q : β„š hp : 0 ≀ p hq : 0 ≀ q ⊒ (↑(toNNRat (p * q))).den = (↑(toNNRat p * toNNRat q)).den [PROOFSTEP] simp [toNNRat, hp, hq, max_eq_left, mul_nonneg] [GOAL] case inr p q : β„š hp : 0 ≀ p hq : q ≀ 0 ⊒ toNNRat (p * q) = toNNRat p * toNNRat q [PROOFSTEP] have hpq := mul_nonpos_of_nonneg_of_nonpos hp hq [GOAL] case inr p q : β„š hp : 0 ≀ p hq : q ≀ 0 hpq : p * q ≀ 0 ⊒ toNNRat (p * q) = toNNRat p * toNNRat q [PROOFSTEP] rw [toNNRat_eq_zero.2 hq, toNNRat_eq_zero.2 hpq, mul_zero] [GOAL] p q✝ q : β„š ⊒ toNNRat q⁻¹ = (toNNRat q)⁻¹ [PROOFSTEP] obtain hq | hq := le_total q 0 [GOAL] case inl p q✝ q : β„š hq : q ≀ 0 ⊒ toNNRat q⁻¹ = (toNNRat q)⁻¹ [PROOFSTEP] rw [toNNRat_eq_zero.mpr hq, inv_zero, toNNRat_eq_zero.mpr (inv_nonpos.mpr hq)] [GOAL] case inr p q✝ q : β„š hq : 0 ≀ q ⊒ toNNRat q⁻¹ = (toNNRat q)⁻¹ [PROOFSTEP] nth_rw 1 [← Rat.coe_toNNRat q hq] [GOAL] case inr p q✝ q : β„š hq : 0 ≀ q ⊒ toNNRat (↑(toNNRat q))⁻¹ = (toNNRat q)⁻¹ [PROOFSTEP] rw [← coe_inv, toNNRat_coe] [GOAL] p q : β„š hp : 0 ≀ p ⊒ toNNRat (p / q) = toNNRat p / toNNRat q [PROOFSTEP] rw [div_eq_mul_inv, div_eq_mul_inv, ← toNNRat_inv, ← toNNRat_mul hp] [GOAL] p q : β„š hq : 0 ≀ q ⊒ toNNRat (p / q) = toNNRat p / toNNRat q [PROOFSTEP] rw [div_eq_inv_mul, div_eq_inv_mul, toNNRat_mul (inv_nonneg.2 hq), toNNRat_inv] [GOAL] p q : β„šβ‰₯0 hn : num p = num q hd : den p = den q ⊒ p = q [PROOFSTEP] ext [GOAL] case a.num p q : β„šβ‰₯0 hn : num p = num q hd : den p = den q ⊒ (↑p).num = (↑q).num [PROOFSTEP] apply (Int.natAbs_inj_of_nonneg_of_nonneg _ _).1 hn [GOAL] p q : β„šβ‰₯0 hn : num p = num q hd : den p = den q ⊒ 0 ≀ (↑p).num p q : β„šβ‰₯0 hn : num p = num q hd : den p = den q ⊒ 0 ≀ (↑q).num [PROOFSTEP] exact Rat.num_nonneg_iff_zero_le.2 p.2 [GOAL] p q : β„šβ‰₯0 hn : num p = num q hd : den p = den q ⊒ 0 ≀ (↑q).num [PROOFSTEP] exact Rat.num_nonneg_iff_zero_le.2 q.2 [GOAL] case a.den p q : β„šβ‰₯0 hn : num p = num q hd : den p = den q ⊒ (↑p).den = (↑q).den [PROOFSTEP] exact hd [GOAL] p q : β„šβ‰₯0 ⊒ p = q β†’ num p = num q ∧ den p = den q [PROOFSTEP] rintro rfl [GOAL] p : β„šβ‰₯0 ⊒ num p = num p ∧ den p = den p [PROOFSTEP] exact ⟨rfl, rfl⟩ [GOAL] p q✝ q : β„šβ‰₯0 ⊒ ↑(num q) / ↑(den q) = q [PROOFSTEP] ext1 [GOAL] case a p q✝ q : β„šβ‰₯0 ⊒ ↑(↑(num q) / ↑(den q)) = ↑q [PROOFSTEP] rw [coe_div, coe_natCast, coe_natCast, num, ← Int.cast_ofNat, Int.natAbs_of_nonneg (Rat.num_nonneg_iff_zero_le.2 q.prop)] [GOAL] case a p q✝ q : β„šβ‰₯0 ⊒ ↑(↑q).num / ↑(den q) = ↑q [PROOFSTEP] exact Rat.num_div_den q [GOAL] p q✝ : β„šβ‰₯0 Ξ± : β„šβ‰₯0 β†’ Sort u_1 h : (m n : β„•) β†’ Ξ± (↑m / ↑n) q : β„šβ‰₯0 ⊒ Ξ± q [PROOFSTEP] rw [← num_div_den q] [GOAL] p q✝ : β„šβ‰₯0 Ξ± : β„šβ‰₯0 β†’ Sort u_1 h : (m n : β„•) β†’ Ξ± (↑m / ↑n) q : β„šβ‰₯0 ⊒ Ξ± (↑(num q) / ↑(den q)) [PROOFSTEP] apply h
module Cats.Util.Logic.Constructive where open import Data.Empty public using (βŠ₯ ; βŠ₯-elim) open import Data.Product public using (_,_ ; βˆƒ-syntax ; Ξ£-syntax) renaming (_Γ—_ to _∧_ ; proj₁ to ∧-eliml ; projβ‚‚ to ∧-elimr) open import Data.Sum public using () renaming (_⊎_ to _∨_ ; inj₁ to ∨-introl ; injβ‚‚ to ∨-intror) open import Data.Unit public using (⊀) renaming (tt to ⊀-intro) open import Relation.Nullary public using (Β¬_) -- De Morgan's constructive rules module _ {p q} {P : Set p} {Q : Set q} where Β¬βˆ¨Β¬β†’Β¬βˆ§ : Β¬ P ∨ Β¬ Q β†’ Β¬ (P ∧ Q) Β¬βˆ¨Β¬β†’Β¬βˆ§ (∨-introl Β¬p) (p , _) = Β¬p p Β¬βˆ¨Β¬β†’Β¬βˆ§ (∨-intror Β¬q) (_ , q) = Β¬q q Β¬βˆ¨β†’Β¬βˆ§Β¬ : Β¬ (P ∨ Q) β†’ Β¬ P ∧ Β¬ Q Β¬βˆ¨β†’Β¬βˆ§Β¬ Β¬p∨q = (Ξ» p β†’ Β¬p∨q (∨-introl p)) , (Ξ» q β†’ Β¬p∨q (∨-intror q)) Β¬βˆ§Β¬β†’Β¬βˆ¨ : Β¬ P ∧ Β¬ Q β†’ Β¬ (P ∨ Q) Β¬βˆ§Β¬β†’Β¬βˆ¨ (Β¬p , _) (∨-introl p) = Β¬p p Β¬βˆ§Β¬β†’Β¬βˆ¨ (_ , Β¬q) (∨-intror q) = Β¬q q -- Quantifiers and negation module _ {u p} {U : Set u} {P : U β†’ Set p} where Β¬βˆƒβ†’βˆ€Β¬ : Β¬ (βˆƒ[ u ] (P u)) β†’ βˆ€ u β†’ Β¬ P u Β¬βˆƒβ†’βˆ€Β¬ Β¬βˆƒ u pu = Β¬βˆƒ (u , pu) βˆ€Β¬β†’Β¬βˆƒ : (βˆ€ u β†’ Β¬ (P u)) β†’ Β¬ (βˆƒ[ u ] (P u)) βˆ€Β¬β†’Β¬βˆƒ βˆ€Β¬ (u , pu) = βˆ€Β¬ u pu βˆƒΒ¬β†’Β¬βˆ€ : βˆƒ[ u ] (Β¬ P u) β†’ Β¬ (βˆ€ u β†’ P u) βˆƒΒ¬β†’Β¬βˆ€ (u , Β¬pu) βˆ€upu = Β¬pu (βˆ€upu u)
[STATEMENT] lemma corr: " <emp> kruskal_algo L <\<lambda>F. \<up> (set F \<subseteq> set L \<and> minimum_spanning_forest (GD_from_list_\<alpha>_graph L F) (GD_from_list_\<alpha>_graph L L))>\<^sub>t" [PROOF STATE] proof (prove) goal (1 subgoal): 1. <emp> kruskal_algo L <\<lambda>r. \<up> (set r \<subseteq> set L \<and> minimum_spanning_forest (GD_from_list_\<alpha>_graph L r) (GD_from_list_\<alpha>_graph L L))>\<^sub>t [PROOF STEP] by(sep_auto heap: fromlist.kruskal_correct simp: kruskal_algo_def )
Require Import Nat. Definition task := forall (f : nat -> nat) (n m x : nat), iter (m^n) (A:=nat) f x = iter n (A:=nat->nat) (iter m (A:=nat)) f x.
module Pi.AuxLemmas where open import Data.Empty open import Data.Unit open import Data.Sum open import Data.Product open import Relation.Binary.PropositionalEquality open import Pi.Syntax open import Pi.Opsem Lemma₁ : βˆ€ {A B C D v v' ΞΊ ΞΊ'} {c : A ↔ B} {c' : C ↔ D} β†’ ⟨ c ∣ v ∣ ΞΊ ⟩ ↦ οΌ» c' ∣ v' ∣ ΞΊ' οΌ½ β†’ A ≑ C Γ— B ≑ D Lemma₁ ↦₁ = refl , refl Lemma₁ ↦₂ = refl , refl Lemmaβ‚‚ : βˆ€ {A B v v' ΞΊ ΞΊ'} {c c' : A ↔ B} β†’ ⟨ c ∣ v ∣ ΞΊ ⟩ ↦ οΌ» c' ∣ v' ∣ ΞΊ' οΌ½ β†’ c ≑ c' Γ— ΞΊ ≑ ΞΊ' Lemmaβ‚‚ ↦₁ = refl , refl Lemmaβ‚‚ ↦₂ = refl , refl Lemma₃ : βˆ€ {A B v v' ΞΊ} {c : A ↔ B} β†’ (r : ⟨ c ∣ v ∣ ΞΊ ⟩ ↦ οΌ» c ∣ v' ∣ ΞΊ οΌ½) β†’ base c ⊎ A ≑ B Lemma₃ (↦₁ {b = b}) = inj₁ b Lemma₃ ↦₂ = injβ‚‚ refl Lemmaβ‚„ : βˆ€ {A v v' ΞΊ} {c : A ↔ A} β†’ (r : ⟨ c ∣ v ∣ ΞΊ ⟩ ↦ οΌ» c ∣ v' ∣ ΞΊ οΌ½) β†’ base c ⊎ c ≑ id↔ Lemmaβ‚„ {c = swapβ‚Š} ↦₁ = inj₁ tt Lemmaβ‚„ {c = swap⋆} ↦₁ = inj₁ tt Lemmaβ‚„ ↦₂ = injβ‚‚ refl
[GOAL] n : β„• ⊒ βˆ€ (a b c : DihedralGroup n), a * b * c = a * (b * c) [PROOFSTEP] rintro (a | a) (b | b) (c | c) [GOAL] case r.r.r n : β„• a b c : ZMod n ⊒ r a * r b * r c = r a * (r b * r c) [PROOFSTEP] simp only [(Β· * Β·), mul] [GOAL] case r.r.sr n : β„• a b c : ZMod n ⊒ r a * r b * sr c = r a * (r b * sr c) [PROOFSTEP] simp only [(Β· * Β·), mul] [GOAL] case r.sr.r n : β„• a b c : ZMod n ⊒ r a * sr b * r c = r a * (sr b * r c) [PROOFSTEP] simp only [(Β· * Β·), mul] [GOAL] case r.sr.sr n : β„• a b c : ZMod n ⊒ r a * sr b * sr c = r a * (sr b * sr c) [PROOFSTEP] simp only [(Β· * Β·), mul] [GOAL] case sr.r.r n : β„• a b c : ZMod n ⊒ sr a * r b * r c = sr a * (r b * r c) [PROOFSTEP] simp only [(Β· * Β·), mul] [GOAL] case sr.r.sr n : β„• a b c : ZMod n ⊒ sr a * r b * sr c = sr a * (r b * sr c) [PROOFSTEP] simp only [(Β· * Β·), mul] [GOAL] case sr.sr.r n : β„• a b c : ZMod n ⊒ sr a * sr b * r c = sr a * (sr b * r c) [PROOFSTEP] simp only [(Β· * Β·), mul] [GOAL] case sr.sr.sr n : β„• a b c : ZMod n ⊒ sr a * sr b * sr c = sr a * (sr b * sr c) [PROOFSTEP] simp only [(Β· * Β·), mul] [GOAL] case r.r.r n : β„• a b c : ZMod n ⊒ r (a + b + c) = r (a + (b + c)) [PROOFSTEP] ring_nf [GOAL] case r.r.sr n : β„• a b c : ZMod n ⊒ sr (c - (a + b)) = sr (c - b - a) [PROOFSTEP] ring_nf [GOAL] case r.sr.r n : β„• a b c : ZMod n ⊒ sr (b - a + c) = sr (b + c - a) [PROOFSTEP] ring_nf [GOAL] case r.sr.sr n : β„• a b c : ZMod n ⊒ r (c - (b - a)) = r (a + (c - b)) [PROOFSTEP] ring_nf [GOAL] case sr.r.r n : β„• a b c : ZMod n ⊒ sr (a + b + c) = sr (a + (b + c)) [PROOFSTEP] ring_nf [GOAL] case sr.r.sr n : β„• a b c : ZMod n ⊒ r (c - (a + b)) = r (c - b - a) [PROOFSTEP] ring_nf [GOAL] case sr.sr.r n : β„• a b c : ZMod n ⊒ r (b - a + c) = r (b + c - a) [PROOFSTEP] ring_nf [GOAL] case sr.sr.sr n : β„• a b c : ZMod n ⊒ sr (c - (b - a)) = sr (a + (c - b)) [PROOFSTEP] ring_nf [GOAL] n : β„• ⊒ βˆ€ (a : DihedralGroup n), 1 * a = a [PROOFSTEP] rintro (a | a) [GOAL] case r n : β„• a : ZMod n ⊒ 1 * r a = r a case sr n : β„• a : ZMod n ⊒ 1 * sr a = sr a [PROOFSTEP] exact congr_arg r (zero_add a) [GOAL] case sr n : β„• a : ZMod n ⊒ 1 * sr a = sr a [PROOFSTEP] exact congr_arg sr (sub_zero a) [GOAL] n : β„• ⊒ βˆ€ (a : DihedralGroup n), a * 1 = a [PROOFSTEP] rintro (a | a) [GOAL] case r n : β„• a : ZMod n ⊒ r a * 1 = r a case sr n : β„• a : ZMod n ⊒ sr a * 1 = sr a [PROOFSTEP] exact congr_arg r (add_zero a) [GOAL] case sr n : β„• a : ZMod n ⊒ sr a * 1 = sr a [PROOFSTEP] exact congr_arg sr (add_zero a) [GOAL] n : β„• ⊒ βˆ€ (a : DihedralGroup n), a⁻¹ * a = 1 [PROOFSTEP] rintro (a | a) [GOAL] case r n : β„• a : ZMod n ⊒ (r a)⁻¹ * r a = 1 case sr n : β„• a : ZMod n ⊒ (sr a)⁻¹ * sr a = 1 [PROOFSTEP] exact congr_arg r (neg_add_self a) [GOAL] case sr n : β„• a : ZMod n ⊒ (sr a)⁻¹ * sr a = 1 [PROOFSTEP] exact congr_arg r (sub_self a) [GOAL] n : β„• ⊒ Function.LeftInverse (fun i => match i with | r j => Sum.inl j | sr j => Sum.inr j) fun i => match i with | Sum.inl j => r j | Sum.inr j => sr j [PROOFSTEP] rintro (x | x) [GOAL] case inl n : β„• x : ZMod n ⊒ (fun i => match i with | r j => Sum.inl j | sr j => Sum.inr j) ((fun i => match i with | Sum.inl j => r j | Sum.inr j => sr j) (Sum.inl x)) = Sum.inl x [PROOFSTEP] rfl [GOAL] case inr n : β„• x : ZMod n ⊒ (fun i => match i with | r j => Sum.inl j | sr j => Sum.inr j) ((fun i => match i with | Sum.inl j => r j | Sum.inr j => sr j) (Sum.inr x)) = Sum.inr x [PROOFSTEP] rfl [GOAL] n : β„• ⊒ Function.RightInverse (fun i => match i with | r j => Sum.inl j | sr j => Sum.inr j) fun i => match i with | Sum.inl j => r j | Sum.inr j => sr j [PROOFSTEP] rintro (x | x) [GOAL] case r n : β„• x : ZMod n ⊒ (fun i => match i with | Sum.inl j => r j | Sum.inr j => sr j) ((fun i => match i with | r j => Sum.inl j | sr j => Sum.inr j) (r x)) = r x [PROOFSTEP] rfl [GOAL] case sr n : β„• x : ZMod n ⊒ (fun i => match i with | Sum.inl j => r j | Sum.inr j => sr j) ((fun i => match i with | r j => Sum.inl j | sr j => Sum.inr j) (sr x)) = sr x [PROOFSTEP] rfl [GOAL] n : β„• ⊒ r 0 β‰  sr 0 [PROOFSTEP] simp_rw [ne_eq] [GOAL] n : β„• inst✝ : NeZero n ⊒ Fintype.card (DihedralGroup n) = 2 * n [PROOFSTEP] rw [← Fintype.card_eq.mpr ⟨fintypeHelper⟩, Fintype.card_sum, ZMod.card, two_mul] [GOAL] n : β„• ⊒ Nat.card (DihedralGroup n) = 2 * n [PROOFSTEP] cases n [GOAL] case zero ⊒ Nat.card (DihedralGroup Nat.zero) = 2 * Nat.zero [PROOFSTEP] rw [Nat.card_eq_zero_of_infinite] [GOAL] case succ n✝ : β„• ⊒ Nat.card (DihedralGroup (Nat.succ n✝)) = 2 * Nat.succ n✝ [PROOFSTEP] rw [Nat.card_eq_fintype_card, card] [GOAL] n k : β„• ⊒ r 1 ^ k = r ↑k [PROOFSTEP] induction' k with k IH [GOAL] case zero n : β„• ⊒ r 1 ^ Nat.zero = r ↑Nat.zero [PROOFSTEP] rw [Nat.cast_zero] [GOAL] case zero n : β„• ⊒ r 1 ^ Nat.zero = r 0 [PROOFSTEP] rfl [GOAL] case succ n k : β„• IH : r 1 ^ k = r ↑k ⊒ r 1 ^ Nat.succ k = r ↑(Nat.succ k) [PROOFSTEP] rw [pow_succ, IH, r_mul_r] [GOAL] case succ n k : β„• IH : r 1 ^ k = r ↑k ⊒ r (1 + ↑k) = r ↑(Nat.succ k) [PROOFSTEP] congr 1 [GOAL] case succ.e_a n k : β„• IH : r 1 ^ k = r ↑k ⊒ 1 + ↑k = ↑(Nat.succ k) [PROOFSTEP] norm_cast [GOAL] case succ.e_a n k : β„• IH : r 1 ^ k = r ↑k ⊒ ↑(1 + k) = ↑(Nat.succ k) [PROOFSTEP] rw [Nat.one_add] [GOAL] n : β„• ⊒ r 1 ^ n = 1 [PROOFSTEP] rw [r_one_pow, one_def] [GOAL] n : β„• ⊒ r ↑n = r 0 [PROOFSTEP] congr 1 [GOAL] case e_a n : β„• ⊒ ↑n = 0 [PROOFSTEP] exact ZMod.nat_cast_self _ [GOAL] n : β„• i : ZMod n ⊒ sr i * sr i = 1 [PROOFSTEP] rw [sr_mul_sr, sub_self, one_def] [GOAL] n : β„• i : ZMod n ⊒ orderOf (sr i) = 2 [PROOFSTEP] apply orderOf_eq_prime [GOAL] case hg n : β„• i : ZMod n ⊒ sr i ^ 2 = 1 [PROOFSTEP] rw [sq, sr_mul_self] [GOAL] case hg1 n : β„• i : ZMod n ⊒ sr i β‰  1 [PROOFSTEP] revert n [GOAL] case hg1 ⊒ βˆ€ {n : β„•} (i : ZMod n), sr i β‰  1 [PROOFSTEP] simp_rw [one_def, ne_eq, forall_const] [GOAL] n : β„• ⊒ orderOf (r 1) = n [PROOFSTEP] rcases eq_zero_or_neZero n with (rfl | hn) [GOAL] case inl ⊒ orderOf (r 1) = 0 [PROOFSTEP] rw [orderOf_eq_zero_iff'] [GOAL] case inl ⊒ βˆ€ (n : β„•), 0 < n β†’ r 1 ^ n β‰  1 [PROOFSTEP] intro n hn [GOAL] case inl n : β„• hn : 0 < n ⊒ r 1 ^ n β‰  1 [PROOFSTEP] rw [r_one_pow, one_def] [GOAL] case inl n : β„• hn : 0 < n ⊒ r ↑n β‰  r 0 [PROOFSTEP] apply mt r.inj [GOAL] case inl n : β„• hn : 0 < n ⊒ ¬↑n = 0 [PROOFSTEP] simpa using hn.ne' [GOAL] case inr n : β„• hn : NeZero n ⊒ orderOf (r 1) = n [PROOFSTEP] apply (Nat.le_of_dvd (NeZero.pos n) <| orderOf_dvd_of_pow_eq_one <| @r_one_pow_n n).lt_or_eq.resolve_left [GOAL] case inr n : β„• hn : NeZero n ⊒ Β¬orderOf (r 1) < n [PROOFSTEP] intro h [GOAL] case inr n : β„• hn : NeZero n h : orderOf (r 1) < n ⊒ False [PROOFSTEP] have h1 : (r 1 : DihedralGroup n) ^ orderOf (r 1) = 1 := pow_orderOf_eq_one _ [GOAL] case inr n : β„• hn : NeZero n h : orderOf (r 1) < n h1 : r 1 ^ orderOf (r 1) = 1 ⊒ False [PROOFSTEP] rw [r_one_pow] at h1 [GOAL] case inr n : β„• hn : NeZero n h : orderOf (r 1) < n h1 : r ↑(orderOf (r 1)) = 1 ⊒ False [PROOFSTEP] injection h1 with h2 [GOAL] case inr n : β„• hn : NeZero n h : orderOf (r 1) < n h2 : ↑(orderOf (r 1)) = 0 ⊒ False [PROOFSTEP] rw [← ZMod.val_eq_zero, ZMod.val_nat_cast, Nat.mod_eq_of_lt h] at h2 [GOAL] case inr n : β„• hn : NeZero n h : orderOf (r 1) < n h2 : orderOf (r 1) = 0 ⊒ False [PROOFSTEP] exact absurd h2.symm (orderOf_pos _).ne [GOAL] n : β„• inst✝ : NeZero n i : ZMod n ⊒ orderOf (r i) = n / Nat.gcd n (ZMod.val i) [PROOFSTEP] conv_lhs => rw [← ZMod.nat_cast_zmod_val i] [GOAL] n : β„• inst✝ : NeZero n i : ZMod n | orderOf (r i) [PROOFSTEP] rw [← ZMod.nat_cast_zmod_val i] [GOAL] n : β„• inst✝ : NeZero n i : ZMod n | orderOf (r i) [PROOFSTEP] rw [← ZMod.nat_cast_zmod_val i] [GOAL] n : β„• inst✝ : NeZero n i : ZMod n | orderOf (r i) [PROOFSTEP] rw [← ZMod.nat_cast_zmod_val i] [GOAL] n : β„• inst✝ : NeZero n i : ZMod n ⊒ orderOf (r ↑(ZMod.val i)) = n / Nat.gcd n (ZMod.val i) [PROOFSTEP] rw [← r_one_pow, orderOf_pow, orderOf_r_one] [GOAL] n : β„• ⊒ Monoid.exponent (DihedralGroup n) = lcm n 2 [PROOFSTEP] rcases eq_zero_or_neZero n with (rfl | hn) [GOAL] case inl ⊒ Monoid.exponent (DihedralGroup 0) = lcm 0 2 [PROOFSTEP] exact Monoid.exponent_eq_zero_of_order_zero orderOf_r_one [GOAL] case inr n : β„• hn : NeZero n ⊒ Monoid.exponent (DihedralGroup n) = lcm n 2 [PROOFSTEP] apply Nat.dvd_antisymm [GOAL] case inr.a n : β„• hn : NeZero n ⊒ Monoid.exponent (DihedralGroup n) ∣ lcm n 2 [PROOFSTEP] apply Monoid.exponent_dvd_of_forall_pow_eq_one [GOAL] case inr.a.hG n : β„• hn : NeZero n ⊒ βˆ€ (g : DihedralGroup n), g ^ lcm n 2 = 1 [PROOFSTEP] rintro (m | m) [GOAL] case inr.a.hG.r n : β„• hn : NeZero n m : ZMod n ⊒ r m ^ lcm n 2 = 1 [PROOFSTEP] rw [← orderOf_dvd_iff_pow_eq_one, orderOf_r] [GOAL] case inr.a.hG.r n : β„• hn : NeZero n m : ZMod n ⊒ n / Nat.gcd n (ZMod.val m) ∣ lcm n 2 [PROOFSTEP] refine' Nat.dvd_trans ⟨gcd n m.val, _⟩ (dvd_lcm_left n 2) [GOAL] case inr.a.hG.r n : β„• hn : NeZero n m : ZMod n ⊒ n = n / Nat.gcd n (ZMod.val m) * gcd n (ZMod.val m) [PROOFSTEP] exact (Nat.div_mul_cancel (Nat.gcd_dvd_left n m.val)).symm [GOAL] case inr.a.hG.sr n : β„• hn : NeZero n m : ZMod n ⊒ sr m ^ lcm n 2 = 1 [PROOFSTEP] rw [← orderOf_dvd_iff_pow_eq_one, orderOf_sr] [GOAL] case inr.a.hG.sr n : β„• hn : NeZero n m : ZMod n ⊒ 2 ∣ lcm n 2 [PROOFSTEP] exact dvd_lcm_right n 2 [GOAL] case inr.a n : β„• hn : NeZero n ⊒ lcm n 2 ∣ Monoid.exponent (DihedralGroup n) [PROOFSTEP] apply lcm_dvd [GOAL] case inr.a.hab n : β„• hn : NeZero n ⊒ n ∣ Monoid.exponent (DihedralGroup n) [PROOFSTEP] convert Monoid.order_dvd_exponent (r (1 : ZMod n)) [GOAL] case h.e'_3 n : β„• hn : NeZero n ⊒ n = orderOf (r 1) [PROOFSTEP] exact orderOf_r_one.symm [GOAL] case inr.a.hcb n : β„• hn : NeZero n ⊒ 2 ∣ Monoid.exponent (DihedralGroup n) [PROOFSTEP] convert Monoid.order_dvd_exponent (sr (0 : ZMod n)) [GOAL] case h.e'_3 n : β„• hn : NeZero n ⊒ 2 = orderOf (sr 0) [PROOFSTEP] exact (orderOf_sr 0).symm [GOAL] n : β„• hn : Odd n u : (ZMod n)Λ£ := ZMod.unitOfCoprime 2 (_ : Nat.coprime 2 n) hu : βˆ€ (a : ZMod n), a + a = 0 ↔ a = 0 i j : ZMod n h : Commute (r i, sr j).fst (r i, sr j).snd ⊒ (fun x => match x with | Sum.inl i => { val := (sr i, r 0), property := (_ : sr (i + 0) = sr (i - 0)) } | Sum.inr (Sum.inl j) => { val := (r 0, sr j), property := (_ : sr (j - 0) = sr (j + 0)) } | Sum.inr (Sum.inr (Sum.inl k)) => { val := (sr (↑u⁻¹ * k), sr (↑u⁻¹ * k)), property := (_ : (sr (↑u⁻¹ * k), sr (↑u⁻¹ * k)).fst * (sr (↑u⁻¹ * k), sr (↑u⁻¹ * k)).snd = (sr (↑u⁻¹ * k), sr (↑u⁻¹ * k)).fst * (sr (↑u⁻¹ * k), sr (↑u⁻¹ * k)).snd) } | Sum.inr (Sum.inr (Sum.inr (i, j))) => { val := (r i, r j), property := (_ : r (i + j) = r (j + i)) }) ((fun x => match x with | { val := (sr i, r a), property := property } => Sum.inl i | { val := (r a, sr j), property := property } => Sum.inr (Sum.inl j) | { val := (sr i, sr j), property := property } => Sum.inr (Sum.inr (Sum.inl (i + j))) | { val := (r i, r j), property := property } => Sum.inr (Sum.inr (Sum.inr (i, j)))) { val := (r i, sr j), property := h }) = { val := (r i, sr j), property := h } [PROOFSTEP] simpa [sub_eq_add_neg, neg_eq_iff_add_eq_zero, hu, eq_comm (a := i) (b := 0)] using h.eq [GOAL] n : β„• hn : Odd n u : (ZMod n)Λ£ := ZMod.unitOfCoprime 2 (_ : Nat.coprime 2 n) hu : βˆ€ (a : ZMod n), a + a = 0 ↔ a = 0 i j : ZMod n h : Commute (sr i, r j).fst (sr i, r j).snd ⊒ (fun x => match x with | Sum.inl i => { val := (sr i, r 0), property := (_ : sr (i + 0) = sr (i - 0)) } | Sum.inr (Sum.inl j) => { val := (r 0, sr j), property := (_ : sr (j - 0) = sr (j + 0)) } | Sum.inr (Sum.inr (Sum.inl k)) => { val := (sr (↑u⁻¹ * k), sr (↑u⁻¹ * k)), property := (_ : (sr (↑u⁻¹ * k), sr (↑u⁻¹ * k)).fst * (sr (↑u⁻¹ * k), sr (↑u⁻¹ * k)).snd = (sr (↑u⁻¹ * k), sr (↑u⁻¹ * k)).fst * (sr (↑u⁻¹ * k), sr (↑u⁻¹ * k)).snd) } | Sum.inr (Sum.inr (Sum.inr (i, j))) => { val := (r i, r j), property := (_ : r (i + j) = r (j + i)) }) ((fun x => match x with | { val := (sr i, r a), property := property } => Sum.inl i | { val := (r a, sr j), property := property } => Sum.inr (Sum.inl j) | { val := (sr i, sr j), property := property } => Sum.inr (Sum.inr (Sum.inl (i + j))) | { val := (r i, r j), property := property } => Sum.inr (Sum.inr (Sum.inr (i, j)))) { val := (sr i, r j), property := h }) = { val := (sr i, r j), property := h } [PROOFSTEP] simpa [sub_eq_add_neg, eq_neg_iff_add_eq_zero, hu, eq_comm (a := j) (b := 0)] using h.eq [GOAL] n : β„• hn : Odd n u : (ZMod n)Λ£ := ZMod.unitOfCoprime 2 (_ : Nat.coprime 2 n) hu : βˆ€ (a : ZMod n), a + a = 0 ↔ a = 0 i j : ZMod n h : Commute (sr i, sr j).fst (sr i, sr j).snd ⊒ (fun x => match x with | Sum.inl i => { val := (sr i, r 0), property := (_ : sr (i + 0) = sr (i - 0)) } | Sum.inr (Sum.inl j) => { val := (r 0, sr j), property := (_ : sr (j - 0) = sr (j + 0)) } | Sum.inr (Sum.inr (Sum.inl k)) => { val := (sr (↑u⁻¹ * k), sr (↑u⁻¹ * k)), property := (_ : (sr (↑u⁻¹ * k), sr (↑u⁻¹ * k)).fst * (sr (↑u⁻¹ * k), sr (↑u⁻¹ * k)).snd = (sr (↑u⁻¹ * k), sr (↑u⁻¹ * k)).fst * (sr (↑u⁻¹ * k), sr (↑u⁻¹ * k)).snd) } | Sum.inr (Sum.inr (Sum.inr (i, j))) => { val := (r i, r j), property := (_ : r (i + j) = r (j + i)) }) ((fun x => match x with | { val := (sr i, r a), property := property } => Sum.inl i | { val := (r a, sr j), property := property } => Sum.inr (Sum.inl j) | { val := (sr i, sr j), property := property } => Sum.inr (Sum.inr (Sum.inl (i + j))) | { val := (r i, r j), property := property } => Sum.inr (Sum.inr (Sum.inr (i, j)))) { val := (sr i, sr j), property := h }) = { val := (sr i, sr j), property := h } [PROOFSTEP] replace h := r.inj h [GOAL] n : β„• hn : Odd n u : (ZMod n)Λ£ := ZMod.unitOfCoprime 2 (_ : Nat.coprime 2 n) hu : βˆ€ (a : ZMod n), a + a = 0 ↔ a = 0 i j : ZMod n h✝ : Commute (sr i, sr j).fst (sr i, sr j).snd h : j - i = i - j ⊒ (fun x => match x with | Sum.inl i => { val := (sr i, r 0), property := (_ : sr (i + 0) = sr (i - 0)) } | Sum.inr (Sum.inl j) => { val := (r 0, sr j), property := (_ : sr (j - 0) = sr (j + 0)) } | Sum.inr (Sum.inr (Sum.inl k)) => { val := (sr (↑u⁻¹ * k), sr (↑u⁻¹ * k)), property := (_ : (sr (↑u⁻¹ * k), sr (↑u⁻¹ * k)).fst * (sr (↑u⁻¹ * k), sr (↑u⁻¹ * k)).snd = (sr (↑u⁻¹ * k), sr (↑u⁻¹ * k)).fst * (sr (↑u⁻¹ * k), sr (↑u⁻¹ * k)).snd) } | Sum.inr (Sum.inr (Sum.inr (i, j))) => { val := (r i, r j), property := (_ : r (i + j) = r (j + i)) }) ((fun x => match x with | { val := (sr i, r a), property := property } => Sum.inl i | { val := (r a, sr j), property := property } => Sum.inr (Sum.inl j) | { val := (sr i, sr j), property := property } => Sum.inr (Sum.inr (Sum.inl (i + j))) | { val := (r i, r j), property := property } => Sum.inr (Sum.inr (Sum.inr (i, j)))) { val := (sr i, sr j), property := h✝ }) = { val := (sr i, sr j), property := h✝ } [PROOFSTEP] rw [← neg_sub, neg_eq_iff_add_eq_zero, hu, sub_eq_zero] at h [GOAL] n : β„• hn : Odd n u : (ZMod n)Λ£ := ZMod.unitOfCoprime 2 (_ : Nat.coprime 2 n) hu : βˆ€ (a : ZMod n), a + a = 0 ↔ a = 0 i j : ZMod n h✝ : Commute (sr i, sr j).fst (sr i, sr j).snd h : i = j ⊒ (fun x => match x with | Sum.inl i => { val := (sr i, r 0), property := (_ : sr (i + 0) = sr (i - 0)) } | Sum.inr (Sum.inl j) => { val := (r 0, sr j), property := (_ : sr (j - 0) = sr (j + 0)) } | Sum.inr (Sum.inr (Sum.inl k)) => { val := (sr (↑u⁻¹ * k), sr (↑u⁻¹ * k)), property := (_ : (sr (↑u⁻¹ * k), sr (↑u⁻¹ * k)).fst * (sr (↑u⁻¹ * k), sr (↑u⁻¹ * k)).snd = (sr (↑u⁻¹ * k), sr (↑u⁻¹ * k)).fst * (sr (↑u⁻¹ * k), sr (↑u⁻¹ * k)).snd) } | Sum.inr (Sum.inr (Sum.inr (i, j))) => { val := (r i, r j), property := (_ : r (i + j) = r (j + i)) }) ((fun x => match x with | { val := (sr i, r a), property := property } => Sum.inl i | { val := (r a, sr j), property := property } => Sum.inr (Sum.inl j) | { val := (sr i, sr j), property := property } => Sum.inr (Sum.inr (Sum.inl (i + j))) | { val := (r i, r j), property := property } => Sum.inr (Sum.inr (Sum.inr (i, j)))) { val := (sr i, sr j), property := h✝ }) = { val := (sr i, sr j), property := h✝ } [PROOFSTEP] rw [Subtype.ext_iff, Prod.ext_iff, sr.injEq, sr.injEq, h, and_self, ← two_mul] [GOAL] n : β„• hn : Odd n u : (ZMod n)Λ£ := ZMod.unitOfCoprime 2 (_ : Nat.coprime 2 n) hu : βˆ€ (a : ZMod n), a + a = 0 ↔ a = 0 i j : ZMod n h✝ : Commute (sr i, sr j).fst (sr i, sr j).snd h : i = j ⊒ ↑u⁻¹ * (2 * j) = j [PROOFSTEP] exact u.inv_mul_cancel_left j [GOAL] n : β„• hn : Odd n ⊒ Nat.card { p // Commute p.fst p.snd } = n * (n + 3) [PROOFSTEP] have hn' : NeZero n := ⟨hn.pos.ne'⟩ [GOAL] n : β„• hn : Odd n hn' : NeZero n ⊒ Nat.card { p // Commute p.fst p.snd } = n * (n + 3) [PROOFSTEP] simp_rw [Nat.card_congr (OddCommuteEquiv hn), Nat.card_sum, Nat.card_prod, Nat.card_zmod] [GOAL] n : β„• hn : Odd n hn' : NeZero n ⊒ n + (n + (n + n * n)) = n * (n + 3) [PROOFSTEP] ring [GOAL] n : β„• hn : Odd n ⊒ Nat.card (ConjClasses (DihedralGroup n)) = (n + 3) / 2 [PROOFSTEP] rw [← Nat.mul_div_mul_left _ 2 hn.pos, ← card_commute_odd hn, mul_comm, card_comm_eq_card_conjClasses_mul_card, nat_card, Nat.mul_div_left _ (mul_pos two_pos hn.pos)]
lemma holomorphic_on_linear [simp, holomorphic_intros]: "((*) c) holomorphic_on s"
/- File: signature_recover_public_key_ec_mul_soundness.lean Autogenerated file. -/ import starkware.cairo.lean.semantics.soundness.hoare import .signature_recover_public_key_code import ..signature_recover_public_key_spec import .signature_recover_public_key_ec_add_soundness import .signature_recover_public_key_ec_mul_inner_soundness open tactic open starkware.cairo.common.cairo_secp.ec open starkware.cairo.common.cairo_secp.bigint open starkware.cairo.common.cairo_secp.field variables {F : Type} [field F] [decidable_eq F] [prelude_hyps F] variable mem : F β†’ F variable Οƒ : register_state F /- starkware.cairo.common.cairo_secp.ec.ec_mul autogenerated soundness theorem -/ theorem auto_sound_ec_mul -- arguments (range_check_ptr : F) (point : EcPoint F) (scalar : BigInt3 F) -- code is in memory at Οƒ.pc (h_mem : mem_at mem code_ec_mul Οƒ.pc) -- all dependencies are in memory (h_mem_4 : mem_at mem code_nondet_bigint3 (Οƒ.pc - 561)) (h_mem_5 : mem_at mem code_unreduced_mul (Οƒ.pc - 549)) (h_mem_6 : mem_at mem code_unreduced_sqr (Οƒ.pc - 529)) (h_mem_7 : mem_at mem code_verify_zero (Οƒ.pc - 513)) (h_mem_8 : mem_at mem code_is_zero (Οƒ.pc - 490)) (h_mem_12 : mem_at mem code_compute_doubling_slope (Οƒ.pc - 385)) (h_mem_13 : mem_at mem code_compute_slope (Οƒ.pc - 341)) (h_mem_14 : mem_at mem code_ec_double (Οƒ.pc - 317)) (h_mem_15 : mem_at mem code_fast_ec_add (Οƒ.pc - 244)) (h_mem_16 : mem_at mem code_ec_add (Οƒ.pc - 157)) (h_mem_17 : mem_at mem code_ec_mul_inner (Οƒ.pc - 101)) -- input arguments on the stack (hin_range_check_ptr : range_check_ptr = mem (Οƒ.fp - 12)) (hin_point : point = cast_EcPoint mem (Οƒ.fp - 11)) (hin_scalar : scalar = cast_BigInt3 mem (Οƒ.fp - 5)) -- conclusion : ensures_ret mem Οƒ (Ξ» ΞΊ Ο„, βˆƒ ΞΌ ≀ ΞΊ, rc_ensures mem (rc_bound F) ΞΌ (mem (Οƒ.fp - 12)) (mem $ Ο„.ap - 7) (spec_ec_mul mem ΞΊ range_check_ptr point scalar (mem (Ο„.ap - 7)) (cast_EcPoint mem (Ο„.ap - 6)))) := begin apply ensures_of_ensuresb, intro Ξ½bound, have h_mem_rec := h_mem, unpack_memory code_ec_mul at h_mem with ⟨hpc0, hpc1, hpc2, hpc3, hpc4, hpc5, hpc6, hpc7, hpc8, hpc9, hpc10, hpc11, hpc12, hpc13, hpc14, hpc15, hpc16, hpc17, hpc18, hpc19, hpc20, hpc21, hpc22, hpc23, hpc24, hpc25, hpc26, hpc27, hpc28, hpc29, hpc30, hpc31, hpc32, hpc33, hpc34, hpc35, hpc36, hpc37, hpc38, hpc39, hpc40, hpc41, hpc42, hpc43, hpc44, hpc45, hpc46, hpc47, hpc48, hpc49, hpc50, hpc51, hpc52, hpc53, hpc54, hpc55, hpc56, hpc57, hpc58, hpc59, hpc60, hpc61, hpc62, hpc63, hpc64, hpc65, hpc66, hpc67, hpc68, hpc69, hpc70, hpc71, hpc72, hpc73, hpc74, hpc75, hpc76, hpc77, hpc78, hpc79⟩, -- ap += 18 step_advance_ap hpc0 hpc1, -- function call step_assert_eq hpc2 with arg0, step_assert_eq hpc3 with arg1, step_assert_eq hpc4 with arg2, step_assert_eq hpc5 with arg3, step_assert_eq hpc6 with arg4, step_assert_eq hpc7 with arg5, step_assert_eq hpc8 with arg6, step_assert_eq hpc9 with arg7, step_assert_eq hpc10 hpc11 with arg8, step_sub hpc12 (auto_sound_ec_mul_inner mem _ range_check_ptr point scalar.d0 86 _ _ _ _ _ _ _ _ _ _ _ _ _), { rw hpc13, norm_num2, exact h_mem_17 }, { rw hpc13, norm_num2, exact h_mem_4 }, { rw hpc13, norm_num2, exact h_mem_5 }, { rw hpc13, norm_num2, exact h_mem_6 }, { rw hpc13, norm_num2, exact h_mem_7 }, { rw hpc13, norm_num2, exact h_mem_12 }, { rw hpc13, norm_num2, exact h_mem_13 }, { rw hpc13, norm_num2, exact h_mem_14 }, { rw hpc13, norm_num2, exact h_mem_15 }, { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, hin_scalar] }, try { dsimp [cast_EcPoint, cast_BigInt3] }, try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8] }, try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, }, { try { ext } ; { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, hin_scalar] }, try { dsimp [cast_EcPoint, cast_BigInt3] }, try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8] }, try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, }, { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, hin_scalar] }, try { dsimp [cast_EcPoint, cast_BigInt3] }, try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8] }, try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, }, { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, hin_scalar] }, try { dsimp [cast_EcPoint, cast_BigInt3] }, try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8] }, try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, }, intros ΞΊ_call14 ap14 h_call14, rcases h_call14 with ⟨rc_m14, rc_mle14, hl_range_check_ptr₁, h_call14⟩, generalize' hr_rev_range_check_ptr₁: mem (ap14 - 13) = range_check_ptr₁, have htv_range_check_ptr₁ := hr_rev_range_check_ptr₁.symm, clear hr_rev_range_check_ptr₁, generalize' hr_rev_pow2_0: cast_EcPoint mem (ap14 - 12) = pow2_0, simp only [hr_rev_pow2_0] at h_call14, have htv_pow2_0 := hr_rev_pow2_0.symm, clear hr_rev_pow2_0, generalize' hr_rev_res0: cast_EcPoint mem (ap14 - 6) = res0, simp only [hr_rev_res0] at h_call14, have htv_res0 := hr_rev_res0.symm, clear hr_rev_res0, try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4 ,arg5 ,arg6 ,arg7 ,arg8] at hl_range_check_ptr₁ }, rw [←htv_range_check_ptr₁, ←hin_range_check_ptr] at hl_range_check_ptr₁, try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4 ,arg5 ,arg6 ,arg7 ,arg8] at h_call14 }, rw [hin_range_check_ptr] at h_call14, clear arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8, -- local var step_assert_eq hpc14 with temp0, step_assert_eq hpc15 with temp1, step_assert_eq hpc16 with temp2, step_assert_eq hpc17 with temp3, step_assert_eq hpc18 with temp4, step_assert_eq hpc19 with temp5, have lc_res0: res0 = cast_EcPoint mem Οƒ.fp, { try { ext } ; { try { simp only [htv_res0] }, try { dsimp [cast_EcPoint, cast_BigInt3] }, try { arith_simps }, try { simp only [temp0, temp1, temp2, temp3, temp4, temp5] }, try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, }, clear temp0 temp1 temp2 temp3 temp4 temp5, -- function call step_assert_eq hpc20 with arg0, step_assert_eq hpc21 with arg1, step_assert_eq hpc22 with arg2, step_assert_eq hpc23 with arg3, step_assert_eq hpc24 with arg4, step_assert_eq hpc25 with arg5, step_assert_eq hpc26 with arg6, step_assert_eq hpc27 with arg7, step_assert_eq hpc28 hpc29 with arg8, step_sub hpc30 (auto_sound_ec_mul_inner mem _ range_check_ptr₁ pow2_0 scalar.d1 86 _ _ _ _ _ _ _ _ _ _ _ _ _), { rw hpc31, norm_num2, exact h_mem_17 }, { rw hpc31, norm_num2, exact h_mem_4 }, { rw hpc31, norm_num2, exact h_mem_5 }, { rw hpc31, norm_num2, exact h_mem_6 }, { rw hpc31, norm_num2, exact h_mem_7 }, { rw hpc31, norm_num2, exact h_mem_12 }, { rw hpc31, norm_num2, exact h_mem_13 }, { rw hpc31, norm_num2, exact h_mem_14 }, { rw hpc31, norm_num2, exact h_mem_15 }, { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, hin_scalar, htv_range_check_ptr₁, htv_pow2_0, htv_res0, lc_res0] }, try { dsimp [cast_EcPoint, cast_BigInt3] }, try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8] }, try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, }, { try { ext } ; { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, hin_scalar, htv_range_check_ptr₁, htv_pow2_0, htv_res0, lc_res0] }, try { dsimp [cast_EcPoint, cast_BigInt3] }, try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8] }, try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, }, { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, hin_scalar, htv_range_check_ptr₁, htv_pow2_0, htv_res0, lc_res0] }, try { dsimp [cast_EcPoint, cast_BigInt3] }, try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8] }, try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, }, { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, hin_scalar, htv_range_check_ptr₁, htv_pow2_0, htv_res0, lc_res0] }, try { dsimp [cast_EcPoint, cast_BigInt3] }, try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8] }, try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, }, intros ΞΊ_call32 ap32 h_call32, rcases h_call32 with ⟨rc_m32, rc_mle32, hl_range_check_ptrβ‚‚, h_call32⟩, generalize' hr_rev_range_check_ptrβ‚‚: mem (ap32 - 13) = range_check_ptrβ‚‚, have htv_range_check_ptrβ‚‚ := hr_rev_range_check_ptrβ‚‚.symm, clear hr_rev_range_check_ptrβ‚‚, generalize' hr_rev_pow2_1: cast_EcPoint mem (ap32 - 12) = pow2_1, simp only [hr_rev_pow2_1] at h_call32, have htv_pow2_1 := hr_rev_pow2_1.symm, clear hr_rev_pow2_1, generalize' hr_rev_res1: cast_EcPoint mem (ap32 - 6) = res1, simp only [hr_rev_res1] at h_call32, have htv_res1 := hr_rev_res1.symm, clear hr_rev_res1, try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4 ,arg5 ,arg6 ,arg7 ,arg8] at hl_range_check_ptrβ‚‚ }, rw [←htv_range_check_ptrβ‚‚, ←htv_range_check_ptr₁] at hl_range_check_ptrβ‚‚, try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4 ,arg5 ,arg6 ,arg7 ,arg8] at h_call32 }, rw [←htv_range_check_ptr₁, hl_range_check_ptr₁, hin_range_check_ptr] at h_call32, clear arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8, -- local var step_assert_eq hpc32 with temp0, step_assert_eq hpc33 with temp1, step_assert_eq hpc34 with temp2, step_assert_eq hpc35 with temp3, step_assert_eq hpc36 with temp4, step_assert_eq hpc37 with temp5, have lc_res1: res1 = cast_EcPoint mem (Οƒ.fp + 6), { try { ext } ; { try { simp only [htv_res1] }, try { dsimp [cast_EcPoint, cast_BigInt3] }, try { arith_simps }, try { simp only [temp0, temp1, temp2, temp3, temp4, temp5] }, try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, }, clear temp0 temp1 temp2 temp3 temp4 temp5, -- function call step_assert_eq hpc38 with arg0, step_assert_eq hpc39 with arg1, step_assert_eq hpc40 with arg2, step_assert_eq hpc41 with arg3, step_assert_eq hpc42 with arg4, step_assert_eq hpc43 with arg5, step_assert_eq hpc44 with arg6, step_assert_eq hpc45 with arg7, step_assert_eq hpc46 hpc47 with arg8, step_sub hpc48 (auto_sound_ec_mul_inner mem _ range_check_ptrβ‚‚ pow2_1 scalar.d2 84 _ _ _ _ _ _ _ _ _ _ _ _ _), { rw hpc49, norm_num2, exact h_mem_17 }, { rw hpc49, norm_num2, exact h_mem_4 }, { rw hpc49, norm_num2, exact h_mem_5 }, { rw hpc49, norm_num2, exact h_mem_6 }, { rw hpc49, norm_num2, exact h_mem_7 }, { rw hpc49, norm_num2, exact h_mem_12 }, { rw hpc49, norm_num2, exact h_mem_13 }, { rw hpc49, norm_num2, exact h_mem_14 }, { rw hpc49, norm_num2, exact h_mem_15 }, { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, hin_scalar, htv_range_check_ptr₁, htv_pow2_0, htv_res0, lc_res0, htv_range_check_ptrβ‚‚, htv_pow2_1, htv_res1, lc_res1] }, try { dsimp [cast_EcPoint, cast_BigInt3] }, try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8] }, try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, }, { try { ext } ; { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, hin_scalar, htv_range_check_ptr₁, htv_pow2_0, htv_res0, lc_res0, htv_range_check_ptrβ‚‚, htv_pow2_1, htv_res1, lc_res1] }, try { dsimp [cast_EcPoint, cast_BigInt3] }, try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8] }, try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, }, { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, hin_scalar, htv_range_check_ptr₁, htv_pow2_0, htv_res0, lc_res0, htv_range_check_ptrβ‚‚, htv_pow2_1, htv_res1, lc_res1] }, try { dsimp [cast_EcPoint, cast_BigInt3] }, try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8] }, try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, }, { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, hin_scalar, htv_range_check_ptr₁, htv_pow2_0, htv_res0, lc_res0, htv_range_check_ptrβ‚‚, htv_pow2_1, htv_res1, lc_res1] }, try { dsimp [cast_EcPoint, cast_BigInt3] }, try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8] }, try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, }, intros ΞΊ_call50 ap50 h_call50, rcases h_call50 with ⟨rc_m50, rc_mle50, hl_range_check_ptr₃, h_call50⟩, generalize' hr_rev_range_check_ptr₃: mem (ap50 - 13) = range_check_ptr₃, have htv_range_check_ptr₃ := hr_rev_range_check_ptr₃.symm, clear hr_rev_range_check_ptr₃, generalize' hr_rev_res2: cast_EcPoint mem (ap50 - 6) = res2, simp only [hr_rev_res2] at h_call50, have htv_res2 := hr_rev_res2.symm, clear hr_rev_res2, try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4 ,arg5 ,arg6 ,arg7 ,arg8] at hl_range_check_ptr₃ }, rw [←htv_range_check_ptr₃, ←htv_range_check_ptrβ‚‚] at hl_range_check_ptr₃, try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4 ,arg5 ,arg6 ,arg7 ,arg8] at h_call50 }, rw [←htv_range_check_ptrβ‚‚, hl_range_check_ptrβ‚‚, hl_range_check_ptr₁, hin_range_check_ptr] at h_call50, clear arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8, -- local var step_assert_eq hpc50 with temp0, step_assert_eq hpc51 with temp1, step_assert_eq hpc52 with temp2, step_assert_eq hpc53 with temp3, step_assert_eq hpc54 with temp4, step_assert_eq hpc55 with temp5, have lc_res2: res2 = cast_EcPoint mem (Οƒ.fp + 12), { try { ext } ; { try { simp only [htv_res2] }, try { dsimp [cast_EcPoint, cast_BigInt3] }, try { arith_simps }, try { simp only [temp0, temp1, temp2, temp3, temp4, temp5] }, try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, }, clear temp0 temp1 temp2 temp3 temp4 temp5, -- function call step_assert_eq hpc56 with arg0, step_assert_eq hpc57 with arg1, step_assert_eq hpc58 with arg2, step_assert_eq hpc59 with arg3, step_assert_eq hpc60 with arg4, step_assert_eq hpc61 with arg5, step_assert_eq hpc62 with arg6, step_assert_eq hpc63 with arg7, step_assert_eq hpc64 with arg8, step_assert_eq hpc65 with arg9, step_assert_eq hpc66 with arg10, step_assert_eq hpc67 with arg11, step_assert_eq hpc68 with arg12, step_sub hpc69 (auto_sound_ec_add mem _ range_check_ptr₃ res0 res1 _ _ _ _ _ _ _ _ _ _ _ _ _), { rw hpc70, norm_num2, exact h_mem_16 }, { rw hpc70, norm_num2, exact h_mem_4 }, { rw hpc70, norm_num2, exact h_mem_5 }, { rw hpc70, norm_num2, exact h_mem_6 }, { rw hpc70, norm_num2, exact h_mem_7 }, { rw hpc70, norm_num2, exact h_mem_8 }, { rw hpc70, norm_num2, exact h_mem_12 }, { rw hpc70, norm_num2, exact h_mem_13 }, { rw hpc70, norm_num2, exact h_mem_14 }, { rw hpc70, norm_num2, exact h_mem_15 }, { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, hin_scalar, htv_range_check_ptr₁, htv_pow2_0, htv_res0, lc_res0, htv_range_check_ptrβ‚‚, htv_pow2_1, htv_res1, lc_res1, htv_range_check_ptr₃, htv_res2, lc_res2] }, try { dsimp [cast_EcPoint, cast_BigInt3] }, try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12] }, try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, }, { try { ext } ; { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, hin_scalar, htv_range_check_ptr₁, htv_pow2_0, htv_res0, lc_res0, htv_range_check_ptrβ‚‚, htv_pow2_1, htv_res1, lc_res1, htv_range_check_ptr₃, htv_res2, lc_res2] }, try { dsimp [cast_EcPoint, cast_BigInt3] }, try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12] }, try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, }, { try { ext } ; { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, hin_scalar, htv_range_check_ptr₁, htv_pow2_0, htv_res0, lc_res0, htv_range_check_ptrβ‚‚, htv_pow2_1, htv_res1, lc_res1, htv_range_check_ptr₃, htv_res2, lc_res2] }, try { dsimp [cast_EcPoint, cast_BigInt3] }, try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12] }, try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, }, intros ΞΊ_call71 ap71 h_call71, rcases h_call71 with ⟨rc_m71, rc_mle71, hl_range_check_ptrβ‚„, h_call71⟩, generalize' hr_rev_range_check_ptrβ‚„: mem (ap71 - 7) = range_check_ptrβ‚„, have htv_range_check_ptrβ‚„ := hr_rev_range_check_ptrβ‚„.symm, clear hr_rev_range_check_ptrβ‚„, generalize' hr_rev_res: cast_EcPoint mem (ap71 - 6) = res, simp only [hr_rev_res] at h_call71, have htv_res := hr_rev_res.symm, clear hr_rev_res, try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4 ,arg5 ,arg6 ,arg7 ,arg8 ,arg9 ,arg10 ,arg11 ,arg12] at hl_range_check_ptrβ‚„ }, rw [←htv_range_check_ptrβ‚„, ←htv_range_check_ptr₃] at hl_range_check_ptrβ‚„, try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4 ,arg5 ,arg6 ,arg7 ,arg8 ,arg9 ,arg10 ,arg11 ,arg12] at h_call71 }, rw [←htv_range_check_ptr₃, hl_range_check_ptr₃, hl_range_check_ptrβ‚‚, hl_range_check_ptr₁, hin_range_check_ptr] at h_call71, clear arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 arg9 arg10 arg11 arg12, -- function call step_assert_eq hpc71 with arg0, step_assert_eq hpc72 with arg1, step_assert_eq hpc73 with arg2, step_assert_eq hpc74 with arg3, step_assert_eq hpc75 with arg4, step_assert_eq hpc76 with arg5, step_sub hpc77 (auto_sound_ec_add mem _ range_check_ptrβ‚„ res res2 _ _ _ _ _ _ _ _ _ _ _ _ _), { rw hpc78, norm_num2, exact h_mem_16 }, { rw hpc78, norm_num2, exact h_mem_4 }, { rw hpc78, norm_num2, exact h_mem_5 }, { rw hpc78, norm_num2, exact h_mem_6 }, { rw hpc78, norm_num2, exact h_mem_7 }, { rw hpc78, norm_num2, exact h_mem_8 }, { rw hpc78, norm_num2, exact h_mem_12 }, { rw hpc78, norm_num2, exact h_mem_13 }, { rw hpc78, norm_num2, exact h_mem_14 }, { rw hpc78, norm_num2, exact h_mem_15 }, { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, hin_scalar, htv_range_check_ptr₁, htv_pow2_0, htv_res0, lc_res0, htv_range_check_ptrβ‚‚, htv_pow2_1, htv_res1, lc_res1, htv_range_check_ptr₃, htv_res2, lc_res2, htv_range_check_ptrβ‚„, htv_res] }, try { dsimp [cast_EcPoint, cast_BigInt3] }, try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3, arg4, arg5] }, try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, }, { try { ext } ; { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, hin_scalar, htv_range_check_ptr₁, htv_pow2_0, htv_res0, lc_res0, htv_range_check_ptrβ‚‚, htv_pow2_1, htv_res1, lc_res1, htv_range_check_ptr₃, htv_res2, lc_res2, htv_range_check_ptrβ‚„, htv_res] }, try { dsimp [cast_EcPoint, cast_BigInt3] }, try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3, arg4, arg5] }, try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, }, { try { ext } ; { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, hin_scalar, htv_range_check_ptr₁, htv_pow2_0, htv_res0, lc_res0, htv_range_check_ptrβ‚‚, htv_pow2_1, htv_res1, lc_res1, htv_range_check_ptr₃, htv_res2, lc_res2, htv_range_check_ptrβ‚„, htv_res] }, try { dsimp [cast_EcPoint, cast_BigInt3] }, try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3, arg4, arg5] }, try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, }, intros ΞΊ_call79 ap79 h_call79, rcases h_call79 with ⟨rc_m79, rc_mle79, hl_range_check_ptrβ‚…, h_call79⟩, generalize' hr_rev_range_check_ptrβ‚…: mem (ap79 - 7) = range_check_ptrβ‚…, have htv_range_check_ptrβ‚… := hr_rev_range_check_ptrβ‚….symm, clear hr_rev_range_check_ptrβ‚…, generalize' hr_rev_res₁: cast_EcPoint mem (ap79 - 6) = res₁, simp only [hr_rev_res₁] at h_call79, have htv_res₁ := hr_rev_res₁.symm, clear hr_rev_res₁, try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4 ,arg5] at hl_range_check_ptrβ‚… }, rw [←htv_range_check_ptrβ‚…, ←htv_range_check_ptrβ‚„] at hl_range_check_ptrβ‚…, try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4 ,arg5] at h_call79 }, rw [←htv_range_check_ptrβ‚„, hl_range_check_ptrβ‚„, hl_range_check_ptr₃, hl_range_check_ptrβ‚‚, hl_range_check_ptr₁, hin_range_check_ptr] at h_call79, clear arg0 arg1 arg2 arg3 arg4 arg5, -- return step_ret hpc79, -- finish step_done, use_only [rfl, rfl], -- range check condition use_only (rc_m14+rc_m32+rc_m50+rc_m71+rc_m79+0+0), split, linarith [rc_mle14, rc_mle32, rc_mle50, rc_mle71, rc_mle79], split, { arith_simps, rw [←htv_range_check_ptrβ‚…, hl_range_check_ptrβ‚…, hl_range_check_ptrβ‚„, hl_range_check_ptr₃, hl_range_check_ptrβ‚‚, hl_range_check_ptr₁, hin_range_check_ptr], try { arith_simps, refl <|> norm_cast }, try { refl } }, intro rc_h_range_check_ptr, repeat { rw [add_assoc] at rc_h_range_check_ptr }, have rc_h_range_check_ptr' := range_checked_add_right rc_h_range_check_ptr, -- Final Proof -- user-provided reduction suffices auto_spec: auto_spec_ec_mul mem _ range_check_ptr point scalar _ _, { apply sound_ec_mul, apply auto_spec }, -- prove the auto generated assertion dsimp [auto_spec_ec_mul], try { norm_num1 }, try { arith_simps }, use_only [ΞΊ_call14], use_only [range_check_ptr₁], use_only [pow2_0], use_only [res0], have rc_h_range_check_ptr₁ := range_checked_offset' rc_h_range_check_ptr, have rc_h_range_check_ptr₁' := range_checked_add_right rc_h_range_check_ptr₁, try { norm_cast at rc_h_range_check_ptr₁' }, have spec14 := h_call14 rc_h_range_check_ptr', rw [←hin_range_check_ptr, ←htv_range_check_ptr₁] at spec14, try { dsimp at spec14, arith_simps at spec14 }, use_only [spec14], use_only [ΞΊ_call32], use_only [range_check_ptrβ‚‚], use_only [pow2_1], use_only [res1], have rc_h_range_check_ptrβ‚‚ := range_checked_offset' rc_h_range_check_ptr₁, have rc_h_range_check_ptrβ‚‚' := range_checked_add_right rc_h_range_check_ptrβ‚‚, try { norm_cast at rc_h_range_check_ptrβ‚‚' }, have spec32 := h_call32 rc_h_range_check_ptr₁', rw [←hin_range_check_ptr, ←hl_range_check_ptr₁, ←htv_range_check_ptrβ‚‚] at spec32, try { dsimp at spec32, arith_simps at spec32 }, use_only [spec32], use_only [ΞΊ_call50], use_only [range_check_ptr₃], use_only [(cast_EcPoint mem (ap50 - 12))], use_only [res2], have rc_h_range_check_ptr₃ := range_checked_offset' rc_h_range_check_ptrβ‚‚, have rc_h_range_check_ptr₃' := range_checked_add_right rc_h_range_check_ptr₃, try { norm_cast at rc_h_range_check_ptr₃' }, have spec50 := h_call50 rc_h_range_check_ptrβ‚‚', rw [←hin_range_check_ptr, ←hl_range_check_ptr₁, ←hl_range_check_ptrβ‚‚, ←htv_range_check_ptr₃] at spec50, try { dsimp at spec50, arith_simps at spec50 }, use_only [spec50], use_only [ΞΊ_call71], use_only [range_check_ptrβ‚„], use_only [res], have rc_h_range_check_ptrβ‚„ := range_checked_offset' rc_h_range_check_ptr₃, have rc_h_range_check_ptrβ‚„' := range_checked_add_right rc_h_range_check_ptrβ‚„, try { norm_cast at rc_h_range_check_ptrβ‚„' }, have spec71 := h_call71 rc_h_range_check_ptr₃', rw [←hin_range_check_ptr, ←hl_range_check_ptr₁, ←hl_range_check_ptrβ‚‚, ←hl_range_check_ptr₃, ←htv_range_check_ptrβ‚„] at spec71, try { dsimp at spec71, arith_simps at spec71 }, use_only [spec71], use_only [ΞΊ_call79], use_only [range_check_ptrβ‚…], use_only [res₁], have rc_h_range_check_ptrβ‚… := range_checked_offset' rc_h_range_check_ptrβ‚„, have rc_h_range_check_ptrβ‚…' := range_checked_add_right rc_h_range_check_ptrβ‚…, try { norm_cast at rc_h_range_check_ptrβ‚…' }, have spec79 := h_call79 rc_h_range_check_ptrβ‚„', rw [←hin_range_check_ptr, ←hl_range_check_ptr₁, ←hl_range_check_ptrβ‚‚, ←hl_range_check_ptr₃, ←hl_range_check_ptrβ‚„, ←htv_range_check_ptrβ‚…] at spec79, try { dsimp at spec79, arith_simps at spec79 }, use_only [spec79], try { split, linarith }, try { ensures_simps; try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, hin_scalar, htv_range_check_ptr₁, htv_pow2_0, htv_res0, lc_res0, htv_range_check_ptrβ‚‚, htv_pow2_1, htv_res1, lc_res1, htv_range_check_ptr₃, htv_res2, lc_res2, htv_range_check_ptrβ‚„, htv_res, htv_range_check_ptrβ‚…, htv_res₁] }, }, try { dsimp [cast_EcPoint, cast_BigInt3] }, try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, end
function sandia_sgmgg_test01 ( ) %*****************************************************************************80 % %% SANDIA_SGMGG_TEST01 demonstrates the naive coefficient calculations. % % Licensing: % % This code is distributed under the GNU LGPL license. % % Modified: % % 23 August 2011 % % Author: % % John Burkardt % fprintf ( 1, '\n' ); fprintf ( 1, 'SANDIA_SGMGG_TEST01:\n' ); fprintf ( 1, ' Demonstrate naive coefficient calculations.\n' ); % % Isotropic grid in 2D. % fprintf ( 1, '\n' ); fprintf ( 1, ' 1) Isotropic grid in 2D\n' ); dim_num = 2; point_num = 7; sparse_index = [ ... 0, 2; ... 0, 3; ... 1, 1; ... 1, 2; ... 2, 0; ... 2, 1; ... 3, 0 ]'; sandia_sgmgg_coef_naive_test ( dim_num, point_num, sparse_index ); % % Isotropic grid in 3D. % fprintf ( 1, '\n' ); fprintf ( 1, ' 2) Isotropic grid in 3D\n' ); dim_num = 3; point_num = 19; sparse_index = [ ... 0, 1, 0; ... 0, 2, 0; ... 0, 3, 0; ... 1, 0, 0; ... 1, 1, 0; ... 1, 2, 0; ... 2, 0, 0; ... 2, 1, 0; ... 3, 0, 0; ... 0, 0, 1; ... 0, 1, 1; ... 0, 2, 1; ... 1, 0, 1; ... 1, 1, 1; ... 2, 0, 1; ... 0, 0, 2; ... 0, 1, 2; ... 1, 0, 2; ... 0, 0, 3 ]'; sandia_sgmgg_coef_naive_test ( dim_num, point_num, sparse_index ); % % Anisotropic grid in 2D. % fprintf ( 1, '\n' ); fprintf ( 1, ' 3) Anisotropic grid in 2D\n' ); dim_num = 2; point_num = 8; sparse_index = [ ... 0, 2; ... 1, 1; ... 1, 2; ... 2, 1; ... 3, 0; ... 3, 1; ... 4, 0; ... 5, 0 ]'; sandia_sgmgg_coef_naive_test ( dim_num, point_num, sparse_index ); % % Generalized grid in 2D. % fprintf ( 1, '\n' ); fprintf ( 1, ' 4) Generalized grid in 2D\n' ); dim_num = 2; point_num = 8; sparse_index = [ ... 0, 0; ... 0, 1; ... 0, 2; ... 0, 3; ... 1, 0; ... 1, 1; ... 2, 0; ... 3, 0 ]'; sandia_sgmgg_coef_naive_test ( dim_num, point_num, sparse_index ); return end
import networkx as nx import matplotlib.pyplot as plt from icecream import ic import numpy as np def load_rrt_gragh_2_maps(filename): G = nx.read_graphml(filename) nx.draw(G) plt.show() # Save the relationship of nodes: key->target(son), value->source(father) node_pos_map = dict() # key->node name, value->position, np.array->(x, y) son_father_map = dict() edge_weight_map = dict() edge_connect_father_son_map = dict() for node in G.nodes(data=True): coords = node[1]["coords"].split(",") x = float(coords[0]) y = float(coords[1]) yaw = float(coords[2]) xy = np.array([[x, y]]) node_pos_map[node[0]] = xy ic(node_pos_map) for edge in G.edges(data=True): son_father_map[edge[1]] = edge[0] edge_weight_map[edge[2]["id"]] = edge[2]["weight"] edge_connect_father_son_map[edge[2]["id"]] = (edge[1], edge[0]) # ic(son_father_map) # ic(edge_weight) # ic(edge_connect_father_son_map) return node_pos_map, son_father_map, edge_weight_map, edge_connect_father_son_map node_pos_map, son_father_map, edge_weight_map, edge_connect_father_son_map = load_rrt_gragh_2_maps(filename="graph.graphml") nodes_pos_graph_list = [] for val in node_pos_map.values(): nodes_pos_graph_list.append(val) ic(nodes_pos_graph_list)
Module CKTransSPL. Require Export cktrans_spl_int. Require Export assetmapping_spl_def. Require Export featuremodel_spl_def. Import FeatureModelSPL. Import AssetMappingSPL. Require Import Coq.Lists.ListSet. Require Import Coq.Arith.Arith. Require Import Coq.Init.Specif. Require Export Coq.Lists.List. Inductive CK: Type. Parameter CKSem_func : CK -> AM -> Conf -> set Asset. (* Axiom over ck evaluation *) Axiom amRef_func: forall (am1 am2: AM), (aMR_func am1 am2) -> forall (K: CK) (C: Conf), wfProduct_ind (CKSem_func K am1 C) -> wfProduct_ind (CKSem_func K am2 C) /\ assetRef_func (CKSem_func K am1 C) (CKSem_func K am2 C). Parameter CKConf_func: CK -> set Conf. (* % Definition <CK equivalence> *) Definition equivalentCKsAux (ck1 ck2: CK): Prop := match (set_diff conf_dec (CKConf_func ck1) (CKConf_func ck2)) with | nil => True | _ => False end. Definition equivalentCKs_func (ck1 ck2: CK): Prop := (equivalentCKsAux ck1 ck2) /\ (equivalentCKsAux ck2 ck1). Definition weakerEqCK_func (fm: FM) (ck1 ck2: CK): Prop := forall am, forall c, set_In c (FMRef_Func fm) -> (CKSem_func ck1 am c = CKSem_func ck2 am c). Lemma equalsCK2_lemma: forall ck1 ck2, equivalentCKs_func ck1 ck2 -> ck1 = ck2. Proof. unfold equivalentCKs. unfold equivalentCKsAux. intros. destruct H. (*+ rewrite equalsSetDiff. - trivial. - reflexivity. + rewrite equalsSetDiff. - trivial. - reflexivity. *) Admitted. End CKTransSPL.
State Before: r : List Char it : Iterator h : ValidFor [] r it ⊒ ValidFor [] r (Iterator.prev it) State After: r : List Char it : Iterator h : ValidFor [] r it ⊒ ValidFor [] r { s := { data := r }, i := 0 } Tactic: simp [Iterator.prev, h.toString, h.pos] State Before: r : List Char it : Iterator h : ValidFor [] r it ⊒ ValidFor [] r { s := { data := r }, i := 0 } State After: no goals Tactic: constructor
import data.nat.digits open nat -- Los dΓ­gitos de n en base b son menores que b. lemma digits_lt_base (b : β„•) (hb : 2 ≀ b) (n : β„•) : βˆ€ d ∈ digits b n, d < b := begin cases b with b, { linarith }, { cases b with b, { linarith }, { clear hb, apply nat.strong_induction_on n, clear n, intro n, intro IH, intro d, intro hd, unfold digits at hd IH, have h := digits_aux_def (b+2) (by linarith) n, cases n with n, { finish }, { replace h := h (nat.zero_lt_succ n), rw h at hd, cases hd, { rw hd, exact n.succ.mod_lt (by linarith) }, { apply IH _ _ d hd, apply nat.div_lt_self (nat.succ_pos _), linarith }}}}, end -- Los dΓ­gitos de la expresiΓ³n decimal de un nΓΊmero son menores o -- iguales que 9. lemma digits_le_9 (n : β„•) : βˆ€ (d ∈ (digits 10 n)), d ≀ 9 := Ξ» d hd, nat.le_of_lt_succ $ digits_lt_base 10 (by norm_num) n _ hd
lemma cone_Inter[intro]: "\<forall>s\<in>f. cone s \<Longrightarrow> cone (\<Inter>f)"
module _ where module G where module H where module A where module B where module C where open G public module I = A.B.C.H
------------------------------------------------------------------------ -- Closure properties for h-levels ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} -- Partly based on Voevodsky's work on so-called univalent -- foundations. open import Equality module H-level.Closure {reflexive} (eq : βˆ€ {a p} β†’ Equality-with-J a p reflexive) where open import Bijection eq as Bijection hiding (id; _∘_) open Derived-definitions-and-properties eq import Equality.Decidable-UIP eq as DUIP open import Equality.Decision-procedures eq open import H-level eq open import Logical-equivalence hiding (id; _∘_) open import Nat eq as Nat open import Prelude open import Surjection eq as Surjection hiding (id; _∘_) ------------------------------------------------------------------------ -- The unit type -- The unit type is contractible. ⊀-contractible : Contractible ⊀ ⊀-contractible = (_ , Ξ» _ β†’ refl _) -- A type is contractible iff it is in bijective correspondence with -- the unit type. contractibleβ‡”β†”βŠ€ : βˆ€ {a} {A : Type a} β†’ Contractible A ⇔ (A ↔ ⊀) contractibleβ‡”β†”βŠ€ = record { to = flip contractible-isomorphic ⊀-contractible ; from = Ξ» Aβ†”βŠ€ β†’ respects-surjection (_↔_.surjection (Bijection.inverse Aβ†”βŠ€)) 0 ⊀-contractible } ------------------------------------------------------------------------ -- The empty type abstract -- The empty type is not contractible. Β¬-βŠ₯-contractible : βˆ€ {β„“} β†’ Β¬ Contractible (βŠ₯ {β„“ = β„“}) Β¬-βŠ₯-contractible = βŠ₯-elim ∘ proj₁ -- The empty type is propositional. βŠ₯-propositional : βˆ€ {β„“} β†’ Is-proposition (βŠ₯ {β„“ = β„“}) βŠ₯-propositional x = βŠ₯-elim x -- Thus any uninhabited type is also propositional. uninhabited-propositional : βˆ€ {a} {A : Type a} β†’ Β¬ A β†’ Is-proposition A uninhabited-propositional Β¬A = respects-surjection (_↔_.surjection $ βŠ₯↔uninhabited {β„“ = # 0} Β¬A) 1 βŠ₯-propositional ------------------------------------------------------------------------ -- Booleans abstract -- The booleans are not propositional. Β¬-Bool-propositional : Β¬ Is-proposition Bool Β¬-Bool-propositional propositional = Bool.trueβ‰’false $ propositional true false -- The booleans form a set. Bool-set : Is-set Bool Bool-set = DUIP.decidableβ‡’set Bool._β‰Ÿ_ ------------------------------------------------------------------------ -- Natural numbers abstract -- β„• is not propositional. Β¬-β„•-propositional : Β¬ Is-proposition β„• Β¬-β„•-propositional β„•-prop = 0β‰’+ $ β„•-prop 0 1 -- β„• is a set. β„•-set : Is-set β„• β„•-set = DUIP.decidableβ‡’set Nat._β‰Ÿ_ -- Nat._≀_ is not a family of contractible types. Β¬-≀-contractible : Β¬ (βˆ€ {m n} β†’ Contractible (m Nat.≀ n)) Β¬-≀-contractible ≀-contr with proj₁ (≀-contr {m = 1} {n = 0}) ... | ≀-reflβ€² 1≑0 = 0β‰’+ (sym 1≑0) ... | ≀-stepβ€² _ +≑0 = 0β‰’+ (sym +≑0) -- Nat._≀_ is a family of propositions. ≀-propositional : βˆ€ {m n} β†’ Is-proposition (m Nat.≀ n) ≀-propositional = irr where lemma : βˆ€ {m n k} β†’ m ≑ n β†’ m ≀ k β†’ suc k ≑ n β†’ βŠ₯β‚€ lemma {m} {n} {k} m≑n m≀k 1+k≑n = <-irreflexive ( suc n β‰‘βŸ¨ cong suc $ sym m≑n βŸ©β‰€ suc m β‰€βŸ¨ suc≀suc m≀k ⟩ suc k β‰‘βŸ¨ 1+k≑n βŸ©β‰€ n βˆŽβ‰€) cong-≀-stepβ€² : βˆ€ {m n k₁ kβ‚‚} {p₁ : m ≀ k₁} {q₁ : suc k₁ ≑ n} {pβ‚‚ : m ≀ kβ‚‚} {qβ‚‚ : suc kβ‚‚ ≑ n} β†’ (k₁≑kβ‚‚ : k₁ ≑ kβ‚‚) β†’ subst (m ≀_) k₁≑kβ‚‚ p₁ ≑ pβ‚‚ β†’ subst (Ξ» k β†’ suc k ≑ n) k₁≑kβ‚‚ q₁ ≑ qβ‚‚ β†’ ≀-stepβ€² p₁ q₁ ≑ ≀-stepβ€² pβ‚‚ qβ‚‚ cong-≀-stepβ€² {p₁ = p₁} {q₁} {pβ‚‚} {qβ‚‚} k₁≑kβ‚‚ p-eq q-eq = cong (Ξ» { (k , p , q) β†’ ≀-stepβ€² {k = k} p q }) (Ξ£-≑,≑→≑ k₁≑kβ‚‚ (subst (Ξ» k β†’ _ ≀ k Γ— suc k ≑ _) k₁≑kβ‚‚ (p₁ , q₁) β‰‘βŸ¨ push-subst-, _ _ ⟩ (subst (_ ≀_) k₁≑kβ‚‚ p₁ , subst (Ξ» k β†’ suc k ≑ _) k₁≑kβ‚‚ q₁) β‰‘βŸ¨ congβ‚‚ _,_ p-eq q-eq ⟩∎ (pβ‚‚ , qβ‚‚) ∎)) irr : βˆ€ {m n} β†’ Is-proposition (m Nat.≀ n) irr (≀-reflβ€² q₁) (≀-reflβ€² qβ‚‚) = cong ≀-reflβ€² $ β„•-set q₁ qβ‚‚ irr (≀-reflβ€² q₁) (≀-stepβ€² pβ‚‚ qβ‚‚) = βŠ₯-elim (lemma q₁ pβ‚‚ qβ‚‚) irr (≀-stepβ€² p₁ q₁) (≀-reflβ€² qβ‚‚) = βŠ₯-elim (lemma qβ‚‚ p₁ q₁) irr {n = n} (≀-stepβ€² {k = k₁} p₁ q₁) (≀-stepβ€² {k = kβ‚‚} pβ‚‚ qβ‚‚) = cong-≀-stepβ€² (cancel-suc (suc k₁ β‰‘βŸ¨ q₁ ⟩ n β‰‘βŸ¨ sym qβ‚‚ ⟩∎ suc kβ‚‚ ∎)) (irr _ pβ‚‚) (β„•-set _ _) -- Nat.Distinct is not a family of contractible types. Β¬-Distinct-contractible : Β¬ (βˆ€ m n β†’ Contractible (Nat.Distinct m n)) Β¬-Distinct-contractible Distinct-contr = proj₁ (Distinct-contr 0 0) -- Distinct is a family of propositions. Distinct-propositional : βˆ€ m n β†’ Is-proposition (Distinct m n) Distinct-propositional zero zero = βŠ₯-propositional Distinct-propositional zero (suc n) = mono₁ 0 ⊀-contractible Distinct-propositional (suc m) zero = mono₁ 0 ⊀-contractible Distinct-propositional (suc m) (suc n) = Distinct-propositional m n ------------------------------------------------------------------------ -- Ξ -types -- Closure of contractibility under Ξ Β A is logically equivalent to -- having extensional equality for functions from A. Ξ -closure-contractible⇔extensionality : βˆ€ {a b} {A : Type a} β†’ ({B : A β†’ Type b} β†’ (βˆ€ x β†’ Contractible (B x)) β†’ Contractible ((x : A) β†’ B x)) ⇔ ({B : A β†’ Type b} β†’ Extensionalityβ€² A B) Ξ -closure-contractible⇔extensionality {b = b} {A} = record { to = β‡’ ; from = Ξ» ext cB β†’ ((Ξ» x β†’ proj₁ (cB x)) , Ξ» f β†’ ext Ξ» x β†’ projβ‚‚ (cB x) (f x)) } where β‡’ : ({B : A β†’ Type b} β†’ (βˆ€ x β†’ Contractible (B x)) β†’ Contractible ((x : A) β†’ B x)) β†’ (βˆ€ {B} β†’ Extensionalityβ€² A B) β‡’ closure {B} {f} {g} f≑g = f β‰‘βŸ¨ sym (cong (Ξ» c β†’ Ξ» x β†’ proj₁ (c x)) $ projβ‚‚ contractible (Ξ» x β†’ (f x , f≑g x))) ⟩ (Ξ» x β†’ proj₁ (proj₁ contractible x)) β‰‘βŸ¨ cong (Ξ» c β†’ Ξ» x β†’ proj₁ (c x)) $ projβ‚‚ contractible (Ξ» x β†’ (g x , refl (g x))) ⟩∎ g ∎ where contractible : Contractible ((x : A) β†’ Singleton (g x)) contractible = closure (singleton-contractible ∘ g) abstract -- Given (generalised) extensionality one can define an -- extensionality proof which is well-behaved. extensionalityβ‡’well-behaved-extensionality : βˆ€ {a b} {A : Type a} β†’ ({B : A β†’ Type b} β†’ Extensionalityβ€² A B) β†’ {B : A β†’ Type b} β†’ Well-behaved-extensionality A B extensionalityβ‡’well-behaved-extensionality {A = A} ext {B} = (Ξ» {_} β†’ extβ€²) , Ξ» f β†’ extβ€² (refl ∘ f) β‰‘βŸ¨ trans-symΛ‘ _ ⟩∎ refl f ∎ where extβ€² : Extensionalityβ€² A B extβ€² = to (from ext) where open _⇔_ Ξ -closure-contractible⇔extensionality -- A potential inverse of extensionality. (See Equivalence for a proof -- which shows that this function has an inverse, assuming -- extensionality.) ext⁻¹ : βˆ€ {a b} {A : Type a} {B : A β†’ Type b} {f g : (x : A) β†’ B x} β†’ f ≑ g β†’ (βˆ€ x β†’ f x ≑ g x) ext⁻¹ f≑g = Ξ» x β†’ cong (Ξ» h β†’ h x) f≑g abstract -- "Evaluation rule" for ext⁻¹. ext⁻¹-refl : βˆ€ {a b} {A : Type a} {B : A β†’ Type b} (f : (x : A) β†’ B x) {x} β†’ ext⁻¹ (refl f) x ≑ refl (f x) ext⁻¹-refl f {x} = cong-refl (Ξ» h β†’ h x) -- Given extensionality there is a (split) surjection from -- βˆ€Β xΒ β†’Β fΒ x ≑ gΒ x to f ≑ g. ext-surj : βˆ€ {a b} β†’ Extensionality a b β†’ {A : Type a} {B : A β†’ Type b} {f g : (x : A) β†’ B x} β†’ (βˆ€ x β†’ f x ≑ g x) β†  (f ≑ g) ext-surj {b = b} ext {A} {B} = record { logical-equivalence = record { to = to ; from = ext⁻¹ } ; right-inverse-of = elim (Ξ» {f g} f≑g β†’ to (ext⁻¹ f≑g) ≑ f≑g) Ξ» h β†’ proj₁ extβ€² (ext⁻¹ (refl h)) β‰‘βŸ¨ cong (proj₁ extβ€²) (proj₁ extβ€² Ξ» _ β†’ ext⁻¹-refl h) ⟩ proj₁ extβ€² (refl ∘ h) β‰‘βŸ¨ projβ‚‚ extβ€² h ⟩∎ refl h ∎ } where extβ€² : {B : A β†’ Type b} β†’ Well-behaved-extensionality A B extβ€² = extensionalityβ‡’well-behaved-extensionality (apply-ext ext) to : {f g : (x : A) β†’ B x} β†’ (βˆ€ x β†’ f x ≑ g x) β†’ f ≑ g to = proj₁ extβ€² -- H-levelβ€² is closed under Ξ Β A (assuming extensionality). Ξ -closureβ€² : βˆ€ {a b} {A : Type a} {B : A β†’ Type b} β†’ Extensionality a b β†’ βˆ€ n β†’ (βˆ€ x β†’ H-levelβ€² n (B x)) β†’ H-levelβ€² n ((x : A) β†’ B x) Ξ -closureβ€² ext zero = _⇔_.from Ξ -closure-contractible⇔extensionality (apply-ext ext) Ξ -closureβ€² ext (suc n) = Ξ» h f g β†’ respects-surjectionβ€² (ext-surj ext) n $ Ξ -closureβ€² ext n (Ξ» x β†’ h x (f x) (g x)) -- H-level is closed under Ξ Β A (assuming extensionality). Ξ -closure : βˆ€ {a b} {A : Type a} {B : A β†’ Type b} β†’ Extensionality a b β†’ βˆ€ n β†’ (βˆ€ x β†’ H-level n (B x)) β†’ H-level n ((x : A) β†’ B x) Ξ -closure ext n h = _⇔_.from H-level⇔H-levelβ€² $ Ξ -closureβ€² ext n (Ξ» x β†’ _⇔_.to H-level⇔H-levelβ€² (h x)) -- This also applies to the implicit function space. implicit-Ξ -closure : βˆ€ {a b} {A : Type a} {B : A β†’ Type b} β†’ Extensionality a b β†’ βˆ€ n β†’ (βˆ€ x β†’ H-level n (B x)) β†’ H-level n ({x : A} β†’ B x) implicit-Ξ -closure ext n = respects-surjection (_↔_.surjection $ Bijection.inverse implicit-Π↔Π) n ∘ Ξ -closure ext n abstract -- Negated types are propositional, assuming extensionality. Β¬-propositional : βˆ€ {a} {A : Type a} β†’ Extensionality a lzero β†’ Is-proposition (Β¬ A) Β¬-propositional ext = Ξ -closure ext 1 (Ξ» _ β†’ βŠ₯-propositional) -- The type βˆ€Β yΒ β†’Β x ≑ y is a proposition (assuming extensionality). -- -- This is LemmaΒ 4.1 from van Doorn's "Constructing the Propositional -- Truncation using Non-recursive HITs" (perhaps the proof is not -- quite identical to van Doorn's). Π≑-proposition : βˆ€ {a} {A : Type a} β†’ Extensionality a a β†’ (x : A) β†’ Is-proposition (βˆ€ y β†’ x ≑ y) Π≑-proposition {A = A} ext x = [inhabitedβ‡’+]β‡’+ 0 Ξ» f β†’ let prop : Is-proposition A prop u v = u β‰‘βŸ¨ sym (f u) ⟩ x β‰‘βŸ¨ f v ⟩∎ v ∎ in Ξ -closure ext 1 Ξ» _ β†’ mono₁ 1 prop ------------------------------------------------------------------------ -- Ξ£-types -- H-levelβ€² is closed under Ξ£. Ξ£-closureβ€² : βˆ€ {a b} {A : Type a} {B : A β†’ Type b} n β†’ H-levelβ€² n A β†’ (βˆ€ x β†’ H-levelβ€² n (B x)) β†’ H-levelβ€² n (Ξ£ A B) Ξ£-closureβ€² {A = A} {B} zero (x , irrA) hB = ((x , proj₁ (hB x)) , Ξ» p β†’ (x , proj₁ (hB x)) β‰‘βŸ¨ elim (Ξ» {x y} _ β†’ _≑_ {A = Ξ£ A B} (x , proj₁ (hB x)) (y , proj₁ (hB y))) (Ξ» _ β†’ refl _) (irrA (proj₁ p)) ⟩ (proj₁ p , proj₁ (hB (proj₁ p))) β‰‘βŸ¨ cong (_,_ (proj₁ p)) (projβ‚‚ (hB (proj₁ p)) (projβ‚‚ p)) ⟩∎ p ∎) Ξ£-closureβ€² {B = B} (suc n) hA hB = Ξ» p₁ pβ‚‚ β†’ respects-surjectionβ€² (_↔_.surjection Ξ£-≑,≑↔≑) n $ Ξ£-closureβ€² n (hA (proj₁ p₁) (proj₁ pβ‚‚)) (Ξ» pr₁p₁≑pr₁pβ‚‚ β†’ hB (proj₁ pβ‚‚) (subst B pr₁p₁≑pr₁pβ‚‚ (projβ‚‚ p₁)) (projβ‚‚ pβ‚‚)) -- H-level is closed under Ξ£. Ξ£-closure : βˆ€ {a b} {A : Type a} {B : A β†’ Type b} n β†’ H-level n A β†’ (βˆ€ x β†’ H-level n (B x)) β†’ H-level n (Ξ£ A B) Ξ£-closure n hA hB = _⇔_.from H-level⇔H-levelβ€² (Ξ£-closureβ€² n (_⇔_.to H-level⇔H-levelβ€² hA) (_⇔_.to H-level⇔H-levelβ€² ∘ hB)) abstract -- In the case of contractibility the codomain only needs to have -- the right h-level (0) for a single index. Ξ£-closure-contractible : βˆ€ {a b} {A : Type a} {B : A β†’ Type b} β†’ (c : Contractible A) β†’ Contractible (B (proj₁ c)) β†’ Contractible (Ξ£ A B) Ξ£-closure-contractible {B = B} cA (b , irrB) = Ξ£-closure 0 cA cB where cB : βˆ€ a β†’ Contractible (B a) cB a = subst B (projβ‚‚ cA a) b , Ξ» bβ€² β†’ subst B (projβ‚‚ cA a) b β‰‘βŸ¨ cong (subst B (projβ‚‚ cA a)) $ irrB (subst B (sym $ projβ‚‚ cA a) bβ€²) ⟩ subst B (projβ‚‚ cA a) (subst B (sym $ projβ‚‚ cA a) bβ€²) β‰‘βŸ¨ subst-subst-sym _ _ _ ⟩∎ bβ€² ∎ -- H-level is closed under _Γ—_. Γ—-closure : βˆ€ {a b} {A : Type a} {B : Type b} n β†’ H-level n A β†’ H-level n B β†’ H-level n (A Γ— B) Γ—-closure n hA hB = Ξ£-closure n hA (const hB) -- If BΒ a is inhabited for all a, and Σ AΒ B has h-levelΒ n, then A -- also has h-levelΒ n. -- -- One cannot, in general, replace βˆ€Β aΒ β†’Β BΒ a with βˆ€Β aΒ β†’Β βˆ₯Β BΒ aΒ βˆ₯ (see -- Circle.Β¬-generalised-proj₁-closure). However, this is possible if -- B is constant (see H-level.Truncation.Propositional.H-level-×₁). proj₁-closure : βˆ€ {a b} {A : Type a} {B : A β†’ Type b} β†’ (βˆ€ a β†’ B a) β†’ βˆ€ n β†’ H-level n (Ξ£ A B) β†’ H-level n A proj₁-closure {A = A} {B} inhabited = respects-surjection surj where surj : Ξ£ A B β†  A surj = record { logical-equivalence = record { to = proj₁ ; from = Ξ» x β†’ x , inhabited x } ; right-inverse-of = refl } -- If A is inhabited and AΒ Γ—Β B has h-levelΒ n, then B also has -- h-levelΒ n. projβ‚‚-closure : βˆ€ {a b} {A : Type a} {B : Type b} β†’ A β†’ βˆ€ n β†’ H-level n (A Γ— B) β†’ H-level n B projβ‚‚-closure {A = A} {B} inhabited = respects-surjection surj where surj : A Γ— B β†  B surj = record { logical-equivalence = record { to = projβ‚‚ ; from = Ξ» x β†’ inhabited , x } ; right-inverse-of = refl } ------------------------------------------------------------------------ -- Logical equivalences, split surjections and bijections -- H-levelΒ n is closed under the type formers _⇔_, _β† _ and _↔_ -- (assuming extensionality). ⇔-closure : βˆ€ {a b} {A : Type a} {B : Type b} β†’ Extensionality (a βŠ” b) (a βŠ” b) β†’ βˆ€ n β†’ H-level n A β†’ H-level n B β†’ H-level n (A ⇔ B) ⇔-closure {a} {b} ext n hA hB = respects-surjection (record { logical-equivalence = record { to = _ ; from = Ξ» A⇔B β†’ _⇔_.to A⇔B , _⇔_.from A⇔B } ; right-inverse-of = Ξ» _ β†’ refl _ }) n (Γ—-closure n (Ξ -closure (lower-extensionality b a ext) n (Ξ» _ β†’ hB)) (Ξ -closure (lower-extensionality a b ext) n (Ξ» _ β†’ hA))) β† -closure : βˆ€ {a b} {A : Type a} {B : Type b} β†’ Extensionality (a βŠ” b) (a βŠ” b) β†’ βˆ€ n β†’ H-level n A β†’ H-level n B β†’ H-level n (A β†  B) β† -closure {a} {b} ext n hA hB = respects-surjection (record { logical-equivalence = record { to = _ ; from = Ξ» Aβ† B β†’ _β† _.logical-equivalence Aβ† B , _β† _.right-inverse-of Aβ† B } ; right-inverse-of = Ξ» _ β†’ refl _ }) n (Ξ£-closure n (⇔-closure ext n hA hB) Ξ» _ β†’ Ξ -closure (lower-extensionality a a ext) n Ξ» _ β†’ ⇒≑ _ hB) ↔-closure : βˆ€ {a b} {A : Type a} {B : Type b} β†’ Extensionality (a βŠ” b) (a βŠ” b) β†’ βˆ€ n β†’ H-level n A β†’ H-level n B β†’ H-level n (A ↔ B) ↔-closure {a} {b} ext n hA hB = respects-surjection (record { logical-equivalence = record { to = _ ; from = Ξ» A↔B β†’ _↔_.surjection A↔B , _↔_.left-inverse-of A↔B } ; right-inverse-of = Ξ» _ β†’ refl _ }) n (Ξ£-closure n (β† -closure ext n hA hB) Ξ» _ β†’ Ξ -closure (lower-extensionality b b ext) n Ξ» _ β†’ ⇒≑ _ hA) ------------------------------------------------------------------------ -- Lifted types -- All H-levels are closed under lifting. ↑-closure : βˆ€ {a b} {A : Type a} n β†’ H-level n A β†’ H-level n (↑ b A) ↑-closure = respects-surjection (_↔_.surjection (Bijection.inverse ↑↔)) -- All H-levels are also closed under removal of lifting. ↑⁻¹-closure : βˆ€ {a b} {A : Type a} n β†’ H-level n (↑ b A) β†’ H-level n A ↑⁻¹-closure = respects-surjection (_↔_.surjection ↑↔) ------------------------------------------------------------------------ -- W-types -- W-types are isomorphic to Ξ£-types containing W-types. W-unfolding : βˆ€ {a b} {A : Type a} {B : A β†’ Type b} β†’ W A B ↔ βˆƒ Ξ» (x : A) β†’ B x β†’ W A B W-unfolding = record { surjection = record { logical-equivalence = record { to = Ξ» w β†’ headα΅‚ w , tailα΅‚ w ; from = uncurry sup } ; right-inverse-of = refl } ; left-inverse-of = left-inverse-of } where left-inverse-of : (w : W _ _) β†’ sup (headα΅‚ w) (tailα΅‚ w) ≑ w left-inverse-of (sup x f) = refl (sup x f) abstract -- Equality between elements of a W-type can be proved using a pair -- of equalities (assuming extensionality). W-≑,≑↠≑ : βˆ€ {a b} {A : Type a} {B : A β†’ Type b} β†’ Extensionality b (a βŠ” b) β†’ βˆ€ {x y} {f : B x β†’ W A B} {g : B y β†’ W A B} β†’ (βˆƒ Ξ» (p : x ≑ y) β†’ βˆ€ i β†’ f i ≑ g (subst B p i)) β†  (sup x f ≑ sup y g) W-≑,≑↠≑ {a} {A = A} {B} ext {x} {y} {f} {g} = (βˆƒ Ξ» (p : x ≑ y) β†’ βˆ€ i β†’ f i ≑ g (subst B p i)) β† βŸ¨ Surjection.βˆƒ-cong lemma ⟩ (βˆƒ Ξ» (p : x ≑ y) β†’ subst (Ξ» x β†’ B x β†’ W A B) p f ≑ g) β† βŸ¨ _↔_.surjection Ξ£-≑,≑↔≑ ⟩ (_≑_ {A = βˆƒ Ξ» (x : A) β†’ B x β†’ W A B} (x , f) (y , g)) β† βŸ¨ β† -≑ (_↔_.surjection (Bijection.inverse (W-unfolding {A = A} {B = B}))) βŸ©β–‘ (sup x f ≑ sup y g) β–‘ where lemma : (p : x ≑ y) β†’ (βˆ€ i β†’ f i ≑ g (subst B p i)) β†  (subst (Ξ» x β†’ B x β†’ W A B) p f ≑ g) lemma p = elim (Ξ» {x y} p β†’ (f : B x β†’ W A B) (g : B y β†’ W A B) β†’ (βˆ€ i β†’ f i ≑ g (subst B p i)) β†  (subst (Ξ» x β†’ B x β†’ W A B) p f ≑ g)) (Ξ» x f g β†’ (βˆ€ i β†’ f i ≑ g (subst B (refl x) i)) β† βŸ¨ subst (Ξ» h β†’ (βˆ€ i β†’ f i ≑ g (h i)) β†  (βˆ€ i β†’ f i ≑ g i)) (sym (apply-ext (lower-extensionality lzero a ext) (subst-refl B))) Surjection.id ⟩ (βˆ€ i β†’ f i ≑ g i) β† βŸ¨ ext-surj ext ⟩ (f ≑ g) β† βŸ¨ subst (Ξ» h β†’ (f ≑ g) β†  (h ≑ g)) (sym $ subst-refl (Ξ» x' β†’ B x' β†’ W A B) f) Surjection.id βŸ©β–‘ (subst (Ξ» x β†’ B x β†’ W A B) (refl x) f ≑ g) β–‘) p f g -- H-level is not closed under W. Β¬-W-closure-contractible : βˆ€ {a b} β†’ Β¬ (βˆ€ {A : Type a} {B : A β†’ Type b} β†’ Contractible A β†’ (βˆ€ x β†’ Contractible (B x)) β†’ Contractible (W A B)) Β¬-W-closure-contractible closure = inhabitedβ‡’W-empty (const (lift tt)) $ proj₁ $ closure (↑-closure 0 ⊀-contractible) (const (↑-closure 0 ⊀-contractible)) Β¬-W-closure : βˆ€ {a b} β†’ Β¬ (βˆ€ {A : Type a} {B : A β†’ Type b} n β†’ H-level n A β†’ (βˆ€ x β†’ H-level n (B x)) β†’ H-level n (W A B)) Β¬-W-closure closure = Β¬-W-closure-contractible (closure 0) -- However, all positive h-levels are closed under W (assuming -- extensionality). W-closureβ€² : βˆ€ {a b} {A : Type a} {B : A β†’ Type b} β†’ Extensionality b (a βŠ” b) β†’ βˆ€ n β†’ H-levelβ€² (1 + n) A β†’ H-levelβ€² (1 + n) (W A B) W-closureβ€² {A = A} {B} ext n h = closure where closure : (x y : W A B) β†’ H-levelβ€² n (x ≑ y) closure (sup x f) (sup y g) = respects-surjectionβ€² (W-≑,≑↠≑ ext) n $ Ξ£-closureβ€² n (h x y) (Ξ» _ β†’ Ξ -closureβ€² ext n (Ξ» i β†’ closure (f _) (g _))) W-closure : βˆ€ {a b} {A : Type a} {B : A β†’ Type b} β†’ Extensionality b (a βŠ” b) β†’ βˆ€ n β†’ H-level (1 + n) A β†’ H-level (1 + n) (W A B) W-closure ext n h = _⇔_.from H-level⇔H-levelβ€² (W-closureβ€² ext n (_⇔_.to H-level⇔H-levelβ€² h)) ------------------------------------------------------------------------ -- H-levels abstract -- Contractible is /not/ a comonad in the category of types and -- functions, because map cannot be defined, but we can at least -- define the following functions. counit : βˆ€ {a} {A : Type a} β†’ Contractible A β†’ A counit = proj₁ cojoin : βˆ€ {a} {A : Type a} β†’ Extensionality a a β†’ Contractible A β†’ Contractible (Contractible A) cojoin {A = A} ext contr = contr₃ where x : A x = proj₁ contr contr₁ : Contractible (βˆ€ y β†’ x ≑ y) contr₁ = Ξ -closureβ€² ext 0 (mono₁′ 0 contr x) contrβ‚‚ : (x : A) β†’ Contractible (βˆ€ y β†’ x ≑ y) contrβ‚‚ x = subst (Ξ» x β†’ Contractible (βˆ€ y β†’ x ≑ y)) (projβ‚‚ contr x) contr₁ contr₃ : Contractible (βˆƒ Ξ» (x : A) β†’ βˆ€ y β†’ x ≑ y) contr₃ = Ξ£-closure 0 contr contrβ‚‚ -- Contractible is not necessarily contractible. Β¬-Contractible-contractible : Β¬ ({A : Type} β†’ Contractible (Contractible A)) Β¬-Contractible-contractible contr = proj₁ $ proj₁ $ contr {A = βŠ₯} -- Contractible is propositional (assuming extensionality). Contractible-propositional : βˆ€ {a} {A : Type a} β†’ Extensionality a a β†’ Is-proposition (Contractible A) Contractible-propositional ext = [inhabitedβ‡’contractible]β‡’propositional (cojoin ext) -- H-levelβ€² is closed under λ PΒ β†’Β For-iterated-equalityΒ nΒ PΒ A. H-levelβ€²-For-iterated-equality : βˆ€ {p A} {P : Type p β†’ Type p} β†’ Extensionality p p β†’ βˆ€ m n β†’ (βˆ€ {A} β†’ H-levelβ€² m (P A)) β†’ H-levelβ€² m (For-iterated-equality n P A) H-levelβ€²-For-iterated-equality ext m zero hyp = hyp H-levelβ€²-For-iterated-equality ext m (suc n) hyp = Ξ -closureβ€² ext m Ξ» _ β†’ Ξ -closureβ€² ext m Ξ» _ β†’ H-levelβ€²-For-iterated-equality ext m n hyp -- A variant of the previous result. H-levelβ€²-For-iterated-equalityβ€² : βˆ€ {p A} {P : Type p β†’ Type p} β†’ Extensionality p p β†’ βˆ€ m n {o} β†’ H-levelβ€² (n + o) A β†’ (βˆ€ {A} β†’ H-levelβ€² o A β†’ H-levelβ€² m (P A)) β†’ H-levelβ€² m (For-iterated-equality n P A) H-levelβ€²-For-iterated-equalityβ€² ext m zero hyp₁ hypβ‚‚ = hypβ‚‚ hyp₁ H-levelβ€²-For-iterated-equalityβ€² ext m (suc n) hyp₁ hypβ‚‚ = Ξ -closureβ€² ext m Ξ» _ β†’ Ξ -closureβ€² ext m Ξ» _ β†’ H-levelβ€²-For-iterated-equalityβ€² ext m n (hyp₁ _ _) hypβ‚‚ -- H-level is closed under λ PΒ β†’Β For-iterated-equalityΒ nΒ PΒ A. H-level-For-iterated-equality : βˆ€ {p A} {P : Type p β†’ Type p} β†’ Extensionality p p β†’ βˆ€ m n β†’ (βˆ€ {A} β†’ H-level m (P A)) β†’ H-level m (For-iterated-equality n P A) H-level-For-iterated-equality ext m n hyp = _⇔_.from H-level⇔H-levelβ€² $ H-levelβ€²-For-iterated-equality ext m n $ _⇔_.to H-level⇔H-levelβ€² hyp -- A variant of the previous result. H-level-For-iterated-equalityβ€² : βˆ€ {p A} {P : Type p β†’ Type p} β†’ Extensionality p p β†’ βˆ€ m n {o} β†’ H-level (n + o) A β†’ (βˆ€ {A} β†’ H-level o A β†’ H-level m (P A)) β†’ H-level m (For-iterated-equality n P A) H-level-For-iterated-equalityβ€² ext m n hyp₁ hypβ‚‚ = _⇔_.from (H-level⇔H-levelβ€² {n = m}) $ H-levelβ€²-For-iterated-equalityβ€² ext m n (_⇔_.to H-level⇔H-levelβ€² hyp₁) (_⇔_.to H-level⇔H-levelβ€² ∘ hypβ‚‚ ∘ _⇔_.from H-level⇔H-levelβ€²) -- H-levelβ€² is pointwise propositional (assuming extensionality). H-levelβ€²-propositional : βˆ€ {a} β†’ Extensionality a a β†’ βˆ€ {A : Type a} n β†’ Is-proposition (H-levelβ€² n A) H-levelβ€²-propositional ext n = _⇔_.from (H-level⇔H-levelβ€² {n = 1}) $ H-levelβ€²-For-iterated-equality ext 1 n $ _⇔_.to (H-level⇔H-levelβ€² {n = 1}) $ Contractible-propositional ext -- The property Is-propositionΒ A is a proposition (assuming -- extensionality). -- -- This result is proved in the HoTT book (first edition, -- LemmaΒ 3.3.5). Is-proposition-propositional : βˆ€ {a} {A : Type a} β†’ Extensionality a a β†’ Is-proposition (Is-proposition A) Is-proposition-propositional ext = [inhabitedβ‡’+]β‡’+ 0 Ξ» p β†’ Ξ -closure ext 1 Ξ» _ β†’ Ξ -closure ext 1 Ξ» _ β†’ ⇒≑ 1 p -- All h-levels are propositional (assuming extensionality). H-level-propositional : βˆ€ {a} β†’ Extensionality a a β†’ βˆ€ {A : Type a} n β†’ Is-proposition (H-level n A) H-level-propositional ext zero = Contractible-propositional ext H-level-propositional ext (suc zero) = Is-proposition-propositional ext H-level-propositional {A} ext (suc (suc n)) = implicit-Ξ -closure ext 1 Ξ» x β†’ implicit-Ξ -closure ext 1 Ξ» y β†’ H-level-propositional ext {A = x ≑ y} (suc n) -- Uniqueness-of-identity-proofs is pointwise propositional -- (assuming extensionality). UIP-propositional : βˆ€ {β„“} β†’ Extensionality (lsuc β„“) β„“ β†’ Is-proposition (Uniqueness-of-identity-proofs β„“) UIP-propositional ext = implicit-Ξ -closure ext 1 Ξ» A β†’ H-level-propositional (lower-extensionality _ lzero ext) 2 ------------------------------------------------------------------------ -- Binary sums abstract -- Binary sums can be expressed using Ξ£ and Bool (with large -- elimination). sum-as-pair : βˆ€ {a b} {A : Type a} {B : Type b} β†’ (A ⊎ B) ↔ (βˆƒ Ξ» (x : Bool) β†’ if x then ↑ b A else ↑ a B) sum-as-pair {a} {b} {A} {B} = record { surjection = record { logical-equivalence = record { to = to ; from = from } ; right-inverse-of = to∘from } ; left-inverse-of = [ refl ∘ inj₁ {B = B} , refl ∘ injβ‚‚ {A = A} ] } where to : A ⊎ B β†’ (βˆƒ Ξ» (x : Bool) β†’ if x then ↑ b A else ↑ a B) to = [ _,_ true ∘ lift , _,_ false ∘ lift ] from : (βˆƒ Ξ» (x : Bool) β†’ if x then ↑ b A else ↑ a B) β†’ A ⊎ B from (true , x) = inj₁ $ lower x from (false , y) = injβ‚‚ $ lower y to∘from : (y : βˆƒ Ξ» x β†’ if x then ↑ b A else ↑ a B) β†’ to (from y) ≑ y to∘from (true , x) = refl _ to∘from (false , y) = refl _ -- H-level is not closed under _⊎_. Β¬-⊎-propositional : βˆ€ {a b} {A : Type a} {B : Type b} β†’ A β†’ B β†’ Β¬ Is-proposition (A ⊎ B) Β¬-⊎-propositional x y hA⊎B = ⊎.inj₁≒injβ‚‚ $ hA⊎B (inj₁ x) (injβ‚‚ y) Β¬-⊎-closure : βˆ€ {a b} β†’ Β¬ (βˆ€ {A : Type a} {B : Type b} n β†’ H-level n A β†’ H-level n B β†’ H-level n (A ⊎ B)) Β¬-⊎-closure ⊎-closure = Β¬-⊎-propositional (lift tt) (lift tt) $ mono₁ 0 $ ⊎-closure 0 (↑-closure 0 ⊀-contractible) (↑-closure 0 ⊀-contractible) -- However, all levels greater than or equal to 2 are closed under -- _⊎_. ⊎-closure : βˆ€ {a b} {A : Type a} {B : Type b} n β†’ H-level (2 + n) A β†’ H-level (2 + n) B β†’ H-level (2 + n) (A ⊎ B) ⊎-closure {a} {b} {A} {B} n hA hB = respects-surjection (_↔_.surjection $ Bijection.inverse sum-as-pair) (2 + n) (Ξ£-closure (2 + n) Bool-2+n if-2+n) where Bool-2+n : H-level (2 + n) Bool Bool-2+n = mono (m≀m+n 2 n) Bool-set if-2+n : (x : Bool) β†’ H-level (2 + n) (if x then ↑ b A else ↑ a B) if-2+n true = respects-surjection (_↔_.surjection $ Bijection.inverse ↑↔) (2 + n) hA if-2+n false = respects-surjection (_↔_.surjection $ Bijection.inverse ↑↔) (2 + n) hB -- Furthermore, if A and B are propositions and mutually exclusive, -- then A ⊎ B is a proposition. ⊎-closure-propositional : βˆ€ {a b} {A : Type a} {B : Type b} β†’ (A β†’ B β†’ βŠ₯β‚€) β†’ Is-proposition A β†’ Is-proposition B β†’ Is-proposition (A ⊎ B) ⊎-closure-propositional Aβ†’Bβ†’βŠ₯ A-prop B-prop = Ξ» where (inj₁ a₁) (inj₁ aβ‚‚) β†’ cong inj₁ (A-prop a₁ aβ‚‚) (inj₁ a₁) (injβ‚‚ bβ‚‚) β†’ βŠ₯-elim (Aβ†’Bβ†’βŠ₯ a₁ bβ‚‚) (injβ‚‚ b₁) (inj₁ aβ‚‚) β†’ βŠ₯-elim (Aβ†’Bβ†’βŠ₯ aβ‚‚ b₁) (injβ‚‚ b₁) (injβ‚‚ bβ‚‚) β†’ cong injβ‚‚ (B-prop b₁ bβ‚‚) -- All levels greater than or equal to 2 are also closed under -- Maybe. Maybe-closure : βˆ€ {a} {A : Type a} n β†’ H-level (2 + n) A β†’ H-level (2 + n) (Maybe A) Maybe-closure n h = ⊎-closure n (mono (zero≀ (2 + n)) ⊀-contractible) h -- T is pointwise propositional. T-propositional : βˆ€ {a b} {A : Type a} {B : Type b} β†’ (x : A ⊎ B) β†’ Is-proposition (T x) T-propositional (inj₁ _) = mono₁ 0 ⊀-contractible T-propositional (injβ‚‚ _) = βŠ₯-propositional -- Furthermore Is-proposition is closed under Dec (assuming -- extensionality). Dec-closure-propositional : βˆ€ {a} {A : Type a} β†’ Extensionality a lzero β†’ Is-proposition A β†’ Is-proposition (Dec A) Dec-closure-propositional {A = A} ext p = Ξ» where (yes a) (yes aβ€²) β†’ cong yes $ p a aβ€² (yes a) (no Β¬a) β†’ βŠ₯-elim (Β¬a a) (no Β¬a) (yes a) β†’ βŠ₯-elim (Β¬a a) (no Β¬a) (no Β¬aβ€²) β†’ cong no $ Β¬-propositional ext Β¬a Β¬aβ€² -- Is-proposition is also closed under _Xor_ (assuming -- extensionality). Xor-closure-propositional : βˆ€ {a b} {A : Type a} {B : Type b} β†’ Extensionality (a βŠ” b) (# 0) β†’ Is-proposition A β†’ Is-proposition B β†’ Is-proposition (A Xor B) Xor-closure-propositional {β„“a} {β„“b} {A} {B} ext pA pB = Ξ» where (inj₁ (a , Β¬b)) (injβ‚‚ (Β¬a , b)) β†’ βŠ₯-elim (Β¬a a) (injβ‚‚ (Β¬a , b)) (inj₁ (a , Β¬b)) β†’ βŠ₯-elim (Β¬b b) (inj₁ (a , Β¬b)) (inj₁ (aβ€² , Β¬bβ€²)) β†’ congβ‚‚ (Ξ» x y β†’ inj₁ (x , y)) (pA a aβ€²) (apply-ext (lower-extensionality β„“a _ ext) Ξ» b β†’ βŠ₯-elim (Β¬b b)) (injβ‚‚ (Β¬a , b)) (injβ‚‚ (Β¬aβ€² , bβ€²)) β†’ congβ‚‚ (Ξ» x y β†’ injβ‚‚ (x , y)) (apply-ext (lower-extensionality β„“b _ ext) Ξ» a β†’ βŠ₯-elim (Β¬a a)) (pB b bβ€²) -- However, H-level is not closed under _Xor_. Β¬-Xor-closure-contractible : βˆ€ {a b} β†’ Β¬ ({A : Type a} {B : Type b} β†’ Contractible A β†’ Contractible B β†’ Contractible (A Xor B)) Β¬-Xor-closure-contractible closure with proj₁ $ closure (↑-closure 0 ⊀-contractible) (↑-closure 0 ⊀-contractible) ... | inj₁ (_ , ¬⊀) = ¬⊀ _ ... | injβ‚‚ (¬⊀ , _) = ¬⊀ _ -- Alternative definition of ⊎-closure (for Typeβ‚€). module Alternative-proof where -- Is-set is closed under _⊎_, by an argument similar to the one -- Hedberg used to prove that decidable equality implies -- uniqueness of identity proofs. ⊎-closure-set : {A B : Type} β†’ Is-set A β†’ Is-set B β†’ Is-set (A ⊎ B) ⊎-closure-set {A} {B} A-set B-set = DUIP.constantβ‡’set c where c : (x y : A ⊎ B) β†’ βˆƒ Ξ» (f : x ≑ y β†’ x ≑ y) β†’ DUIP.Constant f c (inj₁ x) (inj₁ y) = (cong inj₁ ∘ ⊎.cancel-inj₁ , Ξ» p q β†’ cong (cong inj₁) $ A-set (⊎.cancel-inj₁ p) (⊎.cancel-inj₁ q)) c (injβ‚‚ x) (injβ‚‚ y) = (cong injβ‚‚ ∘ ⊎.cancel-injβ‚‚ , Ξ» p q β†’ cong (cong injβ‚‚) $ B-set (⊎.cancel-injβ‚‚ p) (⊎.cancel-injβ‚‚ q)) c (inj₁ x) (injβ‚‚ y) = (βŠ₯-elim ∘ ⊎.inj₁≒injβ‚‚ , Ξ» _ β†’ βŠ₯-elim ∘ ⊎.inj₁≒injβ‚‚) c (injβ‚‚ x) (inj₁ y) = (βŠ₯-elim ∘ ⊎.inj₁≒injβ‚‚ ∘ sym , Ξ» _ β†’ βŠ₯-elim ∘ ⊎.inj₁≒injβ‚‚ ∘ sym) -- H-level is closed under _⊎_ for other levels greater than or equal -- to 2 too. ⊎-closureβ€² : βˆ€ {A B : Type} n β†’ H-level (2 + n) A β†’ H-level (2 + n) B β†’ H-level (2 + n) (A ⊎ B) ⊎-closureβ€² zero = ⊎-closure-set ⊎-closureβ€² {A} {B} (suc n) = clos where clos : H-level (3 + n) A β†’ H-level (3 + n) B β†’ H-level (3 + n) (A ⊎ B) clos hA hB {x = inj₁ x} {y = inj₁ y} = respects-surjection (_↔_.surjection ≑↔inj₁≑inj₁) (2 + n) hA clos hA hB {x = injβ‚‚ x} {y = injβ‚‚ y} = respects-surjection (_↔_.surjection ≑↔inj₂≑injβ‚‚) (2 + n) hB clos hA hB {x = inj₁ x} {y = injβ‚‚ y} {x = p} = βŠ₯-elim (⊎.inj₁≒injβ‚‚ p) clos hA hB {x = injβ‚‚ x} {y = inj₁ y} {x = p} = βŠ₯-elim (⊎.inj₁≒injβ‚‚ (sym p))
lemma prime_factorization_exists_nat: "n > 0 \<Longrightarrow> (\<exists>M. (\<forall>p::nat \<in> set_mset M. prime p) \<and> n = (\<Prod>i \<in># M. i))"
theory Nondeterminism imports Main begin inductive foreach :: "('b \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'b set \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> bool" for f where empty: "foreach f {} a a" | insert: "foreach f S a\<^sub>0 a\<^sub>1 \<Longrightarrow> x \<notin> S \<Longrightarrow> f x a\<^sub>1 a\<^sub>2 \<Longrightarrow> foreach f (insert x S) a\<^sub>0 a\<^sub>2" declare foreach.intros[intro] declare foreach.cases[elim] lemma foreach_mono: assumes "\<And> x a\<^sub>0 a\<^sub>1. f\<^sub>1 x a\<^sub>0 a\<^sub>1 \<Longrightarrow> f\<^sub>2 x a\<^sub>0 a\<^sub>1" assumes "foreach f\<^sub>1 S a\<^sub>0 a\<^sub>1" shows "foreach f\<^sub>2 S a\<^sub>0 a\<^sub>1" using assms(2, 1) by induct auto lemma foreach_mono_inductive[mono]: assumes "\<And> x a\<^sub>0 a\<^sub>1. f\<^sub>1 x a\<^sub>0 a\<^sub>1 \<longrightarrow> f\<^sub>2 x a\<^sub>0 a\<^sub>1" shows "foreach f\<^sub>1 S a\<^sub>0 a\<^sub>1 \<longrightarrow> foreach f\<^sub>2 S a\<^sub>0 a\<^sub>1" using foreach_mono assms by metis inductive foreachc :: "('a \<Rightarrow> bool) \<Rightarrow> ('b \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'b set \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> bool" ("foreach\<^sub>C") for c f where empty: "foreach\<^sub>C c f {} a a" | insert: "foreach\<^sub>C c f S a\<^sub>0 a\<^sub>1 \<Longrightarrow> c a\<^sub>1 \<Longrightarrow> x \<notin> S \<Longrightarrow> f x a\<^sub>1 a\<^sub>2 \<Longrightarrow> foreach\<^sub>C c f (insert x S) a\<^sub>0 a\<^sub>2" | abort: "foreach\<^sub>C c f S a\<^sub>0 a\<^sub>1 \<Longrightarrow> \<not> c a\<^sub>1 \<Longrightarrow> S \<subseteq> S' \<Longrightarrow> foreach\<^sub>C c f S' a\<^sub>0 a\<^sub>1" declare foreachc.intros[intro] declare foreachc.cases[elim] lemma foreachc_mono: assumes "\<And> x a\<^sub>0 a\<^sub>1. f\<^sub>1 x a\<^sub>0 a\<^sub>1 \<Longrightarrow> f\<^sub>2 x a\<^sub>0 a\<^sub>1" assumes "foreach\<^sub>C c f\<^sub>1 S a\<^sub>0 a\<^sub>1" shows "foreach\<^sub>C c f\<^sub>2 S a\<^sub>0 a\<^sub>1" using assms(2, 1) by induct auto lemma foreachc_mono_inductive[mono]: assumes "\<And> x a\<^sub>0 a\<^sub>1. f\<^sub>1 x a\<^sub>0 a\<^sub>1 \<longrightarrow> f\<^sub>2 x a\<^sub>0 a\<^sub>1" shows "foreach\<^sub>C c f\<^sub>1 S a\<^sub>0 a\<^sub>1 \<longrightarrow> foreach\<^sub>C c f\<^sub>2 S a\<^sub>0 a\<^sub>1" using assms foreachc_mono by metis lemma foreachc_reflexive_transitive: assumes "reflp r" "transp r" assumes "foreach\<^sub>C c f S a\<^sub>1 a\<^sub>2" assumes "\<And> x a\<^sub>1 a\<^sub>2. x \<in> S \<Longrightarrow> f x a\<^sub>1 a\<^sub>2 \<Longrightarrow> r a\<^sub>1 a\<^sub>2" shows "r a\<^sub>1 a\<^sub>2" using assms(3, 4) proof induct case (empty a) show ?case using reflpD assms(1) by this next case (insert S a\<^sub>0 a\<^sub>1 x a\<^sub>2) have 0: "r a\<^sub>0 a\<^sub>1" using insert(2) insert(6) by auto have 1: "r a\<^sub>1 a\<^sub>2" using insert(6) insert(5) by auto show ?case using transpD assms(2) 0 1 by this next case (abort S a\<^sub>0 a\<^sub>1 S') have 0: "r a\<^sub>0 a\<^sub>1" using abort(2) abort(4) abort(5) by auto show ?case using 0 by this qed lemma foreachc_preorder: fixes g :: "'a \<Rightarrow> 'b :: preorder" assumes "foreach\<^sub>C c f S a\<^sub>1 a\<^sub>2" assumes "\<And> x a\<^sub>1 a\<^sub>2. x \<in> S \<Longrightarrow> f x a\<^sub>1 a\<^sub>2 \<Longrightarrow> g a\<^sub>1 \<le> g a\<^sub>2" shows "g a\<^sub>1 \<le> g a\<^sub>2" proof - have 0: "reflp (\<lambda> a\<^sub>1 a\<^sub>2. g a\<^sub>1 \<le> g a\<^sub>2)" by (rule reflpI, rule order_refl) have 1: "transp (\<lambda> a\<^sub>1 a\<^sub>2. g a\<^sub>1 \<le> g a\<^sub>2)" by (rule transpI, rule order_trans) show ?thesis using foreachc_reflexive_transitive 0 1 assms by this qed lemma foreachc_equality: assumes "foreach\<^sub>C c f S a\<^sub>1 a\<^sub>2" assumes "\<And> x a\<^sub>1 a\<^sub>2. x \<in> S \<Longrightarrow> f x a\<^sub>1 a\<^sub>2 \<Longrightarrow> g a\<^sub>1 = g a\<^sub>2" shows "g a\<^sub>1 = g a\<^sub>2" proof - have 0: "reflp (\<lambda> a\<^sub>1 a\<^sub>2. g a\<^sub>1 = g a\<^sub>2)" by (rule reflpI, auto) have 1: "transp (\<lambda> a\<^sub>1 a\<^sub>2. g a\<^sub>1 = g a\<^sub>2)" by (rule transpI, auto) show "g a\<^sub>1 = g a\<^sub>2" using foreachc_reflexive_transitive 0 1 assms by this qed lemma foreachc_implication: assumes "foreach\<^sub>C c f S a\<^sub>1 a\<^sub>2" assumes "\<And> x a\<^sub>1 a\<^sub>2. x \<in> S \<Longrightarrow> f x a\<^sub>1 a\<^sub>2 \<Longrightarrow> P a\<^sub>1 \<Longrightarrow> P a\<^sub>2" shows "P a\<^sub>1 \<Longrightarrow> P a\<^sub>2" proof - have 0: "reflp (\<lambda> a\<^sub>1 a\<^sub>2. P a\<^sub>1 \<longrightarrow> P a\<^sub>2)" by (rule reflpI, auto) have 1: "transp (\<lambda> a\<^sub>1 a\<^sub>2. P a\<^sub>1 \<longrightarrow> P a\<^sub>2)" by (rule transpI, auto) show "P a\<^sub>1 \<Longrightarrow> P a\<^sub>2" using foreachc_reflexive_transitive[OF 0 1] assms by blast qed lemma foreachc_success: assumes "foreach\<^sub>C c f S a\<^sub>0 a\<^sub>1" assumes "c a\<^sub>1" shows "foreach f S a\<^sub>0 a\<^sub>1" using assms by induct auto fun find :: "'a set \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> 'a option \<Rightarrow> bool" where "find A P None \<longleftrightarrow> (\<forall> a \<in> A. \<not> P a)" | "find A P (Some a) \<longleftrightarrow> a \<in> A \<and> P a" end
[GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ ⊒ βˆƒ s, MeasurableSet s ∧ (βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t) ∧ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] let d : Set Ξ± β†’ ℝ := fun s => ((ΞΌ s).toNNReal : ℝ) - (Ξ½ s).toNNReal [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) ⊒ βˆƒ s, MeasurableSet s ∧ (βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t) ∧ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] let c : Set ℝ := d '' {s | MeasurableSet s} [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} ⊒ βˆƒ s, MeasurableSet s ∧ (βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t) ∧ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] let Ξ³ : ℝ := sSup c [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c ⊒ βˆƒ s, MeasurableSet s ∧ (βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t) ∧ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] have hΞΌ : βˆ€ s, ΞΌ s β‰  ∞ := measure_ne_top ΞΌ [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ ⊒ βˆƒ s, MeasurableSet s ∧ (βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t) ∧ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] have hΞ½ : βˆ€ s, Ξ½ s β‰  ∞ := measure_ne_top Ξ½ [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ ⊒ βˆƒ s, MeasurableSet s ∧ (βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t) ∧ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] have to_nnreal_ΞΌ : βˆ€ s, ((ΞΌ s).toNNReal : ℝβ‰₯0∞) = ΞΌ s := fun s => ENNReal.coe_toNNReal <| hΞΌ _ [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s ⊒ βˆƒ s, MeasurableSet s ∧ (βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t) ∧ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] have to_nnreal_Ξ½ : βˆ€ s, ((Ξ½ s).toNNReal : ℝβ‰₯0∞) = Ξ½ s := fun s => ENNReal.coe_toNNReal <| hΞ½ _ [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s ⊒ βˆƒ s, MeasurableSet s ∧ (βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t) ∧ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] have d_split : βˆ€ s t, MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) := by intro s t _hs ht dsimp only rw [← measure_inter_add_diff s ht, ← measure_inter_add_diff s ht, ENNReal.toNNReal_add (hΞΌ _) (hΞΌ _), ENNReal.toNNReal_add (hΞ½ _) (hΞ½ _), NNReal.coe_add, NNReal.coe_add] simp only [sub_eq_add_neg, neg_add] abel [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s ⊒ βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) [PROOFSTEP] intro s t _hs ht [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s s t : Set Ξ± _hs : MeasurableSet s ht : MeasurableSet t ⊒ d s = d (s \ t) + d (s ∩ t) [PROOFSTEP] dsimp only [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s s t : Set Ξ± _hs : MeasurableSet s ht : MeasurableSet t ⊒ ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) = ↑(ENNReal.toNNReal (↑↑μ (s \ t))) - ↑(ENNReal.toNNReal (↑↑ν (s \ t))) + (↑(ENNReal.toNNReal (↑↑μ (s ∩ t))) - ↑(ENNReal.toNNReal (↑↑ν (s ∩ t)))) [PROOFSTEP] rw [← measure_inter_add_diff s ht, ← measure_inter_add_diff s ht, ENNReal.toNNReal_add (hΞΌ _) (hΞΌ _), ENNReal.toNNReal_add (hΞ½ _) (hΞ½ _), NNReal.coe_add, NNReal.coe_add] [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s s t : Set Ξ± _hs : MeasurableSet s ht : MeasurableSet t ⊒ ↑(ENNReal.toNNReal (↑↑μ (s ∩ t))) + ↑(ENNReal.toNNReal (↑↑μ (s \ t))) - (↑(ENNReal.toNNReal (↑↑ν (s ∩ t))) + ↑(ENNReal.toNNReal (↑↑ν (s \ t)))) = ↑(ENNReal.toNNReal (↑↑μ (s \ t))) - ↑(ENNReal.toNNReal (↑↑ν (s \ t))) + (↑(ENNReal.toNNReal (↑↑μ (s ∩ t))) - ↑(ENNReal.toNNReal (↑↑ν (s ∩ t)))) [PROOFSTEP] simp only [sub_eq_add_neg, neg_add] [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s s t : Set Ξ± _hs : MeasurableSet s ht : MeasurableSet t ⊒ ↑(ENNReal.toNNReal (↑↑μ (s ∩ t))) + ↑(ENNReal.toNNReal (↑↑μ (s \ t))) + (-↑(ENNReal.toNNReal (↑↑ν (s ∩ t))) + -↑(ENNReal.toNNReal (↑↑ν (s \ t)))) = ↑(ENNReal.toNNReal (↑↑μ (s \ t))) + -↑(ENNReal.toNNReal (↑↑ν (s \ t))) + (↑(ENNReal.toNNReal (↑↑μ (s ∩ t))) + -↑(ENNReal.toNNReal (↑↑ν (s ∩ t)))) [PROOFSTEP] abel [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s s t : Set Ξ± _hs : MeasurableSet s ht : MeasurableSet t ⊒ ↑(ENNReal.toNNReal (↑↑μ (s ∩ t))) + ↑(ENNReal.toNNReal (↑↑μ (s \ t))) + (-↑(ENNReal.toNNReal (↑↑ν (s ∩ t))) + -↑(ENNReal.toNNReal (↑↑ν (s \ t)))) = ↑(ENNReal.toNNReal (↑↑μ (s \ t))) + -↑(ENNReal.toNNReal (↑↑ν (s \ t))) + (↑(ENNReal.toNNReal (↑↑μ (s ∩ t))) + -↑(ENNReal.toNNReal (↑↑ν (s ∩ t)))) [PROOFSTEP] abel [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) ⊒ βˆƒ s, MeasurableSet s ∧ (βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t) ∧ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] have d_Union : βˆ€ s : β„• β†’ Set Ξ±, Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ n, s n))) := by intro s hm refine' Tendsto.sub _ _ <;> refine' NNReal.tendsto_coe.2 <| (ENNReal.tendsto_toNNReal _).comp <| tendsto_measure_iUnion hm exact hΞΌ _ exact hΞ½ _ [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) ⊒ βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) [PROOFSTEP] intro s hm [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) s : β„• β†’ Set Ξ± hm : Monotone s ⊒ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) [PROOFSTEP] refine' Tendsto.sub _ _ [GOAL] case refine'_1 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) s : β„• β†’ Set Ξ± hm : Monotone s ⊒ Tendsto (fun n => ↑(ENNReal.toNNReal (↑↑μ (s n)))) atTop (𝓝 ↑(ENNReal.toNNReal (↑↑μ (⋃ (n : β„•), s n)))) [PROOFSTEP] refine' NNReal.tendsto_coe.2 <| (ENNReal.tendsto_toNNReal _).comp <| tendsto_measure_iUnion hm [GOAL] case refine'_2 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) s : β„• β†’ Set Ξ± hm : Monotone s ⊒ Tendsto (fun n => ↑(ENNReal.toNNReal (↑↑ν (s n)))) atTop (𝓝 ↑(ENNReal.toNNReal (↑↑ν (⋃ (n : β„•), s n)))) [PROOFSTEP] refine' NNReal.tendsto_coe.2 <| (ENNReal.tendsto_toNNReal _).comp <| tendsto_measure_iUnion hm [GOAL] case refine'_1 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) s : β„• β†’ Set Ξ± hm : Monotone s ⊒ ↑↑μ (⋃ (n : β„•), s n) β‰  ⊀ case refine'_2 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) s : β„• β†’ Set Ξ± hm : Monotone s ⊒ ↑↑ν (⋃ (n : β„•), s n) β‰  ⊀ [PROOFSTEP] exact hΞΌ _ [GOAL] case refine'_2 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) s : β„• β†’ Set Ξ± hm : Monotone s ⊒ ↑↑ν (⋃ (n : β„•), s n) β‰  ⊀ [PROOFSTEP] exact hΞ½ _ [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) ⊒ βˆƒ s, MeasurableSet s ∧ (βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t) ∧ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] have d_Inter : βˆ€ s : β„• β†’ Set Ξ±, (βˆ€ n, MeasurableSet (s n)) β†’ (βˆ€ n m, n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ n, s n))) := by intro s hs hm refine' Tendsto.sub _ _ <;> refine' NNReal.tendsto_coe.2 <| (ENNReal.tendsto_toNNReal <| _).comp <| tendsto_measure_iInter hs hm _ exacts [hΞΌ _, ⟨0, hΞΌ _⟩, hΞ½ _, ⟨0, hΞ½ _⟩] [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) ⊒ βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) [PROOFSTEP] intro s hs hm [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) s : β„• β†’ Set Ξ± hs : βˆ€ (n : β„•), MeasurableSet (s n) hm : βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n ⊒ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) [PROOFSTEP] refine' Tendsto.sub _ _ [GOAL] case refine'_1 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) s : β„• β†’ Set Ξ± hs : βˆ€ (n : β„•), MeasurableSet (s n) hm : βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n ⊒ Tendsto (fun n => ↑(ENNReal.toNNReal (↑↑μ (s n)))) atTop (𝓝 ↑(ENNReal.toNNReal (↑↑μ (β‹‚ (n : β„•), s n)))) [PROOFSTEP] refine' NNReal.tendsto_coe.2 <| (ENNReal.tendsto_toNNReal <| _).comp <| tendsto_measure_iInter hs hm _ [GOAL] case refine'_2 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) s : β„• β†’ Set Ξ± hs : βˆ€ (n : β„•), MeasurableSet (s n) hm : βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n ⊒ Tendsto (fun n => ↑(ENNReal.toNNReal (↑↑ν (s n)))) atTop (𝓝 ↑(ENNReal.toNNReal (↑↑ν (β‹‚ (n : β„•), s n)))) [PROOFSTEP] refine' NNReal.tendsto_coe.2 <| (ENNReal.tendsto_toNNReal <| _).comp <| tendsto_measure_iInter hs hm _ [GOAL] case refine'_1.refine'_1 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) s : β„• β†’ Set Ξ± hs : βˆ€ (n : β„•), MeasurableSet (s n) hm : βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n ⊒ ↑↑μ (β‹‚ (n : β„•), s n) β‰  ⊀ case refine'_1.refine'_2 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) s : β„• β†’ Set Ξ± hs : βˆ€ (n : β„•), MeasurableSet (s n) hm : βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n ⊒ βˆƒ i, ↑↑μ (s i) β‰  ⊀ case refine'_2.refine'_1 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) s : β„• β†’ Set Ξ± hs : βˆ€ (n : β„•), MeasurableSet (s n) hm : βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n ⊒ ↑↑ν (β‹‚ (n : β„•), s n) β‰  ⊀ case refine'_2.refine'_2 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) s : β„• β†’ Set Ξ± hs : βˆ€ (n : β„•), MeasurableSet (s n) hm : βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n ⊒ βˆƒ i, ↑↑ν (s i) β‰  ⊀ [PROOFSTEP] exacts [hΞΌ _, ⟨0, hΞΌ _⟩, hΞ½ _, ⟨0, hΞ½ _⟩] [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) ⊒ βˆƒ s, MeasurableSet s ∧ (βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t) ∧ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] have bdd_c : BddAbove c := by use(ΞΌ univ).toNNReal rintro r ⟨s, _hs, rfl⟩ refine' le_trans (sub_le_self _ <| NNReal.coe_nonneg _) _ rw [NNReal.coe_le_coe, ← ENNReal.coe_le_coe, to_nnreal_ΞΌ, to_nnreal_ΞΌ] exact measure_mono (subset_univ _) [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) ⊒ BddAbove c [PROOFSTEP] use(ΞΌ univ).toNNReal [GOAL] case h Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) ⊒ ↑(ENNReal.toNNReal (↑↑μ univ)) ∈ upperBounds c [PROOFSTEP] rintro r ⟨s, _hs, rfl⟩ [GOAL] case h.intro.intro Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) s : Set Ξ± _hs : s ∈ {s | MeasurableSet s} ⊒ d s ≀ ↑(ENNReal.toNNReal (↑↑μ univ)) [PROOFSTEP] refine' le_trans (sub_le_self _ <| NNReal.coe_nonneg _) _ [GOAL] case h.intro.intro Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) s : Set Ξ± _hs : s ∈ {s | MeasurableSet s} ⊒ ↑(ENNReal.toNNReal (↑↑μ s)) ≀ ↑(ENNReal.toNNReal (↑↑μ univ)) [PROOFSTEP] rw [NNReal.coe_le_coe, ← ENNReal.coe_le_coe, to_nnreal_ΞΌ, to_nnreal_ΞΌ] [GOAL] case h.intro.intro Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) s : Set Ξ± _hs : s ∈ {s | MeasurableSet s} ⊒ ↑↑μ s ≀ ↑↑μ univ [PROOFSTEP] exact measure_mono (subset_univ _) [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c ⊒ βˆƒ s, MeasurableSet s ∧ (βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t) ∧ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] have c_nonempty : c.Nonempty := Nonempty.image _ ⟨_, MeasurableSet.empty⟩ [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c ⊒ βˆƒ s, MeasurableSet s ∧ (βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t) ∧ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] have d_le_Ξ³ : βˆ€ s, MeasurableSet s β†’ d s ≀ Ξ³ := fun s hs => le_csSup bdd_c ⟨s, hs, rfl⟩ [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ ⊒ βˆƒ s, MeasurableSet s ∧ (βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t) ∧ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] have : βˆ€ n : β„•, βˆƒ s : Set Ξ±, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s := by intro n have : Ξ³ - (1 / 2) ^ n < Ξ³ := sub_lt_self Ξ³ (pow_pos (half_pos zero_lt_one) n) rcases exists_lt_of_lt_csSup c_nonempty this with ⟨r, ⟨s, hs, rfl⟩, hlt⟩ exact ⟨s, hs, hlt⟩ [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ ⊒ βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s [PROOFSTEP] intro n [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ n : β„• ⊒ βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s [PROOFSTEP] have : Ξ³ - (1 / 2) ^ n < Ξ³ := sub_lt_self Ξ³ (pow_pos (half_pos zero_lt_one) n) [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ n : β„• this : Ξ³ - (1 / 2) ^ n < Ξ³ ⊒ βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s [PROOFSTEP] rcases exists_lt_of_lt_csSup c_nonempty this with ⟨r, ⟨s, hs, rfl⟩, hlt⟩ [GOAL] case intro.intro.intro.intro Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ n : β„• this : Ξ³ - (1 / 2) ^ n < Ξ³ s : Set Ξ± hs : s ∈ {s | MeasurableSet s} hlt : Ξ³ - (1 / 2) ^ n < d s ⊒ βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s [PROOFSTEP] exact ⟨s, hs, hlt⟩ [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s ⊒ βˆƒ s, MeasurableSet s ∧ (βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t) ∧ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] rcases Classical.axiom_of_choice this with ⟨e, he⟩ [GOAL] case intro Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) ⊒ βˆƒ s, MeasurableSet s ∧ (βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t) ∧ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] change β„• β†’ Set Ξ± at e [GOAL] case intro Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) ⊒ βˆƒ s, MeasurableSet s ∧ (βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t) ∧ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] have he₁ : βˆ€ n, MeasurableSet (e n) := fun n => (he n).1 [GOAL] case intro Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) ⊒ βˆƒ s, MeasurableSet s ∧ (βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t) ∧ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] have heβ‚‚ : βˆ€ n, Ξ³ - (1 / 2) ^ n < d (e n) := fun n => (he n).2 [GOAL] case intro Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) ⊒ βˆƒ s, MeasurableSet s ∧ (βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t) ∧ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] let f : β„• β†’ β„• β†’ Set Ξ± := fun n m => (Finset.Ico n (m + 1)).inf e [GOAL] case intro Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e ⊒ βˆƒ s, MeasurableSet s ∧ (βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t) ∧ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] have hf : βˆ€ n m, MeasurableSet (f n m) := by intro n m simp only [Finset.inf_eq_iInf] exact MeasurableSet.biInter (to_countable _) fun i _ => he₁ _ [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e ⊒ βˆ€ (n m : β„•), MeasurableSet (f n m) [PROOFSTEP] intro n m [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e n m : β„• ⊒ MeasurableSet (f n m) [PROOFSTEP] simp only [Finset.inf_eq_iInf] [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e n m : β„• ⊒ MeasurableSet (β¨… (a : β„•) (_ : a ∈ Finset.Ico n (m + 1)), e a) [PROOFSTEP] exact MeasurableSet.biInter (to_countable _) fun i _ => he₁ _ [GOAL] case intro Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) ⊒ βˆƒ s, MeasurableSet s ∧ (βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t) ∧ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] have f_subset_f : βˆ€ {a b c d}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c := by intro a b c d hab hcd simp_rw [Finset.inf_eq_iInf] exact biInter_subset_biInter_left (Finset.Ico_subset_Ico hab <| Nat.succ_le_succ hcd) [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) ⊒ βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c [PROOFSTEP] intro a b c d hab hcd [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d✝ : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c✝ : Set ℝ := d✝ '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c✝ hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d✝ s = d✝ (s \ t) + d✝ (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d✝ (s n)) atTop (𝓝 (d✝ (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d✝ (s n)) atTop (𝓝 (d✝ (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c✝ c_nonempty : Set.Nonempty c✝ d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d✝ s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d✝ s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d✝ (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d✝ (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) a b c d : β„• hab : a ≀ b hcd : c ≀ d ⊒ f a d βŠ† f b c [PROOFSTEP] simp_rw [Finset.inf_eq_iInf] [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d✝ : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c✝ : Set ℝ := d✝ '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c✝ hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d✝ s = d✝ (s \ t) + d✝ (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d✝ (s n)) atTop (𝓝 (d✝ (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d✝ (s n)) atTop (𝓝 (d✝ (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c✝ c_nonempty : Set.Nonempty c✝ d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d✝ s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d✝ s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d✝ (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d✝ (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) a b c d : β„• hab : a ≀ b hcd : c ≀ d ⊒ β¨… (a_1 : β„•) (_ : a_1 ∈ Finset.Ico a (d + 1)), e a_1 βŠ† β¨… (a : β„•) (_ : a ∈ Finset.Ico b (c + 1)), e a [PROOFSTEP] exact biInter_subset_biInter_left (Finset.Ico_subset_Ico hab <| Nat.succ_le_succ hcd) [GOAL] case intro Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c ⊒ βˆƒ s, MeasurableSet s ∧ (βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t) ∧ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] have f_succ : βˆ€ n m, n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) := by intro n m hnm have : n ≀ m + 1 := le_of_lt (Nat.succ_le_succ hnm) simp_rw [Nat.Ico_succ_right_eq_insert_Ico this, Finset.inf_insert, Set.inter_comm] rfl [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c ⊒ βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) [PROOFSTEP] intro n m hnm [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c n m : β„• hnm : n ≀ m ⊒ f n (m + 1) = f n m ∩ e (m + 1) [PROOFSTEP] have : n ≀ m + 1 := le_of_lt (Nat.succ_le_succ hnm) [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this✝ : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c n m : β„• hnm : n ≀ m this : n ≀ m + 1 ⊒ f n (m + 1) = f n m ∩ e (m + 1) [PROOFSTEP] simp_rw [Nat.Ico_succ_right_eq_insert_Ico this, Finset.inf_insert, Set.inter_comm] [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this✝ : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c n m : β„• hnm : n ≀ m this : n ≀ m + 1 ⊒ e (m + 1) βŠ“ Finset.inf (Finset.Ico n (m + 1)) e = e (m + 1) ∩ Finset.inf (Finset.Ico n (m + 1)) e [PROOFSTEP] rfl [GOAL] case intro Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) ⊒ βˆƒ s, MeasurableSet s ∧ (βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t) ∧ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] have le_d_f : βˆ€ n m, m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) := by intro n m h refine' Nat.le_induction _ _ n h Β· have := heβ‚‚ m simp_rw [Nat.Ico_succ_singleton, Finset.inf_singleton] linarith Β· intro n (hmn : m ≀ n) ih have : Ξ³ + (Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ (n + 1)) ≀ Ξ³ + d (f m (n + 1)) := by calc Ξ³ + (Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ (n + 1)) ≀ Ξ³ + (Ξ³ - 2 * (1 / 2) ^ m + ((1 / 2) ^ n - (1 / 2) ^ (n + 1))) := by refine' add_le_add_left (add_le_add_left _ _) Ξ³ simp only [pow_add, pow_one, le_sub_iff_add_le] linarith _ = Ξ³ - (1 / 2) ^ (n + 1) + (Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n) := by simp only [sub_eq_add_neg]; abel _ ≀ d (e (n + 1)) + d (f m n) := (add_le_add (le_of_lt <| heβ‚‚ _) ih) _ ≀ d (e (n + 1)) + d (f m n \ e (n + 1)) + d (f m (n + 1)) := by rw [f_succ _ _ hmn, d_split (f m n) (e (n + 1)) (hf _ _) (he₁ _), add_assoc] _ = d (e (n + 1) βˆͺ f m n) + d (f m (n + 1)) := by rw [d_split (e (n + 1) βˆͺ f m n) (e (n + 1)), union_diff_left, union_inter_cancel_left] abel exact (he₁ _).union (hf _ _) exact he₁ _ _ ≀ Ξ³ + d (f m (n + 1)) := add_le_add_right (d_le_Ξ³ _ <| (he₁ _).union (hf _ _)) _ exact (add_le_add_iff_left Ξ³).1 this [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) ⊒ βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) [PROOFSTEP] intro n m h [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) n m : β„• h : m ≀ n ⊒ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) [PROOFSTEP] refine' Nat.le_induction _ _ n h [GOAL] case refine'_1 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) n m : β„• h : m ≀ n ⊒ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ m ≀ d (f m m) [PROOFSTEP] have := heβ‚‚ m [GOAL] case refine'_1 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this✝ : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) n m : β„• h : m ≀ n this : Ξ³ - (1 / 2) ^ m < d (e m) ⊒ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ m ≀ d (f m m) [PROOFSTEP] simp_rw [Nat.Ico_succ_singleton, Finset.inf_singleton] [GOAL] case refine'_1 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this✝ : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) n m : β„• h : m ≀ n this : Ξ³ - (1 / 2) ^ m < d (e m) ⊒ sSup ((fun a => ↑(ENNReal.toNNReal (↑↑μ a)) - ↑(ENNReal.toNNReal (↑↑ν a))) '' {s | MeasurableSet s}) - 2 * (1 / 2) ^ m + (1 / 2) ^ m ≀ ↑(ENNReal.toNNReal (↑↑μ (e m))) - ↑(ENNReal.toNNReal (↑↑ν (e m))) [PROOFSTEP] linarith [GOAL] case refine'_2 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) n m : β„• h : m ≀ n ⊒ βˆ€ (n : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ (n + 1) ≀ d (f m (n + 1)) [PROOFSTEP] intro n (hmn : m ≀ n) ih [GOAL] case refine'_2 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) n✝ m : β„• h : m ≀ n✝ n : β„• hmn : m ≀ n ih : Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) ⊒ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ (n + 1) ≀ d (f m (n + 1)) [PROOFSTEP] have : Ξ³ + (Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ (n + 1)) ≀ Ξ³ + d (f m (n + 1)) := by calc Ξ³ + (Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ (n + 1)) ≀ Ξ³ + (Ξ³ - 2 * (1 / 2) ^ m + ((1 / 2) ^ n - (1 / 2) ^ (n + 1))) := by refine' add_le_add_left (add_le_add_left _ _) Ξ³ simp only [pow_add, pow_one, le_sub_iff_add_le] linarith _ = Ξ³ - (1 / 2) ^ (n + 1) + (Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n) := by simp only [sub_eq_add_neg]; abel _ ≀ d (e (n + 1)) + d (f m n) := (add_le_add (le_of_lt <| heβ‚‚ _) ih) _ ≀ d (e (n + 1)) + d (f m n \ e (n + 1)) + d (f m (n + 1)) := by rw [f_succ _ _ hmn, d_split (f m n) (e (n + 1)) (hf _ _) (he₁ _), add_assoc] _ = d (e (n + 1) βˆͺ f m n) + d (f m (n + 1)) := by rw [d_split (e (n + 1) βˆͺ f m n) (e (n + 1)), union_diff_left, union_inter_cancel_left] abel exact (he₁ _).union (hf _ _) exact he₁ _ _ ≀ Ξ³ + d (f m (n + 1)) := add_le_add_right (d_le_Ξ³ _ <| (he₁ _).union (hf _ _)) _ [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) n✝ m : β„• h : m ≀ n✝ n : β„• hmn : m ≀ n ih : Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) ⊒ Ξ³ + (Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ (n + 1)) ≀ Ξ³ + d (f m (n + 1)) [PROOFSTEP] calc Ξ³ + (Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ (n + 1)) ≀ Ξ³ + (Ξ³ - 2 * (1 / 2) ^ m + ((1 / 2) ^ n - (1 / 2) ^ (n + 1))) := by refine' add_le_add_left (add_le_add_left _ _) Ξ³ simp only [pow_add, pow_one, le_sub_iff_add_le] linarith _ = Ξ³ - (1 / 2) ^ (n + 1) + (Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n) := by simp only [sub_eq_add_neg]; abel _ ≀ d (e (n + 1)) + d (f m n) := (add_le_add (le_of_lt <| heβ‚‚ _) ih) _ ≀ d (e (n + 1)) + d (f m n \ e (n + 1)) + d (f m (n + 1)) := by rw [f_succ _ _ hmn, d_split (f m n) (e (n + 1)) (hf _ _) (he₁ _), add_assoc] _ = d (e (n + 1) βˆͺ f m n) + d (f m (n + 1)) := by rw [d_split (e (n + 1) βˆͺ f m n) (e (n + 1)), union_diff_left, union_inter_cancel_left] abel exact (he₁ _).union (hf _ _) exact he₁ _ _ ≀ Ξ³ + d (f m (n + 1)) := add_le_add_right (d_le_Ξ³ _ <| (he₁ _).union (hf _ _)) _ [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) n✝ m : β„• h : m ≀ n✝ n : β„• hmn : m ≀ n ih : Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) ⊒ Ξ³ + (Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ (n + 1)) ≀ Ξ³ + (Ξ³ - 2 * (1 / 2) ^ m + ((1 / 2) ^ n - (1 / 2) ^ (n + 1))) [PROOFSTEP] refine' add_le_add_left (add_le_add_left _ _) Ξ³ [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) n✝ m : β„• h : m ≀ n✝ n : β„• hmn : m ≀ n ih : Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) ⊒ (1 / 2) ^ (n + 1) ≀ (1 / 2) ^ n - (1 / 2) ^ (n + 1) [PROOFSTEP] simp only [pow_add, pow_one, le_sub_iff_add_le] [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) n✝ m : β„• h : m ≀ n✝ n : β„• hmn : m ≀ n ih : Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) ⊒ (1 / 2) ^ n * (1 / 2) + (1 / 2) ^ n * (1 / 2) ≀ (1 / 2) ^ n [PROOFSTEP] linarith [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) n✝ m : β„• h : m ≀ n✝ n : β„• hmn : m ≀ n ih : Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) ⊒ Ξ³ + (Ξ³ - 2 * (1 / 2) ^ m + ((1 / 2) ^ n - (1 / 2) ^ (n + 1))) = Ξ³ - (1 / 2) ^ (n + 1) + (Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n) [PROOFSTEP] simp only [sub_eq_add_neg] [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) n✝ m : β„• h : m ≀ n✝ n : β„• hmn : m ≀ n ih : Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) ⊒ sSup ((fun a => ↑(ENNReal.toNNReal (↑↑μ a)) + -↑(ENNReal.toNNReal (↑↑ν a))) '' {s | MeasurableSet s}) + (sSup ((fun a => ↑(ENNReal.toNNReal (↑↑μ a)) + -↑(ENNReal.toNNReal (↑↑ν a))) '' {s | MeasurableSet s}) + -(2 * (1 / 2) ^ m) + ((1 / 2) ^ n + -(1 / 2) ^ (n + 1))) = sSup ((fun a => ↑(ENNReal.toNNReal (↑↑μ a)) + -↑(ENNReal.toNNReal (↑↑ν a))) '' {s | MeasurableSet s}) + -(1 / 2) ^ (n + 1) + (sSup ((fun a => ↑(ENNReal.toNNReal (↑↑μ a)) + -↑(ENNReal.toNNReal (↑↑ν a))) '' {s | MeasurableSet s}) + -(2 * (1 / 2) ^ m) + (1 / 2) ^ n) [PROOFSTEP] abel [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) n✝ m : β„• h : m ≀ n✝ n : β„• hmn : m ≀ n ih : Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) ⊒ sSup ((fun a => ↑(ENNReal.toNNReal (↑↑μ a)) + -↑(ENNReal.toNNReal (↑↑ν a))) '' {s | MeasurableSet s}) + (sSup ((fun a => ↑(ENNReal.toNNReal (↑↑μ a)) + -↑(ENNReal.toNNReal (↑↑ν a))) '' {s | MeasurableSet s}) + -(2 * (1 / 2) ^ m) + ((1 / 2) ^ n + -(1 / 2) ^ (n + 1))) = sSup ((fun a => ↑(ENNReal.toNNReal (↑↑μ a)) + -↑(ENNReal.toNNReal (↑↑ν a))) '' {s | MeasurableSet s}) + -(1 / 2) ^ (n + 1) + (sSup ((fun a => ↑(ENNReal.toNNReal (↑↑μ a)) + -↑(ENNReal.toNNReal (↑↑ν a))) '' {s | MeasurableSet s}) + -(2 * (1 / 2) ^ m) + (1 / 2) ^ n) [PROOFSTEP] abel [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) n✝ m : β„• h : m ≀ n✝ n : β„• hmn : m ≀ n ih : Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) ⊒ d (e (n + 1)) + d (f m n) ≀ d (e (n + 1)) + d (f m n \ e (n + 1)) + d (f m (n + 1)) [PROOFSTEP] rw [f_succ _ _ hmn, d_split (f m n) (e (n + 1)) (hf _ _) (he₁ _), add_assoc] [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) n✝ m : β„• h : m ≀ n✝ n : β„• hmn : m ≀ n ih : Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) ⊒ d (e (n + 1)) + d (f m n \ e (n + 1)) + d (f m (n + 1)) = d (e (n + 1) βˆͺ f m n) + d (f m (n + 1)) [PROOFSTEP] rw [d_split (e (n + 1) βˆͺ f m n) (e (n + 1)), union_diff_left, union_inter_cancel_left] [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) n✝ m : β„• h : m ≀ n✝ n : β„• hmn : m ≀ n ih : Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) ⊒ d (e (n + 1)) + d (f m n \ e (n + 1)) + d (f m (n + 1)) = d (f m n \ e (n + 1)) + d (e (n + 1)) + d (f m (n + 1)) case a Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) n✝ m : β„• h : m ≀ n✝ n : β„• hmn : m ≀ n ih : Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) ⊒ MeasurableSet (e (n + 1) βˆͺ f m n) case a Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) n✝ m : β„• h : m ≀ n✝ n : β„• hmn : m ≀ n ih : Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) ⊒ MeasurableSet (e (n + 1)) [PROOFSTEP] abel [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) n✝ m : β„• h : m ≀ n✝ n : β„• hmn : m ≀ n ih : Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) ⊒ d (e (n + 1)) + d (f m n \ e (n + 1)) + d (f m (n + 1)) = d (f m n \ e (n + 1)) + d (e (n + 1)) + d (f m (n + 1)) case a Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) n✝ m : β„• h : m ≀ n✝ n : β„• hmn : m ≀ n ih : Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) ⊒ MeasurableSet (e (n + 1) βˆͺ f m n) case a Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) n✝ m : β„• h : m ≀ n✝ n : β„• hmn : m ≀ n ih : Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) ⊒ MeasurableSet (e (n + 1)) [PROOFSTEP] abel [GOAL] case a Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) n✝ m : β„• h : m ≀ n✝ n : β„• hmn : m ≀ n ih : Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) ⊒ MeasurableSet (e (n + 1) βˆͺ f m n) case a Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) n✝ m : β„• h : m ≀ n✝ n : β„• hmn : m ≀ n ih : Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) ⊒ MeasurableSet (e (n + 1)) [PROOFSTEP] exact (he₁ _).union (hf _ _) [GOAL] case a Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) n✝ m : β„• h : m ≀ n✝ n : β„• hmn : m ≀ n ih : Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) ⊒ MeasurableSet (e (n + 1)) [PROOFSTEP] exact he₁ _ [GOAL] case refine'_2 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this✝ : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) n✝ m : β„• h : m ≀ n✝ n : β„• hmn : m ≀ n ih : Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) this : Ξ³ + (Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ (n + 1)) ≀ Ξ³ + d (f m (n + 1)) ⊒ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ (n + 1) ≀ d (f m (n + 1)) [PROOFSTEP] exact (add_le_add_iff_left Ξ³).1 this [GOAL] case intro Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) ⊒ βˆƒ s, MeasurableSet s ∧ (βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t) ∧ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] let s := ⋃ m, β‹‚ n, f m n [GOAL] case intro Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n ⊒ βˆƒ s, MeasurableSet s ∧ (βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t) ∧ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] have Ξ³_le_d_s : Ξ³ ≀ d s := by have hΞ³ : Tendsto (fun m : β„• => Ξ³ - 2 * (1 / 2) ^ m) atTop (𝓝 Ξ³) := by suffices Tendsto (fun m : β„• => Ξ³ - 2 * (1 / 2) ^ m) atTop (𝓝 (Ξ³ - 2 * 0)) by simpa only [mul_zero, tsub_zero] exact tendsto_const_nhds.sub <| tendsto_const_nhds.mul <| tendsto_pow_atTop_nhds_0_of_lt_1 (le_of_lt <| half_pos <| zero_lt_one) (half_lt_self zero_lt_one) have hd : Tendsto (fun m => d (β‹‚ n, f m n)) atTop (𝓝 (d (⋃ m, β‹‚ n, f m n))) := by refine' d_Union _ _ exact fun n m hnm => subset_iInter fun i => Subset.trans (iInter_subset (f n) i) <| f_subset_f hnm <| le_rfl refine' le_of_tendsto_of_tendsto' hΞ³ hd fun m => _ have : Tendsto (fun n => d (f m n)) atTop (𝓝 (d (β‹‚ n, f m n))) := by refine' d_Inter _ _ _ Β· intro n exact hf _ _ Β· intro n m hnm exact f_subset_f le_rfl hnm refine' ge_of_tendsto this (eventually_atTop.2 ⟨m, fun n hmn => _⟩) change Ξ³ - 2 * (1 / 2) ^ m ≀ d (f m n) refine' le_trans _ (le_d_f _ _ hmn) exact le_add_of_le_of_nonneg le_rfl (pow_nonneg (le_of_lt <| half_pos <| zero_lt_one) _) [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n ⊒ Ξ³ ≀ d s [PROOFSTEP] have hΞ³ : Tendsto (fun m : β„• => Ξ³ - 2 * (1 / 2) ^ m) atTop (𝓝 Ξ³) := by suffices Tendsto (fun m : β„• => Ξ³ - 2 * (1 / 2) ^ m) atTop (𝓝 (Ξ³ - 2 * 0)) by simpa only [mul_zero, tsub_zero] exact tendsto_const_nhds.sub <| tendsto_const_nhds.mul <| tendsto_pow_atTop_nhds_0_of_lt_1 (le_of_lt <| half_pos <| zero_lt_one) (half_lt_self zero_lt_one) [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n ⊒ Tendsto (fun m => Ξ³ - 2 * (1 / 2) ^ m) atTop (𝓝 Ξ³) [PROOFSTEP] suffices Tendsto (fun m : β„• => Ξ³ - 2 * (1 / 2) ^ m) atTop (𝓝 (Ξ³ - 2 * 0)) by simpa only [mul_zero, tsub_zero] [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this✝ : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n this : Tendsto (fun m => Ξ³ - 2 * (1 / 2) ^ m) atTop (𝓝 (Ξ³ - 2 * 0)) ⊒ Tendsto (fun m => Ξ³ - 2 * (1 / 2) ^ m) atTop (𝓝 Ξ³) [PROOFSTEP] simpa only [mul_zero, tsub_zero] [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n ⊒ Tendsto (fun m => Ξ³ - 2 * (1 / 2) ^ m) atTop (𝓝 (Ξ³ - 2 * 0)) [PROOFSTEP] exact tendsto_const_nhds.sub <| tendsto_const_nhds.mul <| tendsto_pow_atTop_nhds_0_of_lt_1 (le_of_lt <| half_pos <| zero_lt_one) (half_lt_self zero_lt_one) [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n hΞ³ : Tendsto (fun m => Ξ³ - 2 * (1 / 2) ^ m) atTop (𝓝 Ξ³) ⊒ Ξ³ ≀ d s [PROOFSTEP] have hd : Tendsto (fun m => d (β‹‚ n, f m n)) atTop (𝓝 (d (⋃ m, β‹‚ n, f m n))) := by refine' d_Union _ _ exact fun n m hnm => subset_iInter fun i => Subset.trans (iInter_subset (f n) i) <| f_subset_f hnm <| le_rfl [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n hΞ³ : Tendsto (fun m => Ξ³ - 2 * (1 / 2) ^ m) atTop (𝓝 Ξ³) ⊒ Tendsto (fun m => d (β‹‚ (n : β„•), f m n)) atTop (𝓝 (d (⋃ (m : β„•), β‹‚ (n : β„•), f m n))) [PROOFSTEP] refine' d_Union _ _ [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n hΞ³ : Tendsto (fun m => Ξ³ - 2 * (1 / 2) ^ m) atTop (𝓝 Ξ³) ⊒ Monotone fun m => β‹‚ (n : β„•), f m n [PROOFSTEP] exact fun n m hnm => subset_iInter fun i => Subset.trans (iInter_subset (f n) i) <| f_subset_f hnm <| le_rfl [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n hΞ³ : Tendsto (fun m => Ξ³ - 2 * (1 / 2) ^ m) atTop (𝓝 Ξ³) hd : Tendsto (fun m => d (β‹‚ (n : β„•), f m n)) atTop (𝓝 (d (⋃ (m : β„•), β‹‚ (n : β„•), f m n))) ⊒ Ξ³ ≀ d s [PROOFSTEP] refine' le_of_tendsto_of_tendsto' hΞ³ hd fun m => _ [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n hΞ³ : Tendsto (fun m => Ξ³ - 2 * (1 / 2) ^ m) atTop (𝓝 Ξ³) hd : Tendsto (fun m => d (β‹‚ (n : β„•), f m n)) atTop (𝓝 (d (⋃ (m : β„•), β‹‚ (n : β„•), f m n))) m : β„• ⊒ Ξ³ - 2 * (1 / 2) ^ m ≀ d (β‹‚ (n : β„•), f m n) [PROOFSTEP] have : Tendsto (fun n => d (f m n)) atTop (𝓝 (d (β‹‚ n, f m n))) := by refine' d_Inter _ _ _ Β· intro n exact hf _ _ Β· intro n m hnm exact f_subset_f le_rfl hnm [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n hΞ³ : Tendsto (fun m => Ξ³ - 2 * (1 / 2) ^ m) atTop (𝓝 Ξ³) hd : Tendsto (fun m => d (β‹‚ (n : β„•), f m n)) atTop (𝓝 (d (⋃ (m : β„•), β‹‚ (n : β„•), f m n))) m : β„• ⊒ Tendsto (fun n => d (f m n)) atTop (𝓝 (d (β‹‚ (n : β„•), f m n))) [PROOFSTEP] refine' d_Inter _ _ _ [GOAL] case refine'_1 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n hΞ³ : Tendsto (fun m => Ξ³ - 2 * (1 / 2) ^ m) atTop (𝓝 Ξ³) hd : Tendsto (fun m => d (β‹‚ (n : β„•), f m n)) atTop (𝓝 (d (⋃ (m : β„•), β‹‚ (n : β„•), f m n))) m : β„• ⊒ βˆ€ (n : β„•), MeasurableSet (f m n) [PROOFSTEP] intro n [GOAL] case refine'_1 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n hΞ³ : Tendsto (fun m => Ξ³ - 2 * (1 / 2) ^ m) atTop (𝓝 Ξ³) hd : Tendsto (fun m => d (β‹‚ (n : β„•), f m n)) atTop (𝓝 (d (⋃ (m : β„•), β‹‚ (n : β„•), f m n))) m n : β„• ⊒ MeasurableSet (f m n) [PROOFSTEP] exact hf _ _ [GOAL] case refine'_2 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n hΞ³ : Tendsto (fun m => Ξ³ - 2 * (1 / 2) ^ m) atTop (𝓝 Ξ³) hd : Tendsto (fun m => d (β‹‚ (n : β„•), f m n)) atTop (𝓝 (d (⋃ (m : β„•), β‹‚ (n : β„•), f m n))) m : β„• ⊒ βˆ€ (n m_1 : β„•), n ≀ m_1 β†’ f m m_1 βŠ† f m n [PROOFSTEP] intro n m hnm [GOAL] case refine'_2 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n hΞ³ : Tendsto (fun m => Ξ³ - 2 * (1 / 2) ^ m) atTop (𝓝 Ξ³) hd : Tendsto (fun m => d (β‹‚ (n : β„•), f m n)) atTop (𝓝 (d (⋃ (m : β„•), β‹‚ (n : β„•), f m n))) m✝ n m : β„• hnm : n ≀ m ⊒ f m✝ m βŠ† f m✝ n [PROOFSTEP] exact f_subset_f le_rfl hnm [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this✝ : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n hΞ³ : Tendsto (fun m => Ξ³ - 2 * (1 / 2) ^ m) atTop (𝓝 Ξ³) hd : Tendsto (fun m => d (β‹‚ (n : β„•), f m n)) atTop (𝓝 (d (⋃ (m : β„•), β‹‚ (n : β„•), f m n))) m : β„• this : Tendsto (fun n => d (f m n)) atTop (𝓝 (d (β‹‚ (n : β„•), f m n))) ⊒ Ξ³ - 2 * (1 / 2) ^ m ≀ d (β‹‚ (n : β„•), f m n) [PROOFSTEP] refine' ge_of_tendsto this (eventually_atTop.2 ⟨m, fun n hmn => _⟩) [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this✝ : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n hΞ³ : Tendsto (fun m => Ξ³ - 2 * (1 / 2) ^ m) atTop (𝓝 Ξ³) hd : Tendsto (fun m => d (β‹‚ (n : β„•), f m n)) atTop (𝓝 (d (⋃ (m : β„•), β‹‚ (n : β„•), f m n))) m : β„• this : Tendsto (fun n => d (f m n)) atTop (𝓝 (d (β‹‚ (n : β„•), f m n))) n : β„• hmn : n β‰₯ m ⊒ Ξ³ - 2 * (1 / 2) ^ m ≀ d (f m n) [PROOFSTEP] change Ξ³ - 2 * (1 / 2) ^ m ≀ d (f m n) [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this✝ : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n hΞ³ : Tendsto (fun m => Ξ³ - 2 * (1 / 2) ^ m) atTop (𝓝 Ξ³) hd : Tendsto (fun m => d (β‹‚ (n : β„•), f m n)) atTop (𝓝 (d (⋃ (m : β„•), β‹‚ (n : β„•), f m n))) m : β„• this : Tendsto (fun n => d (f m n)) atTop (𝓝 (d (β‹‚ (n : β„•), f m n))) n : β„• hmn : n β‰₯ m ⊒ Ξ³ - 2 * (1 / 2) ^ m ≀ d (f m n) [PROOFSTEP] refine' le_trans _ (le_d_f _ _ hmn) [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this✝ : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n hΞ³ : Tendsto (fun m => Ξ³ - 2 * (1 / 2) ^ m) atTop (𝓝 Ξ³) hd : Tendsto (fun m => d (β‹‚ (n : β„•), f m n)) atTop (𝓝 (d (⋃ (m : β„•), β‹‚ (n : β„•), f m n))) m : β„• this : Tendsto (fun n => d (f m n)) atTop (𝓝 (d (β‹‚ (n : β„•), f m n))) n : β„• hmn : n β‰₯ m ⊒ Ξ³ - 2 * (1 / 2) ^ m ≀ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n [PROOFSTEP] exact le_add_of_le_of_nonneg le_rfl (pow_nonneg (le_of_lt <| half_pos <| zero_lt_one) _) [GOAL] case intro Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n Ξ³_le_d_s : Ξ³ ≀ d s ⊒ βˆƒ s, MeasurableSet s ∧ (βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t) ∧ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] have hs : MeasurableSet s := MeasurableSet.iUnion fun n => MeasurableSet.iInter fun m => hf _ _ [GOAL] case intro Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n Ξ³_le_d_s : Ξ³ ≀ d s hs : MeasurableSet s ⊒ βˆƒ s, MeasurableSet s ∧ (βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t) ∧ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] refine' ⟨s, hs, _, _⟩ [GOAL] case intro.refine'_1 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n Ξ³_le_d_s : Ξ³ ≀ d s hs : MeasurableSet s ⊒ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† s β†’ ↑↑ν t ≀ ↑↑μ t [PROOFSTEP] intro t ht hts [GOAL] case intro.refine'_1 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n Ξ³_le_d_s : Ξ³ ≀ d s hs : MeasurableSet s t : Set Ξ± ht : MeasurableSet t hts : t βŠ† s ⊒ ↑↑ν t ≀ ↑↑μ t [PROOFSTEP] have : 0 ≀ d t := (add_le_add_iff_left Ξ³).1 <| calc Ξ³ + 0 ≀ d s := by rw [add_zero]; exact Ξ³_le_d_s _ = d (s \ t) + d t := by rw [d_split _ _ hs ht, inter_eq_self_of_subset_right hts] _ ≀ Ξ³ + d t := add_le_add (d_le_Ξ³ _ (hs.diff ht)) le_rfl [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n Ξ³_le_d_s : Ξ³ ≀ d s hs : MeasurableSet s t : Set Ξ± ht : MeasurableSet t hts : t βŠ† s ⊒ Ξ³ + 0 ≀ d s [PROOFSTEP] rw [add_zero] [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n Ξ³_le_d_s : Ξ³ ≀ d s hs : MeasurableSet s t : Set Ξ± ht : MeasurableSet t hts : t βŠ† s ⊒ Ξ³ ≀ d s [PROOFSTEP] exact Ξ³_le_d_s [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n Ξ³_le_d_s : Ξ³ ≀ d s hs : MeasurableSet s t : Set Ξ± ht : MeasurableSet t hts : t βŠ† s ⊒ d s = d (s \ t) + d t [PROOFSTEP] rw [d_split _ _ hs ht, inter_eq_self_of_subset_right hts] [GOAL] case intro.refine'_1 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this✝ : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n Ξ³_le_d_s : Ξ³ ≀ d s hs : MeasurableSet s t : Set Ξ± ht : MeasurableSet t hts : t βŠ† s this : 0 ≀ d t ⊒ ↑↑ν t ≀ ↑↑μ t [PROOFSTEP] rw [← to_nnreal_ΞΌ, ← to_nnreal_Ξ½, ENNReal.coe_le_coe, ← NNReal.coe_le_coe] [GOAL] case intro.refine'_1 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this✝ : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n Ξ³_le_d_s : Ξ³ ≀ d s hs : MeasurableSet s t : Set Ξ± ht : MeasurableSet t hts : t βŠ† s this : 0 ≀ d t ⊒ ↑(ENNReal.toNNReal (↑↑ν t)) ≀ ↑(ENNReal.toNNReal (↑↑μ t)) [PROOFSTEP] simpa only [le_sub_iff_add_le, zero_add] using this [GOAL] case intro.refine'_2 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n Ξ³_le_d_s : Ξ³ ≀ d s hs : MeasurableSet s ⊒ βˆ€ (t : Set Ξ±), MeasurableSet t β†’ t βŠ† sᢜ β†’ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] intro t ht hts [GOAL] case intro.refine'_2 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n Ξ³_le_d_s : Ξ³ ≀ d s hs : MeasurableSet s t : Set Ξ± ht : MeasurableSet t hts : t βŠ† sᢜ ⊒ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] have : d t ≀ 0 := (add_le_add_iff_left Ξ³).1 <| calc Ξ³ + d t ≀ d s + d t := add_le_add Ξ³_le_d_s le_rfl _ = d (s βˆͺ t) := by rw [d_split _ _ (hs.union ht) ht, union_diff_right, union_inter_cancel_right, (subset_compl_iff_disjoint_left.1 hts).sdiff_eq_left] _ ≀ Ξ³ + 0 := by rw [add_zero]; exact d_le_Ξ³ _ (hs.union ht) [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n Ξ³_le_d_s : Ξ³ ≀ d s hs : MeasurableSet s t : Set Ξ± ht : MeasurableSet t hts : t βŠ† sᢜ ⊒ d s + d t = d (s βˆͺ t) [PROOFSTEP] rw [d_split _ _ (hs.union ht) ht, union_diff_right, union_inter_cancel_right, (subset_compl_iff_disjoint_left.1 hts).sdiff_eq_left] [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n Ξ³_le_d_s : Ξ³ ≀ d s hs : MeasurableSet s t : Set Ξ± ht : MeasurableSet t hts : t βŠ† sᢜ ⊒ d (s βˆͺ t) ≀ Ξ³ + 0 [PROOFSTEP] rw [add_zero] [GOAL] Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n Ξ³_le_d_s : Ξ³ ≀ d s hs : MeasurableSet s t : Set Ξ± ht : MeasurableSet t hts : t βŠ† sᢜ ⊒ d (s βˆͺ t) ≀ Ξ³ [PROOFSTEP] exact d_le_Ξ³ _ (hs.union ht) [GOAL] case intro.refine'_2 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this✝ : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n Ξ³_le_d_s : Ξ³ ≀ d s hs : MeasurableSet s t : Set Ξ± ht : MeasurableSet t hts : t βŠ† sᢜ this : d t ≀ 0 ⊒ ↑↑μ t ≀ ↑↑ν t [PROOFSTEP] rw [← to_nnreal_ΞΌ, ← to_nnreal_Ξ½, ENNReal.coe_le_coe, ← NNReal.coe_le_coe] [GOAL] case intro.refine'_2 Ξ± : Type u_1 inst✝² : MeasurableSpace Ξ± ΞΌ Ξ½ : Measure Ξ± inst✝¹ : IsFiniteMeasure ΞΌ inst✝ : IsFiniteMeasure Ξ½ d : Set Ξ± β†’ ℝ := fun s => ↑(ENNReal.toNNReal (↑↑μ s)) - ↑(ENNReal.toNNReal (↑↑ν s)) c : Set ℝ := d '' {s | MeasurableSet s} Ξ³ : ℝ := sSup c hΞΌ : βˆ€ (s : Set Ξ±), ↑↑μ s β‰  ⊀ hΞ½ : βˆ€ (s : Set Ξ±), ↑↑ν s β‰  ⊀ to_nnreal_ΞΌ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑μ s)) = ↑↑μ s to_nnreal_Ξ½ : βˆ€ (s : Set Ξ±), ↑(ENNReal.toNNReal (↑↑ν s)) = ↑↑ν s d_split : βˆ€ (s t : Set Ξ±), MeasurableSet s β†’ MeasurableSet t β†’ d s = d (s \ t) + d (s ∩ t) d_Union : βˆ€ (s : β„• β†’ Set Ξ±), Monotone s β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋃ (n : β„•), s n))) d_Inter : βˆ€ (s : β„• β†’ Set Ξ±), (βˆ€ (n : β„•), MeasurableSet (s n)) β†’ (βˆ€ (n m : β„•), n ≀ m β†’ s m βŠ† s n) β†’ Tendsto (fun n => d (s n)) atTop (𝓝 (d (β‹‚ (n : β„•), s n))) bdd_c : BddAbove c c_nonempty : Set.Nonempty c d_le_Ξ³ : βˆ€ (s : Set Ξ±), MeasurableSet s β†’ d s ≀ Ξ³ this✝ : βˆ€ (n : β„•), βˆƒ s, MeasurableSet s ∧ Ξ³ - (1 / 2) ^ n < d s e : β„• β†’ Set Ξ± he : βˆ€ (x : β„•), MeasurableSet (e x) ∧ Ξ³ - (1 / 2) ^ x < d (e x) he₁ : βˆ€ (n : β„•), MeasurableSet (e n) heβ‚‚ : βˆ€ (n : β„•), Ξ³ - (1 / 2) ^ n < d (e n) f : β„• β†’ β„• β†’ Set Ξ± := fun n m => Finset.inf (Finset.Ico n (m + 1)) e hf : βˆ€ (n m : β„•), MeasurableSet (f n m) f_subset_f : βˆ€ {a b c d : β„•}, a ≀ b β†’ c ≀ d β†’ f a d βŠ† f b c f_succ : βˆ€ (n m : β„•), n ≀ m β†’ f n (m + 1) = f n m ∩ e (m + 1) le_d_f : βˆ€ (n m : β„•), m ≀ n β†’ Ξ³ - 2 * (1 / 2) ^ m + (1 / 2) ^ n ≀ d (f m n) s : Set Ξ± := ⋃ (m : β„•), β‹‚ (n : β„•), f m n Ξ³_le_d_s : Ξ³ ≀ d s hs : MeasurableSet s t : Set Ξ± ht : MeasurableSet t hts : t βŠ† sᢜ this : d t ≀ 0 ⊒ ↑(ENNReal.toNNReal (↑↑μ t)) ≀ ↑(ENNReal.toNNReal (↑↑ν t)) [PROOFSTEP] simpa only [sub_le_iff_le_add, zero_add] using this
State Before: a : Nat ⊒ a = a * 1 State After: no goals Tactic: simp
Formal statement is: lemma csqrt_square: assumes "0 < Re b \<or> (Re b = 0 \<and> 0 \<le> Im b)" shows "csqrt (b^2) = b" Informal statement is: If $b$ is a complex number with nonnegative real part, then $\sqrt{b^2} = b$.
{-# OPTIONS --without-K #-} module sets.vec.core where open import function.core open import sets.nat.core using (β„•; zero; suc) open import sets.fin data Vec {i}(A : Set i) : β„• β†’ Set i where [] : Vec A 0 _∷_ : βˆ€ {n} β†’ A β†’ Vec A n β†’ Vec A (suc n) infixr 5 _∷_ head : βˆ€ {i}{A : Set i}{n : β„•} β†’ Vec A (suc n) β†’ A head (x ∷ _) = x tail : βˆ€ {i}{A : Set i}{n : β„•} β†’ Vec A (suc n) β†’ Vec A n tail (_ ∷ xs) = xs tabulate : βˆ€ {i}{A : Set i}{n : β„•} β†’ (Fin n β†’ A) β†’ Vec A n tabulate {n = zero} _ = [] tabulate {n = suc m} f = f zero ∷ tabulate (f ∘ suc) lookup : βˆ€ {i}{A : Set i}{n : β„•} β†’ Vec A n β†’ Fin n β†’ A lookup [] () lookup (x ∷ xs) zero = x lookup (x ∷ xs) (suc i) = lookup xs i _!_ : βˆ€ {i}{A : Set i}{n : β„•} β†’ Vec A n β†’ Fin n β†’ A _!_ = lookup
[STATEMENT] lemma list_all2_list_all[simp]: "list_all2 (\<lambda> x. f) xs ys \<longleftrightarrow> length xs = length ys \<and> list_all f ys" [PROOF STATE] proof (prove) goal (1 subgoal): 1. list_all2 (\<lambda>x. f) xs ys = (length xs = length ys \<and> list_all f ys) [PROOF STEP] by (metis list_all2_length list_all_length)
State Before: ⊒ StrictConcaveOn ℝ (Iio 0) log State After: ⊒ βˆ€ ⦃x : ℝ⦄, x ∈ Iio 0 β†’ βˆ€ ⦃y : ℝ⦄, y ∈ Iio 0 β†’ x β‰  y β†’ βˆ€ ⦃a b : ℝ⦄, 0 < a β†’ 0 < b β†’ a + b = 1 β†’ a β€’ log x + b β€’ log y < log (a β€’ x + b β€’ y) Tactic: refine' ⟨convex_Iio _, _⟩ State Before: ⊒ βˆ€ ⦃x : ℝ⦄, x ∈ Iio 0 β†’ βˆ€ ⦃y : ℝ⦄, y ∈ Iio 0 β†’ x β‰  y β†’ βˆ€ ⦃a b : ℝ⦄, 0 < a β†’ 0 < b β†’ a + b = 1 β†’ a β€’ log x + b β€’ log y < log (a β€’ x + b β€’ y) State After: x : ℝ hx : x < 0 y : ℝ hy : y < 0 hxy : x β‰  y a b : ℝ ha : 0 < a hb : 0 < b hab : a + b = 1 ⊒ a β€’ log x + b β€’ log y < log (a β€’ x + b β€’ y) Tactic: rintro x (hx : x < 0) y (hy : y < 0) hxy a b ha hb hab State Before: x : ℝ hx : x < 0 y : ℝ hy : y < 0 hxy : x β‰  y a b : ℝ ha : 0 < a hb : 0 < b hab : a + b = 1 ⊒ a β€’ log x + b β€’ log y < log (a β€’ x + b β€’ y) State After: x : ℝ hx : x < 0 y : ℝ hy : y < 0 hxy : x β‰  y a b : ℝ ha : 0 < a hb : 0 < b hab : a + b = 1 hx' : 0 < -x ⊒ a β€’ log x + b β€’ log y < log (a β€’ x + b β€’ y) Tactic: have hx' : 0 < -x := by linarith State Before: x : ℝ hx : x < 0 y : ℝ hy : y < 0 hxy : x β‰  y a b : ℝ ha : 0 < a hb : 0 < b hab : a + b = 1 hx' : 0 < -x ⊒ a β€’ log x + b β€’ log y < log (a β€’ x + b β€’ y) State After: x : ℝ hx : x < 0 y : ℝ hy : y < 0 hxy : x β‰  y a b : ℝ ha : 0 < a hb : 0 < b hab : a + b = 1 hx' : 0 < -x hy' : 0 < -y ⊒ a β€’ log x + b β€’ log y < log (a β€’ x + b β€’ y) Tactic: have hy' : 0 < -y := by linarith State Before: x : ℝ hx : x < 0 y : ℝ hy : y < 0 hxy : x β‰  y a b : ℝ ha : 0 < a hb : 0 < b hab : a + b = 1 hx' : 0 < -x hy' : 0 < -y ⊒ a β€’ log x + b β€’ log y < log (a β€’ x + b β€’ y) State After: x : ℝ hx : x < 0 y : ℝ hy : y < 0 hxy : x β‰  y a b : ℝ ha : 0 < a hb : 0 < b hab : a + b = 1 hx' : 0 < -x hy' : 0 < -y hxy' : -x β‰  -y ⊒ a β€’ log x + b β€’ log y < log (a β€’ x + b β€’ y) Tactic: have hxy' : -x β‰  -y := by contrapose! hxy; linarith State Before: x : ℝ hx : x < 0 y : ℝ hy : y < 0 hxy : x β‰  y a b : ℝ ha : 0 < a hb : 0 < b hab : a + b = 1 hx' : 0 < -x hy' : 0 < -y hxy' : -x β‰  -y ⊒ a β€’ log x + b β€’ log y < log (a β€’ x + b β€’ y) State After: no goals Tactic: calc a β€’ log x + b β€’ log y = a β€’ log (-x) + b β€’ log (-y) := by simp_rw [log_neg_eq_log] _ < log (a β€’ -x + b β€’ -y) := (strictConcaveOn_log_Ioi.2 hx' hy' hxy' ha hb hab) _ = log (-(a β€’ x + b β€’ y)) := by congr 1; simp only [Algebra.id.smul_eq_mul]; ring _ = _ := by rw [log_neg_eq_log] State Before: x : ℝ hx : x < 0 y : ℝ hy : y < 0 hxy : x β‰  y a b : ℝ ha : 0 < a hb : 0 < b hab : a + b = 1 ⊒ 0 < -x State After: no goals Tactic: linarith State Before: x : ℝ hx : x < 0 y : ℝ hy : y < 0 hxy : x β‰  y a b : ℝ ha : 0 < a hb : 0 < b hab : a + b = 1 hx' : 0 < -x ⊒ 0 < -y State After: no goals Tactic: linarith State Before: x : ℝ hx : x < 0 y : ℝ hy : y < 0 hxy : x β‰  y a b : ℝ ha : 0 < a hb : 0 < b hab : a + b = 1 hx' : 0 < -x hy' : 0 < -y ⊒ -x β‰  -y State After: x : ℝ hx : x < 0 y : ℝ hy : y < 0 a b : ℝ ha : 0 < a hb : 0 < b hab : a + b = 1 hx' : 0 < -x hy' : 0 < -y hxy : -x = -y ⊒ x = y Tactic: contrapose! hxy State Before: x : ℝ hx : x < 0 y : ℝ hy : y < 0 a b : ℝ ha : 0 < a hb : 0 < b hab : a + b = 1 hx' : 0 < -x hy' : 0 < -y hxy : -x = -y ⊒ x = y State After: no goals Tactic: linarith State Before: x : ℝ hx : x < 0 y : ℝ hy : y < 0 hxy : x β‰  y a b : ℝ ha : 0 < a hb : 0 < b hab : a + b = 1 hx' : 0 < -x hy' : 0 < -y hxy' : -x β‰  -y ⊒ a β€’ log x + b β€’ log y = a β€’ log (-x) + b β€’ log (-y) State After: no goals Tactic: simp_rw [log_neg_eq_log] State Before: x : ℝ hx : x < 0 y : ℝ hy : y < 0 hxy : x β‰  y a b : ℝ ha : 0 < a hb : 0 < b hab : a + b = 1 hx' : 0 < -x hy' : 0 < -y hxy' : -x β‰  -y ⊒ log (a β€’ -x + b β€’ -y) = log (-(a β€’ x + b β€’ y)) State After: case e_x x : ℝ hx : x < 0 y : ℝ hy : y < 0 hxy : x β‰  y a b : ℝ ha : 0 < a hb : 0 < b hab : a + b = 1 hx' : 0 < -x hy' : 0 < -y hxy' : -x β‰  -y ⊒ a β€’ -x + b β€’ -y = -(a β€’ x + b β€’ y) Tactic: congr 1 State Before: case e_x x : ℝ hx : x < 0 y : ℝ hy : y < 0 hxy : x β‰  y a b : ℝ ha : 0 < a hb : 0 < b hab : a + b = 1 hx' : 0 < -x hy' : 0 < -y hxy' : -x β‰  -y ⊒ a β€’ -x + b β€’ -y = -(a β€’ x + b β€’ y) State After: case e_x x : ℝ hx : x < 0 y : ℝ hy : y < 0 hxy : x β‰  y a b : ℝ ha : 0 < a hb : 0 < b hab : a + b = 1 hx' : 0 < -x hy' : 0 < -y hxy' : -x β‰  -y ⊒ a * -x + b * -y = -(a * x + b * y) Tactic: simp only [Algebra.id.smul_eq_mul] State Before: case e_x x : ℝ hx : x < 0 y : ℝ hy : y < 0 hxy : x β‰  y a b : ℝ ha : 0 < a hb : 0 < b hab : a + b = 1 hx' : 0 < -x hy' : 0 < -y hxy' : -x β‰  -y ⊒ a * -x + b * -y = -(a * x + b * y) State After: no goals Tactic: ring State Before: x : ℝ hx : x < 0 y : ℝ hy : y < 0 hxy : x β‰  y a b : ℝ ha : 0 < a hb : 0 < b hab : a + b = 1 hx' : 0 < -x hy' : 0 < -y hxy' : -x β‰  -y ⊒ log (-(a β€’ x + b β€’ y)) = log (a β€’ x + b β€’ y) State After: no goals Tactic: rw [log_neg_eq_log]
Rcpp::sourceCpp('src/CppLoglikelihood.cpp') Rcpp::sourceCpp('src/make_pilot.cpp') library("ramify") get_bandwidth <- function(alpha, beta, pilot) { return(alpha / pilot ^ beta) } roop_likelihoood_by_alpha <- function (beta, vec_alpha, pilot, dat) { dat <- sort(dat) discre_size = length(vec_alpha) n = length(dat) likelihood_by_alpha <- numeric(discre_size) for (i in 1:length(vec_alpha)) { bandwidth <- get_bandwidth(vec_alpha[i], beta, pilot) likelihood_by_alpha[i] <- CppLoglikelihood(dat, bandwidth, as.integer(n)) } return (likelihood_by_alpha) } argmax_logalpha_in_likelihood <- function (range_log_alpha, pilot, dat, discre_size, beta) { vec_logalpha = seq(range_log_alpha[1], range_log_alpha[2], length = discre_size + 1)[1:discre_size] vec_alpha = 10^vec_logalpha likelihood_by_alpha <- roop_likelihoood_by_alpha (beta, vec_alpha, pilot, dat) argmax = ramify::argmax(t(as.matrix(likelihood_by_alpha))) begin = NA; end = NA; l_alpha = length(likelihood_by_alpha) if (argmax == 1) { begin = 1; end=1; warning("range of alpha is not enough") } else if (argmax == l_alpha) { begin = l_alpha; end = l_alpha; warning("range of alpha is not enough") } else { begin = argmax - 1 end = argmax + 1 } return ( list ( argmax = argmax, max_alpha = vec_logalpha[argmax], range_log_alpha = c(vec_logalpha[begin], vec_logalpha[end]), likelihood = likelihood_by_alpha[argmax] ) ) } get_adeba_bandwidth <- function ( dat, range_log_alpha, vec_beta, discre_size1, discre_size2, alpha0, beta0 ) { pilot0 <- numeric(length(dat)) + alpha0 res1 <- argmax_logalpha_in_likelihood (range_log_alpha, pilot0, dat, discre_size1, beta0) res2 <- argmax_logalpha_in_likelihood (res1$range_log_alpha, pilot0, dat, discre_size2, beta0) argmax_alpha_result <- res2$argmax n <- length(dat) likelihood_by_beta <- numeric(length(vec_beta)) - Inf pilot1_prev <- numeric(n) alpha1 <- 10^res2$max_alpha for (i in 1:length(vec_beta)) { bandwidth <- get_bandwidth (alpha1, vec_beta[i], pilot0) pilot1 <- make_pilot(dat, bandwidth, as.integer(n)) res1 <- argmax_logalpha_in_likelihood (range_log_alpha, pilot1, dat, discre_size1, vec_beta[i]) res2 <- argmax_logalpha_in_likelihood (res1$range_log_alpha, pilot1, dat, discre_size2, vec_beta[i]) likelihood <- res2$likelihood likelihood_by_beta[i] <- likelihood alpha1 <- 10^res2$max_alpha argmax_beta <- ramify::argmax(t(as.matrix(likelihood_by_beta))) max_likelihood <- likelihood_by_beta[argmax_beta] beta1 <- vec_beta[ramify::argmax(t(as.matrix(likelihood_by_beta)))] if (max_likelihood != likelihood) { pilot1 <- pilot1_prev alpha1 <- alpha1_prev break } pilot1_prev <- pilot1 alpha1_prev <- alpha1 } bandwidth_result <- get_bandwidth(alpha1, beta1, pilot1) return (bandwidth_result) } kernel_density <- function (dat, bandwith, kernelFn, x = NULL, out = .1) { n <- length(dat) delta <- max(dat) - min(dat) if (is.null(x)) { x <- seq(min(dat) - delta * out, max(dat) + delta * out, length = 400) } y <- numeric(length(x)) for (i in 1:length(dat)) { if (bandwith[i] == Inf) next y <- y + 1 / n / bandwith[i] * kernelFn ((dat[i] - x) / bandwith[i]) } return(list(x = x, y = y)) } triweight <- function (u) { res <- numeric (length(u)) LogiAbsU <- abs(u) <= 1 res[LogiAbsU] <- 35 / 32 * (1 - u[LogiAbsU]^2)^3 return (res) } adeba_denstiy <- function ( dat, range_log_alpha = c(-6.0, 1.0), vec_beta = c(0.0, 0.5, 1.0, 1.5, 2.0), discre_size1 = 14, discre_size2 = 7, alpha0 = 1.0, beta0 = 0.01, x = NULL, out = .2 ) { dat <- sort(dat) mind <- min(dat) maxd <- max(dat) dat = (dat - mind) / (maxd - mind) bandwith <- get_adeba_bandwidth( dat, range_log_alpha, vec_beta, discre_size1, discre_size2, alpha0, beta0 ) normalize_dens <- kernel_density (dat, bandwith, triweight, x = x, out = out) nx <- normalize_dens$x ny <- normalize_dens$y x <- nx * (maxd - mind) + mind delta <- x[3] - x[2] sumP <- sum(ny) y <- ny / (sumP * delta) return (list(x=x,y=y)) } #plot(adeba_denstiy(dat))
(* Copyright 2016 University of Luxembourg This file is part of our formalization of Platzer's "A Complete Uniform Substitution Calculus for Differential Dynamic Logic" available here: http://arxiv.org/pdf/1601.06183.pdf (July 27, 2016). We refer to this formalization as DdlCoq here. DdlCoq 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. DdlCoq 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 DdlCoq. If not, see <http://www.gnu.org/licenses/>. authors: Vincent Rahli Marcus VΓΆlp Ivana Vukotic *) Require Export symbol. Require Export String. Require Export Reals. Require Export Coq.Lists.List. Export List.ListNotations. Require Vector. (** This file implements ddl syntax for Terms, Formulas, Hybrid programs and ODEs. This file is similar to expressions.v but instead of having several expression sorts, here we have only one reals (expression sorts seem to only be used to build tuples for n-ary functions anyway). This implementation works with functions with multiple arguments. *) (*This file is similar to sexpressions.v but instead of having only 1 parameter, functions can now have a multiple parameters. *) Inductive KTnum := | KTNnat (n : nat) : KTnum | KTNreal (r : R) : KTnum. (** Terms --- see Definition 1, Section 2.1 *) Inductive Term : Type := | KTdot (n : nat) : Term (* dot symbol for terms *) | KTfuncOf (f : FunctionSymbol) (n : nat) (a : Vector.t Term n) : Term (* application of function symbol *) | KTnumber (r : KTnum) : Term (* number constant *) | KTread (var : KAssignable) : Term (* read variable x or diff. symbol x' *) | KTneg (child : Term) : Term (* negation -x *) | KTplus (left right : Term) : Term (* addition x+y *) | KTminus (left right : Term) : Term (* subtraction x-y *) | KTtimes (left right : Term) : Term (* multiplication x*y *) | KTdifferential (child : Term) : Term (* differential x' *) . Coercion KTread : KAssignable >-> Term. Definition nat2term (n : nat) : Term := KTnumber (KTNnat n). Coercion nat2term : nat >-> Term. (* A couple of dummy terms *) Definition DTD : Term := KTdot 0. Definition DTN : Term := 0. (** Atomic ODE *) Inductive AtomicODE : Type := | ODEconst (name : ODEConst) : AtomicODE (* constant *) | ODEsing (xp : KAssignable) (e : Term) : AtomicODE (* x' = e *) . (** ODE *) Inductive ODE : Type := | ODEatomic (child : AtomicODE) : ODE | ODEprod (left righ : ODE) : ODE (* . , . *) . Coercion ODEatomic : AtomicODE >-> ODE. (** Formulas --- see Definition 2, Section 2.1 *) Inductive Formula : Type := | KFdot : Formula (* dot symbol for formulas *) | KFtrue : Formula (* true *) | KFfalse : Formula (* false *) | KFequal (left right : Term) : Formula (* x == y *) | KFnotequal (left right : Term) : Formula (* x != y *) | KFgreaterEqual(left right : Term) : Formula (* x >= y *) | KFgreater (left right : Term) : Formula (* x > y *) | KFlessEqual (left right : Term) : Formula (* x =< y *) | KFless (left right : Term) : Formula (* x < y *) | KFpredOf (f : PredicateSymbol) (n : nat) (a : Vector.t Term n) : Formula (* appliction of predicate symbol *) (* predicational or quantifier symbol applied to argument formula child *) | KFquantifier (f : QuantifierSymbol) (a : Formula) : Formula | KFnot (child : Formula) : Formula (* ~p *) | KFand (left right : Formula) : Formula (* p /\ q *) | KFor (left right : Formula) : Formula (* p \/ q *) | KFimply (left right : Formula) : Formula (* p -> q *) | KFequiv (left right : Formula) : Formula (* p <-> q *) (* quantifiers *) | KFforallVars (vars : list KVariable) (child : Formula) : Formula (* Forall x,y,z. p *) | KFexistsVars (vars : list KVariable) (child : Formula) : Formula (* Exists x,y,z. p *) (* modal formulas *) | KFbox (prog : Program) (child : Formula) : Formula (* [alpha] p *) | KFdiamond (prog : Program) (child : Formula) : Formula (* <alpha> p *) (** Hybrid programs --- see Definition 3, Section 2.1 *) with Program : Type := | KPconstant (name : ProgramConstName) : Program (* program constant e.g., alpha *) | KPassign (x : KAssignable) (e : Term) : Program (* x := e or x' := e *) | KPassignAny (x : KAssignable) : Program (* x := * or x' := * *) | KPtest (cond : Formula) : Program (* ?cond *) | KPchoice (left : Program)(right : Program) : Program (* alpha u beta *) | KPcompose (left : Program)(right : Program) : Program (* alpha ; beta *) | KPloop (child : Program) : Program (* alpha* *) | KPodeSystem (ode : ODE) (constraint : Formula) : Program . (** In order to prove properties for Box and Diamond we have to combine definitions for Formulas and Programs *) Scheme Formula_ind_2 := Induction for Formula Sort Prop with Program_ind_2 := Induction for Program Sort Prop. Combined Scheme Formula_Program_multind from Formula_ind_2, Program_ind_2. Scheme Formula_rec_2 := Induction for Formula Sort Type with Program_rec_2 := Induction for Program Sort Type. (** expressions of dL *) Inductive Expression : Type := | term : Term -> Expression (* terms *) | program : Program -> Expression (* programs *) | formula : Formula -> Expression (* formulas *) .
State Before: p : Prop h : Decidable p q : Prop ⊒ (if p then False else q) = (¬p ∧ q) State After: no goals Tactic: by_cases p <;> simp [h]
/- Copyright (c) 2022 James Gallicchio. Authors: James Gallicchio -/ import LeanColls.Classes import LeanColls.List.Basic namespace LeanColls /-! Definition of toList in terms of a fold. Used to define correctness for [Foldable] and [Foldable'] -/ def canonicalToList (fold : {Ξ² : Type w} β†’ (Ξ² β†’ Ο„ β†’ Ξ²) β†’ Ξ² β†’ Ξ²) : List Ο„ := fold (Ξ» acc x => acc ++ [x]) [] namespace Foldable class Correct (C) (Ο„ : outParam _) extends Foldable C Ο„ where foldCorrect : βˆ€ {Ξ²} (c : C) (f : Ξ² β†’ Ο„ β†’ Ξ²) acc, fold c f acc = ( canonicalToList (fold c) |>.foldl f acc) theorem fold_pair [F : Foldable.Correct C Ο„] (f₁ : β₁ β†’ Ο„ β†’ β₁) (acc₁ : β₁) (fβ‚‚ : Ξ²β‚‚ β†’ Ο„ β†’ Ξ²β‚‚) (accβ‚‚ : Ξ²β‚‚) (c : C) : F.fold c (Ξ» (acc₁,accβ‚‚) x => (f₁ acc₁ x, fβ‚‚ accβ‚‚ x)) (acc₁, accβ‚‚) = (F.fold c (Ξ» acc₁ x => f₁ acc₁ x) acc₁, F.fold c (Ξ» accβ‚‚ x => fβ‚‚ accβ‚‚ x) accβ‚‚) := by let list := canonicalToList (F.fold c) suffices List.foldl (Ξ» (acc₁,accβ‚‚) x => (f₁ acc₁ x, fβ‚‚ accβ‚‚ x)) (acc₁, accβ‚‚) list = (List.foldl (Ξ» acc₁ x => f₁ acc₁ x) acc₁ list, List.foldl (Ξ» accβ‚‚ x => fβ‚‚ accβ‚‚ x) accβ‚‚ list) by simp at this simp [←F.foldCorrect] at this exact this induction list generalizing acc₁ accβ‚‚ with | nil => simp [List.foldl] | cons x xs ih => simp apply ih end Foldable namespace Foldable' class Correct (C) (Ο„ : outParam _) (M : outParam (Membership Ο„ C)) extends Foldable.Correct C Ο„, Foldable' C Ο„ M where memCorrect : βˆ€ x (c : C), x ∈ c ↔ x ∈ canonicalToList (fold c) fold'Correct : βˆ€ {Ξ²} (c : C) (f : Ξ² β†’ (x : Ο„) β†’ x ∈ c β†’ Ξ²) acc, fold' c f acc = ( canonicalToList (fold c) |>.foldl' (Ξ» acc x h => f acc x ((memCorrect x c).mpr h)) acc) theorem fold_eq_fold' [M : Membership Ο„ C] [F : Foldable'.Correct C Ο„ M] (c : C) (f : Ξ² β†’ Ο„ β†’ Ξ²) (acc : Ξ²) : F.fold c f acc = F.fold' c (Ξ» acc x _ => f acc x) acc := by rw [F.foldCorrect] rw [F.fold'Correct] simp [canonicalToList, List.foldl_eq_foldl'] theorem fold'_append_singleton_eq_map [M : Membership Ο„ C] [Foldable'.Correct C Ο„ M] (c : C) (f : (x : Ο„) β†’ x ∈ c β†’ Ο„') : Foldable'.Correct.fold' c (Ξ» acc x h => acc ++ [f x h]) [] = (canonicalToList (Foldable.fold c) |>.map' (fun x h => f x ((Foldable'.Correct.memCorrect _ _).mpr h))) := by rw [Correct.fold'Correct] rw [List.foldl'_eq_subtypeByMem_foldl] rw [List.map', List.foldl_eq_map] theorem fold_canonicalToList_fold'_eq_fold' [Foldable'.Correct C Ο„ M] (c : C) (f' : (x : Ο„) β†’ M.mem x c β†’ Ο„') (f : Ξ² β†’ Ο„' β†’ Ξ²) (acc) : List.foldl f acc (canonicalToList (fun f init => Foldable'.Correct.fold' c (fun acc x h => f acc (f' x h)) init )) = Foldable'.Correct.fold' c (fun acc x h => f acc (f' x h)) acc := by simp [canonicalToList] rw [fold'_append_singleton_eq_map] rw [List.map', List.foldl_map, Foldable'.Correct.fold'Correct, List.foldl'_eq_subtypeByMem_foldl] theorem canonicalToList_fold'_eq_map' [Foldable'.Correct C Ο„ M] (c : C) (f' : (x : Ο„) β†’ M.mem x c β†’ Ο„') : canonicalToList (fun f init => Foldable'.Correct.fold' c (fun acc x h => f acc (f' x h)) init ) = (canonicalToList (Foldable.fold c)).map' (fun x h => f' x ((Foldable'.Correct.memCorrect _ _).mpr h)) := by conv => lhs simp [canonicalToList] rw [Correct.fold'Correct] rw [List.foldl'_eq_subtypeByMem_foldl] rw [List.foldl_eq_map]
/- Copyright (c) 2022 Jun Yoshida. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. -/ import Mathlib.Data.List.Basic namespace List universe u v w theorem map_comp {Ξ± : Type u} {Ξ² : Type v} {Ξ³ : Type w} (g : Ξ² β†’ Ξ³) (f : Ξ± β†’ Ξ²) : βˆ€ {as : List Ξ±}, map (g∘ f) as = map g (as.map f) := by intro as induction as case nil => rfl case cons a as h_ind => dsimp [map] rw [h_ind] theorem join_append {Ξ± : Type u} : βˆ€ (ass bss : List (List Ξ±)), (ass ++ bss).join = ass.join ++ bss.join | [], bss => rfl | (as::ass), bss => by dsimp [join] rw [List.append_assoc, join_append ass bss] theorem join_join {Ξ± : Type u} : βˆ€ (asss : List (List (List Ξ±))), asss.join.join = (asss.map join).join | [] => rfl | cons as asss => by dsimp [join] rw [join_append, join_join asss] theorem map_join {Ξ± : Type u} {Ξ² : Type v} (f : Ξ± β†’ Ξ²) : βˆ€ {ass : List (List Ξ±)}, map f ass.join = join (map (map f) ass) | [] => rfl | (as::ass) => by dsimp [join] rw [map_append, map_join f (ass:=ass)] end List
How often have you walked through Davis and asked yourself, damn, what is that nasty funk? Davis is full of many mysterious odors, luckily not too many are of Tabatha the Titan titanic proportions. Cumbleberry Trees explain the semenlike odor in parts of Downtown. Essence of Davis describes the large scale odors found throughout town, e.g., the dung smell emanating from The Dairy. The giant piles of green waste in front of large apartment complexes reek of rotting vegetation in the hot summer months. Each of the many Town Flora contributes its own unique scent. Near the northern part of Central Park Central Parks parking lot, there is a faint smell of cumin. This seems to be due to the wood chips in the playground. The area of Haring Hall near 2205 Haring 2205 often smells bad, likely due to the adjacent mouse factory. Riding ones Bicycles bicycle home around supper time often gives the rider a glorious sample of what others are having for dinner. Around the end of May and beginning of June, strong smell of flowers especially around 3rd Street and C Street Many places around town have bushes that smell like wet dog.
/- Copyright (c) 2020 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import algebra.star.algebra import algebra.algebra.ordered import analysis.special_functions.pow /-! # The Clauser-Horne-Shimony-Holt inequality and Tsirelson's inequality. We establish a version of the Clauser-Horne-Shimony-Holt (CHSH) inequality (which is a generalization of Bell's inequality). This is a foundational result which implies that quantum mechanics is not a local hidden variable theory. As usually stated the CHSH inequality requires substantial language from physics and probability, but it is possible to give a statement that is purely about ordered `*`-algebras. We do that here, to avoid as many practical and logical dependencies as possible. Since the algebra of observables of any quantum system is an ordered `*`-algebra (in particular a von Neumann algebra) this is a strict generalization of the usual statement. Let `R` be a `*`-ring. A CHSH tuple in `R` consists of * four elements `Aβ‚€ A₁ Bβ‚€ B₁ : R`, such that * each `Aα΅’` and `Bβ±Ό` is a self-adjoint involution, and * the `Aα΅’` commute with the `Bβ±Ό`. The physical interpretation is that the four elements are observables (hence self-adjoint) that take values Β±1 (hence involutions), and that the `Aα΅’` are spacelike separated from the `Bβ±Ό` (and hence commute). The CHSH inequality says that when `R` is an ordered `*`-ring (that is, a `*`-ring which is ordered, and for every `r : R`, `0 ≀ star r * r`), which is moreover *commutative*, we have `Aβ‚€ * Bβ‚€ + Aβ‚€ * B₁ + A₁ * Bβ‚€ - A₁ * B₁ ≀ 2` On the other hand, Tsirelson's inequality says that for any ordered `*`-ring we have `Aβ‚€ * Bβ‚€ + Aβ‚€ * B₁ + A₁ * Bβ‚€ - A₁ * B₁ ≀ 2√2` (A caveat: in the commutative case we need 2⁻¹ in the ring, and in the noncommutative case we need √2 and √2⁻¹. To keep things simple we just assume our rings are ℝ-algebras.) The proofs I've seen in the literature either assume a significant framework for quantum mechanics, or assume the ring is a `C^*`-algebra. In the `C^*`-algebra case, the order structure is completely determined by the `*`-algebra structure: `0 ≀ A` iff there exists some `B` so `A = star B * B`. There's a nice proof of both bounds in this setting at https://en.wikipedia.org/wiki/Tsirelson%27s_bound The proof given here is purely algebraic. ## Future work One can show that Tsirelson's inequality is tight. In the `*`-ring of n-by-n complex matrices, if `A ≀ Ξ» I` for some `Ξ» : ℝ`, then every eigenvalue has absolute value at most `Ξ»`. There is a CHSH tuple in 4-by-4 matrices such that `Aβ‚€ * Bβ‚€ + Aβ‚€ * B₁ + A₁ * Bβ‚€ - A₁ * B₁` has `2√2` as an eigenvalue. ## References * [Clauser, Horne, Shimony, Holt, *Proposed experiment to test local hidden-variable theories*][zbMATH06785026] * [Bell, *On the Einstein Podolsky Rosen Paradox*][MR3790629] * [Tsirelson, *Quantum generalizations of Bell's inequality*][MR577178] -/ universes u /-- A CHSH tuple in a `star_monoid R` consists of 4 self-adjoint involutions `Aβ‚€ A₁ Bβ‚€ B₁` such that the `Aα΅’` commute with the `Bβ±Ό`. The physical interpretation is that `Aβ‚€` and `A₁` are a pair of boolean observables which are spacelike separated from another pair `Bβ‚€` and `B₁` of boolean observables. -/ @[nolint has_inhabited_instance] structure is_CHSH_tuple {R} [monoid R] [star_monoid R] (Aβ‚€ A₁ Bβ‚€ B₁ : R) := (Aβ‚€_inv : Aβ‚€^2 = 1) (A₁_inv : A₁^2 = 1) (Bβ‚€_inv : Bβ‚€^2 = 1) (B₁_inv : B₁^2 = 1) (Aβ‚€_sa : star Aβ‚€ = Aβ‚€) (A₁_sa : star A₁ = A₁) (Bβ‚€_sa : star Bβ‚€ = Bβ‚€) (B₁_sa : star B₁ = B₁) (Aβ‚€Bβ‚€_commutes : Aβ‚€ * Bβ‚€ = Bβ‚€ * Aβ‚€) (Aβ‚€B₁_commutes : Aβ‚€ * B₁ = B₁ * Aβ‚€) (A₁Bβ‚€_commutes : A₁ * Bβ‚€ = Bβ‚€ * A₁) (A₁B₁_commutes : A₁ * B₁ = B₁ * A₁) variables {R : Type u} /-- Given a CHSH tuple (Aβ‚€, A₁, Bβ‚€, B₁) in a *commutative* ordered `*`-algebra over ℝ, `Aβ‚€ * Bβ‚€ + Aβ‚€ * B₁ + A₁ * Bβ‚€ - A₁ * B₁ ≀ 2`. (We could work over β„€[β…Ÿ2] if we wanted to!) -/ lemma CHSH_inequality_of_comm [ordered_comm_ring R] [star_ordered_ring R] [algebra ℝ R] [ordered_module ℝ R] (Aβ‚€ A₁ Bβ‚€ B₁ : R) (T : is_CHSH_tuple Aβ‚€ A₁ Bβ‚€ B₁) : Aβ‚€ * Bβ‚€ + Aβ‚€ * B₁ + A₁ * Bβ‚€ - A₁ * B₁ ≀ 2 := begin let P := (2 - Aβ‚€ * Bβ‚€ - Aβ‚€ * B₁ - A₁ * Bβ‚€ + A₁ * B₁), have i₁ : 0 ≀ P, { have idem : P * P = 4 * P, { -- If we had a GrΓΆbner basis algorithm, this would be trivial. -- Without one, it is somewhat tedious! dsimp [P], simp only [add_mul, mul_add, sub_mul, mul_sub, mul_comm, mul_assoc, add_assoc], repeat { conv in (Bβ‚€ * (Aβ‚€ * Bβ‚€)) { rw [T.Aβ‚€Bβ‚€_commutes, ←mul_assoc Bβ‚€ Bβ‚€ Aβ‚€, ←sq, T.Bβ‚€_inv, one_mul], } }, repeat { conv in (Bβ‚€ * (A₁ * Bβ‚€)) { rw [T.A₁Bβ‚€_commutes, ←mul_assoc Bβ‚€ Bβ‚€ A₁, ←sq, T.Bβ‚€_inv, one_mul], } }, repeat { conv in (B₁ * (Aβ‚€ * B₁)) { rw [T.Aβ‚€B₁_commutes, ←mul_assoc B₁ B₁ Aβ‚€, ←sq, T.B₁_inv, one_mul], } }, repeat { conv in (B₁ * (A₁ * B₁)) { rw [T.A₁B₁_commutes, ←mul_assoc B₁ B₁ A₁, ←sq, T.B₁_inv, one_mul], } }, conv in (Aβ‚€ * (Bβ‚€ * (Aβ‚€ * B₁))) { rw [←mul_assoc, T.Aβ‚€Bβ‚€_commutes, mul_assoc, ←mul_assoc Aβ‚€, ←sq, T.Aβ‚€_inv, one_mul], }, conv in (Aβ‚€ * (B₁ * (Aβ‚€ * Bβ‚€))) { rw [←mul_assoc, T.Aβ‚€B₁_commutes, mul_assoc, ←mul_assoc Aβ‚€, ←sq, T.Aβ‚€_inv, one_mul], }, conv in (A₁ * (Bβ‚€ * (A₁ * B₁))) { rw [←mul_assoc, T.A₁Bβ‚€_commutes, mul_assoc, ←mul_assoc A₁, ←sq, T.A₁_inv, one_mul], }, conv in (A₁ * (B₁ * (A₁ * Bβ‚€))) { rw [←mul_assoc, T.A₁B₁_commutes, mul_assoc, ←mul_assoc A₁, ←sq, T.A₁_inv, one_mul], }, simp only [←sq, T.Aβ‚€_inv, T.A₁_inv], simp only [mul_comm A₁ Aβ‚€, mul_comm B₁ Bβ‚€, mul_left_comm A₁ Aβ‚€, mul_left_comm B₁ Bβ‚€, mul_left_comm Bβ‚€ Aβ‚€, mul_left_comm Bβ‚€ A₁, mul_left_comm B₁ Aβ‚€, mul_left_comm B₁ A₁], norm_num, simp only [mul_comm _ (2 : R), mul_comm _ (4 : R), mul_left_comm _ (2 : R), mul_left_comm _ (4 : R)], abel, simp only [neg_mul_eq_neg_mul_symm, mul_one, int.cast_bit0, one_mul, int.cast_one, gsmul_eq_mul, int.cast_neg], simp only [←mul_assoc, ←add_assoc], norm_num, }, have idem' : P = (1 / 4 : ℝ) β€’ (P * P), { have h : 4 * P = (4 : ℝ) β€’ P := by simp [algebra.smul_def], rw [idem, h, ←mul_smul], norm_num, }, have sa : star P = P, { dsimp [P], simp only [star_add, star_sub, star_mul, star_bit0, star_one, T.Aβ‚€_sa, T.A₁_sa, T.Bβ‚€_sa, T.B₁_sa, mul_comm Bβ‚€, mul_comm B₁], }, rw idem', conv_rhs { congr, skip, congr, rw ←sa, }, convert smul_le_smul_of_nonneg (star_mul_self_nonneg : 0 ≀ star P * P) _, { simp, }, { apply_instance, }, { norm_num, }, }, apply le_of_sub_nonneg, simpa only [sub_add_eq_sub_sub, ←sub_add] using i₁, end /-! We now prove some rather specialized lemmas in preparation for the Tsirelson inequality, which we hide in a namespace as they are unlikely to be useful elsewhere. -/ local notation `√2` := (real.sqrt 2 : ℝ) namespace tsirelson_inequality /-! Before proving Tsirelson's bound, we prepare some easy lemmas about √2. -/ -- This calculation, which we need for Tsirelson's bound, -- defeated me. Thanks for the rescue from Shing Tak Lam! lemma tsirelson_inequality_aux : √2 * √2 ^ 3 = √2 * (2 * √2⁻¹ + 4 * (√2⁻¹ * 2⁻¹)) := begin ring_nf, rw [mul_assoc, inv_mul_cancel, real.sqrt_eq_rpow, ←real.rpow_nat_cast, ←real.rpow_mul], { norm_num, rw show (2 : ℝ) ^ (2 : ℝ) = (2 : ℝ) ^ (2 : β„•), by { rw ←real.rpow_nat_cast, norm_num }, norm_num }, { norm_num, }, { norm_num, }, end lemma sqrt_two_inv_mul_self : √2⁻¹ * √2⁻¹ = (2⁻¹ : ℝ) := by { rw [←mul_inv'], norm_num, } end tsirelson_inequality open tsirelson_inequality /-- In a noncommutative ordered `*`-algebra over ℝ, Tsirelson's bound for a CHSH tuple (Aβ‚€, A₁, Bβ‚€, B₁) is `Aβ‚€ * Bβ‚€ + Aβ‚€ * B₁ + A₁ * Bβ‚€ - A₁ * B₁ ≀ 2^(3/2) β€’ 1`. We prove this by providing an explicit sum-of-squares decomposition of the difference. (We could work over `β„€[2^(1/2), 2^(-1/2)]` if we really wanted to!) -/ lemma tsirelson_inequality [ordered_ring R] [star_ordered_ring R] [algebra ℝ R] [ordered_module ℝ R] [star_algebra ℝ R] (Aβ‚€ A₁ Bβ‚€ B₁ : R) (T : is_CHSH_tuple Aβ‚€ A₁ Bβ‚€ B₁) : Aβ‚€ * Bβ‚€ + Aβ‚€ * B₁ + A₁ * Bβ‚€ - A₁ * B₁ ≀ √2^3 β€’ 1 := begin -- abel will create `β„€` multiplication. We will `simp` them away to `ℝ` multiplication. have M : βˆ€ (m : β„€) (a : ℝ) (x : R), m β€’ a β€’ x = ((m : ℝ) * a) β€’ x := Ξ» m a x, by rw [gsmul_eq_smul_cast ℝ, ← mul_smul], let P := √2⁻¹ β€’ (A₁ + Aβ‚€) - Bβ‚€, let Q := √2⁻¹ β€’ (A₁ - Aβ‚€) + B₁, have w : √2^3 β€’ 1 - Aβ‚€ * Bβ‚€ - Aβ‚€ * B₁ - A₁ * Bβ‚€ + A₁ * B₁ = √2⁻¹ β€’ (P^2 + Q^2), { dsimp [P, Q], -- distribute out all the powers and products appearing on the RHS simp only [sq, sub_mul, mul_sub, add_mul, mul_add, smul_add, smul_sub], -- pull all coefficients out to the front, and combine `√2`s where possible simp only [algebra.mul_smul_comm, algebra.smul_mul_assoc, ←mul_smul, sqrt_two_inv_mul_self], -- replace Aα΅’ * Aα΅’ = 1 and Bα΅’ * Bα΅’ = 1 simp only [←sq, T.Aβ‚€_inv, T.A₁_inv, T.Bβ‚€_inv, T.B₁_inv], -- move Aα΅’ to the left of Bα΅’ simp only [←T.Aβ‚€Bβ‚€_commutes, ←T.Aβ‚€B₁_commutes, ←T.A₁Bβ‚€_commutes, ←T.A₁B₁_commutes], -- collect terms, simplify coefficients, and collect terms again: abel, -- all terms coincide, but the last one. Simplify all other terms simp only [M], simp only [neg_mul_eq_neg_mul_symm, int.cast_bit0, one_mul, mul_inv_cancel_of_invertible, int.cast_one, one_smul, int.cast_neg, add_right_inj, neg_smul, ← add_smul], -- just look at the coefficients now: congr, exact mul_left_cancel' (by norm_num) tsirelson_inequality_aux, }, have pos : 0 ≀ √2⁻¹ β€’ (P^2 + Q^2), { have P_sa : star P = P, { dsimp [P], simp only [star_smul, star_add, star_sub, star_id_of_comm, T.Aβ‚€_sa, T.A₁_sa, T.Bβ‚€_sa, T.B₁_sa], }, have Q_sa : star Q = Q, { dsimp [Q], simp only [star_smul, star_add, star_sub, star_id_of_comm, T.Aβ‚€_sa, T.A₁_sa, T.Bβ‚€_sa, T.B₁_sa], }, have P2_nonneg : 0 ≀ P^2, { rw [sq], conv { congr, skip, congr, rw ←P_sa, }, convert (star_mul_self_nonneg : 0 ≀ star P * P), }, have Q2_nonneg : 0 ≀ Q^2, { rw [sq], conv { congr, skip, congr, rw ←Q_sa, }, convert (star_mul_self_nonneg : 0 ≀ star Q * Q), }, convert smul_le_smul_of_nonneg (add_nonneg P2_nonneg Q2_nonneg) (le_of_lt (show 0 < √2⁻¹, by norm_num)), -- `norm_num` can't directly show `0 ≀ √2⁻¹` simp, }, apply le_of_sub_nonneg, simpa only [sub_add_eq_sub_sub, ←sub_add, w] using pos, end
using GridGames @gridgame( name=:Tac, grid=(3,3), players=[:X,:O], actions=[ (3,1), (3,2), (3,3), (2,1), (2,2), (2,3), (1,1), (1,2), (1,3), ], pieces=[:X,:O], ) function Tac() board = emptyboard(Tac) player = getplayer(Tac, :X) states = [TacState(board,player)] Tac([],[],states) end function GridGames.getnextstate(s::TacState, a::TacAction) next_state = TacState( copy(s.board), getnexttoplay(s) ) next_state[a.key...] = getpieceidx(Tac, s.to_play.name) next_state end function GridGames.getlegalactions(s::TacState) if isgamewon(s) return [] end map( cell->getaction(s,(cell.row,cell.col)), emptycells(s) ) end function GridGames.getwinner(s::TacState) function getwinner(cells) piece = getmatchingpiece(s, cells) if !isnothing(piece) return getplayer(s, piece) end nothing end tests = [] append!(tests, [s[row, 1:3] for row in 1:3]) append!(tests, [s[1:3, col] for col in 1:3]) push!(tests, [s[1,1], s[2,2], s[3,3]]) push!(tests, [s[3,1], s[2,2], s[1,3]]) for test in tests player = getwinner(test) if !isnothing(player) return player end end nothing end
section \<open>Set Interface\<close> theory IICF_Set imports "../../Sepref" begin subsection \<open>Operations\<close> definition [simp]: "op_set_is_empty s \<equiv> s={}" lemma op_set_is_empty_param[param]: "(op_set_is_empty,op_set_is_empty)\<in>\<langle>A\<rangle>set_rel \<rightarrow> bool_rel" by auto context notes [simp] = IS_LEFT_UNIQUE_def (* Argh, the set parametricity lemmas use single_valued (K\<inverse>) here. *) begin sepref_decl_op set_empty: "{}" :: "\<langle>A\<rangle>set_rel" . sepref_decl_op (no_def) set_is_empty: op_set_is_empty :: "\<langle>A\<rangle>set_rel \<rightarrow> bool_rel" . sepref_decl_op set_member: "(\<in>)" :: "A \<rightarrow> \<langle>A\<rangle>set_rel \<rightarrow> bool_rel" where "IS_LEFT_UNIQUE A" "IS_RIGHT_UNIQUE A" . sepref_decl_op set_insert: Set.insert :: "A \<rightarrow> \<langle>A\<rangle>set_rel \<rightarrow> \<langle>A\<rangle>set_rel" where "IS_RIGHT_UNIQUE A" . sepref_decl_op set_delete: "\<lambda>x s. s - {x}" :: "A \<rightarrow> \<langle>A\<rangle>set_rel \<rightarrow> \<langle>A\<rangle>set_rel" where "IS_LEFT_UNIQUE A" "IS_RIGHT_UNIQUE A" . sepref_decl_op set_union: "(\<union>)" :: "\<langle>A\<rangle>set_rel \<rightarrow> \<langle>A\<rangle>set_rel \<rightarrow> \<langle>A\<rangle>set_rel" . sepref_decl_op set_inter: "(\<inter>)" :: "\<langle>A\<rangle>set_rel \<rightarrow> \<langle>A\<rangle>set_rel \<rightarrow> \<langle>A\<rangle>set_rel" where "IS_LEFT_UNIQUE A" "IS_RIGHT_UNIQUE A" . sepref_decl_op set_diff: "(-) ::_ set \<Rightarrow> _" :: "\<langle>A\<rangle>set_rel \<rightarrow> \<langle>A\<rangle>set_rel \<rightarrow> \<langle>A\<rangle>set_rel" where "IS_LEFT_UNIQUE A" "IS_RIGHT_UNIQUE A" . sepref_decl_op set_subseteq: "(\<subseteq>)" :: "\<langle>A\<rangle>set_rel \<rightarrow> \<langle>A\<rangle>set_rel \<rightarrow> bool_rel" where "IS_LEFT_UNIQUE A" "IS_RIGHT_UNIQUE A" . sepref_decl_op set_subset: "(\<subset>)" :: "\<langle>A\<rangle>set_rel \<rightarrow> \<langle>A\<rangle>set_rel \<rightarrow> bool_rel" where "IS_LEFT_UNIQUE A" "IS_RIGHT_UNIQUE A" . (* TODO: We may want different operations here: pick with predicate returning option, pick with remove, ... *) sepref_decl_op set_pick: "RES" :: "[\<lambda>s. s\<noteq>{}]\<^sub>f \<langle>K\<rangle>set_rel \<rightarrow> K" by auto end (* TODO: Set-pick. Move from where it is already defined! *) subsection \<open>Patterns\<close> lemma pat_set[def_pat_rules]: "{} \<equiv> op_set_empty" "(\<in>) \<equiv> op_set_member" "Set.insert \<equiv> op_set_insert" "(\<union>) \<equiv> op_set_union" "(\<inter>) \<equiv> op_set_inter" "(-) \<equiv> op_set_diff" "(\<subseteq>) \<equiv> op_set_subseteq" "(\<subset>) \<equiv> op_set_subset" by (auto intro!: eq_reflection) lemma pat_set2[pat_rules]: "(=) $s${} \<equiv> op_set_is_empty$s" "(=) ${}$s \<equiv> op_set_is_empty$s" "(-) $s$(Set.insert$x${}) \<equiv> op_set_delete$x$s" "SPEC$(\<lambda>\<^sub>2x. (\<in>) $x$s) \<equiv> op_set_pick s" "RES$s \<equiv> op_set_pick s" by (auto intro!: eq_reflection) locale set_custom_empty = fixes empty and op_custom_empty :: "'a set" assumes op_custom_empty_def: "op_custom_empty = op_set_empty" begin sepref_register op_custom_empty :: "'ax set" lemma fold_custom_empty: "{} = op_custom_empty" "op_set_empty = op_custom_empty" "mop_set_empty = RETURN op_custom_empty" unfolding op_custom_empty_def by simp_all end end
lemma emeasure_lborel_cbox_finite: "emeasure lborel (cbox a b) < \<infinity>"