text
stringlengths 0
3.34M
|
---|
(* Default settings (from HsToCoq.Coq.Preamble) *)
Generalizable All Variables.
Unset Implicit Arguments.
Set Maximal Implicit Insertion.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Require Coq.Program.Tactics.
Require Coq.Program.Wf.
(* Converted imports: *)
Require GHC.Base.
Import GHC.Base.Notations.
(* No type declarations to convert. *)
(* Converted value declarations: *)
Fixpoint isSubsequenceOf {a} `{(GHC.Base.Eq_ a)} (arg_0__ arg_1__ : list a)
: bool
:= match arg_0__, arg_1__ with
| nil, _ => true
| _, nil => false
| (cons x a' as a), cons y b =>
if x GHC.Base.== y : bool then isSubsequenceOf a' b else
isSubsequenceOf a b
end.
(* External variables:
bool cons false list nil true GHC.Base.Eq_ GHC.Base.op_zeze__
*)
|
(* Title: HOL/Proofs/ex/Proof_Terms.thy
Author: Makarius
Basic examples involving proof terms.
*)
theory Proof_Terms
imports MainRLT
begin
text \<open>
Detailed proof information of a theorem may be retrieved as follows:
\<close>
lemma ex: "A \<and> B \<longrightarrow> B \<and> A"
proof
assume "A \<and> B"
then obtain B and A ..
then show "B \<and> A" ..
qed
ML_val \<open>
val thm = @{thm ex};
(*proof body with digest*)
val body = Proofterm.strip_thm_body (Thm.proof_body_of thm);
(*proof term only*)
val prf = Proofterm.proof_of body;
(*clean output*)
Pretty.writeln (Proof_Syntax.pretty_standard_proof_of \<^context> false thm);
Pretty.writeln (Proof_Syntax.pretty_standard_proof_of \<^context> true thm);
(*all theorems used in the graph of nested proofs*)
val all_thms =
Proofterm.fold_body_thms
(fn {name, ...} => insert (op =) name) [body] [];
\<close>
text \<open>
The result refers to various basic facts of Isabelle/HOL: @{thm [source]
HOL.impI}, @{thm [source] HOL.conjE}, @{thm [source] HOL.conjI} etc. The
combinator \<^ML>\<open>Proofterm.fold_body_thms\<close> recursively explores the graph of
the proofs of all theorems being used here.
\<^medskip>
Alternatively, we may produce a proof term manually, and turn it into a
theorem as follows:
\<close>
ML_val \<open>
val thy = \<^theory>;
val prf =
Proof_Syntax.read_proof thy true false
"impI \<cdot> _ \<cdot> _ \<bullet> \
\ (\<^bold>\<lambda>H: _. \
\ conjE \<cdot> _ \<cdot> _ \<cdot> _ \<bullet> H \<bullet> \
\ (\<^bold>\<lambda>(H: _) Ha: _. conjI \<cdot> _ \<cdot> _ \<bullet> Ha \<bullet> H))";
val thm =
Proofterm.reconstruct_proof thy \<^prop>\<open>A \<and> B \<longrightarrow> B \<and> A\<close> prf
|> Proof_Checker.thm_of_proof thy
|> Drule.export_without_context;
\<close>
end
|
$SVUNIT_INSTALL/test/sim_9/module_in_my_filelist.sv
|
#include <math.h>
#include <stdio.h>
#include <gsl/gsl_rng.h>
#include "matrix_operations.c"
#include "ellipse/parametric_function_roots.c"
#include "polynomial.c"
void characteristic_ellipse_matrix(double *X, double *R, double phi, double exponent)
{
// rotation matrix
double Q[2][2] = {{ 0 }};
double Qt[2][2] = {{ 0 }};
Q[0][0] = cos(phi);
Q[0][1] = sin(phi);
Q[1][0] = -sin(phi);
Q[1][1] = cos(phi);
matrix_transpose(&Qt[0][0], &Q[0][0], 2, 2);
// radii matrix
double O[2][2] = {{ 0 }};
double diag_vals[2];
diag_vals[0] = pow(R[0], exponent * -2.0);
diag_vals[1] = pow(R[1], exponent * -2.0);
set_diagonal(&O[0][0], diag_vals, 2, 2);
// characteristic ellipse matrix
double X_temp[2][2] = {{ 0 }};
matrix_multiply(&X_temp[0][0], &O[0][0], &Q[0][0], 2, 2, 2);
matrix_multiply(X, &Qt[0][0], &X_temp[0][0], 2, 2, 2);
}
double ellipse_overlap(double *rA, double *radiiA, double phiA, double *rB, double *radiiB, double phiB)
{
// find XA^(-1) and XB^(1/2)
double XA[2][2] = {{ 0 }};
double XB[2][2] = {{ 0 }};
characteristic_ellipse_matrix(&XA[0][0], &radiiA[0], phiA, -1.0);
characteristic_ellipse_matrix(&XB[0][0], &radiiB[0], phiB, 0.5);
// find A_AB
double A_AB[2][2] = {{ 0 }};
double A_temp[2][2] = {{ 0 }};
matrix_multiply(&A_temp[0][0], &XA[0][0], &XB[0][0], 2, 2, 2);
matrix_multiply(&A_AB[0][0], &XB[0][0], &A_temp[0][0], 2, 2, 2);
// find r_AB
double rAB[2];
rAB[0] = rB[0] - rA[0];
rAB[1] = rB[1] - rA[1];
// find a_AB
double a_AB[2];
matrix_multiply(&a_AB[0], &XB[0][0], &rAB[0], 2, 2, 1);
// extract elements of the matrix A_AB and a_AB
double a11, a12, a21, a22;
double b1, b2;
a11 = A_AB[0][0];
a12 = A_AB[0][1];
a21 = A_AB[1][0];
a22 = A_AB[1][1];
b1 = a_AB[0];
b2 = a_AB[1];
// find coefficients for the parametric polynomial derivative used to find max
double h[5];
double z[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
size_t n = 5;
h[0] = h0(a11, a12, a21, a22, b1, b2);
h[1] = h1(a11, a12, a21, a22, b1, b2);
h[2] = h2(a11, a12, a21, a22, b1, b2);
h[3] = h3(a11, a12, a21, a22, b1, b2);
h[4] = h4(a11, a12, a21, a22, b1, b2);
// find roots
size_t m;
m = find_roots(&z[0], &h[0], n);
double F;
int i;
if (m > 1)
{
if (f(0, a11, a12, a21, a22, b1, b2) > f(1, a11, a12, a21, a22, b1, b2))
{
F = f(0, a11, a12, a21, a22, b1, b2);
}
else
{
F = f(1, a11, a12, a21, a22, b1, b2);
}
for(i=0; i<=m-2; i++)
{
if (( z[2 * i + 1] == 0 ) & (z[2 * i] > 0) & (z[2 * i] < 1))
{
F = f(z[2 * i], a11, a12, a21, a22, b1, b2);
}
}
}
else
{
F = 0.;
}
return F;
}
double container_square_overlap_potential(double *rA, double *radiiA, double phiA)
{
double rB[2];
double radiiB[2];
double phiB;
double top = 0;
double bottom = 0;
double left = 0;
double right = 0;
// top
rB[0] = 0.5;
rB[1] = 2.0;
radiiB[0] = INFINITY;
radiiB[1] = 1.0;
phiB = 0.0;
top = ellipse_overlap(&rA[0], &radiiA[0], phiA, &rB[0], &radiiB[0], phiB);
// bottom
rB[0] = 0.5;
rB[1] = -1.0;
radiiB[0] = INFINITY;
radiiB[1] = 1.0;
phiB = 0.0;
bottom = ellipse_overlap(&rA[0], &radiiA[0], phiA, &rB[0], &radiiB[0], phiB);
// left
rB[0] = -1.0;
rB[1] = 0.5;
radiiB[0] = 1.0;
radiiB[1] = INFINITY;
phiB = 0.0;
left = ellipse_overlap(&rA[0], &radiiA[0], phiA, &rB[0], &radiiB[0], phiB);
// right
rB[0] = 2.0;
rB[1] = 0.5;
radiiB[0] = 1.0;
radiiB[1] = INFINITY;
phiB = 0.0;
right = ellipse_overlap(&rA[0], &radiiA[0], phiA, &rB[0], &radiiB[0], phiB);
return fminf(top, fminf(bottom, fminf(left, right)));
}
size_t rsa_align_square(double *x, double *y,
size_t npoints, double *radius, double phi, int step_limit,
unsigned long randSeed)
{
// Setup GSL random number generator
const gsl_rng_type * T;
gsl_rng * r;
T = gsl_rng_default;
r = gsl_rng_alloc (T);
// Set the seed
// srand ( time(NULL) );
// unsigned long randSeed = rand();
gsl_rng_set(r, randSeed);
// arrays for overlap_potential functions
double rA[2];
double rB[2];
double radiiA[2];
double radiiB[2];
double F;
double xn = 0.;
double yn = 0.;
radiiA[0] = radius[0];
radiiA[1] = radius[1];
// Set the initial position
double C;
C = fmaxf(radius[0], radius[1]);
F = 0;
while (F < 1.)
{
xn = gsl_rng_uniform (r);
yn = gsl_rng_uniform (r);
rA[0] = xn;
rA[1] = yn;
F = container_square_overlap_potential(&rA[0], &radiiA[0], phi);
}
x[0] = xn;
y[0] = yn;
size_t valid_pts;
int k, flag, step;
step = 0;
valid_pts = 1;
while ((valid_pts < npoints) & (step < step_limit))
{
// Generate new ellipse inside the container
F = 0;
while (F < 1.)
{
xn = gsl_rng_uniform (r);
yn = gsl_rng_uniform (r);
rA[0] = xn;
rA[1] = yn;
F = container_square_overlap_potential(&rA[0], &radiiA[0], phi);
}
// Determine if new ellipse overlaps with existing ellipses
flag = 1;
for (k = 0; k < valid_pts; k++)
{
rA[0] = x[k];
rA[1] = y[k];
rB[0] = xn;
rB[1] = yn;
radiiA[0] = radius[0];
radiiA[1] = radius[1];
radiiB[0] = radius[0];
radiiB[1] = radius[1];
F = ellipse_overlap(&rA[0], &radiiA[0], phi, &rB[0], &radiiB[0], phi);
if (F < 1.0)
{
flag = 0;
break;
}
}
if (flag == 1)
{
x[valid_pts] = xn;
y[valid_pts] = yn;
valid_pts += 1;
}
step += 1;
}
gsl_rng_free (r);
return valid_pts;
}
size_t rsa_square(double *x, double *y,
size_t npoints, double *radius, double *phi, int step_limit,
unsigned long randSeed)
{
// Setup GSL random number generator
const gsl_rng_type * T;
gsl_rng * r;
T = gsl_rng_default;
r = gsl_rng_alloc (T);
// Set the seed
// srand ( time(NULL) );
// unsigned long randSeed = rand();
gsl_rng_set(r, randSeed);
// arrays for overlap_potential functions
double rA[2];
double rB[2];
double radiiA[2];
double radiiB[2];
double phiA;
double phiB;
double F;
double xn = 0;
double yn = 0;
double phin = 0;
radiiA[0] = radius[0];
radiiA[1] = radius[1];
// Set the initial position
double C;
C = fmaxf(radius[0], radius[1]);
F = 0;
while (F < 1.)
{
xn = gsl_rng_uniform (r);
yn = gsl_rng_uniform (r);
rA[0] = xn;
rA[1] = yn;
phiA = 2 * M_PI * gsl_rng_uniform (r);
F = container_square_overlap_potential(&rA[0], &radiiA[0], phiA);
}
x[0] = xn;
y[0] = yn;
phi[0] = phiA;
size_t valid_pts;
int k, flag, step;
step = 0;
valid_pts = 1;
while ((valid_pts < npoints) & (step < step_limit))
{
// Generate new ellipse inside the container
F = 0;
while (F < 1.)
{
xn = gsl_rng_uniform (r);
yn = gsl_rng_uniform (r);
phin = 2 * M_PI * gsl_rng_uniform (r);
rA[0] = xn;
rA[1] = yn;
phiA = phin;
F = container_square_overlap_potential(&rA[0], &radiiA[0], phiA);
}
// Determine if new ellipse overlaps with existing ellipses
flag = 1;
for (k = 0; k < valid_pts; k++)
{
rA[0] = x[k];
rA[1] = y[k];
phiA = phi[k];
rB[0] = xn;
rB[1] = yn;
phiB = phin;
radiiA[0] = radius[0];
radiiA[1] = radius[1];
radiiB[0] = radius[0];
radiiB[1] = radius[1];
F = ellipse_overlap(&rA[0], &radiiA[0], phiA, &rB[0], &radiiB[0], phiB);
if (F < 1.0)
{
flag = 0;
break;
}
}
if (flag == 1)
{
x[valid_pts] = xn;
y[valid_pts] = yn;
phi[valid_pts] = phin;
valid_pts += 1;
}
step += 1;
}
gsl_rng_free (r);
return valid_pts;
} |
# Note that this script can accept some limited command-line arguments, run
# `julia build_tarballs.jl --help` to see a usage message.
using BinaryBuilder, Pkg
name = "LASzip"
version = v"3.4.3"
# Collection of sources required to complete build
sources = [
GitSource("https://github.com/LASzip/LASzip.git", "1ab671e42ff1f086e29d5b7e300a5026e7b8d69b")
]
# Bash recipe for building across all platforms
script = raw"""
cd $WORKSPACE/srcdir
# Patch to find unordered_map from tr1, logic there doesn't work for MINGW32.
if [[ "${target}" == *-mingw* ]]; then
sed -i '/add_definitions(-DUNORDERED)/d' LASzip/src/CMakeLists.txt;
fi
mkdir LASzip/build
cd LASzip/build/
cmake -DCMAKE_INSTALL_PREFIX=$prefix -DCMAKE_CXX_FLAGS="-std=c++11" -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_VERBOSE_MAKEFILE=OFF ..
cmake --build . --target install --config Release
"""
# These are the platforms we will build for by default, unless further
# platforms are passed in on the command line
platforms = supported_platforms()
# The products that we will ensure are always built
products = [
LibraryProduct(["liblaszip", "liblaszip3"], :liblaszip)
]
# Dependencies that must be installed before this package can be built
dependencies = Dependency[
]
# Build the tarballs, and possibly a `build.jl` as well.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies)
|
/*
* Copyright (c) 2010-2018 Wave Computing, Inc. and its applicable licensors.
* All rights reserved; provided, that any files identified as open source shall
* be governed by the specific open source license(s) applicable to such files.
*
* For any files associated with distributions under the Apache 2.0 license,
* full attribution to The Apache Software Foundation is given via the license
* below.
*/
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/op_kernel.h"
#include "tensorflow/core/framework/types.h"
#include "tensorflow/core/framework/node_def.pb.h"
#include <stdlib.h>
#include <assert.h>
#include <string>
#include <iostream>
#include <vector>
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
#include "dfx_op_base.h"
#include "dfx_registry.h"
#define USE_VECTOR_INSTRUCTIONS
#if defined(USE_VECTOR_INSTRUCTIONS)
#include <emmintrin.h>
#include <tmmintrin.h>
#endif
using namespace tensorflow;
class RandomGenerator
{
public:
static RandomGenerator& Instance() {
static RandomGenerator s;
return s;
}
std::mt19937 & get() {
return mt;
}
private:
RandomGenerator() {
std::random_device rd;
mt.seed(rd());
}
~RandomGenerator() {}
std::mt19937 mt;
};
// Constructor will read all provided attributes and bind them to the I/O
// indexes. Note that these attributes must exist in the OpDef or else this
// code asserts (intentional).
WaveDynFxPointOp::WaveDynFxPointOp(OpKernelConstruction* ctx,
const StringVec& attrs)
: OpKernel(ctx), m_iLookup(ctx->num_inputs()), m_oLookup(ctx->num_outputs()), m_use_stochastic_round(false)
{
for (auto a : attrs) {
bool isInput;
int index;
if (!get_iospec(a, isInput, index)) {
continue;
}
string attrVal;
OP_REQUIRES_OK(ctx, ctx->GetAttr(a, &attrVal));
if (isInput) {
assert(index < ctx->num_inputs());
m_iLookup[index] = attrVal;
} else {
assert(index < ctx->num_outputs());
m_oLookup[index] = attrVal;
}
}
}
string WaveDynFxPointOp::get_vp_key(bool isInput, int n) const
{
std::string lName;
if (isInput) {
assert(n < m_iLookup.size());
lName = m_iLookup[n];
} else {
assert(n < m_oLookup.size());
lName = m_oLookup[n];
}
return lName;
}
// Gets the Dynamic Fixed Point for a given I/O. This function finds the key associated
// with this I/O, then looks up the BP associated with the key. If no generator
// is found, it will return an uninitialized BP, which the caller should handle
// appropriately. This ususally means the caller is free to assign an ideal BP.
fxbp WaveDynFxPointOp::get_fxbp(bool isInput, int n) const
{
std::string lName = get_vp_key(isInput, n);
// If the string is empty, nobody has registered this BP. If so, return
// an uninitialized fxbp.
if (lName.size() == 0) {
return fxbp();
}
// Test to see if the BP is static.
fxbp bp;
if (get_static_bp(lName, bp)) {
assert(bp.m_initialized);
return bp;
}
// See if there is a registered BP assignment.
if (get_dynamic_bp(lName, bp)) {
assert(bp.m_initialized);
return bp;
}
// If nothing matches, return the uninitialized BP.
assert(!bp.m_initialized);
return bp;
}
// Helper function to map attribute names to I/O.
bool WaveDynFxPointOp::get_iospec(const std::string& attr, bool& isInput, int& n)
{
assert(attr.size() > 0);
// Parse the attr
auto a0 = boost::algorithm::find_first(attr, "bp_");
if (a0.begin() == attr.end()) {
return false;
}
const char ioType = *(a0.end());
isInput = (ioType == 'i');
std::string::const_iterator a1 = a0.end() + 1;
// We will use the IO index without checking the actual index limit.
n = boost::lexical_cast<int>(*a1);
return true;
}
// This helper function parses an attribute. If the attribute encodes a
// static binary point, it will return it in an fxbp object.
bool WaveDynFxPointOp::get_static_bp(const string& attr, fxbp& bp) const
{
// This code assumes encoded attributes are well-formed.
// TODO: add warning/error.
if (attr.front() != '(' || attr.back() != ')') {
return false;
}
std::vector<std::string> params;
boost::split(params, attr, boost::is_any_of("(,)"));
if (params.size() != 4) {
return false;
}
bp = fxbp(boost::lexical_cast<int>(params[2]),
boost::lexical_cast<int>(params[1]));
return true;
}
// This helper function parses an attribute. If the attribute encodes a
// reference to a dynamic binary point, it will return it in an fxbp object.
bool WaveDynFxPointOp::get_dynamic_bp(const string& attr, fxbp& bp) const
{
// Consult the registry to get Tensor ref from name.
const DynFxPointRegistry* reg = DynFxPointRegistry::get_registry();
const Tensor* t = reg->find_dfx(attr);
if (!t) {
return false;
}
assert(t);
assert(t->dims() == 1);
assert(t->dim_size(0) == 2);
assert(DataTypeIsInteger(t->dtype()));
// Copy the tensor data into an fxbp object.
const auto a = t->flat<int32>();
// Tensor: [WL, BP] - Constructor: (BP, WL)
bp = fxbp(a(1), a(0));
return true;
}
void WaveDynFxPointOp::partial_in(fxbp& dest_bp, WaveDynFxPointOp::DFXVector& m_out,
const float* flat_arr)
{
if (dest_bp.m_bp == -1 || !dest_bp.m_initialized) {
dest_bp.set_range_fp(flat_arr, flat_arr + m_out.size());
}
for (int i = 0; i < m_out.size(); i++) {
m_out[i].set_fxbp(dest_bp);
m_out[i] = flat_arr[i];
}
}
void WaveDynFxPointOp::partial_out(fxbp& out_bp, float* conv_out,
const WaveDynFxPointOp::DFXVector& m_out)
{
if (out_bp.m_bp == -1 || !out_bp.m_initialized) {
out_bp.set_range_dfx(m_out.data(), m_out.data()+m_out.size());
}
DynFxPoint v(out_bp);
if (m_use_stochastic_round) { // stochastic rounding
for (int i = 0; i < m_out.size(); i++) {
v.set_bits(stochastic_rounding(m_out[i].get_value(), out_bp.m_bp - m_out[i].get_fxbp().m_bp));
conv_out[i] = v.to_fp();
}
} else { // convergent rounding
for (int i = 0; i < m_out.size(); i++) {
v = m_out[i];
conv_out[i] = v.to_fp();
}
}
}
void WaveDynFxPointOp::partial_in(fxbp& dest_bp, int32_t* m_out, const float* flat_arr, int n)
{
if (dest_bp.m_bp == -1 || !dest_bp.m_initialized) {
dest_bp.set_range_fp(flat_arr, flat_arr + n);
}
float k = (float)(1 << dest_bp.m_bp);
#if defined(USE_VECTOR_INSTRUCTIONS)
__m128 xk = _mm_set1_ps(k);
for (int i = 0; i < n>>2; i++) {
__m128i xv;
__m128 xf;
xf = _mm_loadu_ps(flat_arr);
xf = _mm_mul_ps(xf, xk);
xf = _mm_round_ps(xf, _MM_FROUND_TO_NEAREST_INT|_MM_FROUND_NO_EXC);
xv = _mm_cvtps_epi32(xf);
_mm_store_si128((__m128i *)m_out, xv);
flat_arr += 4;
m_out += 4;
}
for (int i = 0; i < (n&3); i++)
*m_out++ = (int32_t)roundf(*flat_arr++ * k);
#else
for (int i = 0; i < n; i++)
*m_out++ = (int32_t)roundf(*flat_arr++ * k);
#endif
}
void WaveDynFxPointOp::partial_out(fxbp& out_bp, float* conv_out, const int32_t* m_out, int32_t src_bp, int n)
{
if (out_bp.m_bp == -1 || !out_bp.m_initialized) {
out_bp.set_range_int32(m_out, m_out + n, src_bp);
}
float k = 1.0f / (1 << out_bp.m_bp);
if (out_bp.m_bp >= src_bp) {
int32_t shift = out_bp.m_bp - src_bp;
#if defined(USE_VECTOR_INSTRUCTIONS)
__m128 xk = _mm_set1_ps(k);
for (int i = 0; i < n>>2; i++) {
__m128i xv;
__m128 xf;
xv = _mm_load_si128((__m128i*)m_out);
xv = _mm_slli_epi32(xv, shift);
xf = _mm_cvtepi32_ps(xv);
xf = _mm_mul_ps(xf, xk);
_mm_storeu_ps(conv_out, xf);
m_out += 4;
conv_out += 4;
}
for (int i = 0; i < (n&3); i++) {
int32_t v;
v = *m_out++;
// convert bp
v <<= shift;
*conv_out++ = v * k;
}
#else
for (int i = 0; i < n; i++) {
int32_t v;
v = *m_out++;
// convert bp
v <<= shift;
*conv_out++ = v * k;
}
#endif
} else {
int32_t r;
int32_t shift = src_bp - out_bp.m_bp;
if (m_use_stochastic_round) { // stochastic rounding
int32_t round;
#if defined(USE_VECTOR_INSTRUCTIONS)
std::mt19937 &mt = RandomGenerator::Instance().get();
std::uniform_int_distribution<unsigned int> dist(0, UINT_MAX);
uint32_t rnd[4];
rnd[0] = dist(mt); // random seed
rnd[1] = dist(mt);
rnd[2] = dist(mt);
rnd[3] = dist(mt);
__m128i xrnd = _mm_load_si128((__m128i*)rnd);
__m128i xc1 = _mm_set1_epi32(1664525);
__m128i xc2 = _mm_set1_epi32(1013904223);
__m128 xk = _mm_set1_ps(k);
for (int i = 0; i < n>>2; i++) {
__m128i xv, xr;
__m128 xf;
xv = _mm_load_si128((__m128i*)m_out);
xr = _mm_srli_epi32(xrnd, 32 - shift);
xv = _mm_add_epi32(xv, xr);
xv = _mm_srai_epi32(xv, shift);
xf = _mm_cvtepi32_ps(xv);
xrnd = _mm_mullo_epi32(xrnd, xc1);
xrnd = _mm_add_epi32(xrnd, xc2);
xf = _mm_mul_ps(xf, xk);
_mm_storeu_ps(conv_out, xf);
m_out += 4;
conv_out += 4;
}
_mm_store_si128((__m128i*)rnd, xrnd);
for (int i = 0; i < (n&3); i++) {
int32_t v;
v = *m_out++;
// convert bp
round = rnd[0] >> (32 - shift);
v = (v + round) >> shift;
// linear congruential RNG from
// numerical recipes
rnd[0] = rnd[0] * 1664525 + 1013904223;
*conv_out++ = v * k;
}
#else
std::mt19937 &mt = RandomGenerator::Instance().get();
std::uniform_int_distribution<unsigned int> dist(0, UINT_MAX);
uint32_t rnd = dist(mt); // random seed
for (int i = 0; i < n; i++) {
int32_t v;
v = m_out[i];
// convert bp
round = rnd >> (32 - shift);
v = (v + round) >> shift;
rnd = rnd * 1664525 + 1013904223;
conv_out[i] = v * k;
}
#endif
} else { // convergent rounding
int32_t round = 1 << (shift - 1);
int32_t mask = (round << 1) - 1;
#if defined(USE_VECTOR_INSTRUCTIONS)
__m128i xmask = _mm_set1_epi32(mask);
__m128i xround = _mm_set1_epi32(round);
__m128i xone = _mm_set1_epi32(1);
__m128 xk = _mm_set1_ps(k);
for (int i = 0; i < n>>2; i++) {
__m128i xv, xr;
__m128 xf;
xv = _mm_load_si128((__m128i*)m_out);
xr = _mm_and_si128(xv, xmask);
xv = _mm_add_epi32(xv, xround);
xv = _mm_srai_epi32(xv, shift);
xr = _mm_cmpeq_epi32(xr, xround);
xr = _mm_sub_epi32(xr, xone);
xv = _mm_and_si128(xv, xr);
xf = _mm_cvtepi32_ps(xv);
xf = _mm_mul_ps(xf, xk);
_mm_storeu_ps(conv_out, xf);
m_out += 4;
conv_out += 4;
}
for (int i = 0; i < (n&3); i++) {
int32_t v;
v = *m_out++;
// convert bp
r = v & mask;
v = (v + round) >> shift;
if (r == round)
v &= ~1;
*conv_out++ = v * k;
}
#else
for (int i = 0; i < n; i++) {
int32_t v;
v = *m_out++;
// convert bp
r = v & mask;
v = (v + round) >> shift;
if (r == round)
v &= ~1;
*conv_out++ = v * k;
}
#endif
}
}
}
void WaveDynFxPointOp::partial_out(float* conv_out, const int32_t* m_out, int src_bp, int n)
{
float k = 1.0f / (1 << src_bp);
#if defined(USE_VECTOR_INSTRUCTIONS)
__m128 xk = _mm_set1_ps(k);
for (int i = 0; i < n>>2; i++) {
__m128i xv;
__m128 xf;
xv = _mm_load_si128((__m128i*)m_out);
xf = _mm_cvtepi32_ps(xv);
xf = _mm_mul_ps(xf, xk);
_mm_storeu_ps(conv_out, xf);
m_out += 4;
conv_out += 4;
}
for (int i = 0; i < (n&3); i++)
*conv_out++ = *m_out++ * k;
#else
for (int i = 0; i < n; i++)
*conv_out++ = *m_out++ * k;
#endif
}
// Computes the assigned rounding for value v with rounded bits r.
int32_t WaveDynFxPointOp::stochastic_rounding(int32_t v, int32_t r)
{
int64_t nv = v;
// Positive diffs shift left.
if (r >= 0) {
nv = nv << r;
} else {
// This will be compiled as an arithmetic shift (due to sign).
nv = nv >> (-r);
int32_t round_mask = (1 << (-r)) - 1;
int32_t rv = v & round_mask;
std::mt19937 &mt = RandomGenerator::Instance().get();
std::uniform_int_distribution<unsigned int> dist(0, UINT_MAX);
uint32_t rand_num = (dist(mt) >> (32+r)) & round_mask;
nv += rand_num < rv ? 1 : 0;
}
// Saturation check
// return sat_eval(nv);
return nv;
}
|
module Issue4260.M where
postulate
F : Set → Set
syntax F X = G X
|
program ifst;
{sample25}
var
ch
:
char;
begin readln(ch);
if ch = 'a' then writeln('It is ''a'' ')else writeln('It is not ''a'' ')
end.
|
Set Warnings "-notation-overridden,-parsing".
Require Import Program.Basics.
Require Import FunctionalExtensionality.
Require Import Strings.String.
Require Import Sect2.
(********************************)
(* Towards More Abstract Lenses *)
(********************************)
(* Isomorphism between `MonadState A (state S)` and `lens S A` *)
Definition ms_2_lens {S A} (ms : MonadState A (state S)) : lens S A :=
{| view s := evalState get s
; update s a := execState (put a) s
|}.
Instance lens_2_ms {S A} (ln : lens S A) : MonadState A (state S) :=
{ get := mkState (fun s => (view ln s, s))
; put a := mkState (fun s => (tt, update ln s a))
}.
Lemma MonadState_state_s_induces_lens :
forall {S A : Type} (ms : MonadState A (state S)),
@MonadStateLaws A (state S) _ _ ms -> lensLaws (ms_2_lens ms).
Proof.
intros.
unfold ms_2_lens.
assert (F : forall s, put (evalState get s) = get >> put (evalState get s)).
{ intros.
rewrite <- (non_eff_get (put (evalState get s))).
now rewrite (general_getget (fun _ => put (evalState get s))). }
destruct H.
constructor; intros; simpl.
- (* view_update *)
rewrite F.
rewrite <- execexec_is_execgtgt.
rewrite execevalexec_is_execbind.
now rewrite get_put.
- (* update_view *)
rewrite execeval_is_evalgtgt.
rewrite put_get.
now rewrite eval_ma_gtgt_retx_is_x.
- (* updte_update *)
rewrite execexec_is_execgtgt.
now rewrite put_put.
Qed.
Lemma lens_induces_MonadState_state_s :
forall {S A : Type} (ln : lens S A),
lensLaws ln -> @MonadStateLaws A (state S) _ _ (lens_2_ms ln).
Proof.
intros.
destruct H.
split;
simpl;
intros;
repeat state_reason;
[rewrite view_update | rewrite update_view | rewrite update_update];
auto.
Qed.
Proposition ms_iso_lens :
forall {S A} (ln : lens S A) (ms : MonadState A (state S)),
lensLaws ln ->
@MonadStateLaws _ _ _ _ ms ->
((ms_2_lens ∘ lens_2_ms) ln = ln) /\
((lens_2_ms ∘ ms_2_lens) ms = ms).
Proof.
unfold ms_2_lens. unfold lens_2_ms.
unfold compose.
intros.
split; simpl.
- (* ms_2_lens ∘ lens_2_ms *)
destruct ln.
auto.
- (* lens_2_ms ∘ ms_2_lens *)
assert (G0 : (fun s : S => (evalState get s, s)) =
(fun s : S => (evalState get s, execState get s))).
{ functional_extensionality_i.
apply f_equal.
now rewrite get_leaves_s_as_is. }
rewrite G0.
destruct ms.
simpl.
assert (G1 :
{| runState := fun s : S => (evalState get s, execState get s) |} = get).
{ destruct get.
unfold evalState. unfold execState.
unwrap_layer.
simpl.
now destruct (runState x). }
rewrite G1.
assert (G2 :
(fun a : A => {| runState := fun s : S => (tt, execState (put a) s) |}) = put).
{ functional_extensionality_i.
destruct (put x).
unwrap_layer.
unfold execState.
simpl.
destruct (runState x0).
now destruct u. }
now rewrite G2.
Qed.
(* Lens Algebra definition, just a record *)
Record lensAlg (p : Type -> Type) (A : Type) `{M : Monad p} : Type :=
{ view : p A
; update : A -> p unit
; modify (f : A -> A) : p unit := view >>= (update ∘ f)
}.
Arguments view [p A _ _].
Arguments update [p A _ _].
Arguments modify [p A _ _].
Notation "ln %~ f" := (modify ln f) (at level 40, no associativity).
Record lensAlgLaws {p A} `{Monad p} (ln : lensAlg p A) : Type :=
{ view_view : view ln >>= (fun s1 => view ln >>= (fun s2 => ret (s1, s2))) =
view ln >>= (fun s => ret (s, s))
; view_update : view ln >>= update ln = ret tt
; update_view : forall s, update ln s >> view ln = update ln s >> ret s
; update_update : forall s1 s2, update ln s1 >> update ln s2 = update ln s2
}.
Lemma general_viewview :
forall {p : Type -> Type} {A X : Type}
`{ml : MonadLaws p}
(ln : lensAlg p A)
(lnl : lensAlgLaws ln)
(k : A * A -> p X),
view ln >>= (fun x1 => view ln >>= (fun x2 => k (x1, x2))) =
view ln >>= (fun x1 => k (x1, x1)).
Proof.
intros.
destruct ml.
destruct lnl.
assert (G : view ln >>= (fun x1 : A => k (x1, x1)) =
view ln >>= (fun x1 : A => ret (x1, x1) >>= k)).
{ unwrap_layer. now rewrite left_id. }
rewrite G.
rewrite <- assoc.
rewrite <- view_view0.
rewrite -> assoc.
unwrap_layer.
rewrite -> assoc.
unwrap_layer.
now rewrite left_id.
Qed.
Lemma non_eff_view :
forall {p : Type -> Type} {A}
`{ml : MonadLaws p}
(ln : lensAlg p A)
(lnl : lensAlgLaws ln)
{X}
(k : p X),
view ln >> k = k.
Proof.
intros.
pose proof (@general_viewview p A X H _ ml ln lnl) as J.
destruct ml.
destruct lnl.
rewrite <- (left_id unit _ tt (fun _ => k)).
rewrite <- view_update0.
repeat rewrite assoc.
now rewrite (J (fun pair => update ln (snd pair) >> k)).
Qed.
(* `MonadState_state` is isomorphic to `identityLn` *)
(* We only show one way, since the full isomorphism follows from the previous
proposition for the general case. *)
Corollary MonadState_state_is_identity_lens :
forall A, ms_2_lens MonadState_state = identityLn A.
Proof. auto. Qed.
(*************************)
(* University Data Layer *)
(*************************)
Record DepartmentAlg p Dep `{id : MonadState Dep p} :=
{ budgetLn : lensAlg p nat }.
Arguments budgetLn [p Dep _ _ id].
Record UniversityAlg p Univ `{id : MonadState Univ p} :=
{ nameLn : lensAlg p string
; q : Type -> Type
; Dep : Type
; fq : Functor q
; mq : Monad q
; msq : MonadState Dep q
; ev : DepartmentAlg q Dep
; mathDepLn : lensAlg p Dep
}.
Definition doubleDepBudget p Dep
`{MonadState Dep p}
(data : DepartmentAlg p Dep) : p unit :=
budgetLn data %~ (fun b => b * 2).
(* However, we can't implement an analogous for `duplicateUnivBudget`!!! *)
|
[GOAL]
p : ℕ
p_prime : Nat.Prime p
m n : ℤ
k l : ℕ
hpm : ↑(p ^ k) ∣ m
hpn : ↑(p ^ l) ∣ n
hpmn : ↑(p ^ (k + l + 1)) ∣ m * n
hpm' : p ^ k ∣ natAbs m
hpn' : p ^ l ∣ natAbs n
⊢ p ^ (k + l + 1) ∣ natAbs m * natAbs n
[PROOFSTEP]
rw [← Int.natAbs_mul]
[GOAL]
p : ℕ
p_prime : Nat.Prime p
m n : ℤ
k l : ℕ
hpm : ↑(p ^ k) ∣ m
hpn : ↑(p ^ l) ∣ n
hpmn : ↑(p ^ (k + l + 1)) ∣ m * n
hpm' : p ^ k ∣ natAbs m
hpn' : p ^ l ∣ natAbs n
⊢ p ^ (k + l + 1) ∣ natAbs (m * n)
[PROOFSTEP]
apply Int.coe_nat_dvd.1 <| Int.dvd_natAbs.2 hpmn
[GOAL]
p : ℕ
p_prime : Nat.Prime p
m n : ℤ
k l : ℕ
hpm : ↑(p ^ k) ∣ m
hpn : ↑(p ^ l) ∣ n
hpmn : ↑(p ^ (k + l + 1)) ∣ m * n
hpm' : p ^ k ∣ natAbs m
hpn' : p ^ l ∣ natAbs n
hpmn' : p ^ (k + l + 1) ∣ natAbs m * natAbs n
hsd : p ^ (k + 1) ∣ natAbs m ∨ p ^ (l + 1) ∣ natAbs n :=
Nat.succ_dvd_or_succ_dvd_of_succ_sum_dvd_mul p_prime hpm' hpn' hpmn'
hsd1 : p ^ (k + 1) ∣ natAbs m
⊢ ↑(p ^ (k + 1)) ∣ m
[PROOFSTEP]
apply Int.dvd_natAbs.1
[GOAL]
p : ℕ
p_prime : Nat.Prime p
m n : ℤ
k l : ℕ
hpm : ↑(p ^ k) ∣ m
hpn : ↑(p ^ l) ∣ n
hpmn : ↑(p ^ (k + l + 1)) ∣ m * n
hpm' : p ^ k ∣ natAbs m
hpn' : p ^ l ∣ natAbs n
hpmn' : p ^ (k + l + 1) ∣ natAbs m * natAbs n
hsd : p ^ (k + 1) ∣ natAbs m ∨ p ^ (l + 1) ∣ natAbs n :=
Nat.succ_dvd_or_succ_dvd_of_succ_sum_dvd_mul p_prime hpm' hpn' hpmn'
hsd1 : p ^ (k + 1) ∣ natAbs m
⊢ ↑(p ^ (k + 1)) ∣ ↑(natAbs m)
[PROOFSTEP]
apply Int.coe_nat_dvd.2 hsd1
[GOAL]
p : ℕ
p_prime : Nat.Prime p
m n : ℤ
k l : ℕ
hpm : ↑(p ^ k) ∣ m
hpn : ↑(p ^ l) ∣ n
hpmn : ↑(p ^ (k + l + 1)) ∣ m * n
hpm' : p ^ k ∣ natAbs m
hpn' : p ^ l ∣ natAbs n
hpmn' : p ^ (k + l + 1) ∣ natAbs m * natAbs n
hsd : p ^ (k + 1) ∣ natAbs m ∨ p ^ (l + 1) ∣ natAbs n :=
Nat.succ_dvd_or_succ_dvd_of_succ_sum_dvd_mul p_prime hpm' hpn' hpmn'
hsd2 : p ^ (l + 1) ∣ natAbs n
⊢ ↑(p ^ (l + 1)) ∣ n
[PROOFSTEP]
apply Int.dvd_natAbs.1
[GOAL]
p : ℕ
p_prime : Nat.Prime p
m n : ℤ
k l : ℕ
hpm : ↑(p ^ k) ∣ m
hpn : ↑(p ^ l) ∣ n
hpmn : ↑(p ^ (k + l + 1)) ∣ m * n
hpm' : p ^ k ∣ natAbs m
hpn' : p ^ l ∣ natAbs n
hpmn' : p ^ (k + l + 1) ∣ natAbs m * natAbs n
hsd : p ^ (k + 1) ∣ natAbs m ∨ p ^ (l + 1) ∣ natAbs n :=
Nat.succ_dvd_or_succ_dvd_of_succ_sum_dvd_mul p_prime hpm' hpn' hpmn'
hsd2 : p ^ (l + 1) ∣ natAbs n
⊢ ↑(p ^ (l + 1)) ∣ ↑(natAbs n)
[PROOFSTEP]
apply Int.coe_nat_dvd.2 hsd2
[GOAL]
p : ℕ
hp : Nat.Prime p
k : ℤ
h : ↑p ∣ k ^ 2
⊢ p ∣ natAbs k
[PROOFSTEP]
apply @Nat.Prime.dvd_of_dvd_pow _ _ 2 hp
[GOAL]
p : ℕ
hp : Nat.Prime p
k : ℤ
h : ↑p ∣ k ^ 2
⊢ p ∣ natAbs k ^ 2
[PROOFSTEP]
rwa [sq, ← natAbs_mul, ← coe_nat_dvd_left, ← sq]
|
#!/usr/bin/env python
# coding: utf-8
# In[1]:
#Testing reductions MPI simple version (two reductions)
# In[1]:
import logging
import numpy
from mpi4py import MPI
import astropy.units as u
from astropy.coordinates import SkyCoord
from data_models.polarisation import PolarisationFrame
from processing_library.image.operations import create_empty_image_like
from processing_library.image.operations import create_image_from_array
#from processing_components.image.operations import qa_image, show_image, export_image_to_fits
from processing_components.image.operations import qa_image
from processing_components.simulation.testing_support import create_test_image
from processing_components.image.gather_scatter import image_gather_facets, image_scatter_facets
from workflows.shared.imaging.imaging_shared import sum_invert_results_local, remove_sumwt
#from matplotlib import pyplot as plt
#from matplotlib import pylab
#pylab.rcParams['figure.figsize'] = (12.0, 12.0)
#pylab.rcParams['image.cmap'] = 'rainbow'
# In[2]:
# Define a simple function to take the square root of an image
def imagerooter(image_list) -> list():
new_image_list = []
for im in image_list:
newim = create_empty_image_like(im)
newim.data = numpy.sqrt(numpy.abs(im.data))
new_image_list.append(newim)
return new_image_list
# In[3]:
# Set up MPI
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
size = comm.Get_size()
#recvdata = numpy.zeros((2,size),dtype='i')
#recvdata = numpy.zeros((2,size),dtype=numpy.int)
#senddata = numpy.array([(rank+1)*numpy.arange(size,dtype='i'),(rank+1)*numpy.arange(size,dtype='i')])
#senddata = numpy.array([(rank+1)*numpy.arange(size,dtype=numpy.int),(rank+1)*numpy.arange(size,dtype=numpy.int)])
#print('%d:before Reduce: send data = '%rank)
#print(senddata)
#op_sum = MPI.Op.Create(fn_sum, commute=True)
# I have to create a datatype ???
#recvdata=comm.reduce(senddata,root=0,op=op_sum)
#print('%d:after Reduce: data = '%rank)
#print(recvdata)
# Create data
frequency = numpy.array([1e8])
phasecentre = SkyCoord(ra=+15.0 * u.deg, dec=-35.0 * u.deg, frame='icrs', equinox='J2000')
model = create_test_image(frequency=frequency, phasecentre=phasecentre, cellsize=0.001,
polarisation_frame=PolarisationFrame('stokesI'))
#print(model)
nchan, npol, ny, nx = model.data.shape
sumwt = numpy.ones([nchan, npol])
print('%d:before Reduce: data = '%rank)
print(sumwt)
#f=show_image(model, title='Model image', cm='Greys', vmax=1.0, vmin=-0.1)
print(qa_image(model, context='Model image'))
#plt.show()
# In[5]:
# Accum images into one with weights
result_image = create_empty_image_like(model)
comm.Reduce(model.data,result_image.data,root=0,op=MPI.SUM)
#f=show_image(result_image, title='Result image', cm='Greys', vmax=1.0, vmin=-0.1)
#plt.show()
if rank==0:
print('%d:after Reduce: data = '%rank)
print(qa_image(result_image,context='Result image'))
# test correctness
assert(result_image.data.shape==model.data.shape)
numpy.testing.assert_array_almost_equal_nulp(result_image.data,
(model.data)*size, 7)
# In[6]:
result_sumwt = numpy.zeros([nchan, npol])
comm.Reduce(sumwt,result_sumwt,root=0,op=MPI.SUM)
if rank==0:
print(result_sumwt)
numpy.testing.assert_array_almost_equal_nulp(result_sumwt,sumwt*size,7)
# In[ ]:
|
#include <stdio.h>
#include <gsl/gsl_sf_bessel.h>
int
main (void)
{
double x = 5.0;
double y = gsl_sf_bessel_J0 (x);
printf ("J0(%g) = %.18e\n", x, y);
return 0;
}
|
theory embedding_frames
imports embedding_shallow
begin
(*we introduce some default modalities and constraints*)
consts \<R>::"w\<Rightarrow>\<sigma>" (*binary accessibility relation*)
consts \<T>::"w\<Rightarrow>(w\<Rightarrow>\<sigma>)" (*ternary accessibility relation*)
(*for multi-modal logics we can provide the accessibility relation as a parameter*)
definition box::"\<sigma>\<Rightarrow>\<sigma>" ("\<box>_" [57]58) where "\<box>A \<equiv> \<lambda>w. \<forall>v. \<R> w v \<longrightarrow> A v"
definition dia::"\<sigma>\<Rightarrow>\<sigma>" ("\<diamond>_" [57]58) where "\<diamond>A \<equiv> \<lambda>w. \<exists>v. \<R> w v \<and> A v"
definition fusion::"\<sigma>\<Rightarrow>\<sigma>\<Rightarrow>\<sigma>" (infixr "\<otimes>" 80) where "A \<otimes> B \<equiv> \<lambda>x. (\<exists>y z. (\<T> y z x \<and> A y) \<and> B z)"
definition impl::"\<sigma>\<Rightarrow>\<sigma>\<Rightarrow>\<sigma>" (infixr "\<Rightarrow>" 80) where "A \<Rightarrow> B \<equiv> \<lambda>x. (\<forall>y z. (\<T> y x z \<and> A y) \<longrightarrow> B z)"
definition lpmi::"\<sigma>\<Rightarrow>\<sigma>\<Rightarrow>\<sigma>" (infixr "\<Leftarrow>" 80) where "B \<Leftarrow> A \<equiv> \<lambda>x. (\<forall>y z. (\<T> x y z \<and> A y) \<longrightarrow> B z)"
lemma assoc: "(A \<otimes> (B \<otimes> C)) = ((A \<otimes> B) \<otimes> C)" nitpick oops (*non assoc*)
lemma exchange: "(A \<otimes> B) = (B \<otimes> A)" nitpick oops (*non comm*)
lemma contraction: "(A \<otimes> A) = A" nitpick oops (*non idem*)
lemma lw: "(A \<otimes> B) \<subseteq> A" nitpick oops
lemma "A \<otimes> (A \<Rightarrow> B) \<subseteq> B" using impl_def fusion_def subset_def by fastforce
lemma "B \<subseteq> A \<Rightarrow> (A \<otimes> B)" using impl_def fusion_def subset_def by fastforce
lemma "(B \<Leftarrow> A) \<otimes> A \<subseteq> B" using fusion_def lpmi_def subset_def by fastforce
lemma "A \<subseteq> B \<and> C \<subseteq> D \<longrightarrow> A \<otimes> C \<subseteq> B \<otimes> D" by (smt (verit, del_insts) fusion_def subset_def)
lemma "A \<subseteq> B \<and> C \<subseteq> D \<longrightarrow> B \<Rightarrow> C \<subseteq> A \<Rightarrow> D" by (smt (verit, ccfv_SIG) impl_def subset_def)
lemma "A \<subseteq> B \<and> C \<subseteq> D \<longrightarrow> C \<Leftarrow> B \<subseteq> D \<Leftarrow> A" by (smt (verit, best) lpmi_def subset_def)
(*We can say of two unary operators \<phi> and \<psi> that they form an "adjoint" or "residuated" pair.
We then call \<phi> (\<psi>) the down (up) adjoint/residue to/of \<psi> (\<phi>).*)
definition Residuated::"\<sigma> Rel \<Rightarrow> (\<sigma>\<Rightarrow>\<sigma>)Rel" ("_-RESID")
where "R-RESID \<phi> \<psi> \<equiv> \<forall>A B. R (\<phi> A) B \<longleftrightarrow> R A (\<psi> B)"
(*We can express residuation for binary operators in two different flavours*)
abbreviation Residuated_left::"\<sigma> Rel \<Rightarrow> (\<sigma>\<Rightarrow>\<sigma>\<Rightarrow>\<sigma>)Rel" ("_-RESID\<^sup>l")
where "R-RESID\<^sup>l \<phi> \<psi> \<equiv> \<forall>A. R-RESID (\<phi> A) (\<psi> A)"
abbreviation Residuated_right::"\<sigma> Rel \<Rightarrow> (\<sigma>\<Rightarrow>\<sigma>\<Rightarrow>\<sigma>)Rel" ("_-RESID\<^sup>r")
where "R-RESID\<^sup>r \<phi> \<psi> \<equiv> \<forall>A. R-RESID (\<phi>\<^sup>T A) (\<psi>\<^sup>T A)"
lemma "R-RESID\<^sup>l \<phi> \<psi> = (\<forall>A B C. R (\<phi> A B) C \<longleftrightarrow> R B (\<psi> A C))" unfolding Residuated_def by simp
lemma "R-RESID\<^sup>r \<phi> \<psi> = (\<forall>A B C. R (\<phi> B A) C \<longleftrightarrow> R B (\<psi> C A))" unfolding Residuated_def by simp
(*For instance*)
lemma "(\<preceq>)-RESID\<^sup>l (\<inter>) (\<rightarrow>) \<longleftrightarrow> (A \<inter> B \<preceq> C \<longleftrightarrow> B \<preceq> A \<rightarrow> C)" by (smt (verit, best) Residuated_def base.impl_def inter_def subset_def)
lemma "(\<preceq>)-RESID\<^sup>r (\<leftharpoonup>) (\<union>) \<longleftrightarrow> (B \<leftharpoonup> A \<preceq> C \<longleftrightarrow> B \<preceq> C \<union> A)" by (smt (verit) Residuated_def diff_def subset_def union_def)
(*We have in fact*)
lemma "(\<preceq>)-RESID\<^sup>l (\<inter>) (\<rightarrow>)" by (smt (verit, ccfv_SIG) Residuated_def base.impl_def inter_def subset_def)
lemma "(\<preceq>)-RESID\<^sup>r (\<leftharpoonup>) (\<union>)" by (smt (verit, best) Residuated_def diff_def subset_def union_def)
(*And also*)
lemma "(\<preceq>)-RESID\<^sup>l (\<otimes>) (\<Rightarrow>)" by (smt (z3) Residuated_def impl_def fusion_def subset_def)
lemma "(\<preceq>)-RESID\<^sup>r (\<otimes>) (\<Leftarrow>)" by (smt (z3) Residuated_def fusion_def lpmi_def subset_def)
lemma "(\<Leftarrow>) = (\<Rightarrow>)\<^sup>T" nitpick oops
axiomatization
where assoc\<T>: "\<forall>x y z u. (\<exists>s. \<T> x y s \<and> \<T> s z u) \<longleftrightarrow> (\<exists>t. \<T> x t u \<and> \<T> y z t) "
lemma assoc: "(A \<otimes> (B \<otimes> C)) = ((A \<otimes> B) \<otimes> C)" unfolding fusion_def using assoc\<T> by fastforce (*assoc*)
axiomatization
where comm\<T>: "\<forall>x y u. \<T> x y u \<longleftrightarrow> (\<T> y x u) "
lemma exchange: "(A \<otimes> B) = (B \<otimes> A)" unfolding fusion_def by (meson comm\<T>)
lemma "(\<preceq>)-RESID\<^sup>r (\<otimes>) (\<Leftarrow>)" by (smt (z3) Residuated_def fusion_def lpmi_def subset_def)
lemma "(\<Leftarrow>) = (\<Rightarrow>)\<^sup>T" using comm\<T> impl_def lpmi_def by presburger
lemma contraction1: "(A \<otimes> A) \<subseteq> A" nitpick oops
lemma contraction2: "A \<subseteq> (A \<otimes> A)" nitpick oops
lemma lw: "(A \<otimes> B) \<subseteq> A" nitpick oops
definition par::"\<sigma>\<Rightarrow>\<sigma>\<Rightarrow>\<sigma>" (infixr "\<oplus>" 79) where "A \<oplus> B \<equiv> \<midarrow>(\<midarrow>A \<otimes> \<midarrow>B)"
lemma "A \<otimes> \<midarrow>A \<approx> \<emptyset>" nitpick oops
lemma "A \<oplus> \<midarrow>A \<approx> \<UU>" nitpick oops
end |
If you are thinking of moving to Sandhutton or just want to know a what the area is like, the statistics on this page should give you a good introduction. They cover a range of socio-economic factors so you can compare Sandhutton to figures for North Yorkshire and nationally. These statistics can tell you if Sandhutton is an economically deprived area and how hard it might be to get a job.
The respondents of the 2011 Census were asked to rate their health. These are the results for Sandhutton. The percentage of residents in Sandhutton rating their health as 'very good' is more than the national average. Also the percentage of residents in Sandhutton rating their health as 'very bad' is less than the national average, suggesting that the health of the residents of Sandhutton is generally better than in the average person in England.
These figures on the claiming of benefits in Sandhutton come from the Department for Work & Pensions and are dated . They can often be a good indicator of the prosperity of the town and possible indicator of how hard it would be to get employment in the area. The rate of unemployment in Sandhutton is both lower than the average for North Yorkshire and lower than the national average, suggesting that finding a job in this area maybe easier than most places. The rate of claiming any benefit (which includes in work benefits) is more than 10% lower in Sandhutton than the national average, suggesting higher salaries than the average in the area.
These statistics are for the highest level education obtained by the residents of Sandhutton and are from the UK Census of 2011. Sandhutton has a lower level of residents with either no qualifications or qualifications equal to 1 or more GCSE at grade D or below, than the national average. Sandhutton also has a high level of residents with a higher education qualification (level 4) than the national average, suggesting that the residents of Sandhutton are better educated than the average England citizen.
These figures for Country of Birth for the residents of Sandhutton are from the UK Census of 2011. Since Sandhutton has a higher level of residents born in the UK than the national average and a lower rate of residents either born in other EU countries or outside the EU, it does not have a significant immigrant population.
The population of Sandhutton as a whole, is older than the national average. The population of Sandhutton is also older than the North Yorkshire average, making Sandhutton a older persons location.
Do you live in Sandhutton? Let us know what you think in the comments below. |
/-
Copyright (c) 2022 Kevin Buzzard. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author : Kevin Buzzard
-/
import tactic -- imports all the Lean tactics
import data.real.basic -- imports the real numbers
/-!
# Doing algebra in the real numbers
The `ring` tactic will prove algebraic identities like
(x + y) ^ 2 = x ^ 2 + 2 * x * y + y ^ 2 in rings, and Lean
knows that the real numbers are a ring. See if you can use
`ring` to prove these theorems.
## New tactics you will need
* `ring`
* `intro` (new functionality: use on a goal of type `⊢ ∀ x, ...`)
-/
example (x y : ℝ) : (x + y) ^ 2 = x ^ 2 + 2 * x * y + y ^ 2 :=
begin
ring,
end
example : ∀ (a b : ℝ), ∃ x,
(a + b) ^ 3 = a ^ 3 + x * a ^ 2 * b + 3 * a * b ^ 2 + b ^ 3 :=
begin
intros a b,use 3, ring,
end
example : ∃ (x : ℝ), ∀ y, y + y = x * y :=
begin
use 2,intro y,ring,
end
example : ∀ (x : ℝ), ∃ y, x + y = 2 :=
begin
intro x,use 2-x,ring,
end
example : ∀ (x : ℝ), ∃ y, x + y ≠ 2 :=
begin
intro x, use -12-x,ring_nf,norm_num,
end
|
using GaussianProcessODEs
using Test
using LinearAlgebra
using KernelFunctions
@testset "cholmod" begin
n = 30
A = rand(n,n)
A = A*A'
Ach = cholesky(A)
k = rand(1:n)
# k = 4
c = rand(n)
c = c ./(4*norm(c))
c[k] = 1
Ah = deepcopy(A)
Ah[k, :] = c
Ah[:, k] = c
if !isposdef(Ah)
println("Randomly generated a bad c (modified A not pos def), test will fail")
end
Bch = deepcopy(Ach)
# Bch = Cholesky(Ach.L, :L, 0)
Bch2 = cholmod(Bch, c, k)
cholmod!(Bch, c, k)
Test.@test !(A ≈ Ah)
Test.@test cholesky(Ah).L ≈ Bch.L
Test.@test cholesky(Ah).L ≈ Bch2.L
Test.@test Bch.L*Bch.L' ≈ Ah
Test.@test Bch2.L*Bch2.L' ≈ Ah
end
@testset "kcholmod" begin
d = 2
n = 100
ker = psmkernel(ones(d+1).*0.5);
Zt = [rand(d).*10 for i in 1:n ]
Kt = kernelmatrix(ker, Zt)
Ktchol = cholesky(Kt)
l = rand(1:n)
c = rand(2)
Ztmod = deepcopy(Zt)
Ztmod[l] = c
Ktmod = kernelmatrix(ker, Ztmod)
Ktmodchol = cholesky(Ktmod)
Kx = kernelmatrix(ker, [c], Ztmod)
kcholmod!(Ktchol, Kx, l)
Test.@test Ktchol.L ≈ Ktmodchol.L
end
|
abstract type HilbertAlgorithm{T} end
index_type(::HilbertAlgorithm{T}) where {T} = T
"""
encode_hilbert(ha::HilbertAlgorithm{T}, X::Vector{A})
A 1-based Hilbert encoding. Both the Hilbert index and the axes start counting
at 1 instead of 0.
"""
function encode_hilbert(gg::HilbertAlgorithm{T}, X::Vector{A}) where {A, T}
encode_hilbert_zero(gg, X .- one(A)) + one(T)
end
"""
decode_hilbert!(ha::HilbertAlgorithm{T}, X::Vector{A})
A 1-based Hilbert decode, from [`decode_hilbert_zero!`](@ref). Both the Hilbert
index and the axes start counting at 1 instead of 0.
"""
function decode_hilbert!(gg::HilbertAlgorithm{T}, X::Vector{A}, h::T) where {A,T}
decode_hilbert_zero!(gg, X, h - one(T))
X .+= one(A)
end
|
# git-test
# change |
> module NonNegRational.tests.Main
> import NonNegRational.NonNegRational
> import NonNegRational.BasicOperations
> import NonNegRational.BasicProperties
> import Fraction.Fraction
> import PNat.PNat
> import Nat.Positive
> %default total
> %auto_implicits off
> postulate sumOneLemma : {m, n, d : Nat} -> m + n = S d ->
> fromFraction (m, Element (S d) MkPositive)
> +
> fromFraction (n, Element (S d) MkPositive)
> =
> 1
> n1 : Nat
> n1 = 1
> n2 : Nat
> n2 = 3
> d : Nat
> d = 3
> x : NonNegRational
> x = fromFraction (n1, Element (S d) MkPositive)
> y : NonNegRational
> y = fromFraction (n2, Element (S d) MkPositive)
> postulate h : n1 + n2 = S d
> p : x + y = 1
> p = NonNegRational.tests.Main.sumOneLemma {m = n1} {n = n2} {d = d} h
|
Require Import ZArith.
Open Scope Z_scope.
Theorem ring_example1: forall x y: Z, (x+y)*(x+y) = x*x + 2*x*y + y*y.
Proof.
intros x y. ring.
Qed.
Definition square (z:Z) := z*z.
Theorem ring_example2: forall x y:Z, square (x+y) = square x + 2*x*y + square y.
Proof.
intros x y. unfold square. ring.
Qed.
Require Import Arith. (* otherwise ring tactic wil fail for nat *)
Theorem ring_example3:
(forall x y: nat, (x+y)*(x+y) = x*x + 2*x*y + y*y)%nat.
Proof.
intros x y. ring.
Qed.
|
REBOL [
Title: "Memory-tools"
Date: 13-Jul-2003/12:28:53+2:00
Name: none
Version: none
File: none
Home: none
Author: "Ladislav Mecir"
Owner: none
Rights: none
Needs: none
Tabs: none
Usage: [
a: "123^(0)45"
adr: address? a
get-mem? adr ; == #"1"
get-mem? adr + 1 ; == #"2"
get-mem? adr + 2 ; == #"3"
get-mem? adr + 3 ; == #"^@"
get-mem? adr + 4 ; == #"4"
get-mem? adr + 5 ; == #"5"
get-mem? adr + 6 ; == #"^@"
get-mem?/nts adr ; == "123"
get-mem?/part adr 7 ; == "123^@45^@"
set-mem adr + 1 #"a" ; == #"a"
a ; == "1a3^@45"
]
Purpose: none
Comment: {taken from Rebol's mail-list discussion by Oldes (thread: "External library interface")}
History: none
Language: none
Type: none
Content: none
Email: [email protected]
]
probe-mem: func[
address [binary!]
length [integer!]
/local m
][
m: head insert/dup copy [] [. [char!]] length
m: make struct! compose/deep [bin [struct! (reduce [m])]] none
change third m address
probe third m/bin
free m
]
address?: function [
{get the address of a string}
s [any-string!]
] [address] [
s: make struct! [s [string!]] reduce [s]
address: make struct! [i [integer!]] none
change third address third s
address/i
]
get-mem?: function [
{get the byte from a memory address}
address [integer!]
/nts {a null-terminated string}
/part {a binary with a specified length}
length [integer!]
] [m] [
address: make struct! [i [integer!]] reduce [address]
if nts [
m: make struct! [s [string!]] none
change third m third address
return m/s
]
if part [
m: head insert/dup copy [] [. [char!]] length
m: make struct! compose/deep [bin [struct! (reduce [m])]] none
change third m third address
return to string! third m/bin
]
m: make struct! [c [struct! [chr [char!]]]] none
change third m third address
m/c/chr
]
set-mem: function [
{set a byte at a specific memory address}
address [integer!]
value [char!]
] [m] [
address: make struct! [i [integer!]] reduce [address]
m: make struct! [c [struct! [chr [char!]]]] none
change third m third address
m/c/chr: value
]
make-array: func [length [integer!] spec [block!] "eg: [ch [char!]]" /local result][
result: copy []
repeat n length [foreach [name type] spec [repend result [to-word join name n type]]]
result
] |
#include <boost/smart_ptr/make_local_shared_object.hpp>
|
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module SL where
open import Data.Nat
open import Data.Product
open import Data.Sum
open import Relation.Binary.PropositionalEquality
-- Example from: Hofmann and Streicher. The groupoid model refutes
-- uniqueness of identity proofs.
thm₁ : ∀ n → n ≡ 0 ⊎ Σ ℕ (λ n' → n ≡ suc n')
thm₁ zero = inj₁ refl
thm₁ (suc n) = inj₂ (n , refl)
postulate indℕ : (P : ℕ → Set) → P 0 → (∀ n → P n → P (suc n)) → ∀ n → P n
thm₂ : ∀ n → n ≡ 0 ⊎ Σ ℕ λ n' → n ≡ suc n'
thm₂ = indℕ P P0 is
where
P : ℕ → Set
P m = m ≡ 0 ⊎ Σ ℕ λ m' → m ≡ suc m'
P0 : P 0
P0 = inj₁ refl
is : ∀ m → P m → P (suc m)
is m _ = inj₂ (m , refl)
|
/-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
! This file was ported from Lean 3 source module topology.sheaves.limits
! leanprover-community/mathlib commit 70fd9563a21e7b963887c9360bd29b2393e6225a
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathbin.Topology.Sheaves.Sheaf
import Mathbin.CategoryTheory.Sites.Limits
import Mathbin.CategoryTheory.Limits.FunctorCategory
/-!
# Presheaves in `C` have limits and colimits when `C` does.
-/
noncomputable section
universe v u
open CategoryTheory
open CategoryTheory.Limits
variable {C : Type u} [Category.{v} C] {J : Type v} [SmallCategory J]
namespace TopCat
instance [HasLimits C] (X : TopCat) : HasLimits (Presheaf C X) :=
Limits.functorCategoryHasLimitsOfSize.{v, v}
instance [HasColimits C] (X : TopCat) : HasColimitsOfSize.{v} (Presheaf C X) :=
Limits.functorCategoryHasColimitsOfSize
instance [HasLimits C] (X : TopCat) : CreatesLimits (Sheaf.forget C X) :=
Sheaf.CategoryTheory.SheafToPresheaf.CategoryTheory.createsLimits.{u, v, v}
instance [HasLimits C] (X : TopCat) : HasLimitsOfSize.{v} (Sheaf.{v} C X) :=
has_limits_of_has_limits_creates_limits (Sheaf.forget C X)
theorem isSheaf_of_isLimit [HasLimits C] {X : TopCat} (F : J ⥤ Presheaf.{v} C X)
(H : ∀ j, (F.obj j).IsSheaf) {c : Cone F} (hc : IsLimit c) : c.pt.IsSheaf :=
by
let F' : J ⥤ sheaf C X :=
{ obj := fun j => ⟨F.obj j, H j⟩
map := fun X Y f => ⟨F.map f⟩ }
let e : F' ⋙ sheaf.forget C X ≅ F := nat_iso.of_components (fun _ => iso.refl _) (by tidy)
exact
presheaf.is_sheaf_of_iso
((is_limit_of_preserves (sheaf.forget C X) (limit.is_limit F')).conePointsIsoOfNatIso hc e)
(limit F').2
#align Top.is_sheaf_of_is_limit TopCat.isSheaf_of_isLimit
theorem limit_isSheaf [HasLimits C] {X : TopCat} (F : J ⥤ Presheaf.{v} C X)
(H : ∀ j, (F.obj j).IsSheaf) : (limit F).IsSheaf :=
isSheaf_of_isLimit F H (limit.isLimit F)
#align Top.limit_is_sheaf TopCat.limit_isSheaf
end TopCat
|
[STATEMENT]
lemma trace_callee_return_pmf_None [simp]:
"trace_callee_eq callee1 callee2 A (return_pmf None) (return_pmf None)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. trace_callee_eq callee1 callee2 A (return_pmf None) (return_pmf None)
[PROOF STEP]
by(rule trace_callee_eqI) simp |
module foo_module
implicit none
type foo
contains
final :: hello
end type
contains
subroutine hello(this)
type(foo) :: this
print *,"Hello from finalizer."
end subroutine
end module
program main
use foo_module
implicit none
block
type(foo) :: bar
end block
end program
|
[STATEMENT]
lemma
inv_check_left_moving_in_middle_2_on_left_moving_in_middle_B[simp]:
assumes "inv_check_left_moving_in_middle (as, lm) (s, Bk # list, Oc # r) ires"
shows "inv_on_left_moving_in_middle_B (as, lm) (s', list, Bk # Oc # r) ires"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. inv_on_left_moving_in_middle_B (as, lm) (s', list, Bk # Oc # r) ires
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
inv_check_left_moving_in_middle (as, lm) (s, Bk # list, Oc # r) ires
goal (1 subgoal):
1. inv_on_left_moving_in_middle_B (as, lm) (s', list, Bk # Oc # r) ires
[PROOF STEP]
apply(simp only: inv_check_left_moving_in_middle.simps
inv_on_left_moving_in_middle_B.simps)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<exists>lm1 lm2 r' rn. lm = lm1 @ lm2 \<and> Oc # Bk # list = <rev lm1> @ Bk # Bk # ires \<and> Oc # r = Oc # Bk # r' \<and> r' = <lm2> @ Bk \<up> rn \<Longrightarrow> \<exists>lm1 lm2 rn. lm = lm1 @ lm2 \<and> (if lm1 = [] then list = Bk # ires else list = <rev lm1> @ Bk # Bk # ires) \<and> Bk # Oc # r = Bk # <lm2> @ Bk \<up> rn
[PROOF STEP]
apply(erule_tac exE)+
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<And>lm1 lm2 r' rn. lm = lm1 @ lm2 \<and> Oc # Bk # list = <rev lm1> @ Bk # Bk # ires \<and> Oc # r = Oc # Bk # r' \<and> r' = <lm2> @ Bk \<up> rn \<Longrightarrow> \<exists>lm1 lm2 rn. lm = lm1 @ lm2 \<and> (if lm1 = [] then list = Bk # ires else list = <rev lm1> @ Bk # Bk # ires) \<and> Bk # Oc # r = Bk # <lm2> @ Bk \<up> rn
[PROOF STEP]
apply(rename_tac lm1 lm2 r' rn)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<And>lm1 lm2 r' rn. lm = lm1 @ lm2 \<and> Oc # Bk # list = <rev lm1> @ Bk # Bk # ires \<and> Oc # r = Oc # Bk # r' \<and> r' = <lm2> @ Bk \<up> rn \<Longrightarrow> \<exists>lm1 lm2 rn. lm = lm1 @ lm2 \<and> (if lm1 = [] then list = Bk # ires else list = <rev lm1> @ Bk # Bk # ires) \<and> Bk # Oc # r = Bk # <lm2> @ Bk \<up> rn
[PROOF STEP]
apply(rule_tac x = "rev (tl (rev lm1))" in exI,
rule_tac x = "[hd (rev lm1)] @ lm2" in exI, auto)
[PROOF STATE]
proof (prove)
goal (6 subgoals):
1. \<And>lm1 lm2 rn. \<lbrakk>lm = lm1 @ lm2; Oc # Bk # list = <rev lm1> @ Bk # Bk # ires; r = Bk # <lm2> @ Bk \<up> rn; tl (rev lm1) = []\<rbrakk> \<Longrightarrow> lm1 = [hd (rev lm1)]
2. \<And>lm1 lm2 rn. \<lbrakk>lm = lm1 @ lm2; Oc # Bk # list = <rev lm1> @ Bk # Bk # ires; r = Bk # <lm2> @ Bk \<up> rn; tl (rev lm1) = []\<rbrakk> \<Longrightarrow> list = Bk # ires
3. \<And>lm1 lm2 rn. \<lbrakk>lm = lm1 @ lm2; Oc # Bk # list = <rev lm1> @ Bk # Bk # ires; r = Bk # <lm2> @ Bk \<up> rn; tl (rev lm1) = []\<rbrakk> \<Longrightarrow> \<exists>rna. Oc # Bk # <lm2> @ Bk \<up> rn = <hd (rev lm1) # lm2> @ Bk \<up> rna
4. \<And>lm1 lm2 rn. \<lbrakk>lm = lm1 @ lm2; Oc # Bk # list = <rev lm1> @ Bk # Bk # ires; r = Bk # <lm2> @ Bk \<up> rn; tl (rev lm1) \<noteq> []\<rbrakk> \<Longrightarrow> lm1 = rev (tl (rev lm1)) @ [hd (rev lm1)]
5. \<And>lm1 lm2 rn. \<lbrakk>lm = lm1 @ lm2; Oc # Bk # list = <rev lm1> @ Bk # Bk # ires; r = Bk # <lm2> @ Bk \<up> rn; tl (rev lm1) \<noteq> []\<rbrakk> \<Longrightarrow> list = <tl (rev lm1)> @ Bk # Bk # ires
6. \<And>lm1 lm2 rn. \<lbrakk>lm = lm1 @ lm2; Oc # Bk # list = <rev lm1> @ Bk # Bk # ires; r = Bk # <lm2> @ Bk \<up> rn; tl (rev lm1) \<noteq> []\<rbrakk> \<Longrightarrow> \<exists>rna. Oc # Bk # <lm2> @ Bk \<up> rn = <hd (rev lm1) # lm2> @ Bk \<up> rna
[PROOF STEP]
apply(case_tac [!] "rev lm1",case_tac [!] "tl (rev lm1)")
[PROOF STATE]
proof (prove)
goal (24 subgoals):
1. \<And>lm1 lm2 rn. \<lbrakk>lm = lm1 @ lm2; Oc # Bk # list = <rev lm1> @ Bk # Bk # ires; r = Bk # <lm2> @ Bk \<up> rn; tl (rev lm1) = []; rev lm1 = []; tl (rev lm1) = []\<rbrakk> \<Longrightarrow> lm1 = [hd (rev lm1)]
2. \<And>lm1 lm2 rn a lista. \<lbrakk>lm = lm1 @ lm2; Oc # Bk # list = <rev lm1> @ Bk # Bk # ires; r = Bk # <lm2> @ Bk \<up> rn; tl (rev lm1) = []; rev lm1 = []; tl (rev lm1) = a # lista\<rbrakk> \<Longrightarrow> lm1 = [hd (rev lm1)]
3. \<And>lm1 lm2 rn a lista. \<lbrakk>lm = lm1 @ lm2; Oc # Bk # list = <rev lm1> @ Bk # Bk # ires; r = Bk # <lm2> @ Bk \<up> rn; tl (rev lm1) = []; rev lm1 = a # lista; tl (rev lm1) = []\<rbrakk> \<Longrightarrow> lm1 = [hd (rev lm1)]
4. \<And>lm1 lm2 rn a lista aa listaa. \<lbrakk>lm = lm1 @ lm2; Oc # Bk # list = <rev lm1> @ Bk # Bk # ires; r = Bk # <lm2> @ Bk \<up> rn; tl (rev lm1) = []; rev lm1 = a # lista; tl (rev lm1) = aa # listaa\<rbrakk> \<Longrightarrow> lm1 = [hd (rev lm1)]
5. \<And>lm1 lm2 rn. \<lbrakk>lm = lm1 @ lm2; Oc # Bk # list = <rev lm1> @ Bk # Bk # ires; r = Bk # <lm2> @ Bk \<up> rn; tl (rev lm1) = []; rev lm1 = []; tl (rev lm1) = []\<rbrakk> \<Longrightarrow> list = Bk # ires
6. \<And>lm1 lm2 rn a lista. \<lbrakk>lm = lm1 @ lm2; Oc # Bk # list = <rev lm1> @ Bk # Bk # ires; r = Bk # <lm2> @ Bk \<up> rn; tl (rev lm1) = []; rev lm1 = []; tl (rev lm1) = a # lista\<rbrakk> \<Longrightarrow> list = Bk # ires
7. \<And>lm1 lm2 rn a lista. \<lbrakk>lm = lm1 @ lm2; Oc # Bk # list = <rev lm1> @ Bk # Bk # ires; r = Bk # <lm2> @ Bk \<up> rn; tl (rev lm1) = []; rev lm1 = a # lista; tl (rev lm1) = []\<rbrakk> \<Longrightarrow> list = Bk # ires
8. \<And>lm1 lm2 rn a lista aa listaa. \<lbrakk>lm = lm1 @ lm2; Oc # Bk # list = <rev lm1> @ Bk # Bk # ires; r = Bk # <lm2> @ Bk \<up> rn; tl (rev lm1) = []; rev lm1 = a # lista; tl (rev lm1) = aa # listaa\<rbrakk> \<Longrightarrow> list = Bk # ires
9. \<And>lm1 lm2 rn. \<lbrakk>lm = lm1 @ lm2; Oc # Bk # list = <rev lm1> @ Bk # Bk # ires; r = Bk # <lm2> @ Bk \<up> rn; tl (rev lm1) = []; rev lm1 = []; tl (rev lm1) = []\<rbrakk> \<Longrightarrow> \<exists>rna. Oc # Bk # <lm2> @ Bk \<up> rn = <hd (rev lm1) # lm2> @ Bk \<up> rna
10. \<And>lm1 lm2 rn a lista. \<lbrakk>lm = lm1 @ lm2; Oc # Bk # list = <rev lm1> @ Bk # Bk # ires; r = Bk # <lm2> @ Bk \<up> rn; tl (rev lm1) = []; rev lm1 = []; tl (rev lm1) = a # lista\<rbrakk> \<Longrightarrow> \<exists>rna. Oc # Bk # <lm2> @ Bk \<up> rn = <hd (rev lm1) # lm2> @ Bk \<up> rna
A total of 24 subgoals...
[PROOF STEP]
apply(simp_all add: tape_of_nat_def tape_of_list_def)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
1. \<And>lm1 lm2 rn lista. \<lbrakk>lm = 0 # lm2; list = Bk # ires; r = Bk # tape_of_nat_list lm2 @ Bk \<up> rn; lista = []; lm1 = [0]\<rbrakk> \<Longrightarrow> \<exists>rna. Oc # Bk # tape_of_nat_list lm2 @ Bk \<up> rn = tape_of_nat_list (0 # lm2) @ Bk \<up> rna
2. \<And>lm1 lm2 rn lista aa listaa. \<lbrakk>lm = rev listaa @ aa # 0 # lm2; list = tape_of_nat_list (aa # listaa) @ Bk # Bk # ires; r = Bk # tape_of_nat_list lm2 @ Bk \<up> rn; lm1 = rev listaa @ [aa, 0]; lista = aa # listaa\<rbrakk> \<Longrightarrow> \<exists>rna. Oc # Bk # tape_of_nat_list lm2 @ Bk \<up> rn = tape_of_nat_list (0 # lm2) @ Bk \<up> rna
[PROOF STEP]
apply(case_tac [1] lm2, auto simp:tape_of_nat_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<And>lm2 rn aa lista. \<lbrakk>lm = rev lista @ aa # 0 # lm2; list = tape_of_nat_list (aa # lista) @ Bk # Bk # ires; r = Bk # tape_of_nat_list lm2 @ Bk \<up> rn\<rbrakk> \<Longrightarrow> \<exists>rna. Oc # Bk # tape_of_nat_list lm2 @ Bk \<up> rn = tape_of_nat_list (0 # lm2) @ Bk \<up> rna
[PROOF STEP]
apply(case_tac lm2, auto simp:tape_of_nat_def)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done |
State Before: G : Type u_1
inst✝³ : Group G
H : Subgroup G
inst✝² : Normal H
H₁ H₂ : Subgroup G
inst✝¹ : Normal H₁
inst✝ : Normal H₂
h : H₁ = H₂
⊢ comap (mk' H₁) (center (G ⧸ H₁)) = comap (mk' H₂) (center (G ⧸ H₂)) State After: G : Type u_1
inst✝³ : Group G
H : Subgroup G
inst✝² : Normal H
H₁ : Subgroup G
inst✝¹ inst✝ : Normal H₁
⊢ comap (mk' H₁) (center (G ⧸ H₁)) = comap (mk' H₁) (center (G ⧸ H₁)) Tactic: subst h State Before: G : Type u_1
inst✝³ : Group G
H : Subgroup G
inst✝² : Normal H
H₁ : Subgroup G
inst✝¹ inst✝ : Normal H₁
⊢ comap (mk' H₁) (center (G ⧸ H₁)) = comap (mk' H₁) (center (G ⧸ H₁)) State After: no goals Tactic: rfl |
section \<open>Constructing Paths and Runs in Transition Systems\<close>
theory Transition_System_Construction
imports
"../Basic/Sequence_LTL"
"Transition_System"
begin
context transition_system
begin
lemma invariant_run:
assumes "P p" "\<And> p. P p \<Longrightarrow> \<exists> a. enabled a p \<and> P (execute a p) \<and> Q p a"
obtains r
where "run r p" "pred_stream P (p ## trace r p)" "stream_all2 Q (p ## trace r p) r"
proof -
obtain f where 1: "enabled (f p) p" "P (execute (f p) p)" "Q p (f p)" if "P p" for p using assms(2) by metis
let ?g = "\<lambda> p. execute (f p) p"
let ?r = "\<lambda> p. smap f (siterate ?g p)"
show ?thesis
proof
show "run (?r p) p" using assms(1) 1 by (coinduction arbitrary: p) (auto)
show "pred_stream P (p ## trace (?r p) p)" using assms(1) 1 by (coinduction arbitrary: p) (auto)
show "stream_all2 Q (p ## trace (?r p) p) (?r p)" using assms(1) 1 by (coinduction arbitrary: p) (auto)
qed
qed
lemma recurring_condition:
assumes "P p" "\<And> p. P p \<Longrightarrow> \<exists> r. r \<noteq> [] \<and> path r p \<and> P (target r p)"
obtains r
where "run r p" "infs P (p ## trace r p)"
proof -
obtain f where 1: "f p \<noteq> []" "path (f p) p" "P (target (f p) p)" if "P p" for p using assms(2) by metis
let ?g = "\<lambda> p. target (f p) p"
let ?r = "\<lambda> p. flat (smap f (siterate ?g p))"
have 2: "?r p = f p @- ?r (?g p)" if "P p" for p using that 1(1) by (simp add: flat_unfold)
show ?thesis
proof
show "run (?r p) p" using assms(1) 1 2 by (coinduction arbitrary: p rule: run_coinduct_shift) (blast)
show "infs P (p ## trace (?r p) p)" using assms(1) 1 2 by (coinduction arbitrary: p rule: infs_sscan_coinduct) (blast)
qed
qed
lemma invariant_run_index:
assumes "P n p" "\<And> n p. P n p \<Longrightarrow> \<exists> a. enabled a p \<and> P (Suc n) (execute a p) \<and> Q n p a"
obtains r
where
"run r p"
"\<And> i. P (n + i) (target (stake i r) p)"
"\<And> i. Q (n + i) (target (stake i r) p) (r !! i)"
proof -
define s where "s \<equiv> (n, p)"
have 1: "case_prod P s" using assms(1) unfolding s_def by auto
obtain f where 2:
"\<And> n p. P n p \<Longrightarrow> enabled (f n p) p"
"\<And> n p. P n p \<Longrightarrow> P (Suc n) (execute (f n p) p)"
"\<And> n p. P n p \<Longrightarrow> Q n p (f n p)"
using assms(2) by metis
define g where "g \<equiv> \<lambda> (n, p). (Suc n, execute (f n p) p)"
let ?r = "smap (case_prod f) (siterate g s)"
have 3: "run ?r (snd s)" using 1 2(1, 2) unfolding g_def by (coinduction arbitrary: s) (auto)
have 4: "case_prod P (compow k g s)" for k using 1 2(2) unfolding g_def by (induct k) (auto)
have 5: "case_prod Q (compow k g s) (?r !! k)" for k using 2(3) 4 by (simp add: case_prod_beta)
have 6: "compow k g (n, p) = (n + k, target (stake k ?r) p)" for k
unfolding s_def g_def by (induct k) (auto simp add: stake_Suc simp del: stake.simps(2))
show ?thesis using that 3 4 5 unfolding s_def 6 by simp
qed
lemma koenig:
assumes "infinite (reachable p)"
assumes "\<And> q. q \<in> reachable p \<Longrightarrow> finite (successors q)"
obtains r
where "run r p"
proof (rule invariant_run[where ?P = "\<lambda> q. q \<in> reachable p \<and> infinite (reachable q)"])
show "p \<in> reachable p \<and> infinite (reachable p)" using assms(1) by auto
next
fix q
assume 1: "q \<in> reachable p \<and> infinite (reachable q)"
have 2: "finite (successors q)" using assms(2) 1 by auto
have 3: "infinite (insert q (\<Union>(reachable ` (successors q))))" using reachable_step 1 by metis
obtain s where 4: "s \<in> successors q" "infinite (reachable s)" using 2 3 by auto
show "\<exists> a. enabled a q \<and> (execute a q \<in> reachable p \<and> infinite (reachable (execute a q))) \<and> True"
using 1 4 by auto
qed
end
end
|
lemmas LIM_not_zero = LIM_const_not_eq [where L = 0] |
*DECK ULSIA
SUBROUTINE ULSIA (A, MDA, M, N, B, MDB, NB, RE, AE, KEY, MODE, NP,
+ KRANK, KSURE, RNORM, W, LW, IWORK, LIW, INFO)
C***BEGIN PROLOGUE ULSIA
C***PURPOSE Solve an underdetermined linear system of equations by
C performing an LQ factorization of the matrix using
C Householder transformations. Emphasis is put on detecting
C possible rank deficiency.
C***LIBRARY SLATEC
C***CATEGORY D9
C***TYPE SINGLE PRECISION (ULSIA-S, DULSIA-D)
C***KEYWORDS LINEAR LEAST SQUARES, LQ FACTORIZATION,
C UNDERDETERMINED LINEAR SYSTEM
C***AUTHOR Manteuffel, T. A., (LANL)
C***DESCRIPTION
C
C ULSIA computes the minimal length solution(s) to the problem AX=B
C where A is an M by N matrix with M.LE.N and B is the M by NB
C matrix of right hand sides. User input bounds on the uncertainty
C in the elements of A are used to detect numerical rank deficiency.
C The algorithm employs a row and column pivot strategy to
C minimize the growth of uncertainty and round-off errors.
C
C ULSIA requires (MDA+1)*N + (MDB+1)*NB + 6*M dimensioned space
C
C ******************************************************************
C * *
C * WARNING - All input arrays are changed on exit. *
C * *
C ******************************************************************
C
C Input..
C
C A(,) Linear coefficient matrix of AX=B, with MDA the
C MDA,M,N actual first dimension of A in the calling program.
C M is the row dimension (no. of EQUATIONS of the
C problem) and N the col dimension (no. of UNKNOWNS).
C Must have MDA.GE.M and M.LE.N.
C
C B(,) Right hand side(s), with MDB the actual first
C MDB,NB dimension of B in the calling program. NB is the
C number of M by 1 right hand sides. Since the
C solution is returned in B, must have MDB.GE.N. If
C NB = 0, B is never accessed.
C
C ******************************************************************
C * *
C * Note - Use of RE and AE are what make this *
C * code significantly different from *
C * other linear least squares solvers. *
C * However, the inexperienced user is *
C * advised to set RE=0.,AE=0.,KEY=0. *
C * *
C ******************************************************************
C
C RE(),AE(),KEY
C RE() RE() is a vector of length N such that RE(I) is
C the maximum relative uncertainty in row I of
C the matrix A. The values of RE() must be between
C 0 and 1. A minimum of 10*machine precision will
C be enforced.
C
C AE() AE() is a vector of length N such that AE(I) is
C the maximum absolute uncertainty in row I of
C the matrix A. The values of AE() must be greater
C than or equal to 0.
C
C KEY For ease of use, RE and AE may be input as either
C vectors or scalars. If a scalar is input, the algo-
C rithm will use that value for each column of A.
C The parameter KEY indicates whether scalars or
C vectors are being input.
C KEY=0 RE scalar AE scalar
C KEY=1 RE vector AE scalar
C KEY=2 RE scalar AE vector
C KEY=3 RE vector AE vector
C
C
C MODE The integer MODE indicates how the routine
C is to react if rank deficiency is detected.
C If MODE = 0 return immediately, no solution
C 1 compute truncated solution
C 2 compute minimal length least squares sol
C The inexperienced user is advised to set MODE=0
C
C NP The first NP rows of A will not be interchanged
C with other rows even though the pivot strategy
C would suggest otherwise.
C The inexperienced user is advised to set NP=0.
C
C WORK() A real work array dimensioned 5*M. However, if
C RE or AE have been specified as vectors, dimension
C WORK 4*M. If both RE and AE have been specified
C as vectors, dimension WORK 3*M.
C
C LW Actual dimension of WORK
C
C IWORK() Integer work array dimensioned at least N+M.
C
C LIW Actual dimension of IWORK.
C
C
C INFO Is a flag which provides for the efficient
C solution of subsequent problems involving the
C same A but different B.
C If INFO = 0 original call
C INFO = 1 subsequent calls
C On subsequent calls, the user must supply A, KRANK,
C LW, IWORK, LIW, and the first 2*M locations of WORK
C as output by the original call to ULSIA. MODE must
C be equal to the value of MODE in the original call.
C If MODE.LT.2, only the first N locations of WORK
C are accessed. AE, RE, KEY, and NP are not accessed.
C
C
C
C
C Output..
C
C A(,) Contains the lower triangular part of the reduced
C matrix and the transformation information. It togeth
C with the first M elements of WORK (see below)
C completely specify the LQ factorization of A.
C
C B(,) Contains the N by NB solution matrix for X.
C
C KRANK,KSURE The numerical rank of A, based upon the relative
C and absolute bounds on uncertainty, is bounded
C above by KRANK and below by KSURE. The algorithm
C returns a solution based on KRANK. KSURE provides
C an indication of the precision of the rank.
C
C RNORM() Contains the Euclidean length of the NB residual
C vectors B(I)-AX(I), I=1,NB. If the matrix A is of
C full rank, then RNORM=0.0.
C
C WORK() The first M locations of WORK contain values
C necessary to reproduce the Householder
C transformation.
C
C IWORK() The first N locations contain the order in
C which the columns of A were used. The next
C M locations contain the order in which the
C rows of A were used.
C
C INFO Flag to indicate status of computation on completion
C -1 Parameter error(s)
C 0 - Rank deficient, no solution
C 1 - Rank deficient, truncated solution
C 2 - Rank deficient, minimal length least squares sol
C 3 - Numerical rank 0, zero solution
C 4 - Rank .LT. NP
C 5 - Full rank
C
C***REFERENCES T. Manteuffel, An interval analysis approach to rank
C determination in linear least squares problems,
C Report SAND80-0655, Sandia Laboratories, June 1980.
C***ROUTINES CALLED R1MACH, U11US, U12US, XERMSG
C***REVISION HISTORY (YYMMDD)
C 810801 DATE WRITTEN
C 890831 Modified array declarations. (WRB)
C 891009 Removed unreferenced variable. (WRB)
C 891009 REVISION DATE from Version 3.2
C 891214 Prologue converted to Version 4.0 format. (BAB)
C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
C 900510 Fixed an error message. (RWC)
C 920501 Reformatted the REFERENCES section. (WRB)
C***END PROLOGUE ULSIA
DIMENSION A(MDA,*),B(MDB,*),RE(*),AE(*),RNORM(*),W(*)
INTEGER IWORK(*)
C
C***FIRST EXECUTABLE STATEMENT ULSIA
IF(INFO.LT.0 .OR. INFO.GT.1) GO TO 514
IT=INFO
INFO=-1
IF(NB.EQ.0 .AND. IT.EQ.1) GO TO 501
IF(M.LT.1) GO TO 502
IF(N.LT.1) GO TO 503
IF(N.LT.M) GO TO 504
IF(MDA.LT.M) GO TO 505
IF(LIW.LT.M+N) GO TO 506
IF(MODE.LT.0 .OR. MODE.GT.3) GO TO 515
IF(NB.EQ.0) GO TO 4
IF(NB.LT.0) GO TO 507
IF(MDB.LT.N) GO TO 508
IF(IT.EQ.0) GO TO 4
GO TO 400
4 IF(KEY.LT.0.OR.KEY.GT.3) GO TO 509
IF(KEY.EQ.0 .AND. LW.LT.5*M) GO TO 510
IF(KEY.EQ.1 .AND. LW.LT.4*M) GO TO 510
IF(KEY.EQ.2 .AND. LW.LT.4*M) GO TO 510
IF(KEY.EQ.3 .AND. LW.LT.3*M) GO TO 510
IF(NP.LT.0 .OR. NP.GT.M) GO TO 516
C
EPS=10.*R1MACH(4)
M1=1
M2=M1+M
M3=M2+M
M4=M3+M
M5=M4+M
C
IF(KEY.EQ.1) GO TO 100
IF(KEY.EQ.2) GO TO 200
IF(KEY.EQ.3) GO TO 300
C
IF(RE(1).LT.0.0) GO TO 511
IF(RE(1).GT.1.0) GO TO 512
IF(RE(1).LT.EPS) RE(1)=EPS
IF(AE(1).LT.0.0) GO TO 513
DO 20 I=1,M
W(M4-1+I)=RE(1)
W(M5-1+I)=AE(1)
20 CONTINUE
CALL U11US(A,MDA,M,N,W(M4),W(M5),MODE,NP,KRANK,KSURE,
1 W(M1),W(M2),W(M3),IWORK(M1),IWORK(M2))
GO TO 400
C
100 CONTINUE
IF(AE(1).LT.0.0) GO TO 513
DO 120 I=1,M
IF(RE(I).LT.0.0) GO TO 511
IF(RE(I).GT.1.0) GO TO 512
IF(RE(I).LT.EPS) RE(I)=EPS
W(M4-1+I)=AE(1)
120 CONTINUE
CALL U11US(A,MDA,M,N,RE,W(M4),MODE,NP,KRANK,KSURE,
1 W(M1),W(M2),W(M3),IWORK(M1),IWORK(M2))
GO TO 400
C
200 CONTINUE
IF(RE(1).LT.0.0) GO TO 511
IF(RE(1).GT.1.0) GO TO 512
IF(RE(1).LT.EPS) RE(1)=EPS
DO 220 I=1,M
W(M4-1+I)=RE(1)
IF(AE(I).LT.0.0) GO TO 513
220 CONTINUE
CALL U11US(A,MDA,M,N,W(M4),AE,MODE,NP,KRANK,KSURE,
1 W(M1),W(M2),W(M3),IWORK(M1),IWORK(M2))
GO TO 400
C
300 CONTINUE
DO 320 I=1,M
IF(RE(I).LT.0.0) GO TO 511
IF(RE(I).GT.1.0) GO TO 512
IF(RE(I).LT.EPS) RE(I)=EPS
IF(AE(I).LT.0.0) GO TO 513
320 CONTINUE
CALL U11US(A,MDA,M,N,RE,AE,MODE,NP,KRANK,KSURE,
1 W(M1),W(M2),W(M3),IWORK(M1),IWORK(M2))
C
C DETERMINE INFO
C
400 IF(KRANK.NE.M) GO TO 402
INFO=5
GO TO 410
402 IF(KRANK.NE.0) GO TO 404
INFO=3
GO TO 410
404 IF(KRANK.GE.NP) GO TO 406
INFO=4
RETURN
406 INFO=MODE
IF(MODE.EQ.0) RETURN
410 IF(NB.EQ.0) RETURN
C
C
C SOLUTION PHASE
C
M1=1
M2=M1+M
M3=M2+M
IF(INFO.EQ.2) GO TO 420
IF(LW.LT.M2-1) GO TO 510
CALL U12US(A,MDA,M,N,B,MDB,NB,MODE,KRANK,
1 RNORM,W(M1),W(M1),IWORK(M1),IWORK(M2))
RETURN
C
420 IF(LW.LT.M3-1) GO TO 510
CALL U12US(A,MDA,M,N,B,MDB,NB,MODE,KRANK,
1 RNORM,W(M1),W(M2),IWORK(M1),IWORK(M2))
RETURN
C
C ERROR MESSAGES
C
501 CALL XERMSG ('SLATEC', 'ULSIA',
+ 'SOLUTION ONLY (INFO=1) BUT NO RIGHT HAND SIDE (NB=0)', 1, 0)
RETURN
502 CALL XERMSG ('SLATEC', 'ULSIA', 'M.LT.1', 2, 1)
RETURN
503 CALL XERMSG ('SLATEC', 'ULSIA', 'N.LT.1', 2, 1)
RETURN
504 CALL XERMSG ('SLATEC', 'ULSIA', 'N.LT.M', 2, 1)
RETURN
505 CALL XERMSG ('SLATEC', 'ULSIA', 'MDA.LT.M', 2, 1)
RETURN
506 CALL XERMSG ('SLATEC', 'ULSIA', 'LIW.LT.M+N', 2, 1)
RETURN
507 CALL XERMSG ('SLATEC', 'ULSIA', 'NB.LT.0', 2, 1)
RETURN
508 CALL XERMSG ('SLATEC', 'ULSIA', 'MDB.LT.N', 2, 1)
RETURN
509 CALL XERMSG ('SLATEC', 'ULSIA', 'KEY OUT OF RANGE', 2, 1)
RETURN
510 CALL XERMSG ('SLATEC', 'ULSIA', 'INSUFFICIENT WORK SPACE', 8, 1)
INFO=-1
RETURN
511 CALL XERMSG ('SLATEC', 'ULSIA', 'RE(I) .LT. 0', 2, 1)
RETURN
512 CALL XERMSG ('SLATEC', 'ULSIA', 'RE(I) .GT. 1', 2, 1)
RETURN
513 CALL XERMSG ('SLATEC', 'ULSIA', 'AE(I) .LT. 0', 2, 1)
RETURN
514 CALL XERMSG ('SLATEC', 'ULSIA', 'INFO OUT OF RANGE', 2, 1)
RETURN
515 CALL XERMSG ('SLATEC', 'ULSIA', 'MODE OUT OF RANGE', 2, 1)
RETURN
516 CALL XERMSG ('SLATEC', 'ULSIA', 'NP OUT OF RANGE', 2, 1)
RETURN
END
|
module Chapter6
import Data.Vect
%default total
-- type synonyms
Position : Type
Position = (Double, Double)
tri : Vect 3 Position
tri = [(0.0, 0.0), (1.0, 2.0), (-23.22, -11.089)]
-- type-level functions
-- type-level functions are merely functions that return a Type
-- defining functions with a variable number of arguments
|
from functools import partial
import theano
import theano.tensor as T
import numpy as np
import lasagne as nn
import scipy.misc
from glob import glob
from lasagne.layers import dnn
import utils
batch_size = 1
learning_rate = 5.0
momentum = theano.shared(np.float32(0.9))
steps_per_zoom = 1
network_power = 1
prior_strength = 1000
zoomspeed = 1.05
width = 1024 #1024 #600#1280
height = 576 #576 #336#720 #multiple of 2
estimated_input_fps=15./steps_per_zoom
n_classes = 1000
total_steps = 100
#Determines also the scale of the entire thing!
image = scipy.misc.imread(glob("hd1.*")[0])
"""
batch_size = 1
learning_rate = 2.0
momentum = theano.shared(np.float32(0.9))
steps_per_zoom = 30
network_power = 1
prior_strength = 10
zoomspeed = 1.05
width = 960
height = 540 #multiple of 2
estimated_input_fps=80./steps_per_zoom
n_classes = 1000
"""
pretrained_params = np.load("data/vgg16.npy")
# image = scipy.misc.imread("image.png")
print image.dtype
mean_img = np.transpose(np.load("data/mean.npy").astype("float32"), axes=(2,0,1)).mean() #.mean() for any size
# image -= mean_img
image = np.transpose(image, axes=(2,0,1))
conv3 = partial(dnn.Conv2DDNNLayer,
strides=(1, 1),
border_mode="same",
filter_size=(3,3),
nonlinearity=nn.nonlinearities.rectify)
class custom_flatten_dense(nn.layers.DenseLayer):
def get_output_for(self, input, **kwargs):
if input.ndim > 2:
# if the input has more than two dimensions, flatten it into a
# batch of feature vectors.
input = input.dimshuffle(0,3,1,2)
input = input.flatten(2)
activation = T.dot(input, self.W)
if self.b is not None:
activation = activation + self.b.dimshuffle('x', 0)
return self.nonlinearity(activation)
dense = partial(nn.layers.DenseLayer,
nonlinearity=nn.nonlinearities.rectify)
max_pool = partial(dnn.MaxPool2DDNNLayer,
ds=(2,2),
strides=(2,2))
def build_model(batch_size=batch_size):
l_in = nn.layers.InputLayer(shape=(batch_size,)+image.shape)
l = l_in
l = conv3(l, num_filters=64)
l = conv3(l, num_filters=64)
l = max_pool(l)
l = conv3(l, num_filters=128)
l = conv3(l, num_filters=128)
l = max_pool(l)
l = conv3(l, num_filters=256)
l = conv3(l, num_filters=256)
l = conv3(l, num_filters=256)
l = max_pool(l)
l = conv3(l, num_filters=512)
l = conv3(l, num_filters=512)
l = conv3(l, num_filters=512)
l = max_pool(l)
l = conv3(l, num_filters=512)
l = conv3(l, num_filters=512)
l = conv3(l, num_filters=512)
l = max_pool(l)
l = dnn.Conv2DDNNLayer(l,
num_filters=4096,
strides=(1, 1),
border_mode="valid",
filter_size=(7,7))
l = dnn.Conv2DDNNLayer(l,
num_filters=4096,
strides=(1, 1),
border_mode="same",
filter_size=(1,1))
l = dnn.Conv2DDNNLayer(l,
num_filters=n_classes,
strides=(1,1),
border_mode="same",
filter_size=(1,1),
nonlinearity=None)
l_to_strengthen = l
l_out = l
return utils.struct(
input=l_in,
out=l_out,
to_strengthen=l_to_strengthen)
def build_updates(loss, all_params, learning_rate, beta1=0.9, beta2=0.999,
epsilon=1e-8):
all_grads = theano.grad(loss, all_params)
updates = []
resets = []
t = theano.shared(1) # timestep, for bias correction
for param_i, grad_i in zip(all_params, all_grads):
mparam_i = theano.shared(np.zeros(param_i.get_value().shape, dtype=theano.config.floatX)) # 1st moment
vparam_i = theano.shared(np.zeros(param_i.get_value().shape, dtype=theano.config.floatX)) # 2nd moment
m = beta1 * grad_i + (1 - beta1) * mparam_i # new value for 1st moment estimate
v = beta2 * T.sqr(grad_i) + (1 - beta2) * vparam_i # new value for 2nd moment estimate
m_unbiased = m / (1 - (1 - beta1) ** t.astype(theano.config.floatX))
v_unbiased = v / (1 - (1 - beta2) ** t.astype(theano.config.floatX))
w = param_i - learning_rate * m_unbiased / (T.sqrt(v_unbiased) + epsilon) # new parameter values
updates.append((mparam_i, m))
updates.append((vparam_i, v))
updates.append((param_i, w))
resets.append([mparam_i, np.zeros(param_i.get_value().shape, dtype=theano.config.floatX)])
resets.append([vparam_i, np.zeros(param_i.get_value().shape, dtype=theano.config.floatX)])
resets.append([t, 1])
updates.append((t, t + 1))
return updates, resets
|
subroutine ComputeDG82(DG82, lmax, m, theta0)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! This routine will compute the kernel of Grunbaum et al. 1982
! that commutes with the space concentration kernel. This
! kernel is tridiagonal and has simple expressions for
! its elements. Note that this kernel is multiplied by -1 in
! comparison to Grunbaum et al. in order that the eigenvectors
! will be listed in the same order as the eigenvectors of the
! equivalent space concentration matrix Dllm. While the eigenfunctions
! of this kernel correspond to the eigenvalues of Dllm, the eigenvalues
! do NOT!
!
! Calling Parameters
! IN
! lmax: Maximum spherical harmonic degree.
! theta0: Angular radius of spherical cap IN RADIANS.
! m: Angular order to concentration problem.
! OUT
! D0G82: Symmetric tridiagonal kernel with a maximum size of lmax+1 by lmax+1.
!
! Dependencies: none
!
! Written by Mark Wieczorek (June 2004)
!
! Copyright (c) 2005, Mark A. Wieczorek
! All rights reserved.
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
implicit none
real*8, intent(out) :: DG82(:,:)
real*8, intent(in) :: theta0
integer, intent(in) :: lmax, m
real*8 :: x
integer :: i, n
n = lmax + 1 - abs(m)
if(n<1) then
print*, "Error --- ComputeDG82"
print*, "abs(M) must be less than or equal to LMAX"
print*, "Input values of l and m are ", lmax, m
stop
elseif (size(DG82(1,:)) < n .or. size(DG82(:,1)) < n) then
print*, "Error --- ComputeDG82"
print*, "DG82 must be dimensioned as (LMAX-abs(M)+1,LMAX-abs(M)+1) where LMAX and M are ", lmax, m
print*, "Input array is dimensioned as ", size(DG82(1,:)), size(DG82(:,1))
stop
endif
DG82 = 0.0d0
x = cos(theta0)
DG82(1,1) = x * dble(1+m) * dble(m)
do i=2, n, 1
DG82(i,i) = x * dble(i+m) * dble(i+m-1)
DG82(i,i-1) = - sqrt(dble(i-1+m)**2 - dble(m)**2) * &
( dble(i-1+m)**2 - dble(lmax+1)**2 ) / &
sqrt(4.0d0*dble(i-1+m)**2 - 1.0d0)
DG82(i-1,i) = DG82(i,i-1)
enddo
end subroutine ComputeDG82
|
! Exercise nested function decomposition, gcc/tree-nested.c.
! { dg-do run }
program collapse2
call test1
call test2
contains
subroutine test1
integer :: i, j, k, a(1:3, 4:6, 5:7)
logical :: l
l = .false.
a(:, :, :) = 0
!$acc parallel reduction (.or.:l)
!$acc loop worker vector collapse(4 - 1)
do 164 i = 1, 3
do 164 j = 4, 6
do 164 k = 5, 7
a(i, j, k) = i + j + k
164 end do
!$acc loop worker vector reduction(.or.:l) collapse(2)
firstdo: do i = 1, 3
do j = 4, 6
do k = 5, 7
if (a(i, j, k) .ne. (i + j + k)) l = .true.
end do
end do
end do firstdo
!$acc end parallel
if (l) call abort
end subroutine test1
subroutine test2
integer :: a(3,3,3), k, kk, kkk, l, ll, lll
a = 0
!$acc parallel num_workers(8)
! Use "gang(static:1)" here and below to effectively turn gang-redundant
! execution mode into something like gang-single.
!$acc loop gang(static:1) collapse(1)
do 115 k=1,3
!$acc loop collapse(2)
dokk: do kk=1,3
do kkk=1,3
a(k,kk,kkk) = 1
enddo
enddo dokk
115 continue
!$acc loop gang(static:1) collapse(1)
do k=1,3
if (any(a(k,1:3,1:3).ne.1)) call abort
enddo
! Use "gang(static:1)" here and below to effectively turn gang-redundant
! execution mode into something like gang-single.
!$acc loop gang(static:1) collapse(1)
dol: do 120 l=1,3
!$acc loop collapse(2)
doll: do ll=1,3
do lll=1,3
a(l,ll,lll) = 2
enddo
enddo doll
120 end do dol
!$acc loop gang(static:1) collapse(1)
do l=1,3
if (any(a(l,1:3,1:3).ne.2)) call abort
enddo
!$acc end parallel
end subroutine test2
end program collapse2
|
using Documenter, WhereTheWaterFlows
makedocs(;
modules=[WhereTheWaterFlows],
format=Documenter.HTML(),
pages=[
"Home" => "index.md",
],
repo="https://github.com/mauro3/WhereTheWaterFlows.jl/blob/{commit}{path}#L{line}",
sitename="WhereTheWaterFlows.jl",
authors="Mauro Werder <[email protected]>",
assets=String[],
)
deploydocs(;
repo="github.com/mauro3/WhereTheWaterFlows.jl",
)
|
function prob_test1341 ( )
%*****************************************************************************80
%
%% TEST01341 checks RIBESL against BESSEL_IX_VALUES.
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 14 February 2003
%
% Author:
%
% John Burkardt
%
fprintf ( 1, '\n' );
fprintf ( 1, 'TEST1341:\n' );
fprintf ( 1, ' RIBESL computes values of Bessel functions\n' );
fprintf ( 1, ' of NONINTEGER order.\n' );
fprintf ( 1, ' BESSEL_IX_VALUES returns selected values of the\n' );
fprintf ( 1, ' Bessel function In for NONINTEGER order.\n' );
fprintf ( 1, '\n' );
fprintf ( 1, ...
' ALPHA X FX FX2\n' );
fprintf ( 1, ...
' (table) (RIBESL)\n' );
fprintf ( 1, '\n' );
n_data = 0;
while ( 1 )
[ n_data, alpha, x, fx ] = bessel_ix_values ( n_data );
if ( n_data == 0 );
break
end
ize = 1;
nb = floor ( alpha ) + 1;
alpha_frac = alpha - floor ( alpha );
[ b, ncalc ] = ribesl ( x, alpha_frac, nb, ize );
fx2 = b(nb);
fprintf ( 1, ' %12f %12f %24.16e %24.16e\n', alpha, x, fx, fx2 );
end
return
end
|
/-
Copyright (c) 2020 Joseph Myers. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Myers, Yury Kudryashov
! This file was ported from Lean 3 source module algebra.add_torsor
! leanprover-community/mathlib commit 9003f28797c0664a49e4179487267c494477d853
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathlib.Data.Set.Pointwise.SMul
/-!
# Torsors of additive group actions
This file defines torsors of additive group actions.
## Notations
The group elements are referred to as acting on points. This file
defines the notation `+ᵥ` for adding a group element to a point and
`-ᵥ` for subtracting two points to produce a group element.
## Implementation notes
Affine spaces are the motivating example of torsors of additive group actions. It may be appropriate
to refactor in terms of the general definition of group actions, via `to_additive`, when there is a
use for multiplicative torsors (currently mathlib only develops the theory of group actions for
multiplicative group actions).
## Notations
* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;
* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor
as an element of the corresponding additive group;
## References
* https://en.wikipedia.org/wiki/Principal_homogeneous_space
* https://en.wikipedia.org/wiki/Affine_space
-/
/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,
acted on by an `AddGroup G` with a transitive and free action given
by the `+ᵥ` operation and a corresponding subtraction given by the
`-ᵥ` operation. In the case of a vector space, it is an affine
space. -/
class AddTorsor (G : outParam (Type _)) (P : Type _) [outParam <| AddGroup G] extends AddAction G P,
VSub G P where
[Nonempty : Nonempty P]
/-- Torsor subtraction and addition with the same element cancels out. -/
vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1
/-- Torsor addition and subtraction with the same element cancels out. -/
vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g
#align add_torsor AddTorsor
attribute [instance] AddTorsor.Nonempty -- porting note: removers `nolint instance_priority`
--Porting note: removed
--attribute [nolint dangerous_instance] AddTorsor.toVSub
/-- An `AddGroup G` is a torsor for itself. -/
--@[nolint instance_priority] Porting note: linter does not exist
instance addGroupIsAddTorsor (G : Type _) [AddGroup G] : AddTorsor G G
where
vsub := Sub.sub
vsub_vadd' := sub_add_cancel
vadd_vsub' := add_sub_cancel
#align add_group_is_add_torsor addGroupIsAddTorsor
/-- Simplify subtraction for a torsor for an `AddGroup G` over
itself. -/
@[simp]
theorem vsub_eq_sub {G : Type _} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=
rfl
#align vsub_eq_sub vsub_eq_sub
section General
variable {G : Type _} {P : Type _} [AddGroup G] [T : AddTorsor G P]
/-- Adding the result of subtracting from another point produces that
point. -/
@[simp]
theorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=
AddTorsor.vsub_vadd' p1 p2
#align vsub_vadd vsub_vadd
/-- Adding a group element then subtracting the original point
produces that group element. -/
@[simp]
theorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=
AddTorsor.vadd_vsub' g p
#align vadd_vsub vadd_vsub
/-- If the same point added to two group elements produces equal
results, those group elements are equal. -/
theorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by
-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p
rw [← vadd_vsub g1 p, h, vadd_vsub]
#align vadd_right_cancel vadd_right_cancel
@[simp]
theorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=
⟨vadd_right_cancel p, fun h => h ▸ rfl⟩
#align vadd_right_cancel_iff vadd_right_cancel_iff
/-- Adding a group element to the point `p` is an injective
function. -/
theorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>
vadd_right_cancel p
#align vadd_right_injective vadd_right_injective
/-- Adding a group element to a point, then subtracting another point,
produces the same result as subtracting the points then adding the
group element. -/
theorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) :=
by
apply vadd_right_cancel p2
rw [vsub_vadd, add_vadd, vsub_vadd]
#align vadd_vsub_assoc vadd_vsub_assoc
/-- Subtracting a point from itself produces 0. -/
@[simp]
theorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by
rw [← zero_add (p -ᵥ p), ← vadd_vsub_assoc, vadd_vsub]
#align vsub_self vsub_self
/-- If subtracting two points produces 0, they are equal. -/
theorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by
rw [← vsub_vadd p1 p2, h, zero_vadd]
#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero
/-- Subtracting two points produces 0 if and only if they are
equal. -/
@[simp]
theorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=
Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _
#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq
theorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=
not_congr vsub_eq_zero_iff_eq
#align vsub_ne_zero vsub_ne_zero
/-- Cancellation adding the results of two subtractions. -/
@[simp]
theorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 :=
by
apply vadd_right_cancel p3
rw [add_vadd, vsub_vadd, vsub_vadd, vsub_vadd]
#align vsub_add_vsub_cancel vsub_add_vsub_cancel
/-- Subtracting two points in the reverse order produces the negation
of subtracting them. -/
@[simp]
theorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 :=
by
refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)
rw [vsub_add_vsub_cancel, vsub_self]
#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev
theorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by
rw [vadd_vsub_assoc, sub_eq_add_neg, neg_vsub_eq_vsub_rev]
#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub
/-- Subtracting the result of adding a group element produces the same result
as subtracting the points and subtracting that group element. -/
theorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by
rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←
add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]
#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub
/-- Cancellation subtracting the results of two subtractions. -/
@[simp]
theorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by
rw [← vsub_vadd_eq_vsub_sub, vsub_vadd]
#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right
/-- Convert between an equality with adding a group element to a point
and an equality of a subtraction of two points with a group
element. -/
theorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=
⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩
#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq
theorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :
v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by
rw [eq_vadd_iff_vsub_eq, vadd_vsub_assoc, ← add_right_inj (-v₁), neg_add_cancel_left, eq_comm]
#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub
namespace Set
open Pointwise
-- Porting note: simp can prove this
--@[simp]
theorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by
rw [Set.singleton_vsub_singleton, vsub_self]
#align set.singleton_vsub_self Set.singleton_vsub_self
end Set
@[simp]
theorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by
rw [vsub_vadd_eq_vsub_sub, vadd_vsub_assoc, vsub_self, add_zero]
#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right
/-- If the same point subtracted from two points produces equal
results, those points are equal. -/
theorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by
rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h
#align vsub_left_cancel vsub_left_cancel
/-- The same point subtracted from two points produces equal results
if and only if those points are equal. -/
@[simp]
theorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=
⟨vsub_left_cancel, fun h => h ▸ rfl⟩
#align vsub_left_cancel_iff vsub_left_cancel_iff
/-- Subtracting the point `p` is an injective function. -/
theorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>
vsub_left_cancel
#align vsub_left_injective vsub_left_injective
/-- If subtracting two points from the same point produces equal
results, those points are equal. -/
theorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 :=
by
refine' vadd_left_cancel (p -ᵥ p2) _
rw [vsub_vadd, ← h, vsub_vadd]
#align vsub_right_cancel vsub_right_cancel
/-- Subtracting two points from the same point produces equal results
if and only if those points are equal. -/
@[simp]
theorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=
⟨vsub_right_cancel, fun h => h ▸ rfl⟩
#align vsub_right_cancel_iff vsub_right_cancel_iff
/-- Subtracting a point from the point `p` is an injective
function. -/
theorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>
vsub_right_cancel
#align vsub_right_injective vsub_right_injective
end General
section comm
variable {G : Type _} {P : Type _} [AddCommGroup G] [AddTorsor G P]
-- Porting note: Removed:
-- include G
/-- Cancellation subtracting the results of two subtractions. -/
@[simp]
theorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by
rw [sub_eq_add_neg, neg_vsub_eq_vsub_rev, add_comm, vsub_add_vsub_cancel]
#align vsub_sub_vsub_cancel_left vsub_sub_vsub_cancel_left
@[simp]
theorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by
rw [vsub_vadd_eq_vsub_sub, vadd_vsub_assoc, add_sub_cancel']
#align vadd_vsub_vadd_cancel_left vadd_vsub_vadd_cancel_left
theorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := by
rw [← @vsub_eq_zero_iff_eq G, vadd_vsub_assoc, vsub_vadd_eq_vsub_sub]
simp
#align vsub_vadd_comm vsub_vadd_comm
theorem vadd_eq_vadd_iff_sub_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :
v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂ := by
rw [vadd_eq_vadd_iff_neg_add_eq_vsub, neg_add_eq_sub]
#align vadd_eq_vadd_iff_sub_eq_vsub vadd_eq_vadd_iff_sub_eq_vsub
theorem vsub_sub_vsub_comm (p₁ p₂ p₃ p₄ : P) : p₁ -ᵥ p₂ - (p₃ -ᵥ p₄) = p₁ -ᵥ p₃ - (p₂ -ᵥ p₄) := by
rw [← vsub_vadd_eq_vsub_sub, vsub_vadd_comm, vsub_vadd_eq_vsub_sub]
#align vsub_sub_vsub_comm vsub_sub_vsub_comm
end comm
namespace Prod
variable {G : Type _} {P : Type _} {G' : Type _} {P' : Type _} [AddGroup G] [AddGroup G']
[AddTorsor G P] [AddTorsor G' P']
-- Porting note: the `{_ : ...}` instance terms make this instance not dangerous
instance {G : Type _} {P : Type _} {G' : Type _} {P' : Type _} {_ : AddGroup G} {_ : AddGroup G'}
[AddTorsor G P] [AddTorsor G' P'] : AddTorsor (G × G') (P × P') where
vadd v p := (v.1 +ᵥ p.1, v.2 +ᵥ p.2)
zero_vadd _ := Prod.ext (zero_vadd _ _) (zero_vadd _ _)
add_vadd _ _ _ := Prod.ext (add_vadd _ _ _) (add_vadd _ _ _)
vsub p₁ p₂ := (p₁.1 -ᵥ p₂.1, p₁.2 -ᵥ p₂.2)
Nonempty := Prod.Nonempty
vsub_vadd' _ _ := Prod.ext (vsub_vadd _ _) (vsub_vadd _ _)
vadd_vsub' _ _ := Prod.ext (vadd_vsub _ _) (vadd_vsub _ _)
-- Porting note: The proofs above used to be shorter:
-- zero_vadd p := by simp ⊢ 0 +ᵥ p = p
-- add_vadd := by simp [add_vadd] ⊢ ∀ (a : G) (b : G') (a_1 : G) (b_1 : G') (a_2 : P) (b_2 : P'),
-- (a + a_1, b + b_1) +ᵥ (a_2, b_2) = (a, b) +ᵥ ((a_1, b_1) +ᵥ (a_2, b_2))
-- vsub_vadd' p₁ p₂ := show (p₁.1 -ᵥ p₂.1 +ᵥ p₂.1, _) = p₁ by simp
-- ⊢ (p₁.fst -ᵥ p₂.fst +ᵥ p₂.fst, ((p₁.fst -ᵥ p₂.fst, p₁.snd -ᵥ p₂.snd) +ᵥ p₂).snd) = p₁
-- vadd_vsub' v p := show (v.1 +ᵥ p.1 -ᵥ p.1, v.2 +ᵥ p.2 -ᵥ p.2) = v by simp
-- ⊢ (v.fst +ᵥ p.fst -ᵥ p.fst, v.snd) = v
@[simp]
theorem fst_vadd (v : G × G') (p : P × P') : (v +ᵥ p).1 = v.1 +ᵥ p.1 :=
rfl
#align prod.fst_vadd Prod.fst_vadd
@[simp]
theorem snd_vadd (v : G × G') (p : P × P') : (v +ᵥ p).2 = v.2 +ᵥ p.2 :=
rfl
#align prod.snd_vadd Prod.snd_vadd
@[simp]
theorem mk_vadd_mk (v : G) (v' : G') (p : P) (p' : P') : (v, v') +ᵥ (p, p') = (v +ᵥ p, v' +ᵥ p') :=
rfl
#align prod.mk_vadd_mk Prod.mk_vadd_mk
@[simp]
theorem fst_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').1 = p₁.1 -ᵥ p₂.1 :=
rfl
#align prod.fst_vsub Prod.fst_vsub
@[simp]
theorem snd_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').2 = p₁.2 -ᵥ p₂.2 :=
rfl
#align prod.snd_vsub Prod.snd_vsub
@[simp]
theorem mk_vsub_mk (p₁ p₂ : P) (p₁' p₂' : P') :
((p₁, p₁') -ᵥ (p₂, p₂') : G × G') = (p₁ -ᵥ p₂, p₁' -ᵥ p₂') :=
rfl
#align prod.mk_vsub_mk Prod.mk_vsub_mk
end Prod
namespace Pi
universe u v w
variable {I : Type u} {fg : I → Type v} [∀ i, AddGroup (fg i)] {fp : I → Type w}
open AddAction AddTorsor
/-- A product of `AddTorsor`s is an `AddTorsor`. -/
instance [T : ∀ i, AddTorsor (fg i) (fp i)] : AddTorsor (∀ i, fg i) (∀ i, fp i) where
vadd g p i := g i +ᵥ p i
zero_vadd p := funext fun i => zero_vadd (fg i) (p i)
add_vadd g₁ g₂ p := funext fun i => add_vadd (g₁ i) (g₂ i) (p i)
vsub p₁ p₂ i := p₁ i -ᵥ p₂ i
Nonempty := ⟨fun i => Classical.choice (T i).Nonempty⟩
vsub_vadd' p₁ p₂ := funext fun i => vsub_vadd (p₁ i) (p₂ i)
vadd_vsub' g p := funext fun i => vadd_vsub (g i) (p i)
end Pi
namespace Equiv
variable {G : Type _} {P : Type _} [AddGroup G] [AddTorsor G P]
-- Porting note: Removed:
-- include G
/-- `v ↦ v +ᵥ p` as an equivalence. -/
def vaddConst (p : P) : G ≃ P where
toFun v := v +ᵥ p
invFun p' := p' -ᵥ p
left_inv _ := vadd_vsub _ _
right_inv _ := vsub_vadd _ _
#align equiv.vadd_const Equiv.vaddConst
@[simp]
theorem coe_vaddConst (p : P) : ⇑(vaddConst p) = fun v => v +ᵥ p :=
rfl
#align equiv.coe_vadd_const Equiv.coe_vaddConst
@[simp]
/-- `p' ↦ p -ᵥ p'` as an equivalence. -/
def constVSub (p : P) : P ≃ G where
toFun := (· -ᵥ ·) p
invFun v := -v +ᵥ p
left_inv p' := by simp
right_inv v := by simp [vsub_vadd_eq_vsub_sub]
#align equiv.const_vsub Equiv.constVSub
@[simp]
theorem coe_constVSub (p : P) : ⇑(constVSub p) = (· -ᵥ ·) p :=
rfl
#align equiv.coe_const_vsub Equiv.coe_constVSub
@[simp]
theorem coe_constVSub_symm (p : P) : ⇑(constVSub p).symm = fun (v : G) => -v +ᵥ p :=
rfl
#align equiv.coe_const_vsub_symm Equiv.coe_constVSub_symm
variable (P)
/-- The permutation given by `p ↦ v +ᵥ p`. -/
def constVAdd (v : G) : Equiv.Perm P where
toFun := (· +ᵥ ·) v
invFun := (· +ᵥ ·) (-v)
left_inv p := by simp [vadd_vadd]
right_inv p := by simp [vadd_vadd]
#align equiv.const_vadd Equiv.constVAdd
@[simp]
theorem coe_constVAdd (v : G) : ⇑(constVAdd P v) = (· +ᵥ ·) v :=
rfl
#align equiv.coe_const_vadd Equiv.coe_constVAdd
variable (G)
@[simp]
theorem constVAdd_zero : constVAdd P (0 : G) = 1 :=
ext <| zero_vadd G
#align equiv.const_vadd_zero Equiv.constVAdd_zero
variable {G}
@[simp]
theorem constVAdd_add (v₁ v₂ : G) : constVAdd P (v₁ + v₂) = constVAdd P v₁ * constVAdd P v₂ :=
ext <| add_vadd v₁ v₂
#align equiv.const_vadd_add Equiv.constVAdd_add
/-- `Equiv.constVAdd` as a homomorphism from `Multiplicative G` to `Equiv.perm P` -/
def constVAddHom : Multiplicative G →* Equiv.Perm P where
toFun v := constVAdd P (Multiplicative.toAdd v)
map_one' := constVAdd_zero G P
map_mul' := constVAdd_add P
#align equiv.const_vadd_hom Equiv.constVAddHom
variable {P}
-- Porting note: Previous code was:
-- open _Root_.Function
open Function
/-- Point reflection in `x` as a permutation. -/
def pointReflection (x : P) : Perm P :=
(constVSub x).trans (vaddConst x)
#align equiv.point_reflection Equiv.pointReflection
theorem pointReflection_apply (x y : P) : pointReflection x y = x -ᵥ y +ᵥ x :=
rfl
#align equiv.point_reflection_apply Equiv.pointReflection_apply
@[simp]
theorem pointReflection_symm (x : P) : (pointReflection x).symm = pointReflection x :=
ext <| by simp [pointReflection]
#align equiv.point_reflection_symm Equiv.pointReflection_symm
@[simp]
theorem pointReflection_self (x : P) : pointReflection x x = x :=
vsub_vadd _ _
#align equiv.point_reflection_self Equiv.pointReflection_self
theorem pointReflection_involutive (x : P) : Involutive (pointReflection x : P → P) := fun y =>
(Equiv.apply_eq_iff_eq_symm_apply _).2 <| by rw [pointReflection_symm]
#align equiv.point_reflection_involutive Equiv.pointReflection_involutive
set_option linter.deprecated false
/-- `x` is the only fixed point of `pointReflection x`. This lemma requires
`x + x = y + y ↔ x = y`. There is no typeclass to use here, so we add it as an explicit argument. -/
theorem pointReflection_fixed_iff_of_injective_bit0 {x y : P} (h : Injective (bit0 : G → G)) :
pointReflection x y = y ↔ y = x := by
rw [pointReflection_apply, eq_comm, eq_vadd_iff_vsub_eq, ← neg_vsub_eq_vsub_rev,
neg_eq_iff_add_eq_zero, ← bit0, ← bit0_zero, h.eq_iff, vsub_eq_zero_iff_eq, eq_comm]
#align
equiv.point_reflection_fixed_iff_of_injective_bit0
Equiv.pointReflection_fixed_iff_of_injective_bit0
-- Porting note: Removed:
-- omit G
-- Porting note: need this to calm down CI
theorem injective_pointReflection_left_of_injective_bit0 {G P : Type _} [AddCommGroup G]
[AddTorsor G P] (h : Injective (bit0 : G → G)) (y : P) :
Injective fun x : P => pointReflection x y :=
fun x₁ x₂ (hy : pointReflection x₁ y = pointReflection x₂ y) => by
rwa [pointReflection_apply, pointReflection_apply, vadd_eq_vadd_iff_sub_eq_vsub,
vsub_sub_vsub_cancel_right, ← neg_vsub_eq_vsub_rev, neg_eq_iff_add_eq_zero, ← bit0, ← bit0_zero,
h.eq_iff, vsub_eq_zero_iff_eq] at hy
#align
equiv.injective_point_reflection_left_of_injective_bit0
Equiv.injective_pointReflection_left_of_injective_bit0
end Equiv
theorem AddTorsor.subsingleton_iff (G P : Type _) [AddGroup G] [AddTorsor G P] :
Subsingleton G ↔ Subsingleton P := by
inhabit P
exact (Equiv.vaddConst default).subsingleton_congr
#align add_torsor.subsingleton_iff AddTorsor.subsingleton_iff
|
{-
cd collatzProof_DivSeq/program2
chcp 65001
idris
-}
module ProofColDivSeqBase
%default total
-- %language ElabReflection
%access export
-- mod2
public export
data Parity : Nat -> Type where
Even : Parity (n + n)
Odd : Parity (S (n + n))
helpEven : (j : Nat) -> Parity (S j + S j) -> Parity (S (S (plus j j)))
helpEven j p = rewrite plusSuccRightSucc j j in p
helpOdd : (j : Nat) -> Parity (S (S (j + S j))) -> Parity (S (S (S (j + j))))
helpOdd j p = rewrite plusSuccRightSucc j j in p
parity : (n:Nat) -> Parity n
parity Z = Even {n=Z}
parity (S Z) = Odd {n=Z}
parity (S (S k)) with (parity k)
parity (S (S (j + j))) | Even = helpEven j (Even {n = S j})
parity (S (S (S (j + j)))) | Odd = helpOdd j (Odd {n = S j})
-- mod3
public export
data Mod3 : Nat -> Type where
ThreeZero : Mod3 (n + n + n)
ThreeOne : Mod3 (S (n + n + n))
ThreeTwo : Mod3 (S (S (n + n + n)))
helpThreeZero : (j:Nat) -> (plus (plus (S j) (S j)) (S j)) = S (S (S (plus (plus j j) j)))
helpThreeZero j = rewrite sym $ plusSuccRightSucc j j in
rewrite sym $ plusSuccRightSucc (plus j j) j in Refl
helpThreeOne : (j:Nat) -> S (plus (plus (S j) (S j)) (S j)) = S (S (S (S (plus (plus j j) j))))
helpThreeOne j = cong {f=S} $ helpThreeZero j
helpThreeTwo : (j:Nat) -> S (S (plus (plus (S j) (S j)) (S j))) = S (S (S (S (S (plus (plus j j) j)))))
helpThreeTwo j = cong {f=S} $ helpThreeOne j
mod3 : (n:Nat) -> Mod3 n
mod3 Z = ThreeZero {n=Z}
mod3 (S Z) = ThreeOne {n=Z}
mod3 (S (S Z)) = ThreeTwo {n=Z}
mod3 (S (S (S k))) with (mod3 k)
mod3 (S (S (S (j + j + j)))) | ThreeZero =
rewrite sym $ helpThreeZero j in ThreeZero {n=S j}
mod3 (S (S (S (S (j + j + j))))) | ThreeOne =
rewrite sym $ helpThreeOne j in ThreeOne {n=S j}
mod3 (S (S (S (S (S (j + j + j)))))) | ThreeTwo =
rewrite sym $ helpThreeTwo j in ThreeTwo {n=S j}
-- ---------------------------------
-- divSeqの実装に必要な関数
-- ----- from libs/contrib/Data/CoList.idr -----
public export
codata CoList : Type -> Type where
Nil : CoList a
(::) : a -> CoList a -> CoList a
implementation Functor CoList where
map f [] = []
map f (x::xs) = f x :: map f xs
implementation Show a => Show (CoList a) where
show xs = "[" ++ show' "" 20 xs ++ "]" where
show' : String -> (n : Nat) -> (xs : CoList a) -> String
show' acc Z _ = acc ++ "..."
show' acc (S n) [] = acc
show' acc (S n) [x] = acc ++ show x
show' acc (S n) (x :: xs) = show' (acc ++ (show x) ++ ", ") n xs
unfoldr : (a -> Maybe (b, a)) -> a -> CoList b
unfoldr f x =
case f x of
Just (y, new_x) => y :: (unfoldr f new_x)
_ => []
-- ----- from libs/contrib/Data/CoList.idr -----
countEven : Nat -> Nat -> Nat -> (Nat, Nat)
countEven n Z acc = (acc, n)
countEven n (S nn) acc =
if (modNatNZ n 2 SIsNotZ) == 1
then (acc, n)
else countEven (divNatNZ n 2 SIsNotZ) nn (acc+1)
-- divSeqの実装
divSeq : Nat -> CoList Integer
divSeq n = divSeq' n n
where
divSeq' : Nat -> Nat -> CoList Integer
divSeq' n Z = []
divSeq' Z (S k) = []
divSeq' (S n) (S k) with (parity n)
divSeq' (S (S (j + j))) (S k) | Odd = divSeq' (S j) k
divSeq' (S (j + j) ) (S k) | Even =
map toIntegerNat
(unfoldr (\b => if b <= 1 then Nothing
else Just (countEven (b*3+1) (b*3+1) 0) ) (S (j + j)))
definiDivSeq0 : divSeq Z = []
definiDivSeq0 = Refl
-- ---------------------------------
-- その他関数
limitedNStep : CoList Integer -> Nat -> Bool
limitedNStep [] _ = True
limitedNStep (_ :: _) Z = False
limitedNStep (_ :: xs) (S n) = limitedNStep xs n
definiLimited0 : limitedNStep [] Z = True
definiLimited0 = Refl
-- ---------------------------------
|
------------------------------------------------------------------------
-- The unit type (in Set₁)
------------------------------------------------------------------------
module Data.Unit1 where
record ⊤₁ : Set₁ where
|
/-
Copyright (c) 2020 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Floris van Doorn
-/
import measure_theory.measure.giry_monad
import dynamics.ergodic.measure_preserving
import measure_theory.integral.set_integral
import measure_theory.measure.open_pos
/-!
# The product measure
In this file we define and prove properties about the binary product measure. If `α` and `β` have
σ-finite measures `μ` resp. `ν` then `α × β` can be equipped with a σ-finite measure `μ.prod ν` that
satisfies `(μ.prod ν) s = ∫⁻ x, ν {y | (x, y) ∈ s} ∂μ`.
We also have `(μ.prod ν) (s ×ˢ t) = μ s * ν t`, i.e. the measure of a rectangle is the product of
the measures of the sides.
We also prove Tonelli's theorem and Fubini's theorem.
## Main definition
* `measure_theory.measure.prod`: The product of two measures.
## Main results
* `measure_theory.measure.prod_apply` states `μ.prod ν s = ∫⁻ x, ν {y | (x, y) ∈ s} ∂μ`
for measurable `s`. `measure_theory.measure.prod_apply_symm` is the reversed version.
* `measure_theory.measure.prod_prod` states `μ.prod ν (s ×ˢ t) = μ s * ν t` for measurable sets
`s` and `t`.
* `measure_theory.lintegral_prod`: Tonelli's theorem. It states that for a measurable function
`α × β → ℝ≥0∞` we have `∫⁻ z, f z ∂(μ.prod ν) = ∫⁻ x, ∫⁻ y, f (x, y) ∂ν ∂μ`. The version
for functions `α → β → ℝ≥0∞` is reversed, and called `lintegral_lintegral`. Both versions have
a variant with `_symm` appended, where the order of integration is reversed.
The lemma `measurable.lintegral_prod_right'` states that the inner integral of the right-hand side
is measurable.
* `measure_theory.integrable_prod_iff` states that a binary function is integrable iff both
* `y ↦ f (x, y)` is integrable for almost every `x`, and
* the function `x ↦ ∫ ∥f (x, y)∥ dy` is integrable.
* `measure_theory.integral_prod`: Fubini's theorem. It states that for a integrable function
`α × β → E` (where `E` is a second countable Banach space) we have
`∫ z, f z ∂(μ.prod ν) = ∫ x, ∫ y, f (x, y) ∂ν ∂μ`. This theorem has the same variants as
Tonelli's theorem. The lemma `measure_theory.integrable.integral_prod_right` states that the
inner integral of the right-hand side is integrable.
## Implementation Notes
Many results are proven twice, once for functions in curried form (`α → β → γ`) and one for
functions in uncurried form (`α × β → γ`). The former often has an assumption
`measurable (uncurry f)`, which could be inconvenient to discharge, but for the latter it is more
common that the function has to be given explicitly, since Lean cannot synthesize the function by
itself. We name the lemmas about the uncurried form with a prime.
Tonelli's theorem and Fubini's theorem have a different naming scheme, since the version for the
uncurried version is reversed.
## Tags
product measure, Fubini's theorem, Tonelli's theorem, Fubini-Tonelli theorem
-/
noncomputable theory
open_locale classical topological_space ennreal measure_theory
open set function real ennreal
open measure_theory measurable_space measure_theory.measure
open topological_space (hiding generate_from)
open filter (hiding prod_eq map)
variables {α α' β β' γ E : Type*}
/-- Rectangles formed by π-systems form a π-system. -/
lemma is_pi_system.prod {C : set (set α)} {D : set (set β)} (hC : is_pi_system C)
(hD : is_pi_system D) : is_pi_system (image2 (×ˢ) C D) :=
begin
rintro _ ⟨s₁, t₁, hs₁, ht₁, rfl⟩ _ ⟨s₂, t₂, hs₂, ht₂, rfl⟩ hst,
rw [prod_inter_prod] at hst ⊢, rw [prod_nonempty_iff] at hst,
exact mem_image2_of_mem (hC _ hs₁ _ hs₂ hst.1) (hD _ ht₁ _ ht₂ hst.2)
end
/-- Rectangles of countably spanning sets are countably spanning. -/
lemma is_countably_spanning.prod {C : set (set α)} {D : set (set β)}
(hC : is_countably_spanning C) (hD : is_countably_spanning D) :
is_countably_spanning (image2 (×ˢ) C D) :=
begin
rcases ⟨hC, hD⟩ with ⟨⟨s, h1s, h2s⟩, t, h1t, h2t⟩,
refine ⟨λ n, (s n.unpair.1) ×ˢ (t n.unpair.2), λ n, mem_image2_of_mem (h1s _) (h1t _), _⟩,
rw [Union_unpair_prod, h2s, h2t, univ_prod_univ]
end
variables [measurable_space α] [measurable_space α'] [measurable_space β] [measurable_space β']
variables [measurable_space γ]
variables {μ : measure α} {ν : measure β} {τ : measure γ}
variables [normed_group E]
/-! ### Measurability
Before we define the product measure, we can talk about the measurability of operations on binary
functions. We show that if `f` is a binary measurable function, then the function that integrates
along one of the variables (using either the Lebesgue or Bochner integral) is measurable.
-/
/-- The product of generated σ-algebras is the one generated by rectangles, if both generating sets
are countably spanning. -/
lemma generate_from_prod_eq {α β} {C : set (set α)} {D : set (set β)}
(hC : is_countably_spanning C) (hD : is_countably_spanning D) :
@prod.measurable_space _ _ (generate_from C) (generate_from D) =
generate_from (image2 (×ˢ) C D) :=
begin
apply le_antisymm,
{ refine sup_le _ _; rw [comap_generate_from];
apply generate_from_le; rintro _ ⟨s, hs, rfl⟩,
{ rcases hD with ⟨t, h1t, h2t⟩,
rw [← prod_univ, ← h2t, prod_Union],
apply measurable_set.Union,
intro n, apply measurable_set_generate_from,
exact ⟨s, t n, hs, h1t n, rfl⟩ },
{ rcases hC with ⟨t, h1t, h2t⟩,
rw [← univ_prod, ← h2t, Union_prod_const],
apply measurable_set.Union,
rintro n, apply measurable_set_generate_from,
exact mem_image2_of_mem (h1t n) hs } },
{ apply generate_from_le, rintro _ ⟨s, t, hs, ht, rfl⟩, rw [prod_eq],
apply (measurable_fst _).inter (measurable_snd _),
{ exact measurable_set_generate_from hs },
{ exact measurable_set_generate_from ht } }
end
/-- If `C` and `D` generate the σ-algebras on `α` resp. `β`, then rectangles formed by `C` and `D`
generate the σ-algebra on `α × β`. -/
lemma generate_from_eq_prod {C : set (set α)} {D : set (set β)} (hC : generate_from C = ‹_›)
(hD : generate_from D = ‹_›) (h2C : is_countably_spanning C) (h2D : is_countably_spanning D) :
generate_from (image2 (×ˢ) C D) = prod.measurable_space :=
by rw [← hC, ← hD, generate_from_prod_eq h2C h2D]
/-- The product σ-algebra is generated from boxes, i.e. `s ×ˢ t` for sets `s : set α` and
`t : set β`. -/
lemma generate_from_prod :
generate_from (image2 (×ˢ) {s : set α | measurable_set s} {t : set β | measurable_set t}) =
prod.measurable_space :=
generate_from_eq_prod generate_from_measurable_set generate_from_measurable_set
is_countably_spanning_measurable_set is_countably_spanning_measurable_set
/-- Rectangles form a π-system. -/
lemma is_pi_system_prod :
is_pi_system (image2 (×ˢ) {s : set α | measurable_set s} {t : set β | measurable_set t}) :=
is_pi_system_measurable_set.prod is_pi_system_measurable_set
/-- If `ν` is a finite measure, and `s ⊆ α × β` is measurable, then `x ↦ ν { y | (x, y) ∈ s }` is
a measurable function. `measurable_measure_prod_mk_left` is strictly more general. -/
lemma measurable_measure_prod_mk_left_finite [is_finite_measure ν] {s : set (α × β)}
(hs : measurable_set s) : measurable (λ x, ν (prod.mk x ⁻¹' s)) :=
begin
refine induction_on_inter generate_from_prod.symm is_pi_system_prod _ _ _ _ hs,
{ simp [measurable_zero, const_def] },
{ rintro _ ⟨s, t, hs, ht, rfl⟩, simp only [mk_preimage_prod_right_eq_if, measure_if],
exact measurable_const.indicator hs },
{ intros t ht h2t,
simp_rw [preimage_compl, measure_compl (measurable_prod_mk_left ht) (measure_ne_top ν _)],
exact h2t.const_sub _ },
{ intros f h1f h2f h3f, simp_rw [preimage_Union],
have : ∀ b, ν (⋃ i, prod.mk b ⁻¹' f i) = ∑' i, ν (prod.mk b ⁻¹' f i) :=
λ b, measure_Union (λ i j hij, disjoint.preimage _ (h1f i j hij))
(λ i, measurable_prod_mk_left (h2f i)),
simp_rw [this], apply measurable.ennreal_tsum h3f },
end
/-- If `ν` is a σ-finite measure, and `s ⊆ α × β` is measurable, then `x ↦ ν { y | (x, y) ∈ s }` is
a measurable function. -/
lemma measurable_measure_prod_mk_left [sigma_finite ν] {s : set (α × β)}
(hs : measurable_set s) : measurable (λ x, ν (prod.mk x ⁻¹' s)) :=
begin
have : ∀ x, measurable_set (prod.mk x ⁻¹' s) := λ x, measurable_prod_mk_left hs,
simp only [← @supr_restrict_spanning_sets _ _ ν, this],
apply measurable_supr, intro i,
haveI := fact.mk (measure_spanning_sets_lt_top ν i),
exact measurable_measure_prod_mk_left_finite hs
end
/-- If `μ` is a σ-finite measure, and `s ⊆ α × β` is measurable, then `y ↦ μ { x | (x, y) ∈ s }` is
a measurable function. -/
lemma measurable_measure_prod_mk_right {μ : measure α} [sigma_finite μ] {s : set (α × β)}
(hs : measurable_set s) : measurable (λ y, μ ((λ x, (x, y)) ⁻¹' s)) :=
measurable_measure_prod_mk_left (measurable_set_swap_iff.mpr hs)
lemma measurable.map_prod_mk_left [sigma_finite ν] : measurable (λ x : α, map (prod.mk x) ν) :=
begin
apply measurable_of_measurable_coe, intros s hs,
simp_rw [map_apply measurable_prod_mk_left hs],
exact measurable_measure_prod_mk_left hs
end
lemma measurable.map_prod_mk_right {μ : measure α} [sigma_finite μ] :
measurable (λ y : β, map (λ x : α, (x, y)) μ) :=
begin
apply measurable_of_measurable_coe, intros s hs,
simp_rw [map_apply measurable_prod_mk_right hs],
exact measurable_measure_prod_mk_right hs
end
/-- The Lebesgue integral is measurable. This shows that the integrand of (the right-hand-side of)
Tonelli's theorem is measurable. -/
lemma measurable.lintegral_prod_right' [sigma_finite ν] :
∀ {f : α × β → ℝ≥0∞} (hf : measurable f), measurable (λ x, ∫⁻ y, f (x, y) ∂ν) :=
begin
have m := @measurable_prod_mk_left,
refine measurable.ennreal_induction _ _ _,
{ intros c s hs, simp only [← indicator_comp_right],
suffices : measurable (λ x, c * ν (prod.mk x ⁻¹' s)),
{ simpa [lintegral_indicator _ (m hs)] },
exact (measurable_measure_prod_mk_left hs).const_mul _ },
{ rintro f g - hf hg h2f h2g, simp_rw [pi.add_apply, lintegral_add_left (hf.comp m)],
exact h2f.add h2g },
{ intros f hf h2f h3f,
have := measurable_supr h3f,
have : ∀ x, monotone (λ n y, f n (x, y)) := λ x i j hij y, h2f hij (x, y),
simpa [lintegral_supr (λ n, (hf n).comp m), this] }
end
/-- The Lebesgue integral is measurable. This shows that the integrand of (the right-hand-side of)
Tonelli's theorem is measurable.
This version has the argument `f` in curried form. -/
lemma measurable.lintegral_prod_right [sigma_finite ν] {f : α → β → ℝ≥0∞}
(hf : measurable (uncurry f)) : measurable (λ x, ∫⁻ y, f x y ∂ν) :=
hf.lintegral_prod_right'
/-- The Lebesgue integral is measurable. This shows that the integrand of (the right-hand-side of)
the symmetric version of Tonelli's theorem is measurable. -/
lemma measurable.lintegral_prod_left' [sigma_finite μ] {f : α × β → ℝ≥0∞}
(hf : measurable f) : measurable (λ y, ∫⁻ x, f (x, y) ∂μ) :=
(measurable_swap_iff.mpr hf).lintegral_prod_right'
/-- The Lebesgue integral is measurable. This shows that the integrand of (the right-hand-side of)
the symmetric version of Tonelli's theorem is measurable.
This version has the argument `f` in curried form. -/
lemma measurable.lintegral_prod_left [sigma_finite μ] {f : α → β → ℝ≥0∞}
(hf : measurable (uncurry f)) : measurable (λ y, ∫⁻ x, f x y ∂μ) :=
hf.lintegral_prod_left'
lemma measurable_set_integrable [sigma_finite ν] ⦃f : α → β → E⦄
(hf : strongly_measurable (uncurry f)) : measurable_set {x | integrable (f x) ν} :=
begin
simp_rw [integrable, hf.of_uncurry_left.ae_strongly_measurable, true_and],
exact measurable_set_lt (measurable.lintegral_prod_right hf.ennnorm) measurable_const
end
section
variables [normed_space ℝ E] [complete_space E]
/-- The Bochner integral is measurable. This shows that the integrand of (the right-hand-side of)
Fubini's theorem is measurable.
This version has `f` in curried form. -/
lemma measure_theory.strongly_measurable.integral_prod_right [sigma_finite ν] ⦃f : α → β → E⦄
(hf : strongly_measurable (uncurry f)) : strongly_measurable (λ x, ∫ y, f x y ∂ν) :=
begin
borelize E,
haveI : separable_space (range (uncurry f) ∪ {0} : set E) :=
hf.separable_space_range_union_singleton,
let s : ℕ → simple_func (α × β) E := simple_func.approx_on _ hf.measurable
(range (uncurry f) ∪ {0}) 0 (by simp),
let s' : ℕ → α → simple_func β E := λ n x, (s n).comp (prod.mk x) measurable_prod_mk_left,
let f' : ℕ → α → E := λ n, {x | integrable (f x) ν}.indicator
(λ x, (s' n x).integral ν),
have hf' : ∀ n, strongly_measurable (f' n),
{ intro n, refine strongly_measurable.indicator _ (measurable_set_integrable hf),
have : ∀ x, (s' n x).range.filter (λ x, x ≠ 0) ⊆ (s n).range,
{ intros x, refine finset.subset.trans (finset.filter_subset _ _) _, intro y,
simp_rw [simple_func.mem_range], rintro ⟨z, rfl⟩, exact ⟨(x, z), rfl⟩ },
simp only [simple_func.integral_eq_sum_of_subset (this _)],
refine finset.strongly_measurable_sum _ (λ x _, _),
refine (measurable.ennreal_to_real _).strongly_measurable.smul_const _,
simp only [simple_func.coe_comp, preimage_comp] {single_pass := tt},
apply measurable_measure_prod_mk_left,
exact (s n).measurable_set_fiber x },
have h2f' : tendsto f' at_top (𝓝 (λ (x : α), ∫ (y : β), f x y ∂ν)),
{ rw [tendsto_pi_nhds], intro x,
by_cases hfx : integrable (f x) ν,
{ have : ∀ n, integrable (s' n x) ν,
{ intro n, apply (hfx.norm.add hfx.norm).mono' (s' n x).ae_strongly_measurable,
apply eventually_of_forall, intro y,
simp_rw [s', simple_func.coe_comp], exact simple_func.norm_approx_on_zero_le _ _ (x, y) n },
simp only [f', hfx, simple_func.integral_eq_integral _ (this _), indicator_of_mem,
mem_set_of_eq],
refine tendsto_integral_of_dominated_convergence (λ y, ∥f x y∥ + ∥f x y∥)
(λ n, (s' n x).ae_strongly_measurable) (hfx.norm.add hfx.norm) _ _,
{ exact λ n, eventually_of_forall (λ y, simple_func.norm_approx_on_zero_le _ _ (x, y) n) },
{ refine eventually_of_forall (λ y, simple_func.tendsto_approx_on _ _ _),
apply subset_closure,
simp [-uncurry_apply_pair], } },
{ simpa [f', hfx, integral_undef] using @tendsto_const_nhds _ _ _ (0 : E) _, } },
exact strongly_measurable_of_tendsto _ hf' h2f'
end
/-- The Bochner integral is measurable. This shows that the integrand of (the right-hand-side of)
Fubini's theorem is measurable. -/
lemma measure_theory.strongly_measurable.integral_prod_right' [sigma_finite ν] ⦃f : α × β → E⦄
(hf : strongly_measurable f) : strongly_measurable (λ x, ∫ y, f (x, y) ∂ν) :=
by { rw [← uncurry_curry f] at hf, exact hf.integral_prod_right }
/-- The Bochner integral is measurable. This shows that the integrand of (the right-hand-side of)
the symmetric version of Fubini's theorem is measurable.
This version has `f` in curried form. -/
lemma measure_theory.strongly_measurable.integral_prod_left [sigma_finite μ] ⦃f : α → β → E⦄
(hf : strongly_measurable (uncurry f)) : strongly_measurable (λ y, ∫ x, f x y ∂μ) :=
(hf.comp_measurable measurable_swap).integral_prod_right'
/-- The Bochner integral is measurable. This shows that the integrand of (the right-hand-side of)
the symmetric version of Fubini's theorem is measurable. -/
lemma measure_theory.strongly_measurable.integral_prod_left' [sigma_finite μ] ⦃f : α × β → E⦄
(hf : strongly_measurable f) : strongly_measurable (λ y, ∫ x, f (x, y) ∂μ) :=
(hf.comp_measurable measurable_swap).integral_prod_right'
end
/-! ### The product measure -/
namespace measure_theory
namespace measure
/-- The binary product of measures. They are defined for arbitrary measures, but we basically
prove all properties under the assumption that at least one of them is σ-finite. -/
@[irreducible] protected def prod (μ : measure α) (ν : measure β) : measure (α × β) :=
bind μ $ λ x : α, map (prod.mk x) ν
instance prod.measure_space {α β} [measure_space α] [measure_space β] : measure_space (α × β) :=
{ volume := volume.prod volume }
variables {μ ν} [sigma_finite ν]
lemma volume_eq_prod (α β) [measure_space α] [measure_space β] :
(volume : measure (α × β)) = (volume : measure α).prod (volume : measure β) :=
rfl
lemma prod_apply {s : set (α × β)} (hs : measurable_set s) :
μ.prod ν s = ∫⁻ x, ν (prod.mk x ⁻¹' s) ∂μ :=
by simp_rw [measure.prod, bind_apply hs measurable.map_prod_mk_left,
map_apply measurable_prod_mk_left hs]
/-- The product measure of the product of two sets is the product of their measures. Note that we
do not need the sets to be measurable. -/
@[simp] lemma prod_prod (s : set α) (t : set β) : μ.prod ν (s ×ˢ t) = μ s * ν t :=
begin
apply le_antisymm,
{ set ST := (to_measurable μ s) ×ˢ (to_measurable ν t),
have hSTm : measurable_set ST :=
(measurable_set_to_measurable _ _).prod (measurable_set_to_measurable _ _),
calc μ.prod ν (s ×ˢ t) ≤ μ.prod ν ST :
measure_mono $ set.prod_mono (subset_to_measurable _ _) (subset_to_measurable _ _)
... = μ (to_measurable μ s) * ν (to_measurable ν t) :
by simp_rw [prod_apply hSTm, mk_preimage_prod_right_eq_if, measure_if,
lintegral_indicator _ (measurable_set_to_measurable _ _), lintegral_const,
restrict_apply_univ, mul_comm]
... = μ s * ν t : by rw [measure_to_measurable, measure_to_measurable] },
{ /- Formalization is based on https://mathoverflow.net/a/254134/136589 -/
set ST := to_measurable (μ.prod ν) (s ×ˢ t),
have hSTm : measurable_set ST := measurable_set_to_measurable _ _,
have hST : s ×ˢ t ⊆ ST := subset_to_measurable _ _,
set f : α → ℝ≥0∞ := λ x, ν (prod.mk x ⁻¹' ST),
have hfm : measurable f := measurable_measure_prod_mk_left hSTm,
set s' : set α := {x | ν t ≤ f x},
have hss' : s ⊆ s' := λ x hx, measure_mono (λ y hy, hST $ mk_mem_prod hx hy),
calc μ s * ν t ≤ μ s' * ν t : mul_le_mul_right' (measure_mono hss') _
... = ∫⁻ x in s', ν t ∂μ : by rw [set_lintegral_const, mul_comm]
... ≤ ∫⁻ x in s', f x ∂μ : set_lintegral_mono measurable_const hfm (λ x, id)
... ≤ ∫⁻ x, f x ∂μ : lintegral_mono' restrict_le_self le_rfl
... = μ.prod ν ST : (prod_apply hSTm).symm
... = μ.prod ν (s ×ˢ t) : measure_to_measurable _ }
end
instance {X Y : Type*} [topological_space X] [topological_space Y]
{m : measurable_space X} {μ : measure X} [is_open_pos_measure μ]
{m' : measurable_space Y} {ν : measure Y} [is_open_pos_measure ν] [sigma_finite ν] :
is_open_pos_measure (μ.prod ν) :=
begin
constructor,
rintros U U_open ⟨⟨x, y⟩, hxy⟩,
rcases is_open_prod_iff.1 U_open x y hxy with ⟨u, v, u_open, v_open, xu, yv, huv⟩,
refine ne_of_gt (lt_of_lt_of_le _ (measure_mono huv)),
simp only [prod_prod, canonically_ordered_comm_semiring.mul_pos],
split,
{ exact u_open.measure_pos μ ⟨x, xu⟩ },
{ exact v_open.measure_pos ν ⟨y, yv⟩ }
end
instance {α β : Type*} {mα : measurable_space α} {mβ : measurable_space β}
(μ : measure α) (ν : measure β) [is_finite_measure μ] [is_finite_measure ν] :
is_finite_measure (μ.prod ν) :=
begin
constructor,
rw [← univ_prod_univ, prod_prod],
exact mul_lt_top (measure_lt_top _ _).ne (measure_lt_top _ _).ne,
end
instance {α β : Type*} {mα : measurable_space α} {mβ : measurable_space β}
(μ : measure α) (ν : measure β) [is_probability_measure μ] [is_probability_measure ν] :
is_probability_measure (μ.prod ν) :=
⟨by rw [← univ_prod_univ, prod_prod, measure_univ, measure_univ, mul_one]⟩
instance {α β : Type*} [topological_space α] [topological_space β]
{mα : measurable_space α} {mβ : measurable_space β} (μ : measure α) (ν : measure β)
[is_finite_measure_on_compacts μ] [is_finite_measure_on_compacts ν] [sigma_finite ν] :
is_finite_measure_on_compacts (μ.prod ν) :=
begin
refine ⟨λ K hK, _⟩,
set L := (prod.fst '' K) ×ˢ (prod.snd '' K) with hL,
have : K ⊆ L,
{ rintros ⟨x, y⟩ hxy,
simp only [prod_mk_mem_set_prod_eq, mem_image, prod.exists, exists_and_distrib_right,
exists_eq_right],
exact ⟨⟨y, hxy⟩, ⟨x, hxy⟩⟩ },
apply lt_of_le_of_lt (measure_mono this),
rw [hL, prod_prod],
exact mul_lt_top ((is_compact.measure_lt_top ((hK.image continuous_fst))).ne)
((is_compact.measure_lt_top ((hK.image continuous_snd))).ne)
end
lemma ae_measure_lt_top {s : set (α × β)} (hs : measurable_set s)
(h2s : (μ.prod ν) s ≠ ∞) : ∀ᵐ x ∂μ, ν (prod.mk x ⁻¹' s) < ∞ :=
by { simp_rw [prod_apply hs] at h2s, refine ae_lt_top (measurable_measure_prod_mk_left hs) h2s }
lemma integrable_measure_prod_mk_left {s : set (α × β)}
(hs : measurable_set s) (h2s : (μ.prod ν) s ≠ ∞) :
integrable (λ x, (ν (prod.mk x ⁻¹' s)).to_real) μ :=
begin
refine ⟨(measurable_measure_prod_mk_left hs).ennreal_to_real.ae_measurable.ae_strongly_measurable,
_⟩,
simp_rw [has_finite_integral, ennnorm_eq_of_real to_real_nonneg],
convert h2s.lt_top using 1, simp_rw [prod_apply hs], apply lintegral_congr_ae,
refine (ae_measure_lt_top hs h2s).mp _, apply eventually_of_forall, intros x hx,
rw [lt_top_iff_ne_top] at hx, simp [of_real_to_real, hx],
end
/-- Note: the assumption `hs` cannot be dropped. For a counterexample, see
Walter Rudin *Real and Complex Analysis*, example (c) in section 8.9. -/
lemma measure_prod_null {s : set (α × β)}
(hs : measurable_set s) : μ.prod ν s = 0 ↔ (λ x, ν (prod.mk x ⁻¹' s)) =ᵐ[μ] 0 :=
by simp_rw [prod_apply hs, lintegral_eq_zero_iff (measurable_measure_prod_mk_left hs)]
/-- Note: the converse is not true without assuming that `s` is measurable. For a counterexample,
see Walter Rudin *Real and Complex Analysis*, example (c) in section 8.9. -/
lemma measure_ae_null_of_prod_null {s : set (α × β)}
(h : μ.prod ν s = 0) : (λ x, ν (prod.mk x ⁻¹' s)) =ᵐ[μ] 0 :=
begin
obtain ⟨t, hst, mt, ht⟩ := exists_measurable_superset_of_null h,
simp_rw [measure_prod_null mt] at ht,
rw [eventually_le_antisymm_iff],
exact ⟨eventually_le.trans_eq
(eventually_of_forall $ λ x, (measure_mono (preimage_mono hst) : _)) ht,
eventually_of_forall $ λ x, zero_le _⟩
end
/-- Note: the converse is not true. For a counterexample, see
Walter Rudin *Real and Complex Analysis*, example (c) in section 8.9. -/
lemma ae_ae_of_ae_prod {p : α × β → Prop} (h : ∀ᵐ z ∂μ.prod ν, p z) :
∀ᵐ x ∂ μ, ∀ᵐ y ∂ ν, p (x, y) :=
measure_ae_null_of_prod_null h
/-- `μ.prod ν` has finite spanning sets in rectangles of finite spanning sets. -/
noncomputable! def finite_spanning_sets_in.prod {ν : measure β} {C : set (set α)} {D : set (set β)}
(hμ : μ.finite_spanning_sets_in C) (hν : ν.finite_spanning_sets_in D) :
(μ.prod ν).finite_spanning_sets_in (image2 (×ˢ) C D) :=
begin
haveI := hν.sigma_finite,
refine ⟨λ n, hμ.set n.unpair.1 ×ˢ hν.set n.unpair.2,
λ n, mem_image2_of_mem (hμ.set_mem _) (hν.set_mem _), λ n, _, _⟩,
{ rw [prod_prod],
exact mul_lt_top (hμ.finite _).ne (hν.finite _).ne },
{ simp_rw [Union_unpair_prod, hμ.spanning, hν.spanning, univ_prod_univ] }
end
lemma prod_fst_absolutely_continuous : map prod.fst (μ.prod ν) ≪ μ :=
begin
refine absolutely_continuous.mk (λ s hs h2s, _),
rw [map_apply measurable_fst hs, ← prod_univ, prod_prod, h2s, zero_mul],
end
lemma prod_snd_absolutely_continuous : map prod.snd (μ.prod ν) ≪ ν :=
begin
refine absolutely_continuous.mk (λ s hs h2s, _),
rw [map_apply measurable_snd hs, ← univ_prod, prod_prod, h2s, mul_zero]
end
variables [sigma_finite μ]
instance prod.sigma_finite : sigma_finite (μ.prod ν) :=
(μ.to_finite_spanning_sets_in.prod ν.to_finite_spanning_sets_in).sigma_finite
/-- A measure on a product space equals the product measure if they are equal on rectangles
with as sides sets that generate the corresponding σ-algebras. -/
lemma prod_eq_generate_from {μ : measure α} {ν : measure β} {C : set (set α)}
{D : set (set β)} (hC : generate_from C = ‹_›)
(hD : generate_from D = ‹_›) (h2C : is_pi_system C) (h2D : is_pi_system D)
(h3C : μ.finite_spanning_sets_in C) (h3D : ν.finite_spanning_sets_in D)
{μν : measure (α × β)}
(h₁ : ∀ (s ∈ C) (t ∈ D), μν (s ×ˢ t) = μ s * ν t) : μ.prod ν = μν :=
begin
refine (h3C.prod h3D).ext
(generate_from_eq_prod hC hD h3C.is_countably_spanning h3D.is_countably_spanning).symm
(h2C.prod h2D) _,
{ rintro _ ⟨s, t, hs, ht, rfl⟩, haveI := h3D.sigma_finite,
rw [h₁ s hs t ht, prod_prod] }
end
/-- A measure on a product space equals the product measure if they are equal on rectangles. -/
lemma prod_eq {μν : measure (α × β)}
(h : ∀ s t, measurable_set s → measurable_set t → μν (s ×ˢ t) = μ s * ν t) : μ.prod ν = μν :=
prod_eq_generate_from generate_from_measurable_set generate_from_measurable_set
is_pi_system_measurable_set is_pi_system_measurable_set
μ.to_finite_spanning_sets_in ν.to_finite_spanning_sets_in (λ s hs t ht, h s t hs ht)
lemma prod_swap : map prod.swap (μ.prod ν) = ν.prod μ :=
begin
refine (prod_eq _).symm,
intros s t hs ht,
simp_rw [map_apply measurable_swap (hs.prod ht), preimage_swap_prod, prod_prod, mul_comm]
end
lemma prod_apply_symm {s : set (α × β)} (hs : measurable_set s) :
μ.prod ν s = ∫⁻ y, μ ((λ x, (x, y)) ⁻¹' s) ∂ν :=
by { rw [← prod_swap, map_apply measurable_swap hs],
simp only [prod_apply (measurable_swap hs)], refl }
lemma prod_assoc_prod [sigma_finite τ] :
map measurable_equiv.prod_assoc ((μ.prod ν).prod τ) = μ.prod (ν.prod τ) :=
begin
refine (prod_eq_generate_from generate_from_measurable_set generate_from_prod
is_pi_system_measurable_set is_pi_system_prod μ.to_finite_spanning_sets_in
(ν.to_finite_spanning_sets_in.prod τ.to_finite_spanning_sets_in) _).symm,
rintro s hs _ ⟨t, u, ht, hu, rfl⟩, rw [mem_set_of_eq] at hs ht hu,
simp_rw [map_apply (measurable_equiv.measurable _) (hs.prod (ht.prod hu)),
measurable_equiv.prod_assoc, measurable_equiv.coe_mk, equiv.prod_assoc_preimage,
prod_prod, mul_assoc]
end
/-! ### The product of specific measures -/
lemma prod_restrict (s : set α) (t : set β) :
(μ.restrict s).prod (ν.restrict t) = (μ.prod ν).restrict (s ×ˢ t) :=
begin
refine prod_eq (λ s' t' hs' ht', _),
rw [restrict_apply (hs'.prod ht'), prod_inter_prod, prod_prod, restrict_apply hs',
restrict_apply ht']
end
lemma restrict_prod_eq_prod_univ (s : set α) :
(μ.restrict s).prod ν = (μ.prod ν).restrict (s ×ˢ (univ : set β)) :=
begin
have : ν = ν.restrict set.univ := measure.restrict_univ.symm,
rwa [this, measure.prod_restrict, ← this],
end
lemma prod_dirac (y : β) : μ.prod (dirac y) = map (λ x, (x, y)) μ :=
begin
refine prod_eq (λ s t hs ht, _),
simp_rw [map_apply measurable_prod_mk_right (hs.prod ht), mk_preimage_prod_left_eq_if, measure_if,
dirac_apply' _ ht, ← indicator_mul_right _ (λ x, μ s), pi.one_apply, mul_one]
end
lemma dirac_prod (x : α) : (dirac x).prod ν = map (prod.mk x) ν :=
begin
refine prod_eq (λ s t hs ht, _),
simp_rw [map_apply measurable_prod_mk_left (hs.prod ht), mk_preimage_prod_right_eq_if, measure_if,
dirac_apply' _ hs, ← indicator_mul_left _ _ (λ x, ν t), pi.one_apply, one_mul]
end
lemma dirac_prod_dirac {x : α} {y : β} : (dirac x).prod (dirac y) = dirac (x, y) :=
by rw [prod_dirac, map_dirac measurable_prod_mk_right]
lemma prod_sum {ι : Type*} [fintype ι] (ν : ι → measure β) [∀ i, sigma_finite (ν i)] :
μ.prod (sum ν) = sum (λ i, μ.prod (ν i)) :=
begin
refine prod_eq (λ s t hs ht, _),
simp_rw [sum_apply _ (hs.prod ht), sum_apply _ ht, prod_prod, ennreal.tsum_mul_left]
end
lemma sum_prod {ι : Type*} [fintype ι] (μ : ι → measure α) [∀ i, sigma_finite (μ i)] :
(sum μ).prod ν = sum (λ i, (μ i).prod ν) :=
begin
refine prod_eq (λ s t hs ht, _),
simp_rw [sum_apply _ (hs.prod ht), sum_apply _ hs, prod_prod, ennreal.tsum_mul_right]
end
lemma prod_add (ν' : measure β) [sigma_finite ν'] : μ.prod (ν + ν') = μ.prod ν + μ.prod ν' :=
by { refine prod_eq (λ s t hs ht, _), simp_rw [add_apply, prod_prod, left_distrib] }
lemma add_prod (μ' : measure α) [sigma_finite μ'] : (μ + μ').prod ν = μ.prod ν + μ'.prod ν :=
by { refine prod_eq (λ s t hs ht, _), simp_rw [add_apply, prod_prod, right_distrib] }
@[simp] lemma zero_prod (ν : measure β) : (0 : measure α).prod ν = 0 :=
by { rw measure.prod, exact bind_zero_left _ }
@[simp] lemma prod_zero (μ : measure α) : μ.prod (0 : measure β) = 0 :=
by simp [measure.prod]
lemma map_prod_map {δ} [measurable_space δ] {f : α → β} {g : γ → δ}
{μa : measure α} {μc : measure γ} (hfa : sigma_finite (map f μa))
(hgc : sigma_finite (map g μc)) (hf : measurable f) (hg : measurable g) :
(map f μa).prod (map g μc) = map (prod.map f g) (μa.prod μc) :=
begin
haveI := hgc.of_map μc hg.ae_measurable,
refine prod_eq (λ s t hs ht, _),
rw [map_apply (hf.prod_map hg) (hs.prod ht), map_apply hf hs, map_apply hg ht],
exact prod_prod (f ⁻¹' s) (g ⁻¹' t)
end
end measure
open measure
namespace measure_preserving
variables {δ : Type*} [measurable_space δ] {μa : measure α} {μb : measure β}
{μc : measure γ} {μd : measure δ}
lemma skew_product [sigma_finite μb] [sigma_finite μd]
{f : α → β} (hf : measure_preserving f μa μb) {g : α → γ → δ}
(hgm : measurable (uncurry g)) (hg : ∀ᵐ x ∂μa, map (g x) μc = μd) :
measure_preserving (λ p : α × γ, (f p.1, g p.1 p.2)) (μa.prod μc) (μb.prod μd) :=
begin
classical,
have : measurable (λ p : α × γ, (f p.1, g p.1 p.2)) := (hf.1.comp measurable_fst).prod_mk hgm,
/- if `μa = 0`, then the lemma is trivial, otherwise we can use `hg`
to deduce `sigma_finite μc`. -/
rcases eq_or_ne μa 0 with (rfl|ha),
{ rw [← hf.map_eq, zero_prod, measure.map_zero, zero_prod],
exact ⟨this, by simp only [measure.map_zero]⟩ },
haveI : sigma_finite μc,
{ rcases (ae_ne_bot.2 ha).nonempty_of_mem hg with ⟨x, hx : map (g x) μc = μd⟩,
exact sigma_finite.of_map _ hgm.of_uncurry_left.ae_measurable (by rwa hx) },
-- Thus we can apply `measure.prod_eq` to prove equality of measures.
refine ⟨this, (prod_eq $ λ s t hs ht, _).symm⟩,
rw [map_apply this (hs.prod ht)],
refine (prod_apply (this $ hs.prod ht)).trans _,
have : ∀ᵐ x ∂μa, μc ((λ y, (f x, g x y)) ⁻¹' s ×ˢ t) = indicator (f ⁻¹' s) (λ y, μd t) x,
{ refine hg.mono (λ x hx, _), unfreezingI { subst hx },
simp only [mk_preimage_prod_right_fn_eq_if, indicator_apply, mem_preimage],
split_ifs,
exacts [(map_apply hgm.of_uncurry_left ht).symm, measure_empty] },
simp only [preimage_preimage],
rw [lintegral_congr_ae this, lintegral_indicator _ (hf.1 hs),
set_lintegral_const, hf.measure_preimage hs, mul_comm]
end
/-- If `f : α → β` sends the measure `μa` to `μb` and `g : γ → δ` sends the measure `μc` to `μd`,
then `prod.map f g` sends `μa.prod μc` to `μb.prod μd`. -/
protected lemma prod [sigma_finite μb] [sigma_finite μd] {f : α → β} {g : γ → δ}
(hf : measure_preserving f μa μb) (hg : measure_preserving g μc μd) :
measure_preserving (prod.map f g) (μa.prod μc) (μb.prod μd) :=
have measurable (uncurry $ λ _ : α, g), from (hg.1.comp measurable_snd),
hf.skew_product this $ filter.eventually_of_forall $ λ _, hg.map_eq
end measure_preserving
namespace quasi_measure_preserving
lemma prod_of_right {f : α × β → γ} {μ : measure α} {ν : measure β} {τ : measure γ}
(hf : measurable f) [sigma_finite ν]
(h2f : ∀ᵐ x ∂μ, quasi_measure_preserving (λ y, f (x, y)) ν τ) :
quasi_measure_preserving f (μ.prod ν) τ :=
begin
refine ⟨hf, _⟩,
refine absolutely_continuous.mk (λ s hs h2s, _),
simp_rw [map_apply hf hs, prod_apply (hf hs), preimage_preimage,
lintegral_congr_ae (h2f.mono (λ x hx, hx.preimage_null h2s)), lintegral_zero],
end
lemma prod_of_left {α β γ} [measurable_space α] [measurable_space β]
[measurable_space γ] {f : α × β → γ} {μ : measure α} {ν : measure β} {τ : measure γ}
(hf : measurable f) [sigma_finite μ] [sigma_finite ν]
(h2f : ∀ᵐ y ∂ν, quasi_measure_preserving (λ x, f (x, y)) μ τ) :
quasi_measure_preserving f (μ.prod ν) τ :=
begin
rw [← prod_swap],
convert (quasi_measure_preserving.prod_of_right (hf.comp measurable_swap) h2f).comp
((measurable_swap.measure_preserving (ν.prod μ)).symm measurable_equiv.prod_comm)
.quasi_measure_preserving,
ext ⟨x, y⟩, refl,
end
end quasi_measure_preserving
end measure_theory
open measure_theory.measure
section
lemma ae_measurable.prod_swap [sigma_finite μ] [sigma_finite ν] {f : β × α → γ}
(hf : ae_measurable f (ν.prod μ)) : ae_measurable (λ (z : α × β), f z.swap) (μ.prod ν) :=
by { rw ← prod_swap at hf, exact hf.comp_measurable measurable_swap }
lemma measure_theory.ae_strongly_measurable.prod_swap
{γ : Type*} [topological_space γ] [sigma_finite μ] [sigma_finite ν] {f : β × α → γ}
(hf : ae_strongly_measurable f (ν.prod μ)) :
ae_strongly_measurable (λ (z : α × β), f z.swap) (μ.prod ν) :=
by { rw ← prod_swap at hf, exact hf.comp_measurable measurable_swap }
lemma ae_measurable.fst [sigma_finite ν] {f : α → γ}
(hf : ae_measurable f μ) : ae_measurable (λ (z : α × β), f z.1) (μ.prod ν) :=
hf.comp_measurable' measurable_fst prod_fst_absolutely_continuous
lemma ae_measurable.snd [sigma_finite ν] {f : β → γ}
(hf : ae_measurable f ν) : ae_measurable (λ (z : α × β), f z.2) (μ.prod ν) :=
hf.comp_measurable' measurable_snd prod_snd_absolutely_continuous
lemma measure_theory.ae_strongly_measurable.fst {γ} [topological_space γ] [sigma_finite ν]
{f : α → γ} (hf : ae_strongly_measurable f μ) :
ae_strongly_measurable (λ (z : α × β), f z.1) (μ.prod ν) :=
hf.comp_measurable' measurable_fst prod_fst_absolutely_continuous
lemma measure_theory.ae_strongly_measurable.snd {γ} [topological_space γ] [sigma_finite ν]
{f : β → γ} (hf : ae_strongly_measurable f ν) :
ae_strongly_measurable (λ (z : α × β), f z.2) (μ.prod ν) :=
hf.comp_measurable' measurable_snd prod_snd_absolutely_continuous
/-- The Bochner integral is a.e.-measurable.
This shows that the integrand of (the right-hand-side of) Fubini's theorem is a.e.-measurable. -/
lemma measure_theory.ae_strongly_measurable.integral_prod_right' [sigma_finite ν]
[normed_space ℝ E] [complete_space E]
⦃f : α × β → E⦄ (hf : ae_strongly_measurable f (μ.prod ν)) :
ae_strongly_measurable (λ x, ∫ y, f (x, y) ∂ν) μ :=
⟨λ x, ∫ y, hf.mk f (x, y) ∂ν, hf.strongly_measurable_mk.integral_prod_right',
by { filter_upwards [ae_ae_of_ae_prod hf.ae_eq_mk] with _ hx using integral_congr_ae hx }⟩
lemma measure_theory.ae_strongly_measurable.prod_mk_left
{γ : Type*} [sigma_finite ν] [topological_space γ] {f : α × β → γ}
(hf : ae_strongly_measurable f (μ.prod ν)) : ∀ᵐ x ∂μ, ae_strongly_measurable (λ y, f (x, y)) ν :=
begin
filter_upwards [ae_ae_of_ae_prod hf.ae_eq_mk] with x hx,
exact ⟨λ y, hf.mk f (x, y), hf.strongly_measurable_mk.comp_measurable measurable_prod_mk_left, hx⟩
end
end
namespace measure_theory
/-! ### The Lebesgue integral on a product -/
variables [sigma_finite ν]
lemma lintegral_prod_swap [sigma_finite μ] (f : α × β → ℝ≥0∞)
(hf : ae_measurable f (μ.prod ν)) : ∫⁻ z, f z.swap ∂(ν.prod μ) = ∫⁻ z, f z ∂(μ.prod ν) :=
by { rw ← prod_swap at hf, rw [← lintegral_map' hf measurable_swap.ae_measurable, prod_swap] }
/-- **Tonelli's Theorem**: For `ℝ≥0∞`-valued measurable functions on `α × β`,
the integral of `f` is equal to the iterated integral. -/
lemma lintegral_prod_of_measurable :
∀ (f : α × β → ℝ≥0∞) (hf : measurable f), ∫⁻ z, f z ∂(μ.prod ν) = ∫⁻ x, ∫⁻ y, f (x, y) ∂ν ∂μ :=
begin
have m := @measurable_prod_mk_left,
refine measurable.ennreal_induction _ _ _,
{ intros c s hs, simp only [← indicator_comp_right],
simp [lintegral_indicator, m hs, hs, lintegral_const_mul, measurable_measure_prod_mk_left hs,
prod_apply] },
{ rintro f g - hf hg h2f h2g,
simp [lintegral_add_left, measurable.lintegral_prod_right', hf.comp m, hf, h2f, h2g] },
{ intros f hf h2f h3f,
have kf : ∀ x n, measurable (λ y, f n (x, y)) := λ x n, (hf n).comp m,
have k2f : ∀ x, monotone (λ n y, f n (x, y)) := λ x i j hij y, h2f hij (x, y),
have lf : ∀ n, measurable (λ x, ∫⁻ y, f n (x, y) ∂ν) := λ n, (hf n).lintegral_prod_right',
have l2f : monotone (λ n x, ∫⁻ y, f n (x, y) ∂ν) := λ i j hij x, lintegral_mono (k2f x hij),
simp only [lintegral_supr hf h2f, lintegral_supr (kf _), k2f, lintegral_supr lf l2f, h3f] },
end
/-- **Tonelli's Theorem**: For `ℝ≥0∞`-valued almost everywhere measurable functions on `α × β`,
the integral of `f` is equal to the iterated integral. -/
lemma lintegral_prod (f : α × β → ℝ≥0∞) (hf : ae_measurable f (μ.prod ν)) :
∫⁻ z, f z ∂(μ.prod ν) = ∫⁻ x, ∫⁻ y, f (x, y) ∂ν ∂μ :=
begin
have A : ∫⁻ z, f z ∂(μ.prod ν) = ∫⁻ z, hf.mk f z ∂(μ.prod ν) :=
lintegral_congr_ae hf.ae_eq_mk,
have B : ∫⁻ x, ∫⁻ y, f (x, y) ∂ν ∂μ = ∫⁻ x, ∫⁻ y, hf.mk f (x, y) ∂ν ∂μ,
{ apply lintegral_congr_ae,
filter_upwards [ae_ae_of_ae_prod hf.ae_eq_mk] with _ ha using lintegral_congr_ae ha, },
rw [A, B, lintegral_prod_of_measurable _ hf.measurable_mk],
apply_instance
end
/-- The symmetric verion of Tonelli's Theorem: For `ℝ≥0∞`-valued almost everywhere measurable
functions on `α × β`, the integral of `f` is equal to the iterated integral, in reverse order. -/
lemma lintegral_prod_symm [sigma_finite μ] (f : α × β → ℝ≥0∞)
(hf : ae_measurable f (μ.prod ν)) : ∫⁻ z, f z ∂(μ.prod ν) = ∫⁻ y, ∫⁻ x, f (x, y) ∂μ ∂ν :=
by { simp_rw [← lintegral_prod_swap f hf], exact lintegral_prod _ hf.prod_swap }
/-- The symmetric verion of Tonelli's Theorem: For `ℝ≥0∞`-valued measurable
functions on `α × β`, the integral of `f` is equal to the iterated integral, in reverse order. -/
lemma lintegral_prod_symm' [sigma_finite μ] (f : α × β → ℝ≥0∞)
(hf : measurable f) : ∫⁻ z, f z ∂(μ.prod ν) = ∫⁻ y, ∫⁻ x, f (x, y) ∂μ ∂ν :=
lintegral_prod_symm f hf.ae_measurable
/-- The reversed version of **Tonelli's Theorem**. In this version `f` is in curried form, which
makes it easier for the elaborator to figure out `f` automatically. -/
lemma lintegral_lintegral ⦃f : α → β → ℝ≥0∞⦄
(hf : ae_measurable (uncurry f) (μ.prod ν)) :
∫⁻ x, ∫⁻ y, f x y ∂ν ∂μ = ∫⁻ z, f z.1 z.2 ∂(μ.prod ν) :=
(lintegral_prod _ hf).symm
/-- The reversed version of **Tonelli's Theorem** (symmetric version). In this version `f` is in
curried form, which makes it easier for the elaborator to figure out `f` automatically. -/
lemma lintegral_lintegral_symm [sigma_finite μ] ⦃f : α → β → ℝ≥0∞⦄
(hf : ae_measurable (uncurry f) (μ.prod ν)) :
∫⁻ x, ∫⁻ y, f x y ∂ν ∂μ = ∫⁻ z, f z.2 z.1 ∂(ν.prod μ) :=
(lintegral_prod_symm _ hf.prod_swap).symm
/-- Change the order of Lebesgue integration. -/
lemma lintegral_lintegral_swap [sigma_finite μ] ⦃f : α → β → ℝ≥0∞⦄
(hf : ae_measurable (uncurry f) (μ.prod ν)) :
∫⁻ x, ∫⁻ y, f x y ∂ν ∂μ = ∫⁻ y, ∫⁻ x, f x y ∂μ ∂ν :=
(lintegral_lintegral hf).trans (lintegral_prod_symm _ hf)
lemma lintegral_prod_mul {f : α → ℝ≥0∞} {g : β → ℝ≥0∞}
(hf : ae_measurable f μ) (hg : ae_measurable g ν) :
∫⁻ z, f z.1 * g z.2 ∂(μ.prod ν) = ∫⁻ x, f x ∂μ * ∫⁻ y, g y ∂ν :=
by simp [lintegral_prod _ (hf.fst.mul hg.snd), lintegral_lintegral_mul hf hg]
/-! ### Integrability on a product -/
section
lemma integrable.swap [sigma_finite μ] ⦃f : α × β → E⦄
(hf : integrable f (μ.prod ν)) : integrable (f ∘ prod.swap) (ν.prod μ) :=
⟨hf.ae_strongly_measurable.prod_swap,
(lintegral_prod_swap _ hf.ae_strongly_measurable.ennnorm : _).le.trans_lt hf.has_finite_integral⟩
lemma integrable_swap_iff [sigma_finite μ] ⦃f : α × β → E⦄ :
integrable (f ∘ prod.swap) (ν.prod μ) ↔ integrable f (μ.prod ν) :=
⟨λ hf, by { convert hf.swap, ext ⟨x, y⟩, refl }, λ hf, hf.swap⟩
lemma has_finite_integral_prod_iff ⦃f : α × β → E⦄ (h1f : strongly_measurable f) :
has_finite_integral f (μ.prod ν) ↔ (∀ᵐ x ∂ μ, has_finite_integral (λ y, f (x, y)) ν) ∧
has_finite_integral (λ x, ∫ y, ∥f (x, y)∥ ∂ν) μ :=
begin
simp only [has_finite_integral, lintegral_prod_of_measurable _ h1f.ennnorm],
have : ∀ x, ∀ᵐ y ∂ν, 0 ≤ ∥f (x, y)∥ := λ x, eventually_of_forall (λ y, norm_nonneg _),
simp_rw [integral_eq_lintegral_of_nonneg_ae (this _)
(h1f.norm.comp_measurable measurable_prod_mk_left).ae_strongly_measurable,
ennnorm_eq_of_real to_real_nonneg, of_real_norm_eq_coe_nnnorm],
-- this fact is probably too specialized to be its own lemma
have : ∀ {p q r : Prop} (h1 : r → p), (r ↔ p ∧ q) ↔ (p → (r ↔ q)) :=
λ p q r h1, by rw [← and.congr_right_iff, and_iff_right_of_imp h1],
rw [this],
{ intro h2f, rw lintegral_congr_ae,
refine h2f.mp _, apply eventually_of_forall, intros x hx, dsimp only,
rw [of_real_to_real], rw [← lt_top_iff_ne_top], exact hx },
{ intro h2f, refine ae_lt_top _ h2f.ne, exact h1f.ennnorm.lintegral_prod_right' },
end
lemma has_finite_integral_prod_iff' ⦃f : α × β → E⦄ (h1f : ae_strongly_measurable f (μ.prod ν)) :
has_finite_integral f (μ.prod ν) ↔ (∀ᵐ x ∂ μ, has_finite_integral (λ y, f (x, y)) ν) ∧
has_finite_integral (λ x, ∫ y, ∥f (x, y)∥ ∂ν) μ :=
begin
rw [has_finite_integral_congr h1f.ae_eq_mk,
has_finite_integral_prod_iff h1f.strongly_measurable_mk],
apply and_congr,
{ apply eventually_congr,
filter_upwards [ae_ae_of_ae_prod h1f.ae_eq_mk.symm],
assume x hx,
exact has_finite_integral_congr hx },
{ apply has_finite_integral_congr,
filter_upwards [ae_ae_of_ae_prod h1f.ae_eq_mk.symm] with _ hx
using integral_congr_ae (eventually_eq.fun_comp hx _), },
{ apply_instance, },
end
/-- A binary function is integrable if the function `y ↦ f (x, y)` is integrable for almost every
`x` and the function `x ↦ ∫ ∥f (x, y)∥ dy` is integrable. -/
lemma integrable_prod_iff ⦃f : α × β → E⦄ (h1f : ae_strongly_measurable f (μ.prod ν)) :
integrable f (μ.prod ν) ↔
(∀ᵐ x ∂ μ, integrable (λ y, f (x, y)) ν) ∧ integrable (λ x, ∫ y, ∥f (x, y)∥ ∂ν) μ :=
by simp [integrable, h1f, has_finite_integral_prod_iff', h1f.norm.integral_prod_right',
h1f.prod_mk_left]
/-- A binary function is integrable if the function `x ↦ f (x, y)` is integrable for almost every
`y` and the function `y ↦ ∫ ∥f (x, y)∥ dx` is integrable. -/
lemma integrable_prod_iff' [sigma_finite μ] ⦃f : α × β → E⦄
(h1f : ae_strongly_measurable f (μ.prod ν)) :
integrable f (μ.prod ν) ↔
(∀ᵐ y ∂ ν, integrable (λ x, f (x, y)) μ) ∧ integrable (λ y, ∫ x, ∥f (x, y)∥ ∂μ) ν :=
by { convert integrable_prod_iff (h1f.prod_swap) using 1, rw [integrable_swap_iff] }
lemma integrable.prod_left_ae [sigma_finite μ] ⦃f : α × β → E⦄
(hf : integrable f (μ.prod ν)) : ∀ᵐ y ∂ ν, integrable (λ x, f (x, y)) μ :=
((integrable_prod_iff' hf.ae_strongly_measurable).mp hf).1
lemma integrable.prod_right_ae [sigma_finite μ] ⦃f : α × β → E⦄
(hf : integrable f (μ.prod ν)) : ∀ᵐ x ∂ μ, integrable (λ y, f (x, y)) ν :=
hf.swap.prod_left_ae
lemma integrable.integral_norm_prod_left ⦃f : α × β → E⦄
(hf : integrable f (μ.prod ν)) : integrable (λ x, ∫ y, ∥f (x, y)∥ ∂ν) μ :=
((integrable_prod_iff hf.ae_strongly_measurable).mp hf).2
lemma integrable.integral_norm_prod_right [sigma_finite μ] ⦃f : α × β → E⦄
(hf : integrable f (μ.prod ν)) : integrable (λ y, ∫ x, ∥f (x, y)∥ ∂μ) ν :=
hf.swap.integral_norm_prod_left
lemma integrable_prod_mul {f : α → ℝ} {g : β → ℝ} (hf : integrable f μ) (hg : integrable g ν) :
integrable (λ (z : α × β), f z.1 * g z.2) (μ.prod ν) :=
begin
refine (integrable_prod_iff _).2 ⟨_, _⟩,
{ apply ae_strongly_measurable.mul,
{ exact (hf.1.mono' prod_fst_absolutely_continuous).comp_measurable measurable_fst },
{ exact (hg.1.mono' prod_snd_absolutely_continuous).comp_measurable measurable_snd } },
{ exact eventually_of_forall (λ x, hg.const_mul (f x)) },
{ simpa only [norm_mul, integral_mul_left] using hf.norm.mul_const _ }
end
end
variables [normed_space ℝ E] [complete_space E]
lemma integrable.integral_prod_left ⦃f : α × β → E⦄
(hf : integrable f (μ.prod ν)) : integrable (λ x, ∫ y, f (x, y) ∂ν) μ :=
integrable.mono hf.integral_norm_prod_left hf.ae_strongly_measurable.integral_prod_right' $
eventually_of_forall $ λ x, (norm_integral_le_integral_norm _).trans_eq $
(norm_of_nonneg $ integral_nonneg_of_ae $ eventually_of_forall $
λ y, (norm_nonneg (f (x, y)) : _)).symm
lemma integrable.integral_prod_right [sigma_finite μ] ⦃f : α × β → E⦄
(hf : integrable f (μ.prod ν)) : integrable (λ y, ∫ x, f (x, y) ∂μ) ν :=
hf.swap.integral_prod_left
/-! ### The Bochner integral on a product -/
variables [sigma_finite μ]
lemma integral_prod_swap (f : α × β → E)
(hf : ae_strongly_measurable f (μ.prod ν)) : ∫ z, f z.swap ∂(ν.prod μ) = ∫ z, f z ∂(μ.prod ν) :=
begin
rw ← prod_swap at hf,
rw [← integral_map measurable_swap.ae_measurable hf, prod_swap]
end
variables {E' : Type*} [normed_group E'] [complete_space E'] [normed_space ℝ E']
/-! Some rules about the sum/difference of double integrals. They follow from `integral_add`, but
we separate them out as separate lemmas, because they involve quite some steps. -/
/-- Integrals commute with addition inside another integral. `F` can be any function. -/
lemma integral_fn_integral_add ⦃f g : α × β → E⦄ (F : E → E')
(hf : integrable f (μ.prod ν)) (hg : integrable g (μ.prod ν)) :
∫ x, F (∫ y, f (x, y) + g (x, y) ∂ν) ∂μ = ∫ x, F (∫ y, f (x, y) ∂ν + ∫ y, g (x, y) ∂ν) ∂μ :=
begin
refine integral_congr_ae _,
filter_upwards [hf.prod_right_ae, hg.prod_right_ae] with _ h2f h2g,
simp [integral_add h2f h2g],
end
/-- Integrals commute with subtraction inside another integral.
`F` can be any measurable function. -/
lemma integral_fn_integral_sub ⦃f g : α × β → E⦄ (F : E → E')
(hf : integrable f (μ.prod ν)) (hg : integrable g (μ.prod ν)) :
∫ x, F (∫ y, f (x, y) - g (x, y) ∂ν) ∂μ = ∫ x, F (∫ y, f (x, y) ∂ν - ∫ y, g (x, y) ∂ν) ∂μ :=
begin
refine integral_congr_ae _,
filter_upwards [hf.prod_right_ae, hg.prod_right_ae] with _ h2f h2g,
simp [integral_sub h2f h2g],
end
/-- Integrals commute with subtraction inside a lower Lebesgue integral.
`F` can be any function. -/
lemma lintegral_fn_integral_sub ⦃f g : α × β → E⦄
(F : E → ℝ≥0∞) (hf : integrable f (μ.prod ν)) (hg : integrable g (μ.prod ν)) :
∫⁻ x, F (∫ y, f (x, y) - g (x, y) ∂ν) ∂μ = ∫⁻ x, F (∫ y, f (x, y) ∂ν - ∫ y, g (x, y) ∂ν) ∂μ :=
begin
refine lintegral_congr_ae _,
filter_upwards [hf.prod_right_ae, hg.prod_right_ae] with _ h2f h2g,
simp [integral_sub h2f h2g],
end
/-- Double integrals commute with addition. -/
lemma integral_integral_add ⦃f g : α × β → E⦄
(hf : integrable f (μ.prod ν)) (hg : integrable g (μ.prod ν)) :
∫ x, ∫ y, f (x, y) + g (x, y) ∂ν ∂μ = ∫ x, ∫ y, f (x, y) ∂ν ∂μ + ∫ x, ∫ y, g (x, y) ∂ν ∂μ :=
(integral_fn_integral_add id hf hg).trans $
integral_add hf.integral_prod_left hg.integral_prod_left
/-- Double integrals commute with addition. This is the version with `(f + g) (x, y)`
(instead of `f (x, y) + g (x, y)`) in the LHS. -/
lemma integral_integral_add' ⦃f g : α × β → E⦄
(hf : integrable f (μ.prod ν)) (hg : integrable g (μ.prod ν)) :
∫ x, ∫ y, (f + g) (x, y) ∂ν ∂μ = ∫ x, ∫ y, f (x, y) ∂ν ∂μ + ∫ x, ∫ y, g (x, y) ∂ν ∂μ :=
integral_integral_add hf hg
/-- Double integrals commute with subtraction. -/
lemma integral_integral_sub ⦃f g : α × β → E⦄
(hf : integrable f (μ.prod ν)) (hg : integrable g (μ.prod ν)) :
∫ x, ∫ y, f (x, y) - g (x, y) ∂ν ∂μ = ∫ x, ∫ y, f (x, y) ∂ν ∂μ - ∫ x, ∫ y, g (x, y) ∂ν ∂μ :=
(integral_fn_integral_sub id hf hg).trans $
integral_sub hf.integral_prod_left hg.integral_prod_left
/-- Double integrals commute with subtraction. This is the version with `(f - g) (x, y)`
(instead of `f (x, y) - g (x, y)`) in the LHS. -/
lemma integral_integral_sub' ⦃f g : α × β → E⦄
(hf : integrable f (μ.prod ν)) (hg : integrable g (μ.prod ν)) :
∫ x, ∫ y, (f - g) (x, y) ∂ν ∂μ = ∫ x, ∫ y, f (x, y) ∂ν ∂μ - ∫ x, ∫ y, g (x, y) ∂ν ∂μ :=
integral_integral_sub hf hg
/-- The map that sends an L¹-function `f : α × β → E` to `∫∫f` is continuous. -/
lemma continuous_integral_integral :
continuous (λ (f : α × β →₁[μ.prod ν] E), ∫ x, ∫ y, f (x, y) ∂ν ∂μ) :=
begin
rw [continuous_iff_continuous_at], intro g,
refine tendsto_integral_of_L1 _ (L1.integrable_coe_fn g).integral_prod_left
(eventually_of_forall $ λ h, (L1.integrable_coe_fn h).integral_prod_left) _,
simp_rw [← lintegral_fn_integral_sub (λ x, (∥x∥₊ : ℝ≥0∞)) (L1.integrable_coe_fn _)
(L1.integrable_coe_fn g)],
refine tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds _ (λ i, zero_le _) _,
{ exact λ i, ∫⁻ x, ∫⁻ y, ∥i (x, y) - g (x, y)∥₊ ∂ν ∂μ },
swap, { exact λ i, lintegral_mono (λ x, ennnorm_integral_le_lintegral_ennnorm _) },
show tendsto (λ (i : α × β →₁[μ.prod ν] E),
∫⁻ x, ∫⁻ (y : β), ∥i (x, y) - g (x, y)∥₊ ∂ν ∂μ) (𝓝 g) (𝓝 0),
have : ∀ (i : α × β →₁[μ.prod ν] E), measurable (λ z, (∥i z - g z∥₊ : ℝ≥0∞)) :=
λ i, ((Lp.strongly_measurable i).sub (Lp.strongly_measurable g)).ennnorm,
simp_rw [← lintegral_prod_of_measurable _ (this _), ← L1.of_real_norm_sub_eq_lintegral,
← of_real_zero],
refine (continuous_of_real.tendsto 0).comp _,
rw [← tendsto_iff_norm_tendsto_zero], exact tendsto_id
end
/-- **Fubini's Theorem**: For integrable functions on `α × β`,
the Bochner integral of `f` is equal to the iterated Bochner integral.
`integrable_prod_iff` can be useful to show that the function in question in integrable.
`measure_theory.integrable.integral_prod_right` is useful to show that the inner integral
of the right-hand side is integrable. -/
lemma integral_prod : ∀ (f : α × β → E) (hf : integrable f (μ.prod ν)),
∫ z, f z ∂(μ.prod ν) = ∫ x, ∫ y, f (x, y) ∂ν ∂μ :=
begin
apply integrable.induction,
{ intros c s hs h2s,
simp_rw [integral_indicator hs, ← indicator_comp_right,
function.comp, integral_indicator (measurable_prod_mk_left hs),
set_integral_const, integral_smul_const,
integral_to_real (measurable_measure_prod_mk_left hs).ae_measurable
(ae_measure_lt_top hs h2s.ne), prod_apply hs] },
{ intros f g hfg i_f i_g hf hg,
simp_rw [integral_add' i_f i_g, integral_integral_add' i_f i_g, hf, hg] },
{ exact is_closed_eq continuous_integral continuous_integral_integral },
{ intros f g hfg i_f hf, convert hf using 1,
{ exact integral_congr_ae hfg.symm },
{ refine integral_congr_ae _,
refine (ae_ae_of_ae_prod hfg).mp _,
apply eventually_of_forall, intros x hfgx,
exact integral_congr_ae (ae_eq_symm hfgx) } }
end
/-- Symmetric version of **Fubini's Theorem**: For integrable functions on `α × β`,
the Bochner integral of `f` is equal to the iterated Bochner integral.
This version has the integrals on the right-hand side in the other order. -/
lemma integral_prod_symm (f : α × β → E) (hf : integrable f (μ.prod ν)) :
∫ z, f z ∂(μ.prod ν) = ∫ y, ∫ x, f (x, y) ∂μ ∂ν :=
by { simp_rw [← integral_prod_swap f hf.ae_strongly_measurable], exact integral_prod _ hf.swap }
/-- Reversed version of **Fubini's Theorem**. -/
lemma integral_integral {f : α → β → E} (hf : integrable (uncurry f) (μ.prod ν)) :
∫ x, ∫ y, f x y ∂ν ∂μ = ∫ z, f z.1 z.2 ∂(μ.prod ν) :=
(integral_prod _ hf).symm
/-- Reversed version of **Fubini's Theorem** (symmetric version). -/
lemma integral_integral_symm {f : α → β → E} (hf : integrable (uncurry f) (μ.prod ν)) :
∫ x, ∫ y, f x y ∂ν ∂μ = ∫ z, f z.2 z.1 ∂(ν.prod μ) :=
(integral_prod_symm _ hf.swap).symm
/-- Change the order of Bochner integration. -/
lemma integral_integral_swap ⦃f : α → β → E⦄ (hf : integrable (uncurry f) (μ.prod ν)) :
∫ x, ∫ y, f x y ∂ν ∂μ = ∫ y, ∫ x, f x y ∂μ ∂ν :=
(integral_integral hf).trans (integral_prod_symm _ hf)
/-- **Fubini's Theorem** for set integrals. -/
lemma set_integral_prod (f : α × β → E) {s : set α} {t : set β}
(hf : integrable_on f (s ×ˢ t) (μ.prod ν)) :
∫ z in s ×ˢ t, f z ∂(μ.prod ν) = ∫ x in s, ∫ y in t, f (x, y) ∂ν ∂μ :=
begin
simp only [← measure.prod_restrict s t, integrable_on] at hf ⊢,
exact integral_prod f hf
end
lemma integral_prod_mul (f : α → ℝ) (g : β → ℝ) :
∫ z, f z.1 * g z.2 ∂(μ.prod ν) = (∫ x, f x ∂μ) * (∫ y, g y ∂ν) :=
begin
by_cases h : integrable (λ (z : α × β), f z.1 * g z.2) (μ.prod ν),
{ rw integral_prod _ h,
simp_rw [integral_mul_left, integral_mul_right] },
have H : ¬(integrable f μ) ∨ ¬(integrable g ν),
{ contrapose! h,
exact integrable_prod_mul h.1 h.2 },
cases H;
simp [integral_undef h, integral_undef H],
end
lemma set_integral_prod_mul (f : α → ℝ) (g : β → ℝ) (s : set α) (t : set β) :
∫ z in s ×ˢ t, f z.1 * g z.2 ∂(μ.prod ν) = (∫ x in s, f x ∂μ) * (∫ y in t, g y ∂ν) :=
by simp only [← measure.prod_restrict s t, integrable_on, integral_prod_mul]
end measure_theory
|
[STATEMENT]
lemma vcg_of_RETURN:
assumes "f \<equiv> do { ASSERT \<Phi>; RETURN r }"
shows "\<lbrakk>\<Phi>; SPEC (\<lambda>x. x=r) \<le> m\<rbrakk> \<Longrightarrow> f \<le> m"
and "\<lbrakk>\<Phi> \<Longrightarrow> SPEC (\<lambda>x. x=r) \<le>\<^sub>n m\<rbrakk> \<Longrightarrow> f \<le>\<^sub>n m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (\<lbrakk>\<Phi>; SPEC (\<lambda>x. x = r) \<le> m\<rbrakk> \<Longrightarrow> f \<le> m) &&& ((\<Phi> \<Longrightarrow> SPEC (\<lambda>x. x = r) \<le>\<^sub>n m) \<Longrightarrow> f \<le>\<^sub>n m)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f \<equiv> ASSERT \<Phi> \<bind> (\<lambda>_. RETURN r)
goal (1 subgoal):
1. (\<lbrakk>\<Phi>; SPEC (\<lambda>x. x = r) \<le> m\<rbrakk> \<Longrightarrow> f \<le> m) &&& ((\<Phi> \<Longrightarrow> SPEC (\<lambda>x. x = r) \<le>\<^sub>n m) \<Longrightarrow> f \<le>\<^sub>n m)
[PROOF STEP]
by (auto simp: pw_le_iff pw_leof_iff refine_pw_simps) |
import ReactorModel.Determinism.InstantaneousStep
open Classical
namespace Execution
namespace Instantaneous
namespace Execution
variable [ReactorType.Indexable α] {s₁ s₂ : State α}
theorem progress_not_mem_rcns (e : s₁ ⇓ᵢ* s₂) (h : rcn ∈ s₁.progress) : rcn ∉ e.rcns := by
induction e <;> simp [rcns, not_or]
case trans e e' hi =>
simp [hi $ e.monotonic_progress h]
intro hc
exact absurd (hc ▸ h) e.rcn_not_mem_progress
theorem mem_progress_iff (e : s₁ ⇓ᵢ* s₂) :
(rcn ∈ s₂.progress) ↔ (rcn ∈ e.rcns ∨ rcn ∈ s₁.progress) := by
induction e <;> simp [rcns]
case trans s₁ s₂ s₃ e e' hi =>
simp [hi]
constructor <;> intro
all_goals repeat cases ‹_ ∨ _› <;> simp [*]
case mp.inr h => cases e.mem_progress_iff.mp h <;> simp [*]
case mpr.inl.inl h => simp [e.rcn_mem_progress]
case mpr.inr h => simp [e.monotonic_progress h]
-- Corollary of `InstExecution.mem_progress_iff`.
theorem rcns_mem_progress (e : s₁ ⇓ᵢ* s₂) (h : rcn ∈ e.rcns) : rcn ∈ s₂.progress :=
e.mem_progress_iff.mpr $ .inl h
theorem rcns_nodup {s₁ s₂ : State α} : (e : s₁ ⇓ᵢ* s₂) → e.rcns.Nodup
| refl => List.nodup_nil
| trans e e' => List.nodup_cons.mpr ⟨e'.progress_not_mem_rcns e.rcn_mem_progress, e'.rcns_nodup⟩
theorem progress_eq_rcns_perm
(e₁ : s ⇓ᵢ* s₁) (e₂ : s ⇓ᵢ* s₂) (hp : s₁.progress = s₂.progress) : e₁.rcns ~ e₂.rcns := by
apply List.perm_ext e₁.rcns_nodup e₂.rcns_nodup |>.mpr
intro rcn
by_cases hc : rcn ∈ s.progress
case pos => simp [e₁.progress_not_mem_rcns hc, e₂.progress_not_mem_rcns hc]
case neg =>
constructor <;> intro hm
case mp => exact e₂.mem_progress_iff.mp (hp ▸ e₁.rcns_mem_progress hm) |>.resolve_right hc
case mpr => exact e₁.mem_progress_iff.mp (hp ▸ e₂.rcns_mem_progress hm) |>.resolve_right hc
theorem preserves_tag {s₁ s₂ : State α} : (s₁ ⇓ᵢ* s₂) → s₁.tag = s₂.tag
| refl => rfl
| trans e e' => e.preserves_tag.trans e'.preserves_tag
theorem rcns_trans_eq_cons (e₁ : s ⇓ᵢ s₁) (e₂ : s₁ ⇓ᵢ* s₂) :
(trans e₁ e₂).rcns = e₁.rcn :: e₂.rcns := by
simp [rcns, Step.rcn]
theorem progress_eq {s₁ s₂ : State α} :
(e : s₁ ⇓ᵢ* s₂) → s₂.progress = s₁.progress ∪ { i | i ∈ e.rcns }
| refl => by simp [rcns]
| trans e e' => by
simp [e.progress_eq ▸ e'.progress_eq, rcns_trans_eq_cons]
apply Set.insert_union'
theorem mem_rcns_not_mem_progress (e : s₁ ⇓ᵢ* s₂) (h : rcn ∈ e.rcns) : rcn ∉ s₁.progress := by
induction e
case refl => contradiction
case trans e e' hi =>
cases e'.rcns_trans_eq_cons e ▸ h
case head => exact e.rcn_not_mem_progress
case tail h => exact mt e.monotonic_progress (hi h)
theorem mem_rcns_iff (e : s₁ ⇓ᵢ* s₂) : rcn ∈ e.rcns ↔ (rcn ∈ s₂.progress ∧ rcn ∉ s₁.progress) := by
simp [e.progress_eq, s₁.mem_record'_progress_iff e.rcns rcn, or_and_right]
exact e.mem_rcns_not_mem_progress
theorem equiv {s₁ s₂ : State α} : (s₁ ⇓ᵢ* s₂) → s₁.rtr ≈ s₂.rtr
| refl => .refl
| trans e e' => ReactorType.Equivalent.trans e.equiv e'.equiv
theorem head_minimal (e : s₁ ⇓ᵢ s₂) (e' : s₂ ⇓ᵢ* s₃) : (e.rcn :: e'.rcns) ≮[s₁.rtr] e.rcn := by
by_contra hc
simp [Minimal] at hc
have ⟨_, hm, h⟩ := hc e.acyclic
replace hc := mt e.monotonic_progress $ e'.mem_rcns_not_mem_progress hm
exact absurd (e.allows_rcn.deps h) hc
theorem head_not_mem_tail (e : s₁ ⇓ᵢ s₂) (e' : s₂ ⇓ᵢ* s₃) (h : i ∈ e'.rcns) : e.rcn ≠ i := by
intro hc
have := trans e e' |>.rcns_nodup
have := hc.symm ▸ List.not_nodup_cons_of_mem h
contradiction
-- The core lemma for `prepend_minimal`.
theorem cons_prepend_minimal
(e : s₁ ⇓ᵢ s₂) (e' : s₂ ⇓ᵢ* s₃) (hm : i ∈ e'.rcns) (hr : (e.rcn :: e'.rcns) ≮[s₁.rtr] i) :
∃ f : s₁ ⇓ᵢ* s₃, f.rcns = i :: e.rcn :: (e'.rcns.erase i) := by
induction e' generalizing s₁ <;> simp [rcns] at *
case trans s₁ s₂ s₄ e' e'' hi =>
cases hm
case inl hm =>
simp [hm] at hr
have ⟨_, f, f', ⟨hf₁, hf₂⟩⟩ := e.prepend_indep e' hr.cons_head
exists trans f $ trans f' e''
simp [hm, rcns, ←hf₁, ←hf₂]
case inr hm =>
have ⟨f, hf⟩ := hi e' hm $ hr.cons_tail.equiv e.equiv
cases f <;> simp [rcns] at hf
case trans f f'' =>
have ⟨h₁, h₂⟩ := hf
have ⟨_, f, f', ⟨hf₁, hf₂⟩⟩ := e.prepend_indep f $ h₁.symm ▸ hr |>.cons_head
exists trans f $ trans f' f''
simp [rcns, hf₁, h₁, hf₂, h₂, e''.rcns.erase_cons_tail $ head_not_mem_tail e' e'' hm]
theorem prepend_minimal (e : s₁ ⇓ᵢ* s₂) (hm : i ∈ e.rcns) (hr : e.rcns ≮[s₁.rtr] i) :
∃ (e' : s₁ ⇓ᵢ* s₂), e'.rcns = i :: (e.rcns.erase i) := by
cases e <;> simp [rcns] at *; cases ‹_ ∨ _›
case trans.inl e e' h =>
exists trans e e'
simp [rcns, h]
case trans.inr e e' h =>
exact e'.rcns.erase_cons_tail (head_not_mem_tail e e' h) ▸ cons_prepend_minimal e e' h hr
theorem rcns_perm_deterministic
(e₁ : s ⇓ᵢ* s₁) (e₂ : s ⇓ᵢ* s₂) (hp : e₁.rcns ~ e₂.rcns) : s₁.rtr = s₂.rtr := by
induction e₁
case refl => cases e₂ <;> simp [rcns] at hp ⊢
case trans s sₘ₁ s₁ e₁ e₁' hi =>
have hm := hp.mem_iff.mp $ List.mem_cons_self _ _
have hm' := e₁'.head_minimal e₁ |>.perm hp
have ⟨e₂, he₂⟩ := e₂.prepend_minimal hm hm'
cases e₂ <;> simp [rcns] at he₂
case trans sₘ₂ e₂ e₂' =>
have ⟨h, h'⟩ := he₂
cases e₁.deterministic e₂ h.symm
apply hi e₂'
rw [h']
exact List.perm_cons _ |>.mp (hp.trans $ List.perm_cons_erase hm)
protected theorem deterministic
(e₁ : s ⇓ᵢ* s₁) (e₂ : s ⇓ᵢ* s₂) (ht : s₁.tag = s₂.tag) (hp : s₁.progress = s₂.progress) :
s₁ = s₂ := by
ext1 <;> try assumption
exact rcns_perm_deterministic e₁ e₂ $ progress_eq_rcns_perm e₁ e₂ hp
end Execution
end Instantaneous
end Execution |
! ###################################################################
! Copyright (c) 2013-2022, Marc De Graef Research Group/Carnegie Mellon University
! All rights reserved.
!
! Redistribution and use in source and binary forms, with or without modification, are
! permitted provided that the following conditions are met:
!
! - Redistributions of source code must retain the above copyright notice, this list
! of conditions and the following disclaimer.
! - Redistributions in binary form must reproduce the above copyright notice, this
! list of conditions and the following disclaimer in the documentation and/or
! other materials provided with the distribution.
! - Neither the names of Marc De Graef, Carnegie Mellon University nor the names
! of its contributors may be used to endorse or promote products derived from
! this software without specific prior written permission.
!
! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
! SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
! OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
! USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! ###################################################################
module mod_ECPmaster
!! author: MDG
!! version: 1.0
!! date: 03/03/20
!!
!! class definition for the EMECPmaster program
use mod_kinds
use mod_global
use mod_MPfiles
IMPLICIT NONE
! class definition
type, public :: ECPmaster_T
private
character(fnlen) :: nmldeffile = 'EMECPmaster.nml'
type(ECPmasterNameListType) :: nml
contains
private
procedure, pass(self) :: readNameList_
! procedure, pass(self) :: writeHDFNameList_ replaced by routine in MPfiles.f90
procedure, pass(self) :: getNameList_
procedure, pass(self) :: ECPmaster_
generic, public :: getNameList => getNameList_
! generic, public :: writeHDFNameList => writeHDFNameList_
generic, public :: readNameList => readNameList_
generic, public :: ECPmaster => ECPmaster_
end type ECPmaster_T
! the constructor routine for this class
interface ECPmaster_T
module procedure ECPmaster_constructor
end interface ECPmaster_T
contains
!--------------------------------------------------------------------------
type(ECPmaster_T) function ECPmaster_constructor( nmlfile ) result(ECPmaster)
!DEC$ ATTRIBUTES DLLEXPORT :: ECPmaster_constructor
!! author: MDG
!! version: 1.0
!! date: 03/03/20
!!
!! constructor for the ECPmaster_T Class; reads the name list
IMPLICIT NONE
character(fnlen), OPTIONAL :: nmlfile
call ECPmaster%readNameList(nmlfile)
end function ECPmaster_constructor
!--------------------------------------------------------------------------
subroutine ECPmaster_destructor(self)
!DEC$ ATTRIBUTES DLLEXPORT :: ECPmaster_destructor
!! author: MDG
!! version: 1.0
!! date: 03/03/20
!!
!! destructor for the ECPmaster_T Class
IMPLICIT NONE
type(ECPmaster_T), INTENT(INOUT) :: self
call reportDestructor('ECPmaster_T')
end subroutine ECPmaster_destructor
!--------------------------------------------------------------------------
subroutine readNameList_(self, nmlfile, initonly)
!DEC$ ATTRIBUTES DLLEXPORT :: readNameList_
!! author: MDG
!! version: 1.0
!! date: 03/03/20
!!
!! read the namelist from an nml file for the ECPmaster_T Class
use mod_io
use mod_EMsoft
IMPLICIT NONE
class(ECPmaster_T), INTENT(INOUT) :: self
character(fnlen),INTENT(IN) :: nmlfile
!! full path to namelist file
logical,OPTIONAL,INTENT(IN) :: initonly
!! fill in the default values only; do not read the file
type(EMsoft_T) :: EMsoft
type(IO_T) :: Message
logical :: skipread = .FALSE.
integer(kind=irg) :: npx
integer(kind=irg) :: nthreads
real(kind=sgl) :: dmin
character(3) :: Notify
character(fnlen) :: copyfromenergyfile
character(fnlen) :: h5copypath
character(fnlen) :: energyfile
logical :: combinesites
logical :: kinematical
! define the IO namelist to facilitate passing variables to the program.
namelist /ECPmastervars/ dmin, Notify, h5copypath, energyfile, npx, nthreads, copyfromenergyfile, combinesites, kinematical
! set the input parameters to default values (except for xtalname, which must be present)
nthreads = 1
dmin = 0.04 ! smallest d-spacing to include in dynamical matrix [nm]
npx = 256
Notify = 'Off'
h5copypath = 'undefined'
energyfile = 'undefined' ! default filename for z_0(E_e) data from EMMC Monte Carlo simulations
copyfromenergyfile = 'undefined'
kinematical = .FALSE.
combinesites = .FALSE.
if (present(initonly)) then
if (initonly) skipread = .TRUE.
end if
if (.not.skipread) then
! read the namelist file
open(UNIT=dataunit,FILE=trim(nmlfile),DELIM='apostrophe',STATUS='old')
read(UNIT=dataunit,NML=ECPmastervars)
close(UNIT=dataunit,STATUS='keep')
! check for required entries
if (trim(energyfile).eq.'undefined') then
call Message%printError('EMECPmaster:',' energy file name is undefined in '//nmlfile)
end if
end if
! if we get here, then all appears to be ok, and we need to fill in the emnl fields
self%nml%npx = npx
self%nml%nthreads = nthreads
self%nml%dmin = dmin
self%nml%Notify = Notify
self%nml%h5copypath = h5copypath
self%nml%copyfromenergyfile = copyfromenergyfile
self%nml%energyfile = energyfile
self%nml%combinesites = combinesites
self%nml%kinematical = kinematical
end subroutine readNameList_
!--------------------------------------------------------------------------
function getNameList_(self) result(nml)
!DEC$ ATTRIBUTES DLLEXPORT :: getNameList_
!! author: MDG
!! version: 1.0
!! date: 03/03/20
!!
!! pass the namelist for the ECPmaster_T Class to the calling program
IMPLICIT NONE
class(ECPmaster_T), INTENT(INOUT) :: self
type(ECPmasterNameListType) :: nml
nml = self%nml
end function getNameList_
!--------------------------------------------------------------------------
subroutine ECPmaster_(self, EMsoft, progname)
!DEC$ ATTRIBUTES DLLEXPORT :: ECPmaster_
!! author: MDG
!! version: 1.0
!! date: 03/03/20
!!
!! compute an ECP master pattern for a given energy
use mod_EMsoft
use mod_initializers
use mod_symmetry
use mod_crystallography
use mod_gvectors
use mod_kvectors
use mod_io
use mod_math
use mod_diffraction
use mod_timing
use mod_Lambert
use HDF5
use mod_HDFsupport
use mod_HDFnames
use ISO_C_BINDING
use omp_lib
use mod_OMPsupport
use mod_notifications
use stringconstants
use mod_MCfiles
IMPLICIT NONE
class(ECPmaster_T), INTENT(INOUT) :: self
type(EMsoft_T), INTENT(INOUT) :: EMsoft
character(fnlen),INTENT(IN) :: progname
type(Cell_T) :: cell
type(DynType) :: Dyn
type(Timing_T) :: timer
type(IO_T) :: Message
type(Lambert_T) :: L
type(HDF_T) :: HDF
type(SpaceGroup_T) :: SG
type(Diffraction_T) :: Diff
type(MCfile_T) :: MCFT
type(MPfile_T) :: MPFT
type(kvectors_T) :: kvec
type(gvectors_T) :: reflist
type(HDFnames_T) :: HDFnames
real(kind=dbl) :: frac
integer(kind=irg) :: gzero, istat, tickstart
type(MCOpenCLNameListType) :: mcnl
integer(kind=irg) :: numangle, numzbins, nx, ny, npy, totnum_el, numsites ! reading from MC file
real(kind=dbl) :: EkeV, Ehistmin, Ebinsize, depthmax, depthstep, sig, omega ! reading from MC file
integer(kind=irg), allocatable :: acc_z(:,:,:,:),accum_z(:,:,:,:) ! reading from MC file
integer(kind=irg) :: io_int_sgl(1), io_int(6) ! integer output variable
real(kind=dbl) :: io_real(5) ! real output variable
integer(kind=irg) :: i, j, ik, kkk, isym, pgnum, SamplingType, nix, nixp, niy, niyp, hkl(3) ! variables for point group and Laue group
integer(kind=irg),parameter :: LaueTest(11) = (/ 149, 151, 153, 156, 158, 160, 161, 164, 165, 166, 167 /) ! space groups with 2 or mirror at 30 degrees
integer(kind=irg) :: npyhex, ijmax, numk, skip ! parameters for calckvectors and calcwavelength subroutine
integer(kind=irg) :: ga(3), gb(3) ! shortest reciprocal lattice vector for zone axis
real(kind=sgl), allocatable :: thick(:), mLPNH(:,:,:), mLPSH(:,:,:), svals(:), lambdaZ(:), klist(:,:), knlist(:),&
masterSPNH(:,:,:), masterSPSH(:,:,:), auxNH(:,:,:), auxSH(:,:,:)
real(kind=dbl) :: intthick, dc(3), dx, dxm, dy, dym, edge, scl, xy(2), Radius, tpi
complex(kind=dbl),allocatable :: Lgh(:,:),Sgh(:,:),Sghtmp(:,:,:)
complex(kind=dbl),allocatable :: DynMat(:,:)
complex(kind=dbl) :: czero
integer(kind=irg) :: nt, nns, nnw, tots, totw ! thickness array and BetheParameters strong and weak beams
real(kind=sgl) :: FN(3), kk(3), fnat, kn, tstop
integer(kind=irg) :: numset, nref, ipx, ipy, ipz, iequiv(3,48), nequiv, ip, jp, izz, IE, iz, one,ierr, &
NUMTHREADS, totstrong, totweak, nat(maxpasym)
integer(kind=irg),allocatable :: kij(:,:)
real(kind=dbl) :: res(2), xyz(3), ind, nabsl
character(fnlen) :: oldprogname, energyfile, outname
character(fnlen) :: xtalname, groupname, datagroupname, HDF_FileVersion, attributename
character(8) :: MCscversion
character(4) :: MCmode
character(6) :: projtype
character(11) :: dstr
character(15) :: tstrb
character(15) :: tstre
logical :: f_exists, readonly, overwrite=.TRUE., insert=.TRUE., g_exists, xtaldataread, stereog
character(fnlen, KIND=c_char),allocatable,TARGET :: stringarray(:)
character(fnlen,kind=c_char) :: line2(1)
logical :: verbose, usehex, switchmirror
type(gnode),save :: rlp
type(kvectorlist), pointer :: ktmp ! linked list for incident wave vectors for master list
type(kvectorlist), pointer :: kheadcone,ktmpcone ! linked list for incident wave vectors for individual pattern
real(kind=dbl),allocatable :: ecpattern(:,:)
type(reflisttype),pointer :: firstw,rltmp
integer(kind=irg) :: nthreads,TID,ix,hdferr,num_el,etotal, nlines,nsx,nsy,SelE
character(fnlen) :: dataset, instring, fname
character(fnlen) :: mode
integer(HSIZE_T) :: dims4(4), cnt4(4), offset4(4), dims3(3), cnt3(3), offset3(3)
character(fnlen),ALLOCATABLE :: MessageLines(:)
integer(kind=irg) :: NumLines
character(fnlen) :: SlackUsername, exectime
character(100) :: c
!$OMP THREADPRIVATE(rlp)
call openFortranHDFInterface()
HDF = HDF_T()
! set the HDF group names for this program
HDFnames = HDFnames_T()
call MPFT%setModality('ECP')
! simplify the notation a little
associate( emnl => self%nml )
! initialize the timing routines
timer = Timing_T()
tstrb = timer%getTimeString()
! if copyfromenergyfile is different from 'undefined', then we need to
! copy all the Monte Carlo data from that file into a new file, which
! will then be read from and written to by the ComputeMasterPattern routine.
if (emnl%copyfromenergyfile.ne.'undefined') then
call MCFT%copyMCdata(EMsoft, HDF, emnl%copyfromenergyfile, emnl%energyfile, emnl%h5copypath)
end if
stereog = .TRUE.
timer = Timing_T()
tstrb = timer%getTimeString()
tpi = 2.D0*cPi
czero = cmplx(0.D0,0.D0)
gzero = 1
frac = 0.05
!=============================================
!=============================================
! ---------- read Monte Carlo .h5 output file and extract necessary parameters
call HDFnames%set_ProgramData(SC_MCOpenCL)
call HDFnames%set_NMLlist(SC_MCCLNameList)
call HDFnames%set_NMLfilename(SC_MCOpenCLNML)
energyfile = ''
energyfile = EMsoft%generateFilePath('EMdatapathname',trim(emnl%energyfile))
outname = trim(energyfile)
call MCFT%setFileName(energyfile)
call MCFT%readMCfile(HDF, HDFnames, getAccumz=.TRUE.)
mcnl = MCFT%getnml()
call MCFT%copyaccumz(accum_z)
numzbins = MCFT%getnumzbins()
numangle = MCFT%getnumangles()
nsx = (mcnl%numsx - 1)/2
nsy = nsx
etotal = sum(accum_z(numangle,:,:,:))
io_int(1) = mcnl%totnum_el
call Message%WriteValue(' --> total number of BSE electrons in MC data set ', io_int, 1)
!=============================================
!=============================================
! crystallography section
verbose = .TRUE.
call cell%setFileName(mcnl%xtalname)
call Diff%setrlpmethod('WK')
call Diff%setV(dble(mcnl%EkeV))
call Initialize_Cell(cell, Diff, SG, Dyn, EMsoft, emnl%dmin, verbose, useHDF=HDF)
! check the crystal system and setting; abort the program for trigonal with rhombohedral setting with
! an explanation for the user
if ((SG%getSpaceGroupXtalSystem().eq.5).and.(cell%getLatParm('b').eq.cell%getLatParm('c'))) then
call Message%printMessage( (/ &
' ', &
' ========Program Aborted======== ', &
' The ECP master pattern simulation for rhombohedral/trigonal structures ', &
' requires that the structure be described using the hexagonal reference ', &
' frame. Please re-enter the crystal structure in this setting and re-run', &
' the Monte Carlo calculation and this master pattern program. '/) )
stop
end if
! allocate and compute the Sgh loop-up table
numset = cell%getNatomtype()
call Diff%Initialize_SghLUT(cell, SG, emnl%dmin, numset, nat, verbose)
! determine the point group number
j=0
do i=1,32
if (SGPG(i).le.SG%getSpaceGroupNumber()) j=i
end do
isym = j
! here is new code dealing with all the special cases (quite a few more compared to the
! Laue group case)... isym is the point group number. Once the symmetry case has been
! fully determined (taking into account things like 31m and 3m1 an such), then the only places
! that symmetry is handled are the modified Calckvectors routine, and the filling of the modified
! Lambert projections after the dynamical simulation step. We are also changing the name of the
! sr array (or srhex) to mLPNH and mLPSH (modified Lambert Projection Northern/Southern Hemisphere),
! and we change the output HDF5 file a little as well. We need to make sure that the EMEBSD program
! issues a warning when an old format HDF5 file is read.
! Here, we encode isym into a new number that describes the sampling scheme; the new schemes are
! described in detail in the EBSD manual pdf file.
SamplingType = PGSamplingType(isym)
! next, intercept the special cases (hexagonal vs. rhombohedral cases that require special treatment)
if ((SamplingType.eq.-1).or.(isym.eq.14).or.(isym.eq.26)) then
SamplingType = SG%getHexvsRho(isym)
end if
! if the point group is trigonal or hexagonal, we need to switch usehex to .TRUE. so that
! the program will use the hexagonal sampling method
usehex = .FALSE.
if ((SG%getSpaceGroupXtalSystem().eq.4).or.(SG%getSpaceGroupXtalSystem().eq.5)) usehex = .TRUE.
! ---------- end of symmetry and crystallography section
!=============================================
!=============================================
!=============================================
!=============================================
! ---------- a couple of initializations
npy = emnl%npx
ijmax = float(emnl%npx)**2 ! truncation value for beam directions
! ----------
!=============================================
!=============================================
!=============================================
!=============================================
! if the combinesites parameter is .TRUE., then we only need to
! allocate a dimension of 1 in the master pattern array since we are adding
! together the master patterns for all sites in the asymmetric unit.
if (emnl%combinesites.eqv..TRUE.) then
numsites = 1
else
numsites = numset
end if
! ---------- allocate memory for the master patterns
allocate(mLPNH(-emnl%npx:emnl%npx,-npy:npy,1:numsites),stat=istat)
allocate(mLPSH(-emnl%npx:emnl%npx,-npy:npy,1:numsites),stat=istat)
allocate(masterSPNH(-emnl%npx:emnl%npx,-npy:npy,1))
allocate(masterSPSH(-emnl%npx:emnl%npx,-npy:npy,1))
! set various arrays to zero
if (emnl%uniform.eqv..TRUE.) then
mLPNH = 1.0
mLPSH = 1.0
masterSPNH = 1.0
masterSPSH = 1.0
else
mLPNH = 0.0
mLPSH = 0.0
masterSPNH = 0.0
masterSPSH = 0.0
end if
! force dynamical matrix routine to read new Bethe parameters from file
call Diff%SetBetheParameters(EMsoft, .TRUE., emnl%BetheParametersFile)
!=============================================
! create or update the HDF5 output file
!=============================================
call HDFnames%set_ProgramData(SC_ECPmaster)
call HDFnames%set_NMLlist(SC_ECPmasterNameList)
call HDFnames%set_NMLfilename(SC_ECPmasterNML)
! Open an existing file or create a new file using the default properties.
if (trim(energyfile).eq.trim(outname)) then
hdferr = HDF%openFile(outname)
else
hdferr = HDF%createFile(outname)
end if
! write the EMheader to the file
datagroupname = trim(HDFnames%get_ProgramData())
call HDF%writeEMheader(EMsoft,dstr, tstrb, tstre, progname, datagroupname)
! open or create a namelist group to write all the namelist files into
hdferr = HDF%createGroup(HDFnames%get_NMLfiles())
! read the text file and write the array to the file
dataset = HDFnames%get_NMLfilename()
hdferr = HDF%writeDatasetTextFile(dataset, EMsoft%nmldeffile)
! leave this group
call HDF%pop()
! create a namelist group to write all the namelist files into
hdferr = HDF%createGroup(HDFnames%get_NMLparameters())
call MPFT%writeHDFNameList(HDF, HDFnames, emnl)
call Diff%writeBetheparameterNameList(HDF)
! leave this group
call HDF%pop()
! then the remainder of the data in a EMData group
hdferr = HDF%createGroup(HDFnames%get_EMData())
! create the EBSDmaster group and add a HDF_FileVersion attribbute to it
hdferr = HDF%createGroup(HDFnames%get_ProgramData())
HDF_FileVersion = '4.0'
HDF_FileVersion = cstringify(HDF_FileVersion)
attributename = SC_HDFFileVersion
hdferr = HDF%addStringAttributeToGroup(attributename, HDF_FileVersion)
! =====================================================
! The following write commands constitute HDF_FileVersion = 4.0
! =====================================================
dataset = SC_xtalname
allocate(stringarray(1))
stringarray(1)= trim(mcnl%xtalname)
call H5Lexists_f(HDF%getobjectID(),trim(dataset),g_exists, hdferr)
if (g_exists) then
hdferr = HDF%writeDatasetStringArray(dataset, stringarray, 1, overwrite)
else
hdferr = HDF%writeDatasetStringArray(dataset, stringarray, 1)
end if
dataset = SC_numset
call H5Lexists_f(HDF%getobjectID(),trim(dataset),g_exists, hdferr)
if (g_exists) then
hdferr = HDF%writeDatasetInteger(dataset, numset, overwrite)
else
hdferr = HDF%writeDatasetInteger(dataset, numset)
end if
dataset = SC_EkeV
call H5Lexists_f(HDF%getobjectID(),trim(dataset),g_exists, hdferr)
if (g_exists) then
hdferr = HDF%writeDatasetDouble(dataset, EkeV, overwrite)
else
hdferr = HDF%writeDatasetDouble(dataset, EkeV)
end if
! create the hyperslabs and write zeroes to them for now
dataset = SC_mLPNH
dims3 = (/ 2*emnl%npx+1, 2*emnl%npx+1, numsites /)
cnt3 = (/ 2*emnl%npx+1, 2*emnl%npx+1, numsites /)
offset3 = (/ 0, 0, 0 /)
call H5Lexists_f(HDF%getobjectID(),trim(dataset),g_exists, hdferr)
if (g_exists) then
hdferr = HDF%writeHyperslabFloatArray(dataset, mLPNH, dims3, offset3, cnt3, insert)
else
hdferr = HDF%writeHyperslabFloatArray(dataset, mLPNH, dims3, offset3, cnt3)
end if
dataset = SC_mLPSH
dims3 = (/ 2*emnl%npx+1, 2*emnl%npx+1, numsites /)
cnt3 = (/ 2*emnl%npx+1, 2*emnl%npx+1, numsites /)
offset3 = (/ 0, 0, 0 /)
call H5Lexists_f(HDF%getobjectID(),trim(dataset),g_exists, hdferr)
if (g_exists) then
hdferr = HDF%writeHyperslabFloatArray(dataset, mLPSH, dims3, offset3, cnt3, insert)
else
hdferr = HDF%writeHyperslabFloatArray(dataset, mLPSH, dims3, offset3, cnt3)
end if
dataset = SC_masterSPNH
dims3 = (/ 2*emnl%npx+1, 2*emnl%npx+1, numsites /)
cnt3 = (/ 2*emnl%npx+1, 2*emnl%npx+1, numsites /)
offset3 = (/ 0, 0, 0 /)
call H5Lexists_f(HDF%getobjectID(),trim(dataset),g_exists, hdferr)
if (g_exists) then
hdferr = HDF%writeHyperslabFloatArray(dataset, masterSPNH, dims3, offset3, cnt3, insert)
else
hdferr = HDF%writeHyperslabFloatArray(dataset, masterSPNH, dims3, offset3, cnt3)
end if
dataset = SC_masterSPSH
dims3 = (/ 2*emnl%npx+1, 2*emnl%npx+1, numsites /)
cnt3 = (/ 2*emnl%npx+1, 2*emnl%npx+1, numsites /)
offset3 = (/ 0, 0, 0 /)
call H5Lexists_f(HDF%getobjectID(),trim(dataset),g_exists, hdferr)
if (g_exists) then
hdferr = HDF%writeHyperslabFloatArray(dataset, masterSPSH, dims3, offset3, cnt3, insert)
else
hdferr = HDF%writeHyperslabFloatArray(dataset, masterSPSH, dims3, offset3, cnt3)
end if
! =====================================================
! end of HDF_FileVersion = 4.0 write statements
! =====================================================
call HDF%pop(.TRUE.)
! we use two times, one (1) for each individual energy level, the other (2) for the overall time
call timer%Time_tick(1)
reflist = gvectors_T()
!=============================================
! ---------- create the incident beam directions list
! determine all independent incident beam directions (use a linked list starting at khead)
! numk is the total number of k-vectors to be included in this computation;
! note that this needs to be redone for each energy, since the wave vector changes with energy
kvec = kvectors_T() ! initialize the wave vector list
call kvec%set_kinp( (/ 0.D0, 0.D0, 1.D0 /) )
call kvec%set_ktmax( 0.D0 )
call kvec%set_SamplingType( SamplingType )
call kvec%set_mapmode('RoscaLambert')
if (usehex) then
call kvec%Calckvectors(cell, SG, Diff, (/ 0.D0, 0.D0, 0.D0 /),emnl%npx,npy, ijmax,usehex)
else
call kvec%Calckvectors(cell, SG, Diff, (/ 0.D0, 0.D0, 0.D0 /),emnl%npx,npy, ijmax,usehex)
end if
numk = kvec%get_numk()
io_int(1)=numk
call Message%WriteValue('# independent beam directions to be considered = ', io_int, 1, "(I8)")
! ! convert part of the kvector linked list into arrays for OpenMP
izz = MCFT%getnumzbins()
allocate(lambdaZ(1:izz),stat=istat)
allocate(kij(3,numk),stat=istat)
allocate(klist(3,numk),knlist(numk),stat=istat)
! ! point to the first beam direction
ktmp => kvec%get_ListHead()
! ! and loop through the list, keeping k, kn, and i,j
kij(1:3,1) = (/ ktmp%i, ktmp%j, ktmp%hs /)
klist(1:3,1) = ktmp%k
knlist(1) = ktmp%kn
do i = 2,numk
ktmp => ktmp%next
kij(1:3,i) = (/ ktmp%i, ktmp%j, ktmp%hs /)
klist(1:3,i) = ktmp%k
knlist(i) = ktmp%kn
end do
! ! and remove the linked list
call kvec%Delete_kvectorlist()
call Diff%setrlpmethod('WK')
hkl=(/0,0,0/)
call Diff%CalcUcg(cell,hkl)
rlp = Diff%getrlp()
nabsl = rlp%xgp
do iz=1,izz
lambdaZ(iz) = float(sum(accum_z(numangle,iz,:,:)))/float(etotal)
lambdaZ(iz) = lambdaZ(iz) * exp(2.0*sngl(cPi)*(iz-1)*mcnl%depthstep/nabsl)
end do
verbose = .FALSE.
totstrong = 0
totweak = 0
fnat = 1.0/float(sum(cell%getnumat()))
intthick = dble(mcnl%depthmax)
! here's where we introduce the OpenMP calls, to speed up the overall calculations...
! set the number of OpenMP threads
nthreads = emnl%nthreads
!call OMP_SET_NUM_THREADS(nthreads)
call OMP_setNThreads(nthreads)
! use OpenMP to run on multiple cores ...
!$OMP PARALLEL COPYIN(rlp) &
!$OMP& PRIVATE(DynMat,Sgh,sghtmp,Lgh,i,FN,TID,kn,ipx,ipy,ix,ip,iequiv,nequiv,reflist,firstw) &
!$OMP& PRIVATE(kk,nns,nnw,nref,nat,io_int,io_int_sgl,nthreads,svals)
NUMTHREADS = OMP_GET_NUM_THREADS()
TID = OMP_GET_THREAD_NUM()
allocate(svals(numset))
!$OMP DO SCHEDULE(DYNAMIC,100)
! ---------- and here we start the beam direction loop
beamloop:do ik = 1,numk
!=============================================
! ---------- create the master reflection list for this beam direction
! Then we must determine the masterlist of reflections (also a linked list);
! This list basically samples a large reciprocal space volume; it does not
! distinguish between zero and higher order Laue zones, since that
! distinction becomes meaningless when we consider the complete
! reciprocal lattice.
reflist = gvectors_T()
kk = klist(1:3,ik)
FN = kk
! 02-06-2020 CLément Lafond : using emnl% cause fortran error 157 on Windows, replaced by self%nml% while trying to fix it
call reflist%Initialize_ReflectionList(cell, SG, Diff, FN, kk, self%nml%dmin, verbose)
nref = reflist%get_nref()
! ---------- end of "create the master reflection list"
!=============================================
! determine strong and weak reflections
nullify(firstw)
nns = 0
nnw = 0
call reflist%Apply_BethePotentials(Diff, firstw, nns, nnw)
if (self%nml%kinematical.eqv..FALSE.) then
! generate the dynamical matrix
if (allocated(DynMat)) deallocate(DynMat)
allocate(DynMat(nns,nns))
call reflist%GetDynMat(cell, Diff, firstw, DynMat, nns, nnw)
totstrong = totstrong + nns
totweak = totweak + nnw
if (ik.eq.1) write (*,*) ' maxval(DynMat) = ', maxval(abs(DynMat))
else
! all reflections are strong, but they are not coupled to each other, only to the
! incident beam; all q_{g-g'} are zero except the ones with g'=0. In addition, there
! is no anomalous absorption, only normal absorption.
if (allocated(DynMat)) deallocate(DynMat)
allocate(DynMat(nns,nns))
call reflist%GetDynMatKin(cell, Diff, firstw, DynMat, nns)
totstrong = totstrong + nns
totweak = 0
end if
! then we need to initialize the Sgh and Lgh arrays
if (allocated(Sghtmp)) deallocate(Sghtmp)
if (allocated(Lgh)) deallocate(Lgh)
allocate(Sghtmp(nns,nns,numset),Lgh(nns,nns))
Sghtmp = czero
Lgh = czero
call reflist%getSghfromLUT(Diff,nns,numset,Sghtmp)
! solve the dynamical eigenvalue equation for this beam direction
kn = knlist(ik)
call reflist%CalcLgh(DynMat,Lgh,intthick,dble(kn),nns,gzero,mcnl%depthstep,lambdaZ,izz)
! sum over the element-wise (Hadamard) product of the Lgh and Sgh arrays
svals = 0.0
do ix=1,numset
svals(ix) = real(sum(Lgh(1:nns,1:nns)*Sghtmp(1:nns,1:nns,ix)))
end do
svals = svals * fnat
! and store the resulting svals values, applying point group symmetry where needed.
ipx = kij(1,ik)
ipy = kij(2,ik)
ipz = kij(3,ik)
!
if (usehex) then
call L%Apply3DPGSymmetry(cell,SG,ipx,ipy,ipz,self%nml%npx,iequiv,nequiv,usehex)
else
if ((SG%getSpaceGroupNumber().ge.195).and.(SG%getSpaceGroupNumber().le.230)) then
call L%Apply3DPGSymmetry(cell,SG,ipx,ipy,ipz,self%nml%npx,iequiv,nequiv,cubictype=SamplingType)
else
call L%Apply3DPGSymmetry(cell,SG,ipx,ipy,ipz,self%nml%npx,iequiv,nequiv)
end if
end if
!$OMP CRITICAL
if (self%nml%combinesites.eqv..FALSE.) then
do ix=1,nequiv
if (iequiv(3,ix).eq.-1) mLPSH(iequiv(1,ix),iequiv(2,ix),1:numset) = svals(1:numset)
if (iequiv(3,ix).eq.1) mLPNH(iequiv(1,ix),iequiv(2,ix),1:numset) = svals(1:numset)
end do
else
do ix=1,nequiv
if (iequiv(3,ix).eq.-1) mLPSH(iequiv(1,ix),iequiv(2,ix),1) = sum(svals)
if (iequiv(3,ix).eq.1) mLPNH(iequiv(1,ix),iequiv(2,ix),1) = sum(svals)
end do
end if
!$OMP END CRITICAL
totw = totw + nnw
tots = tots + nns
deallocate(Lgh, Sghtmp)
if (mod(ik,5000).eq.0) then
io_int(1) = ik
io_int(2) = numk
call Message%WriteValue(' completed beam direction ',io_int, 2, "(I8,' of ',I8)")
end if
call reflist%Delete_gvectorlist()
end do beamloop
!end of OpenMP portion
!$OMP END PARALLEL
io_int(1) = nint(float(tots)/float(numk))
call Message%WriteValue(' -> Average number of strong reflections = ',io_int, 1, "(I5)")
io_int(1) = nint(float(totw)/float(numk))
call Message%WriteValue(' -> Average number of weak reflections = ',io_int, 1, "(I5)")
if (usehex) then
! and finally, we convert the hexagonally sampled array to a square Lambert projection which will be used
! for all ECP pattern interpolations; we need to do this for both the Northern and Southern hemispheres
! we begin by allocating auxiliary arrays to hold copies of the hexagonal data; the original arrays will
! then be overwritten with the newly interpolated data.
allocate(auxNH(-emnl%npx:emnl%npx,-npy:npy,1:numset),stat=istat)
allocate(auxSH(-emnl%npx:emnl%npx,-npy:npy,1:numset),stat=istat)
auxNH = mLPNH
auxSH = mLPSH
edge = 1.D0 / dble(emnl%npx)
scl = float(emnl%npx)
do i=-emnl%npx,emnl%npx
do j=-npy,npy
! determine the spherical direction for this point
L = Lambert_T( xyd = (/ dble(i), dble(j) /) * edge )
ierr = L%LambertSquareToSphere(dc)
! convert direction cosines to hexagonal Lambert projections
L = Lambert_T( xyzd = dc )
ierr = L%LambertSphereToHex(xy)
xy = xy * scl
! interpolate intensity from the neighboring points
if (ierr.eq.0) then
nix = floor(xy(1))
niy = floor(xy(2))
nixp = nix+1
niyp = niy+1
if (nixp.gt.emnl%npx) nixp = nix
if (niyp.gt.emnl%npx) niyp = niy
dx = xy(1) - nix
dy = xy(2) - niy
dxm = 1.D0 - dx
dym = 1.D0 - dy
mLPNH(i,j,1:numset) = auxNH(nix,niy,1:numset)*dxm*dym + auxNH(nixp,niy,1:numset)*dx*dym + &
auxNH(nix,niyp,1:numset)*dxm*dy + auxNH(nixp,niyp,1:numset)*dx*dy
mLPSH(i,j,1:numset) = auxSH(nix,niy,1:numset)*dxm*dym + auxSH(nixp,niy,1:numset)*dx*dym + &
auxSH(nix,niyp,1:numset)*dxm*dy + auxSH(nixp,niyp,1:numset)*dx*dy
end if
end do
end do
deallocate(auxNH, auxSH)
end if
! make sure that the outer pixel rim of the mLPSH patterns is identical to
! that of the mLPNH array.
mLPSH(-emnl%npx,-emnl%npx:emnl%npx,1:numset) = mLPNH(-emnl%npx,-emnl%npx:emnl%npx,1:numset)
mLPSH( emnl%npx,-emnl%npx:emnl%npx,1:numset) = mLPNH( emnl%npx,-emnl%npx:emnl%npx,1:numset)
mLPSH(-emnl%npx:emnl%npx,-emnl%npx,1:numset) = mLPNH(-emnl%npx:emnl%npx,-emnl%npx,1:numset)
mLPSH(-emnl%npx:emnl%npx, emnl%npx,1:numset) = mLPNH(-emnl%npx:emnl%npx, emnl%npx,1:numset)
! get stereographic projections (summed over the atomic positions)
Radius = 1.0
do i=-emnl%npx,emnl%npx
do j=-emnl%npx,emnl%npx
L = Lambert_T( xyd = (/ dble(i), dble(j) /) / dble(emnl%npx) )
ierr = L%StereoGraphicInverse( xyz, Radius )
xyz = xyz/vecnorm(xyz)
if (ierr.ne.0) then
masterSPNH(i,j,1:numset) = 0.0
masterSPSH(i,j,1:numset) = 0.0
else
masterSPNH(i,j,1:numset) = InterpolateLambert(xyz, mLPNH, emnl%npx, numset)
masterSPSH(i,j,1:numset) = InterpolateLambert(xyz, mLPSH, emnl%npx, numset)
end if
end do
end do
! open the existing file using the default properties.
hdferr = HDF%openFile(outname)
! update the time string
hdferr = HDF%openGroup(HDFnames%get_EMheader())
hdferr = HDF%openGroup(HDFnames%get_ProgramData())
dataset = SC_StopTime
call timer%Time_tock(1)
tstop = timer%getInterval(1)
call timer%Time_reset(1)
call timer%makeTimeStamp()
dstr = timer%getDateString()
tstre = timer%getTimeString()
line2(1) = dstr//', '//tstre
hdferr = HDF%writeDatasetStringArray(dataset, line2, 1, overwrite)
io_int(1) = tstop
call Message%WriteValue(' Execution time [s]: ',io_int,1)
dataset = SC_Duration
call H5Lexists_f(HDF%getobjectID(),trim(dataset),g_exists, hdferr)
if (g_exists) then
hdferr = HDF%writeDatasetFloat(dataset, tstop, overwrite)
else
hdferr = HDF%writeDatasetFloat(dataset, tstop)
end if
call HDF%pop()
call HDF%pop()
hdferr = HDF%openGroup(HDFnames%get_EMData())
hdferr = HDF%openGroup(HDFnames%get_ProgramData())
! add data to the hyperslab
dataset = SC_mLPNH
dims3 = (/ 2*emnl%npx+1, 2*emnl%npx+1, numsites /)
cnt3 = (/ 2*emnl%npx+1, 2*emnl%npx+1, numsites /)
offset3 = (/ 0, 0, 0 /)
hdferr = HDF%writeHyperslabFloatArray(dataset, mLPNH, dims3, offset3, cnt3, insert)
dataset = SC_mLPSH
dims3 = (/ 2*emnl%npx+1, 2*emnl%npx+1, numsites /)
cnt3 = (/ 2*emnl%npx+1, 2*emnl%npx+1, numsites /)
offset3 = (/ 0, 0, 0 /)
hdferr = HDF%writeHyperslabFloatArray(dataset, mLPSH, dims3, offset3, cnt3, insert)
dataset = SC_masterSPNH
dims3 = (/ 2*emnl%npx+1, 2*emnl%npx+1, numsites /)
cnt3 = (/ 2*emnl%npx+1, 2*emnl%npx+1, numsites /)
offset3 = (/ 0, 0, 0 /)
hdferr = HDF%writeHyperslabFloatArray(dataset, masterSPNH, dims3, offset3, cnt3, insert)
dataset = SC_masterSPSH
dims3 = (/ 2*emnl%npx+1, 2*emnl%npx+1, numsites /)
cnt3 = (/ 2*emnl%npx+1, 2*emnl%npx+1, numsites /)
offset3 = (/ 0, 0, 0 /)
hdferr = HDF%writeHyperslabFloatArray(dataset, masterSPSH, dims3, offset3, cnt3, insert)
call HDF%pop(.TRUE.)
call Message%printMessage(' Final data stored in file '//trim(emnl%energyfile), frm = "(A/)")
! if requested, we notify the user that this program has completed its run
if (trim(EMsoft%getConfigParameter('EMNotify')).ne.'Off') then
if (trim(emnl%Notify).eq.'On') then
NumLines = 3
allocate(MessageLines(NumLines))
call hostnm(c)
MessageLines(1) = 'EMECPmaster program has ended successfully'
MessageLines(2) = 'Master pattern data stored in '//trim(outname)
write (exectime,"(F10.4)") timer%getInterval(2)
MessageLines(3) = 'Total execution time [s]: '//trim(exectime)
SlackUsername = 'EMsoft on '//trim(c)
i = PostMessage(EMsoft, MessageLines, NumLines, SlackUsername)
end if
end if
end associate
end subroutine ECPmaster_
end module mod_ECPmaster
|
```python
%matplotlib inline
```
```python
from IPython.core.display import HTML
css_file = './inet.css'
HTML(open(css_file, "r").read())
```
<style>
#notebook h1 {
font-size: 200%;
text-align: center;
}
#notebook h2 {
font-size: 150%;
text-align: center;
}
#notebook h3 {
font-size: 150%;
margin-bottom: 10px;
}
#notebook div.cell {
width: 100%;
}
#notebook h3.bank {
margin-bottom: 20px;
}
#notebook p {
font-size: 150%;
}
#notebook ul {
font-size: 150%;
}
#notebook ol {
font-size: 150%;
}
#notebook li {
padding-top: 5px;
padding-bottom: 5px;
}
#notebook h1.title-slide {
font-size: 250%;
text-align: center;
}
#notebook h2.title-slide {
padding-top: 100px;
padding-bottom: 100px;
}
#notebook img.title-slide {
height: 150px;
margin: auto;
}
</style>
```python
import matplotlib.pyplot as plt
from matplotlib import collections as mc
plt.xkcd()
import numpy as np
import pandas as pd
import seaborn as sn
import statsmodels.formula.api as smf
from IPython.html import widgets
from IPython.display import display
import pypwt
```
:0: FutureWarning: IPython widgets are experimental and may change in the future.
<h1 class="title-slide"> (Linear) Regression </h1>
<h3>Q: What is regression?</h3>
A: Drawing a "line" through a scatter of data points in a principled way...
<h3>Q: What is <em>linear</em> regression?</h3>
A: Drawing a <em>straight</em> "line" through a scatter of data points in a principled way...
<h2>Linear regression in practice</h2>
<h2 class="section-header"> Step 1: Grab some data...</h2>
```python
# grab the entire Penn World Tables data from the web...
pwt = pypwt.load_pwt_data()
```
```python
#...this gives us a panel (i.e., two dimensional) data set
pwt
```
<class 'pandas.core.panel.Panel'>
Dimensions: 38 (items) x 167 (major_axis) x 62 (minor_axis)
Items axis: country to delta_k
Major_axis axis: AGO to ZWE
Minor_axis axis: 1950-01-01 00:00:00 to 2011-01-01 00:00:00
```python
def labor_supply(data, year="1950-01-01"):
"""
Labor supply in a given year is the product of number of employed
persons, 'emp', and the average number of hours worked, 'avh'.
Parameters
----------
data : pandas.Panel
The Penn World Tables (PWT) data set.
year : str (default="1950-01-01")
Some year between 1950 and 2011. Format should be "YYYY-01-01".
Returns
-------
L : pandas.Series
Effective labor supply in units of employed person-years.
"""
L = data.minor_xs(year)["emp"] * data.minor_xs(year)["avh"]
return L
def real_gdp_per_unit_labor(data, year="1950-01-01"):
"""
Real gross domestic product (GDP) per unit labor is the ratio of
some measure of real output and some measure of labor supply.
Parameters
----------
data : pandas.Panel
The Penn World Tables (PWT) data set.
year : str (default="1950-01-01")
Some year between 1950 and 2011. Format should be "YYYY-01-01".
Returns
-------
rgdppul : pandas.Series
Real gdp per unit labor supply.
"""
rgdppul = data.minor_xs(year)["rgdpo"] / labor_supply(data, year)
return rgdppul
def growth_rate_real_gdp_per_unit_labor(data, start="1950-01-01", end="2011-01-01"):
"""
Plot the growth rate of real GDP per unit labor over some time period
against the level of real GDP per unit labor at the start of the time
period.
Parameters
----------
data : pandas.Panel
The Penn World Tables (PWT) data set.
start : str (default="1950-01-01")
Some year between 1950 and 2011. Format should be "YYYY-01-01".
end : str (default="2011-01-01")
Some year between 1950 and 2011. Format should be "YYYY-01-01".
"""
gr = (np.log(real_gdp_per_unit_labor(data, end)) -
np.log(real_gdp_per_unit_labor(data, start)))
return gr
def some_interesting_plot(data, start="1950-01-01", end="2011-01-01"):
"""
Plot the growth rate of real GDP per unit labor over some time period
against the level of real GDP per unit labor at the start of the time
period.
Parameters
----------
data : pandas.Panel
The Penn World Tables (PWT) data set.
start : str (default="1950-01-01")
Some year between 1950 and 2011. Format should be "YYYY-01-01".
end : str (default="2011-01-01")
Some year between 1950 and 2011. Format should be "YYYY-01-01".
"""
# create the scatter plot
fig, ax = plt.subplots(1, 1, figsize=(12,9))
xs = np.log(real_gdp_per_unit_labor(data, start))
ys = growth_rate_real_gdp_per_unit_labor(data, start, end)
ax.scatter(xs, ys, color='k')
# axis labels, title, etc
ax.set_xlabel('Log income (per unit labor) in 1960', fontsize=25)
ax.set_xlim(0.95 * xs.min(), 1.05 * xs.max())
ax.set_ylabel('Income (per unit labor) growth\n({}-{})'.format(start[:4], end[:4]),
fontsize=25)
ax.set_ylim(1.05 * ys.min(), 1.05 * ys.max())
ax.set_title('Do poor countries grow faster than rich countries?',
fontsize=25, family="serif")
```
Let's focus on a relation between...
1. (log) level of real income
2. subsequent growth rate of income
...note that income is "per unit labor supply"
<h2 class="section-header">Step 2: plot your data...</h2>
```python
some_interesting_plot(data=pwt, start="1960-01-01", end="2010-01-01")
```
<h2 class="section-header">Step 3: draw a (straight!) line through your data...</h2>
```python
def another_interesting_plot(data, start, end, intercept=2.5, slope=-0.5):
"""
Plot the growth rate of real GDP per unit labor over some time period
against the level of real GDP per unit labor at the start of the time
period. Then add a regression line associated with given values for the
intercept and slope.
Parameters
----------
data : pandas.Panel
The Penn World Tables (PWT) data set.
start : str (default="1950-01-01")
Some year between 1950 and 2011. Format should be "YYYY-01-01".
end : str (default="2011-01-01")
Some year between 1950 and 2011. Format should be "YYYY-01-01".
intercept: float (defalut=2.5)
Intercept for the regression line.
slope : float (default=-0.5)
Slope for the regression line.
"""
# create the scatter plot
fig, ax = plt.subplots(1, 1, figsize=(12,9))
xs = np.log(real_gdp_per_unit_labor(data, start))
ys = growth_rate_real_gdp_per_unit_labor(data, start, end)
ax.scatter(xs, ys, color='k')
# compute the regression line given params
grid = np.linspace(0.95 * xs.min(), 1.05 * xs.max(), 1000)
predicted = lambda x: intercept + slope * x
yhat, = ax.plot(grid, predicted(grid) , color='b',
label=r"$\hat{y}_i=%.2f + %.2fx_i$" %(intercept, slope))
# axis labels, title, etc
ax.set_xlabel('Log income (per unit labor) in 1960', fontsize=25)
ax.set_xlim(0.95 * xs.min(), 1.05 * xs.max())
ax.set_ylabel('Income (per unit labor) growth\n({}-{})'.format(start[:4], end[:4]),
fontsize=25)
ax.set_ylim(1.05 * ys.min(), 1.05 * ys.max())
ax.legend(bbox_to_anchor=(1.0, 0.95), prop={'size': 25})
```
Since we are drawing straight lines...
$$y_i = \beta_0 + \beta_1 x_i + \epsilon_i$$
where
\begin{align}
y_i=& \text{income growth from 1960-2010} \\
x_i=& \ln (\text{income in 1960})
\end{align}
and $i=\text{AGO},\dots,\text{ZWE}$.
```python
another_interesting_plot(pwt, start="1960-01-01", end="2010-01-01")
```
<h2 class="section-header">Step 4: choose some measure of deviation between model and data...</h2>
Given our choice of model...
$$ y_i = \beta_0 + \beta_1 x_i + \epsilon_i,\ i=1,\dots,N $$
...focus on the sum of squared errors (SSE):
$$ SSE \equiv \sum_{i=1}^N \epsilon_i^2 = \sum_{i=1}^N \big(y_i - (\beta_0 + \beta_1x_i)\big)^2 $$
<h2 class="section-header">Step 5: choose params to minimize deviation between model and data...</h2>
```python
def another_static_plot(data, start, end, intercept=2.5, slope=-0.5):
"""
Plot the growth rate of real GDP per unit labor over some time period
against the level of real GDP per unit labor at the start of the time
period. Then add a regression line associated with given values for the
intercept and slope.
Parameters
----------
data : pandas.Panel
The Penn World Tables (PWT) data set.
start : str (default="1950-01-01")
Some year between 1950 and 2011. Format should be "YYYY-01-01".
end : str (default="2011-01-01")
Some year between 1950 and 2011. Format should be "YYYY-01-01".
intercept: float (default=2.5)
Intercept for the regression line.
slope : float (default=-0.5)
Slope for the regression line.
"""
# create the scatter plot
fig, ax = plt.subplots(1, 1, figsize=(12,9))
xs = np.log(real_gdp_per_unit_labor(data, start))
ys = growth_rate_real_gdp_per_unit_labor(data, start, end)
ax.scatter(xs, ys, color='k')
# compute and plot the regression line given current params
predicted = lambda x: intercept + slope * x
grid = np.linspace(0.95 * xs.min(), 1.05 * xs.max(), 1000)
yhat, = ax.plot(grid, predicted(grid) , color='b')
ssr = np.sum((predicted(xs) - ys)**2)
# add the residuals to the plot
lines = zip(zip(xs, ys), zip(xs, predicted(xs)))
lc = mc.LineCollection(lines, colors='r', linewidths=2)
ax.add_collection(lc)
# axis labels, title, etc
ax.set_xlabel('Log income (per unit labor) in 1960', fontsize=25)
ax.set_xlim(0.95 * xs.min(), 1.05 * xs.max())
ax.set_ylabel('Income (per unit labor) growth\n({}-{})'.format(start[:4], end[:4]),
fontsize=25)
fig.suptitle(r'Sum of squared errors (SSE) $\equiv \sum_{i=1}^N (y_i - (\beta_0 + \beta_1x_i))^2$',
x=0.5, y=1.025, fontsize=25, family="serif")
fig.legend([yhat, lc], [r"$\hat{y}_i=\hat{\beta}_0 + \hat{\beta}_1x_i$", r"$SSE={0:.4f}$".format(ssr)],
bbox_to_anchor=(0.8, 0.85), prop={'size': 25})
# create the interactive widget
intercept_widget = widgets.FloatSlider(value=2.5e0, min=0.0, max=5.0, step=5e-2, description=r"$\hat{\beta}_0$")
slope_widget = widgets.FloatSlider(value=-0.5, min=-1.0, max=1.0, step=5e-2, description=r"$\hat{\beta}_1$")
some_interactive_plot = widgets.interactive(another_static_plot,
data=widgets.fixed(pwt),
start=widgets.fixed("1960-01-01"),
end=widgets.fixed("2010-01-01"),
intercept=intercept_widget,
slope=slope_widget,
)
```
<h3>Informal parameter estimation...</h3>
```python
display(some_interactive_plot)
```
<h3>Formal parameter estimation...</h3>
Our estimates $\hat{\beta}_0$ and $\hat{\beta}_1$ solve the following optimization problem...
$$ \min_{\beta_0, \beta_1} \sum_{i=1}^N (y_i - (\beta_0 + \beta_1x_i))^2 $$
Taking of derivatives yields a system of first-order conditions...
\begin{align}
0 =& -2\sum_{i=1}^N (y_i - (\beta_0 + \beta_1x_i)) \\
0 =& -2\sum_{i=1}^N (y_i - (\beta_0 + \beta_1x_i))x_i
\end{align}
...which after some algebra yields...
\begin{align}
\hat{\beta}_0 =& \bar{y} - \hat{\beta}_1 \bar{x} \\
\hat{\beta}_1 =& \frac{\frac{1}{N}\sum_{i=1}^N(x_i - \bar{x})(y_i - \bar{y})}{\frac{1}{N}\sum_{i=1}^N(x_i - \bar{x})^2}
\end{align}
Intuition for $\hat{\beta}_1$...
\begin{align}
\hat{\beta}_1 =& \frac{Cov(x, y)}{Var(x)} \\
\equiv& \frac{\text{How much do $x$ and $y$ vary together?}}{\text{How much does $x$ vary in general?}}
\end{align}
```python
# compute the optimal parameter estimates "by hand"
estimated_slope = xs.cov(ys) / xs.var()
estimated_intercept = ys.mean() - estimated_slope * xs.mean()
```
```python
print "Estimated intercept: {}".format(estimated_intercept)
print "Estimated slope: {}".format(estimated_slope)
```
Estimated intercept: 2.60212926608
Estimated slope: -0.610771408878
```python
# define the variables
xs = np.log(real_gdp_per_unit_labor(pwt, '1960-01-01'))
ys = growth_rate_real_gdp_per_unit_labor(pwt, '1960-01-01', '2010-01-01')
# compute and plot the regression line given current params
data = pd.DataFrame.from_dict({'x': xs, 'y': ys})
lm = smf.ols(formula="y ~ x", data=data).fit()
```
```python
lm.summary()
```
<table class="simpletable">
<caption>OLS Regression Results</caption>
<tr>
<th>Dep. Variable:</th> <td>y</td> <th> R-squared: </th> <td> 0.438</td>
</tr>
<tr>
<th>Model:</th> <td>OLS</td> <th> Adj. R-squared: </th> <td> 0.420</td>
</tr>
<tr>
<th>Method:</th> <td>Least Squares</td> <th> F-statistic: </th> <td> 24.19</td>
</tr>
<tr>
<th>Date:</th> <td>Thu, 21 May 2015</td> <th> Prob (F-statistic):</th> <td>2.71e-05</td>
</tr>
<tr>
<th>Time:</th> <td>10:50:38</td> <th> Log-Likelihood: </th> <td> -21.613</td>
</tr>
<tr>
<th>No. Observations:</th> <td> 33</td> <th> AIC: </th> <td> 47.23</td>
</tr>
<tr>
<th>Df Residuals:</th> <td> 31</td> <th> BIC: </th> <td> 50.22</td>
</tr>
<tr>
<th>Df Model:</th> <td> 1</td> <th> </th> <td> </td>
</tr>
<tr>
<th>Covariance Type:</th> <td>nonrobust</td> <th> </th> <td> </td>
</tr>
</table>
<table class="simpletable">
<tr>
<td></td> <th>coef</th> <th>std err</th> <th>t</th> <th>P>|t|</th> <th>[95.0% Conf. Int.]</th>
</tr>
<tr>
<th>Intercept</th> <td> 2.6021</td> <td> 0.276</td> <td> 9.442</td> <td> 0.000</td> <td> 2.040 3.164</td>
</tr>
<tr>
<th>x</th> <td> -0.6108</td> <td> 0.124</td> <td> -4.919</td> <td> 0.000</td> <td> -0.864 -0.358</td>
</tr>
</table>
<table class="simpletable">
<tr>
<th>Omnibus:</th> <td> 6.668</td> <th> Durbin-Watson: </th> <td> 1.627</td>
</tr>
<tr>
<th>Prob(Omnibus):</th> <td> 0.036</td> <th> Jarque-Bera (JB): </th> <td> 5.773</td>
</tr>
<tr>
<th>Skew:</th> <td>-1.021</td> <th> Prob(JB): </th> <td> 0.0558</td>
</tr>
<tr>
<th>Kurtosis:</th> <td> 3.178</td> <th> Cond. No. </th> <td> 8.68</td>
</tr>
</table>
```python
def plot_fitted_model(data, start="1950-01-01", end="2011-01-01"):
"""
Plot the growth rate of real GDP per unit labor over some time period
against the level of real GDP per unit labor at the start of the time
period. Then add a regression line associated with given values for the
intercept and slope.
Parameters
----------
data : pandas.Panel
The Penn World Tables (PWT) data set.
start : str (default="1950-01-01")
Some year between 1950 and 2011. Format should be "YYYY-01-01".
end : str (default="2011-01-01")
Some year between 1950 and 2011. Format should be "YYYY-01-01".
"""
# create the scatter plot
fig, ax = plt.subplots(1, 1, figsize=(12,9))
xs = np.log(real_gdp_per_unit_labor(data, start))
ys = (np.log(real_gdp_per_unit_labor(data, end)) -
np.log(real_gdp_per_unit_labor(data, start)))
ax.scatter(xs, ys, color='k')
# compute and plot the regression line given current params
data = pd.DataFrame.from_dict({'x': xs, 'y': ys})
lm = smf.ols(formula="y ~ x", data=data).fit()
predicted = lambda x: lm.params[0] + lm.params[1] * x
grid = np.linspace(0.95 * xs.min(), 1.05 * xs.max(), 1000)
yhat, = ax.plot(grid, predicted(grid) , color='b')
ssr = np.sum((predicted(xs) - ys)**2)
# add the residuals to the plot
lines = zip(zip(xs, ys), zip(xs, predicted(xs)))
lc = mc.LineCollection(lines, colors='r', linewidths=2)
ax.add_collection(lc)
# axis labels, title, etc
ax.set_xlabel('Log income (per unit labor) in 1960', fontsize=25)
ax.set_xlim(0.95 * xs.min(), 1.05 * xs.max())
ax.set_ylabel('Income (per unit labor) growth\n({}-{})'.format(start[:4], end[:4]),
fontsize=25)
ax.set_ylim(1.05 * ys.min(), 1.05 * ys.max())
fig.legend([yhat, lc], [r"$\hat{y}_i=%.4f + %.4f x_i$" % (lm.params[0], lm.params[1]),
r"$SSR={0:.4f}$".format(ssr)],
bbox_to_anchor=(0.85, 0.85), prop={'size': 25})
```
<h3>Plotting the final result...</h3>
```python
plot_fitted_model(pwt, '1960-01-01', '2010-01-01')
```
<h2>Have we found any evidence for convergence?</h2>
Yes...
* slope coefficient has the correct sign
...but...
What about...
* Omitted variable bias!
* Sample selection issues!
* Measurement error?
* etc.
|
function factorial(x)
if x ≤ 1
return 1
else
return x * factorial(x - 1)
end
end
v = factorial(big(9000))
s = string(v)
for c in s
println(c)
end
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Rudimentary timer class based on MPI_WTIME
! 2016: Nick Featherstone, CU Research Computing
Module Timing
USE MPI, Only : MPI_WTIME, MPI_WTICK
Type, Public :: Timer
Real*8 :: delta, elapsed
Real*8 :: t1
Contains
Procedure :: Init => Initialize_Timer
Procedure :: startclock
Procedure :: stopclock
Procedure :: increment
End Type Timer
Contains
Subroutine get_ticklength(tl)
Implicit None
Real*8, Intent(InOUt) :: tl
tl = mpi_wtick()
End Subroutine get_ticklength
Subroutine Initialize_Timer(self)
Implicit None
Class(Timer) :: self
self%elapsed = 0.0d0
self%t1 = 0.0d0
self%delta = 0.0d0
End Subroutine Initialize_Timer
Subroutine Startclock(self)
Implicit None
Class(Timer) :: self
self%t1 = MPI_WTIME()
End Subroutine Startclock
Subroutine Stopclock(self)
Implicit None
Real*8 :: t2
Class(Timer) :: self
t2 = MPI_WTIME()
self%delta = t2-self%t1
End Subroutine Stopclock
Subroutine Increment(self)
Implicit None
Class(Timer) :: self
Call self%stopclock()
self%elapsed = self%elapsed+self%delta
End Subroutine Increment
End Module Timing
|
theory PigeonholeWorking
imports Complex_Main HOL.Finite_Set
begin
lemma distinct2:
fixes A :: "'a set"
assumes assms:
"finite A"
"card A \<ge> 2"
obtains x y where "x \<in> A \<and> y \<in> A \<and> x \<noteq> y"
proof-
obtain x A' where "x \<in> A \<and> x \<notin> A' \<and> card A' = card A - 1 \<and> A' \<subseteq> A"
using assms(2) card_eq_SucD [of "A" "card A - 1"] by auto
hence x: "x \<in> A" "x \<notin> A'" "card A' = card A - 1" "A' \<subseteq> A" by auto
hence A'_card: "card A' = card A - 1" by auto
also have "... \<ge> 1" using assms(2) by auto
finally have "card A' \<ge> 1" by auto
then obtain y where y: "y \<in> A'" using card_eq_SucD [of "A'" "card A' - 1"] by auto
from that show ?thesis using x y by auto
qed
theorem pigeonhole:
fixes f :: "'a \<Rightarrow> 'b"
shows "\<And>A B. \<forall>a \<in> A. \<exists>b \<in> B. f a = b
\<Longrightarrow> m = card B - 1
\<Longrightarrow> finite A
\<Longrightarrow> finite B
\<Longrightarrow> card B < card A
\<Longrightarrow> card B > 0
\<Longrightarrow> (\<exists>x y. x \<noteq> y \<and> f x = f y)"
proof(induction m rule: nat.induct)
case zero
then have B_card: "card B = 1" using zero.prems by auto
then have A_card: "card A \<ge> 2" using zero.prems by auto
obtain b where "B = {b}" using B_card card_1_singletonE by auto
then have "\<forall>x \<in> A. f x = b" using zero.prems by auto
moreover obtain x y where "x \<in> A \<and> y \<in> A \<and> x \<noteq> y" using A_card zero.prems distinct2[of "A"] by auto
moreover have "f x = b" using calculation by auto
moreover have "f y = b" using calculation by auto
ultimately have "x \<noteq> y \<and> f x = f y" by auto
hence "\<exists>y. x \<noteq> y \<and> f x = f y" by (rule exI)
thus ?case by (rule exI)
next
case (Suc m)
have "card A > 0" using Suc.prems by auto
from this obtain a where a: "a \<in> A" using card_eq_SucD[of "A" "card A - 1"] by auto
then have fa_in_B: "f a \<in> B" using Suc.prems by auto
show ?case
proof(cases "\<exists>y. a \<noteq> y \<and> f a = f y")
case True
thus ?thesis by (rule exI)
next
case False
then have fa_unique: "\<forall>y. a \<noteq> y \<longrightarrow> f a \<noteq> f y" by auto
define A' where "A' = A - {a}"
define B' where "B' = B - {f a}"
have A'_card: "card A' = card A - 1" using a A'_def card_Diff_singleton[of "a" "A'"] by auto
have B'_card: "card B' = card B - 1" using fa_in_B B'_def card_Diff_singleton[of "f a" "B'"] by auto
have "A' \<subseteq> A" using A'_def by auto
moreover from this have "\<forall>x \<in> A'. f x \<in> B" using Suc.prems by auto
moreover have "\<forall>x \<in> A'. f x \<noteq> f a" using fa_unique A'_def by auto
moreover from this have "\<forall>x \<in> A'. f x \<notin> {f a}" using A'_def B'_def fa_unique by auto
ultimately have "\<forall>x \<in> A'. f x \<in> B \<and> f x \<notin> {f a}" by auto
then have "\<forall>x \<in> A'. f x \<in> B'" using B'_def by auto
then have "\<forall>x \<in> A'. \<exists>b \<in> B'. f x = b" by auto
moreover have "finite A'" using Suc.prems A'_def by auto
moreover have "finite B'" using Suc.prems B'_def by auto
moreover have "card B' > 0" using Suc.prems B'_card by auto
moreover from this have "card B' < card A'" using Suc.prems by (auto simp: A'_card B'_card)
moreover have "card B' - 1 = m" using Suc.prems B'_card by auto
ultimately show ?thesis using Suc.IH[of "A'" "B'"] by auto
qed
qed
(*Better formatted and stuff*)
theorem pigeonhole2:
fixes f :: "'a \<Rightarrow> 'b"
fixes m :: "nat"
assumes "\<forall>a \<in> A. \<exists>b \<in> B. f a = b"
assumes "finite A"
assumes "finite B"
assumes "card B < card A"
assumes "card B > 0"
shows "\<exists>x y. x \<noteq> y \<and> f x = f y"
using assms
proof(induction "card B - 1" arbitrary: "A" "B" rule: nat.induct)
case zero
then have B_card: "card B = 1" using zero.prems by auto
then have A_card: "card A \<ge> 2" using zero.prems by auto
obtain b where "B = {b}" using B_card card_1_singletonE by auto
then have "\<forall>x \<in> A. f x = b" using zero.prems by auto
moreover obtain x y where "x \<in> A \<and> y \<in> A \<and> x \<noteq> y" using A_card zero.prems distinct2[of "A"] by auto
moreover have "f x = b" using calculation by auto
moreover have "f y = b" using calculation by auto
ultimately have "x \<noteq> y \<and> f x = f y" by auto
hence "\<exists>y. x \<noteq> y \<and> f x = f y" by (rule exI)
thus ?case by (rule exI)
next
case (Suc m)
have "card A > 0" using Suc.prems by auto
from this obtain a where a: "a \<in> A" using card_eq_SucD[of "A" "card A - 1"] by auto
then have fa_in_B: "f a \<in> B" using Suc.prems by auto
show ?case
proof(cases "\<exists>y. a \<noteq> y \<and> f a = f y")
case True
thus ?thesis by (rule exI)
next
case False
then have fa_unique: "\<forall>y. a \<noteq> y \<longrightarrow> f a \<noteq> f y" by auto
let ?A' = "A - {a}"
let ?B' = "B - {f a}"
have A'_card: "card ?A' = card A - 1" using a card_Diff_singleton[of "a" "?A'"] by auto
have B'_card: "card ?B' = card B - 1" using fa_in_B card_Diff_singleton[of "f a" "?B'"] by auto
have "?A' \<subseteq> A" by auto
moreover from this have "\<forall>x \<in> ?A'. f x \<in> B" using Suc.prems by auto
moreover have "\<forall>x \<in> ?A'. f x \<noteq> f a" using fa_unique by auto
moreover from this have "\<forall>x \<in> ?A'. f x \<notin> {f a}" using fa_unique by auto
ultimately have "\<forall>x \<in> ?A'. f x \<in> B \<and> f x \<notin> {f a}" by auto
then have "\<forall>x \<in> ?A'. f x \<in> ?B'" by auto
then have "\<forall>x \<in> ?A'. \<exists>b \<in> ?B'. f x = b" by auto
moreover have "finite ?A'" using Suc.prems by auto
moreover have "finite ?B'" using Suc.prems by auto
moreover have "card ?B' > 0" using B'_card Suc.hyps(2) by linarith
moreover from this have "card ?B' < card ?A'"
by (simp add: A'_card B'_card Suc.prems(4) diff_less_mono)
moreover have "card ?B' - 1 = m"
by (metis B'_card Suc.hyps(2) diff_Suc_1)
ultimately show ?thesis using Suc.hyps(1)[of "?B'" "?A'"] by auto
qed
qed
theorem pigeonhole_obtain:
fixes f :: "'a \<Rightarrow> 'b" and
A :: "'a set" and
B :: "'b set"
assumes "finite A" and
"finite B" and
"card A > card B" and
"\<forall>x \<in> A. f x \<in> B"
obtains x y where "f x = f y" using pigeonhole by auto
theorem pigeonhole_app:
fixes f :: "nat \<Rightarrow> nat" and
A :: "nat set" and
B :: "nat set"
assumes "finite A" and
"finite B" and
"card A > card B" and
"\<forall>x \<in> A. f x \<in> B"
shows "\<exists>x y. f x = f y" using assms pigeonhole by auto
end |
[STATEMENT]
lemma rot_circle_bot_left_edges_neq [simp]: "rot_circle_bot_edge \<noteq> rot_circle_left_edge"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. rot_circle_bot_edge \<noteq> rot_circle_left_edge
[PROOF STEP]
by (simp add: rot_circle_left_edge_def rot_circle_bot_edge_def x_coord_def) |
[STATEMENT]
lemma Lower_dual [simp]:
"Lower (inv_gorder L) A = Upper L A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. Lower (inv_gorder L) A = Upper L A
[PROOF STEP]
by (simp add:Upper_def Lower_def) |
Formal statement is: lemma primes_characterization'_int [rule_format]: "finite {p. p \<ge> 0 \<and> 0 < f (p::int)} \<Longrightarrow> \<forall>p. 0 < f p \<longrightarrow> prime p \<Longrightarrow> prime_factors (\<Prod>p | p \<ge> 0 \<and> 0 < f p. p ^ f p) = {p. p \<ge> 0 \<and> 0 < f p}" Informal statement is: If $f$ is a function from the positive integers to the positive integers such that the set of primes $p$ such that $f(p) > 0$ is finite, then the prime factors of $\prod_{p \geq 0, f(p) > 0} p^{f(p)}$ are exactly the primes $p$ such that $f(p) > 0$. |
[STATEMENT]
lemma sbintrunc_rest [simp]: "(signed_take_bit :: nat \<Rightarrow> int \<Rightarrow> int) n ((\<lambda>k::int. k div 2) ((signed_take_bit :: nat \<Rightarrow> int \<Rightarrow> int) n bin)) = (\<lambda>k::int. k div 2) ((signed_take_bit :: nat \<Rightarrow> int \<Rightarrow> int) n bin)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. signed_take_bit n (signed_take_bit n bin div 2) = signed_take_bit n bin div 2
[PROOF STEP]
by (induct n arbitrary: bin) (simp_all add: signed_take_bit_Suc mod2_eq_if) |
SUBROUTINE LAMBERT_SURFACE (NSTOKES, NUMMU, MODE,
. MU_VALUES, QUAD_WEIGHTS,
. GROUND_ALBEDO,
. REFLECT, TRANS, SOURCE)
C LAMBERT_SURFACE makes the reflection matrix for a Lambertian
C surface with albedo (GROUND_ALBEDO). Also makes the diagonal
C transmission and zero source function.
INTEGER NSTOKES, NUMMU, MODE
REAL*8 MU_VALUES(NUMMU), QUAD_WEIGHTS(NUMMU)
REAL*8 GROUND_ALBEDO
REAL*8 REFLECT(NSTOKES,NUMMU, NSTOKES,NUMMU, 2)
REAL*8 TRANS(NSTOKES,NUMMU, NSTOKES,NUMMU, 2)
REAL*8 SOURCE(NSTOKES,NUMMU, 2)
INTEGER J1, J2, N
N = NSTOKES*NUMMU
CALL MZERO (2*N, N, REFLECT)
CALL MZERO (2*N, 1, SOURCE)
CALL MIDENTITY (N, TRANS(1,1,1,1,1))
CALL MIDENTITY (N, TRANS(1,1,1,1,2))
C The Lambertian ground reflects the flux equally in all direction
C and completely unpolarizes the radiation
IF (MODE .EQ. 0) THEN
DO J1 = 1, NUMMU
DO J2 = 1, NUMMU
REFLECT(1,J1, 1,J2, 2) = 2.0*GROUND_ALBEDO*
. MU_VALUES(J2)*QUAD_WEIGHTS(J2)
ENDDO
ENDDO
ENDIF
RETURN
END
SUBROUTINE LAMBERT_RADIANCE (NSTOKES, NUMMU, MODE,
. SRC_CODE, GROUND_ALBEDO, GROUND_TEMP,
. WAVELENGTH, DIRECT_SFC_FLUX, RADIANCE)
C LAMBERT_RADIANCE calculates the ground radiance of a Lambertian
C surface. The radiance is due to thermal radiation and reflected
C direct solar radiation if there is a solar source (SRC_CODE=1,3).
C TOTAL_DEPTH is the total optical depth in the direction of the
C direct source (sun), with the path length effect already included.
INTEGER NSTOKES, NUMMU, MODE, SRC_CODE
REAL*8 GROUND_ALBEDO, GROUND_TEMP, WAVELENGTH
REAL*8 DIRECT_SFC_FLUX
REAL*8 RADIANCE(NSTOKES,NUMMU)
INTEGER J, N
REAL*8 TMP, THERMAL, PLANCK, PI
PARAMETER (PI = 3.1415926535897932384D0)
N = NSTOKES*NUMMU
CALL MZERO (N, 1, RADIANCE)
IF (MODE .EQ. 0) THEN
C Thermal radiation going up
IF (SRC_CODE .EQ. 2 .OR. SRC_CODE .EQ. 3) THEN
CALL PLANCK_FUNCTION (GROUND_TEMP, 'R', WAVELENGTH, PLANCK)
THERMAL = (1.0-GROUND_ALBEDO)*PLANCK
DO J = 1, NUMMU
RADIANCE(1,J) = THERMAL
ENDDO
ENDIF
C Direct solar reflection (unpolarized)
IF (SRC_CODE .EQ. 1 .OR. SRC_CODE .EQ. 3) THEN
TMP = DIRECT_SFC_FLUX * GROUND_ALBEDO/PI
DO J = 1, NUMMU
RADIANCE(1,J) = RADIANCE(1,J) + TMP
ENDDO
ENDIF
ENDIF
RETURN
END
SUBROUTINE FRESNEL_SURFACE (NSTOKES, NUMMU,
. MU_VALUES, INDEX,
. REFLECT, TRANS, SOURCE)
C FRESNEL_REFLECT makes the reflection matrix for a
C plane surface with index of refraction (INDEX) using
C the Fresnel reflection formulae. Also makes the diagonal
C transmission and zero source function.
INTEGER NSTOKES, NUMMU
REAL*8 MU_VALUES(NUMMU)
REAL*8 REFLECT(NSTOKES,NUMMU, NSTOKES,NUMMU, 2)
REAL*8 TRANS(NSTOKES,NUMMU, NSTOKES,NUMMU, 2)
REAL*8 SOURCE(NSTOKES,NUMMU, 2)
COMPLEX*16 INDEX
INTEGER J, N
REAL*8 COSI, R1, R2, R3, R4
COMPLEX*16 EPSILON, D, RH, RV
N = NSTOKES*NUMMU
CALL MZERO (2*N, N, REFLECT)
CALL MZERO (2*N, 1, SOURCE)
CALL MIDENTITY (N, TRANS(1,1,1,1,1))
CALL MIDENTITY (N, TRANS(1,1,1,1,2))
EPSILON = INDEX**2
DO J = 1, NUMMU
COSI = MU_VALUES(J)
D = CDSQRT(EPSILON - 1.0D0 + COSI**2)
RH = (COSI - D) / (COSI + D)
RV =(EPSILON*COSI - D) / (EPSILON*COSI + D)
R1 = (CDABS(RV)**2 + CDABS(RH)**2 )/2.0D0
R2 = (CDABS(RV)**2 - CDABS(RH)**2 )/2.0D0
R3 = DREAL(RV*CONJG(RH))
R4 = DIMAG(RV*CONJG(RH))
REFLECT(1,J, 1,J, 2) = R1
IF (NSTOKES .GT. 1) THEN
REFLECT(1,J, 2,J, 2) = R2
REFLECT(2,J, 1,J, 2) = R2
REFLECT(2,J, 2,J, 2) = R1
ENDIF
IF (NSTOKES .GT. 2) THEN
REFLECT(3,J, 3,J, 2) = R3
ENDIF
IF (NSTOKES .GT. 3) THEN
REFLECT(3,J, 4,J, 2) = -R4
REFLECT(4,J, 3,J, 2) = R4
REFLECT(4,J, 4,J, 2) = R3
ENDIF
ENDDO
RETURN
END
SUBROUTINE FRESNEL_RADIANCE (NSTOKES, NUMMU, MODE,
. MU_VALUES, INDEX, GROUND_TEMP,
. WAVELENGTH, RADIANCE)
C FRESNEL_RADIANCE calculates the ground radiance of a plane
C surface using the Fresnel formulae. The radiance is due only to
C thermal radiation (this subroutine cannot do specular reflection).
INTEGER NSTOKES, NUMMU, MODE
REAL*8 GROUND_TEMP, WAVELENGTH, MU_VALUES(NUMMU)
REAL*8 RADIANCE(NSTOKES,NUMMU)
COMPLEX*16 INDEX
INTEGER J, N
REAL*8 ZERO, PLANCK, COSI, R1, R2
COMPLEX*16 EPSILON, D, RH, RV
PARAMETER (ZERO=0.0D0)
C Thermal radiation going up
N = NSTOKES*NUMMU
CALL MZERO (N, 1, RADIANCE)
IF (MODE .EQ. 0) THEN
CALL PLANCK_FUNCTION (GROUND_TEMP, 'R', WAVELENGTH, PLANCK)
EPSILON = INDEX**2
DO J = 1, NUMMU
COSI = MU_VALUES(J)
D = CDSQRT(EPSILON - 1.0D0 + COSI**2)
RH = (COSI - D) / (COSI + D)
RV =(EPSILON*COSI - D) / (EPSILON*COSI + D)
R1 = (CDABS(RV)**2 + CDABS(RH)**2 )/2.0D0
R2 = (CDABS(RV)**2 - CDABS(RH)**2 )/2.0D0
RADIANCE(1,J) = (1.0 - R1) * PLANCK
IF (NSTOKES .GT. 1) RADIANCE(2,J) = -R2 * PLANCK
ENDDO
ENDIF
RETURN
END
SUBROUTINE THERMAL_RADIANCE (NSTOKES, NUMMU, MODE,
. TEMPERATURE, ALBEDO,
. WAVELENGTH, RADIANCE)
C THERMAL_RADIANCE returns a polarized radiance vector for
C thermal emission at WAVELENGTH (microns) for a body with
C ALBEDO and with a TEMPERATURE (Kelvins). The radiance is in
C the units: Watts / (meter^2 ster micron). The emission is
C isotropic and unpolarized: only the first term in azimuth Fourier
C series is nonzero, and all MU terms are the same.
INTEGER NSTOKES, NUMMU, MODE
REAL*8 TEMPERATURE, WAVELENGTH, ALBEDO
REAL*8 RADIANCE(NSTOKES,NUMMU,2)
INTEGER J, N
REAL*8 PLANCK, THERMAL
N = NSTOKES*NUMMU
CALL MZERO (2*N, 1, RADIANCE)
IF (MODE .EQ. 0) THEN
CALL PLANCK_FUNCTION (TEMPERATURE, 'R', WAVELENGTH, PLANCK)
THERMAL = (1.0-ALBEDO)*PLANCK
DO J = 1, NUMMU
RADIANCE(1,J,1) = THERMAL
RADIANCE(1,J,2) = THERMAL
ENDDO
ENDIF
RETURN
END
SUBROUTINE PLANCK_FUNCTION (TEMP, UNITS, WAVELENGTH, PLANCK)
C Calculates the Planck blackbody radiance in
C [Watts /(meter^2 ster micron)] for a temperature in [Kelvins]
C at a wavelength in [microns]. If using temperature units then
C the Planck function is simple the temperature.
REAL*8 TEMP, WAVELENGTH, PLANCK
CHARACTER*1 UNITS
IF (UNITS .EQ. 'T') THEN
PLANCK = TEMP
ELSE
IF (TEMP .GT. 0.0) THEN
PLANCK = 1.1911D8 / WAVELENGTH**5
. / (DEXP(1.4388D4/(WAVELENGTH*TEMP)) - 1)
ELSE
PLANCK = 0.0
ENDIF
ENDIF
RETURN
END
SUBROUTINE GAUSS_LEGENDRE_QUADRATURE
. (NUM, ABSCISSAS, WEIGHTS)
C Generates the abscissas and weights for an even 2*NUM point
C Gauss-Legendre quadrature. Only the NUM positive points are returned.
INTEGER NUM
REAL*8 ABSCISSAS(1), WEIGHTS(1)
INTEGER N, I, J, L
REAL*8 X, XP, PL, PL1, PL2, DPL, TINY
PARAMETER (TINY=3.0D-14)
N = 2*NUM
DO J = 1, NUM
X = COS(3.141592654*(J-.25)/(N+.5))
I = 0
100 CONTINUE
PL1 = 1
PL = X
DO L = 2, N
PL2 = PL1
PL1 = PL
PL = ( (2*L-1)*X*PL1 - (L-1)*PL2 )/L
ENDDO
DPL = N*(X*PL-PL1)/(X*X-1)
XP = X
X = XP - PL/DPL
I = I+1
IF (ABS(X-XP).GT.TINY .AND. I.LT.10) GO TO 100
ABSCISSAS(NUM+1-J) = X
WEIGHTS(NUM+1-J) = 2/((1-X*X)*DPL*DPL)
ENDDO
RETURN
END
SUBROUTINE DOUBLE_GAUSS_QUADRATURE
. (NUM, ABSCISSAS, WEIGHTS)
C Generates the abscissas and weights for an even 2*NUM point
C Gauss-Legendre quadrature. Only the NUM positive points are returned.
INTEGER NUM
REAL*8 ABSCISSAS(*), WEIGHTS(*)
INTEGER N, K, I, J, L
REAL*8 X, XP, PL, PL1, PL2, DPL, TINY
PARAMETER (TINY=3.0D-14)
N = NUM
K = (N+1)/2
DO J = 1, K
X = COS(3.141592654*(J-.25)/(N+.5))
I = 0
100 CONTINUE
PL1 = 1
PL = X
DO L = 2, N
PL2 = PL1
PL1 = PL
PL = ( (2*L-1)*X*PL1 - (L-1)*PL2 )/L
ENDDO
DPL = N*(X*PL-PL1)/(X*X-1)
XP = X
X = XP - PL/DPL
I = I+1
IF (ABS(X-XP).GT.TINY .AND. I.LT.10) GO TO 100
ABSCISSAS(J) = (1D0-X)/2D0
ABSCISSAS(NUM+1-J) = (1D0+X)/2D0
WEIGHTS(NUM+1-J) = 1.0D0/((1.0D0-X*X)*DPL*DPL)
WEIGHTS(J) = 1.0D0/((1.0D0-X*X)*DPL*DPL)
ENDDO
RETURN
END
SUBROUTINE LOBATTO_QUADRATURE
. (NUM, ABSCISSAS, WEIGHTS)
C Generates the abscissas and weights for an even 2*NUM point
C Gauss-Legendre quadrature. Only the NUM positive points are returned.
INTEGER NUM
REAL*8 ABSCISSAS(*), WEIGHTS(*)
INTEGER N, N1, I, J, L
REAL*8 X, XP, PL, PL1, PL2, DPL, D2PL, CI, TINY
PARAMETER (TINY=3.0D-14)
N = 2*NUM
N1 = N-1
CI = 0.50
IF (MOD(N,2) .EQ. 1) CI = 1.00
DO J = 1, NUM-1
X = SIN(3.141592654*(J-CI)/(N-.5))
I = 0
100 CONTINUE
PL1 = 1
PL = X
DO L = 2, N1
PL2 = PL1
PL1 = PL
PL = ( (2*L-1)*X*PL1 - (L-1)*PL2 )/L
ENDDO
DPL = N1*(X*PL-PL1)/(X*X-1)
D2PL = (2.D0*X*DPL-N1*(N1+1)*PL) / (1D0-X*X)
XP = X
X = XP - DPL/D2PL
I = I+1
IF (ABS(X-XP).GT.TINY .AND. I.LT.10) GO TO 100
ABSCISSAS(J) = X
WEIGHTS(J) = 2.0D0/(N*N1*PL*PL)
ENDDO
ABSCISSAS(NUM) = 1.D0
WEIGHTS(NUM) = 2.D0/(N*N1)
RETURN
END
|
/-
Copyright (c) 2019 Simon Hudon. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Simon Hudon
-/
import tactic.basic
import data.equiv.basic
/-!
# Monad
## Attributes
* ext
* functor_norm
* monad_norm
## Implementation Details
Set of rewrite rules and automation for monads in general and
`reader_t`, `state_t`, `except_t` and `option_t` in particular.
The rewrite rules for monads are carefully chosen so that `simp with
functor_norm` will not introduce monadic vocabulary in a context where
applicatives would do just fine but will handle monadic notation
already present in an expression.
In a context where monadic reasoning is desired `simp with monad_norm`
will translate functor and applicative notation into monad notation
and use regular `functor_norm` rules as well.
## Tags
functor, applicative, monad, simp
-/
mk_simp_attribute monad_norm none with functor_norm
attribute [ext] reader_t.ext state_t.ext except_t.ext option_t.ext
attribute [functor_norm] bind_assoc pure_bind bind_pure
attribute [monad_norm] seq_eq_bind_map
universes u v
@[monad_norm]
lemma map_eq_bind_pure_comp
(m : Type u → Type v) [monad m] [is_lawful_monad m] {α β : Type u} (f : α → β) (x : m α) :
f <$> x = x >>= pure ∘ f := by rw bind_pure_comp_eq_map
/-- run a `state_t` program and discard the final state -/
def state_t.eval {m : Type u → Type v} [functor m] {σ α} (cmd : state_t σ m α) (s : σ) : m α :=
prod.fst <$> cmd.run s
universes u₀ u₁ v₀ v₁
/-- reduce the equivalence between two state monads to the equivalence between
their respective function spaces -/
def state_t.equiv {m₁ : Type u₀ → Type v₀} {m₂ : Type u₁ → Type v₁}
{α₁ σ₁ : Type u₀} {α₂ σ₂ : Type u₁} (F : (σ₁ → m₁ (α₁ × σ₁)) ≃ (σ₂ → m₂ (α₂ × σ₂))) :
state_t σ₁ m₁ α₁ ≃ state_t σ₂ m₂ α₂ :=
{ to_fun := λ ⟨f⟩, ⟨F f⟩,
inv_fun := λ ⟨f⟩, ⟨F.symm f⟩,
left_inv := λ ⟨f⟩, congr_arg state_t.mk $ F.left_inv _,
right_inv := λ ⟨f⟩, congr_arg state_t.mk $ F.right_inv _ }
/-- reduce the equivalence between two reader monads to the equivalence between
their respective function spaces -/
def reader_t.equiv {m₁ : Type u₀ → Type v₀} {m₂ : Type u₁ → Type v₁}
{α₁ ρ₁ : Type u₀} {α₂ ρ₂ : Type u₁} (F : (ρ₁ → m₁ α₁) ≃ (ρ₂ → m₂ α₂)) :
reader_t ρ₁ m₁ α₁ ≃ reader_t ρ₂ m₂ α₂ :=
{ to_fun := λ ⟨f⟩, ⟨F f⟩,
inv_fun := λ ⟨f⟩, ⟨F.symm f⟩,
left_inv := λ ⟨f⟩, congr_arg reader_t.mk $ F.left_inv _,
right_inv := λ ⟨f⟩, congr_arg reader_t.mk $ F.right_inv _ }
|
module BuckinghamPi
(
FundamentalUnit(..),
DimensionalVariable(..),
DimensionlessVariable(..),
Exponent(..),
generatePiGroups,
numFundamentalUnits
) where
import Control.Applicative
import Data.List (nub, (\\))
import Numeric.LinearAlgebra.Data
import Numeric.LinearAlgebra.HMatrix
import Text.Printf (printf)
-- Define sum type for fundamental units (M,L,T,Theta).
data FundamentalUnit = Mass | Length | Time | Temperature deriving (Eq,Show)
-- Define type synonym for Exponent.
type Exponent = Double
-- A variable is defined by the name, along with units, which is a list of tuples which contains
-- the FundamentalUnit along with an exponent.
data DimensionalVariable = DimensionalVariable {name :: String, units :: [(FundamentalUnit, Exponent)]} deriving (Eq,Show)
-- Define data type for a dimensionless variable.
data DimensionlessVariable = DimensionlessVariable {dimensionalVariables :: [DimensionalVariable], exponents :: [Exponent]} deriving (Eq)
-- Define function which normalizes exponents so that the smallest value is +/- 1.
normalizeExponents :: [Exponent] -> [Exponent]
normalizeExponents exps = map (/factor) exps
where
minExp = minimum exps
factor = minExp * signum minExp
-- Define show instance for a dimensionless variable.
instance Show DimensionlessVariable where
show (DimensionlessVariable dimVars exps) = concatMap (uncurry (printf "%s^(%.4f) ")) $ filter (\t -> abs (snd t) > 1.0e-6) $ zip (map name dimVars) (normalizeExponents exps)
getFundamentalUnits :: DimensionalVariable -> [FundamentalUnit]
getFundamentalUnits dimVar = map fst $ units dimVar
getUniqueFundamentalUnits :: [DimensionalVariable] -> [FundamentalUnit]
getUniqueFundamentalUnits = nub . concatMap getFundamentalUnits
numFundamentalUnits :: [DimensionalVariable] -> Int
numFundamentalUnits = length . getUniqueFundamentalUnits
-- Define function that computes the number of dimensionless groups given a list of dimensional variables.
computeNumberOfGroups :: [DimensionalVariable] -> Int
computeNumberOfGroups dimensionalVars = length dimensionalVars - numFundamentalUnits dimensionalVars
-- Define function that returns nonrepeating variables.
getNonrepeatingVars :: [DimensionalVariable] -> [Int] -> [DimensionalVariable]
getNonrepeatingVars dimVars repeatedIndices = [dimVars !! i | i <- [0..(length dimVars - 1)], i `notElem` repeatedIndices]
-- Define a function that returns the exponent on a given unit in the given dimensional variable.
getExponent :: FundamentalUnit -> DimensionalVariable -> Exponent
getExponent unit dimVar
| unit `elem` map fst (units dimVar) = snd $ head $ filter (\u -> fst u == unit) $ units dimVar
| otherwise = 0.0
-- Define a function that returns the equation that must be solved.
getEquation :: [DimensionalVariable] -> FundamentalUnit -> [Exponent]
getEquation varCombination funUnit = map (getExponent funUnit) varCombination
getVariableCombinations :: [DimensionalVariable] -> [DimensionalVariable] -> [[DimensionalVariable]]
getVariableCombinations repeatingVars = map (\x -> repeatingVars ++ [x])
buildMatrix :: [DimensionalVariable] -> [FundamentalUnit] -> Matrix Double
buildMatrix varCombination funUnits = fromLists $ map (getEquation varCombination) funUnits
findDimensionlessGroup :: [FundamentalUnit] -> [DimensionalVariable] -> DimensionlessVariable
findDimensionlessGroup funUnits dimVars = DimensionlessVariable dimVars (concat . toLists $ nullspace $ buildMatrix dimVars funUnits)
-- Define function which takes a list of dimensional variables along with a list of integers
-- that identifies which are the repeated variables, and returns a list of dimensionless variables.
generatePiGroups :: [DimensionalVariable] -> [Int] -> [DimensionlessVariable]
generatePiGroups dimVars repeatingVarInds = map (findDimensionlessGroup funUnits) (getVariableCombinations repeatingVars nonrepeatingVars)
where
repeatingVars = [dimVars !! i | i <- repeatingVarInds]
nonrepeatingVars = dimVars \\ repeatingVars
funUnits = getUniqueFundamentalUnits dimVars
|
/**
*
* @file example_sgelqf.c
*
* PLASMA testing routines
* PLASMA is a software package provided by Univ. of Tennessee,
* Univ. of California Berkeley and Univ. of Colorado Denver
*
* @brief Example using LQ factorization
*
* @version 2.6.0
* @author Bilel Hadri
* @date 2010-11-15
* @generated s Tue Jan 7 11:45:20 2014
*
**/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <plasma.h>
#include <cblas.h>
#include <lapacke.h>
#include <core_blas.h>
#ifndef max
#define max(a, b) ((a) > (b) ? (a) : (b))
#endif
#ifndef min
#define min(a, b) ((a) < (b) ? (a) : (b))
#endif
int check_orthogonality(int, int, int, float*);
int check_factorization(int, int, float*, float*, int, float*);
int IONE=1;
int ISEED[4] = {0,0,0,1}; /* initial seed for slarnv() */
int main ()
{
int cores = 2;
int M = 10;
int N = 15;
int LDA = 10;
int K = min(M, N);
int info;
int info_ortho, info_factorization;
int i,j;
int LDAxN = LDA*N;
float *A1 = (float *)malloc(LDA*N*sizeof(float));
float *A2 = (float *)malloc(LDA*N*sizeof(float));
float *Q = (float *)malloc(LDA*N*sizeof(float));
PLASMA_desc *T;
/* Check if unable to allocate memory */
if ((!A1)||(!A2)||(!Q)){
printf("Out of Memory \n ");
return EXIT_SUCCESS;
}
/* Plasma Initialization */
PLASMA_Init(cores);
printf("-- PLASMA is initialized to run on %d cores. \n",cores);
/* Allocate T */
PLASMA_Alloc_Workspace_sgelqf(M, N, &T);
/* Initialize A1 and A2 */
LAPACKE_slarnv_work(IONE, ISEED, LDAxN, A1);
for (i = 0; i < M; i++)
for (j = 0; j < N; j++)
A2[LDA*j+i] = A1[LDA*j+i] ;
/* Factorization QR of the matrix A2 */
info = PLASMA_sgelqf(M, N, A2, LDA, T);
/* Building the economy-size Q */
memset((void*)Q, 0, LDA*N*sizeof(float));
for (i = 0; i < K; i++)
Q[LDA*i+i] = 1.0;
PLASMA_sorglq(M, N, K, A2, LDA, T, Q, LDA);
/* Check the orthogonality, factorization and the solution */
info_ortho = check_orthogonality(M, N, LDA, Q);
info_factorization = check_factorization(M, N, A1, A2, LDA, Q);
if ((info_ortho != 0)|(info_factorization != 0)|(info != 0))
printf("-- Error in SGELQF example ! \n");
else
printf("-- Run of SGELQF example successful ! \n");
free(A1); free(A2); free(Q); free(T);
PLASMA_Finalize();
return EXIT_SUCCESS;
}
/*-------------------------------------------------------------------
* Check the orthogonality of Q
*/
int check_orthogonality(int M, int N, int LDQ, float *Q)
{
float alpha, beta;
float normQ;
int info_ortho;
int i;
int minMN = min(M, N);
float eps;
float *work = (float *)malloc(minMN*sizeof(float));
eps = LAPACKE_slamch_work('e');
alpha = 1.0;
beta = -1.0;
/* Build the idendity matrix USE DLASET?*/
float *Id = (float *) malloc(minMN*minMN*sizeof(float));
memset((void*)Id, 0, minMN*minMN*sizeof(float));
for (i = 0; i < minMN; i++)
Id[i*minMN+i] = (float)1.0;
/* Perform Id - Q'Q */
if (M >= N)
cblas_ssyrk(CblasColMajor, CblasUpper, CblasTrans, N, M, alpha, Q, LDQ, beta, Id, N);
else
cblas_ssyrk(CblasColMajor, CblasUpper, CblasNoTrans, M, N, alpha, Q, LDQ, beta, Id, M);
normQ = LAPACKE_slansy_work(LAPACK_COL_MAJOR, lapack_const(PlasmaInfNorm), 'u', minMN, Id, minMN, work);
printf("============\n");
printf("Checking the orthogonality of Q \n");
printf("||Id-Q'*Q||_oo / (N*eps) = %e \n",normQ/(minMN*eps));
if ( isnan(normQ / (minMN * eps)) || (normQ / (minMN * eps) > 10.0) ) {
printf("-- Orthogonality is suspicious ! \n");
info_ortho=1;
}
else {
printf("-- Orthogonality is CORRECT ! \n");
info_ortho=0;
}
free(work); free(Id);
return info_ortho;
}
/*------------------------------------------------------------
* Check the factorization QR
*/
int check_factorization(int M, int N, float *A1, float *A2, int LDA, float *Q)
{
float Anorm, Rnorm;
float alpha, beta;
int info_factorization;
int i,j;
float eps;
eps = LAPACKE_slamch_work('e');
float *Ql = (float *)malloc(M*N*sizeof(float));
float *Residual = (float *)malloc(M*N*sizeof(float));
float *work = (float *)malloc(max(M,N)*sizeof(float));
alpha=1.0;
beta=0.0;
if (M >= N) {
/* Extract the R */
float *R = (float *)malloc(N*N*sizeof(float));
memset((void*)R, 0, N*N*sizeof(float));
LAPACKE_slacpy_work(LAPACK_COL_MAJOR,'u', M, N, A2, LDA, R, N);
/* Perform Ql=Q*R */
memset((void*)Ql, 0, M*N*sizeof(float));
cblas_sgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, M, N, N, (alpha), Q, LDA, R, N, (beta), Ql, M);
free(R);
}
else {
/* Extract the L */
float *L = (float *)malloc(M*M*sizeof(float));
memset((void*)L, 0, M*M*sizeof(float));
LAPACKE_slacpy_work(LAPACK_COL_MAJOR,'l', M, N, A2, LDA, L, M);
/* Perform Ql=LQ */
memset((void*)Ql, 0, M*N*sizeof(float));
cblas_sgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, M, N, M, (alpha), L, M, Q, LDA, (beta), Ql, M);
free(L);
}
/* Compute the Residual */
for (i = 0; i < M; i++)
for (j = 0 ; j < N; j++)
Residual[j*M+i] = A1[j*LDA+i]-Ql[j*M+i];
Rnorm = LAPACKE_slange_work(LAPACK_COL_MAJOR, lapack_const(PlasmaInfNorm), M, N, Residual, M, work);
Anorm = LAPACKE_slange_work(LAPACK_COL_MAJOR, lapack_const(PlasmaInfNorm), M, N, A2, LDA, work);
if (M >= N) {
printf("============\n");
printf("Checking the QR Factorization \n");
printf("-- ||A-QR||_oo/(||A||_oo.N.eps) = %e \n",Rnorm/(Anorm*N*eps));
}
else {
printf("============\n");
printf("Checking the LQ Factorization \n");
printf("-- ||A-LQ||_oo/(||A||_oo.N.eps) = %e \n",Rnorm/(Anorm*N*eps));
}
if (isnan(Rnorm / (Anorm * N *eps)) || (Rnorm / (Anorm * N * eps) > 10.0) ) {
printf("-- Factorization is suspicious ! \n");
info_factorization = 1;
}
else {
printf("-- Factorization is CORRECT ! \n");
info_factorization = 0;
}
free(work); free(Ql); free(Residual);
return info_factorization;
}
|
universes u v
namespace state_t
variables {σ α : Type u}
variables {m : Type u → Type u}
variables [monad m]
variables [is_lawful_monad m]
open is_lawful_monad
lemma get_bind (s : σ) (f : σ → state_t σ m α)
: (get >>= f).run s = (f s).run s :=
by { simp [bind,state_t.bind,get,state_t.get,monad_state.lift,pure_bind,has_pure.pure,bind._match_1] }
end state_t
|
module LatticeSymmetries.Group
( Permutation,
unPermutation,
mkPermutation,
identityPermutation,
fromGenerators,
pgLength,
Symmetry,
mkSymmetry,
SymmetriesHeader (..),
mkSymmetries,
symmetriesFromHeader,
Symmetries (..),
nullSymmetries,
emptySymmetries,
symmetriesGetNumberBits,
symmetriesFromSpec,
)
where
import Data.Aeson (FromJSON (..), ToJSON (..), object, withObject, (.:), (.=))
import Data.Complex
import qualified Data.List
import Data.Ratio
import qualified Data.Set as Set
import qualified Data.Vector as B
import qualified Data.Vector.Generic as G
import qualified Data.Vector.Storable as S
import Foreign.C.Types (CDouble)
import Foreign.ForeignPtr
import Foreign.Ptr
import Foreign.Storable
import GHC.Exts (IsList (..))
import LatticeSymmetries.Benes
import LatticeSymmetries.Dense
import LatticeSymmetries.FFI
import LatticeSymmetries.IO
import LatticeSymmetries.Utils
import System.IO.Unsafe (unsafePerformIO)
import Prelude hiding (identity, permutations, toList)
newtype PermutationGroup = PermutationGroup (B.Vector Permutation)
deriving stock (Show, Eq)
getPeriodicity :: Permutation -> Int
getPeriodicity p₀ = go 1 p₀
where
identity = identityPermutation (G.length (unPermutation p₀))
go !n !p
| p == identity = n
| otherwise = go (n + 1) (p₀ <> p)
nullPermutationGroup :: PermutationGroup -> Bool
nullPermutationGroup (PermutationGroup gs) = G.null gs
data Symmetry = Symmetry
{ symmetryPermutation :: !Permutation,
symmetryPhase :: !(Ratio Int)
}
deriving stock (Show, Eq, Ord)
symmetrySector :: Symmetry -> Int
symmetrySector s
| denominator sector == 1 = numerator sector
| otherwise = error $ "this should not have happened: invalid symmetry: " <> show s
where
sector = symmetryPhase s * fromIntegral (getPeriodicity (symmetryPermutation s))
instance FromJSON Symmetry where
parseJSON = withObject "Symmetry" $ \v -> do
mkSymmetry <$> v .: "permutation" <*> v .: "sector"
instance ToJSON Symmetry where
toJSON s = object ["permutation" .= symmetryPermutation s, "sector" .= symmetrySector s]
mkSymmetry :: Permutation -> Int -> Symmetry
mkSymmetry p sector
| sector < 0 || sector >= periodicity =
error $
"invalid sector: " <> show sector <> "; permutation has periodicity " <> show periodicity
| otherwise = Symmetry p (sector % periodicity)
where
periodicity = getPeriodicity p
symmetryNumberSites :: Symmetry -> Int
symmetryNumberSites (Symmetry p _) = G.length (unPermutation p)
modOne :: Integral a => Ratio a -> Ratio a
modOne x
| x >= 1 = x - fromIntegral (numerator x `div` denominator x)
| otherwise = x
instance Semigroup Symmetry where
(<>) (Symmetry pa λa) (Symmetry pb λb) = Symmetry (pa <> pb) (modOne (λa + λb))
data SymmetriesHeader = SymmetriesHeader
{ symmHeaderGroup :: !PermutationGroup,
symmHeaderNetwork :: !BatchedBenesNetwork,
symmHeaderCharactersReal :: !(S.Vector Double),
symmHeaderCharactersImag :: !(S.Vector Double)
}
deriving stock (Show, Eq)
getNumberBits :: SymmetriesHeader -> Int
getNumberBits (SymmetriesHeader (PermutationGroup gs) _ _ _)
| G.null gs = 0
| otherwise = G.length . unPermutation . G.head $ gs
emptySymmetriesHeader :: SymmetriesHeader
emptySymmetriesHeader = SymmetriesHeader (PermutationGroup G.empty) emptyBatchedBenesNetwork G.empty G.empty
data Symmetries = Symmetries {symmetriesHeader :: !SymmetriesHeader, symmetriesContents :: !(ForeignPtr Cpermutation_group)}
deriving stock (Show)
instance Eq Symmetries where
(==) a b = symmetriesHeader a == symmetriesHeader b
instance FromJSON Symmetries where
parseJSON xs = mkSymmetries <$> parseJSON xs
instance ToJSON Symmetries where
toJSON symmetries = toJSON (toSymmetryList symmetries)
toSymmetryList :: Symmetries -> [Symmetry]
toSymmetryList (Symmetries (SymmetriesHeader (PermutationGroup gs) _ λsRe λsIm) _) =
Data.List.zipWith3 _toSymmetry (G.toList gs) (G.toList λsRe) (G.toList λsIm)
where
_toSymmetry :: Permutation -> Double -> Double -> Symmetry
_toSymmetry g λRe λIm
| r ≈ 1 && s' ≈ fromIntegral (round s' :: Int) = mkSymmetry g (round s')
| otherwise = error $ "failed to reconstruct Symmetry from " <> show (toList g) <> " and λ = " <> show λRe <> " + " <> show λIm <> "j"
where
-- φ = sector / periodicity, but care needs to be taken because φ is approximate
s' = φ * fromIntegral n
n = getPeriodicity g
-- polar returns the phase in (-π, π], we add 2π to get a positive value
(r, _φ) = polar (λRe :+ λIm)
φ = _φ / (2 * pi) + (if _φ < 0 then 1 else 0)
pgLength :: PermutationGroup -> Int
pgLength (PermutationGroup gs) = G.length gs
fromGenerators :: (Semigroup a, Ord a) => a -> [a] -> [a]
fromGenerators _ [] = []
fromGenerators identity gs = go Set.empty (Set.singleton identity)
where
go !interior !boundary
| Set.null boundary = Set.toAscList $ interior
| otherwise = go interior' boundary'
where
interior' = interior `Set.union` boundary
boundary' = Set.fromList [h <> g | h <- Set.toList boundary, g <- gs] Set.\\ interior'
nullSymmetries :: Symmetries -> Bool
nullSymmetries = nullPermutationGroup . symmHeaderGroup . symmetriesHeader
emptySymmetries :: Symmetries
emptySymmetries = symmetriesFromHeader emptySymmetriesHeader
symmetriesGetNumberBits :: Symmetries -> Int
symmetriesGetNumberBits = getNumberBits . symmetriesHeader
mkSymmetries :: [Symmetry] -> Symmetries
mkSymmetries gs = case symmetriesFromHeader <$> mkSymmetriesHeader gs of
Just s -> s
Nothing -> error "incompatible symmetries"
mkSymmetriesHeader :: [Symmetry] -> Maybe SymmetriesHeader
mkSymmetriesHeader [] = Just emptySymmetriesHeader
mkSymmetriesHeader gs@(g : _)
| all ((== n) . symmetryNumberSites) gs = case isConsistent of
True ->
let permutations = G.fromList $ symmetryPermutation <$> symmetries
permGroup = PermutationGroup permutations
benesNetwork = mkBatchedBenesNetwork $ G.map toBenesNetwork permutations
charactersReal = G.fromList $ (\φ -> cos (-2 * pi * realToFrac φ)) <$> symmetryPhase <$> symmetries
charactersImag = G.fromList $ (\φ -> sin (-2 * pi * realToFrac φ)) <$> symmetryPhase <$> symmetries
in Just $ SymmetriesHeader permGroup benesNetwork charactersReal charactersImag
False -> Nothing
| otherwise = error "symmetries have different number of sites"
where
n = symmetryNumberSites g
identity = mkSymmetry (identityPermutation n) 0
symmetries = fromGenerators identity gs
isConsistent = all id $ do
s₁ <- symmetries
s₂ <- symmetries
let s₃@(Symmetry p₃ λ₃) = s₁ <> s₂
pure $
Set.member s₃ set
&& denominator (λ₃ * fromIntegral (getPeriodicity p₃)) == 1
where
set = Set.fromList symmetries
symmetriesFromHeader :: SymmetriesHeader -> Symmetries
symmetriesFromHeader x = unsafePerformIO $ do
fp <- mallocForeignPtr
let (DenseMatrix numberShifts numberMasks masks) = bbnMasks $ symmHeaderNetwork x
shifts = bbnShifts $ symmHeaderNetwork x
numberBits = getNumberBits x
withForeignPtr fp $ \ptr ->
S.unsafeWith masks $ \masksPtr ->
S.unsafeWith shifts $ \shiftsPtr ->
S.unsafeWith (symmHeaderCharactersReal x) $ \eigvalsRealPtr ->
S.unsafeWith (symmHeaderCharactersImag x) $ \eigvalsImagPtr ->
poke ptr $
Cpermutation_group
{ cpermutation_group_refcount = 0,
cpermutation_group_number_bits = fromIntegral numberBits,
cpermutation_group_number_shifts = fromIntegral numberShifts,
cpermutation_group_number_masks = fromIntegral numberMasks,
cpermutation_group_masks = masksPtr,
cpermutation_group_shifts = shiftsPtr,
cpermutation_group_eigvals_re = (castPtr :: Ptr Double -> Ptr CDouble) eigvalsRealPtr,
cpermutation_group_eigvals_im = (castPtr :: Ptr Double -> Ptr CDouble) eigvalsImagPtr
}
pure $ Symmetries x fp
{-# NOINLINE symmetriesFromHeader #-}
symmetryFromSpec :: SymmetrySpec -> Symmetry
symmetryFromSpec (SymmetrySpec p k) =
mkSymmetry (mkPermutation (G.fromList (toList p))) k
symmetriesFromSpec :: [SymmetrySpec] -> Symmetries
symmetriesFromSpec = mkSymmetries . fmap symmetryFromSpec
|
function [ t, rank ] = subset_lex_successor ( n, t, rank )
%*****************************************************************************80
%
%% SUBSET_LEX_SUCCESSOR computes the subset lexicographic successor.
%
% Discussion:
%
% In the original code, there is a last element with no successor.
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 25 January 2011
%
% Author:
%
% John Burkardt
%
% Reference:
%
% Donald Kreher, Douglas Simpson,
% Combinatorial Algorithms,
% CRC Press, 1998,
% ISBN: 0-8493-3988-X,
% LC: QA164.K73.
%
% Parameters:
%
% Input, integer N, the number of elements in the master set.
% N must be positive.
%
% Input/output, integer T(N), describes a subset. T(I) is 0 if
% the I-th element of the master set is not in the subset, and is
% 1 if the I-th element is part of the subset.
% On input, T describes a subset.
% On output, T describes the next subset in the ordering.
% If the input T was the last in the ordering, then the output T
% will be the first.
%
% Input/output, integer RANK, the rank.
% If RANK = -1 on input, then the routine understands that this is
% the first call, and that the user wishes the routine to supply
% the first element in the ordering, which has RANK = 0.
% In general, the input value of RANK is increased by 1 for output,
% unless the very last element of the ordering was input, in which
% case the output value of RANK is 0.
%
%
% Return the first element.
%
if ( rank == -1 )
t(1:n) = 0;
rank = 0;
return
end
%
% Check.
%
subset_check ( n, t );
for i = n : -1 : 1
if ( t(i) == 0 )
t(i) = 1;
rank = rank + 1;
return
else
t(i) = 0;
end
end
rank = 0;
return
end
|
plus_commutes_Z : (m : Nat) -> m = plus m Z
plus_commutes_Z Z = Refl
plus_commutes_Z (S k)
= let rec = plus_commutes_Z k in
rewrite sym rec in Refl
plus_commutes_S : (k : Nat) -> (m : Nat) -> S (plus m k) = plus m (S k)
plus_commutes_S k Z = Refl
plus_commutes_S k (S j)
= rewrite plus_commutes_S k j in Refl
total
plus_commutes : (n : Nat) -> (m : Nat) -> n + m = m + n
plus_commutes Z m = plus_commutes_Z m
plus_commutes (S k) m
= rewrite plus_commutes k m in
plus_commutes_S k m
|
On 27 December 2006 , it was revealed that the Cabinet had approved over half a billion baht worth of funding for a 14 @,@ 000 @-@ man secret anti @-@ protest special operations force , of which General Saprang was Commander . The so @-@ called CNS Special Operations Center , funded with 556 million baht diverted from the Defense Ministry , Police Office , and government emergency reserve fund , had been secretly established by the CNS on 1 December 2006 in order to control protests .
|
(* This file attempts to implement a cycle-accurate emulation of a 6502 processor,
failing only on illegal opcodes.
*)
From Coq Require Import ssreflect BinInt.
From RecordUpdate Require Import RecordSet.
Require Memory. Import Memory(memory).
Require Import Word.
(* Flags *)
Record flags : Set := mk_flags
{ FlagC : bool
; FlagZ : bool
; FlagI : bool
; FlagD : bool
; FlagV : bool
; FlagN : bool
}.
#[global]
Instance set_flags : Settable _ := settable! mk_flags
<FlagC; FlagZ; FlagI; FlagD; FlagV; FlagN>.
Definition byte_of_flags (flags : flags) : word 8 :=
Word.push_low (FlagC flags,
Word.push_low (FlagZ flags,
Word.push_low (FlagI flags,
Word.push_low (FlagD flags,
Word.push_low (true,
Word.push_low (true,
Word.push_low (FlagV flags,
Word.push_low (FlagN flags,
Word.trivial)))))))).
Definition flags_of_byte (w : word 8) : flags :=
let (C, w) := Word.pop_low w in
let (Z, w) := Word.pop_low w in
let (I, w) := Word.pop_low w in
let (D, w) := Word.pop_low w in
let (_, w) := Word.pop_low w in
let (_, w) := Word.pop_low w in
let (V, w) := Word.pop_low w in
let (N, w) := Word.pop_low w in
mk_flags C Z I D V N.
Definition setZN (w : word 8) (f : flags) : flags :=
set FlagZ (fun _ => Word.eqb w (op₀ false)) (set FlagN (fun _ => Word.bit w 7%b) f).
(* Registers *)
Record registers : Set :=
{ RegPC : word 16
; RegA : word 8
; RegX : word 8
; RegY : word 8
; RegS : word 8
; RegP : flags
}.
#[global]
Instance set_registers : Settable _ := settable! Build_registers
<RegPC; RegA; RegX; RegY; RegS; RegP>.
(* Cycles *)
Inductive cycle (T : Type) :=
| read : word 16 -> (word 8 -> T) -> cycle T
| write : word 16 -> word 8 -> T -> cycle T
.
Arguments read {T}.
Arguments write {T}.
Inductive cycles (T : Type) :=
| zero : T -> cycles T
| suc : cycle (cycles T) -> cycles T
.
Arguments zero {T}.
Arguments suc {T}.
Definition cycles_builder (A : Type) : Type :=
forall B, (A -> cycles B) -> cycles B.
(* Addressing Modes *)
(* Citation: Appendix A of
http://archive.6502.org/books/mcs6500_family_hardware_manual.pdf
*)
Inductive addressing_mode : Set :=
| Accumulator
| Immediate
| Implied
| Relative
| Absolute
| ZeroPage
| Indirect
| AbsoluteX
| AbsoluteY
| ZeroPageX
| ZeroPageY
| IndexedIndirect
| IndirectIndexed
.
Notation "f $ x" := (f x) (at level 60, right associativity, only parsing).
(* The first argument should be true if this operation only *reads* memory,
and does not write it. This is necessary because the processor
occasionally takes one fewer cycle in that case.
*)
Definition effective_address (read_only : bool)
(mode : addressing_mode) (r : registers) : cycles_builder (word 16) :=
fun _ continuation => match mode with
| Immediate => continuation (Word.increment 1 (RegPC r))
| Absolute =>
suc $ read (Word.increment 1 $ RegPC r) $ fun lo =>
suc $ read (Word.increment 2 $ RegPC r) $ fun hi =>
continuation $ Word.concat lo hi
| AbsoluteX =>
suc $ read (Word.increment 1 $ RegPC r) $ fun lo =>
suc $ read (Word.increment 2 $ RegPC r) $ fun hi =>
let (lo, carry) := Word.add_with_carry false lo (RegX r) in
if carry || negb read_only
then
suc $ read (Word.concat lo hi) $ fun _ =>
continuation $ Word.concat lo (if carry then Word.increment 1 hi else hi)
else
continuation $ Word.concat lo hi
| AbsoluteY =>
suc $ read (Word.increment 1 $ RegPC r) $ fun lo =>
suc $ read (Word.increment 2 $ RegPC r) $ fun hi =>
let (lo, carry) := Word.add_with_carry false lo (RegY r) in
if carry || negb read_only
then
suc $ read (Word.concat lo hi) $ fun _ =>
continuation $ Word.concat lo (if carry then Word.increment 1 hi else hi)
else
continuation $ Word.concat lo hi
| ZeroPage =>
suc $ read (Word.increment 1 $ RegPC r) $ fun lo =>
continuation $ Word.concat lo (op₀ false)
| ZeroPageX =>
suc $ read (Word.increment 1 $ RegPC r) $ fun lo =>
suc $ read (Word.concat lo (op₀ false)) $ fun _ =>
continuation $ Word.concat (Word.add lo (RegX r)) (op₀ false)
| ZeroPageY =>
suc $ read (Word.increment 1 $ RegPC r) $ fun lo =>
suc $ read (Word.concat lo (op₀ false)) $ fun _ =>
continuation $ Word.concat (Word.add lo (RegY r)) (op₀ false)
| IndexedIndirect =>
suc $ read (Word.increment 1 $ RegPC r) $ fun lo =>
suc $ read (Word.concat lo (op₀ false)) $ fun _ =>
let lo := Word.add lo (RegX r) in
suc $ read (Word.concat lo (op₀ false)) $ fun lo' =>
suc $ read (Word.concat (Word.increment 1 lo) (op₀ false)) $ fun hi' =>
continuation $ Word.concat lo' hi'
| IndirectIndexed =>
suc $ read (Word.increment 1 $ RegPC r) $ fun lo =>
suc $ read (Word.concat lo (op₀ false)) $ fun lo' =>
suc $ read (Word.concat (Word.increment 1 lo) (op₀ false)) $ fun hi' =>
let (lo', carry) := Word.add_with_carry false lo' (RegY r) in
if carry || negb read_only
then
suc $ read (Word.concat lo' hi') $ fun _ =>
continuation $ Word.concat lo' (if carry then Word.increment 1 hi' else hi')
else
continuation $ Word.concat lo' hi'
| Indirect =>
suc $ read (Word.increment 1 $ RegPC r) $ fun lo =>
suc $ read (Word.increment 2 $ RegPC r) $ fun hi =>
(* Yes, this behaves weirdly when lo = 0xFF. Yes, that's intended. *)
suc $ read (Word.concat lo hi) $ fun lo' =>
suc $ read (Word.concat (Word.increment 1 lo) hi) $ fun hi' =>
continuation $ Word.concat lo' hi'
| Relative =>
suc $ read (Word.increment 1 (RegPC r)) $ fun offset =>
suc $ read (Word.increment 2 (RegPC r)) $ fun _ =>
let (lo, hi) := Word.split (m := 8) (Word.increment 2 (RegPC r)) in
let (lo, carry) := Word.add_with_carry false lo offset in
let page_change := (
Word.int_of_bit carry -
Word.int_of_bit (Word.bit offset 7%b)
)%Z in
if Z.eqb page_change 0
then
continuation $ Word.concat lo hi
else
suc $ read (Word.concat lo hi) $ fun _ =>
continuation $ Word.concat lo (Word.increment page_change hi)
(* These modes don't really produce addresses, so I'll produce dummy values. *)
| Accumulator =>
suc $ read (Word.increment 1 $ RegPC r) $ fun _ =>
continuation $ op₀ false
| Implied =>
suc $ read (Word.increment 1 $ RegPC r) $ fun _ =>
continuation $ op₀ false
end.
Definition mode_length (mode : addressing_mode) : Z :=
match mode with
| Accumulator => 1
| Immediate => 2
| Implied => 1
| Relative => 2
| Absolute => 3
| AbsoluteX => 3
| AbsoluteY => 3
| ZeroPage => 2
| ZeroPageX => 2
| ZeroPageY => 2
| IndexedIndirect => 2
| IndirectIndexed => 2
| Indirect => 3
end.
Definition inc_pc (mode : addressing_mode) : registers -> registers :=
set RegPC (Word.increment (mode_length mode)).
Definition execute_non_memory_op (f : registers -> registers)
(mode : addressing_mode) (r : registers) : cycles registers :=
suc $ read (Word.increment 1 $ RegPC r) $ fun _ =>
zero $ f (inc_pc mode r).
(* There are no "read accumulator" operations. *)
Definition execute_read_op (f : registers -> word 8 -> registers)
(mode : addressing_mode) (r : registers) : cycles registers :=
effective_address true mode r _ $ fun addr =>
suc $ read addr $ fun w =>
zero $ f (inc_pc mode r) w.
Definition execute_write_op (f : registers -> registers * word 8)
(mode : addressing_mode) (r : registers) : cycles registers :=
effective_address false mode r _ $ fun addr =>
let (r,w) := f (inc_pc mode r) in
suc $ write addr w $
zero $ r.
Definition execute_modify_op (f : registers -> word 8 -> registers * word 8)
(mode : addressing_mode) (r : registers) : cycles registers :=
match mode with
| Accumulator =>
suc $ read (Word.increment 1 (RegPC r)) $ fun _ =>
let (r,w) := f (inc_pc Accumulator r) (RegA r) in
zero $ set RegA (fun _ => w) r
| _ =>
effective_address false mode r _ $ fun addr =>
suc $ read addr $ fun w =>
suc $ write addr w $
let (r,w) := f (inc_pc mode r) w in
suc $ write addr w $
zero $ r
end.
Definition execute_branch (cond : registers -> bool) (r : registers) : cycles registers :=
if cond r
then
effective_address true Relative r _ $ fun addr =>
zero $ set RegPC (fun _ => addr) r
else
suc $ read (Word.increment 1 (RegPC r)) $ fun _ =>
zero $ inc_pc Relative r.
(* Instructions *)
Inductive instruction : Set :=
| ADC : instruction
| AND : instruction
| ASL : instruction
| BCC : instruction
| BCS : instruction
| BEQ : instruction
| BIT : instruction
| BMI : instruction
| BNE : instruction
| BPL : instruction
| BRK : instruction
| BVC : instruction
| BVS : instruction
| CLC : instruction
| CLD : instruction
| CLI : instruction
| CLV : instruction
| CMP : instruction
| CPX : instruction
| CPY : instruction
| DEC : instruction
| DEX : instruction
| DEY : instruction
| EOR : instruction
| INC : instruction
| INX : instruction
| INY : instruction
| JMP : instruction
| JSR : instruction
| LDA : instruction
| LDX : instruction
| LDY : instruction
| LSR : instruction
| NOP : instruction
| ORA : instruction
| PHA : instruction
| PHP : instruction
| PLA : instruction
| PLP : instruction
| ROL : instruction
| ROR : instruction
| RTI : instruction
| RTS : instruction
| SBC : instruction
| SEC : instruction
| SED : instruction
| SEI : instruction
| STA : instruction
| STX : instruction
| STY : instruction
| TAX : instruction
| TAY : instruction
| TSX : instruction
| TXA : instruction
| TXS : instruction
| TYA : instruction
.
Definition run (instruction : instruction) :
addressing_mode -> registers -> cycles registers :=
match instruction with
| NOP => execute_non_memory_op $ fun r => r
| BIT => execute_read_op $ fun r w => set RegP
(fun f =>
set FlagN (fun _ => Word.bit w 7%b) $
set FlagV (fun _ => Word.bit w 6%b) $
set FlagZ (fun _ => Word.eqb (op₂ andb w (RegA r)) (op₀ false)) f)
r
| CMP => execute_read_op $ fun r w =>
let (w , inv_borrow) := Word.sub_with_inv_borrow true (RegA r) w in
set RegP (fun f => set FlagC (fun _ => inv_borrow) $ setZN w f) r
| CPX => execute_read_op $ fun r w =>
let (w , inv_borrow) := Word.sub_with_inv_borrow true (RegX r) w in
set RegP (fun f => set FlagC (fun _ => inv_borrow) $ setZN w f) r
| CPY => execute_read_op $ fun r w =>
let (w , inv_borrow) := Word.sub_with_inv_borrow true (RegY r) w in
set RegP (fun f => set FlagC (fun _ => inv_borrow) $ setZN w f) r
| DEC => execute_modify_op $ fun r w => let w := Word.increment (-1) w in
(set RegP (setZN w) r, w)
| DEX => execute_non_memory_op $ fun r => let w := Word.increment (-1) (RegX r) in
set RegP (setZN w) $ set RegX (fun _ => w) r
| DEY => execute_non_memory_op $ fun r => let w := Word.increment (-1) (RegY r) in
set RegP (setZN w) $ set RegY (fun _ => w) r
| INC => execute_modify_op $ fun r w => let w := Word.increment 1 w in
(set RegP (setZN w) r, w)
| INX => execute_non_memory_op $ fun r => let w := Word.increment 1 (RegX r) in
set RegP (setZN w) $ set RegX (fun _ => w) r
| INY => execute_non_memory_op $ fun r => let w := Word.increment 1 (RegY r) in
set RegP (setZN w) $ set RegY (fun _ => w) r
(* Bitwise Operations *)
| AND => execute_read_op $ fun r w =>
let w := op₂ andb w (RegA r) in
set RegA (fun _ => w) $
set RegP (setZN w) r
| EOR => execute_read_op $ fun r w =>
let w := op₂ xorb w (RegA r) in
set RegA (fun _ => w) $
set RegP (setZN w) r
| ORA => execute_read_op $ fun r w =>
let w := op₂ orb w (RegA r) in
set RegA (fun _ => w) $
set RegP (setZN w) r
| ASL => execute_modify_op $ fun r w =>
let (w , carry) := Word.pop_high (Word.push_low (false, w)) in
(set RegP (fun f => set FlagC (fun _ => carry) $ setZN w f) r, w)
| LSR => execute_modify_op $ fun r w =>
let (carry , w) := Word.pop_low (Word.push_high (w , false)) in
(set RegP (fun f => set FlagC (fun _ => carry) $ setZN w f) r, w)
| ROL => execute_modify_op $ fun r w =>
let (w , carry) := Word.pop_high (Word.push_low (FlagC (RegP r), w)) in
(set RegP (fun f => set FlagC (fun _ => carry) $ setZN w f) r, w)
| ROR => execute_modify_op $ fun r w =>
let (carry , w) := Word.pop_low (Word.push_high (w , FlagC (RegP r))) in
(set RegP (fun f => set FlagC (fun _ => carry) $ setZN w f) r, w)
(* Moving Data Around *)
| LDA => execute_read_op $ fun r w => set RegP (setZN w) $ set RegA (fun _ => w) r
| LDX => execute_read_op $ fun r w => set RegP (setZN w) $ set RegX (fun _ => w) r
| LDY => execute_read_op $ fun r w => set RegP (setZN w) $ set RegY (fun _ => w) r
| STA => execute_write_op $ fun r => (r , RegA r)
| STX => execute_write_op $ fun r => (r , RegX r)
| STY => execute_write_op $ fun r => (r , RegY r)
| TAX => execute_non_memory_op $ fun r =>
set RegP (setZN (RegA r)) $ set RegX (fun _ => RegA r) r
| TAY => execute_non_memory_op $ fun r =>
set RegP (setZN (RegA r)) $ set RegY (fun _ => RegA r) r
| TSX => execute_non_memory_op $ fun r =>
set RegP (setZN (RegS r)) $ set RegX (fun _ => RegS r) r
| TXA => execute_non_memory_op $ fun r =>
set RegP (setZN (RegX r)) $ set RegA (fun _ => RegX r) r
| TXS => execute_non_memory_op $ fun r =>
set RegP (setZN (RegX r)) $ set RegS (fun _ => RegX r) r
| TYA => execute_non_memory_op $ fun r =>
set RegP (setZN (RegY r)) $ set RegA (fun _ => RegY r) r
(* Flags *)
| CLC => execute_non_memory_op $ set RegP $ set FlagC $ fun _ => false
| CLD => execute_non_memory_op $ set RegP $ set FlagD $ fun _ => false
| CLI => execute_non_memory_op $ set RegP $ set FlagI $ fun _ => false
| CLV => execute_non_memory_op $ set RegP $ set FlagV $ fun _ => false
| SEC => execute_non_memory_op $ set RegP $ set FlagC $ fun _ => true
| SED => execute_non_memory_op $ set RegP $ set FlagD $ fun _ => true
| SEI => execute_non_memory_op $ set RegP $ set FlagI $ fun _ => true
(* Branch and Jump *)
| BCS => fun _ => execute_branch $ fun r => (FlagC (RegP r))
| BCC => fun _ => execute_branch $ fun r => negb (FlagC (RegP r))
| BEQ => fun _ => execute_branch $ fun r => (FlagZ (RegP r))
| BNE => fun _ => execute_branch $ fun r => negb (FlagZ (RegP r))
| BVS => fun _ => execute_branch $ fun r => (FlagV (RegP r))
| BVC => fun _ => execute_branch $ fun r => negb (FlagV (RegP r))
| BMI => fun _ => execute_branch $ fun r => (FlagN (RegP r))
| BPL => fun _ => execute_branch $ fun r => negb (FlagN (RegP r))
| JMP => fun mode r => effective_address true mode r _ $ fun addr =>
zero $ set RegPC (fun _ => addr) r
(* Addition and Subtraction *)
| ADC => execute_read_op $ fun r num1 =>
let num0 := RegA r in
let (binary_sum, binary_carry) :=
Word.add_with_carry (FlagC (RegP r)) num0 num1 in
if FlagD (RegP r)
then
let (lo0, hi0) := Word.split (m := 4) num0 in
let (lo1, hi1) := Word.split (m := 4) num1 in
let (lo, carry_mid) := Word.add_with_carry (FlagC (RegP r)) lo0 lo1 in
let (lo_minus_10, no_decimal_carry) :=
Word.sub_with_inv_borrow true lo (word_of_int 10) in
let (lo, carry_mid) :=
if no_decimal_carry
then (lo, carry_mid)
else (lo_minus_10, true) in
let (hi, carry_out) := Word.add_with_carry carry_mid hi0 hi1 in
let (hi_minus_10, no_decimal_carry) :=
Word.sub_with_inv_borrow true hi (word_of_int 10) in
let (hi, carry_out) :=
if no_decimal_carry
then (hi, carry_out)
else (hi_minus_10, true) in
set RegA (fun _ => Word.concat lo hi) $
set RegP
(fun f =>
set FlagC (fun _ => carry_out) $
set FlagZ (fun _ => Word.eqb binary_sum (op₀ false)) $
set FlagN (fun _ => Word.bit hi 3%b) $
set FlagV
(fun _ =>
Word.bit hi0 3%b
&& Word.bit hi1 3%b
&& negb (Word.bit hi 3%b)
|| negb (Word.bit hi0 3%b)
&& negb (Word.bit hi1 3%b)
&& Word.bit hi 3%b
)%bool $
setZN binary_sum f)
r
else
set RegA (fun _ => binary_sum) $
set RegP
(fun f =>
set FlagC (fun _ => binary_carry) $
set FlagV
(fun _ =>
Word.bit num0 7%b
&& Word.bit num1 7%b
&& negb (Word.bit binary_sum 7%b)
|| negb (Word.bit num0 7%b)
&& negb (Word.bit num1 7%b)
&& Word.bit binary_sum 7%b
)%bool $
setZN binary_sum f)
r
| SBC => execute_read_op $ fun r num1 =>
let num0 := RegA r in
let (binary_difference, binary_inv_borrow) :=
Word.sub_with_inv_borrow (FlagC (RegP r)) num0 num1 in
let r := set RegP
(fun f =>
set FlagC (fun _ => binary_inv_borrow) $
set FlagV (fun _ =>
Word.bit num0 7%b
&& negb (Word.bit num1 7%b)
&& negb (Word.bit binary_difference 7%b)
|| negb (Word.bit num0 7%b)
&& Word.bit num1 7%b
&& Word.bit binary_difference 7%b
)%bool $
setZN binary_difference f)
r in
if FlagD (RegP r)
then
let (lo0, hi0) := Word.split (m := 4) num0 in
let (lo1, hi1) := Word.split (m := 4) num1 in
let (lo, inv_borrow_mid) := Word.sub_with_inv_borrow (FlagC (RegP r)) lo0 lo1 in
let lo := if inv_borrow_mid then lo else Word.increment 10 lo in
let (hi, inv_borrow_out) := Word.sub_with_inv_borrow inv_borrow_mid hi0 hi1 in
let hi := if inv_borrow_out then hi else Word.increment 10 hi in
set RegA (fun _ => Word.concat lo hi) r
else
set RegA (fun _ => binary_difference) r
(* Stack operations *)
| BRK => fun _ r =>
suc $ read (Word.increment 1 (RegPC r)) $ fun _ =>
let (lo, hi) := Word.split (m := 8) (RegPC r) in
suc $ write (Word.concat (RegS r) (word_of_int 1)) hi $
suc $ write (Word.concat (Word.increment (-1) (RegS r)) (word_of_int 1)) lo $
suc $ write (Word.concat (Word.increment (-2) (RegS r)) (word_of_int 1))
(byte_of_flags (RegP r)) $
suc $ read (word_of_int 0xfffe) $ fun lo =>
suc $ read (word_of_int 0xffff) $ fun hi =>
zero $
set RegS (Word.increment (-3)) $
set RegP (set FlagI (fun _ => true)) $
set RegPC (fun _ => Word.concat lo hi) r
| JSR => fun _ r =>
suc $ read (Word.increment 1 (RegPC r)) $ fun lo' =>
let (lo, hi) := Word.split (m := 8) (Word.increment 2 (RegPC r)) in
suc $ read (Word.concat (RegS r) (word_of_int 1)) $ fun _ =>
suc $ write (Word.concat (RegS r) (word_of_int 1)) hi $
suc $ write (Word.concat (Word.increment (-1) (RegS r)) (word_of_int 1)) lo $
suc $ read (Word.increment 2 (RegPC r)) $ fun hi' =>
zero $
set RegS (Word.increment (-2)) $
set RegPC (fun _ => Word.concat lo' hi') r
| PHA => fun _ r =>
suc $ read (Word.increment 1 (RegPC r)) $ fun _ =>
suc $ write (Word.concat (RegS r) (word_of_int 1)) (RegA r) $
zero $
set RegS (Word.increment (-1)) $
set RegPC (Word.increment 1) r
| PHP => fun _ r =>
suc $ read (Word.increment 1 (RegPC r)) $ fun _ =>
suc $ write (Word.concat (RegS r) (word_of_int 1)) (byte_of_flags (RegP r)) $
zero $
set RegS (Word.increment (-1)) $
set RegPC (Word.increment 1) r
| PLA => fun _ r =>
suc $ read (Word.increment 1 (RegPC r)) $ fun _ =>
suc $ read (Word.concat (RegS r) (word_of_int 1)) $ fun _ =>
suc $ read (Word.concat (Word.increment 1 (RegS r)) (word_of_int 1)) $ fun w =>
zero $
set RegS (Word.increment 1) $
set RegA (fun _ => w) $
set RegPC (Word.increment 1) r
| PLP => fun _ r =>
suc $ read (Word.increment 1 (RegPC r)) $ fun _ =>
suc $ read (Word.concat (RegS r) (word_of_int 1)) $ fun _ =>
suc $ read (Word.concat (Word.increment 1 (RegS r)) (word_of_int 1)) $ fun w =>
zero $
set RegS (Word.increment 1) $
set RegP (fun _ => flags_of_byte w) $
set RegPC (Word.increment 1) r
| RTI => fun _ r =>
suc $ read (Word.increment 1 (RegPC r)) $ fun _ =>
suc $ read (Word.concat (RegS r) (word_of_int 1)) $ fun _ =>
suc $ read (Word.concat (Word.increment 1 (RegS r)) (word_of_int 1)) $ fun flags =>
suc $ read (Word.concat (Word.increment 2 (RegS r)) (word_of_int 1)) $ fun lo =>
suc $ read (Word.concat (Word.increment 3 (RegS r)) (word_of_int 1)) $ fun hi =>
suc $ read (Word.concat lo hi) $ fun _ =>
zero $
set RegS (Word.increment 3) $
set RegP (fun _ => flags_of_byte flags) $
set RegPC (fun _ => Word.concat lo hi) r
| RTS => fun _ r =>
suc $ read (Word.increment 1 (RegPC r)) $ fun _ =>
suc $ read (Word.concat (RegS r) (word_of_int 1)) $ fun _ =>
suc $ read (Word.concat (Word.increment 1 (RegS r)) (word_of_int 1)) $ fun lo =>
suc $ read (Word.concat (Word.increment 2 (RegS r)) (word_of_int 1)) $ fun hi =>
suc $ read (Word.concat lo hi) $ fun _ =>
zero $
set RegS (Word.increment 2) $
set RegPC (fun _ => Word.increment 1 (Word.concat lo hi)) r
end.
(* Opcodes *)
Definition opcode_table : memory 8 (option (instruction * addressing_mode)) :=
Eval compute in Memory.new 8 (fun x => x)
(Some (BRK, Implied)) (Some (ORA, IndexedIndirect)) None None
None (Some (ORA, ZeroPage)) (Some (ASL, ZeroPage)) None
(Some (PHP, Implied)) (Some (ORA, Immediate)) (Some (ASL, Accumulator)) None
None (Some (ORA, Absolute)) (Some (ASL, Absolute)) None
(Some (BPL, Relative)) (Some (ORA, IndirectIndexed)) None None
None (Some (ORA, ZeroPageX)) (Some (ASL, ZeroPageX)) None
(Some (CLC, Implied)) (Some (ORA, AbsoluteY)) None None
None (Some (ORA, AbsoluteX)) (Some (ASL, AbsoluteX)) None
(Some (JSR, Absolute)) (Some (AND, IndexedIndirect)) None None
(Some (BIT, ZeroPage)) (Some (AND, ZeroPage)) (Some (ROL, ZeroPage)) None
(Some (PLP, Implied)) (Some (AND, Immediate)) (Some (ROL, Accumulator)) None
(Some (BIT, Absolute)) (Some (AND, Absolute)) (Some (ROL, Absolute)) None
(Some (BMI, Relative)) (Some (AND, IndirectIndexed)) None None
None (Some (AND, ZeroPageX)) (Some (ROL, ZeroPageX)) None
(Some (SEC, Implied)) (Some (AND, AbsoluteY)) None None
None (Some (AND, AbsoluteX)) (Some (ROL, AbsoluteX)) None
(Some (RTI, Implied)) (Some (EOR, IndexedIndirect)) None None
None (Some (EOR, ZeroPage)) (Some (LSR, ZeroPage)) None
(Some (PHA, Implied)) (Some (EOR, Immediate)) (Some (LSR, Accumulator)) None
(Some (JMP, Absolute)) (Some (EOR, Absolute)) (Some (LSR, Absolute)) None
(Some (BVC, Relative)) (Some (EOR, IndirectIndexed)) None None
None (Some (EOR, ZeroPageX)) (Some (LSR, ZeroPageX)) None
(Some (CLI, Implied)) (Some (EOR, AbsoluteY)) None None
None (Some (EOR, AbsoluteX)) (Some (LSR, AbsoluteX)) None
(Some (RTS, Implied)) (Some (ADC, IndexedIndirect)) None None
None (Some (ADC, ZeroPage)) (Some (ROR, ZeroPage)) None
(Some (PLA, Implied)) (Some (ADC, Immediate)) (Some (ROR, Accumulator)) None
(Some (JMP, Indirect)) (Some (ADC, Absolute)) (Some (ROR, AbsoluteX)) None
(Some (BVS, Relative)) (Some (ADC, IndirectIndexed)) None None
None (Some (ADC, ZeroPageX)) (Some (ROR, ZeroPageX)) None
(Some (SEI, Implied)) (Some (ADC, AbsoluteY)) None None
None (Some (ADC, AbsoluteX)) (Some (ROR, Absolute)) None
None (Some (STA, IndexedIndirect)) None None
(Some (STY, ZeroPage)) (Some (STA, ZeroPage)) (Some (STX, ZeroPage)) None
(Some (DEY, Implied)) None (Some (TXA, Implied)) None
(Some (STY, Absolute)) (Some (STA, Absolute)) (Some (STX, Absolute)) None
(Some (BCC, Relative)) (Some (STA, IndirectIndexed)) None None
(Some (STY, ZeroPageX)) (Some (STA, ZeroPageX)) (Some (STX, ZeroPageY)) None
(Some (TYA, Implied)) (Some (STA, AbsoluteY)) (Some (TXS, Implied)) None
None (Some (STA, AbsoluteX)) None None
(Some (LDY, Immediate)) (Some (LDA, IndexedIndirect)) (Some (LDX, Immediate)) None
(Some (LDY, ZeroPage)) (Some (LDA, ZeroPage)) (Some (LDX, ZeroPage)) None
(Some (TAY, Implied)) (Some (LDA, Immediate)) (Some (TAX, Implied)) None
(Some (LDY, Absolute)) (Some (LDA, Absolute)) (Some (LDX, Absolute)) None
(Some (BCS, Relative)) (Some (LDA, IndirectIndexed)) None None
(Some (LDY, ZeroPageX)) (Some (LDA, ZeroPageX)) (Some (LDX, ZeroPageY)) None
(Some (CLV, Implied)) (Some (LDA, AbsoluteY)) (Some (TSX, Implied)) None
(Some (LDY, AbsoluteX)) (Some (LDA, AbsoluteX)) (Some (LDX, AbsoluteY)) None
(Some (CPY, Immediate)) (Some (CMP, IndexedIndirect)) None None
(Some (CPY, ZeroPage)) (Some (CMP, ZeroPage)) (Some (DEC, ZeroPage)) None
(Some (INY, Implied)) (Some (CMP, Immediate)) (Some (DEX, Implied)) None
(Some (CPY, Absolute)) (Some (CMP, Absolute)) (Some (DEC, Absolute)) None
(Some (BNE, Relative)) (Some (CMP, IndirectIndexed)) None None
None (Some (CMP, ZeroPageX)) (Some (DEC, ZeroPageX)) None
(Some (CLD, Implied)) (Some (CMP, AbsoluteY)) None None
None (Some (CMP, AbsoluteX)) (Some (DEC, AbsoluteX)) None
(Some (CPX, Immediate)) (Some (SBC, IndexedIndirect)) None None
(Some (CPX, ZeroPage)) (Some (SBC, ZeroPage)) (Some (INC, ZeroPage)) None
(Some (INX, Implied)) (Some (SBC, Immediate)) (Some (NOP, Implied)) None
(Some (CPX, Absolute)) (Some (SBC, Absolute)) (Some (INC, Absolute)) None
(Some (BEQ, Relative)) (Some (SBC, IndirectIndexed)) None None
None (Some (SBC, ZeroPageX)) (Some (INC, ZeroPageX)) None
(Some (SED, Implied)) (Some (SBC, AbsoluteY)) None None
None (Some (SBC, AbsoluteX)) (Some (INC, AbsoluteX)) None.
Definition parse_opcode (w : word 8) : option (instruction * addressing_mode) :=
Memory.read w opcode_table.
(* Step through a single processor instruction. *)
Definition step (r : registers) : cycle (option (cycles registers)) :=
read (RegPC r) $ fun opcode => option_map
(fun x => run (fst x) (snd x) r)
(parse_opcode opcode).
|
Set Implicit Arguments.
Generalizable All Variables.
Set Asymmetric Patterns.
Set Universe Polymorphism.
Set Printing Universes.
Set Printing All.
Record PreCategory :=
{
Object :> Type;
Morphism : Object -> Object -> Type
}.
Inductive paths A (x : A) : A -> Type := idpath : @paths A x x.
Inductive Unit : Prop := tt. (* Changing this to [Set] fixes things *)
Inductive Bool : Set := true | false.
Definition DiscreteCategory X : PreCategory
:= @Build_PreCategory X
(@paths X).
Definition IndiscreteCategory X : PreCategory
:= @Build_PreCategory X
(fun _ _ => Unit).
Check (IndiscreteCategory Unit).
Check (DiscreteCategory Bool).
Definition NatCategory (n : nat) :=
match n with
| 0 => IndiscreteCategory Unit
| _ => DiscreteCategory Bool
end. (* Error: Universe inconsistency (cannot enforce Set <= Prop). *)
|
From iris.proofmode Require Import tactics.
From iris_named_props Require Import named_props.
Set Default Proof Using "All".
Section tests.
Context {PROP: bi} {Haffine: BiAffine PROP}.
Implicit Types (P Q R : PROP).
Lemma demo_split_manual P Q R :
"HP" ∷ P ∗
"HQ" ∷ Q ∗
"HP_to_R" ∷ (P -∗ R) -∗
R ∗ Q.
Proof.
iNamed 1.
iSplitL "HP HP_to_R".
- iApply ("HP_to_R" with "HP").
- iExact "HQ".
Qed.
Lemma demo_split_delay P Q R :
"HP" ∷ P ∗
"HQ" ∷ Q ∗
"HP_to_R" ∷ (P -∗ R) -∗
R ∗ Q.
Proof.
iNamed 1.
iSplitDelay.
- iSpecialize ("HP_to_R" with "HP").
iFrame.
Show.
rewrite left_id. (* TODO: this is an annoyance *)
iNamedAccu.
- iNamed 1.
Show.
iExact "HQ".
Qed.
End tests.
|
STMicroelectronics, a semiconductor company, and Mayo Clinic, a health-care organization, are collaborating on a novel platform for remotely monitoring patients with chronic cardiovascular disease. The companies claims that the platform will provide a comprehensive and unobtrusive solution that monitors person-specific data and physiological parameters and influences lifestyle and treatment choices.
Telemedicine, which allows medical professionals to monitor or treat patients even when they are not in the same location, is widely recognized as an essential step in reducing the escalating cost of healthcare. Instead of entering a hospital or visiting a doctor for check-ups, the patient wears a small device that continually monitors a number of relevant physiological parameters. This approach has many potential benefits, including maintaining wellness, earlier detection of developing health conditions, improving lifestyle, and lowering healthcare costs.
“Mayo Clinic has always committed the best available resources to caring for patients with cardiovascular disease. This collaboration, by enhancing our ability to record important physiologic information while patients are outside the medical environment and active in their daily lives, will extend our ability to prevent and treat illness,” said Paul Friedman, M.D., a cardiology consultant and specialist in cardiovascular electrophysiology at Mayo Clinic, who added that an initial program of patient trials is already underway.
This platform is the result of an R&D collaboration that combines STMicroelectronics’s expertise in developing innovative solutions using its advanced sensor, microprocessor and communication products and Mayo Clinic’s best-in-class medical expertise. It uses a combination of sensors, ultra-low-power microcontroller and wireless modules, and interfaces to provide information about the patient’s heart rate, breathing rate, physical activity and other measurements wirelessly obtained from external medical devices. |
\ Show if a device with address 'dev' is present on the I2C-bus
: I2C? ( dev -- )
i2c-on device! {device-ok?}
0= if ." Not " then ." Present " ;
\ End ;;;
|
[STATEMENT]
lemma subst_term_preserves_term_ok[simp]:
"term_ok \<Theta> (subst_term [((x, \<tau>), Fv y \<tau>)] A) \<longleftrightarrow> term_ok \<Theta> A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. term_ok \<Theta> (subst_term [((x, \<tau>), Fv y \<tau>)] A) = term_ok \<Theta> A
[PROOF STEP]
by (simp add: wt_term_def) |
/*
Copyright (c) 2005-2021, University of Oxford.
All rights reserved.
University of Oxford means the Chancellor, Masters and Scholars of the
University of Oxford, having an administrative office at Wellington
Square, Oxford OX1 2JD, UK.
This file is part of Chaste.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the University of Oxford nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TESTTOROIDALHONEYCOMBVERTEXMESHGENERATOR_HPP_
#define TESTTOROIDALHONEYCOMBVERTEXMESHGENERATOR_HPP_
#include <cxxtest/TestSuite.h>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include "ToroidalHoneycombVertexMeshGenerator.hpp"
#include "FileComparison.hpp"
//This test is always run sequentially (never in parallel)
#include "FakePetscSetup.hpp"
class TestToroidalHoneycombVertexMeshGenerator : public CxxTest::TestSuite
{
public:
void TestToroidal2dVertexMeshGenerator()
{
ToroidalHoneycombVertexMeshGenerator generator(4, 4);
// Coverage
TS_ASSERT_THROWS_THIS(generator.GetMesh(),
"A toroidal mesh was created but a normal mesh is being requested.");
// Create periodic mesh
Toroidal2dVertexMesh* p_mesh = generator.GetToroidalMesh();
// Test that the mesh has the correct numbers of nodes and elements
TS_ASSERT_EQUALS(p_mesh->GetNumElements(), 16u);
TS_ASSERT_EQUALS(p_mesh->GetNumNodes(), 32u);
// Test that some elements own the correct nodes
VertexElement<2,2>* p_element0 = p_mesh->GetElement(0);
TS_ASSERT_EQUALS(p_element0->GetNumNodes(), 6u);
TS_ASSERT_EQUALS(p_element0->GetNodeGlobalIndex(0), 0u);
TS_ASSERT_EQUALS(p_element0->GetNodeGlobalIndex(1), 5u);
TS_ASSERT_EQUALS(p_element0->GetNodeGlobalIndex(2), 9u);
TS_ASSERT_EQUALS(p_element0->GetNodeGlobalIndex(3), 12u);
TS_ASSERT_EQUALS(p_element0->GetNodeGlobalIndex(4), 8u);
TS_ASSERT_EQUALS(p_element0->GetNodeGlobalIndex(5), 4u);
VertexElement<2,2>* p_element5 = p_mesh->GetElement(5);
TS_ASSERT_EQUALS(p_element5->GetNumNodes(), 6u);
TS_ASSERT_EQUALS(p_element5->GetNodeGlobalIndex(0), 10u);
TS_ASSERT_EQUALS(p_element5->GetNodeGlobalIndex(1), 14u);
TS_ASSERT_EQUALS(p_element5->GetNodeGlobalIndex(2), 18u);
TS_ASSERT_EQUALS(p_element5->GetNodeGlobalIndex(3), 22u);
TS_ASSERT_EQUALS(p_element5->GetNodeGlobalIndex(4), 17u);
TS_ASSERT_EQUALS(p_element5->GetNodeGlobalIndex(5), 13u);
VertexElement<2,2>* p_element7 = p_mesh->GetElement(7);
TS_ASSERT_EQUALS(p_element7->GetNumNodes(), 6u);
TS_ASSERT_EQUALS(p_element7->GetNodeGlobalIndex(0), 8u);
TS_ASSERT_EQUALS(p_element7->GetNodeGlobalIndex(1), 12u);
TS_ASSERT_EQUALS(p_element7->GetNodeGlobalIndex(2), 16u);
TS_ASSERT_EQUALS(p_element7->GetNodeGlobalIndex(3), 20u);
TS_ASSERT_EQUALS(p_element7->GetNodeGlobalIndex(4), 19u);
TS_ASSERT_EQUALS(p_element7->GetNodeGlobalIndex(5), 15u);
VertexElement<2,2>* p_element12 = p_mesh->GetElement(12);
TS_ASSERT_EQUALS(p_element12->GetNumNodes(), 6u);
TS_ASSERT_EQUALS(p_element12->GetNodeGlobalIndex(0), 25u);
TS_ASSERT_EQUALS(p_element12->GetNodeGlobalIndex(1), 29u);
TS_ASSERT_EQUALS(p_element12->GetNodeGlobalIndex(2), 1u);
TS_ASSERT_EQUALS(p_element12->GetNodeGlobalIndex(3), 5u);
TS_ASSERT_EQUALS(p_element12->GetNodeGlobalIndex(4), 0u);
TS_ASSERT_EQUALS(p_element12->GetNodeGlobalIndex(5), 28u);
VertexElement<2,2>* p_element15 = p_mesh->GetElement(15);
TS_ASSERT_EQUALS(p_element15->GetNumNodes(), 6u);
TS_ASSERT_EQUALS(p_element15->GetNodeGlobalIndex(0), 24u);
TS_ASSERT_EQUALS(p_element15->GetNodeGlobalIndex(1), 28u);
TS_ASSERT_EQUALS(p_element15->GetNodeGlobalIndex(2), 0u);
TS_ASSERT_EQUALS(p_element15->GetNodeGlobalIndex(3), 4u);
TS_ASSERT_EQUALS(p_element15->GetNodeGlobalIndex(4), 3u);
TS_ASSERT_EQUALS(p_element15->GetNodeGlobalIndex(5), 31u);
// Create a vertex mesh writer with toroidal mesh
VertexMeshWriter<2,2> vertex_mesh_writer_1("TestToroidal2dVertexMesh", "toroidal_vertex_mesh");
vertex_mesh_writer_1.WriteFilesUsingMesh(*p_mesh);
OutputFileHandler handler_1("TestToroidal2dVertexMesh", false);
std::string results_file1 = handler_1.GetOutputDirectoryFullPath() + "toroidal_vertex_mesh.node";
std::string results_file2 = handler_1.GetOutputDirectoryFullPath() + "toroidal_vertex_mesh.cell";
{
FileComparison comparer(results_file1, "mesh/test/data/TestToroidal2dVertexMesh/toroidal_vertex_mesh.node");
TS_ASSERT(comparer.CompareFiles());
}
{
FileComparison comparer(results_file2, "mesh/test/data/TestToroidal2dVertexMesh/toroidal_vertex_mesh.cell");
TS_ASSERT(comparer.CompareFiles());
}
}
};
#endif /*TESTTOROIDALHONEYCOMBVERTEXMESHGENERATOR_HPP_*/
|
{-# OPTIONS --no-unicode #-}
data Two : Set where
tt ff : Two
data Foo : Set where
foo : Foo -> Foo -> Foo
test1 : Foo → Two
test1 x₀ = {!!}
test : Foo -> Foo → Two
test x1 = {!!}
|
[STATEMENT]
lemma mset_subset_add_mset [simp]: "add_mset x N \<subset># add_mset x M \<longleftrightarrow> N \<subset># M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (add_mset x N \<subset># add_mset x M) = (N \<subset># M)
[PROOF STEP]
unfolding add_mset_add_single[of _ N] add_mset_add_single[of _ M]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (N + {#x#} \<subset># M + {#x#}) = (N \<subset># M)
[PROOF STEP]
by (fact subset_mset.add_less_cancel_right) |
/-
Theorems/Examples from Fuichi, Uchida "Shugo to Iso" (2020).
-/
universes u v
-- What's the difference between:
-- Sort, Sort*, Type, Type* ?
variables {A B C W X Y Z α β: Sort*}
--def injective {X Y} (f : X → Y) : Prop :=
-- ∀ ⦃ x₁ x₂ ⦄, f x₁ = f x₂ → x₁ = x₂
def injective (f: X → Y) : Prop :=
∀ ⦃ x₁ x₂ ⦄ , f x₁ = f x₂ → x₁ = x₂
--@[reducible] def injective (f : α → β) : Prop :=
--∀ ⦃a₁ a₂⦄, f a₁ = f a₂ → a₁ = a₂
def surjective (f: X → Y) : Prop :=
∀ y, ∃ x, f x = y
theorem injective_id : injective(@id X) :=
assume x₁ x₂,
assume h1: id x₁ = id x₂,
show x₁ = x₂, from h1
--theorem injective_comp {f: X → Y} {g: Y→ Z}
--(hg: injective f) (hg: injective g) :
--injective (g ∘ f) :=
--sorry
/--
Theorem 6.1:
Let f: A → B, g : B → A,
f ∘ g = id B → surgective f ∧ injective g.
-/
theorem id_comp_surj
{f: A → B} {g: B → A} :
f ∘ g = @id B → surjective f :=
assume h1: f ∘ g = @id B,
assume b₁ : B,
-- congr_fun is a congruence rule for the simplifier, see:
-- https://leanprover.github.io/theorem_proving_in_lean/quantifiers_and_equality.html#equality
have h2: f (g b₁) = id b₁, from congr_fun h1 b₁,
let a := g b₁ in
show ∃ a, f(a) = b₁, from exists.intro a h2
/-
let a := g b₁ in
show ∃ a, f(a) = b₁, from exists.intro a h2
-/
theorem id_comp_injective
{f: A → B} {g: B → A} :
f ∘ g = @id B → injective g :=
assume h1: f ∘ g = @id B,
assume b₁ b₂ : B,
assume h2: g b₁ = g b₂,
have h3: f (g b₁) = f (g b₂), from congr_arg f h2,
have h4: f (g b₁) = id b₁, from congr_fun h1 b₁,
have h5: f (g b₂) = id b₂, from congr_fun h1 b₂,
have h6: id b₁ = f (g b₂), from eq.subst h4 h3,
have h7: id b₁ = id b₂, from eq.subst h5 h6,
show b₁ = b₂, from h7
--have id b₁ = f (g b₂), by rw [←h3, h4],
--by rw [←h3,h4,←h5],
--show b₁ = b₂, by rewrite [h5,h4,h3]
/-
Exercise 6.2
Let f: A→B, g: B→C
(1) If g ∘ f is injective, f is injective
(2) If g ∘ f is surjective, g is surjective
-/
-- (1)
theorem comp_injective_1st
{f: A → B} {g: B → C} :
injective (g ∘ f) → injective f :=
assume h1: injective (g ∘ f),
assume a₁ a₂ : A,
assume h4: f a₁ = f a₂,
-- We can not say the following equality on the image of the function g
-- unless using congr_arg.
-- have h5: g (f a₁) = g (f a₂), from h4,
have h5: g (f a₁) = g (f a₂), from congr_arg g h4,
show a₁ = a₂, from h1 h5
--(2) can not prove with this
theorem can_not_prove_comp_surjective_2nd
{f: A → B} {g: B → C} :
surjective(g ∘ f) → surjective g :=
assume h1: surjective (g ∘ f),
have h2: ∀c:C, ∃a:A, g (f a) = c, from h1,
assume a : A,
let b := f a in
show ∀c:C, ∃b:B, g (b) = c, from exists.intro b h2
--(2)
theorem comp_surjective_2nd
{f: A → B} {g: B → C} :
surjective(g ∘ f) → surjective g :=
assume h1: surjective (g ∘ f),
-- can not exists.elim for
-- ∀c:C,∃a:A, g(f a) = c, from h1
assume c:C,
have h2: ∃a:A, g (f a) = c, from h1 c,
-- exists.elim for ∃a:A
exists.elim h2 (
assume a₁: A,
assume h: g (f a₁) = c,
let b := f a₁ in
show ∃b:B, g(b) = c, from exists.intro b h
)
--show ∀c:C, ∃b:B, g(b) = c, from h3
-- have h3: ∀c:C,
--have h3: ∀a:A, ∃b:B, f(a) = b, by rfl,
--assume a : A,
--let b := f a in
--show ∀c:C, ∃b:B, g (b) = c, from exists.intro b h2
/-
exists.elim h2
(assume a₁,
assume ha: ∀c, g (f a₁) = c,
let b := f a₁ in
show ∀c, ∃b, g (b) = c, from exists.intro b ha)
-/
|
(* Exercise 25 *)
Require Import BenB.
Variable D : Set.
Variables P Q S T : D -> Prop.
Variable R : D -> D -> Prop.
Theorem exercise_025 : ~(forall x, P x /\ Q x) /\ (forall x, P x) -> ~(forall x, Q x).
Proof.
imp_i a1.
neg_i (forall x:D, P x /\ Q x) a2.
con_e1 (forall x:D, P x).
hyp a1.
all_i a.
con_i.
all_e (forall x:D, P x) a.
con_e2 (~(forall x:D, P x /\ Q x)).
hyp a1.
all_e (forall x:D, Q x) a.
hyp a2.
Qed. |
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
R₁ : Type u_4
inst✝³ : CommRing R₁
inst✝² : IsDomain R₁
inst✝¹ : Algebra R₁ K
inst✝ : IsFractionRing R₁ K
I J✝ J : FractionalIdeal R₁⁰ K
h : J ≠ 0
⊢ ↑J⁻¹ = IsLocalization.coeSubmodule K ⊤ / ↑J
[PROOFSTEP]
rw [inv_nonzero]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
R₁ : Type u_4
inst✝³ : CommRing R₁
inst✝² : IsDomain R₁
inst✝¹ : Algebra R₁ K
inst✝ : IsFractionRing R₁ K
I J✝ J : FractionalIdeal R₁⁰ K
h : J ≠ 0
⊢ ↑{ val := ↑1 / ↑J, property := (_ : IsFractional R₁⁰ (↑1 / ↑J)) } = IsLocalization.coeSubmodule K ⊤ / ↑J
case h
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
R₁ : Type u_4
inst✝³ : CommRing R₁
inst✝² : IsDomain R₁
inst✝¹ : Algebra R₁ K
inst✝ : IsFractionRing R₁ K
I J✝ J : FractionalIdeal R₁⁰ K
h : J ≠ 0
⊢ J ≠ 0
[PROOFSTEP]
rfl
[GOAL]
case h
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
R₁ : Type u_4
inst✝³ : CommRing R₁
inst✝² : IsDomain R₁
inst✝¹ : Algebra R₁ K
inst✝ : IsFractionRing R₁ K
I J✝ J : FractionalIdeal R₁⁰ K
h : J ≠ 0
⊢ J ≠ 0
[PROOFSTEP]
assumption
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
R₁ : Type u_4
inst✝³ : CommRing R₁
inst✝² : IsDomain R₁
inst✝¹ : Algebra R₁ K
inst✝ : IsFractionRing R₁ K
I J : FractionalIdeal R₁⁰ K
hI : I ≠ 0
hJ : J ≠ 0
hIJ : I ≤ J
⊢ J⁻¹ ≤ I⁻¹
[PROOFSTEP]
intro x
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
R₁ : Type u_4
inst✝³ : CommRing R₁
inst✝² : IsDomain R₁
inst✝¹ : Algebra R₁ K
inst✝ : IsFractionRing R₁ K
I J : FractionalIdeal R₁⁰ K
hI : I ≠ 0
hJ : J ≠ 0
hIJ : I ≤ J
x : K
⊢ x ∈ (fun a => ↑a) J⁻¹ → x ∈ (fun a => ↑a) I⁻¹
[PROOFSTEP]
simp only [val_eq_coe, mem_coe, mem_inv_iff hJ, mem_inv_iff hI]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
R₁ : Type u_4
inst✝³ : CommRing R₁
inst✝² : IsDomain R₁
inst✝¹ : Algebra R₁ K
inst✝ : IsFractionRing R₁ K
I J : FractionalIdeal R₁⁰ K
hI : I ≠ 0
hJ : J ≠ 0
hIJ : I ≤ J
x : K
⊢ (∀ (y : K), y ∈ J → x * y ∈ 1) → ∀ (y : K), y ∈ I → x * y ∈ 1
[PROOFSTEP]
exact fun h y hy => h y (hIJ hy)
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
R₁ : Type u_4
inst✝³ : CommRing R₁
inst✝² : IsDomain R₁
inst✝¹ : Algebra R₁ K
inst✝ : IsFractionRing R₁ K
I✝ J✝ I J : FractionalIdeal R₁⁰ K
h : I * J = 1
⊢ J = I⁻¹
[PROOFSTEP]
have hI : I ≠ 0 := ne_zero_of_mul_eq_one I J h
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
R₁ : Type u_4
inst✝³ : CommRing R₁
inst✝² : IsDomain R₁
inst✝¹ : Algebra R₁ K
inst✝ : IsFractionRing R₁ K
I✝ J✝ I J : FractionalIdeal R₁⁰ K
h : I * J = 1
hI : I ≠ 0
⊢ J = I⁻¹
[PROOFSTEP]
suffices h' : I * (1 / I) = 1
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
R₁ : Type u_4
inst✝³ : CommRing R₁
inst✝² : IsDomain R₁
inst✝¹ : Algebra R₁ K
inst✝ : IsFractionRing R₁ K
I✝ J✝ I J : FractionalIdeal R₁⁰ K
h : I * J = 1
hI : I ≠ 0
h' : I * (1 / I) = 1
⊢ J = I⁻¹
[PROOFSTEP]
exact congr_arg Units.inv <| @Units.ext _ _ (Units.mkOfMulEqOne _ _ h) (Units.mkOfMulEqOne _ _ h') rfl
[GOAL]
case h'
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
R₁ : Type u_4
inst✝³ : CommRing R₁
inst✝² : IsDomain R₁
inst✝¹ : Algebra R₁ K
inst✝ : IsFractionRing R₁ K
I✝ J✝ I J : FractionalIdeal R₁⁰ K
h : I * J = 1
hI : I ≠ 0
⊢ I * (1 / I) = 1
[PROOFSTEP]
apply le_antisymm
[GOAL]
case h'.a
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
R₁ : Type u_4
inst✝³ : CommRing R₁
inst✝² : IsDomain R₁
inst✝¹ : Algebra R₁ K
inst✝ : IsFractionRing R₁ K
I✝ J✝ I J : FractionalIdeal R₁⁰ K
h : I * J = 1
hI : I ≠ 0
⊢ I * (1 / I) ≤ 1
[PROOFSTEP]
apply mul_le.mpr _
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
R₁ : Type u_4
inst✝³ : CommRing R₁
inst✝² : IsDomain R₁
inst✝¹ : Algebra R₁ K
inst✝ : IsFractionRing R₁ K
I✝ J✝ I J : FractionalIdeal R₁⁰ K
h : I * J = 1
hI : I ≠ 0
⊢ ∀ (i : K), i ∈ I → ∀ (j : K), j ∈ 1 / I → i * j ∈ 1
[PROOFSTEP]
intro x hx y hy
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
R₁ : Type u_4
inst✝³ : CommRing R₁
inst✝² : IsDomain R₁
inst✝¹ : Algebra R₁ K
inst✝ : IsFractionRing R₁ K
I✝ J✝ I J : FractionalIdeal R₁⁰ K
h : I * J = 1
hI : I ≠ 0
x : K
hx : x ∈ I
y : K
hy : y ∈ 1 / I
⊢ x * y ∈ 1
[PROOFSTEP]
rw [mul_comm]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
R₁ : Type u_4
inst✝³ : CommRing R₁
inst✝² : IsDomain R₁
inst✝¹ : Algebra R₁ K
inst✝ : IsFractionRing R₁ K
I✝ J✝ I J : FractionalIdeal R₁⁰ K
h : I * J = 1
hI : I ≠ 0
x : K
hx : x ∈ I
y : K
hy : y ∈ 1 / I
⊢ y * x ∈ 1
[PROOFSTEP]
exact (mem_div_iff_of_nonzero hI).mp hy x hx
[GOAL]
case h'.a
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
R₁ : Type u_4
inst✝³ : CommRing R₁
inst✝² : IsDomain R₁
inst✝¹ : Algebra R₁ K
inst✝ : IsFractionRing R₁ K
I✝ J✝ I J : FractionalIdeal R₁⁰ K
h : I * J = 1
hI : I ≠ 0
⊢ 1 ≤ I * (1 / I)
[PROOFSTEP]
rw [← h]
[GOAL]
case h'.a
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
R₁ : Type u_4
inst✝³ : CommRing R₁
inst✝² : IsDomain R₁
inst✝¹ : Algebra R₁ K
inst✝ : IsFractionRing R₁ K
I✝ J✝ I J : FractionalIdeal R₁⁰ K
h : I * J = 1
hI : I ≠ 0
⊢ I * J ≤ I * (I * J / I)
[PROOFSTEP]
apply mul_left_mono I
[GOAL]
case h'.a.a
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
R₁ : Type u_4
inst✝³ : CommRing R₁
inst✝² : IsDomain R₁
inst✝¹ : Algebra R₁ K
inst✝ : IsFractionRing R₁ K
I✝ J✝ I J : FractionalIdeal R₁⁰ K
h : I * J = 1
hI : I ≠ 0
⊢ J ≤ I * J / I
[PROOFSTEP]
apply (le_div_iff_of_nonzero hI).mpr _
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
R₁ : Type u_4
inst✝³ : CommRing R₁
inst✝² : IsDomain R₁
inst✝¹ : Algebra R₁ K
inst✝ : IsFractionRing R₁ K
I✝ J✝ I J : FractionalIdeal R₁⁰ K
h : I * J = 1
hI : I ≠ 0
⊢ ∀ (x : K), x ∈ J → ∀ (y : K), y ∈ I → x * y ∈ I * J
[PROOFSTEP]
intro y hy x hx
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
R₁ : Type u_4
inst✝³ : CommRing R₁
inst✝² : IsDomain R₁
inst✝¹ : Algebra R₁ K
inst✝ : IsFractionRing R₁ K
I✝ J✝ I J : FractionalIdeal R₁⁰ K
h : I * J = 1
hI : I ≠ 0
y : K
hy : y ∈ J
x : K
hx : x ∈ I
⊢ y * x ∈ I * J
[PROOFSTEP]
rw [mul_comm]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
R₁ : Type u_4
inst✝³ : CommRing R₁
inst✝² : IsDomain R₁
inst✝¹ : Algebra R₁ K
inst✝ : IsFractionRing R₁ K
I✝ J✝ I J : FractionalIdeal R₁⁰ K
h : I * J = 1
hI : I ≠ 0
y : K
hy : y ∈ J
x : K
hx : x ∈ I
⊢ x * y ∈ I * J
[PROOFSTEP]
exact mul_mem_mul hx hy
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
R₁ : Type u_4
inst✝³ : CommRing R₁
inst✝² : IsDomain R₁
inst✝¹ : Algebra R₁ K
inst✝ : IsFractionRing R₁ K
I✝ J✝ I : FractionalIdeal R₁⁰ K
x✝ : ∃ J, I * J = 1
J : FractionalIdeal R₁⁰ K
hJ : I * J = 1
⊢ I * I⁻¹ = 1
[PROOFSTEP]
rwa [← right_inverse_eq K I J hJ]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁰ : CommRing R
inst✝⁹ : CommRing A
inst✝⁸ : Field K
inst✝⁷ : IsDomain A
R₁ : Type u_4
inst✝⁶ : CommRing R₁
inst✝⁵ : IsDomain R₁
inst✝⁴ : Algebra R₁ K
inst✝³ : IsFractionRing R₁ K
I✝ J : FractionalIdeal R₁⁰ K
K' : Type u_5
inst✝² : Field K'
inst✝¹ : Algebra R₁ K'
inst✝ : IsFractionRing R₁ K'
I : FractionalIdeal R₁⁰ K
h : K ≃ₐ[R₁] K'
⊢ map (↑h) I⁻¹ = (map (↑h) I)⁻¹
[PROOFSTEP]
rw [inv_eq, map_div, map_one, inv_eq]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁰ : CommRing R
inst✝⁹ : CommRing A
inst✝⁸ : Field K
inst✝⁷ : IsDomain A
R₁ : Type u_4
inst✝⁶ : CommRing R₁
inst✝⁵ : IsDomain R₁
inst✝⁴ : Algebra R₁ K
inst✝³ : IsFractionRing R₁ K
I J : FractionalIdeal R₁⁰ K
K' : Type u_5
inst✝² : Field K'
inst✝¹ : Algebra R₁ K'
inst✝ : IsFractionRing R₁ K'
x y : K
⊢ spanSingleton R₁⁰ x / spanSingleton R₁⁰ y = spanSingleton R₁⁰ (x / y)
[PROOFSTEP]
rw [div_spanSingleton, mul_comm, spanSingleton_mul_spanSingleton, div_eq_mul_inv]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁰ : CommRing R
inst✝⁹ : CommRing A
inst✝⁸ : Field K
inst✝⁷ : IsDomain A
R₁ : Type u_4
inst✝⁶ : CommRing R₁
inst✝⁵ : IsDomain R₁
inst✝⁴ : Algebra R₁ K
inst✝³ : IsFractionRing R₁ K
I J : FractionalIdeal R₁⁰ K
K' : Type u_5
inst✝² : Field K'
inst✝¹ : Algebra R₁ K'
inst✝ : IsFractionRing R₁ K'
x : K
hx : x ≠ 0
⊢ spanSingleton R₁⁰ x / spanSingleton R₁⁰ x = 1
[PROOFSTEP]
rw [spanSingleton_div_spanSingleton, div_self hx, spanSingleton_one]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁰ : CommRing R
inst✝⁹ : CommRing A
inst✝⁸ : Field K
inst✝⁷ : IsDomain A
R₁ : Type u_4
inst✝⁶ : CommRing R₁
inst✝⁵ : IsDomain R₁
inst✝⁴ : Algebra R₁ K
inst✝³ : IsFractionRing R₁ K
I J : FractionalIdeal R₁⁰ K
K' : Type u_5
inst✝² : Field K'
inst✝¹ : Algebra R₁ K'
inst✝ : IsFractionRing R₁ K'
x : R₁
hx : x ≠ 0
⊢ ↑(Ideal.span {x}) / ↑(Ideal.span {x}) = 1
[PROOFSTEP]
rw [coeIdeal_span_singleton,
spanSingleton_div_self K <| (map_ne_zero_iff _ <| NoZeroSMulDivisors.algebraMap_injective R₁ K).mpr hx]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁰ : CommRing R
inst✝⁹ : CommRing A
inst✝⁸ : Field K
inst✝⁷ : IsDomain A
R₁ : Type u_4
inst✝⁶ : CommRing R₁
inst✝⁵ : IsDomain R₁
inst✝⁴ : Algebra R₁ K
inst✝³ : IsFractionRing R₁ K
I J : FractionalIdeal R₁⁰ K
K' : Type u_5
inst✝² : Field K'
inst✝¹ : Algebra R₁ K'
inst✝ : IsFractionRing R₁ K'
x : K
hx : x ≠ 0
⊢ spanSingleton R₁⁰ x * (spanSingleton R₁⁰ x)⁻¹ = 1
[PROOFSTEP]
rw [spanSingleton_inv, spanSingleton_mul_spanSingleton, mul_inv_cancel hx, spanSingleton_one]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁰ : CommRing R
inst✝⁹ : CommRing A
inst✝⁸ : Field K
inst✝⁷ : IsDomain A
R₁ : Type u_4
inst✝⁶ : CommRing R₁
inst✝⁵ : IsDomain R₁
inst✝⁴ : Algebra R₁ K
inst✝³ : IsFractionRing R₁ K
I J : FractionalIdeal R₁⁰ K
K' : Type u_5
inst✝² : Field K'
inst✝¹ : Algebra R₁ K'
inst✝ : IsFractionRing R₁ K'
x : R₁
hx : x ≠ 0
⊢ ↑(Ideal.span {x}) * (↑(Ideal.span {x}))⁻¹ = 1
[PROOFSTEP]
rw [coeIdeal_span_singleton,
spanSingleton_mul_inv K <| (map_ne_zero_iff _ <| NoZeroSMulDivisors.algebraMap_injective R₁ K).mpr hx]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁰ : CommRing R
inst✝⁹ : CommRing A
inst✝⁸ : Field K
inst✝⁷ : IsDomain A
R₁ : Type u_4
inst✝⁶ : CommRing R₁
inst✝⁵ : IsDomain R₁
inst✝⁴ : Algebra R₁ K
inst✝³ : IsFractionRing R₁ K
I J : FractionalIdeal R₁⁰ K
K' : Type u_5
inst✝² : Field K'
inst✝¹ : Algebra R₁ K'
inst✝ : IsFractionRing R₁ K'
x : K
hx : x ≠ 0
⊢ (spanSingleton R₁⁰ x)⁻¹ * spanSingleton R₁⁰ x = 1
[PROOFSTEP]
rw [mul_comm, spanSingleton_mul_inv K hx]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁰ : CommRing R
inst✝⁹ : CommRing A
inst✝⁸ : Field K
inst✝⁷ : IsDomain A
R₁ : Type u_4
inst✝⁶ : CommRing R₁
inst✝⁵ : IsDomain R₁
inst✝⁴ : Algebra R₁ K
inst✝³ : IsFractionRing R₁ K
I J : FractionalIdeal R₁⁰ K
K' : Type u_5
inst✝² : Field K'
inst✝¹ : Algebra R₁ K'
inst✝ : IsFractionRing R₁ K'
x : R₁
hx : x ≠ 0
⊢ (↑(Ideal.span {x}))⁻¹ * ↑(Ideal.span {x}) = 1
[PROOFSTEP]
rw [mul_comm, coe_ideal_span_singleton_mul_inv K hx]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁴ : CommRing R
inst✝¹³ : CommRing A
inst✝¹² : Field K
inst✝¹¹ : IsDomain A
R₁✝ : Type u_4
inst✝¹⁰ : CommRing R₁✝
inst✝⁹ : IsDomain R₁✝
inst✝⁸ : Algebra R₁✝ K
inst✝⁷ : IsFractionRing R₁✝ K
I✝ J : FractionalIdeal R₁✝⁰ K
K' : Type u_5
inst✝⁶ : Field K'
inst✝⁵ : Algebra R₁✝ K'
inst✝⁴ : IsFractionRing R₁✝ K'
R₁ : Type u_6
inst✝³ : CommRing R₁
inst✝² : Algebra R₁ K
inst✝¹ : IsLocalization R₁⁰ K
I : FractionalIdeal R₁⁰ K
inst✝ : IsPrincipal ↑I
h : I ≠ 0
⊢ I * spanSingleton R₁⁰ (generator ↑I)⁻¹ = 1
[PROOFSTEP]
conv_lhs => congr; rw [eq_spanSingleton_of_principal I]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁴ : CommRing R
inst✝¹³ : CommRing A
inst✝¹² : Field K
inst✝¹¹ : IsDomain A
R₁✝ : Type u_4
inst✝¹⁰ : CommRing R₁✝
inst✝⁹ : IsDomain R₁✝
inst✝⁸ : Algebra R₁✝ K
inst✝⁷ : IsFractionRing R₁✝ K
I✝ J : FractionalIdeal R₁✝⁰ K
K' : Type u_5
inst✝⁶ : Field K'
inst✝⁵ : Algebra R₁✝ K'
inst✝⁴ : IsFractionRing R₁✝ K'
R₁ : Type u_6
inst✝³ : CommRing R₁
inst✝² : Algebra R₁ K
inst✝¹ : IsLocalization R₁⁰ K
I : FractionalIdeal R₁⁰ K
inst✝ : IsPrincipal ↑I
h : I ≠ 0
| I * spanSingleton R₁⁰ (generator ↑I)⁻¹
[PROOFSTEP]
congr; rw [eq_spanSingleton_of_principal I]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁴ : CommRing R
inst✝¹³ : CommRing A
inst✝¹² : Field K
inst✝¹¹ : IsDomain A
R₁✝ : Type u_4
inst✝¹⁰ : CommRing R₁✝
inst✝⁹ : IsDomain R₁✝
inst✝⁸ : Algebra R₁✝ K
inst✝⁷ : IsFractionRing R₁✝ K
I✝ J : FractionalIdeal R₁✝⁰ K
K' : Type u_5
inst✝⁶ : Field K'
inst✝⁵ : Algebra R₁✝ K'
inst✝⁴ : IsFractionRing R₁✝ K'
R₁ : Type u_6
inst✝³ : CommRing R₁
inst✝² : Algebra R₁ K
inst✝¹ : IsLocalization R₁⁰ K
I : FractionalIdeal R₁⁰ K
inst✝ : IsPrincipal ↑I
h : I ≠ 0
| I * spanSingleton R₁⁰ (generator ↑I)⁻¹
[PROOFSTEP]
congr; rw [eq_spanSingleton_of_principal I]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁴ : CommRing R
inst✝¹³ : CommRing A
inst✝¹² : Field K
inst✝¹¹ : IsDomain A
R₁✝ : Type u_4
inst✝¹⁰ : CommRing R₁✝
inst✝⁹ : IsDomain R₁✝
inst✝⁸ : Algebra R₁✝ K
inst✝⁷ : IsFractionRing R₁✝ K
I✝ J : FractionalIdeal R₁✝⁰ K
K' : Type u_5
inst✝⁶ : Field K'
inst✝⁵ : Algebra R₁✝ K'
inst✝⁴ : IsFractionRing R₁✝ K'
R₁ : Type u_6
inst✝³ : CommRing R₁
inst✝² : Algebra R₁ K
inst✝¹ : IsLocalization R₁⁰ K
I : FractionalIdeal R₁⁰ K
inst✝ : IsPrincipal ↑I
h : I ≠ 0
| I * spanSingleton R₁⁰ (generator ↑I)⁻¹
[PROOFSTEP]
congr
[GOAL]
case a
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁴ : CommRing R
inst✝¹³ : CommRing A
inst✝¹² : Field K
inst✝¹¹ : IsDomain A
R₁✝ : Type u_4
inst✝¹⁰ : CommRing R₁✝
inst✝⁹ : IsDomain R₁✝
inst✝⁸ : Algebra R₁✝ K
inst✝⁷ : IsFractionRing R₁✝ K
I✝ J : FractionalIdeal R₁✝⁰ K
K' : Type u_5
inst✝⁶ : Field K'
inst✝⁵ : Algebra R₁✝ K'
inst✝⁴ : IsFractionRing R₁✝ K'
R₁ : Type u_6
inst✝³ : CommRing R₁
inst✝² : Algebra R₁ K
inst✝¹ : IsLocalization R₁⁰ K
I : FractionalIdeal R₁⁰ K
inst✝ : IsPrincipal ↑I
h : I ≠ 0
| I
case a
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁴ : CommRing R
inst✝¹³ : CommRing A
inst✝¹² : Field K
inst✝¹¹ : IsDomain A
R₁✝ : Type u_4
inst✝¹⁰ : CommRing R₁✝
inst✝⁹ : IsDomain R₁✝
inst✝⁸ : Algebra R₁✝ K
inst✝⁷ : IsFractionRing R₁✝ K
I✝ J : FractionalIdeal R₁✝⁰ K
K' : Type u_5
inst✝⁶ : Field K'
inst✝⁵ : Algebra R₁✝ K'
inst✝⁴ : IsFractionRing R₁✝ K'
R₁ : Type u_6
inst✝³ : CommRing R₁
inst✝² : Algebra R₁ K
inst✝¹ : IsLocalization R₁⁰ K
I : FractionalIdeal R₁⁰ K
inst✝ : IsPrincipal ↑I
h : I ≠ 0
| spanSingleton R₁⁰ (generator ↑I)⁻¹
[PROOFSTEP]
rw [eq_spanSingleton_of_principal I]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁴ : CommRing R
inst✝¹³ : CommRing A
inst✝¹² : Field K
inst✝¹¹ : IsDomain A
R₁✝ : Type u_4
inst✝¹⁰ : CommRing R₁✝
inst✝⁹ : IsDomain R₁✝
inst✝⁸ : Algebra R₁✝ K
inst✝⁷ : IsFractionRing R₁✝ K
I✝ J : FractionalIdeal R₁✝⁰ K
K' : Type u_5
inst✝⁶ : Field K'
inst✝⁵ : Algebra R₁✝ K'
inst✝⁴ : IsFractionRing R₁✝ K'
R₁ : Type u_6
inst✝³ : CommRing R₁
inst✝² : Algebra R₁ K
inst✝¹ : IsLocalization R₁⁰ K
I : FractionalIdeal R₁⁰ K
inst✝ : IsPrincipal ↑I
h : I ≠ 0
⊢ spanSingleton R₁⁰ (generator ↑I) * spanSingleton R₁⁰ (generator ↑I)⁻¹ = 1
[PROOFSTEP]
rw [spanSingleton_mul_spanSingleton, mul_inv_cancel, spanSingleton_one]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁴ : CommRing R
inst✝¹³ : CommRing A
inst✝¹² : Field K
inst✝¹¹ : IsDomain A
R₁✝ : Type u_4
inst✝¹⁰ : CommRing R₁✝
inst✝⁹ : IsDomain R₁✝
inst✝⁸ : Algebra R₁✝ K
inst✝⁷ : IsFractionRing R₁✝ K
I✝ J : FractionalIdeal R₁✝⁰ K
K' : Type u_5
inst✝⁶ : Field K'
inst✝⁵ : Algebra R₁✝ K'
inst✝⁴ : IsFractionRing R₁✝ K'
R₁ : Type u_6
inst✝³ : CommRing R₁
inst✝² : Algebra R₁ K
inst✝¹ : IsLocalization R₁⁰ K
I : FractionalIdeal R₁⁰ K
inst✝ : IsPrincipal ↑I
h : I ≠ 0
⊢ generator ↑I ≠ 0
[PROOFSTEP]
intro generator_I_eq_zero
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁴ : CommRing R
inst✝¹³ : CommRing A
inst✝¹² : Field K
inst✝¹¹ : IsDomain A
R₁✝ : Type u_4
inst✝¹⁰ : CommRing R₁✝
inst✝⁹ : IsDomain R₁✝
inst✝⁸ : Algebra R₁✝ K
inst✝⁷ : IsFractionRing R₁✝ K
I✝ J : FractionalIdeal R₁✝⁰ K
K' : Type u_5
inst✝⁶ : Field K'
inst✝⁵ : Algebra R₁✝ K'
inst✝⁴ : IsFractionRing R₁✝ K'
R₁ : Type u_6
inst✝³ : CommRing R₁
inst✝² : Algebra R₁ K
inst✝¹ : IsLocalization R₁⁰ K
I : FractionalIdeal R₁⁰ K
inst✝ : IsPrincipal ↑I
h : I ≠ 0
generator_I_eq_zero : generator ↑I = 0
⊢ False
[PROOFSTEP]
apply h
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁴ : CommRing R
inst✝¹³ : CommRing A
inst✝¹² : Field K
inst✝¹¹ : IsDomain A
R₁✝ : Type u_4
inst✝¹⁰ : CommRing R₁✝
inst✝⁹ : IsDomain R₁✝
inst✝⁸ : Algebra R₁✝ K
inst✝⁷ : IsFractionRing R₁✝ K
I✝ J : FractionalIdeal R₁✝⁰ K
K' : Type u_5
inst✝⁶ : Field K'
inst✝⁵ : Algebra R₁✝ K'
inst✝⁴ : IsFractionRing R₁✝ K'
R₁ : Type u_6
inst✝³ : CommRing R₁
inst✝² : Algebra R₁ K
inst✝¹ : IsLocalization R₁⁰ K
I : FractionalIdeal R₁⁰ K
inst✝ : IsPrincipal ↑I
h : I ≠ 0
generator_I_eq_zero : generator ↑I = 0
⊢ I = 0
[PROOFSTEP]
rw [eq_spanSingleton_of_principal I, generator_I_eq_zero, spanSingleton_zero]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
R₁ : Type u_4
inst✝⁷ : CommRing R₁
inst✝⁶ : IsDomain R₁
inst✝⁵ : Algebra R₁ K
inst✝⁴ : IsFractionRing R₁ K
I✝ J : FractionalIdeal R₁⁰ K
K' : Type u_5
inst✝³ : Field K'
inst✝² : Algebra R₁ K'
inst✝¹ : IsFractionRing R₁ K'
I : FractionalIdeal R₁⁰ K
inst✝ : IsPrincipal ↑I
⊢ I * I⁻¹ = 1 ↔ generator ↑I ≠ 0
[PROOFSTEP]
constructor
[GOAL]
case mp
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
R₁ : Type u_4
inst✝⁷ : CommRing R₁
inst✝⁶ : IsDomain R₁
inst✝⁵ : Algebra R₁ K
inst✝⁴ : IsFractionRing R₁ K
I✝ J : FractionalIdeal R₁⁰ K
K' : Type u_5
inst✝³ : Field K'
inst✝² : Algebra R₁ K'
inst✝¹ : IsFractionRing R₁ K'
I : FractionalIdeal R₁⁰ K
inst✝ : IsPrincipal ↑I
⊢ I * I⁻¹ = 1 → generator ↑I ≠ 0
[PROOFSTEP]
intro hI hg
[GOAL]
case mp
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
R₁ : Type u_4
inst✝⁷ : CommRing R₁
inst✝⁶ : IsDomain R₁
inst✝⁵ : Algebra R₁ K
inst✝⁴ : IsFractionRing R₁ K
I✝ J : FractionalIdeal R₁⁰ K
K' : Type u_5
inst✝³ : Field K'
inst✝² : Algebra R₁ K'
inst✝¹ : IsFractionRing R₁ K'
I : FractionalIdeal R₁⁰ K
inst✝ : IsPrincipal ↑I
hI : I * I⁻¹ = 1
hg : generator ↑I = 0
⊢ False
[PROOFSTEP]
apply ne_zero_of_mul_eq_one _ _ hI
[GOAL]
case mp
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
R₁ : Type u_4
inst✝⁷ : CommRing R₁
inst✝⁶ : IsDomain R₁
inst✝⁵ : Algebra R₁ K
inst✝⁴ : IsFractionRing R₁ K
I✝ J : FractionalIdeal R₁⁰ K
K' : Type u_5
inst✝³ : Field K'
inst✝² : Algebra R₁ K'
inst✝¹ : IsFractionRing R₁ K'
I : FractionalIdeal R₁⁰ K
inst✝ : IsPrincipal ↑I
hI : I * I⁻¹ = 1
hg : generator ↑I = 0
⊢ I = 0
[PROOFSTEP]
rw [eq_spanSingleton_of_principal I, hg, spanSingleton_zero]
[GOAL]
case mpr
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
R₁ : Type u_4
inst✝⁷ : CommRing R₁
inst✝⁶ : IsDomain R₁
inst✝⁵ : Algebra R₁ K
inst✝⁴ : IsFractionRing R₁ K
I✝ J : FractionalIdeal R₁⁰ K
K' : Type u_5
inst✝³ : Field K'
inst✝² : Algebra R₁ K'
inst✝¹ : IsFractionRing R₁ K'
I : FractionalIdeal R₁⁰ K
inst✝ : IsPrincipal ↑I
⊢ generator ↑I ≠ 0 → I * I⁻¹ = 1
[PROOFSTEP]
intro hg
[GOAL]
case mpr
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
R₁ : Type u_4
inst✝⁷ : CommRing R₁
inst✝⁶ : IsDomain R₁
inst✝⁵ : Algebra R₁ K
inst✝⁴ : IsFractionRing R₁ K
I✝ J : FractionalIdeal R₁⁰ K
K' : Type u_5
inst✝³ : Field K'
inst✝² : Algebra R₁ K'
inst✝¹ : IsFractionRing R₁ K'
I : FractionalIdeal R₁⁰ K
inst✝ : IsPrincipal ↑I
hg : generator ↑I ≠ 0
⊢ I * I⁻¹ = 1
[PROOFSTEP]
apply invertible_of_principal
[GOAL]
case mpr.h
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
R₁ : Type u_4
inst✝⁷ : CommRing R₁
inst✝⁶ : IsDomain R₁
inst✝⁵ : Algebra R₁ K
inst✝⁴ : IsFractionRing R₁ K
I✝ J : FractionalIdeal R₁⁰ K
K' : Type u_5
inst✝³ : Field K'
inst✝² : Algebra R₁ K'
inst✝¹ : IsFractionRing R₁ K'
I : FractionalIdeal R₁⁰ K
inst✝ : IsPrincipal ↑I
hg : generator ↑I ≠ 0
⊢ I ≠ 0
[PROOFSTEP]
rw [eq_spanSingleton_of_principal I]
[GOAL]
case mpr.h
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
R₁ : Type u_4
inst✝⁷ : CommRing R₁
inst✝⁶ : IsDomain R₁
inst✝⁵ : Algebra R₁ K
inst✝⁴ : IsFractionRing R₁ K
I✝ J : FractionalIdeal R₁⁰ K
K' : Type u_5
inst✝³ : Field K'
inst✝² : Algebra R₁ K'
inst✝¹ : IsFractionRing R₁ K'
I : FractionalIdeal R₁⁰ K
inst✝ : IsPrincipal ↑I
hg : generator ↑I ≠ 0
⊢ spanSingleton R₁⁰ (generator ↑I) ≠ 0
[PROOFSTEP]
intro hI
[GOAL]
case mpr.h
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
R₁ : Type u_4
inst✝⁷ : CommRing R₁
inst✝⁶ : IsDomain R₁
inst✝⁵ : Algebra R₁ K
inst✝⁴ : IsFractionRing R₁ K
I✝ J : FractionalIdeal R₁⁰ K
K' : Type u_5
inst✝³ : Field K'
inst✝² : Algebra R₁ K'
inst✝¹ : IsFractionRing R₁ K'
I : FractionalIdeal R₁⁰ K
inst✝ : IsPrincipal ↑I
hg : generator ↑I ≠ 0
hI : spanSingleton R₁⁰ (generator ↑I) = 0
⊢ False
[PROOFSTEP]
have := mem_spanSingleton_self R₁⁰ (generator (I : Submodule R₁ K))
[GOAL]
case mpr.h
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
R₁ : Type u_4
inst✝⁷ : CommRing R₁
inst✝⁶ : IsDomain R₁
inst✝⁵ : Algebra R₁ K
inst✝⁴ : IsFractionRing R₁ K
I✝ J : FractionalIdeal R₁⁰ K
K' : Type u_5
inst✝³ : Field K'
inst✝² : Algebra R₁ K'
inst✝¹ : IsFractionRing R₁ K'
I : FractionalIdeal R₁⁰ K
inst✝ : IsPrincipal ↑I
hg : generator ↑I ≠ 0
hI : spanSingleton R₁⁰ (generator ↑I) = 0
this : generator ↑I ∈ spanSingleton R₁⁰ (generator ↑I)
⊢ False
[PROOFSTEP]
rw [hI, mem_zero_iff] at this
[GOAL]
case mpr.h
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
R₁ : Type u_4
inst✝⁷ : CommRing R₁
inst✝⁶ : IsDomain R₁
inst✝⁵ : Algebra R₁ K
inst✝⁴ : IsFractionRing R₁ K
I✝ J : FractionalIdeal R₁⁰ K
K' : Type u_5
inst✝³ : Field K'
inst✝² : Algebra R₁ K'
inst✝¹ : IsFractionRing R₁ K'
I : FractionalIdeal R₁⁰ K
inst✝ : IsPrincipal ↑I
hg : generator ↑I ≠ 0
hI : spanSingleton R₁⁰ (generator ↑I) = 0
this : generator ↑I = 0
⊢ False
[PROOFSTEP]
contradiction
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
R₁ : Type u_4
inst✝⁷ : CommRing R₁
inst✝⁶ : IsDomain R₁
inst✝⁵ : Algebra R₁ K
inst✝⁴ : IsFractionRing R₁ K
I✝ J : FractionalIdeal R₁⁰ K
K' : Type u_5
inst✝³ : Field K'
inst✝² : Algebra R₁ K'
inst✝¹ : IsFractionRing R₁ K'
I : FractionalIdeal R₁⁰ K
inst✝ : IsPrincipal ↑I
h : I ≠ 0
⊢ IsPrincipal ↑I⁻¹
[PROOFSTEP]
rw [val_eq_coe, isPrincipal_iff]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
R₁ : Type u_4
inst✝⁷ : CommRing R₁
inst✝⁶ : IsDomain R₁
inst✝⁵ : Algebra R₁ K
inst✝⁴ : IsFractionRing R₁ K
I✝ J : FractionalIdeal R₁⁰ K
K' : Type u_5
inst✝³ : Field K'
inst✝² : Algebra R₁ K'
inst✝¹ : IsFractionRing R₁ K'
I : FractionalIdeal R₁⁰ K
inst✝ : IsPrincipal ↑I
h : I ≠ 0
⊢ ∃ x, I⁻¹ = spanSingleton R₁⁰ x
[PROOFSTEP]
use(generator (I : Submodule R₁ K))⁻¹
[GOAL]
case h
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
R₁ : Type u_4
inst✝⁷ : CommRing R₁
inst✝⁶ : IsDomain R₁
inst✝⁵ : Algebra R₁ K
inst✝⁴ : IsFractionRing R₁ K
I✝ J : FractionalIdeal R₁⁰ K
K' : Type u_5
inst✝³ : Field K'
inst✝² : Algebra R₁ K'
inst✝¹ : IsFractionRing R₁ K'
I : FractionalIdeal R₁⁰ K
inst✝ : IsPrincipal ↑I
h : I ≠ 0
⊢ I⁻¹ = spanSingleton R₁⁰ (generator ↑I)⁻¹
[PROOFSTEP]
have hI : I * spanSingleton _ (generator (I : Submodule R₁ K))⁻¹ = 1
[GOAL]
case hI
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
R₁ : Type u_4
inst✝⁷ : CommRing R₁
inst✝⁶ : IsDomain R₁
inst✝⁵ : Algebra R₁ K
inst✝⁴ : IsFractionRing R₁ K
I✝ J : FractionalIdeal R₁⁰ K
K' : Type u_5
inst✝³ : Field K'
inst✝² : Algebra R₁ K'
inst✝¹ : IsFractionRing R₁ K'
I : FractionalIdeal R₁⁰ K
inst✝ : IsPrincipal ↑I
h : I ≠ 0
⊢ I * spanSingleton R₁⁰ (generator ↑I)⁻¹ = 1
case h
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
R₁ : Type u_4
inst✝⁷ : CommRing R₁
inst✝⁶ : IsDomain R₁
inst✝⁵ : Algebra R₁ K
inst✝⁴ : IsFractionRing R₁ K
I✝ J : FractionalIdeal R₁⁰ K
K' : Type u_5
inst✝³ : Field K'
inst✝² : Algebra R₁ K'
inst✝¹ : IsFractionRing R₁ K'
I : FractionalIdeal R₁⁰ K
inst✝ : IsPrincipal ↑I
h : I ≠ 0
hI : I * spanSingleton R₁⁰ (generator ↑I)⁻¹ = 1
⊢ I⁻¹ = spanSingleton R₁⁰ (generator ↑I)⁻¹
[PROOFSTEP]
apply mul_generator_self_inv _ I h
[GOAL]
case h
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
R₁ : Type u_4
inst✝⁷ : CommRing R₁
inst✝⁶ : IsDomain R₁
inst✝⁵ : Algebra R₁ K
inst✝⁴ : IsFractionRing R₁ K
I✝ J : FractionalIdeal R₁⁰ K
K' : Type u_5
inst✝³ : Field K'
inst✝² : Algebra R₁ K'
inst✝¹ : IsFractionRing R₁ K'
I : FractionalIdeal R₁⁰ K
inst✝ : IsPrincipal ↑I
h : I ≠ 0
hI : I * spanSingleton R₁⁰ (generator ↑I)⁻¹ = 1
⊢ I⁻¹ = spanSingleton R₁⁰ (generator ↑I)⁻¹
[PROOFSTEP]
exact (right_inverse_eq _ I (spanSingleton _ (generator (I : Submodule R₁ K))⁻¹) hI).symm
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
⊢ IsDedekindDomainInv A ↔ ∀ (I : FractionalIdeal A⁰ K), I ≠ ⊥ → I * I⁻¹ = 1
[PROOFSTEP]
let h : FractionalIdeal A⁰ (FractionRing A) ≃+* FractionalIdeal A⁰ K :=
FractionalIdeal.mapEquiv (FractionRing.algEquiv A K)
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : FractionalIdeal A⁰ (FractionRing A) ≃+* FractionalIdeal A⁰ K := mapEquiv (FractionRing.algEquiv A K)
⊢ IsDedekindDomainInv A ↔ ∀ (I : FractionalIdeal A⁰ K), I ≠ ⊥ → I * I⁻¹ = 1
[PROOFSTEP]
refine h.toEquiv.forall_congr (fun {x} => ?_)
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : FractionalIdeal A⁰ (FractionRing A) ≃+* FractionalIdeal A⁰ K := mapEquiv (FractionRing.algEquiv A K)
x : FractionalIdeal A⁰ (FractionRing A)
⊢ x ≠ ⊥ → x * x⁻¹ = 1 ↔ ↑h.toEquiv x ≠ ⊥ → ↑h.toEquiv x * (↑h.toEquiv x)⁻¹ = 1
[PROOFSTEP]
rw [← h.toEquiv.apply_eq_iff_eq]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : FractionalIdeal A⁰ (FractionRing A) ≃+* FractionalIdeal A⁰ K := mapEquiv (FractionRing.algEquiv A K)
x : FractionalIdeal A⁰ (FractionRing A)
⊢ x ≠ ⊥ → ↑h.toEquiv (x * x⁻¹) = ↑h.toEquiv 1 ↔ ↑h.toEquiv x ≠ ⊥ → ↑h.toEquiv x * (↑h.toEquiv x)⁻¹ = 1
[PROOFSTEP]
simp [IsDedekindDomainInv]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
x : K
hx : IsIntegral A x
hI : IsUnit (adjoinIntegral A⁰ x hx)
⊢ adjoinIntegral A⁰ x hx = 1
[PROOFSTEP]
set I := adjoinIntegral A⁰ x hx
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
x : K
hx : IsIntegral A x
I : FractionalIdeal A⁰ K := adjoinIntegral A⁰ x hx
hI : IsUnit I
⊢ I = 1
[PROOFSTEP]
have mul_self : I * I = I := by apply coeToSubmodule_injective; simp
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
x : K
hx : IsIntegral A x
I : FractionalIdeal A⁰ K := adjoinIntegral A⁰ x hx
hI : IsUnit I
⊢ I * I = I
[PROOFSTEP]
apply coeToSubmodule_injective
[GOAL]
case a
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
x : K
hx : IsIntegral A x
I : FractionalIdeal A⁰ K := adjoinIntegral A⁰ x hx
hI : IsUnit I
⊢ (fun I => ↑I) (I * I) = (fun I => ↑I) I
[PROOFSTEP]
simp
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
x : K
hx : IsIntegral A x
I : FractionalIdeal A⁰ K := adjoinIntegral A⁰ x hx
hI : IsUnit I
mul_self : I * I = I
⊢ I = 1
[PROOFSTEP]
convert congr_arg (· * I⁻¹) mul_self
[GOAL]
case h.e'_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
x : K
hx : IsIntegral A x
I : FractionalIdeal A⁰ K := adjoinIntegral A⁰ x hx
hI : IsUnit I
mul_self : I * I = I
⊢ I = I * I * I⁻¹
[PROOFSTEP]
simp only [(mul_inv_cancel_iff_isUnit K).mpr hI, mul_assoc, mul_one]
[GOAL]
case h.e'_3
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
x : K
hx : IsIntegral A x
I : FractionalIdeal A⁰ K := adjoinIntegral A⁰ x hx
hI : IsUnit I
mul_self : I * I = I
⊢ 1 = I * I⁻¹
[PROOFSTEP]
simp only [(mul_inv_cancel_iff_isUnit K).mpr hI, mul_assoc, mul_one]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
⊢ IsNoetherianRing A
[PROOFSTEP]
refine' isNoetherianRing_iff.mpr ⟨fun I : Ideal A => _⟩
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
I : Ideal A
⊢ Submodule.FG I
[PROOFSTEP]
by_cases hI : I = ⊥
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
I : Ideal A
hI : I = ⊥
⊢ Submodule.FG I
[PROOFSTEP]
rw [hI]
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
I : Ideal A
hI : I = ⊥
⊢ Submodule.FG ⊥
[PROOFSTEP]
apply Submodule.fg_bot
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
I : Ideal A
hI : ¬I = ⊥
⊢ Submodule.FG I
[PROOFSTEP]
have hI : (I : FractionalIdeal A⁰ (FractionRing A)) ≠ 0 := coeIdeal_ne_zero.mpr hI
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
I : Ideal A
hI✝ : ¬I = ⊥
hI : ↑I ≠ 0
⊢ Submodule.FG I
[PROOFSTEP]
exact I.fg_of_isUnit (IsFractionRing.injective A (FractionRing A)) (h.isUnit hI)
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
⊢ IsIntegrallyClosed A
[PROOFSTEP]
refine ⟨fun {x hx} => ?_⟩
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
x : FractionRing A
hx : IsIntegral A x
⊢ ∃ y, ↑(algebraMap A (FractionRing A)) y = x
[PROOFSTEP]
rw [← Set.mem_range, ← Algebra.mem_bot, ← Subalgebra.mem_toSubmodule, Algebra.toSubmodule_bot, ←
coe_spanSingleton A⁰ (1 : FractionRing A), spanSingleton_one, ←
FractionalIdeal.adjoinIntegral_eq_one_of_isUnit x hx (h.isUnit _)]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
x : FractionRing A
hx : IsIntegral A x
⊢ x ∈ ↑(adjoinIntegral A⁰ x hx)
[PROOFSTEP]
exact mem_adjoinIntegral_self A⁰ x hx
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
x : FractionRing A
hx : IsIntegral A x
⊢ adjoinIntegral A⁰ x hx ≠ 0
[PROOFSTEP]
exact fun h => one_ne_zero (eq_zero_iff.mp h 1 (Algebra.adjoin A { x }).one_mem)
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
⊢ ∀ {p : Ideal A}, p ≠ ⊥ → Ideal.IsPrime p → Ideal.IsMaximal p
[PROOFSTEP]
rintro P P_ne hP
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
P : Ideal A
P_ne : P ≠ ⊥
hP : Ideal.IsPrime P
⊢ Ideal.IsMaximal P
[PROOFSTEP]
refine
Ideal.isMaximal_def.mpr
⟨hP.ne_top, fun M hM => ?_⟩
-- We may assume `P` and `M` (as fractional ideals) are nonzero.
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
P : Ideal A
P_ne : P ≠ ⊥
hP : Ideal.IsPrime P
M : Ideal A
hM : P < M
⊢ M = ⊤
[PROOFSTEP]
have P'_ne : (P : FractionalIdeal A⁰ (FractionRing A)) ≠ 0 := coeIdeal_ne_zero.mpr P_ne
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
P : Ideal A
P_ne : P ≠ ⊥
hP : Ideal.IsPrime P
M : Ideal A
hM : P < M
P'_ne : ↑P ≠ 0
⊢ M = ⊤
[PROOFSTEP]
have M'_ne : (M : FractionalIdeal A⁰ (FractionRing A)) ≠ 0 := coeIdeal_ne_zero.mpr (lt_of_le_of_lt bot_le hM).ne'
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
P : Ideal A
P_ne : P ≠ ⊥
hP : Ideal.IsPrime P
M : Ideal A
hM : P < M
P'_ne : ↑P ≠ 0
M'_ne : ↑M ≠ 0
⊢ M = ⊤
[PROOFSTEP]
suffices (M⁻¹ : FractionalIdeal A⁰ (FractionRing A)) * P ≤ P
by
rw [eq_top_iff, ← coeIdeal_le_coeIdeal (FractionRing A), coeIdeal_top]
calc
(1 : FractionalIdeal A⁰ (FractionRing A)) = _ * _ * _ := ?_
_ ≤ _ * _ :=
(mul_right_mono ((P : FractionalIdeal A⁰ (FractionRing A))⁻¹ * M : FractionalIdeal A⁰ (FractionRing A)) this)
_ = M := ?_
·
rw [mul_assoc, ← mul_assoc (P : FractionalIdeal A⁰ (FractionRing A)), h.mul_inv_eq_one P'_ne, one_mul,
h.inv_mul_eq_one M'_ne]
·
rw [← mul_assoc (P : FractionalIdeal A⁰ (FractionRing A)), h.mul_inv_eq_one P'_ne, one_mul]
-- Suppose we have `x ∈ M⁻¹ * P`, then in fact `x = algebraMap _ _ y` for some `y`.
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
P : Ideal A
P_ne : P ≠ ⊥
hP : Ideal.IsPrime P
M : Ideal A
hM : P < M
P'_ne : ↑P ≠ 0
M'_ne : ↑M ≠ 0
this : (↑M)⁻¹ * ↑P ≤ ↑P
⊢ M = ⊤
[PROOFSTEP]
rw [eq_top_iff, ← coeIdeal_le_coeIdeal (FractionRing A), coeIdeal_top]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
P : Ideal A
P_ne : P ≠ ⊥
hP : Ideal.IsPrime P
M : Ideal A
hM : P < M
P'_ne : ↑P ≠ 0
M'_ne : ↑M ≠ 0
this : (↑M)⁻¹ * ↑P ≤ ↑P
⊢ 1 ≤ ↑M
[PROOFSTEP]
calc
(1 : FractionalIdeal A⁰ (FractionRing A)) = _ * _ * _ := ?_
_ ≤ _ * _ :=
(mul_right_mono ((P : FractionalIdeal A⁰ (FractionRing A))⁻¹ * M : FractionalIdeal A⁰ (FractionRing A)) this)
_ = M := ?_
[GOAL]
case calc_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
P : Ideal A
P_ne : P ≠ ⊥
hP : Ideal.IsPrime P
M : Ideal A
hM : P < M
P'_ne : ↑P ≠ 0
M'_ne : ↑M ≠ 0
this : (↑M)⁻¹ * ↑P ≤ ↑P
⊢ 1 = (↑M)⁻¹ * ↑P * ((↑P)⁻¹ * ↑M)
[PROOFSTEP]
rw [mul_assoc, ← mul_assoc (P : FractionalIdeal A⁰ (FractionRing A)), h.mul_inv_eq_one P'_ne, one_mul,
h.inv_mul_eq_one M'_ne]
[GOAL]
case calc_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
P : Ideal A
P_ne : P ≠ ⊥
hP : Ideal.IsPrime P
M : Ideal A
hM : P < M
P'_ne : ↑P ≠ 0
M'_ne : ↑M ≠ 0
this : (↑M)⁻¹ * ↑P ≤ ↑P
⊢ ↑P * ((↑P)⁻¹ * ↑M) = ↑M
[PROOFSTEP]
rw [← mul_assoc (P : FractionalIdeal A⁰ (FractionRing A)), h.mul_inv_eq_one P'_ne, one_mul]
-- Suppose we have `x ∈ M⁻¹ * P`, then in fact `x = algebraMap _ _ y` for some `y`.
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
P : Ideal A
P_ne : P ≠ ⊥
hP : Ideal.IsPrime P
M : Ideal A
hM : P < M
P'_ne : ↑P ≠ 0
M'_ne : ↑M ≠ 0
⊢ (↑M)⁻¹ * ↑P ≤ ↑P
[PROOFSTEP]
intro x hx
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
P : Ideal A
P_ne : P ≠ ⊥
hP : Ideal.IsPrime P
M : Ideal A
hM : P < M
P'_ne : ↑P ≠ 0
M'_ne : ↑M ≠ 0
x : FractionRing A
hx : x ∈ (fun a => ↑a) ((↑M)⁻¹ * ↑P)
⊢ x ∈ (fun a => ↑a) ↑P
[PROOFSTEP]
have le_one : (M⁻¹ : FractionalIdeal A⁰ (FractionRing A)) * P ≤ 1 :=
by
rw [← h.inv_mul_eq_one M'_ne]
exact mul_left_mono _ ((coeIdeal_le_coeIdeal (FractionRing A)).mpr hM.le)
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
P : Ideal A
P_ne : P ≠ ⊥
hP : Ideal.IsPrime P
M : Ideal A
hM : P < M
P'_ne : ↑P ≠ 0
M'_ne : ↑M ≠ 0
x : FractionRing A
hx : x ∈ (fun a => ↑a) ((↑M)⁻¹ * ↑P)
⊢ (↑M)⁻¹ * ↑P ≤ 1
[PROOFSTEP]
rw [← h.inv_mul_eq_one M'_ne]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
P : Ideal A
P_ne : P ≠ ⊥
hP : Ideal.IsPrime P
M : Ideal A
hM : P < M
P'_ne : ↑P ≠ 0
M'_ne : ↑M ≠ 0
x : FractionRing A
hx : x ∈ (fun a => ↑a) ((↑M)⁻¹ * ↑P)
⊢ (↑M)⁻¹ * ↑P ≤ (↑M)⁻¹ * ↑M
[PROOFSTEP]
exact mul_left_mono _ ((coeIdeal_le_coeIdeal (FractionRing A)).mpr hM.le)
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
P : Ideal A
P_ne : P ≠ ⊥
hP : Ideal.IsPrime P
M : Ideal A
hM : P < M
P'_ne : ↑P ≠ 0
M'_ne : ↑M ≠ 0
x : FractionRing A
hx : x ∈ (fun a => ↑a) ((↑M)⁻¹ * ↑P)
le_one : (↑M)⁻¹ * ↑P ≤ 1
⊢ x ∈ (fun a => ↑a) ↑P
[PROOFSTEP]
obtain ⟨y, _hy, rfl⟩ :=
(mem_coeIdeal _).mp
(le_one hx)
-- Since `M` is strictly greater than `P`, let `z ∈ M \ P`.
[GOAL]
case intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
P : Ideal A
P_ne : P ≠ ⊥
hP : Ideal.IsPrime P
M : Ideal A
hM : P < M
P'_ne : ↑P ≠ 0
M'_ne : ↑M ≠ 0
le_one : (↑M)⁻¹ * ↑P ≤ 1
y : A
_hy : y ∈ ⊤
hx : ↑(algebraMap A (FractionRing A)) y ∈ (fun a => ↑a) ((↑M)⁻¹ * ↑P)
⊢ ↑(algebraMap A (FractionRing A)) y ∈ (fun a => ↑a) ↑P
[PROOFSTEP]
obtain ⟨z, hzM, hzp⟩ := SetLike.exists_of_lt hM
[GOAL]
case intro.intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
P : Ideal A
P_ne : P ≠ ⊥
hP : Ideal.IsPrime P
M : Ideal A
hM : P < M
P'_ne : ↑P ≠ 0
M'_ne : ↑M ≠ 0
le_one : (↑M)⁻¹ * ↑P ≤ 1
y : A
_hy : y ∈ ⊤
hx : ↑(algebraMap A (FractionRing A)) y ∈ (fun a => ↑a) ((↑M)⁻¹ * ↑P)
z : A
hzM : z ∈ M
hzp : ¬z ∈ P
⊢ ↑(algebraMap A (FractionRing A)) y ∈ (fun a => ↑a) ↑P
[PROOFSTEP]
have zy_mem := mul_mem_mul (mem_coeIdeal_of_mem A⁰ hzM) hx
[GOAL]
case intro.intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
P : Ideal A
P_ne : P ≠ ⊥
hP : Ideal.IsPrime P
M : Ideal A
hM : P < M
P'_ne : ↑P ≠ 0
M'_ne : ↑M ≠ 0
le_one : (↑M)⁻¹ * ↑P ≤ 1
y : A
_hy : y ∈ ⊤
hx : ↑(algebraMap A (FractionRing A)) y ∈ (fun a => ↑a) ((↑M)⁻¹ * ↑P)
z : A
hzM : z ∈ M
hzp : ¬z ∈ P
zy_mem : ↑(algebraMap A (FractionRing A)) z * ↑(algebraMap A (FractionRing A)) y ∈ ↑M * ((↑M)⁻¹ * ↑P)
⊢ ↑(algebraMap A (FractionRing A)) y ∈ (fun a => ↑a) ↑P
[PROOFSTEP]
rw [← RingHom.map_mul, ← mul_assoc, h.mul_inv_eq_one M'_ne, one_mul] at zy_mem
[GOAL]
case intro.intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
P : Ideal A
P_ne : P ≠ ⊥
hP : Ideal.IsPrime P
M : Ideal A
hM : P < M
P'_ne : ↑P ≠ 0
M'_ne : ↑M ≠ 0
le_one : (↑M)⁻¹ * ↑P ≤ 1
y : A
_hy : y ∈ ⊤
hx : ↑(algebraMap A (FractionRing A)) y ∈ (fun a => ↑a) ((↑M)⁻¹ * ↑P)
z : A
hzM : z ∈ M
hzp : ¬z ∈ P
zy_mem : ↑(algebraMap A (FractionRing A)) (z * y) ∈ ↑P
⊢ ↑(algebraMap A (FractionRing A)) y ∈ (fun a => ↑a) ↑P
[PROOFSTEP]
obtain ⟨zy, hzy, zy_eq⟩ := (mem_coeIdeal A⁰).mp zy_mem
[GOAL]
case intro.intro.intro.intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
P : Ideal A
P_ne : P ≠ ⊥
hP : Ideal.IsPrime P
M : Ideal A
hM : P < M
P'_ne : ↑P ≠ 0
M'_ne : ↑M ≠ 0
le_one : (↑M)⁻¹ * ↑P ≤ 1
y : A
_hy : y ∈ ⊤
hx : ↑(algebraMap A (FractionRing A)) y ∈ (fun a => ↑a) ((↑M)⁻¹ * ↑P)
z : A
hzM : z ∈ M
hzp : ¬z ∈ P
zy_mem : ↑(algebraMap A (FractionRing A)) (z * y) ∈ ↑P
zy : A
hzy : zy ∈ P
zy_eq : ↑(algebraMap A ((fun x => FractionRing A) z)) zy = ↑(algebraMap A (FractionRing A)) (z * y)
⊢ ↑(algebraMap A (FractionRing A)) y ∈ (fun a => ↑a) ↑P
[PROOFSTEP]
rw [IsFractionRing.injective A (FractionRing A) zy_eq] at hzy
[GOAL]
case intro.intro.intro.intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomainInv A
P : Ideal A
P_ne : P ≠ ⊥
hP : Ideal.IsPrime P
M : Ideal A
hM : P < M
P'_ne : ↑P ≠ 0
M'_ne : ↑M ≠ 0
le_one : (↑M)⁻¹ * ↑P ≤ 1
y : A
_hy : y ∈ ⊤
hx : ↑(algebraMap A (FractionRing A)) y ∈ (fun a => ↑a) ((↑M)⁻¹ * ↑P)
z : A
hzM : z ∈ M
hzp : ¬z ∈ P
zy_mem : ↑(algebraMap A (FractionRing A)) (z * y) ∈ ↑P
zy : A
hzy : z * y ∈ P
zy_eq : ↑(algebraMap A ((fun x => FractionRing A) z)) zy = ↑(algebraMap A (FractionRing A)) (z * y)
⊢ ↑(algebraMap A (FractionRing A)) y ∈ (fun a => ↑a) ↑P
[PROOFSTEP]
exact mem_coeIdeal_of_mem A⁰ (Or.resolve_left (hP.mem_or_mem hzy) hzp)
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I M : Ideal A
hI0 : I ≠ ⊥
hIM : I ≤ M
hM : Ideal.IsMaximal M
⊢ ∃ Z,
Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
[PROOFSTEP]
obtain ⟨Z₀, hZ₀⟩ := PrimeSpectrum.exists_primeSpectrum_prod_le_and_ne_bot_of_domain hNF hI0
[GOAL]
case intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I M : Ideal A
hI0 : I ≠ ⊥
hIM : I ≤ M
hM : Ideal.IsMaximal M
Z₀ : Multiset (PrimeSpectrum A)
hZ₀ :
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≤ I ∧ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≠ ⊥
⊢ ∃ Z,
Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
[PROOFSTEP]
obtain ⟨Z, ⟨hZI, hprodZ⟩, h_eraseZ⟩ :=
Multiset.wellFounded_lt.has_min
(fun Z => (Z.map PrimeSpectrum.asIdeal).prod ≤ I ∧ (Z.map PrimeSpectrum.asIdeal).prod ≠ ⊥) ⟨Z₀, hZ₀⟩
[GOAL]
case intro.intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I M : Ideal A
hI0 : I ≠ ⊥
hIM : I ≤ M
hM : Ideal.IsMaximal M
Z₀ : Multiset (PrimeSpectrum A)
hZ₀ :
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≤ I ∧ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≠ ⊥
Z : Multiset (PrimeSpectrum A)
h_eraseZ :
∀ (x : Multiset (PrimeSpectrum A)),
(x ∈ fun Z =>
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥) →
¬x < Z
hZI : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
hprodZ : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥
⊢ ∃ Z,
Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
[PROOFSTEP]
have hZM : Multiset.prod (Z.map PrimeSpectrum.asIdeal) ≤ M := le_trans hZI hIM
[GOAL]
case intro.intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I M : Ideal A
hI0 : I ≠ ⊥
hIM : I ≤ M
hM : Ideal.IsMaximal M
Z₀ : Multiset (PrimeSpectrum A)
hZ₀ :
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≤ I ∧ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≠ ⊥
Z : Multiset (PrimeSpectrum A)
h_eraseZ :
∀ (x : Multiset (PrimeSpectrum A)),
(x ∈ fun Z =>
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥) →
¬x < Z
hZI : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
hprodZ : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥
hZM : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ M
⊢ ∃ Z,
Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
[PROOFSTEP]
have hZ0 : Z ≠ 0 := by rintro rfl; simp [hM.ne_top] at hZM
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I M : Ideal A
hI0 : I ≠ ⊥
hIM : I ≤ M
hM : Ideal.IsMaximal M
Z₀ : Multiset (PrimeSpectrum A)
hZ₀ :
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≤ I ∧ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≠ ⊥
Z : Multiset (PrimeSpectrum A)
h_eraseZ :
∀ (x : Multiset (PrimeSpectrum A)),
(x ∈ fun Z =>
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥) →
¬x < Z
hZI : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
hprodZ : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥
hZM : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ M
⊢ Z ≠ 0
[PROOFSTEP]
rintro rfl
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I M : Ideal A
hI0 : I ≠ ⊥
hIM : I ≤ M
hM : Ideal.IsMaximal M
Z₀ : Multiset (PrimeSpectrum A)
hZ₀ :
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≤ I ∧ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≠ ⊥
h_eraseZ :
∀ (x : Multiset (PrimeSpectrum A)),
(x ∈ fun Z =>
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥) →
¬x < 0
hZI : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal 0) ≤ I
hprodZ : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal 0) ≠ ⊥
hZM : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal 0) ≤ M
⊢ False
[PROOFSTEP]
simp [hM.ne_top] at hZM
[GOAL]
case intro.intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I M : Ideal A
hI0 : I ≠ ⊥
hIM : I ≤ M
hM : Ideal.IsMaximal M
Z₀ : Multiset (PrimeSpectrum A)
hZ₀ :
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≤ I ∧ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≠ ⊥
Z : Multiset (PrimeSpectrum A)
h_eraseZ :
∀ (x : Multiset (PrimeSpectrum A)),
(x ∈ fun Z =>
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥) →
¬x < Z
hZI : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
hprodZ : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥
hZM : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ M
hZ0 : Z ≠ 0
⊢ ∃ Z,
Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
[PROOFSTEP]
obtain ⟨_, hPZ', hPM⟩ := (hM.isPrime.multiset_prod_le (mt Multiset.map_eq_zero.mp hZ0)).mp hZM
[GOAL]
case intro.intro.intro.intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I M : Ideal A
hI0 : I ≠ ⊥
hIM : I ≤ M
hM : Ideal.IsMaximal M
Z₀ : Multiset (PrimeSpectrum A)
hZ₀ :
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≤ I ∧ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≠ ⊥
Z : Multiset (PrimeSpectrum A)
h_eraseZ :
∀ (x : Multiset (PrimeSpectrum A)),
(x ∈ fun Z =>
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥) →
¬x < Z
hZI : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
hprodZ : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥
hZM : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ M
hZ0 : Z ≠ 0
w✝ : Ideal A
hPZ' : w✝ ∈ Multiset.map PrimeSpectrum.asIdeal Z
hPM : w✝ ≤ M
⊢ ∃ Z,
Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
[PROOFSTEP]
obtain ⟨P, hPZ, rfl⟩ := Multiset.mem_map.mp hPZ'
[GOAL]
case intro.intro.intro.intro.intro.intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I M : Ideal A
hI0 : I ≠ ⊥
hIM : I ≤ M
hM : Ideal.IsMaximal M
Z₀ : Multiset (PrimeSpectrum A)
hZ₀ :
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≤ I ∧ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≠ ⊥
Z : Multiset (PrimeSpectrum A)
h_eraseZ :
∀ (x : Multiset (PrimeSpectrum A)),
(x ∈ fun Z =>
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥) →
¬x < Z
hZI : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
hprodZ : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥
hZM : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ M
hZ0 : Z ≠ 0
P : PrimeSpectrum A
hPZ : P ∈ Z
hPZ' : P.asIdeal ∈ Multiset.map PrimeSpectrum.asIdeal Z
hPM : P.asIdeal ≤ M
⊢ ∃ Z,
Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
[PROOFSTEP]
classical
have := Multiset.map_erase PrimeSpectrum.asIdeal PrimeSpectrum.ext P Z
obtain ⟨hP0, hZP0⟩ : P.asIdeal ≠ ⊥ ∧ ((Z.erase P).map PrimeSpectrum.asIdeal).prod ≠ ⊥ := by
rwa [Ne.def, ← Multiset.cons_erase hPZ', Multiset.prod_cons, Ideal.mul_eq_bot, not_or, ← this] at hprodZ
have hPM' := (P.IsPrime.isMaximal hP0).eq_of_le hM.ne_top hPM
subst hPM'
refine ⟨Z.erase P, ?_, ?_⟩
· convert hZI
rw [this, Multiset.cons_erase hPZ']
· refine fun h => h_eraseZ (Z.erase P) ⟨h, ?_⟩ (Multiset.erase_lt.mpr hPZ)
exact hZP0
[GOAL]
case intro.intro.intro.intro.intro.intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I M : Ideal A
hI0 : I ≠ ⊥
hIM : I ≤ M
hM : Ideal.IsMaximal M
Z₀ : Multiset (PrimeSpectrum A)
hZ₀ :
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≤ I ∧ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≠ ⊥
Z : Multiset (PrimeSpectrum A)
h_eraseZ :
∀ (x : Multiset (PrimeSpectrum A)),
(x ∈ fun Z =>
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥) →
¬x < Z
hZI : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
hprodZ : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥
hZM : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ M
hZ0 : Z ≠ 0
P : PrimeSpectrum A
hPZ : P ∈ Z
hPZ' : P.asIdeal ∈ Multiset.map PrimeSpectrum.asIdeal Z
hPM : P.asIdeal ≤ M
⊢ ∃ Z,
Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
[PROOFSTEP]
have := Multiset.map_erase PrimeSpectrum.asIdeal PrimeSpectrum.ext P Z
[GOAL]
case intro.intro.intro.intro.intro.intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I M : Ideal A
hI0 : I ≠ ⊥
hIM : I ≤ M
hM : Ideal.IsMaximal M
Z₀ : Multiset (PrimeSpectrum A)
hZ₀ :
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≤ I ∧ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≠ ⊥
Z : Multiset (PrimeSpectrum A)
h_eraseZ :
∀ (x : Multiset (PrimeSpectrum A)),
(x ∈ fun Z =>
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥) →
¬x < Z
hZI : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
hprodZ : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥
hZM : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ M
hZ0 : Z ≠ 0
P : PrimeSpectrum A
hPZ : P ∈ Z
hPZ' : P.asIdeal ∈ Multiset.map PrimeSpectrum.asIdeal Z
hPM : P.asIdeal ≤ M
this :
Multiset.map PrimeSpectrum.asIdeal (Multiset.erase Z P) =
Multiset.erase (Multiset.map PrimeSpectrum.asIdeal Z) P.asIdeal
⊢ ∃ Z,
Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
[PROOFSTEP]
obtain ⟨hP0, hZP0⟩ : P.asIdeal ≠ ⊥ ∧ ((Z.erase P).map PrimeSpectrum.asIdeal).prod ≠ ⊥ := by
rwa [Ne.def, ← Multiset.cons_erase hPZ', Multiset.prod_cons, Ideal.mul_eq_bot, not_or, ← this] at hprodZ
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I M : Ideal A
hI0 : I ≠ ⊥
hIM : I ≤ M
hM : Ideal.IsMaximal M
Z₀ : Multiset (PrimeSpectrum A)
hZ₀ :
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≤ I ∧ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≠ ⊥
Z : Multiset (PrimeSpectrum A)
h_eraseZ :
∀ (x : Multiset (PrimeSpectrum A)),
(x ∈ fun Z =>
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥) →
¬x < Z
hZI : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
hprodZ : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥
hZM : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ M
hZ0 : Z ≠ 0
P : PrimeSpectrum A
hPZ : P ∈ Z
hPZ' : P.asIdeal ∈ Multiset.map PrimeSpectrum.asIdeal Z
hPM : P.asIdeal ≤ M
this :
Multiset.map PrimeSpectrum.asIdeal (Multiset.erase Z P) =
Multiset.erase (Multiset.map PrimeSpectrum.asIdeal Z) P.asIdeal
⊢ P.asIdeal ≠ ⊥ ∧ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal (Multiset.erase Z P)) ≠ ⊥
[PROOFSTEP]
rwa [Ne.def, ← Multiset.cons_erase hPZ', Multiset.prod_cons, Ideal.mul_eq_bot, not_or, ← this] at hprodZ
[GOAL]
case intro.intro.intro.intro.intro.intro.intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I M : Ideal A
hI0 : I ≠ ⊥
hIM : I ≤ M
hM : Ideal.IsMaximal M
Z₀ : Multiset (PrimeSpectrum A)
hZ₀ :
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≤ I ∧ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≠ ⊥
Z : Multiset (PrimeSpectrum A)
h_eraseZ :
∀ (x : Multiset (PrimeSpectrum A)),
(x ∈ fun Z =>
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥) →
¬x < Z
hZI : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
hprodZ : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥
hZM : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ M
hZ0 : Z ≠ 0
P : PrimeSpectrum A
hPZ : P ∈ Z
hPZ' : P.asIdeal ∈ Multiset.map PrimeSpectrum.asIdeal Z
hPM : P.asIdeal ≤ M
this :
Multiset.map PrimeSpectrum.asIdeal (Multiset.erase Z P) =
Multiset.erase (Multiset.map PrimeSpectrum.asIdeal Z) P.asIdeal
hP0 : P.asIdeal ≠ ⊥
hZP0 : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal (Multiset.erase Z P)) ≠ ⊥
⊢ ∃ Z,
Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
[PROOFSTEP]
have hPM' := (P.IsPrime.isMaximal hP0).eq_of_le hM.ne_top hPM
[GOAL]
case intro.intro.intro.intro.intro.intro.intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I M : Ideal A
hI0 : I ≠ ⊥
hIM : I ≤ M
hM : Ideal.IsMaximal M
Z₀ : Multiset (PrimeSpectrum A)
hZ₀ :
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≤ I ∧ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≠ ⊥
Z : Multiset (PrimeSpectrum A)
h_eraseZ :
∀ (x : Multiset (PrimeSpectrum A)),
(x ∈ fun Z =>
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥) →
¬x < Z
hZI : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
hprodZ : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥
hZM : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ M
hZ0 : Z ≠ 0
P : PrimeSpectrum A
hPZ : P ∈ Z
hPZ' : P.asIdeal ∈ Multiset.map PrimeSpectrum.asIdeal Z
hPM : P.asIdeal ≤ M
this :
Multiset.map PrimeSpectrum.asIdeal (Multiset.erase Z P) =
Multiset.erase (Multiset.map PrimeSpectrum.asIdeal Z) P.asIdeal
hP0 : P.asIdeal ≠ ⊥
hZP0 : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal (Multiset.erase Z P)) ≠ ⊥
hPM' : P.asIdeal = M
⊢ ∃ Z,
Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
[PROOFSTEP]
subst hPM'
[GOAL]
case intro.intro.intro.intro.intro.intro.intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
Z₀ : Multiset (PrimeSpectrum A)
hZ₀ :
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≤ I ∧ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≠ ⊥
Z : Multiset (PrimeSpectrum A)
h_eraseZ :
∀ (x : Multiset (PrimeSpectrum A)),
(x ∈ fun Z =>
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥) →
¬x < Z
hZI : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
hprodZ : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥
hZ0 : Z ≠ 0
P : PrimeSpectrum A
hPZ : P ∈ Z
hPZ' : P.asIdeal ∈ Multiset.map PrimeSpectrum.asIdeal Z
this :
Multiset.map PrimeSpectrum.asIdeal (Multiset.erase Z P) =
Multiset.erase (Multiset.map PrimeSpectrum.asIdeal Z) P.asIdeal
hP0 : P.asIdeal ≠ ⊥
hZP0 : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal (Multiset.erase Z P)) ≠ ⊥
hIM : I ≤ P.asIdeal
hM : Ideal.IsMaximal P.asIdeal
hZM : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ P.asIdeal
hPM : P.asIdeal ≤ P.asIdeal
⊢ ∃ Z,
Multiset.prod (P.asIdeal ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
[PROOFSTEP]
refine ⟨Z.erase P, ?_, ?_⟩
[GOAL]
case intro.intro.intro.intro.intro.intro.intro.intro.intro.refine_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
Z₀ : Multiset (PrimeSpectrum A)
hZ₀ :
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≤ I ∧ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≠ ⊥
Z : Multiset (PrimeSpectrum A)
h_eraseZ :
∀ (x : Multiset (PrimeSpectrum A)),
(x ∈ fun Z =>
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥) →
¬x < Z
hZI : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
hprodZ : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥
hZ0 : Z ≠ 0
P : PrimeSpectrum A
hPZ : P ∈ Z
hPZ' : P.asIdeal ∈ Multiset.map PrimeSpectrum.asIdeal Z
this :
Multiset.map PrimeSpectrum.asIdeal (Multiset.erase Z P) =
Multiset.erase (Multiset.map PrimeSpectrum.asIdeal Z) P.asIdeal
hP0 : P.asIdeal ≠ ⊥
hZP0 : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal (Multiset.erase Z P)) ≠ ⊥
hIM : I ≤ P.asIdeal
hM : Ideal.IsMaximal P.asIdeal
hZM : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ P.asIdeal
hPM : P.asIdeal ≤ P.asIdeal
⊢ Multiset.prod (P.asIdeal ::ₘ Multiset.map PrimeSpectrum.asIdeal (Multiset.erase Z P)) ≤ I
[PROOFSTEP]
convert hZI
[GOAL]
case h.e'_3.h.e'_3
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
Z₀ : Multiset (PrimeSpectrum A)
hZ₀ :
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≤ I ∧ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≠ ⊥
Z : Multiset (PrimeSpectrum A)
h_eraseZ :
∀ (x : Multiset (PrimeSpectrum A)),
(x ∈ fun Z =>
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥) →
¬x < Z
hZI : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
hprodZ : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥
hZ0 : Z ≠ 0
P : PrimeSpectrum A
hPZ : P ∈ Z
hPZ' : P.asIdeal ∈ Multiset.map PrimeSpectrum.asIdeal Z
this :
Multiset.map PrimeSpectrum.asIdeal (Multiset.erase Z P) =
Multiset.erase (Multiset.map PrimeSpectrum.asIdeal Z) P.asIdeal
hP0 : P.asIdeal ≠ ⊥
hZP0 : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal (Multiset.erase Z P)) ≠ ⊥
hIM : I ≤ P.asIdeal
hM : Ideal.IsMaximal P.asIdeal
hZM : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ P.asIdeal
hPM : P.asIdeal ≤ P.asIdeal
⊢ P.asIdeal ::ₘ Multiset.map PrimeSpectrum.asIdeal (Multiset.erase Z P) = Multiset.map PrimeSpectrum.asIdeal Z
[PROOFSTEP]
rw [this, Multiset.cons_erase hPZ']
[GOAL]
case intro.intro.intro.intro.intro.intro.intro.intro.intro.refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
Z₀ : Multiset (PrimeSpectrum A)
hZ₀ :
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≤ I ∧ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≠ ⊥
Z : Multiset (PrimeSpectrum A)
h_eraseZ :
∀ (x : Multiset (PrimeSpectrum A)),
(x ∈ fun Z =>
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥) →
¬x < Z
hZI : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
hprodZ : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥
hZ0 : Z ≠ 0
P : PrimeSpectrum A
hPZ : P ∈ Z
hPZ' : P.asIdeal ∈ Multiset.map PrimeSpectrum.asIdeal Z
this :
Multiset.map PrimeSpectrum.asIdeal (Multiset.erase Z P) =
Multiset.erase (Multiset.map PrimeSpectrum.asIdeal Z) P.asIdeal
hP0 : P.asIdeal ≠ ⊥
hZP0 : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal (Multiset.erase Z P)) ≠ ⊥
hIM : I ≤ P.asIdeal
hM : Ideal.IsMaximal P.asIdeal
hZM : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ P.asIdeal
hPM : P.asIdeal ≤ P.asIdeal
⊢ ¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal (Multiset.erase Z P)) ≤ I
[PROOFSTEP]
refine fun h => h_eraseZ (Z.erase P) ⟨h, ?_⟩ (Multiset.erase_lt.mpr hPZ)
[GOAL]
case intro.intro.intro.intro.intro.intro.intro.intro.intro.refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
Z₀ : Multiset (PrimeSpectrum A)
hZ₀ :
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≤ I ∧ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z₀) ≠ ⊥
Z : Multiset (PrimeSpectrum A)
h_eraseZ :
∀ (x : Multiset (PrimeSpectrum A)),
(x ∈ fun Z =>
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I ∧
Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥) →
¬x < Z
hZI : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ I
hprodZ : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≠ ⊥
hZ0 : Z ≠ 0
P : PrimeSpectrum A
hPZ : P ∈ Z
hPZ' : P.asIdeal ∈ Multiset.map PrimeSpectrum.asIdeal Z
this :
Multiset.map PrimeSpectrum.asIdeal (Multiset.erase Z P) =
Multiset.erase (Multiset.map PrimeSpectrum.asIdeal Z) P.asIdeal
hP0 : P.asIdeal ≠ ⊥
hZP0 : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal (Multiset.erase Z P)) ≠ ⊥
hIM : I ≤ P.asIdeal
hM : Ideal.IsMaximal P.asIdeal
hZM : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ P.asIdeal
hPM : P.asIdeal ≤ P.asIdeal
h : Multiset.prod (Multiset.map PrimeSpectrum.asIdeal (Multiset.erase Z P)) ≤ I
⊢ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal (Multiset.erase Z P)) ≠ ⊥
[PROOFSTEP]
exact hZP0
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
⊢ ∃ x, x ∈ (↑I)⁻¹ ∧ ¬x ∈ 1
[PROOFSTEP]
suffices ∀ {M : Ideal A} (_hM : M.IsMaximal), ∃ x : K, x ∈ (M⁻¹ : FractionalIdeal A⁰ K) ∧ x ∉ (1 : FractionalIdeal A⁰ K)
by
obtain ⟨M, hM, hIM⟩ : ∃ M : Ideal A, IsMaximal M ∧ I ≤ M := Ideal.exists_le_maximal I hI1
skip
have hM0 := (M.bot_lt_of_maximal hNF).ne'
obtain ⟨x, hxM, hx1⟩ := this hM
refine ⟨x, inv_anti_mono ?_ ?_ ((coeIdeal_le_coeIdeal _).mpr hIM) hxM, hx1⟩ <;> rw [coeIdeal_ne_zero] <;>
assumption
-- Let `a` be a nonzero element of `M` and `J` the ideal generated by `a`.
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
this : ∀ {M : Ideal A}, IsMaximal M → ∃ x, x ∈ (↑M)⁻¹ ∧ ¬x ∈ 1
⊢ ∃ x, x ∈ (↑I)⁻¹ ∧ ¬x ∈ 1
[PROOFSTEP]
obtain ⟨M, hM, hIM⟩ : ∃ M : Ideal A, IsMaximal M ∧ I ≤ M := Ideal.exists_le_maximal I hI1
[GOAL]
case intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
this : ∀ {M : Ideal A}, IsMaximal M → ∃ x, x ∈ (↑M)⁻¹ ∧ ¬x ∈ 1
M : Ideal A
hM : IsMaximal M
hIM : I ≤ M
⊢ ∃ x, x ∈ (↑I)⁻¹ ∧ ¬x ∈ 1
[PROOFSTEP]
skip
[GOAL]
case intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
this : ∀ {M : Ideal A}, IsMaximal M → ∃ x, x ∈ (↑M)⁻¹ ∧ ¬x ∈ 1
M : Ideal A
hM : IsMaximal M
hIM : I ≤ M
⊢ ∃ x, x ∈ (↑I)⁻¹ ∧ ¬x ∈ 1
[PROOFSTEP]
have hM0 := (M.bot_lt_of_maximal hNF).ne'
[GOAL]
case intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
this : ∀ {M : Ideal A}, IsMaximal M → ∃ x, x ∈ (↑M)⁻¹ ∧ ¬x ∈ 1
M : Ideal A
hM : IsMaximal M
hIM : I ≤ M
hM0 : M ≠ ⊥
⊢ ∃ x, x ∈ (↑I)⁻¹ ∧ ¬x ∈ 1
[PROOFSTEP]
obtain ⟨x, hxM, hx1⟩ := this hM
[GOAL]
case intro.intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
this : ∀ {M : Ideal A}, IsMaximal M → ∃ x, x ∈ (↑M)⁻¹ ∧ ¬x ∈ 1
M : Ideal A
hM : IsMaximal M
hIM : I ≤ M
hM0 : M ≠ ⊥
x : K
hxM : x ∈ (↑M)⁻¹
hx1 : ¬x ∈ 1
⊢ ∃ x, x ∈ (↑I)⁻¹ ∧ ¬x ∈ 1
[PROOFSTEP]
refine ⟨x, inv_anti_mono ?_ ?_ ((coeIdeal_le_coeIdeal _).mpr hIM) hxM, hx1⟩
[GOAL]
case intro.intro.intro.intro.refine_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
this : ∀ {M : Ideal A}, IsMaximal M → ∃ x, x ∈ (↑M)⁻¹ ∧ ¬x ∈ 1
M : Ideal A
hM : IsMaximal M
hIM : I ≤ M
hM0 : M ≠ ⊥
x : K
hxM : x ∈ (↑M)⁻¹
hx1 : ¬x ∈ 1
⊢ ↑I ≠ 0
[PROOFSTEP]
rw [coeIdeal_ne_zero]
[GOAL]
case intro.intro.intro.intro.refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
this : ∀ {M : Ideal A}, IsMaximal M → ∃ x, x ∈ (↑M)⁻¹ ∧ ¬x ∈ 1
M : Ideal A
hM : IsMaximal M
hIM : I ≤ M
hM0 : M ≠ ⊥
x : K
hxM : x ∈ (↑M)⁻¹
hx1 : ¬x ∈ 1
⊢ ↑M ≠ 0
[PROOFSTEP]
rw [coeIdeal_ne_zero]
[GOAL]
case intro.intro.intro.intro.refine_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
this : ∀ {M : Ideal A}, IsMaximal M → ∃ x, x ∈ (↑M)⁻¹ ∧ ¬x ∈ 1
M : Ideal A
hM : IsMaximal M
hIM : I ≤ M
hM0 : M ≠ ⊥
x : K
hxM : x ∈ (↑M)⁻¹
hx1 : ¬x ∈ 1
⊢ I ≠ ⊥
[PROOFSTEP]
assumption
-- Let `a` be a nonzero element of `M` and `J` the ideal generated by `a`.
[GOAL]
case intro.intro.intro.intro.refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
this : ∀ {M : Ideal A}, IsMaximal M → ∃ x, x ∈ (↑M)⁻¹ ∧ ¬x ∈ 1
M : Ideal A
hM : IsMaximal M
hIM : I ≤ M
hM0 : M ≠ ⊥
x : K
hxM : x ∈ (↑M)⁻¹
hx1 : ¬x ∈ 1
⊢ M ≠ ⊥
[PROOFSTEP]
assumption
-- Let `a` be a nonzero element of `M` and `J` the ideal generated by `a`.
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
⊢ ∀ {M : Ideal A}, IsMaximal M → ∃ x, x ∈ (↑M)⁻¹ ∧ ¬x ∈ 1
[PROOFSTEP]
intro M hM
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
⊢ ∃ x, x ∈ (↑M)⁻¹ ∧ ¬x ∈ 1
[PROOFSTEP]
skip
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
⊢ ∃ x, x ∈ (↑M)⁻¹ ∧ ¬x ∈ 1
[PROOFSTEP]
obtain ⟨⟨a, haM⟩, ha0⟩ := Submodule.nonzero_mem_of_bot_lt (M.bot_lt_of_maximal hNF)
[GOAL]
case intro.mk
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
a : A
haM : a ∈ M
ha0 : { val := a, property := haM } ≠ 0
⊢ ∃ x, x ∈ (↑M)⁻¹ ∧ ¬x ∈ 1
[PROOFSTEP]
replace ha0 : a ≠ 0 := Subtype.coe_injective.ne ha0
[GOAL]
case intro.mk
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
a : A
haM : a ∈ M
ha0 : a ≠ 0
⊢ ∃ x, x ∈ (↑M)⁻¹ ∧ ¬x ∈ 1
[PROOFSTEP]
let J : Ideal A := Ideal.span { a }
[GOAL]
case intro.mk
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
a : A
haM : a ∈ M
ha0 : a ≠ 0
J : Ideal A := span {a}
⊢ ∃ x, x ∈ (↑M)⁻¹ ∧ ¬x ∈ 1
[PROOFSTEP]
have hJ0 : J ≠ ⊥ := mt Ideal.span_singleton_eq_bot.mp ha0
[GOAL]
case intro.mk
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
a : A
haM : a ∈ M
ha0 : a ≠ 0
J : Ideal A := span {a}
hJ0 : J ≠ ⊥
⊢ ∃ x, x ∈ (↑M)⁻¹ ∧ ¬x ∈ 1
[PROOFSTEP]
have hJM : J ≤ M := Ideal.span_le.mpr (Set.singleton_subset_iff.mpr haM)
[GOAL]
case intro.mk
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
a : A
haM : a ∈ M
ha0 : a ≠ 0
J : Ideal A := span {a}
hJ0 : J ≠ ⊥
hJM : J ≤ M
⊢ ∃ x, x ∈ (↑M)⁻¹ ∧ ¬x ∈ 1
[PROOFSTEP]
have hM0 : ⊥ < M := M.bot_lt_of_maximal hNF
[GOAL]
case intro.mk
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
a : A
haM : a ∈ M
ha0 : a ≠ 0
J : Ideal A := span {a}
hJ0 : J ≠ ⊥
hJM : J ≤ M
hM0 : ⊥ < M
⊢ ∃ x, x ∈ (↑M)⁻¹ ∧ ¬x ∈ 1
[PROOFSTEP]
obtain ⟨Z, hle, hnle⟩ := exists_multiset_prod_cons_le_and_prod_not_le hNF hJ0 hJM
[GOAL]
case intro.mk.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
a : A
haM : a ∈ M
ha0 : a ≠ 0
J : Ideal A := span {a}
hJ0 : J ≠ ⊥
hJM : J ≤ M
hM0 : ⊥ < M
Z : Multiset (PrimeSpectrum A)
hle : Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
hnle : ¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
⊢ ∃ x, x ∈ (↑M)⁻¹ ∧ ¬x ∈ 1
[PROOFSTEP]
obtain ⟨b, hbZ, hbJ⟩ := SetLike.not_le_iff_exists.mp hnle
[GOAL]
case intro.mk.intro.intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
a : A
haM : a ∈ M
ha0 : a ≠ 0
J : Ideal A := span {a}
hJ0 : J ≠ ⊥
hJM : J ≤ M
hM0 : ⊥ < M
Z : Multiset (PrimeSpectrum A)
hle : Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
hnle : ¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
b : A
hbZ : b ∈ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z)
hbJ : ¬b ∈ J
⊢ ∃ x, x ∈ (↑M)⁻¹ ∧ ¬x ∈ 1
[PROOFSTEP]
have hnz_fa : algebraMap A K a ≠ 0 := mt ((injective_iff_map_eq_zero _).mp (IsFractionRing.injective A K) a) ha0
[GOAL]
case intro.mk.intro.intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
a : A
haM : a ∈ M
ha0 : a ≠ 0
J : Ideal A := span {a}
hJ0 : J ≠ ⊥
hJM : J ≤ M
hM0 : ⊥ < M
Z : Multiset (PrimeSpectrum A)
hle : Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
hnle : ¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
b : A
hbZ : b ∈ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z)
hbJ : ¬b ∈ J
hnz_fa : ↑(algebraMap A K) a ≠ 0
⊢ ∃ x, x ∈ (↑M)⁻¹ ∧ ¬x ∈ 1
[PROOFSTEP]
have _hb0 : algebraMap A K b ≠ 0 :=
mt ((injective_iff_map_eq_zero _).mp (IsFractionRing.injective A K) b) fun h => hbJ <| h.symm ▸ J.zero_mem
[GOAL]
case intro.mk.intro.intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
a : A
haM : a ∈ M
ha0 : a ≠ 0
J : Ideal A := span {a}
hJ0 : J ≠ ⊥
hJM : J ≤ M
hM0 : ⊥ < M
Z : Multiset (PrimeSpectrum A)
hle : Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
hnle : ¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
b : A
hbZ : b ∈ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z)
hbJ : ¬b ∈ J
hnz_fa : ↑(algebraMap A K) a ≠ 0
_hb0 : ↑(algebraMap A K) b ≠ 0
⊢ ∃ x, x ∈ (↑M)⁻¹ ∧ ¬x ∈ 1
[PROOFSTEP]
refine' ⟨algebraMap A K b * (algebraMap A K a)⁻¹, (mem_inv_iff _).mpr _, _⟩
[GOAL]
case intro.mk.intro.intro.intro.intro.refine'_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
a : A
haM : a ∈ M
ha0 : a ≠ 0
J : Ideal A := span {a}
hJ0 : J ≠ ⊥
hJM : J ≤ M
hM0 : ⊥ < M
Z : Multiset (PrimeSpectrum A)
hle : Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
hnle : ¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
b : A
hbZ : b ∈ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z)
hbJ : ¬b ∈ J
hnz_fa : ↑(algebraMap A K) a ≠ 0
_hb0 : ↑(algebraMap A K) b ≠ 0
⊢ ↑M ≠ 0
[PROOFSTEP]
exact coeIdeal_ne_zero.mpr hM0.ne'
[GOAL]
case intro.mk.intro.intro.intro.intro.refine'_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
a : A
haM : a ∈ M
ha0 : a ≠ 0
J : Ideal A := span {a}
hJ0 : J ≠ ⊥
hJM : J ≤ M
hM0 : ⊥ < M
Z : Multiset (PrimeSpectrum A)
hle : Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
hnle : ¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
b : A
hbZ : b ∈ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z)
hbJ : ¬b ∈ J
hnz_fa : ↑(algebraMap A K) a ≠ 0
_hb0 : ↑(algebraMap A K) b ≠ 0
⊢ ∀ (y : K), y ∈ ↑M → ↑(algebraMap A K) b * (↑(algebraMap A K) a)⁻¹ * y ∈ 1
[PROOFSTEP]
rintro y₀ hy₀
[GOAL]
case intro.mk.intro.intro.intro.intro.refine'_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
a : A
haM : a ∈ M
ha0 : a ≠ 0
J : Ideal A := span {a}
hJ0 : J ≠ ⊥
hJM : J ≤ M
hM0 : ⊥ < M
Z : Multiset (PrimeSpectrum A)
hle : Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
hnle : ¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
b : A
hbZ : b ∈ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z)
hbJ : ¬b ∈ J
hnz_fa : ↑(algebraMap A K) a ≠ 0
_hb0 : ↑(algebraMap A K) b ≠ 0
y₀ : K
hy₀ : y₀ ∈ ↑M
⊢ ↑(algebraMap A K) b * (↑(algebraMap A K) a)⁻¹ * y₀ ∈ 1
[PROOFSTEP]
obtain ⟨y, h_Iy, rfl⟩ := (mem_coeIdeal _).mp hy₀
[GOAL]
case intro.mk.intro.intro.intro.intro.refine'_2.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
a : A
haM : a ∈ M
ha0 : a ≠ 0
J : Ideal A := span {a}
hJ0 : J ≠ ⊥
hJM : J ≤ M
hM0 : ⊥ < M
Z : Multiset (PrimeSpectrum A)
hle : Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
hnle : ¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
b : A
hbZ : b ∈ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z)
hbJ : ¬b ∈ J
hnz_fa : ↑(algebraMap A K) a ≠ 0
_hb0 : ↑(algebraMap A K) b ≠ 0
y : A
h_Iy : y ∈ M
hy₀ : ↑(algebraMap A K) y ∈ ↑M
⊢ ↑(algebraMap A K) b * (↑(algebraMap A K) a)⁻¹ * ↑(algebraMap A K) y ∈ 1
[PROOFSTEP]
rw [mul_comm, ← mul_assoc, ← RingHom.map_mul]
[GOAL]
case intro.mk.intro.intro.intro.intro.refine'_2.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
a : A
haM : a ∈ M
ha0 : a ≠ 0
J : Ideal A := span {a}
hJ0 : J ≠ ⊥
hJM : J ≤ M
hM0 : ⊥ < M
Z : Multiset (PrimeSpectrum A)
hle : Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
hnle : ¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
b : A
hbZ : b ∈ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z)
hbJ : ¬b ∈ J
hnz_fa : ↑(algebraMap A K) a ≠ 0
_hb0 : ↑(algebraMap A K) b ≠ 0
y : A
h_Iy : y ∈ M
hy₀ : ↑(algebraMap A K) y ∈ ↑M
⊢ ↑(algebraMap A K) (y * b) * (↑(algebraMap A K) a)⁻¹ ∈ 1
[PROOFSTEP]
have h_yb : y * b ∈ J := by
apply hle
rw [Multiset.prod_cons]
exact Submodule.smul_mem_smul h_Iy hbZ
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
a : A
haM : a ∈ M
ha0 : a ≠ 0
J : Ideal A := span {a}
hJ0 : J ≠ ⊥
hJM : J ≤ M
hM0 : ⊥ < M
Z : Multiset (PrimeSpectrum A)
hle : Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
hnle : ¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
b : A
hbZ : b ∈ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z)
hbJ : ¬b ∈ J
hnz_fa : ↑(algebraMap A K) a ≠ 0
_hb0 : ↑(algebraMap A K) b ≠ 0
y : A
h_Iy : y ∈ M
hy₀ : ↑(algebraMap A K) y ∈ ↑M
⊢ y * b ∈ J
[PROOFSTEP]
apply hle
[GOAL]
case a
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
a : A
haM : a ∈ M
ha0 : a ≠ 0
J : Ideal A := span {a}
hJ0 : J ≠ ⊥
hJM : J ≤ M
hM0 : ⊥ < M
Z : Multiset (PrimeSpectrum A)
hle : Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
hnle : ¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
b : A
hbZ : b ∈ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z)
hbJ : ¬b ∈ J
hnz_fa : ↑(algebraMap A K) a ≠ 0
_hb0 : ↑(algebraMap A K) b ≠ 0
y : A
h_Iy : y ∈ M
hy₀ : ↑(algebraMap A K) y ∈ ↑M
⊢ y * b ∈ Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z)
[PROOFSTEP]
rw [Multiset.prod_cons]
[GOAL]
case a
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
a : A
haM : a ∈ M
ha0 : a ≠ 0
J : Ideal A := span {a}
hJ0 : J ≠ ⊥
hJM : J ≤ M
hM0 : ⊥ < M
Z : Multiset (PrimeSpectrum A)
hle : Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
hnle : ¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
b : A
hbZ : b ∈ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z)
hbJ : ¬b ∈ J
hnz_fa : ↑(algebraMap A K) a ≠ 0
_hb0 : ↑(algebraMap A K) b ≠ 0
y : A
h_Iy : y ∈ M
hy₀ : ↑(algebraMap A K) y ∈ ↑M
⊢ y * b ∈ M * Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z)
[PROOFSTEP]
exact Submodule.smul_mem_smul h_Iy hbZ
[GOAL]
case intro.mk.intro.intro.intro.intro.refine'_2.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
a : A
haM : a ∈ M
ha0 : a ≠ 0
J : Ideal A := span {a}
hJ0 : J ≠ ⊥
hJM : J ≤ M
hM0 : ⊥ < M
Z : Multiset (PrimeSpectrum A)
hle : Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
hnle : ¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
b : A
hbZ : b ∈ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z)
hbJ : ¬b ∈ J
hnz_fa : ↑(algebraMap A K) a ≠ 0
_hb0 : ↑(algebraMap A K) b ≠ 0
y : A
h_Iy : y ∈ M
hy₀ : ↑(algebraMap A K) y ∈ ↑M
h_yb : y * b ∈ J
⊢ ↑(algebraMap A K) (y * b) * (↑(algebraMap A K) a)⁻¹ ∈ 1
[PROOFSTEP]
rw [Ideal.mem_span_singleton'] at h_yb
[GOAL]
case intro.mk.intro.intro.intro.intro.refine'_2.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
a : A
haM : a ∈ M
ha0 : a ≠ 0
J : Ideal A := span {a}
hJ0 : J ≠ ⊥
hJM : J ≤ M
hM0 : ⊥ < M
Z : Multiset (PrimeSpectrum A)
hle : Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
hnle : ¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
b : A
hbZ : b ∈ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z)
hbJ : ¬b ∈ J
hnz_fa : ↑(algebraMap A K) a ≠ 0
_hb0 : ↑(algebraMap A K) b ≠ 0
y : A
h_Iy : y ∈ M
hy₀ : ↑(algebraMap A K) y ∈ ↑M
h_yb : ∃ a_1, a_1 * a = y * b
⊢ ↑(algebraMap A K) (y * b) * (↑(algebraMap A K) a)⁻¹ ∈ 1
[PROOFSTEP]
rcases h_yb with ⟨c, hc⟩
[GOAL]
case intro.mk.intro.intro.intro.intro.refine'_2.intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
a : A
haM : a ∈ M
ha0 : a ≠ 0
J : Ideal A := span {a}
hJ0 : J ≠ ⊥
hJM : J ≤ M
hM0 : ⊥ < M
Z : Multiset (PrimeSpectrum A)
hle : Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
hnle : ¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
b : A
hbZ : b ∈ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z)
hbJ : ¬b ∈ J
hnz_fa : ↑(algebraMap A K) a ≠ 0
_hb0 : ↑(algebraMap A K) b ≠ 0
y : A
h_Iy : y ∈ M
hy₀ : ↑(algebraMap A K) y ∈ ↑M
c : A
hc : c * a = y * b
⊢ ↑(algebraMap A K) (y * b) * (↑(algebraMap A K) a)⁻¹ ∈ 1
[PROOFSTEP]
rw [← hc, RingHom.map_mul, mul_assoc, mul_inv_cancel hnz_fa, mul_one]
[GOAL]
case intro.mk.intro.intro.intro.intro.refine'_2.intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
a : A
haM : a ∈ M
ha0 : a ≠ 0
J : Ideal A := span {a}
hJ0 : J ≠ ⊥
hJM : J ≤ M
hM0 : ⊥ < M
Z : Multiset (PrimeSpectrum A)
hle : Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
hnle : ¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
b : A
hbZ : b ∈ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z)
hbJ : ¬b ∈ J
hnz_fa : ↑(algebraMap A K) a ≠ 0
_hb0 : ↑(algebraMap A K) b ≠ 0
y : A
h_Iy : y ∈ M
hy₀ : ↑(algebraMap A K) y ∈ ↑M
c : A
hc : c * a = y * b
⊢ ↑(algebraMap A K) c ∈ 1
[PROOFSTEP]
apply coe_mem_one
[GOAL]
case intro.mk.intro.intro.intro.intro.refine'_3
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
a : A
haM : a ∈ M
ha0 : a ≠ 0
J : Ideal A := span {a}
hJ0 : J ≠ ⊥
hJM : J ≤ M
hM0 : ⊥ < M
Z : Multiset (PrimeSpectrum A)
hle : Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
hnle : ¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
b : A
hbZ : b ∈ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z)
hbJ : ¬b ∈ J
hnz_fa : ↑(algebraMap A K) a ≠ 0
_hb0 : ↑(algebraMap A K) b ≠ 0
⊢ ¬↑(algebraMap A K) b * (↑(algebraMap A K) a)⁻¹ ∈ 1
[PROOFSTEP]
refine' mt (mem_one_iff _).mp _
[GOAL]
case intro.mk.intro.intro.intro.intro.refine'_3
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
a : A
haM : a ∈ M
ha0 : a ≠ 0
J : Ideal A := span {a}
hJ0 : J ≠ ⊥
hJM : J ≤ M
hM0 : ⊥ < M
Z : Multiset (PrimeSpectrum A)
hle : Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
hnle : ¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
b : A
hbZ : b ∈ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z)
hbJ : ¬b ∈ J
hnz_fa : ↑(algebraMap A K) a ≠ 0
_hb0 : ↑(algebraMap A K) b ≠ 0
⊢ ¬∃ x', ↑(algebraMap A K) x' = ↑(algebraMap A K) b * (↑(algebraMap A K) a)⁻¹
[PROOFSTEP]
rintro ⟨x', h₂_abs⟩
[GOAL]
case intro.mk.intro.intro.intro.intro.refine'_3.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
a : A
haM : a ∈ M
ha0 : a ≠ 0
J : Ideal A := span {a}
hJ0 : J ≠ ⊥
hJM : J ≤ M
hM0 : ⊥ < M
Z : Multiset (PrimeSpectrum A)
hle : Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
hnle : ¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
b : A
hbZ : b ∈ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z)
hbJ : ¬b ∈ J
hnz_fa : ↑(algebraMap A K) a ≠ 0
_hb0 : ↑(algebraMap A K) b ≠ 0
x' : A
h₂_abs : ↑(algebraMap A K) x' = ↑(algebraMap A K) b * (↑(algebraMap A K) a)⁻¹
⊢ False
[PROOFSTEP]
rw [← div_eq_mul_inv, eq_div_iff_mul_eq hnz_fa, ← RingHom.map_mul] at h₂_abs
[GOAL]
case intro.mk.intro.intro.intro.intro.refine'_3.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
a : A
haM : a ∈ M
ha0 : a ≠ 0
J : Ideal A := span {a}
hJ0 : J ≠ ⊥
hJM : J ≤ M
hM0 : ⊥ < M
Z : Multiset (PrimeSpectrum A)
hle : Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
hnle : ¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
b : A
hbZ : b ∈ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z)
hbJ : ¬b ∈ J
hnz_fa : ↑(algebraMap A K) a ≠ 0
_hb0 : ↑(algebraMap A K) b ≠ 0
x' : A
h₂_abs : ↑(algebraMap A K) (x' * a) = ↑(algebraMap A K) b
⊢ False
[PROOFSTEP]
have := Ideal.mem_span_singleton'.mpr ⟨x', IsFractionRing.injective A K h₂_abs⟩
[GOAL]
case intro.mk.intro.intro.intro.intro.refine'_3.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
hNF : ¬IsField A
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
M : Ideal A
hM : IsMaximal M
a : A
haM : a ∈ M
ha0 : a ≠ 0
J : Ideal A := span {a}
hJ0 : J ≠ ⊥
hJM : J ≤ M
hM0 : ⊥ < M
Z : Multiset (PrimeSpectrum A)
hle : Multiset.prod (M ::ₘ Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
hnle : ¬Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z) ≤ J
b : A
hbZ : b ∈ Multiset.prod (Multiset.map PrimeSpectrum.asIdeal Z)
hbJ : ¬b ∈ J
hnz_fa : ↑(algebraMap A K) a ≠ 0
_hb0 : ↑(algebraMap A K) b ≠ 0
x' : A
h₂_abs : ↑(algebraMap A K) (x' * a) = ↑(algebraMap A K) b
this : b ∈ span {a}
⊢ False
[PROOFSTEP]
contradiction
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I : Ideal A
hI : I ≠ ⊥
⊢ 1 ∈ (↑I)⁻¹
[PROOFSTEP]
rw [mem_inv_iff (coeIdeal_ne_zero.mpr hI)]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I : Ideal A
hI : I ≠ ⊥
⊢ ∀ (y : K), y ∈ ↑I → 1 * y ∈ 1
[PROOFSTEP]
intro y hy
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I : Ideal A
hI : I ≠ ⊥
y : K
hy : y ∈ ↑I
⊢ 1 * y ∈ 1
[PROOFSTEP]
rw [one_mul]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I : Ideal A
hI : I ≠ ⊥
y : K
hy : y ∈ ↑I
⊢ y ∈ 1
[PROOFSTEP]
exact coeIdeal_le_one hy
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hI : (↑I * (↑I)⁻¹)⁻¹ ≤ 1
⊢ ↑I * (↑I)⁻¹ = 1
[PROOFSTEP]
by_cases hI1 : I = ⊤
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hI : (↑I * (↑I)⁻¹)⁻¹ ≤ 1
hI1 : I = ⊤
⊢ ↑I * (↑I)⁻¹ = 1
[PROOFSTEP]
rw [hI1, coeIdeal_top, one_mul, inv_one]
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hI : (↑I * (↑I)⁻¹)⁻¹ ≤ 1
hI1 : ¬I = ⊤
⊢ ↑I * (↑I)⁻¹ = 1
[PROOFSTEP]
by_cases hNF : IsField A
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hI : (↑I * (↑I)⁻¹)⁻¹ ≤ 1
hI1 : ¬I = ⊤
hNF : IsField A
⊢ ↑I * (↑I)⁻¹ = 1
[PROOFSTEP]
letI := hNF.toField
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hI : (↑I * (↑I)⁻¹)⁻¹ ≤ 1
hI1 : ¬I = ⊤
hNF : IsField A
this : Field A := IsField.toField hNF
⊢ ↑I * (↑I)⁻¹ = 1
[PROOFSTEP]
rcases hI1 (I.eq_bot_or_top.resolve_left hI0) with
⟨⟩
-- We'll show a contradiction with `exists_not_mem_one_of_ne_bot`:
-- `J⁻¹ = (I * I⁻¹)⁻¹` cannot have an element `x ∉ 1`, so it must equal `1`.
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hI : (↑I * (↑I)⁻¹)⁻¹ ≤ 1
hI1 : ¬I = ⊤
hNF : ¬IsField A
⊢ ↑I * (↑I)⁻¹ = 1
[PROOFSTEP]
obtain ⟨J, hJ⟩ : ∃ J : Ideal A, (J : FractionalIdeal A⁰ K) = I * (I : FractionalIdeal A⁰ K)⁻¹ :=
le_one_iff_exists_coeIdeal.mp mul_one_div_le_one
[GOAL]
case neg.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hI : (↑I * (↑I)⁻¹)⁻¹ ≤ 1
hI1 : ¬I = ⊤
hNF : ¬IsField A
J : Ideal A
hJ : ↑J = ↑I * (↑I)⁻¹
⊢ ↑I * (↑I)⁻¹ = 1
[PROOFSTEP]
by_cases hJ0 : J = ⊥
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hI : (↑I * (↑I)⁻¹)⁻¹ ≤ 1
hI1 : ¬I = ⊤
hNF : ¬IsField A
J : Ideal A
hJ : ↑J = ↑I * (↑I)⁻¹
hJ0 : J = ⊥
⊢ ↑I * (↑I)⁻¹ = 1
[PROOFSTEP]
subst hJ0
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hI : (↑I * (↑I)⁻¹)⁻¹ ≤ 1
hI1 : ¬I = ⊤
hNF : ¬IsField A
hJ : ↑⊥ = ↑I * (↑I)⁻¹
⊢ ↑I * (↑I)⁻¹ = 1
[PROOFSTEP]
refine' absurd _ hI0
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hI : (↑I * (↑I)⁻¹)⁻¹ ≤ 1
hI1 : ¬I = ⊤
hNF : ¬IsField A
hJ : ↑⊥ = ↑I * (↑I)⁻¹
⊢ I = ⊥
[PROOFSTEP]
rw [eq_bot_iff, ← coeIdeal_le_coeIdeal K, hJ]
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hI : (↑I * (↑I)⁻¹)⁻¹ ≤ 1
hI1 : ¬I = ⊤
hNF : ¬IsField A
hJ : ↑⊥ = ↑I * (↑I)⁻¹
⊢ ↑I ≤ ↑I * (↑I)⁻¹
[PROOFSTEP]
exact coe_ideal_le_self_mul_inv K I
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hI : (↑I * (↑I)⁻¹)⁻¹ ≤ 1
hI1 : ¬I = ⊤
hNF : ¬IsField A
J : Ideal A
hJ : ↑J = ↑I * (↑I)⁻¹
hJ0 : ¬J = ⊥
⊢ ↑I * (↑I)⁻¹ = 1
[PROOFSTEP]
by_cases hJ1 : J = ⊤
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hI : (↑I * (↑I)⁻¹)⁻¹ ≤ 1
hI1 : ¬I = ⊤
hNF : ¬IsField A
J : Ideal A
hJ : ↑J = ↑I * (↑I)⁻¹
hJ0 : ¬J = ⊥
hJ1 : J = ⊤
⊢ ↑I * (↑I)⁻¹ = 1
[PROOFSTEP]
rw [← hJ, hJ1, coeIdeal_top]
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hI : (↑I * (↑I)⁻¹)⁻¹ ≤ 1
hI1 : ¬I = ⊤
hNF : ¬IsField A
J : Ideal A
hJ : ↑J = ↑I * (↑I)⁻¹
hJ0 : ¬J = ⊥
hJ1 : ¬J = ⊤
⊢ ↑I * (↑I)⁻¹ = 1
[PROOFSTEP]
obtain ⟨x, hx, hx1⟩ : ∃ x : K, x ∈ (J : FractionalIdeal A⁰ K)⁻¹ ∧ x ∉ (1 : FractionalIdeal A⁰ K) :=
exists_not_mem_one_of_ne_bot hNF hJ0 hJ1
[GOAL]
case neg.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hI : (↑I * (↑I)⁻¹)⁻¹ ≤ 1
hI1 : ¬I = ⊤
hNF : ¬IsField A
J : Ideal A
hJ : ↑J = ↑I * (↑I)⁻¹
hJ0 : ¬J = ⊥
hJ1 : ¬J = ⊤
x : K
hx : x ∈ (↑J)⁻¹
hx1 : ¬x ∈ 1
⊢ ↑I * (↑I)⁻¹ = 1
[PROOFSTEP]
contrapose! hx1 with h_abs
[GOAL]
case neg.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hI : (↑I * (↑I)⁻¹)⁻¹ ≤ 1
hI1 : ¬I = ⊤
hNF : ¬IsField A
J : Ideal A
hJ : ↑J = ↑I * (↑I)⁻¹
hJ0 : ¬J = ⊥
hJ1 : ¬J = ⊤
x : K
hx : x ∈ (↑J)⁻¹
h_abs : ↑I * (↑I)⁻¹ ≠ 1
⊢ x ∈ 1
[PROOFSTEP]
rw [hJ] at hx
[GOAL]
case neg.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hI : (↑I * (↑I)⁻¹)⁻¹ ≤ 1
hI1 : ¬I = ⊤
hNF : ¬IsField A
J : Ideal A
hJ : ↑J = ↑I * (↑I)⁻¹
hJ0 : ¬J = ⊥
hJ1 : ¬J = ⊤
x : K
hx : x ∈ (↑I * (↑I)⁻¹)⁻¹
h_abs : ↑I * (↑I)⁻¹ ≠ 1
⊢ x ∈ 1
[PROOFSTEP]
exact hI hx
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
⊢ ↑I * (↑I)⁻¹ = 1
[PROOFSTEP]
apply mul_inv_cancel_of_le_one hI0
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
⊢ (↑I * (↑I)⁻¹)⁻¹ ≤ 1
[PROOFSTEP]
by_cases hJ0 : I * (I : FractionalIdeal A⁰ K)⁻¹ = 0
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ↑I * (↑I)⁻¹ = 0
⊢ (↑I * (↑I)⁻¹)⁻¹ ≤ 1
[PROOFSTEP]
rw [hJ0, inv_zero']
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ↑I * (↑I)⁻¹ = 0
⊢ 0 ≤ 1
[PROOFSTEP]
exact zero_le _
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
⊢ (↑I * (↑I)⁻¹)⁻¹ ≤ 1
[PROOFSTEP]
intro x hx
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : x ∈ (fun a => ↑a) (↑I * (↑I)⁻¹)⁻¹
⊢ x ∈ (fun a => ↑a) 1
[PROOFSTEP]
suffices x ∈ integralClosure A K by
rwa [IsIntegrallyClosed.integralClosure_eq_bot, Algebra.mem_bot, Set.mem_range, ← mem_one_iff] at this
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : x ∈ (fun a => ↑a) (↑I * (↑I)⁻¹)⁻¹
this : x ∈ integralClosure A K
⊢ x ∈ (fun a => ↑a) 1
[PROOFSTEP]
rwa [IsIntegrallyClosed.integralClosure_eq_bot, Algebra.mem_bot, Set.mem_range, ← mem_one_iff] at this
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : x ∈ (fun a => ↑a) (↑I * (↑I)⁻¹)⁻¹
⊢ x ∈ integralClosure A K
[PROOFSTEP]
rw [mem_integralClosure_iff_mem_FG]
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : x ∈ (fun a => ↑a) (↑I * (↑I)⁻¹)⁻¹
⊢ ∃ M, Submodule.FG (↑Subalgebra.toSubmodule M) ∧ x ∈ M
[PROOFSTEP]
have x_mul_mem : ∀ b ∈ (I⁻¹ : FractionalIdeal A⁰ K), x * b ∈ (I⁻¹ : FractionalIdeal A⁰ K) :=
by
intro b hb
rw [mem_inv_iff]
dsimp only at hx
rw [val_eq_coe, mem_coe, mem_inv_iff] at hx
swap; · exact hJ0
swap; · exact coeIdeal_ne_zero.mpr hI0
simp only [mul_assoc, mul_comm b] at hx ⊢
intro y hy
exact
hx _
(mul_mem_mul hy hb)
-- It turns out the subalgebra consisting of all `p(x)` for `p : A[X]` works.
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : x ∈ (fun a => ↑a) (↑I * (↑I)⁻¹)⁻¹
⊢ ∀ (b : K), b ∈ (↑I)⁻¹ → x * b ∈ (↑I)⁻¹
[PROOFSTEP]
intro b hb
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : x ∈ (fun a => ↑a) (↑I * (↑I)⁻¹)⁻¹
b : K
hb : b ∈ (↑I)⁻¹
⊢ x * b ∈ (↑I)⁻¹
[PROOFSTEP]
rw [mem_inv_iff]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : x ∈ (fun a => ↑a) (↑I * (↑I)⁻¹)⁻¹
b : K
hb : b ∈ (↑I)⁻¹
⊢ ∀ (y : K), y ∈ ↑I → x * b * y ∈ 1
case hI
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : x ∈ (fun a => ↑a) (↑I * (↑I)⁻¹)⁻¹
b : K
hb : b ∈ (↑I)⁻¹
⊢ ↑I ≠ 0
[PROOFSTEP]
dsimp only at hx
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : x ∈ ↑(↑I * (↑I)⁻¹)⁻¹
b : K
hb : b ∈ (↑I)⁻¹
⊢ ∀ (y : K), y ∈ ↑I → x * b * y ∈ 1
case hI
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : x ∈ (fun a => ↑a) (↑I * (↑I)⁻¹)⁻¹
b : K
hb : b ∈ (↑I)⁻¹
⊢ ↑I ≠ 0
[PROOFSTEP]
rw [val_eq_coe, mem_coe, mem_inv_iff] at hx
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : ∀ (y : K), y ∈ ↑I * (↑I)⁻¹ → x * y ∈ 1
b : K
hb : b ∈ (↑I)⁻¹
⊢ ∀ (y : K), y ∈ ↑I → x * b * y ∈ 1
case hI
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : x ∈ (↑I * (↑I)⁻¹)⁻¹
b : K
hb : b ∈ (↑I)⁻¹
⊢ ↑I * (↑I)⁻¹ ≠ 0
case hI
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : x ∈ (fun a => ↑a) (↑I * (↑I)⁻¹)⁻¹
b : K
hb : b ∈ (↑I)⁻¹
⊢ ↑I ≠ 0
[PROOFSTEP]
swap
[GOAL]
case hI
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : x ∈ (↑I * (↑I)⁻¹)⁻¹
b : K
hb : b ∈ (↑I)⁻¹
⊢ ↑I * (↑I)⁻¹ ≠ 0
[PROOFSTEP]
exact hJ0
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : ∀ (y : K), y ∈ ↑I * (↑I)⁻¹ → x * y ∈ 1
b : K
hb : b ∈ (↑I)⁻¹
⊢ ∀ (y : K), y ∈ ↑I → x * b * y ∈ 1
case hI
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : x ∈ (fun a => ↑a) (↑I * (↑I)⁻¹)⁻¹
b : K
hb : b ∈ (↑I)⁻¹
⊢ ↑I ≠ 0
[PROOFSTEP]
swap
[GOAL]
case hI
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : x ∈ (fun a => ↑a) (↑I * (↑I)⁻¹)⁻¹
b : K
hb : b ∈ (↑I)⁻¹
⊢ ↑I ≠ 0
[PROOFSTEP]
exact coeIdeal_ne_zero.mpr hI0
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : ∀ (y : K), y ∈ ↑I * (↑I)⁻¹ → x * y ∈ 1
b : K
hb : b ∈ (↑I)⁻¹
⊢ ∀ (y : K), y ∈ ↑I → x * b * y ∈ 1
[PROOFSTEP]
simp only [mul_assoc, mul_comm b] at hx ⊢
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : ∀ (y : K), y ∈ ↑I * (↑I)⁻¹ → x * y ∈ 1
b : K
hb : b ∈ (↑I)⁻¹
⊢ ∀ (y : K), y ∈ ↑I → x * (y * b) ∈ 1
[PROOFSTEP]
intro y hy
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : ∀ (y : K), y ∈ ↑I * (↑I)⁻¹ → x * y ∈ 1
b : K
hb : b ∈ (↑I)⁻¹
y : K
hy : y ∈ ↑I
⊢ x * (y * b) ∈ 1
[PROOFSTEP]
exact
hx _
(mul_mem_mul hy hb)
-- It turns out the subalgebra consisting of all `p(x)` for `p : A[X]` works.
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : x ∈ (fun a => ↑a) (↑I * (↑I)⁻¹)⁻¹
x_mul_mem : ∀ (b : K), b ∈ (↑I)⁻¹ → x * b ∈ (↑I)⁻¹
⊢ ∃ M, Submodule.FG (↑Subalgebra.toSubmodule M) ∧ x ∈ M
[PROOFSTEP]
refine
⟨AlgHom.range (Polynomial.aeval x : A[X] →ₐ[A] K),
isNoetherian_submodule.mp (isNoetherian (I : FractionalIdeal A⁰ K)⁻¹) _ fun y hy => ?_,
⟨Polynomial.X, Polynomial.aeval_X x⟩⟩
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : x ∈ (fun a => ↑a) (↑I * (↑I)⁻¹)⁻¹
x_mul_mem : ∀ (b : K), b ∈ (↑I)⁻¹ → x * b ∈ (↑I)⁻¹
y : K
hy : y ∈ ↑Subalgebra.toSubmodule (AlgHom.range (Polynomial.aeval x))
⊢ y ∈ ↑(↑I)⁻¹
[PROOFSTEP]
obtain ⟨p, rfl⟩ := (AlgHom.mem_range _).mp hy
[GOAL]
case neg.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : x ∈ (fun a => ↑a) (↑I * (↑I)⁻¹)⁻¹
x_mul_mem : ∀ (b : K), b ∈ (↑I)⁻¹ → x * b ∈ (↑I)⁻¹
p : A[X]
hy : ↑(Polynomial.aeval x) p ∈ ↑Subalgebra.toSubmodule (AlgHom.range (Polynomial.aeval x))
⊢ ↑(Polynomial.aeval x) p ∈ ↑(↑I)⁻¹
[PROOFSTEP]
rw [Polynomial.aeval_eq_sum_range]
[GOAL]
case neg.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : x ∈ (fun a => ↑a) (↑I * (↑I)⁻¹)⁻¹
x_mul_mem : ∀ (b : K), b ∈ (↑I)⁻¹ → x * b ∈ (↑I)⁻¹
p : A[X]
hy : ↑(Polynomial.aeval x) p ∈ ↑Subalgebra.toSubmodule (AlgHom.range (Polynomial.aeval x))
⊢ (Finset.sum (Finset.range (Polynomial.natDegree p + 1)) fun i => Polynomial.coeff p i • x ^ i) ∈ ↑(↑I)⁻¹
[PROOFSTEP]
refine Submodule.sum_mem _ fun i hi => Submodule.smul_mem _ _ ?_
[GOAL]
case neg.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : x ∈ (fun a => ↑a) (↑I * (↑I)⁻¹)⁻¹
x_mul_mem : ∀ (b : K), b ∈ (↑I)⁻¹ → x * b ∈ (↑I)⁻¹
p : A[X]
hy : ↑(Polynomial.aeval x) p ∈ ↑Subalgebra.toSubmodule (AlgHom.range (Polynomial.aeval x))
i : ℕ
hi : i ∈ Finset.range (Polynomial.natDegree p + 1)
⊢ x ^ i ∈ ↑(↑I)⁻¹
[PROOFSTEP]
clear hi
[GOAL]
case neg.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : x ∈ (fun a => ↑a) (↑I * (↑I)⁻¹)⁻¹
x_mul_mem : ∀ (b : K), b ∈ (↑I)⁻¹ → x * b ∈ (↑I)⁻¹
p : A[X]
hy : ↑(Polynomial.aeval x) p ∈ ↑Subalgebra.toSubmodule (AlgHom.range (Polynomial.aeval x))
i : ℕ
⊢ x ^ i ∈ ↑(↑I)⁻¹
[PROOFSTEP]
induction' i with i ih
[GOAL]
case neg.intro.zero
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : x ∈ (fun a => ↑a) (↑I * (↑I)⁻¹)⁻¹
x_mul_mem : ∀ (b : K), b ∈ (↑I)⁻¹ → x * b ∈ (↑I)⁻¹
p : A[X]
hy : ↑(Polynomial.aeval x) p ∈ ↑Subalgebra.toSubmodule (AlgHom.range (Polynomial.aeval x))
⊢ x ^ Nat.zero ∈ ↑(↑I)⁻¹
[PROOFSTEP]
rw [pow_zero]
[GOAL]
case neg.intro.zero
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : x ∈ (fun a => ↑a) (↑I * (↑I)⁻¹)⁻¹
x_mul_mem : ∀ (b : K), b ∈ (↑I)⁻¹ → x * b ∈ (↑I)⁻¹
p : A[X]
hy : ↑(Polynomial.aeval x) p ∈ ↑Subalgebra.toSubmodule (AlgHom.range (Polynomial.aeval x))
⊢ 1 ∈ ↑(↑I)⁻¹
[PROOFSTEP]
exact one_mem_inv_coe_ideal hI0
[GOAL]
case neg.intro.succ
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : x ∈ (fun a => ↑a) (↑I * (↑I)⁻¹)⁻¹
x_mul_mem : ∀ (b : K), b ∈ (↑I)⁻¹ → x * b ∈ (↑I)⁻¹
p : A[X]
hy : ↑(Polynomial.aeval x) p ∈ ↑Subalgebra.toSubmodule (AlgHom.range (Polynomial.aeval x))
i : ℕ
ih : x ^ i ∈ ↑(↑I)⁻¹
⊢ x ^ Nat.succ i ∈ ↑(↑I)⁻¹
[PROOFSTEP]
show x ^ i.succ ∈ (I⁻¹ : FractionalIdeal A⁰ K)
[GOAL]
case neg.intro.succ
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : x ∈ (fun a => ↑a) (↑I * (↑I)⁻¹)⁻¹
x_mul_mem : ∀ (b : K), b ∈ (↑I)⁻¹ → x * b ∈ (↑I)⁻¹
p : A[X]
hy : ↑(Polynomial.aeval x) p ∈ ↑Subalgebra.toSubmodule (AlgHom.range (Polynomial.aeval x))
i : ℕ
ih : x ^ i ∈ ↑(↑I)⁻¹
⊢ x ^ Nat.succ i ∈ (↑I)⁻¹
[PROOFSTEP]
rw [pow_succ]
[GOAL]
case neg.intro.succ
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : IsDedekindDomain A
I : Ideal A
hI0 : I ≠ ⊥
hJ0 : ¬↑I * (↑I)⁻¹ = 0
x : K
hx : x ∈ (fun a => ↑a) (↑I * (↑I)⁻¹)⁻¹
x_mul_mem : ∀ (b : K), b ∈ (↑I)⁻¹ → x * b ∈ (↑I)⁻¹
p : A[X]
hy : ↑(Polynomial.aeval x) p ∈ ↑Subalgebra.toSubmodule (AlgHom.range (Polynomial.aeval x))
i : ℕ
ih : x ^ i ∈ ↑(↑I)⁻¹
⊢ x * x ^ i ∈ (↑I)⁻¹
[PROOFSTEP]
exact x_mul_mem _ ih
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
I : FractionalIdeal A⁰ K
hne : I ≠ 0
⊢ I * I⁻¹ = 1
[PROOFSTEP]
obtain ⟨a, J, ha, hJ⟩ : ∃ (a : A) (aI : Ideal A), a ≠ 0 ∧ I = spanSingleton A⁰ (algebraMap A K a)⁻¹ * aI :=
exists_eq_spanSingleton_mul I
[GOAL]
case intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
I : FractionalIdeal A⁰ K
hne : I ≠ 0
a : A
J : Ideal A
ha : a ≠ 0
hJ : I = spanSingleton A⁰ (↑(algebraMap A K) a)⁻¹ * ↑J
⊢ I * I⁻¹ = 1
[PROOFSTEP]
suffices h₂ : I * (spanSingleton A⁰ (algebraMap _ _ a) * (J : FractionalIdeal A⁰ K)⁻¹) = 1
[GOAL]
case intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
I : FractionalIdeal A⁰ K
hne : I ≠ 0
a : A
J : Ideal A
ha : a ≠ 0
hJ : I = spanSingleton A⁰ (↑(algebraMap A K) a)⁻¹ * ↑J
h₂ : I * (spanSingleton A⁰ (↑(algebraMap A K) a) * (↑J)⁻¹) = 1
⊢ I * I⁻¹ = 1
[PROOFSTEP]
rw [mul_inv_cancel_iff]
[GOAL]
case intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
I : FractionalIdeal A⁰ K
hne : I ≠ 0
a : A
J : Ideal A
ha : a ≠ 0
hJ : I = spanSingleton A⁰ (↑(algebraMap A K) a)⁻¹ * ↑J
h₂ : I * (spanSingleton A⁰ (↑(algebraMap A K) a) * (↑J)⁻¹) = 1
⊢ ∃ J, I * J = 1
[PROOFSTEP]
exact ⟨spanSingleton A⁰ (algebraMap _ _ a) * (J : FractionalIdeal A⁰ K)⁻¹, h₂⟩
[GOAL]
case h₂
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
I : FractionalIdeal A⁰ K
hne : I ≠ 0
a : A
J : Ideal A
ha : a ≠ 0
hJ : I = spanSingleton A⁰ (↑(algebraMap A K) a)⁻¹ * ↑J
⊢ I * (spanSingleton A⁰ (↑(algebraMap A K) a) * (↑J)⁻¹) = 1
[PROOFSTEP]
subst hJ
[GOAL]
case h₂
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
a : A
J : Ideal A
ha : a ≠ 0
hne : spanSingleton A⁰ (↑(algebraMap A K) a)⁻¹ * ↑J ≠ 0
⊢ spanSingleton A⁰ (↑(algebraMap A K) a)⁻¹ * ↑J * (spanSingleton A⁰ (↑(algebraMap A K) a) * (↑J)⁻¹) = 1
[PROOFSTEP]
rw [mul_assoc, mul_left_comm (J : FractionalIdeal A⁰ K), coe_ideal_mul_inv, mul_one, spanSingleton_mul_spanSingleton,
inv_mul_cancel, spanSingleton_one]
[GOAL]
case h₂
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
a : A
J : Ideal A
ha : a ≠ 0
hne : spanSingleton A⁰ (↑(algebraMap A K) a)⁻¹ * ↑J ≠ 0
⊢ ↑(algebraMap A K) a ≠ 0
[PROOFSTEP]
exact mt ((injective_iff_map_eq_zero (algebraMap A K)).mp (IsFractionRing.injective A K) _) ha
[GOAL]
case h₂.hI0
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
a : A
J : Ideal A
ha : a ≠ 0
hne : spanSingleton A⁰ (↑(algebraMap A K) a)⁻¹ * ↑J ≠ 0
⊢ J ≠ ⊥
[PROOFSTEP]
exact coeIdeal_ne_zero.mp (right_ne_zero_of_mul hne)
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
J : FractionalIdeal A⁰ K
hJ : J ≠ 0
⊢ ∀ {I I' : FractionalIdeal A⁰ K}, I * J ≤ I' * J ↔ I ≤ I'
[PROOFSTEP]
intro I I'
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
J : FractionalIdeal A⁰ K
hJ : J ≠ 0
I I' : FractionalIdeal A⁰ K
⊢ I * J ≤ I' * J ↔ I ≤ I'
[PROOFSTEP]
constructor
[GOAL]
case mp
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
J : FractionalIdeal A⁰ K
hJ : J ≠ 0
I I' : FractionalIdeal A⁰ K
⊢ I * J ≤ I' * J → I ≤ I'
[PROOFSTEP]
intro h
[GOAL]
case mp
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
J : FractionalIdeal A⁰ K
hJ : J ≠ 0
I I' : FractionalIdeal A⁰ K
h : I * J ≤ I' * J
⊢ I ≤ I'
[PROOFSTEP]
convert mul_right_mono J⁻¹ h
[GOAL]
case h.e'_3
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
J : FractionalIdeal A⁰ K
hJ : J ≠ 0
I I' : FractionalIdeal A⁰ K
h : I * J ≤ I' * J
⊢ I = (fun J_1 => J_1 * J⁻¹) (I * J)
[PROOFSTEP]
dsimp only
[GOAL]
case h.e'_4
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
J : FractionalIdeal A⁰ K
hJ : J ≠ 0
I I' : FractionalIdeal A⁰ K
h : I * J ≤ I' * J
⊢ I' = (fun J_1 => J_1 * J⁻¹) (I' * J)
[PROOFSTEP]
dsimp only
[GOAL]
case h.e'_3
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
J : FractionalIdeal A⁰ K
hJ : J ≠ 0
I I' : FractionalIdeal A⁰ K
h : I * J ≤ I' * J
⊢ I = I * J * J⁻¹
[PROOFSTEP]
rw [mul_assoc, FractionalIdeal.mul_inv_cancel hJ, mul_one]
[GOAL]
case h.e'_4
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
J : FractionalIdeal A⁰ K
hJ : J ≠ 0
I I' : FractionalIdeal A⁰ K
h : I * J ≤ I' * J
⊢ I' = I' * J * J⁻¹
[PROOFSTEP]
rw [mul_assoc, FractionalIdeal.mul_inv_cancel hJ, mul_one]
[GOAL]
case mpr
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
J : FractionalIdeal A⁰ K
hJ : J ≠ 0
I I' : FractionalIdeal A⁰ K
⊢ I ≤ I' → I * J ≤ I' * J
[PROOFSTEP]
exact fun h => mul_right_mono J h
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
J : FractionalIdeal A⁰ K
hJ : J ≠ 0
I I' : FractionalIdeal A⁰ K
⊢ J * I ≤ J * I' ↔ I ≤ I'
[PROOFSTEP]
convert mul_right_le_iff hJ using 1
[GOAL]
case h.e'_1.a
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
J : FractionalIdeal A⁰ K
hJ : J ≠ 0
I I' : FractionalIdeal A⁰ K
⊢ J * I ≤ J * I' ↔ I * J ≤ I' * J
[PROOFSTEP]
simp only [mul_comm]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
I J : FractionalIdeal A⁰ K
⊢ I / J = I * J⁻¹
[PROOFSTEP]
by_cases hJ : J = 0
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
I J : FractionalIdeal A⁰ K
hJ : J = 0
⊢ I / J = I * J⁻¹
[PROOFSTEP]
rw [hJ, div_zero, inv_zero', mul_zero]
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
I J : FractionalIdeal A⁰ K
hJ : ¬J = 0
⊢ I / J = I * J⁻¹
[PROOFSTEP]
refine' le_antisymm ((mul_right_le_iff hJ).mp _) ((le_div_iff_mul_le hJ).mpr _)
[GOAL]
case neg.refine'_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
I J : FractionalIdeal A⁰ K
hJ : ¬J = 0
⊢ I / J * J ≤ I * J⁻¹ * J
[PROOFSTEP]
rw [mul_assoc, mul_comm J⁻¹, FractionalIdeal.mul_inv_cancel hJ, mul_one, mul_le]
[GOAL]
case neg.refine'_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
I J : FractionalIdeal A⁰ K
hJ : ¬J = 0
⊢ ∀ (i : K), i ∈ I / J → ∀ (j : K), j ∈ J → i * j ∈ I
[PROOFSTEP]
intro x hx y hy
[GOAL]
case neg.refine'_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
I J : FractionalIdeal A⁰ K
hJ : ¬J = 0
x : K
hx : x ∈ I / J
y : K
hy : y ∈ J
⊢ x * y ∈ I
[PROOFSTEP]
rw [mem_div_iff_of_nonzero hJ] at hx
[GOAL]
case neg.refine'_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
I J : FractionalIdeal A⁰ K
hJ : ¬J = 0
x : K
hx : ∀ (y : K), y ∈ J → x * y ∈ I
y : K
hy : y ∈ J
⊢ x * y ∈ I
[PROOFSTEP]
exact hx y hy
[GOAL]
case neg.refine'_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : IsDedekindDomain A
I J : FractionalIdeal A⁰ K
hJ : ¬J = 0
⊢ I * J⁻¹ * J ≤ I
[PROOFSTEP]
rw [mul_assoc, mul_comm J⁻¹, FractionalIdeal.mul_inv_cancel hJ, mul_one]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
src✝ : CommSemiring (FractionalIdeal A⁰ K) := commSemiring
⊢ CancelCommMonoidWithZero (FractionalIdeal A⁰ K)
[PROOFSTEP]
infer_instance
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
h : J ≤ I
⊢ I ∣ J
[PROOFSTEP]
by_cases hI : I = ⊥
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
h : J ≤ I
hI : I = ⊥
⊢ I ∣ J
[PROOFSTEP]
have hJ : J = ⊥ := by rwa [hI, ← eq_bot_iff] at h
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
h : J ≤ I
hI : I = ⊥
⊢ J = ⊥
[PROOFSTEP]
rwa [hI, ← eq_bot_iff] at h
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
h : J ≤ I
hI : I = ⊥
hJ : J = ⊥
⊢ I ∣ J
[PROOFSTEP]
rw [hI, hJ]
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
h : J ≤ I
hI : ¬I = ⊥
⊢ I ∣ J
[PROOFSTEP]
have hI' : (I : FractionalIdeal A⁰ (FractionRing A)) ≠ 0 := coeIdeal_ne_zero.mpr hI
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
h : J ≤ I
hI : ¬I = ⊥
hI' : ↑I ≠ 0
⊢ I ∣ J
[PROOFSTEP]
have : (I : FractionalIdeal A⁰ (FractionRing A))⁻¹ * J ≤ 1 :=
le_trans (mul_left_mono (↑I)⁻¹ ((coeIdeal_le_coeIdeal _).mpr h)) (le_of_eq (inv_mul_cancel hI'))
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
h : J ≤ I
hI : ¬I = ⊥
hI' : ↑I ≠ 0
this : (↑I)⁻¹ * ↑J ≤ 1
⊢ I ∣ J
[PROOFSTEP]
obtain ⟨H, hH⟩ := le_one_iff_exists_coeIdeal.mp this
[GOAL]
case neg.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
h : J ≤ I
hI : ¬I = ⊥
hI' : ↑I ≠ 0
this : (↑I)⁻¹ * ↑J ≤ 1
H : Ideal A
hH : ↑H = (↑I)⁻¹ * ↑J
⊢ I ∣ J
[PROOFSTEP]
use H
[GOAL]
case h
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
h : J ≤ I
hI : ¬I = ⊥
hI' : ↑I ≠ 0
this : (↑I)⁻¹ * ↑J ≤ 1
H : Ideal A
hH : ↑H = (↑I)⁻¹ * ↑J
⊢ J = I * H
[PROOFSTEP]
refine coeIdeal_injective (show (J : FractionalIdeal A⁰ (FractionRing A)) = ↑(I * H) from ?_)
[GOAL]
case h
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
h : J ≤ I
hI : ¬I = ⊥
hI' : ↑I ≠ 0
this : (↑I)⁻¹ * ↑J ≤ 1
H : Ideal A
hH : ↑H = (↑I)⁻¹ * ↑J
⊢ ↑J = ↑(I * H)
[PROOFSTEP]
rw [coeIdeal_mul, hH, ← mul_assoc, mul_inv_cancel hI', one_mul]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
x✝ : DvdNotUnit I J
hI : I ≠ 0
H : Ideal A
hunit : ¬IsUnit H
hmul : J = I * H
h : J = I
⊢ I * H = I * 1
[PROOFSTEP]
rw [← hmul, h, mul_one]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
⊢ WellFounded DvdNotUnit
[PROOFSTEP]
have : WellFounded ((· > ·) : Ideal A → Ideal A → Prop) :=
isNoetherian_iff_wellFounded.mp (isNoetherianRing_iff.mp IsDedekindDomain.toIsNoetherian)
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
this : WellFounded fun x x_1 => x > x_1
⊢ WellFounded DvdNotUnit
[PROOFSTEP]
convert this
[GOAL]
case h.e'_2.h.h.h.e
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
this : WellFounded fun x x_1 => x > x_1
x✝¹ x✝ : Ideal A
⊢ DvdNotUnit = GT.gt
[PROOFSTEP]
ext
[GOAL]
case h.e'_2.h.h.h.e.h.h.a
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
this : WellFounded fun x x_1 => x > x_1
x✝³ x✝² x✝¹ x✝ : Ideal A
⊢ DvdNotUnit x✝¹ x✝ ↔ x✝¹ > x✝
[PROOFSTEP]
rw [Ideal.dvdNotUnit_iff_lt]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
⊢ ∀ {a : Ideal A}, Irreducible a ↔ Prime a
[PROOFSTEP]
intro P
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P : Ideal A
⊢ Irreducible P ↔ Prime P
[PROOFSTEP]
exact
⟨fun hirr =>
⟨hirr.ne_zero, hirr.not_unit, fun I J =>
by
have : P.IsMaximal := by
refine ⟨⟨mt Ideal.isUnit_iff.mpr hirr.not_unit, ?_⟩⟩
intro J hJ
obtain ⟨_J_ne, H, hunit, P_eq⟩ := Ideal.dvdNotUnit_iff_lt.mpr hJ
exact Ideal.isUnit_iff.mp ((hirr.isUnit_or_isUnit P_eq).resolve_right hunit)
rw [Ideal.dvd_iff_le, Ideal.dvd_iff_le, Ideal.dvd_iff_le, SetLike.le_def, SetLike.le_def, SetLike.le_def]
contrapose!
rintro ⟨⟨x, x_mem, x_not_mem⟩, ⟨y, y_mem, y_not_mem⟩⟩
exact ⟨x * y, Ideal.mul_mem_mul x_mem y_mem, mt this.isPrime.mem_or_mem (not_or_of_not x_not_mem y_not_mem)⟩⟩,
Prime.irreducible⟩
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P : Ideal A
hirr : Irreducible P
I J : Ideal A
⊢ P ∣ I * J → P ∣ I ∨ P ∣ J
[PROOFSTEP]
have : P.IsMaximal := by
refine ⟨⟨mt Ideal.isUnit_iff.mpr hirr.not_unit, ?_⟩⟩
intro J hJ
obtain ⟨_J_ne, H, hunit, P_eq⟩ := Ideal.dvdNotUnit_iff_lt.mpr hJ
exact Ideal.isUnit_iff.mp ((hirr.isUnit_or_isUnit P_eq).resolve_right hunit)
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P : Ideal A
hirr : Irreducible P
I J : Ideal A
⊢ IsMaximal P
[PROOFSTEP]
refine ⟨⟨mt Ideal.isUnit_iff.mpr hirr.not_unit, ?_⟩⟩
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P : Ideal A
hirr : Irreducible P
I J : Ideal A
⊢ ∀ (b : Ideal A), P < b → b = ⊤
[PROOFSTEP]
intro J hJ
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P : Ideal A
hirr : Irreducible P
I J✝ J : Ideal A
hJ : P < J
⊢ J = ⊤
[PROOFSTEP]
obtain ⟨_J_ne, H, hunit, P_eq⟩ := Ideal.dvdNotUnit_iff_lt.mpr hJ
[GOAL]
case intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P : Ideal A
hirr : Irreducible P
I J✝ J : Ideal A
hJ : P < J
_J_ne : J ≠ 0
H : Ideal A
hunit : ¬IsUnit H
P_eq : P = J * H
⊢ J = ⊤
[PROOFSTEP]
exact Ideal.isUnit_iff.mp ((hirr.isUnit_or_isUnit P_eq).resolve_right hunit)
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P : Ideal A
hirr : Irreducible P
I J : Ideal A
this : IsMaximal P
⊢ P ∣ I * J → P ∣ I ∨ P ∣ J
[PROOFSTEP]
rw [Ideal.dvd_iff_le, Ideal.dvd_iff_le, Ideal.dvd_iff_le, SetLike.le_def, SetLike.le_def, SetLike.le_def]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P : Ideal A
hirr : Irreducible P
I J : Ideal A
this : IsMaximal P
⊢ (∀ ⦃x : A⦄, x ∈ I * J → x ∈ P) → (∀ ⦃x : A⦄, x ∈ I → x ∈ P) ∨ ∀ ⦃x : A⦄, x ∈ J → x ∈ P
[PROOFSTEP]
contrapose!
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P : Ideal A
hirr : Irreducible P
I J : Ideal A
this : IsMaximal P
⊢ ((Exists fun ⦃x⦄ => x ∈ I ∧ ¬x ∈ P) ∧ Exists fun ⦃x⦄ => x ∈ J ∧ ¬x ∈ P) → Exists fun ⦃x⦄ => x ∈ I * J ∧ ¬x ∈ P
[PROOFSTEP]
rintro ⟨⟨x, x_mem, x_not_mem⟩, ⟨y, y_mem, y_not_mem⟩⟩
[GOAL]
case intro.intro.intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P : Ideal A
hirr : Irreducible P
I J : Ideal A
this : IsMaximal P
x : A
x_mem : x ∈ I
x_not_mem : ¬x ∈ P
y : A
y_mem : y ∈ J
y_not_mem : ¬y ∈ P
⊢ Exists fun ⦃x⦄ => x ∈ I * J ∧ ¬x ∈ P
[PROOFSTEP]
exact ⟨x * y, Ideal.mul_mem_mul x_mem y_mem, mt this.isPrime.mem_or_mem (not_or_of_not x_not_mem y_not_mem)⟩
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P : Ideal A
h : Prime P
⊢ IsPrime P
[PROOFSTEP]
refine ⟨?_, fun hxy => ?_⟩
[GOAL]
case refine_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P : Ideal A
h : Prime P
⊢ P ≠ ⊤
[PROOFSTEP]
rintro rfl
[GOAL]
case refine_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : Prime ⊤
⊢ False
[PROOFSTEP]
rw [← Ideal.one_eq_top] at h
[GOAL]
case refine_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
h : Prime 1
⊢ False
[PROOFSTEP]
exact h.not_unit isUnit_one
[GOAL]
case refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P : Ideal A
h : Prime P
x✝ y✝ : A
hxy : x✝ * y✝ ∈ P
⊢ x✝ ∈ P ∨ y✝ ∈ P
[PROOFSTEP]
simp only [← Ideal.dvd_span_singleton, ← Ideal.span_singleton_mul_span_singleton] at hxy ⊢
[GOAL]
case refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P : Ideal A
h : Prime P
x✝ y✝ : A
hxy : P ∣ span {x✝} * span {y✝}
⊢ P ∣ span {x✝} ∨ P ∣ span {y✝}
[PROOFSTEP]
exact h.dvd_or_dvd hxy
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P : Ideal A
hP : P ≠ ⊥
h : IsPrime P
⊢ Prime P
[PROOFSTEP]
refine ⟨hP, mt Ideal.isUnit_iff.mp h.ne_top, fun I J hIJ => ?_⟩
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P : Ideal A
hP : P ≠ ⊥
h : IsPrime P
I J : Ideal A
hIJ : P ∣ I * J
⊢ P ∣ I ∨ P ∣ J
[PROOFSTEP]
simpa only [Ideal.dvd_iff_le] using h.mul_le.mp (Ideal.le_of_dvd hIJ)
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
e : ℕ
he : 2 ≤ e
⊢ I ^ e < I
[PROOFSTEP]
convert I.strictAnti_pow hI0 hI1 he
[GOAL]
case h.e'_4
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
e : ℕ
he : 2 ≤ e
⊢ I = (fun x x_1 => x ^ x_1) I 1
[PROOFSTEP]
dsimp only
[GOAL]
case h.e'_4
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I : Ideal A
hI0 : I ≠ ⊥
hI1 : I ≠ ⊤
e : ℕ
he : 2 ≤ e
⊢ I = I ^ 1
[PROOFSTEP]
rw [pow_one]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P I : Ideal A
P_prime : IsPrime P
hP : P ≠ ⊥
i : ℕ
hlt : P ^ (i + 1) < I
hle : I ≤ P ^ i
⊢ I = P ^ i
[PROOFSTEP]
have := Classical.decEq (Ideal A)
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P I : Ideal A
P_prime : IsPrime P
hP : P ≠ ⊥
i : ℕ
hlt : P ^ (i + 1) < I
hle : I ≤ P ^ i
this : DecidableEq (Ideal A)
⊢ I = P ^ i
[PROOFSTEP]
refine le_antisymm hle ?_
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P I : Ideal A
P_prime : IsPrime P
hP : P ≠ ⊥
i : ℕ
hlt : P ^ (i + 1) < I
hle : I ≤ P ^ i
this : DecidableEq (Ideal A)
⊢ P ^ i ≤ I
[PROOFSTEP]
have P_prime' := Ideal.prime_of_isPrime hP P_prime
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P I : Ideal A
P_prime : IsPrime P
hP : P ≠ ⊥
i : ℕ
hlt : P ^ (i + 1) < I
hle : I ≤ P ^ i
this : DecidableEq (Ideal A)
P_prime' : Prime P
⊢ P ^ i ≤ I
[PROOFSTEP]
have h1 : I ≠ ⊥ := (lt_of_le_of_lt bot_le hlt).ne'
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P I : Ideal A
P_prime : IsPrime P
hP : P ≠ ⊥
i : ℕ
hlt : P ^ (i + 1) < I
hle : I ≤ P ^ i
this : DecidableEq (Ideal A)
P_prime' : Prime P
h1 : I ≠ ⊥
⊢ P ^ i ≤ I
[PROOFSTEP]
have := pow_ne_zero i hP
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P I : Ideal A
P_prime : IsPrime P
hP : P ≠ ⊥
i : ℕ
hlt : P ^ (i + 1) < I
hle : I ≤ P ^ i
this✝ : DecidableEq (Ideal A)
P_prime' : Prime P
h1 : I ≠ ⊥
this : P ^ i ≠ 0
⊢ P ^ i ≤ I
[PROOFSTEP]
have h3 := pow_ne_zero (i + 1) hP
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P I : Ideal A
P_prime : IsPrime P
hP : P ≠ ⊥
i : ℕ
hlt : P ^ (i + 1) < I
hle : I ≤ P ^ i
this✝ : DecidableEq (Ideal A)
P_prime' : Prime P
h1 : I ≠ ⊥
this : P ^ i ≠ 0
h3 : P ^ (i + 1) ≠ 0
⊢ P ^ i ≤ I
[PROOFSTEP]
rw [← Ideal.dvdNotUnit_iff_lt, dvdNotUnit_iff_normalizedFactors_lt_normalizedFactors h1 h3, normalizedFactors_pow,
normalizedFactors_irreducible P_prime'.irreducible, Multiset.nsmul_singleton, Multiset.lt_replicate_succ] at hlt
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P I : Ideal A
P_prime : IsPrime P
hP : P ≠ ⊥
i : ℕ
hle : I ≤ P ^ i
this✝ : DecidableEq (Ideal A)
hlt : normalizedFactors I ≤ Multiset.replicate i (↑normalize P)
P_prime' : Prime P
h1 : I ≠ ⊥
this : P ^ i ≠ 0
h3 : P ^ (i + 1) ≠ 0
⊢ P ^ i ≤ I
[PROOFSTEP]
rw [← Ideal.dvd_iff_le, dvd_iff_normalizedFactors_le_normalizedFactors, normalizedFactors_pow,
normalizedFactors_irreducible P_prime'.irreducible, Multiset.nsmul_singleton]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P I : Ideal A
P_prime : IsPrime P
hP : P ≠ ⊥
i : ℕ
hle : I ≤ P ^ i
this✝ : DecidableEq (Ideal A)
hlt : normalizedFactors I ≤ Multiset.replicate i (↑normalize P)
P_prime' : Prime P
h1 : I ≠ ⊥
this : P ^ i ≠ 0
h3 : P ^ (i + 1) ≠ 0
⊢ normalizedFactors I ≤ Multiset.replicate i (↑normalize P)
case hx
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P I : Ideal A
P_prime : IsPrime P
hP : P ≠ ⊥
i : ℕ
hle : I ≤ P ^ i
this✝ : DecidableEq (Ideal A)
hlt : normalizedFactors I ≤ Multiset.replicate i (↑normalize P)
P_prime' : Prime P
h1 : I ≠ ⊥
this : P ^ i ≠ 0
h3 : P ^ (i + 1) ≠ 0
⊢ I ≠ 0
case hy
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P I : Ideal A
P_prime : IsPrime P
hP : P ≠ ⊥
i : ℕ
hle : I ≤ P ^ i
this✝ : DecidableEq (Ideal A)
hlt : normalizedFactors I ≤ Multiset.replicate i (↑normalize P)
P_prime' : Prime P
h1 : I ≠ ⊥
this : P ^ i ≠ 0
h3 : P ^ (i + 1) ≠ 0
⊢ P ^ i ≠ 0
[PROOFSTEP]
all_goals assumption
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P I : Ideal A
P_prime : IsPrime P
hP : P ≠ ⊥
i : ℕ
hle : I ≤ P ^ i
this✝ : DecidableEq (Ideal A)
hlt : normalizedFactors I ≤ Multiset.replicate i (↑normalize P)
P_prime' : Prime P
h1 : I ≠ ⊥
this : P ^ i ≠ 0
h3 : P ^ (i + 1) ≠ 0
⊢ normalizedFactors I ≤ Multiset.replicate i (↑normalize P)
[PROOFSTEP]
assumption
[GOAL]
case hx
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P I : Ideal A
P_prime : IsPrime P
hP : P ≠ ⊥
i : ℕ
hle : I ≤ P ^ i
this✝ : DecidableEq (Ideal A)
hlt : normalizedFactors I ≤ Multiset.replicate i (↑normalize P)
P_prime' : Prime P
h1 : I ≠ ⊥
this : P ^ i ≠ 0
h3 : P ^ (i + 1) ≠ 0
⊢ I ≠ 0
[PROOFSTEP]
assumption
[GOAL]
case hy
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
P I : Ideal A
P_prime : IsPrime P
hP : P ≠ ⊥
i : ℕ
hle : I ≤ P ^ i
this✝ : DecidableEq (Ideal A)
hlt : normalizedFactors I ≤ Multiset.replicate i (↑normalize P)
P_prime' : Prime P
h1 : I ≠ ⊥
this : P ^ i ≠ 0
h3 : P ^ (i + 1) ≠ 0
⊢ P ^ i ≠ 0
[PROOFSTEP]
assumption
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
x : A
n : ℕ
I : Ideal A
⊢ Associates.mk I ^ n ≤ Associates.mk (span {x}) ↔ x ∈ I ^ n
[PROOFSTEP]
simp_rw [← Associates.dvd_eq_le, ← Associates.mk_pow, Associates.mk_dvd_mk, Ideal.dvd_span_singleton]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
J : Ideal A
hJ : J ≠ ⊤
ι : Type u_4
s : Finset ι
f : ι → K
j : ι
hjs : j ∈ s
hjf : f j ≠ 0
⊢ ∃ a, (∀ (i : ι), i ∈ s → IsLocalization.IsInteger A (a * f i)) ∧ ∃ i, i ∈ s ∧ ¬a * f i ∈ ↑J
[PROOFSTEP]
let I : FractionalIdeal A⁰ K := spanFinset A s f
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
J : Ideal A
hJ : J ≠ ⊤
ι : Type u_4
s : Finset ι
f : ι → K
j : ι
hjs : j ∈ s
hjf : f j ≠ 0
I : FractionalIdeal A⁰ K := spanFinset A s f
⊢ ∃ a, (∀ (i : ι), i ∈ s → IsLocalization.IsInteger A (a * f i)) ∧ ∃ i, i ∈ s ∧ ¬a * f i ∈ ↑J
[PROOFSTEP]
have hI0 : I ≠ 0 :=
spanFinset_ne_zero.mpr
⟨j, hjs, hjf⟩
-- We claim the multiplier `a` we're looking for is in `I⁻¹ \ (J / I)`.
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
J : Ideal A
hJ : J ≠ ⊤
ι : Type u_4
s : Finset ι
f : ι → K
j : ι
hjs : j ∈ s
hjf : f j ≠ 0
I : FractionalIdeal A⁰ K := spanFinset A s f
hI0 : I ≠ 0
⊢ ∃ a, (∀ (i : ι), i ∈ s → IsLocalization.IsInteger A (a * f i)) ∧ ∃ i, i ∈ s ∧ ¬a * f i ∈ ↑J
[PROOFSTEP]
suffices ↑J / I < I⁻¹ by
obtain ⟨_, a, hI, hpI⟩ := SetLike.lt_iff_le_and_exists.mp this
rw [mem_inv_iff hI0] at hI
refine'
⟨a, fun i hi => _, _⟩
-- By definition, `a ∈ I⁻¹` multiplies elements of `I` into elements of `1`,
-- in other words, `a * f i` is an integer.
· exact (mem_one_iff _).mp (hI (f i) (Submodule.subset_span (Set.mem_image_of_mem f hi)))
· contrapose! hpI
refine' (mem_div_iff_of_nonzero hI0).mpr fun y hy => Submodule.span_induction hy _ _ _ _
· rintro _ ⟨i, hi, rfl⟩; exact hpI i hi
· rw [mul_zero]; exact Submodule.zero_mem _
· intro x y hx hy; rw [mul_add]; exact Submodule.add_mem _ hx hy
· intro b x hx; rw [mul_smul_comm]; exact Submodule.smul_mem _ b hx
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
J : Ideal A
hJ : J ≠ ⊤
ι : Type u_4
s : Finset ι
f : ι → K
j : ι
hjs : j ∈ s
hjf : f j ≠ 0
I : FractionalIdeal A⁰ K := spanFinset A s f
hI0 : I ≠ 0
this : ↑J / I < I⁻¹
⊢ ∃ a, (∀ (i : ι), i ∈ s → IsLocalization.IsInteger A (a * f i)) ∧ ∃ i, i ∈ s ∧ ¬a * f i ∈ ↑J
[PROOFSTEP]
obtain ⟨_, a, hI, hpI⟩ := SetLike.lt_iff_le_and_exists.mp this
[GOAL]
case intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
J : Ideal A
hJ : J ≠ ⊤
ι : Type u_4
s : Finset ι
f : ι → K
j : ι
hjs : j ∈ s
hjf : f j ≠ 0
I : FractionalIdeal A⁰ K := spanFinset A s f
hI0 : I ≠ 0
this : ↑J / I < I⁻¹
left✝ : ↑J / I ≤ I⁻¹
a : K
hI : a ∈ I⁻¹
hpI : ¬a ∈ ↑J / I
⊢ ∃ a, (∀ (i : ι), i ∈ s → IsLocalization.IsInteger A (a * f i)) ∧ ∃ i, i ∈ s ∧ ¬a * f i ∈ ↑J
[PROOFSTEP]
rw [mem_inv_iff hI0] at hI
[GOAL]
case intro.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
J : Ideal A
hJ : J ≠ ⊤
ι : Type u_4
s : Finset ι
f : ι → K
j : ι
hjs : j ∈ s
hjf : f j ≠ 0
I : FractionalIdeal A⁰ K := spanFinset A s f
hI0 : I ≠ 0
this : ↑J / I < I⁻¹
left✝ : ↑J / I ≤ I⁻¹
a : K
hI : ∀ (y : K), y ∈ I → a * y ∈ 1
hpI : ¬a ∈ ↑J / I
⊢ ∃ a, (∀ (i : ι), i ∈ s → IsLocalization.IsInteger A (a * f i)) ∧ ∃ i, i ∈ s ∧ ¬a * f i ∈ ↑J
[PROOFSTEP]
refine'
⟨a, fun i hi => _, _⟩
-- By definition, `a ∈ I⁻¹` multiplies elements of `I` into elements of `1`,
-- in other words, `a * f i` is an integer.
[GOAL]
case intro.intro.intro.refine'_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
J : Ideal A
hJ : J ≠ ⊤
ι : Type u_4
s : Finset ι
f : ι → K
j : ι
hjs : j ∈ s
hjf : f j ≠ 0
I : FractionalIdeal A⁰ K := spanFinset A s f
hI0 : I ≠ 0
this : ↑J / I < I⁻¹
left✝ : ↑J / I ≤ I⁻¹
a : K
hI : ∀ (y : K), y ∈ I → a * y ∈ 1
hpI : ¬a ∈ ↑J / I
i : ι
hi : i ∈ s
⊢ IsLocalization.IsInteger A (a * f i)
[PROOFSTEP]
exact (mem_one_iff _).mp (hI (f i) (Submodule.subset_span (Set.mem_image_of_mem f hi)))
[GOAL]
case intro.intro.intro.refine'_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
J : Ideal A
hJ : J ≠ ⊤
ι : Type u_4
s : Finset ι
f : ι → K
j : ι
hjs : j ∈ s
hjf : f j ≠ 0
I : FractionalIdeal A⁰ K := spanFinset A s f
hI0 : I ≠ 0
this : ↑J / I < I⁻¹
left✝ : ↑J / I ≤ I⁻¹
a : K
hI : ∀ (y : K), y ∈ I → a * y ∈ 1
hpI : ¬a ∈ ↑J / I
⊢ ∃ i, i ∈ s ∧ ¬a * f i ∈ ↑J
[PROOFSTEP]
contrapose! hpI
[GOAL]
case intro.intro.intro.refine'_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
J : Ideal A
hJ : J ≠ ⊤
ι : Type u_4
s : Finset ι
f : ι → K
j : ι
hjs : j ∈ s
hjf : f j ≠ 0
I : FractionalIdeal A⁰ K := spanFinset A s f
hI0 : I ≠ 0
this : ↑J / I < I⁻¹
left✝ : ↑J / I ≤ I⁻¹
a : K
hI : ∀ (y : K), y ∈ I → a * y ∈ 1
hpI : ∀ (i : ι), i ∈ s → a * f i ∈ ↑J
⊢ a ∈ ↑J / spanFinset A s f
[PROOFSTEP]
refine' (mem_div_iff_of_nonzero hI0).mpr fun y hy => Submodule.span_induction hy _ _ _ _
[GOAL]
case intro.intro.intro.refine'_2.refine'_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
J : Ideal A
hJ : J ≠ ⊤
ι : Type u_4
s : Finset ι
f : ι → K
j : ι
hjs : j ∈ s
hjf : f j ≠ 0
I : FractionalIdeal A⁰ K := spanFinset A s f
hI0 : I ≠ 0
this : ↑J / I < I⁻¹
left✝ : ↑J / I ≤ I⁻¹
a : K
hI : ∀ (y : K), y ∈ I → a * y ∈ 1
hpI : ∀ (i : ι), i ∈ s → a * f i ∈ ↑J
y : K
hy : y ∈ I
⊢ ∀ (x : K), x ∈ f '' ↑s → a * x ∈ ↑J
[PROOFSTEP]
rintro _ ⟨i, hi, rfl⟩
[GOAL]
case intro.intro.intro.refine'_2.refine'_1.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
J : Ideal A
hJ : J ≠ ⊤
ι : Type u_4
s : Finset ι
f : ι → K
j : ι
hjs : j ∈ s
hjf : f j ≠ 0
I : FractionalIdeal A⁰ K := spanFinset A s f
hI0 : I ≠ 0
this : ↑J / I < I⁻¹
left✝ : ↑J / I ≤ I⁻¹
a : K
hI : ∀ (y : K), y ∈ I → a * y ∈ 1
hpI : ∀ (i : ι), i ∈ s → a * f i ∈ ↑J
y : K
hy : y ∈ I
i : ι
hi : i ∈ ↑s
⊢ a * f i ∈ ↑J
[PROOFSTEP]
exact hpI i hi
[GOAL]
case intro.intro.intro.refine'_2.refine'_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
J : Ideal A
hJ : J ≠ ⊤
ι : Type u_4
s : Finset ι
f : ι → K
j : ι
hjs : j ∈ s
hjf : f j ≠ 0
I : FractionalIdeal A⁰ K := spanFinset A s f
hI0 : I ≠ 0
this : ↑J / I < I⁻¹
left✝ : ↑J / I ≤ I⁻¹
a : K
hI : ∀ (y : K), y ∈ I → a * y ∈ 1
hpI : ∀ (i : ι), i ∈ s → a * f i ∈ ↑J
y : K
hy : y ∈ I
⊢ a * 0 ∈ ↑J
[PROOFSTEP]
rw [mul_zero]
[GOAL]
case intro.intro.intro.refine'_2.refine'_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
J : Ideal A
hJ : J ≠ ⊤
ι : Type u_4
s : Finset ι
f : ι → K
j : ι
hjs : j ∈ s
hjf : f j ≠ 0
I : FractionalIdeal A⁰ K := spanFinset A s f
hI0 : I ≠ 0
this : ↑J / I < I⁻¹
left✝ : ↑J / I ≤ I⁻¹
a : K
hI : ∀ (y : K), y ∈ I → a * y ∈ 1
hpI : ∀ (i : ι), i ∈ s → a * f i ∈ ↑J
y : K
hy : y ∈ I
⊢ 0 ∈ ↑J
[PROOFSTEP]
exact Submodule.zero_mem _
[GOAL]
case intro.intro.intro.refine'_2.refine'_3
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
J : Ideal A
hJ : J ≠ ⊤
ι : Type u_4
s : Finset ι
f : ι → K
j : ι
hjs : j ∈ s
hjf : f j ≠ 0
I : FractionalIdeal A⁰ K := spanFinset A s f
hI0 : I ≠ 0
this : ↑J / I < I⁻¹
left✝ : ↑J / I ≤ I⁻¹
a : K
hI : ∀ (y : K), y ∈ I → a * y ∈ 1
hpI : ∀ (i : ι), i ∈ s → a * f i ∈ ↑J
y : K
hy : y ∈ I
⊢ ∀ (x y : K), a * x ∈ ↑J → a * y ∈ ↑J → a * (x + y) ∈ ↑J
[PROOFSTEP]
intro x y hx hy
[GOAL]
case intro.intro.intro.refine'_2.refine'_3
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
J : Ideal A
hJ : J ≠ ⊤
ι : Type u_4
s : Finset ι
f : ι → K
j : ι
hjs : j ∈ s
hjf : f j ≠ 0
I : FractionalIdeal A⁰ K := spanFinset A s f
hI0 : I ≠ 0
this : ↑J / I < I⁻¹
left✝ : ↑J / I ≤ I⁻¹
a : K
hI : ∀ (y : K), y ∈ I → a * y ∈ 1
hpI : ∀ (i : ι), i ∈ s → a * f i ∈ ↑J
y✝ : K
hy✝ : y✝ ∈ I
x y : K
hx : a * x ∈ ↑J
hy : a * y ∈ ↑J
⊢ a * (x + y) ∈ ↑J
[PROOFSTEP]
rw [mul_add]
[GOAL]
case intro.intro.intro.refine'_2.refine'_3
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
J : Ideal A
hJ : J ≠ ⊤
ι : Type u_4
s : Finset ι
f : ι → K
j : ι
hjs : j ∈ s
hjf : f j ≠ 0
I : FractionalIdeal A⁰ K := spanFinset A s f
hI0 : I ≠ 0
this : ↑J / I < I⁻¹
left✝ : ↑J / I ≤ I⁻¹
a : K
hI : ∀ (y : K), y ∈ I → a * y ∈ 1
hpI : ∀ (i : ι), i ∈ s → a * f i ∈ ↑J
y✝ : K
hy✝ : y✝ ∈ I
x y : K
hx : a * x ∈ ↑J
hy : a * y ∈ ↑J
⊢ a * x + a * y ∈ ↑J
[PROOFSTEP]
exact Submodule.add_mem _ hx hy
[GOAL]
case intro.intro.intro.refine'_2.refine'_4
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
J : Ideal A
hJ : J ≠ ⊤
ι : Type u_4
s : Finset ι
f : ι → K
j : ι
hjs : j ∈ s
hjf : f j ≠ 0
I : FractionalIdeal A⁰ K := spanFinset A s f
hI0 : I ≠ 0
this : ↑J / I < I⁻¹
left✝ : ↑J / I ≤ I⁻¹
a : K
hI : ∀ (y : K), y ∈ I → a * y ∈ 1
hpI : ∀ (i : ι), i ∈ s → a * f i ∈ ↑J
y : K
hy : y ∈ I
⊢ ∀ (a_1 : A) (x : K), a * x ∈ ↑J → a * a_1 • x ∈ ↑J
[PROOFSTEP]
intro b x hx
[GOAL]
case intro.intro.intro.refine'_2.refine'_4
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
J : Ideal A
hJ : J ≠ ⊤
ι : Type u_4
s : Finset ι
f : ι → K
j : ι
hjs : j ∈ s
hjf : f j ≠ 0
I : FractionalIdeal A⁰ K := spanFinset A s f
hI0 : I ≠ 0
this : ↑J / I < I⁻¹
left✝ : ↑J / I ≤ I⁻¹
a : K
hI : ∀ (y : K), y ∈ I → a * y ∈ 1
hpI : ∀ (i : ι), i ∈ s → a * f i ∈ ↑J
y : K
hy : y ∈ I
b : A
x : K
hx : a * x ∈ ↑J
⊢ a * b • x ∈ ↑J
[PROOFSTEP]
rw [mul_smul_comm]
[GOAL]
case intro.intro.intro.refine'_2.refine'_4
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
J : Ideal A
hJ : J ≠ ⊤
ι : Type u_4
s : Finset ι
f : ι → K
j : ι
hjs : j ∈ s
hjf : f j ≠ 0
I : FractionalIdeal A⁰ K := spanFinset A s f
hI0 : I ≠ 0
this : ↑J / I < I⁻¹
left✝ : ↑J / I ≤ I⁻¹
a : K
hI : ∀ (y : K), y ∈ I → a * y ∈ 1
hpI : ∀ (i : ι), i ∈ s → a * f i ∈ ↑J
y : K
hy : y ∈ I
b : A
x : K
hx : a * x ∈ ↑J
⊢ b • (a * x) ∈ ↑J
[PROOFSTEP]
exact Submodule.smul_mem _ b hx
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
J : Ideal A
hJ : J ≠ ⊤
ι : Type u_4
s : Finset ι
f : ι → K
j : ι
hjs : j ∈ s
hjf : f j ≠ 0
I : FractionalIdeal A⁰ K := spanFinset A s f
hI0 : I ≠ 0
⊢ ↑J / I < I⁻¹
[PROOFSTEP]
calc
↑J / I = ↑J * I⁻¹ := div_eq_mul_inv (↑J) I
_ < 1 * I⁻¹ := (mul_right_strictMono (inv_ne_zero hI0) ?_)
_ = I⁻¹ := one_mul _
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
J : Ideal A
hJ : J ≠ ⊤
ι : Type u_4
s : Finset ι
f : ι → K
j : ι
hjs : j ∈ s
hjf : f j ≠ 0
I : FractionalIdeal A⁰ K := spanFinset A s f
hI0 : I ≠ 0
⊢ ↑J < 1
[PROOFSTEP]
rw [← coeIdeal_top]
-- And multiplying by `I⁻¹` is indeed strictly monotone.
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
J : Ideal A
hJ : J ≠ ⊤
ι : Type u_4
s : Finset ι
f : ι → K
j : ι
hjs : j ∈ s
hjf : f j ≠ 0
I : FractionalIdeal A⁰ K := spanFinset A s f
hI0 : I ≠ 0
⊢ ↑J < ↑⊤
[PROOFSTEP]
exact strictMono_of_le_iff_le (fun _ _ => (coeIdeal_le_coeIdeal K).symm) (lt_top_iff_ne_top.mpr hJ)
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
⊢ (I ⊔ J) * (I ⊓ J) = I * J
[PROOFSTEP]
letI := Classical.decEq (Ideal A)
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
this : DecidableEq (Ideal A) := Classical.decEq (Ideal A)
⊢ (I ⊔ J) * (I ⊓ J) = I * J
[PROOFSTEP]
letI := Classical.decEq (Associates (Ideal A))
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
this✝ : DecidableEq (Ideal A) := Classical.decEq (Ideal A)
this : DecidableEq (Associates (Ideal A)) := Classical.decEq (Associates (Ideal A))
⊢ (I ⊔ J) * (I ⊓ J) = I * J
[PROOFSTEP]
letI := UniqueFactorizationMonoid.toNormalizedGCDMonoid (Ideal A)
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
this✝¹ : DecidableEq (Ideal A) := Classical.decEq (Ideal A)
this✝ : DecidableEq (Associates (Ideal A)) := Classical.decEq (Associates (Ideal A))
this : NormalizedGCDMonoid (Ideal A) := toNormalizedGCDMonoid (Ideal A)
⊢ (I ⊔ J) * (I ⊓ J) = I * J
[PROOFSTEP]
have hgcd : gcd I J = I ⊔ J := by
rw [gcd_eq_normalize _ _, normalize_eq]
· rw [dvd_iff_le, sup_le_iff, ← dvd_iff_le, ← dvd_iff_le]
exact ⟨gcd_dvd_left _ _, gcd_dvd_right _ _⟩
· rw [dvd_gcd_iff, dvd_iff_le, dvd_iff_le]
simp
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
this✝¹ : DecidableEq (Ideal A) := Classical.decEq (Ideal A)
this✝ : DecidableEq (Associates (Ideal A)) := Classical.decEq (Associates (Ideal A))
this : NormalizedGCDMonoid (Ideal A) := toNormalizedGCDMonoid (Ideal A)
⊢ gcd I J = I ⊔ J
[PROOFSTEP]
rw [gcd_eq_normalize _ _, normalize_eq]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
this✝¹ : DecidableEq (Ideal A) := Classical.decEq (Ideal A)
this✝ : DecidableEq (Associates (Ideal A)) := Classical.decEq (Associates (Ideal A))
this : NormalizedGCDMonoid (Ideal A) := toNormalizedGCDMonoid (Ideal A)
⊢ gcd I J ∣ I ⊔ J
[PROOFSTEP]
rw [dvd_iff_le, sup_le_iff, ← dvd_iff_le, ← dvd_iff_le]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
this✝¹ : DecidableEq (Ideal A) := Classical.decEq (Ideal A)
this✝ : DecidableEq (Associates (Ideal A)) := Classical.decEq (Associates (Ideal A))
this : NormalizedGCDMonoid (Ideal A) := toNormalizedGCDMonoid (Ideal A)
⊢ gcd I J ∣ I ∧ gcd I J ∣ J
[PROOFSTEP]
exact ⟨gcd_dvd_left _ _, gcd_dvd_right _ _⟩
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
this✝¹ : DecidableEq (Ideal A) := Classical.decEq (Ideal A)
this✝ : DecidableEq (Associates (Ideal A)) := Classical.decEq (Associates (Ideal A))
this : NormalizedGCDMonoid (Ideal A) := toNormalizedGCDMonoid (Ideal A)
⊢ I ⊔ J ∣ gcd I J
[PROOFSTEP]
rw [dvd_gcd_iff, dvd_iff_le, dvd_iff_le]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
this✝¹ : DecidableEq (Ideal A) := Classical.decEq (Ideal A)
this✝ : DecidableEq (Associates (Ideal A)) := Classical.decEq (Associates (Ideal A))
this : NormalizedGCDMonoid (Ideal A) := toNormalizedGCDMonoid (Ideal A)
⊢ I ≤ I ⊔ J ∧ J ≤ I ⊔ J
[PROOFSTEP]
simp
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
this✝¹ : DecidableEq (Ideal A) := Classical.decEq (Ideal A)
this✝ : DecidableEq (Associates (Ideal A)) := Classical.decEq (Associates (Ideal A))
this : NormalizedGCDMonoid (Ideal A) := toNormalizedGCDMonoid (Ideal A)
hgcd : gcd I J = I ⊔ J
⊢ (I ⊔ J) * (I ⊓ J) = I * J
[PROOFSTEP]
have hlcm : lcm I J = I ⊓ J := by
rw [lcm_eq_normalize _ _, normalize_eq]
· rw [lcm_dvd_iff, dvd_iff_le, dvd_iff_le]
simp
· rw [dvd_iff_le, le_inf_iff, ← dvd_iff_le, ← dvd_iff_le]
exact ⟨dvd_lcm_left _ _, dvd_lcm_right _ _⟩
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
this✝¹ : DecidableEq (Ideal A) := Classical.decEq (Ideal A)
this✝ : DecidableEq (Associates (Ideal A)) := Classical.decEq (Associates (Ideal A))
this : NormalizedGCDMonoid (Ideal A) := toNormalizedGCDMonoid (Ideal A)
hgcd : gcd I J = I ⊔ J
⊢ lcm I J = I ⊓ J
[PROOFSTEP]
rw [lcm_eq_normalize _ _, normalize_eq]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
this✝¹ : DecidableEq (Ideal A) := Classical.decEq (Ideal A)
this✝ : DecidableEq (Associates (Ideal A)) := Classical.decEq (Associates (Ideal A))
this : NormalizedGCDMonoid (Ideal A) := toNormalizedGCDMonoid (Ideal A)
hgcd : gcd I J = I ⊔ J
⊢ lcm I J ∣ I ⊓ J
[PROOFSTEP]
rw [lcm_dvd_iff, dvd_iff_le, dvd_iff_le]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
this✝¹ : DecidableEq (Ideal A) := Classical.decEq (Ideal A)
this✝ : DecidableEq (Associates (Ideal A)) := Classical.decEq (Associates (Ideal A))
this : NormalizedGCDMonoid (Ideal A) := toNormalizedGCDMonoid (Ideal A)
hgcd : gcd I J = I ⊔ J
⊢ I ⊓ J ≤ I ∧ I ⊓ J ≤ J
[PROOFSTEP]
simp
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
this✝¹ : DecidableEq (Ideal A) := Classical.decEq (Ideal A)
this✝ : DecidableEq (Associates (Ideal A)) := Classical.decEq (Associates (Ideal A))
this : NormalizedGCDMonoid (Ideal A) := toNormalizedGCDMonoid (Ideal A)
hgcd : gcd I J = I ⊔ J
⊢ I ⊓ J ∣ lcm I J
[PROOFSTEP]
rw [dvd_iff_le, le_inf_iff, ← dvd_iff_le, ← dvd_iff_le]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
this✝¹ : DecidableEq (Ideal A) := Classical.decEq (Ideal A)
this✝ : DecidableEq (Associates (Ideal A)) := Classical.decEq (Associates (Ideal A))
this : NormalizedGCDMonoid (Ideal A) := toNormalizedGCDMonoid (Ideal A)
hgcd : gcd I J = I ⊔ J
⊢ I ∣ lcm I J ∧ J ∣ lcm I J
[PROOFSTEP]
exact ⟨dvd_lcm_left _ _, dvd_lcm_right _ _⟩
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
this✝¹ : DecidableEq (Ideal A) := Classical.decEq (Ideal A)
this✝ : DecidableEq (Associates (Ideal A)) := Classical.decEq (Associates (Ideal A))
this : NormalizedGCDMonoid (Ideal A) := toNormalizedGCDMonoid (Ideal A)
hgcd : gcd I J = I ⊔ J
hlcm : lcm I J = I ⊓ J
⊢ (I ⊔ J) * (I ⊓ J) = I * J
[PROOFSTEP]
rw [← hgcd, ← hlcm, associated_iff_eq.mp (gcd_mul_lcm _ _)]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
src✝ : NormalizationMonoid (Ideal A) := normalizationMonoid
x✝¹ x✝ : Ideal A
⊢ (fun x x_1 => x ⊔ x_1) x✝¹ x✝ ∣ x✝¹
[PROOFSTEP]
simpa only [dvd_iff_le] using le_sup_left
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
src✝ : NormalizationMonoid (Ideal A) := normalizationMonoid
x✝¹ x✝ : Ideal A
⊢ (fun x x_1 => x ⊔ x_1) x✝¹ x✝ ∣ x✝
[PROOFSTEP]
simpa only [dvd_iff_le] using le_sup_right
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
src✝ : NormalizationMonoid (Ideal A) := normalizationMonoid
⊢ ∀ {a b c : Ideal A}, a ∣ c → a ∣ b → a ∣ (fun x x_1 => x ⊔ x_1) c b
[PROOFSTEP]
simp only [dvd_iff_le]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
src✝ : NormalizationMonoid (Ideal A) := normalizationMonoid
⊢ ∀ {a b c : Ideal A}, c ≤ a → b ≤ a → c ⊔ b ≤ a
[PROOFSTEP]
exact fun h1 h2 => @sup_le (Ideal A) _ _ _ _ h1 h2
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
src✝ : NormalizationMonoid (Ideal A) := normalizationMonoid
x✝¹ x✝ : Ideal A
⊢ Associated ((fun x x_1 => x ⊔ x_1) x✝¹ x✝ * (fun x x_1 => x ⊓ x_1) x✝¹ x✝) (x✝¹ * x✝)
[PROOFSTEP]
rw [associated_iff_eq, sup_mul_inf]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
src✝ : NormalizationMonoid (Ideal A) := normalizationMonoid
x✝ : Ideal A
⊢ (fun x x_1 => x ⊓ x_1) 0 x✝ = 0
[PROOFSTEP]
simp only [zero_eq_bot, bot_inf_eq]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
src✝ : NormalizationMonoid (Ideal A) := normalizationMonoid
x✝ : Ideal A
⊢ (fun x x_1 => x ⊓ x_1) x✝ 0 = 0
[PROOFSTEP]
simp only [zero_eq_bot, inf_bot_eq]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDedekindDomain A
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
I J : Ideal A
coprime : I ⊔ J = ⊤
⊢ I ⊓ J = I * J
[PROOFSTEP]
rw [← associated_iff_eq.mp (gcd_mul_lcm I J), lcm_eq_inf I J, gcd_eq_sup, coprime, top_mul]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : J ≠ ⊥
⊢ I ⊔ J = Multiset.prod (normalizedFactors I ∩ normalizedFactors J)
[PROOFSTEP]
have H :
normalizedFactors (normalizedFactors I ∩ normalizedFactors J).prod = normalizedFactors I ∩ normalizedFactors J :=
by
apply normalizedFactors_prod_of_prime
intro p hp
rw [mem_inter] at hp
exact prime_of_normalized_factor p hp.left
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : J ≠ ⊥
⊢ normalizedFactors (Multiset.prod (normalizedFactors I ∩ normalizedFactors J)) =
normalizedFactors I ∩ normalizedFactors J
[PROOFSTEP]
apply normalizedFactors_prod_of_prime
[GOAL]
case h
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : J ≠ ⊥
⊢ ∀ (p : Ideal T), p ∈ normalizedFactors I ∩ normalizedFactors J → Prime p
[PROOFSTEP]
intro p hp
[GOAL]
case h
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : J ≠ ⊥
p : Ideal T
hp : p ∈ normalizedFactors I ∩ normalizedFactors J
⊢ Prime p
[PROOFSTEP]
rw [mem_inter] at hp
[GOAL]
case h
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : J ≠ ⊥
p : Ideal T
hp : p ∈ normalizedFactors I ∧ p ∈ normalizedFactors J
⊢ Prime p
[PROOFSTEP]
exact prime_of_normalized_factor p hp.left
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : J ≠ ⊥
H :
normalizedFactors (Multiset.prod (normalizedFactors I ∩ normalizedFactors J)) =
normalizedFactors I ∩ normalizedFactors J
⊢ I ⊔ J = Multiset.prod (normalizedFactors I ∩ normalizedFactors J)
[PROOFSTEP]
have :=
Multiset.prod_ne_zero_of_prime (normalizedFactors I ∩ normalizedFactors J) fun _ h =>
prime_of_normalized_factor _ (Multiset.mem_inter.1 h).1
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : J ≠ ⊥
H :
normalizedFactors (Multiset.prod (normalizedFactors I ∩ normalizedFactors J)) =
normalizedFactors I ∩ normalizedFactors J
this : Multiset.prod (normalizedFactors I ∩ normalizedFactors J) ≠ 0
⊢ I ⊔ J = Multiset.prod (normalizedFactors I ∩ normalizedFactors J)
[PROOFSTEP]
apply le_antisymm
[GOAL]
case a
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : J ≠ ⊥
H :
normalizedFactors (Multiset.prod (normalizedFactors I ∩ normalizedFactors J)) =
normalizedFactors I ∩ normalizedFactors J
this : Multiset.prod (normalizedFactors I ∩ normalizedFactors J) ≠ 0
⊢ I ⊔ J ≤ Multiset.prod (normalizedFactors I ∩ normalizedFactors J)
[PROOFSTEP]
rw [sup_le_iff, ← dvd_iff_le, ← dvd_iff_le]
[GOAL]
case a
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : J ≠ ⊥
H :
normalizedFactors (Multiset.prod (normalizedFactors I ∩ normalizedFactors J)) =
normalizedFactors I ∩ normalizedFactors J
this : Multiset.prod (normalizedFactors I ∩ normalizedFactors J) ≠ 0
⊢ Multiset.prod (normalizedFactors I ∩ normalizedFactors J) ∣ I ∧
Multiset.prod (normalizedFactors I ∩ normalizedFactors J) ∣ J
[PROOFSTEP]
constructor
[GOAL]
case a.left
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : J ≠ ⊥
H :
normalizedFactors (Multiset.prod (normalizedFactors I ∩ normalizedFactors J)) =
normalizedFactors I ∩ normalizedFactors J
this : Multiset.prod (normalizedFactors I ∩ normalizedFactors J) ≠ 0
⊢ Multiset.prod (normalizedFactors I ∩ normalizedFactors J) ∣ I
[PROOFSTEP]
rw [dvd_iff_normalizedFactors_le_normalizedFactors this hI, H]
[GOAL]
case a.left
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : J ≠ ⊥
H :
normalizedFactors (Multiset.prod (normalizedFactors I ∩ normalizedFactors J)) =
normalizedFactors I ∩ normalizedFactors J
this : Multiset.prod (normalizedFactors I ∩ normalizedFactors J) ≠ 0
⊢ normalizedFactors I ∩ normalizedFactors J ≤ normalizedFactors I
[PROOFSTEP]
exact inf_le_left
[GOAL]
case a.right
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : J ≠ ⊥
H :
normalizedFactors (Multiset.prod (normalizedFactors I ∩ normalizedFactors J)) =
normalizedFactors I ∩ normalizedFactors J
this : Multiset.prod (normalizedFactors I ∩ normalizedFactors J) ≠ 0
⊢ Multiset.prod (normalizedFactors I ∩ normalizedFactors J) ∣ J
[PROOFSTEP]
rw [dvd_iff_normalizedFactors_le_normalizedFactors this hJ, H]
[GOAL]
case a.right
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : J ≠ ⊥
H :
normalizedFactors (Multiset.prod (normalizedFactors I ∩ normalizedFactors J)) =
normalizedFactors I ∩ normalizedFactors J
this : Multiset.prod (normalizedFactors I ∩ normalizedFactors J) ≠ 0
⊢ normalizedFactors I ∩ normalizedFactors J ≤ normalizedFactors J
[PROOFSTEP]
exact inf_le_right
[GOAL]
case a
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : J ≠ ⊥
H :
normalizedFactors (Multiset.prod (normalizedFactors I ∩ normalizedFactors J)) =
normalizedFactors I ∩ normalizedFactors J
this : Multiset.prod (normalizedFactors I ∩ normalizedFactors J) ≠ 0
⊢ Multiset.prod (normalizedFactors I ∩ normalizedFactors J) ≤ I ⊔ J
[PROOFSTEP]
rw [← dvd_iff_le, dvd_iff_normalizedFactors_le_normalizedFactors, normalizedFactors_prod_of_prime, le_iff_count]
[GOAL]
case a
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : J ≠ ⊥
H :
normalizedFactors (Multiset.prod (normalizedFactors I ∩ normalizedFactors J)) =
normalizedFactors I ∩ normalizedFactors J
this : Multiset.prod (normalizedFactors I ∩ normalizedFactors J) ≠ 0
⊢ ∀ (a : Ideal T), count a (normalizedFactors (I ⊔ J)) ≤ count a (normalizedFactors I ∩ normalizedFactors J)
[PROOFSTEP]
intro a
[GOAL]
case a
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : J ≠ ⊥
H :
normalizedFactors (Multiset.prod (normalizedFactors I ∩ normalizedFactors J)) =
normalizedFactors I ∩ normalizedFactors J
this : Multiset.prod (normalizedFactors I ∩ normalizedFactors J) ≠ 0
a : Ideal T
⊢ count a (normalizedFactors (I ⊔ J)) ≤ count a (normalizedFactors I ∩ normalizedFactors J)
[PROOFSTEP]
rw [Multiset.count_inter]
[GOAL]
case a
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : J ≠ ⊥
H :
normalizedFactors (Multiset.prod (normalizedFactors I ∩ normalizedFactors J)) =
normalizedFactors I ∩ normalizedFactors J
this : Multiset.prod (normalizedFactors I ∩ normalizedFactors J) ≠ 0
a : Ideal T
⊢ count a (normalizedFactors (I ⊔ J)) ≤ min (count a (normalizedFactors I)) (count a (normalizedFactors J))
[PROOFSTEP]
exact le_min (count_le_of_ideal_ge le_sup_left hI a) (count_le_of_ideal_ge le_sup_right hJ a)
[GOAL]
case a
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : J ≠ ⊥
H :
normalizedFactors (Multiset.prod (normalizedFactors I ∩ normalizedFactors J)) =
normalizedFactors I ∩ normalizedFactors J
this : Multiset.prod (normalizedFactors I ∩ normalizedFactors J) ≠ 0
⊢ ∀ (p : Ideal T), p ∈ normalizedFactors I ∩ normalizedFactors J → Prime p
[PROOFSTEP]
intro p hp
[GOAL]
case a
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : J ≠ ⊥
H :
normalizedFactors (Multiset.prod (normalizedFactors I ∩ normalizedFactors J)) =
normalizedFactors I ∩ normalizedFactors J
this : Multiset.prod (normalizedFactors I ∩ normalizedFactors J) ≠ 0
p : Ideal T
hp : p ∈ normalizedFactors I ∩ normalizedFactors J
⊢ Prime p
[PROOFSTEP]
rw [mem_inter] at hp
[GOAL]
case a
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : J ≠ ⊥
H :
normalizedFactors (Multiset.prod (normalizedFactors I ∩ normalizedFactors J)) =
normalizedFactors I ∩ normalizedFactors J
this : Multiset.prod (normalizedFactors I ∩ normalizedFactors J) ≠ 0
p : Ideal T
hp : p ∈ normalizedFactors I ∧ p ∈ normalizedFactors J
⊢ Prime p
[PROOFSTEP]
exact prime_of_normalized_factor p hp.left
[GOAL]
case a.hx
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : J ≠ ⊥
H :
normalizedFactors (Multiset.prod (normalizedFactors I ∩ normalizedFactors J)) =
normalizedFactors I ∩ normalizedFactors J
this : Multiset.prod (normalizedFactors I ∩ normalizedFactors J) ≠ 0
⊢ I ⊔ J ≠ 0
[PROOFSTEP]
exact ne_bot_of_le_ne_bot hI le_sup_left
[GOAL]
case a.hy
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : J ≠ ⊥
H :
normalizedFactors (Multiset.prod (normalizedFactors I ∩ normalizedFactors J)) =
normalizedFactors I ∩ normalizedFactors J
this : Multiset.prod (normalizedFactors I ∩ normalizedFactors J) ≠ 0
⊢ Multiset.prod (normalizedFactors I ∩ normalizedFactors J) ≠ 0
[PROOFSTEP]
exact this
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : Irreducible J
n : ℕ
⊢ J ^ n ⊔ I = J ^ min (count J (normalizedFactors I)) n
[PROOFSTEP]
rw [sup_eq_prod_inf_factors (pow_ne_zero n hJ.ne_zero) hI, min_comm, normalizedFactors_of_irreducible_pow hJ,
normalize_eq J, replicate_inter, prod_replicate]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hJ : Irreducible J
n : ℕ
hn : ↑n ≤ multiplicity J I
⊢ J ^ n ⊔ I = J ^ n
[PROOFSTEP]
by_cases hI : I = ⊥
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hJ : Irreducible J
n : ℕ
hn : ↑n ≤ multiplicity J I
hI : I = ⊥
⊢ J ^ n ⊔ I = J ^ n
[PROOFSTEP]
simp_all
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hJ : Irreducible J
n : ℕ
hn : ↑n ≤ multiplicity J I
hI : ¬I = ⊥
⊢ J ^ n ⊔ I = J ^ n
[PROOFSTEP]
rw [irreducible_pow_sup hI hJ, min_eq_right]
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hJ : Irreducible J
n : ℕ
hn : ↑n ≤ multiplicity J I
hI : ¬I = ⊥
⊢ n ≤ count J (normalizedFactors I)
[PROOFSTEP]
rwa [multiplicity_eq_count_normalizedFactors hJ hI, PartENat.coe_le_coe, normalize_eq J] at hn
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : Irreducible J
n : ℕ
hn : multiplicity J I ≤ ↑n
⊢ J ^ n ⊔ I = J ^ Part.get (multiplicity J I) (_ : (multiplicity J I).Dom)
[PROOFSTEP]
rw [irreducible_pow_sup hI hJ, min_eq_left]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : Irreducible J
n : ℕ
hn : multiplicity J I ≤ ↑n
⊢ J ^ count J (normalizedFactors I) = J ^ Part.get (multiplicity J I) (_ : (multiplicity J I).Dom)
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : Irreducible J
n : ℕ
hn : multiplicity J I ≤ ↑n
⊢ count J (normalizedFactors I) ≤ n
[PROOFSTEP]
congr
[GOAL]
case e_a
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : Irreducible J
n : ℕ
hn : multiplicity J I ≤ ↑n
⊢ count J (normalizedFactors I) = Part.get (multiplicity J I) (_ : (multiplicity J I).Dom)
[PROOFSTEP]
rw [← PartENat.natCast_inj, PartENat.natCast_get, multiplicity_eq_count_normalizedFactors hJ hI, normalize_eq J]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
T : Type u_4
inst✝² : CommRing T
inst✝¹ : IsDomain T
inst✝ : IsDedekindDomain T
I J : Ideal T
hI : I ≠ ⊥
hJ : Irreducible J
n : ℕ
hn : multiplicity J I ≤ ↑n
⊢ count J (normalizedFactors I) ≤ n
[PROOFSTEP]
rwa [multiplicity_eq_count_normalizedFactors hJ hI, PartENat.coe_le_coe, normalize_eq J] at hn
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDomain R
inst✝¹ : IsDedekindDomain R
v : HeightOneSpectrum R
inst✝ : Algebra R K
hK : IsFractionRing R K
⊢ ⨅ (v : HeightOneSpectrum R),
Localization.subalgebra.ofField K (Ideal.primeCompl v.asIdeal) (_ : Ideal.primeCompl v.asIdeal ≤ R⁰) =
⊥
[PROOFSTEP]
ext x
[GOAL]
case h
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDomain R
inst✝¹ : IsDedekindDomain R
v : HeightOneSpectrum R
inst✝ : Algebra R K
hK : IsFractionRing R K
x : K
⊢ x ∈
⨅ (v : HeightOneSpectrum R),
Localization.subalgebra.ofField K (Ideal.primeCompl v.asIdeal) (_ : Ideal.primeCompl v.asIdeal ≤ R⁰) ↔
x ∈ ⊥
[PROOFSTEP]
rw [Algebra.mem_iInf]
[GOAL]
case h
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDomain R
inst✝¹ : IsDedekindDomain R
v : HeightOneSpectrum R
inst✝ : Algebra R K
hK : IsFractionRing R K
x : K
⊢ (∀ (i : HeightOneSpectrum R),
x ∈ Localization.subalgebra.ofField K (Ideal.primeCompl i.asIdeal) (_ : Ideal.primeCompl i.asIdeal ≤ R⁰)) ↔
x ∈ ⊥
[PROOFSTEP]
constructor
[GOAL]
case h.mp
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDomain R
inst✝¹ : IsDedekindDomain R
v : HeightOneSpectrum R
inst✝ : Algebra R K
hK : IsFractionRing R K
x : K
⊢ (∀ (i : HeightOneSpectrum R),
x ∈ Localization.subalgebra.ofField K (Ideal.primeCompl i.asIdeal) (_ : Ideal.primeCompl i.asIdeal ≤ R⁰)) →
x ∈ ⊥
case h.mpr
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDomain R
inst✝¹ : IsDedekindDomain R
v : HeightOneSpectrum R
inst✝ : Algebra R K
hK : IsFractionRing R K
x : K
⊢ x ∈ ⊥ →
∀ (i : HeightOneSpectrum R),
x ∈ Localization.subalgebra.ofField K (Ideal.primeCompl i.asIdeal) (_ : Ideal.primeCompl i.asIdeal ≤ R⁰)
[PROOFSTEP]
by_cases hR : IsField R
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDomain R
inst✝¹ : IsDedekindDomain R
v : HeightOneSpectrum R
inst✝ : Algebra R K
hK : IsFractionRing R K
x : K
hR : IsField R
⊢ (∀ (i : HeightOneSpectrum R),
x ∈ Localization.subalgebra.ofField K (Ideal.primeCompl i.asIdeal) (_ : Ideal.primeCompl i.asIdeal ≤ R⁰)) →
x ∈ ⊥
[PROOFSTEP]
rcases Function.bijective_iff_has_inverse.mp
(IsField.localization_map_bijective (Rₘ := K) (flip nonZeroDivisors.ne_zero rfl : 0 ∉ R⁰) hR) with
⟨algebra_map_inv, _, algebra_map_right_inv⟩
[GOAL]
case pos.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDomain R
inst✝¹ : IsDedekindDomain R
v : HeightOneSpectrum R
inst✝ : Algebra R K
hK : IsFractionRing R K
x : K
hR : IsField R
algebra_map_inv : K → R
left✝ : Function.LeftInverse algebra_map_inv ↑(algebraMap R K)
algebra_map_right_inv : Function.RightInverse algebra_map_inv ↑(algebraMap R K)
⊢ (∀ (i : HeightOneSpectrum R),
x ∈ Localization.subalgebra.ofField K (Ideal.primeCompl i.asIdeal) (_ : Ideal.primeCompl i.asIdeal ≤ R⁰)) →
x ∈ ⊥
[PROOFSTEP]
exact fun _ => Algebra.mem_bot.mpr ⟨algebra_map_inv x, algebra_map_right_inv x⟩
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDomain R
inst✝¹ : IsDedekindDomain R
v : HeightOneSpectrum R
inst✝ : Algebra R K
hK : IsFractionRing R K
x : K
hR : ¬IsField R
⊢ (∀ (i : HeightOneSpectrum R),
x ∈ Localization.subalgebra.ofField K (Ideal.primeCompl i.asIdeal) (_ : Ideal.primeCompl i.asIdeal ≤ R⁰)) →
x ∈ ⊥
case h.mpr
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDomain R
inst✝¹ : IsDedekindDomain R
v : HeightOneSpectrum R
inst✝ : Algebra R K
hK : IsFractionRing R K
x : K
⊢ x ∈ ⊥ →
∀ (i : HeightOneSpectrum R),
x ∈ Localization.subalgebra.ofField K (Ideal.primeCompl i.asIdeal) (_ : Ideal.primeCompl i.asIdeal ≤ R⁰)
[PROOFSTEP]
all_goals rw [← MaximalSpectrum.iInf_localization_eq_bot, Algebra.mem_iInf]
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDomain R
inst✝¹ : IsDedekindDomain R
v : HeightOneSpectrum R
inst✝ : Algebra R K
hK : IsFractionRing R K
x : K
hR : ¬IsField R
⊢ (∀ (i : HeightOneSpectrum R),
x ∈ Localization.subalgebra.ofField K (Ideal.primeCompl i.asIdeal) (_ : Ideal.primeCompl i.asIdeal ≤ R⁰)) →
x ∈ ⊥
[PROOFSTEP]
rw [← MaximalSpectrum.iInf_localization_eq_bot, Algebra.mem_iInf]
[GOAL]
case h.mpr
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDomain R
inst✝¹ : IsDedekindDomain R
v : HeightOneSpectrum R
inst✝ : Algebra R K
hK : IsFractionRing R K
x : K
⊢ x ∈ ⊥ →
∀ (i : HeightOneSpectrum R),
x ∈ Localization.subalgebra.ofField K (Ideal.primeCompl i.asIdeal) (_ : Ideal.primeCompl i.asIdeal ≤ R⁰)
[PROOFSTEP]
rw [← MaximalSpectrum.iInf_localization_eq_bot, Algebra.mem_iInf]
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDomain R
inst✝¹ : IsDedekindDomain R
v : HeightOneSpectrum R
inst✝ : Algebra R K
hK : IsFractionRing R K
x : K
hR : ¬IsField R
⊢ (∀ (i : HeightOneSpectrum R),
x ∈ Localization.subalgebra.ofField K (Ideal.primeCompl i.asIdeal) (_ : Ideal.primeCompl i.asIdeal ≤ R⁰)) →
∀ (i : MaximalSpectrum R),
x ∈ Localization.subalgebra.ofField K (Ideal.primeCompl i.asIdeal) (_ : Ideal.primeCompl i.asIdeal ≤ R⁰)
[PROOFSTEP]
exact fun hx ⟨v, hv⟩ => hx ((equivMaximalSpectrum hR).symm ⟨v, hv⟩)
[GOAL]
case h.mpr
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDomain R
inst✝¹ : IsDedekindDomain R
v : HeightOneSpectrum R
inst✝ : Algebra R K
hK : IsFractionRing R K
x : K
⊢ (∀ (i : MaximalSpectrum R),
x ∈ Localization.subalgebra.ofField K (Ideal.primeCompl i.asIdeal) (_ : Ideal.primeCompl i.asIdeal ≤ R⁰)) →
∀ (i : HeightOneSpectrum R),
x ∈ Localization.subalgebra.ofField K (Ideal.primeCompl i.asIdeal) (_ : Ideal.primeCompl i.asIdeal ≤ R⁰)
[PROOFSTEP]
exact fun hx ⟨v, hv, hbot⟩ => hx ⟨v, hv.isMaximal hbot⟩
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁴ : CommRing R
inst✝³ : CommRing A
inst✝² : Field K
inst✝¹ : IsDomain A
inst✝ : IsDedekindDomain A
I : Ideal R
J : Ideal A
f : R ⧸ I →+* A ⧸ J
hf : Function.Surjective ↑f
X : { p // p ∣ I }
⊢ comap (Ideal.Quotient.mk J) (map f (map (Ideal.Quotient.mk I) ↑X)) ∣ J
[PROOFSTEP]
have : RingHom.ker (Ideal.Quotient.mk J) ≤ comap (Ideal.Quotient.mk J) (map f (map (Ideal.Quotient.mk I) X)) :=
ker_le_comap (Ideal.Quotient.mk J)
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁴ : CommRing R
inst✝³ : CommRing A
inst✝² : Field K
inst✝¹ : IsDomain A
inst✝ : IsDedekindDomain A
I : Ideal R
J : Ideal A
f : R ⧸ I →+* A ⧸ J
hf : Function.Surjective ↑f
X : { p // p ∣ I }
this : RingHom.ker (Ideal.Quotient.mk J) ≤ comap (Ideal.Quotient.mk J) (map f (map (Ideal.Quotient.mk I) ↑X))
⊢ comap (Ideal.Quotient.mk J) (map f (map (Ideal.Quotient.mk I) ↑X)) ∣ J
[PROOFSTEP]
rw [mk_ker] at this
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁴ : CommRing R
inst✝³ : CommRing A
inst✝² : Field K
inst✝¹ : IsDomain A
inst✝ : IsDedekindDomain A
I : Ideal R
J : Ideal A
f : R ⧸ I →+* A ⧸ J
hf : Function.Surjective ↑f
X : { p // p ∣ I }
this : J ≤ comap (Ideal.Quotient.mk J) (map f (map (Ideal.Quotient.mk I) ↑X))
⊢ comap (Ideal.Quotient.mk J) (map f (map (Ideal.Quotient.mk I) ↑X)) ∣ J
[PROOFSTEP]
exact dvd_iff_le.mpr this
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁴ : CommRing R
inst✝³ : CommRing A
inst✝² : Field K
inst✝¹ : IsDomain A
inst✝ : IsDedekindDomain A
I : Ideal R
J : Ideal A
f : R ⧸ I →+* A ⧸ J
hf : Function.Surjective ↑f
⊢ Monotone fun X =>
{ val := comap (Ideal.Quotient.mk J) (map f (map (Ideal.Quotient.mk I) ↑X)),
property := (_ : comap (Ideal.Quotient.mk J) (map f (map (Ideal.Quotient.mk I) ↑X)) ∣ J) }
[PROOFSTEP]
rintro ⟨X, hX⟩ ⟨Y, hY⟩ h
[GOAL]
case mk.mk
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁴ : CommRing R
inst✝³ : CommRing A
inst✝² : Field K
inst✝¹ : IsDomain A
inst✝ : IsDedekindDomain A
I : Ideal R
J : Ideal A
f : R ⧸ I →+* A ⧸ J
hf : Function.Surjective ↑f
X : Ideal R
hX : X ∣ I
Y : Ideal R
hY : Y ∣ I
h : { val := X, property := hX } ≤ { val := Y, property := hY }
⊢ (fun X =>
{ val := comap (Ideal.Quotient.mk J) (map f (map (Ideal.Quotient.mk I) ↑X)),
property := (_ : comap (Ideal.Quotient.mk J) (map f (map (Ideal.Quotient.mk I) ↑X)) ∣ J) })
{ val := X, property := hX } ≤
(fun X =>
{ val := comap (Ideal.Quotient.mk J) (map f (map (Ideal.Quotient.mk I) ↑X)),
property := (_ : comap (Ideal.Quotient.mk J) (map f (map (Ideal.Quotient.mk I) ↑X)) ∣ J) })
{ val := Y, property := hY }
[PROOFSTEP]
rw [← Subtype.coe_le_coe, Subtype.coe_mk, Subtype.coe_mk] at h ⊢
[GOAL]
case mk.mk
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁴ : CommRing R
inst✝³ : CommRing A
inst✝² : Field K
inst✝¹ : IsDomain A
inst✝ : IsDedekindDomain A
I : Ideal R
J : Ideal A
f : R ⧸ I →+* A ⧸ J
hf : Function.Surjective ↑f
X : Ideal R
hX : X ∣ I
Y : Ideal R
hY : Y ∣ I
h : X ≤ Y
⊢ comap (Ideal.Quotient.mk J) (map f (map (Ideal.Quotient.mk I) X)) ≤
↑((fun X =>
{ val := comap (Ideal.Quotient.mk J) (map f (map (Ideal.Quotient.mk I) ↑X)),
property := (_ : comap (Ideal.Quotient.mk J) (map f (map (Ideal.Quotient.mk I) ↑X)) ∣ J) })
{ val := Y, property := hY })
[PROOFSTEP]
rw [Subtype.coe_mk, comap_le_comap_iff_of_surjective (Ideal.Quotient.mk J) Quotient.mk_surjective, map_le_iff_le_comap,
Subtype.coe_mk, comap_map_of_surjective _ hf (map (Ideal.Quotient.mk I) Y)]
[GOAL]
case mk.mk
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁴ : CommRing R
inst✝³ : CommRing A
inst✝² : Field K
inst✝¹ : IsDomain A
inst✝ : IsDedekindDomain A
I : Ideal R
J : Ideal A
f : R ⧸ I →+* A ⧸ J
hf : Function.Surjective ↑f
X : Ideal R
hX : X ∣ I
Y : Ideal R
hY : Y ∣ I
h : X ≤ Y
⊢ map (Ideal.Quotient.mk I) X ≤ map (Ideal.Quotient.mk I) Y ⊔ comap f ⊥
[PROOFSTEP]
suffices map (Ideal.Quotient.mk I) X ≤ map (Ideal.Quotient.mk I) Y by exact le_sup_of_le_left this
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁴ : CommRing R
inst✝³ : CommRing A
inst✝² : Field K
inst✝¹ : IsDomain A
inst✝ : IsDedekindDomain A
I : Ideal R
J : Ideal A
f : R ⧸ I →+* A ⧸ J
hf : Function.Surjective ↑f
X : Ideal R
hX : X ∣ I
Y : Ideal R
hY : Y ∣ I
h : X ≤ Y
this : map (Ideal.Quotient.mk I) X ≤ map (Ideal.Quotient.mk I) Y
⊢ map (Ideal.Quotient.mk I) X ≤ map (Ideal.Quotient.mk I) Y ⊔ comap f ⊥
[PROOFSTEP]
exact le_sup_of_le_left this
[GOAL]
case mk.mk
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁴ : CommRing R
inst✝³ : CommRing A
inst✝² : Field K
inst✝¹ : IsDomain A
inst✝ : IsDedekindDomain A
I : Ideal R
J : Ideal A
f : R ⧸ I →+* A ⧸ J
hf : Function.Surjective ↑f
X : Ideal R
hX : X ∣ I
Y : Ideal R
hY : Y ∣ I
h : X ≤ Y
⊢ map (Ideal.Quotient.mk I) X ≤ map (Ideal.Quotient.mk I) Y
[PROOFSTEP]
rwa [map_le_iff_le_comap, comap_map_of_surjective (Ideal.Quotient.mk I) Quotient.mk_surjective, ←
RingHom.ker_eq_comap_bot, mk_ker, sup_eq_left.mpr <| le_of_dvd hY]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁴ : CommRing R
inst✝³ : CommRing A
inst✝² : Field K
inst✝¹ : IsDomain A
inst✝ : IsDedekindDomain A
I : Ideal R
J : Ideal A
X : { p // p ∣ J }
⊢ ↑(idealFactorsFunOfQuotHom (_ : Function.Surjective ↑(RingHom.id (A ⧸ J)))) X = ↑OrderHom.id X
[PROOFSTEP]
simp only [idealFactorsFunOfQuotHom, map_id, OrderHom.coe_mk, OrderHom.id_coe, id.def,
comap_map_of_surjective (Ideal.Quotient.mk J) Quotient.mk_surjective, ←
RingHom.ker_eq_comap_bot (Ideal.Quotient.mk J), mk_ker, sup_eq_left.mpr (dvd_iff_le.mp X.prop), Subtype.coe_eta]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
inst✝³ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝² : CommRing B
inst✝¹ : IsDomain B
inst✝ : IsDedekindDomain B
L : Ideal B
f : R ⧸ I →+* A ⧸ J
g : A ⧸ J →+* B ⧸ L
hf : Function.Surjective ↑f
hg : Function.Surjective ↑g
⊢ OrderHom.comp (idealFactorsFunOfQuotHom hg) (idealFactorsFunOfQuotHom hf) =
idealFactorsFunOfQuotHom (_ : Function.Surjective ↑(RingHom.comp g f))
[PROOFSTEP]
refine OrderHom.ext _ _ (funext fun x => ?_)
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
inst✝³ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝² : CommRing B
inst✝¹ : IsDomain B
inst✝ : IsDedekindDomain B
L : Ideal B
f : R ⧸ I →+* A ⧸ J
g : A ⧸ J →+* B ⧸ L
hf : Function.Surjective ↑f
hg : Function.Surjective ↑g
x : { p // p ∣ I }
⊢ ↑(OrderHom.comp (idealFactorsFunOfQuotHom hg) (idealFactorsFunOfQuotHom hf)) x =
↑(idealFactorsFunOfQuotHom (_ : Function.Surjective ↑(RingHom.comp g f))) x
[PROOFSTEP]
rw [idealFactorsFunOfQuotHom, idealFactorsFunOfQuotHom, OrderHom.comp_coe, OrderHom.coe_mk, OrderHom.coe_mk,
Function.comp_apply, idealFactorsFunOfQuotHom, OrderHom.coe_mk, Subtype.mk_eq_mk, Subtype.coe_mk,
map_comap_of_surjective (Ideal.Quotient.mk J) Quotient.mk_surjective, map_map]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁹ : CommRing R
inst✝⁸ : CommRing A
inst✝⁷ : Field K
inst✝⁶ : IsDomain A
inst✝⁵ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁴ : CommRing B
inst✝³ : IsDomain B
inst✝² : IsDedekindDomain B
L : Ideal B
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
⊢ ↑{p | p ∣ I} ≃o ↑{p | p ∣ J}
[PROOFSTEP]
have f_surj : Function.Surjective (f : R ⧸ I →+* A ⧸ J) := f.surjective
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁹ : CommRing R
inst✝⁸ : CommRing A
inst✝⁷ : Field K
inst✝⁶ : IsDomain A
inst✝⁵ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁴ : CommRing B
inst✝³ : IsDomain B
inst✝² : IsDedekindDomain B
L : Ideal B
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
f_surj : Function.Surjective ↑↑f
⊢ ↑{p | p ∣ I} ≃o ↑{p | p ∣ J}
[PROOFSTEP]
have fsym_surj : Function.Surjective (f.symm : A ⧸ J →+* R ⧸ I) := f.symm.surjective
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁹ : CommRing R
inst✝⁸ : CommRing A
inst✝⁷ : Field K
inst✝⁶ : IsDomain A
inst✝⁵ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁴ : CommRing B
inst✝³ : IsDomain B
inst✝² : IsDedekindDomain B
L : Ideal B
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
f_surj : Function.Surjective ↑↑f
fsym_surj : Function.Surjective ↑↑(RingEquiv.symm f)
⊢ ↑{p | p ∣ I} ≃o ↑{p | p ∣ J}
[PROOFSTEP]
refine OrderIso.ofHomInv (idealFactorsFunOfQuotHom f_surj) (idealFactorsFunOfQuotHom fsym_surj) ?_ ?_
[GOAL]
case refine_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁹ : CommRing R
inst✝⁸ : CommRing A
inst✝⁷ : Field K
inst✝⁶ : IsDomain A
inst✝⁵ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁴ : CommRing B
inst✝³ : IsDomain B
inst✝² : IsDedekindDomain B
L : Ideal B
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
f_surj : Function.Surjective ↑↑f
fsym_surj : Function.Surjective ↑↑(RingEquiv.symm f)
⊢ OrderHom.comp ↑(idealFactorsFunOfQuotHom f_surj) ↑(idealFactorsFunOfQuotHom fsym_surj) = OrderHom.id
[PROOFSTEP]
have := idealFactorsFunOfQuotHom_comp fsym_surj f_surj
[GOAL]
case refine_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁹ : CommRing R
inst✝⁸ : CommRing A
inst✝⁷ : Field K
inst✝⁶ : IsDomain A
inst✝⁵ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁴ : CommRing B
inst✝³ : IsDomain B
inst✝² : IsDedekindDomain B
L : Ideal B
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
f_surj : Function.Surjective ↑↑f
fsym_surj : Function.Surjective ↑↑(RingEquiv.symm f)
this :
OrderHom.comp (idealFactorsFunOfQuotHom f_surj) (idealFactorsFunOfQuotHom fsym_surj) =
idealFactorsFunOfQuotHom (_ : Function.Surjective ↑(RingHom.comp ↑f ↑(RingEquiv.symm f)))
⊢ OrderHom.comp ↑(idealFactorsFunOfQuotHom f_surj) ↑(idealFactorsFunOfQuotHom fsym_surj) = OrderHom.id
[PROOFSTEP]
simp only [RingEquiv.comp_symm, idealFactorsFunOfQuotHom_id] at this
[GOAL]
case refine_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁹ : CommRing R
inst✝⁸ : CommRing A
inst✝⁷ : Field K
inst✝⁶ : IsDomain A
inst✝⁵ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁴ : CommRing B
inst✝³ : IsDomain B
inst✝² : IsDedekindDomain B
L : Ideal B
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
f_surj : Function.Surjective ↑↑f
fsym_surj : Function.Surjective ↑↑(RingEquiv.symm f)
this : OrderHom.comp (idealFactorsFunOfQuotHom f_surj) (idealFactorsFunOfQuotHom fsym_surj) = OrderHom.id
⊢ OrderHom.comp ↑(idealFactorsFunOfQuotHom f_surj) ↑(idealFactorsFunOfQuotHom fsym_surj) = OrderHom.id
[PROOFSTEP]
rw [← this]
[GOAL]
case refine_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁹ : CommRing R
inst✝⁸ : CommRing A
inst✝⁷ : Field K
inst✝⁶ : IsDomain A
inst✝⁵ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁴ : CommRing B
inst✝³ : IsDomain B
inst✝² : IsDedekindDomain B
L : Ideal B
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
f_surj : Function.Surjective ↑↑f
fsym_surj : Function.Surjective ↑↑(RingEquiv.symm f)
this : OrderHom.comp (idealFactorsFunOfQuotHom f_surj) (idealFactorsFunOfQuotHom fsym_surj) = OrderHom.id
⊢ OrderHom.comp ↑(idealFactorsFunOfQuotHom f_surj) ↑(idealFactorsFunOfQuotHom fsym_surj) =
OrderHom.comp (idealFactorsFunOfQuotHom f_surj) (idealFactorsFunOfQuotHom fsym_surj)
[PROOFSTEP]
congr
[GOAL]
case refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁹ : CommRing R
inst✝⁸ : CommRing A
inst✝⁷ : Field K
inst✝⁶ : IsDomain A
inst✝⁵ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁴ : CommRing B
inst✝³ : IsDomain B
inst✝² : IsDedekindDomain B
L : Ideal B
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
f_surj : Function.Surjective ↑↑f
fsym_surj : Function.Surjective ↑↑(RingEquiv.symm f)
⊢ OrderHom.comp ↑(idealFactorsFunOfQuotHom fsym_surj) ↑(idealFactorsFunOfQuotHom f_surj) = OrderHom.id
[PROOFSTEP]
have := idealFactorsFunOfQuotHom_comp f_surj fsym_surj
[GOAL]
case refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁹ : CommRing R
inst✝⁸ : CommRing A
inst✝⁷ : Field K
inst✝⁶ : IsDomain A
inst✝⁵ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁴ : CommRing B
inst✝³ : IsDomain B
inst✝² : IsDedekindDomain B
L : Ideal B
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
f_surj : Function.Surjective ↑↑f
fsym_surj : Function.Surjective ↑↑(RingEquiv.symm f)
this :
OrderHom.comp (idealFactorsFunOfQuotHom fsym_surj) (idealFactorsFunOfQuotHom f_surj) =
idealFactorsFunOfQuotHom (_ : Function.Surjective ↑(RingHom.comp ↑(RingEquiv.symm f) ↑f))
⊢ OrderHom.comp ↑(idealFactorsFunOfQuotHom fsym_surj) ↑(idealFactorsFunOfQuotHom f_surj) = OrderHom.id
[PROOFSTEP]
simp only [RingEquiv.symm_comp, idealFactorsFunOfQuotHom_id] at this
[GOAL]
case refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁹ : CommRing R
inst✝⁸ : CommRing A
inst✝⁷ : Field K
inst✝⁶ : IsDomain A
inst✝⁵ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁴ : CommRing B
inst✝³ : IsDomain B
inst✝² : IsDedekindDomain B
L : Ideal B
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
f_surj : Function.Surjective ↑↑f
fsym_surj : Function.Surjective ↑↑(RingEquiv.symm f)
this : OrderHom.comp (idealFactorsFunOfQuotHom fsym_surj) (idealFactorsFunOfQuotHom f_surj) = OrderHom.id
⊢ OrderHom.comp ↑(idealFactorsFunOfQuotHom fsym_surj) ↑(idealFactorsFunOfQuotHom f_surj) = OrderHom.id
[PROOFSTEP]
rw [← this]
[GOAL]
case refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁹ : CommRing R
inst✝⁸ : CommRing A
inst✝⁷ : Field K
inst✝⁶ : IsDomain A
inst✝⁵ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁴ : CommRing B
inst✝³ : IsDomain B
inst✝² : IsDedekindDomain B
L : Ideal B
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
f_surj : Function.Surjective ↑↑f
fsym_surj : Function.Surjective ↑↑(RingEquiv.symm f)
this : OrderHom.comp (idealFactorsFunOfQuotHom fsym_surj) (idealFactorsFunOfQuotHom f_surj) = OrderHom.id
⊢ OrderHom.comp ↑(idealFactorsFunOfQuotHom fsym_surj) ↑(idealFactorsFunOfQuotHom f_surj) =
OrderHom.comp (idealFactorsFunOfQuotHom fsym_surj) (idealFactorsFunOfQuotHom f_surj)
[PROOFSTEP]
congr
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁹ : CommRing R
inst✝⁸ : CommRing A
inst✝⁷ : Field K
inst✝⁶ : IsDomain A
inst✝⁵ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁴ : CommRing B
inst✝³ : IsDomain B
inst✝² : IsDedekindDomain B
L✝ : Ideal B
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
L M : Ideal R
hL : L ∣ I
hM : M ∣ I
⊢ ↑(↑(idealFactorsEquivOfQuotEquiv f) { val := L, property := hL }) ∣
↑(↑(idealFactorsEquivOfQuotEquiv f) { val := M, property := hM }) ↔
L ∣ M
[PROOFSTEP]
suffices
idealFactorsEquivOfQuotEquiv f ⟨M, hM⟩ ≤ idealFactorsEquivOfQuotEquiv f ⟨L, hL⟩ ↔
(⟨M, hM⟩ : {p : Ideal R | p ∣ I}) ≤ ⟨L, hL⟩
by rw [dvd_iff_le, dvd_iff_le, Subtype.coe_le_coe, this, Subtype.mk_le_mk]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁹ : CommRing R
inst✝⁸ : CommRing A
inst✝⁷ : Field K
inst✝⁶ : IsDomain A
inst✝⁵ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁴ : CommRing B
inst✝³ : IsDomain B
inst✝² : IsDedekindDomain B
L✝ : Ideal B
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
L M : Ideal R
hL : L ∣ I
hM : M ∣ I
this :
↑(idealFactorsEquivOfQuotEquiv f) { val := M, property := hM } ≤
↑(idealFactorsEquivOfQuotEquiv f) { val := L, property := hL } ↔
{ val := M, property := hM } ≤ { val := L, property := hL }
⊢ ↑(↑(idealFactorsEquivOfQuotEquiv f) { val := L, property := hL }) ∣
↑(↑(idealFactorsEquivOfQuotEquiv f) { val := M, property := hM }) ↔
L ∣ M
[PROOFSTEP]
rw [dvd_iff_le, dvd_iff_le, Subtype.coe_le_coe, this, Subtype.mk_le_mk]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁹ : CommRing R
inst✝⁸ : CommRing A
inst✝⁷ : Field K
inst✝⁶ : IsDomain A
inst✝⁵ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁴ : CommRing B
inst✝³ : IsDomain B
inst✝² : IsDedekindDomain B
L✝ : Ideal B
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
L M : Ideal R
hL : L ∣ I
hM : M ∣ I
⊢ ↑(idealFactorsEquivOfQuotEquiv f) { val := M, property := hM } ≤
↑(idealFactorsEquivOfQuotEquiv f) { val := L, property := hL } ↔
{ val := M, property := hM } ≤ { val := L, property := hL }
[PROOFSTEP]
exact (idealFactorsEquivOfQuotEquiv f).le_iff_le
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
inst✝⁷ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁶ : CommRing B
inst✝⁵ : IsDomain B
inst✝⁴ : IsDedekindDomain B
L✝ : Ideal B
inst✝³ : IsDomain R
inst✝² : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
inst✝¹ : DecidableEq (Ideal R)
inst✝ : DecidableEq (Ideal A)
hJ : J ≠ ⊥
L : Ideal R
hL : L ∈ normalizedFactors I
⊢ ↑(↑(idealFactorsEquivOfQuotEquiv f) { val := L, property := (_ : L ∣ I) }) ∈ normalizedFactors J
[PROOFSTEP]
by_cases hI : I = ⊥
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
inst✝⁷ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁶ : CommRing B
inst✝⁵ : IsDomain B
inst✝⁴ : IsDedekindDomain B
L✝ : Ideal B
inst✝³ : IsDomain R
inst✝² : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
inst✝¹ : DecidableEq (Ideal R)
inst✝ : DecidableEq (Ideal A)
hJ : J ≠ ⊥
L : Ideal R
hL : L ∈ normalizedFactors I
hI : I = ⊥
⊢ ↑(↑(idealFactorsEquivOfQuotEquiv f) { val := L, property := (_ : L ∣ I) }) ∈ normalizedFactors J
[PROOFSTEP]
exfalso
[GOAL]
case pos.h
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
inst✝⁷ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁶ : CommRing B
inst✝⁵ : IsDomain B
inst✝⁴ : IsDedekindDomain B
L✝ : Ideal B
inst✝³ : IsDomain R
inst✝² : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
inst✝¹ : DecidableEq (Ideal R)
inst✝ : DecidableEq (Ideal A)
hJ : J ≠ ⊥
L : Ideal R
hL : L ∈ normalizedFactors I
hI : I = ⊥
⊢ False
[PROOFSTEP]
rw [hI, bot_eq_zero, normalizedFactors_zero, ← Multiset.empty_eq_zero] at hL
[GOAL]
case pos.h
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
inst✝⁷ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁶ : CommRing B
inst✝⁵ : IsDomain B
inst✝⁴ : IsDedekindDomain B
L✝ : Ideal B
inst✝³ : IsDomain R
inst✝² : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
inst✝¹ : DecidableEq (Ideal R)
inst✝ : DecidableEq (Ideal A)
hJ : J ≠ ⊥
L : Ideal R
hL : L ∈ ∅
hI : I = ⊥
⊢ False
[PROOFSTEP]
exact Finset.not_mem_empty _ hL
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
inst✝⁷ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁶ : CommRing B
inst✝⁵ : IsDomain B
inst✝⁴ : IsDedekindDomain B
L✝ : Ideal B
inst✝³ : IsDomain R
inst✝² : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
inst✝¹ : DecidableEq (Ideal R)
inst✝ : DecidableEq (Ideal A)
hJ : J ≠ ⊥
L : Ideal R
hL : L ∈ normalizedFactors I
hI : ¬I = ⊥
⊢ ↑(↑(idealFactorsEquivOfQuotEquiv f) { val := L, property := (_ : L ∣ I) }) ∈ normalizedFactors J
[PROOFSTEP]
refine
mem_normalizedFactors_factor_dvd_iso_of_mem_normalizedFactors hI hJ hL (d := (idealFactorsEquivOfQuotEquiv f).toEquiv)
?_
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
inst✝⁷ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁶ : CommRing B
inst✝⁵ : IsDomain B
inst✝⁴ : IsDedekindDomain B
L✝ : Ideal B
inst✝³ : IsDomain R
inst✝² : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
inst✝¹ : DecidableEq (Ideal R)
inst✝ : DecidableEq (Ideal A)
hJ : J ≠ ⊥
L : Ideal R
hL : L ∈ normalizedFactors I
hI : ¬I = ⊥
⊢ ∀ (l l' : { l // l ∣ I }),
↑(↑(idealFactorsEquivOfQuotEquiv f).toEquiv l) ∣ ↑(↑(idealFactorsEquivOfQuotEquiv f).toEquiv l') ↔ ↑l ∣ ↑l'
[PROOFSTEP]
rintro ⟨l, hl⟩ ⟨l', hl'⟩
[GOAL]
case neg.mk.mk
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
inst✝⁷ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁶ : CommRing B
inst✝⁵ : IsDomain B
inst✝⁴ : IsDedekindDomain B
L✝ : Ideal B
inst✝³ : IsDomain R
inst✝² : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
inst✝¹ : DecidableEq (Ideal R)
inst✝ : DecidableEq (Ideal A)
hJ : J ≠ ⊥
L : Ideal R
hL : L ∈ normalizedFactors I
hI : ¬I = ⊥
l : Ideal R
hl : l ∣ I
l' : Ideal R
hl' : l' ∣ I
⊢ ↑(↑(idealFactorsEquivOfQuotEquiv f).toEquiv { val := l, property := hl }) ∣
↑(↑(idealFactorsEquivOfQuotEquiv f).toEquiv { val := l', property := hl' }) ↔
↑{ val := l, property := hl } ∣ ↑{ val := l', property := hl' }
[PROOFSTEP]
rw [Subtype.coe_mk, Subtype.coe_mk]
[GOAL]
case neg.mk.mk
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
inst✝⁷ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁶ : CommRing B
inst✝⁵ : IsDomain B
inst✝⁴ : IsDedekindDomain B
L✝ : Ideal B
inst✝³ : IsDomain R
inst✝² : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
inst✝¹ : DecidableEq (Ideal R)
inst✝ : DecidableEq (Ideal A)
hJ : J ≠ ⊥
L : Ideal R
hL : L ∈ normalizedFactors I
hI : ¬I = ⊥
l : Ideal R
hl : l ∣ I
l' : Ideal R
hl' : l' ∣ I
⊢ ↑(↑(idealFactorsEquivOfQuotEquiv f).toEquiv { val := l, property := hl }) ∣
↑(↑(idealFactorsEquivOfQuotEquiv f).toEquiv { val := l', property := hl' }) ↔
↑{ val := l, property := hl } ∣ ↑{ val := l', property := hl' }
[PROOFSTEP]
apply idealFactorsEquivOfQuotEquiv_is_dvd_iso f
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
inst✝⁷ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁶ : CommRing B
inst✝⁵ : IsDomain B
inst✝⁴ : IsDedekindDomain B
L : Ideal B
inst✝³ : IsDomain R
inst✝² : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
inst✝¹ : DecidableEq (Ideal R)
inst✝ : DecidableEq (Ideal A)
hI : I ≠ ⊥
hJ : J ≠ ⊥
j : ↑{M | M ∈ normalizedFactors J}
⊢ ↑(↑(OrderIso.symm (idealFactorsEquivOfQuotEquiv f)) { val := ↑j, property := (_ : ↑j ∣ J) }) ∈
{L | L ∈ normalizedFactors I}
[PROOFSTEP]
rw [idealFactorsEquivOfQuotEquiv_symm]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
inst✝⁷ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁶ : CommRing B
inst✝⁵ : IsDomain B
inst✝⁴ : IsDedekindDomain B
L : Ideal B
inst✝³ : IsDomain R
inst✝² : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
inst✝¹ : DecidableEq (Ideal R)
inst✝ : DecidableEq (Ideal A)
hI : I ≠ ⊥
hJ : J ≠ ⊥
j : ↑{M | M ∈ normalizedFactors J}
⊢ ↑(↑(idealFactorsEquivOfQuotEquiv (RingEquiv.symm f)) { val := ↑j, property := (_ : ↑j ∣ J) }) ∈
{L | L ∈ normalizedFactors I}
[PROOFSTEP]
exact idealFactorsEquivOfQuotEquiv_mem_normalizedFactors_of_mem_normalizedFactors f.symm hI j.prop
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
inst✝⁷ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁶ : CommRing B
inst✝⁵ : IsDomain B
inst✝⁴ : IsDedekindDomain B
L : Ideal B
inst✝³ : IsDomain R
inst✝² : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
inst✝¹ : DecidableEq (Ideal R)
inst✝ : DecidableEq (Ideal A)
hI : I ≠ ⊥
hJ : J ≠ ⊥
x✝ : ↑{L | L ∈ normalizedFactors I}
j : Ideal R
hj : j ∈ {L | L ∈ normalizedFactors I}
⊢ (fun j =>
{ val := ↑(↑(OrderIso.symm (idealFactorsEquivOfQuotEquiv f)) { val := ↑j, property := (_ : ↑j ∣ J) }),
property :=
(_ :
↑(↑(OrderIso.symm (idealFactorsEquivOfQuotEquiv f)) { val := ↑j, property := (_ : ↑j ∣ J) }) ∈
{L | L ∈ normalizedFactors I}) })
((fun j =>
{ val := ↑(↑(idealFactorsEquivOfQuotEquiv f) { val := ↑j, property := (_ : ↑j ∣ I) }),
property :=
(_ :
↑(↑(idealFactorsEquivOfQuotEquiv f) { val := ↑j, property := (_ : ↑j ∣ I) }) ∈ normalizedFactors J) })
{ val := j, property := hj }) =
{ val := j, property := hj }
[PROOFSTEP]
simp
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : Field K
inst✝⁸ : IsDomain A
inst✝⁷ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁶ : CommRing B
inst✝⁵ : IsDomain B
inst✝⁴ : IsDedekindDomain B
L : Ideal B
inst✝³ : IsDomain R
inst✝² : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
inst✝¹ : DecidableEq (Ideal R)
inst✝ : DecidableEq (Ideal A)
hI : I ≠ ⊥
hJ : J ≠ ⊥
x✝ : ↑{M | M ∈ normalizedFactors J}
j : Ideal A
hj : j ∈ {M | M ∈ normalizedFactors J}
⊢ (fun j =>
{ val := ↑(↑(idealFactorsEquivOfQuotEquiv f) { val := ↑j, property := (_ : ↑j ∣ I) }),
property :=
(_ : ↑(↑(idealFactorsEquivOfQuotEquiv f) { val := ↑j, property := (_ : ↑j ∣ I) }) ∈ normalizedFactors J) })
((fun j =>
{ val := ↑(↑(OrderIso.symm (idealFactorsEquivOfQuotEquiv f)) { val := ↑j, property := (_ : ↑j ∣ J) }),
property :=
(_ :
↑(↑(OrderIso.symm (idealFactorsEquivOfQuotEquiv f)) { val := ↑j, property := (_ : ↑j ∣ J) }) ∈
{L | L ∈ normalizedFactors I}) })
{ val := j, property := hj }) =
{ val := j, property := hj }
[PROOFSTEP]
simp
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹³ : CommRing R
inst✝¹² : CommRing A
inst✝¹¹ : Field K
inst✝¹⁰ : IsDomain A
inst✝⁹ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁸ : CommRing B
inst✝⁷ : IsDomain B
inst✝⁶ : IsDedekindDomain B
L✝ : Ideal B
inst✝⁵ : IsDomain R
inst✝⁴ : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
inst✝³ : DecidableEq (Ideal R)
inst✝² : DecidableEq (Ideal A)
inst✝¹ : DecidableRel fun x x_1 => x ∣ x_1
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
hI : I ≠ ⊥
hJ : J ≠ ⊥
L : Ideal R
hL : L ∈ normalizedFactors I
⊢ multiplicity (↑(↑(normalizedFactorsEquivOfQuotEquiv f hI hJ) { val := L, property := hL })) J = multiplicity L I
[PROOFSTEP]
rw [normalizedFactorsEquivOfQuotEquiv, Equiv.coe_fn_mk, Subtype.coe_mk]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹³ : CommRing R
inst✝¹² : CommRing A
inst✝¹¹ : Field K
inst✝¹⁰ : IsDomain A
inst✝⁹ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁸ : CommRing B
inst✝⁷ : IsDomain B
inst✝⁶ : IsDedekindDomain B
L✝ : Ideal B
inst✝⁵ : IsDomain R
inst✝⁴ : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
inst✝³ : DecidableEq (Ideal R)
inst✝² : DecidableEq (Ideal A)
inst✝¹ : DecidableRel fun x x_1 => x ∣ x_1
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
hI : I ≠ ⊥
hJ : J ≠ ⊥
L : Ideal R
hL : L ∈ normalizedFactors I
⊢ multiplicity
(↑(↑(idealFactorsEquivOfQuotEquiv f)
{ val := ↑{ val := L, property := hL }, property := (_ : ↑{ val := L, property := hL } ∣ I) }))
J =
multiplicity L I
[PROOFSTEP]
refine
multiplicity_factor_dvd_iso_eq_multiplicity_of_mem_normalizedFactors hI hJ hL (d :=
(idealFactorsEquivOfQuotEquiv f).toEquiv) ?_
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹³ : CommRing R
inst✝¹² : CommRing A
inst✝¹¹ : Field K
inst✝¹⁰ : IsDomain A
inst✝⁹ : IsDedekindDomain A
I : Ideal R
J : Ideal A
B : Type u_4
inst✝⁸ : CommRing B
inst✝⁷ : IsDomain B
inst✝⁶ : IsDedekindDomain B
L✝ : Ideal B
inst✝⁵ : IsDomain R
inst✝⁴ : IsDedekindDomain R
f : R ⧸ I ≃+* A ⧸ J
inst✝³ : DecidableEq (Ideal R)
inst✝² : DecidableEq (Ideal A)
inst✝¹ : DecidableRel fun x x_1 => x ∣ x_1
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
hI : I ≠ ⊥
hJ : J ≠ ⊥
L : Ideal R
hL : L ∈ normalizedFactors I
⊢ ∀ (l l' : { l // l ∣ I }),
↑(↑(idealFactorsEquivOfQuotEquiv f).toEquiv l) ∣ ↑(↑(idealFactorsEquivOfQuotEquiv f).toEquiv l') ↔ ↑l ∣ ↑l'
[PROOFSTEP]
exact fun ⟨l, hl⟩ ⟨l', hl'⟩ => idealFactorsEquivOfQuotEquiv_is_dvd_iso f hl hl'
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝³ : CommRing R
inst✝² : CommRing A
inst✝¹ : Field K
inst✝ : IsDomain A
I J : Ideal R
h : ∀ (P : Ideal R), I ≤ P → J ≤ P → ¬IsPrime P
⊢ I ⊔ J = ⊤
[PROOFSTEP]
by_contra hIJ
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝³ : CommRing R
inst✝² : CommRing A
inst✝¹ : Field K
inst✝ : IsDomain A
I J : Ideal R
h : ∀ (P : Ideal R), I ≤ P → J ≤ P → ¬IsPrime P
hIJ : ¬I ⊔ J = ⊤
⊢ False
[PROOFSTEP]
obtain ⟨P, hP, hIJ⟩ := Ideal.exists_le_maximal _ hIJ
[GOAL]
case intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝³ : CommRing R
inst✝² : CommRing A
inst✝¹ : Field K
inst✝ : IsDomain A
I J : Ideal R
h : ∀ (P : Ideal R), I ≤ P → J ≤ P → ¬IsPrime P
hIJ✝ : ¬I ⊔ J = ⊤
P : Ideal R
hP : IsMaximal P
hIJ : I ⊔ J ≤ P
⊢ False
[PROOFSTEP]
exact h P (le_trans le_sup_left hIJ) (le_trans le_sup_right hIJ) hP.isPrime
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
I : Ideal R
hI : IsPrime I
a b : R
n : ℕ
h : a * b ∈ I ^ n
⊢ a ∈ I ∨ b ∈ I ^ n
[PROOFSTEP]
cases n
[GOAL]
case zero
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
I : Ideal R
hI : IsPrime I
a b : R
h : a * b ∈ I ^ Nat.zero
⊢ a ∈ I ∨ b ∈ I ^ Nat.zero
[PROOFSTEP]
simp
[GOAL]
case succ
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
I : Ideal R
hI : IsPrime I
a b : R
n✝ : ℕ
h : a * b ∈ I ^ Nat.succ n✝
⊢ a ∈ I ∨ b ∈ I ^ Nat.succ n✝
[PROOFSTEP]
by_cases hI0 : I = ⊥
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
I : Ideal R
hI : IsPrime I
a b : R
n✝ : ℕ
h : a * b ∈ I ^ Nat.succ n✝
hI0 : I = ⊥
⊢ a ∈ I ∨ b ∈ I ^ Nat.succ n✝
[PROOFSTEP]
simpa [pow_succ, hI0] using h
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
I : Ideal R
hI : IsPrime I
a b : R
n✝ : ℕ
h : a * b ∈ I ^ Nat.succ n✝
hI0 : ¬I = ⊥
⊢ a ∈ I ∨ b ∈ I ^ Nat.succ n✝
[PROOFSTEP]
simp only [← Submodule.span_singleton_le_iff_mem, Ideal.submodule_span_eq, ← Ideal.dvd_iff_le, ←
Ideal.span_singleton_mul_span_singleton] at h ⊢
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
I : Ideal R
hI : IsPrime I
a b : R
n✝ : ℕ
hI0 : ¬I = ⊥
h : I ^ Nat.succ n✝ ∣ span {a} * span {b}
⊢ I ∣ span {a} ∨ I ^ Nat.succ n✝ ∣ span {b}
[PROOFSTEP]
by_cases ha : I ∣ span { a }
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
I : Ideal R
hI : IsPrime I
a b : R
n✝ : ℕ
hI0 : ¬I = ⊥
h : I ^ Nat.succ n✝ ∣ span {a} * span {b}
ha : I ∣ span {a}
⊢ I ∣ span {a} ∨ I ^ Nat.succ n✝ ∣ span {b}
[PROOFSTEP]
exact Or.inl ha
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
I : Ideal R
hI : IsPrime I
a b : R
n✝ : ℕ
hI0 : ¬I = ⊥
h : I ^ Nat.succ n✝ ∣ span {a} * span {b}
ha : ¬I ∣ span {a}
⊢ I ∣ span {a} ∨ I ^ Nat.succ n✝ ∣ span {b}
[PROOFSTEP]
rw [mul_comm] at h
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
I : Ideal R
hI : IsPrime I
a b : R
n✝ : ℕ
hI0 : ¬I = ⊥
h : I ^ Nat.succ n✝ ∣ span {b} * span {a}
ha : ¬I ∣ span {a}
⊢ I ∣ span {a} ∨ I ^ Nat.succ n✝ ∣ span {b}
[PROOFSTEP]
exact Or.inr (Prime.pow_dvd_of_dvd_mul_right ((Ideal.prime_iff_isPrime hI0).mpr hI) _ ha h)
[GOAL]
R : Type u_1
A : Type u_2
K✝ : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K✝
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
I J K : Ideal R
coprime : ∀ (P : Ideal R), J ≤ P → K ≤ P → ¬IsPrime P
hJ : I ≤ J
hK : I ≤ K
⊢ I ≤ J * K
[PROOFSTEP]
simp only [← Ideal.dvd_iff_le] at coprime hJ hK ⊢
[GOAL]
R : Type u_1
A : Type u_2
K✝ : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K✝
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
I J K : Ideal R
coprime : ∀ (P : Ideal R), P ∣ J → P ∣ K → ¬IsPrime P
hJ : J ∣ I
hK : K ∣ I
⊢ J * K ∣ I
[PROOFSTEP]
by_cases hJ0 : J = 0
[GOAL]
case pos
R : Type u_1
A : Type u_2
K✝ : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K✝
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
I J K : Ideal R
coprime : ∀ (P : Ideal R), P ∣ J → P ∣ K → ¬IsPrime P
hJ : J ∣ I
hK : K ∣ I
hJ0 : J = 0
⊢ J * K ∣ I
[PROOFSTEP]
simpa only [hJ0, zero_mul] using hJ
[GOAL]
case neg
R : Type u_1
A : Type u_2
K✝ : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K✝
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
I J K : Ideal R
coprime : ∀ (P : Ideal R), P ∣ J → P ∣ K → ¬IsPrime P
hJ : J ∣ I
hK : K ∣ I
hJ0 : ¬J = 0
⊢ J * K ∣ I
[PROOFSTEP]
obtain ⟨I', rfl⟩ := hK
[GOAL]
case neg.intro
R : Type u_1
A : Type u_2
K✝ : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K✝
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
J K : Ideal R
coprime : ∀ (P : Ideal R), P ∣ J → P ∣ K → ¬IsPrime P
hJ0 : ¬J = 0
I' : Ideal R
hJ : J ∣ K * I'
⊢ J * K ∣ K * I'
[PROOFSTEP]
rw [mul_comm]
[GOAL]
case neg.intro
R : Type u_1
A : Type u_2
K✝ : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K✝
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
J K : Ideal R
coprime : ∀ (P : Ideal R), P ∣ J → P ∣ K → ¬IsPrime P
hJ0 : ¬J = 0
I' : Ideal R
hJ : J ∣ K * I'
⊢ K * J ∣ K * I'
[PROOFSTEP]
refine mul_dvd_mul_left K (UniqueFactorizationMonoid.dvd_of_dvd_mul_right_of_no_prime_factors (b := K) hJ0 ?_ hJ)
[GOAL]
case neg.intro
R : Type u_1
A : Type u_2
K✝ : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K✝
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
J K : Ideal R
coprime : ∀ (P : Ideal R), P ∣ J → P ∣ K → ¬IsPrime P
hJ0 : ¬J = 0
I' : Ideal R
hJ : J ∣ K * I'
⊢ ∀ {d : Ideal R}, d ∣ J → d ∣ K → ¬Prime d
[PROOFSTEP]
exact fun hPJ hPK => mt Ideal.isPrime_of_prime (coprime _ hPJ hPK)
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
I P : Ideal R
hP : IsPrime P
n : ℕ
h : I ^ n ≤ P
⊢ I ≤ P
[PROOFSTEP]
by_cases hP0 : P = ⊥
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
I P : Ideal R
hP : IsPrime P
n : ℕ
h : I ^ n ≤ P
hP0 : P = ⊥
⊢ I ≤ P
[PROOFSTEP]
simp only [hP0, le_bot_iff] at h ⊢
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
I P : Ideal R
hP : IsPrime P
n : ℕ
hP0 : P = ⊥
h : I ^ n = ⊥
⊢ I = ⊥
[PROOFSTEP]
exact pow_eq_zero h
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
I P : Ideal R
hP : IsPrime P
n : ℕ
h : I ^ n ≤ P
hP0 : ¬P = ⊥
⊢ I ≤ P
[PROOFSTEP]
rw [← Ideal.dvd_iff_le] at h ⊢
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
I P : Ideal R
hP : IsPrime P
n : ℕ
h : P ∣ I ^ n
hP0 : ¬P = ⊥
⊢ P ∣ I
[PROOFSTEP]
exact ((Ideal.prime_iff_isPrime hP0).mpr hP).dvd_of_dvd_pow h
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s : Finset ι
f : ι → Ideal R
P : Ideal R
hP : IsPrime P
⊢ ∏ i in s, f i ≤ P ↔ ∃ i, i ∈ s ∧ f i ≤ P
[PROOFSTEP]
by_cases hP0 : P = ⊥
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s : Finset ι
f : ι → Ideal R
P : Ideal R
hP : IsPrime P
hP0 : P = ⊥
⊢ ∏ i in s, f i ≤ P ↔ ∃ i, i ∈ s ∧ f i ≤ P
[PROOFSTEP]
simp only [hP0, le_bot_iff]
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s : Finset ι
f : ι → Ideal R
P : Ideal R
hP : IsPrime P
hP0 : P = ⊥
⊢ ∏ i in s, f i = ⊥ ↔ ∃ i, i ∈ s ∧ f i = ⊥
[PROOFSTEP]
rw [← Ideal.zero_eq_bot, Finset.prod_eq_zero_iff]
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s : Finset ι
f : ι → Ideal R
P : Ideal R
hP : IsPrime P
hP0 : ¬P = ⊥
⊢ ∏ i in s, f i ≤ P ↔ ∃ i, i ∈ s ∧ f i ≤ P
[PROOFSTEP]
simp only [← Ideal.dvd_iff_le]
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s : Finset ι
f : ι → Ideal R
P : Ideal R
hP : IsPrime P
hP0 : ¬P = ⊥
⊢ P ∣ ∏ i in s, f i ↔ ∃ i, i ∈ s ∧ P ∣ f i
[PROOFSTEP]
exact ((Ideal.prime_iff_isPrime hP0).mpr hP).dvd_finset_prod_iff _
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s : Finset ι
f : ι → Ideal R
e : ι → ℕ
prime : ∀ (i : ι), i ∈ s → Prime (f i)
coprime : ∀ (i : ι), i ∈ s → ∀ (j : ι), j ∈ s → i ≠ j → f i ≠ f j
⊢ (Finset.inf s fun i => f i ^ e i) = ∏ i in s, f i ^ e i
[PROOFSTEP]
letI := Classical.decEq ι
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s : Finset ι
f : ι → Ideal R
e : ι → ℕ
prime : ∀ (i : ι), i ∈ s → Prime (f i)
coprime : ∀ (i : ι), i ∈ s → ∀ (j : ι), j ∈ s → i ≠ j → f i ≠ f j
this : DecidableEq ι := Classical.decEq ι
⊢ (Finset.inf s fun i => f i ^ e i) = ∏ i in s, f i ^ e i
[PROOFSTEP]
revert prime coprime
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s : Finset ι
f : ι → Ideal R
e : ι → ℕ
this : DecidableEq ι := Classical.decEq ι
⊢ (∀ (i : ι), i ∈ s → Prime (f i)) →
(∀ (i : ι), i ∈ s → ∀ (j : ι), j ∈ s → i ≠ j → f i ≠ f j) → (Finset.inf s fun i => f i ^ e i) = ∏ i in s, f i ^ e i
[PROOFSTEP]
refine s.induction ?_ ?_
[GOAL]
case refine_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s : Finset ι
f : ι → Ideal R
e : ι → ℕ
this : DecidableEq ι := Classical.decEq ι
⊢ (∀ (i : ι), i ∈ ∅ → Prime (f i)) →
(∀ (i : ι), i ∈ ∅ → ∀ (j : ι), j ∈ ∅ → i ≠ j → f i ≠ f j) → (Finset.inf ∅ fun i => f i ^ e i) = ∏ i in ∅, f i ^ e i
[PROOFSTEP]
simp
[GOAL]
case refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s : Finset ι
f : ι → Ideal R
e : ι → ℕ
this : DecidableEq ι := Classical.decEq ι
⊢ ∀ ⦃a : ι⦄ {s : Finset ι},
¬a ∈ s →
((∀ (i : ι), i ∈ s → Prime (f i)) →
(∀ (i : ι), i ∈ s → ∀ (j : ι), j ∈ s → i ≠ j → f i ≠ f j) →
(Finset.inf s fun i => f i ^ e i) = ∏ i in s, f i ^ e i) →
(∀ (i : ι), i ∈ insert a s → Prime (f i)) →
(∀ (i : ι), i ∈ insert a s → ∀ (j : ι), j ∈ insert a s → i ≠ j → f i ≠ f j) →
(Finset.inf (insert a s) fun i => f i ^ e i) = ∏ i in insert a s, f i ^ e i
[PROOFSTEP]
intro a s ha ih prime coprime
[GOAL]
case refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s✝ : Finset ι
f : ι → Ideal R
e : ι → ℕ
this : DecidableEq ι := Classical.decEq ι
a : ι
s : Finset ι
ha : ¬a ∈ s
ih :
(∀ (i : ι), i ∈ s → Prime (f i)) →
(∀ (i : ι), i ∈ s → ∀ (j : ι), j ∈ s → i ≠ j → f i ≠ f j) → (Finset.inf s fun i => f i ^ e i) = ∏ i in s, f i ^ e i
prime : ∀ (i : ι), i ∈ insert a s → Prime (f i)
coprime : ∀ (i : ι), i ∈ insert a s → ∀ (j : ι), j ∈ insert a s → i ≠ j → f i ≠ f j
⊢ (Finset.inf (insert a s) fun i => f i ^ e i) = ∏ i in insert a s, f i ^ e i
[PROOFSTEP]
specialize
ih (fun i hi => prime i (Finset.mem_insert_of_mem hi)) fun i hi j hj =>
coprime i (Finset.mem_insert_of_mem hi) j (Finset.mem_insert_of_mem hj)
[GOAL]
case refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s✝ : Finset ι
f : ι → Ideal R
e : ι → ℕ
this : DecidableEq ι := Classical.decEq ι
a : ι
s : Finset ι
ha : ¬a ∈ s
prime : ∀ (i : ι), i ∈ insert a s → Prime (f i)
coprime : ∀ (i : ι), i ∈ insert a s → ∀ (j : ι), j ∈ insert a s → i ≠ j → f i ≠ f j
ih : (Finset.inf s fun i => f i ^ e i) = ∏ i in s, f i ^ e i
⊢ (Finset.inf (insert a s) fun i => f i ^ e i) = ∏ i in insert a s, f i ^ e i
[PROOFSTEP]
rw [Finset.inf_insert, Finset.prod_insert ha, ih]
[GOAL]
case refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s✝ : Finset ι
f : ι → Ideal R
e : ι → ℕ
this : DecidableEq ι := Classical.decEq ι
a : ι
s : Finset ι
ha : ¬a ∈ s
prime : ∀ (i : ι), i ∈ insert a s → Prime (f i)
coprime : ∀ (i : ι), i ∈ insert a s → ∀ (j : ι), j ∈ insert a s → i ≠ j → f i ≠ f j
ih : (Finset.inf s fun i => f i ^ e i) = ∏ i in s, f i ^ e i
⊢ f a ^ e a ⊓ ∏ i in s, f i ^ e i = f a ^ e a * ∏ x in s, f x ^ e x
[PROOFSTEP]
refine' le_antisymm (Ideal.le_mul_of_no_prime_factors _ inf_le_left inf_le_right) Ideal.mul_le_inf
[GOAL]
case refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s✝ : Finset ι
f : ι → Ideal R
e : ι → ℕ
this : DecidableEq ι := Classical.decEq ι
a : ι
s : Finset ι
ha : ¬a ∈ s
prime : ∀ (i : ι), i ∈ insert a s → Prime (f i)
coprime : ∀ (i : ι), i ∈ insert a s → ∀ (j : ι), j ∈ insert a s → i ≠ j → f i ≠ f j
ih : (Finset.inf s fun i => f i ^ e i) = ∏ i in s, f i ^ e i
⊢ ∀ (P : Ideal R), f a ^ e a ≤ P → ∏ x in s, f x ^ e x ≤ P → ¬IsPrime P
[PROOFSTEP]
intro P hPa hPs hPp
[GOAL]
case refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s✝ : Finset ι
f : ι → Ideal R
e : ι → ℕ
this : DecidableEq ι := Classical.decEq ι
a : ι
s : Finset ι
ha : ¬a ∈ s
prime : ∀ (i : ι), i ∈ insert a s → Prime (f i)
coprime : ∀ (i : ι), i ∈ insert a s → ∀ (j : ι), j ∈ insert a s → i ≠ j → f i ≠ f j
ih : (Finset.inf s fun i => f i ^ e i) = ∏ i in s, f i ^ e i
P : Ideal R
hPa : f a ^ e a ≤ P
hPs : ∏ x in s, f x ^ e x ≤ P
hPp : IsPrime P
⊢ False
[PROOFSTEP]
haveI := hPp
[GOAL]
case refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s✝ : Finset ι
f : ι → Ideal R
e : ι → ℕ
this✝ : DecidableEq ι := Classical.decEq ι
a : ι
s : Finset ι
ha : ¬a ∈ s
prime : ∀ (i : ι), i ∈ insert a s → Prime (f i)
coprime : ∀ (i : ι), i ∈ insert a s → ∀ (j : ι), j ∈ insert a s → i ≠ j → f i ≠ f j
ih : (Finset.inf s fun i => f i ^ e i) = ∏ i in s, f i ^ e i
P : Ideal R
hPa : f a ^ e a ≤ P
hPs : ∏ x in s, f x ^ e x ≤ P
hPp this : IsPrime P
⊢ False
[PROOFSTEP]
obtain ⟨b, hb, hPb⟩ := Ideal.prod_le_prime.mp hPs
[GOAL]
case refine_2.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s✝ : Finset ι
f : ι → Ideal R
e : ι → ℕ
this✝ : DecidableEq ι := Classical.decEq ι
a : ι
s : Finset ι
ha : ¬a ∈ s
prime : ∀ (i : ι), i ∈ insert a s → Prime (f i)
coprime : ∀ (i : ι), i ∈ insert a s → ∀ (j : ι), j ∈ insert a s → i ≠ j → f i ≠ f j
ih : (Finset.inf s fun i => f i ^ e i) = ∏ i in s, f i ^ e i
P : Ideal R
hPa : f a ^ e a ≤ P
hPs : ∏ x in s, f x ^ e x ≤ P
hPp this : IsPrime P
b : ι
hb : b ∈ s
hPb : f b ^ e b ≤ P
⊢ False
[PROOFSTEP]
haveI := Ideal.isPrime_of_prime (prime a (Finset.mem_insert_self a s))
[GOAL]
case refine_2.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s✝ : Finset ι
f : ι → Ideal R
e : ι → ℕ
this✝¹ : DecidableEq ι := Classical.decEq ι
a : ι
s : Finset ι
ha : ¬a ∈ s
prime : ∀ (i : ι), i ∈ insert a s → Prime (f i)
coprime : ∀ (i : ι), i ∈ insert a s → ∀ (j : ι), j ∈ insert a s → i ≠ j → f i ≠ f j
ih : (Finset.inf s fun i => f i ^ e i) = ∏ i in s, f i ^ e i
P : Ideal R
hPa : f a ^ e a ≤ P
hPs : ∏ x in s, f x ^ e x ≤ P
hPp this✝ : IsPrime P
b : ι
hb : b ∈ s
hPb : f b ^ e b ≤ P
this : IsPrime (f a)
⊢ False
[PROOFSTEP]
haveI := Ideal.isPrime_of_prime (prime b (Finset.mem_insert_of_mem hb))
[GOAL]
case refine_2.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s✝ : Finset ι
f : ι → Ideal R
e : ι → ℕ
this✝² : DecidableEq ι := Classical.decEq ι
a : ι
s : Finset ι
ha : ¬a ∈ s
prime : ∀ (i : ι), i ∈ insert a s → Prime (f i)
coprime : ∀ (i : ι), i ∈ insert a s → ∀ (j : ι), j ∈ insert a s → i ≠ j → f i ≠ f j
ih : (Finset.inf s fun i => f i ^ e i) = ∏ i in s, f i ^ e i
P : Ideal R
hPa : f a ^ e a ≤ P
hPs : ∏ x in s, f x ^ e x ≤ P
hPp this✝¹ : IsPrime P
b : ι
hb : b ∈ s
hPb : f b ^ e b ≤ P
this✝ : IsPrime (f a)
this : IsPrime (f b)
⊢ False
[PROOFSTEP]
refine coprime a (Finset.mem_insert_self a s) b (Finset.mem_insert_of_mem hb) ?_ ?_
[GOAL]
case refine_2.intro.intro.refine_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s✝ : Finset ι
f : ι → Ideal R
e : ι → ℕ
this✝² : DecidableEq ι := Classical.decEq ι
a : ι
s : Finset ι
ha : ¬a ∈ s
prime : ∀ (i : ι), i ∈ insert a s → Prime (f i)
coprime : ∀ (i : ι), i ∈ insert a s → ∀ (j : ι), j ∈ insert a s → i ≠ j → f i ≠ f j
ih : (Finset.inf s fun i => f i ^ e i) = ∏ i in s, f i ^ e i
P : Ideal R
hPa : f a ^ e a ≤ P
hPs : ∏ x in s, f x ^ e x ≤ P
hPp this✝¹ : IsPrime P
b : ι
hb : b ∈ s
hPb : f b ^ e b ≤ P
this✝ : IsPrime (f a)
this : IsPrime (f b)
⊢ a ≠ b
[PROOFSTEP]
rintro rfl
[GOAL]
case refine_2.intro.intro.refine_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s✝ : Finset ι
f : ι → Ideal R
e : ι → ℕ
this✝² : DecidableEq ι := Classical.decEq ι
a : ι
s : Finset ι
ha : ¬a ∈ s
prime : ∀ (i : ι), i ∈ insert a s → Prime (f i)
coprime : ∀ (i : ι), i ∈ insert a s → ∀ (j : ι), j ∈ insert a s → i ≠ j → f i ≠ f j
ih : (Finset.inf s fun i => f i ^ e i) = ∏ i in s, f i ^ e i
P : Ideal R
hPa : f a ^ e a ≤ P
hPs : ∏ x in s, f x ^ e x ≤ P
hPp this✝¹ : IsPrime P
this✝ : IsPrime (f a)
hb : a ∈ s
hPb : f a ^ e a ≤ P
this : IsPrime (f a)
⊢ False
[PROOFSTEP]
contradiction
[GOAL]
case refine_2.intro.intro.refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s✝ : Finset ι
f : ι → Ideal R
e : ι → ℕ
this✝² : DecidableEq ι := Classical.decEq ι
a : ι
s : Finset ι
ha : ¬a ∈ s
prime : ∀ (i : ι), i ∈ insert a s → Prime (f i)
coprime : ∀ (i : ι), i ∈ insert a s → ∀ (j : ι), j ∈ insert a s → i ≠ j → f i ≠ f j
ih : (Finset.inf s fun i => f i ^ e i) = ∏ i in s, f i ^ e i
P : Ideal R
hPa : f a ^ e a ≤ P
hPs : ∏ x in s, f x ^ e x ≤ P
hPp this✝¹ : IsPrime P
b : ι
hb : b ∈ s
hPb : f b ^ e b ≤ P
this✝ : IsPrime (f a)
this : IsPrime (f b)
⊢ f a = f b
[PROOFSTEP]
refine
((Ring.DimensionLeOne.prime_le_prime_iff_eq ?_).mp (Ideal.le_of_pow_le_prime hPa)).trans
((Ring.DimensionLeOne.prime_le_prime_iff_eq ?_).mp (Ideal.le_of_pow_le_prime hPb)).symm
[GOAL]
case refine_2.intro.intro.refine_2.refine_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s✝ : Finset ι
f : ι → Ideal R
e : ι → ℕ
this✝² : DecidableEq ι := Classical.decEq ι
a : ι
s : Finset ι
ha : ¬a ∈ s
prime : ∀ (i : ι), i ∈ insert a s → Prime (f i)
coprime : ∀ (i : ι), i ∈ insert a s → ∀ (j : ι), j ∈ insert a s → i ≠ j → f i ≠ f j
ih : (Finset.inf s fun i => f i ^ e i) = ∏ i in s, f i ^ e i
P : Ideal R
hPa : f a ^ e a ≤ P
hPs : ∏ x in s, f x ^ e x ≤ P
hPp this✝¹ : IsPrime P
b : ι
hb : b ∈ s
hPb : f b ^ e b ≤ P
this✝ : IsPrime (f a)
this : IsPrime (f b)
⊢ f a ≠ ⊥
case refine_2.intro.intro.refine_2.refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s✝ : Finset ι
f : ι → Ideal R
e : ι → ℕ
this✝² : DecidableEq ι := Classical.decEq ι
a : ι
s : Finset ι
ha : ¬a ∈ s
prime : ∀ (i : ι), i ∈ insert a s → Prime (f i)
coprime : ∀ (i : ι), i ∈ insert a s → ∀ (j : ι), j ∈ insert a s → i ≠ j → f i ≠ f j
ih : (Finset.inf s fun i => f i ^ e i) = ∏ i in s, f i ^ e i
P : Ideal R
hPa : f a ^ e a ≤ P
hPs : ∏ x in s, f x ^ e x ≤ P
hPp this✝¹ : IsPrime P
b : ι
hb : b ∈ s
hPb : f b ^ e b ≤ P
this✝ : IsPrime (f a)
this : IsPrime (f b)
⊢ f b ≠ ⊥
[PROOFSTEP]
exact (prime a (Finset.mem_insert_self a s)).ne_zero
[GOAL]
case refine_2.intro.intro.refine_2.refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s✝ : Finset ι
f : ι → Ideal R
e : ι → ℕ
this✝² : DecidableEq ι := Classical.decEq ι
a : ι
s : Finset ι
ha : ¬a ∈ s
prime : ∀ (i : ι), i ∈ insert a s → Prime (f i)
coprime : ∀ (i : ι), i ∈ insert a s → ∀ (j : ι), j ∈ insert a s → i ≠ j → f i ≠ f j
ih : (Finset.inf s fun i => f i ^ e i) = ∏ i in s, f i ^ e i
P : Ideal R
hPa : f a ^ e a ≤ P
hPs : ∏ x in s, f x ^ e x ≤ P
hPp this✝¹ : IsPrime P
b : ι
hb : b ∈ s
hPb : f b ^ e b ≤ P
this✝ : IsPrime (f a)
this : IsPrime (f b)
⊢ f b ≠ ⊥
[PROOFSTEP]
exact (prime b (Finset.mem_insert_of_mem hb)).ne_zero
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDomain R
inst✝¹ : IsDedekindDomain R
ι : Type u_4
inst✝ : Fintype ι
I : Ideal R
P : ι → Ideal R
e : ι → ℕ
prime : ∀ (i : ι), Prime (P i)
coprime : ∀ (i j : ι), i ≠ j → P i ≠ P j
prod_eq : ∏ i : ι, P i ^ e i = I
⊢ I = ⨅ (i : ι), P i ^ e i
[PROOFSTEP]
simp only [← prod_eq, Finset.inf_eq_iInf, Finset.mem_univ, ciInf_pos, ←
IsDedekindDomain.inf_prime_pow_eq_prod _ _ _ (fun i _ => prime i) fun i _ j _ => coprime i j]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDomain R
inst✝¹ : IsDedekindDomain R
ι : Type u_4
inst✝ : Fintype ι
I : Ideal R
P : ι → Ideal R
e : ι → ℕ
prime : ∀ (i : ι), Prime (P i)
coprime : ∀ (i j : ι), i ≠ j → P i ≠ P j
prod_eq : ∏ i : ι, P i ^ e i = I
i j : ι
hij : i ≠ j
⊢ ∀ (P_1 : Ideal R), P i ^ e i ≤ P_1 → P j ^ e j ≤ P_1 → ¬IsPrime P_1
[PROOFSTEP]
intro P hPi hPj hPp
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDomain R
inst✝¹ : IsDedekindDomain R
ι : Type u_4
inst✝ : Fintype ι
I : Ideal R
P✝ : ι → Ideal R
e : ι → ℕ
prime : ∀ (i : ι), Prime (P✝ i)
coprime : ∀ (i j : ι), i ≠ j → P✝ i ≠ P✝ j
prod_eq : ∏ i : ι, P✝ i ^ e i = I
i j : ι
hij : i ≠ j
P : Ideal R
hPi : P✝ i ^ e i ≤ P
hPj : P✝ j ^ e j ≤ P
hPp : IsPrime P
⊢ False
[PROOFSTEP]
haveI := hPp
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDomain R
inst✝¹ : IsDedekindDomain R
ι : Type u_4
inst✝ : Fintype ι
I : Ideal R
P✝ : ι → Ideal R
e : ι → ℕ
prime : ∀ (i : ι), Prime (P✝ i)
coprime : ∀ (i j : ι), i ≠ j → P✝ i ≠ P✝ j
prod_eq : ∏ i : ι, P✝ i ^ e i = I
i j : ι
hij : i ≠ j
P : Ideal R
hPi : P✝ i ^ e i ≤ P
hPj : P✝ j ^ e j ≤ P
hPp this : IsPrime P
⊢ False
[PROOFSTEP]
haveI := Ideal.isPrime_of_prime (prime i)
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDomain R
inst✝¹ : IsDedekindDomain R
ι : Type u_4
inst✝ : Fintype ι
I : Ideal R
P✝ : ι → Ideal R
e : ι → ℕ
prime : ∀ (i : ι), Prime (P✝ i)
coprime : ∀ (i j : ι), i ≠ j → P✝ i ≠ P✝ j
prod_eq : ∏ i : ι, P✝ i ^ e i = I
i j : ι
hij : i ≠ j
P : Ideal R
hPi : P✝ i ^ e i ≤ P
hPj : P✝ j ^ e j ≤ P
hPp this✝ : IsPrime P
this : IsPrime (P✝ i)
⊢ False
[PROOFSTEP]
haveI := Ideal.isPrime_of_prime (prime j)
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDomain R
inst✝¹ : IsDedekindDomain R
ι : Type u_4
inst✝ : Fintype ι
I : Ideal R
P✝ : ι → Ideal R
e : ι → ℕ
prime : ∀ (i : ι), Prime (P✝ i)
coprime : ∀ (i j : ι), i ≠ j → P✝ i ≠ P✝ j
prod_eq : ∏ i : ι, P✝ i ^ e i = I
i j : ι
hij : i ≠ j
P : Ideal R
hPi : P✝ i ^ e i ≤ P
hPj : P✝ j ^ e j ≤ P
hPp this✝¹ : IsPrime P
this✝ : IsPrime (P✝ i)
this : IsPrime (P✝ j)
⊢ False
[PROOFSTEP]
refine coprime i j hij ?_
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDomain R
inst✝¹ : IsDedekindDomain R
ι : Type u_4
inst✝ : Fintype ι
I : Ideal R
P✝ : ι → Ideal R
e : ι → ℕ
prime : ∀ (i : ι), Prime (P✝ i)
coprime : ∀ (i j : ι), i ≠ j → P✝ i ≠ P✝ j
prod_eq : ∏ i : ι, P✝ i ^ e i = I
i j : ι
hij : i ≠ j
P : Ideal R
hPi : P✝ i ^ e i ≤ P
hPj : P✝ j ^ e j ≤ P
hPp this✝¹ : IsPrime P
this✝ : IsPrime (P✝ i)
this : IsPrime (P✝ j)
⊢ P✝ i = P✝ j
[PROOFSTEP]
refine
((Ring.DimensionLeOne.prime_le_prime_iff_eq ?_).mp (Ideal.le_of_pow_le_prime hPi)).trans
((Ring.DimensionLeOne.prime_le_prime_iff_eq ?_).mp (Ideal.le_of_pow_le_prime hPj)).symm
[GOAL]
case refine_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDomain R
inst✝¹ : IsDedekindDomain R
ι : Type u_4
inst✝ : Fintype ι
I : Ideal R
P✝ : ι → Ideal R
e : ι → ℕ
prime : ∀ (i : ι), Prime (P✝ i)
coprime : ∀ (i j : ι), i ≠ j → P✝ i ≠ P✝ j
prod_eq : ∏ i : ι, P✝ i ^ e i = I
i j : ι
hij : i ≠ j
P : Ideal R
hPi : P✝ i ^ e i ≤ P
hPj : P✝ j ^ e j ≤ P
hPp this✝¹ : IsPrime P
this✝ : IsPrime (P✝ i)
this : IsPrime (P✝ j)
⊢ P✝ i ≠ ⊥
case refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDomain R
inst✝¹ : IsDedekindDomain R
ι : Type u_4
inst✝ : Fintype ι
I : Ideal R
P✝ : ι → Ideal R
e : ι → ℕ
prime : ∀ (i : ι), Prime (P✝ i)
coprime : ∀ (i j : ι), i ≠ j → P✝ i ≠ P✝ j
prod_eq : ∏ i : ι, P✝ i ^ e i = I
i j : ι
hij : i ≠ j
P : Ideal R
hPi : P✝ i ^ e i ≤ P
hPj : P✝ j ^ e j ≤ P
hPp this✝¹ : IsPrime P
this✝ : IsPrime (P✝ i)
this : IsPrime (P✝ j)
⊢ P✝ j ≠ ⊥
[PROOFSTEP]
exact (prime i).ne_zero
[GOAL]
case refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : CommRing A
inst✝⁴ : Field K
inst✝³ : IsDomain A
inst✝² : IsDomain R
inst✝¹ : IsDedekindDomain R
ι : Type u_4
inst✝ : Fintype ι
I : Ideal R
P✝ : ι → Ideal R
e : ι → ℕ
prime : ∀ (i : ι), Prime (P✝ i)
coprime : ∀ (i j : ι), i ≠ j → P✝ i ≠ P✝ j
prod_eq : ∏ i : ι, P✝ i ^ e i = I
i j : ι
hij : i ≠ j
P : Ideal R
hPi : P✝ i ^ e i ≤ P
hPj : P✝ j ^ e j ≤ P
hPp this✝¹ : IsPrime P
this✝ : IsPrime (P✝ i)
this : IsPrime (P✝ j)
⊢ P✝ j ≠ ⊥
[PROOFSTEP]
exact (prime j).ne_zero
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
I : Ideal R
hI : I ≠ ⊥
⊢ Multiset.prod (Multiset.map (fun P => P) (factors I)) = Multiset.prod (factors I)
[PROOFSTEP]
rw [Multiset.map_id']
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s : Finset ι
P : ι → Ideal R
e : ι → ℕ
prime : ∀ (i : ι), i ∈ s → Prime (P i)
coprime : ∀ (i : ι), i ∈ s → ∀ (j : ι), j ∈ s → i ≠ j → P i ≠ P j
x : (i : { x // x ∈ s }) → R ⧸ P ↑i ^ e ↑i
⊢ ∃ y, ∀ (i : ι) (hi : i ∈ s), ↑(Ideal.Quotient.mk (P i ^ e i)) y = x { val := i, property := hi }
[PROOFSTEP]
let f := IsDedekindDomain.quotientEquivPiOfFinsetProdEq _ P e prime coprime rfl
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s : Finset ι
P : ι → Ideal R
e : ι → ℕ
prime : ∀ (i : ι), i ∈ s → Prime (P i)
coprime : ∀ (i : ι), i ∈ s → ∀ (j : ι), j ∈ s → i ≠ j → P i ≠ P j
x : (i : { x // x ∈ s }) → R ⧸ P ↑i ^ e ↑i
f : R ⧸ ∏ i in s, P i ^ e i ≃+* ((i : { x // x ∈ s }) → R ⧸ P ↑i ^ e ↑i) :=
quotientEquivPiOfFinsetProdEq (∏ i in s, P i ^ e i) P e prime coprime (_ : ∏ i in s, P i ^ e i = ∏ i in s, P i ^ e i)
⊢ ∃ y, ∀ (i : ι) (hi : i ∈ s), ↑(Ideal.Quotient.mk (P i ^ e i)) y = x { val := i, property := hi }
[PROOFSTEP]
obtain ⟨y, rfl⟩ := f.surjective x
[GOAL]
case intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s : Finset ι
P : ι → Ideal R
e : ι → ℕ
prime : ∀ (i : ι), i ∈ s → Prime (P i)
coprime : ∀ (i : ι), i ∈ s → ∀ (j : ι), j ∈ s → i ≠ j → P i ≠ P j
f : R ⧸ ∏ i in s, P i ^ e i ≃+* ((i : { x // x ∈ s }) → R ⧸ P ↑i ^ e ↑i) :=
quotientEquivPiOfFinsetProdEq (∏ i in s, P i ^ e i) P e prime coprime (_ : ∏ i in s, P i ^ e i = ∏ i in s, P i ^ e i)
y : R ⧸ ∏ i in s, P i ^ e i
⊢ ∃ y_1, ∀ (i : ι) (hi : i ∈ s), ↑(Ideal.Quotient.mk (P i ^ e i)) y_1 = ↑f y { val := i, property := hi }
[PROOFSTEP]
obtain ⟨z, rfl⟩ := Ideal.Quotient.mk_surjective y
[GOAL]
case intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s : Finset ι
P : ι → Ideal R
e : ι → ℕ
prime : ∀ (i : ι), i ∈ s → Prime (P i)
coprime : ∀ (i : ι), i ∈ s → ∀ (j : ι), j ∈ s → i ≠ j → P i ≠ P j
f : R ⧸ ∏ i in s, P i ^ e i ≃+* ((i : { x // x ∈ s }) → R ⧸ P ↑i ^ e ↑i) :=
quotientEquivPiOfFinsetProdEq (∏ i in s, P i ^ e i) P e prime coprime (_ : ∏ i in s, P i ^ e i = ∏ i in s, P i ^ e i)
z : R
⊢ ∃ y,
∀ (i : ι) (hi : i ∈ s),
↑(Ideal.Quotient.mk (P i ^ e i)) y =
↑f (↑(Ideal.Quotient.mk (∏ i in s, P i ^ e i)) z) { val := i, property := hi }
[PROOFSTEP]
exact ⟨z, fun i _hi => rfl⟩
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s : Finset ι
P : ι → Ideal R
e : ι → ℕ
prime : ∀ (i : ι), i ∈ s → Prime (P i)
coprime : ∀ (i : ι), i ∈ s → ∀ (j : ι), j ∈ s → i ≠ j → P i ≠ P j
x : { x // x ∈ s } → R
⊢ ∃ y, ∀ (i : ι) (hi : i ∈ s), y - x { val := i, property := hi } ∈ P i ^ e i
[PROOFSTEP]
obtain ⟨y, hy⟩ := IsDedekindDomain.exists_representative_mod_finset P e prime coprime fun i => Ideal.Quotient.mk _ (x i)
[GOAL]
case intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Field K
inst✝² : IsDomain A
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
ι : Type u_4
s : Finset ι
P : ι → Ideal R
e : ι → ℕ
prime : ∀ (i : ι), i ∈ s → Prime (P i)
coprime : ∀ (i : ι), i ∈ s → ∀ (j : ι), j ∈ s → i ≠ j → P i ≠ P j
x : { x // x ∈ s } → R
y : R
hy :
∀ (i : ι) (hi : i ∈ s),
↑(Ideal.Quotient.mk (P i ^ e i)) y =
↑(Ideal.Quotient.mk (P ↑{ val := i, property := hi } ^ e ↑{ val := i, property := hi }))
(x { val := i, property := hi })
⊢ ∃ y, ∀ (i : ι) (hi : i ∈ s), y - x { val := i, property := hi } ∈ P i ^ e i
[PROOFSTEP]
exact ⟨y, fun i hi => Ideal.Quotient.eq.mp (hy i hi)⟩
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Field K
inst✝⁵ : IsDomain A
inst✝⁴ : IsDomain R
inst✝³ : IsPrincipalIdealRing R
inst✝² : NormalizationMonoid R
inst✝¹ : DecidableEq R
inst✝ : DecidableEq (Ideal R)
a b : R
ha : a ∈ normalizedFactors b
⊢ span {a} ∈ normalizedFactors (span {b})
[PROOFSTEP]
by_cases hb : b = 0
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Field K
inst✝⁵ : IsDomain A
inst✝⁴ : IsDomain R
inst✝³ : IsPrincipalIdealRing R
inst✝² : NormalizationMonoid R
inst✝¹ : DecidableEq R
inst✝ : DecidableEq (Ideal R)
a b : R
ha : a ∈ normalizedFactors b
hb : b = 0
⊢ span {a} ∈ normalizedFactors (span {b})
[PROOFSTEP]
rw [Ideal.span_singleton_eq_bot.mpr hb, bot_eq_zero, normalizedFactors_zero]
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Field K
inst✝⁵ : IsDomain A
inst✝⁴ : IsDomain R
inst✝³ : IsPrincipalIdealRing R
inst✝² : NormalizationMonoid R
inst✝¹ : DecidableEq R
inst✝ : DecidableEq (Ideal R)
a b : R
ha : a ∈ normalizedFactors b
hb : b = 0
⊢ span {a} ∈ 0
[PROOFSTEP]
rw [hb, normalizedFactors_zero] at ha
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Field K
inst✝⁵ : IsDomain A
inst✝⁴ : IsDomain R
inst✝³ : IsPrincipalIdealRing R
inst✝² : NormalizationMonoid R
inst✝¹ : DecidableEq R
inst✝ : DecidableEq (Ideal R)
a b : R
ha : a ∈ 0
hb : b = 0
⊢ span {a} ∈ 0
[PROOFSTEP]
exact absurd ha (Multiset.not_mem_zero a)
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Field K
inst✝⁵ : IsDomain A
inst✝⁴ : IsDomain R
inst✝³ : IsPrincipalIdealRing R
inst✝² : NormalizationMonoid R
inst✝¹ : DecidableEq R
inst✝ : DecidableEq (Ideal R)
a b : R
ha : a ∈ normalizedFactors b
hb : ¬b = 0
⊢ span {a} ∈ normalizedFactors (span {b})
[PROOFSTEP]
suffices Prime (Ideal.span ({ a } : Set R))
by
obtain ⟨c, hc, hc'⟩ :=
exists_mem_normalizedFactors_of_dvd ?_ this.irreducible
(dvd_iff_le.mpr (span_singleton_le_span_singleton.mpr (dvd_of_mem_normalizedFactors ha)))
rwa [associated_iff_eq.mp hc']
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Field K
inst✝⁵ : IsDomain A
inst✝⁴ : IsDomain R
inst✝³ : IsPrincipalIdealRing R
inst✝² : NormalizationMonoid R
inst✝¹ : DecidableEq R
inst✝ : DecidableEq (Ideal R)
a b : R
ha : a ∈ normalizedFactors b
hb : ¬b = 0
this : Prime (span {a})
⊢ span {a} ∈ normalizedFactors (span {b})
[PROOFSTEP]
obtain ⟨c, hc, hc'⟩ :=
exists_mem_normalizedFactors_of_dvd ?_ this.irreducible
(dvd_iff_le.mpr (span_singleton_le_span_singleton.mpr (dvd_of_mem_normalizedFactors ha)))
[GOAL]
case intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Field K
inst✝⁵ : IsDomain A
inst✝⁴ : IsDomain R
inst✝³ : IsPrincipalIdealRing R
inst✝² : NormalizationMonoid R
inst✝¹ : DecidableEq R
inst✝ : DecidableEq (Ideal R)
a b : R
ha : a ∈ normalizedFactors b
hb : ¬b = 0
this : Prime (span {a})
c : Ideal R
hc : c ∈ normalizedFactors (span {b})
hc' : Associated (span {a}) c
⊢ span {a} ∈ normalizedFactors (span {b})
[PROOFSTEP]
rwa [associated_iff_eq.mp hc']
[GOAL]
case neg.refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Field K
inst✝⁵ : IsDomain A
inst✝⁴ : IsDomain R
inst✝³ : IsPrincipalIdealRing R
inst✝² : NormalizationMonoid R
inst✝¹ : DecidableEq R
inst✝ : DecidableEq (Ideal R)
a b : R
ha : a ∈ normalizedFactors b
hb : ¬b = 0
this : Prime (span {a})
⊢ span {b} ≠ 0
[PROOFSTEP]
by_contra h
[GOAL]
case neg.refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Field K
inst✝⁵ : IsDomain A
inst✝⁴ : IsDomain R
inst✝³ : IsPrincipalIdealRing R
inst✝² : NormalizationMonoid R
inst✝¹ : DecidableEq R
inst✝ : DecidableEq (Ideal R)
a b : R
ha : a ∈ normalizedFactors b
hb : ¬b = 0
this : Prime (span {a})
h : span {b} = 0
⊢ False
[PROOFSTEP]
exact hb (span_singleton_eq_bot.mp h)
[GOAL]
case neg.refine_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Field K
inst✝⁵ : IsDomain A
inst✝⁴ : IsDomain R
inst✝³ : IsPrincipalIdealRing R
inst✝² : NormalizationMonoid R
inst✝¹ : DecidableEq R
inst✝ : DecidableEq (Ideal R)
a b : R
ha : a ∈ normalizedFactors b
hb : ¬b = 0
⊢ Prime (span {a})
[PROOFSTEP]
rw [prime_iff_isPrime]
[GOAL]
case neg.refine_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Field K
inst✝⁵ : IsDomain A
inst✝⁴ : IsDomain R
inst✝³ : IsPrincipalIdealRing R
inst✝² : NormalizationMonoid R
inst✝¹ : DecidableEq R
inst✝ : DecidableEq (Ideal R)
a b : R
ha : a ∈ normalizedFactors b
hb : ¬b = 0
⊢ IsPrime (span {a})
[PROOFSTEP]
exact (span_singleton_prime (prime_of_normalized_factor a ha).ne_zero).mpr (prime_of_normalized_factor a ha)
[GOAL]
case neg.refine_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Field K
inst✝⁵ : IsDomain A
inst✝⁴ : IsDomain R
inst✝³ : IsPrincipalIdealRing R
inst✝² : NormalizationMonoid R
inst✝¹ : DecidableEq R
inst✝ : DecidableEq (Ideal R)
a b : R
ha : a ∈ normalizedFactors b
hb : ¬b = 0
⊢ span {a} ≠ ⊥
[PROOFSTEP]
by_contra h
[GOAL]
case neg.refine_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Field K
inst✝⁵ : IsDomain A
inst✝⁴ : IsDomain R
inst✝³ : IsPrincipalIdealRing R
inst✝² : NormalizationMonoid R
inst✝¹ : DecidableEq R
inst✝ : DecidableEq (Ideal R)
a b : R
ha : a ∈ normalizedFactors b
hb : ¬b = 0
h : span {a} = ⊥
⊢ False
[PROOFSTEP]
exact (prime_of_normalized_factor a ha).ne_zero (span_singleton_eq_bot.mp h)
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
inst✝³ : IsDomain R
inst✝² : IsPrincipalIdealRing R
inst✝¹ : DecidableRel fun x x_1 => x ∣ x_1
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
a b : R
⊢ multiplicity (span {a}) (span {b}) = multiplicity a b
[PROOFSTEP]
by_cases h : Finite a b
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
inst✝³ : IsDomain R
inst✝² : IsPrincipalIdealRing R
inst✝¹ : DecidableRel fun x x_1 => x ∣ x_1
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
a b : R
h : multiplicity.Finite a b
⊢ multiplicity (span {a}) (span {b}) = multiplicity a b
[PROOFSTEP]
rw [← PartENat.natCast_get (finite_iff_dom.mp h)]
[GOAL]
case pos
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
inst✝³ : IsDomain R
inst✝² : IsPrincipalIdealRing R
inst✝¹ : DecidableRel fun x x_1 => x ∣ x_1
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
a b : R
h : multiplicity.Finite a b
⊢ multiplicity (span {a}) (span {b}) = ↑(Part.get (multiplicity a b) (_ : (multiplicity a b).Dom))
[PROOFSTEP]
refine (multiplicity.unique (show Ideal.span { a } ^ (multiplicity a b).get h ∣ Ideal.span { b } from ?_) ?_).symm
[GOAL]
case pos.refine_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
inst✝³ : IsDomain R
inst✝² : IsPrincipalIdealRing R
inst✝¹ : DecidableRel fun x x_1 => x ∣ x_1
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
a b : R
h : multiplicity.Finite a b
⊢ span {a} ^ Part.get (multiplicity a b) h ∣ span {b}
[PROOFSTEP]
rw [Ideal.span_singleton_pow, span_singleton_dvd_span_singleton_iff_dvd]
[GOAL]
case pos.refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
inst✝³ : IsDomain R
inst✝² : IsPrincipalIdealRing R
inst✝¹ : DecidableRel fun x x_1 => x ∣ x_1
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
a b : R
h : multiplicity.Finite a b
⊢ ¬span {a} ^ (Part.get (multiplicity a b) h + 1) ∣ span {b}
[PROOFSTEP]
rw [Ideal.span_singleton_pow, span_singleton_dvd_span_singleton_iff_dvd]
[GOAL]
case pos.refine_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
inst✝³ : IsDomain R
inst✝² : IsPrincipalIdealRing R
inst✝¹ : DecidableRel fun x x_1 => x ∣ x_1
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
a b : R
h : multiplicity.Finite a b
⊢ a ^ Part.get (multiplicity a b) h ∣ b
case pos.refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
inst✝³ : IsDomain R
inst✝² : IsPrincipalIdealRing R
inst✝¹ : DecidableRel fun x x_1 => x ∣ x_1
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
a b : R
h : multiplicity.Finite a b
⊢ ¬a ^ (Part.get (multiplicity a b) h + 1) ∣ b
[PROOFSTEP]
exact pow_multiplicity_dvd h
[GOAL]
case pos.refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
inst✝³ : IsDomain R
inst✝² : IsPrincipalIdealRing R
inst✝¹ : DecidableRel fun x x_1 => x ∣ x_1
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
a b : R
h : multiplicity.Finite a b
⊢ ¬a ^ (Part.get (multiplicity a b) h + 1) ∣ b
[PROOFSTEP]
exact multiplicity.is_greatest ((PartENat.lt_coe_iff _ _).mpr (Exists.intro (finite_iff_dom.mp h) (Nat.lt_succ_self _)))
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
inst✝³ : IsDomain R
inst✝² : IsPrincipalIdealRing R
inst✝¹ : DecidableRel fun x x_1 => x ∣ x_1
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
a b : R
h : ¬multiplicity.Finite a b
⊢ multiplicity (span {a}) (span {b}) = multiplicity a b
[PROOFSTEP]
suffices ¬Finite (Ideal.span ({ a } : Set R)) (Ideal.span ({ b } : Set R))
by
rw [finite_iff_dom, PartENat.not_dom_iff_eq_top] at h this
rw [h, this]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
inst✝³ : IsDomain R
inst✝² : IsPrincipalIdealRing R
inst✝¹ : DecidableRel fun x x_1 => x ∣ x_1
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
a b : R
h : ¬multiplicity.Finite a b
this : ¬multiplicity.Finite (span {a}) (span {b})
⊢ multiplicity (span {a}) (span {b}) = multiplicity a b
[PROOFSTEP]
rw [finite_iff_dom, PartENat.not_dom_iff_eq_top] at h this
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
inst✝³ : IsDomain R
inst✝² : IsPrincipalIdealRing R
inst✝¹ : DecidableRel fun x x_1 => x ∣ x_1
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
a b : R
h✝ : ¬multiplicity.Finite a b
h : multiplicity a b = ⊤
this✝ : ¬multiplicity.Finite (span {a}) (span {b})
this : multiplicity (span {a}) (span {b}) = ⊤
⊢ multiplicity (span {a}) (span {b}) = multiplicity a b
[PROOFSTEP]
rw [h, this]
[GOAL]
case neg
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
inst✝³ : IsDomain R
inst✝² : IsPrincipalIdealRing R
inst✝¹ : DecidableRel fun x x_1 => x ∣ x_1
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
a b : R
h : ¬multiplicity.Finite a b
⊢ ¬multiplicity.Finite (span {a}) (span {b})
[PROOFSTEP]
exact
not_finite_iff_forall.mpr fun n =>
by
rw [Ideal.span_singleton_pow, span_singleton_dvd_span_singleton_iff_dvd]
exact not_finite_iff_forall.mp h n
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
inst✝³ : IsDomain R
inst✝² : IsPrincipalIdealRing R
inst✝¹ : DecidableRel fun x x_1 => x ∣ x_1
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
a b : R
h : ¬multiplicity.Finite a b
n : ℕ
⊢ span {a} ^ n ∣ span {b}
[PROOFSTEP]
rw [Ideal.span_singleton_pow, span_singleton_dvd_span_singleton_iff_dvd]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Field K
inst✝⁴ : IsDomain A
inst✝³ : IsDomain R
inst✝² : IsPrincipalIdealRing R
inst✝¹ : DecidableRel fun x x_1 => x ∣ x_1
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
a b : R
h : ¬multiplicity.Finite a b
n : ℕ
⊢ a ^ n ∣ b
[PROOFSTEP]
exact not_finite_iff_forall.mp h n
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Field K
inst✝⁵ : IsDomain A
inst✝⁴ : IsDomain R
inst✝³ : IsPrincipalIdealRing R
inst✝² : DecidableEq R
inst✝¹ : DecidableEq (Ideal R)
inst✝ : NormalizationMonoid R
r : R
hr : r ≠ 0
⊢ ↑{d | d ∈ normalizedFactors r} ≃ ↑{I | I ∈ normalizedFactors (span {r})}
[PROOFSTEP]
refine Equiv.ofBijective ?_ ?_
[GOAL]
case refine_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Field K
inst✝⁵ : IsDomain A
inst✝⁴ : IsDomain R
inst✝³ : IsPrincipalIdealRing R
inst✝² : DecidableEq R
inst✝¹ : DecidableEq (Ideal R)
inst✝ : NormalizationMonoid R
r : R
hr : r ≠ 0
⊢ ↑{d | d ∈ normalizedFactors r} → ↑{I | I ∈ normalizedFactors (span {r})}
[PROOFSTEP]
exact fun d => ⟨Ideal.span {↑d}, singleton_span_mem_normalizedFactors_of_mem_normalizedFactors d.prop⟩
[GOAL]
case refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Field K
inst✝⁵ : IsDomain A
inst✝⁴ : IsDomain R
inst✝³ : IsPrincipalIdealRing R
inst✝² : DecidableEq R
inst✝¹ : DecidableEq (Ideal R)
inst✝ : NormalizationMonoid R
r : R
hr : r ≠ 0
⊢ Function.Bijective fun d => { val := span {↑d}, property := (_ : span {↑d} ∈ normalizedFactors (span {r})) }
[PROOFSTEP]
refine ⟨?_, ?_⟩
[GOAL]
case refine_2.refine_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Field K
inst✝⁵ : IsDomain A
inst✝⁴ : IsDomain R
inst✝³ : IsPrincipalIdealRing R
inst✝² : DecidableEq R
inst✝¹ : DecidableEq (Ideal R)
inst✝ : NormalizationMonoid R
r : R
hr : r ≠ 0
⊢ Function.Injective fun d => { val := span {↑d}, property := (_ : span {↑d} ∈ normalizedFactors (span {r})) }
[PROOFSTEP]
rintro ⟨a, ha⟩ ⟨b, hb⟩ h
[GOAL]
case refine_2.refine_1.mk.mk
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Field K
inst✝⁵ : IsDomain A
inst✝⁴ : IsDomain R
inst✝³ : IsPrincipalIdealRing R
inst✝² : DecidableEq R
inst✝¹ : DecidableEq (Ideal R)
inst✝ : NormalizationMonoid R
r : R
hr : r ≠ 0
a : R
ha : a ∈ {d | d ∈ normalizedFactors r}
b : R
hb : b ∈ {d | d ∈ normalizedFactors r}
h :
(fun d => { val := span {↑d}, property := (_ : span {↑d} ∈ normalizedFactors (span {r})) })
{ val := a, property := ha } =
(fun d => { val := span {↑d}, property := (_ : span {↑d} ∈ normalizedFactors (span {r})) })
{ val := b, property := hb }
⊢ { val := a, property := ha } = { val := b, property := hb }
[PROOFSTEP]
rw [Subtype.mk_eq_mk, Ideal.span_singleton_eq_span_singleton, Subtype.coe_mk, Subtype.coe_mk] at h
[GOAL]
case refine_2.refine_1.mk.mk
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Field K
inst✝⁵ : IsDomain A
inst✝⁴ : IsDomain R
inst✝³ : IsPrincipalIdealRing R
inst✝² : DecidableEq R
inst✝¹ : DecidableEq (Ideal R)
inst✝ : NormalizationMonoid R
r : R
hr : r ≠ 0
a : R
ha : a ∈ {d | d ∈ normalizedFactors r}
b : R
hb : b ∈ {d | d ∈ normalizedFactors r}
h : Associated a b
⊢ { val := a, property := ha } = { val := b, property := hb }
[PROOFSTEP]
exact Subtype.mk_eq_mk.mpr (mem_normalizedFactors_eq_of_associated ha hb h)
[GOAL]
case refine_2.refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Field K
inst✝⁵ : IsDomain A
inst✝⁴ : IsDomain R
inst✝³ : IsPrincipalIdealRing R
inst✝² : DecidableEq R
inst✝¹ : DecidableEq (Ideal R)
inst✝ : NormalizationMonoid R
r : R
hr : r ≠ 0
⊢ Function.Surjective fun d => { val := span {↑d}, property := (_ : span {↑d} ∈ normalizedFactors (span {r})) }
[PROOFSTEP]
rintro ⟨i, hi⟩
[GOAL]
case refine_2.refine_2.mk
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Field K
inst✝⁵ : IsDomain A
inst✝⁴ : IsDomain R
inst✝³ : IsPrincipalIdealRing R
inst✝² : DecidableEq R
inst✝¹ : DecidableEq (Ideal R)
inst✝ : NormalizationMonoid R
r : R
hr : r ≠ 0
i : Ideal R
hi : i ∈ {I | I ∈ normalizedFactors (span {r})}
⊢ ∃ a,
(fun d => { val := span {↑d}, property := (_ : span {↑d} ∈ normalizedFactors (span {r})) }) a =
{ val := i, property := hi }
[PROOFSTEP]
have : i.IsPrime := isPrime_of_prime (prime_of_normalized_factor i hi)
[GOAL]
case refine_2.refine_2.mk
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Field K
inst✝⁵ : IsDomain A
inst✝⁴ : IsDomain R
inst✝³ : IsPrincipalIdealRing R
inst✝² : DecidableEq R
inst✝¹ : DecidableEq (Ideal R)
inst✝ : NormalizationMonoid R
r : R
hr : r ≠ 0
i : Ideal R
hi : i ∈ {I | I ∈ normalizedFactors (span {r})}
this : IsPrime i
⊢ ∃ a,
(fun d => { val := span {↑d}, property := (_ : span {↑d} ∈ normalizedFactors (span {r})) }) a =
{ val := i, property := hi }
[PROOFSTEP]
have :=
exists_mem_normalizedFactors_of_dvd hr
(Submodule.IsPrincipal.prime_generator_of_isPrime i (prime_of_normalized_factor i hi).ne_zero).irreducible ?_
[GOAL]
case refine_2.refine_2.mk.refine_2
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Field K
inst✝⁵ : IsDomain A
inst✝⁴ : IsDomain R
inst✝³ : IsPrincipalIdealRing R
inst✝² : DecidableEq R
inst✝¹ : DecidableEq (Ideal R)
inst✝ : NormalizationMonoid R
r : R
hr : r ≠ 0
i : Ideal R
hi : i ∈ {I | I ∈ normalizedFactors (span {r})}
this✝ : IsPrime i
this : ∃ q, q ∈ normalizedFactors r ∧ Associated (Submodule.IsPrincipal.generator i) q
⊢ ∃ a,
(fun d => { val := span {↑d}, property := (_ : span {↑d} ∈ normalizedFactors (span {r})) }) a =
{ val := i, property := hi }
[PROOFSTEP]
obtain ⟨a, ha, ha'⟩ := this
[GOAL]
case refine_2.refine_2.mk.refine_2.intro.intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Field K
inst✝⁵ : IsDomain A
inst✝⁴ : IsDomain R
inst✝³ : IsPrincipalIdealRing R
inst✝² : DecidableEq R
inst✝¹ : DecidableEq (Ideal R)
inst✝ : NormalizationMonoid R
r : R
hr : r ≠ 0
i : Ideal R
hi : i ∈ {I | I ∈ normalizedFactors (span {r})}
this : IsPrime i
a : R
ha : a ∈ normalizedFactors r
ha' : Associated (Submodule.IsPrincipal.generator i) a
⊢ ∃ a,
(fun d => { val := span {↑d}, property := (_ : span {↑d} ∈ normalizedFactors (span {r})) }) a =
{ val := i, property := hi }
[PROOFSTEP]
use⟨a, ha⟩
[GOAL]
case h
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Field K
inst✝⁵ : IsDomain A
inst✝⁴ : IsDomain R
inst✝³ : IsPrincipalIdealRing R
inst✝² : DecidableEq R
inst✝¹ : DecidableEq (Ideal R)
inst✝ : NormalizationMonoid R
r : R
hr : r ≠ 0
i : Ideal R
hi : i ∈ {I | I ∈ normalizedFactors (span {r})}
this : IsPrime i
a : R
ha : a ∈ normalizedFactors r
ha' : Associated (Submodule.IsPrincipal.generator i) a
⊢ (fun d => { val := span {↑d}, property := (_ : span {↑d} ∈ normalizedFactors (span {r})) })
{ val := a, property := ha } =
{ val := i, property := hi }
[PROOFSTEP]
simp only [Subtype.coe_mk, Subtype.mk_eq_mk, ← span_singleton_eq_span_singleton.mpr ha', Ideal.span_singleton_generator]
[GOAL]
case refine_2.refine_2.mk.refine_1
R : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Field K
inst✝⁵ : IsDomain A
inst✝⁴ : IsDomain R
inst✝³ : IsPrincipalIdealRing R
inst✝² : DecidableEq R
inst✝¹ : DecidableEq (Ideal R)
inst✝ : NormalizationMonoid R
r : R
hr : r ≠ 0
i : Ideal R
hi : i ∈ {I | I ∈ normalizedFactors (span {r})}
this : IsPrime i
⊢ Submodule.IsPrincipal.generator i ∣ r
[PROOFSTEP]
exact
(Submodule.IsPrincipal.mem_iff_generator_dvd i).mp
((show Ideal.span { r } ≤ i from dvd_iff_le.mp (dvd_of_mem_normalizedFactors hi))
(mem_span_singleton.mpr (dvd_refl r)))
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁰ : CommRing R
inst✝⁹ : CommRing A
inst✝⁸ : Field K
inst✝⁷ : IsDomain A
inst✝⁶ : IsDomain R
inst✝⁵ : IsPrincipalIdealRing R
inst✝⁴ : DecidableEq R
inst✝³ : DecidableEq (Ideal R)
inst✝² : NormalizationMonoid R
inst✝¹ : DecidableRel fun x x_1 => x ∣ x_1
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
r d : R
hr : r ≠ 0
hd : d ∈ normalizedFactors r
⊢ multiplicity d r =
multiplicity (↑(↑(normalizedFactorsEquivSpanNormalizedFactors hr) { val := d, property := hd })) (span {r})
[PROOFSTEP]
simp only [normalizedFactorsEquivSpanNormalizedFactors, multiplicity_eq_multiplicity_span, Subtype.coe_mk,
Equiv.ofBijective_apply]
[GOAL]
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁰ : CommRing R
inst✝⁹ : CommRing A
inst✝⁸ : Field K
inst✝⁷ : IsDomain A
inst✝⁶ : IsDomain R
inst✝⁵ : IsPrincipalIdealRing R
inst✝⁴ : DecidableEq R
inst✝³ : DecidableEq (Ideal R)
inst✝² : NormalizationMonoid R
inst✝¹ : DecidableRel fun x x_1 => x ∣ x_1
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
r : R
hr : r ≠ 0
I : ↑{I | I ∈ normalizedFactors (span {r})}
⊢ multiplicity (↑(↑(normalizedFactorsEquivSpanNormalizedFactors hr).symm I)) r = multiplicity (↑I) (span {r})
[PROOFSTEP]
obtain ⟨x, hx⟩ := (normalizedFactorsEquivSpanNormalizedFactors hr).surjective I
[GOAL]
case intro
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁰ : CommRing R
inst✝⁹ : CommRing A
inst✝⁸ : Field K
inst✝⁷ : IsDomain A
inst✝⁶ : IsDomain R
inst✝⁵ : IsPrincipalIdealRing R
inst✝⁴ : DecidableEq R
inst✝³ : DecidableEq (Ideal R)
inst✝² : NormalizationMonoid R
inst✝¹ : DecidableRel fun x x_1 => x ∣ x_1
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
r : R
hr : r ≠ 0
I : ↑{I | I ∈ normalizedFactors (span {r})}
x : ↑{d | d ∈ normalizedFactors r}
hx : ↑(normalizedFactorsEquivSpanNormalizedFactors hr) x = I
⊢ multiplicity (↑(↑(normalizedFactorsEquivSpanNormalizedFactors hr).symm I)) r = multiplicity (↑I) (span {r})
[PROOFSTEP]
obtain ⟨a, ha⟩ := x
[GOAL]
case intro.mk
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁰ : CommRing R
inst✝⁹ : CommRing A
inst✝⁸ : Field K
inst✝⁷ : IsDomain A
inst✝⁶ : IsDomain R
inst✝⁵ : IsPrincipalIdealRing R
inst✝⁴ : DecidableEq R
inst✝³ : DecidableEq (Ideal R)
inst✝² : NormalizationMonoid R
inst✝¹ : DecidableRel fun x x_1 => x ∣ x_1
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
r : R
hr : r ≠ 0
I : ↑{I | I ∈ normalizedFactors (span {r})}
a : R
ha : a ∈ {d | d ∈ normalizedFactors r}
hx : ↑(normalizedFactorsEquivSpanNormalizedFactors hr) { val := a, property := ha } = I
⊢ multiplicity (↑(↑(normalizedFactorsEquivSpanNormalizedFactors hr).symm I)) r = multiplicity (↑I) (span {r})
[PROOFSTEP]
rw [hx.symm, Equiv.symm_apply_apply, Subtype.coe_mk,
multiplicity_normalizedFactorsEquivSpanNormalizedFactors_eq_multiplicity hr ha, hx]
|
Require Import Coq.QArith.QArith_base.
Require Import Coq.QArith.Qabs.
Require Import Psatz.
Require Import Coq.QArith.Qround.
Require Import Coq.PArith.Pnat.
Require Import Sequence.
Require Import Utility.
Definition a := 5#1.
Definition b := 2#1.
Definition seq_ex1 q:= a+b/q.
Definition r_ex1 := a.
Definition a_ex1 q := q*b.
Lemma a_spec_ex1 : forall q, q>0 -> Qabs ((seq_ex1 (a_ex1 q)) + -r_ex1) <= 1/q.
Proof.
intros.
unfold seq_ex1.
unfold a_ex1.
unfold r_ex1.
assert( a + b / (q * b) + - a == b / (q * b)) by lra.
rewrite H0.
assert( b / (q*b)==b * (/q) * (/b) ).
{
assert(b * (/q) * (/b) == b * ((/q) * (/b))) by lra.
assert( H2 := Qinv_mult_distr q b).
assert(/q * /b == /(q*b)) by lra.
rewrite H3 in H1.
auto with *.
}
rewrite H1.
assert ( b * / q * / b == /q ).
{
assert( b * / q * / b == (b * /b) * /q) by lra.
rewrite H2.
assert( b * /b == 1) by auto with *.
rewrite H3.
lra.
}
rewrite H2.
assert( H3 := qinvq_eq_1divq q).
rewrite H3.
assert( H4 := q_pos_invq_pos q H ).
assert( 0 <= 1/q ) by lra.
assert( H6 := Qabs_pos (1/q) H5 ).
rewrite H6.
apply Qle_refl.
Qed.
Lemma ex1' : ConvergentSequence_def seq_ex1 r_ex1 a_ex1.
Proof.
unfold ConvergentSequence_def.
intros.
apply (a_spec_ex1 q).
auto.
Qed.
Lemma ex1p : ConvergentSequence.
Proof.
apply Build_ConvergentSequence with (Seq := seq_ex1) (Seqr := r_ex1) (Seqa := a_ex1).
apply ex1'.
Qed.
|
" An Introduction to Proteins " from <unk> ( Huntington 's Disease Outreach Project for Education at Stanford )
|
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
x✝ : OpensLeCover U
⊢ {
obj := fun V =>
{
obj :=
{ left := V.obj, right := { as := PUnit.unit },
hom := homOfLE (_ : (𝟭 (Opens ↑X)).obj V.obj ≤ (Functor.fromPUnit Y).obj { as := PUnit.unit }) },
property :=
(_ :
∃ Y_1 h g,
presieveOfCoveringAux U Y g ∧
h ≫ g =
{ left := V.obj, right := { as := PUnit.unit },
hom :=
homOfLE
(_ :
(𝟭 (Opens ↑X)).obj V.obj ≤ (Functor.fromPUnit Y).obj { as := PUnit.unit }) }.hom) },
map := fun {x x_1} g => Over.homMk g }.map
(𝟙 x✝) =
𝟙
({
obj := fun V =>
{
obj :=
{ left := V.obj, right := { as := PUnit.unit },
hom := homOfLE (_ : (𝟭 (Opens ↑X)).obj V.obj ≤ (Functor.fromPUnit Y).obj { as := PUnit.unit }) },
property :=
(_ :
∃ Y_1 h g,
presieveOfCoveringAux U Y g ∧
h ≫ g =
{ left := V.obj, right := { as := PUnit.unit },
hom :=
homOfLE
(_ :
(𝟭 (Opens ↑X)).obj V.obj ≤ (Functor.fromPUnit Y).obj { as := PUnit.unit }) }.hom) },
map := fun {x x_1} g => Over.homMk g }.obj
x✝)
[PROOFSTEP]
refine Over.OverMorphism.ext ?_
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
x✝ : OpensLeCover U
⊢ ({
obj := fun V =>
{
obj :=
{ left := V.obj, right := { as := PUnit.unit },
hom := homOfLE (_ : (𝟭 (Opens ↑X)).obj V.obj ≤ (Functor.fromPUnit Y).obj { as := PUnit.unit }) },
property :=
(_ :
∃ Y_1 h g,
presieveOfCoveringAux U Y g ∧
h ≫ g =
{ left := V.obj, right := { as := PUnit.unit },
hom :=
homOfLE
(_ :
(𝟭 (Opens ↑X)).obj V.obj ≤ (Functor.fromPUnit Y).obj { as := PUnit.unit }) }.hom) },
map := fun {x x_1} g => Over.homMk g }.map
(𝟙 x✝)).left =
(𝟙
({
obj := fun V =>
{
obj :=
{ left := V.obj, right := { as := PUnit.unit },
hom := homOfLE (_ : (𝟭 (Opens ↑X)).obj V.obj ≤ (Functor.fromPUnit Y).obj { as := PUnit.unit }) },
property :=
(_ :
∃ Y_1 h g,
presieveOfCoveringAux U Y g ∧
h ≫ g =
{ left := V.obj, right := { as := PUnit.unit },
hom :=
homOfLE
(_ :
(𝟭 (Opens ↑X)).obj V.obj ≤
(Functor.fromPUnit Y).obj { as := PUnit.unit }) }.hom) },
map := fun {x x_1} g => Over.homMk g }.obj
x✝)).left
[PROOFSTEP]
simp only [Functor.id_obj, Sieve.generate_apply, Functor.const_obj_obj, Over.homMk_left, eq_iff_true_of_subsingleton]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
x✝² x✝¹ x✝ : OpensLeCover U
f : x✝² ⟶ x✝¹
g : x✝¹ ⟶ x✝
⊢ {
obj := fun V =>
{
obj :=
{ left := V.obj, right := { as := PUnit.unit },
hom := homOfLE (_ : (𝟭 (Opens ↑X)).obj V.obj ≤ (Functor.fromPUnit Y).obj { as := PUnit.unit }) },
property :=
(_ :
∃ Y_1 h g,
presieveOfCoveringAux U Y g ∧
h ≫ g =
{ left := V.obj, right := { as := PUnit.unit },
hom :=
homOfLE
(_ :
(𝟭 (Opens ↑X)).obj V.obj ≤ (Functor.fromPUnit Y).obj { as := PUnit.unit }) }.hom) },
map := fun {x x_1} g => Over.homMk g }.map
(f ≫ g) =
{
obj := fun V =>
{
obj :=
{ left := V.obj, right := { as := PUnit.unit },
hom := homOfLE (_ : (𝟭 (Opens ↑X)).obj V.obj ≤ (Functor.fromPUnit Y).obj { as := PUnit.unit }) },
property :=
(_ :
∃ Y_1 h g,
presieveOfCoveringAux U Y g ∧
h ≫ g =
{ left := V.obj, right := { as := PUnit.unit },
hom :=
homOfLE
(_ :
(𝟭 (Opens ↑X)).obj V.obj ≤ (Functor.fromPUnit Y).obj { as := PUnit.unit }) }.hom) },
map := fun {x x_1} g => Over.homMk g }.map
f ≫
{
obj := fun V =>
{
obj :=
{ left := V.obj, right := { as := PUnit.unit },
hom := homOfLE (_ : (𝟭 (Opens ↑X)).obj V.obj ≤ (Functor.fromPUnit Y).obj { as := PUnit.unit }) },
property :=
(_ :
∃ Y_1 h g,
presieveOfCoveringAux U Y g ∧
h ≫ g =
{ left := V.obj, right := { as := PUnit.unit },
hom :=
homOfLE
(_ :
(𝟭 (Opens ↑X)).obj V.obj ≤ (Functor.fromPUnit Y).obj { as := PUnit.unit }) }.hom) },
map := fun {x x_1} g => Over.homMk g }.map
g
[PROOFSTEP]
refine Over.OverMorphism.ext ?_
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
x✝² x✝¹ x✝ : OpensLeCover U
f : x✝² ⟶ x✝¹
g : x✝¹ ⟶ x✝
⊢ ({
obj := fun V =>
{
obj :=
{ left := V.obj, right := { as := PUnit.unit },
hom := homOfLE (_ : (𝟭 (Opens ↑X)).obj V.obj ≤ (Functor.fromPUnit Y).obj { as := PUnit.unit }) },
property :=
(_ :
∃ Y_1 h g,
presieveOfCoveringAux U Y g ∧
h ≫ g =
{ left := V.obj, right := { as := PUnit.unit },
hom :=
homOfLE
(_ :
(𝟭 (Opens ↑X)).obj V.obj ≤ (Functor.fromPUnit Y).obj { as := PUnit.unit }) }.hom) },
map := fun {x x_1} g => Over.homMk g }.map
(f ≫ g)).left =
({
obj := fun V =>
{
obj :=
{ left := V.obj, right := { as := PUnit.unit },
hom := homOfLE (_ : (𝟭 (Opens ↑X)).obj V.obj ≤ (Functor.fromPUnit Y).obj { as := PUnit.unit }) },
property :=
(_ :
∃ Y_1 h g,
presieveOfCoveringAux U Y g ∧
h ≫ g =
{ left := V.obj, right := { as := PUnit.unit },
hom :=
homOfLE
(_ :
(𝟭 (Opens ↑X)).obj V.obj ≤
(Functor.fromPUnit Y).obj { as := PUnit.unit }) }.hom) },
map := fun {x x_1} g => Over.homMk g }.map
f ≫
{
obj := fun V =>
{
obj :=
{ left := V.obj, right := { as := PUnit.unit },
hom := homOfLE (_ : (𝟭 (Opens ↑X)).obj V.obj ≤ (Functor.fromPUnit Y).obj { as := PUnit.unit }) },
property :=
(_ :
∃ Y_1 h g,
presieveOfCoveringAux U Y g ∧
h ≫ g =
{ left := V.obj, right := { as := PUnit.unit },
hom :=
homOfLE
(_ :
(𝟭 (Opens ↑X)).obj V.obj ≤
(Functor.fromPUnit Y).obj { as := PUnit.unit }) }.hom) },
map := fun {x x_1} g => Over.homMk g }.map
g).left
[PROOFSTEP]
simp only [Functor.id_obj, Sieve.generate_apply, Functor.const_obj_obj, Over.homMk_left, eq_iff_true_of_subsingleton]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
⊢ ∀ (X_1 : FullSubcategory fun f => (Sieve.generate (presieveOfCoveringAux U Y)).arrows f.hom),
(𝟭 (FullSubcategory fun f => (Sieve.generate (presieveOfCoveringAux U Y)).arrows f.hom)).obj X_1 =
(generateEquivalenceOpensLe_functor' U ?m.44561 ⋙ generateEquivalenceOpensLe_inverse' U ?m.44608).obj X_1
[PROOFSTEP]
rintro ⟨⟨_, _⟩, _⟩
[GOAL]
case mk.mk
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
left✝ : Opens ↑X
right✝ : Discrete PUnit
hom✝ : (𝟭 (Opens ↑X)).obj left✝ ⟶ (Functor.fromPUnit Y).obj right✝
property✝ : (Sieve.generate (presieveOfCoveringAux U Y)).arrows { left := left✝, right := right✝, hom := hom✝ }.hom
⊢ (𝟭 (FullSubcategory fun f => (Sieve.generate (presieveOfCoveringAux U Y)).arrows f.hom)).obj
{ obj := { left := left✝, right := right✝, hom := hom✝ }, property := property✝ } =
(generateEquivalenceOpensLe_functor' U ?m.44561 ⋙ generateEquivalenceOpensLe_inverse' U ?m.44608).obj
{ obj := { left := left✝, right := right✝, hom := hom✝ }, property := property✝ }
[PROOFSTEP]
dsimp
[GOAL]
case mk.mk
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
left✝ : Opens ↑X
right✝ : Discrete PUnit
hom✝ : (𝟭 (Opens ↑X)).obj left✝ ⟶ (Functor.fromPUnit Y).obj right✝
property✝ : (Sieve.generate (presieveOfCoveringAux U Y)).arrows { left := left✝, right := right✝, hom := hom✝ }.hom
⊢ { obj := { left := left✝, right := right✝, hom := hom✝ }, property := property✝ } =
(generateEquivalenceOpensLe_inverse' U ?m.44608).obj
((generateEquivalenceOpensLe_functor' U ?m.44561).obj
{ obj := { left := left✝, right := right✝, hom := hom✝ }, property := property✝ })
[PROOFSTEP]
congr
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
⊢ ∀ (X_1 Y_1 : FullSubcategory fun f => (Sieve.generate (presieveOfCoveringAux U Y)).arrows f.hom) (f : X_1 ⟶ Y_1),
(𝟭 (FullSubcategory fun f => (Sieve.generate (presieveOfCoveringAux U Y)).arrows f.hom)).map f =
eqToHom
(_ :
(𝟭 (FullSubcategory fun f => (Sieve.generate (presieveOfCoveringAux U Y)).arrows f.hom)).obj X_1 =
(generateEquivalenceOpensLe_functor' U ?m.44561 ⋙ generateEquivalenceOpensLe_inverse' U ?m.44608).obj
X_1) ≫
(generateEquivalenceOpensLe_functor' U ?m.44561 ⋙ generateEquivalenceOpensLe_inverse' U ?m.44608).map f ≫
eqToHom
(_ :
(generateEquivalenceOpensLe_functor' U ?m.44561 ⋙ generateEquivalenceOpensLe_inverse' U ?m.44608).obj
Y_1 =
(𝟭 (FullSubcategory fun f => (Sieve.generate (presieveOfCoveringAux U Y)).arrows f.hom)).obj Y_1)
[PROOFSTEP]
intros
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
X✝ Y✝ : FullSubcategory fun f => (Sieve.generate (presieveOfCoveringAux U Y)).arrows f.hom
f✝ : X✝ ⟶ Y✝
⊢ (𝟭 (FullSubcategory fun f => (Sieve.generate (presieveOfCoveringAux U Y)).arrows f.hom)).map f✝ =
eqToHom
(_ :
(𝟭 (FullSubcategory fun f => (Sieve.generate (presieveOfCoveringAux U Y)).arrows f.hom)).obj X✝ =
(generateEquivalenceOpensLe_functor' U ?m.44561 ⋙ generateEquivalenceOpensLe_inverse' U ?m.44608).obj X✝) ≫
(generateEquivalenceOpensLe_functor' U ?m.44561 ⋙ generateEquivalenceOpensLe_inverse' U ?m.44608).map f✝ ≫
eqToHom
(_ :
(generateEquivalenceOpensLe_functor' U ?m.44561 ⋙ generateEquivalenceOpensLe_inverse' U ?m.44608).obj Y✝ =
(𝟭 (FullSubcategory fun f => (Sieve.generate (presieveOfCoveringAux U Y)).arrows f.hom)).obj Y✝)
[PROOFSTEP]
refine Over.OverMorphism.ext ?_
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
X✝ Y✝ : FullSubcategory fun f => (Sieve.generate (presieveOfCoveringAux U Y)).arrows f.hom
f✝ : X✝ ⟶ Y✝
⊢ ((𝟭 (FullSubcategory fun f => (Sieve.generate (presieveOfCoveringAux U Y)).arrows f.hom)).map f✝).left =
(eqToHom
(_ :
(𝟭 (FullSubcategory fun f => (Sieve.generate (presieveOfCoveringAux U Y)).arrows f.hom)).obj X✝ =
(generateEquivalenceOpensLe_functor' U ?m.44561 ⋙ generateEquivalenceOpensLe_inverse' U ?m.44608).obj
X✝) ≫
(generateEquivalenceOpensLe_functor' U ?m.44561 ⋙ generateEquivalenceOpensLe_inverse' U ?m.44608).map f✝ ≫
eqToHom
(_ :
(generateEquivalenceOpensLe_functor' U ?m.44561 ⋙ generateEquivalenceOpensLe_inverse' U ?m.44608).obj Y✝ =
(𝟭 (FullSubcategory fun f => (Sieve.generate (presieveOfCoveringAux U Y)).arrows f.hom)).obj Y✝)).left
[PROOFSTEP]
aesop_cat
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
⊢ ∀ (X_1 : OpensLeCover U),
(generateEquivalenceOpensLe_inverse' U (_ : Y = iSup U) ⋙
generateEquivalenceOpensLe_functor' U (_ : Y = iSup U)).obj
X_1 =
(𝟭 (OpensLeCover U)).obj X_1
[PROOFSTEP]
intro
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
X✝ : OpensLeCover U
⊢ (generateEquivalenceOpensLe_inverse' U (_ : Y = iSup U) ⋙ generateEquivalenceOpensLe_functor' U (_ : Y = iSup U)).obj
X✝ =
(𝟭 (OpensLeCover U)).obj X✝
[PROOFSTEP]
refine FullSubcategory.ext _ _ ?_
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
X✝ : OpensLeCover U
⊢ ((generateEquivalenceOpensLe_inverse' U (_ : Y = iSup U) ⋙ generateEquivalenceOpensLe_functor' U (_ : Y = iSup U)).obj
X✝).obj =
((𝟭 (OpensLeCover U)).obj X✝).obj
[PROOFSTEP]
rfl
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
⊢ ∀ (X_1 Y_1 : OpensLeCover U) (f : X_1 ⟶ Y_1),
HEq
((generateEquivalenceOpensLe_inverse' U (_ : Y = iSup U) ⋙
generateEquivalenceOpensLe_functor' U (_ : Y = iSup U)).map
f)
((𝟭 (OpensLeCover U)).map f)
[PROOFSTEP]
intros
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
X✝ Y✝ : OpensLeCover U
f✝ : X✝ ⟶ Y✝
⊢ HEq
((generateEquivalenceOpensLe_inverse' U (_ : Y = iSup U) ⋙
generateEquivalenceOpensLe_functor' U (_ : Y = iSup U)).map
f✝)
((𝟭 (OpensLeCover U)).map f✝)
[PROOFSTEP]
rfl
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
j : (FullSubcategory fun f => (Sieve.generate (presieveOfCoveringAux U Y)).arrows f.hom)ᵒᵖ
⊢ F.map
(eqToHom
(_ :
op (opensLeCoverCocone U).pt =
op (Presieve.cocone (Sieve.generate (presieveOfCoveringAux U Y)).arrows).pt)) ≫
NatTrans.app (F.mapCone (Cocone.op (Presieve.cocone (Sieve.generate (presieveOfCoveringAux U Y)).arrows))).π j =
NatTrans.app
(Cone.whisker (Equivalence.op (generateEquivalenceOpensLe U hY)).functor
(F.mapCone (Cocone.op (opensLeCoverCocone U)))).π
j
[PROOFSTEP]
erw [← F.map_comp]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
j : (FullSubcategory fun f => (Sieve.generate (presieveOfCoveringAux U Y)).arrows f.hom)ᵒᵖ
⊢ F.map
(eqToHom
(_ :
op (opensLeCoverCocone U).pt =
op (Presieve.cocone (Sieve.generate (presieveOfCoveringAux U Y)).arrows).pt) ≫
NatTrans.app (Cocone.op (Presieve.cocone (Sieve.generate (presieveOfCoveringAux U Y)).arrows)).π j) =
NatTrans.app
(Cone.whisker (Equivalence.op (generateEquivalenceOpensLe U hY)).functor
(F.mapCone (Cocone.op (opensLeCoverCocone U)))).π
j
[PROOFSTEP]
dsimp
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
j : (FullSubcategory fun f => (Sieve.generate (presieveOfCoveringAux U Y)).arrows f.hom)ᵒᵖ
⊢ F.map (eqToHom (_ : op (opensLeCoverCocone U).pt = op Y) ≫ j.unop.obj.hom.op) =
F.map
(NatTrans.app (opensLeCoverCocone U).ι ((generateEquivalenceOpensLe_functor' U (_ : Y = iSup U)).obj j.unop)).op
[PROOFSTEP]
congr 1
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
j : (FullSubcategory fun f => (Sieve.generate (presieveOfCoveringAux U Y)).arrows f.hom)ᵒᵖ
⊢ F.map
(eqToHom
(_ :
op (Presieve.cocone (Sieve.generate (presieveOfCoveringAux U Y)).arrows).pt =
op (opensLeCoverCocone U).pt)) ≫
NatTrans.app
(Cone.whisker (Equivalence.op (generateEquivalenceOpensLe U hY)).functor
(F.mapCone (Cocone.op (opensLeCoverCocone U)))).π
j =
NatTrans.app (F.mapCone (Cocone.op (Presieve.cocone (Sieve.generate (presieveOfCoveringAux U Y)).arrows))).π j
[PROOFSTEP]
erw [← F.map_comp]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
j : (FullSubcategory fun f => (Sieve.generate (presieveOfCoveringAux U Y)).arrows f.hom)ᵒᵖ
⊢ F.map
(eqToHom
(_ :
op (Presieve.cocone (Sieve.generate (presieveOfCoveringAux U Y)).arrows).pt =
op (opensLeCoverCocone U).pt) ≫
NatTrans.app (Cocone.op (opensLeCoverCocone U)).π
((Equivalence.op (generateEquivalenceOpensLe U hY)).functor.obj j)) =
NatTrans.app (F.mapCone (Cocone.op (Presieve.cocone (Sieve.generate (presieveOfCoveringAux U Y)).arrows))).π j
[PROOFSTEP]
dsimp
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
j : (FullSubcategory fun f => (Sieve.generate (presieveOfCoveringAux U Y)).arrows f.hom)ᵒᵖ
⊢ F.map
(eqToHom (_ : op Y = op (opensLeCoverCocone U).pt) ≫
(NatTrans.app (opensLeCoverCocone U).ι
((generateEquivalenceOpensLe_functor' U (_ : Y = iSup U)).obj j.unop)).op) =
F.map j.unop.obj.hom.op
[PROOFSTEP]
congr 1
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
⊢ ConeMorphism.mk
(F.map
(eqToHom
(_ :
op (opensLeCoverCocone U).pt =
op (Presieve.cocone (Sieve.generate (presieveOfCoveringAux U Y)).arrows).pt))) ≫
ConeMorphism.mk
(F.map
(eqToHom
(_ :
op (Presieve.cocone (Sieve.generate (presieveOfCoveringAux U Y)).arrows).pt =
op (opensLeCoverCocone U).pt))) =
𝟙
(Cone.whisker (Equivalence.op (generateEquivalenceOpensLe U hY)).functor
(F.mapCone (Cocone.op (opensLeCoverCocone U))))
[PROOFSTEP]
ext
[GOAL]
case w
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
⊢ (ConeMorphism.mk
(F.map
(eqToHom
(_ :
op (opensLeCoverCocone U).pt =
op (Presieve.cocone (Sieve.generate (presieveOfCoveringAux U Y)).arrows).pt))) ≫
ConeMorphism.mk
(F.map
(eqToHom
(_ :
op (Presieve.cocone (Sieve.generate (presieveOfCoveringAux U Y)).arrows).pt =
op (opensLeCoverCocone U).pt)))).Hom =
(𝟙
(Cone.whisker (Equivalence.op (generateEquivalenceOpensLe U hY)).functor
(F.mapCone (Cocone.op (opensLeCoverCocone U))))).Hom
[PROOFSTEP]
simp [eqToHom_map]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
⊢ ConeMorphism.mk
(F.map
(eqToHom
(_ :
op (Presieve.cocone (Sieve.generate (presieveOfCoveringAux U Y)).arrows).pt =
op (opensLeCoverCocone U).pt))) ≫
ConeMorphism.mk
(F.map
(eqToHom
(_ :
op (opensLeCoverCocone U).pt =
op (Presieve.cocone (Sieve.generate (presieveOfCoveringAux U Y)).arrows).pt))) =
𝟙 (F.mapCone (Cocone.op (Presieve.cocone (Sieve.generate (presieveOfCoveringAux U Y)).arrows)))
[PROOFSTEP]
ext
[GOAL]
case w
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
⊢ (ConeMorphism.mk
(F.map
(eqToHom
(_ :
op (Presieve.cocone (Sieve.generate (presieveOfCoveringAux U Y)).arrows).pt =
op (opensLeCoverCocone U).pt))) ≫
ConeMorphism.mk
(F.map
(eqToHom
(_ :
op (opensLeCoverCocone U).pt =
op (Presieve.cocone (Sieve.generate (presieveOfCoveringAux U Y)).arrows).pt)))).Hom =
(𝟙 (F.mapCone (Cocone.op (Presieve.cocone (Sieve.generate (presieveOfCoveringAux U Y)).arrows)))).Hom
[PROOFSTEP]
simp [eqToHom_map]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
R : Presieve Y
hR : Sieve.generate R ∈ GrothendieckTopology.sieves (Opens.grothendieckTopology ↑X) Y
⊢ IsLimit (F.mapCone (Cocone.op (opensLeCoverCocone (coveringOfPresieve Y R)))) ≃
IsLimit (F.mapCone (Cocone.op (Presieve.cocone (Sieve.generate R).arrows)))
[PROOFSTEP]
convert
isLimitOpensLeEquivGenerate₁ F (coveringOfPresieve Y R)
(coveringOfPresieve.iSup_eq_of_mem_grothendieck Y R hR).symm using
1
[GOAL]
case h.e'_2
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
R : Presieve Y
hR : Sieve.generate R ∈ GrothendieckTopology.sieves (Opens.grothendieckTopology ↑X) Y
⊢ IsLimit (F.mapCone (Cocone.op (Presieve.cocone (Sieve.generate R).arrows))) =
IsLimit
(F.mapCone
(Cocone.op (Presieve.cocone (Sieve.generate (presieveOfCoveringAux (coveringOfPresieve Y R) Y)).arrows)))
[PROOFSTEP]
rw [covering_presieve_eq_self R]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
⊢ IsSheaf F ↔ IsSheafOpensLeCover F
[PROOFSTEP]
refine' (Presheaf.isSheaf_iff_isLimit _ _).trans _
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
⊢ (∀ ⦃X_1 : Opens ↑X⦄ (S : Sieve X_1),
S ∈ GrothendieckTopology.sieves (Opens.grothendieckTopology ↑X) X_1 →
Nonempty (IsLimit (F.mapCone (Cocone.op (Presieve.cocone S.arrows))))) ↔
IsSheafOpensLeCover F
[PROOFSTEP]
constructor
[GOAL]
case mp
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
⊢ (∀ ⦃X_1 : Opens ↑X⦄ (S : Sieve X_1),
S ∈ GrothendieckTopology.sieves (Opens.grothendieckTopology ↑X) X_1 →
Nonempty (IsLimit (F.mapCone (Cocone.op (Presieve.cocone S.arrows))))) →
IsSheafOpensLeCover F
[PROOFSTEP]
intro h ι U
[GOAL]
case mp
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι✝ : Type w
U✝ : ι✝ → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U✝
h :
∀ ⦃X_1 : Opens ↑X⦄ (S : Sieve X_1),
S ∈ GrothendieckTopology.sieves (Opens.grothendieckTopology ↑X) X_1 →
Nonempty (IsLimit (F.mapCone (Cocone.op (Presieve.cocone S.arrows))))
ι : Type w
U : ι → Opens ↑X
⊢ Nonempty (IsLimit (F.mapCone (Cocone.op (opensLeCoverCocone U))))
[PROOFSTEP]
rw [(isLimitOpensLeEquivGenerate₁ F U rfl).nonempty_congr]
[GOAL]
case mp
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι✝ : Type w
U✝ : ι✝ → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U✝
h :
∀ ⦃X_1 : Opens ↑X⦄ (S : Sieve X_1),
S ∈ GrothendieckTopology.sieves (Opens.grothendieckTopology ↑X) X_1 →
Nonempty (IsLimit (F.mapCone (Cocone.op (Presieve.cocone S.arrows))))
ι : Type w
U : ι → Opens ↑X
⊢ Nonempty
(IsLimit (F.mapCone (Cocone.op (Presieve.cocone (Sieve.generate (presieveOfCoveringAux U (iSup U))).arrows))))
[PROOFSTEP]
apply h
[GOAL]
case mp.a
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι✝ : Type w
U✝ : ι✝ → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U✝
h :
∀ ⦃X_1 : Opens ↑X⦄ (S : Sieve X_1),
S ∈ GrothendieckTopology.sieves (Opens.grothendieckTopology ↑X) X_1 →
Nonempty (IsLimit (F.mapCone (Cocone.op (Presieve.cocone S.arrows))))
ι : Type w
U : ι → Opens ↑X
⊢ Sieve.generate (presieveOfCoveringAux U (iSup U)) ∈
GrothendieckTopology.sieves (Opens.grothendieckTopology ↑X) (iSup U)
[PROOFSTEP]
apply presieveOfCovering.mem_grothendieckTopology
[GOAL]
case mpr
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y : Opens ↑X
hY : Y = iSup U
⊢ IsSheafOpensLeCover F →
∀ ⦃X_1 : Opens ↑X⦄ (S : Sieve X_1),
S ∈ GrothendieckTopology.sieves (Opens.grothendieckTopology ↑X) X_1 →
Nonempty (IsLimit (F.mapCone (Cocone.op (Presieve.cocone S.arrows))))
[PROOFSTEP]
intro h Y S
[GOAL]
case mpr
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y✝ : Opens ↑X
hY : Y✝ = iSup U
h : IsSheafOpensLeCover F
Y : Opens ↑X
S : Sieve Y
⊢ S ∈ GrothendieckTopology.sieves (Opens.grothendieckTopology ↑X) Y →
Nonempty (IsLimit (F.mapCone (Cocone.op (Presieve.cocone S.arrows))))
[PROOFSTEP]
rw [← Sieve.generate_sieve S]
[GOAL]
case mpr
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y✝ : Opens ↑X
hY : Y✝ = iSup U
h : IsSheafOpensLeCover F
Y : Opens ↑X
S : Sieve Y
⊢ Sieve.generate S.arrows ∈ GrothendieckTopology.sieves (Opens.grothendieckTopology ↑X) Y →
Nonempty (IsLimit (F.mapCone (Cocone.op (Presieve.cocone (Sieve.generate S.arrows).arrows))))
[PROOFSTEP]
intro hS
[GOAL]
case mpr
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y✝ : Opens ↑X
hY : Y✝ = iSup U
h : IsSheafOpensLeCover F
Y : Opens ↑X
S : Sieve Y
hS : Sieve.generate S.arrows ∈ GrothendieckTopology.sieves (Opens.grothendieckTopology ↑X) Y
⊢ Nonempty (IsLimit (F.mapCone (Cocone.op (Presieve.cocone (Sieve.generate S.arrows).arrows))))
[PROOFSTEP]
rw [← (isLimitOpensLeEquivGenerate₂ F S.1 hS).nonempty_congr]
[GOAL]
case mpr
C : Type u
inst✝ : Category.{v, u} C
X : TopCat
F : Presheaf C X
ι : Type w
U : ι → Opens ↑X
Y✝ : Opens ↑X
hY : Y✝ = iSup U
h : IsSheafOpensLeCover F
Y : Opens ↑X
S : Sieve Y
hS : Sieve.generate S.arrows ∈ GrothendieckTopology.sieves (Opens.grothendieckTopology ↑X) Y
⊢ Nonempty (IsLimit (F.mapCone (Cocone.op (opensLeCoverCocone (coveringOfPresieve Y S.arrows)))))
[PROOFSTEP]
apply h
|
function y = acoshplus1(x)
%ACOSHPLUS1 Inverse hyperbolic cosine of argument plus one.
%
% ACOSHPLUS1(X) is ACOSH(X+1) calculated in a way that is numerically better
% when X is close to one.
%
% This illustrates the difference
%
% x = 2e-15*(0:0.01:1);
% plot(x, acosh(x+1), 'b-', x, acoshplus1(x), 'r-');
%
% See also COSHMINUS1.
% Author: Peter J. Acklam
% Time-stamp: 2003-10-13 14:54:17 +0200
% E-mail: [email protected]
% URL: http://home.online.no/~pjacklam
% check number of input arguments
error(nargchk(1, 1, nargin));
y = 2 * asinh(sqrt(x / 2));
|
myTestRule {
#Input parameter is:
# Data object path
#Output parameters are:
# Collection name
# File name
#Output from running the example is:
# Object is /tempZone/home/rods/sub1/foo1
# Collection is /tempZone/home/rods/sub1 and file is foo1
writeLine("stdout","Object is *dataObject");
msiSplitPath(*dataObject,*Coll,*File);
writeLine("stdout","Collection is *Coll and file is *File");
}
INPUT *dataObject="/tempZone/home/rods/sub1/foo1"
OUTPUT ruleExecOut
|
{-# OPTIONS --without-K --rewriting #-}
module C1.LEM where
open import Basics
open import Bool
open import LEM
open import NotNot
open import Flat
open import Sharp
open import C1.Base
open import lib.NType2
-- UNFINISHED due to ♯-ptwise problems
♯-prop-is-¬¬ : ∀ {i}(P : PropT i) (p : (P holds) is-codiscrete) → (P holds) ≃ ((not (not P)) holds)
♯-prop-is-¬¬ P p =
iff-to-≃ {P = P} {Q = not (not P)}
-- ⇒
continue
-- ⇐
(not (not P) holds
–⟨ lemma ⟩→
♯ (P holds)
–⟨ un♯ p ⟩→
P holds
→∎)
where
postulate lemma : not (not P) holds → ♯ (P holds)
-- The problem here is that ♯-ptwise won't rewrite to ♯ (P holds)
-- So, we can't run the right proof.
-- I'm not sure why though...
nbhd-is-infinitesimal : ∀ {i} {A : hSet i} (a : ∈ A) → (nbhd a) is-infinitesimal
nbhd-is-infinitesimal {A = (A , p)} a =
has-level-in (((a , refl≈)^♯) ,
(λ b' → ♯-=-retract $
let♯ b ^♯:= b' in♯
(♯-=-compare
(<– (♯-prop-is-¬¬ (♯ₙ $ (a , refl≈) ==ₚ b)
(♯-is-codiscrete ((a , refl≈) == b)))
{!snd b!})) ^♯
in-family (λ b' → ((a , refl≈)^♯) == b')))
|
[STATEMENT]
lemma subresultant_prs_gcd: assumes "subresultant_prs G1 G2 = (Gk, hk)"
shows "\<exists> a b. a \<noteq> 0 \<and> b \<noteq> 0 \<and> smult a (gcd G1 G2) = smult b (normalize Gk)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (normalize Gk)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (normalize Gk)
[PROOF STEP]
from subresultant_prs[OF div_exp_sound assms]
[PROOF STATE]
proof (chain)
picking this:
F k = ffp Gk \<and> h k = ff hk \<and> (?i \<noteq> 0 \<longrightarrow> F ?i \<in> range ffp) \<and> (3 \<le> ?i \<longrightarrow> ?i \<le> Suc k \<longrightarrow> \<beta> ?i \<in> range ff)
[PROOF STEP]
have Fk: "F k = ffp Gk" and "\<forall> i. \<exists> H. i \<noteq> 0 \<longrightarrow> F i = ffp H"
and "\<forall> i. \<exists> b. 3 \<le> i \<longrightarrow> i \<le> Suc k \<longrightarrow> \<beta> i = ff b"
[PROOF STATE]
proof (prove)
using this:
F k = ffp Gk \<and> h k = ff hk \<and> (?i \<noteq> 0 \<longrightarrow> F ?i \<in> range ffp) \<and> (3 \<le> ?i \<longrightarrow> ?i \<le> Suc k \<longrightarrow> \<beta> ?i \<in> range ff)
goal (1 subgoal):
1. F k = ffp Gk &&& \<forall>i. \<exists>H. i \<noteq> 0 \<longrightarrow> F i = ffp H &&& \<forall>i. \<exists>b. 3 \<le> i \<longrightarrow> i \<le> Suc k \<longrightarrow> \<beta> i = ff b
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
F k = ffp Gk
\<forall>i. \<exists>H. i \<noteq> 0 \<longrightarrow> F i = ffp H
\<forall>i. \<exists>b. 3 \<le> i \<longrightarrow> i \<le> Suc k \<longrightarrow> \<beta> i = ff b
goal (1 subgoal):
1. \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (normalize Gk)
[PROOF STEP]
from choice[OF this(2)] choice[OF this(3)]
[PROOF STATE]
proof (chain)
picking this:
\<exists>f. \<forall>x. x \<noteq> 0 \<longrightarrow> F x = ffp (f x)
\<exists>f. \<forall>x\<ge>3. x \<le> Suc k \<longrightarrow> \<beta> x = ff (f x)
[PROOF STEP]
obtain H beta where
FH: "\<And> i. i \<noteq> 0 \<Longrightarrow> F i = ffp (H i)" and
beta: "\<And> i. 3 \<le> i \<Longrightarrow> i \<le> Suc k \<Longrightarrow> \<beta> i = ff (beta i)"
[PROOF STATE]
proof (prove)
using this:
\<exists>f. \<forall>x. x \<noteq> 0 \<longrightarrow> F x = ffp (f x)
\<exists>f. \<forall>x\<ge>3. x \<le> Suc k \<longrightarrow> \<beta> x = ff (f x)
goal (1 subgoal):
1. (\<And>H beta. \<lbrakk>\<And>i. i \<noteq> 0 \<Longrightarrow> F i = ffp (H i); \<And>i. \<lbrakk>3 \<le> i; i \<le> Suc k\<rbrakk> \<Longrightarrow> \<beta> i = ff (beta i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?i1 \<noteq> 0 \<Longrightarrow> F ?i1 = ffp (H ?i1)
\<lbrakk>3 \<le> ?i1; ?i1 \<le> Suc k\<rbrakk> \<Longrightarrow> \<beta> ?i1 = ff (beta ?i1)
goal (1 subgoal):
1. \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (normalize Gk)
[PROOF STEP]
from Fk FH[OF k0] FH[of 1] FH[of 2] FH[of "Suc k"] F0[of "Suc k"] F1 F2
[PROOF STATE]
proof (chain)
picking this:
F k = ffp Gk
F k = ffp (H k)
1 \<noteq> 0 \<Longrightarrow> F 1 = ffp (H 1)
2 \<noteq> 0 \<Longrightarrow> F 2 = ffp (H 2)
Suc k \<noteq> 0 \<Longrightarrow> F (Suc k) = ffp (H (Suc k))
Suc k \<noteq> 0 \<Longrightarrow> (F (Suc k) = 0) = (k < Suc k)
F 1 = ffp G1
F 2 = ffp G2
[PROOF STEP]
have border: "H k = Gk" "H 1 = G1" "H 2 = G2" "H (Suc k) = 0"
[PROOF STATE]
proof (prove)
using this:
F k = ffp Gk
F k = ffp (H k)
1 \<noteq> 0 \<Longrightarrow> F 1 = ffp (H 1)
2 \<noteq> 0 \<Longrightarrow> F 2 = ffp (H 2)
Suc k \<noteq> 0 \<Longrightarrow> F (Suc k) = ffp (H (Suc k))
Suc k \<noteq> 0 \<Longrightarrow> (F (Suc k) = 0) = (k < Suc k)
F 1 = ffp G1
F 2 = ffp G2
goal (1 subgoal):
1. (H k = Gk &&& H 1 = G1) &&& H 2 = G2 &&& H (Suc k) = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
H k = Gk
H 1 = G1
H 2 = G2
H (Suc k) = 0
goal (1 subgoal):
1. \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (normalize Gk)
[PROOF STEP]
have "i \<noteq> 0 \<Longrightarrow> i \<le> k \<Longrightarrow> \<exists> a b. a \<noteq> 0 \<and> b \<noteq> 0 \<and> smult a (gcd G1 G2) = smult b (gcd (H i) (H (Suc i)))" for i
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lbrakk>i \<noteq> 0; i \<le> k\<rbrakk> \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
proof (induct i rule: less_induct)
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<And>x. \<lbrakk>\<And>y. \<lbrakk>y < x; y \<noteq> 0; y \<le> k\<rbrakk> \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H y) (H (Suc y))); x \<noteq> 0; x \<le> k\<rbrakk> \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H x) (H (Suc x)))
[PROOF STEP]
case (less i)
[PROOF STATE]
proof (state)
this:
\<lbrakk>?y1 < i; ?y1 \<noteq> 0; ?y1 \<le> k\<rbrakk> \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H ?y1) (H (Suc ?y1)))
i \<noteq> 0
i \<le> k
goal (1 subgoal):
1. \<And>x. \<lbrakk>\<And>y. \<lbrakk>y < x; y \<noteq> 0; y \<le> k\<rbrakk> \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H y) (H (Suc y))); x \<noteq> 0; x \<le> k\<rbrakk> \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H x) (H (Suc x)))
[PROOF STEP]
from less(3)
[PROOF STATE]
proof (chain)
picking this:
i \<le> k
[PROOF STEP]
have ik: "i \<le> k"
[PROOF STATE]
proof (prove)
using this:
i \<le> k
goal (1 subgoal):
1. i \<le> k
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
i \<le> k
goal (1 subgoal):
1. \<And>x. \<lbrakk>\<And>y. \<lbrakk>y < x; y \<noteq> 0; y \<le> k\<rbrakk> \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H y) (H (Suc y))); x \<noteq> 0; x \<le> k\<rbrakk> \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H x) (H (Suc x)))
[PROOF STEP]
from less(2)
[PROOF STATE]
proof (chain)
picking this:
i \<noteq> 0
[PROOF STEP]
have "i = 1 \<or> i \<ge> 2"
[PROOF STATE]
proof (prove)
using this:
i \<noteq> 0
goal (1 subgoal):
1. i = 1 \<or> 2 \<le> i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i = 1 \<or> 2 \<le> i
goal (1 subgoal):
1. \<And>x. \<lbrakk>\<And>y. \<lbrakk>y < x; y \<noteq> 0; y \<le> k\<rbrakk> \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H y) (H (Suc y))); x \<noteq> 0; x \<le> k\<rbrakk> \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H x) (H (Suc x)))
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
i = 1 \<or> 2 \<le> i
goal (1 subgoal):
1. \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. i = 1 \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
2. 2 \<le> i \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
assume "i = 1"
[PROOF STATE]
proof (state)
this:
i = 1
goal (2 subgoals):
1. i = 1 \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
2. 2 \<le> i \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
i = 1
goal (1 subgoal):
1. \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
unfolding border[symmetric]
[PROOF STATE]
proof (prove)
using this:
i = 1
goal (1 subgoal):
1. \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd (H 1) (H 2)) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
by (intro exI[of _ 1], auto simp: numeral_2_eq_2)
[PROOF STATE]
proof (state)
this:
\<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
goal (1 subgoal):
1. 2 \<le> i \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. 2 \<le> i \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
assume i2: "i \<ge> 2"
[PROOF STATE]
proof (state)
this:
2 \<le> i
goal (1 subgoal):
1. 2 \<le> i \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
with ik
[PROOF STATE]
proof (chain)
picking this:
i \<le> k
2 \<le> i
[PROOF STEP]
have "i - 1 < i" "i - 1 \<noteq> 0" and imk: "i - 1 \<le> k"
[PROOF STATE]
proof (prove)
using this:
i \<le> k
2 \<le> i
goal (1 subgoal):
1. (i - 1 < i &&& i - 1 \<noteq> 0) &&& i - 1 \<le> k
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i - 1 < i
i - 1 \<noteq> 0
i - 1 \<le> k
goal (1 subgoal):
1. 2 \<le> i \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
from less(1)[OF this] i2
[PROOF STATE]
proof (chain)
picking this:
\<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H (i - 1)) (H (Suc (i - 1))))
2 \<le> i
[PROOF STEP]
obtain a b where a: "a \<noteq> 0" and b: "b \<noteq> 0" and IH: "smult a (gcd G1 G2) = smult b (gcd (H (i - 1)) (H i))"
[PROOF STATE]
proof (prove)
using this:
\<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H (i - 1)) (H (Suc (i - 1))))
2 \<le> i
goal (1 subgoal):
1. (\<And>a b. \<lbrakk>a \<noteq> (0::'a); b \<noteq> (0::'a); Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H (i - 1)) (H i))\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a \<noteq> (0::'a)
b \<noteq> (0::'a)
Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H (i - 1)) (H i))
goal (1 subgoal):
1. 2 \<le> i \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
define M where "M = pseudo_mod (H (i - 1)) (H i)"
[PROOF STATE]
proof (state)
this:
M = pseudo_mod (H (i - 1)) (H i)
goal (1 subgoal):
1. 2 \<le> i \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
define c where "c = \<beta> (Suc i)"
[PROOF STATE]
proof (state)
this:
c = \<beta> (Suc i)
goal (1 subgoal):
1. 2 \<le> i \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
have M: "pseudo_mod (F (i - 1)) (F i) = ffp M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. pseudo_mod (F (i - 1)) (F i) = ffp M
[PROOF STEP]
unfolding to_fract_hom.pseudo_mod_hom[symmetric] M_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. pseudo_mod (F (i - 1)) (F i) = pseudo_mod (ffp (H (i - 1))) (ffp (H i))
[PROOF STEP]
using i2 FH
[PROOF STATE]
proof (prove)
using this:
2 \<le> i
?i1 \<noteq> 0 \<Longrightarrow> F ?i1 = ffp (H ?i1)
goal (1 subgoal):
1. pseudo_mod (F (i - 1)) (F i) = pseudo_mod (ffp (H (i - 1))) (ffp (H i))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
pseudo_mod (F (i - 1)) (F i) = ffp M
goal (1 subgoal):
1. 2 \<le> i \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
have c: "c \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. c \<noteq> 0
[PROOF STEP]
using \<beta>0
[PROOF STATE]
proof (prove)
using this:
\<beta> ?i \<noteq> 0
goal (1 subgoal):
1. c \<noteq> 0
[PROOF STEP]
unfolding c_def
[PROOF STATE]
proof (prove)
using this:
\<beta> ?i \<noteq> 0
goal (1 subgoal):
1. \<beta> (Suc i) \<noteq> 0
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
c \<noteq> 0
goal (1 subgoal):
1. 2 \<le> i \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
from i2 ik
[PROOF STATE]
proof (chain)
picking this:
2 \<le> i
i \<le> k
[PROOF STEP]
have 3: "Suc i \<ge> 3" "Suc i \<le> Suc k"
[PROOF STATE]
proof (prove)
using this:
2 \<le> i
i \<le> k
goal (1 subgoal):
1. 3 \<le> Suc i &&& Suc i \<le> Suc k
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
3 \<le> Suc i
Suc i \<le> Suc k
goal (1 subgoal):
1. 2 \<le> i \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
from pmod[OF 3]
[PROOF STATE]
proof (chain)
picking this:
Polynomial.smult (\<beta> (Suc i)) (F (Suc i)) = pseudo_mod (F (Suc i - 2)) (F (Suc i - 1))
[PROOF STEP]
have pm: "smult c (F (Suc i)) = pseudo_mod (F (i - 1)) (F i)"
[PROOF STATE]
proof (prove)
using this:
Polynomial.smult (\<beta> (Suc i)) (F (Suc i)) = pseudo_mod (F (Suc i - 2)) (F (Suc i - 1))
goal (1 subgoal):
1. Polynomial.smult c (F (Suc i)) = pseudo_mod (F (i - 1)) (F i)
[PROOF STEP]
unfolding c_def
[PROOF STATE]
proof (prove)
using this:
Polynomial.smult (\<beta> (Suc i)) (F (Suc i)) = pseudo_mod (F (Suc i - 2)) (F (Suc i - 1))
goal (1 subgoal):
1. Polynomial.smult (\<beta> (Suc i)) (F (Suc i)) = pseudo_mod (F (i - 1)) (F i)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Polynomial.smult c (F (Suc i)) = pseudo_mod (F (i - 1)) (F i)
goal (1 subgoal):
1. 2 \<le> i \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
from beta[OF 3, folded c_def]
[PROOF STATE]
proof (chain)
picking this:
c = ff (beta (Suc i))
[PROOF STEP]
obtain d where cd: "c = ff d"
[PROOF STATE]
proof (prove)
using this:
c = ff (beta (Suc i))
goal (1 subgoal):
1. (\<And>d. c = ff d \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
c = ff d
goal (1 subgoal):
1. 2 \<le> i \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
with c
[PROOF STATE]
proof (chain)
picking this:
c \<noteq> 0
c = ff d
[PROOF STEP]
have d: "d \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
c \<noteq> 0
c = ff d
goal (1 subgoal):
1. d \<noteq> (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
d \<noteq> (0::'a)
goal (1 subgoal):
1. 2 \<le> i \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
from pm[unfolded cd M] FH[of "Suc i"]
[PROOF STATE]
proof (chain)
picking this:
Polynomial.smult (ff d) (F (Suc i)) = ffp M
Suc i \<noteq> 0 \<Longrightarrow> F (Suc i) = ffp (H (Suc i))
[PROOF STEP]
have "ffp (smult d (H (Suc i))) = ffp M"
[PROOF STATE]
proof (prove)
using this:
Polynomial.smult (ff d) (F (Suc i)) = ffp M
Suc i \<noteq> 0 \<Longrightarrow> F (Suc i) = ffp (H (Suc i))
goal (1 subgoal):
1. ffp (Polynomial.smult d (H (Suc i))) = ffp M
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ffp (Polynomial.smult d (H (Suc i))) = ffp M
goal (1 subgoal):
1. 2 \<le> i \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
hence pm: "smult d (H (Suc i)) = M"
[PROOF STATE]
proof (prove)
using this:
ffp (Polynomial.smult d (H (Suc i))) = ffp M
goal (1 subgoal):
1. Polynomial.smult d (H (Suc i)) = M
[PROOF STEP]
by (rule map_poly_hom.injectivity)
[PROOF STATE]
proof (state)
this:
Polynomial.smult d (H (Suc i)) = M
goal (1 subgoal):
1. 2 \<le> i \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
from ik F0[of i] i2 FH[of i]
[PROOF STATE]
proof (chain)
picking this:
i \<le> k
i \<noteq> 0 \<Longrightarrow> (F i = 0) = (k < i)
2 \<le> i
i \<noteq> 0 \<Longrightarrow> F i = ffp (H i)
[PROOF STEP]
have Hi0: "H i \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
i \<le> k
i \<noteq> 0 \<Longrightarrow> (F i = 0) = (k < i)
2 \<le> i
i \<noteq> 0 \<Longrightarrow> F i = ffp (H i)
goal (1 subgoal):
1. H i \<noteq> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
H i \<noteq> 0
goal (1 subgoal):
1. 2 \<le> i \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
from pseudo_mod[OF this, of "H (i - 1)", folded M_def]
[PROOF STATE]
proof (chain)
picking this:
\<exists>a q. a \<noteq> (0::'a) \<and> Polynomial.smult a (H (i - 1)) = H i * q + M
M = 0 \<or> degree M < degree (H i)
[PROOF STEP]
obtain c Q where c: "c \<noteq> 0" and "smult c (H (i - 1)) = H i * Q + M"
[PROOF STATE]
proof (prove)
using this:
\<exists>a q. a \<noteq> (0::'a) \<and> Polynomial.smult a (H (i - 1)) = H i * q + M
M = 0 \<or> degree M < degree (H i)
goal (1 subgoal):
1. (\<And>c Q. \<lbrakk>c \<noteq> (0::'a); Polynomial.smult c (H (i - 1)) = H i * Q + M\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
c \<noteq> (0::'a)
Polynomial.smult c (H (i - 1)) = H i * Q + M
goal (1 subgoal):
1. 2 \<le> i \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
from this[folded pm]
[PROOF STATE]
proof (chain)
picking this:
c \<noteq> (0::'a)
Polynomial.smult c (H (i - 1)) = H i * Q + Polynomial.smult d (H (Suc i))
[PROOF STEP]
have "smult c (H (i - 1)) = Q * H i + smult d (H (Suc i))"
[PROOF STATE]
proof (prove)
using this:
c \<noteq> (0::'a)
Polynomial.smult c (H (i - 1)) = H i * Q + Polynomial.smult d (H (Suc i))
goal (1 subgoal):
1. Polynomial.smult c (H (i - 1)) = Q * H i + Polynomial.smult d (H (Suc i))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Polynomial.smult c (H (i - 1)) = Q * H i + Polynomial.smult d (H (Suc i))
goal (1 subgoal):
1. 2 \<le> i \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
from gcd_add_mult[of "H i" Q "smult d (H (Suc i))", folded this]
[PROOF STATE]
proof (chain)
picking this:
gcd (H i) (Polynomial.smult c (H (i - 1))) = gcd (H i) (Polynomial.smult d (H (Suc i)))
[PROOF STEP]
have "gcd (H i) (smult c (H (i - 1))) = gcd (H i) (smult d (H (Suc i)))"
[PROOF STATE]
proof (prove)
using this:
gcd (H i) (Polynomial.smult c (H (i - 1))) = gcd (H i) (Polynomial.smult d (H (Suc i)))
goal (1 subgoal):
1. gcd (H i) (Polynomial.smult c (H (i - 1))) = gcd (H i) (Polynomial.smult d (H (Suc i)))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
gcd (H i) (Polynomial.smult c (H (i - 1))) = gcd (H i) (Polynomial.smult d (H (Suc i)))
goal (1 subgoal):
1. 2 \<le> i \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
with gcd_smult_ex[OF c, of "H (i - 1)" "H i"]
[PROOF STATE]
proof (chain)
picking this:
\<exists>b. gcd (Polynomial.smult c (H (i - 1))) (H i) = Polynomial.smult b (gcd (H (i - 1)) (H i)) \<and> b \<noteq> (0::'a)
gcd (H i) (Polynomial.smult c (H (i - 1))) = gcd (H i) (Polynomial.smult d (H (Suc i)))
[PROOF STEP]
obtain e where
e: "e \<noteq> 0" and "gcd (H i) (smult d (H (Suc i))) = smult e (gcd (H i) (H (i - 1)))"
[PROOF STATE]
proof (prove)
using this:
\<exists>b. gcd (Polynomial.smult c (H (i - 1))) (H i) = Polynomial.smult b (gcd (H (i - 1)) (H i)) \<and> b \<noteq> (0::'a)
gcd (H i) (Polynomial.smult c (H (i - 1))) = gcd (H i) (Polynomial.smult d (H (Suc i)))
goal (1 subgoal):
1. (\<And>e. \<lbrakk>e \<noteq> (0::'a); gcd (H i) (Polynomial.smult d (H (Suc i))) = Polynomial.smult e (gcd (H i) (H (i - 1)))\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding gcd.commute[of "H i"]
[PROOF STATE]
proof (prove)
using this:
\<exists>b. gcd (Polynomial.smult c (H (i - 1))) (H i) = Polynomial.smult b (gcd (H (i - 1)) (H i)) \<and> b \<noteq> (0::'a)
gcd (Polynomial.smult c (H (i - 1))) (H i) = gcd (Polynomial.smult d (H (Suc i))) (H i)
goal (1 subgoal):
1. (\<And>e. \<lbrakk>e \<noteq> (0::'a); gcd (Polynomial.smult d (H (Suc i))) (H i) = Polynomial.smult e (gcd (H (i - 1)) (H i))\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
e \<noteq> (0::'a)
gcd (H i) (Polynomial.smult d (H (Suc i))) = Polynomial.smult e (gcd (H i) (H (i - 1)))
goal (1 subgoal):
1. 2 \<le> i \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
with gcd_smult_ex[OF d, of "H (Suc i)" "H i"]
[PROOF STATE]
proof (chain)
picking this:
\<exists>b. gcd (Polynomial.smult d (H (Suc i))) (H i) = Polynomial.smult b (gcd (H (Suc i)) (H i)) \<and> b \<noteq> (0::'a)
e \<noteq> (0::'a)
gcd (H i) (Polynomial.smult d (H (Suc i))) = Polynomial.smult e (gcd (H i) (H (i - 1)))
[PROOF STEP]
obtain c where
c: "c \<noteq> 0" and "smult c (gcd (H i) (H (Suc i))) = smult e (gcd (H (i - 1)) (H i))"
[PROOF STATE]
proof (prove)
using this:
\<exists>b. gcd (Polynomial.smult d (H (Suc i))) (H i) = Polynomial.smult b (gcd (H (Suc i)) (H i)) \<and> b \<noteq> (0::'a)
e \<noteq> (0::'a)
gcd (H i) (Polynomial.smult d (H (Suc i))) = Polynomial.smult e (gcd (H i) (H (i - 1)))
goal (1 subgoal):
1. (\<And>c. \<lbrakk>c \<noteq> (0::'a); Polynomial.smult c (gcd (H i) (H (Suc i))) = Polynomial.smult e (gcd (H (i - 1)) (H i))\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding gcd.commute[of "H i"]
[PROOF STATE]
proof (prove)
using this:
\<exists>b. gcd (Polynomial.smult d (H (Suc i))) (H i) = Polynomial.smult b (gcd (H (Suc i)) (H i)) \<and> b \<noteq> (0::'a)
e \<noteq> (0::'a)
gcd (Polynomial.smult d (H (Suc i))) (H i) = Polynomial.smult e (gcd (H (i - 1)) (H i))
goal (1 subgoal):
1. (\<And>c. \<lbrakk>c \<noteq> (0::'a); Polynomial.smult c (gcd (H (Suc i)) (H i)) = Polynomial.smult e (gcd (H (i - 1)) (H i))\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
c \<noteq> (0::'a)
Polynomial.smult c (gcd (H i) (H (Suc i))) = Polynomial.smult e (gcd (H (i - 1)) (H i))
goal (1 subgoal):
1. 2 \<le> i \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
from arg_cong[OF this(2), of "smult b"] arg_cong[OF IH, of "smult e"]
[PROOF STATE]
proof (chain)
picking this:
Polynomial.smult b (Polynomial.smult c (gcd (H i) (H (Suc i)))) = Polynomial.smult b (Polynomial.smult e (gcd (H (i - 1)) (H i)))
Polynomial.smult e (Polynomial.smult a (gcd G1 G2)) = Polynomial.smult e (Polynomial.smult b (gcd (H (i - 1)) (H i)))
[PROOF STEP]
have "smult (e * a) (gcd G1 G2) = smult (b * c) (gcd (H i) (H (Suc i)))"
[PROOF STATE]
proof (prove)
using this:
Polynomial.smult b (Polynomial.smult c (gcd (H i) (H (Suc i)))) = Polynomial.smult b (Polynomial.smult e (gcd (H (i - 1)) (H i)))
Polynomial.smult e (Polynomial.smult a (gcd G1 G2)) = Polynomial.smult e (Polynomial.smult b (gcd (H (i - 1)) (H i)))
goal (1 subgoal):
1. Polynomial.smult (e * a) (gcd G1 G2) = Polynomial.smult (b * c) (gcd (H i) (H (Suc i)))
[PROOF STEP]
unfolding smult_smult
[PROOF STATE]
proof (prove)
using this:
Polynomial.smult (b * c) (gcd (H i) (H (Suc i))) = Polynomial.smult (b * e) (gcd (H (i - 1)) (H i))
Polynomial.smult (e * a) (gcd G1 G2) = Polynomial.smult (e * b) (gcd (H (i - 1)) (H i))
goal (1 subgoal):
1. Polynomial.smult (e * a) (gcd G1 G2) = Polynomial.smult (b * c) (gcd (H i) (H (Suc i)))
[PROOF STEP]
by (simp add: ac_simps)
[PROOF STATE]
proof (state)
this:
Polynomial.smult (e * a) (gcd G1 G2) = Polynomial.smult (b * c) (gcd (H i) (H (Suc i)))
goal (1 subgoal):
1. 2 \<le> i \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
Polynomial.smult (e * a) (gcd G1 G2) = Polynomial.smult (b * c) (gcd (H i) (H (Suc i)))
goal (1 subgoal):
1. 2 \<le> i \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
have "e * a \<noteq> 0" "b * c \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. e * a \<noteq> (0::'a) &&& b * c \<noteq> (0::'a)
[PROOF STEP]
using a b c e
[PROOF STATE]
proof (prove)
using this:
a \<noteq> (0::'a)
b \<noteq> (0::'a)
c \<noteq> (0::'a)
e \<noteq> (0::'a)
goal (1 subgoal):
1. e * a \<noteq> (0::'a) &&& b * c \<noteq> (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
e * a \<noteq> (0::'a)
b * c \<noteq> (0::'a)
goal (1 subgoal):
1. 2 \<le> i \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
Polynomial.smult (e * a) (gcd G1 G2) = Polynomial.smult (b * c) (gcd (H i) (H (Suc i)))
e * a \<noteq> (0::'a)
b * c \<noteq> (0::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
Polynomial.smult (e * a) (gcd G1 G2) = Polynomial.smult (b * c) (gcd (H i) (H (Suc i)))
e * a \<noteq> (0::'a)
b * c \<noteq> (0::'a)
goal (1 subgoal):
1. \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H i) (H (Suc i)))
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i1 \<noteq> 0; ?i1 \<le> k\<rbrakk> \<Longrightarrow> \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd (H ?i1) (H (Suc ?i1)))
goal (1 subgoal):
1. \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (normalize Gk)
[PROOF STEP]
from this[OF k0 le_refl, unfolded border]
[PROOF STATE]
proof (chain)
picking this:
\<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd Gk 0)
[PROOF STEP]
obtain a b where "a \<noteq> 0" "b \<noteq> 0" and "smult a (gcd G1 G2) = smult b (normalize Gk)"
[PROOF STATE]
proof (prove)
using this:
\<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (gcd Gk 0)
goal (1 subgoal):
1. (\<And>a b. \<lbrakk>a \<noteq> (0::'a); b \<noteq> (0::'a); Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (normalize Gk)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a \<noteq> (0::'a)
b \<noteq> (0::'a)
Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (normalize Gk)
goal (1 subgoal):
1. \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (normalize Gk)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
a \<noteq> (0::'a)
b \<noteq> (0::'a)
Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (normalize Gk)
goal (1 subgoal):
1. \<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (normalize Gk)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>a b. a \<noteq> (0::'a) \<and> b \<noteq> (0::'a) \<and> Polynomial.smult a (gcd G1 G2) = Polynomial.smult b (normalize Gk)
goal:
No subgoals!
[PROOF STEP]
qed |
[GOAL]
α : Type u
l : Thunk (List α)
t : List α
⊢ (fun xs => Thunk.get l ++ xs) t = (fun xs => Thunk.get l ++ xs) [] ++ t
[PROOFSTEP]
simp
[GOAL]
α : Type u
l : List α
⊢ toList (ofList l) = l
[PROOFSTEP]
cases l
[GOAL]
case nil
α : Type u
⊢ toList (ofList []) = []
case cons α : Type u head✝ : α tail✝ : List α ⊢ toList (ofList (head✝ :: tail✝)) = head✝ :: tail✝
[PROOFSTEP]
rfl
[GOAL]
case cons
α : Type u
head✝ : α
tail✝ : List α
⊢ toList (ofList (head✝ :: tail✝)) = head✝ :: tail✝
[PROOFSTEP]
simp only [DList.toList, DList.ofList, List.cons_append, List.append_nil]
[GOAL]
α : Type u
l : DList α
⊢ ofList (toList l) = l
[PROOFSTEP]
cases' l with app inv
[GOAL]
case mk
α : Type u
app : List α → List α
inv : ∀ (l : List α), app l = app [] ++ l
⊢ ofList (toList { apply := app, invariant := inv }) = { apply := app, invariant := inv }
[PROOFSTEP]
simp only [ofList, toList, mk.injEq]
[GOAL]
case mk
α : Type u
app : List α → List α
inv : ∀ (l : List α), app l = app [] ++ l
⊢ (fun x => app [] ++ x) = app
[PROOFSTEP]
funext x
[GOAL]
case mk.h
α : Type u
app : List α → List α
inv : ∀ (l : List α), app l = app [] ++ l
x : List α
⊢ app [] ++ x = app x
[PROOFSTEP]
rw [(inv x)]
[GOAL]
α : Type u
⊢ toList empty = []
[PROOFSTEP]
simp
[GOAL]
α : Type u
x : α
⊢ toList (singleton x) = [x]
[PROOFSTEP]
simp
[GOAL]
α : Type u
l₁ l₂ : DList α
⊢ toList (append l₁ l₂) = toList l₁ ++ toList l₂
[PROOFSTEP]
cases' l₁ with _ l₁_invariant
[GOAL]
case mk
α : Type u
l₂ : DList α
apply✝ : List α → List α
l₁_invariant : ∀ (l : List α), apply✝ l = apply✝ [] ++ l
⊢ toList (append { apply := apply✝, invariant := l₁_invariant } l₂) =
toList { apply := apply✝, invariant := l₁_invariant } ++ toList l₂
[PROOFSTEP]
cases' l₂
[GOAL]
case mk.mk
α : Type u
apply✝¹ : List α → List α
l₁_invariant : ∀ (l : List α), apply✝¹ l = apply✝¹ [] ++ l
apply✝ : List α → List α
invariant✝ : ∀ (l : List α), apply✝ l = apply✝ [] ++ l
⊢ toList (append { apply := apply✝¹, invariant := l₁_invariant } { apply := apply✝, invariant := invariant✝ }) =
toList { apply := apply✝¹, invariant := l₁_invariant } ++ toList { apply := apply✝, invariant := invariant✝ }
[PROOFSTEP]
simp
[GOAL]
case mk.mk
α : Type u
apply✝¹ : List α → List α
l₁_invariant : ∀ (l : List α), apply✝¹ l = apply✝¹ [] ++ l
apply✝ : List α → List α
invariant✝ : ∀ (l : List α), apply✝ l = apply✝ [] ++ l
⊢ apply✝¹ (apply✝ []) = apply✝¹ [] ++ apply✝ []
[PROOFSTEP]
rw [l₁_invariant]
[GOAL]
α : Type u
x : α
l : DList α
⊢ toList (cons x l) = x :: toList l
[PROOFSTEP]
cases l
[GOAL]
case mk
α : Type u
x : α
apply✝ : List α → List α
invariant✝ : ∀ (l : List α), apply✝ l = apply✝ [] ++ l
⊢ toList (cons x { apply := apply✝, invariant := invariant✝ }) =
x :: toList { apply := apply✝, invariant := invariant✝ }
[PROOFSTEP]
simp
[GOAL]
α : Type u
x : α
l : DList α
⊢ toList (push l x) = toList l ++ [x]
[PROOFSTEP]
cases' l with _ l_invariant
[GOAL]
case mk
α : Type u
x : α
apply✝ : List α → List α
l_invariant : ∀ (l : List α), apply✝ l = apply✝ [] ++ l
⊢ toList (push { apply := apply✝, invariant := l_invariant } x) =
toList { apply := apply✝, invariant := l_invariant } ++ [x]
[PROOFSTEP]
simp
[GOAL]
case mk
α : Type u
x : α
apply✝ : List α → List α
l_invariant : ∀ (l : List α), apply✝ l = apply✝ [] ++ l
⊢ apply✝ [x] = apply✝ [] ++ [x]
[PROOFSTEP]
rw [l_invariant]
|
/*
* @file
* @author University of Warwick
* @version 1.0
*
* @section LICENSE
*
* @section DESCRIPTION
*
* Unit Tests for the Benchmark class
*/
#define BOOST_TEST_MODULE Benchmark
#include <boost/test/unit_test.hpp>
#include <boost/test/output_test_stream.hpp>
#include <stdexcept>
#include "Benchmark.h"
#include "Communicator.h"
#include "Error.h"
using namespace cupcfd::benchmark;
// These tests require MPI
BOOST_AUTO_TEST_CASE(setup)
{
int argc = boost::unit_test::framework::master_test_suite().argc;
char ** argv = boost::unit_test::framework::master_test_suite().argv;
MPI_Init(&argc, &argv);
}
// === Constructor ===
// Test 1:
BOOST_AUTO_TEST_CASE(constructor_test1)
{
// Virtual Class....
}
// Finalize MPI
BOOST_AUTO_TEST_CASE(cleanup)
{
// Cleanup MPI Environment
MPI_Finalize();
}
|
# PROPOSAL TO CALCULATE WINDOW MEAN
# =================================
# =================================
# Idea: Get Data From all words in timespan, calculate, write back
# Steps
# Connect to DB
# Get all data from DB
# Reshape 1: make big table
# Calculation
# Plot Example Word "Flugzeug"
# Reshape II: make tall table (date, w_id, window_value)
# Write back into DB
# WRITE IN MySQL
# ==============
# overwrite Data in mysql in table "aliss15a_windows_of_r"
dbWriteTable(mydb, "aliss15a_windows_of_r", data_for_mysql, overwrite = TRUE, append=FALSE, row.names=FALSE, field.types=list(date="date", w_id="int (10)", window8="float"))
#das dauert jetzt lange wegen meiner internetverbindung
|
/-
Copyright (c) 2022 Oliver Nash. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Oliver Nash
! This file was ported from Lean 3 source module measure_theory.group.add_circle
! leanprover-community/mathlib commit f2ce6086713c78a7f880485f7917ea547a215982
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathbin.MeasureTheory.Integral.Periodic
import Mathbin.Data.Zmod.Quotient
/-!
# Measure-theoretic results about the additive circle
The file is a place to collect measure-theoretic results about the additive circle.
## Main definitions:
* `add_circle.closed_ball_ae_eq_ball`: open and closed balls in the additive circle are almost
equal
* `add_circle.is_add_fundamental_domain_of_ae_ball`: a ball is a fundamental domain for rational
angle rotation in the additive circle
-/
open Set Function Filter MeasureTheory MeasureTheory.Measure Metric
open MeasureTheory Pointwise BigOperators Topology ENNReal
namespace AddCircle
variable {T : ℝ} [hT : Fact (0 < T)]
include hT
theorem closedBall_ae_eq_ball {x : AddCircle T} {ε : ℝ} : closedBall x ε =ᵐ[volume] ball x ε :=
by
cases' le_or_lt ε 0 with hε hε
· rw [ball_eq_empty.mpr hε, ae_eq_empty, volume_closed_ball,
min_eq_right (by linarith [hT.out] : 2 * ε ≤ T), ENNReal.ofReal_eq_zero]
exact mul_nonpos_of_nonneg_of_nonpos zero_le_two hε
· suffices volume (closed_ball x ε) ≤ volume (ball x ε) by
exact
(ae_eq_of_subset_of_measure_ge ball_subset_closed_ball this measurableSet_ball
(measure_ne_top _ _)).symm
have : tendsto (fun δ => volume (closed_ball x δ)) (𝓝[<] ε) (𝓝 <| volume (closed_ball x ε)) :=
by
simp_rw [volume_closed_ball]
refine' ENNReal.tendsto_ofReal (tendsto.min tendsto_const_nhds <| tendsto.const_mul _ _)
convert(@monotone_id ℝ _).tendsto_nhdsWithin_Iio ε
simp
refine'
le_of_tendsto this (mem_nhds_within_Iio_iff_exists_Ioo_subset.mpr ⟨0, hε, fun r hr => _⟩)
exact measure_mono (closed_ball_subset_ball hr.2)
#align add_circle.closed_ball_ae_eq_ball AddCircle.closedBall_ae_eq_ball
/-- Let `G` be the subgroup of `add_circle T` generated by a point `u` of finite order `n : ℕ`. Then
any set `I` that is almost equal to a ball of radius `T / 2n` is a fundamental domain for the action
of `G` on `add_circle T` by left addition. -/
theorem isAddFundamentalDomainOfAeBall (I : Set <| AddCircle T) (u x : AddCircle T)
(hu : IsOfFinAddOrder u) (hI : I =ᵐ[volume] ball x (T / (2 * addOrderOf u))) :
IsAddFundamentalDomain (AddSubgroup.zmultiples u) I :=
by
set G := AddSubgroup.zmultiples u
set n := addOrderOf u
set B := ball x (T / (2 * n))
have hn : 1 ≤ (n : ℝ) := by
norm_cast
linarith [addOrderOf_pos' hu]
refine' is_add_fundamental_domain.mk_of_measure_univ_le _ _ _ _
·-- `null_measurable_set I volume`
exact measurable_set_ball.null_measurable_set.congr hI.symm
· -- `∀ (g : G), g ≠ 0 → ae_disjoint volume (g +ᵥ I) I`
rintro ⟨g, hg⟩ hg'
replace hg' : g ≠ 0
· simpa only [Ne.def, AddSubgroup.mk_eq_zero_iff] using hg'
change ae_disjoint volume (g +ᵥ I) I
refine'
ae_disjoint.congr (Disjoint.aeDisjoint _)
((quasi_measure_preserving_add_left volume (-g)).vadd_ae_eq_of_ae_eq g hI) hI
have hBg : g +ᵥ B = ball (g + x) (T / (2 * n)) := by
rw [add_comm g x, ← singleton_add_ball _ x g, add_ball, thickening_singleton]
rw [hBg]
apply ball_disjoint_ball
rw [dist_eq_norm, add_sub_cancel, div_mul_eq_div_div, ← add_div, ← add_div, add_self_div_two,
div_le_iff' (by positivity : 0 < (n : ℝ)), ← nsmul_eq_mul]
refine'
(le_add_order_smul_norm_of_is_of_fin_add_order (hu.of_mem_zmultiples hg) hg').trans
(nsmul_le_nsmul (norm_nonneg g) _)
exact Nat.le_of_dvd (add_order_of_pos_iff.mpr hu) (addOrderOf_dvd_of_mem_zmultiples hg)
·-- `∀ (g : G), quasi_measure_preserving (has_vadd.vadd g) volume volume`
exact fun g => quasi_measure_preserving_add_left volume g
· -- `volume univ ≤ ∑' (g : G), volume (g +ᵥ I)`
replace hI : I =ᵐ[volume] closed_ball x (T / (2 * ↑n)) := hI.trans closed_ball_ae_eq_ball.symm
haveI : Fintype G := @Fintype.ofFinite _ hu.finite_zmultiples
have hG_card : (Finset.univ : Finset G).card = n :=
by
show _ = addOrderOf u
rw [add_order_eq_card_zmultiples', Nat.card_eq_fintype_card]
rfl
simp_rw [measure_vadd]
rw [AddCircle.measure_univ, tsum_fintype, Finset.sum_const, measure_congr hI,
volume_closed_ball, ← ENNReal.ofReal_nsmul, mul_div, mul_div_mul_comm,
div_self (@two_ne_zero ℝ _ _ _ _), one_mul, min_eq_right (div_le_self hT.out.le hn), hG_card,
nsmul_eq_mul, mul_div_cancel' T (lt_of_lt_of_le zero_lt_one hn).Ne.symm]
exact le_refl _
#align add_circle.is_add_fundamental_domain_of_ae_ball AddCircle.isAddFundamentalDomainOfAeBall
theorem volume_of_add_preimage_eq (s I : Set <| AddCircle T) (u x : AddCircle T)
(hu : IsOfFinAddOrder u) (hs : (u +ᵥ s : Set <| AddCircle T) =ᵐ[volume] s)
(hI : I =ᵐ[volume] ball x (T / (2 * addOrderOf u))) :
volume s = addOrderOf u • volume (s ∩ I) :=
by
let G := AddSubgroup.zmultiples u
haveI : Fintype G := @Fintype.ofFinite _ hu.finite_zmultiples
have hsG : ∀ g : G, (g +ᵥ s : Set <| AddCircle T) =ᵐ[volume] s :=
by
rintro ⟨y, hy⟩
exact (vadd_ae_eq_self_of_mem_zmultiples hs hy : _)
rw [(is_add_fundamental_domain_of_ae_ball I u x hu hI).measure_eq_card_smul_of_vadd_ae_eq_self s
hsG,
add_order_eq_card_zmultiples' u, Nat.card_eq_fintype_card]
#align add_circle.volume_of_add_preimage_eq AddCircle.volume_of_add_preimage_eq
end AddCircle
|
Rebol [
Title: "Form Date"
Author: "Christopher Ross-Gill"
Date: 26-Apr-2007
Version: 1.0.2
File: %form-date.r
Rights: http://creativecommons.org/licenses/by-sa/3.0/
Purpose: {Return formatted date string using strftime style format specifiers}
Home: http://www.ross-gill.com/QM/
Comment: {Extracted from the QuarterMaster web framework}
History: [
1.0.2 03-Mar-2013 rgchris "Fixed leaked local words"
1.0.1 05-Feb-2013 rgchris "Minor update to padding/pairs for R3 compatability"
1.0.1 18-Jul-2007 btiffin "Obtained permission to add %c and %s precise seconds"
1.0.0 26-Apr-2007 btiffin "Obtained permission to prepare script for rebol.org library"
1.0.0 24-Apr-2007 rgchris "The original"
]
Notes: {
do http://reb4.me/r/form-date to include the form-date function in the global namespace
>> form-date now "%A %e%i %B, %Y at %T"
== "Thursday 26th April, 2007 at 00:44:12"
>> form-date now "%d-%b-%Y/%H:%M:%S%Z"
== "26-Apr-2007/00:49:39-04:00"
>> now
== 26-Apr-2007/0:52:13-4:00
>> form-date now/precise "%c"
== "19-Jul-2007/01:02:03.012000-04:00"
}
]
form-date: use [
get-class interpolate
pad pad-zone pad-precise to-epoch-time to-iso-week
date-codes
][
;--## SERIES HELPER
;-------------------------------------------------------------------##
get-class: func [classes [block!] item][
all [
classes: find classes item
classes: find/reverse classes type? pick head classes 1
first classes
]
]
;--## STRING HELPERS
;-------------------------------------------------------------------##
interpolate: func [body [string!] escapes [any-block!] /local out][
body: out: copy body
parse/all body [
any [
to #"%" body: (
body: change/part body reduce any [
select/case escapes body/2 body/2
] 2
) :body
]
]
out
]
pad: func [text length [integer!] /with padding [char!]][
padding: any [padding #"0"]
text: form text
skip tail insert/dup text padding length negate length
]
;--## DATE HELPERS
;-------------------------------------------------------------------##
pad-zone: func [time /flat][
rejoin [
pick "-+" time/hour < 0
pad abs time/hour 2
either flat [""][#":"]
pad time/minute 2
]
]
pad-precise: func [seconds [number!] /local out][
seconds: form round/to make time! seconds 1E-6 ; works so long as 0 <= seconds < 60
head change copy "00.000000" find/last/tail form seconds ":"
]
to-epoch-time: func [date [date!]][
; date/time: date/time - date/zone
date: form any [
attempt [to integer! difference date 1-Jan-1970/0:0:0]
date - 1-Jan-1970/0:0:0 * 86400.0
]
clear find/last date "."
date
]
to-iso-week: use [get-iso-year][
get-iso-year: func [year [integer!] /local d1 d2][
d1: to-date join "4-Jan-" year
d2: to-date join "28-Dec-" year
reduce [d1 + 1 - d1/weekday d2 + 7 - d2/weekday]
]
func [date [date!] /local out d1 d2][
out: 0x0
set [d1 d2] get-iso-year out/y: date/year
case [
date < d1 [d1: first get-iso-year out/y: date/year - 1]
date > d2 [d1: first get-iso-year out/y: date/year + 1]
]
out/x: date + 8 - date/weekday - d1 / 7
out
]
]
date-codes: [
#"a" [copy/part pick system/locale/days date/weekday 3]
#"A" [pick system/locale/days date/weekday]
#"b" [copy/part pick system/locale/months date/month 3]
#"B" [pick system/locale/months date/month]
#"C" [to-integer date/year / 100]
#"d" [pad date/day 2]
#"D" [date/year #"-" pad date/month 2 #"-" pad date/day 2]
#"e" [date/day]
#"g" [pad (to integer! second to-iso-week date) // 100 2]
#"G" [to integer! second to-iso-week date]
#"h" [time/hour + 11 // 12 + 1]
#"H" [pad time/hour 2]
#"i" [any [get-class ["st" 1 21 31 "nd" 2 22 "rd" 3 23] date/day "th"]]
#"I" [pad time/hour + 11 // 12 + 1 2]
#"j" [pad date/julian 3]
#"J" [date/julian]
#"m" [pad date/month 2]
#"M" [pad time/minute 2]
#"p" [pick ["am" "pm"] time/hour < 12]
#"P" [pick ["AM" "PM"] time/hour < 12]
#"R" [pad time/hour 2 #":" pad time/minute 2]
#"s" [to-epoch-time date]
#"S" [pad to integer! time/second 2]
#"t" [#"^-"]
#"T" [pad time/hour 2 #":" pad time/minute 2 #":" pad round time/second 2]
#"u" [date/weekday]
#"U" [pad to integer! date/julian + 6 - (date/weekday // 7) / 7 2]
#"V" [pad to integer! first to-iso-week date 2]
#"w" [date/weekday // 7]
#"W" [pad to integer! date/julian + 7 - date/weekday / 7 2]
#"y" [pad date/year // 100 2]
#"x" [pad-precise time/second]
#"Y" [date/year]
#"z" [pad-zone/flat zone]
#"Z" [pad-zone zone]
#"%" ["%"]
#"c" [
date/year #"-" pad date/month 2 "-" pad date/day 2 "T"
pad time/hour 2 #":" pad time/minute 2 #":" pad to integer! time/second 2
either gmt ["Z"][pad-zone zone]
]
]
func [
"Renders a date to a given format (largely compatible with strftime)"
date [date!] format [any-string!]
/gmt "Align time with GMT"
/local time zone nyd
][
bind date-codes 'date
all [
gmt date/time date/zone
date/time: date/time - date/zone
date/zone: none
]
time: any [date/time 0:00]
zone: any [date/zone 0:00]
interpolate format date-codes
]
]
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Code related to vector equality over propositional equality that
-- makes use of heterogeneous equality
------------------------------------------------------------------------
{-# OPTIONS --with-K --safe #-}
module Data.Vec.Relation.Binary.Equality.Propositional.WithK
{a} {A : Set a} where
open import Data.Vec
open import Data.Vec.Relation.Binary.Equality.Propositional {A = A}
open import Relation.Binary.PropositionalEquality
open import Relation.Binary.HeterogeneousEquality as H using (_≅_)
≋⇒≅ : ∀ {m n} {xs : Vec A m} {ys : Vec A n} →
xs ≋ ys → xs ≅ ys
≋⇒≅ p with length-equal p
... | refl = H.≡-to-≅ (≋⇒≡ p)
|
#pragma once
#ifndef _NOGSL
#include <gsl/gsl_vector.h>
#else
#include "CustomSolver.h"
#endif
#include "ValueGrad.h"
#include "BooleanNodes.h"
#include "BooleanDAG.h"
#include "NodeVisitor.h"
#include "VarStore.h"
#include <map>
#include "FloatSupport.h"
#include "SymbolicEvaluator.h"
#include <iostream>
using namespace std;
// AutoDiff through only the numerical structure - ignores all boolean structure
class IteAutoDiff: public NodeVisitor, public SymbolicEvaluator
{
FloatManager& floats;
BooleanDAG& bdag;
map<string, int> floatCtrls; // Maps float ctrl names to indices within grad vector
int nctrls; // number of float ctrls
gsl_vector* ctrls; // ctrl values
vector<ValueGrad*> values; // Keeps track of values along with gradients for each node
map<int, int> inputValues; // Maps node id to values set by the SAT solver
map<int, int> iteCtrls;
double error = 0.0;
gsl_vector* errorGrad;
int DEFAULT_INP = -1;
public:
IteAutoDiff(BooleanDAG& bdag_p, FloatManager& _floats, const map<string, int>& floatCtrls_p, const map<int, int>& iteCtrls_p);
~IteAutoDiff(void);
virtual void visit( SRC_node& node );
virtual void visit( DST_node& node );
virtual void visit( CTRL_node& node );
virtual void visit( PLUS_node& node );
virtual void visit( TIMES_node& node );
virtual void visit( ARRACC_node& node );
virtual void visit( DIV_node& node );
virtual void visit( MOD_node& node );
virtual void visit( NEG_node& node );
virtual void visit( CONST_node& node );
virtual void visit( LT_node& node );
virtual void visit( EQ_node& node );
virtual void visit( AND_node& node );
virtual void visit( OR_node& node );
virtual void visit( NOT_node& node );
virtual void visit( ARRASS_node& node );
virtual void visit( UFUN_node& node );
virtual void visit( TUPLE_R_node& node );
virtual void visit( ASSERT_node& node );
virtual void run(const gsl_vector* ctrls_p, const map<int, int>& inputValues_p);
virtual bool checkAll(const gsl_vector* ctrls_p, const map<int, int>& inputValues_p, bool onlyBool = false){
Assert(false, "NYI");
return true;
}
virtual bool check(bool_node* n, int expected);
virtual double computeError(bool_node* n, int expected, gsl_vector* errorGrad);
virtual double computeDist(bool_node*, gsl_vector* distgrad);
virtual bool hasDist(bool_node* n);
virtual double computeVal(bool_node*, gsl_vector* distgrad);
virtual bool hasVal(bool_node* n);
virtual bool hasSqrtDist(bool_node* n);
virtual double computeSqrtError(bool_node* n, gsl_vector* errorGrad);
virtual double computeSqrtDist(bool_node* n, gsl_vector* errorGrad);
virtual double getVal(bool_node* n);
virtual gsl_vector* getGrad(bool_node* n);
//virtual set<int> getConflicts(int nid);
void setvalue(bool_node& bn, ValueGrad* v) {
values[bn.id] = v;
}
ValueGrad* v(bool_node& bn) {
ValueGrad* val = values[bn.id];
if (val == NULL) {
gsl_vector* g = gsl_vector_alloc(nctrls);
val = new ValueGrad(0, g);
setvalue(bn, val);
}
return val;
}
ValueGrad* v(bool_node* bn) {
return v(*bn);
}
virtual void print() {
for (int i = 0; i < bdag.size(); i++) {
cout << bdag[i]->lprint() << " ";
ValueGrad* val = v(bdag[i]);
if (val->set) {
cout << val->print() << endl;
} else {
cout << "UNSET" << endl;
}
}
}
virtual void printFull() {
for (int i = 0; i < bdag.size(); i++) {
cout << bdag[i]->lprint() << endl;
ValueGrad* val = v(bdag[i]);
if (val->set) {
cout << val->printFull() << endl;
} else {
cout << "UNSET" << endl;
}
}
}
bool isFloat(bool_node& bn) {
return (bn.getOtype() == OutType::FLOAT);
}
bool isFloat(bool_node* bn) {
return (bn->getOtype() == OutType::FLOAT);
}
int getInputValue(bool_node& bn) {
if (inputValues.find(bn.id) != inputValues.end()) {
int val = inputValues[bn.id];
//Assert(val == 0 || val == 1, "NYI: Integer values");
return val;
} else {
return DEFAULT_INP;
}
}
int getInputValue(bool_node* bn) {
return getInputValue(*bn);
}
};
|
#=
This file tests the save and load feature of the Mapper.
=#
@testset "Testing Save/Load" begin
# Create two maps that are the same
m = place!(Example1.make_map(); move_attempts = 5000)
sm = Mapper2.SAStruct(m)
# Place struct sm
Mapper2.SA.place!(sm; move_attempts = 5000)
# Record the placed sm into map m
Mapper2.SA.record(m, sm)
route!(m)
# Save the placement
save(m, "tests")
##################################
# Now create a new testmap.
##################################
n = Example1.make_map()
# Load the placement into "n"
load(n, "tests")
# Create a SA struct for the new map.
sn = Mapper2.SAStruct(n)
# Preplace "n" into "sn"
Mapper2.SA.preplace(n, sn)
# Assert the two costs are the same.
@test Mapper2.SA.map_cost(sn) == Mapper2.SA.map_cost(sm)
# Get the link histograms for the two maps. Make sure they match
lm = MapperCore.global_link_histogram(m)
ln = MapperCore.global_link_histogram(n)
@test lm == ln
rm("tests.jls")
end
|
#define PIPL_PLUGIN_NAME "FixBlack"
#include "Plugin.r" |
% Figure 3.40 Feedback Control of Dynamic Systems, 6e
% Franklin, Powell, Emami
% script to generate Fig. 3.40
fh=@(ki,k) 6+3*k-ki;
ezplot(fh)
hold on;
f=@(ki,k) ki;
ezplot(f);
% add shading
fillvert = [0, -2
0, 7
7, 7
7, 0];
fcolor = [ .1 .1 .1 .1];
patch(fillvert(:,1)', fillvert(:,2)', fcolor)
xlabel('K_I');
ylabel('K');
title('Allowable region for stability');
nicegrid;
hold off
|
PROGRAM BOO
CALL FOO()
END
|
If $p$ is a polynomial over a Euclidean domain $R$, then $p$ has a unique factorization into irreducible polynomials. |
function res = read(varargin)
opts.scoresroot = fullfile(hb_path, 'scores_new');
opts = vl_argparse(opts, varargin);
scoresroot = opts.scoresroot;
dirs = utls.listdirs(scoresroot);
res.verification = cell(1, numel(dirs));
res.matching = cell(1, numel(dirs));
res.retrieval = cell(1, numel(dirs));
for resi = 1:numel(dirs)
res.verification{resi} = readtable(fullfile(scoresroot, dirs{resi}, 'verification.csv'));
res.matching{resi} = readtable(fullfile(scoresroot, dirs{resi}, 'matching.csv'));
res.retrieval{resi} = readtable(fullfile(scoresroot, dirs{resi}, 'retrieval.csv'));
end
res.verification = vertcat(res.verification{:});
res.matching = vertcat(res.matching{:});
res.retrieval = vertcat(res.retrieval{:});
end
|
The Water Margin ( c . 1400 ) is a Ming Dynasty military romance about one hundred and eight demons @-@ born @-@ men and women who band together to rebel against the lavish Song Dynasty government . Lin Chong and Lu Junyi , two of these outlaws , are briefly mentioned as being Zhou 's previous students in The Story of Yue Fei . They are not characters within the main plot , though , as both are killed by " villainous officials " prior to Zhou becoming precept of the Wang household . Most importantly , the two were not among his historical students since they are fictional characters .
|
(* Title: IND_CPA.thy
Author: Andreas Lochbihler, ETH Zurich *)
theory IND_CPA imports
CryptHOL.Generative_Probabilistic_Value
CryptHOL.Computational_Model
CryptHOL.Negligible
begin
subsection \<open>The IND-CPA game for symmetric encryption schemes\<close>
locale ind_cpa =
fixes key_gen :: "'key spmf" \<comment> \<open>probabilistic\<close>
and encrypt :: "'key \<Rightarrow> 'plain \<Rightarrow> 'cipher spmf" \<comment> \<open>probabilistic\<close>
and decrypt :: "'key \<Rightarrow> 'cipher \<Rightarrow> 'plain option" \<comment> \<open>deterministic, but not used\<close>
and valid_plain :: "'plain \<Rightarrow> bool" \<comment> \<open>checks whether a plain text is valid, i.e., has the right format\<close>
begin
text \<open>
We cannot incorporate the predicate @{term valid_plain} in the type @{typ "'plain"} of plaintexts,
because the single @{typ "'plain"} must contain plaintexts for all values of the security parameter,
as HOL does not have dependent types. Consequently, the oracle has to ensure that the received
plaintexts are valid.
\<close>
type_synonym ('plain', 'cipher', 'state) adversary =
"(('plain' \<times> 'plain') \<times> 'state, 'plain', 'cipher') gpv
\<times> ('cipher' \<Rightarrow> 'state \<Rightarrow> (bool, 'plain', 'cipher') gpv)"
definition encrypt_oracle :: "'key \<Rightarrow> unit \<Rightarrow> 'plain \<Rightarrow> ('cipher \<times> unit) spmf"
where
"encrypt_oracle key \<sigma> plain = do {
cipher \<leftarrow> encrypt key plain;
return_spmf (cipher, ())
}"
definition ind_cpa :: "('plain, 'cipher, 'state) adversary \<Rightarrow> bool spmf"
where
"ind_cpa \<A> = do {
let (\<A>1, \<A>2) = \<A>;
key \<leftarrow> key_gen;
b \<leftarrow> coin_spmf;
(guess, _) \<leftarrow> exec_gpv (encrypt_oracle key) (do {
((m0, m1), \<sigma>) \<leftarrow> \<A>1;
if valid_plain m0 \<and> valid_plain m1 then do {
cipher \<leftarrow> lift_spmf (encrypt key (if b then m0 else m1));
\<A>2 cipher \<sigma>
} else lift_spmf coin_spmf
}) ();
return_spmf (guess = b)
}"
definition advantage :: "('plain, 'cipher, 'state) adversary \<Rightarrow> real"
where "advantage \<A> = \<bar>spmf (ind_cpa \<A>) True - 1/2\<bar>"
lemma advantage_nonneg: "advantage \<A> \<ge> 0" by(simp add: advantage_def)
definition ibounded_by :: "('plain, 'cipher, 'state) adversary \<Rightarrow> enat \<Rightarrow> bool"
where
"ibounded_by = (\<lambda>(\<A>1, \<A>2) q.
(\<exists>q1 q2. interaction_any_bounded_by \<A>1 q1 \<and> (\<forall>cipher \<sigma>. interaction_any_bounded_by (\<A>2 cipher \<sigma>) q2) \<and> q1 + q2 \<le> q))"
lemma ibounded_byE [consumes 1, case_names ibounded_by, elim?]:
assumes "ibounded_by (\<A>1, \<A>2) q"
obtains q1 q2
where "q1 + q2 \<le> q"
and "interaction_any_bounded_by \<A>1 q1"
and "\<And>cipher \<sigma>. interaction_any_bounded_by (\<A>2 cipher \<sigma>) q2"
using assms by(auto simp add: ibounded_by_def)
lemma ibounded_byI [intro?]:
"\<lbrakk> interaction_any_bounded_by \<A>1 q1; \<And>cipher \<sigma>. interaction_any_bounded_by (\<A>2 cipher \<sigma>) q2; q1 + q2 \<le> q \<rbrakk>
\<Longrightarrow> ibounded_by (\<A>1, \<A>2) q"
by(auto simp add: ibounded_by_def)
definition lossless :: "('plain, 'cipher, 'state) adversary \<Rightarrow> bool"
where "lossless = (\<lambda>(\<A>1, \<A>2). lossless_gpv \<I>_full \<A>1 \<and> (\<forall>cipher \<sigma>. lossless_gpv \<I>_full (\<A>2 cipher \<sigma>)))"
end
end
|
% (this is just an interface)
function varargout = mydatesod_inv (varargin)
[varargout{1:nargout}] = mydatesodi (varargin{:});
end
%!test
%! % just check whether it runs:
%! mydatesod_inv(1, 2);
|
F01CKJ Example Program Results
Matrix A
5.0 8.0
8.0 14.0
|
/-
Copyright (c) 2019 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Sébastien Gouëzel, Rémy Degenne
-/
import analysis.convex.specific_functions
import analysis.special_functions.pow
import data.real.conjugate_exponents
import tactic.nth_rewrite
import measure_theory.integration
/-!
# Mean value inequalities
In this file we prove several inequalities, including AM-GM inequality, Young's inequality,
Hölder inequality, and Minkowski inequality.
## Main theorems
### AM-GM inequality:
The inequality says that the geometric mean of a tuple of non-negative numbers is less than or equal
to their arithmetic mean. We prove the weighted version of this inequality: if $w$ and $z$
are two non-negative vectors and $\sum_{i\in s} w_i=1$, then
$$
\prod_{i\in s} z_i^{w_i} ≤ \sum_{i\in s} w_iz_i.
$$
The classical version is a special case of this inequality for $w_i=\frac{1}{n}$.
We prove a few versions of this inequality. Each of the following lemmas comes in two versions:
a version for real-valued non-negative functions is in the `real` namespace, and a version for
`nnreal`-valued functions is in the `nnreal` namespace.
- `geom_mean_le_arith_mean_weighted` : weighted version for functions on `finset`s;
- `geom_mean_le_arith_mean2_weighted` : weighted version for two numbers;
- `geom_mean_le_arith_mean3_weighted` : weighted version for three numbers;
- `geom_mean_le_arith_mean4_weighted` : weighted version for four numbers.
### Generalized mean inequality
The inequality says that for two non-negative vectors $w$ and $z$ with $\sum_{i\in s} w_i=1$
and $p ≤ q$ we have
$$
\sqrt[p]{\sum_{i\in s} w_i z_i^p} ≤ \sqrt[q]{\sum_{i\in s} w_i z_i^q}.
$$
Currently we only prove this inequality for $p=1$. As in the rest of `mathlib`, we provide
different theorems for natural exponents (`pow_arith_mean_le_arith_mean_pow`), integer exponents
(`fpow_arith_mean_le_arith_mean_fpow`), and real exponents (`rpow_arith_mean_le_arith_mean_rpow` and
`arith_mean_le_rpow_mean`). In the first two cases we prove
$$
\left(\sum_{i\in s} w_i z_i\right)^n ≤ \sum_{i\in s} w_i z_i^n
$$
in order to avoid using real exponents. For real exponents we prove both this and standard versions.
### Young's inequality
Young's inequality says that for non-negative numbers `a`, `b`, `p`, `q` such that
$\frac{1}{p}+\frac{1}{q}=1$ we have
$$
ab ≤ \frac{a^p}{p} + \frac{b^q}{q}.
$$
This inequality is a special case of the AM-GM inequality. It can be used to prove Hölder's
inequality (see below) but we use a different proof.
### Hölder's inequality
The inequality says that for two conjugate exponents `p` and `q` (i.e., for two positive numbers
such that $\frac{1}{p}+\frac{1}{q}=1$) and any two non-negative vectors their inner product is
less than or equal to the product of the $L_p$ norm of the first vector and the $L_q$ norm of the
second vector:
$$
\sum_{i\in s} a_ib_i ≤ \sqrt[p]{\sum_{i\in s} a_i^p}\sqrt[q]{\sum_{i\in s} b_i^q}.
$$
We give versions of this result in `ℝ`, `ℝ≥0` and `ℝ≥0∞`.
There are at least two short proofs of this inequality. In one proof we prenormalize both vectors,
then apply Young's inequality to each $a_ib_i$. We use a different proof deducing this inequality
from the generalized mean inequality for well-chosen vectors and weights.
Hölder's inequality for the Lebesgue integral of `ℝ≥0∞` and `ℝ≥0` functions: we prove
`∫ (f * g) ∂μ ≤ (∫ f^p ∂μ) ^ (1/p) * (∫ g^q ∂μ) ^ (1/q)` for `p`, `q` conjugate real exponents
and `α→(e)nnreal` functions in two cases,
* `ennreal.lintegral_mul_le_Lp_mul_Lq` : ℝ≥0∞ functions,
* `nnreal.lintegral_mul_le_Lp_mul_Lq` : ℝ≥0 functions.
### Minkowski's inequality
The inequality says that for `p ≥ 1` the function
$$
\|a\|_p=\sqrt[p]{\sum_{i\in s} a_i^p}
$$
satisfies the triangle inequality $\|a+b\|_p\le \|a\|_p+\|b\|_p$.
We give versions of this result in `real`, `ℝ≥0` and `ℝ≥0∞`.
We deduce this inequality from Hölder's inequality. Namely, Hölder inequality implies that $\|a\|_p$
is the maximum of the inner product $\sum_{i\in s}a_ib_i$ over `b` such that $\|b\|_q\le 1$. Now
Minkowski's inequality follows from the fact that the maximum value of the sum of two functions is
less than or equal to the sum of the maximum values of the summands.
Minkowski's inequality for the Lebesgue integral of measurable functions with `ℝ≥0∞` values:
we prove `(∫ (f + g)^p ∂μ) ^ (1/p) ≤ (∫ f^p ∂μ) ^ (1/p) + (∫ g^p ∂μ) ^ (1/p)` for `1 ≤ p`.
## TODO
- each inequality `A ≤ B` should come with a theorem `A = B ↔ _`; one of the ways to prove them
is to define `strict_convex_on` functions.
- generalized mean inequality with any `p ≤ q`, including negative numbers;
- prove that the power mean tends to the geometric mean as the exponent tends to zero.
- prove integral versions of these inequalities.
-/
universes u v
open finset
open_locale classical big_operators nnreal ennreal
noncomputable theory
variables {ι : Type u} (s : finset ι)
namespace real
/-- AM-GM inequality: the geometric mean is less than or equal to the arithmetic mean, weighted
version for real-valued nonnegative functions. -/
theorem geom_mean_le_arith_mean_weighted (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i in s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) :
(∏ i in s, (z i) ^ (w i)) ≤ ∑ i in s, w i * z i :=
begin
-- If some number `z i` equals zero and has non-zero weight, then LHS is 0 and RHS is nonnegative.
by_cases A : ∃ i ∈ s, z i = 0 ∧ w i ≠ 0,
{ rcases A with ⟨i, his, hzi, hwi⟩,
rw [prod_eq_zero his],
{ exact sum_nonneg (λ j hj, mul_nonneg (hw j hj) (hz j hj)) },
{ rw hzi, exact zero_rpow hwi } },
-- If all numbers `z i` with non-zero weight are positive, then we apply Jensen's inequality
-- for `exp` and numbers `log (z i)` with weights `w i`.
{ simp only [not_exists, not_and, ne.def, not_not] at A,
have := convex_on_exp.map_sum_le hw hw' (λ i _, set.mem_univ $ log (z i)),
simp only [exp_sum, (∘), smul_eq_mul, mul_comm (w _) (log _)] at this,
convert this using 1; [apply prod_congr rfl, apply sum_congr rfl]; intros i hi,
{ cases eq_or_lt_of_le (hz i hi) with hz hz,
{ simp [A i hi hz.symm] },
{ exact rpow_def_of_pos hz _ } },
{ cases eq_or_lt_of_le (hz i hi) with hz hz,
{ simp [A i hi hz.symm] },
{ rw [exp_log hz] } } }
end
theorem pow_arith_mean_le_arith_mean_pow (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i in s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) (n : ℕ) :
(∑ i in s, w i * z i) ^ n ≤ ∑ i in s, (w i * z i ^ n) :=
(convex_on_pow n).map_sum_le hw hw' hz
theorem pow_arith_mean_le_arith_mean_pow_of_even (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i in s, w i = 1) {n : ℕ} (hn : even n) :
(∑ i in s, w i * z i) ^ n ≤ ∑ i in s, (w i * z i ^ n) :=
(convex_on_pow_of_even hn).map_sum_le hw hw' (λ _ _, trivial)
theorem fpow_arith_mean_le_arith_mean_fpow (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i in s, w i = 1) (hz : ∀ i ∈ s, 0 < z i) (m : ℤ) :
(∑ i in s, w i * z i) ^ m ≤ ∑ i in s, (w i * z i ^ m) :=
(convex_on_fpow m).map_sum_le hw hw' hz
theorem rpow_arith_mean_le_arith_mean_rpow (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i in s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) {p : ℝ} (hp : 1 ≤ p) :
(∑ i in s, w i * z i) ^ p ≤ ∑ i in s, (w i * z i ^ p) :=
(convex_on_rpow hp).map_sum_le hw hw' hz
theorem arith_mean_le_rpow_mean (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i in s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) {p : ℝ} (hp : 1 ≤ p) :
∑ i in s, w i * z i ≤ (∑ i in s, (w i * z i ^ p)) ^ (1 / p) :=
begin
have : 0 < p := lt_of_lt_of_le zero_lt_one hp,
rw [← rpow_le_rpow_iff _ _ this, ← rpow_mul, one_div_mul_cancel (ne_of_gt this), rpow_one],
exact rpow_arith_mean_le_arith_mean_rpow s w z hw hw' hz hp,
all_goals { apply_rules [sum_nonneg, rpow_nonneg_of_nonneg],
intros i hi,
apply_rules [mul_nonneg, rpow_nonneg_of_nonneg, hw i hi, hz i hi] },
end
end real
namespace nnreal
/-- The geometric mean is less than or equal to the arithmetic mean, weighted version
for `nnreal`-valued functions. -/
theorem geom_mean_le_arith_mean_weighted (w z : ι → ℝ≥0) (hw' : ∑ i in s, w i = 1) :
(∏ i in s, (z i) ^ (w i:ℝ)) ≤ ∑ i in s, w i * z i :=
by exact_mod_cast real.geom_mean_le_arith_mean_weighted _ _ _ (λ i _, (w i).coe_nonneg)
(by assumption_mod_cast) (λ i _, (z i).coe_nonneg)
/-- The geometric mean is less than or equal to the arithmetic mean, weighted version
for two `nnreal` numbers. -/
theorem geom_mean_le_arith_mean2_weighted (w₁ w₂ p₁ p₂ : ℝ≥0) :
w₁ + w₂ = 1 → p₁ ^ (w₁:ℝ) * p₂ ^ (w₂:ℝ) ≤ w₁ * p₁ + w₂ * p₂ :=
by simpa only [fin.prod_univ_succ, fin.sum_univ_succ, fin.prod_univ_zero, fin.sum_univ_zero,
fin.cons_succ, fin.cons_zero, add_zero, mul_one]
using geom_mean_le_arith_mean_weighted (univ : finset (fin 2))
(fin.cons w₁ $ fin.cons w₂ fin_zero_elim) (fin.cons p₁ $ fin.cons p₂ $ fin_zero_elim)
theorem geom_mean_le_arith_mean3_weighted (w₁ w₂ w₃ p₁ p₂ p₃ : ℝ≥0) :
w₁ + w₂ + w₃ = 1 → p₁ ^ (w₁:ℝ) * p₂ ^ (w₂:ℝ) * p₃ ^ (w₃:ℝ) ≤ w₁ * p₁ + w₂ * p₂ + w₃ * p₃ :=
by simpa only [fin.prod_univ_succ, fin.sum_univ_succ, fin.prod_univ_zero, fin.sum_univ_zero,
fin.cons_succ, fin.cons_zero, add_zero, mul_one, ← add_assoc, mul_assoc]
using geom_mean_le_arith_mean_weighted (univ : finset (fin 3))
(fin.cons w₁ $ fin.cons w₂ $ fin.cons w₃ fin_zero_elim)
(fin.cons p₁ $ fin.cons p₂ $ fin.cons p₃ fin_zero_elim)
theorem geom_mean_le_arith_mean4_weighted (w₁ w₂ w₃ w₄ p₁ p₂ p₃ p₄ : ℝ≥0) :
w₁ + w₂ + w₃ + w₄ = 1 → p₁ ^ (w₁:ℝ) * p₂ ^ (w₂:ℝ) * p₃ ^ (w₃:ℝ)* p₄ ^ (w₄:ℝ) ≤
w₁ * p₁ + w₂ * p₂ + w₃ * p₃ + w₄ * p₄ :=
by simpa only [fin.prod_univ_succ, fin.sum_univ_succ, fin.prod_univ_zero, fin.sum_univ_zero,
fin.cons_succ, fin.cons_zero, add_zero, mul_one, ← add_assoc, mul_assoc]
using geom_mean_le_arith_mean_weighted (univ : finset (fin 4))
(fin.cons w₁ $ fin.cons w₂ $ fin.cons w₃ $ fin.cons w₄ fin_zero_elim)
(fin.cons p₁ $ fin.cons p₂ $ fin.cons p₃ $ fin.cons p₄ fin_zero_elim)
/-- Weighted generalized mean inequality, version sums over finite sets, with `ℝ≥0`-valued
functions and natural exponent. -/
theorem pow_arith_mean_le_arith_mean_pow (w z : ι → ℝ≥0) (hw' : ∑ i in s, w i = 1) (n : ℕ) :
(∑ i in s, w i * z i) ^ n ≤ ∑ i in s, (w i * z i ^ n) :=
by exact_mod_cast real.pow_arith_mean_le_arith_mean_pow s _ _ (λ i _, (w i).coe_nonneg)
(by exact_mod_cast hw') (λ i _, (z i).coe_nonneg) n
/-- Weighted generalized mean inequality, version for sums over finite sets, with `ℝ≥0`-valued
functions and real exponents. -/
theorem rpow_arith_mean_le_arith_mean_rpow (w z : ι → ℝ≥0) (hw' : ∑ i in s, w i = 1) {p : ℝ}
(hp : 1 ≤ p) :
(∑ i in s, w i * z i) ^ p ≤ ∑ i in s, (w i * z i ^ p) :=
by exact_mod_cast real.rpow_arith_mean_le_arith_mean_rpow s _ _ (λ i _, (w i).coe_nonneg)
(by exact_mod_cast hw') (λ i _, (z i).coe_nonneg) hp
/-- Weighted generalized mean inequality, version for two elements of `ℝ≥0` and real exponents. -/
theorem rpow_arith_mean_le_arith_mean2_rpow (w₁ w₂ z₁ z₂ : ℝ≥0) (hw' : w₁ + w₂ = 1) {p : ℝ}
(hp : 1 ≤ p) :
(w₁ * z₁ + w₂ * z₂) ^ p ≤ w₁ * z₁ ^ p + w₂ * z₂ ^ p :=
begin
have h := rpow_arith_mean_le_arith_mean_rpow (univ : finset (fin 2))
(fin.cons w₁ $ fin.cons w₂ fin_zero_elim) (fin.cons z₁ $ fin.cons z₂ $ fin_zero_elim) _ hp,
{ simpa [fin.sum_univ_succ, fin.sum_univ_zero, fin.cons_succ, fin.cons_zero] using h, },
{ simp [hw', fin.sum_univ_succ, fin.sum_univ_zero, fin.cons_succ, fin.cons_zero], },
end
/-- Weighted generalized mean inequality, version for sums over finite sets, with `ℝ≥0`-valued
functions and real exponents. -/
theorem arith_mean_le_rpow_mean (w z : ι → ℝ≥0) (hw' : ∑ i in s, w i = 1) {p : ℝ}
(hp : 1 ≤ p) :
∑ i in s, w i * z i ≤ (∑ i in s, (w i * z i ^ p)) ^ (1 / p) :=
by exact_mod_cast real.arith_mean_le_rpow_mean s _ _ (λ i _, (w i).coe_nonneg)
(by exact_mod_cast hw') (λ i _, (z i).coe_nonneg) hp
end nnreal
namespace ennreal
/-- Weighted generalized mean inequality, version for sums over finite sets, with `ℝ≥0∞`-valued
functions and real exponents. -/
theorem rpow_arith_mean_le_arith_mean_rpow (w z : ι → ℝ≥0∞) (hw' : ∑ i in s, w i = 1) {p : ℝ}
(hp : 1 ≤ p) :
(∑ i in s, w i * z i) ^ p ≤ ∑ i in s, (w i * z i ^ p) :=
begin
have hp_pos : 0 < p, from lt_of_lt_of_le zero_lt_one hp,
have hp_nonneg : 0 ≤ p, from le_of_lt hp_pos,
have hp_not_nonpos : ¬ p ≤ 0, by simp [hp_pos],
have hp_not_neg : ¬ p < 0, by simp [hp_nonneg],
have h_top_iff_rpow_top : ∀ (i : ι) (hi : i ∈ s), w i * z i = ⊤ ↔ w i * (z i) ^ p = ⊤,
by simp [hp_pos, hp_nonneg, hp_not_nonpos, hp_not_neg],
refine le_of_top_imp_top_of_to_nnreal_le _ _,
{ -- first, prove `(∑ i in s, w i * z i) ^ p = ⊤ → ∑ i in s, (w i * z i ^ p) = ⊤`
rw [rpow_eq_top_iff, sum_eq_top_iff, sum_eq_top_iff],
intro h,
simp only [and_false, hp_not_neg, false_or] at h,
rcases h.left with ⟨a, H, ha⟩,
use [a, H],
rwa ←h_top_iff_rpow_top a H, },
{ -- second, suppose both `(∑ i in s, w i * z i) ^ p ≠ ⊤` and `∑ i in s, (w i * z i ^ p) ≠ ⊤`,
-- and prove `((∑ i in s, w i * z i) ^ p).to_nnreal ≤ (∑ i in s, (w i * z i ^ p)).to_nnreal`,
-- by using `nnreal.rpow_arith_mean_le_arith_mean_rpow`.
intros h_top_rpow_sum _,
-- show hypotheses needed to put the `.to_nnreal` inside the sums.
have h_top : ∀ (a : ι), a ∈ s → w a * z a < ⊤,
{ have h_top_sum : ∑ (i : ι) in s, w i * z i < ⊤,
{ by_contra h,
rw [lt_top_iff_ne_top, not_not] at h,
rw [h, top_rpow_of_pos hp_pos] at h_top_rpow_sum,
exact h_top_rpow_sum rfl, },
rwa sum_lt_top_iff at h_top_sum, },
have h_top_rpow : ∀ (a : ι), a ∈ s → w a * z a ^ p < ⊤,
{ intros i hi,
specialize h_top i hi,
rw lt_top_iff_ne_top at h_top ⊢,
rwa [ne.def, ←h_top_iff_rpow_top i hi], },
-- put the `.to_nnreal` inside the sums.
simp_rw [to_nnreal_sum h_top_rpow, ←to_nnreal_rpow, to_nnreal_sum h_top, to_nnreal_mul,
←to_nnreal_rpow],
-- use corresponding nnreal result
refine nnreal.rpow_arith_mean_le_arith_mean_rpow s (λ i, (w i).to_nnreal) (λ i, (z i).to_nnreal)
_ hp,
-- verify the hypothesis `∑ i in s, (w i).to_nnreal = 1`, using `∑ i in s, w i = 1` .
have h_sum_nnreal : (∑ i in s, w i) = ↑(∑ i in s, (w i).to_nnreal),
{ have hw_top : ∑ i in s, w i < ⊤, by { rw hw', exact one_lt_top, },
rw ←to_nnreal_sum,
{ rw coe_to_nnreal,
rwa ←lt_top_iff_ne_top, },
{ rwa sum_lt_top_iff at hw_top, }, },
rwa [←coe_eq_coe, ←h_sum_nnreal], },
end
/-- Weighted generalized mean inequality, version for two elements of `ℝ≥0∞` and real
exponents. -/
theorem rpow_arith_mean_le_arith_mean2_rpow (w₁ w₂ z₁ z₂ : ℝ≥0∞) (hw' : w₁ + w₂ = 1) {p : ℝ}
(hp : 1 ≤ p) :
(w₁ * z₁ + w₂ * z₂) ^ p ≤ w₁ * z₁ ^ p + w₂ * z₂ ^ p :=
begin
have h := rpow_arith_mean_le_arith_mean_rpow (univ : finset (fin 2))
(fin.cons w₁ $ fin.cons w₂ fin_zero_elim) (fin.cons z₁ $ fin.cons z₂ $ fin_zero_elim) _ hp,
{ simpa [fin.sum_univ_succ, fin.sum_univ_zero, fin.cons_succ, fin.cons_zero] using h, },
{ simp [hw', fin.sum_univ_succ, fin.sum_univ_zero, fin.cons_succ, fin.cons_zero], },
end
end ennreal
namespace real
theorem geom_mean_le_arith_mean2_weighted {w₁ w₂ p₁ p₂ : ℝ} (hw₁ : 0 ≤ w₁) (hw₂ : 0 ≤ w₂)
(hp₁ : 0 ≤ p₁) (hp₂ : 0 ≤ p₂) (hw : w₁ + w₂ = 1) :
p₁ ^ w₁ * p₂ ^ w₂ ≤ w₁ * p₁ + w₂ * p₂ :=
nnreal.geom_mean_le_arith_mean2_weighted ⟨w₁, hw₁⟩ ⟨w₂, hw₂⟩ ⟨p₁, hp₁⟩ ⟨p₂, hp₂⟩ $
nnreal.coe_eq.1 $ by assumption
theorem geom_mean_le_arith_mean3_weighted {w₁ w₂ w₃ p₁ p₂ p₃ : ℝ} (hw₁ : 0 ≤ w₁) (hw₂ : 0 ≤ w₂)
(hw₃ : 0 ≤ w₃) (hp₁ : 0 ≤ p₁) (hp₂ : 0 ≤ p₂) (hp₃ : 0 ≤ p₃) (hw : w₁ + w₂ + w₃ = 1) :
p₁ ^ w₁ * p₂ ^ w₂ * p₃ ^ w₃ ≤ w₁ * p₁ + w₂ * p₂ + w₃ * p₃ :=
nnreal.geom_mean_le_arith_mean3_weighted
⟨w₁, hw₁⟩ ⟨w₂, hw₂⟩ ⟨w₃, hw₃⟩ ⟨p₁, hp₁⟩ ⟨p₂, hp₂⟩ ⟨p₃, hp₃⟩ $ nnreal.coe_eq.1 hw
theorem geom_mean_le_arith_mean4_weighted {w₁ w₂ w₃ w₄ p₁ p₂ p₃ p₄ : ℝ} (hw₁ : 0 ≤ w₁)
(hw₂ : 0 ≤ w₂) (hw₃ : 0 ≤ w₃) (hw₄ : 0 ≤ w₄) (hp₁ : 0 ≤ p₁) (hp₂ : 0 ≤ p₂) (hp₃ : 0 ≤ p₃)
(hp₄ : 0 ≤ p₄) (hw : w₁ + w₂ + w₃ + w₄ = 1) :
p₁ ^ w₁ * p₂ ^ w₂ * p₃ ^ w₃ * p₄ ^ w₄ ≤ w₁ * p₁ + w₂ * p₂ + w₃ * p₃ + w₄ * p₄ :=
nnreal.geom_mean_le_arith_mean4_weighted ⟨w₁, hw₁⟩ ⟨w₂, hw₂⟩ ⟨w₃, hw₃⟩ ⟨w₄, hw₄⟩
⟨p₁, hp₁⟩ ⟨p₂, hp₂⟩ ⟨p₃, hp₃⟩ ⟨p₄, hp₄⟩ $ nnreal.coe_eq.1 $ by assumption
/-- Young's inequality, a version for nonnegative real numbers. -/
theorem young_inequality_of_nonneg {a b p q : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b)
(hpq : p.is_conjugate_exponent q) :
a * b ≤ a^p / p + b^q / q :=
by simpa [← rpow_mul, ha, hb, hpq.ne_zero, hpq.symm.ne_zero, div_eq_inv_mul]
using geom_mean_le_arith_mean2_weighted hpq.one_div_nonneg hpq.symm.one_div_nonneg
(rpow_nonneg_of_nonneg ha p) (rpow_nonneg_of_nonneg hb q) hpq.inv_add_inv_conj
/-- Young's inequality, a version for arbitrary real numbers. -/
theorem young_inequality (a b : ℝ) {p q : ℝ} (hpq : p.is_conjugate_exponent q) :
a * b ≤ (abs a)^p / p + (abs b)^q / q :=
calc a * b ≤ abs (a * b) : le_abs_self (a * b)
... = abs a * abs b : abs_mul a b
... ≤ (abs a)^p / p + (abs b)^q / q :
real.young_inequality_of_nonneg (abs_nonneg a) (abs_nonneg b) hpq
end real
namespace nnreal
/-- Young's inequality, `ℝ≥0` version. We use `{p q : ℝ≥0}` in order to avoid constructing
witnesses of `0 ≤ p` and `0 ≤ q` for the denominators. -/
theorem young_inequality (a b : ℝ≥0) {p q : ℝ≥0} (hp : 1 < p) (hpq : 1 / p + 1 / q = 1) :
a * b ≤ a^(p:ℝ) / p + b^(q:ℝ) / q :=
real.young_inequality_of_nonneg a.coe_nonneg b.coe_nonneg ⟨hp, nnreal.coe_eq.2 hpq⟩
/-- Young's inequality, `ℝ≥0` version with real conjugate exponents. -/
theorem young_inequality_real (a b : ℝ≥0) {p q : ℝ} (hpq : p.is_conjugate_exponent q) :
a * b ≤ a ^ p / nnreal.of_real p + b ^ q / nnreal.of_real q :=
begin
nth_rewrite 0 ←coe_of_real p hpq.nonneg,
nth_rewrite 0 ←coe_of_real q hpq.symm.nonneg,
exact young_inequality a b hpq.one_lt_nnreal hpq.inv_add_inv_conj_nnreal,
end
/-- Hölder inequality: the scalar product of two functions is bounded by the product of their
`L^p` and `L^q` norms when `p` and `q` are conjugate exponents. Version for sums over finite sets,
with `ℝ≥0`-valued functions. -/
theorem inner_le_Lp_mul_Lq (f g : ι → ℝ≥0) {p q : ℝ}
(hpq : p.is_conjugate_exponent q) :
∑ i in s, f i * g i ≤ (∑ i in s, (f i) ^ p) ^ (1 / p) * (∑ i in s, (g i) ^ q) ^ (1 / q) :=
begin
-- Let `G=∥g∥_q` be the `L_q`-norm of `g`.
set G := (∑ i in s, (g i) ^ q) ^ (1 / q),
have hGq : G ^ q = ∑ i in s, (g i) ^ q,
{ rw [← rpow_mul, one_div_mul_cancel hpq.symm.ne_zero, rpow_one], },
-- First consider the trivial case `∥g∥_q=0`
by_cases hG : G = 0,
{ rw [hG, sum_eq_zero, mul_zero],
intros i hi,
simp only [rpow_eq_zero_iff, sum_eq_zero_iff] at hG,
simp [(hG.1 i hi).1] },
{ -- Move power from right to left
rw [← div_le_iff hG, sum_div],
-- Now the inequality follows from the weighted generalized mean inequality
-- with weights `w_i` and numbers `z_i` given by the following formulas.
set w : ι → ℝ≥0 := λ i, (g i) ^ q / G ^ q,
set z : ι → ℝ≥0 := λ i, f i * (G / g i) ^ (q / p),
-- Show that the sum of weights equals one
have A : ∑ i in s, w i = 1,
{ rw [← sum_div, hGq, div_self],
simpa [rpow_eq_zero_iff, hpq.symm.ne_zero] using hG },
-- LHS of the goal equals LHS of the weighted generalized mean inequality
calc (∑ i in s, f i * g i / G) = (∑ i in s, w i * z i) :
begin
refine sum_congr rfl (λ i hi, _),
have : q - q / p = 1, by field_simp [hpq.ne_zero, hpq.symm.mul_eq_add],
dsimp only [w, z],
rw [← div_rpow, mul_left_comm, mul_div_assoc, ← @inv_div _ _ _ G, inv_rpow,
← div_eq_mul_inv, ← rpow_sub']; simp [this]
end
-- Apply the generalized mean inequality
... ≤ (∑ i in s, w i * (z i) ^ p) ^ (1 / p) :
nnreal.arith_mean_le_rpow_mean s w z A (le_of_lt hpq.one_lt)
-- Simplify the right hand side. Terms with `g i ≠ 0` are equal to `(f i) ^ p`,
-- the others are zeros.
... ≤ (∑ i in s, (f i) ^ p) ^ (1 / p) :
begin
refine rpow_le_rpow (sum_le_sum (λ i hi, _)) hpq.one_div_nonneg,
dsimp only [w, z],
rw [mul_rpow, mul_left_comm, ← rpow_mul _ _ p, div_mul_cancel _ hpq.ne_zero, div_rpow,
div_mul_div, mul_comm (G ^ q), mul_div_mul_right],
{ nth_rewrite 1 [← mul_one ((f i) ^ p)],
exact canonically_ordered_semiring.mul_le_mul (le_refl _) (div_self_le _) },
{ simpa [hpq.symm.ne_zero] using hG }
end }
end
/-- The `L_p` seminorm of a vector `f` is the greatest value of the inner product
`∑ i in s, f i * g i` over functions `g` of `L_q` seminorm less than or equal to one. -/
theorem is_greatest_Lp (f : ι → ℝ≥0) {p q : ℝ} (hpq : p.is_conjugate_exponent q) :
is_greatest ((λ g : ι → ℝ≥0, ∑ i in s, f i * g i) ''
{g | ∑ i in s, (g i)^q ≤ 1}) ((∑ i in s, (f i)^p) ^ (1 / p)) :=
begin
split,
{ use λ i, ((f i) ^ p / f i / (∑ i in s, (f i) ^ p) ^ (1 / q)),
by_cases hf : ∑ i in s, (f i)^p = 0,
{ simp [hf, hpq.ne_zero, hpq.symm.ne_zero] },
{ have A : p + q - q ≠ 0, by simp [hpq.ne_zero],
have B : ∀ y : ℝ≥0, y * y^p / y = y^p,
{ refine λ y, mul_div_cancel_left_of_imp (λ h, _),
simpa [h, hpq.ne_zero] },
simp only [set.mem_set_of_eq, div_rpow, ← sum_div, ← rpow_mul,
div_mul_cancel _ hpq.symm.ne_zero, rpow_one, div_le_iff hf, one_mul, hpq.mul_eq_add,
← rpow_sub' _ A, _root_.add_sub_cancel, le_refl, true_and, ← mul_div_assoc, B],
rw [div_eq_iff, ← rpow_add hf, hpq.inv_add_inv_conj, rpow_one],
simpa [hpq.symm.ne_zero] using hf } },
{ rintros _ ⟨g, hg, rfl⟩,
apply le_trans (inner_le_Lp_mul_Lq s f g hpq),
simpa only [mul_one] using canonically_ordered_semiring.mul_le_mul (le_refl _)
(nnreal.rpow_le_one hg (le_of_lt hpq.symm.one_div_pos)) }
end
/-- Minkowski inequality: the `L_p` seminorm of the sum of two vectors is less than or equal
to the sum of the `L_p`-seminorms of the summands. A version for `nnreal`-valued functions. -/
theorem Lp_add_le (f g : ι → ℝ≥0) {p : ℝ} (hp : 1 ≤ p) :
(∑ i in s, (f i + g i) ^ p) ^ (1 / p) ≤
(∑ i in s, (f i) ^ p) ^ (1 / p) + (∑ i in s, (g i) ^ p) ^ (1 / p) :=
begin
-- The result is trivial when `p = 1`, so we can assume `1 < p`.
rcases eq_or_lt_of_le hp with rfl|hp, { simp [finset.sum_add_distrib] },
have hpq := real.is_conjugate_exponent_conjugate_exponent hp,
have := is_greatest_Lp s (f + g) hpq,
simp only [pi.add_apply, add_mul, sum_add_distrib] at this,
rcases this.1 with ⟨φ, hφ, H⟩,
rw ← H,
exact add_le_add ((is_greatest_Lp s f hpq).2 ⟨φ, hφ, rfl⟩)
((is_greatest_Lp s g hpq).2 ⟨φ, hφ, rfl⟩)
end
end nnreal
namespace real
variables (f g : ι → ℝ) {p q : ℝ}
/-- Hölder inequality: the scalar product of two functions is bounded by the product of their
`L^p` and `L^q` norms when `p` and `q` are conjugate exponents. Version for sums over finite sets,
with real-valued functions. -/
theorem inner_le_Lp_mul_Lq (hpq : is_conjugate_exponent p q) :
∑ i in s, f i * g i ≤ (∑ i in s, (abs $ f i)^p) ^ (1 / p) * (∑ i in s, (abs $ g i)^q) ^ (1 / q) :=
begin
have := nnreal.coe_le_coe.2 (nnreal.inner_le_Lp_mul_Lq s (λ i, ⟨_, abs_nonneg (f i)⟩)
(λ i, ⟨_, abs_nonneg (g i)⟩) hpq),
push_cast at this,
refine le_trans (sum_le_sum $ λ i hi, _) this,
simp only [← abs_mul, le_abs_self]
end
/-- Minkowski inequality: the `L_p` seminorm of the sum of two vectors is less than or equal
to the sum of the `L_p`-seminorms of the summands. A version for `real`-valued functions. -/
theorem Lp_add_le (hp : 1 ≤ p) :
(∑ i in s, (abs $ f i + g i) ^ p) ^ (1 / p) ≤
(∑ i in s, (abs $ f i) ^ p) ^ (1 / p) + (∑ i in s, (abs $ g i) ^ p) ^ (1 / p) :=
begin
have := nnreal.coe_le_coe.2 (nnreal.Lp_add_le s (λ i, ⟨_, abs_nonneg (f i)⟩)
(λ i, ⟨_, abs_nonneg (g i)⟩) hp),
push_cast at this,
refine le_trans (rpow_le_rpow _ (sum_le_sum $ λ i hi, _) _) this;
simp [sum_nonneg, rpow_nonneg_of_nonneg, abs_nonneg, le_trans zero_le_one hp, abs_add,
rpow_le_rpow]
end
variables {f g}
/-- Hölder inequality: the scalar product of two functions is bounded by the product of their
`L^p` and `L^q` norms when `p` and `q` are conjugate exponents. Version for sums over finite sets,
with real-valued nonnegative functions. -/
theorem inner_le_Lp_mul_Lq_of_nonneg (hpq : is_conjugate_exponent p q)
(hf : ∀ i ∈ s, 0 ≤ f i) (hg : ∀ i ∈ s, 0 ≤ g i) :
∑ i in s, f i * g i ≤ (∑ i in s, (f i)^p) ^ (1 / p) * (∑ i in s, (g i)^q) ^ (1 / q) :=
by convert inner_le_Lp_mul_Lq s f g hpq using 3; apply sum_congr rfl; intros i hi;
simp only [abs_of_nonneg, hf i hi, hg i hi]
/-- Minkowski inequality: the `L_p` seminorm of the sum of two vectors is less than or equal
to the sum of the `L_p`-seminorms of the summands. A version for `real`-valued nonnegative
functions. -/
theorem Lp_add_le_of_nonneg (hp : 1 ≤ p) (hf : ∀ i ∈ s, 0 ≤ f i) (hg : ∀ i ∈ s, 0 ≤ g i) :
(∑ i in s, (f i + g i) ^ p) ^ (1 / p) ≤
(∑ i in s, (f i) ^ p) ^ (1 / p) + (∑ i in s, (g i) ^ p) ^ (1 / p) :=
by convert Lp_add_le s f g hp using 2 ; [skip, congr' 1, congr' 1];
apply sum_congr rfl; intros i hi; simp only [abs_of_nonneg, hf i hi, hg i hi, add_nonneg]
end real
namespace ennreal
/-- Young's inequality, `ℝ≥0∞` version with real conjugate exponents. -/
theorem young_inequality (a b : ℝ≥0∞) {p q : ℝ} (hpq : p.is_conjugate_exponent q) :
a * b ≤ a ^ p / ennreal.of_real p + b ^ q / ennreal.of_real q :=
begin
by_cases h : a = ⊤ ∨ b = ⊤,
{ refine le_trans le_top (le_of_eq _),
repeat { rw div_eq_mul_inv },
cases h; rw h; simp [h, hpq.pos, hpq.symm.pos], },
push_neg at h, -- if a ≠ ⊤ and b ≠ ⊤, use the nnreal version: nnreal.young_inequality_real
rw [←coe_to_nnreal h.left, ←coe_to_nnreal h.right, ←coe_mul,
coe_rpow_of_nonneg _ hpq.nonneg, coe_rpow_of_nonneg _ hpq.symm.nonneg, ennreal.of_real,
ennreal.of_real, ←@coe_div (nnreal.of_real p) _ (by simp [hpq.pos]),
←@coe_div (nnreal.of_real q) _ (by simp [hpq.symm.pos]), ←coe_add, coe_le_coe],
exact nnreal.young_inequality_real a.to_nnreal b.to_nnreal hpq,
end
variables (f g : ι → ℝ≥0∞) {p q : ℝ}
/-- Hölder inequality: the scalar product of two functions is bounded by the product of their
`L^p` and `L^q` norms when `p` and `q` are conjugate exponents. Version for sums over finite sets,
with `ℝ≥0∞`-valued functions. -/
theorem inner_le_Lp_mul_Lq (hpq : p.is_conjugate_exponent q) :
(∑ i in s, f i * g i) ≤ (∑ i in s, (f i)^p) ^ (1/p) * (∑ i in s, (g i)^q) ^ (1/q) :=
begin
by_cases H : (∑ i in s, (f i)^p) ^ (1/p) = 0 ∨ (∑ i in s, (g i)^q) ^ (1/q) = 0,
{ replace H : (∀ i ∈ s, f i = 0) ∨ (∀ i ∈ s, g i = 0),
by simpa [ennreal.rpow_eq_zero_iff, hpq.pos, hpq.symm.pos, asymm hpq.pos, asymm hpq.symm.pos,
sum_eq_zero_iff_of_nonneg] using H,
have : ∀ i ∈ s, f i * g i = 0 := λ i hi, by cases H; simp [H i hi],
have : (∑ i in s, f i * g i) = (∑ i in s, 0) := sum_congr rfl this,
simp [this] },
push_neg at H,
by_cases H' : (∑ i in s, (f i)^p) ^ (1/p) = ⊤ ∨ (∑ i in s, (g i)^q) ^ (1/q) = ⊤,
{ cases H'; simp [H', -one_div, H] },
replace H' : (∀ i ∈ s, f i ≠ ⊤) ∧ (∀ i ∈ s, g i ≠ ⊤),
by simpa [ennreal.rpow_eq_top_iff, asymm hpq.pos, asymm hpq.symm.pos, hpq.pos, hpq.symm.pos,
ennreal.sum_eq_top_iff, not_or_distrib] using H',
have := ennreal.coe_le_coe.2 (@nnreal.inner_le_Lp_mul_Lq _ s (λ i, ennreal.to_nnreal (f i))
(λ i, ennreal.to_nnreal (g i)) _ _ hpq),
simp [← ennreal.coe_rpow_of_nonneg, le_of_lt (hpq.pos), le_of_lt (hpq.one_div_pos),
le_of_lt (hpq.symm.pos), le_of_lt (hpq.symm.one_div_pos)] at this,
convert this using 1;
[skip, congr' 2];
[skip, skip, simp, skip, simp];
{ apply finset.sum_congr rfl (λ i hi, _), simp [H'.1 i hi, H'.2 i hi, -with_zero.coe_mul,
with_top.coe_mul.symm] },
end
/-- Minkowski inequality: the `L_p` seminorm of the sum of two vectors is less than or equal
to the sum of the `L_p`-seminorms of the summands. A version for `ℝ≥0∞` valued nonnegative
functions. -/
theorem Lp_add_le (hp : 1 ≤ p) :
(∑ i in s, (f i + g i) ^ p)^(1/p) ≤ (∑ i in s, (f i)^p) ^ (1/p) + (∑ i in s, (g i)^p) ^ (1/p) :=
begin
by_cases H' : (∑ i in s, (f i)^p) ^ (1/p) = ⊤ ∨ (∑ i in s, (g i)^p) ^ (1/p) = ⊤,
{ cases H'; simp [H', -one_div] },
have pos : 0 < p := lt_of_lt_of_le zero_lt_one hp,
replace H' : (∀ i ∈ s, f i ≠ ⊤) ∧ (∀ i ∈ s, g i ≠ ⊤),
by simpa [ennreal.rpow_eq_top_iff, asymm pos, pos, ennreal.sum_eq_top_iff,
not_or_distrib] using H',
have := ennreal.coe_le_coe.2 (@nnreal.Lp_add_le _ s (λ i, ennreal.to_nnreal (f i))
(λ i, ennreal.to_nnreal (g i)) _ hp),
push_cast [← ennreal.coe_rpow_of_nonneg, le_of_lt (pos), le_of_lt (one_div_pos.2 pos)] at this,
convert this using 2;
[skip, congr' 1, congr' 1];
{ apply finset.sum_congr rfl (λ i hi, _), simp [H'.1 i hi, H'.2 i hi] }
end
private lemma add_rpow_le_one_of_add_le_one {p : ℝ} (a b : ℝ≥0∞) (hab : a + b ≤ 1)
(hp1 : 1 ≤ p) :
a ^ p + b ^ p ≤ 1 :=
begin
have h_le_one : ∀ x : ℝ≥0∞, x ≤ 1 → x ^ p ≤ x, from λ x hx, rpow_le_self_of_le_one hx hp1,
have ha : a ≤ 1, from (self_le_add_right a b).trans hab,
have hb : b ≤ 1, from (self_le_add_left b a).trans hab,
exact (add_le_add (h_le_one a ha) (h_le_one b hb)).trans hab,
end
lemma add_rpow_le_rpow_add {p : ℝ} (a b : ℝ≥0∞) (hp1 : 1 ≤ p) :
a ^ p + b ^ p ≤ (a + b) ^ p :=
begin
have hp_pos : 0 < p := lt_of_lt_of_le zero_lt_one hp1,
by_cases h_top : a + b = ⊤,
{ rw ←@ennreal.rpow_eq_top_iff_of_pos (a + b) p hp_pos at h_top,
rw h_top,
exact le_top, },
obtain ⟨ha_top, hb_top⟩ := add_ne_top.mp h_top,
by_cases h_zero : a + b = 0,
{ simp [add_eq_zero_iff.mp h_zero, ennreal.zero_rpow_of_pos hp_pos], },
have h_nonzero : ¬(a = 0 ∧ b = 0), by rwa add_eq_zero_iff at h_zero,
have h_add : a/(a+b) + b/(a+b) = 1, by rw [div_add_div_same, div_self h_zero h_top],
have h := add_rpow_le_one_of_add_le_one (a/(a+b)) (b/(a+b)) h_add.le hp1,
rw [div_rpow_of_nonneg a (a+b) hp_pos.le, div_rpow_of_nonneg b (a+b) hp_pos.le] at h,
have hab_0 : (a + b)^p ≠ 0, by simp [ha_top, hb_top, hp_pos, h_nonzero],
have hab_top : (a + b)^p ≠ ⊤, by simp [ha_top, hb_top, hp_pos, h_nonzero],
have h_mul : (a + b)^p * (a ^ p / (a + b) ^ p + b ^ p / (a + b) ^ p) ≤ (a + b)^p,
{ nth_rewrite 3 ←mul_one ((a + b)^p),
exact (mul_le_mul_left hab_0 hab_top).mpr h, },
rwa [div_eq_mul_inv, div_eq_mul_inv, mul_add, mul_comm (a^p), mul_comm (b^p), ←mul_assoc,
←mul_assoc, mul_inv_cancel hab_0 hab_top, one_mul, one_mul] at h_mul,
end
lemma rpow_add_rpow_le_add {p : ℝ} (a b : ℝ≥0∞) (hp1 : 1 ≤ p) :
(a ^ p + b ^ p) ^ (1/p) ≤ a + b :=
begin
rw ←@ennreal.le_rpow_one_div_iff _ _ (1/p) (by simp [lt_of_lt_of_le zero_lt_one hp1]),
rw one_div_one_div,
exact add_rpow_le_rpow_add _ _ hp1,
end
theorem rpow_add_rpow_le {p q : ℝ} (a b : ℝ≥0∞) (hp_pos : 0 < p) (hpq : p ≤ q) :
(a ^ q + b ^ q) ^ (1/q) ≤ (a ^ p + b ^ p) ^ (1/p) :=
begin
have h_rpow : ∀ a : ℝ≥0∞, a^q = (a^p)^(q/p),
from λ a, by rw [←ennreal.rpow_mul, div_eq_inv_mul, ←mul_assoc,
_root_.mul_inv_cancel hp_pos.ne.symm, one_mul],
have h_rpow_add_rpow_le_add : ((a^p)^(q/p) + (b^p)^(q/p)) ^ (1/(q/p)) ≤ a^p + b^p,
{ refine rpow_add_rpow_le_add (a^p) (b^p) _,
rwa one_le_div hp_pos, },
rw [h_rpow a, h_rpow b, ennreal.le_rpow_one_div_iff hp_pos, ←ennreal.rpow_mul, mul_comm,
mul_one_div],
rwa one_div_div at h_rpow_add_rpow_le_add,
end
lemma rpow_add_le_add_rpow {p : ℝ} (a b : ℝ≥0∞) (hp_pos : 0 < p) (hp1 : p ≤ 1) :
(a + b) ^ p ≤ a ^ p + b ^ p :=
begin
have h := rpow_add_rpow_le a b hp_pos hp1,
rw one_div_one at h,
repeat { rw ennreal.rpow_one at h },
exact (ennreal.le_rpow_one_div_iff hp_pos).mp h,
end
end ennreal
section lintegral
/-!
### Hölder's inequality for the Lebesgue integral of ℝ≥0∞ and nnreal functions
We prove `∫ (f * g) ∂μ ≤ (∫ f^p ∂μ) ^ (1/p) * (∫ g^q ∂μ) ^ (1/q)` for `p`, `q`
conjugate real exponents and `α→(e)nnreal` functions in several cases, the first two being useful
only to prove the more general results:
* `ennreal.lintegral_mul_le_one_of_lintegral_rpow_eq_one` : ℝ≥0∞ functions for which the
integrals on the right are equal to 1,
* `ennreal.lintegral_mul_le_Lp_mul_Lq_of_ne_zero_of_ne_top` : ℝ≥0∞ functions for which the
integrals on the right are neither ⊤ nor 0,
* `ennreal.lintegral_mul_le_Lp_mul_Lq` : ℝ≥0∞ functions,
* `nnreal.lintegral_mul_le_Lp_mul_Lq` : nnreal functions.
-/
open measure_theory
variables {α : Type*} [measurable_space α] {μ : measure α}
namespace ennreal
lemma lintegral_mul_le_one_of_lintegral_rpow_eq_one {p q : ℝ} (hpq : p.is_conjugate_exponent q)
{f g : α → ℝ≥0∞} (hf : ae_measurable f μ) (hg : ae_measurable g μ)
(hf_norm : ∫⁻ a, (f a)^p ∂μ = 1) (hg_norm : ∫⁻ a, (g a)^q ∂μ = 1) :
∫⁻ a, (f * g) a ∂μ ≤ 1 :=
begin
calc ∫⁻ (a : α), ((f * g) a) ∂μ
≤ ∫⁻ (a : α), ((f a)^p / ennreal.of_real p + (g a)^q / ennreal.of_real q) ∂μ :
lintegral_mono (λ a, young_inequality (f a) (g a) hpq)
... = 1 :
begin
simp only [div_eq_mul_inv],
rw lintegral_add',
{ rw [lintegral_mul_const'' _ (hf.pow_const p), lintegral_mul_const'' _ (hg.pow_const q),
hf_norm, hg_norm, ← div_eq_mul_inv, ← div_eq_mul_inv, hpq.inv_add_inv_conj_ennreal], },
{ exact (hf.pow_const _).mul_const _, },
{ exact (hg.pow_const _).mul_const _, },
end
end
/-- Function multiplied by the inverse of its p-seminorm `(∫⁻ f^p ∂μ) ^ 1/p`-/
def fun_mul_inv_snorm (f : α → ℝ≥0∞) (p : ℝ) (μ : measure α) : α → ℝ≥0∞ :=
λ a, (f a) * ((∫⁻ c, (f c) ^ p ∂μ) ^ (1 / p))⁻¹
lemma fun_eq_fun_mul_inv_snorm_mul_snorm {p : ℝ} (f : α → ℝ≥0∞)
(hf_nonzero : ∫⁻ a, (f a) ^ p ∂μ ≠ 0) (hf_top : ∫⁻ a, (f a) ^ p ∂μ ≠ ⊤) {a : α} :
f a = (fun_mul_inv_snorm f p μ a) * (∫⁻ c, (f c)^p ∂μ)^(1/p) :=
by simp [fun_mul_inv_snorm, mul_assoc, inv_mul_cancel, hf_nonzero, hf_top]
lemma fun_mul_inv_snorm_rpow {p : ℝ} (hp0 : 0 < p) {f : α → ℝ≥0∞} {a : α} :
(fun_mul_inv_snorm f p μ a) ^ p = (f a)^p * (∫⁻ c, (f c) ^ p ∂μ)⁻¹ :=
begin
rw [fun_mul_inv_snorm, mul_rpow_of_nonneg _ _ (le_of_lt hp0)],
suffices h_inv_rpow : ((∫⁻ (c : α), f c ^ p ∂μ) ^ (1 / p))⁻¹ ^ p = (∫⁻ (c : α), f c ^ p ∂μ)⁻¹,
by rw h_inv_rpow,
rw [inv_rpow_of_pos hp0, ←rpow_mul, div_eq_mul_inv, one_mul,
_root_.inv_mul_cancel (ne_of_lt hp0).symm, rpow_one],
end
lemma lintegral_rpow_fun_mul_inv_snorm_eq_one {p : ℝ} (hp0_lt : 0 < p) {f : α → ℝ≥0∞}
(hf : ae_measurable f μ) (hf_nonzero : ∫⁻ a, (f a)^p ∂μ ≠ 0) (hf_top : ∫⁻ a, (f a)^p ∂μ ≠ ⊤) :
∫⁻ c, (fun_mul_inv_snorm f p μ c)^p ∂μ = 1 :=
begin
simp_rw fun_mul_inv_snorm_rpow hp0_lt,
rw [lintegral_mul_const'' _ (hf.pow_const p), mul_inv_cancel hf_nonzero hf_top],
end
/-- Hölder's inequality in case of finite non-zero integrals -/
lemma lintegral_mul_le_Lp_mul_Lq_of_ne_zero_of_ne_top {p q : ℝ} (hpq : p.is_conjugate_exponent q)
{f g : α → ℝ≥0∞} (hf : ae_measurable f μ) (hg : ae_measurable g μ)
(hf_nontop : ∫⁻ a, (f a)^p ∂μ ≠ ⊤) (hg_nontop : ∫⁻ a, (g a)^q ∂μ ≠ ⊤)
(hf_nonzero : ∫⁻ a, (f a)^p ∂μ ≠ 0) (hg_nonzero : ∫⁻ a, (g a)^q ∂μ ≠ 0) :
∫⁻ a, (f * g) a ∂μ ≤ (∫⁻ a, (f a)^p ∂μ)^(1/p) * (∫⁻ a, (g a)^q ∂μ)^(1/q) :=
begin
let npf := (∫⁻ (c : α), (f c) ^ p ∂μ) ^ (1/p),
let nqg := (∫⁻ (c : α), (g c) ^ q ∂μ) ^ (1/q),
calc ∫⁻ (a : α), (f * g) a ∂μ
= ∫⁻ (a : α), ((fun_mul_inv_snorm f p μ * fun_mul_inv_snorm g q μ) a)
* (npf * nqg) ∂μ :
begin
refine lintegral_congr (λ a, _),
rw [pi.mul_apply, fun_eq_fun_mul_inv_snorm_mul_snorm f hf_nonzero hf_nontop,
fun_eq_fun_mul_inv_snorm_mul_snorm g hg_nonzero hg_nontop, pi.mul_apply],
ring,
end
... ≤ npf * nqg :
begin
rw lintegral_mul_const' (npf * nqg) _ (by simp [hf_nontop, hg_nontop, hf_nonzero, hg_nonzero]),
nth_rewrite 1 ←one_mul (npf * nqg),
refine mul_le_mul _ (le_refl (npf * nqg)),
have hf1 := lintegral_rpow_fun_mul_inv_snorm_eq_one hpq.pos hf hf_nonzero hf_nontop,
have hg1 := lintegral_rpow_fun_mul_inv_snorm_eq_one hpq.symm.pos hg hg_nonzero hg_nontop,
exact lintegral_mul_le_one_of_lintegral_rpow_eq_one hpq (hf.mul_const _)
(hg.mul_const _) hf1 hg1,
end
end
lemma ae_eq_zero_of_lintegral_rpow_eq_zero {p : ℝ} (hp0_lt : 0 < p) {f : α → ℝ≥0∞}
(hf : ae_measurable f μ) (hf_zero : ∫⁻ a, (f a)^p ∂μ = 0) :
f =ᵐ[μ] 0 :=
begin
rw lintegral_eq_zero_iff' (hf.pow_const p) at hf_zero,
refine filter.eventually.mp hf_zero (filter.eventually_of_forall (λ x, _)),
dsimp only,
rw [pi.zero_apply, rpow_eq_zero_iff],
intro hx,
cases hx,
{ exact hx.left, },
{ exfalso,
linarith, },
end
lemma lintegral_mul_eq_zero_of_lintegral_rpow_eq_zero {p : ℝ} (hp0_lt : 0 < p)
{f g : α → ℝ≥0∞} (hf : ae_measurable f μ) (hf_zero : ∫⁻ a, (f a)^p ∂μ = 0) :
∫⁻ a, (f * g) a ∂μ = 0 :=
begin
rw ←@lintegral_zero_fun α _ μ,
refine lintegral_congr_ae _,
suffices h_mul_zero : f * g =ᵐ[μ] 0 * g , by rwa zero_mul at h_mul_zero,
have hf_eq_zero : f =ᵐ[μ] 0, from ae_eq_zero_of_lintegral_rpow_eq_zero hp0_lt hf hf_zero,
exact filter.eventually_eq.mul hf_eq_zero (ae_eq_refl g),
end
lemma lintegral_mul_le_Lp_mul_Lq_of_ne_zero_of_eq_top {p q : ℝ} (hp0_lt : 0 < p) (hq0 : 0 ≤ q)
{f g : α → ℝ≥0∞} (hf_top : ∫⁻ a, (f a)^p ∂μ = ⊤) (hg_nonzero : ∫⁻ a, (g a)^q ∂μ ≠ 0) :
∫⁻ a, (f * g) a ∂μ ≤ (∫⁻ a, (f a)^p ∂μ) ^ (1/p) * (∫⁻ a, (g a)^q ∂μ) ^ (1/q) :=
begin
refine le_trans le_top (le_of_eq _),
have hp0_inv_lt : 0 < 1/p, by simp [hp0_lt],
rw [hf_top, ennreal.top_rpow_of_pos hp0_inv_lt],
simp [hq0, hg_nonzero],
end
/-- Hölder's inequality for functions `α → ℝ≥0∞`. The integral of the product of two functions
is bounded by the product of their `ℒp` and `ℒq` seminorms when `p` and `q` are conjugate
exponents. -/
theorem lintegral_mul_le_Lp_mul_Lq (μ : measure α) {p q : ℝ} (hpq : p.is_conjugate_exponent q)
{f g : α → ℝ≥0∞} (hf : ae_measurable f μ) (hg : ae_measurable g μ) :
∫⁻ a, (f * g) a ∂μ ≤ (∫⁻ a, (f a)^p ∂μ) ^ (1/p) * (∫⁻ a, (g a)^q ∂μ) ^ (1/q) :=
begin
by_cases hf_zero : ∫⁻ a, (f a) ^ p ∂μ = 0,
{ refine le_trans (le_of_eq _) (zero_le _),
exact lintegral_mul_eq_zero_of_lintegral_rpow_eq_zero hpq.pos hf hf_zero, },
by_cases hg_zero : ∫⁻ a, (g a) ^ q ∂μ = 0,
{ refine le_trans (le_of_eq _) (zero_le _),
rw mul_comm,
exact lintegral_mul_eq_zero_of_lintegral_rpow_eq_zero hpq.symm.pos hg hg_zero, },
by_cases hf_top : ∫⁻ a, (f a) ^ p ∂μ = ⊤,
{ exact lintegral_mul_le_Lp_mul_Lq_of_ne_zero_of_eq_top hpq.pos hpq.symm.nonneg hf_top hg_zero, },
by_cases hg_top : ∫⁻ a, (g a) ^ q ∂μ = ⊤,
{ rw [mul_comm, mul_comm ((∫⁻ (a : α), (f a) ^ p ∂μ) ^ (1 / p))],
exact lintegral_mul_le_Lp_mul_Lq_of_ne_zero_of_eq_top hpq.symm.pos hpq.nonneg hg_top hf_zero, },
-- non-⊤ non-zero case
exact ennreal.lintegral_mul_le_Lp_mul_Lq_of_ne_zero_of_ne_top hpq hf hg hf_top hg_top hf_zero
hg_zero,
end
lemma lintegral_rpow_add_lt_top_of_lintegral_rpow_lt_top {p : ℝ}
{f g : α → ℝ≥0∞} (hf : ae_measurable f μ) (hf_top : ∫⁻ a, (f a) ^ p ∂μ < ⊤)
(hg : ae_measurable g μ) (hg_top : ∫⁻ a, (g a) ^ p ∂μ < ⊤) (hp1 : 1 ≤ p) :
∫⁻ a, ((f + g) a) ^ p ∂μ < ⊤ :=
begin
have hp0_lt : 0 < p, from lt_of_lt_of_le zero_lt_one hp1,
have hp0 : 0 ≤ p, from le_of_lt hp0_lt,
calc ∫⁻ (a : α), (f a + g a) ^ p ∂μ
≤ ∫⁻ a, ((2:ℝ≥0∞)^(p-1) * (f a) ^ p + (2:ℝ≥0∞)^(p-1) * (g a) ^ p) ∂ μ :
begin
refine lintegral_mono (λ a, _),
dsimp only,
have h_zero_lt_half_rpow : (0 : ℝ≥0∞) < (1 / 2) ^ p,
{ rw [←ennreal.zero_rpow_of_pos hp0_lt],
exact ennreal.rpow_lt_rpow (by simp [zero_lt_one]) hp0_lt, },
have h_rw : (1 / 2) ^ p * (2:ℝ≥0∞) ^ (p - 1) = 1 / 2,
{ rw [sub_eq_add_neg, ennreal.rpow_add _ _ ennreal.two_ne_zero ennreal.coe_ne_top,
←mul_assoc, ←ennreal.mul_rpow_of_nonneg _ _ hp0, one_div,
ennreal.inv_mul_cancel ennreal.two_ne_zero ennreal.coe_ne_top, ennreal.one_rpow,
one_mul, ennreal.rpow_neg_one], },
rw ←ennreal.mul_le_mul_left (ne_of_lt h_zero_lt_half_rpow).symm _,
{ rw [mul_add, ← mul_assoc, ← mul_assoc, h_rw, ←ennreal.mul_rpow_of_nonneg _ _ hp0, mul_add],
refine ennreal.rpow_arith_mean_le_arith_mean2_rpow (1/2 : ℝ≥0∞) (1/2 : ℝ≥0∞)
(f a) (g a) _ hp1,
rw [ennreal.div_add_div_same, one_add_one_eq_two,
ennreal.div_self ennreal.two_ne_zero ennreal.coe_ne_top], },
{ rw ←ennreal.lt_top_iff_ne_top,
refine ennreal.rpow_lt_top_of_nonneg hp0 _,
rw [one_div, ennreal.inv_ne_top],
exact ennreal.two_ne_zero, },
end
... < ⊤ :
begin
rw [lintegral_add', lintegral_const_mul'' _ (hf.pow_const p),
lintegral_const_mul'' _ (hg.pow_const p), ennreal.add_lt_top],
{ have h_two : (2 : ℝ≥0∞) ^ (p - 1) < ⊤,
from ennreal.rpow_lt_top_of_nonneg (by simp [hp1]) ennreal.coe_ne_top,
repeat {rw ennreal.mul_lt_top_iff},
simp [hf_top, hg_top, h_two], },
{ exact (hf.pow_const _).const_mul _ },
{ exact (hg.pow_const _).const_mul _ },
end
end
lemma lintegral_Lp_mul_le_Lq_mul_Lr {α} [measurable_space α] {p q r : ℝ} (hp0_lt : 0 < p)
(hpq : p < q) (hpqr : 1/p = 1/q + 1/r) (μ : measure α) {f g : α → ℝ≥0∞}
(hf : ae_measurable f μ) (hg : ae_measurable g μ) :
(∫⁻ a, ((f * g) a)^p ∂μ) ^ (1/p) ≤ (∫⁻ a, (f a)^q ∂μ) ^ (1/q) * (∫⁻ a, (g a)^r ∂μ) ^ (1/r) :=
begin
have hp0_ne : p ≠ 0, from (ne_of_lt hp0_lt).symm,
have hp0 : 0 ≤ p, from le_of_lt hp0_lt,
have hq0_lt : 0 < q, from lt_of_le_of_lt hp0 hpq,
have hq0_ne : q ≠ 0, from (ne_of_lt hq0_lt).symm,
have h_one_div_r : 1/r = 1/p - 1/q, by simp [hpqr],
have hr0_ne : r ≠ 0,
{ have hr_inv_pos : 0 < 1/r,
by rwa [h_one_div_r, sub_pos, one_div_lt_one_div hq0_lt hp0_lt],
rw [one_div, _root_.inv_pos] at hr_inv_pos,
exact (ne_of_lt hr_inv_pos).symm, },
let p2 := q/p,
let q2 := p2.conjugate_exponent,
have hp2q2 : p2.is_conjugate_exponent q2,
from real.is_conjugate_exponent_conjugate_exponent (by simp [lt_div_iff, hpq, hp0_lt]),
calc (∫⁻ (a : α), ((f * g) a) ^ p ∂μ) ^ (1 / p)
= (∫⁻ (a : α), (f a)^p * (g a)^p ∂μ) ^ (1 / p) :
by simp_rw [pi.mul_apply, ennreal.mul_rpow_of_nonneg _ _ hp0]
... ≤ ((∫⁻ a, (f a)^(p * p2) ∂ μ)^(1/p2) * (∫⁻ a, (g a)^(p * q2) ∂ μ)^(1/q2)) ^ (1/p) :
begin
refine ennreal.rpow_le_rpow _ (by simp [hp0]),
simp_rw ennreal.rpow_mul,
exact ennreal.lintegral_mul_le_Lp_mul_Lq μ hp2q2 (hf.pow_const _) (hg.pow_const _)
end
... = (∫⁻ (a : α), (f a) ^ q ∂μ) ^ (1 / q) * (∫⁻ (a : α), (g a) ^ r ∂μ) ^ (1 / r) :
begin
rw [@ennreal.mul_rpow_of_nonneg _ _ (1/p) (by simp [hp0]), ←ennreal.rpow_mul,
←ennreal.rpow_mul],
have hpp2 : p * p2 = q,
{ symmetry, rw [mul_comm, ←div_eq_iff hp0_ne], },
have hpq2 : p * q2 = r,
{ rw [← inv_inv' r, ← one_div, ← one_div, h_one_div_r],
field_simp [q2, real.conjugate_exponent, p2, hp0_ne, hq0_ne] },
simp_rw [div_mul_div, mul_one, mul_comm p2, mul_comm q2, hpp2, hpq2],
end
end
lemma lintegral_mul_rpow_le_lintegral_rpow_mul_lintegral_rpow {p q : ℝ}
(hpq : p.is_conjugate_exponent q) {f g : α → ℝ≥0∞}
(hf : ae_measurable f μ) (hg : ae_measurable g μ) (hf_top : ∫⁻ a, (f a) ^ p ∂μ ≠ ⊤) :
∫⁻ a, (f a) * (g a) ^ (p - 1) ∂μ ≤ (∫⁻ a, (f a)^p ∂μ) ^ (1/p) * (∫⁻ a, (g a)^p ∂μ) ^ (1/q) :=
begin
refine le_trans (ennreal.lintegral_mul_le_Lp_mul_Lq μ hpq hf (hg.pow_const _)) _,
by_cases hf_zero_rpow : (∫⁻ (a : α), (f a) ^ p ∂μ) ^ (1 / p) = 0,
{ rw [hf_zero_rpow, zero_mul],
exact zero_le _, },
have hf_top_rpow : (∫⁻ (a : α), (f a) ^ p ∂μ) ^ (1 / p) ≠ ⊤,
{ by_contra h,
push_neg at h,
refine hf_top _,
have hp_not_neg : ¬ p < 0, by simp [hpq.nonneg],
simpa [hpq.pos, hp_not_neg] using h, },
refine (ennreal.mul_le_mul_left hf_zero_rpow hf_top_rpow).mpr (le_of_eq _),
congr,
ext1 a,
rw [←ennreal.rpow_mul, hpq.sub_one_mul_conj],
end
lemma lintegral_rpow_add_le_add_snorm_mul_lintegral_rpow_add {p q : ℝ}
(hpq : p.is_conjugate_exponent q) {f g : α → ℝ≥0∞} (hf : ae_measurable f μ)
(hf_top : ∫⁻ a, (f a) ^ p ∂μ ≠ ⊤) (hg : ae_measurable g μ) (hg_top : ∫⁻ a, (g a) ^ p ∂μ ≠ ⊤) :
∫⁻ a, ((f + g) a)^p ∂ μ
≤ ((∫⁻ a, (f a)^p ∂μ) ^ (1/p) + (∫⁻ a, (g a)^p ∂μ) ^ (1/p))
* (∫⁻ a, (f a + g a)^p ∂μ) ^ (1/q) :=
begin
calc ∫⁻ a, ((f+g) a) ^ p ∂μ ≤ ∫⁻ a, ((f + g) a) * ((f + g) a) ^ (p - 1) ∂μ :
begin
refine lintegral_mono (λ a, _),
dsimp only,
by_cases h_zero : (f + g) a = 0,
{ rw [h_zero, ennreal.zero_rpow_of_pos hpq.pos],
exact zero_le _, },
by_cases h_top : (f + g) a = ⊤,
{ rw [h_top, ennreal.top_rpow_of_pos hpq.sub_one_pos, ennreal.top_mul_top],
exact le_top, },
refine le_of_eq _,
nth_rewrite 1 ←ennreal.rpow_one ((f + g) a),
rw [←ennreal.rpow_add _ _ h_zero h_top, add_sub_cancel'_right],
end
... = ∫⁻ (a : α), f a * (f + g) a ^ (p - 1) ∂μ + ∫⁻ (a : α), g a * (f + g) a ^ (p - 1) ∂μ :
begin
have h_add_m : ae_measurable (λ (a : α), ((f + g) a) ^ (p-1)) μ,
from (hf.add hg).pow_const _,
have h_add_apply : ∫⁻ (a : α), (f + g) a * (f + g) a ^ (p - 1) ∂μ
= ∫⁻ (a : α), (f a + g a) * (f + g) a ^ (p - 1) ∂μ,
from rfl,
simp_rw [h_add_apply, add_mul],
rw lintegral_add' (hf.mul h_add_m) (hg.mul h_add_m),
end
... ≤ ((∫⁻ a, (f a)^p ∂μ) ^ (1/p) + (∫⁻ a, (g a)^p ∂μ) ^ (1/p))
* (∫⁻ a, (f a + g a)^p ∂μ) ^ (1/q) :
begin
rw add_mul,
exact add_le_add
(lintegral_mul_rpow_le_lintegral_rpow_mul_lintegral_rpow hpq hf (hf.add hg) hf_top)
(lintegral_mul_rpow_le_lintegral_rpow_mul_lintegral_rpow hpq hg (hf.add hg) hg_top),
end
end
private lemma lintegral_Lp_add_le_aux {p q : ℝ}
(hpq : p.is_conjugate_exponent q) {f g : α → ℝ≥0∞} (hf : ae_measurable f μ)
(hf_top : ∫⁻ a, (f a) ^ p ∂μ ≠ ⊤) (hg : ae_measurable g μ) (hg_top : ∫⁻ a, (g a) ^ p ∂μ ≠ ⊤)
(h_add_zero : ∫⁻ a, ((f+g) a) ^ p ∂ μ ≠ 0) (h_add_top : ∫⁻ a, ((f+g) a) ^ p ∂ μ ≠ ⊤) :
(∫⁻ a, ((f + g) a)^p ∂ μ) ^ (1/p) ≤ (∫⁻ a, (f a)^p ∂μ) ^ (1/p) + (∫⁻ a, (g a)^p ∂μ) ^ (1/p) :=
begin
have hp_not_nonpos : ¬ p ≤ 0, by simp [hpq.pos],
have htop_rpow : (∫⁻ a, ((f+g) a) ^ p ∂μ)^(1/p) ≠ ⊤,
{ by_contra h,
push_neg at h,
exact h_add_top (@ennreal.rpow_eq_top_of_nonneg _ (1/p) (by simp [hpq.nonneg]) h), },
have h0_rpow : (∫⁻ a, ((f+g) a) ^ p ∂ μ) ^ (1/p) ≠ 0,
by simp [h_add_zero, h_add_top, hpq.nonneg, hp_not_nonpos, -pi.add_apply],
suffices h : 1 ≤ (∫⁻ (a : α), ((f+g) a)^p ∂μ) ^ -(1/p)
* ((∫⁻ (a : α), (f a)^p ∂μ) ^ (1/p) + (∫⁻ (a : α), (g a)^p ∂μ) ^ (1/p)),
by rwa [←mul_le_mul_left h0_rpow htop_rpow, ←mul_assoc, ←rpow_add _ _ h_add_zero h_add_top,
←sub_eq_add_neg, _root_.sub_self, rpow_zero, one_mul, mul_one] at h,
have h : ∫⁻ (a : α), ((f+g) a)^p ∂μ
≤ ((∫⁻ (a : α), (f a)^p ∂μ) ^ (1/p) + (∫⁻ (a : α), (g a)^p ∂μ) ^ (1/p))
* (∫⁻ (a : α), ((f+g) a)^p ∂μ) ^ (1/q),
from lintegral_rpow_add_le_add_snorm_mul_lintegral_rpow_add hpq hf hf_top hg hg_top,
have h_one_div_q : 1/q = 1 - 1/p, by { nth_rewrite 1 ←hpq.inv_add_inv_conj, ring, },
simp_rw [h_one_div_q, sub_eq_add_neg 1 (1/p), ennreal.rpow_add _ _ h_add_zero h_add_top,
rpow_one] at h,
nth_rewrite 1 mul_comm at h,
nth_rewrite 0 ←one_mul (∫⁻ (a : α), ((f+g) a) ^ p ∂μ) at h,
rwa [←mul_assoc, ennreal.mul_le_mul_right h_add_zero h_add_top, mul_comm] at h,
end
/-- Minkowski's inequality for functions `α → ℝ≥0∞`: the `ℒp` seminorm of the sum of two
functions is bounded by the sum of their `ℒp` seminorms. -/
theorem lintegral_Lp_add_le {p : ℝ} {f g : α → ℝ≥0∞}
(hf : ae_measurable f μ) (hg : ae_measurable g μ) (hp1 : 1 ≤ p) :
(∫⁻ a, ((f + g) a)^p ∂ μ) ^ (1/p) ≤ (∫⁻ a, (f a)^p ∂μ) ^ (1/p) + (∫⁻ a, (g a)^p ∂μ) ^ (1/p) :=
begin
have hp_pos : 0 < p, from lt_of_lt_of_le zero_lt_one hp1,
by_cases hf_top : ∫⁻ a, (f a) ^ p ∂μ = ⊤,
{ simp [hf_top, hp_pos], },
by_cases hg_top : ∫⁻ a, (g a) ^ p ∂μ = ⊤,
{ simp [hg_top, hp_pos], },
by_cases h1 : p = 1,
{ refine le_of_eq _,
simp_rw [h1, one_div_one, ennreal.rpow_one],
exact lintegral_add' hf hg, },
have hp1_lt : 1 < p, by { refine lt_of_le_of_ne hp1 _, symmetry, exact h1, },
have hpq := real.is_conjugate_exponent_conjugate_exponent hp1_lt,
by_cases h0 : ∫⁻ a, ((f+g) a) ^ p ∂ μ = 0,
{ rw [h0, @ennreal.zero_rpow_of_pos (1/p) (by simp [lt_of_lt_of_le zero_lt_one hp1])],
exact zero_le _, },
have htop : ∫⁻ a, ((f+g) a) ^ p ∂ μ ≠ ⊤,
{ rw ←ne.def at hf_top hg_top,
rw ←ennreal.lt_top_iff_ne_top at hf_top hg_top ⊢,
exact lintegral_rpow_add_lt_top_of_lintegral_rpow_lt_top hf hf_top hg hg_top hp1, },
exact lintegral_Lp_add_le_aux hpq hf hf_top hg hg_top h0 htop,
end
end ennreal
/-- Hölder's inequality for functions `α → ℝ≥0`. The integral of the product of two functions
is bounded by the product of their `ℒp` and `ℒq` seminorms when `p` and `q` are conjugate
exponents. -/
theorem nnreal.lintegral_mul_le_Lp_mul_Lq {p q : ℝ} (hpq : p.is_conjugate_exponent q)
{f g : α → ℝ≥0} (hf : ae_measurable f μ) (hg : ae_measurable g μ) :
∫⁻ a, (f * g) a ∂μ ≤ (∫⁻ a, (f a)^p ∂μ)^(1/p) * (∫⁻ a, (g a)^q ∂μ)^(1/q) :=
begin
simp_rw [pi.mul_apply, ennreal.coe_mul],
exact ennreal.lintegral_mul_le_Lp_mul_Lq μ hpq hf.ennreal_coe hg.ennreal_coe,
end
end lintegral
|
theorem ex1 : (fun y => y + 0) = (fun x => 0 + x) := by
funext x
simp
theorem ex2 : (fun y x => y + x + 0) = (fun x y => y + x) := by
funext x y
rw [Nat.add_zero, Nat.add_comm]
theorem ex3 : (fun (x : Nat × Nat) => x.1 + x.2) = (fun (x : Nat × Nat) => x.2 + x.1) := by
funext (a, b)
show a + b = b + a
rw [Nat.add_comm]
theorem ex4 : (fun (x : Nat × Nat) (y : Nat × Nat) => x.1 + y.2) = (fun (x : Nat × Nat) (z : Nat × Nat) => z.2 + x.1) := by
funext (a, b) (c, d)
show a + d = d + a
rw [Nat.add_comm]
theorem ex5 : (fun (x : Id Nat) => x.succ + 0) = (fun (x : Id Nat) => 0 + x.succ) := by
funext (x : Nat)
have y := x + 1 -- if `(x : Nat)` is not used at `funext`, then `x+1` would fail to be elaborated since we don't have the instance `Add (Id Nat)`
rw [Nat.add_comm]
|
||| An expression language with mechanical proof of type-safety.
|||
||| `Variant` is an expression language supporting Let-bindings, and
||| type unsafe variants. Standard constructions are used to
||| represent the language as an EDSL, together with proof of progress
||| taken from PLFA Part 2.
|||
||| This module compliments Section 4.1 of the Functional Pearl.
|||
module Razor.Variant
import Razor.Common
%default total
namespace Types
public export
data Ty = TyInt
| TyChar
| TyVariant (Vect (S n) (Pair String Ty))
namespace Terms
mutual
public export
data Case : (ctxt : List Ty)
-> (label : String)
-> (type : Ty)
-> (body : Ty)
-> Type
where
MkCase : (label : String)
-> (branch : Variant (ctxt += type) body)
-> Case ctxt label type body
public export
data Cases : (ctxt : List Ty)
-> (types : Vect (S n) (Pair String Ty))
-> (body : Ty)
-> Type
where
Singleton : (branch : Case g label ty b)
-> Cases g [(label, ty)] b
Extend : (branch : Case g label ty b)
-> (rest : Cases g kvs b)
-> Cases g ((label, ty) :: kvs) b
public export
data Variant : List Ty -> Ty -> Type where
-- Let-Binding & Variables
Var : Elem ty g -> Variant g ty
Let : {expr, body : Ty}
-> (this : Variant g expr)
-> (beInThis : Variant (expr::g) body)
-> Variant g body
-- Base Values
I : Int -> Variant g TyInt
C : Char -> Variant g TyChar
-- Variants & Accessors
Tag : {kvs : Vect (S n) (Pair String Ty)}
-> (label : String)
-> (value : Variant g ty)
-> (prf : Elem (label, ty) kvs)
-> Variant g (TyVariant kvs)
Match : {kvs : Vect (S n) (Pair String Ty)}
-> {b : Ty}
-> (value : Variant g (TyVariant kvs))
-> (cases : Cases g kvs b)
-> Variant g b
namespace Renaming
public export
weaken : forall type
. (Contains old type -> Contains new type)
-> (Contains (old += type') type -> Contains (new += type') type)
weaken func Here = Here
weaken func (There rest) = There (func rest)
mutual
namespace Case
public export
rename : (forall type . Contains old type -> Contains new type)
-> (forall type, body . Case old label type body
-> Case new label type body)
rename f (MkCase label branch)
= MkCase label (rename (weaken f) branch)
namespace Cases
public export
rename : (forall type . Contains (old) type -> Contains (new) type)
-> (forall types, type . Cases old types type
-> Cases new types type)
rename f (Singleton branch)
= Singleton (Case.rename f branch)
rename f (Extend branch rest)
= Extend (Case.rename f branch) (rename f rest)
public export
rename : (forall type . Contains old type -> Contains new type)
-> (forall type . Variant old type -> Variant new type)
-- Let-Bindings & Variables
rename f (Var x) = Var (f x)
rename f (Let this beInThis)
= Let (rename f this)
(rename (weaken f) beInThis)
-- Base Variables
rename f (I x) = I x
rename f (C x) = C x
-- Variants & Accesors
rename f (Tag label value prf) = Tag label (rename f value) prf
rename f (Match value cases) = Match (rename f value)
(Cases.rename f cases)
namespace Substitution
public export
weakens : forall old, new
. (f : forall type
. Contains old type
-> Variant new type)
-> (forall type . Contains (old += type') type
-> Variant (new += type') type)
weakens f Here = Var Here
weakens f (There rest) = rename There (f rest)
namespace General
mutual
namespace Case
public export
subst : (f : forall type
. Contains old type
-> Variant new type)
-> (forall type, body . Case old label type body
-> Case new label type body)
subst f (MkCase label branch)
= MkCase label (subst (weakens f) branch)
namespace Cases
public export
subst : (f : forall type
. Contains old type
-> Variant new type)
-> (forall types, type . Cases old types type
-> Cases new types type)
subst f (Singleton branch)
= Singleton (Case.subst f branch)
subst f (Extend branch rest)
= Extend (Case.subst f branch) (subst f rest)
public export
subst : (forall type . Contains old type -> Variant new type)
-> (forall type . Variant old type -> Variant new type)
-- Let-Bindings & Variables
subst f (Var x) = f x
subst f (Let this beInThis)
= Let (subst f this) (subst (weakens f) beInThis)
-- Base Values
subst f (I x) = I x
subst f (C x) = C x
-- Variants & Accessors
subst f (Tag label value prf)
= Tag label (subst f value) prf
subst f (Match value cases)
= Match (subst f value) (subst f cases)
namespace Single
public export
apply : (this : Variant ctxt typeB)
-> (idx : Contains (ctxt += typeB) typeA)
-> Variant ctxt typeA
apply this Here = this
apply this (There rest) = Var rest
public export
subst : (this : Variant ctxt typeB)
-> (inThis : Variant (ctxt += typeB) typeA)
-> Variant ctxt typeA
subst {ctxt} {typeA} {typeB} this inThis
= General.subst (apply this) inThis
namespace Values
public export
data Value : Variant ctxt type -> Type where
-- Base Values
IV : Value (I i)
CV : Value (C c)
-- Variants
MkTagV : {kvs : Vect (S n) (Pair String Ty)}
-> {value' : Variant Nil type}
-> (value : Value value')
-> {prf : Elem (label, type) kvs}
-> Value (Tag label value' prf)
namespace Reduction
namespace Cases
public export
data Redux : (value : Variant g type)
-> (cases : Cases g kvs body)
-> (idx : Elem (label, type) kvs)
-> (result : Variant g body)
-> Type
where
ReduceSingleton : {value : Variant g type}
-> Value value
-> Redux value
(Singleton (MkCase label branch))
Here
(subst value branch)
ReduceExtend : {value : Variant g type}
-> {rest : Cases g kvs body}
-> Value value
-> Redux value
(Extend (MkCase label branch) rest)
Here
(Single.subst value branch)
SkipThis : Redux value rest later result
-> Redux value
(Extend branch rest)
(There later)
result
public export
data Redux : (this, that : Variant ctxt type) -> Type where
-- Let Bindings
SimplifyLetValue : Redux this that
-> Redux (Let this body)
(Let that body)
ReduceLetBody : Value value
-> Redux (Let value body)
(subst value body)
-- Variants & Accessors
SimplifyTag : {kvs : Vect (S n) (Pair String Ty)}
-> {prf : Elem (label, type) kvs}
-> (redux : Redux this that)
-> Redux (Tag label this prf) (Tag label that prf)
SimplifyMatchCase : {cases : Cases _ kvs type}
-> (redux : Redux this that)
-> Redux (Match this cases) (Match that cases)
ReduceCases : {kvs : Vect (S n) (Pair String Ty)}
-> {idx : Elem (label, type') kvs}
-> {value : Variant g type'}
-> {this : Cases g kvs type}
-> {that : Variant g type}
-> (prf : Value value)
-> (redux : Redux value this idx that)
-> Redux (Match (Tag label value idx) this)
that
namespace Progress
public export
data Progress : (term : Variant Nil type)
-> Type
where
Done : {term : Variant Nil type}
-> (value : Value term)
-> Progress term
Step : {type : Ty}
-> {this, that : Variant Nil type}
-> (step : Redux this that)
-> Progress this
namespace Cases
public export
data Progress : (label : String)
-> (value : Variant Nil type)
-> (idx : Elem (label, type) kvs)
-> (term : Cases Nil kvs body)
-> Type
where
Step : {value : Variant Nil type'}
-> {idx : Elem (label, type') kvs}
-> {cases : Cases Nil kvs type}
-> {that : Variant Nil type}
-> (step : Redux value cases idx that)
-> Progress label value idx cases
mutual
namespace Cases
public export
progress : {value' : Variant Nil type}
-> (idx : Elem (label, type) kvs)
-> (value : Value value')
-> (term : Cases Nil kvs body)
-> Progress label value' idx term
progress Here value (Singleton (MkCase label branch))
= Step (ReduceSingleton value)
progress Here value (Extend (MkCase label branch) rest)
= Step (ReduceExtend value)
progress (There later) value (Extend branch rest) with (progress later value rest)
progress (There later) value (Extend branch rest) | Step step
= Step (SkipThis step)
public export
progress : forall type . (term : Variant Nil type) -> Progress term
-- Let-Bindings & Variables
progress (Var _) impossible
progress (Let this beInThis) with (progress this)
progress (Let this beInThis) | (Done value) = Step (ReduceLetBody value)
progress (Let this beInThis) | (Step step) = Step (SimplifyLetValue step)
-- Base Values
progress (I x) = Done IV
progress (C x) = Done CV
-- Variants & Accessors
progress (Tag label value prf) with (progress value)
progress (Tag label value prf) | (Done value') = Done (MkTagV value')
progress (Tag label value prf) | (Step step) = Step (SimplifyTag step)
progress (Match value cases) with (progress value)
progress (Match (Tag label value' prf) cases) | (Done (MkTagV x)) with (progress prf x cases)
progress (Match (Tag label value' prf) cases) | (Done (MkTagV x)) | (Step step)
= Step (ReduceCases x step)
progress (Match value cases) | (Step step) = Step (SimplifyMatchCase step)
namespace Evaluation
public export
data Reduces : (this : Variant ctxt type)
-> (that : Variant ctxt type)
-> Type
where
Refl : {this : Variant ctxt type}
-> Reduces this this
Trans : {this, that, end : Variant ctxt type}
-> Redux this that
-> Reduces that end
-> Reduces this end
public export
data Finished : (term : Variant ctxt type)
-> Type
where
Normalised : {term : Variant ctxt type}
-> (this : Value term)
-> Finished term
OOF : Finished term
public export
data Evaluate : (term : Variant Nil type) -> Type where
RunEval : {this, that : Variant Nil type}
-> (steps : Inf (Reduces this that))
-> (result : Finished that)
-> Evaluate this
public export
data Fuel = Empty | More (Lazy Fuel)
public export
covering
forever : Fuel
forever = More forever
public export
compute : (fuel : Fuel)
-> (term : Variant Nil type)
-> Evaluate term
compute Empty term = RunEval Refl OOF
compute (More fuel) term with (progress term)
compute (More fuel) term | (Done value) = RunEval Refl (Normalised value)
compute (More fuel) term | (Step step {that}) with (compute fuel that)
compute (More fuel) term | (Step step {that = that}) | (RunEval steps result)
= RunEval (Trans step steps) result
public export
covering
run : (this : Variant Nil type)
-> Maybe (Subset (Variant Nil type) (Reduces this))
run this with (compute forever this)
run this | (RunEval steps (Normalised {term} x)) = Just (Element term steps)
run this | (RunEval steps OOF) = Nothing
namespace Examples
public export
ici : Variant Nil (TyVariant [("int", TyInt), ("char", TyChar)])
ici = Tag "int" (I 1) Here
public export
icc : Variant Nil (TyVariant [("int", TyInt), ("char", TyChar)])
icc = Tag "char" (C 'c') (There Here)
public export
iciM : Variant Nil TyInt
iciM = Match ici (Extend (MkCase "int" (Var Here)) (Singleton (MkCase "char" $ I 2)))
public export
iccM : Variant Nil TyInt
iccM = Match icc (Extend (MkCase "int" $ Var Here) (Singleton (MkCase "char" $ I 2)))
{-
public export
snip : Variant Nil TyInt
snip = (Match (Tag "int" (I 1) Here) (Extend (MkCase "int" (Var Here))
(Singleton (MkCase "char" (I 2)))))
-}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.