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 & 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>" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.